summaryrefslogtreecommitdiff
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/ARCMT/Common.h70
-rw-r--r--clang/test/ARCMT/GC-check-warn-nsalloc.m12
-rw-r--r--clang/test/ARCMT/GC-check.m20
-rw-r--r--clang/test/ARCMT/GC-no-arc-runtime.m78
-rw-r--r--clang/test/ARCMT/GC-no-arc-runtime.m.result73
-rw-r--r--clang/test/ARCMT/GC-no-finalize-removal.m90
-rw-r--r--clang/test/ARCMT/GC-no-finalize-removal.m.result98
-rw-r--r--clang/test/ARCMT/GC.h6
-rw-r--r--clang/test/ARCMT/GC.m95
-rw-r--r--clang/test/ARCMT/GC.m.result90
-rw-r--r--clang/test/ARCMT/Inputs/test.h15
-rw-r--r--clang/test/ARCMT/Inputs/test.h.result13
-rw-r--r--clang/test/ARCMT/Inputs/test1.m.in6
-rw-r--r--clang/test/ARCMT/Inputs/test1.m.in.result5
-rw-r--r--clang/test/ARCMT/Inputs/test2.m.in6
-rw-r--r--clang/test/ARCMT/Inputs/test2.m.in.result5
-rw-r--r--clang/test/ARCMT/api.m10
-rw-r--r--clang/test/ARCMT/api.m.result10
-rw-r--r--clang/test/ARCMT/assign-prop-no-arc-runtime.m15
-rw-r--r--clang/test/ARCMT/assign-prop-no-arc-runtime.m.result15
-rw-r--r--clang/test/ARCMT/assign-prop-with-arc-runtime.m73
-rw-r--r--clang/test/ARCMT/assign-prop-with-arc-runtime.m.result73
-rw-r--r--clang/test/ARCMT/atautorelease-2.m30
-rw-r--r--clang/test/ARCMT/atautorelease-2.m.result29
-rw-r--r--clang/test/ARCMT/atautorelease-3.m41
-rw-r--r--clang/test/ARCMT/atautorelease-3.m.result32
-rw-r--r--clang/test/ARCMT/atautorelease-check.m145
-rw-r--r--clang/test/ARCMT/atautorelease.m62
-rw-r--r--clang/test/ARCMT/atautorelease.m.result61
-rw-r--r--clang/test/ARCMT/autoreleases.m49
-rw-r--r--clang/test/ARCMT/autoreleases.m.result49
-rw-r--r--clang/test/ARCMT/check-api.m43
-rw-r--r--clang/test/ARCMT/check-with-serialized-diag.m55
-rw-r--r--clang/test/ARCMT/checking.m327
-rw-r--r--clang/test/ARCMT/cxx-checking.mm106
-rw-r--r--clang/test/ARCMT/cxx-rewrite.mm34
-rw-r--r--clang/test/ARCMT/cxx-rewrite.mm.result32
-rw-r--r--clang/test/ARCMT/dealloc.m25
-rw-r--r--clang/test/ARCMT/dealloc.m.result21
-rw-r--r--clang/test/ARCMT/dispatch.m29
-rw-r--r--clang/test/ARCMT/dispatch.m.result25
-rw-r--r--clang/test/ARCMT/driver-migrate.m12
-rw-r--r--clang/test/ARCMT/init.m40
-rw-r--r--clang/test/ARCMT/init.m.result40
-rw-r--r--clang/test/ARCMT/migrate-emit-errors.m12
-rw-r--r--clang/test/ARCMT/migrate-plist-output.m52
-rw-r--r--clang/test/ARCMT/migrate-space-in-path.m6
-rw-r--r--clang/test/ARCMT/migrate.m6
-rw-r--r--clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m43
-rw-r--r--clang/test/ARCMT/nonobjc-to-objc-cast-2.m35
-rw-r--r--clang/test/ARCMT/nonobjc-to-objc-cast.m62
-rw-r--r--clang/test/ARCMT/nonobjc-to-objc-cast.m.result62
-rw-r--r--clang/test/ARCMT/objcmt-numeric-literals.m501
-rw-r--r--clang/test/ARCMT/objcmt-numeric-literals.m.result501
-rw-r--r--clang/test/ARCMT/objcmt-subscripting-literals.m137
-rw-r--r--clang/test/ARCMT/objcmt-subscripting-literals.m.result137
-rw-r--r--clang/test/ARCMT/releases-driver.m68
-rw-r--r--clang/test/ARCMT/releases-driver.m.result61
-rw-r--r--clang/test/ARCMT/releases.m99
-rw-r--r--clang/test/ARCMT/releases.m.result90
-rw-r--r--clang/test/ARCMT/remove-dealloc-method.m26
-rw-r--r--clang/test/ARCMT/remove-dealloc-method.m.result20
-rw-r--r--clang/test/ARCMT/remove-dealloc-zerouts.m44
-rw-r--r--clang/test/ARCMT/remove-dealloc-zerouts.m.result39
-rw-r--r--clang/test/ARCMT/remove-statements.m45
-rw-r--r--clang/test/ARCMT/remove-statements.m.result38
-rw-r--r--clang/test/ARCMT/retains.m71
-rw-r--r--clang/test/ARCMT/retains.m.result65
-rw-r--r--clang/test/ARCMT/rewrite-block-var.m45
-rw-r--r--clang/test/ARCMT/rewrite-block-var.m.result45
-rw-r--r--clang/test/ARCMT/safe-arc-assign.m14
-rw-r--r--clang/test/ARCMT/safe-arc-assign.m.result14
-rw-r--r--clang/test/ARCMT/with space/test.h15
-rw-r--r--clang/test/ARCMT/with space/test.h.result13
-rw-r--r--clang/test/ARCMT/with space/test1.m.in6
-rw-r--r--clang/test/ARCMT/with space/test1.m.in.result5
-rw-r--r--clang/test/ARCMT/with space/test2.m.in6
-rw-r--r--clang/test/ARCMT/with space/test2.m.in.result5
-rw-r--r--clang/test/ARCMT/with-arc-mode-check.m9
-rw-r--r--clang/test/ARCMT/with-arc-mode-migrate.m13
-rw-r--r--clang/test/ARCMT/with-arc-mode-migrate.m.result12
-rw-r--r--clang/test/ARCMT/with-arc-mode-modify.m13
-rw-r--r--clang/test/ARCMT/with-arc-mode-modify.m.result12
-rw-r--r--clang/test/ASTMerge/Inputs/category1.m48
-rw-r--r--clang/test/ASTMerge/Inputs/category2.m49
-rw-r--r--clang/test/ASTMerge/Inputs/class-template1.cpp34
-rw-r--r--clang/test/ASTMerge/Inputs/class-template2.cpp35
-rw-r--r--clang/test/ASTMerge/Inputs/class1.cpp15
-rw-r--r--clang/test/ASTMerge/Inputs/class2.cpp9
-rw-r--r--clang/test/ASTMerge/Inputs/enum1.c42
-rw-r--r--clang/test/ASTMerge/Inputs/enum2.c42
-rw-r--r--clang/test/ASTMerge/Inputs/exprs1.c10
-rw-r--r--clang/test/ASTMerge/Inputs/exprs2.c10
-rw-r--r--clang/test/ASTMerge/Inputs/function1.c6
-rw-r--r--clang/test/ASTMerge/Inputs/function2.c7
-rw-r--r--clang/test/ASTMerge/Inputs/interface1.m103
-rw-r--r--clang/test/ASTMerge/Inputs/interface2.m100
-rw-r--r--clang/test/ASTMerge/Inputs/lit.local.cfg1
-rw-r--r--clang/test/ASTMerge/Inputs/namespace1.cpp17
-rw-r--r--clang/test/ASTMerge/Inputs/namespace2.cpp17
-rw-r--r--clang/test/ASTMerge/Inputs/property1.m31
-rw-r--r--clang/test/ASTMerge/Inputs/property2.m33
-rw-r--r--clang/test/ASTMerge/Inputs/struct1.c63
-rw-r--r--clang/test/ASTMerge/Inputs/struct2.c60
-rw-r--r--clang/test/ASTMerge/Inputs/typedef1.c4
-rw-r--r--clang/test/ASTMerge/Inputs/typedef2.c4
-rw-r--r--clang/test/ASTMerge/Inputs/var1.c7
-rw-r--r--clang/test/ASTMerge/Inputs/var1.h1
-rw-r--r--clang/test/ASTMerge/Inputs/var2.c7
-rw-r--r--clang/test/ASTMerge/category.m11
-rw-r--r--clang/test/ASTMerge/class-template.cpp24
-rw-r--r--clang/test/ASTMerge/class.cpp9
-rw-r--r--clang/test/ASTMerge/enum.c25
-rw-r--r--clang/test/ASTMerge/exprs.c4
-rw-r--r--clang/test/ASTMerge/function.c9
-rw-r--r--clang/test/ASTMerge/interface.m22
-rw-r--r--clang/test/ASTMerge/namespace.cpp6
-rw-r--r--clang/test/ASTMerge/property.m13
-rw-r--r--clang/test/ASTMerge/struct.c42
-rw-r--r--clang/test/ASTMerge/typedef.c7
-rw-r--r--clang/test/ASTMerge/var.c12
-rw-r--r--clang/test/Analysis/CFContainers.mm204
-rw-r--r--clang/test/Analysis/CFDateGC.m86
-rw-r--r--clang/test/Analysis/CFNumber.c34
-rw-r--r--clang/test/Analysis/CFRetainRelease_NSAssertionHandler.m73
-rw-r--r--clang/test/Analysis/CGColorSpace.c19
-rw-r--r--clang/test/Analysis/CheckNSError.m57
-rw-r--r--clang/test/Analysis/MissingDealloc.m117
-rw-r--r--clang/test/Analysis/NSPanel.m88
-rw-r--r--clang/test/Analysis/NSString.m408
-rw-r--r--clang/test/Analysis/NSWindow.m87
-rw-r--r--clang/test/Analysis/NoReturn.m78
-rw-r--r--clang/test/Analysis/OSAtomic_mac.cpp19
-rw-r--r--clang/test/Analysis/ObjCProperties.m21
-rw-r--r--clang/test/Analysis/ObjCRetSigs.m25
-rw-r--r--clang/test/Analysis/PR2599.m63
-rw-r--r--clang/test/Analysis/PR2978.m62
-rw-r--r--clang/test/Analysis/PR3991.m69
-rw-r--r--clang/test/Analysis/PR7218.c6
-rw-r--r--clang/test/Analysis/PR9741.cpp8
-rw-r--r--clang/test/Analysis/additive-folding-range-constraints.c99
-rw-r--r--clang/test/Analysis/additive-folding.c203
-rw-r--r--clang/test/Analysis/analyzeOneFunction.m56
-rw-r--r--clang/test/Analysis/analyze_display_progress.c9
-rw-r--r--clang/test/Analysis/analyzer-stats.c14
-rw-r--r--clang/test/Analysis/array-struct-region.c47
-rw-r--r--clang/test/Analysis/array-struct.c178
-rw-r--r--clang/test/Analysis/auto-obj-dtors-cfg-output.cpp864
-rw-r--r--clang/test/Analysis/base-init.cpp31
-rw-r--r--clang/test/Analysis/blocks.m90
-rw-r--r--clang/test/Analysis/bool-assignment.cpp87
-rw-r--r--clang/test/Analysis/bool-assignment2.c35
-rw-r--r--clang/test/Analysis/bstring.c430
-rw-r--r--clang/test/Analysis/casts.c67
-rw-r--r--clang/test/Analysis/casts.m42
-rw-r--r--clang/test/Analysis/cfref_PR2519.c46
-rw-r--r--clang/test/Analysis/cfref_rdar6080742.c56
-rw-r--r--clang/test/Analysis/check-deserialization.cpp20
-rw-r--r--clang/test/Analysis/chroot.c24
-rw-r--r--clang/test/Analysis/complex.c18
-rw-r--r--clang/test/Analysis/concrete-address.c6
-rw-r--r--clang/test/Analysis/constant-folding.c72
-rw-r--r--clang/test/Analysis/coverage.c94
-rw-r--r--clang/test/Analysis/cstring-syntax-cxx.cpp16
-rw-r--r--clang/test/Analysis/cstring-syntax.c13
-rw-r--r--clang/test/Analysis/cxx-crashes.cpp56
-rw-r--r--clang/test/Analysis/dead-stores.c550
-rw-r--r--clang/test/Analysis/dead-stores.cpp112
-rw-r--r--clang/test/Analysis/dead-stores.m90
-rw-r--r--clang/test/Analysis/debug-CallGraph.c21
-rw-r--r--clang/test/Analysis/default-analyze.m63
-rw-r--r--clang/test/Analysis/default-diagnostic-visitors.c13
-rw-r--r--clang/test/Analysis/delegates.m113
-rw-r--r--clang/test/Analysis/derived-to-base.cpp15
-rw-r--r--clang/test/Analysis/div-zero.cpp13
-rw-r--r--clang/test/Analysis/domtest.c165
-rw-r--r--clang/test/Analysis/dtor.cpp13
-rw-r--r--clang/test/Analysis/dtors-in-dtor-cfg-output.cpp56
-rw-r--r--clang/test/Analysis/dynamic-cast.cpp230
-rw-r--r--clang/test/Analysis/elementtype.c13
-rw-r--r--clang/test/Analysis/exercise-ps.c23
-rw-r--r--clang/test/Analysis/fields.c28
-rw-r--r--clang/test/Analysis/free.c72
-rw-r--r--clang/test/Analysis/func.c15
-rw-r--r--clang/test/Analysis/global-region-invalidation.c75
-rw-r--r--clang/test/Analysis/html-diags-multifile.c17
-rw-r--r--clang/test/Analysis/html-diags-multifile.h4
-rw-r--r--clang/test/Analysis/html-diags.c20
-rw-r--r--clang/test/Analysis/idempotent-operations-limited-loops.c21
-rw-r--r--clang/test/Analysis/idempotent-operations.c236
-rw-r--r--clang/test/Analysis/idempotent-operations.cpp34
-rw-r--r--clang/test/Analysis/idempotent-operations.m54
-rw-r--r--clang/test/Analysis/initializer.cpp14
-rw-r--r--clang/test/Analysis/initializers-cfg-output.cpp98
-rw-r--r--clang/test/Analysis/inline-not-supported.c29
-rw-r--r--clang/test/Analysis/inline-plist.c369
-rw-r--r--clang/test/Analysis/inline-unique-reports.c184
-rw-r--r--clang/test/Analysis/inline.c92
-rw-r--r--clang/test/Analysis/inline2.c14
-rw-r--r--clang/test/Analysis/inline3.c14
-rw-r--r--clang/test/Analysis/inline4.c14
-rw-r--r--clang/test/Analysis/iterators.cpp105
-rw-r--r--clang/test/Analysis/keychainAPI-diagnostic-visitor.m35
-rw-r--r--clang/test/Analysis/keychainAPI.m409
-rw-r--r--clang/test/Analysis/lambdas.cpp20
-rw-r--r--clang/test/Analysis/lvalue.cpp6
-rw-r--r--clang/test/Analysis/malloc-annotations.c271
-rw-r--r--clang/test/Analysis/malloc-interprocedural.c98
-rw-r--r--clang/test/Analysis/malloc-overflow.c113
-rw-r--r--clang/test/Analysis/malloc-overflow.cpp11
-rw-r--r--clang/test/Analysis/malloc-plist.c2814
-rw-r--r--clang/test/Analysis/malloc-sizeof.c27
-rw-r--r--clang/test/Analysis/malloc.c809
-rw-r--r--clang/test/Analysis/malloc.cpp16
-rw-r--r--clang/test/Analysis/malloc.m37
-rw-r--r--clang/test/Analysis/malloc.mm156
-rw-r--r--clang/test/Analysis/method-arg-decay.m97
-rw-r--r--clang/test/Analysis/method-call-intra-p.cpp32
-rw-r--r--clang/test/Analysis/method-call.cpp41
-rw-r--r--clang/test/Analysis/misc-ps-64.m47
-rw-r--r--clang/test/Analysis/misc-ps-cxx0x.cpp75
-rw-r--r--clang/test/Analysis/misc-ps-eager-assume.m146
-rw-r--r--clang/test/Analysis/misc-ps-ranges.m59
-rw-r--r--clang/test/Analysis/misc-ps-region-store-i386.m14
-rw-r--r--clang/test/Analysis/misc-ps-region-store-x86_64.m14
-rw-r--r--clang/test/Analysis/misc-ps-region-store.cpp580
-rw-r--r--clang/test/Analysis/misc-ps-region-store.m1343
-rw-r--r--clang/test/Analysis/misc-ps-region-store.mm48
-rw-r--r--clang/test/Analysis/misc-ps.c128
-rw-r--r--clang/test/Analysis/misc-ps.m1347
-rw-r--r--clang/test/Analysis/new.cpp15
-rw-r--r--clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m32
-rw-r--r--clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m95
-rw-r--r--clang/test/Analysis/no-exit-cfg.c18
-rw-r--r--clang/test/Analysis/no-outofbounds.c32
-rw-r--r--clang/test/Analysis/null-deref-ps-region.c14
-rw-r--r--clang/test/Analysis/null-deref-ps.c313
-rw-r--r--clang/test/Analysis/nullptr.cpp83
-rw-r--r--clang/test/Analysis/objc-arc.m220
-rw-r--r--clang/test/Analysis/objc-bool.m22
-rw-r--r--clang/test/Analysis/objc-method-coverage.m17
-rw-r--r--clang/test/Analysis/operator-calls.cpp16
-rw-r--r--clang/test/Analysis/out-of-bounds.c154
-rw-r--r--clang/test/Analysis/outofbound-notwork.c32
-rw-r--r--clang/test/Analysis/outofbound.c88
-rw-r--r--clang/test/Analysis/override-werror.c14
-rw-r--r--clang/test/Analysis/plist-output-alternate.m972
-rw-r--r--clang/test/Analysis/plist-output.m1339
-rw-r--r--clang/test/Analysis/pr4209.m72
-rw-r--r--clang/test/Analysis/pr_2542_rdar_6793404.m67
-rw-r--r--clang/test/Analysis/pr_4164.c40
-rw-r--r--clang/test/Analysis/properties.m168
-rw-r--r--clang/test/Analysis/pthreadlock.c137
-rw-r--r--clang/test/Analysis/ptr-arith.c288
-rw-r--r--clang/test/Analysis/rdar-6442306-1.m33
-rw-r--r--clang/test/Analysis/rdar-6540084.m37
-rw-r--r--clang/test/Analysis/rdar-6541136-region.c27
-rw-r--r--clang/test/Analysis/rdar-6562655.m64
-rw-r--r--clang/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m25
-rw-r--r--clang/test/Analysis/rdar-7168531.m18
-rw-r--r--clang/test/Analysis/redefined_system.c17
-rw-r--r--clang/test/Analysis/refcnt_naming.m84
-rw-r--r--clang/test/Analysis/reference.cpp58
-rw-r--r--clang/test/Analysis/region-1.m91
-rw-r--r--clang/test/Analysis/retain-release-gc-only.m387
-rw-r--r--clang/test/Analysis/retain-release-inline.m347
-rw-r--r--clang/test/Analysis/retain-release-path-notes-gc.m73
-rw-r--r--clang/test/Analysis/retain-release-path-notes.m132
-rw-r--r--clang/test/Analysis/retain-release-region-store.m257
-rw-r--r--clang/test/Analysis/retain-release.m1741
-rw-r--r--clang/test/Analysis/retain-release.mm368
-rw-r--r--clang/test/Analysis/security-syntax-checks-no-emit.c33
-rw-r--r--clang/test/Analysis/security-syntax-checks.m199
-rw-r--r--clang/test/Analysis/self-init.m256
-rw-r--r--clang/test/Analysis/sizeofpointer.c8
-rw-r--r--clang/test/Analysis/stack-addr-ps.c92
-rw-r--r--clang/test/Analysis/stack-addr-ps.cpp86
-rw-r--r--clang/test/Analysis/stack-block-returned.cpp9
-rw-r--r--clang/test/Analysis/stackaddrleak.c34
-rw-r--r--clang/test/Analysis/stats.c8
-rw-r--r--clang/test/Analysis/stream.c85
-rw-r--r--clang/test/Analysis/string-fail.c113
-rw-r--r--clang/test/Analysis/string.c1124
-rw-r--r--clang/test/Analysis/system-header-simulator-objc.h114
-rw-r--r--clang/test/Analysis/system-header-simulator.h38
-rw-r--r--clang/test/Analysis/taint-generic.c185
-rw-r--r--clang/test/Analysis/taint-tester.c204
-rw-r--r--clang/test/Analysis/taint-tester.cpp26
-rw-r--r--clang/test/Analysis/taint-tester.m20
-rw-r--r--clang/test/Analysis/temp-obj-dtors-cfg-output.cpp767
-rw-r--r--clang/test/Analysis/undef-buffers.c43
-rw-r--r--clang/test/Analysis/uninit-msg-expr.m56
-rw-r--r--clang/test/Analysis/uninit-ps-rdar6145427.m39
-rw-r--r--clang/test/Analysis/uninit-vals-ps-region.m78
-rw-r--r--clang/test/Analysis/uninit-vals-ps.c124
-rw-r--r--clang/test/Analysis/uninit-vals.m33
-rw-r--r--clang/test/Analysis/unions-region.m41
-rw-r--r--clang/test/Analysis/unix-fns.c138
-rw-r--r--clang/test/Analysis/unreachable-code-path.c141
-rw-r--r--clang/test/Analysis/unused-ivars.m110
-rw-r--r--clang/test/Analysis/variadic-method-types.m100
-rw-r--r--clang/test/Analysis/virtualcall.cpp53
-rw-r--r--clang/test/CMakeLists.txt117
-rw-r--r--clang/test/CXX/basic/basic.def.odr/p1-var.cpp21
-rw-r--r--clang/test/CXX/basic/basic.def.odr/p2-typeid.cpp36
-rw-r--r--clang/test/CXX/basic/basic.link/p9.cpp10
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp27
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp110
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp20
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp64
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp89
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p3.cpp30
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp60
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp18
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp27
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp65
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp41
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp25
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp35
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6-0x.cpp26
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp24
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp35
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p11.cpp12
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p12.cpp13
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p13.cpp8
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp18
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p15.cpp17
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp24
-rw-r--r--clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp37
-rw-r--r--clang/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp24
-rw-r--r--clang/test/CXX/basic/basic.scope/basic.scope.local/p4-0x.cpp68
-rw-r--r--clang/test/CXX/basic/basic.scope/basic.scope.pdecl/p3.cpp26
-rw-r--r--clang/test/CXX/basic/basic.scope/basic.scope.pdecl/p9.cpp18
-rw-r--r--clang/test/CXX/basic/basic.start/basic.start.main/p2a.cpp8
-rw-r--r--clang/test/CXX/basic/basic.start/basic.start.main/p2b.cpp8
-rw-r--r--clang/test/CXX/basic/basic.start/basic.start.main/p2c.cpp4
-rw-r--r--clang/test/CXX/basic/basic.start/basic.start.main/p2d.cpp4
-rw-r--r--clang/test/CXX/basic/basic.start/basic.start.main/p2e.cpp4
-rw-r--r--clang/test/CXX/basic/basic.start/basic.start.main/p2f.cpp7
-rw-r--r--clang/test/CXX/basic/basic.start/basic.start.main/p2g.cpp4
-rw-r--r--clang/test/CXX/basic/basic.start/basic.start.main/p2h.cpp5
-rw-r--r--clang/test/CXX/basic/basic.start/basic.start.main/p2i.cpp6
-rw-r--r--clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.allocation/p1.cpp44
-rw-r--r--clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p1.cpp11
-rw-r--r--clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-nodef.cpp7
-rw-r--r--clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp13
-rw-r--r--clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp28
-rw-r--r--clang/test/CXX/basic/basic.types/p10.cpp132
-rw-r--r--clang/test/CXX/class.access/class.access.base/p1.cpp155
-rw-r--r--clang/test/CXX/class.access/class.access.base/p5.cpp75
-rw-r--r--clang/test/CXX/class.access/class.access.dcl/p1.cpp199
-rw-r--r--clang/test/CXX/class.access/class.access.nest/p1.cpp33
-rw-r--r--clang/test/CXX/class.access/class.friend/p1.cpp356
-rw-r--r--clang/test/CXX/class.access/class.friend/p11.cpp19
-rw-r--r--clang/test/CXX/class.access/class.friend/p2-cxx03.cpp13
-rw-r--r--clang/test/CXX/class.access/class.friend/p3-cxx0x.cpp29
-rw-r--r--clang/test/CXX/class.access/class.friend/p6.cpp20
-rw-r--r--clang/test/CXX/class.access/class.protected/p1-cxx11.cpp20
-rw-r--r--clang/test/CXX/class.access/class.protected/p1.cpp519
-rw-r--r--clang/test/CXX/class.access/p4.cpp510
-rw-r--r--clang/test/CXX/class.access/p6.cpp192
-rw-r--r--clang/test/CXX/class.derived/class.abstract/p4.cpp80
-rw-r--r--clang/test/CXX/class.derived/class.abstract/p5.cpp23
-rw-r--r--clang/test/CXX/class.derived/class.member.lookup/p6.cpp40
-rw-r--r--clang/test/CXX/class.derived/class.member.lookup/p8.cpp63
-rw-r--r--clang/test/CXX/class.derived/class.member.lookup/p9.cpp28
-rw-r--r--clang/test/CXX/class.derived/class.virtual/p12.cpp19
-rw-r--r--clang/test/CXX/class.derived/class.virtual/p2.cpp37
-rw-r--r--clang/test/CXX/class.derived/class.virtual/p3-0x.cpp53
-rw-r--r--clang/test/CXX/class.derived/p1.cpp40
-rw-r--r--clang/test/CXX/class.derived/p2.cpp8
-rw-r--r--clang/test/CXX/class/class.base/class.base.init/p5-0x.cpp26
-rw-r--r--clang/test/CXX/class/class.bit/p2.cpp22
-rw-r--r--clang/test/CXX/class/class.friend/p1-ambiguous.cpp37
-rw-r--r--clang/test/CXX/class/class.friend/p1-cxx11.cpp12
-rw-r--r--clang/test/CXX/class/class.friend/p1.cpp77
-rw-r--r--clang/test/CXX/class/class.friend/p2.cpp10
-rw-r--r--clang/test/CXX/class/class.friend/p6.cpp10
-rw-r--r--clang/test/CXX/class/class.local/p1-0x.cpp18
-rw-r--r--clang/test/CXX/class/class.local/p1.cpp18
-rw-r--r--clang/test/CXX/class/class.local/p2.cpp11
-rw-r--r--clang/test/CXX/class/class.local/p3.cpp30
-rw-r--r--clang/test/CXX/class/class.local/p4.cpp10
-rw-r--r--clang/test/CXX/class/class.mem/p1.cpp91
-rw-r--r--clang/test/CXX/class/class.mem/p13.cpp40
-rw-r--r--clang/test/CXX/class/class.mem/p14.cpp19
-rw-r--r--clang/test/CXX/class/class.mem/p1b.cpp46
-rw-r--r--clang/test/CXX/class/class.mem/p2.cpp58
-rw-r--r--clang/test/CXX/class/class.mem/p5-0x.cpp9
-rw-r--r--clang/test/CXX/class/class.mem/p8-0x.cpp53
-rw-r--r--clang/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp98
-rw-r--r--clang/test/CXX/class/class.nest/p1-cxx0x.cpp14
-rw-r--r--clang/test/CXX/class/class.nest/p1.cpp14
-rw-r--r--clang/test/CXX/class/class.nest/p3.cpp25
-rw-r--r--clang/test/CXX/class/class.nested.type/p1.cpp13
-rw-r--r--clang/test/CXX/class/class.static/class.static.data/p3.cpp44
-rw-r--r--clang/test/CXX/class/class.static/class.static.data/p4.cpp25
-rw-r--r--clang/test/CXX/class/class.union/p1.cpp125
-rw-r--r--clang/test/CXX/class/class.union/p2-0x.cpp48
-rw-r--r--clang/test/CXX/class/p1-0x.cpp6
-rw-r--r--clang/test/CXX/class/p2-0x.cpp28
-rw-r--r--clang/test/CXX/class/p6-0x.cpp30
-rw-r--r--clang/test/CXX/conv/conv.mem/p4.cpp65
-rw-r--r--clang/test/CXX/conv/conv.prom/p2.cpp16
-rw-r--r--clang/test/CXX/conv/conv.prom/p4.cpp9
-rw-r--r--clang/test/CXX/conv/conv.ptr/p2.cpp6
-rw-r--r--clang/test/CXX/conv/conv.qual/pr6089.cpp18
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp93
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.unnamed/p1.cpp42
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp9
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p2.cpp24
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp13
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp118
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp110
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp34
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp91
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp163
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p13.cpp76
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3-cxx0x.cpp46
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp213
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp12
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp8
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp15
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8.cpp98
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp141
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p6.cpp15
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p6.cpp13
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.enum/p5.cpp56
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.link/p7.cpp30
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp123
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p2.cpp26
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp139
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp249
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp112
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp68
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp38
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp37
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp13
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp7
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp16
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp32
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp14
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp26
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp11
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp49
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp51
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp43
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp68
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp104
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp32
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp19
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp61
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp27
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp108
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp43
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp160
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p3.cpp8
-rw-r--r--clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p4.cpp15
-rw-r--r--clang/test/CXX/dcl.dcl/p4-0x.cpp21
-rw-r--r--clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp56
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp78
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp18
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp17
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp33
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp209
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp210
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp19
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p1.cpp14
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p3.cpp3
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp194
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp77
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx0x-no-extra-copy.cpp64
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp53
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp135
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp40
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.string/p1.cpp19
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/dcl.init.string/p2.cpp2
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/p14-0x.cpp44
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/p5.cpp20
-rw-r--r--clang/test/CXX/dcl.decl/dcl.init/p6.cpp28
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp7
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp54
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp16
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p2.cpp9
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p3.cpp13
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp55
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp19
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp33
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp7
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp4
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp62
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp48
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp31
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp7
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp3
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp53
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp20
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8-0x.cpp6
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp10
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp3
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp26
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp145
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp26
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp24
-rw-r--r--clang/test/CXX/dcl.decl/dcl.meaning/p1.cpp37
-rw-r--r--clang/test/CXX/dcl.decl/dcl.name/p1.cpp20
-rw-r--r--clang/test/CXX/dcl.decl/p4-0x.cpp8
-rw-r--r--clang/test/CXX/except/except.handle/p16.cpp40
-rw-r--r--clang/test/CXX/except/except.spec/canonical.cpp53
-rw-r--r--clang/test/CXX/except/except.spec/p1.cpp81
-rw-r--r--clang/test/CXX/except/except.spec/p11.cpp12
-rw-r--r--clang/test/CXX/except/except.spec/p14-ir.cpp79
-rw-r--r--clang/test/CXX/except/except.spec/p14.cpp41
-rw-r--r--clang/test/CXX/except/except.spec/p15.cpp24
-rw-r--r--clang/test/CXX/except/except.spec/p2-dynamic-types.cpp34
-rw-r--r--clang/test/CXX/except/except.spec/p2-places.cpp63
-rw-r--r--clang/test/CXX/except/except.spec/p3.cpp106
-rw-r--r--clang/test/CXX/except/except.spec/p5-pointers.cpp85
-rw-r--r--clang/test/CXX/except/except.spec/p5-virtual.cpp96
-rw-r--r--clang/test/CXX/except/except.spec/p9-dynamic.cpp12
-rw-r--r--clang/test/CXX/except/except.spec/p9-noexcept.cpp19
-rw-r--r--clang/test/CXX/except/except.spec/template.cpp12
-rw-r--r--clang/test/CXX/expr/expr.ass/p9-cxx11.cpp34
-rw-r--r--clang/test/CXX/expr/expr.cast/p4-0x.cpp11
-rw-r--r--clang/test/CXX/expr/expr.cast/p4.cpp23
-rw-r--r--clang/test/CXX/expr/expr.const/p2-0x.cpp596
-rw-r--r--clang/test/CXX/expr/expr.const/p3-0x-nowarn.cpp8
-rw-r--r--clang/test/CXX/expr/expr.const/p3-0x.cpp110
-rw-r--r--clang/test/CXX/expr/expr.const/p5-0x.cpp85
-rw-r--r--clang/test/CXX/expr/expr.mptr.oper/p5.cpp61
-rw-r--r--clang/test/CXX/expr/expr.mptr.oper/p6-0x.cpp34
-rw-r--r--clang/test/CXX/expr/expr.post/expr.call/p7-0x.cpp30
-rw-r--r--clang/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp17
-rw-r--r--clang/test/CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp14
-rw-r--r--clang/test/CXX/expr/expr.post/expr.ref/p3.cpp15
-rw-r--r--clang/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp16
-rw-r--r--clang/test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp24
-rw-r--r--clang/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp29
-rw-r--r--clang/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp12
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp38
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp101
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp20
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp78
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm88
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp50
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp40
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11.cpp16
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp77
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp16
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp75
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp12
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp40
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp45
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp28
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp42
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p20.cpp12
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p21.cpp9
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp58
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp6
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp51
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm8
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp64
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp22
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp56
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp29
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp149
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.delete/p5.cpp46
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.new/p17-crash.cpp14
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.new/p17.cpp16
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.new/p19.cpp46
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp23
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp13
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.new/p20.cpp141
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp38
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp26
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp189
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h8
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.unary.op/p3.cpp28
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp43
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp35
-rw-r--r--clang/test/CXX/expr/p3.cpp15
-rw-r--r--clang/test/CXX/expr/p8.cpp18
-rw-r--r--clang/test/CXX/expr/p9.cpp50
-rw-r--r--clang/test/CXX/lex/lex.charset/p2-cxx11.cpp42
-rw-r--r--clang/test/CXX/lex/lex.charset/p2-cxx98.cpp55
-rw-r--r--clang/test/CXX/lex/lex.literal/lex.ccon/p1.cpp16
-rw-r--r--clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp7
-rw-r--r--clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp14
-rw-r--r--clang/test/CXX/lex/lex.literal/lex.ext/p2.cpp16
-rw-r--r--clang/test/CXX/lex/lex.literal/lex.ext/p3.cpp18
-rw-r--r--clang/test/CXX/lex/lex.literal/lex.ext/p4.cpp18
-rw-r--r--clang/test/CXX/lex/lex.literal/lex.ext/p5.cpp13
-rw-r--r--clang/test/CXX/lex/lex.literal/lex.ext/p6.cpp14
-rw-r--r--clang/test/CXX/lex/lex.literal/lex.ext/p7.cpp27
-rw-r--r--clang/test/CXX/lex/lex.literal/lex.ext/p8.cpp18
-rw-r--r--clang/test/CXX/lex/lex.literal/lex.ext/p9.cpp13
-rw-r--r--clang/test/CXX/lex/lex.pptoken/p3-0x.cpp11
-rw-r--r--clang/test/CXX/lex/lex.trigraph/p1.cpp19
-rw-r--r--clang/test/CXX/lex/lex.trigraph/p2.cpp3
-rw-r--r--clang/test/CXX/lex/lex.trigraph/p3.cpp8
-rw-r--r--clang/test/CXX/over/over.built/p1.cpp16
-rw-r--r--clang/test/CXX/over/over.built/p23.cpp25
-rw-r--r--clang/test/CXX/over/over.built/p25.cpp15
-rw-r--r--clang/test/CXX/over/over.load/p2-0x.cpp24
-rw-r--r--clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp15
-rw-r--r--clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp14
-rw-r--r--clang/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp59
-rw-r--r--clang/test/CXX/over/over.match/over.match.best/p1.cpp16
-rw-r--r--clang/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp37
-rw-r--r--clang/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp70
-rw-r--r--clang/test/CXX/over/over.oper/over.literal/p2.cpp35
-rw-r--r--clang/test/CXX/over/over.oper/over.literal/p3.cpp40
-rw-r--r--clang/test/CXX/over/over.oper/over.literal/p5.cpp22
-rw-r--r--clang/test/CXX/over/over.oper/over.literal/p6.cpp13
-rw-r--r--clang/test/CXX/over/over.oper/over.literal/p7.cpp16
-rw-r--r--clang/test/CXX/over/over.oper/over.literal/p8.cpp19
-rw-r--r--clang/test/CXX/over/over.over/p1.cpp94
-rw-r--r--clang/test/CXX/over/over.over/p2-resolve-single-template-id.cpp191
-rw-r--r--clang/test/CXX/over/over.over/p2.cpp9
-rw-r--r--clang/test/CXX/over/over.over/p4.cpp20
-rw-r--r--clang/test/CXX/special/class.copy/implicit-move-def.cpp117
-rw-r--r--clang/test/CXX/special/class.copy/implicit-move.cpp236
-rw-r--r--clang/test/CXX/special/class.copy/p11.0x.copy.cpp121
-rw-r--r--clang/test/CXX/special/class.copy/p11.0x.move.cpp164
-rw-r--r--clang/test/CXX/special/class.copy/p13-0x.cpp60
-rw-r--r--clang/test/CXX/special/class.copy/p15-0x.cpp41
-rw-r--r--clang/test/CXX/special/class.copy/p15-inclass.cpp42
-rw-r--r--clang/test/CXX/special/class.copy/p20.cpp46
-rw-r--r--clang/test/CXX/special/class.copy/p3.cpp27
-rw-r--r--clang/test/CXX/special/class.copy/p33-0x.cpp57
-rw-r--r--clang/test/CXX/special/class.copy/p8-cxx11.cpp48
-rw-r--r--clang/test/CXX/special/class.copy/p9.cpp44
-rw-r--r--clang/test/CXX/special/class.ctor/p1.cpp42
-rw-r--r--clang/test/CXX/special/class.ctor/p4-0x.cpp7
-rw-r--r--clang/test/CXX/special/class.ctor/p5-0x.cpp182
-rw-r--r--clang/test/CXX/special/class.ctor/p6-0x.cpp57
-rw-r--r--clang/test/CXX/special/class.dtor/p10-0x.cpp39
-rw-r--r--clang/test/CXX/special/class.dtor/p2-0x.cpp10
-rw-r--r--clang/test/CXX/special/class.dtor/p2.cpp7
-rw-r--r--clang/test/CXX/special/class.dtor/p3-0x.cpp177
-rw-r--r--clang/test/CXX/special/class.dtor/p5-0x.cpp104
-rw-r--r--clang/test/CXX/special/class.dtor/p9.cpp85
-rw-r--r--clang/test/CXX/special/class.free/p1.cpp11
-rw-r--r--clang/test/CXX/special/class.free/p6.cpp11
-rw-r--r--clang/test/CXX/special/class.inhctor/elsewhere.cpp57
-rw-r--r--clang/test/CXX/special/class.inhctor/p3.cpp48
-rw-r--r--clang/test/CXX/special/class.inhctor/p7.cpp29
-rw-r--r--clang/test/CXX/special/class.init/class.base.init/p8-0x.cpp62
-rw-r--r--clang/test/CXX/special/class.init/class.base.init/p9-0x.cpp36
-rw-r--r--clang/test/CXX/special/class.temporary/p1.cpp57
-rw-r--r--clang/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp40
-rw-r--r--clang/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp55
-rw-r--r--clang/test/CXX/stmt.stmt/stmt.dcl/p3.cpp47
-rw-r--r--clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp209
-rw-r--r--clang/test/CXX/stmt.stmt/stmt.label/p1.cpp25
-rw-r--r--clang/test/CXX/stmt.stmt/stmt.select/p3.cpp19
-rw-r--r--clang/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp39
-rw-r--r--clang/test/CXX/temp/p3.cpp18
-rw-r--r--clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp60
-rw-r--r--clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp95
-rw-r--r--clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp205
-rw-r--r--clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp40
-rw-r--r--clang/test/CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp20
-rw-r--r--clang/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp42
-rw-r--r--clang/test/CXX/temp/temp.decls/p3.cpp7
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.alias/p1.cpp8
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.alias/p2.cpp45
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.alias/p3.cpp13
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp76
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp8
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp13
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class.spec/p9.cpp26
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp48
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1-neg.cpp25
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1.cpp25
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class/temp.mem.class/p1.cpp27
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class/temp.mem.enum/p1.cpp152
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1-retmem.cpp28
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp100
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp17
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/pr5056.cpp17
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1-inst.cpp28
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp26
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3-0x.cpp17
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp16
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p4.cpp23
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p5.cpp12
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4-neg.cpp27
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4.cpp13
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p6.cpp16
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp358
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.friend/p3.cpp12
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.friend/p4.cpp28
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.friend/p5.cpp103
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.friend/p8.cpp6
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.mem/p1.cpp35
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp6
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp79
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp50
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/example-bind.cpp352
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/example-function.cpp86
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/example-tuple.cpp260
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp46
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp127
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp75
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp274
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp251
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/p1.cpp9
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/p2.cpp22
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp193
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp403
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp43
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.variadic/partial-ordering.cpp61
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p1.cpp12
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp27
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-nodeduct.cpp36
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp65
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp68
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/cwg1170.cpp41
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp26
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp42
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp30
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p1-0x.cpp88
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p2.cpp31
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp46
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp148
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp20
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp128
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p2.cpp36
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p3.cpp30
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp44
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.funcaddr/p1.cpp22
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p11.cpp47
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp27
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p9-0x.cpp10
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p10-0x.cpp4
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p17.cpp31
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p2-0x.cpp23
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp31
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p22.cpp14
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p5-0x.cpp22
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p8-0x.cpp47
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp55
-rw-r--r--clang/test/CXX/temp/temp.names/p2.cpp13
-rw-r--r--clang/test/CXX/temp/temp.names/p4.cpp15
-rw-r--r--clang/test/CXX/temp/temp.param/p1.cpp12
-rw-r--r--clang/test/CXX/temp/temp.param/p10-0x.cpp13
-rw-r--r--clang/test/CXX/temp/temp.param/p10.cpp12
-rw-r--r--clang/test/CXX/temp/temp.param/p11-0x.cpp81
-rw-r--r--clang/test/CXX/temp/temp.param/p11.cpp15
-rw-r--r--clang/test/CXX/temp/temp.param/p12.cpp39
-rw-r--r--clang/test/CXX/temp/temp.param/p13.cpp14
-rw-r--r--clang/test/CXX/temp/temp.param/p14.cpp5
-rw-r--r--clang/test/CXX/temp/temp.param/p15-cxx0x.cpp24
-rw-r--r--clang/test/CXX/temp/temp.param/p15.cpp12
-rw-r--r--clang/test/CXX/temp/temp.param/p2.cpp22
-rw-r--r--clang/test/CXX/temp/temp.param/p3.cpp40
-rw-r--r--clang/test/CXX/temp/temp.param/p4.cpp21
-rw-r--r--clang/test/CXX/temp/temp.param/p5.cpp13
-rw-r--r--clang/test/CXX/temp/temp.param/p7.cpp15
-rw-r--r--clang/test/CXX/temp/temp.param/p8.cpp6
-rw-r--r--clang/test/CXX/temp/temp.param/p9-0x.cpp61
-rw-r--r--clang/test/CXX/temp/temp.param/p9.cpp23
-rw-r--r--clang/test/CXX/temp/temp.res/temp.dep.res/temp.point/p1.cpp32
-rw-r--r--clang/test/CXX/temp/temp.res/temp.dep/p3.cpp43
-rw-r--r--clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp27
-rw-r--r--clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp21
-rw-r--r--clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp30
-rw-r--r--clang/test/CXX/temp/temp.res/temp.local/p1.cpp32
-rw-r--r--clang/test/CXX/temp/temp.res/temp.local/p3.cpp32
-rw-r--r--clang/test/CXX/temp/temp.res/temp.local/p7.cpp10
-rw-r--r--clang/test/CXX/temp/temp.res/temp.local/p8.cpp53
-rw-r--r--clang/test/CXX/temp/temp.res/temp.local/p9.cpp15
-rw-r--r--clang/test/CXX/temp/temp.spec/p5.cpp47
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp334
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p1.cpp99
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p10.cpp7
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p11.cpp8
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p13.cpp6
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp42
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp33
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p16.cpp38
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp34
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp20
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p19.cpp30
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp302
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp252
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp14
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p21.cpp30
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp13
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp58
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p5-example.cpp34
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p5.cpp61
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p6.cpp63
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.expl.spec/p9.cpp14
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp24
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p1-emit.cpp29
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp89
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p10.cpp33
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p11.cpp18
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p12.cpp6
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p2.cpp43
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p3-0x.cpp65
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p3.cpp81
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p4.cpp48
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p5.cpp17
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p6.cpp35
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p7.cpp36
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p8.cpp40
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp66
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.explicit/p9.cpp59
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.inst/p1.cpp104
-rw-r--r--clang/test/CXX/temp/temp.spec/temp.inst/p11.cpp15
-rw-r--r--clang/test/CXX/temp/temp.type/p1-0x.cpp23
-rw-r--r--clang/test/CodeCompletion/Inputs/macros.h4
-rw-r--r--clang/test/CodeCompletion/Inputs/reserved.h2
-rw-r--r--clang/test/CodeCompletion/PR9728.cpp9
-rw-r--r--clang/test/CodeCompletion/call.c15
-rw-r--r--clang/test/CodeCompletion/call.cpp28
-rw-r--r--clang/test/CodeCompletion/enum-switch-case-qualified.cpp32
-rw-r--r--clang/test/CodeCompletion/enum-switch-case.c45
-rw-r--r--clang/test/CodeCompletion/enum-switch-case.cpp28
-rw-r--r--clang/test/CodeCompletion/function-templates.cpp23
-rw-r--r--clang/test/CodeCompletion/functions.cpp8
-rw-r--r--clang/test/CodeCompletion/macros.c34
-rw-r--r--clang/test/CodeCompletion/member-access.c12
-rw-r--r--clang/test/CodeCompletion/member-access.cpp42
-rw-r--r--clang/test/CodeCompletion/namespace-alias.cpp20
-rw-r--r--clang/test/CodeCompletion/namespace.cpp14
-rw-r--r--clang/test/CodeCompletion/nested-name-specifier.cpp17
-rw-r--r--clang/test/CodeCompletion/objc-message.m35
-rw-r--r--clang/test/CodeCompletion/operator.cpp17
-rw-r--r--clang/test/CodeCompletion/ordinary-name.c17
-rw-r--r--clang/test/CodeCompletion/ordinary-name.cpp229
-rw-r--r--clang/test/CodeCompletion/preamble.c7
-rw-r--r--clang/test/CodeCompletion/some_struct.h1
-rw-r--r--clang/test/CodeCompletion/stdin.c7
-rw-r--r--clang/test/CodeCompletion/tag.c12
-rw-r--r--clang/test/CodeCompletion/tag.cpp27
-rw-r--r--clang/test/CodeCompletion/templates.cpp28
-rw-r--r--clang/test/CodeCompletion/truncation.c15
-rw-r--r--clang/test/CodeCompletion/truncation.c.h5
-rw-r--r--clang/test/CodeCompletion/using-namespace.cpp20
-rw-r--r--clang/test/CodeCompletion/using.cpp24
-rw-r--r--clang/test/CodeGen/2002-01-23-LoadQISIReloadFailure.c11
-rw-r--r--clang/test/CodeGen/2002-01-24-ComplexSpaceInType.c11
-rw-r--r--clang/test/CodeGen/2002-01-24-HandleCallInsnSEGV.c9
-rw-r--r--clang/test/CodeGen/2002-02-13-ConditionalInCall.c11
-rw-r--r--clang/test/CodeGen/2002-02-13-ReloadProblem.c18
-rw-r--r--clang/test/CodeGen/2002-02-13-TypeVarNameCollision.c16
-rw-r--r--clang/test/CodeGen/2002-02-13-UnnamedLocal.c21
-rw-r--r--clang/test/CodeGen/2002-02-14-EntryNodePreds.c37
-rw-r--r--clang/test/CodeGen/2002-02-16-RenamingTest.c18
-rw-r--r--clang/test/CodeGen/2002-02-17-ArgumentAddress.c39
-rw-r--r--clang/test/CodeGen/2002-02-18-64bitConstant.c10
-rw-r--r--clang/test/CodeGen/2002-02-18-StaticData.c13
-rw-r--r--clang/test/CodeGen/2002-03-11-LargeCharInString.c10
-rw-r--r--clang/test/CodeGen/2002-03-12-ArrayInitialization.c19
-rw-r--r--clang/test/CodeGen/2002-03-12-StructInitialize.c14
-rw-r--r--clang/test/CodeGen/2002-03-12-StructInitializer.c18
-rw-r--r--clang/test/CodeGen/2002-03-14-BrokenPHINode.c19
-rw-r--r--clang/test/CodeGen/2002-03-14-BrokenSSA.c17
-rw-r--r--clang/test/CodeGen/2002-03-14-QuotesInStrConst.c10
-rw-r--r--clang/test/CodeGen/2002-04-07-SwitchStmt.c22
-rw-r--r--clang/test/CodeGen/2002-04-08-LocalArray.c14
-rw-r--r--clang/test/CodeGen/2002-04-09-StructRetVal.c12
-rw-r--r--clang/test/CodeGen/2002-04-10-StructParameters.c25
-rw-r--r--clang/test/CodeGen/2002-05-23-StaticValues.c15
-rw-r--r--clang/test/CodeGen/2002-05-23-TypeNameCollision.c19
-rw-r--r--clang/test/CodeGen/2002-05-24-Alloca.c11
-rw-r--r--clang/test/CodeGen/2002-06-25-FWriteInterfaceFailure.c9
-rw-r--r--clang/test/CodeGen/2002-07-14-MiscListTests.c71
-rw-r--r--clang/test/CodeGen/2002-07-14-MiscTests.c57
-rw-r--r--clang/test/CodeGen/2002-07-14-MiscTests2.c13
-rw-r--r--clang/test/CodeGen/2002-07-14-MiscTests3.c182
-rw-r--r--clang/test/CodeGen/2002-07-16-HardStringInit.c8
-rw-r--r--clang/test/CodeGen/2002-07-17-StringConstant.c4
-rw-r--r--clang/test/CodeGen/2002-07-30-SubregSetAssertion.c12
-rw-r--r--clang/test/CodeGen/2002-07-30-UnionTest.c22
-rw-r--r--clang/test/CodeGen/2002-07-30-VarArgsCallFailure.c8
-rw-r--r--clang/test/CodeGen/2002-07-31-BadAssert.c16
-rw-r--r--clang/test/CodeGen/2002-07-31-SubregFailure.c14
-rw-r--r--clang/test/CodeGen/2002-08-02-UnionTest.c19
-rw-r--r--clang/test/CodeGen/2002-08-19-RecursiveLocals.c18
-rw-r--r--clang/test/CodeGen/2002-09-08-PointerShifts.c6
-rw-r--r--clang/test/CodeGen/2002-09-18-UnionProblem.c26
-rw-r--r--clang/test/CodeGen/2002-09-19-StarInLabel.c9
-rw-r--r--clang/test/CodeGen/2002-10-12-TooManyArguments.c8
-rw-r--r--clang/test/CodeGen/2002-12-15-GlobalBoolTest.c5
-rw-r--r--clang/test/CodeGen/2002-12-15-GlobalConstantTest.c8
-rw-r--r--clang/test/CodeGen/2002-12-15-GlobalRedefinition.c5
-rw-r--r--clang/test/CodeGen/2002-12-15-StructParameters.c18
-rw-r--r--clang/test/CodeGen/2003-01-30-UnionInit.c8
-rw-r--r--clang/test/CodeGen/2003-03-03-DeferredType.c12
-rw-r--r--clang/test/CodeGen/2003-06-22-UnionCrash.c13
-rw-r--r--clang/test/CodeGen/2003-06-23-GCC-fold-infinite-recursion.c6
-rw-r--r--clang/test/CodeGen/2003-06-26-CFECrash.c19
-rw-r--r--clang/test/CodeGen/2003-06-29-MultipleFunctionDefinition.c8
-rw-r--r--clang/test/CodeGen/2003-07-22-ArrayAccessTypeSafety.c7
-rw-r--r--clang/test/CodeGen/2003-08-06-BuiltinSetjmpLongjmp.c14
-rw-r--r--clang/test/CodeGen/2003-08-17-DeadCodeShortCircuit.c6
-rw-r--r--clang/test/CodeGen/2003-08-18-SigSetJmp.c10
-rw-r--r--clang/test/CodeGen/2003-08-18-StructAsValue.c11
-rw-r--r--clang/test/CodeGen/2003-08-20-BadBitfieldRef.c8
-rw-r--r--clang/test/CodeGen/2003-08-20-PrototypeMismatch.c15
-rw-r--r--clang/test/CodeGen/2003-08-20-vfork-bug.c6
-rw-r--r--clang/test/CodeGen/2003-08-21-BinOp-Type-Mismatch.c10
-rw-r--r--clang/test/CodeGen/2003-08-21-StmtExpr.c12
-rw-r--r--clang/test/CodeGen/2003-08-21-WideString.c16
-rw-r--r--clang/test/CodeGen/2003-08-23-LocalUnionTest.c11
-rw-r--r--clang/test/CodeGen/2003-08-29-BitFieldStruct.c13
-rw-r--r--clang/test/CodeGen/2003-08-29-HugeCharConst.c5
-rw-r--r--clang/test/CodeGen/2003-08-29-StructLayoutBug.c10
-rw-r--r--clang/test/CodeGen/2003-08-30-AggregateInitializer.c16
-rw-r--r--clang/test/CodeGen/2003-08-30-LargeIntegerBitfieldMember.c9
-rw-r--r--clang/test/CodeGen/2003-09-18-BitfieldTests.c30
-rw-r--r--clang/test/CodeGen/2003-09-30-StructLayout.c18
-rw-r--r--clang/test/CodeGen/2003-10-02-UnionLValueError.c11
-rw-r--r--clang/test/CodeGen/2003-10-06-NegateExprType.c8
-rw-r--r--clang/test/CodeGen/2003-10-09-UnionInitializerBug.c17
-rw-r--r--clang/test/CodeGen/2003-10-28-ident.c4
-rw-r--r--clang/test/CodeGen/2003-10-29-AsmRename.c22
-rw-r--r--clang/test/CodeGen/2003-11-01-C99-CompoundLiteral.c8
-rw-r--r--clang/test/CodeGen/2003-11-01-EmptyStructCrash.c6
-rw-r--r--clang/test/CodeGen/2003-11-01-GlobalUnionInit.c7
-rw-r--r--clang/test/CodeGen/2003-11-03-AddrArrayElement.c11
-rw-r--r--clang/test/CodeGen/2003-11-04-EmptyStruct.c6
-rw-r--r--clang/test/CodeGen/2003-11-04-OutOfMemory.c9
-rw-r--r--clang/test/CodeGen/2003-11-08-PointerSubNotGetelementptr.c10
-rw-r--r--clang/test/CodeGen/2003-11-12-VoidString.c4
-rw-r--r--clang/test/CodeGen/2003-11-13-TypeSafety.c5
-rw-r--r--clang/test/CodeGen/2003-11-16-StaticArrayInit.c8
-rw-r--r--clang/test/CodeGen/2003-11-18-CondExprLValue.c9
-rw-r--r--clang/test/CodeGen/2003-11-19-AddressOfRegister.c11
-rw-r--r--clang/test/CodeGen/2003-11-19-BitFieldArray.c12
-rw-r--r--clang/test/CodeGen/2003-11-20-Bitfields.c12
-rw-r--r--clang/test/CodeGen/2003-11-20-ComplexDivision.c7
-rw-r--r--clang/test/CodeGen/2003-11-20-UnionBitfield.c12
-rw-r--r--clang/test/CodeGen/2003-11-26-PointerShift.c6
-rw-r--r--clang/test/CodeGen/2003-11-27-ConstructorCast.c14
-rw-r--r--clang/test/CodeGen/2003-11-27-UnionCtorInitialization.c16
-rw-r--r--clang/test/CodeGen/2003-12-14-ExternInlineSupport.c3
-rw-r--r--clang/test/CodeGen/2004-01-01-UnknownInitSize.c14
-rw-r--r--clang/test/CodeGen/2004-01-08-ExternInlineRedefine.c14
-rw-r--r--clang/test/CodeGen/2004-02-12-LargeAggregateCopy.c8
-rw-r--r--clang/test/CodeGen/2004-02-13-BuiltinFrameReturnAddress.c10
-rw-r--r--clang/test/CodeGen/2004-02-13-IllegalVararg.c9
-rw-r--r--clang/test/CodeGen/2004-02-13-Memset.c12
-rw-r--r--clang/test/CodeGen/2004-02-14-ZeroInitializer.c4
-rw-r--r--clang/test/CodeGen/2004-02-20-Builtins.c5
-rw-r--r--clang/test/CodeGen/2004-03-07-ComplexDivEquals.c6
-rw-r--r--clang/test/CodeGen/2004-03-07-ExternalConstant.c7
-rw-r--r--clang/test/CodeGen/2004-03-09-LargeArrayInitializers.c32
-rw-r--r--clang/test/CodeGen/2004-03-15-SimpleIndirectGoto.c23
-rw-r--r--clang/test/CodeGen/2004-03-16-AsmRegisterCrash.c12
-rw-r--r--clang/test/CodeGen/2004-05-07-VarArrays.c5
-rw-r--r--clang/test/CodeGen/2004-05-21-IncompleteEnum.c5
-rw-r--r--clang/test/CodeGen/2004-06-08-OpaqueStructArg.c7
-rw-r--r--clang/test/CodeGen/2004-06-17-UnorderedBuiltins.c24
-rw-r--r--clang/test/CodeGen/2004-06-17-UnorderedCompares.c19
-rw-r--r--clang/test/CodeGen/2004-06-18-VariableLengthArrayOfStructures.c10
-rw-r--r--clang/test/CodeGen/2004-07-06-FunctionCast.c10
-rw-r--r--clang/test/CodeGen/2004-08-06-LargeStructTest.c19
-rw-r--r--clang/test/CodeGen/2004-11-25-UnnamedBitfieldPadding.c8
-rw-r--r--clang/test/CodeGen/2004-11-27-InvalidConstantExpr.c10
-rw-r--r--clang/test/CodeGen/2004-11-27-StaticFunctionRedeclare.c15
-rw-r--r--clang/test/CodeGen/2005-01-02-ConstantInits.c24
-rw-r--r--clang/test/CodeGen/2005-01-02-PointerDifference.c4
-rw-r--r--clang/test/CodeGen/2005-01-02-VAArgError-ICE.c9
-rw-r--r--clang/test/CodeGen/2005-02-20-AggregateSAVEEXPR.c5
-rw-r--r--clang/test/CodeGen/2005-02-27-MarkGlobalConstant.c12
-rw-r--r--clang/test/CodeGen/2005-03-05-OffsetOfHack.c12
-rw-r--r--clang/test/CodeGen/2005-03-06-OffsetOfStructCrash.c14
-rw-r--r--clang/test/CodeGen/2005-03-11-Prefetch.c7
-rw-r--r--clang/test/CodeGen/2005-04-09-ComplexOps.c8
-rw-r--r--clang/test/CodeGen/2005-05-10-GlobalUnionInit.c6
-rw-r--r--clang/test/CodeGen/2005-06-15-ExpandGotoInternalProblem.c14
-rw-r--r--clang/test/CodeGen/2005-07-20-SqrtNoErrno.c10
-rw-r--r--clang/test/CodeGen/2005-07-26-UnionInitCrash.c3
-rw-r--r--clang/test/CodeGen/2005-07-28-IncorrectWeakGlobal.c5
-rw-r--r--clang/test/CodeGen/2005-09-20-ComplexConstants.c4
-rw-r--r--clang/test/CodeGen/2005-09-24-AsmUserPrefix.c8
-rw-r--r--clang/test/CodeGen/2005-09-24-BitFieldCrash.c33
-rw-r--r--clang/test/CodeGen/2005-12-04-AttributeUsed.c7
-rw-r--r--clang/test/CodeGen/2005-12-04-DeclarationLineNumbers.c23
-rw-r--r--clang/test/CodeGen/2006-01-13-Includes.c10
-rw-r--r--clang/test/CodeGen/2006-01-13-StackSave.c11
-rw-r--r--clang/test/CodeGen/2006-01-16-BitCountIntrinsicsUnsigned.c12
-rw-r--r--clang/test/CodeGen/2006-01-23-FileScopeAsm.c12
-rw-r--r--clang/test/CodeGen/2006-03-03-MissingInitializer.c10
-rw-r--r--clang/test/CodeGen/2006-03-16-VectorCtor.c10
-rw-r--r--clang/test/CodeGen/2006-03-17-KnRMismatch.c8
-rw-r--r--clang/test/CodeGen/2006-05-19-SingleEltReturn.c23
-rw-r--r--clang/test/CodeGen/2006-07-31-PR854.c12
-rw-r--r--clang/test/CodeGen/2006-09-11-BitfieldRefCrash.c12
-rw-r--r--clang/test/CodeGen/2006-09-18-fwrite-cast-crash.c12
-rw-r--r--clang/test/CodeGen/2006-09-21-IncompleteElementType.c3
-rw-r--r--clang/test/CodeGen/2006-09-25-DebugFilename.c4
-rw-r--r--clang/test/CodeGen/2006-09-25-DebugFilename.h6
-rw-r--r--clang/test/CodeGen/2006-09-28-SimpleAsm.c12
-rw-r--r--clang/test/CodeGen/2006-10-30-ArrayCrash.c17
-rw-r--r--clang/test/CodeGen/2006-12-14-ordered_expr.c6
-rw-r--r--clang/test/CodeGen/2007-01-06-KNR-Proto.c10
-rw-r--r--clang/test/CodeGen/2007-01-20-VectorICE.c11
-rw-r--r--clang/test/CodeGen/2007-01-24-InlineAsmCModifier.c12
-rw-r--r--clang/test/CodeGen/2007-02-04-AddrLValue-2.c13
-rw-r--r--clang/test/CodeGen/2007-02-04-AddrLValue.c23
-rw-r--r--clang/test/CodeGen/2007-02-04-EmptyStruct.c9
-rw-r--r--clang/test/CodeGen/2007-02-07-AddrLabel.c10
-rw-r--r--clang/test/CodeGen/2007-02-16-VoidPtrDiff.c5
-rw-r--r--clang/test/CodeGen/2007-02-25-C-DotDotDot.c10
-rw-r--r--clang/test/CodeGen/2007-03-01-VarSizeArrayIdx.c7
-rw-r--r--clang/test/CodeGen/2007-03-05-DataLayout.c55
-rw-r--r--clang/test/CodeGen/2007-03-26-BitfieldAfterZeroWidth.c6
-rw-r--r--clang/test/CodeGen/2007-03-26-ZeroWidthBitfield.c2
-rw-r--r--clang/test/CodeGen/2007-03-27-VarLengthArray.c9
-rw-r--r--clang/test/CodeGen/2007-04-05-PackedBitFields-2.c16
-rw-r--r--clang/test/CodeGen/2007-04-05-PackedBitFields.c16
-rw-r--r--clang/test/CodeGen/2007-04-05-PackedStruct.c18
-rw-r--r--clang/test/CodeGen/2007-04-05-PadBeforeZeroLengthField.c9
-rw-r--r--clang/test/CodeGen/2007-04-05-UnPackedStruct.c16
-rw-r--r--clang/test/CodeGen/2007-04-11-InlineAsmStruct.c8
-rw-r--r--clang/test/CodeGen/2007-04-11-InlineAsmUnion.c7
-rw-r--r--clang/test/CodeGen/2007-04-11-PR1321.c12
-rw-r--r--clang/test/CodeGen/2007-04-13-InlineAsmStruct2.c9
-rw-r--r--clang/test/CodeGen/2007-04-13-InlineAsmUnion2.c8
-rw-r--r--clang/test/CodeGen/2007-04-14-FNoBuiltin.c7
-rw-r--r--clang/test/CodeGen/2007-04-17-ZeroSizeBitFields.c4
-rw-r--r--clang/test/CodeGen/2007-04-24-VolatileStructCopy.c11
-rw-r--r--clang/test/CodeGen/2007-04-24-bit-not-expr.c7
-rw-r--r--clang/test/CodeGen/2007-04-24-str-const.c17
-rw-r--r--clang/test/CodeGen/2007-05-07-PaddingElements.c12
-rw-r--r--clang/test/CodeGen/2007-05-08-PCH.c7
-rw-r--r--clang/test/CodeGen/2007-05-11-str-const.c5
-rw-r--r--clang/test/CodeGen/2007-05-15-PaddingElement.c23
-rw-r--r--clang/test/CodeGen/2007-05-16-EmptyStruct.c5
-rw-r--r--clang/test/CodeGen/2007-05-29-UnionCopy.c18
-rw-r--r--clang/test/CodeGen/2007-06-05-NoInlineAttribute.c13
-rw-r--r--clang/test/CodeGen/2007-06-15-AnnotateAttribute.c21
-rw-r--r--clang/test/CodeGen/2007-06-18-SextAttrAggregate.c12
-rw-r--r--clang/test/CodeGen/2007-07-29-RestrictPtrArg.c6
-rw-r--r--clang/test/CodeGen/2007-08-01-LoadStoreAlign.c18
-rw-r--r--clang/test/CodeGen/2007-08-21-ComplexCst.c3
-rw-r--r--clang/test/CodeGen/2007-08-22-CTTZ.c8
-rw-r--r--clang/test/CodeGen/2007-09-05-ConstCtor.c14
-rw-r--r--clang/test/CodeGen/2007-09-12-PragmaPack.c32
-rw-r--r--clang/test/CodeGen/2007-09-14-NegatePointer.c7
-rw-r--r--clang/test/CodeGen/2007-09-17-WeakRef.c10
-rw-r--r--clang/test/CodeGen/2007-09-26-Alignment.c8
-rw-r--r--clang/test/CodeGen/2007-09-27-ComplexIntCompare.c15
-rw-r--r--clang/test/CodeGen/2007-09-28-PackedUnionMember.c38
-rw-r--r--clang/test/CodeGen/2007-10-02-VolatileArray.c7
-rw-r--r--clang/test/CodeGen/2007-10-15-VoidPtr.c4
-rw-r--r--clang/test/CodeGen/2007-10-30-Volatile.c6
-rw-r--r--clang/test/CodeGen/2007-11-07-AlignedMemcpy.c4
-rw-r--r--clang/test/CodeGen/2007-11-07-CopyAggregateAlign.c7
-rw-r--r--clang/test/CodeGen/2007-11-07-ZeroAggregateAlign.c5
-rw-r--r--clang/test/CodeGen/2007-11-28-GlobalInitializer.c8
-rw-r--r--clang/test/CodeGen/2007-11-29-ArraySizeFromInitializer.c4
-rw-r--r--clang/test/CodeGen/2007-12-16-AsmNoUnwind.c3
-rw-r--r--clang/test/CodeGen/2008-01-04-WideBitfield.c12
-rw-r--r--clang/test/CodeGen/2008-01-07-UnusualIntSize.c15
-rw-r--r--clang/test/CodeGen/2008-01-11-ChainConsistency.c3
-rw-r--r--clang/test/CodeGen/2008-01-21-PackedBitFields.c7
-rw-r--r--clang/test/CodeGen/2008-01-21-PackedStructField.c18
-rw-r--r--clang/test/CodeGen/2008-01-24-StructAlignAndBitFields.c4
-rw-r--r--clang/test/CodeGen/2008-01-25-ByValReadNone.c16
-rw-r--r--clang/test/CodeGen/2008-01-25-ZeroSizedAggregate.c39
-rw-r--r--clang/test/CodeGen/2008-01-28-PragmaMark.c6
-rw-r--r--clang/test/CodeGen/2008-01-28-UnionSize.c24
-rw-r--r--clang/test/CodeGen/2008-02-07-bitfield-bug.c11
-rw-r--r--clang/test/CodeGen/2008-02-08-bitfield-bug.c9
-rw-r--r--clang/test/CodeGen/2008-02-26-inline-asm-bug.c6
-rw-r--r--clang/test/CodeGen/2008-03-03-CtorAttrType.c6
-rw-r--r--clang/test/CodeGen/2008-03-05-syncPtr.c40
-rw-r--r--clang/test/CodeGen/2008-03-24-BitField-And-Alloca.c89
-rw-r--r--clang/test/CodeGen/2008-03-26-PackedBitFields.c7
-rw-r--r--clang/test/CodeGen/2008-04-08-NoExceptions.c10
-rw-r--r--clang/test/CodeGen/2008-05-06-CFECrash.c4
-rw-r--r--clang/test/CodeGen/2008-05-12-TempUsedBeforeDef.c10
-rw-r--r--clang/test/CodeGen/2008-05-19-AlwaysInline.c12
-rw-r--r--clang/test/CodeGen/2008-07-17-no-emit-on-error.c15
-rw-r--r--clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c8
-rw-r--r--clang/test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c12
-rw-r--r--clang/test/CodeGen/2008-07-22-packed-bitfield-access.c10
-rw-r--r--clang/test/CodeGen/2008-07-29-override-alias-decl.c19
-rw-r--r--clang/test/CodeGen/2008-07-30-implicit-initialization.c28
-rw-r--r--clang/test/CodeGen/2008-07-30-redef-of-bitcasted-decl.c28
-rw-r--r--clang/test/CodeGen/2008-07-31-asm-labels.c33
-rw-r--r--clang/test/CodeGen/2008-07-31-promotion-of-compound-pointer-arithmetic.c25
-rw-r--r--clang/test/CodeGen/2008-08-04-void-pointer-arithmetic.c6
-rw-r--r--clang/test/CodeGen/2008-08-07-AlignPadding1.c32
-rw-r--r--clang/test/CodeGen/2008-08-07-AlignPadding2.c18
-rw-r--r--clang/test/CodeGen/2008-08-07-GEPIntToPtr.c15
-rw-r--r--clang/test/CodeGen/2008-08-19-cast-of-typedef.c10
-rw-r--r--clang/test/CodeGen/2008-09-03-WeakAlias.c9
-rw-r--r--clang/test/CodeGen/2008-09-22-bad-switch-type.c34
-rw-r--r--clang/test/CodeGen/2008-10-13-FrontendCrash.c9
-rw-r--r--clang/test/CodeGen/2008-10-30-ZeroPlacement.c9
-rw-r--r--clang/test/CodeGen/2008-11-02-WeakAlias.c6
-rw-r--r--clang/test/CodeGen/2008-11-08-InstCombineSelect.c17
-rw-r--r--clang/test/CodeGen/2008-12-23-AsmIntPointerTie.c8
-rw-r--r--clang/test/CodeGen/2009-01-05-BlockInlining.c29
-rw-r--r--clang/test/CodeGen/2009-01-21-InvalidIterator.c74
-rw-r--r--clang/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c13
-rw-r--r--clang/test/CodeGen/2009-02-13-zerosize-union-field.c16
-rw-r--r--clang/test/CodeGen/2009-03-01-MallocNoAlias.c3
-rw-r--r--clang/test/CodeGen/2009-03-08-ZeroEltStructCrash.c14
-rw-r--r--clang/test/CodeGen/2009-03-13-dbg.c2
-rw-r--r--clang/test/CodeGen/2009-03-22-increment-bitfield.c7
-rw-r--r--clang/test/CodeGen/2009-04-23-dbg.c20
-rw-r--r--clang/test/CodeGen/2009-04-28-UnionArrayCrash.c11
-rw-r--r--clang/test/CodeGen/2009-05-04-EnumInreg.c17
-rw-r--r--clang/test/CodeGen/2009-05-22-callingconv.c25
-rw-r--r--clang/test/CodeGen/2009-05-28-const-typedef.c17
-rw-r--r--clang/test/CodeGen/2009-06-01-addrofknr.c21
-rw-r--r--clang/test/CodeGen/2009-06-14-HighlyAligned.c8
-rw-r--r--clang/test/CodeGen/2009-06-14-anonymous-union-init.c7
-rw-r--r--clang/test/CodeGen/2009-06-18-StaticInitTailPadPack.c26
-rw-r--r--clang/test/CodeGen/2009-07-14-VoidPtr.c6
-rw-r--r--clang/test/CodeGen/2009-07-15-pad-wchar_t-array.c17
-rw-r--r--clang/test/CodeGen/2009-07-22-StructLayout.c34
-rw-r--r--clang/test/CodeGen/2009-07-31-DbgDeclare.c5
-rw-r--r--clang/test/CodeGen/2009-08-14-vararray-crash.c11
-rw-r--r--clang/test/CodeGen/2009-09-24-SqrtErrno.c12
-rw-r--r--clang/test/CodeGen/2009-10-20-GlobalDebug.c10
-rw-r--r--clang/test/CodeGen/2009-12-07-BitFieldAlignment.c15
-rw-r--r--clang/test/CodeGen/2010-01-13-MemBarrier.c11
-rw-r--r--clang/test/CodeGen/2010-01-14-FnType-DebugInfo.c4
-rw-r--r--clang/test/CodeGen/2010-01-18-Inlined-Debug.c12
-rw-r--r--clang/test/CodeGen/2010-02-10-PointerName.c7
-rw-r--r--clang/test/CodeGen/2010-02-15-DbgStaticVar.c13
-rw-r--r--clang/test/CodeGen/2010-02-16-DbgScopes.c18
-rw-r--r--clang/test/CodeGen/2010-02-18-Dbg-VectorType.c9
-rw-r--r--clang/test/CodeGen/2010-03-09-DbgInfo.c2
-rw-r--r--clang/test/CodeGen/2010-03-5-LexicalScope.c10
-rw-r--r--clang/test/CodeGen/2010-05-26-AsmSideEffect.c9
-rw-r--r--clang/test/CodeGen/2010-06-11-SaveExpr.c8
-rw-r--r--clang/test/CodeGen/2010-06-17-asmcrash.c16
-rw-r--r--clang/test/CodeGen/2010-07-08-DeclDebugLineNo.c10
-rw-r--r--clang/test/CodeGen/2010-07-14-overconservative-align.c14
-rw-r--r--clang/test/CodeGen/2010-07-14-ref-off-end.c24
-rw-r--r--clang/test/CodeGen/2010-08-10-DbgConstant.c5
-rw-r--r--clang/test/CodeGen/2010-08-12-asm-aggr-arg.c16
-rw-r--r--clang/test/CodeGen/2010-12-01-CommonGlobal.c7
-rw-r--r--clang/test/CodeGen/2011-02-21-DATA-common.c5
-rw-r--r--clang/test/CodeGen/2011-03-02-UnionInitializer.c2
-rw-r--r--clang/test/CodeGen/2011-03-08-ZeroFieldUnionInitializer.c7
-rw-r--r--clang/test/CodeGen/2011-03-31-ArrayRefFolding.c15
-rw-r--r--clang/test/CodeGen/3dnow-builtins.c156
-rw-r--r--clang/test/CodeGen/Atomics.c203
-rw-r--r--clang/test/CodeGen/BasicInstrs.c25
-rw-r--r--clang/test/CodeGen/Inputs/stdio.h9
-rw-r--r--clang/test/CodeGen/OpaqueStruct.c12
-rw-r--r--clang/test/CodeGen/PR2001-bitfield-reload.c16
-rw-r--r--clang/test/CodeGen/PR2413-void-address-cast-error.c6
-rw-r--r--clang/test/CodeGen/PR2643-null-store-to-bitfield.c10
-rw-r--r--clang/test/CodeGen/PR2743-reference-missing-static.c16
-rw-r--r--clang/test/CodeGen/PR3130-cond-constant.c3
-rw-r--r--clang/test/CodeGen/PR3589-freestanding-libcalls.c9
-rw-r--r--clang/test/CodeGen/PR3613-static-decl.c16
-rw-r--r--clang/test/CodeGen/PR3709-int-to-pointer-sign.c5
-rw-r--r--clang/test/CodeGen/PR4611-bitfield-layout.c6
-rw-r--r--clang/test/CodeGen/PR5060-align.c13
-rw-r--r--clang/test/CodeGen/_Bool-conversion.c12
-rw-r--r--clang/test/CodeGen/address-safety-attr.cpp35
-rw-r--r--clang/test/CodeGen/address-space-cast.c4
-rw-r--r--clang/test/CodeGen/address-space-compound-literal.c5
-rw-r--r--clang/test/CodeGen/address-space-field1.c38
-rw-r--r--clang/test/CodeGen/address-space.c44
-rw-r--r--clang/test/CodeGen/alias.c32
-rw-r--r--clang/test/CodeGen/align-local.c8
-rw-r--r--clang/test/CodeGen/align-param.c18
-rw-r--r--clang/test/CodeGen/alignment.c59
-rw-r--r--clang/test/CodeGen/alignof.c12
-rw-r--r--clang/test/CodeGen/altivec.c40
-rw-r--r--clang/test/CodeGen/always-inline.c12
-rw-r--r--clang/test/CodeGen/always_inline.c20
-rw-r--r--clang/test/CodeGen/annotations-builtin.c52
-rw-r--r--clang/test/CodeGen/annotations-field.c27
-rw-r--r--clang/test/CodeGen/annotations-global.c41
-rw-r--r--clang/test/CodeGen/annotations-loc.c10
-rw-r--r--clang/test/CodeGen/annotations-var.c48
-rw-r--r--clang/test/CodeGen/arm-aapcs-vfp.c82
-rw-r--r--clang/test/CodeGen/arm-aapcs-zerolength-bitfield.c236
-rw-r--r--clang/test/CodeGen/arm-apcs-zerolength-bitfield.c240
-rw-r--r--clang/test/CodeGen/arm-arguments.c167
-rw-r--r--clang/test/CodeGen/arm-asm-variable.c31
-rw-r--r--clang/test/CodeGen/arm-asm.c7
-rw-r--r--clang/test/CodeGen/arm-cc.c18
-rw-r--r--clang/test/CodeGen/arm-clear.c21
-rw-r--r--clang/test/CodeGen/arm-homogenous.c160
-rw-r--r--clang/test/CodeGen/arm-inline-asm.c6
-rw-r--r--clang/test/CodeGen/arm-pcs.c12
-rw-r--r--clang/test/CodeGen/arm-vaarg-align.c33
-rw-r--r--clang/test/CodeGen/arm-vector-align.c29
-rw-r--r--clang/test/CodeGen/arm-vector-arguments.c30
-rw-r--r--clang/test/CodeGen/array.c14
-rw-r--r--clang/test/CodeGen/arrayderef.c16
-rw-r--r--clang/test/CodeGen/asm-errors.c11
-rw-r--r--clang/test/CodeGen/asm-inout.c48
-rw-r--r--clang/test/CodeGen/asm-label.c19
-rw-r--r--clang/test/CodeGen/asm-reg-var-local.c24
-rw-r--r--clang/test/CodeGen/asm-variable.c65
-rw-r--r--clang/test/CodeGen/asm.c222
-rw-r--r--clang/test/CodeGen/asm_arm.c54
-rw-r--r--clang/test/CodeGen/assign.c32
-rw-r--r--clang/test/CodeGen/atomic-ops.c314
-rw-r--r--clang/test/CodeGen/atomic.c109
-rw-r--r--clang/test/CodeGen/atomic_ops.c14
-rw-r--r--clang/test/CodeGen/attr-availability.c31
-rw-r--r--clang/test/CodeGen/attr-cleanup.c8
-rw-r--r--clang/test/CodeGen/attr-naked.c16
-rw-r--r--clang/test/CodeGen/attr-nodebug.c12
-rw-r--r--clang/test/CodeGen/attr-noinline.c9
-rw-r--r--clang/test/CodeGen/attr-used.c14
-rw-r--r--clang/test/CodeGen/attr-weak-import.c26
-rw-r--r--clang/test/CodeGen/attr-weakref.c62
-rw-r--r--clang/test/CodeGen/attr-weakref2.c54
-rw-r--r--clang/test/CodeGen/attribute-section-data-common.c5
-rw-r--r--clang/test/CodeGen/attribute_constructor.c6
-rw-r--r--clang/test/CodeGen/attributes.c83
-rw-r--r--clang/test/CodeGen/available-externally-suppress.c27
-rw-r--r--clang/test/CodeGen/avx-builtins.c25
-rw-r--r--clang/test/CodeGen/avx-cmp-builtins.c46
-rw-r--r--clang/test/CodeGen/avx-shuffle-builtins.c65
-rw-r--r--clang/test/CodeGen/avx2-builtins.c782
-rw-r--r--clang/test/CodeGen/bitfield-2.c368
-rw-r--r--clang/test/CodeGen/bitfield-assign.c44
-rw-r--r--clang/test/CodeGen/bitfield-init.c14
-rw-r--r--clang/test/CodeGen/bitfield-promote.c18
-rw-r--r--clang/test/CodeGen/bitfield.c74
-rw-r--r--clang/test/CodeGen/block-3.c8
-rw-r--r--clang/test/CodeGen/block-byref-aggr.c17
-rw-r--r--clang/test/CodeGen/block-copy.c20
-rw-r--r--clang/test/CodeGen/blocks-1.c78
-rw-r--r--clang/test/CodeGen/blocks-2.c18
-rw-r--r--clang/test/CodeGen/blocks-aligned-byref-variable.c19
-rw-r--r--clang/test/CodeGen/blocks-seq.c18
-rw-r--r--clang/test/CodeGen/blocks.c42
-rw-r--r--clang/test/CodeGen/blocksignature.c96
-rw-r--r--clang/test/CodeGen/blockstret.c106
-rw-r--r--clang/test/CodeGen/blockwithlocalstatic.c19
-rw-r--r--clang/test/CodeGen/bmi-builtins.c79
-rw-r--r--clang/test/CodeGen/bmi2-builtins.c36
-rw-r--r--clang/test/CodeGen/bool-bitfield.c54
-rw-r--r--clang/test/CodeGen/bool-convert.c10
-rw-r--r--clang/test/CodeGen/bool-init.c4
-rw-r--r--clang/test/CodeGen/bool_test.c5
-rw-r--r--clang/test/CodeGen/boolassign.c7
-rw-r--r--clang/test/CodeGen/builtin-attributes.c58
-rw-r--r--clang/test/CodeGen/builtin-count-zeros.c8
-rw-r--r--clang/test/CodeGen/builtin-expect.c47
-rw-r--r--clang/test/CodeGen/builtin-memfns.c65
-rw-r--r--clang/test/CodeGen/builtin-nanf.c15
-rw-r--r--clang/test/CodeGen/builtin-recursive.cc10
-rw-r--r--clang/test/CodeGen/builtin-rename.c8
-rw-r--r--clang/test/CodeGen/builtin-stackaddress.c9
-rw-r--r--clang/test/CodeGen/builtin-unwind-init.c5
-rw-r--r--clang/test/CodeGen/builtins-arm.c12
-rw-r--r--clang/test/CodeGen/builtins-ppc-altivec.c3115
-rw-r--r--clang/test/CodeGen/builtins-ptx.c99
-rw-r--r--clang/test/CodeGen/builtins-x86.c496
-rw-r--r--clang/test/CodeGen/builtins.c205
-rw-r--r--clang/test/CodeGen/builtinshufflevector.c6
-rw-r--r--clang/test/CodeGen/builtinshufflevector2.c35
-rw-r--r--clang/test/CodeGen/byval-memcpy-elim.c53
-rw-r--r--clang/test/CodeGen/c-strings.c36
-rw-r--r--clang/test/CodeGen/call.c39
-rw-r--r--clang/test/CodeGen/capture-complex-expr-in-block.c20
-rw-r--r--clang/test/CodeGen/cast-emit.c12
-rw-r--r--clang/test/CodeGen/cast.c6
-rw-r--r--clang/test/CodeGen/catch-undef-behavior.c7
-rw-r--r--clang/test/CodeGen/cfstring.c23
-rw-r--r--clang/test/CodeGen/cfstring2.c13
-rw-r--r--clang/test/CodeGen/char-literal.c90
-rw-r--r--clang/test/CodeGen/cleanup-stack.c25
-rw-r--r--clang/test/CodeGen/complex-indirect.c12
-rw-r--r--clang/test/CodeGen/complex-init-list.c18
-rw-r--r--clang/test/CodeGen/complex.c99
-rw-r--r--clang/test/CodeGen/compound-literal.c34
-rw-r--r--clang/test/CodeGen/compound-type.c7
-rw-r--r--clang/test/CodeGen/compound.c25
-rw-r--r--clang/test/CodeGen/conditional-gnu-ext.c36
-rw-r--r--clang/test/CodeGen/conditional.c74
-rw-r--r--clang/test/CodeGen/const-arithmetic.c8
-rw-r--r--clang/test/CodeGen/const-init.c146
-rw-r--r--clang/test/CodeGen/const-label-addr.c4
-rw-r--r--clang/test/CodeGen/const-unordered-compare.c7
-rw-r--r--clang/test/CodeGen/constant-comparison.c12
-rw-r--r--clang/test/CodeGen/constructor-attribute.c38
-rw-r--r--clang/test/CodeGen/count-builtins.c33
-rw-r--r--clang/test/CodeGen/cxx-condition.cpp9
-rw-r--r--clang/test/CodeGen/cxx-default-arg.cpp25
-rw-r--r--clang/test/CodeGen/cxx-value-init.cpp11
-rw-r--r--clang/test/CodeGen/darwin-string-literals.c19
-rw-r--r--clang/test/CodeGen/darwin-thread-specifier.c3
-rw-r--r--clang/test/CodeGen/debug-dead-local-var.c14
-rw-r--r--clang/test/CodeGen/debug-info-args.c9
-rw-r--r--clang/test/CodeGen/debug-info-block.c11
-rw-r--r--clang/test/CodeGen/debug-info-compilation-dir.c6
-rw-r--r--clang/test/CodeGen/debug-info-crash.c31
-rw-r--r--clang/test/CodeGen/debug-info-enum.c11
-rw-r--r--clang/test/CodeGen/debug-info-iv.c36
-rw-r--r--clang/test/CodeGen/debug-info-line.c23
-rw-r--r--clang/test/CodeGen/debug-info-line2.c17
-rw-r--r--clang/test/CodeGen/debug-info-line3.c16
-rw-r--r--clang/test/CodeGen/debug-info-member.c3
-rw-r--r--clang/test/CodeGen/debug-info-scope.c14
-rw-r--r--clang/test/CodeGen/debug-info-static.c8
-rw-r--r--clang/test/CodeGen/debug-info-var-location.c21
-rw-r--r--clang/test/CodeGen/debug-info.c61
-rw-r--r--clang/test/CodeGen/debug-line-1.c20
-rw-r--r--clang/test/CodeGen/decl-in-prototype.c21
-rw-r--r--clang/test/CodeGen/decl.c119
-rw-r--r--clang/test/CodeGen/designated-initializers.c89
-rw-r--r--clang/test/CodeGen/dllimport-dllexport.c12
-rw-r--r--clang/test/CodeGen/dostmt.c70
-rw-r--r--clang/test/CodeGen/emit-all-decls.c8
-rw-r--r--clang/test/CodeGen/empty-union-init.c13
-rw-r--r--clang/test/CodeGen/enum.c22
-rw-r--r--clang/test/CodeGen/enum2.c8
-rw-r--r--clang/test/CodeGen/exact-div-expr.c6
-rw-r--r--clang/test/CodeGen/exceptions.c21
-rw-r--r--clang/test/CodeGen/exprs.c176
-rw-r--r--clang/test/CodeGen/ext-vector-member-alignment.c27
-rw-r--r--clang/test/CodeGen/ext-vector.c288
-rw-r--r--clang/test/CodeGen/extern-block-var.c6
-rw-r--r--clang/test/CodeGen/extern-inline.c26
-rw-r--r--clang/test/CodeGen/extern-weak.c12
-rw-r--r--clang/test/CodeGen/flexible-array-init.c7
-rw-r--r--clang/test/CodeGen/fma4-builtins.c166
-rw-r--r--clang/test/CodeGen/fold-const-declref.c9
-rw-r--r--clang/test/CodeGen/fp16-ops.c283
-rw-r--r--clang/test/CodeGen/frame-pointer-elim.c40
-rw-r--r--clang/test/CodeGen/func-aligned.c7
-rw-r--r--clang/test/CodeGen/func-decl-cleanup.c12
-rw-r--r--clang/test/CodeGen/func-in-block.c19
-rw-r--r--clang/test/CodeGen/func-ptr-cast-decl.c6
-rw-r--r--clang/test/CodeGen/func-return-member.c26
-rw-r--r--clang/test/CodeGen/funccall.c17
-rw-r--r--clang/test/CodeGen/function-attributes.c113
-rw-r--r--clang/test/CodeGen/functions.c67
-rw-r--r--clang/test/CodeGen/global-decls.c21
-rw-r--r--clang/test/CodeGen/global-init.c52
-rw-r--r--clang/test/CodeGen/global-with-initialiser.c25
-rw-r--r--clang/test/CodeGen/globalinit.c51
-rw-r--r--clang/test/CodeGen/hidden-visibility.c4
-rw-r--r--clang/test/CodeGen/imaginary.c4
-rw-r--r--clang/test/CodeGen/implicit-arg.c10
-rw-r--r--clang/test/CodeGen/incomplete-function-type.c14
-rw-r--r--clang/test/CodeGen/indirect-goto.c31
-rw-r--r--clang/test/CodeGen/init-with-member-expr.c21
-rw-r--r--clang/test/CodeGen/init.c132
-rw-r--r--clang/test/CodeGen/inline-asm-mrv.c12
-rw-r--r--clang/test/CodeGen/inline.c129
-rw-r--r--clang/test/CodeGen/inline2.c62
-rw-r--r--clang/test/CodeGen/instrument-functions.c18
-rw-r--r--clang/test/CodeGen/int-to-pointer.c6
-rw-r--r--clang/test/CodeGen/integer-overflow.c66
-rw-r--r--clang/test/CodeGen/kr-func-promote.c5
-rw-r--r--clang/test/CodeGen/kr-style-block.c10
-rw-r--r--clang/test/CodeGen/libcalls-d.c16
-rw-r--r--clang/test/CodeGen/libcalls-fno-builtin.c28
-rw-r--r--clang/test/CodeGen/libcalls-ld.c19
-rw-r--r--clang/test/CodeGen/libcalls.c75
-rw-r--r--clang/test/CodeGen/lifetime.c23
-rw-r--r--clang/test/CodeGen/lineno-dbginfo.c5
-rw-r--r--clang/test/CodeGen/link-bitcode-file.c24
-rw-r--r--clang/test/CodeGen/linkage-redecl.c11
-rw-r--r--clang/test/CodeGen/long-double-x86.c4
-rw-r--r--clang/test/CodeGen/lzcnt-builtins.c24
-rw-r--r--clang/test/CodeGen/mandel.c65
-rw-r--r--clang/test/CodeGen/mangle.c74
-rw-r--r--clang/test/CodeGen/may-alias.c30
-rw-r--r--clang/test/CodeGen/mcount.c4
-rw-r--r--clang/test/CodeGen/merge-attrs.c13
-rw-r--r--clang/test/CodeGen/merge-statics.c13
-rw-r--r--clang/test/CodeGen/microsoft-call-conv.c50
-rw-r--r--clang/test/CodeGen/mips-clobber-reg.c80
-rw-r--r--clang/test/CodeGen/mips-constraint-regs.c44
-rw-r--r--clang/test/CodeGen/mips64-class-return.cpp46
-rw-r--r--clang/test/CodeGen/mips64-f128-literal.c9
-rw-r--r--clang/test/CodeGen/mips64-nontrivial-return.cpp17
-rw-r--r--clang/test/CodeGen/mips64-padding-arg.c43
-rw-r--r--clang/test/CodeGen/misaligned-param.c13
-rw-r--r--clang/test/CodeGen/mms-bitfields.c22
-rw-r--r--clang/test/CodeGen/mmx-builtins.c453
-rw-r--r--clang/test/CodeGen/mmx-inline-asm.c22
-rw-r--r--clang/test/CodeGen/mmx-shift-with-immediate.c23
-rw-r--r--clang/test/CodeGen/mrtd.c15
-rw-r--r--clang/test/CodeGen/ms-anonymous-struct.c99
-rw-r--r--clang/test/CodeGen/ms-declspecs.c16
-rw-r--r--clang/test/CodeGen/ms_struct-bitfield-1.c91
-rw-r--r--clang/test/CodeGen/ms_struct-bitfield-2.c135
-rw-r--r--clang/test/CodeGen/ms_struct-bitfield-3.c49
-rw-r--r--clang/test/CodeGen/ms_struct-bitfield-init.c68
-rw-r--r--clang/test/CodeGen/ms_struct-bitfield.c131
-rw-r--r--clang/test/CodeGen/ms_struct-pack.c125
-rw-r--r--clang/test/CodeGen/ms_struct.c23
-rw-r--r--clang/test/CodeGen/mult-alt-generic.c281
-rw-r--r--clang/test/CodeGen/mult-alt-x86.c374
-rw-r--r--clang/test/CodeGen/no-common.c15
-rw-r--r--clang/test/CodeGen/noinline.c14
-rw-r--r--clang/test/CodeGen/object-size.c136
-rw-r--r--clang/test/CodeGen/offsetof.c12
-rw-r--r--clang/test/CodeGen/opaque-pointer.c13
-rw-r--r--clang/test/CodeGen/overloadable.c26
-rw-r--r--clang/test/CodeGen/override-layout.c174
-rw-r--r--clang/test/CodeGen/packed-arrays.c155
-rw-r--r--clang/test/CodeGen/packed-nest-unpacked.c47
-rw-r--r--clang/test/CodeGen/packed-structure.c101
-rw-r--r--clang/test/CodeGen/packed-union.c15
-rw-r--r--clang/test/CodeGen/palignr.c31
-rw-r--r--clang/test/CodeGen/parameter-passing.c56
-rw-r--r--clang/test/CodeGen/pascal-string.c8
-rw-r--r--clang/test/CodeGen/pascal-wchar-string.c41
-rw-r--r--clang/test/CodeGen/pointer-arithmetic.c25
-rw-r--r--clang/test/CodeGen/pointer-cmp-type.c3
-rw-r--r--clang/test/CodeGen/pointer-signext.c32
-rw-r--r--clang/test/CodeGen/pointer-to-int.c13
-rw-r--r--clang/test/CodeGen/popcnt-builtins.c16
-rw-r--r--clang/test/CodeGen/powerpc_types.c10
-rw-r--r--clang/test/CodeGen/pr12251.c11
-rw-r--r--clang/test/CodeGen/pr2394.c7
-rw-r--r--clang/test/CodeGen/pr3518.c29
-rw-r--r--clang/test/CodeGen/pr4349.c38
-rw-r--r--clang/test/CodeGen/pr5406.c17
-rw-r--r--clang/test/CodeGen/pr9614.c29
-rw-r--r--clang/test/CodeGen/pragma-pack-1.c7
-rw-r--r--clang/test/CodeGen/pragma-pack-2.c23
-rw-r--r--clang/test/CodeGen/pragma-pack-3.c17
-rw-r--r--clang/test/CodeGen/pragma-visibility.c24
-rw-r--r--clang/test/CodeGen/pragma-weak.c172
-rw-r--r--clang/test/CodeGen/predefined-expr.c45
-rw-r--r--clang/test/CodeGen/private-extern-redef.c39
-rw-r--r--clang/test/CodeGen/private-extern.c10
-rw-r--r--clang/test/CodeGen/ptx-cc.c9
-rw-r--r--clang/test/CodeGen/redef-ext-inline.c6
-rw-r--r--clang/test/CodeGen/redefine_extname.c15
-rw-r--r--clang/test/CodeGen/regparm-flag.c20
-rw-r--r--clang/test/CodeGen/regparm.c27
-rw-r--r--clang/test/CodeGen/restrict.c26
-rw-r--r--clang/test/CodeGen/shared-string-literals.c9
-rw-r--r--clang/test/CodeGen/sizeof-vla.c13
-rw-r--r--clang/test/CodeGen/sret.c15
-rw-r--r--clang/test/CodeGen/sret2.c9
-rw-r--r--clang/test/CodeGen/sse-builtins.c153
-rw-r--r--clang/test/CodeGen/stack-protector.c14
-rw-r--r--clang/test/CodeGen/statements.c40
-rw-r--r--clang/test/CodeGen/static-forward-decl-fun.c6
-rw-r--r--clang/test/CodeGen/static-forward-decl.c5
-rw-r--r--clang/test/CodeGen/static-local-union.c4
-rw-r--r--clang/test/CodeGen/static-order.c22
-rw-r--r--clang/test/CodeGen/staticinit.c41
-rw-r--r--clang/test/CodeGen/stdcall-fastcall.c50
-rw-r--r--clang/test/CodeGen/string-literal-short-wstring.c32
-rw-r--r--clang/test/CodeGen/string-literal-unicode-conversion.c63
-rw-r--r--clang/test/CodeGen/string-literal.c80
-rw-r--r--clang/test/CodeGen/struct-comma.c4
-rw-r--r--clang/test/CodeGen/struct-copy.c7
-rw-r--r--clang/test/CodeGen/struct-init.c37
-rw-r--r--clang/test/CodeGen/struct-matching-constraint.c13
-rw-r--r--clang/test/CodeGen/struct-passing.c24
-rw-r--r--clang/test/CodeGen/struct-x86-darwin.c25
-rw-r--r--clang/test/CodeGen/struct.c196
-rw-r--r--clang/test/CodeGen/switch-dce.c234
-rw-r--r--clang/test/CodeGen/switch.c213
-rw-r--r--clang/test/CodeGen/target-data.c6
-rw-r--r--clang/test/CodeGen/tbaa-for-vptr.cpp19
-rw-r--r--clang/test/CodeGen/tentative-decls.c38
-rw-r--r--clang/test/CodeGen/thread-specifier.c15
-rw-r--r--clang/test/CodeGen/transparent-union.c25
-rw-r--r--clang/test/CodeGen/trapv.c49
-rw-r--r--clang/test/CodeGen/typedef-func.c16
-rw-r--r--clang/test/CodeGen/typedef.c8
-rw-r--r--clang/test/CodeGen/types.c34
-rw-r--r--clang/test/CodeGen/uint128_t.c18
-rw-r--r--clang/test/CodeGen/unaligned-memcpy.c5
-rw-r--r--clang/test/CodeGen/union-align.c17
-rw-r--r--clang/test/CodeGen/union-init.c31
-rw-r--r--clang/test/CodeGen/union-init2.c13
-rw-r--r--clang/test/CodeGen/union.c46
-rw-r--r--clang/test/CodeGen/unreachable.c37
-rw-r--r--clang/test/CodeGen/unwind-attr.c24
-rw-r--r--clang/test/CodeGen/utf16-cfstrings.c10
-rw-r--r--clang/test/CodeGen/varargs.c11
-rw-r--r--clang/test/CodeGen/variable-array.c19
-rw-r--r--clang/test/CodeGen/vector.c57
-rw-r--r--clang/test/CodeGen/vfprintf.c8
-rw-r--r--clang/test/CodeGen/visibility.c69
-rw-r--r--clang/test/CodeGen/vla-2.c10
-rw-r--r--clang/test/CodeGen/vla-3.c11
-rw-r--r--clang/test/CodeGen/vla-4.c24
-rw-r--r--clang/test/CodeGen/vla.c144
-rw-r--r--clang/test/CodeGen/vld_dup.c49
-rw-r--r--clang/test/CodeGen/volatile-1.c315
-rw-r--r--clang/test/CodeGen/volatile-2.c23
-rw-r--r--clang/test/CodeGen/volatile.c100
-rw-r--r--clang/test/CodeGen/wchar-const.c24
-rw-r--r--clang/test/CodeGen/weak-global.c3
-rw-r--r--clang/test/CodeGen/weak-incomplete.c5
-rw-r--r--clang/test/CodeGen/weak_constant.c13
-rw-r--r--clang/test/CodeGen/whilestmt.c62
-rw-r--r--clang/test/CodeGen/writable-strings.c8
-rw-r--r--clang/test/CodeGen/x86.c15
-rw-r--r--clang/test/CodeGen/x86_32-arguments-darwin.c326
-rw-r--r--clang/test/CodeGen/x86_32-arguments-linux.c51
-rw-r--r--clang/test/CodeGen/x86_32-arguments-nommx.c11
-rw-r--r--clang/test/CodeGen/x86_32-arguments-realign.c11
-rw-r--r--clang/test/CodeGen/x86_32-arguments-win32.c48
-rw-r--r--clang/test/CodeGen/x86_64-arguments-darwin.c17
-rw-r--r--clang/test/CodeGen/x86_64-arguments.c356
-rw-r--r--clang/test/CodeGenCUDA/device-stub.cu13
-rw-r--r--clang/test/CodeGenCUDA/filter-decl.cu40
-rw-r--r--clang/test/CodeGenCUDA/kernel-call.cu13
-rw-r--r--clang/test/CodeGenCUDA/ptx-kernels.cu12
-rw-r--r--clang/test/CodeGenCXX/2003-11-02-WeakLinkage.cpp13
-rw-r--r--clang/test/CodeGenCXX/2003-11-18-PtrMemConstantInitializer.cpp13
-rw-r--r--clang/test/CodeGenCXX/2003-11-27-MultipleInheritanceThunk.cpp28
-rw-r--r--clang/test/CodeGenCXX/2003-11-29-DuplicatedCleanupTest.cpp41
-rw-r--r--clang/test/CodeGenCXX/2003-12-08-ArrayOfPtrToMemberFunc.cpp12
-rw-r--r--clang/test/CodeGenCXX/2004-01-11-DynamicInitializedConstant.cpp6
-rw-r--r--clang/test/CodeGenCXX/2004-03-08-ReinterpretCastCopy.cpp21
-rw-r--r--clang/test/CodeGenCXX/2004-03-09-UnmangledBuiltinMethods.cpp8
-rw-r--r--clang/test/CodeGenCXX/2004-03-15-CleanupsAndGotos.cpp14
-rw-r--r--clang/test/CodeGenCXX/2004-06-08-LateTemplateInstantiation.cpp18
-rw-r--r--clang/test/CodeGenCXX/2004-09-27-DidntEmitTemplate.cpp22
-rw-r--r--clang/test/CodeGenCXX/2004-11-27-ExceptionCleanupAssertion.cpp14
-rw-r--r--clang/test/CodeGenCXX/2004-11-27-FriendDefaultArgCrash.cpp9
-rw-r--r--clang/test/CodeGenCXX/2005-01-03-StaticInitializers.cpp8
-rw-r--r--clang/test/CodeGenCXX/2005-02-11-AnonymousUnion.cpp32
-rw-r--r--clang/test/CodeGenCXX/2005-02-13-BadDynamicInit.cpp9
-rw-r--r--clang/test/CodeGenCXX/2005-02-14-BitFieldOffset.cpp12
-rw-r--r--clang/test/CodeGenCXX/2005-02-19-BitfieldStructCrash.cpp14
-rw-r--r--clang/test/CodeGenCXX/2005-02-19-UnnamedVirtualThunkArgument.cpp22
-rw-r--r--clang/test/CodeGenCXX/2005-02-20-BrokenReferenceTest.cpp10
-rw-r--r--clang/test/CodeGenCXX/2006-03-01-GimplifyCrash.cpp14
-rw-r--r--clang/test/CodeGenCXX/2006-03-06-C++RecurseCrash.cpp23
-rw-r--r--clang/test/CodeGenCXX/2006-09-12-OpaqueStructCrash.cpp27
-rw-r--r--clang/test/CodeGenCXX/2006-10-30-ClassBitfield.cpp16
-rw-r--r--clang/test/CodeGenCXX/2006-11-20-GlobalSymbols.cpp11
-rw-r--r--clang/test/CodeGenCXX/2006-11-30-ConstantExprCrash.cpp21
-rw-r--r--clang/test/CodeGenCXX/2007-01-02-UnboundedArray.cpp14
-rw-r--r--clang/test/CodeGenCXX/2007-01-06-PtrMethodInit.cpp75
-rw-r--r--clang/test/CodeGenCXX/2007-04-05-PackedBitFields-1.cpp22
-rw-r--r--clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap-2.cpp23
-rw-r--r--clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap.cpp23
-rw-r--r--clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsSmall.cpp27
-rw-r--r--clang/test/CodeGenCXX/2007-04-05-StructPackedFieldUnpacked.cpp24
-rw-r--r--clang/test/CodeGenCXX/2007-04-10-PackedUnion.cpp41
-rw-r--r--clang/test/CodeGenCXX/2007-04-14-FNoBuiltin.cpp8
-rw-r--r--clang/test/CodeGenCXX/2007-05-03-VectorInit.cpp17
-rw-r--r--clang/test/CodeGenCXX/2007-07-29-RestrictPtrArg.cpp7
-rw-r--r--clang/test/CodeGenCXX/2007-07-29-RestrictRefArg.cpp7
-rw-r--r--clang/test/CodeGenCXX/2007-09-10-RecursiveTypeResolution.cpp87
-rw-r--r--clang/test/CodeGenCXX/2007-10-01-StructResize.cpp13
-rw-r--r--clang/test/CodeGenCXX/2008-01-12-VecInit.cpp5
-rw-r--r--clang/test/CodeGenCXX/2008-05-07-CrazyOffsetOf.cpp8
-rw-r--r--clang/test/CodeGenCXX/2009-03-17-dbg.cpp15
-rw-r--r--clang/test/CodeGenCXX/2009-04-23-bool2.cpp15
-rw-r--r--clang/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp15
-rw-r--r--clang/test/CodeGenCXX/2009-06-16-DebugInfoCrash.cpp10
-rw-r--r--clang/test/CodeGenCXX/2009-07-16-Using.cpp8
-rw-r--r--clang/test/CodeGenCXX/2009-08-05-ZeroInitWidth.cpp11
-rw-r--r--clang/test/CodeGenCXX/2009-08-11-VectorRetTy.cpp13
-rw-r--r--clang/test/CodeGenCXX/2009-09-09-packed-layout.cpp18
-rw-r--r--clang/test/CodeGenCXX/2009-10-27-crash.cpp43
-rw-r--r--clang/test/CodeGenCXX/2009-12-23-MissingSext.cpp16
-rw-r--r--clang/test/CodeGenCXX/2010-03-09-AnonAggregate.cpp12
-rw-r--r--clang/test/CodeGenCXX/2010-05-10-Var-DbgInfo.cpp42
-rw-r--r--clang/test/CodeGenCXX/2010-05-11-alwaysinlineinstantiation.cpp33
-rw-r--r--clang/test/CodeGenCXX/2010-05-12-PtrToMember-Dbg.cpp17
-rw-r--r--clang/test/CodeGenCXX/2010-06-21-LocalVarDbg.cpp14
-rw-r--r--clang/test/CodeGenCXX/2010-06-22-BitfieldInit.cpp20
-rw-r--r--clang/test/CodeGenCXX/2010-06-22-ZeroBitfield.cpp5
-rw-r--r--clang/test/CodeGenCXX/2010-07-23-DeclLoc.cpp86
-rw-r--r--clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp26
-rw-r--r--clang/test/CodeGenCXX/2012-02-06-VecInitialization.cpp8
-rw-r--r--clang/test/CodeGenCXX/2012-03-16-StoreAlign.cpp36
-rw-r--r--clang/test/CodeGenCXX/DynArrayInit.cpp15
-rw-r--r--clang/test/CodeGenCXX/PR4827-cast.cpp5
-rw-r--r--clang/test/CodeGenCXX/PR4983-constructor-conversion.cpp16
-rw-r--r--clang/test/CodeGenCXX/PR5050-constructor-conversion.cpp19
-rw-r--r--clang/test/CodeGenCXX/PR5093-static-member-function.cpp9
-rw-r--r--clang/test/CodeGenCXX/PR5834-constructor-conversion.cpp14
-rw-r--r--clang/test/CodeGenCXX/PR5863-unreachable-block.cpp13
-rw-r--r--clang/test/CodeGenCXX/PR6474.cpp31
-rw-r--r--clang/test/CodeGenCXX/__null.cpp9
-rw-r--r--clang/test/CodeGenCXX/abstract-class-ctors-dtors.cpp16
-rw-r--r--clang/test/CodeGenCXX/address-of-fntemplate.cpp27
-rw-r--r--clang/test/CodeGenCXX/alloca-align.cpp28
-rw-r--r--clang/test/CodeGenCXX/anonymous-namespaces.cpp68
-rw-r--r--clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp181
-rw-r--r--clang/test/CodeGenCXX/apple-kext-guard-variable.cpp9
-rw-r--r--clang/test/CodeGenCXX/apple-kext-indirect-call-2.C77
-rw-r--r--clang/test/CodeGenCXX/apple-kext-indirect-call.C14
-rw-r--r--clang/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp19
-rw-r--r--clang/test/CodeGenCXX/apple-kext-linkage.C33
-rw-r--r--clang/test/CodeGenCXX/apple-kext-no-staticinit-section.C20
-rw-r--r--clang/test/CodeGenCXX/apple-kext.cpp22
-rw-r--r--clang/test/CodeGenCXX/arm-cc.cpp20
-rw-r--r--clang/test/CodeGenCXX/arm.cpp369
-rw-r--r--clang/test/CodeGenCXX/array-construction.cpp37
-rw-r--r--clang/test/CodeGenCXX/array-operator-delete-call.cpp64
-rw-r--r--clang/test/CodeGenCXX/array-pointer-decay.cpp7
-rw-r--r--clang/test/CodeGenCXX/array-value-initialize.cpp52
-rw-r--r--clang/test/CodeGenCXX/asm.cpp14
-rw-r--r--clang/test/CodeGenCXX/assign-operator.cpp30
-rw-r--r--clang/test/CodeGenCXX/atomic.cpp17
-rw-r--r--clang/test/CodeGenCXX/atomicinit.cpp48
-rw-r--r--clang/test/CodeGenCXX/attr-used.cpp9
-rw-r--r--clang/test/CodeGenCXX/attr.cpp28
-rw-r--r--clang/test/CodeGenCXX/bitfield-layout.cpp43
-rw-r--r--clang/test/CodeGenCXX/block-byref-cxx-objc.cpp35
-rw-r--r--clang/test/CodeGenCXX/block-destruct.cpp9
-rw-r--r--clang/test/CodeGenCXX/block-in-ctor-dtor.cpp48
-rw-r--r--clang/test/CodeGenCXX/block.cpp19
-rw-r--r--clang/test/CodeGenCXX/blocks-cxx11.cpp84
-rw-r--r--clang/test/CodeGenCXX/blocks.cpp228
-rw-r--r--clang/test/CodeGenCXX/builtins.cpp21
-rw-r--r--clang/test/CodeGenCXX/c-linkage.cpp13
-rw-r--r--clang/test/CodeGenCXX/c99-variable-length-array.cpp37
-rw-r--r--clang/test/CodeGenCXX/call-arg-zero-temp.cpp23
-rw-r--r--clang/test/CodeGenCXX/cast-conversion.cpp33
-rw-r--r--clang/test/CodeGenCXX/casts.cpp20
-rw-r--r--clang/test/CodeGenCXX/class-layout.cpp79
-rw-r--r--clang/test/CodeGenCXX/compound-literals.cpp44
-rw-r--r--clang/test/CodeGenCXX/condition.cpp317
-rw-r--r--clang/test/CodeGenCXX/conditional-expr-lvalue.cpp20
-rw-r--r--clang/test/CodeGenCXX/conditional-gnu-ext.cpp150
-rw-r--r--clang/test/CodeGenCXX/conditional-temporaries.cpp55
-rw-r--r--clang/test/CodeGenCXX/const-base-cast.cpp10
-rw-r--r--clang/test/CodeGenCXX/const-global-linkage.cpp13
-rw-r--r--clang/test/CodeGenCXX/const-init-cxx11.cpp428
-rw-r--r--clang/test/CodeGenCXX/const-init.cpp78
-rw-r--r--clang/test/CodeGenCXX/constructor-attr.cpp12
-rw-r--r--clang/test/CodeGenCXX/constructor-conversion.cpp55
-rw-r--r--clang/test/CodeGenCXX/constructor-convert.cpp20
-rw-r--r--clang/test/CodeGenCXX/constructor-default-arg.cpp40
-rw-r--r--clang/test/CodeGenCXX/constructor-direct-call.cpp60
-rw-r--r--clang/test/CodeGenCXX/constructor-for-array-members.cpp44
-rw-r--r--clang/test/CodeGenCXX/constructor-init-reference.cpp9
-rw-r--r--clang/test/CodeGenCXX/constructor-init.cpp222
-rw-r--r--clang/test/CodeGenCXX/constructor-template.cpp54
-rw-r--r--clang/test/CodeGenCXX/constructors.cpp115
-rw-r--r--clang/test/CodeGenCXX/conversion-function.cpp120
-rw-r--r--clang/test/CodeGenCXX/conversion-operator-base.cpp7
-rw-r--r--clang/test/CodeGenCXX/convert-to-fptr.cpp47
-rw-r--r--clang/test/CodeGenCXX/copy-assign-synthesis-1.cpp109
-rw-r--r--clang/test/CodeGenCXX/copy-assign-synthesis-2.cpp4
-rw-r--r--clang/test/CodeGenCXX/copy-assign-synthesis-3.cpp24
-rw-r--r--clang/test/CodeGenCXX/copy-assign-synthesis.cpp79
-rw-r--r--clang/test/CodeGenCXX/copy-assign-volatile-synthesis.cpp43
-rw-r--r--clang/test/CodeGenCXX/copy-constructor-elim-2.cpp77
-rw-r--r--clang/test/CodeGenCXX/copy-constructor-elim.cpp42
-rw-r--r--clang/test/CodeGenCXX/copy-constructor-synthesis-2.cpp7
-rw-r--r--clang/test/CodeGenCXX/copy-constructor-synthesis.cpp156
-rw-r--r--clang/test/CodeGenCXX/copy-in-cplus-object.cpp28
-rw-r--r--clang/test/CodeGenCXX/copy-initialization.cpp29
-rw-r--r--clang/test/CodeGenCXX/cxx-apple-kext.cpp36
-rw-r--r--clang/test/CodeGenCXX/cxx-block-objects.cpp33
-rw-r--r--clang/test/CodeGenCXX/cxx0x-defaulted-templates.cpp19
-rw-r--r--clang/test/CodeGenCXX/cxx0x-delegating-ctors.cpp56
-rw-r--r--clang/test/CodeGenCXX/cxx0x-initializer-array.cpp10
-rw-r--r--clang/test/CodeGenCXX/cxx0x-initializer-references.cpp69
-rw-r--r--clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp7
-rw-r--r--clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp37
-rw-r--r--clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp85
-rw-r--r--clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp252
-rw-r--r--clang/test/CodeGenCXX/cxx11-exception-spec.cpp120
-rw-r--r--clang/test/CodeGenCXX/cxx11-unrestricted-union.cpp76
-rw-r--r--clang/test/CodeGenCXX/cxx11-user-defined-literal.cpp69
-rw-r--r--clang/test/CodeGenCXX/debug-info-artificial-arg.cpp30
-rw-r--r--clang/test/CodeGenCXX/debug-info-byval.cpp31
-rw-r--r--clang/test/CodeGenCXX/debug-info-char16.cpp6
-rw-r--r--clang/test/CodeGenCXX/debug-info-class.cpp12
-rw-r--r--clang/test/CodeGenCXX/debug-info-context.cpp17
-rw-r--r--clang/test/CodeGenCXX/debug-info-ctor.cpp14
-rw-r--r--clang/test/CodeGenCXX/debug-info-ctor2.cpp15
-rw-r--r--clang/test/CodeGenCXX/debug-info-cxx0x.cpp8
-rw-r--r--clang/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp24
-rw-r--r--clang/test/CodeGenCXX/debug-info-enum.cpp8
-rw-r--r--clang/test/CodeGenCXX/debug-info-fn-template.cpp15
-rw-r--r--clang/test/CodeGenCXX/debug-info-friend.cpp11
-rw-r--r--clang/test/CodeGenCXX/debug-info-fwd-ref.cpp26
-rw-r--r--clang/test/CodeGenCXX/debug-info-large-constant.cpp8
-rw-r--r--clang/test/CodeGenCXX/debug-info-limit-type.cpp24
-rw-r--r--clang/test/CodeGenCXX/debug-info-limit.cpp14
-rw-r--r--clang/test/CodeGenCXX/debug-info-member.cpp6
-rw-r--r--clang/test/CodeGenCXX/debug-info-method-spec.cpp10
-rw-r--r--clang/test/CodeGenCXX/debug-info-method.cpp6
-rw-r--r--clang/test/CodeGenCXX/debug-info-method2.cpp19
-rw-r--r--clang/test/CodeGenCXX/debug-info-namespace.cpp12
-rw-r--r--clang/test/CodeGenCXX/debug-info-nullptr.cpp7
-rw-r--r--clang/test/CodeGenCXX/debug-info-pubtypes.cpp17
-rw-r--r--clang/test/CodeGenCXX/debug-info-static-fns.cpp10
-rw-r--r--clang/test/CodeGenCXX/debug-info-template-limit.cpp15
-rw-r--r--clang/test/CodeGenCXX/debug-info-template-member.cpp21
-rw-r--r--clang/test/CodeGenCXX/debug-info-template-recursive.cpp13
-rw-r--r--clang/test/CodeGenCXX/debug-info-template.cpp46
-rw-r--r--clang/test/CodeGenCXX/debug-info-this.cpp15
-rw-r--r--clang/test/CodeGenCXX/debug-info-use-after-free.cpp312
-rw-r--r--clang/test/CodeGenCXX/debug-info-wchar.cpp5
-rw-r--r--clang/test/CodeGenCXX/debug-info.cpp69
-rw-r--r--clang/test/CodeGenCXX/debug-lambda-expressions.cpp71
-rw-r--r--clang/test/CodeGenCXX/decl-ref-init.cpp31
-rw-r--r--clang/test/CodeGenCXX/default-arg-temps.cpp73
-rw-r--r--clang/test/CodeGenCXX/default-arguments.cpp76
-rw-r--r--clang/test/CodeGenCXX/default-constructor-default-argument.cpp8
-rw-r--r--clang/test/CodeGenCXX/default-constructor-for-members.cpp24
-rw-r--r--clang/test/CodeGenCXX/default-constructor-template-member.cpp10
-rw-r--r--clang/test/CodeGenCXX/default-destructor-nested.cpp13
-rw-r--r--clang/test/CodeGenCXX/default-destructor-synthesis.cpp36
-rw-r--r--clang/test/CodeGenCXX/deferred-global-init.cpp16
-rw-r--r--clang/test/CodeGenCXX/delete-two-arg.cpp70
-rw-r--r--clang/test/CodeGenCXX/delete.cpp135
-rw-r--r--clang/test/CodeGenCXX/dependent-type-member-pointer.cpp18
-rw-r--r--clang/test/CodeGenCXX/derived-to-base-conv.cpp85
-rw-r--r--clang/test/CodeGenCXX/derived-to-base.cpp47
-rw-r--r--clang/test/CodeGenCXX/derived-to-virtual-base-class-calls-final.cpp16
-rw-r--r--clang/test/CodeGenCXX/destructor-calls.cpp41
-rw-r--r--clang/test/CodeGenCXX/destructor-debug-info.cpp21
-rw-r--r--clang/test/CodeGenCXX/destructors.cpp403
-rw-r--r--clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp51
-rw-r--r--clang/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp55
-rw-r--r--clang/test/CodeGenCXX/dynamic-cast-always-null.cpp19
-rw-r--r--clang/test/CodeGenCXX/dynamic-cast.cpp18
-rw-r--r--clang/test/CodeGenCXX/eh.cpp446
-rw-r--r--clang/test/CodeGenCXX/elide-call-reference.cpp11
-rw-r--r--clang/test/CodeGenCXX/empty-classes.cpp82
-rw-r--r--clang/test/CodeGenCXX/empty-union.cpp7
-rw-r--r--clang/test/CodeGenCXX/enum.cpp4
-rw-r--r--clang/test/CodeGenCXX/eval-recursive-constant.cpp5
-rw-r--r--clang/test/CodeGenCXX/exceptions-no-rtti.cpp51
-rw-r--r--clang/test/CodeGenCXX/exceptions.cpp416
-rw-r--r--clang/test/CodeGenCXX/explicit-instantiation.cpp45
-rw-r--r--clang/test/CodeGenCXX/expr.cpp37
-rw-r--r--clang/test/CodeGenCXX/extern-c.cpp16
-rw-r--r--clang/test/CodeGenCXX/field-access-debug-info.cpp14
-rw-r--r--clang/test/CodeGenCXX/for-range-temporaries.cpp146
-rw-r--r--clang/test/CodeGenCXX/for-range.cpp128
-rw-r--r--clang/test/CodeGenCXX/forward-enum.cpp11
-rw-r--r--clang/test/CodeGenCXX/fp16-mangle.cpp12
-rw-r--r--clang/test/CodeGenCXX/fp16-overload.cpp10
-rw-r--r--clang/test/CodeGenCXX/friend-redecl.cpp18
-rw-r--r--clang/test/CodeGenCXX/function-template-explicit-specialization.cpp13
-rw-r--r--clang/test/CodeGenCXX/function-template-specialization.cpp26
-rw-r--r--clang/test/CodeGenCXX/global-array-destruction.cpp34
-rw-r--r--clang/test/CodeGenCXX/global-dtor-no-atexit.cpp44
-rw-r--r--clang/test/CodeGenCXX/global-init-darwin.cpp23
-rw-r--r--clang/test/CodeGenCXX/global-init.cpp122
-rw-r--r--clang/test/CodeGenCXX/global-llvm-constant.cpp32
-rw-r--r--clang/test/CodeGenCXX/goto.cpp43
-rw-r--r--clang/test/CodeGenCXX/implicit-copy-assign-operator.cpp56
-rw-r--r--clang/test/CodeGenCXX/implicit-copy-constructor.cpp82
-rw-r--r--clang/test/CodeGenCXX/implicit-instantiation-1.cpp28
-rw-r--r--clang/test/CodeGenCXX/incomplete-member-function-pointer.cpp10
-rw-r--r--clang/test/CodeGenCXX/incomplete-types.cpp43
-rw-r--r--clang/test/CodeGenCXX/inheriting-constructor.cpp11
-rw-r--r--clang/test/CodeGenCXX/init-invariant.cpp60
-rw-r--r--clang/test/CodeGenCXX/inline-functions.cpp55
-rw-r--r--clang/test/CodeGenCXX/instantiate-blocks.cpp59
-rw-r--r--clang/test/CodeGenCXX/instantiate-init-list.cpp13
-rw-r--r--clang/test/CodeGenCXX/instantiate-temporaries.cpp37
-rw-r--r--clang/test/CodeGenCXX/instrument-functions.cpp30
-rw-r--r--clang/test/CodeGenCXX/internal-linkage.cpp64
-rw-r--r--clang/test/CodeGenCXX/key-function-vtable.cpp52
-rw-r--r--clang/test/CodeGenCXX/lambda-expressions.cpp78
-rw-r--r--clang/test/CodeGenCXX/lvalue-bitcasts.cpp163
-rw-r--r--clang/test/CodeGenCXX/m64-ptr.cpp18
-rw-r--r--clang/test/CodeGenCXX/mangle-98.cpp12
-rw-r--r--clang/test/CodeGenCXX/mangle-abi-examples.cpp27
-rw-r--r--clang/test/CodeGenCXX/mangle-address-space.cpp12
-rw-r--r--clang/test/CodeGenCXX/mangle-alias-template.cpp48
-rw-r--r--clang/test/CodeGenCXX/mangle-exprs.cpp193
-rw-r--r--clang/test/CodeGenCXX/mangle-extern-local.cpp45
-rw-r--r--clang/test/CodeGenCXX/mangle-extreme.cpp47
-rw-r--r--clang/test/CodeGenCXX/mangle-lambdas.cpp202
-rw-r--r--clang/test/CodeGenCXX/mangle-local-class-names.cpp57
-rw-r--r--clang/test/CodeGenCXX/mangle-local-class-vtables.cpp61
-rw-r--r--clang/test/CodeGenCXX/mangle-local-classes-nested.cpp81
-rw-r--r--clang/test/CodeGenCXX/mangle-ms.cpp105
-rw-r--r--clang/test/CodeGenCXX/mangle-neon-vectors.cpp32
-rw-r--r--clang/test/CodeGenCXX/mangle-nullptr-arg.cpp13
-rw-r--r--clang/test/CodeGenCXX/mangle-ref-qualifiers.cpp16
-rw-r--r--clang/test/CodeGenCXX/mangle-std-externc.cpp27
-rw-r--r--clang/test/CodeGenCXX/mangle-subst-std.cpp112
-rw-r--r--clang/test/CodeGenCXX/mangle-subst.cpp82
-rw-r--r--clang/test/CodeGenCXX/mangle-system-header.cpp11
-rw-r--r--clang/test/CodeGenCXX/mangle-template.cpp172
-rw-r--r--clang/test/CodeGenCXX/mangle-this-cxx11.cpp20
-rw-r--r--clang/test/CodeGenCXX/mangle-unnameable-conversions.cpp14
-rw-r--r--clang/test/CodeGenCXX/mangle-unnamed.cpp92
-rw-r--r--clang/test/CodeGenCXX/mangle-variadic-templates.cpp67
-rw-r--r--clang/test/CodeGenCXX/mangle.cpp854
-rw-r--r--clang/test/CodeGenCXX/member-alignment.cpp20
-rw-r--r--clang/test/CodeGenCXX/member-call-parens.cpp12
-rw-r--r--clang/test/CodeGenCXX/member-expressions.cpp86
-rw-r--r--clang/test/CodeGenCXX/member-function-pointer-calls.cpp23
-rw-r--r--clang/test/CodeGenCXX/member-function-pointers.cpp274
-rw-r--r--clang/test/CodeGenCXX/member-functions.cpp63
-rw-r--r--clang/test/CodeGenCXX/member-init-anon-union.cpp35
-rw-r--r--clang/test/CodeGenCXX/member-init-assignment.cpp17
-rw-r--r--clang/test/CodeGenCXX/member-init-ctor.cpp14
-rw-r--r--clang/test/CodeGenCXX/member-init-struct.cpp18
-rw-r--r--clang/test/CodeGenCXX/member-init-union.cpp10
-rw-r--r--clang/test/CodeGenCXX/member-initializers.cpp34
-rw-r--r--clang/test/CodeGenCXX/member-pointer-type-convert.cpp11
-rw-r--r--clang/test/CodeGenCXX/member-templates.cpp31
-rw-r--r--clang/test/CodeGenCXX/multi-dim-operator-new.cpp49
-rw-r--r--clang/test/CodeGenCXX/namespace-aliases.cpp9
-rw-r--r--clang/test/CodeGenCXX/nested-base-member-access.cpp52
-rw-r--r--clang/test/CodeGenCXX/new-array-init-exceptions.cpp41
-rw-r--r--clang/test/CodeGenCXX/new-array-init.cpp33
-rw-r--r--clang/test/CodeGenCXX/new-operator-phi.cpp11
-rw-r--r--clang/test/CodeGenCXX/new-overflow.cpp209
-rw-r--r--clang/test/CodeGenCXX/new-with-default-arg.cpp33
-rw-r--r--clang/test/CodeGenCXX/new.cpp252
-rw-r--r--clang/test/CodeGenCXX/no-exceptions.cpp12
-rw-r--r--clang/test/CodeGenCXX/noinline-template.cpp16
-rw-r--r--clang/test/CodeGenCXX/nonconst-init.cpp5
-rw-r--r--clang/test/CodeGenCXX/nrvo-noreturn.cc17
-rw-r--r--clang/test/CodeGenCXX/nrvo.cpp161
-rw-r--r--clang/test/CodeGenCXX/nullptr.cpp24
-rw-r--r--clang/test/CodeGenCXX/operator-new.cpp29
-rw-r--r--clang/test/CodeGenCXX/overload-binop-implicitconvert.cpp22
-rw-r--r--clang/test/CodeGenCXX/override-layout.cpp64
-rw-r--r--clang/test/CodeGenCXX/partial-destruction.cpp172
-rw-r--r--clang/test/CodeGenCXX/pointers-to-data-members.cpp242
-rw-r--r--clang/test/CodeGenCXX/pr11676.cpp17
-rw-r--r--clang/test/CodeGenCXX/pr11797.cpp8
-rw-r--r--clang/test/CodeGenCXX/pr12104.cpp7
-rw-r--r--clang/test/CodeGenCXX/pr12104.h9
-rw-r--r--clang/test/CodeGenCXX/pr12251.cpp146
-rw-r--r--clang/test/CodeGenCXX/pr9130.cpp14
-rw-r--r--clang/test/CodeGenCXX/pr9965.cpp14
-rw-r--r--clang/test/CodeGenCXX/pragma-pack-2.cpp17
-rw-r--r--clang/test/CodeGenCXX/pragma-pack.cpp16
-rw-r--r--clang/test/CodeGenCXX/pragma-visibility.cpp62
-rw-r--r--clang/test/CodeGenCXX/predefined-expr-sizeof.cpp30
-rw-r--r--clang/test/CodeGenCXX/predefined-expr.cpp517
-rw-r--r--clang/test/CodeGenCXX/ptr-to-datamember.cpp99
-rw-r--r--clang/test/CodeGenCXX/ptr-to-member-function.cpp71
-rw-r--r--clang/test/CodeGenCXX/reference-bind-default-argument.cpp6
-rw-r--r--clang/test/CodeGenCXX/reference-cast.cpp194
-rw-r--r--clang/test/CodeGenCXX/reference-field.cpp6
-rw-r--r--clang/test/CodeGenCXX/reference-in-block-args.cpp29
-rw-r--r--clang/test/CodeGenCXX/reference-in-blocks.cpp43
-rw-r--r--clang/test/CodeGenCXX/reference-init.cpp24
-rw-r--r--clang/test/CodeGenCXX/references.cpp313
-rw-r--r--clang/test/CodeGenCXX/regparm.cpp6
-rw-r--r--clang/test/CodeGenCXX/reinterpret-cast.cpp17
-rw-r--r--clang/test/CodeGenCXX/rtti-fundamental.cpp116
-rw-r--r--clang/test/CodeGenCXX/rtti-layout.cpp205
-rw-r--r--clang/test/CodeGenCXX/rtti-linkage.cpp140
-rw-r--r--clang/test/CodeGenCXX/rtti-visibility.cpp35
-rw-r--r--clang/test/CodeGenCXX/rvalue-references.cpp111
-rw-r--r--clang/test/CodeGenCXX/scoped-enums.cpp9
-rw-r--r--clang/test/CodeGenCXX/sel-address.mm14
-rw-r--r--clang/test/CodeGenCXX/sizeof-unwind-exception.cpp28
-rw-r--r--clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp200
-rw-r--r--clang/test/CodeGenCXX/specialized-static-data-mem-init.cpp29
-rw-r--r--clang/test/CodeGenCXX/static-assert.cpp7
-rw-r--r--clang/test/CodeGenCXX/static-data-member.cpp104
-rw-r--r--clang/test/CodeGenCXX/static-init-1.cpp23
-rw-r--r--clang/test/CodeGenCXX/static-init-2.cpp6
-rw-r--r--clang/test/CodeGenCXX/static-init-3.cpp28
-rw-r--r--clang/test/CodeGenCXX/static-init.cpp154
-rw-r--r--clang/test/CodeGenCXX/static-local-in-local-class.cpp33
-rw-r--r--clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp11
-rw-r--r--clang/test/CodeGenCXX/static-mutable.cpp12
-rw-r--r--clang/test/CodeGenCXX/stmtexpr.cpp75
-rw-r--r--clang/test/CodeGenCXX/switch-case-folding-1.cpp22
-rw-r--r--clang/test/CodeGenCXX/switch-case-folding-2.cpp21
-rw-r--r--clang/test/CodeGenCXX/switch-case-folding.cpp18
-rw-r--r--clang/test/CodeGenCXX/temp-order.cpp226
-rw-r--r--clang/test/CodeGenCXX/template-anonymous-types.cpp37
-rw-r--r--clang/test/CodeGenCXX/template-anonymous-union-member-initializer.cpp11
-rw-r--r--clang/test/CodeGenCXX/template-dependent-bind-temporary.cpp24
-rw-r--r--clang/test/CodeGenCXX/template-inner-struct-visibility-hidden.cpp24
-rw-r--r--clang/test/CodeGenCXX/template-instantiation.cpp190
-rw-r--r--clang/test/CodeGenCXX/template-linkage.cpp44
-rw-r--r--clang/test/CodeGenCXX/template-static-var-defer.cpp12
-rw-r--r--clang/test/CodeGenCXX/temporaries.cpp539
-rw-r--r--clang/test/CodeGenCXX/thiscall-struct-return.cpp41
-rw-r--r--clang/test/CodeGenCXX/threadsafe-statics-exceptions.cpp28
-rw-r--r--clang/test/CodeGenCXX/threadsafe-statics.cpp23
-rw-r--r--clang/test/CodeGenCXX/throw-expression-dtor.cpp13
-rw-r--r--clang/test/CodeGenCXX/throw-expressions.cpp20
-rw-r--r--clang/test/CodeGenCXX/thunk-linkonce-odr.cpp33
-rw-r--r--clang/test/CodeGenCXX/thunk-use-after-free.cpp42
-rw-r--r--clang/test/CodeGenCXX/thunks-available-externally.cpp88
-rw-r--r--clang/test/CodeGenCXX/thunks.cpp308
-rw-r--r--clang/test/CodeGenCXX/trivial-constructor-init.cpp20
-rw-r--r--clang/test/CodeGenCXX/try-catch.cpp13
-rw-r--r--clang/test/CodeGenCXX/typeid-cxx11.cpp30
-rw-r--r--clang/test/CodeGenCXX/typeid.cpp44
-rw-r--r--clang/test/CodeGenCXX/typeinfo16
-rw-r--r--clang/test/CodeGenCXX/unary-type-trait.cpp3
-rw-r--r--clang/test/CodeGenCXX/uncode-string.cpp6
-rw-r--r--clang/test/CodeGenCXX/union-dtor.cpp42
-rw-r--r--clang/test/CodeGenCXX/unknown-anytype.cpp99
-rw-r--r--clang/test/CodeGenCXX/value-init.cpp262
-rw-r--r--clang/test/CodeGenCXX/vararg-conversion-ctor.cpp23
-rw-r--r--clang/test/CodeGenCXX/vararg-non-pod.cpp16
-rw-r--r--clang/test/CodeGenCXX/varargs.cpp43
-rw-r--r--clang/test/CodeGenCXX/variadic-templates.cpp23
-rw-r--r--clang/test/CodeGenCXX/virt-call-offsets.cpp8
-rw-r--r--clang/test/CodeGenCXX/virt-canonical-decl.cpp19
-rw-r--r--clang/test/CodeGenCXX/virt-dtor-gen.cpp10
-rw-r--r--clang/test/CodeGenCXX/virt-dtor-key.cpp9
-rw-r--r--clang/test/CodeGenCXX/virt-template-vtable.cpp22
-rw-r--r--clang/test/CodeGenCXX/virt-thunk-reference.cpp7
-rw-r--r--clang/test/CodeGenCXX/virtual-base-cast.cpp33
-rw-r--r--clang/test/CodeGenCXX/virtual-base-ctor.cpp11
-rw-r--r--clang/test/CodeGenCXX/virtual-base-destructor-call.cpp51
-rw-r--r--clang/test/CodeGenCXX/virtual-bases.cpp48
-rw-r--r--clang/test/CodeGenCXX/virtual-destructor-calls.cpp48
-rw-r--r--clang/test/CodeGenCXX/virtual-destructor-synthesis.cpp16
-rw-r--r--clang/test/CodeGenCXX/virtual-function-calls.cpp38
-rw-r--r--clang/test/CodeGenCXX/virtual-functions-incomplete-types.cpp30
-rw-r--r--clang/test/CodeGenCXX/virtual-implicit-copy-assignment.cpp11
-rw-r--r--clang/test/CodeGenCXX/virtual-implicit-move-assignment.cpp12
-rw-r--r--clang/test/CodeGenCXX/virtual-inherited-destructor.cpp8
-rw-r--r--clang/test/CodeGenCXX/virtual-operator-call.cpp10
-rw-r--r--clang/test/CodeGenCXX/virtual-pseudo-destructor-call.cpp14
-rw-r--r--clang/test/CodeGenCXX/visibility-hidden-extern-templates.cpp26
-rw-r--r--clang/test/CodeGenCXX/visibility-inlines-hidden.cpp110
-rw-r--r--clang/test/CodeGenCXX/visibility.cpp607
-rw-r--r--clang/test/CodeGenCXX/vla.cpp56
-rw-r--r--clang/test/CodeGenCXX/volatile-1.cpp352
-rw-r--r--clang/test/CodeGenCXX/volatile.cpp33
-rw-r--r--clang/test/CodeGenCXX/vtable-available-externally.cpp171
-rw-r--r--clang/test/CodeGenCXX/vtable-cast-crash.cpp21
-rw-r--r--clang/test/CodeGenCXX/vtable-debug-info.cpp319
-rw-r--r--clang/test/CodeGenCXX/vtable-key-function.cpp33
-rw-r--r--clang/test/CodeGenCXX/vtable-layout-abi-examples.cpp322
-rw-r--r--clang/test/CodeGenCXX/vtable-layout-extreme.cpp210
-rw-r--r--clang/test/CodeGenCXX/vtable-layout.cpp1729
-rw-r--r--clang/test/CodeGenCXX/vtable-linkage.cpp216
-rw-r--r--clang/test/CodeGenCXX/vtable-pointer-initialization.cpp57
-rw-r--r--clang/test/CodeGenCXX/vtt-layout.cpp64
-rw-r--r--clang/test/CodeGenCXX/warn-padded-packed.cpp76
-rw-r--r--clang/test/CodeGenCXX/weak-extern-typeinfo.cpp47
-rw-r--r--clang/test/CodeGenCXX/weak-external.cpp66
-rw-r--r--clang/test/CodeGenCXX/x86_32-arguments.cpp116
-rw-r--r--clang/test/CodeGenCXX/x86_64-arguments.cpp183
-rw-r--r--clang/test/CodeGenObjC/2007-04-03-ObjcEH.m27
-rw-r--r--clang/test/CodeGenObjC/2007-05-02-Strong.m23
-rw-r--r--clang/test/CodeGenObjC/2007-10-18-ProDescriptor.m18
-rw-r--r--clang/test/CodeGenObjC/2007-10-23-GC-WriteBarrier.m9
-rw-r--r--clang/test/CodeGenObjC/2008-08-25-incompatible-cond-expr.m10
-rw-r--r--clang/test/CodeGenObjC/2008-10-23-invalid-icmp.m7
-rw-r--r--clang/test/CodeGenObjC/2008-10-3-EhValue.m50
-rw-r--r--clang/test/CodeGenObjC/2008-11-12-Metadata.m14
-rw-r--r--clang/test/CodeGenObjC/2008-11-24-ConstCFStrings.m13
-rw-r--r--clang/test/CodeGenObjC/2008-11-25-Blocks.m17
-rw-r--r--clang/test/CodeGenObjC/2009-01-21-invalid-debug-info.m16
-rw-r--r--clang/test/CodeGenObjC/2009-01-26-WriteBarrier-2.m19
-rw-r--r--clang/test/CodeGenObjC/2009-02-05-VolatileProp.m10
-rw-r--r--clang/test/CodeGenObjC/2009-08-05-utf16.m5
-rw-r--r--clang/test/CodeGenObjC/2010-02-01-utf16-with-null.m5
-rw-r--r--clang/test/CodeGenObjC/2010-02-09-DbgSelf.m14
-rw-r--r--clang/test/CodeGenObjC/2010-02-15-Dbg-MethodStart.m15
-rw-r--r--clang/test/CodeGenObjC/2010-02-23-DbgInheritance.m10
-rw-r--r--clang/test/CodeGenObjC/2010-03-17-StructRef.m43
-rw-r--r--clang/test/CodeGenObjC/2011-03-08-IVarLookup.m30
-rw-r--r--clang/test/CodeGenObjC/Inputs/literal-support.h35
-rw-r--r--clang/test/CodeGenObjC/arc-arm.m20
-rw-r--r--clang/test/CodeGenObjC/arc-block-copy-escape.m22
-rw-r--r--clang/test/CodeGenObjC/arc-block-ivar-layout.m60
-rw-r--r--clang/test/CodeGenObjC/arc-blocks.m523
-rw-r--r--clang/test/CodeGenObjC/arc-bridged-cast.m90
-rw-r--r--clang/test/CodeGenObjC/arc-compound-stmt.m29
-rw-r--r--clang/test/CodeGenObjC/arc-cond-stmt.m48
-rw-r--r--clang/test/CodeGenObjC/arc-exceptions.m45
-rw-r--r--clang/test/CodeGenObjC/arc-foreach.m173
-rw-r--r--clang/test/CodeGenObjC/arc-ivar-layout.m55
-rw-r--r--clang/test/CodeGenObjC/arc-literals.m121
-rw-r--r--clang/test/CodeGenObjC/arc-no-arc-exceptions.m78
-rw-r--r--clang/test/CodeGenObjC/arc-no-runtime.m9
-rw-r--r--clang/test/CodeGenObjC/arc-property.m15
-rw-r--r--clang/test/CodeGenObjC/arc-related-result-type.m30
-rw-r--r--clang/test/CodeGenObjC/arc-unbridged-cast.m35
-rw-r--r--clang/test/CodeGenObjC/arc-unopt.m69
-rw-r--r--clang/test/CodeGenObjC/arc-weak-property.m55
-rw-r--r--clang/test/CodeGenObjC/arc-with-atthrow.m17
-rw-r--r--clang/test/CodeGenObjC/arc.m1539
-rw-r--r--clang/test/CodeGenObjC/arm-atomic-scalar-setter-getter.m13
-rw-r--r--clang/test/CodeGenObjC/assign.m36
-rw-r--r--clang/test/CodeGenObjC/atomic-aggregate-property.m42
-rw-r--r--clang/test/CodeGenObjC/attr-availability.m24
-rw-r--r--clang/test/CodeGenObjC/attr-strong.c9
-rw-r--r--clang/test/CodeGenObjC/auto-property-synthesize-protocol.m37
-rw-r--r--clang/test/CodeGenObjC/autorelease.m30
-rw-r--r--clang/test/CodeGenObjC/bitfield-1.m81
-rw-r--r--clang/test/CodeGenObjC/bitfield-access.m44
-rw-r--r--clang/test/CodeGenObjC/bitfield-gnu.m5
-rw-r--r--clang/test/CodeGenObjC/bitfield-ivar-metadata.m15
-rw-r--r--clang/test/CodeGenObjC/bitfield-ivar-offsets.m25
-rw-r--r--clang/test/CodeGenObjC/bitfield_encoding.m12
-rw-r--r--clang/test/CodeGenObjC/block-6.m18
-rw-r--r--clang/test/CodeGenObjC/block-var-layout.m166
-rw-r--r--clang/test/CodeGenObjC/blocks-1.m43
-rw-r--r--clang/test/CodeGenObjC/blocks-2.m38
-rw-r--r--clang/test/CodeGenObjC/blocks-3.m21
-rw-r--r--clang/test/CodeGenObjC/blocks-4.m21
-rw-r--r--clang/test/CodeGenObjC/blocks-5.m37
-rw-r--r--clang/test/CodeGenObjC/blocks-ivar-debug.m20
-rw-r--r--clang/test/CodeGenObjC/blocks.m102
-rw-r--r--clang/test/CodeGenObjC/builtins.m7
-rw-r--r--clang/test/CodeGenObjC/catch-lexical-block.m16
-rw-r--r--clang/test/CodeGenObjC/category-class.m17
-rw-r--r--clang/test/CodeGenObjC/category-super-class-meth.m19
-rw-r--r--clang/test/CodeGenObjC/class-getter-dotsyntax.m21
-rw-r--r--clang/test/CodeGenObjC/class-type.m36
-rw-r--r--clang/test/CodeGenObjC/compatibility-alias.m8
-rw-r--r--clang/test/CodeGenObjC/complex-double-abi.m16
-rw-r--r--clang/test/CodeGenObjC/complex-property.m32
-rw-r--r--clang/test/CodeGenObjC/constant-string-class-1.m23
-rw-r--r--clang/test/CodeGenObjC/constant-string-class.m35
-rw-r--r--clang/test/CodeGenObjC/constant-strings.m16
-rw-r--r--clang/test/CodeGenObjC/continuation-class.m35
-rw-r--r--clang/test/CodeGenObjC/deadcode_strip_used_var.m9
-rw-r--r--clang/test/CodeGenObjC/debug-info-block-helper.m30
-rw-r--r--clang/test/CodeGenObjC/debug-info-blocks.m55
-rw-r--r--clang/test/CodeGenObjC/debug-info-class-extension.m15
-rw-r--r--clang/test/CodeGenObjC/debug-info-class-extension2.m14
-rw-r--r--clang/test/CodeGenObjC/debug-info-class-extension3.m12
-rw-r--r--clang/test/CodeGenObjC/debug-info-crash-2.m15
-rw-r--r--clang/test/CodeGenObjC/debug-info-crash.m41
-rw-r--r--clang/test/CodeGenObjC/debug-info-default-synth-ivar.m35
-rw-r--r--clang/test/CodeGenObjC/debug-info-fwddecl.m5
-rw-r--r--clang/test/CodeGenObjC/debug-info-getter-name.m54
-rw-r--r--clang/test/CodeGenObjC/debug-info-impl.m16
-rw-r--r--clang/test/CodeGenObjC/debug-info-linkagename.m18
-rw-r--r--clang/test/CodeGenObjC/debug-info-property.m14
-rw-r--r--clang/test/CodeGenObjC/debug-info-property2.m14
-rw-r--r--clang/test/CodeGenObjC/debug-info-property3.m12
-rw-r--r--clang/test/CodeGenObjC/debug-info-property4.m17
-rw-r--r--clang/test/CodeGenObjC/debug-info-property5.m32
-rw-r--r--clang/test/CodeGenObjC/debug-info-pubtypes.m14
-rw-r--r--clang/test/CodeGenObjC/debug-info-selector.m15
-rw-r--r--clang/test/CodeGenObjC/debug-info-self.m16
-rw-r--r--clang/test/CodeGenObjC/debug-info-static-var.m23
-rw-r--r--clang/test/CodeGenObjC/debug-info-synthesis.m34
-rw-r--r--clang/test/CodeGenObjC/debug-property-synth.m20
-rw-r--r--clang/test/CodeGenObjC/default-property-synthesis.m38
-rw-r--r--clang/test/CodeGenObjC/dot-syntax-1.m264
-rw-r--r--clang/test/CodeGenObjC/dot-syntax-2.m27
-rw-r--r--clang/test/CodeGenObjC/dot-syntax.m98
-rw-r--r--clang/test/CodeGenObjC/encode-cstyle-method.m11
-rw-r--r--clang/test/CodeGenObjC/encode-test-2.m30
-rw-r--r--clang/test/CodeGenObjC/encode-test-3.m21
-rw-r--r--clang/test/CodeGenObjC/encode-test-4.m10
-rw-r--r--clang/test/CodeGenObjC/encode-test-5.m16
-rw-r--r--clang/test/CodeGenObjC/encode-test.m167
-rw-r--r--clang/test/CodeGenObjC/exceptions-nonfragile.m31
-rw-r--r--clang/test/CodeGenObjC/exceptions.m183
-rw-r--r--clang/test/CodeGenObjC/for-in.m50
-rw-r--r--clang/test/CodeGenObjC/forward-class-impl-metadata.m47
-rw-r--r--clang/test/CodeGenObjC/forward-decl-param.m19
-rw-r--r--clang/test/CodeGenObjC/fp2ret.m28
-rw-r--r--clang/test/CodeGenObjC/fpret.m38
-rw-r--r--clang/test/CodeGenObjC/function-decay.m10
-rw-r--r--clang/test/CodeGenObjC/gc-weak-attribute.m28
-rw-r--r--clang/test/CodeGenObjC/gc.m14
-rw-r--r--clang/test/CodeGenObjC/gnu-exceptions.m29
-rw-r--r--clang/test/CodeGenObjC/hidden-visibility.m25
-rw-r--r--clang/test/CodeGenObjC/hidden.m19
-rw-r--r--clang/test/CodeGenObjC/id-isa-codegen.m73
-rw-r--r--clang/test/CodeGenObjC/illegal-UTF8.m6
-rw-r--r--clang/test/CodeGenObjC/image-info.m17
-rw-r--r--clang/test/CodeGenObjC/implicit-objc_msgSend.m7
-rw-r--r--clang/test/CodeGenObjC/implicit-property.m16
-rw-r--r--clang/test/CodeGenObjC/instance-method-metadata.m35
-rw-r--r--clang/test/CodeGenObjC/interface-layout-64.m123
-rw-r--r--clang/test/CodeGenObjC/interface.m34
-rw-r--r--clang/test/CodeGenObjC/ivar-base-as-invariant-load.m29
-rw-r--r--clang/test/CodeGenObjC/ivar-layout-64-bitfields.m46
-rw-r--r--clang/test/CodeGenObjC/ivar-layout-64.m94
-rw-r--r--clang/test/CodeGenObjC/ivar-layout-array0-struct.m23
-rw-r--r--clang/test/CodeGenObjC/ivar-layout-no-optimize.m20
-rw-r--r--clang/test/CodeGenObjC/ivar-layout-nonfragile-abi2.m51
-rw-r--r--clang/test/CodeGenObjC/ivars.m29
-rw-r--r--clang/test/CodeGenObjC/link-errors.m39
-rw-r--r--clang/test/CodeGenObjC/local-static-block.m57
-rw-r--r--clang/test/CodeGenObjC/message-arrays.m15
-rw-r--r--clang/test/CodeGenObjC/messages-2.m175
-rw-r--r--clang/test/CodeGenObjC/messages.m47
-rw-r--r--clang/test/CodeGenObjC/metadata-symbols-32.m87
-rw-r--r--clang/test/CodeGenObjC/metadata-symbols-64.m129
-rw-r--r--clang/test/CodeGenObjC/metadata_symbols.m75
-rw-r--r--clang/test/CodeGenObjC/misc-atomic-property.m80
-rw-r--r--clang/test/CodeGenObjC/mrr-autorelease.m24
-rw-r--r--clang/test/CodeGenObjC/nested-rethrow.m25
-rw-r--r--clang/test/CodeGenObjC/newproperty-nested-synthesis-1.m78
-rw-r--r--clang/test/CodeGenObjC/next-objc-dispatch.m73
-rw-r--r--clang/test/CodeGenObjC/no-category-class.m8
-rw-r--r--clang/test/CodeGenObjC/no-vararg-messaging.m19
-rw-r--r--clang/test/CodeGenObjC/non-lazy-classes.m32
-rw-r--r--clang/test/CodeGenObjC/nonlazy-msgSend.m6
-rw-r--r--clang/test/CodeGenObjC/ns-constant-strings.m39
-rw-r--r--clang/test/CodeGenObjC/ns_consume_null_check.m32
-rw-r--r--clang/test/CodeGenObjC/objc-align.m44
-rw-r--r--clang/test/CodeGenObjC/objc-arc-container-subscripting.m21
-rw-r--r--clang/test/CodeGenObjC/objc-assign-ivar.m52
-rw-r--r--clang/test/CodeGenObjC/objc-container-subscripting-1.m56
-rw-r--r--clang/test/CodeGenObjC/objc-container-subscripting.m45
-rw-r--r--clang/test/CodeGenObjC/objc-dictionary-literal.m25
-rw-r--r--clang/test/CodeGenObjC/objc-gc-aggr-assign.m62
-rw-r--r--clang/test/CodeGenObjC/objc-literal-debugger-test.m16
-rw-r--r--clang/test/CodeGenObjC/objc-literal-tests.m95
-rw-r--r--clang/test/CodeGenObjC/objc-read-weak-byref.m26
-rw-r--r--clang/test/CodeGenObjC/objc2-assign-global.m80
-rw-r--r--clang/test/CodeGenObjC/objc2-ivar-assign.m40
-rw-r--r--clang/test/CodeGenObjC/objc2-legacy-dispatch.m26
-rw-r--r--clang/test/CodeGenObjC/objc2-new-gc-api-strongcast.m27
-rw-r--r--clang/test/CodeGenObjC/objc2-no-strong-cast.m22
-rw-r--r--clang/test/CodeGenObjC/objc2-no-write-barrier.m20
-rw-r--r--clang/test/CodeGenObjC/objc2-nonfragile-abi-impl.m15
-rw-r--r--clang/test/CodeGenObjC/objc2-property-encode.m13
-rw-r--r--clang/test/CodeGenObjC/objc2-protocol-enc.m43
-rw-r--r--clang/test/CodeGenObjC/objc2-retain-codegen.m13
-rw-r--r--clang/test/CodeGenObjC/objc2-strong-cast-1.m24
-rw-r--r--clang/test/CodeGenObjC/objc2-strong-cast-block-import.m25
-rw-r--r--clang/test/CodeGenObjC/objc2-strong-cast.m18
-rw-r--r--clang/test/CodeGenObjC/objc2-weak-assign.m28
-rw-r--r--clang/test/CodeGenObjC/objc2-weak-block-call.m24
-rw-r--r--clang/test/CodeGenObjC/objc2-weak-compare.m26
-rw-r--r--clang/test/CodeGenObjC/objc2-weak-import-attribute.m48
-rw-r--r--clang/test/CodeGenObjC/objc2-weak-ivar-debug.m17
-rw-r--r--clang/test/CodeGenObjC/objc2-weak-ivar.m11
-rw-r--r--clang/test/CodeGenObjC/objc2-write-barrier-2.m83
-rw-r--r--clang/test/CodeGenObjC/objc2-write-barrier-3.m49
-rw-r--r--clang/test/CodeGenObjC/objc2-write-barrier-4.m30
-rw-r--r--clang/test/CodeGenObjC/objc2-write-barrier-5.m46
-rw-r--r--clang/test/CodeGenObjC/objc2-write-barrier.m116
-rw-r--r--clang/test/CodeGenObjC/object-incr-decr-1.m19
-rw-r--r--clang/test/CodeGenObjC/optimized-setter.m33
-rw-r--r--clang/test/CodeGenObjC/overloadable.m10
-rw-r--r--clang/test/CodeGenObjC/predefined-expr.m90
-rw-r--r--clang/test/CodeGenObjC/property-aggregate.m31
-rw-r--r--clang/test/CodeGenObjC/property-agrr-getter.m44
-rw-r--r--clang/test/CodeGenObjC/property-category-impl.m20
-rw-r--r--clang/test/CodeGenObjC/property-complex.m61
-rw-r--r--clang/test/CodeGenObjC/property-dbg.m17
-rw-r--r--clang/test/CodeGenObjC/property-getter-dot-syntax.m11
-rw-r--r--clang/test/CodeGenObjC/property-incr-decr-1.m29
-rw-r--r--clang/test/CodeGenObjC/property-list-in-class.m32
-rw-r--r--clang/test/CodeGenObjC/property-ref-cast-to-void.m18
-rw-r--r--clang/test/CodeGenObjC/property-setter-attr.m10
-rw-r--r--clang/test/CodeGenObjC/property-type-mismatch.m17
-rw-r--r--clang/test/CodeGenObjC/property.m168
-rw-r--r--clang/test/CodeGenObjC/protocol-in-extended-class.m29
-rw-r--r--clang/test/CodeGenObjC/protocol-property-synth.m33
-rw-r--r--clang/test/CodeGenObjC/protocols-lazy.m47
-rw-r--r--clang/test/CodeGenObjC/protocols.m57
-rw-r--r--clang/test/CodeGenObjC/rdr-6732143-dangling-block-reference.m10
-rw-r--r--clang/test/CodeGenObjC/related-result-type.m54
-rw-r--r--clang/test/CodeGenObjC/return-objc-object.mm19
-rw-r--r--clang/test/CodeGenObjC/runtime-fns.m33
-rw-r--r--clang/test/CodeGenObjC/sel-as-builtin-type.m23
-rw-r--r--clang/test/CodeGenObjC/selector-ref-invariance.m9
-rw-r--r--clang/test/CodeGenObjC/simplify-exceptions.mm18
-rw-r--r--clang/test/CodeGenObjC/stand-alone-implementation.m16
-rw-r--r--clang/test/CodeGenObjC/super-classmethod-category.m13
-rw-r--r--clang/test/CodeGenObjC/super-dotsyntax-property.m41
-rw-r--r--clang/test/CodeGenObjC/super-dotsyntax-struct-property.m47
-rw-r--r--clang/test/CodeGenObjC/super-message-fragileabi.m32
-rw-r--r--clang/test/CodeGenObjC/synchronized.m79
-rw-r--r--clang/test/CodeGenObjC/synthesize_ivar-cont-class.m18
-rw-r--r--clang/test/CodeGenObjC/synthesize_ivar.m38
-rw-r--r--clang/test/CodeGenObjC/terminate.m29
-rw-r--r--clang/test/CodeGenObjC/try.m10
-rw-r--r--clang/test/CodeGenObjC/undefined-protocol.m6
-rw-r--r--clang/test/CodeGenObjC/unname-bf-metadata.m14
-rw-r--r--clang/test/CodeGenObjC/variadic-sends.m41
-rw-r--r--clang/test/CodeGenObjC/x86_64-struct-return-gc.m31
-rw-r--r--clang/test/CodeGenObjCXX/2007-10-03-MetadataPointers.mm7
-rw-r--r--clang/test/CodeGenObjCXX/2010-08-04-Template.mm10
-rw-r--r--clang/test/CodeGenObjCXX/2010-08-06-X.Y-syntax.mm16
-rw-r--r--clang/test/CodeGenObjCXX/Inputs/literal-support.h35
-rw-r--r--clang/test/CodeGenObjCXX/address-safety-attr.mm20
-rw-r--r--clang/test/CodeGenObjCXX/arc-exceptions.mm85
-rw-r--r--clang/test/CodeGenObjCXX/arc-globals.mm27
-rw-r--r--clang/test/CodeGenObjCXX/arc-mangle.mm25
-rw-r--r--clang/test/CodeGenObjCXX/arc-move.mm75
-rw-r--r--clang/test/CodeGenObjCXX/arc-new-delete.mm95
-rw-r--r--clang/test/CodeGenObjCXX/arc-pseudo-destructors.mm21
-rw-r--r--clang/test/CodeGenObjCXX/arc-references.mm84
-rw-r--r--clang/test/CodeGenObjCXX/arc-returns-inner-reference-ptr.mm22
-rw-r--r--clang/test/CodeGenObjCXX/arc-special-member-functions.mm165
-rw-r--r--clang/test/CodeGenObjCXX/arc.mm254
-rw-r--r--clang/test/CodeGenObjCXX/block-in-template-inst.mm71
-rw-r--r--clang/test/CodeGenObjCXX/block-var-layout.mm157
-rw-r--r--clang/test/CodeGenObjCXX/blocks.mm46
-rw-r--r--clang/test/CodeGenObjCXX/catch-id-type.mm51
-rw-r--r--clang/test/CodeGenObjCXX/copy.mm39
-rw-r--r--clang/test/CodeGenObjCXX/copyable-property-object.mm28
-rw-r--r--clang/test/CodeGenObjCXX/debug-info.mm41
-rw-r--r--clang/test/CodeGenObjCXX/encode.mm189
-rw-r--r--clang/test/CodeGenObjCXX/exceptions.mm18
-rw-r--r--clang/test/CodeGenObjCXX/foreach-statement.mm10
-rw-r--r--clang/test/CodeGenObjCXX/gc.mm20
-rw-r--r--clang/test/CodeGenObjCXX/implicit-copy-assign-operator.mm57
-rw-r--r--clang/test/CodeGenObjCXX/implicit-copy-constructor.mm73
-rw-r--r--clang/test/CodeGenObjCXX/ivar-objects.mm104
-rw-r--r--clang/test/CodeGenObjCXX/lambda-expressions.mm39
-rw-r--r--clang/test/CodeGenObjCXX/literals.mm111
-rw-r--r--clang/test/CodeGenObjCXX/lvalue-reference-getter.mm28
-rw-r--r--clang/test/CodeGenObjCXX/mangle-blocks.mm50
-rw-r--r--clang/test/CodeGenObjCXX/mangle.mm56
-rw-r--r--clang/test/CodeGenObjCXX/message-reference.mm20
-rw-r--r--clang/test/CodeGenObjCXX/method-local-extern-mangle.mm14
-rw-r--r--clang/test/CodeGenObjCXX/nrvo.mm32
-rw-r--r--clang/test/CodeGenObjCXX/objc-container-subscripting-1.mm50
-rw-r--r--clang/test/CodeGenObjCXX/objc-container-subscripting.mm57
-rw-r--r--clang/test/CodeGenObjCXX/property-derived-to-base-conv.mm25
-rw-r--r--clang/test/CodeGenObjCXX/property-dot-copy.mm68
-rw-r--r--clang/test/CodeGenObjCXX/property-dot-reference.mm62
-rw-r--r--clang/test/CodeGenObjCXX/property-object-conditional-exp.mm44
-rw-r--r--clang/test/CodeGenObjCXX/property-object-reference-1.mm31
-rw-r--r--clang/test/CodeGenObjCXX/property-object-reference-2.mm56
-rw-r--r--clang/test/CodeGenObjCXX/property-object-reference.mm35
-rw-r--r--clang/test/CodeGenObjCXX/property-objects.mm78
-rw-r--r--clang/test/CodeGenObjCXX/property-reference.mm96
-rw-r--r--clang/test/CodeGenObjCXX/refence-assign-write-barrier.mm20
-rw-r--r--clang/test/CodeGenObjCXX/references.mm45
-rw-r--r--clang/test/CodeGenObjCXX/rtti.mm52
-rw-r--r--clang/test/CodeGenObjCXX/selector-expr-lvalue.mm16
-rw-r--r--clang/test/CodeGenObjCXX/write-barrier-global-assign.mm29
-rw-r--r--clang/test/CodeGenOpenCL/2011-04-15-vec-init-from-vec.cl11
-rw-r--r--clang/test/CodeGenOpenCL/address-spaces.cl27
-rw-r--r--clang/test/CodeGenOpenCL/ext-vector-shuffle.cl17
-rw-r--r--clang/test/CodeGenOpenCL/fpmath.cl25
-rw-r--r--clang/test/CodeGenOpenCL/kernel-metadata.cl10
-rw-r--r--clang/test/CodeGenOpenCL/local.cl7
-rw-r--r--clang/test/CodeGenOpenCL/ptx-calls.cl12
-rw-r--r--clang/test/CodeGenOpenCL/ptx-kernels.cl10
-rw-r--r--clang/test/CodeGenOpenCL/single-precision-constant.cl7
-rw-r--r--clang/test/CodeGenOpenCL/vector_literals_nested.cl23
-rw-r--r--clang/test/CodeGenOpenCL/vector_literals_valid.cl22
-rw-r--r--clang/test/CodeGenOpenCL/vector_logops.cl19
-rw-r--r--clang/test/Coverage/ast-printing.c6
-rw-r--r--clang/test/Coverage/ast-printing.cpp7
-rw-r--r--clang/test/Coverage/ast-printing.m5
-rw-r--r--clang/test/Coverage/c-language-features.inc198
-rw-r--r--clang/test/Coverage/codegen-gnu.m3
-rw-r--r--clang/test/Coverage/codegen-next.m4
-rw-r--r--clang/test/Coverage/codegen.c7
-rw-r--r--clang/test/Coverage/cxx-language-features.inc27
-rw-r--r--clang/test/Coverage/html-diagnostics.c22
-rw-r--r--clang/test/Coverage/html-print.c3
-rw-r--r--clang/test/Coverage/objc-language-features.inc87
-rw-r--r--clang/test/Coverage/targets.c20
-rw-r--r--clang/test/Coverage/verbose.c1
-rw-r--r--clang/test/Driver/Inputs/basic_freebsd64_tree/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/crt1.o0
-rw-r--r--clang/test/Driver/Inputs/basic_freebsd64_tree/usr/lib32/.keep0
-rw-r--r--clang/test/Driver/Inputs/basic_freebsd_tree/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/basic_freebsd_tree/usr/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/basic_freebsd_tree/usr/lib/crt1.o0
-rw-r--r--clang/test/Driver/Inputs/basic_freebsd_tree/usr/lib32/.keep0
-rw-r--r--clang/test/Driver/Inputs/basic_linux_tree/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/basic_linux_tree/usr/i386-unknown-linux/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/basic_linux_tree/usr/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/basic_linux_tree/usr/x86_64-unknown-linux/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/lib/i386-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc64-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/lib/x86_64-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/backward/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc64-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/x86_64-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc64-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/x86_64-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/i386-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc64-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/x86_64-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/fake_install_tree/bin/.keep0
-rw-r--r--clang/test/Driver/Inputs/fake_install_tree/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/fake_install_tree/lib/gcc/x86_64-unknown-linux/4.5.0/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing1/bin/.keep0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.6.99/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.6/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7.1/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing2/bin/.keep0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.6.99/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.6.x/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.1/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing3/bin/.keep0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.98/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing4/bin/.keep0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing4/lib/gcc/i386-unknown-linux/4.7.98/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing4/lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/gcc_version_parsing4/lib/gcc/i386-unknown-linux/4.7.99/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/multiarch_freebsd64_tree/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/crt1.o0
-rw-r--r--clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/.keep0
-rw-r--r--clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/crt1.o0
-rw-r--r--clang/test/Driver/Inputs/multilib_32bit_linux_tree/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_32bit_linux_tree/lib32/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_32bit_linux_tree/lib64/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib32/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib64/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/64/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib32/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib64/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_64bit_linux_tree/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_64bit_linux_tree/lib32/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_64bit_linux_tree/lib64/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib32/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib64/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/lib32/.keep0
-rw-r--r--clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/lib64/.keep0
-rwxr-xr-xclang/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-as2
-rwxr-xr-xclang/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-ld2
-rw-r--r--clang/test/Driver/Inputs/suse_10.3_ppc64_tree/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/suse_10.3_ppc64_tree/lib64/.keep0
-rw-r--r--clang/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/64/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/crtbegin.o0
-rw-r--r--clang/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib64/.keep0
-rw-r--r--clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/i386-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/.keep0
-rw-r--r--clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/.keep0
-rw-r--r--clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/backward/.keep0
-rw-r--r--clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/i386-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/.keep0
-rw-r--r--clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/.keep0
-rw-r--r--clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o0
-rw-r--r--clang/test/Driver/Wp-args.c13
-rw-r--r--clang/test/Driver/Xarch.c9
-rw-r--r--clang/test/Driver/Xlinker-args.c9
-rw-r--r--clang/test/Driver/altivec.cpp14
-rw-r--r--clang/test/Driver/analyze.c8
-rw-r--r--clang/test/Driver/apple-kext-i386.cpp50
-rw-r--r--clang/test/Driver/apple-kext-mkernel.c22
-rw-r--r--clang/test/Driver/arc-exceptions.m5
-rw-r--r--clang/test/Driver/arc.c17
-rw-r--r--clang/test/Driver/arch.c3
-rw-r--r--clang/test/Driver/arclite-link.c8
-rw-r--r--clang/test/Driver/arm-darwin-builtin.c14
-rw-r--r--clang/test/Driver/arm-mfpmath.c29
-rw-r--r--clang/test/Driver/arm-mfpu.c48
-rw-r--r--clang/test/Driver/asan.c8
-rw-r--r--clang/test/Driver/ast.c26
-rw-r--r--clang/test/Driver/at_file.c30
-rw-r--r--clang/test/Driver/at_file.c.args11
-rw-r--r--clang/test/Driver/bindings.c49
-rw-r--r--clang/test/Driver/cc-log-diagnostics.c35
-rw-r--r--clang/test/Driver/cc-print-options.c7
-rw-r--r--clang/test/Driver/ccc-add-args.c5
-rw-r--r--clang/test/Driver/ccc-host-triple-no-integrated-as.c17
-rw-r--r--clang/test/Driver/cfi.c9
-rw-r--r--clang/test/Driver/clang-c-as-cxx.c6
-rw-r--r--clang/test/Driver/clang-exception-flags.cpp23
-rw-r--r--clang/test/Driver/clang-g-opts.c5
-rw-r--r--clang/test/Driver/clang-translation.c46
-rw-r--r--clang/test/Driver/clang_cpp.c4
-rw-r--r--clang/test/Driver/clang_f_opts.c31
-rw-r--r--clang/test/Driver/clang_wrapv_opts.c11
-rw-r--r--clang/test/Driver/cpath.c22
-rw-r--r--clang/test/Driver/cpp-precomp.c5
-rw-r--r--clang/test/Driver/darwin-as.c17
-rw-r--r--clang/test/Driver/darwin-cc.c4
-rw-r--r--clang/test/Driver/darwin-debug-flags.c13
-rw-r--r--clang/test/Driver/darwin-dsymutil.c45
-rw-r--r--clang/test/Driver/darwin-iphone-defaults.m28
-rw-r--r--clang/test/Driver/darwin-ld.c123
-rw-r--r--clang/test/Driver/darwin-objc-defaults.m88
-rw-r--r--clang/test/Driver/darwin-objc-gc.m19
-rw-r--r--clang/test/Driver/darwin-objc-options.m21
-rw-r--r--clang/test/Driver/darwin-verify-debug.c34
-rw-r--r--clang/test/Driver/darwin-version.c31
-rw-r--r--clang/test/Driver/darwin-xarch.c20
-rw-r--r--clang/test/Driver/debug-options-as.c18
-rw-r--r--clang/test/Driver/debug-options.c27
-rw-r--r--clang/test/Driver/debug.c11
-rw-r--r--clang/test/Driver/default-toolchain.c8
-rw-r--r--clang/test/Driver/diagnostics.c9
-rw-r--r--clang/test/Driver/dragonfly.c7
-rw-r--r--clang/test/Driver/dwarf2-cfi-asm.c35
-rw-r--r--clang/test/Driver/emit-llvm.c10
-rw-r--r--clang/test/Driver/exceptions.m19
-rw-r--r--clang/test/Driver/fast-math.c119
-rw-r--r--clang/test/Driver/flags.c9
-rw-r--r--clang/test/Driver/frame-pointer.c24
-rw-r--r--clang/test/Driver/freebsd.c30
-rw-r--r--clang/test/Driver/gcc-toolchain.cpp23
-rw-r--r--clang/test/Driver/gcc_forward.c13
-rw-r--r--clang/test/Driver/gnu-runtime.m5
-rw-r--r--clang/test/Driver/gold-lto.c6
-rw-r--r--clang/test/Driver/hello.c18
-rw-r--r--clang/test/Driver/immediate-options.c4
-rw-r--r--clang/test/Driver/index-header-map.c4
-rw-r--r--clang/test/Driver/invalid-o-level.c4
-rw-r--r--clang/test/Driver/ios-simulator-arcruntime.c6
-rw-r--r--clang/test/Driver/le32-unknown-nacl.cpp146
-rw-r--r--clang/test/Driver/linker-opts.c5
-rw-r--r--clang/test/Driver/linux-as.c31
-rw-r--r--clang/test/Driver/linux-header-search.cpp75
-rw-r--r--clang/test/Driver/linux-ld.c270
-rw-r--r--clang/test/Driver/lto.c23
-rw-r--r--clang/test/Driver/m_and_mm.c3
-rw-r--r--clang/test/Driver/mg.c5
-rw-r--r--clang/test/Driver/mips-as.c31
-rw-r--r--clang/test/Driver/mips-float.c42
-rw-r--r--clang/test/Driver/mno-global-merge.c12
-rw-r--r--clang/test/Driver/modules.m6
-rw-r--r--clang/test/Driver/modules.mm6
-rw-r--r--clang/test/Driver/no-objc-arr.m8
-rw-r--r--clang/test/Driver/no-objc-default-synthesize-properties.m10
-rw-r--r--clang/test/Driver/no-sibling-calls.c8
-rw-r--r--clang/test/Driver/noexecstack.c1
-rw-r--r--clang/test/Driver/noinline.c10
-rw-r--r--clang/test/Driver/nostdincxx.cpp4
-rw-r--r--clang/test/Driver/nostdlib.c4
-rw-r--r--clang/test/Driver/nostdlibinc.c10
-rw-r--r--clang/test/Driver/objc++-cpp-output.mm8
-rw-r--r--clang/test/Driver/objc-cpp-output.m7
-rw-r--r--clang/test/Driver/openbsd.c5
-rw-r--r--clang/test/Driver/option-aliases.c11
-rw-r--r--clang/test/Driver/output-file-cleanup.c25
-rw-r--r--clang/test/Driver/parsing.c22
-rw-r--r--clang/test/Driver/phases.c78
-rw-r--r--clang/test/Driver/pic.c81
-rw-r--r--clang/test/Driver/prefixed-tools.c12
-rw-r--r--clang/test/Driver/preprocessor.c6
-rw-r--r--clang/test/Driver/pth.c12
-rw-r--r--clang/test/Driver/qa_override.c6
-rw-r--r--clang/test/Driver/redundant-args.c2
-rw-r--r--clang/test/Driver/redzone.c6
-rw-r--r--clang/test/Driver/rewrite-legacy-objc.m15
-rw-r--r--clang/test/Driver/rewrite-objc.m15
-rw-r--r--clang/test/Driver/stackrealign.c12
-rw-r--r--clang/test/Driver/std.c8
-rw-r--r--clang/test/Driver/std.cpp24
-rw-r--r--clang/test/Driver/sysroot-flags.c28
-rw-r--r--clang/test/Driver/sysroot.c18
-rw-r--r--clang/test/Driver/target.c11
-rw-r--r--clang/test/Driver/tsan.c8
-rw-r--r--clang/test/Driver/unknown-arg.c4
-rw-r--r--clang/test/Driver/unknown-gcc-arch.c8
-rw-r--r--clang/test/Driver/working-directory.c4
-rw-r--r--clang/test/Driver/x86_features.c3
-rw-r--r--clang/test/FixIt/atomic-property.m29
-rw-r--r--clang/test/FixIt/auto-fixit.m11
-rw-r--r--clang/test/FixIt/dereference-addressof.c22
-rw-r--r--clang/test/FixIt/fixit-c90.c17
-rw-r--r--clang/test/FixIt/fixit-cxx0x.cpp110
-rw-r--r--clang/test/FixIt/fixit-cxx11-compat.cpp11
-rw-r--r--clang/test/FixIt/fixit-errors-1.c16
-rw-r--r--clang/test/FixIt/fixit-errors.c23
-rw-r--r--clang/test/FixIt/fixit-function-call.cpp118
-rw-r--r--clang/test/FixIt/fixit-missing-method-return-type.m24
-rw-r--r--clang/test/FixIt/fixit-objc-message.m38
-rw-r--r--clang/test/FixIt/fixit-objc.m69
-rw-r--r--clang/test/FixIt/fixit-pmem.cpp26
-rw-r--r--clang/test/FixIt/fixit-recompile.c6
-rw-r--r--clang/test/FixIt/fixit-recursive-block.c12
-rw-r--r--clang/test/FixIt/fixit-static-object-decl.m29
-rw-r--r--clang/test/FixIt/fixit-suffix.c5
-rw-r--r--clang/test/FixIt/fixit-unrecoverable.c8
-rw-r--r--clang/test/FixIt/fixit-unrecoverable.cpp12
-rw-r--r--clang/test/FixIt/fixit-vexing-parse-cxx0x.cpp21
-rw-r--r--clang/test/FixIt/fixit-vexing-parse.cpp89
-rw-r--r--clang/test/FixIt/fixit.c102
-rw-r--r--clang/test/FixIt/fixit.cpp206
-rw-r--r--clang/test/FixIt/no-fixit.cpp7
-rw-r--r--clang/test/FixIt/no-macro-fixit.c16
-rw-r--r--clang/test/FixIt/no-typo.c6
-rw-r--r--clang/test/FixIt/objc-literals.m44
-rw-r--r--clang/test/FixIt/typo-crash.cpp29
-rw-r--r--clang/test/FixIt/typo-crash.m6
-rw-r--r--clang/test/FixIt/typo.c37
-rw-r--r--clang/test/FixIt/typo.cpp88
-rw-r--r--clang/test/FixIt/typo.m167
-rw-r--r--clang/test/Frontend/Inputs/TestFramework.framework/Headers/TestFramework.h1
-rw-r--r--clang/test/Frontend/Inputs/lit.local.cfg1
-rw-r--r--clang/test/Frontend/Inputs/test.h1
-rw-r--r--clang/test/Frontend/Inputs/test2.h1
-rw-r--r--clang/test/Frontend/Inputs/test3.h1
-rw-r--r--clang/test/Frontend/Weverything.c9
-rw-r--r--clang/test/Frontend/Wno-everything.c7
-rw-r--r--clang/test/Frontend/ast-codegen.c12
-rw-r--r--clang/test/Frontend/ast-main.c8
-rw-r--r--clang/test/Frontend/cpp-output.c14
-rw-r--r--clang/test/Frontend/darwin-version.c25
-rw-r--r--clang/test/Frontend/dependency-gen.c27
-rw-r--r--clang/test/Frontend/dependency-generation-crash.c4
-rw-r--r--clang/test/Frontend/diagnostics-option-names.c8
-rw-r--r--clang/test/Frontend/iframework.c3
-rw-r--r--clang/test/Frontend/ir-support-codegen.ll9
-rw-r--r--clang/test/Frontend/ir-support-errors.ll8
-rw-r--r--clang/test/Frontend/lit.local.cfg1
-rw-r--r--clang/test/Frontend/macros.c4
-rw-r--r--clang/test/Frontend/output-failures.c4
-rw-r--r--clang/test/Frontend/preprocessed-output-macro-first-token.c5
-rw-r--r--clang/test/Frontend/print-header-includes.c8
-rw-r--r--clang/test/Frontend/rewrite-macros.c17
-rw-r--r--clang/test/Frontend/stdin.c3
-rw-r--r--clang/test/Frontend/undef.c4
-rw-r--r--clang/test/Frontend/unknown-pragmas.c4
-rw-r--r--clang/test/Frontend/warning-mapping-1.c6
-rw-r--r--clang/test/Frontend/warning-mapping-2.c5
-rw-r--r--clang/test/Frontend/warning-mapping-3.c10
-rw-r--r--clang/test/Frontend/warning-mapping-4.c6
-rw-r--r--clang/test/Frontend/warning-mapping-5.c9
-rw-r--r--clang/test/Headers/arm-neon-header.c5
-rw-r--r--clang/test/Headers/c89.c10
-rw-r--r--clang/test/Headers/int64-type.c4
-rw-r--r--clang/test/Headers/stdbool.cpp14
-rw-r--r--clang/test/Headers/typedef_guards.c28
-rw-r--r--clang/test/Headers/wchar_limits.cpp9
-rw-r--r--clang/test/Headers/wmmintrin.c4
-rw-r--r--clang/test/Headers/x86-intrinsics-headers.c15
-rw-r--r--clang/test/Index/IBOutletCollection.m18
-rw-r--r--clang/test/Index/Inputs/Frameworks/Framework.framework/Headers/Framework.h2
-rw-r--r--clang/test/Index/Inputs/Headers/a.h2
-rw-r--r--clang/test/Index/Inputs/Headers/a_extensions.h1
-rw-r--r--clang/test/Index/Inputs/Headers/crash.h6
-rw-r--r--clang/test/Index/Inputs/Headers/module.map10
-rw-r--r--clang/test/Index/Inputs/Headers/nested/module.map4
-rw-r--r--clang/test/Index/Inputs/Headers/nested/nested.h1
-rw-r--r--clang/test/Index/Inputs/a.h4
-rw-r--r--clang/test/Index/Inputs/b.h1
-rw-r--r--clang/test/Index/Inputs/c-index-pch.h7
-rw-r--r--clang/test/Index/Inputs/cindex-from-source.h1
-rw-r--r--clang/test/Index/Inputs/complete-pch.h10
-rw-r--r--clang/test/Index/Inputs/crash-recovery-code-complete-remap.c12
-rw-r--r--clang/test/Index/Inputs/crash-recovery-reparse-remap.c11
-rw-r--r--clang/test/Index/Inputs/foo.h8
-rw-r--r--clang/test/Index/Inputs/get-cursor-includes-1.h6
-rw-r--r--clang/test/Index/Inputs/get-cursor-includes-2.h2
-rw-r--r--clang/test/Index/Inputs/guarded.h6
-rw-r--r--clang/test/Index/Inputs/lit.local.cfg1
-rw-r--r--clang/test/Index/Inputs/objc.h11
-rw-r--r--clang/test/Index/Inputs/pragma-once.h3
-rw-r--r--clang/test/Index/Inputs/pragma_disable_warning.h1
-rw-r--r--clang/test/Index/Inputs/preamble-reparse-1.c2
-rw-r--r--clang/test/Index/Inputs/preamble-reparse-2.c1
-rw-r--r--clang/test/Index/Inputs/preamble.h6
-rw-r--r--clang/test/Index/Inputs/preamble_macro_template.h6
-rw-r--r--clang/test/Index/Inputs/prefix.h4
-rw-r--r--clang/test/Index/Inputs/redeclarations.h21
-rw-r--r--clang/test/Index/Inputs/remap-complete-to.c6
-rw-r--r--clang/test/Index/Inputs/remap-load-to.c3
-rw-r--r--clang/test/Index/Inputs/reparse-instantiate.h14
-rw-r--r--clang/test/Index/Inputs/t1.c28
-rw-r--r--clang/test/Index/Inputs/t1.m20
-rw-r--r--clang/test/Index/Inputs/t2.c11
-rw-r--r--clang/test/Index/Inputs/t2.m13
-rw-r--r--clang/test/Index/TestClassDecl.m33
-rw-r--r--clang/test/Index/TestClassForwardDecl.m41
-rw-r--r--clang/test/Index/annotate-attribute.cpp33
-rw-r--r--clang/test/Index/annotate-context-sensitive.cpp42
-rw-r--r--clang/test/Index/annotate-literals.m72
-rw-r--r--clang/test/Index/annotate-macro-args.h16
-rw-r--r--clang/test/Index/annotate-macro-args.m23
-rw-r--r--clang/test/Index/annotate-nested-name-specifier.cpp466
-rw-r--r--clang/test/Index/annotate-subscripting.m92
-rw-r--r--clang/test/Index/annotate-tokens-cxx0x.cpp27
-rw-r--r--clang/test/Index/annotate-tokens-include.c7
-rw-r--r--clang/test/Index/annotate-tokens-include.h1
-rw-r--r--clang/test/Index/annotate-tokens-pp.c198
-rw-r--r--clang/test/Index/annotate-tokens-preamble.c20
-rw-r--r--clang/test/Index/annotate-tokens-with-default-args.cpp16
-rw-r--r--clang/test/Index/annotate-tokens-with-default-args.h3
-rw-r--r--clang/test/Index/annotate-tokens.c136
-rw-r--r--clang/test/Index/annotate-tokens.cpp122
-rw-r--r--clang/test/Index/annotate-tokens.m576
-rw-r--r--clang/test/Index/annotate-toplevel-in-objccontainer.m33
-rw-r--r--clang/test/Index/annotate-toplevel-in-objccontainer.m.h9
-rw-r--r--clang/test/Index/arc-annotate.m38
-rw-r--r--clang/test/Index/arc-complete.m16
-rw-r--r--clang/test/Index/asm-attribute.c6
-rw-r--r--clang/test/Index/blocks.c34
-rw-r--r--clang/test/Index/c-index-api-loadTU-test.m163
-rw-r--r--clang/test/Index/c-index-getCursor-pp.c39
-rw-r--r--clang/test/Index/c-index-getCursor-test.m168
-rw-r--r--clang/test/Index/c-index-pch.c9
-rw-r--r--clang/test/Index/c-index-redecls.c107
-rw-r--r--clang/test/Index/cindex-from-source.m12
-rw-r--r--clang/test/Index/cindex-on-invalid-usrs.m7
-rw-r--r--clang/test/Index/cindex-on-invalid.m21
-rw-r--r--clang/test/Index/cindex-test-inclusions.c13
-rw-r--r--clang/test/Index/code-completion.cpp90
-rw-r--r--clang/test/Index/complete-access-checks.cpp89
-rw-r--r--clang/test/Index/complete-at-directives.m54
-rw-r--r--clang/test/Index/complete-at-exprstmt.m55
-rw-r--r--clang/test/Index/complete-blocks.m64
-rw-r--r--clang/test/Index/complete-categories.m39
-rw-r--r--clang/test/Index/complete-ctor-inits.cpp40
-rw-r--r--clang/test/Index/complete-cxx-inline-methods.cpp44
-rw-r--r--clang/test/Index/complete-declarators.cpp43
-rw-r--r--clang/test/Index/complete-declarators.m72
-rw-r--r--clang/test/Index/complete-driver-errors.c24
-rw-r--r--clang/test/Index/complete-enums.c22
-rw-r--r--clang/test/Index/complete-enums.cpp25
-rw-r--r--clang/test/Index/complete-exprs.c69
-rw-r--r--clang/test/Index/complete-exprs.cpp84
-rw-r--r--clang/test/Index/complete-exprs.m49
-rw-r--r--clang/test/Index/complete-hiding.c32
-rw-r--r--clang/test/Index/complete-in-invalid-method.m19
-rw-r--r--clang/test/Index/complete-in-stringify.c17
-rw-r--r--clang/test/Index/complete-interfaces.m47
-rw-r--r--clang/test/Index/complete-ivar-access.m69
-rw-r--r--clang/test/Index/complete-kvc.m105
-rw-r--r--clang/test/Index/complete-lambdas.cpp43
-rw-r--r--clang/test/Index/complete-macro-args.c22
-rw-r--r--clang/test/Index/complete-macros.c43
-rw-r--r--clang/test/Index/complete-member-access.m77
-rw-r--r--clang/test/Index/complete-memfunc-cvquals.cpp86
-rw-r--r--clang/test/Index/complete-method-decls.m184
-rw-r--r--clang/test/Index/complete-modules.m14
-rw-r--r--clang/test/Index/complete-natural.m57
-rw-r--r--clang/test/Index/complete-objc-message-id.m74
-rw-r--r--clang/test/Index/complete-objc-message.m336
-rw-r--r--clang/test/Index/complete-pch.m26
-rw-r--r--clang/test/Index/complete-preprocessor.m80
-rw-r--r--clang/test/Index/complete-properties.m82
-rw-r--r--clang/test/Index/complete-property-flags.m26
-rw-r--r--clang/test/Index/complete-property-getset.m41
-rw-r--r--clang/test/Index/complete-protocols.m27
-rw-r--r--clang/test/Index/complete-qualified.cpp20
-rw-r--r--clang/test/Index/complete-recovery.m38
-rw-r--r--clang/test/Index/complete-stmt.c16
-rw-r--r--clang/test/Index/complete-super.cpp42
-rw-r--r--clang/test/Index/complete-super.m81
-rw-r--r--clang/test/Index/complete-synthesized.m46
-rw-r--r--clang/test/Index/complete-tabs.c9
-rw-r--r--clang/test/Index/complete-templates.cpp19
-rw-r--r--clang/test/Index/complete-type-factors.m137
-rw-r--r--clang/test/Index/complete-unterminated.c30
-rw-r--r--clang/test/Index/complete-with-annotations.cpp23
-rw-r--r--clang/test/Index/crash-recovery-code-complete.c12
-rw-r--r--clang/test/Index/crash-recovery-modules.m20
-rw-r--r--clang/test/Index/crash-recovery-reparse.c12
-rw-r--r--clang/test/Index/crash-recovery.c7
-rw-r--r--clang/test/Index/cursor-ref-names.cpp47
-rw-r--r--clang/test/Index/cxx-operator-overload.cpp28
-rw-r--r--clang/test/Index/cxx11-lambdas.cpp33
-rw-r--r--clang/test/Index/error-on-deserialized.c13
-rw-r--r--clang/test/Index/file-macro-refs.c12
-rw-r--r--clang/test/Index/file-refs-subscripting.m65
-rw-r--r--clang/test/Index/file-refs.c57
-rw-r--r--clang/test/Index/file-refs.cpp104
-rw-r--r--clang/test/Index/file-refs.m91
-rw-r--r--clang/test/Index/fix-its.c27
-rw-r--r--clang/test/Index/get-cursor-includes.c7
-rw-r--r--clang/test/Index/get-cursor-macro-args.h16
-rw-r--r--clang/test/Index/get-cursor-macro-args.m19
-rw-r--r--clang/test/Index/get-cursor.c14
-rw-r--r--clang/test/Index/get-cursor.cpp95
-rw-r--r--clang/test/Index/get-cursor.m104
-rw-r--r--clang/test/Index/getcursor-pp-pch.c43
-rw-r--r--clang/test/Index/getcursor-pp-pch.c.h5
-rw-r--r--clang/test/Index/in-class-init.cpp6
-rw-r--r--clang/test/Index/include_test.h1
-rw-r--r--clang/test/Index/include_test_2.h0
-rw-r--r--clang/test/Index/index-attrs.m17
-rw-r--r--clang/test/Index/index-decls.m30
-rw-r--r--clang/test/Index/index-invalid-code.m8
-rw-r--r--clang/test/Index/index-many-logical-ops.c2011
-rw-r--r--clang/test/Index/index-refs.cpp121
-rw-r--r--clang/test/Index/index-subscripting-literals.m66
-rw-r--r--clang/test/Index/index-suppress-refs.cpp12
-rw-r--r--clang/test/Index/index-suppress-refs.h9
-rw-r--r--clang/test/Index/index-suppress-refs.hpp3
-rw-r--r--clang/test/Index/index-suppress-refs.m44
-rw-r--r--clang/test/Index/index-templates.cpp207
-rw-r--r--clang/test/Index/initializer-memory.cpp16
-rw-r--r--clang/test/Index/invalid-code-rdar10451854.m15
-rw-r--r--clang/test/Index/invalid-code-rdar_7833619.m4
-rw-r--r--clang/test/Index/invalid-rdar-8236270.cpp11
-rw-r--r--clang/test/Index/linkage.c30
-rw-r--r--clang/test/Index/load-classes.cpp28
-rw-r--r--clang/test/Index/load-decls.c15
-rw-r--r--clang/test/Index/load-exprs.c81
-rw-r--r--clang/test/Index/load-namespaces.cpp50
-rw-r--r--clang/test/Index/load-stmts.cpp231
-rw-r--r--clang/test/Index/local-symbols.m44
-rw-r--r--clang/test/Index/ms-if-exists.cpp24
-rw-r--r--clang/test/Index/nested-binaryoperators.cpp1983
-rw-r--r--clang/test/Index/overrides.cpp20
-rw-r--r--clang/test/Index/overrides.m61
-rw-r--r--clang/test/Index/pch-opaque-value.cpp16
-rw-r--r--clang/test/Index/pch-with-errors.c42
-rw-r--r--clang/test/Index/pch-with-errors.m28
-rw-r--r--clang/test/Index/pragma-diag-reparse.c20
-rw-r--r--clang/test/Index/preamble-reparse-chained.c10
-rw-r--r--clang/test/Index/preamble-reparse-cmd-define.c9
-rw-r--r--clang/test/Index/preamble-reparse-cmd-define.c.h1
-rw-r--r--clang/test/Index/preamble-reparse-cmd-define.c.remap8
-rw-r--r--clang/test/Index/preamble-reparse-import.m12
-rw-r--r--clang/test/Index/preamble-reparse-import.m-1.h5
-rw-r--r--clang/test/Index/preamble-reparse-import.m-2.h5
-rw-r--r--clang/test/Index/preamble-reparse-import.m-3.h1
-rw-r--r--clang/test/Index/preamble-reparse.c2
-rw-r--r--clang/test/Index/preamble.c24
-rw-r--r--clang/test/Index/preamble_macro_template.cpp15
-rw-r--r--clang/test/Index/print-display-names.cpp20
-rw-r--r--clang/test/Index/print-typekind.c28
-rw-r--r--clang/test/Index/print-typekind.m10
-rw-r--r--clang/test/Index/print-usrs.c17
-rw-r--r--clang/test/Index/properties-class-extensions.m99
-rw-r--r--clang/test/Index/rdar-8288645-invalid-code.mm7
-rw-r--r--clang/test/Index/recover-bad-code-rdar_7487294.c13
-rw-r--r--clang/test/Index/recursive-cxx-member-calls.cpp2243
-rw-r--r--clang/test/Index/recursive-member-access.c532
-rw-r--r--clang/test/Index/redeclarations.cpp21
-rw-r--r--clang/test/Index/remap-complete.c4
-rw-r--r--clang/test/Index/remap-cursor-at.c4
-rw-r--r--clang/test/Index/remap-load.c10
-rw-r--r--clang/test/Index/reparse-instantiate.cpp7
-rw-r--r--clang/test/Index/retain-target-options.c8
-rw-r--r--clang/test/Index/targeted-annotation.c99
-rw-r--r--clang/test/Index/targeted-cursor.c65
-rw-r--r--clang/test/Index/targeted-cursor.m6
-rw-r--r--clang/test/Index/targeted-cursor.m.h7
-rw-r--r--clang/test/Index/targeted-fields.h3
-rw-r--r--clang/test/Index/targeted-file-refs.c59
-rw-r--r--clang/test/Index/targeted-nested1.h2
-rw-r--r--clang/test/Index/targeted-preamble.h2
-rw-r--r--clang/test/Index/targeted-top.h24
-rw-r--r--clang/test/Index/unmatched-braces.c9
-rw-r--r--clang/test/Index/unmatched-braces.m11
-rw-r--r--clang/test/Index/usrs-cxx0x.cpp8
-rw-r--r--clang/test/Index/usrs.cpp146
-rw-r--r--clang/test/Index/usrs.m284
-rw-r--r--clang/test/Index/vector-types.c6
-rw-r--r--clang/test/Index/warning-flags.c16
-rw-r--r--clang/test/Index/werror.c12
-rw-r--r--clang/test/Lexer/11-27-2007-FloatLiterals.c13
-rw-r--r--clang/test/Lexer/badstring_in_if0.c8
-rw-r--r--clang/test/Lexer/bcpl-escaped-newline.c12
-rw-r--r--clang/test/Lexer/block_cmt_end.c34
-rw-r--r--clang/test/Lexer/c90.c34
-rw-r--r--clang/test/Lexer/char-escapes.c22
-rw-r--r--clang/test/Lexer/char-literal-encoding-error.c15
-rw-r--r--clang/test/Lexer/char-literal.cpp24
-rw-r--r--clang/test/Lexer/clang-keywords.cpp3
-rw-r--r--clang/test/Lexer/comment-escape.c6
-rw-r--r--clang/test/Lexer/conflict-marker.c38
-rw-r--r--clang/test/Lexer/constants.c69
-rw-r--r--clang/test/Lexer/counter.c16
-rw-r--r--clang/test/Lexer/cxx0x_keyword.cpp2
-rw-r--r--clang/test/Lexer/cxx0x_keyword_as_cxx98.cpp36
-rw-r--r--clang/test/Lexer/cxx0x_raw_string_delim_length.cpp7
-rw-r--r--clang/test/Lexer/cxx0x_raw_string_unterminated.cpp4
-rw-r--r--clang/test/Lexer/digraph.c15
-rw-r--r--clang/test/Lexer/dollar-idents.c7
-rw-r--r--clang/test/Lexer/escape_newline.c11
-rw-r--r--clang/test/Lexer/gnu_keywords.c12
-rw-r--r--clang/test/Lexer/has_extension.c44
-rw-r--r--clang/test/Lexer/has_extension_cxx.cpp49
-rw-r--r--clang/test/Lexer/has_feature_address_sanitizer.cpp11
-rw-r--r--clang/test/Lexer/has_feature_c1x.c47
-rw-r--r--clang/test/Lexer/has_feature_cxx0x.cpp274
-rw-r--r--clang/test/Lexer/has_feature_exceptions.cpp11
-rw-r--r--clang/test/Lexer/has_feature_modules.m25
-rw-r--r--clang/test/Lexer/has_feature_objc_arc.m20
-rw-r--r--clang/test/Lexer/has_feature_rtti.cpp11
-rw-r--r--clang/test/Lexer/has_feature_type_traits.cpp111
-rw-r--r--clang/test/Lexer/hexfloat.cpp7
-rw-r--r--clang/test/Lexer/ms-extensions.c43
-rw-r--r--clang/test/Lexer/ms-extensions.cpp6
-rw-r--r--clang/test/Lexer/msdos-cpm-eof.c7
-rw-r--r--clang/test/Lexer/multiple-include.c27
-rw-r--r--clang/test/Lexer/newline-eof-c++11.cpp4
-rw-r--r--clang/test/Lexer/newline-eof-c++98-compat.cpp4
-rw-r--r--clang/test/Lexer/newline-eof.c5
-rw-r--r--clang/test/Lexer/numeric-literal-trash.c13
-rw-r--r--clang/test/Lexer/pragma-mark.c11
-rw-r--r--clang/test/Lexer/pragma-message.c14
-rw-r--r--clang/test/Lexer/pragma-operators.cpp20
-rw-r--r--clang/test/Lexer/preamble.c36
-rw-r--r--clang/test/Lexer/rdar-8914293.c7
-rw-r--r--clang/test/Lexer/rdr-6096838-2.c5
-rw-r--r--clang/test/Lexer/rdr-6096838.c6
-rw-r--r--clang/test/Lexer/string-literal-encoding.c33
-rw-r--r--clang/test/Lexer/string_concat.cpp33
-rw-r--r--clang/test/Lexer/token-concat-2.c4
-rw-r--r--clang/test/Lexer/token-concat.c4
-rw-r--r--clang/test/Lexer/token-concat.cpp19
-rw-r--r--clang/test/Lexer/unknown-char.c2
-rw-r--r--clang/test/Lexer/utf-16.c6
-rw-r--r--clang/test/Lexer/utf-16.c.txtbin0 -> 48 bytes
-rw-r--r--clang/test/Lexer/utf8-char-literal.cpp5
-rw-r--r--clang/test/Lexer/wchar.c12
-rw-r--r--clang/test/Makefile71
-rw-r--r--clang/test/Misc/Inputs/include.h3
-rw-r--r--clang/test/Misc/Inputs/remapped-file1
-rw-r--r--clang/test/Misc/Inputs/remapped-file-23
-rw-r--r--clang/test/Misc/Inputs/remapped-file-32
-rw-r--r--clang/test/Misc/Inputs/working-directory.h1
-rw-r--r--clang/test/Misc/ast-dump-templates.cpp39
-rw-r--r--clang/test/Misc/caret-diags-macros.c120
-rw-r--r--clang/test/Misc/caret-diags-scratch-buffer.c12
-rw-r--r--clang/test/Misc/diag-aka-types.cpp68
-rw-r--r--clang/test/Misc/diag-format.c34
-rw-r--r--clang/test/Misc/diag-line-wrapping.cpp13
-rw-r--r--clang/test/Misc/diag-macro-backtrace.c53
-rw-r--r--clang/test/Misc/diag-mapping.c30
-rw-r--r--clang/test/Misc/diag-mapping2.c22
-rw-r--r--clang/test/Misc/diag-verify.cpp48
-rw-r--r--clang/test/Misc/emit-html-insert.c4
-rw-r--r--clang/test/Misc/emit-html.c18
-rw-r--r--clang/test/Misc/error-limit-multiple-notes.cpp23
-rw-r--r--clang/test/Misc/error-limit.c15
-rw-r--r--clang/test/Misc/include-stack-for-note-flag.cpp28
-rw-r--r--clang/test/Misc/integer-literal-printing.cpp13
-rw-r--r--clang/test/Misc/macro-backtrace.c57
-rw-r--r--clang/test/Misc/message-length.c41
-rw-r--r--clang/test/Misc/predefines.c5
-rw-r--r--clang/test/Misc/remap-file.c8
-rw-r--r--clang/test/Misc/serialized-diags-no-category.c12
-rw-r--r--clang/test/Misc/serialized-diags-no-issue.c10
-rw-r--r--clang/test/Misc/serialized-diags-single-issue.c36
-rw-r--r--clang/test/Misc/serialized-diags.c67
-rw-r--r--clang/test/Misc/serialized-diags.h5
-rw-r--r--clang/test/Misc/show-diag-options.c27
-rw-r--r--clang/test/Misc/tabstop.c47
-rw-r--r--clang/test/Misc/unprintable.c16
-rw-r--r--clang/test/Misc/verify.c14
-rw-r--r--clang/test/Misc/warn-in-system-header.c4
-rw-r--r--clang/test/Misc/warn-in-system-header.h4
-rw-r--r--clang/test/Misc/warning-flags.c273
-rw-r--r--clang/test/Misc/wnull-character.cppbin0 -> 143 bytes
-rw-r--r--clang/test/Misc/working-directory.c5
-rw-r--r--clang/test/Misc/wrong-encoding.c16
-rw-r--r--clang/test/Modules/Inputs/AlsoDependsOnModule.framework/Headers/AlsoDependsOnModule.h2
-rw-r--r--clang/test/Modules/Inputs/CmdLine.framework/Headers/CmdLine.h6
-rw-r--r--clang/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h1
-rw-r--r--clang/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h2
-rw-r--r--clang/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h5
-rw-r--r--clang/test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h5
-rw-r--r--clang/test/Modules/Inputs/DependsOnModule.framework/Headers/other.h1
-rw-r--r--clang/test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h2
-rw-r--r--clang/test/Modules/Inputs/DependsOnModule.framework/module.map19
-rw-r--r--clang/test/Modules/Inputs/DependsOnModule.framework/module_private.map6
-rw-r--r--clang/test/Modules/Inputs/MethodPoolA.h8
-rw-r--r--clang/test/Modules/Inputs/MethodPoolB.h13
-rw-r--r--clang/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h5
-rw-r--r--clang/test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h1
-rw-r--r--clang/test/Modules/Inputs/Module.framework/Headers/Module.h22
-rw-r--r--clang/test/Modules/Inputs/Module.framework/Headers/NotInModule.h1
-rw-r--r--clang/test/Modules/Inputs/Module.framework/Headers/Sub.h3
-rw-r--r--clang/test/Modules/Inputs/Module.framework/Headers/Sub2.h1
-rw-r--r--clang/test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h1
-rw-r--r--clang/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h3
-rw-r--r--clang/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h6
-rw-r--r--clang/test/Modules/Inputs/NoUmbrella.framework/Headers/A.h8
-rw-r--r--clang/test/Modules/Inputs/NoUmbrella.framework/Headers/B.h1
-rw-r--r--clang/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h1
-rw-r--r--clang/test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h1
-rw-r--r--clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h1
-rw-r--r--clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h1
-rw-r--r--clang/test/Modules/Inputs/NoUmbrella.framework/module.map9
-rw-r--r--clang/test/Modules/Inputs/NoUmbrella.framework/module_private.map4
-rw-r--r--clang/test/Modules/Inputs/System/usr/include/module.map21
-rw-r--r--clang/test/Modules/Inputs/System/usr/include/stdbool.h1
-rw-r--r--clang/test/Modules/Inputs/System/usr/include/stdint.h1
-rw-r--r--clang/test/Modules/Inputs/System/usr/include/stdio.h3
-rw-r--r--clang/test/Modules/Inputs/category_bottom.h11
-rw-r--r--clang/test/Modules/Inputs/category_left.h15
-rw-r--r--clang/test/Modules/Inputs/category_other.h6
-rw-r--r--clang/test/Modules/Inputs/category_right.h12
-rw-r--r--clang/test/Modules/Inputs/category_top.h14
-rw-r--r--clang/test/Modules/Inputs/decl.h2
-rw-r--r--clang/test/Modules/Inputs/decl2.h1
-rw-r--r--clang/test/Modules/Inputs/def-include.h13
-rw-r--r--clang/test/Modules/Inputs/def.h11
-rw-r--r--clang/test/Modules/Inputs/diamond.h1
-rw-r--r--clang/test/Modules/Inputs/diamond_bottom.h4
-rw-r--r--clang/test/Modules/Inputs/diamond_left.h9
-rw-r--r--clang/test/Modules/Inputs/diamond_right.h7
-rw-r--r--clang/test/Modules/Inputs/diamond_top.h4
-rw-r--r--clang/test/Modules/Inputs/irgen.h1
-rw-r--r--clang/test/Modules/Inputs/load_failure.h1
-rw-r--r--clang/test/Modules/Inputs/lookup_left.h3
-rw-r--r--clang/test/Modules/Inputs/lookup_left.hpp5
-rw-r--r--clang/test/Modules/Inputs/lookup_right.h5
-rw-r--r--clang/test/Modules/Inputs/lookup_right.hpp1
-rw-r--r--clang/test/Modules/Inputs/macros.h10
-rw-r--r--clang/test/Modules/Inputs/module.map86
-rw-r--r--clang/test/Modules/Inputs/module_private_left.h26
-rw-r--r--clang/test/Modules/Inputs/module_private_right.h13
-rw-r--r--clang/test/Modules/Inputs/namespaces-left.h53
-rw-r--r--clang/test/Modules/Inputs/namespaces-right.h61
-rw-r--r--clang/test/Modules/Inputs/namespaces-top.h14
-rw-r--r--clang/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h4
-rw-r--r--clang/test/Modules/Inputs/normal-module-map/Umbrella/module.map3
-rw-r--r--clang/test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h2
-rw-r--r--clang/test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h1
-rw-r--r--clang/test/Modules/Inputs/normal-module-map/Umbrella2/module.map3
-rw-r--r--clang/test/Modules/Inputs/normal-module-map/a1.h1
-rw-r--r--clang/test/Modules/Inputs/normal-module-map/a2.h1
-rw-r--r--clang/test/Modules/Inputs/normal-module-map/b1.h2
-rw-r--r--clang/test/Modules/Inputs/normal-module-map/module.map13
-rw-r--r--clang/test/Modules/Inputs/normal-module-map/nested/module.map4
-rw-r--r--clang/test/Modules/Inputs/normal-module-map/nested/nested1.h1
-rw-r--r--clang/test/Modules/Inputs/normal-module-map/nested/nested2.h1
-rw-r--r--clang/test/Modules/Inputs/normal-module-map/nested_umbrella/a.h2
-rw-r--r--clang/test/Modules/Inputs/normal-module-map/nested_umbrella/b.h2
-rw-r--r--clang/test/Modules/Inputs/point.h2
-rw-r--r--clang/test/Modules/Inputs/redecl-merge-bottom.h28
-rw-r--r--clang/test/Modules/Inputs/redecl-merge-left-left.h7
-rw-r--r--clang/test/Modules/Inputs/redecl-merge-left.h90
-rw-r--r--clang/test/Modules/Inputs/redecl-merge-right.h94
-rw-r--r--clang/test/Modules/Inputs/redecl-merge-top-explicit.h9
-rw-r--r--clang/test/Modules/Inputs/redecl-merge-top.h20
-rw-r--r--clang/test/Modules/Inputs/redecl_namespaces_left.h3
-rw-r--r--clang/test/Modules/Inputs/redecl_namespaces_right.h3
-rw-r--r--clang/test/Modules/Inputs/redeclarations_left.h2
-rw-r--r--clang/test/Modules/Inputs/redeclarations_right.h2
-rw-r--r--clang/test/Modules/Inputs/subdir/module.map3
-rw-r--r--clang/test/Modules/Inputs/subdir/subdir.h1
-rw-r--r--clang/test/Modules/Inputs/submodules/hash_map.h4
-rw-r--r--clang/test/Modules/Inputs/submodules/module.map5
-rw-r--r--clang/test/Modules/Inputs/submodules/type_traits.h12
-rw-r--r--clang/test/Modules/Inputs/submodules/vector.h3
-rw-r--r--clang/test/Modules/Inputs/wildcard-submodule-exports/A_one.h1
-rw-r--r--clang/test/Modules/Inputs/wildcard-submodule-exports/A_two.h1
-rw-r--r--clang/test/Modules/Inputs/wildcard-submodule-exports/B_one.h1
-rw-r--r--clang/test/Modules/Inputs/wildcard-submodule-exports/B_two.h1
-rw-r--r--clang/test/Modules/Inputs/wildcard-submodule-exports/C_one.h4
-rw-r--r--clang/test/Modules/Inputs/wildcard-submodule-exports/C_two.h4
-rw-r--r--clang/test/Modules/Inputs/wildcard-submodule-exports/module.map20
-rw-r--r--clang/test/Modules/auto-module-import.m73
-rw-r--r--clang/test/Modules/compiler_builtins.m10
-rw-r--r--clang/test/Modules/cstd.m29
-rw-r--r--clang/test/Modules/cycles.c12
-rw-r--r--clang/test/Modules/decldef.mm28
-rw-r--r--clang/test/Modules/diamond-pch.c28
-rw-r--r--clang/test/Modules/diamond.c29
-rw-r--r--clang/test/Modules/driver.c6
-rw-r--r--clang/test/Modules/header-import.m7
-rw-r--r--clang/test/Modules/inferred-submodules.m15
-rw-r--r--clang/test/Modules/irgen.c13
-rw-r--r--clang/test/Modules/load_failure.c21
-rw-r--r--clang/test/Modules/lookup.cpp34
-rw-r--r--clang/test/Modules/lookup.m20
-rw-r--r--clang/test/Modules/macros.c30
-rw-r--r--clang/test/Modules/method_pool.m30
-rw-r--r--clang/test/Modules/module-private.cpp96
-rw-r--r--clang/test/Modules/namespaces.cpp64
-rw-r--r--clang/test/Modules/normal-module-map.cpp35
-rw-r--r--clang/test/Modules/objc-categories.m40
-rw-r--r--clang/test/Modules/on-demand-build-warnings.m5
-rw-r--r--clang/test/Modules/on-demand-build.m27
-rw-r--r--clang/test/Modules/on-demand-macros.m13
-rw-r--r--clang/test/Modules/redecl-merge.m158
-rw-r--r--clang/test/Modules/redecl-namespaces.mm13
-rw-r--r--clang/test/Modules/redeclarations.m11
-rw-r--r--clang/test/Modules/requires.m5
-rw-r--r--clang/test/Modules/subframeworks.m22
-rw-r--r--clang/test/Modules/submodules-preprocess.cpp61
-rw-r--r--clang/test/Modules/submodules.cpp29
-rw-r--r--clang/test/Modules/submodules.m11
-rw-r--r--clang/test/Modules/wildcard-submodule-exports.cpp26
-rw-r--r--clang/test/PCH/Inputs/arc.h26
-rw-r--r--clang/test/PCH/Inputs/chain-decls1.h11
-rw-r--r--clang/test/PCH/Inputs/chain-decls2.h12
-rw-r--r--clang/test/PCH/Inputs/chain-ext_vector1.h3
-rw-r--r--clang/test/PCH/Inputs/chain-ext_vector2.h3
-rw-r--r--clang/test/PCH/Inputs/chain-external-defs1.h13
-rw-r--r--clang/test/PCH/Inputs/chain-external-defs2.h11
-rw-r--r--clang/test/PCH/Inputs/chain-macro-override1.h5
-rw-r--r--clang/test/PCH/Inputs/chain-macro-override2.h5
-rw-r--r--clang/test/PCH/Inputs/chain-macro1.h1
-rw-r--r--clang/test/PCH/Inputs/chain-macro2.h1
-rw-r--r--clang/test/PCH/Inputs/chain-remap-types1.h10
-rw-r--r--clang/test/PCH/Inputs/chain-remap-types2.h8
-rw-r--r--clang/test/PCH/Inputs/chain-selectors1.h16
-rw-r--r--clang/test/PCH/Inputs/chain-selectors2.h15
-rw-r--r--clang/test/PCH/Inputs/chain-trivial1.h0
-rw-r--r--clang/test/PCH/Inputs/chain-trivial2.h0
-rw-r--r--clang/test/PCH/Inputs/cxx-method.h6
-rw-r--r--clang/test/PCH/Inputs/namespaces.h44
-rw-r--r--clang/test/PCH/Inputs/preamble.h1
-rw-r--r--clang/test/PCH/Inputs/typo.h6
-rw-r--r--clang/test/PCH/Inputs/typo.hpp8
-rw-r--r--clang/test/PCH/Inputs/va_arg.h2
-rw-r--r--clang/test/PCH/Inputs/working-directory-1.h5
-rw-r--r--clang/test/PCH/arc.m17
-rw-r--r--clang/test/PCH/asm.c11
-rw-r--r--clang/test/PCH/asm.h14
-rw-r--r--clang/test/PCH/attrs-PR8406.c23
-rw-r--r--clang/test/PCH/attrs.c17
-rw-r--r--clang/test/PCH/blocks.c12
-rw-r--r--clang/test/PCH/blocks.h14
-rw-r--r--clang/test/PCH/builtins.c10
-rw-r--r--clang/test/PCH/builtins.h2
-rw-r--r--clang/test/PCH/chain-categories.m51
-rw-r--r--clang/test/PCH/chain-categories2.m57
-rw-r--r--clang/test/PCH/chain-class-extension.m42
-rw-r--r--clang/test/PCH/chain-conversion-lookup.cpp26
-rw-r--r--clang/test/PCH/chain-cxx.cpp142
-rw-r--r--clang/test/PCH/chain-decls.c27
-rw-r--r--clang/test/PCH/chain-empty-initial-namespace.cpp24
-rw-r--r--clang/test/PCH/chain-ext_vector.c11
-rw-r--r--clang/test/PCH/chain-external-defs.c54
-rw-r--r--clang/test/PCH/chain-friend-instantiation.cpp61
-rw-r--r--clang/test/PCH/chain-implicit-definition.cpp39
-rw-r--r--clang/test/PCH/chain-late-anonymous-namespace.cpp61
-rw-r--r--clang/test/PCH/chain-macro-override.c14
-rw-r--r--clang/test/PCH/chain-macro.c9
-rw-r--r--clang/test/PCH/chain-pending-instantiations.cpp33
-rw-r--r--clang/test/PCH/chain-predecl.h3
-rw-r--r--clang/test/PCH/chain-predecl.m16
-rw-r--r--clang/test/PCH/chain-remap-types.m12
-rw-r--r--clang/test/PCH/chain-selectors.m40
-rw-r--r--clang/test/PCH/chain-trivial.c4
-rw-r--r--clang/test/PCH/changed-files.c28
-rw-r--r--clang/test/PCH/check-deserializations.cpp20
-rw-r--r--clang/test/PCH/cmdline-include.c6
-rw-r--r--clang/test/PCH/cmdline-include1.h1
-rw-r--r--clang/test/PCH/cmdline-include2.h1
-rw-r--r--clang/test/PCH/cocoa.m7
-rw-r--r--clang/test/PCH/cuda-kernel-call.cu25
-rw-r--r--clang/test/PCH/cxx-alias-decl.cpp20
-rw-r--r--clang/test/PCH/cxx-alias-decl.h11
-rw-r--r--clang/test/PCH/cxx-chain-function-template.cpp32
-rw-r--r--clang/test/PCH/cxx-constexpr.cpp19
-rw-r--r--clang/test/PCH/cxx-exprs.cpp27
-rw-r--r--clang/test/PCH/cxx-for-range.cpp19
-rw-r--r--clang/test/PCH/cxx-for-range.h35
-rw-r--r--clang/test/PCH/cxx-friends.cpp13
-rw-r--r--clang/test/PCH/cxx-friends.h6
-rw-r--r--clang/test/PCH/cxx-functions.cpp10
-rw-r--r--clang/test/PCH/cxx-functions.h1
-rw-r--r--clang/test/PCH/cxx-implicit-moves.cpp23
-rw-r--r--clang/test/PCH/cxx-member-init.cpp22
-rw-r--r--clang/test/PCH/cxx-method.cpp8
-rw-r--r--clang/test/PCH/cxx-ms-function-specialization-class-scope.cpp13
-rw-r--r--clang/test/PCH/cxx-ms-function-specialization-class-scope.h29
-rw-r--r--clang/test/PCH/cxx-namespaces.cpp10
-rw-r--r--clang/test/PCH/cxx-namespaces.h7
-rw-r--r--clang/test/PCH/cxx-offsetof-base.cpp2
-rw-r--r--clang/test/PCH/cxx-offsetof-base.h5
-rw-r--r--clang/test/PCH/cxx-reference.cpp6
-rw-r--r--clang/test/PCH/cxx-reference.h13
-rw-r--r--clang/test/PCH/cxx-required-decls.cpp10
-rw-r--r--clang/test/PCH/cxx-required-decls.h12
-rw-r--r--clang/test/PCH/cxx-static_assert.cpp20
-rw-r--r--clang/test/PCH/cxx-templates.cpp70
-rw-r--r--clang/test/PCH/cxx-templates.h217
-rw-r--r--clang/test/PCH/cxx-trailing-return.cpp15
-rw-r--r--clang/test/PCH/cxx-traits.cpp11
-rw-r--r--clang/test/PCH/cxx-traits.h16
-rw-r--r--clang/test/PCH/cxx-typeid.cpp9
-rw-r--r--clang/test/PCH/cxx-typeid.h3
-rw-r--r--clang/test/PCH/cxx-using.cpp15
-rw-r--r--clang/test/PCH/cxx-using.h16
-rw-r--r--clang/test/PCH/cxx-variadic-templates.cpp11
-rw-r--r--clang/test/PCH/cxx-variadic-templates.h18
-rw-r--r--clang/test/PCH/cxx0x-default-delete.cpp34
-rw-r--r--clang/test/PCH/cxx0x-delegating-ctors.cpp20
-rw-r--r--clang/test/PCH/cxx11-constexpr.cpp29
-rw-r--r--clang/test/PCH/cxx11-enum-template.cpp26
-rw-r--r--clang/test/PCH/cxx11-exception-spec.cpp17
-rw-r--r--clang/test/PCH/cxx11-lambdas.mm48
-rw-r--r--clang/test/PCH/cxx11-user-defined-literals.cpp21
-rw-r--r--clang/test/PCH/cxx_exprs.cpp39
-rw-r--r--clang/test/PCH/cxx_exprs.h83
-rw-r--r--clang/test/PCH/designated-init.c7
-rw-r--r--clang/test/PCH/designated-init.c.h42
-rw-r--r--clang/test/PCH/enum.c15
-rw-r--r--clang/test/PCH/enum.h16
-rw-r--r--clang/test/PCH/exprs.c98
-rw-r--r--clang/test/PCH/exprs.h107
-rw-r--r--clang/test/PCH/ext_vector.c10
-rw-r--r--clang/test/PCH/ext_vector.h4
-rw-r--r--clang/test/PCH/external-defs.c19
-rw-r--r--clang/test/PCH/external-defs.h13
-rw-r--r--clang/test/PCH/functions.c25
-rw-r--r--clang/test/PCH/functions.h11
-rw-r--r--clang/test/PCH/fuzzy-pch.c19
-rw-r--r--clang/test/PCH/fuzzy-pch.h2
-rw-r--r--clang/test/PCH/headermap.h3
-rw-r--r--clang/test/PCH/headermap.m15
-rw-r--r--clang/test/PCH/headersearch.cpp44
-rw-r--r--clang/test/PCH/libroot/usr/include/reloc.h15
-rw-r--r--clang/test/PCH/libroot/usr/include/reloc2.h15
-rw-r--r--clang/test/PCH/line-directive.c25
-rw-r--r--clang/test/PCH/line-directive.h2
-rw-r--r--clang/test/PCH/method-redecls.m18
-rw-r--r--clang/test/PCH/method_pool.h36
-rw-r--r--clang/test/PCH/method_pool.m21
-rw-r--r--clang/test/PCH/missing-file.cpp31
-rw-r--r--clang/test/PCH/modified-header-crash.c10
-rw-r--r--clang/test/PCH/modified-header-crash.h1
-rw-r--r--clang/test/PCH/modified-header-error.c12
-rw-r--r--clang/test/PCH/ms-if-exists.cpp29
-rw-r--r--clang/test/PCH/multiple_decls.c17
-rw-r--r--clang/test/PCH/multiple_decls.h7
-rw-r--r--clang/test/PCH/namespaces.cpp45
-rw-r--r--clang/test/PCH/nonvisible-external-defs.c10
-rw-r--r--clang/test/PCH/nonvisible-external-defs.h11
-rw-r--r--clang/test/PCH/objc_container.h26
-rw-r--r--clang/test/PCH/objc_container.m20
-rw-r--r--clang/test/PCH/objc_exprs.h26
-rw-r--r--clang/test/PCH/objc_exprs.m27
-rw-r--r--clang/test/PCH/objc_import.h7
-rw-r--r--clang/test/PCH/objc_import.m15
-rw-r--r--clang/test/PCH/objc_literals.m66
-rw-r--r--clang/test/PCH/objc_literals.mm65
-rw-r--r--clang/test/PCH/objc_methods.h11
-rw-r--r--clang/test/PCH/objc_methods.m16
-rw-r--r--clang/test/PCH/objc_property.h12
-rw-r--r--clang/test/PCH/objc_property.m11
-rw-r--r--clang/test/PCH/objc_stmts.h22
-rw-r--r--clang/test/PCH/objc_stmts.m12
-rw-r--r--clang/test/PCH/objcxx-ivar-class.h16
-rw-r--r--clang/test/PCH/objcxx-ivar-class.mm15
-rw-r--r--clang/test/PCH/opencl-extensions.cl17
-rw-r--r--clang/test/PCH/pchpch.c6
-rw-r--r--clang/test/PCH/pchpch1.h0
-rw-r--r--clang/test/PCH/pchpch2.h0
-rw-r--r--clang/test/PCH/pending-ids.m33
-rw-r--r--clang/test/PCH/pr4489.c48
-rw-r--r--clang/test/PCH/pragma-diag-section.cpp29
-rw-r--r--clang/test/PCH/pragma-diag.c20
-rw-r--r--clang/test/PCH/pragma-weak.c10
-rw-r--r--clang/test/PCH/pragma-weak.h10
-rw-r--r--clang/test/PCH/preamble.c23
-rw-r--r--clang/test/PCH/preprocess.c8
-rw-r--r--clang/test/PCH/preprocess.h7
-rw-r--r--clang/test/PCH/pth.c7
-rw-r--r--clang/test/PCH/pth.h12
-rw-r--r--clang/test/PCH/rdar10830559.cpp35
-rw-r--r--clang/test/PCH/rdar8852495.c26
-rw-r--r--clang/test/PCH/reinclude.cpp10
-rw-r--r--clang/test/PCH/reinclude1.h7
-rw-r--r--clang/test/PCH/reinclude2.h1
-rw-r--r--clang/test/PCH/reloc.c14
-rw-r--r--clang/test/PCH/replaced-decl.m22
-rw-r--r--clang/test/PCH/selector-warning.h24
-rw-r--r--clang/test/PCH/selector-warning.m19
-rw-r--r--clang/test/PCH/single-token-macro.c24
-rw-r--r--clang/test/PCH/source-manager-stack.c12
-rw-r--r--clang/test/PCH/stmts.c14
-rw-r--r--clang/test/PCH/stmts.h96
-rw-r--r--clang/test/PCH/struct.c28
-rw-r--r--clang/test/PCH/struct.h29
-rw-r--r--clang/test/PCH/subscripting-literals.m47
-rw-r--r--clang/test/PCH/tentative-defs.c9
-rw-r--r--clang/test/PCH/tentative-defs.h9
-rw-r--r--clang/test/PCH/types.c73
-rw-r--r--clang/test/PCH/types.h50
-rw-r--r--clang/test/PCH/typo.cpp17
-rw-r--r--clang/test/PCH/typo.m6
-rw-r--r--clang/test/PCH/typo2.cpp13
-rw-r--r--clang/test/PCH/va_arg.c12
-rw-r--r--clang/test/PCH/va_arg.cpp16
-rw-r--r--clang/test/PCH/va_arg.h8
-rw-r--r--clang/test/PCH/variables.c47
-rw-r--r--clang/test/PCH/variables.h25
-rw-r--r--clang/test/PCH/working-directory.cpp12
-rw-r--r--clang/test/PCH/working-directory.h1
-rw-r--r--clang/test/Parser/CompoundStmtScope.c8
-rw-r--r--clang/test/Parser/DelayedTemplateParsing.cpp92
-rw-r--r--clang/test/Parser/MicrosoftExtensions.c77
-rw-r--r--clang/test/Parser/MicrosoftExtensions.cpp311
-rw-r--r--clang/test/Parser/PR11000.cpp9
-rw-r--r--clang/test/Parser/access-spec-attrs.cpp12
-rw-r--r--clang/test/Parser/altivec.c121
-rw-r--r--clang/test/Parser/argument_qualified.c5
-rw-r--r--clang/test/Parser/argument_redef.c6
-rw-r--r--clang/test/Parser/argument_scope.c6
-rw-r--r--clang/test/Parser/asm-constraints-pr7869.c45
-rw-r--r--clang/test/Parser/asm.c19
-rw-r--r--clang/test/Parser/asm.cpp8
-rw-r--r--clang/test/Parser/attr-availability.c28
-rw-r--r--clang/test/Parser/attributes.c98
-rw-r--r--clang/test/Parser/backtrack-crash.cpp4
-rw-r--r--clang/test/Parser/bad-control.c9
-rw-r--r--clang/test/Parser/block-block-storageclass.c17
-rw-r--r--clang/test/Parser/block-pointer-decl.c28
-rw-r--r--clang/test/Parser/bracket-crash.cpp6
-rw-r--r--clang/test/Parser/builtin_classify_type.c21
-rw-r--r--clang/test/Parser/builtin_types_compatible.c43
-rw-r--r--clang/test/Parser/c-namespace.c6
-rw-r--r--clang/test/Parser/c1x-alignas.c7
-rw-r--r--clang/test/Parser/c1x-generic-selection.c10
-rw-r--r--clang/test/Parser/char-literal-printing.c67
-rw-r--r--clang/test/Parser/check-objc2-syntax-1.m10
-rw-r--r--clang/test/Parser/check-syntax-1.m19
-rw-r--r--clang/test/Parser/check_cast.c12
-rw-r--r--clang/test/Parser/compound_literal.c5
-rw-r--r--clang/test/Parser/control-scope.c8
-rw-r--r--clang/test/Parser/cuda-kernel-call.cu9
-rw-r--r--clang/test/Parser/cxx-altivec.cpp170
-rw-r--r--clang/test/Parser/cxx-ambig-decl-expr-xfail.cpp16
-rw-r--r--clang/test/Parser/cxx-ambig-decl-expr.cpp10
-rw-r--r--clang/test/Parser/cxx-ambig-paren-expr.cpp66
-rw-r--r--clang/test/Parser/cxx-attributes.cpp9
-rw-r--r--clang/test/Parser/cxx-bool.cpp4
-rw-r--r--clang/test/Parser/cxx-casting.cpp92
-rw-r--r--clang/test/Parser/cxx-class.cpp89
-rw-r--r--clang/test/Parser/cxx-condition.cpp15
-rw-r--r--clang/test/Parser/cxx-decl.cpp129
-rw-r--r--clang/test/Parser/cxx-default-args.cpp16
-rw-r--r--clang/test/Parser/cxx-default-delete.cpp23
-rw-r--r--clang/test/Parser/cxx-ext-delete-default.cpp11
-rw-r--r--clang/test/Parser/cxx-extern-c-array.cpp7
-rw-r--r--clang/test/Parser/cxx-friend.cpp40
-rw-r--r--clang/test/Parser/cxx-in-c.c5
-rw-r--r--clang/test/Parser/cxx-member-crash.cpp15
-rw-r--r--clang/test/Parser/cxx-member-init-missing-paren-crash.cpp12
-rw-r--r--clang/test/Parser/cxx-member-initializers.cpp15
-rw-r--r--clang/test/Parser/cxx-namespace-alias.cpp9
-rw-r--r--clang/test/Parser/cxx-reference.cpp21
-rw-r--r--clang/test/Parser/cxx-stmt.cpp60
-rw-r--r--clang/test/Parser/cxx-template-argument.cpp12
-rw-r--r--clang/test/Parser/cxx-template-decl.cpp115
-rw-r--r--clang/test/Parser/cxx-throw.cpp15
-rw-r--r--clang/test/Parser/cxx-typeid.cpp13
-rw-r--r--clang/test/Parser/cxx-typeof.cpp13
-rw-r--r--clang/test/Parser/cxx-undeclared-identifier.cpp9
-rw-r--r--clang/test/Parser/cxx-using-declaration.cpp45
-rw-r--r--clang/test/Parser/cxx-using-directive.cpp38
-rw-r--r--clang/test/Parser/cxx-variadic-func.cpp5
-rw-r--r--clang/test/Parser/cxx0x-ambig.cpp127
-rw-r--r--clang/test/Parser/cxx0x-attributes.cpp83
-rw-r--r--clang/test/Parser/cxx0x-condition.cpp37
-rw-r--r--clang/test/Parser/cxx0x-decl.cpp18
-rw-r--r--clang/test/Parser/cxx0x-for-range.cpp30
-rw-r--r--clang/test/Parser/cxx0x-in-cxx98.cpp23
-rw-r--r--clang/test/Parser/cxx0x-lambda-expressions.cpp43
-rw-r--r--clang/test/Parser/cxx0x-literal-operators.cpp8
-rw-r--r--clang/test/Parser/cxx0x-member-initializers.cpp29
-rw-r--r--clang/test/Parser/cxx0x-override-control-keywords.cpp25
-rw-r--r--clang/test/Parser/cxx0x-rvalue-reference.cpp9
-rw-r--r--clang/test/Parser/cxx11-stmt-attributes.cpp54
-rw-r--r--clang/test/Parser/cxx11-type-specifier.cpp20
-rw-r--r--clang/test/Parser/cxx11-user-defined-literals.cpp112
-rw-r--r--clang/test/Parser/declarators.c102
-rw-r--r--clang/test/Parser/designator.c17
-rw-r--r--clang/test/Parser/encode.m8
-rw-r--r--clang/test/Parser/enhanced-proto-1.m17
-rw-r--r--clang/test/Parser/expressions.c59
-rw-r--r--clang/test/Parser/expressions.m6
-rw-r--r--clang/test/Parser/extension.c20
-rw-r--r--clang/test/Parser/for.cpp20
-rw-r--r--clang/test/Parser/function-decls.c10
-rw-r--r--clang/test/Parser/goto.c30
-rw-r--r--clang/test/Parser/if-scope-c90.c8
-rw-r--r--clang/test/Parser/if-scope-c99.c8
-rw-r--r--clang/test/Parser/implicit-casts.c21
-rw-r--r--clang/test/Parser/knr_parameter_attributes.c11
-rw-r--r--clang/test/Parser/method-def-in-class.m14
-rw-r--r--clang/test/Parser/method-prototype-1.m43
-rw-r--r--clang/test/Parser/missing-end-2.m19
-rw-r--r--clang/test/Parser/missing-end-3.m10
-rw-r--r--clang/test/Parser/missing-end-4.m51
-rw-r--r--clang/test/Parser/missing-end.m7
-rw-r--r--clang/test/Parser/ms-inline-asm.c25
-rw-r--r--clang/test/Parser/namelookup-bug-1.c7
-rw-r--r--clang/test/Parser/namelookup-bug-2.c14
-rw-r--r--clang/test/Parser/namespace-alias-attr.cpp8
-rw-r--r--clang/test/Parser/namespaces.cpp8
-rw-r--r--clang/test/Parser/nested-namespaces-recovery.cpp24
-rw-r--r--clang/test/Parser/objc-alias-printing.m18
-rw-r--r--clang/test/Parser/objc-category-neg-1.m8
-rw-r--r--clang/test/Parser/objc-forcollection-1.m43
-rw-r--r--clang/test/Parser/objc-forcollection-neg-2.m38
-rw-r--r--clang/test/Parser/objc-forcollection-neg.m38
-rw-r--r--clang/test/Parser/objc-foreach-syntax.m25
-rw-r--r--clang/test/Parser/objc-init.m60
-rw-r--r--clang/test/Parser/objc-interfaces.m8
-rw-r--r--clang/test/Parser/objc-messaging-1.m26
-rw-r--r--clang/test/Parser/objc-messaging-neg-1.m13
-rw-r--r--clang/test/Parser/objc-missing-impl.m2
-rw-r--r--clang/test/Parser/objc-property-syntax.m17
-rw-r--r--clang/test/Parser/objc-quirks.m32
-rw-r--r--clang/test/Parser/objc-synthesized-recover.m15
-rw-r--r--clang/test/Parser/objc-try-catch-1.m70
-rw-r--r--clang/test/Parser/objc-type-printing.m19
-rw-r--r--clang/test/Parser/objcxx-at.mm15
-rw-r--r--clang/test/Parser/objcxx-lambda-expressions-neg.mm5
-rw-r--r--clang/test/Parser/objcxx0x-lambda-expressions.mm23
-rw-r--r--clang/test/Parser/objcxx11-attributes.mm57
-rw-r--r--clang/test/Parser/objcxx11-user-defined-literal.mm3
-rw-r--r--clang/test/Parser/offsetof.c7
-rw-r--r--clang/test/Parser/opencl-astype.cl20
-rw-r--r--clang/test/Parser/opencl-image-access.cl16
-rw-r--r--clang/test/Parser/opencl-kernel.cl9
-rw-r--r--clang/test/Parser/opencl-pragma.cl15
-rw-r--r--clang/test/Parser/opencl-storage-class.cl15
-rw-r--r--clang/test/Parser/parenthesis-balance.cpp15
-rw-r--r--clang/test/Parser/parmvardecl_conversion.c4
-rw-r--r--clang/test/Parser/parser_overflow.c7
-rw-r--r--clang/test/Parser/placeholder-recovery.m12
-rw-r--r--clang/test/Parser/pointer-arithmetic.c9
-rw-r--r--clang/test/Parser/pointer_promotion.c17
-rw-r--r--clang/test/Parser/pragma-options.c22
-rw-r--r--clang/test/Parser/pragma-pack.c32
-rw-r--r--clang/test/Parser/pragma-visibility.c9
-rw-r--r--clang/test/Parser/pragma-visibility2.c19
-rw-r--r--clang/test/Parser/pragma-weak.c17
-rw-r--r--clang/test/Parser/prefix-attributes.m8
-rw-r--r--clang/test/Parser/promote_types_in_proto.c9
-rw-r--r--clang/test/Parser/recovery.c100
-rw-r--r--clang/test/Parser/recovery.cpp42
-rw-r--r--clang/test/Parser/recovery.m5
-rw-r--r--clang/test/Parser/recursion-limits.cpp259
-rw-r--r--clang/test/Parser/selector-1.m20
-rw-r--r--clang/test/Parser/skip-function-bodies.mm45
-rw-r--r--clang/test/Parser/statements.c64
-rw-r--r--clang/test/Parser/struct-recursion.c11
-rw-r--r--clang/test/Parser/switch-recovery.cpp172
-rw-r--r--clang/test/Parser/top-level-semi-cxx0x.cpp15
-rw-r--r--clang/test/Parser/traditional_arg_scope.c7
-rw-r--r--clang/test/Parser/typeof.c26
-rw-r--r--clang/test/Parser/types.c14
-rw-r--r--clang/test/Parser/warn-dangling-else.cpp55
-rw-r--r--clang/test/Preprocessor/Inputs/TestFramework.framework/.system_framework0
-rw-r--r--clang/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/AnotherTestFramework.framework/Headers/AnotherTestFramework.h3
-rw-r--r--clang/test/Preprocessor/Inputs/TestFramework.framework/Headers/TestFramework.h6
-rw-r--r--clang/test/Preprocessor/_Pragma-dependency.c7
-rw-r--r--clang/test/Preprocessor/_Pragma-dependency2.c5
-rw-r--r--clang/test/Preprocessor/_Pragma-in-macro-arg.c35
-rw-r--r--clang/test/Preprocessor/_Pragma-location.c4
-rw-r--r--clang/test/Preprocessor/_Pragma-physloc.c6
-rw-r--r--clang/test/Preprocessor/_Pragma.c10
-rw-r--r--clang/test/Preprocessor/assembler-with-cpp.c79
-rw-r--r--clang/test/Preprocessor/builtin_line.c13
-rw-r--r--clang/test/Preprocessor/c90.c10
-rw-r--r--clang/test/Preprocessor/c99-6_10_3_3_p4.c10
-rw-r--r--clang/test/Preprocessor/c99-6_10_3_4_p5.c28
-rw-r--r--clang/test/Preprocessor/c99-6_10_3_4_p6.c27
-rw-r--r--clang/test/Preprocessor/c99-6_10_3_4_p7.c10
-rw-r--r--clang/test/Preprocessor/c99-6_10_3_4_p9.c20
-rw-r--r--clang/test/Preprocessor/clang_headers.c3
-rw-r--r--clang/test/Preprocessor/comment_save.c8
-rw-r--r--clang/test/Preprocessor/comment_save_if.c11
-rw-r--r--clang/test/Preprocessor/comment_save_macro.c13
-rw-r--r--clang/test/Preprocessor/cxx_and.cpp17
-rw-r--r--clang/test/Preprocessor/cxx_bitand.cpp16
-rw-r--r--clang/test/Preprocessor/cxx_bitor.cpp18
-rw-r--r--clang/test/Preprocessor/cxx_compl.cpp16
-rw-r--r--clang/test/Preprocessor/cxx_not.cpp15
-rw-r--r--clang/test/Preprocessor/cxx_not_eq.cpp16
-rw-r--r--clang/test/Preprocessor/cxx_oper_keyword.cpp7
-rw-r--r--clang/test/Preprocessor/cxx_oper_keyword_ms_compat.cpp179
-rw-r--r--clang/test/Preprocessor/cxx_oper_spelling.cpp11
-rw-r--r--clang/test/Preprocessor/cxx_or.cpp17
-rw-r--r--clang/test/Preprocessor/cxx_true.cpp13
-rw-r--r--clang/test/Preprocessor/cxx_xor.cpp18
-rw-r--r--clang/test/Preprocessor/dependencies-and-pp.c31
-rw-r--r--clang/test/Preprocessor/directive-invalid.c7
-rw-r--r--clang/test/Preprocessor/disabled-cond-diags.c10
-rw-r--r--clang/test/Preprocessor/dump-macros-spacing.c13
-rw-r--r--clang/test/Preprocessor/dump-macros-undef.c8
-rw-r--r--clang/test/Preprocessor/dump-options.c3
-rw-r--r--clang/test/Preprocessor/dump_macros.c38
-rw-r--r--clang/test/Preprocessor/dumptokens_phyloc.c5
-rw-r--r--clang/test/Preprocessor/expr_comma.c10
-rw-r--r--clang/test/Preprocessor/expr_define_expansion.c5
-rw-r--r--clang/test/Preprocessor/expr_invalid_tok.c15
-rw-r--r--clang/test/Preprocessor/expr_liveness.c52
-rw-r--r--clang/test/Preprocessor/expr_multichar.c5
-rw-r--r--clang/test/Preprocessor/expr_usual_conversions.c14
-rw-r--r--clang/test/Preprocessor/extension-warning.c18
-rw-r--r--clang/test/Preprocessor/feature_tests.c34
-rw-r--r--clang/test/Preprocessor/file_to_include.h3
-rw-r--r--clang/test/Preprocessor/function_macro_file.c5
-rw-r--r--clang/test/Preprocessor/function_macro_file.h3
-rw-r--r--clang/test/Preprocessor/has_attribute.c26
-rw-r--r--clang/test/Preprocessor/has_include.c83
-rw-r--r--clang/test/Preprocessor/hash_line.c8
-rw-r--r--clang/test/Preprocessor/hash_space.c6
-rw-r--r--clang/test/Preprocessor/header_lookup1.c2
-rw-r--r--clang/test/Preprocessor/if_warning.c31
-rw-r--r--clang/test/Preprocessor/ifdef-recover.c15
-rw-r--r--clang/test/Preprocessor/import_self.c7
-rw-r--r--clang/test/Preprocessor/include-directive1.c14
-rw-r--r--clang/test/Preprocessor/include-directive2.c17
-rw-r--r--clang/test/Preprocessor/include-directive3.c3
-rw-r--r--clang/test/Preprocessor/include-macros.c4
-rw-r--r--clang/test/Preprocessor/include-pth.c3
-rw-r--r--clang/test/Preprocessor/indent_macro.c6
-rw-r--r--clang/test/Preprocessor/init.c1764
-rw-r--r--clang/test/Preprocessor/line-directive-output.c71
-rw-r--r--clang/test/Preprocessor/line-directive.c92
-rw-r--r--clang/test/Preprocessor/macro-multiline.c8
-rw-r--r--clang/test/Preprocessor/macro_arg_directive.c20
-rw-r--r--clang/test/Preprocessor/macro_arg_directive.h9
-rw-r--r--clang/test/Preprocessor/macro_arg_keyword.c6
-rw-r--r--clang/test/Preprocessor/macro_disable.c43
-rw-r--r--clang/test/Preprocessor/macro_expand.c19
-rw-r--r--clang/test/Preprocessor/macro_expandloc.c6
-rw-r--r--clang/test/Preprocessor/macro_expandloc2.c6
-rw-r--r--clang/test/Preprocessor/macro_fn.c46
-rw-r--r--clang/test/Preprocessor/macro_fn_comma_swallow.c28
-rw-r--r--clang/test/Preprocessor/macro_fn_disable_expand.c30
-rw-r--r--clang/test/Preprocessor/macro_fn_lparen_scan.c27
-rw-r--r--clang/test/Preprocessor/macro_fn_lparen_scan2.c7
-rw-r--r--clang/test/Preprocessor/macro_fn_placemarker.c5
-rw-r--r--clang/test/Preprocessor/macro_fn_preexpand.c12
-rw-r--r--clang/test/Preprocessor/macro_fn_varargs_iso.c11
-rw-r--r--clang/test/Preprocessor/macro_fn_varargs_named.c10
-rw-r--r--clang/test/Preprocessor/macro_misc.c23
-rw-r--r--clang/test/Preprocessor/macro_not_define.c9
-rw-r--r--clang/test/Preprocessor/macro_paste_bad.c34
-rw-r--r--clang/test/Preprocessor/macro_paste_bcpl_comment.c5
-rw-r--r--clang/test/Preprocessor/macro_paste_c_block_comment.c5
-rw-r--r--clang/test/Preprocessor/macro_paste_commaext.c13
-rw-r--r--clang/test/Preprocessor/macro_paste_empty.c13
-rw-r--r--clang/test/Preprocessor/macro_paste_hard.c17
-rw-r--r--clang/test/Preprocessor/macro_paste_hashhash.c11
-rw-r--r--clang/test/Preprocessor/macro_paste_msextensions.c34
-rw-r--r--clang/test/Preprocessor/macro_paste_none.c6
-rw-r--r--clang/test/Preprocessor/macro_paste_simple.c14
-rw-r--r--clang/test/Preprocessor/macro_paste_spacing.c7
-rw-r--r--clang/test/Preprocessor/macro_paste_spacing2.c6
-rw-r--r--clang/test/Preprocessor/macro_rescan.c9
-rw-r--r--clang/test/Preprocessor/macro_rescan2.c15
-rw-r--r--clang/test/Preprocessor/macro_rescan_varargs.c13
-rw-r--r--clang/test/Preprocessor/macro_rparen_scan.c8
-rw-r--r--clang/test/Preprocessor/macro_rparen_scan2.c10
-rw-r--r--clang/test/Preprocessor/macro_space.c5
-rw-r--r--clang/test/Preprocessor/macro_undef.c4
-rw-r--r--clang/test/Preprocessor/mi_opt.c11
-rw-r--r--clang/test/Preprocessor/mi_opt.h4
-rw-r--r--clang/test/Preprocessor/mi_opt2.c15
-rw-r--r--clang/test/Preprocessor/mi_opt2.h5
-rw-r--r--clang/test/Preprocessor/microsoft-import.c17
-rw-r--r--clang/test/Preprocessor/missing-system-header.c2
-rw-r--r--clang/test/Preprocessor/missing-system-header.h2
-rw-r--r--clang/test/Preprocessor/mmx.c13
-rw-r--r--clang/test/Preprocessor/non_fragile_feature.m12
-rw-r--r--clang/test/Preprocessor/non_fragile_feature1.m8
-rw-r--r--clang/test/Preprocessor/objc-pp.m4
-rw-r--r--clang/test/Preprocessor/optimize.c29
-rw-r--r--clang/test/Preprocessor/output_paste_avoid.c33
-rw-r--r--clang/test/Preprocessor/overflow.c25
-rw-r--r--clang/test/Preprocessor/pic.c34
-rw-r--r--clang/test/Preprocessor/pp-record.c12
-rw-r--r--clang/test/Preprocessor/pp-record.h3
-rw-r--r--clang/test/Preprocessor/pr2086.c11
-rw-r--r--clang/test/Preprocessor/pr2086.h6
-rw-r--r--clang/test/Preprocessor/pragma-pushpop-macro.c41
-rw-r--r--clang/test/Preprocessor/pragma_diagnostic.c32
-rw-r--r--clang/test/Preprocessor/pragma_diagnostic_output.c26
-rw-r--r--clang/test/Preprocessor/pragma_diagnostic_sections.cpp80
-rw-r--r--clang/test/Preprocessor/pragma_microsoft.c83
-rw-r--r--clang/test/Preprocessor/pragma_poison.c20
-rw-r--r--clang/test/Preprocessor/pragma_sysheader.c12
-rw-r--r--clang/test/Preprocessor/pragma_sysheader.h4
-rw-r--r--clang/test/Preprocessor/pragma_unknown.c28
-rw-r--r--clang/test/Preprocessor/predefined-arch-macros.c866
-rw-r--r--clang/test/Preprocessor/predefined-exceptions.m15
-rw-r--r--clang/test/Preprocessor/predefined-macros.c15
-rw-r--r--clang/test/Preprocessor/print_line_count.c4
-rw-r--r--clang/test/Preprocessor/print_line_empty_file.c12
-rw-r--r--clang/test/Preprocessor/print_line_track.c17
-rw-r--r--clang/test/Preprocessor/pushable-diagnostics.c17
-rw-r--r--clang/test/Preprocessor/skipping_unclean.c9
-rw-r--r--clang/test/Preprocessor/stdint.c959
-rw-r--r--clang/test/Preprocessor/stringize_misc.c30
-rw-r--r--clang/test/Preprocessor/stringize_space.c4
-rw-r--r--clang/test/Preprocessor/stringize_space2.c6
-rw-r--r--clang/test/Preprocessor/traditional-cpp.c12
-rw-r--r--clang/test/Preprocessor/undef-error.c5
-rw-r--r--clang/test/Preprocessor/unterminated.c5
-rw-r--r--clang/test/Preprocessor/user_defined_system_framework.c8
-rw-r--r--clang/test/Preprocessor/warn-disabled-macro-expansion.c27
-rw-r--r--clang/test/Preprocessor/warn-macro-unused.c10
-rw-r--r--clang/test/Preprocessor/warn-macro-unused.h1
-rw-r--r--clang/test/Preprocessor/warning_tests.c19
-rw-r--r--clang/test/Preprocessor/x86_target_features.c32
-rw-r--r--clang/test/Rewriter/blockcast3.mm26
-rw-r--r--clang/test/Rewriter/blockstruct.m17
-rw-r--r--clang/test/Rewriter/crash.m25
-rw-r--r--clang/test/Rewriter/dllimport-typedef.c17
-rw-r--r--clang/test/Rewriter/finally.m42
-rw-r--r--clang/test/Rewriter/func-in-impl.m30
-rw-r--r--clang/test/Rewriter/id-test-3.m14
-rw-r--r--clang/test/Rewriter/inner-block-helper-funcs.mm32
-rw-r--r--clang/test/Rewriter/instancetype-test.mm77
-rw-r--r--clang/test/Rewriter/ivar-encoding-1.m15
-rw-r--r--clang/test/Rewriter/ivar-encoding-2.m12
-rw-r--r--clang/test/Rewriter/metadata-test-1.m12
-rw-r--r--clang/test/Rewriter/metadata-test-2.m15
-rw-r--r--clang/test/Rewriter/method-encoding-1.m18
-rw-r--r--clang/test/Rewriter/missing-dllimport.c19
-rw-r--r--clang/test/Rewriter/objc-bool-literal-check-modern.mm29
-rw-r--r--clang/test/Rewriter/objc-bool-literal-modern-1.mm31
-rw-r--r--clang/test/Rewriter/objc-bool-literal-modern.mm23
-rw-r--r--clang/test/Rewriter/objc-encoding-bug-1.m19
-rw-r--r--clang/test/Rewriter/objc-ivar-receiver-1.m24
-rw-r--r--clang/test/Rewriter/objc-modern-class-init-hooks.mm36
-rw-r--r--clang/test/Rewriter/objc-modern-class-init.mm23
-rw-r--r--clang/test/Rewriter/objc-modern-container-subscript.mm48
-rw-r--r--clang/test/Rewriter/objc-modern-implicit-cast.mm33
-rw-r--r--clang/test/Rewriter/objc-modern-ivar-receiver-1.mm31
-rw-r--r--clang/test/Rewriter/objc-modern-linkage-spec.mm21
-rw-r--r--clang/test/Rewriter/objc-modern-metadata-visibility.mm40
-rw-r--r--clang/test/Rewriter/objc-modern-numeric-literal.mm69
-rw-r--r--clang/test/Rewriter/objc-modern-property-attributes.mm35
-rw-r--r--clang/test/Rewriter/objc-string-concat-1.m14
-rw-r--r--clang/test/Rewriter/objc-super-test.m18
-rw-r--r--clang/test/Rewriter/objc-synchronized-1.m20
-rw-r--r--clang/test/Rewriter/properties.m57
-rw-r--r--clang/test/Rewriter/property-dot-syntax.mm46
-rw-r--r--clang/test/Rewriter/protocol-rewrite-1.m48
-rw-r--r--clang/test/Rewriter/protocol-rewrite-2.m7
-rw-r--r--clang/test/Rewriter/rewrite-anonymous-union.m30
-rw-r--r--clang/test/Rewriter/rewrite-api-bug.m11
-rw-r--r--clang/test/Rewriter/rewrite-block-argument.m33
-rw-r--r--clang/test/Rewriter/rewrite-block-consts.mm19
-rw-r--r--clang/test/Rewriter/rewrite-block-ivar-call.mm12
-rw-r--r--clang/test/Rewriter/rewrite-block-literal-1.mm35
-rw-r--r--clang/test/Rewriter/rewrite-block-literal.mm76
-rw-r--r--clang/test/Rewriter/rewrite-block-pointer.mm109
-rw-r--r--clang/test/Rewriter/rewrite-block-property.m15
-rw-r--r--clang/test/Rewriter/rewrite-byref-in-nested-blocks.mm28
-rw-r--r--clang/test/Rewriter/rewrite-byref-vars.mm57
-rw-r--r--clang/test/Rewriter/rewrite-captured-nested-bvar.c35
-rw-r--r--clang/test/Rewriter/rewrite-cast-ivar-access.mm53
-rw-r--r--clang/test/Rewriter/rewrite-cast-ivar-modern-access.mm46
-rw-r--r--clang/test/Rewriter/rewrite-cast-to-bool.mm17
-rw-r--r--clang/test/Rewriter/rewrite-category-property.mm15
-rw-r--r--clang/test/Rewriter/rewrite-constructor-init.mm24
-rw-r--r--clang/test/Rewriter/rewrite-eh.m20
-rw-r--r--clang/test/Rewriter/rewrite-elaborated-type.mm40
-rw-r--r--clang/test/Rewriter/rewrite-extern-c.mm8
-rw-r--r--clang/test/Rewriter/rewrite-foreach-1.m37
-rw-r--r--clang/test/Rewriter/rewrite-foreach-2.m34
-rw-r--r--clang/test/Rewriter/rewrite-foreach-3.m29
-rw-r--r--clang/test/Rewriter/rewrite-foreach-4.m32
-rw-r--r--clang/test/Rewriter/rewrite-foreach-5.m51
-rw-r--r--clang/test/Rewriter/rewrite-foreach-6.m17
-rw-r--r--clang/test/Rewriter/rewrite-foreach-7.m7
-rw-r--r--clang/test/Rewriter/rewrite-foreach-in-block.mm30
-rw-r--r--clang/test/Rewriter/rewrite-foreach-protocol-id.m29
-rw-r--r--clang/test/Rewriter/rewrite-forward-class.m35
-rw-r--r--clang/test/Rewriter/rewrite-forward-class.mm44
-rw-r--r--clang/test/Rewriter/rewrite-function-decl.mm31
-rw-r--r--clang/test/Rewriter/rewrite-implementation.mm16
-rw-r--r--clang/test/Rewriter/rewrite-ivar-use.m28
-rw-r--r--clang/test/Rewriter/rewrite-local-externs-in-block.mm23
-rw-r--r--clang/test/Rewriter/rewrite-local-static-id.mm24
-rw-r--r--clang/test/Rewriter/rewrite-message-expr.mm25
-rw-r--r--clang/test/Rewriter/rewrite-modern-array-literal.mm27
-rw-r--r--clang/test/Rewriter/rewrite-modern-block-ivar-call.mm17
-rw-r--r--clang/test/Rewriter/rewrite-modern-block.mm23
-rw-r--r--clang/test/Rewriter/rewrite-modern-catch.m31
-rw-r--r--clang/test/Rewriter/rewrite-modern-class.mm70
-rw-r--r--clang/test/Rewriter/rewrite-modern-container-literal.mm55
-rw-r--r--clang/test/Rewriter/rewrite-modern-extern-c-func-decl.mm45
-rw-r--r--clang/test/Rewriter/rewrite-modern-ivar-use.mm26
-rw-r--r--clang/test/Rewriter/rewrite-modern-ivars-1.mm89
-rw-r--r--clang/test/Rewriter/rewrite-modern-ivars-2.mm101
-rw-r--r--clang/test/Rewriter/rewrite-modern-ivars.mm64
-rw-r--r--clang/test/Rewriter/rewrite-modern-nested-ivar.mm33
-rw-r--r--clang/test/Rewriter/rewrite-modern-protocol-1.mm14
-rw-r--r--clang/test/Rewriter/rewrite-modern-protocol.mm31
-rw-r--r--clang/test/Rewriter/rewrite-modern-struct-ivar.mm24
-rw-r--r--clang/test/Rewriter/rewrite-modern-super.mm23
-rw-r--r--clang/test/Rewriter/rewrite-modern-synchronized.m35
-rw-r--r--clang/test/Rewriter/rewrite-modern-throw.m67
-rw-r--r--clang/test/Rewriter/rewrite-modern-try-catch-finally.m63
-rw-r--r--clang/test/Rewriter/rewrite-modern-try-finally.m40
-rw-r--r--clang/test/Rewriter/rewrite-modern-typeof.mm46
-rw-r--r--clang/test/Rewriter/rewrite-nest.m27
-rw-r--r--clang/test/Rewriter/rewrite-nested-blocks-1.mm49
-rw-r--r--clang/test/Rewriter/rewrite-nested-blocks-2.mm21
-rw-r--r--clang/test/Rewriter/rewrite-nested-blocks.mm58
-rw-r--r--clang/test/Rewriter/rewrite-nested-ivar.mm33
-rwxr-xr-xclang/test/Rewriter/rewrite-nested-property-in-blocks.mm54
-rw-r--r--clang/test/Rewriter/rewrite-no-nextline.mm10
-rw-r--r--clang/test/Rewriter/rewrite-property-attributes.mm22
-rw-r--r--clang/test/Rewriter/rewrite-property-set-cfstring.mm21
-rw-r--r--clang/test/Rewriter/rewrite-protocol-property.mm22
-rw-r--r--clang/test/Rewriter/rewrite-protocol-qualified.mm50
-rw-r--r--clang/test/Rewriter/rewrite-protocol-type-1.m27
-rw-r--r--clang/test/Rewriter/rewrite-qualified-id.mm21
-rw-r--r--clang/test/Rewriter/rewrite-rewritten-initializer.mm28
-rw-r--r--clang/test/Rewriter/rewrite-static-block.mm11
-rw-r--r--clang/test/Rewriter/rewrite-super-message.mm51
-rw-r--r--clang/test/Rewriter/rewrite-trivial-constructor.mm21
-rw-r--r--clang/test/Rewriter/rewrite-try-catch.m27
-rw-r--r--clang/test/Rewriter/rewrite-typeof.mm39
-rw-r--r--clang/test/Rewriter/rewrite-unique-block-api.mm27
-rw-r--r--clang/test/Rewriter/rewrite-user-defined-accessors.mm30
-rw-r--r--clang/test/Rewriter/rewrite-vararg.m27
-rw-r--r--clang/test/Rewriter/rewrite-weak-attr.m13
-rw-r--r--clang/test/Rewriter/static-type-protocol-1.m27
-rw-r--r--clang/test/Rewriter/undecl-objc-h.m29
-rw-r--r--clang/test/Rewriter/undeclared-method-1.m9
-rw-r--r--clang/test/Rewriter/undef-field-reference-1.m15
-rw-r--r--clang/test/Rewriter/unnamed-bf-modern-write.mm23
-rw-r--r--clang/test/Rewriter/va-method.m17
-rw-r--r--clang/test/Rewriter/weak_byref_objects.m15
-rw-r--r--clang/test/Sema/128bitint.c13
-rw-r--r--clang/test/Sema/2007-10-01-BuildArrayRef.c20
-rw-r--r--clang/test/Sema/2009-03-09-WeakDeclarations-1.c16
-rw-r--r--clang/test/Sema/2009-04-22-UnknownSize.c4
-rw-r--r--clang/test/Sema/2009-07-17-VoidParameter.c4
-rw-r--r--clang/test/Sema/2010-05-31-palignr.c22
-rw-r--r--clang/test/Sema/Inputs/conversion.h4
-rw-r--r--clang/test/Sema/Inputs/pragma-arc-cf-code-audited.h16
-rw-r--r--clang/test/Sema/Inputs/unused-expr-system-header.h23
-rw-r--r--clang/test/Sema/MicrosoftCompatibility.c16
-rw-r--r--clang/test/Sema/MicrosoftExtensions.c102
-rw-r--r--clang/test/Sema/PR2727.c8
-rw-r--r--clang/test/Sema/PR2728.c9
-rw-r--r--clang/test/Sema/PR2919-builtin-types-compat-strips-crv.c7
-rw-r--r--clang/test/Sema/PR2923.c12
-rw-r--r--clang/test/Sema/PR2963-enum-constant.c17
-rw-r--r--clang/test/Sema/__try.c172
-rw-r--r--clang/test/Sema/address-constant.c10
-rw-r--r--clang/test/Sema/address_spaces.c50
-rw-r--r--clang/test/Sema/align-arm-apcs.c4
-rw-r--r--clang/test/Sema/align-x86-64.c25
-rw-r--r--clang/test/Sema/align-x86.c48
-rw-r--r--clang/test/Sema/alignas.c19
-rw-r--r--clang/test/Sema/altivec-init.c47
-rw-r--r--clang/test/Sema/annotate.c10
-rw-r--r--clang/test/Sema/anonymous-struct-union-c11.c19
-rw-r--r--clang/test/Sema/anonymous-struct-union.c110
-rw-r--r--clang/test/Sema/arg-duplicate.c15
-rw-r--r--clang/test/Sema/arg-scope-c99.c2
-rw-r--r--clang/test/Sema/arg-scope.c5
-rw-r--r--clang/test/Sema/arm-layout.c53
-rw-r--r--clang/test/Sema/arm-neon-types.c35
-rw-r--r--clang/test/Sema/array-bounds-ptr-arith.c21
-rw-r--r--clang/test/Sema/array-constraint.c52
-rw-r--r--clang/test/Sema/array-declared-as-incorrect-type.c16
-rw-r--r--clang/test/Sema/array-init.c289
-rw-r--r--clang/test/Sema/array-size-64.c7
-rw-r--r--clang/test/Sema/array-size.c10
-rw-r--r--clang/test/Sema/asm.c125
-rw-r--r--clang/test/Sema/assign-null.c10
-rw-r--r--clang/test/Sema/assign.c15
-rw-r--r--clang/test/Sema/ast-print.c8
-rw-r--r--clang/test/Sema/atomic-ops.c165
-rw-r--r--clang/test/Sema/atomic-type.c22
-rw-r--r--clang/test/Sema/attr-alias.c8
-rw-r--r--clang/test/Sema/attr-aligned.c38
-rw-r--r--clang/test/Sema/attr-args.c40
-rw-r--r--clang/test/Sema/attr-availability-ios.c21
-rw-r--r--clang/test/Sema/attr-availability-macosx.c31
-rw-r--r--clang/test/Sema/attr-availability.c26
-rw-r--r--clang/test/Sema/attr-cleanup.c40
-rw-r--r--clang/test/Sema/attr-decl-after-definition.c19
-rw-r--r--clang/test/Sema/attr-declspec-ignored.c12
-rw-r--r--clang/test/Sema/attr-deprecated-message.c31
-rw-r--r--clang/test/Sema/attr-deprecated.c115
-rw-r--r--clang/test/Sema/attr-format.c80
-rw-r--r--clang/test/Sema/attr-format_arg.c13
-rw-r--r--clang/test/Sema/attr-malloc.c28
-rw-r--r--clang/test/Sema/attr-mode.c59
-rw-r--r--clang/test/Sema/attr-naked.c12
-rw-r--r--clang/test/Sema/attr-nodebug.c8
-rw-r--r--clang/test/Sema/attr-noinline.c8
-rw-r--r--clang/test/Sema/attr-noreturn.c44
-rw-r--r--clang/test/Sema/attr-regparm.c11
-rw-r--r--clang/test/Sema/attr-returns-twice.c12
-rw-r--r--clang/test/Sema/attr-section.c15
-rw-r--r--clang/test/Sema/attr-sentinel.c59
-rw-r--r--clang/test/Sema/attr-unavailable-message.c49
-rw-r--r--clang/test/Sema/attr-unknown.c4
-rw-r--r--clang/test/Sema/attr-unused.c43
-rw-r--r--clang/test/Sema/attr-used.c20
-rw-r--r--clang/test/Sema/attr-visibility.c9
-rw-r--r--clang/test/Sema/attr-weak.c18
-rw-r--r--clang/test/Sema/bitfield-layout.c42
-rw-r--r--clang/test/Sema/bitfield-promote.c34
-rw-r--r--clang/test/Sema/bitfield.c41
-rw-r--r--clang/test/Sema/block-args.c47
-rw-r--r--clang/test/Sema/block-call.c52
-rw-r--r--clang/test/Sema/block-explicit-noreturn-type.c15
-rw-r--r--clang/test/Sema/block-labels.c27
-rw-r--r--clang/test/Sema/block-literal.c89
-rw-r--r--clang/test/Sema/block-misc.c228
-rw-r--r--clang/test/Sema/block-printf-attribute-1.c21
-rw-r--r--clang/test/Sema/block-return-1.c6
-rw-r--r--clang/test/Sema/block-return-2.c5
-rw-r--r--clang/test/Sema/block-return-3.c5
-rw-r--r--clang/test/Sema/block-return.c136
-rw-r--r--clang/test/Sema/block-sentinel-attribute.c25
-rw-r--r--clang/test/Sema/block-storageclass.c18
-rw-r--r--clang/test/Sema/builtin-object-size.c28
-rw-r--r--clang/test/Sema/builtin-prefetch.c14
-rw-r--r--clang/test/Sema/builtin-stackaddress.c16
-rw-r--r--clang/test/Sema/builtin-unary-fp.c16
-rw-r--r--clang/test/Sema/builtin_objc_msgSend.c12
-rw-r--r--clang/test/Sema/builtins-arm.c16
-rw-r--r--clang/test/Sema/builtins-decl.c8
-rw-r--r--clang/test/Sema/builtins.c164
-rw-r--r--clang/test/Sema/c11-typedef-redef.c18
-rw-r--r--clang/test/Sema/c89-2.c5
-rw-r--r--clang/test/Sema/c89.c112
-rw-r--r--clang/test/Sema/callingconv.c46
-rw-r--r--clang/test/Sema/carbon.c5
-rw-r--r--clang/test/Sema/cast-incomplete.c14
-rw-r--r--clang/test/Sema/cast-to-union.c20
-rw-r--r--clang/test/Sema/cast.c159
-rw-r--r--clang/test/Sema/check-increment.c10
-rw-r--r--clang/test/Sema/compare.c335
-rw-r--r--clang/test/Sema/complex-imag.c29
-rw-r--r--clang/test/Sema/complex-init-list.c48
-rw-r--r--clang/test/Sema/complex-int.c67
-rw-r--r--clang/test/Sema/complex-promotion.c15
-rw-r--r--clang/test/Sema/compound-literal.c37
-rw-r--r--clang/test/Sema/conditional-expr.c112
-rw-r--r--clang/test/Sema/conditional.c14
-rw-r--r--clang/test/Sema/const-eval-64.c7
-rw-r--r--clang/test/Sema/const-eval.c133
-rw-r--r--clang/test/Sema/const-ptr-int-ptr-cast.c5
-rw-r--r--clang/test/Sema/constant-builtins-2.c56
-rw-r--r--clang/test/Sema/constant-builtins.c24
-rw-r--r--clang/test/Sema/constant-conversion.c82
-rw-r--r--clang/test/Sema/constructor-attribute.c15
-rw-r--r--clang/test/Sema/conversion-64-32.c19
-rw-r--r--clang/test/Sema/conversion.c419
-rw-r--r--clang/test/Sema/crash-invalid-array.c17
-rw-r--r--clang/test/Sema/darwin-align-cast.c24
-rw-r--r--clang/test/Sema/decl-in-prototype.c33
-rw-r--r--clang/test/Sema/decl-invalid.c28
-rw-r--r--clang/test/Sema/decl-type-merging.c16
-rw-r--r--clang/test/Sema/declspec.c38
-rw-r--r--clang/test/Sema/default.c8
-rw-r--r--clang/test/Sema/default1.c2
-rw-r--r--clang/test/Sema/deref.c44
-rw-r--r--clang/test/Sema/designated-initializers.c279
-rw-r--r--clang/test/Sema/dllimport-dllexport.c37
-rw-r--r--clang/test/Sema/enum-packed.c16
-rw-r--r--clang/test/Sema/enum.c121
-rw-r--r--clang/test/Sema/expr-address-of.c120
-rw-r--r--clang/test/Sema/expr-comma-c99.c17
-rw-r--r--clang/test/Sema/expr-comma.c17
-rw-r--r--clang/test/Sema/exprs.c240
-rw-r--r--clang/test/Sema/ext_vector_casts.c52
-rw-r--r--clang/test/Sema/ext_vector_comparisons.c30
-rw-r--r--clang/test/Sema/ext_vector_components.c47
-rw-r--r--clang/test/Sema/extern-redecl.c22
-rw-r--r--clang/test/Sema/flexible-array-init.c91
-rw-r--r--clang/test/Sema/floating-point-compare.c25
-rw-r--r--clang/test/Sema/fn-ptr-as-fn-prototype.c15
-rw-r--r--clang/test/Sema/for.c7
-rw-r--r--clang/test/Sema/format-string-percentm.c7
-rw-r--r--clang/test/Sema/format-strings-c90.c30
-rw-r--r--clang/test/Sema/format-strings-fixit-ssize_t.c18
-rw-r--r--clang/test/Sema/format-strings-fixit.c208
-rw-r--r--clang/test/Sema/format-strings-int-typedefs.c37
-rw-r--r--clang/test/Sema/format-strings-no-fixit.c65
-rw-r--r--clang/test/Sema/format-strings-non-iso.c29
-rw-r--r--clang/test/Sema/format-strings-scanf.c123
-rw-r--r--clang/test/Sema/format-strings-size_t.c15
-rw-r--r--clang/test/Sema/format-strings.c523
-rw-r--r--clang/test/Sema/fp16-sema.c30
-rw-r--r--clang/test/Sema/fpack-struct.c9
-rw-r--r--clang/test/Sema/freemain.c9
-rw-r--r--clang/test/Sema/function-ptr.c11
-rw-r--r--clang/test/Sema/function-redecl.c131
-rw-r--r--clang/test/Sema/function.c94
-rw-r--r--clang/test/Sema/generic-selection.c26
-rw-r--r--clang/test/Sema/gnu89.c5
-rw-r--r--clang/test/Sema/heinous-extensions-off.c10
-rw-r--r--clang/test/Sema/heinous-extensions-on.c9
-rw-r--r--clang/test/Sema/i-c-e.c75
-rw-r--r--clang/test/Sema/illegal-types.c7
-rw-r--r--clang/test/Sema/implicit-builtin-decl.c57
-rw-r--r--clang/test/Sema/implicit-builtin-freestanding.c4
-rw-r--r--clang/test/Sema/implicit-builtin-redecl.c26
-rw-r--r--clang/test/Sema/implicit-cast.c8
-rw-r--r--clang/test/Sema/implicit-decl.c32
-rw-r--r--clang/test/Sema/implicit-def.c8
-rw-r--r--clang/test/Sema/implicit-int.c28
-rw-r--r--clang/test/Sema/incompatible-sign.c5
-rw-r--r--clang/test/Sema/incomplete-call.c13
-rw-r--r--clang/test/Sema/incomplete-decl.c31
-rw-r--r--clang/test/Sema/indirect-goto.c11
-rw-r--r--clang/test/Sema/init-struct-qualified.c12
-rw-r--r--clang/test/Sema/init-vector.c17
-rw-r--r--clang/test/Sema/init.c159
-rw-r--r--clang/test/Sema/initialize-noreturn.c16
-rw-r--r--clang/test/Sema/inline-redef.c24
-rw-r--r--clang/test/Sema/inline.c6
-rw-r--r--clang/test/Sema/int-arith-convert.c12
-rw-r--r--clang/test/Sema/invalid-decl.c22
-rw-r--r--clang/test/Sema/invalid-init-diag.c4
-rw-r--r--clang/test/Sema/invalid-struct-init.c27
-rw-r--r--clang/test/Sema/knr-def-call.c41
-rw-r--r--clang/test/Sema/knr-variadic-def.c29
-rw-r--r--clang/test/Sema/many-logical-ops.c2010
-rw-r--r--clang/test/Sema/many-parameters.c310
-rw-r--r--clang/test/Sema/member-reference.c20
-rw-r--r--clang/test/Sema/memset-invalid.c6
-rw-r--r--clang/test/Sema/merge-decls.c39
-rw-r--r--clang/test/Sema/missing-field-initializers.c52
-rw-r--r--clang/test/Sema/ms_class_layout.cpp335
-rw-r--r--clang/test/Sema/neon-vector-types.c33
-rw-r--r--clang/test/Sema/nested-redef.c22
-rw-r--r--clang/test/Sema/no-format-y2k-turnsoff-format.c9
-rw-r--r--clang/test/Sema/nonnull.c21
-rw-r--r--clang/test/Sema/offsetof.c71
-rw-r--r--clang/test/Sema/overloadable-complex.c50
-rw-r--r--clang/test/Sema/overloadable.c71
-rw-r--r--clang/test/Sema/overloaded-func-transparent-union.c28
-rw-r--r--clang/test/Sema/parentheses.c73
-rw-r--r--clang/test/Sema/parentheses.cpp47
-rw-r--r--clang/test/Sema/pointer-addition.c21
-rw-r--r--clang/test/Sema/pointer-conversion.c10
-rw-r--r--clang/test/Sema/pointer-subtract-compat.c11
-rw-r--r--clang/test/Sema/pragma-align-mac68k-unsupported.c4
-rw-r--r--clang/test/Sema/pragma-align-mac68k.c98
-rw-r--r--clang/test/Sema/pragma-align-packed.c30
-rw-r--r--clang/test/Sema/pragma-arc-cf-code-audited.c18
-rw-r--r--clang/test/Sema/pragma-ms_struct.c55
-rw-r--r--clang/test/Sema/pragma-pack-2.c59
-rw-r--r--clang/test/Sema/pragma-pack-3.c34
-rw-r--r--clang/test/Sema/pragma-pack-4.c19
-rw-r--r--clang/test/Sema/pragma-pack-5.c45
-rw-r--r--clang/test/Sema/pragma-pack-and-options-align.c42
-rw-r--r--clang/test/Sema/pragma-pack-apple.c10
-rw-r--r--clang/test/Sema/pragma-pack.c27
-rw-r--r--clang/test/Sema/pragma-unused.c65
-rw-r--r--clang/test/Sema/predef.c19
-rw-r--r--clang/test/Sema/predefined-function.c38
-rw-r--r--clang/test/Sema/private-extern.c84
-rw-r--r--clang/test/Sema/rdr6094103-unordered-compare-promote.c6
-rw-r--r--clang/test/Sema/recover-goto.c5
-rw-r--r--clang/test/Sema/redefinition.c14
-rw-r--r--clang/test/Sema/return-noreturn.c37
-rw-r--r--clang/test/Sema/return-silent.c9
-rw-r--r--clang/test/Sema/return.c266
-rw-r--r--clang/test/Sema/scope-check.c234
-rw-r--r--clang/test/Sema/self-comparison.c88
-rw-r--r--clang/test/Sema/sentinel-attribute.c15
-rw-r--r--clang/test/Sema/shift.c68
-rw-r--r--clang/test/Sema/short-enums.c5
-rw-r--r--clang/test/Sema/sign-conversion.c8
-rw-r--r--clang/test/Sema/statements.c102
-rw-r--r--clang/test/Sema/static-array.c31
-rw-r--r--clang/test/Sema/static-assert.c11
-rw-r--r--clang/test/Sema/static-init.c24
-rw-r--r--clang/test/Sema/stdcall-fastcall.c21
-rw-r--r--clang/test/Sema/struct-cast.c15
-rw-r--r--clang/test/Sema/struct-compat.c17
-rw-r--r--clang/test/Sema/struct-decl.c59
-rw-r--r--clang/test/Sema/struct-packed-align.c134
-rw-r--r--clang/test/Sema/surpress-deprecated.c7
-rw-r--r--clang/test/Sema/switch.c322
-rw-r--r--clang/test/Sema/tentative-decls.c65
-rw-r--r--clang/test/Sema/text-diag.c4
-rw-r--r--clang/test/Sema/thread-specifier.c21
-rw-r--r--clang/test/Sema/transparent-union-pointer.c14
-rw-r--r--clang/test/Sema/transparent-union.c73
-rw-r--r--clang/test/Sema/type-spec-struct-union.c65
-rw-r--r--clang/test/Sema/typecheck-binop.c27
-rw-r--r--clang/test/Sema/typedef-prototype.c8
-rw-r--r--clang/test/Sema/typedef-redef.c11
-rw-r--r--clang/test/Sema/typedef-retain.c26
-rw-r--r--clang/test/Sema/typedef-variable-type.c8
-rw-r--r--clang/test/Sema/typeof-use-deprecated.c26
-rw-r--r--clang/test/Sema/types.c66
-rw-r--r--clang/test/Sema/ucn-cstring.c16
-rw-r--r--clang/test/Sema/uninit-variables-vectors.c17
-rw-r--r--clang/test/Sema/uninit-variables.c426
-rw-r--r--clang/test/Sema/unnamed-bitfield-init.c6
-rw-r--r--clang/test/Sema/unused-expr-system-header.c10
-rw-r--r--clang/test/Sema/unused-expr.c123
-rw-r--r--clang/test/Sema/usual-float.c12
-rw-r--r--clang/test/Sema/va_arg_x86_32.c6
-rw-r--r--clang/test/Sema/va_arg_x86_64.c15
-rw-r--r--clang/test/Sema/var-redecl.c62
-rw-r--r--clang/test/Sema/varargs-x86-64.c8
-rw-r--r--clang/test/Sema/varargs.c78
-rw-r--r--clang/test/Sema/variadic-block.c41
-rw-r--r--clang/test/Sema/variadic-incomplete-arg-type.c13
-rw-r--r--clang/test/Sema/vector-assign.c53
-rw-r--r--clang/test/Sema/vector-cast.c38
-rw-r--r--clang/test/Sema/vector-init.c44
-rw-r--r--clang/test/Sema/vector-ops.c29
-rw-r--r--clang/test/Sema/vfprintf-invalid-redecl.c6
-rw-r--r--clang/test/Sema/vfprintf-valid-redecl.c6
-rw-r--r--clang/test/Sema/vla-2.c17
-rw-r--r--clang/test/Sema/vla.c67
-rw-r--r--clang/test/Sema/void_arg.c26
-rw-r--r--clang/test/Sema/warn-cast-align.c41
-rw-r--r--clang/test/Sema/warn-char-subscripts.c64
-rw-r--r--clang/test/Sema/warn-freestanding-complex.c4
-rw-r--r--clang/test/Sema/warn-gnu-designators.c2
-rw-r--r--clang/test/Sema/warn-missing-braces.c3
-rw-r--r--clang/test/Sema/warn-missing-prototypes.c37
-rw-r--r--clang/test/Sema/warn-shadow.c61
-rw-r--r--clang/test/Sema/warn-sizeof-arrayarg.c30
-rw-r--r--clang/test/Sema/warn-strlcpycat-size.c55
-rw-r--r--clang/test/Sema/warn-strncat-size.c71
-rw-r--r--clang/test/Sema/warn-unreachable.c134
-rw-r--r--clang/test/Sema/warn-unused-function.c56
-rw-r--r--clang/test/Sema/warn-unused-label.c11
-rw-r--r--clang/test/Sema/warn-unused-parameters.c30
-rw-r--r--clang/test/Sema/warn-unused-value.c90
-rw-r--r--clang/test/Sema/warn-unused-variables.c32
-rw-r--r--clang/test/Sema/warn-write-strings.c10
-rw-r--r--clang/test/Sema/wchar.c22
-rw-r--r--clang/test/Sema/weak-import-on-enum.c8
-rw-r--r--clang/test/Sema/x86-attr-force-align-arg-pointer.c21
-rw-r--r--clang/test/Sema/x86-builtin-palignr.c17
-rw-r--r--clang/test/SemaCUDA/config-type.cu3
-rw-r--r--clang/test/SemaCUDA/cuda.h19
-rw-r--r--clang/test/SemaCUDA/function-target.cu44
-rw-r--r--clang/test/SemaCUDA/kernel-call.cu26
-rw-r--r--clang/test/SemaCUDA/qualifiers.cu8
-rw-r--r--clang/test/SemaCXX/2008-01-11-BadWarning.cpp5
-rw-r--r--clang/test/SemaCXX/Inputs/array-bounds-system-header.h11
-rw-r--r--clang/test/SemaCXX/Inputs/lit.local.cfg1
-rw-r--r--clang/test/SemaCXX/Inputs/malloc.h3
-rw-r--r--clang/test/SemaCXX/Inputs/warn-new-overaligned-3.h19
-rw-r--r--clang/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp8
-rw-r--r--clang/test/SemaCXX/MicrosoftCompatibility.cpp176
-rw-r--r--clang/test/SemaCXX/MicrosoftExtensions.cpp205
-rw-r--r--clang/test/SemaCXX/PR10177.cpp40
-rw-r--r--clang/test/SemaCXX/PR10243.cpp23
-rw-r--r--clang/test/SemaCXX/PR10447.cpp22
-rw-r--r--clang/test/SemaCXX/PR10458.cpp7
-rw-r--r--clang/test/SemaCXX/PR11358.cpp51
-rw-r--r--clang/test/SemaCXX/PR12481.cpp17
-rw-r--r--clang/test/SemaCXX/PR5086-ambig-resolution-enum.cpp13
-rw-r--r--clang/test/SemaCXX/PR6562.cpp10
-rw-r--r--clang/test/SemaCXX/PR6618.cpp13
-rw-r--r--clang/test/SemaCXX/PR7410.cpp13
-rw-r--r--clang/test/SemaCXX/PR7944.cpp12
-rw-r--r--clang/test/SemaCXX/PR8012.cpp3
-rw-r--r--clang/test/SemaCXX/PR8385.cpp7
-rw-r--r--clang/test/SemaCXX/PR8755.cpp16
-rw-r--r--clang/test/SemaCXX/PR8884.cpp12
-rw-r--r--clang/test/SemaCXX/PR9459.cpp7
-rw-r--r--clang/test/SemaCXX/PR9460.cpp19
-rw-r--r--clang/test/SemaCXX/PR9461.cpp32
-rw-r--r--clang/test/SemaCXX/PR9572.cpp15
-rw-r--r--clang/test/SemaCXX/PR9884.cpp17
-rw-r--r--clang/test/SemaCXX/PR9902.cpp28
-rw-r--r--clang/test/SemaCXX/PR9908.cpp32
-rw-r--r--clang/test/SemaCXX/__null.cpp21
-rw-r--r--clang/test/SemaCXX/__try.cpp58
-rw-r--r--clang/test/SemaCXX/abstract.cpp261
-rw-r--r--clang/test/SemaCXX/access-base-class.cpp91
-rw-r--r--clang/test/SemaCXX/access-control-check.cpp15
-rw-r--r--clang/test/SemaCXX/access-member-pointer.cpp11
-rw-r--r--clang/test/SemaCXX/access.cpp34
-rw-r--r--clang/test/SemaCXX/addr-of-overloaded-function-casting.cpp57
-rw-r--r--clang/test/SemaCXX/addr-of-overloaded-function.cpp210
-rw-r--r--clang/test/SemaCXX/address-of-temporary.cpp12
-rw-r--r--clang/test/SemaCXX/address-of.cpp46
-rw-r--r--clang/test/SemaCXX/address-space-conversion.cpp197
-rw-r--r--clang/test/SemaCXX/address-space-newdelete.cpp24
-rw-r--r--clang/test/SemaCXX/address-space-references.cpp19
-rw-r--r--clang/test/SemaCXX/aggregate-initialization.cpp84
-rw-r--r--clang/test/SemaCXX/alias-template.cpp147
-rw-r--r--clang/test/SemaCXX/alignof-sizeof-reference.cpp22
-rw-r--r--clang/test/SemaCXX/altivec.cpp78
-rw-r--r--clang/test/SemaCXX/ambig-user-defined-conversions.cpp67
-rw-r--r--clang/test/SemaCXX/ambiguous-builtin-unary-operator.cpp34
-rw-r--r--clang/test/SemaCXX/anonymous-struct.cpp16
-rw-r--r--clang/test/SemaCXX/anonymous-union.cpp199
-rw-r--r--clang/test/SemaCXX/array-bound-merge.cpp9
-rw-r--r--clang/test/SemaCXX/array-bounds-ptr-arith.cpp33
-rw-r--r--clang/test/SemaCXX/array-bounds-system-header.cpp9
-rw-r--r--clang/test/SemaCXX/array-bounds.cpp255
-rw-r--r--clang/test/SemaCXX/arrow-operator.cpp38
-rw-r--r--clang/test/SemaCXX/atomic-type.cxx35
-rw-r--r--clang/test/SemaCXX/attr-after-definition.cpp9
-rw-r--r--clang/test/SemaCXX/attr-cxx0x.cpp32
-rw-r--r--clang/test/SemaCXX/attr-declspec-ignored.cpp19
-rw-r--r--clang/test/SemaCXX/attr-deprecated.cpp235
-rw-r--r--clang/test/SemaCXX/attr-format.cpp35
-rw-r--r--clang/test/SemaCXX/attr-nonnull.cpp33
-rw-r--r--clang/test/SemaCXX/attr-noreturn.cpp56
-rw-r--r--clang/test/SemaCXX/attr-regparm.cpp15
-rw-r--r--clang/test/SemaCXX/attr-sentinel.cpp23
-rw-r--r--clang/test/SemaCXX/attr-unavailable.cpp39
-rw-r--r--clang/test/SemaCXX/attr-weak.cpp29
-rw-r--r--clang/test/SemaCXX/attr-weakref.cpp31
-rw-r--r--clang/test/SemaCXX/auto-cxx0x.cpp5
-rw-r--r--clang/test/SemaCXX/auto-cxx98.cpp8
-rw-r--r--clang/test/SemaCXX/auto-subst-failure.cpp15
-rw-r--r--clang/test/SemaCXX/bitfield-layout.cpp30
-rw-r--r--clang/test/SemaCXX/block-call.cpp52
-rw-r--r--clang/test/SemaCXX/blocks-1.cpp58
-rw-r--r--clang/test/SemaCXX/blocks.cpp70
-rw-r--r--clang/test/SemaCXX/bool.cpp33
-rw-r--r--clang/test/SemaCXX/borland-extensions.cpp53
-rw-r--r--clang/test/SemaCXX/builtin-exception-spec.cpp6
-rw-r--r--clang/test/SemaCXX/builtin-ptrtomember-ambig.cpp27
-rw-r--r--clang/test/SemaCXX/builtin-ptrtomember-overload-1.cpp46
-rw-r--r--clang/test/SemaCXX/builtin-ptrtomember-overload.cpp30
-rw-r--r--clang/test/SemaCXX/builtin_objc_msgSend.cpp14
-rw-r--r--clang/test/SemaCXX/builtins.cpp9
-rw-r--r--clang/test/SemaCXX/c99-variable-length-array.cpp141
-rw-r--r--clang/test/SemaCXX/c99.cpp9
-rw-r--r--clang/test/SemaCXX/cast-conversion.cpp47
-rw-r--r--clang/test/SemaCXX/cast-explicit-ctor.cpp6
-rw-r--r--clang/test/SemaCXX/class-base-member-init.cpp92
-rw-r--r--clang/test/SemaCXX/class-layout.cpp104
-rw-r--r--clang/test/SemaCXX/class-names.cpp52
-rw-r--r--clang/test/SemaCXX/class.cpp197
-rw-r--r--clang/test/SemaCXX/comma.cpp8
-rw-r--r--clang/test/SemaCXX/compare.cpp225
-rw-r--r--clang/test/SemaCXX/complex-init-list.cpp14
-rw-r--r--clang/test/SemaCXX/complex-overload.cpp50
-rw-r--r--clang/test/SemaCXX/composite-pointer-type.cpp60
-rw-r--r--clang/test/SemaCXX/compound-literal.cpp14
-rw-r--r--clang/test/SemaCXX/condition.cpp60
-rw-r--r--clang/test/SemaCXX/conditional-expr.cpp330
-rw-r--r--clang/test/SemaCXX/const-cast.cpp64
-rw-r--r--clang/test/SemaCXX/constant-expression-cxx11.cpp1250
-rw-r--r--clang/test/SemaCXX/constant-expression.cpp119
-rw-r--r--clang/test/SemaCXX/constexpr-ackermann.cpp8
-rw-r--r--clang/test/SemaCXX/constexpr-backtrace-limit.cpp34
-rw-r--r--clang/test/SemaCXX/constexpr-depth.cpp8
-rw-r--r--clang/test/SemaCXX/constexpr-factorial.cpp9
-rw-r--r--clang/test/SemaCXX/constexpr-nqueens.cpp73
-rw-r--r--clang/test/SemaCXX/constexpr-printing.cpp102
-rw-r--r--clang/test/SemaCXX/constexpr-strlen.cpp15
-rw-r--r--clang/test/SemaCXX/constexpr-turing.cpp55
-rw-r--r--clang/test/SemaCXX/constexpr-value-init.cpp37
-rw-r--r--clang/test/SemaCXX/constructor-initializer.cpp282
-rw-r--r--clang/test/SemaCXX/constructor-recovery.cpp9
-rw-r--r--clang/test/SemaCXX/constructor.cpp87
-rw-r--r--clang/test/SemaCXX/conversion-delete-expr.cpp109
-rw-r--r--clang/test/SemaCXX/conversion-function.cpp394
-rw-r--r--clang/test/SemaCXX/conversion.cpp83
-rw-r--r--clang/test/SemaCXX/convert-to-bool.cpp67
-rw-r--r--clang/test/SemaCXX/converting-constructor.cpp47
-rw-r--r--clang/test/SemaCXX/copy-assignment.cpp110
-rw-r--r--clang/test/SemaCXX/copy-constructor-error.cpp25
-rw-r--r--clang/test/SemaCXX/copy-initialization.cpp67
-rw-r--r--clang/test/SemaCXX/crashes.cpp106
-rw-r--r--clang/test/SemaCXX/cstyle-cast.cpp231
-rw-r--r--clang/test/SemaCXX/cv-unqual-rvalues.cpp24
-rw-r--r--clang/test/SemaCXX/cxx-member-pointer-op.cpp21
-rw-r--r--clang/test/SemaCXX/cxx0x-class.cpp39
-rw-r--r--clang/test/SemaCXX/cxx0x-compat.cpp39
-rw-r--r--clang/test/SemaCXX/cxx0x-constexpr-const.cpp10
-rw-r--r--clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp75
-rw-r--r--clang/test/SemaCXX/cxx0x-defaulted-functions.cpp53
-rw-r--r--clang/test/SemaCXX/cxx0x-delegating-ctors.cpp48
-rw-r--r--clang/test/SemaCXX/cxx0x-deleted-default-ctor.cpp131
-rw-r--r--clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp89
-rw-r--r--clang/test/SemaCXX/cxx0x-initializer-constructor.cpp283
-rw-r--r--clang/test/SemaCXX/cxx0x-initializer-references.cpp92
-rw-r--r--clang/test/SemaCXX/cxx0x-initializer-scalars.cpp116
-rw-r--r--clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp177
-rw-r--r--clang/test/SemaCXX/cxx0x-nontrivial-union.cpp124
-rw-r--r--clang/test/SemaCXX/cxx0x-return-init-list.cpp16
-rw-r--r--clang/test/SemaCXX/cxx0x-type-convert-construct.cpp21
-rw-r--r--clang/test/SemaCXX/cxx11-ast-print.cpp41
-rw-r--r--clang/test/SemaCXX/cxx11-user-defined-literals.cpp137
-rw-r--r--clang/test/SemaCXX/cxx98-compat-flags.cpp35
-rw-r--r--clang/test/SemaCXX/cxx98-compat-pedantic.cpp34
-rw-r--r--clang/test/SemaCXX/cxx98-compat.cpp305
-rw-r--r--clang/test/SemaCXX/dcl_ambig_res.cpp76
-rw-r--r--clang/test/SemaCXX/dcl_init_aggr.cpp123
-rw-r--r--clang/test/SemaCXX/decl-expr-ambiguity.cpp72
-rw-r--r--clang/test/SemaCXX/decl-init-ref.cpp29
-rw-r--r--clang/test/SemaCXX/decltype-98.cpp3
-rw-r--r--clang/test/SemaCXX/decltype-crash.cpp7
-rw-r--r--clang/test/SemaCXX/decltype-overloaded-functions.cpp15
-rw-r--r--clang/test/SemaCXX/decltype-pr4444.cpp6
-rw-r--r--clang/test/SemaCXX/decltype-pr4448.cpp8
-rw-r--r--clang/test/SemaCXX/decltype-this.cpp16
-rw-r--r--clang/test/SemaCXX/decltype.cpp30
-rw-r--r--clang/test/SemaCXX/default-arg-special-member.cpp12
-rw-r--r--clang/test/SemaCXX/default-argument-temporaries.cpp11
-rw-r--r--clang/test/SemaCXX/default-assignment-operator.cpp118
-rw-r--r--clang/test/SemaCXX/default-constructor-initializers.cpp68
-rw-r--r--clang/test/SemaCXX/default1.cpp52
-rw-r--r--clang/test/SemaCXX/default2.cpp124
-rw-r--r--clang/test/SemaCXX/defaulted-ctor-loop.cpp14
-rw-r--r--clang/test/SemaCXX/defaulted-private-dtor.cpp56
-rw-r--r--clang/test/SemaCXX/delete.cpp9
-rw-r--r--clang/test/SemaCXX/deleted-function.cpp57
-rw-r--r--clang/test/SemaCXX/deleted-operator.cpp18
-rw-r--r--clang/test/SemaCXX/dependent-auto.cpp59
-rw-r--r--clang/test/SemaCXX/dependent-noexcept-unevaluated.cpp40
-rw-r--r--clang/test/SemaCXX/dependent-types.cpp13
-rw-r--r--clang/test/SemaCXX/derived-to-base-ambig.cpp33
-rw-r--r--clang/test/SemaCXX/destructor.cpp365
-rw-r--r--clang/test/SemaCXX/direct-initializer.cpp50
-rw-r--r--clang/test/SemaCXX/discrim-union.cpp118
-rw-r--r--clang/test/SemaCXX/do-while-scope.cpp8
-rw-r--r--clang/test/SemaCXX/dr1301.cpp67
-rw-r--r--clang/test/SemaCXX/dynamic-cast.cpp74
-rw-r--r--clang/test/SemaCXX/elaborated-type-specifier.cpp48
-rw-r--r--clang/test/SemaCXX/empty-class-layout.cpp157
-rw-r--r--clang/test/SemaCXX/enum-bitfield.cpp18
-rw-r--r--clang/test/SemaCXX/enum-scoped.cpp247
-rw-r--r--clang/test/SemaCXX/enum-unscoped-nonexistent.cpp39
-rw-r--r--clang/test/SemaCXX/enum.cpp97
-rw-r--r--clang/test/SemaCXX/exception-spec-no-exceptions.cpp33
-rw-r--r--clang/test/SemaCXX/exceptions.cpp122
-rw-r--r--clang/test/SemaCXX/explicit.cpp175
-rw-r--r--clang/test/SemaCXX/expression-traits.cpp620
-rw-r--r--clang/test/SemaCXX/expressions.cpp120
-rw-r--r--clang/test/SemaCXX/flexible-array-test.cpp69
-rw-r--r--clang/test/SemaCXX/fntype-decl.cpp20
-rw-r--r--clang/test/SemaCXX/for-range-examples.cpp182
-rw-r--r--clang/test/SemaCXX/for-range-no-std.cpp43
-rw-r--r--clang/test/SemaCXX/for-range-unused.cpp21
-rw-r--r--clang/test/SemaCXX/format-strings-0x.cpp15
-rw-r--r--clang/test/SemaCXX/format-strings.cpp77
-rw-r--r--clang/test/SemaCXX/friend-class-nodecl.cpp10
-rw-r--r--clang/test/SemaCXX/friend-out-of-line.cpp12
-rw-r--r--clang/test/SemaCXX/friend.cpp140
-rw-r--r--clang/test/SemaCXX/function-extern-c.cpp38
-rw-r--r--clang/test/SemaCXX/function-overload-typo-crash.cpp28
-rw-r--r--clang/test/SemaCXX/function-overloaded-redecl.cpp10
-rw-r--r--clang/test/SemaCXX/function-redecl.cpp100
-rw-r--r--clang/test/SemaCXX/function-type-qual.cpp28
-rw-r--r--clang/test/SemaCXX/functional-cast.cpp320
-rw-r--r--clang/test/SemaCXX/generic-selection.cpp46
-rw-r--r--clang/test/SemaCXX/gnu-case-ranges.cpp24
-rw-r--r--clang/test/SemaCXX/goto.cpp127
-rw-r--r--clang/test/SemaCXX/goto2.cpp47
-rw-r--r--clang/test/SemaCXX/i-c-e-cxx.cpp68
-rw-r--r--clang/test/SemaCXX/illegal-member-initialization.cpp31
-rw-r--r--clang/test/SemaCXX/implicit-exception-spec.cpp89
-rw-r--r--clang/test/SemaCXX/implicit-int.cpp5
-rw-r--r--clang/test/SemaCXX/implicit-member-functions.cpp52
-rw-r--r--clang/test/SemaCXX/implicit-virtual-member-functions.cpp29
-rw-r--r--clang/test/SemaCXX/incomplete-call.cpp49
-rw-r--r--clang/test/SemaCXX/increment-decrement.cpp14
-rw-r--r--clang/test/SemaCXX/indirect-goto.cpp7
-rw-r--r--clang/test/SemaCXX/inherit.cpp32
-rw-r--r--clang/test/SemaCXX/init-priority-attr.cpp36
-rw-r--r--clang/test/SemaCXX/inline.cpp5
-rw-r--r--clang/test/SemaCXX/instantiate-blocks.cpp32
-rw-r--r--clang/test/SemaCXX/invalid-instantiated-field-decl.cpp35
-rw-r--r--clang/test/SemaCXX/invalid-member-expr.cpp39
-rw-r--r--clang/test/SemaCXX/invalid-template-specifier.cpp12
-rw-r--r--clang/test/SemaCXX/issue547.cpp66
-rw-r--r--clang/test/SemaCXX/lambda-expressions.cpp150
-rw-r--r--clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp33
-rw-r--r--clang/test/SemaCXX/libstdcxx_map_base_hack.cpp25
-rw-r--r--clang/test/SemaCXX/linkage-spec.cpp104
-rw-r--r--clang/test/SemaCXX/linkage.cpp96
-rw-r--r--clang/test/SemaCXX/literal-operators.cpp43
-rw-r--r--clang/test/SemaCXX/literal-type.cpp77
-rw-r--r--clang/test/SemaCXX/local-classes.cpp41
-rw-r--r--clang/test/SemaCXX/lookup-member.cpp13
-rw-r--r--clang/test/SemaCXX/member-class-11.cpp8
-rw-r--r--clang/test/SemaCXX/member-expr-anonymous-union.cpp9
-rw-r--r--clang/test/SemaCXX/member-expr-static.cpp19
-rw-r--r--clang/test/SemaCXX/member-expr.cpp159
-rw-r--r--clang/test/SemaCXX/member-init.cpp75
-rw-r--r--clang/test/SemaCXX/member-location.cpp8
-rw-r--r--clang/test/SemaCXX/member-name-lookup.cpp158
-rw-r--r--clang/test/SemaCXX/member-operator-expr.cpp29
-rw-r--r--clang/test/SemaCXX/member-pointer-ms.cpp14
-rw-r--r--clang/test/SemaCXX/member-pointer-size.cpp15
-rw-r--r--clang/test/SemaCXX/member-pointer.cpp314
-rw-r--r--clang/test/SemaCXX/member-pointers-2.cpp51
-rw-r--r--clang/test/SemaCXX/microsoft-cxx0x.cpp8
-rw-r--r--clang/test/SemaCXX/missing-header.cpp9
-rw-r--r--clang/test/SemaCXX/missing-members.cpp36
-rw-r--r--clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp121
-rw-r--r--clang/test/SemaCXX/ms-exception-spec.cpp3
-rw-r--r--clang/test/SemaCXX/namespace-alias.cpp127
-rw-r--r--clang/test/SemaCXX/namespace.cpp92
-rw-r--r--clang/test/SemaCXX/neon-vector-types.cpp27
-rw-r--r--clang/test/SemaCXX/nested-name-spec-locations.cpp162
-rw-r--r--clang/test/SemaCXX/nested-name-spec.cpp288
-rw-r--r--clang/test/SemaCXX/new-array-size-conv.cpp27
-rw-r--r--clang/test/SemaCXX/new-delete-0x.cpp32
-rw-r--r--clang/test/SemaCXX/new-delete-cxx0x.cpp26
-rw-r--r--clang/test/SemaCXX/new-delete-predefined-decl-2.cpp13
-rw-r--r--clang/test/SemaCXX/new-delete-predefined-decl.cpp19
-rw-r--r--clang/test/SemaCXX/new-delete.cpp501
-rw-r--r--clang/test/SemaCXX/no-exceptions.cpp35
-rw-r--r--clang/test/SemaCXX/no-implicit-builtin-decls.cpp7
-rw-r--r--clang/test/SemaCXX/non-empty-class-size-zero.cpp18
-rw-r--r--clang/test/SemaCXX/null_in_arithmetic_ops.cpp93
-rw-r--r--clang/test/SemaCXX/nullptr-98.cpp3
-rw-r--r--clang/test/SemaCXX/nullptr.cpp185
-rw-r--r--clang/test/SemaCXX/nullptr_in_arithmetic_ops.cpp73
-rw-r--r--clang/test/SemaCXX/offsetof.cpp75
-rw-r--r--clang/test/SemaCXX/operator-arrow-temporary.cpp19
-rw-r--r--clang/test/SemaCXX/out-of-line-def-mismatch.cpp24
-rw-r--r--clang/test/SemaCXX/overload-0x.cpp11
-rw-r--r--clang/test/SemaCXX/overload-call-copycon.cpp51
-rw-r--r--clang/test/SemaCXX/overload-call.cpp570
-rw-r--r--clang/test/SemaCXX/overload-decl.cpp31
-rw-r--r--clang/test/SemaCXX/overload-member-call.cpp98
-rw-r--r--clang/test/SemaCXX/overload-value-dep-arg.cpp13
-rw-r--r--clang/test/SemaCXX/overloaded-builtin-operators-0x.cpp11
-rw-r--r--clang/test/SemaCXX/overloaded-builtin-operators.cpp239
-rw-r--r--clang/test/SemaCXX/overloaded-name.cpp30
-rw-r--r--clang/test/SemaCXX/overloaded-operator-decl.cpp50
-rw-r--r--clang/test/SemaCXX/overloaded-operator.cpp417
-rw-r--r--clang/test/SemaCXX/pascal-strings.cpp6
-rw-r--r--clang/test/SemaCXX/pragma-pack.cpp34
-rw-r--r--clang/test/SemaCXX/pragma-unused.cpp8
-rw-r--r--clang/test/SemaCXX/pragma-visibility.cpp23
-rw-r--r--clang/test/SemaCXX/prefetch-enum.cpp9
-rw-r--r--clang/test/SemaCXX/primary-base.cpp11
-rw-r--r--clang/test/SemaCXX/pseudo-destructors.cpp82
-rw-r--r--clang/test/SemaCXX/ptrtomember-overload-resolution.cpp44
-rw-r--r--clang/test/SemaCXX/ptrtomember.cpp33
-rw-r--r--clang/test/SemaCXX/qual-id-test.cpp149
-rw-r--r--clang/test/SemaCXX/qualification-conversion.cpp34
-rw-r--r--clang/test/SemaCXX/qualified-id-lookup.cpp153
-rw-r--r--clang/test/SemaCXX/qualified-member-enum.cpp10
-rw-r--r--clang/test/SemaCXX/qualified-names-diag.cpp33
-rw-r--r--clang/test/SemaCXX/qualified-names-print.cpp15
-rw-r--r--clang/test/SemaCXX/redeclared-alias-template.cpp23
-rw-r--r--clang/test/SemaCXX/redeclared-auto.cpp26
-rw-r--r--clang/test/SemaCXX/ref-init-ambiguous.cpp28
-rw-r--r--clang/test/SemaCXX/references.cpp139
-rw-r--r--clang/test/SemaCXX/reinterpret-cast.cpp292
-rw-r--r--clang/test/SemaCXX/reinterpret-fn-obj-pedantic.cpp9
-rw-r--r--clang/test/SemaCXX/return-noreturn.cpp140
-rw-r--r--clang/test/SemaCXX/return-stack-addr.cpp141
-rw-r--r--clang/test/SemaCXX/return.cpp82
-rw-r--r--clang/test/SemaCXX/runtimediag-ppe.cpp18
-rw-r--r--clang/test/SemaCXX/rval-references-examples.cpp112
-rw-r--r--clang/test/SemaCXX/rval-references.cpp94
-rw-r--r--clang/test/SemaCXX/scope-check.cpp209
-rw-r--r--clang/test/SemaCXX/shift.cpp14
-rw-r--r--clang/test/SemaCXX/short-enums.cpp17
-rw-r--r--clang/test/SemaCXX/short-wchar-sign.cpp6
-rw-r--r--clang/test/SemaCXX/sourceranges.cpp27
-rw-r--r--clang/test/SemaCXX/statements.cpp22
-rw-r--r--clang/test/SemaCXX/static-array-member.cpp18
-rw-r--r--clang/test/SemaCXX/static-assert.cpp36
-rw-r--r--clang/test/SemaCXX/static-cast-complete-type.cpp13
-rw-r--r--clang/test/SemaCXX/static-cast.cpp197
-rw-r--r--clang/test/SemaCXX/static-initializers.cpp10
-rw-r--r--clang/test/SemaCXX/storage-class.cpp7
-rw-r--r--clang/test/SemaCXX/string-plus-int.cpp66
-rw-r--r--clang/test/SemaCXX/struct-class-redecl.cpp164
-rw-r--r--clang/test/SemaCXX/switch-0x.cpp11
-rw-r--r--clang/test/SemaCXX/switch.cpp87
-rw-r--r--clang/test/SemaCXX/tag-ambig.cpp28
-rw-r--r--clang/test/SemaCXX/templated-friend-decl.cpp15
-rw-r--r--clang/test/SemaCXX/this.cpp6
-rw-r--r--clang/test/SemaCXX/trailing-return-0x.cpp71
-rw-r--r--clang/test/SemaCXX/trivial-constructor.cpp38
-rw-r--r--clang/test/SemaCXX/trivial-destructor.cpp38
-rw-r--r--clang/test/SemaCXX/type-convert-construct.cpp17
-rw-r--r--clang/test/SemaCXX/type-definition-in-specifier.cpp25
-rw-r--r--clang/test/SemaCXX/type-dependent-exprs.cpp35
-rw-r--r--clang/test/SemaCXX/type-formatting.cpp10
-rw-r--r--clang/test/SemaCXX/type-traits-incomplete.cpp8
-rw-r--r--clang/test/SemaCXX/type-traits.cpp1818
-rw-r--r--clang/test/SemaCXX/typedef-redecl.cpp95
-rw-r--r--clang/test/SemaCXX/typeid-ref.cpp12
-rw-r--r--clang/test/SemaCXX/typeid.cpp23
-rw-r--r--clang/test/SemaCXX/types_compatible_p.cpp5
-rw-r--r--clang/test/SemaCXX/typo-correction.cpp192
-rw-r--r--clang/test/SemaCXX/unary-real-imag.cpp6
-rw-r--r--clang/test/SemaCXX/undefined-internal.cpp183
-rw-r--r--clang/test/SemaCXX/underlying_type.cpp43
-rw-r--r--clang/test/SemaCXX/uninit-variables-conditional.cpp23
-rw-r--r--clang/test/SemaCXX/uninit-variables.cpp143
-rw-r--r--clang/test/SemaCXX/uninitialized.cpp169
-rw-r--r--clang/test/SemaCXX/unknown-anytype-blocks.cpp11
-rw-r--r--clang/test/SemaCXX/unknown-anytype.cpp47
-rw-r--r--clang/test/SemaCXX/unknown-type-name.cpp29
-rw-r--r--clang/test/SemaCXX/unreachable-catch-clauses.cpp14
-rw-r--r--clang/test/SemaCXX/unreachable-code.cpp58
-rw-r--r--clang/test/SemaCXX/unused-functions.cpp10
-rw-r--r--clang/test/SemaCXX/unused-with-error.cpp8
-rw-r--r--clang/test/SemaCXX/unused.cpp24
-rw-r--r--clang/test/SemaCXX/user-defined-conversions.cpp99
-rw-r--r--clang/test/SemaCXX/using-decl-1.cpp120
-rw-r--r--clang/test/SemaCXX/using-decl-pr4441.cpp8
-rw-r--r--clang/test/SemaCXX/using-decl-pr4450.cpp15
-rw-r--r--clang/test/SemaCXX/using-decl-templates.cpp82
-rw-r--r--clang/test/SemaCXX/using-directive.cpp135
-rw-r--r--clang/test/SemaCXX/value-dependent-exprs.cpp47
-rw-r--r--clang/test/SemaCXX/value-initialization.cpp10
-rw-r--r--clang/test/SemaCXX/vararg-default-arg.cpp10
-rw-r--r--clang/test/SemaCXX/vararg-non-pod.cpp125
-rw-r--r--clang/test/SemaCXX/vector-casts.cpp40
-rw-r--r--clang/test/SemaCXX/vector-no-lax.cpp9
-rw-r--r--clang/test/SemaCXX/vector.cpp269
-rw-r--r--clang/test/SemaCXX/virtual-base-used.cpp42
-rw-r--r--clang/test/SemaCXX/virtual-member-functions-key-function.cpp29
-rw-r--r--clang/test/SemaCXX/virtual-override.cpp290
-rw-r--r--clang/test/SemaCXX/virtuals.cpp47
-rw-r--r--clang/test/SemaCXX/vla.cpp5
-rw-r--r--clang/test/SemaCXX/vtable-instantiation.cc68
-rw-r--r--clang/test/SemaCXX/warn-assignment-condition.cpp146
-rw-r--r--clang/test/SemaCXX/warn-bad-memaccess.cpp117
-rw-r--r--clang/test/SemaCXX/warn-bool-conversion.cpp24
-rw-r--r--clang/test/SemaCXX/warn-cast-align.cpp45
-rw-r--r--clang/test/SemaCXX/warn-char-subscripts.cpp21
-rw-r--r--clang/test/SemaCXX/warn-dangling-field.cpp37
-rw-r--r--clang/test/SemaCXX/warn-deprecated-header.cpp6
-rw-r--r--clang/test/SemaCXX/warn-empty-body.cpp271
-rw-r--r--clang/test/SemaCXX/warn-enum-compare.cpp212
-rw-r--r--clang/test/SemaCXX/warn-everthing.cpp13
-rw-r--r--clang/test/SemaCXX/warn-exit-time-destructors.cpp27
-rw-r--r--clang/test/SemaCXX/warn-func-as-bool.cpp40
-rw-r--r--clang/test/SemaCXX/warn-global-constructors.cpp97
-rw-r--r--clang/test/SemaCXX/warn-large-by-value-copy.cpp47
-rw-r--r--clang/test/SemaCXX/warn-literal-conversion.cpp40
-rw-r--r--clang/test/SemaCXX/warn-memset-bad-sizeof.cpp145
-rw-r--r--clang/test/SemaCXX/warn-missing-noreturn.cpp125
-rw-r--r--clang/test/SemaCXX/warn-missing-prototypes.cpp32
-rw-r--r--clang/test/SemaCXX/warn-new-overaligned-2.cpp22
-rw-r--r--clang/test/SemaCXX/warn-new-overaligned-3.cpp33
-rw-r--r--clang/test/SemaCXX/warn-new-overaligned.cpp73
-rw-r--r--clang/test/SemaCXX/warn-overloaded-virtual.cpp66
-rw-r--r--clang/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp14
-rw-r--r--clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp132
-rw-r--r--clang/test/SemaCXX/warn-self-assign.cpp47
-rw-r--r--clang/test/SemaCXX/warn-self-comparisons.cpp5
-rw-r--r--clang/test/SemaCXX/warn-shadow.cpp83
-rw-r--r--clang/test/SemaCXX/warn-sign-conversion.cpp80
-rw-r--r--clang/test/SemaCXX/warn-string-conversion.cpp18
-rw-r--r--clang/test/SemaCXX/warn-thread-safety-analysis.cpp2243
-rw-r--r--clang/test/SemaCXX/warn-thread-safety-parsing.cpp1345
-rw-r--r--clang/test/SemaCXX/warn-unreachable.cpp109
-rw-r--r--clang/test/SemaCXX/warn-unused-comparison.cpp94
-rw-r--r--clang/test/SemaCXX/warn-unused-filescoped.cpp89
-rw-r--r--clang/test/SemaCXX/warn-unused-parameters.cpp34
-rw-r--r--clang/test/SemaCXX/warn-unused-result.cpp44
-rw-r--r--clang/test/SemaCXX/warn-unused-value.cpp51
-rw-r--r--clang/test/SemaCXX/warn-unused-variables.cpp124
-rw-r--r--clang/test/SemaCXX/warn-using-namespace-in-header.cpp54
-rw-r--r--clang/test/SemaCXX/warn-using-namespace-in-header.h50
-rw-r--r--clang/test/SemaCXX/warn-weak-vtables.cpp78
-rw-r--r--clang/test/SemaCXX/wchar_t.cpp32
-rw-r--r--clang/test/SemaCXX/writable-strings-deprecated.cpp14
-rw-r--r--clang/test/SemaCXX/zero-length-arrays.cpp26
-rw-r--r--clang/test/SemaObjC/ClassPropertyNotObject.m15
-rw-r--r--clang/test/SemaObjC/ContClassPropertyLookup.m38
-rw-r--r--clang/test/SemaObjC/DoubleMethod.m19
-rw-r--r--clang/test/SemaObjC/Inputs/arc-system-header.h52
-rw-r--r--clang/test/SemaObjC/NSString-type.m10
-rw-r--r--clang/test/SemaObjC/access-property-getter.m36
-rw-r--r--clang/test/SemaObjC/alias-test-1.m31
-rw-r--r--clang/test/SemaObjC/alias-test-2.m17
-rw-r--r--clang/test/SemaObjC/arc-bridged-cast.m44
-rw-r--r--clang/test/SemaObjC/arc-cf.m45
-rw-r--r--clang/test/SemaObjC/arc-decls.m99
-rw-r--r--clang/test/SemaObjC/arc-invalid.m18
-rw-r--r--clang/test/SemaObjC/arc-jump-block.m97
-rw-r--r--clang/test/SemaObjC/arc-no-runtime.m16
-rw-r--r--clang/test/SemaObjC/arc-non-pod-memaccess.m63
-rw-r--r--clang/test/SemaObjC/arc-nsconsumed-errors.m20
-rw-r--r--clang/test/SemaObjC/arc-objc-lifetime.m42
-rw-r--r--clang/test/SemaObjC/arc-peformselector.m38
-rw-r--r--clang/test/SemaObjC/arc-property-decl-attrs.m81
-rw-r--r--clang/test/SemaObjC/arc-property-lifetime.m170
-rw-r--r--clang/test/SemaObjC/arc-property.m57
-rw-r--r--clang/test/SemaObjC/arc-readonly-property-ivar-1.m29
-rw-r--r--clang/test/SemaObjC/arc-readonly-property-ivar.m16
-rw-r--r--clang/test/SemaObjC/arc-retain-block-property.m30
-rw-r--r--clang/test/SemaObjC/arc-setter-property-match.m35
-rw-r--r--clang/test/SemaObjC/arc-system-header.m50
-rw-r--r--clang/test/SemaObjC/arc-type-conversion.m98
-rw-r--r--clang/test/SemaObjC/arc-unavailable-for-weakref.m64
-rw-r--r--clang/test/SemaObjC/arc-unavailable-system-function.m13
-rw-r--r--clang/test/SemaObjC/arc-unbridged-cast.m123
-rw-r--r--clang/test/SemaObjC/arc-unsafe-assigns.m41
-rw-r--r--clang/test/SemaObjC/arc-unsafe_unretained.m12
-rw-r--r--clang/test/SemaObjC/arc.m698
-rw-r--r--clang/test/SemaObjC/argument-checking.m26
-rw-r--r--clang/test/SemaObjC/assign-rvalue-message.m24
-rw-r--r--clang/test/SemaObjC/at-defs.m29
-rw-r--r--clang/test/SemaObjC/atomoic-property-synnthesis-rules.m377
-rw-r--r--clang/test/SemaObjC/attr-availability.m13
-rw-r--r--clang/test/SemaObjC/attr-cleanup.m10
-rw-r--r--clang/test/SemaObjC/attr-deprecated.m123
-rw-r--r--clang/test/SemaObjC/attr-malloc.m16
-rw-r--r--clang/test/SemaObjC/attr-ns-bridged.m15
-rw-r--r--clang/test/SemaObjC/attr-objc-exception.m16
-rw-r--r--clang/test/SemaObjC/attr-objc-gc.m30
-rw-r--r--clang/test/SemaObjC/attr-root-class.m16
-rw-r--r--clang/test/SemaObjC/autoreleasepool.m22
-rw-r--r--clang/test/SemaObjC/bad-property-synthesis-crash.m23
-rw-r--r--clang/test/SemaObjC/bad-receiver-1.m21
-rw-r--r--clang/test/SemaObjC/block-as-object.m20
-rw-r--r--clang/test/SemaObjC/block-attr.m12
-rw-r--r--clang/test/SemaObjC/block-explicit-return-type.m77
-rw-r--r--clang/test/SemaObjC/block-id-as-block-argtype.m27
-rw-r--r--clang/test/SemaObjC/block-ivar.m19
-rw-r--r--clang/test/SemaObjC/block-on-method-param.m12
-rw-r--r--clang/test/SemaObjC/block-return.m13
-rw-r--r--clang/test/SemaObjC/block-type-safety.m157
-rw-r--r--clang/test/SemaObjC/blocks.m75
-rw-r--r--clang/test/SemaObjC/builtin_objc_assign_ivar.m6
-rw-r--r--clang/test/SemaObjC/builtin_objc_lib_functions.m29
-rw-r--r--clang/test/SemaObjC/builtin_objc_msgSend.m3
-rw-r--r--clang/test/SemaObjC/builtin_objc_nslog.m13
-rw-r--r--clang/test/SemaObjC/call-super-2.m108
-rw-r--r--clang/test/SemaObjC/catch-stmt.m13
-rw-r--r--clang/test/SemaObjC/category-1.m101
-rw-r--r--clang/test/SemaObjC/category-method-lookup-2.m23
-rw-r--r--clang/test/SemaObjC/category-method-lookup.m31
-rw-r--r--clang/test/SemaObjC/check-dup-decl-methods-1.m38
-rw-r--r--clang/test/SemaObjC/check-dup-objc-decls-1.m44
-rw-r--r--clang/test/SemaObjC/class-bitfield.m37
-rw-r--r--clang/test/SemaObjC/class-conforming-protocol-1.m20
-rw-r--r--clang/test/SemaObjC/class-conforming-protocol-2.m23
-rw-r--r--clang/test/SemaObjC/class-def-test-1.m35
-rw-r--r--clang/test/SemaObjC/class-extension-after-implementation.m11
-rw-r--r--clang/test/SemaObjC/class-extension-dup-methods.m15
-rw-r--r--clang/test/SemaObjC/class-getter-using-dotsyntax.m39
-rw-r--r--clang/test/SemaObjC/class-impl-1.m40
-rw-r--r--clang/test/SemaObjC/class-message-protocol-lookup.m34
-rw-r--r--clang/test/SemaObjC/class-method-lookup.m46
-rw-r--r--clang/test/SemaObjC/class-method-self.m26
-rw-r--r--clang/test/SemaObjC/class-property-access.m12
-rw-r--r--clang/test/SemaObjC/class-proto-1.m36
-rw-r--r--clang/test/SemaObjC/class-protocol-method-match.m48
-rw-r--r--clang/test/SemaObjC/class-protocol.m6
-rw-r--r--clang/test/SemaObjC/class-unavail-warning.m42
-rw-r--r--clang/test/SemaObjC/cocoa-api-usage.m88
-rw-r--r--clang/test/SemaObjC/cocoa-api-usage.m.fixed88
-rw-r--r--clang/test/SemaObjC/cocoa.m5
-rw-r--r--clang/test/SemaObjC/compare-qualified-class.m30
-rw-r--r--clang/test/SemaObjC/compare-qualified-id.m34
-rw-r--r--clang/test/SemaObjC/compatible-protocol-qualified-types.m76
-rw-r--r--clang/test/SemaObjC/compound-init.m7
-rw-r--r--clang/test/SemaObjC/comptypes-1.m89
-rw-r--r--clang/test/SemaObjC/comptypes-10.m52
-rw-r--r--clang/test/SemaObjC/comptypes-2.m37
-rw-r--r--clang/test/SemaObjC/comptypes-3.m64
-rw-r--r--clang/test/SemaObjC/comptypes-4.m25
-rw-r--r--clang/test/SemaObjC/comptypes-5.m44
-rw-r--r--clang/test/SemaObjC/comptypes-6.m16
-rw-r--r--clang/test/SemaObjC/comptypes-7.m75
-rw-r--r--clang/test/SemaObjC/comptypes-8.m12
-rw-r--r--clang/test/SemaObjC/comptypes-9.m86
-rw-r--r--clang/test/SemaObjC/comptypes-a.m34
-rw-r--r--clang/test/SemaObjC/comptypes-legal.m37
-rw-r--r--clang/test/SemaObjC/conditional-expr-2.m29
-rw-r--r--clang/test/SemaObjC/conditional-expr-3.m67
-rw-r--r--clang/test/SemaObjC/conditional-expr-4.m80
-rw-r--r--clang/test/SemaObjC/conditional-expr-5.m27
-rw-r--r--clang/test/SemaObjC/conditional-expr-6.m51
-rw-r--r--clang/test/SemaObjC/conditional-expr-7.m30
-rw-r--r--clang/test/SemaObjC/conditional-expr-8.m25
-rw-r--r--clang/test/SemaObjC/conditional-expr.m119
-rw-r--r--clang/test/SemaObjC/conflict-atomic-property.m10
-rw-r--r--clang/test/SemaObjC/conflict-nonfragile-abi2.m36
-rw-r--r--clang/test/SemaObjC/conflicting-ivar-test-1.m86
-rw-r--r--clang/test/SemaObjC/continuation-class-err.m51
-rw-r--r--clang/test/SemaObjC/continuation-class-property.m63
-rw-r--r--clang/test/SemaObjC/crash-label.m9
-rw-r--r--clang/test/SemaObjC/custom-atomic-property.m20
-rw-r--r--clang/test/SemaObjC/debugger-cast-result-to-id.m16
-rw-r--r--clang/test/SemaObjC/debugger-support.m14
-rw-r--r--clang/test/SemaObjC/default-synthesize-1.m116
-rw-r--r--clang/test/SemaObjC/default-synthesize-2.m116
-rw-r--r--clang/test/SemaObjC/default-synthesize-3.m41
-rw-r--r--clang/test/SemaObjC/default-synthesize.m140
-rw-r--r--clang/test/SemaObjC/deref-interface.m12
-rw-r--r--clang/test/SemaObjC/direct-synthesized-ivar-access.m15
-rw-r--r--clang/test/SemaObjC/dist-object-modifiers.m21
-rw-r--r--clang/test/SemaObjC/duplicate-ivar-check.m22
-rw-r--r--clang/test/SemaObjC/duplicate-ivar-in-class-extension.m32
-rw-r--r--clang/test/SemaObjC/duplicate-property-class-extension.m24
-rw-r--r--clang/test/SemaObjC/duplicate-property.m8
-rw-r--r--clang/test/SemaObjC/enhanced-proto-2.m21
-rw-r--r--clang/test/SemaObjC/enum-fixed-type.m37
-rw-r--r--clang/test/SemaObjC/err-ivar-access-in-class-method.m26
-rw-r--r--clang/test/SemaObjC/error-implicit-property.m30
-rw-r--r--clang/test/SemaObjC/error-missing-getter.m19
-rw-r--r--clang/test/SemaObjC/error-property-gc-attr.m28
-rw-r--r--clang/test/SemaObjC/exprs.m44
-rw-r--r--clang/test/SemaObjC/foreach.m57
-rw-r--r--clang/test/SemaObjC/format-arg-attribute.m27
-rw-r--r--clang/test/SemaObjC/format-strings-objc.m188
-rw-r--r--clang/test/SemaObjC/forward-class-1.m58
-rw-r--r--clang/test/SemaObjC/forward-class-receiver.m13
-rw-r--r--clang/test/SemaObjC/forward-class-redeclare.m29
-rw-r--r--clang/test/SemaObjC/gc-attributes.m22
-rw-r--r--clang/test/SemaObjC/gcc-cast-ext.m24
-rw-r--r--clang/test/SemaObjC/ibaction.m17
-rw-r--r--clang/test/SemaObjC/iboutletcollection-attr.m43
-rw-r--r--clang/test/SemaObjC/id-isa-ref.m35
-rw-r--r--clang/test/SemaObjC/id.m21
-rw-r--r--clang/test/SemaObjC/id_builtin.m10
-rw-r--r--clang/test/SemaObjC/idiomatic-parentheses.m35
-rw-r--r--clang/test/SemaObjC/ignore-qualifier-on-qualified-id.m21
-rw-r--r--clang/test/SemaObjC/ignore-weakimport-method.m6
-rw-r--r--clang/test/SemaObjC/illegal-nonarc-bridged-cast.m44
-rw-r--r--clang/test/SemaObjC/incompatible-protocol-qualified-types.m40
-rw-r--r--clang/test/SemaObjC/incomplete-implementation.m40
-rw-r--r--clang/test/SemaObjC/inst-method-lookup-in-root.m27
-rw-r--r--clang/test/SemaObjC/instancetype.m190
-rw-r--r--clang/test/SemaObjC/interface-1.m38
-rw-r--r--clang/test/SemaObjC/interface-layout-2.m16
-rw-r--r--clang/test/SemaObjC/interface-layout.m27
-rw-r--r--clang/test/SemaObjC/interface-scope-2.m128
-rw-r--r--clang/test/SemaObjC/interface-scope.m12
-rw-r--r--clang/test/SemaObjC/interface-tu-variable.m26
-rw-r--r--clang/test/SemaObjC/invalid-code.m54
-rw-r--r--clang/test/SemaObjC/invalid-objc-decls-1.m42
-rw-r--r--clang/test/SemaObjC/invalid-receiver.m9
-rw-r--r--clang/test/SemaObjC/invalid-typename.m12
-rw-r--r--clang/test/SemaObjC/ivar-access-package.m47
-rw-r--r--clang/test/SemaObjC/ivar-access-tests.m122
-rw-r--r--clang/test/SemaObjC/ivar-in-class-extension-error.m15
-rw-r--r--clang/test/SemaObjC/ivar-in-class-extension.m42
-rw-r--r--clang/test/SemaObjC/ivar-in-implementations.m39
-rw-r--r--clang/test/SemaObjC/ivar-lookup-resolution-builtin.m40
-rw-r--r--clang/test/SemaObjC/ivar-lookup.m82
-rw-r--r--clang/test/SemaObjC/ivar-ref-misuse.m42
-rw-r--r--clang/test/SemaObjC/ivar-sem-check-1.m19
-rw-r--r--clang/test/SemaObjC/ivar-sem-check-2.m23
-rw-r--r--clang/test/SemaObjC/legacy-implementation-1.m11
-rw-r--r--clang/test/SemaObjC/message.m100
-rw-r--r--clang/test/SemaObjC/method-arg-qualifier-warning.m20
-rw-r--r--clang/test/SemaObjC/method-attributes.m57
-rw-r--r--clang/test/SemaObjC/method-bad-param.m44
-rw-r--r--clang/test/SemaObjC/method-conflict-1.m83
-rw-r--r--clang/test/SemaObjC/method-conflict-2.m44
-rw-r--r--clang/test/SemaObjC/method-conflict.m66
-rw-r--r--clang/test/SemaObjC/method-def-1.m40
-rw-r--r--clang/test/SemaObjC/method-def-2.m19
-rw-r--r--clang/test/SemaObjC/method-encoding-2.m12
-rw-r--r--clang/test/SemaObjC/method-in-class-extension-impl.m20
-rw-r--r--clang/test/SemaObjC/method-lookup-2.m63
-rw-r--r--clang/test/SemaObjC/method-lookup-3.m73
-rw-r--r--clang/test/SemaObjC/method-lookup-4.m62
-rw-r--r--clang/test/SemaObjC/method-lookup-5.m10
-rw-r--r--clang/test/SemaObjC/method-lookup.m35
-rw-r--r--clang/test/SemaObjC/method-no-context.m4
-rw-r--r--clang/test/SemaObjC/method-not-defined.m13
-rw-r--r--clang/test/SemaObjC/method-prototype-scope.m38
-rw-r--r--clang/test/SemaObjC/method-sentinel-attr.m49
-rw-r--r--clang/test/SemaObjC/method-typecheck-1.m36
-rw-r--r--clang/test/SemaObjC/method-typecheck-2.m25
-rw-r--r--clang/test/SemaObjC/method-typecheck-3.m22
-rw-r--r--clang/test/SemaObjC/method-undef-category-warn-1.m74
-rw-r--r--clang/test/SemaObjC/method-undef-extension-warn-1.m24
-rw-r--r--clang/test/SemaObjC/method-undefined-warn-1.m56
-rw-r--r--clang/test/SemaObjC/method-unused-attribute.m15
-rw-r--r--clang/test/SemaObjC/method-warn-unused-attribute.m16
-rw-r--r--clang/test/SemaObjC/missing-atend-metadata.m22
-rw-r--r--clang/test/SemaObjC/missing-method-context.m4
-rw-r--r--clang/test/SemaObjC/missing-method-return-type.m11
-rw-r--r--clang/test/SemaObjC/narrow-property-type-in-cont-class.m19
-rw-r--r--clang/test/SemaObjC/nested-typedef-decl.m21
-rw-r--r--clang/test/SemaObjC/newproperty-class-method-1.m62
-rw-r--r--clang/test/SemaObjC/no-gc-weak-test.m28
-rw-r--r--clang/test/SemaObjC/no-ivar-access-control.m70
-rw-r--r--clang/test/SemaObjC/no-objc-exceptions.m13
-rw-r--r--clang/test/SemaObjC/no-protocol-option-tests.m32
-rw-r--r--clang/test/SemaObjC/no-warn-qual-mismatch.m16
-rw-r--r--clang/test/SemaObjC/no-warn-synth-protocol-meth.m17
-rw-r--r--clang/test/SemaObjC/no-warn-unimpl-method.m42
-rw-r--r--clang/test/SemaObjC/no-warning-unavail-unimp.m12
-rw-r--r--clang/test/SemaObjC/nonnull.h2
-rw-r--r--clang/test/SemaObjC/nonnull.m96
-rw-r--r--clang/test/SemaObjC/nsobject-attribute-1.m48
-rw-r--r--clang/test/SemaObjC/nsobject-attribute.m54
-rw-r--r--clang/test/SemaObjC/objc-array-literal.m41
-rw-r--r--clang/test/SemaObjC/objc-buffered-methods.m25
-rw-r--r--clang/test/SemaObjC/objc-container-subscripting-1.m23
-rw-r--r--clang/test/SemaObjC/objc-container-subscripting-2.m30
-rw-r--r--clang/test/SemaObjC/objc-container-subscripting-3.m25
-rw-r--r--clang/test/SemaObjC/objc-container-subscripting.m42
-rw-r--r--clang/test/SemaObjC/objc-cstyle-args-in-methods.m20
-rw-r--r--clang/test/SemaObjC/objc-dictionary-literal.m34
-rw-r--r--clang/test/SemaObjC/objc-literal-nsnumber.m85
-rw-r--r--clang/test/SemaObjC/objc-literal-sig.m40
-rw-r--r--clang/test/SemaObjC/objc-qualified-property-lookup.m21
-rw-r--r--clang/test/SemaObjC/objc-string-constant.m39
-rw-r--r--clang/test/SemaObjC/objc2-merge-gc-attribue-decl.m29
-rw-r--r--clang/test/SemaObjC/objc2-warn-weak-decl.m11
-rw-r--r--clang/test/SemaObjC/pedantic-dynamic-test.m16
-rw-r--r--clang/test/SemaObjC/pragma-pack.m16
-rw-r--r--clang/test/SemaObjC/property-10.m48
-rw-r--r--clang/test/SemaObjC/property-11.m36
-rw-r--r--clang/test/SemaObjC/property-12.m32
-rw-r--r--clang/test/SemaObjC/property-13.m78
-rw-r--r--clang/test/SemaObjC/property-2.m63
-rw-r--r--clang/test/SemaObjC/property-3.m14
-rw-r--r--clang/test/SemaObjC/property-4.m29
-rw-r--r--clang/test/SemaObjC/property-5.m34
-rw-r--r--clang/test/SemaObjC/property-6.m69
-rw-r--r--clang/test/SemaObjC/property-7.m34
-rw-r--r--clang/test/SemaObjC/property-8.m74
-rw-r--r--clang/test/SemaObjC/property-9-impl-method.m95
-rw-r--r--clang/test/SemaObjC/property-9.m108
-rw-r--r--clang/test/SemaObjC/property-and-class-extension.m36
-rw-r--r--clang/test/SemaObjC/property-and-ivar-use.m36
-rw-r--r--clang/test/SemaObjC/property-category-1.m53
-rw-r--r--clang/test/SemaObjC/property-category-2.m20
-rw-r--r--clang/test/SemaObjC/property-category-3.m31
-rw-r--r--clang/test/SemaObjC/property-category-4.m18
-rw-r--r--clang/test/SemaObjC/property-category-impl.m31
-rw-r--r--clang/test/SemaObjC/property-dot-receiver.m22
-rw-r--r--clang/test/SemaObjC/property-error-readonly-assign.m44
-rw-r--r--clang/test/SemaObjC/property-expression-error.m23
-rw-r--r--clang/test/SemaObjC/property-impl-misuse.m36
-rw-r--r--clang/test/SemaObjC/property-in-class-extension.m50
-rw-r--r--clang/test/SemaObjC/property-inherited.m46
-rw-r--r--clang/test/SemaObjC/property-ivar-mismatch.m14
-rw-r--r--clang/test/SemaObjC/property-lookup-in-id.m33
-rw-r--r--clang/test/SemaObjC/property-method-lookup-impl.m24
-rw-r--r--clang/test/SemaObjC/property-missing.m34
-rw-r--r--clang/test/SemaObjC/property-nonfragile-abi.m21
-rw-r--r--clang/test/SemaObjC/property-noprotocol-warning.m36
-rw-r--r--clang/test/SemaObjC/property-not-lvalue.m34
-rw-r--r--clang/test/SemaObjC/property-ns-returns-not-retained-attr.m21
-rw-r--r--clang/test/SemaObjC/property-redundant-decl-accessor.m18
-rw-r--r--clang/test/SemaObjC/property-typecheck-1.m101
-rw-r--r--clang/test/SemaObjC/property-user-setter.m104
-rw-r--r--clang/test/SemaObjC/property-weak.m5
-rw-r--r--clang/test/SemaObjC/property.m83
-rw-r--r--clang/test/SemaObjC/props-on-prots.m65
-rw-r--r--clang/test/SemaObjC/protocol-archane.m42
-rw-r--r--clang/test/SemaObjC/protocol-attribute.m49
-rw-r--r--clang/test/SemaObjC/protocol-expr-1.m15
-rw-r--r--clang/test/SemaObjC/protocol-expr-neg-1.m19
-rw-r--r--clang/test/SemaObjC/protocol-id-test-1.m16
-rw-r--r--clang/test/SemaObjC/protocol-id-test-2.m12
-rw-r--r--clang/test/SemaObjC/protocol-id-test-3.m94
-rw-r--r--clang/test/SemaObjC/protocol-implementation-inherited.m56
-rw-r--r--clang/test/SemaObjC/protocol-implementing-class-methods.m41
-rw-r--r--clang/test/SemaObjC/protocol-lookup-2.m33
-rw-r--r--clang/test/SemaObjC/protocol-lookup.m51
-rw-r--r--clang/test/SemaObjC/protocol-qualified-class-unsupported.m40
-rw-r--r--clang/test/SemaObjC/protocol-typecheck.m25
-rw-r--r--clang/test/SemaObjC/protocol-warn.m55
-rw-r--r--clang/test/SemaObjC/protocols.m67
-rw-r--r--clang/test/SemaObjC/provisional-ivar-lookup.m43
-rw-r--r--clang/test/SemaObjC/qualified-protocol-method-conflicts.m39
-rw-r--r--clang/test/SemaObjC/rdar6248119.m27
-rw-r--r--clang/test/SemaObjC/rdr-6211479-array-property.m8
-rw-r--r--clang/test/SemaObjC/receiver-forward-class.m19
-rw-r--r--clang/test/SemaObjC/related-result-type-inference.m180
-rw-r--r--clang/test/SemaObjC/restrict-id-type.m9
-rw-r--r--clang/test/SemaObjC/return.m50
-rw-r--r--clang/test/SemaObjC/scope-check.m103
-rw-r--r--clang/test/SemaObjC/selector-1.m28
-rw-r--r--clang/test/SemaObjC/selector-2.m14
-rw-r--r--clang/test/SemaObjC/selector-3.m54
-rw-r--r--clang/test/SemaObjC/selector-error.m20
-rw-r--r--clang/test/SemaObjC/selector-overload.m47
-rw-r--r--clang/test/SemaObjC/self-assign.m14
-rw-r--r--clang/test/SemaObjC/self-declared-in-block.m52
-rw-r--r--clang/test/SemaObjC/self-in-function.m26
-rw-r--r--clang/test/SemaObjC/setter-dotsyntax.m19
-rw-r--r--clang/test/SemaObjC/severe-syntax-error.m23
-rw-r--r--clang/test/SemaObjC/sizeof-interface.m90
-rw-r--r--clang/test/SemaObjC/special-dep-unavail-warning.m55
-rw-r--r--clang/test/SemaObjC/stand-alone-implementation.m12
-rw-r--r--clang/test/SemaObjC/static-ivar-ref-1.m30
-rw-r--r--clang/test/SemaObjC/stmts.m18
-rw-r--r--clang/test/SemaObjC/string.m15
-rw-r--r--clang/test/SemaObjC/super-cat-prot.m50
-rw-r--r--clang/test/SemaObjC/super-class-protocol-conformance.m63
-rw-r--r--clang/test/SemaObjC/super-property-message-expr.m21
-rw-r--r--clang/test/SemaObjC/super-property-notation.m30
-rw-r--r--clang/test/SemaObjC/super.m87
-rw-r--r--clang/test/SemaObjC/synchronized.m23
-rw-r--r--clang/test/SemaObjC/synth-provisional-ivars-1.m28
-rw-r--r--clang/test/SemaObjC/synth-provisional-ivars.m50
-rw-r--r--clang/test/SemaObjC/synthesize-setter-contclass.m24
-rw-r--r--clang/test/SemaObjC/synthesized-ivar.m61
-rw-r--r--clang/test/SemaObjC/transparent-union.m22
-rw-r--r--clang/test/SemaObjC/try-catch.m47
-rw-r--r--clang/test/SemaObjC/typedef-class.m78
-rw-r--r--clang/test/SemaObjC/ucn-objc-string.m13
-rw-r--r--clang/test/SemaObjC/undeclared-selector.m45
-rw-r--r--clang/test/SemaObjC/undef-class-messagin-error.m13
-rw-r--r--clang/test/SemaObjC/undef-protocol-methods-1.m37
-rw-r--r--clang/test/SemaObjC/undef-superclass-1.m36
-rw-r--r--clang/test/SemaObjC/undefined-protocol-type-1.m9
-rw-r--r--clang/test/SemaObjC/unimplemented-protocol-prop.m39
-rw-r--r--clang/test/SemaObjC/uninit-variables.m27
-rw-r--r--clang/test/SemaObjC/unknown-anytype.m29
-rw-r--r--clang/test/SemaObjC/unqualified-to-qualified-class-warn.m72
-rw-r--r--clang/test/SemaObjC/unused.m53
-rw-r--r--clang/test/SemaObjC/va-method-1.m17
-rw-r--r--clang/test/SemaObjC/warn-assign-property-nscopying.m16
-rw-r--r--clang/test/SemaObjC/warn-deprecated-implementations.m46
-rw-r--r--clang/test/SemaObjC/warn-forward-class-attr-deprecated.m24
-rw-r--r--clang/test/SemaObjC/warn-implicit-atomic-property.m13
-rw-r--r--clang/test/SemaObjC/warn-incompatible-builtin-types.m42
-rw-r--r--clang/test/SemaObjC/warn-missing-super.m58
-rw-r--r--clang/test/SemaObjC/warn-retain-cycle.m125
-rw-r--r--clang/test/SemaObjC/warn-selector-selection.m14
-rw-r--r--clang/test/SemaObjC/warn-strict-selector-match.m75
-rw-r--r--clang/test/SemaObjC/warn-superclass-method-mismatch.m50
-rw-r--r--clang/test/SemaObjC/warn-unreachable.m17
-rw-r--r--clang/test/SemaObjC/warn-unused-exception-param.m4
-rw-r--r--clang/test/SemaObjC/warn-weak-field.m25
-rw-r--r--clang/test/SemaObjC/warn-write-strings.m4
-rw-r--r--clang/test/SemaObjC/weak-attr-ivar.m84
-rw-r--r--clang/test/SemaObjC/weak-property.m24
-rw-r--r--clang/test/SemaObjC/weak-receiver-warn.m19
-rw-r--r--clang/test/SemaObjC/writable-property-in-superclass.m17
-rw-r--r--clang/test/SemaObjCXX/Inputs/arc-system-header.h14
-rw-r--r--clang/test/SemaObjCXX/NSString-type.mm10
-rw-r--r--clang/test/SemaObjCXX/arc-0x.mm53
-rw-r--r--clang/test/SemaObjCXX/arc-bool-conversion.mm7
-rw-r--r--clang/test/SemaObjCXX/arc-bridged-cast.mm36
-rw-r--r--clang/test/SemaObjCXX/arc-libstdcxx.mm10
-rw-r--r--clang/test/SemaObjCXX/arc-memfunc.mm15
-rw-r--r--clang/test/SemaObjCXX/arc-non-pod.mm116
-rw-r--r--clang/test/SemaObjCXX/arc-nsconsumed-errors.mm20
-rw-r--r--clang/test/SemaObjCXX/arc-object-init-destroy.mm52
-rw-r--r--clang/test/SemaObjCXX/arc-overloading.mm202
-rw-r--r--clang/test/SemaObjCXX/arc-ppe.mm16
-rw-r--r--clang/test/SemaObjCXX/arc-system-header.mm10
-rw-r--r--clang/test/SemaObjCXX/arc-templates.mm268
-rw-r--r--clang/test/SemaObjCXX/arc-type-conversion.mm218
-rw-r--r--clang/test/SemaObjCXX/arc-type-traits.mm90
-rw-r--r--clang/test/SemaObjCXX/arc-unavailable-for-weakref.mm50
-rw-r--r--clang/test/SemaObjCXX/arc-unbridged-cast.mm110
-rw-r--r--clang/test/SemaObjCXX/argument-dependent-lookup.mm19
-rw-r--r--clang/test/SemaObjCXX/blocks.mm146
-rw-r--r--clang/test/SemaObjCXX/category-lookup.mm10
-rw-r--r--clang/test/SemaObjCXX/composite-objc-pointertype.mm18
-rw-r--r--clang/test/SemaObjCXX/conditional-expr.mm67
-rw-r--r--clang/test/SemaObjCXX/const-cast.mm13
-rw-r--r--clang/test/SemaObjCXX/conversion-ranking.mm89
-rw-r--r--clang/test/SemaObjCXX/conversion-to-objc-pointer-2.mm88
-rw-r--r--clang/test/SemaObjCXX/conversion-to-objc-pointer.mm50
-rw-r--r--clang/test/SemaObjCXX/cstyle-block-pointer-cast.mm42
-rw-r--r--clang/test/SemaObjCXX/cstyle-cast.mm40
-rw-r--r--clang/test/SemaObjCXX/cxxoperator-selector.mm24
-rw-r--r--clang/test/SemaObjCXX/debugger-cast-result-to-id.mm17
-rw-r--r--clang/test/SemaObjCXX/deduction.mm65
-rw-r--r--clang/test/SemaObjCXX/exceptions-fragile.mm12
-rw-r--r--clang/test/SemaObjCXX/expr-objcxx.mm4
-rw-r--r--clang/test/SemaObjCXX/foreach-block.mm14
-rw-r--r--clang/test/SemaObjCXX/fragile-abi-object-assign.m13
-rw-r--r--clang/test/SemaObjCXX/function-pointer-void-star.mm9
-rw-r--r--clang/test/SemaObjCXX/gc-attributes.mm22
-rw-r--r--clang/test/SemaObjCXX/goto.mm16
-rw-r--r--clang/test/SemaObjCXX/instantiate-expr.mm75
-rw-r--r--clang/test/SemaObjCXX/instantiate-message.mm50
-rw-r--r--clang/test/SemaObjCXX/instantiate-method-return.mm26
-rw-r--r--clang/test/SemaObjCXX/instantiate-stmt.mm78
-rw-r--r--clang/test/SemaObjCXX/ivar-construct.mm37
-rw-r--r--clang/test/SemaObjCXX/ivar-lookup.mm18
-rw-r--r--clang/test/SemaObjCXX/ivar-reference-type.mm5
-rw-r--r--clang/test/SemaObjCXX/ivar-struct.mm7
-rw-r--r--clang/test/SemaObjCXX/linkage-spec.mm21
-rw-r--r--clang/test/SemaObjCXX/literals.mm187
-rw-r--r--clang/test/SemaObjCXX/message.mm127
-rw-r--r--clang/test/SemaObjCXX/namespace-lookup.mm14
-rw-r--r--clang/test/SemaObjCXX/null_objc_pointer.mm13
-rw-r--r--clang/test/SemaObjCXX/nullptr.mm16
-rw-r--r--clang/test/SemaObjCXX/objc-container-subscripting.mm138
-rw-r--r--clang/test/SemaObjCXX/objc-decls-inside-namespace.mm32
-rw-r--r--clang/test/SemaObjCXX/objc-extern-c.mm30
-rw-r--r--clang/test/SemaObjCXX/objc-pointer-conv.mm48
-rw-r--r--clang/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm51
-rw-r--r--clang/test/SemaObjCXX/overload-1.mm25
-rw-r--r--clang/test/SemaObjCXX/overload-gc.mm24
-rw-r--r--clang/test/SemaObjCXX/overload.mm179
-rw-r--r--clang/test/SemaObjCXX/parameters.mm17
-rw-r--r--clang/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm49
-rw-r--r--clang/test/SemaObjCXX/propert-dot-error.mm69
-rw-r--r--clang/test/SemaObjCXX/properties.mm108
-rw-r--r--clang/test/SemaObjCXX/property-reference.mm59
-rw-r--r--clang/test/SemaObjCXX/property-synthesis-error.mm74
-rw-r--r--clang/test/SemaObjCXX/property-type-mismatch.mm19
-rw-r--r--clang/test/SemaObjCXX/protocol-lookup.mm56
-rw-r--r--clang/test/SemaObjCXX/references.mm62
-rw-r--r--clang/test/SemaObjCXX/reinterpret-cast-objc-pointertype.mm23
-rw-r--r--clang/test/SemaObjCXX/related-result-type-inference.mm71
-rw-r--r--clang/test/SemaObjCXX/reserved-keyword-methods.mm42
-rw-r--r--clang/test/SemaObjCXX/standard-conversion-to-bool.mm12
-rw-r--r--clang/test/SemaObjCXX/static-cast.mm29
-rw-r--r--clang/test/SemaObjCXX/unknown-anytype.mm9
-rw-r--r--clang/test/SemaObjCXX/vararg-non-pod.mm32
-rw-r--r--clang/test/SemaObjCXX/vla.mm12
-rw-r--r--clang/test/SemaObjCXX/void_to_obj.mm26
-rw-r--r--clang/test/SemaObjCXX/warn-strict-selector-match.mm18
-rw-r--r--clang/test/SemaOpenCL/address-spaces.cl13
-rw-r--r--clang/test/SemaOpenCL/cond.cl5
-rw-r--r--clang/test/SemaOpenCL/extension-fp64.cl19
-rw-r--r--clang/test/SemaOpenCL/init.cl15
-rw-r--r--clang/test/SemaOpenCL/vec_compare.cl11
-rw-r--r--clang/test/SemaOpenCL/vec_step.cl32
-rw-r--r--clang/test/SemaOpenCL/vector_conv_invalid.cl14
-rw-r--r--clang/test/SemaOpenCL/vector_literals_const.cl26
-rw-r--r--clang/test/SemaOpenCL/vector_literals_invalid.cl13
-rw-r--r--clang/test/SemaTemplate/ackermann.cpp38
-rw-r--r--clang/test/SemaTemplate/address-spaces.cpp86
-rw-r--r--clang/test/SemaTemplate/alias-church-numerals.cpp34
-rw-r--r--clang/test/SemaTemplate/alias-nested-nontag.cpp6
-rw-r--r--clang/test/SemaTemplate/alias-template-template-param.cpp7
-rw-r--r--clang/test/SemaTemplate/alias-templates.cpp102
-rw-r--r--clang/test/SemaTemplate/ambiguous-ovl-print.cpp9
-rw-r--r--clang/test/SemaTemplate/anonymous-union.cpp40
-rw-r--r--clang/test/SemaTemplate/array-to-pointer-decay.cpp25
-rw-r--r--clang/test/SemaTemplate/atomics.cpp16
-rw-r--r--clang/test/SemaTemplate/attributes.cpp34
-rw-r--r--clang/test/SemaTemplate/canonical-expr-type-0x.cpp25
-rw-r--r--clang/test/SemaTemplate/canonical-expr-type.cpp53
-rw-r--r--clang/test/SemaTemplate/class-template-ctor-initializer.cpp55
-rw-r--r--clang/test/SemaTemplate/class-template-decl.cpp97
-rw-r--r--clang/test/SemaTemplate/class-template-id-2.cpp24
-rw-r--r--clang/test/SemaTemplate/class-template-id.cpp47
-rw-r--r--clang/test/SemaTemplate/class-template-spec.cpp121
-rw-r--r--clang/test/SemaTemplate/constexpr-instantiate.cpp77
-rw-r--r--clang/test/SemaTemplate/constructor-template.cpp128
-rw-r--r--clang/test/SemaTemplate/copy-ctor-assign.cpp52
-rw-r--r--clang/test/SemaTemplate/crash-10438657.cpp15
-rw-r--r--clang/test/SemaTemplate/crash-8204126.cpp6
-rw-r--r--clang/test/SemaTemplate/current-instantiation.cpp237
-rw-r--r--clang/test/SemaTemplate/deduction-crash.cpp89
-rw-r--r--clang/test/SemaTemplate/deduction.cpp164
-rw-r--r--clang/test/SemaTemplate/default-arguments-cxx0x.cpp26
-rw-r--r--clang/test/SemaTemplate/default-arguments.cpp138
-rw-r--r--clang/test/SemaTemplate/default-expr-arguments-2.cpp19
-rw-r--r--clang/test/SemaTemplate/default-expr-arguments.cpp305
-rw-r--r--clang/test/SemaTemplate/delegating-constructors.cpp31
-rw-r--r--clang/test/SemaTemplate/dependent-base-classes.cpp137
-rw-r--r--clang/test/SemaTemplate/dependent-base-member-init.cpp68
-rw-r--r--clang/test/SemaTemplate/dependent-class-member-operator.cpp11
-rw-r--r--clang/test/SemaTemplate/dependent-expr.cpp73
-rw-r--r--clang/test/SemaTemplate/dependent-names-no-std.cpp21
-rw-r--r--clang/test/SemaTemplate/dependent-names.cpp326
-rw-r--r--clang/test/SemaTemplate/dependent-sized_array.cpp17
-rw-r--r--clang/test/SemaTemplate/dependent-template-recover.cpp60
-rw-r--r--clang/test/SemaTemplate/dependent-type-identity.cpp100
-rw-r--r--clang/test/SemaTemplate/destructor-template.cpp59
-rw-r--r--clang/test/SemaTemplate/elaborated-type-specifier.cpp40
-rw-r--r--clang/test/SemaTemplate/enum-argument.cpp36
-rw-r--r--clang/test/SemaTemplate/enum-forward.cpp8
-rw-r--r--clang/test/SemaTemplate/example-dynarray.cpp177
-rw-r--r--clang/test/SemaTemplate/example-typelist.cpp98
-rw-r--r--clang/test/SemaTemplate/explicit-instantiation.cpp107
-rw-r--r--clang/test/SemaTemplate/explicit-specialization-member.cpp21
-rw-r--r--clang/test/SemaTemplate/ext-vector-type.cpp94
-rw-r--r--clang/test/SemaTemplate/extern-templates.cpp64
-rw-r--r--clang/test/SemaTemplate/fibonacci.cpp66
-rw-r--r--clang/test/SemaTemplate/friend-template.cpp245
-rw-r--r--clang/test/SemaTemplate/friend.cpp33
-rw-r--r--clang/test/SemaTemplate/fun-template-def.cpp48
-rw-r--r--clang/test/SemaTemplate/function-template-specialization.cpp48
-rw-r--r--clang/test/SemaTemplate/implicit-instantiation-1.cpp25
-rw-r--r--clang/test/SemaTemplate/inject-templated-friend-post.cpp72
-rw-r--r--clang/test/SemaTemplate/inject-templated-friend.cpp48
-rw-r--r--clang/test/SemaTemplate/injected-class-name.cpp62
-rw-r--r--clang/test/SemaTemplate/instantiate-anonymous-union.cpp89
-rw-r--r--clang/test/SemaTemplate/instantiate-array.cpp28
-rw-r--r--clang/test/SemaTemplate/instantiate-attr.cpp26
-rw-r--r--clang/test/SemaTemplate/instantiate-c99.cpp81
-rw-r--r--clang/test/SemaTemplate/instantiate-call.cpp51
-rw-r--r--clang/test/SemaTemplate/instantiate-case.cpp21
-rw-r--r--clang/test/SemaTemplate/instantiate-cast.cpp117
-rw-r--r--clang/test/SemaTemplate/instantiate-clang.cpp35
-rw-r--r--clang/test/SemaTemplate/instantiate-complete.cpp146
-rw-r--r--clang/test/SemaTemplate/instantiate-decl-dtor.cpp11
-rw-r--r--clang/test/SemaTemplate/instantiate-decl-init.cpp46
-rw-r--r--clang/test/SemaTemplate/instantiate-declref-ice.cpp34
-rw-r--r--clang/test/SemaTemplate/instantiate-declref.cpp117
-rw-r--r--clang/test/SemaTemplate/instantiate-deeply.cpp36
-rw-r--r--clang/test/SemaTemplate/instantiate-default-assignment-operator.cpp17
-rw-r--r--clang/test/SemaTemplate/instantiate-dependent-nested-name.cpp7
-rw-r--r--clang/test/SemaTemplate/instantiate-elab-type-specifier.cpp13
-rw-r--r--clang/test/SemaTemplate/instantiate-enum-2.cpp9
-rw-r--r--clang/test/SemaTemplate/instantiate-enum.cpp27
-rw-r--r--clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp133
-rw-r--r--clang/test/SemaTemplate/instantiate-exception-spec.cpp11
-rw-r--r--clang/test/SemaTemplate/instantiate-expr-1.cpp192
-rw-r--r--clang/test/SemaTemplate/instantiate-expr-2.cpp245
-rw-r--r--clang/test/SemaTemplate/instantiate-expr-3.cpp119
-rw-r--r--clang/test/SemaTemplate/instantiate-expr-4.cpp354
-rw-r--r--clang/test/SemaTemplate/instantiate-expr-5.cpp38
-rw-r--r--clang/test/SemaTemplate/instantiate-expr-basic.cpp17
-rw-r--r--clang/test/SemaTemplate/instantiate-field.cpp104
-rw-r--r--clang/test/SemaTemplate/instantiate-friend-class.cpp9
-rw-r--r--clang/test/SemaTemplate/instantiate-function-1.cpp249
-rw-r--r--clang/test/SemaTemplate/instantiate-function-1.mm17
-rw-r--r--clang/test/SemaTemplate/instantiate-function-2.cpp66
-rw-r--r--clang/test/SemaTemplate/instantiate-function-params.cpp90
-rw-r--r--clang/test/SemaTemplate/instantiate-init.cpp109
-rw-r--r--clang/test/SemaTemplate/instantiate-invalid.cpp52
-rw-r--r--clang/test/SemaTemplate/instantiate-local-class.cpp67
-rw-r--r--clang/test/SemaTemplate/instantiate-member-class.cpp142
-rw-r--r--clang/test/SemaTemplate/instantiate-member-expr.cpp68
-rw-r--r--clang/test/SemaTemplate/instantiate-member-initializers.cpp27
-rw-r--r--clang/test/SemaTemplate/instantiate-member-pointers.cpp67
-rw-r--r--clang/test/SemaTemplate/instantiate-member-template.cpp261
-rw-r--r--clang/test/SemaTemplate/instantiate-method.cpp177
-rw-r--r--clang/test/SemaTemplate/instantiate-non-dependent-types.cpp14
-rw-r--r--clang/test/SemaTemplate/instantiate-non-type-template-parameter.cpp55
-rw-r--r--clang/test/SemaTemplate/instantiate-objc-1.mm48
-rw-r--r--clang/test/SemaTemplate/instantiate-overload-candidates.cpp21
-rw-r--r--clang/test/SemaTemplate/instantiate-overloaded-arrow.cpp20
-rw-r--r--clang/test/SemaTemplate/instantiate-self.cpp89
-rw-r--r--clang/test/SemaTemplate/instantiate-sizeof.cpp10
-rw-r--r--clang/test/SemaTemplate/instantiate-static-var.cpp116
-rw-r--r--clang/test/SemaTemplate/instantiate-subscript.cpp41
-rw-r--r--clang/test/SemaTemplate/instantiate-template-template-parm.cpp97
-rw-r--r--clang/test/SemaTemplate/instantiate-try-catch.cpp31
-rw-r--r--clang/test/SemaTemplate/instantiate-type.cpp17
-rw-r--r--clang/test/SemaTemplate/instantiate-typedef.cpp15
-rw-r--r--clang/test/SemaTemplate/instantiate-typeof.cpp10
-rw-r--r--clang/test/SemaTemplate/instantiate-using-decl.cpp82
-rw-r--r--clang/test/SemaTemplate/instantiation-backtrace.cpp32
-rw-r--r--clang/test/SemaTemplate/instantiation-default-1.cpp102
-rw-r--r--clang/test/SemaTemplate/instantiation-default-2.cpp18
-rw-r--r--clang/test/SemaTemplate/instantiation-default-3.cpp21
-rw-r--r--clang/test/SemaTemplate/instantiation-depth.cpp13
-rw-r--r--clang/test/SemaTemplate/instantiation-order.cpp15
-rw-r--r--clang/test/SemaTemplate/issue150.cpp107
-rw-r--r--clang/test/SemaTemplate/lookup-dependent-bases.cpp19
-rw-r--r--clang/test/SemaTemplate/member-access-ambig.cpp45
-rw-r--r--clang/test/SemaTemplate/member-access-expr.cpp149
-rw-r--r--clang/test/SemaTemplate/member-function-template.cpp103
-rw-r--r--clang/test/SemaTemplate/member-inclass-init-value-dependent.cpp18
-rw-r--r--clang/test/SemaTemplate/member-initializers.cpp13
-rw-r--r--clang/test/SemaTemplate/member-template-access-expr.cpp144
-rw-r--r--clang/test/SemaTemplate/metafun-apply.cpp40
-rw-r--r--clang/test/SemaTemplate/missing-class-keyword-crash.cpp7
-rw-r--r--clang/test/SemaTemplate/ms-function-specialization-class-scope.cpp71
-rw-r--r--clang/test/SemaTemplate/ms-if-exists.cpp68
-rw-r--r--clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp145
-rw-r--r--clang/test/SemaTemplate/nested-incomplete-class.cpp21
-rw-r--r--clang/test/SemaTemplate/nested-linkage.cpp3
-rw-r--r--clang/test/SemaTemplate/nested-name-spec-template.cpp142
-rw-r--r--clang/test/SemaTemplate/nested-template.cpp157
-rw-r--r--clang/test/SemaTemplate/operator-function-id-template.cpp28
-rw-r--r--clang/test/SemaTemplate/operator-template.cpp18
-rw-r--r--clang/test/SemaTemplate/overload-candidates.cpp40
-rw-r--r--clang/test/SemaTemplate/overload-uneval.cpp42
-rw-r--r--clang/test/SemaTemplate/partial-spec-instantiate.cpp50
-rw-r--r--clang/test/SemaTemplate/pragma-ms_struct.cpp10
-rw-r--r--clang/test/SemaTemplate/qualified-id.cpp56
-rw-r--r--clang/test/SemaTemplate/qualified-names-diag.cpp16
-rw-r--r--clang/test/SemaTemplate/rdar9173693.cpp6
-rw-r--r--clang/test/SemaTemplate/recovery-crash.cpp19
-rw-r--r--clang/test/SemaTemplate/recursive-template-instantiation.cpp10
-rw-r--r--clang/test/SemaTemplate/resolve-single-template-id.cpp82
-rw-r--r--clang/test/SemaTemplate/self-comparison.cpp48
-rw-r--r--clang/test/SemaTemplate/temp.cpp19
-rw-r--r--clang/test/SemaTemplate/temp_arg.cpp20
-rw-r--r--clang/test/SemaTemplate/temp_arg_nontype.cpp325
-rw-r--r--clang/test/SemaTemplate/temp_arg_template.cpp62
-rw-r--r--clang/test/SemaTemplate/temp_arg_type.cpp42
-rw-r--r--clang/test/SemaTemplate/temp_class_order.cpp42
-rw-r--r--clang/test/SemaTemplate/temp_class_spec.cpp363
-rw-r--r--clang/test/SemaTemplate/temp_class_spec_blocks.cpp34
-rw-r--r--clang/test/SemaTemplate/temp_class_spec_neg.cpp45
-rw-r--r--clang/test/SemaTemplate/temp_explicit.cpp151
-rw-r--r--clang/test/SemaTemplate/temp_explicit_cxx0x.cpp24
-rw-r--r--clang/test/SemaTemplate/temp_func_order.cpp95
-rw-r--r--clang/test/SemaTemplate/template-class-traits.cpp8
-rw-r--r--clang/test/SemaTemplate/template-decl-fail.cpp10
-rw-r--r--clang/test/SemaTemplate/template-id-expr.cpp98
-rw-r--r--clang/test/SemaTemplate/template-id-printing.cpp141
-rw-r--r--clang/test/SemaTemplate/typename-specifier-2.cpp30
-rw-r--r--clang/test/SemaTemplate/typename-specifier-3.cpp19
-rw-r--r--clang/test/SemaTemplate/typename-specifier-4.cpp164
-rw-r--r--clang/test/SemaTemplate/typename-specifier.cpp117
-rw-r--r--clang/test/SemaTemplate/typo-dependent-name.cpp17
-rw-r--r--clang/test/SemaTemplate/unresolved-construct.cpp19
-rw-r--r--clang/test/SemaTemplate/unused-variables.cpp21
-rw-r--r--clang/test/SemaTemplate/value-dependent-null-pointer-constant.cpp29
-rw-r--r--clang/test/SemaTemplate/virtual-member-functions.cpp86
-rwxr-xr-xclang/test/TestRunner.sh13
-rw-r--r--clang/test/Tooling/clang-check-args.cpp8
-rw-r--r--clang/test/Tooling/clang-check-pwd.cpp13
-rw-r--r--clang/test/Tooling/clang-check.cpp13
-rw-r--r--clang/test/Unit/lit.cfg86
-rw-r--r--clang/test/Unit/lit.site.cfg.in26
-rw-r--r--clang/test/cxx-sections.data1943
-rw-r--r--clang/test/lit.cfg257
-rw-r--r--clang/test/lit.site.cfg.in21
-rwxr-xr-xclang/test/make_test_dirs.pl27
5009 files changed, 256953 insertions, 0 deletions
diff --git a/clang/test/ARCMT/Common.h b/clang/test/ARCMT/Common.h
new file mode 100644
index 0000000..16856ed
--- /dev/null
+++ b/clang/test/ARCMT/Common.h
@@ -0,0 +1,70 @@
+#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 NS_INLINE static __inline__ __attribute__((always_inline))
+#define nil ((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);
+id CFBridgingRelease(CFTypeRef CF_CONSUMED X);
+
+NS_INLINE NS_RETURNS_RETAINED id NSMakeCollectable(CFTypeRef CF_CONSUMED cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
+
+@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;
+@end
+
+@interface NSObject <NSObject> {}
+- (id)init;
+
++ (id)new;
++ (id)alloc;
+- (void)dealloc;
+
+- (void)finalize;
+
+- (id)copy;
+- (id)mutableCopy;
+@end
+
+NS_AUTOMATED_REFCOUNT_UNAVAILABLE
+@interface NSAutoreleasePool : NSObject {
+@private
+ void *_token;
+ void *_reserved3;
+ void *_reserved2;
+ void *_reserved;
+}
+
++ (void)addObject:(id)anObject;
+
+- (void)addObject:(id)anObject;
+
+- (void)drain;
+
+@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);
diff --git a/clang/test/ARCMT/GC-check-warn-nsalloc.m b/clang/test/ARCMT/GC-check-warn-nsalloc.m
new file mode 100644
index 0000000..5ce36c4
--- /dev/null
+++ b/clang/test/ARCMT/GC-check-warn-nsalloc.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -arcmt-check -verify -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only %s
+// RUN: %clang_cc1 -arcmt-check -verify -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only -x objective-c++ %s
+// DISABLE: mingw32
+// rdar://10532541
+// XFAIL: *
+
+typedef unsigned NSUInteger;
+void *__strong NSAllocateCollectable(NSUInteger size, NSUInteger options);
+
+void test1() {
+ NSAllocateCollectable(100, 0); // expected-warning {{call returns pointer to GC managed memory; it will become unmanaged in ARC}}
+}
diff --git a/clang/test/ARCMT/GC-check.m b/clang/test/ARCMT/GC-check.m
new file mode 100644
index 0000000..3a1b67c
--- /dev/null
+++ b/clang/test/ARCMT/GC-check.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fobjc-gc-only %s
+// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fobjc-gc-only -x objective-c++ %s
+// DISABLE: mingw32
+
+#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}}
+}
+
+@interface I1 {
+ __strong void *gcVar; // expected-error {{GC managed memory will become unmanaged in ARC}}
+}
+@end;
diff --git a/clang/test/ARCMT/GC-no-arc-runtime.m b/clang/test/ARCMT/GC-no-arc-runtime.m
new file mode 100644
index 0000000..f069992
--- /dev/null
+++ b/clang/test/ARCMT/GC-no-arc-runtime.m
@@ -0,0 +1,78 @@
+// 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
+// DISABLE: mingw32
+
+#include "Common.h"
+#include "GC.h"
+
+void test1(CFTypeRef *cft) {
+ id x = NSMakeCollectable(cft);
+}
+
+@interface I1
+@end
+
+@implementation I1
+-(void)dealloc {
+ // dealloc
+ test1(0);
+}
+
+-(void)finalize {
+ // finalize
+ test1(0);
+}
+@end
+
+@interface I2
+@property (retain) id prop;
+@end
+
+@implementation I2
+@synthesize prop;
+
+-(void)finalize {
+ self.prop = 0;
+ // finalize
+ test1(0);
+}
+@end
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface QQ {
+ __weak id s;
+ __weak QQ *q;
+}
+@end
+
+@interface I3
+@property (assign) I3 *__weak pw1, *__weak pw2;
+@property (assign) I3 *__strong ps;
+@property (assign) I3 * pds;
+@end
+
+@interface I4Impl {
+ I4Impl *pds2;
+}
+@property (assign) I4Impl *__weak pw1, *__weak pw2;
+@property (assign) I4Impl *__strong ps;
+@property (assign) I4Impl * pds;
+@property (assign) I4Impl * pds2;
+@end
+
+@implementation I4Impl
+@synthesize pw1, pw2, ps, pds, pds2;
+
+-(void)test1:(CFTypeRef *)cft {
+ id x = NSMakeCollectable(cft);
+}
+@end
+
+@interface I5 {
+ __weak id prop;
+}
+@property (readonly) __weak id prop;
+@end
diff --git a/clang/test/ARCMT/GC-no-arc-runtime.m.result b/clang/test/ARCMT/GC-no-arc-runtime.m.result
new file mode 100644
index 0000000..f55ca38
--- /dev/null
+++ b/clang/test/ARCMT/GC-no-arc-runtime.m.result
@@ -0,0 +1,73 @@
+// 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
+// DISABLE: mingw32
+
+#include "Common.h"
+#include "GC.h"
+
+void test1(CFTypeRef *cft) {
+ id x = CFBridgingRelease(cft);
+}
+
+@interface I1
+@end
+
+@implementation I1
+-(void)dealloc {
+ // dealloc
+ test1(0);
+}
+
+@end
+
+@interface I2
+@property (strong) id prop;
+@end
+
+@implementation I2
+@synthesize prop;
+
+-(void)dealloc {
+ // finalize
+ test1(0);
+}
+@end
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface QQ {
+ __unsafe_unretained id s;
+ __unsafe_unretained QQ *q;
+}
+@end
+
+@interface I3
+@property (unsafe_unretained) I3 * pw1, * pw2;
+@property (strong) I3 * ps;
+@property (assign) I3 * pds;
+@end
+
+@interface I4Impl {
+ I4Impl *__strong pds2;
+}
+@property (unsafe_unretained) I4Impl * pw1, * pw2;
+@property (strong) I4Impl * ps;
+@property (strong) I4Impl * pds;
+@property (strong) I4Impl * pds2;
+@end
+
+@implementation I4Impl
+@synthesize pw1, pw2, ps, pds, pds2;
+
+-(void)test1:(CFTypeRef *)cft {
+ id x = CFBridgingRelease(cft);
+}
+@end
+
+@interface I5 {
+ __unsafe_unretained id prop;
+}
+@property (unsafe_unretained, readonly) id prop;
+@end
diff --git a/clang/test/ARCMT/GC-no-finalize-removal.m b/clang/test/ARCMT/GC-no-finalize-removal.m
new file mode 100644
index 0000000..14e8602
--- /dev/null
+++ b/clang/test/ARCMT/GC-no-finalize-removal.m
@@ -0,0 +1,90 @@
+// 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
+// DISABLE: mingw32
+
+#include "Common.h"
+#include "GC.h"
+
+void test1(CFTypeRef *cft) {
+ id x = NSMakeCollectable(cft);
+}
+
+@interface I1
+@end
+
+@implementation I1
+-(void)dealloc {
+ // dealloc
+ test1(0);
+}
+
+-(void)finalize {
+ // finalize
+ test1(0);
+}
+@end
+
+@interface I2
+@property (retain) id prop;
+@end
+
+@implementation I2
+@synthesize prop;
+
+-(void)finalize {
+ self.prop = 0;
+ // finalize
+ test1(0);
+}
+@end
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface QQ {
+ __weak id s;
+ __weak QQ *q;
+}
+@end
+
+@interface I3
+@property (assign) I3 *__weak pw1, *__weak pw2;
+@property (assign) I3 *__strong ps;
+@property (assign) I3 * pds;
+@end
+
+@interface I4Impl {
+ I4Impl *pds2;
+ I4Impl *pds3;
+ __weak I4Impl *pw3;
+ __weak I4Impl *pw4;
+}
+@property (assign) I4Impl *__weak pw1, *__weak pw2;
+@property (assign) I4Impl *__strong ps;
+@property (assign) I4Impl * pds;
+@property (assign) I4Impl * pds2;
+@property (readwrite) I4Impl * pds3;
+@property (readonly) I4Impl * pds4;
+@property (readonly) __weak I4Impl *pw3;
+@property (assign) __weak I4Impl *pw4;
+@end
+
+@implementation I4Impl
+@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
+
+-(void)test1:(CFTypeRef *)cft {
+ id x = NSMakeCollectable(cft);
+}
+@end
+
+// rdar://10532449
+@interface rdar10532449
+@property (assign) id assign_prop;
+@property (assign, readonly) id __strong strong_readonly_prop;
+@property (assign) id __weak weak_prop;
+@end
+
+@implementation rdar10532449
+@synthesize assign_prop, strong_readonly_prop, weak_prop;
+@end
diff --git a/clang/test/ARCMT/GC-no-finalize-removal.m.result b/clang/test/ARCMT/GC-no-finalize-removal.m.result
new file mode 100644
index 0000000..ea14873
--- /dev/null
+++ b/clang/test/ARCMT/GC-no-finalize-removal.m.result
@@ -0,0 +1,98 @@
+// 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
+// DISABLE: mingw32
+
+#include "Common.h"
+#include "GC.h"
+
+void test1(CFTypeRef *cft) {
+ id x = CFBridgingRelease(cft);
+}
+
+@interface I1
+@end
+
+@implementation I1
+-(void)dealloc {
+ // dealloc
+ test1(0);
+}
+
+#if !__has_feature(objc_arc)
+-(void)finalize {
+ // finalize
+ test1(0);
+}
+#endif
+@end
+
+@interface I2
+@property (strong) id prop;
+@end
+
+@implementation I2
+@synthesize prop;
+
+#if !__has_feature(objc_arc)
+-(void)finalize {
+ self.prop = 0;
+ // finalize
+ test1(0);
+}
+#endif
+-(void)dealloc {
+ // finalize
+ test1(0);
+}
+@end
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface QQ {
+ __weak id s;
+ __unsafe_unretained QQ *q;
+}
+@end
+
+@interface I3
+@property (weak) I3 * pw1, * pw2;
+@property (strong) I3 * ps;
+@property (assign) I3 * pds;
+@end
+
+@interface I4Impl {
+ I4Impl *__strong pds2;
+ I4Impl *pds3;
+ __weak I4Impl *pw3;
+ __weak I4Impl *pw4;
+}
+@property (weak) I4Impl * pw1, * pw2;
+@property (strong) I4Impl * ps;
+@property (strong) I4Impl * pds;
+@property (strong) I4Impl * pds2;
+@property (readwrite) I4Impl * pds3;
+@property (readonly) I4Impl * pds4;
+@property (weak, readonly) I4Impl *pw3;
+@property (weak) I4Impl *pw4;
+@end
+
+@implementation I4Impl
+@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
+
+-(void)test1:(CFTypeRef *)cft {
+ id x = CFBridgingRelease(cft);
+}
+@end
+
+// rdar://10532449
+@interface rdar10532449
+@property (strong) id assign_prop;
+@property (strong, readonly) id strong_readonly_prop;
+@property (weak) id weak_prop;
+@end
+
+@implementation rdar10532449
+@synthesize assign_prop, strong_readonly_prop, weak_prop;
+@end
diff --git a/clang/test/ARCMT/GC.h b/clang/test/ARCMT/GC.h
new file mode 100644
index 0000000..4301baf
--- /dev/null
+++ b/clang/test/ARCMT/GC.h
@@ -0,0 +1,6 @@
+
+@interface ExtInterface {
+ __strong ExtInterface *myivar;
+ __strong void *gcVar;
+}
+@end
diff --git a/clang/test/ARCMT/GC.m b/clang/test/ARCMT/GC.m
new file mode 100644
index 0000000..eebbaf6
--- /dev/null
+++ b/clang/test/ARCMT/GC.m
@@ -0,0 +1,95 @@
+// 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
+// DISABLE: mingw32
+
+#include "Common.h"
+#include "GC.h"
+
+void test1(CFTypeRef *cft) {
+ id x = NSMakeCollectable(cft);
+}
+
+@interface I1
+@end
+
+@implementation I1
+-(void)dealloc {
+ // dealloc
+ test1(0);
+}
+
+-(void)finalize {
+ // finalize
+ test1(0);
+}
+@end
+
+@interface I2
+@property (retain) id prop;
+@end
+
+@implementation I2
+@synthesize prop;
+
+-(void)finalize {
+ self.prop = 0;
+ // finalize
+ test1(0);
+}
+@end
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface QQ {
+ __weak id s;
+ __weak QQ *q;
+}
+@end
+
+@interface I3
+@property (assign) I3 *__weak pw1, *__weak pw2;
+@property (assign) I3 *__strong ps;
+@property (assign) I3 * pds;
+@end
+
+@interface I4Impl {
+ I4Impl *pds2;
+ I4Impl *pds3;
+ __weak I4Impl *pw3;
+ __weak I4Impl *pw4;
+}
+@property (assign) I4Impl *__weak pw1, *__weak pw2;
+@property (assign) I4Impl *__strong ps;
+@property (assign) I4Impl * pds;
+@property (assign) I4Impl * pds2;
+@property (readwrite) I4Impl * pds3;
+@property (readonly) I4Impl * pds4;
+@property (readonly) __weak I4Impl *pw3;
+@property (assign) __weak I4Impl *pw4;
+@end
+
+@implementation I4Impl
+@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
+
+-(void)test1:(CFTypeRef *)cft {
+ id x = NSMakeCollectable(cft);
+}
+@end
+
+// rdar://10532449
+@interface rdar10532449
+@property (assign) id assign_prop;
+@property (assign, readonly) id __strong strong_readonly_prop;
+@property (assign) id __weak weak_prop;
+@end
+
+@implementation rdar10532449
+@synthesize assign_prop, strong_readonly_prop, weak_prop;
+@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
new file mode 100644
index 0000000..c2c523f
--- /dev/null
+++ b/clang/test/ARCMT/GC.m.result
@@ -0,0 +1,90 @@
+// 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
+// DISABLE: mingw32
+
+#include "Common.h"
+#include "GC.h"
+
+void test1(CFTypeRef *cft) {
+ id x = CFBridgingRelease(cft);
+}
+
+@interface I1
+@end
+
+@implementation I1
+-(void)dealloc {
+ // dealloc
+ test1(0);
+}
+
+@end
+
+@interface I2
+@property (strong) id prop;
+@end
+
+@implementation I2
+@synthesize prop;
+
+-(void)dealloc {
+ // finalize
+ test1(0);
+}
+@end
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface QQ {
+ __weak id s;
+ __unsafe_unretained QQ *q;
+}
+@end
+
+@interface I3
+@property (weak) I3 * pw1, * pw2;
+@property (strong) I3 * ps;
+@property (assign) I3 * pds;
+@end
+
+@interface I4Impl {
+ I4Impl *__strong pds2;
+ I4Impl *pds3;
+ __weak I4Impl *pw3;
+ __weak I4Impl *pw4;
+}
+@property (weak) I4Impl * pw1, * pw2;
+@property (strong) I4Impl * ps;
+@property (strong) I4Impl * pds;
+@property (strong) I4Impl * pds2;
+@property (readwrite) I4Impl * pds3;
+@property (readonly) I4Impl * pds4;
+@property (weak, readonly) I4Impl *pw3;
+@property (weak) I4Impl *pw4;
+@end
+
+@implementation I4Impl
+@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
+
+-(void)test1:(CFTypeRef *)cft {
+ id x = CFBridgingRelease(cft);
+}
+@end
+
+// rdar://10532449
+@interface rdar10532449
+@property (strong) id assign_prop;
+@property (strong, readonly) id strong_readonly_prop;
+@property (weak) id weak_prop;
+@end
+
+@implementation rdar10532449
+@synthesize assign_prop, strong_readonly_prop, weak_prop;
+@end
+
+void test2(id p, __strong I1 *ap[]) {
+ for (__strong I1 *specRule in p) {
+ }
+}
diff --git a/clang/test/ARCMT/Inputs/test.h b/clang/test/ARCMT/Inputs/test.h
new file mode 100644
index 0000000..756295f
--- /dev/null
+++ b/clang/test/ARCMT/Inputs/test.h
@@ -0,0 +1,15 @@
+@protocol NSObject
+- (oneway void)release;
+@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
new file mode 100644
index 0000000..0638a33
--- /dev/null
+++ b/clang/test/ARCMT/Inputs/test.h.result
@@ -0,0 +1,13 @@
+@protocol NSObject
+- (oneway void)release;
+@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
new file mode 100644
index 0000000..8416a88
--- /dev/null
+++ b/clang/test/ARCMT/Inputs/test1.m.in
@@ -0,0 +1,6 @@
+#define PART1
+#include "test.h"
+
+void test1(id p) {
+ [p release];
+}
diff --git a/clang/test/ARCMT/Inputs/test1.m.in.result b/clang/test/ARCMT/Inputs/test1.m.in.result
new file mode 100644
index 0000000..f351fe6
--- /dev/null
+++ b/clang/test/ARCMT/Inputs/test1.m.in.result
@@ -0,0 +1,5 @@
+#define PART1
+#include "test.h"
+
+void test1(id p) {
+}
diff --git a/clang/test/ARCMT/Inputs/test2.m.in b/clang/test/ARCMT/Inputs/test2.m.in
new file mode 100644
index 0000000..99f87b0
--- /dev/null
+++ b/clang/test/ARCMT/Inputs/test2.m.in
@@ -0,0 +1,6 @@
+#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
new file mode 100644
index 0000000..f8e918c
--- /dev/null
+++ b/clang/test/ARCMT/Inputs/test2.m.in.result
@@ -0,0 +1,5 @@
+#define PART2
+#include "test.h"
+
+void test2(id p) {
+}
diff --git a/clang/test/ARCMT/api.m b/clang/test/ARCMT/api.m
new file mode 100644
index 0000000..ba122c4
--- /dev/null
+++ b/clang/test/ARCMT/api.m
@@ -0,0 +1,10 @@
+// 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
+// DISABLE: mingw32
+
+#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
new file mode 100644
index 0000000..7e04e7d
--- /dev/null
+++ b/clang/test/ARCMT/api.m.result
@@ -0,0 +1,10 @@
+// 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
+// DISABLE: mingw32
+
+#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
new file mode 100644
index 0000000..de1c456
--- /dev/null
+++ b/clang/test/ARCMT/assign-prop-no-arc-runtime.m
@@ -0,0 +1,15 @@
+// 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"
+
+@interface Foo : NSObject {
+ NSObject *x;
+}
+@property (readonly,assign) id x;
+@end
+
+@implementation Foo
+@synthesize x;
+@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
new file mode 100644
index 0000000..23848d3
--- /dev/null
+++ b/clang/test/ARCMT/assign-prop-no-arc-runtime.m.result
@@ -0,0 +1,15 @@
+// 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"
+
+@interface Foo : NSObject {
+ NSObject *__unsafe_unretained x;
+}
+@property (readonly,unsafe_unretained) id x;
+@end
+
+@implementation Foo
+@synthesize x;
+@end
diff --git a/clang/test/ARCMT/assign-prop-with-arc-runtime.m b/clang/test/ARCMT/assign-prop-with-arc-runtime.m
new file mode 100644
index 0000000..c357eeb
--- /dev/null
+++ b/clang/test/ARCMT/assign-prop-with-arc-runtime.m
@@ -0,0 +1,73 @@
+// 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
+// DISABLE: mingw32
+
+#include "Common.h"
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface WeakOptOut
+@end
+
+@class _NSCachedAttributedString;
+typedef _NSCachedAttributedString *BadClassForWeak;
+
+@class Forw;
+
+@interface Foo : NSObject {
+ Foo *x, *w, *q1, *q2;
+ WeakOptOut *oo;
+ BadClassForWeak bcw;
+ id not_safe1;
+ NSObject *not_safe2;
+ Forw *not_safe3;
+ Foo *assign_plus1;
+}
+@property (readonly) Foo *x;
+@property (assign) Foo *w;
+@property Foo *q1, *q2;
+@property (assign) WeakOptOut *oo;
+@property (assign) BadClassForWeak bcw;
+@property (assign) id not_safe1;
+@property () NSObject *not_safe2;
+@property Forw *not_safe3;
+@property (readonly) Foo *assign_plus1;
+@property (readonly) Foo *assign_plus2;
+@property (readonly) Foo *assign_plus3;
+
+@property (assign) Foo *no_user_ivar1;
+@property (readonly) Foo *no_user_ivar2;
+
+@property (retain) id def1;
+@property (atomic,retain) id def2;
+@property (retain,atomic) id def3;
+
+@end
+
+@implementation Foo
+@synthesize x,w,q1,q2,oo,bcw,not_safe1,not_safe2,not_safe3;
+@synthesize no_user_ivar1, no_user_ivar2;
+@synthesize assign_plus1, assign_plus2, assign_plus3;
+@synthesize def1, def2, def3;
+
+-(void)test:(Foo *)parm {
+ assign_plus1 = [[Foo alloc] init];
+ assign_plus2 = [Foo new];
+ assign_plus3 = [parm retain];
+}
+@end
+
+@interface TestExt
+@property (retain,readonly) TestExt *x1;
+@property (readonly) TestExt *x2;
+@end
+
+@interface TestExt()
+@property (retain,readwrite) TestExt *x1;
+@property (readwrite) TestExt *x2;
+@property (retain) TestExt *x3;
+@end
+
+@implementation TestExt
+@synthesize x1, x2, x3;
+@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
new file mode 100644
index 0000000..a255a36
--- /dev/null
+++ b/clang/test/ARCMT/assign-prop-with-arc-runtime.m.result
@@ -0,0 +1,73 @@
+// 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
+// DISABLE: mingw32
+
+#include "Common.h"
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface WeakOptOut
+@end
+
+@class _NSCachedAttributedString;
+typedef _NSCachedAttributedString *BadClassForWeak;
+
+@class Forw;
+
+@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;
+}
+@property (weak, readonly) Foo *x;
+@property (weak) Foo *w;
+@property (weak) Foo *q1, *q2;
+@property (unsafe_unretained) WeakOptOut *oo;
+@property (unsafe_unretained) BadClassForWeak bcw;
+@property (unsafe_unretained) id not_safe1;
+@property (unsafe_unretained) NSObject *not_safe2;
+@property (unsafe_unretained) Forw *not_safe3;
+@property (readonly) Foo *assign_plus1;
+@property (readonly) Foo *assign_plus2;
+@property (readonly) Foo *assign_plus3;
+
+@property (weak) Foo *no_user_ivar1;
+@property (weak, readonly) Foo *no_user_ivar2;
+
+@property (strong) id def1;
+@property (atomic,strong) id def2;
+@property (strong,atomic) id def3;
+
+@end
+
+@implementation Foo
+@synthesize x,w,q1,q2,oo,bcw,not_safe1,not_safe2,not_safe3;
+@synthesize no_user_ivar1, no_user_ivar2;
+@synthesize assign_plus1, assign_plus2, assign_plus3;
+@synthesize def1, def2, def3;
+
+-(void)test:(Foo *)parm {
+ assign_plus1 = [[Foo alloc] init];
+ assign_plus2 = [Foo new];
+ assign_plus3 = parm;
+}
+@end
+
+@interface TestExt
+@property (strong,readonly) TestExt *x1;
+@property (weak, readonly) TestExt *x2;
+@end
+
+@interface TestExt()
+@property (strong,readwrite) TestExt *x1;
+@property (weak, readwrite) TestExt *x2;
+@property (strong) TestExt *x3;
+@end
+
+@implementation TestExt
+@synthesize x1, x2, x3;
+@end
diff --git a/clang/test/ARCMT/atautorelease-2.m b/clang/test/ARCMT/atautorelease-2.m
new file mode 100644
index 0000000..5c2cd6b
--- /dev/null
+++ b/clang/test/ARCMT/atautorelease-2.m
@@ -0,0 +1,30 @@
+// 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
+// DISABLE: mingw32
+
+@interface NSAutoreleasePool
+- drain;
++new;
++alloc;
+-init;
+-autorelease;
+-release;
+@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
new file mode 100644
index 0000000..06bf0d5
--- /dev/null
+++ b/clang/test/ARCMT/atautorelease-2.m.result
@@ -0,0 +1,29 @@
+// 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
+// DISABLE: mingw32
+
+@interface NSAutoreleasePool
+- drain;
++new;
++alloc;
+-init;
+-autorelease;
+-release;
+@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
new file mode 100644
index 0000000..0b6abdf
--- /dev/null
+++ b/clang/test/ARCMT/atautorelease-3.m
@@ -0,0 +1,41 @@
+// 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
+// DISABLE: mingw32
+
+@interface NSAutoreleasePool
+- drain;
++new;
++alloc;
+-init;
+-autorelease;
+- release;
+@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
new file mode 100644
index 0000000..9103de4
--- /dev/null
+++ b/clang/test/ARCMT/atautorelease-3.m.result
@@ -0,0 +1,32 @@
+// 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
+// DISABLE: mingw32
+
+@interface NSAutoreleasePool
+- drain;
++new;
++alloc;
+-init;
+-autorelease;
+- release;
+@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
new file mode 100644
index 0000000..8daf9d6
--- /dev/null
+++ b/clang/test/ARCMT/atautorelease-check.m
@@ -0,0 +1,145 @@
+// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s
+// DISABLE: mingw32
+
+#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;
+
+@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;
+@end
+
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+
+@protocol NSMutableCopying
+- (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+
+@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;
+@end
+
+extern void NSRecycleZone(NSZone *zone);
+
+NS_AUTOMATED_REFCOUNT_UNAVAILABLE
+@interface NSAutoreleasePool : NSObject { // expected-note 13 {{marked unavailable here}}
+@private
+ void *_token;
+ void *_reserved3;
+ void *_reserved2;
+ void *_reserved;
+}
+
++ (void)addObject:(id)anObject;
+
+- (void)addObject:(id)anObject;
+
+- (void)drain;
+
+@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
new file mode 100644
index 0000000..132553b
--- /dev/null
+++ b/clang/test/ARCMT/atautorelease.m
@@ -0,0 +1,62 @@
+// 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
+// DISABLE: mingw32
+
+#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;
+}
+
+@interface Foo : NSObject
+@property (assign) id myProp;
+@end
+
+@implementation Foo
+@synthesize myProp;
+
+-(void)test:(id)p {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [pool drain];
+ self.myProp = p;
+}
+@end
diff --git a/clang/test/ARCMT/atautorelease.m.result b/clang/test/ARCMT/atautorelease.m.result
new file mode 100644
index 0000000..5191f47
--- /dev/null
+++ b/clang/test/ARCMT/atautorelease.m.result
@@ -0,0 +1,61 @@
+// 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
+// DISABLE: mingw32
+
+#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;
+ }
+}
+
+@interface Foo : NSObject
+@property (unsafe_unretained) id myProp;
+@end
+
+@implementation Foo
+@synthesize myProp;
+
+-(void)test:(id)p {
+ @autoreleasepool {
+ }
+ self.myProp = p;
+}
+@end
diff --git a/clang/test/ARCMT/autoreleases.m b/clang/test/ARCMT/autoreleases.m
new file mode 100644
index 0000000..3acddb7
--- /dev/null
+++ b/clang/test/ARCMT/autoreleases.m
@@ -0,0 +1,49 @@
+// 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
+// DISABLE: mingw32
+
+typedef unsigned char BOOL;
+
+@interface NSObject {
+ id isa;
+}
++new;
++alloc;
+-init;
+-autorelease;
+@end
+
+@interface NSAutoreleasePool : NSObject
+- drain;
+@end
+
+@interface A : NSObject {
+@package
+ id object;
+}
+@end
+
+@interface B : NSObject
+- (BOOL)containsSelf:(A*)a;
+@end
+
+@implementation A
+@end
+
+@implementation B
+- (BOOL)containsSelf:(A*)a {
+ return a->object == self;
+}
+@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;
+}
diff --git a/clang/test/ARCMT/autoreleases.m.result b/clang/test/ARCMT/autoreleases.m.result
new file mode 100644
index 0000000..49bc321
--- /dev/null
+++ b/clang/test/ARCMT/autoreleases.m.result
@@ -0,0 +1,49 @@
+// 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
+// DISABLE: mingw32
+
+typedef unsigned char BOOL;
+
+@interface NSObject {
+ id isa;
+}
++new;
++alloc;
+-init;
+-autorelease;
+@end
+
+@interface NSAutoreleasePool : NSObject
+- drain;
+@end
+
+@interface A : NSObject {
+@package
+ id object;
+}
+@end
+
+@interface B : NSObject
+- (BOOL)containsSelf:(A*)a;
+@end
+
+@implementation A
+@end
+
+@implementation B
+- (BOOL)containsSelf:(A*)a {
+ return a->object == self;
+}
+@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;
+}
diff --git a/clang/test/ARCMT/check-api.m b/clang/test/ARCMT/check-api.m
new file mode 100644
index 0000000..11f4313
--- /dev/null
+++ b/clang/test/ARCMT/check-api.m
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-macosx10.7 %s
+
+#include "Common.h"
+
+@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;
+@end
+
+@interface Test
+@end
+
+@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];
+}
+@end
diff --git a/clang/test/ARCMT/check-with-serialized-diag.m b/clang/test/ARCMT/check-with-serialized-diag.m
new file mode 100644
index 0000000..d8073d0
--- /dev/null
+++ b/clang/test/ARCMT/check-with-serialized-diag.m
@@ -0,0 +1,55 @@
+
+@protocol NSObject
+- (id)retain;
+- (unsigned)retainCount;
+- (oneway void)release;
+- (id)autorelease;
+@end
+
+@interface NSObject <NSObject> {}
+- (id)init;
+
++ (id)new;
++ (id)alloc;
+- (void)dealloc;
+
+- (void)finalize;
+
+- (id)copy;
+- (id)mutableCopy;
+@end
+
+@interface A : NSObject
+@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-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:4: error: ARC forbids explicit message send of 'retain'
+// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:32:23 {{.*}}check-with-serialized-diag.m:32:29
+// CHECK-NEXT: Number FIXITs = 0
+// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:4: error: ARC forbids explicit message send of 'retain'
+// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:34:15 {{.*}}check-with-serialized-diag.m:34:21
+// CHECK-NEXT: Number FIXITs = 0
+// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:35:4: error: ARC forbids explicit message send of 'retainCount'
+// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:35:6 {{.*}}check-with-serialized-diag.m:35:17
+// CHECK-NEXT: Number FIXITs = 0
+
diff --git a/clang/test/ARCMT/checking.m b/clang/test/ARCMT/checking.m
new file mode 100644
index 0000000..cf71611
--- /dev/null
+++ b/clang/test/ARCMT/checking.m
@@ -0,0 +1,327 @@
+// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s
+// DISABLE: mingw32
+
+#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;
+
+@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;
+@end
+
+@interface NSObject <NSObject> {}
+- (id)init;
+
++ (id)new;
++ (id)alloc;
+- (void)dealloc;
+
+- (void)finalize;
+
+- (id)copy;
+- (id)mutableCopy;
+@end
+
+typedef const struct __CFString * CFStringRef;
+extern const CFStringRef kUTTypePlainText;
+extern const CFStringRef kUTTypeRTF;
+@class NSString;
+@class A;
+
+struct UnsafeS {
+ A *__unsafe_unretained unsafeObj;
+};
+
+@interface A : NSObject
+- (id)retain;
+- (id)retainCount;
+- (id)autorelease;
+- (id)init;
+- (oneway void)release;
+- (void)dealloc;
+-(void)test;
+-(id)delegate;
+@end
+
+@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; }
+@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}}
+ 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'}}
+ [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}}
+
+ 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; // expected-error {{ARC forbids Objective-C objects in structs or unions}}
+};
+
+@interface B
+-(id)alloc;
+- (id)initWithInt: (int) i;
+@end
+
+void rdar8861761() {
+ B *o1 = [[B alloc] initWithInt:0];
+ B *o2 = [B alloc];
+ [o2 initWithInt:0];
+}
+
+@interface Test13
+- (id) init0;
+- (void) noninit;
+@end
+@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 (id x in collection) { // expected-error {{use of undeclared identifier 'collection'}}
+ x = 0;
+ }
+}
+@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) {
+ // FIXME: Fix this automatically ?
+ switch (cond) {
+ case 0:
+ ;
+ id x; // expected-note {{jump bypasses initialization of retaining variable}}
+
+ case 1: // expected-error {{switch case is in protected scope}}
+ break;
+ }
+}
+
+@class Test8_incomplete;
+@interface Test8_complete @end;
+@interface Test8_super @end;
+@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}}
+@end
+@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}}
+@end
+
+@class Test9_incomplete;
+@interface Test9
+- (Test9_incomplete*) init1; // expected-error {{init methods must return a type related to the receiver type}}
+- (Test9_incomplete*) init2;
+@end
+id test9(Test9 *v) {
+ return [v init1];
+}
+
+// rdar://9491791
+void rdar9491791(int p) {
+ switch (p) {
+ case 3:;
+ NSObject *o = [[NSObject alloc] init]; // expected-note {{jump bypasses initialization of retaining variable}}
+ [o release];
+ break;
+ default: // expected-error {{switch case is in protected scope}}
+ break;
+ }
+}
+
+#define RELEASE_MACRO(x) do { [x release]; } while(1)
+
+// rdar://9504750
+void rdar9504750(id p) {
+ RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message send of 'release'}}
+}
+
+// rdar://8939557
+@interface TestReadonlyProperty : NSObject
+@property(assign,readonly) NSObject *value;
+@end
+
+@implementation TestReadonlyProperty
+@synthesize value;
+- (void)viewDidLoad {
+ value = [NSObject new]; // expected-error {{assigning retained object}}
+}
+@end
+
+// rdar://9601437
+@interface I9601437 {
+ __unsafe_unretained id x;
+}
+-(void)Meth;
+@end
+
+@implementation I9601437
+-(void)Meth {
+ self->x = [NSObject new]; // expected-error {{assigning retained object}}
+}
+@end
diff --git a/clang/test/ARCMT/cxx-checking.mm b/clang/test/ARCMT/cxx-checking.mm
new file mode 100644
index 0000000..9f9e3d8
--- /dev/null
+++ b/clang/test/ARCMT/cxx-checking.mm
@@ -0,0 +1,106 @@
+// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fsyntax-only -fblocks -Warc-abi %s
+// DISABLE: mingw32
+
+// Classes that have an Objective-C object pointer.
+struct HasObjectMember0 { // expected-warning{{'HasObjectMember0' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
+ id x;
+};
+
+struct HasObjectMember1 { // expected-warning{{'HasObjectMember1' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
+ id x[3];
+};
+
+struct HasObjectMember2 { // expected-warning{{'HasObjectMember2' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
+ 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 { // expected-warning{{'HasBlockPointerMember0' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
+ int (^bp)(int);
+};
+
+struct HasBlockPointerMember1 { // expected-warning{{'HasBlockPointerMember1' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
+ int (^bp[2][3])(int);
+};
+
+struct NonPOD {
+ NonPOD(const NonPOD&);
+};
+
+struct HasObjectMemberAndNonPOD0 { // expected-warning{{'HasObjectMemberAndNonPOD0' cannot be shared between ARC and non-ARC code; add a non-trivial copy assignment operator to make it ABI-compatible}} \
+ // expected-warning{{'HasObjectMemberAndNonPOD0' cannot be shared between ARC and non-ARC code; add a non-trivial destructor to make it ABI-compatible}}
+ id x;
+ NonPOD np;
+};
+
+struct HasObjectMemberAndNonPOD1 { // expected-warning{{'HasObjectMemberAndNonPOD1' cannot be shared between ARC and non-ARC code; add a non-trivial copy assignment operator to make it ABI-compatible}} \
+ // expected-warning{{'HasObjectMemberAndNonPOD1' cannot be shared between ARC and non-ARC code; add a non-trivial destructor to make it ABI-compatible}}
+ NonPOD np;
+ id x[3];
+};
+
+struct HasObjectMemberAndNonPOD2 { // expected-warning{{'HasObjectMemberAndNonPOD2' cannot be shared between ARC and non-ARC code; add a non-trivial copy assignment operator to make it ABI-compatible}} \
+ // expected-warning{{'HasObjectMemberAndNonPOD2' cannot be shared between ARC and non-ARC code; add a non-trivial destructor to make it ABI-compatible}}
+ NonPOD np;
+ id x[3][2];
+};
+
+struct HasObjectMemberAndNonPOD3 {
+ HasObjectMemberAndNonPOD3 &operator=(const HasObjectMemberAndNonPOD3&);
+ ~HasObjectMemberAndNonPOD3();
+ NonPOD np;
+ id x[3][2];
+};
+
+struct HasBlockPointerMemberAndNonPOD0 { // expected-warning{{'HasBlockPointerMemberAndNonPOD0' cannot be shared between ARC and non-ARC code; add a non-trivial copy assignment operator to make it ABI-compatible}} \
+// expected-warning{{'HasBlockPointerMemberAndNonPOD0' cannot be shared between ARC and non-ARC code; add a non-trivial destructor to make it ABI-compatible}}
+ NonPOD np;
+ int (^bp)(int);
+};
+
+struct HasBlockPointerMemberAndNonPOD1 { // expected-warning{{'HasBlockPointerMemberAndNonPOD1' cannot be shared between ARC and non-ARC code; add a non-trivial copy assignment operator to make it ABI-compatible}} \
+// expected-warning{{'HasBlockPointerMemberAndNonPOD1' cannot be shared between ARC and non-ARC code; add a non-trivial destructor to make it ABI-compatible}}
+ 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 non-POD element type 'id __strong[]'}}
+};
+
+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
new file mode 100644
index 0000000..92bb718
--- /dev/null
+++ b/clang/test/ARCMT/cxx-rewrite.mm
@@ -0,0 +1,34 @@
+// 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
+// DISABLE: mingw32
+
+#include "Common.h"
+
+@interface NSString : NSObject
++(id)string;
+@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
new file mode 100644
index 0000000..a2dc9a5
--- /dev/null
+++ b/clang/test/ARCMT/cxx-rewrite.mm.result
@@ -0,0 +1,32 @@
+// 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
+// DISABLE: mingw32
+
+#include "Common.h"
+
+@interface NSString : NSObject
++(id)string;
+@end
+
+struct foo {
+ NSString *s;
+ foo(NSString *s): s(s){
+ @autoreleasepool {
+ [NSString string];
+ }
+ }
+ ~foo(){ s; }
+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
new file mode 100644
index 0000000..34df1a4
--- /dev/null
+++ b/clang/test/ARCMT/dealloc.m
@@ -0,0 +1,25 @@
+// 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
+// DISABLE: mingw32
+
+@interface A
+- (id)retain;
+- (id)autorelease;
+- (oneway void)release;
+- (void)dealloc;
+@end
+
+void test1(A *a) {
+ [a dealloc];
+}
+
+@interface Test2 : A
+- (void) dealloc;
+@end
+
+@implementation Test2
+- (void) dealloc {
+ [super dealloc];
+}
+@end
diff --git a/clang/test/ARCMT/dealloc.m.result b/clang/test/ARCMT/dealloc.m.result
new file mode 100644
index 0000000..3ff2885
--- /dev/null
+++ b/clang/test/ARCMT/dealloc.m.result
@@ -0,0 +1,21 @@
+// 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
+// DISABLE: mingw32
+
+@interface A
+- (id)retain;
+- (id)autorelease;
+- (oneway void)release;
+- (void)dealloc;
+@end
+
+void test1(A *a) {
+}
+
+@interface Test2 : A
+- (void) dealloc;
+@end
+
+@implementation Test2
+@end
diff --git a/clang/test/ARCMT/dispatch.m b/clang/test/ARCMT/dispatch.m
new file mode 100644
index 0000000..75c4a83
--- /dev/null
+++ b/clang/test/ARCMT/dispatch.m
@@ -0,0 +1,29 @@
+// 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"
+
+#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);
+
+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
new file mode 100644
index 0000000..e897672
--- /dev/null
+++ b/clang/test/ARCMT/dispatch.m.result
@@ -0,0 +1,25 @@
+// 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"
+
+#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);
+
+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
new file mode 100644
index 0000000..a912ad9
--- /dev/null
+++ b/clang/test/ARCMT/driver-migrate.m
@@ -0,0 +1,12 @@
+// RUN: %clang -### -ccc-arcmt-migrate /foo/bar -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: "-arcmt-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)?"}}
diff --git a/clang/test/ARCMT/init.m b/clang/test/ARCMT/init.m
new file mode 100644
index 0000000..9dbb1f8
--- /dev/null
+++ b/clang/test/ARCMT/init.m
@@ -0,0 +1,40 @@
+// 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
+// DISABLE: mingw32
+
+#define nil (void *)0
+
+@interface NSObject
+-init;
+@end
+
+@interface A : NSObject
+-init;
+-init2;
+-foo;
++alloc;
+@end
+
+@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;
+}
+@end
diff --git a/clang/test/ARCMT/init.m.result b/clang/test/ARCMT/init.m.result
new file mode 100644
index 0000000..d7f7300
--- /dev/null
+++ b/clang/test/ARCMT/init.m.result
@@ -0,0 +1,40 @@
+// 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
+// DISABLE: mingw32
+
+#define nil (void *)0
+
+@interface NSObject
+-init;
+@end
+
+@interface A : NSObject
+-init;
+-init2;
+-foo;
++alloc;
+@end
+
+@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;
+}
+@end
diff --git a/clang/test/ARCMT/migrate-emit-errors.m b/clang/test/ARCMT/migrate-emit-errors.m
new file mode 100644
index 0000000..95c0d2f
--- /dev/null
+++ b/clang/test/ARCMT/migrate-emit-errors.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t -arcmt-migrate-emit-errors %s 2>&1 | FileCheck %s
+// RUN: rm -rf %t
+
+@protocol NSObject
+- (oneway void)release;
+@end
+
+void test(id p) {
+ [p release];
+}
+
+// CHECK: error: ARC forbids explicit message send of 'release' \ No newline at end of file
diff --git a/clang/test/ARCMT/migrate-plist-output.m b/clang/test/ARCMT/migrate-plist-output.m
new file mode 100644
index 0000000..12efa93
--- /dev/null
+++ b/clang/test/ARCMT/migrate-plist-output.m
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -arcmt-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
+
+@protocol NSObject
+- (oneway void)release;
+@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 &apos;release&apos;</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>4</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>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </plist>
+
+// DISABLE: mingw32
diff --git a/clang/test/ARCMT/migrate-space-in-path.m b/clang/test/ARCMT/migrate-space-in-path.m
new file mode 100644
index 0000000..89dfe14
--- /dev/null
+++ b/clang/test/ARCMT/migrate-space-in-path.m
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t.migrate
+// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t.migrate %S/"with space"/test1.m.in -x objective-c
+// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t.migrate %S/"with space"/test2.m.in -x objective-c
+// RUN: c-arcmt-test -mt-migrate-directory %t.migrate | arcmt-test -verify-transformed-files %S/"with space"/test1.m.in.result %S/"with space"/test2.m.in.result %S/"with space"/test.h.result
+// RUN: rm -rf %t.migrate
+// DISABLE: mingw32
diff --git a/clang/test/ARCMT/migrate.m b/clang/test/ARCMT/migrate.m
new file mode 100644
index 0000000..6f41258
--- /dev/null
+++ b/clang/test/ARCMT/migrate.m
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t %S/Inputs/test1.m.in -x objective-c
+// RUN: %clang_cc1 -arcmt-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
+// DISABLE: mingw32
diff --git a/clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m b/clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
new file mode 100644
index 0000000..81841fb
--- /dev/null
+++ b/clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -arcmt-check -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -verify %s
+// DISABLE: mingw32
+// rdar://10387088
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
+
+extern
+CFTypeRef CFRetain(CFTypeRef cf);
+
+@interface INTF
+{
+ void *cf_format;
+ id objc_format;
+}
+@end
+
+@interface NSString
++ (id)stringWithFormat:(NSString *)format;
+@end
+
+@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
+}
+@end
+
diff --git a/clang/test/ARCMT/nonobjc-to-objc-cast-2.m b/clang/test/ARCMT/nonobjc-to-objc-cast-2.m
new file mode 100644
index 0000000..1ec0089
--- /dev/null
+++ b/clang/test/ARCMT/nonobjc-to-objc-cast-2.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s
+// DISABLE: mingw32
+
+#include "Common.h"
+
+@interface NSString : NSObject
+-(id)string;
+-(id)newString;
+@end
+
+typedef const struct __CFString * CFStringRef;
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
+
+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() {
+ 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}}
+}
diff --git a/clang/test/ARCMT/nonobjc-to-objc-cast.m b/clang/test/ARCMT/nonobjc-to-objc-cast.m
new file mode 100644
index 0000000..fcdcd89
--- /dev/null
+++ b/clang/test/ARCMT/nonobjc-to-objc-cast.m
@@ -0,0 +1,62 @@
+// 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
+// DISABLE: mingw32
+
+#include "Common.h"
+
+@interface NSString : NSObject
+-(id)string;
+-(id)newString;
+@end
+
+typedef const struct __CFString * CFStringRef;
+extern const CFStringRef kUTTypePlainText;
+extern const CFStringRef kUTTypeRTF;
+
+typedef const struct __CFAllocator * CFAllocatorRef;
+typedef const struct __CFUUID * CFUUIDRef;
+
+extern const CFAllocatorRef kCFAllocatorDefault;
+
+extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid);
+
+void f(BOOL b, id p) {
+ NSString *str = (NSString *)kUTTypePlainText;
+ str = b ? kUTTypeRTF : kUTTypePlainText;
+ str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText);
+ str = (NSString *)p; // no change.
+
+ CFUUIDRef _uuid;
+ NSString *_uuidString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid);
+ _uuidString = [(NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid) autorelease];
+ _uuidString = CFRetain(_uuid);
+}
+
+@implementation NSString (StrExt)
+- (NSString *)stringEscapedAsURI {
+ CFStringRef str = (CFStringRef)self;
+ CFStringRef str2 = self;
+ return self;
+}
+@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
new file mode 100644
index 0000000..b50a948
--- /dev/null
+++ b/clang/test/ARCMT/nonobjc-to-objc-cast.m.result
@@ -0,0 +1,62 @@
+// 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
+// DISABLE: mingw32
+
+#include "Common.h"
+
+@interface NSString : NSObject
+-(id)string;
+-(id)newString;
+@end
+
+typedef const struct __CFString * CFStringRef;
+extern const CFStringRef kUTTypePlainText;
+extern const CFStringRef kUTTypeRTF;
+
+typedef const struct __CFAllocator * CFAllocatorRef;
+typedef const struct __CFUUID * CFUUIDRef;
+
+extern const CFAllocatorRef kCFAllocatorDefault;
+
+extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid);
+
+void f(BOOL b, id p) {
+ NSString *str = (__bridge NSString *)kUTTypePlainText;
+ str = (__bridge NSString *)(b ? kUTTypeRTF : kUTTypePlainText);
+ str = (__bridge NSString *)(b ? kUTTypeRTF : kUTTypePlainText);
+ str = (NSString *)p; // no change.
+
+ CFUUIDRef _uuid;
+ NSString *_uuidString = (__bridge_transfer NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid);
+ _uuidString = (__bridge_transfer NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid);
+ _uuidString = (__bridge_transfer NSString *)(CFRetain(_uuid));
+}
+
+@implementation NSString (StrExt)
+- (NSString *)stringEscapedAsURI {
+ CFStringRef str = (__bridge CFStringRef)self;
+ CFStringRef str2 = (__bridge CFStringRef)(self);
+ return self;
+}
+@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 = (__bridge_retained CFStringRef)([NSString new]);
+ ref = (__bridge_retained CFStringRef)([s newString]);
+ ref = (__bridge_retained CFStringRef)[NSString new];
+ ref = (__bridge_retained CFStringRef)([[NSString alloc] init]);
+ ref = (__bridge_retained CFStringRef)([s string]);
+ ref = (__bridge_retained CFStringRef)[s string];
+ ref = (__bridge_retained CFTypeRef)([s string]);
+ ref = (__bridge_retained CFTypeRef)(s);
+ ref = (__bridge_retained CFStringRef)(s);
+
+ consumeParam((__bridge_retained CFStringRef)s);
+ consumeParam((__bridge_retained CFStringRef)(s));
+}
diff --git a/clang/test/ARCMT/objcmt-numeric-literals.m b/clang/test/ARCMT/objcmt-numeric-literals.m
new file mode 100644
index 0000000..b86af4d
--- /dev/null
+++ b/clang/test/ARCMT/objcmt-numeric-literals.m
@@ -0,0 +1,501 @@
+// 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
+
+#define YES __objc_yes
+#define NO __objc_no
+
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+typedef signed char BOOL;
+#define nil ((void*) 0)
+
+@interface NSObject
++ (id)alloc;
+@end
+
+@interface NSNumber : NSObject
+@end
+
+@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;
+@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
new file mode 100644
index 0000000..1c4187a
--- /dev/null
+++ b/clang/test/ARCMT/objcmt-numeric-literals.m.result
@@ -0,0 +1,501 @@
+// 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
+
+#define YES __objc_yes
+#define NO __objc_no
+
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+typedef signed char BOOL;
+#define nil ((void*) 0)
+
+@interface NSObject
++ (id)alloc;
+@end
+
+@interface NSNumber : NSObject
+@end
+
+@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;
+@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];
+ [NSNumber numberWithInteger: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];
+ [NSNumber numberWithUnsignedInteger:VAL_UINT];
+}
diff --git a/clang/test/ARCMT/objcmt-subscripting-literals.m b/clang/test/ARCMT/objcmt-subscripting-literals.m
new file mode 100644
index 0000000..3d26efe
--- /dev/null
+++ b/clang/test/ARCMT/objcmt-subscripting-literals.m
@@ -0,0 +1,137 @@
+// 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
+
+typedef signed char BOOL;
+#define nil ((void*) 0)
+
+@interface NSObject
++ (id)alloc;
+@end
+
+@interface NSString : NSObject
++ (id)stringWithString:(NSString *)string;
+- (id)initWithString:(NSString *)aString;
+@end
+
+@interface NSArray : NSObject
+- (id)objectAtIndex:(unsigned long)index;
+- (id)objectAtIndexedSubscript:(int)index;
+@end
+
+@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;
+
+- (id)objectAtIndex:(unsigned long)index;
+@end
+
+@interface NSMutableArray : NSArray
+- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary : NSObject
+- (id)objectForKeyedSubscript:(id)key;
+@end
+
+@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;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)anObject forKey:(id)aKey;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@interface NSNumber : NSObject
+@end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+#define M(x) (x)
+#define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
+#define TWO(x) ((x), (x))
+
+@interface I
+@end
+@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 = [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];
+}
+@end
diff --git a/clang/test/ARCMT/objcmt-subscripting-literals.m.result b/clang/test/ARCMT/objcmt-subscripting-literals.m.result
new file mode 100644
index 0000000..8ac6dcc
--- /dev/null
+++ b/clang/test/ARCMT/objcmt-subscripting-literals.m.result
@@ -0,0 +1,137 @@
+// 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
+
+typedef signed char BOOL;
+#define nil ((void*) 0)
+
+@interface NSObject
++ (id)alloc;
+@end
+
+@interface NSString : NSObject
++ (id)stringWithString:(NSString *)string;
+- (id)initWithString:(NSString *)aString;
+@end
+
+@interface NSArray : NSObject
+- (id)objectAtIndex:(unsigned long)index;
+- (id)objectAtIndexedSubscript:(int)index;
+@end
+
+@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;
+
+- (id)objectAtIndex:(unsigned long)index;
+@end
+
+@interface NSMutableArray : NSArray
+- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary : NSObject
+- (id)objectForKeyedSubscript:(id)key;
+@end
+
+@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;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)anObject forKey:(id)aKey;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@interface NSNumber : NSObject
+@end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+#define M(x) (x)
+#define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
+#define TWO(x) ((x), (x))
+
+@interface I
+@end
+@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 = @{@"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];
+}
+@end
diff --git a/clang/test/ARCMT/releases-driver.m b/clang/test/ARCMT/releases-driver.m
new file mode 100644
index 0000000..b75432a
--- /dev/null
+++ b/clang/test/ARCMT/releases-driver.m
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
+// RUN: cp %s %t
+// RUN: %clang_cc1 -arcmt-modify -triple x86_64-apple-macosx10.6 -x objective-c %t
+// RUN: diff %t %s.result
+// RUN: rm %t
+
+typedef int BOOL;
+
+id IhaveSideEffect();
+
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+- (oneway void)release;
+@end
+
+@interface NSObject <NSObject> {}
+@end
+
+@interface Foo : NSObject {
+ id bar;
+}
+@property (retain) id bar;
+-(void)test:(id)obj;
+@end
+
+@implementation Foo
+
+@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;
+}
+
+@end
+
+void func(Foo *p) {
+ [p release];
+ (([p release]));
+}
+
+@interface Baz {
+ id <NSObject> _foo;
+}
+@end
+
+@implementation Baz
+- dealloc {
+ [_foo release];
+ return 0;
+}
+@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
new file mode 100644
index 0000000..70c0aec
--- /dev/null
+++ b/clang/test/ARCMT/releases-driver.m.result
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
+// RUN: cp %s %t
+// RUN: %clang_cc1 -arcmt-modify -triple x86_64-apple-macosx10.6 -x objective-c %t
+// RUN: diff %t %s.result
+// RUN: rm %t
+
+typedef int BOOL;
+
+id IhaveSideEffect();
+
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+- (oneway void)release;
+@end
+
+@interface NSObject <NSObject> {}
+@end
+
+@interface Foo : NSObject {
+ id bar;
+}
+@property (strong) id bar;
+-(void)test:(id)obj;
+@end
+
+@implementation Foo
+
+@synthesize bar;
+
+-(void)test:(id)obj {
+ id x = self.bar;
+ self.bar = obj;
+ // do stuff with x;
+
+ IhaveSideEffect();
+
+ x = 0;
+}
+
+@end
+
+void func(Foo *p) {
+}
+
+@interface Baz {
+ id <NSObject> _foo;
+}
+@end
+
+@implementation Baz
+- dealloc {
+ return 0;
+}
+@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
new file mode 100644
index 0000000..867fab9
--- /dev/null
+++ b/clang/test/ARCMT/releases.m
@@ -0,0 +1,99 @@
+// 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();
+
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+- (oneway void)release;
+@end
+
+@interface NSObject <NSObject> {}
+@end
+
+@interface Foo : NSObject {
+ id bar;
+}
+@property (retain) id bar;
+-(void)test:(id)obj;
+@end
+
+@implementation Foo
+
+@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];
+ }
+}
+
+@end
+
+void func(Foo *p) {
+ [p release];
+ (([p release]));
+}
+
+@interface Baz {
+ id <NSObject> _foo;
+}
+@end
+
+@implementation Baz
+- dealloc {
+ [_foo release];
+ return 0;
+}
+@end
+
+void block_test(Foo *p) {
+ id (^B)() = ^() {
+ if (p) {
+ id (^IB)() = ^() {
+ 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);
+}
+
+@implementation Foo2
+
+static id internal_var = 0;
+
++ (void)setIt:(id)newone {
+ if (internal_var != newone) {
+ [internal_var release];
+ internal_var = [newone retain];
+ }
+}
+@end
diff --git a/clang/test/ARCMT/releases.m.result b/clang/test/ARCMT/releases.m.result
new file mode 100644
index 0000000..556610a
--- /dev/null
+++ b/clang/test/ARCMT/releases.m.result
@@ -0,0 +1,90 @@
+// 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();
+
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+- (oneway void)release;
+@end
+
+@interface NSObject <NSObject> {}
+@end
+
+@interface Foo : NSObject {
+ id bar;
+}
+@property (strong) id bar;
+-(void)test:(id)obj;
+@end
+
+@implementation Foo
+
+@synthesize bar;
+
+-(void)test:(id)obj {
+ id x = self.bar;
+ self.bar = obj;
+ // do stuff with x;
+
+ IhaveSideEffect();
+
+ x = 0;
+
+ @try {
+ } @finally {
+ x = nil;
+ }
+}
+
+@end
+
+void func(Foo *p) {
+}
+
+@interface Baz {
+ id <NSObject> _foo;
+}
+@end
+
+@implementation Baz
+- dealloc {
+ return 0;
+}
+@end
+
+void block_test(Foo *p) {
+ id (^B)() = ^() {
+ if (p) {
+ id (^IB)() = ^() {
+ 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) {
+}
+
+@implementation Foo2
+
+static id internal_var = 0;
+
++ (void)setIt:(id)newone {
+ if (internal_var != newone) {
+ internal_var = newone;
+ }
+}
+@end
diff --git a/clang/test/ARCMT/remove-dealloc-method.m b/clang/test/ARCMT/remove-dealloc-method.m
new file mode 100644
index 0000000..8e39fc8
--- /dev/null
+++ b/clang/test/ARCMT/remove-dealloc-method.m
@@ -0,0 +1,26 @@
+// 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)
+
+@interface Foo
+@property (retain) id x;
+@property (retain) id y;
+@property (retain) id w;
+@property (retain) id z;
+@end
+
+@implementation Foo
+@synthesize x;
+@synthesize y;
+@synthesize w;
+@synthesize z;
+
+- (void) dealloc {
+ self.x = 0;
+ [self setY:nil];
+ w = nil;
+ self.z = nil;
+}
+@end
diff --git a/clang/test/ARCMT/remove-dealloc-method.m.result b/clang/test/ARCMT/remove-dealloc-method.m.result
new file mode 100644
index 0000000..47e31f9
--- /dev/null
+++ b/clang/test/ARCMT/remove-dealloc-method.m.result
@@ -0,0 +1,20 @@
+// 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)
+
+@interface Foo
+@property (strong) id x;
+@property (strong) id y;
+@property (strong) id w;
+@property (strong) id z;
+@end
+
+@implementation Foo
+@synthesize x;
+@synthesize y;
+@synthesize w;
+@synthesize z;
+
+@end
diff --git a/clang/test/ARCMT/remove-dealloc-zerouts.m b/clang/test/ARCMT/remove-dealloc-zerouts.m
new file mode 100644
index 0000000..4176ec5
--- /dev/null
+++ b/clang/test/ARCMT/remove-dealloc-zerouts.m
@@ -0,0 +1,44 @@
+// 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
+
+@interface Foo
+@property (retain) id x;
+@property (retain) id y;
+@property (retain) id w;
+@property (retain) id z;
+@property (strong) id q;
+@end
+
+@implementation Foo
+@synthesize x;
+@synthesize y;
+@synthesize w;
+@synthesize q;
+@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;
+}
+@end
+
+@interface Bar
+@property (retain) Foo *a;
+- (void) setA:(Foo*) val;
+- (id) a;
+@end
+
+@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.
+}
+@synthesize a;
+- (void) setA:(Foo*) val { }
+- (id) a {return 0;}
+@end
diff --git a/clang/test/ARCMT/remove-dealloc-zerouts.m.result b/clang/test/ARCMT/remove-dealloc-zerouts.m.result
new file mode 100644
index 0000000..9ae831a
--- /dev/null
+++ b/clang/test/ARCMT/remove-dealloc-zerouts.m.result
@@ -0,0 +1,39 @@
+// 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
+
+@interface Foo
+@property (strong) id x;
+@property (strong) id y;
+@property (strong) id w;
+@property (strong) id z;
+@property (strong) id q;
+@end
+
+@implementation Foo
+@synthesize x;
+@synthesize y;
+@synthesize w;
+@synthesize q;
+@dynamic z;
+
+- (void) dealloc {
+ self.z = 0;
+}
+@end
+
+@interface Bar
+@property (strong) Foo *a;
+- (void) setA:(Foo*) val;
+- (id) a;
+@end
+
+@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.
+}
+@synthesize a;
+- (void) setA:(Foo*) val { }
+- (id) a {return 0;}
+@end
diff --git a/clang/test/ARCMT/remove-statements.m b/clang/test/ARCMT/remove-statements.m
new file mode 100644
index 0000000..286a8e7
--- /dev/null
+++ b/clang/test/ARCMT/remove-statements.m
@@ -0,0 +1,45 @@
+// 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"
+
+@interface myController : NSObject
+-(id)test:(id)x;
+@end
+
+#define MY_MACRO1(x)
+#define MY_MACRO2(x) (void)x
+
+@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);
+}
+@end
diff --git a/clang/test/ARCMT/remove-statements.m.result b/clang/test/ARCMT/remove-statements.m.result
new file mode 100644
index 0000000..6a4ea08
--- /dev/null
+++ b/clang/test/ARCMT/remove-statements.m.result
@@ -0,0 +1,38 @@
+// 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"
+
+@interface myController : NSObject
+-(id)test:(id)x;
+@end
+
+#define MY_MACRO1(x)
+#define MY_MACRO2(x) (void)x
+
+@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);
+}
+@end
diff --git a/clang/test/ARCMT/retains.m b/clang/test/ARCMT/retains.m
new file mode 100644
index 0000000..60283a6
--- /dev/null
+++ b/clang/test/ARCMT/retains.m
@@ -0,0 +1,71 @@
+// 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();
+
+@interface Foo : NSObject {
+ id bar;
+}
+@property (retain) id bar;
+-(id)test:(id)obj;
+-(id)something;
+@end
+
+#define Something_Macro(key, comment) \
+ [[Foo new] something]
+
+@implementation Foo
+
+@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])));
+}
+@end
+
+id foo (Foo *p) {
+ p = [p retain];
+ return ([p retain]);
+}
+
+void block_tests(Foo *p) {
+ id (^B)() = ^() {
+ if (p) {
+ id (^IB)() = ^() {
+ 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
new file mode 100644
index 0000000..2011e50
--- /dev/null
+++ b/clang/test/ARCMT/retains.m.result
@@ -0,0 +1,65 @@
+// 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();
+
+@interface Foo : NSObject {
+ id bar;
+}
+@property (strong) id bar;
+-(id)test:(id)obj;
+-(id)something;
+@end
+
+#define Something_Macro(key, comment) \
+ [[Foo new] something]
+
+@implementation Foo
+
+@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)));
+}
+@end
+
+id foo (Foo *p) {
+ p = p;
+ return (p);
+}
+
+void block_tests(Foo *p) {
+ id (^B)() = ^() {
+ if (p) {
+ id (^IB)() = ^() {
+ 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
new file mode 100644
index 0000000..538f16c
--- /dev/null
+++ b/clang/test/ARCMT/rewrite-block-var.m
@@ -0,0 +1,45 @@
+// 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"
+
+@interface Foo : NSObject
+-(Foo *)something;
+@end
+
+void bar(void (^block)());
+
+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
new file mode 100644
index 0000000..a9d0b0f
--- /dev/null
+++ b/clang/test/ARCMT/rewrite-block-var.m.result
@@ -0,0 +1,45 @@
+// 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"
+
+@interface Foo : NSObject
+-(Foo *)something;
+@end
+
+void bar(void (^block)());
+
+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
new file mode 100644
index 0000000..4a0a575
--- /dev/null
+++ b/clang/test/ARCMT/safe-arc-assign.m
@@ -0,0 +1,14 @@
+// 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
new file mode 100644
index 0000000..c25955e
--- /dev/null
+++ b/clang/test/ARCMT/safe-arc-assign.m.result
@@ -0,0 +1,14 @@
+// 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/with space/test.h b/clang/test/ARCMT/with space/test.h
new file mode 100644
index 0000000..756295f
--- /dev/null
+++ b/clang/test/ARCMT/with space/test.h
@@ -0,0 +1,15 @@
+@protocol NSObject
+- (oneway void)release;
+@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/with space/test.h.result b/clang/test/ARCMT/with space/test.h.result
new file mode 100644
index 0000000..0638a33
--- /dev/null
+++ b/clang/test/ARCMT/with space/test.h.result
@@ -0,0 +1,13 @@
+@protocol NSObject
+- (oneway void)release;
+@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/with space/test1.m.in b/clang/test/ARCMT/with space/test1.m.in
new file mode 100644
index 0000000..8416a88
--- /dev/null
+++ b/clang/test/ARCMT/with space/test1.m.in
@@ -0,0 +1,6 @@
+#define PART1
+#include "test.h"
+
+void test1(id p) {
+ [p release];
+}
diff --git a/clang/test/ARCMT/with space/test1.m.in.result b/clang/test/ARCMT/with space/test1.m.in.result
new file mode 100644
index 0000000..f351fe6
--- /dev/null
+++ b/clang/test/ARCMT/with space/test1.m.in.result
@@ -0,0 +1,5 @@
+#define PART1
+#include "test.h"
+
+void test1(id p) {
+}
diff --git a/clang/test/ARCMT/with space/test2.m.in b/clang/test/ARCMT/with space/test2.m.in
new file mode 100644
index 0000000..99f87b0
--- /dev/null
+++ b/clang/test/ARCMT/with space/test2.m.in
@@ -0,0 +1,6 @@
+#define PART2
+#include "test.h"
+
+void test2(id p) {
+ [p release];
+}
diff --git a/clang/test/ARCMT/with space/test2.m.in.result b/clang/test/ARCMT/with space/test2.m.in.result
new file mode 100644
index 0000000..f8e918c
--- /dev/null
+++ b/clang/test/ARCMT/with space/test2.m.in.result
@@ -0,0 +1,5 @@
+#define PART2
+#include "test.h"
+
+void test2(id p) {
+}
diff --git a/clang/test/ARCMT/with-arc-mode-check.m b/clang/test/ARCMT/with-arc-mode-check.m
new file mode 100644
index 0000000..33f31f5
--- /dev/null
+++ b/clang/test/ARCMT/with-arc-mode-check.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -arcmt-check -fsyntax-only -fobjc-arc -x objective-c %s
+
+@protocol NSObject
+- (oneway void)release;
+@end
+
+void test1(id p) {
+ [p release];
+}
diff --git a/clang/test/ARCMT/with-arc-mode-migrate.m b/clang/test/ARCMT/with-arc-mode-migrate.m
new file mode 100644
index 0000000..4688594
--- /dev/null
+++ b/clang/test/ARCMT/with-arc-mode-migrate.m
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
+// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t -fsyntax-only -fobjc-arc %s
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+// RUN: rm -rf %t
+
+@protocol NSObject
+- (oneway void)release;
+@end
+
+void test1(id p) {
+ [p release];
+}
diff --git a/clang/test/ARCMT/with-arc-mode-migrate.m.result b/clang/test/ARCMT/with-arc-mode-migrate.m.result
new file mode 100644
index 0000000..dd34b99
--- /dev/null
+++ b/clang/test/ARCMT/with-arc-mode-migrate.m.result
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
+// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t -fsyntax-only -fobjc-arc %s
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+// RUN: rm -rf %t
+
+@protocol NSObject
+- (oneway void)release;
+@end
+
+void test1(id p) {
+}
diff --git a/clang/test/ARCMT/with-arc-mode-modify.m b/clang/test/ARCMT/with-arc-mode-modify.m
new file mode 100644
index 0000000..fbbd630
--- /dev/null
+++ b/clang/test/ARCMT/with-arc-mode-modify.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
+// RUN: cp %s %t
+// RUN: %clang_cc1 -arcmt-modify -fsyntax-only -fobjc-arc -x objective-c %t
+// RUN: diff %t %s.result
+// RUN: rm %t
+
+@protocol NSObject
+- (oneway void)release;
+@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
new file mode 100644
index 0000000..631f276
--- /dev/null
+++ b/clang/test/ARCMT/with-arc-mode-modify.m.result
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
+// RUN: cp %s %t
+// RUN: %clang_cc1 -arcmt-modify -fsyntax-only -fobjc-arc -x objective-c %t
+// RUN: diff %t %s.result
+// RUN: rm %t
+
+@protocol NSObject
+- (oneway void)release;
+@end
+
+void test1(id p) {
+}
diff --git a/clang/test/ASTMerge/Inputs/category1.m b/clang/test/ASTMerge/Inputs/category1.m
new file mode 100644
index 0000000..afcaab8
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/category1.m
@@ -0,0 +1,48 @@
+@interface I1
+@end
+
+// Matching category
+@interface I1 (Cat1)
+- (int)method0;
+@end
+
+// Matching class extension
+@interface I1 ()
+- (int)method1;
+@end
+
+// Mismatched category
+@interface I1 (Cat2)
+- (int)method2;
+@end
+
+@interface I2
+@end
+
+// Mismatched class extension
+@interface I2 ()
+- (int)method3;
+@end
+
+// Category with implementation
+@interface I2 (Cat3)
+@end
+
+@implementation I2 (Cat3)
+@end
+
+// Category with implementation
+@interface I2 (Cat4)
+@end
+
+@implementation I2 (Cat4)
+@end
+
+// Category with mismatched implementation
+@interface I2 (Cat6)
+@end
+
+@implementation I2 (Cat6)
+- (float)blah { return 0; }
+@end
+
diff --git a/clang/test/ASTMerge/Inputs/category2.m b/clang/test/ASTMerge/Inputs/category2.m
new file mode 100644
index 0000000..49a3c27
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/category2.m
@@ -0,0 +1,49 @@
+typedef int Int;
+
+@interface I1
+@end
+
+// Matching category
+@interface I1 (Cat1)
+- (Int)method0;
+@end
+
+// Matching class extension
+@interface I1 ()
+- (Int)method1;
+@end
+
+// Mismatched category
+@interface I1 (Cat2)
+- (float)method2;
+@end
+
+@interface I2
+@end
+
+// Mismatched class extension
+@interface I2 ()
+- (float)method3;
+@end
+
+// Category with implementation
+@interface I2 (Cat3)
+@end
+
+@implementation I2 (Cat3)
+@end
+
+// Category with implementation
+@interface I2 (Cat5)
+@end
+
+@implementation I2 (Cat5)
+@end
+
+// Category with mismatched implementation
+@interface I2 (Cat6)
+@end
+
+@implementation I2 (Cat6)
+- (int)blah { return 0; }
+@end
diff --git a/clang/test/ASTMerge/Inputs/class-template1.cpp b/clang/test/ASTMerge/Inputs/class-template1.cpp
new file mode 100644
index 0000000..440b5ab
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/class-template1.cpp
@@ -0,0 +1,34 @@
+template<typename T>
+struct X0;
+
+template<int I>
+struct X1;
+
+template<int I>
+struct X2;
+
+template<int I>
+struct X3;
+
+template<template<int I> class>
+struct X4;
+
+template<template<long> class>
+struct X5;
+
+template<typename>
+struct X6;
+
+extern X0<int> *x0i;
+extern X0<long> *x0l;
+extern X0<float> *x0r;
+
+template<>
+struct X0<char> {
+ int member;
+};
+
+template<>
+struct X0<wchar_t> {
+ int member;
+};
diff --git a/clang/test/ASTMerge/Inputs/class-template2.cpp b/clang/test/ASTMerge/Inputs/class-template2.cpp
new file mode 100644
index 0000000..6300301
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/class-template2.cpp
@@ -0,0 +1,35 @@
+template<class T>
+struct X0;
+
+template<int I>
+struct X1;
+
+template<long I>
+struct X2;
+
+template<typename>
+struct X3;
+
+template<template<int I> class>
+struct X4;
+
+template<template<int I> class>
+struct X5;
+
+template<template<int I> class>
+struct X6;
+
+typedef int Integer;
+extern X0<Integer> *x0i;
+extern X0<float> *x0f;
+extern X0<double> *x0r;
+
+template<>
+struct X0<char> {
+ int member;
+};
+
+template<>
+struct X0<wchar_t> {
+ float member;
+};
diff --git a/clang/test/ASTMerge/Inputs/class1.cpp b/clang/test/ASTMerge/Inputs/class1.cpp
new file mode 100644
index 0000000..b600cdb
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/class1.cpp
@@ -0,0 +1,15 @@
+struct A {
+ int x;
+};
+
+struct B : A {
+ float y;
+ float foo();
+};
+
+struct C {
+ C(int i = 10);
+ C(const C&);
+ C &operator=(C&);
+ ~C();
+};
diff --git a/clang/test/ASTMerge/Inputs/class2.cpp b/clang/test/ASTMerge/Inputs/class2.cpp
new file mode 100644
index 0000000..fa38916
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/class2.cpp
@@ -0,0 +1,9 @@
+struct A {
+ int x;
+};
+
+struct B : A {
+ int y;
+ int foo();
+};
+
diff --git a/clang/test/ASTMerge/Inputs/enum1.c b/clang/test/ASTMerge/Inputs/enum1.c
new file mode 100644
index 0000000..f2b9c5c
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/enum1.c
@@ -0,0 +1,42 @@
+// Matching
+enum E1 {
+ E1Enumerator1,
+ E1Enumerator2 = 3,
+ E1Enumerator3
+} x1;
+
+// Value mismatch
+enum E2 {
+ E2Enumerator1,
+ E2Enumerator2 = 3,
+ E2Enumerator3
+} x2;
+
+// Name mismatch
+enum E3 {
+ E3Enumerator1,
+ E3Enumerator2 = 3,
+ E3Enumerator3
+} x3;
+
+// Missing enumerator
+enum E4 {
+ E4Enumerator1,
+ E4Enumerator2,
+ E4Enumerator3
+} x4;
+
+// Extra enumerator
+enum E5 {
+ E5Enumerator1,
+ E5Enumerator2,
+ E5Enumerator3
+} x5;
+
+// Matching, with typedef
+typedef enum {
+ E6Enumerator1,
+ E6Enumerator2
+} E6;
+
+E6 x6;
diff --git a/clang/test/ASTMerge/Inputs/enum2.c b/clang/test/ASTMerge/Inputs/enum2.c
new file mode 100644
index 0000000..315b4dc
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/enum2.c
@@ -0,0 +1,42 @@
+// Matching
+enum E1 {
+ E1Enumerator1,
+ E1Enumerator2 = 3,
+ E1Enumerator3
+} x1;
+
+// Value mismatch
+enum E2 {
+ E2Enumerator1,
+ E2Enumerator2 = 4,
+ E2Enumerator3
+} x2;
+
+// Name mismatch
+enum E3 {
+ E3Enumerator1,
+ E3Enumerator = 3,
+ E3Enumerator3
+} x3;
+
+// Missing enumerator
+enum E4 {
+ E4Enumerator1,
+ E4Enumerator2
+} x4;
+
+// Extra enumerator
+enum E5 {
+ E5Enumerator1,
+ E5Enumerator2,
+ E5Enumerator3,
+ E5Enumerator4
+} x5;
+
+// Matching, with typedef
+typedef enum {
+ E6Enumerator1,
+ E6Enumerator2
+} E6;
+
+E6 x6;
diff --git a/clang/test/ASTMerge/Inputs/exprs1.c b/clang/test/ASTMerge/Inputs/exprs1.c
new file mode 100644
index 0000000..1c268da
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/exprs1.c
@@ -0,0 +1,10 @@
+// Matching
+enum E0 {
+ E0_Val0 = 'a',
+ E0_Val1 = (17),
+ E0_Val2 = (1 << 2),
+ E0_Val3 = E0_Val2,
+ E0_Val4 = sizeof(int*),
+ E0_Val5 = (unsigned int)-1
+};
+
diff --git a/clang/test/ASTMerge/Inputs/exprs2.c b/clang/test/ASTMerge/Inputs/exprs2.c
new file mode 100644
index 0000000..1c268da
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/exprs2.c
@@ -0,0 +1,10 @@
+// Matching
+enum E0 {
+ E0_Val0 = 'a',
+ E0_Val1 = (17),
+ E0_Val2 = (1 << 2),
+ E0_Val3 = E0_Val2,
+ E0_Val4 = sizeof(int*),
+ E0_Val5 = (unsigned int)-1
+};
+
diff --git a/clang/test/ASTMerge/Inputs/function1.c b/clang/test/ASTMerge/Inputs/function1.c
new file mode 100644
index 0000000..4523bd3
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/function1.c
@@ -0,0 +1,6 @@
+void f0(int);
+void f1(int, float);
+void f2();
+void f3(void);
+void f4(int, int);
+int f5(int) __attribute__((const));
diff --git a/clang/test/ASTMerge/Inputs/function2.c b/clang/test/ASTMerge/Inputs/function2.c
new file mode 100644
index 0000000..6ca810a
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/function2.c
@@ -0,0 +1,7 @@
+typedef int Int;
+void f0(Int);
+void f1(Int, double);
+void f2(int, int);
+void f3(int);
+static void f4(float, float);
+int f5(int) __attribute__((const));
diff --git a/clang/test/ASTMerge/Inputs/interface1.m b/clang/test/ASTMerge/Inputs/interface1.m
new file mode 100644
index 0000000..5865c0e
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/interface1.m
@@ -0,0 +1,103 @@
+// Matches
+@interface I1 {
+ int ivar1;
+}
+@end
+
+// Matches
+@interface I2 : I1 {
+ float ivar2;
+}
+@end
+
+// Ivar mismatch
+@interface I3 {
+ int ivar1;
+ int ivar2;
+}
+@end
+
+// Superclass mismatch
+@interface I4 : I2 {
+}
+@end
+
+// Methods match
+@interface I5
+- (int)foo;
++ (float)bar;
+@end
+
+// Method mismatch
+@interface I6
+- (int)foo;
++ (int)foo;
+@end
+
+// Method mismatch
+@interface I7
+- (int)foo;
++ (int)bar:(int)x;
+@end
+
+// Method mismatch
+@interface I8
+- (int)foo;
++ (int)bar:(float)x;
+@end
+
+// Matching protocol
+@protocol P0
++ (int)foo;
+- (int)bar:(float)x;
+@end
+
+// Protocol with mismatching method
+@protocol P1
++ (int)foo;
+- (int)bar:(float)x;
+@end
+
+// Interface with protocol
+@interface I9 <P0>
++ (int)foo;
+- (int)bar:(float)x;
+@end
+
+// Protocol with protocol
+@protocol P2 <P0>
+- (float)wibble:(int)a1 second:(int)a2;
+@end
+
+// Forward-declared interfaces
+@class I10, I11;
+@interface I12
+@end
+
+// Forward-declared protocols
+@protocol P3, P5;
+@protocol P4
+- (double)honk:(int)a;
+@end
+
+// Interface with implementation
+@interface I13
+@end
+
+@implementation I13
+@end
+
+@interface I13a
+@end
+
+@implementation I13a
+@end
+
+// Implementation by itself
+@implementation I14 : I12
+@end
+
+@implementation I15 : I12
+@end
+
+
diff --git a/clang/test/ASTMerge/Inputs/interface2.m b/clang/test/ASTMerge/Inputs/interface2.m
new file mode 100644
index 0000000..2133bd1
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/interface2.m
@@ -0,0 +1,100 @@
+// Matches
+@interface I1 {
+ int ivar1;
+}
+@end
+
+// Matches
+@interface I2 : I1 {
+ float ivar2;
+}
+@end
+
+// Ivar mismatch
+@interface I3 {
+ int ivar1;
+ float ivar2;
+}
+@end
+
+// Superclass mismatch
+@interface I4 : I1 {
+}
+@end
+
+// Methods match
+@interface I5
++ (float)bar;
+- (int)foo;
+@end
+
+// Method mismatch
+@interface I6
++ (float)foo;
+@end
+
+// Method mismatch
+@interface I7
+- (int)foo;
++ (int)bar:(float)x;
+@end
+
+// Method mismatch
+@interface I8
+- (int)foo;
++ (int)bar:(float)x, ...;
+@end
+
+// Matching protocol
+@protocol P0
++ (int)foo;
+- (int)bar:(float)x;
+@end
+
+// Protocol with mismatching method
+@protocol P1
++ (int)foo;
+- (int)bar:(double)x;
+@end
+
+// Interface with protocol
+@interface I9 <P0>
++ (int)foo;
+- (int)bar:(float)x;
+@end
+
+// Protocol with protocol
+@protocol P2 <P0>
+- (float)wibble:(int)a1 second:(int)a2;
+@end
+
+// Forward-declared interface
+@class I10; @interface I12 @end
+@interface I11
+@end
+
+// Forward-declared protocols
+@protocol P3, P4;
+@protocol P5
+- (double)honk:(int)a;
+@end
+
+// Interface with implementation
+@interface I13
+@end
+
+@implementation I13
+@end
+
+@interface I13b
+@end
+
+@implementation I13b
+@end
+
+// Implementation by itself
+@implementation I14 : I12
+@end
+
+@implementation I15 : I11
+@end
diff --git a/clang/test/ASTMerge/Inputs/lit.local.cfg b/clang/test/ASTMerge/Inputs/lit.local.cfg
new file mode 100644
index 0000000..e6f55ee
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = []
diff --git a/clang/test/ASTMerge/Inputs/namespace1.cpp b/clang/test/ASTMerge/Inputs/namespace1.cpp
new file mode 100644
index 0000000..1ff84f3
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/namespace1.cpp
@@ -0,0 +1,17 @@
+// Merge success
+namespace N1 {
+ int x;
+}
+
+// Merge multiple namespaces
+namespace N2 {
+ extern int x;
+}
+namespace N2 {
+ extern float y;
+}
+
+// Merge namespace with conflict
+namespace N3 {
+ extern float z;
+}
diff --git a/clang/test/ASTMerge/Inputs/namespace2.cpp b/clang/test/ASTMerge/Inputs/namespace2.cpp
new file mode 100644
index 0000000..80429f7
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/namespace2.cpp
@@ -0,0 +1,17 @@
+// Merge success
+namespace N1 {
+ extern int x0;
+}
+
+// Merge multiple namespaces
+namespace N2 {
+ extern int x;
+}
+namespace N2 {
+ extern float y;
+}
+
+// Merge namespace with conflict
+namespace N3 {
+ extern double z;
+}
diff --git a/clang/test/ASTMerge/Inputs/property1.m b/clang/test/ASTMerge/Inputs/property1.m
new file mode 100644
index 0000000..22fe0a0
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/property1.m
@@ -0,0 +1,31 @@
+// Matching properties
+@interface I1 {
+}
+- (int)getProp2;
+- (void)setProp2:(int)value;
+@end
+
+// Mismatched property
+@interface I2
+@property (readonly) float Prop1;
+@end
+
+// Properties with implementations
+@interface I3 {
+ int ivar1;
+ int ivar2;
+ int ivar3;
+ int Prop4;
+}
+@property int Prop1;
+@property int Prop2;
+@property int Prop3;
+@property int Prop4;
+@end
+
+@implementation I3
+@synthesize Prop1 = ivar1;
+@synthesize Prop2 = ivar3;
+@dynamic Prop3;
+@synthesize Prop4;
+@end
diff --git a/clang/test/ASTMerge/Inputs/property2.m b/clang/test/ASTMerge/Inputs/property2.m
new file mode 100644
index 0000000..64a03fb
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/property2.m
@@ -0,0 +1,33 @@
+// Matching properties
+@interface I1 {
+}
+- (int)getProp2;
+- (void)setProp2:(int)value;
+@property (readonly) int Prop1;
+@property (getter = getProp2, setter = setProp2:) int Prop2;
+@end
+
+// Mismatched property
+@interface I2
+@property (readonly) int Prop1;
+@end
+
+// Properties with implementations
+@interface I3 {
+ int ivar1;
+ int ivar2;
+ int ivar3;
+ int Prop4;
+}
+@property int Prop1;
+@property int Prop2;
+@property int Prop3;
+@property int Prop4;
+@end
+
+@implementation I3
+@synthesize Prop2 = ivar2;
+@synthesize Prop1 = ivar1;
+@synthesize Prop3 = ivar3;
+@synthesize Prop4 = Prop4;
+@end
diff --git a/clang/test/ASTMerge/Inputs/struct1.c b/clang/test/ASTMerge/Inputs/struct1.c
new file mode 100644
index 0000000..af2af8a
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/struct1.c
@@ -0,0 +1,63 @@
+typedef int Int;
+typedef float Float;
+
+// Matches
+struct S0 {
+ Int field1;
+ Float field2;
+};
+
+struct S0 x0;
+
+// Mismatch in field type
+struct S1 {
+ Int field1;
+ int field2;
+};
+
+struct S1 x1;
+
+// Mismatch in tag kind.
+struct S2 { int i; float f; } x2;
+
+// Missing fields
+struct S3 { int i; float f; double d; } x3;
+
+// Extra fields
+struct S4 { int i; } x4;
+
+// Bit-field matches
+struct S5 { int i : 8; unsigned j : 8; } x5;
+
+// Bit-field mismatch
+struct S6 { int i : 8; unsigned j : 8; } x6;
+
+// Bit-field mismatch
+struct S7 { int i : 8; unsigned j : 8; } x7;
+
+// Incomplete type
+struct S8 *x8;
+
+// Incomplete type
+struct S9 { int i; float f; } *x9;
+
+// Incomplete type
+struct S10 *x10;
+
+// Matches
+struct ListNode {
+ int value;
+ struct ListNode *Next;
+} xList;
+
+// Mismatch due to struct used internally
+struct DeepError {
+ int value;
+ struct DeeperError { int i; int f; } *Deeper;
+} xDeep;
+
+// Matches
+struct {
+ Int i;
+ float f;
+} x11;
diff --git a/clang/test/ASTMerge/Inputs/struct2.c b/clang/test/ASTMerge/Inputs/struct2.c
new file mode 100644
index 0000000..4b43df7
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/struct2.c
@@ -0,0 +1,60 @@
+// Matches
+struct S0 {
+ int field1;
+ float field2;
+};
+
+struct S0 x0;
+
+// Mismatch in field type
+struct S1 {
+ int field1;
+ float field2;
+};
+
+struct S1 x1;
+
+// Mismatch in tag kind.
+union S2 { int i; float f; } x2;
+
+// Missing fields
+struct S3 { int i; float f; } x3;
+
+// Extra fields
+struct S4 { int i; float f; } x4;
+
+// Bit-field matches
+struct S5 { int i : 8; unsigned j : 8; } x5;
+
+// Bit-field mismatch
+struct S6 { int i : 8; unsigned j; } x6;
+
+// Bit-field mismatch
+struct S7 { int i : 8; unsigned j : 16; } x7;
+
+// Incomplete type
+struct S8 { int i; float f; } *x8;
+
+// Incomplete type
+struct S9 *x9;
+
+// Incomplete type
+struct S10 *x10;
+
+// Matches
+struct ListNode {
+ int value;
+ struct ListNode *Next;
+} xList;
+
+// Mismatch due to struct used internally
+struct DeepError {
+ int value;
+ struct DeeperError { int i; float f; } *Deeper;
+} xDeep;
+
+// Matches
+struct {
+ int i;
+ float f;
+} x11;
diff --git a/clang/test/ASTMerge/Inputs/typedef1.c b/clang/test/ASTMerge/Inputs/typedef1.c
new file mode 100644
index 0000000..5657675
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/typedef1.c
@@ -0,0 +1,4 @@
+typedef int Typedef1;
+typedef int Typedef2;
+Typedef1 x1;
+Typedef2 x2;
diff --git a/clang/test/ASTMerge/Inputs/typedef2.c b/clang/test/ASTMerge/Inputs/typedef2.c
new file mode 100644
index 0000000..129d710
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/typedef2.c
@@ -0,0 +1,4 @@
+typedef int Typedef1;
+typedef double Typedef2;
+Typedef1 x1;
+Typedef2 x2;
diff --git a/clang/test/ASTMerge/Inputs/var1.c b/clang/test/ASTMerge/Inputs/var1.c
new file mode 100644
index 0000000..4f5cbe1
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/var1.c
@@ -0,0 +1,7 @@
+int *x0;
+float **x1;
+#include "var1.h"
+int xarray0[17];
+int xarray1[];
+int xarray2[18];
+int xarray3[18];
diff --git a/clang/test/ASTMerge/Inputs/var1.h b/clang/test/ASTMerge/Inputs/var1.h
new file mode 100644
index 0000000..1518e17
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/var1.h
@@ -0,0 +1 @@
+double x2;
diff --git a/clang/test/ASTMerge/Inputs/var2.c b/clang/test/ASTMerge/Inputs/var2.c
new file mode 100644
index 0000000..01986e4
--- /dev/null
+++ b/clang/test/ASTMerge/Inputs/var2.c
@@ -0,0 +1,7 @@
+int *x0;
+double *x1;
+int x2;
+int xarray0[17];
+int xarray1[17];
+int xarray2[];
+int xarray3[17];
diff --git a/clang/test/ASTMerge/category.m b/clang/test/ASTMerge/category.m
new file mode 100644
index 0000000..54a1240
--- /dev/null
+++ b/clang/test/ASTMerge/category.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/category1.m
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/category2.m
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: category2.m:18:1: error: instance method 'method2' has incompatible result types in different translation units ('float' vs. 'int')
+// CHECK: category1.m:16:1: note: instance method 'method2' also declared here
+// CHECK: category2.m:26:1: error: instance method 'method3' has incompatible result types in different translation units ('float' vs. 'int')
+// CHECK: category1.m:24:1: note: instance method 'method3' also declared here
+// CHECK: category2.m:48:1: error: instance method 'blah' has incompatible result types in different translation units ('int' vs. 'float')
+// CHECK: category1.m:46:1: note: instance method 'blah' also declared here
+// CHECK: 3 errors generated.
diff --git a/clang/test/ASTMerge/class-template.cpp b/clang/test/ASTMerge/class-template.cpp
new file mode 100644
index 0000000..eea31b1
--- /dev/null
+++ b/clang/test/ASTMerge/class-template.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/class-template1.cpp
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/class-template2.cpp
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: class-template1.cpp:7:14: error: non-type template parameter declared with incompatible types in different translation units ('int' vs. 'long')
+// CHECK: class-template2.cpp:7:15: note: declared here with type 'long'
+
+// CHECK: class-template1.cpp:10:14: error: template parameter has different kinds in different translation units
+// CHECK: class-template2.cpp:10:10: note: template parameter declared here
+
+// CHECK: class-template1.cpp:16:23: error: non-type template parameter declared with incompatible types in different translation units ('long' vs. 'int')
+// CHECK: class-template2.cpp:16:23: note: declared here with type 'int'
+
+// CHECK: class-template1.cpp:19:10: error: template parameter has different kinds in different translation units
+// CHECK: class-template2.cpp:19:10: note: template parameter declared here
+
+// CHECK: class-template2.cpp:25:20: error: external variable 'x0r' declared with incompatible types in different translation units ('X0<double> *' vs. 'X0<float> *')
+// CHECK: class-template1.cpp:24:19: note: declared here with type 'X0<float> *'
+
+// CHECK: class-template1.cpp:32:8: warning: type 'X0<wchar_t>' has incompatible definitions in different translation units
+// CHECK: class-template1.cpp:33:7: note: field 'member' has type 'int' here
+// CHECK: class-template2.cpp:34:9: note: field 'member' has type 'float' here
+
+// CHECK: 1 warning and 5 errors generated.
diff --git a/clang/test/ASTMerge/class.cpp b/clang/test/ASTMerge/class.cpp
new file mode 100644
index 0000000..114687f
--- /dev/null
+++ b/clang/test/ASTMerge/class.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/class1.cpp
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/class2.cpp
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: class1.cpp:5:8: warning: type 'B' has incompatible definitions in different translation units
+// CHECK: class1.cpp:6:9: note: field 'y' has type 'float' here
+// CHECK: class2.cpp:6:7: note: field 'y' has type 'int' here
+
+// FIXME: we should also complain about mismatched types on the method
diff --git a/clang/test/ASTMerge/enum.c b/clang/test/ASTMerge/enum.c
new file mode 100644
index 0000000..4380d19
--- /dev/null
+++ b/clang/test/ASTMerge/enum.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/enum1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/enum2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: enum1.c:9:6: warning: type 'enum E2' has incompatible definitions in different translation units
+// CHECK: enum1.c:11:3: note: enumerator 'E2Enumerator2' with value 3 here
+// CHECK: enum2.c:11:3: note: enumerator 'E2Enumerator2' with value 4 here
+// CHECK: enum2.c:13:3: error: external variable 'x2' declared with incompatible types in different translation units ('enum E2' vs. 'enum E2')
+// CHECK: enum1.c:13:3: note: declared here with type 'enum E2'
+// CHECK: enum1.c:16:6: warning: type 'enum E3' has incompatible definitions in different translation units
+// CHECK: enum1.c:18:3: note: enumerator 'E3Enumerator2' with value 3 here
+// CHECK: enum2.c:18:3: note: enumerator 'E3Enumerator' with value 3 here
+// CHECK: enum2.c:20:3: error: external variable 'x3' declared with incompatible types in different translation units ('enum E3' vs. 'enum E3')
+// CHECK: enum1.c:20:3: note: declared here with type 'enum E3'
+// CHECK: enum1.c:23:6: warning: type 'enum E4' has incompatible definitions in different translation units
+// CHECK: enum1.c:26:3: note: enumerator 'E4Enumerator3' with value 2 here
+// CHECK: enum2.c:23:6: note: no corresponding enumerator here
+// CHECK: enum2.c:26:3: error: external variable 'x4' declared with incompatible types in different translation units ('enum E4' vs. 'enum E4')
+// CHECK: enum1.c:27:3: note: declared here with type 'enum E4'
+// CHECK: enum1.c:30:6: warning: type 'enum E5' has incompatible definitions in different translation units
+// CHECK: enum2.c:33:3: note: enumerator 'E5Enumerator4' with value 3 here
+// CHECK: enum1.c:30:6: note: no corresponding enumerator here
+// CHECK: enum2.c:34:3: error: external variable 'x5' declared with incompatible types in different translation units ('enum E5' vs. 'enum E5')
+// CHECK: enum1.c:34:3: note: declared here with type 'enum E5'
+// CHECK: 4 warnings and 4 errors generated
diff --git a/clang/test/ASTMerge/exprs.c b/clang/test/ASTMerge/exprs.c
new file mode 100644
index 0000000..0a4e1e5
--- /dev/null
+++ b/clang/test/ASTMerge/exprs.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/exprs1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/exprs2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only -verify %s
+
diff --git a/clang/test/ASTMerge/function.c b/clang/test/ASTMerge/function.c
new file mode 100644
index 0000000..f97ecee
--- /dev/null
+++ b/clang/test/ASTMerge/function.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/function1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/function2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: function2.c:3:6: error: external function 'f1' declared with incompatible types in different translation units ('void (Int, double)' vs. 'void (int, float)')
+// CHECK: function1.c:2:6: note: declared here with type 'void (int, float)'
+// CHECK: function2.c:5:6: error: external function 'f3' declared with incompatible types in different translation units ('void (int)' vs. 'void (void)')
+// CHECK: function1.c:4:6: note: declared here with type 'void (void)'
+// CHECK: 2 errors generated
diff --git a/clang/test/ASTMerge/interface.m b/clang/test/ASTMerge/interface.m
new file mode 100644
index 0000000..747ef38
--- /dev/null
+++ b/clang/test/ASTMerge/interface.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/interface1.m
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/interface2.m
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: interface2.m:16:9: error: instance variable 'ivar2' declared with incompatible types in different translation units ('float' vs. 'int')
+// CHECK: interface1.m:16:7: note: declared here with type 'int'
+// CHECK: interface1.m:21:12: error: class 'I4' has incompatible superclasses
+// CHECK: interface1.m:21:17: note: inherits from superclass 'I2' here
+// CHECK: interface2.m:21:17: note: inherits from superclass 'I1' here
+// CHECK: interface2.m:33:1: error: class method 'foo' has incompatible result types in different translation units ('float' vs. 'int')
+// CHECK: interface1.m:34:1: note: class method 'foo' also declared here
+// CHECK: interface2.m:39:19: error: class method 'bar:' has a parameter with a different types in different translation units ('float' vs. 'int')
+// CHECK: interface1.m:40:17: note: declared here with type 'int'
+// CHECK: interface2.m:45:1: error: class method 'bar:' is variadic in one translation unit and not variadic in another
+// CHECK: interface1.m:46:1: note: class method 'bar:' also declared here
+// CHECK: interface2.m:57:20: error: instance method 'bar:' has a parameter with a different types in different translation units ('double' vs. 'float')
+// CHECK: interface1.m:58:19: note: declared here with type 'float'
+// CHECK: interface1.m:100:17: error: class 'I15' has incompatible superclasses
+// CHECK: interface1.m:100:17: note: inherits from superclass 'I12' here
+// CHECK: interface2.m:99:17: note: inherits from superclass 'I11' here
+// CHECK: 8 errors generated
+
diff --git a/clang/test/ASTMerge/namespace.cpp b/clang/test/ASTMerge/namespace.cpp
new file mode 100644
index 0000000..6c46f0a
--- /dev/null
+++ b/clang/test/ASTMerge/namespace.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/namespace1.cpp
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/namespace2.cpp
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: namespace2.cpp:16:17: error: external variable 'z' declared with incompatible types in different translation units ('double' vs. 'float')
+// CHECK: namespace1.cpp:16:16: note: declared here with type 'float'
diff --git a/clang/test/ASTMerge/property.m b/clang/test/ASTMerge/property.m
new file mode 100644
index 0000000..a8dd7c4
--- /dev/null
+++ b/clang/test/ASTMerge/property.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/property1.m
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/property2.m
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: property2.m:12:26: error: property 'Prop1' declared with incompatible types in different translation units ('int' vs. 'float')
+// CHECK: property1.m:10:28: note: declared here with type 'float'
+// CHECK: property2.m:12:26: error: instance method 'Prop1' has incompatible result types in different translation units ('int' vs. 'float')
+// CHECK: property1.m:10:28: note: instance method 'Prop1' also declared here
+// CHECK: property1.m:28:21: error: property 'Prop2' is synthesized to different ivars in different translation units ('ivar3' vs. 'ivar2')
+// CHECK: property2.m:29:21: note: property is synthesized to ivar 'ivar2' here
+// CHECK: property1.m:29:10: error: property 'Prop3' is implemented with @dynamic in one translation but @synthesize in another translation unit
+// CHECK: property2.m:31:13: note: property 'Prop3' is implemented with @synthesize here
+// CHECK: 4 errors generated.
diff --git a/clang/test/ASTMerge/struct.c b/clang/test/ASTMerge/struct.c
new file mode 100644
index 0000000..7217222
--- /dev/null
+++ b/clang/test/ASTMerge/struct.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/struct1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/struct2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: struct1.c:13:8: warning: type 'struct S1' has incompatible definitions in different translation units
+// CHECK: struct1.c:15:7: note: field 'field2' has type 'int' here
+// CHECK: struct2.c:12:9: note: field 'field2' has type 'float' here
+// CHECK: struct2.c:15:11: error: external variable 'x1' declared with incompatible types in different translation units ('struct S1' vs. 'struct S1')
+// CHECK: struct1.c:18:11: note: declared here with type 'struct S1'
+// CHECK: struct1.c:21:8: warning: type 'struct S2' has incompatible definitions in different translation units
+// CHECK: struct2.c:18:7: note: 'S2' is a union here
+// CHECK: struct2.c:18:30: error: external variable 'x2' declared with incompatible types in different translation units ('union S2' vs. 'struct S2')
+// CHECK: struct1.c:21:31: note: declared here with type 'struct S2'
+// CHECK: struct1.c:24:8: warning: type 'struct S3' has incompatible definitions in different translation units
+// CHECK: struct1.c:24:36: note: field 'd' has type 'double' here
+// CHECK: struct2.c:21:8: note: no corresponding field here
+// CHECK: struct2.c:21:31: error: external variable 'x3' declared with incompatible types in different translation units ('struct S3' vs. 'struct S3')
+// CHECK: struct1.c:24:41: note: declared here with type 'struct S3'
+// CHECK: struct1.c:27:8: warning: type 'struct S4' has incompatible definitions in different translation units
+// CHECK: struct2.c:24:26: note: field 'f' has type 'float' here
+// CHECK: struct1.c:27:8: note: no corresponding field here
+// CHECK: struct2.c:24:31: error: external variable 'x4' declared with incompatible types in different translation units ('struct S4' vs. 'struct S4')
+// CHECK: struct1.c:27:22: note: declared here with type 'struct S4'
+// CHECK: struct1.c:33:8: warning: type 'struct S6' has incompatible definitions in different translation units
+// CHECK: struct1.c:33:33: note: bit-field 'j' with type 'unsigned int' and length 8 here
+// CHECK: struct2.c:30:33: note: field 'j' is not a bit-field
+// CHECK: struct2.c:30:38: error: external variable 'x6' declared with incompatible types in different translation units ('struct S6' vs. 'struct S6')
+// CHECK: struct1.c:33:42: note: declared here with type 'struct S6'
+// CHECK: struct1.c:36:8: warning: type 'struct S7' has incompatible definitions in different translation units
+// CHECK: struct1.c:36:33: note: bit-field 'j' with type 'unsigned int' and length 8 here
+// CHECK: struct2.c:33:33: note: bit-field 'j' with type 'unsigned int' and length 16 here
+// CHECK: struct2.c:33:43: error: external variable 'x7' declared with incompatible types in different translation units ('struct S7' vs. 'struct S7')
+// CHECK: struct1.c:36:42: note: declared here with type 'struct S7'
+// CHECK: struct1.c:56:10: warning: type 'struct DeeperError' has incompatible definitions in different translation units
+// CHECK: struct1.c:56:35: note: field 'f' has type 'int' here
+// CHECK: struct2.c:53:37: note: field 'f' has type 'float' here
+// CHECK: struct1.c:54:8: warning: type 'struct DeepError' has incompatible definitions in different translation units
+// CHECK: struct1.c:56:41: note: field 'Deeper' has type 'struct DeeperError *' here
+// CHECK: struct2.c:53:43: note: field 'Deeper' has type 'struct DeeperError *' here
+// CHECK: struct2.c:54:3: error: external variable 'xDeep' declared with incompatible types in different translation units ('struct DeepError' vs. 'struct DeepError')
+// CHECK: struct1.c:57:3: note: declared here with type 'struct DeepError'
+// CHECK: 8 warnings and 7 errors generated
diff --git a/clang/test/ASTMerge/typedef.c b/clang/test/ASTMerge/typedef.c
new file mode 100644
index 0000000..6f91129
--- /dev/null
+++ b/clang/test/ASTMerge/typedef.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/typedef1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/typedef2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: typedef2.c:4:10: error: external variable 'x2' declared with incompatible types in different translation units ('Typedef2' (aka 'double') vs. 'Typedef2' (aka 'int'))
+// CHECK: typedef1.c:4:10: note: declared here with type 'Typedef2' (aka 'int')
+// CHECK: 1 error
diff --git a/clang/test/ASTMerge/var.c b/clang/test/ASTMerge/var.c
new file mode 100644
index 0000000..e1dde6a
--- /dev/null
+++ b/clang/test/ASTMerge/var.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/var1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/var2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only -fdiagnostics-show-note-include-stack %s 2>&1 | FileCheck %s
+
+// CHECK: var2.c:2:9: error: external variable 'x1' declared with incompatible types in different translation units ('double *' vs. 'float **')
+// CHECK: var1.c:2:9: note: declared here with type 'float **'
+// CHECK: var2.c:3:5: error: external variable 'x2' declared with incompatible types in different translation units ('int' vs. 'double')
+// CHECK: In file included from{{.*}}var1.c:3:
+// CHECK: var1.h:1:8: note: declared here with type 'double'
+// CHECK: error: external variable 'xarray3' declared with incompatible types in different translation units ('int [17]' vs. 'int [18]')
+// CHECK: var1.c:7:5: note: declared here with type 'int [18]'
+// CHECK: 3 errors
diff --git a/clang/test/Analysis/CFContainers.mm b/clang/test/Analysis/CFContainers.mm
new file mode 100644
index 0000000..7d6c175
--- /dev/null
+++ b/clang/test/Analysis/CFContainers.mm
@@ -0,0 +1,204 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.coreFoundation.containers.PointerSizedValues,osx.coreFoundation.containers.OutOfBounds -analyzer-store=region -triple x86_64-apple-darwin -verify %s
+
+typedef const struct __CFAllocator * CFAllocatorRef;
+typedef const struct __CFString * CFStringRef;
+typedef unsigned char Boolean;
+typedef signed long CFIndex;
+extern
+const CFAllocatorRef kCFAllocatorDefault;
+typedef const void * (*CFArrayRetainCallBack)(CFAllocatorRef allocator, const void *value);
+typedef void (*CFArrayReleaseCallBack)(CFAllocatorRef allocator, const void *value);
+typedef CFStringRef (*CFArrayCopyDescriptionCallBack)(const void *value);
+typedef Boolean (*CFArrayEqualCallBack)(const void *value1, const void *value2);
+typedef struct {
+ CFIndex version;
+ CFArrayRetainCallBack retain;
+ CFArrayReleaseCallBack release;
+ CFArrayCopyDescriptionCallBack copyDescription;
+ CFArrayEqualCallBack equal;
+} CFArrayCallBacks;
+typedef const struct __CFArray * CFArrayRef;
+CFArrayRef CFArrayCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFArrayCallBacks *callBacks);
+typedef const struct __CFString * CFStringRef;
+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;
+typedef CFIndex CFComparisonResult;
+typedef const struct __CFDictionary * CFDictionaryRef;
+typedef const void * (*CFDictionaryRetainCallBack)(CFAllocatorRef allocator, const void *value);
+typedef void (*CFDictionaryReleaseCallBack)(CFAllocatorRef allocator, const void *value);
+typedef CFStringRef (*CFDictionaryCopyDescriptionCallBack)(const void *value);
+typedef Boolean (*CFDictionaryEqualCallBack)(const void *value1, const void *value2);
+typedef Boolean (*CFArrayEqualCallBack)(const void *value1, const void *value2);
+typedef Boolean (*CFSetEqualCallBack)(const void *value1, const void *value2);
+typedef const void * (*CFSetRetainCallBack)(CFAllocatorRef allocator, const void *value);
+typedef void (*CFSetReleaseCallBack)(CFAllocatorRef allocator, const void *value);
+typedef CFStringRef (*CFSetCopyDescriptionCallBack)(const void *value);
+typedef struct {
+ CFIndex version;
+ CFSetRetainCallBack retain;
+ CFSetReleaseCallBack release;
+ CFSetCopyDescriptionCallBack copyDescription;
+ CFSetEqualCallBack equal;
+} CFSetCallBacks;
+typedef struct {
+ CFIndex version;
+ CFDictionaryRetainCallBack retain;
+ CFDictionaryReleaseCallBack release;
+ CFDictionaryCopyDescriptionCallBack copyDescription;
+ CFDictionaryEqualCallBack equal;
+} CFDictionaryKeyCallBacks;
+typedef struct {
+ CFIndex version;
+ CFDictionaryRetainCallBack retain;
+ CFDictionaryReleaseCallBack release;
+ CFDictionaryCopyDescriptionCallBack copyDescription;
+ CFDictionaryEqualCallBack equal;
+} CFDictionaryValueCallBacks;
+CFDictionaryRef CFDictionaryCreate(CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
+extern
+const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
+typedef const struct __CFSet * CFSetRef;
+extern
+const CFSetCallBacks kCFTypeSetCallBacks;
+extern
+const CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks;
+extern
+const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx);
+extern
+CFIndex CFArrayGetCount(CFArrayRef theArray);
+CFDictionaryRef CFDictionaryCreate(CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const
+CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
+CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr);
+extern
+CFSetRef CFSetCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFSetCallBacks *callBacks);
+#define CFSTR(cStr) ((CFStringRef) __builtin___CFStringMakeConstantString ("" cStr ""))
+#define NULL __null
+
+// Done with the headers.
+// Test experimental.osx.cocoa.ContainerAPI checker.
+void testContainers(int **xNoWarn, CFIndex count) {
+ int x[] = { 1, 2, 3 };
+ CFArrayRef foo = CFArrayCreate(kCFAllocatorDefault, (const void **) x, sizeof(x) / sizeof(x[0]), 0);// expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}}
+
+ CFArrayRef fooNoWarn = CFArrayCreate(kCFAllocatorDefault, (const void **) xNoWarn, sizeof(xNoWarn) / sizeof(xNoWarn[0]), 0); // no warning
+ CFArrayRef fooNoWarn2 = CFArrayCreate(kCFAllocatorDefault, 0, sizeof(xNoWarn) / sizeof(xNoWarn[0]), 0);// no warning, passing in 0
+ CFArrayRef fooNoWarn3 = CFArrayCreate(kCFAllocatorDefault, NULL, sizeof(xNoWarn) / sizeof(xNoWarn[0]), 0);// no warning, passing in NULL
+
+ CFSetRef set = CFSetCreate(NULL, (const void **)x, 3, &kCFTypeSetCallBacks); // expected-warning {{The first argument to 'CFSetCreate' must be a C array of pointer-sized values}}
+ CFArrayRef* pairs = new CFArrayRef[count];
+ CFSetRef fSet = CFSetCreate(kCFAllocatorDefault, (const void**) pairs, count - 1, &kCFTypeSetCallBacks);// no warning
+}
+
+void CreateDict(int *elems) {
+ const short days28 = 28;
+ const short days30 = 30;
+ const short days31 = 31;
+ CFIndex numValues = 6;
+ CFStringRef keys[6];
+ CFNumberRef values[6];
+ keys[0] = CFSTR("January"); values[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days31);
+ keys[1] = CFSTR("February"); values[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days28);
+ keys[2] = CFSTR("March"); values[2] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days31);
+ keys[3] = CFSTR("April"); values[3] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days30);
+ keys[4] = CFSTR("May"); values[4] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days31);
+ keys[5] = CFSTR("June"); values[5] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days30);
+
+ const CFDictionaryKeyCallBacks keyCB = kCFCopyStringDictionaryKeyCallBacks;
+ const CFDictionaryValueCallBacks valCB = kCFTypeDictionaryValueCallBacks;
+ CFDictionaryRef dict1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)values, numValues, &keyCB, &valCB); // no warning
+ CFDictionaryRef dict2 = CFDictionaryCreate(kCFAllocatorDefault, (const void**)elems[0], (const void**)values, numValues, &keyCB, &valCB); //expected-warning {{The first argument to 'CFDictionaryCreate' must be a C array of}}
+ CFDictionaryRef dict3 = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)elems, numValues, &keyCB, &valCB); // expected-warning {{The second argument to 'CFDictionaryCreate' must be a C array of pointer-sized values}}
+}
+
+void OutOfBoundsSymbolicOffByOne(const void ** input, CFIndex S) {
+ CFArrayRef array;
+ array = CFArrayCreate(kCFAllocatorDefault, input, S, 0);
+ const void *s1 = CFArrayGetValueAtIndex(array, 0); // no warning
+ const void *s2 = CFArrayGetValueAtIndex(array, S-1); // no warning
+ const void *s3 = CFArrayGetValueAtIndex(array, S); // expected-warning {{Index is out of bounds}}
+}
+
+void OutOfBoundsConst(const void ** input, CFIndex S) {
+ CFArrayRef array;
+ array = CFArrayCreate(kCFAllocatorDefault, input, 3, 0);
+ const void *s1 = CFArrayGetValueAtIndex(array, 0); // no warning
+ const void *s2 = CFArrayGetValueAtIndex(array, 2); // no warning
+ const void *s3 = CFArrayGetValueAtIndex(array, 5); // expected-warning {{Index is out of bounds}}
+
+ // TODO: The solver is probably not strong enough here.
+ CFIndex sIndex;
+ for (sIndex = 0 ; sIndex <= 5 ; sIndex += 3 ) {
+ const void *s = CFArrayGetValueAtIndex(array, sIndex);
+ }
+}
+
+void OutOfBoundsZiro(const void ** input, CFIndex S) {
+ CFArrayRef array;
+ // The API allows to set the size to 0. Check that we don't undeflow when the size is 0.
+ array = CFArrayCreate(kCFAllocatorDefault, 0, 0, 0);
+ const void *s1 = CFArrayGetValueAtIndex(array, 0); // expected-warning {{Index is out of bounds}}
+}
+
+void TestGetCount(CFArrayRef A, CFIndex sIndex) {
+ CFIndex sCount = CFArrayGetCount(A);
+ if (sCount > sIndex)
+ const void *s1 = CFArrayGetValueAtIndex(A, sIndex);
+ const void *s2 = CFArrayGetValueAtIndex(A, sCount);// expected-warning {{Index is out of bounds}}
+}
+
+typedef void* XX[3];
+void TestPointerToArray(int *elems, void *p1, void *p2, void *p3, unsigned count, void* fn[], char cp[]) {
+ void* x[] = { p1, p2, p3 };
+ CFArrayCreate(0, (const void **) &x, count, 0); // no warning
+
+ void* y[] = { p1, p2, p3 };
+ CFArrayCreate(0, (const void **) y, count, 0); // no warning
+ XX *z = &x;
+ CFArrayCreate(0, (const void **) z, count, 0); // no warning
+
+ CFArrayCreate(0, (const void **) &fn, count, 0); // false negative
+ CFArrayCreate(0, (const void **) fn, count, 0); // no warning
+ CFArrayCreate(0, (const void **) cp, count, 0); // expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}}
+
+ char cc[] = { 0, 2, 3 };
+ CFArrayCreate(0, (const void **) &cc, count, 0); // expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}}
+ CFArrayCreate(0, (const void **) cc, count, 0); // expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}}
+}
+
+void TestUndef(CFArrayRef A, CFIndex sIndex, void* x[]) {
+ unsigned undefVal;
+ const void *s1 = CFArrayGetValueAtIndex(A, undefVal);
+
+ unsigned undefVal2;
+ CFArrayRef B = CFArrayCreate(0, (const void **) &x, undefVal2, 0);
+ const void *s2 = CFArrayGetValueAtIndex(B, 2);
+}
+
+void TestConst(CFArrayRef A, CFIndex sIndex, void* x[]) {
+ CFArrayRef B = CFArrayCreate(0, (const void **) &x, 4, 0);
+ const void *s1 = CFArrayGetValueAtIndex(B, 2);
+
+}
+
+void TestNullArray() {
+ CFArrayGetValueAtIndex(0, 0);
+}
diff --git a/clang/test/Analysis/CFDateGC.m b/clang/test/Analysis/CFDateGC.m
new file mode 100644
index 0000000..4884bb9
--- /dev/null
+++ b/clang/test/Analysis/CFDateGC.m
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -analyzer-constraints=basic -verify -fobjc-gc %s -Wno-implicit-function-declaration
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -analyzer-constraints=range -verify -fobjc-gc %s -Wno-implicit-function-declaration
+
+//===----------------------------------------------------------------------===//
+// The following code is reduced using delta-debugging from
+// Foundation.h and CoreFoundation.h (Mac OS X).
+//
+// It includes the basic definitions for the test cases below.
+// Not directly including [Core]Foundation.h directly makes this test case
+// both svelte and portable to non-Mac platforms.
+//===----------------------------------------------------------------------===//
+
+typedef const void * CFTypeRef;
+void CFRelease(CFTypeRef cf);
+CFTypeRef CFRetain(CFTypeRef cf);
+CFTypeRef CFMakeCollectable(CFTypeRef cf);
+typedef const struct __CFAllocator * CFAllocatorRef;
+typedef double CFTimeInterval;
+typedef CFTimeInterval CFAbsoluteTime;
+typedef const struct __CFDate * CFDateRef;
+extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at);
+extern CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate);
+typedef struct objc_object {} *id;
+typedef signed char BOOL;
+static __inline__ __attribute__((always_inline)) id NSMakeCollectable(CFTypeRef cf) { return 0; }
+@protocol NSObject - (BOOL)isEqual:(id)object;
+- (oneway void)release;
+- (id)retain;
+@end
+@class NSArray;
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+CFAbsoluteTime CFAbsoluteTimeGetCurrent();
+
+CFAbsoluteTime f1_use_after_release() {
+ CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+ CFDateRef date = CFDateCreate(0, t);
+ CFRetain(date);
+ [NSMakeCollectable(date) release];
+ CFDateGetAbsoluteTime(date); // no-warning
+ CFRelease(date);
+ t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}}
+ return t;
+}
+
+// The following two test cases verifies that CFMakeCollectable is a no-op
+// in non-GC mode and a "release" in GC mode.
+CFAbsoluteTime f2_use_after_release() {
+ CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+ CFDateRef date = CFDateCreate(0, t);
+ CFRetain(date);
+ [(id) CFMakeCollectable(date) release];
+ CFDateGetAbsoluteTime(date); // no-warning
+ CFRelease(date);
+ t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}}
+ return t;
+}
+
+CFAbsoluteTime f2_noleak() {
+ CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+ CFDateRef date = CFDateCreate(0, t);
+ CFRetain(date);
+ [(id) CFMakeCollectable(date) release];
+ CFDateGetAbsoluteTime(date); // no-warning
+ t = CFDateGetAbsoluteTime(date); // no-warning
+ CFRelease(date); // no-warning
+ return t;
+}
+
+void f3_leak_with_gc() {
+ CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning 2 {{leak}}
+ [[(id) date retain] release];
+}
+
+// The following test case verifies that we "stop tracking" a retained object
+// when it is passed as an argument to an implicitly defined function.
+CFAbsoluteTime f4() {
+ CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+ CFDateRef date = CFDateCreate(0, t);
+ CFRetain(date);
+ some_implicitly_defined_function_stop_tracking(date); // no-warning
+ return t;
+}
diff --git a/clang/test/Analysis/CFNumber.c b/clang/test/Analysis/CFNumber.c
new file mode 100644
index 0000000..fbbe4d1
--- /dev/null
+++ b/clang/test/Analysis/CFNumber.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.coreFoundation.CFNumber,osx.cocoa.RetainCount -analyzer-store=region -analyzer-constraints=basic -verify -triple x86_64-apple-darwin9 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.coreFoundation.CFNumber,osx.cocoa.RetainCount -analyzer-store=region -analyzer-constraints=range -verify -triple x86_64-apple-darwin9 %s
+
+typedef signed long CFIndex;
+typedef const struct __CFAllocator * CFAllocatorRef;
+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);
+
+CFNumberRef f1(unsigned char x) {
+ return CFNumberCreate(0, kCFNumberSInt16Type, &x); // expected-warning{{An 8 bit integer is used to initialize a CFNumber object that represents a 16 bit integer. 8 bits of the CFNumber value will be garbage.}}
+}
+
+__attribute__((cf_returns_retained)) CFNumberRef f2(unsigned short x) {
+ return CFNumberCreate(0, kCFNumberSInt8Type, &x); // expected-warning{{A 16 bit integer is used to initialize a CFNumber object that represents an 8 bit integer. 8 bits of the input integer will be lost.}}
+}
+
+// test that the attribute overrides the naming convention.
+__attribute__((cf_returns_not_retained)) CFNumberRef CreateNum(unsigned char x) {
+ return CFNumberCreate(0, kCFNumberSInt8Type, &x); // expected-warning{{leak}}
+}
+
+CFNumberRef f3(unsigned i) {
+ return CFNumberCreate(0, kCFNumberLongType, &i); // expected-warning{{A 32 bit integer is used to initialize a CFNumber object that represents a 64 bit integer.}}
+}
diff --git a/clang/test/Analysis/CFRetainRelease_NSAssertionHandler.m b/clang/test/Analysis/CFRetainRelease_NSAssertionHandler.m
new file mode 100644
index 0000000..e0c9be1
--- /dev/null
+++ b/clang/test/Analysis/CFRetainRelease_NSAssertionHandler.m
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -verify %s -analyzer-constraints=basic -analyzer-store=region
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -verify %s -analyzer-constraints=range -analyzer-store=region
+
+typedef struct objc_selector *SEL;
+typedef signed char BOOL;
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@interface NSObject <NSObject> {} - (id)init; @end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
++ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
+@end extern NSString * const NSBundleDidLoadNotification;
+@interface NSAssertionHandler : NSObject {}
++ (NSAssertionHandler *)currentHandler;
+- (void)handleFailureInMethod:(SEL)selector object:(id)object file:(NSString *)fileName lineNumber:(NSInteger)line description:(NSString *)format,...;
+- (void)handleFailureInFunction:(NSString *)functionName file:(NSString *)fileName lineNumber:(NSInteger)line description:(NSString *)format,...;
+@end
+extern NSString * const NSConnectionReplyMode;
+
+//----------------------------------------------------------------------------//
+// The following test case was filed in PR 2593:
+// http://llvm.org/bugs/show_bug.cgi?id=2593
+//
+// There should be no null dereference flagged by the checker because of
+// NSParameterAssert and NSAssert.
+
+
+@interface TestAssert : NSObject {}
+@end
+
+@implementation TestAssert
+
+- (id)initWithPointer: (int*)x
+{
+ // Expansion of: NSParameterAssert( x != 0 );
+ do { if (!((x != 0))) { [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd object:self file:[NSString stringWithUTF8String:"CFRetainRelease_NSAssertionHandler.m"] lineNumber:21 description:(@"Invalid parameter not satisfying: %s"), ("x != 0"), (0), (0), (0), (0)]; } } while(0);
+
+ if( (self = [super init]) != 0 )
+ {
+ *x = 1; // no-warning
+ }
+
+ return self;
+}
+
+- (id)initWithPointer2: (int*)x
+{
+ // Expansion of: NSAssert( x != 0, @"" );
+ do { if (!((x != 0))) { [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd object:self file:[NSString stringWithUTF8String:"CFRetainRelease_NSAssertionHandler.m"] lineNumber:33 description:((@"")), (0), (0), (0), (0), (0)]; } } while(0);
+
+ if( (self = [super init]) != 0 )
+ {
+ *x = 1; // no-warning
+ }
+
+ return self;
+}
+
+@end
+
+void pointerFunction (int *x) {
+ // Manual expansion of NSCAssert( x != 0, @"")
+ do { if (!((x != 0))) { [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithUTF8String:__PRETTY_FUNCTION__] file:[NSString stringWithUTF8String:__FILE__] lineNumber:__LINE__ description:((@""))]; } } while(0);
+
+ *x = 1; // no-warning
+}
diff --git a/clang/test/Analysis/CGColorSpace.c b/clang/test/Analysis/CGColorSpace.c
new file mode 100644
index 0000000..1bd20fa
--- /dev/null
+++ b/clang/test/Analysis/CGColorSpace.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -analyzer-constraints=basic -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -analyzer-constraints=range -verify %s
+
+typedef struct CGColorSpace *CGColorSpaceRef;
+extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void);
+extern CGColorSpaceRef CGColorSpaceRetain(CGColorSpaceRef space);
+extern void CGColorSpaceRelease(CGColorSpaceRef space);
+
+void f() {
+ CGColorSpaceRef X = CGColorSpaceCreateDeviceRGB(); // expected-warning{{leak}}
+ CGColorSpaceRetain(X);
+}
+
+void fb() {
+ CGColorSpaceRef X = CGColorSpaceCreateDeviceRGB();
+ CGColorSpaceRetain(X);
+ CGColorSpaceRelease(X);
+ CGColorSpaceRelease(X); // no-warning
+}
diff --git a/clang/test/Analysis/CheckNSError.m b/clang/test/Analysis/CheckNSError.m
new file mode 100644
index 0000000..d35b686
--- /dev/null
+++ b/clang/test/Analysis/CheckNSError.m
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
+
+
+typedef signed char BOOL;
+typedef int NSInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@interface NSObject <NSObject> {} @end
+@class NSDictionary;
+@interface NSError : NSObject <NSCopying, NSCoding> {}
++ (id)errorWithDomain:(NSString *)domain code:(NSInteger)code userInfo:(NSDictionary *)dict;
+@end
+extern NSString * const NSXMLParserErrorDomain ;
+
+@interface A
+- (void)myMethodWhichMayFail:(NSError **)error;
+- (BOOL)myMethodWhichMayFail2:(NSError **)error;
+@end
+
+@implementation A
+- (void)myMethodWhichMayFail:(NSError **)error { // expected-warning {{Method accepting NSError** should have a non-void return value to indicate whether or not an error occurred}}
+ *error = [NSError errorWithDomain:@"domain" code:1 userInfo:0]; // expected-warning {{Potential null dereference.}}
+}
+
+- (BOOL)myMethodWhichMayFail2:(NSError **)error { // no-warning
+ if (error) *error = [NSError errorWithDomain:@"domain" code:1 userInfo:0]; // no-warning
+ return 0;
+}
+@end
+
+struct __CFError {};
+typedef struct __CFError* CFErrorRef;
+
+void foo(CFErrorRef* error) { // expected-warning {{Function accepting CFErrorRef* should have a non-void return value to indicate whether or not an error occurred}}
+ *error = 0; // expected-warning {{Potential null dereference.}}
+}
+
+int f1(CFErrorRef* error) {
+ if (error) *error = 0; // no-warning
+ return 0;
+}
+
+int f2(CFErrorRef* error) {
+ if (0 != error) *error = 0; // no-warning
+ return 0;
+}
+
+int f3(CFErrorRef* error) {
+ if (error != 0) *error = 0; // no-warning
+ return 0;
+}
+
+
diff --git a/clang/test/Analysis/MissingDealloc.m b/clang/test/Analysis/MissingDealloc.m
new file mode 100644
index 0000000..51a5912
--- /dev/null
+++ b/clang/test/Analysis/MissingDealloc.m
@@ -0,0 +1,117 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.osx.cocoa.Dealloc '-DIBOutlet=__attribute__((iboutlet))' %s -verify
+typedef signed char BOOL;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (Class)class;
+@end
+
+@interface NSObject <NSObject> {}
+- (void)dealloc;
+- (id)init;
+@end
+
+typedef struct objc_selector *SEL;
+
+// <rdar://problem/6380411>: 'myproperty' has kind 'assign' and thus the
+// assignment through the setter does not perform a release.
+
+@interface MyObject : NSObject {
+ id _myproperty;
+}
+@property(assign) id myproperty;
+@end
+
+@implementation MyObject
+@synthesize myproperty=_myproperty; // no-warning
+- (void)dealloc {
+ self.myproperty = 0;
+ [super dealloc];
+}
+@end
+
+//===------------------------------------------------------------------------===
+// Don't warn about iVars that are selectors.
+
+@interface TestSELs : NSObject {
+ SEL a;
+ SEL b;
+}
+
+@end
+
+@implementation TestSELs
+- (id)init {
+ if( (self = [super init]) ) {
+ a = @selector(a);
+ b = @selector(b);
+ }
+
+ return self;
+}
+@end
+
+//===------------------------------------------------------------------------===
+// Don't warn about iVars that are IBOutlets.
+
+#ifndef IBOutlet
+#define IBOutlet
+#endif
+
+@class NSWindow;
+
+@interface HasOutlet : NSObject {
+IBOutlet NSWindow *window;
+}
+@end
+
+@implementation HasOutlet // no-warning
+@end
+
+//===------------------------------------------------------------------------===
+// <rdar://problem/6380411>
+// Was bogus warning: "The '_myproperty' instance variable was not retained by a
+// synthesized property but was released in 'dealloc'"
+
+@interface MyObject_rdar6380411 : NSObject {
+ id _myproperty;
+}
+@property(assign) id myproperty;
+@end
+
+@implementation MyObject_rdar6380411
+@synthesize myproperty=_myproperty;
+- (void)dealloc {
+ // Don't claim that myproperty is released since it the property
+ // has the 'assign' attribute.
+ self.myproperty = 0; // no-warning
+ [super dealloc];
+}
+@end
+
+//===------------------------------------------------------------------------===
+// PR 3187: http://llvm.org/bugs/show_bug.cgi?id=3187
+// - Disable the missing -dealloc check for classes that subclass SenTestCase
+
+@class NSString;
+
+@interface SenTestCase : NSObject {}
+@end
+
+@interface MyClassTest : SenTestCase {
+ NSString *resourcePath;
+}
+@end
+
+@interface NSBundle : NSObject {}
++ (NSBundle *)bundleForClass:(Class)aClass;
+- (NSString *)resourcePath;
+@end
+
+@implementation MyClassTest
+- (void)setUp {
+ resourcePath = [[NSBundle bundleForClass:[self class]] resourcePath];
+}
+- (void)testXXX {
+ // do something which uses resourcepath
+}
+@end
diff --git a/clang/test/Analysis/NSPanel.m b/clang/test/Analysis/NSPanel.m
new file mode 100644
index 0000000..578658e
--- /dev/null
+++ b/clang/test/Analysis/NSPanel.m
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
+
+// BEGIN delta-debugging reduced header stuff
+
+typedef struct objc_selector *SEL;
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (oneway void)release;
+@end
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+@protocol NSMutableCopying
+- (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+@protocol NSCoding
+- (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
++ (id)alloc;
+@end
+typedef float CGFloat;
+typedef struct _NSPoint {} NSRect;
+static __inline__ __attribute__((always_inline)) NSRect NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h) { NSRect r; return r; }
+typedef struct {} NSFastEnumerationState;
+@protocol NSFastEnumeration
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+@class NSString;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+- (NSUInteger)count;
+@end
+@interface NSMutableArray : NSArray
+- (void)addObject:(id)anObject;
+@end @class NSAppleEventDescriptor;
+enum { NSBackingStoreRetained = 0, NSBackingStoreNonretained = 1, NSBackingStoreBuffered = 2 };
+typedef NSUInteger NSBackingStoreType;
+@interface NSResponder : NSObject <NSCoding> {} @end
+@protocol NSAnimatablePropertyContainer
+- (id)animator;
+@end
+@protocol NSValidatedUserInterfaceItem
+- (SEL)action;
+@end
+@protocol NSUserInterfaceValidations
+- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
+@end @class NSDate, NSDictionary, NSError, NSException, NSNotification;
+enum { NSBorderlessWindowMask = 0, NSTitledWindowMask = 1 << 0, NSClosableWindowMask = 1 << 1, NSMiniaturizableWindowMask = 1 << 2, NSResizableWindowMask = 1 << 3 };
+@interface NSWindow : NSResponder <NSAnimatablePropertyContainer, NSUserInterfaceValidations> {}
+- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag;
+@end
+extern NSString *NSWindowDidBecomeKeyNotification;
+@interface NSPanel : NSWindow {}
+@end
+@class NSTableHeaderView;
+
+// END delta-debugging reduced header stuff
+
+@interface MyClass
+{
+ NSMutableArray *panels;
+}
+- (void)myMethod;
+- (void)myMethod2;
+@end
+
+@implementation MyClass // no-warning
+- (void)myMethod
+{
+ NSPanel *panel = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:(BOOL)1];
+
+ [panels addObject:panel];
+
+ [panel release]; // no-warning
+}
+- (void)myMethod2
+{
+ NSPanel *panel = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:(BOOL)1]; // no-warning
+
+ [panels addObject:panel];
+}
+@end
+
diff --git a/clang/test/Analysis/NSString.m b/clang/test/Analysis/NSString.m
new file mode 100644
index 0000000..4035cc9
--- /dev/null
+++ b/clang/test/Analysis/NSString.m
@@ -0,0 +1,408 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
+
+
+//===----------------------------------------------------------------------===//
+// The following code is reduced using delta-debugging from
+// Foundation.h (Mac OS X).
+//
+// It includes the basic definitions for the test cases below.
+// Not directly including Foundation.h directly makes this test case
+// both svelte and portable to non-Mac platforms.
+//===----------------------------------------------------------------------===//
+
+#ifdef TEST_64
+typedef long long int64_t;
+_Bool OSAtomicCompareAndSwap64Barrier( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue );
+#define COMPARE_SWAP_BARRIER OSAtomicCompareAndSwap64Barrier
+typedef int64_t intptr_t;
+#else
+typedef int int32_t;
+_Bool OSAtomicCompareAndSwap32Barrier( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue );
+#define COMPARE_SWAP_BARRIER OSAtomicCompareAndSwap32Barrier
+typedef int32_t intptr_t;
+#endif
+
+typedef const void * CFTypeRef;
+typedef const struct __CFString * CFStringRef;
+typedef const struct __CFAllocator * CFAllocatorRef;
+extern const CFAllocatorRef kCFAllocatorDefault;
+extern CFTypeRef CFRetain(CFTypeRef cf);
+void CFRelease(CFTypeRef cf);
+typedef const struct __CFDictionary * CFDictionaryRef;
+const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key);
+extern CFStringRef CFStringCreateWithFormat(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, ...);
+typedef signed char BOOL;
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+typedef NSInteger NSComparisonResult;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (oneway void)release;
+- (id)retain;
+- (id)autorelease;
+@end
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+@protocol NSMutableCopying
+- (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+@protocol NSCoding
+- (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
+- (id)init;
++ (id)alloc;
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+typedef struct {} NSFastEnumerationState;
+@protocol NSFastEnumeration
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+@class NSString;
+typedef struct _NSRange {} NSRange;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+- (NSUInteger)count;
+@end
+@interface NSMutableArray : NSArray
+- (void)addObject:(id)anObject;
+- (id)initWithCapacity:(NSUInteger)numItems;
+@end
+typedef unsigned short unichar;
+@class NSData, NSArray, NSDictionary, NSCharacterSet, NSData, NSURL, NSError, NSLocale;
+typedef NSUInteger NSStringCompareOptions;
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length;
+- (NSComparisonResult)compare:(NSString *)string;
+- (NSComparisonResult)compare:(NSString *)string options:(NSStringCompareOptions)mask;
+- (NSComparisonResult)compare:(NSString *)string options:(NSStringCompareOptions)mask range:(NSRange)compareRange;
+- (NSComparisonResult)compare:(NSString *)string options:(NSStringCompareOptions)mask range:(NSRange)compareRange locale:(id)locale;
+- (NSComparisonResult)caseInsensitiveCompare:(NSString *)string;
+- (NSArray *)componentsSeparatedByCharactersInSet:(NSCharacterSet *)separator;
++ (id)stringWithFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2)));
+@end
+@interface NSSimpleCString : NSString {} @end
+@interface NSConstantString : NSSimpleCString @end
+extern void *_NSConstantStringClassReference;
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+NSComparisonResult f1(NSString* s) {
+ NSString *aString = 0;
+ return [s compare:aString]; // expected-warning {{Argument to 'NSString' method 'compare:' cannot be nil}}
+}
+
+NSComparisonResult f2(NSString* s) {
+ NSString *aString = 0;
+ return [s caseInsensitiveCompare:aString]; // expected-warning {{Argument to 'NSString' method 'caseInsensitiveCompare:' cannot be nil}}
+}
+
+NSComparisonResult f3(NSString* s, NSStringCompareOptions op) {
+ NSString *aString = 0;
+ return [s compare:aString options:op]; // expected-warning {{Argument to 'NSString' method 'compare:options:' cannot be nil}}
+}
+
+NSComparisonResult f4(NSString* s, NSStringCompareOptions op, NSRange R) {
+ NSString *aString = 0;
+ return [s compare:aString options:op range:R]; // expected-warning {{Argument to 'NSString' method 'compare:options:range:' cannot be nil}}
+}
+
+NSComparisonResult f5(NSString* s, NSStringCompareOptions op, NSRange R) {
+ NSString *aString = 0;
+ return [s compare:aString options:op range:R locale:0]; // expected-warning {{Argument to 'NSString' method 'compare:options:range:locale:' cannot be nil}}
+}
+
+NSArray *f6(NSString* s) {
+ return [s componentsSeparatedByCharactersInSet:0]; // expected-warning {{Argument to 'NSString' method 'componentsSeparatedByCharactersInSet:' cannot be nil}}
+}
+
+NSString* f7(NSString* s1, NSString* s2, NSString* s3) {
+
+ NSString* s4 = (NSString*)
+ CFStringCreateWithFormat(kCFAllocatorDefault, 0, // expected-warning{{leak}}
+ (CFStringRef) __builtin___CFStringMakeConstantString("%@ %@ (%@)"),
+ s1, s2, s3);
+
+ CFRetain(s4);
+ return s4;
+}
+
+NSMutableArray* f8() {
+
+ NSString* s = [[NSString alloc] init];
+ NSMutableArray* a = [[NSMutableArray alloc] initWithCapacity:2];
+ [a addObject:s];
+ [s release]; // no-warning
+ return a;
+}
+
+void f9() {
+
+ NSString* s = [[NSString alloc] init];
+ NSString* q = s;
+ [s release];
+ [q release]; // expected-warning {{used after it is released}}
+}
+
+NSString* f10() {
+ static NSString* s = 0;
+ if (!s) s = [[NSString alloc] init];
+ return s; // no-warning
+}
+
+// Test case for regression reported in <rdar://problem/6452745>.
+// Essentially 's' should not be considered allocated on the false branch.
+// This exercises the 'EvalAssume' logic in GRTransferFuncs (CFRefCount.cpp).
+NSString* f11(CFDictionaryRef dict, const char* key) {
+ NSString* s = (NSString*) CFDictionaryGetValue(dict, key);
+ [s retain];
+ if (s) {
+ [s release];
+ }
+ return 0;
+}
+
+// Test case for passing a tracked object by-reference to a function we
+// don't understand.
+void unknown_function_f12(NSString** s);
+void f12() {
+ NSString *string = [[NSString alloc] init];
+ unknown_function_f12(&string); // no-warning
+}
+
+// Test double release of CFString (PR 4014).
+void f13(void) {
+ CFStringRef ref = CFStringCreateWithFormat(kCFAllocatorDefault, ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "%d" "")), 100);
+ CFRelease(ref);
+ CFRelease(ref); // expected-warning{{Reference-counted object is used after it is released}}
+}
+
+@interface MyString : NSString
+@end
+
+void f14(MyString *s) {
+ [s compare:0]; // expected-warning {{Argument to 'MyString' method 'compare:' cannot be nil}}
+}
+
+// Test regular use of -autorelease
+@interface TestAutorelease
+-(NSString*) getString;
+@end
+@implementation TestAutorelease
+-(NSString*) getString {
+ NSString *str = [[NSString alloc] init];
+ return [str autorelease]; // no-warning
+}
+- (void)m1
+{
+ NSString *s = [[NSString alloc] init]; // expected-warning{{leak}}
+ [s retain];
+ [s autorelease];
+}
+- (void)m2
+{
+ NSString *s = [[[NSString alloc] init] autorelease]; // expected-warning{{leak}}
+ [s retain];
+}
+- (void)m3
+{
+ NSString *s = [[[NSString alloc] init] autorelease];
+ [s retain];
+ [s autorelease];
+}
+- (void)m4
+{
+ NSString *s = [[NSString alloc] init]; // expected-warning{{leak}}
+ [s retain];
+}
+- (void)m5
+{
+ NSString *s = [[NSString alloc] init];
+ [s autorelease];
+}
+@end
+
+@interface C1 : NSObject {}
+- (NSString*) getShared;
++ (C1*) sharedInstance;
+@end
+@implementation C1 : NSObject {}
+- (NSString*) getShared {
+ static NSString* s = 0;
+ if (!s) s = [[NSString alloc] init];
+ return s; // no-warning
+}
++ (C1 *)sharedInstance {
+ static C1 *sharedInstance = 0;
+ if (!sharedInstance) {
+ sharedInstance = [[C1 alloc] init];
+ }
+ return sharedInstance; // no-warning
+}
+@end
+
+@interface SharedClass : NSObject
++ (id)sharedInstance;
+- (id)notShared;
+@end
+
+@implementation SharedClass
+
+- (id)_init {
+ if ((self = [super init])) {
+ NSLog(@"Bar");
+ }
+ return self;
+}
+
+- (id)notShared {
+ return [[SharedClass alloc] _init]; // expected-warning{{leak}}
+}
+
++ (id)sharedInstance {
+ static SharedClass *_sharedInstance = 0;
+ if (!_sharedInstance) {
+ _sharedInstance = [[SharedClass alloc] _init];
+ }
+ return _sharedInstance; // no-warning
+}
+@end
+
+id testSharedClassFromFunction() {
+ return [[SharedClass alloc] _init]; // no-warning
+}
+
+// Test OSCompareAndSwap
+_Bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue );
+extern BOOL objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation);
+
+void testOSCompareAndSwap() {
+ NSString *old = 0;
+ NSString *s = [[NSString alloc] init]; // no-warning
+ if (!OSAtomicCompareAndSwapPtr(0, s, (void**) &old))
+ [s release];
+ else
+ [old release];
+}
+
+void testOSCompareAndSwapXXBarrier_local() {
+ NSString *old = 0;
+ NSString *s = [[NSString alloc] init]; // no-warning
+ if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) &old))
+ [s release];
+ else
+ [old release];
+}
+
+void testOSCompareAndSwapXXBarrier_local_no_direct_release() {
+ NSString *old = 0;
+ NSString *s = [[NSString alloc] init]; // no-warning
+ if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) &old))
+ return;
+ else
+ [old release];
+}
+
+int testOSCompareAndSwapXXBarrier_id(Class myclass, id xclass) {
+ if (COMPARE_SWAP_BARRIER(0, (intptr_t) myclass, (intptr_t*) &xclass))
+ return 1;
+ return 0;
+}
+
+void test_objc_atomicCompareAndSwap_local() {
+ NSString *old = 0;
+ NSString *s = [[NSString alloc] init]; // no-warning
+ if (!objc_atomicCompareAndSwapPtr(0, s, &old))
+ [s release];
+ else
+ [old release];
+}
+
+void test_objc_atomicCompareAndSwap_local_no_direct_release() {
+ NSString *old = 0;
+ NSString *s = [[NSString alloc] init]; // no-warning
+ if (!objc_atomicCompareAndSwapPtr(0, s, &old))
+ return;
+ else
+ [old release];
+}
+
+void test_objc_atomicCompareAndSwap_parameter(NSString **old) {
+ NSString *s = [[NSString alloc] init]; // no-warning
+ if (!objc_atomicCompareAndSwapPtr(0, s, old))
+ [s release];
+ else
+ [*old release];
+}
+
+void test_objc_atomicCompareAndSwap_parameter_no_direct_release(NSString **old) {
+ NSString *s = [[NSString alloc] init]; // expected-warning{{leak}}
+ if (!objc_atomicCompareAndSwapPtr(0, s, old))
+ return;
+ else
+ [*old release];
+}
+
+
+// Test stringWithFormat (<rdar://problem/6815234>)
+void test_stringWithFormat() {
+ NSString *string = [[NSString stringWithFormat:@"%ld", (long) 100] retain];
+ [string release];
+ [string release]; // expected-warning{{Incorrect decrement of the reference count}}
+}
+
+// Test isTrackedObjectType().
+typedef NSString* WonkyTypedef;
+@interface TestIsTracked
++ (WonkyTypedef)newString;
+@end
+
+void test_isTrackedObjectType(void) {
+ NSString *str = [TestIsTracked newString]; // expected-warning{{Potential leak}}
+}
+
+// Test isTrackedCFObjectType().
+@interface TestIsCFTracked
++ (CFStringRef) badNewCFString;
++ (CFStringRef) newCFString;
+@end
+
+@implementation TestIsCFTracked
++ (CFStringRef) newCFString {
+ return CFStringCreateWithFormat(kCFAllocatorDefault, ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "%d" "")), 100); // no-warning
+}
++ (CFStringRef) badNewCFString {
+ return CFStringCreateWithFormat(kCFAllocatorDefault, ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "%d" "")), 100); // expected-warning{{leak}}
+}
+
+// Test @synchronized
+void test_synchronized(id x) {
+ @synchronized(x) {
+ NSString *string = [[NSString stringWithFormat:@"%ld", (long) 100] retain]; // expected-warning {{leak}}
+ }
+}
+@end
+
+void testOSCompareAndSwapXXBarrier_parameter(NSString **old) {
+ NSString *s = [[NSString alloc] init]; // no-warning
+ if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) old))
+ [s release];
+ else
+ [*old release];
+}
+
+void testOSCompareAndSwapXXBarrier_parameter_no_direct_release(NSString **old) {
+ NSString *s = [[NSString alloc] init]; // no-warning
+ if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) old))
+ [s release];
+ else
+ return;
+}
diff --git a/clang/test/Analysis/NSWindow.m b/clang/test/Analysis/NSWindow.m
new file mode 100644
index 0000000..495f8e1
--- /dev/null
+++ b/clang/test/Analysis/NSWindow.m
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core,deadcode.DeadStores -analyzer-store=region -analyzer-constraints=basic -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core,deadcode.DeadStores -analyzer-store=region -analyzer-constraints=range -verify %s
+
+// These declarations were reduced using Delta-Debugging from Foundation.h
+// on Mac OS X. The test cases are below.
+
+typedef struct objc_selector *SEL;
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+@end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
+ + (id)alloc;
+@end
+typedef float CGFloat;
+typedef struct _NSPoint {} NSRect;
+NSRect NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h);
+enum { NSBackingStoreRetained = 0, NSBackingStoreNonretained = 1, NSBackingStoreBuffered = 2 };
+typedef NSUInteger NSBackingStoreType;
+@interface NSResponder : NSObject <NSCoding> {}
+@end
+@protocol NSAnimatablePropertyContainer
+- (id)animator;
+@end
+extern NSString *NSAnimationTriggerOrderIn ;
+@class CIFilter, CALayer, NSDictionary, NSScreen, NSShadow, NSTrackingArea;
+@interface NSView : NSResponder <NSAnimatablePropertyContainer> {} @end
+@protocol NSValidatedUserInterfaceItem - (SEL)action; @end
+@protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem; @end @class NSNotification, NSText, NSView, NSMutableSet, NSSet, NSDate;
+enum { NSBorderlessWindowMask = 0, NSTitledWindowMask = 1 << 0, NSClosableWindowMask = 1 << 1, NSMiniaturizableWindowMask = 1 << 2, NSResizableWindowMask = 1 << 3 };
+@interface NSWindow : NSResponder <NSAnimatablePropertyContainer, NSUserInterfaceValidations> {
+ struct __wFlags {} _wFlags;
+}
+- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag;
+- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag screen:(NSScreen *)screen;
+- (void)orderFrontRegardless;
+@end
+
+extern NSString *NSWindowDidBecomeKeyNotification;
+
+// Test cases.
+
+void f1() {
+ NSWindow *window = [[NSWindow alloc]
+ initWithContentRect:NSMakeRect(0,0,100,100)
+ styleMask:NSTitledWindowMask|NSClosableWindowMask
+ backing:NSBackingStoreBuffered
+ defer:0];
+
+ [window orderFrontRegardless]; // no-warning
+}
+
+void f2() {
+ NSWindow *window = [[NSWindow alloc]
+ initWithContentRect:NSMakeRect(0,0,100,100)
+ styleMask:NSTitledWindowMask|NSClosableWindowMask
+ backing:NSBackingStoreBuffered
+ defer:0
+ screen:0];
+
+ [window orderFrontRegardless]; // no-warning
+}
+
+void f2b() {
+ // FIXME: NSWindow doesn't own itself until it is displayed.
+ NSWindow *window = [[NSWindow alloc] // no-warning
+ initWithContentRect:NSMakeRect(0,0,100,100)
+ styleMask:NSTitledWindowMask|NSClosableWindowMask
+ backing:NSBackingStoreBuffered
+ defer:0
+ screen:0];
+
+ [window orderFrontRegardless];
+
+ [window retain];
+}
+
+
+void f3() {
+ // FIXME: For now we don't track NSWindow.
+ NSWindow *window = [NSWindow alloc]; // expected-warning{{never read}}
+}
diff --git a/clang/test/Analysis/NoReturn.m b/clang/test/Analysis/NoReturn.m
new file mode 100644
index 0000000..ea2efd0
--- /dev/null
+++ b/clang/test/Analysis/NoReturn.m
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s
+
+#include <stdarg.h>
+
+//===----------------------------------------------------------------------===//
+// The following code is reduced using delta-debugging from
+// Foundation.h (Mac OS X).
+//
+// It includes the basic definitions for the test cases below.
+// Not directly including Foundation.h directly makes this test case
+// both svelte and portable to non-Mac platforms.
+//===----------------------------------------------------------------------===//
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@interface NSObject <NSObject> {} @end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
++ (id)stringWithFormat:(NSString *)format, ...;
+@end
+@interface NSSimpleCString : NSString {} @end
+@interface NSConstantString : NSSimpleCString @end
+extern void *_NSConstantStringClassReference;
+typedef double NSTimeInterval;
+@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate; @end
+@class NSString, NSDictionary, NSArray;
+@interface NSException : NSObject <NSCopying, NSCoding> {}
++ (NSException *)exceptionWithName:(NSString *)name reason:(NSString *)reason userInfo:(NSDictionary *)userInfo;
+- (void)raise;
+@end
+@interface NSException (NSExceptionRaisingConveniences)
++ (void)raise:(NSString *)name format:(NSString *)format, ...;
++ (void)raise:(NSString *)name format:(NSString *)format arguments:(va_list)argList;
+@end
+
+enum {NSPointerFunctionsStrongMemory = (0 << 0), NSPointerFunctionsZeroingWeakMemory = (1 << 0), NSPointerFunctionsOpaqueMemory = (2 << 0), NSPointerFunctionsMallocMemory = (3 << 0), NSPointerFunctionsMachVirtualMemory = (4 << 0), NSPointerFunctionsObjectPersonality = (0 << 8), NSPointerFunctionsOpaquePersonality = (1 << 8), NSPointerFunctionsObjectPointerPersonality = (2 << 8), NSPointerFunctionsCStringPersonality = (3 << 8), NSPointerFunctionsStructPersonality = (4 << 8), NSPointerFunctionsIntegerPersonality = (5 << 8), NSPointerFunctionsCopyIn = (1 << 16), };
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+int f1(int *x, NSString* s) {
+
+ if (x) ++x;
+
+ [NSException raise:@"Blah" format:[NSString stringWithFormat:@"Blah %@", s]];
+
+ return *x; // no-warning
+}
+
+int f2(int *x, ...) {
+
+ if (x) ++x;
+ va_list alist;
+ va_start(alist, x);
+
+ [NSException raise:@"Blah" format:@"Blah %@" arguments:alist];
+
+ return *x; // no-warning
+}
+
+int f3(int* x) {
+
+ if (x) ++x;
+
+ [[NSException exceptionWithName:@"My Exception" reason:@"Want to test exceptions." userInfo:0] raise];
+
+ return *x; // no-warning
+}
+
diff --git a/clang/test/Analysis/OSAtomic_mac.cpp b/clang/test/Analysis/OSAtomic_mac.cpp
new file mode 100644
index 0000000..8ad7b3c
--- /dev/null
+++ b/clang/test/Analysis/OSAtomic_mac.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,osx -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
+
+// Test handling of OSAtomicCompareAndSwap when C++ inserts "no-op" casts and we
+// do a forced load and binding to the environment on an expression that would regularly
+// not have an environment binding. This previously triggered a crash (<rdar://problem/9339920>).
+// NOTE: It is critical that the function called is OSAtomicCompareAndSwapIntBarrier.
+bool OSAtomicCompareAndSwapIntBarrier( int __oldValue, int __newValue, volatile int *__theValue ) ;
+static int _rdar9339920_x = 0;
+int rdar9339920_aux();
+
+int rdar9339920_test() {
+ int rdar9339920_x = rdar9339920_aux();
+ if (rdar9339920_x != _rdar9339920_x) {
+ if (OSAtomicCompareAndSwapIntBarrier(_rdar9339920_x, rdar9339920_x, &_rdar9339920_x))
+ return 1;
+ }
+ return 0;
+}
+
diff --git a/clang/test/Analysis/ObjCProperties.m b/clang/test/Analysis/ObjCProperties.m
new file mode 100644
index 0000000..b9ed9b9
--- /dev/null
+++ b/clang/test/Analysis/ObjCProperties.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=basic -Wno-objc-root-class %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -Wno-objc-root-class %s -verify
+
+// The point of this test cases is to exercise properties in the static
+// analyzer
+
+@interface MyClass {
+@private
+ id _X;
+}
+- (id)initWithY:(id)Y;
+@property(copy, readwrite) id X;
+@end
+
+@implementation MyClass
+@synthesize X = _X;
+- (id)initWithY:(id)Y {
+ self.X = Y;
+ return self;
+}
+@end
diff --git a/clang/test/Analysis/ObjCRetSigs.m b/clang/test/Analysis/ObjCRetSigs.m
new file mode 100644
index 0000000..13078a3
--- /dev/null
+++ b/clang/test/Analysis/ObjCRetSigs.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=osx.cocoa.IncompatibleMethodTypes -verify -Wno-objc-root-class %s
+
+int printf(const char *, ...);
+
+@interface MyBase
+-(long long)length;
+@end
+
+@interface MySub : MyBase{}
+-(double)length;
+@end
+
+@implementation MyBase
+-(long long)length{
+ printf("Called MyBase -length;\n");
+ return 3;
+}
+@end
+
+@implementation MySub
+-(double)length{ // expected-warning{{types are incompatible}}
+ printf("Called MySub -length;\n");
+ return 3.3;
+}
+@end
diff --git a/clang/test/Analysis/PR2599.m b/clang/test/Analysis/PR2599.m
new file mode 100644
index 0000000..5436063
--- /dev/null
+++ b/clang/test/Analysis/PR2599.m
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-constraints=range -analyzer-store=region -fobjc-gc -verify %s
+
+typedef const void * CFTypeRef;
+typedef const struct __CFString * CFStringRef;
+typedef const struct __CFAllocator * CFAllocatorRef;
+typedef const struct __CFDictionary * CFDictionaryRef;
+CFTypeRef CFMakeCollectable(CFTypeRef cf) ;
+extern CFStringRef CFStringCreateWithFormat(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, ...);
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)autorelease;
+@end
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSMutableCopying
+- (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+@protocol
+NSCoding
+- (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
+- (id)init;
++ (id)alloc;
+@end
+enum { NSASCIIStringEncoding = 1, NSNEXTSTEPStringEncoding = 2, NSJapaneseEUCStringEncoding = 3, NSUTF8StringEncoding = 4, NSISOLatin1StringEncoding = 5, NSSymbolStringEncoding = 6, NSNonLossyASCIIStringEncoding = 7, NSShiftJISStringEncoding = 8, NSISOLatin2StringEncoding = 9, NSUnicodeStringEncoding = 10, NSWindowsCP1251StringEncoding = 11, NSWindowsCP1252StringEncoding = 12, NSWindowsCP1253StringEncoding = 13, NSWindowsCP1254StringEncoding = 14, NSWindowsCP1250StringEncoding = 15, NSISO2022JPStringEncoding = 21, NSMacOSRomanStringEncoding = 30, NSUTF16StringEncoding = NSUnicodeStringEncoding, NSUTF16BigEndianStringEncoding = 0x90000100, NSUTF16LittleEndianStringEncoding = 0x94000100, NSUTF32StringEncoding = 0x8c000100, NSUTF32BigEndianStringEncoding = 0x98000100, NSUTF32LittleEndianStringEncoding = 0x9c000100 };
+typedef NSUInteger NSStringEncoding;
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
+- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)len encoding:(NSStringEncoding)encoding freeWhenDone:(BOOL)freeBuffer;
+@end
+@interface NSAutoreleasePool : NSObject {}
+- (void)drain;
+@end
+extern NSString * const NSXMLParserErrorDomain ;
+
+// The actual test case. UTIL_AUTORELEASE_CF_AS_ID is a macro that doesn't
+// actually do what it was intended to.
+
+#define NSSTRINGWRAPPER(bytes,len) \
+ [[[NSString alloc] initWithBytesNoCopy: (void*)(bytes) length: (len) encoding: NSUTF8StringEncoding freeWhenDone: (BOOL)0] autorelease]
+
+#define UTIL_AUTORELEASE_CF_AS_ID(cf) ( (((void*)0) == (cf)) ? ((void*)0) : [(id) CFMakeCollectable( (CFTypeRef) cf) autorelease] )
+
+#define UTIL_AUTORELEASE_CF_AS_ID_WITHOUT_TEST(cf) ( [(id) CFMakeCollectable( (CFTypeRef) cf) autorelease] )
+
+static char *lorem = "fooBarBaz";
+
+void NSLog(NSString *, ...);
+
+int main (int argc, const char * argv[]) {
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ NSString *tmp1 = NSSTRINGWRAPPER(lorem, 6); // no-warning
+ NSString *tmp2 = UTIL_AUTORELEASE_CF_AS_ID( CFStringCreateWithFormat(((void*)0), ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "lorem: %@" "")), tmp1) ); // expected-warning 2 {{leak}}
+ NSString *tmp3 = UTIL_AUTORELEASE_CF_AS_ID_WITHOUT_TEST( CFStringCreateWithFormat(((void*)0), ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "lorem: %@" "")), tmp1) );
+ NSLog(@"tmp2: %@ tmp3: %@", tmp2, tmp3);
+ [pool drain];
+ return 0;
+}
diff --git a/clang/test/Analysis/PR2978.m b/clang/test/Analysis/PR2978.m
new file mode 100644
index 0000000..ea139d2
--- /dev/null
+++ b/clang/test/Analysis/PR2978.m
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=experimental.osx.cocoa.Dealloc %s -verify
+
+// Tests for the checker which checks missing/extra ivar 'release' calls
+// in dealloc.
+
+@interface NSObject
+- (void)release;
+- dealloc;
+@end
+
+@interface MyClass : NSObject {
+@private
+ id _X;
+ id _Y;
+ id _Z;
+ id _K;
+ id _N;
+ id _M;
+ id _V;
+ id _W;
+}
+@property(retain) id X;
+@property(retain) id Y;
+@property(assign) id Z;
+@property(assign) id K;
+@property(readonly) id N;
+@property(retain) id M;
+@property(retain) id V;
+@property(retain) id W;
+-(id) O;
+-(void) setO: (id) arg;
+@end
+
+@implementation MyClass
+@synthesize X = _X;
+@synthesize Y = _Y; // expected-warning{{The '_Y' instance variable was retained by a synthesized property but wasn't released in 'dealloc'}}
+@synthesize Z = _Z; // expected-warning{{The '_Z' instance variable was not retained by a synthesized property but was released in 'dealloc'}}
+@synthesize K = _K;
+@synthesize N = _N;
+@synthesize M = _M;
+@synthesize V = _V;
+@synthesize W = _W; // expected-warning{{The '_W' instance variable was retained by a synthesized property but wasn't released in 'dealloc'}}
+
+-(id) O{ return 0; }
+-(void) setO:(id)arg { }
+
+- (id)dealloc
+{
+ [_X release];
+ [_Z release];
+ [_N release];
+
+ self.M = 0; // This will release '_M'
+ [self setV:0]; // This will release '_V'
+ [self setW:@"newW"]; // This will release '_W', but retain the new value
+ self.O = 0; // no-warning
+ [super dealloc];
+ return 0;
+}
+
+@end
+
diff --git a/clang/test/Analysis/PR3991.m b/clang/test/Analysis/PR3991.m
new file mode 100644
index 0000000..38d0bc0
--- /dev/null
+++ b/clang/test/Analysis/PR3991.m
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify -triple x86_64-apple-darwin9 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -triple x86_64-apple-darwin9 %s
+
+//===----------------------------------------------------------------------===//
+// Delta-debugging produced forward declarations.
+//===----------------------------------------------------------------------===//
+
+typedef signed char BOOL;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end @interface NSObject <NSObject> {
+}
+@end extern id <NSObject> NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone);
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding> - (unsigned)count;
+@end @class NSTimer, NSPort, NSArray;
+@class NSURLHandle, NSMutableArray, NSMutableData, NSData, NSURL;
+@interface NSResponder : NSObject <NSCoding> {
+}
+@end @class NSBitmapImageRep, NSCursor, NSGraphicsContext, NSImage, NSPasteboard, NSScrollView, NSWindow, NSAttributedString;
+@interface NSView : NSResponder {
+ struct __VFlags2 {
+ }
+ _vFlags2;
+}
+@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError;
+@interface NSBox : NSView {
+}
+@end @class GDataFeedDocList, GDataServiceTicket, GDataServiceTicket, IHGoogleDocsAdapter;
+@protocol IHGoogleDocsAdapterDelegate - (void)googleDocsAdapter:(IHGoogleDocsAdapter*)inGoogleDocsAdapter accountVerifyIsValid:(BOOL)inIsValid error:(NSError *)inError;
+@end @interface IHGoogleDocsAdapter : NSObject {
+}
+- (NSArray *)entries; // expected-note {{method definition for 'entries' not found}}
+@end extern Class const kGDataUseRegisteredClass ;
+@interface IHGoogleDocsAdapter () - (GDataFeedDocList *)feedDocList; // expected-note {{method definition for 'feedDocList' not found}}
+- (NSArray *)directoryPathComponents; // expected-note {{method definition for 'directoryPathComponents' not found}}
+- (unsigned int)currentPathComponentIndex; // expected-note {{method definition for 'currentPathComponentIndex' not found}}
+- (void)setCurrentPathComponentIndex:(unsigned int)aCurrentPathComponentIndex; // expected-note {{method definition for 'setCurrentPathComponentIndex:' not found}}
+- (NSURL *)folderFeedURL; // expected-note {{method definition for 'folderFeedURL' not found}}
+@end
+
+@implementation IHGoogleDocsAdapter - (id)initWithUsername:(NSString *)inUsername password:(NSString *)inPassword owner:(NSObject <IHGoogleDocsAdapterDelegate> *)owner { // expected-warning {{incomplete implementation}}
+ return 0;
+}
+
+//===----------------------------------------------------------------------===//
+// Actual test case:
+//
+// The analyzer currently doesn't reason about ObjCKVCRefExpr. Have both
+// GRExprEngine::Visit and GRExprEngine::VisitLValue have such expressions
+// evaluate to UnknownVal.
+//===----------------------------------------------------------------------===//
+
+- (void)docListListFetchTicket:(GDataServiceTicket *)ticket finishedWithFeed:(GDataFeedDocList *)feed {
+ BOOL doGetDir = self.directoryPathComponents != 0 && self.currentPathComponentIndex < [self.directoryPathComponents count];
+ if (doGetDir) {
+ BOOL isDirExisting = [[self.feedDocList entries] count] > 0;
+ if (isDirExisting) {
+ if (self.folderFeedURL != 0) {
+ if (++self.currentPathComponentIndex == [self.directoryPathComponents count]) {
+ }
+ }
+ }
+ }
+}
+@end
diff --git a/clang/test/Analysis/PR7218.c b/clang/test/Analysis/PR7218.c
new file mode 100644
index 0000000..1775e05
--- /dev/null
+++ b/clang/test/Analysis/PR7218.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -verify %s
+char PR7218(char a) {
+ char buf[2];
+ buf[0] = a;
+ return buf[1]; // expected-warning {{Undefined or garbage value returned to caller}}
+}
diff --git a/clang/test/Analysis/PR9741.cpp b/clang/test/Analysis/PR9741.cpp
new file mode 100644
index 0000000..7497d56
--- /dev/null
+++ b/clang/test/Analysis/PR9741.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -cc1 -std=c++11 -Wuninitialized -verify %s
+
+void f() {
+ int a[] = { 1, 2, 3 };
+ unsigned int u = 0;
+ for (auto x : a)
+ ;
+}
diff --git a/clang/test/Analysis/additive-folding-range-constraints.c b/clang/test/Analysis/additive-folding-range-constraints.c
new file mode 100644
index 0000000..32e0cfe
--- /dev/null
+++ b/clang/test/Analysis/additive-folding-range-constraints.c
@@ -0,0 +1,99 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -verify -analyzer-constraints=range %s
+
+// These are used to trigger warnings.
+typedef typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+#define NULL ((void*)0)
+#define UINT_MAX (__INT_MAX__ *2U +1U)
+
+// Each of these adjusted ranges has an adjustment small enough to split the
+// solution range across an overflow boundary (Min for <, Max for >).
+// This corresponds to one set of branches in RangeConstraintManager.
+void smallAdjustmentGT (unsigned a) {
+ char* b = NULL;
+ if (a+2 > 1)
+ b = malloc(1);
+ if (a == UINT_MAX-1 || a == UINT_MAX)
+ return; // no-warning
+ else if (a < UINT_MAX-1)
+ free(b);
+ return; // no-warning
+}
+
+void smallAdjustmentGE (unsigned a) {
+ char* b = NULL;
+ if (a+2 >= 1)
+ b = malloc(1);
+ if (a == UINT_MAX-1)
+ return; // no-warning
+ else if (a < UINT_MAX-1 || a == UINT_MAX)
+ free(b);
+ return; // no-warning
+}
+
+void smallAdjustmentLT (unsigned a) {
+ char* b = NULL;
+ if (a+1 < 2)
+ b = malloc(1);
+ if (a == 0 || a == UINT_MAX)
+ free(b);
+ return; // no-warning
+}
+
+void smallAdjustmentLE (unsigned a) {
+ char* b = NULL;
+ if (a+1 <= 2)
+ b = malloc(1);
+ if (a == 0 || a == 1 || a == UINT_MAX)
+ free(b);
+ return; // no-warning
+}
+
+
+// Each of these adjusted ranges has an adjustment large enough to push the
+// comparison value over an overflow boundary (Min for <, Max for >).
+// This corresponds to one set of branches in RangeConstraintManager.
+void largeAdjustmentGT (unsigned a) {
+ char* b = NULL;
+ if (a-2 > UINT_MAX-1)
+ b = malloc(1);
+ if (a == 1 || a == 0)
+ free(b);
+ else if (a > 1)
+ free(b);
+ return; // no-warning
+}
+
+void largeAdjustmentGE (unsigned a) {
+ char* b = NULL;
+ if (a-2 >= UINT_MAX-1)
+ b = malloc(1);
+ if (a > 1)
+ return; // no-warning
+ else if (a == 1 || a == 0)
+ free(b);
+ return; // no-warning
+}
+
+void largeAdjustmentLT (unsigned a) {
+ char* b = NULL;
+ if (a+2 < 1)
+ b = malloc(1);
+ if (a == UINT_MAX-1 || a == UINT_MAX)
+ free(b);
+ else if (a < UINT_MAX-1)
+ return; // no-warning
+ return; // no-warning
+}
+
+void largeAdjustmentLE (unsigned a) {
+ char* b = NULL;
+ if (a+2 <= 1)
+ b = malloc(1);
+ if (a < UINT_MAX-1)
+ return; // no-warning
+ else if (a == UINT_MAX-1 || a == UINT_MAX)
+ free(b);
+ return; // no-warning
+}
diff --git a/clang/test/Analysis/additive-folding.c b/clang/test/Analysis/additive-folding.c
new file mode 100644
index 0000000..beb08aa
--- /dev/null
+++ b/clang/test/Analysis/additive-folding.c
@@ -0,0 +1,203 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,unix.Malloc -verify -analyzer-constraints=basic %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,unix.Malloc -verify -analyzer-constraints=range %s
+
+// These are used to trigger warnings.
+typedef typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+#define NULL ((void*)0)
+#define UINT_MAX -1U
+
+//---------------
+// Plus/minus
+//---------------
+
+void separateExpressions (int a) {
+ int b = a + 1;
+ --b;
+
+ char* buf = malloc(1);
+ if (a != 0 && b == 0)
+ return; // expected-warning{{never executed}}
+ free(buf);
+}
+
+void oneLongExpression (int a) {
+ // Expression canonicalization should still allow this to work, even though
+ // the first term is on the left.
+ int b = 15 + a + 15 - 10 - 20;
+
+ char* buf = malloc(1);
+ if (a != 0 && b == 0)
+ return; // expected-warning{{never executed}}
+ free(buf);
+}
+
+void mixedTypes (int a) {
+ char* buf = malloc(1);
+
+ // Different additive types should not cause crashes when constant-folding.
+ // This is part of PR7406.
+ int b = a + 1LL;
+ if (a != 0 && (b-1) == 0) // not crash
+ return; // expected-warning{{never executed}}
+
+ int c = a + 1U;
+ if (a != 0 && (c-1) == 0) // not crash
+ return; // expected-warning{{never executed}}
+
+ free(buf);
+}
+
+//---------------
+// Comparisons
+//---------------
+
+// Equality and inequality only
+void eq_ne (unsigned a) {
+ char* b = NULL;
+ if (a == UINT_MAX)
+ b = malloc(1);
+ if (a+1 != 0)
+ return; // no-warning
+ if (a-1 != UINT_MAX-1)
+ return; // no-warning
+ free(b);
+}
+
+void ne_eq (unsigned a) {
+ char* b = NULL;
+ if (a != UINT_MAX)
+ b = malloc(1);
+ if (a+1 == 0)
+ return; // no-warning
+ if (a-1 == UINT_MAX-1)
+ return; // no-warning
+ free(b);
+}
+
+// Mixed typed inequalities (part of PR7406)
+// These should not crash.
+void mixed_eq_ne (int a) {
+ char* b = NULL;
+ if (a == 1)
+ b = malloc(1);
+ if (a+1U != 2)
+ return; // no-warning
+ if (a-1U != 0)
+ return; // expected-warning{{never executed}}
+ free(b);
+}
+
+void mixed_ne_eq (int a) {
+ char* b = NULL;
+ if (a != 1)
+ b = malloc(1);
+ if (a+1U == 2)
+ return; // no-warning
+ if (a-1U == 0)
+ return; // expected-warning{{never executed}}
+ free(b);
+}
+
+
+// Simple order comparisons with no adjustment
+void baselineGT (unsigned a) {
+ char* b = NULL;
+ if (a > 0)
+ b = malloc(1);
+ if (a == 0)
+ return; // no-warning
+ free(b);
+}
+
+void baselineGE (unsigned a) {
+ char* b = NULL;
+ if (a >= UINT_MAX)
+ b = malloc(1);
+ if (a == UINT_MAX)
+ free(b);
+ return; // no-warning
+}
+
+void baselineLT (unsigned a) {
+ char* b = NULL;
+ if (a < UINT_MAX)
+ b = malloc(1);
+ if (a == UINT_MAX)
+ return; // no-warning
+ free(b);
+}
+
+void baselineLE (unsigned a) {
+ char* b = NULL;
+ if (a <= 0)
+ b = malloc(1);
+ if (a == 0)
+ free(b);
+ return; // no-warning
+}
+
+
+// Adjustment gives each of these an extra solution!
+void adjustedGT (unsigned a) {
+ char* b = NULL;
+ if (a-1 > UINT_MAX-1)
+ b = malloc(1);
+ return; // expected-warning{{leak}}
+}
+
+void adjustedGE (unsigned a) {
+ char* b = NULL;
+ if (a-1 >= UINT_MAX-1)
+ b = malloc(1);
+ if (a == UINT_MAX)
+ free(b);
+ return; // expected-warning{{leak}}
+}
+
+void adjustedLT (unsigned a) {
+ char* b = NULL;
+ if (a+1 < 1)
+ b = malloc(1);
+ return; // expected-warning{{leak}}
+}
+
+void adjustedLE (unsigned a) {
+ char* b = NULL;
+ if (a+1 <= 1)
+ b = malloc(1);
+ if (a == 0)
+ free(b);
+ return; // expected-warning{{leak}}
+}
+
+
+// Tautologies
+void tautologyGT (unsigned a) {
+ char* b = malloc(1);
+ if (a > UINT_MAX)
+ return; // no-warning
+ free(b);
+}
+
+void tautologyGE (unsigned a) {
+ char* b = malloc(1);
+ if (a >= 0) // expected-warning{{always true}}
+ free(b);
+ return; // no-warning
+}
+
+void tautologyLT (unsigned a) {
+ char* b = malloc(1);
+ if (a < 0) // expected-warning{{always false}}
+ return; // expected-warning{{never executed}}
+ free(b);
+}
+
+void tautologyLE (unsigned a) {
+ char* b = malloc(1);
+ if (a <= UINT_MAX)
+ free(b);
+ return; // no-warning
+}
diff --git a/clang/test/Analysis/analyzeOneFunction.m b/clang/test/Analysis/analyzeOneFunction.m
new file mode 100644
index 0000000..1ff2fc8
--- /dev/null
+++ b/clang/test/Analysis/analyzeOneFunction.m
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -analyze -analyze-function="myMethodWithY:withX:" -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
+@interface NSObject <NSObject> {}
++(id)alloc;
+-(id)init;
+-(id)autorelease;
+-(id)copy;
+-(id)retain;
+@end
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
+-(id)initWithFormat:(NSString *)f,...;
+-(BOOL)isEqualToString:(NSString *)s;
++ (id)string;
+@end
+
+@interface Test1 : NSObject {
+ NSString *text;
+}
+-(id)myMethod;
+-(id)myMethodWithY:(int)Y withX:(int)X;
+
+@property (nonatomic, assign) NSString *text;
+@end
+
+@implementation Test1
+
+@synthesize text;
+
+-(id)myMethod {
+ Test1 *cell = [[[Test1 alloc] init] autorelease];
+
+ NSString *string1 = [[NSString alloc] initWithFormat:@"test %f", 0.0]; // No warning: this function is not analized.
+ cell.text = string1;
+
+ return cell;
+}
+
+-(id)myMethodWithY:(int)Y withX:(int)X {
+ Test1 *cell = [[[Test1 alloc] init] autorelease];
+
+ NSString *string1 = [[NSString alloc] initWithFormat:@"test %f %d", 0.0, X+Y]; // expected-warning {{Potential leak}}
+ cell.text = string1;
+
+ return cell;
+}
+
+@end
diff --git a/clang/test/Analysis/analyze_display_progress.c b/clang/test/Analysis/analyze_display_progress.c
new file mode 100644
index 0000000..958ed00
--- /dev/null
+++ b/clang/test/Analysis/analyze_display_progress.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -analyzer-display-progress %s 2>&1 | FileCheck %s
+
+void f() {};
+void g() {};
+void h() {}
+
+// CHECK: analyze_display_progress.c f
+// CHECK: analyze_display_progress.c g
+// CHECK: analyze_display_progress.c h \ No newline at end of file
diff --git a/clang/test/Analysis/analyzer-stats.c b/clang/test/Analysis/analyzer-stats.c
new file mode 100644
index 0000000..9eeaade
--- /dev/null
+++ b/clang/test/Analysis/analyzer-stats.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,deadcode.DeadStores,debug.Stats -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
+
+int foo();
+
+int test() { // expected-warning{{Total CFGBlocks}}
+ int a = 1;
+ a = 34 / 12;
+
+ if (foo())
+ return a;
+
+ a /= 4;
+ return a;
+}
diff --git a/clang/test/Analysis/array-struct-region.c b/clang/test/Analysis/array-struct-region.c
new file mode 100644
index 0000000..4b085c8
--- /dev/null
+++ b/clang/test/Analysis/array-struct-region.c
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,experimental.deadcode.UnreachableCode -analyzer-store=region -analyzer-constraints=basic -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,experimental.deadcode.UnreachableCode -analyzer-store=region -analyzer-constraints=range -verify %s
+
+int string_literal_init() {
+ char a[] = "abc";
+ char b[2] = "abc"; // expected-warning{{too long}}
+ char c[5] = "abc";
+
+ if (a[1] != 'b')
+ return 0; // expected-warning{{never executed}}
+ if (b[1] != 'b')
+ return 0; // expected-warning{{never executed}}
+ if (c[1] != 'b')
+ return 0; // expected-warning{{never executed}}
+
+ if (a[3] != 0)
+ return 0; // expected-warning{{never executed}}
+ if (c[3] != 0)
+ return 0; // expected-warning{{never executed}}
+
+ if (c[4] != 0)
+ return 0; // expected-warning{{never executed}}
+
+ return 42;
+}
+
+void nested_compound_literals(int rad) {
+ int vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, // expected-warning 6 {{implicit conversion turns literal floating-point number into integer}}
+ {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; // expected-warning 6 {{implicit conversion turns literal floating-point number into integer}}
+ int a;
+
+ for (a = 0; a < 6; ++a) {
+ vec[a][0] *= rad; // no-warning
+ vec[a][1] *= rad; // no-warning
+ }
+}
+
+void nested_compound_literals_float(float rad) {
+ float vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169},
+ {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+ int a;
+
+ for (a = 0; a < 6; ++a) {
+ vec[a][0] *= rad; // no-warning
+ vec[a][1] *= rad; // no-warning
+ }
+}
diff --git a/clang/test/Analysis/array-struct.c b/clang/test/Analysis/array-struct.c
new file mode 100644
index 0000000..c5bdb86
--- /dev/null
+++ b/clang/test/Analysis/array-struct.c
@@ -0,0 +1,178 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core.CastToStruct -analyzer-store=region -analyzer-constraints=basic -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core.CastToStruct -analyzer-store=region -analyzer-constraints=range -verify %s
+
+struct s {
+ int data;
+ int data_array[10];
+};
+
+typedef struct {
+ int data;
+} STYPE;
+
+void g(char *p);
+void g1(struct s* p);
+
+// Array to pointer conversion. Array in the struct field.
+void f(void) {
+ int a[10];
+ int (*p)[10];
+ p = &a;
+ (*p)[3] = 1;
+
+ struct s d;
+ struct s *q;
+ q = &d;
+ q->data = 3;
+ d.data_array[9] = 17;
+}
+
+// StringLiteral in lvalue context and pointer to array type.
+// p: ElementRegion, q: StringRegion
+void f2() {
+ char *p = "/usr/local";
+ char (*q)[4];
+ q = &"abc";
+}
+
+// Typedef'ed struct definition.
+void f3() {
+ STYPE s;
+}
+
+// Initialize array with InitExprList.
+void f4() {
+ int a[] = { 1, 2, 3};
+ int b[3] = { 1, 2 };
+ struct s c[] = {{1,{1}}};
+}
+
+// Struct variable in lvalue context.
+// Assign UnknownVal to the whole struct.
+void f5() {
+ struct s data;
+ g1(&data);
+}
+
+// AllocaRegion test.
+void f6() {
+ char *p;
+ p = __builtin_alloca(10);
+ g(p);
+ char c = *p;
+ p[1] = 'a';
+ // Test if RegionStore::EvalBinOp converts the alloca region to element
+ // region.
+ p += 2;
+}
+
+struct s2;
+
+void g2(struct s2 *p);
+
+// Incomplete struct pointer used as function argument.
+void f7() {
+ struct s2 *p = __builtin_alloca(10);
+ g2(p);
+}
+
+// sizeof() is unsigned while -1 is signed in array index.
+void f8() {
+ int a[10];
+ a[sizeof(a)/sizeof(int) - 1] = 1; // no-warning
+}
+
+// Initialization of struct array elements.
+void f9() {
+ struct s a[10];
+}
+
+// Initializing array with string literal.
+void f10() {
+ char a1[4] = "abc";
+ char a3[6] = "abc";
+}
+
+// Retrieve the default value of element/field region.
+void f11() {
+ struct s a;
+ g1(&a);
+ if (a.data == 0) // no-warning
+ a.data = 1;
+}
+
+// Convert unsigned offset to signed when creating ElementRegion from
+// SymbolicRegion.
+void f12(int *list) {
+ unsigned i = 0;
+ list[i] = 1;
+}
+
+struct s1 {
+ struct s2 {
+ int d;
+ } e;
+};
+
+// The binding of a.e.d should not be removed. Test recursive subregion map
+// building: a->e, e->d. Only then 'a' could be added to live region roots.
+void f13(double timeout) {
+ struct s1 a;
+ a.e.d = (int) timeout;
+ if (a.e.d == 10)
+ a.e.d = 4;
+}
+
+struct s3 {
+ int a[2];
+};
+
+static struct s3 opt;
+
+// Test if the embedded array is retrieved correctly.
+void f14() {
+ struct s3 my_opt = opt;
+}
+
+void bar(int*);
+
+// Test if the array is correctly invalidated.
+void f15() {
+ int a[10];
+ bar(a);
+ if (a[1]) // no-warning
+ (void)1;
+}
+
+struct s3 p[1];
+
+// Code from postgresql.
+// Current cast logic of region store mistakenly leaves the final result region
+// an ElementRegion of type 'char'. Then load a nonloc::SymbolVal from it and
+// assigns to 'a'.
+void f16(struct s3 *p) {
+ struct s3 a = *((struct s3*) ((char*) &p[0])); // expected-warning{{Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption.}}
+}
+
+void inv(struct s1 *);
+
+// Invalidate the struct field.
+void f17() {
+ struct s1 t;
+ int x;
+ inv(&t);
+ if (t.e.d)
+ x = 1;
+}
+
+void read(char*);
+
+void f18() {
+ char *q;
+ char *p = (char *) __builtin_alloca(10);
+ read(p);
+ q = p;
+ q++;
+ if (*q) { // no-warning
+ }
+}
diff --git a/clang/test/Analysis/auto-obj-dtors-cfg-output.cpp b/clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
new file mode 100644
index 0000000..67a8f2e
--- /dev/null
+++ b/clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
@@ -0,0 +1,864 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+// XPASS: *
+
+class A {
+public:
+ A() {}
+ ~A() {}
+ operator int() const { return 1; }
+};
+
+extern const bool UV;
+
+void test_const_ref() {
+ A a;
+ const A& b = a;
+ const A& c = A();
+}
+
+void test_array() {
+ A a[2];
+ A b[0];
+}
+
+void test_scope() {
+ A a;
+ { A c;
+ A d;
+ }
+ A b;
+}
+
+void test_return() {
+ A a;
+ A b;
+ if (UV) return;
+ A c;
+}
+
+void test_goto() {
+ A a;
+l0:
+ A b;
+ { A a;
+ if (UV) goto l0;
+ if (UV) goto l1;
+ A b;
+ }
+l1:
+ A c;
+}
+
+void test_if_implicit_scope() {
+ A a;
+ if (A b = a)
+ A c;
+ else A c;
+}
+
+void test_if_jumps() {
+ A a;
+ if (A b = a) {
+ A c;
+ if (UV) return;
+ A d;
+ } else {
+ A c;
+ if (UV) return;
+ A d;
+ }
+ A e;
+}
+
+void test_while_implicit_scope() {
+ A a;
+ while (A b = a)
+ A c;
+}
+
+void test_while_jumps() {
+ A a;
+ while (A b = a) {
+ A c;
+ if (UV) break;
+ if (UV) continue;
+ if (UV) return;
+ A d;
+ }
+ A e;
+}
+
+void test_do_implicit_scope() {
+ do A a;
+ while (UV);
+}
+
+void test_do_jumps() {
+ A a;
+ do {
+ A b;
+ if (UV) break;
+ if (UV) continue;
+ if (UV) return;
+ A c;
+ } while (UV);
+ A d;
+}
+
+void test_switch_implicit_scope() {
+ A a;
+ switch (A b = a)
+ A c;
+}
+
+void test_switch_jumps() {
+ A a;
+ switch (A b = a) {
+ case 0: {
+ A c;
+ if (UV) break;
+ if (UV) return;
+ A f;
+ }
+ case 1:
+ break;
+ }
+ A g;
+}
+
+void test_for_implicit_scope() {
+ for (A a; A b = a; )
+ A c;
+}
+
+void test_for_jumps() {
+ A a;
+ for (A b; A c = b; ) {
+ A d;
+ if (UV) break;
+ if (UV) continue;
+ if (UV) return;
+ A e;
+ }
+ A f;
+}
+
+void test_catch_const_ref() {
+ try {
+ } catch (const A& e) {
+ }
+}
+
+void test_catch_copy() {
+ try {
+ } catch (A e) {
+ }
+}
+
+// CHECK: [B1 (ENTRY)]
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B1 (ENTRY)]
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: 1
+// CHECK: 2: return [B1.1];
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: a
+// CHECK: 4: [B1.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 5: const A &b = a;
+// CHECK: 6: A() (CXXConstructExpr, class A)
+// CHECK: 7: [B1.6] (BindTemporary)
+// CHECK: 8: [B1.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B1.8]
+// CHECK: 10: const A &c = A();
+// CHECK: 11: [B1.10].~A() (Implicit destructor)
+// CHECK: 12: [B1.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A [2])
+// CHECK: 2: A a[2];
+// CHECK: 3: (CXXConstructExpr, class A [0])
+// CHECK: 4: A b[0];
+// CHECK: 5: [B1.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: (CXXConstructExpr, class A)
+// CHECK: 4: A c;
+// CHECK: 5: (CXXConstructExpr, class A)
+// CHECK: 6: A d;
+// CHECK: 7: [B1.6].~A() (Implicit destructor)
+// CHECK: 8: [B1.4].~A() (Implicit destructor)
+// CHECK: 9: (CXXConstructExpr, class A)
+// CHECK: 10: A b;
+// CHECK: 11: [B1.10].~A() (Implicit destructor)
+// CHECK: 12: [B1.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B4 (ENTRY)]
+// CHECK: Succs (1): B3
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B1.2].~A() (Implicit destructor)
+// CHECK: 4: [B3.4].~A() (Implicit destructor)
+// CHECK: 5: [B3.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: return;
+// CHECK: 2: [B3.4].~A() (Implicit destructor)
+// CHECK: 3: [B3.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B3
+// CHECK: Succs (1): B0
+// CHECK: [B3]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: (CXXConstructExpr, class A)
+// CHECK: 4: A b;
+// CHECK: 5: UV
+// CHECK: 6: [B3.5] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B3.6]
+// CHECK: Preds (1): B4
+// CHECK: Succs (2): B2 B1
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (2): B1 B2
+// CHECK: [B8 (ENTRY)]
+// CHECK: Succs (1): B7
+// CHECK: [B1]
+// CHECK: l1:
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B1.2].~A() (Implicit destructor)
+// CHECK: 4: [B6.2].~A() (Implicit destructor)
+// CHECK: 5: [B7.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A b;
+// CHECK: 3: [B2.2].~A() (Implicit destructor)
+// CHECK: 4: [B6.4].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: [B6.4].~A() (Implicit destructor)
+// CHECK: T: goto l1;
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: UV
+// CHECK: 2: [B4.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B4.2]
+// CHECK: Preds (1): B6
+// CHECK: Succs (2): B3 B2
+// CHECK: [B5]
+// CHECK: 1: [B6.4].~A() (Implicit destructor)
+// CHECK: 2: [B6.2].~A() (Implicit destructor)
+// CHECK: T: goto l0;
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B6
+// CHECK: [B6]
+// CHECK: l0:
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A b;
+// CHECK: 3: (CXXConstructExpr, class A)
+// CHECK: 4: A a;
+// CHECK: 5: UV
+// CHECK: 6: [B6.5] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B6.6]
+// CHECK: Preds (2): B7 B5
+// CHECK: Succs (2): B5 B4
+// CHECK: [B7]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B6
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B5 (ENTRY)]
+// CHECK: Succs (1): B4
+// CHECK: [B1]
+// CHECK: 1: [B4.6].~A() (Implicit destructor)
+// CHECK: 2: [B4.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B2.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B3.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: a
+// CHECK: 4: [B4.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 5: [B4.4] (CXXConstructExpr, class A)
+// CHECK: 6: A b = a;
+// CHECK: 7: b
+// CHECK: 8: [B4.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B4.8].operator int
+// CHECK: 10: [B4.9]()
+// CHECK: 11: [B4.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 12: [B4.11] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: if [B4.12]
+// CHECK: Preds (1): B5
+// CHECK: Succs (2): B3 B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B9 (ENTRY)]
+// CHECK: Succs (1): B8
+// CHECK: [B1]
+// CHECK: 1: [B8.6].~A() (Implicit destructor)
+// CHECK: 2: (CXXConstructExpr, class A)
+// CHECK: 3: A e;
+// CHECK: 4: [B1.3].~A() (Implicit destructor)
+// CHECK: 5: [B8.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B5
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A d;
+// CHECK: 3: [B2.2].~A() (Implicit destructor)
+// CHECK: 4: [B4.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: return;
+// CHECK: 2: [B4.2].~A() (Implicit destructor)
+// CHECK: 3: [B8.6].~A() (Implicit destructor)
+// CHECK: 4: [B8.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B0
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: UV
+// CHECK: 4: [B4.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B4.4]
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B3 B2
+// CHECK: [B5]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A d;
+// CHECK: 3: [B5.2].~A() (Implicit destructor)
+// CHECK: 4: [B7.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B1
+// CHECK: [B6]
+// CHECK: 1: return;
+// CHECK: 2: [B7.2].~A() (Implicit destructor)
+// CHECK: 3: [B8.6].~A() (Implicit destructor)
+// CHECK: 4: [B8.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B0
+// CHECK: [B7]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: UV
+// CHECK: 4: [B7.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B7.4]
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B6 B5
+// CHECK: [B8]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: a
+// CHECK: 4: [B8.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 5: [B8.4] (CXXConstructExpr, class A)
+// CHECK: 6: A b = a;
+// CHECK: 7: b
+// CHECK: 8: [B8.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B8.8].operator int
+// CHECK: 10: [B8.9]()
+// CHECK: 11: [B8.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 12: [B8.11] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: if [B8.12]
+// CHECK: Preds (1): B9
+// CHECK: Succs (2): B7 B4
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (3): B1 B3 B6
+// CHECK: [B6 (ENTRY)]
+// CHECK: Succs (1): B5
+// CHECK: [B1]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: 2: [B5.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: a
+// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B2.2] (CXXConstructExpr, class A)
+// CHECK: 4: A b = a;
+// CHECK: 5: b
+// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 7: [B2.6].operator int
+// CHECK: 8: [B2.7]()
+// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: while [B2.10]
+// CHECK: Preds (2): B3 B5
+// CHECK: Succs (2): B4 B1
+// CHECK: [B3]
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B2
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B4.2].~A() (Implicit destructor)
+// CHECK: 4: [B2.4].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B3
+// CHECK: [B5]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B12 (ENTRY)]
+// CHECK: Succs (1): B11
+// CHECK: [B1]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: 2: (CXXConstructExpr, class A)
+// CHECK: 3: A e;
+// CHECK: 4: [B1.3].~A() (Implicit destructor)
+// CHECK: 5: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B9 B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: a
+// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B2.2] (CXXConstructExpr, class A)
+// CHECK: 4: A b = a;
+// CHECK: 5: b
+// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 7: [B2.6].operator int
+// CHECK: 8: [B2.7]()
+// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: while [B2.10]
+// CHECK: Preds (2): B3 B11
+// CHECK: Succs (2): B10 B1
+// CHECK: [B3]
+// CHECK: Preds (2): B4 B7
+// CHECK: Succs (1): B2
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A d;
+// CHECK: 3: [B4.2].~A() (Implicit destructor)
+// CHECK: 4: [B10.2].~A() (Implicit destructor)
+// CHECK: 5: [B2.4].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B3
+// CHECK: [B5]
+// CHECK: 1: return;
+// CHECK: 2: [B10.2].~A() (Implicit destructor)
+// CHECK: 3: [B2.4].~A() (Implicit destructor)
+// CHECK: 4: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B0
+// CHECK: [B6]
+// CHECK: 1: UV
+// CHECK: 2: [B6.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B6.2]
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B5 B4
+// CHECK: [B7]
+// CHECK: 1: [B10.2].~A() (Implicit destructor)
+// CHECK: 2: [B2.4].~A() (Implicit destructor)
+// CHECK: T: continue;
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B3
+// CHECK: [B8]
+// CHECK: 1: UV
+// CHECK: 2: [B8.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B8.2]
+// CHECK: Preds (1): B10
+// CHECK: Succs (2): B7 B6
+// CHECK: [B9]
+// CHECK: 1: [B10.2].~A() (Implicit destructor)
+// CHECK: T: break;
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B1
+// CHECK: [B10]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: UV
+// CHECK: 4: [B10.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B10.4]
+// CHECK: Preds (1): B2
+// CHECK: Succs (2): B9 B8
+// CHECK: [B11]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: Preds (1): B12
+// CHECK: Succs (1): B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (2): B1 B5
+// CHECK: [B4 (ENTRY)]
+// CHECK: Succs (1): B2
+// CHECK: [B1]
+// CHECK: 1: UV
+// CHECK: 2: [B1.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: do ... while [B1.2]
+// CHECK: Preds (1): B2
+// CHECK: Succs (2): B3 B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: [B2.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B3 B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: Preds (1): B1
+// CHECK: Succs (1): B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B12 (ENTRY)]
+// CHECK: Succs (1): B11
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A d;
+// CHECK: 3: [B1.2].~A() (Implicit destructor)
+// CHECK: 4: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B8 B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: UV
+// CHECK: 2: [B2.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: do ... while [B2.2]
+// CHECK: Preds (2): B3 B6
+// CHECK: Succs (2): B10 B1
+// CHECK: [B3]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B3.2].~A() (Implicit destructor)
+// CHECK: 4: [B9.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B5
+// CHECK: Succs (1): B2
+// CHECK: [B4]
+// CHECK: 1: return;
+// CHECK: 2: [B9.2].~A() (Implicit destructor)
+// CHECK: 3: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B5
+// CHECK: Succs (1): B0
+// CHECK: [B5]
+// CHECK: 1: UV
+// CHECK: 2: [B5.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B5.2]
+// CHECK: Preds (1): B7
+// CHECK: Succs (2): B4 B3
+// CHECK: [B6]
+// CHECK: 1: [B9.2].~A() (Implicit destructor)
+// CHECK: T: continue;
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B2
+// CHECK: [B7]
+// CHECK: 1: UV
+// CHECK: 2: [B7.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B7.2]
+// CHECK: Preds (1): B9
+// CHECK: Succs (2): B6 B5
+// CHECK: [B8]
+// CHECK: 1: [B9.2].~A() (Implicit destructor)
+// CHECK: T: break;
+// CHECK: Preds (1): B9
+// CHECK: Succs (1): B1
+// CHECK: [B9]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A b;
+// CHECK: 3: UV
+// CHECK: 4: [B9.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B9.4]
+// CHECK: Preds (2): B10 B11
+// CHECK: Succs (2): B8 B7
+// CHECK: [B10]
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B9
+// CHECK: [B11]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: Preds (1): B12
+// CHECK: Succs (1): B9
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (2): B1 B4
+// CHECK: [B4 (ENTRY)]
+// CHECK: Succs (1): B2
+// CHECK: [B1]
+// CHECK: 1: [B2.6].~A() (Implicit destructor)
+// CHECK: 2: [B2.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B3 B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: a
+// CHECK: 4: [B2.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 5: [B2.4] (CXXConstructExpr, class A)
+// CHECK: 6: A b = a;
+// CHECK: 7: b
+// CHECK: 8: [B2.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B2.8].operator int
+// CHECK: 10: [B2.9]()
+// CHECK: 11: [B2.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: T: switch [B2.11]
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B3.2].~A() (Implicit destructor)
+// CHECK: Succs (1): B1
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B9 (ENTRY)]
+// CHECK: Succs (1): B2
+// CHECK: [B1]
+// CHECK: 1: [B2.6].~A() (Implicit destructor)
+// CHECK: 2: (CXXConstructExpr, class A)
+// CHECK: 3: A g;
+// CHECK: 4: [B1.3].~A() (Implicit destructor)
+// CHECK: 5: [B2.2].~A() (Implicit destructor)
+// CHECK: Preds (3): B3 B7 B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: a
+// CHECK: 4: [B2.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 5: [B2.4] (CXXConstructExpr, class A)
+// CHECK: 6: A b = a;
+// CHECK: 7: b
+// CHECK: 8: [B2.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B2.8].operator int
+// CHECK: 10: [B2.9]()
+// CHECK: 11: [B2.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: T: switch [B2.11]
+// CHECK: Preds (1): B9
+// CHECK: Succs (3): B3 B8
+// CHECK: B1
+// CHECK: [B3]
+// CHECK: case 1:
+// CHECK: T: break;
+// CHECK: Preds (2): B2 B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A f;
+// CHECK: 3: [B4.2].~A() (Implicit destructor)
+// CHECK: 4: [B8.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B3
+// CHECK: [B5]
+// CHECK: 1: return;
+// CHECK: 2: [B8.2].~A() (Implicit destructor)
+// CHECK: 3: [B2.6].~A() (Implicit destructor)
+// CHECK: 4: [B2.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B0
+// CHECK: [B6]
+// CHECK: 1: UV
+// CHECK: 2: [B6.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B6.2]
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B5 B4
+// CHECK: [B7]
+// CHECK: 1: [B8.2].~A() (Implicit destructor)
+// CHECK: T: break;
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B1
+// CHECK: [B8]
+// CHECK: case 0:
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: UV
+// CHECK: 4: [B8.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B8.4]
+// CHECK: Preds (1): B2
+// CHECK: Succs (2): B7 B6
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (2): B1 B5
+// CHECK: [B6 (ENTRY)]
+// CHECK: Succs (1): B5
+// CHECK: [B1]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: 2: [B5.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: a
+// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B2.2] (CXXConstructExpr, class A)
+// CHECK: 4: A b = a;
+// CHECK: 5: b
+// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 7: [B2.6].operator int
+// CHECK: 8: [B2.7]()
+// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: for (...; [B2.10]; )
+// CHECK: Preds (2): B3 B5
+// CHECK: Succs (2): B4 B1
+// CHECK: [B3]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B2
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B4.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B3
+// CHECK: [B5]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B12 (ENTRY)]
+// CHECK: Succs (1): B11
+// CHECK: [B1]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: 2: [B11.4].~A() (Implicit destructor)
+// CHECK: 3: (CXXConstructExpr, class A)
+// CHECK: 4: A f;
+// CHECK: 5: [B1.4].~A() (Implicit destructor)
+// CHECK: 6: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B9 B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: b
+// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B2.2] (CXXConstructExpr, class A)
+// CHECK: 4: A c = b;
+// CHECK: 5: c
+// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 7: [B2.6].operator int
+// CHECK: 8: [B2.7]()
+// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: for (...; [B2.10]; )
+// CHECK: Preds (2): B3 B11
+// CHECK: Succs (2): B10 B1
+// CHECK: [B3]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: Preds (2): B4 B7
+// CHECK: Succs (1): B2
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A e;
+// CHECK: 3: [B4.2].~A() (Implicit destructor)
+// CHECK: 4: [B10.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B3
+// CHECK: [B5]
+// CHECK: 1: return;
+// CHECK: 2: [B10.2].~A() (Implicit destructor)
+// CHECK: 3: [B2.4].~A() (Implicit destructor)
+// CHECK: 4: [B11.4].~A() (Implicit destructor)
+// CHECK: 5: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B0
+// CHECK: [B6]
+// CHECK: 1: UV
+// CHECK: 2: [B6.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B6.2]
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B5 B4
+// CHECK: [B7]
+// CHECK: 1: [B10.2].~A() (Implicit destructor)
+// CHECK: T: continue;
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B3
+// CHECK: [B8]
+// CHECK: 1: UV
+// CHECK: 2: [B8.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B8.2]
+// CHECK: Preds (1): B10
+// CHECK: Succs (2): B7 B6
+// CHECK: [B9]
+// CHECK: 1: [B10.2].~A() (Implicit destructor)
+// CHECK: T: break;
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B1
+// CHECK: [B10]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A d;
+// CHECK: 3: UV
+// CHECK: 4: [B10.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B10.4]
+// CHECK: Preds (1): B2
+// CHECK: Succs (2): B9 B8
+// CHECK: [B11]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: (CXXConstructExpr, class A)
+// CHECK: 4: A b;
+// CHECK: Preds (1): B12
+// CHECK: Succs (1): B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (2): B1 B5
+// CHECK: [B3 (ENTRY)]
+// CHECK: Succs (1): B0
+// CHECK: [B1]
+// CHECK: T: try ...
+// CHECK: Succs (2): B2 B0
+// CHECK: [B2]
+// CHECK: catch (const A &e):
+// CHECK: 1: catch (const A &e) {
+// CHECK: }
+// CHECK: Preds (1): B1
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (3): B2 B1 B3
+// CHECK: [B3 (ENTRY)]
+// CHECK: Succs (1): B0
+// CHECK: [B1]
+// CHECK: T: try ...
+// CHECK: Succs (2): B2 B0
+// CHECK: [B2]
+// CHECK: catch (A e):
+// CHECK: 1: catch (A e) {
+// CHECK: }
+// CHECK: 2: [B2.1].~A() (Implicit destructor)
+// CHECK: Preds (1): B1
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (3): B2 B1 B3
diff --git a/clang/test/Analysis/base-init.cpp b/clang/test/Analysis/base-init.cpp
new file mode 100644
index 0000000..8fd7abc
--- /dev/null
+++ b/clang/test/Analysis/base-init.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -analyzer-inline-call -cfg-add-initializers -verify %s
+// XFAIL: *
+
+class A {
+ int x;
+public:
+ A();
+ int getx() const {
+ return x;
+ }
+};
+
+A::A() : x(0) {
+}
+
+class B : public A {
+ int y;
+public:
+ B();
+};
+
+B::B() {
+}
+
+void f() {
+ B b;
+ if (b.getx() != 0) {
+ int *p = 0;
+ *p = 0; // no-warning
+ }
+}
diff --git a/clang/test/Analysis/blocks.m b/clang/test/Analysis/blocks.m
new file mode 100644
index 0000000..7a604dd
--- /dev/null
+++ b/clang/test/Analysis/blocks.m
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core -analyzer-store=region -fblocks -verify %s
+
+//===----------------------------------------------------------------------===//
+// The following code is reduced using delta-debugging from Mac OS X headers:
+//===----------------------------------------------------------------------===//
+
+typedef __builtin_va_list va_list;
+typedef unsigned int uint32_t;
+typedef struct dispatch_queue_s *dispatch_queue_t;
+typedef struct dispatch_queue_attr_s *dispatch_queue_attr_t;
+typedef void (^dispatch_block_t)(void);
+void dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
+__attribute__((visibility("default"))) __attribute__((__malloc__)) __attribute__((__warn_unused_result__)) __attribute__((__nothrow__)) dispatch_queue_t dispatch_queue_create(const char *label, dispatch_queue_attr_t attr);
+typedef long dispatch_once_t;
+void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);
+typedef signed char BOOL;
+typedef unsigned long NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (oneway void)release;
+@end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@interface NSObject <NSObject> {}
++ (id)alloc;
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length;
+- ( const char *)UTF8String;
+- (id)initWithFormat:(NSString *)format arguments:(va_list)argList __attribute__((format(__NSString__, 1, 0)));
+@end
+@class NSString, NSData;
+typedef struct cssm_sample {} CSSM_SAMPLEGROUP, *CSSM_SAMPLEGROUP_PTR;
+typedef struct __aslclient *aslclient;
+typedef struct __aslmsg *aslmsg;
+aslclient asl_open(const char *ident, const char *facility, uint32_t opts);
+int asl_log(aslclient asl, aslmsg msg, int level, const char *format, ...) __attribute__((__format__ (__printf__, 4, 5)));
+
+//===----------------------------------------------------------------------===//
+// Begin actual test cases.
+//===----------------------------------------------------------------------===//
+
+// test1 - This test case exposed logic that caused the analyzer to crash because of a memory bug
+// in BlockDataRegion. It represents real code that contains two block literals. Eventually
+// via IPA 'logQueue' and 'client' should be updated after the call to 'dispatch_once'.
+void test1(NSString *format, ...) {
+ static dispatch_queue_t logQueue;
+ static aslclient client;
+ static dispatch_once_t pred;
+ do {
+ if (__builtin_expect(*(&pred), ~0l) != ~0l)
+ dispatch_once(&pred, ^{
+ logQueue = dispatch_queue_create("com.mycompany.myproduct.asl", ((void*)0));
+ client = asl_open(((void*)0), "com.mycompany.myproduct", 0);
+ });
+ } while (0);
+
+ va_list args;
+ __builtin_va_start(args, format);
+
+ NSString *str = [[NSString alloc] initWithFormat:format arguments:args];
+ dispatch_async(logQueue, ^{ asl_log(client, ((void*)0), 4, "%s", [str UTF8String]); });
+ [str release];
+
+ __builtin_va_end(args);
+}
+
+// test2 - Test that captured variables that are uninitialized are flagged
+// as such.
+void test2() {
+ static int y = 0;
+ int x;
+ ^{ y = x + 1; }(); // expected-warning{{Variable 'x' is uninitialized when captured by block}}
+}
+
+void test2_b() {
+ static int y = 0;
+ __block int x;
+ // This is also a bug, but should be found not by checking the value
+ // 'x' is bound at block creation.
+ ^{ y = x + 1; }(); // no-warning
+}
+
+void test2_c() {
+ typedef void (^myblock)(void);
+ myblock f = ^() { f(); }; // expected-warning{{Variable 'f' is uninitialized when captured by block}}
+} \ No newline at end of file
diff --git a/clang/test/Analysis/bool-assignment.cpp b/clang/test/Analysis/bool-assignment.cpp
new file mode 100644
index 0000000..e573129
--- /dev/null
+++ b/clang/test/Analysis/bool-assignment.cpp
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core.BoolAssignment -analyzer-store=region -verify %s
+
+// Test C++'s bool
+
+void test_cppbool_initialization(int y) {
+ if (y < 0) {
+ bool x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ bool x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ bool x = y; // no-warning
+}
+
+void test_cppbool_assignment(int y) {
+ bool x = 0; // no-warning
+ if (y < 0) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ x = y; // no-warning
+}
+
+// Test Objective-C's BOOL
+
+typedef signed char BOOL;
+
+void test_BOOL_initialization(int y) {
+ if (y < 0) {
+ BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ BOOL x = y; // no-warning
+}
+
+void test_BOOL_assignment(int y) {
+ BOOL x = 0; // no-warning
+ if (y < 0) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ x = y; // no-warning
+}
+
+
+// Test MacTypes.h's Boolean
+
+typedef unsigned char Boolean;
+
+void test_Boolean_initialization(int y) {
+ if (y < 0) {
+ Boolean x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ Boolean x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ Boolean x = y; // no-warning
+}
+
+void test_Boolean_assignment(int y) {
+ Boolean x = 0; // no-warning
+ if (y < 0) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ x = y; // no-warning
+}
diff --git a/clang/test/Analysis/bool-assignment2.c b/clang/test/Analysis/bool-assignment2.c
new file mode 100644
index 0000000..9de26cf
--- /dev/null
+++ b/clang/test/Analysis/bool-assignment2.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -std=c99 -analyze -analyzer-checker=core,experimental.core.BoolAssignment -analyzer-store=region -verify %s
+
+// Test stdbool.h's _Bool
+
+// Prior to C99, stdbool.h uses this typedef, but even in ANSI C mode, _Bool
+// appears to be defined.
+
+// #if __STDC_VERSION__ < 199901L
+// typedef int _Bool;
+// #endif
+
+void test_stdbool_initialization(int y) {
+ if (y < 0) {
+ _Bool x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ _Bool x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ _Bool x = y; // no-warning
+}
+
+void test_stdbool_assignment(int y) {
+ _Bool x = 0; // no-warning
+ if (y < 0) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ x = y; // no-warning
+}
diff --git a/clang/test/Analysis/bstring.c b/clang/test/Analysis/bstring.c
new file mode 100644
index 0000000..833c917
--- /dev/null
+++ b/clang/test/Analysis/bstring.c
@@ -0,0 +1,430 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,unix.cstring.NullArg,experimental.unix.cstring.OutOfBounds,experimental.unix.cstring.BufferOverlap,experimental.unix.cstring.NotNullTerminated -analyzer-store=region -Wno-null-dereference -verify %s
+
+//===----------------------------------------------------------------------===
+// Declarations
+//===----------------------------------------------------------------------===
+
+// Some functions are so similar to each other that they follow the same code
+// path, such as memcpy and __memcpy_chk, or memcmp and bcmp. If VARIANT is
+// defined, make sure to use the variants instead to make sure they are still
+// checked by the analyzer.
+
+// Some functions are implemented as builtins. These should be #defined as
+// BUILTIN(f), which will prepend "__builtin_" if USE_BUILTINS is defined.
+
+// Functions that have variants and are also available as builtins should be
+// declared carefully! See memcpy() for an example.
+
+#ifdef USE_BUILTINS
+# define BUILTIN(f) __builtin_ ## f
+#else /* USE_BUILTINS */
+# define BUILTIN(f) f
+#endif /* USE_BUILTINS */
+
+typedef typeof(sizeof(int)) size_t;
+
+//===----------------------------------------------------------------------===
+// memcpy()
+//===----------------------------------------------------------------------===
+
+#ifdef VARIANT
+
+#define __memcpy_chk BUILTIN(__memcpy_chk)
+void *__memcpy_chk(void *restrict s1, const void *restrict s2, size_t n,
+ size_t destlen);
+
+#define memcpy(a,b,c) __memcpy_chk(a,b,c,(size_t)-1)
+
+#else /* VARIANT */
+
+#define memcpy BUILTIN(memcpy)
+void *memcpy(void *restrict s1, const void *restrict s2, size_t n);
+
+#endif /* VARIANT */
+
+
+void memcpy0 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[4] = {0};
+
+ memcpy(dst, src, 4); // no-warning
+
+ if (memcpy(dst, src, 4) != dst) {
+ (void)*(char*)0; // no-warning
+ }
+
+ if (dst[0] != 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void memcpy1 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[10];
+
+ memcpy(dst, src, 5); // expected-warning{{Memory copy function accesses out-of-bound array element}}
+}
+
+void memcpy2 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[1];
+
+ memcpy(dst, src, 4); // expected-warning{{Memory copy function overflows destination buffer}}
+}
+
+void memcpy3 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[3];
+
+ memcpy(dst+1, src+2, 2); // no-warning
+}
+
+void memcpy4 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[10];
+
+ memcpy(dst+2, src+2, 3); // expected-warning{{Memory copy function accesses out-of-bound array element}}
+}
+
+void memcpy5() {
+ char src[] = {1, 2, 3, 4};
+ char dst[3];
+
+ memcpy(dst+2, src+2, 2); // expected-warning{{Memory copy function overflows destination buffer}}
+}
+
+void memcpy6() {
+ int a[4] = {0};
+ memcpy(a, a, 8); // expected-warning{{overlapping}}
+}
+
+void memcpy7() {
+ int a[4] = {0};
+ memcpy(a+2, a+1, 8); // expected-warning{{overlapping}}
+}
+
+void memcpy8() {
+ int a[4] = {0};
+ memcpy(a+1, a+2, 8); // expected-warning{{overlapping}}
+}
+
+void memcpy9() {
+ int a[4] = {0};
+ memcpy(a+2, a+1, 4); // no-warning
+ memcpy(a+1, a+2, 4); // no-warning
+}
+
+void memcpy10() {
+ char a[4] = {0};
+ memcpy(0, a, 4); // expected-warning{{Null pointer argument in call to memory copy function}}
+}
+
+void memcpy11() {
+ char a[4] = {0};
+ memcpy(a, 0, 4); // expected-warning{{Null pointer argument in call to memory copy function}}
+}
+
+void memcpy12() {
+ char a[4] = {0};
+ memcpy(0, a, 0); // no-warning
+}
+
+void memcpy13() {
+ char a[4] = {0};
+ memcpy(a, 0, 0); // no-warning
+}
+
+void memcpy_unknown_size (size_t n) {
+ char a[4], b[4] = {1};
+ if (memcpy(a, b, n) != a)
+ (void)*(char*)0; // no-warning
+}
+
+void memcpy_unknown_size_warn (size_t n) {
+ char a[4];
+ if (memcpy(a, 0, n) != a) // expected-warning{{Null pointer argument in call to memory copy function}}
+ (void)*(char*)0; // no-warning
+}
+
+//===----------------------------------------------------------------------===
+// mempcpy()
+//===----------------------------------------------------------------------===
+
+#ifdef VARIANT
+
+#define __mempcpy_chk BUILTIN(__mempcpy_chk)
+void *__mempcpy_chk(void *restrict s1, const void *restrict s2, size_t n,
+ size_t destlen);
+
+#define mempcpy(a,b,c) __mempcpy_chk(a,b,c,(size_t)-1)
+
+#else /* VARIANT */
+
+#define mempcpy BUILTIN(mempcpy)
+void *mempcpy(void *restrict s1, const void *restrict s2, size_t n);
+
+#endif /* VARIANT */
+
+
+void mempcpy0 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[5] = {0};
+
+ mempcpy(dst, src, 4); // no-warning
+
+ if (mempcpy(dst, src, 4) != &dst[4]) {
+ (void)*(char*)0; // no-warning
+ }
+
+ if (dst[0] != 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void mempcpy1 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[10];
+
+ mempcpy(dst, src, 5); // expected-warning{{Memory copy function accesses out-of-bound array element}}
+}
+
+void mempcpy2 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[1];
+
+ mempcpy(dst, src, 4); // expected-warning{{Memory copy function overflows destination buffer}}
+}
+
+void mempcpy3 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[3];
+
+ mempcpy(dst+1, src+2, 2); // no-warning
+}
+
+void mempcpy4 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[10];
+
+ mempcpy(dst+2, src+2, 3); // expected-warning{{Memory copy function accesses out-of-bound array element}}
+}
+
+void mempcpy5() {
+ char src[] = {1, 2, 3, 4};
+ char dst[3];
+
+ mempcpy(dst+2, src+2, 2); // expected-warning{{Memory copy function overflows destination buffer}}
+}
+
+void mempcpy6() {
+ int a[4] = {0};
+ mempcpy(a, a, 8); // expected-warning{{overlapping}}
+}
+
+void mempcpy7() {
+ int a[4] = {0};
+ mempcpy(a+2, a+1, 8); // expected-warning{{overlapping}}
+}
+
+void mempcpy8() {
+ int a[4] = {0};
+ mempcpy(a+1, a+2, 8); // expected-warning{{overlapping}}
+}
+
+void mempcpy9() {
+ int a[4] = {0};
+ mempcpy(a+2, a+1, 4); // no-warning
+ mempcpy(a+1, a+2, 4); // no-warning
+}
+
+void mempcpy10() {
+ char a[4] = {0};
+ mempcpy(0, a, 4); // expected-warning{{Null pointer argument in call to memory copy function}}
+}
+
+void mempcpy11() {
+ char a[4] = {0};
+ mempcpy(a, 0, 4); // expected-warning{{Null pointer argument in call to memory copy function}}
+}
+
+void mempcpy12() {
+ char a[4] = {0};
+ mempcpy(0, a, 0); // no-warning
+}
+
+void mempcpy13() {
+ char a[4] = {0};
+ mempcpy(a, 0, 0); // no-warning
+}
+
+void mempcpy_unknown_size_warn (size_t n) {
+ char a[4];
+ if (mempcpy(a, 0, n) != a) // expected-warning{{Null pointer argument in call to memory copy function}}
+ (void)*(char*)0; // no-warning
+}
+
+void mempcpy_unknownable_size (char *src, float n) {
+ char a[4];
+ // This used to crash because we don't model floats.
+ mempcpy(a, src, (size_t)n);
+}
+
+//===----------------------------------------------------------------------===
+// memmove()
+//===----------------------------------------------------------------------===
+
+#ifdef VARIANT
+
+#define __memmove_chk BUILTIN(__memmove_chk)
+void *__memmove_chk(void *s1, const void *s2, size_t n, size_t destlen);
+
+#define memmove(a,b,c) __memmove_chk(a,b,c,(size_t)-1)
+
+#else /* VARIANT */
+
+#define memmove BUILTIN(memmove)
+void *memmove(void *s1, const void *s2, size_t n);
+
+#endif /* VARIANT */
+
+
+void memmove0 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[4] = {0};
+
+ memmove(dst, src, 4); // no-warning
+
+ if (memmove(dst, src, 4) != dst) {
+ (void)*(char*)0; // no-warning
+ }
+
+ if (dst[0] != 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void memmove1 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[10];
+
+ memmove(dst, src, 5); // expected-warning{{out-of-bound}}
+}
+
+void memmove2 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[1];
+
+ memmove(dst, src, 4); // expected-warning{{overflow}}
+}
+
+//===----------------------------------------------------------------------===
+// memcmp()
+//===----------------------------------------------------------------------===
+
+#ifdef VARIANT
+
+#define bcmp BUILTIN(bcmp)
+// __builtin_bcmp is not defined with const in Builtins.def.
+int bcmp(/*const*/ void *s1, /*const*/ void *s2, size_t n);
+#define memcmp bcmp
+
+#else /* VARIANT */
+
+#define memcmp BUILTIN(memcmp)
+int memcmp(const void *s1, const void *s2, size_t n);
+
+#endif /* VARIANT */
+
+
+void memcmp0 () {
+ char a[] = {1, 2, 3, 4};
+ char b[4] = { 0 };
+
+ memcmp(a, b, 4); // no-warning
+}
+
+void memcmp1 () {
+ char a[] = {1, 2, 3, 4};
+ char b[10] = { 0 };
+
+ memcmp(a, b, 5); // expected-warning{{out-of-bound}}
+}
+
+void memcmp2 () {
+ char a[] = {1, 2, 3, 4};
+ char b[1] = { 0 };
+
+ memcmp(a, b, 4); // expected-warning{{out-of-bound}}
+}
+
+void memcmp3 () {
+ char a[] = {1, 2, 3, 4};
+
+ if (memcmp(a, a, 4))
+ (void)*(char*)0; // no-warning
+}
+
+void memcmp4 (char *input) {
+ char a[] = {1, 2, 3, 4};
+
+ if (memcmp(a, input, 4))
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void memcmp5 (char *input) {
+ char a[] = {1, 2, 3, 4};
+
+ if (memcmp(a, 0, 0)) // no-warning
+ (void)*(char*)0; // no-warning
+ if (memcmp(0, a, 0)) // no-warning
+ (void)*(char*)0; // no-warning
+ if (memcmp(a, input, 0)) // no-warning
+ (void)*(char*)0; // no-warning
+}
+
+void memcmp6 (char *a, char *b, size_t n) {
+ int result = memcmp(a, b, n);
+ if (result != 0)
+ return;
+ if (n == 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+int memcmp7 (char *a, size_t x, size_t y, size_t n) {
+ // We used to crash when either of the arguments was unknown.
+ return memcmp(a, &a[x*y], n) +
+ memcmp(&a[x*y], a, n);
+}
+
+//===----------------------------------------------------------------------===
+// bcopy()
+//===----------------------------------------------------------------------===
+
+#define bcopy BUILTIN(bcopy)
+// __builtin_bcopy is not defined with const in Builtins.def.
+void bcopy(/*const*/ void *s1, void *s2, size_t n);
+
+
+void bcopy0 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[4] = {0};
+
+ bcopy(src, dst, 4); // no-warning
+
+ if (dst[0] != 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void bcopy1 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[10];
+
+ bcopy(src, dst, 5); // expected-warning{{out-of-bound}}
+}
+
+void bcopy2 () {
+ char src[] = {1, 2, 3, 4};
+ char dst[1];
+
+ bcopy(src, dst, 4); // expected-warning{{overflow}}
+}
diff --git a/clang/test/Analysis/casts.c b/clang/test/Analysis/casts.c
new file mode 100644
index 0000000..8b88a2d
--- /dev/null
+++ b/clang/test/Analysis/casts.c
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s
+
+// Test if the 'storage' region gets properly initialized after it is cast to
+// 'struct sockaddr *'.
+
+typedef unsigned char __uint8_t;
+typedef unsigned int __uint32_t;
+typedef __uint32_t __darwin_socklen_t;
+typedef __uint8_t sa_family_t;
+typedef __darwin_socklen_t socklen_t;
+struct sockaddr { sa_family_t sa_family; };
+struct sockaddr_storage {};
+
+void getsockname();
+
+void f(int sock) {
+ struct sockaddr_storage storage;
+ struct sockaddr* sockaddr = (struct sockaddr*)&storage;
+ socklen_t addrlen = sizeof(storage);
+ getsockname(sock, sockaddr, &addrlen);
+ switch (sockaddr->sa_family) { // no-warning
+ default:
+ ;
+ }
+}
+
+struct s {
+ struct s *value;
+};
+
+void f1(struct s **pval) {
+ int *tbool = ((void*)0);
+ struct s *t = *pval;
+ pval = &(t->value);
+ tbool = (int *)pval; // use the cast-to type 'int *' to create element region.
+ char c = (unsigned char) *tbool; // Should use cast-to type to create symbol.
+ if (*tbool == -1) // here load the element region with the correct type 'int'
+ (void)3;
+}
+
+void f2(const char *str) {
+ unsigned char ch, cl, *p;
+
+ p = (unsigned char *)str;
+ ch = *p++; // use cast-to type 'unsigned char' to create element region.
+ cl = *p++;
+ if(!cl)
+ cl = 'a';
+}
+
+// Test cast VariableSizeArray to pointer does not crash.
+void *memcpy(void *, void const *, unsigned long);
+typedef unsigned char Byte;
+void doit(char *data, int len) {
+ if (len) {
+ Byte buf[len];
+ memcpy(buf, data, len);
+ }
+}
+
+// PR 6013 and 6035 - Test that a cast of a pointer to long and then to int does not crash SValuator.
+void pr6013_6035_test(void *p) {
+ unsigned int foo;
+ foo = ((long)(p));
+ (void) foo;
+}
diff --git a/clang/test/Analysis/casts.m b/clang/test/Analysis/casts.m
new file mode 100644
index 0000000..6f19211
--- /dev/null
+++ b/clang/test/Analysis/casts.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s
+
+// Test function pointer casts. Currently we track function addresses using
+// loc::FunctionVal. Because casts can be arbitrary, do we need to model
+// functions with regions?
+typedef void* (*MyFuncTest1)(void);
+
+MyFuncTest1 test1_aux(void);
+void test1(void) {
+ void *x;
+ void* (*p)(void);
+ p = ((void*) test1_aux());
+ if (p != ((void*) 0)) x = (*p)();
+}
+
+// Test casts from void* to function pointers. Same issue as above:
+// should we eventually model function pointers using regions?
+void* test2(void *p) {
+ MyFuncTest1 fp = (MyFuncTest1) p;
+ return (*fp)();
+}
+
+// <radar://10087620>
+// A cast from int onjective C property reference to int.
+typedef signed char BOOL;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@interface NSObject <NSObject> {} - (id)init; @end
+typedef enum {
+ EEOne,
+ EETwo
+} RDR10087620Enum;
+@interface RDR10087620 : NSObject {
+ RDR10087620Enum elem;
+}
+@property (readwrite, nonatomic) RDR10087620Enum elem;
+@end
+
+static void
+adium_media_ready_cb(RDR10087620 *InObj)
+{
+ InObj.elem |= EEOne;
+}
diff --git a/clang/test/Analysis/cfref_PR2519.c b/clang/test/Analysis/cfref_PR2519.c
new file mode 100644
index 0000000..5292109
--- /dev/null
+++ b/clang/test/Analysis/cfref_PR2519.c
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s
+
+typedef unsigned char Boolean;
+typedef signed long CFIndex;
+typedef const void * CFTypeRef;
+typedef const struct __CFString * CFStringRef;
+typedef const struct __CFAllocator * CFAllocatorRef;
+extern const CFAllocatorRef kCFAllocatorDefault;
+typedef struct {} CFAllocatorContext;
+extern void CFRelease(CFTypeRef cf);
+typedef struct {}
+CFDictionaryKeyCallBacks;
+extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks;
+typedef struct {}
+CFDictionaryValueCallBacks;
+extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
+typedef const struct __CFDictionary * CFDictionaryRef;
+extern CFDictionaryRef CFDictionaryCreate(CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
+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 struct __CFNotificationCenter * CFNotificationCenterRef;
+extern CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void);
+extern void CFNotificationCenterPostNotification(CFNotificationCenterRef center, CFStringRef name, const void *object, CFDictionaryRef userInfo, Boolean deliverImmediately);
+
+// This test case was reported in PR2519 as a false positive (_value was
+// reported as being leaked).
+
+int main(int argc, char **argv) {
+ CFStringRef _key = ((CFStringRef) __builtin___CFStringMakeConstantString ("" "Process identifier" ""));
+ int pid = 42;
+
+ CFNumberRef _value = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &pid);
+ CFDictionaryRef userInfo = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&_key, (const void **)&_value, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFRelease(_value); // no-warning
+ CFNotificationCenterPostNotification(CFNotificationCenterGetDistributedCenter(),
+ ((CFStringRef) __builtin___CFStringMakeConstantString ("" "GrowlPreferencesChanged" "")),
+ ((CFStringRef) __builtin___CFStringMakeConstantString ("" "GrowlUserDefaults" "")),
+ userInfo, 0);
+ CFRelease(userInfo); // no-warning
+
+ return 0;
+}
+
diff --git a/clang/test/Analysis/cfref_rdar6080742.c b/clang/test/Analysis/cfref_rdar6080742.c
new file mode 100644
index 0000000..ea4c3ee
--- /dev/null
+++ b/clang/test/Analysis/cfref_rdar6080742.c
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s
+
+// This test case was reported in <rdar:problem/6080742>.
+// It tests path-sensitivity with respect to '!(cfstring != 0)' (negation of inequality).
+
+int printf(const char *restrict,...);
+typedef unsigned long UInt32;
+typedef signed long SInt32;
+typedef SInt32 OSStatus;
+typedef unsigned char Boolean;
+enum { noErr = 0};
+typedef const void *CFTypeRef;
+typedef const struct __CFString *CFStringRef;
+typedef const struct __CFAllocator *CFAllocatorRef;
+extern void CFRelease(CFTypeRef cf);
+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);
+
+enum { memROZWarn = -99, memROZError = -99, memROZErr = -99, memFullErr = -108,
+ nilHandleErr = -109, memWZErr = -111, memPurErr = -112, memAdrErr = -110,
+ memAZErr = -113, memPCErr = -114, memBCErr = -115, memSCErr = -116, memLockedErr = -117};
+
+#define DEBUG1
+
+void DebugStop(const char *format,...);
+void DebugTraceIf(unsigned int condition, const char *format,...);
+Boolean DebugDisplayOSStatusMsg(OSStatus status, const char *statusStr, const char *fileName, unsigned long lineNumber);
+
+#define Assert(condition)if (!(condition)) { DebugStop("Assertion failure: %s [File: %s, Line: %lu]", #condition, __FILE__, __LINE__); }
+#define AssertMsg(condition, message)if (!(condition)) { DebugStop("Assertion failure: %s (%s) [File: %s, Line: %lu]", #condition, message, __FILE__, __LINE__); }
+#define Require(condition)if (!(condition)) { DebugStop("Assertion failure: %s [File: %s, Line: %lu]", #condition, __FILE__, __LINE__); }
+#define RequireAction(condition, action)if (!(condition)) { DebugStop("Assertion failure: %s [File: %s, Line: %lu]", #condition, __FILE__, __LINE__); action }
+#define RequireActionSilent(condition, action)if (!(condition)) { action }
+#define AssertNoErr(err){ DebugDisplayOSStatusMsg((err), #err, __FILE__, __LINE__); }
+#define RequireNoErr(err, action){ if( DebugDisplayOSStatusMsg((err), #err, __FILE__, __LINE__) ) { action }}
+
+void DebugStop(const char *format,...); /* Not an abort function. */
+
+int main(int argc, char *argv[]) {
+ CFStringRef cfString;
+ OSStatus status = noErr;
+ cfString = CFStringCreateWithCString(0, "hello", kCFStringEncodingUTF8);
+ RequireAction(cfString != 0, return memFullErr;) //no - warning
+ printf("cfstring %p\n", cfString);
+ Exit:
+ CFRelease(cfString);
+ return 0;
+}
diff --git a/clang/test/Analysis/check-deserialization.cpp b/clang/test/Analysis/check-deserialization.cpp
new file mode 100644
index 0000000..2b0bce2
--- /dev/null
+++ b/clang/test/Analysis/check-deserialization.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -error-on-deserialized-decl S1_method -include-pch %t -analyze -analyzer-checker=core %s
+// RUN: %clang_cc1 -include-pch %t -analyze -analyzer-checker=core -verify %s
+
+#ifndef HEADER
+#define HEADER
+// Header.
+
+void S1_method(); // This should not be deserialized.
+
+
+#else
+// Using the header.
+
+int test() {
+ int x = 0;
+ return 5/x; //expected-warning {{Division by zero}}
+}
+
+#endif
diff --git a/clang/test/Analysis/chroot.c b/clang/test/Analysis/chroot.c
new file mode 100644
index 0000000..1948f48
--- /dev/null
+++ b/clang/test/Analysis/chroot.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.unix.Chroot -analyzer-store region -verify %s
+
+extern int chroot(const char* path);
+extern int chdir(const char* path);
+
+void foo(void) {
+}
+
+void f1(void) {
+ chroot("/usr/local"); // root changed.
+ foo(); // expected-warning {{No call of chdir("/") immediately after chroot}}
+}
+
+void f2(void) {
+ chroot("/usr/local"); // root changed.
+ chdir("/"); // enter the jail.
+ foo(); // no-warning
+}
+
+void f3(void) {
+ chroot("/usr/local"); // root changed.
+ chdir("../"); // change working directory, still out of jail.
+ foo(); // expected-warning {{No call of chdir("/") immediately after chroot}}
+}
diff --git a/clang/test/Analysis/complex.c b/clang/test/Analysis/complex.c
new file mode 100644
index 0000000..c118a61
--- /dev/null
+++ b/clang/test/Analysis/complex.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-constraints=basic -verify -Wno-unreachable-code -ffreestanding %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-constraints=range -verify -Wno-unreachable-code -ffreestanding %s
+
+#include <stdint.h>
+
+void f1(int * p) {
+
+ // This branch should be infeasible
+ // because __imag__ p is 0.
+ if (!p && __imag__ (intptr_t) p)
+ *p = 1; // no-warning
+
+ // If p != 0 then this branch is feasible; otherwise it is not.
+ if (__real__ (intptr_t) p)
+ *p = 1; // no-warning
+
+ *p = 2; // expected-warning{{Dereference of null pointer}}
+}
diff --git a/clang/test/Analysis/concrete-address.c b/clang/test/Analysis/concrete-address.c
new file mode 100644
index 0000000..f6c445e
--- /dev/null
+++ b/clang/test/Analysis/concrete-address.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s
+
+void foo() {
+ int *p = (int*) 0x10000; // Should not crash here.
+ *p = 3;
+}
diff --git a/clang/test/Analysis/constant-folding.c b/clang/test/Analysis/constant-folding.c
new file mode 100644
index 0000000..e7a5705
--- /dev/null
+++ b/clang/test/Analysis/constant-folding.c
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode -Wno-null-dereference -verify %s
+
+// Trigger a warning if the analyzer reaches this point in the control flow.
+#define WARN ((void)*(char*)0)
+
+// There should be no warnings unless otherwise indicated.
+
+void testComparisons (int a) {
+ // Sema can already catch the simple comparison a==a,
+ // since that's usually a logic error (and not path-dependent).
+ int b = a;
+ if (!(b==a)) WARN; // expected-warning{{never executed}}
+ if (!(b>=a)) WARN; // expected-warning{{never executed}}
+ if (!(b<=a)) WARN; // expected-warning{{never executed}}
+ if (b!=a) WARN; // expected-warning{{never executed}}
+ if (b>a) WARN; // expected-warning{{never executed}}
+ if (b<a) WARN; // expected-warning{{never executed}}
+}
+
+void testSelfOperations (int a) {
+ if ((a|a) != a) WARN; // expected-warning{{never executed}}
+ if ((a&a) != a) WARN; // expected-warning{{never executed}}
+ if ((a^a) != 0) WARN; // expected-warning{{never executed}}
+ if ((a-a) != 0) WARN; // expected-warning{{never executed}}
+}
+
+void testIdempotent (int a) {
+ if ((a*1) != a) WARN; // expected-warning{{never executed}}
+ if ((a/1) != a) WARN; // expected-warning{{never executed}}
+ if ((a+0) != a) WARN; // expected-warning{{never executed}}
+ if ((a-0) != a) WARN; // expected-warning{{never executed}}
+ if ((a<<0) != a) WARN; // expected-warning{{never executed}}
+ if ((a>>0) != a) WARN; // expected-warning{{never executed}}
+ if ((a^0) != a) WARN; // expected-warning{{never executed}}
+ if ((a&(~0)) != a) WARN; // expected-warning{{never executed}}
+ if ((a|0) != a) WARN; // expected-warning{{never executed}}
+}
+
+void testReductionToConstant (int a) {
+ if ((a*0) != 0) WARN; // expected-warning{{never executed}}
+ if ((a&0) != 0) WARN; // expected-warning{{never executed}}
+ if ((a|(~0)) != (~0)) WARN; // expected-warning{{never executed}}
+}
+
+void testSymmetricIntSymOperations (int a) {
+ if ((2+a) != (a+2)) WARN; // expected-warning{{never executed}}
+ if ((2*a) != (a*2)) WARN; // expected-warning{{never executed}}
+ if ((2&a) != (a&2)) WARN; // expected-warning{{never executed}}
+ if ((2^a) != (a^2)) WARN; // expected-warning{{never executed}}
+ if ((2|a) != (a|2)) WARN; // expected-warning{{never executed}}
+}
+
+void testAsymmetricIntSymOperations (int a) {
+ if (((~0) >> a) != (~0)) WARN; // expected-warning{{never executed}}
+ if ((0 >> a) != 0) WARN; // expected-warning{{never executed}}
+ if ((0 << a) != 0) WARN; // expected-warning{{never executed}}
+
+ // Unsigned right shift shifts in zeroes.
+ if ((((unsigned)(~0)) >> ((unsigned) a)) != ((unsigned)(~0)))
+ WARN; // expected-warning{{}}
+}
+
+void testLocations (char *a) {
+ char *b = a;
+ if (!(b==a)) WARN; // expected-warning{{never executed}}
+ if (!(b>=a)) WARN; // expected-warning{{never executed}}
+ if (!(b<=a)) WARN; // expected-warning{{never executed}}
+ if (b!=a) WARN; // expected-warning{{never executed}}
+ if (b>a) WARN; // expected-warning{{never executed}}
+ if (b<a) WARN; // expected-warning{{never executed}}
+ if (b-a) WARN; // expected-warning{{never executed}}
+}
diff --git a/clang/test/Analysis/coverage.c b/clang/test/Analysis/coverage.c
new file mode 100644
index 0000000..73d78da
--- /dev/null
+++ b/clang/test/Analysis/coverage.c
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -analyzer-max-loop 4 -verify %s
+#include "system-header-simulator.h"
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+
+static int another_function(int *y) {
+ if (*y > 0)
+ return *y;
+ return 0;
+}
+
+static void function_which_doesnt_give_up(int **x) {
+ *x = 0;
+}
+
+static void function_which_gives_up(int *x) {
+ for (int i = 0; i < 5; ++i)
+ (*x)++;
+}
+
+static void function_which_gives_up_nested(int *x) {
+ function_which_gives_up(x);
+ for (int i = 0; i < 5; ++i)
+ (*x)++;
+}
+
+static void function_which_doesnt_give_up_nested(int *x, int *y) {
+ *y = another_function(x);
+ function_which_gives_up(x);
+}
+
+void coverage1(int *x) {
+ function_which_gives_up(x);
+ char *m = (char*)malloc(12); // expected-warning {{potential leak}}
+}
+
+void coverage2(int *x) {
+ if (x) {
+ function_which_gives_up(x);
+ char *m = (char*)malloc(12);// expected-warning {{potential leak}}
+ }
+}
+
+void coverage3(int *x) {
+ x++;
+ function_which_gives_up(x);
+ char *m = (char*)malloc(12);// expected-warning {{potential leak}}
+}
+
+void coverage4(int *x) {
+ *x += another_function(x);
+ function_which_gives_up(x);
+ char *m = (char*)malloc(12);// expected-warning {{potential leak}}
+}
+
+void coverage5(int *x) {
+ for (int i = 0; i<7; ++i)
+ function_which_gives_up(x);
+ // The root function gives up here.
+ char *m = (char*)malloc(12); // no-warning
+}
+
+void coverage6(int *x) {
+ for (int i = 0; i<3; ++i) {
+ function_which_gives_up(x);
+ }
+ char *m = (char*)malloc(12); // expected-warning {{potential leak}}
+}
+
+int coverage7_inline(int *i) {
+ function_which_doesnt_give_up(&i);
+ return *i; // expected-warning {{Dereference}}
+}
+
+void coverage8(int *x) {
+ int y;
+ function_which_doesnt_give_up_nested(x, &y);
+ y = (*x)/y; // expected-warning {{Division by zero}}
+ char *m = (char*)malloc(12); // expected-warning {{potential leak}}
+}
+
+void function_which_gives_up_settonull(int **x) {
+ *x = 0;
+ int y = 0;
+ for (int i = 0; i < 5; ++i)
+ y++;
+}
+
+void coverage9(int *x) {
+ int y = 5;
+ function_which_gives_up_settonull(&x);
+ y = (*x); // no warning
+}
diff --git a/clang/test/Analysis/cstring-syntax-cxx.cpp b/clang/test/Analysis/cstring-syntax-cxx.cpp
new file mode 100644
index 0000000..f8975ab
--- /dev/null
+++ b/clang/test/Analysis/cstring-syntax-cxx.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -verify %s
+
+// Ensure we don't crash on C++ declarations with special names.
+struct X {
+ X(int i): i(i) {}
+ int i;
+};
+
+X operator+(X a, X b) {
+ return X(a.i + b.i);
+}
+
+void test(X a, X b) {
+ X c = a + b;
+}
+
diff --git a/clang/test/Analysis/cstring-syntax.c b/clang/test/Analysis/cstring-syntax.c
new file mode 100644
index 0000000..64ecb67
--- /dev/null
+++ b/clang/test/Analysis/cstring-syntax.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -Wno-strlcpy-strlcat-size -Wno-sizeof-array-argument -Wno-sizeof-pointer-memaccess -verify %s
+
+typedef __SIZE_TYPE__ size_t;
+char *strncat(char *, const char *, size_t);
+size_t strlen (const char *s);
+
+void testStrncat(const char *src) {
+ char dest[10];
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - 1); // expected-warning {{Potential buffer overflow. Replace with 'sizeof(dest) - strlen(dest) - 1' or use a safer 'strlcat' API}}
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest)); // expected-warning {{Potential buffer overflow. Replace with}}
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - strlen(dest)); // expected-warning {{Potential buffer overflow. Replace with}}
+ strncat(dest, src, sizeof(src)); // expected-warning {{Potential buffer overflow. Replace with}}
+}
diff --git a/clang/test/Analysis/cxx-crashes.cpp b/clang/test/Analysis/cxx-crashes.cpp
new file mode 100644
index 0000000..17fc74d
--- /dev/null
+++ b/clang/test/Analysis/cxx-crashes.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
+
+int f1(char *dst) {
+ char *p = dst + 4;
+ char *q = dst + 3;
+ return !(q >= p);
+}
+
+long f2(char *c) {
+ return long(c) & 1;
+}
+
+bool f3() {
+ return !false;
+}
+
+void *f4(int* w) {
+ return reinterpret_cast<void*&>(w);
+}
+
+namespace {
+
+struct A { };
+struct B {
+ operator A() { return A(); }
+};
+
+A f(char *dst) {
+ B b;
+ return b;
+}
+
+}
+
+namespace {
+
+struct S {
+ void *p;
+};
+
+void *f(S* w) {
+ return &reinterpret_cast<void*&>(*w);
+}
+
+}
+
+namespace {
+
+struct C {
+ void *p;
+ static void f();
+};
+
+void C::f() { }
+
+}
diff --git a/clang/test/Analysis/dead-stores.c b/clang/test/Analysis/dead-stores.c
new file mode 100644
index 0000000..b8d195d
--- /dev/null
+++ b/clang/test/Analysis/dead-stores.c
@@ -0,0 +1,550 @@
+// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores,experimental.deadcode.IdempotentOperations -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores,experimental.deadcode.IdempotentOperations -analyzer-store=region -analyzer-constraints=basic -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores,experimental.deadcode.IdempotentOperations -analyzer-store=region -analyzer-constraints=range -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
+
+void f1() {
+ int k, y; // expected-warning{{unused variable 'k'}} expected-warning{{unused variable 'y'}}
+ int abc=1;
+ long idx=abc+3*5; // expected-warning {{never read}} expected-warning{{unused variable 'idx'}}
+}
+
+void f2(void *b) {
+ char *c = (char*)b; // no-warning
+ char *d = b+1; // expected-warning {{never read}} expected-warning{{unused variable 'd'}}
+ printf("%s", c); // expected-warning{{implicitly declaring library function 'printf' with type 'int (const char *, ...)'}} \
+ // expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
+}
+
+int f();
+
+void f3() {
+ int r;
+ if ((r = f()) != 0) { // no-warning
+ int y = r; // no-warning
+ printf("the error is: %d\n", y);
+ }
+}
+
+void f4(int k) {
+
+ k = 1;
+
+ if (k)
+ f1();
+
+ k = 2; // expected-warning {{never read}}
+}
+
+void f5() {
+
+ int x = 4; // no-warning
+ int *p = &x; // expected-warning{{never read}} expected-warning{{unused variable 'p'}}
+
+}
+
+//
+int f6() {
+
+ int x = 4;
+ ++x; // no-warning
+ return 1;
+}
+
+int f7(int *p) {
+ // This is allowed for defensive programming.
+ p = 0; // no-warning
+ return 1;
+}
+
+int f7b(int *p) {
+ // This is allowed for defensive programming.
+ p = (0); // no-warning
+ return 1;
+}
+
+int f7c(int *p) {
+ // This is allowed for defensive programming.
+ p = (void*) 0; // no-warning
+ return 1;
+}
+
+int f7d(int *p) {
+ // This is allowed for defensive programming.
+ p = (void*) (0); // no-warning
+ return 1;
+}
+
+// Don't warn for dead stores in nested expressions. We have yet
+// to see a real bug in this scenario.
+int f8(int *p) {
+ extern int *baz();
+ if ((p = baz())) // no-warning
+ return 1;
+ return 0;
+}
+
+int f9() {
+ int x = 4;
+ x = x + 10; // expected-warning{{never read}}
+ return 1;
+}
+
+int f10() {
+ int x = 4;
+ x = 10 + x; // expected-warning{{never read}}
+ return 1;
+}
+
+int f11() {
+ int x = 4;
+ return x++; // expected-warning{{never read}}
+}
+
+int f11b() {
+ int x = 4;
+ return ((((++x)))); // no-warning
+}
+
+int f12a(int y) {
+ int x = y; // expected-warning{{unused variable 'x'}}
+ return 1;
+}
+int f12b(int y) {
+ int x __attribute__((unused)) = y; // no-warning
+ return 1;
+}
+int f12c(int y) {
+ // Allow initialiation of scalar variables by parameters as a form of
+ // defensive programming.
+ int x = y; // no-warning
+ x = 1;
+ return x;
+}
+
+// Filed with PR 2630. This code should produce no warnings.
+int f13(void)
+{
+ int a = 1;
+ int b, c = b = a + a;
+
+ if (b > 0)
+ return (0);
+
+ return (a + b + c);
+}
+
+// Filed with PR 2763.
+int f14(int count) {
+ int index, nextLineIndex;
+ for (index = 0; index < count; index = nextLineIndex+1) {
+ nextLineIndex = index+1; // no-warning
+ continue;
+ }
+ return index;
+}
+
+// Test case for <rdar://problem/6248086>
+void f15(unsigned x, unsigned y) {
+ int count = x * y; // no-warning
+ int z[count]; // expected-warning{{unused variable 'z'}}
+}
+
+// Don't warn for dead stores in nested expressions. We have yet
+// to see a real bug in this scenario.
+int f16(int x) {
+ x = x * 2;
+ x = sizeof(int [x = (x || x + 1) * 2]) // expected-warning{{The left operand to '+' is always 0}} expected-warning{{The left operand to '*' is always 1}}
+ ? 5 : 8;
+ return x;
+}
+
+// Self-assignments should not be flagged as dead stores.
+void f17() {
+ int x = 1;
+ x = x;
+}
+
+// <rdar://problem/6506065>
+// The values of dead stores are only "consumed" in an enclosing expression
+// what that value is actually used. In other words, don't say "Although the
+// value stored to 'x' is used...".
+int f18() {
+ int x = 0; // no-warning
+ if (1)
+ x = 10; // expected-warning{{Value stored to 'x' is never read}}
+ while (1)
+ x = 10; // expected-warning{{Value stored to 'x' is never read}}
+ // unreachable.
+ do
+ x = 10; // no-warning
+ while (1);
+ return (x = 10); // no-warning
+}
+
+int f18_a() {
+ int x = 0; // no-warning
+ return (x = 10); // no-warning
+}
+
+void f18_b() {
+ int x = 0; // no-warning
+ if (1)
+ x = 10; // expected-warning{{Value stored to 'x' is never read}}
+}
+
+void f18_c() {
+ int x = 0;
+ while (1)
+ x = 10; // expected-warning{{Value stored to 'x' is never read}}
+}
+
+void f18_d() {
+ int x = 0; // no-warning
+ do
+ x = 10; // expected-warning{{Value stored to 'x' is never read}}
+ while (1);
+}
+
+// PR 3514: false positive `dead initialization` warning for init to global
+// http://llvm.org/bugs/show_bug.cgi?id=3514
+extern const int MyConstant;
+int f19(void) {
+ int x = MyConstant; // no-warning
+ x = 1;
+ return x;
+}
+
+int f19b(void) { // This case is the same as f19.
+ const int MyConstant = 0;
+ int x = MyConstant; // no-warning
+ x = 1;
+ return x;
+}
+
+void f20(void) {
+ int x = 1; // no-warning
+#pragma unused(x)
+}
+
+void halt() __attribute__((noreturn));
+int f21() {
+ int x = 4;
+
+ x = x + 1; // expected-warning{{never read}}
+ if (1) {
+ halt();
+ (void)x;
+ }
+ return 1;
+}
+
+int j;
+void f22() {
+ int x = 4;
+ int y1 = 4;
+ int y2 = 4;
+ int y3 = 4;
+ int y4 = 4;
+ int y5 = 4;
+ int y6 = 4;
+ int y7 = 4;
+ int y8 = 4;
+ int y9 = 4;
+ int y10 = 4;
+ int y11 = 4;
+ int y12 = 4;
+ int y13 = 4;
+ int y14 = 4;
+ int y15 = 4;
+ int y16 = 4;
+ int y17 = 4;
+ int y18 = 4;
+ int y19 = 4;
+ int y20 = 4;
+
+ x = x + 1; // expected-warning{{never read}}
+ ++y1;
+ ++y2;
+ ++y3;
+ ++y4;
+ ++y5;
+ ++y6;
+ ++y7;
+ ++y8;
+ ++y9;
+ ++y10;
+ ++y11;
+ ++y12;
+ ++y13;
+ ++y14;
+ ++y15;
+ ++y16;
+ ++y17;
+ ++y18;
+ ++y19;
+ ++y20;
+
+ switch (j) {
+ case 1:
+ if (0)
+ (void)x;
+ if (1) {
+ (void)y1;
+ return;
+ }
+ (void)x;
+ break;
+ case 2:
+ if (0)
+ (void)x;
+ else {
+ (void)y2;
+ return;
+ }
+ (void)x;
+ break;
+ case 3:
+ if (1) {
+ (void)y3;
+ return;
+ } else
+ (void)x;
+ (void)x;
+ break;
+ case 4:
+ 0 ? : ((void)y4, ({ return; }));
+ (void)x;
+ break;
+ case 5:
+ 1 ? : (void)x;
+ 0 ? (void)x : ((void)y5, ({ return; }));
+ (void)x;
+ break;
+ case 6:
+ 1 ? ((void)y6, ({ return; })) : (void)x;
+ (void)x;
+ break;
+ case 7:
+ (void)(0 && x);
+ (void)y7;
+ (void)(0 || (y8, ({ return; }), 1)); // expected-warning {{expression result unused}}
+ (void)x;
+ break;
+ case 8:
+ (void)(1 && (y9, ({ return; }), 1)); // expected-warning {{expression result unused}}
+ (void)x;
+ break;
+ case 9:
+ (void)(1 || x);
+ (void)y10;
+ break;
+ case 10:
+ while (0) {
+ (void)x;
+ }
+ (void)y11;
+ break;
+ case 11:
+ while (1) {
+ (void)y12;
+ }
+ (void)x;
+ break;
+ case 12:
+ do {
+ (void)y13;
+ } while (0);
+ (void)y14;
+ break;
+ case 13:
+ do {
+ (void)y15;
+ } while (1);
+ (void)x;
+ break;
+ case 14:
+ for (;;) {
+ (void)y16;
+ }
+ (void)x;
+ break;
+ case 15:
+ for (;1;) {
+ (void)y17;
+ }
+ (void)x;
+ break;
+ case 16:
+ for (;0;) {
+ (void)x;
+ }
+ (void)y18;
+ break;
+ case 17:
+ __builtin_choose_expr(0, (void)x, ((void)y19, ({ return; })));
+ (void)x;
+ break;
+ case 19:
+ __builtin_choose_expr(1, ((void)y20, ({ return; })), (void)x);
+ (void)x;
+ break;
+ }
+}
+
+void f23_aux(const char* s);
+void f23(int argc, char **argv) {
+ int shouldLog = (argc > 1); // no-warning
+ ^{
+ if (shouldLog) f23_aux("I did too use it!\n");
+ else f23_aux("I shouldn't log. Wait.. d'oh!\n");
+ }();
+}
+
+void f23_pos(int argc, char **argv) {
+ int shouldLog = (argc > 1); // expected-warning{{Value stored to 'shouldLog' during its initialization is never read}} expected-warning{{unused variable 'shouldLog'}}
+ ^{
+ f23_aux("I did too use it!\n");
+ }();
+}
+
+void f24_A(int y) {
+ // FIXME: One day this should be reported as dead since 'z = x + y' is dead.
+ int x = (y > 2); // no-warning
+ ^ {
+ int z = x + y; // expected-warning{{Value stored to 'z' during its initialization is never read}} expected-warning{{unused variable 'z'}}
+ }();
+}
+
+void f24_B(int y) {
+ // FIXME: One day this should be reported as dead since 'x' is just overwritten.
+ __block int x = (y > 2); // no-warning
+ ^{
+ // FIXME: This should eventually be a dead store since it is never read either.
+ x = 5; // no-warning
+ }();
+}
+
+int f24_C(int y) {
+ // FIXME: One day this should be reported as dead since 'x' is just overwritten.
+ __block int x = (y > 2); // no-warning
+ ^{
+ x = 5; // no-warning
+ }();
+ return x;
+}
+
+int f24_D(int y) {
+ __block int x = (y > 2); // no-warning
+ ^{
+ if (y > 4)
+ x = 5; // no-warning
+ }();
+ return x;
+}
+
+// This example shows that writing to a variable captured by a block means that it might
+// not be dead.
+int f25(int y) {
+ __block int x = (y > 2);
+ __block int z = 0;
+ void (^foo)() = ^{ z = x + y; };
+ x = 4; // no-warning
+ foo();
+ return z;
+}
+
+// This test is mostly the same as 'f25', but shows that the heuristic of pruning out dead
+// stores for variables that are just marked '__block' is overly conservative.
+int f25_b(int y) {
+ // FIXME: we should eventually report a dead store here.
+ __block int x = (y > 2);
+ __block int z = 0;
+ x = 4; // no-warning
+ return z;
+}
+
+int f26_nestedblocks() {
+ int z;
+ z = 1;
+ __block int y = 0;
+ ^{
+ int k;
+ k = 1; // expected-warning{{Value stored to 'k' is never read}}
+ ^{
+ y = z + 1;
+ }();
+ }();
+ return y;
+}
+
+// The FOREACH macro in QT uses 'break' statements within statement expressions
+// placed within the increment code of for loops.
+void rdar8014335() {
+ for (int i = 0 ; i != 10 ; ({ break; })) {
+ for ( ; ; ({ ++i; break; })) ;
+ // Note that the next value stored to 'i' is never executed
+ // because the next statement to be executed is the 'break'
+ // in the increment code of the first loop.
+ i = i * 3; // expected-warning{{Value stored to 'i' is never read}} expected-warning{{The left operand to '*' is always 1}}
+ }
+}
+
+// <rdar://problem/8320674> NullStmts followed by do...while() can lead to disconnected CFG
+//
+// This previously caused bogus dead-stores warnings because the body of the first do...while was
+// disconnected from the entry of the function.
+typedef struct { float r; float i; } s_rdar8320674;
+typedef struct { s_rdar8320674 x[1]; } s2_rdar8320674;
+
+void rdar8320674(s_rdar8320674 *z, unsigned y, s2_rdar8320674 *st, int m)
+{
+ s_rdar8320674 * z2;
+ s_rdar8320674 * tw1 = st->x;
+ s_rdar8320674 t;
+ z2 = z + m;
+ do{
+ ; ;
+ do{ (t).r = (*z2).r*(*tw1).r - (*z2).i*(*tw1).i; (t).i = (*z2).r*(*tw1).i + (*z2).i*(*tw1).r; }while(0);
+ tw1 += y;
+ do { (*z2).r=(*z).r-(t).r; (*z2).i=(*z).i-(t).i; }while(0);
+ do { (*z).r += (t).r; (*z).i += (t).i; }while(0);
+ ++z2;
+ ++z;
+ }while (--m);
+}
+
+// Avoid dead stores resulting from an assignment (and use) being unreachable.
+void rdar8405222_aux(int i);
+void rdar8405222() {
+ const int show = 0;
+ int i = 0;
+
+ if (show)
+ i = 5; // no-warning
+
+ if (show)
+ rdar8405222_aux(i);
+}
+
+// Look through chains of assignements, e.g.: int x = y = 0, when employing
+// silencing heuristics.
+int radar11185138_foo() {
+ int x, y;
+ x = y = 0; // expected-warning {{never read}}
+ return y;
+}
+
+int rdar11185138_bar() {
+ int y;
+ int x = y = 0; // no-warning
+ x = 2;
+ y = 2;
+ return x + y;
+}
+
+int *radar11185138_baz() {
+ int *x, *y;
+ x = y = 0; // no-warning
+ return y;
+}
+
diff --git a/clang/test/Analysis/dead-stores.cpp b/clang/test/Analysis/dead-stores.cpp
new file mode 100644
index 0000000..43d8796
--- /dev/null
+++ b/clang/test/Analysis/dead-stores.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-store=region -analyzer-constraints=basic -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-store=region -analyzer-constraints=range -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s
+
+//===----------------------------------------------------------------------===//
+// Basic dead store checking (but in C++ mode).
+//===----------------------------------------------------------------------===//
+
+int j;
+void test1() {
+ int x = 4;
+
+ x = x + 1; // expected-warning{{never read}}
+
+ switch (j) {
+ case 1:
+ throw 1;
+ (void)x;
+ break;
+ }
+}
+
+//===----------------------------------------------------------------------===//
+// Dead store checking involving constructors.
+//===----------------------------------------------------------------------===//
+
+class Test2 {
+ int &x;
+public:
+ Test2(int &y) : x(y) {}
+ ~Test2() { ++x; }
+};
+
+int test2(int x) {
+ { Test2 a(x); } // no-warning
+ return x;
+}
+
+//===----------------------------------------------------------------------===//
+// Dead store checking involving CXXTemporaryExprs
+//===----------------------------------------------------------------------===//
+
+namespace TestTemp {
+ template<typename _Tp>
+ class pencil {
+ public:
+ ~pencil() throw() {}
+ };
+ template<typename _Tp, typename _Number2> struct _Row_base {
+ _Row_base(const pencil<_Tp>& x) {}
+ };
+ template<typename _Tp, typename _Number2 = TestTemp::pencil<_Tp> >
+ class row : protected _Row_base<_Tp, _Number2> {
+ typedef _Row_base<_Tp, _Number2> _Base;
+ typedef _Number2 pencil_type;
+ public:
+ explicit row(const pencil_type& __a = pencil_type()) : _Base(__a) {}
+ };
+}
+
+void test2_b() {
+ TestTemp::row<const char*> x; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// Test references.
+//===----------------------------------------------------------------------===//
+
+void test3_a(int x) {
+ x = x + 1; // expected-warning{{never read}}
+}
+
+void test3_b(int &x) {
+ x = x + 1; // no-warninge
+}
+
+void test3_c(int x) {
+ int &y = x;
+ // Shows the limitation of dead stores tracking. The write is really
+ // dead since the value cannot escape the function.
+ ++y; // no-warning
+}
+
+void test3_d(int &x) {
+ int &y = x;
+ ++y; // no-warning
+}
+
+void test3_e(int &x) {
+ int &y = x;
+}
+
+//===----------------------------------------------------------------------===//
+// Dead stores involving 'new'
+//===----------------------------------------------------------------------===//
+
+static void test_new(unsigned n) {
+ char **p = new char* [n]; // expected-warning{{never read}}
+}
+
+//===----------------------------------------------------------------------===//
+// Dead stores in namespaces.
+//===----------------------------------------------------------------------===//
+
+namespace foo {
+ int test_4(int x) {
+ x = 2; // expected-warning{{Value stored to 'x' is never read}}
+ x = 2;
+ return x;
+ }
+}
+
diff --git a/clang/test/Analysis/dead-stores.m b/clang/test/Analysis/dead-stores.m
new file mode 100644
index 0000000..0834274
--- /dev/null
+++ b/clang/test/Analysis/dead-stores.m
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=deadcode.DeadStores,osx.cocoa.RetainCount -fblocks -verify -Wno-objc-root-class %s
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@interface NSObject <NSObject> {} @end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value; @end
+typedef float CGFloat;
+typedef struct _NSPoint {} NSRange;
+@interface NSValue (NSValueRangeExtensions) + (NSValue *)valueWithRange:(NSRange)range;
+- (BOOL)containsObject:(id)anObject;
+@end
+@class NSURLAuthenticationChallenge;
+@interface NSResponder : NSObject <NSCoding> {} @end
+@class NSArray, NSDictionary, NSString;
+@interface NSObject (NSKeyValueBindingCreation)
++ (void)exposeBinding:(NSString *)binding;
+- (NSArray *)exposedBindings;
+@end
+extern NSString *NSAlignmentBinding;
+
+// This test case was reported as a false positive due to a bug in the
+// LiveVariables <-> deadcode.DeadStores interplay. We should not flag a warning
+// here. The test case was reported in:
+// http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-July/002157.html
+void DeadStoreTest(NSObject *anObject) {
+ NSArray *keys;
+ if ((keys = [anObject exposedBindings]) && // no-warning
+ ([keys containsObject:@"name"] && [keys containsObject:@"icon"])) {}
+}
+
+// This test case was a false positive due to how clang models
+// pointer types and ObjC object pointer types differently. Here
+// we don't warn about a dead store because 'nil' is assigned to
+// an object pointer for the sake of defensive programming.
+void rdar_7631278(NSObject *x) {
+ x = ((void*)0);
+}
+
+// This test case issuing a bogus warning for the declaration of 'isExec'
+// because the compound statement for the @synchronized was being visited
+// twice by the LiveVariables analysis.
+BOOL baz_rdar8527823();
+void foo_rdar8527823();
+@interface RDar8527823
+- (void) bar_rbar8527823;
+@end
+@implementation RDar8527823
+- (void) bar_rbar8527823
+{
+ @synchronized(self) {
+ BOOL isExec = baz_rdar8527823(); // no-warning
+ if (isExec) foo_rdar8527823();
+ }
+}
+@end
+
+// Don't flag dead stores to assignments to self within a nested assignment.
+@interface Rdar7947686
+- (id) init;
+@end
+
+@interface Rdar7947686_B : Rdar7947686
+- (id) init;
+@end
+
+@implementation Rdar7947686_B
+- (id) init {
+ id x = (self = [super init]); // no-warning
+ return x;
+}
+@end
+
+// Don't flag dead stores when a variable is captured in a block used
+// by a property access.
+@interface RDar10591355
+@property (assign) int x;
+@end
+
+RDar10591355 *rdar10591355_aux();
+
+void rdar10591355() {
+ RDar10591355 *p = rdar10591355_aux();
+ ^{ (void) p.x; }();
+}
diff --git a/clang/test/Analysis/debug-CallGraph.c b/clang/test/Analysis/debug-CallGraph.c
new file mode 100644
index 0000000..b7c7c8a
--- /dev/null
+++ b/clang/test/Analysis/debug-CallGraph.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCallGraph %s 2>&1 | FileCheck %s
+
+static void mmm(int y) {
+ if (y != 0)
+ y++;
+ y = y/0;
+}
+
+static int foo(int x, int y) {
+ mmm(y);
+ if (x != 0)
+ x++;
+ return 5/x;
+}
+
+void aaa() {
+ foo(1,2);
+}
+
+// CHECK:--- Call graph Dump ---
+// CHECK: Function: < root > calls: aaa
diff --git a/clang/test/Analysis/default-analyze.m b/clang/test/Analysis/default-analyze.m
new file mode 100644
index 0000000..82656b2
--- /dev/null
+++ b/clang/test/Analysis/default-analyze.m
@@ -0,0 +1,63 @@
+// RUN: %clang --analyze %s -o %t
+
+// Tests that some specific checkers are enabled by default.
+
+id foo(int x) {
+ id title;
+ switch (x) {
+ case 1:
+ title = @"foo"; // expected-warning {{never read}}
+ case 2:
+ title = @"bar";
+ break;
+ default:
+ title = "@baz";
+ break;
+ }
+ return title;
+}
+
+// <rdar://problem/8808566> Static analyzer is wrong: NSWidth(imgRect) not understood as unconditional assignment
+//
+// Note: this requires inlining support. This previously issued a false positive use of
+// uninitialized value when calling NSWidth.
+typedef double CGFloat;
+
+struct CGPoint {
+ CGFloat x;
+ CGFloat y;
+};
+typedef struct CGPoint CGPoint;
+
+struct CGSize {
+ CGFloat width;
+ CGFloat height;
+};
+typedef struct CGSize CGSize;
+
+struct CGRect {
+ CGPoint origin;
+ CGSize size;
+};
+typedef struct CGRect CGRect;
+
+typedef CGRect NSRect;
+typedef CGSize NSSize;
+
+static __inline__ __attribute__((always_inline)) CGFloat NSWidth(NSRect aRect) {
+ return (aRect.size.width);
+}
+
+static __inline__ __attribute__((always_inline)) CGFloat NSHeight(NSRect aRect) {
+ return (aRect.size.height);
+}
+
+NSSize rdar880566_size();
+
+double rdar8808566() {
+ NSRect myRect;
+ myRect.size = rdar880566_size();
+ double x = NSWidth(myRect) + NSHeight(myRect); // no-warning
+ return x;
+}
+
diff --git a/clang/test/Analysis/default-diagnostic-visitors.c b/clang/test/Analysis/default-diagnostic-visitors.c
new file mode 100644
index 0000000..9cb9ba8
--- /dev/null
+++ b/clang/test/Analysis/default-diagnostic-visitors.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-output=text -verify %s
+
+// This file is for testing enhanced diagnostics produced by the default BugReporterVisitors.
+
+int getPasswordAndItem()
+{
+ int err = 0;
+ int *password; // expected-note {{Variable 'password' declared without an initial value}}
+ if (password == 0) { // expected-warning {{The left operand of '==' is a garbage value}} // expected-note {{The left operand of '==' is a garbage value}}
+ err = *password;
+ }
+ return err;
+}
diff --git a/clang/test/Analysis/delegates.m b/clang/test/Analysis/delegates.m
new file mode 100644
index 0000000..8f42b83
--- /dev/null
+++ b/clang/test/Analysis/delegates.m
@@ -0,0 +1,113 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
+
+
+//===----------------------------------------------------------------------===//
+// The following code is reduced using delta-debugging from
+// Foundation.h (Mac OS X).
+//
+// It includes the basic definitions for the test cases below.
+// Not directly including Foundation.h directly makes this test case
+// both svelte and portable to non-Mac platforms.
+//===----------------------------------------------------------------------===//
+
+typedef const void * CFTypeRef;
+typedef const struct __CFString * CFStringRef;
+typedef const struct __CFAllocator * CFAllocatorRef;
+extern const CFAllocatorRef kCFAllocatorDefault;
+extern CFTypeRef CFRetain(CFTypeRef cf);
+void CFRelease(CFTypeRef cf);
+typedef const struct __CFDictionary * CFDictionaryRef;
+const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key);
+extern CFStringRef CFStringCreateWithFormat(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, ...);
+typedef signed char BOOL;
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+typedef struct objc_selector *SEL;
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+typedef NSInteger NSComparisonResult;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (oneway void)release;
+- (Class)class;
+- (id)retain;
+@end
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+@protocol NSMutableCopying
+- (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+@protocol NSCoding
+- (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
+- (id)init;
++ (id)alloc;
++ (Class)class;
+- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait;
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+typedef struct {} NSFastEnumerationState;
+@protocol NSFastEnumeration
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+@class NSString;
+typedef struct _NSRange {} NSRange;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+- (NSUInteger)count;
+@end
+@interface NSMutableArray : NSArray
+- (void)addObject:(id)anObject;
+- (id)initWithCapacity:(NSUInteger)numItems;
+@end
+typedef unsigned short unichar;
+@class NSData, NSArray, NSDictionary, NSCharacterSet, NSData, NSURL, NSError, NSLocale;
+typedef NSUInteger NSStringCompareOptions;
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length;
+- (NSComparisonResult)compare:(NSString *)string;
+- (NSComparisonResult)compare:(NSString *)string options:(NSStringCompareOptions)mask;
+- (NSComparisonResult)compare:(NSString *)string options:(NSStringCompareOptions)mask range:(NSRange)compareRange;
+- (NSComparisonResult)compare:(NSString *)string options:(NSStringCompareOptions)mask range:(NSRange)compareRange locale:(id)locale;
+- (NSComparisonResult)caseInsensitiveCompare:(NSString *)string;
+- (NSArray *)componentsSeparatedByCharactersInSet:(NSCharacterSet *)separator;
+@end
+@interface NSSimpleCString : NSString {} @end
+@interface NSConstantString : NSSimpleCString @end
+extern void *_NSConstantStringClassReference;
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+// <rdar://problem/6062730>
+// The analyzer doesn't perform any inter-procedural analysis, so delegates
+// involving [NSObject performSelector...] tend to lead to false positives.
+// For now the analyzer just stops tracking the reference count of the
+// receiver until we have better support for delegates.
+
+@interface test_6062730 : NSObject
++ (void)postNotification:(NSString *)str;
+- (void)foo;
+- (void)bar;
+@end
+
+@implementation test_6062730
+- (void) foo {
+ NSString *str = [[NSString alloc] init];
+ [test_6062730 performSelectorOnMainThread:@selector(postNotification:) withObject:str waitUntilDone:1];
+}
+
+- (void) bar {
+ NSString *str = [[NSString alloc] init]; // expected-warning{{leak}}
+ // FIXME: We need to resolve [self class] to 'test_6062730'.
+ [[self class] performSelectorOnMainThread:@selector(postNotification:) withObject:str waitUntilDone:1];
+}
+
++ (void) postNotification:(NSString *)str {
+ [str release]; // no-warning
+}
+@end
+
diff --git a/clang/test/Analysis/derived-to-base.cpp b/clang/test/Analysis/derived-to-base.cpp
new file mode 100644
index 0000000..f65b9db
--- /dev/null
+++ b/clang/test/Analysis/derived-to-base.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region %s
+
+class A {
+protected:
+ int x;
+};
+
+class B : public A {
+public:
+ void f();
+};
+
+void B::f() {
+ x = 3;
+}
diff --git a/clang/test/Analysis/div-zero.cpp b/clang/test/Analysis/div-zero.cpp
new file mode 100644
index 0000000..d1261dc
--- /dev/null
+++ b/clang/test/Analysis/div-zero.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core.DivideZero -verify %s
+
+int fooPR10616 (int qX ) {
+ int a, c, d;
+
+ d = (qX-1);
+ while ( d != 0 ) {
+ d = c - (c/d) * d;
+ }
+
+ return (a % (qX-1)); // expected-warning {{Division by zero}}
+
+}
diff --git a/clang/test/Analysis/domtest.c b/clang/test/Analysis/domtest.c
new file mode 100644
index 0000000..245186a
--- /dev/null
+++ b/clang/test/Analysis/domtest.c
@@ -0,0 +1,165 @@
+// RUN: %clang -cc1 -analyze -analyzer-checker=debug.DumpDominators %s 2>&1 | FileCheck %s
+
+// Test the DominatorsTree implementation with various control flows
+int test1()
+{
+ int x = 6;
+ int y = x/2;
+ int z;
+
+ while(y > 0) {
+ if(y < x) {
+ x = x/y;
+ y = y-1;
+ }else{
+ z = x - y;
+ }
+ x = x - 1;
+ x = x - 1;
+ }
+ z = x+y;
+ z = 3;
+ return 0;
+}
+
+// CHECK: Immediate dominance tree (Node#,IDom#):
+// CHECK: (0,1)
+// CHECK: (1,2)
+// CHECK: (2,8)
+// CHECK: (3,4)
+// CHECK: (4,7)
+// CHECK: (5,7)
+// CHECK: (6,7)
+// CHECK: (7,2)
+// CHECK: (8,9)
+// CHECK: (9,9)
+
+int test2()
+{
+ int x,y,z;
+
+ x = 10; y = 100;
+ if(x > 0){
+ y = 1;
+ }else{
+ while(x<=0){
+ x++;
+ y++;
+ }
+ }
+ z = y;
+
+ return 0;
+}
+
+// CHECK: Immediate dominance tree (Node#,IDom#):
+// CHECK: (0,1)
+// CHECK: (1,6)
+// CHECK: (2,6)
+// CHECK: (3,4)
+// CHECK: (4,2)
+// CHECK: (5,6)
+// CHECK: (6,7)
+// CHECK: (7,7)
+
+int test3()
+{
+ int x,y,z;
+
+ x = y = z = 1;
+ if(x>0) {
+ while(x>=0){
+ while(y>=x) {
+ x = x-1;
+ y = y/2;
+ }
+ }
+ }
+ z = y;
+
+ return 0;
+}
+
+// CHECK: Immediate dominance tree (Node#,IDom#):
+// CHECK: (0,1)
+// CHECK: (1,7)
+// CHECK: (2,7)
+// CHECK: (3,4)
+// CHECK: (4,2)
+// CHECK: (5,6)
+// CHECK: (6,4)
+// CHECK: (7,8)
+// CHECK: (8,8)
+
+int test4()
+{
+ int y = 3;
+ while(y > 0) {
+ if(y < 3) {
+ while(y>0)
+ y ++;
+ }else{
+ while(y<10)
+ y ++;
+ }
+ }
+ return 0;
+}
+
+// CHECK: Immediate dominance tree (Node#,IDom#):
+// CHECK: (0,1)
+// CHECK: (1,2)
+// CHECK: (2,11)
+// CHECK: (3,10)
+// CHECK: (4,10)
+// CHECK: (5,6)
+// CHECK: (6,4)
+// CHECK: (7,10)
+// CHECK: (8,9)
+// CHECK: (9,7)
+// CHECK: (10,2)
+// CHECK: (11,12)
+// CHECK: (12,12)
+
+int test5()
+{
+ int x,y,z,a,b,c;
+ x = 1;
+ y = 2;
+ z = 3;
+ a = 4;
+ b = 5;
+ c = 6;
+ if ( x < 10 ) {
+ if ( y < 10 ) {
+ if ( z < 10 ) {
+ x = 4;
+ } else {
+ x = 5;
+ }
+ a = 10;
+ } else {
+ x = 6;
+ }
+ b = 10;
+ } else {
+ x = 7;
+ }
+ c = 11;
+ return 0;
+}
+
+// CHECK: Immediate dominance tree (Node#,IDom#):
+// CHECK: (0,1)
+// CHECK: (1,10)
+// CHECK: (2,10)
+// CHECK: (3,9)
+// CHECK: (4,9)
+// CHECK: (5,8)
+// CHECK: (6,8)
+// CHECK: (7,8)
+// CHECK: (8,9)
+// CHECK: (9,10)
+// CHECK: (10,11)
+// CHECK: (11,11)
+
diff --git a/clang/test/Analysis/dtor.cpp b/clang/test/Analysis/dtor.cpp
new file mode 100644
index 0000000..8d63cc4
--- /dev/null
+++ b/clang/test/Analysis/dtor.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -analyzer-ipa=inlining -cfg-add-implicit-dtors -verify %s
+
+class A {
+public:
+ ~A() {
+ int *x = 0;
+ *x = 3; // expected-warning{{Dereference of null pointer}}
+ }
+};
+
+int main() {
+ A a;
+}
diff --git a/clang/test/Analysis/dtors-in-dtor-cfg-output.cpp b/clang/test/Analysis/dtors-in-dtor-cfg-output.cpp
new file mode 100644
index 0000000..68ba37e
--- /dev/null
+++ b/clang/test/Analysis/dtors-in-dtor-cfg-output.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors %s 2>&1 | FileCheck %s
+// XPASS: *
+
+class A {
+public:
+ ~A() {}
+};
+
+class B : public virtual A {
+public:
+ ~B() {}
+};
+
+class C : public virtual A {
+public:
+ ~C() {}
+};
+
+class TestOrder : public C, public B, public virtual A {
+ A a;
+ int i;
+ A *p;
+public:
+ ~TestOrder();
+};
+
+TestOrder::~TestOrder() {}
+
+class TestArray {
+ A a[2];
+ A b[0];
+public:
+ ~TestArray();
+};
+
+TestArray::~TestArray() {}
+
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: this->a.~A() (Member object destructor)
+// CHECK: 2: ~B() (Base object destructor)
+// CHECK: 3: ~C() (Base object destructor)
+// CHECK: 4: ~A() (Base object destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: this->a.~A() (Member object destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
diff --git a/clang/test/Analysis/dynamic-cast.cpp b/clang/test/Analysis/dynamic-cast.cpp
new file mode 100644
index 0000000..8e63b2b
--- /dev/null
+++ b/clang/test/Analysis/dynamic-cast.cpp
@@ -0,0 +1,230 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core -verify %s
+
+class A {
+public:
+ virtual void f(){};
+
+};
+class B : public A{
+public:
+ int m;
+};
+class C : public A{};
+
+class BB: public B{};
+
+// A lot of the tests below have the if statement in them, which forces the
+// analyzer to explore both path - when the result is 0 and not. This makes
+// sure that we definitely know that the result is non-0 (as the result of
+// the cast).
+int testDynCastFromRadar() {
+ B aa;
+ A *a = &aa;
+ const int* res = 0;
+ B *b = dynamic_cast<B*>(a);
+ static const int i = 5;
+ if(b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testBaseToBase1() {
+ B b;
+ B *pb = &b;
+ B *pbb = dynamic_cast<B*>(pb);
+ const int* res = 0;
+ static const int i = 5;
+ if (pbb) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testMultipleLevelsOfSubclassing1() {
+ BB bb;
+ B *pb = &bb;
+ A *pa = pb;
+ B *b = dynamic_cast<B*>(pa);
+ const int* res = 0;
+ static const int i = 5;
+ if (b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testMultipleLevelsOfSubclassing2() {
+ BB bb;
+ A *pbb = &bb;
+ B *b = dynamic_cast<B*>(pbb);
+ BB *s = dynamic_cast<BB*>(b);
+ const int* res = 0;
+ static const int i = 5;
+ if (s) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testMultipleLevelsOfSubclassing3() {
+ BB bb;
+ A *pbb = &bb;
+ B *b = dynamic_cast<B*>(pbb);
+ return b->m; // no warning
+}
+
+int testLHS() {
+ B aa;
+ A *a = &aa;
+ return (dynamic_cast<B*>(a))->m;
+}
+
+int testLHS2() {
+ B aa;
+ A *a = &aa;
+ return (*dynamic_cast<B*>(a)).m;
+}
+
+int testDynCastUnknown2(class A *a) {
+ B *b = dynamic_cast<B*>(a);
+ return b->m; // no warning
+}
+
+int testDynCastUnknown(class A *a) {
+ B *b = dynamic_cast<B*>(a);
+ const int* res = 0;
+ static const int i = 5;
+ if (b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // expected-warning {{Dereference of null pointer}}
+}
+
+int testDynCastFail2() {
+ C c;
+ A *pa = &c;
+ B *b = dynamic_cast<B*>(pa);
+ return b->m; // expected-warning {{dereference of a null pointer}}
+}
+
+int testLHSFail() {
+ C c;
+ A *a = &c;
+ return (*dynamic_cast<B*>(a)).m; // expected-warning {{Dereference of null pointer}}
+}
+
+int testBaseToDerivedFail() {
+ A a;
+ B *b = dynamic_cast<B*>(&a);
+ return b->m; // expected-warning {{dereference of a null pointer}}
+}
+
+int testConstZeroFail() {
+ B *b = dynamic_cast<B*>((A *)0);
+ return b->m; // expected-warning {{dereference of a null pointer}}
+}
+
+int testConstZeroFail2() {
+ A *a = 0;
+ B *b = dynamic_cast<B*>(a);
+ return b->m; // expected-warning {{dereference of a null pointer}}
+}
+
+int testUpcast() {
+ B b;
+ A *a = dynamic_cast<A*>(&b);
+ const int* res = 0;
+ static const int i = 5;
+ if (a) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testCastToVoidStar() {
+ A a;
+ void *b = dynamic_cast<void*>(&a);
+ const int* res = 0;
+ static const int i = 5;
+ if (b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testReferenceSuccesfulCast() {
+ B rb;
+ B &b = dynamic_cast<B&>(rb);
+ int *x = 0;
+ return *x; // expected-warning {{Dereference of null pointer}}
+}
+
+int testReferenceFailedCast() {
+ A a;
+ B &b = dynamic_cast<B&>(a);
+ int *x = 0;
+ return *x; // no warning (An exception is thrown by the cast.)
+}
+
+// Here we allow any outcome of the cast and this is good because there is a
+// situation where this will fail. So if the user has written the code in this
+// way, we assume they expect the cast to succeed.
+// Note, this might need special handling if we track types of symbolic casts
+// and use them for dynamic_cast handling.
+int testDynCastMostLikelyWillFail(C *c) {
+ B *b = 0;
+ b = dynamic_cast<B*>(c);
+ const int* res = 0;
+ static const int i = 5;
+ if (b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // expected-warning{{Dereference of null pointer}}
+}
+
+class M : public B, public C {};
+void callTestDynCastMostLikelyWillFail() {
+ M m;
+ testDynCastMostLikelyWillFail(&m);
+}
+
+// False positives/negatives.
+
+// Due to symbolic regions not being typed.
+int testDynCastFalsePositive(BB *c) {
+ B *b = 0;
+ b = dynamic_cast<B*>(c);
+ const int* res = 0;
+ static const int i = 5;
+ if (b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // expected-warning{{Dereference of null pointer}}
+}
+
+// Does not work when we new an object.
+int testDynCastFail3() {
+ A *a = new A();
+ B *b = dynamic_cast<B*>(a);
+ return b->m;
+}
+
diff --git a/clang/test/Analysis/elementtype.c b/clang/test/Analysis/elementtype.c
new file mode 100644
index 0000000..7452a0a
--- /dev/null
+++ b/clang/test/Analysis/elementtype.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region %s
+
+typedef struct added_obj_st {
+ int type;
+} ADDED_OBJ;
+
+// Test if we are using the canonical type for ElementRegion.
+void f() {
+ ADDED_OBJ *ao[4]={((void*)0),((void*)0),((void*)0),((void*)0)};
+ if (ao[0] != ((void*)0)) {
+ ao[0]->type=0;
+ }
+}
diff --git a/clang/test/Analysis/exercise-ps.c b/clang/test/Analysis/exercise-ps.c
new file mode 100644
index 0000000..b592c33
--- /dev/null
+++ b/clang/test/Analysis/exercise-ps.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s
+//
+// Just exercise the analyzer on code that has at one point caused issues
+// (i.e., no assertions or crashes).
+
+
+static void f1(const char *x, char *y) {
+ while (*x != 0) {
+ *y++ = *x++;
+ }
+}
+
+// This following case checks that we properly handle typedefs when getting
+// the RvalueType of an ElementRegion.
+typedef struct F12_struct {} F12_typedef;
+typedef void* void_typedef;
+void_typedef f2_helper();
+static void f2(void *buf) {
+ F12_typedef* x;
+ x = f2_helper();
+ memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring library function 'memcpy' with type 'void *(void *, const void *}} \
+ // expected-note{{please include the header <string.h> or explicitly provide a declaration for 'memcpy'}}
+}
diff --git a/clang/test/Analysis/fields.c b/clang/test/Analysis/fields.c
new file mode 100644
index 0000000..2e72c77
--- /dev/null
+++ b/clang/test/Analysis/fields.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core %s -analyzer-store=region -verify
+
+unsigned foo();
+typedef struct bf { unsigned x:2; } bf;
+void bar() {
+ bf y;
+ *(unsigned*)&y = foo();
+ y.x = 1;
+}
+
+struct s {
+ int n;
+};
+
+void f() {
+ struct s a;
+ int *p = &(a.n) + 1;
+}
+
+typedef struct {
+ int x,y;
+} Point;
+
+Point getit(void);
+void test() {
+ Point p;
+ (void)(p = getit()).x;
+}
diff --git a/clang/test/Analysis/free.c b/clang/test/Analysis/free.c
new file mode 100644
index 0000000..f688db7
--- /dev/null
+++ b/clang/test/Analysis/free.c
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-checker=core,unix.Malloc -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-checker=core,experimental.unix.MallocWithAnnotations -fblocks -verify %s
+void free(void *);
+
+void t1 () {
+ int a[] = { 1 };
+ free(a); // expected-warning {{Argument to free() is the address of the local variable 'a', which is not memory allocated by malloc()}}
+}
+
+void t2 () {
+ int a = 1;
+ free(&a); // expected-warning {{Argument to free() is the address of the local variable 'a', which is not memory allocated by malloc()}}
+}
+
+void t3 () {
+ static int a[] = { 1 };
+ free(a); // expected-warning {{Argument to free() is the address of the static variable 'a', which is not memory allocated by malloc()}}
+}
+
+void t4 (char *x) {
+ free(x); // no-warning
+}
+
+void t5 () {
+ extern char *ptr();
+ free(ptr()); // no-warning
+}
+
+void t6 () {
+ free((void*)1000); // expected-warning {{Argument to free() is a constant address (1000), which is not memory allocated by malloc()}}
+}
+
+void t7 (char **x) {
+ free(*x); // no-warning
+}
+
+void t8 (char **x) {
+ // ugh
+ free((*x)+8); // no-warning
+}
+
+void t9 () {
+label:
+ free(&&label); // expected-warning {{Argument to free() is the address of the label 'label', which is not memory allocated by malloc()}}
+}
+
+void t10 () {
+ free((void*)&t10); // expected-warning {{Argument to free() is the address of the function 't10', which is not memory allocated by malloc()}}
+}
+
+void t11 () {
+ char *p = (char*)__builtin_alloca(2);
+ free(p); // expected-warning {{Argument to free() was allocated by alloca(), not malloc()}}
+}
+
+void t12 () {
+ free(^{return;}); // expected-warning {{Argument to free() is a block, which is not memory allocated by malloc()}}
+}
+
+void t13 (char a) {
+ free(&a); // expected-warning {{Argument to free() is the address of the parameter 'a', which is not memory allocated by malloc()}}
+}
+
+static int someGlobal[2];
+void t14 () {
+ free(someGlobal); // expected-warning {{Argument to free() is the address of the global variable 'someGlobal', which is not memory allocated by malloc()}}
+}
+
+void t15 (char **x, int offset) {
+ // Unknown value
+ free(x[offset]); // no-warning
+}
diff --git a/clang/test/Analysis/func.c b/clang/test/Analysis/func.c
new file mode 100644
index 0000000..b6cebde
--- /dev/null
+++ b/clang/test/Analysis/func.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s
+
+void f(void) {
+ void (*p)(void);
+ p = f;
+ p = &f;
+ p();
+ (*p)();
+}
+
+void g(void (*fp)(void));
+
+void f2() {
+ g(f);
+}
diff --git a/clang/test/Analysis/global-region-invalidation.c b/clang/test/Analysis/global-region-invalidation.c
new file mode 100644
index 0000000..184ffb8
--- /dev/null
+++ b/clang/test/Analysis/global-region-invalidation.c
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -disable-free -analyzer-eagerly-assume -analyzer-checker=core,deadcode,experimental.security.taint,debug.TaintTest -verify %s
+
+// Note, we do need to include headers here, since the analyzer checks if the function declaration is located in a system header.
+#include "system-header-simulator.h"
+
+// Test that system header does not invalidate the internal global.
+int size_rdar9373039 = 1;
+int rdar9373039() {
+ int x;
+ int j = 0;
+
+ for (int i = 0 ; i < size_rdar9373039 ; ++i)
+ x = 1;
+
+ // strlen doesn't invalidate the value of 'size_rdar9373039'.
+ int extra = (2 + strlen ("Clang") + ((4 - ((unsigned int) (2 + strlen ("Clang")) % 4)) % 4)) + (2 + strlen ("1.0") + ((4 - ((unsigned int) (2 + strlen ("1.0")) % 4)) % 4));
+
+ for (int i = 0 ; i < size_rdar9373039 ; ++i)
+ j += x; // no-warning
+
+ return j;
+}
+
+// Test stdin does not get invalidated by a system call nor by an internal call.
+void foo();
+int stdinTest() {
+ int i = 0;
+ fscanf(stdin, "%d", &i);
+ foo();
+ int m = i; // expected-warning + {{tainted}}
+ fscanf(stdin, "%d", &i);
+ int j = i; // expected-warning + {{tainted}}
+ return m + j; // expected-warning + {{tainted}}
+}
+
+// Test errno gets invalidated by a system call.
+int testErrnoSystem() {
+ int i;
+ int *p = 0;
+ fscanf(stdin, "%d", &i);
+ if (errno == 0) {
+ fscanf(stdin, "%d", &i); // errno gets invalidated here.
+ return 5 / errno; // no-warning
+ }
+ return 0;
+}
+
+// Test that errno gets invalidated by internal calls.
+int testErrnoInternal() {
+ int i;
+ int *p = 0;
+ fscanf(stdin, "%d", &i);
+ if (errno == 0) {
+ foo(); // errno gets invalidated here.
+ return 5 / errno; // no-warning
+ }
+ return 0;
+}
+
+// Test that const integer does not get invalidated.
+const int x = 0;
+int constIntGlob() {
+ const int *m = &x;
+ foo();
+ return 3 / *m; // expected-warning {{Division by zero}}
+}
+
+extern const int x;
+int constIntGlobExtern() {
+ if (x == 0) {
+ foo();
+ return 5 / x; // expected-warning {{Division by zero}}
+ }
+ return 0;
+}
diff --git a/clang/test/Analysis/html-diags-multifile.c b/clang/test/Analysis/html-diags-multifile.c
new file mode 100644
index 0000000..611dd07
--- /dev/null
+++ b/clang/test/Analysis/html-diags-multifile.c
@@ -0,0 +1,17 @@
+// RUN: mkdir -p %t.dir
+// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t.dir
+// RUN: ls %t.dir | grep report | count 0
+// RUN: rm -fR %t.dir
+// REQUIRES: shell
+
+// This tests that we do not currently emit HTML diagnostics for reports that
+// cross file boundaries.
+
+#include "html-diags-multifile.h"
+
+#define CALL_HAS_BUG(q) has_bug(q)
+
+void test_call_macro() {
+ CALL_HAS_BUG(0);
+}
+
diff --git a/clang/test/Analysis/html-diags-multifile.h b/clang/test/Analysis/html-diags-multifile.h
new file mode 100644
index 0000000..71d39ba
--- /dev/null
+++ b/clang/test/Analysis/html-diags-multifile.h
@@ -0,0 +1,4 @@
+#define DEREF(p) *p = 0xDEADBEEF
+void has_bug(int *p) {
+ DEREF(p);
+}
diff --git a/clang/test/Analysis/html-diags.c b/clang/test/Analysis/html-diags.c
new file mode 100644
index 0000000..59d81a5
--- /dev/null
+++ b/clang/test/Analysis/html-diags.c
@@ -0,0 +1,20 @@
+// RUN: mkdir %t.dir
+// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %T.dir %s
+// RUN: rm -fR %t.dir
+
+// Currently this test mainly checks that the HTML diagnostics doesn't crash
+// when handling macros will calls with macros. We should actually validate
+// the output, but that requires being able to match against a specifically
+// generate HTML file.
+
+#define DEREF(p) *p = 0xDEADBEEF
+
+void has_bug(int *p) {
+ DEREF(p);
+}
+
+#define CALL_HAS_BUG(q) has_bug(q)
+
+void test_call_macro() {
+ CALL_HAS_BUG(0);
+}
diff --git a/clang/test/Analysis/idempotent-operations-limited-loops.c b/clang/test/Analysis/idempotent-operations-limited-loops.c
new file mode 100644
index 0000000..71e7c27
--- /dev/null
+++ b/clang/test/Analysis/idempotent-operations-limited-loops.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,experimental.deadcode.IdempotentOperations -analyzer-max-loop 3 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,experimental.deadcode.IdempotentOperations -analyzer-max-loop 4 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,experimental.deadcode.IdempotentOperations %s -verify
+
+void always_warning() { int *p = 0; *p = 0xDEADBEEF; } // expected-warning{{Dereference of null pointer (loaded from variable 'p')}}
+
+// This test case previously caused a bogus idempotent operation warning
+// due to us not properly culling warnings due to incomplete analysis of loops.
+int pr8403()
+{
+ int i;
+ for(i=0; i<10; i++)
+ {
+ int j;
+ for(j=0; j+1<i; j++)
+ {
+ }
+ }
+ return 0;
+}
+
diff --git a/clang/test/Analysis/idempotent-operations.c b/clang/test/Analysis/idempotent-operations.c
new file mode 100644
index 0000000..6cc9a01
--- /dev/null
+++ b/clang/test/Analysis/idempotent-operations.c
@@ -0,0 +1,236 @@
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=experimental.deadcode.IdempotentOperations -verify %s
+
+// Basic tests
+
+extern void test(int i);
+extern void test_f(float f);
+
+unsigned basic() {
+ int x = 10, zero = 0, one = 1;
+
+ // x op x
+ x = x; // expected-warning {{Assigned value is always the same as the existing value}}
+ test(x - x); // expected-warning {{Both operands to '-' always have the same value}}
+ x -= x; // expected-warning {{Both operands to '-=' always have the same value}}
+ x = 10; // no-warning
+ test(x / x); // expected-warning {{Both operands to '/' always have the same value}}
+ x /= x; // expected-warning {{Both operands to '/=' always have the same value}}
+ x = 10; // no-warning
+ test(x & x); // expected-warning {{Both operands to '&' always have the same value}}
+ x &= x; // expected-warning {{Both operands to '&=' always have the same value}}
+ test(x | x); // expected-warning {{Both operands to '|' always have the same value}}
+ x |= x; // expected-warning {{Both operands to '|=' always have the same value}}
+
+ // x op 1
+ test(x * one); // expected-warning {{The right operand to '*' is always 1}}
+ x *= one; // expected-warning {{The right operand to '*=' is always 1}}
+ test(x / one); // expected-warning {{The right operand to '/' is always 1}}
+ x /= one; // expected-warning {{The right operand to '/=' is always 1}}
+
+ // 1 op x
+ test(one * x); // expected-warning {{The left operand to '*' is always 1}}
+
+ // x op 0
+ test(x + zero); // expected-warning {{The right operand to '+' is always 0}}
+ test(x - zero); // expected-warning {{The right operand to '-' is always 0}}
+ test(x * zero); // expected-warning {{The right operand to '*' is always 0}}
+ test(x & zero); // expected-warning {{The right operand to '&' is always 0}}
+ test(x | zero); // expected-warning {{The right operand to '|' is always 0}}
+ test(x ^ zero); // expected-warning {{The right operand to '^' is always 0}}
+ test(x << zero); // expected-warning {{The right operand to '<<' is always 0}}
+ test(x >> zero); // expected-warning {{The right operand to '>>' is always 0}}
+
+ // 0 op x
+ test(zero + x); // expected-warning {{The left operand to '+' is always 0}}
+ test(zero - x); // expected-warning {{The left operand to '-' is always 0}}
+ test(zero / x); // expected-warning {{The left operand to '/' is always 0}}
+ test(zero * x); // expected-warning {{The left operand to '*' is always 0}}
+ test(zero & x); // expected-warning {{The left operand to '&' is always 0}}
+ test(zero | x); // expected-warning {{The left operand to '|' is always 0}}
+ test(zero ^ x); // expected-warning {{The left operand to '^' is always 0}}
+ test(zero << x); // expected-warning {{The left operand to '<<' is always 0}}
+ test(zero >> x); // expected-warning {{The left operand to '>>' is always 0}}
+
+ // Overwrite the values so these aren't marked as Pseudoconstants
+ x = 1;
+ zero = 2;
+ one = 3;
+
+ return x + zero + one;
+}
+
+void floats(float x) {
+ test_f(x * 1.0); // no-warning
+ test_f(x * 1.0F); // no-warning
+}
+
+// Ensure that we don't report false poitives in complex loops
+void bailout() {
+ int unused = 0, result = 4;
+ result = result; // expected-warning {{Assigned value is always the same as the existing value}}
+
+ for (unsigned bg = 0; bg < 1024; bg ++) {
+ result = bg * result; // no-warning
+
+ for (int i = 0; i < 256; i++) {
+ unused *= i; // no-warning
+ }
+ }
+}
+
+// Relaxed liveness - check that we don't kill liveness at assignments
+typedef unsigned uintptr_t;
+void kill_at_assign() {
+ short array[2];
+ uintptr_t x = (uintptr_t) array;
+ short *p = (short *) x;
+
+ // The following branch should be infeasible.
+ if (!(p = &array[0])) { // expected-warning{{Assigned value is always the same as the existing value}}
+ p = 0;
+ *p = 1; // no-warning
+ }
+}
+
+// False positive tests
+
+unsigned false1() {
+ int a = 10;
+ return a * (5 - 2 - 3); // no-warning
+}
+
+enum testenum { enum1 = 0, enum2 };
+unsigned false2() {
+ int a = 1234;
+ return enum1 + a; // no-warning
+}
+
+// Self assignments of unused variables are common false positives
+unsigned false3(int param, int param2) {
+ param = param; // no-warning
+
+ // if a self assigned variable is used later, then it should be reported still
+ param2 = param2; // expected-warning{{Assigned value is always the same as the existing value}}
+
+ unsigned nonparam = 5;
+
+ nonparam = nonparam; // expected-warning{{Assigned value is always the same as the existing value}}
+
+ return param2 + nonparam;
+}
+
+// Pseudo-constants (vars only read) and constants should not be reported
+unsigned false4() {
+ // Trivial constant
+ const int height = 1;
+ int c = 42;
+ test(height * c); // no-warning
+
+ // Pseudo-constant (never changes after decl)
+ int width = height;
+
+ return width * 10; // no-warning
+}
+
+// Block pseudoconstants
+void false4a() {
+ // Pseudo-constant
+ __block int a = 1;
+ int b = 10;
+ __block int c = 0;
+ b *= a; // no-warning
+
+ ^{
+ // Psuedoconstant block var
+ test(b * c); // no-warning
+
+ // Non-pseudoconstant block var
+ int d = 0;
+ test(b * d); // expected-warning{{The right operand to '*' is always 0}}
+ d = 5;
+ test(d);
+ }();
+
+ test(a + b);
+}
+
+// Static vars are common false positives
+int false5() {
+ static int test = 0;
+ int a = 56;
+ a *= test; // no-warning
+ test++;
+ return a;
+}
+
+// Non-local storage vars are considered false positives
+int globalInt = 1;
+int false6() {
+ int localInt = 23;
+
+ localInt /= globalInt;
+
+ return localInt;
+}
+
+// Check that assignments filter out false positives correctly
+int false7() {
+ int zero = 0; // pseudo-constant
+ int one = 1;
+
+ int a = 55;
+ a = a; // expected-warning{{Assigned value is always the same as the existing value}}
+ a = enum1 * a; // no-warning
+
+ int b = 123;
+ b = b; // no-warning
+
+ return a;
+}
+
+// Check truncations do not flag as self-assignments
+void false8() {
+ int a = 10000000;
+ a = (short)a; // no-warning
+ test(a);
+}
+
+// This test case previously flagged a warning at 'b == c' because the
+// analyzer previously allowed 'UnknownVal' as the index for ElementRegions.
+typedef struct RDar8431728_F {
+ int RDar8431728_A;
+ unsigned char *RDar8431728_B;
+ int RDar8431728_E[6];
+} RDar8431728_D;
+static inline int RDar8431728_C(RDar8431728_D * s, int n,
+ unsigned char **RDar8431728_B_ptr) {
+ int xy, wrap, pred, a, b, c;
+
+ xy = s->RDar8431728_E[n];
+ wrap = s->RDar8431728_A;
+
+ a = s->RDar8431728_B[xy - 1];
+ b = s->RDar8431728_B[xy - 1 - wrap];
+ c = s->RDar8431728_B[xy - wrap];
+
+ if (b == c) { // no-warning
+ pred = a;
+ } else {
+ pred = c;
+ }
+
+ *RDar8431728_B_ptr = &s->RDar8431728_B[xy];
+
+ return pred;
+}
+
+// <rdar://problem/8601243> - Don't warn on pointer arithmetic. This
+// is often idiomatic.
+unsigned rdar8601243_aux(unsigned n);
+void rdar8601243() {
+ char arr[100];
+ char *start = arr;
+ start = start + rdar8601243_aux(sizeof(arr) - (arr - start)); // no-warning
+ (void) start;
+}
+
diff --git a/clang/test/Analysis/idempotent-operations.cpp b/clang/test/Analysis/idempotent-operations.cpp
new file mode 100644
index 0000000..51b5905
--- /dev/null
+++ b/clang/test/Analysis/idempotent-operations.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=experimental.deadcode.IdempotentOperations -verify %s
+
+// C++ specific false positives
+
+extern void test(int i);
+extern void test_ref(int &i);
+
+// Test references affecting pseudoconstants
+void false1() {
+ int a = 0;
+ int five = 5;
+ int &b = a;
+ test(five * a); // expected-warning {{The right operand to '*' is always 0}}
+ b = 4;
+}
+
+// Test not flagging idempotent operations because we aborted the analysis
+// of a path because of an unsupported construct.
+struct RDar9219143_Foo {
+ ~RDar9219143_Foo();
+ operator bool() const;
+};
+
+RDar9219143_Foo foo();
+unsigned RDar9219143_bar();
+void RDar9219143_test() {
+ unsigned i, e;
+ for (i = 0, e = RDar9219143_bar(); i != e; ++i)
+ if (foo())
+ break;
+ if (i == e) // no-warning
+ return;
+}
+
diff --git a/clang/test/Analysis/idempotent-operations.m b/clang/test/Analysis/idempotent-operations.m
new file mode 100644
index 0000000..9a9820c
--- /dev/null
+++ b/clang/test/Analysis/idempotent-operations.m
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=experimental.deadcode.IdempotentOperations,osx.cocoa.RetainCount -verify %s
+
+typedef signed char BOOL;
+typedef unsigned long NSUInteger;
+typedef struct _NSZone NSZone;
+@protocol NSObject - (BOOL)isEqual:(id)object;
+@end
+
+@interface NSObject {}
+ @property int locked;
+ @property(nonatomic, readonly) NSObject *media;
+@end
+
+// <rdar://problem/8725041> - Don't flag idempotent operation warnings when
+// a method may invalidate an instance variable.
+@interface Rdar8725041 : NSObject {
+ id _attribute;
+}
+ - (void) method2;
+@end
+
+@implementation Rdar8725041
+- (BOOL) method1 {
+ BOOL needsUpdate = (BOOL)0;
+ id oldAttribute = _attribute;
+ [self method2];
+ needsUpdate |= (_attribute != oldAttribute); // no-warning
+ return needsUpdate;
+}
+
+- (void) method2
+{
+ _attribute = ((void*)0);
+}
+@end
+
+// Test that the idempotent operations checker works in the prescence
+// of property expressions.
+void pr9116(NSObject *placeholder) {
+ int x = placeholder.media.locked = placeholder ? 1 : 0;
+}
+
+// <rdar://problem/9130239>: Test that calling property setters doesn't
+// trigger an assertion failure when the object is nil.
+@interface RDar9130239
+@property (assign) id delegate;
+@end
+
+void test_RDar9130239(RDar9130239 *x) {
+ if (x)
+ return;
+ x.delegate = x; // no-warning
+}
+
diff --git a/clang/test/Analysis/initializer.cpp b/clang/test/Analysis/initializer.cpp
new file mode 100644
index 0000000..656a8bf
--- /dev/null
+++ b/clang/test/Analysis/initializer.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -cfg-add-initializers -verify %s
+
+class A {
+ int x;
+public:
+ A();
+};
+
+A::A() : x(0) {
+ if (x != 0) {
+ int *p = 0;
+ *p = 0; // no-warning
+ }
+}
diff --git a/clang/test/Analysis/initializers-cfg-output.cpp b/clang/test/Analysis/initializers-cfg-output.cpp
new file mode 100644
index 0000000..8a7a3f5
--- /dev/null
+++ b/clang/test/Analysis/initializers-cfg-output.cpp
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-initializers %s 2>&1 | FileCheck %s
+// XPASS: *
+
+class A {
+public:
+ A() {}
+ A(int i) {}
+};
+
+class B : public virtual A {
+public:
+ B() {}
+ B(int i) : A(i) {}
+};
+
+class C : public virtual A {
+public:
+ C() {}
+ C(int i) : A(i) {}
+};
+
+class TestOrder : public C, public B, public A {
+ int i;
+ int& r;
+public:
+ TestOrder();
+};
+
+TestOrder::TestOrder()
+ : r(i), B(), i(), C() {
+ A a;
+}
+
+class TestControlFlow {
+ int x, y, z;
+public:
+ TestControlFlow(bool b);
+};
+
+TestControlFlow::TestControlFlow(bool b)
+ : y(b ? 0 : 1)
+ , x(0)
+ , z(y) {
+ int v;
+}
+
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A([B1.1]) (Base initializer)
+// CHECK: 3: (CXXConstructExpr, class C)
+// CHECK: 4: C([B1.3]) (Base initializer)
+// CHECK: 5: (CXXConstructExpr, class B)
+// CHECK: 6: B([B1.5]) (Base initializer)
+// CHECK: 7: (CXXConstructExpr, class A)
+// CHECK: 8: A([B1.7]) (Base initializer)
+// CHECK: 9: /*implicit*/int()
+// CHECK: 10: i([B1.9]) (Member initializer)
+// CHECK: 11: this
+// CHECK: 12: [B1.11]->i
+// CHECK: 13: r([B1.12]) (Member initializer)
+// CHECK: 14: (CXXConstructExpr, class A)
+// CHECK: 15: A a;
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B5 (ENTRY)]
+// CHECK: Succs (1): B4
+// CHECK: [B1]
+// CHECK: 1: [B4.4] ? [B2.1] : [B3.1]
+// CHECK: 2: y([B1.1]) (Member initializer)
+// CHECK: 3: this
+// CHECK: 4: [B1.3]->y
+// CHECK: 5: [B1.4] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK: 6: z([B1.5]) (Member initializer)
+// CHECK: 7: int v;
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: 0
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: 1
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: 0
+// CHECK: 2: x([B4.1]) (Member initializer)
+// CHECK: 3: b
+// CHECK: 4: [B4.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: [B4.4] ? ... : ...
+// CHECK: Preds (1): B5
+// CHECK: Succs (2): B2 B3
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
diff --git a/clang/test/Analysis/inline-not-supported.c b/clang/test/Analysis/inline-not-supported.c
new file mode 100644
index 0000000..bff0e4d
--- /dev/null
+++ b/clang/test/Analysis/inline-not-supported.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
+
+// For now, don't inline varargs.
+void foo(int *x, ...) {
+ *x = 1;
+}
+
+void bar() {
+ foo(0, 2); // no-warning
+}
+
+// For now, don't inline vararg blocks.
+void (^baz)(int *x, ...) = ^(int *x, ...) { *x = 1; };
+
+void taz() {
+ baz(0, 2); // no-warning
+}
+
+// For now, don't inline blocks.
+void (^qux)(int *p) = ^(int *p) { *p = 1; };
+void test_qux() {
+ qux(0); // no-warning
+}
+
+
+void test_analyzer_is_running() {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+}
diff --git a/clang/test/Analysis/inline-plist.c b/clang/test/Analysis/inline-plist.c
new file mode 100644
index 0000000..549082d
--- /dev/null
+++ b/clang/test/Analysis/inline-plist.c
@@ -0,0 +1,369 @@
+// RUN: %clang --analyze %s -Xclang -analyzer-ipa=inlining -o %t
+// RUN: FileCheck -input-file %t %s
+
+// <rdar://problem/10967815>
+void mmm(int y) {
+ if (y != 0)
+ y++;
+}
+
+int foo(int x, int y) {
+ mmm(y);
+ if (x != 0)
+ x++;
+ return 5/x;
+}
+
+// Test a bug triggering only when inlined.
+void has_bug(int *p) {
+ *p = 0xDEADBEEF;
+}
+
+void test_has_bug() {
+ has_bug(0);
+}
+
+
+// CHECK: <?xml version="1.0" encoding="UTF-8"?>
+// 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>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</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>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;x&apos; is equal to 0</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;x&apos; is equal to 0</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>12</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>14</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Division by zero</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Division by zero</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Division by zero</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Division by zero</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>foo</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>3</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>23</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;has_bug&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;has_bug&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;test_has_bug&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;test_has_bug&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</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>19</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>has_bug</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </plist>
diff --git a/clang/test/Analysis/inline-unique-reports.c b/clang/test/Analysis/inline-unique-reports.c
new file mode 100644
index 0000000..ae94267
--- /dev/null
+++ b/clang/test/Analysis/inline-unique-reports.c
@@ -0,0 +1,184 @@
+// RUN: %clang --analyze %s -Xclang -analyzer-ipa=inlining -o %t > /dev/null 2>&1
+// RUN: FileCheck -input-file %t %s
+
+static inline bug(int *p) {
+ *p = 0xDEADBEEF;
+}
+
+void test_bug_1() {
+ int *p = 0;
+ bug(p);
+}
+
+void test_bug_2() {
+ int *p = 0;
+ bug(p);
+}
+
+// CHECK: <?xml version="1.0" encoding="UTF-8"?>
+// 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>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>9</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>9</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</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>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;bug&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;bug&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;test_bug_1&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;test_bug_1&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</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>5</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>bug</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </plist>
diff --git a/clang/test/Analysis/inline.c b/clang/test/Analysis/inline.c
new file mode 100644
index 0000000..0827d93
--- /dev/null
+++ b/clang/test/Analysis/inline.c
@@ -0,0 +1,92 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
+
+int test1_f1() {
+ int y = 1;
+ y++;
+ return y;
+}
+
+void test1_f2() {
+ int x = 1;
+ x = test1_f1();
+ if (x == 1) {
+ int *p = 0;
+ *p = 3; // no-warning
+ }
+ if (x == 2) {
+ int *p = 0;
+ *p = 3; // expected-warning{{Dereference of null pointer (loaded from variable 'p')}}
+ }
+}
+
+// Test that inlining works when the declared function has less arguments
+// than the actual number in the declaration.
+void test2_f1() {}
+int test2_f2();
+
+void test2_f3() {
+ test2_f1(test2_f2()); // expected-warning{{too many arguments in call to 'test2_f1'}}
+}
+
+// Test that inlining works with recursive functions.
+
+unsigned factorial(unsigned x) {
+ if (x <= 1)
+ return 1;
+ return x * factorial(x - 1);
+}
+
+void test_factorial() {
+ if (factorial(3) == 6) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+ }
+ else {
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+}
+
+void test_factorial_2() {
+ unsigned x = factorial(3);
+ if (x == factorial(3)) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+ }
+ else {
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+}
+
+// Test that returning stack memory from a parent stack frame does
+// not trigger a warning.
+static char *return_buf(char *buf) {
+ return buf + 10;
+}
+
+void test_return_stack_memory_ok() {
+ char stack_buf[100];
+ char *pos = return_buf(stack_buf);
+ (void) pos;
+}
+
+char *test_return_stack_memory_bad() {
+ char stack_buf[100];
+ char *x = stack_buf;
+ return x; // expected-warning {{stack memory associated}}
+}
+
+// Test that passing a struct value with an uninitialized field does
+// not trigger a warning if we are inlining and the body is available.
+struct rdar10977037 { int x, y; };
+int test_rdar10977037_aux(struct rdar10977037 v) { return v.y; }
+int test_rdar10977037_aux_2(struct rdar10977037 v);
+int test_rdar10977037() {
+ struct rdar10977037 v;
+ v.y = 1;
+ v. y += test_rdar10977037_aux(v); // no-warning
+ return test_rdar10977037_aux_2(v); // expected-warning {{Passed-by-value struct argument contains uninitialized data}}
+}
+
+
diff --git a/clang/test/Analysis/inline2.c b/clang/test/Analysis/inline2.c
new file mode 100644
index 0000000..473146c
--- /dev/null
+++ b/clang/test/Analysis/inline2.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
+
+// Test parameter 'a' is registered to LiveVariables analysis data although it
+// is not referenced in the function body.
+// Before processing 'return 1;', in RemoveDeadBindings(), we query the liveness
+// of 'a', because we have a binding for it due to parameter passing.
+int f1(int a) {
+ return 1;
+}
+
+void f2() {
+ int x;
+ x = f1(1);
+}
diff --git a/clang/test/Analysis/inline3.c b/clang/test/Analysis/inline3.c
new file mode 100644
index 0000000..968d82a
--- /dev/null
+++ b/clang/test/Analysis/inline3.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
+
+// Test when entering f1(), we set the right AnalysisDeclContext to Environment.
+// Otherwise, block-level expr '1 && a' would not be block-level.
+int a;
+
+void f1() {
+ if (1 && a)
+ return;
+}
+
+void f2() {
+ f1();
+}
diff --git a/clang/test/Analysis/inline4.c b/clang/test/Analysis/inline4.c
new file mode 100644
index 0000000..e7715e0
--- /dev/null
+++ b/clang/test/Analysis/inline4.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
+
+int g(int a) {
+ return a;
+}
+
+int f(int a) {
+ // Do not remove block-level expression bindings of caller when analyzing
+ // in the callee.
+ if (1 && g(a)) // The binding of '1 && g(a)' which is an UndefinedVal
+ // carries important information.
+ return 1;
+ return 0;
+}
diff --git a/clang/test/Analysis/iterators.cpp b/clang/test/Analysis/iterators.cpp
new file mode 100644
index 0000000..1b6340b
--- /dev/null
+++ b/clang/test/Analysis/iterators.cpp
@@ -0,0 +1,105 @@
+// RUN: %clang --analyze -Xclang -analyzer-checker=core,experimental.cplusplus.Iterators -Xclang -verify %s
+// XFAIL: win32
+
+#include <vector>
+
+void fum(std::vector<int>::iterator t);
+
+void foo1()
+{
+ // iterators that are defined but not initialized
+ std::vector<int>::iterator it2;
+ fum(it2); // expected-warning{{Use of iterator that is not defined}}
+ *it2; // expected-warning{{Use of iterator that is not defined}}
+
+ std::vector<int> v, vv;
+ std::vector<int>::iterator it = v.begin();
+ fum(it); // no-warning
+ *it; // no-warning
+ // a valid iterator plus an integer is still valid
+ std::vector<int>::iterator et = it + 3;
+ while(it != et) { // no-warning
+ if (*it == 0) // no-warning
+ *it = 1; // no-warning
+ }
+ // iterators from different instances Cannot be compared
+ et = vv.end();
+ while(it != et) // expected-warning{{Cannot compare iterators from different containers}}
+ ;
+
+ for( std::vector<int>::iterator it = v.begin(); it != v.end(); it++ ) { // no-warning
+ if (*it == 1) // no-warning
+ *it = 0; // no-warning
+ }
+
+ // copying a valid iterator results in a valid iterator
+ et = it; // no-warning
+ *et; // no-warning
+
+ // any combo of valid iterator plus a constant is still valid
+ et = it + 2; // no-warning
+ *et; // no-warning
+ et = 2 + it; // no-warning
+ *et; // no-warning
+ et = 2 + 4 + it; // no-warning
+ *et; // no-warning
+
+ // calling insert invalidates unless assigned to as result, but still
+ // invalidates other iterators on the same instance
+ it = v.insert( it, 1 ); // no-warning
+ *et; // expected-warning{{Attempt to use an iterator made invalid by call to 'insert'}}
+ ++it; // no-warning
+
+ // calling erase invalidates the iterator
+ v.erase(it); // no-warning
+ et = it + 2; // expected-warning{{Attempt to use an iterator made invalid by call to 'erase'}}
+ et = 2 + it + 2; // expected-warning{{Attempt to use an iterator made invalid by call to 'erase'}}
+ et = 2 + it; // expected-warning{{Attempt to use an iterator made invalid by call to 'erase'}}
+ ++it; // expected-warning{{Attempt to use an iterator made invalid by call to 'erase'}}
+ it++; // expected-warning{{Attempt to use an iterator made invalid by call to 'erase'}}
+ *it; // expected-warning{{Attempt to use an iterator made invalid by call to 'erase'}}
+ it = v.insert( it, 1 ); // expected-warning{{Attempt to use an iterator made invalid by call to 'erase'}}
+ // now valid after return from insert
+ *it; // no-warning
+}
+
+// work with using namespace
+void foo2()
+{
+ using namespace std;
+
+ vector<int> v;
+ vector<int>::iterator it = v.begin();
+ *it; // no-warning
+ v.insert( it, 1 ); // no-warning
+ *it; // expected-warning{{Attempt to use an iterator made invalid by call to 'insert'}}
+ it = v.insert( it, 1 ); // expected-warning{{Attempt to use an iterator made invalid by call to 'insert'}}
+ *it; // no-warning
+}
+
+// using reserve eliminates some warnings
+void foo3()
+{
+ std::vector<long> v;
+ std::vector<long>::iterator b = v.begin();
+ v.reserve( 100 );
+
+ // iterator assigned before the reserve is still invalidated
+ *b; // expected-warning{{Attempt to use an iterator made invalid by call to 'reserve'}}
+ b = v.begin();
+ v.insert( b, 1 ); // no-warning
+
+ // iterator after assignment is still valid (probably)
+ *b; // no-warning
+}
+
+// check on copying one iterator to another
+void foo4()
+{
+ std::vector<float> v, vv;
+ std::vector<float>::iterator it = v.begin();
+ *it; // no-warning
+ v = vv;
+ *it; // expected-warning{{Attempt to use an iterator made invalid by copying another container to its container}}
+}
+
diff --git a/clang/test/Analysis/keychainAPI-diagnostic-visitor.m b/clang/test/Analysis/keychainAPI-diagnostic-visitor.m
new file mode 100644
index 0000000..a78b114
--- /dev/null
+++ b/clang/test/Analysis/keychainAPI-diagnostic-visitor.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=osx.SecKeychainAPI -analyzer-store=region -analyzer-output=text -verify %s
+
+// This file is for testing enhanced diagnostics produced by the default SecKeychainAPI checker.
+
+typedef unsigned int OSStatus;
+typedef unsigned int SecKeychainAttributeList;
+typedef unsigned int SecKeychainItemRef;
+typedef unsigned int SecItemClass;
+typedef unsigned int UInt32;
+enum {
+ noErr = 0,
+ GenericError = 1
+};
+OSStatus SecKeychainItemCopyContent (
+ SecKeychainItemRef itemRef,
+ SecItemClass *itemClass,
+ SecKeychainAttributeList *attrList,
+ UInt32 *length,
+ void **outData
+ );
+
+void DellocWithCFStringCreate4() {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 length;
+ char *bytes;
+ char *x;
+ st = SecKeychainItemCopyContent(2, ptr, ptr, &length, (void **)&bytes); // expected-note {{Data is allocated here}}
+ x = bytes;
+ if (st == noErr) // expected-note {{Assuming 'st' is equal to noErr}} // expected-note{{Taking true branch}}
+ x = bytes;;
+
+ length++; // expected-warning {{Allocated data is not released}} // expected-note{{Allocated data is not released}}
+}
+
diff --git a/clang/test/Analysis/keychainAPI.m b/clang/test/Analysis/keychainAPI.m
new file mode 100644
index 0000000..cb4f72c
--- /dev/null
+++ b/clang/test/Analysis/keychainAPI.m
@@ -0,0 +1,409 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.SecKeychainAPI %s -analyzer-ipa=inlining -verify
+
+// Fake typedefs.
+typedef unsigned int OSStatus;
+typedef unsigned int SecKeychainAttributeList;
+typedef unsigned int SecKeychainItemRef;
+typedef unsigned int SecItemClass;
+typedef unsigned int UInt32;
+typedef unsigned int CFTypeRef;
+typedef unsigned int UInt16;
+typedef unsigned int SecProtocolType;
+typedef unsigned int SecAuthenticationType;
+typedef unsigned int SecKeychainAttributeInfo;
+enum {
+ noErr = 0,
+ GenericError = 1
+};
+
+// Functions that allocate data.
+OSStatus SecKeychainItemCopyContent (
+ SecKeychainItemRef itemRef,
+ SecItemClass *itemClass,
+ SecKeychainAttributeList *attrList,
+ UInt32 *length,
+ void **outData
+);
+OSStatus SecKeychainFindGenericPassword (
+ CFTypeRef keychainOrArray,
+ UInt32 serviceNameLength,
+ const char *serviceName,
+ UInt32 accountNameLength,
+ const char *accountName,
+ UInt32 *passwordLength,
+ void **passwordData,
+ SecKeychainItemRef *itemRef
+);
+OSStatus SecKeychainFindInternetPassword (
+ CFTypeRef keychainOrArray,
+ UInt32 serverNameLength,
+ const char *serverName,
+ UInt32 securityDomainLength,
+ const char *securityDomain,
+ UInt32 accountNameLength,
+ const char *accountName,
+ UInt32 pathLength,
+ const char *path,
+ UInt16 port,
+ SecProtocolType protocol,
+ SecAuthenticationType authenticationType,
+ UInt32 *passwordLength,
+ void **passwordData,
+ SecKeychainItemRef *itemRef
+);
+OSStatus SecKeychainItemCopyAttributesAndData (
+ SecKeychainItemRef itemRef,
+ SecKeychainAttributeInfo *info,
+ SecItemClass *itemClass,
+ SecKeychainAttributeList **attrList,
+ UInt32 *length,
+ void **outData
+);
+
+// Functions which free data.
+OSStatus SecKeychainItemFreeContent (
+ SecKeychainAttributeList *attrList,
+ void *data
+);
+OSStatus SecKeychainItemFreeAttributesAndData (
+ SecKeychainAttributeList *attrList,
+ void *data
+);
+
+void errRetVal() {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 length;
+ void *outData;
+ st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData);
+ if (st == GenericError) // expected-warning{{Allocated data is not released: missing a call to 'SecKeychainItemFreeContent'.}}
+ SecKeychainItemFreeContent(ptr, outData); // expected-warning{{Only call free if a valid (non-NULL) buffer was returned}}
+}
+
+// If null is passed in, the data is not allocated, so no need for the matching free.
+void fooDoNotReportNull() {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 *length = 0;
+ void **outData = 0;
+ SecKeychainItemCopyContent(2, ptr, ptr, 0, 0);
+ SecKeychainItemCopyContent(2, ptr, ptr, length, outData);
+}// no-warning
+
+void doubleAlloc() {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 length;
+ void *outData;
+ st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData);
+ st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData); // expected-warning {{Allocated data should be released before another call to the allocator:}}
+ if (st == noErr)
+ SecKeychainItemFreeContent(ptr, outData);
+}
+
+void fooOnlyFree() {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 length;
+ void *outData = &length;
+ SecKeychainItemFreeContent(ptr, outData);// expected-warning{{Trying to free data which has not been allocated}}
+}
+
+// Do not warn if undefined value is passed to a function.
+void fooOnlyFreeUndef() {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 length;
+ void *outData;
+ SecKeychainItemFreeContent(ptr, outData);
+}// no-warning
+
+// Do not warn if the address is a parameter in the enclosing function.
+void fooOnlyFreeParam(void *attrList, void* X) {
+ SecKeychainItemFreeContent(attrList, X);
+}// no-warning
+
+// If we are returning the value, do not report.
+void* returnContent() {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 length;
+ void *outData;
+ st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData);
+ return outData;
+} // no-warning
+
+// Password was passed in as an argument and does not have to be deleted.
+OSStatus getPasswordAndItem(void** password, UInt32* passwordLength) {
+ OSStatus err;
+ SecKeychainItemRef item;
+ err = SecKeychainFindGenericPassword(0, 3, "xx", 3, "xx",
+ passwordLength, password, &item);
+ return err;
+} // no-warning
+
+// Make sure we do not report an error if we call free only if password != 0.
+// Also, do not report double allocation if first allocation returned an error.
+OSStatus testSecKeychainFindGenericPassword(UInt32* passwordLength,
+ CFTypeRef keychainOrArray, SecProtocolType protocol,
+ SecAuthenticationType authenticationType) {
+ OSStatus err;
+ SecKeychainItemRef item;
+ void *password;
+ err = SecKeychainFindGenericPassword(0, 3, "xx", 3, "xx",
+ passwordLength, &password, &item);
+ if( err == GenericError ) {
+ err = SecKeychainFindInternetPassword(keychainOrArray,
+ 16, "server", 16, "domain", 16, "account",
+ 16, "path", 222, protocol, authenticationType,
+ passwordLength, &(password), 0);
+ }
+
+ if (err == noErr && password) {
+ SecKeychainItemFreeContent(0, password);
+ }
+ return err;
+}
+
+int apiMismatch(SecKeychainItemRef itemRef,
+ SecKeychainAttributeInfo *info,
+ SecItemClass *itemClass) {
+ OSStatus st = 0;
+ SecKeychainAttributeList *attrList;
+ UInt32 length;
+ void *outData;
+
+ st = SecKeychainItemCopyAttributesAndData(itemRef, info, itemClass,
+ &attrList, &length, &outData);
+ if (st == noErr)
+ SecKeychainItemFreeContent(attrList, outData); // expected-warning{{Deallocator doesn't match the allocator}}
+ return 0;
+}
+
+int ErrorCodesFromDifferentAPISDoNotInterfere(SecKeychainItemRef itemRef,
+ SecKeychainAttributeInfo *info,
+ SecItemClass *itemClass) {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 length;
+ void *outData;
+ OSStatus st2 = 0;
+ SecKeychainAttributeList *attrList;
+ UInt32 length2;
+ void *outData2;
+
+ st2 = SecKeychainItemCopyAttributesAndData(itemRef, info, itemClass,
+ &attrList, &length2, &outData2);
+ st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData);
+ if (st == noErr) {
+ SecKeychainItemFreeContent(ptr, outData);
+ if (st2 == noErr) {
+ SecKeychainItemFreeAttributesAndData(attrList, outData2);
+ }
+ }
+ return 0; // expected-warning{{Allocated data is not released: missing a call to 'SecKeychainItemFreeAttributesAndData'}}
+}
+
+int foo(CFTypeRef keychainOrArray, SecProtocolType protocol,
+ SecAuthenticationType authenticationType, SecKeychainItemRef *itemRef) {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+
+ UInt32 length;
+ void *outData[5];
+
+ st = SecKeychainFindInternetPassword(keychainOrArray,
+ 16, "server", 16, "domain", 16, "account",
+ 16, "path", 222, protocol, authenticationType,
+ &length, &(outData[3]), itemRef);
+ if (length == 5) {
+ if (st == noErr)
+ SecKeychainItemFreeContent(ptr, outData[3]);
+ }
+ if (length) { // expected-warning{{Allocated data is not released: missing a call to 'SecKeychainItemFreeContent'.}}
+ length++;
+ }
+ return 0;
+}// no-warning
+
+void free(void *ptr);
+void deallocateWithFree() {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 length;
+ void *outData;
+ st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData);
+ if (st == noErr)
+ free(outData); // expected-warning{{Deallocator doesn't match the allocator: 'SecKeychainItemFreeContent' should be used}}
+}
+
+// Typesdefs for CFStringCreateWithBytesNoCopy.
+typedef char uint8_t;
+typedef signed long CFIndex;
+typedef UInt32 CFStringEncoding;
+typedef unsigned Boolean;
+typedef const struct __CFString * CFStringRef;
+typedef const struct __CFAllocator * CFAllocatorRef;
+extern const CFAllocatorRef kCFAllocatorDefault;
+extern const CFAllocatorRef kCFAllocatorSystemDefault;
+extern const CFAllocatorRef kCFAllocatorMalloc;
+extern const CFAllocatorRef kCFAllocatorMallocZone;
+extern const CFAllocatorRef kCFAllocatorNull;
+extern const CFAllocatorRef kCFAllocatorUseContext;
+CFStringRef CFStringCreateWithBytesNoCopy(CFAllocatorRef alloc, const uint8_t *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean externalFormat, CFAllocatorRef contentsDeallocator);
+extern void CFRelease(CFStringRef cf);
+
+void DellocWithCFStringCreate1(CFAllocatorRef alloc) {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 length;
+ void *bytes;
+ char * x;
+ st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &bytes);
+ if (st == noErr) {
+ CFStringRef userStr = CFStringCreateWithBytesNoCopy(alloc, bytes, length, 5, 0, kCFAllocatorDefault); // expected-warning{{Deallocator doesn't match the allocator:}}
+ CFRelease(userStr);
+ }
+}
+
+void DellocWithCFStringCreate2(CFAllocatorRef alloc) {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 length;
+ void *bytes;
+ char * x;
+ st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &bytes);
+ if (st == noErr) {
+ CFStringRef userStr = CFStringCreateWithBytesNoCopy(alloc, bytes, length, 5, 0, kCFAllocatorNull); // expected-warning{{Allocated data is not released}}
+ CFRelease(userStr);
+ }
+}
+
+void DellocWithCFStringCreate3(CFAllocatorRef alloc) {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 length;
+ void *bytes;
+ char * x;
+ st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &bytes);
+ if (st == noErr) {
+ CFStringRef userStr = CFStringCreateWithBytesNoCopy(alloc, bytes, length, 5, 0, kCFAllocatorUseContext);
+ CFRelease(userStr);
+ }
+}
+
+void DellocWithCFStringCreate4(CFAllocatorRef alloc) {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 length;
+ void *bytes;
+ char * x;
+ st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &bytes);
+ if (st == noErr) {
+ CFStringRef userStr = CFStringCreateWithBytesNoCopy(alloc, bytes, length, 5, 0, 0); // expected-warning{{Deallocator doesn't match the allocator:}}
+ CFRelease(userStr);
+ }
+}
+
+void radar10508828() {
+ UInt32 pwdLen = 0;
+ void* pwdBytes = 0;
+ OSStatus rc = SecKeychainFindGenericPassword(0, 3, "foo", 3, "bar", &pwdLen, &pwdBytes, 0);
+#pragma unused(rc)
+ if (pwdBytes)
+ SecKeychainItemFreeContent(0, pwdBytes);
+}
+
+void radar10508828_2() {
+ UInt32 pwdLen = 0;
+ void* pwdBytes = 0;
+ OSStatus rc = SecKeychainFindGenericPassword(0, 3, "foo", 3, "bar", &pwdLen, &pwdBytes, 0);
+ SecKeychainItemFreeContent(0, pwdBytes); // expected-warning {{Only call free if a valid (non-NULL) buffer was returned.}}
+}
+
+//Example from bug 10797.
+__inline__ static
+const char *__WBASLLevelString(int level) {
+ return "foo";
+}
+
+static int *bug10798(int *p, int columns, int prevRow) {
+ int *row = 0;
+ row = p + prevRow * columns;
+ prevRow += 2;
+ do {
+ ++prevRow;
+ row+=columns;
+ } while(10 >= row[1]);
+ return row;
+}
+
+// Test inter-procedural behaviour.
+
+void my_FreeParam(void *attrList, void* X) {
+ SecKeychainItemFreeContent(attrList, X);
+}
+
+void *my_AllocateReturn(OSStatus *st) {
+ unsigned int *ptr = 0;
+ UInt32 length;
+ void *outData;
+ *st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData);
+ return outData;
+}
+
+OSStatus my_Allocate_Param(void** password, UInt32* passwordLength) {
+ OSStatus err;
+ SecKeychainItemRef item;
+ err = SecKeychainFindGenericPassword(0, 3, "xx", 3, "xx",
+ passwordLength, password, &item);
+ return err;
+}
+
+void allocAndFree1() {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 length;
+ void *outData;
+ st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData);
+ if (st == noErr)
+ my_FreeParam(ptr, outData);
+}
+
+void consumeChar(char);
+
+void allocNoFree2(int x) {
+ OSStatus st = 0;
+ void *outData = my_AllocateReturn(&st);
+ if (x) {
+ consumeChar(*(char*)outData); // expected-warning{{Allocated data is not released:}}
+ return;
+ } else {
+ consumeChar(*(char*)outData);
+ }
+ return;
+}
+
+void allocAndFree2(void *attrList) {
+ OSStatus st = 0;
+ void *outData = my_AllocateReturn(&st);
+ if (st == noErr)
+ my_FreeParam(attrList, outData);
+}
+
+void allocNoFree3() {
+ UInt32 length = 32;
+ void *outData;
+ void *outData2;
+ OSStatus st = my_Allocate_Param(&outData, &length); // expected-warning{{Allocated data is not released}}
+ st = my_Allocate_Param(&outData2, &length); // expected-warning{{Allocated data is not released}}
+}
+
+void allocAndFree3(void *attrList) {
+ UInt32 length = 32;
+ void *outData;
+ OSStatus st = my_Allocate_Param(&outData, &length);
+ if (st == noErr)
+ SecKeychainItemFreeContent(attrList, outData);
+}
+
diff --git a/clang/test/Analysis/lambdas.cpp b/clang/test/Analysis/lambdas.cpp
new file mode 100644
index 0000000..77b36c4
--- /dev/null
+++ b/clang/test/Analysis/lambdas.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -analyze -analyzer-checker=debug.DumpCFG %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+struct X { X(const X&); };
+void f(X x) { (void) [x]{}; }
+
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: x
+// CHECK: 2: [B1.1] (ImplicitCastExpr, NoOp, const struct X)
+// CHECK: 3: [B1.2] (CXXConstructExpr, struct X)
+// CHECK: 4: [=x] {
+// CHECK: }
+// CHECK: 5: (void)[B1.4] (CStyleCastExpr, ToVoid, void)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+
diff --git a/clang/test/Analysis/lvalue.cpp b/clang/test/Analysis/lvalue.cpp
new file mode 100644
index 0000000..0cc42f5
--- /dev/null
+++ b/clang/test/Analysis/lvalue.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify %s
+
+int f1() {
+ int x = 0, y = 1;
+ return x += y; // Should bind a location to 'x += y'. No crash.
+}
diff --git a/clang/test/Analysis/malloc-annotations.c b/clang/test/Analysis/malloc-annotations.c
new file mode 100644
index 0000000..a0c1452
--- /dev/null
+++ b/clang/test/Analysis/malloc-annotations.c
@@ -0,0 +1,271 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,experimental.unix.MallocWithAnnotations -analyzer-store=region -verify %s
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+void *realloc(void *ptr, size_t size);
+void *calloc(size_t nmemb, size_t size);
+void __attribute((ownership_returns(malloc))) *my_malloc(size_t);
+void __attribute((ownership_takes(malloc, 1))) my_free(void *);
+void my_freeBoth(void *, void *)
+ __attribute((ownership_holds(malloc, 1, 2)));
+void __attribute((ownership_returns(malloc, 1))) *my_malloc2(size_t);
+void __attribute((ownership_holds(malloc, 1))) my_hold(void *);
+
+// Duplicate attributes are silly, but not an error.
+// Duplicate attribute has no extra effect.
+// If two are of different kinds, that is an error and reported as such.
+void __attribute((ownership_holds(malloc, 1)))
+__attribute((ownership_holds(malloc, 1)))
+__attribute((ownership_holds(malloc, 3))) my_hold2(void *, void *, void *);
+void *my_malloc3(size_t);
+void *myglobalpointer;
+struct stuff {
+ void *somefield;
+};
+struct stuff myglobalstuff;
+
+void f1() {
+ int *p = malloc(12);
+ return; // expected-warning{{Memory is never released; potential leak}}
+}
+
+void f2() {
+ int *p = malloc(12);
+ free(p);
+ free(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void f2_realloc_0() {
+ int *p = malloc(12);
+ realloc(p,0);
+ realloc(p,0); // expected-warning{{Attempt to free released memory}}
+}
+
+void f2_realloc_1() {
+ int *p = malloc(12);
+ int *q = realloc(p,0); // no-warning
+}
+
+// ownership attributes tests
+void naf1() {
+ int *p = my_malloc3(12);
+ return; // no-warning
+}
+
+void n2af1() {
+ int *p = my_malloc2(12);
+ return; // expected-warning{{Memory is never released; potential leak}}
+}
+
+void af1() {
+ int *p = my_malloc(12);
+ return; // expected-warning{{Memory is never released; potential leak}}
+}
+
+void af1_b() {
+ int *p = my_malloc(12); // expected-warning{{Memory is never released; potential leak}}
+}
+
+void af1_c() {
+ myglobalpointer = my_malloc(12); // no-warning
+}
+
+// TODO: We will be able to handle this after we add support for tracking allocations stored in struct fields.
+void af1_d() {
+ struct stuff mystuff;
+ mystuff.somefield = my_malloc(12); // false negative
+}
+
+// Test that we can pass out allocated memory via pointer-to-pointer.
+void af1_e(void **pp) {
+ *pp = my_malloc(42); // no-warning
+}
+
+void af1_f(struct stuff *somestuff) {
+ somestuff->somefield = my_malloc(12); // no-warning
+}
+
+// Allocating memory for a field via multiple indirections to our arguments is OK.
+void af1_g(struct stuff **pps) {
+ *pps = my_malloc(sizeof(struct stuff)); // no-warning
+ (*pps)->somefield = my_malloc(42); // no-warning
+}
+
+void af2() {
+ int *p = my_malloc(12);
+ my_free(p);
+ free(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void af2b() {
+ int *p = my_malloc(12);
+ free(p);
+ my_free(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void af2c() {
+ int *p = my_malloc(12);
+ free(p);
+ my_hold(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void af2d() {
+ int *p = my_malloc(12);
+ free(p);
+ my_hold2(0, 0, p); // expected-warning{{Attempt to free released memory}}
+}
+
+// No leak if malloc returns null.
+void af2e() {
+ int *p = my_malloc(12);
+ if (!p)
+ return; // no-warning
+ free(p); // no-warning
+}
+
+// This case would inflict a double-free elsewhere.
+// However, this case is considered an analyzer bug since it causes false-positives.
+void af3() {
+ int *p = my_malloc(12);
+ my_hold(p);
+ free(p); // no-warning
+}
+
+int * af4() {
+ int *p = my_malloc(12);
+ my_free(p);
+ return p; // expected-warning{{Use of memory after it is freed}}
+}
+
+// This case is (possibly) ok, be conservative
+int * af5() {
+ int *p = my_malloc(12);
+ my_hold(p);
+ return p; // no-warning
+}
+
+
+
+// This case tests that storing malloc'ed memory to a static variable which is
+// then returned is not leaked. In the absence of known contracts for functions
+// or inter-procedural analysis, this is a conservative answer.
+int *f3() {
+ static int *p = 0;
+ p = malloc(12);
+ return p; // no-warning
+}
+
+// This case tests that storing malloc'ed memory to a static global variable
+// which is then returned is not leaked. In the absence of known contracts for
+// functions or inter-procedural analysis, this is a conservative answer.
+static int *p_f4 = 0;
+int *f4() {
+ p_f4 = malloc(12);
+ return p_f4; // no-warning
+}
+
+int *f5() {
+ int *q = malloc(12);
+ q = realloc(q, 20);
+ return q; // no-warning
+}
+
+void f6() {
+ int *p = malloc(12);
+ if (!p)
+ return; // no-warning
+ else
+ free(p);
+}
+
+void f6_realloc() {
+ int *p = malloc(12);
+ if (!p)
+ return; // no-warning
+ else
+ realloc(p,0);
+}
+
+
+char *doit2();
+void pr6069() {
+ char *buf = doit2();
+ free(buf);
+}
+
+void pr6293() {
+ free(0);
+}
+
+void f7() {
+ char *x = (char*) malloc(4);
+ free(x);
+ x[0] = 'a'; // expected-warning{{Use of memory after it is freed}}
+}
+
+void f7_realloc() {
+ char *x = (char*) malloc(4);
+ realloc(x,0);
+ x[0] = 'a'; // expected-warning{{Use of memory after it is freed}}
+}
+
+void PR6123() {
+ int *x = malloc(11); // expected-warning{{Cast a region whose size is not a multiple of the destination type size.}}
+}
+
+void PR7217() {
+ int *buf = malloc(2); // expected-warning{{Cast a region whose size is not a multiple of the destination type size.}}
+ buf[1] = 'c'; // not crash
+}
+
+void mallocCastToVoid() {
+ void *p = malloc(2);
+ const void *cp = p; // not crash
+ free(p);
+}
+
+void mallocCastToFP() {
+ void *p = malloc(2);
+ void (*fp)() = p; // not crash
+ free(p);
+}
+
+// This tests that malloc() buffers are undefined by default
+char mallocGarbage () {
+ char *buf = malloc(2);
+ char result = buf[1]; // expected-warning{{undefined}}
+ free(buf);
+ return result;
+}
+
+// This tests that calloc() buffers need to be freed
+void callocNoFree () {
+ char *buf = calloc(2,2);
+ return; // expected-warning{{never released}}
+}
+
+// These test that calloc() buffers are zeroed by default
+char callocZeroesGood () {
+ char *buf = calloc(2,2);
+ char result = buf[3]; // no-warning
+ if (buf[1] == 0) {
+ free(buf);
+ }
+ return result; // no-warning
+}
+
+char callocZeroesBad () {
+ char *buf = calloc(2,2);
+ char result = buf[3]; // no-warning
+ if (buf[1] != 0) {
+ free(buf); // expected-warning{{never executed}}
+ }
+ return result; // expected-warning{{never released}}
+}
+
+void testMultipleFreeAnnotations() {
+ int *p = malloc(12);
+ int *q = malloc(12);
+ my_freeBoth(p, q);
+}
+
diff --git a/clang/test/Analysis/malloc-interprocedural.c b/clang/test/Analysis/malloc-interprocedural.c
new file mode 100644
index 0000000..589bc4f
--- /dev/null
+++ b/clang/test/Analysis/malloc-interprocedural.c
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.Malloc -analyzer-ipa=inlining -analyzer-inline-max-stack-depth=5 -analyzer-inline-max-function-size=6 -analyzer-store=region -verify %s
+
+#include "system-header-simulator.h"
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void *valloc(size_t);
+void free(void *);
+void *realloc(void *ptr, size_t size);
+void *reallocf(void *ptr, size_t size);
+void *calloc(size_t nmemb, size_t size);
+extern void exit(int) __attribute__ ((__noreturn__));
+
+static void my_malloc1(void **d, size_t size) {
+ *d = malloc(size);
+}
+
+static void *my_malloc2(int elevel, size_t size) {
+ void *data;
+ data = malloc(size);
+ if (data == 0)
+ exit(0);
+ return data;
+}
+
+static void my_free1(void *p) {
+ free(p);
+}
+
+static void test1() {
+ void *data = 0;
+ my_malloc1(&data, 4); // expected-warning {{Memory is never released; potential leak of memory pointed to by 'data'}}
+}
+
+static void test11() {
+ void *data = 0;
+ my_malloc1(&data, 4);
+ my_free1(data);
+}
+
+static void testUniqueingByallocationSiteInTopLevelFunction() {
+ void *data = my_malloc2(1, 4);
+ data = 0;
+ int x = 5;// expected-warning {{Memory is never released; potential leak of memory pointed to by 'data'}}
+ data = my_malloc2(1, 4);// expected-warning {{Memory is never released; potential leak of memory pointed to by 'data'}}
+}
+
+static void test3() {
+ void *data = my_malloc2(1, 4);
+ free(data);
+ data = my_malloc2(1, 4);
+ free(data);
+}
+
+int test4() {
+ int *data = (int*)my_malloc2(1, 4);
+ my_free1(data);
+ data = (int *)my_malloc2(1, 4);
+ my_free1(data);
+ return *data; // expected-warning {{Use of memory after it is freed}}
+}
+
+void test6() {
+ int *data = (int *)my_malloc2(1, 4);
+ my_free1((int*)data);
+ my_free1((int*)data); // expected-warning{{Use of memory after it is freed}}
+}
+
+// TODO: We should warn here.
+void test5() {
+ int *data;
+ my_free1((int*)data);
+}
+
+static char *reshape(char *in) {
+ return 0;
+}
+
+void testThatRemoveDeadBindingsRunBeforeEachCall() {
+ char *v = malloc(12);
+ v = reshape(v);
+ v = reshape(v);// expected-warning {{Memory is never released; potential leak of memory pointed to by 'v'}}
+}
+
+// Test that we keep processing after 'return;'
+void fooWithEmptyReturn(int x) {
+ if (x)
+ return;
+ x++;
+ return;
+}
+
+int uafAndCallsFooWithEmptyReturn() {
+ int *x = (int*)malloc(12);
+ free(x);
+ fooWithEmptyReturn(12);
+ return *x; // expected-warning {{Use of memory after it is freed}}
+}
diff --git a/clang/test/Analysis/malloc-overflow.c b/clang/test/Analysis/malloc-overflow.c
new file mode 100644
index 0000000..714fd3d
--- /dev/null
+++ b/clang/test/Analysis/malloc-overflow.c
@@ -0,0 +1,113 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.MallocOverflow -verify %s
+
+#define NULL ((void *) 0)
+typedef __typeof__(sizeof(int)) size_t;
+extern void * malloc(size_t);
+
+void * f1(int n)
+{
+ return malloc(n * sizeof(int)); // expected-warning {{the computation of the size of the memory allocation may overflow}}
+}
+
+void * f2(int n)
+{
+ return malloc(sizeof(int) * n); // // expected-warning {{the computation of the size of the memory allocation may overflow}}
+}
+
+void * f3()
+{
+ return malloc(4 * sizeof(int)); // no-warning
+}
+
+struct s4
+{
+ int n;
+};
+
+void * f4(struct s4 *s)
+{
+ return malloc(s->n * sizeof(int)); // expected-warning {{the computation of the size of the memory allocation may overflow}}
+}
+
+void * f5(struct s4 *s)
+{
+ struct s4 s2 = *s;
+ return malloc(s2.n * sizeof(int)); // expected-warning {{the computation of the size of the memory allocation may overflow}}
+}
+
+void * f6(int n)
+{
+ return malloc((n + 1) * sizeof(int)); // expected-warning {{the computation of the size of the memory allocation may overflow}}
+}
+
+extern void * malloc (size_t);
+
+void * f7(int n)
+{
+ if (n > 10)
+ return NULL;
+ return malloc(n * sizeof(int)); // no-warning
+}
+
+void * f8(int n)
+{
+ if (n < 10)
+ return malloc(n * sizeof(int)); // no-warning
+ else
+ return NULL;
+}
+
+void * f9(int n)
+{
+ int * x = malloc(n * sizeof(int)); // expected-warning {{the computation of the size of the memory allocation may overflow}}
+ for (int i = 0; i < n; i++)
+ x[i] = i;
+ return x;
+}
+
+void * f10(int n)
+{
+ int * x = malloc(n * sizeof(int)); // expected-warning {{the computation of the size of the memory allocation may overflow}}
+ int i = 0;
+ while (i < n)
+ x[i++] = 0;
+ return x;
+}
+
+void * f11(int n)
+{
+ int * x = malloc(n * sizeof(int)); // expected-warning {{the computation of the size of the memory allocation may overflow}}
+ int i = 0;
+ do {
+ x[i++] = 0;
+ } while (i < n);
+ return x;
+}
+
+void * f12(int n)
+{
+ n = (n > 10 ? 10 : n);
+ int * x = malloc(n * sizeof(int)); // no-warning
+ for (int i = 0; i < n; i++)
+ x[i] = i;
+ return x;
+}
+
+struct s13
+{
+ int n;
+};
+
+void * f13(struct s13 *s)
+{
+ if (s->n > 10)
+ return NULL;
+ return malloc(s->n * sizeof(int)); // no warning
+}
+
+void * f14(int n)
+{
+ if (n < 0)
+ return NULL;
+ return malloc(n * sizeof(int)); // expected-warning {{the computation of the size of the memory allocation may overflow}}
+}
diff --git a/clang/test/Analysis/malloc-overflow.cpp b/clang/test/Analysis/malloc-overflow.cpp
new file mode 100644
index 0000000..c1ac6be
--- /dev/null
+++ b/clang/test/Analysis/malloc-overflow.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.MallocOverflow -verify %s
+
+class A {
+public:
+ A& operator<<(const A &a);
+};
+
+void f() {
+ A a = A(), b = A();
+ a << b;
+}
diff --git a/clang/test/Analysis/malloc-plist.c b/clang/test/Analysis/malloc-plist.c
new file mode 100644
index 0000000..db2e0f0
--- /dev/null
+++ b/clang/test/Analysis/malloc-plist.c
@@ -0,0 +1,2814 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.Malloc -analyzer-output=plist -o %t %s
+// RUN: FileCheck --input-file %t %s
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+void *realloc(void *ptr, size_t size);
+
+void diagnosticTest(int in) {
+ if (in > 5) {
+ int *p = malloc(12);
+ (*p)++;
+ }
+ in++; // expected-warning {{leak}}
+}
+
+void myArrayAllocation() {
+ int **A;
+ A = malloc(2*sizeof(int*));
+ A[0] = 0;// expected-warning {{leak}}
+}
+
+void reallocDiagnostics() {
+ char * buf = malloc(100);
+ char * tmp;
+ tmp = (char*)realloc(buf, 0x1000000);
+ if (!tmp) {
+ return;// expected-warning {{leak}}
+ }
+ buf = tmp;
+ free(buf);
+}
+
+void *wrapper() {
+ void *x = malloc(100);
+ // This is intentionally done to test diagnostic emission.
+ if (x)
+ return x;
+ return 0;
+}
+
+void test_wrapper() {
+ void *buf = wrapper();
+ (void) buf;
+}
+
+// Test what happens when the same call frees and allocated memory.
+// Also tests the stack hint for parameters, when they are passed directly or via pointer.
+void my_free(void *x) {
+ free(x);
+}
+void my_malloc_and_free(void **x) {
+ *x = malloc(100);
+ if (*x)
+ my_free(*x);
+ return;
+}
+void *test_double_action_call() {
+ void *buf;
+ my_malloc_and_free(&buf);
+ return buf;
+}
+
+// Test stack hint for 'reallocation failed'.
+char *my_realloc(char *buf) {
+ char *tmp;
+ tmp = (char*)realloc(buf, 0x1000000);
+ if (!tmp) {
+ return tmp;
+ }
+ return tmp;
+}
+void reallocIntra() {
+ char *buf = (char *)malloc(100);
+ buf = my_realloc(buf);
+ free(buf);
+}
+
+// Test stack hint when returning a result.
+static char *malloc_wrapper_ret() {
+ return (char*)malloc(12);
+}
+void use_ret() {
+ char *v;
+ v = malloc_wrapper_ret();
+}
+
+// Test that we refer to the last symbol used in the leak diagnostic.
+void LeakedSymbol(int in) {
+ int *m = 0;
+ int *p;
+ p = (int*)malloc(12);
+ (*p)++;
+ m = p;
+ p = 0;
+ (*m)++;
+ in++;
+}
+
+// CHECK: <?xml version="1.0" encoding="UTF-8"?>
+// 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>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>27</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>18</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>11</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>27</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>27</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</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>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;p&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;p&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;p&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>diagnosticTest</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>30</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>9</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>19</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>30</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>30</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>21</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>21</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>21</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;A&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;A&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;A&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>myArrayAllocation</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>21</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>18</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>24</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>18</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>26</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Attempt to reallocate memory</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Attempt to reallocate memory</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>9</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>27</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;tmp&apos; is null</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;tmp&apos; is null</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</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>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Reallocation failed</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Reallocation failed</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>9</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>28</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>reallocDiagnostics</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</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>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;wrapper&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;wrapper&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>34</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;test_wrapper&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;test_wrapper&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>34</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>34</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>13</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>35</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</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>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;x&apos; is non-null</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;x&apos; is non-null</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>38</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>38</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</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>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Returned allocated memory</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Returned allocated memory</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>45</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>45</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>45</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_wrapper</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>45</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</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>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;my_malloc_and_free&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;my_malloc_and_free&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>52</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;test_double_action_call&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;test_double_action_call&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>52</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>52</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>20</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>10</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>53</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>20</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>20</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</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>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>17</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;my_free&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;my_free&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>49</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>2</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;my_malloc_and_free&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;my_malloc_and_free&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>49</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>49</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>5</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>50</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>2</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is released</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is released</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</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>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>17</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>2</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Returned released memory via 1st parameter</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Returned released memory via 1st parameter</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>17</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</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>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Returned released memory via 1st parameter</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Returned released memory via 1st parameter</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>5</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>61</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Use of memory after it is freed</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Use of memory after it is freed</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Use of memory after it is freed</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Use-after-free</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_double_action_call</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>35</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>25</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>74</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>35</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>35</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</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>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;my_realloc&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;my_realloc&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>65</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;reallocIntra&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;reallocIntra&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>65</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>65</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>66</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>66</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>66</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>66</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>18</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>67</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Attempt to reallocate memory</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Attempt to reallocate memory</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>9</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>68</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;tmp&apos; is null</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;tmp&apos; is null</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</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>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Reallocation failed</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Reallocation failed</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>69</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>69</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</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>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Reallocation of 1st parameter failed</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Reallocation of 1st parameter failed</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>5</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>76</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>reallocIntra</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>84</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>84</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</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>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;malloc_wrapper_ret&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;malloc_wrapper_ret&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>80</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;use_ret&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;use_ret&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>80</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>80</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>19</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>19</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>81</integer>
+// CHECK: <key>col</key><integer>19</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</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>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Returned allocated memory</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Returned allocated memory</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>86</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>86</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>86</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;v&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;v&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;v&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>use_ret</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>86</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>90</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>90</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>24</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>15</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>92</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>24</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>24</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>5</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>97</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;m&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;m&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;m&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>LeakedSymbol</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </plist>
+
diff --git a/clang/test/Analysis/malloc-sizeof.c b/clang/test/Analysis/malloc-sizeof.c
new file mode 100644
index 0000000..d2b3bcf
--- /dev/null
+++ b/clang/test/Analysis/malloc-sizeof.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.unix.MallocSizeof -verify %s
+
+#include <stddef.h>
+
+void *malloc(size_t size);
+void *calloc(size_t nmemb, size_t size);
+void *realloc(void *ptr, size_t size);
+
+struct A {};
+struct B {};
+
+void foo() {
+ int *ip1 = malloc(sizeof(1));
+ int *ip2 = malloc(4 * sizeof(int));
+
+ long *lp1 = malloc(sizeof(short)); // expected-warning {{Result of 'malloc' is converted to type 'long *', whose pointee type 'long' is incompatible with sizeof operand type 'short'}}
+ long *lp2 = malloc(5 * sizeof(double)); // expected-warning {{Result of 'malloc' is converted to type 'long *', whose pointee type 'long' is incompatible with sizeof operand type 'double'}}
+ long *lp3 = malloc(5 * sizeof(char) + 2); // expected-warning {{Result of 'malloc' is converted to type 'long *', whose pointee type 'long' is incompatible with sizeof operand type 'char'}}
+
+ struct A *ap1 = calloc(1, sizeof(struct A));
+ struct A *ap2 = calloc(2, sizeof(*ap1));
+ struct A *ap3 = calloc(2, sizeof(ap1)); // expected-warning {{Result of 'calloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct A *'}}
+ struct A *ap4 = calloc(3, sizeof(struct A*)); // expected-warning {{Result of 'calloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct A *'}}
+ struct A *ap5 = calloc(4, sizeof(struct B)); // expected-warning {{Result of 'calloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct B'}}
+ struct A *ap6 = realloc(ap5, sizeof(struct A));
+ struct A *ap7 = realloc(ap5, sizeof(struct B)); // expected-warning {{Result of 'realloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct B'}}
+}
diff --git a/clang/test/Analysis/malloc.c b/clang/test/Analysis/malloc.c
new file mode 100644
index 0000000..3b47123
--- /dev/null
+++ b/clang/test/Analysis/malloc.c
@@ -0,0 +1,809 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,unix.Malloc -analyzer-store=region -verify %s
+#include "system-header-simulator.h"
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void *valloc(size_t);
+void free(void *);
+void *realloc(void *ptr, size_t size);
+void *reallocf(void *ptr, size_t size);
+void *calloc(size_t nmemb, size_t size);
+
+void myfoo(int *p);
+void myfooint(int p);
+char *fooRetPtr();
+
+void f1() {
+ int *p = malloc(12);
+ return; // expected-warning{{Memory is never released; potential leak}}
+}
+
+void f2() {
+ int *p = malloc(12);
+ free(p);
+ free(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void f2_realloc_0() {
+ int *p = malloc(12);
+ realloc(p,0);
+ realloc(p,0); // expected-warning{{Attempt to free released memory}}
+}
+
+void f2_realloc_1() {
+ int *p = malloc(12);
+ int *q = realloc(p,0); // no-warning
+}
+
+void reallocNotNullPtr(unsigned sizeIn) {
+ unsigned size = 12;
+ char *p = (char*)malloc(size);
+ if (p) {
+ char *q = (char*)realloc(p, sizeIn);
+ char x = *q; // expected-warning {{Memory is never released; potential leak}}
+ }
+}
+
+int *realloctest1() {
+ int *q = malloc(12);
+ q = realloc(q, 20);
+ return q; // no warning - returning the allocated value
+}
+
+// p should be freed if realloc fails.
+void reallocFails() {
+ char *p = malloc(12);
+ char *r = realloc(p, 12+1);
+ if (!r) {
+ free(p);
+ } else {
+ free(r);
+ }
+}
+
+void reallocSizeZero1() {
+ char *p = malloc(12);
+ char *r = realloc(p, 0);
+ if (!r) {
+ free(p);
+ } else {
+ free(r);
+ }
+}
+
+void reallocSizeZero2() {
+ char *p = malloc(12);
+ char *r = realloc(p, 0);
+ if (!r) {
+ free(p);
+ } else {
+ free(r);
+ }
+ free(p); // expected-warning {{Attempt to free released memory}}
+}
+
+void reallocSizeZero3() {
+ char *p = malloc(12);
+ char *r = realloc(p, 0);
+ free(r);
+}
+
+void reallocSizeZero4() {
+ char *r = realloc(0, 0);
+ free(r);
+}
+
+void reallocSizeZero5() {
+ char *r = realloc(0, 0);
+}
+
+void reallocPtrZero1() {
+ char *r = realloc(0, 12); // expected-warning {{Memory is never released; potential leak}}
+}
+
+void reallocPtrZero2() {
+ char *r = realloc(0, 12);
+ if (r)
+ free(r);
+}
+
+void reallocPtrZero3() {
+ char *r = realloc(0, 12);
+ free(r);
+}
+
+void reallocRadar6337483_1() {
+ char *buf = malloc(100);
+ buf = (char*)realloc(buf, 0x1000000);
+ if (!buf) {
+ return;// expected-warning {{Memory is never released; potential leak}}
+ }
+ free(buf);
+}
+
+void reallocRadar6337483_2() {
+ char *buf = malloc(100);
+ char *buf2 = (char*)realloc(buf, 0x1000000);
+ if (!buf2) { // expected-warning {{Memory is never released; potential leak}}
+ ;
+ } else {
+ free(buf2);
+ }
+}
+
+void reallocRadar6337483_3() {
+ char * buf = malloc(100);
+ char * tmp;
+ tmp = (char*)realloc(buf, 0x1000000);
+ if (!tmp) {
+ free(buf);
+ return;
+ }
+ buf = tmp;
+ free(buf);
+}
+
+void reallocRadar6337483_4() {
+ char *buf = malloc(100);
+ char *buf2 = (char*)realloc(buf, 0x1000000);
+ if (!buf2) {
+ return; // expected-warning {{Memory is never released; potential leak}}
+ } else {
+ free(buf2);
+ }
+}
+
+int *reallocfTest1() {
+ int *q = malloc(12);
+ q = reallocf(q, 20);
+ return q; // no warning - returning the allocated value
+}
+
+void reallocfRadar6337483_4() {
+ char *buf = malloc(100);
+ char *buf2 = (char*)reallocf(buf, 0x1000000);
+ if (!buf2) {
+ return; // no warning - reallocf frees even on failure
+ } else {
+ free(buf2);
+ }
+}
+
+void reallocfRadar6337483_3() {
+ char * buf = malloc(100);
+ char * tmp;
+ tmp = (char*)reallocf(buf, 0x1000000);
+ if (!tmp) {
+ free(buf); // expected-warning {{Attempt to free released memory}}
+ return;
+ }
+ buf = tmp;
+ free(buf);
+}
+
+void reallocfPtrZero1() {
+ char *r = reallocf(0, 12); // expected-warning {{Memory is never released; potential leak}}
+}
+
+
+// This case tests that storing malloc'ed memory to a static variable which is
+// then returned is not leaked. In the absence of known contracts for functions
+// or inter-procedural analysis, this is a conservative answer.
+int *f3() {
+ static int *p = 0;
+ p = malloc(12);
+ return p; // no-warning
+}
+
+// This case tests that storing malloc'ed memory to a static global variable
+// which is then returned is not leaked. In the absence of known contracts for
+// functions or inter-procedural analysis, this is a conservative answer.
+static int *p_f4 = 0;
+int *f4() {
+ p_f4 = malloc(12);
+ return p_f4; // no-warning
+}
+
+int *f5() {
+ int *q = malloc(12);
+ q = realloc(q, 20);
+ return q; // no-warning
+}
+
+void f6() {
+ int *p = malloc(12);
+ if (!p)
+ return; // no-warning
+ else
+ free(p);
+}
+
+void f6_realloc() {
+ int *p = malloc(12);
+ if (!p)
+ return; // no-warning
+ else
+ realloc(p,0);
+}
+
+
+char *doit2();
+void pr6069() {
+ char *buf = doit2();
+ free(buf);
+}
+
+void pr6293() {
+ free(0);
+}
+
+void f7() {
+ char *x = (char*) malloc(4);
+ free(x);
+ x[0] = 'a'; // expected-warning{{Use of memory after it is freed}}
+}
+
+void f7_realloc() {
+ char *x = (char*) malloc(4);
+ realloc(x,0);
+ x[0] = 'a'; // expected-warning{{Use of memory after it is freed}}
+}
+
+void PR6123() {
+ int *x = malloc(11); // expected-warning{{Cast a region whose size is not a multiple of the destination type size.}}
+}
+
+void PR7217() {
+ int *buf = malloc(2); // expected-warning{{Cast a region whose size is not a multiple of the destination type size.}}
+ buf[1] = 'c'; // not crash
+}
+
+void mallocCastToVoid() {
+ void *p = malloc(2);
+ const void *cp = p; // not crash
+ free(p);
+}
+
+void mallocCastToFP() {
+ void *p = malloc(2);
+ void (*fp)() = p; // not crash
+ free(p);
+}
+
+// This tests that malloc() buffers are undefined by default
+char mallocGarbage () {
+ char *buf = malloc(2);
+ char result = buf[1]; // expected-warning{{undefined}}
+ free(buf);
+ return result;
+}
+
+// This tests that calloc() buffers need to be freed
+void callocNoFree () {
+ char *buf = calloc(2,2);
+ return; // expected-warning{{never released}}
+}
+
+// These test that calloc() buffers are zeroed by default
+char callocZeroesGood () {
+ char *buf = calloc(2,2);
+ char result = buf[3]; // no-warning
+ if (buf[1] == 0) {
+ free(buf);
+ }
+ return result; // no-warning
+}
+
+char callocZeroesBad () {
+ char *buf = calloc(2,2);
+ char result = buf[3]; // no-warning
+ if (buf[1] != 0) {
+ free(buf); // expected-warning{{never executed}}
+ }
+ return result; // expected-warning{{never released}}
+}
+
+void nullFree() {
+ int *p = 0;
+ free(p); // no warning - a nop
+}
+
+void paramFree(int *p) {
+ myfoo(p);
+ free(p); // no warning
+ myfoo(p); // TODO: This should be a warning.
+}
+
+int* mallocEscapeRet() {
+ int *p = malloc(12);
+ return p; // no warning
+}
+
+void mallocEscapeFoo() {
+ int *p = malloc(12);
+ myfoo(p);
+ return; // no warning
+}
+
+void mallocEscapeFree() {
+ int *p = malloc(12);
+ myfoo(p);
+ free(p);
+}
+
+void mallocEscapeFreeFree() {
+ int *p = malloc(12);
+ myfoo(p);
+ free(p);
+ free(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void mallocEscapeFreeUse() {
+ int *p = malloc(12);
+ myfoo(p);
+ free(p);
+ myfoo(p); // expected-warning{{Use of memory after it is freed}}
+}
+
+int *myalloc();
+void myalloc2(int **p);
+
+void mallocEscapeFreeCustomAlloc() {
+ int *p = malloc(12);
+ myfoo(p);
+ free(p);
+ p = myalloc();
+ free(p); // no warning
+}
+
+void mallocEscapeFreeCustomAlloc2() {
+ int *p = malloc(12);
+ myfoo(p);
+ free(p);
+ myalloc2(&p);
+ free(p); // no warning
+}
+
+void mallocBindFreeUse() {
+ int *x = malloc(12);
+ int *y = x;
+ free(y);
+ myfoo(x); // expected-warning{{Use of memory after it is freed}}
+}
+
+void mallocEscapeMalloc() {
+ int *p = malloc(12);
+ myfoo(p);
+ p = malloc(12); // expected-warning{{Memory is never released; potential leak}}
+}
+
+void mallocMalloc() {
+ int *p = malloc(12);
+ p = malloc(12); // expected-warning 2 {{Memory is never released; potential leak}}
+}
+
+void mallocFreeMalloc() {
+ int *p = malloc(12);
+ free(p);
+ p = malloc(12);
+ free(p);
+}
+
+void mallocFreeUse_params() {
+ int *p = malloc(12);
+ free(p);
+ myfoo(p); //expected-warning{{Use of memory after it is freed}}
+}
+
+void mallocFreeUse_params2() {
+ int *p = malloc(12);
+ free(p);
+ myfooint(*p); //expected-warning{{Use of memory after it is freed}}
+}
+
+void mallocFailedOrNot() {
+ int *p = malloc(12);
+ if (!p)
+ free(p);
+ else
+ free(p);
+}
+
+struct StructWithInt {
+ int g;
+};
+
+int *mallocReturnFreed() {
+ int *p = malloc(12);
+ free(p);
+ return p; // expected-warning {{Use of memory after it is freed}}
+}
+
+int useAfterFreeStruct() {
+ struct StructWithInt *px= malloc(sizeof(struct StructWithInt));
+ px->g = 5;
+ free(px);
+ return px->g; // expected-warning {{Use of memory after it is freed}}
+}
+
+void nonSymbolAsFirstArg(int *pp, struct StructWithInt *p);
+
+void mallocEscapeFooNonSymbolArg() {
+ struct StructWithInt *p = malloc(sizeof(struct StructWithInt));
+ nonSymbolAsFirstArg(&p->g, p);
+ return; // no warning
+}
+
+void mallocFailedOrNotLeak() {
+ int *p = malloc(12);
+ if (p == 0)
+ return; // no warning
+ else
+ return; // expected-warning {{Memory is never released; potential leak}}
+}
+
+void mallocAssignment() {
+ char *p = malloc(12);
+ p = fooRetPtr(); // expected-warning {{leak}}
+}
+
+int vallocTest() {
+ char *mem = valloc(12);
+ return 0; // expected-warning {{Memory is never released; potential leak}}
+}
+
+void vallocEscapeFreeUse() {
+ int *p = valloc(12);
+ myfoo(p);
+ free(p);
+ myfoo(p); // expected-warning{{Use of memory after it is freed}}
+}
+
+int *Gl;
+struct GlStTy {
+ int *x;
+};
+
+struct GlStTy GlS = {0};
+
+void GlobalFree() {
+ free(Gl);
+}
+
+void GlobalMalloc() {
+ Gl = malloc(12);
+}
+
+void GlobalStructMalloc() {
+ int *a = malloc(12);
+ GlS.x = a;
+}
+
+void GlobalStructMallocFree() {
+ int *a = malloc(12);
+ GlS.x = a;
+ free(GlS.x);
+}
+
+char *ArrayG[12];
+
+void globalArrayTest() {
+ char *p = (char*)malloc(12);
+ ArrayG[0] = p;
+}
+
+// Make sure that we properly handle a pointer stored into a local struct/array.
+typedef struct _StructWithPtr {
+ int *memP;
+} StructWithPtr;
+
+static StructWithPtr arrOfStructs[10];
+
+void testMalloc() {
+ int *x = malloc(12);
+ StructWithPtr St;
+ St.memP = x;
+ arrOfStructs[0] = St;
+}
+
+StructWithPtr testMalloc2() {
+ int *x = malloc(12);
+ StructWithPtr St;
+ St.memP = x;
+ return St;
+}
+
+int *testMalloc3() {
+ int *x = malloc(12);
+ int *y = x;
+ return y;
+}
+
+void testElemRegion1() {
+ char *x = (void*)malloc(2);
+ int *ix = (int*)x;
+ free(&(x[0]));
+}
+
+void testElemRegion2(int **pp) {
+ int *p = malloc(12);
+ *pp = p;
+ free(pp[0]);
+}
+
+void testElemRegion3(int **pp) {
+ int *p = malloc(12);
+ *pp = p;
+ free(*pp);
+}
+// Region escape testing.
+
+unsigned takePtrToPtr(int **p);
+void PassTheAddrOfAllocatedData(int f) {
+ int *p = malloc(12);
+ // We don't know what happens after the call. Should stop tracking here.
+ if (takePtrToPtr(&p))
+ f++;
+ free(p); // no warning
+}
+
+struct X {
+ int *p;
+};
+unsigned takePtrToStruct(struct X *s);
+int ** foo2(int *g, int f) {
+ int *p = malloc(12);
+ struct X *px= malloc(sizeof(struct X));
+ px->p = p;
+ // We don't know what happens after this call. Should not track px nor p.
+ if (takePtrToStruct(px))
+ f++;
+ free(p);
+ return 0;
+}
+
+struct X* RegInvalidationDetect1(struct X *s2) {
+ struct X *px= malloc(sizeof(struct X));
+ px->p = 0;
+ px = s2;
+ return px; // expected-warning {{Memory is never released; potential leak}}
+}
+
+struct X* RegInvalidationGiveUp1() {
+ int *p = malloc(12);
+ struct X *px= malloc(sizeof(struct X));
+ px->p = p;
+ return px;
+}
+
+int **RegInvalidationDetect2(int **pp) {
+ int *p = malloc(12);
+ pp = &p;
+ pp++;
+ return 0;// expected-warning {{Memory is never released; potential leak}}
+}
+
+extern void exit(int) __attribute__ ((__noreturn__));
+void mallocExit(int *g) {
+ struct xx *p = malloc(12);
+ if (g != 0)
+ exit(1);
+ free(p);
+ return;
+}
+
+extern void __assert_fail (__const char *__assertion, __const char *__file,
+ unsigned int __line, __const char *__function)
+ __attribute__ ((__noreturn__));
+#define assert(expr) \
+ ((expr) ? (void)(0) : __assert_fail (#expr, __FILE__, __LINE__, __func__))
+void mallocAssert(int *g) {
+ struct xx *p = malloc(12);
+
+ assert(g != 0);
+ free(p);
+ return;
+}
+
+void doNotInvalidateWhenPassedToSystemCalls(char *s) {
+ char *p = malloc(12);
+ strlen(p);
+ strcpy(p, s); // expected-warning {{leak}}
+}
+
+// Rely on the CString checker evaluation of the strcpy API to convey that the result of strcpy is equal to p.
+void symbolLostWithStrcpy(char *s) {
+ char *p = malloc(12);
+ p = strcpy(p, s);
+ free(p);
+}
+
+
+// The same test as the one above, but with what is actually generated on a mac.
+static __inline char *
+__inline_strcpy_chk (char *restrict __dest, const char *restrict __src)
+{
+ return __builtin___strcpy_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1));
+}
+
+void symbolLostWithStrcpy_InlineStrcpyVersion(char *s) {
+ char *p = malloc(12);
+ p = ((__builtin_object_size (p, 0) != (size_t) -1) ? __builtin___strcpy_chk (p, s, __builtin_object_size (p, 2 > 1)) : __inline_strcpy_chk (p, s));
+ free(p);
+}
+
+// Here we are returning a pointer one past the allocated value. An idiom which
+// can be used for implementing special malloc. The correct uses of this might
+// be rare enough so that we could keep this as a warning.
+static void *specialMalloc(int n){
+ int *p;
+ p = malloc( n+8 );
+ if( p ){
+ p[0] = n;
+ p++;
+ }
+ return p;
+}
+
+// Potentially, the user could free the struct by performing pointer arithmetic on the return value.
+// This is a variation of the specialMalloc issue, though probably would be more rare in correct code.
+int *specialMallocWithStruct() {
+ struct StructWithInt *px= malloc(sizeof(struct StructWithInt));
+ return &(px->g);
+}
+
+// Test various allocation/deallocation functions.
+
+char *strdup(const char *s);
+char *strndup(const char *s, size_t n);
+
+void testStrdup(const char *s, unsigned validIndex) {
+ char *s2 = strdup(s);
+ s2[validIndex + 1] = 'b';// expected-warning {{Memory is never released; potential leak}}
+}
+
+int testStrndup(const char *s, unsigned validIndex, unsigned size) {
+ char *s2 = strndup(s, size);
+ s2 [validIndex + 1] = 'b';
+ if (s2[validIndex] != 'a')
+ return 0;
+ else
+ return 1;// expected-warning {{Memory is never released; potential leak}}
+}
+
+void testStrdupContentIsDefined(const char *s, unsigned validIndex) {
+ char *s2 = strdup(s);
+ char result = s2[1];// no warning
+ free(s2);
+}
+
+// ----------------------------------------------------------------------------
+// Test the system library functions to which the pointer can escape.
+// This tests false positive suppression.
+
+// For now, we assume memory passed to pthread_specific escapes.
+// TODO: We could check that if a new pthread binding is set, the existing
+// binding must be freed; otherwise, a memory leak can occur.
+void testPthereadSpecificEscape(pthread_key_t key) {
+ void *buf = malloc(12);
+ pthread_setspecific(key, buf); // no warning
+}
+
+// PR12101: Test funopen().
+static int releasePtr(void *_ctx) {
+ free(_ctx);
+ return 0;
+}
+FILE *useFunOpen() {
+ void *ctx = malloc(sizeof(int));
+ FILE *f = funopen(ctx, 0, 0, 0, releasePtr); // no warning
+ if (f == 0) {
+ free(ctx);
+ }
+ return f;
+}
+FILE *useFunOpenNoReleaseFunction() {
+ void *ctx = malloc(sizeof(int));
+ FILE *f = funopen(ctx, 0, 0, 0, 0);
+ if (f == 0) {
+ free(ctx);
+ }
+ return f; // expected-warning{{leak}}
+}
+
+// Test setbuf, setvbuf.
+int my_main_no_warning() {
+ char *p = malloc(100);
+ setvbuf(stdout, p, 0, 100);
+ return 0;
+}
+int my_main_no_warning2() {
+ char *p = malloc(100);
+ setbuf(__stdoutp, p);
+ return 0;
+}
+int my_main_warn(FILE *f) {
+ char *p = malloc(100);
+ setvbuf(f, p, 0, 100);
+ return 0;// expected-warning {{leak}}
+}
+
+// <rdar://problem/10978247>.
+// some people use stack allocated memory as an optimization to avoid
+// a heap allocation for small work sizes. This tests the analyzer's
+// understanding that the malloc'ed memory is not the same as stackBuffer.
+void radar10978247(int myValueSize) {
+ char stackBuffer[128];
+ char *buffer;
+
+ if (myValueSize <= sizeof(stackBuffer))
+ buffer = stackBuffer;
+ else
+ buffer = malloc(myValueSize);
+
+ // do stuff with the buffer
+ if (buffer != stackBuffer)
+ free(buffer);
+}
+
+void radar10978247_positive(int myValueSize) {
+ char stackBuffer[128];
+ char *buffer;
+
+ if (myValueSize <= sizeof(stackBuffer))
+ buffer = stackBuffer;
+ else
+ buffer = malloc(myValueSize);
+
+ // do stuff with the buffer
+ if (buffer == stackBuffer) // expected-warning {{leak}}
+ return;
+}
+
+// ----------------------------------------------------------------------------
+// Below are the known false positives.
+
+// TODO: There should be no warning here. This one might be difficult to get rid of.
+void dependsOnValueOfPtr(int *g, unsigned f) {
+ int *p;
+
+ if (f) {
+ p = g;
+ } else {
+ p = malloc(12);
+ }
+
+ if (p != g)
+ free(p);
+ else
+ return; // expected-warning{{Memory is never released; potential leak}}
+ return;
+}
+
+// ----------------------------------------------------------------------------
+// False negatives.
+
+// TODO: This requires tracking symbols stored inside the structs/arrays.
+void testMalloc5() {
+ StructWithPtr St;
+ StructWithPtr *pSt = &St;
+ pSt->memP = malloc(12);
+}
+
+// TODO: This is another false negative.
+void testMallocWithParam(int **p) {
+ *p = (int*) malloc(sizeof(int));
+ *p = 0;
+}
+
+void testMallocWithParam_2(int **p) {
+ *p = (int*) malloc(sizeof(int));
+}
+
+// TODO: This should produce a warning, similar to the previous issue.
+void localArrayTest() {
+ char *p = (char*)malloc(12);
+ char *ArrayL[12];
+ ArrayL[0] = p;
+}
+
diff --git a/clang/test/Analysis/malloc.cpp b/clang/test/Analysis/malloc.cpp
new file mode 100644
index 0000000..8f80b2b
--- /dev/null
+++ b/clang/test/Analysis/malloc.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,unix.Malloc -analyzer-store=region -verify %s
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+void *realloc(void *ptr, size_t size);
+void *calloc(size_t nmemb, size_t size);
+
+// Test for radar://11110132.
+struct Foo {
+ mutable void* m_data;
+ Foo(void* data) : m_data(data) {}
+};
+Foo aFunction() {
+ return malloc(10);
+}
diff --git a/clang/test/Analysis/malloc.m b/clang/test/Analysis/malloc.m
new file mode 100644
index 0000000..6c94118
--- /dev/null
+++ b/clang/test/Analysis/malloc.m
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -Wno-objc-root-class %s
+#include "system-header-simulator-objc.h"
+
+@class NSString;
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+
+// RDar10579586 - Test use of malloc() with Objective-C string literal as a
+// test condition. Not really a malloc() issue, but this also exercises
+// the check that malloc() returns uninitialized memory.
+@interface RDar10579586
+struct rdar0579586_str {
+ char str_c;
+};
+@end
+
+void rdar10579586(char x);
+
+@implementation RDar10579586
++ (NSString *)foobar
+{
+ struct rdar0579586_str *buffer = ((void*)0);
+ NSString *error = ((void*)0);
+
+ if ((buffer = malloc(sizeof(struct rdar0579586_str))) == ((void*)0))
+ error = @"buffer allocation failure";
+
+ if (error != ((void*)0))
+ return error;
+
+ rdar10579586(buffer->str_c); // expected-warning {{Function call argument is an uninitialized value}}
+ free(buffer);
+ return ((void*)0);
+}
+@end
+
diff --git a/clang/test/Analysis/malloc.mm b/clang/test/Analysis/malloc.mm
new file mode 100644
index 0000000..3515a4f
--- /dev/null
+++ b/clang/test/Analysis/malloc.mm
@@ -0,0 +1,156 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -fblocks %s
+#include "system-header-simulator-objc.h"
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+
+// Done with headers. Start testing.
+void testNSDatafFreeWhenDoneNoError(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength];
+ free(data); // no warning
+}
+
+void testNSDataFreeWhenDoneYES(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength freeWhenDone:1]; // no-warning
+}
+
+void testNSDataFreeWhenDoneYES2(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [[NSData alloc] initWithBytesNoCopy:data length:dataLength freeWhenDone:1]; // no-warning
+}
+
+
+void testNSStringFreeWhenDoneYES(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSString *nsstr = [[NSString alloc] initWithBytesNoCopy:data length:dataLength encoding:NSUTF8StringEncoding freeWhenDone:1]; // no-warning
+}
+
+void testNSStringFreeWhenDoneYES2(NSUInteger dataLength) {
+ unichar *data = (unichar*)malloc(42);
+ NSString *nsstr = [[NSString alloc] initWithCharactersNoCopy:data length:dataLength freeWhenDone:1]; // no-warning
+}
+
+
+void testNSDataFreeWhenDoneNO(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+void testNSDataFreeWhenDoneNO2(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [[NSData alloc] initWithBytesNoCopy:data length:dataLength freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+
+void testNSStringFreeWhenDoneNO(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSString *nsstr = [[NSString alloc] initWithBytesNoCopy:data length:dataLength encoding:NSUTF8StringEncoding freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+void testNSStringFreeWhenDoneNO2(NSUInteger dataLength) {
+ unichar *data = (unichar*)malloc(42);
+ NSString *nsstr = [[NSString alloc] initWithCharactersNoCopy:data length:dataLength freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+// TODO: False Negative.
+void testNSDatafFreeWhenDoneFN(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength freeWhenDone:1];
+ free(data); // false negative
+}
+
+// Test CF/NS...NoCopy. PR12100: Pointers can escape when custom deallocators are provided.
+void testNSDatafFreeWhenDone(NSUInteger dataLength) {
+ CFStringRef str;
+ char *bytes = (char*)malloc(12);
+ str = CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0); // no warning
+ CFRelease(str); // default allocator also frees bytes
+}
+
+void stringWithExternalContentsExample(void) {
+#define BufferSize 1000
+ CFMutableStringRef mutStr;
+ UniChar *myBuffer;
+
+ myBuffer = (UniChar *)malloc(BufferSize * sizeof(UniChar));
+
+ mutStr = CFStringCreateMutableWithExternalCharactersNoCopy(0, myBuffer, 0, BufferSize, kCFAllocatorNull); // expected-warning{{leak}}
+
+ CFRelease(mutStr);
+ //free(myBuffer);
+}
+
+// PR12101 : pointers can escape through custom deallocators set on creation of a container.
+void TestCallbackReleasesMemory(CFDictionaryKeyCallBacks keyCallbacks) {
+ void *key = malloc(12);
+ void *val = malloc(12);
+ CFMutableDictionaryRef x = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &keyCallbacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionarySetValue(x, key, val);
+ return;// no-warning
+}
+
+NSData *radar10976702() {
+ void *bytes = malloc(10);
+ return [NSData dataWithBytesNoCopy:bytes length:10]; // no-warning
+}
+
+void testBlocks() {
+ int *x= (int*)malloc(sizeof(int));
+ int (^myBlock)(int) = ^(int num) {
+ free(x);
+ return num;
+ };
+ myBlock(3);
+}
+
+// Test NSMapInsert.
+@interface NSMapTable : NSObject <NSCopying, NSCoding, NSFastEnumeration>
+@end
+extern void *NSMapGet(NSMapTable *table, const void *key);
+extern void NSMapInsert(NSMapTable *table, const void *key, const void *value);
+extern void NSMapInsertKnownAbsent(NSMapTable *table, const void *key, const void *value);
+char *strdup(const char *s);
+
+NSString * radar11152419(NSString *string1, NSMapTable *map) {
+ const char *strkey = "key";
+ NSString *string = ( NSString *)NSMapGet(map, strkey);
+ if (!string) {
+ string = [string1 copy];
+ NSMapInsert(map, strdup(strkey), (void*)string); // no warning
+ NSMapInsertKnownAbsent(map, strdup(strkey), (void*)string); // no warning
+ }
+ return string;
+}
+
+// Test that we handle pointer escaping through OSAtomicEnqueue.
+typedef volatile struct {
+ void *opaque1;
+ long opaque2;
+} OSQueueHead;
+void OSAtomicEnqueue( OSQueueHead *__list, void *__new, size_t __offset) __attribute__((weak_import));
+static inline void radar11111210(OSQueueHead *pool) {
+ void *newItem = malloc(4);
+ OSAtomicEnqueue(pool, newItem, 4);
+}
+
+// Pointer might escape through CGDataProviderCreateWithData (radar://11187558).
+typedef struct CGDataProvider *CGDataProviderRef;
+typedef void (*CGDataProviderReleaseDataCallback)(void *info, const void *data,
+ size_t size);
+extern CGDataProviderRef CGDataProviderCreateWithData(void *info,
+ const void *data, size_t size,
+ CGDataProviderReleaseDataCallback releaseData)
+ __attribute__((visibility("default")));
+void *calloc(size_t, size_t);
+
+static void releaseDataCallback (void *info, const void *data, size_t size) {
+#pragma unused (info, size)
+ free((void*)data);
+}
+void testCGDataProviderCreateWithData() {
+ void* b = calloc(8, 8);
+ CGDataProviderRef p = CGDataProviderCreateWithData(0, b, 8*8, releaseDataCallback);
+} \ No newline at end of file
diff --git a/clang/test/Analysis/method-arg-decay.m b/clang/test/Analysis/method-arg-decay.m
new file mode 100644
index 0000000..a36d81e
--- /dev/null
+++ b/clang/test/Analysis/method-arg-decay.m
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -analyzer-checker=core -verify %s
+typedef signed char BOOL;
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end @interface NSObject <NSObject> {
+}
+@end extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
+@end @class NSString, NSData, NSMutableData, NSMutableDictionary, NSMutableArray;
+typedef struct {
+}
+ NSFastEnumerationState;
+@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end @class NSString;
+typedef struct _NSRange {
+}
+ NSRange;
+@interface NSValue (NSValueRangeExtensions) + (NSValue *)valueWithRange:(NSRange)range;
+- (id)objectAtIndex:(NSUInteger)index;
+@end typedef unsigned short unichar;
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length;
+@end @class NSArray, NSDictionary, NSString, NSError;
+@interface NSSet : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end extern NSString *NSAccessibilityRoleDescription(NSString *role, NSString *subrole) ;
+@interface NSResponder : NSObject <NSCoding> {
+}
+@end @protocol NSAnimatablePropertyContainer - (id)animator;
+@end extern NSString *NSAnimationTriggerOrderIn ;
+@interface NSView : NSResponder <NSAnimatablePropertyContainer> {
+}
+@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView;
+@interface NSWindowController : NSResponder <NSCoding> {
+}
+@end @class NSArray, NSFont, NSTabViewItem;
+@interface NSTabView : NSView {
+}
+- (NSArray *)tabViewItems;
+- (NSString *)label;
+@end typedef enum {
+PBXNoItemChanged = 0x00, PBXProjectItemChanged = 0x01, PBXReferenceChanged = 0x02, PBXGroupChanged = 0x04, PBXTargetChanged = 0x08, PBXBuildPhaseChanged = 0x10, PBXBuildFileChanged = 0x20, PBXBreakpointChanged = 0x40, }
+ PBXArchiveMask;
+@interface PBXModule : NSWindowController {
+}
+@end typedef enum {
+PBXFindMatchContains, PBXFindMatchStartsWith, PBXFindMatchWholeWords, PBXFindMatchEndsWith }
+ PBXFindMatchStyle;
+@protocol PBXSelectableText - (NSString *)selectedString;
+@end @protocol PBXFindableText <PBXSelectableText> - (BOOL)findText:(NSString *)string ignoreCase:(BOOL)ignoreCase matchStyle:(PBXFindMatchStyle)matchStyle backwards:(BOOL)backwards wrap:(BOOL)wrap;
+@end @class PBXProjectDocument, PBXProject, PBXAttributedStatusView;
+@interface PBXProjectModule : PBXModule <PBXFindableText> {
+}
+@end @class PBXBookmark;
+@protocol PBXSelectionTarget - (NSObject <PBXSelectionTarget> *) performAction:(id)action withSelection:(NSArray *)selection; // expected-note {{method 'performAction:withSelection:' declared here}}
+@end @class XCPropertyDictionary, XCPropertyCondition, XCPropertyConditionSet, XCMutablePropertyConditionSet;
+extern NSMutableArray *XCFindPossibleKeyModules(PBXModule *module, BOOL useExposedModulesOnly);
+@interface NSString (StringUtilities) - (NSString *) trimToLength:(NSInteger)length preserveRange:(NSRange)range;
+- (id) objectOfType:(Class)type matchingFunction:(BOOL (void *, void *))comparator usingData:(void *)data;
+@end @class XCControlView;
+@protocol XCDockViewHeader - (NSImage *) headerImage;
+@end @class XCDockableTabModule;
+@interface XCExtendedTabView : NSTabView <XCDockViewHeader> {
+}
+@end @class PBXProjectDocument, PBXFileReference, PBXModule, XCWindowTool;
+@interface XCPerspectiveModule : PBXProjectModule <PBXSelectionTarget> { // expected-note {{required for direct or indirect protocol 'PBXSelectionTarget'}}
+ XCExtendedTabView *_perspectivesTabView;
+}
+- (PBXModule *) moduleForTab:(NSTabViewItem *)item; // expected-note {{method definition for 'moduleForTab:' not found}}
+@end
+@implementation XCPerspectiveModule // expected-warning {{incomplete implementation}} expected-warning {{method 'performAction:withSelection:' in protocol not implemented}}}
++ (void) openForProjectDocument:(PBXProjectDocument *)projectDocument {
+}
+- (PBXModule *) type:(Class)type inPerspective:(id)perspectiveIdentifer matchingFunction:(BOOL (void *, void *))comparator usingData:(void *)data {
+ NSArray *allItems = [_perspectivesTabView tabViewItems];
+ NSInteger i, c = [allItems count];
+ for (i = 0;
+ i < c;
+ i++) {
+ NSTabViewItem *item = [allItems objectAtIndex:i];
+ if ([[item label] isEqual:perspectiveIdentifer]) {
+ PBXProjectModule *pModule = (PBXProjectModule *)[self moduleForTab:item];
+ PBXModule *obj = [XCFindPossibleKeyModules(pModule, (BOOL)0) objectOfType:type matchingFunction:comparator usingData:data];
+ }
+ }
+ return 0;
+}
+- (BOOL)buffer:(char *)buf containsAnyPrompts:(char *[])prompts
+{
+ prompts++;
+ return (BOOL)0;
+}
+@end
diff --git a/clang/test/Analysis/method-call-intra-p.cpp b/clang/test/Analysis/method-call-intra-p.cpp
new file mode 100644
index 0000000..701479f
--- /dev/null
+++ b/clang/test/Analysis/method-call-intra-p.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -verify %s
+
+// Intra-procedural C++ tests.
+
+// Test relaxing function call arguments invalidation to be aware of const
+// arguments. radar://10595327
+struct InvalidateArgs {
+ void ttt(const int &nptr);
+ virtual void vttt(const int *nptr);
+};
+struct ChildOfInvalidateArgs: public InvalidateArgs {
+ virtual void vttt(const int *nptr);
+};
+void declarationFun(int x) {
+ InvalidateArgs t;
+ x = 3;
+ int y = x + 1;
+ int *p = 0;
+ t.ttt(y);
+ if (x == y)
+ y = *p; // no-warning
+}
+void virtualFun(int x) {
+ ChildOfInvalidateArgs t;
+ InvalidateArgs *pt = &t;
+ x = 3;
+ int y = x + 1;
+ int *p = 0;
+ pt->vttt(&y);
+ if (x == y)
+ y = *p; // no-warning
+}
diff --git a/clang/test/Analysis/method-call.cpp b/clang/test/Analysis/method-call.cpp
new file mode 100644
index 0000000..323fffe
--- /dev/null
+++ b/clang/test/Analysis/method-call.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-inline-call -analyzer-store region -verify %s
+// XFAIL: *
+
+struct A {
+ int x;
+ A(int a) { x = a; }
+ int getx() const { return x; }
+};
+
+void f1() {
+ A x(3);
+ if (x.getx() == 3) {
+ int *p = 0;
+ *p = 3; // expected-warning{{Dereference of null pointer}}
+ } else {
+ int *p = 0;
+ *p = 3; // no-warning
+ }
+}
+
+void f2() {
+ const A &x = A(3);
+ if (x.getx() == 3) {
+ int *p = 0;
+ *p = 3; // expected-warning{{Dereference of null pointer}}
+ } else {
+ int *p = 0;
+ *p = 3; // no-warning
+ }
+}
+
+void f3() {
+ const A &x = (A)3;
+ if (x.getx() == 3) {
+ int *p = 0;
+ *p = 3; // expected-warning{{Dereference of null pointer}}
+ } else {
+ int *p = 0;
+ *p = 3; // no-warning
+ }
+}
diff --git a/clang/test/Analysis/misc-ps-64.m b/clang/test/Analysis/misc-ps-64.m
new file mode 100644
index 0000000..e20a27f
--- /dev/null
+++ b/clang/test/Analysis/misc-ps-64.m
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify -fblocks %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -fblocks %s
+
+// <rdar://problem/6440393> - A bunch of misc. failures involving evaluating
+// these expressions and building CFGs. These tests are here to prevent
+// regressions.
+typedef long long int64_t;
+@class NSString, NSDictionary;
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+typedef unsigned char Boolean;
+typedef const struct __CFDictionary * CFDictionaryRef;
+
+extern Boolean CFDictionaryGetValueIfPresent(CFDictionaryRef theDict, const void *key, const void **value);
+void shazam(NSUInteger i, unsigned char **out);
+
+void rdar_6440393_1(NSDictionary *dict) {
+ NSInteger x = 0;
+ unsigned char buf[10], *bufptr = buf;
+ if (!CFDictionaryGetValueIfPresent(0, dict, (void *)&x))
+ return;
+ shazam(x, &bufptr);
+}
+
+// <rdar://problem/6845148> - In this example we got a signedness
+// mismatch between the literal '0' and the value of 'scrooge'. The
+// trick is to have the evaluator convert the literal to an unsigned
+// integer when doing a comparison with the pointer. This happens
+// because of the transfer function logic of
+// OSAtomicCompareAndSwap64Barrier, which doesn't have special casts
+// in place to do this for us.
+_Bool OSAtomicCompareAndSwap64Barrier( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue );
+extern id objc_lookUpClass(const char *name);
+void rdar_6845148(id debug_yourself) {
+ if (!debug_yourself) {
+ const char *wacky = ((void *)0);
+ Class scrooge = wacky ? (Class)objc_lookUpClass(wacky) : ((void *)0);
+ OSAtomicCompareAndSwap64Barrier(0, (int64_t)scrooge, (int64_t*)&debug_yourself);
+ }
+}
+void rdar_6845148_b(id debug_yourself) {
+ if (!debug_yourself) {
+ const char *wacky = ((void *)0);
+ Class scrooge = wacky ? (Class)objc_lookUpClass(wacky) : ((void *)0);
+ OSAtomicCompareAndSwap64Barrier((int64_t)scrooge, 0, (int64_t*)&debug_yourself);
+ }
+}
diff --git a/clang/test/Analysis/misc-ps-cxx0x.cpp b/clang/test/Analysis/misc-ps-cxx0x.cpp
new file mode 100644
index 0000000..b4dee31
--- /dev/null
+++ b/clang/test/Analysis/misc-ps-cxx0x.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang --analyze -std=c++11 %s -Xclang -verify -o /dev/null
+
+void test_static_assert() {
+ static_assert(sizeof(void *) == sizeof(void*), "test_static_assert");
+}
+
+void test_analyzer_working() {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+}
+
+// Test that pointer-to-member functions don't cause the analyzer
+// to crash.
+struct RDar10243398 {
+ void bar(int x);
+};
+
+typedef void (RDar10243398::*RDar10243398MemberFn)(int x);
+
+void test_rdar10243398(RDar10243398 *p) {
+ RDar10243398MemberFn q = &RDar10243398::bar;
+ ((*p).*(q))(1);
+}
+
+// Tests for CXXTemporaryObjectExpr.
+struct X {
+ X( int *ip, int );
+};
+
+// Test to see if CXXTemporaryObjectExpr is being handled.
+int tempobj1()
+{
+ int j;
+ int i;
+ X a = X( &j, 1 );
+
+ return i; // expected-warning {{Undefined or garbage value returned to caller}}
+}
+
+// Test to see if CXXTemporaryObjectExpr invalidates arguments.
+int tempobj2()
+{
+ int j;
+ X a = X( &j, 1 );
+
+ return j; // no-warning
+}
+
+
+// Test for correct handling of C++ ForRange statement.
+void test1() {
+ int array[2] = { 1, 2 };
+ int j = 0;
+ for ( int i : array )
+ j += i;
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+}
+
+void test2() {
+ int array[2] = { 1, 2 };
+ int j = 0;
+ for (int i : array)
+ j += i;
+ if (j == 3)
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+}
+
+// Do not crash on the following when constructing the
+// callgraph.
+struct RDar11178609 {
+ ~RDar11178609() = delete;
+};
diff --git a/clang/test/Analysis/misc-ps-eager-assume.m b/clang/test/Analysis/misc-ps-eager-assume.m
new file mode 100644
index 0000000..0aff8e4
--- /dev/null
+++ b/clang/test/Analysis/misc-ps-eager-assume.m
@@ -0,0 +1,146 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -fblocks %s -analyzer-eagerly-assume
+
+// Delta-reduced header stuff (needed for test cases).
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object;
+- (oneway void)release;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end @interface NSObject <NSObject> {}
++ (id)alloc;
+- (id)init;
+@end typedef struct {}
+NSFastEnumerationState;
+@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end @interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSMutableArray : NSArray - (void)addObject:(id)anObject;
+- (BOOL)isEqualToString:(NSString *)aString;
+@end @interface NSAutoreleasePool : NSObject {}
+- (void)drain;
+- (id)init;
+@end
+
+// This test case tests that (x != 0) is eagerly evaluated before stored to
+// 'y'. This test case complements recoverCastedSymbol (see below) because
+// the symbolic expression is stored to 'y' (which is a short instead of an
+// int). recoverCastedSymbol() only recovers path-sensitivity when the
+// symbolic expression is literally the branch condition.
+//
+void handle_assign_of_condition(int x) {
+ // The cast to 'short' causes us to lose symbolic constraint.
+ short y = (x != 0);
+ char *p = 0;
+ if (y) {
+ // This should be infeasible.
+ if (!(x != 0)) {
+ *p = 1; // no-warning
+ }
+ }
+}
+
+// From <rdar://problem/6619921>
+//
+// In this test case, 'needsAnArray' is a signed char. The analyzer tracks
+// a symbolic value for this variable, but in the branch condition it is
+// promoted to 'int'. Currently the analyzer doesn't reason well about
+// promotions of symbolic values, so this test case tests the logic in
+// 'recoverCastedSymbol()' (GRExprEngine.cpp) to test that we recover
+// path-sensitivity and use the symbol for 'needsAnArray' in the branch
+// condition.
+//
+void handle_symbolic_cast_in_condition(void) {
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+ BOOL needsAnArray = [@"aString" isEqualToString:@"anotherString"];
+ NSMutableArray* array = needsAnArray ? [[NSMutableArray alloc] init] : 0;
+ if(needsAnArray)
+ [array release];
+
+ [pool drain];
+}
+
+// From PR 3836 (http://llvm.org/bugs/show_bug.cgi?id=3836)
+//
+// In this test case, the double '!' works fine with our symbolic constraints,
+// but we don't support comparing SymConstraint != SymConstraint. By eagerly
+// assuming the truth of !!a or !!b, we can compare these values directly.
+//
+void pr3836(int *a, int *b) {
+ if (!!a != !!b) /* one of them is NULL */
+ return;
+ if (!a && !b) /* both are NULL */
+ return;
+
+ *a = 1; // no-warning
+ *b = 1; // no-warning
+}
+
+
+//===---------------------------------------------------------------------===//
+// <rdar://problem/7342806>
+// This false positive occurred because the symbolic constraint on a short was
+// not maintained via sign extension. The analyzer doesn't properly handle
+// the sign extension, but now tracks the constraint. This particular
+// case relies on -analyzer-eagerly-assume because of the expression
+// 'Flag1 != Count > 0'.
+//===---------------------------------------------------------------------===//
+
+void rdar7342806_aux(short x);
+
+void rdar7342806() {
+ extern short Count;
+ extern short Flag1;
+
+ short *Pointer = 0;
+ short Flag2 = !!Pointer; // Flag2 is false (0).
+ short Ok = 1;
+ short Which;
+
+ if( Flag1 != Count > 0 )
+ // Static analyzer skips this so either
+ // Flag1 is true and Count > 0
+ // or
+ // Flag1 is false and Count <= 0
+ Ok = 0;
+
+ if( Flag1 != Flag2 )
+ // Analyzer skips this so Flag1 and Flag2 have the
+ // same value, both are false because Flag2 is false. And
+ // from that we know Count must be <= 0.
+ Ok = 0;
+
+ for( Which = 0;
+ Which < Count && Ok;
+ Which++ )
+ // This statement can only execute if Count > 0 which can only
+ // happen when Flag1 and Flag2 are both true and Flag2 will only
+ // be true when Pointer is not NULL.
+ rdar7342806_aux(*Pointer); // no-warning
+}
+
+//===---------------------------------------------------------------------===//
+// PR 5627 - http://llvm.org/bugs/show_bug.cgi?id=5627
+// This test case depends on using -analyzer-eagerly-assume and
+// -analyzer-store=region. The '-analyzer-eagerly-assume' causes the path
+// to bifurcate when evaluating the function call argument, and a state
+// caching bug in GRExprEngine::CheckerVisit (and friends) caused the store
+// to 'p' to not be evaluated along one path, but then an autotransition caused
+// the path to keep on propagating with 'p' still set to an undefined value.
+// We would then get a bogus report of returning uninitialized memory.
+// Note: CheckerVisit mistakenly cleared an existing node, and the cleared
+// node was resurrected by GRStmtNodeBuilder::~GRStmtNodeBuilder(), where
+// 'p' was not assigned.
+//===---------------------------------------------------------------------===//
+
+float *pr5627_f(int y);
+
+float *pr5627_g(int x) {
+ float *p;
+ p = pr5627_f(!x);
+ return p; // no-warning
+}
+
diff --git a/clang/test/Analysis/misc-ps-ranges.m b/clang/test/Analysis/misc-ps-ranges.m
new file mode 100644
index 0000000..00337f4
--- /dev/null
+++ b/clang/test/Analysis/misc-ps-ranges.m
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -fblocks %s
+
+// <rdar://problem/6776949>
+// main's 'argc' argument is always > 0
+int main(int argc, char* argv[]) {
+ int *p = 0;
+
+ if (argc == 0)
+ *p = 1;
+
+ if (argc == 1)
+ return 1;
+
+ int x = 1;
+ int i;
+
+ for(i=1;i<argc;i++){
+ p = &x;
+ }
+
+ return *p; // no-warning
+}
+
+// PR 5969: the comparison of argc < 3 || argc > 4 should constraint the switch
+// statement from having the 'default' branch taken. This previously reported a false
+// positive with the use of 'v'.
+
+int pr5969(int argc, char *argv[]) {
+
+ int v;
+
+ if ((argc < 3) || (argc > 4)) return 0;
+
+ switch(argc) {
+ case 3:
+ v = 33;
+ break;
+ case 4:
+ v = 44;
+ break;
+ }
+
+ return v; // no-warning
+}
+
+int pr5969_positive(int argc, char *argv[]) {
+
+ int v;
+
+ if ((argc < 3) || (argc > 4)) return 0;
+
+ switch(argc) {
+ case 3:
+ v = 33;
+ break;
+ }
+
+ return v; // expected-warning{{Undefined or garbage value returned to caller}}
+}
diff --git a/clang/test/Analysis/misc-ps-region-store-i386.m b/clang/test/Analysis/misc-ps-region-store-i386.m
new file mode 100644
index 0000000..3106a24
--- /dev/null
+++ b/clang/test/Analysis/misc-ps-region-store-i386.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify -fblocks %s
+
+// Here is a case where a pointer is treated as integer, invalidated as an
+// integer, and then used again as a pointer. This test just makes sure
+// we don't crash.
+typedef unsigned uintptr_t;
+void test_pointer_invalidated_as_int_aux(uintptr_t* ptr);
+void test_pointer_invalidated_as_int() {
+ void *x;
+ test_pointer_invalidated_as_int_aux((uintptr_t*) &x);
+ // Here we have a pointer to integer cast.
+ uintptr_t y = (uintptr_t) x;
+}
+
diff --git a/clang/test/Analysis/misc-ps-region-store-x86_64.m b/clang/test/Analysis/misc-ps-region-store-x86_64.m
new file mode 100644
index 0000000..2c604cf
--- /dev/null
+++ b/clang/test/Analysis/misc-ps-region-store-x86_64.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify -fblocks %s
+
+// Here is a case where a pointer is treated as integer, invalidated as an
+// integer, and then used again as a pointer. This test just makes sure
+// we don't crash.
+typedef unsigned long uintptr_t;
+void test_pointer_invalidated_as_int_aux(uintptr_t* ptr);
+void test_pointer_invalidated_as_int() {
+ void *x;
+ test_pointer_invalidated_as_int_aux((uintptr_t*) &x);
+ // Here we have a pointer to integer cast.
+ uintptr_t y = (uintptr_t) x;
+}
+
diff --git a/clang/test/Analysis/misc-ps-region-store.cpp b/clang/test/Analysis/misc-ps-region-store.cpp
new file mode 100644
index 0000000..8d75fb8
--- /dev/null
+++ b/clang/test/Analysis/misc-ps-region-store.cpp
@@ -0,0 +1,580 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s -fexceptions -fcxx-exceptions
+
+// Test basic handling of references.
+char &test1_aux();
+char *test1() {
+ return &test1_aux();
+}
+
+// Test test1_aux() evaluates to char &.
+char test1_as_rvalue() {
+ return test1_aux();
+}
+
+// Test passing a value as a reference. The 'const' in test2_aux() adds
+// an ImplicitCastExpr, which is evaluated as an lvalue.
+int test2_aux(const int &n);
+int test2(int n) {
+ return test2_aux(n);
+}
+
+int test2_b_aux(const short &n);
+int test2_b(int n) {
+ return test2_b_aux(n);
+}
+
+// Test getting the lvalue of a derived and converting it to a base. This
+// previously crashed.
+class Test3_Base {};
+class Test3_Derived : public Test3_Base {};
+
+int test3_aux(Test3_Base &x);
+int test3(Test3_Derived x) {
+ return test3_aux(x);
+}
+
+//===---------------------------------------------------------------------===//
+// Test CFG support for C++ condition variables.
+//===---------------------------------------------------------------------===//
+
+int test_init_in_condition_aux();
+int test_init_in_condition() {
+ if (int x = test_init_in_condition_aux()) { // no-warning
+ return 1;
+ }
+ return 0;
+}
+
+int test_init_in_condition_switch() {
+ switch (int x = test_init_in_condition_aux()) { // no-warning
+ case 1:
+ return 0;
+ case 2:
+ if (x == 2)
+ return 0;
+ else {
+ // Unreachable.
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+ default:
+ break;
+ }
+ return 0;
+}
+
+int test_init_in_condition_while() {
+ int z = 0;
+ while (int x = ++z) { // no-warning
+ if (x == 2)
+ break;
+ }
+
+ if (z == 2)
+ return 0;
+
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ return 0;
+}
+
+
+int test_init_in_condition_for() {
+ int z = 0;
+ for (int x = 0; int y = ++z; ++x) {
+ if (x == y) // no-warning
+ break;
+ }
+ if (z == 1)
+ return 0;
+
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ return 0;
+}
+
+//===---------------------------------------------------------------------===//
+// Test handling of 'this' pointer.
+//===---------------------------------------------------------------------===//
+
+class TestHandleThis {
+ int x;
+
+ TestHandleThis();
+ int foo();
+ int null_deref_negative();
+ int null_deref_positive();
+};
+
+int TestHandleThis::foo() {
+ // Assume that 'x' is initialized.
+ return x + 1; // no-warning
+}
+
+int TestHandleThis::null_deref_negative() {
+ x = 10;
+ if (x == 10) {
+ return 1;
+ }
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ return 0;
+}
+
+int TestHandleThis::null_deref_positive() {
+ x = 10;
+ if (x == 9) {
+ return 1;
+ }
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning{{null pointer}}
+ return 0;
+}
+
+// PR 7675 - passing literals by-reference
+void pr7675(const double &a);
+void pr7675(const int &a);
+void pr7675(const char &a);
+void pr7675_i(const _Complex double &a);
+
+void pr7675_test() {
+ pr7675(10.0);
+ pr7675(10);
+ pr7675('c');
+ pr7675_i(4.0i);
+ // Add null deref to ensure we are analyzing the code up to this point.
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning{{null pointer}}
+}
+
+// <rdar://problem/8375510> - CFGBuilder should handle temporaries.
+struct R8375510 {
+ R8375510();
+ ~R8375510();
+ R8375510 operator++(int);
+};
+
+int r8375510(R8375510 x, R8375510 y) {
+ for (; ; x++) { }
+}
+
+// PR8419 -- this used to crash.
+
+class String8419 {
+ public:
+ char& get(int n);
+ char& operator[](int n);
+};
+
+char& get8419();
+
+void Test8419() {
+ String8419 s;
+ ++(s.get(0));
+ get8419()--; // used to crash
+ --s[0]; // used to crash
+ s[0] &= 1; // used to crash
+ s[0]++; // used to crash
+}
+
+// PR8426 -- this used to crash.
+
+void Use(void* to);
+
+template <class T> class Foo {
+ ~Foo();
+ struct Bar;
+ Bar* bar_;
+};
+
+template <class T> Foo<T>::~Foo() {
+ Use(bar_);
+ T::DoSomething();
+ bar_->Work();
+}
+
+// PR8427 -- this used to crash.
+
+class Dummy {};
+
+bool operator==(Dummy, int);
+
+template <typename T>
+class Foo2 {
+ bool Bar();
+};
+
+template <typename T>
+bool Foo2<T>::Bar() {
+ return 0 == T();
+}
+
+// PR8433 -- this used to crash.
+
+template <typename T>
+class Foo3 {
+ public:
+ void Bar();
+ void Baz();
+ T value_;
+};
+
+template <typename T>
+void Foo3<T>::Bar() {
+ Baz();
+ value_();
+}
+
+//===---------------------------------------------------------------------===//
+// Handle misc. C++ constructs.
+//===---------------------------------------------------------------------===//
+
+namespace fum {
+ int i = 3;
+};
+
+void test_namespace() {
+ // Previously triggered a crash.
+ using namespace fum;
+ int x = i;
+}
+
+// Test handling methods that accept references as parameters, and that
+// variables are properly invalidated.
+class RDar9203355 {
+ bool foo(unsigned valA, long long &result) const;
+ bool foo(unsigned valA, int &result) const;
+};
+bool RDar9203355::foo(unsigned valA, int &result) const {
+ long long val;
+ if (foo(valA, val) ||
+ (int)val != val) // no-warning
+ return true;
+ result = val; // no-warning
+ return false;
+}
+
+// Test handling of new[].
+void rdar9212512() {
+ int *x = new int[10];
+ for (unsigned i = 0 ; i < 2 ; ++i) {
+ // This previously triggered an uninitialized values warning.
+ x[i] = 1; // no-warning
+ }
+}
+
+// Test basic support for dynamic_cast<>.
+struct Rdar9212495_C { virtual void bar() const; };
+class Rdar9212495_B : public Rdar9212495_C {};
+class Rdar9212495_A : public Rdar9212495_B {};
+const Rdar9212495_A& rdar9212495(const Rdar9212495_C* ptr) {
+ const Rdar9212495_A& val = dynamic_cast<const Rdar9212495_A&>(*ptr);
+
+ if (&val == 0) {
+ val.bar(); // FIXME: This should eventually be a null dereference.
+ }
+
+ return val;
+}
+
+// Test constructors invalidating arguments. Previously this raised
+// an uninitialized value warning.
+extern "C" void __attribute__((noreturn)) PR9645_exit(int i);
+
+class PR9645_SideEffect
+{
+public:
+ PR9645_SideEffect(int *pi); // caches pi in i_
+ void Read(int *pi); // copies *pi into *i_
+private:
+ int *i_;
+};
+
+void PR9645() {
+ int i;
+
+ PR9645_SideEffect se(&i);
+ int j = 1;
+ se.Read(&j); // this has a side-effect of initializing i.
+
+ PR9645_exit(i); // no-warning
+}
+
+PR9645_SideEffect::PR9645_SideEffect(int *pi) : i_(pi) {}
+void PR9645_SideEffect::Read(int *pi) { *i_ = *pi; }
+
+// Invalidate fields during C++ method calls.
+class RDar9267815 {
+ int x;
+ void test();
+ void test_pos();
+ void test2();
+ void invalidate();
+};
+
+void RDar9267815::test_pos() {
+ int *p = 0;
+ if (x == 42)
+ return;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+}
+void RDar9267815::test() {
+ int *p = 0;
+ if (x == 42)
+ return;
+ if (x == 42)
+ *p = 0xDEADBEEF; // no-warning
+}
+
+void RDar9267815::test2() {
+ int *p = 0;
+ if (x == 42)
+ return;
+ invalidate();
+ if (x == 42)
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+}
+
+// Test reference parameters.
+void test_ref_double_aux(double &Value);
+float test_ref_double() {
+ double dVal;
+ test_ref_double_aux(dVal);
+ // This previously warned because 'dVal' was thought to be uninitialized.
+ float Val = (float)dVal; // no-warning
+ return Val;
+}
+
+// Test invalidation of class fields.
+class TestInvalidateClass {
+public:
+ int x;
+};
+
+void test_invalidate_class_aux(TestInvalidateClass &x);
+
+int test_invalidate_class() {
+ TestInvalidateClass y;
+ test_invalidate_class_aux(y);
+ return y.x; // no-warning
+}
+
+// Test correct pointer arithmetic using 'p--'. This is to warn that we
+// were loading beyond the written characters in buf.
+char *RDar9269695(char *dst, unsigned int n)
+{
+ char buff[40], *p;
+
+ p = buff;
+ do
+ *p++ = '0' + n % 10;
+ while (n /= 10);
+
+ do
+ *dst++ = *--p; // no-warning
+ while (p != buff);
+
+ return dst;
+}
+
+// Test that we invalidate byref arguments passed to constructors.
+class TestInvalidateInCtor {
+public:
+ TestInvalidateInCtor(unsigned &x);
+};
+
+unsigned test_invalidate_in_ctor() {
+ unsigned x;
+ TestInvalidateInCtor foo(x);
+ return x; // no-warning
+}
+unsigned test_invalidate_in_ctor_new() {
+ unsigned x;
+ delete (new TestInvalidateInCtor(x));
+ return x; // no-warning
+}
+
+// Test assigning into a symbolic offset.
+struct TestAssignIntoSymbolicOffset {
+ int **stuff[100];
+ void test(int x, int y);
+};
+
+void TestAssignIntoSymbolicOffset::test(int x, int y) {
+ x--;
+ if (x > 8 || x < 0)
+ return;
+ if (stuff[x])
+ return;
+ if (!stuff[x]) {
+ stuff[x] = new int*[y+1];
+ // Previously triggered a null dereference.
+ stuff[x][y] = 0; // no-warning
+ }
+}
+
+// Test loads from static fields. This previously triggered an uninitialized
+// value warning.
+class ClassWithStatic {
+public:
+ static const unsigned value = 1;
+};
+
+int rdar9948787_negative() {
+ ClassWithStatic classWithStatic;
+ unsigned value = classWithStatic.value;
+ if (value == 1)
+ return 1;
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ return 0;
+}
+
+int rdar9948787_positive() {
+ ClassWithStatic classWithStatic;
+ unsigned value = classWithStatic.value;
+ if (value == 0)
+ return 1;
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+ return 0;
+}
+
+// Regression test against global constants and switches.
+enum rdar10202899_ValT { rdar10202899_ValTA, rdar10202899_ValTB, rdar10202899_ValTC };
+const rdar10202899_ValT val = rdar10202899_ValTA;
+void rdar10202899_test1() {
+ switch (val) {
+ case rdar10202899_ValTA: {}
+ };
+}
+
+void rdar10202899_test2() {
+ if (val == rdar10202899_ValTA)
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF;
+}
+
+void rdar10202899_test3() {
+ switch (val) {
+ case rdar10202899_ValTA: return;
+ default: ;
+ };
+ int *p = 0;
+ *p = 0xDEADBEEF;
+}
+
+// This used to crash the analyzer because of the unnamed bitfield.
+void PR11249()
+{
+ struct {
+ char f1:4;
+ char :4;
+ char f2[1];
+ char f3;
+ } V = { 1, {2}, 3 };
+ int *p = 0;
+ if (V.f1 != 1)
+ *p = 0xDEADBEEF; // no-warning
+ if (V.f2[0] != 2)
+ *p = 0xDEADBEEF; // no-warning
+ if (V.f3 != 3)
+ *p = 0xDEADBEEF; // no-warning
+}
+
+// Handle doing a load from the memory associated with the code for
+// a function.
+extern double nan( const char * );
+double PR11450() {
+ double NaN = *(double*) nan;
+ return NaN;
+}
+
+// Test that 'this' is assumed non-null upon analyzing the entry to a "top-level"
+// function (i.e., when not analyzing from a specific caller).
+struct TestNullThis {
+ int field;
+ void test();
+};
+
+void TestNullThis::test() {
+ int *p = &field;
+ if (p)
+ return;
+ field = 2; // no-warning
+}
+
+// Test handling of 'catch' exception variables, and not warning
+// about uninitialized values.
+enum MyEnum { MyEnumValue };
+MyEnum rdar10892489() {
+ try {
+ throw MyEnumValue;
+ } catch (MyEnum e) {
+ return e; // no-warning
+ }
+ return MyEnumValue;
+}
+
+MyEnum rdar10892489_positive() {
+ try {
+ throw MyEnumValue;
+ } catch (MyEnum e) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+ return e;
+ }
+ return MyEnumValue;
+}
+
+// Test handling of catch with no condition variable.
+void PR11545() {
+ try
+ {
+ throw;
+ }
+ catch (...)
+ {
+ }
+}
+
+void PR11545_positive() {
+ try
+ {
+ throw;
+ }
+ catch (...)
+ {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+ }
+}
+
+// Test handling taking the address of a field. While the analyzer
+// currently doesn't do anything intelligent here, this previously
+// resulted in a crash.
+class PR11146 {
+public:
+ struct Entry;
+ void baz();
+};
+
+struct PR11146::Entry {
+ int x;
+};
+
+void PR11146::baz() {
+ (void) &Entry::x;
+}
+
+// Test symbolicating a reference. In this example, the
+// analyzer (originally) didn't know how to handle x[index - index2],
+// returning an UnknownVal. The conjured symbol wasn't a location,
+// and would result in a crash.
+void rdar10924675(unsigned short x[], int index, int index2) {
+ unsigned short &y = x[index - index2];
+ if (y == 0)
+ return;
+}
diff --git a/clang/test/Analysis/misc-ps-region-store.m b/clang/test/Analysis/misc-ps-region-store.m
new file mode 100644
index 0000000..d263d4d
--- /dev/null
+++ b/clang/test/Analysis/misc-ps-region-store.m
@@ -0,0 +1,1343 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core.CastToStruct,experimental.security.ReturnPtrRange,experimental.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DTEST_64 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core.CastToStruct,experimental.security.ReturnPtrRange,experimental.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s
+
+typedef long unsigned int size_t;
+void *memcpy(void *, const void *, size_t);
+void *alloca(size_t);
+
+typedef struct objc_selector *SEL;
+typedef signed char BOOL;
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@interface NSObject <NSObject> {} - (id)init; @end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
++ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
+@end extern NSString * const NSBundleDidLoadNotification;
+@interface NSAssertionHandler : NSObject {}
++ (NSAssertionHandler *)currentHandler;
+- (void)handleFailureInMethod:(SEL)selector object:(id)object file:(NSString *)fileName lineNumber:(NSInteger)line description:(NSString *)format,...;
+@end
+extern NSString * const NSConnectionReplyMode;
+
+#ifdef TEST_64
+typedef long long int64_t;
+typedef int64_t intptr_t;
+#else
+typedef int int32_t;
+typedef int32_t intptr_t;
+#endif
+
+//---------------------------------------------------------------------------
+// Test case 'checkaccess_union' differs for region store and basic store.
+// The basic store doesn't reason about compound literals, so the code
+// below won't fire an "uninitialized value" warning.
+//---------------------------------------------------------------------------
+
+// PR 2948 (testcase; crash on VisitLValue for union types)
+// http://llvm.org/bugs/show_bug.cgi?id=2948
+void checkaccess_union() {
+ int ret = 0, status;
+ // Since RegionStore doesn't handle unions yet,
+ // this branch condition won't be triggered
+ // as involving an uninitialized value.
+ if (((((__extension__ (((union { // no-warning
+ __typeof (status) __in; int __i;}
+ )
+ {
+ .__in = (status)}
+ ).__i))) & 0xff00) >> 8) == 1)
+ ret = 1;
+}
+
+// Check our handling of fields being invalidated by function calls.
+struct test2_struct { int x; int y; char* s; };
+void test2_help(struct test2_struct* p);
+
+char test2() {
+ struct test2_struct s;
+ test2_help(&s);
+ char *p = 0;
+
+ if (s.x > 1) {
+ if (s.s != 0) {
+ p = "hello";
+ }
+ }
+
+ if (s.x > 1) {
+ if (s.s != 0) {
+ return *p;
+ }
+ }
+
+ return 'a';
+}
+
+// BasicStore handles this case incorrectly because it doesn't reason about
+// the value pointed to by 'x' and thus creates different symbolic values
+// at the declarations of 'a' and 'b' respectively. RegionStore handles
+// it correctly. See the companion test in 'misc-ps-basic-store.m'.
+void test_trivial_symbolic_comparison_pointer_parameter(int *x) {
+ int a = *x;
+ int b = *x;
+ if (a != b) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+}
+
+// This is a modified test from 'misc-ps.m'. Here we have the extra
+// NULL dereferences which are pruned out by RegionStore's symbolic reasoning
+// of fields.
+typedef struct _BStruct { void *grue; } BStruct;
+void testB_aux(void *ptr);
+
+void testB(BStruct *b) {
+ {
+ int *__gruep__ = ((int *)&((b)->grue));
+ int __gruev__ = *__gruep__;
+ int __gruev2__ = *__gruep__;
+ if (__gruev__ != __gruev2__) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+
+ testB_aux(__gruep__);
+ }
+ {
+ int *__gruep__ = ((int *)&((b)->grue));
+ int __gruev__ = *__gruep__;
+ int __gruev2__ = *__gruep__;
+ if (__gruev__ != __gruev2__) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+
+ if (~0 != __gruev__) {}
+ }
+}
+
+void testB_2(BStruct *b) {
+ {
+ int **__gruep__ = ((int **)&((b)->grue));
+ int *__gruev__ = *__gruep__;
+ testB_aux(__gruep__);
+ }
+ {
+ int **__gruep__ = ((int **)&((b)->grue));
+ int *__gruev__ = *__gruep__;
+ if ((int*)~0 != __gruev__) {}
+ }
+}
+
+// This test case is a reduced case of a caching bug discovered by an
+// assertion failure in RegionStoreManager::BindArray. Essentially the
+// DeclStmt is evaluated twice, but on the second loop iteration the
+// engine caches out. Previously a false transition would cause UnknownVal
+// to bind to the variable, firing an assertion failure. This bug was fixed
+// in r76262.
+void test_declstmt_caching() {
+again:
+ {
+ const char a[] = "I like to crash";
+ goto again;
+ }
+}
+
+//===----------------------------------------------------------------------===//
+// Reduced test case from <rdar://problem/7114618>.
+// Basically a null check is performed on the field value, which is then
+// assigned to a variable and then checked again.
+//===----------------------------------------------------------------------===//
+struct s_7114618 { int *p; };
+void test_rdar_7114618(struct s_7114618 *s) {
+ if (s->p) {
+ int *p = s->p;
+ if (!p) {
+ // Infeasible
+ int *dead = 0;
+ *dead = 0xDEADBEEF; // no-warning
+ }
+ }
+}
+
+// Test pointers increment correctly.
+void f() {
+ int a[2];
+ a[1] = 3;
+ int *p = a;
+ p++;
+ if (*p != 3) {
+ int *q = 0;
+ *q = 3; // no-warning
+ }
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7185607>
+// Bit-fields of a struct should be invalidated when blasting the entire
+// struct with an integer constant.
+//===----------------------------------------------------------------------===//
+struct test_7185607 {
+ int x : 10;
+ int y : 22;
+};
+int rdar_test_7185607() {
+ struct test_7185607 s; // Uninitialized.
+ *((unsigned *) &s) = 0U;
+ return s.x; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7242006> [RegionStore] compound literal assignment with
+// floats not honored
+// This test case is mirrored in misc-ps.m, but this case is a negative.
+//===----------------------------------------------------------------------===//
+typedef float CGFloat;
+typedef struct _NSSize {
+ CGFloat width;
+ CGFloat height;
+} NSSize;
+
+CGFloat rdar7242006_negative(CGFloat x) {
+ NSSize y;
+ return y.width; // expected-warning{{garbage}}
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7249340> - Allow binding of values to symbolic regions.
+// This test case shows how RegionStore tracks the value bound to 'x'
+// after the assignment.
+//===----------------------------------------------------------------------===//
+typedef int* ptr_rdar_7249340;
+void rdar_7249340(ptr_rdar_7249340 x) {
+ *x = 1;
+ if (*x)
+ return;
+ int *p = 0; // This is unreachable.
+ *p = 0xDEADBEEF; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7249327> - This test case tests both value tracking of
+// array values and that we handle symbolic values that are casted
+// between different integer types. Note the assignment 'n = *a++'; here
+// 'n' is and 'int' and '*a' is 'unsigned'. Previously we got a false positive
+// at 'x += *b++' (undefined value) because we got a false path.
+//===----------------------------------------------------------------------===//
+int rdar_7249327_aux(void);
+
+void rdar_7249327(unsigned int A[2*32]) {
+ int B[2*32];
+ int *b;
+ unsigned int *a;
+ int x = 0;
+
+ int n;
+
+ a = A;
+ b = B;
+
+ n = *a++;
+ if (n)
+ *b++ = rdar_7249327_aux();
+
+ a = A;
+ b = B;
+
+ n = *a++; // expected-warning{{Assigned value is always the same as the existing value}}
+ if (n)
+ x += *b++; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6914474> - Check that 'x' is invalidated because its
+// address is passed in as a value to a struct.
+//===----------------------------------------------------------------------===//
+struct doodad_6914474 { int *v; };
+extern void prod_6914474(struct doodad_6914474 *d);
+int rdar_6914474(void) {
+ int x;
+ struct doodad_6914474 d;
+ d.v = &x;
+ prod_6914474(&d);
+ return x; // no-warning
+}
+
+// Test invalidation of a single field.
+struct s_test_field_invalidate {
+ int x;
+};
+extern void test_invalidate_field(int *x);
+int test_invalidate_field_test() {
+ struct s_test_field_invalidate y;
+ test_invalidate_field(&y.x);
+ return y.x; // no-warning
+}
+int test_invalidate_field_test_positive() {
+ struct s_test_field_invalidate y;
+ return y.x; // expected-warning{{garbage}}
+}
+
+// This test case illustrates how a typeless array of bytes casted to a
+// struct should be treated as initialized. RemoveDeadBindings previously
+// had a bug that caused 'x' to lose its default symbolic value after the
+// assignment to 'p', thus causing 'p->z' to evaluate to "undefined".
+struct ArrayWrapper { unsigned char y[16]; };
+struct WrappedStruct { unsigned z; };
+
+void test_handle_array_wrapper_helper();
+
+int test_handle_array_wrapper() {
+ struct ArrayWrapper x;
+ test_handle_array_wrapper_helper(&x);
+ struct WrappedStruct *p = (struct WrappedStruct*) x.y; // expected-warning{{Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption.}}
+ return p->z; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7261075> [RegionStore] crash when
+// handling load: '*((unsigned int *)"????")'
+//===----------------------------------------------------------------------===//
+
+int rdar_7261075(void) {
+ unsigned int var = 0;
+ if (var == *((unsigned int *)"????"))
+ return 1;
+ return 0;
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7275774> false path due to limited pointer
+// arithmetic constraints
+//===----------------------------------------------------------------------===//
+
+void rdar_7275774(void *data, unsigned n) {
+ if (!(data || n == 0))
+ return;
+
+ unsigned short *p = (unsigned short*) data;
+ unsigned short *q = p + (n / 2);
+
+ if (p < q) {
+ // If we reach here, 'p' cannot be null. If 'p' is null, then 'n' must
+ // be '0', meaning that this branch is not feasible.
+ *p = *q; // no-warning
+ }
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7312221>
+//
+// Test that Objective-C instance variables aren't prematurely pruned
+// from the analysis state.
+//===----------------------------------------------------------------------===//
+
+struct rdar_7312221_value { int x; };
+
+@interface RDar7312221
+{
+ struct rdar_7312221_value *y;
+}
+- (void) doSomething_7312221;
+@end
+
+extern struct rdar_7312221_value *rdar_7312221_helper();
+extern int rdar_7312221_helper_2(id o);
+extern void rdar_7312221_helper_3(int z);
+
+@implementation RDar7312221
+- (void) doSomething_7312221 {
+ if (y == 0) {
+ y = rdar_7312221_helper();
+ if (y != 0) {
+ y->x = rdar_7312221_helper_2(self);
+ // The following use of 'y->x' previously triggered a null dereference, as the value of 'y'
+ // before 'y = rdar_7312221_helper()' would be used.
+ rdar_7312221_helper_3(y->x); // no-warning
+ }
+ }
+}
+@end
+
+struct rdar_7312221_container {
+ struct rdar_7312221_value *y;
+};
+
+extern int rdar_7312221_helper_4(struct rdar_7312221_container *s);
+
+// This test case essentially matches the one in [RDar7312221 doSomething_7312221].
+void doSomething_7312221_with_struct(struct rdar_7312221_container *Self) {
+ if (Self->y == 0) {
+ Self->y = rdar_7312221_helper();
+ if (Self->y != 0) {
+ Self->y->x = rdar_7312221_helper_4(Self);
+ rdar_7312221_helper_3(Self->y->x); // no-warning
+ }
+ }
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7332673> - Just more tests cases for regions
+//===----------------------------------------------------------------------===//
+
+void rdar_7332673_test1() {
+ char value[1];
+ if ( *(value) != 1 ) {} // expected-warning{{The left operand of '!=' is a garbage value}}
+}
+int rdar_7332673_test2_aux(char *x);
+void rdar_7332673_test2() {
+ char *value;
+ if ( rdar_7332673_test2_aux(value) != 1 ) {} // expected-warning{{Function call argument is an uninitialized value}}
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7347252>: Because of a bug in
+// RegionStoreManager::RemoveDeadBindings(), the symbol for s->session->p
+// would incorrectly be pruned from the state after the call to
+// rdar7347252_malloc1(), and would incorrectly result in a warning about
+// passing a null pointer to rdar7347252_memcpy().
+//===----------------------------------------------------------------------===//
+
+struct rdar7347252_AA { char *p;};
+typedef struct {
+ struct rdar7347252_AA *session;
+ int t;
+ char *q;
+} rdar7347252_SSL1;
+
+int rdar7347252_f(rdar7347252_SSL1 *s);
+char *rdar7347252_malloc1(int);
+char *rdar7347252_memcpy1(char *d, char *s, int n) __attribute__((nonnull (1,2)));
+
+int rdar7347252(rdar7347252_SSL1 *s) {
+ rdar7347252_f(s); // the SymbolicRegion of 's' is set a default binding of conjured symbol
+ if (s->session->p == ((void*)0)) {
+ if ((s->session->p = rdar7347252_malloc1(10)) == ((void*)0)) {
+ return 0;
+ }
+ rdar7347252_memcpy1(s->session->p, "aa", 2); // no-warning
+ }
+ return 0;
+}
+
+//===----------------------------------------------------------------------===//
+// PR 5316 - "crash when accessing field of lazy compound value"
+// Previously this caused a crash at the MemberExpr '.chr' when loading
+// a field value from a LazyCompoundVal
+//===----------------------------------------------------------------------===//
+
+typedef unsigned int pr5316_wint_t;
+typedef pr5316_wint_t pr5316_REFRESH_CHAR;
+typedef struct {
+ pr5316_REFRESH_CHAR chr;
+}
+pr5316_REFRESH_ELEMENT;
+static void pr5316(pr5316_REFRESH_ELEMENT *dst, const pr5316_REFRESH_ELEMENT *src) {
+ while ((*dst++ = *src++).chr != L'\0') ;
+}
+
+//===----------------------------------------------------------------------===//
+// Exercise creating ElementRegion with symbolic super region.
+//===----------------------------------------------------------------------===//
+void element_region_with_symbolic_superregion(int* p) {
+ int *x;
+ int a;
+ if (p[0] == 1)
+ x = &a;
+ if (p[0] == 1)
+ (void)*x; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// Test returning an out-of-bounds pointer (CWE-466)
+//===----------------------------------------------------------------------===//
+
+static int test_cwe466_return_outofbounds_pointer_a[10];
+int *test_cwe466_return_outofbounds_pointer() {
+ int *p = test_cwe466_return_outofbounds_pointer_a+10;
+ return p; // expected-warning{{Returned pointer value points outside the original object}}
+}
+
+//===----------------------------------------------------------------------===//
+// PR 3135 - Test case that shows that a variable may get invalidated when its
+// address is included in a structure that is passed-by-value to an unknown function.
+//===----------------------------------------------------------------------===//
+
+typedef struct { int *a; } pr3135_structure;
+int pr3135_bar(pr3135_structure *x);
+int pr3135() {
+ int x;
+ pr3135_structure y = { &x };
+ // the call to pr3135_bar may initialize x
+ if (pr3135_bar(&y) && x) // no-warning
+ return 1;
+ return 0;
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7403269> - Test that we handle compound initializers with
+// partially unspecified array values. Previously this caused a crash.
+//===----------------------------------------------------------------------===//
+
+typedef struct RDar7403269 {
+ unsigned x[10];
+ unsigned y;
+} RDar7403269;
+
+void rdar7403269() {
+ RDar7403269 z = { .y = 0 };
+ if (z.x[4] == 0)
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+}
+
+typedef struct RDar7403269_b {
+ struct zorg { int w; int k; } x[10];
+ unsigned y;
+} RDar7403269_b;
+
+void rdar7403269_b() {
+ RDar7403269_b z = { .y = 0 };
+ if (z.x[5].w == 0)
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+}
+
+void rdar7403269_b_pos() {
+ RDar7403269_b z = { .y = 0 };
+ if (z.x[5].w == 1)
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning{{Dereference of null pointer}}
+}
+
+
+//===----------------------------------------------------------------------===//
+// Test that incrementing a non-null pointer results in a non-null pointer.
+// (<rdar://problem/7191542>)
+//===----------------------------------------------------------------------===//
+
+void test_increment_nonnull_rdar_7191542(const char *path) {
+ const char *alf = 0;
+
+ for (;;) {
+ // When using basic-store, we get a null dereference here because we lose information
+ // about path after the pointer increment.
+ char c = *path++; // no-warning
+ if (c == 'a') {
+ alf = path;
+ }
+
+ if (alf)
+ return;
+ }
+}
+
+//===----------------------------------------------------------------------===//
+// Test that the store (implicitly) tracks values for doubles/floats that are
+// uninitialized (<rdar://problem/6811085>)
+//===----------------------------------------------------------------------===//
+
+double rdar_6811085(void) {
+ double u;
+ return u + 10; // expected-warning{{The left operand of '+' is a garbage value}}
+}
+
+//===----------------------------------------------------------------------===//
+// Path-sensitive tests for blocks.
+//===----------------------------------------------------------------------===//
+
+void indirect_block_call(void (^f)());
+
+int blocks_1(int *p, int z) {
+ __block int *q = 0;
+ void (^bar)() = ^{ q = p; };
+
+ if (z == 1) {
+ // The call to 'bar' might cause 'q' to be invalidated.
+ bar();
+ *q = 0x1; // no-warning
+ }
+ else if (z == 2) {
+ // The function 'indirect_block_call' might invoke bar, thus causing
+ // 'q' to possibly be invalidated.
+ indirect_block_call(bar);
+ *q = 0x1; // no-warning
+ }
+ else {
+ *q = 0xDEADBEEF; // expected-warning{{Dereference of null pointer}}
+ }
+ return z;
+}
+
+int blocks_2(int *p, int z) {
+ int *q = 0;
+ void (^bar)(int **) = ^(int **r){ *r = p; };
+
+ if (z) {
+ // The call to 'bar' might cause 'q' to be invalidated.
+ bar(&q);
+ *q = 0x1; // no-warning
+ }
+ else {
+ *q = 0xDEADBEEF; // expected-warning{{Dereference of null pointer}}
+ }
+ return z;
+}
+
+// Test that the value of 'x' is considered invalidated after the block
+// is passed as an argument to the message expression.
+typedef void (^RDar7582031CB)(void);
+@interface RDar7582031
+- rdar7582031:RDar7582031CB;
+- rdar7582031_b:RDar7582031CB;
+@end
+
+// Test with one block.
+unsigned rdar7582031(RDar7582031 *o) {
+ __block unsigned x;
+ [o rdar7582031:^{ x = 1; }];
+ return x; // no-warning
+}
+
+// Test with two blocks.
+unsigned long rdar7582031_b(RDar7582031 *o) {
+ __block unsigned y;
+ __block unsigned long x;
+ [o rdar7582031:^{ y = 1; }];
+ [o rdar7582031_b:^{ x = 1LL; }];
+ return x + (unsigned long) y; // no-warning
+}
+
+// Show we get an error when 'o' is null because the message
+// expression has no effect.
+unsigned long rdar7582031_b2(RDar7582031 *o) {
+ __block unsigned y;
+ __block unsigned long x;
+ if (o)
+ return 1;
+ [o rdar7582031:^{ y = 1; }];
+ [o rdar7582031_b:^{ x = 1LL; }];
+ return x + (unsigned long) y; // expected-warning{{The left operand of '+' is a garbage value}}
+}
+
+// Show that we handle static variables also getting invalidated.
+void rdar7582031_aux(void (^)(void));
+RDar7582031 *rdar7582031_aux_2();
+
+unsigned rdar7582031_static() {
+ static RDar7582031 *o = 0;
+ rdar7582031_aux(^{ o = rdar7582031_aux_2(); });
+
+ __block unsigned x;
+ [o rdar7582031:^{ x = 1; }];
+ return x; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7462324> - Test that variables passed using __blocks
+// are not treated as being uninitialized.
+//===----------------------------------------------------------------------===//
+
+typedef void (^RDar_7462324_Callback)(id obj);
+
+@interface RDar7462324
+- (void) foo:(id)target;
+- (void) foo_positive:(id)target;
+
+@end
+
+@implementation RDar7462324
+- (void) foo:(id)target {
+ __block RDar_7462324_Callback builder = ((void*) 0);
+ builder = ^(id object) {
+ if (object) {
+ builder(self); // no-warning
+ }
+ };
+ builder(target);
+}
+- (void) foo_positive:(id)target {
+ __block RDar_7462324_Callback builder = ((void*) 0);
+ builder = ^(id object) {
+ id x;
+ if (object) {
+ builder(x); // expected-warning{{Function call argument is an uninitialized value}}
+ }
+ };
+ builder(target);
+}
+@end
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7468209> - Scanning for live variables within a block should
+// not crash on variables passed by reference via __block.
+//===----------------------------------------------------------------------===//
+
+int rdar7468209_aux();
+void rdar7468209_aux_2();
+
+void rdar7468209() {
+ __block int x = 0;
+ ^{
+ x = rdar7468209_aux();
+ // We need a second statement so that 'x' would be removed from the store if it wasn't
+ // passed by reference.
+ rdar7468209_aux_2();
+ }();
+}
+
+//===----------------------------------------------------------------------===//
+// PR 5857 - Test loading an integer from a byte array that has also been
+// reinterpreted to be loaded as a field.
+//===----------------------------------------------------------------------===//
+
+typedef struct { int x; } TestFieldLoad;
+int pr5857(char *src) {
+ TestFieldLoad *tfl = (TestFieldLoad *) (intptr_t) src;
+ int y = tfl->x;
+ long long *z = (long long *) (intptr_t) src;
+ long long w = 0;
+ int n = 0;
+ for (n = 0; n < y; ++n) {
+ // Previously we crashed analyzing this statement.
+ w = *z++;
+ }
+ return 1;
+}
+
+//===----------------------------------------------------------------------===//
+// PR 4358 - Without field-sensitivity, this code previously triggered
+// a false positive that 'uninit' could be uninitialized at the call
+// to pr4358_aux().
+//===----------------------------------------------------------------------===//
+
+struct pr4358 {
+ int bar;
+ int baz;
+};
+void pr4358_aux(int x);
+void pr4358(struct pr4358 *pnt) {
+ int uninit;
+ if (pnt->bar < 3) {
+ uninit = 1;
+ } else if (pnt->baz > 2) {
+ uninit = 3;
+ } else if (pnt->baz <= 2) {
+ uninit = 2;
+ }
+ pr4358_aux(uninit); // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7526777>
+// Test handling fields of values returned from function calls or
+// message expressions.
+//===----------------------------------------------------------------------===//
+
+typedef struct testReturn_rdar_7526777 {
+ int x;
+ int y;
+} testReturn_rdar_7526777;
+
+@interface TestReturnStruct_rdar_7526777
+- (testReturn_rdar_7526777) foo;
+@end
+
+int test_return_struct(TestReturnStruct_rdar_7526777 *x) {
+ return [x foo].x;
+}
+
+testReturn_rdar_7526777 test_return_struct_2_aux_rdar_7526777();
+
+int test_return_struct_2_rdar_7526777() {
+ return test_return_struct_2_aux_rdar_7526777().x;
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7527292> Assertion failed: (Op == BinaryOperator::Add ||
+// Op == BinaryOperator::Sub)
+// This test case previously triggered an assertion failure due to a discrepancy
+// been the loaded/stored value in the array
+//===----------------------------------------------------------------------===//
+
+_Bool OSAtomicCompareAndSwapPtrBarrier( void *__oldValue, void *__newValue, void * volatile *__theValue );
+
+void rdar_7527292() {
+ static id Cache7527292[32];
+ for (signed long idx = 0;
+ idx < 32;
+ idx++) {
+ id v = Cache7527292[idx];
+ if (v && OSAtomicCompareAndSwapPtrBarrier(v, ((void*)0), (void * volatile *)(Cache7527292 + idx))) {
+ }
+ }
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7515938> - Handle initialization of incomplete arrays
+// in structures using a compound value. Previously this crashed.
+//===----------------------------------------------------------------------===//
+
+struct rdar_7515938 {
+ int x;
+ int y[];
+};
+
+const struct rdar_7515938 *rdar_7515938() {
+ static const struct rdar_7515938 z = { 0, { 1, 2 } };
+ if (z.y[0] != 1) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+ return &z;
+}
+
+struct rdar_7515938_str {
+ int x;
+ char y[];
+};
+
+const struct rdar_7515938_str *rdar_7515938_str() {
+ static const struct rdar_7515938_str z = { 0, "hello" };
+ return &z;
+}
+
+//===----------------------------------------------------------------------===//
+// Assorted test cases from PR 4172.
+//===----------------------------------------------------------------------===//
+
+struct PR4172A_s { int *a; };
+
+void PR4172A_f2(struct PR4172A_s *p);
+
+int PR4172A_f1(void) {
+ struct PR4172A_s m;
+ int b[4];
+ m.a = b;
+ PR4172A_f2(&m);
+ return b[3]; // no-warning
+}
+
+struct PR4172B_s { int *a; };
+
+void PR4172B_f2(struct PR4172B_s *p);
+
+int PR4172B_f1(void) {
+ struct PR4172B_s m;
+ int x;
+ m.a = &x;
+ PR4172B_f2(&m);
+ return x; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// Test invalidation of values in struct literals.
+//===----------------------------------------------------------------------===//
+
+struct s_rev96062 { int *x; int *y; };
+struct s_rev96062_nested { struct s_rev96062 z; };
+
+void test_a_rev96062_aux(struct s_rev96062 *s);
+void test_a_rev96062_aux2(struct s_rev96062_nested *s);
+
+int test_a_rev96062() {
+ int a, b;
+ struct s_rev96062 x = { &a, &b };
+ test_a_rev96062_aux(&x);
+ return a + b; // no-warning
+}
+int test_b_rev96062() {
+ int a, b;
+ struct s_rev96062 x = { &a, &b };
+ struct s_rev96062 z = x;
+ test_a_rev96062_aux(&z);
+ return a + b; // no-warning
+}
+int test_c_rev96062() {
+ int a, b;
+ struct s_rev96062 x = { &a, &b };
+ struct s_rev96062_nested w = { x };
+ struct s_rev96062_nested z = w;
+ test_a_rev96062_aux2(&z);
+ return a + b; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7242010> - The access to y[0] at the bottom previously
+// was reported as an uninitialized value.
+//===----------------------------------------------------------------------===//
+
+char *rdar_7242010(int count, char **y) {
+ char **x = alloca((count + 4) * sizeof(*x));
+ x[0] = "hi";
+ x[1] = "there";
+ x[2] = "every";
+ x[3] = "body";
+ memcpy(x + 4, y, count * sizeof(*x));
+ y = x;
+ return y[0]; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7770737>
+//===----------------------------------------------------------------------===//
+
+struct rdar_7770737_s { intptr_t p; };
+void rdar_7770737_aux(struct rdar_7770737_s *p);
+int rdar_7770737(void)
+{
+ int x;
+
+ // Previously 'f' was not properly invalidated, causing the use of
+ // an uninitailized value below.
+ struct rdar_7770737_s f = { .p = (intptr_t)&x };
+ rdar_7770737_aux(&f);
+ return x; // no-warning
+}
+int rdar_7770737_pos(void)
+{
+ int x;
+ struct rdar_7770737_s f = { .p = (intptr_t)&x };
+ return x; // expected-warning{{Undefined or garbage value returned to caller}}
+}
+
+//===----------------------------------------------------------------------===//
+// Test handling of the implicit 'isa' field. For now we don't do anything
+// interesting.
+//===----------------------------------------------------------------------===//
+
+void pr6302(id x, Class y) {
+ // This previously crashed the analyzer (reported in PR 6302)
+ x->isa = y; // expected-warning {{direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()}}
+}
+
+//===----------------------------------------------------------------------===//
+// Specially handle global variables that are declared constant. In the
+// example below, this forces the loop to take exactly 2 iterations.
+//===----------------------------------------------------------------------===//
+
+const int pr6288_L_N = 2;
+void pr6288_(void) {
+ int x[2];
+ int *px[2];
+ int i;
+ for (i = 0; i < pr6288_L_N; i++)
+ px[i] = &x[i];
+ *(px[0]) = 0; // no-warning
+}
+
+void pr6288_pos(int z) {
+ int x[2];
+ int *px[2];
+ int i;
+ for (i = 0; i < z; i++)
+ px[i] = &x[i]; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
+ *(px[0]) = 0; // expected-warning{{Dereference of undefined pointer value}}
+}
+
+void pr6288_b(void) {
+ const int L_N = 2;
+ int x[2];
+ int *px[2];
+ int i;
+ for (i = 0; i < L_N; i++)
+ px[i] = &x[i];
+ *(px[0]) = 0; // no-warning
+}
+
+// <rdar://problem/7817800> - A bug in RemoveDeadBindings was causing instance variable bindings
+// to get prematurely pruned from the state.
+@interface Rdar7817800 {
+ char *x;
+}
+- (void) rdar7817800_baz;
+@end
+
+char *rdar7817800_foobar();
+void rdar7817800_qux(void*);
+
+@implementation Rdar7817800
+- (void) rdar7817800_baz {
+ if (x)
+ rdar7817800_qux(x);
+ x = rdar7817800_foobar();
+ // Previously this triggered a bogus null dereference warning.
+ x[1] = 'a'; // no-warning
+}
+@end
+
+// PR 6036 - This test case triggered a crash inside StoreManager::CastRegion because the size
+// of 'unsigned long (*)[0]' is 0.
+struct pr6036_a { int pr6036_b; };
+struct pr6036_c;
+void u132monitk (struct pr6036_c *pr6036_d) {
+ (void) ((struct pr6036_a *) (unsigned long (*)[0]) ((char *) pr6036_d - 1))->pr6036_b; // expected-warning{{Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption}}
+}
+
+// <rdar://problem/7813989> - ?-expressions used as a base of a member expression should be treated as an lvalue
+typedef struct rdar7813989_NestedVal { int w; } rdar7813989_NestedVal;
+typedef struct rdar7813989_Val { rdar7813989_NestedVal nv; } rdar7813989_Val;
+
+int rdar7813989(int x, rdar7813989_Val *a, rdar7813989_Val *b) {
+ // This previously crashed with an assertion failure.
+ int z = (x ? a->nv : b->nv).w;
+ return z + 1;
+}
+
+// PR 6844 - Don't crash on vaarg expression.
+typedef __builtin_va_list va_list;
+void map(int srcID, ...) {
+ va_list ap;
+ int i;
+ for (i = 0; i < srcID; i++) {
+ int v = __builtin_va_arg(ap, int);
+ }
+}
+
+// PR 6854 - crash when casting symbolic memory address to a float
+// Handle casting from a symbolic region to a 'float'. This isn't
+// really all that intelligent, but previously this caused a crash
+// in SimpleSValuator.
+void pr6854(void * arg) {
+ void * a = arg;
+ *(void**)a = arg;
+ float f = *(float*) a;
+}
+
+// <rdar://problem/8032791> False positive due to symbolic store not find
+// value because of 'const' qualifier
+double rdar_8032791_2();
+double rdar_8032791_1() {
+ struct R8032791 { double x[2]; double y; }
+ data[3] = {
+ {{1.0, 3.0}, 3.0}, // 1 2 3
+ {{1.0, 1.0}, 0.0}, // 1 1 2 2 3 3
+ {{1.0, 3.0}, 1.0} // 1 2 3
+ };
+
+ double x = 0.0;
+ for (unsigned i = 0 ; i < 3; i++) {
+ const struct R8032791 *p = &data[i];
+ x += p->y + rdar_8032791_2(); // no-warning
+ }
+ return x;
+}
+
+// PR 7450 - Handle pointer arithmetic with __builtin_alloca
+void pr_7450_aux(void *x);
+void pr_7450() {
+ void *p = __builtin_alloca(10);
+ // Don't crash when analyzing the following statement.
+ pr_7450_aux(p + 8);
+}
+
+// <rdar://problem/8243408> - Symbolicate struct values returned by value.
+struct s_rdar_8243408 { int x; };
+extern struct s_rdar_8243408 rdar_8243408_aux(void);
+void rdar_8243408(void) {
+ struct s_rdar_8243408 a = { 1 }, *b = 0;
+ while (a.x && !b)
+ a = rdar_8243408_aux();
+
+ // Previously there was a false error here with 'b' being null.
+ (void) (a.x && b->x); // no-warning
+
+ // Introduce a null deref to ensure we are checking this path.
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning{{Dereference of null pointer}}
+}
+
+// <rdar://problem/8258814>
+int r8258814()
+{
+ int foo;
+ int * a = &foo;
+ a[0] = 10;
+ // Do not warn that the value of 'foo' is uninitialized.
+ return foo; // no-warning
+}
+
+// PR 8052 - Don't crash when reasoning about loads from a function address.\n
+typedef unsigned int __uint32_t;
+typedef unsigned long vm_offset_t;
+typedef __uint32_t pd_entry_t;
+typedef unsigned char u_char;
+typedef unsigned int u_int;
+typedef unsigned long u_long;
+extern int bootMP_size;
+void bootMP(void);
+static void
+pr8052(u_int boot_addr)
+{
+ int x;
+ int size = *(int *) ((u_long) & bootMP_size);
+ u_char *src = (u_char *) ((u_long) bootMP);
+ u_char *dst = (u_char *) boot_addr + ((vm_offset_t) ((((((((1 <<
+12) / (sizeof(pd_entry_t))) - 1) - 1) - (260 - 2))) << 22) | ((0) << 12)));
+ for (x = 0;
+ x < size;
+ ++x)
+ *dst++ = *src++;
+}
+
+// PR 8015 - don't return undefined values for arrays when using a valid
+// symbolic index
+int pr8015_A();
+void pr8015_B(const char *);
+
+void pr8015_C() {
+ int number = pr8015_A();
+ const char *numbers[] = { "zero" };
+ if (number == 0) {
+ pr8015_B(numbers[number]); // no-warning
+ }
+}
+
+// Tests that we correctly handle that 'number' is perfectly constrained
+// after 'if (nunber == 0)', allowing us to resolve that
+// numbers[number] == numbers[0].
+void pr8015_D_FIXME() {
+ int number = pr8015_A();
+ const char *numbers[] = { "zero" };
+ if (number == 0) {
+ if (numbers[number] == numbers[0]) // expected-warning{{Both operands to '==' always have the same value}}
+ return;
+ // Unreachable.
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warnng
+ }
+}
+
+void pr8015_E() {
+ // Similar to pr8015_C, but number is allowed to be a valid range.
+ unsigned number = pr8015_A();
+ const char *numbers[] = { "zero", "one", "two" };
+ if (number < 3) {
+ pr8015_B(numbers[number]); // no-warning
+ }
+}
+
+void pr8015_F_FIXME() {
+ // Similar to pr8015_E, but like pr8015_D we check if the pointer
+ // is the same as one of the string literals. The null dereference
+ // here is not feasible in practice, so this is a false positive.
+ int number = pr8015_A();
+ const char *numbers[] = { "zero", "one", "two" };
+ if (number < 3) {
+ const char *p = numbers[number];
+ if (p == numbers[0] || p == numbers[1] || p == numbers[2])
+ return;
+ int *q = 0;
+ *q = 0xDEADBEEF; // expected-warning{{Dereference of null pointer}}
+ }
+}
+
+// PR 8141. Previously the statement expression in the for loop caused
+// the CFG builder to crash.
+struct list_pr8141
+{
+ struct list_pr8141 *tail;
+};
+
+struct list_pr8141 *
+pr8141 (void) {
+ struct list_pr8141 *items;
+ for (;; items = ({ do { } while (0); items->tail; })) // expected-warning{{Dereference of undefined pointer value}}
+ {
+ }
+}
+
+// Don't crash when building the CFG.
+void do_not_crash(int x) {
+ while (x - ({do {} while (0); x; })) {
+ }
+}
+
+// <rdar://problem/8424269> - Handle looking at the size of a VLA in
+// ArrayBoundChecker. Nothing intelligent (yet); just don't crash.
+typedef struct RDar8424269_A {
+ int RDar8424269_C;
+} RDar8424269_A;
+static void RDar8424269_B(RDar8424269_A *p, unsigned char *RDar8424269_D,
+ const unsigned char *RDar8424269_E, int RDar8424269_F,
+ int b_w, int b_h, int dx, int dy) {
+ int x, y, b, r, l;
+ unsigned char tmp2t[3][RDar8424269_F * (32 + 8)];
+ unsigned char *tmp2 = tmp2t[0];
+ if (p && !p->RDar8424269_C)
+ b = 15;
+ tmp2 = tmp2t[1];
+ if (b & 2) { // expected-warning{{The left operand of '&' is a garbage value}}
+ for (y = 0; y < b_h; y++) {
+ for (x = 0; x < b_w + 1; x++) {
+ int am = 0;
+ tmp2[x] = am;
+ }
+ }
+ }
+ tmp2 = tmp2t[2];
+}
+
+// <rdar://problem/8642434> - Handle transparent unions with the AttrNonNullChecker.
+typedef union {
+ struct rdar_8642434_typeA *_dq;
+}
+rdar_8642434_typeB __attribute__((transparent_union));
+
+__attribute__((visibility("default"))) __attribute__((__nonnull__)) __attribute__((__nothrow__))
+void rdar_8642434_funcA(rdar_8642434_typeB object);
+
+void rdar_8642434_funcB(struct rdar_8642434_typeA *x, struct rdar_8642434_typeA *y) {
+ rdar_8642434_funcA(x);
+ if (!y)
+ rdar_8642434_funcA(y); // expected-warning{{Null pointer passed as an argument to a 'nonnull' parameter}}
+}
+
+// <rdar://problem/8848957> - Handle loads and stores from a symbolic index
+// into array without warning about an uninitialized value being returned.
+// While RegionStore can't fully reason about this example, it shouldn't
+// warn here either.
+typedef struct s_test_rdar8848957 {
+ int x, y, z;
+} s_test_rdar8848957;
+
+s_test_rdar8848957 foo_rdar8848957();
+int rdar8848957(int index) {
+ s_test_rdar8848957 vals[10];
+ vals[index] = foo_rdar8848957();
+ return vals[index].x; // no-warning
+}
+
+// PR 9049 - crash on symbolicating unions. This test exists solely to
+// test that the analyzer doesn't crash.
+typedef struct pr9048_cdev *pr9048_cdev_t;
+typedef union pr9048_abstracted_disklabel { void *opaque; } pr9048_disklabel_t;
+struct pr9048_diskslice { pr9048_disklabel_t ds_label; };
+struct pr9048_diskslices {
+ int dss_secmult;
+ struct pr9048_diskslice dss_slices[16];
+};
+void pr9048(pr9048_cdev_t dev, struct pr9048_diskslices * ssp, unsigned int slice)
+{
+ pr9048_disklabel_t lp;
+ struct pr9048_diskslice *sp;
+ sp = &ssp->dss_slices[slice];
+ if (ssp->dss_secmult == 1) {
+ } else if ((lp = sp->ds_label).opaque != ((void *) 0)) {
+ }
+}
+
+// Test Store reference counting in the presence of Lazy compound values.
+// This previously caused an infinite recursion.
+typedef struct {} Rdar_9103310_A;
+typedef struct Rdar_9103310_B Rdar_9103310_B_t;
+struct Rdar_9103310_B {
+ unsigned char Rdar_9103310_C[101];
+};
+void Rdar_9103310_E(Rdar_9103310_A * x, struct Rdar_9103310_C * b) { // expected-warning {{declaration of 'struct Rdar_9103310_C' will not be visible outside of this function}}
+ char Rdar_9103310_D[4][4] = { "a", "b", "c", "d"};
+ int i;
+ Rdar_9103310_B_t *y = (Rdar_9103310_B_t *) x;
+ for (i = 0; i < 101; i++) {
+ Rdar_9103310_F(b, "%2d%s ", (y->Rdar_9103310_C[i]) / 4, Rdar_9103310_D[(y->Rdar_9103310_C[i]) % 4]); // expected-warning {{implicit declaration of function 'Rdar_9103310_F' is invalid in C99}}
+ }
+}
+
+// Test handling binding lazy compound values to a region and then have
+// specific elements have other bindings.
+int PR9455() {
+ char arr[4] = "000";
+ arr[0] = '1';
+ if (arr[1] == '0')
+ return 1;
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ return 1;
+}
+int PR9455_2() {
+ char arr[4] = "000";
+ arr[0] = '1';
+ if (arr[1] == '0') {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+ }
+ return 1;
+}
+
+// Test initialization of substructs via lazy compound values.
+typedef float RDar9163742_Float;
+
+typedef struct {
+ RDar9163742_Float x, y;
+} RDar9163742_Point;
+typedef struct {
+ RDar9163742_Float width, height;
+} RDar9163742_Size;
+typedef struct {
+ RDar9163742_Point origin;
+ RDar9163742_Size size;
+} RDar9163742_Rect;
+
+extern RDar9163742_Rect RDar9163742_RectIntegral(RDar9163742_Rect);
+
+RDar9163742_Rect RDar9163742_IntegralRect(RDar9163742_Rect frame)
+{
+ RDar9163742_Rect integralFrame;
+ integralFrame.origin.x = frame.origin.x;
+ integralFrame.origin.y = frame.origin.y;
+ integralFrame.size = frame.size;
+ return RDar9163742_RectIntegral(integralFrame); // no-warning; all fields initialized
+}
+
+// Test correct handling of prefix '--' operator.
+void rdar9444714() {
+ int x;
+ char str[ 32 ];
+ char buf[ 32 ];
+ char * dst;
+ char * ptr;
+
+ x = 1234;
+ dst = str;
+ ptr = buf;
+ do
+ {
+ *ptr++ = (char)( '0' + ( x % 10 ) );
+ x /= 10;
+ } while( x > 0 );
+
+ while( ptr > buf )
+ {
+ *dst++ = *( --( ptr ) ); // no-warning
+ }
+ *dst = '\0';
+}
+
+// Test handling symbolic elements with field accesses.
+// <rdar://problem/11127008>
+typedef struct {
+ unsigned value;
+} RDar11127008;
+
+signed rdar_11127008_index();
+
+static unsigned rdar_11127008(void) {
+ RDar11127008 values[] = {{.value = 0}, {.value = 1}};
+ signed index = rdar_11127008_index();
+ if (index < 0) return 0;
+ if (index >= 2) return 0;
+ return values[index].value;
+}
+
diff --git a/clang/test/Analysis/misc-ps-region-store.mm b/clang/test/Analysis/misc-ps-region-store.mm
new file mode 100644
index 0000000..8615c6a
--- /dev/null
+++ b/clang/test/Analysis/misc-ps-region-store.mm
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
+
+//===------------------------------------------------------------------------------------------===//
+// This files tests our path-sensitive handling of Objective-c++ files.
+//===------------------------------------------------------------------------------------------===//
+
+// Test basic handling of references.
+char &test1_aux();
+char *test1() {
+ return &test1_aux();
+}
+
+// Test test1_aux() evaluates to char &.
+char test1_as_rvalue() {
+ return test1_aux();
+}
+
+// Test basic handling of references with Objective-C classes.
+@interface Test1
+- (char&) foo;
+@end
+
+char* Test1_harness(Test1 *p) {
+ return &[p foo];
+}
+
+char Test1_harness_b(Test1 *p) {
+ return [p foo];
+}
+
+// Basic test of C++ references with Objective-C pointers.
+@interface RDar10569024
+@property(readonly) int x;
+@end
+
+typedef RDar10569024* RDar10569024Ref;
+
+void rdar10569024_aux(RDar10569024Ref o);
+
+int rdar10569024(id p, id collection) {
+ for (id elem in collection) {
+ const RDar10569024Ref &o = (RDar10569024Ref) elem;
+ rdar10569024_aux(o); // no-warning
+ return o.x; // no-warning
+ }
+ return 0;
+}
diff --git a/clang/test/Analysis/misc-ps.c b/clang/test/Analysis/misc-ps.c
new file mode 100644
index 0000000..f81b0dd
--- /dev/null
+++ b/clang/test/Analysis/misc-ps.c
@@ -0,0 +1,128 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -disable-free -analyzer-eagerly-assume -analyzer-checker=core -analyzer-checker=deadcode -verify %s
+
+int size_rdar9373039 = 1;
+int foo_rdar9373039(const char *);
+
+int rdar93730392() {
+ int x;
+ int j = 0;
+
+ for (int i = 0 ; i < size_rdar9373039 ; ++i)
+ x = 1;
+
+ int extra = (2 + foo_rdar9373039 ("Clang") + ((4 - ((unsigned int) (2 + foo_rdar9373039 ("Clang")) % 4)) % 4)) + (2 + foo_rdar9373039 ("1.0") + ((4 - ((unsigned int) (2 + foo_rdar9373039 ("1.0")) % 4)) % 4)); // expected-warning {{never read}}
+
+ for (int i = 0 ; i < size_rdar9373039 ; ++i)
+ j += x; // expected-warning {{garbage}}
+
+ return j;
+}
+
+
+int PR8962 (int *t) {
+ // This should look through the __extension__ no-op.
+ if (__extension__ (t)) return 0;
+ return *t; // expected-warning {{null pointer}}
+}
+
+int PR8962_b (int *t) {
+ // This should still ignore the nested casts
+ // which aren't handled by a single IgnoreParens()
+ if (((int)((int)t))) return 0;
+ return *t; // expected-warning {{null pointer}}
+}
+
+int PR8962_c (int *t) {
+ // If the last element in a StmtExpr was a ParenExpr, it's still live
+ if (({ (t ? (_Bool)0 : (_Bool)1); })) return 0;
+ return *t; // no-warning
+}
+
+int PR8962_d (int *t) {
+ // If the last element in a StmtExpr is an __extension__, it's still live
+ if (({ __extension__(t ? (_Bool)0 : (_Bool)1); })) return 0;
+ return *t; // no-warning
+}
+
+int PR8962_e (int *t) {
+ // Redundant casts can mess things up!
+ // Environment used to skip through NoOp casts, but LiveVariables didn't!
+ if (({ (t ? (int)(int)0L : (int)(int)1L); })) return 0;
+ return *t; // no-warning
+}
+
+int PR8962_f (int *t) {
+ // The StmtExpr isn't a block-level expression here,
+ // the __extension__ is. But the value should be attached to the StmtExpr
+ // anyway. Make sure the block-level check is /before/ IgnoreParens.
+ if ( __extension__({
+ _Bool r;
+ if (t) r = 0;
+ else r = 1;
+ r;
+ }) ) return 0;
+ return *t; // no-warning
+}
+
+// This previously crashed logic in the analyzer engine when evaluating locations.
+void rdar10308201_aux(unsigned val);
+void rdar10308201 (int valA, void *valB, unsigned valC) {
+ unsigned actual_base, lines;
+ if (valC == 0) {
+ actual_base = (unsigned)valB;
+ for (;;) {
+ if (valA & (1<<0))
+ rdar10308201_aux(actual_base);
+ }
+ }
+}
+
+typedef struct Struct103 {
+ unsigned i;
+} Struct103;
+typedef unsigned int size_t;
+void __my_memset_chk(char*, int, size_t);
+static int radar10367606(int t) {
+ Struct103 overall;
+ ((__builtin_object_size ((char *) &overall, 0) != (size_t) -1) ? __builtin___memset_chk ((char *) &overall, 0, sizeof(Struct103), __builtin_object_size ((char *) &overall, 0)) : __my_memset_chk ((char *) &overall, 0, sizeof(Struct103)));
+ return 0;
+}
+
+/* Caching out on a sink node. */
+extern int fooR10376675();
+extern int* bazR10376675();
+extern int nR10376675;
+void barR10376675(int *x) {
+ int *pm;
+ if (nR10376675 * 2) {
+ int *pk = bazR10376675();
+ pm = pk; //expected-warning {{never read}}
+ }
+ do {
+ *x = fooR10376675();
+ } while (0);
+}
+
+// Test accesses to wide character strings doesn't break the analyzer.
+typedef int wchar_t;
+struct rdar10385775 {
+ wchar_t *name;
+};
+void RDar10385775(struct rdar10385775* p) {
+ p->name = L"a";
+}
+
+// Test double loop of array and array literals. Previously this
+// resulted in a false positive uninitailized value warning.
+void rdar10686586() {
+ int array1[] = { 1, 2, 3, 0 };
+ int array2[] = { 1, 2, 3, 0 };
+ int *array[] = { array1, array2 };
+ int sum = 0;
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < 4; j++) {
+ sum += array[i][j]; // no-warning
+ }
+ }
+}
+
diff --git a/clang/test/Analysis/misc-ps.m b/clang/test/Analysis/misc-ps.m
new file mode 100644
index 0000000..9d2ff5b
--- /dev/null
+++ b/clang/test/Analysis/misc-ps.m
@@ -0,0 +1,1347 @@
+// NOTE: Use '-fobjc-gc' to test the analysis being run twice, and multiple reports are not issued.
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+
+#ifndef __clang_analyzer__
+#error __clang_analyzer__ not defined
+#endif
+
+typedef struct objc_ivar *Ivar;
+typedef struct objc_selector *SEL;
+typedef signed char BOOL;
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSArray, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)autorelease;
+@end
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
+@protocol NSCoding
+- (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
+- (id)init;
++ (id)allocWithZone:(NSZone *)zone;
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
++ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
+@end extern NSString * const NSBundleDidLoadNotification;
+@interface NSValue : NSObject <NSCopying, NSCoding>
+- (void)getValue:(void *)value;
+@end
+@interface NSNumber : NSValue
+- (char)charValue;
+- (id)initWithBool:(BOOL)value;
+@end
+@interface NSAssertionHandler : NSObject {}
++ (NSAssertionHandler *)currentHandler;
+- (void)handleFailureInMethod:(SEL)selector object:(id)object file:(NSString *)fileName lineNumber:(NSInteger)line description:(NSString *)format,...;
+@end
+extern NSString * const NSConnectionReplyMode;
+typedef float CGFloat;
+typedef struct _NSPoint {
+ CGFloat x;
+ CGFloat y;
+} NSPoint;
+typedef struct _NSSize {
+ CGFloat width;
+ CGFloat height;
+} NSSize;
+typedef struct _NSRect {
+ NSPoint origin;
+ NSSize size;
+} NSRect;
+
+// Reduced test case from crash in <rdar://problem/6253157>
+@interface A @end
+@implementation A
+- (void)foo:(void (^)(NSObject *x))block {
+ if (!((block != ((void *)0)))) {}
+}
+@end
+
+// Reduced test case from crash in PR 2796;
+// http://llvm.org/bugs/show_bug.cgi?id=2796
+
+unsigned foo(unsigned x) { return __alignof__((x)) + sizeof(x); }
+
+// Improvement to path-sensitivity involving compound assignments.
+// Addresses false positive in <rdar://problem/6268365>
+//
+
+unsigned r6268365Aux();
+
+void r6268365() {
+ unsigned x = 0;
+ x &= r6268365Aux(); // expected-warning{{The left operand to '&=' is always 0}}
+ unsigned j = 0;
+
+ if (x == 0) ++j;
+ if (x == 0) x = x / j; // expected-warning{{Assigned value is always the same as the existing value}} expected-warning{{The right operand to '/' is always 1}}
+}
+
+void divzeroassume(unsigned x, unsigned j) {
+ x /= j;
+ if (j == 0) x /= 0; // no static-analyzer warning expected-warning {{division by zero is undefined}}
+ if (j == 0) x /= j; // no static-analyzer warning
+ if (j == 0) x = x / 0; // no static-analyzer warning expected-warning {{division by zero is undefined}}
+}
+
+void divzeroassumeB(unsigned x, unsigned j) {
+ x = x / j;
+ if (j == 0) x /= 0; // no static-analyzer warning expected-warning {{division by zero is undefined}}
+ if (j == 0) x /= j; // no static-analyzer warning
+ if (j == 0) x = x / 0; // no static-analyzer warning expected-warning {{division by zero is undefined}}
+}
+
+// InitListExpr processing
+
+typedef float __m128 __attribute__((__vector_size__(16), __may_alias__));
+__m128 return128() {
+ // This compound literal has a Vector type. We currently just
+ // return UnknownVal.
+ return __extension__(__m128) { 0.0f, 0.0f, 0.0f, 0.0f };
+}
+
+typedef long long __v2di __attribute__ ((__vector_size__ (16)));
+typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__));
+__m128i vec128i(long long __q1, long long __q0) {
+ // This compound literal returns true for both isVectorType() and
+ // isIntegerType().
+ return __extension__ (__m128i)(__v2di){ __q0, __q1 };
+}
+
+// Zero-sized VLAs.
+void check_zero_sized_VLA(int x) {
+ if (x)
+ return;
+
+ int vla[x]; // expected-warning{{Declared variable-length array (VLA) has zero size}}
+}
+
+void check_uninit_sized_VLA() {
+ int x;
+ int vla[x]; // expected-warning{{Declared variable-length array (VLA) uses a garbage value as its size}}
+}
+
+// sizeof(void)
+// - Tests a regression reported in PR 3211: http://llvm.org/bugs/show_bug.cgi?id=3211
+void handle_sizeof_void(unsigned flag) {
+ int* p = 0;
+
+ if (flag) {
+ if (sizeof(void) == 1)
+ return;
+ // Infeasible.
+ *p = 1; // no-warning
+ }
+
+ void* q;
+
+ if (!flag) {
+ if (sizeof(*q) == 1)
+ return;
+ // Infeasibe.
+ *p = 1; // no-warning
+ }
+
+ // Infeasible.
+ *p = 1; // no-warning
+}
+
+// check deference of undefined values
+void check_deref_undef(void) {
+ int *p;
+ *p = 0xDEADBEEF; // expected-warning{{Dereference of undefined pointer value}}
+}
+
+// PR 3422
+void pr3422_helper(char *p);
+void pr3422() {
+ char buf[100];
+ char *q = &buf[10];
+ pr3422_helper(&q[1]);
+}
+
+// PR 3543 (handle empty statement expressions)
+void pr_3543(void) {
+ ({});
+}
+
+// <rdar://problem/6611677>
+// This test case test the use of a vector type within an array subscript
+// expression.
+typedef long long __a64vector __attribute__((__vector_size__(8)));
+typedef long long __a128vector __attribute__((__vector_size__(16)));
+static inline __a64vector __attribute__((__always_inline__, __nodebug__))
+my_test_mm_movepi64_pi64(__a128vector a) {
+ return (__a64vector)a[0];
+}
+
+// Test basic tracking of ivars associated with 'self'.
+@interface SelfIvarTest : NSObject {
+ int flag;
+}
+- (void)test_self_tracking;
+@end
+
+@implementation SelfIvarTest
+- (void)test_self_tracking {
+ char *p = 0;
+ char c;
+
+ if (flag)
+ p = "hello";
+
+ if (flag)
+ c = *p; // no-warning
+}
+@end
+
+// PR 3770
+char pr3770(int x) {
+ int y = x & 0x2;
+ char *p = 0;
+ if (y == 1)
+ p = "hello";
+
+ if (y == 1)
+ return p[0]; // no-warning
+
+ return 'a';
+}
+
+// PR 3772
+// - We just want to test that this doesn't crash the analyzer.
+typedef struct st ST;
+struct st { char *name; };
+extern ST *Cur_Pu;
+
+void pr3772(void)
+{
+ static ST *last_Cur_Pu;
+ if (last_Cur_Pu == Cur_Pu) {
+ return;
+ }
+}
+
+// PR 3780 - This tests that StmtIterator isn't broken for VLAs in DeclGroups.
+void pr3780(int sz) { typedef double MAT[sz][sz]; }
+
+// <rdar://problem/6695527> - Test that we don't symbolicate doubles before
+// we are ready to do something with them.
+int rdar6695527(double x) {
+ if (!x) { return 0; }
+ return 1;
+}
+
+// <rdar://problem/6708148> - Test that we properly invalidate structs
+// passed-by-reference to a function.
+void pr6708148_invalidate(NSRect *x);
+void pr6708148_use(NSRect x);
+void pr6708148_test(void) {
+ NSRect x;
+ pr6708148_invalidate(&x);
+ pr6708148_use(x); // no-warning
+}
+
+// Handle both kinds of noreturn attributes for pruning paths.
+void rdar_6777003_noret() __attribute__((noreturn));
+void rdar_6777003_analyzer_noret() __attribute__((analyzer_noreturn));
+
+void rdar_6777003(int x) {
+ int *p = 0;
+
+ if (x == 1) {
+ rdar_6777003_noret();
+ *p = 1; // no-warning;
+ }
+
+ if (x == 2) {
+ rdar_6777003_analyzer_noret();
+ *p = 1; // no-warning;
+ }
+
+ *p = 1; // expected-warning{{Dereference of null pointer}}
+}
+
+// Check that the pointer-to-conts arguments do not get invalidated by Obj C
+// interfaces. radar://10595327
+int rdar_10595327(char *str) {
+ char fl = str[0];
+ int *p = 0;
+ NSString *s = [NSString stringWithUTF8String:str];
+ if (str[0] != fl)
+ return *p; // no-warning
+ return 0;
+}
+
+// For pointer arithmetic, --/++ should be treated as preserving non-nullness,
+// regardless of how well the underlying StoreManager reasons about pointer
+// arithmetic.
+// <rdar://problem/6777209>
+void rdar_6777209(char *p) {
+ if (p == 0)
+ return;
+
+ ++p;
+
+ // This branch should always be infeasible.
+ if (p == 0)
+ *p = 'c'; // no-warning
+}
+
+// PR 4033. A symbolic 'void *' pointer can be used as the address for a
+// computed goto.
+typedef void *Opcode;
+Opcode pr_4033_getOpcode();
+void pr_4033(void) {
+ void *lbl = &&next_opcode;
+next_opcode:
+ {
+ Opcode op = pr_4033_getOpcode();
+ if (op) goto *op;
+ }
+}
+
+// Test invalidating pointers-to-pointers with slightly different types. This
+// example came from a recent false positive due to a regression where the
+// branch condition was falsely reported as being uninitialized.
+void invalidate_by_ref(char **x);
+int test_invalidate_by_ref() {
+ unsigned short y;
+ invalidate_by_ref((char**) &y);
+ if (y) // no-warning
+ return 1;
+ return 0;
+}
+
+// Test for <rdar://problem/7027684>. This just tests that the CFG is
+// constructed correctly. Previously, the successor block of the entrance
+// was the block containing the merge for '?', which would trigger an
+// assertion failure.
+int rdar_7027684_aux();
+int rdar_7027684_aux_2() __attribute__((noreturn));
+void rdar_7027684(int x, int y) {
+ {}; // this empty compound statement is critical.
+ (rdar_7027684_aux() ? rdar_7027684_aux_2() : (void) 0);
+}
+
+// Test that we handle casts of string literals to arbitrary types.
+unsigned const char *string_literal_test1() {
+ return (const unsigned char*) "hello";
+}
+
+const float *string_literal_test2() {
+ return (const float*) "hello";
+}
+
+// Test that we handle casts *from* incomplete struct types.
+extern const struct _FooAssertStruct _cmd;
+void test_cast_from_incomplete_struct_aux(volatile const void *x);
+void test_cast_from_incomplete_struct() {
+ test_cast_from_incomplete_struct_aux(&_cmd);
+}
+
+// Test for <rdar://problem/7034511>
+// "ValueManager::makeIntVal(uint64_t X, QualType T) should return a 'Loc'
+// when 'T' is a pointer"
+//
+// Previously this case would crash.
+void test_rdar_7034511(NSArray *y) {
+ NSObject *x;
+ for (x in y) {}
+ if (x == ((void*) 0)) {}
+}
+
+// Handle casts of function pointers (CodeTextRegions) to arbitrary pointer
+// types. This was previously causing a crash in CastRegion.
+void handle_funcptr_voidptr_casts() {
+ void **ptr;
+ typedef void *PVOID;
+ typedef void *PCHAR;
+ typedef long INT_PTR, *PINT_PTR;
+ typedef INT_PTR (*FARPROC)();
+ FARPROC handle_funcptr_voidptr_casts_aux();
+ PVOID handle_funcptr_voidptr_casts_aux_2(PVOID volatile *x);
+ PVOID handle_funcptr_voidptr_casts_aux_3(PCHAR volatile *x);
+
+ ptr = (void**) handle_funcptr_voidptr_casts_aux();
+ handle_funcptr_voidptr_casts_aux_2(ptr);
+ handle_funcptr_voidptr_casts_aux_3(ptr);
+}
+
+// RegionStore::Retrieve previously crashed on this example. This example
+// was previously in the test file 'xfail_regionstore_wine_crash.c'.
+void testA() {
+ long x = 0;
+ char *y = (char *) &x;
+ if (!*y)
+ return;
+}
+
+// RegionStoreManager previously crashed on this example. The problem is that
+// the value bound to the field of b->grue after the call to testB_aux is
+// a symbolic region. The second '*__gruep__' involves performing a load
+// from a 'int*' that really is a 'void**'. The loaded location must be
+// implicitly converted to an integer that wraps a location. Previosly we would
+// get a crash here due to an assertion failure.
+typedef struct _BStruct { void *grue; } BStruct;
+void testB_aux(void *ptr);
+void testB(BStruct *b) {
+ {
+ int *__gruep__ = ((int *)&((b)->grue));
+ int __gruev__ = *__gruep__;
+ testB_aux(__gruep__);
+ }
+ {
+ int *__gruep__ = ((int *)&((b)->grue));
+ int __gruev__ = *__gruep__;
+ if (~0 != __gruev__) {}
+ }
+}
+
+void test_trivial_symbolic_comparison(int *x) {
+ int test_trivial_symbolic_comparison_aux();
+ int a = test_trivial_symbolic_comparison_aux();
+ int b = a;
+ if (a != b) { // expected-warning{{Both operands to '!=' always have the same value}}
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+
+ a = a == 1;
+ b = b == 1;
+ if (a != b) { // expected-warning{{Both operands to '!=' always have the same value}}
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+}
+
+// Test for:
+// <rdar://problem/7062158> false positive null dereference due to
+// BasicStoreManager not tracking *static* globals
+//
+// This just tests the proper tracking of symbolic values for globals (both
+// static and non-static).
+//
+static int* x_rdar_7062158;
+void rdar_7062158() {
+ int *current = x_rdar_7062158;
+ if (current == x_rdar_7062158)
+ return;
+
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+}
+
+int* x_rdar_7062158_2;
+void rdar_7062158_2() {
+ int *current = x_rdar_7062158_2;
+ if (current == x_rdar_7062158_2)
+ return;
+
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+}
+
+// This test reproduces a case for a crash when analyzing ClamAV using
+// RegionStoreManager (the crash doesn't exhibit in BasicStoreManager because
+// it isn't doing anything smart about arrays). The problem is that on the
+// second line, 'p = &p[i]', p is assigned an ElementRegion whose index
+// is a 16-bit integer. On the third line, a new ElementRegion is created
+// based on the previous region, but there the region uses a 32-bit integer,
+// resulting in a clash of values (an assertion failure at best). We resolve
+// this problem by implicitly converting index values to 'int' when the
+// ElementRegion is created.
+unsigned char test_array_index_bitwidth(const unsigned char *p) {
+ unsigned short i = 0;
+ for (i = 0; i < 2; i++) p = &p[i];
+ return p[i+1];
+}
+
+// This case tests that CastRegion handles casts involving BlockPointerTypes.
+// It should not crash.
+void test_block_cast() {
+ id test_block_cast_aux();
+ (void (^)(void *))test_block_cast_aux(); // expected-warning{{expression result unused}}
+}
+
+int OSAtomicCompareAndSwap32Barrier();
+
+// Test comparison of 'id' instance variable to a null void* constant after
+// performing an OSAtomicCompareAndSwap32Barrier.
+// This previously was a crash in RegionStoreManager.
+@interface TestIdNull {
+ id x;
+}
+-(int)foo;
+@end
+@implementation TestIdNull
+-(int)foo {
+ OSAtomicCompareAndSwap32Barrier(0, (signed)2, (signed*)&x);
+ if (x == (void*) 0) { return 0; }
+ return 1;
+}
+@end
+
+// PR 4594 - This was a crash when handling casts in SimpleSValuator.
+void PR4594() {
+ char *buf[1];
+ char **foo = buf;
+ *foo = "test";
+}
+
+// Test invalidation logic where an integer is casted to an array with a
+// different sign and then invalidated.
+void test_invalidate_cast_int() {
+ void test_invalidate_cast_int_aux(unsigned *i);
+ signed i;
+ test_invalidate_cast_int_aux((unsigned*) &i);
+ if (i < 0)
+ return;
+}
+
+int ivar_getOffset();
+
+// Reduced from a crash involving the cast of an Objective-C symbolic region to
+// 'char *'
+static NSNumber *test_ivar_offset(id self, SEL _cmd, Ivar inIvar) {
+ return [[[NSNumber allocWithZone:((void*)0)] initWithBool:*(_Bool *)((char *)self + ivar_getOffset(inIvar))] autorelease];
+}
+
+// Reduced from a crash in StoreManager::CastRegion involving a divide-by-zero.
+// This resulted from not properly handling region casts to 'const void*'.
+void test_cast_const_voidptr() {
+ char x[10];
+ char *p = &x[1];
+ const void* q = p;
+}
+
+// Reduced from a crash when analyzing Wine. This test handles loads from
+// function addresses.
+typedef long (*FARPROC)();
+FARPROC test_load_func(FARPROC origfun) {
+ if (!*(unsigned char*) origfun)
+ return origfun;
+ return 0;
+}
+
+// Test passing-by-value an initialized struct variable.
+struct test_pass_val {
+ int x;
+ int y;
+};
+void test_pass_val_aux(struct test_pass_val s);
+void test_pass_val() {
+ struct test_pass_val s;
+ s.x = 1;
+ s.y = 2;
+ test_pass_val_aux(s);
+}
+
+// This is a reduced test case of a false positive that previously appeared
+// in RegionStoreManager. Previously the array access resulted in dereferencing
+// an undefined value.
+int test_array_compound(int *q, int *r, int *z) {
+ int *array[] = { q, r, z };
+ int j = 0;
+ for (unsigned i = 0; i < 3 ; ++i)
+ if (*array[i]) ++j; // no-warning
+ return j;
+}
+
+// symbolic value stored in 'x' wouldn't be implicitly casted to a signed value
+// during the comparison.
+int rdar_7124210(unsigned int x) {
+ enum { SOME_CONSTANT = 123 };
+ int compare = ((signed) SOME_CONSTANT) == *((signed *) &x);
+ return compare ? 0 : 1; // Forces the evaluation of the symbolic constraint.
+}
+
+void pr4781(unsigned long *raw1) {
+ unsigned long *cook, *raw0;
+ unsigned long dough[32];
+ int i;
+ cook = dough;
+ for( i = 0; i < 16; i++, raw1++ ) {
+ raw0 = raw1++;
+ *cook = (*raw0 & 0x00fc0000L) << 6;
+ *cook |= (*raw0 & 0x00000fc0L) << 10;
+ }
+}
+
+// <rdar://problem/7185647> - 'self' should be treated as being non-null
+// upon entry to an objective-c method.
+@interface RDar7185647
+- (id)foo;
+@end
+@implementation RDar7185647
+- (id) foo {
+ if (self)
+ return self;
+ *((volatile int *) 0x0) = 0xDEADBEEF; // no-warning
+ return self;
+}
+@end
+
+// Test reasoning of __builtin_offsetof;
+struct test_offsetof_A {
+ int x;
+ int y;
+};
+struct test_offsetof_B {
+ int w;
+ int z;
+};
+void test_offsetof_1() {
+ if (__builtin_offsetof(struct test_offsetof_A, x) ==
+ __builtin_offsetof(struct test_offsetof_B, w))
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+}
+void test_offsetof_2() {
+ if (__builtin_offsetof(struct test_offsetof_A, y) ==
+ __builtin_offsetof(struct test_offsetof_B, z))
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+}
+void test_offsetof_3() {
+ if (__builtin_offsetof(struct test_offsetof_A, y) -
+ __builtin_offsetof(struct test_offsetof_A, x)
+ ==
+ __builtin_offsetof(struct test_offsetof_B, z) -
+ __builtin_offsetof(struct test_offsetof_B, w))
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+}
+void test_offsetof_4() {
+ if (__builtin_offsetof(struct test_offsetof_A, y) ==
+ __builtin_offsetof(struct test_offsetof_B, w))
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning{{Dereference of null pointer}}
+}
+
+// <rdar://problem/6829164> "nil receiver" false positive: make tracking
+// of the MemRegion for 'self' path-sensitive
+@interface RDar6829164 : NSObject {
+ double x; int y;
+}
+- (id) init;
+@end
+
+id rdar_6829164_1();
+double rdar_6829164_2();
+
+@implementation RDar6829164
+- (id) init {
+ if((self = [super init]) != 0) {
+ id z = rdar_6829164_1();
+ y = (z != 0);
+ if (y)
+ x = rdar_6829164_2();
+ }
+ return self;
+}
+@end
+
+// <rdar://problem/7242015> - Invalidate values passed-by-reference
+// to functions when the pointer to the value is passed as an integer.
+void test_7242015_aux(unsigned long);
+int rdar_7242015() {
+ int x;
+ test_7242015_aux((unsigned long) &x); // no-warning
+ return x; // Previously we return and uninitialized value when
+ // using RegionStore.
+}
+
+// <rdar://problem/7242006> [RegionStore] compound literal assignment with
+// floats not honored
+CGFloat rdar7242006(CGFloat x) {
+ NSSize y = (NSSize){x, 10};
+ return y.width; // no-warning
+}
+
+// PR 4988 - This test exhibits a case where a function can be referenced
+// when not explicitly used in an "lvalue" context (as far as the analyzer is
+// concerned). This previously triggered a crash due to an invalid assertion.
+void pr_4988(void) {
+ pr_4988; // expected-warning{{expression result unused}}
+}
+
+// <rdar://problem/7152418> - A 'signed char' is used as a flag, which is
+// implicitly converted to an int.
+void *rdar7152418_bar();
+@interface RDar7152418 {
+ signed char x;
+}
+-(char)foo;
+@end;
+@implementation RDar7152418
+-(char)foo {
+ char *p = 0;
+ void *result = 0;
+ if (x) {
+ result = rdar7152418_bar();
+ p = "hello";
+ }
+ if (!result) {
+ result = rdar7152418_bar();
+ if (result && x)
+ return *p; // no-warning
+ }
+ return 1;
+}
+
+//===----------------------------------------------------------------------===//
+// Test constant-folding of symbolic values, automatically handling type
+// conversions of the symbol as necessary.
+//===----------------------------------------------------------------------===//
+
+// Previously this would crash once we started eagerly evaluating symbols whose
+// values were constrained to a single value.
+void test_symbol_fold_1(signed char x) {
+ while (1) {
+ if (x == ((signed char) 0)) {}
+ }
+}
+
+// This previously caused a crash because it triggered an assertion in APSInt.
+void test_symbol_fold_2(unsigned int * p, unsigned int n,
+ const unsigned int * grumpkin, unsigned int dn) {
+ unsigned int i;
+ unsigned int tempsub[8];
+ unsigned int *solgrumpkin = tempsub + n;
+ for (i = 0; i < n; i++)
+ solgrumpkin[i] = (i < dn) ? ~grumpkin[i] : 0xFFFFFFFF;
+ for (i <<= 5; i < (n << 5); i++) {}
+}
+
+// This previously caused a crash because it triggered an assertion in APSInt.
+// 'x' would evaluate to a 8-bit constant (because of the return value of
+// test_symbol_fold_3_aux()) which would not get properly promoted to an
+// integer.
+char test_symbol_fold_3_aux(void);
+unsigned test_symbol_fold_3(void) {
+ unsigned x = test_symbol_fold_3_aux();
+ if (x == 54)
+ return (x << 8) | 0x5;
+ return 0;
+}
+
+//===----------------------------------------------------------------------===//
+// Tests for the warning of casting a non-struct type to a struct type
+//===----------------------------------------------------------------------===//
+
+typedef struct {unsigned int v;} NSSwappedFloat;
+
+NSSwappedFloat test_cast_nonstruct_to_struct(float x) {
+ struct hodor {
+ float number;
+ NSSwappedFloat sf;
+ };
+ return ((struct hodor *)&x)->sf; // expected-warning{{Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption}}
+}
+
+NSSwappedFloat test_cast_nonstruct_to_union(float x) {
+ union bran {
+ float number;
+ NSSwappedFloat sf;
+ };
+ return ((union bran *)&x)->sf; // no-warning
+}
+
+void test_undefined_array_subscript() {
+ int i, a[10];
+ int *p = &a[i]; // expected-warning{{Array subscript is undefined}}
+}
+@end
+
+//===----------------------------------------------------------------------===//
+// Test using an uninitialized value as a branch condition.
+//===----------------------------------------------------------------------===//
+
+int test_uninit_branch(void) {
+ int x;
+ if (x) // expected-warning{{Branch condition evaluates to a garbage value}}
+ return 1;
+ return 0;
+}
+
+int test_uninit_branch_b(void) {
+ int x;
+ return x ? 1 : 0; // expected-warning{{Branch condition evaluates to a garbage value}}
+}
+
+int test_uninit_branch_c(void) {
+ int x;
+ if ((short)x) // expected-warning{{Branch condition evaluates to a garbage value}}
+ return 1;
+ return 0;
+}
+
+//===----------------------------------------------------------------------===//
+// Test passing an undefined value in a message or function call.
+//===----------------------------------------------------------------------===//
+
+void test_bad_call_aux(int x);
+void test_bad_call(void) {
+ int y;
+ test_bad_call_aux(y); // expected-warning{{Function call argument is an uninitialized value}}
+}
+
+@interface TestBadArg {}
+- (void) testBadArg:(int) x;
+@end
+
+void test_bad_msg(TestBadArg *p) {
+ int y;
+ [p testBadArg:y]; // expected-warning{{Argument in message expression is an uninitialized value}}
+}
+
+//===----------------------------------------------------------------------===//
+// PR 6033 - Test emitting the correct output in a warning where we use '%'
+// with operands that are undefined.
+//===----------------------------------------------------------------------===//
+
+int pr6033(int x) {
+ int y;
+ return x % y; // expected-warning{{The right operand of '%' is a garbage value}}
+}
+
+struct trie {
+ struct trie* next;
+};
+
+struct kwset {
+ struct trie *trie;
+ unsigned char y[10];
+ struct trie* next[10];
+ int d;
+};
+
+typedef struct trie trie_t;
+typedef struct kwset kwset_t;
+
+void f(kwset_t *kws, char const *p, char const *q) {
+ struct trie const *trie;
+ struct trie * const *next = kws->next;
+ register unsigned char c;
+ register char const *end = p;
+ register char const *lim = q;
+ register int d = 1;
+ register unsigned char const *y = kws->y;
+
+ d = y[c = (end+=d)[-1]]; // no-warning
+ trie = next[c];
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7593875> When handling sizeof(VLA) it leads to a hole in
+// the ExplodedGraph (causing a false positive)
+//===----------------------------------------------------------------------===//
+
+int rdar_7593875_aux(int x);
+int rdar_7593875(int n) {
+ int z[n > 10 ? 10 : n]; // VLA.
+ int v;
+ v = rdar_7593875_aux(sizeof(z));
+ // Previously we got a false positive about 'v' being uninitialized.
+ return v; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// Handle casts from symbolic regions (packaged as integers) to doubles.
+// Previously this caused an assertion failure.
+//===----------------------------------------------------------------------===//
+
+void *foo_rev95119();
+void baz_rev95119(double x);
+void bar_rev95119() {
+ // foo_rev95119() returns a symbolic pointer. It is then
+ // cast to an int which is then cast to a double.
+ int value = (int) foo_rev95119();
+ baz_rev95119((double)value);
+}
+
+//===----------------------------------------------------------------------===//
+// Handle loading a symbolic pointer from a symbolic region that was
+// invalidated by a call to an unknown function.
+//===----------------------------------------------------------------------===//
+
+void bar_rev95192(int **x);
+void foo_rev95192(int **x) {
+ *x = 0;
+ bar_rev95192(x);
+ // Not a null dereference.
+ **x = 1; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// Handle casts of a function to a function pointer with a different return
+// value. We don't yet emit an error for such cases, but we now we at least
+// don't crash when the return value gets interpreted in a way that
+// violates our invariants.
+//===----------------------------------------------------------------------===//
+
+void *foo_rev95267();
+int bar_rev95267() {
+ char (*Callback_rev95267)(void) = (char (*)(void)) foo_rev95267;
+ if ((*Callback_rev95267)() == (char) 0)
+ return 1;
+ return 0;
+}
+
+// Same as previous case, but handle casts to 'void'.
+int bar_rev95274() {
+ void (*Callback_rev95274)(void) = (void (*)(void)) foo_rev95267;
+ (*Callback_rev95274)();
+ return 0;
+}
+
+void rdar7582031_test_static_init_zero() {
+ static unsigned x;
+ if (x == 0)
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF;
+}
+void rdar7582031_test_static_init_zero_b() {
+ static void* x;
+ if (x == 0)
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF;
+}
+
+//===----------------------------------------------------------------------===//
+// Test handling of parameters that are structs that contain floats and //
+// nested fields. //
+//===----------------------------------------------------------------------===//
+
+struct s_rev95547_nested { float x, y; };
+struct s_rev95547 {
+ struct s_rev95547_nested z1;
+ struct s_rev95547_nested z2;
+};
+float foo_rev95547(struct s_rev95547 w) {
+ return w.z1.x + 20.0; // no-warning
+}
+void foo_rev95547_b(struct s_rev95547 w) {
+ struct s_rev95547 w2 = w;
+ w2.z1.x += 20.0; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// Test handling statement expressions that don't populate a CFG block that
+// is used to represent the computation of the RHS of a logical operator.
+// This previously triggered a crash.
+//===----------------------------------------------------------------------===//
+
+void pr6938() {
+ if (1 && ({
+ while (0);
+ 0;
+ }) == 0) {
+ }
+}
+
+void pr6938_b() {
+ if (1 && *({ // expected-warning{{Dereference of null pointer}}
+ while (0) {}
+ ({
+ (int *) 0;
+ });
+ }) == 0) {
+ }
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7979430> - The CFG for code containing an empty
+// @synchronized block was previously broken (and would crash the analyzer).
+//===----------------------------------------------------------------------===//
+
+void r7979430(id x) {
+ @synchronized(x) {}
+}
+
+//===----------------------------------------------------------------------===
+// PR 7361 - Test that functions wrapped in macro instantiations are analyzed.
+//===----------------------------------------------------------------------===
+#define MAKE_TEST_FN() \
+ void test_pr7361 (char a) {\
+ char* b = 0x0; *b = a;\
+ }
+
+MAKE_TEST_FN() // expected-warning{{null pointer}}
+
+//===----------------------------------------------------------------------===
+// PR 7491 - Test that symbolic expressions can be used as conditions.
+//===----------------------------------------------------------------------===
+
+void pr7491 () {
+ extern int getint();
+ int a = getint()-1;
+ if (a) {
+ return;
+ }
+ if (!a) {
+ return;
+ } else {
+ // Should be unreachable
+ (void)*(char*)0; // no-warning
+ }
+}
+
+//===----------------------------------------------------------------------===
+// PR 7475 - Test that assumptions about global variables are reset after
+// calling a global function.
+//===----------------------------------------------------------------------===
+
+int *pr7475_someGlobal;
+void pr7475_setUpGlobal();
+
+void pr7475() {
+ if (pr7475_someGlobal == 0)
+ pr7475_setUpGlobal();
+ *pr7475_someGlobal = 0; // no-warning
+}
+
+void pr7475_warn() {
+ static int *someStatic = 0;
+ if (someStatic == 0)
+ pr7475_setUpGlobal();
+ *someStatic = 0; // expected-warning{{null pointer}}
+}
+
+// <rdar://problem/8202272> - __imag passed non-complex should not crash
+float f0(_Complex float x) {
+ float l0 = __real x;
+ return __real l0 + __imag l0;
+}
+
+
+//===----------------------------------------------------------------------===
+// Test that we can reduce symbols to constants whether they are on the left
+// or right side of an expression.
+//===----------------------------------------------------------------------===
+
+void reduce_to_constant(int x, int y) {
+ if (x != 20)
+ return;
+
+ int a = x + y;
+ int b = y + x;
+
+ if (y == -20 && a != 0)
+ (void)*(char*)0; // no-warning
+ if (y == -20 && b != 0)
+ (void)*(char*)0; // no-warning
+}
+
+// <rdar://problem/8360854> - Test that code after a switch statement with no
+// 'case:' labels is correctly evaluated.
+void r8360854(int n) {
+ switch (n) {
+ default: ;
+ }
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning{{null pointer}}
+}
+
+// PR 8050 - crash in CastSizeChecker when pointee is an incomplete type
+typedef long unsigned int __darwin_size_t;
+typedef __darwin_size_t size_t;
+void *malloc(size_t);
+
+struct PR8050;
+
+void pr8050(struct PR8050 **arg)
+{
+ *arg = malloc(1);
+}
+
+// <rdar://problem/5880430> Switch on enum should not consider default case live
+// if all enum values are covered
+enum Cases { C1, C2, C3, C4 };
+void test_enum_cases(enum Cases C) {
+ switch (C) {
+ case C1:
+ case C2:
+ case C4:
+ case C3:
+ return;
+ }
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+}
+
+void test_enum_cases_positive(enum Cases C) {
+ switch (C) { // expected-warning{{enumeration value 'C4' not handled in switch}}
+ case C1:
+ case C2:
+ case C3:
+ return;
+ }
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning{{Dereference of null pointer}}
+}
+
+// <rdar://problem/6351970> rule request: warn if synchronization mutex can be nil
+void rdar6351970() {
+ id x = 0;
+ @synchronized(x) {} // expected-warning{{Nil value used as mutex for @synchronized() (no synchronization will occur)}}
+}
+
+void rdar6351970_b(id x) {
+ if (!x)
+ @synchronized(x) {} // expected-warning{{Nil value used as mutex for @synchronized() (no synchronization will occur)}}
+}
+
+void rdar6351970_c() {
+ id x;
+ @synchronized(x) {} // expected-warning{{Uninitialized value used as mutex for @synchronized}}
+}
+
+@interface Rdar8578650
+- (id) foo8578650;
+@end
+
+void rdar8578650(id x) {
+ @synchronized (x) {
+ [x foo8578650];
+ }
+ // At this point we should assume that 'x' is not nil, not
+ // the inverse.
+ @synchronized (x) { // no-warning
+ }
+}
+
+// <rdar://problem/6352035> rule request: direct structure member access null pointer dereference
+@interface RDar6352035 {
+ int c;
+}
+- (void)foo;
+- (void)bar;
+@end
+
+@implementation RDar6352035
+- (void)foo {
+ RDar6352035 *friend = 0;
+ friend->c = 7; // expected-warning{{Instance variable access (via 'friend') results in a null pointer dereference}}
+}
+- (void)bar {
+ self = 0;
+ c = 7; // expected-warning{{Instance variable access (via 'self') results in a null pointer dereference}}
+}
+@end
+
+// PR 8149 - GNU statement expression in condition of ForStmt.
+// This previously triggered an assertion failure in CFGBuilder.
+void pr8149(void) {
+ for (; ({ do { } while (0); 0; });) { }
+}
+
+// PR 8458 - Make sure @synchronized doesn't crash with properties.
+@interface PR8458 {}
+@property(readonly) id lock;
+@end
+
+static
+void __PR8458(PR8458 *x) {
+ @synchronized(x.lock) {} // no-warning
+}
+
+// PR 8440 - False null dereference during store to array-in-field-in-global.
+// This test case previously resulted in a bogus null deref warning from
+// incorrect lazy symbolication logic in RegionStore.
+static struct {
+ int num;
+ char **data;
+} saved_pr8440;
+
+char *foo_pr8440();
+char **bar_pr8440();
+void baz_pr8440(int n)
+{
+ saved_pr8440.num = n;
+ if (saved_pr8440.data)
+ return;
+ saved_pr8440.data = bar_pr8440();
+ for (int i = 0 ; i < n ; i ++)
+ saved_pr8440.data[i] = foo_pr8440(); // no-warning
+}
+
+// Support direct accesses to non-null memory. Reported in:
+// PR 5272
+// <rdar://problem/6839683>
+int test_direct_address_load() {
+ int *p = (int*) 0x4000;
+ return *p; // no-warning
+}
+
+void pr5272_test() {
+ struct pr5272 { int var2; };
+ (*(struct pr5272*)0xBC000000).var2 = 0; // no-warning
+ (*(struct pr5272*)0xBC000000).var2 += 2; // no-warning
+}
+
+// Support casting the return value of function to another different type
+// This previously caused a crash, although we likely need more precise
+// reasoning here. <rdar://problem/8663544>
+void* rdar8663544();
+typedef struct {} Val8663544;
+Val8663544 bazR8663544() {
+ Val8663544(*func) () = (Val8663544(*) ()) rdar8663544;
+ return func();
+}
+
+// PR 8619 - Handle ternary expressions with a call to a noreturn function.
+// This previously resulted in a crash.
+void pr8619_noreturn(int x) __attribute__((noreturn));
+
+void pr8619(int a, int b, int c) {
+ a ?: pr8619_noreturn(b || c);
+}
+
+
+// PR 8646 - crash in the analyzer when handling unions.
+union pr8648_union {
+ signed long long pr8648_union_field;
+};
+void pr8648() {
+ long long y;
+ union pr8648_union x = { .pr8648_union_field = 0LL };
+ y = x.pr8648_union_field;
+
+ union pr8648_union z;
+ z = (union pr8648_union) { .pr8648_union_field = 0LL };
+
+ union pr8648_union w;
+ w = ({ (union pr8648_union) { .pr8648_union_field = 0LL }; });
+
+ // crash, no assignment
+ (void) ({ (union pr8648_union) { .pr8648_union_field = 0LL }; }).pr8648_union_field;
+
+ // crash with assignment
+ y = ({ (union pr8648_union) { .pr8648_union_field = 0LL }; }).pr8648_union_field;
+}
+
+// PR 9269 - don't assert when building the following CFG. The for statement
+// contains a condition with multiple basic blocks, and the value of the
+// statement expression is then indexed as part of a bigger condition expression.
+// This example exposed a bug in child traversal in the CFGBuilder.
+void pr9269() {
+ struct s { char *bar[10]; } baz[2] = { 0 };
+ unsigned i = 0;
+ for (i = 0;
+ (* ({ while(0); ({ &baz[0]; }); })).bar[0] != 0; // expected-warning {{while loop has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
+ ++i) {}
+}
+
+// Test evaluation of GNU-style ?:.
+int pr9287(int type) { return type ? : 0; } // no-warning
+
+void pr9287_b(int type, int *p) {
+ int x = type ? : 0;
+ if (x) {
+ p = 0;
+ }
+ if (type) {
+ *p = 0xDEADBEEF; // expected-warning {{null pointer}}
+ }
+}
+
+void pr9287_c(int type, int *p) {
+ int x = type ? : 0;
+ if (x) {
+ p = 0;
+ }
+ if (!type) {
+ *p = 0xDEADBEEF; // no-warning
+ }
+}
+
+void test_switch() {
+ switch (4) {
+ case 1: {
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ break;
+ }
+ case 4: {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+ break;
+ }
+ default: {
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ break;
+ }
+ }
+}
+
+// PR 9467. Tests various CFG optimizations. This previously crashed.
+static void test(unsigned int bit_mask)
+{
+ unsigned int bit_index;
+ for (bit_index = 0;
+ bit_index < 24;
+ bit_index++) {
+ switch ((0x01 << bit_index) & bit_mask) {
+ case 0x100000: ;
+ }
+ }
+}
+
+// Don't crash on code containing __label__.
+int radar9414427_aux();
+void radar9414427() {
+ __label__ mylabel;
+ if (radar9414427_aux()) {
+ mylabel: do {}
+ while (0);
+ }
+}
+
+// Analyze methods in @implementation (category)
+@interface RDar9465344
+@end
+
+@implementation RDar9465344 (MyCategory)
+- (void) testcategoryImpl {
+ int *p = 0x0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+}
+@end
+
+@implementation RDar9465344
+@end
+
+// Don't crash when analyzing access to 'self' within a block.
+@interface Rdar10380300Base
+- (void) foo;
+@end
+@interface Rdar10380300 : Rdar10380300Base @end
+@implementation Rdar10380300
+- (void)foo {
+ ^{
+ [super foo];
+ }();
+}
+@end
+
diff --git a/clang/test/Analysis/new.cpp b/clang/test/Analysis/new.cpp
new file mode 100644
index 0000000..5ca8c46
--- /dev/null
+++ b/clang/test/Analysis/new.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -verify %s
+// XFAIL: *
+
+void f1() {
+ int *n = new int;
+ if (*n) { // expected-warning {{Branch condition evaluates to a garbage value}}
+ }
+}
+
+void f2() {
+ int *n = new int(3);
+ if (*n) { // no-warning
+ }
+}
+
diff --git a/clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m b/clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
new file mode 100644
index 0000000..c1cc076
--- /dev/null
+++ b/clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=range -analyzer-store=region -verify -Wno-objc-root-class %s
+
+// <rdar://problem/6888289> - This test case shows that a nil instance
+// variable can possibly be initialized by a method.
+@interface RDar6888289
+{
+ id *x;
+}
+- (void) test:(id) y;
+- (void) test2:(id) y;
+- (void) invalidate;
+@end
+
+id *getVal(void);
+
+@implementation RDar6888289
+- (void) test:(id)y {
+ if (!x)
+ [self invalidate];
+ *x = y;
+}
+- (void) test2:(id)y {
+ if (!x) {}
+ *x = y; // expected-warning {{null}}
+}
+
+- (void) invalidate {
+ x = getVal();
+}
+
+@end
+
diff --git a/clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m b/clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
new file mode 100644
index 0000000..e4d5aaf
--- /dev/null
+++ b/clang/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -Wno-objc-root-class %s 2>&1 | FileCheck -check-prefix=darwin8 %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -Wno-objc-root-class %s 2>&1 | FileCheck -check-prefix=darwin9 %s
+// RUN: %clang_cc1 -triple thumbv6-apple-ios4.0 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -Wno-objc-root-class %s 2>&1 | FileCheck -check-prefix=darwin9 %s
+
+@interface MyClass {}
+- (void *)voidPtrM;
+- (int)intM;
+- (long long)longlongM;
+- (unsigned long long)unsignedLongLongM;
+- (double)doubleM;
+- (long double)longDoubleM;
+- (void)voidM;
+@end
+@implementation MyClass
+- (void *)voidPtrM { return (void *)0; }
+- (int)intM { return 0; }
+- (long long)longlongM { return 0; }
+- (unsigned long long)unsignedLongLongM { return 0; }
+- (double)doubleM { return 0.0; }
+- (long double)longDoubleM { return 0.0; }
+- (void)voidM {}
+@end
+
+void createFoo() {
+ MyClass *obj = 0;
+
+ void *v = [obj voidPtrM]; // no-warning
+ int i = [obj intM]; // no-warning
+}
+
+void createFoo2() {
+ MyClass *obj = 0;
+
+ long double ld = [obj longDoubleM];
+}
+
+void createFoo3() {
+ MyClass *obj;
+ obj = 0;
+
+ long long ll = [obj longlongM];
+}
+
+void createFoo4() {
+ MyClass *obj = 0;
+
+ double d = [obj doubleM];
+}
+
+void createFoo5() {
+ MyClass *obj = (id)@"";
+
+ double d = [obj doubleM]; // no-warning
+}
+
+void createFoo6() {
+ MyClass *obj;
+ obj = 0;
+
+ unsigned long long ull = [obj unsignedLongLongM];
+}
+
+void handleNilPruneLoop(MyClass *obj) {
+ if (!!obj)
+ return;
+
+ // Test if [obj intM] evaluates to 0, thus pruning the entire loop.
+ for (int i = 0; i < [obj intM]; i++) {
+ long long j = [obj longlongM];
+ }
+
+ long long j = [obj longlongM];
+}
+
+int handleVoidInComma() {
+ MyClass *obj = 0;
+ return [obj voidM], 0;
+}
+
+int marker(void) { // control reaches end of non-void function
+}
+
+// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
+// CHECK-darwin8: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
+// CHECK-darwin8: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage
+// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
+// CHECK-darwin8: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
+
+// CHECK-darwin9-NOT: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
+// CHECK-darwin9-NOT: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
+// CHECK-darwin9-NOT: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage
+// CHECK-darwin9-NOT: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
+// CHECK-darwin9-NOT: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
+// CHECK-darwin9: 1 warning generated
+
diff --git a/clang/test/Analysis/no-exit-cfg.c b/clang/test/Analysis/no-exit-cfg.c
new file mode 100644
index 0000000..1a80a25
--- /dev/null
+++ b/clang/test/Analysis/no-exit-cfg.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s
+
+// This is a test case for the issue reported in PR 2819:
+// http://llvm.org/bugs/show_bug.cgi?id=2819
+// The flow-sensitive dataflow solver should work even when no block in
+// the CFG reaches the exit block.
+
+int g(int x);
+void h(int x);
+
+int f(int x)
+{
+out_err:
+ if (g(x)) {
+ h(x);
+ }
+ goto out_err;
+}
diff --git a/clang/test/Analysis/no-outofbounds.c b/clang/test/Analysis/no-outofbounds.c
new file mode 100644
index 0000000..821f486
--- /dev/null
+++ b/clang/test/Analysis/no-outofbounds.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,experimental.unix,experimental.security.ArrayBound -analyzer-store=region -verify %s
+
+//===----------------------------------------------------------------------===//
+// This file tests cases where we should not flag out-of-bounds warnings.
+//===----------------------------------------------------------------------===//
+
+void f() {
+ long x = 0;
+ char *y = (char*) &x;
+ char c = y[0] + y[1] + y[2]; // no-warning
+ short *z = (short*) &x;
+ short s = z[0] + z[1]; // no-warning
+}
+
+void g() {
+ int a[2];
+ char *b = (char*)a;
+ b[3] = 'c'; // no-warning
+}
+
+typedef typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+
+void field() {
+ struct vec { size_t len; int data[0]; };
+ // FIXME: Not warn for this.
+ struct vec *a = malloc(sizeof(struct vec) + 10); // expected-warning {{Cast a region whose size is not a multiple of the destination type size}}
+ a->len = 10;
+ a->data[1] = 5; // no-warning
+ free(a);
+}
diff --git a/clang/test/Analysis/null-deref-ps-region.c b/clang/test/Analysis/null-deref-ps-region.c
new file mode 100644
index 0000000..08bfac7
--- /dev/null
+++ b/clang/test/Analysis/null-deref-ps-region.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -std=gnu99 -analyzer-store=region -verify %s
+
+
+// The store for 'a[1]' should not be removed mistakenly. SymbolicRegions may
+// also be live roots.
+void f14(int *a) {
+ int i;
+ a[1] = 1;
+ i = a[1];
+ if (i != 1) {
+ int *p = 0;
+ i = *p; // no-warning
+ }
+}
diff --git a/clang/test/Analysis/null-deref-ps.c b/clang/test/Analysis/null-deref-ps.c
new file mode 100644
index 0000000..a707970
--- /dev/null
+++ b/clang/test/Analysis/null-deref-ps.c
@@ -0,0 +1,313 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,experimental.deadcode.IdempotentOperations,experimental.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -analyzer-purge=none -verify %s -Wno-error=return-type
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,experimental.deadcode.IdempotentOperations,experimental.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -verify %s -Wno-error=return-type
+
+typedef unsigned uintptr_t;
+
+extern void __assert_fail (__const char *__assertion, __const char *__file,
+ unsigned int __line, __const char *__function)
+ __attribute__ ((__noreturn__));
+
+#define assert(expr) \
+ ((expr) ? (void)(0) : __assert_fail (#expr, __FILE__, __LINE__, __func__))
+
+void f1(int *p) {
+ if (p) *p = 1;
+ else *p = 0; // expected-warning{{ereference}}
+}
+
+struct foo_struct {
+ int x;
+};
+
+int f2(struct foo_struct* p) {
+
+ if (p)
+ p->x = 1;
+
+ return p->x++; // expected-warning{{Access to field 'x' results in a dereference of a null pointer (loaded from variable 'p')}}
+}
+
+int f3(char* x) {
+
+ int i = 2;
+
+ if (x)
+ return x[i - 1];
+
+ return x[i+1]; // expected-warning{{Array access (from variable 'x') results in a null pointer dereference}}
+}
+
+int f3_b(char* x) {
+
+ int i = 2;
+
+ if (x)
+ return x[i - 1];
+
+ return x[i+1]++; // expected-warning{{Array access (from variable 'x') results in a null pointer dereference}}
+}
+
+int f4(int *p) {
+
+ uintptr_t x = (uintptr_t) p;
+
+ if (x)
+ return 1;
+
+ int *q = (int*) x;
+ return *q; // expected-warning{{Dereference of null pointer (loaded from variable 'q')}}
+}
+
+int f4_b() {
+ short array[2];
+ uintptr_t x = array; // expected-warning{{incompatible pointer to integer conversion}}
+ short *p = x; // expected-warning{{incompatible integer to pointer conversion}}
+
+ // The following branch should be infeasible.
+ if (!(p == &array[0])) { // expected-warning{{Both operands to '==' always have the same value}}
+ p = 0;
+ *p = 1; // no-warning
+ }
+
+ if (p) {
+ *p = 5; // no-warning
+ p = 0;
+ }
+ else return; // expected-warning {{non-void function 'f4_b' should return a value}}
+
+ *p += 10; // expected-warning{{Dereference of null pointer}}
+ return 0;
+}
+
+int f5() {
+
+ char *s = "hello world";
+ return s[0]; // no-warning
+}
+
+int bar(int* p, int q) __attribute__((nonnull));
+
+int f6(int *p) {
+ return !p ? bar(p, 1) // expected-warning {{Null pointer passed as an argument to a 'nonnull' parameter}}
+ : bar(p, 0); // no-warning
+}
+
+int bar2(int* p, int q) __attribute__((nonnull(1)));
+
+int f6b(int *p) {
+ return !p ? bar2(p, 1) // expected-warning {{Null pointer passed as an argument to a 'nonnull' parameter}}
+ : bar2(p, 0); // no-warning
+}
+
+int bar3(int*p, int q, int *r) __attribute__((nonnull(1,3)));
+
+int f6c(int *p, int *q) {
+ return !p ? bar3(q, 2, p) // expected-warning {{Null pointer passed as an argument to a 'nonnull' parameter}}
+ : bar3(p, 2, q); // no-warning
+}
+
+void f6d(int *p) {
+ bar(p, 0);
+ // At this point, 'p' cannot be null.
+ if (!p) {
+ int *q = 0;
+ *q = 0xDEADBEEF; // no-warning
+ }
+}
+
+void f6e(int *p, int offset) {
+ // PR7406 - crash from treating an UnknownVal as defined, to see if it's 0.
+ bar((p+offset)+1, 0); // not crash
+}
+
+int* qux();
+
+int f7(int x) {
+
+ int* p = 0;
+
+ if (0 == x)
+ p = qux();
+
+ if (0 == x)
+ *p = 1; // no-warning
+
+ return x;
+}
+
+int* f7b(int *x) {
+
+ int* p = 0;
+
+ if (((void*)0) == x)
+ p = qux();
+
+ if (((void*)0) == x)
+ *p = 1; // no-warning
+
+ return x;
+}
+
+int* f7c(int *x) {
+
+ int* p = 0;
+
+ if (((void*)0) == x)
+ p = qux();
+
+ if (((void*)0) != x)
+ return x;
+
+ // If we reach here then 'p' is not null.
+ *p = 1; // no-warning
+ return x;
+}
+
+int* f7c2(int *x) {
+
+ int* p = 0;
+
+ if (((void*)0) == x)
+ p = qux();
+
+ if (((void*)0) == x)
+ return x;
+
+ *p = 1; // expected-warning{{null}}
+ return x;
+}
+
+
+void f8(int *p, int *q) {
+ if (!p)
+ if (p)
+ *p = 1; // no-warning
+
+ if (q)
+ if (!q)
+ *q = 1; // no-warning
+}
+
+int* qux();
+
+int f9(unsigned len) {
+ assert (len != 0);
+ int *p = 0;
+ unsigned i;
+
+ for (i = 0; i < len; ++i)
+ p = qux(i);
+
+ return *p++; // no-warning
+}
+
+int f9b(unsigned len) {
+ assert (len > 0); // note use of '>'
+ int *p = 0;
+ unsigned i;
+
+ for (i = 0; i < len; ++i)
+ p = qux(i);
+
+ return *p++; // no-warning
+}
+
+int* f10(int* p, signed char x, int y) {
+ // This line tests symbolication with compound assignments where the
+ // LHS and RHS have different bitwidths. The new symbolic value
+ // for 'x' should have a bitwidth of 8.
+ x &= y;
+
+ // This tests that our symbolication worked, and that we correctly test
+ // x against 0 (with the same bitwidth).
+ if (!x) {
+ if (!p) return 0;
+ *p = 10;
+ }
+ else p = 0;
+
+ if (!x)
+ *p = 5; // no-warning
+
+ return p;
+}
+
+// Test case from <rdar://problem/6407949>
+void f11(unsigned i) {
+ int *x = 0;
+ if (i >= 0) { // expected-warning{{always true}}
+ // always true
+ } else {
+ *x = 42; // no-warning
+ }
+}
+
+void f11b(unsigned i) {
+ int *x = 0;
+ if (i <= ~(unsigned)0) {
+ // always true
+ } else {
+ *x = 42; // no-warning
+ }
+}
+
+// Test case for switch statements with weird case arms.
+typedef int BOOL, *PBOOL, *LPBOOL;
+typedef long LONG_PTR, *PLONG_PTR;
+typedef unsigned long ULONG_PTR, *PULONG_PTR;
+typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
+typedef LONG_PTR LRESULT;
+typedef struct _F12ITEM *HF12ITEM;
+
+void f12(HF12ITEM i, char *q) {
+ char *p = 0;
+ switch ((DWORD_PTR) i) {
+ case 0 ... 10:
+ p = q;
+ break;
+ case (DWORD_PTR) ((HF12ITEM) - 65535):
+ return;
+ default:
+ return;
+ }
+
+ *p = 1; // no-warning
+}
+
+// Test handling of translating between integer "pointers" and back.
+void f13() {
+ int *x = 0;
+ if (((((int) x) << 2) + 1) >> 1) *x = 1;
+}
+
+// PR 4759 - Attribute non-null checking by the analyzer was not correctly
+// handling pointer values that were undefined.
+void pr4759_aux(int *p) __attribute__((nonnull));
+
+void pr4759() {
+ int *p;
+ pr4759_aux(p); // expected-warning{{Function call argument is an uninitialized value}}
+}
+
+// Relax function call arguments invalidation to be aware of const
+// arguments. Test with function pointers. radar://10595327
+void ttt(const int *nptr);
+void ttt2(const int *nptr);
+typedef void (*NoConstType)(int*);
+int foo10595327(int b) {
+ void (*fp)(int *);
+ // We use path sensitivity to get the function declaration. Even when the
+ // function pointer is cast to non pointer-to-const parameter type, we can
+ // find the right function declaration.
+ if (b > 5)
+ fp = (NoConstType)ttt2;
+ else
+ fp = (NoConstType)ttt;
+ int x = 3;
+ int y = x + 1;
+ int *p = 0;
+ fp(&y);
+ if (x == y)
+ return *p; // no-warning
+ return 0;
+}
diff --git a/clang/test/Analysis/nullptr.cpp b/clang/test/Analysis/nullptr.cpp
new file mode 100644
index 0000000..3119b4f
--- /dev/null
+++ b/clang/test/Analysis/nullptr.cpp
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -std=c++11 -Wno-conversion-null -analyze -analyzer-checker=core -analyzer-store region -verify %s
+
+// test to see if nullptr is detected as a null pointer
+void foo1(void) {
+ char *np = nullptr;
+ *np = 0; // expected-warning{{Dereference of null pointer}}
+}
+
+// check if comparing nullptr to nullptr is detected properly
+void foo2(void) {
+ char *np1 = nullptr;
+ char *np2 = np1;
+ char c;
+ if (np1 == np2)
+ np1 = &c;
+ *np1 = 0; // no-warning
+}
+
+// invoving a nullptr in a more complex operation should be cause a warning
+void foo3(void) {
+ struct foo {
+ int a, f;
+ };
+ char *np = nullptr;
+ // casting a nullptr to anything should be caught eventually
+ int *ip = &(((struct foo *)np)->f);
+ *ip = 0; // expected-warning{{Dereference of null pointer}}
+ // should be error here too, but analysis gets stopped
+// *np = 0;
+}
+
+// nullptr is implemented as a zero integer value, so should be able to compare
+void foo4(void) {
+ char *np = nullptr;
+ if (np != 0)
+ *np = 0; // no-warning
+ char *cp = 0;
+ if (np != cp)
+ *np = 0; // no-warning
+}
+
+int pr10372(void *& x) {
+ // GNU null is a pointer-sized integer, not a pointer.
+ x = __null;
+ // This used to crash.
+ return __null;
+}
+
+void zoo1() {
+ char **p = 0;
+ delete *(p + 0); // expected-warning{{Dereference of null pointer}}
+}
+
+void zoo2() {
+ int **a = 0;
+ int **b = 0;
+ asm ("nop"
+ :"=a"(*a)
+ :"0"(*b) // expected-warning{{Dereference of null pointer}}
+ );
+}
+
+int exprWithCleanups() {
+ struct S {
+ S(int a):a(a){}
+ ~S() {}
+
+ int a;
+ };
+
+ int *x = 0;
+ return S(*x).a; // expected-warning{{Dereference of null pointer}}
+}
+
+int materializeTempExpr() {
+ int *n = 0;
+ struct S {
+ int a;
+ S(int i): a(i) {}
+ };
+ const S &s = S(*n); // expected-warning{{Dereference of null pointer}}
+ return s.a;
+}
diff --git a/clang/test/Analysis/objc-arc.m b/clang/test/Analysis/objc-arc.m
new file mode 100644
index 0000000..e6c6ab5
--- /dev/null
+++ b/clang/test/Analysis/objc-arc.m
@@ -0,0 +1,220 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,deadcode -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -fobjc-arc %s
+
+typedef signed char BOOL;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+typedef unsigned long NSUInteger;
+
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+@end
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+@protocol NSCoding;
+@protocol NSMutableCopying;
+@protocol NSFastEnumeration
+- (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
++ (id)alloc;
+- (id)init;
+- (NSString *)description;
+@end
+@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;
+@end
+
+typedef const struct __CFAllocator * CFAllocatorRef;
+extern const CFAllocatorRef kCFAllocatorDefault;
+typedef double CFTimeInterval;
+typedef CFTimeInterval CFAbsoluteTime;
+extern CFAbsoluteTime CFAbsoluteTimeGetCurrent(void);
+typedef const struct __CFDate * CFDateRef;
+extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at);
+
+typedef const void* objc_objectptr_t;
+__attribute__((ns_returns_retained)) id objc_retainedObject(objc_objectptr_t __attribute__((cf_consumed)) pointer);
+__attribute__((ns_returns_not_retained)) id objc_unretainedObject(objc_objectptr_t pointer);
+
+// Test the analyzer is working at all.
+void test_working() {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+}
+
+// Test that in ARC mode that blocks are correctly automatically copied
+// and not flagged as warnings by the analyzer.
+typedef void (^Block)(void);
+void testblock_bar(int x);
+
+Block testblock_foo(int x) {
+ Block b = ^{ testblock_bar(x); };
+ return b; // no-warning
+}
+
+Block testblock_baz(int x) {
+ return ^{ testblock_bar(x); }; // no-warning
+}
+
+Block global_block;
+
+void testblock_qux(int x) {
+ global_block = ^{ testblock_bar(x); }; // no-warning
+}
+
+// Test that Objective-C pointers are null initialized.
+void test_nil_initialized() {
+ id x;
+ if (x == 0)
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+}
+
+// Test that we don't flag leaks of Objective-C objects.
+void test_alloc() {
+ [NSObject alloc]; // no-warning
+}
+
+// Test that CF allocations are still caught as leaks.
+void test_cf_leak() {
+ CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+ CFDateRef date = CFDateCreate(0, t); // expected-warning {{Potential leak}}
+ (void) date;
+}
+
+// Test that 'init' methods do not try to claim ownerhip of an *unowned* allocated object
+// in ARC mode.
+@interface RDar9424890_A : NSObject
+- (id)initWithCleaner:(int)pop mop:(NSString *)mop ;
+- (RDar9424890_A *)rdar9424890:(NSString *)identifier;
+@end
+@interface RDar9424890_B : NSObject
+@end
+@implementation RDar9424890_B
+- (RDar9424890_A *)obj:(RDar9424890_A *)obj {
+ static NSString *WhizFiz = @"WhizFiz";
+ RDar9424890_A *cell = [obj rdar9424890:WhizFiz];
+ if (cell == ((void*)0)) {
+ cell = [[RDar9424890_A alloc] initWithCleaner:0 mop:WhizFiz]; // no-warning
+ }
+ return cell;
+}
+@end
+
+// Test that dead store checking works in the prescence of "cleanups" in the AST.
+void rdar9424882() {
+ id x = [NSObject alloc]; // expected-warning {{Value stored to 'x' during its initialization is never read}}
+}
+
+// Test
+typedef const void *CFTypeRef;
+typedef const struct __CFString *CFStringRef;
+
+@interface NSString
+- (id) self;
+@end
+
+CFTypeRef CFCreateSomething();
+CFStringRef CFCreateString();
+CFTypeRef CFGetSomething();
+CFStringRef CFGetString();
+
+id CreateSomething();
+NSString *CreateNSString();
+
+void from_cf() {
+ id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning{{never read}}
+ id obj2 = (__bridge_transfer NSString*)CFCreateString();
+ [obj2 self]; // Add a use, to show we can use the object after it has been transfered.
+ id obj3 = (__bridge id)CFGetSomething();
+ [obj3 self]; // Add a use, to show we can use the object after it has been bridged.
+ id obj4 = (__bridge NSString*)CFGetString(); // expected-warning{{never read}}
+ id obj5 = (__bridge id)CFCreateSomething(); // expected-warning{{never read}} expected-warning{{leak}}
+ id obj6 = (__bridge NSString*)CFCreateString(); // expected-warning{{never read}} expected-warning{{leak}}
+}
+
+void to_cf(id obj) {
+ CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // expected-warning{{never read}}
+ CFStringRef cf2 = (__bridge_retained CFStringRef)CreateNSString(); // expected-warning{{never read}}
+ CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // expected-warning{{never read}}
+ CFStringRef cf4 = (__bridge CFStringRef)CreateNSString(); // expected-warning{{never read}}
+}
+
+void test_objc_retainedObject() {
+ CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+ CFDateRef date = CFDateCreate(0, t);
+ id x = objc_retainedObject(date);
+ (void) x;
+}
+
+void test_objc_unretainedObject() {
+ CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+ CFDateRef date = CFDateCreate(0, t); // expected-warning {{Potential leak}}
+ id x = objc_unretainedObject(date);
+ (void) x;
+}
+
+// Previously this resulted in a "return of stack address" warning.
+id test_return() {
+ id x = (__bridge_transfer id) CFCreateString();
+ return x; // no-warning
+}
+
+void test_objc_arrays() {
+ { // CASE ONE -- OBJECT IN ARRAY CREATED DIRECTLY
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a = [[NSArray alloc] initWithObjects:o, (void*)0];
+ [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];
+ [a2 description];
+ [o description];
+ }
+
+ { // CASE THREE -- OBJECT IN RETAINED @[]
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a3 = @[o];
+ [a3 description];
+ [o description];
+ }
+ {
+ // CASE 4, verify analyzer still working.
+ CFCreateString(); // expected-warning {{leak}}
+ }
+}
+
+// <rdar://problem/11059275> - dispatch_set_context and ARC.
+__attribute__((cf_returns_retained)) CFTypeRef CFBridgingRetain(id X);
+typedef void* dispatch_object_t;
+void dispatch_set_context(dispatch_object_t object, const void *context);
+
+void rdar11059275(dispatch_object_t object) {
+ NSObject *o = [[NSObject alloc] init];
+ dispatch_set_context(object, CFBridgingRetain(o)); // no-warning
+}
+void rdar11059275_positive() {
+ NSObject *o = [[NSObject alloc] init]; // expected-warning {{leak}}
+ CFBridgingRetain(o);
+}
+void rdar11059275_negative() {
+ NSObject *o = [[NSObject alloc] init]; // no-warning
+ (void) o;
+}
+
diff --git a/clang/test/Analysis/objc-bool.m b/clang/test/Analysis/objc-bool.m
new file mode 100644
index 0000000..f95736a
--- /dev/null
+++ b/clang/test/Analysis/objc-bool.m
@@ -0,0 +1,22 @@
+// RUN: %clang --analyze %s -o %t -Xclang -verify
+
+// Test handling of ObjC bool literals.
+
+typedef signed char BOOL;
+
+void rdar_10597458() {
+ if (__objc_yes)
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+}
+
+void rdar_10597458_b(BOOL b) {
+ if (b == __objc_no)
+ return;
+
+ if (b == __objc_no) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+}
diff --git a/clang/test/Analysis/objc-method-coverage.m b/clang/test/Analysis/objc-method-coverage.m
new file mode 100644
index 0000000..056aafe
--- /dev/null
+++ b/clang/test/Analysis/objc-method-coverage.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-stats -fblocks %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=none -analyzer-stats -fblocks %s 2>&1 | FileCheck %s
+
+@interface I
+int f() {
+ return 0;
+}
+@end
+
+@implementation I
++ (void *)ff{
+ return (void*)0;
+}
+@end
+
+// CHECK: ... Statistics Collected ...
+// CHECK: 2 AnalysisConsumer - The # of functions analysed (as top level). \ No newline at end of file
diff --git a/clang/test/Analysis/operator-calls.cpp b/clang/test/Analysis/operator-calls.cpp
new file mode 100644
index 0000000..73cd28a
--- /dev/null
+++ b/clang/test/Analysis/operator-calls.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -verify %s
+struct X0 { };
+bool operator==(const X0&, const X0&);
+
+// PR7287
+struct test { int a[2]; };
+
+void t2() {
+ test p = {{1,2}};
+ test q;
+ q = p;
+}
+
+bool PR7287(X0 a, X0 b) {
+ return operator==(a, b);
+}
diff --git a/clang/test/Analysis/out-of-bounds.c b/clang/test/Analysis/out-of-bounds.c
new file mode 100644
index 0000000..a97bba5
--- /dev/null
+++ b/clang/test/Analysis/out-of-bounds.c
@@ -0,0 +1,154 @@
+// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,experimental.security.ArrayBoundV2 -verify %s
+
+// Tests doing an out-of-bounds access after the end of an array using:
+// - constant integer index
+// - constant integer size for buffer
+void test1(int x) {
+ int buf[100];
+ buf[100] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+void test1_ok(int x) {
+ int buf[100];
+ buf[99] = 1; // no-warning
+}
+
+const char test1_strings_underrun(int x) {
+ const char *mystr = "mary had a little lamb";
+ return mystr[-1]; // expected-warning{{Out of bound memory access}}
+}
+
+const char test1_strings_overrun(int x) {
+ const char *mystr = "mary had a little lamb";
+ return mystr[1000]; // expected-warning{{Out of bound memory access}}
+}
+
+const char test1_strings_ok(int x) {
+ const char *mystr = "mary had a little lamb";
+ return mystr[5]; // no-warning
+}
+
+// Tests doing an out-of-bounds access after the end of an array using:
+// - indirect pointer to buffer
+// - constant integer index
+// - constant integer size for buffer
+void test1_ptr(int x) {
+ int buf[100];
+ int *p = buf;
+ p[101] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+void test1_ptr_ok(int x) {
+ int buf[100];
+ int *p = buf;
+ p[99] = 1; // no-warning
+}
+
+// Tests doing an out-of-bounds access before the start of an array using:
+// - indirect pointer to buffer, manipulated using simple pointer arithmetic
+// - constant integer index
+// - constant integer size for buffer
+void test1_ptr_arith(int x) {
+ int buf[100];
+ int *p = buf;
+ p = p + 100;
+ p[0] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+void test1_ptr_arith_ok(int x) {
+ int buf[100];
+ int *p = buf;
+ p = p + 99;
+ p[0] = 1; // no-warning
+}
+
+void test1_ptr_arith_bad(int x) {
+ int buf[100];
+ int *p = buf;
+ p = p + 99;
+ p[1] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+void test1_ptr_arith_ok2(int x) {
+ int buf[100];
+ int *p = buf;
+ p = p + 99;
+ p[-1] = 1; // no-warning
+}
+
+// Tests doing an out-of-bounds access before the start of an array using:
+// - constant integer index
+// - constant integer size for buffer
+void test2(int x) {
+ int buf[100];
+ buf[-1] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+// Tests doing an out-of-bounds access before the start of an array using:
+// - indirect pointer to buffer
+// - constant integer index
+// - constant integer size for buffer
+void test2_ptr(int x) {
+ int buf[100];
+ int *p = buf;
+ p[-1] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+// Tests doing an out-of-bounds access before the start of an array using:
+// - indirect pointer to buffer, manipulated using simple pointer arithmetic
+// - constant integer index
+// - constant integer size for buffer
+void test2_ptr_arith(int x) {
+ int buf[100];
+ int *p = buf;
+ --p;
+ p[0] = 1; // expected-warning {{Out of bound memory access (accessed memory precedes memory block)}}
+}
+
+// Tests doing an out-of-bounds access before the start of a multi-dimensional
+// array using:
+// - constant integer indices
+// - constant integer sizes for the array
+void test2_multi(int x) {
+ int buf[100][100];
+ buf[0][-1] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+// Tests doing an out-of-bounds access before the start of a multi-dimensional
+// array using:
+// - constant integer indices
+// - constant integer sizes for the array
+void test2_multi_b(int x) {
+ int buf[100][100];
+ buf[-1][0] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+void test2_multi_ok(int x) {
+ int buf[100][100];
+ buf[0][0] = 1; // no-warning
+}
+
+// Testing if solver handles (symbol * constant) < constant
+void test3(int x) {
+ int buf[100];
+ if (x < 0)
+ buf[x] = 1; // expected-warning {{Out of bound memory access (accessed memory precedes memory block)}}
+}
+
+// *** FIXME ***
+// We don't get a warning here yet because our symbolic constraint solving
+// doesn't handle: (symbol * constant) < constant
+void test4(int x) {
+ int buf[100];
+ if (x > 99)
+ buf[x] = 1;
+}
+
+// Don't warn when indexing below the start of a symbolic region's whose
+// base extent we don't know.
+int *get_symbolic();
+void test_index_below_symboloc() {
+ int *buf = get_symbolic();
+ buf[-1] = 0; // no-warning;
+}
+
diff --git a/clang/test/Analysis/outofbound-notwork.c b/clang/test/Analysis/outofbound-notwork.c
new file mode 100644
index 0000000..45e713b
--- /dev/null
+++ b/clang/test/Analysis/outofbound-notwork.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,experimental.unix,experimental.security.ArrayBound -analyzer-store=region -verify %s
+// XFAIL: *
+
+// Once we better handle modeling of sizes of VLAs, we can pull this back
+// into outofbound.c.
+
+void sizeof_vla(int a) {
+ if (a == 5) {
+ char x[a];
+ int y[sizeof(x)];
+ y[4] = 4; // no-warning
+ y[5] = 5; // expected-warning{{out-of-bound}}
+ }
+}
+
+void sizeof_vla_2(int a) {
+ if (a == 5) {
+ char x[a];
+ int y[sizeof(x) / sizeof(char)];
+ y[4] = 4; // no-warning
+ y[5] = 5; // expected-warning{{out-of-bound}}
+ }
+}
+
+void sizeof_vla_3(int a) {
+ if (a == 5) {
+ char x[a];
+ int y[sizeof(*&*&*&x)];
+ y[4] = 4; // no-warning
+ y[5] = 5; // expected-warning{{out-of-bound}}
+ }
+}
diff --git a/clang/test/Analysis/outofbound.c b/clang/test/Analysis/outofbound.c
new file mode 100644
index 0000000..2e7a7d3
--- /dev/null
+++ b/clang/test/Analysis/outofbound.c
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,experimental.unix,experimental.security.ArrayBound -analyzer-store=region -verify %s
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void *calloc(size_t, size_t);
+
+char f1() {
+ char* s = "abcd";
+ char c = s[4]; // no-warning
+ return s[5] + c; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
+}
+
+void f2() {
+ int *p = malloc(12);
+ p[3] = 4; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
+}
+
+struct three_words {
+ int c[3];
+};
+
+struct seven_words {
+ int c[7];
+};
+
+void f3() {
+ struct three_words a, *p;
+ p = &a;
+ p[0] = a; // no-warning
+ p[1] = a; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
+}
+
+void f4() {
+ struct seven_words c;
+ struct three_words a, *p = (struct three_words *)&c;
+ p[0] = a; // no-warning
+ p[1] = a; // no-warning
+ p[2] = a; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
+}
+
+void f5() {
+ char *p = calloc(2,2);
+ p[3] = '.'; // no-warning
+ p[4] = '!'; // expected-warning{{out-of-bound}}
+}
+
+void f6() {
+ char a[2];
+ int *b = (int*)a;
+ b[1] = 3; // expected-warning{{out-of-bound}}
+}
+
+void f7() {
+ struct three_words a;
+ a.c[3] = 1; // expected-warning{{out-of-bound}}
+}
+
+void vla(int a) {
+ if (a == 5) {
+ int x[a];
+ x[4] = 4; // no-warning
+ x[5] = 5; // expected-warning{{out-of-bound}}
+ }
+}
+
+void alloca_region(int a) {
+ if (a == 5) {
+ char *x = __builtin_alloca(a);
+ x[4] = 4; // no-warning
+ x[5] = 5; // expected-warning{{out-of-bound}}
+ }
+}
+
+int symbolic_index(int a) {
+ int x[2] = {1, 2};
+ if (a == 2) {
+ return x[a]; // expected-warning{{out-of-bound}}
+ }
+ return 0;
+}
+
+int symbolic_index2(int a) {
+ int x[2] = {1, 2};
+ if (a < 0) {
+ return x[a]; // expected-warning{{out-of-bound}}
+ }
+ return 0;
+}
diff --git a/clang/test/Analysis/override-werror.c b/clang/test/Analysis/override-werror.c
new file mode 100644
index 0000000..d3b75f6
--- /dev/null
+++ b/clang/test/Analysis/override-werror.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -Werror %s -analyzer-store=region -verify
+
+// This test case illustrates that using '-analyze' overrides the effect of
+// -Werror. This allows basic warnings not to interfere with producing
+// analyzer results.
+
+char* f(int *p) {
+ return p; // expected-warning{{incompatible pointer types}}
+}
+
+void g(int *p) {
+ if (!p) *p = 0; // expected-warning{{null}}
+}
+
diff --git a/clang/test/Analysis/plist-output-alternate.m b/clang/test/Analysis/plist-output-alternate.m
new file mode 100644
index 0000000..83100dc
--- /dev/null
+++ b/clang/test/Analysis/plist-output-alternate.m
@@ -0,0 +1,972 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-output=plist -o %t %s
+// RUN: FileCheck --input-file %t %s
+
+void test_null_init(void) {
+ int *p = 0;
+ *p = 0xDEADBEEF;
+}
+
+void test_null_assign(void) {
+ int *p;
+ p = 0;
+ *p = 0xDEADBEEF;
+}
+
+void test_null_assign_transitive(void) {
+ int *p;
+ p = 0;
+ int *q = p;
+ *q = 0xDEADBEEF;
+}
+
+void test_null_cond(int *p) {
+ if (!p) {
+ *p = 0xDEADBEEF;
+ }
+}
+
+void test_null_cond_transitive(int *q) {
+ if (!q) {
+ int *p = q;
+ *p = 0xDEADBEEF;
+ }
+}
+
+void test_null_field(void) {
+ struct s { int *p; } x;
+ x.p = 0;
+ *(x.p) = 0xDEADBEEF;
+}
+
+// <rdar://problem/8331641> leak reports should not show paths that end with exit() (but ones that don't end with exit())
+void panic() __attribute__((noreturn));
+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 const struct __CFAllocator * CFAllocatorRef;
+extern const CFAllocatorRef kCFAllocatorDefault;
+typedef signed long CFIndex;
+typedef CFIndex CFNumberType;
+typedef const struct __CFNumber * CFNumberRef;
+
+extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr);
+
+void rdar8331641(int x) {
+ signed z = 1;
+ CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // expected-warning{{leak}}
+ if (x)
+ panic();
+ (void) value;
+}
+
+// CHECK: <?xml version="1.0" encoding="UTF-8"?>
+// 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>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</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>6</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_init</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>3</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>12</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_assign</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>16</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>16</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</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>19</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_assign_transitive</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>7</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>23</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;p&apos; is null</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;p&apos; is null</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</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>24</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_cond</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>30</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>30</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>30</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>30</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</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>31</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_cond_transitive</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>36</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>36</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>36</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>36</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>36</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>36</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>38</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>38</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>38</integer>
+// CHECK: <key>col</key><integer>3</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>38</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>38</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_field</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>38</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>82</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>23</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>54</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>82</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object with a +1 retain count</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object with a +1 retain count</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>82</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>58</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>58</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>58</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Object leaked: object allocated and stored into &apos;value&apos; is not referenced later in this execution path and has a retain count of +1</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Object leaked: object allocated and stored into &apos;value&apos; is not referenced later in this execution path and has a retain count of +1</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Potential leak of an object stored into &apos;value&apos;</string>
+// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string>
+// CHECK: <key>type</key><string>Leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>rdar8331641</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>58</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </plist>
diff --git a/clang/test/Analysis/plist-output.m b/clang/test/Analysis/plist-output.m
new file mode 100644
index 0000000..72e8f8d
--- /dev/null
+++ b/clang/test/Analysis/plist-output.m
@@ -0,0 +1,1339 @@
+// RUN: %clang --analyze %s -o %t > /dev/null 2>&1
+// RUN: FileCheck -input-file %t %s
+
+void test_null_init(void) {
+ int *p = 0;
+ *p = 0xDEADBEEF;
+}
+
+void test_null_assign(void) {
+ int *p;
+ p = 0;
+ *p = 0xDEADBEEF;
+}
+
+void test_null_assign_transitive(void) {
+ int *p;
+ p = 0;
+ int *q = p;
+ *q = 0xDEADBEEF;
+}
+
+void test_null_cond(int *p) {
+ if (!p) {
+ *p = 0xDEADBEEF;
+ }
+}
+
+void test_null_cond_transitive(int *q) {
+ if (!q) {
+ // FIXME: we need a diagnostic saying that p is initialized to 0
+ int *p = q;
+ *p = 0xDEADBEEF;
+ }
+}
+
+void test_null_field(void) {
+ struct s { int *p; } x;
+ x.p = 0;
+ *(x.p) = 0xDEADBEEF;
+}
+
+void test_assumptions(int a, int b)
+{
+ if (a == 0) {
+ return;
+ }
+ if (b != 0) {
+ return;
+ }
+ int *p = 0;
+ *p = 0xDEADBEEF;
+}
+
+int *bar_cond_assign();
+int test_cond_assign() {
+ int *p;
+ if (p = bar_cond_assign())
+ return 1;
+ return *p;
+}
+
+// The following previously crashed when generating extensive diagnostics.
+// <rdar://problem/10797980>
+@interface RDar10797980_help
+@property (readonly) int x;
+@end
+
+@interface RDar10797980 {
+ RDar10797980_help *y;
+}
+- (void) test;
+@end
+
+@implementation RDar10797980
+- (void) test {
+ if (y.x == 1) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{deference}}
+ }
+}
+@end
+
+// CHECK: <?xml version="1.0" encoding="UTF-8"?>
+// 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>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</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>6</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_init</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>3</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>12</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_assign</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>16</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>16</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</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>19</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_assign_transitive</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>7</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>23</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;p&apos; is null</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;p&apos; is null</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</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>24</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_cond</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>5</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>32</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_cond_transitive</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>39</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>39</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>39</integer>
+// CHECK: <key>col</key><integer>3</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>39</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>39</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_field</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>39</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>44</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>44</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>44</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>44</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>44</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>44</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>3</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>51</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_assumptions</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>7</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>57</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;p&apos; is null</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;p&apos; is null</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>10</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>59</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_cond_assign</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>77</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>77</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>77</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>77</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>5</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>78</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>Objective-C method</string>
+// CHECK: <key>issue_context</key><string>test</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </plist>
+
diff --git a/clang/test/Analysis/pr4209.m b/clang/test/Analysis/pr4209.m
new file mode 100644
index 0000000..e16d1aa
--- /dev/null
+++ b/clang/test/Analysis/pr4209.m
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s
+
+// This test case was crashing due to how CFRefCount.cpp resolved the
+// ObjCInterfaceDecl* and ClassName in EvalObjCMessageExpr.
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end @interface NSObject <NSObject> {
+}
+@end typedef float CGFloat;
+typedef struct _NSPoint {
+}
+NSFastEnumerationState;
+@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end @class NSString;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSMutableArray : NSArray - (void)addObject:(id)anObject;
+@end typedef unsigned short unichar;
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length;
+- (int)intValue;
+@end @interface NSSimpleCString : NSString {
+}
+@end @interface NSConstantString : NSSimpleCString @end extern void *_NSConstantStringClassReference;
+@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey;
+@end typedef struct {
+}
+CMProfileLocation;
+@interface NSResponder : NSObject <NSCoding> {
+}
+@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView;
+@interface NSCell : NSObject <NSCopying, NSCoding> {
+}
+@end extern NSString *NSControlTintDidChangeNotification;
+@interface NSActionCell : NSCell {
+}
+@end @class NSArray, NSDocument, NSWindow;
+@interface NSWindowController : NSResponder <NSCoding> {
+}
+@end @class EBayCategoryType, GSEbayCategory, GBSearchRequest;
+@interface GBCategoryChooserPanelController : NSWindowController {
+ GSEbayCategory *rootCategory;
+}
+- (NSMutableDictionary*)categoryDictionaryForCategoryID:(int)inID inRootTreeCategories:(NSMutableArray*)inRootTreeCategories; // expected-note {{method definition for 'categoryDictionaryForCategoryID:inRootTreeCategories:' not found}}
+-(NSString*) categoryID; // expected-note {{method definition for 'categoryID' not found}} expected-note {{using}}
+@end @interface GSEbayCategory : NSObject <NSCoding> {
+}
+- (int) categoryID; // expected-note {{also found}}
+- (GSEbayCategory *) parent;
+- (GSEbayCategory*) subcategoryWithID:(int) inID;
+@end @implementation GBCategoryChooserPanelController + (int) chooseCategoryIDFromCategories:(NSArray*) inCategories searchRequest:(GBSearchRequest*)inRequest parentWindow:(NSWindow*) inParent { // expected-warning {{incomplete implementation}}
+ return 0;
+}
+- (void) addCategory:(EBayCategoryType*)inCategory toRootTreeCategory:(NSMutableArray*)inRootTreeCategories {
+ GSEbayCategory *category = [rootCategory subcategoryWithID:[[inCategory categoryID] intValue]]; // expected-warning {{multiple methods named 'categoryID' found}}
+
+ if (rootCategory != category) {
+ GSEbayCategory *parent = category;
+ while ((((void*)0) != (parent = [parent parent])) && ([parent categoryID] != 0)) {
+ NSMutableDictionary *treeCategoryDict = [self categoryDictionaryForCategoryID:[parent categoryID] inRootTreeCategories:inRootTreeCategories];
+ if (((void*)0) == treeCategoryDict) {
+ }
+ }
+ }
+}
+@end
diff --git a/clang/test/Analysis/pr_2542_rdar_6793404.m b/clang/test/Analysis/pr_2542_rdar_6793404.m
new file mode 100644
index 0000000..19c140d
--- /dev/null
+++ b/clang/test/Analysis/pr_2542_rdar_6793404.m
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -pedantic -analyzer-store=region -verify -Wno-objc-root-class %s
+
+// BEGIN delta-debugging reduced header stuff
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSCoder;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+- (oneway void)release;
+@end
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+@protocol NSCoding
+- (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
+- (id)init;
++ (id)alloc;
+@end
+typedef double NSTimeInterval;
+enum { NSAnimationEaseInOut, NSAnimationEaseIn, NSAnimationEaseOut, NSAnimationLinear };
+typedef NSUInteger NSAnimationCurve;
+@interface NSAnimation : NSObject <NSCopying, NSCoding> {}
+- (id)initWithDuration:(NSTimeInterval)duration animationCurve:(NSAnimationCurve)animationCurve;
+- (void)startAnimation;
+- (void)setDelegate:(id)delegate;
+@end
+
+// END delta-debugging reduced header stuff
+
+// From NSAnimation Class Reference
+// -(void)startAnimation
+// The receiver retains itself and is then autoreleased at the end
+// of the animation or when it receives stopAnimation.
+
+@interface MyClass { }
+- (void)animationDidEnd:(NSAnimation *)animation;
+@end
+
+@implementation MyClass
+- (void)f1 {
+ // NOTE: The analyzer doesn't really handle this; it just stops tracking
+ // 'animation' when it is sent the message 'setDelegate:'.
+ NSAnimation *animation = [[NSAnimation alloc] // no-warning
+ initWithDuration:1.0
+ animationCurve:NSAnimationEaseInOut];
+
+ [animation setDelegate:self];
+ [animation startAnimation];
+}
+
+- (void)f2 {
+ NSAnimation *animation = [[NSAnimation alloc] // expected-warning{{leak}}
+ initWithDuration:1.0
+ animationCurve:NSAnimationEaseInOut];
+
+ [animation startAnimation];
+}
+
+- (void)animationDidEnd:(NSAnimation *)animation {
+ [animation release];
+}
+@end
diff --git a/clang/test/Analysis/pr_4164.c b/clang/test/Analysis/pr_4164.c
new file mode 100644
index 0000000..187f4c6
--- /dev/null
+++ b/clang/test/Analysis/pr_4164.c
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s
+
+// PR 4164: http://llvm.org/bugs/show_bug.cgi?id=4164
+//
+// Eventually this should be pulled into misc-ps.m. This is in a separate test
+// file for now to play around with the specific issues for BasicStoreManager
+// and StoreManager (i.e., we can make a copy of this file for either
+// StoreManager should one start to fail in the near future).
+//
+// The basic issue is that the VarRegion for 'size' is casted to (char*),
+// resulting in an ElementRegion. 'getsockopt' is an unknown function that
+// takes a void*, which means the ElementRegion should get stripped off.
+typedef unsigned int __uint32_t;
+typedef __uint32_t __darwin_socklen_t;
+typedef __darwin_socklen_t socklen_t;
+int getsockopt(int, int, int, void * restrict, socklen_t * restrict);
+
+int test1() {
+ int s = -1;
+ int size;
+ socklen_t size_len = sizeof(size);
+ if (getsockopt(s, 0xffff, 0x1001, (char *)&size, &size_len) < 0)
+ return -1;
+
+ return size; // no-warning
+}
+
+// Similar case: instead of passing a 'void*', we pass 'char*'. In this
+// case we pass an ElementRegion to the invalidation logic. Since it is
+// an ElementRegion that just layers on top of another typed region and the
+// ElementRegion itself has elements whose type are integral (essentially raw
+// data) we strip off the ElementRegion when doing the invalidation.
+int takes_charptr(char* p);
+int test2() {
+ int size;
+ if (takes_charptr((char*)&size))
+ return -1;
+ return size; // no-warning
+}
+
diff --git a/clang/test/Analysis/properties.m b/clang/test/Analysis/properties.m
new file mode 100644
index 0000000..4aa9180
--- /dev/null
+++ b/clang/test/Analysis/properties.m
@@ -0,0 +1,168 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify -Wno-objc-root-class %s
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
+@interface NSObject <NSObject> {}
++(id)alloc;
+-(id)init;
+-(id)autorelease;
+-(id)copy;
+-(id)retain;
+@end
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
+-(id)initWithFormat:(NSString *)f,...;
+-(BOOL)isEqualToString:(NSString *)s;
++ (id)string;
+@end
+@interface NSNumber : NSObject {}
++(id)alloc;
+-(id)initWithInteger:(int)i;
+@end
+
+// rdar://6946338
+
+@interface Test1 : NSObject {
+ NSString *text;
+}
+-(id)myMethod;
+@property (nonatomic, assign) NSString *text;
+@end
+
+
+@implementation Test1
+
+@synthesize text;
+
+-(id)myMethod {
+ Test1 *cell = [[[Test1 alloc] init] autorelease];
+
+ NSString *string1 = [[NSString alloc] initWithFormat:@"test %f", 0.0]; // expected-warning {{Potential leak}}
+ cell.text = string1;
+
+ return cell;
+}
+
+@end
+
+
+// rdar://8824416
+
+@interface MyNumber : NSObject
+{
+ NSNumber* _myNumber;
+}
+
+- (id)initWithNumber:(NSNumber *)number;
+
+@property (nonatomic, readonly) NSNumber* myNumber;
+@property (nonatomic, readonly) NSNumber* newMyNumber;
+
+@end
+
+@implementation MyNumber
+@synthesize myNumber=_myNumber;
+
+- (id)initWithNumber:(NSNumber *)number
+{
+ self = [super init];
+
+ if ( self )
+ {
+ _myNumber = [number copy];
+ }
+
+ return self;
+}
+
+- (NSNumber*)newMyNumber
+{
+ if ( _myNumber )
+ return [_myNumber retain];
+
+ return [[NSNumber alloc] initWithInteger:1];
+}
+
+- (id)valueForUndefinedKey:(NSString*)key
+{
+ id value = 0;
+
+ if ([key isEqualToString:@"MyIvarNumberAsPropertyOverReleased"])
+ value = self.myNumber; // _myNumber will be over released, since the value returned from self.myNumber is not retained.
+ else if ([key isEqualToString:@"MyIvarNumberAsPropertyOk"])
+ value = [self.myNumber retain]; // this line fixes the over release
+ else if ([key isEqualToString:@"MyIvarNumberAsNewMyNumber"])
+ value = self.newMyNumber; // this one is ok, since value is returned retained
+ else
+ value = [[NSNumber alloc] initWithInteger:0];
+
+ return [value autorelease]; // expected-warning {{Object sent -autorelease too many times}}
+}
+
+@end
+
+NSNumber* numberFromMyNumberProperty(MyNumber* aMyNumber)
+{
+ NSNumber* result = aMyNumber.myNumber;
+
+ return [result autorelease]; // expected-warning {{Object sent -autorelease too many times}}
+}
+
+
+// rdar://6611873
+
+@interface Person : NSObject {
+ NSString *_name;
+}
+@property (retain) NSString * name;
+@end
+
+@implementation Person
+@synthesize name = _name;
+@end
+
+void rdar6611873() {
+ Person *p = [[[Person alloc] init] autorelease];
+
+ p.name = [[NSString string] retain]; // expected-warning {{leak}}
+ p.name = [[NSString alloc] init]; // expected-warning {{leak}}
+}
+
+@interface SubPerson : Person
+-(NSString *)foo;
+@end
+
+@implementation SubPerson
+-(NSString *)foo {
+ return super.name;
+}
+@end
+
+// <rdar://problem/9241180> Static analyzer doesn't detect uninitialized variable issues for property accesses
+@interface RDar9241180
+@property (readwrite,assign) id x;
+-(id)testAnalyzer1:(int) y;
+-(void)testAnalyzer2;
+@end
+
+@implementation RDar9241180
+@synthesize x;
+-(id)testAnalyzer1:(int)y {
+ RDar9241180 *o;
+ if (y && o.x) // expected-warning {{Property access on an uninitialized object pointer}}
+ return o;
+ return o; // expected-warning {{Undefined or garbage value returned to caller}}
+}
+-(void)testAnalyzer2 {
+ id y;
+ self.x = y; // expected-warning {{Argument for property setter is an uninitialized value}}
+}
+@end
+
+
diff --git a/clang/test/Analysis/pthreadlock.c b/clang/test/Analysis/pthreadlock.c
new file mode 100644
index 0000000..4735d20
--- /dev/null
+++ b/clang/test/Analysis/pthreadlock.c
@@ -0,0 +1,137 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.unix.PthreadLock -verify %s
+
+// Tests performing normal locking patterns and wrong locking orders
+
+typedef struct {
+ void *foo;
+} pthread_mutex_t;
+
+typedef pthread_mutex_t lck_mtx_t;
+
+extern int pthread_mutex_lock(pthread_mutex_t *);
+extern int pthread_mutex_unlock(pthread_mutex_t *);
+extern int pthread_mutex_trylock(pthread_mutex_t *);
+extern int lck_mtx_lock(lck_mtx_t *);
+extern int lck_mtx_unlock(lck_mtx_t *);
+extern int lck_mtx_try_lock(lck_mtx_t *);
+
+pthread_mutex_t mtx1, mtx2;
+lck_mtx_t lck1, lck2;
+
+void
+ok1(void)
+{
+ pthread_mutex_lock(&mtx1); // no-warning
+}
+
+void
+ok2(void)
+{
+ pthread_mutex_unlock(&mtx1); // no-warning
+}
+
+void
+ok3(void)
+{
+ pthread_mutex_lock(&mtx1); // no-warning
+ pthread_mutex_unlock(&mtx1); // no-warning
+ pthread_mutex_lock(&mtx1); // no-warning
+ pthread_mutex_unlock(&mtx1); // no-warning
+}
+
+void
+ok4(void)
+{
+ pthread_mutex_lock(&mtx1); // no-warning
+ pthread_mutex_unlock(&mtx1); // no-warning
+ pthread_mutex_lock(&mtx2); // no-warning
+ pthread_mutex_unlock(&mtx2); // no-warning
+}
+
+void
+ok5(void)
+{
+ if (pthread_mutex_trylock(&mtx1) == 0) // no-warning
+ pthread_mutex_unlock(&mtx1); // no-warning
+}
+
+void
+ok6(void)
+{
+ lck_mtx_lock(&lck1); // no-warning
+}
+
+void
+ok7(void)
+{
+ if (lck_mtx_try_lock(&lck1) != 0) // no-warning
+ lck_mtx_unlock(&lck1); // no-warning
+}
+
+void
+bad1(void)
+{
+ pthread_mutex_lock(&mtx1); // no-warning
+ pthread_mutex_lock(&mtx1); // expected-warning{{This lock has already been acquired}}
+}
+
+void
+bad2(void)
+{
+ pthread_mutex_lock(&mtx1); // no-warning
+ pthread_mutex_unlock(&mtx1); // no-warning
+ pthread_mutex_lock(&mtx1); // no-warning
+ pthread_mutex_lock(&mtx1); // expected-warning{{This lock has already been acquired}}
+}
+
+void
+bad3(void)
+{
+ pthread_mutex_lock(&mtx1); // no-warning
+ pthread_mutex_lock(&mtx2); // no-warning
+ pthread_mutex_unlock(&mtx1); // expected-warning{{This was not the most recently acquired lock}}
+ pthread_mutex_unlock(&mtx2);
+}
+
+void
+bad4(void)
+{
+ if (pthread_mutex_trylock(&mtx1)) // no-warning
+ return;
+ pthread_mutex_lock(&mtx2); // no-warning
+ pthread_mutex_unlock(&mtx1); // expected-warning{{This was not the most recently acquired lock}}
+}
+
+void
+bad5(void)
+{
+ lck_mtx_lock(&lck1); // no-warning
+ lck_mtx_lock(&lck1); // expected-warning{{This lock has already been acquired}}
+}
+
+void
+bad6(void)
+{
+ lck_mtx_lock(&lck1); // no-warning
+ lck_mtx_unlock(&lck1); // no-warning
+ lck_mtx_lock(&lck1); // no-warning
+ lck_mtx_lock(&lck1); // expected-warning{{This lock has already been acquired}}
+}
+
+void
+bad7(void)
+{
+ lck_mtx_lock(&lck1); // no-warning
+ lck_mtx_lock(&lck2); // no-warning
+ lck_mtx_unlock(&lck1); // expected-warning{{This was not the most recently acquired lock}}
+ lck_mtx_unlock(&lck2);
+}
+
+void
+bad8(void)
+{
+ if (lck_mtx_try_lock(&lck1) == 0) // no-warning
+ return;
+ lck_mtx_lock(&lck2); // no-warning
+ lck_mtx_unlock(&lck1); // expected-warning{{This was not the most recently acquired lock}}
+}
diff --git a/clang/test/Analysis/ptr-arith.c b/clang/test/Analysis/ptr-arith.c
new file mode 100644
index 0000000..fb37f1c
--- /dev/null
+++ b/clang/test/Analysis/ptr-arith.c
@@ -0,0 +1,288 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core.FixedAddr,experimental.core.PointerArithm,experimental.core.PointerSub -analyzer-store=region -verify -triple x86_64-apple-darwin9 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core.FixedAddr,experimental.core.PointerArithm,experimental.core.PointerSub -analyzer-store=region -verify -triple i686-apple-darwin9 %s
+
+// Used to trigger warnings for unreachable paths.
+#define WARN do { int a, b; int c = &b-&a; } while (0)
+
+void f1() {
+ int a[10];
+ int *p = a;
+ ++p;
+}
+
+char* foo();
+
+void f2() {
+ char *p = foo();
+ ++p;
+}
+
+// This test case checks if we get the right rvalue type of a TypedViewRegion.
+// The ElementRegion's type depends on the array region's rvalue type. If it was
+// a pointer type, we would get a loc::SymbolVal for '*p'.
+void* memchr();
+static int
+domain_port (const char *domain_b, const char *domain_e,
+ const char **domain_e_ptr)
+{
+ int port = 0;
+
+ const char *p;
+ const char *colon = memchr (domain_b, ':', domain_e - domain_b);
+
+ for (p = colon + 1; p < domain_e ; p++)
+ port = 10 * port + (*p - '0');
+ return port;
+}
+
+void f3() {
+ int x, y;
+ int d = &y - &x; // expected-warning{{Subtraction of two pointers that do not point to the same memory chunk may cause incorrect result.}}
+
+ int a[10];
+ int *p = &a[2];
+ int *q = &a[8];
+ d = q-p; // no-warning
+}
+
+void f4() {
+ int *p;
+ p = (int*) 0x10000; // expected-warning{{Using a fixed address is not portable because that address will probably not be valid in all environments or platforms.}}
+}
+
+void f5() {
+ int x, y;
+ int *p;
+ p = &x + 1; // expected-warning{{Pointer arithmetic done on non-array variables means reliance on memory layout, which is dangerous.}}
+
+ int a[10];
+ p = a + 1; // no-warning
+}
+
+// Allow arithmetic on different symbolic regions.
+void f6(int *p, int *q) {
+ int d = q - p; // no-warning
+}
+
+void null_operand(int *a) {
+start:
+ // LHS is a label, RHS is NULL
+ if (&&start == 0)
+ WARN; // no-warning
+ if (&&start < 0)
+ WARN; // no-warning
+ if (&&start <= 0)
+ WARN; // no-warning
+ if (!(&&start != 0))
+ WARN; // no-warning
+ if (!(&&start > 0))
+ WARN; // no-warning
+ if (!(&&start >= 0))
+ WARN; // no-warning
+ if (!(&&start - 0))
+ WARN; // no-warning
+
+ // LHS is a non-symbolic value, RHS is NULL
+ if (&a == 0)
+ WARN; // no-warning
+ if (&a < 0)
+ WARN; // no-warning
+ if (&a <= 0)
+ WARN; // no-warning
+ if (!(&a != 0))
+ WARN; // no-warning
+ if (!(&a > 0))
+ WARN; // no-warning
+ if (!(&a >= 0))
+ WARN; // no-warning
+
+ if (!(&a - 0)) // expected-warning{{Pointer arithmetic done on non-array variables}}
+ WARN; // no-warning
+
+ // LHS is NULL, RHS is non-symbolic
+ // The same code is used for labels and non-symbolic values.
+ if (0 == &a)
+ WARN; // no-warning
+ if (0 > &a)
+ WARN; // no-warning
+ if (0 >= &a)
+ WARN; // no-warning
+ if (!(0 != &a))
+ WARN; // no-warning
+ if (!(0 < &a))
+ WARN; // no-warning
+ if (!(0 <= &a))
+ WARN; // no-warning
+
+ // LHS is a symbolic value, RHS is NULL
+ if (a == 0)
+ WARN; // expected-warning{{}}
+ if (a < 0)
+ WARN; // no-warning
+ if (a <= 0)
+ WARN; // expected-warning{{}}
+ if (!(a != 0))
+ WARN; // expected-warning{{}}
+ if (!(a > 0))
+ WARN; // expected-warning{{}}
+ if (!(a >= 0))
+ WARN; // no-warning
+ if (!(a - 0))
+ WARN; // expected-warning{{}}
+
+ // LHS is NULL, RHS is a symbolic value
+ if (0 == a)
+ WARN; // expected-warning{{}}
+ if (0 > a)
+ WARN; // no-warning
+ if (0 >= a)
+ WARN; // expected-warning{{}}
+ if (!(0 != a))
+ WARN; // expected-warning{{}}
+ if (!(0 < a))
+ WARN; // expected-warning{{}}
+ if (!(0 <= a))
+ WARN; // no-warning
+}
+
+void const_locs() {
+ char *a = (char*)0x1000;
+ char *b = (char*)0x1100;
+start:
+ if (a==b)
+ WARN; // no-warning
+ if (!(a!=b))
+ WARN; // no-warning
+ if (a>b)
+ WARN; // no-warning
+ if (b<a)
+ WARN; // no-warning
+ if (a>=b)
+ WARN; // no-warning
+ if (b<=a)
+ WARN; // no-warning
+ if (b-a != 0x100)
+ WARN; // no-warning
+
+ if (&&start == a)
+ WARN; // expected-warning{{}}
+ if (a == &&start)
+ WARN; // expected-warning{{}}
+ if (&a == (char**)a)
+ WARN; // expected-warning{{}}
+ if ((char**)a == &a)
+ WARN; // expected-warning{{}}
+}
+
+void array_matching_types() {
+ int array[10];
+ int *a = &array[2];
+ int *b = &array[5];
+
+ if (a==b)
+ WARN; // no-warning
+ if (!(a!=b))
+ WARN; // no-warning
+ if (a>b)
+ WARN; // no-warning
+ if (b<a)
+ WARN; // no-warning
+ if (a>=b)
+ WARN; // no-warning
+ if (b<=a)
+ WARN; // no-warning
+ if ((b-a) == 0)
+ WARN; // no-warning
+}
+
+// This takes a different code path than array_matching_types()
+void array_different_types() {
+ int array[10];
+ int *a = &array[2];
+ char *b = (char*)&array[5];
+
+ if (a==b) // expected-warning{{comparison of distinct pointer types}}
+ WARN; // no-warning
+ if (!(a!=b)) // expected-warning{{comparison of distinct pointer types}}
+ WARN; // no-warning
+ if (a>b) // expected-warning{{comparison of distinct pointer types}}
+ WARN; // no-warning
+ if (b<a) // expected-warning{{comparison of distinct pointer types}}
+ WARN; // no-warning
+ if (a>=b) // expected-warning{{comparison of distinct pointer types}}
+ WARN; // no-warning
+ if (b<=a) // expected-warning{{comparison of distinct pointer types}}
+ WARN; // no-warning
+}
+
+struct test { int x; int y; };
+void struct_fields() {
+ struct test a, b;
+
+ if (&a.x == &a.y)
+ WARN; // no-warning
+ if (!(&a.x != &a.y))
+ WARN; // no-warning
+ if (&a.x > &a.y)
+ WARN; // no-warning
+ if (&a.y < &a.x)
+ WARN; // no-warning
+ if (&a.x >= &a.y)
+ WARN; // no-warning
+ if (&a.y <= &a.x)
+ WARN; // no-warning
+
+ if (&a.x == &b.x)
+ WARN; // no-warning
+ if (!(&a.x != &b.x))
+ WARN; // no-warning
+ if (&a.x > &b.x)
+ WARN; // expected-warning{{}}
+ if (&b.x < &a.x)
+ WARN; // expected-warning{{}}
+ if (&a.x >= &b.x)
+ WARN; // expected-warning{{}}
+ if (&b.x <= &a.x)
+ WARN; // expected-warning{{}}
+}
+
+void mixed_region_types() {
+ struct test s;
+ int array[2];
+ void *a = &array, *b = &s;
+
+ if (&a == &b)
+ WARN; // no-warning
+ if (!(&a != &b))
+ WARN; // no-warning
+ if (&a > &b)
+ WARN; // expected-warning{{}}
+ if (&b < &a)
+ WARN; // expected-warning{{}}
+ if (&a >= &b)
+ WARN; // expected-warning{{}}
+ if (&b <= &a)
+ WARN; // expected-warning{{}}
+}
+
+void symbolic_region(int *p) {
+ int a;
+
+ if (&a == p)
+ WARN; // no-warning
+ if (&a != p)
+ WARN; // expected-warning{{}}
+ if (&a > p)
+ WARN; // expected-warning{{}}
+ if (&a < p)
+ WARN; // expected-warning{{}}
+ if (&a >= p)
+ WARN; // expected-warning{{}}
+ if (&a <= p)
+ WARN; // expected-warning{{}}
+}
+
+void PR7527 (int *p) {
+ if (((int) p) & 1) // not crash
+ return;
+}
diff --git a/clang/test/Analysis/rdar-6442306-1.m b/clang/test/Analysis/rdar-6442306-1.m
new file mode 100644
index 0000000..62992d0
--- /dev/null
+++ b/clang/test/Analysis/rdar-6442306-1.m
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core %s -analyzer-store=region -verify
+
+typedef int bar_return_t;
+typedef struct {
+ unsigned char int_rep;
+} Foo_record_t;
+extern Foo_record_t Foo_record;
+struct QuxSize {};
+typedef struct QuxSize QuxSize;
+typedef struct {
+ Foo_record_t Foo;
+ QuxSize size[0];
+} __Request__SetPortalSize_t;
+
+double __Foo_READSWAP__double(double*);
+
+static __inline__ bar_return_t
+__Beeble_check__Request__SetPortalSize_t(__Request__SetPortalSize_t *In0P) {
+ if (In0P->Foo.int_rep != Foo_record.int_rep) {
+ do {
+ int __i__, __C__ = (2);
+ for (__i__ = 0;
+ __i__ < __C__;
+ __i__++) do {
+ *(&((double *)(&In0P->size))[__i__]) =
+ __Foo_READSWAP__double(&((double *)(&In0P->size))[__i__]);
+ }
+ while (0);
+ }
+ while (0);
+ }
+ return 0;
+}
diff --git a/clang/test/Analysis/rdar-6540084.m b/clang/test/Analysis/rdar-6540084.m
new file mode 100644
index 0000000..d710c47
--- /dev/null
+++ b/clang/test/Analysis/rdar-6540084.m
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=deadcode.DeadStores -verify %s
+//
+// This test exercises the live variables analysis (LiveVariables.cpp).
+// The case originally identified a non-termination bug.
+//
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@interface NSObject <NSObject> {} @end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+@class NSArray;
+@class NSMutableArray, NSIndexSet, NSView, NSPredicate, NSString, NSViewAnimation, NSTimer; // expected-note{{forward declaration of class here}}
+@interface FooBazController : NSObject {}
+@end
+typedef struct {} TazVersion;
+@class TazNode;
+@interface TazGuttenberg : NSObject {} typedef NSUInteger BugsBunnyType; @end
+@interface FooBaz : NSObject {}
+@property (nonatomic) BugsBunnyType matchType;
+@property (nonatomic, retain) NSArray *papyrus; @end
+@implementation FooBazController
+- (NSArray *)excitingStuff:(FooBaz *)options {
+ BugsBunnyType matchType = options.matchType;
+ NSPredicate *isSearchablePredicate = [NSPredicate predicateWithFormat:@"isSearchable == YES"]; // expected-warning{{receiver 'NSPredicate' is a forward class and corresponding}} // expected-warning{{return type defaults to 'id'}}
+ for (TazGuttenberg *Guttenberg in options.papyrus) {
+ NSArray *GuttenbergNodes = [Guttenberg nodes]; // expected-warning{{return type defaults to 'id'}}
+ NSArray *searchableNodes = [GuttenbergNodes filteredArrayUsingPredicate:isSearchablePredicate]; // expected-warning{{return type defaults to 'id'}}
+ for (TazNode *node in searchableNodes) {
+ switch (matchType) {
+ default: break;
+ }
+ }
+ }
+ while (1) {}
+}
+@end
diff --git a/clang/test/Analysis/rdar-6541136-region.c b/clang/test/Analysis/rdar-6541136-region.c
new file mode 100644
index 0000000..b90d4f4
--- /dev/null
+++ b/clang/test/Analysis/rdar-6541136-region.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -verify -analyze -analyzer-checker=core,experimental.security.ArrayBound -analyzer-store=region %s
+
+struct tea_cheese { unsigned magic; };
+typedef struct tea_cheese kernel_tea_cheese_t;
+extern kernel_tea_cheese_t _wonky_gesticulate_cheese;
+
+// This test case exercises the ElementRegion::getRValueType() logic.
+
+void test1( void ) {
+ kernel_tea_cheese_t *wonky = &_wonky_gesticulate_cheese;
+ struct load_wine *cmd = (void*) &wonky[1];
+ cmd = cmd;
+ char *p = (void*) &wonky[1];
+ kernel_tea_cheese_t *q = &wonky[1];
+ // This test case tests both the RegionStore logic (doesn't crash) and
+ // the out-of-bounds checking. We don't expect the warning for now since
+ // out-of-bound checking is temporarily disabled.
+ kernel_tea_cheese_t r = *q; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
+}
+
+void test1_b( void ) {
+ kernel_tea_cheese_t *wonky = &_wonky_gesticulate_cheese;
+ struct load_wine *cmd = (void*) &wonky[1];
+ cmd = cmd;
+ char *p = (void*) &wonky[1];
+ *p = 1; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
+}
diff --git a/clang/test/Analysis/rdar-6562655.m b/clang/test/Analysis/rdar-6562655.m
new file mode 100644
index 0000000..3a59273
--- /dev/null
+++ b/clang/test/Analysis/rdar-6562655.m
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-constraints=basic -analyzer-store=region -verify %s
+//
+// This test case mainly checks that the retain/release checker doesn't crash
+// on this file.
+//
+typedef int int32_t;
+typedef signed char BOOL;
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end @interface NSObject <NSObject> {}
+@end extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+@interface NSResponder : NSObject <NSCoding> {}
+@end @protocol NSAnimatablePropertyContainer - (id)animator;
+@end extern NSString *NSAnimationTriggerOrderIn ;
+@interface NSView : NSResponder <NSAnimatablePropertyContainer> {
+}
+@end enum {
+NSNullCellType = 0, NSTextCellType = 1, NSImageCellType = 2 };
+typedef struct __CFlags {
+ unsigned int botnet:3;
+}
+ _CFlags;
+@interface Bar : NSObject <NSCopying, NSCoding> {
+ _CFlags _cFlags;
+@private id _support;
+}
+@end extern NSString *NSControlTintDidChangeNotification;
+typedef NSInteger NSBotnet;
+@interface NSControl : NSView {
+}
+@end @class NSAttributedString, NSFont, NSImage, NSSound;
+typedef int32_t Baz;
+@interface Bar(BarInternal) - (void)_setIsWhite:(BOOL)isWhite;
+@end
+@interface Bar (BarBotnetCompatibility)
+- (NSBotnet)_initialBotnetZorg;
+@end
+typedef struct _NSRunArrayItem {
+ unsigned int botnetIsSet:1;
+} BarAuxFlags;
+@interface BarAuxiliary : NSObject {
+@public
+ NSControl *controlView;
+ BarAuxFlags auxCFlags;
+}
+@end
+@implementation Bar
+static Baz Qux = 0;
+- (id)copyWithZone:(NSZone *)zone { return 0; }
+- (void)encodeWithCoder:(NSCoder *)coder {}
+@end
+@implementation Bar (BarBotnet)
+- (NSBotnet)botnet {
+ if (!(*(BarAuxiliary **)&self->_support)->auxCFlags.botnetIsSet) {
+ _cFlags.botnet = [self _initialBotnetZorg];
+ }
+ while (1) {}
+}
+@end
diff --git a/clang/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m b/clang/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
new file mode 100644
index 0000000..5af4776
--- /dev/null
+++ b/clang/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -verify -Wno-objc-root-class %s
+
+typedef struct Foo { int x; } Bar;
+
+@interface MyClass {}
+- (Bar)foo;
+@end
+@implementation MyClass
+- (Bar)foo {
+ struct Foo f = { 0 };
+ return f;
+}
+@end
+
+void createFoo() {
+ MyClass *obj = 0;
+ Bar f = [obj foo]; // no-warning
+}
+
+void createFoo2() {
+ MyClass *obj = 0;
+ [obj foo]; // no-warning
+ Bar f = [obj foo]; // no-warning
+}
+
diff --git a/clang/test/Analysis/rdar-7168531.m b/clang/test/Analysis/rdar-7168531.m
new file mode 100644
index 0000000..1516255
--- /dev/null
+++ b/clang/test/Analysis/rdar-7168531.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -triple i386-apple-darwin10 -fobjc-fragile-abi -analyzer-store=region %s
+
+// Note that the target triple is important for this test case. It specifies that we use the
+// fragile Objective-C ABI.
+
+@interface Foo {
+ int x;
+}
+@end
+
+@implementation Foo
+static Foo* bar(Foo *p) {
+ if (p->x)
+ return ++p; // This is only valid for the fragile ABI.
+
+ return p;
+}
+@end
diff --git a/clang/test/Analysis/redefined_system.c b/clang/test/Analysis/redefined_system.c
new file mode 100644
index 0000000..3c08b5e
--- /dev/null
+++ b/clang/test/Analysis/redefined_system.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix,core,experimental.security.taint -w -verify %s
+
+// Make sure we don't crash when someone redefines a system function we reason about.
+
+char memmove ();
+char malloc();
+char system();
+char stdin();
+char memccpy();
+char free();
+char strdup();
+char atoi();
+
+int foo () {
+ return memmove() + malloc() + system() + stdin() + memccpy() + free() + strdup() + atoi();
+
+}
diff --git a/clang/test/Analysis/refcnt_naming.m b/clang/test/Analysis/refcnt_naming.m
new file mode 100644
index 0000000..aff713b
--- /dev/null
+++ b/clang/test/Analysis/refcnt_naming.m
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -verify %s
+
+typedef const struct __CFString * CFStringRef;
+typedef const struct __CFAllocator * CFAllocatorRef;
+typedef const struct __CFURL * CFURLRef;
+extern CFURLRef CFURLCreateWithString(CFAllocatorRef allocator, CFStringRef URLString, CFURLRef baseURL);
+typedef signed char BOOL;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@interface NSObject <NSObject> {} @end
+@class NSArray, NSString, NSURL;
+
+@interface NamingTest : NSObject {}
+-(NSObject*)copyPhoto;
+-(NSObject*)mutableCopyPhoto;
+-(NSObject*)mutable;
+-(NSObject*)mutableCopying;
+-(NSObject*)photocopy; // read as "photocopy"
+-(NSObject*)photoCopy; // read as "photo Copy"
+-(NSObject*)__blebPRCopy; // read as "bleb PRCopy"
+-(NSObject*)__blebPRcopy; // read as "bleb P Rcopy"
+-(NSObject*)new_theprefixdoescount; // read as "new theprefixdoescount"
+-(NSObject*)newestAwesomeStuff; // read as "newest awesome stuff"
+
+@end
+
+@interface MyClass : NSObject
+{
+ id myObject;
+}
+- (NSURL *)myMethod:(NSString *)inString;
+- (NSURL *)getMethod:(NSString*)inString;
+- (NSURL *)getMethod2:(NSString*)inString;
+- (void)addObject:(id) __attribute__((ns_consumed)) X;
+- (void)addObject2:(id) X;
+@end
+
+@implementation MyClass
+
+- (NSURL *)myMethod:(NSString *)inString
+{
+ NSURL *url = (NSURL *)CFURLCreateWithString(0, (CFStringRef)inString, 0); // expected-warning{{leak}}
+ return url;
+}
+
+- (NSURL *)getMethod:(NSString *)inString
+{
+ NSURL *url = (NSURL *)CFURLCreateWithString(0, (CFStringRef)inString, 0);
+ [self addObject:url];
+ return url; // no-warning
+}
+
+- (NSURL *)getMethod2:(NSString *)inString
+{
+ NSURL *url = (NSURL *)CFURLCreateWithString(0, (CFStringRef)inString, 0); // expected-warning{{leak}}
+ [self addObject2:url];
+ return url;
+}
+
+void testNames(NamingTest* x) {
+ [x copyPhoto]; // expected-warning{{leak}}
+ [x mutableCopyPhoto]; // expected-warning{{leak}}
+ [x mutable]; // no-warning
+ [x mutableCopying]; // no-warning
+ [x photocopy]; // no-warning
+ [x photoCopy]; // no-warning
+ [x __blebPRCopy]; // no-warning
+ [x __blebPRcopy]; // no-warning
+ [x new_theprefixdoescount]; // expected-warning{{leak}}
+ [x newestAwesomeStuff]; // no-warning
+}
+
+
+- (void)addObject:(id)X
+{
+ myObject = X;
+}
+
+- (void)addObject2:(id)X
+{
+ myObject = X;
+}
+
+@end
+
diff --git a/clang/test/Analysis/reference.cpp b/clang/test/Analysis/reference.cpp
new file mode 100644
index 0000000..5897e68
--- /dev/null
+++ b/clang/test/Analysis/reference.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-null-dereference %s
+// XFAIL
+
+typedef typeof(sizeof(int)) size_t;
+void malloc (size_t);
+
+void f1() {
+ int const &i = 3; // <--- **FIXME** This is currently not being modeled correctly.
+ int b = i;
+
+ int *p = 0;
+
+ if (b != 3)
+ *p = 1; // no-warning
+}
+
+char* ptr();
+char& ref();
+
+// These next two tests just shouldn't crash.
+char t1 () {
+ ref() = 'c';
+ return '0';
+}
+
+// just a sanity test, the same behavior as t1()
+char t2 () {
+ *ptr() = 'c';
+ return '0';
+}
+
+// Each of the tests below is repeated with pointers as well as references.
+// This is mostly a sanity check, but then again, both should work!
+char t3 () {
+ char& r = ref();
+ r = 'c'; // no-warning
+ if (r) return r;
+ return *(char*)0; // no-warning
+}
+
+char t4 () {
+ char* p = ptr();
+ *p = 'c'; // no-warning
+ if (*p) return *p;
+ return *(char*)0; // no-warning
+}
+
+char t5 (char& r) {
+ r = 'c'; // no-warning
+ if (r) return r;
+ return *(char*)0; // no-warning
+}
+
+char t6 (char* p) {
+ *p = 'c'; // no-warning
+ if (*p) return *p;
+ return *(char*)0; // no-warning
+}
diff --git a/clang/test/Analysis/region-1.m b/clang/test/Analysis/region-1.m
new file mode 100644
index 0000000..be92766
--- /dev/null
+++ b/clang/test/Analysis/region-1.m
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s
+//
+// This test case simply should not crash. It evaluates the logic of not
+// using MemRegion::getRValueType in incorrect places.
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object;
+- (Class)class;
+- (BOOL)isLegOfClass:(Class)aClass;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end @interface NSObject <NSObject> {
+}
+@end @class NSArray;
+@interface NSResponder : NSObject <NSCoding> {
+}
+@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView;
+@class JabasectItem;
+@protocol EcoClassifier;
+@protocol EcoClassInterfaceCommons <EcoClassifier> @end @protocol EcoImplementation;
+@protocol EcoBehavioredClassifier <EcoClassInterfaceCommons> - (NSArray *) implementations;
+@end enum {
+CK_UNRESTRICTED= 0, CK_READ_ONLY, CK_ADD_ONLY, CK_REMOVE_ONLY };
+@protocol EcoClass <EcoBehavioredClassifier> - (NSArray *) ownedAttributes;
+@end @protocol EcoNamespace;
+@protocol EcoType;
+@protocol EcoClassifier <EcoNamespace,EcoType> - (NSArray *) features;
+@end @protocol EcoComment;
+@protocol EcoElement <NSObject> - (NSArray *) ownedElements;
+@end @protocol EcoDirectedRelationship;
+@protocol EcoNamedElement <EcoElement> - (NSString *) name;
+@end extern NSString *const JabaPathSeparator;
+@protocol EcoNamespace <EcoNamedElement> - (NSArray *) Legs;
+@end enum {
+PDK_IN=0, PDK_INOUT, PDK_OUT, PDK_RETURN };
+@interface EcoElementImp : NSObject <EcoElement, NSCoding> {
+}
+@end @class EcoNamespace;
+@interface EcoNamedElementImp : EcoElementImp <EcoNamedElement>{
+}
+@end @interface EcoNamespaceImp : EcoNamedElementImp <EcoNamespace> {
+}
+@end @class JabaSCDocController, JabaSCDisplaySpecification;
+@interface JabaSCSharedDiagramViewController : NSObject {
+}
+@end extern NSString *const JabaSCsectGraphicNamesectIdentifier;
+@interface EcoClassifierImp : EcoNamespaceImp <EcoClassifier> {
+}
+@end @class EcoOperationImp;
+@interface EcoClassImp : EcoClassifierImp <EcoClass> {
+}
+@end extern NSString *const JabaAddedUMLElements;
+@class JabaSCClass, JabaSCInterface, JabaSCOperation;
+@class DosLegVaseSymbol, DosProtocolSymbol, DosMethodSymbol, DosFileReference;
+@interface HancodeFett : NSObject {
+}
++ (DosLegVaseSymbol *) symbolFromClass: (JabaSCClass *) clz;
+@end enum _JabaSourceLanguage {
+JabaSourceUnknown=0, JabaSourcePrawn, JabaSourceC, JabaSourceCPP, JabaSourceObjectiveC };
+typedef NSUInteger JabaSourceLanguage;
+@protocol JabaSCClassifier <EcoClassInterfaceCommons> - (JabaSourceLanguage)language;
+@end @interface JabaSCClass : EcoClassImp <JabaSCClassifier> {
+}
+@end @class DosGlobalID, DosPQuLC, DosPQuUnLC;
+@protocol XCProxyObjectProtocol - (id) representedObject;
+@end typedef union _Dossymbollocation {
+}
+ DosRecordArrPrl;
+@interface DosIndexEntry : NSObject {
+}
+@end @class DosProjectIndex, DosTextPapyruswiggle, DosDocPapyruswiggle, DosLegVaseSymbol;
+@interface DosSymbol : DosIndexEntry {
+}
+@end @interface DosLegVaseSymbol : DosSymbol {
+}
+@end typedef enum _DosTextRangeType {
+Dos_CharacterRangeType = 0, Dos_LineRangeType = 1 }
+ DosTextRangeType;
+@implementation JabaSCSharedDiagramViewController + (NSImage *)findImageNamed:(NSString *)name {
+ return 0;
+}
+- (void)revealSourceInEditor:(JabasectItem *)sectItem duperGesture:(BOOL)duperGesture {
+ id <EcoNamedElement> selectedElement = [sectItem representedObject];
+ id <EcoNamedElement> selectedClassifier = selectedElement;
+ DosSymbol *symbol=((void *)0);
+ if([selectedClassifier isLegOfClass:[JabaSCClass class]]) {
+ symbol = [HancodeFett symbolFromClass:(JabaSCClass *) selectedClassifier];
+ }
+}
+@end
diff --git a/clang/test/Analysis/retain-release-gc-only.m b/clang/test/Analysis/retain-release-gc-only.m
new file mode 100644
index 0000000..0340a3c
--- /dev/null
+++ b/clang/test/Analysis/retain-release-gc-only.m
@@ -0,0 +1,387 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.NSAutoreleasePool -analyzer-store=region -fobjc-gc-only -fblocks -verify -Wno-objc-root-class %s
+
+//===----------------------------------------------------------------------===//
+// Header stuff.
+//===----------------------------------------------------------------------===//
+
+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 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);
+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;
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+- (oneway void)release;
+- (id)autorelease;
+- (Class)class;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
++ (id)allocWithZone:(NSZone *)zone;
++ (id)alloc;
+- (void)dealloc;
+- (oneway void)release;
+- (id)copy;
+@end
+@interface NSObject (NSCoderMethods)
+- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+typedef struct {
+}
+NSFastEnumerationState;
+@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end @class NSString, NSDictionary;
+@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
+@end @interface NSNumber : NSValue - (char)charValue;
+- (id)initWithInt:(int)value;
+@end @class NSString;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSArray (NSArrayCreation) + (id)array;
+@end @interface NSAutoreleasePool : NSObject {
+}
+- (void)drain;
+- (id)init;
+@end extern NSString * const NSBundleDidLoadNotification;
+typedef double NSTimeInterval;
+@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate;
+@end typedef unsigned short unichar;
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length;
+- ( const char *)UTF8String;
+- (id)initWithUTF8String:(const char *)nullTerminatedCString;
++ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
+@end @class NSString, NSURL, NSError;
+@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;
+@end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary;
+@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey;
+- (void)setObject:(id)anObject forKey:(id)aKey;
+@end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (id)dictionaryWithCapacity:(NSUInteger)numItems;
+@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 masterPort, CFDictionaryRef matching );
+kern_return_t IOServiceGetMatchingServices( mach_port_t masterPort, CFDictionaryRef matching, io_iterator_t * existing );
+kern_return_t IOServiceAddNotification( mach_port_t masterPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated));
+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 masterPort, uint32_t options, const char * bsdName );
+CFMutableDictionaryRef IOOpenFirmwarePathMatching( mach_port_t masterPort, 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 );
+@interface NSTask : NSObject - (id)init;
+@end typedef struct CGColorSpace *CGColorSpaceRef;
+typedef struct CGImage *CGImageRef;
+typedef struct CGLayer *CGLayerRef;
+@interface NSResponder : NSObject <NSCoding> {
+}
+@end @protocol NSAnimatablePropertyContainer - (id)animator;
+@end extern NSString *NSAnimationTriggerOrderIn ;
+@interface NSView : NSResponder <NSAnimatablePropertyContainer> {
+}
+@end @protocol NSValidatedUserInterfaceItem - (SEL)action;
+@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
+@end @class NSDate, NSDictionary, NSError, NSException, NSNotification;
+@interface NSApplication : NSResponder <NSUserInterfaceValidations> {
+}
+@end enum {
+NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 };
+typedef NSUInteger NSApplicationTerminateReply;
+@protocol NSApplicationDelegate <NSObject> @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
+@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView;
+@interface NSCell : NSObject <NSCopying, NSCoding> {
+}
+@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError;
+typedef struct {
+}
+CVTimeStamp;
+@interface CIImage : NSObject <NSCoding, NSCopying> {
+}
+typedef int CIFormat;
+@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 );
+@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;
+@end extern NSString* const QCRendererEventKey;
+@protocol QCCompositionRenderer - (NSDictionary*) attributes;
+@end @interface QCRenderer : NSObject <QCCompositionRenderer> {
+}
+- (id) createSnapshotImageOfType:(NSString*)type;
+@end extern NSString* const QCViewDidStartRenderingNotification;
+@interface QCView : NSView <QCCompositionRenderer> {
+}
+- (id) createSnapshotImageOfType:(NSString*)type;
+@end enum {
+ICEXIFOrientation1 = 1, ICEXIFOrientation2 = 2, ICEXIFOrientation3 = 3, ICEXIFOrientation4 = 4, ICEXIFOrientation5 = 5, ICEXIFOrientation6 = 6, ICEXIFOrientation7 = 7, ICEXIFOrientation8 = 8, };
+@class ICDevice;
+@protocol ICDeviceDelegate <NSObject> @required - (void)didRemoveDevice:(ICDevice*)device;
+@end extern NSString *const ICScannerStatusWarmingUp;
+@class ICScannerDevice;
+@protocol ICScannerDeviceDelegate <ICDeviceDelegate> @optional - (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner;
+@end
+CFTypeRef CFMakeCollectable(CFTypeRef cf) ;
+
+static __inline__ __attribute__((always_inline)) id NSMakeCollectable(CFTypeRef
+cf) {
+ return cf ? (id)CFMakeCollectable(cf) : ((void*)0);
+}
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+void f1() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+ id x = [(id) A autorelease];
+ CFRelease((CFMutableArrayRef) x);
+}
+
+void f2() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}}
+ id x = [(id) A retain];
+ [x release];
+ [x release];
+}
+
+void f3() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}}
+ CFMakeCollectable(A);
+ CFRetain(A);
+}
+
+void f3b() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+ CFMakeCollectable(A);
+}
+
+
+void f4() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}}
+ NSMakeCollectable(A);
+ CFRetain(A);
+}
+
+void f4b() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+ NSMakeCollectable(A);
+}
+
+void f5() {
+ id x = [NSMakeCollectable(CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks)) autorelease]; // no-warning
+}
+
+void f5b() {
+ id x = [(id) CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks) autorelease]; // expected-warning{{leak}}
+}
+
+// Test return of non-owned objects in contexts where an owned object
+// is expected.
+@interface TestReturnNotOwnedWhenExpectedOwned
+- (NSString*)newString;
+- (CFMutableArrayRef)newArray;
+@end
+
+@implementation TestReturnNotOwnedWhenExpectedOwned
+- (NSString*)newString {
+ NSString *s = [NSString stringWithUTF8String:"hello"]; // expected-warning{{Potential leak (when using garbage collection) of an object}}
+ CFRetain(s);
+ return s;
+}
+- (CFMutableArrayRef)newArray{
+ return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+}
+@end
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6948053> False positive: object substitution during -init*
+// methods warns about returning +0 when using -fobjc-gc-only
+//===----------------------------------------------------------------------===//
+
+@interface MyClassRdar6948053 : NSObject
+- (id) init;
++ (id) shared;
+@end
+
+@implementation MyClassRdar6948053
++(id) shared {
+ return (id) 0;
+}
+- (id) init
+{
+ Class myClass = [self class];
+ [self release];
+ return [[myClass shared] retain]; // no-warning
+}
+@end
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7174400> 'ciContext createCGImage:outputImage fromRect:' returns a retained CF object (not GC'ed)//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
+
+void rdar_7174400(QCView *view, QCRenderer *renderer, CIContext *context,
+ NSString *str, CIImage *img, CGRect rect,
+ CIFormat form, CGColorSpaceRef cs) {
+ [view createSnapshotImageOfType:str]; // no-warning
+ [renderer createSnapshotImageOfType:str]; // no-warning
+ [context createCGImage:img fromRect:rect]; // expected-warning{{leak}}
+ [context createCGImage:img fromRect:rect format:form colorSpace:cs]; // expected-warning{{leak}}
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6250216> Warn against using -[NSAutoreleasePool release] in
+// GC mode
+//===----------------------------------------------------------------------===//
+
+void rdar_6250216(void) {
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ [pool release]; // expected-warning{{Use -drain instead of -release when using NSAutoreleasePool and garbage collection}}
+}
+
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7407273> Don't crash when analyzing messages sent to blocks
+//===----------------------------------------------------------------------===//
+
+@class RDar7407273;
+typedef void (^RDar7407273Block)(RDar7407273 *operation);
+void rdar7407273(RDar7407273Block b) {
+ [b copy];
+}
+
+//===----------------------------------------------------------------------===//
+// Tests of ownership attributes.
+//===----------------------------------------------------------------------===//
+
+@interface TestOwnershipAttr : NSObject
+- (NSString*) returnsAnOwnedString __attribute__((ns_returns_retained));
+- (NSString*) returnsAnOwnedCFString __attribute__((cf_returns_retained));
+@end
+
+void test_attr_1(TestOwnershipAttr *X) {
+ NSString *str = [X returnsAnOwnedString]; // no-warning
+}
+
+void test_attr_1b(TestOwnershipAttr *X) {
+ NSString *str = [X returnsAnOwnedCFString]; // expected-warning{{leak}}
+}
+
+@interface MyClassTestCFAttr : NSObject {}
+- (NSDate*) returnsCFRetained __attribute__((cf_returns_retained));
+- (NSDate*) alsoReturnsRetained;
+- (NSDate*) returnsNSRetained __attribute__((ns_returns_retained));
+@end
+
+__attribute__((cf_returns_retained))
+CFDateRef returnsRetainedCFDate() {
+ return CFDateCreate(0, CFAbsoluteTimeGetCurrent());
+}
+
+@implementation MyClassTestCFAttr
+- (NSDate*) returnsCFRetained {
+ return (NSDate*) returnsRetainedCFDate(); // No leak.
+}
+
+- (NSDate*) alsoReturnsRetained {
+ return (NSDate*) returnsRetainedCFDate(); // expected-warning{{leak}}
+}
+
+- (NSDate*) returnsNSRetained {
+ return (NSDate*) returnsRetainedCFDate(); // expected-warning{{leak}}
+}
+@end
diff --git a/clang/test/Analysis/retain-release-inline.m b/clang/test/Analysis/retain-release-inline.m
new file mode 100644
index 0000000..610df7f
--- /dev/null
+++ b/clang/test/Analysis/retain-release-inline.m
@@ -0,0 +1,347 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -analyzer-ipa=inlining -verify %s
+
+//===----------------------------------------------------------------------===//
+// 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);
+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;
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+- (oneway void)release;
+- (id)autorelease;
+- (id)init;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
++ (id)allocWithZone:(NSZone *)zone;
++ (id)alloc;
+- (void)dealloc;
+@end
+@interface NSObject (NSCoderMethods)
+- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+typedef struct {
+}
+NSFastEnumerationState;
+@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end @class NSString, NSDictionary;
+@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
+@end @interface NSNumber : NSValue - (char)charValue;
+- (id)initWithInt:(int)value;
+@end @class NSString;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSArray (NSArrayCreation) + (id)array;
+@end @interface NSAutoreleasePool : NSObject {
+}
+- (void)drain;
+@end extern NSString * const NSBundleDidLoadNotification;
+typedef double NSTimeInterval;
+@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate;
+@end typedef unsigned short unichar;
+@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;
+@end @class NSString, NSURL, NSError;
+@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;
+@end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary;
+@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey;
+- (void)setObject:(id)anObject forKey:(id)aKey;
+@end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (id)dictionaryWithCapacity:(NSUInteger)numItems;
+@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 masterPort, CFDictionaryRef matching );
+kern_return_t IOServiceGetMatchingServices( mach_port_t masterPort, CFDictionaryRef matching, io_iterator_t * existing );
+kern_return_t IOServiceAddNotification( mach_port_t masterPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated));
+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 masterPort, uint32_t options, const char * bsdName );
+CFMutableDictionaryRef IOOpenFirmwarePathMatching( mach_port_t masterPort, 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 );
+@interface NSTask : NSObject - (id)init;
+@end typedef struct CGColorSpace *CGColorSpaceRef;
+typedef struct CGImage *CGImageRef;
+typedef struct CGLayer *CGLayerRef;
+@interface NSResponder : NSObject <NSCoding> {
+}
+@end @protocol NSAnimatablePropertyContainer - (id)animator;
+@end extern NSString *NSAnimationTriggerOrderIn ;
+@interface NSView : NSResponder <NSAnimatablePropertyContainer> {
+}
+@end @protocol NSValidatedUserInterfaceItem - (SEL)action;
+@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
+@end @class NSDate, NSDictionary, NSError, NSException, NSNotification;
+@interface NSApplication : NSResponder <NSUserInterfaceValidations> {
+}
+@end enum {
+NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 };
+typedef NSUInteger NSApplicationTerminateReply;
+@protocol NSApplicationDelegate <NSObject> @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
+@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView;
+@interface NSCell : NSObject <NSCopying, NSCoding> {
+}
+@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError;
+typedef struct {
+}
+CVTimeStamp;
+@interface CIImage : NSObject <NSCoding, NSCopying> {
+}
+typedef int CIFormat;
+@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 );
+@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;
+@end extern NSString* const QCRendererEventKey;
+@protocol QCCompositionRenderer - (NSDictionary*) attributes;
+@end @interface QCRenderer : NSObject <QCCompositionRenderer> {
+}
+- (id) createSnapshotImageOfType:(NSString*)type;
+@end extern NSString* const QCViewDidStartRenderingNotification;
+@interface QCView : NSView <QCCompositionRenderer> {
+}
+- (id) createSnapshotImageOfType:(NSString*)type;
+@end enum {
+ICEXIFOrientation1 = 1, ICEXIFOrientation2 = 2, ICEXIFOrientation3 = 3, ICEXIFOrientation4 = 4, ICEXIFOrientation5 = 5, ICEXIFOrientation6 = 6, ICEXIFOrientation7 = 7, ICEXIFOrientation8 = 8, };
+@class ICDevice;
+@protocol ICDeviceDelegate <NSObject> @required - (void)didRemoveDevice:(ICDevice*)device;
+@end extern NSString *const ICScannerStatusWarmingUp;
+@class ICScannerDevice;
+@protocol ICScannerDeviceDelegate <ICDeviceDelegate> @optional - (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner;
+@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);
+
+@interface NSMutableArray : NSObject
+- (void)addObject:(id)object;
++ (id)array;
+@end
+
+enum {
+ NSASCIIStringEncoding = 1,
+ NSNEXTSTEPStringEncoding = 2,
+ NSJapaneseEUCStringEncoding = 3,
+ NSUTF8StringEncoding = 4,
+ NSISOLatin1StringEncoding = 5,
+ NSSymbolStringEncoding = 6,
+ NSNonLossyASCIIStringEncoding = 7,
+};
+typedef struct __CFString * CFMutableStringRef;
+typedef NSUInteger NSStringEncoding;
+
+extern CFStringRef CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator);
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+void foo(id x) {
+ [x retain];
+}
+
+void bar(id x) {
+ [x release];
+}
+
+void test() {
+ NSString *s = [[NSString alloc] init]; // expected-warning {{Potential leak}}
+ foo(s);
+ foo(s);
+ bar(s);
+}
+void test_neg() {
+ NSString *s = [[NSString alloc] init]; // no-warning
+ foo(s);
+ foo(s);
+ bar(s);
+ bar(s);
+ bar(s);
+}
+
+//===----------------------------------------------------------------------===//
+// Test returning retained and not-retained values.
+//===----------------------------------------------------------------------===//
+
+// On return (intraprocedural), assume CF objects are leaked.
+CFStringRef test_return_ratained_CF(char *bytes) {
+ CFStringRef str;
+ return CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0); // expected-warning {{leak}}
+}
+
+// On return (intraprocedural), assume NSObjects are not leaked.
+id test_return_retained_NS() {
+ return [[NSString alloc] init]; // no-warning
+}
+
+void test_test_return_retained() {
+ id x = test_return_retained_NS(); // expected-warning {{leak}}
+ [x retain];
+ [x release];
+}
+
+//===----------------------------------------------------------------------===//
+// Test not applying "double effects" from inlining and RetainCountChecker summaries.
+// If we inline a call, we should already see its retain/release semantics.
+//===----------------------------------------------------------------------===//
+
+__attribute__((cf_returns_retained)) CFStringRef test_return_inline(CFStringRef x) {
+ CFRetain(x);
+ return x;
+}
+
+void test_test_return_inline(char *bytes) {
+ CFStringRef str = CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0);
+ // After this call, 'str' really has +2 reference count.
+ CFStringRef str2 = test_return_inline(str);
+ // After this call, 'str' really has a +1 reference count.
+ CFRelease(str);
+ // After this call, 'str2' and 'str' has a +0 reference count.
+ CFRelease(str2);
+}
+
+void test_test_return_inline_2(char *bytes) {
+ CFStringRef str = CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0); // expected-warning {{leak}}
+ // After this call, 'str' really has +2 reference count.
+ CFStringRef str2 = test_return_inline(str);
+ // After this call, 'str' really has a +1 reference count.
+ CFRelease(str);
+}
+
+
+
diff --git a/clang/test/Analysis/retain-release-path-notes-gc.m b/clang/test/Analysis/retain-release-path-notes-gc.m
new file mode 100644
index 0000000..1e74f00
--- /dev/null
+++ b/clang/test/Analysis/retain-release-path-notes-gc.m
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -analyzer-output=text -fobjc-gc-only -verify %s
+
+/***
+This file is for testing the path-sensitive notes for retain/release errors.
+Its goal is to have simple branch coverage of any path-based diagnostics,
+not to actually check all possible retain/release errors.
+
+This file is for notes that only appear in a GC-enabled analysis.
+Non-specific and ref-count-only notes should go in retain-release-path-notes.m.
+***/
+
+@interface NSObject
++ (id)alloc;
+- (id)init;
+- (void)dealloc;
+
+- (Class)class;
+
+- (id)retain;
+- (void)release;
+- (void)autorelease;
+@end
+
+@interface Foo : NSObject
+- (id)methodWithValue;
+@property(retain) id propertyValue;
+@end
+
+typedef struct CFType *CFTypeRef;
+CFTypeRef CFRetain(CFTypeRef);
+void CFRelease(CFTypeRef);
+
+id NSMakeCollectable(CFTypeRef);
+CFTypeRef CFMakeCollectable(CFTypeRef);
+
+CFTypeRef CFCreateSomething();
+CFTypeRef CFGetSomething();
+
+
+void creationViaCFCreate () {
+ CFTypeRef leaked = CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected}}
+ return; // expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
+}
+
+void makeCollectable () {
+ CFTypeRef leaked = CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected}}
+ CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +2 retain count}}
+ CFMakeCollectable(leaked); // expected-note{{In GC mode a call to 'CFMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. An object must have a 0 retain count to be garbage collected. After this call its retain count is +1}}
+ NSMakeCollectable(leaked); // expected-note{{In GC mode a call to 'NSMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. Since it now has a 0 retain count the object can be automatically collected by the garbage collector}}
+ CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +1 retain count. The object is not eligible for garbage collection until the retain count reaches 0 again}}
+ return; // expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
+}
+
+void retainReleaseIgnored () {
+ id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +0 retain count}}
+ [object retain]; // expected-note{{In GC mode the 'retain' message has no effect}}
+ [object release]; // expected-note{{In GC mode the 'release' message has no effect}}
+ [object autorelease]; // expected-note{{In GC mode an 'autorelease' has no effect}}
+ CFRelease((CFTypeRef)object); // expected-warning{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} expected-note{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}}
+}
+
+@implementation Foo (FundamentalRuleUnderGC)
+- (id)getViolation {
+ id object = (id) CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected}}
+ return object; // expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' and returned from method 'getViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector}}
+}
+
+- (id)copyViolation {
+ id object = (id) CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected}}
+ return object; // expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' and returned from method 'copyViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector}}
+}
+@end
+
diff --git a/clang/test/Analysis/retain-release-path-notes.m b/clang/test/Analysis/retain-release-path-notes.m
new file mode 100644
index 0000000..c3f5fcd
--- /dev/null
+++ b/clang/test/Analysis/retain-release-path-notes.m
@@ -0,0 +1,132 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -analyzer-output=text -verify %s
+
+// This actually still works after the pseudo-object refactor, it just
+// uses messages that say 'method' instead of 'property'. Ted wanted
+// this xfailed and filed as a bug. rdar://problem/10402993
+
+/***
+This file is for testing the path-sensitive notes for retain/release errors.
+Its goal is to have simple branch coverage of any path-based diagnostics,
+not to actually check all possible retain/release errors.
+
+This file includes notes that only appear in a ref-counted analysis.
+GC-specific notes should go in retain-release-path-notes-gc.m.
+***/
+
+@interface NSObject
++ (id)alloc;
+- (id)init;
+- (void)dealloc;
+
+- (Class)class;
+
+- (id)retain;
+- (void)release;
+- (void)autorelease;
+@end
+
+@interface Foo : NSObject
+- (id)methodWithValue;
+@property(retain) id propertyValue;
+@end
+
+typedef struct CFType *CFTypeRef;
+CFTypeRef CFRetain(CFTypeRef);
+void CFRelease(CFTypeRef);
+
+id NSMakeCollectable(CFTypeRef);
+CFTypeRef CFMakeCollectable(CFTypeRef);
+
+CFTypeRef CFCreateSomething();
+CFTypeRef CFGetSomething();
+
+
+void creationViaAlloc () {
+ id leaked = [[NSObject alloc] init]; // expected-warning{{leak}} expected-note{{Method returns an Objective-C object with a +1 retain count}}
+ return; // expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
+}
+
+void creationViaCFCreate () {
+ CFTypeRef leaked = CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count}}
+ return; // expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
+}
+
+void acquisitionViaMethod (Foo *foo) {
+ id leaked = [foo methodWithValue]; // expected-warning{{leak}} expected-note{{Method returns an Objective-C object with a +0 retain count}}
+ [leaked retain]; // expected-note{{Reference count incremented. The object now has a +1 retain count}}
+ [leaked retain]; // expected-note{{Reference count incremented. The object now has a +2 retain count}}
+ [leaked release]; // expected-note{{Reference count decremented. The object now has a +1 retain count}}
+ return; // expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
+}
+
+void acquisitionViaProperty (Foo *foo) {
+ id leaked = foo.propertyValue; // expected-warning{{leak}} expected-note{{Property returns an Objective-C object with a +0 retain count}}
+ [leaked retain]; // expected-note{{Reference count incremented. The object now has a +1 retain count}}
+ return; // expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
+}
+
+void acquisitionViaCFFunction () {
+ CFTypeRef leaked = CFGetSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count}}
+ CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +1 retain count}}
+ return; // expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
+}
+
+void explicitDealloc () {
+ id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+ [object dealloc]; // expected-note{{Object released by directly sending the '-dealloc' message}}
+ [object class]; // expected-warning{{Reference-counted object is used after it is released}} // expected-note{{Reference-counted object is used after it is released}}
+}
+
+void implicitDealloc () {
+ id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+ [object release]; // expected-note{{Object released}}
+ [object class]; // expected-warning{{Reference-counted object is used after it is released}} // expected-note{{Reference-counted object is used after it is released}}
+}
+
+void overAutorelease () {
+ id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+ [object autorelease]; // expected-note{{Object sent -autorelease message}}
+ [object autorelease]; // expected-note{{Object sent -autorelease message}}
+ return; // expected-warning{{Object sent -autorelease too many times}} expected-note{{Object over-autoreleased: object was sent -autorelease 2 times but the object has a +1 retain count}}
+}
+
+void autoreleaseUnowned (Foo *foo) {
+ id object = foo.propertyValue; // expected-note{{Property returns an Objective-C object with a +0 retain count}}
+ [object autorelease]; // expected-note{{Object sent -autorelease message}}
+ return; // expected-warning{{Object sent -autorelease too many times}} expected-note{{Object over-autoreleased: object was sent -autorelease but the object has a +0 retain count}}
+}
+
+void makeCollectableIgnored () {
+ CFTypeRef leaked = CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count}}
+ CFMakeCollectable(leaked); // expected-note{{When GC is not enabled a call to 'CFMakeCollectable' has no effect on its argument}}
+ NSMakeCollectable(leaked); // expected-note{{When GC is not enabled a call to 'NSMakeCollectable' has no effect on its argument}}
+ return; // expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
+}
+
+CFTypeRef CFCopyRuleViolation () {
+ CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count}}
+ return object; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object returned to caller with a +0 retain count}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
+}
+
+CFTypeRef CFGetRuleViolation () {
+ CFTypeRef object = CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count}}
+ return object; // expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' is returned from a function whose name ('CFGetRuleViolation') does not contain 'Copy' or 'Create'. This violates the naming convention rules given in the Memory Management Guide for Core Foundation}}
+}
+
+@implementation Foo (FundamentalMemoryManagementRules)
+- (id)copyViolation {
+ id result = self.propertyValue; // expected-note{{Property returns an Objective-C object with a +0 retain count}}
+ return result; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object returned to caller with a +0 retain count}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
+}
+
+- (id)getViolation {
+ id result = [[Foo alloc] init]; // expected-warning{{leak}} expected-note{{Method returns an Objective-C object with a +1 retain count}}
+ return result; // expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'result' is returned from a method whose name ('getViolation') does not start with 'copy', 'mutableCopy', 'alloc' or 'new'. This violates the naming convention rules given in the Memory Management Guide for Cocoa}}
+}
+
+- (id)copyAutorelease {
+ id result = [[Foo alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+ [result autorelease]; // expected-note{{Object sent -autorelease message}}
+ return result; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object returned to caller with a +0 retain count}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
+}
+@end
diff --git a/clang/test/Analysis/retain-release-region-store.m b/clang/test/Analysis/retain-release-region-store.m
new file mode 100644
index 0000000..9173813
--- /dev/null
+++ b/clang/test/Analysis/retain-release-region-store.m
@@ -0,0 +1,257 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -analyzer-max-loop 6 -verify %s
+
+//===----------------------------------------------------------------------===//
+// The following code is reduced using delta-debugging from
+// Foundation.h (Mac OS X).
+//
+// It includes the basic definitions for the test cases below.
+// Not including Foundation.h directly makes this test case both svelte and
+// portable to non-Mac platforms.
+//===----------------------------------------------------------------------===//
+
+typedef unsigned int __darwin_natural_t;
+typedef unsigned long UInt32;
+typedef signed long CFIndex;
+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);
+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);
+typedef const struct __CFDictionary * CFDictionaryRef;
+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;
+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 signed char BOOL;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+- (oneway void)release;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
+- (id)init;
++ (id)allocWithZone:(NSZone *)zone;
++ (id)alloc;
+- (void)dealloc;
+@end
+typedef float CGFloat;
+typedef double NSTimeInterval;
+@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate;
+@end enum {
+NSObjCNoType = 0, NSObjCVoidType = 'v', NSObjCCharType = 'c', NSObjCShortType = 's', NSObjCLongType = 'l', NSObjCLonglongType = 'q', NSObjCFloatType = 'f', NSObjCDoubleType = 'd', NSObjCBoolType = 'B', NSObjCSelectorType = ':', NSObjCObjectType = '@', NSObjCStructType = '{', NSObjCPointerType = '^', NSObjCStringType = '*', NSObjCArrayType = '[', NSObjCUnionType = '(', NSObjCBitfield = 'b' }
+__attribute__((deprecated));
+typedef int kern_return_t;
+typedef kern_return_t mach_error_t;
+typedef mach_port_t io_object_t;
+typedef io_object_t io_service_t;
+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 );
+@interface NSAppleEventManager : NSObject {
+}
+@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 );
+@interface NSNumber : NSObject
+- (id)initWithInt:(int)value;
+@end
+typedef unsigned long NSUInteger;
+@interface NSArray : NSObject
+-(id) initWithObjects:(const id *)objects count:(NSUInteger) cnt;
+@end
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+// Test to see if we *issue* an error when we store the pointer
+// to a struct. This differs from basic store.
+
+CFAbsoluteTime CFAbsoluteTimeGetCurrent(void);
+
+struct foo {
+ NSDate* f;
+};
+
+// FIXME: We should be warning about a use-after-free here, but we
+// temporarily "escape" retain counted objects stored to structs very eagerly
+// until we can properly tell whether they have escaped via a return value
+// or not.
+CFAbsoluteTime f4() {
+ struct foo x;
+
+ CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+ CFDateRef date = CFDateCreate(0, t);
+ [((NSDate*) date) retain];
+ CFRelease(date);
+ CFDateGetAbsoluteTime(date); // no-warning
+ x.f = (NSDate*) date;
+ [((NSDate*) date) release];
+ // FIXME: the following line should warn.
+ t = CFDateGetAbsoluteTime(date); // no-warning
+ return t;
+}
+
+// Test that assigning to an self.ivar loses track of an object.
+// This is a temporary hack to reduce false positives.
+@interface Test3 : NSObject {
+ id myObj;
+}
+- (void)test_self_assign_ivar;
+@end
+
+@implementation Test3
+- (void)test_self_assign_ivar {
+ CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+ CFDateRef date = CFDateCreate(0, t); // no-warning
+ myObj = (id) date;
+}
+@end
+
+//===------------------------------------------------------------------------------------------===//
+// <rdar://problem/7257223> (also <rdar://problem/7283470>) - False positive due to not invalidating
+// the reference count of a tracked region that was itself invalidated.
+//===------------------------------------------------------------------------------------------===//
+
+typedef struct __rdar_7257223 { CFDateRef x; } RDar7257223;
+void rdar_7257223_aux(RDar7257223 *p);
+
+CFDateRef rdar7257223_Create(void) {
+ RDar7257223 s;
+ CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+ s.x = CFDateCreate(0, t); // no-warning
+ rdar_7257223_aux(&s);
+ return s.x;
+}
+
+CFDateRef rdar7257223_Create_2(void) {
+ RDar7257223 s;
+ CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+ s.x = CFDateCreate(0, t); // no-warning
+ return s.x;
+}
+
+void rdar7283470(void) {
+ NSNumber *numbers[] = {
+ [[NSNumber alloc] initWithInt:1], // no-warning
+ [[NSNumber alloc] initWithInt:2], // no-warning
+ [[NSNumber alloc] initWithInt:3], // no-warning
+ [[NSNumber alloc] initWithInt:4], // no-warning
+ [[NSNumber alloc] initWithInt:5] // no-warning
+ };
+
+ for (unsigned i = 0 ; i < sizeof(numbers) / sizeof(numbers[0]) ; ++i)
+ [numbers[i] release];
+}
+
+void rdar7283470_positive(void) {
+ NSNumber *numbers[] = {
+ [[NSNumber alloc] initWithInt:1], // expected-warning{{leak}}
+ [[NSNumber alloc] initWithInt:2], // expected-warning{{leak}}
+ [[NSNumber alloc] initWithInt:3], // expected-warning{{leak}}
+ [[NSNumber alloc] initWithInt:4], // expected-warning{{leak}}
+ [[NSNumber alloc] initWithInt:5] // expected-warning{{leak}}
+ };
+}
+
+void rdar7283470_2(void) {
+ NSNumber *numbers[] = {
+ [[NSNumber alloc] initWithInt:1], // no-warning
+ [[NSNumber alloc] initWithInt:2], // no-warning
+ [[NSNumber alloc] initWithInt:3], // no-warning
+ [[NSNumber alloc] initWithInt:4], // no-warning
+ [[NSNumber alloc] initWithInt:5] // no-warning
+ };
+
+ NSArray *s_numbers =[[NSArray alloc] initWithObjects:&numbers[0] count:sizeof(numbers) / sizeof(numbers[0])];
+
+ for (unsigned i = 0 ; i < sizeof(numbers) / sizeof(numbers[0]) ; ++i)
+ [numbers[i] release];
+
+ [s_numbers release];
+}
+
+void rdar7283470_2_positive(void) {
+ NSNumber *numbers[] = {
+ [[NSNumber alloc] initWithInt:1], // no-warning
+ [[NSNumber alloc] initWithInt:2], // no-warning
+ [[NSNumber alloc] initWithInt:3], // no-warning
+ [[NSNumber alloc] initWithInt:4], // no-warning
+ [[NSNumber alloc] initWithInt:5] // no-warning
+ };
+
+ NSArray *s_numbers =[[NSArray alloc] initWithObjects: &numbers[0] count:sizeof(numbers) / sizeof(numbers[0])]; // expected-warning{{leak}}
+
+ for (unsigned i = 0 ; i < sizeof(numbers) / sizeof(numbers[0]) ; ++i)
+ [numbers[i] release];
+}
+
+void pr6699(int x) {
+ CFDateRef values[2];
+ values[0] = values[1] = 0;
+
+ if (x) {
+ CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
+ values[1] = CFDateCreate(0, t);
+ }
+
+ if (values[1]) {
+ // A bug in RegionStore::RemoveDeadBindings caused 'values[1]' to get prematurely
+ // pruned from the store.
+ CFRelease(values[1]); // no-warning
+ }
+}
+
+// <rdar://problem/8261992> Idempotent operation checker false positive with ObjC ivars
+@interface R8261992 : NSObject {
+ @package int myIvar;
+}
+@end
+
+static void R8261992_ChangeMyIvar(R8261992 *tc) {
+ tc->myIvar = 5;
+}
+
+void R8261992_test(R8261992 *tc) {
+ int temp = tc->myIvar;
+ // The ivar binding for tc->myIvar gets invalidated.
+ R8261992_ChangeMyIvar(tc);
+ tc->myIvar = temp; // no-warning
+ tc = [[R8261992 alloc] init];
+ temp = tc->myIvar; // no-warning
+ // The ivar binding for tc->myIvar gets invalidated.
+ R8261992_ChangeMyIvar(tc);
+ tc->myIvar = temp;
+ [tc release]; // no-warning
+ // did we analyze this?
+ int *p = 0x0;
+ *p = 0xDEADBEEF; // expected-warning{{null}}
+}
+
diff --git a/clang/test/Analysis/retain-release.m b/clang/test/Analysis/retain-release.m
new file mode 100644
index 0000000..06c510e
--- /dev/null
+++ b/clang/test/Analysis/retain-release.m
@@ -0,0 +1,1741 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -x objective-c++ -Wno-objc-root-class %s
+
+#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
+
+//===----------------------------------------------------------------------===//
+// 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);
+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;
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+- (oneway void)release;
+- (id)autorelease;
+- (NSString *)description;
+- (id)init;
+@end
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
++ (id)allocWithZone:(NSZone *)zone;
++ (id)alloc;
+- (void)dealloc;
+@end
+@interface NSObject (NSCoderMethods)
+- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+typedef struct {
+}
+NSFastEnumerationState;
+@protocol NSFastEnumeration
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+@class NSString, NSDictionary;
+@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
+@end @interface NSNumber : NSValue - (char)charValue;
+- (id)initWithInt:(int)value;
+@end @class NSString;
+@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;
+@end @interface NSArray (NSArrayCreation) + (id)array;
+@end @interface NSAutoreleasePool : NSObject {
+}
+- (void)drain;
+@end extern NSString * const NSBundleDidLoadNotification;
+typedef double NSTimeInterval;
+@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate;
+@end typedef unsigned short unichar;
+@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;
+@end @class NSString, NSURL, NSError;
+@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;
+@end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary;
+@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;
+@end
+@interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey;
+- (void)setObject:(id)anObject forKey:(id)aKey;
+@end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (id)dictionaryWithCapacity:(NSUInteger)numItems;
+@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 masterPort, CFDictionaryRef matching );
+kern_return_t IOServiceGetMatchingServices( mach_port_t masterPort, CFDictionaryRef matching, io_iterator_t * existing );
+kern_return_t IOServiceAddNotification( mach_port_t masterPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated));
+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 masterPort, uint32_t options, const char * bsdName );
+CFMutableDictionaryRef IOOpenFirmwarePathMatching( mach_port_t masterPort, 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 );
+@interface NSTask : NSObject - (id)init;
+@end typedef struct CGColorSpace *CGColorSpaceRef;
+typedef struct CGImage *CGImageRef;
+typedef struct CGLayer *CGLayerRef;
+@interface NSResponder : NSObject <NSCoding> {
+}
+@end @protocol NSAnimatablePropertyContainer - (id)animator;
+@end extern NSString *NSAnimationTriggerOrderIn ;
+@interface NSView : NSResponder <NSAnimatablePropertyContainer> {
+}
+@end @protocol NSValidatedUserInterfaceItem - (SEL)action;
+@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
+@end @class NSDate, NSDictionary, NSError, NSException, NSNotification;
+@interface NSApplication : NSResponder <NSUserInterfaceValidations> {
+}
+@end enum {
+NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 };
+typedef NSUInteger NSApplicationTerminateReply;
+@protocol NSApplicationDelegate <NSObject> @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
+@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView;
+@interface NSCell : NSObject <NSCopying, NSCoding> {
+}
+@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError;
+typedef struct {
+}
+CVTimeStamp;
+@interface CIImage : NSObject <NSCoding, NSCopying> {
+}
+typedef int CIFormat;
+@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 );
+@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;
+@end extern NSString* const QCRendererEventKey;
+@protocol QCCompositionRenderer - (NSDictionary*) attributes;
+@end @interface QCRenderer : NSObject <QCCompositionRenderer> {
+}
+- (id) createSnapshotImageOfType:(NSString*)type;
+@end extern NSString* const QCViewDidStartRenderingNotification;
+@interface QCView : NSView <QCCompositionRenderer> {
+}
+- (id) createSnapshotImageOfType:(NSString*)type;
+@end enum {
+ICEXIFOrientation1 = 1, ICEXIFOrientation2 = 2, ICEXIFOrientation3 = 3, ICEXIFOrientation4 = 4, ICEXIFOrientation5 = 5, ICEXIFOrientation6 = 6, ICEXIFOrientation7 = 7, ICEXIFOrientation8 = 8, };
+@class ICDevice;
+@protocol ICDeviceDelegate <NSObject> @required - (void)didRemoveDevice:(ICDevice*)device;
+@end extern NSString *const ICScannerStatusWarmingUp;
+@class ICScannerDevice;
+@protocol ICScannerDeviceDelegate <ICDeviceDelegate> @optional - (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner;
+@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);
+
+@interface NSMutableArray : NSObject
+- (void)addObject:(id)object;
++ (id)array;
+@end
+
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+CFAbsoluteTime f1() {
+ 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() {
+ 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 supresss an error when we store the pointer
+// to a global.
+
+CFAbsoluteTime f3() {
+ 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() {
+ 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();
+
+CFDateRef f8() {
+ CFDateRef date = MyDateCreate(); // expected-warning{{leak}}
+ CFRetain(date);
+ return date;
+}
+
+__attribute__((cf_returns_retained)) CFDateRef f9() {
+ 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() {
+ // 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();
+CREATEFUN MyCreateFun;
+
+void f12() {
+ CFTypeRef o = MyCreateFun(); // expected-warning {{leak}}
+}
+
+void f13_autorelease() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+ [(id) A autorelease]; // no-warning
+}
+
+void f13_autorelease_b() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
+ [(id) A autorelease];
+ [(id) A autorelease]; // expected-warning{{Object sent -autorelease too many times}}
+}
+
+CFMutableArrayRef f13_autorelease_c() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
+ [(id) A autorelease];
+ [(id) A autorelease];
+ return A; // expected-warning{{Object sent -autorelease too many times}}
+}
+
+CFMutableArrayRef f13_autorelease_d() {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
+ [(id) A autorelease];
+ [(id) A autorelease];
+ CFMutableArrayRef B = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{Object sent -autorelease 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() {
+ 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() {
+ // 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.
+void f16(int x, CFTypeRef p) {
+ if (p)
+ return;
+
+ if (x) {
+ CFRelease(p); // expected-warning{{Null pointer argument in call to CFRelease}}
+ }
+ else {
+ CFRetain(p); // expected-warning{{Null pointer argument in call to CFRetain}}
+ }
+}
+
+// Test that an object is non-null after being CFRetained/CFReleased.
+void f17(int x, CFTypeRef p) {
+ if (x) {
+ CFRelease(p);
+ if (!p)
+ CFRelease(0); // no-warning
+ }
+ else {
+ CFRetain(p);
+ if (!p)
+ CFRetain(0); // no-warning
+ }
+}
+
+// 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.
+@interface SelfIvarTest : NSObject {
+ id myObj;
+}
+- (void)test_self_tracking;
+@end
+
+@implementation SelfIvarTest
+- (void)test_self_tracking {
+ myObj = (id) CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+}
+@end
+
+// Test return of non-owned objects in contexts where an owned object
+// is expected.
+@interface TestReturnNotOwnedWhenExpectedOwned
+- (NSString*)newString;
+@end
+
+@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}}
+}
+@end
+
+// <rdar://problem/6659160>
+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.
+@interface PR3677: NSObject @end
+@implementation PR3677
++ (id)allocWithZone:(NSZone *)inZone {
+ return [super allocWithZone:inZone]; // no-warning
+}
+@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
+}
+
+// From <rdar://problem/6704930>. 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];
+ }
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6833332>
+// One build of the analyzer accidentally stopped tracking the allocated
+// object after the 'retain'.
+//===----------------------------------------------------------------------===//
+
+@interface rdar_6833332 : NSObject <NSApplicationDelegate> {
+ NSWindow *window;
+}
+@property (nonatomic, retain) NSWindow *window;
+@end
+
+@implementation rdar_6833332
+@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);
+}
+@end
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6257780> clang checker fails to catch use-after-release
+//===----------------------------------------------------------------------===//
+
+int rdar_6257780_Case1() {
+ 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;
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/10640253> Analyzer is confused about NSAutoreleasePool -allocWithZone:.
+//===----------------------------------------------------------------------===//
+
+void rdar_10640253_autorelease_allocWithZone() {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool allocWithZone:(NSZone*)0] init];
+ (void) pool;
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6866843> Checker should understand new/setObject:/release constructs
+//===----------------------------------------------------------------------===//
+
+void rdar_6866843() {
+ 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];
+}
+
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6877235> Classes typedef-ed to CF objects should get the same treatment as CF objects
+//===----------------------------------------------------------------------===//
+
+typedef CFTypeRef OtherRef;
+
+@interface RDar6877235 : NSObject {}
+- (CFTypeRef)_copyCFTypeRef;
+- (OtherRef)_copyOtherRef;
+@end
+
+@implementation RDar6877235
+- (CFTypeRef)_copyCFTypeRef {
+ return [[NSString alloc] init]; // no-warning
+}
+- (OtherRef)_copyOtherRef {
+ return [[NSString alloc] init]; // no-warning
+}
+@end
+
+//===----------------------------------------------------------------------===//
+//<rdar://problem/6320065> false positive - init method returns an object
+// owned by caller
+//===----------------------------------------------------------------------===//
+
+@interface RDar6320065 : NSObject {
+ NSString *_foo;
+}
+- (id)initReturningNewClass;
+- (id)_initReturningNewClassBad;
+- (id)initReturningNewClassBad2;
+@end
+
+@interface RDar6320065Subclass : RDar6320065
+@end
+
+@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}}
+}
+
+@end
+
+@implementation RDar6320065Subclass
+@end
+
+int RDar6320065_test() {
+ RDar6320065 *test = [[RDar6320065 alloc] init]; // no-warning
+ [test release];
+ return 0;
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7129086> -awakeAfterUsingCoder: returns an owned object
+// and claims the receiver
+//===----------------------------------------------------------------------===//
+
+@interface RDar7129086 : NSObject {} @end
+@implementation RDar7129086
+- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder {
+ [self release]; // no-warning
+ return [NSString alloc]; // no-warning
+}
+@end
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6859457> [NSData dataWithBytesNoCopy] does not return a
+// retained object
+//===----------------------------------------------------------------------===//
+
+@interface RDar6859457 : NSObject {}
+- (NSString*) NoCopyString;
+- (NSString*) noCopyString;
+@end
+
+@implementation RDar6859457
+- (NSString*) NoCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}}
+- (NSString*) noCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}}
+@end
+
+void test_RDar6859457(RDar6859457 *x, void *bytes, NSUInteger dataLength) {
+ [x NoCopyString]; // no-warning
+ [x noCopyString]; // no-warning
+ [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;
+}
+
+//===----------------------------------------------------------------------===//
+// Method name that has a null IdentifierInfo* for its first selector slot.
+// This test just makes sure that we handle it.
+//===----------------------------------------------------------------------===//
+
+@interface TestNullIdentifier
+@end
+
+@implementation TestNullIdentifier
++ (id):(int)x, ... {
+ return [[NSString alloc] init]; // expected-warning{{leak}}
+}
+@end
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6893565> 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;
+
+@interface RDar6893565 {}
+-(TD6893565)newThing;
+@end
+
+@implementation RDar6893565
+-(TD6893565)newThing {
+ return (TD6893565) [[NSString alloc] init]; // no-warning
+}
+@end
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6902710> 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}}
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6945561> -[CIContext createCGLayerWithSize:info:]
+// misinterpreted by clang scan-build
+//===----------------------------------------------------------------------===//
+
+void rdar6945561(CIContext *context, CGSize size, CFDictionaryRef d) {
+ [context createCGLayerWithSize:size info:d]; // expected-warning{{leak}}
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6961230> add knowledge of IOKit functions to retain/release
+// checker
+//===----------------------------------------------------------------------===//
+
+void IOBSDNameMatching_wrapper(mach_port_t masterPort, uint32_t options, const char * bsdName) {
+ IOBSDNameMatching(masterPort, 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 IOServiceAddNotification_wrapper(mach_port_t masterPort, const io_name_t notificationType,
+ mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) {
+
+ CFDictionaryRef matching = CreateDict();
+ CFRelease(matching);
+ IOServiceAddNotification(masterPort, 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 masterPort, uint32_t options,
+ const char * path) {
+ IOOpenFirmwarePathMatching(masterPort, options, path); // expected-warning{{leak}}
+}
+
+void IOServiceGetMatchingService_wrapper(mach_port_t masterPort) {
+ CFDictionaryRef matching = CreateDict();
+ IOServiceGetMatchingService(masterPort, matching);
+ CFRelease(matching); // expected-warning{{used after it is released}}
+}
+
+void IOServiceGetMatchingServices_wrapper(mach_port_t masterPort, io_iterator_t *existing) {
+ CFDictionaryRef matching = CreateDict();
+ IOServiceGetMatchingServices(masterPort, 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 *);
+
+// <rdar://problem/6539791>
+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
+ }
+}
+
+// <rdar://problem/6560661>
+// 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
+}
+
+// <rdar://problem/7152619>
+// 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);
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7299394> 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;
+
+int pthread_create(pthread_t *, const pthread_attr_t *,
+ void *(*)(void *), void *);
+
+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}}
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7283567> 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) ;
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7358899> 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);
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7265711> 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').
+//===----------------------------------------------------------------------===//
+
+@interface RDar7265711 {}
+- (id) new_stuff;
+@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];
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7306898> clang thinks [NSCursor dragCopyCursor] returns a
+// retained reference
+//===----------------------------------------------------------------------===//
+
+@interface NSCursor : NSObject
++ (NSCursor *)dragCopyCursor;
+@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}}
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7252064> sending 'release', 'retain', etc. to a Class
+// directly is not likely what the user intended
+//===----------------------------------------------------------------------===//
+
+@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;
+
+@protocol FooP;
+
+@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*) 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;
+@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}}
+}
+
+void testattr2_a() {
+ TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // expected-warning{{leak}}
+}
+
+void testattr2_b() {
+ TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // expected-warning{{leak}}
+}
+
+void testattr2_c() {
+ TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // no-warning
+ [x release];
+}
+
+void testattr3() {
+ 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() {
+ TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // no-warning
+ consume_ns(x);
+ TestOwnershipAttr *y = [TestOwnershipAttr alloc]; // no-warning
+ consume_cf(y);
+}
+
+
+@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;
+@end
+
+CF_RETURNS_RETAINED
+CFDateRef returnsRetainedCFDate() {
+ return CFDateCreate(0, CFAbsoluteTimeGetCurrent());
+}
+
+@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
+}
+@end
+
+//===----------------------------------------------------------------------===//
+// Test that leaks post-dominated by "panic" functions are not reported.
+//
+// <rdar://problem/5905851> do not report a leak when post-dominated by a call
+// to a noreturn or panic function
+//===----------------------------------------------------------------------===//
+
+void panic() __attribute__((noreturn));
+void panic_not_in_hardcoded_list() __attribute__((noreturn));
+
+void test_panic_negative() {
+ signed z = 1;
+ CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // expected-warning{{leak}}
+}
+
+void test_panic_positive() {
+ 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 in <rdar://problem/7796563>, 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) {
+ // Eventually this should be reported as a leak.
+ NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning
+ ^(NSObject *o){ [o retain]; }(number);
+}
+
+//===--------------------------------------------------------------------===//
+// Test sending message to super that returns an object alias. Previously
+// this caused a crash in the analyzer.
+//===--------------------------------------------------------------------===//
+
+@interface Rdar8015556 : NSObject {} @end
+@implementation Rdar8015556
+- (id)retain {
+ return [super retain];
+}
+@end
+
+// <rdar://problem/8272168> - Correcly handle Class<...> in Cocoa Conventions
+// detector.
+
+@protocol Prot_R8272168 @end
+Class <Prot_R8272168> GetAClassThatImplementsProt_R8272168();
+void r8272168() {
+ GetAClassThatImplementsProt_R8272168();
+}
+
+// Test case for <rdar://problem/8356342>, which in the past triggered
+// a false positive.
+@interface RDar8356342
+- (NSDate*) rdar8356342:(NSDate *)inValue;
+@end
+
+@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;
+}
+@end
+
+// <rdar://problem/8724287> - 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);
+ }
+}
+
+// <rdar://problem/9234108> - 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() {
+ rdar_9234108_helper(0, CFStringCreate());
+}
+
+// <rdar://problem/9726279> - Make sure that objc_method_family works
+// to override naming conventions.
+struct TwoDoubles {
+ double one;
+ double two;
+};
+typedef struct TwoDoubles TwoDoubles;
+
+@interface NSValue (Mine)
+- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles __attribute__((objc_method_family(init)));
+@end
+
+@implementation NSValue (Mine)
+- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles
+{
+ return [self init];
+}
+@end
+
+void rdar9726279() {
+ TwoDoubles twoDoubles = { 0.0, 0.0 };
+ NSValue *value = [[NSValue alloc] _prefix_initWithTwoDoubles:twoDoubles];
+ [value release];
+}
+
+// <rdar://problem/9732321>
+// 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() {
+ return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+}
+
+CFArrayRef camelcase_createno() {
+ return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}}
+}
+
+CFArrayRef camelcase_copy() {
+ return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+}
+
+CFArrayRef camelcase_copying() {
+ return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}}
+}
+
+CFArrayRef copyCamelCase() {
+ return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+}
+
+CFArrayRef __copyCamelCase() {
+ return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+}
+
+CFArrayRef __createCamelCase() {
+ return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+}
+
+CFArrayRef camel_create() {
+ return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+}
+
+
+CFArrayRef camel_creat() {
+ return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}}
+}
+
+CFArrayRef camel_copy() {
+ return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+}
+
+CFArrayRef camel_copyMachine() {
+ return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+}
+
+CFArrayRef camel_copymachine() {
+ return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}}
+}
+
+// rdar://problem/8024350
+@protocol F18P
+- (id) clone;
+@end
+@interface F18 : NSObject<F18P> @end
+@interface F18(Cat)
+- (id) clone NS_RETURNS_RETAINED;
+@end
+
+@implementation F18
+- (id) clone {
+ return [F18 alloc];
+}
+@end
+
+// Radar 6582778.
+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
+}
+
+// <rdar://problem/10232019> - Test that objects passed to containers
+// are marked "escaped".
+
+void rdar10232019() {
+ 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() {
+ 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.
+// <rdar://problem/9658496>
+typedef void * xpc_object_t;
+xpc_object_t _CFXPCCreateXPCObjectFromCFObject(CFTypeRef cf);
+void xpc_release(xpc_object_t object);
+
+void rdar9658496() {
+ 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.
+@interface RDar10824732 : NSObject
+- (id)initWithObj:(id CF_CONSUMED)obj;
+@end
+
+@implementation RDar10824732
+- (id)initWithObj:(id)obj {
+ [obj release];
+ return [super init];
+}
+@end
+
+void rdar_10824732() {
+ @autoreleasepool {
+ NSString *obj = @"test";
+ RDar10824732 *foo = [[RDar10824732 alloc] initWithObj:obj]; // no-warning
+ [foo release];
+ }
+}
+
+//===----------------------------------------------------------------------===//
+// 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() {
+ CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning
+ struct rdar11104566 V;
+ V.myStr = cf;
+ return V; // no-warning
+}
+
+struct rdar11104566 *test_2_rdar11104566() {
+ 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() {
+ { // 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];
+ }
+}
+
diff --git a/clang/test/Analysis/retain-release.mm b/clang/test/Analysis/retain-release.mm
new file mode 100644
index 0000000..01727ea
--- /dev/null
+++ b/clang/test/Analysis/retain-release.mm
@@ -0,0 +1,368 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify %s
+
+#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
+
+//===----------------------------------------------------------------------===//
+// 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 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);
+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;
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+- (id)copy;
+- (oneway void)release;
+- (id)autorelease;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
++ (id)allocWithZone:(NSZone *)zone;
++ (id)alloc;
+- (void)dealloc;
+- (id)init;
+@end
+@interface NSObject (NSCoderMethods)
+- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+typedef struct {
+}
+NSFastEnumerationState;
+@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end @class NSString, NSDictionary;
+@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
+@end @interface NSNumber : NSValue - (char)charValue;
+- (id)initWithInt:(int)value;
+@end @class NSString;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSArray (NSArrayCreation) + (id)array;
+@end @interface NSAutoreleasePool : NSObject {
+}
+- (void)drain;
+@end extern NSString * const NSBundleDidLoadNotification;
+typedef double NSTimeInterval;
+@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate;
+@end typedef unsigned short unichar;
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length;
+- ( const char *)UTF8String;
+- (id)initWithUTF8String:(const char *)nullTerminatedCString;
++ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
+@end @class NSString, NSURL, NSError;
+@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;
+@end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary;
+@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey;
+- (void)setObject:(id)anObject forKey:(id)aKey;
+@end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (id)dictionaryWithCapacity:(NSUInteger)numItems;
+@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 masterPort, CFDictionaryRef matching );
+kern_return_t IOServiceGetMatchingServices( mach_port_t masterPort, CFDictionaryRef matching, io_iterator_t * existing );
+kern_return_t IOServiceAddNotification( mach_port_t masterPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated));
+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 masterPort, uint32_t options, const char * bsdName );
+CFMutableDictionaryRef IOOpenFirmwarePathMatching( mach_port_t masterPort, 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 );
+@interface NSTask : NSObject - (id)init;
+@end typedef struct CGColorSpace *CGColorSpaceRef;
+typedef struct CGImage *CGImageRef;
+typedef struct CGLayer *CGLayerRef;
+@interface NSResponder : NSObject <NSCoding> {
+}
+@end @protocol NSAnimatablePropertyContainer - (id)animator;
+@end extern NSString *NSAnimationTriggerOrderIn ;
+@interface NSView : NSResponder <NSAnimatablePropertyContainer> {
+}
+@end @protocol NSValidatedUserInterfaceItem - (SEL)action;
+@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
+@end @class NSDate, NSDictionary, NSError, NSException, NSNotification;
+@interface NSApplication : NSResponder <NSUserInterfaceValidations> {
+}
+@end enum {
+NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 };
+typedef NSUInteger NSApplicationTerminateReply;
+@protocol NSApplicationDelegate <NSObject> @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
+@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView;
+@interface NSCell : NSObject <NSCopying, NSCoding> {
+}
+@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError;
+typedef struct {
+}
+CVTimeStamp;
+@interface CIImage : NSObject <NSCoding, NSCopying> {
+}
+typedef int CIFormat;
+@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 );
+@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;
+@end extern NSString* const QCRendererEventKey;
+@protocol QCCompositionRenderer - (NSDictionary*) attributes;
+@end @interface QCRenderer : NSObject <QCCompositionRenderer> {
+}
+- (id) createSnapshotImageOfType:(NSString*)type;
+@end extern NSString* const QCViewDidStartRenderingNotification;
+@interface QCView : NSView <QCCompositionRenderer> {
+}
+- (id) createSnapshotImageOfType:(NSString*)type;
+@end enum {
+ICEXIFOrientation1 = 1, ICEXIFOrientation2 = 2, ICEXIFOrientation3 = 3, ICEXIFOrientation4 = 4, ICEXIFOrientation5 = 5, ICEXIFOrientation6 = 6, ICEXIFOrientation7 = 7, ICEXIFOrientation8 = 8, };
+@class ICDevice;
+@protocol ICDeviceDelegate <NSObject> @required - (void)didRemoveDevice:(ICDevice*)device;
+@end extern NSString *const ICScannerStatusWarmingUp;
+@class ICScannerDevice;
+@protocol ICScannerDeviceDelegate <ICDeviceDelegate> @optional - (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner;
+@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);
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+class SmartPointer {
+ id x;
+public:
+ SmartPointer(id x) : x(x) {}
+ ~SmartPointer() { [x release]; }
+
+ void adopt(id x);
+ void noAdopt(id x);
+};
+
+void test_positive() {
+ id x = [[NSObject alloc] init]; // expected-warning {{leak}}
+}
+
+void test_smartpointer_1() {
+ id x = [[NSObject alloc] init]; // no-warning
+ SmartPointer foo(x);
+}
+
+void test_smartpointer_2() {
+ id x = [[NSObject alloc] init]; // no-warning
+ SmartPointer foo(0);
+ foo.adopt(x);
+}
+
+// FIXME: Eventually we want annotations to say whether or not
+// a C++ method claims ownership of an Objective-C object.
+void test_smartpointer_3() {
+ id x = [[NSObject alloc] init]; // no-warning
+ SmartPointer foo(0);
+ foo.noAdopt(x);
+}
+
+void test_smartpointer_4() {
+ id x = [[NSObject alloc] init]; // no-warning
+ SmartPointer *foo = new SmartPointer(x);
+ delete foo;
+}
+
+extern CFStringRef ElectronMicroscopyEngage(void);
+void test_microscopy() {
+ NSString *token = (NSString*) ElectronMicroscopyEngage();
+ [token release]; // expected-warning {{object that is not owned}}
+}
+
+extern CFStringRef Scopy(void);
+void test_Scopy() {
+ NSString *token = (NSString*) Scopy();
+ [token release]; // expected-warning {{object that is not owned}}
+}
+
+//===----------------------------------------------------------------------===//
+// Test handling of template functions used to do magic with
+// tracked retained pointers.
+//===----------------------------------------------------------------------===//
+
+template <typename T, typename U> T static_objc_cast(U* value)
+{
+ // ...debugging code omitted...
+ return static_cast<T>(value);
+}
+
+int rdar10553686(void)
+{
+ NSObject* bar = static_objc_cast<NSObject*>([[NSObject alloc] init]);
+ [bar release];
+ return 0;
+}
+int rdar10553686_positive(void)
+{
+ NSObject* bar = static_objc_cast<NSObject*>([[NSObject alloc] init]);
+ [bar release];
+ [bar retain]; // expected-warning {{used after it is released}}
+ return 0;
+}
+
+@interface NSMapTable : NSObject <NSCopying, NSCoding, NSFastEnumeration>
+@end
+extern void *NSMapGet(NSMapTable *table, const void *key);
+extern void NSMapInsert(NSMapTable *table, const void *key, const void *value);
+extern void NSMapInsertKnownAbsent(NSMapTable *table, const void *key, const void *value);
+char *strdup(const char *s);
+
+NSString * radar11152419(NSString *string1, NSString *key1, NSMapTable *map) {
+ NSString *string = ( NSString *)NSMapGet(map, key1);
+ if (!string) {
+ string = [string1 copy];
+ NSString *key = [key1 copy];
+ NSMapInsert(map, (void*) key, (void*)string); // no warning
+ NSMapInsertKnownAbsent(map, (void*)key, (void*)string); // no warning
+ }
+ return string;
+}
+
diff --git a/clang/test/Analysis/security-syntax-checks-no-emit.c b/clang/test/Analysis/security-syntax-checks-no-emit.c
new file mode 100644
index 0000000..c2869ca
--- /dev/null
+++ b/clang/test/Analysis/security-syntax-checks-no-emit.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -analyze -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
+
+// This file complements 'security-syntax-checks.m', but tests that we omit
+// specific checks on platforms where they don't make sense.
+
+// Omit the 'rand' check since 'arc4random' is not available on Linux.
+int rand(void);
+double drand48(void);
+double erand48(unsigned short[3]);
+long jrand48(unsigned short[3]);
+void lcong48(unsigned short[7]);
+long lrand48(void);
+long mrand48(void);
+long nrand48(unsigned short[3]);
+long random(void);
+int rand_r(unsigned *);
+
+void test_rand()
+{
+ unsigned short a[7];
+ unsigned b;
+
+ rand(); // no-warning
+ drand48(); // no-warning
+ erand48(a); // no-warning
+ jrand48(a); // no-warning
+ lcong48(a); // no-warning
+ lrand48(); // no-warning
+ mrand48(); // no-warning
+ nrand48(a); // no-warning
+ rand_r(&b); // no-warning
+ random(); // no-warning
+}
diff --git a/clang/test/Analysis/security-syntax-checks.m b/clang/test/Analysis/security-syntax-checks.m
new file mode 100644
index 0000000..f4ccefe
--- /dev/null
+++ b/clang/test/Analysis/security-syntax-checks.m
@@ -0,0 +1,199 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DUSE_BUILTINS -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DVARIANT -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
+
+#ifdef USE_BUILTINS
+# define BUILTIN(f) __builtin_ ## f
+#else /* USE_BUILTINS */
+# define BUILTIN(f) f
+#endif /* USE_BUILTINS */
+
+typedef typeof(sizeof(int)) size_t;
+
+
+// <rdar://problem/6336718> rule request: floating point used as loop
+// condition (FLP30-C, FLP-30-CPP)
+//
+// For reference: https://www.securecoding.cert.org/confluence/display/seccode/FLP30-C.+Do+not+use+floating+point+variables+as+loop+counters
+//
+void test_float_condition() {
+ for (float x = 0.1f; x <= 1.0f; x += 0.1f) {} // expected-warning{{Variable 'x' with floating point type 'float'}}
+ for (float x = 100000001.0f; x <= 100000010.0f; x += 1.0f) {} // expected-warning{{Variable 'x' with floating point type 'float'}}
+ for (float x = 100000001.0f; x <= 100000010.0f; x++ ) {} // expected-warning{{Variable 'x' with floating point type 'float'}}
+ for (double x = 100000001.0; x <= 100000010.0; x++ ) {} // expected-warning{{Variable 'x' with floating point type 'double'}}
+ for (double x = 100000001.0; ((x)) <= 100000010.0; ((x))++ ) {} // expected-warning{{Variable 'x' with floating point type 'double'}}
+
+ for (double x = 100000001.0; 100000010.0 >= x; x = x + 1.0 ) {} // expected-warning{{Variable 'x' with floating point type 'double'}}
+
+ int i = 0;
+ for (double x = 100000001.0; ((x)) <= 100000010.0; ((x))++, ++i ) {} // expected-warning{{Variable 'x' with floating point type 'double'}}
+
+ typedef float FooType;
+ for (FooType x = 100000001.0f; x <= 100000010.0f; x++ ) {} // expected-warning{{Variable 'x' with floating point type 'FooType'}}
+}
+
+// <rdar://problem/6335715> rule request: gets() buffer overflow
+// Part of recommendation: 300-BSI (buildsecurityin.us-cert.gov)
+char* gets(char *buf);
+
+void test_gets() {
+ char buff[1024];
+ gets(buff); // expected-warning{{Call to function 'gets' is extremely insecure as it can always result in a buffer overflow}}
+}
+
+int getpw(unsigned int uid, char *buf);
+
+void test_getpw() {
+ char buff[1024];
+ getpw(2, buff); // expected-warning{{The getpw() function is dangerous as it may overflow the provided buffer. It is obsoleted by getpwuid().}}
+}
+
+// <rdar://problem/6337132> CWE-273: Failure to Check Whether Privileges Were
+// Dropped Successfully
+typedef unsigned int __uint32_t;
+typedef __uint32_t __darwin_uid_t;
+typedef __uint32_t __darwin_gid_t;
+typedef __darwin_uid_t uid_t;
+typedef __darwin_gid_t gid_t;
+int setuid(uid_t);
+int setregid(gid_t, gid_t);
+int setreuid(uid_t, uid_t);
+extern void check(int);
+void abort(void);
+
+void test_setuid()
+{
+ setuid(2); // expected-warning{{The return value from the call to 'setuid' is not checked. If an error occurs in 'setuid', the following code may execute with unexpected privileges}}
+ setuid(0); // expected-warning{{The return value from the call to 'setuid' is not checked. If an error occurs in 'setuid', the following code may execute with unexpected privileges}}
+ if (setuid (2) != 0)
+ abort();
+
+ // Currently the 'setuid' check is not flow-sensitive, and only looks
+ // at whether the function was called in a compound statement. This
+ // will lead to false negatives, but there should be no false positives.
+ int t = setuid(2); // no-warning
+ (void)setuid (2); // no-warning
+
+ check(setuid (2)); // no-warning
+
+ setreuid(2,2); // expected-warning{{The return value from the call to 'setreuid' is not checked. If an error occurs in 'setreuid', the following code may execute with unexpected privileges}}
+ setregid(2,2); // expected-warning{{The return value from the call to 'setregid' is not checked. If an error occurs in 'setregid', the following code may execute with unexpected privileges}}
+}
+
+// <rdar://problem/6337100> CWE-338: Use of cryptographically weak prng
+int rand(void);
+double drand48(void);
+double erand48(unsigned short[3]);
+long jrand48(unsigned short[3]);
+void lcong48(unsigned short[7]);
+long lrand48(void);
+long mrand48(void);
+long nrand48(unsigned short[3]);
+long random(void);
+int rand_r(unsigned *);
+
+void test_rand()
+{
+ unsigned short a[7];
+ unsigned b;
+
+ rand(); // expected-warning{{Function 'rand' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ drand48(); // expected-warning{{Function 'drand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ erand48(a); // expected-warning{{Function 'erand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ jrand48(a); // expected-warning{{Function 'jrand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ lcong48(a); // expected-warning{{Function 'lcong48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ lrand48(); // expected-warning{{Function 'lrand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ mrand48(); // expected-warning{{Function 'mrand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ nrand48(a); // expected-warning{{Function 'nrand48' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ rand_r(&b); // expected-warning{{Function 'rand_r' is obsolete because it implements a poor random number generator. Use 'arc4random' instead}}
+ random(); // expected-warning{{The 'random' function produces a sequence of values that an adversary may be able to predict. Use 'arc4random' instead}}
+}
+
+char *mktemp(char *buf);
+
+void test_mktemp() {
+ char *x = mktemp("/tmp/zxcv"); // expected-warning{{Call to function 'mktemp' is insecure as it always creates or uses insecure temporary file}}
+}
+
+
+//===----------------------------------------------------------------------===
+// strcpy()
+//===----------------------------------------------------------------------===
+#ifdef VARIANT
+
+#define __strcpy_chk BUILTIN(__strcpy_chk)
+char *__strcpy_chk(char *restrict s1, const char *restrict s2, size_t destlen);
+
+#define strcpy(a,b) __strcpy_chk(a,b,(size_t)-1)
+
+#else /* VARIANT */
+
+#define strcpy BUILTIN(strcpy)
+char *strcpy(char *restrict s1, const char *restrict s2);
+
+#endif /* VARIANT */
+
+void test_strcpy() {
+ char x[4];
+ char *y;
+
+ strcpy(x, y); //expected-warning{{Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119.}}
+}
+
+//===----------------------------------------------------------------------===
+// strcat()
+//===----------------------------------------------------------------------===
+#ifdef VARIANT
+
+#define __strcat_chk BUILTIN(__strcat_chk)
+char *__strcat_chk(char *restrict s1, const char *restrict s2, size_t destlen);
+
+#define strcat(a,b) __strcat_chk(a,b,(size_t)-1)
+
+#else /* VARIANT */
+
+#define strcat BUILTIN(strcat)
+char *strcat(char *restrict s1, const char *restrict s2);
+
+#endif /* VARIANT */
+
+void test_strcat() {
+ char x[4];
+ char *y;
+
+ strcat(x, y); //expected-warning{{Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119.}}
+}
+
+//===----------------------------------------------------------------------===
+// vfork()
+//===----------------------------------------------------------------------===
+typedef int __int32_t;
+typedef __int32_t pid_t;
+pid_t vfork(void);
+
+void test_vfork() {
+ vfork(); //expected-warning{{Call to function 'vfork' is insecure as it can lead to denial of service situations in the parent process.}}
+}
+
+//===----------------------------------------------------------------------===
+// mkstemp()
+//===----------------------------------------------------------------------===
+
+char *mkdtemp(char *template);
+int mkstemps(char *template, int suffixlen);
+int mkstemp(char *template);
+char *mktemp(char *template);
+
+void test_mkstemp() {
+ mkstemp("XX"); // expected-warning {{Call to 'mkstemp' should have at least 6 'X's in the format string to be secure (2 'X's seen)}}
+ mkstemp("XXXXXX");
+ mkstemp("XXXXXXX");
+ mkstemps("XXXXXX", 0);
+ mkstemps("XXXXXX", 1); // expected-warning {{5 'X's seen}}
+ mkstemps("XXXXXX", 2); // expected-warning {{Call to 'mkstemps' should have at least 6 'X's in the format string to be secure (4 'X's seen, 2 characters used as a suffix)}}
+ mkdtemp("XX"); // expected-warning {{2 'X's seen}}
+ mkstemp("X"); // expected-warning {{Call to 'mkstemp' should have at least 6 'X's in the format string to be secure (1 'X' seen)}}
+ mkdtemp("XXXXXX");
+}
+
diff --git a/clang/test/Analysis/self-init.m b/clang/test/Analysis/self-init.m
new file mode 100644
index 0000000..d515173
--- /dev/null
+++ b/clang/test/Analysis/self-init.m
@@ -0,0 +1,256 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties %s -verify
+
+@class NSZone, NSCoder;
+@protocol NSObject- (id)self;
+@end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
++ (id)allocWithZone:(NSZone *)zone;
++ (id)alloc;
+- (void)dealloc;
+-(id)class;
+-(id)init;
+-(id)release;
+@end
+@interface NSProxy <NSObject> {}
+@end
+
+//#import "Foundation/NSObject.h"
+typedef unsigned NSUInteger;
+typedef long NSInteger;
+
+@interface NSInvocation : NSObject {}
+- (void)getArgument:(void *)argumentLocation atIndex:(NSInteger)idx;
+- (void)setArgument:(void *)argumentLocation atIndex:(NSInteger)idx;
+@end
+
+@class NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
++ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
+@end extern NSString * const NSBundleDidLoadNotification;
+@interface NSAssertionHandler : NSObject {}
++ (NSAssertionHandler *)currentHandler;
+- (void)handleFailureInMethod:(SEL)selector object:(id)object file:(NSString *)fileName lineNumber:(NSInteger)line description:(NSString *)format,...;
+@end
+extern NSString * const NSConnectionReplyMode;
+
+@interface NSBundle : NSObject
++(id)loadNibNamed:(NSString*)s owner:(id)o;
+@end
+
+void log(void *obj);
+extern void *somePtr;
+
+@class MyObj;
+extern id _commonInit(MyObj *self);
+
+@interface MyObj : NSObject {
+ id myivar;
+ int myint;
+}
+-(id)_init;
+-(id)initWithSomething:(int)x;
+-(void)doSomething;
++(id)commonInitMember:(id)s;
+@end
+
+@interface MyProxyObj : NSProxy {}
+-(id)init;
+@end
+
+@implementation MyObj
+
+-(id)init {
+ do { if (!((somePtr != 0))) { [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd object:self file:[NSString stringWithUTF8String:"init.m"] lineNumber:21 description:(@"Invalid parameter not satisfying: %s"), ("x != 0"), (0), (0), (0), (0)]; } } while(0);
+ return [self initWithSomething:0];
+}
+
+-(id)init2 {
+ self = [self initWithSomething:0];
+ return self;
+}
+
+-(id)init3 {
+ log([self class]);
+ return [self initWithSomething:0];
+}
+
+-(id)init4 {
+ self = [super init];
+ if (self) {
+ log(&self);
+ }
+ return self;
+}
+
+-(id)init4_w {
+ [super init];
+ if (self) {
+ log(&self);
+ }
+ return self; // expected-warning {{Returning 'self' while it is not set to the result of '[(super or self) init...]'}}
+}
+
+- (id)initWithSomething:(int)x {
+ if ((self = [super init]))
+ myint = x;
+ return self;
+}
+
+-(id)_init {
+ myivar = 0;
+ return self;
+}
+
+-(id)init5 {
+ [NSBundle loadNibNamed:@"Window" owner:self];
+ return [self initWithSomething:0];
+}
+
+-(id)init6 {
+ [NSBundle loadNibNamed:@"Window" owner:myivar]; // no-warning
+ return [self initWithSomething:0];
+}
+
+-(id)init7 {
+ if (0 != (self = [self _init]))
+ myivar = 0;
+ return self;
+}
+
+-(id)init8 {
+ if ((self = [super init])) {
+ log(&self);
+ myivar = 0;
+ }
+ return self;
+}
+
+-(id)init9 {
+ [self doSomething];
+ return self; // no-warning
+}
+
+-(id)init10 {
+ myivar = 0; // no-warning
+ return self;
+}
+
+-(id)init11 {
+ return self; // no-warning
+}
+
+-(id)init12 {
+ [super init];
+ return self; // expected-warning {{Returning 'self'}}
+}
+
+-(id)init13 {
+ if (self == [super init]) {
+ myivar = 0; // expected-warning {{Instance variable used}}
+ }
+ return self; // expected-warning {{Returning 'self'}}
+}
+
+-(id)init14 {
+ if (!(self = _commonInit(self)))
+ return 0;
+ return self;
+}
+
+-(id)init14_w {
+ [super init];
+ self = _commonInit(self);
+ return self; // expected-warning {{Returning 'self' while it is not set to the result of '[(super or self) init...]'}}
+}
+
+-(id)init15 {
+ if (!(self = [super init]))
+ return 0;
+ return self;
+}
+
+-(id)init16 {
+ somePtr = [super init];
+ self = somePtr;
+ myivar = 0;
+ return self;
+}
+
+-(id)init17 {
+ somePtr = [super init];
+ myivar = 0; // expected-warning {{Instance variable used}}
+ return 0;
+}
+
+-(id)init18 {
+ self = [super init];
+ self = _commonInit(self);
+ return self;
+}
+
++(id)commonInitMember:(id)s {
+ return s;
+}
+
+-(id)init19 {
+ self = [super init];
+ self = [MyObj commonInitMember:self];
+ return self;
+}
+
+-(id)init19_w {
+ [super init];
+ self = [MyObj commonInitMember:self];
+ return self; // expected-warning {{Returning 'self'}}
+}
+
+-(void)doSomething {}
+
+@end
+
+@implementation MyProxyObj
+
+- (id)init { return self; }
+
+@end
+
+
+// Test for radar://10973514 : self should not be invalidated by a method call.
+@interface Test : NSObject {
+ NSInvocation *invocation_;
+}
+@end
+@implementation Test
+-(id) initWithTarget:(id) rec selector:(SEL) cb {
+ if (self=[super init]) {
+ [invocation_ setArgument:&self atIndex:2];
+ }
+ return self;
+}
+@end
+
+// Test radar:11235991 - passing self to a call to super.
+@protocol MyDelegate
+@end
+@interface Object : NSObject
+- (id) initWithObject: (id)i;
+@end
+@interface Derived: Object <MyDelegate>
+- (id) initWithInt: (int)t;
+@property (nonatomic, retain, readwrite) Object *size;
+@end
+@implementation Derived
+- (id) initWithInt: (int)t {
+ if ((self = [super initWithObject:self])) {
+ _size = [[Object alloc] init];
+ }
+ return self;
+}
+@end
diff --git a/clang/test/Analysis/sizeofpointer.c b/clang/test/Analysis/sizeofpointer.c
new file mode 100644
index 0000000..0c86de8
--- /dev/null
+++ b/clang/test/Analysis/sizeofpointer.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core.SizeofPtr -verify %s
+
+struct s {
+};
+
+int f(struct s *p) {
+ return sizeof(p); // expected-warning{{The code calls sizeof() on a pointer type. This can produce an unexpected result.}}
+}
diff --git a/clang/test/Analysis/stack-addr-ps.c b/clang/test/Analysis/stack-addr-ps.c
new file mode 100644
index 0000000..a443a32
--- /dev/null
+++ b/clang/test/Analysis/stack-addr-ps.c
@@ -0,0 +1,92 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -fblocks -verify %s
+
+int* f1() {
+ int x = 0;
+ return &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned}} expected-warning{{address of stack memory associated with local variable 'x' returned}}
+}
+
+int* f2(int y) {
+ return &y; // expected-warning{{Address of stack memory associated with local variable 'y' returned}} expected-warning{{address of stack memory associated with local variable 'y' returned}}
+}
+
+int* f3(int x, int *y) {
+ int w = 0;
+
+ if (x)
+ y = &w;
+
+ return y; // expected-warning{{Address of stack memory associated with local variable 'w' returned to caller}}
+}
+
+void* compound_literal(int x, int y) {
+ if (x)
+ return &(unsigned short){((unsigned short)0x22EF)}; // expected-warning{{Address of stack memory}}
+
+ int* array[] = {};
+ struct s { int z; double y; int w; };
+
+ if (y)
+ return &((struct s){ 2, 0.4, 5 * 8 }); // expected-warning{{Address of stack memory}}
+
+
+ void* p = &((struct s){ 42, 0.4, x ? 42 : 0 });
+ return p; // expected-warning{{Address of stack memory}}
+}
+
+void* alloca_test() {
+ void* p = __builtin_alloca(10);
+ return p; // expected-warning{{Address of stack memory}}
+}
+
+int array_test(int x[2]) {
+ return x[0]; // no-warning
+}
+
+struct baz {
+ int x;
+ int y[2];
+};
+
+int struct_test(struct baz byVal, int flag) {
+ if (flag)
+ return byVal.x; // no-warning
+ else {
+ return byVal.y[0]; // no-warning
+ }
+}
+
+typedef int (^ComparatorBlock)(int a, int b);
+ComparatorBlock test_return_block(void) {
+ // This block is a global since it has no captures.
+ ComparatorBlock b = ^int(int a, int b){ return a > b; };
+ return b; // no-warning
+}
+
+ComparatorBlock test_return_block_with_capture(int x) {
+ // This block is stack allocated because it has captures.
+ ComparatorBlock b = ^int(int a, int b){ return a > b + x; };
+ return b; // expected-warning{{Address of stack-allocated block}}
+}
+
+ComparatorBlock test_return_block_neg_aux(void);
+ComparatorBlock test_return_block_neg(void) {
+ ComparatorBlock b = test_return_block_neg_aux();
+ return b; // no-warning
+}
+
+// <rdar://problem/7523821>
+int *rdar_7523821_f2() {
+ int a[3];
+ return a; // expected-warning 2 {{ddress of stack memory associated with local variable 'a' returned}}
+};
+
+// Handle blocks that have no captures or are otherwise declared 'static'.
+// <rdar://problem/10348049>
+typedef int (^RDar10348049)(int value);
+RDar10348049 test_rdar10348049(void) {
+ static RDar10348049 b = ^int(int x) {
+ return x + 2;
+ };
+ return b; // no-warning
+}
+
diff --git a/clang/test/Analysis/stack-addr-ps.cpp b/clang/test/Analysis/stack-addr-ps.cpp
new file mode 100644
index 0000000..b09e435
--- /dev/null
+++ b/clang/test/Analysis/stack-addr-ps.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify %s
+
+// FIXME: Only the stack-address checking in Sema catches this right now, and
+// the stack analyzer doesn't handle the ImplicitCastExpr (lvalue).
+const int& g() {
+ int s;
+ return s; // expected-warning{{Address of stack memory associated with local variable 's' returned}} expected-warning{{reference to stack memory associated with local variable 's' returned}}
+}
+
+const int& g2() {
+ int s1;
+ int &s2 = s1; // expected-note {{binding reference variable 's2' here}}
+ return s2; // expected-warning{{Address of stack memory associated with local variable 's1' returned}} expected-warning {{reference to stack memory associated with local variable 's1' returned}}
+}
+
+const int& g3() {
+ int s1;
+ int &s2 = s1; // expected-note {{binding reference variable 's2' here}}
+ int &s3 = s2; // expected-note {{binding reference variable 's3' here}}
+ return s3; // expected-warning{{Address of stack memory associated with local variable 's1' returned}} expected-warning {{reference to stack memory associated with local variable 's1' returned}}
+}
+
+int get_value();
+
+const int &get_reference1() { return get_value(); } // expected-warning{{Address of stack memory associated with temporary object of type 'const int' returned}} expected-warning {{returning reference to local temporary}}
+
+const int &get_reference2() {
+ const int &x = get_value(); // expected-note {{binding reference variable 'x' here}}
+ return x; // expected-warning{{Address of stack memory associated with temporary object of type 'const int' returned}} expected-warning {{returning reference to local temporary}}
+}
+
+const int &get_reference3() {
+ const int &x1 = get_value(); // expected-note {{binding reference variable 'x1' here}}
+ const int &x2 = x1; // expected-note {{binding reference variable 'x2' here}}
+ return x2; // expected-warning{{Address of stack memory associated with temporary object of type 'const int' returned}} expected-warning {{returning reference to local temporary}}
+}
+
+int global_var;
+int *f1() {
+ int &y = global_var;
+ return &y;
+}
+
+int *f2() {
+ int x1;
+ int &x2 = x1; // expected-note {{binding reference variable 'x2' here}}
+ return &x2; // expected-warning{{Address of stack memory associated with local variable 'x1' returned}} expected-warning {{address of stack memory associated with local variable 'x1' returned}}
+}
+
+int *f3() {
+ int x1;
+ int *const &x2 = &x1; // expected-note {{binding reference variable 'x2' here}}
+ return x2; // expected-warning {{address of stack memory associated with local variable 'x1' returned}} expected-warning {{Address of stack memory associated with local variable 'x1' returned to caller}}
+}
+
+const int *f4() {
+ const int &x1 = get_value(); // expected-note {{binding reference variable 'x1' here}}
+ const int &x2 = x1; // expected-note {{binding reference variable 'x2' here}}
+ return &x2; // expected-warning{{Address of stack memory associated with temporary object of type 'const int' returned}} expected-warning {{returning address of local temporary}}
+}
+
+struct S {
+ int x;
+};
+
+int *mf() {
+ S s1;
+ S &s2 = s1; // expected-note {{binding reference variable 's2' here}}
+ int &x = s2.x; // expected-note {{binding reference variable 'x' here}}
+ return &x; // expected-warning{{Address of stack memory associated with local variable 's1' returned}} expected-warning {{address of stack memory associated with local variable 's1' returned}}
+}
+
+void *lf() {
+ label:
+ void *const &x = &&label; // expected-note {{binding reference variable 'x' here}}
+ return x; // expected-warning {{returning address of label, which is local}}
+}
+
+template <typename T>
+struct TS {
+ int *get();
+ int *m() {
+ int *&x = get();
+ return x;
+ }
+};
diff --git a/clang/test/Analysis/stack-block-returned.cpp b/clang/test/Analysis/stack-block-returned.cpp
new file mode 100644
index 0000000..af2cec7
--- /dev/null
+++ b/clang/test/Analysis/stack-block-returned.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -fblocks -verify %s
+
+typedef void (^bptr)(void);
+
+bptr bf(int j) {
+ __block int i;
+ const bptr &qq = ^{ i=0; }; // expected-note {{binding reference variable 'qq' here}}
+ return qq; // expected-error {{returning block that lives on the local stack}}
+}
diff --git a/clang/test/Analysis/stackaddrleak.c b/clang/test/Analysis/stackaddrleak.c
new file mode 100644
index 0000000..ada0cc1
--- /dev/null
+++ b/clang/test/Analysis/stackaddrleak.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -verify %s
+
+char const *p;
+
+void f0() {
+ char const str[] = "This will change";
+ p = str; // expected-warning{{Address of stack memory associated with local variable 'str' is still referred to by the global variable 'p' upon returning to the caller. This will be a dangling reference}}
+}
+
+void f1() {
+ char const str[] = "This will change";
+ p = str;
+ p = 0; // no-warning
+}
+
+void f2() {
+ p = (const char *) __builtin_alloca(12); // expected-warning{{Address of stack memory allocated by call to alloca() on line 17 is still referred to by the global variable 'p' upon returning to the caller. This will be a dangling reference}}
+}
+
+// PR 7383 - previosly the stack address checker would crash on this example
+// because it would attempt to do a direct load from 'pr7383_list'.
+static int pr7383(__const char *__)
+{
+ return 0;
+}
+extern __const char *__const pr7383_list[];
+
+// Test that we catch multiple returns via globals when analyzing a function.
+void test_multi_return() {
+ static int *a, *b;
+ int x;
+ a = &x;
+ b = &x; // expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the global variable 'a' upon returning}} expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the global variable 'b' upon returning}}
+}
diff --git a/clang/test/Analysis/stats.c b/clang/test/Analysis/stats.c
new file mode 100644
index 0000000..6beadbe
--- /dev/null
+++ b/clang/test/Analysis/stats.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-stats %s 2>&1 | FileCheck %s
+
+void foo() {
+ int x;
+}
+// CHECK: ... Statistics Collected ...
+// CHECK:100 AnalysisConsumer - The % of reachable basic blocks.
+// CHECK:The # of times RemoveDeadBindings is called
diff --git a/clang/test/Analysis/stream.c b/clang/test/Analysis/stream.c
new file mode 100644
index 0000000..e68835e
--- /dev/null
+++ b/clang/test/Analysis/stream.c
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.unix.Stream -analyzer-store region -verify %s
+
+typedef __typeof__(sizeof(int)) size_t;
+typedef struct _IO_FILE FILE;
+#define SEEK_SET 0 /* Seek from beginning of file. */
+#define SEEK_CUR 1 /* Seek from current position. */
+#define SEEK_END 2 /* Seek from end of file. */
+extern FILE *fopen(const char *path, const char *mode);
+extern FILE *tmpfile(void);
+extern int fclose(FILE *fp);
+extern size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
+extern int fseek (FILE *__stream, long int __off, int __whence);
+extern long int ftell (FILE *__stream);
+extern void rewind (FILE *__stream);
+
+void f1(void) {
+ FILE *p = fopen("foo", "r");
+ char buf[1024];
+ fread(buf, 1, 1, p); // expected-warning {{Stream pointer might be NULL.}}
+ fclose(p);
+}
+
+void f2(void) {
+ FILE *p = fopen("foo", "r");
+ fseek(p, 1, SEEK_SET); // expected-warning {{Stream pointer might be NULL.}}
+ fclose(p);
+}
+
+void f3(void) {
+ FILE *p = fopen("foo", "r");
+ ftell(p); // expected-warning {{Stream pointer might be NULL.}}
+ fclose(p);
+}
+
+void f4(void) {
+ FILE *p = fopen("foo", "r");
+ rewind(p); // expected-warning {{Stream pointer might be NULL.}}
+ fclose(p);
+}
+
+void f5(void) {
+ FILE *p = fopen("foo", "r");
+ if (!p)
+ return;
+ fseek(p, 1, SEEK_SET); // no-warning
+ fseek(p, 1, 3); // expected-warning {{The whence argument to fseek() should be SEEK_SET, SEEK_END, or SEEK_CUR.}}
+ fclose(p);
+}
+
+void f6(void) {
+ FILE *p = fopen("foo", "r");
+ fclose(p);
+ fclose(p); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour.}}
+}
+
+void f7(void) {
+ FILE *p = tmpfile();
+ ftell(p); // expected-warning {{Stream pointer might be NULL.}}
+ fclose(p);
+}
+
+void f8(int c) {
+ FILE *p = fopen("foo.c", "r");
+ if(c)
+ return; // expected-warning {{Opened File never closed. Potential Resource leak.}}
+ fclose(p);
+}
+
+FILE *f9(void) {
+ FILE *p = fopen("foo.c", "r");
+ if (p)
+ return p; // no-warning
+ else
+ return 0;
+}
+
+void pr7831(FILE *fp) {
+ fclose(fp); // no-warning
+}
+
+// PR 8081 - null pointer crash when 'whence' is not an integer constant
+void pr8081(FILE *stream, long offset, int whence) {
+ fseek(stream, offset, whence);
+}
+
diff --git a/clang/test/Analysis/string-fail.c b/clang/test/Analysis/string-fail.c
new file mode 100644
index 0000000..3bff6d4
--- /dev/null
+++ b/clang/test/Analysis/string-fail.c
@@ -0,0 +1,113 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// XFAIL: *
+
+// This file is for tests that may eventually go into string.c, or may be
+// deleted outright. At one point these tests passed, but only because we
+// weren't correctly modelling the behavior of the relevant string functions.
+// The tests aren't incorrect, but require the analyzer to be smarter about
+// conjured values than it currently is.
+
+//===----------------------------------------------------------------------===
+// Declarations
+//===----------------------------------------------------------------------===
+
+// Some functions are so similar to each other that they follow the same code
+// path, such as memcpy and __memcpy_chk, or memcmp and bcmp. If VARIANT is
+// defined, make sure to use the variants instead to make sure they are still
+// checked by the analyzer.
+
+// Some functions are implemented as builtins. These should be #defined as
+// BUILTIN(f), which will prepend "__builtin_" if USE_BUILTINS is defined.
+
+// Functions that have variants and are also available as builtins should be
+// declared carefully! See memcpy() for an example.
+
+#ifdef USE_BUILTINS
+# define BUILTIN(f) __builtin_ ## f
+#else /* USE_BUILTINS */
+# define BUILTIN(f) f
+#endif /* USE_BUILTINS */
+
+#define NULL 0
+typedef typeof(sizeof(int)) size_t;
+
+
+//===----------------------------------------------------------------------===
+// strnlen()
+//===----------------------------------------------------------------------===
+
+#define strnlen BUILTIN(strnlen)
+size_t strnlen(const char *s, size_t maxlen);
+
+void strnlen_liveness(const char *x) {
+ if (strnlen(x, 10) < 5)
+ return;
+ if (strnlen(x, 10) < 5)
+ (void)*(char*)0; // no-warning
+}
+
+void strnlen_subregion() {
+ struct two_stringsn { char a[2], b[2]; };
+ extern void use_two_stringsn(struct two_stringsn *);
+
+ struct two_stringsn z;
+ use_two_stringsn(&z);
+
+ size_t a = strnlen(z.a, 10);
+ z.b[0] = 5;
+ size_t b = strnlen(z.a, 10);
+ if (a == 0 && b != 0)
+ (void)*(char*)0; // expected-warning{{never executed}}
+
+ use_two_stringsn(&z);
+
+ size_t c = strnlen(z.a, 10);
+ if (a == 0 && c != 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+extern void use_stringn(char *);
+void strnlen_argument(char *x) {
+ size_t a = strnlen(x, 10);
+ size_t b = strnlen(x, 10);
+ if (a == 0 && b != 0)
+ (void)*(char*)0; // expected-warning{{never executed}}
+
+ use_stringn(x);
+
+ size_t c = strnlen(x, 10);
+ if (a == 0 && c != 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+extern char global_strn[];
+void strnlen_global() {
+ size_t a = strnlen(global_strn, 10);
+ size_t b = strnlen(global_strn, 10);
+ if (a == 0 && b != 0)
+ (void)*(char*)0; // expected-warning{{never executed}}
+
+ // Call a function with unknown effects, which should invalidate globals.
+ use_stringn(0);
+
+ size_t c = strnlen(global_strn, 10);
+ if (a == 0 && c != 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void strnlen_indirect(char *x) {
+ size_t a = strnlen(x, 10);
+ char *p = x;
+ char **p2 = &p;
+ size_t b = strnlen(x, 10);
+ if (a == 0 && b != 0)
+ (void)*(char*)0; // expected-warning{{never executed}}
+
+ extern void use_stringn_ptr(char*const*);
+ use_stringn_ptr(p2);
+
+ size_t c = strnlen(x, 10);
+ if (a == 0 && c != 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
diff --git a/clang/test/Analysis/string.c b/clang/test/Analysis/string.c
new file mode 100644
index 0000000..c0814b8
--- /dev/null
+++ b/clang/test/Analysis/string.c
@@ -0,0 +1,1124 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=experimental.security.taint,core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+
+//===----------------------------------------------------------------------===
+// Declarations
+//===----------------------------------------------------------------------===
+
+// Some functions are so similar to each other that they follow the same code
+// path, such as memcpy and __memcpy_chk, or memcmp and bcmp. If VARIANT is
+// defined, make sure to use the variants instead to make sure they are still
+// checked by the analyzer.
+
+// Some functions are implemented as builtins. These should be #defined as
+// BUILTIN(f), which will prepend "__builtin_" if USE_BUILTINS is defined.
+
+// Functions that have variants and are also available as builtins should be
+// declared carefully! See memcpy() for an example.
+
+#ifdef USE_BUILTINS
+# define BUILTIN(f) __builtin_ ## f
+#else /* USE_BUILTINS */
+# define BUILTIN(f) f
+#endif /* USE_BUILTINS */
+
+#define NULL 0
+typedef typeof(sizeof(int)) size_t;
+int scanf(const char *restrict format, ...);
+
+//===----------------------------------------------------------------------===
+// strlen()
+//===----------------------------------------------------------------------===
+
+#define strlen BUILTIN(strlen)
+size_t strlen(const char *s);
+
+void strlen_constant0() {
+ if (strlen("123") != 3)
+ (void)*(char*)0; // no-warning
+}
+
+void strlen_constant1() {
+ const char *a = "123";
+ if (strlen(a) != 3)
+ (void)*(char*)0; // no-warning
+}
+
+void strlen_constant2(char x) {
+ char a[] = "123";
+ if (strlen(a) != 3)
+ (void)*(char*)0; // no-warning
+ a[0] = x;
+ if (strlen(a) != 3)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+size_t strlen_null() {
+ return strlen(0); // expected-warning{{Null pointer argument in call to string length function}}
+}
+
+size_t strlen_fn() {
+ return strlen((char*)&strlen_fn); // expected-warning{{Argument to string length function is the address of the function 'strlen_fn', which is not a null-terminated string}}
+}
+
+size_t strlen_nonloc() {
+label:
+ return strlen((char*)&&label); // expected-warning{{Argument to string length function is the address of the label 'label', which is not a null-terminated string}}
+}
+
+void strlen_subregion() {
+ struct two_strings { char a[2], b[2]; };
+ extern void use_two_strings(struct two_strings *);
+
+ struct two_strings z;
+ use_two_strings(&z);
+
+ size_t a = strlen(z.a);
+ z.b[0] = 5;
+ size_t b = strlen(z.a);
+ if (a == 0 && b != 0)
+ (void)*(char*)0; // expected-warning{{never executed}}
+
+ use_two_strings(&z);
+
+ size_t c = strlen(z.a);
+ if (a == 0 && c != 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+extern void use_string(char *);
+void strlen_argument(char *x) {
+ size_t a = strlen(x);
+ size_t b = strlen(x);
+ if (a == 0 && b != 0)
+ (void)*(char*)0; // expected-warning{{never executed}}
+
+ use_string(x);
+
+ size_t c = strlen(x);
+ if (a == 0 && c != 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+extern char global_str[];
+void strlen_global() {
+ size_t a = strlen(global_str);
+ size_t b = strlen(global_str);
+ if (a == 0 && b != 0)
+ (void)*(char*)0; // expected-warning{{never executed}}
+
+ // Call a function with unknown effects, which should invalidate globals.
+ use_string(0);
+
+ size_t c = strlen(global_str);
+ if (a == 0 && c != 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void strlen_indirect(char *x) {
+ size_t a = strlen(x);
+ char *p = x;
+ char **p2 = &p;
+ size_t b = strlen(x);
+ if (a == 0 && b != 0)
+ (void)*(char*)0; // expected-warning{{never executed}}
+
+ extern void use_string_ptr(char*const*);
+ use_string_ptr(p2);
+
+ size_t c = strlen(x);
+ if (a == 0 && c != 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void strlen_indirect2(char *x) {
+ size_t a = strlen(x);
+ char *p = x;
+ char **p2 = &p;
+ extern void use_string_ptr2(char**);
+ use_string_ptr2(p2);
+
+ size_t c = strlen(x);
+ if (a == 0 && c != 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void strlen_liveness(const char *x) {
+ if (strlen(x) < 5)
+ return;
+ if (strlen(x) < 5)
+ (void)*(char*)0; // no-warning
+}
+
+//===----------------------------------------------------------------------===
+// strnlen()
+//===----------------------------------------------------------------------===
+
+size_t strnlen(const char *s, size_t maxlen);
+
+void strnlen_constant0() {
+ if (strnlen("123", 10) != 3)
+ (void)*(char*)0; // expected-warning{{never executed}}
+}
+
+void strnlen_constant1() {
+ const char *a = "123";
+ if (strnlen(a, 10) != 3)
+ (void)*(char*)0; // expected-warning{{never executed}}
+}
+
+void strnlen_constant2(char x) {
+ char a[] = "123";
+ if (strnlen(a, 10) != 3)
+ (void)*(char*)0; // expected-warning{{never executed}}
+ a[0] = x;
+ if (strnlen(a, 10) != 3)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void strnlen_constant4() {
+ if (strnlen("123456", 3) != 3)
+ (void)*(char*)0; // expected-warning{{never executed}}
+}
+
+void strnlen_constant5() {
+ const char *a = "123456";
+ if (strnlen(a, 3) != 3)
+ (void)*(char*)0; // expected-warning{{never executed}}
+}
+
+void strnlen_constant6(char x) {
+ char a[] = "123456";
+ if (strnlen(a, 3) != 3)
+ (void)*(char*)0; // expected-warning{{never executed}}
+ a[0] = x;
+ if (strnlen(a, 3) != 3)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+size_t strnlen_null() {
+ return strnlen(0, 3); // expected-warning{{Null pointer argument in call to string length function}}
+}
+
+size_t strnlen_fn() {
+ return strnlen((char*)&strlen_fn, 3); // expected-warning{{Argument to string length function is the address of the function 'strlen_fn', which is not a null-terminated string}}
+}
+
+size_t strnlen_nonloc() {
+label:
+ return strnlen((char*)&&label, 3); // expected-warning{{Argument to string length function is the address of the label 'label', which is not a null-terminated string}}
+}
+
+void strnlen_zero() {
+ if (strnlen("abc", 0) != 0)
+ (void)*(char*)0; // expected-warning{{never executed}}
+ if (strnlen(NULL, 0) != 0) // no-warning
+ (void)*(char*)0; // no-warning
+}
+
+size_t strnlen_compound_literal() {
+ // This used to crash because we don't model the string lengths of
+ // compound literals.
+ return strnlen((char[]) { 'a', 'b', 0 }, 1);
+}
+
+size_t strnlen_unknown_limit(float f) {
+ // This used to crash because we don't model the integer values of floats.
+ return strnlen("abc", (int)f);
+}
+
+void strnlen_is_not_strlen(char *x) {
+ if (strnlen(x, 10) != strlen(x))
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void strnlen_at_limit(char *x) {
+ size_t len = strnlen(x, 10);
+ if (len > 10)
+ (void)*(char*)0; // expected-warning{{never executed}}
+ if (len == 10)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void strnlen_less_than_limit(char *x) {
+ size_t len = strnlen(x, 10);
+ if (len > 10)
+ (void)*(char*)0; // expected-warning{{never executed}}
+ if (len < 10)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void strnlen_at_actual(size_t limit) {
+ size_t len = strnlen("abc", limit);
+ if (len > 3)
+ (void)*(char*)0; // expected-warning{{never executed}}
+ if (len == 3)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void strnlen_less_than_actual(size_t limit) {
+ size_t len = strnlen("abc", limit);
+ if (len > 3)
+ (void)*(char*)0; // expected-warning{{never executed}}
+ if (len < 3)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+//===----------------------------------------------------------------------===
+// strcpy()
+//===----------------------------------------------------------------------===
+
+#ifdef VARIANT
+
+#define __strcpy_chk BUILTIN(__strcpy_chk)
+char *__strcpy_chk(char *restrict s1, const char *restrict s2, size_t destlen);
+
+#define strcpy(a,b) __strcpy_chk(a,b,(size_t)-1)
+
+#else /* VARIANT */
+
+#define strcpy BUILTIN(strcpy)
+char *strcpy(char *restrict s1, const char *restrict s2);
+
+#endif /* VARIANT */
+
+
+void strcpy_null_dst(char *x) {
+ strcpy(NULL, x); // expected-warning{{Null pointer argument in call to string copy function}}
+}
+
+void strcpy_null_src(char *x) {
+ strcpy(x, NULL); // expected-warning{{Null pointer argument in call to string copy function}}
+}
+
+void strcpy_fn(char *x) {
+ strcpy(x, (char*)&strcpy_fn); // expected-warning{{Argument to string copy function is the address of the function 'strcpy_fn', which is not a null-terminated string}}
+}
+
+void strcpy_fn_const(char *x) {
+ strcpy(x, (const char*)&strcpy_fn); // expected-warning{{Argument to string copy function is the address of the function 'strcpy_fn', which is not a null-terminated string}}
+}
+
+void strcpy_effects(char *x, char *y) {
+ char a = x[0];
+
+ if (strcpy(x, y) != x)
+ (void)*(char*)0; // no-warning
+
+ if (strlen(x) != strlen(y))
+ (void)*(char*)0; // no-warning
+
+ if (a != x[0])
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void strcpy_overflow(char *y) {
+ char x[4];
+ if (strlen(y) == 4)
+ strcpy(x, y); // expected-warning{{String copy function overflows destination buffer}}
+}
+
+void strcpy_no_overflow(char *y) {
+ char x[4];
+ if (strlen(y) == 3)
+ strcpy(x, y); // no-warning
+}
+
+//===----------------------------------------------------------------------===
+// stpcpy()
+//===----------------------------------------------------------------------===
+
+#ifdef VARIANT
+
+#define __stpcpy_chk BUILTIN(__stpcpy_chk)
+char *__stpcpy_chk(char *restrict s1, const char *restrict s2, size_t destlen);
+
+#define stpcpy(a,b) __stpcpy_chk(a,b,(size_t)-1)
+
+#else /* VARIANT */
+
+#define stpcpy BUILTIN(stpcpy)
+char *stpcpy(char *restrict s1, const char *restrict s2);
+
+#endif /* VARIANT */
+
+
+void stpcpy_effect(char *x, char *y) {
+ char a = x[0];
+
+ if (stpcpy(x, y) != &x[strlen(y)])
+ (void)*(char*)0; // no-warning
+
+ if (strlen(x) != strlen(y))
+ (void)*(char*)0; // no-warning
+
+ if (a != x[0])
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void stpcpy_overflow(char *y) {
+ char x[4];
+ if (strlen(y) == 4)
+ stpcpy(x, y); // expected-warning{{String copy function overflows destination buffer}}
+}
+
+void stpcpy_no_overflow(char *y) {
+ char x[4];
+ if (strlen(y) == 3)
+ stpcpy(x, y); // no-warning
+}
+
+//===----------------------------------------------------------------------===
+// strcat()
+//===----------------------------------------------------------------------===
+
+#ifdef VARIANT
+
+#define __strcat_chk BUILTIN(__strcat_chk)
+char *__strcat_chk(char *restrict s1, const char *restrict s2, size_t destlen);
+
+#define strcat(a,b) __strcat_chk(a,b,(size_t)-1)
+
+#else /* VARIANT */
+
+#define strcat BUILTIN(strcat)
+char *strcat(char *restrict s1, const char *restrict s2);
+
+#endif /* VARIANT */
+
+
+void strcat_null_dst(char *x) {
+ strcat(NULL, x); // expected-warning{{Null pointer argument in call to string copy function}}
+}
+
+void strcat_null_src(char *x) {
+ strcat(x, NULL); // expected-warning{{Null pointer argument in call to string copy function}}
+}
+
+void strcat_fn(char *x) {
+ strcat(x, (char*)&strcat_fn); // expected-warning{{Argument to string copy function is the address of the function 'strcat_fn', which is not a null-terminated string}}
+}
+
+void strcat_effects(char *y) {
+ char x[8] = "123";
+ size_t orig_len = strlen(x);
+ char a = x[0];
+
+ if (strlen(y) != 4)
+ return;
+
+ if (strcat(x, y) != x)
+ (void)*(char*)0; // no-warning
+
+ if ((int)strlen(x) != (orig_len + strlen(y)))
+ (void)*(char*)0; // no-warning
+}
+
+void strcat_overflow_0(char *y) {
+ char x[4] = "12";
+ if (strlen(y) == 4)
+ strcat(x, y); // expected-warning{{String copy function overflows destination buffer}}
+}
+
+void strcat_overflow_1(char *y) {
+ char x[4] = "12";
+ if (strlen(y) == 3)
+ strcat(x, y); // expected-warning{{String copy function overflows destination buffer}}
+}
+
+void strcat_overflow_2(char *y) {
+ char x[4] = "12";
+ if (strlen(y) == 2)
+ strcat(x, y); // expected-warning{{String copy function overflows destination buffer}}
+}
+
+void strcat_no_overflow(char *y) {
+ char x[5] = "12";
+ if (strlen(y) == 2)
+ strcat(x, y); // no-warning
+}
+
+void strcat_symbolic_dst_length(char *dst) {
+ strcat(dst, "1234");
+ if (strlen(dst) < 4)
+ (void)*(char*)0; // no-warning
+}
+
+void strcat_symbolic_src_length(char *src) {
+ char dst[8] = "1234";
+ strcat(dst, src);
+ if (strlen(dst) < 4)
+ (void)*(char*)0; // no-warning
+}
+
+void strcat_symbolic_dst_length_taint(char *dst) {
+ scanf("%s", dst); // Taint data.
+ strcat(dst, "1234");
+ if (strlen(dst) < 4)
+ (void)*(char*)0; // no-warning
+}
+
+void strcat_unknown_src_length(char *src, int offset) {
+ char dst[8] = "1234";
+ strcat(dst, &src[offset]);
+ if (strlen(dst) < 4)
+ (void)*(char*)0; // no-warning
+}
+
+// There is no strcat_unknown_dst_length because if we can't get a symbolic
+// length for the "before" strlen, we won't be able to set one for "after".
+
+void strcat_too_big(char *dst, char *src) {
+ if (strlen(dst) != (((size_t)0) - 2))
+ return;
+ if (strlen(src) != 2)
+ return;
+ strcat(dst, src); // expected-warning{{This expression will create a string whose length is too big to be represented as a size_t}}
+}
+
+
+//===----------------------------------------------------------------------===
+// strncpy()
+//===----------------------------------------------------------------------===
+
+#ifdef VARIANT
+
+#define __strncpy_chk BUILTIN(__strncpy_chk)
+char *__strncpy_chk(char *restrict s1, const char *restrict s2, size_t n, size_t destlen);
+
+#define strncpy(a,b,n) __strncpy_chk(a,b,n,(size_t)-1)
+
+#else /* VARIANT */
+
+#define strncpy BUILTIN(strncpy)
+char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
+
+#endif /* VARIANT */
+
+
+void strncpy_null_dst(char *x) {
+ strncpy(NULL, x, 5); // expected-warning{{Null pointer argument in call to string copy function}}
+}
+
+void strncpy_null_src(char *x) {
+ strncpy(x, NULL, 5); // expected-warning{{Null pointer argument in call to string copy function}}
+}
+
+void strncpy_fn(char *x) {
+ strncpy(x, (char*)&strcpy_fn, 5); // expected-warning{{Argument to string copy function is the address of the function 'strcpy_fn', which is not a null-terminated string}}
+}
+
+void strncpy_effects(char *x, char *y) {
+ char a = x[0];
+
+ if (strncpy(x, y, 5) != x)
+ (void)*(char*)0; // no-warning
+
+ if (strlen(x) != strlen(y))
+ (void)*(char*)0; // expected-warning{{null}}
+
+ if (a != x[0])
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void strncpy_overflow(char *y) {
+ char x[4];
+ if (strlen(y) == 4)
+ strncpy(x, y, 5); // expected-warning{{Size argument is greater than the length of the destination buffer}}
+}
+
+void strncpy_no_overflow(char *y) {
+ char x[4];
+ if (strlen(y) == 3)
+ strncpy(x, y, 5); // expected-warning{{Size argument is greater than the length of the destination buffer}}
+}
+
+void strncpy_no_overflow2(char *y, int n) {
+ if (n <= 4)
+ return;
+
+ char x[4];
+ if (strlen(y) == 3)
+ strncpy(x, y, n); // expected-warning{{Size argument is greater than the length of the destination buffer}}
+}
+
+void strncpy_truncate(char *y) {
+ char x[4];
+ if (strlen(y) == 4)
+ strncpy(x, y, 3); // no-warning
+}
+
+void strncpy_no_truncate(char *y) {
+ char x[4];
+ if (strlen(y) == 3)
+ strncpy(x, y, 3); // no-warning
+}
+
+void strncpy_exactly_matching_buffer(char *y) {
+ char x[4];
+ strncpy(x, y, 4); // no-warning
+
+ // strncpy does not null-terminate, so we have no idea what the strlen is
+ // after this.
+ if (strlen(x) > 4)
+ (void)*(int*)0; // expected-warning{{null}}
+}
+
+void strncpy_exactly_matching_buffer2(char *y) {
+ if (strlen(y) >= 4)
+ return;
+
+ char x[4];
+ strncpy(x, y, 4); // no-warning
+
+ // This time, we know that y fits in x anyway.
+ if (strlen(x) > 3)
+ (void)*(int*)0; // no-warning
+}
+
+//===----------------------------------------------------------------------===
+// strncat()
+//===----------------------------------------------------------------------===
+
+#ifdef VARIANT
+
+#define __strncat_chk BUILTIN(__strncat_chk)
+char *__strncat_chk(char *restrict s1, const char *restrict s2, size_t n, size_t destlen);
+
+#define strncat(a,b,c) __strncat_chk(a,b,c, (size_t)-1)
+
+#else /* VARIANT */
+
+#define strncat BUILTIN(strncat)
+char *strncat(char *restrict s1, const char *restrict s2, size_t n);
+
+#endif /* VARIANT */
+
+
+void strncat_null_dst(char *x) {
+ strncat(NULL, x, 4); // expected-warning{{Null pointer argument in call to string copy function}}
+}
+
+void strncat_null_src(char *x) {
+ strncat(x, NULL, 4); // expected-warning{{Null pointer argument in call to string copy function}}
+}
+
+void strncat_fn(char *x) {
+ strncat(x, (char*)&strncat_fn, 4); // expected-warning{{Argument to string copy function is the address of the function 'strncat_fn', which is not a null-terminated string}}
+}
+
+void strncat_effects(char *y) {
+ char x[8] = "123";
+ size_t orig_len = strlen(x);
+ char a = x[0];
+
+ if (strlen(y) != 4)
+ return;
+
+ if (strncat(x, y, strlen(y)) != x)
+ (void)*(char*)0; // no-warning
+
+ if (strlen(x) != orig_len + strlen(y))
+ (void)*(char*)0; // no-warning
+}
+
+void strncat_overflow_0(char *y) {
+ char x[4] = "12";
+ if (strlen(y) == 4)
+ strncat(x, y, strlen(y)); // expected-warning{{Size argument is greater than the free space in the destination buffer}}
+}
+
+void strncat_overflow_1(char *y) {
+ char x[4] = "12";
+ if (strlen(y) == 3)
+ strncat(x, y, strlen(y)); // expected-warning{{Size argument is greater than the free space in the destination buffer}}
+}
+
+void strncat_overflow_2(char *y) {
+ char x[4] = "12";
+ if (strlen(y) == 2)
+ strncat(x, y, strlen(y)); // expected-warning{{Size argument is greater than the free space in the destination buffer}}
+}
+
+void strncat_overflow_3(char *y) {
+ char x[4] = "12";
+ if (strlen(y) == 4)
+ strncat(x, y, 2); // expected-warning{{Size argument is greater than the free space in the destination buffer}}
+}
+void strncat_no_overflow_1(char *y) {
+ char x[5] = "12";
+ if (strlen(y) == 2)
+ strncat(x, y, strlen(y)); // no-warning
+}
+
+void strncat_no_overflow_2(char *y) {
+ char x[4] = "12";
+ if (strlen(y) == 4)
+ strncat(x, y, 1); // no-warning
+}
+
+void strncat_symbolic_dst_length(char *dst) {
+ strncat(dst, "1234", 5);
+ if (strlen(dst) < 4)
+ (void)*(char*)0; // no-warning
+}
+
+void strncat_symbolic_src_length(char *src) {
+ char dst[8] = "1234";
+ strncat(dst, src, 3);
+ if (strlen(dst) < 4)
+ (void)*(char*)0; // no-warning
+
+ char dst2[8] = "1234";
+ strncat(dst2, src, 4); // expected-warning{{Size argument is greater than the free space in the destination buffer}}
+}
+
+void strncat_unknown_src_length(char *src, int offset) {
+ char dst[8] = "1234";
+ strncat(dst, &src[offset], 3);
+ if (strlen(dst) < 4)
+ (void)*(char*)0; // no-warning
+
+ char dst2[8] = "1234";
+ strncat(dst2, &src[offset], 4); // expected-warning{{Size argument is greater than the free space in the destination buffer}}
+}
+
+// There is no strncat_unknown_dst_length because if we can't get a symbolic
+// length for the "before" strlen, we won't be able to set one for "after".
+
+void strncat_symbolic_limit(unsigned limit) {
+ char dst[6] = "1234";
+ char src[] = "567";
+ strncat(dst, src, limit); // no-warning
+ if (strlen(dst) < 4)
+ (void)*(char*)0; // no-warning
+ if (strlen(dst) == 4)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void strncat_unknown_limit(float limit) {
+ char dst[6] = "1234";
+ char src[] = "567";
+ strncat(dst, src, (size_t)limit); // no-warning
+ if (strlen(dst) < 4)
+ (void)*(char*)0; // no-warning
+ if (strlen(dst) == 4)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
+void strncat_too_big(char *dst, char *src) {
+ if (strlen(dst) != (((size_t)0) - 2))
+ return;
+ if (strlen(src) != 2)
+ return;
+ strncat(dst, src, 2); // expected-warning{{This expression will create a string whose length is too big to be represented as a size_t}}
+}
+
+//===----------------------------------------------------------------------===
+// strcmp()
+//===----------------------------------------------------------------------===
+
+#define strcmp BUILTIN(strcmp)
+int strcmp(const char * s1, const char * s2);
+
+void strcmp_constant0() {
+ if (strcmp("123", "123") != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strcmp_constant_and_var_0() {
+ char *x = "123";
+ if (strcmp(x, "123") != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strcmp_constant_and_var_1() {
+ char *x = "123";
+ if (strcmp("123", x) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strcmp_0() {
+ char *x = "123";
+ char *y = "123";
+ if (strcmp(x, y) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strcmp_1() {
+ char *x = "234";
+ char *y = "123";
+ if (strcmp(x, y) != 1)
+ (void)*(char*)0; // no-warning
+}
+
+void strcmp_2() {
+ char *x = "123";
+ char *y = "234";
+ if (strcmp(x, y) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strcmp_null_0() {
+ char *x = NULL;
+ char *y = "123";
+ strcmp(x, y); // expected-warning{{Null pointer argument in call to string comparison function}}
+}
+
+void strcmp_null_1() {
+ char *x = "123";
+ char *y = NULL;
+ strcmp(x, y); // expected-warning{{Null pointer argument in call to string comparison function}}
+}
+
+void strcmp_diff_length_0() {
+ char *x = "12345";
+ char *y = "234";
+ if (strcmp(x, y) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strcmp_diff_length_1() {
+ char *x = "123";
+ char *y = "23456";
+ if (strcmp(x, y) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strcmp_diff_length_2() {
+ char *x = "12345";
+ char *y = "123";
+ if (strcmp(x, y) != 1)
+ (void)*(char*)0; // no-warning
+}
+
+void strcmp_diff_length_3() {
+ char *x = "123";
+ char *y = "12345";
+ if (strcmp(x, y) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strcmp_embedded_null () {
+ if (strcmp("\0z", "\0y") != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strcmp_unknown_arg (char *unknown) {
+ if (strcmp(unknown, unknown) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+//===----------------------------------------------------------------------===
+// strncmp()
+//===----------------------------------------------------------------------===
+
+#define strncmp BUILTIN(strncmp)
+int strncmp(const char *s1, const char *s2, size_t n);
+
+void strncmp_constant0() {
+ if (strncmp("123", "123", 3) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strncmp_constant_and_var_0() {
+ char *x = "123";
+ if (strncmp(x, "123", 3) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strncmp_constant_and_var_1() {
+ char *x = "123";
+ if (strncmp("123", x, 3) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strncmp_0() {
+ char *x = "123";
+ char *y = "123";
+ if (strncmp(x, y, 3) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strncmp_1() {
+ char *x = "234";
+ char *y = "123";
+ if (strncmp(x, y, 3) != 1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncmp_2() {
+ char *x = "123";
+ char *y = "234";
+ if (strncmp(x, y, 3) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncmp_null_0() {
+ char *x = NULL;
+ char *y = "123";
+ strncmp(x, y, 3); // expected-warning{{Null pointer argument in call to string comparison function}}
+}
+
+void strncmp_null_1() {
+ char *x = "123";
+ char *y = NULL;
+ strncmp(x, y, 3); // expected-warning{{Null pointer argument in call to string comparison function}}
+}
+
+void strncmp_diff_length_0() {
+ char *x = "12345";
+ char *y = "234";
+ if (strncmp(x, y, 5) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncmp_diff_length_1() {
+ char *x = "123";
+ char *y = "23456";
+ if (strncmp(x, y, 5) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncmp_diff_length_2() {
+ char *x = "12345";
+ char *y = "123";
+ if (strncmp(x, y, 5) != 1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncmp_diff_length_3() {
+ char *x = "123";
+ char *y = "12345";
+ if (strncmp(x, y, 5) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncmp_diff_length_4() {
+ char *x = "123";
+ char *y = "12345";
+ if (strncmp(x, y, 3) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strncmp_diff_length_5() {
+ char *x = "012";
+ char *y = "12345";
+ if (strncmp(x, y, 3) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncmp_diff_length_6() {
+ char *x = "234";
+ char *y = "12345";
+ if (strncmp(x, y, 3) != 1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncmp_embedded_null () {
+ if (strncmp("ab\0zz", "ab\0yy", 4) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+//===----------------------------------------------------------------------===
+// strcasecmp()
+//===----------------------------------------------------------------------===
+
+#define strcasecmp BUILTIN(strcasecmp)
+int strcasecmp(const char *s1, const char *s2);
+
+void strcasecmp_constant0() {
+ if (strcasecmp("abc", "Abc") != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strcasecmp_constant_and_var_0() {
+ char *x = "abc";
+ if (strcasecmp(x, "Abc") != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strcasecmp_constant_and_var_1() {
+ char *x = "abc";
+ if (strcasecmp("Abc", x) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strcasecmp_0() {
+ char *x = "abc";
+ char *y = "Abc";
+ if (strcasecmp(x, y) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strcasecmp_1() {
+ char *x = "Bcd";
+ char *y = "abc";
+ if (strcasecmp(x, y) != 1)
+ (void)*(char*)0; // no-warning
+}
+
+void strcasecmp_2() {
+ char *x = "abc";
+ char *y = "Bcd";
+ if (strcasecmp(x, y) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strcasecmp_null_0() {
+ char *x = NULL;
+ char *y = "123";
+ strcasecmp(x, y); // expected-warning{{Null pointer argument in call to string comparison function}}
+}
+
+void strcasecmp_null_1() {
+ char *x = "123";
+ char *y = NULL;
+ strcasecmp(x, y); // expected-warning{{Null pointer argument in call to string comparison function}}
+}
+
+void strcasecmp_diff_length_0() {
+ char *x = "abcde";
+ char *y = "aBd";
+ if (strcasecmp(x, y) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strcasecmp_diff_length_1() {
+ char *x = "abc";
+ char *y = "aBdef";
+ if (strcasecmp(x, y) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strcasecmp_diff_length_2() {
+ char *x = "aBcDe";
+ char *y = "abc";
+ if (strcasecmp(x, y) != 1)
+ (void)*(char*)0; // no-warning
+}
+
+void strcasecmp_diff_length_3() {
+ char *x = "aBc";
+ char *y = "abcde";
+ if (strcasecmp(x, y) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strcasecmp_embedded_null () {
+ if (strcasecmp("ab\0zz", "ab\0yy") != 0)
+ (void)*(char*)0; // no-warning
+}
+
+//===----------------------------------------------------------------------===
+// strncasecmp()
+//===----------------------------------------------------------------------===
+
+#define strncasecmp BUILTIN(strncasecmp)
+int strncasecmp(const char *s1, const char *s2, size_t n);
+
+void strncasecmp_constant0() {
+ if (strncasecmp("abc", "Abc", 3) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_constant_and_var_0() {
+ char *x = "abc";
+ if (strncasecmp(x, "Abc", 3) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_constant_and_var_1() {
+ char *x = "abc";
+ if (strncasecmp("Abc", x, 3) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_0() {
+ char *x = "abc";
+ char *y = "Abc";
+ if (strncasecmp(x, y, 3) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_1() {
+ char *x = "Bcd";
+ char *y = "abc";
+ if (strncasecmp(x, y, 3) != 1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_2() {
+ char *x = "abc";
+ char *y = "Bcd";
+ if (strncasecmp(x, y, 3) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_null_0() {
+ char *x = NULL;
+ char *y = "123";
+ strncasecmp(x, y, 3); // expected-warning{{Null pointer argument in call to string comparison function}}
+}
+
+void strncasecmp_null_1() {
+ char *x = "123";
+ char *y = NULL;
+ strncasecmp(x, y, 3); // expected-warning{{Null pointer argument in call to string comparison function}}
+}
+
+void strncasecmp_diff_length_0() {
+ char *x = "abcde";
+ char *y = "aBd";
+ if (strncasecmp(x, y, 5) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_diff_length_1() {
+ char *x = "abc";
+ char *y = "aBdef";
+ if (strncasecmp(x, y, 5) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_diff_length_2() {
+ char *x = "aBcDe";
+ char *y = "abc";
+ if (strncasecmp(x, y, 5) != 1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_diff_length_3() {
+ char *x = "aBc";
+ char *y = "abcde";
+ if (strncasecmp(x, y, 5) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_diff_length_4() {
+ char *x = "abcde";
+ char *y = "aBc";
+ if (strncasecmp(x, y, 3) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_diff_length_5() {
+ char *x = "abcde";
+ char *y = "aBd";
+ if (strncasecmp(x, y, 3) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_diff_length_6() {
+ char *x = "aBDe";
+ char *y = "abc";
+ if (strncasecmp(x, y, 3) != 1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_embedded_null () {
+ if (strncasecmp("ab\0zz", "ab\0yy", 4) != 0)
+ (void)*(char*)0; // no-warning
+}
diff --git a/clang/test/Analysis/system-header-simulator-objc.h b/clang/test/Analysis/system-header-simulator-objc.h
new file mode 100644
index 0000000..92d5899
--- /dev/null
+++ b/clang/test/Analysis/system-header-simulator-objc.h
@@ -0,0 +1,114 @@
+#pragma clang system_header
+
+typedef unsigned int UInt32;
+typedef unsigned short UInt16;
+
+typedef signed long CFIndex;
+typedef signed char BOOL;
+typedef unsigned long NSUInteger;
+typedef unsigned short unichar;
+typedef UInt16 UniChar;
+
+enum {
+ NSASCIIStringEncoding = 1,
+ NSNEXTSTEPStringEncoding = 2,
+ NSJapaneseEUCStringEncoding = 3,
+ NSUTF8StringEncoding = 4,
+ NSISOLatin1StringEncoding = 5,
+ NSSymbolStringEncoding = 6,
+ NSNonLossyASCIIStringEncoding = 7,
+};
+typedef const struct __CFString * CFStringRef;
+typedef struct __CFString * CFMutableStringRef;
+typedef NSUInteger NSStringEncoding;
+typedef UInt32 CFStringEncoding;
+
+typedef const void * CFTypeRef;
+
+typedef const struct __CFAllocator * CFAllocatorRef;
+extern const CFAllocatorRef kCFAllocatorDefault;
+extern const CFAllocatorRef kCFAllocatorSystemDefault;
+extern const CFAllocatorRef kCFAllocatorMalloc;
+extern const CFAllocatorRef kCFAllocatorMallocZone;
+extern const CFAllocatorRef kCFAllocatorNull;
+
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+- (id)copy;
+- (oneway void)release;
+- (id)autorelease;
+- (id)init;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
++ (id)allocWithZone:(NSZone *)zone;
++ (id)alloc;
+- (void)dealloc;
+@end
+@interface NSObject (NSCoderMethods)
+- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+typedef struct {
+}
+NSFastEnumerationState;
+@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end @class NSString, NSDictionary;
+@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
+@end @interface NSNumber : NSValue - (char)charValue;
+- (id)initWithInt:(int)value;
+@end @class NSString;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSArray (NSArrayCreation) + (id)array;
+@end @interface NSAutoreleasePool : NSObject {
+}
+- (void)drain;
+@end extern NSString * const NSBundleDidLoadNotification;
+typedef double NSTimeInterval;
+@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate;
+@end
+
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
+- (NSString *)stringByAppendingString:(NSString *)aString;
+- ( const char *)UTF8String;
+- (id)initWithUTF8String:(const char *)nullTerminatedCString;
+- (id)initWithCharactersNoCopy:(unichar *)characters length:(NSUInteger)length freeWhenDone:(BOOL)freeBuffer;
+- (id)initWithCharacters:(const unichar *)characters length:(NSUInteger)length;
+- (id)initWithBytes:(const void *)bytes length:(NSUInteger)len encoding:(NSStringEncoding)encoding;
+- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)len encoding:(NSStringEncoding)encoding freeWhenDone:(BOOL)freeBuffer;
++ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
+@end @class NSString, NSURL, NSError;
+@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;
+- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;
+- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b;
+@end
+
+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);
+void CFDictionarySetValue(CFMutableDictionaryRef, const void *, const void *);
+
+
+extern void CFRelease(CFTypeRef cf);
+
+extern CFMutableStringRef CFStringCreateMutableWithExternalCharactersNoCopy(CFAllocatorRef alloc, UniChar *chars, CFIndex numChars, CFIndex capacity, CFAllocatorRef externalCharactersAllocator);
+extern CFStringRef CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator);
+extern void CFStringAppend(CFMutableStringRef theString, CFStringRef appendedString);
diff --git a/clang/test/Analysis/system-header-simulator.h b/clang/test/Analysis/system-header-simulator.h
new file mode 100644
index 0000000..6212131
--- /dev/null
+++ b/clang/test/Analysis/system-header-simulator.h
@@ -0,0 +1,38 @@
+#pragma clang system_header
+
+typedef struct _FILE FILE;
+extern FILE *stdin;
+extern FILE *stdout;
+extern FILE *stderr;
+// Include a variant of standard streams that occur in the pre-processed file.
+extern FILE *__stdinp;
+extern FILE *__stdoutp;
+extern FILE *__stderrp;
+
+
+int fscanf(FILE *restrict, const char *restrict, ...);
+
+// Note, on some platforms errno macro gets replaced with a function call.
+extern int errno;
+
+unsigned long strlen(const char *);
+
+char *strcpy(char *restrict, const char *restrict);
+
+typedef unsigned long __darwin_pthread_key_t;
+typedef __darwin_pthread_key_t pthread_key_t;
+int pthread_setspecific(pthread_key_t, const void *);
+
+typedef long long __int64_t;
+typedef __int64_t __darwin_off_t;
+typedef __darwin_off_t fpos_t;
+
+void setbuf(FILE * restrict, char * restrict);
+int setvbuf(FILE * restrict, char * restrict, int, size_t);
+
+FILE *funopen(const void *,
+ int (*)(void *, char *, int),
+ int (*)(void *, const char *, int),
+ fpos_t (*)(void *, fpos_t, int),
+ int (*)(void *));
+
diff --git a/clang/test/Analysis/taint-generic.c b/clang/test/Analysis/taint-generic.c
new file mode 100644
index 0000000..b00372a
--- /dev/null
+++ b/clang/test/Analysis/taint-generic.c
@@ -0,0 +1,185 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.taint,core,experimental.security.ArrayBoundV2 -Wno-format-security -verify %s
+
+int scanf(const char *restrict format, ...);
+int getchar(void);
+
+typedef struct _FILE FILE;
+extern FILE *stdin;
+int fscanf(FILE *restrict stream, const char *restrict format, ...);
+int sprintf(char *str, const char *format, ...);
+void setproctitle(const char *fmt, ...);
+typedef __typeof(sizeof(int)) size_t;
+
+// Define string functions. Use builtin for some of them. They all default to
+// the processing in the taint checker.
+#define strcpy(dest, src) \
+ ((__builtin_object_size(dest, 0) != -1ULL) \
+ ? __builtin___strcpy_chk (dest, src, __builtin_object_size(dest, 1)) \
+ : __inline_strcpy_chk(dest, src))
+
+static char *__inline_strcpy_chk (char *dest, const char *src) {
+ return __builtin___strcpy_chk(dest, src, __builtin_object_size(dest, 1));
+}
+char *stpcpy(char *restrict s1, const char *restrict s2);
+char *strncpy( char * destination, const char * source, size_t num );
+char *strndup(const char *s, size_t n);
+char *strncat(char *restrict s1, const char *restrict s2, size_t n);
+
+void *malloc(size_t);
+void *calloc(size_t nmemb, size_t size);
+void bcopy(void *s1, void *s2, size_t n);
+
+#define BUFSIZE 10
+
+int Buffer[BUFSIZE];
+void bufferScanfDirect(void)
+{
+ int n;
+ scanf("%d", &n);
+ Buffer[n] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void bufferScanfArithmetic1(int x) {
+ int n;
+ scanf("%d", &n);
+ int m = (n - 3);
+ Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void bufferScanfArithmetic2(int x) {
+ int n;
+ scanf("%d", &n);
+ int m = 100 - (n + 3) * x;
+ Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void bufferScanfAssignment(int x) {
+ int n;
+ scanf("%d", &n);
+ int m;
+ if (x > 0) {
+ m = n;
+ Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
+ }
+}
+
+void scanfArg() {
+ int t = 0;
+ scanf("%d", t); // expected-warning {{format specifies type 'int *' but the argument has type 'int'}}
+}
+
+void bufferGetchar(int x) {
+ int m = getchar();
+ Buffer[m] = 1; //expected-warning {{Out of bound memory access (index is tainted)}}
+}
+
+void testUncontrolledFormatString(char **p) {
+ char s[80];
+ fscanf(stdin, "%s", s);
+ char buf[128];
+ sprintf(buf,s); // expected-warning {{Uncontrolled Format String}}
+ setproctitle(s, 3); // expected-warning {{Uncontrolled Format String}}
+
+ // Test taint propagation through strcpy and family.
+ char scpy[80];
+ strcpy(scpy, s);
+ sprintf(buf,scpy); // expected-warning {{Uncontrolled Format String}}
+
+ stpcpy(*(++p), s); // this generates __inline.
+ setproctitle(*(p), 3); // expected-warning {{Uncontrolled Format String}}
+
+ char spcpy[80];
+ stpcpy(spcpy, s);
+ setproctitle(spcpy, 3); // expected-warning {{Uncontrolled Format String}}
+
+ char *spcpyret;
+ spcpyret = stpcpy(spcpy, s);
+ setproctitle(spcpyret, 3); // expected-warning {{Uncontrolled Format String}}
+
+ char sncpy[80];
+ strncpy(sncpy, s, 20);
+ setproctitle(sncpy, 3); // expected-warning {{Uncontrolled Format String}}
+
+ char *dup;
+ dup = strndup(s, 20);
+ setproctitle(dup, 3); // expected-warning {{Uncontrolled Format String}}
+
+}
+
+int system(const char *command);
+void testTaintSystemCall() {
+ char buffer[156];
+ char addr[128];
+ scanf("%s", addr);
+ system(addr); // expected-warning {{Untrusted data is passed to a system call}}
+
+ // Test that spintf transfers taint.
+ sprintf(buffer, "/bin/mail %s < /tmp/email", addr);
+ system(buffer); // expected-warning {{Untrusted data is passed to a system call}}
+}
+
+void testTaintSystemCall2() {
+ // Test that snpintf transfers taint.
+ char buffern[156];
+ char addr[128];
+ scanf("%s", addr);
+ __builtin_snprintf(buffern, 10, "/bin/mail %s < /tmp/email", addr);
+ system(buffern); // expected-warning {{Untrusted data is passed to a system call}}
+}
+
+void testTaintSystemCall3() {
+ char buffern2[156];
+ int numt;
+ char addr[128];
+ scanf("%s %d", addr, &numt);
+ __builtin_snprintf(buffern2, numt, "/bin/mail %s < /tmp/email", "abcd");
+ system(buffern2); // expected-warning {{Untrusted data is passed to a system call}}
+}
+
+void testTaintedBufferSize() {
+ size_t ts;
+ scanf("%zd", &ts);
+
+ int *buf1 = (int*)malloc(ts*sizeof(int)); // expected-warning {{Untrusted data is used to specify the buffer size}}
+ char *dst = (char*)calloc(ts, sizeof(char)); //expected-warning {{Untrusted data is used to specify the buffer size}}
+ bcopy(buf1, dst, ts); // expected-warning {{Untrusted data is used to specify the buffer size}}
+ __builtin_memcpy(dst, buf1, (ts + 4)*sizeof(char)); // expected-warning {{Untrusted data is used to specify the buffer size}}
+
+ // If both buffers are trusted, do not issue a warning.
+ char *dst2 = (char*)malloc(ts*sizeof(char)); // expected-warning {{Untrusted data is used to specify the buffer size}}
+ strncat(dst2, dst, ts); // no-warning
+}
+
+#define AF_UNIX 1 /* local to host (pipes) */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define AF_LOCAL AF_UNIX /* backward compatibility */
+#define SOCK_STREAM 1
+int socket(int, int, int);
+size_t read(int, void *, size_t);
+int execl(const char *, const char *, ...);
+
+void testSocket() {
+ int sock;
+ char buffer[100];
+
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+ read(sock, buffer, 100);
+ execl(buffer, "filename", 0); // expected-warning {{Untrusted data is passed to a system call}}
+
+ sock = socket(AF_LOCAL, SOCK_STREAM, 0);
+ read(sock, buffer, 100);
+ execl(buffer, "filename", 0); // no-warning
+}
+
+int testDivByZero() {
+ int x;
+ scanf("%d", &x);
+ return 5/x; // expected-warning {{Division by a tainted value, possibly zero}}
+}
+
+// Zero-sized VLAs.
+void testTaintedVLASize() {
+ int x;
+ scanf("%d", &x);
+ int vla[x]; // expected-warning{{Declared variable-length array (VLA) has tainted size}}
+}
diff --git a/clang/test/Analysis/taint-tester.c b/clang/test/Analysis/taint-tester.c
new file mode 100644
index 0000000..3773335
--- /dev/null
+++ b/clang/test/Analysis/taint-tester.c
@@ -0,0 +1,204 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.taint,debug.TaintTest %s -verify
+
+#include <stdarg.h>
+
+int scanf(const char *restrict format, ...);
+int getchar(void);
+typedef __typeof(sizeof(int)) size_t;
+
+#define BUFSIZE 10
+int Buffer[BUFSIZE];
+
+struct XYStruct {
+ int x;
+ int y;
+ char z;
+};
+
+void taintTracking(int x) {
+ int n;
+ int *addr = &Buffer[0];
+ scanf("%d", &n);
+ addr += n;// expected-warning + {{tainted}}
+ *addr = n; // expected-warning + {{tainted}}
+
+ double tdiv = n / 30; // expected-warning+ {{tainted}}
+ char *loc_cast = (char *) n; // expected-warning +{{tainted}}
+ char tinc = tdiv++; // expected-warning + {{tainted}}
+ int tincdec = (char)tinc--; // expected-warning+{{tainted}}
+
+ // Tainted ptr arithmetic/array element address.
+ int tprtarithmetic1 = *(addr+1); // expected-warning + {{tainted}}
+
+ // Dereference.
+ int *ptr;
+ scanf("%p", &ptr);
+ int ptrDeref = *ptr; // expected-warning + {{tainted}}
+ int _ptrDeref = ptrDeref + 13; // expected-warning + {{tainted}}
+
+ // Pointer arithmetic + dereferencing.
+ // FIXME: We fail to propagate the taint here because RegionStore does not
+ // handle ElementRegions with symbolic indexes.
+ int addrDeref = *addr; // expected-warning + {{tainted}}
+ int _addrDeref = addrDeref;
+
+ // Tainted struct address, casts.
+ struct XYStruct *xyPtr = 0;
+ scanf("%p", &xyPtr);
+ void *tXYStructPtr = xyPtr; // expected-warning + {{tainted}}
+ struct XYStruct *xyPtrCopy = tXYStructPtr; // expected-warning + {{tainted}}
+ int ptrtx = xyPtr->x;// expected-warning + {{tainted}}
+ int ptrty = xyPtr->y;// expected-warning + {{tainted}}
+
+ // Taint on fields of a struct.
+ struct XYStruct xy = {2, 3, 11};
+ scanf("%d", &xy.y);
+ scanf("%d", &xy.x);
+ int tx = xy.x; // expected-warning + {{tainted}}
+ int ty = xy.y; // FIXME: This should be tainted as well.
+ char ntz = xy.z;// no warning
+ // Now, scanf scans both.
+ scanf("%d %d", &xy.y, &xy.x);
+ int ttx = xy.x; // expected-warning + {{tainted}}
+ int tty = xy.y; // expected-warning + {{tainted}}
+}
+
+void BitwiseOp(int in, char inn) {
+ // Taint on bitwise operations, integer to integer cast.
+ int m;
+ int x = 0;
+ scanf("%d", &x);
+ int y = (in << (x << in)) * 5;// expected-warning + {{tainted}}
+ // The next line tests integer to integer cast.
+ int z = y & inn; // expected-warning + {{tainted}}
+ if (y == 5) // expected-warning + {{tainted}}
+ m = z | z;// expected-warning + {{tainted}}
+ else
+ m = inn;
+ int mm = m; // expected-warning + {{tainted}}
+}
+
+// Test getenv.
+char *getenv(const char *name);
+void getenvTest(char *home) {
+ home = getenv("HOME"); // expected-warning + {{tainted}}
+ if (home != 0) { // expected-warning + {{tainted}}
+ char d = home[0]; // expected-warning + {{tainted}}
+ }
+}
+
+typedef struct _FILE FILE;
+extern FILE *stdin;
+extern FILE *stdout;
+extern FILE *stderr;
+int fscanf(FILE *restrict stream, const char *restrict format, ...);
+int fprintf(FILE *stream, const char *format, ...);
+int fclose(FILE *stream);
+FILE *fopen(const char *path, const char *mode);
+
+int fscanfTest(void) {
+ FILE *fp;
+ char s[80];
+ int t;
+
+ // Check if stdin is treated as tainted.
+ fscanf(stdin, "%s %d", s, &t);
+ // Note, here, s is not tainted, but the data s points to is tainted.
+ char *ts = s;
+ char tss = s[0]; // expected-warning + {{tainted}}
+ int tt = t; // expected-warning + {{tainted}}
+ if((fp=fopen("test", "w")) == 0) // expected-warning + {{tainted}}
+ return 1;
+ fprintf(fp, "%s %d", s, t); // expected-warning + {{tainted}}
+ fclose(fp); // expected-warning + {{tainted}}
+
+ // Test fscanf and fopen.
+ if((fp=fopen("test","r")) == 0) // expected-warning + {{tainted}}
+ return 1;
+ fscanf(fp, "%s%d", s, &t); // expected-warning + {{tainted}}
+ fprintf(stdout, "%s %d", s, t); // expected-warning + {{tainted}}
+ return 0;
+}
+
+// Check if we propagate taint from stdin when it's used in an assignment.
+void stdinTest1() {
+ int i;
+ fscanf(stdin, "%d", &i);
+ int j = i; // expected-warning + {{tainted}}
+}
+void stdinTest2(FILE *pIn) {
+ FILE *p = stdin;
+ FILE *pp = p;
+ int ii;
+
+ fscanf(pp, "%d", &ii);
+ int jj = ii;// expected-warning + {{tainted}}
+
+ fscanf(p, "%d", &ii);
+ int jj2 = ii;// expected-warning + {{tainted}}
+
+ ii = 3;
+ int jj3 = ii;// no warning
+
+ p = pIn;
+ fscanf(p, "%d", &ii);
+ int jj4 = ii;// no warning
+}
+
+void stdinTest3() {
+ FILE **ppp = &stdin;
+ int iii;
+ fscanf(*ppp, "%d", &iii);
+ int jjj = iii;// expected-warning + {{tainted}}
+}
+
+// Test that stdin does not get invalidated by calls.
+void foo();
+void stdinTest4() {
+ int i;
+ fscanf(stdin, "%d", &i);
+ foo();
+ int j = i; // expected-warning + {{tainted}}
+}
+
+int getw(FILE *);
+void getwTest() {
+ int i = getw(stdin); // expected-warning + {{tainted}}
+}
+
+typedef long ssize_t;
+ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict);
+int printf(const char * __restrict, ...);
+void free(void *ptr);
+void getlineTest(void) {
+ FILE *fp;
+ char *line = 0;
+ size_t len = 0;
+ ssize_t read;
+ while ((read = getline(&line, &len, stdin)) != -1) {
+ printf("%s", line); // expected-warning + {{tainted}}
+ }
+ free(line); // expected-warning + {{tainted}}
+}
+
+// Test propagation functions - the ones that propagate taint from arguments to
+// return value, ptr arguments.
+
+int atoi(const char *nptr);
+long atol(const char *nptr);
+long long atoll(const char *nptr);
+
+void atoiTest() {
+ char s[80];
+ scanf("%s", s);
+ int d = atoi(s); // expected-warning + {{tainted}}
+ int td = d; // expected-warning + {{tainted}}
+
+ long l = atol(s); // expected-warning + {{tainted}}
+ int tl = l; // expected-warning + {{tainted}}
+
+ long long ll = atoll(s); // expected-warning + {{tainted}}
+ int tll = ll; // expected-warning + {{tainted}}
+
+}
+
diff --git a/clang/test/Analysis/taint-tester.cpp b/clang/test/Analysis/taint-tester.cpp
new file mode 100644
index 0000000..679fbc2
--- /dev/null
+++ b/clang/test/Analysis/taint-tester.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.taint,debug.TaintTest %s -verify
+
+typedef struct _FILE FILE;
+typedef __typeof(sizeof(int)) size_t;
+extern FILE *stdin;
+typedef long ssize_t;
+ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict);
+int printf(const char * __restrict, ...);
+void free(void *ptr);
+
+struct GetLineTestStruct {
+ ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict);
+};
+
+void getlineTest(void) {
+ FILE *fp;
+ char *line = 0;
+ size_t len = 0;
+ ssize_t read;
+ struct GetLineTestStruct T;
+
+ while ((read = T.getline(&line, &len, stdin)) != -1) {
+ printf("%s", line); // no warning
+ }
+ free(line);
+}
diff --git a/clang/test/Analysis/taint-tester.m b/clang/test/Analysis/taint-tester.m
new file mode 100644
index 0000000..ae55c66
--- /dev/null
+++ b/clang/test/Analysis/taint-tester.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.taint,debug.TaintTest %s -verify
+
+#import <stdarg.h>
+
+@interface NSString
+- (NSString *)stringByAppendingString:(NSString *)aString;
+@end
+extern void NSLog (NSString *format, ...);
+extern void NSLogv(NSString *format, va_list args);
+
+void TestLog (NSString *format, ...);
+void TestLog (NSString *format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ NSString *string = @"AAA: ";
+
+ NSLogv([string stringByAppendingString:format], ap);
+
+ va_end(ap);
+} \ No newline at end of file
diff --git a/clang/test/Analysis/temp-obj-dtors-cfg-output.cpp b/clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
new file mode 100644
index 0000000..53ab211
--- /dev/null
+++ b/clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
@@ -0,0 +1,767 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors -cfg-add-initializers %s 2>&1 | FileCheck %s
+// XPASS: *
+
+class A {
+public:
+ A() {}
+ ~A() {}
+
+ static A make() { return A(); }
+
+ operator bool() { return false; }
+ operator int() { return 0; }
+};
+
+class B {
+public:
+ B() {}
+ ~B() {}
+
+ operator bool() { return true; }
+ operator int() { return 1; }
+ operator A() { return A(); }
+};
+
+void foo(int);
+void foo(bool);
+void foo(const A&);
+
+void test_binary() {
+ int a = int(A()) + int(B());
+ foo(int(A()) + int(B()));
+ int b;
+}
+
+void test_and() {
+ bool a = A() && B();
+ foo(A() && B());
+ int b;
+}
+
+void test_or() {
+ bool a = A() || B();
+ foo(A() || B());
+ int b;
+}
+
+void test_cond() {
+ A a = B() ? A() : A(B());
+ if (B()) { foo(0); } else { foo(0); }
+ int b;
+}
+
+void test_cond_cref() {
+ const A& a = B() ? A() : A(B());
+ foo(B() ? A() : A(B()));
+ int b;
+}
+
+void test_cond_implicit() {
+ A a = A() ?: A();
+ int b;
+}
+
+void test_cond_implicit_cref() {
+ const A& a = A() ?: A();
+ foo(A() ?: A());
+ int b;
+}
+
+void test_copy_init() {
+ A a = A();
+ int b;
+}
+
+void test_cref_init() {
+ const A& a = A();
+ foo(A());
+ int b;
+}
+
+void test_call_copy_init() {
+ A a = A::make();
+ int b;
+}
+
+void test_call_cref_init() {
+ const A& a = A::make();
+ foo(A::make());
+ int b;
+}
+
+void test_assign() {
+ int a;
+ a = A();
+ int b;
+}
+
+class TestCtorInits {
+ int a;
+ int b;
+public:
+ TestCtorInits();
+};
+
+TestCtorInits::TestCtorInits()
+ : a(int(A()) + int(B()))
+ , b() {}
+
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+
+// CHECK: [B1]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B1.1] (BindTemporary)
+// CHECK: 3: [B1.2].operator int
+// CHECK: 4: [B1.3]()
+// CHECK: 5: [B1.4] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 6: int([B1.5]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 7: B() (CXXConstructExpr, class B)
+// CHECK: 8: [B1.7] (BindTemporary)
+// CHECK: 9: [B1.8].operator int
+// CHECK: 10: [B1.9]()
+// CHECK: 11: [B1.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 12: int([B1.11]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 13: [B1.6] + [B1.12]
+// CHECK: 14: int a = int(A().operator int()) + int(B().operator int());
+// CHECK: 15: ~B() (Temporary object destructor)
+// CHECK: 16: ~A() (Temporary object destructor)
+// CHECK: 17: A() (CXXConstructExpr, class A)
+// CHECK: 18: [B1.17] (BindTemporary)
+// CHECK: 19: [B1.18].operator int
+// CHECK: 20: [B1.19]()
+// CHECK: 21: [B1.20] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 22: int([B1.21]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 23: B() (CXXConstructExpr, class B)
+// CHECK: 24: [B1.23] (BindTemporary)
+// CHECK: 25: [B1.24].operator int
+// CHECK: 26: [B1.25]()
+// CHECK: 27: [B1.26] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 28: int([B1.27]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 29: [B1.22] + [B1.28]
+// CHECK: 30: foo
+// CHECK: 31: [B1.30] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(int))
+// CHECK: 32: [B1.31]([B1.29])
+// CHECK: 33: ~B() (Temporary object destructor)
+// CHECK: 34: ~A() (Temporary object destructor)
+// CHECK: 35: int b;
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B10 (ENTRY)]
+// CHECK: Succs (1): B8
+// CHECK: [B1]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: int b;
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B3
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: [B4.6] && [B5.5]
+// CHECK: 2: foo
+// CHECK: 3: [B3.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(_Bool))
+// CHECK: 4: [B3.3]([B3.1])
+// CHECK: T: [B4.6] && ...
+// CHECK: Preds (2): B5 B4
+// CHECK: Succs (2): B2 B1
+// CHECK: [B4]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: A() (CXXConstructExpr, class A)
+// CHECK: 3: [B4.2] (BindTemporary)
+// CHECK: 4: [B4.3].operator _Bool
+// CHECK: 5: [B4.4]()
+// CHECK: 6: [B4.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B4.6] && ...
+// CHECK: Preds (2): B6 B7
+// CHECK: Succs (2): B5 B3
+// CHECK: [B5]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B5.1] (BindTemporary)
+// CHECK: 3: [B5.2].operator _Bool
+// CHECK: 4: [B5.3]()
+// CHECK: 5: [B5.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B3
+// CHECK: [B6]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: [B8.5] && [B9.5]
+// CHECK: 2: bool a = A().operator _Bool() && B().operator _Bool();
+// CHECK: T: [B8.5] && ...
+// CHECK: Preds (2): B9 B8
+// CHECK: Succs (2): B6 B4
+// CHECK: [B8]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B8.1] (BindTemporary)
+// CHECK: 3: [B8.2].operator _Bool
+// CHECK: 4: [B8.3]()
+// CHECK: 5: [B8.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B8.5] && ...
+// CHECK: Preds (1): B10
+// CHECK: Succs (2): B9 B7
+// CHECK: [B9]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B9.1] (BindTemporary)
+// CHECK: 3: [B9.2].operator _Bool
+// CHECK: 4: [B9.3]()
+// CHECK: 5: [B9.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B7
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B10 (ENTRY)]
+// CHECK: Succs (1): B8
+// CHECK: [B1]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: int b;
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B3
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: [B4.6] || [B5.5]
+// CHECK: 2: foo
+// CHECK: 3: [B3.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(_Bool))
+// CHECK: 4: [B3.3]([B3.1])
+// CHECK: T: [B4.6] || ...
+// CHECK: Preds (2): B5 B4
+// CHECK: Succs (2): B1 B2
+// CHECK: [B4]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: A() (CXXConstructExpr, class A)
+// CHECK: 3: [B4.2] (BindTemporary)
+// CHECK: 4: [B4.3].operator _Bool
+// CHECK: 5: [B4.4]()
+// CHECK: 6: [B4.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B4.6] || ...
+// CHECK: Preds (2): B6 B7
+// CHECK: Succs (2): B3 B5
+// CHECK: [B5]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B5.1] (BindTemporary)
+// CHECK: 3: [B5.2].operator _Bool
+// CHECK: 4: [B5.3]()
+// CHECK: 5: [B5.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B3
+// CHECK: [B6]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: [B8.5] || [B9.5]
+// CHECK: 2: bool a = A().operator _Bool() || B().operator _Bool();
+// CHECK: T: [B8.5] || ...
+// CHECK: Preds (2): B9 B8
+// CHECK: Succs (2): B4 B6
+// CHECK: [B8]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B8.1] (BindTemporary)
+// CHECK: 3: [B8.2].operator _Bool
+// CHECK: 4: [B8.3]()
+// CHECK: 5: [B8.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B8.5] || ...
+// CHECK: Preds (1): B10
+// CHECK: Succs (2): B7 B9
+// CHECK: [B9]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B9.1] (BindTemporary)
+// CHECK: 3: [B9.2].operator _Bool
+// CHECK: 4: [B9.3]()
+// CHECK: 5: [B9.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B7
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B11 (ENTRY)]
+// CHECK: Succs (1): B10
+// CHECK: [B1]
+// CHECK: 1: int b;
+// CHECK: 2: [B7.5].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: 0
+// CHECK: 2: foo
+// CHECK: 3: [B2.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(int))
+// CHECK: 4: [B2.3]([B2.1])
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: 0
+// CHECK: 2: foo
+// CHECK: 3: [B3.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(int))
+// CHECK: 4: [B3.3]([B3.1])
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: 2: B() (CXXConstructExpr, class B)
+// CHECK: 3: [B4.2] (BindTemporary)
+// CHECK: 4: [B4.3].operator _Bool
+// CHECK: 5: [B4.4]()
+// CHECK: 6: [B4.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: 7: ~B() (Temporary object destructor)
+// CHECK: T: if [B4.6]
+// CHECK: Preds (2): B5 B6
+// CHECK: Succs (2): B3 B2
+// CHECK: [B5]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B6]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: 3: ~A() (Temporary object destructor)
+// CHECK: 4: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: [B10.5] ? [B8.6] : [B9.15]
+// CHECK: 2: [B7.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B7.2]
+// CHECK: 4: [B7.3] (CXXConstructExpr, class A)
+// CHECK: 5: A a = B().operator _Bool() ? A() : A(B().operator A());
+// CHECK: T: [B10.5] ? ... : ...
+// CHECK: Preds (2): B8 B9
+// CHECK: Succs (2): B5 B6
+// CHECK: [B8]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B8.1] (BindTemporary)
+// CHECK: 3: [B8.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B8.3]
+// CHECK: 5: [B8.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B8.5] (BindTemporary)
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B7
+// CHECK: [B9]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B9.1] (BindTemporary)
+// CHECK: 3: [B9.2].operator A
+// CHECK: 4: [B9.3]()
+// CHECK: 5: [B9.4] (ImplicitCastExpr, UserDefinedConversion, class A)
+// CHECK: 6: [B9.5] (BindTemporary)
+// CHECK: 7: [B9.6] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 8: [B9.7]
+// CHECK: 9: [B9.8] (CXXConstructExpr, class A)
+// CHECK: 10: [B9.9] (BindTemporary)
+// CHECK: 11: A([B9.10]) (CXXFunctionalCastExpr, ConstructorConversion, class A)
+// CHECK: 12: [B9.11] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 13: [B9.12]
+// CHECK: 14: [B9.13] (CXXConstructExpr, class A)
+// CHECK: 15: [B9.14] (BindTemporary)
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B7
+// CHECK: [B10]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B10.1] (BindTemporary)
+// CHECK: 3: [B10.2].operator _Bool
+// CHECK: 4: [B10.3]()
+// CHECK: 5: [B10.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B10.5] ? ... : ...
+// CHECK: Preds (1): B11
+// CHECK: Succs (2): B8 B9
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B14 (ENTRY)]
+// CHECK: Succs (1): B13
+// CHECK: [B1]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: 2: int b;
+// CHECK: 3: [B10.4].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: 3: ~A() (Temporary object destructor)
+// CHECK: 4: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: [B7.6] ? [B5.6] : [B6.15]
+// CHECK: 2: [B4.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B4.2]
+// CHECK: 4: foo
+// CHECK: 5: [B4.4] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(const class A &))
+// CHECK: 6: [B4.5]([B4.3])
+// CHECK: T: [B7.6] ? ... : ...
+// CHECK: Preds (2): B5 B6
+// CHECK: Succs (2): B2 B3
+// CHECK: [B5]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B5.1] (BindTemporary)
+// CHECK: 3: [B5.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B5.3]
+// CHECK: 5: [B5.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B5.5] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B6]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B6.1] (BindTemporary)
+// CHECK: 3: [B6.2].operator A
+// CHECK: 4: [B6.3]()
+// CHECK: 5: [B6.4] (ImplicitCastExpr, UserDefinedConversion, class A)
+// CHECK: 6: [B6.5] (BindTemporary)
+// CHECK: 7: [B6.6] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 8: [B6.7]
+// CHECK: 9: [B6.8] (CXXConstructExpr, class A)
+// CHECK: 10: [B6.9] (BindTemporary)
+// CHECK: 11: A([B6.10]) (CXXFunctionalCastExpr, ConstructorConversion, class A)
+// CHECK: 12: [B6.11] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 13: [B6.12]
+// CHECK: 14: [B6.13] (CXXConstructExpr, class A)
+// CHECK: 15: [B6.14] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: 2: B() (CXXConstructExpr, class B)
+// CHECK: 3: [B7.2] (BindTemporary)
+// CHECK: 4: [B7.3].operator _Bool
+// CHECK: 5: [B7.4]()
+// CHECK: 6: [B7.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B7.6] ? ... : ...
+// CHECK: Preds (2): B8 B9
+// CHECK: Succs (2): B5 B6
+// CHECK: [B8]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B7
+// CHECK: [B9]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: 3: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B7
+// CHECK: [B10]
+// CHECK: 1: [B13.5] ? [B11.6] : [B12.15]
+// CHECK: 2: [B10.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B10.2]
+// CHECK: 4: const A &a = B().operator _Bool() ? A() : A(B().operator A());
+// CHECK: T: [B13.5] ? ... : ...
+// CHECK: Preds (2): B11 B12
+// CHECK: Succs (2): B8 B9
+// CHECK: [B11]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B11.1] (BindTemporary)
+// CHECK: 3: [B11.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B11.3]
+// CHECK: 5: [B11.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B11.5] (BindTemporary)
+// CHECK: Preds (1): B13
+// CHECK: Succs (1): B10
+// CHECK: [B12]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B12.1] (BindTemporary)
+// CHECK: 3: [B12.2].operator A
+// CHECK: 4: [B12.3]()
+// CHECK: 5: [B12.4] (ImplicitCastExpr, UserDefinedConversion, class A)
+// CHECK: 6: [B12.5] (BindTemporary)
+// CHECK: 7: [B12.6] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 8: [B12.7]
+// CHECK: 9: [B12.8] (CXXConstructExpr, class A)
+// CHECK: 10: [B12.9] (BindTemporary)
+// CHECK: 11: A([B12.10]) (CXXFunctionalCastExpr, ConstructorConversion, class A)
+// CHECK: 12: [B12.11] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 13: [B12.12]
+// CHECK: 14: [B12.13] (CXXConstructExpr, class A)
+// CHECK: 15: [B12.14] (BindTemporary)
+// CHECK: Preds (1): B13
+// CHECK: Succs (1): B10
+// CHECK: [B13]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B13.1] (BindTemporary)
+// CHECK: 3: [B13.2].operator _Bool
+// CHECK: 4: [B13.3]()
+// CHECK: 5: [B13.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B13.5] ? ... : ...
+// CHECK: Preds (1): B14
+// CHECK: Succs (2): B11 B12
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B8 (ENTRY)]
+// CHECK: Succs (1): B7
+// CHECK: [B1]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: int b;
+// CHECK: 3: [B4.5].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: [B7.2] ?: [B6.6]
+// CHECK: 2: [B4.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B4.2]
+// CHECK: 4: [B4.3] (CXXConstructExpr, class A)
+// CHECK: 5: A a = A() ?: A();
+// CHECK: T: [B7.5] ? ... : ...
+// CHECK: Preds (2): B5 B6
+// CHECK: Succs (2): B2 B3
+// CHECK: [B5]
+// CHECK: 1: [B7.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 2: [B5.1]
+// CHECK: 3: [B5.2] (CXXConstructExpr, class A)
+// CHECK: 4: [B5.3] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B6]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B6.1] (BindTemporary)
+// CHECK: 3: [B6.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B6.3]
+// CHECK: 5: [B6.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B6.5] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B7.1] (BindTemporary)
+// CHECK: 3: [B7.2].operator _Bool
+// CHECK: 4: [B7.3]()
+// CHECK: 5: [B7.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B7.5] ? ... : ...
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B5 B6
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B13 (ENTRY)]
+// CHECK: Succs (1): B12
+// CHECK: [B1]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: int b;
+// CHECK: 3: [B9.4].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: [B7.3] ?: [B6.6]
+// CHECK: 2: [B4.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B4.2]
+// CHECK: 4: foo
+// CHECK: 5: [B4.4] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(const class A &))
+// CHECK: 6: [B4.5]([B4.3])
+// CHECK: T: [B7.6] ? ... : ...
+// CHECK: Preds (2): B5 B6
+// CHECK: Succs (2): B2 B3
+// CHECK: [B5]
+// CHECK: 1: [B7.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 2: [B5.1]
+// CHECK: 3: [B5.2] (CXXConstructExpr, class A)
+// CHECK: 4: [B5.3] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B6]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B6.1] (BindTemporary)
+// CHECK: 3: [B6.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B6.3]
+// CHECK: 5: [B6.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B6.5] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: A() (CXXConstructExpr, class A)
+// CHECK: 3: [B7.2] (BindTemporary)
+// CHECK: 4: [B7.3].operator _Bool
+// CHECK: 5: [B7.4]()
+// CHECK: 6: [B7.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B7.6] ? ... : ...
+// CHECK: Preds (2): B9 B8
+// CHECK: Succs (2): B5 B6
+// CHECK: [B8]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B9
+// CHECK: Succs (1): B7
+// CHECK: [B9]
+// CHECK: 1: [B12.2] ?: [B11.6]
+// CHECK: 2: [B9.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B9.2]
+// CHECK: 4: const A &a = A() ?: A();
+// CHECK: T: [B12.5] ? ... : ...
+// CHECK: Preds (2): B10 B11
+// CHECK: Succs (2): B7 B8
+// CHECK: [B10]
+// CHECK: 1: [B12.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 2: [B10.1]
+// CHECK: 3: [B10.2] (CXXConstructExpr, class A)
+// CHECK: 4: [B10.3] (BindTemporary)
+// CHECK: Preds (1): B12
+// CHECK: Succs (1): B9
+// CHECK: [B11]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B11.1] (BindTemporary)
+// CHECK: 3: [B11.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B11.3]
+// CHECK: 5: [B11.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B11.5] (BindTemporary)
+// CHECK: Preds (1): B12
+// CHECK: Succs (1): B9
+// CHECK: [B12]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B12.1] (BindTemporary)
+// CHECK: 3: [B12.2].operator _Bool
+// CHECK: 4: [B12.3]()
+// CHECK: 5: [B12.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B12.5] ? ... : ...
+// CHECK: Preds (1): B13
+// CHECK: Succs (2): B10 B11
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B1.1] (BindTemporary)
+// CHECK: 3: [B1.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B1.3]
+// CHECK: 5: [B1.4] (CXXConstructExpr, class A)
+// CHECK: 6: A a = A();
+// CHECK: 7: ~A() (Temporary object destructor)
+// CHECK: 8: int b;
+// CHECK: 9: [B1.6].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B1.1] (BindTemporary)
+// CHECK: 3: [B1.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B1.3]
+// CHECK: 5: const A &a = A();
+// CHECK: 6: A() (CXXConstructExpr, class A)
+// CHECK: 7: [B1.6] (BindTemporary)
+// CHECK: 8: [B1.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B1.8]
+// CHECK: 10: foo
+// CHECK: 11: [B1.10] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(const class A &))
+// CHECK: 12: [B1.11]([B1.9])
+// CHECK: 13: ~A() (Temporary object destructor)
+// CHECK: 14: int b;
+// CHECK: 15: [B1.5].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: A::make
+// CHECK: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, class A (*)(void))
+// CHECK: 3: [B1.2]()
+// CHECK: 4: [B1.3] (BindTemporary)
+// CHECK: 5: [B1.4] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 6: [B1.5]
+// CHECK: 7: [B1.6] (CXXConstructExpr, class A)
+// CHECK: 8: A a = A::make();
+// CHECK: 9: ~A() (Temporary object destructor)
+// CHECK: 10: int b;
+// CHECK: 11: [B1.8].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: A::make
+// CHECK: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, class A (*)(void))
+// CHECK: 3: [B1.2]()
+// CHECK: 4: [B1.3] (BindTemporary)
+// CHECK: 5: [B1.4] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 6: [B1.5]
+// CHECK: 7: const A &a = A::make();
+// CHECK: 8: A::make
+// CHECK: 9: [B1.8] (ImplicitCastExpr, FunctionToPointerDecay, class A (*)(void))
+// CHECK: 10: [B1.9]()
+// CHECK: 11: [B1.10] (BindTemporary)
+// CHECK: 12: [B1.11] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 13: [B1.12]
+// CHECK: 14: foo
+// CHECK: 15: [B1.14] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(const class A &))
+// CHECK: 16: [B1.15]([B1.13])
+// CHECK: 17: ~A() (Temporary object destructor)
+// CHECK: 18: int b;
+// CHECK: 19: [B1.7].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: int a;
+// CHECK: 2: A() (CXXConstructExpr, class A)
+// CHECK: 3: [B1.2] (BindTemporary)
+// CHECK: 4: [B1.3].operator int
+// CHECK: 5: [B1.4]()
+// CHECK: 6: [B1.5] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 7: a
+// CHECK: 8: [B1.7] = [B1.6]
+// CHECK: 9: ~A() (Temporary object destructor)
+// CHECK: 10: int b;
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B1.1] (BindTemporary)
+// CHECK: 3: [B1.2].operator int
+// CHECK: 4: [B1.3]()
+// CHECK: 5: [B1.4] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 6: int([B1.5]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 7: B() (CXXConstructExpr, class B)
+// CHECK: 8: [B1.7] (BindTemporary)
+// CHECK: 9: [B1.8].operator int
+// CHECK: 10: [B1.9]()
+// CHECK: 11: [B1.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 12: int([B1.11]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 13: [B1.6] + [B1.12]
+// CHECK: 14: a([B1.13]) (Member initializer)
+// CHECK: 15: ~B() (Temporary object destructor)
+// CHECK: 16: ~A() (Temporary object destructor)
+// CHECK: 17: /*implicit*/int()
+// CHECK: 18: b([B1.17]) (Member initializer)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+
diff --git a/clang/test/Analysis/undef-buffers.c b/clang/test/Analysis/undef-buffers.c
new file mode 100644
index 0000000..cfdd7f4
--- /dev/null
+++ b/clang/test/Analysis/undef-buffers.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.unix,core.uninitialized -analyzer-store=region -verify %s
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+
+char stackBased1 () {
+ char buf[2];
+ buf[0] = 'a';
+ return buf[1]; // expected-warning{{Undefined}}
+}
+
+char stackBased2 () {
+ char buf[2];
+ buf[1] = 'a';
+ return buf[0]; // expected-warning{{Undefined}}
+}
+
+// Exercise the conditional visitor. Radar://10105448
+char stackBased3 (int *x) {
+ char buf[2];
+ int *y;
+ buf[0] = 'a';
+ if (!(y = x)) {
+ return buf[1]; // expected-warning{{Undefined}}
+ }
+ return buf[0];
+}
+
+char heapBased1 () {
+ char *buf = malloc(2);
+ buf[0] = 'a';
+ char result = buf[1]; // expected-warning{{undefined}}
+ free(buf);
+ return result;
+}
+
+char heapBased2 () {
+ char *buf = malloc(2);
+ buf[1] = 'a';
+ char result = buf[0]; // expected-warning{{undefined}}
+ free(buf);
+ return result;
+}
diff --git a/clang/test/Analysis/uninit-msg-expr.m b/clang/test/Analysis/uninit-msg-expr.m
new file mode 100644
index 0000000..19fdf61
--- /dev/null
+++ b/clang/test/Analysis/uninit-msg-expr.m
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify %s
+
+//===----------------------------------------------------------------------===//
+// The following code is reduced using delta-debugging from
+// Foundation.h (Mac OS X).
+//
+// It includes the basic definitions for the test cases below.
+// Not directly including Foundation.h directly makes this test case
+// both svelte and portable to non-Mac platforms.
+//===----------------------------------------------------------------------===//
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@interface NSObject <NSObject> {} @end
+@class NSString, NSData;
+@class NSString, NSData, NSMutableData, NSMutableDictionary, NSMutableArray;
+typedef struct {} NSFastEnumerationState;
+@protocol NSFastEnumeration
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+@class NSData, NSIndexSet, NSString, NSURL;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+- (NSUInteger)count;
+@end
+@interface NSArray (NSArrayCreation)
++ (id)array;
+- (NSUInteger)length;
+- (void)addObject:(id)object;
+@end
+extern NSString * const NSUndoManagerCheckpointNotification;
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+unsigned f1() {
+ NSString *aString;
+ return [aString length]; // expected-warning {{Receiver in message expression is an uninitialized value}}
+}
+
+unsigned f2() {
+ NSString *aString = 0;
+ return [aString length]; // no-warning
+}
+
+void f3() {
+ NSMutableArray *aArray = [NSArray array];
+ NSString *aString;
+ [aArray addObject:aString]; // expected-warning {{Argument in message expression is an uninitialized value}}
+}
diff --git a/clang/test/Analysis/uninit-ps-rdar6145427.m b/clang/test/Analysis/uninit-ps-rdar6145427.m
new file mode 100644
index 0000000..c18116f
--- /dev/null
+++ b/clang/test/Analysis/uninit-ps-rdar6145427.m
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify -analyzer-store=region %s
+
+// Delta-Debugging reduced preamble.
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@interface NSObject <NSObject> {}
++ (id)alloc;
+- (id)init;
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value; @end
+@class NSString, NSData;
+typedef struct _NSPoint {} NSRange;
+@interface NSValue (NSValueRangeExtensions)
++ (NSValue *)valueWithRange:(NSRange)range;
+- (id)objectAtIndex:(NSUInteger)index;
+@end
+@interface NSAutoreleasePool : NSObject {} - (void)drain; @end
+extern NSString * const NSBundleDidLoadNotification;
+typedef struct {} NSDecimal;
+@interface NSNetService : NSObject {} - (id)init; @end
+extern NSString * const NSUndoManagerCheckpointNotification;
+
+// Test case: <rdar://problem/6145427>
+
+int main (int argc, const char * argv[]) {
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ id someUnintializedPointer = [someUnintializedPointer objectAtIndex:0]; // expected-warning{{Receiver in message expression is an uninitialized value}}
+ NSLog(@"%@", someUnintializedPointer);
+ [pool drain];
+ return 0;
+}
diff --git a/clang/test/Analysis/uninit-vals-ps-region.m b/clang/test/Analysis/uninit-vals-ps-region.m
new file mode 100644
index 0000000..d613c71
--- /dev/null
+++ b/clang/test/Analysis/uninit-vals-ps-region.m
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-checker=core,experimental.deadcode.IdempotentOperations -verify %s
+
+struct s {
+ int data;
+};
+
+struct s global;
+
+void g(int);
+
+void f4() {
+ int a;
+ if (global.data == 0)
+ a = 3;
+ if (global.data == 0) // When the true branch is feasible 'a = 3'.
+ g(a); // no-warning
+}
+
+
+// Test uninitialized value due to part of the structure being uninitialized.
+struct TestUninit { int x; int y; };
+struct TestUninit test_uninit_aux();
+void test_unit_aux2(int);
+void test_uninit_pos() {
+ struct TestUninit v1 = { 0, 0 };
+ struct TestUninit v2 = test_uninit_aux();
+ int z;
+ v1.y = z; // expected-warning{{Assigned value is garbage or undefined}}
+ test_unit_aux2(v2.x + v1.y);
+}
+void test_uninit_pos_2() {
+ struct TestUninit v1 = { 0, 0 };
+ struct TestUninit v2;
+ test_unit_aux2(v2.x + v1.y); // expected-warning{{The left operand of '+' is a garbage value}}
+}
+void test_uninit_pos_3() {
+ struct TestUninit v1 = { 0, 0 };
+ struct TestUninit v2;
+ test_unit_aux2(v1.y + v2.x); // expected-warning{{The right operand of '+' is a garbage value}}
+}
+
+void test_uninit_neg() {
+ struct TestUninit v1 = { 0, 0 };
+ struct TestUninit v2 = test_uninit_aux();
+ test_unit_aux2(v2.x + v1.y); // expected-warning{{The right operand to '+' is always 0}}
+}
+
+extern void test_uninit_struct_arg_aux(struct TestUninit arg);
+void test_uninit_struct_arg() {
+ struct TestUninit x;
+ test_uninit_struct_arg_aux(x); // expected-warning{{Passed-by-value struct argument contains uninitialized data (e.g., field: 'x')}}
+}
+
+@interface Foo
+- (void) passVal:(struct TestUninit)arg;
+@end
+void testFoo(Foo *o) {
+ struct TestUninit x;
+ [o passVal:x]; // expected-warning{{Passed-by-value struct argument contains uninitialized data (e.g., field: 'x')}}
+}
+
+// Test case from <rdar://problem/7780304>. That shows an uninitialized value
+// being used in the LHS of a compound assignment.
+void rdar_7780304() {
+ typedef struct s_r7780304 { int x; } s_r7780304;
+ s_r7780304 b;
+ b.x |= 1; // expected-warning{{The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage}}
+}
+
+
+// The flip side of PR10163 -- float arrays that are actually uninitialized
+// (The main test is in uninit-vals.m)
+void test_PR10163(float);
+void PR10163 (void) {
+ float x[2];
+ test_PR10163(x[1]); // expected-warning{{uninitialized value}}
+}
+
diff --git a/clang/test/Analysis/uninit-vals-ps.c b/clang/test/Analysis/uninit-vals-ps.c
new file mode 100644
index 0000000..f301157
--- /dev/null
+++ b/clang/test/Analysis/uninit-vals-ps.c
@@ -0,0 +1,124 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify %s
+
+struct FPRec {
+ void (*my_func)(int * x);
+};
+
+int bar(int x);
+
+int f1_a(struct FPRec* foo) {
+ int x;
+ (*foo->my_func)(&x);
+ return bar(x)+1; // no-warning
+}
+
+int f1_b() {
+ int x;
+ return bar(x)+1; // expected-warning{{Function call argument is an uninitialized value}}
+}
+
+int f2() {
+
+ int x;
+
+ if (x+1) // expected-warning{{The left operand of '+' is a garbage value}}
+ return 1;
+
+ return 2;
+}
+
+int f2_b() {
+ int x;
+
+ return ((1+x)+2+((x))) + 1 ? 1 : 2; // expected-warning{{The right operand of '+' is a garbage value}}
+}
+
+int f3(void) {
+ int i;
+ int *p = &i;
+ if (*p > 0) // expected-warning{{The left operand of '>' is a garbage value}}
+ return 0;
+ else
+ return 1;
+}
+
+void f4_aux(float* x);
+float f4(void) {
+ float x;
+ f4_aux(&x);
+ return x; // no-warning
+}
+
+struct f5_struct { int x; };
+void f5_aux(struct f5_struct* s);
+int f5(void) {
+ struct f5_struct s;
+ f5_aux(&s);
+ return s.x; // no-warning
+}
+
+int ret_uninit() {
+ int i;
+ int *p = &i;
+ return *p; // expected-warning{{Undefined or garbage value returned to caller}}
+}
+
+// <rdar://problem/6451816>
+typedef unsigned char Boolean;
+typedef const struct __CFNumber * CFNumberRef;
+typedef signed long CFIndex;
+typedef CFIndex CFNumberType;
+typedef unsigned long UInt32;
+typedef UInt32 CFStringEncoding;
+typedef const struct __CFString * CFStringRef;
+extern Boolean CFNumberGetValue(CFNumberRef number, CFNumberType theType, void *valuePtr);
+extern CFStringRef CFStringConvertEncodingToIANACharSetName(CFStringEncoding encoding);
+
+CFStringRef rdar_6451816(CFNumberRef nr) {
+ CFStringEncoding encoding;
+ // &encoding is casted to void*. This test case tests whether or not
+ // we properly invalidate the value of 'encoding'.
+ CFNumberGetValue(nr, 9, &encoding);
+ return CFStringConvertEncodingToIANACharSetName(encoding); // no-warning
+}
+
+// PR 4630 - false warning with nonnull attribute
+// This false positive (due to a regression) caused the analyzer to falsely
+// flag a "return of uninitialized value" warning in the first branch due to
+// the nonnull attribute.
+void pr_4630_aux(char *x, int *y) __attribute__ ((nonnull (1)));
+void pr_4630_aux_2(char *x, int *y);
+int pr_4630(char *a, int y) {
+ int x;
+ if (y) {
+ pr_4630_aux(a, &x);
+ return x; // no-warning
+ }
+ else {
+ pr_4630_aux_2(a, &x);
+ return x; // no-warning
+ }
+}
+
+// PR 4631 - False positive with union initializer
+// Previously the analyzer didn't examine the compound initializers of unions,
+// resulting in some false positives for initializers with side-effects.
+union u_4631 { int a; };
+struct s_4631 { int a; };
+int pr4631_f2(int *p);
+int pr4631_f3(void *q);
+int pr4631_f1(void)
+{
+ int x;
+ union u_4631 m = { pr4631_f2(&x) };
+ pr4631_f3(&m); // tell analyzer that we use m
+ return x; // no-warning
+}
+int pr4631_f1_b(void)
+{
+ int x;
+ struct s_4631 m = { pr4631_f2(&x) };
+ pr4631_f3(&m); // tell analyzer that we use m
+ return x; // no-warning
+}
+
diff --git a/clang/test/Analysis/uninit-vals.m b/clang/test/Analysis/uninit-vals.m
new file mode 100644
index 0000000..4ba26f5
--- /dev/null
+++ b/clang/test/Analysis/uninit-vals.m
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify %s
+
+typedef unsigned int NSUInteger;
+
+@interface A
+- (NSUInteger)foo;
+@end
+
+NSUInteger f8(A* x){
+ const NSUInteger n = [x foo];
+ int* bogus;
+
+ if (n > 0) { // tests const cast transfer function logic
+ NSUInteger i;
+
+ for (i = 0; i < n; ++i)
+ bogus = 0;
+
+ if (bogus) // no-warning
+ return n+1;
+ }
+
+ return n;
+}
+
+
+// PR10163 -- don't warn for default-initialized float arrays.
+// (An additional test is in uninit-vals-ps-region.m)
+void test_PR10163(float);
+void PR10163 (void) {
+ float x[2] = {0};
+ test_PR10163(x[1]); // no-warning
+}
diff --git a/clang/test/Analysis/unions-region.m b/clang/test/Analysis/unions-region.m
new file mode 100644
index 0000000..1a71684
--- /dev/null
+++ b/clang/test/Analysis/unions-region.m
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-constraints=range %s -verify
+
+//===-- unions-region.m ---------------------------------------------------===//
+//
+// This file tests the analyzer's reasoning about unions.
+//
+//===----------------------------------------------------------------------===//
+
+// [testA] When using RegionStore, this test case previously had a
+// false positive of a 'pass-by-value argument is uninitialized'
+// warning at the call to 'testA_aux' and 'testA_aux_2'.
+union u_testA {
+ unsigned i;
+ float f;
+};
+
+float testA(float f) {
+ int testA_aux(unsigned x);
+ int testA_aux_2(union u_testA z);
+
+ union u_testA swap;
+ swap.f = f;
+
+ if (testA_aux(swap.i)) // no-warning
+ swap.i = ((swap.i & 0xffff0000) >> 16) | ((swap.i & 0x0000fffff) << 16);
+
+ testA_aux_2(swap); // no-warning
+
+ return swap.f;
+}
+
+// [testB] When using RegionStore, this test case previously had a
+// false positive of a 'pass-by-value argument is uninitialized'
+// warning at the call to 'testB_aux'.
+void testB(int i) {
+ void testB_aux(short z);
+ union { short x[2]; unsigned y; } val;
+ val.y = 10;
+ testB_aux(val.x[1]); // no-warning
+}
+
diff --git a/clang/test/Analysis/unix-fns.c b/clang/test/Analysis/unix-fns.c
new file mode 100644
index 0000000..ec62098
--- /dev/null
+++ b/clang/test/Analysis/unix-fns.c
@@ -0,0 +1,138 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=unix.API,osx.API %s -analyzer-store=region -fblocks -verify
+
+struct _opaque_pthread_once_t {
+ long __sig;
+ char __opaque[8];
+};
+typedef struct _opaque_pthread_once_t __darwin_pthread_once_t;
+typedef __darwin_pthread_once_t pthread_once_t;
+int pthread_once(pthread_once_t *, void (*)(void));
+typedef long unsigned int __darwin_size_t;
+typedef __darwin_size_t size_t;
+void *calloc(size_t, size_t);
+void *malloc(size_t);
+void *realloc(void *, size_t);
+void *alloca(size_t);
+void *valloc(size_t);
+
+typedef void (^dispatch_block_t)(void);
+typedef long dispatch_once_t;
+void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);
+
+#ifndef O_CREAT
+#define O_CREAT 0x0200
+#define O_RDONLY 0x0000
+#endif
+int open(const char *, int, ...);
+int close(int fildes);
+
+void test_open(const char *path) {
+ int fd;
+ fd = open(path, O_RDONLY); // no-warning
+ if (!fd)
+ close(fd);
+
+ fd = open(path, O_CREAT); // expected-warning{{Call to 'open' requires a third argument when the 'O_CREAT' flag is set}}
+ if (!fd)
+ close(fd);
+}
+
+void test_dispatch_once() {
+ dispatch_once_t pred = 0;
+ do { if (__builtin_expect(*(&pred), ~0l) != ~0l) dispatch_once((&pred), (^() {})); } while (0); // expected-warning{{Call to 'dispatch_once' uses the local variable 'pred' for the predicate value}}
+}
+void test_dispatch_once_neg() {
+ static dispatch_once_t pred = 0;
+ do { if (__builtin_expect(*(&pred), ~0l) != ~0l) dispatch_once((&pred), (^() {})); } while (0); // no-warning
+}
+
+void test_pthread_once_aux();
+
+void test_pthread_once() {
+ pthread_once_t pred = {0x30B1BCBA, {0}};
+ pthread_once(&pred, test_pthread_once_aux); // expected-warning{{Call to 'pthread_once' uses the local variable 'pred' for the "control" value}}
+}
+void test_pthread_once_neg() {
+ static pthread_once_t pred = {0x30B1BCBA, {0}};
+ pthread_once(&pred, test_pthread_once_aux); // no-warning
+}
+
+// PR 2899 - warn of zero-sized allocations to malloc().
+void pr2899() {
+ char* foo = malloc(0); // expected-warning{{Call to 'malloc' has an allocation size of 0 bytes}}
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void pr2899_nowarn(size_t size) {
+ char* foo = malloc(size); // no-warning
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_calloc(void) {
+ char *foo = calloc(0, 42); // expected-warning{{Call to 'calloc' has an allocation size of 0 bytes}}
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_calloc2(void) {
+ char *foo = calloc(42, 0); // expected-warning{{Call to 'calloc' has an allocation size of 0 bytes}}
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_calloc_nowarn(size_t nmemb, size_t size) {
+ char *foo = calloc(nmemb, size); // no-warning
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_realloc(char *ptr) {
+ char *foo = realloc(ptr, 0); // expected-warning{{Call to 'realloc' has an allocation size of 0 bytes}}
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_realloc_nowarn(char *ptr, size_t size) {
+ char *foo = realloc(ptr, size); // no-warning
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_alloca() {
+ char *foo = alloca(0); // expected-warning{{Call to 'alloca' has an allocation size of 0 bytes}}
+ for(unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_alloca_nowarn(size_t sz) {
+ char *foo = alloca(sz); // no-warning
+ for(unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_builtin_alloca() {
+ char *foo2 = __builtin_alloca(0); // expected-warning{{Call to 'alloca' has an allocation size of 0 bytes}}
+ for(unsigned i = 0; i < 100; i++) {
+ foo2[i] = 0;
+ }
+}
+void test_builtin_alloca_nowarn(size_t sz) {
+ char *foo2 = __builtin_alloca(sz); // no-warning
+ for(unsigned i = 0; i < 100; i++) {
+ foo2[i] = 0;
+ }
+}
+void test_valloc() {
+ char *foo = valloc(0); // expected-warning{{Call to 'valloc' has an allocation size of 0 bytes}}
+ for(unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_valloc_nowarn(size_t sz) {
+ char *foo = valloc(sz); // no-warning
+ for(unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
diff --git a/clang/test/Analysis/unreachable-code-path.c b/clang/test/Analysis/unreachable-code-path.c
new file mode 100644
index 0000000..48a3462
--- /dev/null
+++ b/clang/test/Analysis/unreachable-code-path.c
@@ -0,0 +1,141 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,deadcode.DeadStores,experimental.deadcode.UnreachableCode -verify -analyzer-opt-analyze-nested-blocks -Wno-unused-value %s
+
+extern void foo(int a);
+
+// The first few tests are non-path specific - we should be able to find them
+
+void test(unsigned a) {
+ switch (a) {
+ a += 5; // expected-warning{{never executed}}
+ case 2:
+ a *= 10;
+ case 3:
+ a %= 2;
+ }
+ foo(a);
+}
+
+void test2(unsigned a) {
+ help:
+ if (a > 0)
+ return;
+ if (a == 0)
+ return;
+ foo(a); // expected-warning{{never executed}}
+ goto help;
+}
+
+void test3(unsigned a) {
+ while(1);
+ if (a > 5) { // expected-warning{{never executed}}
+ return;
+ }
+}
+
+// These next tests are path-sensitive
+
+void test4() {
+ int a = 5;
+
+ while (a > 1)
+ a -= 2;
+
+ if (a > 1) {
+ a = a + 56; // expected-warning{{never executed}}
+ }
+
+ foo(a);
+}
+
+extern void bar(char c);
+
+void test5(const char *c) {
+ foo(c[0]);
+
+ if (!c) {
+ bar(1); // expected-warning{{never executed}}
+ }
+}
+
+// These next tests are false positives and should not generate warnings
+
+void test6(const char *c) {
+ if (c) return;
+ if (!c) return;
+ __builtin_unreachable(); // no-warning
+}
+
+// Compile-time constant false positives
+#define CONSTANT 0
+enum test_enum { Off, On };
+void test7() {
+ if (CONSTANT)
+ return; // no-warning
+
+ if (sizeof(int))
+ return; // no-warning
+
+ if (Off)
+ return; // no-warning
+}
+
+void test8() {
+ static unsigned a = 0;
+
+ if (a)
+ a = 123; // no-warning
+
+ a = 5;
+}
+
+// Check for bugs where multiple statements are reported
+void test9(unsigned a) {
+ switch (a) {
+ if (a) // expected-warning{{never executed}}
+ foo(a + 5); // no-warning
+ else // no-warning
+ foo(a); // no-warning
+ case 1:
+ case 2:
+ break;
+ default:
+ break;
+ }
+}
+
+// Tests from flow-sensitive version
+void test10() {
+ goto c;
+ d:
+ goto e; // expected-warning {{never executed}}
+ c: ;
+ int i;
+ return;
+ goto b; // expected-warning {{never executed}}
+ goto a; // expected-warning {{never executed}}
+ b:
+ i = 1; // no-warning
+ a:
+ i = 2; // no-warning
+ goto f;
+ e:
+ goto d;
+ f: ;
+}
+
+// test11: we can actually end up in the default case, even if it is not
+// obvious: there might be something wrong with the given argument.
+enum foobar { FOO, BAR };
+extern void error();
+void test11(enum foobar fb) {
+ switch (fb) {
+ case FOO:
+ break;
+ case BAR:
+ break;
+ default:
+ error(); // no-warning
+ return;
+ error(); // expected-warning {{never executed}}
+ }
+}
diff --git a/clang/test/Analysis/unused-ivars.m b/clang/test/Analysis/unused-ivars.m
new file mode 100644
index 0000000..8941840
--- /dev/null
+++ b/clang/test/Analysis/unused-ivars.m
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=osx.cocoa.UnusedIvars -verify -Wno-objc-root-class %s
+
+//===--- BEGIN: Delta-debugging reduced headers. --------------------------===//
+
+@protocol NSObject
+- (id)retain;
+- (oneway void)release;
+@end
+@interface NSObject <NSObject> {}
+- (id)init;
++ (id)alloc;
+@end
+
+//===--- END: Delta-debugging reduced headers. ----------------------------===//
+
+// This test case tests the basic functionality of the unused ivar test.
+@interface TestA {
+@private
+ int x; // expected-warning {{Instance variable 'x' in class 'TestA' is never used}}
+}
+@end
+@implementation TestA @end
+
+// This test case tests whether the unused ivar check handles blocks that
+// reference an instance variable. (<rdar://problem/7075531>)
+@interface TestB : NSObject {
+@private
+ id _ivar; // no-warning
+}
+@property (readwrite,retain) id ivar;
+@end
+
+@implementation TestB
+- (id)ivar {
+ __attribute__((__blocks__(byref))) id value = ((void*)0);
+ void (^b)() = ^{ value = _ivar; };
+ b();
+ return value;
+}
+
+- (void)setIvar:(id)newValue {
+ void (^b)() = ^{ [_ivar release]; _ivar = [newValue retain]; };
+ b();
+}
+@end
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/6260004> Detect that ivar is in use, if used in category
+// in the same file as the implementation
+//===----------------------------------------------------------------------===//
+
+@protocol Protocol6260004
+- (id) getId;
+@end
+
+@interface RDar6260004 {
+@private
+ id x; // no-warning
+}
+@end
+@implementation RDar6260004 @end
+@implementation RDar6260004 (Protocol6260004)
+- (id) getId {
+ return x;
+}
+@end
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7254495> - ivars referenced by lexically nested functions
+// should not be flagged as unused
+//===----------------------------------------------------------------------===//
+
+@interface RDar7254495 {
+@private
+ int x; // no-warning
+}
+@end
+
+@implementation RDar7254495
+int radar_7254495(RDar7254495 *a) {
+ return a->x;
+}
+@end
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7353683> - consult attribute((unused)) to silence warnings
+// about unused instance variables
+//===----------------------------------------------------------------------===//
+
+@interface RDar7353683 {
+@private
+ id x __attribute__((unused));
+}
+@end
+
+@implementation RDar7353683
+@end
+//===----------------------------------------------------------------------===//
+// <rdar://problem/8481311> Unused bitfield ivars trigger cause weird
+// diagnostic: "Instance variable '' in class..."
+//===----------------------------------------------------------------------===//
+
+@interface RDar8481311 {
+@private
+ unsigned bitfield:1; // expected-warning {{Instance variable 'bitfield' in class 'RDar8481311' is never used}}
+}
+@end
+
+@implementation RDar8481311
+@end
diff --git a/clang/test/Analysis/variadic-method-types.m b/clang/test/Analysis/variadic-method-types.m
new file mode 100644
index 0000000..4d0f6bc
--- /dev/null
+++ b/clang/test/Analysis/variadic-method-types.m
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.VariadicMethodTypes -analyzer-store=region -fblocks -verify %s
+
+//===----------------------------------------------------------------------===//
+// The following code is reduced using delta-debugging from
+// Foundation.h (Mac OS X).
+//
+// It includes the basic definitions for the test cases below.
+// Not directly including Foundation.h directly makes this test case
+// both svelte and portable to non-Mac platforms.
+//===----------------------------------------------------------------------===//
+
+#define nil (void*)0
+typedef const struct __CFString * CFStringRef;
+extern const CFStringRef kCGImageSourceShouldCache __attribute__((visibility("default")));
+typedef signed char BOOL;
+typedef struct _NSZone NSZone;
+typedef unsigned int NSUInteger;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (oneway void)release;
+- (id)retain;
+- (id)autorelease;
+@end
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+@protocol NSMutableCopying
+- (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+@class NSCoder;
+@protocol NSCoding
+- (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
+- (id)init;
++ (id)alloc;
+@end
+typedef struct {} NSFastEnumerationState;
+@protocol NSFastEnumeration
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+@end
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+@end
+@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+@end
+@interface NSDictionary (NSDictionaryCreation)
++ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ... __attribute__((sentinel(0,1)));
+- (id)initWithObjectsAndKeys:(id)firstObject, ... __attribute__((sentinel(0,1)));
+@end
+@interface NSSet : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+@end
+@interface NSSet (NSSetCreation)
++ (id)setWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+@end
+@interface NSOrderedSet : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+@end
+@interface NSOrderedSet (NSOrderedSetCreation)
++ (id)orderedSetWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+@end
+@protocol P;
+@class C;
+
+typedef struct FooType * __attribute__ ((NSObject)) FooType;
+typedef struct BarType * BarType;
+
+
+void f(id a, id<P> b, C* c, C<P> *d, FooType fooType, BarType barType) {
+ [NSArray arrayWithObjects:@"Hello", a, b, c, d, nil];
+ [NSArray arrayWithObjects:@"Foo", ^{}, nil];
+
+ [NSArray arrayWithObjects:@"Foo", "Bar", "Baz", nil]; // expected-warning 2 {{Argument to 'NSArray' method 'arrayWithObjects:' should be an Objective-C pointer type, not 'char *'}}
+ [NSDictionary dictionaryWithObjectsAndKeys:@"Foo", "Bar", nil]; // expected-warning {{Argument to 'NSDictionary' method 'dictionaryWithObjectsAndKeys:' should be an Objective-C pointer type, not 'char *'}}
+ [NSSet setWithObjects:@"Foo", "Bar", nil]; // expected-warning {{Argument to 'NSSet' method 'setWithObjects:' should be an Objective-C pointer type, not 'char *'}}
+ [NSOrderedSet orderedSetWithObjects:@"Foo", "Bar", nil]; // expected-warning {{Argument to 'NSOrderedSet' method 'orderedSetWithObjects:' should be an Objective-C pointer type, not 'char *'}}
+
+ [[[NSArray alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSArray' method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
+ [[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSDictionary' method 'initWithObjectsAndKeys:' should be an Objective-C pointer type, not 'char *'}}
+ [[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", (void*) 0, nil] autorelease]; // no-warning
+ [[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", kCGImageSourceShouldCache, nil] autorelease]; // no-warning
+ [[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", fooType, nil] autorelease]; // no-warning
+ [[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", barType, nil] autorelease]; // expected-warning {{Argument to 'NSDictionary' method 'initWithObjectsAndKeys:' should be an Objective-C pointer type, not 'BarType'}}
+ [[[NSSet alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSSet' method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
+ [[[NSOrderedSet alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSOrderedSet' method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
+}
+
+// This previously crashed the variadic argument checker.
+@protocol RDar9273215
+- (void)rdar9273215:(id)x, ...;
+@end
+
+void test_rdar9273215(id<RDar9273215> y) {
+ return [y rdar9273215:y, y];
+}
+
diff --git a/clang/test/Analysis/virtualcall.cpp b/clang/test/Analysis/virtualcall.cpp
new file mode 100644
index 0000000..127d04f
--- /dev/null
+++ b/clang/test/Analysis/virtualcall.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.cplusplus.VirtualCall -analyzer-store region -verify %s
+
+class A {
+public:
+ A();
+ ~A() {};
+
+ virtual int foo() = 0;
+ virtual void bar() = 0;
+ void f() {
+ foo(); // expected-warning{{Call pure virtual functions during construction or destruction may leads undefined behaviour}}
+ }
+};
+
+class B : public A {
+public:
+ B() {
+ foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+ }
+ ~B();
+
+ virtual int foo();
+ virtual void bar() { foo(); } // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+};
+
+A::A() {
+ f();
+}
+
+B::~B() {
+ this->B::foo(); // no-warning
+ this->B::bar();
+ this->foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+}
+
+class C : public B {
+public:
+ C();
+ ~C();
+
+ virtual int foo();
+ void f(int i);
+};
+
+C::C() {
+ f(foo()); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+}
+
+int main() {
+ A *a;
+ B *b;
+ C *c;
+}
diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
new file mode 100644
index 0000000..ae9de78
--- /dev/null
+++ b/clang/test/CMakeLists.txt
@@ -0,0 +1,117 @@
+set(CLANG_TEST_DIRECTORIES
+ "Analysis"
+ "CodeCompletion"
+ "CodeGen"
+ "CodeGenCUDA"
+ "CodeGenCXX"
+ "CodeGenObjC"
+ "CodeGenOpenCL"
+ "Coverage"
+ "CXX"
+ "Driver"
+ "FixIt"
+ "Frontend"
+ "Headers"
+ "Index"
+ "Lexer"
+ "Misc"
+ "PCH"
+ "Parser"
+ "Preprocessor"
+ "Rewriter"
+ "Sema"
+ "SemaCUDA"
+ "SemaCXX"
+ "SemaObjC"
+ "SemaObjCXX"
+ "SemaOpenCL"
+ "SemaTemplate")
+
+set(LLVM_SOURCE_DIR "${LLVM_MAIN_SRC_DIR}")
+set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}")
+set(LLVM_BUILD_MODE "%(build_mode)s")
+set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s")
+set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib/%(build_config)s")
+set(CLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
+set(CLANG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..")
+if(BUILD_SHARED_LIBS)
+ set(ENABLE_SHARED 1)
+else()
+ set(ENABLE_SHARED 0)
+endif(BUILD_SHARED_LIBS)
+
+configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+ ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
+
+configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
+ ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
+ @ONLY)
+
+include(FindPythonInterp)
+if(PYTHONINTERP_FOUND)
+ if( LLVM_MAIN_SRC_DIR )
+ set(LIT "${LLVM_SOURCE_DIR}/utils/lit/lit.py")
+ else()
+ set(LIT "${PATH_TO_LLVM_BUILD}/bin/${CMAKE_CFG_INTDIR}/llvm-lit")
+ # Installed LLVM does not contain ${CMAKE_CFG_INTDIR} in paths.
+ if( NOT EXISTS ${LIT} )
+ set(LIT "${PATH_TO_LLVM_BUILD}/bin/llvm-lit")
+ endif()
+ endif()
+
+ if( PATH_TO_LLVM_BUILD )
+ set(CLANG_TEST_EXTRA_ARGS "--path=${CLANG_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}")
+ endif()
+
+ option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF)
+ if(CLANG_TEST_USE_VG)
+ set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg")
+ endif ()
+
+ set(LIT_ARGS "${CLANG_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}")
+ separate_arguments(LIT_ARGS)
+
+ add_custom_target(clang-test.deps)
+ set_target_properties(clang-test.deps PROPERTIES FOLDER "Clang tests")
+
+ add_custom_target(clang-test
+ COMMAND ${PYTHON_EXECUTABLE}
+ ${LIT}
+ --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+ --param clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
+ --param build_config=${CMAKE_CFG_INTDIR}
+ --param build_mode=${RUNTIME_BUILD_MODE}
+ ${LIT_ARGS}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ COMMENT "Running Clang regression tests")
+
+ if( NOT CLANG_BUILT_STANDALONE )
+ add_custom_target(check-all
+ COMMAND ${PYTHON_EXECUTABLE}
+ ${LIT}
+ --param build_config=${CMAKE_CFG_INTDIR}
+ --param build_mode=${RUNTIME_BUILD_MODE}
+ ${LIT_ARGS}
+ ${LLVM_BINARY_DIR}/test
+ ${CMAKE_CURRENT_BINARY_DIR}
+ COMMENT "Running Clang and LLVM regression tests")
+ add_dependencies(check-all clang-test.deps)
+ if ( LLVM_INCLUDE_TESTS )
+ add_dependencies(clang-test.deps ClangUnitTests)
+ add_dependencies(check-all check.deps)
+ endif ( LLVM_INCLUDE_TESTS )
+ add_dependencies(clang-test.deps
+ llvm-dis llc opt
+ FileCheck count not
+ )
+ endif()
+
+ add_dependencies(clang-test clang-test.deps)
+ add_dependencies(clang-test.deps
+ clang clang-headers c-index-test diagtool arcmt-test c-arcmt-test
+ clang-check
+ )
+
+endif()
diff --git a/clang/test/CXX/basic/basic.def.odr/p1-var.cpp b/clang/test/CXX/basic/basic.def.odr/p1-var.cpp
new file mode 100644
index 0000000..892f546
--- /dev/null
+++ b/clang/test/CXX/basic/basic.def.odr/p1-var.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++ [basic.def.odr]p1:
+// No translation unit shall contain more than one definition of any
+// variable, [...].
+
+// Bad: in C++, these are both definitions. None of that C99 tentative stuff.
+int i; // expected-note {{previous}}
+int i; // expected-error {{redefinition}}
+
+// OK: decl + def
+extern int j;
+int j;
+
+// OK: def + decl
+int k;
+extern int k;
+
+// Bad. The important thing here is that we don't emit the diagnostic twice.
+int l = 1; // expected-note {{previous}}
+int l = 2; // expected-error {{redefinition}}
diff --git a/clang/test/CXX/basic/basic.def.odr/p2-typeid.cpp b/clang/test/CXX/basic/basic.def.odr/p2-typeid.cpp
new file mode 100644
index 0000000..55debe3
--- /dev/null
+++ b/clang/test/CXX/basic/basic.def.odr/p2-typeid.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++ [basic.def.odr]p2:
+// An expression is potentially evaluated unless it [...] is the
+// operand of the typeid operator and the expression does not
+// designate an lvalue of polymorphic class type.
+
+// FIXME: This should really include <typeinfo>, but we don't have that yet.
+namespace std {
+ class type_info;
+}
+
+struct Poly {
+ virtual ~Poly();
+};
+
+struct NonPoly { };
+
+template<typename T, typename Result = T>
+struct X {
+ Result f(T t) { return t + t; } // expected-error{{invalid operands}}
+
+ void g(T t) {
+ (void)typeid(f(t)); // expected-note{{here}}
+ }
+};
+
+void test(X<Poly> xp, X<Poly, Poly&> xpr, X<NonPoly> xnp, X<NonPoly, NonPoly&> xnpr) {
+ // These are okay (although GCC and EDG get them wrong).
+ xp.g(Poly());
+ xnp.g(NonPoly());
+ xnpr.g(NonPoly());
+
+ // Triggers an error (as it should);
+ xpr.g(Poly()); // expected-note{{instantiation of member function}}
+}
diff --git a/clang/test/CXX/basic/basic.link/p9.cpp b/clang/test/CXX/basic/basic.link/p9.cpp
new file mode 100644
index 0000000..680c93d
--- /dev/null
+++ b/clang/test/CXX/basic/basic.link/p9.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// FIXME: This test is woefully incomplete.
+namespace N { } // expected-note{{here}}
+
+// First bullet: two names with external linkage that refer to
+// different kinds of entities.
+void f() {
+ int N(); // expected-error{{redefinition}} expected-warning{{interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp
new file mode 100644
index 0000000..f650ad5
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace N1 {
+ struct X { };
+ int& f(void*);
+}
+
+namespace N2 {
+ template<typename T> struct Y { };
+}
+
+namespace N3 {
+ void test() {
+ int &ir = f((N2::Y<N1::X>*)0);
+ }
+}
+
+int g(void *);
+long g(N1::X);
+
+namespace N1 {
+ void h(int (*)(void *));
+}
+
+void test() {
+ h((&g));
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp
new file mode 100644
index 0000000..f5ad68b
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace N {
+ struct X { };
+
+ X operator+(X, X);
+
+ void f(X);
+ void g(X); // expected-note{{candidate function}}
+
+ void test_multiadd(X x) {
+ (void)(x + x);
+ }
+}
+
+namespace M {
+ struct Y : N::X { };
+}
+
+void f(); // expected-note 2 {{'f' declared here}}
+
+void test_operator_adl(N::X x, M::Y y) {
+ (void)(x + x);
+ (void)(y + y);
+}
+
+void test_func_adl(N::X x, M::Y y) {
+ f(x);
+ f(y);
+ (f)(x); // expected-error{{too many arguments to function call}}
+ ::f(x); // expected-error{{too many arguments to function call}}
+}
+
+namespace N {
+ void test_multiadd2(X x) {
+ (void)(x + x);
+ }
+}
+
+
+void test_func_adl_only(N::X x) {
+ g(x);
+}
+
+namespace M {
+ int g(N::X); // expected-note{{candidate function}}
+
+ void test(N::X x) {
+ g(x); // expected-error{{call to 'g' is ambiguous}}
+ int i = (g)(x);
+
+ int g(N::X);
+ g(x); // okay; calls locally-declared function, no ADL
+ }
+}
+
+
+void test_operator_name_adl(N::X x) {
+ (void)operator+(x, x);
+}
+
+struct Z { };
+int& f(Z);
+
+namespace O {
+ char &f();
+ void test_global_scope_adl(Z z) {
+ {
+ int& ir = f(z);
+ }
+ }
+}
+
+extern "C" {
+ struct L { };
+}
+
+void h(L); // expected-note{{candidate function}}
+
+namespace P {
+ void h(L); // expected-note{{candidate function}}
+ void test_transparent_context_adl(L l) {
+ {
+ h(l); // expected-error {{call to 'h' is ambiguous}}
+ }
+ }
+}
+
+namespace test5 {
+ namespace NS {
+ struct A;
+ void foo(void (*)(A&));
+ }
+ void bar(NS::A& a);
+
+ void test() {
+ foo(&bar);
+ }
+}
+
+// PR6762: __builtin_va_list should be invisible to ADL on all platforms.
+void test6_function(__builtin_va_list &argv);
+namespace test6 {
+ void test6_function(__builtin_va_list &argv);
+
+ void test() {
+ __builtin_va_list args;
+ test6_function(args);
+ }
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp
new file mode 100644
index 0000000..c4c2c8d
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// FIXME: embellish
+
+namespace test0 {
+ namespace A {
+ class Foo {
+ };
+
+ void foo(const Foo &foo);
+ }
+
+ class Test {
+ enum E { foo = 0 };
+
+ void test() {
+ foo(A::Foo()); // expected-error {{not a function}}
+ }
+ };
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
new file mode 100644
index 0000000..32dd75a
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace A {
+ class A {
+ friend void func(A);
+ friend A operator+(A,A);
+ };
+}
+
+namespace B {
+ class B {
+ static void func(B);
+ };
+ B operator+(B,B);
+}
+
+namespace D {
+ class D {};
+}
+
+namespace C {
+ class C {}; // expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'B::B' to 'const C::C &' for 1st argument}}
+ void func(C); // expected-note {{'C::func' declared here}} \
+ // expected-note {{passing argument to parameter here}}
+ C operator+(C,C);
+ D::D operator+(D::D,D::D);
+}
+
+namespace D {
+ using namespace C;
+}
+
+namespace Test {
+ void test() {
+ func(A::A());
+ // FIXME: namespace-aware typo correction causes an extra, misleading
+ // message in this case; some form of backtracking, diagnostic message
+ // delaying, or argument checking before emitting diagnostics is needed to
+ // avoid accepting and printing out a typo correction that proves to be
+ // incorrect once argument-dependent lookup resolution has occurred.
+ func(B::B()); // expected-error {{use of undeclared identifier 'func'; did you mean 'C::func'?}} \
+ // expected-error {{no viable conversion from 'B::B' to 'C::C'}}
+ func(C::C());
+ A::A() + A::A();
+ B::B() + B::B();
+ C::C() + C::C();
+ D::D() + D::D(); // expected-error {{invalid operands to binary expression ('D::D' and 'D::D')}}
+ }
+}
+
+// PR6716
+namespace test1 {
+ template <class T> class A {
+ template <class U> friend void foo(A &, U); // expected-note {{not viable: 1st argument ('const A<int>') would lose const qualifier}}
+
+ public:
+ A();
+ };
+
+ void test() {
+ const A<int> a;
+ foo(a, 10); // expected-error {{no matching function for call to 'foo'}}
+ }
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
new file mode 100644
index 0000000..c207283
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify %s
+
+// C++98 [basic.lookup.classref]p1:
+// In a class member access expression (5.2.5), if the . or -> token is
+// immediately followed by an identifier followed by a <, the identifier must
+// be looked up to determine whether the < is the beginning of a template
+// argument list (14.2) or a less-than operator. The identifier is first
+// looked up in the class of the object expression. If the identifier is not
+// found, it is then looked up in the context of the entire postfix-expression
+// and shall name a class or function template. If the lookup in the class of
+// the object expression finds a template, the name is also looked up in the
+// context of the entire postfix-expression and
+// -- if the name is not found, the name found in the class of the object
+// expression is used, otherwise
+// -- if the name is found in the context of the entire postfix-expression
+// and does not name a class template, the name found in the class of the
+// object expression is used, otherwise
+// -- if the name found is a class template, it must refer to the same
+// entity as the one found in the class of the object expression,
+// otherwise the program is ill-formed.
+
+// From PR 7247
+template<typename T>
+struct set{}; // expected-note{{lookup from the current scope refers here}}
+struct Value {
+ template<typename T>
+ void set(T value) {} // expected-note{{lookup in the object type 'Value' refers here}}
+
+ void resolves_to_same() {
+ Value v;
+ v.set<double>(3.2);
+ }
+};
+void resolves_to_different() {
+ {
+ Value v;
+ // The fact that the next line is a warning rather than an error is an
+ // extension.
+ v.set<double>(3.2); // expected-warning{{lookup of 'set' in member access expression is ambiguous; using member of 'Value'}}
+ }
+ {
+ int set; // Non-template.
+ Value v;
+ v.set<double>(3.2);
+ }
+}
+
+namespace rdar9915664 {
+ struct A {
+ template<typename T> void a();
+ };
+
+ struct B : A { };
+
+ struct C : A { };
+
+ struct D : B, C {
+ A &getA() { return static_cast<B&>(*this); }
+
+ void test_a() {
+ getA().a<int>();
+ }
+ };
+}
+
+namespace PR11856 {
+ template<typename T> T end(T);
+
+ template <typename T>
+ void Foo() {
+ T it1;
+ if (it1->end < it1->end) {
+ }
+ }
+
+ template<typename T> T *end(T*);
+
+ class X { };
+ template <typename T>
+ void Foo2() {
+ T it1;
+ if (it1->end < it1->end) {
+ }
+
+ X *x;
+ if (x->end < 7) { // expected-error{{no member named 'end' in 'PR11856::X'}}
+ }
+ }
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p3.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p3.cpp
new file mode 100644
index 0000000..cd7e669
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p3.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++0x [basic.lookup.classref]p3:
+// If the unqualified-id is ~type-name, the type-name is looked up in the
+// context of the entire postfix-expression. If the type T of the object
+// expression is of a class type C, the type-name is also looked up in the
+// scope of class C. At least one of the lookups shall find a name that
+// refers to (possibly cv-qualified) T.
+
+// From core issue 305
+struct A {
+};
+
+struct C {
+ struct A {};
+ void f ();
+};
+
+void C::f () {
+ ::A *a;
+ a->~A ();
+}
+
+// From core issue 414
+struct X {};
+void f() {
+ X x;
+ struct X {};
+ x.~X();
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp
new file mode 100644
index 0000000..004d1e4
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace test0 {
+ struct A {
+ static int foo;
+ };
+
+ namespace i0 {
+ typedef int A; // expected-note {{declared here}}
+
+ int test() {
+ struct A a; // expected-error {{elaborated type refers to a typedef}}
+ return a.foo;
+ }
+ }
+
+ namespace i1 {
+ template <class> class A; // expected-note {{declared here}}
+
+ int test() {
+ struct A a; // expected-error {{elaborated type refers to a template}}
+ return a.foo;
+ }
+ }
+
+ namespace i2 {
+ int A;
+
+ int test() {
+ struct A a;
+ return a.foo;
+ }
+ }
+
+ namespace i3 {
+ void A();
+
+ int test() {
+ struct A a;
+ return a.foo;
+ }
+ }
+
+ namespace i4 {
+ template <class T> void A();
+
+ int test() {
+ struct A a;
+ return a.foo;
+ }
+ }
+
+ // This should magically be okay; see comment in SemaDecl.cpp.
+ // rdar://problem/7898108
+ typedef struct A A;
+ int test() {
+ struct A a;
+ return a.foo;
+ }
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp
new file mode 100644
index 0000000..8126d28
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// elaborated-type-specifier:
+// class-key '::'? nested-name-specifier? 'template'? simple-template-id
+// Tests that this form is accepted by the compiler but does not follow
+// the elaborated lookup rules of [basic.lookup.elab].
+
+template <typename> class Ident {}; // expected-note {{previous use is here}}
+
+namespace A {
+ template <typename> void Ident();
+
+ class Ident<int> AIdent; // expected-error {{refers to a function template}}
+ class ::Ident<int> AnotherIdent;
+}
+
+class Ident<int> GlobalIdent;
+union Ident<int> GlobalIdent2; // expected-error {{ tag type that does not match }}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
new file mode 100644
index 0000000..7ecedd5
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct X0 {
+ X0 f1();
+ X0 f2();
+};
+
+template<typename T>
+struct X1 {
+ X1<T>(int);
+ (X1<T>)(float);
+ X1 f2();
+ X1 f2(int);
+ X1 f2(float);
+};
+
+// Error recovery: out-of-line constructors whose names have template arguments.
+template<typename T> X1<T>::X1<T>(int) { } // expected-error{{out-of-line constructor for 'X1' cannot have template arguments}}
+template<typename T> (X1<T>::X1<T>)(float) { } // expected-error{{out-of-line constructor for 'X1' cannot have template arguments}}
+
+// Error recovery: out-of-line constructor names intended to be types
+X0::X0 X0::f1() { return X0(); } // expected-error{{qualified reference to 'X0' is a constructor name rather than a type wherever a constructor can be declared}}
+
+struct X0::X0 X0::f2() { return X0(); }
+
+template<typename T> X1<T>::X1<T> X1<T>::f2() { } // expected-error{{qualified reference to 'X1' is a constructor name rather than a template name wherever a constructor can be declared}}
+template<typename T> X1<T>::X1<T> (X1<T>::f2)(int) { } // expected-error{{qualified reference to 'X1' is a constructor name rather than a template name wherever a constructor can be declared}}
+template<typename T> struct X1<T>::X1<T> (X1<T>::f2)(float) { }
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
new file mode 100644
index 0000000..3039396
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace Ints {
+ int zero = 0; // expected-note {{candidate found by name lookup is 'Ints::zero'}}
+ void f(int); // expected-note 3 {{candidate function}}
+ void g(int);
+}
+
+namespace Floats {
+ float zero = 0.0f; // expected-note {{candidate found by name lookup is 'Floats::zero'}}
+ void f(float); // expected-note 3 {{candidate function}}
+ void g(float);
+}
+
+namespace Numbers {
+ using namespace Ints;
+ using namespace Floats;
+}
+
+void test() {
+ int i = Ints::zero;
+ Ints::f(i);
+
+ float f = Floats::zero;
+ Floats::f(f);
+
+ double n = Numbers::zero; // expected-error {{reference to 'zero' is ambiguous}}
+ Numbers::f(n); // expected-error{{call to 'f' is ambiguous}}
+ Numbers::f(i);
+ Numbers::f(f);
+}
+
+namespace Numbers {
+ struct Number { // expected-note 2 {{candidate}}
+ explicit Number(double d) : d(d) {}
+ double d;
+ };
+ Number zero(0.0f);
+ void g(Number); // expected-note 2{{passing argument to parameter here}}
+}
+
+void test2() {
+ Numbers::Number n = Numbers::zero;
+ Numbers::f(n); // expected-error {{no matching function for call to 'f'}}
+ Numbers::g(n);
+}
+
+namespace Numbers2 {
+ using Numbers::f;
+ using Numbers::g;
+}
+
+void test3() {
+ Numbers::Number n = Numbers::zero;
+ Numbers2::f(n); // expected-error {{no matching function for call to 'f'}}
+ Numbers2::g(n);
+
+ int i = Ints::zero;
+ Numbers2::f(i);
+ Numbers2::g(i); // expected-error {{no viable conversion from 'int' to 'Numbers::Number'}}
+
+ float f = Floats::zero;
+ Numbers2::f(f);
+ Numbers2::g(f); // expected-error {{no viable conversion from 'float' to 'Numbers::Number'}}
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp
new file mode 100644
index 0000000..dc0f8b4
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// This is basically paraphrased from the standard.
+
+namespace Root {
+ int i = 0;
+ void f();
+}
+
+namespace A {
+ using namespace Root;
+}
+
+namespace B {
+ using namespace Root;
+}
+
+namespace AB {
+ using namespace A;
+ using namespace B;
+}
+
+void test() {
+ if (AB::i)
+ AB::f();
+}
+
+namespace C {
+ using Root::i;
+ using Root::f;
+}
+
+namespace AC {
+ using namespace A;
+ using namespace C;
+}
+
+void test2() {
+ if (AC::i)
+ AC::f();
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp
new file mode 100644
index 0000000..38eccfa
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace A {
+ int a;
+}
+
+namespace C {
+ int c;
+}
+
+namespace B {
+ using namespace C;
+ int b;
+}
+
+namespace C {
+ using namespace B;
+ using namespace A;
+}
+
+void test() {
+ C::a++;
+ C::b++;
+ C::c++;
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp
new file mode 100644
index 0000000..5045bac
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace A {
+ struct x {}; // expected-note {{candidate found by name lookup is 'A::x'}}
+ int x; // expected-note {{candidate found by name lookup is 'A::x'}}
+
+ struct y {}; // expected-note {{type declaration hidden}}
+
+ struct z;
+ void z(float);
+}
+
+namespace B {
+ struct x {}; // expected-note {{candidate found by name lookup is 'B::x'}}
+ float x; // expected-note {{candidate found by name lookup is 'B::x'}}
+
+ float y; // expected-note {{declaration hides type}}
+
+ void z(int);
+}
+
+namespace AB {
+ using namespace A;
+ using namespace B;
+}
+
+void test() {
+ struct AB::x foo; // expected-error {{reference to 'x' is ambiguous}}
+ int i = AB::x; // expected-error {{reference to 'x' is ambiguous}}
+
+ struct AB::y bar;
+ float f = AB::y; // expected-error {{a type named 'y' is hidden by a declaration in a different namespace}}
+ AB::z(i);
+ AB::z(f);
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6-0x.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6-0x.cpp
new file mode 100644
index 0000000..c745c84
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6-0x.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// XFAIL: *
+// Our C++0x doesn't currently have specialized destructor name handling,
+// since the specification is still in flux.
+struct C {
+ typedef int I;
+};
+
+typedef int I1, I2;
+extern int* p;
+extern int* q;
+
+void f() {
+ p->C::I::~I();
+ q->I1::~I2();
+}
+
+struct A {
+ ~A();
+};
+
+typedef A AB;
+int main() {
+ AB *p;
+ p->AB::~AB();
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp
new file mode 100644
index 0000000..0956de3
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct C {
+ typedef int I;
+};
+
+typedef int I1, I2;
+extern int* p;
+extern int* q;
+
+void f() {
+ p->C::I::~I();
+ q->I1::~I2();
+}
+
+struct A {
+ ~A();
+};
+
+typedef A AB;
+int main() {
+ AB *p;
+ p->AB::~AB(); // expected-error{{expected the class name after '~' to name a destructor}}
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp
new file mode 100644
index 0000000..ab0dc24
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// When looking up a namespace-name in a using-directive or
+// namespace-alias-definition, only namespace names are considered.
+
+struct ns1 {};
+void ns2();
+int ns3 = 0;
+
+namespace ns0 {
+ namespace ns1 {
+ struct test0 {};
+ }
+ namespace ns2 {
+ struct test1 {};
+ }
+ namespace ns3 {
+ struct test2 {};
+ }
+}
+
+using namespace ns0;
+
+namespace test3 = ns1;
+namespace test4 = ns2;
+namespace test5 = ns3;
+
+using namespace ns1;
+using namespace ns2;
+using namespace ns3;
+
+test0 a;
+test1 b;
+test2 c;
+
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p11.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p11.cpp
new file mode 100644
index 0000000..a1cf529
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p11.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+static const int a = 10;
+
+void f0(int a,
+ int b = a) { // expected-error {{default argument references parameter 'a'}}
+}
+
+template<int a,
+ int b = a>
+class A {
+};
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p12.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p12.cpp
new file mode 100644
index 0000000..878ff07
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p12.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct S {};
+S E0;
+
+namespace {
+ enum {
+ E0 = 1,
+ E1 = E0 + 1
+ };
+}
+
+
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p13.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p13.cpp
new file mode 100644
index 0000000..58d7ff4
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p13.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct S {
+ static const int f0 = 0;
+ static int f1;
+};
+
+int S::f1 = f0;
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp
new file mode 100644
index 0000000..0fa4f65
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++0x [basic.lookup.unqual]p14:
+// If a variable member of a namespace is defined outside of the
+// scope of its namespace then any name used in the definition of
+// the variable member (after the declarator-id) is looked up as if
+// the definition of the variable member occurred in its namespace.
+
+namespace N {
+ struct S {};
+ S i;
+ extern S j;
+ extern S j2;
+}
+
+int i = 2;
+N::S N::j = i;
+N::S N::j2(i);
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p15.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p15.cpp
new file mode 100644
index 0000000..253d15e
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p15.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// XFAIL: *
+
+class C {
+public:
+ C(int a, int b);
+};
+
+C::C(int a, // expected-note {{previous definition}}
+ int b) // expected-note {{previous definition}}
+try {
+ int c;
+
+} catch (int a) { // expected-error {{redefinition of 'a'}}
+ int b; // expected-error {{redefinition of 'b'}}
+ ++c; // expected-error {{use of undeclared identifier 'c'}}
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp
new file mode 100644
index 0000000..20a7ae0
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int f;
+
+namespace N0 {
+ struct A {
+ friend void f();
+ void g() {
+ int i = f(1);
+ }
+ };
+}
+
+namespace N1 {
+ struct A {
+ friend void f(A &);
+ operator int();
+ void g(A a) {
+ // ADL should not apply to the lookup of 'f', it refers to the typedef
+ // above.
+ int i = f(a);
+ }
+ };
+}
diff --git a/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp
new file mode 100644
index 0000000..d2afd5d
--- /dev/null
+++ b/clang/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR5741
+namespace test0 {
+ struct A {
+ struct B { };
+ struct C;
+ };
+
+ struct A::C : B { };
+}
+
+// Test that successive base specifiers don't screw with each other.
+namespace test1 {
+ struct Opaque1 {};
+ struct Opaque2 {};
+
+ struct A {
+ struct B { B(Opaque1); };
+ };
+ struct B {
+ B(Opaque2);
+ };
+
+ struct C : A, B {
+ // Apparently the base-or-member lookup is actually ambiguous
+ // without this qualification.
+ C() : A(), test1::B(Opaque2()) {}
+ };
+}
+
+// Test that we don't find the injected class name when parsing base
+// specifiers.
+namespace test2 {
+ template <class T> struct bar {};
+ template <class T> struct foo : bar<foo> {}; // expected-error {{use of class template foo requires template arguments}} expected-note {{template is declared here}}
+}
diff --git a/clang/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp b/clang/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp
new file mode 100644
index 0000000..911df98
--- /dev/null
+++ b/clang/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// rdar4641403
+namespace N {
+ struct X { // expected-note{{candidate found by name lookup}}
+ float b;
+ };
+}
+
+using namespace N;
+
+typedef struct {
+ int a;
+} X; // expected-note{{candidate found by name lookup}}
+
+
+struct Y { };
+void Y(int) { }
+
+void f() {
+ X *x; // expected-error{{reference to 'X' is ambiguous}}
+ Y(1); // okay
+}
+
diff --git a/clang/test/CXX/basic/basic.scope/basic.scope.local/p4-0x.cpp b/clang/test/CXX/basic/basic.scope/basic.scope.local/p4-0x.cpp
new file mode 100644
index 0000000..cd51c78
--- /dev/null
+++ b/clang/test/CXX/basic/basic.scope/basic.scope.local/p4-0x.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+void f() {
+ int b;
+ int arr[] = {1, 2, 3};
+
+ if (bool b = true) // expected-note 2{{previous definition}}
+ bool b; // expected-error {{redefinition}}
+ else
+ int b; // expected-error {{redefinition}}
+ while (bool b = true) // expected-note {{previous definition}}
+ int b; // expected-error {{redefinition}}
+ for (int c; // expected-note 2{{previous definition}}
+ bool c = true;) // expected-error {{redefinition}}
+ double c; // expected-error {{redefinition}}
+ switch (int n = 37 + 5) // expected-note {{previous definition}}
+ int n; // expected-error {{redefinition}}
+ for (int a : arr) // expected-note {{previous definition}}
+ int a = 0; // expected-error {{redefinition}}
+
+ if (bool b = true) { // expected-note 2{{previous definition}}
+ int b; // expected-error {{redefinition}}
+ } else {
+ int b; // expected-error {{redefinition}}
+ }
+ while (bool b = true) { // expected-note {{previous definition}}
+ int b; // expected-error {{redefinition}}
+ }
+ for (int c; // expected-note 2{{previous definition}}
+ bool c = true;) { // expected-error {{redefinition}}
+ double c; // expected-error {{redefinition}}
+ }
+ switch (int n = 37 + 5) { // expected-note {{previous definition}}
+ int n; // expected-error {{redefinition}}
+ }
+ for (int &a : arr) { // expected-note {{previous definition}}
+ int a = 0; // expected-error {{redefinition}}
+ }
+
+ if (bool b = true) {{ // expected-note {{previous definition}}
+ bool b;
+ }} else {
+ int b; // expected-error {{redefinition}}
+ }
+ if (bool b = true) { // expected-note {{previous definition}}
+ bool b; // expected-error {{redefinition}}
+ } else {{
+ int b;
+ }}
+ if (bool b = true) {{
+ bool b;
+ }} else {{
+ int b;
+ }}
+ while (bool b = true) {{
+ int b;
+ }}
+ for (int c; // expected-note {{previous definition}}
+ bool c = true; ) {{ // expected-error {{redefinition}}
+ double c;
+ }}
+ switch (int n = 37 + 5) {{
+ int n;
+ }}
+ for (int &a : arr) {{
+ int a = 0;
+ }}
+}
diff --git a/clang/test/CXX/basic/basic.scope/basic.scope.pdecl/p3.cpp b/clang/test/CXX/basic/basic.scope/basic.scope.pdecl/p3.cpp
new file mode 100644
index 0000000..407a5f7
--- /dev/null
+++ b/clang/test/CXX/basic/basic.scope/basic.scope.pdecl/p3.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// Classes.
+namespace Class {
+ namespace NS {
+ class C {}; // expected-note {{candidate}}
+ }
+ using namespace NS;
+ class C : C {}; // expected-error {{reference to 'C' is ambiguous}} \
+ expected-note {{candidate}}
+}
+
+// Enumerations.
+enum E {
+ EPtrSize = sizeof((E*)0) // ok, E is already declared
+};
+
+// Alias declarations. clang implements the proposed resolution to N1044.
+namespace Alias {
+ namespace NS {
+ class C;
+ }
+ using namespace NS;
+ using C = C; // ok, C = B::C
+ using C = NS::C; // ok, same type
+}
diff --git a/clang/test/CXX/basic/basic.scope/basic.scope.pdecl/p9.cpp b/clang/test/CXX/basic/basic.scope/basic.scope.pdecl/p9.cpp
new file mode 100644
index 0000000..e64b675
--- /dev/null
+++ b/clang/test/CXX/basic/basic.scope/basic.scope.pdecl/p9.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Template type parameters.
+typedef unsigned char T;
+template<typename T = T> struct X0 { };
+template<> struct X0<unsigned char> { static const bool value = true; };
+int array0[X0<>::value? 1 : -1];
+
+// Non-type template parameters.
+const int N = 17;
+template<int N = N> struct X1 { };
+template<> struct X1<17> { static const bool value = true; };
+int array1[X1<>::value? 1 : -1];
+
+// Template template parameters.
+template<template<class> class X0 = X0> struct X2 { };
+template<> struct X2<X0> { static const bool value = true; };
+int array2[X2<>::value? 1 : -1];
diff --git a/clang/test/CXX/basic/basic.start/basic.start.main/p2a.cpp b/clang/test/CXX/basic/basic.start/basic.start.main/p2a.cpp
new file mode 100644
index 0000000..b8dfbe7
--- /dev/null
+++ b/clang/test/CXX/basic/basic.start/basic.start.main/p2a.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int Int;
+typedef char Char;
+typedef Char* Carp;
+
+Int main(Int argc, Carp argv[]) {
+}
diff --git a/clang/test/CXX/basic/basic.start/basic.start.main/p2b.cpp b/clang/test/CXX/basic/basic.start/basic.start.main/p2b.cpp
new file mode 100644
index 0000000..785382c
--- /dev/null
+++ b/clang/test/CXX/basic/basic.start/basic.start.main/p2b.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int Int;
+typedef char Char;
+typedef Char* Carp;
+
+Int main(Int argc, Carp argv[], Char *env[]) {
+}
diff --git a/clang/test/CXX/basic/basic.start/basic.start.main/p2c.cpp b/clang/test/CXX/basic/basic.start/basic.start.main/p2c.cpp
new file mode 100644
index 0000000..81b08b9
--- /dev/null
+++ b/clang/test/CXX/basic/basic.start/basic.start.main/p2c.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int main() {
+}
diff --git a/clang/test/CXX/basic/basic.start/basic.start.main/p2d.cpp b/clang/test/CXX/basic/basic.start/basic.start.main/p2d.cpp
new file mode 100644
index 0000000..bcdbdb2
--- /dev/null
+++ b/clang/test/CXX/basic/basic.start/basic.start.main/p2d.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+static int main() { // expected-error {{'main' is not allowed to be declared static}}
+}
diff --git a/clang/test/CXX/basic/basic.start/basic.start.main/p2e.cpp b/clang/test/CXX/basic/basic.start/basic.start.main/p2e.cpp
new file mode 100644
index 0000000..954fdbd
--- /dev/null
+++ b/clang/test/CXX/basic/basic.start/basic.start.main/p2e.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+inline int main() { // expected-error {{'main' is not allowed to be declared inline}}
+}
diff --git a/clang/test/CXX/basic/basic.start/basic.start.main/p2f.cpp b/clang/test/CXX/basic/basic.start/basic.start.main/p2f.cpp
new file mode 100644
index 0000000..ea5a752
--- /dev/null
+++ b/clang/test/CXX/basic/basic.start/basic.start.main/p2f.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void // expected-error {{'main' must return 'int'}}
+main( // expected-error {{first parameter of 'main' (argument count) must be of type 'int'}}
+ float a
+) {
+}
diff --git a/clang/test/CXX/basic/basic.start/basic.start.main/p2g.cpp b/clang/test/CXX/basic/basic.start/basic.start.main/p2g.cpp
new file mode 100644
index 0000000..e3209fd
--- /dev/null
+++ b/clang/test/CXX/basic/basic.start/basic.start.main/p2g.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int main(int argc, const char* const* argv) {
+}
diff --git a/clang/test/CXX/basic/basic.start/basic.start.main/p2h.cpp b/clang/test/CXX/basic/basic.start/basic.start.main/p2h.cpp
new file mode 100644
index 0000000..abf8faa
--- /dev/null
+++ b/clang/test/CXX/basic/basic.start/basic.start.main/p2h.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+int main() { } // expected-error{{'main' cannot be a template}}
+
diff --git a/clang/test/CXX/basic/basic.start/basic.start.main/p2i.cpp b/clang/test/CXX/basic/basic.start/basic.start.main/p2i.cpp
new file mode 100644
index 0000000..db8da3c
--- /dev/null
+++ b/clang/test/CXX/basic/basic.start/basic.start.main/p2i.cpp
@@ -0,0 +1,6 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -x c++ %s -std=c++11 -fsyntax-only -verify
+// RUN: not %clang_cc1 -x c++ %t -std=c++11 -fixit
+// RUN: %clang_cc1 -x c++ %t -std=c++11 -fsyntax-only
+
+constexpr int main() { } // expected-error{{'main' is not allowed to be declared constexpr}}
diff --git a/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.allocation/p1.cpp b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.allocation/p1.cpp
new file mode 100644
index 0000000..8a62ae8
--- /dev/null
+++ b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.allocation/p1.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+#include <stddef.h>
+
+struct A {
+ void *operator new(size_t);
+};
+
+namespace NS {
+ void *operator new(size_t);; // expected-error {{'operator new' cannot be declared inside a namespace}}
+}
+
+static void *operator new(size_t); // expected-error {{'operator new' cannot be declared static in global scope}}
+
+struct B {
+ void operator new(size_t); // expected-error {{'operator new' must return type 'void *'}}
+};
+
+struct C {
+ void *operator new(); // expected-error {{'operator new' must have at least one parameter}}
+};
+
+struct D {
+ void *operator new(bool); // expected-error {{'operator new' takes type size_t}}
+};
+
+struct E {
+ void *operator new(size_t = 0); // expected-error {{parameter of 'operator new' cannot have a default argument}}
+};
+
+struct F {
+ template<typename T> void *operator new(size_t, int);
+};
+
+struct G {
+ template<typename T> T operator new(size_t, int); // expected-error {{'operator new' cannot have a dependent return type; use 'void *' instead}}
+};
+
+struct H {
+ template<typename T> void *operator new(T, int); // expected-error {{'operator new' cannot take a dependent type as first parameter; use size_t}}
+};
+
+struct I {
+ template<typename T> void *operator new(size_t); // expected-error {{'operator new' template must have at least two parameters}}
+};
diff --git a/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p1.cpp b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p1.cpp
new file mode 100644
index 0000000..e00e948
--- /dev/null
+++ b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p1.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {
+ void operator delete(void*);
+};
+
+namespace NS {
+ void operator delete(void *); // expected-error {{'operator delete' cannot be declared inside a namespace}}
+}
+
+static void operator delete(void *); // expected-error {{'operator delete' cannot be declared static in global scope}}
diff --git a/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-nodef.cpp b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-nodef.cpp
new file mode 100644
index 0000000..6cd587c
--- /dev/null
+++ b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-nodef.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int *use_new(int N) {
+ return new int [N];
+}
+
+int std = 17;
diff --git a/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp
new file mode 100644
index 0000000..4567c46
--- /dev/null
+++ b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+namespace std {
+ class bad_alloc { };
+
+ typedef __SIZE_TYPE__ size_t;
+}
+
+class foo { virtual ~foo(); };
+
+void* operator new(std::size_t);
+void* operator new[](std::size_t);
+void operator delete(void*);
+void operator delete[](void*);
diff --git a/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp
new file mode 100644
index 0000000..47b5158
--- /dev/null
+++ b/clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify %s
+int *use_new(int N) {
+ if (N == 1)
+ return new int;
+
+ return new int [N];
+}
+
+void use_delete(int* ip, int N) {
+ if (N == 1)
+ delete ip;
+ else
+ delete [] ip;
+}
+
+namespace std {
+ class bad_alloc { };
+
+ typedef __SIZE_TYPE__ size_t;
+}
+
+void* operator new(std::size_t) throw(std::bad_alloc); // expected-note{{previous declaration}}
+void* operator new[](std::size_t) throw(std::bad_alloc);
+void operator delete(void*) throw(); // expected-note{{previous declaration}}
+void operator delete[](void*) throw();
+
+void* operator new(std::size_t); // expected-warning{{'operator new' is missing exception specification 'throw(std::bad_alloc)'}}
+void operator delete(void*); // expected-warning{{'operator delete' is missing exception specification 'throw()'}}
diff --git a/clang/test/CXX/basic/basic.types/p10.cpp b/clang/test/CXX/basic/basic.types/p10.cpp
new file mode 100644
index 0000000..83b910b
--- /dev/null
+++ b/clang/test/CXX/basic/basic.types/p10.cpp
@@ -0,0 +1,132 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct NonLiteral { NonLiteral(); };
+
+// A type is a literal type if it is:
+
+// - a scalar type
+constexpr int f1(double) { return 0; }
+
+// - a reference type
+struct S { S(); };
+constexpr int f2(S &) { return 0; }
+
+// FIXME: I'm not entirely sure whether the following is legal or not...
+struct BeingDefined;
+extern BeingDefined beingdefined;
+struct BeingDefined {
+ static constexpr BeingDefined& t = beingdefined;
+};
+
+// - a class type that has all of the following properties:
+
+// (implied) - it is complete
+
+struct Incomplete;
+template<class T> struct ClassTemp {};
+
+constexpr Incomplete incomplete = {}; // expected-error {{constexpr variable cannot have non-literal type 'const Incomplete'}}
+constexpr Incomplete incomplete2[] = {}; // expected-error {{constexpr variable cannot have non-literal type 'Incomplete const[]'}}
+constexpr ClassTemp<int> classtemplate = {};
+constexpr ClassTemp<int> classtemplate2[] = {};
+
+// - it has a trivial destructor
+struct UserProvDtor {
+ constexpr int f(); // expected-error {{non-literal type 'UserProvDtor' cannot have constexpr members}}
+ ~UserProvDtor(); // expected-note {{has a user-provided destructor}}
+};
+
+struct NonTrivDtor {
+ constexpr NonTrivDtor();
+ constexpr int f(); // expected-error {{non-literal type 'NonTrivDtor' cannot have constexpr members}}
+ virtual ~NonTrivDtor() = default; // expected-note {{has a non-trivial destructor}}
+};
+struct NonTrivDtorBase {
+ ~NonTrivDtorBase();
+};
+template<typename T>
+struct DerivedFromNonTrivDtor : T { // expected-note {{'DerivedFromNonTrivDtor<NonTrivDtorBase>' is not literal because it has base class 'NonTrivDtorBase' of non-literal type}}
+ constexpr DerivedFromNonTrivDtor();
+};
+constexpr int f(DerivedFromNonTrivDtor<NonTrivDtorBase>) { return 0; } // expected-error {{constexpr function's 1st parameter type 'DerivedFromNonTrivDtor<NonTrivDtorBase>' is not a literal type}}
+struct TrivDtor {
+ constexpr TrivDtor();
+};
+constexpr int f(TrivDtor) { return 0; }
+struct TrivDefaultedDtor {
+ constexpr TrivDefaultedDtor();
+ ~TrivDefaultedDtor() = default;
+};
+constexpr int f(TrivDefaultedDtor) { return 0; }
+
+// - it is an aggregate type or has at least one constexpr constructor or
+// constexpr constructor template that is not a copy or move constructor
+struct Agg {
+ int a;
+ char *b;
+};
+constexpr int f3(Agg a) { return a.a; }
+struct CtorTemplate {
+ template<typename T> constexpr CtorTemplate(T);
+};
+struct CopyCtorOnly { // expected-note {{'CopyCtorOnly' is not literal because it is not an aggregate and has no constexpr constructors other than copy or move constructors}}
+ constexpr CopyCtorOnly(CopyCtorOnly&);
+ constexpr int f(); // expected-error {{non-literal type 'CopyCtorOnly' cannot have constexpr members}}
+};
+struct MoveCtorOnly { // expected-note {{no constexpr constructors other than copy or move constructors}}
+ constexpr MoveCtorOnly(MoveCtorOnly&&);
+ constexpr int f(); // expected-error {{non-literal type 'MoveCtorOnly' cannot have constexpr members}}
+};
+template<typename T>
+struct CtorArg {
+ constexpr CtorArg(T);
+};
+constexpr int f(CtorArg<int>) { return 0; } // ok
+constexpr int f(CtorArg<NonLiteral>) { return 0; } // ok, ctor is still constexpr
+// We have a special-case diagnostic for classes with virtual base classes.
+struct VBase {};
+struct HasVBase : virtual VBase {}; // expected-note 2{{virtual base class declared here}}
+struct Derived : HasVBase {
+ constexpr Derived() {} // expected-error {{constexpr constructor not allowed in struct with virtual base class}}
+};
+template<typename T> struct DerivedFromVBase : T { // expected-note {{struct with virtual base class is not a literal type}}
+ constexpr DerivedFromVBase();
+};
+constexpr int f(DerivedFromVBase<HasVBase>) {} // expected-error {{constexpr function's 1st parameter type 'DerivedFromVBase<HasVBase>' is not a literal type}}
+template<typename T> constexpr DerivedFromVBase<T>::DerivedFromVBase() : T() {}
+constexpr int nVBase = (DerivedFromVBase<HasVBase>(), 0); // expected-error {{constant expression}} expected-note {{cannot construct object of type 'DerivedFromVBase<HasVBase>' with virtual base class in a constant expression}}
+
+// - it has all non-static data members and base classes of literal types
+struct NonLitMember {
+ S s; // expected-note {{has data member 's' of non-literal type 'S'}}
+};
+constexpr int f(NonLitMember) {} // expected-error {{1st parameter type 'NonLitMember' is not a literal type}}
+struct NonLitBase :
+ S { // expected-note {{base class 'S' of non-literal type}}
+ constexpr NonLitBase();
+ constexpr int f() { return 0; } // expected-error {{non-literal type 'NonLitBase' cannot have constexpr members}}
+};
+struct LitMemBase : Agg {
+ Agg agg;
+};
+template<typename T>
+struct MemberType {
+ T t; // expected-note {{'MemberType<NonLiteral>' is not literal because it has data member 't' of non-literal type 'NonLiteral'}}
+ constexpr MemberType();
+};
+constexpr int f(MemberType<int>) { return 0; }
+constexpr int f(MemberType<NonLiteral>) { return 0; } // expected-error {{not a literal type}}
+
+// - an array of literal type
+struct ArrGood {
+ Agg agg[24];
+ double d[12];
+ TrivDtor td[3];
+ TrivDefaultedDtor tdd[3];
+};
+constexpr int f(ArrGood) { return 0; }
+
+struct ArrBad {
+ S s[3]; // expected-note {{data member 's' of non-literal type 'S [3]'}}
+};
+constexpr int f(ArrBad) { return 0; } // expected-error {{1st parameter type 'ArrBad' is not a literal type}}
diff --git a/clang/test/CXX/class.access/class.access.base/p1.cpp b/clang/test/CXX/class.access/class.access.base/p1.cpp
new file mode 100644
index 0000000..43cc99e
--- /dev/null
+++ b/clang/test/CXX/class.access/class.access.base/p1.cpp
@@ -0,0 +1,155 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++0x [class.access.base]p1(a):
+// If a class is declared to be a base class for another class using
+// the public access specifier, the public members of the base class
+// are accessible as public members of the derived class and protected
+// members of the base class are accessible as protected members of
+// the derived class.
+namespace test0 {
+ class Base {
+ public: int pub; static int spub;
+ protected: int prot; static int sprot; // expected-note 4 {{declared protected here}}
+ private: int priv; static int spriv; // expected-note 8 {{declared private here}}
+ };
+
+ class Test : public Base {
+ void test() {
+ pub++;
+ spub++;
+ prot++;
+ sprot++;
+ priv++; // expected-error {{private member}}
+ spriv++; // expected-error {{private member}}
+
+ Base::pub++;
+ Base::spub++;
+ Base::prot++;
+ Base::sprot++;
+ Base::priv++; // expected-error {{private member}}
+ Base::spriv++; // expected-error {{private member}}
+ }
+ };
+
+ void test(Test *t) {
+ t->pub++;
+ t->spub++;
+ t->prot++; // expected-error {{protected member}}
+ t->sprot++; // expected-error {{protected member}}
+ t->priv++; // expected-error {{private member}}
+ t->spriv++; // expected-error {{private member}}
+
+ t->Base::pub++;
+ t->Base::spub++;
+ t->Base::prot++; // expected-error {{protected member}}
+ t->Base::sprot++; // expected-error {{protected member}}
+ t->Base::priv++; // expected-error {{private member}}
+ t->Base::spriv++; // expected-error {{private member}}
+ }
+}
+
+// C++0x [class.access.base]p1(b):
+// If a class is declared to be a base class for another class using
+// the protected access specifier, the public and protected members
+// of the base class are accessible as protected members of the
+// derived class.
+namespace test1 {
+ class Base { // expected-note 6{{member is declared here}}
+ public:
+ int pub; // expected-note{{member is declared here}}
+ static int spub; // expected-note{{member is declared here}}
+ protected: int prot; static int sprot; // expected-note 4 {{declared protected here}}
+ private: int priv; static int spriv; // expected-note 8 {{declared private here}}
+ };
+
+ class Test : protected Base { // expected-note 6 {{declared protected here}} expected-note 8 {{constrained by protected inheritance here}}
+ void test() {
+ pub++;
+ spub++;
+ prot++;
+ sprot++;
+ priv++; // expected-error {{private member}}
+ spriv++; // expected-error {{private member}}
+
+ Base::pub++;
+ Base::spub++;
+ Base::prot++;
+ Base::sprot++;
+ Base::priv++; // expected-error {{private member}}
+ Base::spriv++; // expected-error {{private member}}
+ }
+ };
+
+ void test(Test *t) {
+ t->pub++; // expected-error {{protected member}} expected-error {{protected base class}}
+ t->spub++; // expected-error {{protected member}}
+ t->prot++; // expected-error {{protected member}} expected-error {{protected base class}}
+ t->sprot++; // expected-error {{protected member}}
+ t->priv++; // expected-error {{private member}} expected-error {{protected base class}}
+ t->spriv++; // expected-error {{private member}}
+
+ // Two possible errors here: one for Base, one for the member
+ t->Base::pub++; // expected-error {{protected member}} expected-error {{protected base class}}
+ t->Base::spub++; // expected-error {{protected member}}
+ t->Base::prot++; // expected-error 2 {{protected member}} expected-error {{protected base class}}
+ t->Base::sprot++; // expected-error 2 {{protected member}}
+ t->Base::priv++; // expected-error {{protected member}} expected-error {{private member}} expected-error {{protected base class}}
+ t->Base::spriv++; // expected-error {{protected member}} expected-error {{private member}}
+ }
+}
+
+// C++0x [class.access.base]p1(b):
+// If a class is declared to be a base class for another class using
+// the private access specifier, the public and protected members of
+// the base class are accessible as private members of the derived
+// class.
+namespace test2 {
+ class Base { // expected-note 6{{member is declared here}}
+ public:
+ int pub; // expected-note{{member is declared here}}
+ static int spub; // expected-note{{member is declared here}}
+ protected:
+ int prot; // expected-note {{declared protected here}} \
+ // expected-note{{member is declared here}}
+ static int sprot; // expected-note {{declared protected here}} \
+ // expected-note{{member is declared here}}
+ private:
+ int priv; // expected-note 4 {{declared private here}}
+ static int spriv; // expected-note 4 {{declared private here}}
+ };
+
+ class Test : private Base { // expected-note 6 {{declared private here}} \
+ // expected-note 10 {{constrained by private inheritance here}}
+ void test() {
+ pub++;
+ spub++;
+ prot++;
+ sprot++;
+ priv++; // expected-error {{private member}}
+ spriv++; // expected-error {{private member}}
+
+ Base::pub++;
+ Base::spub++;
+ Base::prot++;
+ Base::sprot++;
+ Base::priv++; // expected-error {{private member}}
+ Base::spriv++; // expected-error {{private member}}
+ }
+ };
+
+ void test(Test *t) {
+ t->pub++; // expected-error {{private member}} expected-error {{private base class}}
+ t->spub++; // expected-error {{private member}}
+ t->prot++; // expected-error {{private member}} expected-error {{private base class}}
+ t->sprot++; // expected-error {{private member}}
+ t->priv++; // expected-error {{private member}} expected-error {{private base class}}
+ t->spriv++; // expected-error {{private member}}
+
+ t->Base::pub++; // expected-error {{private member}} expected-error {{private base class}}
+ t->Base::spub++; // expected-error {{private member}}
+ t->Base::prot++; // expected-error {{protected member}} expected-error {{private member}} expected-error {{private base class}}
+ t->Base::sprot++; // expected-error {{protected member}} expected-error {{private member}}
+ t->Base::priv++; // expected-error 2 {{private member}} expected-error {{private base class}}
+ t->Base::spriv++; // expected-error 2 {{private member}}
+ }
+}
diff --git a/clang/test/CXX/class.access/class.access.base/p5.cpp b/clang/test/CXX/class.access/class.access.base/p5.cpp
new file mode 100644
index 0000000..255fbfc
--- /dev/null
+++ b/clang/test/CXX/class.access/class.access.base/p5.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -verify %s
+
+namespace test0 {
+ struct A {
+ static int x;
+ };
+ struct B : A {};
+ struct C : B {};
+
+ int test() {
+ return A::x
+ + B::x
+ + C::x;
+ }
+}
+
+namespace test1 {
+ struct A {
+ private: static int x; // expected-note 5 {{declared private here}}
+ static int test() { return x; }
+ };
+ struct B : public A {
+ static int test() { return x; } // expected-error {{private member}}
+ };
+ struct C : private A {
+ static int test() { return x; } // expected-error {{private member}}
+ };
+
+ struct D {
+ public: static int x; // expected-note{{member is declared here}}
+ static int test() { return x; }
+ };
+ struct E : private D { // expected-note{{constrained by private inheritance}}
+ static int test() { return x; }
+ };
+
+ int test() {
+ return A::x // expected-error {{private member}}
+ + B::x // expected-error {{private member}}
+ + C::x // expected-error {{private member}}
+ + D::x
+ + E::x; // expected-error {{private member}}
+ }
+}
+
+namespace test2 {
+ class A {
+ protected: static int x; // expected-note{{member is declared here}}
+ };
+
+ class B : private A {}; // expected-note {{private inheritance}}
+ class C : private A {
+ int test(B *b) {
+ return b->x; // expected-error {{private member}}
+ }
+ };
+}
+
+namespace test3 {
+ class A {
+ protected: static int x;
+ };
+
+ class B : public A {};
+ class C : private A {
+ int test(B *b) {
+ // x is accessible at C when named in A.
+ // A is an accessible base of B at C.
+ // Therefore this succeeds.
+ return b->x;
+ }
+ };
+}
+
+// TODO: flesh out these cases
diff --git a/clang/test/CXX/class.access/class.access.dcl/p1.cpp b/clang/test/CXX/class.access/class.access.dcl/p1.cpp
new file mode 100644
index 0000000..aab5fff
--- /dev/null
+++ b/clang/test/CXX/class.access/class.access.dcl/p1.cpp
@@ -0,0 +1,199 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// This is just the test for [namespace.udecl]p4 with 'using'
+// uniformly stripped out.
+
+// C++03 [namespace.udecl]p4:
+// A using-declaration used as a member-declaration shall refer to a
+// member of a base class of the class being defined, shall refer to
+// a member of an anonymous union that is a member of a base class
+// of the class being defined, or shall refer to an enumerator for
+// an enumeration type that is a member of a base class of the class
+// being defined.
+
+// There is no directly analogous paragraph in C++0x, and the feature
+// works sufficiently differently there that it needs a separate test.
+
+namespace test0 {
+ namespace NonClass {
+ typedef int type;
+ struct hiding {};
+ int hiding;
+ static union { double union_member; };
+ enum tagname { enumerator };
+ }
+
+ class Test0 {
+ NonClass::type; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}}
+ NonClass::hiding; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}}
+ NonClass::union_member; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}}
+ NonClass::enumerator; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}}
+ };
+}
+
+struct Opaque0 {};
+
+namespace test1 {
+ struct A {
+ typedef int type;
+ struct hiding {}; // expected-note {{previous use is here}}
+ Opaque0 hiding;
+ union { double union_member; };
+ enum tagname { enumerator };
+ };
+
+ struct B : A {
+ A::type; // expected-warning {{access declarations are deprecated}}
+ A::hiding; // expected-warning {{access declarations are deprecated}}
+ A::union_member; // expected-warning {{access declarations are deprecated}}
+ A::enumerator; // expected-warning {{access declarations are deprecated}}
+ A::tagname; // expected-warning {{access declarations are deprecated}}
+
+ void test0() {
+ type t = 0;
+ }
+
+ void test1() {
+ typedef struct A::hiding local;
+ struct hiding _ = local();
+ }
+
+ void test2() {
+ union hiding _; // expected-error {{tag type that does not match previous}}
+ }
+
+ void test3() {
+ char array[sizeof(union_member) == sizeof(double) ? 1 : -1];
+ }
+
+ void test4() {
+ enum tagname _ = enumerator;
+ }
+
+ void test5() {
+ Opaque0 _ = hiding;
+ }
+ };
+}
+
+namespace test2 {
+ struct A {
+ typedef int type;
+ struct hiding {}; // expected-note {{previous use is here}}
+ int hiding;
+ union { double union_member; };
+ enum tagname { enumerator };
+ };
+
+ template <class T> struct B : A {
+ A::type; // expected-warning {{access declarations are deprecated}}
+ A::hiding; // expected-warning {{access declarations are deprecated}}
+ A::union_member; // expected-warning {{access declarations are deprecated}}
+ A::enumerator; // expected-warning {{access declarations are deprecated}}
+ A::tagname; // expected-warning {{access declarations are deprecated}}
+
+ void test0() {
+ type t = 0;
+ }
+
+ void test1() {
+ typedef struct A::hiding local;
+ struct hiding _ = local();
+ }
+
+ void test2() {
+ union hiding _; // expected-error {{tag type that does not match previous}}
+ }
+
+ void test3() {
+ char array[sizeof(union_member) == sizeof(double) ? 1 : -1];
+ }
+
+ void test4() {
+ enum tagname _ = enumerator;
+ }
+
+ void test5() {
+ Opaque0 _ = hiding;
+ }
+ };
+}
+
+namespace test3 {
+ struct hiding {};
+
+ template <class T> struct A {
+ typedef int type; // expected-note {{target of using declaration}}
+ struct hiding {};
+ Opaque0 hiding;
+ union { double union_member; };
+ enum tagname { enumerator }; // expected-note {{target of using declaration}}
+ };
+
+ template <class T> struct B : A<T> {
+ A<T>::type; // expected-error {{dependent using declaration resolved to type without 'typename'}} // expected-warning {{access declarations are deprecated}}
+ A<T>::hiding; // expected-warning {{access declarations are deprecated}}
+ A<T>::union_member; // expected-warning {{access declarations are deprecated}}
+ A<T>::enumerator; // expected-warning {{access declarations are deprecated}}
+ A<T>::tagname; // expected-error {{dependent using declaration resolved to type without 'typename'}} // expected-warning {{access declarations are deprecated}}
+
+ // FIXME: re-enable these when the various bugs involving tags are fixed
+#if 0
+ void test1() {
+ typedef struct A<T>::hiding local;
+ struct hiding _ = local();
+ }
+
+ void test2() {
+ typedef struct A<T>::hiding local;
+ union hiding _ = local();
+ }
+#endif
+
+ void test3() {
+ char array[sizeof(union_member) == sizeof(double) ? 1 : -1];
+ }
+
+#if 0
+ void test4() {
+ enum tagname _ = enumerator;
+ }
+#endif
+
+ void test5() {
+ Opaque0 _ = hiding;
+ }
+ };
+
+ template struct B<int>; // expected-note {{in instantiation}}
+}
+
+namespace test4 {
+ struct Base {
+ int foo();
+ };
+
+ struct Unrelated {
+ int foo();
+ };
+
+ struct Subclass : Base {
+ };
+
+ namespace InnerNS {
+ int foo();
+ }
+
+ // We should be able to diagnose these without instantiation.
+ template <class T> struct C : Base {
+ InnerNS::foo; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}}
+ Base::bar; // expected-error {{no member named 'bar'}} expected-warning {{access declarations are deprecated}}
+ Unrelated::foo; // expected-error {{not a base class}} expected-warning {{access declarations are deprecated}}
+ C::foo; // legal in C++03 // expected-warning {{access declarations are deprecated}}
+ Subclass::foo; // legal in C++03 // expected-warning {{access declarations are deprecated}}
+
+ int bar(); //expected-note {{target of using declaration}}
+ C::bar; // expected-error {{refers to its own class}} expected-warning {{access declarations are deprecated}}
+ };
+}
+
diff --git a/clang/test/CXX/class.access/class.access.nest/p1.cpp b/clang/test/CXX/class.access/class.access.nest/p1.cpp
new file mode 100644
index 0000000..eceffcf
--- /dev/null
+++ b/clang/test/CXX/class.access/class.access.nest/p1.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Derived from GNU's std::string
+namespace test0 {
+ class A {
+ struct B {
+ unsigned long length;
+ };
+ struct C : B {
+ static const unsigned long max_length;
+ };
+ };
+
+ const unsigned long A::C::max_length = sizeof(B);
+}
+
+// Example from the standard.
+namespace test1 {
+ class E {
+ int x;
+ class B {};
+
+ class I {
+ B b;
+ int y; // expected-note {{declared private here}}
+ void f(E* p, int i) {
+ p->x = i;
+ }
+ };
+
+ int g(I* p) { return p->y; } // expected-error {{'y' is a private member of 'test1::E::I'}}
+ };
+}
diff --git a/clang/test/CXX/class.access/class.friend/p1.cpp b/clang/test/CXX/class.access/class.friend/p1.cpp
new file mode 100644
index 0000000..68ff83f
--- /dev/null
+++ b/clang/test/CXX/class.access/class.friend/p1.cpp
@@ -0,0 +1,356 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++'0x [class.friend] p1:
+// A friend of a class is a function or class that is given permission to use
+// the private and protected member names from the class. A class specifies
+// its friends, if any, by way of friend declarations. Such declarations give
+// special access rights to the friends, but they do not make the nominated
+// friends members of the befriending class.
+
+struct S { static void f(); };
+S* g() { return 0; }
+
+struct X {
+ friend struct S;
+ friend S* g();
+};
+
+void test1() {
+ S s;
+ g()->f();
+ S::f();
+ X::g(); // expected-error{{no member named 'g' in 'X'}}
+ X::S x_s; // expected-error{{no member named 'S' in 'X'}}
+ X x;
+ x.g(); // expected-error{{no member named 'g' in 'X'}}
+}
+
+// Test that we recurse through namespaces to find already declared names, but
+// new names are declared within the enclosing namespace.
+namespace N {
+ struct X {
+ friend struct S;
+ friend S* g();
+
+ friend struct S2;
+ friend struct S2* g2();
+ };
+
+ struct S2 { static void f2(); };
+ S2* g2() { return 0; }
+
+ void test() {
+ g()->f();
+ S s;
+ S::f();
+ X::g(); // expected-error{{no member named 'g' in 'N::X'}}
+ X::S x_s; // expected-error{{no member named 'S' in 'N::X'}}
+ X x;
+ x.g(); // expected-error{{no member named 'g' in 'N::X'}}
+
+ g2();
+ S2 s2;
+ ::g2(); // expected-error{{no member named 'g2' in the global namespace}}
+ ::S2 g_s2; // expected-error{{no member named 'S2' in the global namespace}}
+ X::g2(); // expected-error{{no member named 'g2' in 'N::X'}}
+ X::S2 x_s2; // expected-error{{no member named 'S2' in 'N::X'}}
+ x.g2(); // expected-error{{no member named 'g2' in 'N::X'}}
+ }
+}
+
+namespace test0 {
+ class ClassFriend {
+ void test();
+ };
+
+ class MemberFriend {
+ void test();
+ };
+
+ void declared_test();
+
+ class Class {
+ static void member(); // expected-note 2 {{declared private here}}
+
+ friend class ClassFriend;
+ friend class UndeclaredClassFriend;
+
+ friend void undeclared_test();
+ friend void declared_test();
+ friend void MemberFriend::test();
+ };
+
+ void declared_test() {
+ Class::member();
+ }
+
+ void undeclared_test() {
+ Class::member();
+ }
+
+ void unfriended_test() {
+ Class::member(); // expected-error {{'member' is a private member of 'test0::Class'}}
+ }
+
+ void ClassFriend::test() {
+ Class::member();
+ }
+
+ void MemberFriend::test() {
+ Class::member();
+ }
+
+ class UndeclaredClassFriend {
+ void test() {
+ Class::member();
+ }
+ };
+
+ class ClassNonFriend {
+ void test() {
+ Class::member(); // expected-error {{'member' is a private member of 'test0::Class'}}
+ }
+ };
+}
+
+// Make sure that friends have access to inherited protected members.
+namespace test2 {
+ struct X;
+
+ class ilist_half_node {
+ friend struct ilist_walker_bad;
+ X *Prev;
+ protected:
+ X *getPrev() { return Prev; } // expected-note{{member is declared here}}
+ };
+
+ class ilist_node : private ilist_half_node { // expected-note {{declared private here}} expected-note {{constrained by private inheritance here}}
+ friend struct ilist_walker;
+ X *Next;
+ X *getNext() { return Next; } // expected-note {{declared private here}}
+ };
+
+ struct X : ilist_node {};
+
+ struct ilist_walker {
+ static X *getPrev(X *N) { return N->getPrev(); }
+ static X *getNext(X *N) { return N->getNext(); }
+ };
+
+ struct ilist_walker_bad {
+ static X *getPrev(X *N) { return N->getPrev(); } // \
+ // expected-error {{'getPrev' is a private member of 'test2::ilist_half_node'}} \
+ // expected-error {{cannot cast 'test2::X' to its private base class 'test2::ilist_half_node'}}
+
+ static X *getNext(X *N) { return N->getNext(); } // \
+ // expected-error {{'getNext' is a private member of 'test2::ilist_node'}}
+ };
+}
+
+namespace test3 {
+ class A { protected: int x; }; // expected-note {{declared protected here}}
+
+ class B : public A {
+ friend int foo(B*);
+ };
+
+ int foo(B *p) {
+ return p->x;
+ }
+
+ int foo(const B *p) {
+ return p->x; // expected-error {{'x' is a protected member of 'test3::A'}}
+ }
+}
+
+namespace test3a {
+ class A { protected: int x; };
+
+ class B : public A {
+ friend int foo(B*);
+ };
+
+ int foo(B * const p) {
+ return p->x;
+ }
+}
+
+namespace test4 {
+ template <class T> class Holder {
+ T object;
+ friend bool operator==(Holder &a, Holder &b) {
+ return a.object == b.object; // expected-error {{invalid operands to binary expression}}
+ }
+ };
+
+ struct Inequal {};
+ bool test() {
+ Holder<Inequal> a, b;
+ return a == b; // expected-note {{requested here}}
+ }
+}
+
+
+// PR6174
+namespace test5 {
+ namespace ns {
+ class A;
+ }
+
+ class ns::A {
+ private: int x;
+ friend class B;
+ };
+
+ namespace ns {
+ class B {
+ int test(A *p) { return p->x; }
+ };
+ }
+}
+
+// PR6207
+namespace test6 {
+ struct A {};
+
+ struct B {
+ friend A::A();
+ friend A::~A();
+ friend A &A::operator=(const A&);
+ };
+}
+
+namespace test7 {
+ template <class T> struct X {
+ X();
+ ~X();
+ void foo();
+ void bar();
+ };
+
+ class A {
+ friend void X<int>::foo();
+ friend X<int>::X();
+ friend X<int>::X(const X&);
+
+ private:
+ A(); // expected-note 2 {{declared private here}}
+ };
+
+ template<> void X<int>::foo() {
+ A a;
+ }
+
+ template<> void X<int>::bar() {
+ A a; // expected-error {{calling a private constructor}}
+ }
+
+ template<> X<int>::X() {
+ A a;
+ }
+
+ template<> X<int>::~X() {
+ A a; // expected-error {{calling a private constructor}}
+ }
+}
+
+// Return types, parameters and default arguments to friend functions.
+namespace test8 {
+ class A {
+ typedef int I; // expected-note 4 {{declared private here}}
+ static const I x = 0; // expected-note {{implicitly declared private here}}
+ friend I f(I i);
+ template<typename T> friend I g(I i);
+ };
+
+ const A::I A::x;
+ A::I f(A::I i = A::x) {}
+ template<typename T> A::I g(A::I i) {
+ T t;
+ }
+ template A::I g<A::I>(A::I i);
+
+ A::I f2(A::I i = A::x) {} // expected-error 3 {{is a private member of}}
+ template<typename T> A::I g2(A::I i) { // expected-error 2 {{is a private member of}}
+ T t;
+ }
+ template A::I g2<A::I>(A::I i);
+}
+
+// PR6885
+namespace test9 {
+ class B {
+ friend class test9;
+ };
+}
+
+// PR7230
+namespace test10 {
+ extern "C" void f(void);
+ extern "C" void g(void);
+
+ namespace NS {
+ class C {
+ void foo(void); // expected-note {{declared private here}}
+ friend void test10::f(void);
+ };
+ static C* bar;
+ }
+
+ void f(void) {
+ NS::bar->foo();
+ }
+
+ void g(void) {
+ NS::bar->foo(); // expected-error {{private member}}
+ }
+}
+
+// PR8705
+namespace test11 {
+ class A {
+ void test0(int);
+ void test1(int);
+ void test2(int);
+ void test3(int);
+ };
+
+ class B {
+ typedef int private_type; // expected-note 2 {{implicitly declared private here}}
+ friend void A::test0(int);
+ friend void A::test1(int);
+ };
+
+ void A::test0(B::private_type x) {}
+ void A::test1(int x = B::private_type()) {}
+ void A::test2(B::private_type x) {} // expected-error {{'private_type' is a private member of 'test11::B'}}
+ void A::test3(int x = B::private_type()) {} // expected-error {{'private_type' is a private member of 'test11::B'}}
+}
+
+
+// PR9221
+namespace test12 {
+ struct A {
+ void foo();
+ };
+ class B : private A {
+ friend void A::foo();
+ void *mem;
+ };
+ void A::foo() {
+ void *var = static_cast<B*>(this)->mem;
+ }
+}
+
+namespace PR9103 {
+ struct base {
+ protected:
+ static void foo(void) {}
+ };
+
+ struct cls: base {
+ friend void bar(void) {
+ base::foo();
+ }
+ };
+}
diff --git a/clang/test/CXX/class.access/class.friend/p11.cpp b/clang/test/CXX/class.access/class.friend/p11.cpp
new file mode 100644
index 0000000..a05b2d2
--- /dev/null
+++ b/clang/test/CXX/class.access/class.friend/p11.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// rdar://problem/8540720
+namespace test0 {
+ void foo() {
+ void bar();
+ class A {
+ friend void bar();
+ };
+ }
+}
+
+namespace test1 {
+ void foo() {
+ class A {
+ friend void bar(); // expected-error {{no matching function found in local scope}}
+ };
+ }
+}
diff --git a/clang/test/CXX/class.access/class.friend/p2-cxx03.cpp b/clang/test/CXX/class.access/class.friend/p2-cxx03.cpp
new file mode 100644
index 0000000..f8cabfd
--- /dev/null
+++ b/clang/test/CXX/class.access/class.friend/p2-cxx03.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T>
+class X0 {
+ friend T; // expected-warning{{non-class friend type 'T' is a C++11 extension}}
+};
+
+class X1 { };
+enum E1 { };
+X0<X1> x0a;
+X0<X1 *> x0b;
+X0<int> x0c;
+X0<E1> x0d;
+
diff --git a/clang/test/CXX/class.access/class.friend/p3-cxx0x.cpp b/clang/test/CXX/class.access/class.friend/p3-cxx0x.cpp
new file mode 100644
index 0000000..00fc0a3
--- /dev/null
+++ b/clang/test/CXX/class.access/class.friend/p3-cxx0x.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+template<typename T>
+class X0 {
+ friend T;
+};
+
+class Y1 { };
+enum E1 { };
+X0<Y1> x0a;
+X0<Y1 *> x0b;
+X0<int> x0c;
+X0<E1> x0d;
+
+template<typename T>
+class X1 {
+ friend typename T::type; // expected-error{{no type named 'type' in 'Y1'}}
+};
+
+struct Y2 {
+ struct type { };
+};
+
+struct Y3 {
+ typedef int type;
+};
+
+X1<Y2> x1a;
+X1<Y3> x1b;
+X1<Y1> x1c; // expected-note{{in instantiation of template class 'X1<Y1>' requested here}}
diff --git a/clang/test/CXX/class.access/class.friend/p6.cpp b/clang/test/CXX/class.access/class.friend/p6.cpp
new file mode 100644
index 0000000..7f7d909
--- /dev/null
+++ b/clang/test/CXX/class.access/class.friend/p6.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f1();
+
+struct X {
+ void f2();
+};
+
+struct Y {
+ friend void ::f1() { } // expected-error{{friend function definition cannot be qualified with '::'}}
+ friend void X::f2() { } // expected-error{{friend function definition cannot be qualified with 'X::'}}
+};
+
+void local() {
+ void f();
+
+ struct Local {
+ friend void f() { } // expected-error{{friend function cannot be defined in a local class}}
+ };
+}
diff --git a/clang/test/CXX/class.access/class.protected/p1-cxx11.cpp b/clang/test/CXX/class.access/class.protected/p1-cxx11.cpp
new file mode 100644
index 0000000..dc9b20d
--- /dev/null
+++ b/clang/test/CXX/class.access/class.protected/p1-cxx11.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR12497
+namespace test0 {
+ class A {
+ protected:
+ A() {}
+ A(const A &) {}
+ ~A() {}
+ A &operator=(const A &a) { return *this; }
+ };
+
+ class B : public A {};
+
+ void test() {
+ B b1;
+ B b2 = b1;
+ b1 = b2;
+ }
+}
diff --git a/clang/test/CXX/class.access/class.protected/p1.cpp b/clang/test/CXX/class.access/class.protected/p1.cpp
new file mode 100644
index 0000000..c9491e1
--- /dev/null
+++ b/clang/test/CXX/class.access/class.protected/p1.cpp
@@ -0,0 +1,519 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace test0 {
+ class A {
+ protected: int x; // expected-note 3 {{declared}} \
+ // expected-note {{member is declared here}}
+ static int sx; // expected-note 3 {{declared}} \
+ // expected-note {{member is declared here}}
+ };
+ class B : public A {
+ };
+ class C : protected A { // expected-note {{declared}}
+ };
+ class D : private B { // expected-note 3 {{constrained}}
+ };
+
+ void test(A &a) {
+ (void) a.x; // expected-error {{'x' is a protected member}}
+ (void) a.sx; // expected-error {{'sx' is a protected member}}
+ }
+ void test(B &b) {
+ (void) b.x; // expected-error {{'x' is a protected member}}
+ (void) b.sx; // expected-error {{'sx' is a protected member}}
+ }
+ void test(C &c) {
+ (void) c.x; // expected-error {{'x' is a protected member}} expected-error {{protected base class}}
+ (void) c.sx; // expected-error {{'sx' is a protected member}}
+ }
+ void test(D &d) {
+ (void) d.x; // expected-error {{'x' is a private member}} expected-error {{private base class}}
+ (void) d.sx; // expected-error {{'sx' is a private member}}
+ }
+}
+
+namespace test1 {
+ class A {
+ protected: int x;
+ static int sx;
+ static void test(A&);
+ };
+ class B : public A {
+ static void test(B&);
+ };
+ class C : protected A {
+ static void test(C&);
+ };
+ class D : private B {
+ static void test(D&);
+ };
+
+ void A::test(A &a) {
+ (void) a.x;
+ (void) a.sx;
+ }
+ void B::test(B &b) {
+ (void) b.x;
+ (void) b.sx;
+ }
+ void C::test(C &c) {
+ (void) c.x;
+ (void) c.sx;
+ }
+ void D::test(D &d) {
+ (void) d.x;
+ (void) d.sx;
+ }
+}
+
+namespace test2 {
+ class A {
+ protected: int x; // expected-note 3 {{can only access this member on an object of type}}
+ static int sx;
+ static void test(A&);
+ };
+ class B : public A {
+ static void test(A&);
+ };
+ class C : protected A {
+ static void test(A&);
+ };
+ class D : private B {
+ static void test(A&);
+ };
+
+ void A::test(A &a) {
+ (void) a.x;
+ (void) a.sx;
+ }
+ void B::test(A &a) {
+ (void) a.x; // expected-error {{'x' is a protected member}}
+ (void) a.sx;
+ }
+ void C::test(A &a) {
+ (void) a.x; // expected-error {{'x' is a protected member}}
+ (void) a.sx;
+ }
+ void D::test(A &a) {
+ (void) a.x; // expected-error {{'x' is a protected member}}
+ (void) a.sx;
+ }
+}
+
+namespace test3 {
+ class B;
+ class A {
+ protected: int x; //expected-note {{declared protected}} // expected-note {{can only access this member on an object of type}}
+ static int sx;
+ static void test(B&);
+ };
+ class B : public A {
+ static void test(B&);
+ };
+ class C : protected A {
+ static void test(B&);
+ };
+ class D : private B {
+ static void test(B&);
+ };
+
+ void A::test(B &b) {
+ (void) b.x;
+ (void) b.sx;
+ }
+ void B::test(B &b) {
+ (void) b.x;
+ (void) b.sx;
+ }
+ void C::test(B &b) {
+ (void) b.x; // expected-error {{'x' is a protected member}}
+ (void) b.sx;
+ }
+ void D::test(B &b) {
+ (void) b.x; // expected-error {{'x' is a protected member}}
+ (void) b.sx;
+ }
+}
+
+namespace test4 {
+ class C;
+ class A {
+ protected: int x; // expected-note 2{{declared protected here}} expected-note{{member is declared here}}
+ static int sx; // expected-note 3{{member is declared here}}
+ static void test(C&);
+ };
+ class B : public A {
+ static void test(C&);
+ };
+ class C : protected A { // expected-note 4 {{constrained}} expected-note 3 {{declared}}
+ static void test(C&);
+ };
+ class D : private B {
+ static void test(C&);
+ };
+
+ void A::test(C &c) {
+ (void) c.x; // expected-error {{'x' is a protected member}} \
+ // expected-error {{protected base class}}
+ (void) c.sx; // expected-error {{'sx' is a protected member}}
+ }
+ void B::test(C &c) {
+ (void) c.x; // expected-error {{'x' is a protected member}} \
+ // expected-error {{protected base class}}
+ (void) c.sx; // expected-error {{'sx' is a protected member}}
+ }
+ void C::test(C &c) {
+ (void) c.x;
+ (void) c.sx;
+ }
+ void D::test(C &c) {
+ (void) c.x; // expected-error {{'x' is a protected member}} \
+ // expected-error {{protected base class}}
+ (void) c.sx; // expected-error {{'sx' is a protected member}}
+ }
+}
+
+namespace test5 {
+ class D;
+ class A {
+ protected: int x; // expected-note 3{{member is declared here}}
+ static int sx; // expected-note 3{{member is declared here}}
+ static void test(D&);
+ };
+ class B : public A {
+ static void test(D&);
+ };
+ class C : protected A {
+ static void test(D&);
+ };
+ class D : private B { // expected-note 9 {{constrained}}
+ static void test(D&);
+ };
+
+ void A::test(D &d) {
+ (void) d.x; // expected-error {{'x' is a private member}} \
+ // expected-error {{cannot cast}}
+ (void) d.sx; // expected-error {{'sx' is a private member}}
+ }
+ void B::test(D &d) {
+ (void) d.x; // expected-error {{'x' is a private member}} \
+ // expected-error {{cannot cast}}
+ (void) d.sx; // expected-error {{'sx' is a private member}}
+ }
+ void C::test(D &d) {
+ (void) d.x; // expected-error {{'x' is a private member}} \
+ // expected-error {{cannot cast}}
+ (void) d.sx; // expected-error {{'sx' is a private member}}
+ }
+ void D::test(D &d) {
+ (void) d.x;
+ (void) d.sx;
+ }
+}
+
+namespace test6 {
+ class Static {};
+ class A {
+ protected:
+ void foo(int); // expected-note 3 {{can only access this member on an object of type}}
+ void foo(long);
+ static void foo(Static);
+
+ static void test(A&);
+ };
+ class B : public A {
+ static void test(A&);
+ };
+ class C : protected A {
+ static void test(A&);
+ };
+ class D : private B {
+ static void test(A&);
+ };
+
+ void A::test(A &a) {
+ a.foo(10);
+ a.foo(Static());
+ }
+ void B::test(A &a) {
+ a.foo(10); // expected-error {{'foo' is a protected member}}
+ a.foo(Static());
+ }
+ void C::test(A &a) {
+ a.foo(10); // expected-error {{'foo' is a protected member}}
+ a.foo(Static());
+ }
+ void D::test(A &a) {
+ a.foo(10); // expected-error {{'foo' is a protected member}}
+ a.foo(Static());
+ }
+}
+
+namespace test7 {
+ class Static {};
+ class A {
+ protected:
+ void foo(int); // expected-note 3 {{must name member using the type of the current context}}
+ void foo(long);
+ static void foo(Static);
+
+ static void test();
+ };
+ class B : public A {
+ static void test();
+ };
+ class C : protected A {
+ static void test();
+ };
+ class D : private B {
+ static void test();
+ };
+
+ void A::test() {
+ void (A::*x)(int) = &A::foo;
+ void (*sx)(Static) = &A::foo;
+ }
+ void B::test() {
+ void (A::*x)(int) = &A::foo; // expected-error {{'foo' is a protected member}}
+ void (*sx)(Static) = &A::foo;
+ }
+ void C::test() {
+ void (A::*x)(int) = &A::foo; // expected-error {{'foo' is a protected member}}
+ void (*sx)(Static) = &A::foo;
+ }
+ void D::test() {
+ void (A::*x)(int) = &A::foo; // expected-error {{'foo' is a protected member}}
+ void (*sx)(Static) = &A::foo;
+ }
+}
+
+namespace test8 {
+ class Static {};
+ class A {
+ protected:
+ void foo(int); // expected-note 3 {{must name member using the type of the current context}}
+ void foo(long);
+ static void foo(Static);
+
+ static void test();
+ };
+ class B : public A {
+ static void test();
+ };
+ class C : protected A {
+ static void test();
+ };
+ class D : private B {
+ static void test();
+ };
+ void call(void (A::*)(int));
+ void calls(void (*)(Static));
+
+ void A::test() {
+ call(&A::foo);
+ calls(&A::foo);
+ }
+ void B::test() {
+ call(&A::foo); // expected-error {{'foo' is a protected member}}
+ calls(&A::foo);
+ }
+ void C::test() {
+ call(&A::foo); // expected-error {{'foo' is a protected member}}
+ calls(&A::foo);
+ }
+ void D::test() {
+ call(&A::foo); // expected-error {{'foo' is a protected member}}
+ calls(&A::foo);
+ }
+}
+
+namespace test9 {
+ class A { // expected-note {{member is declared here}}
+ protected: int foo(); // expected-note 4 {{declared}} expected-note 2 {{can only access this member on an object of type}} expected-note {{member is declared here}}
+ };
+
+ class B : public A { // expected-note {{member is declared here}}
+ friend class D;
+ };
+
+ class C : protected B { // expected-note {{declared}} \
+ // expected-note 9 {{constrained}}
+ };
+
+ class D : public A {
+ static void test(A &a) {
+ a.foo(); // expected-error {{'foo' is a protected member}}
+ a.A::foo(); // expected-error {{'foo' is a protected member}}
+ a.B::foo();
+ a.C::foo(); // expected-error {{'foo' is a protected member}}
+ }
+
+ static void test(B &b) {
+ b.foo();
+ b.A::foo();
+ b.B::foo();
+ b.C::foo(); // expected-error {{'foo' is a protected member}}
+ }
+
+ static void test(C &c) {
+ c.foo(); // expected-error {{'foo' is a protected member}} \
+ // expected-error {{cannot cast}}
+ c.A::foo(); // expected-error {{'A' is a protected member}} \
+ // expected-error {{cannot cast}}
+ c.B::foo(); // expected-error {{'B' is a protected member}} \
+ // expected-error {{cannot cast}}
+ c.C::foo(); // expected-error {{'foo' is a protected member}} \
+ // expected-error {{cannot cast}}
+ }
+
+ static void test(D &d) {
+ d.foo();
+ d.A::foo();
+ d.B::foo();
+ d.C::foo(); // expected-error {{'foo' is a protected member}}
+ }
+ };
+}
+
+namespace test10 {
+ template<typename T> class A {
+ protected:
+ int foo();
+ int foo() const;
+
+ ~A() { foo(); }
+ };
+
+ template class A<int>;
+}
+
+// rdar://problem/8360285: class.protected friendship
+namespace test11 {
+ class A {
+ protected:
+ int foo();
+ };
+
+ class B : public A {
+ friend class C;
+ };
+
+ class C {
+ void test() {
+ B b;
+ b.A::foo();
+ }
+ };
+}
+
+// This friendship is considered because a public member of A would be
+// a private member of C.
+namespace test12 {
+ class A { protected: int foo(); };
+ class B : public virtual A {};
+ class C : private B { friend void test(); };
+ class D : private C, public virtual A {};
+
+ void test() {
+ D d;
+ d.A::foo();
+ }
+}
+
+// This friendship is not considered because a public member of A is
+// inaccessible in C.
+namespace test13 {
+ class A { protected: int foo(); }; // expected-note {{can only access this member on an object of type}}
+ class B : private virtual A {};
+ class C : private B { friend void test(); };
+ class D : public virtual A {};
+
+ void test() {
+ D d;
+ d.A::foo(); // expected-error {{protected member}}
+ }
+}
+
+// PR8058
+namespace test14 {
+ class A {
+ protected:
+ template <class T> void temp(T t); // expected-note {{must name member using the type of the current context}}
+
+ void nontemp(int); // expected-note {{must name member using the type of the current context}}
+
+ template <class T> void ovl_temp(T t); // expected-note {{must name member using the type of the current context}}
+ void ovl_temp(float);
+
+ void ovl_nontemp(int); // expected-note {{must name member using the type of the current context}}
+ void ovl_nontemp(float);
+
+ template <class T> void ovl_withtemp(T);
+ void ovl_withtemp(int); // expected-note {{must name member using the type of the current context}}
+ };
+
+ class B : public A {
+ void use() {
+ void (A::*ptr)(int);
+ ptr = &A::temp; // expected-error {{protected member}}
+ ptr = &A::nontemp; // expected-error {{protected member}}
+ ptr = &A::ovl_temp; // expected-error {{protected member}}
+ ptr = &A::ovl_nontemp; // expected-error {{protected member}}
+ ptr = &A::ovl_withtemp; // expected-error {{protected member}}
+ }
+ };
+}
+
+namespace test15 {
+ class A {
+ protected:
+ A(); // expected-note 2 {{protected constructor can only be used to construct a base class subobject}}
+ A(const A &); // expected-note {{protected constructor can only be used to construct a base class subobject}}
+ ~A(); // expected-note 3 {{protected destructor can only be used to destroy a base class subobject}}
+ };
+
+ class B : public A {
+ // The uses here are fine.
+ B() {}
+ B(int i) : A() {}
+ ~B() {}
+
+ // All these uses are bad.
+
+ void test0() {
+ A a; // expected-error {{protected constructor}} expected-error {{protected destructor}}
+ }
+
+ A *test1() {
+ return new A(); // expected-error {{protected constructor}}
+ }
+
+ void test2(A *a) {
+ delete a; // expected-error {{protected destructor}}
+ }
+
+ A test3(A *a) {
+ return *a; // expected-error {{protected constructor}}
+ }
+
+ void test4(A *a) {
+ a->~A(); // expected-error {{protected member}}
+ }
+ };
+}
+
+namespace test16 {
+ class A {
+ protected:
+ ~A();
+ };
+
+ class B : public virtual A {
+ public:
+ ~B() {}
+ };
+
+ class C : public B {
+ ~C() {}
+ };
+}
diff --git a/clang/test/CXX/class.access/p4.cpp b/clang/test/CXX/class.access/p4.cpp
new file mode 100644
index 0000000..5ad738b
--- /dev/null
+++ b/clang/test/CXX/class.access/p4.cpp
@@ -0,0 +1,510 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
+
+// C++0x [class.access]p4:
+
+// Access control is applied uniformly to all names, whether the
+// names are referred to from declarations or expressions. In the
+// case of overloaded function names, access control is applied to
+// the function selected by overload resolution.
+
+class Public {} PublicInst;
+class Protected {} ProtectedInst;
+class Private {} PrivateInst;
+
+namespace test0 {
+ class A {
+ public:
+ void foo(Public&);
+ protected:
+ void foo(Protected&); // expected-note 2 {{declared protected here}}
+ private:
+ void foo(Private&); // expected-note 2 {{declared private here}}
+ };
+
+ void test(A *op) {
+ op->foo(PublicInst);
+ op->foo(ProtectedInst); // expected-error {{'foo' is a protected member}}
+ op->foo(PrivateInst); // expected-error {{'foo' is a private member}}
+
+ void (A::*a)(Public&) = &A::foo;
+ void (A::*b)(Protected&) = &A::foo; // expected-error {{'foo' is a protected member}}
+ void (A::*c)(Private&) = &A::foo; // expected-error {{'foo' is a private member}}
+ }
+}
+
+// Member operators.
+namespace test1 {
+ class A {
+ public:
+ void operator+(Public&);
+ void operator[](Public&);
+ void operator()(Public&);
+ typedef void (*PublicSurrogate)(Public&);
+ operator PublicSurrogate() const;
+ protected:
+ void operator+(Protected&); // expected-note {{declared protected here}}
+ void operator[](Protected&); // expected-note {{declared protected here}}
+ void operator()(Protected&); // expected-note {{declared protected here}}
+ typedef void (*ProtectedSurrogate)(Protected&);
+ operator ProtectedSurrogate() const; // expected-note {{declared protected here}}
+ private:
+ void operator+(Private&); // expected-note {{declared private here}}
+ void operator[](Private&); // expected-note {{declared private here}}
+ void operator()(Private&); // expected-note {{declared private here}}
+ void operator-(); // expected-note {{declared private here}}
+ typedef void (*PrivateSurrogate)(Private&);
+ operator PrivateSurrogate() const; // expected-note {{declared private here}}
+ };
+ void operator+(const A &, Public&);
+ void operator+(const A &, Protected&);
+ void operator+(const A &, Private&);
+ void operator-(const A &);
+
+ void test(A &a, Public &pub, Protected &prot, Private &priv) {
+ a + pub;
+ a + prot; // expected-error {{'operator+' is a protected member}}
+ a + priv; // expected-error {{'operator+' is a private member}}
+ a[pub];
+ a[prot]; // expected-error {{'operator[]' is a protected member}}
+ a[priv]; // expected-error {{'operator[]' is a private member}}
+ a(pub);
+ a(prot); // expected-error {{'operator()' is a protected member}}
+ a(priv); // expected-error {{'operator()' is a private member}}
+ -a; // expected-error {{'operator-' is a private member}}
+
+ const A &ca = a;
+ ca + pub;
+ ca + prot;
+ ca + priv;
+ -ca;
+ // These are all surrogate calls
+ ca(pub);
+ ca(prot); // expected-error {{'operator void (*)(class Protected &)' is a protected member}}
+ ca(priv); // expected-error {{'operator void (*)(class Private &)' is a private member}}
+ }
+}
+
+// Implicit constructor calls.
+namespace test2 {
+ class A {
+ private:
+ A(); // expected-note 3 {{declared private here}}
+
+ static A foo;
+ };
+
+ A a; // expected-error {{calling a private constructor}}
+ A A::foo; // okay
+
+ class B : A { }; // expected-error {{base class 'test2::A' has private default constructor}}
+ B b; // expected-note{{implicit default constructor}}
+
+ class C : virtual A {
+ public:
+ C();
+ };
+
+ class D : C { }; // expected-error {{inherited virtual base class 'test2::A' has private default constructor}}
+ D d; // expected-note{{implicit default constructor}}
+}
+
+// Implicit destructor calls.
+namespace test3 {
+ class A {
+ private:
+ ~A(); // expected-note 2 {{declared private here}}
+ static A foo;
+ };
+
+ A a; // expected-error {{variable of type 'test3::A' has private destructor}}
+ A A::foo;
+
+ void foo(A param) { // okay
+ A local; // expected-error {{variable of type 'test3::A' has private destructor}}
+ }
+
+ template <unsigned N> class Base { ~Base(); }; // expected-note 14 {{declared private here}}
+ class Base2 : virtual Base<2> { ~Base2(); }; // expected-note 3 {{declared private here}} \
+ // expected-error {{base class 'Base<2>' has private destructor}}
+ class Base3 : virtual Base<3> { public: ~Base3(); }; // expected-error {{base class 'Base<3>' has private destructor}}
+
+ // These don't cause diagnostics because we don't need the destructor.
+ class Derived0 : Base<0> { ~Derived0(); };
+ class Derived1 : Base<1> { };
+
+ class Derived2 : // expected-error {{inherited virtual base class 'Base<2>' has private destructor}} \
+ // expected-error {{inherited virtual base class 'Base<3>' has private destructor}}
+ Base<0>, // expected-error {{base class 'Base<0>' has private destructor}}
+ virtual Base<1>, // expected-error {{base class 'Base<1>' has private destructor}}
+ Base2, // expected-error {{base class 'test3::Base2' has private destructor}}
+ virtual Base3
+ {
+ ~Derived2() {}
+ };
+
+ class Derived3 : // expected-error 2 {{inherited virtual base class 'Base<2>' has private destructor}} \
+ // expected-error 2 {{inherited virtual base class 'Base<3>' has private destructor}} \
+ // expected-note 2{{implicit default constructor}}
+ Base<0>, // expected-error 2 {{base class 'Base<0>' has private destructor}}
+ virtual Base<1>, // expected-error 2 {{base class 'Base<1>' has private destructor}}
+ Base2, // expected-error 2 {{base class 'test3::Base2' has private destructor}}
+ virtual Base3
+ {};
+ Derived3 d3; // expected-note {{implicit default constructor}}\
+ // expected-note{{implicit default destructor}}}
+}
+
+// Conversion functions.
+namespace test4 {
+ class Base {
+ private:
+ operator Private(); // expected-note 4 {{declared private here}}
+ public:
+ operator Public(); // expected-note 2{{member is declared here}}
+ };
+
+ class Derived1 : private Base { // expected-note 2 {{declared private here}} \
+ // expected-note {{constrained by private inheritance}}
+ Private test1() { return *this; } // expected-error {{'operator Private' is a private member}}
+ Public test2() { return *this; }
+ };
+ Private test1(Derived1 &d) { return d; } // expected-error {{'operator Private' is a private member}} \
+ // expected-error {{cannot cast 'test4::Derived1' to its private base class}}
+ Public test2(Derived1 &d) { return d; } // expected-error {{cannot cast 'test4::Derived1' to its private base class}} \
+ // expected-error {{'operator Public' is a private member}}
+
+
+ class Derived2 : public Base {
+ Private test1() { return *this; } // expected-error {{'operator Private' is a private member}}
+ Public test2() { return *this; }
+ };
+ Private test1(Derived2 &d) { return d; } // expected-error {{'operator Private' is a private member}}
+ Public test2(Derived2 &d) { return d; }
+
+ class Derived3 : private Base { // expected-note {{constrained by private inheritance here}} \
+ // expected-note {{declared private here}}
+ public:
+ operator Private();
+ };
+ Private test1(Derived3 &d) { return d; }
+ Public test2(Derived3 &d) { return d; } // expected-error {{'operator Public' is a private member of 'test4::Base'}} \
+ // expected-error {{cannot cast 'test4::Derived3' to its private base class}}
+
+ class Derived4 : public Base {
+ public:
+ operator Private();
+ };
+ Private test1(Derived4 &d) { return d; }
+ Public test2(Derived4 &d) { return d; }
+}
+
+// Implicit copy assignment operator uses.
+namespace test5 {
+ class A {
+ void operator=(const A &); // expected-note 2 {{implicitly declared private here}}
+ };
+
+ class Test1 { A a; }; // expected-error {{private member}}
+ void test1() {
+ Test1 a;
+ a = Test1(); // expected-note{{implicit default copy}}
+ }
+
+ class Test2 : A {}; // expected-error {{private member}}
+ void test2() {
+ Test2 a;
+ a = Test2(); // expected-note{{implicit default copy}}
+ }
+}
+
+// Implicit copy constructor uses.
+namespace test6 {
+ class A {
+ public: A();
+ private: A(const A &); // expected-note 2 {{declared private here}}
+ };
+
+ class Test1 { A a; }; // expected-error {{field of type 'test6::A' has private copy constructor}}
+ void test1(const Test1 &t) {
+ Test1 a = t; // expected-note{{implicit default copy}}
+ }
+
+ class Test2 : A {}; // expected-error {{base class 'test6::A' has private copy constructor}}
+ void test2(const Test2 &t) {
+ Test2 a = t; // expected-note{{implicit default copy}}
+ }
+}
+
+// Redeclaration lookups are not accesses.
+namespace test7 {
+ class A {
+ int private_member;
+ };
+ class B : A {
+ int foo(int private_member) {
+ return 0;
+ }
+ };
+}
+
+// Ignored operator new and delete overloads are not
+namespace test8 {
+ typedef __typeof__(sizeof(int)) size_t;
+
+ class A {
+ void *operator new(size_t s);
+ void operator delete(void *p);
+ public:
+ void *operator new(size_t s, int n);
+ void operator delete(void *p, int n);
+ };
+
+ void test() {
+ new (2) A();
+ }
+}
+
+// Don't silently upgrade forbidden-access paths to private.
+namespace test9 {
+ class A {
+ public: static int x; // expected-note {{member is declared here}}
+ };
+ class B : private A { // expected-note {{constrained by private inheritance here}}
+ };
+ class C : public B {
+ static int getX() { return x; } // expected-error {{'x' is a private member of 'test9::A'}}
+ };
+}
+
+namespace test10 {
+ class A {
+ enum {
+ value = 10 // expected-note {{declared private here}}
+ };
+ friend class C;
+ };
+
+ class B {
+ enum {
+ value = A::value // expected-error {{'value' is a private member of 'test10::A'}}
+ };
+ };
+
+ class C {
+ enum {
+ value = A::value
+ };
+ };
+}
+
+namespace test11 {
+ class A {
+ protected: virtual ~A();
+ };
+
+ class B : public A {
+ ~B();
+ };
+
+ B::~B() {};
+}
+
+namespace test12 {
+ class A {
+ int x;
+
+ void foo() {
+ class Local {
+ int foo(A *a) {
+ return a->x;
+ }
+ };
+ }
+ };
+}
+
+namespace test13 {
+ struct A {
+ int x;
+ unsigned foo() const;
+ };
+
+ struct B : protected A {
+ using A::foo;
+ using A::x;
+ };
+
+ void test() {
+ A *d;
+ d->foo();
+ (void) d->x;
+ }
+}
+
+// Destructors for temporaries.
+namespace test14 {
+ class A {
+ private: ~A(); // expected-note {{declared private here}}
+ };
+ A foo();
+
+ void test() {
+ foo(); // expected-error {{temporary of type 'test14::A' has private destructor}}
+ }
+
+ class X {
+ ~X(); // expected-note {{declared private here}}
+ };
+
+ struct Y1 {
+ operator X();
+ };
+
+ void g() {
+ const X &xr = Y1(); // expected-error{{temporary of type 'test14::X' has private destructor}}
+ }
+}
+
+// PR 7024
+namespace test15 {
+ template <class T> class A {
+ private:
+ int private_foo; // expected-note {{declared private here}}
+ static int private_sfoo; // expected-note {{declared private here}}
+ protected:
+ int protected_foo; // expected-note 3 {{declared protected here}} // expected-note {{can only access this member on an object of type 'test15::B<int>'}}
+ static int protected_sfoo; // expected-note 3 {{declared protected here}}
+
+ int test1(A<int> &a) {
+ return a.private_foo; // expected-error {{private member}}
+ }
+
+ int test2(A<int> &a) {
+ return a.private_sfoo; // expected-error {{private member}}
+ }
+
+ int test3(A<int> &a) {
+ return a.protected_foo; // expected-error {{protected member}}
+ }
+
+ int test4(A<int> &a) {
+ return a.protected_sfoo; // expected-error {{protected member}}
+ }
+ };
+
+ template class A<int>;
+ template class A<long>; // expected-note 4 {{in instantiation}}
+
+ template <class T> class B : public A<T> {
+ // TODO: These first two accesses can be detected as ill-formed at
+ // definition time because they're member accesses and A<int> can't
+ // be a subclass of B<T> for any T.
+
+ int test1(A<int> &a) {
+ return a.protected_foo; // expected-error 2 {{protected member}}
+ }
+
+ int test2(A<int> &a) {
+ return a.protected_sfoo; // expected-error {{protected member}}
+ }
+
+ int test3(B<int> &b) {
+ return b.protected_foo; // expected-error {{protected member}}
+ }
+
+ int test4(B<int> &b) {
+ return b.protected_sfoo; // expected-error {{protected member}}
+ }
+ };
+
+ template class B<int>; // expected-note {{in instantiation}}
+ template class B<long>; // expected-note 4 {{in instantiation}}
+}
+
+// PR7281
+namespace test16 {
+ class A { ~A(); }; // expected-note 2{{declared private here}}
+ void b() { throw A(); } // expected-error{{temporary of type 'test16::A' has private destructor}} \
+ // expected-error{{exception object of type 'test16::A' has private destructor}}
+}
+
+// rdar://problem/8146294
+namespace test17 {
+ class A {
+ template <typename T> class Inner { }; // expected-note {{declared private here}}
+ };
+
+ A::Inner<int> s; // expected-error {{'Inner' is a private member of 'test17::A'}}
+}
+
+namespace test18 {
+ template <class T> class A {};
+ class B : A<int> {
+ A<int> member;
+ };
+
+ // FIXME: this access to A should be forbidden (because C++ is dumb),
+ // but LookupResult can't express the necessary information to do
+ // the check, so we aggressively suppress access control.
+ class C : B {
+ A<int> member;
+ };
+}
+
+// PR8325
+namespace test19 {
+ class A { ~A(); };
+ // The destructor is not implicitly referenced here. Contrast to test16,
+ // testing PR7281, earlier in this file.
+ void b(A* x) { throw x; }
+}
+
+// PR7930
+namespace test20 {
+ class Foo {
+ Foo(); // expected-note {{implicitly declared private here}}
+ };
+ Foo::Foo() {}
+
+ void test() {
+ Foo a; // expected-error {{calling a private constructor}}
+ }
+}
+
+namespace test21 {
+ template <class T> class A {
+ void foo();
+ void bar();
+ class Inner; // expected-note {{implicitly declared private here}}
+ public:
+ void baz();
+ };
+ template <class T> class A<T>::Inner {};
+ class B {
+ template <class T> class A<T>::Inner; // expected-error{{non-friend class member 'Inner' cannot have a qualified name}}
+ };
+
+ void test() {
+ A<int>::Inner i; // expected-error {{'Inner' is a private member}}
+ }
+}
+
+namespace rdar8876150 {
+ struct A { operator bool(); };
+ struct B : private A { using A::operator bool; };
+
+ bool f() {
+ B b;
+ return !b;
+ }
+}
+
+namespace test23 {
+ template <typename T> class A {
+ A();
+ static A instance;
+ };
+
+ template <typename T> A<T> A<T>::instance;
+ template class A<int>;
+}
diff --git a/clang/test/CXX/class.access/p6.cpp b/clang/test/CXX/class.access/p6.cpp
new file mode 100644
index 0000000..fbdc87b
--- /dev/null
+++ b/clang/test/CXX/class.access/p6.cpp
@@ -0,0 +1,192 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++0x [class.access]p6:
+// All access controls in [class.access] affect the ability to
+// access a class member name from a particular scope. For purposes
+// of access control, the base-specifiers of a class and the
+// definitions of class members that appear outside of the class
+// definition are considered to be within the scope of that
+// class. In particular, access controls apply as usual to member
+// names accessed as part of a function return type, even though it
+// is not possible to determine the access privileges of that use
+// without first parsing the rest of the function
+// declarator. Similarly, access control for implicit calls to the
+// constructors, the conversion functions, or the destructor called
+// to create and destroy a static data member is performed as if
+// these calls appeared in the scope of the member's class.
+
+struct Public {}; struct Protected {}; struct Private {};
+
+namespace test0 {
+ class A {
+ typedef int type; // expected-note {{declared private here}}
+ type foo();
+ };
+
+ A::type foo() { } // expected-error {{'type' is a private member}}
+ A::type A::foo() { }
+}
+
+// conversion decls
+namespace test1 {
+ class A {
+ public:
+ A();
+ operator Public ();
+ A(Public);
+ protected:
+ operator Protected (); // expected-note {{declared protected here}}
+ A(Protected); // expected-note {{declared protected here}}
+ private:
+ operator Private (); // expected-note {{declared private here}}
+ A(Private); // expected-note {{declared private here}}
+ };
+
+ void test() {
+ A a;
+ Public pub = a;
+ Protected prot = a; // expected-error {{'operator Protected' is a protected member}}
+ Private priv = a; // expected-error {{'operator Private' is a private member}}
+ A apub = pub;
+ A aprot = prot; // expected-error {{protected constructor}}
+ A apriv = priv; // expected-error {{private constructor}}
+ }
+}
+
+// PR6967
+namespace test2 {
+ class A {
+ public:
+ template <class T> static void set(T &t, typename T::type v) {
+ t.value = v;
+ }
+ template <class T> static typename T::type get(const T &t) {
+ return t.value;
+ }
+ };
+
+ class B {
+ friend class A;
+
+ private:
+ typedef int type;
+ type value;
+ };
+
+ int test() {
+ B b;
+ A::set(b, 0);
+ return A::get(b);
+ }
+}
+
+namespace test3 {
+ class Green {}; class Blue {};
+
+ // We have to wrap this in a class because a partial specialization
+ // isn't actually in the context of the template.
+ struct Outer {
+ template <class T, class Nat> class A {
+ };
+ };
+
+ template <class T> class Outer::A<T, typename T::nature> {
+ public:
+ static void foo();
+ };
+
+ class B {
+ private: typedef Green nature;
+ friend class Outer;
+ };
+
+ void test() {
+ Outer::A<B, Green>::foo();
+ Outer::A<B, Blue>::foo(); // expected-error {{no member named 'foo'}}
+ }
+}
+
+namespace test4 {
+ template <class T> class A {
+ private: typedef int type;
+ template <class U> friend void foo(U &, typename U::type);
+ };
+
+ template <class U> void foo(U &, typename U::type) {}
+
+ void test() {
+ A<int> a;
+ foo(a, 0);
+ }
+}
+
+// PR7644
+namespace test5 {
+ class A {
+ enum Enum { E0, E1, E2 }; // expected-note 4 {{declared private here}}
+ template <Enum> void foo();
+ template <Enum> class bar;
+ };
+
+ template <A::Enum en> void A::foo() {}
+ template <A::Enum en> class A::bar {};
+
+ template <A::Enum en> void foo() {} // expected-error {{'Enum' is a private member of 'test5::A'}}
+ template <A::Enum en> class bar {}; // expected-error {{'Enum' is a private member of 'test5::A'}}
+
+ class B {
+ template <A::Enum en> void foo() {} // expected-error {{'Enum' is a private member of 'test5::A'}}
+ template <A::Enum en> class bar {}; // expected-error {{'Enum' is a private member of 'test5::A'}}
+ };
+}
+
+namespace test6 {
+ class A {
+ public: class public_inner {};
+ protected: class protected_inner {};
+ private: class private_inner {}; // expected-note {{declared private here}}
+ };
+
+ class B : A {
+ public_inner a;
+ protected_inner b;
+ private_inner c; // expected-error {{'private_inner' is a private member of 'test6::A'}}
+ };
+}
+
+// PR9229
+namespace test7 {
+ void foo(int arg[1]);
+ class A {
+ void check();
+ };
+ class B {
+ friend class A;
+ A ins;
+ };
+ void A::check() {
+ void foo(int arg[__builtin_offsetof(B, ins)]);
+ }
+}
+
+// rdar://problem/10155256
+namespace test8 {
+ class A {
+ typedef void* (A::*UnspecifiedBoolType)() const;
+ operator UnspecifiedBoolType() const; // expected-note {{implicitly declared private here}}
+ };
+
+ void test(A &a) {
+ if (a) return; // expected-error {{'operator void *(class test8::A::*)(void) const' is a private member of 'test8::A'}}
+ }
+}
+
+namespace test9 {
+ class A {
+ operator char*() const; // expected-note {{implicitly declared private here}}
+ };
+
+ void test(A &a) {
+ delete a; // expected-error {{'operator char *' is a private member of 'test9::A'}}
+ }
+}
diff --git a/clang/test/CXX/class.derived/class.abstract/p4.cpp b/clang/test/CXX/class.derived/class.abstract/p4.cpp
new file mode 100644
index 0000000..b04de21
--- /dev/null
+++ b/clang/test/CXX/class.derived/class.abstract/p4.cpp
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR6631 {
+ struct A {
+ virtual void f() = 0;
+ };
+
+ struct B : virtual A { };
+
+ struct C : virtual A {
+ virtual void f();
+ };
+
+ struct D : public B, public C {
+ virtual void f();
+ };
+
+ void f() {
+ (void)new D; // okay
+ }
+}
+
+// Check cases where we have a virtual function that is pure in one
+// subobject but not pure in another subobject.
+namespace PartlyPure {
+ struct A {
+ virtual void f() = 0; // expected-note{{unimplemented pure virtual method}}
+ };
+
+ struct B : A {
+ virtual void f();
+ };
+
+ struct C : virtual A { };
+
+ struct D : B, C { };
+
+ void f() {
+ (void) new D; // expected-error{{abstract class}}
+ }
+}
+
+namespace NonPureAlongOnePath {
+ struct A {
+ virtual void f() = 0;
+ };
+
+ struct B : virtual A {
+ virtual void f();
+ };
+
+ struct C : virtual A { };
+
+ struct D : B, C { };
+
+ void f() {
+ (void) new D; // okay
+ }
+}
+
+namespace NonPureAlongOnePath2 {
+ struct Aprime {
+ virtual void f() = 0;
+ };
+
+ struct A : Aprime {
+ };
+
+ struct B : virtual A {
+ virtual void f();
+ };
+
+ struct C : virtual A { };
+
+ struct D : B, C { };
+
+ void f() {
+ (void) new D; // okay
+ }
+}
diff --git a/clang/test/CXX/class.derived/class.abstract/p5.cpp b/clang/test/CXX/class.derived/class.abstract/p5.cpp
new file mode 100644
index 0000000..cdff931
--- /dev/null
+++ b/clang/test/CXX/class.derived/class.abstract/p5.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {
+ virtual void f() = 0; // expected-note{{unimplemented pure virtual method}}
+};
+
+struct B : A {
+ virtual void f();
+};
+
+struct C : B {
+ virtual void f() = 0; // expected-note 2{{unimplemented pure virtual method}}
+};
+
+struct D : C {
+};
+
+void test() {
+ (void)new A; // expected-error{{abstract class}}
+ (void)new B;
+ (void)new C; // expected-error{{abstract class}}
+ (void)new D; // expected-error{{abstract class}}
+}
diff --git a/clang/test/CXX/class.derived/class.member.lookup/p6.cpp b/clang/test/CXX/class.derived/class.member.lookup/p6.cpp
new file mode 100644
index 0000000..7239881
--- /dev/null
+++ b/clang/test/CXX/class.derived/class.member.lookup/p6.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class V {
+public:
+ int f();
+ int x;
+};
+
+class W {
+public:
+ int g(); // expected-note{{member found by ambiguous name lookup}}
+ int y; // expected-note{{member found by ambiguous name lookup}}
+};
+
+class B : public virtual V, public W
+{
+public:
+ int f();
+ int x;
+ int g(); // expected-note{{member found by ambiguous name lookup}}
+ int y; // expected-note{{member found by ambiguous name lookup}}
+};
+
+class C : public virtual V, public W { };
+
+class D : public B, public C { void glorp(); };
+
+void D::glorp() {
+ x++;
+ f();
+ y++; // expected-error{{member 'y' found in multiple base classes of different types}}
+ g(); // expected-error{{member 'g' found in multiple base classes of different types}}
+}
+
+// PR6462
+struct BaseIO { BaseIO* rdbuf() { return 0; } };
+struct Pcommon : virtual BaseIO { int rdbuf() { return 0; } };
+struct P : virtual BaseIO, Pcommon {};
+
+void f() { P p; p.rdbuf(); }
diff --git a/clang/test/CXX/class.derived/class.member.lookup/p8.cpp b/clang/test/CXX/class.derived/class.member.lookup/p8.cpp
new file mode 100644
index 0000000..4d4acc3
--- /dev/null
+++ b/clang/test/CXX/class.derived/class.member.lookup/p8.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// FIXME: Access control checks
+
+namespace PR5820 {
+ // also <rdar://problem/7535045>
+ struct Base {
+ void Foo();
+ int Member;
+ };
+
+ struct D1 : public Base {};
+ struct D2 : public Base {};
+
+ struct Derived : public D1, public D2 {
+ void Inner();
+ };
+
+ void Test() {
+ Derived d;
+ d.D1::Foo();
+ d.D1::Member = 17;
+ }
+
+ void Derived::Inner() {
+ D1::Foo();
+ D1::Member = 42;
+ this->D1::Foo();
+ this->D1::Member = 42;
+ }
+}
+
+template<typename T>
+struct BaseT {
+ void Foo(); // expected-note{{found by ambiguous name lookup}}
+ int Member;
+};
+
+template<typename T> struct Derived1T : BaseT<T> { };
+template<typename T> struct Derived2T : BaseT<T> { };
+
+template<typename T>
+struct DerivedT : public Derived1T<T>, public Derived2T<T> {
+ void Inner();
+};
+
+template<typename T>
+void DerivedT<T>::Inner() {
+ Derived1T<T>::Foo();
+ Derived2T<T>::Member = 42;
+ this->Derived1T<T>::Foo();
+ this->Derived2T<T>::Member = 42;
+ this->Foo(); // expected-error{{non-static member 'Foo' found in multiple base-class subobjects of type 'BaseT<int>'}}
+}
+
+template<typename T>
+void Test(DerivedT<T> d) {
+ d.template Derived1T<T>::Foo();
+ d.template Derived2T<T>::Member = 17;
+ d.Inner(); // expected-note{{in instantiation}}
+}
+
+template void Test(DerivedT<int>);
diff --git a/clang/test/CXX/class.derived/class.member.lookup/p9.cpp b/clang/test/CXX/class.derived/class.member.lookup/p9.cpp
new file mode 100644
index 0000000..ba7bd21
--- /dev/null
+++ b/clang/test/CXX/class.derived/class.member.lookup/p9.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace rdar8436162 {
+ class ClsA {
+ public:
+ static void f();
+ void g();
+ };
+
+ class ClsB : virtual private ClsA {
+ public:
+ using ClsA::f;
+ using ClsA::g; // expected-note{{member found by ambiguous name lookup}}
+ };
+
+ class ClsF : virtual private ClsA {
+ public:
+ using ClsA::f;
+ using ClsA::g; // expected-note{{member found by ambiguous name lookup}}
+ };
+
+ class ClsE : public ClsB, public ClsF {
+ void test() {
+ f();
+ g(); // expected-error{{member 'g' found in multiple base classes of different types}}
+ }
+ };
+}
diff --git a/clang/test/CXX/class.derived/class.virtual/p12.cpp b/clang/test/CXX/class.derived/class.virtual/p12.cpp
new file mode 100644
index 0000000..208a0d1
--- /dev/null
+++ b/clang/test/CXX/class.derived/class.virtual/p12.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -ast-print %s | FileCheck %s
+
+// CHECK: test12_A::foo()
+struct test12_A {
+ virtual void foo();
+
+ void bar() {
+ test12_A::foo();
+ }
+};
+
+// CHECK: xp->test24_B::wibble()
+struct test24_B {
+ virtual void wibble();
+};
+
+void foo(test24_B *xp) {
+ xp->test24_B::wibble();
+}
diff --git a/clang/test/CXX/class.derived/class.virtual/p2.cpp b/clang/test/CXX/class.derived/class.virtual/p2.cpp
new file mode 100644
index 0000000..64d93c8
--- /dev/null
+++ b/clang/test/CXX/class.derived/class.virtual/p2.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct A {
+ virtual void f() = 0; // expected-note 2{{overridden virtual function}}
+};
+
+struct Aprime : virtual A {
+ virtual void f();
+};
+
+struct B : Aprime {
+ virtual void f(); // expected-note 3{{final overrider of 'A::f'}}
+};
+
+struct C : virtual A {
+ virtual void f(); // expected-note{{final overrider of 'A::f'}}
+};
+
+struct D : B, C { }; // expected-error{{virtual function 'A::f' has more than one final overrider in 'D'}}
+
+struct B2 : B { };
+
+struct E : B, B2 { }; //expected-error{{virtual function 'A::f' has more than one final overrider in 'E'}}
+
+struct F : B, B2 {
+ virtual void f(); // okay
+};
+
+struct G : F { }; // okay
+
+struct H : G, A { }; // okay
+
+namespace MultipleSubobjects {
+ struct A { virtual void f(); };
+ struct B : A { virtual void f(); };
+ struct C : A { virtual void f(); };
+ struct D : B, C { }; // okay
+}
diff --git a/clang/test/CXX/class.derived/class.virtual/p3-0x.cpp b/clang/test/CXX/class.derived/class.virtual/p3-0x.cpp
new file mode 100644
index 0000000..c4a401b
--- /dev/null
+++ b/clang/test/CXX/class.derived/class.virtual/p3-0x.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+namespace Test1 {
+
+struct B {
+ virtual void f(int);
+};
+
+struct D : B {
+ virtual void f(long) override; // expected-error {{'f' marked 'override' but does not override any member functions}}
+ void f(int) override;
+};
+}
+
+namespace Test2 {
+
+struct A {
+ virtual void f(int, char, int);
+};
+
+template<typename T>
+struct B : A {
+ virtual void f(T) override;
+};
+
+}
+
+namespace Test3 {
+
+struct A {
+ virtual void f(int, char, int);
+};
+
+template<typename... Args>
+struct B : A {
+ virtual void f(Args...) override; // expected-error {{'f' marked 'override' but does not override any member functions}}
+};
+
+template struct B<int, char, int>;
+template struct B<int>; // expected-note {{in instantiation of template class 'Test3::B<int>' requested here}}
+
+}
+
+namespace Test4 {
+struct B {
+ virtual void f() const final; // expected-note {{overridden virtual function is here}}
+};
+
+struct D : B {
+ void f() const; // expected-error {{declaration of 'f' overrides a 'final' function}}
+};
+
+}
diff --git a/clang/test/CXX/class.derived/p1.cpp b/clang/test/CXX/class.derived/p1.cpp
new file mode 100644
index 0000000..dc5cb2b
--- /dev/null
+++ b/clang/test/CXX/class.derived/p1.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11
+
+// base-clause:
+// : base-specifier-list
+// base-specifier-list:
+// base-specifier ...[opt]
+// base-specifier-list , base-specifier ...[opt]
+// base-specifier:
+// attribute-specifier-seq[opt] base-type-specifier
+// attribute-specifier-seq[opt] virtual access-specifier[opt] base-type-specifier
+// attribute-specifier-seq[opt] access-specifier virtual[opt] base-type-specifier
+// class-or-decltype:
+// nested-name-specifier[opt] class-name
+// decltype-specifier
+// base-type-specifier:
+// class-or-decltype
+// access-specifier:
+// private
+// protected
+// public
+
+namespace PR11216 {
+ struct Base { };
+ struct Derived : decltype(Base()) { };
+
+ int func();
+ struct Derived2 : decltype(func()) { }; // expected-error {{base specifier must name a class}}
+
+ template<typename T>
+ struct Derived3 : decltype(T().foo()) { };
+ struct Foo { Base foo(); };
+ Derived3<Foo> d;
+
+ struct Derived4 : :: decltype(Base()) { }; // expected-error {{unexpected namespace scope prior to decltype}}
+
+ struct Derived5 : PR11216:: decltype(Base()) { }; // expected-error {{unexpected namespace scope prior to decltype}}
+
+ template<typename T>
+ struct Derived6 : typename T::foo { }; // expected-error {{'typename' is redundant; base classes are implicitly types}}
+}
diff --git a/clang/test/CXX/class.derived/p2.cpp b/clang/test/CXX/class.derived/p2.cpp
new file mode 100644
index 0000000..7ef53d3
--- /dev/null
+++ b/clang/test/CXX/class.derived/p2.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+// "During the lookup for a base class name, non-type names are ignored"
+namespace PR5840 {
+ struct Base {};
+ int Base = 10;
+ struct Derived : Base {};
+}
diff --git a/clang/test/CXX/class/class.base/class.base.init/p5-0x.cpp b/clang/test/CXX/class/class.base/class.base.init/p5-0x.cpp
new file mode 100644
index 0000000..e9aa6da
--- /dev/null
+++ b/clang/test/CXX/class/class.base/class.base.init/p5-0x.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// [class.base.init]p5
+// A ctor-initializer may initialize a variant member of the constructor’s
+// class. If a ctor-initializer specifies more than one mem-initializer for the
+// same member or for the same base class, the ctor-initializer is ill-formed.
+
+union E {
+ int a;
+ int b;
+ E() : a(1), // expected-note{{previous initialization is here}}
+ b(2) { // expected-error{{initializing multiple members of union}}
+ }
+};
+
+union F {
+ struct {
+ int a;
+ int b;
+ };
+ int c;
+ F() : a(1), // expected-note{{previous initialization is here}}
+ b(2),
+ c(3) { // expected-error{{initializing multiple members of union}}
+ }
+};
diff --git a/clang/test/CXX/class/class.bit/p2.cpp b/clang/test/CXX/class/class.bit/p2.cpp
new file mode 100644
index 0000000..7962330
--- /dev/null
+++ b/clang/test/CXX/class/class.bit/p2.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct A {
+private:
+ int : 0;
+};
+
+A a = { };
+A a2 = { 1 }; // expected-error{{excess elements in struct initializer}}
+
+struct B {
+ const int : 0;
+};
+
+B b;
+
+void testB() {
+ B b2(b);
+ B b3(static_cast<B&&>(b2));
+ b = b;
+ b = static_cast<B&&>(b);
+}
diff --git a/clang/test/CXX/class/class.friend/p1-ambiguous.cpp b/clang/test/CXX/class/class.friend/p1-ambiguous.cpp
new file mode 100644
index 0000000..a9dca4f
--- /dev/null
+++ b/clang/test/CXX/class/class.friend/p1-ambiguous.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Make sure that friend declarations don't introduce ambiguous
+// declarations.
+
+// Test case courtesy of Shantonu Sen.
+// Bug 4784.
+
+class foo;
+
+extern "C" {
+ int c_func(foo *a);
+};
+int cpp_func(foo *a);
+
+class foo {
+public:
+ friend int c_func(foo *a);
+ friend int cpp_func(foo *a);
+ int caller();
+private:
+ int x;
+};
+
+int c_func(foo *a) {
+ return a->x;
+}
+
+int cpp_func(foo *a) {
+ return a->x;
+}
+
+int foo::caller() {
+ c_func(this);
+ cpp_func(this);
+ return 0;
+}
diff --git a/clang/test/CXX/class/class.friend/p1-cxx11.cpp b/clang/test/CXX/class/class.friend/p1-cxx11.cpp
new file mode 100644
index 0000000..235f295
--- /dev/null
+++ b/clang/test/CXX/class/class.friend/p1-cxx11.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+class A {
+ class AInner {
+ };
+
+ void a_member();
+ friend void A::a_member(); // ok in c++11, ill-formed in c++98
+ friend void a_member(); // ok in both, refers to non-member
+ friend class A::AInner; // ok in c++11, extension in c++98
+ friend class AInner; // ok in both, refers to non-member
+};
diff --git a/clang/test/CXX/class/class.friend/p1.cpp b/clang/test/CXX/class/class.friend/p1.cpp
new file mode 100644
index 0000000..07b3a10
--- /dev/null
+++ b/clang/test/CXX/class/class.friend/p1.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct Outer {
+ struct Inner {
+ int intfield;
+ };
+};
+
+struct Base {
+ void base_member();
+
+ typedef int Int;
+ Int typedeffed_member();
+};
+
+struct Derived : public Base {
+};
+
+int myglobal;
+
+void global_function();
+extern "C" {
+ void global_c_function();
+}
+
+class A {
+ class AInner {
+ };
+
+ friend class PreDeclared;
+ friend class Outer::Inner;
+ friend int Outer::Inner::intfield; // expected-error {{friends can only be classes or functions}}
+ friend int Outer::Inner::missing_field; //expected-error {{friends can only be classes or functions}}
+ friend int myoperation(float); // okay
+ friend int myglobal; // expected-error {{friends can only be classes or functions}}
+
+ friend void global_function();
+ friend void global_c_function();
+
+ friend class UndeclaredSoFar;
+ UndeclaredSoFar x; // expected-error {{unknown type name 'UndeclaredSoFar'}}
+
+ void a_member();
+ friend void A::a_member(); // expected-error {{friends cannot be members of the declaring class}}
+ friend void a_member(); // okay (because we ignore class scopes when looking up friends)
+ friend class A::AInner; // this is okay as an extension
+ friend class AInner; // okay, refers to ::AInner
+
+ friend void Derived::missing_member(); // expected-error {{no function named 'missing_member' with type 'void ()' was found in the specified scope}}
+
+ friend void Derived::base_member(); // expected-error {{no function named 'base_member' with type 'void ()' was found in the specified scope}}
+
+ friend int Base::typedeffed_member(); // okay: should look through typedef
+
+ // These test that the friend is properly not being treated as a
+ // member function.
+ friend A operator|(const A& l, const A& r); // okay
+ friend A operator|(const A& r); // expected-error {{overloaded 'operator|' must be a binary operator (has 1 parameter)}}
+
+ friend operator bool() const; // expected-error {{must use a qualified name when declaring a conversion operator as a friend}} \
+ // expected-error{{non-member function cannot have 'const' qualifier}}
+
+ typedef void ftypedef();
+ friend ftypedef typedeffed_function; // okay (because it's not declared as a member)
+
+ class facet;
+ friend class facet; // should not assert
+ class facet {};
+};
+
+A::UndeclaredSoFar y; // expected-error {{no type named 'UndeclaredSoFar' in 'A'}}
+
+class PreDeclared;
+
+int myoperation(float f) {
+ return (int) f;
+}
diff --git a/clang/test/CXX/class/class.friend/p2.cpp b/clang/test/CXX/class/class.friend/p2.cpp
new file mode 100644
index 0000000..fb3cd19
--- /dev/null
+++ b/clang/test/CXX/class/class.friend/p2.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct B0;
+
+class A {
+ friend class B {}; // expected-error {{cannot define a type in a friend declaration}}
+ friend int; // expected-warning {{non-class friend type 'int' is a C++11 extension}}
+ friend B0; // expected-warning {{specify 'struct' to befriend 'B0'}}
+ friend class C; // okay
+};
diff --git a/clang/test/CXX/class/class.friend/p6.cpp b/clang/test/CXX/class/class.friend/p6.cpp
new file mode 100644
index 0000000..7d7a064
--- /dev/null
+++ b/clang/test/CXX/class/class.friend/p6.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -Wc++11-compat -verify %s
+
+class A {
+ friend static class B; // expected-error {{'static' is invalid in friend declarations}}
+ friend extern class C; // expected-error {{'extern' is invalid in friend declarations}}
+ friend auto class D; // expected-warning {{incompatible with C++11}} expected-error {{'auto' is invalid in friend declarations}}
+ friend register class E; // expected-error {{'register' is invalid in friend declarations}}
+ friend mutable class F; // expected-error {{'mutable' is invalid in friend declarations}}
+ friend typedef class G; // expected-error {{'typedef' is invalid in friend declarations}}
+};
diff --git a/clang/test/CXX/class/class.local/p1-0x.cpp b/clang/test/CXX/class/class.local/p1-0x.cpp
new file mode 100644
index 0000000..49125f5
--- /dev/null
+++ b/clang/test/CXX/class/class.local/p1-0x.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+void f() {
+ int x = 3; // expected-note{{'x' declared here}}
+ const int c = 2;
+ struct C {
+ int& x2 = x; // expected-error{{reference to local variable 'x' declared in enclosing function 'f'}}
+ int cc = c;
+ };
+ (void)[]() mutable {
+ int x = 3; // expected-note{{'x' declared here}}
+ struct C {
+ int& x2 = x; // expected-error{{reference to local variable 'x' declared in enclosing lambda expression}}
+ };
+ };
+ C();
+}
+
diff --git a/clang/test/CXX/class/class.local/p1.cpp b/clang/test/CXX/class/class.local/p1.cpp
new file mode 100644
index 0000000..62ade5c
--- /dev/null
+++ b/clang/test/CXX/class/class.local/p1.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int x;
+void f()
+{
+ static int s;
+ int x; // expected-note{{'x' declared here}}
+ extern int g();
+
+ struct local {
+ int g() { return x; } // expected-error{{reference to local variable 'x' declared in enclosing function 'f'}}
+ int h() { return s; }
+ int k() { return :: x; }
+ int l() { return g(); }
+ };
+}
+
+local* p = 0; // expected-error{{unknown type name 'local'}}
diff --git a/clang/test/CXX/class/class.local/p2.cpp b/clang/test/CXX/class/class.local/p2.cpp
new file mode 100644
index 0000000..db4c90f
--- /dev/null
+++ b/clang/test/CXX/class/class.local/p2.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A { };
+
+void f() {
+ struct B : private A {}; // expected-note{{declared private here}}
+
+ B b;
+
+ A *a = &b; // expected-error{{cannot cast 'B' to its private base class 'A'}}
+}
diff --git a/clang/test/CXX/class/class.local/p3.cpp b/clang/test/CXX/class/class.local/p3.cpp
new file mode 100644
index 0000000..3753790
--- /dev/null
+++ b/clang/test/CXX/class/class.local/p3.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f1() {
+ struct X {
+ struct Y;
+ };
+
+ struct X::Y {
+ void f() {}
+ };
+}
+
+void f2() {
+ struct X {
+ struct Y;
+
+ struct Y {
+ void f() {}
+ };
+ };
+}
+
+// A class nested within a local class is a local class.
+void f3(int a) { // expected-note{{'a' declared here}}
+ struct X {
+ struct Y {
+ int f() { return a; } // expected-error{{reference to local variable 'a' declared in enclosing function 'f3'}}
+ };
+ };
+}
diff --git a/clang/test/CXX/class/class.local/p4.cpp b/clang/test/CXX/class/class.local/p4.cpp
new file mode 100644
index 0000000..d780744
--- /dev/null
+++ b/clang/test/CXX/class/class.local/p4.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f() {
+ struct X {
+ static int a; // expected-error {{static data member 'a' not allowed in local class 'X'}}
+ int b;
+
+ static void f() { }
+ };
+}
diff --git a/clang/test/CXX/class/class.mem/p1.cpp b/clang/test/CXX/class/class.mem/p1.cpp
new file mode 100644
index 0000000..a41f1db
--- /dev/null
+++ b/clang/test/CXX/class/class.mem/p1.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct S
+{
+ static int v1; // expected-note{{previous declaration is here}}
+ int v1; //expected-error{{duplicate member 'v1'}}
+ int v; //expected-note 2{{previous definition is here}} \
+ // expected-note{{previous declaration is here}}
+ static int v; //expected-error{{redefinition of 'v' as different kind of symbol}}
+ int v; //expected-error{{duplicate member 'v'}}
+ static int v; //expected-error{{redefinition of 'v' as different kind of symbol}}
+ enum EnumT { E = 10 };
+ friend struct M;
+ struct X; //expected-note{{forward declaration of 'S::X'}}
+ friend struct X;
+};
+
+S::EnumT Evar = S::E; // ok
+S::EnumT Evar2 = EnumT(); //expected-error{{use of undeclared identifier 'EnumT'}}
+S::M m; //expected-error{{no type named 'M' in 'S'}}
+S::X x; //expected-error{{variable has incomplete type 'S::X'}}
+
+
+struct S2
+{
+ static int v2; // expected-note{{previous declaration is here}}
+ static int v2; //expected-error{{duplicate member 'v2'}}
+};
+
+struct S3
+{
+ static int v3;
+ struct S4
+ {
+ static int v3;
+ };
+};
+
+struct S4
+{
+ static int v4;
+};
+
+int S4::v4; //expected-note{{previous definition is here}}
+int S4::v4; //expected-error{{redefinition of 'v4'}}
+
+struct S5
+{
+ static int v5; //expected-note{{previous definition is here}}
+ void v5() { } //expected-error{{redefinition of 'v5' as different kind of symbol}}
+
+ void v6() { } //expected-note{{previous definition is here}}
+ static int v6; //expected-error{{redefinition of 'v6' as different kind of symbol}}
+
+ void v7() { }
+ void v7(int) { } //expected-note{{previous definition is here}}
+ static int v7; //expected-error{{redefinition of 'v7' as different kind of symbol}}
+
+ void v8();
+ int v8(int); //expected-note{{previous declaration is here}}
+ int v8; //expected-error{{duplicate member 'v8'}}
+
+
+};
+
+namespace PR8245 {
+ class X {
+ public:
+ template<class C>
+ class Inner {
+ public:
+ void foo(bool bar = true);
+ int bam;
+ };
+
+ Inner<int> _foo;
+ };
+
+ void f() {
+ X::Inner<int> c2i;
+ X::Inner<float> c2f;
+ c2i.foo();
+ c2f.foo();
+ }
+
+ class Y {
+ class Inner {
+ void foo(int = sizeof(Y));
+ };
+ };
+}
diff --git a/clang/test/CXX/class/class.mem/p13.cpp b/clang/test/CXX/class/class.mem/p13.cpp
new file mode 100644
index 0000000..8488584
--- /dev/null
+++ b/clang/test/CXX/class/class.mem/p13.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// If T is the name of a class, then each of the following shall have
+// a name different from T:
+
+// - every static data member of class T;
+struct X0 {
+ static int X0; // expected-error{{member 'X0' has the same name as its class}}
+};
+
+// - every member function of class T
+// (Cannot be tested)
+
+// - every member of class T that is itself a type;
+struct X1 { // expected-note{{previous use is here}}
+ enum X1 { }; // expected-error{{use of 'X1' with tag type that does not match previous declaration}}
+};
+
+struct X2 {
+ typedef int X2; // expected-error{{member 'X2' has the same name as its class}}
+};
+
+// - every enumerator of every member of class T that is an enumerated type; and
+struct X3 {
+ enum E {
+ X3 // expected-error{{member 'X3' has the same name as its class}}
+ };
+};
+
+// - every member of every anonymous union that is a member of class T.
+struct X4 {
+ union {
+ int X;
+ union {
+ float Y;
+ unsigned X4; // expected-error{{member 'X4' has the same name as its class}}
+ };
+ };
+};
+
diff --git a/clang/test/CXX/class/class.mem/p14.cpp b/clang/test/CXX/class/class.mem/p14.cpp
new file mode 100644
index 0000000..72b232e
--- /dev/null
+++ b/clang/test/CXX/class/class.mem/p14.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// In addition, if class T has a user-declared constructor (12.1),
+// every non-static data member of class T shall have a name different
+// from T.
+
+struct X0 {
+ int X0; // okay
+};
+
+struct X1 {
+ int X1;
+ X1(); // expected-error{{declarator requires an identifier}}
+};
+
+struct X2 {
+ X2();
+ float X2; // expected-error{{member 'X2' has the same name as its class}}
+};
diff --git a/clang/test/CXX/class/class.mem/p1b.cpp b/clang/test/CXX/class/class.mem/p1b.cpp
new file mode 100644
index 0000000..3e8c985
--- /dev/null
+++ b/clang/test/CXX/class/class.mem/p1b.cpp
@@ -0,0 +1,46 @@
+// The first run checks that the correct errors are generated,
+// implicitly checking the order of default argument parsing:
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// The second run checks the order of inline method definitions:
+// RUN: not %clang_cc1 -fsyntax-only %s 2> %t
+// RUN: FileCheck %s < %t
+
+class A {
+public:
+ void a1() {
+ B b = B();
+ }
+
+ class B;
+ void a2(B b = B()); // expected-error{{use of default argument to function 'B' that is declared later in class 'B'}}
+
+ void a3(int a = 42);
+
+ // CHECK: error: use of undeclared identifier 'first'
+ void a4(int a = first); // expected-error{{use of undeclared identifier 'first'}}
+
+ class B {
+ public:
+ B(int b = 42) { // expected-note{{default argument declared here}}
+ A a;
+ a.a3();
+ a.a6();
+ }
+
+ void b1(A a = A()); // expected-error{{use of default argument to function 'A' that is declared later in class 'A'}}
+
+ // CHECK: error: use of undeclared identifier 'second'
+ void b2(int a = second); // expected-error{{use of undeclared identifier 'second'}}
+ };
+
+ void a5() {
+ B b = B();
+ }
+
+ void a6(B b = B());
+
+ A(int a = 42); // expected-note{{default argument declared here}}
+
+ // CHECK: error: use of undeclared identifier 'third'
+ void a7(int a = third); // expected-error{{use of undeclared identifier 'third'}}
+};
diff --git a/clang/test/CXX/class/class.mem/p2.cpp b/clang/test/CXX/class/class.mem/p2.cpp
new file mode 100644
index 0000000..4aa4a5c
--- /dev/null
+++ b/clang/test/CXX/class/class.mem/p2.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// C++11 [class.mem]p2:
+// A class is considered a completely-defined object type (or
+// complete type) at the closing } of the class-specifier. Within
+// the class member-specification, the class is regarded as complete
+// within function bodies, default arguments,
+// exception-specifications, and brace-or-equal-initializers for
+// non-static data members (including such things in nested classes).
+// Otherwise it is regarded as incomplete within its own class
+// member-specification.
+
+namespace test0 {
+ struct A { // expected-note {{definition of 'test0::A' is not complete until the closing '}'}}
+ A x; // expected-error {{field has incomplete type 'test0::A'}}
+ };
+}
+
+namespace test1 {
+ template <class T> struct A {
+ A<int> x; // expected-error {{implicit instantiation of template 'test1::A<int>' within its own definition}}
+ };
+}
+
+namespace test2 {
+ template <class T> struct A;
+ template <> struct A<int> {};
+ template <class T> struct A {
+ A<int> x;
+ };
+}
+
+namespace test3 {
+ struct A {
+ struct B {
+ void f() throw(A);
+ void g() throw(B);
+ };
+
+ void f() throw(A);
+ void g() throw(B);
+ };
+
+ template<typename T>
+ struct A2 {
+ struct B {
+ void f1() throw(A2);
+ void f2() throw(A2<T>);
+ void g() throw(B);
+ };
+
+ void f1() throw(A2);
+ void f2() throw(A2<T>);
+ void g() throw(B);
+ };
+
+ template struct A2<int>;
+}
diff --git a/clang/test/CXX/class/class.mem/p5-0x.cpp b/clang/test/CXX/class/class.mem/p5-0x.cpp
new file mode 100644
index 0000000..6061c4c
--- /dev/null
+++ b/clang/test/CXX/class/class.mem/p5-0x.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+int f();
+
+struct S
+{
+ int a = f(); // ok
+ int b = g(); // expected-error {{use of undeclared identifier 'g'}}
+};
diff --git a/clang/test/CXX/class/class.mem/p8-0x.cpp b/clang/test/CXX/class/class.mem/p8-0x.cpp
new file mode 100644
index 0000000..d2c3dc3
--- /dev/null
+++ b/clang/test/CXX/class/class.mem/p8-0x.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+struct Base1 {
+ virtual void g();
+};
+
+struct A : Base1 {
+ virtual void g() override override; // expected-error {{class member already marked 'override'}}
+ virtual void h() final final; // expected-error {{class member already marked 'final'}}
+};
+
+struct Base2 {
+ virtual void e1(), e2();
+ virtual void f();
+};
+
+struct B : Base2 {
+ virtual void e1() override, e2(int); // No error.
+ virtual void f() override;
+ void g() override; // expected-error {{only virtual member functions can be marked 'override'}}
+ int h override; // expected-error {{only virtual member functions can be marked 'override'}}
+};
+
+struct C {
+ virtual void f() final;
+ void g() final; // expected-error {{only virtual member functions can be marked 'final'}}
+ int h final; // expected-error {{only virtual member functions can be marked 'final'}}
+};
+
+namespace inline_extension {
+ struct Base1 {
+ virtual void g() {}
+ };
+
+ struct A : Base1 {
+ virtual void g() override override {} // expected-error {{class member already marked 'override'}}
+ virtual void h() final final {} // expected-error {{class member already marked 'final'}}
+ };
+
+ struct Base2 {
+ virtual void f();
+ };
+
+ struct B : Base2 {
+ virtual void f() override {}
+ void g() override {} // expected-error {{only virtual member functions can be marked 'override'}}
+ };
+
+ struct C {
+ virtual void f() final {}
+ void g() final {} // expected-error {{only virtual member functions can be marked 'final'}}
+ };
+}
diff --git a/clang/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp b/clang/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp
new file mode 100644
index 0000000..9116e71
--- /dev/null
+++ b/clang/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// [class.mfct.non-static]p3:
+// When an id-expression (5.1) that is not part of a class member
+// access syntax (5.2.5) and not used to form a pointer to member
+// (5.3.1) is used in the body of a non-static member function of
+// class X, if name lookup (3.4.1) resolves the name in the
+// id-expression to a non-static non-type member of some class C,
+// the id-expression is transformed into a class member access
+// expression (5.2.5) using (*this) (9.3.2) as the
+// postfix-expression to the left of the . operator. [ Note: if C is
+// not X or a base class of X, the class member access expression is
+// ill-formed. --end note] Similarly during name lookup, when an
+// unqualified-id (5.1) used in the definition of a member function
+// for class X resolves to a static member, an enumerator or a
+// nested type of class X or of a base class of X, the
+// unqualified-id is transformed into a qualified-id (5.1) in which
+// the nested-name-specifier names the class of the member function.
+
+namespace test0 {
+ class A {
+ int data_member;
+ int instance_method();
+ static int static_method();
+
+ bool test() {
+ return data_member + instance_method() < static_method();
+ }
+ };
+}
+
+namespace test1 {
+ struct Opaque1 {}; struct Opaque2 {}; struct Opaque3 {};
+
+ struct A {
+ void foo(Opaque1); // expected-note {{candidate}}
+ void foo(Opaque2); // expected-note {{candidate}}
+ };
+
+ struct B : A {
+ void test();
+ };
+
+ struct C1 : A { };
+ struct C2 : B { };
+
+ void B::test() {
+ A::foo(Opaque1());
+ A::foo(Opaque2());
+ A::foo(Opaque3()); // expected-error {{no matching member function}}
+
+ C1::foo(Opaque1()); // expected-error {{call to non-static member function without an object argument}}
+ C2::foo(Opaque1()); // expected-error {{call to non-static member function without an object argument}}
+ }
+}
+
+namespace test2 {
+ struct Unrelated {
+ void foo();
+ };
+
+ template <class T> struct B;
+ template <class T> struct C;
+
+ template <class T> struct A {
+ void foo();
+
+ void test0() {
+ Unrelated::foo(); // expected-error {{call to non-static member function without an object argument}}
+ }
+
+ void test1() {
+ B<T>::foo();
+ }
+
+ static void test2() {
+ B<T>::foo(); // expected-error {{call to non-static member function without an object argument}}
+ }
+
+ void test3() {
+ C<T>::foo(); // expected-error {{no member named 'foo'}}
+ }
+ };
+
+ template <class T> struct B : A<T> {
+ };
+
+ template <class T> struct C {
+ };
+
+ int test() {
+ A<int> a;
+ a.test0(); // no instantiation note here, decl is ill-formed
+ a.test1();
+ a.test2(); // expected-note {{in instantiation}}
+ a.test3(); // expected-note {{in instantiation}}
+ }
+}
diff --git a/clang/test/CXX/class/class.nest/p1-cxx0x.cpp b/clang/test/CXX/class/class.nest/p1-cxx0x.cpp
new file mode 100644
index 0000000..b7a1a48
--- /dev/null
+++ b/clang/test/CXX/class/class.nest/p1-cxx0x.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+class Outer {
+ int x;
+ static int sx;
+ int f();
+
+ // The first case is invalid in the C++03 mode but valid in C++0x (see 5.1.1.10).
+ class Inner {
+ static char a[sizeof(x)]; // okay
+ static char b[sizeof(sx)]; // okay
+ static char c[sizeof(f)]; // expected-error {{call to non-static member function without an object argument}}
+ };
+};
diff --git a/clang/test/CXX/class/class.nest/p1.cpp b/clang/test/CXX/class/class.nest/p1.cpp
new file mode 100644
index 0000000..b0341da
--- /dev/null
+++ b/clang/test/CXX/class/class.nest/p1.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class Outer {
+ int x;
+ static int sx;
+ int f();
+
+ // C++11 does relax this rule (see 5.1.1.10) in the first case, but we need to enforce it in C++03 mode.
+ class Inner {
+ static char a[sizeof(x)]; // expected-error {{invalid use of non-static data member 'x'}}
+ static char b[sizeof(sx)]; // okay
+ static char c[sizeof(f)]; // expected-error {{call to non-static member function without an object argument}}
+ };
+};
diff --git a/clang/test/CXX/class/class.nest/p3.cpp b/clang/test/CXX/class/class.nest/p3.cpp
new file mode 100644
index 0000000..c4c4ca7
--- /dev/null
+++ b/clang/test/CXX/class/class.nest/p3.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++0x [class.nest] p3:
+// If class X is defined in a namespace scope, a nested class Y may be
+// declared in class X and later defined in the definition of class X or be
+// later defined in a namespace scope enclosing the definition of class X.
+
+namespace example {
+ class E {
+ class I1;
+ class I2;
+ class I1 { };
+ };
+ class E::I2 { };
+}
+
+// Don't insert out-of-line inner class definitions into the namespace scope.
+namespace PR6107 {
+ struct S1 { };
+ struct S2 {
+ struct S1;
+ };
+ struct S2::S1 { };
+ S1 s1;
+}
diff --git a/clang/test/CXX/class/class.nested.type/p1.cpp b/clang/test/CXX/class/class.nested.type/p1.cpp
new file mode 100644
index 0000000..4a04a44
--- /dev/null
+++ b/clang/test/CXX/class/class.nested.type/p1.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class X {
+public:
+ typedef int I;
+ class Y { };
+ I a;
+};
+
+I b; // expected-error{{unknown type name 'I'}}
+Y c; // expected-error{{unknown type name 'Y'}}
+X::Y d;
+X::I e;
diff --git a/clang/test/CXX/class/class.static/class.static.data/p3.cpp b/clang/test/CXX/class/class.static/class.static.data/p3.cpp
new file mode 100644
index 0000000..117997e
--- /dev/null
+++ b/clang/test/CXX/class/class.static/class.static.data/p3.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct NonLit { // expected-note 3{{no constexpr constructors}}
+ NonLit();
+};
+
+struct S {
+ static constexpr int a = 0;
+ static constexpr int b; // expected-error {{declaration of constexpr static data member 'b' requires an initializer}}
+
+ static constexpr int c = 0;
+ static const int d;
+ static const int d2 = 0;
+
+ static constexpr double e = 0.0; // ok
+ static const double f = 0.0; // expected-warning {{extension}} expected-note {{use 'constexpr' specifier}}
+ static char *const g = 0; // expected-error {{requires 'constexpr' specifier}}
+ static const NonLit h = NonLit(); // expected-error {{must be initialized out of line}}
+};
+
+constexpr int S::a;
+constexpr int S::b = 0;
+
+const int S::c;
+constexpr int S::d = 0;
+constexpr int S::d2;
+
+template<typename T>
+struct U {
+ static constexpr int a = 0;
+ static constexpr int b; // expected-error {{declaration of constexpr static data member 'b' requires an initializer}}
+ static constexpr NonLit h = NonLit(); // expected-error {{cannot have non-literal type 'const NonLit'}}
+ static constexpr T c = T(); // expected-error {{cannot have non-literal type}}
+ static const T d;
+};
+
+template<typename T> constexpr T U<T>::d = T(); // expected-error {{non-literal type 'const NonLit'}}
+
+U<int> u1;
+U<NonLit> u2; // expected-note {{here}}
+
+static_assert(U<int>::a == 0, "");
+
+constexpr int outofline = (U<NonLit>::d, 0); // expected-note {{here}} expected-warning {{unused}}
diff --git a/clang/test/CXX/class/class.static/class.static.data/p4.cpp b/clang/test/CXX/class/class.static/class.static.data/p4.cpp
new file mode 100644
index 0000000..2b1eca7
--- /dev/null
+++ b/clang/test/CXX/class/class.static/class.static.data/p4.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct InClassInitializerOnly {
+ static const int i = 0;
+};
+int const InClassInitializerOnly::i;
+
+struct OutOfClassInitializerOnly {
+ static const int i;
+};
+int const OutOfClassInitializerOnly::i = 0;
+
+struct InClassInitializerAndOutOfClassCopyInitializer {
+ static const int i = 0; // expected-note{{previous definition is here}}
+};
+int const InClassInitializerAndOutOfClassCopyInitializer::i = 0; // expected-error{{redefinition of 'i'}}
+
+struct InClassInitializerAndOutOfClassDirectInitializer {
+ static const int i = 0; // expected-note{{previous definition is here}}
+};
+int const InClassInitializerAndOutOfClassDirectInitializer::i(0); // expected-error{{redefinition of 'i'}}
+
+
+
+int main() { }
+
diff --git a/clang/test/CXX/class/class.union/p1.cpp b/clang/test/CXX/class/class.union/p1.cpp
new file mode 100644
index 0000000..f344ae5
--- /dev/null
+++ b/clang/test/CXX/class/class.union/p1.cpp
@@ -0,0 +1,125 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void abort() __attribute__((noreturn));
+
+class Okay {
+ int a_;
+};
+
+class Virtual {
+ virtual void foo() { abort(); } // expected-note 4 {{because type 'Virtual' has a virtual member function}}
+};
+
+class VirtualBase : virtual Okay { // expected-note 4 {{because type 'VirtualBase' has a virtual base class}}
+};
+
+class Ctor {
+ Ctor() { abort(); } // expected-note 4 {{because type 'Ctor' has a user-declared constructor}}
+};
+class Ctor2 {
+ Ctor2(); // expected-note 3 {{because type 'Ctor2' has a user-declared constructor}}
+};
+class CtorTmpl {
+ template<typename T> CtorTmpl(); // expected-note {{because type 'CtorTmpl' has a user-declared constructor}}
+};
+
+class CopyCtor {
+ CopyCtor(CopyCtor &cc) { abort(); } // expected-note 4 {{because type 'CopyCtor' has a user-declared copy constructor}}
+};
+
+// FIXME: this should eventually trigger on the operator's declaration line
+class CopyAssign { // expected-note 4 {{because type 'CopyAssign' has a user-declared copy assignment operator}}
+ CopyAssign& operator=(CopyAssign& CA) { abort(); }
+};
+
+class Dtor {
+ ~Dtor() { abort(); } // expected-note 4 {{because type 'Dtor' has a user-declared destructor}}
+};
+
+union U1 {
+ Virtual v; // expected-error {{union member 'v' has a non-trivial copy constructor}}
+ VirtualBase vbase; // expected-error {{union member 'vbase' has a non-trivial copy constructor}}
+ Ctor ctor; // expected-error {{union member 'ctor' has a non-trivial constructor}}
+ Ctor2 ctor2; // expected-error {{union member 'ctor2' has a non-trivial constructor}}
+ CtorTmpl ctortmpl; // expected-error {{union member 'ctortmpl' has a non-trivial constructor}}
+ CopyCtor copyctor; // expected-error {{union member 'copyctor' has a non-trivial copy constructor}}
+ CopyAssign copyassign; // expected-error {{union member 'copyassign' has a non-trivial copy assignment operator}}
+ Dtor dtor; // expected-error {{union member 'dtor' has a non-trivial destructor}}
+ Okay okay;
+};
+
+union U2 {
+ struct {
+ Virtual v; // expected-note {{because type 'U2::<anonymous struct}}
+ } m1; // expected-error {{union member 'm1' has a non-trivial copy constructor}}
+ struct {
+ VirtualBase vbase; // expected-note {{because type 'U2::<anonymous struct}}
+ } m2; // expected-error {{union member 'm2' has a non-trivial copy constructor}}
+ struct {
+ Ctor ctor; // expected-note {{because type 'U2::<anonymous struct}}
+ } m3; // expected-error {{union member 'm3' has a non-trivial constructor}}
+ struct {
+ Ctor2 ctor2; // expected-note {{because type 'U2::<anonymous struct}}
+ } m3a; // expected-error {{union member 'm3a' has a non-trivial constructor}}
+ struct {
+ CopyCtor copyctor; // expected-note {{because type 'U2::<anonymous struct}}
+ } m4; // expected-error {{union member 'm4' has a non-trivial copy constructor}}
+ struct {
+ CopyAssign copyassign; // expected-note {{because type 'U2::<anonymous struct}}
+ } m5; // expected-error {{union member 'm5' has a non-trivial copy assignment operator}}
+ struct {
+ Dtor dtor; // expected-note {{because type 'U2::<anonymous struct}}
+ } m6; // expected-error {{union member 'm6' has a non-trivial destructor}}
+ struct {
+ Okay okay;
+ } m7;
+};
+
+union U3 {
+ struct s1 : Virtual { // expected-note {{because type 'U3::s1' has a base class with a non-trivial copy constructor}}
+ } m1; // expected-error {{union member 'm1' has a non-trivial copy constructor}}
+ struct s2 : VirtualBase { // expected-note {{because type 'U3::s2' has a base class with a non-trivial copy constructor}}
+ } m2; // expected-error {{union member 'm2' has a non-trivial copy constructor}}
+ struct s3 : Ctor { // expected-note {{because type 'U3::s3' has a base class with a non-trivial constructor}}
+ } m3; // expected-error {{union member 'm3' has a non-trivial constructor}}
+ struct s3a : Ctor2 { // expected-note {{because type 'U3::s3a' has a base class with a non-trivial constructor}}
+ } m3a; // expected-error {{union member 'm3a' has a non-trivial constructor}}
+ struct s4 : CopyCtor { // expected-note {{because type 'U3::s4' has a base class with a non-trivial copy constructor}}
+ } m4; // expected-error {{union member 'm4' has a non-trivial copy constructor}}
+ struct s5 : CopyAssign { // expected-note {{because type 'U3::s5' has a base class with a non-trivial copy assignment operator}}
+ } m5; // expected-error {{union member 'm5' has a non-trivial copy assignment operator}}
+ struct s6 : Dtor { // expected-note {{because type 'U3::s6' has a base class with a non-trivial destructor}}
+ } m6; // expected-error {{union member 'm6' has a non-trivial destructor}}
+ struct s7 : Okay {
+ } m7;
+};
+
+union U4 {
+ static int i1; // expected-warning {{static data member 'i1' in union is a C++11 extension}}
+};
+int U4::i1 = 10;
+
+union U5 {
+ int& i1; // expected-error {{union member 'i1' has reference type 'int &'}}
+};
+
+template <class A, class B> struct Either {
+ bool tag;
+ union { // expected-note 6 {{in instantiation of member class}}
+ A a;
+ B b; // expected-error 6 {{non-trivial}}
+ };
+
+ Either(const A& a) : tag(true), a(a) {}
+ Either(const B& b) : tag(false), b(b) {}
+};
+
+void fred() {
+ Either<int,Virtual> virt(0); // expected-note {{in instantiation of template}}
+ Either<int,VirtualBase> vbase(0); // expected-note {{in instantiation of template}}
+ Either<int,Ctor> ctor(0); // expected-note {{in instantiation of template}}
+ Either<int,CopyCtor> copyctor(0); // expected-note {{in instantiation of template}}
+ Either<int,CopyAssign> copyassign(0); // expected-note {{in instantiation of template}}
+ Either<int,Dtor> dtor(0); // expected-note {{in instantiation of template}}
+ Either<int,Okay> okay(0);
+}
diff --git a/clang/test/CXX/class/class.union/p2-0x.cpp b/clang/test/CXX/class/class.union/p2-0x.cpp
new file mode 100644
index 0000000..b5c4109
--- /dev/null
+++ b/clang/test/CXX/class/class.union/p2-0x.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+// Unlike in C++98, C++11 allows unions to have static data members.
+
+union U1 {
+ static constexpr int k1 = 0;
+ static const int k2 = k1;
+ static int k3 = k2; // expected-error {{non-const static data member must be initialized out of line}}
+ static constexpr double k4 = k2;
+ static const double k5 = k4; // expected-warning {{GNU extension}} expected-note {{use 'constexpr'}}
+ int n[k1 + 3];
+};
+
+constexpr int U1::k1;
+constexpr int U1::k2;
+int U1::k3;
+
+const double U1::k4;
+const double U1::k5;
+
+template<typename T>
+union U2 {
+ static const int k1;
+ static double k2;
+ T t;
+};
+template<typename T> constexpr int U2<T>::k1 = sizeof(U2<T>);
+template<typename T> double U2<T>::k2 = 5.3;
+
+static_assert(U2<int>::k1 == sizeof(int), "");
+static_assert(U2<char>::k1 == sizeof(char), "");
+
+union U3 {
+ static const int k;
+ U3() : k(0) {} // expected-error {{does not name a non-static data member}}
+};
+
+struct S {
+ union {
+ static const int n; // expected-error {{static members cannot be declared in an anonymous union}}
+ int a;
+ int b;
+ };
+};
+static union {
+ static const int k; // expected-error {{static members cannot be declared in an anonymous union}}
+ int n;
+};
diff --git a/clang/test/CXX/class/p1-0x.cpp b/clang/test/CXX/class/p1-0x.cpp
new file mode 100644
index 0000000..be5fdff
--- /dev/null
+++ b/clang/test/CXX/class/p1-0x.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+namespace Test1 {
+
+class A final { };
+
+}
diff --git a/clang/test/CXX/class/p2-0x.cpp b/clang/test/CXX/class/p2-0x.cpp
new file mode 100644
index 0000000..dbb01e5
--- /dev/null
+++ b/clang/test/CXX/class/p2-0x.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+namespace Test1 {
+
+class A final { }; // expected-note {{'A' declared here}}
+class B : A { }; // expected-error {{base 'A' is marked 'final'}}
+
+}
+
+namespace Test2 {
+
+template<typename T> struct A final { }; // expected-note 2 {{'A' declared here}}
+struct B : A<int> { }; // expected-error {{base 'A' is marked 'final'}}
+
+template<typename T> struct C : A<T> { }; // expected-error {{base 'A' is marked 'final'}}
+struct D : C<int> { }; // expected-note {{in instantiation of template class 'Test2::C<int>' requested here}}
+
+}
+
+namespace Test3 {
+
+template<typename T> struct A { };
+template<> struct A<int> final { }; // expected-note {{'A' declared here}}
+
+struct B : A<bool> { };
+struct C : A<int> { }; // expected-error {{base 'A' is marked 'final'}}
+
+}
+
diff --git a/clang/test/CXX/class/p6-0x.cpp b/clang/test/CXX/class/p6-0x.cpp
new file mode 100644
index 0000000..f2cf482
--- /dev/null
+++ b/clang/test/CXX/class/p6-0x.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+class Trivial { int n; void f(); };
+class NonTrivial1 { NonTrivial1(const NonTrivial1 &); };
+class NonTrivial2 { NonTrivial2(NonTrivial2 &&); };
+class NonTrivial3 { NonTrivial3 operator=(const NonTrivial3 &); };
+class NonTrivial4 { NonTrivial4 operator=(NonTrivial4 &&); };
+class NonTrivial5 { ~NonTrivial5(); };
+
+static_assert(__is_trivial(Trivial), "Trivial is not trivial");
+static_assert(!__is_trivial(NonTrivial1), "NonTrivial1 is trivial");
+static_assert(!__is_trivial(NonTrivial2), "NonTrivial2 is trivial");
+static_assert(!__is_trivial(NonTrivial3), "NonTrivial3 is trivial");
+static_assert(!__is_trivial(NonTrivial4), "NonTrivial4 is trivial");
+static_assert(!__is_trivial(NonTrivial5), "NonTrivial5 is trivial");
+
+struct Trivial2 {
+ Trivial2() = default;
+ Trivial2(const Trivial2 &) = default;
+ Trivial2(Trivial2 &&) = default;
+ Trivial2 &operator=(const Trivial2 &) = default;
+ Trivial2 &operator=(Trivial2 &) = default;
+ ~Trivial2() = default;
+};
+
+class NonTrivial6 { ~NonTrivial6(); };
+
+NonTrivial6::~NonTrivial6() = default;
+
+static_assert(!__is_trivial(NonTrivial6), "NonTrivial6 is trivial");
diff --git a/clang/test/CXX/conv/conv.mem/p4.cpp b/clang/test/CXX/conv/conv.mem/p4.cpp
new file mode 100644
index 0000000..e0748d8
--- /dev/null
+++ b/clang/test/CXX/conv/conv.mem/p4.cpp
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct Base {
+ int data;
+ int method();
+};
+int (Base::*data_ptr) = &Base::data;
+int (Base::*method_ptr)() = &Base::method;
+
+namespace test0 {
+ struct Derived : Base {};
+ void test() {
+ int (Derived::*d) = data_ptr;
+ int (Derived::*m)() = method_ptr;
+ }
+}
+
+// Can't be inaccessible.
+namespace test1 {
+ struct Derived : private Base {}; // expected-note 2 {{declared private here}}
+ void test() {
+ int (Derived::*d) = data_ptr; // expected-error {{cannot cast private base class 'Base' to 'test1::Derived'}}
+ int (Derived::*m)() = method_ptr; // expected-error {{cannot cast private base class 'Base' to 'test1::Derived'}}
+ }
+};
+
+// Can't be ambiguous.
+namespace test2 {
+ struct A : Base {};
+ struct B : Base {};
+ struct Derived : A, B {};
+ void test() {
+ int (Derived::*d) = data_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test2::Derived':}}
+ int (Derived::*m)() = method_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test2::Derived':}}
+ }
+}
+
+// Can't be virtual.
+namespace test3 {
+ struct Derived : virtual Base {};
+ void test() {
+ int (Derived::*d) = data_ptr; // expected-error {{conversion from pointer to member of class 'Base' to pointer to member of class 'test3::Derived' via virtual base 'Base' is not allowed}}
+ int (Derived::*m)() = method_ptr; // expected-error {{conversion from pointer to member of class 'Base' to pointer to member of class 'test3::Derived' via virtual base 'Base' is not allowed}}
+ }
+}
+
+// Can't be virtual even if there's a non-virtual path.
+namespace test4 {
+ struct A : Base {};
+ struct Derived : Base, virtual A {};
+ void test() {
+ int (Derived::*d) = data_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test4::Derived':}}
+ int (Derived::*m)() = method_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test4::Derived':}}
+ }
+}
+
+// PR6254: don't get thrown off by a virtual base.
+namespace test5 {
+ struct A {};
+ struct Derived : Base, virtual A {};
+ void test() {
+ int (Derived::*d) = data_ptr;
+ int (Derived::*m)() = method_ptr;
+ }
+}
diff --git a/clang/test/CXX/conv/conv.prom/p2.cpp b/clang/test/CXX/conv/conv.prom/p2.cpp
new file mode 100644
index 0000000..8d75419
--- /dev/null
+++ b/clang/test/CXX/conv/conv.prom/p2.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -ffreestanding %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -fshort-wchar -ffreestanding %s
+
+#include <stdint.h>
+
+// In theory, the promoted types vary by platform; however, in reality they
+// are quite consistent across all platforms where clang runs.
+
+extern int promoted_wchar;
+extern decltype(+L'a') promoted_wchar;
+
+extern int promoted_char16;
+extern decltype(+u'a') promoted_char16;
+
+extern unsigned promoted_char32;
+extern decltype(+U'a') promoted_char32;
diff --git a/clang/test/CXX/conv/conv.prom/p4.cpp b/clang/test/CXX/conv/conv.prom/p4.cpp
new file mode 100644
index 0000000..02a91cd
--- /dev/null
+++ b/clang/test/CXX/conv/conv.prom/p4.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+enum X : short { A, B };
+extern decltype(+A) x;
+extern int x;
+
+enum Y : long { C, D };
+extern decltype(+C) y;
+extern long y;
diff --git a/clang/test/CXX/conv/conv.ptr/p2.cpp b/clang/test/CXX/conv/conv.ptr/p2.cpp
new file mode 100644
index 0000000..8808d20
--- /dev/null
+++ b/clang/test/CXX/conv/conv.ptr/p2.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace pr7801 {
+ extern void* x[];
+ void* dummy[] = { &x };
+}
diff --git a/clang/test/CXX/conv/conv.qual/pr6089.cpp b/clang/test/CXX/conv/conv.qual/pr6089.cpp
new file mode 100644
index 0000000..ae75ec4
--- /dev/null
+++ b/clang/test/CXX/conv/conv.qual/pr6089.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+bool is_char_ptr( const char* );
+
+template< class T >
+ long is_char_ptr( T /* r */ );
+
+// Note: the const here does not lead to a qualification conversion
+template< class T >
+ void make_range( T* const r, bool );
+
+template< class T >
+ void make_range( T& r, long );
+
+void first_finder( const char*& Search )
+{
+ make_range( Search, is_char_ptr(Search) );
+}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp
new file mode 100644
index 0000000..069ca0a
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp
@@ -0,0 +1,93 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+// C++'0x [namespace.memdef] p3:
+// Every name first declared in a namespace is a member of that namespace. If
+// a friend declaration in a non-local class first declares a class or
+// function the friend class or function is a member of the innermost
+// enclosing namespace.
+
+namespace N {
+ struct S0 {
+ friend struct F0;
+ friend void f0(int);
+ struct F0 member_func();
+ };
+ struct F0 { };
+ F0 f0() { return S0().member_func(); }
+}
+N::F0 f0_var = N::f0();
+
+// Ensure we can handle attaching friend declarations to an enclosing namespace
+// with multiple contexts.
+namespace N { struct S1 { struct IS1; }; }
+namespace N {
+ struct S1::IS1 {
+ friend struct F1;
+ friend void f1(int);
+ struct F1 member_func();
+ };
+ struct F1 { };
+ F1 f1() { return S1::IS1().member_func(); }
+}
+N::F1 f1_var = N::f1();
+
+// The name of the friend is not found by unqualified lookup (3.4.1) or by
+// qualified lookup (3.4.3) until a matching declaration is provided in that
+// namespace scope (either before or after the class definition granting
+// friendship). If a friend function is called, its name may be found by the
+// name lookup that considers functions from namespaces and classes
+// associated with the types of the function arguments (3.4.2). If the name
+// in a friend declaration is neither qualified nor a template-id and the
+// declaration is a function or an elaborated-type-specifier, the lookup to
+// determine whether the entity has been previously declared shall not
+// consider any scopes outside the innermost enclosing namespace.
+
+template<typename T> struct X0 { };
+struct X1 { };
+
+struct Y {
+ template<typename T> union X0;
+ template<typename T> friend union X0;
+
+ union X1;
+ friend union X1;
+};
+
+namespace N {
+ namespace M {
+ template<typename T> class X;
+ }
+}
+
+namespace N3 {
+ class Y {
+ template<typename T> friend class N::M::X;
+ };
+}
+
+// FIXME: Woefully inadequate for testing
+
+// Friends declared as template-ids aren't subject to the restriction
+// on innermost namespaces.
+// rdar://problem/8552377
+namespace test5 {
+ template <class T> void f(T);
+ namespace ns {
+ class A {
+ friend void f<int>(int);
+ static void foo(); // expected-note 2 {{declared private here}}
+ };
+
+ // Note that this happens without instantiation.
+ template <class T> void f(T) {
+ A::foo(); // expected-error {{'foo' is a private member of 'test5::ns::A'}}
+ }
+ }
+
+ template <class T> void f(T) {
+ ns::A::foo(); // expected-error {{'foo' is a private member of 'test5::ns::A'}}
+ }
+
+ template void f<int>(int);
+ template void f<long>(long); //expected-note {{instantiation}}
+}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.unnamed/p1.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.unnamed/p1.cpp
new file mode 100644
index 0000000..b4ec585
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.unnamed/p1.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -emit-llvm-only -verify %s
+
+// This lame little test was ripped straight from the standard.
+namespace {
+ int i; // expected-note {{candidate}}
+}
+void test0() { i++; }
+
+namespace A {
+ namespace {
+ int i; // expected-note {{candidate}}
+ int j;
+ }
+ void test1() { i++; }
+}
+
+using namespace A;
+
+void test2() {
+ i++; // expected-error {{reference to 'i' is ambiguous}}
+ A::i++;
+ j++;
+}
+
+
+// Test that all anonymous namespaces in a translation unit are
+// considered the same context.
+namespace {
+ class Test3 {}; // expected-note {{previous definition}}
+}
+namespace {
+ class Test3 {}; // expected-error {{redefinition of 'Test3'}}
+}
+
+namespace test4 {
+ namespace {
+ class Test4 {}; // expected-note {{previous definition}}
+ }
+ namespace {
+ class Test4 {}; // expected-error {{redefinition of 'Test4'}}
+ }
+}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp
new file mode 100644
index 0000000..6ffa873
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -pedantic %s
+
+// Intentionally compiled as C++03 to test the extension warning.
+
+namespace a {} // original
+namespace a {} // ext
+inline namespace b {} // inline original expected-warning {{inline namespaces are}}
+inline namespace b {} // inline ext expected-warning {{inline namespaces are}}
+inline namespace {} // inline unnamed expected-warning {{inline namespaces are}}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p2.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p2.cpp
new file mode 100644
index 0000000..411c16c
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p2.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR8430
+namespace N {
+ class A { };
+}
+
+namespace M { }
+
+using namespace M;
+
+namespace N {
+ namespace M {
+ }
+}
+
+namespace M {
+ namespace N {
+ }
+}
+
+namespace N {
+ A *getA();
+}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp
new file mode 100644
index 0000000..98d12f9
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+namespace NIL {} // expected-note {{previous definition}}
+inline namespace NIL {} // expected-error {{cannot be reopened as inline}}
+inline namespace IL {} // expected-note {{previous definition}}
+namespace IL {} // expected-warning{{inline namespace cannot be re-opened as a non-inline namespace}}
+
+namespace {} // expected-note {{previous definition}}
+inline namespace {} // expected-error {{cannot be reopened as inline}}
+namespace X {
+ inline namespace {} // expected-note {{previous definition}}
+ namespace {} // expected-error {{cannot be reopened as non-inline}}
+}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp
new file mode 100644
index 0000000..3bc4856
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp
@@ -0,0 +1,118 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// Fun things you can do with inline namespaces:
+
+inline namespace X {
+ void f1();
+
+ inline namespace Y {
+ void f2();
+
+ template <typename T> class C {};
+ }
+
+ // Specialize and partially specialize somewhere else.
+ template <> class C<int> {};
+ template <typename T> class C<T*> {};
+}
+
+// Qualified and unqualified lookup as if member of enclosing NS.
+void foo1() {
+ f1();
+ ::f1();
+ X::f1();
+ Y::f1(); // expected-error {{no member named 'f1' in namespace 'X::Y'}}
+
+ f2();
+ ::f2();
+ X::f2();
+ Y::f2();
+}
+
+template <> class C<float> {};
+template <typename T> class C<T&> {};
+
+template class C<double>;
+
+
+// As well as all the fun with ADL.
+
+namespace ADL {
+ struct Outer {};
+
+ inline namespace IL {
+ struct Inner {};
+
+ void fo(Outer);
+ }
+
+ void fi(Inner);
+
+ inline namespace IL2 {
+ void fi2(Inner);
+ }
+}
+
+void foo2() {
+ ADL::Outer o;
+ ADL::Inner i;
+ fo(o);
+ fi(i);
+ fi2(i);
+}
+
+// Let's not forget overload sets.
+struct Distinct {};
+inline namespace Over {
+ void over(Distinct);
+}
+void over(int);
+
+void foo3() {
+ Distinct d;
+ ::over(d);
+}
+
+// Don't forget to do correct lookup for redeclarations.
+namespace redecl { inline namespace n1 {
+
+ template <class Tp> class allocator;
+
+ template <>
+ class allocator<void>
+ {
+ public:
+ typedef const void* const_pointer;
+ };
+
+ template <class Tp>
+ class allocator
+ {
+ public:
+ typedef Tp& reference;
+
+ void allocate(allocator<void>::const_pointer = 0);
+ };
+
+} }
+
+// Normal redeclarations (not for explicit instantiations or
+// specializations) are distinct in an inline namespace vs. not in an
+// inline namespace.
+namespace redecl2 {
+ inline namespace n1 {
+ void f(int) { }
+ struct X1 { };
+ template<typename T> void f(T) { }
+ template<typename T> struct X2 { };
+ int i = 71;
+ enum E { e };
+ }
+
+ void f(int) { }
+ struct X1 { };
+ template<typename T> void f(T) { }
+ template<typename T> struct X2 { };
+ int i = 71;
+ enum E { e };
+}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp
new file mode 100644
index 0000000..bf30ee7
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// We have to avoid ADL for this test.
+
+template <unsigned N> class test {};
+
+class foo {}; // expected-note {{candidate}}
+test<0> foo(foo); // expected-note {{candidate}}
+
+namespace Test0 {
+ class foo { int x; };
+ test<1> foo(class foo);
+
+ namespace A {
+ test<2> foo(class ::foo); // expected-note {{candidate}} \
+ // expected-note{{passing argument to parameter here}}
+
+ void test0() {
+ using ::foo;
+
+ class foo a;
+ test<0> _ = (foo)(a);
+ }
+
+ void test1() {
+ using Test0::foo;
+
+ class foo a;
+ test<1> _ = (foo)(a);
+ };
+
+ void test2() {
+ class ::foo a;
+
+ // Argument-dependent lookup is ambiguous between B:: and ::.
+ test<0> _0 = foo(a); // expected-error {{call to 'foo' is ambiguous}}
+
+ // But basic unqualified lookup is not.
+ test<2> _1 = (foo)(a);
+
+ class Test0::foo b;
+ test<2> _2 = (foo)(b); // expected-error {{no viable conversion from 'class Test0::foo' to 'class ::foo'}}
+ }
+ }
+}
+
+namespace Test1 {
+ namespace A {
+ class a {};
+ }
+
+ namespace B {
+ typedef class {} b;
+ }
+
+ namespace C {
+ int c(); // expected-note {{target of using declaration}}
+ }
+
+ namespace D {
+ using typename A::a;
+ using typename B::b;
+ using typename C::c; // expected-error {{'typename' keyword used on a non-type}}
+
+ a _1 = A::a();
+ b _2 = B::b();
+ }
+}
+
+namespace test2 {
+ class A {
+ protected:
+ operator int();
+ operator bool();
+ };
+
+ class B : private A {
+ protected:
+ using A::operator int; // expected-note {{declared protected here}}
+ public:
+ using A::operator bool;
+ };
+
+ int test() {
+ bool b = B();
+ return B(); // expected-error {{'operator int' is a protected member of 'test2::B'}}
+ }
+}
+
+namespace test3 {
+ class A {
+ public:
+ ~A();
+ };
+
+ class B {
+ friend class C;
+ private:
+ operator A*();
+ };
+
+ class C : public B {
+ public:
+ using B::operator A*;
+ };
+
+ void test() {
+ delete C();
+ }
+}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp
new file mode 100644
index 0000000..546c4a4
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace test0 {
+ namespace ns0 {
+ class tag;
+ int tag();
+ }
+
+ namespace ns1 {
+ using ns0::tag;
+ }
+
+ namespace ns2 {
+ using ns0::tag;
+ }
+
+ using ns1::tag;
+ using ns2::tag;
+}
+
+// PR 5752
+namespace test1 {
+ namespace ns {
+ void foo();
+ }
+
+ using ns::foo;
+ void foo(int);
+
+ namespace ns {
+ using test1::foo;
+ }
+}
+
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp
new file mode 100644
index 0000000..c7966ce
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++03 [namespace.udecl]p11:
+// If a function declaration in namespace scope or block scope has
+// the same name and the same parameter types as a function
+// introduced by a using-declaration, the program is
+// ill-formed. [Note: two using-declarations may introduce functions
+// with the same name and the same parameter types. If, for a call
+// to an unqualified function name, function overload resolution
+// selects the functions introduced by such using-declarations, the
+// function call is ill-formed.
+
+namespace test0 {
+ namespace ns { void foo(); } // expected-note {{target of using declaration}}
+ int foo(void); // expected-note {{conflicting declaration}}
+ using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}}
+}
+
+namespace test1 {
+ namespace ns { void foo(); } // expected-note {{target of using declaration}}
+ using ns::foo; //expected-note {{using declaration}}
+ int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}}
+}
+
+namespace test2 {
+ namespace ns { void foo(); } // expected-note 2 {{target of using declaration}}
+ void test0() {
+ int foo(void); // expected-note {{conflicting declaration}}
+ using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}}
+ }
+
+ void test1() {
+ using ns::foo; //expected-note {{using declaration}}
+ int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}}
+ }
+}
+
+namespace test3 {
+ namespace ns { void foo(); } // expected-note 2 {{target of using declaration}}
+ class Test0 {
+ void test() {
+ int foo(void); // expected-note {{conflicting declaration}}
+ using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}}
+ }
+ };
+
+ class Test1 {
+ void test() {
+ using ns::foo; //expected-note {{using declaration}}
+ int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}}
+ }
+ };
+}
+
+namespace test4 {
+ namespace ns { void foo(); } // expected-note 2 {{target of using declaration}}
+ template <typename> class Test0 {
+ void test() {
+ int foo(void); // expected-note {{conflicting declaration}}
+ using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}}
+ }
+ };
+
+ template <typename> class Test1 {
+ void test() {
+ using ns::foo; //expected-note {{using declaration}}
+ int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}}
+ }
+ };
+}
+
+// FIXME: we should be able to diagnose both of these, but we can't.
+namespace test5 {
+ namespace ns { void foo(int); }
+ template <typename T> class Test0 {
+ void test() {
+ int foo(T);
+ using ns::foo;
+ }
+ };
+
+ template <typename T> class Test1 {
+ void test() {
+ using ns::foo;
+ int foo(T);
+ }
+ };
+
+ template class Test0<int>;
+ template class Test1<int>;
+}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
new file mode 100644
index 0000000..cc28bf6
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
@@ -0,0 +1,163 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++03 [namespace.udecl]p12:
+// When a using-declaration brings names from a base class into a
+// derived class scope, member functions in the derived class
+// override and/or hide member functions with the same name and
+// parameter types in a base class (rather than conflicting).
+
+template <unsigned n> struct Opaque {};
+template <unsigned n> void expect(Opaque<n> _) {}
+
+// PR5727
+// This just shouldn't crash.
+namespace test0 {
+ template<typename> struct RefPtr { };
+ template<typename> struct PtrHash {
+ static void f() { }
+ };
+ template<typename T> struct PtrHash<RefPtr<T> > : PtrHash<T*> {
+ using PtrHash<T*>::f;
+ static void f() { f(); }
+ };
+}
+
+// Simple hiding.
+namespace test1 {
+ struct Base {
+ Opaque<0> foo(Opaque<0>);
+ Opaque<0> foo(Opaque<1>);
+ Opaque<0> foo(Opaque<2>);
+ };
+
+ // using before decls
+ struct Test0 : Base {
+ using Base::foo;
+ Opaque<1> foo(Opaque<1>);
+ Opaque<1> foo(Opaque<3>);
+
+ void test0() { Opaque<0> _ = foo(Opaque<0>()); }
+ void test1() { Opaque<1> _ = foo(Opaque<1>()); }
+ void test2() { Opaque<0> _ = foo(Opaque<2>()); }
+ void test3() { Opaque<1> _ = foo(Opaque<3>()); }
+ };
+
+ // using after decls
+ struct Test1 : Base {
+ Opaque<1> foo(Opaque<1>);
+ Opaque<1> foo(Opaque<3>);
+ using Base::foo;
+
+ void test0() { Opaque<0> _ = foo(Opaque<0>()); }
+ void test1() { Opaque<1> _ = foo(Opaque<1>()); }
+ void test2() { Opaque<0> _ = foo(Opaque<2>()); }
+ void test3() { Opaque<1> _ = foo(Opaque<3>()); }
+ };
+
+ // using between decls
+ struct Test2 : Base {
+ Opaque<1> foo(Opaque<0>);
+ using Base::foo;
+ Opaque<1> foo(Opaque<2>);
+ Opaque<1> foo(Opaque<3>);
+
+ void test0() { Opaque<1> _ = foo(Opaque<0>()); }
+ void test1() { Opaque<0> _ = foo(Opaque<1>()); }
+ void test2() { Opaque<1> _ = foo(Opaque<2>()); }
+ void test3() { Opaque<1> _ = foo(Opaque<3>()); }
+ };
+}
+
+// Crazy dependent hiding.
+namespace test2 {
+ struct Base {
+ void foo(int);
+ };
+
+ template <typename T> struct Derived1 : Base {
+ using Base::foo;
+ void foo(T);
+
+ void testUnresolved(int i) { foo(i); }
+ };
+
+ void test0(int i) {
+ Derived1<int> d1;
+ d1.foo(i);
+ d1.testUnresolved(i);
+ }
+
+ // Same thing, except with the order of members reversed.
+ template <typename T> struct Derived2 : Base {
+ void foo(T);
+ using Base::foo;
+
+ void testUnresolved(int i) { foo(i); }
+ };
+
+ void test1(int i) {
+ Derived2<int> d2;
+ d2.foo(i);
+ d2.testUnresolved(i);
+ }
+}
+
+// Hiding of member templates.
+namespace test3 {
+ struct Base {
+ template <class T> Opaque<0> foo() { return Opaque<0>(); }
+ template <int n> Opaque<1> foo() { return Opaque<1>(); }
+ };
+
+ struct Derived1 : Base {
+ using Base::foo;
+ template <int n> Opaque<2> foo() { return Opaque<2>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'n'}}
+ };
+
+ struct Derived2 : Base {
+ template <int n> Opaque<2> foo() { return Opaque<2>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'n'}}
+ using Base::foo;
+ };
+
+ struct Derived3 : Base {
+ using Base::foo;
+ template <class T> Opaque<3> foo() { return Opaque<3>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'T'}}
+ };
+
+ struct Derived4 : Base {
+ template <class T> Opaque<3> foo() { return Opaque<3>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'T'}}
+ using Base::foo;
+ };
+
+ void test() {
+ expect<0>(Base().foo<int>());
+ expect<1>(Base().foo<0>());
+ expect<0>(Derived1().foo<int>()); // expected-error {{no matching member function for call to 'foo'}}
+ expect<2>(Derived1().foo<0>());
+ expect<0>(Derived2().foo<int>()); // expected-error {{no matching member function for call to 'foo'}}
+ expect<2>(Derived2().foo<0>());
+ expect<3>(Derived3().foo<int>());
+ expect<1>(Derived3().foo<0>()); // expected-error {{no matching member function for call to 'foo'}}
+ expect<3>(Derived4().foo<int>());
+ expect<1>(Derived4().foo<0>()); // expected-error {{no matching member function for call to 'foo'}}
+ }
+}
+
+// PR7384: access control for member templates.
+namespace test4 {
+ class Base {
+ protected:
+ template<typename T> void foo(T);
+ template<typename T> void bar(T); // expected-note {{declared protected here}}
+ };
+
+ struct Derived : Base {
+ using Base::foo;
+ };
+
+ void test() {
+ Derived d;
+ d.foo<int>(3);
+ d.bar<int>(3); // expected-error {{'bar' is a protected member}}
+ }
+}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p13.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p13.cpp
new file mode 100644
index 0000000..dd44bfc
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p13.cpp
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++03 [namespace.udecl]p3:
+// For the purpose of overload resolution, the functions which are
+// introduced by a using-declaration into a derived class will be
+// treated as though they were members of the derived class. In
+// particular, the implicit this parameter shall be treated as if it
+// were a pointer to the derived class rather than to the base
+// class. This has no effect on the type of the function, and in all
+// other respects the function remains a member of the base class.
+
+namespace test0 {
+ struct Opaque0 {};
+ struct Opaque1 {};
+
+ struct Base {
+ Opaque0 test0(int*);
+ Opaque0 test1(const int*);
+ Opaque0 test2(int*);
+ Opaque0 test3(int*) const;
+ };
+
+ struct Derived : Base {
+ using Base::test0;
+ Opaque1 test0(const int*);
+
+ using Base::test1;
+ Opaque1 test1(int*);
+
+ using Base::test2;
+ Opaque1 test2(int*) const;
+
+ using Base::test3;
+ Opaque1 test3(int*);
+ };
+
+ void test0() {
+ Opaque0 a = Derived().test0((int*) 0);
+ Opaque1 b = Derived().test0((const int*) 0);
+ }
+
+ void test1() {
+ Opaque1 a = Derived().test1((int*) 0);
+ Opaque0 b = Derived().test1((const int*) 0);
+ }
+
+ void test2() {
+ Opaque0 a = ((Derived*) 0)->test2((int*) 0);
+ Opaque1 b = ((const Derived*) 0)->test2((int*) 0);
+ }
+
+ void test3() {
+ Opaque1 a = ((Derived*) 0)->test3((int*) 0);
+ Opaque0 b = ((const Derived*) 0)->test3((int*) 0);
+ }
+}
+
+// Typedef redeclaration.
+namespace rdar8018262 {
+ typedef void (*fp)();
+
+ namespace N {
+ typedef void (*fp)();
+ }
+
+ using N::fp;
+
+ fp fp_1;
+}
+
+// Things to test:
+// member operators
+// conversion operators
+// call operators
+// call-surrogate conversion operators
+// everything, but in dependent contexts
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3-cxx0x.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3-cxx0x.cpp
new file mode 100644
index 0000000..f61437e
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3-cxx0x.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// C++0x N2914.
+
+struct B {
+ void f(char);
+ void g(char);
+ enum E { e };
+ union { int x; };
+};
+
+class C {
+ int g();
+};
+
+class D2 : public B {
+ using B::f;
+ using B::e;
+ using B::x;
+ using C::g; // expected-error{{using declaration refers into 'C::', which is not a base class of 'D2'}}
+};
+
+namespace test1 {
+ struct Base {
+ int foo();
+ };
+
+ struct Unrelated {
+ int foo();
+ };
+
+ struct Subclass : Base {
+ };
+
+ namespace InnerNS {
+ int foo();
+ }
+
+ // We should be able to diagnose these without instantiation.
+ template <class T> struct C : Base {
+ using InnerNS::foo; // expected-error {{not a class}}
+ using Base::bar; // expected-error {{no member named 'bar'}}
+ using Unrelated::foo; // expected-error {{not a base class}}
+ using C::foo; // expected-error {{refers to its own class}}
+ using Subclass::foo; // expected-error {{not a base class}}
+ };
+}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp
new file mode 100644
index 0000000..a43d9e0
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp
@@ -0,0 +1,213 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++03 [namespace.udecl]p4:
+// A using-declaration used as a member-declaration shall refer to a
+// member of a base class of the class being defined, shall refer to
+// a member of an anonymous union that is a member of a base class
+// of the class being defined, or shall refer to an enumerator for
+// an enumeration type that is a member of a base class of the class
+// being defined.
+
+// There is no directly analogous paragraph in C++0x, and the feature
+// works sufficiently differently there that it needs a separate test.
+
+namespace test0 {
+ namespace NonClass {
+ typedef int type;
+ struct hiding {};
+ int hiding;
+ static union { double union_member; };
+ enum tagname { enumerator };
+ }
+
+ class Test0 {
+ using NonClass::type; // expected-error {{not a class}}
+ using NonClass::hiding; // expected-error {{not a class}}
+ using NonClass::union_member; // expected-error {{not a class}}
+ using NonClass::enumerator; // expected-error {{not a class}}
+ };
+}
+
+struct Opaque0 {};
+
+namespace test1 {
+ struct A {
+ typedef int type;
+ struct hiding {}; // expected-note {{previous use is here}}
+ Opaque0 hiding;
+ union { double union_member; };
+ enum tagname { enumerator };
+ };
+
+ struct B : A {
+ using A::type;
+ using A::hiding;
+ using A::union_member;
+ using A::enumerator;
+ using A::tagname;
+
+ void test0() {
+ type t = 0;
+ }
+
+ void test1() {
+ typedef struct A::hiding local;
+ struct hiding _ = local();
+ }
+
+ void test2() {
+ union hiding _; // expected-error {{tag type that does not match previous}}
+ }
+
+ void test3() {
+ char array[sizeof(union_member) == sizeof(double) ? 1 : -1];
+ }
+
+ void test4() {
+ enum tagname _ = enumerator;
+ }
+
+ void test5() {
+ Opaque0 _ = hiding;
+ }
+ };
+}
+
+namespace test2 {
+ struct A {
+ typedef int type;
+ struct hiding {}; // expected-note {{previous use is here}}
+ int hiding;
+ union { double union_member; };
+ enum tagname { enumerator };
+ };
+
+ template <class T> struct B : A {
+ using A::type;
+ using A::hiding;
+ using A::union_member;
+ using A::enumerator;
+ using A::tagname;
+
+ void test0() {
+ type t = 0;
+ }
+
+ void test1() {
+ typedef struct A::hiding local;
+ struct hiding _ = local();
+ }
+
+ void test2() {
+ union hiding _; // expected-error {{tag type that does not match previous}}
+ }
+
+ void test3() {
+ char array[sizeof(union_member) == sizeof(double) ? 1 : -1];
+ }
+
+ void test4() {
+ enum tagname _ = enumerator;
+ }
+
+ void test5() {
+ Opaque0 _ = hiding;
+ }
+ };
+}
+
+namespace test3 {
+ struct hiding {};
+
+ template <class T> struct A {
+ typedef int type; // expected-note {{target of using declaration}}
+ struct hiding {};
+ Opaque0 hiding; // expected-note {{target of using declaration}}
+ union { double union_member; }; // expected-note {{target of using declaration}}
+ enum tagname { enumerator }; // expected-note 2 {{target of using declaration}}
+ };
+
+ template <class T> struct B : A<T> {
+ using A<T>::type; // expected-error {{dependent using declaration resolved to type without 'typename'}}
+ using A<T>::hiding;
+ using A<T>::union_member;
+ using A<T>::enumerator;
+ using A<T>::tagname; // expected-error {{dependent using declaration resolved to type without 'typename'}}
+
+ // FIXME: re-enable these when the various bugs involving tags are fixed
+#if 0
+ void test1() {
+ typedef struct A<T>::hiding local;
+ struct hiding _ = local();
+ }
+
+ void test2() {
+ typedef struct A<T>::hiding local;
+ union hiding _ = local();
+ }
+#endif
+
+ void test3() {
+ char array[sizeof(union_member) == sizeof(double) ? 1 : -1];
+ }
+
+#if 0
+ void test4() {
+ enum tagname _ = enumerator;
+ }
+#endif
+
+ void test5() {
+ Opaque0 _ = hiding;
+ }
+ };
+
+ template struct B<int>; // expected-note {{in instantiation}}
+
+ template <class T> struct C : A<T> {
+ using typename A<T>::type;
+ using typename A<T>::hiding; // expected-note {{declared here}} \
+ // expected-error {{'typename' keyword used on a non-type}}
+ using typename A<T>::union_member; // expected-error {{'typename' keyword used on a non-type}}
+ using typename A<T>::enumerator; // expected-error {{'typename' keyword used on a non-type}}
+
+ void test6() {
+ type t = 0;
+ }
+
+ void test7() {
+ Opaque0 _ = hiding; // expected-error {{does not refer to a value}}
+ }
+ };
+
+ template struct C<int>; // expected-note {{in instantiation}}
+}
+
+namespace test4 {
+ struct Base {
+ int foo();
+ };
+
+ struct Unrelated {
+ int foo();
+ };
+
+ struct Subclass : Base {
+ };
+
+ namespace InnerNS {
+ int foo();
+ }
+
+ // We should be able to diagnose these without instantiation.
+ template <class T> struct C : Base {
+ using InnerNS::foo; // expected-error {{not a class}}
+ using Base::bar; // expected-error {{no member named 'bar'}}
+ using Unrelated::foo; // expected-error {{not a base class}}
+ using C::foo; // legal in C++03
+ using Subclass::foo; // legal in C++03
+
+ int bar(); //expected-note {{target of using declaration}}
+ using C::bar; // expected-error {{refers to its own class}}
+ };
+}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp
new file mode 100644
index 0000000..edaa975
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// C++0x N2914.
+
+struct A {
+ template<class T> void f(T);
+ template<class T> struct X { };
+};
+
+struct B : A {
+ using A::f<double>; // expected-error{{using declaration can not refer to a template specialization}}
+ using A::X<int>; // expected-error{{using declaration can not refer to a template specialization}}
+};
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp
new file mode 100644
index 0000000..c4b8849
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// C++0x N2914.
+
+namespace A {
+ namespace B { }
+}
+
+using A::B; // expected-error{{using declaration can not refer to namespace}}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp
new file mode 100644
index 0000000..78b5a41
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// C++0x N2914.
+
+struct X {
+ int i;
+ static int a;
+};
+
+using X::i; // expected-error{{using declaration can not refer to class member}}
+using X::s; // expected-error{{using declaration can not refer to class member}}
+
+void f() {
+ using X::i; // expected-error{{using declaration can not refer to class member}}
+ using X::s; // expected-error{{using declaration can not refer to class member}}
+}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8.cpp
new file mode 100644
index 0000000..4660971
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8.cpp
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct Opaque0 {};
+struct Opaque1 {};
+
+// Redeclarations are okay in a namespace.
+namespace test0 {
+ namespace ns {
+ void foo(Opaque0); // expected-note 2 {{candidate function}}
+ }
+
+ using ns::foo;
+ using ns::foo;
+
+ void test0() {
+ foo(Opaque1()); // expected-error {{no matching function for call}}
+ }
+
+ namespace ns {
+ void foo(Opaque1);
+ }
+
+ void test1() {
+ foo(Opaque1()); // expected-error {{no matching function for call}}
+ }
+
+ using ns::foo;
+
+ void test2() {
+ foo(Opaque1());
+ }
+
+ using ns::foo;
+}
+
+// Make sure we handle transparent contexts the same way.
+namespace test1 {
+ namespace ns {
+ void foo(Opaque0); // expected-note 2 {{candidate function}}
+ }
+
+ extern "C++" {
+ using ns::foo;
+ }
+
+ void test0() {
+ foo(Opaque1()); // expected-error {{no matching function for call}}
+ }
+
+ namespace ns {
+ void foo(Opaque1);
+ }
+
+ void test1() {
+ foo(Opaque1()); // expected-error {{no matching function for call}}
+ }
+
+ extern "C++" {
+ using ns::foo;
+ }
+
+ void test2() {
+ foo(Opaque1());
+ }
+}
+
+// Make sure we detect invalid redeclarations that can't be detected
+// until template instantiation.
+namespace test2 {
+ template <class T> struct Base {
+ typedef Base type;
+ void foo();
+ };
+
+ template <class T> struct Derived : Base<T> {
+ // These are invalid redeclarations, detectable only after
+ // instantiation.
+ using Base<T>::foo; // expected-note {{previous using decl}}
+ using Base<T>::type::foo; //expected-error {{redeclaration of using decl}}
+ };
+
+ template struct Derived<int>; // expected-note {{in instantiation of template class}}
+}
+
+// Redeclarations are okay in a function.
+namespace test3 {
+ namespace N {
+ int f(int);
+ typedef int type;
+ }
+
+ void g() {
+ using N::f;
+ using N::f;
+ using N::type;
+ using N::type;
+ }
+}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp
new file mode 100644
index 0000000..20a19ab
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp
@@ -0,0 +1,141 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// (this actually occurs before paragraph 1)
+namespace test0 {
+ namespace A {}
+ class B {
+ using namespace A; // expected-error {{'using namespace' is not allowed in classes}}
+ };
+}
+
+
+struct opaque0 {};
+struct opaque1 {};
+
+// Test that names appear as if in deepest common ancestor.
+namespace test1 {
+ namespace A {
+ namespace B {
+ opaque0 foo(); // expected-note {{candidate}}
+ }
+ }
+
+ namespace C {
+ opaque1 foo(); // expected-note {{candidate}}
+
+ opaque1 test() {
+ using namespace A::B;
+ return foo(); // C::foo
+ }
+ }
+
+ opaque1 test() {
+ using namespace A::B;
+ using namespace C;
+ return foo(); // expected-error {{call to 'foo' is ambiguous}}
+ }
+}
+
+// Same thing, but with the directives in namespaces.
+namespace test2 {
+ namespace A {
+ namespace B {
+ opaque0 foo(); // expected-note {{candidate}}
+ }
+ }
+
+ namespace C {
+ opaque1 foo(); // expected-note {{candidate}}
+
+ namespace test {
+ using namespace A::B;
+
+ opaque1 test() {
+ return foo(); // C::foo
+ }
+ }
+ }
+
+ namespace test {
+ using namespace A::B;
+ using namespace C;
+
+ opaque1 test() {
+ return foo(); // expected-error {{call to 'foo' is ambiguous}}
+ }
+ }
+}
+
+// Transitivity.
+namespace test3 {
+ namespace A {
+ namespace B {
+ opaque0 foo();
+ }
+ }
+ namespace C {
+ using namespace A;
+ }
+
+ opaque0 test0() {
+ using namespace C;
+ using namespace B;
+ return foo();
+ }
+
+ namespace D {
+ using namespace C;
+ }
+ namespace A {
+ opaque1 foo();
+ }
+
+ opaque1 test1() {
+ using namespace D;
+ return foo();
+ }
+}
+
+// Transitivity acts like synthetic using directives.
+namespace test4 {
+ namespace A {
+ namespace B {
+ opaque0 foo(); // expected-note {{candidate}}
+ }
+ }
+
+ namespace C {
+ using namespace A::B;
+ }
+
+ opaque1 foo(); // expected-note {{candidate}}
+
+ namespace A {
+ namespace D {
+ using namespace C;
+ }
+
+ opaque0 test() {
+ using namespace D;
+ return foo();
+ }
+ }
+
+ opaque0 test() {
+ using namespace A::D;
+ return foo(); // expected-error {{call to 'foo' is ambiguous}}
+ }
+}
+
+// Bug: using directives should be followed when parsing default
+// arguments in scoped declarations.
+class test5 {
+ int inc(int x);
+};
+namespace Test5 {
+ int default_x = 0;
+}
+using namespace Test5;
+int test5::inc(int x = default_x) {
+ return x+1;
+}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p6.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p6.cpp
new file mode 100644
index 0000000..4cb91cd
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p6.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/8296180>
+typedef int pid_t;
+namespace ns {
+ typedef int pid_t;
+}
+using namespace ns;
+pid_t x;
+
+struct A { };
+namespace ns {
+ typedef ::A A;
+}
+A a;
diff --git a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p6.cpp b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p6.cpp
new file mode 100644
index 0000000..f9702ba
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p6.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+namespace std_example {
+
+int p[10];
+void f() {
+ int x = 42, y[5];
+ // FIXME: Produce a better diagnostic for this case.
+ int(p[[x] { return x; }()]); // expected-error {{expected ']'}}
+ y[[] { return 2; }()] = 2; // expected-error {{consecutive left square brackets}}
+}
+
+}
diff --git a/clang/test/CXX/dcl.dcl/dcl.enum/p5.cpp b/clang/test/CXX/dcl.dcl/dcl.enum/p5.cpp
new file mode 100644
index 0000000..f260624
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.enum/p5.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s
+template<typename T> int force_same(T, T);
+
+// C++ [dcl.enum]p5:
+// [...] If the underlying type is not fixed, the type of each enumerator is
+// the type of its initializing value:
+// - If an initializer is specified for an enumerator, the initializing
+// value has the same type as the expression.
+enum Bullet1 {
+ Bullet1Val1 = 'a',
+ Bullet1Val2 = 10u,
+ Bullet1Val1IsChar = sizeof(force_same(Bullet1Val1, char(0))),
+ Bullet1Val2IsUnsigned = sizeof(force_same(Bullet1Val2, unsigned(0)))
+};
+
+// - If no initializer is specified for the first enumerator, the
+// initializing value has an unspecified integral type.
+enum Bullet2 {
+ Bullet2Val,
+ Bullet2ValIsInt = sizeof(force_same(Bullet2Val, int(0)))
+};
+
+// - Otherwise the type of the initializing value is the same as the type
+// of the initializing value of the preceding enumerator unless the
+// incremented value is not representable in that type, in which case the
+// type is an unspecified integral type sufficient to contain the
+// incremented value. If no such type exists, the program is ill-formed.
+enum Bullet3a {
+ Bullet3aVal1 = 17,
+ Bullet3aVal2,
+ Bullet3aVal2IsInt = sizeof(force_same(Bullet3aVal2, int(0))),
+ Bullet3aVal3 = 2147483647,
+ Bullet3aVal3IsInt = sizeof(force_same(Bullet3aVal3, int(0))),
+ Bullet3aVal4,
+ Bullet3aVal4IsUnsigned = sizeof(force_same(Bullet3aVal4, 0ul))
+};
+
+enum Bullet3b {
+ Bullet3bVal1 = 17u,
+ Bullet3bVal2,
+ Bullet3bVal2IsInt = sizeof(force_same(Bullet3bVal2, 0u)),
+ Bullet3bVal3 = 2147483647u,
+ Bullet3bVal3IsInt = sizeof(force_same(Bullet3bVal3, 0u)),
+ Bullet3bVal4,
+ Bullet3bVal4IsUnsigned = sizeof(force_same(Bullet3bVal4, 0ul))
+};
+
+enum Bullet3c {
+ Bullet3cVal1 = 0xFFFFFFFFFFFFFFFEull,
+ Bullet3cVal2,
+ Bullet3cVal3 // expected-warning{{not representable}}
+};
+
+// Following the closing brace of an enum-specifier, each enumerator has the
+// type of its enumeration.
+int array0[sizeof(force_same(Bullet3bVal3, Bullet3b(0)))? 1 : -1];
diff --git a/clang/test/CXX/dcl.dcl/dcl.link/p7.cpp b/clang/test/CXX/dcl.dcl/dcl.link/p7.cpp
new file mode 100644
index 0000000..bd9ff3c
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.link/p7.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+struct X { };
+
+// CHECK: @x1 = global %struct.X zeroinitializer
+// CHECK: @x4 = global %struct.X zeroinitializer
+// CHECK: @x2 = external global %struct.X
+// CHECK: @x3 = external global %struct.X
+extern "C" {
+
+
+ X x1;
+}
+
+extern "C" X x2;
+
+extern X x3;
+
+X x4;
+
+X& get(int i) {
+ if (i == 1)
+ return x1;
+ else if (i == 2)
+ return x2;
+ else if (i == 3)
+ return x3;
+ else
+ return x4;
+}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
new file mode 100644
index 0000000..6820fc6
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct notlit { // expected-note {{not literal because}}
+ notlit() {}
+};
+struct notlit2 {
+ notlit2() {}
+};
+
+// valid declarations
+constexpr int i1 = 0;
+constexpr int f1() { return 0; }
+struct s1 {
+ constexpr static int mi1 = 0;
+ const static int mi2;
+};
+constexpr int s1::mi2 = 0;
+
+// invalid declarations
+// not a definition of an object
+constexpr extern int i2; // expected-error {{constexpr variable declaration must be a definition}}
+// not a literal type
+constexpr notlit nl1; // expected-error {{constexpr variable cannot have non-literal type 'const notlit'}}
+// function parameters
+void f2(constexpr int i) {} // expected-error {{function parameter cannot be constexpr}}
+// non-static member
+struct s2 {
+ constexpr int mi1; // expected-error {{non-static data member cannot be constexpr}}
+ static constexpr int mi2; // expected-error {{requires an initializer}}
+};
+// typedef
+typedef constexpr int CI; // expected-error {{typedef cannot be constexpr}}
+// tag
+constexpr class C1 {}; // expected-error {{class cannot be marked constexpr}}
+constexpr struct S1 {}; // expected-error {{struct cannot be marked constexpr}}
+constexpr union U1 {}; // expected-error {{union cannot be marked constexpr}}
+constexpr enum E1 {}; // expected-error {{enum cannot be marked constexpr}}
+template <typename T> constexpr class TC1 {}; // expected-error {{class cannot be marked constexpr}}
+template <typename T> constexpr struct TS1 {}; // expected-error {{struct cannot be marked constexpr}}
+template <typename T> constexpr union TU1 {}; // expected-error {{union cannot be marked constexpr}}
+class C2 {} constexpr; // expected-error {{class cannot be marked constexpr}}
+struct S2 {} constexpr; // expected-error {{struct cannot be marked constexpr}}
+union U2 {} constexpr; // expected-error {{union cannot be marked constexpr}}
+enum E2 {} constexpr; // expected-error {{enum cannot be marked constexpr}}
+constexpr class C3 {} c3 = C3();
+constexpr struct S3 {} s3 = S3();
+constexpr union U3 {} u3 = {};
+constexpr enum E3 { V3 } e3 = V3;
+class C4 {} constexpr c4 = C4();
+struct S4 {} constexpr s4 = S4();
+union U4 {} constexpr u4 = {};
+enum E4 { V4 } constexpr e4 = V4;
+constexpr int; // expected-error {{constexpr can only be used in variable and function declarations}}
+// redeclaration mismatch
+constexpr int f3(); // expected-note {{previous declaration is here}}
+int f3(); // expected-error {{non-constexpr declaration of 'f3' follows constexpr declaration}}
+int f4(); // expected-note {{previous declaration is here}}
+constexpr int f4(); // expected-error {{constexpr declaration of 'f4' follows non-constexpr declaration}}
+template<typename T> constexpr T f5(T);
+template<typename T> constexpr T f5(T); // expected-note {{previous}}
+template<typename T> T f5(T); // expected-error {{non-constexpr declaration of 'f5' follows constexpr declaration}}
+template<typename T> T f6(T); // expected-note {{here}}
+template<typename T> constexpr T f6(T); // expected-error {{constexpr declaration of 'f6' follows non-constexpr declaration}}
+// destructor
+struct ConstexprDtor {
+ constexpr ~ConstexprDtor() = default; // expected-error {{destructor cannot be marked constexpr}}
+};
+
+// template stuff
+template <typename T> constexpr T ft(T t) { return t; }
+template <typename T> T gt(T t) { return t; }
+struct S {
+ template<typename T> constexpr T f();
+ template<typename T> T g() const;
+};
+
+// explicit specialization can differ in constepxr
+template <> notlit ft(notlit nl) { return nl; }
+template <> char ft(char c) { return c; } // expected-note {{previous}}
+template <> constexpr char ft(char nl); // expected-error {{constexpr declaration of 'ft<char>' follows non-constexpr declaration}}
+template <> constexpr int gt(int nl) { return nl; }
+template <> notlit S::f() const { return notlit(); }
+template <> constexpr int S::g() { return 0; } // expected-note {{previous}}
+template <> int S::g() const; // expected-error {{non-constexpr declaration of 'g<int>' follows constexpr declaration}}
+// specializations can drop the 'constexpr' but not the implied 'const'.
+template <> char S::g() { return 0; } // expected-error {{no function template matches}}
+template <> double S::g() const { return 0; } // ok
+
+constexpr int i3 = ft(1);
+
+void test() {
+ // ignore constexpr when instantiating with non-literal
+ notlit2 nl2;
+ (void)ft(nl2);
+}
+
+// Examples from the standard:
+constexpr int square(int x); // expected-note {{declared here}}
+constexpr int bufsz = 1024;
+
+constexpr struct pixel { // expected-error {{struct cannot be marked constexpr}}
+ int x;
+ int y;
+ constexpr pixel(int);
+};
+
+constexpr pixel::pixel(int a)
+ : x(square(a)), y(square(a)) // expected-note {{undefined function 'square' cannot be used in a constant expression}}
+ { }
+
+constexpr pixel small(2); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'pixel(2)'}}
+
+constexpr int square(int x) {
+ return x * x;
+}
+
+constexpr pixel large(4);
+
+int next(constexpr int x) { // expected-error {{function parameter cannot be constexpr}}
+ return x + 1;
+}
+
+extern constexpr int memsz; // expected-error {{constexpr variable declaration must be a definition}}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p2.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p2.cpp
new file mode 100644
index 0000000..001a086
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p2.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - | FileCheck %s
+
+// constexpr functions and constexpr constructors are implicitly inline.
+struct S {
+ constexpr S(int n);
+ constexpr int g();
+ int n;
+};
+
+constexpr S::S(int n) : n(n) {}
+
+constexpr S f(S s) {
+ return s.n * 2;
+}
+
+constexpr int S::g() {
+ return f(*this).n;
+}
+
+// CHECK: define linkonce_odr {{.*}} @_Z1f1S(
+// CHECK: define linkonce_odr {{.*}} @_ZN1SC1Ei(
+// CHECK: define linkonce_odr {{.*}} @_ZNK1S1gEv(
+
+int g() {
+ return f(42).g();
+}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
new file mode 100644
index 0000000..cafdd63
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
@@ -0,0 +1,139 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+namespace N {
+ typedef char C;
+}
+
+namespace M {
+ typedef double D;
+}
+
+struct NonLiteral { // expected-note 2{{no constexpr constructors}}
+ NonLiteral() {}
+ NonLiteral(int) {}
+};
+struct Literal {
+ constexpr Literal() {}
+ operator int() const { return 0; }
+};
+
+struct S {
+ virtual int ImplicitlyVirtual() const = 0; // expected-note {{overridden virtual function}}
+};
+struct SS : S {
+ int ImplicitlyVirtual() const;
+};
+
+// The definition of a constexpr function shall satisfy the following
+// constraints:
+struct T : SS, NonLiteral { // expected-note {{base class 'NonLiteral' of non-literal type}}
+ constexpr T();
+ constexpr int f(); // expected-error {{non-literal type 'T' cannot have constexpr members}}
+
+ // - it shall not be virtual;
+ virtual constexpr int ExplicitlyVirtual() { return 0; } // expected-error {{virtual function cannot be constexpr}}
+
+ constexpr int ImplicitlyVirtual() { return 0; } // expected-error {{virtual function cannot be constexpr}}
+
+ // - its return type shall be a literal type;
+ constexpr NonLiteral NonLiteralReturn() { return {}; } // expected-error {{constexpr function's return type 'NonLiteral' is not a literal type}}
+ constexpr void VoidReturn() { return; } // expected-error {{constexpr function's return type 'void' is not a literal type}}
+ constexpr ~T(); // expected-error {{destructor cannot be marked constexpr}}
+ typedef NonLiteral F();
+ constexpr F NonLiteralReturn2; // ok until definition
+
+ // - each of its parameter types shall be a literal type;
+ constexpr int NonLiteralParam(NonLiteral) { return 0; } // expected-error {{constexpr function's 1st parameter type 'NonLiteral' is not a literal type}}
+ typedef int G(NonLiteral);
+ constexpr G NonLiteralParam2; // ok until definition
+
+ // - its function-body shall be = delete, = default,
+ constexpr int Deleted() = delete;
+ // It's not possible for the function-body to legally be "= default" here.
+ // Other than constructors, only the copy- and move-assignment operators and
+ // destructor can be defaulted. Destructors can't be constexpr since they
+ // don't have a literal return type. Defaulted assignment operators can't be
+ // constexpr since they can't be const.
+ constexpr T &operator=(const T&) = default; // expected-error {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}
+};
+struct U {
+ constexpr U SelfReturn();
+ constexpr int SelfParam(U);
+};
+
+struct V : virtual U { // expected-note {{here}}
+ constexpr int F() { return 0; } // expected-error {{constexpr member function not allowed in struct with virtual base class}}
+};
+
+// or a compound-statememt that contains only
+constexpr int AllowedStmts() {
+ // - null statements
+ ;
+
+ // - static_assert-declarations
+ static_assert(true, "the impossible happened!");
+
+ // - typedef declarations and alias-declarations that do not define classes
+ // or enumerations
+ typedef int I;
+ typedef struct S T;
+ using J = int;
+ using K = int[sizeof(I) + sizeof(J)];
+ // Note, the standard requires we reject this.
+ struct U;
+
+ // - using-declarations
+ using N::C;
+
+ // - using-directives
+ using namespace N;
+
+ // - and exactly one return statement
+ return sizeof(K) + sizeof(C) + sizeof(K);
+}
+constexpr int ForStmt() {
+ for (int n = 0; n < 10; ++n) // expected-error {{statement not allowed in constexpr function}}
+ return 0;
+}
+constexpr int VarDecl() {
+ constexpr int a = 0; // expected-error {{variables cannot be declared in a constexpr function}}
+ return 0;
+}
+constexpr int FuncDecl() {
+ constexpr int ForwardDecl(int); // expected-error {{statement not allowed in constexpr function}}
+ return ForwardDecl(42);
+}
+constexpr int ClassDecl1() {
+ typedef struct { } S1; // expected-error {{types cannot be defined in a constexpr function}}
+ return 0;
+}
+constexpr int ClassDecl2() {
+ using S2 = struct { }; // expected-error {{types cannot be defined in a constexpr function}}
+ return 0;
+}
+constexpr int ClassDecl3() {
+ struct S3 { }; // expected-error {{types cannot be defined in a constexpr function}}
+ return 0;
+}
+constexpr int NoReturn() {} // expected-error {{no return statement in constexpr function}}
+constexpr int MultiReturn() {
+ return 0; // expected-note {{return statement}}
+ return 0; // expected-error {{multiple return statements in constexpr function}}
+}
+
+// - every constructor call and implicit conversion used in initializing the
+// return value shall be one of those allowed in a constant expression.
+//
+// We implement the proposed resolution of DR1364 and ignore this bullet.
+// However, we implement the spirit of the check as part of the p5 checking that
+// a constexpr function must be able to produce a constant expression.
+namespace DR1364 {
+ constexpr int f(int k) {
+ return k; // ok, even though lvalue-to-rvalue conversion of a function
+ // parameter is not allowed in a constant expression.
+ }
+ int kGlobal; // expected-note {{here}}
+ constexpr int f() { // expected-error {{constexpr function never produces a constant expression}}
+ return kGlobal; // expected-note {{read of non-const}}
+ }
+}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
new file mode 100644
index 0000000..65573c7
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
@@ -0,0 +1,249 @@
+// RUN: %clang_cc1 -verify -std=c++11 -fcxx-exceptions %s
+
+namespace N {
+ typedef char C;
+}
+
+namespace M {
+ typedef double D;
+}
+
+struct NonLiteral { // expected-note 2{{no constexpr constructors}}
+ NonLiteral() {}
+ NonLiteral(int) {}
+};
+struct Literal {
+ constexpr Literal() {}
+ explicit Literal(int); // expected-note 2 {{here}}
+ operator int() const { return 0; }
+};
+
+// In the definition of a constexpr constructor, each of the parameter types
+// shall be a literal type.
+struct S {
+ constexpr S(int, N::C) {}
+ constexpr S(int, NonLiteral, N::C) {} // expected-error {{constexpr constructor's 2nd parameter type 'NonLiteral' is not a literal type}}
+ constexpr S(int, NonLiteral = 42) {} // expected-error {{constexpr constructor's 2nd parameter type 'NonLiteral' is not a literal type}}
+
+ // In addition, either its function-body shall be = delete or = default
+ constexpr S() = default;
+ constexpr S(Literal) = delete;
+};
+
+// or it shall satisfy the following constraints:
+
+// - the class shall not have any virtual base classes;
+struct T : virtual S { // expected-note {{here}}
+ constexpr T() {} // expected-error {{constexpr constructor not allowed in struct with virtual base class}}
+};
+namespace IndirectVBase {
+ struct A {};
+ struct B : virtual A {}; // expected-note {{here}}
+ class C : public B {
+ public:
+ constexpr C() {} // expected-error {{constexpr constructor not allowed in class with virtual base class}}
+ };
+}
+
+// - its function-body shall not be a function-try-block;
+struct U {
+ constexpr U()
+ try // expected-error {{function try block not allowed in constexpr constructor}}
+ : u() {
+ } catch (...) {
+ throw;
+ }
+ int u;
+};
+
+// - the compound-statememt of its function-body shall contain only
+struct V {
+ constexpr V() {
+ // - null statements,
+ ;
+
+ // - static_assert-declarations,
+ static_assert(true, "the impossible happened!");
+
+ // - typedef declarations and alias-declarations that do not define classes
+ // or enumerations,
+ typedef int I;
+ typedef struct S T;
+ using J = int;
+ using K = int[sizeof(I) + sizeof(J)];
+ // Note, the standard requires we reject this.
+ struct U;
+
+ // - using-declarations,
+ using N::C;
+
+ // - and using-directives;
+ using namespace N;
+ }
+
+ constexpr V(int(&)[1]) {
+ for (int n = 0; n < 10; ++n) // expected-error {{statement not allowed in constexpr constructor}}
+ /**/;
+ }
+ constexpr V(int(&)[2]) {
+ constexpr int a = 0; // expected-error {{variables cannot be declared in a constexpr constructor}}
+ }
+ constexpr V(int(&)[3]) {
+ constexpr int ForwardDecl(int); // expected-error {{statement not allowed in constexpr constructor}}
+ }
+ constexpr V(int(&)[4]) {
+ typedef struct { } S1; // expected-error {{types cannot be defined in a constexpr constructor}}
+ }
+ constexpr V(int(&)[5]) {
+ using S2 = struct { }; // expected-error {{types cannot be defined in a constexpr constructor}}
+ }
+ constexpr V(int(&)[6]) {
+ struct S3 { }; // expected-error {{types cannot be defined in a constexpr constructor}}
+ }
+ constexpr V(int(&)[7]) {
+ return; // expected-error {{statement not allowed in constexpr constructor}}
+ }
+};
+
+// - every non-static data member and base class sub-object shall be initialized
+struct W {
+ int n; // expected-note {{member not initialized by constructor}}
+ constexpr W() {} // expected-error {{constexpr constructor must initialize all members}}
+};
+struct AnonMembers {
+ int a; // expected-note {{member not initialized by constructor}}
+ union { // expected-note 2{{member not initialized by constructor}}
+ char b;
+ struct {
+ double c;
+ long d; // expected-note {{member not initialized by constructor}}
+ };
+ union {
+ char e;
+ void *f;
+ };
+ };
+ struct { // expected-note {{member not initialized by constructor}}
+ long long g;
+ struct {
+ int h; // expected-note {{member not initialized by constructor}}
+ double i; // expected-note {{member not initialized by constructor}}
+ };
+ union { // expected-note 2{{member not initialized by constructor}}
+ char *j;
+ AnonMembers *k;
+ };
+ };
+
+ constexpr AnonMembers(int(&)[1]) : a(), b(), g(), h(), i(), j() {} // ok
+ // missing d, i, j/k union
+ constexpr AnonMembers(int(&)[2]) : a(), c(), g(), h() {} // expected-error {{constexpr constructor must initialize all members}}
+ constexpr AnonMembers(int(&)[3]) : a(), e(), g(), h(), i(), k() {} // ok
+ // missing h, j/k union
+ constexpr AnonMembers(int(&)[4]) : a(), c(), d(), g(), i() {} // expected-error {{constexpr constructor must initialize all members}}
+ // missing b/c/d/e/f union
+ constexpr AnonMembers(int(&)[5]) : a(), g(), h(), i(), k() {} // expected-error {{constexpr constructor must initialize all members}}
+ // missing a, b/c/d/e/f union, g/h/i/j/k struct
+ constexpr AnonMembers(int(&)[6]) {} // expected-error {{constexpr constructor must initialize all members}}
+};
+
+union Empty {
+ constexpr Empty() {} // ok
+} constexpr empty1;
+
+struct EmptyVariant {
+ union {};
+ struct {};
+ constexpr EmptyVariant() {} // ok
+} constexpr empty2;
+
+template<typename T> using Int = int;
+template<typename T>
+struct TemplateInit {
+ T a;
+ int b; // desired-note {{not initialized}}
+ Int<T> c; // desired-note {{not initialized}}
+ struct {
+ T d;
+ int e; // desired-note {{not initialized}}
+ Int<T> f; // desired-note {{not initialized}}
+ };
+ struct {
+ Literal l;
+ Literal m;
+ Literal n[3];
+ };
+ union { // desired-note {{not initialized}}
+ T g;
+ T h;
+ };
+ // FIXME: This is ill-formed (no diagnostic required). We should diagnose it.
+ constexpr TemplateInit() {} // desired-error {{must initialize all members}}
+};
+template<typename T> struct TemplateInit2 {
+ Literal l;
+ constexpr TemplateInit2() {} // ok
+};
+
+template<typename T> struct weak_ptr {
+ constexpr weak_ptr() : p(0) {}
+ T *p;
+};
+template<typename T> struct enable_shared_from_this {
+ weak_ptr<T> weak_this;
+ constexpr enable_shared_from_this() {} // ok
+};
+constexpr int f(enable_shared_from_this<int>);
+
+// - every constructor involved in initializing non-static data members and base
+// class sub-objects shall be a constexpr constructor.
+struct ConstexprBaseMemberCtors : Literal {
+ Literal l;
+
+ constexpr ConstexprBaseMemberCtors() : Literal(), l() {} // ok
+ constexpr ConstexprBaseMemberCtors(char) : // expected-error {{constexpr constructor never produces a constant expression}}
+ Literal(0), // expected-note {{non-constexpr constructor}}
+ l() {}
+ constexpr ConstexprBaseMemberCtors(double) : Literal(), // expected-error {{constexpr constructor never produces a constant expression}}
+ l(0) // expected-note {{non-constexpr constructor}}
+ {}
+};
+
+// - every assignment-expression that is an initializer-caluse appearing
+// directly or indirectly within a brace-or-equal-initializer for a non-static
+// data member that is not named by a mem-initializer-id shall be a constant
+// expression; and
+//
+// Note, we deliberately do not implement this bullet, so that we can allow the
+// following example. (See N3308).
+struct X {
+ int a = 0;
+ int b = 2 * a + 1; // ok, not a constant expression.
+
+ constexpr X() {}
+ constexpr X(int c) : a(c) {} // ok, b initialized by 2 * c + 1
+};
+
+// - every implicit conversion used in converting a constructor argument to the
+// corresponding parameter type and converting a full-expression to the
+// corresponding member type shall be one of those allowed in a constant
+// expression.
+//
+// We implement the proposed resolution of DR1364 and ignore this bullet.
+// However, we implement the intent of this wording as part of the p5 check that
+// the function must be able to produce a constant expression.
+int kGlobal; // expected-note {{here}}
+struct Z {
+ constexpr Z(int a) : n(a) {}
+ constexpr Z() : n(kGlobal) {} // expected-error {{constexpr constructor never produces a constant expression}} expected-note {{read of non-const}}
+ int n;
+};
+
+
+namespace StdExample {
+ struct Length {
+ explicit constexpr Length(int i = 0) : val(i) { }
+ private:
+ int val;
+ };
+}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
new file mode 100644
index 0000000..fd17d35
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fcxx-exceptions %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -fcxx-exceptions -Wno-invalid-constexpr %s
+
+namespace StdExample {
+
+constexpr int f(void *) { return 0; }
+constexpr int f(...) { return 1; }
+constexpr int g1() { return f(0); }
+constexpr int g2(int n) { return f(n); }
+constexpr int g3(int n) { return f(n*0); }
+
+namespace N {
+ constexpr int c = 5;
+ constexpr int h() { return c; }
+}
+constexpr int c = 0;
+constexpr int g4() { return N::h(); }
+
+static_assert(f(0) == 0, "");
+static_assert(f('0') == 1, "");
+static_assert(g1() == 0, "");
+static_assert(g2(0) == 1, "");
+static_assert(g2(1) == 1, "");
+static_assert(g3(0) == 1, "");
+static_assert(g3(1) == 1, "");
+static_assert(N::h() == 5, "");
+static_assert(g4() == 5, "");
+
+
+constexpr int f(bool b)
+ { return b ? throw 0 : 0; } // ok
+constexpr int f() { return throw 0, 0; } // expected-error {{constexpr function never produces a constant expression}} expected-note {{subexpression}}
+
+struct B {
+ constexpr B(int x) : i(0) { }
+ int i;
+};
+
+int global; // expected-note {{declared here}}
+
+struct D : B {
+ constexpr D() : B(global) { } // expected-error {{constexpr constructor never produces a constant expression}} expected-note {{read of non-const}}
+};
+
+}
+
+namespace PotentialConstant {
+
+constexpr int Comma(int n) { return // expected-error {{constexpr function never produces a constant expression}}
+ (void)(n * 2),
+ throw 0, // expected-note {{subexpression}}
+ 0;
+}
+
+int ng; // expected-note 6{{here}}
+constexpr int BinaryOp1(int n) { return n + ng; } // expected-error {{never produces}} expected-note {{read}}
+constexpr int BinaryOp2(int n) { return ng + n; } // expected-error {{never produces}} expected-note {{read}}
+
+double dg; // expected-note 2{{here}}
+constexpr double BinaryOp1(double d) { return d + dg; } // expected-error {{never produces}} expected-note {{read}}
+constexpr double BinaryOp2(double d) { return dg + d; } // expected-error {{never produces}} expected-note {{read}}
+
+constexpr int Add(int a, int b, int c) { return a + b + c; }
+constexpr int FunctionArgs(int a) { return Add(a, ng, a); } // expected-error {{never produces}} expected-note {{read}}
+
+struct S { int a; int b; int c[2]; };
+constexpr S InitList(int a) { return { a, ng }; }; // expected-error {{never produces}} expected-note {{read}}
+constexpr S InitList1a(int a) { return S{ a, ng }; }; // expected-error {{never produces}} expected-note {{read}}
+constexpr S InitList2(int a) { return { a, a, { ng } }; }; // expected-error {{never produces}} expected-note {{read}}
+constexpr S InitList3(int a) { return a ? S{ a, a } : S{ a, ng }; }; // ok
+
+constexpr int LogicalAnd1(int n) { return n && (throw, 0); } // ok
+constexpr int LogicalAnd2(int n) { return 1 && (throw, 0); } // expected-error {{never produces}} expected-note {{subexpression}}
+
+constexpr int LogicalOr1(int n) { return n || (throw, 0); } // ok
+constexpr int LogicalOr2(int n) { return 0 || (throw, 0); } // expected-error {{never produces}} expected-note {{subexpression}}
+
+constexpr int Conditional1(bool b, int n) { return b ? n : ng; } // ok
+constexpr int Conditional2(bool b, int n) { return b ? n * ng : n + ng; } // expected-error {{never produces}} expected-note {{both arms of conditional operator are unable to produce a constant expression}}
+
+// __builtin_constant_p ? : is magical, and is always a potential constant.
+constexpr bool BcpCall(int n) {
+ return __builtin_constant_p((int*)n != &n) ? (int*)n != &n : (int*)n != &n;
+}
+static_assert(BcpCall(0), "");
+
+// DR1311: A function template which can produce a constant expression, but
+// for which a particular specialization cannot, is ok.
+template<typename T> constexpr T cmin(T a, T b) {
+ return a < b ? a : b;
+}
+int n = cmin(3, 5); // ok
+
+struct X {
+ constexpr X() {}
+ bool operator<(X); // not constexpr
+};
+
+X x = cmin(X(), X()); // ok, not constexpr
+
+// Same with other temploids.
+template<typename T>
+struct Y {
+ constexpr Y() {}
+ constexpr int get() { return T(); }
+};
+struct Z { operator int(); };
+
+int y1 = Y<int>().get(); // ok
+int y2 = Y<Z>().get(); // ok
+
+}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp
new file mode 100644
index 0000000..1a6dc9e
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+namespace N {
+ typedef char C;
+}
+
+namespace M {
+ typedef double D;
+}
+
+struct NonLiteral {
+ NonLiteral() {}
+ NonLiteral(int) {} // expected-note 2{{here}}
+ operator int() const { return 0; }
+};
+struct Literal {
+ constexpr Literal() {}
+ operator int() const { return 0; }
+};
+
+struct S {
+ virtual int ImplicitlyVirtual() const;
+};
+struct T {};
+
+template<typename T> struct ImplicitVirtualFromDependentBase : T {
+ constexpr int ImplicitlyVirtual() { return 0; }
+};
+
+constexpr int a = ImplicitVirtualFromDependentBase<S>().ImplicitlyVirtual(); // expected-error {{constant expression}} expected-note {{cannot evaluate virtual function call}}
+constexpr int b = ImplicitVirtualFromDependentBase<T>().ImplicitlyVirtual(); // ok
+constexpr int c = ImplicitVirtualFromDependentBase<S>().ImplicitVirtualFromDependentBase<S>::ImplicitlyVirtual();
+
+template<typename R> struct ConstexprMember {
+ constexpr R F() { return 0; }
+};
+constexpr int d = ConstexprMember<int>().F(); // ok
+constexpr int e = ConstexprMember<NonLiteral>().F(); // expected-error {{constant expression}}
+
+template<typename ...P> struct ConstexprCtor {
+ constexpr ConstexprCtor(P...) {}
+};
+constexpr ConstexprCtor<> f1() { return {}; } // ok
+constexpr ConstexprCtor<int> f2() { return 0; } // ok
+constexpr ConstexprCtor<NonLiteral> f3() { return { 0 }; } // expected-error {{never produces a constant expression}} expected-note {{non-constexpr constructor 'NonLiteral}}
+constexpr ConstexprCtor<int, NonLiteral> f4() { return { 0, 0 }; } // expected-error {{never produces a constant expression}} expected-note {{non-constexpr constructor 'NonLiteral}}
+
+struct VirtBase : virtual S {}; // expected-note {{here}}
+
+namespace TemplateVBase {
+ template<typename T> struct T1 : virtual Literal { // expected-note {{here}}
+ constexpr T1() {} // expected-error {{constexpr constructor not allowed in struct with virtual base class}}
+ };
+
+ template<typename T> struct T2 : virtual T {
+ // FIXME: This is ill-formed (no diagnostic required).
+ // We should diagnose it now rather than waiting until instantiation.
+ constexpr T2() {}
+ };
+ constexpr T2<Literal> g2() { return {}; }
+
+ template<typename T> class T3 : public T { // expected-note {{class with virtual base class is not a literal type}}
+ public:
+ constexpr T3() {}
+ };
+ constexpr T3<Literal> g3() { return {}; } // ok
+ constexpr T3<VirtBase> g4() { return {}; } // expected-error {{not a literal type}}
+}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp
new file mode 100644
index 0000000..c4935b3
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct S {
+ constexpr int f();
+ constexpr int g() const;
+ static constexpr int Sf();
+};
+
+void f(const S &s) {
+ s.f();
+ s.g();
+
+ int (*f)() = &S::Sf;
+ int (S::*g)() const = &S::g;
+}
+
+namespace std_example {
+
+ class debug_flag { // expected-note {{not an aggregate and has no constexpr constructors}}
+ public:
+ explicit debug_flag(bool);
+ constexpr bool is_on(); // expected-error {{non-literal type 'std_example::debug_flag' cannot have constexpr members}}
+ private:
+ bool flag;
+ };
+
+ constexpr int bar(int x, int y) // expected-note {{here}}
+ { return x + y + x*y; }
+ int bar(int x, int y) // expected-error {{non-constexpr declaration of 'bar' follows constexpr declaration}}
+ { return x * 2 + 3 * y; }
+
+}
+
+// The constexpr specifier is allowed for static member functions of non-literal types.
+class NonLiteralClass {
+ NonLiteralClass(bool);
+ static constexpr bool isDebugFlag();
+};
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp
new file mode 100644
index 0000000..2412a14
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// A constexpr specifier used in an object declaration declares the object as
+// const.
+constexpr int a = 0;
+extern const int a;
+
+int i; // expected-note 2{{here}}
+constexpr int *b = &i;
+extern int *const b;
+
+constexpr int &c = i;
+extern int &c;
+
+constexpr int (*d)(int) = 0;
+extern int (*const d)(int);
+
+// A variable declaration which uses the constexpr specifier shall have an
+// initializer and shall be initialized by a constant expression.
+constexpr int ni1; // expected-error {{default initialization of an object of const type 'const int'}}
+constexpr struct C { C(); } ni2; // expected-error {{cannot have non-literal type 'const struct C'}} expected-note 3{{has no constexpr constructors}}
+constexpr double &ni3; // expected-error {{declaration of reference variable 'ni3' requires an initializer}}
+
+constexpr int nc1 = i; // expected-error {{constexpr variable 'nc1' must be initialized by a constant expression}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}}
+constexpr C nc2 = C(); // expected-error {{cannot have non-literal type 'const C'}}
+int &f(); // expected-note {{declared here}}
+constexpr int &nc3 = f(); // expected-error {{constexpr variable 'nc3' must be initialized by a constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}}
+constexpr int nc4(i); // expected-error {{constexpr variable 'nc4' must be initialized by a constant expression}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}}
+constexpr C nc5((C())); // expected-error {{cannot have non-literal type 'const C'}}
+int &f(); // expected-note {{here}}
+constexpr int &nc6(f()); // expected-error {{constexpr variable 'nc6' must be initialized by a constant expression}} expected-note {{non-constexpr function 'f'}}
+
+struct pixel {
+ int x, y;
+};
+constexpr pixel ur = { 1294, 1024 }; // ok
+constexpr pixel origin; // expected-error {{default initialization of an object of const type 'const pixel' requires a user-provided default constructor}}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp
new file mode 100644
index 0000000..d7b9eff
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -verify %s
+
+void f0a(void) {
+ inline void f1(); // expected-error {{inline declaration of 'f1' not allowed in block scope}}
+}
+
+void f0b(void) {
+ void f1();
+}
+
+// FIXME: Add test for "If the inline specifier is used in a friend declaration,
+// that declaration shall be a definition or the function shall have previously
+// been declared inline.
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp
new file mode 100644
index 0000000..07eec1e
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -verify %s
+// XFAIL: *
+
+void f0() {
+}
+
+inline void f0(); // expected-error {{function definition cannot precede inline declaration}}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp
new file mode 100644
index 0000000..ee870d9
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -verify %s
+
+class A {
+public:
+ explicit A();
+
+ explicit operator int(); // expected-warning {{explicit conversion functions are a C++11 extension}}
+
+ explicit void f0(); // expected-error {{'explicit' can only be applied to a constructor or conversion function}}
+
+ operator bool();
+};
+
+explicit A::A() { } // expected-error {{'explicit' can only be specified inside the class definition}}
+explicit A::operator bool() { return false; } // expected-warning {{explicit conversion functions are a C++11 extension}}\
+ // expected-error {{'explicit' can only be specified inside the class definition}}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp
new file mode 100644
index 0000000..cbb439e
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// A storage-class-specifier shall not be specified in an explicit
+// specialization (14.7.3) or an explicit instantiation (14.7.2)
+// directive.
+template<typename T> void f(T) {}
+template<typename T> static void g(T) {}
+
+
+template<> static void f<int>(int); // expected-error{{explicit specialization has extraneous, inconsistent storage class 'static'}}
+template static void f<float>(float); // expected-error{{explicit instantiation cannot have a storage class}}
+
+template<> void f<double>(double);
+template void f<long>(long);
+
+template<> static void g<int>(int); // expected-warning{{explicit specialization cannot have a storage class}}
+template static void g<float>(float); // expected-error{{explicit instantiation cannot have a storage class}}
+
+template<> void g<double>(double);
+template void g<long>(long);
+
+template<typename T>
+struct X {
+ static int value;
+};
+
+template<typename T>
+int X<T>::value = 17;
+
+template static int X<int>::value; // expected-error{{explicit instantiation cannot have a storage class}}
+
+template<> static int X<float>::value; // expected-error{{'static' can only be specified inside the class definition}}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp
new file mode 100644
index 0000000..fd86276
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -verify %s
+// XFAIL: *
+
+typedef const int T0;
+typedef int& T1;
+
+struct s0 {
+ mutable const int f0; // expected-error{{'mutable' and 'const' cannot be mixed}}
+ mutable T0 f1; // expected-error{{'mutable' and 'const' cannot be mixed}}
+ mutable int &f2; // expected-error{{'mutable' cannot be applied to references}}
+ mutable T1 f3; // expected-error{{'mutable' cannot be applied to references}}
+ mutable struct s1 {}; // expected-error{{'mutable' cannot be applied to non-data members}}
+ mutable void im0(); // expected-error{{'mutable' cannot be applied to functions}}
+};
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp
new file mode 100644
index 0000000..44cc5a7
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++0x-compat %s
+
+// The auto or register specifiers can be applied only to names of objects
+// declared in a block (6.3) or to function parameters (8.4).
+
+auto int ao; // expected-error {{illegal storage class on file-scoped variable}}
+auto void af(); // expected-error {{illegal storage class on function}}
+
+register int ro; // expected-error {{illegal storage class on file-scoped variable}}
+register void rf(); // expected-error {{illegal storage class on function}}
+
+struct S {
+ auto int ao; // expected-error {{storage class specified for a member declaration}}
+ auto void af(); // expected-error {{storage class specified for a member declaration}}
+
+ register int ro; // expected-error {{storage class specified for a member declaration}}
+ register void rf(); // expected-error {{storage class specified for a member declaration}}
+};
+
+void foo(auto int ap, register int rp) {
+ auto int abo;
+ auto void abf(); // expected-error {{illegal storage class on function}}
+
+ register int rbo;
+ register void rbf(); // expected-error {{illegal storage class on function}}
+}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp
new file mode 100644
index 0000000..491ab17
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify %s
+
+struct S; // expected-note 2{{forward declaration of 'S'}}
+extern S a;
+extern S f(); // expected-note {{'f' declared here}}
+extern void g(S a);
+
+void h() {
+ g(a); // expected-error {{argument type 'S' is incomplete}}
+ f(); // expected-error {{calling 'f' with incomplete return type 'S'}}
+}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp
new file mode 100644
index 0000000..a385aa9
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s -std=c++11
+
+struct S {
+ virtual ~S();
+
+ void g() throw (auto(*)()->int);
+
+ // Note, this is not permitted: conversion-declarator cannot have a trailing return type.
+ // FIXME: don't issue the second diagnostic for this.
+ operator auto(*)()->int(); // expected-error{{'auto' not allowed here}} expected-error {{C++ requires a type specifier}}
+};
+
+typedef auto Fun(int a) -> decltype(a + a);
+typedef auto (*PFun)(int a) -> decltype(a + a);
+
+void g(auto (*f)() -> int) {
+ try { }
+ catch (auto (&f)() -> int) { }
+ catch (auto (*const f[10])() -> int) { }
+}
+
+namespace std {
+ class type_info;
+}
+
+template<typename T> struct U {};
+
+void j() {
+ (void)typeid(auto(*)()->void);
+ (void)sizeof(auto(*)()->void);
+ (void)__alignof(auto(*)()->void);
+
+ U<auto(*)()->void> v;
+
+ int n;
+ (void)static_cast<auto(*)()->void>(&j);
+ auto p = reinterpret_cast<auto(*)()->int>(&j);
+ (void)const_cast<auto(**)()->int>(&p);
+ (void)(auto(*)()->void)(&j);
+}
+
+template <auto (*f)() -> void = &j> class C { };
+struct F : auto(*)()->int {}; // expected-error{{expected class name}}
+template<typename T = auto(*)()->int> struct G { };
+
+int g();
+auto (*h)() -> auto = &g; // expected-error{{'auto' not allowed in function return type}}
+auto (*i)() = &g; // ok; auto deduced as int.
+auto (*k)() -> int = i; // ok; no deduction.
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp
new file mode 100644
index 0000000..1daf02f
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions -Wc++11-compat
+void f() {
+ auto a = a; // expected-error{{variable 'a' declared with 'auto' type cannot appear in its own initializer}}
+ auto *b = b; // expected-error{{variable 'b' declared with 'auto' type cannot appear in its own initializer}}
+ const auto c = c; // expected-error{{variable 'c' declared with 'auto' type cannot appear in its own initializer}}
+ if (auto d = d) {} // expected-error {{variable 'd' declared with 'auto' type cannot appear in its own initializer}}
+ auto e = ({ auto f = e; 0; }); // expected-error {{variable 'e' declared with 'auto' type cannot appear in its own initializer}}
+}
+
+void g() {
+ auto a; // expected-error{{declaration of variable 'a' with type 'auto' requires an initializer}}
+
+ auto *b; // expected-error{{declaration of variable 'b' with type 'auto *' requires an initializer}}
+
+ if (auto b) {} // expected-error {{must have an initializer}}
+ for (;auto b;) {} // expected-error {{must have an initializer}}
+ while (auto b) {} // expected-error {{must have an initializer}}
+ if (auto b = true) { (void)b; }
+}
+
+auto n(1,2,3); // expected-error{{initializer for variable 'n' with type 'auto' contains multiple expressions}}
+
+namespace N
+{
+ auto a = "const char [16]", *p = &a;
+}
+
+void h() {
+ auto b = 42ULL;
+
+ for (auto c = 0; c < b; ++c) {
+ }
+}
+
+template<typename T, typename U> struct same;
+template<typename T> struct same<T, T> {};
+
+void p3example() {
+ auto x = 5;
+ const auto *v = &x, u = 6;
+ static auto y = 0.0;
+ // In C++98: 'auto' storage class specifier is redundant and incompatible with C++0x
+ // In C++0x: 'auto' storage class specifier is not permitted in C++0x, and will not be supported in future releases
+ auto int r; // expected-warning {{'auto' storage class specifier}}
+
+ same<__typeof(x), int> xHasTypeInt;
+ same<__typeof(v), const int*> vHasTypeConstIntPtr;
+ same<__typeof(u), const int> uHasTypeConstInt;
+ same<__typeof(y), double> yHasTypeDouble;
+}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp
new file mode 100644
index 0000000..e566d2a
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions
+
+template<typename T>
+struct only {
+ only(T);
+ template<typename U> only(U) = delete;
+};
+
+void f() {
+ if (auto a = true) {
+ }
+
+ switch (auto a = 0) {
+ }
+
+ while (auto a = false) {
+ }
+
+ for (; auto a = false; ) {
+ }
+
+ new const auto (0);
+ new (auto) (0.0);
+
+ int arr[] = {1, 2, 3};
+ for (auto i : arr) {
+ }
+}
+
+class X {
+ static const auto n = 'x';
+
+ auto m = 0; // expected-error {{'auto' not allowed in non-static class member}}
+};
+
+struct S {
+ static const auto a; // expected-error {{declaration of variable 'a' with type 'auto const' requires an initializer}}
+ static const auto b = 0;
+ static const int c;
+};
+const int S::b;
+const auto S::c = 0;
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
new file mode 100644
index 0000000..71f57dc
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s -std=c++11
+
+struct S {
+ virtual ~S();
+
+ auto a; // expected-error{{'auto' not allowed in non-static struct member}}
+ auto *b; // expected-error{{'auto' not allowed in non-static struct member}}
+ const auto c; // expected-error{{'auto' not allowed in non-static struct member}}
+
+ void f() throw (auto); // expected-error{{'auto' not allowed here}}
+
+ friend auto; // expected-error{{'auto' not allowed in non-static struct member}}
+
+ operator auto(); // expected-error{{'auto' not allowed here}}
+};
+
+// PR 9278: auto is not allowed in typedefs, except with a trailing return type.
+typedef auto *AutoPtr; // expected-error{{'auto' not allowed in typedef}}
+typedef auto (*PFun)(int a); // expected-error{{'auto' not allowed in typedef}}
+typedef auto Fun(int a) -> decltype(a + a);
+
+void g(auto a) { // expected-error{{'auto' not allowed in function prototype}}
+ try { }
+ catch (auto &a) { } // expected-error{{'auto' not allowed in exception declaration}}
+ catch (const auto a) { } // expected-error{{'auto' not allowed in exception declaration}}
+ try { } catch (auto a) { } // expected-error{{'auto' not allowed in exception declaration}}
+}
+
+void h(auto a[10]) { // expected-error{{'auto' not allowed in function prototype}}
+}
+
+void i(const auto a) { // expected-error{{'auto' not allowed in function prototype}}
+}
+
+namespace std {
+ class type_info;
+}
+
+template<typename T> struct U {};
+
+void j() {
+ (void)typeid(auto); // expected-error{{'auto' not allowed here}}
+ (void)sizeof(auto); // expected-error{{'auto' not allowed here}}
+ (void)__alignof(auto); // expected-error{{'auto' not allowed here}}
+
+ U<auto> v; // expected-error{{'auto' not allowed in template argument}}
+
+ int n;
+ (void)dynamic_cast<auto&>(n); // expected-error{{'auto' not allowed here}}
+ (void)static_cast<auto*>(&n); // expected-error{{'auto' not allowed here}}
+ (void)reinterpret_cast<auto*>(&n); // expected-error{{'auto' not allowed here}}
+ (void)const_cast<auto>(n); // expected-error{{'auto' not allowed here}}
+ (void)*(auto*)(&n); // expected-error{{'auto' not allowed here}}
+ (void)auto(n); // expected-error{{expected expression}}
+ (void)auto{n}; // expected-error{{expected expression}}
+}
+
+template <auto a = 10> class C { }; // expected-error{{'auto' not allowed in template parameter}}
+int ints[] = {1, 2, 3};
+template <const auto (*a)[3] = &ints> class D { }; // expected-error{{'auto' not allowed in template parameter}}
+enum E : auto {}; // expected-error{{'auto' not allowed here}}
+struct F : auto {}; // expected-error{{expected class name}}
+template<typename T = auto> struct G { }; // expected-error{{'auto' not allowed in template argument}}
+
+using A = auto; // expected-error{{'auto' not allowed in type alias}}
+
+// FIXME: don't issue the second diagnostic for this error.
+auto k() -> auto; // expected-error{{'auto' not allowed in function return type}} unexpected-error{{without trailing return type}}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
new file mode 100644
index 0000000..d327efc
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions
+
+template<typename T>
+struct only {
+ only(T);
+ template<typename U> only(U) = delete;
+};
+
+namespace N
+{
+ auto a = "const char [16]", *p = &a;
+
+ only<const char [16]> testA = a;
+ only<const char **> testP = p;
+}
+
+void h() {
+ auto b = 42ULL;
+ only<unsigned long long> testB = b;
+
+ for (auto c = 0; c < 100; ++c) {
+ only<int> testC = c;
+ }
+}
+
+void p3example() {
+ auto x = 5;
+ const auto *v = &x, u = 6;
+ static auto y = 0.0;
+
+ only<int> testX = x;
+ only<const int*> testV = v;
+ only<const int> testU = u;
+ only<double> testY = y;
+}
+
+void f() {
+ if (auto a = true) {
+ only<bool> testA = a;
+ }
+
+ switch (auto a = 0) {
+ case 0:
+ only<int> testA = a;
+ }
+
+ while (auto a = false) {
+ only<bool> testA = a;
+ }
+
+ for (; auto a = "test"; ) {
+ only<const char[5]> testA = a;
+ }
+
+ auto *fail1 = 0; // expected-error {{variable 'fail1' with type 'auto *' has incompatible initializer of type 'int'}}
+ int **p;
+ const auto **fail2(p); // expected-error {{variable 'fail2' with type 'auto const **' has incompatible initializer of type 'int **'}}
+}
+
+struct S {
+ void f();
+ char g(int);
+ float g(double);
+ int m;
+
+ void test() {
+ auto p1 = &S::f;
+ auto S::*p2 = &S::f;
+ auto (S::*p3)() = &S::f;
+ auto p4 = &S::g; // expected-error {{incompatible initializer of type '<overloaded function type>'}}
+ auto S::*p5 = &S::g; // expected-error {{incompatible initializer of type '<overloaded function type>'}}
+ auto (S::*p6)(int) = &S::g;
+ auto p7 = &S::m;
+ auto S::*p8 = &S::m;
+
+ only<void (S::*)()> test1 = p1;
+ only<void (S::*)()> test2 = p2;
+ only<void (S::*)()> test3 = p3;
+ only<char (S::*)(int)> test6 = p6;
+ only<int (S::*)> test7 = p7;
+ only<int (S::*)> test8 = p8;
+ }
+};
+
+namespace PR10939 {
+ struct X {
+ int method(int);
+ int method(float);
+ };
+
+ template<typename T> T g(T);
+
+ void f(X *x) {
+ auto value = x->method; // expected-error {{reference to non-static member function must be called}}
+ if (value) { }
+
+ auto funcptr = &g<int>;
+ int (*funcptr2)(int) = funcptr;
+ }
+}
+
+// if the initializer is a braced-init-list, deduce auto as std::initializer_list<T>:
+// see SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp
new file mode 100644
index 0000000..9c1d397
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions
+void f() {
+ auto a = 0, b = 0, c = 0;
+ auto d = 0, e = 0.0; // expected-error {{'int' in declaration of 'd' and deduced as 'double' in declaration of 'e'}}
+
+ auto v1 = 0, *p1 = &v1;
+ auto *p2 = 0, v2 = *p2; // expected-error {{incompatible initializer}}
+
+ const int k = 0;
+ auto &f = k, &g = a; // expected-error {{'const int' in declaration of 'f' and deduced as 'int' in declaration of 'g'}}
+
+ typedef int I;
+ I x;
+ auto xa = x, xb = 0;
+
+ auto &&ra1 = a, rb1 = b; // expected-error {{'int &' in declaration of 'ra1' and deduced as 'int' in declaration of 'rb1'}}
+ auto &&ra2 = +a, rb2 = b;
+}
+
+void g() {
+ auto a = 0,
+#if __has_feature(cxx_trailing_return)
+ (*b)() -> void,
+#endif
+ c = 0;
+ auto d = 0, // expected-error {{'auto' deduced as 'int' in declaration of 'd' and deduced as 'double' in declaration of 'f'}}
+#if __has_feature(cxx_trailing_return)
+ (*e)() -> void,
+#endif
+ f = 0.0;
+}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp
new file mode 100644
index 0000000..0271041
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct A { typedef int type; };
+template<typename T> using X = A; // expected-note {{declared here}}
+struct X<int>* p2; // expected-error {{elaborated type refers to a type alias template}}
+
+
+template<typename T> using Id = T; // expected-note {{declared here}}
+template<template<typename> class F>
+struct Y {
+ struct F<int> i; // expected-error {{elaborated type refers to a type alias template}}
+ typename F<A>::type j; // ok
+
+ // FIXME: don't produce the diagnostic both for the definition and the instantiation.
+ template<typename T> using U = F<char>; // expected-note 2{{declared here}}
+ struct Y<F>::template U<char> k; // expected-error 2{{elaborated type refers to a type alias template}}
+ typename Y<F>::template U<char> l; // ok
+};
+template struct Y<Id>; // expected-note {{requested here}}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp
new file mode 100644
index 0000000..8d58498
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class A {}; // expected-note 4 {{previous use is here}}
+enum E {};
+
+void a1(struct A);
+void a2(class A);
+void a3(union A); // expected-error {{use of 'A' with tag type that does not match previous declaration}}
+void a4(enum A); // expected-error {{use of 'A' with tag type that does not match previous declaration}}
+
+class A1 {
+ friend struct A;
+ friend class A;
+ friend union A; // expected-error {{use of 'A' with tag type that does not match previous declaration}}
+
+ friend enum A; // expected-error {{use of 'A' with tag type that does not match previous declaration}}
+ friend enum E; // expected-warning {{cannot be a friend}}
+};
+
+template <class T> struct B { // expected-note {{previous use is here}}
+ class Member {}; // expected-note 2 {{previous use is here}}
+};
+
+template <> class B<int> {
+ // no type Member
+};
+
+template <> struct B<A> {
+ union Member { // expected-note 4 {{previous use is here}}
+ void* a;
+ };
+};
+
+void b1(struct B<float>);
+void b2(class B<float>);
+void b3(union B<float>); // expected-error {{use of 'B<float>' with tag type that does not match previous declaration}}
+//void b4(enum B<float>); // this just doesn't parse; you can't template an enum directly
+
+void c1(struct B<float>::Member);
+void c2(class B<float>::Member);
+void c3(union B<float>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}}
+void c4(enum B<float>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}}
+
+void d1(struct B<int>::Member); // expected-error {{no struct named 'Member' in 'B<int>'}}
+void d2(class B<int>::Member); // expected-error {{no class named 'Member' in 'B<int>'}}
+void d3(union B<int>::Member); // expected-error {{no union named 'Member' in 'B<int>'}}
+void d4(enum B<int>::Member); // expected-error {{no enum named 'Member' in 'B<int>'}}
+
+void e1(struct B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}}
+void e2(class B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}}
+void e3(union B<A>::Member);
+void e4(enum B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}}
+
+template <class T> struct C {
+ void foo(class B<T>::Member); // expected-error{{no class named 'Member' in 'B<int>'}} \
+ // expected-error{{use of 'Member' with tag type that does not match previous declaration}}
+};
+
+C<float> f1;
+C<int> f2; // expected-note {{in instantiation of template class}}
+C<A> f3; // expected-note {{in instantiation of template class}}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp
new file mode 100644
index 0000000..53227ea
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+const int&& foo();
+int i;
+struct A { double x; };
+const A* a = new A();
+
+static_assert(is_same<decltype(foo()), const int&&>::value, "");
+static_assert(is_same<decltype(i), int>::value, "");
+static_assert(is_same<decltype(a->x), double>::value, "");
+static_assert(is_same<decltype((a->x)), const double&>::value, "");
+static_assert(is_same<decltype(static_cast<int&&>(i)), int&&>::value, "");
+
+int f0(int); // expected-note{{possible target}}
+float f0(float); // expected-note{{possible target}}
+
+decltype(f0) f0_a; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp
new file mode 100644
index 0000000..2bd5d23
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp
@@ -0,0 +1,108 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+namespace std_example {
+
+template<class T> struct A { ~A() = delete; }; // expected-note {{deleted here}}
+template<class T> auto h() -> A<T>;
+template<class T> auto i(T) -> T;
+template<class T> auto f(T) -> decltype(i(h<T>())); // #1
+template<class T> auto f(T) -> void; // #2
+auto g() -> void {
+ f(42); // ok, calls #2, since #1 is not viable.
+}
+template<class T> auto q(T) -> decltype((h<T>()));
+void r() {
+ // Deduction against q succeeds, but results in a temporary which can't be
+ // destroyed.
+ q(42); // expected-error {{attempt to use a deleted function}}
+}
+
+}
+
+class PD {
+ friend struct A;
+ ~PD(); // expected-note 4{{here}}
+public:
+ typedef int n;
+};
+struct DD {
+ ~DD() = delete; // expected-note 2{{here}}
+ typedef int n;
+};
+
+struct A {
+ decltype(PD()) s; // ok
+ decltype(PD())::n n; // ok
+ decltype(DD()) *p = new decltype(DD()); // ok
+};
+
+// Two errors here: one for the decltype, one for the variable.
+decltype(PD(), PD()) pd1; // expected-error 2{{private destructor}}
+decltype(DD(), DD()) dd1; // expected-error 2{{deleted function}}
+
+decltype(((13, ((DD())))))::n dd_parens; // ok
+decltype(((((42)), PD())))::n pd_parens_comma; // ok
+
+// Ensure parens aren't stripped from a decltype node.
+extern decltype(PD()) pd_ref; // ok
+decltype((pd_ref)) pd_ref3 = pd_ref; // ok, PD &
+decltype(pd_ref) pd_ref2 = pd_ref; // expected-error {{private destructor}}
+
+namespace libcxx_example {
+ struct nat {
+ nat() = delete;
+ nat(const nat&) = delete;
+ nat &operator=(const nat&) = delete;
+ ~nat() = delete;
+ };
+ struct any {
+ any(...);
+ };
+
+ template<typename T, typename U> struct is_same { static const bool value = false; };
+ template<typename T> struct is_same<T, T> { static const bool value = true; };
+
+ template<typename T> T declval();
+
+ void swap(int &a, int &b);
+ nat swap(any, any);
+
+ template<typename T> struct swappable {
+ typedef decltype(swap(declval<T&>(), declval<T&>())) type;
+ static const bool value = !is_same<type, nat>::value;
+ constexpr operator bool() { return value; }
+ };
+
+ static_assert(swappable<int>(), "");
+ static_assert(!swappable<const int>(), "");
+}
+
+namespace RequireCompleteType {
+ template<int N, bool OK> struct S {
+ static_assert(OK, "boom!"); // expected-error 2{{boom!}}
+ };
+
+ template<typename T> T make();
+ template<int N, bool OK> S<N, OK> make();
+ void consume(...);
+
+ decltype(make<0, false>()) *p1; // ok
+ decltype((make<1, false>())) *p2; // ok
+
+ // A complete type is required here in order to detect an overloaded 'operator,'.
+ decltype(123, make<2, false>()) *p3; // expected-note {{here}}
+
+ decltype(consume(make<3, false>())) *p4; // expected-note {{here}}
+
+ decltype(make<decltype(make<4, false>())>()) *p5; // ok
+}
+
+namespace Overload {
+ DD operator+(PD &a, PD &b);
+ decltype(PD()) *pd_ptr;
+ decltype(*pd_ptr + *pd_ptr) *dd_ptr; // ok
+
+ decltype(0, *pd_ptr) pd_ref2 = pd_ref; // ok
+ DD operator,(int a, PD b);
+ decltype(0, *pd_ptr) *dd_ptr2; // expected-error {{private destructor}}
+}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp
new file mode 100644
index 0000000..0b518bb
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fcxx-exceptions
+
+using X = struct { // ok
+};
+template<typename T> using Y = struct { // expected-error {{can not be defined in a type alias template}}
+};
+
+class K {
+ virtual ~K();
+ operator struct S {} (); // expected-error{{'K::S' can not be defined in a type specifier}}
+};
+
+struct A {};
+
+void f() {
+ int arr[3] = {1,2,3};
+
+ for (struct S { S(int) {} } s : arr) { // expected-error {{types may not be defined in a for range declaration}}
+ }
+
+ new struct T {}; // expected-error {{'T' can not be defined in a type specifier}}
+ new struct A {}; // expected-error {{'A' can not be defined in a type specifier}}
+
+ try {} catch (struct U {}) {} // expected-error {{'U' can not be defined in a type specifier}}
+
+ (void)(struct V { V(int); })0; // expected-error {{'V' can not be defined in a type specifier}}
+
+ (void)dynamic_cast<struct W {}*>((K*)0); // expected-error {{'W' can not be defined in a type specifier}}
+ (void)static_cast<struct X {}*>(0); // expected-error {{'X' can not be defined in a type specifier}}
+ (void)reinterpret_cast<struct Y {}*>(0); // expected-error {{'Y' can not be defined in a type specifier}}
+ (void)const_cast<struct Z {}*>((const Z*)0); // expected-error {{'Z' can not be defined in a type specifier}}
+}
+
+void g() throw (struct Ex {}) { // expected-error {{'Ex' can not be defined in a type specifier}}
+}
+
+int alignas(struct Aa {}) x; // expected-error {{'Aa' can not be defined in a type specifier}}
+
+int a = sizeof(struct So {}); // expected-error {{'So' can not be defined in a type specifier}}
+int b = alignof(struct Ao {}); // expected-error {{'Ao' can not be defined in a type specifier}}
+
+namespace std { struct type_info; }
+const std::type_info &ti = typeid(struct Ti {}); // expected-error {{'Ti' can not be defined in a type specifier}}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
new file mode 100644
index 0000000..b06eb01
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
@@ -0,0 +1,160 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+namespace RedeclAliasTypedef {
+ typedef int T;
+ using T = int;
+ using T = int;
+ typedef T T;
+ using T = T;
+ typedef int T;
+}
+
+namespace IllegalTypeIds {
+ using A = void(int n = 0); // expected-error {{default arguments can only be specified for parameters in a function declaration}}
+ using B = inline void(int n); // expected-error {{type name does not allow function specifier}}
+ using C = virtual void(int n); // expected-error {{type name does not allow function specifier}}
+ using D = explicit void(int n); // expected-error {{type name does not allow function specifier}}
+ using E = void(int n) throw(); // expected-error {{exception specifications are not allowed in type aliases}}
+ using F = void(*)(int n) &&; // expected-error {{pointer to function type cannot have '&&' qualifier}}
+ using G = __thread void(int n); // expected-error {{type name does not allow storage class to be specified}}
+ using H = constexpr int; // expected-error {{type name does not allow constexpr specifier}}
+
+ using Y = void(int n); // ok
+ using Z = void(int n) &&; // ok
+}
+
+namespace IllegalSyntax {
+ using ::T = void(int n); // expected-error {{name defined in alias declaration must be an identifier}}
+ using operator int = void(int n); // expected-error {{name defined in alias declaration must be an identifier}}
+ using typename U = void; // expected-error {{name defined in alias declaration must be an identifier}}
+ using typename ::V = void(int n); // expected-error {{name defined in alias declaration must be an identifier}}
+ using typename ::operator bool = void(int n); // expected-error {{name defined in alias declaration must be an identifier}}
+}
+
+namespace VariableLengthArrays {
+ using T = int[42]; // ok
+
+ int n = 32;
+ using T = int[n]; // expected-error {{variable length array declaration not allowed at file scope}}
+
+ const int m = 42;
+ using U = int[m]; // expected-note {{previous definition}}
+ using U = int[42]; // ok
+ using U = int; // expected-error {{type alias redefinition with different types ('int' vs 'int [42]')}}
+
+ void f() {
+ int n = 42;
+ goto foo; // expected-error {{goto into protected scope}}
+ using T = int[n]; // expected-note {{bypasses initialization of VLA type alias}}
+ foo: ;
+ }
+}
+
+namespace RedeclFunc {
+ int f(int, char**);
+ using T = int;
+ T f(int, char **); // ok
+}
+
+namespace LookupFilter {
+ namespace N { struct S; }
+ using namespace N;
+ using S = S*; // ok
+}
+
+namespace InFunctions {
+ template<typename...T> void f0() {
+ using U = T*; // expected-error {{declaration type contains unexpanded parameter pack 'T'}}
+ U u;
+ }
+ template void f0<int, char>();
+
+ void f1() {
+ using T = int;
+ }
+ void f2() {
+ using T = int[-1]; // expected-error {{array size is negative}}
+ }
+
+ template<typename...T> void f3() { // expected-note {{template parameter is declared here}}
+ using T = int; // expected-error {{declaration of 'T' shadows template parameter}}
+ }
+}
+
+namespace ClassNameRedecl {
+ class C0 {
+ // FIXME: this diagnostic is pretty poor
+ using C0 = int; // expected-error {{name defined in alias declaration must be an identifier}}
+ };
+ class C1 {
+ // FIXME: this diagnostic is pretty poor
+ using C1 = C1; // expected-error {{name defined in alias declaration must be an identifier}}
+ };
+ class C2 {
+ using C0 = C1; // ok
+ };
+ template<typename...T> class C3 {
+ using f = T; // expected-error {{declaration type contains unexpanded parameter pack 'T'}}
+ };
+ template<typename T> class C4 { // expected-note {{template parameter is declared here}}
+ using T = int; // expected-error {{declaration of 'T' shadows template parameter}}
+ };
+ class C5 {
+ class c; // expected-note {{previous definition}}
+ using c = int; // expected-error {{typedef redefinition with different types}}
+ class d;
+ using d = d; // ok
+ };
+ class C6 {
+ class c { using C6 = int; }; // ok
+ };
+}
+
+class CtorDtorName {
+ using X = CtorDtorName;
+ X(); // expected-error {{expected member name}}
+ ~X(); // expected-error {{destructor cannot be declared using a type alias}}
+};
+
+namespace TagName {
+ using S = struct { int n; };
+ using T = class { int n; };
+ using U = enum { a, b, c };
+ using V = struct V { int n; };
+}
+
+namespace CWG1044 {
+ // FIXME: this diagnostic isn't ideal. one diagnostic is enough.
+ using T = T; // expected-error {{type name requires a specifier}} \
+ expected-error {{expected ';' after alias declaration}}
+}
+
+namespace StdExample {
+ template<typename T, typename U> struct pair;
+
+ using handler_t = void (*)(int);
+ extern handler_t ignore;
+ extern void (*ignore)(int);
+ // FIXME: we know we're parsing a type here; don't recover as if we were
+ // using operator*.
+ using cell = pair<void*, cell*>; // expected-error {{use of undeclared identifier 'cell'}} \
+ expected-error {{expected expression}}
+}
+
+namespace Access {
+ class C0 {
+ using U = int; // expected-note {{declared private here}}
+ };
+ C0::U v; // expected-error {{'U' is a private member}}
+ class C1 {
+ public:
+ using U = int;
+ };
+ C1::U w; // ok
+}
+
+namespace VoidArg {
+ using V = void;
+ V f(int); // ok
+ V g(V); // expected-error {{empty parameter list defined with a type alias of 'void' not allowed}}
+}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p3.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p3.cpp
new file mode 100644
index 0000000..28f49d0
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p3.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify %s
+
+typedef struct s { int x; } s;
+typedef int I;
+typedef int I2;
+typedef I2 I; // expected-note {{previous definition is here}}
+
+typedef char I; // expected-error {{typedef redefinition with different types}}
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p4.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p4.cpp
new file mode 100644
index 0000000..c16ba20
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p4.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -verify %s
+
+struct S {
+ typedef struct A {} A; // expected-note {{previous definition is here}}
+ typedef struct B B;
+ typedef A A; // expected-error {{redefinition of 'A'}}
+
+ struct C { };
+ typedef struct C OtherC;
+ typedef OtherC C;
+
+ typedef struct D { } D2;
+ typedef D2 D;
+};
+
diff --git a/clang/test/CXX/dcl.dcl/p4-0x.cpp b/clang/test/CXX/dcl.dcl/p4-0x.cpp
new file mode 100644
index 0000000..31d4912
--- /dev/null
+++ b/clang/test/CXX/dcl.dcl/p4-0x.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only %s
+
+struct S {
+ constexpr S(bool b) : b(b) {}
+ constexpr explicit operator bool() { return b; }
+ bool b;
+};
+struct T {
+ constexpr operator int() { return 1; }
+};
+struct U {
+ constexpr operator int() { return 1; } // expected-note {{candidate}}
+ constexpr operator long() { return 0; } // expected-note {{candidate}}
+};
+
+static_assert(S(true), "");
+static_assert(S(false), "not so fast"); // expected-error {{not so fast}}
+static_assert(T(), "");
+static_assert(U(), ""); // expected-error {{ambiguous}}
+
+static_assert(false, L"\x14hi" "!" R"x(")x"); // expected-error {{static_assert failed L"\024hi!\""}}
diff --git a/clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp b/clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
new file mode 100644
index 0000000..06dd1bb
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// An explicitly-defaulted function may be declared constexpr only if it would
+// have been implicitly declared as constexpr.
+struct S1 {
+ constexpr S1() = default; // expected-error {{defaulted definition of default constructor is not constexpr}}
+ constexpr S1(const S1&) = default;
+ constexpr S1(S1&&) = default;
+ constexpr S1 &operator=(const S1&) = default; // expected-error {{explicitly-defaulted copy assignment operator may not have}}
+ constexpr S1 &operator=(S1&&) = default; // expected-error {{explicitly-defaulted move assignment operator may not have}}
+ constexpr ~S1() = default; // expected-error {{destructor cannot be marked constexpr}}
+ int n;
+};
+struct NoCopyMove {
+ constexpr NoCopyMove() {}
+ NoCopyMove(const NoCopyMove&);
+ NoCopyMove(NoCopyMove&&);
+};
+struct S2 {
+ constexpr S2() = default;
+ constexpr S2(const S2&) = default; // expected-error {{defaulted definition of copy constructor is not constexpr}}
+ constexpr S2(S2&&) = default; // expected-error {{defaulted definition of move constructor is not constexpr}}
+ NoCopyMove ncm;
+};
+
+// If a function is explicitly defaulted on its first declaration
+// -- it is implicitly considered to be constexpr if the implicit declaration
+// would be
+struct S3 {
+ S3() = default; // expected-note {{here}}
+ S3(const S3&) = default;
+ S3(S3&&) = default;
+ constexpr S3(int n) : n(n) {}
+ int n;
+};
+constexpr S3 s3a = S3(0);
+constexpr S3 s3b = s3a;
+constexpr S3 s3c = S3();
+constexpr S3 s3d; // expected-error {{constant expression}} expected-note {{non-constexpr constructor}}
+
+struct S4 {
+ S4() = default;
+ S4(const S4&) = default; // expected-note {{here}}
+ S4(S4&&) = default; // expected-note {{here}}
+ NoCopyMove ncm;
+};
+constexpr S4 s4a; // ok
+constexpr S4 s4b = S4(); // expected-error {{constant expression}} expected-note {{non-constexpr constructor}}
+constexpr S4 s4c = s4a; // expected-error {{constant expression}} expected-note {{non-constexpr constructor}}
+
+struct S5 {
+ constexpr S5();
+ int n = 1, m = n + 3;
+};
+constexpr S5::S5() = default;
+static_assert(S5().m == 4, "");
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp
new file mode 100644
index 0000000..7764980
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// An aggregate is an array or a class...
+struct Aggr {
+private:
+ static const int n;
+ void f();
+protected:
+ struct Inner { int m; };
+public:
+ bool &br; // expected-note {{default constructor of 'Aggr' is implicitly deleted because field 'br' of reference type 'bool &' would not be initialized}}
+};
+bool b;
+Aggr ag = { b };
+
+// with no user-provided constructors, ...
+struct NonAggr1a { // expected-note 2 {{candidate constructor}}
+ NonAggr1a(int, int); // expected-note {{candidate constructor}}
+ int k;
+};
+// In C++0x, 'user-provided' is only defined for special member functions, so
+// this type is considered to be an aggregate. This is considered to be
+// a language defect.
+NonAggr1a na1a = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr1a'}}
+
+struct NonAggr1b {
+ NonAggr1b(const NonAggr1b &); // expected-note {{candidate constructor}}
+ int k;
+};
+NonAggr1b na1b = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr1b'}}
+
+// no brace-or-equal-initializers for non-static data members, ...
+struct NonAggr2 { // expected-note 3 {{candidate constructor}}
+ int m = { 123 };
+};
+NonAggr2 na2 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr2'}}
+
+// no private...
+struct NonAggr3 { // expected-note 3 {{candidate constructor}}
+private:
+ int n;
+};
+NonAggr3 na3 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr3'}}
+
+// or protected non-static data members, ...
+struct NonAggr4 { // expected-note 3 {{candidate constructor}}
+protected:
+ int n;
+};
+NonAggr4 na4 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr4'}}
+
+// no base classes, ...
+struct NonAggr5 : Aggr { // expected-note 3 {{candidate constructor}}
+};
+NonAggr5 na5 = { b }; // expected-error {{no matching constructor for initialization of 'NonAggr5'}}
+template<typename...BaseList>
+struct MaybeAggr5a : BaseList... {}; // expected-note {{default constructor of 'MaybeAggr5a<Aggr>' is implicitly deleted because base class 'Aggr' has a deleted default constructor}}
+MaybeAggr5a<> ma5a0 = {}; // ok
+MaybeAggr5a<Aggr> ma5a1 = {}; // expected-error {{call to implicitly-deleted default constructor of 'MaybeAggr5a<Aggr>'}}
+
+// and no virtual functions.
+struct NonAggr6 { // expected-note 3 {{candidate constructor}}
+ virtual void f();
+ int n;
+};
+NonAggr6 na6 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr6'}}
+
+struct DefaultedAggr {
+ int n;
+
+ DefaultedAggr() = default;
+ DefaultedAggr(const DefaultedAggr &) = default;
+ DefaultedAggr(DefaultedAggr &&) = default;
+ DefaultedAggr &operator=(const DefaultedAggr &) = default;
+ DefaultedAggr &operator=(DefaultedAggr &) = default;
+ ~DefaultedAggr() = default;
+};
+DefaultedAggr da = { 42 } ;
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp
new file mode 100644
index 0000000..1041571
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -pedantic -Werror %s
+int a1[] = { 1, 3, 5 };
+void f() {
+ int a2[] = { 1, 3, 5 };
+}
+template <typename T>
+void tf() {
+ T t;
+ // Element type may be dependent
+ T a3[] = { 1, 3, 5 };
+ // As might be the initializer list, value
+ int a5[] = { sizeof(T) };
+ // or even type.
+ int a6[] = { t.get() };
+}
+
+// Allowed by GNU extension
+int a4[] = {}; // expected-error {{zero size arrays}}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp
new file mode 100644
index 0000000..b30e0ec
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+void f0() {
+ int &ir = { 17 }; // expected-error{{reference to type 'int' cannot bind to an initializer list}}
+}
+
+namespace PR12453 {
+ template<typename T>
+ void f(int i) {
+ T x{i}; // expected-error{{non-constant-expression cannot be narrowed from type 'int' to 'float' in initializer list}} \
+ // expected-note{{override this message by inserting an explicit cast}}
+ T y{i}; // expected-error{{non-constant-expression cannot be narrowed from type 'int' to 'float' in initializer list}} \
+ // expected-note{{override this message by inserting an explicit cast}}
+ }
+
+ template void f<float>(int); // expected-note{{in instantiation of function template specialization 'PR12453::f<float>' requested here}}
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp
new file mode 100644
index 0000000..0bea4ed
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -Wc++11-compat -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+
+// Verify that the appropriate fixits are emitted for narrowing conversions in
+// initializer lists.
+
+typedef short int16_t;
+
+void fixits() {
+ int x = 999;
+ struct {char c;} c2 = {x};
+ // CHECK: warning:{{.*}} cannot be narrowed
+ // CHECK: fix-it:{{.*}}:26}:"static_cast<char>("
+ // CHECK: fix-it:{{.*}}:27}:")"
+ struct {int16_t i;} i16 = {70000};
+ // CHECK: warning:{{.*}} cannot be narrowed
+ // CHECK: fix-it:{{.*}}:30}:"static_cast<int16_t>("
+ // CHECK: fix-it:{{.*}}:35}:")"
+}
+
+template<typename T>
+void maybe_shrink_int(T t) {
+ struct {T t;} t2 = {700};
+}
+
+void test_template() {
+ maybe_shrink_int((char)3);
+ // CHECK: warning:{{.*}} cannot be narrowed
+ // CHECK: note:{{.*}} in instantiation
+ // CHECK: note:{{.*}} override
+ // FIXME: This should be static_cast<T>.
+ // CHECK: fix-it:{{.*}}"static_cast<char>("
+ // CHECK: fix-it:{{.*}}")"
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
new file mode 100644
index 0000000..db20ea6
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
@@ -0,0 +1,209 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -triple x86_64-apple-macosx10.6.7 -verify %s
+
+// Verify that narrowing conversions in initializer lists cause errors in C++0x
+// mode.
+
+void std_example() {
+ int x = 999; // x is not a constant expression
+ const int y = 999;
+ const int z = 99;
+ char c1 = x; // OK, though it might narrow (in this case, it does narrow)
+ char c2{x}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ char c3{y}; // expected-error {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+ char c4{z}; // OK: no narrowing needed
+ unsigned char uc1 = {5}; // OK: no narrowing needed
+ unsigned char uc2 = {-1}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ unsigned int ui1 = {-1}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ signed int si1 =
+ { (unsigned int)-1 }; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ int ii = {2.0}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ float f1 { x }; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ float f2 { 7 }; // OK: 7 can be exactly represented as a float
+ int f(int);
+ int a[] =
+ { 2, f(2), f(2.0) }; // OK: the double-to-int conversion is not at the top level
+}
+
+// Test each rule individually.
+
+template<typename T>
+struct Agg {
+ T t;
+};
+
+template<typename T>
+struct Convert {
+ constexpr Convert(T v) : v(v) {}
+ constexpr operator T() const { return v; }
+ T v;
+};
+template<typename T> Convert<T> ConvertVar();
+
+// C++0x [dcl.init.list]p7: A narrowing conversion is an implicit conversion
+//
+// * from a floating-point type to an integer type, or
+
+void float_to_int() {
+ Agg<char> a1 = {1.0F}; // expected-error {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}}
+ Agg<char> a2 = {1.0}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> a3 = {1.0L}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+
+ float f = 1.0;
+ double d = 1.0;
+ long double ld = 1.0;
+ Agg<char> a4 = {f}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> a5 = {d}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> a6 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+
+ Agg<char> ce1 = { Convert<float>(1.0) }; // expected-error {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}}
+ Agg<char> ce2 = { ConvertVar<double>() }; // expected-error {{type 'double' cannot be narrowed to 'char'}} expected-note {{override}}
+}
+
+// * from long double to double or float, or from double to float, except where
+// the source is a constant expression and the actual value after conversion
+// is within the range of values that can be represented (even if it cannot be
+// represented exactly), or
+
+void shrink_float() {
+ // These aren't constant expressions.
+ float f = 1.0;
+ double d = 1.0;
+ long double ld = 1.0;
+
+ // Variables.
+ Agg<float> f1 = {f}; // OK (no-op)
+ Agg<float> f2 = {d}; // expected-error {{non-constant-expression cannot be narrowed from type 'double' to 'float'}} expected-note {{override}}
+ Agg<float> f3 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ // Exact constants.
+ Agg<float> f4 = {1.0}; // OK (double constant represented exactly)
+ Agg<float> f5 = {1.0L}; // OK (long double constant represented exactly)
+ // Inexact but in-range constants.
+ Agg<float> f6 = {0.1}; // OK (double constant in range but rounded)
+ Agg<float> f7 = {0.1L}; // OK (long double constant in range but rounded)
+ // Out of range constants.
+ Agg<float> f8 = {1E50}; // expected-error {{constant expression evaluates to 1.000000e+50 which cannot be narrowed to type 'float'}} expected-note {{override}}
+ Agg<float> f9 = {1E50L}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ // More complex constant expression.
+ constexpr long double e40 = 1E40L, e30 = 1E30L, e39 = 1E39L;
+ Agg<float> f10 = {e40 - 5 * e39 + e30 - 5 * e39}; // OK
+
+ // Variables.
+ Agg<double> d1 = {f}; // OK (widening)
+ Agg<double> d2 = {d}; // OK (no-op)
+ Agg<double> d3 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ // Exact constant.
+ Agg<double> d4 = {1.0L}; // OK (long double constant represented exactly)
+ // Inexact but in-range constant.
+ Agg<double> d5 = {0.1L}; // OK (long double constant in range but rounded)
+ // Out of range constant.
+ Agg<double> d6 = {1E315L}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ // More complex constant expression.
+ constexpr long double e315 = 1E315L, e305 = 1E305L, e314 = 1E314L;
+ Agg<double> d7 = {e315 - 5 * e314 + e305 - 5 * e314}; // OK
+
+ Agg<float> ce1 = { Convert<double>(1e300) }; // expected-error {{constant expression evaluates to 1.000000e+300 which cannot be narrowed to type 'float'}} expected-note {{override}}
+ Agg<double> ce2 = { ConvertVar<long double>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'long double' to 'double'}} expected-note {{override}}
+}
+
+// * from an integer type or unscoped enumeration type to a floating-point type,
+// except where the source is a constant expression and the actual value after
+// conversion will fit into the target type and will produce the original
+// value when converted back to the original type, or
+void int_to_float() {
+ // Not a constant expression.
+ char c = 1;
+
+ // Variables. Yes, even though all char's will fit into any floating type.
+ Agg<float> f1 = {c}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<double> f2 = {c}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<long double> f3 = {c}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+
+ // Constants.
+ Agg<float> f4 = {12345678}; // OK (exactly fits in a float)
+ Agg<float> f5 = {123456789}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+
+ Agg<float> ce1 = { Convert<int>(123456789) }; // expected-error {{constant expression evaluates to 123456789 which cannot be narrowed to type 'float'}} expected-note {{override}}
+ Agg<double> ce2 = { ConvertVar<long long>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'long long' to 'double'}} expected-note {{override}}
+}
+
+// * from an integer type or unscoped enumeration type to an integer type that
+// cannot represent all the values of the original type, except where the
+// source is a constant expression and the actual value after conversion will
+// fit into the target type and will produce the original value when converted
+// back to the original type.
+void shrink_int() {
+ // Not a constant expression.
+ short s = 1;
+ unsigned short us = 1;
+ Agg<char> c1 = {s}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<unsigned short> s1 = {s}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<short> s2 = {us}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+
+ // "that cannot represent all the values of the original type" means that the
+ // validity of the program depends on the relative sizes of integral types.
+ // This test compiles with -m64, so sizeof(int)<sizeof(long)==sizeof(long
+ // long).
+ long l1 = 1;
+ Agg<int> i1 = {l1}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ long long ll = 1;
+ Agg<long> l2 = {ll}; // OK
+
+ // Constants.
+ Agg<char> c2 = {127}; // OK
+ Agg<char> c3 = {300}; // expected-error {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+
+ Agg<int> i2 = {0x7FFFFFFFU}; // OK
+ Agg<int> i3 = {0x80000000U}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<unsigned int> i4 = {-0x80000000L}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+
+ // Bool is also an integer type, but conversions to it are a different AST
+ // node.
+ Agg<bool> b1 = {0}; // OK
+ Agg<bool> b2 = {1}; // OK
+ Agg<bool> b3 = {-1}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+
+ // Conversions from pointers to booleans aren't narrowing conversions.
+ Agg<bool> b = {&b1}; // OK
+
+ Agg<short> ce1 = { Convert<int>(100000) }; // expected-error {{constant expression evaluates to 100000 which cannot be narrowed to type 'short'}} expected-note {{override}} expected-warning {{changes value from 100000 to -31072}}
+ Agg<char> ce2 = { ConvertVar<short>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'short' to 'char'}} expected-note {{override}}
+}
+
+// Be sure that type- and value-dependent expressions in templates get the error
+// too.
+
+template<int I, typename T>
+void maybe_shrink_int(T t) {
+ Agg<short> s1 = {t}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<short> s2 = {I}; // expected-error {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+ Agg<T> t2 = {700}; // expected-error {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+}
+
+void test_template() {
+ maybe_shrink_int<15>((int)3); // expected-note {{in instantiation}}
+ maybe_shrink_int<70000>((char)3); // expected-note {{in instantiation}}
+}
+
+
+// We don't want qualifiers on the types in the diagnostic.
+
+void test_qualifiers(int i) {
+ const int j = i;
+ struct {const unsigned char c;} c1 = {j}; // expected-error {{from type 'int' to 'unsigned char' in}} expected-note {{override}}
+ // Template arguments make it harder to avoid printing qualifiers:
+ Agg<const unsigned char> c2 = {j}; // expected-error {{from type 'int' to 'const unsigned char' in}} expected-note {{override}}
+}
+
+// Test SFINAE checks.
+template<unsigned> struct Value { };
+
+template<typename T>
+int &check_narrowed(Value<sizeof((T){1.1})>);
+
+template<typename T>
+float &check_narrowed(...);
+
+void test_narrowed(Value<sizeof(int)> vi, Value<sizeof(double)> vd) {
+ int &ir = check_narrowed<double>(vd);
+ float &fr = check_narrowed<int>(vi);
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp
new file mode 100644
index 0000000..4bcf113
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp
@@ -0,0 +1,210 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-error=c++11-narrowing -triple x86_64-apple-macosx10.6.7 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-error=narrowing -triple x86_64-apple-macosx10.6.7 -verify %s
+
+// Verify that narrowing conversions in initializer lists cause errors in C++0x
+// mode.
+
+void std_example() {
+ int x = 999; // x is not a constant expression
+ const int y = 999;
+ const int z = 99;
+ char c1 = x; // OK, though it might narrow (in this case, it does narrow)
+ char c2{x}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ char c3{y}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+ char c4{z}; // OK: no narrowing needed
+ unsigned char uc1 = {5}; // OK: no narrowing needed
+ unsigned char uc2 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ unsigned int ui1 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ signed int si1 =
+ { (unsigned int)-1 }; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ int ii = {2.0}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ float f1 { x }; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ float f2 { 7 }; // OK: 7 can be exactly represented as a float
+ int f(int);
+ int a[] =
+ { 2, f(2), f(2.0) }; // OK: the double-to-int conversion is not at the top level
+}
+
+// Test each rule individually.
+
+template<typename T>
+struct Agg {
+ T t;
+};
+
+template<typename T>
+struct Convert {
+ constexpr Convert(T v) : v(v) {}
+ constexpr operator T() const { return v; }
+ T v;
+};
+template<typename T> Convert<T> ConvertVar();
+
+// C++0x [dcl.init.list]p7: A narrowing conversion is an implicit conversion
+//
+// * from a floating-point type to an integer type, or
+
+void float_to_int() {
+ Agg<char> a1 = {1.0F}; // expected-warning {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}}
+ Agg<char> a2 = {1.0}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> a3 = {1.0L}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+
+ float f = 1.0;
+ double d = 1.0;
+ long double ld = 1.0;
+ Agg<char> a4 = {f}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> a5 = {d}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> a6 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+
+ Agg<char> ce1 = { Convert<float>(1.0) }; // expected-warning {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}}
+ Agg<char> ce2 = { ConvertVar<double>() }; // expected-warning {{type 'double' cannot be narrowed to 'char'}} expected-note {{override}}
+}
+
+// * from long double to double or float, or from double to float, except where
+// the source is a constant expression and the actual value after conversion
+// is within the range of values that can be represented (even if it cannot be
+// represented exactly), or
+
+void shrink_float() {
+ // These aren't constant expressions.
+ float f = 1.0;
+ double d = 1.0;
+ long double ld = 1.0;
+
+ // Variables.
+ Agg<float> f1 = {f}; // OK (no-op)
+ Agg<float> f2 = {d}; // expected-warning {{non-constant-expression cannot be narrowed from type 'double' to 'float'}} expected-note {{override}}
+ Agg<float> f3 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ // Exact constants.
+ Agg<float> f4 = {1.0}; // OK (double constant represented exactly)
+ Agg<float> f5 = {1.0L}; // OK (long double constant represented exactly)
+ // Inexact but in-range constants.
+ Agg<float> f6 = {0.1}; // OK (double constant in range but rounded)
+ Agg<float> f7 = {0.1L}; // OK (long double constant in range but rounded)
+ // Out of range constants.
+ Agg<float> f8 = {1E50}; // expected-warning {{constant expression evaluates to 1.000000e+50 which cannot be narrowed to type 'float'}} expected-note {{override}}
+ Agg<float> f9 = {1E50L}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ // More complex constant expression.
+ constexpr long double e40 = 1E40L, e30 = 1E30L, e39 = 1E39L;
+ Agg<float> f10 = {e40 - 5 * e39 + e30 - 5 * e39}; // OK
+
+ // Variables.
+ Agg<double> d1 = {f}; // OK (widening)
+ Agg<double> d2 = {d}; // OK (no-op)
+ Agg<double> d3 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ // Exact constant.
+ Agg<double> d4 = {1.0L}; // OK (long double constant represented exactly)
+ // Inexact but in-range constant.
+ Agg<double> d5 = {0.1L}; // OK (long double constant in range but rounded)
+ // Out of range constant.
+ Agg<double> d6 = {1E315L}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ // More complex constant expression.
+ constexpr long double e315 = 1E315L, e305 = 1E305L, e314 = 1E314L;
+ Agg<double> d7 = {e315 - 5 * e314 + e305 - 5 * e314}; // OK
+
+ Agg<float> ce1 = { Convert<double>(1e300) }; // expected-warning {{constant expression evaluates to 1.000000e+300 which cannot be narrowed to type 'float'}} expected-note {{override}}
+ Agg<double> ce2 = { ConvertVar<long double>() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'long double' to 'double'}} expected-note {{override}}
+}
+
+// * from an integer type or unscoped enumeration type to a floating-point type,
+// except where the source is a constant expression and the actual value after
+// conversion will fit into the target type and will produce the original
+// value when converted back to the original type, or
+void int_to_float() {
+ // Not a constant expression.
+ char c = 1;
+
+ // Variables. Yes, even though all char's will fit into any floating type.
+ Agg<float> f1 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<double> f2 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<long double> f3 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+
+ // Constants.
+ Agg<float> f4 = {12345678}; // OK (exactly fits in a float)
+ Agg<float> f5 = {123456789}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+
+ Agg<float> ce1 = { Convert<int>(123456789) }; // expected-warning {{constant expression evaluates to 123456789 which cannot be narrowed to type 'float'}} expected-note {{override}}
+ Agg<double> ce2 = { ConvertVar<long long>() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'long long' to 'double'}} expected-note {{override}}
+}
+
+// * from an integer type or unscoped enumeration type to an integer type that
+// cannot represent all the values of the original type, except where the
+// source is a constant expression and the actual value after conversion will
+// fit into the target type and will produce the original value when converted
+// back to the original type.
+void shrink_int() {
+ // Not a constant expression.
+ short s = 1;
+ unsigned short us = 1;
+ Agg<char> c1 = {s}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<unsigned short> s1 = {s}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<short> s2 = {us}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+
+ // "that cannot represent all the values of the original type" means that the
+ // validity of the program depends on the relative sizes of integral types.
+ // This test compiles with -m64, so sizeof(int)<sizeof(long)==sizeof(long
+ // long).
+ long l1 = 1;
+ Agg<int> i1 = {l1}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ long long ll = 1;
+ Agg<long> l2 = {ll}; // OK
+
+ // Constants.
+ Agg<char> c2 = {127}; // OK
+ Agg<char> c3 = {300}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+
+ Agg<int> i2 = {0x7FFFFFFFU}; // OK
+ Agg<int> i3 = {0x80000000U}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<unsigned int> i4 = {-0x80000000L}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+
+ // Bool is also an integer type, but conversions to it are a different AST
+ // node.
+ Agg<bool> b1 = {0}; // OK
+ Agg<bool> b2 = {1}; // OK
+ Agg<bool> b3 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+
+ // Conversions from pointers to booleans aren't narrowing conversions.
+ Agg<bool> b = {&b1}; // OK
+
+ Agg<short> ce1 = { Convert<int>(100000) }; // expected-warning {{constant expression evaluates to 100000 which cannot be narrowed to type 'short'}} expected-note {{override}} expected-warning {{changes value from 100000 to -31072}}
+ Agg<char> ce2 = { ConvertVar<short>() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'short' to 'char'}} expected-note {{override}}
+}
+
+// Be sure that type- and value-dependent expressions in templates get the warning
+// too.
+
+template<int I, typename T>
+void maybe_shrink_int(T t) {
+ Agg<short> s1 = {t}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<short> s2 = {I}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+ Agg<T> t2 = {700}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+}
+
+void test_template() {
+ maybe_shrink_int<15>((int)3); // expected-note {{in instantiation}}
+ maybe_shrink_int<70000>((char)3); // expected-note {{in instantiation}}
+}
+
+
+// We don't want qualifiers on the types in the diagnostic.
+
+void test_qualifiers(int i) {
+ const int j = i;
+ struct {const unsigned char c;} c1 = {j}; // expected-warning {{from type 'int' to 'unsigned char' in}} expected-note {{override}}
+ // Template arguments make it harder to avoid printing qualifiers:
+ Agg<const unsigned char> c2 = {j}; // expected-warning {{from type 'int' to 'const unsigned char' in}} expected-note {{override}}
+}
+
+// Make sure we still get the right SFINAE behavior.
+template<unsigned> struct Value { };
+
+template<typename T>
+int &check_narrowed(Value<sizeof((T){1.1})>);
+
+template<typename T>
+float &check_narrowed(...);
+
+void test_narrowed(Value<sizeof(int)> vi, Value<sizeof(double)> vd) {
+ int &ir = check_narrowed<double>(vd);
+ float &fr = check_narrowed<int>(vi);
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp
new file mode 100644
index 0000000..885d11b
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR5787
+class C {
+ public:
+ ~C() {}
+};
+
+template <typename T>
+class E {
+ public:
+ E& Foo(const C&);
+ E& Bar() { return Foo(C()); }
+};
+
+void Test() {
+ E<int> e;
+ e.Bar();
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p1.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p1.cpp
new file mode 100644
index 0000000..20c059e
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p1.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+int g(int);
+void f() {
+ int i;
+ int& r = i;
+ r = 1;
+ int* p = &r;
+ int &rr=r;
+ int (&rg)(int) = g;
+ rg(i);
+ int a[3];
+ int (&ra)[3] = a;
+ ra[1] = i;
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p3.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p3.cpp
new file mode 100644
index 0000000..47e215a
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p3.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+int& r1; // expected-error{{declaration of reference variable 'r1' requires an initializer}}
+extern int& r2;
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp
new file mode 100644
index 0000000..adbdff6
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp
@@ -0,0 +1,194 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -pedantic %s
+
+// Test the c++0x-specific reference initialization rules, e.g., the
+// rules for rvalue references.
+template<typename T> T prvalue();
+template<typename T> T&& xvalue();
+template<typename T> T& lvalue();
+
+struct Base { };
+struct Derived : Base { };
+
+struct HasArray {
+ int array[5];
+};
+
+int f(int);
+
+template<typename T>
+struct ConvertsTo {
+ operator T(); // expected-note 2{{candidate function}}
+};
+
+void test_rvalue_refs() {
+ // If the initializer expression...
+ // - is an xvalue, class prvalue, array prvalue or function lvalue
+ // and "cv1 T1" is reference-compatible with "cv2 T2", or
+
+ // xvalue case
+ Base&& base0 = xvalue<Base>();
+ Base&& base1 = xvalue<Derived>();
+ int&& int0 = xvalue<int>();
+
+ // class prvalue case
+ Base&& base2 = prvalue<Base>();
+ Base&& base3 = prvalue<Derived>();
+
+ // array prvalue case
+ int (&&array0)[5] = HasArray().array;
+
+ // function lvalue case
+ int (&&function0)(int) = f;
+
+ // - has a class type (i.e., T2 is a class type), where T1 is not
+ // reference-related to T2, and can be implicitly converted to
+ // an xvalue, class prvalue, or function lvalue of type "cv3
+ // T3", where "cv1 T1" is reference-compatible with "cv3 T3",
+
+ // xvalue
+ Base&& base4 = ConvertsTo<Base&&>();
+ Base&& base5 = ConvertsTo<Derived&&>();
+ int && int1 = ConvertsTo<int&&>();
+
+ // class prvalue
+ Base&& base6 = ConvertsTo<Base>();
+ Base&& base7 = ConvertsTo<Derived>();
+
+ // function lvalue
+ int (&&function1)(int) = ConvertsTo<int(&)(int)>();
+
+ // In the second case, if the reference is an rvalue reference and
+ // the second standard conversion sequence of the user-defined
+ // conversion sequence includes an lvalue-to-rvalue conversion, the
+ // program is ill-formed.
+ int &&int2 = ConvertsTo<int&>(); // expected-error{{no viable conversion from 'ConvertsTo<int &>' to 'int'}}
+ int &&int3 = ConvertsTo<float&>(); // expected-error{{no viable conversion from 'ConvertsTo<float &>' to 'int'}}
+}
+
+class NonCopyable {
+ NonCopyable(const NonCopyable&);
+};
+
+class NonCopyableDerived : public NonCopyable {
+ NonCopyableDerived(const NonCopyableDerived&);
+};
+
+// Make sure we get direct bindings with no copies.
+void test_direct_binding() {
+ NonCopyable &&nc0 = prvalue<NonCopyable>();
+ NonCopyable &&nc1 = prvalue<NonCopyableDerived>();
+ NonCopyable &&nc2 = xvalue<NonCopyable>();
+ NonCopyable &&nc3 = xvalue<NonCopyableDerived>();
+ const NonCopyable &nc4 = prvalue<NonCopyable>();
+ const NonCopyable &nc5 = prvalue<NonCopyableDerived>();
+ const NonCopyable &nc6 = xvalue<NonCopyable>();
+ const NonCopyable &nc7 = xvalue<NonCopyableDerived>();
+ NonCopyable &&nc8 = ConvertsTo<NonCopyable&&>();
+ NonCopyable &&nc9 = ConvertsTo<NonCopyableDerived&&>();
+ const NonCopyable &nc10 = ConvertsTo<NonCopyable&&>();
+ const NonCopyable &nc11 = ConvertsTo<NonCopyableDerived&&>();
+}
+
+namespace std_example_1 {
+ double d = 2.0;
+ double& rd = d;
+ const double& rcd = d;
+ struct A { };
+ struct B : A {
+ operator int&();
+ } b;
+ A& ra = b;
+ const A& rca = b;
+ int& ir = B();
+}
+
+namespace std_example_2 {
+ double& rd2 = 2.0; // expected-error{{non-const lvalue reference to type 'double' cannot bind to a temporary of type 'double'}}
+ int i = 2;
+ double& rd3 = i; // expected-error{{non-const lvalue reference to type 'double' cannot bind to a value of unrelated type 'int'}}
+ struct A { };
+ struct B : A { } b;
+ extern B f();
+ const A& rca = f();
+ A&& rra = f();
+ struct X {
+ operator B(); // expected-note{{candidate function}}
+ operator int&(); // expected-note{{candidate function}}
+ } x;
+ const A& r = x;
+ int&& rri = static_cast<int&&>(i);
+ B&& rrb = x;
+ int&& rri2 = X(); // expected-error{{no viable conversion from 'std_example_2::X' to 'int'}}
+
+ const double& rcd2 = 2;
+ double&& rrd = 2;
+ const volatile int cvi = 1;
+ const int& r2 = cvi; // expected-error{{binding of reference to type 'const int' to a value of type 'const volatile int' drops qualifiers}}
+
+ double d;
+ double&& rrd2 = d; // expected-error{{rvalue reference to type 'double' cannot bind to lvalue of type 'double'}}
+ double&& rrd3 = i;
+}
+
+namespace argument_passing {
+ void base_rvalue_ref(Base&&);
+ void int_rvalue_ref(int&&); // expected-note{{candidate function not viable: no known conversion from 'ConvertsTo<int &>' to 'int &&' for 1st argument}} \
+ // expected-note{{candidate function not viable: no known conversion from 'ConvertsTo<float &>' to 'int &&' for 1st argument}}
+
+ void array_rvalue_ref(int (&&)[5]);
+ void function_rvalue_ref(int (&&)(int));
+
+ void test() {
+ base_rvalue_ref(xvalue<Base>());
+ base_rvalue_ref(xvalue<Derived>());
+ int_rvalue_ref(xvalue<int>());
+
+ base_rvalue_ref(prvalue<Base>());
+ base_rvalue_ref(prvalue<Derived>());
+
+ array_rvalue_ref(HasArray().array);
+
+ function_rvalue_ref(f);
+
+ base_rvalue_ref(ConvertsTo<Base&&>());
+ base_rvalue_ref(ConvertsTo<Derived&&>());
+ int_rvalue_ref(ConvertsTo<int&&>());
+
+ base_rvalue_ref(ConvertsTo<Base>());
+ base_rvalue_ref(ConvertsTo<Derived>());
+
+ function_rvalue_ref(ConvertsTo<int(&)(int)>());
+
+ int_rvalue_ref(ConvertsTo<int&>()); // expected-error{{no matching function for call to 'int_rvalue_ref'}}
+ int_rvalue_ref(ConvertsTo<float&>()); // expected-error{{no matching function for call to 'int_rvalue_ref'}}
+ }
+
+}
+
+namespace pr10644 {
+ struct string {
+ string(const char* __s);
+ };
+ class map {
+ int& operator[](const string& __k);
+ public:
+ int& operator[](const string&& __k);
+ };
+ void foo() {
+ static map key_map;
+ key_map["line"];
+ }
+}
+
+namespace PR11003 {
+ class Value {
+ };
+ struct MoveRef {
+ operator Value &() const ;
+ };
+ MoveRef Move(int);
+ void growTo() {
+ Value x = Move(0);
+ Value y(Move(0));
+ }
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp
new file mode 100644
index 0000000..d58a129
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify %s
+
+// C++03 requires that we check for a copy constructor when binding a
+// reference to a temporary, since we are allowed to make a copy, Even
+// though we don't actually make that copy, make sure that we diagnose
+// cases where that copy constructor is somehow unavailable. As an
+// extension, this is only a warning.
+
+struct X1 {
+ X1();
+ explicit X1(const X1&);
+};
+
+struct X2 {
+ X2();
+
+private:
+ X2(const X2&); // expected-note{{declared private here}}
+};
+
+struct X3 {
+ X3();
+
+private:
+ X3(X3&); // expected-note{{candidate constructor not viable: no known conversion from 'X3' to 'X3 &' for 1st argument}}
+};
+
+// Check for instantiation of default arguments
+template<typename T>
+T get_value_badly() {
+ double *dp = 0;
+ // The extension doesn't extend far enough to turn this error into a warning.
+ T *tp = dp; // expected-error{{cannot initialize a variable of type 'int *' with an lvalue of type 'double *'}}
+ return T();
+}
+
+template<typename T>
+struct X4 {
+ X4();
+ X4(const X4&, T = get_value_badly<T>()); // expected-note{{in instantiation of}}
+};
+
+// Check for "dangerous" default arguments that could cause recursion.
+struct X5 {
+ X5();
+ X5(const X5&, const X5& = X5()); // expected-warning{{no viable constructor copying parameter of type 'X5'}}
+};
+
+void g1(const X1&);
+void g2(const X2&);
+void g3(const X3&);
+void g4(const X4<int>&);
+void g5(const X5&);
+
+void test() {
+ g1(X1());
+ g2(X2()); // expected-warning{{C++98 requires an accessible copy constructor for class 'X2' when binding a reference to a temporary; was private}}
+ g3(X3()); // expected-warning{{no viable constructor copying parameter of type 'X3'}}
+ g4(X4<int>());
+ g5(X5()); // Generates a warning in the default argument.
+}
+
+// Check that unavailable copy constructors still cause SFINAE failures.
+template<int> struct int_c { };
+
+template<typename T> T f(const T&);
+
+// Would be ambiguous with the next g(), except the instantiation failure in
+// sizeof() prevents that.
+template<typename T>
+int &g(int_c<sizeof(f(T()))> * = 0);
+
+template<typename T> float &g();
+
+void h() {
+ float &fp2 = g<X3>(); // Not ambiguous.
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx0x-no-extra-copy.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx0x-no-extra-copy.cpp
new file mode 100644
index 0000000..27eb6d1
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx0x-no-extra-copy.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// C++03 requires that we check for a copy constructor when binding a
+// reference to a reference-compatible rvalue, since we are allowed to
+// make a copy. C++0x does not permit the copy, so ensure that we
+// don't diagnose cases where the copy constructor is unavailable.
+
+struct X1 {
+ X1();
+ explicit X1(const X1&);
+};
+
+struct X2 {
+ X2();
+
+private:
+ X2(const X2&);
+};
+
+struct X3 {
+ X3();
+
+private:
+ X3(X3&);
+};
+
+template<typename T>
+T get_value_badly() {
+ double *dp = 0;
+ T *tp = dp;
+ return T();
+}
+
+template<typename T>
+struct X4 {
+ X4();
+ X4(const X4&, T = get_value_badly<T>());
+};
+
+void g1(const X1&);
+void g2(const X2&);
+void g3(const X3&);
+void g4(const X4<int>&);
+
+void test() {
+ g1(X1());
+ g2(X2());
+ g3(X3());
+ g4(X4<int>());
+}
+
+// Check that unavailable copy constructors do not cause SFINAE failures.
+template<int> struct int_c { };
+
+template<typename T> T f(const T&);
+
+template<typename T>
+int &g(int_c<sizeof(f(T()))> * = 0); // expected-note{{candidate function [with T = X3]}}
+
+template<typename T> float &g(); // expected-note{{candidate function [with T = X3]}}
+
+void h() {
+ float &fp = g<X3>(); // expected-error{{call to 'g' is ambiguous}}
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp
new file mode 100644
index 0000000..08d9639
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -ast-dump %s 2>&1 | FileCheck %s
+
+// CHECK: example0
+void example0() {
+ double d = 2.0;
+ // CHECK: double &rd =
+ // CHECK-NEXT: DeclRefExpr
+ double &rd = d;
+ // CHECK: const double &rcd =
+ // CHECK-NEXT: ImplicitCastExpr{{.*}}'const double' lvalue <NoOp>
+ const double &rcd = d;
+}
+
+struct A { };
+struct B : A { } b;
+
+// CHECK: example1
+void example1() {
+ // CHECK: A &ra =
+ // CHECK: ImplicitCastExpr{{.*}}'struct A' lvalue <DerivedToBase (A)>
+ A &ra = b;
+ // CHECK: const A &rca =
+ // CHECK: ImplicitCastExpr{{.*}}'const struct A' lvalue <NoOp>
+ // CHECK: ImplicitCastExpr{{.*}}'struct A' lvalue <DerivedToBase (A)>
+ const A& rca = b;
+}
+
+extern B f();
+
+struct X {
+ operator B();
+} x;
+
+// CHECK: example2
+void example2() {
+ // CHECK: const A &rca =
+ // CHECK: ImplicitCastExpr{{.*}}'const struct A' <NoOp>
+ // CHECK: ImplicitCastExpr{{.*}}'struct A' <DerivedToBase (A)>
+ // CHECK: CallExpr{{.*}}B
+ const A &rca = f();
+ // CHECK: const A &r =
+ // CHECK: ImplicitCastExpr{{.*}}'const struct A' <NoOp>
+ // CHECK: ImplicitCastExpr{{.*}}'struct A' <DerivedToBase (A)>
+ // CHECK: CXXMemberCallExpr{{.*}}'struct B'
+ const A& r = x;
+}
+
+// CHECK: example3
+void example3() {
+ // CHECK: const double &rcd2 =
+ // CHECK: ImplicitCastExpr{{.*}} <IntegralToFloating>
+ const double& rcd2 = 2;
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp
new file mode 100644
index 0000000..fee5f96
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp
@@ -0,0 +1,135 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct Base { };
+struct Derived : Base { }; // expected-note{{candidate constructor (the implicit copy constructor) not viable}}
+struct Unrelated { };
+struct Derived2 : Base { };
+struct Diamond : Derived, Derived2 { };
+
+struct ConvertibleToBaseRef {
+ operator Base&() const;
+};
+
+struct ConvertibleToDerivedRef {
+ operator Derived&() const;
+};
+
+struct ConvertibleToBothDerivedRef {
+ operator Derived&(); // expected-note{{candidate function}}
+ operator Derived2&(); // expected-note{{candidate function}}
+};
+
+struct ConvertibleToIntRef {
+ operator int&();
+};
+
+struct ConvertibleToBase {
+ operator Base() const;
+};
+
+struct ConvertibleToDerived {
+ operator Derived() const;
+};
+
+struct ConvertibleToBothDerived {
+ operator Derived(); // expected-note{{candidate function}}
+ operator Derived2(); // expected-note{{candidate function}}
+};
+
+struct ConvertibleToInt {
+ operator int();
+};
+
+template<typename T> T create();
+
+// First bullet: lvalue references binding to lvalues (the simple cases).
+void bind_lvalue_to_lvalue(Base b, Derived d,
+ const Base bc, const Derived dc,
+ Diamond diamond,
+ int i) {
+ // Reference-compatible
+ Base &br1 = b;
+ Base &br2 = d;
+ Derived &dr1 = d;
+ Derived &dr2 = b; // expected-error{{non-const lvalue reference to type 'Derived' cannot bind to a value of unrelated type 'Base'}}
+ Base &br3 = bc; // expected-error{{drops qualifiers}}
+ Base &br4 = dc; // expected-error{{drops qualifiers}}
+ Base &br5 = diamond; // expected-error{{ambiguous conversion from derived class 'Diamond' to base class 'Base':}}
+ int &ir = i;
+ long &lr = i; // expected-error{{non-const lvalue reference to type 'long' cannot bind to a value of unrelated type 'int'}}
+}
+
+void bind_lvalue_quals(volatile Base b, volatile Derived d,
+ volatile const Base bvc, volatile const Derived dvc,
+ volatile const int ivc) {
+ volatile Base &bvr1 = b;
+ volatile Base &bvr2 = d;
+ volatile Base &bvr3 = bvc; // expected-error{{binding of reference to type 'volatile Base' to a value of type 'const volatile Base' drops qualifiers}}
+ volatile Base &bvr4 = dvc; // expected-error{{binding of reference to type 'volatile Base' to a value of type 'const volatile Derived' drops qualifiers}}
+
+ volatile int &ir = ivc; // expected-error{{binding of reference to type 'volatile int' to a value of type 'const volatile int' drops qualifiers}}
+
+ const volatile Base &bcvr1 = b;
+ const volatile Base &bcvr2 = d;
+}
+
+void bind_lvalue_to_rvalue() {
+ Base &br1 = Base(); // expected-error{{non-const lvalue reference to type 'Base' cannot bind to a temporary of type 'Base'}}
+ Base &br2 = Derived(); // expected-error{{non-const lvalue reference to type 'Base' cannot bind to a temporary of type 'Derived'}}
+ const volatile Base &br3 = Base(); // expected-error{{volatile lvalue reference to type 'const volatile Base' cannot bind to a temporary of type 'Base'}}
+ const volatile Base &br4 = Derived(); // expected-error{{volatile lvalue reference to type 'const volatile Base' cannot bind to a temporary of type 'Derived'}}
+
+ int &ir = 17; // expected-error{{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'int'}}
+}
+
+void bind_lvalue_to_unrelated(Unrelated ur) {
+ Base &br1 = ur; // expected-error{{non-const lvalue reference to type 'Base' cannot bind to a value of unrelated type 'Unrelated'}}
+ const volatile Base &br2 = ur; // expected-error{{volatile lvalue reference to type 'const volatile Base' cannot bind to a value of unrelated type 'Unrelated'}}
+}
+
+void bind_lvalue_to_conv_lvalue() {
+ // Not reference-related, but convertible
+ Base &nbr1 = ConvertibleToBaseRef();
+ Base &nbr2 = ConvertibleToDerivedRef();
+ Derived &ndr1 = ConvertibleToDerivedRef();
+ int &ir = ConvertibleToIntRef();
+}
+
+void bind_lvalue_to_conv_lvalue_ambig(ConvertibleToBothDerivedRef both) {
+ Derived &dr1 = both;
+ Base &br1 = both; // expected-error{{reference initialization of type 'Base &' with initializer of type 'ConvertibleToBothDerivedRef' is ambiguous}}
+}
+
+struct IntBitfield {
+ int i : 17; // expected-note{{bit-field is declared here}}
+};
+
+void test_bitfield(IntBitfield ib) {
+ int & ir1 = (ib.i); // expected-error{{non-const reference cannot bind to bit-field 'i'}}
+}
+
+// Second bullet: const lvalue reference binding to an rvalue with
+// similar type (both of which are class types).
+void bind_const_lvalue_to_rvalue() {
+ const Base &br1 = create<Base>();
+ const Base &br2 = create<Derived>();
+ const Derived &dr1 = create<Base>(); // expected-error{{no viable conversion}}
+
+ const Base &br3 = create<const Base>();
+ const Base &br4 = create<const Derived>();
+
+ const Base &br5 = create<const volatile Base>(); // expected-error{{binding of reference to type 'const Base' to a value of type 'const volatile Base' drops qualifiers}}
+ const Base &br6 = create<const volatile Derived>(); // expected-error{{binding of reference to type 'const Base' to a value of type 'const volatile Derived' drops qualifiers}}
+
+ const int &ir = create<int>();
+}
+
+// Second bullet: const lvalue reference binds to the result of a conversion.
+void bind_const_lvalue_to_class_conv_temporary() {
+ const Base &br1 = ConvertibleToBase();
+ const Base &br2 = ConvertibleToDerived();
+}
+void bind_lvalue_to_conv_rvalue_ambig(ConvertibleToBothDerived both) {
+ const Derived &dr1 = both;
+ const Base &br1 = both; // expected-error{{reference initialization of type 'const Base &' with initializer of type 'ConvertibleToBothDerived' is ambiguous}}
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp
new file mode 100644
index 0000000..51d61a5
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR5909 {
+ struct Foo {
+ int x : 20;
+ };
+
+ bool Test(const int& foo);
+
+ const Foo f = { 0 }; // It compiles without the 'const'.
+ bool z = Test(f.x);
+}
+
+namespace PR6264 {
+ typedef int (&T)[3];
+ struct S
+ {
+ operator T ();
+ };
+ void f()
+ {
+ T bar = S();
+ }
+}
+
+namespace PR6066 {
+ struct B { };
+ struct A : B {
+ operator B*();
+ operator B&(); // expected-warning{{conversion function converting 'PR6066::A' to its base class 'PR6066::B' will never be used}}
+ };
+
+ void f(B&); // no rvalues accepted
+ void f(B*);
+
+ int g() {
+ f(A()); // calls f(B*)
+ return 0;
+ }
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.string/p1.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.string/p1.cpp
new file mode 100644
index 0000000..3631af1
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.string/p1.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+char x1[]("hello");
+extern char x1[6];
+
+char x2[] = "hello";
+extern char x2[6];
+
+char x3[] = { "hello" };
+extern char x3[6];
+
+wchar_t x4[](L"hello");
+extern wchar_t x4[6];
+
+wchar_t x5[] = L"hello";
+extern wchar_t x5[6];
+
+wchar_t x6[] = { L"hello" };
+extern wchar_t x6[6];
diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.string/p2.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.string/p2.cpp
new file mode 100644
index 0000000..3d67fcc
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.string/p2.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+char test1[1]="f"; // expected-error {{initializer-string for char array is too long}}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/p14-0x.cpp b/clang/test/CXX/dcl.decl/dcl.init/p14-0x.cpp
new file mode 100644
index 0000000..419f2bf
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/p14-0x.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct NoDefault {
+ NoDefault() = delete; // expected-note {{here}}
+ NoDefault(int);
+};
+struct Explicit { // expected-note 2 {{candidate}} expected-note {{here}}
+ explicit Explicit(int);
+};
+struct NoCopy {
+ NoCopy();
+ NoCopy(const NoCopy &) = delete; // expected-note {{here}}
+};
+struct NoMove {
+ NoMove();
+ NoMove(NoMove &&) = delete; // expected-note {{here}}
+};
+class Private {
+ Private(int); // expected-note {{here}}
+public:
+ Private();
+};
+class Friend {
+ friend class S;
+ Friend(int);
+};
+
+
+class S {
+ NoDefault nd1;
+ NoDefault nd2 = 42;
+ Explicit e1; // expected-note {{here}}
+ Explicit e2 = 42; // expected-error {{no viable conversion}}
+ NoCopy nc = NoCopy(); // expected-error {{call to deleted}}
+ NoMove nm = NoMove(); // expected-error {{call to deleted}}
+ Private p = 42; // expected-error {{private constructor}}
+ Friend f = 42;
+
+ S() {} // expected-error {{call to deleted constructor of 'NoDefault'}} \
+ expected-error {{must explicitly initialize the member 'e1' which does not have a default constructor}}
+ S(int) : nd1(42), e1(42) {}
+};
+
+// FIXME: test the other forms which use copy-initialization
diff --git a/clang/test/CXX/dcl.decl/dcl.init/p5.cpp b/clang/test/CXX/dcl.decl/dcl.init/p5.cpp
new file mode 100644
index 0000000..b50e8d7
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/p5.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// FIXME: Very incomplete!
+
+// A program that calls for default-initialization or value-initialization of
+// an entity of reference type is illformed. If T is a cv-qualified type, the
+// cv-unqualified version of T is used for these definitions of
+// zero-initialization, default-initialization, and value-initialization.
+//
+// FIXME: The diagnostics for these errors are terrible because they fall out
+// of the AST representation rather than being explicitly issued during the
+// respective initialization forms.
+struct S { // expected-error {{implicit default constructor for 'S' must explicitly initialize the reference member}} \
+ // expected-note {{candidate constructor (the implicit copy constructor) not viable}}
+ int& x; // expected-note {{declared here}}
+};
+S s; // expected-note {{implicit default constructor for 'S' first required here}}
+S f() {
+ return S(); // expected-error {{no matching constructor for initialization of 'S'}}
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.init/p6.cpp b/clang/test/CXX/dcl.decl/dcl.init/p6.cpp
new file mode 100644
index 0000000..514fd0c
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.init/p6.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// FIXME: Very incomplete!
+
+// If a program calls for the default initialization of an object of a
+// const-qualified type T, T shall be a class type with a
+// user-provided default constructor.
+struct MakeNonPOD { MakeNonPOD(); };
+struct NoUserDefault : public MakeNonPOD { };
+struct HasUserDefault { HasUserDefault(); };
+
+void test_const_default_init() {
+ const NoUserDefault x1; // expected-error{{default initialization of an object of const type 'const NoUserDefault' requires a user-provided default constructor}}
+ const HasUserDefault x2;
+ const int x3; // expected-error{{default initialization of an object of const type 'const int'}}
+}
+
+// rdar://8501008
+struct s0 {};
+struct s1 { static const s0 foo; };
+const struct s0 s1::foo; // expected-error{{default initialization of an object of const type 'const struct s0' requires a user-provided default constructor}}
+
+template<typename T>
+struct s2 {
+ static const s0 foo;
+};
+
+template<> const struct s0 s2<int>::foo; // okay
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp
new file mode 100644
index 0000000..102746c
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+void f() {
+ int b[5];
+ auto a[5] = b; // expected-error{{'a' declared as array of 'auto'}}
+ auto *c[5] = b; // expected-error{{'c' declared as array of 'auto *'}}
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp
new file mode 100644
index 0000000..bb4a48e
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+
+// Simple form
+int ar1[10];
+
+// Element type cannot be:
+// - (cv) void
+volatile void ar2[10]; // expected-error {{incomplete element type 'volatile void'}}
+// - a reference
+int& ar3[10]; // expected-error {{array of references}}
+// - a function type
+typedef void Fn();
+Fn ar4[10]; // expected-error {{array of functions}}
+// - an abstract class
+struct Abstract { virtual void fn() = 0; }; // expected-note {{pure virtual}}
+Abstract ar5[10]; // expected-error {{abstract class}}
+
+// If we have a size, it must be greater than zero.
+int ar6[-1]; // expected-error {{array with a negative size}}
+int ar7[0u]; // expected-warning {{zero size arrays are an extension}}
+
+// An array with unknown bound is incomplete.
+int ar8[]; // expected-error {{needs an explicit size or an initializer}}
+// So is an array with an incomplete element type.
+struct Incomplete; // expected-note {{forward declaration}}
+Incomplete ar9[10]; // expected-error {{incomplete type}}
+// Neither of which should be a problem in situations where no complete type
+// is required. (PR5048)
+void fun(int p1[], Incomplete p2[10]);
+extern int ear1[];
+extern Incomplete ear2[10];
+
+// cv migrates to element type
+typedef const int cint;
+extern cint car1[10];
+typedef int intar[10];
+// thus this is a valid redeclaration
+extern const intar car1;
+
+// Check that instantiation works properly when the element type is a template.
+template <typename T> struct S {
+ typename T::type x; // expected-error {{has no members}}
+};
+S<int> ar10[10]; // expected-note {{requested here}}
+
+// Ensure that negative array size errors include the name of the declared
+// array as this is often used to simulate static_assert with template
+// instantiations, placing the 'error message' in the declarator name.
+int
+user_error_message
+[-1]; // expected-error {{user_error_message}}
+typedef int
+another_user_error_message
+[-1]; // expected-error {{another_user_error_message}}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp
new file mode 100644
index 0000000..385e45d
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {
+ virtual void f(int a = 7);
+};
+
+struct B : public A {
+ void f(int a); // expected-note{{'f' declared here}}
+};
+
+void m() {
+ B* pb = new B;
+ A* pa = pb;
+ pa->f(); // OK, calls pa->B::f(7)
+ pb->f(); // expected-error{{too few arguments}}
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p2.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p2.cpp
new file mode 100644
index 0000000..0a107eb
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p2.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void point(int = 3, int = 4);
+
+void test_point() {
+ point(1,2);
+ point(1);
+ point();
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p3.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p3.cpp
new file mode 100644
index 0000000..e9c5e0c
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p3.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void nondecl(int (*f)(int x = 5)) // {expected-error {{default arguments can only be specified}}}
+{
+ void (*f2)(int = 17) // {expected-error {{default arguments can only be specified}}}
+ = (void (*)(int = 42))f; // {expected-error {{default arguments can only be specified}}}
+}
+
+struct X0 {
+ int (*f)(int = 17); // expected-error{{default arguments can only be specified for parameters in a function declaration}}
+
+ void mem8(int (*fp)(int) = (int (*)(int = 17))0); // expected-error{{default arguments can only be specified for parameters in a function declaration}}
+};
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
new file mode 100644
index 0000000..f3dec52
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f0(int i, int j, int k = 3);
+void f0(int i, int j, int k);
+void f0(int i, int j = 2, int k);
+void f0(int i, int j, int k);
+void f0(int i = 1, // expected-note{{previous definition}}
+ int j, int k);
+void f0(int i, int j, int k);
+
+namespace N0 {
+ void f0(int, int, int); // expected-note{{candidate}}
+
+ void test_f0_inner_scope() {
+ f0(); // expected-error{{no matching}}
+ }
+}
+
+void test_f0_outer_scope() {
+ f0(); // okay
+}
+
+void f0(int i = 1, // expected-error{{redefinition of default argument}}
+ int, int);
+
+template<typename T> void f1(T); // expected-note{{previous}}
+
+template<typename T>
+void f1(T = T()); // expected-error{{cannot be added}}
+
+
+namespace N1 {
+ // example from C++03 standard
+ // FIXME: make these "f2"s into "f"s, then fix our scoping issues
+ void f2(int, int);
+ void f2(int, int = 7);
+ void h() {
+ f2(3); // OK, calls f(3, 7)
+ void f(int = 1, int); // expected-error{{missing default argument}}
+ }
+
+ void m()
+ {
+ void f(int, int); // expected-note{{'f' declared here}}
+ f(4); // expected-error{{too few arguments to function call}}
+ void f(int, int = 5); // expected-note{{previous definition}}
+ f(4); // okay
+ void f(int, int = 5); // expected-error{{redefinition of default argument}}
+ }
+
+ void n()
+ {
+ f2(6); // okay
+ }
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp
new file mode 100644
index 0000000..3100e56
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+float global_f;
+
+void f0(int *ip = &global_f); // expected-error{{cannot initialize}} \
+// expected-note{{passing argument to parameter 'ip' here}}
+
+// Example from C++03 standard
+int a = 1;
+int f(int);
+int g(int x = f(a));
+
+void h() {
+ a = 2;
+ {
+ int *a = 0;
+ g(); // FIXME: check that a is called with a value of 2
+ }
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp
new file mode 100644
index 0000000..9ab0b48
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class C {
+public:
+ void f(int i = 3); // expected-note{{here}}
+ void g(int i, int j = 99);
+};
+
+void C::f(int i = 3) { } // expected-error{{redefinition of default argument}}
+
+void C::g(int i = 88, int j) { }
+
+void test_C(C c) {
+ c.f();
+ c.g();
+}
+
+template<typename T>
+struct X0 {
+ void f(int);
+
+ struct Inner {
+ void g(int);
+ };
+};
+
+// DR217
+template<typename T>
+void X0<T>::f(int = 17) { } // expected-error{{cannot be added}}
+
+// DR217 + DR205 (reading tea leaves)
+template<typename T>
+void X0<T>::Inner::g(int = 17) { } // expected-error{{cannot be added}}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
new file mode 100644
index 0000000..164eb36
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void h()
+{
+ int i;
+ extern void h2(int x = sizeof(i)); // expected-error {{default argument references local variable 'i' of enclosing function}}
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
new file mode 100644
index 0000000..1a08ab7
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class A {
+ void f(A* p = this) { } // expected-error{{invalid use of 'this'}}
+};
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp
new file mode 100644
index 0000000..a879829
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// FIXME: test with non-std qualifiers
+
+namespace move {
+ struct Const {
+ Const(const Const&&) = default; // expected-error {{the parameter for an explicitly-defaulted move constructor may not be const}}
+ Const& operator=(const Const&&) = default; // expected-error {{the parameter for an explicitly-defaulted move assignment operator may not be const}}
+ };
+
+ struct Volatile {
+ Volatile(volatile Volatile&&) = default; // expected-error {{the parameter for an explicitly-defaulted move constructor may not be volatile}}
+ Volatile& operator=(volatile Volatile&&) = default; // expected-error {{the parameter for an explicitly-defaulted move assignment operator may not be volatile}}
+ };
+
+ struct AssignmentRet1 {
+ AssignmentRet1&& operator=(AssignmentRet1&&) = default; // expected-error {{an explicitly-defaulted move assignment operator must return an unqualified lvalue reference to its class type}}
+ };
+
+ struct AssignmentRet2 {
+ const AssignmentRet2& operator=(AssignmentRet2&&) = default; // expected-error {{an explicitly-defaulted move assignment operator must return an unqualified lvalue reference to its class type}}
+ };
+
+ struct ConstAssignment {
+ ConstAssignment& operator=(ConstAssignment&&) const = default; // expected-error {{an explicitly-defaulted move assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}
+ };
+}
+
+namespace copy {
+ struct Volatile {
+ Volatile(const volatile Volatile&) = default; // expected-error {{the parameter for an explicitly-defaulted copy constructor may not be volatile}}
+ Volatile& operator=(const volatile Volatile&) = default; // expected-error {{the parameter for an explicitly-defaulted copy assignment operator may not be volatile}}
+ };
+
+ struct Const {
+ Const(const Const&) = default;
+ Const& operator=(const Const&) = default;
+ };
+
+ struct NonConst {
+ NonConst(NonConst&) = default;
+ NonConst& operator=(NonConst&) = default;
+ };
+
+ struct BadConst {
+ NonConst nc; // makes implicit copy non-const
+ BadConst(const BadConst&) = default; // expected-error {{is const, but}}
+ BadConst& operator=(const BadConst&) = default; // expected-error {{is const, but}}
+ };
+
+ struct AssignmentRet1 {
+ AssignmentRet1&& operator=(const AssignmentRet1&) = default; // expected-error {{an explicitly-defaulted copy assignment operator must return an unqualified lvalue reference to its class type}}
+ };
+
+ struct AssignmentRet2 {
+ const AssignmentRet2& operator=(const AssignmentRet2&) = default; // expected-error {{an explicitly-defaulted copy assignment operator must return an unqualified lvalue reference to its class type}}
+ };
+
+ struct ConstAssignment {
+ ConstAssignment& operator=(const ConstAssignment&) const = default; // expected-error {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}
+ };
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp
new file mode 100644
index 0000000..19a5f23
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -fexceptions -verify %s
+
+// When it is part of a parameter-declaration-clause, the parameter
+// pack is a function parameter pack.
+template<typename ...Types>
+void f0(Types ...args);
+
+template<typename ...Types>
+void f1(const Types &...args);
+
+// [ Note: Otherwise, the parameter-declaration is part of a
+// template-parameter-list and the parameter pack is a template
+// parameter pack; see 14.1. -- end note ]
+template<int ...N>
+struct X0 { };
+
+template<typename ...Types>
+struct X1 {
+ template<Types ...Values> struct Inner;
+};
+
+// A declarator-id or abstract-declarator containing an ellipsis shall
+// only be used in a parameter-declaration.
+int (...f2)(int); // expected-error{{only function and template parameters can be parameter packs}}
+
+void f3() {
+ int ...x; // expected-error{{only function and template parameters can be parameter packs}}
+ if (int ...y = 17) { } // expected-error{{only function and template parameters can be parameter packs}}
+
+ for (int ...z = 0; z < 10; ++z) { } // expected-error{{only function and template parameters can be parameter packs}}
+
+ try {
+ } catch (int ...e) { // expected-error{{only function and template parameters can be parameter packs}}
+ }
+}
+
+template<typename ...Types>
+struct X2 {
+ Types ...members; // expected-error{{only function and template parameters can be parameter packs}} \
+ // expected-error{{data member type contains unexpanded parameter pack}}
+};
+
+// The type T of the declarator-id of the function parameter pack
+// shall contain a template parameter pack; each template parameter
+// pack in T is expanded by the function parameter pack.
+template<typename T>
+void f4(T ...args); // expected-error{{type 'T' of function parameter pack does not contain any unexpanded parameter packs}}
+
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp
new file mode 100644
index 0000000..0e69521
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<typename T> struct identity;
+template<typename ...Types> struct tuple;
+
+template<typename T, typename U> struct is_same {
+ static const bool value = false;
+};
+
+template<typename T> struct is_same<T, T> {
+ static const bool value = true;
+};
+
+// There is a syntactic ambiguity when an ellipsis occurs at the end
+// of a parameter-declaration-clause without a preceding comma. In
+// this case, the ellipsis is parsed as part of the
+// abstract-declarator if the type of the parameter names a template
+// parameter pack that has not been expanded; otherwise, it is parsed
+// as part of the parameter-declaration-clause.
+
+template<typename T, typename ...Types>
+struct X0 {
+ typedef identity<T(Types...)> function_pack_1;
+ typedef identity<T(Types......)> variadic_function_pack_1;
+ typedef identity<T(T...)> variadic_1;
+ typedef tuple<T(Types, ...)...> template_arg_expansion_1;
+};
+
+
+
+// FIXME: Once function parameter packs are implemented, we can test all of the disambiguation
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp
new file mode 100644
index 0000000..6b1f3e4
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+auto a() -> int; // ok
+const auto b() -> int; // expected-error {{function with trailing return type must specify return type 'auto', not 'auto const'}}
+auto *c() -> int; // expected-error {{function with trailing return type must specify return type 'auto', not 'auto *'}}
+auto (d() -> int); // expected-error {{trailing return type may not be nested within parentheses}}
+auto e() -> auto (*)() -> auto (*)() -> void; // ok: same as void (*(*e())())();
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp
new file mode 100644
index 0000000..ad827fb
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+void f(int) { } // expected-note {{previous definition is here}}
+void f(const int) { } // expected-error {{redefinition of 'f'}}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp
new file mode 100644
index 0000000..2ec1454
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+void f0() &; // expected-error {{non-member function cannot have '&' qualifier}}
+void f1() &&; // expected-error {{non-member function cannot have '&&' qualifier}}
+void f2() const volatile &&; // expected-error {{non-member function cannot have 'const volatile &&' qualifier}}
+
+struct X {
+ void f0() &;
+ void f1() &&;
+ static void f2() &; // expected-error{{static member function cannot have '&' qualifier}}
+ static void f3() &&; // expected-error{{static member function cannot have '&&' qualifier}}
+};
+
+typedef void func_type_lvalue() &;
+typedef void func_type_rvalue() &&;
+
+typedef func_type_lvalue *func_type_lvalue_ptr; // expected-error{{pointer to function type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}}
+typedef func_type_rvalue *func_type_rvalue_ptr; // expected-error{{pointer to function type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}}
+
+typedef func_type_lvalue &func_type_lvalue_ref; // expected-error{{reference to function type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}}
+typedef func_type_rvalue &func_type_rvalue_ref; // expected-error{{reference to function type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}}
+
+template<typename T = func_type_lvalue> struct wrap {
+ typedef T val;
+ typedef T *ptr;
+ typedef T &ref;
+};
+
+using func_type_lvalue = wrap<>::val;
+using func_type_lvalue = wrap<func_type_lvalue>::val;
+using func_type_rvalue = wrap<func_type_rvalue>::val;
+
+using func_type_lvalue_ptr = wrap<>::ptr;
+using func_type_lvalue_ptr = wrap<func_type_lvalue>::ptr;
+using func_type_rvalue_ptr = wrap<func_type_rvalue>::ptr;
+
+using func_type_lvalue_ref = wrap<>::ref;
+using func_type_lvalue_ref = wrap<func_type_lvalue>::ref;
+using func_type_rvalue_ref = wrap<func_type_rvalue>::ref;
+
+func_type_lvalue f2; // expected-error{{non-member function of type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}}
+func_type_rvalue f3; // expected-error{{non-member function of type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}}
+
+struct Y {
+ func_type_lvalue f0;
+ func_type_rvalue f1;
+};
+
+void (X::*mpf1)() & = &X::f0;
+void (X::*mpf2)() && = &X::f1;
+
+
+void (f() &&); // expected-error{{non-member function cannot have '&&' qualifier}}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp
new file mode 100644
index 0000000..e2d94fb
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef void F() const;
+
+void f() const; // expected-error {{non-member function cannot have 'const' qualifier}}
+F g; // expected-error {{non-member function of type 'F' (aka 'void () const') cannot have 'const' qualifier}}
+
+struct X {
+ void f() const;
+ friend void g() const; // expected-error {{non-member function cannot have 'const' qualifier}}
+ static void h() const; // expected-error {{static member function cannot have 'const' qualifier}}
+ F i; // ok
+ friend F j; // expected-error {{non-member function of type 'F' (aka 'void () const') cannot have 'const' qualifier}}
+ static F k; // expected-error {{static member function of type 'F' (aka 'void () const') cannot have 'const' qualifier}}
+};
+
+struct Y {
+ friend void X::f() const;
+ friend void ::f() const; // expected-error {{non-member function cannot have 'const' qualifier}}
+};
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8-0x.cpp
new file mode 100644
index 0000000..11926f1
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8-0x.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+auto f() -> int[32]; // expected-error{{function cannot return array}}
+auto g() -> int(int); // expected-error{{function cannot return function}}
+auto h() -> auto() -> int; // expected-error{{function cannot return function}}
+auto i() -> auto(*)() -> int;
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp
new file mode 100644
index 0000000..34a8c85
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A { };
+A::A (enum { e1 }) {} // expected-error{{can not be defined in a parameter}} \
+// expected-error{{out-of-line definition}}
+void A::f(enum { e2 }) {} // expected-error{{can not be defined in a parameter}} \
+// expected-error{{out-of-line definition}}
+
+enum { e3 } A::g() { } // expected-error{{can not be defined in the result type}} \
+// expected-error{{out-of-line definition}}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp
new file mode 100644
index 0000000..574a3e7
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+auto j() -> enum { e3 }; // expected-error{{unnamed enumeration must be a definition}} expected-error {{requires a specifier or qualifier}} expected-error {{without trailing return type}}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp
new file mode 100644
index 0000000..7e35788
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class A {
+public:
+ int& i;
+
+ A(int& i) : i(i) { }
+
+ static int s;
+};
+
+template<typename T> void ft(T& t) {
+ t.*&T::i = 10; // expected-error{{cannot form a pointer-to-member to member 'i' of reference type 'int &'}}
+}
+
+void f() {
+ int b;
+ A a(b);
+
+ int A::*ip = &A::s; // expected-error {{cannot initialize a variable of type 'int A::*' with an rvalue of type 'int *'}}
+ a.*&A::s = 10; // expected-error{{right hand operand to .* has non pointer-to-member type 'int *'}}
+
+ a.*&A::i = 10; // expected-error{{cannot form a pointer-to-member to member 'i' of reference type 'int &'}}
+ ft(a); // expected-note{{in instantiation of function template specialization 'ft<A>' requested here}}
+
+ void A::*p = 0; // expected-error{{'p' declared as a member pointer to void}}
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp
new file mode 100644
index 0000000..c02105c
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp
@@ -0,0 +1,145 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++ [dcl.ref]p5:
+// There shall be no references to references, no arrays of
+// references, and no pointers to references.
+
+// The crazy formatting in here is to enforce the exact report locations.
+
+typedef int &intref;
+typedef intref &intrefref;
+
+template <class T> class RefMem { // expected-warning{{class 'RefMem<int &>' does not declare any constructor to initialize its non-modifiable members}}
+ T
+ &
+ member; // expected-note{{reference member 'member' will never be initialized}}
+};
+
+struct RefRef {
+ int
+ &
+ & // expected-error {{declared as a reference to a reference}}
+ refref0;
+
+ intref
+ &
+ refref1; // collapses
+
+ intrefref
+ &
+ refref2; // collapses
+
+ RefMem
+ <
+ int
+ &
+ >
+ refref3; // collapses expected-note{{in instantiation of template class 'RefMem<int &>' requested here}}
+};
+
+
+template <class T> class PtrMem {
+ T
+ * // expected-error {{declared as a pointer to a reference}}
+ member;
+};
+
+struct RefPtr {
+ typedef
+ int
+ &
+ * // expected-error {{declared as a pointer to a reference}}
+ intrefptr;
+
+ typedef
+ intref
+ * // expected-error {{declared as a pointer to a reference}}
+ intrefptr2;
+
+ int
+ &
+ * // expected-error {{declared as a pointer to a reference}}
+ refptr0;
+
+ intref
+ * // expected-error {{declared as a pointer to a reference}}
+ refptr1;
+
+ PtrMem
+ <
+ int
+ &
+ >
+ refptr2; // expected-note {{in instantiation}}
+};
+
+template <class T> class ArrMem {
+ T
+ member
+ [ // expected-error {{declared as array of references}}
+ 10
+ ];
+};
+template <class T, unsigned N> class DepArrMem {
+ T
+ member
+ [ // expected-error {{declared as array of references}}
+ N
+ ];
+};
+
+struct RefArr {
+ typedef
+ int
+ &
+ intrefarr
+ [ // expected-error {{declared as array of references}}
+ 2
+ ];
+
+ typedef
+ intref
+ intrefarr
+ [ // expected-error {{declared as array of references}}
+ 2
+ ];
+
+ int
+ &
+ refarr0
+ [ // expected-error {{declared as array of references}}
+ 2
+ ];
+ intref
+ refarr1
+ [ // expected-error {{declared as array of references}}
+ 2
+ ];
+ ArrMem
+ <
+ int
+ &
+ >
+ refarr2; // expected-note {{in instantiation}}
+ DepArrMem
+ <
+ int
+ &,
+ 10
+ >
+ refarr3; // expected-note {{in instantiation}}
+};
+
+
+// The declaration of a reference shall contain an initializer
+// (8.5.3) except when the declaration contains an explicit extern
+// specifier (7.1.1), is a class member (9.2) declaration within a
+// class definition, or is the declaration of a parameter or a
+// return type (8.3.5); see 3.1. A reference shall be initialized to
+// refer to a valid object or function. [ Note: in particular, a
+// null reference cannot exist in a well-defined program, because
+// the only way to create such a reference would be to bind it to
+// the "object" obtained by dereferencing a null pointer, which
+// causes undefined behavior. As described in 9.6, a reference
+// cannot be bound directly to a bit-field.
+
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp
new file mode 100644
index 0000000..4ce80bc
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+#define JOIN2(X,Y) X##Y
+#define JOIN(X,Y) JOIN2(X,Y)
+#define CHECK_EQUAL_TYPES(T1, T2) \
+ int JOIN(array,__LINE__)[is_same<T1, T2>::value? 1 : -1]
+
+int i;
+typedef int& LRI;
+typedef int&& RRI;
+
+typedef LRI& r1; CHECK_EQUAL_TYPES(r1, int&);
+typedef const LRI& r2; CHECK_EQUAL_TYPES(r2, int&);
+typedef const LRI&& r3; CHECK_EQUAL_TYPES(r3, int&);
+
+typedef RRI& r4; CHECK_EQUAL_TYPES(r4, int&);
+typedef RRI&& r5; CHECK_EQUAL_TYPES(r5, int&&);
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp
new file mode 100644
index 0000000..99334b8
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// The nested-name-specifier of a qualified declarator-id shall not begin with a decltype-specifier.
+class foo {
+ static int i;
+ void func();
+};
+
+int decltype(foo())::i; // expected-error{{'decltype' cannot be used to name a declaration}}
+void decltype(foo())::func() { // expected-error{{'decltype' cannot be used to name a declaration}}
+}
+
+
+template<typename T>
+class tfoo {
+ static int i;
+ void func();
+};
+
+template<typename T>
+int decltype(tfoo<T>())::i; // expected-error{{nested name specifier 'decltype(tfoo<T>())::' for declaration does not refer into a class, class template or class template partial specialization}}
+template<typename T>
+void decltype(tfoo<T>())::func() { // expected-error{{nested name specifier 'decltype(tfoo<T>())::' for declaration does not refer into a class, class template or class template partial specialization}}
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.meaning/p1.cpp b/clang/test/CXX/dcl.decl/dcl.meaning/p1.cpp
new file mode 100644
index 0000000..3672ea0
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/p1.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR8019 {
+ struct x;
+ template<typename T> struct x2;
+ struct y {
+ struct PR8019::x { int x; }; // expected-error{{non-friend class member 'x' cannot have a qualified name}}
+
+ struct inner;
+ struct y::inner { }; // expected-warning{{extra qualification on member 'inner'}}
+
+ template<typename T>
+ struct PR8019::x2 { }; // expected-error{{non-friend class member 'x2' cannot have a qualified name}}
+
+ template<typename T>
+ struct inner_template;
+
+ template<typename T>
+ struct y::inner_template { }; // expected-warning{{extra qualification on member 'inner_template'}}
+ };
+
+}
+
+namespace NS {
+ void foo();
+ extern int bar;
+ struct X;
+ template<typename T> struct Y;
+ template<typename T> void wibble(T);
+}
+namespace NS {
+ void NS::foo() {} // expected-warning{{extra qualification on member 'foo'}}
+ int NS::bar; // expected-warning{{extra qualification on member 'bar'}}
+ struct NS::X { }; // expected-warning{{extra qualification on member 'X'}}
+ template<typename T> struct NS::Y; // expected-warning{{extra qualification on member 'Y'}}
+ template<typename T> void NS::wibble(T) { } // expected-warning{{extra qualification on member 'wibble'}}
+}
diff --git a/clang/test/CXX/dcl.decl/dcl.name/p1.cpp b/clang/test/CXX/dcl.decl/dcl.name/p1.cpp
new file mode 100644
index 0000000..9838b4f
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/dcl.name/p1.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace pr6200 {
+ struct v {};
+ enum E { e };
+ struct s {
+ int i;
+ operator struct v() { return v(); };
+ operator enum E() { return e; }
+ };
+
+ void f()
+ {
+ // None of these is a declaration.
+ (void)new struct s;
+ (void)new enum E;
+ (void)&s::operator struct v;
+ (void)&s::operator enum E;
+ }
+}
diff --git a/clang/test/CXX/dcl.decl/p4-0x.cpp b/clang/test/CXX/dcl.decl/p4-0x.cpp
new file mode 100644
index 0000000..98c33b2
--- /dev/null
+++ b/clang/test/CXX/dcl.decl/p4-0x.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct X {
+ void f() &;
+ void g() &&;
+};
+
+void (X::*pmf)() & = &X::f;
diff --git a/clang/test/CXX/except/except.handle/p16.cpp b/clang/test/CXX/except/except.handle/p16.cpp
new file mode 100644
index 0000000..0810be1
--- /dev/null
+++ b/clang/test/CXX/except/except.handle/p16.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
+
+// The object declared in an exception-declaration or, if the
+// exception-declaration does not specify a name, a temporary (12.2)
+// is copy-initialized (8.5) from the exception object.
+//
+template<typename T>
+class X {
+ T* ptr;
+
+public:
+ X(const X<T> &) {
+ int *ip = 0;
+ ptr = ip; // expected-error{{assigning to 'float *' from incompatible type 'int *'}}
+ }
+
+ ~X() {
+ float *fp = 0;
+ ptr = fp; // expected-error{{assigning to 'int *' from incompatible type 'float *'}}
+ }
+};
+
+void f() {
+ try {
+ } catch (X<float>) { // expected-note{{instantiation}}
+ // copy constructor
+ } catch (X<int> xi) { // expected-note{{instantiation}}
+ // destructor
+ }
+}
+
+struct Abstract {
+ virtual void f() = 0; // expected-note{{pure virtual}}
+};
+
+void g() {
+ try {
+ } catch (Abstract) { // expected-error{{variable type 'Abstract' is an abstract class}}
+ }
+}
diff --git a/clang/test/CXX/except/except.spec/canonical.cpp b/clang/test/CXX/except/except.spec/canonical.cpp
new file mode 100644
index 0000000..81ca2ae
--- /dev/null
+++ b/clang/test/CXX/except/except.spec/canonical.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// PR10087: Make sure that we don't conflate exception specifications
+// from different functions in the canonical type system.
+namespace std
+{
+
+template <class _Tp> _Tp&& declval() noexcept;
+
+template <class _Tp, class... _Args>
+struct __is_nothrow_constructible
+{
+ static const bool value = noexcept(_Tp(declval<_Args>()...));
+};
+
+template<class, class _Traits, class _Allocator>
+class basic_string
+{
+public:
+ typedef typename _Traits::char_type value_type;
+ typedef _Allocator allocator_type;
+
+ basic_string()
+ noexcept(__is_nothrow_constructible<allocator_type>::value);
+};
+
+template <class, class, class _Compare>
+struct __map_value_compare
+{
+public:
+ __map_value_compare()
+ noexcept(__is_nothrow_constructible<_Compare>::value);
+};
+
+struct less
+{
+};
+
+struct map
+{
+ typedef __map_value_compare<int, short, less> __vc;
+ __vc vc_;
+};
+
+
+template<class T, class _Traits, class _Allocator>
+basic_string<T, _Traits, _Allocator>::basic_string() noexcept(__is_nothrow_constructible<allocator_type>::value) {}
+
+template <class T, class Value, class _Compare>
+__map_value_compare<T, Value, _Compare>::__map_value_compare()
+ noexcept(__is_nothrow_constructible<_Compare>::value) {}
+
+} // std
diff --git a/clang/test/CXX/except/except.spec/p1.cpp b/clang/test/CXX/except/except.spec/p1.cpp
new file mode 100644
index 0000000..e184ec4
--- /dev/null
+++ b/clang/test/CXX/except/except.spec/p1.cpp
@@ -0,0 +1,81 @@
+// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+
+// Simple parser tests, dynamic specification.
+
+namespace dyn {
+
+ struct X { };
+
+ struct Y { };
+
+ void f() throw() { }
+
+ void g(int) throw(X) { }
+
+ void h() throw(X, Y) { }
+
+ class Class {
+ void foo() throw (X, Y) { }
+ };
+
+ void (*fptr)() throw();
+
+}
+
+// Simple parser tests, noexcept specification.
+
+namespace noex {
+
+ void f1() noexcept { }
+ void f2() noexcept (true) { }
+ void f3() noexcept (false) { }
+ void f4() noexcept (1 < 2) { }
+
+ class CA1 {
+ void foo() noexcept { }
+ void bar() noexcept (true) { }
+ };
+
+ void (*fptr1)() noexcept;
+ void (*fptr2)() noexcept (true);
+
+}
+
+namespace mix {
+
+ void f() throw(int) noexcept { } // expected-error {{cannot have both}}
+ void g() noexcept throw(int) { } // expected-error {{cannot have both}}
+
+}
+
+// Sema tests, noexcept specification
+
+namespace noex {
+
+ struct A {};
+
+ void g1() noexcept(A()); // expected-error {{not contextually convertible}}
+ void g2(bool b) noexcept(b); // expected-error {{argument to noexcept specifier must be a constant expression}}
+
+}
+
+namespace noexcept_unevaluated {
+ template<typename T> bool f(T) {
+ T* x = 1;
+ }
+
+ template<typename T>
+ void g(T x) noexcept((sizeof(T) == sizeof(int)) || noexcept(f(x))) { }
+
+ void h() {
+ g(1);
+ }
+}
+
+namespace PR11084 {
+ template<int X> struct A {
+ static int f() noexcept(1/X) { return 10; } // expected-error{{argument to noexcept specifier must be a constant expression}} expected-note{{division by zero}}
+ };
+
+ void g() { A<0>::f(); } // expected-note{{in instantiation of exception specification for 'f' requested here}}
+}
diff --git a/clang/test/CXX/except/except.spec/p11.cpp b/clang/test/CXX/except/except.spec/p11.cpp
new file mode 100644
index 0000000..0e4fad5
--- /dev/null
+++ b/clang/test/CXX/except/except.spec/p11.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+
+// This is the "let the user shoot himself in the foot" clause.
+void f() noexcept {
+ throw 0; // no-error
+}
+void g() throw() {
+ throw 0; // no-error
+}
+void h() throw(int) {
+ throw 0.0; // no-error
+}
diff --git a/clang/test/CXX/except/except.spec/p14-ir.cpp b/clang/test/CXX/except/except.spec/p14-ir.cpp
new file mode 100644
index 0000000..81fbf7d
--- /dev/null
+++ b/clang/test/CXX/except/except.spec/p14-ir.cpp
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fexceptions -o - %s | FileCheck %s
+
+// Copy constructor
+struct X0 {
+ X0();
+ X0(const X0 &) throw();
+ X0(X0 &);
+};
+
+struct X1 {
+ X1();
+ X1(const X1 &) throw();
+};
+
+struct X2 : X1 {
+ X2();
+};
+struct X3 : X0, X1 {
+ X3();
+};
+
+struct X4 {
+ X4(X4 &) throw();
+};
+
+struct X5 : X0, X4 { };
+
+void test(X2 x2, X3 x3, X5 x5) {
+ // CHECK: define linkonce_odr void @_ZN2X2C1ERKS_(%struct.X2* %this, %struct.X2*) unnamed_addr
+ // CHECK: call void @_ZN2X2C2ERKS_({{.*}}) nounwind
+ // CHECK-NEXT: ret void
+ // CHECK-NEXT: }
+ X2 x2a(x2);
+ // CHECK: define linkonce_odr void @_ZN2X3C1ERKS_(%struct.X3* %this, %struct.X3*) unnamed_addr
+ // CHECK: call void @_ZN2X3C2ERKS_({{.*}}) nounwind
+ // CHECK-NEXT: ret void
+ // CHECK-NEXT: }
+ X3 x3a(x3);
+ // CHECK: define linkonce_odr void @_ZN2X5C1ERS_({{.*}}) unnamed_addr
+ // CHECK-NOT: call void @__cxa_call_unexpected
+ // CHECK: ret void
+ X5 x5a(x5);
+}
+
+// Default constructor
+struct X6 {
+ X6() throw();
+};
+
+struct X7 {
+ X7();
+};
+
+struct X8 : X6 { };
+struct X9 : X6, X7 { };
+
+void test() {
+ // CHECK: define linkonce_odr void @_ZN2X8C1Ev(%struct.X8* %this) unnamed_addr
+ // CHECK: call void @_ZN2X8C2Ev({{.*}}) nounwind
+ // CHECK-NEXT: ret void
+ X8();
+
+ // CHECK: define linkonce_odr void @_ZN2X9C1Ev(%struct.X9* %this) unnamed_addr
+ // FIXME: check that this is the end of the line here:
+ // CHECK: call void @_ZN2X9C2Ev({{.*}})
+ // CHECK-NEXT: ret void
+ X9();
+
+ // CHECK: define linkonce_odr void @_ZN2X9C2Ev(%struct.X9* %this) unnamed_addr
+ // CHECK: call void @_ZN2X6C2Ev({{.*}}) nounwind
+ // FIXME: and here:
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: call void @_ZN2X7C2Ev({{.*}})
+ // CHECK: ret void
+
+ // CHECK: define linkonce_odr void @_ZN2X8C2Ev(%struct.X8* %this) unnamed_addr
+ // CHECK: call void @_ZN2X6C2Ev({{.*}}) nounwind
+ // CHECK-NEXT: ret void
+}
diff --git a/clang/test/CXX/except/except.spec/p14.cpp b/clang/test/CXX/except/except.spec/p14.cpp
new file mode 100644
index 0000000..8763a70
--- /dev/null
+++ b/clang/test/CXX/except/except.spec/p14.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -verify -std=c++11 %s
+struct A { };
+struct B { };
+struct C { };
+
+// Destructor
+struct X0 {
+ virtual ~X0() throw(A); // expected-note{{overridden virtual function is here}}
+};
+struct X1 {
+ virtual ~X1() throw(B); // expected-note{{overridden virtual function is here}}
+};
+struct X2 : public X0, public X1 { }; // expected-error 2{{exception specification of overriding function is more lax than base version}}
+
+// Copy-assignment operator.
+struct CA0 {
+ CA0 &operator=(const CA0&) throw(A);
+};
+struct CA1 {
+ CA1 &operator=(const CA1&) throw(B);
+};
+struct CA2 : CA0, CA1 { };
+
+void test_CA() {
+ CA2 &(CA2::*captr1)(const CA2&) throw(A, B) = &CA2::operator=;
+ CA2 &(CA2::*captr2)(const CA2&) throw(A, B, C) = &CA2::operator=;
+ CA2 &(CA2::*captr3)(const CA2&) throw(A) = &CA2::operator=; // expected-error{{target exception specification is not superset of source}}
+ CA2 &(CA2::*captr4)(const CA2&) throw(B) = &CA2::operator=; // expected-error{{target exception specification is not superset of source}}
+}
+
+// In-class member initializers.
+struct IC0 {
+ int inClassInit = 0;
+};
+struct IC1 {
+ int inClassInit = (throw B(), 0);
+};
+// FIXME: the exception specification on the default constructor is wrong:
+// we cannot currently compute the set of thrown types.
+static_assert(noexcept(IC0()), "IC0() does not throw");
+static_assert(!noexcept(IC1()), "IC1() throws");
diff --git a/clang/test/CXX/except/except.spec/p15.cpp b/clang/test/CXX/except/except.spec/p15.cpp
new file mode 100644
index 0000000..110ec3f
--- /dev/null
+++ b/clang/test/CXX/except/except.spec/p15.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+
+// Deallocation functions are implicitly noexcept.
+// Thus, explicit specs aren't allowed to conflict.
+
+void f() {
+ // Force implicit declaration of delete.
+ delete new int;
+ delete[] new int[1];
+}
+
+void operator delete(void*) noexcept;
+void operator delete[](void*) noexcept;
+
+// Same goes for explicit declarations.
+void operator delete(void*, float);
+void operator delete(void*, float) noexcept;
+
+void operator delete[](void*, float);
+void operator delete[](void*, float) noexcept;
+
+// But explicit specs stay.
+void operator delete(void*, double) throw(int); // expected-note {{previous}}
+void operator delete(void*, double) noexcept; // expected-error {{does not match}}
diff --git a/clang/test/CXX/except/except.spec/p2-dynamic-types.cpp b/clang/test/CXX/except/except.spec/p2-dynamic-types.cpp
new file mode 100644
index 0000000..57f8c32
--- /dev/null
+++ b/clang/test/CXX/except/except.spec/p2-dynamic-types.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+
+// Dynamic specifications: valid types.
+
+struct Incomplete; // expected-note 3 {{forward declaration}}
+
+// Exception spec must not have incomplete types, or pointers to them, except
+// void.
+void ic1() throw(void); // expected-error {{incomplete type 'void' is not allowed in exception specification}}
+void ic2() throw(Incomplete); // expected-error {{incomplete type 'Incomplete' is not allowed in exception specification}}
+void ic3() throw(void*);
+void ic4() throw(Incomplete*); // expected-error {{pointer to incomplete type 'Incomplete' is not allowed in exception specification}}
+void ic5() throw(Incomplete&); // expected-error {{reference to incomplete type 'Incomplete' is not allowed in exception specification}}
+
+// Don't suppress errors in template instantiation.
+template <typename T> struct TEx; // expected-note {{template is declared here}}
+
+void tf() throw(TEx<int>); // expected-error {{implicit instantiation of undefined template}}
+
+// DR 437, class throws itself.
+struct DR437 {
+ void f() throw(DR437);
+ void g() throw(DR437*);
+ void h() throw(DR437&);
+};
+
+// DR 437 within a nested class
+struct DR437_out {
+ struct DR437_in {
+ void f() throw(DR437_out);
+ void g() throw(DR437_out*);
+ void h() throw(DR437_out&);
+ };
+};
diff --git a/clang/test/CXX/except/except.spec/p2-places.cpp b/clang/test/CXX/except/except.spec/p2-places.cpp
new file mode 100644
index 0000000..67647fb
--- /dev/null
+++ b/clang/test/CXX/except/except.spec/p2-places.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+
+// Tests where specs are allowed and where they aren't.
+
+namespace dyn {
+
+ // Straight from the standard:
+
+ // Plain function with spec
+ void f() throw(int);
+
+ // Pointer to function with spec
+ void (*fp)() throw (int);
+
+ // Function taking reference to function with spec
+ void g(void pfa() throw(int));
+
+ // Typedef for pointer to function with spec
+ typedef int (*pf)() throw(int); // expected-error {{specifications are not allowed in typedefs}}
+
+ // Some more:
+
+ // Function returning function with spec
+ void (*h())() throw(int);
+
+ // Ultimate parser thrill: function with spec returning function with spec and
+ // taking pointer to function with spec.
+ // The actual function throws int, the return type double, the argument float.
+ void (*i() throw(int))(void (*)() throw(float)) throw(double);
+
+ // Pointer to pointer to function taking function with spec
+ void (**k)(void pfa() throw(int)); // no-error
+
+ // Pointer to pointer to function with spec
+ void (**j)() throw(int); // expected-error {{not allowed beyond a single}}
+
+ // Pointer to function returning pointer to pointer to function with spec
+ void (**(*h())())() throw(int); // expected-error {{not allowed beyond a single}}
+
+}
+
+namespace noex {
+
+ // These parallel those from above.
+
+ void f() noexcept(false);
+
+ void (*fp)() noexcept(false);
+
+ void g(void pfa() noexcept(false));
+
+ typedef int (*pf)() noexcept(false); // expected-error {{specifications are not allowed in typedefs}}
+
+ void (*h())() noexcept(false);
+
+ void (*i() noexcept(false))(void (*)() noexcept(true)) noexcept(false);
+
+ void (**k)(void pfa() noexcept(false)); // no-error
+
+ void (**j)() noexcept(false); // expected-error {{not allowed beyond a single}}
+
+ void (**(*h())())() noexcept(false); // expected-error {{not allowed beyond a single}}
+}
diff --git a/clang/test/CXX/except/except.spec/p3.cpp b/clang/test/CXX/except/except.spec/p3.cpp
new file mode 100644
index 0000000..d77aea4
--- /dev/null
+++ b/clang/test/CXX/except/except.spec/p3.cpp
@@ -0,0 +1,106 @@
+// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+
+// Exception specification compatibility.
+// We test function pointers, because functions have an extra rule in p4.
+
+// Same type is compatible
+extern void (*r1)() throw(int);
+extern void (*r1)() throw(int);
+
+// Typedefs don't matter.
+typedef int INT;
+extern void (*r2)() throw(int);
+extern void (*r2)() throw(INT);
+
+// Order doesn't matter.
+extern void (*r3)() throw(int, float);
+extern void (*r3)() throw(float, int);
+
+// MS throw-any spec and no spec at all are compatible
+extern void (*r4)();
+extern void (*r4)() throw(...);
+
+// throw(X) and no spec are not compatible
+extern void (*r5)() throw(int); // expected-note {{previous declaration}}
+extern void (*r5)(); // expected-error {{exception specification in declaration does not match}}
+
+// For functions, we accept this with a warning.
+extern void f5() throw(int); // expected-note {{previous declaration}}
+extern void f5(); // expected-warning {{missing exception specification}}
+
+// Different types are not compatible.
+extern void (*r7)() throw(int); // expected-note {{previous declaration}}
+extern void (*r7)() throw(float); // expected-error {{exception specification in declaration does not match}}
+
+// Top-level const doesn't matter.
+extern void (*r8)() throw(int);
+extern void (*r8)() throw(const int);
+
+// Multiple appearances don't matter.
+extern void (*r9)() throw(int, int);
+extern void (*r9)() throw(int, int);
+
+
+// noexcept is compatible with itself
+extern void (*r10)() noexcept;
+extern void (*r10)() noexcept;
+
+// noexcept(true) is compatible with noexcept
+extern void (*r11)() noexcept;
+extern void (*r11)() noexcept(true);
+
+// noexcept(false) isn't
+extern void (*r12)() noexcept; // expected-note {{previous declaration}}
+extern void (*r12)() noexcept(false); // expected-error {{does not match}}
+
+// The form of the boolean expression doesn't matter.
+extern void (*r13)() noexcept(1 < 2);
+extern void (*r13)() noexcept(2 > 1);
+
+// noexcept(false) is incompatible with noexcept(true)
+extern void (*r14)() noexcept(true); // expected-note {{previous declaration}}
+extern void (*r14)() noexcept(false); // expected-error {{does not match}}
+
+// noexcept(false) is compatible with itself
+extern void (*r15)() noexcept(false);
+extern void (*r15)() noexcept(false);
+
+// noexcept(false) is compatible with MS throw(...)
+extern void (*r16)() noexcept(false);
+extern void (*r16)() throw(...);
+
+// noexcept(false) is *not* compatible with no spec
+extern void (*r17)(); // expected-note {{previous declaration}}
+extern void (*r17)() noexcept(false); // expected-error {{does not match}}
+
+// except for functions
+void f17();
+void f17() noexcept(false);
+
+// noexcept(false) is compatible with dynamic specs that throw unless
+// CWG 1073 resolution is accepted. Clang implements it.
+//extern void (*r18)() throw(int);
+//extern void (*r18)() noexcept(false);
+
+// noexcept(true) is compatible with dynamic specs that don't throw
+extern void (*r19)() throw();
+extern void (*r19)() noexcept(true);
+
+// The other way round doesn't work.
+extern void (*r20)() throw(); // expected-note {{previous declaration}}
+extern void (*r20)() noexcept(false); // expected-error {{does not match}}
+
+extern void (*r21)() throw(int); // expected-note {{previous declaration}}
+extern void (*r21)() noexcept(true); // expected-error {{does not match}}
+
+
+// As a very special workaround, we allow operator new to match no spec
+// with a throw(bad_alloc) spec, because C++0x makes an incompatible change
+// here.
+extern "C++" { namespace std { class bad_alloc {}; } }
+typedef decltype(sizeof(int)) mysize_t;
+void* operator new(mysize_t) throw(std::bad_alloc);
+void* operator new(mysize_t);
+void* operator new[](mysize_t);
+void* operator new[](mysize_t) throw(std::bad_alloc);
+
diff --git a/clang/test/CXX/except/except.spec/p5-pointers.cpp b/clang/test/CXX/except/except.spec/p5-pointers.cpp
new file mode 100644
index 0000000..dd3c060
--- /dev/null
+++ b/clang/test/CXX/except/except.spec/p5-pointers.cpp
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+
+// Assignment of function pointers.
+
+struct A
+{
+};
+
+struct B1 : A
+{
+};
+
+struct B2 : A
+{
+};
+
+struct D : B1, B2
+{
+};
+
+struct P : private A
+{
+};
+
+// Some functions to play with below.
+void s1() throw();
+void s2() throw(int);
+void s3() throw(A);
+void s4() throw(B1);
+void s5() throw(D);
+void s6();
+void s7() throw(int, float);
+void (*s8())() throw(B1); // s8 returns a pointer to function with spec
+void s9(void (*)() throw(B1)); // s9 takes pointer to function with spec
+
+void s10() noexcept;
+void s11() noexcept(true);
+void s12() noexcept(false);
+
+void fnptrs()
+{
+ // Assignment and initialization of function pointers.
+ void (*t1)() throw() = &s1; // valid
+ t1 = &s2; // expected-error {{not superset}} expected-error {{incompatible type}}
+ t1 = &s3; // expected-error {{not superset}} expected-error {{incompatible type}}
+ void (&t2)() throw() = s2; // expected-error {{not superset}}
+ void (*t3)() throw(int) = &s2; // valid
+ void (*t4)() throw(A) = &s1; // valid
+ t4 = &s3; // valid
+ t4 = &s4; // valid
+ t4 = &s5; // expected-error {{not superset}} expected-error {{incompatible type}}
+ void (*t5)() = &s1; // valid
+ t5 = &s2; // valid
+ t5 = &s6; // valid
+ t5 = &s7; // valid
+ t1 = t3; // expected-error {{not superset}} expected-error {{incompatible type}}
+ t3 = t1; // valid
+ void (*t6)() throw(B1);
+ t6 = t4; // expected-error {{not superset}} expected-error {{incompatible type}}
+ t4 = t6; // valid
+ t5 = t1; // valid
+ t1 = t5; // expected-error {{not superset}} expected-error {{incompatible type}}
+
+ // return types and arguments must match exactly, no inheritance allowed
+ void (*(*t7)())() throw(B1) = &s8; // valid
+ void (*(*t8)())() throw(A) = &s8; // expected-error {{return types differ}}
+ void (*(*t9)())() throw(D) = &s8; // expected-error {{return types differ}}
+ void (*t10)(void (*)() throw(B1)) = &s9; // valid expected-warning{{disambiguated}}
+ void (*t11)(void (*)() throw(A)) = &s9; // expected-error {{argument types differ}} expected-warning{{disambiguated}}
+ void (*t12)(void (*)() throw(D)) = &s9; // expected-error {{argument types differ}} expected-warning{{disambiguated}}
+}
+
+// Member function stuff
+
+struct Str1 { void f() throw(int); }; // expected-note {{previous declaration}}
+void Str1::f() // expected-warning {{missing exception specification}}
+{
+}
+
+void mfnptr()
+{
+ void (Str1::*pfn1)() throw(int) = &Str1::f; // valid
+ void (Str1::*pfn2)() = &Str1::f; // valid
+ void (Str1::*pfn3)() throw() = &Str1::f; // expected-error {{not superset}}
+}
diff --git a/clang/test/CXX/except/except.spec/p5-virtual.cpp b/clang/test/CXX/except/except.spec/p5-virtual.cpp
new file mode 100644
index 0000000..69daec6
--- /dev/null
+++ b/clang/test/CXX/except/except.spec/p5-virtual.cpp
@@ -0,0 +1,96 @@
+// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+
+// Compatibility of virtual functions.
+
+struct A
+{
+};
+
+struct B1 : A
+{
+};
+
+struct B2 : A
+{
+};
+
+struct D : B1, B2
+{
+};
+
+struct P : private A
+{
+};
+
+struct Base
+{
+ virtual void f1() throw();
+ virtual void f2() throw(int, float);
+
+ virtual void f3() throw(int, float);
+ virtual void f4() throw(A);
+ virtual void f5() throw(A, int, float);
+ virtual void f6();
+
+ virtual void f7() noexcept;
+ virtual void f8() noexcept;
+ virtual void f9() noexcept(false);
+ virtual void f10() noexcept(false);
+
+ virtual void f11() throw();
+ virtual void f12() noexcept;
+ virtual void f13() noexcept(false);
+ virtual void f14() throw(int);
+
+ virtual void f15();
+ virtual void f16();
+
+ virtual void g1() throw(); // expected-note {{overridden virtual function is here}}
+ virtual void g2() throw(int); // expected-note {{overridden virtual function is here}}
+ virtual void g3() throw(A); // expected-note {{overridden virtual function is here}}
+ virtual void g4() throw(B1); // expected-note {{overridden virtual function is here}}
+ virtual void g5() throw(A); // expected-note {{overridden virtual function is here}}
+
+ virtual void g6() noexcept; // expected-note {{overridden virtual function is here}}
+ virtual void g7() noexcept; // expected-note {{overridden virtual function is here}}
+
+ virtual void g8() noexcept; // expected-note {{overridden virtual function is here}}
+ virtual void g9() throw(); // expected-note {{overridden virtual function is here}}
+ virtual void g10() throw(int); // expected-note {{overridden virtual function is here}}
+};
+struct Derived : Base
+{
+ virtual void f1() throw();
+ virtual void f2() throw(float, int);
+
+ virtual void f3() throw(float);
+ virtual void f4() throw(B1);
+ virtual void f5() throw(B1, B2, int);
+ virtual void f6() throw(B2, B2, int, float, char, double, bool);
+
+ virtual void f7() noexcept;
+ virtual void f8() noexcept(true);
+ virtual void f9() noexcept(true);
+ virtual void f10() noexcept(false);
+
+ virtual void f11() noexcept;
+ virtual void f12() throw();
+ virtual void f13() throw(int);
+ virtual void f14() noexcept(true);
+
+ virtual void f15() noexcept;
+ virtual void f16() throw();
+
+ virtual void g1() throw(int); // expected-error {{exception specification of overriding function is more lax}}
+ virtual void g2(); // expected-error {{exception specification of overriding function is more lax}}
+ virtual void g3() throw(D); // expected-error {{exception specification of overriding function is more lax}}
+ virtual void g4() throw(A); // expected-error {{exception specification of overriding function is more lax}}
+ virtual void g5() throw(P); // expected-error {{exception specification of overriding function is more lax}}
+
+ virtual void g6() noexcept(false); // expected-error {{exception specification of overriding function is more lax}}
+ virtual void g7(); // expected-error {{exception specification of overriding function is more lax}}
+
+ virtual void g8() throw(int); // expected-error {{exception specification of overriding function is more lax}}
+ virtual void g9() noexcept(false); // expected-error {{exception specification of overriding function is more lax}}
+ virtual void g10() noexcept(false); // expected-error {{exception specification of overriding function is more lax}}
+};
diff --git a/clang/test/CXX/except/except.spec/p9-dynamic.cpp b/clang/test/CXX/except/except.spec/p9-dynamic.cpp
new file mode 100644
index 0000000..4559e0d
--- /dev/null
+++ b/clang/test/CXX/except/except.spec/p9-dynamic.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s
+
+void external();
+
+void target() throw(int)
+{
+ // CHECK: invoke void @_Z8externalv()
+ external();
+}
+// CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+// CHECK-NEXT: filter [1 x i8*] [i8* bitcast (i8** @_ZTIi to i8*)]
+// CHECK: call void @__cxa_call_unexpected
diff --git a/clang/test/CXX/except/except.spec/p9-noexcept.cpp b/clang/test/CXX/except/except.spec/p9-noexcept.cpp
new file mode 100644
index 0000000..7c8d0ef
--- /dev/null
+++ b/clang/test/CXX/except/except.spec/p9-noexcept.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s
+
+void external();
+
+void target() noexcept
+{
+ // CHECK: invoke void @_Z8externalv()
+ external();
+}
+// CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+// CHECK-NEXT: catch i8* null
+// CHECK-NEXT: call void @_ZSt9terminatev() noreturn nounwind
+// CHECK-NEXT: unreachable
+
+void reverse() noexcept(false)
+{
+ // CHECK: call void @_Z8externalv()
+ external();
+}
diff --git a/clang/test/CXX/except/except.spec/template.cpp b/clang/test/CXX/except/except.spec/template.cpp
new file mode 100644
index 0000000..805a604
--- /dev/null
+++ b/clang/test/CXX/except/except.spec/template.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+
+// We use pointer assignment compatibility to test instantiation.
+
+template <int N> void f1() throw(int);
+template <int N> void f2() noexcept(N > 1);
+
+void (*t1)() throw(int) = &f1<0>;
+void (*t2)() throw() = &f1<0>; // expected-error {{not superset}}
+
+void (*t3)() noexcept = &f2<2>; // no-error
+void (*t4)() noexcept = &f2<0>; // expected-error {{not superset}}
diff --git a/clang/test/CXX/expr/expr.ass/p9-cxx11.cpp b/clang/test/CXX/expr/expr.ass/p9-cxx11.cpp
new file mode 100644
index 0000000..206c82c
--- /dev/null
+++ b/clang/test/CXX/expr/expr.ass/p9-cxx11.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+template<typename T> struct complex {
+ complex(T = T(), T = T());
+ void operator+=(complex);
+ T a, b;
+};
+
+void std_example() {
+ complex<double> z;
+ z = { 1, 2 };
+ z += { 1, 2 };
+
+ int a, b;
+ a = b = { 1 };
+ a = { 1 } = b; // expected-error {{initializer list cannot be used on the left hand side of operator '='}}
+ a = a + { 4 }; // expected-error {{initializer list cannot be used on the right hand side of operator '+'}}
+ a = { 3 } * { 4 }; // expected-error {{initializer list cannot be used on the left hand side of operator '*'}} \
+ expected-error {{initializer list cannot be used on the right hand side of operator '*'}}
+}
+
+struct S {
+ constexpr S(int a, int b) : a(a), b(b) {}
+ int a, b;
+};
+struct T {
+ constexpr int operator=(S s) { return s.a; }
+ constexpr int operator+=(S s) { return s.b; }
+};
+static_assert((T() = {4, 9}) == 4, "");
+static_assert((T() += {4, 9}) == 9, "");
+
+int k1 = T() = { 1, 2 } = { 3, 4 }; // expected-error {{initializer list cannot be used on the left hand side of operator '='}}
+int k2 = T() = { 1, 2 } + 1; // expected-error {{initializer list cannot be used on the left hand side of operator '+'}}
diff --git a/clang/test/CXX/expr/expr.cast/p4-0x.cpp b/clang/test/CXX/expr/expr.cast/p4-0x.cpp
new file mode 100644
index 0000000..96bf5f9
--- /dev/null
+++ b/clang/test/CXX/expr/expr.cast/p4-0x.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct X { };
+struct Y : X { };
+
+void test_lvalue_to_rvalue_drop_cvquals(const X &x, const Y &y, const int &i) {
+ (void)(X&&)x;
+ (void)(int&&)i;
+ (void)(X&&)y;
+ (void)(Y&&)x;
+}
diff --git a/clang/test/CXX/expr/expr.cast/p4.cpp b/clang/test/CXX/expr/expr.cast/p4.cpp
new file mode 100644
index 0000000..907e008
--- /dev/null
+++ b/clang/test/CXX/expr/expr.cast/p4.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -ast-dump %s | FileCheck %s
+
+struct A { int x; };
+struct B { int y; };
+struct C : A, B { };
+
+// CHECK: casting_away_constness
+void casting_away_constness(const B &b, const C &c, const B *bp, const C *cp) {
+ // CHECK: DerivedToBase (B)
+ // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'c'
+ (void)(B&)c;
+ // CHECK: BaseToDerived (B)
+ // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'b'
+ (void)(C&)b;
+ // CHECK: DerivedToBase (B)
+ // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'cp'
+ (void)(B*)cp;
+ // CHECK: BaseToDerived (B)
+ // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'bp'
+ (void)(C*)bp;
+ // CHECK: ReturnStmt
+ return;
+}
diff --git a/clang/test/CXX/expr/expr.const/p2-0x.cpp b/clang/test/CXX/expr/expr.const/p2-0x.cpp
new file mode 100644
index 0000000..054669e
--- /dev/null
+++ b/clang/test/CXX/expr/expr.const/p2-0x.cpp
@@ -0,0 +1,596 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -pedantic -verify -fcxx-exceptions %s -fconstexpr-depth 128 -triple i686-pc-linux-gnu
+
+// A conditional-expression is a core constant expression unless it involves one
+// of the following as a potentially evaluated subexpression [...]:
+
+// - this (5.1.1 [expr.prim.general]) [Note: when evaluating a constant
+// expression, function invocation substitution (7.1.5 [dcl.constexpr])
+// replaces each occurrence of this in a constexpr member function with a
+// pointer to the class object. -end note];
+struct This {
+ int this1 : this1; // expected-error {{undeclared}}
+ int this2 : this->this1; // expected-error {{invalid}}
+ void this3() {
+ int n1[this->this1]; // expected-warning {{variable length array}}
+ int n2[this1]; // expected-warning {{variable length array}}
+ (void)n1, (void)n2;
+ }
+};
+
+// - an invocation of a function other than a constexpr constructor for a
+// literal class or a constexpr function [ Note: Overload resolution (13.3)
+// is applied as usual - end note ];
+struct NonConstexpr1 {
+ static int f() { return 1; } // expected-note {{here}}
+ int n : f(); // expected-error {{constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}}
+};
+struct NonConstexpr2 {
+ constexpr NonConstexpr2(); // expected-note {{here}}
+ int n;
+};
+struct NonConstexpr3 {
+ NonConstexpr3();
+ int m : NonConstexpr2().n; // expected-error {{constant expression}} expected-note {{undefined constructor 'NonConstexpr2'}}
+};
+struct NonConstexpr4 {
+ NonConstexpr4(); // expected-note {{declared here}}
+ int n;
+};
+struct NonConstexpr5 {
+ int n : NonConstexpr4().n; // expected-error {{constant expression}} expected-note {{non-constexpr constructor 'NonConstexpr4' cannot be used in a constant expression}}
+};
+
+// - an invocation of an undefined constexpr function or an undefined
+// constexpr constructor;
+struct UndefinedConstexpr {
+ constexpr UndefinedConstexpr();
+ static constexpr int undefinedConstexpr1(); // expected-note {{here}}
+ int undefinedConstexpr2 : undefinedConstexpr1(); // expected-error {{constant expression}} expected-note {{undefined function 'undefinedConstexpr1' cannot be used in a constant expression}}
+};
+
+// - an invocation of a constexpr function with arguments that, when substituted
+// by function invocation substitution (7.1.5), do not produce a core constant
+// expression;
+namespace NonConstExprReturn {
+ static constexpr const int &id_ref(const int &n) {
+ return n;
+ }
+ struct NonConstExprFunction {
+ int n : id_ref(16); // ok
+ };
+ constexpr const int *address_of(const int &a) {
+ return &a;
+ }
+ constexpr const int *return_param(int n) { // expected-note {{declared here}}
+ return address_of(n);
+ }
+ struct S {
+ int n : *return_param(0); // expected-error {{constant expression}} expected-note {{read of variable whose lifetime has ended}}
+ };
+}
+
+// - an invocation of a constexpr constructor with arguments that, when
+// substituted by function invocation substitution (7.1.5), do not produce all
+// constant expressions for the constructor calls and full-expressions in the
+// mem-initializers (including conversions);
+namespace NonConstExprCtor {
+ struct T {
+ constexpr T(const int &r) :
+ r(r) {
+ }
+ const int &r;
+ };
+ constexpr int n = 0;
+ constexpr T t1(n); // ok
+ constexpr T t2(0); // expected-error {{must be initialized by a constant expression}} expected-note {{temporary created here}} expected-note {{reference to temporary is not a constant expression}}
+
+ struct S {
+ int n : T(4).r; // ok
+ };
+}
+
+// - an invocation of a constexpr function or a constexpr constructor that would
+// exceed the implementation-defined recursion limits (see Annex B);
+namespace RecursionLimits {
+ constexpr int RecurseForever(int n) {
+ return n + RecurseForever(n+1); // expected-note {{constexpr evaluation exceeded maximum depth of 128 calls}} expected-note 9{{in call to 'RecurseForever(}} expected-note {{skipping 118 calls}}
+ }
+ struct AlsoRecurseForever {
+ constexpr AlsoRecurseForever(int n) :
+ n(AlsoRecurseForever(n+1).n) // expected-note {{constexpr evaluation exceeded maximum depth of 128 calls}} expected-note 9{{in call to 'AlsoRecurseForever(}} expected-note {{skipping 118 calls}}
+ {}
+ int n;
+ };
+ struct S {
+ int k : RecurseForever(0); // expected-error {{constant expression}} expected-note {{in call to}}
+ int l : AlsoRecurseForever(0).n; // expected-error {{constant expression}} expected-note {{in call to}}
+ };
+}
+
+// DR1458: taking the address of an object of incomplete class type
+namespace IncompleteClassTypeAddr {
+ struct S;
+ extern S s;
+ constexpr S *p = &s; // ok
+ static_assert(p, "");
+
+ extern S sArr[];
+ constexpr S (*p2)[] = &sArr; // ok
+
+ struct S {
+ constexpr S *operator&() { return nullptr; }
+ };
+ constexpr S *q = &s; // ok
+ static_assert(!q, "");
+}
+
+// - an operation that would have undefined behavior [Note: including, for
+// example, signed integer overflow (Clause 5 [expr]), certain pointer
+// arithmetic (5.7 [expr.add]), division by zero (5.6 [expr.mul]), or certain
+// shift operations (5.8 [expr.shift]) -end note];
+namespace UndefinedBehavior {
+ void f(int n) {
+ switch (n) {
+ case (int)4.4e9: // expected-error {{constant expression}} expected-note {{value 4.4E+9 is outside the range of representable values of type 'int'}}
+ case (int)0x80000000u: // ok
+ case (int)10000000000ll: // expected-note {{here}}
+ case (unsigned int)10000000000ll: // expected-error {{duplicate case value}}
+ case (int)(unsigned)(long long)4.4e9: // ok
+ case (int)(float)1e300: // expected-error {{constant expression}} expected-note {{value 1.0E+300 is outside the range of representable values of type 'float'}}
+ case (int)((float)1e37 / 1e30): // ok
+ case (int)(__fp16)65536: // expected-error {{constant expression}} expected-note {{value 65536 is outside the range of representable values of type 'half'}}
+ break;
+ }
+ }
+
+ constexpr int int_min = ~0x7fffffff;
+ constexpr int minus_int_min = -int_min; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}}
+ constexpr int div0 = 3 / 0; // expected-error {{constant expression}} expected-note {{division by zero}} expected-warning {{undefined}}
+ constexpr int mod0 = 3 % 0; // expected-error {{constant expression}} expected-note {{division by zero}} expected-warning {{undefined}}
+ constexpr int int_min_div_minus_1 = int_min / -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}}
+ constexpr int int_min_mod_minus_1 = int_min % -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}}
+
+ constexpr int shl_m1 = 0 << -1; // expected-error {{constant expression}} expected-note {{negative shift count -1}} expected-warning {{negative}}
+ constexpr int shl_0 = 0 << 0; // ok
+ constexpr int shl_31 = 0 << 31; // ok
+ constexpr int shl_32 = 0 << 32; // expected-error {{constant expression}} expected-note {{shift count 32 >= width of type 'int' (32}} expected-warning {{>= width of type}}
+ constexpr int shl_unsigned_negative = unsigned(-3) << 1; // ok
+ constexpr int shl_unsigned_into_sign = 1u << 31; // ok
+ constexpr int shl_unsigned_overflow = 1024u << 31; // ok
+ constexpr int shl_signed_negative = (-3) << 1; // expected-error {{constant expression}} expected-note {{left shift of negative value -3}}
+ constexpr int shl_signed_ok = 1 << 30; // ok
+ constexpr int shl_signed_into_sign = 1 << 31; // ok (DR1457)
+ constexpr int shl_signed_into_sign_2 = 0x7fffffff << 1; // ok (DR1457)
+ constexpr int shl_signed_off_end = 2 << 31; // expected-error {{constant expression}} expected-note {{signed left shift discards bits}} expected-warning {{signed shift result (0x100000000) requires 34 bits to represent, but 'int' only has 32 bits}}
+ constexpr int shl_signed_off_end_2 = 0x7fffffff << 2; // expected-error {{constant expression}} expected-note {{signed left shift discards bits}} expected-warning {{signed shift result (0x1FFFFFFFC) requires 34 bits to represent, but 'int' only has 32 bits}}
+ constexpr int shl_signed_overflow = 1024 << 31; // expected-error {{constant expression}} expected-note {{signed left shift discards bits}} expected-warning {{requires 43 bits to represent}}
+ constexpr int shl_signed_ok2 = 1024 << 20; // ok
+
+ constexpr int shr_m1 = 0 >> -1; // expected-error {{constant expression}} expected-note {{negative shift count -1}} expected-warning {{negative}}
+ constexpr int shr_0 = 0 >> 0; // ok
+ constexpr int shr_31 = 0 >> 31; // ok
+ constexpr int shr_32 = 0 >> 32; // expected-error {{constant expression}} expected-note {{shift count 32 >= width of type}} expected-warning {{>= width of type}}
+
+ struct S {
+ int m;
+ };
+ constexpr S s = { 5 };
+ constexpr const int *p = &s.m + 1;
+ constexpr const int &f(const int *q) {
+ return q[0];
+ }
+ constexpr int n = (f(p), 0); // ok
+ struct T {
+ int n : f(p); // expected-error {{not an integral constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
+ };
+
+ namespace Ptr {
+ struct A {};
+ struct B : A { int n; };
+ B a[3][3];
+ constexpr B *p = a[0] + 4; // expected-error {{constant expression}} expected-note {{element 4 of array of 3 elements}}
+ B b = {};
+ constexpr A *pa = &b + 1; // expected-error {{constant expression}} expected-note {{base class of pointer past the end}}
+ constexpr B *pb = (B*)((A*)&b + 1); // expected-error {{constant expression}} expected-note {{derived class of pointer past the end}}
+ constexpr const int *pn = &(&b + 1)->n; // expected-error {{constant expression}} expected-note {{field of pointer past the end}}
+ constexpr B *parr = &a[3][0]; // expected-error {{constant expression}} expected-note {{array element of pointer past the end}}
+
+ constexpr A *na = nullptr;
+ constexpr B *nb = nullptr;
+ constexpr A &ra = *nb; // expected-error {{constant expression}} expected-note {{cannot access base class of null pointer}}
+ constexpr B &rb = (B&)*na; // expected-error {{constant expression}} expected-note {{cannot access derived class of null pointer}}
+ static_assert((A*)nb == 0, "");
+ static_assert((B*)na == 0, "");
+ constexpr const int &nf = nb->n; // expected-error {{constant expression}} expected-note {{cannot access field of null pointer}}
+ constexpr const int &np = (*(int(*)[4])nullptr)[2]; // expected-error {{constant expression}} expected-note {{cannot access array element of null pointer}}
+
+ struct C {
+ constexpr int f() { return 0; }
+ } constexpr c = C();
+ constexpr int k1 = c.f(); // ok
+ constexpr int k2 = ((C*)nullptr)->f(); // expected-error {{constant expression}} expected-note {{cannot call member function on null pointer}}
+ constexpr int k3 = (&c)[1].f(); // expected-error {{constant expression}} expected-note {{cannot call member function on pointer past the end of object}}
+ C c2;
+ constexpr int k4 = c2.f(); // ok!
+
+ constexpr int diff1 = &a[2] - &a[0];
+ constexpr int diff2 = &a[1][3] - &a[1][0];
+ constexpr int diff3 = &a[2][0] - &a[1][0]; // expected-error {{constant expression}} expected-note {{subtracted pointers are not elements of the same array}}
+ static_assert(&a[2][0] == &a[1][3], "");
+ constexpr int diff4 = (&b + 1) - &b;
+ constexpr int diff5 = &a[1][2].n - &a[1][0].n; // expected-error {{constant expression}} expected-note {{subtracted pointers are not elements of the same array}}
+ constexpr int diff6 = &a[1][2].n - &a[1][2].n;
+ constexpr int diff7 = (A*)&a[0][1] - (A*)&a[0][0]; // expected-error {{constant expression}} expected-note {{subtracted pointers are not elements of the same array}}
+ }
+
+ namespace Overflow {
+ // Signed int overflow.
+ constexpr int n1 = 2 * 3 * 3 * 7 * 11 * 31 * 151 * 331; // ok
+ constexpr int n2 = 65536 * 32768; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of }}
+ constexpr int n3 = n1 + 1; // ok
+ constexpr int n4 = n3 + 1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of }}
+ constexpr int n5 = -65536 * 32768; // ok
+ constexpr int n6 = 3 * -715827883; // expected-error {{constant expression}} expected-note {{value -2147483649 is outside the range of }}
+ constexpr int n7 = -n3 + -1; // ok
+ constexpr int n8 = -1 + n7; // expected-error {{constant expression}} expected-note {{value -2147483649 is outside the range of }}
+ constexpr int n9 = n3 - 0; // ok
+ constexpr int n10 = n3 - -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of }}
+ constexpr int n11 = -1 - n3; // ok
+ constexpr int n12 = -2 - n3; // expected-error {{constant expression}} expected-note {{value -2147483649 is outside the range of }}
+ constexpr int n13 = n5 + n5; // expected-error {{constant expression}} expected-note {{value -4294967296 is outside the range of }}
+ constexpr int n14 = n3 - n5; // expected-error {{constant expression}} expected-note {{value 4294967295 is outside the range of }}
+ constexpr int n15 = n5 * n5; // expected-error {{constant expression}} expected-note {{value 4611686018427387904 is outside the range of }}
+ constexpr signed char c1 = 100 * 2; // ok
+ constexpr signed char c2 = '\x64' * '\2'; // also ok
+ constexpr long long ll1 = 0x7fffffffffffffff; // ok
+ constexpr long long ll2 = ll1 + 1; // expected-error {{constant}} expected-note {{ 9223372036854775808 }}
+ constexpr long long ll3 = -ll1 - 1; // ok
+ constexpr long long ll4 = ll3 - 1; // expected-error {{constant}} expected-note {{ -9223372036854775809 }}
+ constexpr long long ll5 = ll3 * ll3; // expected-error {{constant}} expected-note {{ 85070591730234615865843651857942052864 }}
+
+ // Yikes.
+ char melchizedek[2200000000];
+ typedef decltype(melchizedek[1] - melchizedek[0]) ptrdiff_t;
+ constexpr ptrdiff_t d1 = &melchizedek[0x7fffffff] - &melchizedek[0]; // ok
+ constexpr ptrdiff_t d2 = &melchizedek[0x80000000u] - &melchizedek[0]; // expected-error {{constant expression}} expected-note {{ 2147483648 }}
+ constexpr ptrdiff_t d3 = &melchizedek[0] - &melchizedek[0x80000000u]; // ok
+ constexpr ptrdiff_t d4 = &melchizedek[0] - &melchizedek[0x80000001u]; // expected-error {{constant expression}} expected-note {{ -2147483649 }}
+
+ // Unsigned int overflow.
+ static_assert(65536u * 65536u == 0u, ""); // ok
+ static_assert(4294967295u + 1u == 0u, ""); // ok
+ static_assert(0u - 1u == 4294967295u, ""); // ok
+ static_assert(~0u * ~0u == 1u, ""); // ok
+
+ // Floating-point overflow and NaN.
+ constexpr float f1 = 1e38f * 3.4028f; // ok
+ constexpr float f2 = 1e38f * 3.4029f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}}
+ constexpr float f3 = 1e38f / -.2939f; // ok
+ constexpr float f4 = 1e38f / -.2938f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}}
+ constexpr float f5 = 2e38f + 2e38f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}}
+ constexpr float f6 = -2e38f - 2e38f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}}
+ constexpr float f7 = 0.f / 0.f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces a NaN}}
+ }
+}
+
+// - a lambda-expression (5.1.2);
+struct Lambda {
+ // FIXME: clang crashes when trying to parse this! Revisit this check once
+ // lambdas are fully implemented.
+ //int n : []{ return 1; }();
+};
+
+// - an lvalue-to-rvalue conversion (4.1) unless it is applied to
+namespace LValueToRValue {
+ // - a non-volatile glvalue of integral or enumeration type that refers to a
+ // non-volatile const object with a preceding initialization, initialized
+ // with a constant expression [Note: a string literal (2.14.5 [lex.string])
+ // corresponds to an array of such objects. -end note], or
+ volatile const int vi = 1; // expected-note 2{{here}}
+ const int ci = 1;
+ volatile const int &vrci = ci;
+ static_assert(vi, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}}
+ static_assert(const_cast<int&>(vi), ""); // expected-error {{constant expression}} expected-note {{read of volatile object 'vi'}}
+ static_assert(vrci, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}}
+
+ // - a non-volatile glvalue of literal type that refers to a non-volatile
+ // object defined with constexpr, or that refers to a sub-object of such an
+ // object, or
+ struct V {
+ constexpr V() : v(1) {}
+ volatile int v; // expected-note {{not literal because}}
+ };
+ constexpr V v; // expected-error {{non-literal type}}
+ struct S {
+ constexpr S(int=0) : i(1), v(const_cast<volatile int&>(vi)) {}
+ constexpr S(const S &s) : i(2), v(const_cast<volatile int&>(vi)) {}
+ int i;
+ volatile int &v;
+ };
+ constexpr S s; // ok
+ constexpr volatile S vs; // expected-note {{here}}
+ constexpr const volatile S &vrs = s; // ok
+ static_assert(s.i, "");
+ static_assert(s.v, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}}
+ static_assert(const_cast<int&>(s.v), ""); // expected-error {{constant expression}} expected-note {{read of volatile object 'vi'}}
+ static_assert(vs.i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}}
+ static_assert(const_cast<int&>(vs.i), ""); // expected-error {{constant expression}} expected-note {{read of volatile object 'vs'}}
+ static_assert(vrs.i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}}
+
+ // - a non-volatile glvalue of literal type that refers to a non-volatile
+ // temporary object whose lifetime has not ended, initialized with a
+ // constant expression;
+ constexpr volatile S f() { return S(); }
+ static_assert(f().i, ""); // ok! there's no lvalue-to-rvalue conversion here!
+ static_assert(((volatile const S&&)(S)0).i, ""); // expected-error {{constant expression}}
+}
+
+// DR1312: The proposed wording for this defect has issues, so we ignore this
+// bullet and instead prohibit casts from pointers to cv void (see core-20842
+// and core-20845).
+//
+// - an lvalue-to-rvalue conversion (4.1 [conv.lval]) that is applied to a
+// glvalue of type cv1 T that refers to an object of type cv2 U, where T and U
+// are neither the same type nor similar types (4.4 [conv.qual]);
+
+// - an lvalue-to-rvalue conversion (4.1) that is applied to a glvalue that
+// refers to a non-active member of a union or a subobject thereof;
+namespace LValueToRValueUnion {
+ // test/SemaCXX/constant-expression-cxx11.cpp contains more thorough testing
+ // of this.
+ union U { int a, b; } constexpr u = U();
+ static_assert(u.a == 0, "");
+ constexpr const int *bp = &u.b;
+ constexpr int b = *bp; // expected-error {{constant expression}} expected-note {{read of member 'b' of union with active member 'a'}}
+
+ extern const U pu;
+ constexpr const int *pua = &pu.a;
+ constexpr const int *pub = &pu.b;
+ constexpr U pu = { .b = 1 }; // expected-warning {{C99 feature}}
+ constexpr const int a2 = *pua; // expected-error {{constant expression}} expected-note {{read of member 'a' of union with active member 'b'}}
+ constexpr const int b2 = *pub; // ok
+}
+
+// - an id-expression that refers to a variable or data member of reference type
+// unless the reference has a preceding initialization, initialized with a
+// constant expression;
+namespace References {
+ const int a = 2;
+ int &b = *const_cast<int*>(&a);
+ int c = 10; // expected-note 2 {{here}}
+ int &d = c;
+ constexpr int e = 42;
+ int &f = const_cast<int&>(e);
+ extern int &g;
+ constexpr int &h(); // expected-note {{here}}
+ int &i = h(); // expected-note {{here}}
+ constexpr int &j() { return b; }
+ int &k = j();
+
+ struct S {
+ int A : a;
+ int B : b;
+ int C : c; // expected-error {{constant expression}} expected-note {{read of non-const variable 'c'}}
+ int D : d; // expected-error {{constant expression}} expected-note {{read of non-const variable 'c'}}
+ int D2 : &d - &c + 1;
+ int E : e / 2;
+ int F : f - 11;
+ int G : g; // expected-error {{constant expression}}
+ int H : h(); // expected-error {{constant expression}} expected-note {{undefined function 'h'}}
+ int I : i; // expected-error {{constant expression}} expected-note {{initializer of 'i' is not a constant expression}}
+ int J : j();
+ int K : k;
+ };
+}
+
+// - a dynamic_cast (5.2.7);
+namespace DynamicCast {
+ struct S { int n; };
+ constexpr S s { 16 };
+ struct T {
+ int n : dynamic_cast<const S*>(&s)->n; // expected-warning {{constant expression}} expected-note {{dynamic_cast}}
+ };
+}
+
+// - a reinterpret_cast (5.2.10);
+namespace ReinterpretCast {
+ struct S { int n; };
+ constexpr S s { 16 };
+ struct T {
+ int n : reinterpret_cast<const S*>(&s)->n; // expected-warning {{constant expression}} expected-note {{reinterpret_cast}}
+ };
+ struct U {
+ int m : (long)(S*)6; // expected-warning {{constant expression}} expected-note {{reinterpret_cast}}
+ };
+}
+
+// - a pseudo-destructor call (5.2.4);
+namespace PseudoDtor {
+ int k;
+ typedef int I;
+ struct T {
+ int n : (k.~I(), 0); // expected-error {{constant expression}}
+ };
+}
+
+// - increment or decrement operations (5.2.6, 5.3.2);
+namespace IncDec {
+ int k = 2;
+ struct T {
+ int n : ++k; // expected-error {{constant expression}}
+ int m : --k; // expected-error {{constant expression}}
+ };
+}
+
+// - a typeid expression (5.2.8) whose operand is of a polymorphic class type;
+namespace std {
+ struct type_info {
+ virtual ~type_info();
+ const char *name;
+ };
+}
+namespace TypeId {
+ struct S { virtual void f(); };
+ constexpr S *p = 0;
+ constexpr const std::type_info &ti1 = typeid(*p); // expected-error {{must be initialized by a constant expression}} expected-note {{typeid applied to expression of polymorphic type 'TypeId::S'}}
+
+ struct T {} t;
+ constexpr const std::type_info &ti2 = typeid(t);
+}
+
+// - a new-expression (5.3.4);
+// - a delete-expression (5.3.5);
+namespace NewDelete {
+ int *p = 0;
+ struct T {
+ int n : *new int(4); // expected-error {{constant expression}}
+ int m : (delete p, 2); // expected-error {{constant expression}}
+ };
+}
+
+// - a relational (5.9) or equality (5.10) operator where the result is
+// unspecified;
+namespace UnspecifiedRelations {
+ int a, b;
+ constexpr int *p = &a, *q = &b;
+ // C++11 [expr.rel]p2: If two pointers p and q of the same type point to
+ // different objects that are not members of the same array or to different
+ // functions, or if only one of them is null, the results of p<q, p>q, p<=q,
+ // and p>=q are unspecified.
+ constexpr bool u1 = p < q; // expected-error {{constant expression}}
+ constexpr bool u2 = p > q; // expected-error {{constant expression}}
+ constexpr bool u3 = p <= q; // expected-error {{constant expression}}
+ constexpr bool u4 = p >= q; // expected-error {{constant expression}}
+ constexpr bool u5 = p < 0; // expected-error {{constant expression}}
+ constexpr bool u6 = p <= 0; // expected-error {{constant expression}}
+ constexpr bool u7 = p > 0; // expected-error {{constant expression}}
+ constexpr bool u8 = p >= 0; // expected-error {{constant expression}}
+ constexpr bool u9 = 0 < q; // expected-error {{constant expression}}
+ constexpr bool u10 = 0 <= q; // expected-error {{constant expression}}
+ constexpr bool u11 = 0 > q; // expected-error {{constant expression}}
+ constexpr bool u12 = 0 >= q; // expected-error {{constant expression}}
+ void f(), g();
+
+ constexpr void (*pf)() = &f, (*pg)() = &g;
+ constexpr bool u13 = pf < pg; // expected-error {{constant expression}}
+ constexpr bool u14 = pf == pg;
+
+ // If two pointers point to non-static data members of the same object with
+ // different access control, the result is unspecified.
+ struct A {
+ public:
+ constexpr A() : a(0), b(0) {}
+ int a;
+ constexpr bool cmp() { return &a < &b; } // expected-error {{constexpr function never produces a constant expression}} expected-note {{comparison of address of fields 'a' and 'b' of 'A' with differing access specifiers (public vs private) has unspecified value}}
+ private:
+ int b;
+ };
+ class B {
+ public:
+ A a;
+ constexpr bool cmp() { return &a.a < &b.a; } // expected-error {{constexpr function never produces a constant expression}} expected-note {{comparison of address of fields 'a' and 'b' of 'B' with differing access specifiers (public vs protected) has unspecified value}}
+ protected:
+ A b;
+ };
+
+ // If two pointers point to different base sub-objects of the same object, or
+ // one points to a base subobject and the other points to a member, the result
+ // of the comparison is unspecified. This is not explicitly called out by
+ // [expr.rel]p2, but is covered by 'Other pointer comparisons are
+ // unspecified'.
+ struct C {
+ int c[2];
+ };
+ struct D {
+ int d;
+ };
+ struct E : C, D {
+ struct Inner {
+ int f;
+ } e;
+ } e;
+ constexpr bool base1 = &e.c[0] < &e.d; // expected-error {{constant expression}} expected-note {{comparison of addresses of subobjects of different base classes has unspecified value}}
+ constexpr bool base2 = &e.c[1] < &e.e.f; // expected-error {{constant expression}} expected-note {{comparison of address of base class subobject 'C' of class 'E' to field 'e' has unspecified value}}
+ constexpr bool base3 = &e.e.f < &e.d; // expected-error {{constant expression}} expected-note {{comparison of address of base class subobject 'D' of class 'E' to field 'e' has unspecified value}}
+
+ // [expr.rel]p3: Pointers to void can be compared [...] if both pointers
+ // represent the same address or are both the null pointer [...]; otherwise
+ // the result is unspecified.
+ struct S { int a, b; } s;
+ constexpr void *null = 0;
+ constexpr void *pv = (void*)&s.a;
+ constexpr void *qv = (void*)&s.b;
+ constexpr bool v1 = null < 0;
+ constexpr bool v2 = null < pv; // expected-error {{constant expression}}
+ constexpr bool v3 = null == pv; // ok
+ constexpr bool v4 = qv == pv; // ok
+ constexpr bool v5 = qv >= pv; // expected-error {{constant expression}} expected-note {{unequal pointers to void}}
+ constexpr bool v6 = qv > null; // expected-error {{constant expression}}
+ constexpr bool v7 = qv <= (void*)&s.b; // ok
+ constexpr bool v8 = qv > (void*)&s.a; // expected-error {{constant expression}} expected-note {{unequal pointers to void}}
+}
+
+// - an assignment or a compound assignment (5.17); or
+namespace Assignment {
+ int k;
+ struct T {
+ int n : (k = 9); // expected-error {{constant expression}}
+ int m : (k *= 2); // expected-error {{constant expression}}
+ };
+
+ struct Literal {
+ constexpr Literal(const char *name) : name(name) {}
+ const char *name;
+ };
+ struct Expr {
+ constexpr Expr(Literal l) : IsLiteral(true), l(l) {}
+ bool IsLiteral;
+ union {
+ Literal l;
+ // ...
+ };
+ };
+ struct MulEq {
+ constexpr MulEq(Expr a, Expr b) : LHS(a), RHS(b) {}
+ Expr LHS;
+ Expr RHS;
+ };
+ constexpr MulEq operator*=(Expr a, Expr b) { return MulEq(a, b); }
+ Literal a("a");
+ Literal b("b");
+ MulEq c = a *= b; // ok
+}
+
+// - a throw-expression (15.1)
+namespace Throw {
+ struct S {
+ int n : (throw "hello", 10); // expected-error {{constant expression}}
+ };
+}
+
+// PR9999
+template<unsigned int v>
+class bitWidthHolding {
+public:
+ static const
+ unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1);
+};
+
+static const int width=bitWidthHolding<255>::width;
+
+template<bool b>
+struct always_false {
+ static const bool value = false;
+};
+
+template<bool b>
+struct and_or {
+ static const bool and_value = b && and_or<always_false<b>::value>::and_value;
+ static const bool or_value = !b || and_or<always_false<b>::value>::or_value;
+};
+
+static const bool and_value = and_or<true>::and_value;
+static const bool or_value = and_or<true>::or_value;
+
+static_assert(and_value == false, "");
+static_assert(or_value == true, "");
diff --git a/clang/test/CXX/expr/expr.const/p3-0x-nowarn.cpp b/clang/test/CXX/expr/expr.const/p3-0x-nowarn.cpp
new file mode 100644
index 0000000..c891374
--- /dev/null
+++ b/clang/test/CXX/expr/expr.const/p3-0x-nowarn.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-c++11-narrowing -verify %s
+
+// <rdar://problem/11121178>
+void f(int x) {
+ switch (x) {
+ case 0x80000001: break;
+ }
+}
diff --git a/clang/test/CXX/expr/expr.const/p3-0x.cpp b/clang/test/CXX/expr/expr.const/p3-0x.cpp
new file mode 100644
index 0000000..6ddd11b
--- /dev/null
+++ b/clang/test/CXX/expr/expr.const/p3-0x.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+// A converted constant expression of type T is a core constant expression,
+int nonconst = 8; // expected-note 3 {{here}}
+enum NonConstE : unsigned char { NCE = nonconst }; // expected-error {{enumerator value is not a constant expression}} expected-note {{read of non-const}}
+template<int = nonconst> struct NonConstT {}; // expected-error {{non-type template argument is not a constant expression}} expected-note {{read of non-const}}
+void NonConstF() {
+ switch (nonconst) {
+ case nonconst: // expected-error {{case value is not a constant expression}} expected-note {{read of non-const}}
+ break;
+ }
+ return;
+}
+
+// implicitly converted to a prvalue of type T, where the converted expression
+// is a literal constant expression
+
+bool a(int n) {
+ constexpr char vowels[] = "aeiou";
+ switch (n) {
+ case vowels[0]:
+ case vowels[1]:
+ case vowels[2]:
+ case vowels[3]:
+ case vowels[4]:
+ static_assert(!vowels[5], "unexpected number of vowels");
+ return true;
+ }
+ return false;
+}
+
+// and the implicit conversion sequence contains only
+//
+// user-defined conversions,
+struct S { constexpr operator int() const { return 5; } };
+enum E : unsigned char { E5 = S(), E6, E10 = S() * 2, E1 = E5 / 5 };
+
+// lvalue-to-rvalue conversions,
+const E e10 = E10;
+template<E> struct T {};
+T<e10> s10;
+
+// integral promotions, and
+enum class EE { EE32 = ' ', EE65 = 'A', EE1 = (short)1, EE5 = E5 };
+
+// integral conversions other than narrowing conversions
+int b(unsigned n) {
+ switch (n) {
+ case E6:
+ case EE::EE32: // expected-error {{not implicitly convertible}}
+ case (int)EE::EE32:
+ case 1000:
+ case (long long)1e10: // expected-error {{case value evaluates to 10000000000, which cannot be narrowed to type 'unsigned int'}}
+ case -3: // expected-error {{case value evaluates to -3, which cannot be narrowed to type 'unsigned int'}}
+ return n;
+ }
+ return 0;
+}
+enum class EEE : unsigned short {
+ a = E6,
+ b = EE::EE32, // expected-error {{not implicitly convertible}}
+ c = (int)EE::EE32,
+ d = 1000,
+ e = 123456, // expected-error {{enumerator value evaluates to 123456, which cannot be narrowed to type 'unsigned short'}}
+ f = -3 // expected-error {{enumerator value evaluates to -3, which cannot be narrowed to type 'unsigned short'}}
+};
+template<unsigned char> using A = int;
+using Int = A<E6>;
+using Int = A<EE::EE32>; // expected-error {{not implicitly convertible}}
+using Int = A<(int)EE::EE32>;
+using Int = A<200>;
+using Int = A<1000>; // expected-error {{template argument evaluates to 1000, which cannot be narrowed to type 'unsigned char'}}
+using Int = A<-3>; // expected-error {{template argument evaluates to -3, which cannot be narrowed to type 'unsigned char'}}
+
+// Note, conversions from integral or unscoped enumeration types to bool are
+// integral conversions as well as boolean conversions.
+template<typename T, T v> struct Val { static constexpr T value = v; };
+static_assert(Val<bool, E1>::value == 1, ""); // ok
+static_assert(Val<bool, '\0'>::value == 0, ""); // ok
+static_assert(Val<bool, U'\1'>::value == 1, ""); // ok
+static_assert(Val<bool, E5>::value == 1, ""); // expected-error {{5, which cannot be narrowed to type 'bool'}}
+
+// (no other conversions are permitted)
+using Int = A<1.0>; // expected-error {{conversion from 'double' to 'unsigned char' is not allowed in a converted constant expression}}
+enum B : bool {
+ True = &a, // expected-error {{conversion from 'bool (*)(int)' to 'bool' is not allowed in a converted constant expression}}
+ False = nullptr // expected-error {{conversion from 'nullptr_t' to 'bool' is not allowed in a converted constant expression}}
+};
+void c() {
+ // Note, promoted type of switch is 'int'.
+ switch (bool b = a(5)) { // expected-warning {{boolean value}}
+ case 0.0f: // expected-error {{conversion from 'float' to 'int' is not allowed in a converted constant expression}}
+ break;
+ }
+}
+template<bool B> int f() { return B; }
+template int f<&S::operator int>(); // expected-error {{does not refer to a function template}}
+template int f<(bool)&S::operator int>();
+
+int n = Val<bool, &S::operator int>::value; // expected-error {{conversion from 'int (S::*)() const' to 'bool' is not allowed in a converted constant expression}}
+
+namespace NonConstLValue {
+ struct S {
+ constexpr operator int() { return 10; }
+ };
+ S s; // not constexpr
+ // Under the FDIS, this is not a converted constant expression.
+ // Under the new proposed wording, it is.
+ enum E : char { e = s };
+}
diff --git a/clang/test/CXX/expr/expr.const/p5-0x.cpp b/clang/test/CXX/expr/expr.const/p5-0x.cpp
new file mode 100644
index 0000000..60fabe3
--- /dev/null
+++ b/clang/test/CXX/expr/expr.const/p5-0x.cpp
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+// If an expression of literal class type is used in a context where an integral
+// constant expression is required, then that class type shall have a single
+// non-explicit conversion function to an integral or unscoped enumeration type
+namespace std_example {
+
+struct A {
+ constexpr A(int i) : val(i) { }
+ constexpr operator int() { return val; }
+ constexpr operator long() { return 43; }
+private:
+ int val;
+};
+template<int> struct X { };
+constexpr A a = 42;
+X<a> x; // ok, unique conversion to int
+int ary[a]; // expected-error {{size of array has non-integer type 'const std_example::A'}}
+
+}
+
+struct OK {
+ constexpr OK() {}
+ constexpr operator int() { return 8; }
+} constexpr ok;
+extern struct Incomplete incomplete; // expected-note 4{{forward decl}}
+struct Explicit {
+ constexpr Explicit() {}
+ constexpr explicit operator int() { return 4; } // expected-note 4{{here}}
+} constexpr expl;
+struct Ambiguous {
+ constexpr Ambiguous() {}
+ constexpr operator int() { return 2; } // expected-note 4{{here}}
+ constexpr operator long() { return 1; } // expected-note 4{{here}}
+} constexpr ambig;
+
+constexpr int test_ok = ok; // ok
+constexpr int test_explicit(expl); // ok
+constexpr int test_ambiguous = ambig; // ok
+
+static_assert(test_ok == 8, "");
+static_assert(test_explicit == 4, "");
+static_assert(test_ambiguous == 2, "");
+
+// [expr.new]p6: Every constant-expression in a noptr-new-declarator shall be
+// an integral constant expression
+auto new1 = new int[1][ok];
+auto new2 = new int[1][incomplete]; // expected-error {{incomplete}}
+auto new3 = new int[1][expl]; // expected-error {{explicit conversion}}
+auto new4 = new int[1][ambig]; // expected-error {{ambiguous conversion}}
+
+// [dcl.enum]p5: If the underlying type is not fixed [...] the initializing
+// value [...] shall be an integral constant expression.
+enum NotFixed {
+ enum1 = ok,
+ enum2 = incomplete, // expected-error {{incomplete}}
+ enum3 = expl, // expected-error {{explicit conversion}}
+ enum4 = ambig // expected-error {{ambiguous conversion}}
+};
+
+// [dcl.align]p2: When the alignment-specifier is of the form
+// alignas(assignment-expression), the assignment-expression shall be an
+// integral constant expression
+int alignas(ok) alignas1;
+int alignas(incomplete) alignas2; // expected-error {{incomplete}}
+int alignas(expl) alignas3; // expected-error {{explicit conversion}}
+int alignas(ambig) alignas4; // expected-error {{ambiguous conversion}}
+
+// [dcl.array]p1: If the constant-expression is present, it shall be an integral
+// constant expression
+// FIXME: The VLA recovery results in us giving diagnostics which aren't great
+// here.
+int array1[ok];
+int array2[incomplete]; // expected-error {{non-integer type}}
+int array3[expl]; // expected-error {{non-integer type}}
+int array4[ambig]; // expected-error {{non-integer type}}
+
+// [class.bit]p1: The constasnt-expression shall be an integral constant
+// expression
+struct Bitfields {
+ int bitfield1 : ok;
+ int bitfield2 : incomplete; // expected-error {{incomplete}}
+ int bitfield3 : expl; // expected-error {{explicit conversion}}
+ int bitfield4 : ambig; // expected-error {{ambiguous conversion}}
+};
diff --git a/clang/test/CXX/expr/expr.mptr.oper/p5.cpp b/clang/test/CXX/expr/expr.mptr.oper/p5.cpp
new file mode 100644
index 0000000..7380b5d
--- /dev/null
+++ b/clang/test/CXX/expr/expr.mptr.oper/p5.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct X0 {
+ void f0();
+ void f1() const;
+ void f2() volatile;
+ void f3() const volatile;
+};
+
+void test_object_cvquals(void (X0::*pm)(),
+ void (X0::*pmc)() const,
+ void (X0::*pmv)() volatile,
+ void (X0::*pmcv)() const volatile,
+ X0 *p,
+ const X0 *pc,
+ volatile X0 *pv,
+ const volatile X0 *pcv,
+ X0 &o,
+ const X0 &oc,
+ volatile X0 &ov,
+ const volatile X0 &ocv) {
+ (p->*pm)();
+ (p->*pmc)();
+ (p->*pmv)();
+ (p->*pmcv)();
+
+ (pc->*pm)(); // expected-error{{call to pointer to member function of type 'void ()' drops 'const' qualifier}}
+ (pc->*pmc)();
+ (pc->*pmv)(); // expected-error{{call to pointer to member function of type 'void () volatile' drops 'const' qualifier}}
+ (pc->*pmcv)();
+
+ (pv->*pm)(); // expected-error{{call to pointer to member function of type 'void ()' drops 'volatile' qualifier}}
+ (pv->*pmc)(); // expected-error{{call to pointer to member function of type 'void () const' drops 'volatile' qualifier}}
+ (pv->*pmv)();
+ (pv->*pmcv)();
+
+ (pcv->*pm)(); // expected-error{{call to pointer to member function of type 'void ()' drops 'const volatile' qualifiers}}
+ (pcv->*pmc)(); // expected-error{{call to pointer to member function of type 'void () const' drops 'volatile' qualifier}}
+ (pcv->*pmv)(); // expected-error{{call to pointer to member function of type 'void () volatile' drops 'const' qualifier}}
+ (pcv->*pmcv)();
+
+ (o.*pm)();
+ (o.*pmc)();
+ (o.*pmv)();
+ (o.*pmcv)();
+
+ (oc.*pm)(); // expected-error{{call to pointer to member function of type 'void ()' drops 'const' qualifier}}
+ (oc.*pmc)();
+ (oc.*pmv)(); // expected-error{{call to pointer to member function of type 'void () volatile' drops 'const' qualifier}}
+ (oc.*pmcv)();
+
+ (ov.*pm)(); // expected-error{{call to pointer to member function of type 'void ()' drops 'volatile' qualifier}}
+ (ov.*pmc)(); // expected-error{{call to pointer to member function of type 'void () const' drops 'volatile' qualifier}}
+ (ov.*pmv)();
+ (ov.*pmcv)();
+
+ (ocv.*pm)(); // expected-error{{call to pointer to member function of type 'void ()' drops 'const volatile' qualifiers}}
+ (ocv.*pmc)(); // expected-error{{call to pointer to member function of type 'void () const' drops 'volatile' qualifier}}
+ (ocv.*pmv)(); // expected-error{{call to pointer to member function of type 'void () volatile' drops 'const' qualifier}}
+ (ocv.*pmcv)();
+}
diff --git a/clang/test/CXX/expr/expr.mptr.oper/p6-0x.cpp b/clang/test/CXX/expr/expr.mptr.oper/p6-0x.cpp
new file mode 100644
index 0000000..917b2da
--- /dev/null
+++ b/clang/test/CXX/expr/expr.mptr.oper/p6-0x.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct X { };
+
+template<typename T> T& lvalue();
+template<typename T> T&& xvalue();
+template<typename T> T prvalue();
+
+// In a .* expression whose object expression is an rvalue, the
+// program is ill-formed if the second operand is a pointer to member
+// function with ref-qualifier &. In a ->* expression or in a .*
+// expression whose object expression is an lvalue, the program is
+// ill-formed if the second operand is a pointer to member function
+// with ref-qualifier &&.
+void test(X *xp, int (X::*pmf)(int), int (X::*l_pmf)(int) &,
+ int (X::*r_pmf)(int) &&) {
+ // No ref-qualifier.
+ (lvalue<X>().*pmf)(17);
+ (xvalue<X>().*pmf)(17);
+ (prvalue<X>().*pmf)(17);
+ (xp->*pmf)(17);
+
+ // Lvalue ref-qualifier.
+ (lvalue<X>().*l_pmf)(17);
+ (xvalue<X>().*l_pmf)(17); // expected-error{{pointer-to-member function type 'int (X::*)(int) &' can only be called on an lvalue}}
+ (prvalue<X>().*l_pmf)(17); // expected-error{{pointer-to-member function type 'int (X::*)(int) &' can only be called on an lvalue}}
+ (xp->*l_pmf)(17);
+
+ // Rvalue ref-qualifier.
+ (lvalue<X>().*r_pmf)(17); // expected-error{{pointer-to-member function type 'int (X::*)(int) &&' can only be called on an rvalue}}
+ (xvalue<X>().*r_pmf)(17);
+ (prvalue<X>().*r_pmf)(17);
+ (xp->*r_pmf)(17); // expected-error{{pointer-to-member function type 'int (X::*)(int) &&' can only be called on an rvalue}}
+}
diff --git a/clang/test/CXX/expr/expr.post/expr.call/p7-0x.cpp b/clang/test/CXX/expr/expr.post/expr.call/p7-0x.cpp
new file mode 100644
index 0000000..d51ba09
--- /dev/null
+++ b/clang/test/CXX/expr/expr.post/expr.call/p7-0x.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct X1 {
+ X1();
+};
+
+struct X2 {
+ X2();
+ ~X2();
+};
+
+void vararg(...);
+
+void f(X1 x1, X2 x2) {
+ vararg(x1); // okay
+ vararg(x2); // expected-error{{cannot pass object of non-trivial type 'X2' through variadic function; call will abort at runtime}}
+}
+
+
+namespace PR11131 {
+ struct S;
+
+ S &getS();
+
+ void f(...);
+
+ void g() {
+ (void)sizeof(f(getS()));
+ }
+}
diff --git a/clang/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp b/clang/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp
new file mode 100644
index 0000000..6ba8d51
--- /dev/null
+++ b/clang/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// The result of the expression const_cast<T>(v) is of type T. If T is
+// an lvalue reference to object type, the result is an lvalue; if T
+// is an rvalue reference to object type, the result is an xvalue;.
+
+unsigned int f(int);
+
+template<typename T> T& lvalue();
+template<typename T> T&& xvalue();
+template<typename T> T prvalue();
+
+void test_classification(const int *ptr) {
+ int *ptr0 = const_cast<int *&&>(ptr);
+ int *ptr1 = const_cast<int *&&>(xvalue<const int*>());
+ int *ptr2 = const_cast<int *&&>(prvalue<const int*>());
+}
diff --git a/clang/test/CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp b/clang/test/CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp
new file mode 100644
index 0000000..cddd5cf
--- /dev/null
+++ b/clang/test/CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct X { virtual ~X(); };
+struct Y : public X { };
+struct Z; // expected-note{{forward declaration of 'Z'}}
+
+void test(X &x, Y &y, Z &z) {
+ // If T is an rvalue reference type, v shall be an expression having
+ // a complete class type, and the result is an xvalue of the type
+ // referred to by T.
+ Y &&yr0 = dynamic_cast<Y&&>(x);
+ Y &&yr1 = dynamic_cast<Y&&>(static_cast<X&&>(x));
+ Y &&yr2 = dynamic_cast<Y&&>(z); // expected-error{{'Z' is an incomplete type}}
+}
diff --git a/clang/test/CXX/expr/expr.post/expr.ref/p3.cpp b/clang/test/CXX/expr/expr.post/expr.ref/p3.cpp
new file mode 100644
index 0000000..98771d3
--- /dev/null
+++ b/clang/test/CXX/expr/expr.post/expr.ref/p3.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+template<typename T> struct Node {
+ int lhs;
+ void splay( )
+ {
+ Node<T> n[1];
+ (void)n->lhs;
+ }
+};
+
+void f() {
+ Node<int> n;
+ return n.splay();
+}
diff --git a/clang/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp b/clang/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp
new file mode 100644
index 0000000..22892a6
--- /dev/null
+++ b/clang/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// If T is an lvalue reference type or an rvalue reference to function
+// type, the result is an lvalue; if T is an rvalue reference to
+// object type, the result is an xvalue;
+
+unsigned int f(int);
+
+template<typename T> T&& xvalue();
+void test_classification(char *ptr) {
+ int (&fr0)(int) = reinterpret_cast<int (&&)(int)>(f);
+ int &&ir0 = reinterpret_cast<int &&>(*ptr);
+ int &&ir1 = reinterpret_cast<int &&>(0);
+ int &&ir2 = reinterpret_cast<int &&>('a');
+ int &&ir3 = reinterpret_cast<int &&>(xvalue<char>());
+}
diff --git a/clang/test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp b/clang/test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp
new file mode 100644
index 0000000..9ef15e6
--- /dev/null
+++ b/clang/test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// A glvalue of type "cv1 T1" can be cast to type "rvalue reference to
+// cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1" (8.5.3).
+struct A { };
+struct B : A { };
+
+template<typename T> T& lvalue();
+template<typename T> T&& xvalue();
+
+void test(A &a, B &b) {
+ A &&ar0 = static_cast<A&&>(a);
+ A &&ar1 = static_cast<A&&>(b);
+ A &&ar2 = static_cast<A&&>(lvalue<A>());
+ A &&ar3 = static_cast<A&&>(lvalue<B>());
+ A &&ar4 = static_cast<A&&>(xvalue<A>());
+ A &&ar5 = static_cast<A&&>(xvalue<B>());
+ const A &&ar6 = static_cast<const A&&>(a);
+ const A &&ar7 = static_cast<const A&&>(b);
+ const A &&ar8 = static_cast<const A&&>(lvalue<A>());
+ const A &&ar9 = static_cast<const A&&>(lvalue<B>());
+ const A &&ar10 = static_cast<const A&&>(xvalue<A>());
+ const A &&ar11 = static_cast<const A&&>(xvalue<B>());
+}
diff --git a/clang/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp b/clang/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp
new file mode 100644
index 0000000..731c508
--- /dev/null
+++ b/clang/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+enum class EC { ec1 };
+
+void test0(EC ec) {
+ (void)static_cast<bool>(ec);
+ (void)static_cast<bool>(EC::ec1);
+ (void)static_cast<char>(ec);
+ (void)static_cast<char>(EC::ec1);
+ (void)static_cast<int>(ec);
+ (void)static_cast<int>(EC::ec1);
+ (void)static_cast<unsigned long>(ec);
+ (void)static_cast<unsigned long>(EC::ec1);
+ (void)static_cast<float>(ec);
+ (void)static_cast<float>(EC::ec1);
+ (void)static_cast<double>(ec);
+ (void)static_cast<double>(EC::ec1);
+}
+
+namespace PR9107 {
+ enum E {};
+ template <class _Tp> inline _Tp* addressof(_Tp& __x) {
+ return (_Tp*)&(char&)__x;
+ }
+ void test() {
+ E a;
+ addressof(a);
+ }
+}
diff --git a/clang/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp b/clang/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp
new file mode 100644
index 0000000..253744e
--- /dev/null
+++ b/clang/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct foo {
+ foo();
+ foo(int);
+};
+
+int func(foo& f) {
+ decltype(foo())();
+ f = (decltype(foo()))5;
+ return decltype(3)(5);
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp
new file mode 100644
index 0000000..249c976
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct S {
+ int *j = &nonexistent; // expected-error {{use of undeclared identifier 'nonexistent'}}
+ int *m = &n; // ok
+
+ int n = f(); // ok
+ int f();
+};
+
+int i = sizeof(S::m); // ok
+int j = sizeof(S::m + 42); // ok
+
+
+struct T {
+ int n;
+ static void f() {
+ int a[n]; // expected-error {{invalid use of member 'n' in static member function}}
+ int b[sizeof n]; // ok
+ }
+};
+
+// Make sure the rule for unevaluated operands works correctly with typeid.
+namespace std {
+ class type_info;
+}
+class Poly { virtual ~Poly(); };
+const std::type_info& k = typeid(S::m);
+const std::type_info& m = typeid(*(Poly*)S::m); // expected-error {{invalid use of non-static data member}}
+const std::type_info& n = typeid(*(Poly*)(0*sizeof S::m));
+
+namespace PR11956 {
+ struct X { char a; };
+ struct Y { int f() { return sizeof(X::a); } }; // ok
+
+ struct A { enum E {} E; };
+ struct B { int f() { return sizeof(A::E); } }; // ok
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
new file mode 100644
index 0000000..030c90c
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
@@ -0,0 +1,101 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+struct A {
+ int &f(int*);
+ float &f(int*) const noexcept;
+
+ int *ptr;
+ auto g1() noexcept(noexcept(f(ptr))) -> decltype(f(this->ptr));
+ auto g2() const noexcept(noexcept(f((*this).ptr))) -> decltype(f(ptr));
+};
+
+void testA(A &a) {
+ int &ir = a.g1();
+ float &fr = a.g2();
+ static_assert(!noexcept(a.g1()), "exception-specification failure");
+ static_assert(noexcept(a.g2()), "exception-specification failure");
+}
+
+struct B {
+ char g();
+ template<class T> auto f(T t) -> decltype(t + g())
+ { return t + g(); }
+};
+
+template auto B::f(int t) -> decltype(t + g());
+
+template<typename T>
+struct C {
+ int &f(T*);
+ float &f(T*) const noexcept;
+
+ T* ptr;
+ auto g1() noexcept(noexcept(f(ptr))) -> decltype(f((*this).ptr));
+ auto g2() const noexcept(noexcept(f(((this))->ptr))) -> decltype(f(ptr));
+};
+
+void test_C(C<int> ci) {
+ int *p = 0;
+ int &ir = ci.g1();
+ float &fr = ci.g2();
+ static_assert(!noexcept(ci.g1()), "exception-specification failure");
+ static_assert(noexcept(ci.g2()), "exception-specification failure");
+}
+
+namespace PR10036 {
+ template <class I>
+ void
+ iter_swap(I x, I y) noexcept;
+
+ template <class T>
+ class A
+ {
+ T t_;
+ public:
+ void swap(A& a) noexcept(noexcept(iter_swap(&t_, &a.t_)));
+ };
+
+ void test() {
+ A<int> i, j;
+ i.swap(j);
+ }
+}
+
+namespace Static {
+ struct X1 {
+ int m;
+ static auto f() -> decltype(m); // expected-error{{'this' cannot be implicitly used in a static member function declaration}}
+ static auto g() -> decltype(this->m); // expected-error{{'this' cannot be used in a static member function declaration}}
+
+ static int h();
+
+ static int i() noexcept(noexcept(m + 2)); // expected-error{{'this' cannot be implicitly used in a static member function declaration}}
+ };
+
+ auto X1::h() -> decltype(m) { return 0; } // expected-error{{'this' cannot be implicitly used in a static member function declaration}}
+
+ template<typename T>
+ struct X2 {
+ int m;
+
+ T f(T*);
+ static T f(int);
+
+ auto g(T x) -> decltype(f(x)) { return 0; }
+ };
+
+ void test_X2() {
+ X2<int>().g(0);
+ }
+}
+
+namespace PR12564 {
+ struct Base {
+ void bar(Base&) {} // unexpected-note {{here}}
+ };
+
+ struct Derived : Base {
+ // FIXME: This should be accepted.
+ void foo(Derived& d) noexcept(noexcept(d.bar(d))) {} // unexpected-error {{cannot bind to a value of unrelated type}}
+ };
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp
new file mode 100644
index 0000000..4e57b74
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct S {
+ S *p = this; // ok
+ decltype(this) q; // expected-error {{invalid use of 'this' outside of a non-static member function}}
+
+ int arr[sizeof(this)]; // expected-error {{invalid use of 'this' outside of a non-static member function}}
+ int sz = sizeof(this); // ok
+};
+
+namespace CaptureThis {
+ struct X {
+ int n = 10;
+ int m = [&]{return n + 1; }();
+ int o = [&]{return this->m + 1; }();
+ int p = [&]{return [&](int x) { return this->m + x;}(o); }();
+ };
+
+ X x;
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp
new file mode 100644
index 0000000..5b3a004
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct global {
+};
+
+namespace PR10127 {
+ struct outer {
+ struct middle {
+ struct inner {
+ int func();
+ int i;
+ };
+ struct inner2 {
+ };
+ struct inner3 {
+ };
+ int mfunc();
+ };
+ typedef int td_int;
+ };
+
+ struct str {
+ operator decltype(outer::middle::inner()) ();
+ operator decltype(outer::middle())::inner2 ();
+ operator decltype(outer())::middle::inner3 ();
+ str(int (decltype(outer::middle::inner())::*n)(),
+ int (decltype(outer::middle())::inner::*o)(),
+ int (decltype(outer())::middle::inner::*p)());
+ };
+
+ decltype(outer::middle::inner()) a;
+ void scope() {
+ a.decltype(outer::middle())::mfunc(); // expected-error{{'PR10127::outer::middle::mfunc' is not a member of class 'decltype(outer::middle::inner())'}}
+ a.decltype(outer::middle::inner())::func();
+ a.decltype(outer::middle())::inner::func();
+ a.decltype(outer())::middle::inner::func();
+
+ a.decltype(outer())::middle::inner::~inner();
+
+ decltype(outer())::middle::inner().func();
+ }
+ decltype(outer::middle())::inner b;
+ decltype(outer())::middle::inner c;
+ decltype(outer())::fail d; // expected-error{{no type named 'fail' in 'PR10127::outer'}}
+ decltype(outer())::fail::inner e; // expected-error{{no member named 'fail' in 'PR10127::outer'}}
+ decltype()::fail f; // expected-error{{expected expression}}
+ decltype()::middle::fail g; // expected-error{{expected expression}}
+
+ decltype(int()) h;
+ decltype(int())::PR10127::outer i; // expected-error{{'decltype(int())' (aka 'int') is not a class, namespace, or scoped enumeration}}
+ decltype(int())::global j; // expected-error{{'decltype(int())' (aka 'int') is not a class, namespace, or scoped enumeration}}
+
+ outer::middle k = decltype(outer())::middle();
+ outer::middle::inner l = decltype(outer())::middle::inner();
+
+ template<typename T>
+ struct templ {
+ typename decltype(T())::middle::inner x; // expected-error{{type 'decltype(int())' (aka 'int') cannot be used prior to '::' because it has no members}}
+ };
+
+ template class templ<int>; // expected-note{{in instantiation of template class 'PR10127::templ<int>' requested here}}
+ template class templ<outer>;
+
+ enum class foo {
+ bar,
+ baz
+ };
+
+ foo m = decltype(foo::bar)::baz;
+
+ enum E {
+ };
+ struct bar {
+ enum E : decltype(outer())::td_int(4);
+ enum F : decltype(outer())::td_int;
+ enum G : decltype; // expected-error{{expected '(' after 'decltype'}}
+ };
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm
new file mode 100644
index 0000000..0c3fdb2
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -std=c++11 -fblocks %s -verify
+
+void block_capture_errors() {
+ __block int var; // expected-note 2{{'var' declared here}}
+ (void)[var] { }; // expected-error{{__block variable 'var' cannot be captured in a lambda}}
+
+ (void)[=] { var = 17; }; // expected-error{{__block variable 'var' cannot be captured in a lambda}}
+}
+
+void conversion_to_block(int captured) {
+ int (^b1)(int) = [=](int x) { return x + captured; };
+
+ const auto lambda = [=](int x) { return x + captured; };
+ int (^b2)(int) = lambda;
+}
+
+template<typename T>
+class ConstCopyConstructorBoom {
+public:
+ ConstCopyConstructorBoom(ConstCopyConstructorBoom&);
+
+ ConstCopyConstructorBoom(const ConstCopyConstructorBoom&) {
+ T *ptr = 1; // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}}
+ }
+
+ void foo() const;
+};
+
+void conversion_to_block_init(ConstCopyConstructorBoom<int> boom,
+ ConstCopyConstructorBoom<float> boom2) {
+ const auto& lambda1([=] { boom.foo(); }); // okay
+
+ const auto& lambda2([=] { boom2.foo(); }); // expected-note{{in instantiation of member function}}
+ void (^block)(void) = lambda2;
+}
+
+
+void nesting() {
+ int array[7]; // expected-note 2{{'array' declared here}}
+ [=] () mutable {
+ [&] {
+ ^ {
+ int i = array[2];
+ i += array[3];
+ }();
+ }();
+ }();
+
+ [&] {
+ [=] () mutable {
+ ^ {
+ int i = array[2]; // expected-error{{cannot refer to declaration with an array type inside block}}
+ i += array[3]; // expected-error{{cannot refer to declaration with an array type inside block}}
+ }();
+ }();
+ }();
+}
+
+namespace overloading {
+ void bool_conversion() {
+ if ([](){}) {
+ }
+
+ bool b = []{};
+ b = (bool)[]{};
+ }
+
+ void conversions() {
+ int (*fp)(int) = [](int x) { return x + 1; };
+ fp = [](int x) { return x + 1; };
+
+ typedef int (*func_ptr)(int);
+ fp = (func_ptr)[](int x) { return x + 1; };
+
+ int (^bp)(int) = [](int x) { return x + 1; };
+ bp = [](int x) { return x + 1; };
+
+ typedef int (^block_ptr)(int);
+ bp = (block_ptr)[](int x) { return x + 1; };
+ }
+
+ int &accept_lambda_conv(int (*fp)(int));
+ float &accept_lambda_conv(int (^bp)(int));
+
+ void call_with_lambda() {
+ int &ir = accept_lambda_conv([](int x) { return x + 1; });
+ }
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
new file mode 100644
index 0000000..5dac886
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -Wno-lambda-extensions -verify
+
+void defargs() {
+ auto l1 = [](int i, int j = 17, int k = 18) { return i + j + k; };
+ int i1 = l1(1);
+ int i2 = l1(1, 2);
+ int i3 = l1(1, 2, 3);
+}
+
+
+void defargs_errors() {
+ auto l1 = [](int i,
+ int j = 17,
+ int k) { }; // expected-error{{missing default argument on parameter 'k'}}
+
+ auto l2 = [](int i, int j = i) {}; // expected-error{{default argument references parameter 'i'}}
+
+ int foo;
+ auto l3 = [](int i = foo) {}; // expected-error{{default argument references local variable 'foo' of enclosing function}}
+}
+
+struct NonPOD {
+ NonPOD();
+ NonPOD(const NonPOD&);
+ ~NonPOD();
+};
+
+struct NoDefaultCtor {
+ NoDefaultCtor(const NoDefaultCtor&); // expected-note{{candidate constructor}}
+ ~NoDefaultCtor();
+};
+
+template<typename T>
+void defargs_in_template_unused(T t) {
+ auto l1 = [](const T& value = T()) { };
+ l1(t);
+}
+
+template void defargs_in_template_unused(NonPOD);
+template void defargs_in_template_unused(NoDefaultCtor);
+
+template<typename T>
+void defargs_in_template_used() {
+ auto l1 = [](const T& value = T()) { }; // expected-error{{no matching constructor for initialization of 'NoDefaultCtor'}}
+ l1(); // expected-note{{in instantiation of default function argument expression for 'operator()<NoDefaultCtor>' required here}}
+}
+
+template void defargs_in_template_used<NonPOD>();
+template void defargs_in_template_used<NoDefaultCtor>(); // expected-note{{in instantiation of function template specialization}}
+
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp
new file mode 100644
index 0000000..245e270
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+int GlobalVar; // expected-note {{declared here}}
+
+namespace N {
+ int AmbiguousVar; // expected-note {{candidate}}
+}
+int AmbiguousVar; // expected-note {{candidate}}
+using namespace N;
+
+class X0 {
+ int Member;
+
+ static void Overload(int);
+ void Overload();
+ virtual X0& Overload(float);
+
+ void explicit_capture() {
+ int variable; // expected-note {{declared here}}
+ (void)[&Overload] () {}; // expected-error {{does not name a variable}}
+ (void)[&GlobalVar] () {}; // expected-error {{does not have automatic storage duration}}
+ (void)[&AmbiguousVar] () {}; // expected-error {{reference to 'AmbiguousVar' is ambiguous}}
+ (void)[&Variable] () {}; // expected-error {{use of undeclared identifier 'Variable'; did you mean 'variable'}}
+ }
+};
+
+void test_reaching_scope() {
+ int local; // expected-note{{declared here}}
+ static int local_static; // expected-note{{'local_static' declared here}}
+ (void)[=]() {
+ struct InnerLocal {
+ void member() {
+ (void)[local, // expected-error{{reference to local variable 'local' declared in enclosing function 'test_reaching_scope'}}
+ local_static]() { // expected-error{{'local_static' cannot be captured because it does not have automatic storage duration}}
+ return 0;
+ };
+ }
+ };
+ };
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11.cpp
new file mode 100644
index 0000000..d265dd7
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+void test_reaching_scope() {
+ int local; // expected-note{{declared here}}
+ static int local_static;
+ (void)[=]() {
+ struct InnerLocal {
+ void member() {
+ (void)[=]() {
+ return local + // expected-error{{reference to local variable 'local' declared in enclosing function 'test_reaching_scope'}}
+ local_static;
+ };
+ }
+ };
+ };
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
new file mode 100644
index 0000000..4a2a4f3
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
+
+void odr_used() {
+ int i = 17;
+ [i]{}();
+}
+
+struct ReachingThis {
+ static void static_foo() {
+ (void)[this](){}; // expected-error{{'this' cannot be captured in this context}}
+
+ struct Local {
+ int i;
+
+ void bar() {
+ (void)[this](){};
+ (void)[&](){i = 7; };
+ }
+ };
+ }
+
+ void foo() {
+ (void)[this](){};
+
+ struct Local {
+ int i;
+
+ static void static_bar() {
+ (void)[this](){}; // expected-error{{'this' cannot be captured in this context}}
+ (void)[&](){i = 7; }; // expected-error{{invalid use of member 'i' in static member function}}
+ }
+ };
+ }
+};
+
+void immediately_enclosing(int i) { // expected-note{{'i' declared here}}
+ [i]() {
+ [i] {}();
+ }();
+
+ [=]() {
+ [i] {}();
+ }();
+
+ []() { // expected-note{{lambda expression begins here}}
+ [i] {}(); // expected-error{{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}}
+ }();
+}
+
+void f1(int i) { // expected-note{{declared here}}
+ int const N = 20;
+ auto m1 = [=]{
+ int const M = 30;
+ auto m2 = [i]{
+ int x[N][M];
+ x[0][0] = i;
+ };
+ (void)N;
+ (void)M;
+ (void)m2;
+ };
+ struct s1 {
+ int f;
+ void work(int n) { // expected-note{{declared here}}
+ int m = n*n;
+ int j = 40; // expected-note{{declared here}}
+ auto m3 = [this,m] { // expected-note 3{{lambda expression begins here}}
+ auto m4 = [&,j] { // expected-error{{variable 'j' cannot be implicitly captured in a lambda with no capture-default specified}}
+ int x = n; // expected-error{{variable 'n' cannot be implicitly captured in a lambda with no capture-default specified}}
+ x += m;
+ x += i; // expected-error{{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}}
+ x += f;
+ };
+ };
+ }
+ };
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp
new file mode 100644
index 0000000..8bb707e
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
+
+void f2() {
+ int i = 1;
+ void g1(int = ([i]{ return i; })()); // expected-error{{lambda expression in default argument cannot capture any entity}}
+ void g2(int = ([i]{ return 0; })()); // expected-error{{lambda expression in default argument cannot capture any entity}}
+ void g3(int = ([=]{ return i; })()); // expected-error{{lambda expression in default argument cannot capture any entity}}
+ void g4(int = ([=]{ return 0; })());
+ void g5(int = ([]{ return sizeof i; })());
+}
+
+namespace lambda_in_default_args {
+ int f(int = [] () -> int { int n; return ++n; } ());
+ template<typename T> T g(T = [] () -> T { T n; return ++n; } ());
+ int k = f() + g<int>();
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp
new file mode 100644
index 0000000..678fa4b
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+template<typename T> void capture(const T&);
+
+class NonCopyable {
+ NonCopyable(const NonCopyable&); // expected-note 2 {{implicitly declared private here}}
+public:
+ void foo() const;
+};
+
+class NonConstCopy {
+public:
+ NonConstCopy(NonConstCopy&); // expected-note{{would lose const}}
+};
+
+void capture_by_copy(NonCopyable nc, NonCopyable &ncr, const NonConstCopy nco) {
+ (void)[nc] { }; // expected-error{{capture of variable 'nc' as type 'NonCopyable' calls private copy constructor}}
+ (void)[=] {
+ ncr.foo(); // expected-error{{capture of variable 'ncr' as type 'NonCopyable' calls private copy constructor}}
+ }();
+
+ [nco] {}(); // expected-error{{no matching constructor for initialization of 'const NonConstCopy'}}
+}
+
+struct NonTrivial {
+ NonTrivial();
+ NonTrivial(const NonTrivial &);
+ ~NonTrivial();
+};
+
+struct CopyCtorDefault {
+ CopyCtorDefault();
+ CopyCtorDefault(const CopyCtorDefault&, NonTrivial nt = NonTrivial());
+
+ void foo() const;
+};
+
+void capture_with_default_args(CopyCtorDefault cct) {
+ (void)[=] () -> void { cct.foo(); };
+}
+
+struct ExpectedArrayLayout {
+ CopyCtorDefault array[3];
+};
+
+void capture_array() {
+ CopyCtorDefault array[3];
+ auto x = [=]() -> void {
+ capture(array[0]);
+ };
+ static_assert(sizeof(x) == sizeof(ExpectedArrayLayout), "layout mismatch");
+}
+
+// Check for the expected non-static data members.
+
+struct ExpectedLayout {
+ char a;
+ short b;
+};
+
+void test_layout(char a, short b) {
+ auto x = [=] () -> void {
+ capture(a);
+ capture(b);
+ };
+ static_assert(sizeof(x) == sizeof(ExpectedLayout), "Layout mismatch!");
+}
+
+struct ExpectedThisLayout {
+ ExpectedThisLayout* a;
+ void f() {
+ auto x = [this]() -> void {};
+ static_assert(sizeof(x) == sizeof(ExpectedThisLayout), "Layout mismatch!");
+ }
+};
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp
new file mode 100644
index 0000000..c4deba9
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+class NonCopyable {
+ NonCopyable(const NonCopyable&);
+};
+
+void capture_by_ref(NonCopyable nc, NonCopyable &ncr) {
+ int array[3];
+ (void)[&nc] () -> void {};
+ (void)[&ncr] () -> void {};
+ (void)[&array] () -> void {};
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp
new file mode 100644
index 0000000..0cf01ad
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
+
+
+struct X {
+ X(const X&) = delete; // expected-note 2{{explicitly marked deleted}}
+ X(X&);
+};
+
+void test_capture(X x) {
+ [x] { }(); // okay: non-const copy ctor
+
+ [x] {
+ [x] { // expected-error{{call to deleted constructor of 'X'}}
+ }();
+ }();
+
+ [x] {
+ [&x] {
+ [x] { // expected-error{{call to deleted constructor of 'const X'}}
+ }();
+ }();
+ }();
+
+ int a;
+ [=]{
+ [&] {
+ int &x = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}}
+ int &x2 = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}}
+ }();
+ }();
+
+ [=]{
+ [&a] {
+ [&] {
+ int &x = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}}
+ int &x2 = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}}
+ }();
+ }();
+ }();
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp
new file mode 100644
index 0000000..930a4b3
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+void f3() {
+ float x, &r = x;
+ int i;
+ int &ir = i;
+ const int &irc = i;
+
+ [=,&irc,&ir] {
+ static_assert(is_same<decltype(((r))), float const&>::value,
+ "should be const float&");
+ static_assert(is_same<decltype(x), float>::value, "should be float");
+ static_assert(is_same<decltype((x)), const float&>::value,
+ "should be const float&");
+ static_assert(is_same<decltype(r), float&>::value, "should be float&");
+ static_assert(is_same<decltype(ir), int&>::value, "should be int&");
+ static_assert(is_same<decltype((ir)), int&>::value, "should be int&");
+ static_assert(is_same<decltype(irc), const int&>::value,
+ "should be const int&");
+ static_assert(is_same<decltype((irc)), const int&>::value,
+ "should be const int&");
+ }();
+
+ [=] {
+ [=] () mutable {
+ static_assert(is_same<decltype(x), float>::value, "should be float");
+ static_assert(is_same<decltype((x)), float&>::value,
+ "should be float&");
+ }();
+ }();
+
+ [&i] {
+ static_assert(is_same<decltype((i)), int&>::value, "should be int&");
+ }();
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp
new file mode 100644
index 0000000..6fe3b25
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
+
+struct MoveOnly {
+ MoveOnly(MoveOnly&&);
+ MoveOnly(const MoveOnly&);
+};
+
+template<typename T> T &&move(T&);
+void test_special_member_functions(MoveOnly mo, int i) {
+ auto lambda1 = [i]() { }; // expected-note 2 {{lambda expression begins here}}
+
+ // Default constructor
+ decltype(lambda1) lambda2; // expected-error{{call to implicitly-deleted default constructor of 'decltype(lambda1)' (aka '<lambda}}
+
+ // Copy assignment operator
+ lambda1 = lambda1; // expected-error{{overload resolution selected implicitly-deleted copy assignment operator}}
+
+ // Move assignment operator
+ lambda1 = move(lambda1);
+
+ // Copy constructor
+ decltype(lambda1) lambda3 = lambda1;
+ decltype(lambda1) lambda4(lambda1);
+
+ // Move constructor
+ decltype(lambda1) lambda5 = move(lambda1);
+ decltype(lambda1) lambda6(move(lambda1));
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp
new file mode 100644
index 0000000..c6ed308
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+// prvalue
+void prvalue() {
+ auto&& x = []()->void { };
+ auto& y = []()->void { }; // expected-error{{cannot bind to a temporary of type}}
+}
+
+namespace std {
+ class type_info;
+}
+
+struct P {
+ virtual ~P();
+};
+
+void unevaluated_operand(P &p, int i) {
+ int i2 = sizeof([]()->void{}()); // expected-error{{lambda expression in an unevaluated operand}}
+ const std::type_info &ti1 = typeid([&]() -> P& { return p; }());
+ const std::type_info &ti2 = typeid([&]() -> int { return i; }()); // expected-error{{lambda expression in an unevaluated operand}}
+}
+
+template<typename T>
+struct Boom {
+ Boom(const Boom&) {
+ T* x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} \
+ // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}} \
+ // expected-error{{cannot initialize a variable of type 'double *' with an rvalue of type 'int'}}
+ }
+ void tickle() const;
+};
+
+void odr_used(P &p, Boom<int> boom_int, Boom<float> boom_float,
+ Boom<double> boom_double) {
+ const std::type_info &ti1
+ = typeid([=,&p]() -> P& { boom_int.tickle(); return p; }()); // expected-note{{in instantiation of member function 'Boom<int>::Boom' requested here}}
+ const std::type_info &ti2
+ = typeid([=]() -> int { boom_float.tickle(); return 0; }()); // expected-error{{lambda expression in an unevaluated operand}} \
+ // expected-note{{in instantiation of member function 'Boom<float>::Boom' requested here}}
+
+ auto foo = [=]() -> int { boom_double.tickle(); return 0; }; // expected-note{{in instantiation of member function 'Boom<double>::Boom' requested here}}
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p20.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p20.cpp
new file mode 100644
index 0000000..4487cfc
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p20.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
+
+template<typename T>
+void destroy(T* ptr) {
+ ptr->~T();
+ (*ptr).~T();
+}
+
+void destructor() {
+ auto lambda = []{};
+ destroy(&lambda);
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p21.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p21.cpp
new file mode 100644
index 0000000..7139058
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p21.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+struct DirectInitOnly {
+ explicit DirectInitOnly(DirectInitOnly&);
+};
+
+void direct_init_capture(DirectInitOnly &dio) {
+ [dio] {}();
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp
new file mode 100644
index 0000000..174db25
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+void print();
+
+template<typename T, typename... Ts>
+void print(T first, Ts... rest) {
+ (void)first;
+ print(rest...);
+}
+
+template<typename... Ts>
+void unsupported(Ts ...values) {
+ auto unsup = [values] {}; // expected-error{{unexpanded function parameter pack capture is unsupported}}
+}
+
+template<typename... Ts>
+void implicit_capture(Ts ...values) {
+ auto implicit = [&] { print(values...); };
+ implicit();
+}
+
+template<typename... Ts>
+void do_print(Ts... values) {
+ auto bycopy = [values...]() { print(values...); };
+ bycopy();
+ auto byref = [&values...]() { print(values...); };
+ byref();
+
+ auto bycopy2 = [=]() { print(values...); };
+ bycopy2();
+ auto byref2 = [&]() { print(values...); };
+ byref2();
+}
+
+template void do_print(int, float, double);
+
+template<typename T, int... Values>
+void bogus_expansions(T x) {
+ auto l1 = [x...] {}; // expected-error{{pack expansion does not contain any unexpanded parameter packs}}
+ auto l2 = [Values...] {}; // expected-error{{'Values' in capture list does not name a variable}}
+}
+
+void g(int*, float*, double*);
+
+template<class... Args>
+void std_example(Args... args) {
+ auto lm = [&, args...] { return g(args...); };
+};
+
+template void std_example(int*, float*, double*);
+
+template<typename ...Args>
+void variadic_lambda(Args... args) {
+ auto lambda = [](Args... inner_args) { return g(inner_args...); };
+ lambda(args...);
+}
+
+template void variadic_lambda(int*, float*, double*);
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp
new file mode 100644
index 0000000..562f92a
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+void test_nonaggregate(int i) {
+ auto lambda = [i]() -> void {}; // expected-note 3{{candidate constructor}}
+ decltype(lambda) foo = { 1 }; // expected-error{{no matching constructor}}
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
new file mode 100644
index 0000000..d816e17
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+void missing_lambda_declarator() {
+ [](){}();
+}
+
+template<typename T> T get();
+
+void infer_void_return_type(int i) {
+ if (i > 17)
+ return []() { }();
+
+ if (i > 11)
+ return []() { return; }();
+
+ return [](int x) {
+ switch (x) {
+ case 0: return get<void>();
+ case 1: return;
+ case 2: return { 1, 2.0 }; // expected-error{{cannot deduce lambda return type from initializer list}}
+ }
+ }(7);
+}
+
+struct X { };
+
+X infer_X_return_type(X x) {
+ return [&x](int y) { // expected-warning{{omitted result type}}
+ if (y > 0)
+ return X();
+ else
+ return x;
+ }(5);
+}
+
+X infer_X_return_type_fail(X x) {
+ return [x](int y) { // expected-warning{{omitted result type}}
+ if (y > 0)
+ return X();
+ else
+ return x; // expected-error{{return type 'const X' must match previous return type 'X' when lambda expression has unspecified explicit return type}}
+ }(5);
+}
+
+struct Incomplete; // expected-note{{forward declaration of 'Incomplete'}}
+void test_result_type(int N) {
+ auto l1 = [] () -> Incomplete { }; // expected-error{{incomplete result type 'Incomplete' in lambda expression}}
+
+ typedef int vla[N];
+ auto l2 = [] () -> vla { }; // expected-error{{function cannot return array type 'vla' (aka 'int [N]')}}
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm
new file mode 100644
index 0000000..0126e23
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+@interface A
+@end
+
+void test_result_type() {
+ auto l1 = [] () -> A { }; // expected-error{{non-pointer Objective-C class type 'A' in lambda expression result}}
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
new file mode 100644
index 0000000..68460f0
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -std=c++11 %s -Winvalid-noreturn -verify
+
+// An attribute-specifier-seq in a lambda-declarator appertains to the
+// type of the corresponding function call operator.
+void test_attributes() {
+ auto nrl = [](int x) -> int { if (x > 0) return x; }; // expected-warning{{control may reach end of non-void lambda}}
+
+ auto nrl2 = []() [[noreturn]] { return; }; // expected-error{{lambda declared 'noreturn' should not return}}
+}
+
+template<typename T>
+struct bogus_override_if_virtual : public T {
+ bogus_override_if_virtual() : T(*(T*)0) { }
+ int operator()() const;
+};
+
+void test_quals() {
+ // This function call operator is declared const (9.3.1) if and only
+ // if the lambda- expression's parameter-declaration-clause is not
+ // followed by mutable.
+ auto l = [=](){}; // expected-note{{method is not marked volatile}}
+ const decltype(l) lc = l;
+ l();
+ lc();
+
+ auto ml = [=]() mutable{}; // expected-note{{method is not marked const}} \
+ // expected-note{{method is not marked volatile}}
+ const decltype(ml) mlc = ml;
+ ml();
+ mlc(); // expected-error{{no matching function for call to object of type}}
+
+ // It is neither virtual nor declared volatile.
+ volatile decltype(l) lv = l;
+ volatile decltype(ml) mlv = ml;
+ lv(); // expected-error{{no matching function for call to object of type}}
+ mlv(); // expected-error{{no matching function for call to object of type}}
+
+ bogus_override_if_virtual<decltype(l)> bogus;
+}
+
+// Default arguments (8.3.6) shall not be specified in the
+// parameter-declaration-clause of a lambda- declarator.
+// Note: Removed by core issue 974.
+int test_default_args() {
+ return [](int i = 5, // expected-warning{{C++11 forbids default arguments for lambda expressions}}
+ int j = 17) { return i+j;}(5, 6);
+}
+
+// Any exception-specification specified on a lambda-expression
+// applies to the corresponding function call operator.
+void test_exception_spec() {
+ auto tl1 = []() throw(int) {};
+ auto tl2 = []() {};
+ static_assert(!noexcept(tl1()), "lambda can throw");
+ static_assert(!noexcept(tl2()), "lambda can throw");
+
+ auto ntl1 = []() throw() {};
+ auto ntl2 = []() noexcept(true) {};
+ auto ntl3 = []() noexcept {};
+ static_assert(noexcept(ntl1()), "lambda cannot throw");
+ static_assert(noexcept(ntl2()), "lambda cannot throw");
+ static_assert(noexcept(ntl3()), "lambda cannot throw");
+}
+
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp
new file mode 100644
index 0000000..8b43cef
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+void test_conversion() {
+ int (*fp1)(int) = [](int x) { return x + 1; };
+ void (*fp2)(int) = [](int x) { };
+
+ const auto lambda = [](int x) { };
+ void (*fp3)(int) = lambda;
+
+ volatile const auto lambda2 = [](int x) { }; // expected-note{{but method is not marked volatile}}
+ void (*fp4)(int) = lambda2; // expected-error{{no viable conversion}}
+}
+
+void test_no_conversion() {
+ int (*fp1)(int) = [=](int x) { return x + 1; }; // expected-error{{no viable conversion}}
+ void (*fp2)(int) = [&](int x) { }; // expected-error{{no viable conversion}}
+}
+
+void test_wonky() {
+ const auto l = [](int x) mutable -> int { return + 1; };
+ l(17); // okay: uses conversion function
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
new file mode 100644
index 0000000..9dbe2e1
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+// Check that analysis-based warnings work in lambda bodies.
+void analysis_based_warnings() {
+ (void)[]() -> int { }; // expected-warning{{control reaches end of non-void lambda}}
+}
+
+// Check that we get the right types of captured variables (the
+// semantic-analysis part of p7).
+int &check_const_int(int&);
+float &check_const_int(const int&);
+
+void test_capture_constness(int i, const int ic) {
+ (void)[i,ic] ()->void {
+ float &fr1 = check_const_int(i);
+ float &fr2 = check_const_int(ic);
+ };
+
+ (void)[=] ()->void {
+ float &fr1 = check_const_int(i);
+ float &fr2 = check_const_int(ic);
+ };
+
+ (void)[i,ic] () mutable ->void {
+ int &ir = check_const_int(i);
+ float &fr = check_const_int(ic);
+ };
+
+ (void)[=] () mutable ->void {
+ int &ir = check_const_int(i);
+ float &fr = check_const_int(ic);
+ };
+
+ (void)[&i,&ic] ()->void {
+ int &ir = check_const_int(i);
+ float &fr = check_const_int(ic);
+ };
+
+ (void)[&] ()->void {
+ int &ir = check_const_int(i);
+ float &fr = check_const_int(ic);
+ };
+}
+
+
+struct S1 {
+ int x, y;
+ S1 &operator=(int*);
+ int operator()(int);
+ void f() {
+ [&]()->int {
+ S1 &s1 = operator=(&this->x);
+ return operator()(this->x + y);
+ }();
+ }
+};
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
new file mode 100644
index 0000000..d1384f1
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+class X0 {
+ void explicit_capture() {
+ int foo;
+
+ (void)[foo, foo] () {}; // expected-error {{'foo' can appear only once}}
+ (void)[this, this] () {}; // expected-error {{'this' can appear only once}}
+ (void)[=, foo] () {}; // expected-error {{'&' must precede a capture when}}
+ (void)[=, &foo] () {};
+ (void)[=, this] () {}; // expected-error {{'this' cannot be explicitly captured}}
+ (void)[&, foo] () {};
+ (void)[&, &foo] () {}; // expected-error {{'&' cannot precede a capture when}}
+ (void)[&, this] () {};
+ }
+};
+
+struct S2 {
+ void f(int i);
+ void g(int i);
+};
+
+void S2::f(int i) {
+ (void)[&, i]{ };
+ (void)[&, &i]{ }; // expected-error{{'&' cannot precede a capture when the capture default is '&'}}
+ (void)[=, this]{ }; // expected-error{{'this' cannot be explicitly captured}}
+ (void)[=]{ this->g(i); };
+ (void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
+}
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
new file mode 100644
index 0000000..49b9c66
--- /dev/null
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
@@ -0,0 +1,149 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Winvalid-noreturn %s -verify
+
+template<typename T>
+void test_attributes() {
+ auto nrl = []() [[noreturn]] {}; // expected-error{{lambda declared 'noreturn' should not return}}
+}
+
+template void test_attributes<int>(); // expected-note{{in instantiation of function}}
+
+template<typename T>
+void call_with_zero() {
+ [](T *ptr) -> T& { return *ptr; }(0);
+}
+
+template void call_with_zero<int>();
+
+template<typename T>
+T captures(T x, T y) {
+ auto lambda = [=, &y] () -> T {
+ T i = x;
+ return i + y;
+ };
+
+ return lambda();
+}
+
+struct X {
+ X(const X&);
+};
+
+X operator+(X, X);
+X operator-(X, X);
+
+template int captures(int, int);
+template X captures(X, X);
+
+template<typename T>
+int infer_result(T x, T y) {
+ auto lambda = [=](bool b) { return x + y; };
+ return lambda(true); // expected-error{{no viable conversion from 'X' to 'int'}}
+}
+
+template int infer_result(int, int);
+template int infer_result(X, X); // expected-note{{in instantiation of function template specialization 'infer_result<X>' requested here}}
+
+// Make sure that lambda's operator() can be used from templates.
+template<typename F>
+void accept_lambda(F f) {
+ f(1);
+}
+
+template<typename T>
+void pass_lambda(T x) {
+ accept_lambda([&x](T y) { return x + y; });
+}
+
+template void pass_lambda(int);
+
+namespace std {
+ class type_info;
+}
+
+namespace p2 {
+ struct P {
+ virtual ~P();
+ };
+
+ template<typename T>
+ struct Boom {
+ Boom(const Boom&) {
+ T* x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} \
+ // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}}
+ }
+ void tickle() const;
+ };
+
+ template<typename R, typename T>
+ void odr_used(R &r, Boom<T> boom) {
+ const std::type_info &ti
+ = typeid([=,&r] () -> R& { // expected-error{{lambda expression in an unevaluated operand}}
+ boom.tickle(); // expected-note{{in instantiation of member function}}
+ return r;
+ }());
+ }
+
+ template void odr_used(int&, Boom<int>); // expected-note{{in instantiation of function template specialization}}
+
+ template<typename R, typename T>
+ void odr_used2(R &r, Boom<T> boom) {
+ const std::type_info &ti
+ = typeid([=,&r] () -> R& {
+ boom.tickle(); // expected-note{{in instantiation of member function}}
+ return r;
+ }());
+ }
+
+ template void odr_used2(P&, Boom<float>);
+}
+
+namespace p5 {
+ struct NonConstCopy {
+ NonConstCopy(const NonConstCopy&) = delete;
+ NonConstCopy(NonConstCopy&);
+ };
+
+ template<typename T>
+ void double_capture(T &nc) {
+ [=] () mutable {
+ [=] () mutable {
+ T nc2(nc);
+ }();
+ }();
+ }
+
+ template void double_capture(NonConstCopy&);
+}
+
+namespace NonLocalLambdaInstantation {
+ template<typename T>
+ struct X {
+ static int value;
+ };
+
+ template<typename T>
+ int X<T>::value = []{ return T(); }(); // expected-error{{cannot initialize a variable of type 'int' with an rvalue of type 'int *'}}
+
+ template int X<int>::value;
+ template int X<float>::value;
+ template int X<int*>::value; // expected-note{{in instantiation of static data member }}
+
+ template<typename T>
+ void defaults(int x = []{ return T(); }()) { }; // expected-error{{cannot initialize a parameter of type 'int' with an rvalue of type 'int *'}} \
+ // expected-note{{passing argument to parameter 'x' here}}
+
+ void call_defaults() {
+ defaults<int>();
+ defaults<float>();
+ defaults<int*>(); // expected-note{{in instantiation of default function argument expression for 'defaults<int *>' required here}}
+ }
+
+ template<typename T>
+ struct X2 {
+ int x = []{ return T(); }(); // expected-error{{cannot initialize a member subobject of type 'int' with an rvalue of type 'int *'}}
+ };
+
+ X2<int> x2i;
+ X2<float> x2f;
+ X2<int*> x2ip; // expected-note{{in instantiation of template class 'NonLocalLambdaInstantation::X2<int *>' requested here}}
+}
diff --git a/clang/test/CXX/expr/expr.unary/expr.delete/p5.cpp b/clang/test/CXX/expr/expr.unary/expr.delete/p5.cpp
new file mode 100644
index 0000000..ecb2918
--- /dev/null
+++ b/clang/test/CXX/expr/expr.unary/expr.delete/p5.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -verify %s
+
+// If the object being deleted has incomplete class type at the point of
+// deletion and the complete class has a non-trivial destructor or a
+// deallocation function, the behavior is undefined.
+
+// The trivial case.
+class T0; // expected-note {{forward declaration}}
+void f0(T0 *a) { delete a; } // expected-warning {{deleting pointer to incomplete type}}
+class T0 { ~T0(); };
+
+// The trivial case, inside a template instantiation.
+template<typename T>
+struct T1_A { T *x; ~T1_A() { delete x; } }; // expected-warning {{deleting pointer to incomplete type}}
+class T1_B; // expected-note {{forward declaration}}
+void f0() { T1_A<T1_B> x; } // expected-note {{in instantiation of member function}}
+
+// This case depends on when we check T2_C::f0.
+class T2_A;
+template<typename T>
+struct T2_B { void f0(T *a) { delete a; } };
+struct T2_C { T2_B<T2_A> x; void f0(T2_A *a) { x.f0(a); } };
+void f0(T2_A *a) { T2_C x; x.f0(a); }
+class T2_A { };
+
+// An alternate version of the same.
+class T3_A;
+template<typename T>
+struct T3_B {
+ void f0(T *a) {
+ delete a; // expected-error{{calling a private destructor of class 'T3_A'}}
+ }
+};
+
+struct T3_C {
+ T3_B<T3_A> x;
+ void f0(T3_A *a) {
+ x.f0(a); // expected-note{{in instantiation of member function 'T3_B<T3_A>::f0' requested here}}
+ }
+};
+
+void f0(T3_A *a) { T3_C x; x.f0(a); }
+class T3_A {
+private:
+ ~T3_A(); // expected-note{{declared private here}}
+};
diff --git a/clang/test/CXX/expr/expr.unary/expr.new/p17-crash.cpp b/clang/test/CXX/expr/expr.unary/expr.new/p17-crash.cpp
new file mode 100644
index 0000000..27b915e
--- /dev/null
+++ b/clang/test/CXX/expr/expr.unary/expr.new/p17-crash.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+
+// this used to crash due to templ<int>'s dtor not being marked as used by the
+// new expression in func()
+struct non_trivial {
+ non_trivial() {}
+ ~non_trivial() {}
+};
+template < typename T > class templ {
+ non_trivial n;
+};
+void func() {
+ new templ<int>[1][1];
+}
diff --git a/clang/test/CXX/expr/expr.unary/expr.new/p17.cpp b/clang/test/CXX/expr/expr.unary/expr.new/p17.cpp
new file mode 100644
index 0000000..0d108eb
--- /dev/null
+++ b/clang/test/CXX/expr/expr.unary/expr.new/p17.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class ctor {
+ ctor(); // expected-note{{implicitly declared private here}}
+};
+
+class dtor {
+ ~dtor(); // expected-note 3 {{implicitly declared private here}}
+};
+
+void test() {
+ new ctor[0]; // expected-error{{calling a private constructor of class 'ctor'}}
+ new dtor[0]; // expected-error{{calling a private destructor of class 'dtor'}}
+ new dtor[3]; // expected-error{{calling a private destructor of class 'dtor'}}
+ new dtor[3][3]; // expected-error{{calling a private destructor of class 'dtor'}}
+}
diff --git a/clang/test/CXX/expr/expr.unary/expr.new/p19.cpp b/clang/test/CXX/expr/expr.unary/expr.new/p19.cpp
new file mode 100644
index 0000000..bb69fd5
--- /dev/null
+++ b/clang/test/CXX/expr/expr.unary/expr.new/p19.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s
+typedef __SIZE_TYPE__ size_t;
+
+// Operator delete template for placement new with global lookup
+template<int I>
+struct X0 {
+ X0();
+
+ static void* operator new(size_t) {
+ return I; // expected-error{{cannot initialize}}
+ }
+
+ static void operator delete(void*) {
+ int *ip = I; // expected-error{{cannot initialize}}
+ }
+};
+
+void test_X0() {
+ // Using the global operator new suppresses the search for a
+ // operator delete in the class.
+ ::new X0<2>;
+
+ new X0<3>; // expected-note 2{{instantiation}}
+}
+
+// Operator delete template for placement new[] with global lookup
+template<int I>
+struct X1 {
+ X1();
+
+ static void* operator new[](size_t) {
+ return I; // expected-error{{cannot initialize}}
+ }
+
+ static void operator delete[](void*) {
+ int *ip = I; // expected-error{{cannot initialize}}
+ }
+};
+
+void test_X1() {
+ // Using the global operator new suppresses the search for a
+ // operator delete in the class.
+ ::new X1<2> [17];
+
+ new X1<3> [17]; // expected-note 2{{instantiation}}
+}
diff --git a/clang/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp b/clang/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp
new file mode 100644
index 0000000..4ebbfce
--- /dev/null
+++ b/clang/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+template<typename T>
+struct only {
+ only(T);
+ template<typename U> only(U) = delete;
+};
+
+void f() {
+ only<const int*> p = new const auto (0);
+ only<double*> q = new (auto) (0.0);
+
+ new auto; // expected-error{{new expression for type 'auto' requires a constructor argument}}
+ new (const auto)(); // expected-error{{new expression for type 'auto const' requires a constructor argument}}
+ new (auto) (1,2,3); // expected-error{{new expression for type 'auto' contains multiple constructor arguments}}
+}
+
+void p2example() {
+ only<int*> r = new auto(1);
+ auto x = new auto('a');
+
+ only<char*> testX = x;
+}
diff --git a/clang/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp b/clang/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp
new file mode 100644
index 0000000..eca1ec7
--- /dev/null
+++ b/clang/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fexceptions %s
+typedef __SIZE_TYPE__ size_t;
+
+struct S {
+ // Placement allocation function:
+ static void* operator new(size_t, size_t);
+ // Usual (non-placement) deallocation function:
+ static void operator delete(void*, size_t); // expected-note{{declared here}}
+};
+
+void testS() {
+ S* p = new (0) S; // expected-error{{'new' expression with placement arguments refers to non-placement 'operator delete'}}
+}
diff --git a/clang/test/CXX/expr/expr.unary/expr.new/p20.cpp b/clang/test/CXX/expr/expr.unary/expr.new/p20.cpp
new file mode 100644
index 0000000..8cbe2b9
--- /dev/null
+++ b/clang/test/CXX/expr/expr.unary/expr.new/p20.cpp
@@ -0,0 +1,141 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s
+typedef __SIZE_TYPE__ size_t;
+
+// Overloaded operator delete with two arguments
+template<int I>
+struct X0 {
+ X0();
+ static void* operator new(size_t);
+ static void operator delete(void*, size_t) {
+ int *ip = I; // expected-error{{cannot initialize}}
+ }
+};
+
+void test_X0() {
+ new X0<1>; // expected-note{{instantiation}}
+}
+
+// Overloaded operator delete with one argument
+template<int I>
+struct X1 {
+ X1();
+
+ static void* operator new(size_t);
+ static void operator delete(void*) {
+ int *ip = I; // expected-error{{cannot initialize}}
+ }
+};
+
+void test_X1() {
+ new X1<1>; // expected-note{{instantiation}}
+}
+
+// Overloaded operator delete for placement new
+template<int I>
+struct X2 {
+ X2();
+
+ static void* operator new(size_t, double, double);
+ static void* operator new(size_t, int, int);
+
+ static void operator delete(void*, const int, int) {
+ int *ip = I; // expected-error{{cannot initialize}}
+ }
+
+ static void operator delete(void*, double, double);
+};
+
+void test_X2() {
+ new (0, 0) X2<1>; // expected-note{{instantiation}}
+}
+
+// Operator delete template for placement new
+struct X3 {
+ X3();
+
+ static void* operator new(size_t, double, double);
+
+ template<typename T>
+ static void operator delete(void*, T x, T) {
+ double *dp = &x;
+ int *ip = &x; // expected-error{{cannot initialize}}
+ }
+};
+
+void test_X3() {
+ new (0, 0) X3; // expected-note{{instantiation}}
+}
+
+// Operator delete template for placement new in global scope.
+struct X4 {
+ X4();
+ static void* operator new(size_t, double, double);
+};
+
+template<typename T>
+void operator delete(void*, T x, T) {
+ double *dp = &x;
+ int *ip = &x; // expected-error{{cannot initialize}}
+}
+
+void test_X4() {
+ new (0, 0) X4; // expected-note{{instantiation}}
+}
+
+// Useless operator delete hides global operator delete template.
+struct X5 {
+ X5();
+ static void* operator new(size_t, double, double);
+ void operator delete(void*, double*, double*);
+};
+
+void test_X5() {
+ new (0, 0) X5; // okay, we found X5::operator delete but didn't pick it
+}
+
+// Operator delete template for placement new
+template<int I>
+struct X6 {
+ X6();
+
+ static void* operator new(size_t) {
+ return I; // expected-error{{cannot initialize}}
+ }
+
+ static void operator delete(void*) {
+ int *ip = I; // expected-error{{cannot initialize}}
+ }
+};
+
+void test_X6() {
+ new X6<3>; // expected-note 2{{instantiation}}
+}
+
+void *operator new(size_t, double, double, double);
+
+template<typename T>
+void operator delete(void*, T x, T, T) {
+ double *dp = &x;
+ int *ip = &x; // expected-error{{cannot initialize}}
+}
+void test_int_new() {
+ new (1.0, 1.0, 1.0) int; // expected-note{{instantiation}}
+}
+
+// We don't need an operator delete if the type has a trivial
+// constructor, since we know that constructor cannot throw.
+// FIXME: Is this within the standard? Seems fishy, but both EDG+GCC do it.
+#if 0
+template<int I>
+struct X7 {
+ static void* operator new(size_t);
+ static void operator delete(void*, size_t) {
+ int *ip = I; // okay, since it isn't instantiated.
+ }
+};
+
+void test_X7() {
+ new X7<1>;
+}
+#endif
+
diff --git a/clang/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp b/clang/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp
new file mode 100644
index 0000000..afd8ef0
--- /dev/null
+++ b/clang/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Test parsing + semantic analysis
+template<typename ...Types> struct count_types {
+ static const unsigned value = sizeof...(Types);
+};
+
+template<int ...Values> struct count_ints {
+ static const unsigned value = sizeof...(Values);
+};
+
+// Test instantiation
+int check_types[count_types<short, int, long>::value == 3? 1 : -1];
+int check_ints[count_ints<1, 2, 3, 4, 5>::value == 5? 1 : -1];
+
+// Test instantiation involving function parameter packs.
+struct any {
+ template<typename T> any(T);
+};
+
+template<typename ...Inits>
+void init_me(Inits ...inits) {
+ any array[sizeof...(inits)] = { inits... };
+}
+
+template void init_me<int, float, double*>(int, float, double*);
+
+// Test parser and semantic recovery.
+template<int Value> struct count_ints_2 {
+ static const unsigned value = sizeof...(Value); // expected-error{{'Value' does not refer to the name of a parameter pack}}
+};
+
+template<typename ...Types> // expected-note{{parameter pack 'Types' declared here}}
+struct count_types_2 {
+ static const unsigned value = sizeof... Type; // expected-error{{missing parentheses around the size of parameter pack 'Type'}} \
+ // expected-error{{Type' does not refer to the name of a parameter pack; did you mean 'Types'?}}
+};
+
diff --git a/clang/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp b/clang/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp
new file mode 100644
index 0000000..5c1029f
--- /dev/null
+++ b/clang/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -S -emit-llvm -std=c++11 -include %S/ser.h %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -emit-pch -o %t-ser.pch -std=c++11 -x c++ %S/ser.h
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -S -emit-llvm -std=c++11 -include-pch %t-ser.pch %s -o - | FileCheck %s
+
+struct D {
+ ~D() throw();
+};
+struct E {
+ ~E() throw();
+};
+
+void test() {
+ bool b;
+ // CHECK: store i8 1
+ b = noexcept(0);
+ // CHECK: store i8 0
+ b = noexcept(throw 0);
+ b = f1();
+ b = f2();
+
+ // CHECK-NOT: call void @_ZN1ED1Ev
+ // CHECK: call void @_ZN1DD1Ev
+ D(), noexcept(E());
+}
+// CHECK: ret i1 true
+// CHECK: ret i1 false
diff --git a/clang/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp b/clang/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp
new file mode 100644
index 0000000..b5de1a7
--- /dev/null
+++ b/clang/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp
@@ -0,0 +1,189 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -fms-extensions %s
+
+#define P(e) static_assert(noexcept(e), "expected nothrow")
+#define N(e) static_assert(!noexcept(e), "expected throw")
+#define B(b, e) static_assert(b == noexcept(e), "expectation failed")
+
+void simple() {
+ P(0);
+ P(0 + 0);
+ int i;
+ P(i);
+ P(sizeof(0));
+ P(static_cast<int>(0));
+ N(throw 0);
+ N((throw 0, 0));
+}
+
+void nospec();
+void allspec() throw(...);
+void intspec() throw(int);
+void emptyspec() throw();
+void nothrowattr() __attribute__((nothrow));
+void noexcept_true() noexcept;
+void noexcept_false() noexcept(false);
+
+void call() {
+ N(nospec());
+ N(allspec());
+ N(intspec());
+ P(emptyspec());
+ P(nothrowattr());
+ P(noexcept_true());
+ N(noexcept_false());
+}
+
+void (*pnospec)();
+void (*pallspec)() throw(...);
+void (*pintspec)() throw(int);
+void (*pemptyspec)() throw();
+
+void callptr() {
+ N(pnospec());
+ N((*pnospec)());
+ N(pallspec());
+ N((*pallspec)());
+ N(pintspec());
+ N((*pintspec)());
+ P(pemptyspec());
+ P((*pemptyspec)());
+}
+
+struct S1 {
+ void nospec();
+ void allspec() throw(...);
+ void intspec() throw(int);
+ void emptyspec() throw();
+};
+
+void callmem() {
+ S1 s;
+ N(s.nospec());
+ N(s.allspec());
+ N(s.intspec());
+ P(s.emptyspec());
+}
+
+void (S1::*mpnospec)();
+void (S1::*mpallspec)() throw(...);
+void (S1::*mpintspec)() throw(int);
+void (S1::*mpemptyspec)() throw();
+
+void callmemptr() {
+ S1 s;
+ N((s.*mpnospec)());
+ N((s.*mpallspec)());
+ N((s.*mpintspec)());
+ P((s.*mpemptyspec)());
+}
+
+struct S2 {
+ S2();
+ S2(int, int) throw();
+ void operator +();
+ void operator -() throw();
+ void operator +(int);
+ void operator -(int) throw();
+ operator int();
+ operator float() throw();
+};
+
+void *operator new(__typeof__(sizeof(int)) sz, int) throw();
+
+struct Bad1 {
+ ~Bad1() throw(int);
+};
+struct Bad2 {
+ void operator delete(void*) throw(int);
+};
+
+typedef int X;
+
+void implicits() {
+ N(new int);
+ P(new (0) int);
+ P(delete (int*)0);
+ N(delete (Bad1*)0);
+ N(delete (Bad2*)0);
+ N(S2());
+ P(S2(0, 0));
+ S2 s;
+ N(+s);
+ P(-s);
+ N(s + 0);
+ P(s - 0);
+ N(static_cast<int>(s));
+ P(static_cast<float>(s));
+ N(Bad1());
+ P(X().~X());
+}
+
+struct V {
+ virtual ~V() throw();
+};
+struct D : V {};
+
+void dyncast() {
+ V *pv = 0;
+ D *pd = 0;
+ P(dynamic_cast<V&>(*pd));
+ P(dynamic_cast<V*>(pd));
+ N(dynamic_cast<D&>(*pv));
+ P(dynamic_cast<D*>(pv));
+}
+
+namespace std {
+ struct type_info {};
+}
+
+void idtype() {
+ P(typeid(V));
+ P(typeid((V*)0));
+ P(typeid(*(S1*)0));
+ N(typeid(*(V*)0));
+}
+
+void uneval() {
+ P(sizeof(typeid(*(V*)0)));
+ P(typeid(typeid(*(V*)0)));
+}
+
+struct G1 {};
+struct G2 { int i; };
+struct G3 { S2 s; };
+
+void gencon() {
+ P(G1());
+ P(G2());
+ N(G3());
+}
+
+template <class T> void f(T&&) noexcept;
+template <typename T, bool b>
+void late() {
+ B(b, typeid(*(T*)0));
+ B(b, T(1));
+ B(b, static_cast<T>(S2(0, 0)));
+ B(b, S1() + T());
+ P(f(T()));
+ P(new (0) T);
+ P(delete (T*)0);
+}
+struct S3 {
+ virtual ~S3() throw();
+ S3() throw();
+ explicit S3(int);
+ S3(const S2&);
+};
+template <class T> T&& f2() noexcept;
+template <typename T>
+void late2() {
+ P(dynamic_cast<S3&>(f2<T&>()));
+}
+void operator +(const S1&, float) throw();
+void operator +(const S1&, const S3&);
+void tlate() {
+ late<float, true>();
+ late<S3, false>();
+ late2<S3>();
+}
diff --git a/clang/test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h b/clang/test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h
new file mode 100644
index 0000000..e6e7b79
--- /dev/null
+++ b/clang/test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h
@@ -0,0 +1,8 @@
+// Serialization testing helper for noexcept, included by cg.cpp.
+
+inline bool f1() {
+ return noexcept(0);
+}
+inline bool f2() {
+ return noexcept(throw 0);
+}
diff --git a/clang/test/CXX/expr/expr.unary/expr.unary.op/p3.cpp b/clang/test/CXX/expr/expr.unary/expr.unary.op/p3.cpp
new file mode 100644
index 0000000..2dd6b23
--- /dev/null
+++ b/clang/test/CXX/expr/expr.unary/expr.unary.op/p3.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+namespace rdar10544564 {
+ // Check that we don't attempt to use an overloaded operator& when
+ // naming a pointer-to-member.
+ struct X {
+ void** operator & ();
+ };
+
+ struct Y
+ {
+ public:
+ X member;
+ X memfunc1();
+ X memfunc2();
+ X memfunc2(int);
+
+ void test() {
+ X Y::*data_mem_ptr = &Y::member;
+ X (Y::*func_mem_ptr1)() = &Y::memfunc1;
+ X (Y::*func_mem_ptr2)() = &Y::memfunc2;
+ }
+ };
+
+ X Y::*data_mem_ptr = &Y::member;
+ X (Y::*func_mem_ptr1)() = &Y::memfunc1;
+ X (Y::*func_mem_ptr2)() = &Y::memfunc2;
+}
diff --git a/clang/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp b/clang/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp
new file mode 100644
index 0000000..06cc610
--- /dev/null
+++ b/clang/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// rdar://problem/8347416
+namespace test0 {
+ struct A {
+ void foo(void (A::*)(int)); // expected-note {{passing argument to parameter here}}
+ template<typename T> void g(T);
+
+ void test() {
+ foo(&g<int>); // expected-error {{can't form member pointer of type 'void (test0::A::*)(int)' without '&' and class name}}
+ }
+ };
+}
+
+// This should succeed.
+namespace test1 {
+ struct A {
+ static void f(void (A::*)());
+ static void f(void (*)(int));
+ void g();
+ static void g(int);
+
+ void test() {
+ f(&g);
+ }
+ };
+}
+
+// Also rdar://problem/8347416
+namespace test2 {
+ struct A {
+ static int foo(short);
+ static int foo(float);
+ int foo(int);
+ int foo(double);
+
+ void test();
+ };
+
+ void A::test() {
+ int (A::*ptr)(int) = &(A::foo); // expected-error {{can't form member pointer of type 'int (test2::A::*)(int)' without '&' and class name}}
+ }
+}
diff --git a/clang/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp b/clang/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp
new file mode 100644
index 0000000..ac11940
--- /dev/null
+++ b/clang/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// -- prvalue of arithmetic
+
+bool b = !0;
+
+bool b2 = !1.2;
+
+bool b3 = !4;
+
+// -- unscoped enumeration
+enum { E, F };
+
+bool b4 = !E;
+bool b5 = !F;
+
+// -- pointer,
+bool b6 = !&b4;
+void f();
+bool b61 = !&f;
+
+// -- or pointer to member type can be converted to a prvalue of type bool.
+struct S { void f() { } };
+
+bool b7 = !&S::f;
+
+
+bool b8 = !S(); //expected-error {{invalid argument type 'S'}}
+
+namespace PR8181
+{
+ bool f() { } // expected-note{{possible target for call}}
+ void f(char) { } // expected-note{{possible target for call}}
+ bool b = !&f; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
+}
diff --git a/clang/test/CXX/expr/p3.cpp b/clang/test/CXX/expr/p3.cpp
new file mode 100644
index 0000000..6b243c2
--- /dev/null
+++ b/clang/test/CXX/expr/p3.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+double operator +(double, double); // expected-error{{overloaded 'operator+' must have at least one parameter of class or enumeration type}}
+
+struct A
+{
+ operator int();
+};
+
+int main()
+{
+ A a, b;
+ int i0 = a + 1;
+ int i1 = a + b;
+}
diff --git a/clang/test/CXX/expr/p8.cpp b/clang/test/CXX/expr/p8.cpp
new file mode 100644
index 0000000..2f6c094
--- /dev/null
+++ b/clang/test/CXX/expr/p8.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int a0;
+const volatile int a1 = 2;
+int a2[16];
+int a3();
+
+void f0(int);
+void f1(int *);
+void f2(int (*)());
+
+int main()
+{
+ f0(a0);
+ f0(a1);
+ f1(a2);
+ f2(a3);
+}
diff --git a/clang/test/CXX/expr/p9.cpp b/clang/test/CXX/expr/p9.cpp
new file mode 100644
index 0000000..803b0cc
--- /dev/null
+++ b/clang/test/CXX/expr/p9.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// floating-point overloads
+
+__typeof__(0 + 0.0L) ld0;
+long double &ldr = ld0;
+
+__typeof__(0 + 0.0) d0;
+double &dr = d0;
+
+__typeof__(0 + 0.0f) f0;
+float &fr = f0;
+
+// integral promotions
+
+signed char c0;
+__typeof__(c0 + c0) c1;
+int &cr = c1;
+
+unsigned char uc0;
+__typeof__(uc0 + uc0) uc1;
+int &ucr = uc1;
+
+short s0;
+__typeof__(s0 + s0) s1;
+int &sr = s1;
+
+unsigned short us0;
+__typeof__(us0 + us0) us1;
+int &usr = us1;
+
+// integral overloads
+
+__typeof__(0 + 0UL) ul0;
+unsigned long &ulr = ul0;
+
+template<bool T> struct selector;
+template<> struct selector<true> { typedef long type; };
+template<> struct selector<false> {typedef unsigned long type; };
+__typeof__(0U + 0L) ui_l0;
+selector<(sizeof(long) > sizeof(unsigned int))>::type &ui_lr = ui_l0;
+
+__typeof__(0 + 0L) l0;
+long &lr = l0;
+
+__typeof__(0 + 0U) u0;
+unsigned &ur = u0;
+
+__typeof__(0 + 0) i0;
+int &ir = i0;
diff --git a/clang/test/CXX/lex/lex.charset/p2-cxx11.cpp b/clang/test/CXX/lex/lex.charset/p2-cxx11.cpp
new file mode 100644
index 0000000..b9192ce
--- /dev/null
+++ b/clang/test/CXX/lex/lex.charset/p2-cxx11.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+char c00 = '\u0000'; // ok
+char c01 = '\u0001'; // ok
+char c1f = '\u001f'; // ok
+char c20 = '\u0020'; // ' ', ok
+char c22 = '\u0022'; // ", ok
+char c23 = '\u0023'; // #, ok
+char c24 = '\u0024'; // $, ok
+char c25 = '\u0025'; // %, ok
+char c27 = '\u0027'; // ', ok
+char c3f = '\u003f'; // ?, ok
+char c40 = '\u0040'; // @, ok
+char c41 = '\u0041'; // A, ok
+char c5f = '\u005f'; // _, ok
+char c60 = '\u0060'; // `, ok
+char c7e = '\u007e'; // ~, ok
+char c7f = '\u007f'; // ok
+
+wchar_t w007f = L'\u007f';
+wchar_t w0080 = L'\u0080';
+wchar_t w009f = L'\u009f';
+wchar_t w00a0 = L'\u00a0';
+
+wchar_t wd799 = L'\ud799';
+wchar_t wd800 = L'\ud800'; // expected-error {{invalid universal character}}
+wchar_t wdfff = L'\udfff'; // expected-error {{invalid universal character}}
+wchar_t we000 = L'\ue000';
+
+char32_t w10fffe = U'\U0010fffe';
+char32_t w10ffff = U'\U0010ffff';
+char32_t w110000 = U'\U00110000'; // expected-error {{invalid universal character}}
+
+const char *p1 = "\u0000\u0001\u001f\u0020\u0022\u0023\u0024\u0025\u0027\u003f\u0040\u0041\u005f\u0060\u007e\u007f";
+const wchar_t *p2 = L"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000";
+const char *p3 = u8"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000";
+const char16_t *p4 = u"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000";
+const char32_t *p5 = U"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000";
+const wchar_t *p6 = L"foo \U00110000 bar"; // expected-error {{invalid universal character}}
+const char *p7 = u8"foo \U0000d800 bar"; // expected-error {{invalid universal character}}
+const char16_t *p8 = u"foo \U0000dfff bar"; // expected-error {{invalid universal character}}
+const char32_t *p9 = U"foo \U0010ffff bar"; // ok
diff --git a/clang/test/CXX/lex/lex.charset/p2-cxx98.cpp b/clang/test/CXX/lex/lex.charset/p2-cxx98.cpp
new file mode 100644
index 0000000..a5b7ab6
--- /dev/null
+++ b/clang/test/CXX/lex/lex.charset/p2-cxx98.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -verify -std=c++98 %s
+
+char c00 = '\u0000'; // expected-error {{universal character name refers to a control character}}
+char c01 = '\u0001'; // expected-error {{universal character name refers to a control character}}
+char c1f = '\u001f'; // expected-error {{universal character name refers to a control character}}
+char c20 = '\u0020'; // ' ', expected-error {{character ' ' cannot be specified by a universal character name}}
+char c22 = '\u0022'; // ", expected-error {{character '"' cannot be specified by a universal character name}}
+char c23 = '\u0023'; // #, expected-error {{character '#' cannot be specified by a universal character name}}
+char c24 = '\u0024'; // $, ok
+char c25 = '\u0025'; // %, expected-error {{character '%' cannot be specified by a universal character name}}
+char c27 = '\u0027'; // ', expected-error {{character ''' cannot be specified by a universal character name}}
+char c3f = '\u003f'; // ?, expected-error {{character '?' cannot be specified by a universal character name}}
+char c40 = '\u0040'; // @, ok
+char c41 = '\u0041'; // A, expected-error {{character 'A' cannot be specified by a universal character name}}
+char c5f = '\u005f'; // _, expected-error {{character '_' cannot be specified by a universal character name}}
+char c60 = '\u0060'; // `, ok
+char c7e = '\u007e'; // ~, expected-error {{character '~' cannot be specified by a universal character name}}
+char c7f = '\u007f'; // expected-error {{universal character name refers to a control character}}
+
+wchar_t w007f = L'\u007f'; // expected-error {{universal character name refers to a control character}}
+wchar_t w0080 = L'\u0080'; // expected-error {{universal character name refers to a control character}}
+wchar_t w009f = L'\u009f'; // expected-error {{universal character name refers to a control character}}
+wchar_t w00a0 = L'\u00a0';
+
+wchar_t wd799 = L'\ud799';
+wchar_t wd800 = L'\ud800'; // expected-error {{invalid universal character}}
+wchar_t wdfff = L'\udfff'; // expected-error {{invalid universal character}}
+wchar_t we000 = L'\ue000';
+
+const char *s00 = "\u0000"; // expected-error {{universal character name refers to a control character}}
+const char *s01 = "\u0001"; // expected-error {{universal character name refers to a control character}}
+const char *s1f = "\u001f"; // expected-error {{universal character name refers to a control character}}
+const char *s20 = "\u0020"; // ' ', expected-error {{character ' ' cannot be specified by a universal character name}}
+const char *s22 = "\u0022"; // ", expected-error {{character '"' cannot be specified by a universal character name}}
+const char *s23 = "\u0023"; // #, expected-error {{character '#' cannot be specified by a universal character name}}
+const char *s24 = "\u0024"; // $, ok
+const char *s25 = "\u0025"; // %, expected-error {{character '%' cannot be specified by a universal character name}}
+const char *s27 = "\u0027"; // ', expected-error {{character ''' cannot be specified by a universal character name}}
+const char *s3f = "\u003f"; // ?, expected-error {{character '?' cannot be specified by a universal character name}}
+const char *s40 = "\u0040"; // @, ok
+const char *s41 = "\u0041"; // A, expected-error {{character 'A' cannot be specified by a universal character name}}
+const char *s5f = "\u005f"; // _, expected-error {{character '_' cannot be specified by a universal character name}}
+const char *s60 = "\u0060"; // `, ok
+const char *s7e = "\u007e"; // ~, expected-error {{character '~' cannot be specified by a universal character name}}
+const char *s7f = "\u007f"; // expected-error {{universal character name refers to a control character}}
+
+const wchar_t *ws007f = L"\u007f"; // expected-error {{universal character name refers to a control character}}
+const wchar_t *ws0080 = L"\u0080"; // expected-error {{universal character name refers to a control character}}
+const wchar_t *ws009f = L"\u009f"; // expected-error {{universal character name refers to a control character}}
+const wchar_t *ws00a0 = L"\u00a0";
+
+const wchar_t *wsd799 = L"\ud799";
+const wchar_t *wsd800 = L"\ud800"; // expected-error {{invalid universal character}}
+const wchar_t *wsdfff = L"\udfff"; // expected-error {{invalid universal character}}
+const wchar_t *wse000 = L"\ue000";
diff --git a/clang/test/CXX/lex/lex.literal/lex.ccon/p1.cpp b/clang/test/CXX/lex/lex.literal/lex.ccon/p1.cpp
new file mode 100644
index 0000000..5342153
--- /dev/null
+++ b/clang/test/CXX/lex/lex.literal/lex.ccon/p1.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Check types of char literals
+extern char a;
+extern __typeof('a') a;
+extern int b;
+extern __typeof('asdf') b;
+extern wchar_t c;
+extern __typeof(L'a') c;
+#if __cplusplus >= 201103L
+extern char16_t d;
+extern __typeof(u'a') d;
+extern char32_t e;
+extern __typeof(U'a') e;
+#endif
diff --git a/clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp b/clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp
new file mode 100644
index 0000000..1c227a1
--- /dev/null
+++ b/clang/test/CXX/lex/lex.literal/lex.ext/p1.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+void operator "" p31(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+void operator "" _p31(long double);
+long double operator "" pi(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+
+float hexfloat = 0x1p31; // allow hexfloats
diff --git a/clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp b/clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp
new file mode 100644
index 0000000..1b5d388
--- /dev/null
+++ b/clang/test/CXX/lex/lex.literal/lex.ext/p10.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+using size_t = decltype(sizeof(int));
+void operator "" wibble(const char *); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}}
+void operator "" wibble(const char *, size_t); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}}
+
+template<typename T>
+void f() {
+ // A program containing a reserved ud-suffix is ill-formed.
+ 123wibble; // expected-error {{invalid suffix 'wibble'}}
+ 123.0wibble; // expected-error {{invalid suffix 'wibble'}}
+ const char *p = ""wibble; // expected-error {{invalid suffix on literal; C++11 requires a space between literal and identifier}} expected-error {{expected ';'}}
+ const char *q = R"x("hello")x"wibble; // expected-error {{invalid suffix on literal; C++11 requires a space between literal and identifier}} expected-error {{expected ';'}}
+}
diff --git a/clang/test/CXX/lex/lex.literal/lex.ext/p2.cpp b/clang/test/CXX/lex/lex.literal/lex.ext/p2.cpp
new file mode 100644
index 0000000..3f3f796
--- /dev/null
+++ b/clang/test/CXX/lex/lex.literal/lex.ext/p2.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+typedef decltype(sizeof(int)) size_t;
+
+// FIXME: These diagnostics should say 'size_t' instead of 'unsigned long'
+int a = 123_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'unsigned long long' or 'const char *', and no matching literal operator template}}
+int b = 4.2_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'long double' or 'const char *', and no matching literal operator template}}
+int c = "foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char *' and 'unsigned}}
+int d = L"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const wchar_t *' and 'unsigned}}
+int e = u8"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char *' and 'unsigned}}
+int f = u"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char16_t *' and 'unsigned}}
+int g = U"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char32_t *' and 'unsigned}}
+int h = 'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'char'}}
+int i = L'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'wchar_t'}}
+int j = u'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'char16_t'}}
+int k = U'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'char32_t'}}
diff --git a/clang/test/CXX/lex/lex.literal/lex.ext/p3.cpp b/clang/test/CXX/lex/lex.literal/lex.ext/p3.cpp
new file mode 100644
index 0000000..43f3468
--- /dev/null
+++ b/clang/test/CXX/lex/lex.literal/lex.ext/p3.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+int &operator "" _x1 (unsigned long long);
+int &i1 = 0x123_x1;
+
+double &operator "" _x1 (const char *);
+int &i2 = 45_x1;
+
+template<char...> char &operator "" _x1 ();
+int &i3 = 0377_x1;
+
+int &i4 = 90000000000000000000000000000000000000000000000_x1; // expected-warning {{integer constant is too large}}
+
+double &operator "" _x2 (const char *);
+double &i5 = 123123123123123123123123123123123123123123123_x2;
+
+template<char...Cs> constexpr int operator "" _x3() { return sizeof...(Cs); }
+static_assert(123456789012345678901234567890123456789012345678901234567890_x3 == 60, "");
diff --git a/clang/test/CXX/lex/lex.literal/lex.ext/p4.cpp b/clang/test/CXX/lex/lex.literal/lex.ext/p4.cpp
new file mode 100644
index 0000000..011e832
--- /dev/null
+++ b/clang/test/CXX/lex/lex.literal/lex.ext/p4.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+int &operator "" _x1 (long double);
+int &i1 = 0.123_x1;
+
+double &operator "" _x1 (const char *);
+int &i2 = 45._x1;
+
+template<char...> char &operator "" _x1 ();
+int &i3 = 0377e-1_x1;
+
+int &i4 = 1e1000000_x1; // expected-warning {{too large for type 'long double'}}
+
+double &operator "" _x2 (const char *);
+double &i5 = 1e1000000_x2;
+
+template<char...Cs> constexpr int operator "" _x3() { return sizeof...(Cs); }
+static_assert(1e1000000_x3 == 9, "");
diff --git a/clang/test/CXX/lex/lex.literal/lex.ext/p5.cpp b/clang/test/CXX/lex/lex.literal/lex.ext/p5.cpp
new file mode 100644
index 0000000..4655aa1
--- /dev/null
+++ b/clang/test/CXX/lex/lex.literal/lex.ext/p5.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+using size_t = decltype(sizeof(int));
+
+int &operator "" _x1 (const char *);
+double &operator "" _x1 (const char *, size_t);
+double &i1 = "foo"_x1;
+double &i2 = u8"foo"_x1;
+double &i3 = L"foo"_x1; // expected-error {{no matching literal operator}}
+
+char &operator "" _x1(const wchar_t *, size_t);
+char &i4 = L"foo"_x1; // ok
+double &i5 = R"(foo)"_x1; // ok
diff --git a/clang/test/CXX/lex/lex.literal/lex.ext/p6.cpp b/clang/test/CXX/lex/lex.literal/lex.ext/p6.cpp
new file mode 100644
index 0000000..23cd708
--- /dev/null
+++ b/clang/test/CXX/lex/lex.literal/lex.ext/p6.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+using size_t = decltype(sizeof(int));
+
+int &operator "" _x1 (const char *);
+double &i1 = 'a'_x1; // expected-error {{no matching literal operator}}
+double &operator "" _x1 (wchar_t);
+double &i2 = L'a'_x1;
+double &i3 = 'a'_x1; // expected-error {{no matching literal operator}}
+double &i4 = operator"" _x1('a'); // ok
+
+char &operator "" _x1(char16_t);
+char &i5 = u'a'_x1; // ok
+double &i6 = L'a'_x1; // ok
diff --git a/clang/test/CXX/lex/lex.literal/lex.ext/p7.cpp b/clang/test/CXX/lex/lex.literal/lex.ext/p7.cpp
new file mode 100644
index 0000000..79c9394
--- /dev/null
+++ b/clang/test/CXX/lex/lex.literal/lex.ext/p7.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+using size_t = decltype(sizeof(int));
+namespace std {
+ struct string {};
+}
+
+template<typename T, typename U> struct same_type;
+template<typename T> struct same_type<T, T> {};
+
+namespace std_example {
+
+long double operator "" _w(long double);
+std::string operator "" _w(const char16_t*, size_t);
+unsigned operator "" _w(const char*);
+int main() {
+ auto v1 = 1.2_w; // calls operator "" _w(1.2L)
+ auto v2 = u"one"_w; // calls operator "" _w(u"one", 3)
+ auto v3 = 12_w; // calls operator "" _w("12")
+ "two"_w; // expected-error {{no matching literal operator}}
+
+ same_type<decltype(v1), long double> test1;
+ same_type<decltype(v2), std::string> test2;
+ same_type<decltype(v3), unsigned> test3;
+}
+
+}
diff --git a/clang/test/CXX/lex/lex.literal/lex.ext/p8.cpp b/clang/test/CXX/lex/lex.literal/lex.ext/p8.cpp
new file mode 100644
index 0000000..d907822
--- /dev/null
+++ b/clang/test/CXX/lex/lex.literal/lex.ext/p8.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+using size_t = decltype(sizeof(int));
+constexpr const char *operator "" _id(const char *p, size_t) { return p; }
+constexpr const char *s = "foo"_id "bar" "baz"_id "quux";
+
+constexpr bool streq(const char *p, const char *q) {
+ return *p == *q && (!*p || streq(p+1, q+1));
+}
+static_assert(streq(s, "foobarbazquux"), "");
+
+constexpr const char *operator "" _trim(const char *p, size_t n) {
+ return *p == ' ' ? operator "" _trim(p + 1, n - 1) : p;
+}
+constexpr const char *t = " " " "_trim " foo";
+static_assert(streq(t, "foo"), "");
+
+const char *u = "foo" "bar"_id "baz" "quux"_di "corge"; // expected-error {{differing user-defined suffixes ('_id' and '_di') in string literal concatenation}}
diff --git a/clang/test/CXX/lex/lex.literal/lex.ext/p9.cpp b/clang/test/CXX/lex/lex.literal/lex.ext/p9.cpp
new file mode 100644
index 0000000..65e27b4
--- /dev/null
+++ b/clang/test/CXX/lex/lex.literal/lex.ext/p9.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+using size_t = decltype(sizeof(int));
+void operator "" _x(const wchar_t *, size_t);
+
+namespace std_example {
+
+int main() {
+ L"A" "B" "C"_x;
+ "P"_x "Q" "R"_y; // expected-error {{differing user-defined suffixes ('_x' and '_y') in string literal concatenation}}
+}
+
+}
diff --git a/clang/test/CXX/lex/lex.pptoken/p3-0x.cpp b/clang/test/CXX/lex/lex.pptoken/p3-0x.cpp
new file mode 100644
index 0000000..3d56ac1
--- /dev/null
+++ b/clang/test/CXX/lex/lex.pptoken/p3-0x.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+int a<::> = { 1, 2, 3 };
+int b = a<:::a<:0:>:>;
+bool c = a<:0:><::b;
+
+template<int &n> void f() {}
+template void f<::b>();
+
+#define x a<:: ## : b :>
+int d = x; // expected-error {{pasting formed ':::', an invalid preprocessing token}} expected-error {{expected unqualified-id}}
diff --git a/clang/test/CXX/lex/lex.trigraph/p1.cpp b/clang/test/CXX/lex/lex.trigraph/p1.cpp
new file mode 100644
index 0000000..aacbc55
--- /dev/null
+++ b/clang/test/CXX/lex/lex.trigraph/p1.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -trigraphs -Wtrigraphs -verify %s
+
+??=pragma // expected-warning {{trigraph converted to '#' character}}
+
+int a = '??/0'; // expected-warning {{trigraph converted to '\' character}}
+
+int b = 1 ??' 0; // expected-warning {{trigraph converted to '^' character}}
+
+int c ??(1]; // expected-warning {{trigraph converted to '[' character}}
+
+int d [1??); // expected-warning {{trigraph converted to ']' character}}
+
+int e = 1 ??! 0; // expected-warning {{trigraph converted to '|' character}}
+
+void f() ??<} // expected-warning {{trigraph converted to '{' character}}
+
+void g() {??> // expected-warning {{trigraph converted to '}' character}}
+
+int h = ??- 0; // expected-warning {{trigraph converted to '~' character}}
diff --git a/clang/test/CXX/lex/lex.trigraph/p2.cpp b/clang/test/CXX/lex/lex.trigraph/p2.cpp
new file mode 100644
index 0000000..7d11d5b
--- /dev/null
+++ b/clang/test/CXX/lex/lex.trigraph/p2.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -trigraphs -Wtrigraphs -verify %s
+
+??=define arraycheck(a,b) a??(b??) ??!??! b??(a??) // expected-warning {{trigraph converted to '#' character}} expected-warning {{trigraph converted to '[' character}} expected-warning {{trigraph converted to ']' character}} expected-warning {{trigraph converted to '|' character}} expected-warning {{trigraph converted to '|' character}} expected-warning {{trigraph converted to '[' character}} expected-warning {{trigraph converted to ']' character}}
diff --git a/clang/test/CXX/lex/lex.trigraph/p3.cpp b/clang/test/CXX/lex/lex.trigraph/p3.cpp
new file mode 100644
index 0000000..2be0328
--- /dev/null
+++ b/clang/test/CXX/lex/lex.trigraph/p3.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -trigraphs -Wtrigraphs -verify %s
+
+char a[] =
+"?? ??\"??#??$??%??&??*??+??,??.??0??1??2??3??4??5??6"
+"??7??8??9??:??;?????@??A??B??C??D??E??F??G??H??I??J"
+"??K??L??M??N??O??P??Q??R??S??T??U??V??W??X??Y??Z??["
+"??\\??]??^??_??`??a??b??c??d??e??f??g??h??i??j??k??l"
+"??m??n??o??p??q??r??s??t??u??v??w??x??y??z??{??|??}??~";
diff --git a/clang/test/CXX/over/over.built/p1.cpp b/clang/test/CXX/over/over.built/p1.cpp
new file mode 100644
index 0000000..6000f5b
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p1.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+enum E1 { one };
+enum E2 { two };
+
+bool operator >= (E1, E1) {
+ return false;
+}
+
+bool operator >= (E1, const E2) {
+ return false;
+}
+
+bool test(E1 a, E1 b, E2 c) {
+ return a >= b || a >= c;
+}
diff --git a/clang/test/CXX/over/over.built/p23.cpp b/clang/test/CXX/over/over.built/p23.cpp
new file mode 100644
index 0000000..4125521
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p23.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+struct Variant {
+ template <typename T> operator T();
+};
+
+Variant getValue();
+
+void testVariant() {
+ bool ret1 = getValue() || getValue();
+ bool ret2 = getValue() && getValue();
+ bool ret3 = !getValue();
+}
+
+struct ExplicitVariant {
+ template <typename T> explicit operator T();
+};
+
+ExplicitVariant getExplicitValue();
+
+void testExplicitVariant() {
+ bool ret1 = getExplicitValue() || getExplicitValue();
+ bool ret2 = getExplicitValue() && getExplicitValue();
+ bool ret3 = !getExplicitValue();
+}
diff --git a/clang/test/CXX/over/over.built/p25.cpp b/clang/test/CXX/over/over.built/p25.cpp
new file mode 100644
index 0000000..aea3854
--- /dev/null
+++ b/clang/test/CXX/over/over.built/p25.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+enum class Color { Red, Green, Blue };
+
+struct ConvertsToColorA {
+ operator Color();
+};
+
+struct ConvertsToColorB {
+ operator Color();
+};
+
+Color foo(bool cond, ConvertsToColorA ca, ConvertsToColorB cb) {
+ return cond? ca : cb;
+}
diff --git a/clang/test/CXX/over/over.load/p2-0x.cpp b/clang/test/CXX/over/over.load/p2-0x.cpp
new file mode 100644
index 0000000..cf38741
--- /dev/null
+++ b/clang/test/CXX/over/over.load/p2-0x.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Member function declarations with the same name and the same
+// parameter-type-list as well as mem- ber function template
+// declarations with the same name, the same parameter-type-list, and
+// the same template parameter lists cannot be overloaded if any of
+// them, but not all, have a ref-qualifier (8.3.5).
+
+class Y {
+ void h() &;
+ void h() const &;
+ void h() &&;
+ void i() &; // expected-note{{previous declaration}}
+ void i() const; // expected-error{{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&'}}
+
+ template<typename T> void f(T*) &;
+ template<typename T> void f(T*) &&;
+
+ template<typename T> void g(T*) &; // expected-note{{previous declaration}}
+ template<typename T> void g(T*); // expected-error{{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&'}}
+
+ void k(); // expected-note{{previous declaration}}
+ void k() &&; // expected-error{{cannot overload a member function with ref-qualifier '&&' with a member function without a ref-qualifier}}
+};
diff --git a/clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp b/clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp
new file mode 100644
index 0000000..ea059ce
--- /dev/null
+++ b/clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// rdar://problem/11120365
+namespace test0 {
+ template <class T> struct A {
+ static void foo(const T &t) {}
+ static void foo(T &&t) {
+ t.foo(); // expected-error {{member reference base type 'int' is not a structure or union}}
+ }
+ };
+
+ void test() {
+ A<int>::foo({}); // expected-note {{requested here}}
+ }
+}
diff --git a/clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp b/clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp
new file mode 100644
index 0000000..1c71468
--- /dev/null
+++ b/clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+namespace PR6285 {
+ template<typename T> struct identity
+ { typedef T type; };
+
+ struct D {
+ template<typename T = short>
+ operator typename identity<T>::type(); // expected-note{{candidate}}
+ };
+
+ int f() { return D(); } // expected-error{{no viable conversion}}
+}
+
diff --git a/clang/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp b/clang/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp
new file mode 100644
index 0000000..3971acc
--- /dev/null
+++ b/clang/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+namespace std_example {
+ int i;
+ int f1();
+ int&& f2();
+ int &g(const int &);
+ float &g(const int &&);
+ int &j = g(i);
+ float &k = g(f1());
+ float &l = g(f2());
+
+ int &g2(const int &);
+ float &g2(int &&);
+ int &j2 = g2(i);
+ float &k2 = g2(f1());
+ float &l2 = g2(f2());
+
+ // FIXME: We don't support ref-qualifiers yet.
+#if 0
+ struct A {
+ A& operator<<(int);
+ void p() &;
+ void p() &&;
+ };
+
+ A& operator<<(A&&, char);
+ A() << 1;
+ A() << 'c';
+ A a;
+ a << 1;
+ a << 'c';
+ A().p();
+ a.p();
+#endif
+}
+
+template<typename T>
+struct remove_reference {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_reference<T&> {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_reference<T&&> {
+ typedef T type;
+};
+
+namespace FunctionReferencesOverloading {
+ template<typename T> int &f(typename remove_reference<T>::type&);
+ template<typename T> float &f(typename remove_reference<T>::type&&);
+
+ void test_f(int (&func_ref)(int)) {
+ int &ir = f<int (&)(int)>(func_ref);
+ }
+}
diff --git a/clang/test/CXX/over/over.match/over.match.best/p1.cpp b/clang/test/CXX/over/over.match/over.match.best/p1.cpp
new file mode 100644
index 0000000..5c315a7
--- /dev/null
+++ b/clang/test/CXX/over/over.match/over.match.best/p1.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> int &f0(T*, int);
+float &f0(void*, int);
+
+void test_f0(int* ip, void *vp) {
+ // One argument is better...
+ int &ir = f0(ip, 0);
+
+ // Prefer non-templates to templates
+ float &fr = f0(vp, 0);
+}
+
+// Partial ordering of function template specializations will be tested
+// elsewhere
+// FIXME: Initialization by user-defined conversion is tested elsewhere
diff --git a/clang/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp b/clang/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp
new file mode 100644
index 0000000..31a679f
--- /dev/null
+++ b/clang/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify
+
+namespace ExplicitConv {
+ struct X { }; // expected-note 2{{candidate constructor}}
+
+ struct Y {
+ explicit operator X() const;
+ };
+
+ void test(const Y& y) {
+ X x(static_cast<X>(y));
+ X x2((X)y);
+ X x3 = y; // expected-error{{no viable conversion from 'const ExplicitConv::Y' to 'ExplicitConv::X'}}
+ }
+}
+
+namespace DR899 {
+ struct C { }; // expected-note 2 {{candidate constructor}}
+
+ struct A {
+ explicit operator int() const;
+ explicit operator C() const;
+ };
+
+ struct B {
+ int i;
+ B(const A& a): i(a) { }
+ };
+
+ int main() {
+ A a;
+ int i = a; // expected-error{{no viable conversion}}
+ int j(a);
+ C c = a; // expected-error{{no viable conversion}}
+ C c2(a);
+ }
+}
diff --git a/clang/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp b/clang/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp
new file mode 100644
index 0000000..3845af0
--- /dev/null
+++ b/clang/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<typename T> T &lvalue();
+template<typename T> T &&xvalue();
+template<typename T> T prvalue();
+
+struct X0 {
+ int &f() &;
+ float &f() &&;
+
+ template<typename T> int &ft(T) &;
+ template<typename T> float &ft(T) &&;
+
+ typedef int &(*func_int_ref)();
+ typedef float &(*func_float_ref)();
+
+ operator func_int_ref() &;
+ operator func_float_ref() &&;
+
+ void g();
+
+ int &operator+(const X0&) &;
+ float &operator+(const X0&) &&;
+
+ template<typename T> int &operator+(const T&) &;
+ template<typename T> float &operator+(const T&) &&;
+
+ int &h() const&;
+ float &h() &&;
+ int &h2() const&;
+ float &h2() const&&;
+};
+
+void X0::g() {
+ int &ir1 = f();
+ int &ir2 = X0::f();
+}
+
+void test_ref_qualifier_binding() {
+ int &ir1 = lvalue<X0>().f();
+ float &fr1 = xvalue<X0>().f();
+ float &fr2 = prvalue<X0>().f();
+ int &ir2 = lvalue<X0>().ft(1);
+ float &fr3 = xvalue<X0>().ft(2);
+ float &fr4 = prvalue<X0>().ft(3);
+}
+
+void test_ref_qualifier_binding_with_surrogates() {
+ int &ir1 = lvalue<X0>()();
+ float &fr1 = xvalue<X0>()();
+ float &fr2 = prvalue<X0>()();
+}
+
+void test_ref_qualifier_binding_operators() {
+ int &ir1 = lvalue<X0>() + prvalue<X0>();
+ float &fr1 = xvalue<X0>() + prvalue<X0>();
+ float &fr2 = prvalue<X0>() + prvalue<X0>();
+ int &ir2 = lvalue<X0>() + 1;
+ float &fr3 = xvalue<X0>() + 2;
+ float &fr4 = prvalue<X0>() + 3;
+}
+
+void test_ref_qualifier_overloading() {
+ int &ir1 = lvalue<X0>().h();
+ float &fr1 = xvalue<X0>().h();
+ float &fr2 = prvalue<X0>().h();
+ int &ir2 = lvalue<X0>().h2();
+ float &fr3 = xvalue<X0>().h2();
+ float &fr4 = prvalue<X0>().h2();
+}
diff --git a/clang/test/CXX/over/over.oper/over.literal/p2.cpp b/clang/test/CXX/over/over.oper/over.literal/p2.cpp
new file mode 100644
index 0000000..c012104
--- /dev/null
+++ b/clang/test/CXX/over/over.oper/over.literal/p2.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+void operator "" _a(const char *);
+
+namespace N {
+ using ::operator "" _a;
+
+ void operator "" _b(const char *);
+}
+
+using N::operator "" _b;
+
+class C {
+ void operator "" _c(const char *); // expected-error {{must be in a namespace or global scope}}
+
+ static void operator "" _c(unsigned long long); // expected-error {{must be in a namespace or global scope}}
+
+ friend void operator "" _d(const char *);
+};
+
+int operator "" _e; // expected-error {{cannot be the name of a variable}}
+
+void f() {
+ int operator "" _f; // expected-error {{cannot be the name of a variable}}
+}
+
+extern "C++" {
+ void operator "" _g(const char *);
+}
+
+template<char...> void operator "" _h() {}
+
+template<> void operator "" _h<'a', 'b', 'c'>() {}
+
+template void operator "" _h<'a', 'b', 'c', 'd'>();
diff --git a/clang/test/CXX/over/over.oper/over.literal/p3.cpp b/clang/test/CXX/over/over.oper/over.literal/p3.cpp
new file mode 100644
index 0000000..674ace9
--- /dev/null
+++ b/clang/test/CXX/over/over.oper/over.literal/p3.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+using size_t = decltype(sizeof(int));
+
+// Acceptable parameter declarations
+char operator "" _a(const char *);
+char operator "" _a(const char []);
+char operator "" _a(unsigned long long);
+char operator "" _a(long double);
+char operator "" _a(char);
+char operator "" _a(const volatile char);
+char operator "" _a(wchar_t);
+char operator "" _a(char16_t);
+char operator "" _a(char32_t);
+char operator "" _a(const char *, size_t);
+char operator "" _a(const wchar_t *, size_t);
+char operator "" _a(const char16_t *, size_t);
+char operator "" _a(const char32_t *, size_t);
+char operator "" _a(const char [32], size_t);
+
+// Unacceptable parameter declarations
+char operator "" _b(); // expected-error {{parameter}}
+char operator "" _b(const wchar_t *); // expected-error {{parameter}}
+char operator "" _b(long long); // expected-error {{parameter}}
+char operator "" _b(double); // expected-error {{parameter}}
+char operator "" _b(short); // expected-error {{parameter}}
+char operator "" _a(char, int = 0); // expected-error {{parameter}}
+char operator "" _b(unsigned short); // expected-error {{parameter}}
+char operator "" _b(signed char); // expected-error {{parameter}}
+char operator "" _b(unsigned char); // expected-error {{parameter}}
+char operator "" _b(const short *, size_t); // expected-error {{parameter}}
+char operator "" _b(const unsigned short *, size_t); // expected-error {{parameter}}
+char operator "" _b(const signed char *, size_t); // expected-error {{parameter}}
+char operator "" _b(const unsigned char *, size_t); // expected-error {{parameter}}
+char operator "" _a(const volatile char *, size_t); // expected-error {{parameter}}
+char operator "" _a(volatile wchar_t *, size_t); // expected-error {{parameter}}
+char operator "" _a(char16_t *, size_t); // expected-error {{parameter}}
+char operator "" _a(const char32_t *, size_t, bool = false); // expected-error {{parameter}}
+char operator "" _a(const char *, signed long); // expected-error {{parameter}}
+char operator "" _a(const char *, size_t = 0); // expected-error {{default argument}}
diff --git a/clang/test/CXX/over/over.oper/over.literal/p5.cpp b/clang/test/CXX/over/over.oper/over.literal/p5.cpp
new file mode 100644
index 0000000..66f3f97
--- /dev/null
+++ b/clang/test/CXX/over/over.oper/over.literal/p5.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+using size_t = decltype(sizeof(int));
+template<char...> struct S {};
+
+template<char...> void operator "" _a();
+template<char... C> S<C...> operator "" _a();
+
+template<typename T> struct U {
+ friend int operator "" _a(const char *, size_t);
+ // FIXME: It's not entirely clear whether this is intended to be legal.
+ friend U operator "" _a(const T *, size_t); // expected-error {{parameter}}
+};
+template<char...> struct V {
+ friend void operator "" _b(); // expected-error {{parameter}}
+};
+
+template<char... C, int N = 0> void operator "" _b(); // expected-error {{parameter}}
+template<char... C> void operator "" _b(int N = 0); // expected-error {{parameter}}
+template<char, char...> void operator "" _b(); // expected-error {{parameter}}
+template<typename T> T operator "" _b(const char *); // expected-error {{parameter}}
+template<typename T> int operator "" _b(const T *, size_t); // expected-error {{parameter}}
diff --git a/clang/test/CXX/over/over.oper/over.literal/p6.cpp b/clang/test/CXX/over/over.oper/over.literal/p6.cpp
new file mode 100644
index 0000000..6bfb856
--- /dev/null
+++ b/clang/test/CXX/over/over.oper/over.literal/p6.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+extern "C" void operator "" _a(const char *); // expected-error {{must have C++ linkage}}
+extern "C" template<char...> void operator "" _b(); // expected-error {{must have C++ linkage}}
+
+extern "C" {
+ void operator "" _c(const char *); // expected-error {{must have C++ linkage}}
+ template<char...> void operator "" _d(); // expected-error {{must have C++ linkage}}
+ namespace N {
+ void operator "" _e(const char *); // expected-error {{must have C++ linkage}}
+ template<char...> void operator "" _f(); // expected-error {{must have C++ linkage}}
+ }
+}
diff --git a/clang/test/CXX/over/over.oper/over.literal/p7.cpp b/clang/test/CXX/over/over.oper/over.literal/p7.cpp
new file mode 100644
index 0000000..72411b9
--- /dev/null
+++ b/clang/test/CXX/over/over.oper/over.literal/p7.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+constexpr int operator "" _a(const char *c) {
+ return c[0];
+}
+
+static_assert(operator "" _a("foo") == 'f', "");
+
+void puts(const char *);
+static inline void operator "" _puts(const char *c) {
+ puts(c);
+}
+void f() {
+ operator "" _puts("foo");
+ operator "" _puts("bar");
+}
diff --git a/clang/test/CXX/over/over.oper/over.literal/p8.cpp b/clang/test/CXX/over/over.oper/over.literal/p8.cpp
new file mode 100644
index 0000000..3f76082
--- /dev/null
+++ b/clang/test/CXX/over/over.oper/over.literal/p8.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+struct string;
+namespace std {
+ using size_t = decltype(sizeof(int));
+}
+
+void operator "" _km(long double); // ok
+string operator "" _i18n(const char*, std::size_t); // ok
+// FIXME: This should be accepted once we support UCNs
+template<char...> int operator "" \u03C0(); // ok, UCN for lowercase pi // expected-error {{expected identifier}}
+float operator ""E(const char *); // expected-error {{C++11 requires a space between literal and identifier}} expected-warning {{reserved}}
+float operator " " B(const char *); // expected-error {{must be '""'}} expected-warning {{reserved}}
+string operator "" 5X(const char *, std::size_t); // expected-error {{expected identifier}}
+double operator "" _miles(double); // expected-error {{parameter}}
+template<char...> int operator "" j(const char*); // expected-error {{parameter}}
+
+// FIXME: Accept this as an extension, with a fix-it to add the space
+float operator ""_E(const char *); // expected-error {{C++11 requires a space between the "" and the user-defined suffix in a literal operator}}
diff --git a/clang/test/CXX/over/over.over/p1.cpp b/clang/test/CXX/over/over.over/p1.cpp
new file mode 100644
index 0000000..10c60da
--- /dev/null
+++ b/clang/test/CXX/over/over.over/p1.cpp
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+template<typename T> T f0(T);
+int f0(int);
+
+// -- an object or reference being initialized
+struct S {
+ int (*f0)(int);
+ float (*f1)(float);
+};
+
+void test_init_f0() {
+ int (*f0a)(int) = f0;
+ int (*f0b)(int) = &f0;
+ int (*f0c)(int) = (f0);
+ float (*f0d)(float) = f0;
+ float (*f0e)(float) = &f0;
+ float (*f0f)(float) = (f0);
+ int (&f0g)(int) = f0;
+ int (&f0h)(int) = (f0);
+ float (&f0i)(float) = f0;
+ float (&f0j)(float) = (f0);
+ S s = { f0, f0 };
+}
+
+// -- the left side of an assignment (5.17),
+void test_assign_f0() {
+ int (*f0a)(int) = 0;
+ float (*f0b)(float) = 0;
+
+ f0a = f0;
+ f0a = &f0;
+ f0a = (f0);
+ f0b = f0;
+ f0b = &f0;
+ f0b = (f0);
+}
+
+// -- a parameter of a function (5.2.2),
+void eat_f0(int a(int), float (*b)(float), int (&c)(int), float (&d)(float));
+
+void test_pass_f0() {
+ eat_f0(f0, f0, f0, f0);
+ eat_f0(&f0, &f0, (f0), (f0));
+}
+
+// -- a parameter of a user-defined operator (13.5),
+struct X { };
+void operator+(X, int(int));
+void operator-(X, float(*)(float));
+void operator*(X, int (&)(int));
+void operator/(X, float (&)(float));
+
+void test_operator_pass_f0(X x) {
+ x + f0;
+ x + &f0;
+ x - f0;
+ x - &f0;
+ x * f0;
+ x * (f0);
+ x / f0;
+ x / (f0);
+}
+
+// -- the return value of a function, operator function, or conversion (6.6.3),
+int (*test_return_f0_a())(int) { return f0; }
+int (*test_return_f0_b())(int) { return &f0; }
+int (*test_return_f0_c())(int) { return (f0); }
+float (*test_return_f0_d())(float) { return f0; }
+float (*test_return_f0_e())(float) { return &f0; }
+float (*test_return_f0_f())(float) { return (f0); }
+
+// -- an explicit type conversion (5.2.3, 5.2.9, 5.4), or
+void test_convert_f0() {
+ (void)((int (*)(int))f0);
+ (void)((int (*)(int))&f0);
+ (void)((int (*)(int))(f0));
+ (void)((float (*)(float))f0);
+ (void)((float (*)(float))&f0);
+ (void)((float (*)(float))(f0));
+}
+
+// -- a non-type template-parameter(14.3.2).
+template<int(int)> struct Y0 { };
+template<float(float)> struct Y1 { };
+template<int (&)(int)> struct Y2 { };
+template<float (&)(float)> struct Y3 { };
+
+Y0<f0> y0;
+Y0<&f0> y0a;
+Y1<f0> y1;
+Y1<&f0> y1a;
+Y2<f0> y2;
+Y3<f0> y3;
diff --git a/clang/test/CXX/over/over.over/p2-resolve-single-template-id.cpp b/clang/test/CXX/over/over.over/p2-resolve-single-template-id.cpp
new file mode 100644
index 0000000..e021711
--- /dev/null
+++ b/clang/test/CXX/over/over.over/p2-resolve-single-template-id.cpp
@@ -0,0 +1,191 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-bool-conversion %s
+
+typedef __typeof__(((int*)0)-((int*)0)) ptrdiff_t;
+
+namespace DontResolveTooEarly_WaitForOverloadResolution
+{
+ template <class T> T* f(int); // #1
+ template <class T, class U> T& f(U); // #2
+
+ void g() {
+ int *ip = f<int>(1); // calls #1
+ }
+
+ template <class T>
+ T* f2(int);
+ template <class T, class U>
+ T& f2(U);
+
+ void g2() {
+ int*ip = (f2<int>)(1); // ok
+ }
+
+} // End namespace
+
+namespace DontAllowUnresolvedOverloadedExpressionInAnUnusedExpression
+{
+ void one() { }
+ template<class T> void oneT() { }
+
+ void two() { } // expected-note 2 {{possible target for call}}
+ void two(int) { } // expected-note 2 {{possible target for call}}
+ template<class T> void twoT() { } // expected-note 2 {{possible target for call}}
+ template<class T> void twoT(T) { } // expected-note 2 {{possible target for call}}
+
+ void check()
+ {
+ one; // expected-warning {{expression result unused}}
+ two; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
+ oneT<int>; // expected-warning {{expression result unused}}
+ twoT<int>; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
+ }
+
+ // check the template function case
+ template<class T> void check()
+ {
+ one; // expected-warning {{expression result unused}}
+ two; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
+ oneT<int>; // expected-warning {{expression result unused}}
+ twoT<int>; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
+
+ }
+
+}
+
+ template<typename T>
+ void twoT() { }
+ template<typename T, typename U>
+ void twoT(T) { }
+
+
+ void two() { }; //expected-note 5{{candidate}}
+ void two(int) { }; //expected-note 5{{candidate}}
+
+
+
+ void one() { }
+ template<class T>
+ void oneT() { }
+
+ template<class T>
+ void cant_resolve() { } //expected-note 3{{candidate}}
+
+ template<class T> void cant_resolve(T) { }//expected-note 3{{candidate}}
+
+
+int main()
+{
+
+ { static_cast<void>(one); }
+ { (void)(one); }
+ { static_cast<void>(oneT<int>); }
+ { (void)(oneT<int>); }
+
+ { static_cast<void>(two); } // expected-error {{address of overloaded function 'two' cannot be static_cast to type 'void'}}
+ { (void)(two); } // expected-error {{address of overloaded function 'two' cannot be cast to type 'void'}}
+ { static_cast<void>(twoT<int>); }
+ { (void)(twoT<int>); }
+
+
+ { ptrdiff_t x = reinterpret_cast<ptrdiff_t>(oneT<int>); }
+ { (void) reinterpret_cast<int (*)(char, double)>(oneT<int>); }
+ { (void) reinterpret_cast<ptrdiff_t>(one); }
+ { (void) reinterpret_cast<int (*)(char, double)>(one); }
+
+ { ptrdiff_t x = reinterpret_cast<ptrdiff_t>(twoT<int>); }
+ { (void) reinterpret_cast<int (*)(char, double)>(twoT<int>); }
+ { (void) reinterpret_cast<void (*)(int)>(two); } //expected-error {{reinterpret_cast}}
+ { (void) static_cast<void (*)(int)>(two); } //ok
+
+ { (void) reinterpret_cast<int>(two); } //expected-error {{reinterpret_cast}}
+ { (void) reinterpret_cast<int (*)(char, double)>(two); } //expected-error {{reinterpret_cast}}
+
+ { bool b = (twoT<int>); }
+ { bool b = (twoT<int, int>); }
+
+ { bool b = &twoT<int>; //&foo<int>; }
+ b = &(twoT<int>); }
+
+ { ptrdiff_t x = (ptrdiff_t) &twoT<int>;
+ x = (ptrdiff_t) &twoT<int>; }
+
+ { ptrdiff_t x = (ptrdiff_t) twoT<int>;
+ x = (ptrdiff_t) twoT<int>; }
+
+
+ { ptrdiff_t x = (ptrdiff_t) &twoT<int,int>;
+ x = (ptrdiff_t) &twoT<int>; }
+
+ { oneT<int>; &oneT<int>; } //expected-warning 2{{expression result unused}}
+ { static_cast<void>(cant_resolve<int>); } // expected-error {{address of overload}}
+ { bool b = cant_resolve<int>; } // expected-error {{address of overload}}
+ { (void) cant_resolve<int>; } // expected-error {{address of overload}}
+
+}
+
+namespace member_pointers {
+ struct S {
+ template <typename T> bool f(T) { return false; }
+ template <typename T> static bool g(T) { return false; }
+
+ template <typename T> bool h(T) { return false; } // expected-note 3 {{possible target for call}}
+ template <int N> static bool h(int) { return false; } // expected-note 3 {{possible target for call}}
+ };
+
+ void test(S s) {
+ if (S::f<char>) return; // expected-error {{call to non-static member function without an object argument}}
+ if (S::f<int>) return; // expected-error {{call to non-static member function without an object argument}}
+ if (&S::f<char>) return;
+ if (&S::f<int>) return;
+ if (s.f<char>) return; // expected-error {{reference to non-static member function must be called}}
+ if (s.f<int>) return; // expected-error {{reference to non-static member function must be called}}
+ if (&s.f<char>) return; // expected-error {{cannot create a non-constant pointer to member function}}
+ if (&s.f<int>) return; // expected-error {{cannot create a non-constant pointer to member function}}
+
+ if (S::g<char>) return;
+ if (S::g<int>) return;
+ if (&S::g<char>) return;
+ if (&S::g<int>) return;
+ if (s.g<char>) return;
+ if (s.g<int>) return;
+ if (&s.g<char>) return;
+ if (&s.g<int>) return;
+
+ if (S::h<42>) return;
+ if (S::h<int>) return; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
+ if (&S::h<42>) return;
+ if (&S::h<int>) return;
+ if (s.h<42>) return;
+ if (s.h<int>) return; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
+ if (&s.h<42>) return;
+ if (&s.h<int>) return; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
+
+ { bool b = S::f<char>; } // expected-error {{call to non-static member function without an object argument}}
+ { bool b = S::f<int>; } // expected-error {{call to non-static member function without an object argument}}
+ { bool b = &S::f<char>; }
+ { bool b = &S::f<int>; }
+ // These next two errors are terrible.
+ { bool b = s.f<char>; } // expected-error {{reference to non-static member function must be called}}
+ { bool b = s.f<int>; } // expected-error {{reference to non-static member function must be called}}
+ { bool b = &s.f<char>; } // expected-error {{cannot create a non-constant pointer to member function}}
+ { bool b = &s.f<int>; } // expected-error {{cannot create a non-constant pointer to member function}}
+
+ { bool b = S::g<char>; }
+ { bool b = S::g<int>; }
+ { bool b = &S::g<char>; }
+ { bool b = &S::g<int>; }
+ { bool b = s.g<char>; }
+ { bool b = s.g<int>; }
+ { bool b = &s.g<char>; }
+ { bool b = &s.g<int>; }
+
+ { bool b = S::h<42>; }
+ { bool b = S::h<int>; } // expected-error {{can't form member pointer of type 'bool' without '&' and class name}}
+ { bool b = &S::h<42>; }
+ { bool b = &S::h<int>; }
+ { bool b = s.h<42>; }
+ { bool b = s.h<int>; } // expected-error {{can't form member pointer of type 'bool' without '&' and class name}}
+ { bool b = &s.h<42>; }
+ { bool b = &s.h<int>; } // expected-error {{can't form member pointer of type 'bool' without '&' and class name}}
+ }
+}
diff --git a/clang/test/CXX/over/over.over/p2.cpp b/clang/test/CXX/over/over.over/p2.cpp
new file mode 100644
index 0000000..3e8d0f1
--- /dev/null
+++ b/clang/test/CXX/over/over.over/p2.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> T f0(T, T); //expected-note{{candidate}}
+
+void test_f0() {
+ int (*f0a)(int, int) = f0;
+ int (*f0b)(int, int) = &f0;
+ int (*f0c)(int, float) = f0; // expected-error{{address of overloaded function 'f0' does not match required type 'int (int, float)'}}
+}
diff --git a/clang/test/CXX/over/over.over/p4.cpp b/clang/test/CXX/over/over.over/p4.cpp
new file mode 100644
index 0000000..27d070e
--- /dev/null
+++ b/clang/test/CXX/over/over.over/p4.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> T f0(T); // expected-note{{candidate function}}
+int f0(int); // expected-note{{candidate function}}
+
+void test_f0() {
+ int (*fp0)(int) = f0;
+ int (*fp1)(int) = &f0;
+ float (*fp2)(float) = &f0;
+}
+
+namespace N {
+ int f0(int); // expected-note{{candidate function}}
+}
+
+void test_f0_2() {
+ using namespace N;
+ int (*fp0)(int) = f0; // expected-error{{address of overloaded function 'f0' is ambiguous}}
+ float (*fp1)(float) = f0;
+}
diff --git a/clang/test/CXX/special/class.copy/implicit-move-def.cpp b/clang/test/CXX/special/class.copy/implicit-move-def.cpp
new file mode 100644
index 0000000..5c54aea
--- /dev/null
+++ b/clang/test/CXX/special/class.copy/implicit-move-def.cpp
@@ -0,0 +1,117 @@
+// RUN: %clang_cc1 -emit-llvm -o - -std=c++11 %s | FileCheck -check-prefix=CHECK-ASSIGN %s
+// RUN: %clang_cc1 -emit-llvm -o - -std=c++11 %s | FileCheck -check-prefix=CHECK-ASSIGN %s
+// RUN: %clang_cc1 -emit-llvm -o - -std=c++11 %s | FileCheck -check-prefix=CHECK-CTOR %s
+
+// construct
+
+struct E {
+ E();
+ E(E&&);
+};
+
+struct F {
+ F();
+ F(F&&);
+};
+
+struct G {
+ E e;
+};
+
+struct H : G {
+ F l;
+ E m;
+ F ar[2];
+};
+
+void f() {
+ H s;
+ // CHECK: call void @_ZN1HC1EOS_
+ H t(static_cast<H&&>(s));
+}
+
+
+// assign
+
+struct A {
+ A &operator =(A&&);
+};
+
+struct B {
+ B &operator =(B&&);
+};
+
+struct C {
+ A a;
+};
+
+struct D : C {
+ A a;
+ B b;
+ A ar[2];
+};
+
+void g() {
+ D d;
+ // CHECK: call {{.*}} @_ZN1DaSEOS_
+ d = D();
+}
+
+// PR10822
+struct I {
+ unsigned var[1];
+};
+
+// CHECK: define void @_Z1hv() nounwind {
+void h() {
+ I i;
+ // CHECK: call void @llvm.memcpy.
+ i = I();
+ // CHECK-NEXT: ret void
+}
+
+// PR10860
+struct Empty { };
+struct VirtualWithEmptyBase : Empty {
+ virtual void f();
+};
+
+// CHECK: define void @_Z25move_VirtualWithEmptyBaseR20VirtualWithEmptyBaseS0_
+void move_VirtualWithEmptyBase(VirtualWithEmptyBase &x, VirtualWithEmptyBase &y) {
+ // CHECK: call {{.*}} @_ZN20VirtualWithEmptyBaseaSEOS_
+ x = static_cast<VirtualWithEmptyBase&&>(y);
+ // CHECK-NEXT: ret void
+}
+
+// move assignment ops
+
+// CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN1DaSEOS_
+// CHECK-ASSIGN: call {{.*}} @_ZN1CaSEOS_
+// CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_
+// CHECK-ASSIGN: call {{.*}} @_ZN1BaSEOS_
+// array loop
+// CHECK-ASSIGN: br i1
+// CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_
+
+// VirtualWithEmptyBase move assignment operatpr
+// CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN20VirtualWithEmptyBaseaSEOS_
+// CHECK-ASSIGN: store
+// CHECK-ASSIGN-NEXT: store
+// CHECK-ASSIGN-NOT: call
+// CHECK-ASSIGN: ret
+
+// CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN1CaSEOS_
+// CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_
+
+// move ctors
+
+// CHECK-CTOR: define linkonce_odr {{.*}} @_ZN1HC2EOS_
+// CHECK-CTOR: call {{.*}} @_ZN1GC2EOS_
+// CHECK-CTOR: call {{.*}} @_ZN1FC1EOS_
+// CHECK-CTOR: call {{.*}} @_ZN1EC1EOS_
+// array loop
+// CHECK-CTOR: br i1
+// CHECK-CTOR: call {{.*}} @_ZN1FC1EOS_
+
+// CHECK-CTOR: define linkonce_odr {{.*}} @_ZN1GC2EOS_
+// CHECK-CTOR: call {{.*}} @_ZN1EC1EOS_
diff --git a/clang/test/CXX/special/class.copy/implicit-move.cpp b/clang/test/CXX/special/class.copy/implicit-move.cpp
new file mode 100644
index 0000000..3e9accf
--- /dev/null
+++ b/clang/test/CXX/special/class.copy/implicit-move.cpp
@@ -0,0 +1,236 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// Tests for implicit (non-)declaration of move constructor and
+// assignment: p9, p11, p20, p23.
+
+// This class, used as a member, allows to distinguish move from copy because
+// move operations are no-throw, copy operations aren't.
+struct ThrowingCopy {
+ ThrowingCopy() noexcept;
+ ThrowingCopy(ThrowingCopy &&) noexcept;
+ ThrowingCopy(const ThrowingCopy &) noexcept(false);
+ ThrowingCopy & operator =(ThrowingCopy &&) noexcept;
+ ThrowingCopy & operator =(const ThrowingCopy &) noexcept(false);
+};
+
+struct HasCopyConstructor {
+ ThrowingCopy tc;
+ HasCopyConstructor() noexcept;
+ HasCopyConstructor(const HasCopyConstructor &) noexcept(false);
+};
+
+struct HasCopyAssignment {
+ ThrowingCopy tc;
+ HasCopyAssignment() noexcept;
+ HasCopyAssignment & operator =(const HasCopyAssignment &) noexcept(false);
+};
+
+struct HasMoveConstructor {
+ ThrowingCopy tc;
+ HasMoveConstructor() noexcept;
+ HasMoveConstructor(HasMoveConstructor &&) noexcept; // expected-note {{copy assignment operator is implicitly deleted because 'HasMoveConstructor' has a user-declared move constructor}}
+};
+
+struct HasMoveAssignment { // expected-note {{implicit copy constructor}}
+ ThrowingCopy tc;
+ HasMoveAssignment() noexcept;
+ HasMoveAssignment & operator =(HasMoveAssignment &&) noexcept;
+};
+
+struct HasDestructor {
+ ThrowingCopy tc;
+ HasDestructor() noexcept;
+ ~HasDestructor() noexcept;
+};
+
+void test_basic_exclusion() {
+ static_assert(!noexcept(HasCopyConstructor((HasCopyConstructor()))), "");
+ HasCopyConstructor hcc;
+ static_assert(!noexcept(hcc = HasCopyConstructor()), "");
+
+ static_assert(!noexcept(HasCopyAssignment((HasCopyAssignment()))), "");
+ HasCopyAssignment hca;
+ static_assert(!noexcept(hca = HasCopyAssignment()), "");
+
+ static_assert(noexcept(HasMoveConstructor((HasMoveConstructor()))), "");
+ HasMoveConstructor hmc;
+ hmc = HasMoveConstructor(); // expected-error {{selected implicitly-deleted copy assignment}}
+
+ (HasMoveAssignment(HasMoveAssignment())); // expected-error {{uses deleted function}}
+ HasMoveAssignment hma;
+ static_assert(noexcept(hma = HasMoveAssignment()), "");
+
+ static_assert(!noexcept(HasDestructor((HasDestructor()))), "");
+ HasDestructor hd;
+ static_assert(!noexcept(hd = HasDestructor()), "");
+}
+
+struct PrivateMove {
+ PrivateMove() noexcept;
+ PrivateMove(const PrivateMove &) noexcept(false);
+ PrivateMove & operator =(const PrivateMove &) noexcept(false);
+private:
+ PrivateMove(PrivateMove &&) noexcept;
+ PrivateMove & operator =(PrivateMove &&) noexcept;
+};
+
+struct InheritsPrivateMove : PrivateMove {};
+struct ContainsPrivateMove {
+ PrivateMove pm;
+};
+
+struct PrivateDestructor {
+ PrivateDestructor() noexcept;
+ PrivateDestructor(const PrivateDestructor &) noexcept(false);
+ PrivateDestructor(PrivateDestructor &&) noexcept;
+private:
+ ~PrivateDestructor() noexcept;
+};
+
+struct InheritsPrivateDestructor : PrivateDestructor {}; // expected-note{{base class 'PrivateDestructor' has an inaccessible destructor}}
+struct ContainsPrivateDestructor {
+ PrivateDestructor pd; // expected-note{{field 'pd' has an inaccessible destructor}}
+};
+
+struct NonTrivialCopyOnly {
+ NonTrivialCopyOnly() noexcept;
+ NonTrivialCopyOnly(const NonTrivialCopyOnly &) noexcept(false);
+ NonTrivialCopyOnly & operator =(const NonTrivialCopyOnly &) noexcept(false);
+};
+
+struct InheritsNonTrivialCopyOnly : NonTrivialCopyOnly {};
+struct ContainsNonTrivialCopyOnly {
+ NonTrivialCopyOnly ntco;
+};
+
+struct ContainsConst {
+ const int i;
+ ContainsConst() noexcept;
+ ContainsConst & operator =(ContainsConst &); // expected-note {{not viable}}
+};
+
+struct ContainsRef {
+ int &i;
+ ContainsRef() noexcept;
+ ContainsRef & operator =(ContainsRef &); // expected-note {{not viable}}
+};
+
+struct Base {
+ Base & operator =(Base &);
+};
+struct DirectVirtualBase : virtual Base {}; // expected-note {{copy assignment operator) not viable}}
+struct IndirectVirtualBase : DirectVirtualBase {}; // expected-note {{copy assignment operator) not viable}}
+
+void test_deletion_exclusion() {
+ // FIXME: How to test the union thing?
+
+ static_assert(!noexcept(InheritsPrivateMove(InheritsPrivateMove())), "");
+ static_assert(!noexcept(ContainsPrivateMove(ContainsPrivateMove())), "");
+ InheritsPrivateMove ipm;
+ static_assert(!noexcept(ipm = InheritsPrivateMove()), "");
+ ContainsPrivateMove cpm;
+ static_assert(!noexcept(cpm = ContainsPrivateMove()), "");
+
+ (InheritsPrivateDestructor(InheritsPrivateDestructor())); // expected-error {{call to implicitly-deleted default constructor}}
+ (ContainsPrivateDestructor(ContainsPrivateDestructor())); // expected-error {{call to implicitly-deleted default constructor}}
+
+ static_assert(!noexcept(InheritsNonTrivialCopyOnly(InheritsNonTrivialCopyOnly())), "");
+ static_assert(!noexcept(ContainsNonTrivialCopyOnly(ContainsNonTrivialCopyOnly())), "");
+ InheritsNonTrivialCopyOnly intco;
+ static_assert(!noexcept(intco = InheritsNonTrivialCopyOnly()), "");
+ ContainsNonTrivialCopyOnly cntco;
+ static_assert(!noexcept(cntco = ContainsNonTrivialCopyOnly()), "");
+
+ ContainsConst cc;
+ cc = ContainsConst(); // expected-error {{no viable}}
+
+ ContainsRef cr;
+ cr = ContainsRef(); // expected-error {{no viable}}
+
+ DirectVirtualBase dvb;
+ dvb = DirectVirtualBase(); // expected-error {{no viable}}
+
+ IndirectVirtualBase ivb;
+ ivb = IndirectVirtualBase(); // expected-error {{no viable}}
+}
+
+struct ContainsRValueRef {
+ int&& ri;
+ ContainsRValueRef() noexcept;
+};
+
+void test_contains_rref() {
+ (ContainsRValueRef(ContainsRValueRef()));
+}
+
+
+namespace DR1402 {
+ struct NonTrivialCopyCtor {
+ NonTrivialCopyCtor(const NonTrivialCopyCtor &);
+ };
+ struct NonTrivialCopyAssign {
+ NonTrivialCopyAssign &operator=(const NonTrivialCopyAssign &);
+ };
+
+ struct NonTrivialCopyCtorVBase : virtual NonTrivialCopyCtor {
+ NonTrivialCopyCtorVBase(NonTrivialCopyCtorVBase &&);
+ NonTrivialCopyCtorVBase &operator=(NonTrivialCopyCtorVBase &&) = default;
+ };
+ struct NonTrivialCopyAssignVBase : virtual NonTrivialCopyAssign {
+ NonTrivialCopyAssignVBase(NonTrivialCopyAssignVBase &&);
+ NonTrivialCopyAssignVBase &operator=(NonTrivialCopyAssignVBase &&) = default;
+ };
+
+ struct NonTrivialMoveAssign {
+ NonTrivialMoveAssign(NonTrivialMoveAssign&&);
+ NonTrivialMoveAssign &operator=(NonTrivialMoveAssign &&);
+ };
+ struct NonTrivialMoveAssignVBase : virtual NonTrivialMoveAssign {
+ NonTrivialMoveAssignVBase(NonTrivialMoveAssignVBase &&);
+ NonTrivialMoveAssignVBase &operator=(NonTrivialMoveAssignVBase &&) = default;
+ };
+
+ // A non-movable, non-trivially-copyable class type as a subobject inhibits
+ // the declaration of a move operation.
+ struct NoMove1 { NonTrivialCopyCtor ntcc; }; // expected-note 2{{'const DR1402::NoMove1 &'}}
+ struct NoMove2 { NonTrivialCopyAssign ntcc; }; // expected-note 2{{'const DR1402::NoMove2 &'}}
+ struct NoMove3 : NonTrivialCopyCtor {}; // expected-note 2{{'const DR1402::NoMove3 &'}}
+ struct NoMove4 : NonTrivialCopyAssign {}; // expected-note 2{{'const DR1402::NoMove4 &'}}
+ struct NoMove5 : virtual NonTrivialCopyCtor {}; // expected-note 2{{'const DR1402::NoMove5 &'}}
+ struct NoMove6 : virtual NonTrivialCopyAssign {}; // expected-note 2{{'const DR1402::NoMove6 &'}}
+ struct NoMove7 : NonTrivialCopyCtorVBase {}; // expected-note 2{{'const DR1402::NoMove7 &'}}
+ struct NoMove8 : NonTrivialCopyAssignVBase {}; // expected-note 2{{'const DR1402::NoMove8 &'}}
+
+ // A non-trivially-move-assignable virtual base class inhibits the declaration
+ // of a move assignment (which might move-assign the base class multiple
+ // times).
+ struct NoMove9 : NonTrivialMoveAssign {};
+ struct NoMove10 : virtual NonTrivialMoveAssign {}; // expected-note {{'const DR1402::NoMove10 &'}}
+ struct NoMove11 : NonTrivialMoveAssignVBase {}; // expected-note {{'const DR1402::NoMove11 &'}}
+
+ struct Test {
+ friend NoMove1::NoMove1(NoMove1 &&); // expected-error {{no matching function}}
+ friend NoMove2::NoMove2(NoMove2 &&); // expected-error {{no matching function}}
+ friend NoMove3::NoMove3(NoMove3 &&); // expected-error {{no matching function}}
+ friend NoMove4::NoMove4(NoMove4 &&); // expected-error {{no matching function}}
+ friend NoMove5::NoMove5(NoMove5 &&); // expected-error {{no matching function}}
+ friend NoMove6::NoMove6(NoMove6 &&); // expected-error {{no matching function}}
+ friend NoMove7::NoMove7(NoMove7 &&); // expected-error {{no matching function}}
+ friend NoMove8::NoMove8(NoMove8 &&); // expected-error {{no matching function}}
+ friend NoMove9::NoMove9(NoMove9 &&);
+ friend NoMove10::NoMove10(NoMove10 &&);
+ friend NoMove11::NoMove11(NoMove11 &&);
+
+ friend NoMove1 &NoMove1::operator=(NoMove1 &&); // expected-error {{no matching function}}
+ friend NoMove2 &NoMove2::operator=(NoMove2 &&); // expected-error {{no matching function}}
+ friend NoMove3 &NoMove3::operator=(NoMove3 &&); // expected-error {{no matching function}}
+ friend NoMove4 &NoMove4::operator=(NoMove4 &&); // expected-error {{no matching function}}
+ friend NoMove5 &NoMove5::operator=(NoMove5 &&); // expected-error {{no matching function}}
+ friend NoMove6 &NoMove6::operator=(NoMove6 &&); // expected-error {{no matching function}}
+ friend NoMove7 &NoMove7::operator=(NoMove7 &&); // expected-error {{no matching function}}
+ friend NoMove8 &NoMove8::operator=(NoMove8 &&); // expected-error {{no matching function}}
+ friend NoMove9 &NoMove9::operator=(NoMove9 &&);
+ friend NoMove10 &NoMove10::operator=(NoMove10 &&); // expected-error {{no matching function}}
+ friend NoMove11 &NoMove11::operator=(NoMove11 &&); // expected-error {{no matching function}}
+ };
+}
diff --git a/clang/test/CXX/special/class.copy/p11.0x.copy.cpp b/clang/test/CXX/special/class.copy/p11.0x.copy.cpp
new file mode 100644
index 0000000..b2b4f6a
--- /dev/null
+++ b/clang/test/CXX/special/class.copy/p11.0x.copy.cpp
@@ -0,0 +1,121 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct NonTrivial {
+ NonTrivial(const NonTrivial&);
+};
+
+// A defaulted copy constructor for a class X is defined as deleted if X has:
+
+// -- a variant member with a non-trivial corresponding constructor
+union DeletedNTVariant {
+ NonTrivial NT; // expected-note{{copy constructor of union 'DeletedNTVariant' is implicitly deleted because field 'NT' has a non-trivial copy constructor}}
+ DeletedNTVariant();
+};
+DeletedNTVariant DVa;
+DeletedNTVariant DVb(DVa); // expected-error{{call to implicitly-deleted copy constructor}}
+
+struct DeletedNTVariant2 {
+ union {
+ NonTrivial NT; // expected-note{{copy constructor of union 'DeletedNTVariant2' is implicitly deleted because field 'NT' has a non-trivial copy constructor}}
+ };
+ DeletedNTVariant2();
+};
+DeletedNTVariant2 DV2a;
+DeletedNTVariant2 DV2b(DV2a); // expected-error{{call to implicitly-deleted copy constructor}}
+
+// -- a non-static data member of class type M (or array thereof) that cannot be
+// copied because overload resolution results in an ambiguity or a function
+// that is deleted or inaccessible
+struct NoAccess {
+ NoAccess() = default;
+private:
+ NoAccess(const NoAccess&);
+
+ friend struct HasAccess;
+};
+
+struct HasNoAccess {
+ NoAccess NA; // expected-note{{copy constructor of 'HasNoAccess' is implicitly deleted because field 'NA' has an inaccessible copy constructor}}
+};
+HasNoAccess HNAa;
+HasNoAccess HNAb(HNAa); // expected-error{{call to implicitly-deleted copy constructor}}
+
+struct HasAccess {
+ NoAccess NA;
+};
+
+HasAccess HAa;
+HasAccess HAb(HAa);
+
+struct NonConst {
+ NonConst(NonConst&);
+};
+struct Ambiguity {
+ Ambiguity(const Ambiguity&);
+ Ambiguity(volatile Ambiguity&);
+};
+
+struct IsAmbiguous {
+ NonConst NC;
+ Ambiguity A; // expected-note 2{{copy constructor of 'IsAmbiguous' is implicitly deleted because field 'A' has multiple copy constructors}}
+ IsAmbiguous();
+};
+IsAmbiguous IAa;
+IsAmbiguous IAb(IAa); // expected-error{{call to implicitly-deleted copy constructor}}
+
+struct Deleted {
+ IsAmbiguous IA; // expected-note{{copy constructor of 'Deleted' is implicitly deleted because field 'IA' has a deleted copy constructor}}
+};
+Deleted Da;
+Deleted Db(Da); // expected-error{{call to implicitly-deleted copy constructor}}
+
+// -- a direct or virtual base class B that cannot be copied because overload
+// resolution results in an ambiguity or a function that is deleted or
+// inaccessible
+struct AmbiguousCopyBase : Ambiguity { // expected-note 2{{copy constructor of 'AmbiguousCopyBase' is implicitly deleted because base class 'Ambiguity' has multiple copy constructors}}
+ NonConst NC;
+};
+extern AmbiguousCopyBase ACBa;
+AmbiguousCopyBase ACBb(ACBa); // expected-error {{deleted copy constructor}}
+
+struct DeletedCopyBase : AmbiguousCopyBase {}; // expected-note {{copy constructor of 'DeletedCopyBase' is implicitly deleted because base class 'AmbiguousCopyBase' has a deleted copy constructor}}
+extern DeletedCopyBase DCBa;
+DeletedCopyBase DCBb(DCBa); // expected-error {{deleted copy constructor}}
+
+struct InaccessibleCopyBase : NoAccess {}; // expected-note {{copy constructor of 'InaccessibleCopyBase' is implicitly deleted because base class 'NoAccess' has an inaccessible copy constructor}}
+extern InaccessibleCopyBase ICBa;
+InaccessibleCopyBase ICBb(ICBa); // expected-error {{deleted copy constructor}}
+
+// -- any direct or virtual base class or non-static data member of a type with
+// a destructor that is deleted or inaccessible
+struct NoAccessDtor {
+private:
+ ~NoAccessDtor();
+ friend struct HasAccessDtor;
+};
+
+struct HasNoAccessDtor {
+ NoAccessDtor NAD; // expected-note{{copy constructor of 'HasNoAccessDtor' is implicitly deleted because field 'NAD' has an inaccessible destructor}}
+ HasNoAccessDtor();
+ ~HasNoAccessDtor();
+};
+HasNoAccessDtor HNADa;
+HasNoAccessDtor HNADb(HNADa); // expected-error{{call to implicitly-deleted copy constructor}}
+
+struct HasAccessDtor {
+ NoAccessDtor NAD;
+};
+HasAccessDtor HADa;
+HasAccessDtor HADb(HADa);
+
+struct HasNoAccessDtorBase : NoAccessDtor { // expected-note{{copy constructor of 'HasNoAccessDtorBase' is implicitly deleted because base class 'NoAccessDtor' has an inaccessible destructor}}
+};
+extern HasNoAccessDtorBase HNADBa;
+HasNoAccessDtorBase HNADBb(HNADBa); // expected-error{{implicitly-deleted copy constructor}}
+
+// -- a non-static data member of rvalue reference type
+struct RValue {
+ int && ri = 1; // expected-note{{copy constructor of 'RValue' is implicitly deleted because field 'ri' is of rvalue reference type 'int &&'}}
+};
+RValue RVa;
+RValue RVb(RVa); // expected-error{{call to implicitly-deleted copy constructor}}
diff --git a/clang/test/CXX/special/class.copy/p11.0x.move.cpp b/clang/test/CXX/special/class.copy/p11.0x.move.cpp
new file mode 100644
index 0000000..ff9478b
--- /dev/null
+++ b/clang/test/CXX/special/class.copy/p11.0x.move.cpp
@@ -0,0 +1,164 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct NonTrivial {
+ NonTrivial(NonTrivial&&);
+};
+
+// A defaulted move constructor for a class X is defined as deleted if X has:
+
+// -- a variant member with a non-trivial corresponding constructor
+union DeletedNTVariant {
+ NonTrivial NT;
+ DeletedNTVariant(DeletedNTVariant&&);
+};
+DeletedNTVariant::DeletedNTVariant(DeletedNTVariant&&) = default; // expected-error{{would delete}}
+
+struct DeletedNTVariant2 {
+ union {
+ NonTrivial NT;
+ };
+ DeletedNTVariant2(DeletedNTVariant2&&);
+};
+DeletedNTVariant2::DeletedNTVariant2(DeletedNTVariant2&&) = default; // expected-error{{would delete}}
+
+// -- a non-static data member of class type M (or array thereof) that cannot be
+// copied because overload resolution results in an ambiguity or a function
+// that is deleted or inaccessible
+struct NoAccess {
+ NoAccess() = default;
+private:
+ NoAccess(NoAccess&&);
+
+ friend struct HasAccess;
+};
+
+struct HasNoAccess {
+ NoAccess NA;
+ HasNoAccess(HasNoAccess&&);
+};
+HasNoAccess::HasNoAccess(HasNoAccess&&) = default; // expected-error{{would delete}}
+
+struct HasAccess {
+ NoAccess NA;
+ HasAccess(HasAccess&&);
+};
+HasAccess::HasAccess(HasAccess&&) = default;
+
+struct Ambiguity {
+ Ambiguity(const Ambiguity&&);
+ Ambiguity(volatile Ambiguity&&);
+};
+
+struct IsAmbiguous {
+ Ambiguity A;
+ IsAmbiguous(IsAmbiguous&&);
+};
+IsAmbiguous::IsAmbiguous(IsAmbiguous&&) = default; // expected-error{{would delete}}
+
+struct Deleted {
+ IsAmbiguous IA;
+ Deleted(Deleted&&);
+};
+Deleted::Deleted(Deleted&&) = default; // expected-error{{would delete}}
+
+// -- a direct or virtual base class B that cannot be moved because overload
+// resolution results in an ambiguity or a function that is deleted or
+// inaccessible
+struct AmbiguousMoveBase : Ambiguity {
+ AmbiguousMoveBase(AmbiguousMoveBase&&);
+};
+AmbiguousMoveBase::AmbiguousMoveBase(AmbiguousMoveBase&&) = default; // expected-error{{would delete}}
+
+struct DeletedMoveBase : AmbiguousMoveBase {
+ DeletedMoveBase(DeletedMoveBase&&);
+};
+DeletedMoveBase::DeletedMoveBase(DeletedMoveBase&&) = default; // expected-error{{would delete}}
+
+struct InaccessibleMoveBase : NoAccess {
+ InaccessibleMoveBase(InaccessibleMoveBase&&);
+};
+InaccessibleMoveBase::InaccessibleMoveBase(InaccessibleMoveBase&&) = default; // expected-error{{would delete}}
+
+// -- any direct or virtual base class or non-static data member of a type with
+// a destructor that is deleted or inaccessible
+struct NoAccessDtor {
+ NoAccessDtor(NoAccessDtor&&); // expected-note{{copy constructor is implicitly deleted because 'NoAccessDtor' has a user-declared move constructor}}
+private:
+ ~NoAccessDtor();
+ friend struct HasAccessDtor;
+};
+
+struct HasNoAccessDtor {
+ NoAccessDtor NAD;
+ HasNoAccessDtor(HasNoAccessDtor&&);
+};
+HasNoAccessDtor::HasNoAccessDtor(HasNoAccessDtor&&) = default; // expected-error{{would delete}}
+
+struct HasAccessDtor {
+ NoAccessDtor NAD;
+ HasAccessDtor(HasAccessDtor&&);
+};
+HasAccessDtor::HasAccessDtor(HasAccessDtor&&) = default;
+
+struct HasNoAccessDtorBase : NoAccessDtor { // expected-note{{copy constructor of 'HasNoAccessDtorBase' is implicitly deleted because base class 'NoAccessDtor' has a deleted copy constructor}}
+};
+extern HasNoAccessDtorBase HNADBa;
+HasNoAccessDtorBase HNADBb(HNADBa); // expected-error{{implicitly-deleted copy constructor}}
+
+// The restriction on rvalue reference members applies to only the copy
+// constructor.
+struct RValue {
+ int &&ri = 1;
+ RValue(RValue&&);
+};
+RValue::RValue(RValue&&) = default;
+
+// -- a non-static data member or direct or virtual base class with a type that
+// does not have a move constructor and is not trivially copyable
+struct CopyOnly {
+ CopyOnly(const CopyOnly&);
+};
+
+struct NonMove {
+ CopyOnly CO;
+ NonMove(NonMove&&);
+};
+NonMove::NonMove(NonMove&&) = default; // ok under DR1402
+
+struct Moveable {
+ Moveable();
+ Moveable(Moveable&&);
+};
+
+struct HasMove {
+ Moveable M;
+ HasMove(HasMove&&);
+};
+HasMove::HasMove(HasMove&&) = default;
+
+namespace DR1402 {
+ struct member {
+ member();
+ member(const member&);
+ member& operator=(const member&);
+ ~member();
+ };
+
+ struct A {
+ member m_;
+
+ A() = default;
+ A(const A&) = default;
+ A& operator=(const A&) = default;
+ A(A&&) = default;
+ A& operator=(A&&) = default;
+ ~A() = default;
+ };
+
+ // ok, A's explicitly-defaulted move operations copy m_.
+ void f() {
+ A a, b(a), c(static_cast<A&&>(a));
+ a = b;
+ b = static_cast<A&&>(c);
+ }
+}
diff --git a/clang/test/CXX/special/class.copy/p13-0x.cpp b/clang/test/CXX/special/class.copy/p13-0x.cpp
new file mode 100644
index 0000000..0a9aa62
--- /dev/null
+++ b/clang/test/CXX/special/class.copy/p13-0x.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// If the implicitly-defined constructor would satisfy the requirements of a
+// constexpr constructor, the implicitly-defined constructor is constexpr.
+struct Constexpr1 {
+ constexpr Constexpr1() : n(0) {}
+ int n;
+};
+constexpr Constexpr1 c1a = Constexpr1(Constexpr1()); // ok
+constexpr Constexpr1 c1b = Constexpr1(Constexpr1(c1a)); // ok
+
+struct Constexpr2 {
+ Constexpr1 ce1;
+ constexpr Constexpr2() = default;
+ constexpr Constexpr2(const Constexpr2 &o) : ce1(o.ce1) {}
+ // no move constructor
+};
+
+constexpr Constexpr2 c2a = Constexpr2(Constexpr2()); // ok
+constexpr Constexpr2 c2b = Constexpr2(Constexpr2(c2a)); // ok
+
+struct Constexpr3 {
+ Constexpr2 ce2;
+ // all special constructors are constexpr, move ctor calls ce2's copy ctor
+};
+
+constexpr Constexpr3 c3a = Constexpr3(Constexpr3()); // ok
+constexpr Constexpr3 c3b = Constexpr3(Constexpr3(c3a)); // ok
+
+struct NonConstexprCopy {
+ constexpr NonConstexprCopy() = default;
+ NonConstexprCopy(const NonConstexprCopy &);
+ constexpr NonConstexprCopy(NonConstexprCopy &&) = default;
+
+ int n = 42;
+};
+
+NonConstexprCopy::NonConstexprCopy(const NonConstexprCopy &) = default; // expected-note {{here}}
+
+constexpr NonConstexprCopy ncc1 = NonConstexprCopy(NonConstexprCopy()); // ok
+constexpr NonConstexprCopy ncc2 = ncc1; // expected-error {{constant expression}} expected-note {{non-constexpr constructor}}
+
+struct NonConstexprDefault {
+ NonConstexprDefault() = default;
+ constexpr NonConstexprDefault(int n) : n(n) {}
+ int n;
+};
+struct Constexpr4 {
+ NonConstexprDefault ncd;
+};
+
+constexpr NonConstexprDefault ncd = NonConstexprDefault(NonConstexprDefault(1));
+constexpr Constexpr4 c4a = { ncd };
+constexpr Constexpr4 c4b = Constexpr4(c4a);
+constexpr Constexpr4 c4c = Constexpr4(static_cast<Constexpr4&&>(const_cast<Constexpr4&>(c4b)));
+
+struct Constexpr5Base {};
+struct Constexpr5 : Constexpr5Base { constexpr Constexpr5() {} };
+constexpr Constexpr5 ce5move = Constexpr5();
+constexpr Constexpr5 ce5copy = ce5move;
diff --git a/clang/test/CXX/special/class.copy/p15-0x.cpp b/clang/test/CXX/special/class.copy/p15-0x.cpp
new file mode 100644
index 0000000..fff8844
--- /dev/null
+++ b/clang/test/CXX/special/class.copy/p15-0x.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+namespace PR10622 {
+ struct foo {
+ const int first;
+ foo(const foo&) = default;
+ };
+ void find_or_insert(const foo& __obj) {
+ foo x(__obj);
+ }
+
+ struct bar : foo {
+ bar(const bar&) = default;
+ };
+ void test_bar(const bar &obj) {
+ bar obj2(obj);
+ }
+}
+
+namespace PR11418 {
+ template<typename T>
+ T may_throw() {
+ return T();
+ }
+
+ template<typename T> T &&declval() noexcept;
+
+ struct NonPOD {
+ NonPOD();
+ NonPOD(const NonPOD &) noexcept;
+ NonPOD(NonPOD &&) noexcept;
+ };
+
+ struct X {
+ NonPOD np = may_throw<NonPOD>();
+ };
+
+ static_assert(noexcept(declval<X>()), "noexcept isn't working at all");
+ static_assert(noexcept(X(declval<X&>())), "copy constructor can't throw");
+ static_assert(noexcept(X(declval<X>())), "move constructor can't throw");
+}
diff --git a/clang/test/CXX/special/class.copy/p15-inclass.cpp b/clang/test/CXX/special/class.copy/p15-inclass.cpp
new file mode 100644
index 0000000..c4f8eaf
--- /dev/null
+++ b/clang/test/CXX/special/class.copy/p15-inclass.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+namespace PR11418 {
+ struct NonPOD {
+ NonPOD();
+ NonPOD(const NonPOD &);
+ NonPOD(NonPOD &&);
+ };
+
+ struct X {
+ NonPOD np;
+ int a = 17;
+ };
+
+ void check_copy(X x) {
+ X x2(x);
+ }
+
+ void check_move(X x) {
+ X x3(static_cast<X&&>(x));
+ }
+
+ // CHECK: define linkonce_odr void @_ZN7PR114181XC2EOS0_
+ // CHECK-NOT: 17
+ // CHECK: call void @_ZN7PR114186NonPODC1EOS0_
+ // CHECK-NOT: 17
+ // CHECK: load i32*
+ // CHECK-NOT: 17
+ // CHECK: store i32
+ // CHECK-NOT: 17
+ // CHECK: ret
+
+ // CHECK: define linkonce_odr void @_ZN7PR114181XC2ERKS0_
+ // CHECK-NOT: 17
+ // CHECK: call void @_ZN7PR114186NonPODC1ERKS0_
+ // CHECK-NOT: 17
+ // CHECK: load i32*
+ // CHECK-NOT: 17
+ // CHECK: store i32
+ // CHECK-NOT: 17
+ // CHECK: ret
+}
diff --git a/clang/test/CXX/special/class.copy/p20.cpp b/clang/test/CXX/special/class.copy/p20.cpp
new file mode 100644
index 0000000..8dfb7ca
--- /dev/null
+++ b/clang/test/CXX/special/class.copy/p20.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct ConstCopy {
+ ConstCopy();
+ ConstCopy &operator=(const ConstCopy&);
+};
+
+struct NonConstCopy {
+ NonConstCopy();
+ NonConstCopy &operator=(NonConstCopy&);
+};
+
+struct VirtualInheritsNonConstCopy : virtual NonConstCopy {
+ VirtualInheritsNonConstCopy();
+ VirtualInheritsNonConstCopy &operator=(const VirtualInheritsNonConstCopy&);
+};
+
+struct ImplicitNonConstCopy1 : NonConstCopy { // expected-note{{the implicit copy assignment operator}}
+ ImplicitNonConstCopy1();
+};
+
+struct ImplicitNonConstCopy2 { // expected-note{{the implicit copy assignment operator}}
+ ImplicitNonConstCopy2();
+ NonConstCopy ncc;
+};
+
+struct ImplicitNonConstCopy3 { // expected-note{{the implicit copy assignment operator}}
+ ImplicitNonConstCopy3();
+ NonConstCopy ncc_array[2][3];
+};
+
+struct ImplicitNonConstCopy4 : VirtualInheritsNonConstCopy {
+ ImplicitNonConstCopy4();
+};
+
+void test_non_const_copy(const ImplicitNonConstCopy1 &cincc1,
+ const ImplicitNonConstCopy2 &cincc2,
+ const ImplicitNonConstCopy3 &cincc3,
+ const ImplicitNonConstCopy4 &cincc4,
+ const VirtualInheritsNonConstCopy &vincc) {
+ (void)sizeof(ImplicitNonConstCopy1() = cincc1); // expected-error{{no viable overloaded '='}}
+ (void)sizeof(ImplicitNonConstCopy2() = cincc2); // expected-error{{no viable overloaded '='}}
+ (void)sizeof(ImplicitNonConstCopy3() = cincc3); // expected-error{{no viable overloaded '='}}
+ (void)sizeof(ImplicitNonConstCopy4() = cincc4); // okay
+ (void)sizeof(VirtualInheritsNonConstCopy() = vincc);
+}
diff --git a/clang/test/CXX/special/class.copy/p3.cpp b/clang/test/CXX/special/class.copy/p3.cpp
new file mode 100644
index 0000000..3d87266
--- /dev/null
+++ b/clang/test/CXX/special/class.copy/p3.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+
+// PR6141
+template<typename T>
+struct X {
+ X();
+ template<typename U> X(X<U>);
+ X(const X<T>&);
+};
+
+void f(X<int>) { }
+
+struct Y : X<int> { };
+struct Z : X<float> { };
+
+// CHECK: define i32 @main()
+int main() {
+ // CHECK: call void @_ZN1YC1Ev
+ // CHECK: call void @_ZN1XIiEC1ERKS0_
+ // CHECK: call void @_Z1f1XIiE
+ f(Y());
+ // CHECK: call void @_ZN1ZC1Ev
+ // CHECK: call void @_ZN1XIfEC1ERKS0_
+ // CHECK: call void @_ZN1XIiEC1IfEES_IT_E
+ // CHECK: call void @_Z1f1XIiE
+ f(Z());
+}
diff --git a/clang/test/CXX/special/class.copy/p33-0x.cpp b/clang/test/CXX/special/class.copy/p33-0x.cpp
new file mode 100644
index 0000000..b66e19a
--- /dev/null
+++ b/clang/test/CXX/special/class.copy/p33-0x.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -fsyntax-only -verify %s
+class X {
+ X(const X&);
+
+public:
+ X();
+ X(X&&);
+};
+
+X return_by_move(int i, X x) {
+ X x2;
+ if (i == 0)
+ return x;
+ else if (i == 1)
+ return x2;
+ else
+ return x;
+}
+
+void throw_move_only(X x) {
+ X x2;
+ throw x;
+ throw x2;
+}
+
+namespace PR10142 {
+ struct X {
+ X();
+ X(X&&);
+ X(const X&) = delete; // expected-note 2{{function has been explicitly marked deleted here}}
+ };
+
+ void f(int i) {
+ X x;
+ try {
+ X x2;
+ if (i)
+ throw x2; // okay
+ throw x; // expected-error{{call to deleted constructor of 'PR10142::X'}}
+ } catch (...) {
+ }
+ }
+
+ template<typename T>
+ void f2(int i) {
+ T x;
+ try {
+ T x2;
+ if (i)
+ throw x2; // okay
+ throw x; // expected-error{{call to deleted constructor of 'PR10142::X'}}
+ } catch (...) {
+ }
+ }
+
+ template void f2<X>(int); // expected-note{{in instantiation of function template specialization 'PR10142::f2<PR10142::X>' requested here}}
+}
diff --git a/clang/test/CXX/special/class.copy/p8-cxx11.cpp b/clang/test/CXX/special/class.copy/p8-cxx11.cpp
new file mode 100644
index 0000000..02e6cd1
--- /dev/null
+++ b/clang/test/CXX/special/class.copy/p8-cxx11.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+// C++98 [class.copy]p5 / C++11 [class.copy]p8.
+
+// The implicitly-declared copy constructor for a class X will have the form
+// X::X(const X&)
+// if [every direct subobject] has a copy constructor whose first parameter is
+// of type 'const volatile[opt] T &'. Otherwise, it will have the form
+// X::X(X&)
+
+struct ConstCopy {
+ ConstCopy(const ConstCopy &);
+};
+
+struct NonConstCopy {
+ NonConstCopy(NonConstCopy &);
+};
+
+struct DeletedConstCopy {
+ DeletedConstCopy(const DeletedConstCopy &) = delete;
+};
+
+struct DeletedNonConstCopy {
+ DeletedNonConstCopy(DeletedNonConstCopy &) = delete;
+};
+
+struct ImplicitlyDeletedConstCopy {
+ ImplicitlyDeletedConstCopy(ImplicitlyDeletedConstCopy &&);
+};
+
+
+struct A : ConstCopy {};
+struct B : NonConstCopy { ConstCopy a; };
+struct C : ConstCopy { NonConstCopy a; };
+struct D : DeletedConstCopy {};
+struct E : DeletedNonConstCopy {};
+struct F { ImplicitlyDeletedConstCopy a; };
+struct G : virtual B {};
+
+struct Test {
+ friend A::A(const A &);
+ friend B::B(B &);
+ friend C::C(C &);
+ friend D::D(const D &);
+ friend E::E(E &);
+ friend F::F(const F &);
+ friend G::G(G &);
+};
diff --git a/clang/test/CXX/special/class.copy/p9.cpp b/clang/test/CXX/special/class.copy/p9.cpp
new file mode 100644
index 0000000..77ab19e
--- /dev/null
+++ b/clang/test/CXX/special/class.copy/p9.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct ConstCopy {
+ ConstCopy();
+ ConstCopy(const ConstCopy&);
+};
+
+struct NonConstCopy {
+ NonConstCopy();
+ NonConstCopy(NonConstCopy&);
+};
+
+struct VirtualInheritsNonConstCopy : virtual NonConstCopy {
+ VirtualInheritsNonConstCopy();
+ VirtualInheritsNonConstCopy(const VirtualInheritsNonConstCopy&);
+};
+
+struct ImplicitNonConstCopy1 : NonConstCopy { // expected-note {{candidate constructor}}
+ ImplicitNonConstCopy1(); // expected-note {{candidate constructor}}
+};
+
+struct ImplicitNonConstCopy2 { // expected-note {{candidate constructor}}
+ ImplicitNonConstCopy2(); // expected-note {{candidate constructor}}
+ NonConstCopy ncc;
+};
+
+struct ImplicitNonConstCopy3 { // expected-note {{candidate constructor}}
+ ImplicitNonConstCopy3(); // expected-note {{candidate constructor}}
+ NonConstCopy ncc_array[2][3];
+};
+
+struct ImplicitNonConstCopy4 : VirtualInheritsNonConstCopy { // expected-note {{candidate constructor}}
+ ImplicitNonConstCopy4(); // expected-note {{candidate constructor}}
+};
+
+void test_non_const_copy(const ImplicitNonConstCopy1 &cincc1,
+ const ImplicitNonConstCopy2 &cincc2,
+ const ImplicitNonConstCopy3 &cincc3,
+ const ImplicitNonConstCopy4 &cincc4) {
+ (void)sizeof(ImplicitNonConstCopy1(cincc1)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy1' to 'ImplicitNonConstCopy1'}}
+ (void)sizeof(ImplicitNonConstCopy2(cincc2)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy2' to 'ImplicitNonConstCopy2'}}
+ (void)sizeof(ImplicitNonConstCopy3(cincc3)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy3' to 'ImplicitNonConstCopy3'}}
+ (void)sizeof(ImplicitNonConstCopy4(cincc4)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy4' to 'ImplicitNonConstCopy4'}}
+}
diff --git a/clang/test/CXX/special/class.ctor/p1.cpp b/clang/test/CXX/special/class.ctor/p1.cpp
new file mode 100644
index 0000000..9500a7d
--- /dev/null
+++ b/clang/test/CXX/special/class.ctor/p1.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct X0 {
+ struct type { };
+
+ X0();
+ X0(int);
+ (X0)(float);
+ X0 (f0)(int);
+ X0 (f0)(type);
+
+ X0 f1();
+ X0 f1(double);
+};
+
+X0::X0() { }
+(X0::X0)(int) { }
+
+X0 (X0::f0)(int) { return X0(); }
+
+template<typename T>
+struct X1 {
+ struct type { };
+
+ X1<T>();
+ X1<T>(int);
+ (X1<T>)(float);
+ X1(float, float);
+ (X1)(double);
+ X1<T> (f0)(int);
+ X1<T> (f0)(type);
+ X1 (f1)(int);
+ X1 (f1)(type);
+
+ template<typename U> X1(U);
+ X1 f2();
+ X1 f2(int);
+};
+
+template<typename T> X1<T>::X1() { }
+template<typename T> (X1<T>::X1)(double) { }
+template<typename T> X1<T> X1<T>::f1(int) { return 0; }
+template<typename T> X1<T> (X1<T>::f1)(type) { return 0; }
diff --git a/clang/test/CXX/special/class.ctor/p4-0x.cpp b/clang/test/CXX/special/class.ctor/p4-0x.cpp
new file mode 100644
index 0000000..509beb4
--- /dev/null
+++ b/clang/test/CXX/special/class.ctor/p4-0x.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// A constructor shall not be declared with a ref-qualifier.
+struct X {
+ X() &; // expected-error{{ref-qualifier '&' is not allowed on a constructor}}
+ X(int) &&; // expected-error{{ref-qualifier '&&' is not allowed on a constructor}}
+};
diff --git a/clang/test/CXX/special/class.ctor/p5-0x.cpp b/clang/test/CXX/special/class.ctor/p5-0x.cpp
new file mode 100644
index 0000000..694ab5b
--- /dev/null
+++ b/clang/test/CXX/special/class.ctor/p5-0x.cpp
@@ -0,0 +1,182 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+struct DefaultedDefCtor1 {};
+struct DefaultedDefCtor2 { DefaultedDefCtor2() = default; };
+struct DeletedDefCtor { DeletedDefCtor() = delete; DeletedDefCtor(int); }; // expected-note {{explicitly marked deleted here}}
+class PrivateDefCtor { PrivateDefCtor() = default; public: PrivateDefCtor(int); };
+struct DeletedDtor { ~DeletedDtor() = delete; }; // expected-note 4{{explicitly marked deleted here}}
+class PrivateDtor { ~PrivateDtor() = default; };
+class Friend {
+ Friend() = default; ~Friend() = default;
+ friend struct NotDeleted6c;
+ friend struct NotDeleted7i;
+ friend struct NotDeleted7j;
+ friend struct NotDeleted7k;
+};
+struct UserProvidedDefCtor { UserProvidedDefCtor() {} };
+int n;
+
+
+// A defaulted default constructor for a class X is defined as deleted if:
+
+// - X is a union-like class that has a variant member with a non-trivial
+// default constructor,
+union Deleted1a { UserProvidedDefCtor u; }; // expected-note {{default constructor of union 'Deleted1a' is implicitly deleted because field 'u' has a non-trivial default constructor}}
+Deleted1a d1a; // expected-error {{implicitly-deleted default constructor}}
+union NotDeleted1a { DefaultedDefCtor1 nu; };
+NotDeleted1a nd1a;
+union NotDeleted1b { DefaultedDefCtor2 nu; };
+NotDeleted1b nd1b;
+
+// - any non-static data member with no brace-or-equal-initializer is of
+// reference type,
+class Deleted2a {
+ Deleted2a() = default; // expected-note 4{{implicitly deleted here}}
+ int &a; // expected-note 4{{because field 'a' of reference type 'int &' would not be initialized}}
+};
+Deleted2a d2a; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted2b {
+ int &&b; // expected-note {{default constructor of 'Deleted2b' is implicitly deleted because field 'b' of reference type 'int &&' would not be initialized}}
+};
+Deleted2b d2b; // expected-error {{deleted default constructor}}
+class NotDeleted2a { int &a = n; };
+NotDeleted2a nd2a;
+class NotDeleted2b { int &a = error; }; // expected-error {{undeclared identifier}}
+NotDeleted2b nd2b;
+class NotDeleted2c { int &&a = 0; };
+NotDeleted2c nd2c;
+
+// - any non-variant non-static data member of const qualified type (or array
+// thereof) with no brace-or-equal-initializer does not have a user-provided
+// default constructor,
+class Deleted3a { const int a; }; // expected-note {{because field 'a' of const-qualified type 'const int' would not be initialized}} \
+ expected-warning {{does not declare any constructor}} \
+ expected-note {{will never be initialized}}
+Deleted3a d3a; // expected-error {{implicitly-deleted default constructor}}
+class Deleted3b { const DefaultedDefCtor1 a[42]; }; // expected-note {{because field 'a' of const-qualified type 'const DefaultedDefCtor1' would not be initialized}}
+Deleted3b d3b; // expected-error {{implicitly-deleted default constructor}}
+class Deleted3c { const DefaultedDefCtor2 a; }; // expected-note {{because field 'a' of const-qualified type 'const DefaultedDefCtor2' would not be initialized}}
+Deleted3c d3c; // expected-error {{implicitly-deleted default constructor}}
+class NotDeleted3a { const int a = 0; };
+NotDeleted3a nd3a;
+class NotDeleted3b { const DefaultedDefCtor1 a[42] = {}; };
+NotDeleted3b nd3b;
+class NotDeleted3c { const DefaultedDefCtor2 a = DefaultedDefCtor2(); };
+NotDeleted3c nd3c;
+union NotDeleted3d { const int a; int b; };
+NotDeleted3d nd3d;
+union NotDeleted3e { const DefaultedDefCtor1 a[42]; int b; };
+NotDeleted3e nd3e;
+union NotDeleted3f { const DefaultedDefCtor2 a; int b; };
+NotDeleted3f nd3f;
+struct NotDeleted3g { union { const int a; int b; }; };
+NotDeleted3g nd3g;
+
+// - X is a union and all of its variant members are of const-qualified type (or
+// array thereof),
+union Deleted4a {
+ const int a;
+ const int b;
+ const UserProvidedDefCtor c; // expected-note {{because field 'c' has a non-trivial default constructor}}
+};
+Deleted4a d4a; // expected-error {{implicitly-deleted default constructor}}
+union NotDeleted4a { const int a; int b; };
+NotDeleted4a nd4a;
+
+// - X is a non-union class and all members of any anonymous union member are of
+// const-qualified type (or array thereof),
+struct Deleted5a {
+ union { const int a; }; // expected-note {{because all data members of an anonymous union member are const-qualified}}
+ union { int b; };
+};
+Deleted5a d5a; // expected-error {{implicitly-deleted default constructor}}
+struct NotDeleted5a { union { const int a; int b; }; union { const int c; int d; }; };
+NotDeleted5a nd5a;
+
+// - any direct or virtual base class, or non-static data member with no
+// brace-or-equal-initializer, has class type M (or array thereof) and either
+// M has no default constructor or overload resolution as applied to M's default
+// constructor results in an ambiguity or in a function that is deleted or
+// inaccessible from the defaulted default constructor, or
+struct Deleted6a : Deleted2a {}; // expected-note {{because base class 'Deleted2a' has a deleted default constructor}}
+Deleted6a d6a; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted6b : virtual Deleted2a {}; // expected-note {{because base class 'Deleted2a' has a deleted default constructor}}
+Deleted6b d6b; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted6c { Deleted2a a; }; // expected-note {{because field 'a' has a deleted default constructor}}
+Deleted6c d6c; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted6d { DeletedDefCtor a; }; // expected-note {{because field 'a' has a deleted default constructor}}
+Deleted6d d6d; // expected-error {{implicitly-deleted default constructor}}
+struct NotDeleted6a { DeletedDefCtor a = 0; };
+NotDeleted6a nd6a;
+struct Deleted6e { PrivateDefCtor a; }; // expected-note {{because field 'a' has an inaccessible default constructor}}
+Deleted6e d6e; // expected-error {{implicitly-deleted default constructor}}
+struct NotDeleted6b { PrivateDefCtor a = 0; };
+NotDeleted6b nd6b;
+struct NotDeleted6c { Friend a; };
+NotDeleted6c nd6c;
+
+// - any direct or virtual base class or non-static data member has a type with
+// a destructor that is deleted or inaccessible from the defaulted default
+// constructor.
+struct Deleted7a : DeletedDtor {}; // expected-note {{because base class 'DeletedDtor' has a deleted destructor}}
+Deleted7a d7a; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted7b : virtual DeletedDtor {}; // expected-note {{because base class 'DeletedDtor' has a deleted destructor}}
+Deleted7b d7b; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted7c { DeletedDtor a; }; // expected-note {{because field 'a' has a deleted destructor}}
+Deleted7c d7c; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted7d { DeletedDtor a = {}; }; // expected-note {{because field 'a' has a deleted destructor}}
+Deleted7d d7d; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted7e : PrivateDtor {}; // expected-note {{base class 'PrivateDtor' has an inaccessible destructor}}
+Deleted7e d7e; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted7f : virtual PrivateDtor {}; // expected-note {{base class 'PrivateDtor' has an inaccessible destructor}}
+Deleted7f d7f; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted7g { PrivateDtor a; }; // expected-note {{field 'a' has an inaccessible destructor}}
+Deleted7g d7g; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted7h { PrivateDtor a = {}; }; // expected-note {{field 'a' has an inaccessible destructor}}
+Deleted7h d7h; // expected-error {{implicitly-deleted default constructor}}
+struct NotDeleted7i : Friend {};
+NotDeleted7i d7i;
+struct NotDeleted7j : virtual Friend {};
+NotDeleted7j d7j;
+struct NotDeleted7k { Friend a; };
+NotDeleted7k d7k;
+
+
+class Trivial { static const int n = 42; };
+static_assert(__has_trivial_constructor(Trivial), "Trivial is nontrivial");
+
+// A default constructor is trivial if it is not user-provided and if:
+class NonTrivialDefCtor1 { NonTrivialDefCtor1(); };
+static_assert(!__has_trivial_constructor(NonTrivialDefCtor1), "NonTrivialDefCtor1 is trivial");
+
+// - its class has no virtual functions (10.3) and no virtual base classes (10.1), and
+class NonTrivialDefCtor2 { virtual void f(); };
+static_assert(!__has_trivial_constructor(NonTrivialDefCtor2), "NonTrivialDefCtor2 is trivial");
+class NonTrivialDefCtor3 : virtual Trivial {};
+static_assert(!__has_trivial_constructor(NonTrivialDefCtor3), "NonTrivialDefCtor3 is trivial");
+
+// - no non-static data member of its class has a brace-or-equal-initializer, and
+class NonTrivialDefCtor4 { int m = 52; };
+static_assert(!__has_trivial_constructor(NonTrivialDefCtor4), "NonTrivialDefCtor4 is trivial");
+
+// - all the direct base classes of its class have trivial default constructors, and
+class NonTrivialDefCtor5 : NonTrivialDefCtor1 {};
+static_assert(!__has_trivial_constructor(NonTrivialDefCtor5), "NonTrivialDefCtor5 is trivial");
+
+// - for all the non-static data members of its class that are of class type (or array thereof), each such class
+// has a trivial default constructor.
+class NonTrivialDefCtor6 { NonTrivialDefCtor1 t; };
+static_assert(!__has_trivial_constructor(NonTrivialDefCtor6), "NonTrivialDefCtor5 is trivial");
+
+// Otherwise, the default constructor is non-trivial.
+class Trivial2 { Trivial2() = delete; };
+static_assert(__has_trivial_constructor(Trivial2), "Trivial2 is trivial");
+
+class Trivial3 { Trivial3() = default; };
+static_assert(__has_trivial_constructor(Trivial3), "Trivial3 is trivial");
+
+template<typename T> class Trivial4 { Trivial4() = default; };
+static_assert(__has_trivial_constructor(Trivial4<int>), "Trivial4 is trivial");
+
+template<typename T> class Trivial5 { Trivial5() = delete; };
+static_assert(__has_trivial_constructor(Trivial5<int>), "Trivial5 is trivial");
diff --git a/clang/test/CXX/special/class.ctor/p6-0x.cpp b/clang/test/CXX/special/class.ctor/p6-0x.cpp
new file mode 100644
index 0000000..8c8800f
--- /dev/null
+++ b/clang/test/CXX/special/class.ctor/p6-0x.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+// Implicitly-defined default constructors are constexpr if the implicit
+// definition would be.
+struct NonConstexpr1 { // expected-note {{here}}
+ int a;
+};
+struct NonConstexpr2 { // expected-note {{here}}
+ NonConstexpr1 nl;
+};
+struct NonConstexpr2a : NonConstexpr1 { };
+constexpr NonConstexpr1 nc1 = NonConstexpr1(); // ok, does not call constructor
+constexpr NonConstexpr2 nc2 = NonConstexpr2(); // ok, does not call constructor
+constexpr NonConstexpr2a nc2a = NonConstexpr2a(); // ok, does not call constructor
+constexpr int nc2_a = NonConstexpr2().nl.a; // ok
+constexpr int nc2a_a = NonConstexpr2a().a; // ok
+struct Helper {
+ friend constexpr NonConstexpr1::NonConstexpr1(); // expected-error {{follows non-constexpr declaration}}
+ friend constexpr NonConstexpr2::NonConstexpr2(); // expected-error {{follows non-constexpr declaration}}
+};
+
+struct Constexpr1 {};
+constexpr Constexpr1 c1 = Constexpr1(); // ok
+struct NonConstexpr3 : virtual Constexpr1 {}; // expected-note {{struct with virtual base}} expected-note {{declared here}}
+constexpr NonConstexpr3 nc3 = NonConstexpr3(); // expected-error {{non-literal type 'const NonConstexpr3'}}
+
+struct Constexpr2 {
+ int a = 0;
+};
+constexpr Constexpr2 c2 = Constexpr2(); // ok
+
+int n;
+struct Member {
+ Member() : a(n) {}
+ constexpr Member(int&a) : a(a) {}
+ int &a;
+};
+struct NonConstexpr4 { // expected-note {{here}}
+ Member m;
+};
+constexpr NonConstexpr4 nc4 = NonConstexpr4(); // expected-error {{constant expression}} expected-note {{non-constexpr constructor 'NonConstexpr4'}}
+struct Constexpr3 {
+ constexpr Constexpr3() : m(n) {}
+ Member m;
+};
+constexpr Constexpr3 c3 = Constexpr3(); // ok
+struct Constexpr4 {
+ Constexpr3 m;
+};
+constexpr Constexpr4 c4 = Constexpr4(); // ok
+
+
+// This rule breaks some legal C++98 programs!
+struct A {}; // expected-note {{here}}
+struct B {
+ friend A::A(); // expected-error {{non-constexpr declaration of 'A' follows constexpr declaration}}
+};
diff --git a/clang/test/CXX/special/class.dtor/p10-0x.cpp b/clang/test/CXX/special/class.dtor/p10-0x.cpp
new file mode 100644
index 0000000..e10afb5
--- /dev/null
+++ b/clang/test/CXX/special/class.dtor/p10-0x.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// PR10127/N3031
+struct A { ~A(); };
+struct B {};
+template<typename T>
+void b(const T *x, const A *y) {
+ x->~decltype(T())();
+ x->~decltype(*x)(); // expected-error{{the type of object expression ('const int') does not match the type being destroyed ('decltype(*x)' (aka 'const int &')) in pseudo-destructor expression}} \
+ expected-error{{no member named '~const struct A &' in 'A'}}
+ x->~decltype(int())(); // expected-error{{no member named '~int' in 'A'}}
+
+ y->~decltype(*y)(); // expected-error{{destructor type 'decltype(*y)' (aka 'const A &') in object destruction expression does not match the type 'const A' of the object being destroyed}}
+ y->~decltype(T())(); // expected-error{{destructor type 'decltype(T())' in object destruction expression does not match the type 'const A' of the object being destroyed}}
+ y->~decltype(A())();
+}
+template void b(const int*, const A*); // expected-note{{in instantiation of function template specialization 'b<int>' requested here}}
+template void b(const A*,const A*); // expected-note{{in instantiation of function template specialization 'b<A>' requested here}}
+void a(const A *x, int i, int *pi) {
+ x->~decltype(A())();
+ x->~decltype(*x)(); // expected-error{{destructor type 'decltype(*x)' (aka 'const A &') in object destruction expression does not match the type 'const A' of the object being destroyed}}
+ x->~decltype()(); // expected-error{{expected expression}}
+ x->~decltype(B())(); // expected-error{{destructor type 'decltype(B())' (aka 'B') in object destruction expression does not match the type 'const A' of the object being destroyed}}
+ x->~decltype(x)(); // expected-error{{destructor type 'decltype(x)' (aka 'const A *') in object destruction expression does not match the type 'const A' of the object being destroyed}}
+ // this last one could be better, mentioning that the nested-name-specifier could be removed or a type name after the ~
+ x->::A::~decltype(*x)(); // expected-error{{expected a class name after '~' to name a destructor}}
+ y->~decltype(A())(); // expected-error{{use of undeclared identifier 'y'}}
+
+ typedef int *intp;
+ i->~decltype(int())(); // expected-error{{member reference type 'int' is not a pointer; maybe you meant to use '.'?}}
+ i.~decltype(int())();
+ i->~decltype(intp())(); // expected-error{{member reference type 'int' is not a pointer; maybe you meant to use '.'?}} \
+ expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}
+ i.~decltype(intp())(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}
+ pi->~decltype(int())();
+ pi.~decltype(int())(); // expected-error{{the type of object expression ('int *') does not match the type being destroyed ('decltype(int())' (aka 'int')) in pseudo-destructor expression}}
+ pi.~decltype(intp())();
+ pi->~decltype(intp())(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}
+}
diff --git a/clang/test/CXX/special/class.dtor/p2-0x.cpp b/clang/test/CXX/special/class.dtor/p2-0x.cpp
new file mode 100644
index 0000000..c7b1b58
--- /dev/null
+++ b/clang/test/CXX/special/class.dtor/p2-0x.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// A destructor shall not be declared with a ref-qualifier.
+struct X {
+ ~X() &; // expected-error{{ref-qualifier '&' is not allowed on a destructor}}
+};
+
+struct Y {
+ ~Y() &&; // expected-error{{ref-qualifier '&&' is not allowed on a destructor}}
+};
diff --git a/clang/test/CXX/special/class.dtor/p2.cpp b/clang/test/CXX/special/class.dtor/p2.cpp
new file mode 100644
index 0000000..b05c992
--- /dev/null
+++ b/clang/test/CXX/special/class.dtor/p2.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR5548
+struct A {~A();};
+void a(const A* x) {
+ x->~A();
+}
diff --git a/clang/test/CXX/special/class.dtor/p3-0x.cpp b/clang/test/CXX/special/class.dtor/p3-0x.cpp
new file mode 100644
index 0000000..44bf5aa
--- /dev/null
+++ b/clang/test/CXX/special/class.dtor/p3-0x.cpp
@@ -0,0 +1,177 @@
+// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+struct A {
+ ~A();
+};
+
+struct B {
+ ~B() throw(int);
+};
+
+struct C {
+ B b;
+ ~C() {}
+};
+
+struct D {
+ ~D() noexcept(false);
+};
+
+struct E {
+ D d;
+ ~E() {}
+};
+
+void foo() {
+ A a;
+ C c;
+ E e;
+ // CHECK: invoke {{.*}} @_ZN1ED1Ev
+ // CHECK: invoke {{.*}} @_ZN1CD1Ev
+ // CHECK: call {{.*}} @_ZN1AD1Ev
+}
+
+struct F {
+ D d;
+ ~F();
+};
+F::~F() noexcept(false) {}
+
+struct G {
+ D d;
+ ~G();
+};
+G::~G() {}
+
+struct H {
+ B b;
+ ~H();
+};
+H::~H() throw(int) {}
+
+struct I {
+ B b;
+ ~I();
+};
+I::~I() {}
+
+// Template variants.
+
+template <typename T>
+struct TA {
+ ~TA();
+};
+
+template <typename T>
+struct TB {
+ ~TB() throw(int);
+};
+
+template <typename T>
+struct TC {
+ TB<T> b;
+ ~TC() {}
+};
+
+template <typename T>
+struct TD {
+ ~TD() noexcept(false);
+};
+
+template <typename T>
+struct TE {
+ TD<T> d;
+ ~TE() {}
+};
+
+void tfoo() {
+ TA<int> a;
+ TC<int> c;
+ TE<int> e;
+ // CHECK: invoke {{.*}} @_ZN2TEIiED1Ev
+ // CHECK: invoke {{.*}} @_ZN2TCIiED1Ev
+ // CHECK: call {{.*}} @_ZN2TAIiED1Ev
+}
+
+template <typename T>
+struct TF {
+ TD<T> d;
+ ~TF();
+};
+template <typename T>
+TF<T>::~TF() noexcept(false) {}
+
+template <typename T>
+struct TG {
+ TD<T> d;
+ ~TG();
+};
+template <typename T>
+TG<T>::~TG() {}
+
+template <typename T>
+struct TH {
+ TB<T> b;
+ ~TH();
+};
+template <typename T>
+TH<T>::~TH() {}
+
+void tinst() {
+ TF<int> f;
+ TG<int> g;
+ TH<int> h;
+}
+// CHECK: define linkonce_odr {{.*}} @_ZN2THIiED1Ev
+// CHECK: _ZTIi
+// CHECK: __cxa_call_unexpected
+
+struct VX
+{ virtual ~VX() {} };
+
+struct VY : VX
+{ virtual ~VY() {} };
+
+template<typename T>
+struct TVY : VX
+{ virtual ~TVY() {} };
+
+
+struct VA {
+ B b;
+ virtual ~VA() {}
+};
+
+struct VB : VA
+{ virtual ~VB() {} };
+
+template<typename T>
+struct TVB : VA
+{ virtual ~TVB() {} };
+
+void tinst2() {
+ TVY<int> tvy;
+ TVB<int> tvb;
+}
+
+template <typename T>
+struct Sw {
+ T t;
+ ~Sw() {}
+};
+
+void tsw() {
+ Sw<int> swi;
+ Sw<B> swb;
+}
+// CHECK-NOT: define linkonce_odr {{.*}} @_ZN2SwI1BED1Ev({{.*}} nounwind
+// CHECK: define linkonce_odr {{.*}} @_ZN2SwI1BED1Ev({{.*}}
+// CHECK: _ZTIi
+// CHECK: __cxa_call_unexpected
+// CHECK: define linkonce_odr {{.*}} @_ZN2SwIiED1Ev({{.*}} nounwind
+
+template <typename T>
+struct TVC : VX
+{ virtual ~TVC(); };
+template <typename T>
+TVC<T>::~TVC() {}
diff --git a/clang/test/CXX/special/class.dtor/p5-0x.cpp b/clang/test/CXX/special/class.dtor/p5-0x.cpp
new file mode 100644
index 0000000..dbfa004
--- /dev/null
+++ b/clang/test/CXX/special/class.dtor/p5-0x.cpp
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+struct NonTrivDtor {
+ ~NonTrivDtor();
+};
+struct DeletedDtor {
+ ~DeletedDtor() = delete; // expected-note 5 {{deleted here}}
+};
+class InaccessibleDtor {
+ ~InaccessibleDtor() = default;
+};
+
+// A defaulted destructor for a class X is defined as deleted if:
+
+// -- X is a union-like class that has a variant member with a non-trivial
+// destructor.
+union A1 {
+ A1();
+ NonTrivDtor n; // expected-note {{destructor of union 'A1' is implicitly deleted because field 'n' has a non-trivial destructor}}
+};
+A1 a1; // expected-error {{deleted function}}
+struct A2 {
+ A2();
+ union {
+ NonTrivDtor n; // expected-note {{because field 'n' has a non-trivial destructor}}
+ };
+};
+A2 a2; // expected-error {{deleted function}}
+union A3 {
+ A3();
+ NonTrivDtor n[3]; // expected-note {{because field 'n' has a non-trivial destructor}}
+};
+A3 a3; // expected-error {{deleted function}}
+struct A4 {
+ A4();
+ union {
+ NonTrivDtor n[3]; // expected-note {{because field 'n' has a non-trivial destructor}}
+ };
+};
+A4 a4; // expected-error {{deleted function}}
+
+// -- any of the non-static data members has class type M (or array thereof) and
+// M has a deleted or inaccessible destructor.
+struct B1 {
+ B1();
+ DeletedDtor a; // expected-note {{because field 'a' has a deleted destructor}}
+};
+B1 b1; // expected-error {{deleted function}}
+struct B2 {
+ B2();
+ InaccessibleDtor a; // expected-note {{because field 'a' has an inaccessible destructor}}
+};
+B2 b2; // expected-error {{deleted function}}
+struct B3 {
+ B3();
+ DeletedDtor a[4]; // expected-note {{because field 'a' has a deleted destructor}}
+};
+B3 b3; // expected-error {{deleted function}}
+struct B4 {
+ B4();
+ InaccessibleDtor a[4]; // expected-note {{because field 'a' has an inaccessible destructor}}
+};
+B4 b4; // expected-error {{deleted function}}
+union B5 {
+ B5();
+ // FIXME: Describe the anonymous union member better than ''.
+ union { // expected-note {{because field '' has a deleted destructor}}
+ DeletedDtor a; // expected-note {{because field 'a' has a deleted destructor}}
+ };
+};
+B5 b5; // expected-error {{deleted function}}
+union B6 {
+ B6();
+ union { // expected-note {{because field '' has a deleted destructor}}
+ InaccessibleDtor a; // expected-note {{because field 'a' has an inaccessible destructor}}
+ };
+};
+B6 b6; // expected-error {{deleted function}}
+
+// -- any direct or virtual base class has a deleted or inaccessible destructor.
+struct C1 : DeletedDtor { C1(); } c1; // expected-error {{deleted function}} expected-note {{base class 'DeletedDtor' has a deleted destructor}}
+struct C2 : InaccessibleDtor { C2(); } c2; // expected-error {{deleted function}} expected-note {{base class 'InaccessibleDtor' has an inaccessible destructor}}
+struct C3 : virtual DeletedDtor { C3(); } c3; // expected-error {{deleted function}} expected-note {{base class 'DeletedDtor' has a deleted destructor}}
+struct C4 : virtual InaccessibleDtor { C4(); } c4; // expected-error {{deleted function}} expected-note {{base class 'InaccessibleDtor' has an inaccessible destructor}}
+
+// -- for a virtual destructor, lookup of the non-array deallocation function
+// results in an ambiguity or a function that is deleted or inaccessible.
+class D1 {
+ void operator delete(void*);
+public:
+ virtual ~D1() = default;
+} d1; // ok
+struct D2 : D1 { // expected-note {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
+ // implicitly-virtual destructor
+} d2; // expected-error {{deleted function}}
+struct D3 { // expected-note {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
+ virtual ~D3() = default; // expected-note {{explicitly defaulted function was implicitly deleted here}}
+ void operator delete(void*, double = 0.0);
+ void operator delete(void*, char = 0);
+} d3; // expected-error {{deleted function}}
+struct D4 { // expected-note {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
+ virtual ~D4() = default; // expected-note {{implicitly deleted here}}
+ void operator delete(void*) = delete;
+} d4; // expected-error {{deleted function}}
diff --git a/clang/test/CXX/special/class.dtor/p9.cpp b/clang/test/CXX/special/class.dtor/p9.cpp
new file mode 100644
index 0000000..8b76a15
--- /dev/null
+++ b/clang/test/CXX/special/class.dtor/p9.cpp
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef typeof(sizeof(int)) size_t;
+
+// PR7803
+namespace test0 {
+ class A {
+ public:
+ static void operator delete(void *p) {};
+ virtual ~A();
+ };
+
+ class B : protected A {
+ public:
+ ~B();
+ };
+
+ class C : protected B {
+ public:
+ using B::operator delete;
+ ~C();
+ };
+
+ // Shouldn't have an error.
+ C::~C() {}
+}
+
+namespace test1 {
+ class A {
+ public:
+ static void operator delete(void *p) {}; // expected-note {{member 'operator delete' declared here}}
+ virtual ~A();
+ };
+
+ class B : protected A {
+ public:
+ static void operator delete(void *, size_t) {}; // expected-note {{member 'operator delete' declared here}}
+ ~B();
+ };
+
+ class C : protected B {
+ public:
+ using A::operator delete;
+ using B::operator delete;
+
+ ~C();
+ };
+
+ C::~C() {} // expected-error {{multiple suitable 'operator delete' functions in 'C'}}
+}
+
+// ...at the point of definition of a virtual destructor...
+namespace test2 {
+ struct A {
+ virtual ~A();
+ static void operator delete(void*, const int &);
+ };
+
+ struct B {
+ virtual ~B();
+ static void operator delete(void*, const int &); // expected-note {{declared here}}
+ };
+ B::~B() {} // expected-error {{no suitable member 'operator delete' in 'B'}}
+
+ struct CBase { virtual ~CBase(); };
+ struct C : CBase { // expected-error {{no suitable member 'operator delete' in 'C'}}
+ static void operator delete(void*, const int &); // expected-note {{declared here}}
+ };
+ void test() {
+ C c; // expected-note {{first required here}}
+ }
+}
+
+// PR7346
+namespace test3 {
+ struct A {
+ virtual ~A();
+ static void operator delete(void*, const int &);
+ };
+
+ struct B : A {
+ virtual ~B() {}
+ static void operator delete(void*);
+ };
+}
diff --git a/clang/test/CXX/special/class.free/p1.cpp b/clang/test/CXX/special/class.free/p1.cpp
new file mode 100644
index 0000000..5c0240b
--- /dev/null
+++ b/clang/test/CXX/special/class.free/p1.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+#include <stddef.h>
+
+struct A {
+ void *operator new(size_t) {
+ return this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
+ }
+ void *operator new[](size_t) {
+ return this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
+ }
+};
diff --git a/clang/test/CXX/special/class.free/p6.cpp b/clang/test/CXX/special/class.free/p6.cpp
new file mode 100644
index 0000000..fc4b2ae
--- /dev/null
+++ b/clang/test/CXX/special/class.free/p6.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+#include <stddef.h>
+
+struct A {
+ void operator delete(void*) {
+ (void)this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
+ }
+ void operator delete[](void*) {
+ (void)this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
+ }
+};
diff --git a/clang/test/CXX/special/class.inhctor/elsewhere.cpp b/clang/test/CXX/special/class.inhctor/elsewhere.cpp
new file mode 100644
index 0000000..09fd3d5
--- /dev/null
+++ b/clang/test/CXX/special/class.inhctor/elsewhere.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Tests related to constructor inheriting, but not specified in [class.inhctor]
+
+// [namespace.udecl]p8:
+// A using-declaration for a class member shall be a member-declaration.
+
+struct B1 {
+ B1(int);
+};
+
+using B1::B1; // expected-error {{using declaration can not refer to class member}} expected-error {{not supported}}
+
+// C++0x [namespace.udecl]p10:
+// A using-declaration is a declaration and can therefore be used repeatedly
+// where (and only where) multiple declarations are allowed.
+
+struct I1 : B1 {
+ using B1::B1; // expected-note {{previous using declaration}} expected-error {{not supported}}
+ using B1::B1; // expected-error {{redeclaration of using decl}} expected-error {{not supported}}
+};
+
+// C++0x [namespace.udecl]p3:
+// In a using declaration used as a member-declaration, the nested-name-
+// specifier shall name a base class of the class being defined.
+// If such a using-declaration names a constructor, the nested-name-specifier
+// shall name a direct base class of the class being defined.
+
+struct D1 : I1 {
+ using B1::B1; // expected-error {{'B1' is not a direct base of 'D1', can not inherit constructors}} expected-error {{not supported}}
+};
+
+template<typename T> struct A {};
+
+template<typename T> struct B : A<bool>, A<char> {
+ using A<T>::A; // expected-error {{'A<double>::', which is not a base class of 'B<double>'}} expected-error {{not supported}}
+};
+B<bool> bb;
+B<char> bc;
+B<double> bd; // expected-note {{here}}
+
+template<typename T> struct C : A<T> {
+ using A<bool>::A; // expected-error {{'A<bool>::', which is not a base class of 'C<char>'}} expected-error {{not supported}}
+};
+C<bool> cb;
+C<char> cc; // expected-note {{here}}
+
+template<typename T> struct D : A<T> {};
+template<typename T> struct E : D<T> {
+ using A<bool>::A; // expected-error {{'A<bool>' is not a direct base of 'E<bool>', can not inherit}} expected-error {{not supported}}
+};
+E<bool> eb; // expected-note {{here}}
+
+template<typename T> struct F : D<bool> {
+ using A<T>::A; // expected-error {{'A<bool>' is not a direct base of 'F<bool>'}} expected-error {{not supported}}
+};
+F<bool> fb; // expected-note {{here}}
diff --git a/clang/test/CXX/special/class.inhctor/p3.cpp b/clang/test/CXX/special/class.inhctor/p3.cpp
new file mode 100644
index 0000000..d7093fb
--- /dev/null
+++ b/clang/test/CXX/special/class.inhctor/p3.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct B1 {
+ B1(int);
+ B1(int, int);
+};
+struct D1 : B1 {
+ using B1::B1; // expected-error {{not supported}}
+};
+D1 d1a(1), d1b(1, 1);
+
+D1 fd1() { return 1; }
+
+struct B2 {
+ explicit B2(int, int = 0, int = 0);
+};
+struct D2 : B2 { // expected-note 2 {{candidate constructor}}
+ using B2::B2; // expected-error {{not supported}}
+};
+D2 d2a(1), d2b(1, 1), d2c(1, 1, 1);
+
+D2 fd2() { return 1; } // expected-error {{no viable conversion}}
+
+struct B3 {
+ B3(void*); // expected-note {{inherited from here}}
+};
+struct D3 : B3 { // expected-note 2 {{candidate constructor}}
+ using B3::B3; // expected-note {{candidate constructor (inherited)}} expected-error {{not supported}}
+};
+D3 fd3() { return 1; } // expected-error {{no viable conversion}}
+
+template<typename T> struct T1 : B1 {
+ using B1::B1; // expected-error {{not supported}}
+};
+template<typename T> struct T2 : T1<T> {
+ using T1<int>::T1; // expected-error {{not supported}}
+};
+template<typename T> struct T3 : T1<int> {
+ using T1<T>::T1; // expected-error {{not supported}}
+};
+struct U {
+ friend T1<int>::T1(int);
+ friend T1<int>::T1(int, int);
+ friend T2<int>::T2(int);
+ friend T2<int>::T2(int, int);
+ friend T3<int>::T3(int);
+ friend T3<int>::T3(int, int);
+};
diff --git a/clang/test/CXX/special/class.inhctor/p7.cpp b/clang/test/CXX/special/class.inhctor/p7.cpp
new file mode 100644
index 0000000..bfaa3ac
--- /dev/null
+++ b/clang/test/CXX/special/class.inhctor/p7.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Straight from the standard
+struct B1 {
+ B1(int); // expected-note {{previous constructor}} expected-note {{conflicting constructor}}
+};
+struct B2 {
+ B2(int); // expected-note {{conflicting constructor}}
+};
+struct D1 : B1, B2 {
+ using B1::B1; // expected-note {{inherited here}} expected-error {{not supported}}
+ using B2::B2; // expected-error {{already inherited constructor with the same signature}} expected-error {{not supported}}
+};
+struct D2 : B1, B2 {
+ using B1::B1; // expected-error {{not supported}}
+ using B2::B2; // expected-error {{not supported}}
+ D2(int);
+};
+
+template<typename T> struct B3 {
+ B3(T); // expected-note {{previous constructor}}
+};
+template<typename T> struct B4 : B3<T>, B1 {
+ B4();
+ using B3<T>::B3; // expected-note {{inherited here}} expected-error {{not supported}}
+ using B1::B1; // expected-error {{already inherited}} expected-error {{not supported}}
+};
+B4<char> b4c;
+B4<int> b4i; // expected-note {{here}}
diff --git a/clang/test/CXX/special/class.init/class.base.init/p8-0x.cpp b/clang/test/CXX/special/class.init/class.base.init/p8-0x.cpp
new file mode 100644
index 0000000..a108533
--- /dev/null
+++ b/clang/test/CXX/special/class.init/class.base.init/p8-0x.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+int n;
+struct S {
+ int &a; // expected-note 2{{here}}
+ int &b = n;
+
+ union {
+ const int k = 42;
+ };
+
+ S() {} // expected-error {{constructor for 'S' must explicitly initialize the reference member 'a'}}
+ S(int) : a(n) {} // ok
+ S(char) : b(n) {} // expected-error {{constructor for 'S' must explicitly initialize the reference member 'a'}}
+ S(double) : a(n), b(n) {} // ok
+} s(0);
+
+union U {
+ int a = 0; // desired-note 5 {{previous initialization is here}}
+ char b = 'x';
+
+ // FIXME: these should all be rejected
+ U() {} // desired-error {{initializing multiple members of union}}
+ U(int) : a(1) {} // desired-error {{initializing multiple members of union}}
+ U(char) : b('y') {} // desired-error {{initializing multiple members of union}}
+ // this expected note should be removed & the note should appear on the
+ // declaration of 'a' when this set of cases is handled correctly.
+ U(double) : a(1), // expected-note{{previous initialization is here}} desired-error {{initializing multiple members of union}}
+ b('y') {} // expected-error{{initializing multiple members of union}}
+};
+
+// PR10954: variant members do not acquire an implicit initializer.
+namespace VariantMembers {
+ struct NoDefaultCtor {
+ NoDefaultCtor(int);
+ };
+ union V {
+ NoDefaultCtor ndc;
+ int n;
+
+ V() {}
+ V(int n) : n(n) {}
+ V(int n, bool) : ndc(n) {}
+ };
+ struct K {
+ union {
+ NoDefaultCtor ndc;
+ int n;
+ };
+ K() {}
+ K(int n) : n(n) {}
+ K(int n, bool) : ndc(n) {}
+ };
+ struct Nested {
+ Nested() {}
+ union {
+ struct {
+ NoDefaultCtor ndc;
+ };
+ };
+ };
+}
diff --git a/clang/test/CXX/special/class.init/class.base.init/p9-0x.cpp b/clang/test/CXX/special/class.init/class.base.init/p9-0x.cpp
new file mode 100644
index 0000000..ca5e807
--- /dev/null
+++ b/clang/test/CXX/special/class.init/class.base.init/p9-0x.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++11 %s -O1 -emit-llvm -o - | FileCheck %s
+
+struct S {
+ int n = 10;
+ int m = 2 * n;
+
+ S() {}
+ S(int a) : n(a) {}
+ S(int a, int b) : n(a), m(b) {}
+
+ struct T {
+ T *that = this;
+ };
+};
+
+template<typename T>
+struct U {
+ T *r = &q;
+ T q = 42;
+ U *p = this;
+};
+
+S a;
+// CHECK: @a = {{.*}} { i32 10, i32 20 }
+
+S b(5);
+// CHECK: @b = {{.*}} { i32 5, i32 10 }
+
+S c(3, 9);
+// CHECK: @c = {{.*}} { i32 3, i32 9 }
+
+S::T d;
+// CHECK: @d = {{.*}} { {{.*}} @d }
+
+U<S> e;
+// CHECK: @e = {{.*}} { {{.*}} { i32 42, i32 84 }, {{.*}} @e }
diff --git a/clang/test/CXX/special/class.temporary/p1.cpp b/clang/test/CXX/special/class.temporary/p1.cpp
new file mode 100644
index 0000000..4f6ac0a
--- /dev/null
+++ b/clang/test/CXX/special/class.temporary/p1.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+namespace test0 {
+ struct A {
+ A() = default;
+ int x;
+ int y;
+
+ A(const A&) = delete; // expected-note {{function has been explicitly marked deleted here}}
+ };
+
+ void foo(...);
+
+ void test() {
+ A a;
+ foo(a); // expected-error {{call to deleted constructor of 'test0::A'}}
+ }
+}
+
+namespace test1 {
+ struct A {
+ A() = default;
+ int x;
+ int y;
+
+ private:
+ A(const A&) = default; // expected-note {{declared private here}}
+ };
+
+ void foo(...);
+
+ void test() {
+ A a;
+ foo(a); // expected-error {{calling a private constructor of class 'test1::A'}}
+ }
+}
+
+// Don't enforce this in an unevaluated context.
+namespace test2 {
+ struct A {
+ A(const A&) = delete; // expected-note {{marked deleted here}}
+ };
+
+ typedef char one[1];
+ typedef char two[2];
+
+ one &meta(bool);
+ two &meta(...);
+
+ void a(A &a) {
+ char check[sizeof(meta(a)) == 2 ? 1 : -1];
+ }
+
+ void b(A &a) {
+ meta(a); // expected-error {{call to deleted constructor}}
+ }
+}
diff --git a/clang/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp b/clang/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp
new file mode 100644
index 0000000..81e8e25
--- /dev/null
+++ b/clang/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct T {
+ struct x {
+ int m;
+ };
+ x* operator->();
+ void operator++(int);
+ void operator<<(int);
+ T();
+ T(int);
+ T(int, int);
+};
+
+template<typename A, typename B, typename C, typename D, typename E>
+void func(A, B, C, D, E);
+
+void func(int a, int c) {
+ T(a)->m = 7;
+ T(a)++;
+ T(a,5)<<c;
+
+ T(*d)(int);
+ T(e)[5];
+ T(f) = {1, 2};
+ T(*g)(double(3)); // expected-error{{cannot initialize a variable of type 'T (*)' with an rvalue of type 'double'}}
+ func(a, d, e, f, g);
+}
+
+void func2(int a, int c) {
+ decltype(T())(a)->m = 7;
+ decltype(T())(a)++;
+ decltype(T())(a,5)<<c;
+
+ decltype(T())(*d)(int);
+ decltype(T())(e)[5];
+ decltype(T())(f) = {1, 2};
+ decltype(T())(*g)(double(3)); // expected-error{{cannot initialize a variable of type 'decltype(T()) (*)' (aka 'T *') with an rvalue of type 'double'}}
+ func(a, d, e, f, g);
+}
diff --git a/clang/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp b/clang/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp
new file mode 100644
index 0000000..574cb40
--- /dev/null
+++ b/clang/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// PR10034
+struct X {};
+
+void exx(X) {}
+
+int test_ptr10034(int argc, char **argv)
+{
+ if (argc > 3)
+ goto end;
+
+ X x;
+ X xs[16];
+ exx(x);
+
+ end:
+ if (argc > 1) {
+ for (int i = 0; i < argc; ++i)
+ {
+
+ }
+ }
+ return 0;
+}
+
+struct Y {
+ ~Y();
+};
+
+void f();
+void test_Y() {
+ goto end; // expected-error{{goto into protected scope}}
+ Y y; // expected-note{{jump bypasses variable with a non-trivial destructor}}
+ end:
+ f();
+ goto inner; // expected-error{{goto into protected scope}}
+ {
+ Y y2; // expected-note{{jump bypasses variable with a non-trivial destructor}}
+ inner:
+ f();
+ }
+ return;
+}
+
+struct Z {
+ Z operator=(const Z&);
+};
+
+void test_Z() {
+ goto end;
+ Z z;
+ end:
+ return;
+}
diff --git a/clang/test/CXX/stmt.stmt/stmt.dcl/p3.cpp b/clang/test/CXX/stmt.stmt/stmt.dcl/p3.cpp
new file mode 100644
index 0000000..f52e3b6
--- /dev/null
+++ b/clang/test/CXX/stmt.stmt/stmt.dcl/p3.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR10034
+struct X {};
+
+void exx(X) {}
+
+int test_ptr10034(int argc, char **argv)
+{
+ if (argc > 3)
+ goto end;
+
+ X x;
+ X xs[16];
+ exx(x);
+
+ end:
+ if (argc > 1) {
+ for (int i = 0; i < argc; ++i)
+ {
+
+ }
+ }
+ return 0;
+}
+
+struct Y {
+ ~Y();
+};
+
+void test_Y() {
+ goto end; // expected-error{{goto into protected scope}}
+ Y y; // expected-note{{jump bypasses variable with a non-trivial destructor}}
+ end:
+ return;
+}
+
+struct Z {
+ Z operator=(const Z&);
+};
+
+void test_Z() {
+ goto end; // expected-error{{goto into protected scope}}
+ Z z; // expected-note{{jump bypasses initialization of non-POD variable}}
+ end:
+ return;
+}
diff --git a/clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp b/clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
new file mode 100644
index 0000000..a45b35f
--- /dev/null
+++ b/clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
@@ -0,0 +1,209 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+namespace std {
+ template<typename T>
+ auto begin(T &&t) -> decltype(t.begin()) { return t.begin(); } // expected-note 4{{ignored: substitution failure}}
+ template<typename T>
+ auto end(T &&t) -> decltype(t.end()) { return t.end(); } // expected-note {{candidate template ignored: substitution failure [with T = }}
+
+ template<typename T>
+ auto begin(T &&t) -> decltype(t.alt_begin()) { return t.alt_begin(); } // expected-note {{selected 'begin' template [with T = }} \
+ expected-note 4{{candidate template ignored: substitution failure [with T = }}
+ template<typename T>
+ auto end(T &&t) -> decltype(t.alt_end()) { return t.alt_end(); } // expected-note {{candidate template ignored: substitution failure [with T = }}
+
+ namespace inner {
+ // These should never be considered.
+ int begin(int);
+ int end(int);
+ }
+
+ using namespace inner;
+}
+
+struct A { // expected-note 2 {{candidate constructor}}
+ A();
+ int *begin(); // expected-note 3{{selected 'begin' function with iterator type 'int *'}} expected-note {{'begin' declared here}}
+ int *end();
+};
+
+struct B {
+ B();
+ int *alt_begin();
+ int *alt_end();
+};
+
+void f();
+void f(int);
+
+void g() {
+ for (int a : A())
+ A __begin;
+ for (char *a : A()) { // expected-error {{cannot initialize a variable of type 'char *' with an lvalue of type 'int'}}
+ }
+ for (char *a : B()) { // expected-error {{cannot initialize a variable of type 'char *' with an lvalue of type 'int'}}
+ }
+ // FIXME: Terrible diagnostic here. auto deduction should fail, but does not!
+ for (double a : f) { // expected-error {{cannot use type '<overloaded function type>' as a range}}
+ }
+ for (auto a : A()) {
+ }
+ for (auto a : B()) {
+ }
+ for (auto *a : A()) { // expected-error {{variable 'a' with type 'auto *' has incompatible initializer of type 'int'}}
+ }
+ // : is not a typo for :: here.
+ for (A NS:A()) { // expected-error {{no viable conversion from 'int' to 'A'}}
+ }
+ for (auto not_in_scope : not_in_scope) { // expected-error {{use of undeclared identifier 'not_in_scope'}}
+ }
+
+ for (auto a : A())
+ for (auto b : A()) {
+ __range.begin(); // expected-error {{use of undeclared identifier '__range'}}
+ ++__begin; // expected-error {{use of undeclared identifier '__begin'}}
+ --__end; // expected-error {{use of undeclared identifier '__end'}}
+ }
+
+ for (char c : "test")
+ ;
+ for (auto a : f()) // expected-error {{cannot use type 'void' as a range}}
+ ;
+
+ extern int incomplete[];
+ for (auto a : incomplete) // expected-error {{cannot use incomplete type 'int []' as a range}}
+ ;
+ extern struct Incomplete also_incomplete[2]; // expected-note {{forward declaration}}
+ for (auto &a : also_incomplete) // expected-error {{cannot use incomplete type 'struct Incomplete [2]' as a range}}
+ ;
+
+ struct VoidBegin {
+ void begin(); // expected-note {{selected 'begin' function with iterator type 'void'}}
+ void end();
+ };
+ for (auto a : VoidBegin()) // expected-error {{cannot use type 'void' as an iterator}}
+ ;
+
+ struct null_t {
+ operator int*();
+ };
+ struct Differ {
+ int *begin(); // expected-note {{selected 'begin' function with iterator type 'int *'}}
+ null_t end(); // expected-note {{selected 'end' function with iterator type 'null_t'}}
+ };
+ for (auto a : Differ()) // expected-error {{'begin' and 'end' must return the same type (got 'int *' and 'null_t')}}
+ ;
+
+ for (void f() : "error") // expected-error {{for range declaration must declare a variable}}
+ ;
+
+ for (extern int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'extern'}}
+ for (static int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'static'}}
+ for (register int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'register'}}
+ for (constexpr int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'constexpr'}}
+
+ struct NoBeginADL {
+ null_t alt_end();
+ };
+ struct NoEndADL {
+ null_t alt_begin();
+ };
+ for (auto u : NoBeginADL()) { // expected-error {{no matching function for call to 'begin'}} expected-note {{range has type 'NoBeginADL'}}
+ }
+ for (auto u : NoEndADL()) { // expected-error {{no matching function for call to 'end'}} expected-note {{range has type 'NoEndADL'}}
+ }
+
+ struct NoBegin {
+ null_t end();
+ };
+ struct NoEnd {
+ null_t begin();
+ };
+ for (auto u : NoBegin()) { // expected-error {{range type 'NoBegin' has 'end' member but no 'begin' member}}
+ }
+ for (auto u : NoEnd()) { // expected-error {{range type 'NoEnd' has 'begin' member but no 'end' member}}
+ }
+
+ struct NoIncr {
+ void *begin(); // expected-note {{selected 'begin' function with iterator type 'void *'}}
+ void *end();
+ };
+ for (auto u : NoIncr()) { // expected-error {{arithmetic on a pointer to void}}
+ }
+
+ struct NoNotEq {
+ NoNotEq begin(); // expected-note {{selected 'begin' function with iterator type 'NoNotEq'}}
+ NoNotEq end();
+ void operator++();
+ };
+ for (auto u : NoNotEq()) { // expected-error {{invalid operands to binary expression}}
+ }
+
+ struct NoCopy {
+ NoCopy();
+ NoCopy(const NoCopy &) = delete;
+ int *begin();
+ int *end();
+ };
+ for (int n : NoCopy()) { // ok
+ }
+
+ for (int n : 42) { // expected-error {{no matching function for call to 'begin'}} \
+ expected-note {{range has type 'int'}}
+ }
+
+ for (auto a : *also_incomplete) { // expected-error {{cannot use incomplete type 'struct Incomplete' as a range}}
+ }
+}
+
+template<typename T, typename U>
+void h(T t) {
+ for (U u : t) { // expected-error {{no viable conversion from 'A' to 'int'}}
+ }
+ for (auto u : t) {
+ }
+}
+
+template void h<A, int>(A);
+template void h<A(&)[4], A &>(A(&)[4]);
+template void h<A(&)[13], A>(A(&)[13]);
+template void h<A(&)[13], int>(A(&)[13]); // expected-note {{requested here}}
+
+template<typename T>
+void i(T t) {
+ for (auto u : t) { // expected-error {{no matching function for call to 'begin'}} \
+ expected-error {{member function 'begin' not viable}} \
+ expected-note {{range has type}}
+ }
+}
+template void i<A[13]>(A*); // expected-note {{requested here}}
+template void i<const A>(const A); // expected-note {{requested here}}
+
+namespace NS {
+ class ADL {};
+ int *begin(ADL); // expected-note {{no known conversion from 'NS::NoADL' to 'NS::ADL'}}
+ int *end(ADL);
+
+ class NoADL {};
+}
+int *begin(NS::NoADL);
+int *end(NS::NoADL);
+
+struct VoidBeginADL {};
+void begin(VoidBeginADL); // expected-note {{selected 'begin' function with iterator type 'void'}}
+void end(VoidBeginADL);
+
+void j() {
+ for (auto u : NS::ADL()) {
+ }
+ for (auto u : NS::NoADL()) { // expected-error {{no matching function for call to 'begin'}} expected-note {{range has type}}
+ }
+ for (auto a : VoidBeginADL()) { // expected-error {{cannot use type 'void' as an iterator}}
+ }
+}
+
+void example() {
+ int array[5] = { 1, 2, 3, 4, 5 };
+ for (int &x : array)
+ x *= 2;
+}
diff --git a/clang/test/CXX/stmt.stmt/stmt.label/p1.cpp b/clang/test/CXX/stmt.stmt/stmt.label/p1.cpp
new file mode 100644
index 0000000..90367f8
--- /dev/null
+++ b/clang/test/CXX/stmt.stmt/stmt.label/p1.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f()
+{
+ int x = 0;
+ goto label1;
+
+label1: // expected-note{{previous definition is here}}
+ x = 1;
+ goto label2; // expected-error{{use of undeclared label 'label2'}}
+
+label1: // expected-error{{redefinition of label 'label1'}}
+ x = 2;
+}
+
+void h()
+{
+ int x = 0;
+ switch (x)
+ {
+ case 1:;
+ default:; // expected-error{{multiple default labels in one switch}}
+ default:; // expected-note{{previous case defined here}}
+ }
+}
diff --git a/clang/test/CXX/stmt.stmt/stmt.select/p3.cpp b/clang/test/CXX/stmt.stmt/stmt.select/p3.cpp
new file mode 100644
index 0000000..35e5c91
--- /dev/null
+++ b/clang/test/CXX/stmt.stmt/stmt.select/p3.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int f();
+
+void g() {
+ if (int x = f()) { // expected-note 2{{previous definition}}
+ int x; // expected-error{{redefinition of 'x'}}
+ } else {
+ int x; // expected-error{{redefinition of 'x'}}
+ }
+}
+
+
+void h() {
+ if (int x = f()) // expected-note 2{{previous definition}}
+ int x; // expected-error{{redefinition of 'x'}}
+ else
+ int x; // expected-error{{redefinition of 'x'}}
+}
diff --git a/clang/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp b/clang/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp
new file mode 100644
index 0000000..000c870
--- /dev/null
+++ b/clang/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+struct Value {
+ constexpr Value(int n) : n(n) {}
+ constexpr operator short() { return n; }
+ int n;
+};
+enum E { E0, E1 };
+struct Alt {
+ constexpr operator E() { return E0; }
+};
+
+constexpr short s = Alt();
+
+void test(Value v) {
+ switch (v) {
+ case Alt():
+ case E1:
+ case Value(2):
+ case 3:
+ break;
+ }
+ switch (Alt a = Alt()) {
+ case Alt():
+ case E1:
+ case Value(2):
+ case 3:
+ break;
+ }
+ switch (E0) {
+ case Alt():
+ case E1:
+ // FIXME: These should produce a warning that 2 and 3 are not values of the
+ // enumeration.
+ case Value(2):
+ case 3:
+ break;
+ }
+}
diff --git a/clang/test/CXX/temp/p3.cpp b/clang/test/CXX/temp/p3.cpp
new file mode 100644
index 0000000..c146bc4
--- /dev/null
+++ b/clang/test/CXX/temp/p3.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify %s
+
+template<typename T> struct S {
+ static int a, b;
+};
+
+template<typename T> int S<T>::a, S<T>::b; // expected-error {{can only declare a single entity}}
+
+template<typename T> struct A { static A a; } A<T>::a; // expected-error {{expected ';' after struct}} \
+ expected-error {{use of undeclared identifier 'T'}} \
+ expected-warning{{extra qualification}}
+
+template<typename T> struct B { } f(); // expected-error {{expected ';' after struct}} \
+ expected-error {{requires a type specifier}}
+
+template<typename T> struct C { } // expected-error {{expected ';' after struct}}
+
+A<int> c;
diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp
new file mode 100644
index 0000000..59ce8b6
--- /dev/null
+++ b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+namespace std {
+ typedef decltype(nullptr) nullptr_t;
+}
+
+template<int *ip> struct IP { // expected-note 4 {{template parameter is declared here}}
+ IP<ip> *ip2;
+};
+
+constexpr std::nullptr_t get_nullptr() { return nullptr; }
+
+constexpr std::nullptr_t np = nullptr;
+
+std::nullptr_t nonconst_np; // expected-note{{declared here}}
+
+IP<0> ip0; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}}
+IP<(0)> ip1; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}}
+IP<nullptr> ip2;
+IP<get_nullptr()> ip3;
+IP<(int*)0> ip4;
+IP<np> ip5;
+IP<nonconst_np> ip5; // expected-error{{non-type template argument of type 'std::nullptr_t' (aka 'nullptr_t') is not a constant expression}} \
+// expected-note{{read of non-constexpr variable 'nonconst_np' is not allowed in a constant expression}}
+IP<(float*)0> ip6; // expected-error{{null non-type template argument of type 'float *' does not match template parameter of type 'int *'}}
+
+struct X { };
+template<int X::*pm> struct PM { // expected-note 2 {{template parameter is declared here}}
+ PM<pm> *pm2;
+};
+
+PM<0> pm0; // expected-error{{null non-type template argument must be cast to template parameter type 'int X::*'}}
+PM<(0)> pm1; // expected-error{{null non-type template argument must be cast to template parameter type 'int X::*'}}
+PM<nullptr> pm2;
+PM<get_nullptr()> pm3;
+PM<(int X::*)0> pm4;
+PM<np> pm5;
+
+template<int (X::*pmf)(int)> struct PMF { // expected-note 2 {{template parameter is declared here}}
+ PMF<pmf> *pmf2;
+};
+
+PMF<0> pmf0; // expected-error{{null non-type template argument must be cast to template parameter type 'int (X::*)(int)'}}
+PMF<(0)> pmf1; // expected-error{{null non-type template argument must be cast to template parameter type 'int (X::*)(int)'}}
+PMF<nullptr> pmf2;
+PMF<get_nullptr()> pmf3;
+PMF<(int (X::*)(int))0> pmf4;
+PMF<np> pmf5;
+
+
+template<std::nullptr_t np> struct NP { // expected-note 2{{template parameter is declared here}}
+ NP<np> *np2;
+};
+
+NP<nullptr> np1;
+NP<np> np2;
+NP<get_nullptr()> np3;
+NP<0> np4; // expected-error{{null non-type template argument must be cast to template parameter type 'std::nullptr_t' (aka 'nullptr_t')}}
+constexpr int i = 7;
+NP<i> np5; // expected-error{{non-type template argument of type 'const int' cannot be converted to a value of type 'std::nullptr_t'}}
diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
new file mode 100644
index 0000000..c4db002
--- /dev/null
+++ b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-linux-gnu %s
+
+// C++11 [temp.arg.nontype]p1:
+//
+// A template-argument for a non-type, non-template template-parameter shall
+// be one of:
+// -- an integral constant expression; or
+// -- the name of a non-type template-parameter ; or
+namespace non_type_tmpl_param {
+ template <int N> struct X0 { X0(); };
+ template <int N> X0<N>::X0() { }
+ template <int* N> struct X1 { X1(); };
+ template <int* N> X1<N>::X1() { }
+ template <int& N> struct X3 { X3(); };
+ template <int& N> X3<N>::X3() { }
+ template <int (*F)(int)> struct X4 { X4(); };
+ template <int (*F)(int)> X4<F>::X4() { }
+ template <typename T, int (T::* M)(int)> struct X5 { X5(); };
+ template <typename T, int (T::* M)(int)> X5<T, M>::X5() { }
+}
+
+// -- a constant expression that designates the address of an object with
+// static storage duration and external or internal linkage or a function
+// with external or internal linkage, including function templates and
+// function template-ids, but excluting non-static class members, expressed
+// (ignoring parentheses) as & id-expression, except that the & may be
+// omitted if the name refers to a function or array and shall be omitted
+// if the corresopnding template-parameter is a reference; or
+namespace addr_of_obj_or_func {
+ template <int* p> struct X0 { }; // expected-note 4{{here}}
+ template <int (*fp)(int)> struct X1 { };
+ template <int &p> struct X2 { }; // expected-note 4{{here}}
+ template <const int &p> struct X2k { }; // expected-note {{here}}
+ template <int (&fp)(int)> struct X3 { }; // expected-note 4{{here}}
+
+ int i = 42;
+ int iarr[10];
+ int f(int i);
+ const int ki = 9; // expected-note 5{{here}}
+ __thread int ti = 100; // expected-note 2{{here}}
+ static int f_internal(int); // expected-note 4{{here}}
+ template <typename T> T f_tmpl(T t);
+
+ void test() {
+ X0<i> x0a; // expected-error {{must have its address taken}}
+ X0<&i> x0a_addr;
+ X0<iarr> x0b;
+ X0<&iarr> x0b_addr; // expected-error {{cannot be converted to a value of type 'int *'}}
+ X0<ki> x0c; // expected-error {{must have its address taken}} expected-warning {{internal linkage is a C++11 extension}}
+ X0<&ki> x0c_addr; // expected-error {{cannot be converted to a value of type 'int *'}} expected-warning {{internal linkage is a C++11 extension}}
+ X0<&ti> x0d_addr; // expected-error {{refers to thread-local object}}
+ X1<f> x1a;
+ X1<&f> x1a_addr;
+ X1<f_tmpl> x1b;
+ X1<&f_tmpl> x1b_addr;
+ X1<f_tmpl<int> > x1c;
+ X1<&f_tmpl<int> > x1c_addr;
+ X1<f_internal> x1d; // expected-warning {{internal linkage is a C++11 extension}}
+ X1<&f_internal> x1d_addr; // expected-warning {{internal linkage is a C++11 extension}}
+ X2<i> x2a;
+ X2<&i> x2a_addr; // expected-error {{address taken}}
+ X2<iarr> x2b; // expected-error {{cannot bind to template argument of type 'int [10]'}}
+ X2<&iarr> x2b_addr; // expected-error {{address taken}}
+ X2<ki> x2c; // expected-error {{ignores qualifiers}} expected-warning {{internal linkage is a C++11 extension}}
+ X2k<ki> x2kc; // expected-warning {{internal linkage is a C++11 extension}}
+ X2k<&ki> x2kc_addr; // expected-error {{address taken}} expected-warning {{internal linkage is a C++11 extension}}
+ X2<ti> x2d_addr; // expected-error {{refers to thread-local object}}
+ X3<f> x3a;
+ X3<&f> x3a_addr; // expected-error {{address taken}}
+ X3<f_tmpl> x3b;
+ X3<&f_tmpl> x3b_addr; // expected-error {{address taken}}
+ X3<f_tmpl<int> > x3c;
+ X3<&f_tmpl<int> > x3c_addr; // expected-error {{address taken}}
+ X3<f_internal> x3d; // expected-warning {{internal linkage is a C++11 extension}}
+ X3<&f_internal> x3d_addr; // expected-error {{address taken}} expected-warning {{internal linkage is a C++11 extension}}
+
+ int n; // expected-note {{here}}
+ X0<&n> x0_no_linkage; // expected-error {{non-type template argument refers to object 'n' that does not have linkage}}
+ struct Local { static int f() {} }; // expected-note {{here}}
+ X1<&Local::f> x1_no_linkage; // expected-error {{non-type template argument refers to function 'f' that does not have linkage}}
+ }
+}
+
+// -- a constant expression that evaluates to a null pointer value (4.10); or
+// -- a constant expression that evaluates to a null member pointer value
+// (4.11); or
+// -- a pointer to member expressed as described in 5.3.1.
+
+namespace bad_args {
+ template <int* N> struct X0 { }; // expected-note 2{{template parameter is declared here}}
+ int i = 42;
+ X0<&i + 2> x0a; // expected-error{{non-type template argument does not refer to any declaration}}
+ int* iptr = &i;
+ X0<iptr> x0b; // expected-error{{non-type template argument for template parameter of pointer type 'int *' must have its address taken}}
+}
diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp
new file mode 100644
index 0000000..9b9b532
--- /dev/null
+++ b/clang/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp
@@ -0,0 +1,205 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++0x [temp.arg.nontype] p5:
+// The following conversions are performed on each expression used as
+// a non-type template-argument. If a non-type template-argument cannot be
+// converted to the type of the corresponding template-parameter then the
+// program is ill-formed.
+// -- for a non-type template-parameter of integral or enumeration type,
+// integral promotions (4.5) and integral conversions (4.7) are applied.
+namespace integral_parameters {
+ template<short s> struct X0 { };
+ X0<17> x0i;
+ X0<'a'> x0c;
+ template<char c> struct X1 { };
+ X1<100l> x1l;
+}
+
+// -- for a non-type template-parameter of type pointer to object,
+// qualification conversions (4.4) and the array-to-pointer conversion
+// (4.2) are applied; if the template-argument is of type
+// std::nullptr_t, the null pointer conversion (4.10) is applied.
+namespace pointer_to_object_parameters {
+ // PR6226
+ struct Str {
+ Str(const char *);
+ };
+
+ template<const char *s>
+ struct A {
+ Str get() { return s; }
+ };
+
+ char hello[6] = "Hello";
+ extern const char world[6];
+ const char world[6] = "world";
+ void test() {
+ (void)A<hello>().get();
+ (void)A<world>().get();
+ }
+
+ class X {
+ public:
+ X();
+ X(int, int);
+ operator int() const;
+ };
+
+ template<X const *Ptr> struct A2; // expected-note{{template parameter is declared here}}
+
+ X *X_ptr;
+ X an_X;
+ X array_of_Xs[10];
+ A2<X_ptr> *a12; // expected-error{{must have its address taken}}
+ A2<array_of_Xs> *a13;
+ A2<&an_X> *a13_2;
+ A2<(&an_X)> *a13_3; // expected-warning{{address non-type template argument cannot be surrounded by parentheses}}
+
+ // PR6244
+ struct X1 {} X1v;
+ template <X1*> struct X2 { };
+ template <X1* Value> struct X3 : X2<Value> { };
+ struct X4 : X3<&X1v> { };
+
+ // PR6563
+ int *bar;
+ template <int *> struct zed {}; // expected-note 2{{template parameter is declared here}}
+ void g(zed<bar>*); // expected-error{{must have its address taken}}
+
+ int baz;
+ void g2(zed<baz>*); // expected-error{{must have its address taken}}
+
+ void g3(zed<&baz>*); // okay
+}
+
+// -- For a non-type template-parameter of type reference to object, no
+// conversions apply. The type referred to by the reference may be more
+// cv-qualified than the (otherwise identical) type of the
+// template-argument. The template-parameter is bound directly to the
+// template-argument, which shall be an lvalue.
+namespace reference_parameters {
+ template <int& N> struct S0 { }; // expected-note 3 {{template parameter is declared here}}
+ template <const int& N> struct S1 { }; // expected-note 2 {{template parameter is declared here}}
+ template <volatile int& N> struct S2 { }; // expected-note 2 {{template parameter is declared here}}
+ template <const volatile int& N> struct S3 { };
+ int i;
+ extern const int ci;
+ volatile int vi;
+ extern const volatile int cvi;
+ void test() {
+ S0<i> s0;
+ S0<ci> s0c; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'const int' ignores qualifiers}}
+ S0<vi> s0v; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'volatile int' ignores qualifiers}}
+ S0<cvi> s0cv; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'const volatile int' ignores qualifiers}}
+
+ S1<i> s1;
+ S1<ci> s1c;
+ S1<vi> s1v; // expected-error{{reference binding of non-type template parameter of type 'const int &' to template argument of type 'volatile int' ignores qualifiers}}
+ S1<cvi> s1cv; // expected-error{{reference binding of non-type template parameter of type 'const int &' to template argument of type 'const volatile int' ignores qualifiers}}
+
+ S2<i> s2;
+ S2<ci> s2c; // expected-error{{reference binding of non-type template parameter of type 'volatile int &' to template argument of type 'const int' ignores qualifiers}}
+ S2<vi> s2v;
+ S2<cvi> s2cv; // expected-error{{reference binding of non-type template parameter of type 'volatile int &' to template argument of type 'const volatile int' ignores qualifiers}}
+
+ S3<i> s3;
+ S3<ci> s3c;
+ S3<vi> s3v;
+ S3<cvi> s3cv;
+ }
+
+ namespace PR6250 {
+ template <typename T, const T &ref> void inc() {
+ ref++; // expected-error{{read-only variable is not assignable}}
+ }
+
+ template<typename T, const T &ref> void bind() {
+ T &ref2 = ref; // expected-error{{drops qualifiers}}
+ }
+
+ int counter;
+ void test() {
+ inc<int, counter>(); // expected-note{{instantiation of}}
+ bind<int, counter>(); // expected-note{{instantiation of}}
+ }
+ }
+
+ namespace PR6749 {
+ template <int& i> struct foo {}; // expected-note{{template parameter is declared here}}
+ int x, &y = x;
+ foo<y> f; // expected-error{{is not an object}}
+ }
+}
+
+// -- For a non-type template-parameter of type pointer to function, the
+// function-to-pointer conversion (4.3) is applied; if the
+// template-argument is of type std::nullptr_t, the null pointer
+// conversion (4.10) is applied. If the template-argument represents
+// a set of overloaded functions (or a pointer to such), the matching
+// function is selected from the set (13.4).
+namespace pointer_to_function {
+ template<int (*)(int)> struct X0 { }; // expected-note 3{{template parameter is declared here}}
+ int f(int);
+ int f(float);
+ int g(float);
+ int (*funcptr)(int);
+ void x0a(X0<f>);
+ void x0b(X0<&f>);
+ void x0c(X0<g>); // expected-error{{non-type template argument of type 'int (float)' cannot be converted to a value of type 'int (*)(int)'}}
+ void x0d(X0<&g>); // expected-error{{non-type template argument of type 'int (*)(float)' cannot be converted to a value of type 'int (*)(int)'}}
+ void x0e(X0<funcptr>); // expected-error{{must have its address taken}}
+}
+
+// -- For a non-type template-parameter of type reference to function, no
+// conversions apply. If the template-argument represents a set of
+// overloaded functions, the matching function is selected from the set
+// (13.4).
+namespace reference_to_function {
+ template<int (&)(int)> struct X0 { }; // expected-note 4{{template parameter is declared here}}
+ int f(int);
+ int f(float);
+ int g(float);
+ int (*funcptr)(int);
+ void x0a(X0<f>);
+ void x0b(X0<&f>); // expected-error{{address taken in non-type template argument for template parameter of reference type 'int (&)(int)'}}
+ void x0c(X0<g>); // expected-error{{non-type template parameter of reference type 'int (&)(int)' cannot bind to template argument of type 'int (float)'}}
+ void x0d(X0<&g>); // expected-error{{address taken in non-type template argument for template parameter of reference type 'int (&)(int)'}}
+ void x0e(X0<funcptr>); // expected-error{{non-type template parameter of reference type 'int (&)(int)' cannot bind to template argument of type 'int (*)(int)'}}
+}
+// -- For a non-type template-parameter of type pointer to member function,
+// if the template-argument is of type std::nullptr_t, the null member
+// pointer conversion (4.11) is applied; otherwise, no conversions
+// apply. If the template-argument represents a set of overloaded member
+// functions, the matching member function is selected from the set
+// (13.4).
+namespace pointer_to_member_function {
+ struct X { };
+ struct Y : X {
+ int f(int);
+ int g(int);
+ int g(float);
+ float h(float);
+ };
+
+ template<int (Y::*)(int)> struct X0 {}; // expected-note{{template parameter is declared here}}
+ X0<&Y::f> x0a;
+ X0<&Y::g> x0b;
+ X0<&Y::h> x0c; // expected-error{{non-type template argument of type 'float (pointer_to_member_function::Y::*)(float)' cannot be converted to a value of type 'int (pointer_to_member_function::Y::*)(int)'}}
+}
+
+// -- For a non-type template-parameter of type pointer to data member,
+// qualification conversions (4.4) are applied; if the template-argument
+// is of type std::nullptr_t, the null member pointer conversion (4.11)
+// is applied.
+namespace pointer_to_member_data {
+ struct X { int x; };
+ struct Y : X { int y; };
+
+ template<int Y::*> struct X0 {}; // expected-note{{template parameter is declared here}}
+ X0<&Y::y> x0a;
+ X0<&Y::x> x0b; // expected-error{{non-type template argument of type 'int pointer_to_member_data::X::*' cannot be converted to a value of type 'int pointer_to_member_data::Y::*'}}
+
+ // Test qualification conversions
+ template<const int Y::*> struct X1 {};
+ X1<&Y::y> x1a;
+}
diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp b/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
new file mode 100644
index 0000000..1c13bff
--- /dev/null
+++ b/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template <class T> struct eval; // expected-note 3{{template is declared here}}
+
+template <template <class, class...> class TT, class T1, class... Rest>
+struct eval<TT<T1, Rest...>> { };
+
+template <class T1> struct A;
+template <class T1, class T2> struct B;
+template <int N> struct C;
+template <class T1, int N> struct D;
+template <class T1, class T2, int N = 17> struct E;
+
+eval<A<int>> eA;
+eval<B<int, float>> eB;
+eval<C<17>> eC; // expected-error{{implicit instantiation of undefined template 'eval<C<17> >'}}
+eval<D<int, 17>> eD; // expected-error{{implicit instantiation of undefined template 'eval<D<int, 17> >'}}
+eval<E<int, float>> eE; // expected-error{{implicit instantiation of undefined template 'eval<E<int, float, 17> >}}
+
+template<template <int ...N> class TT> struct X0 { }; // expected-note{{previous non-type template parameter with type 'int' is here}}
+template<int I, int J, int ...Rest> struct X0a;
+template<int ...Rest> struct X0b;
+template<int I, long J> struct X0c; // expected-note{{template non-type parameter has a different type 'long' in template argument}}
+
+X0<X0a> inst_x0a;
+X0<X0b> inst_x0b;
+X0<X0c> inst_x0c; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
+
+template<typename T,
+ template <T ...N> class TT> // expected-note{{previous non-type template parameter with type 'short' is here}}
+struct X1 { };
+template<int I, int J, int ...Rest> struct X1a;
+template<long I, long ...Rest> struct X1b;
+template<short I, short J> struct X1c;
+template<short I, long J> struct X1d; // expected-note{{template non-type parameter has a different type 'long' in template argument}}
+
+X1<int, X1a> inst_x1a;
+X1<long, X1b> inst_x1b;
+X1<short, X1c> inst_x1c;
+X1<short, X1d> inst_x1d; // expected-error{{template template argument has different template parameters than its corresponding template template paramete}}
diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp b/clang/test/CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp
new file mode 100644
index 0000000..b03ed46
--- /dev/null
+++ b/clang/test/CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+// C++03 imposed restrictions in this paragraph that were lifted with 0x, so we
+// just test that the example given now parses cleanly.
+
+template <class T> class X { };
+template <class T> void f(T t) { }
+struct { } unnamed_obj;
+void f() {
+ struct A { };
+ enum { e1 };
+ typedef struct { } B;
+ B b;
+ X<A> x1;
+ X<A*> x2;
+ X<B> x3;
+ f(e1);
+ f(unnamed_obj);
+ f(b);
+}
diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp b/clang/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp
new file mode 100644
index 0000000..0fd9a7e
--- /dev/null
+++ b/clang/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<class T> struct A {
+ static T t; // expected-error{{static data member instantiated with function type 'int ()'}}
+};
+typedef int function();
+A<function> a; // expected-note{{instantiation of}}
+
+template<typename T> struct B {
+ B() { T t; } // expected-error{{variable instantiated with function type 'int ()'}}
+};
+B<function> b; // expected-note{{instantiation of}}
+
+template <typename T> int f0(void *, const T&); // expected-note{{candidate template ignored: substitution failure}}
+enum {e}; // expected-note{{unnamed type used in template argument was declared here}}
+
+void test_f0(int n) {
+ int i = f0(0, e); // expected-warning{{template argument uses unnamed type}}
+ int vla[n];
+ f0(0, vla); // expected-error{{no matching function for call to 'f0'}}
+}
+
+namespace N0 {
+ template <typename R, typename A1> void f0(R (*)(A1));
+ template <typename T> int f1(T);
+ template <typename T, typename U> int f1(T, U);
+ enum {e1}; // expected-note 2{{unnamed type used in template argument was declared here}}
+ enum {e2}; // expected-note 2{{unnamed type used in template argument was declared here}}
+ enum {e3}; // expected-note{{unnamed type used in template argument was declared here}}
+
+ template<typename T> struct X;
+ template<typename T> struct X<T*> { };
+
+ void f() {
+ f0( // expected-warning{{template argument uses unnamed type}}
+ &f1<__typeof__(e1)>); // expected-warning{{template argument uses unnamed type}}
+ int (*fp1)(int, __typeof__(e2)) = f1; // expected-warning{{template argument uses unnamed type}}
+ f1(e2); // expected-warning{{template argument uses unnamed type}}
+ f1(e2);
+
+ X<__typeof__(e3)*> x; // expected-warning{{template argument uses unnamed type}}
+ }
+}
diff --git a/clang/test/CXX/temp/temp.decls/p3.cpp b/clang/test/CXX/temp/temp.decls/p3.cpp
new file mode 100644
index 0000000..41811ff
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/p3.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<typename T> using A = int;
+template<typename T> using A<T*> = char; // expected-error {{partial specialization of alias templates is not permitted}}
+template<> using A<char> = char; // expected-error {{explicit specialization of alias templates is not permitted}}
+template using A<char> = char; // expected-error {{explicit instantiation of alias templates is not permitted}}
+using A<char> = char; // expected-error {{name defined in alias declaration must be an identifier}}
diff --git a/clang/test/CXX/temp/temp.decls/temp.alias/p1.cpp b/clang/test/CXX/temp/temp.decls/temp.alias/p1.cpp
new file mode 100644
index 0000000..966e3c1
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.alias/p1.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<typename T> using U = T;
+
+// The name of the alias template is a template-name.
+U<char> x;
+void f(U<int>);
+typedef U<U<U<U<int>>>> I;
diff --git a/clang/test/CXX/temp/temp.decls/temp.alias/p2.cpp b/clang/test/CXX/temp/temp.decls/temp.alias/p2.cpp
new file mode 100644
index 0000000..a5b39fe
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.alias/p2.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<typename T> using U = T;
+
+using I = U<U<U<U<int>>>>;
+using I = int;
+
+template<typename A, typename B> using Fst = A;
+template<typename A, typename B> using Snd = B;
+
+using I = Fst<Snd<char,int>,double>;
+
+namespace StdExample {
+ // Prerequisites for example.
+ template<class T, class A> struct vector { /* ... */ };
+
+
+ template<class T> struct Alloc {};
+ template<class T> using Vec = vector<T, Alloc<T>>;
+ Vec<int> v;
+
+ template<class T>
+ void process(Vec<T>& v) // expected-note {{previous definition is here}}
+ { /* ... */ }
+
+ template<class T>
+ void process(vector<T, Alloc<T>>& w) // expected-error {{redefinition of 'process'}}
+ { /* ... */ }
+
+ template<template<class> class TT>
+ void f(TT<int>); // expected-note {{candidate template ignored}}
+
+ template<template<class,class> class TT>
+ void g(TT<int, Alloc<int>>);
+
+ int h() {
+ f(v); // expected-error {{no matching function for call to 'f'}}
+ g(v); // OK: TT = vector
+ }
+
+
+ // v's type is same as vector<int, Alloc<int>>.
+ using VTest = vector<int, Alloc<int>>;
+ using VTest = decltype(v);
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.alias/p3.cpp b/clang/test/CXX/temp/temp.decls/temp.alias/p3.cpp
new file mode 100644
index 0000000..afd9b4b
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.alias/p3.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// The example given in the standard (this is rejected for other reasons anyway).
+template<class T> struct A;
+template<class T> using B = typename A<T>::U; // expected-error {{no type named 'U' in 'A<T>'}}
+template<class T> struct A {
+ typedef B<T> U; // expected-note {{in instantiation of template type alias 'B' requested here}}
+};
+B<short> b;
+
+template<typename T> using U = int;
+// FIXME: This is illegal, but probably only because CWG1044 missed this paragraph.
+template<typename T> using U = U<T>;
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
new file mode 100644
index 0000000..d0fc797
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Test class template partial specializations of member templates.
+template<typename T>
+struct X0 {
+ template<typename U> struct Inner0 {
+ static const unsigned value = 0;
+ };
+
+ template<typename U> struct Inner0<U*> {
+ static const unsigned value = 1;
+ };
+};
+
+template<typename T> template<typename U>
+struct X0<T>::Inner0<const U*> {
+ static const unsigned value = 2;
+};
+
+int array0[X0<int>::Inner0<int>::value == 0? 1 : -1];
+int array1[X0<int>::Inner0<int*>::value == 1? 1 : -1];
+int array2[X0<int>::Inner0<const int*>::value == 2? 1 : -1];
+
+// Make sure we can provide out-of-line class template partial specializations
+// for member templates (and instantiate them).
+template<class T> struct A {
+ struct C {
+ template<class T2> struct B;
+ };
+};
+
+// partial specialization of A<T>::C::B<T2>
+template<class T> template<class T2> struct A<T>::C::B<T2*> { };
+
+A<short>::C::B<int*> absip;
+
+// Check for conflicts during template instantiation.
+template<typename T, typename U>
+struct Outer {
+ template<typename X, typename Y> struct Inner;
+ template<typename Y> struct Inner<T, Y> {}; // expected-note{{previous}}
+ template<typename Y> struct Inner<U, Y> {}; // expected-error{{cannot be redeclared}}
+};
+
+Outer<int, int> outer; // expected-note{{instantiation}}
+
+// Test specialization of class template partial specialization members.
+template<> template<typename Z>
+struct X0<float>::Inner0<Z*> {
+ static const unsigned value = 3;
+};
+
+int array3[X0<float>::Inner0<int>::value == 0? 1 : -1];
+int array4[X0<float>::Inner0<int*>::value == 3? 1 : -1];
+int array5[X0<float>::Inner0<const int*>::value == 2? 1 : -1];
+
+namespace rdar8651930 {
+ template<typename OuterT>
+ struct Outer {
+ template<typename T, typename U>
+ struct Inner;
+
+ template<typename T>
+ struct Inner<T, T> {
+ static const bool value = true;
+ };
+
+ template<typename T, typename U>
+ struct Inner {
+ static const bool value = false;
+ };
+ };
+
+ int array0[Outer<int>::Inner<int, int>::value? 1 : -1];
+ int array1[Outer<int>::Inner<int, float>::value? -1 : 1];
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp
new file mode 100644
index 0000000..aa1e2d4
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<int ...Values> struct X1;
+
+template<int ...Values>
+struct X1<0, Values+1 ...>; // expected-error{{non-type template argument depends on a template parameter of the partial specialization}}
+
+
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp
new file mode 100644
index 0000000..b754368
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// -- The argument list of the specialization shall not be identical
+// to the implicit argument list of the primary template.
+
+template<typename T, typename ...Types>
+struct X1;
+
+template<typename T, typename ...Types>
+struct X1<T, Types...> // expected-error{{class template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}}
+{ };
+
+
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/p9.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/p9.cpp
new file mode 100644
index 0000000..2a3e914
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/p9.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR8905
+template<char C1, char C2>
+struct X {
+ static const bool value = 0;
+};
+
+template<int C1>
+struct X<C1, C1> {
+ static const bool value = 1;
+};
+
+int check0[X<1, 2>::value == 0? 1 : -1];
+int check1[X<1, 1>::value == 1? 1 : -1];
+
+template<int, int, int> struct int_values {
+ static const unsigned value = 0;
+};
+
+template<unsigned char C1, unsigned char C3>
+struct int_values<C1, 12, C3> {
+ static const unsigned value = 1;
+};
+
+int check2[int_values<256, 12, 3>::value == 0? 1 : -1];
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp
new file mode 100644
index 0000000..97457ea
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<int I, int J, class T> struct X {
+ static const int value = 0;
+};
+
+template<int I, int J> struct X<I, J, int> {
+ static const int value = 1;
+};
+
+template<int I> struct X<I, I, int> {
+ static const int value = 2;
+};
+
+int array0[X<0, 0, float>::value == 0? 1 : -1];
+int array1[X<0, 1, int>::value == 1? 1 : -1];
+int array2[X<0, 0, int>::value == 2? 1 : -1];
+
+namespace DependentSubstPartialOrdering {
+ template<typename T, typename U = void, typename V = void>
+ struct X {
+ static const unsigned value = 1;
+ };
+
+ template<typename T, typename U>
+ struct X<T, U, typename T::is_b> {
+ static const unsigned value = 2;
+ };
+
+ template<typename T>
+ struct X<T, typename T::is_a, typename T::is_b> {
+ static const unsigned value = 3;
+ };
+
+ struct X1 { };
+
+ struct X2 {
+ typedef void is_b;
+ };
+
+ struct X3 {
+ typedef void is_a;
+ typedef void is_b;
+ };
+
+ int check_X1[X<X1, void, void>::value == 1? 1 : -1];
+ int check_X2[X<X2, void, void>::value == 2? 1 : -1];
+ int check_X3[X<X3, void, void>::value == 3? 1 : -1];
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1-neg.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1-neg.cpp
new file mode 100644
index 0000000..59253db
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1-neg.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T, int N>
+struct A;
+
+template<typename T> // expected-note{{previous template declaration}}
+struct A<T*, 2> {
+ void f0();
+ void f1();
+ void f2();
+};
+
+template<>
+struct A<int, 1> {
+ void g0();
+};
+
+// FIXME: We should probably give more precise diagnostics here, but the
+// diagnostics we give aren't terrible.
+// FIXME: why not point to the first parameter that's "too many"?
+template<typename T, int N> // expected-error{{too many template parameters}}
+void A<T*, 2>::f0() { }
+
+template<typename T, int N>
+void A<T, N>::f1() { } // expected-error{{out-of-line definition}}
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1.cpp
new file mode 100644
index 0000000..87e21e4
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T, int N>
+struct A;
+
+template<typename T>
+struct A<T*, 2> {
+ A(T);
+ ~A();
+
+ void f(T*);
+
+ operator T*();
+
+ static T value;
+};
+
+template<class X> void A<X*, 2>::f(X*) { }
+
+template<class X> X A<X*, 2>::value;
+
+template<class X> A<X*, 2>::A(X) { value = 0; }
+
+template<class X> A<X*, 2>::~A() { }
+
+template<class X> A<X*, 2>::operator X*() { return 0; }
diff --git a/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.class/p1.cpp b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.class/p1.cpp
new file mode 100644
index 0000000..b65e1d0
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.class/p1.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T, typename U>
+struct X0 {
+ struct Inner;
+};
+
+template<typename T, typename U>
+struct X0<T, U>::Inner {
+ T x;
+ U y;
+
+ void f() { x = y; } // expected-error{{incompatible}}
+};
+
+
+void test(int i, float f) {
+ X0<int, float>::Inner inner;
+ inner.x = 5;
+ inner.y = 3.4;
+ inner.f();
+
+ X0<int*, float *>::Inner inner2;
+ inner2.x = &i;
+ inner2.y = &f;
+ inner2.f(); // expected-note{{instantiation}}
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.enum/p1.cpp b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.enum/p1.cpp
new file mode 100644
index 0000000..f8cc009
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.enum/p1.cpp
@@ -0,0 +1,152 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+template<typename T> struct A {
+ enum E : T; // expected-note {{here}}
+ E v;
+ E f() { return A::e1; } // expected-error {{no member named 'e1' in 'A<T>'}}
+ E g() { return E::e1; }
+ E h();
+};
+
+A<int> a;
+A<int>::E a0 = A<int>().v;
+int n = A<int>::E::e1; // expected-error {{implicit instantiation of undefined member}}
+
+template<typename T> enum A<T>::E : T { e1, e2 };
+
+// FIXME: Now that A<T>::E is defined, we are supposed to inject its enumerators
+// into the already-instantiated class A<T>. This seems like a really bad idea,
+// though, so we don't implement that, but what we do implement is inconsistent.
+//
+// Either do as the standard says, or only include enumerators lexically defined
+// within the class in its scope.
+A<int>::E a1 = A<int>::e1; // expected-error {{no member named 'e1' in 'A<int>'}}
+
+A<char>::E a2 = A<char>::e2;
+
+template<typename T> typename A<T>::E A<T>::h() { return e2; }
+A<short>::E a3 = A<short>().h();
+
+
+template<typename T> struct B {
+ enum class E;
+ E v;
+ E f() { return E::e1; }
+ E g();
+};
+
+B<int> b;
+B<int>::E b0 = B<int>().v;
+
+template<typename T> enum class B<T>::E { e1, e2 };
+B<int>::E b1 = B<int>::E::e1;
+
+B<char>::E b2 = B<char>::E::e2;
+
+template<typename T> typename B<T>::E B<T>::g() { return e2; }
+B<short>::E b3 = B<short>().g();
+
+
+// Enumeration members of class templates can be explicitly specialized. For
+// unscoped enumerations, specializations must be defined before the primary
+// template is, since otherwise the primary template will be implicitly
+// instantiated when we parse the nested name specifier.
+template<> enum A<long long>::E : long long { e3, e4 }; // expected-error {{explicit specialization of 'E' after instantiation}} expected-note {{first required here}}
+
+template<> enum class B<long long>::E { e3, e4 };
+B<long long>::E b4 = B<long long>::E::e4;
+
+B<long>::E b5;
+template<> enum class B<long>::E { e5 };
+void fb5() { b5 = decltype(b5)::e5; }
+B<long>::E b6 = B<long>::E::e5;
+
+
+template<typename T> struct C {
+ enum class E : T;
+};
+
+template<> enum class C<long long>::E : long long { e3, e4 };
+C<long long>::E c0 = C<long long>::E::e3;
+
+C<long>::E c1;
+template<> enum class C<long>::E : long { e5 };
+void fc1() { c1 = decltype(c1)::e5; }
+C<long>::E c2 = C<long>::E::e5;
+
+template<> enum class C<int>::E : int { e6 };
+template<typename T> enum class C<T>::E : T { e0 };
+C<int>::E c3 = C<int>::E::e6;
+C<int>::E c4 = C<int>::E::e0; // expected-error {{no member named 'e0' in 'C<int>::E'}}
+
+
+// Enumeration members can't be partially-specialized.
+template<typename T> enum class B<T*>::E { e5, e6 }; // expected-error {{nested name specifier for a declaration cannot depend on a template parameter}}
+
+
+// Explicit specializations can be forward-declared.
+template<typename T>
+struct D {
+ enum class E { e1 };
+};
+template<> enum class D<int>::E;
+D<int>::E d1 = D<int>::E::e1; // expected-error {{incomplete type 'D<int>::E'}}
+template<> enum class D<int>::E { e2 };
+D<int>::E d2 = D<int>::E::e2;
+D<char>::E d3 = D<char>::E::e1; // expected-note {{first required here}}
+D<char>::E d4 = D<char>::E::e2; // expected-error {{no member named 'e2'}}
+template<> enum class D<char>::E { e3 }; // expected-error {{explicit specialization of 'E' after instantiation}}
+
+template<> enum class D<short>::E;
+struct F {
+ // Per C++11 [class.friend]p3, these friend declarations have no effect.
+ // Only classes and functions can be friends.
+ template<typename T> friend enum D<T>::E;
+ template<> friend enum D<short>::E;
+
+ template<> friend enum D<double>::E { e3 }; // expected-error {{cannot define a type in a friend declaration}}
+
+private:
+ static const int n = 1; // expected-note {{private here}}
+};
+template<> enum class D<short>::E {
+ e = F::n // expected-error {{private member}}
+};
+
+class Access {
+ friend class X;
+
+ template<typename T>
+ class Priv {
+ friend class X;
+
+ enum class E : T;
+ };
+
+ class S {
+ typedef int N; // expected-note {{here}}
+ static const int k = 3; // expected-note {{here}}
+
+ friend class Priv<char>;
+ };
+
+ static const int k = 5;
+};
+
+template<> enum class Access::Priv<Access::S::N>::E
+ : Access::S::N { // expected-error {{private member}}
+ a = Access::k, // ok
+ b = Access::S::k // expected-error {{private member}}
+};
+
+template<typename T> enum class Access::Priv<T>::E : T {
+ c = Access::k,
+ d = Access::S::k
+};
+
+class X {
+ Access::Priv<int>::E a = Access::Priv<int>::E::a;
+ Access::Priv<char>::E c = Access::Priv<char>::E::d;
+ // FIXME: We should see an access error for this enumerator.
+ Access::Priv<short>::E b = Access::Priv<short>::E::d;
+};
diff --git a/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1-retmem.cpp b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1-retmem.cpp
new file mode 100644
index 0000000..4c05c62
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1-retmem.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> struct X1 { };
+
+template<typename T>
+struct X0 {
+ typedef int size_type;
+ typedef T value_type;
+
+ size_type f0() const;
+ value_type *f1();
+ X1<value_type*> f2();
+};
+
+template<typename T>
+typename X0<T>::size_type X0<T>::f0() const {
+ return 0;
+}
+
+template<typename U>
+typename X0<U>::value_type *X0<U>::f1() {
+ return 0;
+};
+
+template<typename U>
+X1<typename X0<U>::value_type*> X0<U>::f2() {
+ return 0;
+};
diff --git a/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp
new file mode 100644
index 0000000..1764563
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T, typename U> // expected-note{{previous template}}
+class X0 {
+public:
+ typedef int size_type;
+
+ X0(int);
+ ~X0();
+
+ void f0(const T&, const U&);
+
+ T& operator[](int i) const;
+
+ void f1(size_type) const;
+ void f2(size_type) const;
+ void f3(size_type) const;
+ void f4() ;
+
+ operator T*() const;
+
+ T value;
+};
+
+template<typename T, typename U>
+void X0<T, U>::f0(const T&, const U&) { // expected-note{{previous definition}}
+}
+
+template<class X, class Y>
+X& X0<X, Y>::operator[](int i) const {
+ (void)i;
+ return value;
+}
+
+template<class X, class Y>
+void X0<X, Y>::f1(int) const { }
+
+template<class X, class Y>
+void X0<X, Y>::f2(size_type) const { }
+
+template<class X, class Y, class Z> // expected-error{{too many template parameters}}
+void X0<X, Y>::f3(size_type) const {
+}
+
+template<class X, class Y>
+void X0<Y, X>::f4() { } // expected-error{{does not refer}}
+
+// FIXME: error message should probably say, "redefinition of 'X0<T, U>::f0'"
+// rather than just "redefinition of 'f0'"
+template<typename T, typename U>
+void X0<T, U>::f0(const T&, const U&) { // expected-error{{redefinition}}
+}
+
+// Test out-of-line constructors, destructors
+template<typename T, typename U>
+X0<T, U>::X0(int x) : value(x) { }
+
+template<typename T, typename U>
+X0<T, U>::~X0() { }
+
+// Test out-of-line conversion functions.
+template<typename T, typename U>
+X0<T, U>::operator T*() const {
+ return &value;
+}
+
+namespace N { template <class X> class A {void a();}; }
+namespace N { template <class X> void A<X>::a() {} }
+
+// PR5566
+template<typename T>
+struct X1 {
+ template<typename U>
+ struct B { void f(); };
+};
+
+template<typename T>
+template<typename U>
+void X1<T>::template B<U>::f() { }
+
+// PR5527
+template <template <class> class T>
+class X2 {
+ template <class F>
+ class Bar {
+ void Func();
+ };
+};
+
+template <template <class> class T>
+template <class F>
+void X2<T>::Bar<F>::Func() {}
+
+// PR5528
+template <template <class> class T>
+class X3 {
+ void F();
+};
+
+template <template <class> class T>
+void X3<T>::F() {}
diff --git a/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp
new file mode 100644
index 0000000..f09faa9
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Test instantiation of member functions of class templates defined out-of-line
+template<typename T, typename U>
+struct X0 {
+ void f(T *t, const U &u);
+ void f(T *);
+};
+
+template<typename T, typename U>
+void X0<T, U>::f(T *t, const U &u) {
+ *t = u; // expected-error{{not assignable}}
+}
+
+void test_f(X0<float, int> xfi, X0<void, int> xvi, float *fp, void *vp, int i) {
+ xfi.f(fp, i);
+ xvi.f(vp, i); // expected-note{{instantiation}}
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/pr5056.cpp b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/pr5056.cpp
new file mode 100644
index 0000000..70c9c70
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class/temp.mem.func/pr5056.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+extern "C" void * malloc(int);
+
+template <typename T> struct A {
+ void *malloc(int);
+};
+
+template <typename T>
+inline void *A<T>::malloc(int)
+{
+ return 0;
+}
+
+void f() {
+ malloc(10);
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1-inst.cpp b/clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1-inst.cpp
new file mode 100644
index 0000000..9fc4a58
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1-inst.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Test instantiation of static data members declared out-of-line.
+
+template<typename T>
+struct X {
+ static T value;
+};
+
+template<typename T>
+ T X<T>::value = 17; // expected-error{{no viable conversion}}
+
+struct InitOkay {
+ InitOkay(int) { }
+};
+
+struct CannotInit { }; // expected-note{{candidate constructor (the implicit copy constructor) not viable}}
+
+int &returnInt() { return X<int>::value; }
+float &returnFloat() { return X<float>::value; }
+
+InitOkay &returnInitOkay() { return X<InitOkay>::value; }
+
+unsigned long sizeOkay() { return sizeof(X<CannotInit>::value); }
+
+CannotInit &returnError() {
+ return X<CannotInit>::value; // expected-note{{instantiation}}
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp b/clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp
new file mode 100644
index 0000000..2eae112
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+struct X0 {
+ static T value;
+};
+
+template<typename T>
+T X0<T>::value = 0; // expected-error{{no viable conversion}}
+
+struct X1 {
+ X1(int);
+};
+
+struct X2 { }; // expected-note{{candidate constructor (the implicit copy constructor) not viable}}
+
+int& get_int() { return X0<int>::value; }
+X1& get_X1() { return X0<X1>::value; }
+
+double*& get_double_ptr() { return X0<int*>::value; } // expected-error{{non-const lvalue reference to type 'double *' cannot bind to a value of unrelated type 'int *'}}
+
+X2& get_X2() {
+ return X0<X2>::value; // expected-note{{instantiation}}
+}
+
+template<typename T> T x; // expected-error{{variable 'x' declared as a template}}
diff --git a/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3-0x.cpp b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3-0x.cpp
new file mode 100644
index 0000000..63909fb
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3-0x.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// Core DR 532.
+namespace PR8130 {
+ struct A { };
+
+ template<class T> struct B {
+ template<class R> int &operator*(R&);
+ };
+
+ template<class T, class R> float &operator*(T&, R&);
+ void test() {
+ A a;
+ B<A> b;
+ int &ir = b * a;
+ }
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp
new file mode 100644
index 0000000..2ffdd95
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace DeduceVsMember {
+ template<typename T>
+ struct X {
+ template<typename U>
+ int &operator==(const U& other) const;
+ };
+
+ template<typename T, typename U>
+ float &operator==(const T&, const X<U>&);
+
+ void test(X<int> xi, X<float> xf) {
+ float& ir = (xi == xf);
+ }
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p4.cpp b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p4.cpp
new file mode 100644
index 0000000..b2a6219
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p4.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<class T> struct A { A(); };
+template<class T> int &f(T);
+template<class T> float &f(T*);
+template<class T> double &f(const T*);
+
+template<class T> void g(T); // expected-note{{candidate}}
+template<class T> void g(T&); // expected-note{{candidate}}
+
+template<class T> int &h(const T&);
+template<class T> float &h(A<T>&);
+
+void m() {
+ const int *p;
+ double &dr1 = f(p);
+ float x;
+ g(x); // expected-error{{ambiguous}}
+ A<int> z;
+ float &fr1 = h(z);
+ const A<int> z2;
+ int &ir1 = h(z2);
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p5.cpp b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p5.cpp
new file mode 100644
index 0000000..4d34968
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p5.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<class T> int &f(T);
+template<class T> float &f(T*, int=1);
+
+template<class T> int &g(T);
+template<class T> float &g(T*, ...);
+
+int main() {
+ int* ip;
+ float &fr1 = f(ip);
+ float &fr2 = g(ip);
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4-neg.cpp b/clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4-neg.cpp
new file mode 100644
index 0000000..e9a3eaa
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4-neg.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> void f0(T) { } // expected-note{{previous}}
+template<class U> void f0(U) { } // expected-error{{redefinition}}
+
+template<int I> void f0() { } // expected-note{{previous}}
+template<int> void f0() { } // expected-error{{redefinition}}
+
+typedef int INT;
+
+template<template<class T, T Value1, INT> class X>
+ void f0() { } // expected-note{{previous}}
+template<template<typename T, T Value1, int> class>
+ void f0() { } // expected-error{{redefinition}}
+
+template<typename T>
+struct MetaFun;
+
+template<typename T>
+ typename MetaFun<T*>::type f0(const T&) { while (1) {} } // expected-note{{previous}}
+template<class U>
+ typename MetaFun<U*>::type f0(const U&) { while (1) {} } // expected-error{{redefinition}}
+
+// FIXME: We need canonicalization of expressions for this to work
+// template<int> struct A { };
+// template<int I> void f0(A<I>) { } // Xpected-note{{previous}}
+// template<int J> void f0(A<J>) { } // Xpected-error{{redefinition}}
diff --git a/clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4.cpp b/clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4.cpp
new file mode 100644
index 0000000..f42b94a
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// All of these function templates are distinct.
+template<typename T> void f0(T) { }
+template<typename T, typename U> void f0(T) { }
+template<typename T, typename U> void f0(U) { }
+void f0();
+template<typename T> void f0(T*);
+void f0(int);
+template<int I> void f0();
+template<typename T> void f0();
+
+
diff --git a/clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p6.cpp b/clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p6.cpp
new file mode 100644
index 0000000..a668ada
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p6.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<int N, int M>
+struct A0 {
+ void g0();
+};
+
+template<int X, int Y> void f0(A0<X, Y>) { } // expected-note{{previous}}
+template<int N, int M> void f0(A0<M, N>) { }
+template<int V1, int V2> void f0(A0<V1, V2>) { } // expected-error{{redefinition}}
+
+template<int X, int Y> void f1(A0<0, (X + Y)>) { } // expected-note{{previous}}
+template<int X, int Y> void f1(A0<0, (X - Y)>) { }
+template<int A, int B> void f1(A0<0, (A + B)>) { } // expected-error{{redefinition}}
+
+template<int X, int Y> void A0<X, Y>::g0() { }
diff --git a/clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp b/clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp
new file mode 100644
index 0000000..63f569b
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp
@@ -0,0 +1,358 @@
+// RUN: %clang_cc1 -verify -emit-llvm-only %s
+
+namespace test0 {
+template <typename T> struct Num {
+ T value_;
+
+public:
+ Num(T value) : value_(value) {}
+ T get() const { return value_; }
+
+ template <typename U> struct Rep {
+ U count_;
+ Rep(U count) : count_(count) {}
+
+ friend Num operator*(const Num &a, const Rep &n) {
+ Num x = 0;
+ for (U count = n.count_; count; --count)
+ x += a;
+ return x;
+ }
+ };
+
+ friend Num operator+(const Num &a, const Num &b) {
+ return a.value_ + b.value_;
+ }
+
+ Num& operator+=(const Num& b) {
+ value_ += b.value_;
+ return *this;
+ }
+
+ class Representation {};
+ friend class Representation;
+};
+
+class A {
+ template <typename T> friend bool iszero(const A &a) throw();
+};
+
+template <class T> class B_iterator;
+template <class T> class B {
+ friend class B_iterator<T>;
+};
+
+int calc1() {
+ Num<int> left = -1;
+ Num<int> right = 1;
+ Num<int> result = left + right;
+ return result.get();
+}
+
+int calc2() {
+ Num<int> x = 3;
+ Num<int>::Rep<char> n = (char) 10;
+ Num<int> result = x * n;
+ return result.get();
+}
+}
+
+// Reduced from GNU <locale>
+namespace test1 {
+ class A {
+ bool b; // expected-note {{declared private here}}
+ template <typename T> friend bool has(const A&);
+ };
+ template <typename T> bool has(const A &x) {
+ return x.b;
+ }
+ template <typename T> bool hasnot(const A &x) {
+ return x.b; // expected-error {{'b' is a private member of 'test1::A'}}
+ }
+}
+
+namespace test2 {
+ class A {
+ bool b; // expected-note {{declared private here}}
+ template <typename T> friend class HasChecker;
+ };
+ template <typename T> class HasChecker {
+ bool check(A *a) {
+ return a->b;
+ }
+ };
+ template <typename T> class HasNotChecker {
+ bool check(A *a) {
+ return a->b; // expected-error {{'b' is a private member of 'test2::A'}}
+ }
+ };
+}
+
+namespace test3 {
+ class Bool;
+ template <class T> class User;
+ template <class T> T transform(class Bool, T);
+
+ class Bool {
+ friend class User<bool>;
+ friend bool transform<>(Bool, bool);
+
+ bool value; // expected-note 2 {{declared private here}}
+ };
+
+ template <class T> class User {
+ static T compute(Bool b) {
+ return b.value; // expected-error {{'value' is a private member of 'test3::Bool'}}
+ }
+ };
+
+ template <class T> T transform(Bool b, T value) {
+ if (b.value) // expected-error {{'value' is a private member of 'test3::Bool'}}
+ return value;
+ return value + 1;
+ }
+
+ template bool transform(Bool, bool);
+ template int transform(Bool, int); // expected-note {{requested here}}
+
+ template class User<bool>;
+ template class User<int>; // expected-note {{requested here}}
+}
+
+namespace test4 {
+ template <class T> class A {
+ template <class T0> friend class B;
+ bool foo(const A<T> *) const;
+ };
+
+ template <class T> class B {
+ bool bar(const A<T> *a, const A<T> *b) {
+ return a->foo(b);
+ }
+ };
+
+ template class B<int>;
+}
+
+namespace test5 {
+ template <class T, class U=int> class A {};
+ template <class T> class B {
+ template <class X, class Y> friend class A;
+ };
+ template class B<int>;
+ template class A<int>;
+}
+
+namespace Dependent {
+ template<typename T, typename Traits> class X;
+ template<typename T, typename Traits>
+ X<T, Traits> operator+(const X<T, Traits>&, const T*);
+
+ template<typename T, typename Traits> class X {
+ typedef typename Traits::value_type value_type;
+ friend X operator+<>(const X&, const value_type*);
+ };
+}
+
+namespace test7 {
+ template <class T> class A { // expected-note {{declared here}}
+ friend class B;
+ int x; // expected-note {{declared private here}}
+ };
+
+ class B {
+ int foo(A<int> &a) {
+ return a.x;
+ }
+ };
+
+ class C {
+ int foo(A<int> &a) {
+ return a.x; // expected-error {{'x' is a private member of 'test7::A<int>'}}
+ }
+ };
+
+ // This shouldn't crash.
+ template <class T> class D {
+ friend class A; // expected-error {{elaborated type refers to a template}}
+ };
+ template class D<int>;
+}
+
+namespace test8 {
+ template <class N> class A {
+ static int x;
+ template <class T> friend void foo();
+ };
+ template class A<int>;
+
+ template <class T> void foo() {
+ A<int>::x = 0;
+ }
+ template void foo<int>();
+}
+
+namespace test9 {
+ template <class T> class A {
+ class B; class C;
+
+ int foo(B *b) {
+ return b->x;
+ }
+
+ int foo(C *c) {
+ return c->x; // expected-error {{'x' is a private member}}
+ }
+
+ class B {
+ int x;
+ friend int A::foo(B*);
+ };
+
+ class C {
+ int x; // expected-note {{declared private here}}
+ };
+ };
+
+ template class A<int>; // expected-note {{in instantiation}}
+}
+
+namespace test10 {
+ template <class T> class A;
+ template <class T> A<T> bar(const T*, const A<T>&);
+ template <class T> class A {
+ private:
+ void foo(); // expected-note {{declared private here}}
+ friend A bar<>(const T*, const A<T>&);
+ };
+
+ template <class T> A<T> bar(const T *l, const A<T> &r) {
+ A<T> l1;
+ l1.foo();
+
+ A<char> l2;
+ l2.foo(); // expected-error {{'foo' is a private member of 'test10::A<char>'}}
+
+ return l1;
+ }
+
+ template A<int> bar<int>(const int *, const A<int> &); // expected-note {{in instantiation}}
+}
+
+// PR6752: this shouldn't crash.
+namespace test11 {
+ struct Foo {
+ template<class A>
+ struct IteratorImpl {
+ template<class T> friend class IteratorImpl;
+ };
+ };
+
+ template struct Foo::IteratorImpl<int>;
+ template struct Foo::IteratorImpl<long>;
+}
+
+// PR6827
+namespace test12 {
+ template <typename T> class Foo;
+ template <typename T> Foo<T> foo(T* t){ return Foo<T>(t, true); }
+
+ template <typename T> class Foo {
+ public:
+ Foo(T*);
+ friend Foo<T> foo<T>(T*);
+ private:
+ Foo(T*, bool); // expected-note {{declared private here}}
+ };
+
+ // Should work.
+ int globalInt;
+ Foo<int> f = foo(&globalInt);
+
+ // Shouldn't work.
+ long globalLong;
+ template <> Foo<long> foo(long *t) {
+ Foo<int> s(&globalInt, false); // expected-error {{calling a private constructor}}
+ return Foo<long>(t, true);
+ }
+}
+
+// PR6514
+namespace test13 {
+ template <int N, template <int> class Temp>
+ class Role : public Temp<N> {
+ friend class Temp<N>;
+ int x;
+ };
+
+ template <int N> class Foo {
+ void foo(Role<N, test13::Foo> &role) {
+ (void) role.x;
+ }
+ };
+
+ template class Foo<0>;
+}
+
+namespace test14 {
+ template <class T> class B;
+ template <class T> class A {
+ friend void B<T>::foo();
+ static void foo(); // expected-note {{declared private here}}
+ };
+
+ template <class T> class B {
+ void foo() { return A<long>::foo(); } // expected-error {{'foo' is a private member of 'test14::A<long>'}}
+ };
+
+ template class B<int>; // expected-note {{in instantiation}}
+}
+
+namespace test15 {
+ template <class T> class B;
+ template <class T> class A {
+ friend void B<T>::foo();
+
+ // This shouldn't be misrecognized as a templated-scoped reference.
+ template <class U> friend void B<T>::bar(U);
+
+ static void foo(); // expected-note {{declared private here}}
+ };
+
+ template <class T> class B {
+ void foo() { return A<long>::foo(); } // expected-error {{'foo' is a private member of 'test15::A<long>'}}
+ };
+
+ template <> class B<float> {
+ void foo() { return A<float>::foo(); }
+ template <class U> void bar(U u) {
+ (void) A<float>::foo();
+ }
+ };
+
+ template class B<int>; // expected-note {{in instantiation}}
+}
+
+namespace PR10913 {
+ template<class T> class X;
+
+ template<class T> void f(X<T> *x) {
+ x->member = 0;
+ }
+
+ template<class U, class T> void f2(X<T> *x) {
+ x->member = 0; // expected-error{{'member' is a protected member of 'PR10913::X<int>'}}
+ }
+
+ template<class T> class X {
+ friend void f<T>(X<T> *x);
+ friend void f2<T>(X<int> *x);
+
+ protected:
+ int member; // expected-note{{declared protected here}}
+ };
+
+ template void f(X<int> *);
+ template void f2<int>(X<int> *);
+ template void f2<float>(X<int> *); // expected-note{{in instantiation of function template specialization 'PR10913::f2<float, int>' requested here}}
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.friend/p3.cpp b/clang/test/CXX/temp/temp.decls/temp.friend/p3.cpp
new file mode 100644
index 0000000..0b2a25e
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.friend/p3.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template <class T> class A {
+ typedef int Member;
+};
+
+class B {
+ template <class T> friend class A;
+ template <class T> friend class Undeclared;
+
+ template <class T> friend typename A<T>::Member; // expected-error {{friend type templates must use an elaborated type}}
+};
diff --git a/clang/test/CXX/temp/temp.decls/temp.friend/p4.cpp b/clang/test/CXX/temp/temp.decls/temp.friend/p4.cpp
new file mode 100644
index 0000000..e036cef
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.friend/p4.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+struct X1 {
+ friend void f6(int) { } // expected-error{{redefinition of}} \
+ // expected-note{{previous definition}}
+};
+
+X1<int> x1a;
+X1<float> x1b; // expected-note {{in instantiation of}}
+
+template<typename T>
+struct X2 {
+ operator int();
+
+ friend void f(int x) { } // expected-error{{redefinition}} \
+ // expected-note{{previous definition}}
+};
+
+int array0[sizeof(X2<int>)];
+int array1[sizeof(X2<float>)]; // expected-note{{instantiation of}}
+
+void g() {
+ X2<int> xi;
+ f(xi);
+ X2<float> xf;
+ f(xf);
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.friend/p5.cpp b/clang/test/CXX/temp/temp.decls/temp.friend/p5.cpp
new file mode 100644
index 0000000..63fd3df
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.friend/p5.cpp
@@ -0,0 +1,103 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace test0 {
+ template <class T> class A {
+ class Member {};
+ };
+
+ class B {
+ template <class T> friend class A<T>::Member;
+ };
+
+ A<int> a;
+ B b;
+}
+
+// rdar://problem/8204127
+namespace test1 {
+ template <class T> struct A;
+
+ class C {
+ static void foo();
+ template <class T> friend void A<T>::f();
+ };
+
+ template <class T> struct A {
+ void f() { C::foo(); }
+ };
+
+ template <class T> struct A<T*> {
+ void f() { C::foo(); }
+ };
+
+ template <> struct A<char> {
+ void f() { C::foo(); }
+ };
+}
+
+// FIXME: these should fail!
+namespace test2 {
+ template <class T> struct A;
+
+ class C {
+ static void foo();
+ template <class T> friend void A<T>::g();
+ };
+
+ template <class T> struct A {
+ void f() { C::foo(); }
+ };
+
+ template <class T> struct A<T*> {
+ void f() { C::foo(); }
+ };
+
+ template <> struct A<char> {
+ void f() { C::foo(); }
+ };
+}
+
+// Tests 3, 4 and 5 were all noted in <rdar://problem/8540527>.
+namespace test3 {
+ template <class T> struct A {
+ struct Inner {
+ static int foo();
+ };
+ };
+
+ template <class U> class C {
+ int i;
+ template <class T> friend struct A<T>::Inner;
+ };
+
+ template <class T> int A<T>::Inner::foo() {
+ C<int> c;
+ c.i = 0;
+ return 0;
+ }
+
+ int test = A<int>::Inner::foo();
+}
+
+namespace test4 {
+ template <class T> struct X {
+ template <class U> void operator+=(U);
+
+ template <class V>
+ template <class U>
+ friend void X<V>::operator+=(U);
+ };
+
+ void test() {
+ X<int>() += 1.0;
+ }
+}
+
+namespace test5 {
+ template<template <class> class T> struct A {
+ template<template <class> class T> friend void A<T>::foo();
+ };
+
+ template <class> struct B {};
+ template class A<B>;
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.friend/p8.cpp b/clang/test/CXX/temp/temp.decls/temp.friend/p8.cpp
new file mode 100644
index 0000000..d0221a3
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.friend/p8.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<class T> class A { };
+
+class X {
+ template<class T> friend class A<T*>; // expected-error{{partial specialization cannot be declared as a friend}}
+};
diff --git a/clang/test/CXX/temp/temp.decls/temp.mem/p1.cpp b/clang/test/CXX/temp/temp.decls/temp.mem/p1.cpp
new file mode 100644
index 0000000..f5f1205
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.mem/p1.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template <class T> struct A {
+ static T cond;
+
+ template <class U> struct B {
+ static T twice(U value) {
+ return (cond ? value + value : value);
+ }
+ };
+};
+
+int foo() {
+ A<bool>::cond = true;
+ return A<bool>::B<int>::twice(4);
+}
+
+namespace PR6376 {
+ template<typename T>
+ struct X {
+ template<typename Y>
+ struct Y1 { }; //
+ };
+
+ template<>
+ struct X<float> {
+ template<typename Y>
+ struct Y1 { };
+ };
+
+ template<typename T, typename U>
+ struct Z : public X<T>::template Y1<U> { };
+
+ Z<float, int> z0;
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp b/clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp
new file mode 100644
index 0000000..0eb747b
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.mem/p3.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template <class T> struct AA {
+ template <class C> virtual void g(C); // expected-error{{'virtual' can not be specified on member function templates}}
+ virtual void f();
+};
diff --git a/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp b/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
new file mode 100644
index 0000000..8bcd773
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct A {
+ template <class T> operator T*();
+};
+
+template <class T> A::operator T*() { return 0; }
+template <> A::operator char*(){ return 0; } // specialization
+template A::operator void*(); // explicit instantiation
+
+int main() {
+ A a;
+ int *ip;
+ ip = a.operator int*();
+}
+
+// PR5742
+namespace PR5742 {
+ template <class T> struct A { };
+ template <class T> struct B { };
+
+ struct S {
+ template <class T> operator T();
+ } s;
+
+ void f() {
+ s.operator A<A<int> >();
+ s.operator A<B<int> >();
+ s.operator A<B<A<int> > >();
+ }
+}
+
+// PR5762
+class Foo {
+ public:
+ template <typename T> operator T();
+
+ template <typename T>
+ T As() {
+ return this->operator T();
+ }
+
+ template <typename T>
+ T As2() {
+ return operator T();
+ }
+
+ int AsInt() {
+ return this->operator int();
+ }
+};
+
+template float Foo::As();
+template double Foo::As2();
+
+// Partial ordering with conversion function templates.
+struct X0 {
+ template<typename T> operator T*() {
+ T x = 1;
+ x = 17; // expected-error{{read-only variable is not assignable}}
+ }
+
+ template<typename T> operator T*() const; // expected-note{{explicit instantiation refers here}}
+
+ template<typename T> operator const T*() const {
+ T x = T();
+ return x; // expected-error{{cannot initialize return object of type 'const char *' with an lvalue of type 'char'}} \
+ // expected-error{{cannot initialize return object of type 'const int *' with an lvalue of type 'int'}}
+ }
+};
+
+template X0::operator const char*() const; // expected-note{{'X0::operator const char *<char>' requested here}}
+template X0::operator const int*(); // expected-note{{'X0::operator const int *<const int>' requested here}}
+template X0::operator float*() const; // expected-error{{explicit instantiation of undefined function template}}
+
+void test_X0(X0 x0, const X0 &x0c) {
+ x0.operator const int*(); // expected-note{{in instantiation of function template specialization}}
+ x0.operator float *();
+ x0c.operator const char*();
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp
new file mode 100644
index 0000000..fec8060
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+namespace DeductionForInstantiation {
+ template<unsigned I, typename ...Types>
+ struct X { };
+
+ template<typename ...Types>
+ void f0(X<sizeof...(Types), Types&...>) { }
+
+ // No explicitly-specified arguments
+ template void f0(X<0>);
+ template void f0(X<1, int&>);
+ template void f0(X<2, int&, short&>);
+
+ // One explicitly-specified argument
+ template void f0<float>(X<1, float&>);
+ template void f0<double>(X<1, double&>);
+
+ // Two explicitly-specialized arguments
+ template void f0<char, unsigned char>(X<2, char&, unsigned char&>);
+ template void f0<signed char, char>(X<2, signed char&, char&>);
+
+ // FIXME: Extension of explicitly-specified arguments
+ // template void f0<short, int>(X<3, short&, int&, long&>);
+}
+
+namespace DeductionWithConversion {
+ template<char...> struct char_values {
+ static const unsigned value = 0;
+ };
+
+ template<int C1, char C3>
+ struct char_values<C1, 12, C3> {
+ static const unsigned value = 1;
+ };
+
+ int check0[char_values<1, 12, 3>::value == 1? 1 : -1];
+
+ template<int...> struct int_values {
+ static const unsigned value = 0;
+ };
+
+ template<unsigned char C1, unsigned char C3>
+ struct int_values<C1, 12, C3> {
+ static const unsigned value = 1;
+ };
+
+ int check1[int_values<256, 12, 3>::value == 0? 1 : -1];
+ int check2[int_values<3, 12, 3>::value == 1? 1 : -1];
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/example-bind.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/example-bind.cpp
new file mode 100644
index 0000000..db28eea
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/example-bind.cpp
@@ -0,0 +1,352 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Example bind implementation from the variadic templates proposal,
+// ISO C++ committee document number N2080.
+
+// Helper type traits
+template<typename T>
+struct add_reference {
+ typedef T &type;
+};
+
+template<typename T>
+struct add_reference<T&> {
+ typedef T &type;
+};
+
+template<typename T>
+struct add_const_reference {
+ typedef T const &type;
+};
+
+template<typename T>
+struct add_const_reference<T&> {
+ typedef T &type;
+};
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+template<typename T>
+class reference_wrapper {
+ T *ptr;
+
+public:
+ reference_wrapper(T& t) : ptr(&t) { }
+ operator T&() const { return *ptr; }
+};
+
+template<typename T> reference_wrapper<T> ref(T& t) {
+ return reference_wrapper<T>(t);
+}
+template<typename T> reference_wrapper<const T> cref(const T& t) {
+ return reference_wrapper<const T>(t);
+}
+
+template<typename... Values> class tuple;
+
+// Basis case: zero-length tuple
+template<> class tuple<> { };
+
+template<typename Head, typename... Tail>
+class tuple<Head, Tail...> : private tuple<Tail...> {
+ typedef tuple<Tail...> inherited;
+
+public:
+ tuple() { }
+ // implicit copy-constructor is okay
+
+ // Construct tuple from separate arguments.
+ tuple(typename add_const_reference<Head>::type v,
+ typename add_const_reference<Tail>::type... vtail)
+ : m_head(v), inherited(vtail...) { }
+
+ // Construct tuple from another tuple.
+ template<typename... VValues> tuple(const tuple<VValues...>& other)
+ : m_head(other.head()), inherited(other.tail()) { }
+
+ template<typename... VValues> tuple&
+ operator=(const tuple<VValues...>& other) {
+ m_head = other.head();
+ tail() = other.tail();
+ return *this;
+ }
+
+ typename add_reference<Head>::type head() { return m_head; }
+ typename add_reference<const Head>::type head() const { return m_head; }
+ inherited& tail() { return *this; }
+ const inherited& tail() const { return *this; }
+
+protected:
+ Head m_head;
+};
+
+// Creation functions
+template<typename T>
+struct make_tuple_result {
+ typedef T type;
+};
+
+template<typename T>
+struct make_tuple_result<reference_wrapper<T> > {
+ typedef T& type;
+};
+
+template<typename... Values>
+tuple<typename make_tuple_result<Values>::type...>
+make_tuple(const Values&... values) {
+ return tuple<typename make_tuple_result<Values>::type...>(values...);
+}
+
+template<typename... Values>
+tuple<Values&...> tie(Values&... values) {
+ return tuple<Values&...>(values...);
+}
+
+// Helper classes
+template<typename Tuple> struct tuple_size;
+
+template<typename... Values> struct tuple_size<tuple<Values...> > {
+ static const int value = sizeof...(Values);
+};
+
+template<int I, typename Tuple> struct tuple_element;
+
+template<int I, typename Head, typename... Tail>
+struct tuple_element<I, tuple<Head, Tail...> > {
+ typedef typename tuple_element<I-1, tuple<Tail...> >::type type;
+};
+
+template<typename Head, typename... Tail>
+struct tuple_element<0, tuple<Head, Tail...> > {
+ typedef Head type;
+};
+
+// Element access
+template<int I, typename Tuple> class get_impl;
+template<int I, typename Head, typename... Values>
+class get_impl<I, tuple<Head, Values...> > {
+ typedef typename tuple_element<I-1, tuple<Values...> >::type Element;
+ typedef typename add_reference<Element>::type RJ;
+ typedef typename add_const_reference<Element>::type PJ;
+ typedef get_impl<I-1, tuple<Values...> > Next;
+public:
+ static RJ get(tuple<Head, Values...>& t) { return Next::get(t.tail()); }
+ static PJ get(const tuple<Head, Values...>& t) { return Next::get(t.tail()); }
+};
+
+template<typename Head, typename... Values>
+class get_impl<0, tuple<Head, Values...> > {
+ typedef typename add_reference<Head>::type RJ;
+ typedef typename add_const_reference<Head>::type PJ;
+public:
+ static RJ get(tuple<Head, Values...>& t) { return t.head(); }
+ static PJ get(const tuple<Head, Values...>& t) { return t.head(); }
+};
+
+template<int I, typename... Values> typename add_reference<
+typename tuple_element<I, tuple<Values...> >::type >::type
+get(tuple<Values...>& t) {
+ return get_impl<I, tuple<Values...> >::get(t);
+}
+
+template<int I, typename... Values> typename add_const_reference<
+typename tuple_element<I, tuple<Values...> >::type >::type
+get(const tuple<Values...>& t) {
+ return get_impl<I, tuple<Values...> >::get(t);
+}
+
+// Relational operators
+inline bool operator==(const tuple<>&, const tuple<>&) { return true; }
+
+template<typename T, typename... TTail, typename U, typename... UTail>
+bool operator==(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) {
+ return t.head() == u.head() && t.tail() == u.tail();
+}
+
+template<typename... TValues, typename... UValues>
+bool operator!=(const tuple<TValues...>& t, const tuple<UValues...>& u) {
+ return !(t == u);
+}
+
+inline bool operator<(const tuple<>&, const tuple<>&) { return false; }
+
+template<typename T, typename... TTail, typename U, typename... UTail>
+bool operator<(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) {
+ return (t.head() < u.head() || (!(t.head() < u.head()) && t.tail() < u.tail()));
+}
+
+template<typename... TValues, typename... UValues>
+bool operator>(const tuple<TValues...>& t, const tuple<UValues...>& u) {
+ return u < t;
+}
+
+template<typename... TValues, typename... UValues>
+bool operator<=(const tuple<TValues...>& t, const tuple<UValues...>& u) {
+ return !(u < t);
+}
+
+template<typename... TValues, typename... UValues>
+bool operator>=(const tuple<TValues...>& t, const tuple<UValues...>& u) {
+ return !(t < u);
+}
+
+// make_indices helper
+template<int...> struct int_tuple {};
+// make_indexes impl is a helper for make_indexes
+template<int I, typename IntTuple, typename... Types> struct make_indexes_impl;
+
+template<int I, int... Indexes, typename T, typename... Types>
+struct make_indexes_impl<I, int_tuple<Indexes...>, T, Types...> {
+ typedef typename make_indexes_impl<I+1, int_tuple<Indexes..., I>, Types...>::type type;
+};
+
+template<int I, int... Indexes>
+struct make_indexes_impl<I, int_tuple<Indexes...> > {
+ typedef int_tuple<Indexes...> type;
+};
+
+template<typename... Types>
+struct make_indexes : make_indexes_impl<0, int_tuple<>, Types...> {
+};
+
+// Bind
+template<typename T> struct is_bind_expression {
+ static const bool value = false;
+};
+
+template<typename T> struct is_placeholder {
+ static const int value = 0;
+};
+
+
+template<typename F, typename... BoundArgs> class bound_functor {
+ typedef typename make_indexes<BoundArgs...>::type indexes;
+public:
+ typedef typename F::result_type result_type;
+ explicit bound_functor(const F& f, const BoundArgs&... bound_args)
+ : f(f), bound_args(bound_args...) { } template<typename... Args>
+ typename F::result_type operator()(Args&... args);
+private: F f;
+ tuple<BoundArgs...> bound_args;
+};
+
+template<typename F, typename... BoundArgs>
+inline bound_functor<F, BoundArgs...> bind(const F& f, const BoundArgs&... bound_args) {
+ return bound_functor<F, BoundArgs...>(f, bound_args...);
+}
+
+template<typename F, typename ...BoundArgs>
+struct is_bind_expression<bound_functor<F, BoundArgs...> > {
+ static const bool value = true;
+};
+
+// enable_if helper
+template<bool Cond, typename T = void>
+struct enable_if;
+
+template<typename T>
+struct enable_if<true, T> {
+ typedef T type;
+};
+
+template<typename T>
+struct enable_if<false, T> { };
+
+// safe_tuple_element helper
+template<int I, typename Tuple, typename = void>
+struct safe_tuple_element { };
+
+template<int I, typename... Values>
+struct safe_tuple_element<I, tuple<Values...>,
+ typename enable_if<(I >= 0 && I < tuple_size<tuple<Values...> >::value)>::type> {
+ typedef typename tuple_element<I, tuple<Values...> >::type type;
+};
+
+// mu
+template<typename Bound, typename... Args>
+inline typename safe_tuple_element<is_placeholder<Bound>::value -1,
+ tuple<Args...> >::type
+mu(Bound& bound_arg, const tuple<Args&...>& args) {
+ return get<is_placeholder<Bound>::value-1>(args);
+}
+
+template<typename T, typename... Args>
+inline T& mu(reference_wrapper<T>& bound_arg, const tuple<Args&...>&) {
+ return bound_arg.get();
+}
+
+template<typename F, int... Indexes, typename... Args>
+inline typename F::result_type
+unwrap_and_forward(F& f, int_tuple<Indexes...>, const tuple<Args&...>& args) {
+ return f(get<Indexes>(args)...);
+}
+
+template<typename Bound, typename... Args>
+inline typename enable_if<is_bind_expression<Bound>::value,
+ typename Bound::result_type>::type
+mu(Bound& bound_arg, const tuple<Args&...>& args) {
+ typedef typename make_indexes<Args...>::type Indexes;
+ return unwrap_and_forward(bound_arg, Indexes(), args);
+}
+
+template<typename T>
+struct is_reference_wrapper {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_reference_wrapper<reference_wrapper<T>> {
+ static const bool value = true;
+};
+
+template<typename Bound, typename... Args>
+inline typename enable_if<(!is_bind_expression<Bound>::value
+ && !is_placeholder<Bound>::value
+ && !is_reference_wrapper<Bound>::value),
+ Bound&>::type
+mu(Bound& bound_arg, const tuple<Args&...>&) {
+ return bound_arg;
+}
+
+template<typename F, typename... BoundArgs, int... Indexes, typename... Args>
+typename F::result_type apply_functor(F& f, tuple<BoundArgs...>& bound_args,
+ int_tuple<Indexes...>,
+ const tuple<Args&...>& args) {
+ return f(mu(get<Indexes>(bound_args), args)...);
+}
+
+template<typename F, typename... BoundArgs>
+template<typename... Args>
+typename F::result_type bound_functor<F, BoundArgs...>::operator()(Args&... args) {
+ return apply_functor(f, bound_args, indexes(), tie(args...));
+}
+
+template<int N> struct placeholder { };
+template<int N>
+struct is_placeholder<placeholder<N>> {
+ static const int value = N;
+};
+
+template<typename T>
+struct plus {
+ typedef T result_type;
+
+ T operator()(T x, T y) { return x + y; }
+};
+
+placeholder<1> _1;
+
+// Test bind
+void test_bind() {
+ int x = 17;
+ int y = 25;
+ bind(plus<int>(), x, _1)(y);
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/example-function.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/example-function.cpp
new file mode 100644
index 0000000..e15203a
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/example-function.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Example function implementation from the variadic templates proposal,
+// ISO C++ committee document number N2080.
+
+template<typename Signature> class function;
+
+template<typename R, typename... Args> class invoker_base {
+public:
+ virtual ~invoker_base() { }
+ virtual R invoke(Args...) = 0;
+ virtual invoker_base* clone() = 0;
+};
+
+template<typename F, typename R, typename... Args>
+class functor_invoker : public invoker_base<R, Args...> {
+public:
+ explicit functor_invoker(const F& f) : f(f) { }
+ R invoke(Args... args) { return f(args...); }
+ functor_invoker* clone() { return new functor_invoker(f); }
+
+private:
+ F f;
+};
+
+template<typename R, typename... Args>
+class function<R (Args...)> {
+public:
+ typedef R result_type;
+ function() : invoker (0) { }
+ function(const function& other) : invoker(0) {
+ if (other.invoker)
+ invoker = other.invoker->clone();
+ }
+
+ template<typename F> function(const F& f) : invoker(0) {
+ invoker = new functor_invoker<F, R, Args...>(f);
+ }
+
+ ~function() {
+ if (invoker)
+ delete invoker;
+ }
+
+ function& operator=(const function& other) {
+ function(other).swap(*this);
+ return *this;
+ }
+
+ template<typename F>
+ function& operator=(const F& f) {
+ function(f).swap(*this);
+ return *this;
+ }
+
+ void swap(function& other) {
+ invoker_base<R, Args...>* tmp = invoker;
+ invoker = other.invoker;
+ other.invoker = tmp;
+ }
+
+ result_type operator()(Args... args) const {
+ return invoker->invoke(args...);
+ }
+
+private:
+ invoker_base<R, Args...>* invoker;
+};
+
+template<typename T>
+struct add {
+ T operator()(T x, T y) { return x + y; }
+};
+
+int add_ints(int x, int y) { return x + y; }
+
+void test_function() {
+ function<int(int, int)> f2a;
+ function<int(int, int)> f2b = add<int>();
+ function<int(int, int)> f2c = add<float>();
+ function<int(int, int)> f2d(f2b);
+ function<int(int, int)> f2e = &add_ints;
+ f2c = f2d;
+ f2d = &add_ints;
+ f2c(1.0, 3);
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/example-tuple.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/example-tuple.cpp
new file mode 100644
index 0000000..9de5fa8
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/example-tuple.cpp
@@ -0,0 +1,260 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Example tuple implementation from the variadic templates proposal,
+// ISO C++ committee document number N2080.
+
+// Helper type traits
+template<typename T>
+struct add_reference {
+ typedef T &type;
+};
+
+template<typename T>
+struct add_reference<T&> {
+ typedef T &type;
+};
+
+template<typename T>
+struct add_const_reference {
+ typedef T const &type;
+};
+
+template<typename T>
+struct add_const_reference<T&> {
+ typedef T &type;
+};
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+template<typename T>
+class reference_wrapper {
+ T *ptr;
+
+public:
+ reference_wrapper(T& t) : ptr(&t) { }
+ operator T&() const { return *ptr; }
+};
+
+template<typename T> reference_wrapper<T> ref(T& t) {
+ return reference_wrapper<T>(t);
+}
+template<typename T> reference_wrapper<const T> cref(const T& t) {
+ return reference_wrapper<const T>(t);
+}
+
+template<typename... Values> class tuple;
+
+// Basis case: zero-length tuple
+template<> class tuple<> { };
+
+template<typename Head, typename... Tail>
+class tuple<Head, Tail...> : private tuple<Tail...> {
+ typedef tuple<Tail...> inherited;
+
+public:
+ tuple() { }
+ // implicit copy-constructor is okay
+
+ // Construct tuple from separate arguments.
+ tuple(typename add_const_reference<Head>::type v,
+ typename add_const_reference<Tail>::type... vtail)
+ : m_head(v), inherited(vtail...) { }
+
+ // Construct tuple from another tuple.
+ template<typename... VValues> tuple(const tuple<VValues...>& other)
+ : m_head(other.head()), inherited(other.tail()) { }
+
+ template<typename... VValues> tuple&
+ operator=(const tuple<VValues...>& other) {
+ m_head = other.head();
+ tail() = other.tail();
+ return *this;
+ }
+
+ typename add_reference<Head>::type head() { return m_head; }
+ typename add_reference<const Head>::type head() const { return m_head; }
+ inherited& tail() { return *this; }
+ const inherited& tail() const { return *this; }
+
+protected:
+ Head m_head;
+};
+
+void test_tuple() {
+ tuple<> t0a;
+ tuple<> t0b(t0a);
+ t0a = t0b;
+
+ tuple<int> t1a;
+ tuple<int> t1b(17);
+ tuple<int> t1c(t1b);
+ t1a = t1b;
+
+ tuple<float> t1d(3.14159);
+ tuple<float> t1e(t1d);
+ t1d = t1e;
+
+ int i;
+ float f;
+ double d;
+ tuple<int*, float*, double*> t3a(&i, &f, &d);
+}
+
+// Creation functions
+template<typename T>
+struct make_tuple_result {
+ typedef T type;
+};
+
+template<typename T>
+struct make_tuple_result<reference_wrapper<T> > {
+ typedef T& type;
+};
+
+template<typename... Values>
+tuple<typename make_tuple_result<Values>::type...>
+make_tuple(const Values&... values) {
+ return tuple<typename make_tuple_result<Values>::type...>(values...);
+}
+
+template<typename... Values>
+tuple<Values&...> tie(Values&... values) {
+ return tuple<Values&...>(values...);
+}
+
+template<typename T> const T *addr(const T& ref) { return &ref; }
+void test_creation_functions() {
+ int i;
+ float f;
+ double d;
+ const tuple<int, float&, const double&> *t3p = addr(make_tuple(i, ref(f), cref(d)));
+ const tuple<int&, float&, double&> *t3q = addr(tie(i, f, d));
+}
+
+// Helper classes
+template<typename Tuple> struct tuple_size;
+
+template<typename... Values> struct tuple_size<tuple<Values...> > {
+ static const int value = sizeof...(Values);
+};
+
+int check_tuple_size_0[tuple_size<tuple<> >::value == 0? 1 : -1];
+int check_tuple_size_1[tuple_size<tuple<int>>::value == 1? 1 : -1];
+int check_tuple_size_2[tuple_size<tuple<float, double>>::value == 2? 1 : -1];
+int check_tuple_size_3[tuple_size<tuple<char, unsigned char, signed char>>::value == 3? 1 : -1];
+
+template<int I, typename Tuple> struct tuple_element;
+
+template<int I, typename Head, typename... Tail>
+struct tuple_element<I, tuple<Head, Tail...> > {
+ typedef typename tuple_element<I-1, tuple<Tail...> >::type type;
+};
+
+template<typename Head, typename... Tail>
+struct tuple_element<0, tuple<Head, Tail...> > {
+ typedef Head type;
+};
+
+int check_tuple_element_0[is_same<tuple_element<0, tuple<int&, float, double>>::type,
+ int&>::value? 1 : -1];
+
+int check_tuple_element_1[is_same<tuple_element<1, tuple<int&, float, double>>::type,
+ float>::value? 1 : -1];
+
+int check_tuple_element_2[is_same<tuple_element<2, tuple<int&, float, double>>::type,
+ double>::value? 1 : -1];
+
+// Element access
+template<int I, typename Tuple> class get_impl;
+template<int I, typename Head, typename... Values>
+class get_impl<I, tuple<Head, Values...> > {
+ typedef typename tuple_element<I-1, tuple<Values...> >::type Element;
+ typedef typename add_reference<Element>::type RJ;
+ typedef typename add_const_reference<Element>::type PJ;
+ typedef get_impl<I-1, tuple<Values...> > Next;
+public:
+ static RJ get(tuple<Head, Values...>& t) { return Next::get(t.tail()); }
+ static PJ get(const tuple<Head, Values...>& t) { return Next::get(t.tail()); }
+};
+
+template<typename Head, typename... Values>
+class get_impl<0, tuple<Head, Values...> > {
+ typedef typename add_reference<Head>::type RJ;
+ typedef typename add_const_reference<Head>::type PJ;
+public:
+ static RJ get(tuple<Head, Values...>& t) { return t.head(); }
+ static PJ get(const tuple<Head, Values...>& t) { return t.head(); }
+};
+
+template<int I, typename... Values> typename add_reference<
+typename tuple_element<I, tuple<Values...> >::type >::type
+get(tuple<Values...>& t) {
+ return get_impl<I, tuple<Values...> >::get(t);
+}
+
+template<int I, typename... Values> typename add_const_reference<
+typename tuple_element<I, tuple<Values...> >::type >::type
+get(const tuple<Values...>& t) {
+ return get_impl<I, tuple<Values...> >::get(t);
+}
+
+void test_element_access(tuple<int*, float*, double*&> t3) {
+ int i;
+ float f;
+ double d;
+ get<0>(t3) = &i;
+ get<1>(t3) = &f;
+ get<2>(t3) = &d;
+}
+
+// Relational operators
+inline bool operator==(const tuple<>&, const tuple<>&) { return true; }
+
+template<typename T, typename... TTail, typename U, typename... UTail>
+bool operator==(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) {
+ return t.head() == u.head() && t.tail() == u.tail();
+}
+
+template<typename... TValues, typename... UValues>
+bool operator!=(const tuple<TValues...>& t, const tuple<UValues...>& u) {
+ return !(t == u);
+}
+
+inline bool operator<(const tuple<>&, const tuple<>&) { return false; }
+
+template<typename T, typename... TTail, typename U, typename... UTail>
+bool operator<(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) {
+ return (t.head() < u.head() || (!(t.head() < u.head()) && t.tail() < u.tail()));
+}
+
+template<typename... TValues, typename... UValues>
+bool operator>(const tuple<TValues...>& t, const tuple<UValues...>& u) {
+ return u < t;
+}
+
+template<typename... TValues, typename... UValues>
+bool operator<=(const tuple<TValues...>& t, const tuple<UValues...>& u) {
+ return !(u < t);
+}
+
+template<typename... TValues, typename... UValues>
+bool operator>=(const tuple<TValues...>& t, const tuple<UValues...>& u) {
+ return !(t < u);
+}
+
+void test_relational_operators(tuple<int*, float*, double*> t3) {
+ (void)(t3 == t3);
+ (void)(t3 != t3);
+ (void)(t3 < t3);
+ (void)(t3 <= t3);
+ (void)(t3 >= t3);
+ (void)(t3 > t3);
+};
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp
new file mode 100644
index 0000000..6d9d8c5
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -std=c++11 -fblocks -fsyntax-only -verify %s
+
+// Tests the use of blocks with variadic templates.
+template<typename ...Args>
+int f0(Args ...args) {
+ return ^ {
+ return sizeof...(Args);
+ }() + ^ {
+ return sizeof...(args);
+ }();
+}
+
+template<typename ...Args>
+int f1(Args ...args) {
+ return ^ {
+ return f0(args...);
+ }();
+}
+
+template int f0(int, float, double);
+template int f1(const char*, int, float, double);
+
+template<typename ...Args>
+int f2(Args ...args) {
+ return ^(Args ...block_args) {
+ return f1(block_args...);
+ }(args + 0 ...);
+}
+
+template int f2(const char*, int, float, double);
+
+template<typename ...Args>
+int f3(Args ...args) {
+ return ^(Args *...block_args) {
+ return f1(block_args...);
+ }(&args...);
+}
+
+template int f3(const char*, int, float, double);
+
+template<typename ...Args>
+int PR9953(Args ...args) {
+ return ^(Args *...block_args) {
+ return f1(block_args); // expected-error{{expression contains unexpanded parameter pack 'block_args'}}
+ }(&args...);
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
new file mode 100644
index 0000000..fb72754
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
@@ -0,0 +1,127 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+template<typename T, typename U> struct pair { };
+template<typename ...Types> struct tuple { };
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+namespace ExpandIntoFixed {
+ template<typename T,
+ typename U,
+ typename V = pair<T, U>,
+ typename W = V*>
+ class X0 { };
+
+ template<typename ...Ts>
+ class X1 {
+ public:
+ typedef X0<Ts...> type;
+ };
+
+ static_assert(is_same<X1<int, int>::type,
+ X0<int, int, pair<int, int>, pair<int, int>*>>::value,
+ "fails with two default arguments");
+
+ static_assert(is_same<X1<int, int, float>::type,
+ X0<int, int, float, float*>>::value,
+ "fails with one default argument");
+
+ static_assert(is_same<X1<int, int, float, double>::type,
+ X0<int, int, float, double>>::value,
+ "fails with no default arguments");
+}
+
+namespace ExpandIntoFixedShifted {
+ template<typename T,
+ typename U,
+ typename V = pair<T, U>,
+ typename W = V*>
+ class X0 { };
+
+ template<typename ...Ts>
+ class X1 {
+ public:
+ typedef X0<char, Ts...> type;
+ };
+
+ static_assert(is_same<X1<int>::type,
+ X0<char, int, pair<char, int>, pair<char, int>*>>::value,
+ "fails with two default arguments");
+
+ static_assert(is_same<X1<int, float>::type,
+ X0<char, int, float, float*>>::value,
+ "fails with one default argument");
+
+ static_assert(is_same<X1<int, float, double>::type,
+ X0<char, int, float, double>>::value,
+ "fails with no default arguments");
+}
+
+namespace Deduction {
+ template <typename X, typename Y = double> struct Foo {};
+ template <typename ...Args> tuple<Args...> &foo(Foo<Args...>);
+
+ void call_foo(Foo<int, float> foo_if, Foo<int> foo_i) {
+ tuple<int, float> &t1 = foo(foo_if);
+ tuple<int, double> &t2 = foo(foo_i);
+ }
+}
+
+namespace PR9021a {
+ template<typename, typename>
+ struct A { };
+
+ template<typename ...T>
+ struct B {
+ A<T...> a1;
+ };
+
+ void test() {
+ B<int, int> c;
+ }
+}
+
+namespace PR9021b {
+ template<class, class>
+ struct t2
+ {
+
+ };
+
+ template<template<class...> class M>
+ struct m
+ {
+ template<class... B>
+ using inner = M<B...>;
+ };
+
+ m<t2> sta2;
+}
+
+namespace PartialSpecialization {
+ template<typename T, typename U, typename V = U>
+ struct X0; // expected-note{{template is declared here}}
+
+ template<typename ...Ts>
+ struct X0<Ts...> {
+ };
+
+ X0<int> x0i; // expected-error{{too few template arguments for class template 'X0'}}
+ X0<int, float> x0if;
+ X0<int, float, double> x0ifd;
+}
+
+namespace FixedAliasTemplate {
+ template<typename,typename,typename> struct S {};
+ template<typename T, typename U> using U = S<T, int, U>;
+ template<typename...Ts> U<Ts...> &f(U<Ts...>, Ts...);
+ S<int, int, double> &s1 = f({}, 0, 0.0);
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp
new file mode 100644
index 0000000..b5786ac
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Check for declaration matching with out-of-line declarations and
+// variadic templates, which involves proper computation of the
+// injected-class-name.
+template<typename T, typename ...Types>
+struct X0 {
+ typedef T type;
+
+ void f0(T);
+ type f1(T);
+};
+
+template<typename T, typename ...Types>
+void X0<T, Types...>::f0(T) { }
+
+template<typename T, typename ...Types>
+typename X0<T, Types...>::type X0<T, Types...>::f1(T) { }
+
+template<typename T, typename ...Types>
+struct X0<T, T, Types...> {
+ typedef T* result;
+ result f3();
+
+ template<typename... InnerTypes>
+ struct Inner;
+};
+
+template<typename T, typename ...Types>
+typename X0<T, T, Types...>::result X0<T, T, Types...>::f3() { return 0; }
+
+template<typename T, typename ...Types>
+template<typename ...InnerTypes>
+struct X0<T, T, Types...>::Inner {
+ template<typename ...ReallyInner> void f4();
+};
+
+template<typename T, typename ...Types>
+template<typename ...InnerTypes>
+template<typename ...ReallyInner>
+void X0<T, T, Types...>::Inner<InnerTypes...>::f4() { }
+
+namespace rdar8848837 {
+ // Out-of-line definitions that cause rebuilding in the current
+ // instantiation.
+ template<typename F> struct X;
+
+ template<typename R, typename ...ArgTypes>
+ struct X<R(ArgTypes...)> {
+ X<R(ArgTypes...)> f();
+ };
+
+ template<typename R, typename ...ArgTypes>
+ X<R(ArgTypes...)> X<R(ArgTypes...)>::f() { return *this; }
+
+
+ X<int(float, double)> xif;
+
+ template<unsigned> struct unsigned_c { };
+ template<typename ...ArgTypes> int g(ArgTypes...);
+
+ template<typename F> struct X1;
+
+ template<typename R, typename ...ArgTypes>
+ struct X1<R(ArgTypes...)> {
+ unsigned_c<sizeof(1 + g(ArgTypes()...))> f();
+ };
+
+ template<typename R, typename ...ArgTypes>
+ unsigned_c<sizeof(1 + g(ArgTypes()...))> X1<R(ArgTypes...)>::f() {
+ return unsigned_c<sizeof(int)>();
+ }
+
+ X1<int(float, double)> xif2;
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp
new file mode 100644
index 0000000..73cbd07
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp
@@ -0,0 +1,274 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// This is a collection of various template metafunctions involving
+// variadic templates, which are meant to exercise common use cases.
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+template<typename...> struct tuple { };
+template<int ...> struct int_tuple { };
+template<typename T, typename U> struct pair { };
+
+namespace Count {
+ template<typename Head, typename ...Tail>
+ struct count {
+ static const unsigned value = 1 + count<Tail...>::value;
+ };
+
+ template<typename T>
+ struct count<T> {
+ static const unsigned value = 1;
+ };
+
+ int check1[count<int>::value == 1? 1 : -1];
+ int check2[count<float, double>::value == 2? 1 : -1];
+ int check3[count<char, signed char, unsigned char>::value == 3? 1 : -1];
+}
+
+namespace CountWithPackExpansion {
+ template<typename ...> struct count;
+
+ template<typename Head, typename ...Tail>
+ struct count<Head, Tail...> {
+ static const unsigned value = 1 + count<Tail...>::value;
+ };
+
+ template<>
+ struct count<> {
+ static const unsigned value = 0;
+ };
+
+ int check0[count<>::value == 0? 1 : -1];
+ int check1[count<int>::value == 1? 1 : -1];
+ int check2[count<float, double>::value == 2? 1 : -1];
+ int check3[count<char, signed char, unsigned char>::value == 3? 1 : -1];
+}
+
+namespace Replace {
+ // Simple metafunction that replaces the template arguments of
+ // template template parameters with 'int'.
+ template<typename T>
+ struct EverythingToInt;
+
+ template<template<typename ...> class TT, typename T1, typename T2>
+ struct EverythingToInt<TT<T1, T2> > {
+ typedef TT<int, int> type;
+ };
+
+ int check0[is_same<EverythingToInt<tuple<double, float>>::type,
+ tuple<int, int>>::value? 1 : -1];
+}
+
+namespace Math {
+ template<int ...Values>
+ struct double_values {
+ typedef int_tuple<Values*2 ...> type;
+ };
+
+ int check0[is_same<double_values<1, 2, -3>::type,
+ int_tuple<2, 4, -6>>::value? 1 : -1];
+
+ template<int ...Values>
+ struct square {
+ typedef int_tuple<(Values*Values)...> type;
+ };
+
+ int check1[is_same<square<1, 2, -3>::type,
+ int_tuple<1, 4, 9>>::value? 1 : -1];
+
+ template<typename IntTuple> struct square_tuple;
+
+ template<int ...Values>
+ struct square_tuple<int_tuple<Values...>> {
+ typedef int_tuple<(Values*Values)...> type;
+ };
+
+ int check2[is_same<square_tuple<int_tuple<1, 2, -3> >::type,
+ int_tuple<1, 4, 9>>::value? 1 : -1];
+
+ template<int ...Values> struct sum;
+
+ template<int First, int ...Rest>
+ struct sum<First, Rest...> {
+ static const int value = First + sum<Rest...>::value;
+ };
+
+ template<>
+ struct sum<> {
+ static const int value = 0;
+ };
+
+ int check3[sum<1, 2, 3, 4, 5>::value == 15? 1 : -1];
+
+ template<int ... Values>
+ struct lazy_sum {
+ int operator()() {
+ return sum<Values...>::value;
+ }
+ };
+
+ void f() {
+ lazy_sum<1, 2, 3, 4, 5>()();
+ }
+}
+
+namespace ListMath {
+ template<typename T, T ... V> struct add;
+
+ template<typename T, T i, T ... V>
+ struct add<T, i, V...> {
+ static const T value = i + add<T, V...>::value;
+ };
+
+ template<typename T>
+ struct add<T> {
+ static const T value = T();
+ };
+
+ template<typename T, T ... V>
+ struct List {
+ struct sum {
+ static const T value = add<T, V...>::value;
+ };
+ };
+
+ template<int ... V>
+ struct ListI : public List<int, V...> {
+ };
+
+ int check0[ListI<1, 2, 3>::sum::value == 6? 1 : -1];
+}
+
+namespace Indices {
+ template<unsigned I, unsigned N, typename IntTuple>
+ struct build_indices_impl;
+
+ template<unsigned I, unsigned N, int ...Indices>
+ struct build_indices_impl<I, N, int_tuple<Indices...> >
+ : build_indices_impl<I+1, N, int_tuple<Indices..., I> > {
+ };
+
+ template<unsigned N, int ...Indices>
+ struct build_indices_impl<N, N, int_tuple<Indices...> > {
+ typedef int_tuple<Indices...> type;
+ };
+
+ template<unsigned N>
+ struct build_indices : build_indices_impl<0, N, int_tuple<> > { };
+
+ int check0[is_same<build_indices<5>::type,
+ int_tuple<0, 1, 2, 3, 4>>::value? 1 : -1];
+}
+
+namespace TemplateTemplateApply {
+ template<typename T, template<class> class ...Meta>
+ struct apply_each {
+ typedef tuple<typename Meta<T>::type...> type;
+ };
+
+ template<typename T>
+ struct add_reference {
+ typedef T& type;
+ };
+
+ template<typename T>
+ struct add_pointer {
+ typedef T* type;
+ };
+
+ template<typename T>
+ struct add_const {
+ typedef const T type;
+ };
+
+ int check0[is_same<apply_each<int,
+ add_reference, add_pointer, add_const>::type,
+ tuple<int&, int*, int const>>::value? 1 : -1];
+
+ template<typename T, template<class> class ...Meta>
+ struct apply_each_indirect {
+ typedef typename apply_each<T, Meta...>::type type;
+ };
+
+ int check1[is_same<apply_each_indirect<int, add_reference, add_pointer,
+ add_const>::type,
+ tuple<int&, int*, int const>>::value? 1 : -1];
+
+ template<typename T, typename ...Meta>
+ struct apply_each_nested {
+ typedef typename apply_each<T, Meta::template apply...>::type type;
+ };
+
+ struct add_reference_meta {
+ template<typename T>
+ struct apply {
+ typedef T& type;
+ };
+ };
+
+ struct add_pointer_meta {
+ template<typename T>
+ struct apply {
+ typedef T* type;
+ };
+ };
+
+ struct add_const_meta {
+ template<typename T>
+ struct apply {
+ typedef const T type;
+ };
+ };
+
+ int check2[is_same<apply_each_nested<int, add_reference_meta,
+ add_pointer_meta, add_const_meta>::type,
+ tuple<int&, int*, int const>>::value? 1 : -1];
+
+}
+
+namespace FunctionTypes {
+ template<typename FunctionType>
+ struct Arity;
+
+ template<typename R, typename ...Types>
+ struct Arity<R(Types...)> {
+ static const unsigned value = sizeof...(Types);
+ };
+
+ template<typename R, typename ...Types>
+ struct Arity<R(Types......)> {
+ static const unsigned value = sizeof...(Types);
+ };
+
+ template<typename R, typename T1, typename T2, typename T3, typename T4>
+ struct Arity<R(T1, T2, T3, T4)>; // expected-note{{template is declared here}}
+
+ int check0[Arity<int()>::value == 0? 1 : -1];
+ int check1[Arity<int(float, double)>::value == 2? 1 : -1];
+ int check2[Arity<int(float...)>::value == 1? 1 : -1];
+ int check3[Arity<int(float, double, long double...)>::value == 3? 1 : -1];
+ Arity<int(float, double, long double, char)> check4; // expected-error{{implicit instantiation of undefined template 'FunctionTypes::Arity<int (float, double, long double, char)>'}}
+}
+
+namespace SuperReplace {
+ template<typename T>
+ struct replace_with_int {
+ typedef int type;
+ };
+
+ template<template<typename ...> class TT, typename ...Types>
+ struct replace_with_int<TT<Types...>> {
+ typedef TT<typename replace_with_int<Types>::type...> type;
+ };
+
+ int check0[is_same<replace_with_int<pair<tuple<float, double, short>,
+ pair<char, unsigned char>>>::type,
+ pair<tuple<int, int, int>, pair<int, int>>>::value? 1 : -1];
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp
new file mode 100644
index 0000000..21aa24f
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp
@@ -0,0 +1,251 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<typename T, T ...Values> struct value_tuple {};
+template<typename...> struct tuple { };
+template<typename T, typename U> struct pair { };
+
+template<typename T, T Value> struct value_c;
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+template<typename T>
+struct X0 {
+ template<T ...Values>
+ void f(value_tuple<T, Values...> * = 0);
+};
+
+void test_X0() {
+ X0<int>().f<1, 2, 3, 4, 5>();
+}
+
+namespace PacksAtDifferentLevels {
+
+ template<typename ...Types>
+ struct X {
+ template<typename> struct Inner {
+ static const unsigned value = 1;
+ };
+
+ template<typename ...YTypes>
+ struct Inner<tuple<pair<Types, YTypes>...> > {
+ static const unsigned value = sizeof...(Types) - sizeof...(YTypes);
+ };
+ };
+
+ int check0[X<short, int, long>::Inner<tuple<pair<short, unsigned short>,
+ pair<int, unsigned int>,
+ pair<long, unsigned long>>
+ >::value == 0? 1 : -1];
+
+ int check1[X<short, int>::Inner<tuple<pair<short, unsigned short>,
+ pair<int, unsigned int>,
+ pair<long, unsigned long>>
+ >::value == 1? 1 : -1];
+
+ template<unsigned ...Values> struct unsigned_tuple { };
+ template<typename ...Types>
+ struct X1 {
+ template<typename, typename> struct Inner {
+ static const unsigned value = 0;
+ };
+
+ template<typename ...YTypes>
+ struct Inner<tuple<pair<Types, YTypes>...>,
+ unsigned_tuple<sizeof(Types) + sizeof(YTypes)...>> {
+ static const unsigned value = 1;
+ };
+ };
+
+ int check2[X1<short, int, long>::Inner<tuple<pair<short, unsigned short>,
+ pair<int, unsigned int>,
+ pair<long, unsigned long>>,
+ unsigned_tuple<sizeof(short) + sizeof(unsigned short),
+ sizeof(int) + sizeof(unsigned int),
+ sizeof(long) + sizeof(unsigned long)>
+ >::value == 1? 1 : -1];
+ int check3[X1<short, int>::Inner<tuple<pair<short, unsigned short>,
+ pair<int, unsigned int>,
+ pair<long, unsigned long>>,
+ unsigned_tuple<sizeof(short) + sizeof(unsigned short),
+ sizeof(int) + sizeof(unsigned int),
+ sizeof(long) + sizeof(unsigned long)>
+ >::value == 0? 1 : -1];
+
+ template<typename ...Types>
+ struct X2 {
+ template<typename> struct Inner {
+ static const unsigned value = 1;
+ };
+
+ template<typename R, typename ...YTypes>
+ struct Inner<R(pair<Types, YTypes>...)> {
+ static const unsigned value = sizeof...(Types) - sizeof...(YTypes);
+ };
+ };
+
+ int check4[X2<short, int, long>::Inner<int(pair<short, unsigned short>,
+ pair<int, unsigned int>,
+ pair<long, unsigned long>)
+ >::value == 0? 1 : -1];
+
+ int check5[X2<short, int>::Inner<int(pair<short, unsigned short>,
+ pair<int, unsigned int>,
+ pair<long, unsigned long>)
+ >::value == 1? 1 : -1];
+
+ template<typename T, typename U>
+ struct some_function_object {
+ template<typename>
+ struct result_of;
+ };
+
+ template<template<class> class...> struct metafun_tuple { };
+
+ template<typename ...Types1>
+ struct X3 {
+ template<typename, typename> struct Inner {
+ static const unsigned value = 0;
+ };
+
+ template<typename ...Types2>
+ struct Inner<tuple<pair<Types1, Types2>...>,
+ metafun_tuple<some_function_object<Types1, Types2>::template result_of...> > {
+ static const unsigned value = 1;
+ };
+ };
+
+ int check6[X3<short, int, long>::Inner<tuple<pair<short, unsigned short>,
+ pair<int, unsigned int>,
+ pair<long, unsigned long>>,
+ metafun_tuple<
+ some_function_object<short, unsigned short>::result_of,
+ some_function_object<int, unsigned int>::result_of,
+ some_function_object<long, unsigned long>::result_of>
+ >::value == 1? 1 : -1];
+ int check7[X3<short, int>::Inner<tuple<pair<short, unsigned short>,
+ pair<int, unsigned int>,
+ pair<long, unsigned long>>,
+ metafun_tuple<
+ some_function_object<short, unsigned short>::result_of,
+ some_function_object<int, unsigned int>::result_of,
+ some_function_object<long, unsigned long>::result_of>
+ >::value == 0? 1 : -1];
+
+ template<unsigned I, unsigned J> struct unsigned_pair { };
+
+ template<unsigned ...Values1>
+ struct X4 {
+ template<typename> struct Inner {
+ static const unsigned value = 0;
+ };
+
+ template<unsigned ...Values2>
+ struct Inner<tuple<unsigned_pair<Values1, Values2>...>> {
+ static const unsigned value = 1;
+ };
+ };
+
+ int check8[X4<1, 3, 5>::Inner<tuple<unsigned_pair<1, 2>,
+ unsigned_pair<3, 4>,
+ unsigned_pair<5, 6>>
+ >::value == 1? 1 : -1];
+ int check9[X4<1, 3>::Inner<tuple<unsigned_pair<1, 2>,
+ unsigned_pair<3, 4>,
+ unsigned_pair<5, 6>>
+ >::value == 0? 1 : -1];
+
+ template<class> struct add_reference;
+ template<class> struct add_pointer;
+ template<class> struct add_const;
+
+ template<template<class> class ...Templates>
+ struct X5 {
+ template<typename> struct Inner {
+ static const unsigned value = 0;
+ };
+
+ template<typename ...Types>
+ struct Inner<tuple<Templates<Types>...>> {
+ static const unsigned value = 1;
+ };
+ };
+
+ int check10[X5<add_reference, add_pointer, add_const>
+ ::Inner<tuple<add_reference<int>,
+ add_pointer<float>,
+ add_const<double>>>::value == 1? 1 : -1];
+ int check11[X5<add_reference, add_pointer>
+ ::Inner<tuple<add_reference<int>,
+ add_pointer<float>,
+ add_const<double>>>::value == 0? 1 : -1];
+
+}
+
+namespace ExpandingNonTypeTemplateParameters {
+ template<typename ...Types>
+ struct tuple_of_values {
+ template<Types ...Values> // expected-error{{a non-type template parameter cannot have type 'float'}} \
+ // expected-note{{template parameter is declared here}}
+ struct apply { // expected-note 2{{template is declared here}}
+ typedef tuple<value_c<Types, Values>...> type;
+ };
+ };
+
+ int i;
+ float f;
+ int check_tuple_of_values_1[
+ is_same<tuple_of_values<int&, float&, char, int>::apply<i, f, 'a', 17>
+ ::type,
+ tuple<value_c<int&, i>, value_c<float&, f>, value_c<char, 'a'>,
+ value_c<int, 17>>
+ >::value? 1 : -1];
+
+ tuple_of_values<int, float> tv1; // expected-note{{in instantiation of template class 'ExpandingNonTypeTemplateParameters::tuple_of_values<int, float>' requested here}}
+
+ tuple_of_values<int&, float&>::apply<i, i>::type tv2; // expected-error{{non-type template parameter of reference type 'float &' cannot bind to template argument of type 'int'}}
+
+ tuple_of_values<int&, float&>::apply<i>::type tv3; // expected-error{{too few template arguments for class template 'apply'}}
+
+ tuple_of_values<int&, float&>::apply<i, f, i>::type tv4; // expected-error{{too many template arguments for class template 'apply'}}
+}
+
+namespace ExpandingFunctionParameters {
+ template<typename ...T>
+ struct X0 {
+ typedef int type;
+ };
+
+ template<typename ...T>
+ struct X1 {
+ template<typename ... U>
+ typename X0<T(T, U...)...>::type f(U...);
+ };
+
+ void test() {
+ X1<float> x1;
+ x1.f(17, 3.14159);
+ }
+}
+
+namespace PR10230 {
+ template<typename>
+ struct s
+ {
+ template<typename... Args>
+ auto f() -> int(&)[sizeof...(Args)];
+ };
+
+ void main()
+ {
+ int (&ir1)[1] = s<int>().f<int>();
+ int (&ir3)[3] = s<int>().f<int, float, double>();
+ }
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/p1.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/p1.cpp
new file mode 100644
index 0000000..daff9d1
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/p1.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<class ...Types> struct Tuple;
+
+Tuple<> *t0;
+Tuple<int> *t1;
+Tuple<int, char> *t2a;
+Tuple<int, float> *t2b = t2a; // expected-error{{cannot initialize a variable of type 'Tuple<int, float> *' with an lvalue of type 'Tuple<int, char> *'}}
+Tuple<int, float, double> *t3;
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/p2.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/p2.cpp
new file mode 100644
index 0000000..ce19582
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/p2.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<class ... Types> void f(Types ... args);
+
+void test() {
+ f();
+ f(1);
+ f(2, 1.0);
+}
+
+// Test simple recursive variadic function template
+template<typename Head, typename ...Tail>
+void recurse_until_fail(const Head &, const Tail &...tail) { // expected-note{{candidate function template not viable: requires at least 1 argument, but 0 were provided}}
+ recurse_until_fail(tail...); // expected-error{{no matching function for call to 'recurse_until_fail'}} \
+ // expected-note{{in instantiation of function template specialization 'recurse_until_fail<char [7], >' requested here}} \
+ // expected-note{{in instantiation of function template specialization 'recurse_until_fail<double, char [7]>' requested here}}
+}
+
+void test_recurse_until_fail() {
+ recurse_until_fail(1, 3.14159, "string"); // expected-note{{in instantiation of function template specialization 'recurse_until_fail<int, double, char [7]>' requested here}}
+
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
new file mode 100644
index 0000000..d8294a1
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
@@ -0,0 +1,193 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fexceptions -fcxx-exceptions -verify %s
+
+template<typename... Types> struct tuple;
+template<int I> struct int_c;
+
+template<typename T>
+struct identity {
+ typedef T type;
+};
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+// FIXME: Several more bullets to go
+
+// In a function parameter pack, the pattern is the parameter-declaration
+// without the ellipsis.
+namespace PR11850 {
+ template<typename ...T> struct S {
+ int f(T...a, int b) { return b; }
+ };
+ S<> s;
+ S<int*, char, const double&> t;
+ int k = s.f(0);
+ int l = t.f(&k, 'x', 5.9, 4);
+
+ template<typename ...As> struct A {
+ template<typename ...Bs> struct B {
+ template<typename ...Cs> struct C {
+ C(As..., Bs..., int &k, Cs...);
+ };
+ };
+ };
+ A<>::B<>::C<> c000(k);
+ A<int>::B<>::C<int> c101(1, k, 3);
+ A<>::B<int>::C<int> c011(1, k, 3);
+ A<int>::B<int>::C<> c110(1, 2, k);
+ A<int, int>::B<int, int>::C<int, int> c222(1, 2, 3, 4, k, 5, 6);
+ A<int, int, int>::B<>::C<> c300(1, 2, 3, k);
+
+ int &f();
+ char &f(void*);
+ template<typename ...A> struct U {
+ template<typename ...B> struct V {
+ auto g(A...a, B...b) -> decltype(f(a...));
+ };
+ };
+ U<>::V<int*> v0;
+ U<int*>::V<> v1;
+ int &v0f = v0.g(0);
+ char &v1f = v1.g(0);
+}
+namespace PR12096 {
+ void Foo(int) {}
+ void Foo(int, int) = delete;
+ template<typename ...Args> struct Var {
+ Var(const Args &...args, int *) { Foo(args...); }
+ };
+ Var<int> var(1, 0);
+}
+
+// In an initializer-list (8.5); the pattern is an initializer-clause.
+// Note: this also covers expression-lists, since expression-list is
+// just defined as initializer-list.
+void five_args(int, int, int, int, int); // expected-note{{candidate function not viable: requires 5 arguments, but 6 were provided}}
+
+template<int ...Values>
+void initializer_list_expansion() {
+ int values[5] = { Values... }; // expected-error{{excess elements in array initializer}}
+ five_args(Values...); // expected-error{{no matching function for call to 'five_args'}}
+}
+
+template void initializer_list_expansion<1, 2, 3, 4, 5>();
+template void initializer_list_expansion<1, 2, 3, 4, 5, 6>(); // expected-note{{in instantiation of function template specialization 'initializer_list_expansion<1, 2, 3, 4, 5, 6>' requested here}}
+
+namespace PR8977 {
+ struct A { };
+ template<typename T, typename... Args> void f(Args... args) {
+ // An empty expression-list performs value initialization.
+ constexpr T t(args...);
+ };
+
+ template void f<A>();
+}
+
+// In a base-specifier-list (Clause 10); the pattern is a base-specifier.
+template<typename ...Mixins>
+struct HasMixins : public Mixins... {
+ HasMixins();
+ HasMixins(const HasMixins&);
+ HasMixins(int i);
+};
+
+struct A { }; // expected-note{{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const A' for 1st argument}} \
+// expected-note{{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'A' for 1st argument}} \
+// expected-note{{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
+struct B { };
+struct C { };
+struct D { };
+
+A *checkA = new HasMixins<A, B, C, D>;
+B *checkB = new HasMixins<A, B, C, D>;
+D *checkD = new HasMixins<A, B, C, D>;
+C *checkC = new HasMixins<A, B, D>; // expected-error{{cannot initialize a variable of type 'C *' with an rvalue of type 'HasMixins<A, B, D> *'}}
+HasMixins<> *checkNone = new HasMixins<>;
+
+template<typename Mixins>
+struct BrokenMixins : public Mixins... { }; // expected-error{{pack expansion does not contain any unexpanded parameter packs}}
+
+// In a mem-initializer-list (12.6.2); the pattern is a mem-initializer.
+template<typename ...Mixins>
+HasMixins<Mixins...>::HasMixins(): Mixins()... { }
+
+template<typename ...Mixins>
+HasMixins<Mixins...>::HasMixins(const HasMixins &other): Mixins(other)... { }
+
+template<typename ...Mixins>
+HasMixins<Mixins...>::HasMixins(int i): Mixins(i)... { } // expected-error{{no matching constructor for initialization of 'A'}}
+
+void test_has_mixins() {
+ HasMixins<A, B> ab;
+ HasMixins<A, B> ab2 = ab;
+ HasMixins<A, B> ab3(17); // expected-note{{in instantiation of member function 'HasMixins<A, B>::HasMixins' requested here}}
+}
+
+template<typename T>
+struct X {
+ T member;
+
+ X() : member()... { } // expected-error{{pack expansion for initialization of member 'member'}}
+};
+
+// There was a bug in the delayed parsing code for the
+// following case.
+template<typename ...T>
+struct DelayedParseTest : T...
+{
+ int a;
+ DelayedParseTest(T... i) : T{i}..., a{10} {}
+};
+
+
+// In a template-argument-list (14.3); the pattern is a template-argument.
+template<typename ...Types>
+struct tuple_of_refs {
+ typedef tuple<Types& ...> types;
+};
+
+tuple<int&, float&> *t_int_ref_float_ref;
+tuple_of_refs<int&, float&>::types *t_int_ref_float_ref_2 = t_int_ref_float_ref;
+
+template<typename ...Types>
+struct extract_nested_types {
+ typedef tuple<typename Types::type...> types;
+};
+
+tuple<int, float> *t_int_float;
+extract_nested_types<identity<int>, identity<float> >::types *t_int_float_2
+ = t_int_float;
+
+template<int ...N>
+struct tuple_of_ints {
+ typedef tuple<int_c<N>...> type;
+};
+
+int check_temp_arg_1[is_same<tuple_of_ints<1, 2, 3, 4, 5>::type,
+ tuple<int_c<1>, int_c<2>, int_c<3>, int_c<4>,
+ int_c<5>>>::value? 1 : -1];
+
+// In a dynamic-exception-specification (15.4); the pattern is a type-id.
+template<typename ...Types>
+struct f_with_except {
+ virtual void f() throw(Types...); // expected-note{{overridden virtual function is here}}
+};
+
+struct check_f_with_except_1 : f_with_except<int, float> {
+ virtual void f() throw(int, float);
+};
+
+struct check_f_with_except_2 : f_with_except<int, float> {
+ virtual void f() throw(int);
+};
+
+struct check_f_with_except_3 : f_with_except<int, float> {
+ virtual void f() throw(int, float, double); // expected-error{{exception specification of overriding function is more lax than base version}}
+};
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
new file mode 100644
index 0000000..726e222
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
@@ -0,0 +1,403 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -fblocks -fms-extensions -fsyntax-only -verify %s
+
+template<typename T, typename U> struct pair;
+template<typename ...> struct tuple;
+
+// A parameter pack whose name appears within the pattern of a pack
+// expansion is expanded by that pack expansion. An appearance of the
+// name of a parameter pack is only expanded by the innermost
+// enclosing pack expansion. The pattern of a pack expansion shall
+// name one or more parameter packs that are not expanded by a nested
+// pack expansion.
+template<typename... Types>
+struct Expansion {
+ typedef pair<Types..., int> expand_with_pacs; // okay
+ typedef pair<Types, int...> expand_no_packs; // expected-error{{pack expansion does not contain any unexpanded parameter packs}}
+ typedef pair<pair<Types..., int>..., int> expand_with_expanded_nested; // expected-error{{pack expansion does not contain any unexpanded parameter packs}}
+};
+
+// All of the parameter packs expanded by a pack expansion shall have
+// the same number of arguments specified.
+template<typename ...Types>
+struct ExpansionLengthMismatch {
+ template<typename ...OtherTypes>
+ struct Inner {
+ typedef tuple<pair<Types, OtherTypes>...> type; // expected-error{{pack expansion contains parameter packs 'Types' and 'OtherTypes' that have different lengths (3 vs. 2)}}
+ };
+};
+
+ExpansionLengthMismatch<int, long>::Inner<unsigned int, unsigned long>::type
+ *il_pairs;
+tuple<pair<int, unsigned int>, pair<long, unsigned long> >*il_pairs_2 = il_pairs;
+
+ExpansionLengthMismatch<short, int, long>::Inner<unsigned int, unsigned long>::type // expected-note{{in instantiation of template class 'ExpansionLengthMismatch<short, int, long>::Inner<unsigned int, unsigned long>' requested here}}
+ *il_pairs_bad;
+
+
+// An appearance of a name of a parameter pack that is not expanded is
+// ill-formed.
+
+// Test for unexpanded parameter packs in each of the type nodes.
+template<typename T, int N, typename ... Types>
+struct TestPPName
+ : public Types, public T // expected-error{{base type contains unexpanded parameter pack 'Types'}}
+{
+ // BuiltinType is uninteresting
+ // FIXME: ComplexType is uninteresting?
+ // PointerType
+ typedef Types *types_pointer; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // BlockPointerType
+ typedef Types (^block_pointer_1)(int); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ typedef int (^block_pointer_2)(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // LValueReferenceType
+ typedef Types &lvalue_ref; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // RValueReferenceType
+ typedef Types &&rvalue_ref; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // MemberPointerType
+ typedef Types TestPPName::* member_pointer_1; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ typedef int Types::*member_pointer_2; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // ConstantArrayType
+ typedef Types constant_array[17]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // IncompleteArrayType
+ typedef Types incomplete_array[]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // VariableArrayType
+ void f(int i) {
+ Types variable_array[i]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ }
+
+ // DependentSizedArrayType
+ typedef Types dependent_sized_array[N]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // DependentSizedExtVectorType
+ typedef Types dependent_sized_ext_vector __attribute__((ext_vector_type(N))); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // VectorType is uninteresting
+
+ // ExtVectorType
+ typedef Types ext_vector __attribute__((ext_vector_type(4))); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // FunctionProtoType
+ typedef Types (function_type_1)(int); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ typedef int (function_type_2)(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // FunctionNoProtoType is uninteresting
+ // UnresolvedUsingType is uninteresting
+ // ParenType is uninteresting
+ // TypedefType is uninteresting
+
+ // TypeOfExprType
+ typedef __typeof__((static_cast<Types>(0))) typeof_expr; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // TypeOfType
+ typedef __typeof__(Types) typeof_type; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // DecltypeType
+ typedef decltype((static_cast<Types>(0))) typeof_expr; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // RecordType is uninteresting
+ // EnumType is uninteresting
+ // ElaboratedType is uninteresting
+
+ // TemplateTypeParmType
+ typedef Types template_type_parm; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // SubstTemplateTypeParmType is uninteresting
+
+ // TemplateSpecializationType
+ typedef pair<Types, int> template_specialization; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // InjectedClassName is uninteresting.
+
+ // DependentNameType
+ typedef typename Types::type dependent_name; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // DependentTemplateSpecializationType
+ typedef typename Types::template apply<int> dependent_name_1; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ typedef typename T::template apply<Types> dependent_name_2; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+
+ // ObjCObjectType is uninteresting
+ // ObjCInterfaceType is uninteresting
+ // ObjCObjectPointerType is uninteresting
+};
+
+// FIXME: Test for unexpanded parameter packs in each of the expression nodes.
+template<int ...Values>
+void test_unexpanded_in_exprs() {
+ // PredefinedExpr is uninteresting
+ // DeclRefExpr
+ Values; // expected-error{{expression contains unexpanded parameter pack 'Values'}}
+ // IntegerLiteral is uninteresting
+ // FloatingLiteral is uninteresting
+ // ImaginaryLiteral is uninteresting
+ // StringLiteral is uninteresting
+ // CharacterLiteral is uninteresting
+ (Values); // expected-error{{expression contains unexpanded parameter pack 'Values'}}
+ // UnaryOperator
+ -Values; // expected-error{{expression contains unexpanded parameter pack 'Values'}}
+ // OffsetOfExpr
+ struct OffsetMe {
+ int array[17];
+ };
+ __builtin_offsetof(OffsetMe, array[Values]); // expected-error{{expression contains unexpanded parameter pack 'Values'}}
+ // FIXME: continue this...
+}
+
+template<typename ... Types>
+void TestPPNameFunc(int i) {
+ f(static_cast<Types>(i)); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+}
+
+template<typename T, template<class> class ...Meta>
+struct TestUnexpandedTTP {
+ typedef tuple<typename Meta<T>::type> type; // expected-error{{declaration type contains unexpanded parameter pack 'Meta'}}
+};
+
+// Test for unexpanded parameter packs in declarations.
+template<typename T, typename... Types>
+// FIXME: this should test that the diagnostic reads "type contains..."
+struct alignas(Types) TestUnexpandedDecls : T{ // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+ void member_function(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ void member_function () throw(Types); // expected-error{{exception type contains unexpanded parameter pack 'Types'}}
+ operator Types() const; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ Types data_member; // expected-error{{data member type contains unexpanded parameter pack 'Types'}}
+ static Types static_data_member; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ unsigned bit_field : static_cast<Types>(0); // expected-error{{bit-field size contains unexpanded parameter pack 'Types'}}
+ static_assert(static_cast<Types>(0), "Boom"); // expected-error{{static assertion contains unexpanded parameter pack 'Types'}}
+
+ enum E0 : Types { // expected-error{{fixed underlying type contains unexpanded parameter pack 'Types'}}
+ EnumValue = static_cast<Types>(0) // expected-error{{enumerator value contains unexpanded parameter pack 'Types'}}
+ };
+
+ using typename Types::type; // expected-error{{using declaration contains unexpanded parameter pack 'Types'}}
+ using Types::value; // expected-error{{using declaration contains unexpanded parameter pack 'Types'}}
+ using T::operator Types; // expected-error{{using declaration contains unexpanded parameter pack 'Types'}}
+
+ friend class Types::foo; // expected-error{{friend declaration contains unexpanded parameter pack 'Types'}}
+ friend void friend_func(Types); // expected-error{{friend declaration contains unexpanded parameter pack 'Types'}}
+ friend void Types::other_friend_func(int); // expected-error{{friend declaration contains unexpanded parameter pack 'Types'}}
+
+ void test_initializers() {
+ T copy_init = static_cast<Types>(0); // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
+ T direct_init(0, static_cast<Types>(0)); // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
+ T list_init = { static_cast<Types>(0) }; // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
+ }
+
+ T in_class_member_init = static_cast<Types>(0); // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
+ TestUnexpandedDecls() :
+ Types(static_cast<Types>(0)), // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
+ Types(static_cast<Types>(0))...,
+ in_class_member_init(static_cast<Types>(0)) {} // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
+
+ void default_function_args(T = static_cast<Types>(0)); // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
+
+ template<typename = Types*> // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
+ struct default_template_args_1;
+ template<int = static_cast<Types>(0)> // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
+ struct default_template_args_2;
+ template<template<typename> class = Types::template apply> // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
+ struct default_template_args_3;
+
+ template<Types value> // expected-error{{non-type template parameter type contains unexpanded parameter pack 'Types'}}
+ struct non_type_template_param_type;
+
+ void decls_in_stmts() {
+ Types t; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ for (Types *t = 0; ; ) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ for (; Types *t = 0; ) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ T a[] = { T(), T(), T() };
+ for (Types t : a) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ switch(Types *t = 0) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ while(Types *t = 0) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ if (Types *t = 0) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
+ try {
+ } catch (Types*) { // expected-error{{exception type contains unexpanded parameter pack 'Types'}}
+ }
+ }
+};
+
+// FIXME: Test for unexpanded parameter packs in each of the statements.
+struct X {
+ void f(int, int);
+ template<typename ...Types>
+ void f(Types...);
+};
+
+namespace std {
+ class type_info;
+}
+
+typedef struct _GUID {
+ unsigned long Data1;
+ unsigned short Data2;
+ unsigned short Data3;
+ unsigned char Data4[ 8 ];
+} GUID;
+
+template<typename T, typename ...Types>
+void test_unexpanded_exprs(Types ...values) {
+ // CXXOperatorCallExpr
+ (void)(values + 0); // expected-error{{expression contains unexpanded parameter pack 'values'}}
+ (void)(0 + values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
+
+ // CXXMemberCallExpr
+ values.f(); // expected-error{{expression contains unexpanded parameter pack 'values'}}
+ X x;
+ x.f(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
+ x.Types::f(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+ x.f<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+
+ // CXXStaticCastExpr
+ (void)static_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}}
+
+ // CXXDynamicCastExpr
+ (void)dynamic_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}}
+
+ // CXXReinterpretCastExpr
+ (void)reinterpret_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}}
+
+ // CXXConstCastExpr
+ (void)const_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}}
+
+ // CXXTypeidExpr
+ (void)typeid(Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+ (void)typeid(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
+
+ // CXXUuidofExpr
+ (void)__uuidof(Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+ (void)__uuidof(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
+
+ // CXXThisExpr is uninteresting
+
+ // CXXThrowExpr
+ throw Types(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+ throw values; // expected-error{{expression contains unexpanded parameter pack 'values'}}
+
+ // CXXDefaultArgExpr is uninteresting
+
+ // CXXBindTemporaryExpr is uninteresting
+
+ // CXXConstructExpr is uninteresting
+
+ // CXXFunctionalCastExpr
+ (void)Types(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+
+ // CXXTemporaryObjectExpr
+ (void)X(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
+
+ // CXXScalarValueInitExpr is uninteresting
+
+ // CXXNewExpr
+ (void)new Types; // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+ (void)new X(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
+ (void)new (values) X(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
+ (void)new X [values]; // expected-error{{expression contains unexpanded parameter pack 'values'}}
+
+ // CXXDeleteExpr
+ delete values; // expected-error{{expression contains unexpanded parameter pack 'values'}}
+ delete [] values; // expected-error{{expression contains unexpanded parameter pack 'values'}}
+
+ // CXXPseudoDestructorExpr
+ T t;
+ values.~T(); // expected-error{{expression contains unexpanded parameter pack 'values'}}
+ t.~Types(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+ t.Types::~T(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+
+ // UnaryTypeTraitExpr
+ __is_pod(Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+
+ // BinaryTypeTraitExpr
+ __is_base_of(Types, T); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+ __is_base_of(T, Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+
+ // UnresolvedLookupExpr
+ test_unexpanded_exprs(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
+ test_unexpanded_exprs<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+
+ // DependentScopeDeclRefExpr
+ Types::test_unexpanded_exprs(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+ T::template test_unexpanded_exprs<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+
+ // CXXUnresolvedConstructExpr
+ Types(5); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+
+ // CXXDependentScopeMemberExpr
+ values.foo(); // expected-error{{expression contains unexpanded parameter pack 'values'}}
+ t.foo(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
+
+ // FIXME: There's an evil ambiguity here, because we don't know if
+ // Types refers to the template type parameter pack in scope or a
+ // non-pack member.
+ // t.Types::foo();
+
+ t.template foo<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+
+ // UnresolvedMemberExpr
+ x.f<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+ x.f(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
+
+ // CXXNoexceptExpr
+ noexcept(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
+
+ // PackExpansionExpr is uninteresting
+ // SizeOfPackExpr is uninteresting
+
+ // FIXME: Objective-C expressions will need to go elsewhere
+
+ for (auto t : values) { } // expected-error{{expression contains unexpanded parameter pack 'values'}}
+}
+
+// Test unexpanded parameter packs in partial specializations.
+template<typename ...Types>
+struct TestUnexpandedDecls<int, Types>; // expected-error{{partial specialization contains unexpanded parameter pack 'Types'}}
+
+// Test for diagnostics in the presence of multiple unexpanded
+// parameter packs.
+template<typename T, typename U> struct pair;
+
+template<typename ...OuterTypes>
+struct MemberTemplatePPNames {
+ template<typename ...InnerTypes>
+ struct Inner {
+ typedef pair<OuterTypes, InnerTypes>* types; // expected-error{{declaration type contains unexpanded parameter packs 'OuterTypes' and 'InnerTypes'}}
+
+ template<typename ...VeryInnerTypes>
+ struct VeryInner {
+ typedef pair<pair<VeryInnerTypes, OuterTypes>, pair<InnerTypes, OuterTypes> > types; // expected-error{{declaration type contains unexpanded parameter packs 'VeryInnerTypes', 'OuterTypes', ...}}
+ };
+ };
+};
+
+// Example from working paper
+namespace WorkingPaperExample {
+ template<typename...> struct Tuple {};
+ template<typename T1, typename T2> struct Pair {};
+
+ template<class ... Args1> struct zip {
+ template<class ... Args2> struct with {
+ typedef Tuple<Pair<Args1, Args2> ... > type; // expected-error{{pack expansion contains parameter packs 'Args1' and 'Args2' that have different lengths (1 vs. 2)}}
+ };
+ };
+
+ typedef zip<short, int>::with<unsigned short, unsigned>::type T1; // T1 is Tuple<Pair<short, unsigned short>, Pair<int, unsigned>>
+ typedef Tuple<Pair<short, unsigned short>, Pair<int, unsigned>> T1;
+
+ typedef zip<short>::with<unsigned short, unsigned>::type T2; // expected-note{{in instantiation of template class}}
+
+ template<class ... Args> void f(Args...);
+ template<class ... Args> void h(Args...);
+
+ template<class ... Args>
+ void g(Args ... args) {
+ f(const_cast<const Args*>(&args)...); // OK: "Args" and "args" are expanded within f
+ f(5 ...); // expected-error{{pack expansion does not contain any unexpanded parameter packs}}
+ f(args); // expected-error{{expression contains unexpanded parameter pack 'args'}}
+ f(h(args ...) + args ...);
+ }
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp
new file mode 100644
index 0000000..79340c3
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Check for template type parameter pack (mis-)matches with template
+// type parameters.
+template<typename ...T> struct X0t;
+template<typename ...T> struct X0t;
+
+template<typename ...T> struct X1t; // expected-note{{previous template type parameter pack declared here}}
+template<typename T> struct X1t; // expected-error{{template type parameter conflicts with previous template type parameter pack}}
+
+template<typename T> struct X2t; // expected-note{{previous template type parameter declared here}}
+template<typename ...T> struct X2t; // expected-error{{template type parameter pack conflicts with previous template type parameter}}
+
+template<template<typename ...T> class> struct X0t_intt;
+template<template<typename ...T> class> struct X0t_intt;
+
+template<template<typename ...T> class> struct X1t_intt; // expected-note{{previous template type parameter pack declared here}}
+template<template<typename T> class> struct X1t_intt; // expected-error{{template type parameter conflicts with previous template type parameter pack}}
+
+template<template<typename T> class> struct X2t_intt; // expected-note{{previous template type parameter declared here}}
+template<template<typename ...T> class> struct X2t_intt; // expected-error{{template type parameter pack conflicts with previous template type parameter}}
+
+template<int ...Values> struct X1nt; // expected-note{{previous non-type template parameter pack declared here}}
+template<int Values> struct X1nt; // expected-error{{non-type template parameter conflicts with previous non-type template parameter pack}}
+
+template<template<class T> class> class X1tt; // expected-note{{previous template template parameter declared here}}
+template<template<class T> class...> class X1tt; // expected-error{{template template parameter pack conflicts with previous template template parameter}}
+
+// Check for matching with out-of-line definitions
+namespace rdar8859985 {
+ template<typename ...> struct tuple { };
+ template<int ...> struct int_tuple { };
+
+ template<typename T>
+ struct X {
+ template<typename ...Args1, int ...Indices1>
+ X(tuple<Args1...>, int_tuple<Indices1...>);
+ };
+
+ template<typename T>
+ template<typename ...Args1, int ...Indices1>
+ X<T>::X(tuple<Args1...>, int_tuple<Indices1...>) {}
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.variadic/partial-ordering.cpp b/clang/test/CXX/temp/temp.decls/temp.variadic/partial-ordering.cpp
new file mode 100644
index 0000000..71bd6aa
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.variadic/partial-ordering.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Various tests related to partial ordering of variadic templates.
+template<typename ...Types> struct tuple;
+
+template<typename Tuple>
+struct X1 {
+ static const unsigned value = 0;
+};
+
+template<typename Head, typename ...Tail>
+struct X1<tuple<Head, Tail...> > {
+ static const unsigned value = 1;
+};
+
+template<typename Head, typename ...Tail>
+struct X1<tuple<Head, Tail&...> > {
+ static const unsigned value = 2;
+};
+
+template<typename Head, typename ...Tail>
+struct X1<tuple<Head&, Tail&...> > {
+ static const unsigned value = 3;
+};
+
+int check0[X1<tuple<>>::value == 0? 1 : -1];
+int check1[X1<tuple<int>>::value == 2? 1 : -1];
+int check2[X1<tuple<int, int>>::value == 1? 1 : -1];
+int check3[X1<tuple<int, int&>>::value == 2? 1 : -1];
+int check4[X1<tuple<int&, int&>>::value == 3? 1 : -1];
+
+// Partial ordering of function templates.
+template<typename T1, typename T2, typename ...Rest>
+int &f0(T1, T2, Rest...);
+
+template<typename T1, typename T2>
+float &f0(T1, T2);
+
+void test_f0() {
+ int &ir1 = f0(1, 2.0, 'a');
+ float &fr1 = f0(1, 2.0);
+}
+
+template<typename T1, typename T2, typename ...Rest>
+int &f1(T1, T2, Rest...);
+
+template<typename T1, typename T2>
+float &f1(T1, T2, ...);
+
+void test_f1() {
+ int &ir1 = f1(1, 2.0, 'a');
+}
+
+template<typename T1, typename T2, typename ...Rest>
+int &f2(T1, T2, Rest...);
+
+float &f2(...);
+
+void test_f2() {
+ int &ir1 = f2(1, 2.0, 'a');
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p1.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p1.cpp
new file mode 100644
index 0000000..0aef6ad
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p1.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+template<typename T> struct A { };
+
+template<typename T> T make();
+template<typename T> T make2(const T&);
+
+void test_make() {
+ int& ir0 = make<int&>();
+ A<int> a0 = make< A<int> >();
+ A<int> a1 = make2< A<int> >(A<int>());
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp
new file mode 100644
index 0000000..4d29b74
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+namespace ParameterPacksWithFunctions {
+ template<typename ...> struct count;
+
+ template<typename Head, typename ...Tail>
+ struct count<Head, Tail...> {
+ static const unsigned value = 1 + count<Tail...>::value;
+ };
+
+ template<>
+ struct count<> {
+ static const unsigned value = 0;
+ };
+
+ template<unsigned> struct unsigned_c { };
+
+ template<typename ... Types>
+ unsigned_c<count<Types...>::value> f();
+
+ void test_f() {
+ unsigned_c<0> uc0a = f(); // okay, deduced to an empty pack
+ unsigned_c<0> uc0b = f<>();
+ unsigned_c<1> uc1 = f<int>();
+ unsigned_c<2> uc2 = f<float, double>();
+ }
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-nodeduct.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-nodeduct.cpp
new file mode 100644
index 0000000..de3b44f
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-nodeduct.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR5811
+template <class F> void Call(F f) { f(1); }
+template <typename T> void f(T);
+void a() { Call(f<int>); }
+
+// Check the conversion of a template-id to a pointer
+template<typename T, T* Address> struct Constant { };
+Constant<void(int), &f<int> > constant0;
+
+template<typename T, T* Address> void constant_func();
+void test_constant_func() {
+ constant_func<void(int), &f<int> >();
+}
+
+
+// Check typeof() on a template-id referring to a single function
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+int typeof0[is_same<__typeof__(f<int>), void (int)>::value? 1 : -1];
+int typeof1[is_same<__typeof__(&f<int>), void (*)(int)>::value? 1 : -1];
+
+template <typename T> void g(T); // expected-note{{possible target for call}}
+template <typename T> void g(T, T); // expected-note{{possible target for call}}
+
+int typeof2[is_same<__typeof__(g<float>), void (int)>::value? 1 : -1]; // \
+ // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp
new file mode 100644
index 0000000..5556f35
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<class X, class Y, class Z> X f(Y,Z); // expected-note {{candidate template ignored: couldn't infer template argument 'X'}}
+
+void g() {
+ f<int,char*,double>("aa",3.0); // expected-warning{{conversion from string literal to 'char *' is deprecated}}
+ f<int,char*>("aa",3.0); // Z is deduced to be double \
+ // expected-warning{{conversion from string literal to 'char *' is deprecated}}
+ f<int>("aa",3.0); // Y is deduced to be char*, and
+ // Z is deduced to be double
+ f("aa",3.0); // expected-error{{no matching}}
+}
+
+// PR5910
+namespace PR5910 {
+ template <typename T>
+ void Func() {}
+
+ template <typename R>
+ void Foo(R (*fp)());
+
+ void Test() {
+ Foo(Func<int>);
+ }
+}
+
+// PR5949
+namespace PR5949 {
+ struct Bar;
+
+ template <class Container>
+ void quuz(const Container &cont) {
+ }
+
+ template<typename T>
+ int Foo(Bar *b, void (*Baz)(const T &t), T * = 0) {
+ return 0;
+ }
+
+ template<typename T>
+ int Quux(Bar *b, T * = 0)
+ {
+ return Foo<T>(b, quuz);
+ }
+}
+
+// PR7641
+namespace PR7641 {
+ namespace N2
+ {
+ template<class>
+ int f0(int);
+ }
+ namespace N
+ {
+ using N2::f0;
+ }
+
+ template<class R,class B1>
+ int
+ f1(R(a)(B1));
+
+ void f2()
+ { f1(N::f0<int>); }
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp
new file mode 100644
index 0000000..81addfe
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Metafunction to extract the Nth type from a set of types.
+template<unsigned N, typename ...Types> struct get_nth_type;
+
+template<unsigned N, typename Head, typename ...Tail>
+struct get_nth_type<N, Head, Tail...> : get_nth_type<N-1, Tail...> { };
+
+template<typename Head, typename ...Tail>
+struct get_nth_type<0, Head, Tail...> {
+ typedef Head type;
+};
+
+// Placeholder type when get_nth_type fails.
+struct no_type {};
+
+template<unsigned N>
+struct get_nth_type<N> {
+ typedef no_type type;
+};
+
+template<typename ...Args>
+typename get_nth_type<0, Args...>::type first_arg(Args...);
+
+template<typename ...Args>
+typename get_nth_type<1, Args...>::type second_arg(Args...);
+
+// Test explicit specification of function template arguments.
+void test_explicit_spec_simple() {
+ int *ip1 = first_arg<int *>(0);
+ int *ip2 = first_arg<int *, float*>(0, 0);
+ float *fp1 = first_arg<float *, double*, int*>(0, 0, 0);
+}
+
+// Template argument deduction can extend the sequence of template
+// arguments corresponding to a template parameter pack, even when the
+// sequence contains explicitly specified template arguments.
+void test_explicit_spec_extension(double *dp) {
+ int *ip1 = first_arg<int *>(0, 0);
+ int *ip2 = first_arg<int *, float*>(0, 0, 0, 0);
+ float *fp1 = first_arg<float *, double*, int*>(0, 0, 0);
+ int *i1 = second_arg<float *>(0, (int*)0, 0);
+ double *dp1 = first_arg<>(dp);
+}
+
+template<typename ...Types>
+struct tuple { };
+
+template<typename ...Types>
+void accept_tuple(tuple<Types...>);
+
+void test_explicit_spec_extension_targs(tuple<int, float, double> t3) {
+ accept_tuple(t3);
+ accept_tuple<int, float, double>(t3);
+ accept_tuple<int>(t3);
+ accept_tuple<int, float>(t3);
+}
+
+template<typename R, typename ...ParmTypes>
+void accept_function_ptr(R(*)(ParmTypes...));
+
+void test_explicit_spec_extension_funcparms(int (*f3)(int, float, double)) {
+ accept_function_ptr(f3);
+ accept_function_ptr<int>(f3);
+ accept_function_ptr<int, int>(f3);
+ accept_function_ptr<int, int, float>(f3);
+ accept_function_ptr<int, int, float, double>(f3);
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/cwg1170.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/cwg1170.cpp
new file mode 100644
index 0000000..c14b063
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/cwg1170.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+#if !__has_feature(cxx_access_control_sfinae)
+# error No support for access control as part of SFINAE?
+#endif
+
+typedef char yes_type;
+typedef char (&no_type)[2];
+
+template<unsigned N> struct unsigned_c { };
+
+template<typename T>
+class has_copy_constructor {
+ static T t;
+
+ template<typename U> static yes_type check(unsigned_c<sizeof(U(t))> * = 0);
+ template<typename U> static no_type check(...);
+
+public:
+ static const bool value = (sizeof(check<T>(0)) == sizeof(yes_type));
+};
+
+struct HasCopy { };
+
+struct HasNonConstCopy {
+ HasNonConstCopy(HasNonConstCopy&);
+};
+
+struct HasDeletedCopy {
+ HasDeletedCopy(const HasDeletedCopy&) = delete;
+};
+
+struct HasPrivateCopy {
+private:
+ HasPrivateCopy(const HasPrivateCopy&);
+};
+
+int check0[has_copy_constructor<HasCopy>::value? 1 : -1];
+int check1[has_copy_constructor<HasNonConstCopy>::value? 1 : -1];
+int check2[has_copy_constructor<HasDeletedCopy>::value? -1 : 1];
+int check3[has_copy_constructor<HasPrivateCopy>::value? -1 : 1];
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp
new file mode 100644
index 0000000..c27261c
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template <int> int f(int); // expected-note 2{{candidate}}
+template <signed char> int f(int); // expected-note 2{{candidate}}
+int i1 = f<1>(0); // expected-error{{ambiguous}}
+int i2 = f<1000>(0); // expected-error{{ambiguous}}
+
+namespace PR6707 {
+ template<typename T, T Value>
+ struct X { };
+
+ template<typename T, T Value>
+ void f(X<T, Value>);
+
+ void g(X<int, 10> x) {
+ f(x);
+ }
+
+ static const unsigned char ten = 10;
+ template<typename T, T Value, typename U>
+ void f2(X<T, Value>, X<U, Value>);
+
+ void g2() {
+ f2(X<int, 10>(), X<char, ten>());
+ }
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp
new file mode 100644
index 0000000..6481485
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -verify %s
+
+typedef char one_byte;
+struct two_bytes { char data[2]; };
+
+template<typename T> one_byte __is_class_check(int T::*);
+template<typename T> two_bytes __is_class_check(...);
+
+template<typename T> struct is_class {
+ static const bool value = sizeof(__is_class_check<T>(0)) == 1;
+};
+
+struct X { };
+
+int array0[is_class<X>::value? 1 : -1];
+int array1[is_class<int>::value? -1 : 1];
+int array2[is_class<char[3]>::value? -1 : 1];
+
+namespace instantiation_order1 {
+ template<typename T>
+ struct it_is_a_trap {
+ typedef typename T::trap type;
+ };
+
+ template<bool, typename T = void>
+ struct enable_if {
+ typedef T type;
+ };
+
+ template<typename T>
+ struct enable_if<false, T> { };
+
+ template<typename T>
+ typename enable_if<sizeof(T) == 17>::type
+ f(const T&, typename it_is_a_trap<T>::type* = 0);
+
+ void f(...);
+
+ void test_f() {
+ f('a');
+ }
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp
new file mode 100644
index 0000000..90d2949
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> struct A { };
+
+template<typename T> A<T> f0(T*);
+
+void test_f0(int *ip, float const *cfp) {
+ A<int> a0 = f0(ip);
+ A<const float> a1 = f0(cfp);
+}
+
+template<typename T> void f1(T*, int);
+
+void test_f1(int *ip, float fv) {
+ f1(ip, fv);
+}
+
+// TODO: this diagnostic can and should improve
+template<typename T> void f2(T*, T*); // expected-note {{candidate template ignored: failed template argument deduction}} \
+// expected-note{{candidate template ignored: deduced conflicting types for parameter 'T' ('int' vs. 'float')}}
+
+struct ConvToIntPtr {
+ operator int*() const;
+};
+
+void test_f2(int *ip, float *fp) {
+ f2(ip, ConvToIntPtr()); // expected-error{{no matching function}}
+ f2(ip, ip); // okay
+ f2(ip, fp); // expected-error{{no matching function}}
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p1-0x.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p1-0x.cpp
new file mode 100644
index 0000000..8b192fa
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p1-0x.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Metafunction to extract the Nth type from a set of types.
+template<unsigned N, typename ...Types> struct get_nth_type;
+
+template<unsigned N, typename Head, typename ...Tail>
+struct get_nth_type<N, Head, Tail...> : get_nth_type<N-1, Tail...> { };
+
+template<typename Head, typename ...Tail>
+struct get_nth_type<0, Head, Tail...> {
+ typedef Head type;
+};
+
+// Placeholder type when get_nth_type fails.
+struct no_type {};
+
+template<unsigned N>
+struct get_nth_type<N> {
+ typedef no_type type;
+};
+
+template<typename T, typename U> struct pair { };
+template<typename T, typename U> pair<T, U> make_pair(T, U);
+
+// For a function parameter pack that occurs at the end of the
+// parameter-declaration-list, the type A of each remaining argument
+// of the call is compared with the type P of the declarator-id of the
+// function parameter pack.
+template<typename ...Args>
+typename get_nth_type<0, Args...>::type first_arg(Args...);
+
+template<typename ...Args>
+typename get_nth_type<1, Args...>::type second_arg(Args...);
+
+void test_simple_deduction(int *ip, float *fp, double *dp) {
+ int *ip1 = first_arg(ip);
+ int *ip2 = first_arg(ip, fp);
+ int *ip3 = first_arg(ip, fp, dp);
+ no_type nt1 = first_arg();
+}
+
+template<typename ...Args>
+typename get_nth_type<0, Args...>::type first_arg_ref(Args&...);
+
+template<typename ...Args>
+typename get_nth_type<1, Args...>::type second_arg_ref(Args&...);
+
+void test_simple_ref_deduction(int *ip, float *fp, double *dp) {
+ int *ip1 = first_arg_ref(ip);
+ int *ip2 = first_arg_ref(ip, fp);
+ int *ip3 = first_arg_ref(ip, fp, dp);
+ no_type nt1 = first_arg_ref();
+}
+
+
+template<typename ...Args1, typename ...Args2>
+typename get_nth_type<0, Args1...>::type first_arg_pair(pair<Args1, Args2>...); // expected-note{{candidate template ignored: failed template argument deduction}}
+
+template<typename ...Args1, typename ...Args2>
+typename get_nth_type<1, Args1...>::type second_arg_pair(pair<Args1, Args2>...);
+
+void test_pair_deduction(int *ip, float *fp, double *dp) {
+ int *ip1 = first_arg_pair(make_pair(ip, 17));
+ int *ip2 = first_arg_pair(make_pair(ip, 17), make_pair(fp, 17));
+ int *ip3 = first_arg_pair(make_pair(ip, 17), make_pair(fp, 17),
+ make_pair(dp, 17));
+ float *fp1 = second_arg_pair(make_pair(ip, 17), make_pair(fp, 17));
+ float *fp2 = second_arg_pair(make_pair(ip, 17), make_pair(fp, 17),
+ make_pair(dp, 17));
+ no_type nt1 = first_arg_pair();
+ no_type nt2 = second_arg_pair();
+ no_type nt3 = second_arg_pair(make_pair(ip, 17));
+
+
+ first_arg_pair(make_pair(ip, 17), 16); // expected-error{{no matching function for call to 'first_arg_pair'}}
+}
+
+// For a function parameter pack that does not occur at the end of the
+// parameter-declaration-list, the type of the parameter pack is a
+// non-deduced context.
+template<typename ...Types> struct tuple { };
+
+template<typename ...Types>
+void pack_not_at_end(tuple<Types...>, Types... values, int);
+
+void test_pack_not_at_end(tuple<int*, double*> t2) {
+ pack_not_at_end(t2, 0, 0, 0);
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p2.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p2.cpp
new file mode 100644
index 0000000..c165c45
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p2.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T> struct A { };
+
+// bullet 1
+template<typename T> A<T> f0(T* ptr);
+
+void test_f0_bullet1() {
+ int arr0[6];
+ A<int> a0 = f0(arr0);
+ const int arr1[] = { 1, 2, 3, 4, 5 };
+ A<const int> a1 = f0(arr1);
+}
+
+// bullet 2
+int g0(int, int);
+float g1(float);
+
+void test_f0_bullet2() {
+ A<int(int, int)> a0 = f0(g0);
+ A<float(float)> a1 = f0(g1);
+}
+
+// bullet 3
+struct X { };
+const X get_X();
+
+template<typename T> A<T> f1(T);
+
+void test_f1_bullet3() {
+ A<X> a0 = f1(get_X());
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp
new file mode 100644
index 0000000..e470dd0
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+
+// If P is an rvalue reference to a cv-unqualified template parameter
+// and the argument is an lvalue, the type "lvalue reference to A" is
+// used in place of A for type deduction.
+template<typename T> struct X { };
+
+template<typename T> X<T> f0(T&&);
+
+struct Y { };
+
+template<typename T> T prvalue();
+template<typename T> T&& xvalue();
+template<typename T> T& lvalue();
+
+void test_f0() {
+ X<int> xi0 = f0(prvalue<int>());
+ X<int> xi1 = f0(xvalue<int>());
+ X<int&> xi2 = f0(lvalue<int>());
+ X<Y> xy0 = f0(prvalue<Y>());
+ X<Y> xy1 = f0(xvalue<Y>());
+ X<Y&> xy2 = f0(lvalue<Y>());
+}
+
+template<typename T> X<T> f1(const T&&); // expected-note{{candidate function [with T = int] not viable: no known conversion from 'int' to 'const int &&' for 1st argument}} \
+// expected-note{{candidate function [with T = Y] not viable: no known conversion from 'Y' to 'const Y &&' for 1st argument}}
+
+void test_f1() {
+ X<int> xi0 = f1(prvalue<int>());
+ X<int> xi1 = f1(xvalue<int>());
+ f1(lvalue<int>()); // expected-error{{no matching function for call to 'f1'}}
+ X<Y> xy0 = f1(prvalue<Y>());
+ X<Y> xy1 = f1(xvalue<Y>());
+ f1(lvalue<Y>()); // expected-error{{no matching function for call to 'f1'}}
+}
+
+namespace std_example {
+ template <class T> int f(T&&);
+ template <class T> int g(const T&&); // expected-note{{candidate function [with T = int] not viable: no known conversion from 'int' to 'const int &&' for 1st argument}}
+
+ int i;
+ int n1 = f(i);
+ int n2 = f(0);
+ int n3 = g(i); // expected-error{{no matching function for call to 'g'}}
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
new file mode 100644
index 0000000..295f080
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
@@ -0,0 +1,148 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> struct A { };
+
+// Top-level cv-qualifiers of P's type are ignored for type deduction.
+template<typename T> A<T> f0(const T);
+
+void test_f0(int i, const int ci) {
+ A<int> a0 = f0(i);
+ A<int> a1 = f0(ci);
+}
+
+// If P is a reference type, the type referred to by P is used for type
+// deduction.
+template<typename T> A<T> f1(T&);
+
+void test_f1(int i, const int ci, volatile int vi) {
+ A<int> a0 = f1(i);
+ A<const int> a1 = f1(ci);
+ A<volatile int> a2 = f1(vi);
+}
+
+template<typename T, unsigned N> struct B { };
+template<typename T, unsigned N> B<T, N> g0(T (&array)[N]);
+template<typename T, unsigned N> B<T, N> g0b(const T (&array)[N]);
+
+void test_g0() {
+ int array0[5];
+ B<int, 5> b0 = g0(array0);
+ const int array1[] = { 1, 2, 3};
+ B<const int, 3> b1 = g0(array1);
+ B<int, 3> b2 = g0b(array1);
+}
+
+template<typename T> B<T, 0> g1(const A<T>&);
+
+void test_g1(A<float> af) {
+ B<float, 0> b0 = g1(af);
+ B<int, 0> b1 = g1(A<int>());
+}
+
+// - If the original P is a reference type, the deduced A (i.e., the type
+// referred to by the reference) can be more cv-qualified than the
+// transformed A.
+template<typename T> A<T> f2(const T&);
+
+void test_f2(int i, const int ci, volatile int vi) {
+ A<int> a0 = f2(i);
+ A<int> a1 = f2(ci);
+ A<volatile int> a2 = f2(vi);
+}
+
+// PR5913
+template <typename T, int N>
+void Foo(const T (&a)[N]) {
+ T x;
+ x = 0;
+}
+
+const int a[1] = { 0 };
+
+void Test() {
+ Foo(a);
+}
+
+// - The transformed A can be another pointer or pointer to member type that
+// can be converted to the deduced A via a qualification conversion (4.4).
+template<typename T> A<T> f3(T * * const * const);
+
+void test_f3(int ***ip, volatile int ***vip) {
+ A<int> a0 = f3(ip);
+ A<volatile int> a1 = f3(vip);
+}
+
+// Also accept conversions for pointer types which require removing
+// [[noreturn]].
+namespace noreturn_stripping {
+ template <class R>
+ void f(R (*function)());
+
+ void g() __attribute__ ((__noreturn__));
+ void h();
+ void test() {
+ f(g);
+ f(h);
+ }
+}
+
+// - If P is a class, and P has the form template-id, then A can be a
+// derived class of the deduced A. Likewise, if P is a pointer to a class
+// of the form template-id, A can be a pointer to a derived class pointed
+// to by the deduced A.
+template<typename T, int I> struct C { };
+
+struct D : public C<int, 1> { };
+struct E : public D { };
+struct F : A<float> { };
+struct G : A<float>, C<int, 1> { };
+
+template<typename T, int I>
+ C<T, I> *f4a(const C<T, I>&);
+template<typename T, int I>
+ C<T, I> *f4b(C<T, I>);
+template<typename T, int I>
+ C<T, I> *f4c(C<T, I>*);
+int *f4c(...);
+
+void test_f4(D d, E e, F f, G g) {
+ C<int, 1> *ci1a = f4a(d);
+ C<int, 1> *ci2a = f4a(e);
+ C<int, 1> *ci1b = f4b(d);
+ C<int, 1> *ci2b = f4b(e);
+ C<int, 1> *ci1c = f4c(&d);
+ C<int, 1> *ci2c = f4c(&e);
+ C<int, 1> *ci3c = f4c(&g);
+ int *ip1 = f4c(&f);
+}
+
+// PR8462
+namespace N {
+ struct T0;
+ struct T1;
+
+ template<typename X, typename Y> struct B {};
+
+ struct J : B<T0,T0> {};
+ struct K : B<T1,T1> {};
+
+ struct D : J, K {};
+
+ template<typename X, typename Y> void F(B<Y,X>);
+
+ void test()
+ {
+ D d;
+ N::F<T0>(d); // Fails
+ N::F<T1>(d); // OK
+ }
+}
+
+namespace PR9233 {
+ template<typename T> void f(const T **q); // expected-note{{candidate template ignored: substitution failure [with T = int]}}
+
+ void g(int **p) {
+ f(p); // expected-error{{no matching function for call to 'f'}}
+ }
+
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp
new file mode 100644
index 0000000..83b5f23
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR8598 {
+ template<class T> struct identity { typedef T type; };
+
+ template<class T, class C>
+ void f(T C::*, typename identity<T>::type*){}
+
+ struct X { void f() {}; };
+
+ void g() { (f)(&X::f, 0); }
+}
+
+namespace PR12132 {
+ template<typename S> void fun(const int* const S::* member) {}
+ struct A { int* x; };
+ void foo() {
+ fun(&A::x);
+ }
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp
new file mode 100644
index 0000000..8b18189
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp
@@ -0,0 +1,128 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace test0 {
+ template<class T> void apply(T x, void (*f)(T)) { f(x); } // expected-note 2 {{candidate template ignored: deduced conflicting types for parameter 'T'}}\
+ // expected-note {{no overload of 'temp2' matching 'void (*)(int)'}}
+
+ template<class A> void temp(A);
+ void test0() {
+ // okay: deduce T=int from first argument, A=int during overload
+ apply(0, &temp);
+ apply(0, &temp<>);
+
+ // okay: deduce T=int from first and second arguments
+ apply(0, &temp<int>);
+
+ // deduction failure: T=int from first, T=long from second
+ apply(0, &temp<long>); // expected-error {{no matching function for call to 'apply'}}
+ }
+
+ void over(int);
+ int over(long);
+
+ void test1() {
+ // okay: deductions match
+ apply(0, &over);
+
+ // deduction failure: deduced T=long from first argument, T=int from second
+ apply(0L, &over); // expected-error {{no matching function for call to 'apply'}}
+ }
+
+ void over(short);
+
+ void test2() {
+ // deduce T=int from first arg, second arg is undeduced context,
+ // pick correct overload of 'over' during overload resolution for 'apply'
+ apply(0, &over);
+ }
+
+ template<class A, class B> B temp2(A);
+ void test3() {
+ // deduce T=int from first arg, A=int B=void during overload resolution
+ apply(0, &temp2);
+ apply(0, &temp2<>);
+ apply(0, &temp2<int>);
+
+ // overload failure
+ apply(0, &temp2<long>); // expected-error {{no matching function for call to 'apply'}}
+ }
+}
+
+namespace test1 {
+ template<class T> void invoke(void (*f)(T)) { f(T()); } // expected-note 6 {{couldn't infer template argument}} \
+ // expected-note {{candidate template ignored: couldn't infer template argument 'T'}}
+
+ template<class T> void temp(T);
+ void test0() {
+ // deduction failure: overload has template => undeduced context
+ invoke(&temp); // expected-error {{no matching function for call to 'invoke'}}
+ invoke(&temp<>); // expected-error {{no matching function for call to 'invoke'}}
+
+ // okay: full template-id
+ invoke(&temp<int>);
+ }
+
+ void over(int);
+ int over(long);
+
+ void test1() {
+ // okay: only one overload matches
+ invoke(&over);
+ }
+
+ void over(short);
+
+ void test2() {
+ // deduction failure: overload has multiple matches => undeduced context
+ invoke(&over); // expected-error {{no matching function for call to 'invoke'}}
+ }
+
+ template<class A, class B> B temp2(A);
+ void test3() {
+ // deduction failure: overload has template => undeduced context
+ // (even though partial application temp2<int> could in theory
+ // let us infer T=int)
+ invoke(&temp2); // expected-error {{no matching function for call to 'invoke'}}
+ invoke(&temp2<>); // expected-error {{no matching function for call to 'invoke'}}
+ invoke(&temp2<int>); // expected-error {{no matching function for call to 'invoke'}}
+
+ // okay: full template-id
+ invoke(&temp2<int, void>);
+
+ // overload failure
+ invoke(&temp2<int, int>); // expected-error {{no matching function for call to 'invoke'}}
+ }
+}
+
+namespace rdar8360106 {
+ template<typename R, typename T> void f0(R (*)(T), T);
+ template<typename R, typename T> void f1(R (&)(T) , T); // expected-note{{candidate template ignored: couldn't infer template argument 'R'}}
+ template<typename R, typename T> void f2(R (* const&)(T), T); // expected-note{{candidate template ignored: couldn't infer template argument 'R'}}
+
+ int g(int);
+ int g(int, int);
+
+ void h() {
+ f0(g, 1);
+ f0(&g, 1);
+ f1(g, 1);
+ f1(&g, 1); // expected-error{{no matching function for call to 'f1'}}
+ f2(g, 1); // expected-error{{no matching function for call to 'f2'}}
+ f2(&g, 1);
+ }
+}
+
+namespace PR11713 {
+ template<typename T>
+ int f(int, int, int);
+
+ template<typename T>
+ float f(float, float);
+
+ template<typename R, typename B1, typename B2, typename A1, typename A2>
+ R& g(R (*)(B1, B2), A1, A2);
+
+ void h() {
+ float &fr = g(f<int>, 1, 2);
+ }
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p2.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p2.cpp
new file mode 100644
index 0000000..5a9ea08
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p2.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// FIXME: [temp.deduct.conv]p2 bullets 1 and 2 can't actually happen without
+// references?
+// struct ConvertibleToArray {
+// // template<typename T, unsigned N>
+// // operator T(()[]) const;
+
+// private:
+// typedef int array[17];
+
+// operator array() const;
+// };
+
+// void test_array(ConvertibleToArray cta) {
+// int *ip = cta;
+// ip = cta;
+// const float *cfp = cta;
+// }
+
+// bullet 2
+// struct ConvertibleToFunction {
+// template<typename T, typename A1, typename A2>
+// operator T(A1, A2) const () { };
+// };
+
+// bullet 3
+struct ConvertibleToCVQuals {
+ template<typename T>
+ operator T* const() const;
+};
+
+void test_cvqual_conv(ConvertibleToCVQuals ctcv) {
+ int *ip = ctcv;
+ const int *icp = ctcv;
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p3.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p3.cpp
new file mode 100644
index 0000000..e23e98a
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p3.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct AnyPtr {
+ template<typename T>
+ operator T*() const;
+};
+
+// If A is a cv-qualified type, the top level cv-qualifiers of A's type
+// are ignored for type deduction.
+void test_cvquals(AnyPtr ap) {
+ int* const ip = ap;
+ const float * const volatile fp = ap;
+}
+
+// If A is a reference type, the type referred to by A is used for
+// type deduction.
+void test_ref_arg(AnyPtr ap) {
+ const int* const &ip = ap;
+ double * const &dp = ap;
+}
+
+struct AnyRef {
+ template<typename T>
+ operator T&() const;
+};
+
+void test_ref_param(AnyRef ar) {
+ int &ir = ar;
+ const float &fr = ar;
+ int i = ar;
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp
new file mode 100644
index 0000000..4dca820
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+struct AnyT {
+ template<typename T>
+ operator T();
+};
+
+void test_cvqual_ref(AnyT any) {
+ const int &cir = any;
+}
+
+struct AnyThreeLevelPtr {
+ template<typename T>
+ operator T***() const
+ {
+ T x = 0;
+ // FIXME: looks like we get this wrong, too!
+ // x = 0; // will fail if T is deduced to a const type
+ // (EDG and GCC get this wrong)
+ return 0;
+ }
+};
+
+struct X { };
+
+void test_deduce_with_qual(AnyThreeLevelPtr a3) {
+ int * const * const * const ip = a3;
+}
+
+struct AnyPtrMem {
+ template<typename Class, typename T>
+ operator T Class::*() const
+ {
+ T x = 0;
+ // FIXME: looks like we get this wrong, too!
+ // x = 0; // will fail if T is deduced to a const type.
+ // (EDG and GCC get this wrong)
+ return 0;
+ }
+};
+
+void test_deduce_ptrmem_with_qual(AnyPtrMem apm) {
+ const float X::* pm = apm;
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.funcaddr/p1.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.funcaddr/p1.cpp
new file mode 100644
index 0000000..99a265a
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.funcaddr/p1.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+template<typename T>
+ T f0(T, int);
+
+void test_f0() {
+ int (*f0a)(int, int) = f0;
+ int (*f0b)(int, int) = &f0;
+ float (*f0c)(float, int) = &f0;
+}
+
+template<typename T> T f1(T, int);
+template<typename T> T f1(T);
+
+void test_f1() {
+ float (*f1a)(float, int) = f1;
+ float (*f1b)(float, int) = &f1;
+ float (*f1c)(float) = f1;
+ float (*f1d)(float) = (f1);
+ float (*f1e)(float) = &f1;
+ float (*f1f)(float) = (&f1);
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p11.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p11.cpp
new file mode 100644
index 0000000..01155e1
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p11.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template <class T> T* f(int); // #1
+template <class T, class U> T& f(U); // #2
+
+void g() {
+ int *ip = f<int>(1); // calls #1
+}
+
+template<typename T>
+struct identity {
+ typedef T type;
+};
+
+template <class T>
+ T* f2(int, typename identity<T>::type = 0);
+template <class T, class U>
+ T& f2(U, typename identity<T>::type = 0);
+
+void g2() {
+ int* ip = f2<int>(1);
+}
+
+template<class T, class U> struct A { };
+
+template<class T, class U> inline int *f3( U, A<U,T>* p = 0 ); // #1 expected-note{{candidate function [with T = int, U = int]}}
+template< class U> inline float *f3( U, A<U,U>* p = 0 ); // #2 expected-note{{candidate function [with U = int]}}
+
+void g3() {
+ float *fp = f3<int>( 42, (A<int,int>*)0 ); // Ok, picks #2.
+ f3<int>( 42 ); // expected-error{{call to 'f3' is ambiguous}}
+
+}
+
+namespace PR9006 {
+ struct X {
+ template <class Get>
+ int &f(char const* name, Get fget, char const* docstr = 0);
+
+ template <class Get, class Set>
+ float &f(char const* name, Get fget, Set fset, char const* docstr = 0);
+ };
+
+ void test(X x) {
+ int &ir = x.f("blah", 0, "blah");
+ }
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp
new file mode 100644
index 0000000..b965300
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Note: Partial ordering of function templates containing template
+// parameter packs is independent of the number of deduced arguments
+// for those template parameter packs.
+template<class ...> struct Tuple { };
+template<class ... Types> int &g(Tuple<Types ...>); // #1
+template<class T1, class ... Types> float &g(Tuple<T1, Types ...>); // #2
+template<class T1, class ... Types> double &g(Tuple<T1, Types& ...>); // #3
+
+void test_g() {
+ int &ir1 = g(Tuple<>());
+ float &fr1 = g(Tuple<int, float>());
+ double &dr1 = g(Tuple<int, float&>());
+ double &dr2 = g(Tuple<int>());
+}
+
+template<class ... Types> int &h(int (*)(Types ...)); // #1
+template<class T1, class ... Types> float &h(int (*)(T1, Types ...)); // #2
+template<class T1, class ... Types> double &h(int (*)(T1, Types& ...)); // #3
+
+void test_h() {
+ int &ir1 = h((int(*)())0);
+ float &fr1 = h((int(*)(int, float))0);
+ double &dr1 = h((int(*)(int, float&))0);
+ double &dr2 = h((int(*)(int))0);
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p9-0x.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p9-0x.cpp
new file mode 100644
index 0000000..f204caf
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p9-0x.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<typename T> int &f0(T&);
+template<typename T> float &f0(T&&);
+
+// Core issue 1164
+void test_f0(int i) {
+ int &ir0 = f0(i);
+ float &fr0 = f0(5);
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p10-0x.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p10-0x.cpp
new file mode 100644
index 0000000..8183061
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p10-0x.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+template<typename T> void f(T&&);
+template<> void f(int&) { }
+void (*fp)(int&) = &f;
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p17.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p17.cpp
new file mode 100644
index 0000000..bf5f962
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p17.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<int i> class A { };
+template<short s> void f(A<s>); // expected-note{{candidate template ignored: substitution failure}}
+
+void k1() {
+ A<1> a;
+ f(a); // expected-error{{no matching function for call}}
+ f<1>(a);
+}
+template<const short cs> class B { };
+template<short s> void g(B<s>);
+void k2() {
+ B<1> b;
+ g(b); // OK: cv-qualifiers are ignored on template parameter types
+}
+
+template<short s> void h(int (&)[s]); // expected-note{{candidate function template not viable: requires 1 argument, but 2 were provided}}
+void k3() {
+ int array[5];
+ h(array);
+ h<5>(array);
+}
+
+template<short s> void h(int (&)[s], A<s>); // expected-note{{candidate template ignored: substitution failure}}
+void k4() {
+ A<5> a;
+ int array[5];
+ h(array, a); // expected-error{{no matching function for call}}
+ h<5>(array, a);
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p2-0x.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p2-0x.cpp
new file mode 100644
index 0000000..5b031c2
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p2-0x.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// If type deduction cannot be done for any P/A pair, or if for any
+// pair the deduction leads to more than one possible set of deduced
+// values, or if different pairs yield different deduced values, or if
+// any template argument remains neither deduced nor explicitly
+// specified, template argument deduction fails.
+
+template<typename ...> struct tuple;
+
+template<typename T, typename U>
+struct same_tuple {
+ static const bool value = false;
+};
+
+template<typename ...Types1>
+struct same_tuple<tuple<Types1...>, tuple<Types1...> > {
+ static const bool value = true;
+};
+
+int same_tuple_check1[same_tuple<tuple<int, float>, tuple<int, double>>::value? -1 : 1];
+int same_tuple_check2[same_tuple<tuple<float, double>, tuple<float, double>>::value? 1 : -1];
+
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp
new file mode 100644
index 0000000..4e98a6d
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Note: Template argument deduction involving parameter packs
+// (14.5.3) can deduce zero or more arguments for each parameter pack.
+
+template<class> struct X {
+ static const unsigned value = 0;
+};
+
+template<class R, class ... ArgTypes> struct X<R(int, ArgTypes ...)> {
+ static const unsigned value = 1;
+};
+
+template<class ... Types> struct Y {
+ static const unsigned value = 0;
+};
+
+template<class T, class ... Types> struct Y<T, Types& ...> {
+ static const unsigned value = 1;
+};
+
+template<class ... Types> int f(void (*)(Types ...));
+void g(int, float);
+
+int check0[X<int>::value == 0? 1 : -1]; // uses primary template
+int check1[X<int(int, float, double)>::value == 1? 1 : -1]; // uses partial specialization
+int check2[X<int(float, int)>::value == 0? 1 : -1]; // uses primary template
+int check3[Y<>::value == 0? 1 : -1]; // uses primary template
+int check4[Y<int&, float&, double&>::value == 1? 1 : -1]; // uses partial specialization
+int check5[Y<int, float, double>::value == 0? 1 : -1]; // uses primary template
+int fv = f(g); // okay
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p22.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p22.cpp
new file mode 100644
index 0000000..fcc6cf7
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p22.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// If the original function parameter associated with A is a function
+// parameter pack and the function parameter associated with P is not
+// a function parameter pack, then template argument deduction fails.
+template<class ... Args> int& f(Args ... args);
+template<class T1, class ... Args> float& f(T1 a1, Args ... args);
+template<class T1, class T2> double& f(T1 a1, T2 a2);
+
+void test_f() {
+ int &ir1 = f();
+ float &fr1 = f(1, 2, 3);
+ double &dr1 = f(1, 2);
+}
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p5-0x.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p5-0x.cpp
new file mode 100644
index 0000000..c819d97
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p5-0x.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// FIXME: More bullets to go!
+
+template<typename T, typename U>
+struct has_nondeduced_pack_test {
+ static const bool value = false;
+};
+
+template<typename R, typename FirstType, typename ...Types>
+struct has_nondeduced_pack_test<R(FirstType, Types..., int),
+ R(FirstType, Types...)> {
+ static const bool value = true;
+};
+
+// - A function parameter pack that does not occur at the end of the
+// parameter-declaration-clause.
+int check_nondeduced_pack_test0[
+ has_nondeduced_pack_test<int(float, double, int),
+ int(float, double)>::value? 1 : -1];
+
+
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p8-0x.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p8-0x.cpp
new file mode 100644
index 0000000..a6b1172
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p8-0x.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// Deductions specific to C++0x.
+
+template<typename T>
+struct member_pointer_kind {
+ static const unsigned value = 0;
+};
+
+template<class C, typename R, typename ...Args>
+struct member_pointer_kind<R (C::*)(Args...)> {
+ static const unsigned value = 1;
+};
+
+template<class C, typename R, typename ...Args>
+struct member_pointer_kind<R (C::*)(Args...) &> {
+ static const unsigned value = 2;
+};
+
+template<class C, typename R, typename ...Args>
+struct member_pointer_kind<R (C::*)(Args...) &&> {
+ static const unsigned value = 3;
+};
+
+template<class C, typename R, typename ...Args>
+struct member_pointer_kind<R (C::*)(Args...) const> {
+ static const unsigned value = 4;
+};
+
+template<class C, typename R, typename ...Args>
+struct member_pointer_kind<R (C::*)(Args...) const &> {
+ static const unsigned value = 5;
+};
+
+template<class C, typename R, typename ...Args>
+struct member_pointer_kind<R (C::*)(Args...) const &&> {
+ static const unsigned value = 6;
+};
+
+struct X { };
+
+static_assert(member_pointer_kind<int (X::*)(int)>::value == 1, "");
+static_assert(member_pointer_kind<int (X::*)(int) &>::value == 2, "");
+static_assert(member_pointer_kind<int (X::*)(int) &&>::value == 3, "");
+static_assert(member_pointer_kind<int (X::*)(int) const>::value == 4, "");
+static_assert(member_pointer_kind<int (X::*)(int) const&>::value == 5, "");
+static_assert(member_pointer_kind<int (X::*)(int) const&&>::value == 6, "");
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp
new file mode 100644
index 0000000..7774b5c
--- /dev/null
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<typename ...Types> struct tuple;
+template<unsigned> struct unsigned_c;
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+namespace PackExpansionNotAtEnd {
+ template<typename T, typename U>
+ struct tuple_same_with_int {
+ static const bool value = false;
+ };
+
+ template<typename ...Types>
+ struct tuple_same_with_int<tuple<Types...>, tuple<Types..., int>> {
+ static const bool value = true;
+ };
+
+ int tuple_same_with_int_1[tuple_same_with_int<tuple<int, float, double>,
+ tuple<int, float, double, int>
+ >::value? 1 : -1];
+
+ template<typename ... Types> struct UselessPartialSpec;
+
+ template<typename ... Types, // expected-note{{non-deducible template parameter 'Types'}}
+ typename Tail> // expected-note{{non-deducible template parameter 'Tail'}}
+ struct UselessPartialSpec<Types..., Tail>; // expected-warning{{class template partial specialization contains template parameters that can not be deduced; this partial specialization will never be used}}
+}
+
+namespace DeduceNonTypeTemplateArgsInArray {
+ template<typename ...ArrayTypes>
+ struct split_arrays;
+
+ template<typename ...ElementTypes, unsigned ...Bounds>
+ struct split_arrays<ElementTypes[Bounds]...> {
+ typedef tuple<ElementTypes...> element_types;
+
+ // FIXME: Would like to have unsigned_tuple<Bounds...> here.
+ typedef tuple<unsigned_c<Bounds>...> bounds_types;
+ };
+
+ int check1[is_same<split_arrays<int[1], float[2], double[3]>::element_types,
+ tuple<int, float, double>>::value? 1 : -1];
+ int check2[is_same<split_arrays<int[1], float[2], double[3]>::bounds_types,
+ tuple<unsigned_c<1>, unsigned_c<2>, unsigned_c<3>>
+ >::value? 1 : -1];
+}
diff --git a/clang/test/CXX/temp/temp.names/p2.cpp b/clang/test/CXX/temp/temp.names/p2.cpp
new file mode 100644
index 0000000..93e45dd
--- /dev/null
+++ b/clang/test/CXX/temp/temp.names/p2.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Ensure that when enforcing access control an unqualified template name with
+// explicit template arguments, we don't lose the context of the name lookup
+// because of the required early lookup to determine if it names a template.
+namespace PR7163 {
+ template <typename R, typename P> void h(R (*func)(P)) {}
+ class C {
+ template <typename T> static void g(T*) {};
+ public:
+ void f() { h(g<int>); }
+ };
+}
diff --git a/clang/test/CXX/temp/temp.names/p4.cpp b/clang/test/CXX/temp/temp.names/p4.cpp
new file mode 100644
index 0000000..103a1bd
--- /dev/null
+++ b/clang/test/CXX/temp/temp.names/p4.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct meta {
+ template<typename U>
+ struct apply {
+ typedef U* type;
+ };
+};
+
+template<typename T, typename U>
+void f(typename T::template apply<U>::type);
+
+void test_f(int *ip) {
+ f<meta, int>(ip);
+}
diff --git a/clang/test/CXX/temp/temp.param/p1.cpp b/clang/test/CXX/temp/temp.param/p1.cpp
new file mode 100644
index 0000000..e9a9789
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p1.cpp
@@ -0,0 +1,12 @@
+// Suppress 'no run line' failure.
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<template<> class C> class D; // expected-error{{template template parameter must have its own template parameters}}
+
+
+struct A {};
+template<class M,
+ class T = A, // expected-note{{previous default template argument defined here}}
+ class C> // expected-error{{template parameter missing a default argument}}
+class X0 {}; // expected-note{{template is declared here}}
+X0<int> x0; // expected-error{{too few template arguments for class template 'X0'}}
diff --git a/clang/test/CXX/temp/temp.param/p10-0x.cpp b/clang/test/CXX/temp/temp.param/p10-0x.cpp
new file mode 100644
index 0000000..37bb284
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p10-0x.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template<typename> struct Y1;
+template<typename, int> struct Y2;
+
+template<class T1, class T2 = int> using B2 = T1;
+template<class T1 = int, class T2> using B2 = T1;
+
+template<template<class> class F, template<class> class G = Y1> using B2t = F<G<int>>;
+template<template<class> class F = Y2, template<class> class G> using B2t = F<G<int>>;
+
+template<int N, int M = 5> using B2n = Y2<int, N + M>;
+template<int N = 5, int M> using B2n = Y2<int, N + M>;
diff --git a/clang/test/CXX/temp/temp.param/p10.cpp b/clang/test/CXX/temp/temp.param/p10.cpp
new file mode 100644
index 0000000..b9dac75
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p10.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename> struct Y1;
+template<typename, int> struct Y2;
+
+template<class T1, class T2 = int> class B2;
+template<class T1 = int, class T2> class B2;
+
+template<template<class, int> class, template<class> class = Y1> class B2t;
+template<template<class, int> class = Y2, template<class> class> class B2t;
+
+template<int N, int M = 5> class B2n;
+template<int N = 5, int M> class B2n;
diff --git a/clang/test/CXX/temp/temp.param/p11-0x.cpp b/clang/test/CXX/temp/temp.param/p11-0x.cpp
new file mode 100644
index 0000000..d2276a3
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p11-0x.cpp
@@ -0,0 +1,81 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// If a template-parameter of a class template or alias template has a default
+// template-argument, each subsequent template-parameter shall either have a
+// default template-argument supplied or be a template parameter pack.
+template<typename> struct vector;
+
+template<typename T = int, typename> struct X3t; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
+template<typename T = int, typename> using A3t = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
+template<int V = 0, int> struct X3nt; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
+template<int V = 0, int> using A3nt = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
+template<template<class> class M = vector, template<class> class> struct X3tt; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
+template<template<class> class M = vector, template<class> class> using A3tt = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
+
+template<typename T = int, typename ...Types> struct X2t;
+template<typename T = int, typename ...Types> using A2t = X2t<T, Types...>;
+template<int V = 0, int ...Values> struct X2nt;
+template<int V = 0, int ...Values> using A2nt = X2nt<V, Values...>;
+template<template<class> class M = vector, template<class> class... Metas>
+ struct X2tt;
+template<template<class> class M = vector, template<class> class... Metas>
+ using A2tt = X2tt<M, Metas...>;
+
+// If a template-parameter of a primary class template or alias template is a
+// template parameter pack, it shall be the last template-parameter.
+template<typename ...Types, // expected-error{{template parameter pack must be the last template parameter}}
+ int After, int After2>
+struct X0t;
+X0t<int> pr9789();
+template<typename ...Types, // expected-error{{template parameter pack must be the last template parameter}}
+ int After>
+using A0t = int;
+
+template<int ...Values, // expected-error{{template parameter pack must be the last template parameter}}
+ int After>
+struct X0nt;
+template<int ...Values, // expected-error{{template parameter pack must be the last template parameter}}
+ int After>
+using A0nt = int;
+
+template<template<typename> class ...Templates, // expected-error{{template parameter pack must be the last template parameter}}
+ int After>
+struct X0tt;
+template<template<typename> class ...Templates, // expected-error{{template parameter pack must be the last template parameter}}
+ int After>
+using A0tt = int;
+
+// [ Note: These are not requirements for function templates or class
+// template partial specializations because template arguments can be
+// deduced (14.8.2). -- end note]
+template<typename... Types> struct X1t;
+template<typename ...Types, typename T> struct X1t<T, Types...> { };
+
+template<int... Values> struct X1nt;
+template<int ...Values, int V> struct X1nt<V, Values...> { };
+
+template<template<int> class... Meta> struct X1tt;
+template<template<int> class... Meta, template<int> class M>
+ struct X1tt<M, Meta...> { };
+
+template<typename ...Types, typename T>
+void f1t(X1t<T, Types...>);
+
+template<int ...Values, int V>
+void f1nt(X1nt<V, Values...>);
+
+template<template<int> class... Meta, template<int> class M>
+void f1tt(X1tt<M, Meta...>);
+
+namespace DefaultTemplateArgsInFunction {
+ template<typename T = int, typename U> T &f0(U) { T *x = 0; return *x; }
+
+ void test_f0() {
+ int &ir0 = f0(3.14159);
+ int &ir1 = f0<int>(3.14159);
+ float &fr0 = f0<float>(3.14159);
+ }
+
+ template<> int &f0(int*);
+ template int &f0(double&);
+}
diff --git a/clang/test/CXX/temp/temp.param/p11.cpp b/clang/test/CXX/temp/temp.param/p11.cpp
new file mode 100644
index 0000000..5af0c4e
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p11.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename> struct Y1;
+template<typename, int> struct Y2;
+
+template<class T1 = int, // expected-note{{previous default template argument defined here}}
+ class T2> // expected-error{{template parameter missing a default argument}}
+ class B1;
+
+template<template<class> class = Y1, // expected-note{{previous default template argument defined here}}
+ template<class> class> // expected-error{{template parameter missing a default argument}}
+ class B1t;
+
+template<int N = 5, // expected-note{{previous default template argument defined here}}
+ int M> // expected-error{{template parameter missing a default argument}}
+ class B1n;
diff --git a/clang/test/CXX/temp/temp.param/p12.cpp b/clang/test/CXX/temp/temp.param/p12.cpp
new file mode 100644
index 0000000..7be3879
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p12.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename> struct Y1; // expected-note{{too few template parameters in template template argument}}
+template<typename, int> struct Y2;
+
+// C++ [temp.param]p12:
+template<class T1,
+ class T2 = int> // expected-note{{previous default template argument defined here}}
+ class B3;
+template<class T1, typename T2> class B3;
+template<class T1,
+ typename T2 = float> // expected-error{{template parameter redefines default argument}}
+ class B3;
+
+template<template<class, int> class,
+ template<class> class = Y1> // expected-note{{previous default template argument defined here}}
+ class B3t;
+
+template<template<class, int> class, template<class> class> class B3t;
+
+template<template<class, int> class,
+ template<class> class = Y1> // expected-error{{template parameter redefines default argument}}
+ class B3t;
+
+template<int N,
+ int M = 5> // expected-note{{previous default template argument defined here}}
+ class B3n;
+
+template<int N, int M> class B3n;
+
+template<int N,
+ int M = 7> // expected-error{{template parameter redefines default argument}}
+ class B3n;
+
+// Check validity of default arguments
+template<template<class, int> class // expected-note{{previous template template parameter is here}}
+ = Y1> // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
+ class C1 {};
+
+C1<> c1; // expected-note{{while checking a default template argument}}
diff --git a/clang/test/CXX/temp/temp.param/p13.cpp b/clang/test/CXX/temp/temp.param/p13.cpp
new file mode 100644
index 0000000..7e7dbe5
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p13.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// The scope of atemplate-parameterextends from its point of
+// declaration until the end of its template. In particular, a
+// template-parameter can be used in the declaration of subsequent
+// template-parameters and their default arguments.
+
+template<class T, T* p, class U = T> class X { /* ... */ };
+// FIXME: template<class T> void f(T* p = new T);
+
+// Check for bogus template parameter shadow warning.
+template<template<class T> class,
+ template<class T> class>
+ class B1noshadow;
diff --git a/clang/test/CXX/temp/temp.param/p14.cpp b/clang/test/CXX/temp/temp.param/p14.cpp
new file mode 100644
index 0000000..a6c53c1
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p14.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// XFAIL: *
+
+// A template-parameter shall not be used in its own default argument.
+template<typename T = typename T::type> struct X; // expected-error{{default}}
diff --git a/clang/test/CXX/temp/temp.param/p15-cxx0x.cpp b/clang/test/CXX/temp/temp.param/p15-cxx0x.cpp
new file mode 100644
index 0000000..5fc57a4
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p15-cxx0x.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+template<typename T> struct X;
+template<int I> struct Y;
+
+X<X<int>> *x1;
+
+Y<(1 >> 2)> *y1;
+Y<1 >> 2> *y2; // FIXME: expected-error{{expected unqualified-id}}
+
+X<X<X<X<X<int>>>>> *x2;
+
+template<> struct X<int> { };
+typedef X<int> X_int;
+struct Z : X_int { };
+
+void f(const X<int> x) {
+ (void)reinterpret_cast<X<int>>(x); // expected-error{{reinterpret_cast from}}
+ (void)reinterpret_cast<X<X<X<int>>>>(x); // expected-error{{reinterpret_cast from}}
+
+ X<X<int>> *x1;
+}
+
+template<typename T = void> struct X1 { };
+X1<X1<>> x1a;
diff --git a/clang/test/CXX/temp/temp.param/p15.cpp b/clang/test/CXX/temp/temp.param/p15.cpp
new file mode 100644
index 0000000..ee572e9
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p15.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s
+template<typename T> struct X;
+template<int I> struct Y;
+
+X<X<int> > *x1;
+X<X<int>> *x2; // expected-error{{a space is required between consecutive right angle brackets (use '> >')}}
+
+X<X<X<X<int>> // expected-error{{a space is required between consecutive right angle brackets (use '> >')}}
+ >> *x3; // expected-error{{a space is required between consecutive right angle brackets (use '> >')}}
+
+Y<(1 >> 2)> *y1;
+Y<1 >> 2> *y2; // expected-warning{{use of right-shift operator ('>>') in template argument will require parentheses in C++11}}
diff --git a/clang/test/CXX/temp/temp.param/p2.cpp b/clang/test/CXX/temp/temp.param/p2.cpp
new file mode 100644
index 0000000..fed6e9c
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p2.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// There is no semantic difference between class and typename in a
+// template-parameter. typename followed by an unqualified-id names a
+// template type parameter.
+template<class T> struct X;
+template<typename T> struct X;
+
+// typename followed by aqualified-id denotes the type in a non-type
+// parameter-declaration.
+template<typename T, typename T::type Value> struct Y0;
+template<typename T, typename X<T>::type Value> struct Y1;
+
+// A storage class shall not be specified in a template-parameter declaration.
+template<static int Value> struct Z; // FIXME: expect an error
+
+// Make sure that we properly disambiguate non-type template parameters that
+// start with 'class'.
+class X1 { };
+template<class X1 *xptr> struct Y2 { };
+
+// FIXME: add the example from p2
diff --git a/clang/test/CXX/temp/temp.param/p3.cpp b/clang/test/CXX/temp/temp.param/p3.cpp
new file mode 100644
index 0000000..dc40c4b
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p3.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// A type-parameter defines its identifier to be a type-name (if
+// declared with class or typename) or template-name (if declared with
+// template) in the scope of the template declaration.
+template<typename T> struct X0 {
+ T* value;
+};
+
+template<template<class T> class Y> struct X1 {
+ Y<int> value;
+};
+
+// [Note: because of the name lookup rules, a template-parameter that
+// could be interpreted as either a non-type template-parameter or a
+// type-parameter (because its identifier is the name of an already
+// existing class) is taken as a type-parameter. For example,
+class T { /* ... */ }; // expected-note{{candidate constructor (the implicit copy constructor) not viable}}
+int i;
+
+template<class T, T i> struct X2 {
+ void f(T t)
+ {
+ T t1 = i; //template-parameters T and i
+ ::T t2 = ::i; // global namespace members T and i \
+ // expected-error{{no viable conversion}}
+ }
+};
+
+namespace PR6831 {
+ namespace NA { struct S; }
+ namespace NB { struct S; }
+
+ using namespace NA;
+ using namespace NB;
+
+ template <typename S> void foo();
+ template <int S> void bar();
+ template <template<typename> class S> void baz();
+}
diff --git a/clang/test/CXX/temp/temp.param/p4.cpp b/clang/test/CXX/temp/temp.param/p4.cpp
new file mode 100644
index 0000000..809fb20
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p4.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class X;
+
+// C++ [temp.param]p4
+typedef int INT;
+enum E { enum1, enum2 };
+template<int N> struct A1;
+template<INT N, INT M> struct A2;
+template<enum E x, E y> struct A3;
+template<int &X> struct A4;
+template<int *Ptr> struct A5;
+template<int (&f)(int, int)> struct A6;
+template<int (*fp)(float, double)> struct A7;
+template<int X::*pm> struct A8;
+template<float (X::*pmf)(float, int)> struct A9;
+template<typename T, T x> struct A10;
+
+template<float f> struct A11; // expected-error{{a non-type template parameter cannot have type 'float'}}
+
+template<void *Ptr> struct A12;
+template<int (*IncompleteArrayPtr)[]> struct A13;
diff --git a/clang/test/CXX/temp/temp.param/p5.cpp b/clang/test/CXX/temp/temp.param/p5.cpp
new file mode 100644
index 0000000..3cbb3b7
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p5.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -verify %s -std=c++11
+
+template<const int I> struct S {
+ decltype(I) n;
+ int &&r = I;
+};
+S<5> s;
+
+template<typename T, T v> struct U {
+ decltype(v) n;
+ int &&r = v;
+};
+U<const int, 6> u;
diff --git a/clang/test/CXX/temp/temp.param/p7.cpp b/clang/test/CXX/temp/temp.param/p7.cpp
new file mode 100644
index 0000000..13f0367
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p7.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// A non-type template-parameter shall not be declared to have
+// floating point, class, or void type.
+struct A;
+
+template<double d> class X; // expected-error{{cannot have type}}
+template<double* pd> class Y; //OK
+template<double& rd> class Z; //OK
+
+template<A a> class X0; // expected-error{{cannot have type}}
+
+typedef void VOID;
+template<VOID a> class X01; // expected-error{{cannot have type}}
+
diff --git a/clang/test/CXX/temp/temp.param/p8.cpp b/clang/test/CXX/temp/temp.param/p8.cpp
new file mode 100644
index 0000000..fed048c
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p8.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<int X[10]> struct A;
+template<int *X> struct A;
+template<int f(float, double)> struct B;
+typedef float FLOAT;
+template<int (*f)(FLOAT, double)> struct B;
diff --git a/clang/test/CXX/temp/temp.param/p9-0x.cpp b/clang/test/CXX/temp/temp.param/p9-0x.cpp
new file mode 100644
index 0000000..29a7549
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p9-0x.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// A default template-argument may be specified for any kind of
+// template-parameter that is not a template parameter pack.
+template<typename ...Types = int> // expected-error{{template parameter pack cannot have a default argument}}
+struct X0;
+
+template<int ...Values = 0> // expected-error{{template parameter pack cannot have a default argument}}
+struct X1;
+
+template<typename T> struct vector;
+
+template<template<class> class ...Templates = vector> // expected-error{{template parameter pack cannot have a default argument}}
+struct X2;
+
+struct X3 {
+ template<typename T = int> // expected-error{{default template argument not permitted on a friend template}}
+ friend void f0(X3);
+
+ template<typename T = int>
+ friend void f1(X3) {
+ }
+};
+
+namespace PR8748 {
+ // Testcase 1
+ struct A0 { template<typename U> struct B; };
+ template<typename U = int> struct A0::B { };
+
+ // Testcase 2
+ template<typename T> struct A1 { template<typename U> struct B; };
+ template<typename T> template<typename U = int> struct A1<T>::B { }; // expected-error{{cannot add a default template argument to the definition of a member of a class template}}
+
+ // Testcase 3
+ template<typename T>
+ struct X2 {
+ void f0();
+ template<typename U> void f1();
+ };
+
+ template<typename T = int> void X2<T>::f0() { } // expected-error{{cannot add a default template argument to the definition of a member of a class template}}
+ template<typename T> template<typename U = int> void X2<T>::f1() { } // expected-error{{cannot add a default template argument to the definition of a member of a class template}}
+
+ namespace Inner {
+ template<typename T> struct X3;
+ template<typename T> void f2();
+ }
+
+ // Okay; not class members.
+ template<typename T = int> struct Inner::X3 { };
+ template<typename T = int> void Inner::f2() {}
+}
+
+namespace PR10069 {
+ template<typename T, T a, T b=0, T c=1>
+ T f(T x);
+
+ void g() {
+ f<unsigned int, 0>(0);
+ }
+}
diff --git a/clang/test/CXX/temp/temp.param/p9.cpp b/clang/test/CXX/temp/temp.param/p9.cpp
new file mode 100644
index 0000000..b2318c2
--- /dev/null
+++ b/clang/test/CXX/temp/temp.param/p9.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s
+
+// A default template-argument shall not be specified in a function
+// template declaration or a function template definition
+template<typename T = int> // expected-warning{{default template arguments for a function template are a C++11 extension}}
+ void foo0(T);
+template<typename T = int> // expected-warning{{default template arguments for a function template are a C++11 extension}}
+ void foo1(T) { }
+
+// [...] nor in the template-parameter-list of the definition of a
+// member of a class template.
+template<int N>
+struct X0 {
+ void f();
+};
+
+template<int N = 0> // expected-error{{cannot add a default template argument}}
+void X0<N>::f() { }
+
+class X1 {
+ template<template<int> class TT = X0> // expected-error{{not permitted on a friend template}}
+ friend void f2();
+};
diff --git a/clang/test/CXX/temp/temp.res/temp.dep.res/temp.point/p1.cpp b/clang/test/CXX/temp/temp.res/temp.dep.res/temp.point/p1.cpp
new file mode 100644
index 0000000..75580d2
--- /dev/null
+++ b/clang/test/CXX/temp/temp.res/temp.dep.res/temp.point/p1.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// XFAIL: *
+
+// Note: we fail this test because we perform template instantiation
+// at the end of the translation unit, so argument-dependent lookup
+// finds functions that occur after the point of instantiation. Note
+// that GCC fails this test; EDG passes the test in strict mode, but
+// not in relaxed mode.
+namespace N {
+ struct A { };
+ struct B : public A { };
+
+ int& f0(A&);
+}
+
+template<typename T, typename Result>
+struct X0 {
+ void test_f0(T t) {
+ Result r = f0(t);
+ };
+};
+
+void test_f0() {
+ X0<N::A, int&> xA;
+ xA.test_f0(N::A());
+ X0<N::B, int&> xB;
+ xB.test_f0(N::B());
+}
+
+namespace N {
+ char& f0(B&);
+}
diff --git a/clang/test/CXX/temp/temp.res/temp.dep/p3.cpp b/clang/test/CXX/temp/temp.res/temp.dep/p3.cpp
new file mode 100644
index 0000000..c41a4c6
--- /dev/null
+++ b/clang/test/CXX/temp/temp.res/temp.dep/p3.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct A0 {
+ struct K { };
+};
+
+template <typename T> struct B0: A0 {
+ static void f() {
+ K k;
+ }
+};
+
+namespace E1 {
+ typedef double A;
+
+ template<class T> class B {
+ typedef int A;
+ };
+
+ template<class T>
+ struct X : B<T> {
+ A* blarg(double *dp) {
+ return dp;
+ }
+ };
+}
+
+namespace E2 {
+ struct A {
+ struct B;
+ int *a;
+ int Y;
+ };
+
+ int a;
+ template<class T> struct Y : T {
+ struct B { /* ... */ };
+ B b;
+ void f(int i) { a = i; }
+ Y* p;
+ };
+
+ Y<A> ya;
+}
diff --git a/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp b/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp
new file mode 100644
index 0000000..0aba402
--- /dev/null
+++ b/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+template<int n> struct S;
+
+template<int n> struct T {
+ T() {
+ // An identifier is value-dependent if it is:
+ // - a name declared with a dependent type
+ S<n> s;
+ S<s> check1; // ok, s is value-dependent
+ // - the name of a non-type template parameter
+ typename S<n>::T check2; // ok, n is value-dependent
+ // - a constant with literal type and is initialized with an expression
+ // that is value-dependent.
+ const int k = n;
+ typename S<k>::T check3a; // ok, u is value-dependent
+
+ constexpr const int *p = &k;
+ typename S<*p>::T check3b; // ok, p is value-dependent
+
+ // (missing from the standard)
+ // - a reference and is initialized with an expression that is
+ // value-dependent.
+ const int &i = k;
+ typename S<i>::T check4; // ok, i is value-dependent
+ }
+};
diff --git a/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp b/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp
new file mode 100644
index 0000000..68a41c7
--- /dev/null
+++ b/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++98 -verify %s
+
+template<int n> struct S;
+
+template<int n> struct T {
+ T() {
+ // An identifier is value-dependent if it is:
+ // - a name declared with a dependent type
+ S<n> s;
+ S<s> check1; // ok, s is value-dependent
+ // - the name of a non-type template parameter
+ typename S<n>::T check2; // ok, n is value-dependent
+ // - a constant with literal type and is initialized with an expression
+ // that is value-dependent.
+ const int k = n;
+ typename S<k>::T check3; // ok, u is value-dependent
+
+ const int &i = k;
+ typename S<i>::T check4; // expected-error {{not an integral constant expression}} expected-error {{qualified name}}
+ }
+};
diff --git a/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp b/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp
new file mode 100644
index 0000000..81b070f
--- /dev/null
+++ b/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// Examples from CWG1056.
+namespace Example1 {
+ template<class T> struct A;
+ template<class T> using B = A<T>;
+
+ template<class T> struct A {
+ struct C {};
+ B<T>::C bc; // ok, B<T> is the current instantiation.
+ };
+
+ template<class T> struct A<A<T>> {
+ struct C {};
+ B<B<T>>::C bc; // ok, B<B<T>> is the current instantiation.
+ };
+
+ template<class T> struct A<A<A<T>>> {
+ struct C {};
+ B<B<T>>::C bc; // expected-error {{missing 'typename'}}
+ };
+}
+
+namespace Example2 {
+ template<class T> struct A {
+ void g();
+ };
+ template<class T> using B = A<T>;
+ template<class T> void B<T>::g() {} // ok.
+}
diff --git a/clang/test/CXX/temp/temp.res/temp.local/p1.cpp b/clang/test/CXX/temp/temp.res/temp.local/p1.cpp
new file mode 100644
index 0000000..1ad4464
--- /dev/null
+++ b/clang/test/CXX/temp/temp.res/temp.local/p1.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++0x [temp.local]p1:
+// Like normal (non-template) classes, class templates have an
+// injected-class-name (Clause 9). The injected-class-name can be used with
+// or without a template-argument-list. When it is used without
+// a template-argument-list, it is equivalent to the injected-class-name
+// followed by the template-parameters of the class template enclosed in <>.
+
+template <typename T> struct X0 {
+ X0();
+ ~X0();
+ X0 f(const X0&);
+};
+
+// Test non-type template parameters.
+template <int N1, const int& N2, const int* N3> struct X1 {
+ X1();
+ ~X1();
+ X1 f(const X1& x1a) { X1 x1b(x1a); return x1b; }
+};
+
+// When it is used with a template-argument-list, it refers to the specified
+// class template specialization, which could be the current specialization
+// or another specialization.
+// FIXME: Test this clause.
+
+int i = 42;
+void test() {
+ X0<int> x0; (void)x0;
+ X1<42, i, &i> x1; (void)x1;
+}
diff --git a/clang/test/CXX/temp/temp.res/temp.local/p3.cpp b/clang/test/CXX/temp/temp.res/temp.local/p3.cpp
new file mode 100644
index 0000000..54da885
--- /dev/null
+++ b/clang/test/CXX/temp/temp.res/temp.local/p3.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -verify %s
+
+template <class T> struct Base { // expected-note 4 {{member found by ambiguous name lookup}}
+ static void f();
+};
+
+struct X0 { };
+
+template <class T> struct Derived: Base<int>, Base<char> {
+ typename Derived::Base b; // expected-error{{member 'Base' found in multiple base classes of different types}}
+ typename Derived::Base<double> d; // OK
+
+ void g(X0 *t) {
+ t->Derived::Base<T>::f();
+ t->Base<T>::f();
+ t->Base::f(); // expected-error{{member 'Base' found in multiple base classes of different types}} \
+ // expected-error{{no member named 'f' in 'X0'}} \
+ // expected-error{{expected a class or namespace}}
+ }
+};
+
+namespace PR6717 {
+ template <typename T>
+ class WebVector {
+ } // expected-error {{expected ';' after class}}
+
+ WebVector(const WebVector<T>& other) { } // expected-error{{undeclared identifier 'T'}} \
+ expected-error{{requires a type specifier}}
+
+ template <typename C>
+ WebVector<T>& operator=(const C& other) { } // expected-error{{undeclared identifier 'T'}}
+}
diff --git a/clang/test/CXX/temp/temp.res/temp.local/p7.cpp b/clang/test/CXX/temp/temp.res/temp.local/p7.cpp
new file mode 100644
index 0000000..bd05e75
--- /dev/null
+++ b/clang/test/CXX/temp/temp.res/temp.local/p7.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<class T> struct A {
+ int B;
+ int f();
+};
+
+template<class B> int A<B>::f() {
+ return B;
+}
diff --git a/clang/test/CXX/temp/temp.res/temp.local/p8.cpp b/clang/test/CXX/temp/temp.res/temp.local/p8.cpp
new file mode 100644
index 0000000..5d9d509
--- /dev/null
+++ b/clang/test/CXX/temp/temp.res/temp.local/p8.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace N {
+ enum { C };
+ template<class T> class B {
+ void f(T);
+ };
+}
+
+template<class C> void N::B<C>::f(C) {
+ C b;
+}
+
+namespace N {
+ enum { D };
+ namespace M {
+ enum { C , D };
+ template<typename C> class X {
+ template<typename U> void f(C, U);
+
+ template<typename D> void g(C, D) {
+ C c;
+ D d;
+ }
+ };
+
+ struct Y {
+ template<typename U> void f(U);
+ };
+ }
+
+ struct Y {
+ template<typename D> void f(D);
+ };
+}
+
+template<typename C>
+template<typename D>
+void N::M::X<C>::f(C, D) {
+ C c;
+ D d;
+}
+
+template<typename C>
+void N::M::Y::f(C) {
+ C c;
+}
+
+template<typename D>
+void N::Y::f(D) {
+ D d;
+}
+
diff --git a/clang/test/CXX/temp/temp.res/temp.local/p9.cpp b/clang/test/CXX/temp/temp.res/temp.local/p9.cpp
new file mode 100644
index 0000000..9ca8d88
--- /dev/null
+++ b/clang/test/CXX/temp/temp.res/temp.local/p9.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct A {
+ struct B { void f(); };
+ int a;
+ int Y;
+};
+
+template<class B, class a> struct X : A {
+ B b; // A's B
+ a c; // expected-error{{unknown type name 'a'}}
+
+ void g() {
+ b.g(); // expected-error{{no member named 'g' in 'A::B'}}
+ }
+};
diff --git a/clang/test/CXX/temp/temp.spec/p5.cpp b/clang/test/CXX/temp/temp.spec/p5.cpp
new file mode 100644
index 0000000..0e69a26
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/p5.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> inline void f(T) { }
+template void f(int); // expected-note{{previous explicit instantiation}}
+template void f(int); // expected-error{{duplicate explicit instantiation}}
+
+template<typename T>
+struct X0 {
+ union Inner { };
+
+ void f(T) { }
+
+ static T value;
+};
+
+template<typename T>
+T X0<T>::value = 3.14; // expected-warning{{implicit conversion turns literal floating-point number into integer}}
+
+template struct X0<int>; // expected-note{{previous explicit instantiation}} \
+ expected-note{{requested here}}
+template struct X0<int>; // expected-error{{duplicate explicit instantiation}}
+
+template void X0<float>::f(float); // expected-note{{previous explicit instantiation}}
+template void X0<float>::f(float); // expected-error{{duplicate explicit instantiation}}
+
+template union X0<float>::Inner; // expected-note{{previous explicit instantiation}}
+template union X0<float>::Inner; // expected-error{{duplicate explicit instantiation}}
+
+template float X0<float>::value; // expected-note{{previous explicit instantiation}}
+template float X0<float>::value; // expected-error{{duplicate explicit instantiation}}
+
+// Make sure that we don't get tricked by redeclarations of nested classes.
+namespace NestedClassRedecls {
+ template<typename T>
+ struct X {
+ struct Nested;
+ friend struct Nested;
+
+ struct Nested {
+ Nested() {}
+ } nested;
+ };
+
+ X<int> xi;
+
+ template struct X<int>;
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp
new file mode 100644
index 0000000..aecbfb5
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp
@@ -0,0 +1,334 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR5907 {
+ template<typename T> struct identity { typedef T type; };
+ struct A { A(); };
+ identity<A>::type::A() { }
+
+ struct B { void f(); };
+ template<typename T> struct C { typedef B type; };
+
+ void C<int>::type::f() { }
+}
+
+namespace PR9421 {
+ namespace N { template<typename T> struct S { void f(); }; }
+ typedef N::S<int> T;
+ namespace N { template<> void T::f() {} }
+}
+
+namespace PR8277 {
+ template< typename S >
+ struct C
+ {
+ template< int >
+ void F( void )
+ {
+ }
+ };
+
+ template< typename S >
+ struct D
+ {
+ typedef C< int > A;
+ };
+
+ typedef D< int >::A A;
+
+ template<>
+ template<>
+ void A::F< 0 >( void )
+ {
+ }
+}
+
+namespace PR8277b {
+ template<typename S> struct C {
+ void f();
+ };
+ template<typename S> struct D {
+ typedef C<int> A;
+ };
+ template<> void D<int>::A::f() {
+ }
+}
+
+namespace PR8708 {
+ template<typename T> struct A {
+ template<typename U> struct B {
+ // #2
+ void f();
+ };
+ };
+
+ // #A specialize the member template for
+ // implicit instantiation of A<int>,
+ // leaving the member template "unspecialized"
+ // (14.7.3/16). Specialization uses the syntax
+ // for explicit specialization (14.7.3/14)
+ template<> template<typename U>
+ struct A<int>::B {
+ // #1
+ void g();
+ };
+
+ // #1 define its function g. There is an enclosing
+ // class template, so we write template<> for each
+ // specialized template (14.7.3/15).
+ template<> template<typename U>
+ void A<int>::B<U>::g() { }
+
+ // #2 define the unspecialized member template's
+ // f
+ template<typename T> template<typename U>
+ void A<T>::B<U>::f() { }
+
+
+ // specialize the member template again, now
+ // specializing the member too. This specializes
+ // #A
+ template<> template<>
+ struct A<int>::B<int> {
+ // #3
+ void h();
+ };
+
+ // defines #3. There is no enclosing class template, so
+ // we write no "template<>".
+ void A<int>::B<int>::h() { }
+
+ void test() {
+ // calls #1
+ A<int>::B<float> a; a.g();
+
+ // calls #2
+ A<float>::B<int> b; b.f();
+
+ // calls #3
+ A<int>::B<int> c; c.h();
+ }
+}
+
+namespace PR9482 {
+ namespace N1 {
+ template <typename T> struct S {
+ void foo() {}
+ };
+ }
+
+ namespace N2 {
+ typedef N1::S<int> X;
+ }
+
+ namespace N1 {
+ template<> void N2::X::foo() {}
+ }
+}
+
+namespace PR9668 {
+ namespace First
+ {
+ template<class T>
+ class Bar
+ {
+ protected:
+
+ static const bool static_bool;
+ };
+ }
+
+ namespace Second
+ {
+ class Foo;
+ }
+
+ typedef First::Bar<Second::Foo> Special;
+
+ namespace
+ First
+ {
+ template<>
+ const bool Special::static_bool(false);
+ }
+}
+
+namespace PR9877 {
+ template<int>
+ struct X
+ {
+ struct Y;
+ };
+
+ template<> struct X<0>::Y { static const int Z = 1; };
+ template<> struct X<1>::Y { static const int Z = 1; };
+
+ const int X<0>::Y::Z;
+ template<> const int X<1>::Y::Z; // expected-error{{extraneous 'template<>' in declaration of variable 'Z'}}
+}
+
+namespace PR9913 {
+ template<class,class=int>struct S;
+ template<class X>struct S<X> {
+ template<class T> class F;
+ };
+
+ template<class A>
+ template<class B>
+ class S<A>::F{};
+}
+
+namespace template_class_spec_perClassDecl_nested
+{
+ template <typename T1> struct A {
+ template <typename T2> struct B {
+ template <typename T3> struct C {
+ static void foo();
+ };
+ };
+ };
+
+ template <> struct A<int> {
+ template <typename T2> struct B {
+ template <typename T3> struct C {
+ static void foo();
+ };
+ };
+ };
+
+ template <> template <typename T3> struct A<int>::B<int>::C {
+ static void foo();
+ };
+
+ template <> template <> struct A<int>::B<int>::C<int> {
+ static void foo();
+ };
+
+ template <> template<> template <typename T2> struct A<bool>::B<bool>::C {
+ static void foo();
+ };
+}
+
+
+namespace spec_vs_expl_inst {
+
+ // Test all permutations of Specialization,
+ // explicit instantiation Declaration, and explicit instantiation defInition.
+
+ namespace SDI { // PR11558
+ template <typename STRING_TYPE> class BasicStringPiece;
+ template <> class BasicStringPiece<int> { };
+ extern template class BasicStringPiece<int>;
+ template class BasicStringPiece<int>;
+ }
+
+ namespace SID {
+ template <typename STRING_TYPE> class BasicStringPiece;
+ template <> class BasicStringPiece<int> { };
+ template class BasicStringPiece<int>; // expected-note {{explicit instantiation definition is here}}
+ extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation declaration (with 'extern') follows explicit instantiation definition (without 'extern')}}
+ }
+
+ namespace ISD {
+ template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}}
+ template class BasicStringPiece<int>; // expected-error {{explicit instantiation of undefined template 'spec_vs_expl_inst::ISD::BasicStringPiece<int>'}}
+ template <> class BasicStringPiece<int> { };
+ extern template class BasicStringPiece<int>;
+ }
+
+ namespace IDS {
+ template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}}
+ template class BasicStringPiece<int>; // expected-error {{explicit instantiation of undefined template 'spec_vs_expl_inst::IDS::BasicStringPiece<int>'}} // expected-note {{explicit instantiation definition is here}}
+ extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation declaration (with 'extern') follows explicit instantiation definition (without 'extern')}}
+ template <> class BasicStringPiece<int> { };
+ }
+
+ namespace DIS {
+ template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}}
+ extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation of undefined template 'spec_vs_expl_inst::DIS::BasicStringPiece<int>'}}
+ template class BasicStringPiece<int>;
+ template <> class BasicStringPiece<int> { };
+ }
+
+ namespace DSI {
+ template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}}
+ extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation of undefined template 'spec_vs_expl_inst::DSI::BasicStringPiece<int>'}}
+ template <> class BasicStringPiece<int> { };
+ template class BasicStringPiece<int>;
+ }
+
+ // The same again, with a defined template class.
+
+ namespace SDI_WithDefinedTemplate {
+ template <typename STRING_TYPE> class BasicStringPiece {};
+ template <> class BasicStringPiece<int> { };
+ extern template class BasicStringPiece<int>;
+ template class BasicStringPiece<int>;
+ }
+
+ namespace SID_WithDefinedTemplate {
+ template <typename STRING_TYPE> class BasicStringPiece {};
+ template <> class BasicStringPiece<int> { };
+ template class BasicStringPiece<int>; // expected-note {{explicit instantiation definition is here}}
+ extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation declaration (with 'extern') follows explicit instantiation definition (without 'extern')}}
+ }
+
+ namespace ISD_WithDefinedTemplate {
+ template <typename STRING_TYPE> class BasicStringPiece {};
+ template class BasicStringPiece<int>; // expected-note {{explicit instantiation first required here}}
+ template <> class BasicStringPiece<int> { }; // expected-error {{explicit specialization of 'spec_vs_expl_inst::ISD_WithDefinedTemplate::BasicStringPiece<int>' after instantiation}}
+ extern template class BasicStringPiece<int>;
+ }
+
+ namespace IDS_WithDefinedTemplate {
+ template <typename STRING_TYPE> class BasicStringPiece {};
+ template class BasicStringPiece<int>; // expected-note {{explicit instantiation definition is here}} expected-note {{previous definition is here}}
+ extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation declaration (with 'extern') follows explicit instantiation definition (without 'extern')}}
+ template <> class BasicStringPiece<int> { }; // expected-error {{redefinition of 'spec_vs_expl_inst::IDS_WithDefinedTemplate::BasicStringPiece<int>'}}
+ }
+
+ namespace DIS_WithDefinedTemplate {
+ template <typename STRING_TYPE> class BasicStringPiece {};
+ extern template class BasicStringPiece<int>; // expected-note {{explicit instantiation first required here}}
+ template class BasicStringPiece<int>;
+ template <> class BasicStringPiece<int> { }; // expected-error {{explicit specialization of 'spec_vs_expl_inst::DIS_WithDefinedTemplate::BasicStringPiece<int>' after instantiation}}
+ }
+
+ namespace DSI_WithDefinedTemplate {
+ template <typename STRING_TYPE> class BasicStringPiece {};
+ extern template class BasicStringPiece<int>; // expected-note {{explicit instantiation first required here}}
+ template <> class BasicStringPiece<int> { }; // expected-error {{explicit specialization of 'spec_vs_expl_inst::DSI_WithDefinedTemplate::BasicStringPiece<int>' after instantiation}}
+ template class BasicStringPiece<int>;
+ }
+
+ // And some more random tests.
+
+ namespace SII_WithDefinedTemplate {
+ template <typename STRING_TYPE> class BasicStringPiece {};
+ template <> class BasicStringPiece<int> { };
+ template class BasicStringPiece<int>; // expected-note {{previous explicit instantiation is here}}
+ template class BasicStringPiece<int>; // expected-error {{duplicate explicit instantiation of 'BasicStringPiece<int>'}}
+ }
+
+ namespace SIS {
+ template <typename STRING_TYPE> class BasicStringPiece;
+ template <> class BasicStringPiece<int> { }; // expected-note {{previous definition is here}}
+ template class BasicStringPiece<int>;
+ template <> class BasicStringPiece<int> { }; // expected-error {{redefinition of 'spec_vs_expl_inst::SIS::BasicStringPiece<int>'}}
+ }
+
+ namespace SDS {
+ template <typename STRING_TYPE> class BasicStringPiece;
+ template <> class BasicStringPiece<int> { }; // expected-note {{previous definition is here}}
+ extern template class BasicStringPiece<int>;
+ template <> class BasicStringPiece<int> { }; // expected-error {{redefinition of 'spec_vs_expl_inst::SDS::BasicStringPiece<int>'}}
+ }
+
+ namespace SDIS {
+ template <typename STRING_TYPE> class BasicStringPiece;
+ template <> class BasicStringPiece<int> { }; // expected-note {{previous definition is here}}
+ extern template class BasicStringPiece<int>;
+ template class BasicStringPiece<int>;
+ template <> class BasicStringPiece<int> { }; // expected-error {{redefinition of 'spec_vs_expl_inst::SDIS::BasicStringPiece<int>'}}
+ }
+
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p1.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p1.cpp
new file mode 100644
index 0000000..3843c0d
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p1.cpp
@@ -0,0 +1,99 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// This test creates cases where implicit instantiations of various entities
+// would cause a diagnostic, but provides expliict specializations for those
+// entities that avoid the diagnostic. The intent is to verify that
+// implicit instantiations do not occur (because the explicit specialization
+// is used instead).
+struct NonDefaultConstructible {
+ NonDefaultConstructible(int);
+};
+
+
+// C++ [temp.expl.spec]p1:
+// An explicit specialization of any of the following:
+
+// -- function template
+template<typename T> void f0(T) {
+ T t;
+}
+
+template<> void f0(NonDefaultConstructible) { }
+
+void test_f0(NonDefaultConstructible NDC) {
+ f0(NDC);
+}
+
+// -- class template
+template<typename T>
+struct X0 {
+ static T member;
+
+ void f1(T t) {
+ t = 17;
+ }
+
+ struct Inner : public T { };
+
+ template<typename U>
+ struct InnerTemplate : public T { };
+
+ template<typename U>
+ void ft1(T t, U u);
+};
+
+template<typename T>
+template<typename U>
+void X0<T>::ft1(T t, U u) {
+ t = u;
+}
+
+template<typename T> T X0<T>::member;
+
+template<> struct X0<void> { };
+X0<void> test_X0;
+
+
+// -- member function of a class template
+template<> void X0<void*>::f1(void *) { }
+
+void test_spec(X0<void*> xvp, void *vp) {
+ xvp.f1(vp);
+}
+
+// -- static data member of a class template
+template<>
+NonDefaultConstructible X0<NonDefaultConstructible>::member = 17;
+
+NonDefaultConstructible &get_static_member() {
+ return X0<NonDefaultConstructible>::member;
+}
+
+// -- member class of a class template
+template<>
+struct X0<void*>::Inner { };
+
+X0<void*>::Inner inner0;
+
+// -- member class template of a class template
+template<>
+template<>
+struct X0<void*>::InnerTemplate<int> { };
+
+X0<void*>::InnerTemplate<int> inner_template0;
+
+// -- member function template of a class template
+template<>
+template<>
+void X0<void*>::ft1(void*, const void*) { }
+
+void test_func_template(X0<void *> xvp, void *vp, const void *cvp) {
+ xvp.ft1(vp, cvp);
+}
+
+// example from the standard:
+template<class T> class stream;
+template<> class stream<char> { /* ... */ };
+template<class T> class Array { /* ... */ };
+template<class T> void sort(Array<T>& v) { /* ... */ }
+template<> void sort<char*>(Array<char*>&) ;
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p10.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p10.cpp
new file mode 100644
index 0000000..b81c1e7
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p10.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<class T> class X;
+template<> class X<int>; // expected-note{{forward}}
+X<int>* p;
+
+X<int> x; // expected-error{{incomplete type}}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p11.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p11.cpp
new file mode 100644
index 0000000..5fa2f62
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p11.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<class T> class Array { /* ... */ };
+template<class T> void sort(Array<T>& v);
+
+// explicit specialization for sort(Array<int>&)
+// with deduced template-argument of type int
+template<> void sort(Array<int>&);
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p13.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p13.cpp
new file mode 100644
index 0000000..fb6d1be
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p13.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+template<typename T> void f(T);
+
+template<> void f(int) { }
+void f(int) { }
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp
new file mode 100644
index 0000000..121cb8e
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+template<class T> void f(T) { /* ... */ }
+template<class T> inline void g(T) { /* ... */ }
+
+// CHECK: define void @_Z1gIiEvT_
+template<> void g<>(int) { /* ... */ }
+
+template<class T>
+struct X {
+ void f() { }
+ void g();
+ void h();
+};
+
+template<class T>
+void X<T>::g() {
+}
+
+template<class T>
+inline void X<T>::h() {
+}
+
+// CHECK: define void @_ZN1XIiE1fEv
+template<> void X<int>::f() { }
+
+// CHECK: define void @_ZN1XIiE1hEv
+template<> void X<int>::h() { }
+
+// CHECK: define linkonce_odr void @_Z1fIiEvT_
+template<> inline void f<>(int) { /* ... */ }
+
+// CHECK: define linkonce_odr void @_ZN1XIiE1gEv
+template<> inline void X<int>::g() { }
+
+void test(X<int> xi) {
+ f(17);
+ g(17);
+ xi.f();
+ xi.g();
+ xi.h();
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp
new file mode 100644
index 0000000..72f33df
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct NonDefaultConstructible {
+ NonDefaultConstructible(const NonDefaultConstructible&); // expected-note{{candidate constructor}}
+};
+
+template<typename T, typename U>
+struct X {
+ static T member;
+};
+
+template<typename T, typename U>
+T X<T, U>::member; // expected-error{{no matching constructor}}
+
+// Okay; this is a declaration, not a definition.
+template<>
+NonDefaultConstructible X<NonDefaultConstructible, long>::member;
+
+NonDefaultConstructible &test(bool b) {
+ return b? X<NonDefaultConstructible, int>::member // expected-note{{instantiation}}
+ : X<NonDefaultConstructible, long>::member;
+}
+
+namespace rdar9422013 {
+ template<int>
+ struct X {
+ struct Inner {
+ static unsigned array[17];
+ };
+ };
+
+ template<> unsigned X<1>::Inner::array[]; // okay
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p16.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p16.cpp
new file mode 100644
index 0000000..c7597e9
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p16.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<class T> struct A {
+ void f(T);
+ template<class X1> void g1(T, X1);
+ template<class X2> void g2(T, X2);
+ void h(T) { }
+};
+
+// specialization
+template<> void A<int>::f(int);
+
+// out of class member template definition
+template<class T> template<class X1> void A<T>::g1(T, X1) { }
+
+// member template specialization
+template<> template<class X1> void A<int>::g1(int, X1);
+
+// member template specialization
+template<> template<>
+ void A<int>::g1(int, char); // X1 deduced as char
+
+template<> template<>
+ void A<int>::g2<char>(int, char); // X2 specified as char
+ // member specialization even if defined in class definition
+
+template<> void A<int>::h(int) { }
+
+namespace PR10024 {
+ template <typename T>
+ struct Test{
+ template <typename U>
+ void get(U i) {}
+ };
+
+ template <typename T>
+ template <>
+ void Test<T>::get<double>(double i) {} // expected-error{{cannot specialize (with 'template<>') a member of an unspecialized template}}
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp
new file mode 100644
index 0000000..56231e2
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<class T1>
+class A {
+ template<class T2> class B {
+ void mf();
+ };
+};
+
+template<> template<> class A<int>::B<double>;
+template<> template<> void A<char>::B<char>::mf();
+
+template<> void A<char>::B<int>::mf(); // expected-error{{requires 'template<>'}}
+
+namespace test1 {
+ template <class> class A {
+ static int foo;
+ static int bar;
+ };
+ typedef A<int> AA;
+
+ template <> int AA::foo = 0;
+ int AA::bar = 1; // expected-error {{template specialization requires 'template<>'}}
+ int A<float>::bar = 2; // expected-error {{template specialization requires 'template<>'}}
+
+ template <> class A<double> {
+ public:
+ static int foo;
+ static int bar;
+ };
+
+ typedef A<double> AB;
+ template <> int AB::foo = 0; // expected-error{{extraneous 'template<>'}}
+ int AB::bar = 1;
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp
new file mode 100644
index 0000000..4d175a8
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<class T1> class A {
+ template<class T2> class B {
+ template<class T3> void mf1(T3);
+ void mf2();
+ };
+};
+
+template<> template<class X>
+class A<long>::B { };
+
+template<> template<> template<class T>
+ void A<int>::B<double>::mf1(T t) { }
+
+template<> template<> template<class T>
+void A<long>::B<double>::mf1(T t) { } // expected-error{{does not match}}
+
+// FIXME: This diagnostic could probably be better.
+template<class Y> template<>
+ void A<Y>::B<double>::mf2() { } // expected-error{{does not refer}}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p19.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p19.cpp
new file mode 100644
index 0000000..1c2ea7e
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p19.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+struct X {
+ template<typename U> struct Inner { };
+
+ template<typename U> void f(T, U) { }
+};
+
+template<> template<typename U>
+struct X<int>::Inner {
+ U member;
+};
+
+template<> template<typename U>
+void X<int>::f(int x, U y) {
+ x = y; // expected-error{{incompatible type}}
+}
+
+void test(X<int> xi, X<long> xl, float *fp) {
+ X<int>::Inner<float*> xii;
+ xii.member = fp;
+ xi.f(17, 25);
+ xi.f(17, 3.14159);
+ xi.f(17, fp); // expected-note{{instantiation}}
+ X<long>::Inner<float*> xli;
+
+ xli.member = fp; // expected-error{{no member}}
+ xl.f(17, fp); // okay
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp
new file mode 100644
index 0000000..b0a19fb
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp
@@ -0,0 +1,302 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// This test creates cases where implicit instantiations of various entities
+// would cause a diagnostic, but provides expliict specializations for those
+// entities that avoid the diagnostic. The specializations are alternately
+// declarations and definitions, and the intent of this test is to verify
+// that we allow specializations only in the appropriate namespaces (and
+// nowhere else).
+struct NonDefaultConstructible {
+ NonDefaultConstructible(int);
+};
+
+
+// C++ [temp.expl.spec]p1:
+// An explicit specialization of any of the following:
+
+// -- function template
+namespace N0 {
+ template<typename T> void f0(T) {
+ T t;
+ }
+
+ template<> void f0(NonDefaultConstructible) { }
+
+ void test_f0(NonDefaultConstructible NDC) {
+ f0(NDC);
+ }
+
+ template<> void f0(int);
+ template<> void f0(long);
+}
+
+template<> void N0::f0(int) { } // okay
+
+namespace N1 {
+ template<> void N0::f0(long) { } // expected-error{{does not enclose namespace}}
+}
+
+template<> void N0::f0(double) { }
+
+struct X1 {
+ template<typename T> void f(T);
+
+ template<> void f(int); // expected-error{{in class scope}}
+};
+
+// -- class template
+namespace N0 {
+
+template<typename T>
+struct X0 { // expected-note {{here}}
+ static T member;
+
+ void f1(T t) {
+ t = 17;
+ }
+
+ struct Inner : public T { }; // expected-note 2{{here}}
+
+ template<typename U>
+ struct InnerTemplate : public T { }; // expected-note 1{{explicitly specialized}} \
+ // expected-error{{base specifier}}
+
+ template<typename U>
+ void ft1(T t, U u);
+};
+
+}
+
+template<typename T>
+template<typename U>
+void N0::X0<T>::ft1(T t, U u) {
+ t = u;
+}
+
+template<typename T> T N0::X0<T>::member;
+
+template<> struct N0::X0<void> { };
+N0::X0<void> test_X0;
+
+namespace N1 {
+ template<> struct N0::X0<const void> { }; // expected-error{{class template specialization of 'X0' must originally be declared in namespace 'N0'}}
+}
+
+namespace N0 {
+ template<> struct X0<volatile void>;
+}
+
+template<> struct N0::X0<volatile void> {
+ void f1(void *);
+};
+
+// -- member function of a class template
+template<> void N0::X0<void*>::f1(void *) { }
+
+void test_spec(N0::X0<void*> xvp, void *vp) {
+ xvp.f1(vp);
+}
+
+namespace N0 {
+ template<> void X0<volatile void>::f1(void *) { } // expected-error{{no function template matches}}
+
+ template<> void X0<const volatile void*>::f1(const volatile void*);
+}
+
+void test_x0_cvvoid(N0::X0<const volatile void*> x0, const volatile void *cvp) {
+ x0.f1(cvp); // okay: we've explicitly specialized
+}
+
+// -- static data member of a class template
+namespace N0 {
+ // This actually tests p15; the following is a declaration, not a definition.
+ template<>
+ NonDefaultConstructible X0<NonDefaultConstructible>::member;
+
+ template<> long X0<long>::member = 17;
+
+ template<> float X0<float>::member;
+
+ template<> double X0<double>::member;
+}
+
+NonDefaultConstructible &get_static_member() {
+ return N0::X0<NonDefaultConstructible>::member;
+}
+
+template<> int N0::X0<int>::member;
+
+template<> float N0::X0<float>::member = 3.14f;
+
+namespace N1 {
+ template<> double N0::X0<double>::member = 3.14; // expected-error{{does not enclose namespace}}
+}
+
+// -- member class of a class template
+namespace N0 {
+
+ template<>
+ struct X0<void*>::Inner { };
+
+ template<>
+ struct X0<int>::Inner { };
+
+ template<>
+ struct X0<unsigned>::Inner;
+
+ template<>
+ struct X0<float>::Inner;
+
+ template<>
+ struct X0<double>::Inner; // expected-note{{forward declaration}}
+}
+
+template<>
+struct N0::X0<long>::Inner { };
+
+template<>
+struct N0::X0<float>::Inner { };
+
+namespace N1 {
+ template<>
+ struct N0::X0<unsigned>::Inner { }; // expected-error{{member class specialization}}
+
+ template<>
+ struct N0::X0<unsigned long>::Inner { }; // expected-error{{member class specialization}}
+};
+
+N0::X0<void*>::Inner inner0;
+N0::X0<int>::Inner inner1;
+N0::X0<long>::Inner inner2;
+N0::X0<float>::Inner inner3;
+N0::X0<double>::Inner inner4; // expected-error{{incomplete}}
+
+// -- member class template of a class template
+namespace N0 {
+ template<>
+ template<>
+ struct X0<void*>::InnerTemplate<int> { };
+
+ template<> template<>
+ struct X0<int>::InnerTemplate<int>; // expected-note{{forward declaration}}
+
+ template<> template<>
+ struct X0<int>::InnerTemplate<long>;
+
+ template<> template<>
+ struct X0<int>::InnerTemplate<double>;
+}
+
+template<> template<>
+struct N0::X0<int>::InnerTemplate<long> { }; // okay
+
+template<> template<>
+struct N0::X0<int>::InnerTemplate<float> { };
+
+namespace N1 {
+ template<> template<>
+ struct N0::X0<int>::InnerTemplate<double> { }; // expected-error{{enclosing}}
+}
+
+N0::X0<void*>::InnerTemplate<int> inner_template0;
+N0::X0<int>::InnerTemplate<int> inner_template1; // expected-error{{incomplete}}
+N0::X0<int>::InnerTemplate<long> inner_template2;
+N0::X0<int>::InnerTemplate<unsigned long> inner_template3; // expected-note{{instantiation}}
+
+// -- member function template of a class template
+namespace N0 {
+ template<>
+ template<>
+ void X0<void*>::ft1(void*, const void*) { }
+
+ template<> template<>
+ void X0<void*>::ft1(void *, int);
+
+ template<> template<>
+ void X0<void*>::ft1(void *, unsigned);
+
+ template<> template<>
+ void X0<void*>::ft1(void *, long);
+}
+
+template<> template<>
+void N0::X0<void*>::ft1(void *, unsigned) { } // okay
+
+template<> template<>
+void N0::X0<void*>::ft1(void *, float) { }
+
+namespace N1 {
+ template<> template<>
+ void N0::X0<void*>::ft1(void *, long) { } // expected-error{{does not enclose namespace}}
+}
+
+
+void test_func_template(N0::X0<void *> xvp, void *vp, const void *cvp,
+ int i, unsigned u) {
+ xvp.ft1(vp, cvp);
+ xvp.ft1(vp, i);
+ xvp.ft1(vp, u);
+}
+
+namespace has_inline_namespaces {
+ inline namespace inner {
+ template<class T> void f(T&);
+
+ template<class T>
+ struct X0 {
+ struct MemberClass;
+
+ void mem_func();
+
+ template<typename U>
+ struct MemberClassTemplate;
+
+ template<typename U>
+ void mem_func_template(U&);
+
+ static int value;
+ };
+ }
+
+ struct X1;
+ struct X2;
+
+ // An explicit specialization whose declarator-id is not qualified
+ // shall be declared in the nearest enclosing namespace of the
+ // template, or, if the namespace is inline (7.3.1), any namespace
+ // from its enclosing namespace set.
+ template<> void f(X1&);
+ template<> void f<X2>(X2&);
+
+ template<> struct X0<X1> { };
+
+ template<> struct X0<X2>::MemberClass { };
+
+ template<> void X0<X2>::mem_func();
+
+ template<> template<typename T> struct X0<X2>::MemberClassTemplate { };
+
+ template<> template<typename T> void X0<X2>::mem_func_template(T&) { }
+
+ template<> int X0<X2>::value = 12;
+}
+
+struct X3;
+struct X4;
+
+template<> void has_inline_namespaces::f(X3&);
+template<> void has_inline_namespaces::f<X4>(X4&);
+
+template<> struct has_inline_namespaces::X0<X3> { };
+
+template<> struct has_inline_namespaces::X0<X4>::MemberClass { };
+
+template<> void has_inline_namespaces::X0<X4>::mem_func();
+
+template<> template<typename T>
+struct has_inline_namespaces::X0<X4>::MemberClassTemplate { };
+
+template<> template<typename T>
+void has_inline_namespaces::X0<X4>::mem_func_template(T&) { }
+
+template<> int has_inline_namespaces::X0<X4>::value = 13;
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
new file mode 100644
index 0000000..c972bf7
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
@@ -0,0 +1,252 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// This test creates cases where implicit instantiations of various entities
+// would cause a diagnostic, but provides expliict specializations for those
+// entities that avoid the diagnostic. The specializations are alternately
+// declarations and definitions, and the intent of this test is to verify
+// that we allow specializations only in the appropriate namespaces (and
+// nowhere else).
+struct NonDefaultConstructible {
+ NonDefaultConstructible(int);
+};
+
+
+// C++ [temp.expl.spec]p1:
+// An explicit specialization of any of the following:
+
+// -- function template
+namespace N0 {
+ template<typename T> void f0(T) { // expected-note{{here}}
+ T t;
+ }
+
+ template<> void f0(NonDefaultConstructible) { }
+
+ void test_f0(NonDefaultConstructible NDC) {
+ f0(NDC);
+ }
+
+ template<> void f0(int);
+ template<> void f0(long);
+}
+
+template<> void N0::f0(int) { } // okay
+
+namespace N1 {
+ template<> void N0::f0(long) { } // expected-error{{does not enclose namespace}}
+}
+
+template<> void N0::f0(double); // expected-warning{{C++11 extension}}
+template<> void N0::f0(double) { }
+
+struct X1 {
+ template<typename T> void f(T);
+
+ template<> void f(int); // expected-error{{in class scope}}
+};
+
+// -- class template
+namespace N0 {
+
+template<typename T>
+struct X0 { // expected-note 2{{here}}
+ static T member; // expected-note{{here}}
+
+ void f1(T t) { // expected-note{{explicitly specialized declaration is here}}
+ t = 17;
+ }
+
+ struct Inner : public T { }; // expected-note 3{{here}}
+
+ template<typename U>
+ struct InnerTemplate : public T { }; // expected-note 2{{explicitly specialized}} \
+ // expected-error{{base specifier}}
+
+ template<typename U>
+ void ft1(T t, U u); // expected-note{{explicitly specialized}}
+};
+
+}
+
+template<typename T>
+template<typename U>
+void N0::X0<T>::ft1(T t, U u) {
+ t = u;
+}
+
+template<typename T> T N0::X0<T>::member;
+
+template<> struct N0::X0<void> { }; // expected-warning{{C++11 extension}}
+N0::X0<void> test_X0;
+
+namespace N1 {
+ template<> struct N0::X0<const void> { }; // expected-error{{originally}}
+}
+
+namespace N0 {
+ template<> struct X0<volatile void>;
+}
+
+template<> struct N0::X0<volatile void> {
+ void f1(void *);
+};
+
+// -- member function of a class template
+template<> void N0::X0<void*>::f1(void *) { } // expected-warning{{member function specialization}}
+
+void test_spec(N0::X0<void*> xvp, void *vp) {
+ xvp.f1(vp);
+}
+
+namespace N0 {
+ template<> void X0<volatile void>::f1(void *) { } // expected-error{{no function template matches}}
+
+ template<> void X0<const volatile void*>::f1(const volatile void*);
+}
+
+void test_x0_cvvoid(N0::X0<const volatile void*> x0, const volatile void *cvp) {
+ x0.f1(cvp); // okay: we've explicitly specialized
+}
+
+// -- static data member of a class template
+namespace N0 {
+ // This actually tests p15; the following is a declaration, not a definition.
+ template<>
+ NonDefaultConstructible X0<NonDefaultConstructible>::member;
+
+ template<> long X0<long>::member = 17;
+
+ template<> float X0<float>::member;
+
+ template<> double X0<double>::member;
+}
+
+NonDefaultConstructible &get_static_member() {
+ return N0::X0<NonDefaultConstructible>::member;
+}
+
+template<> int N0::X0<int>::member; // expected-warning{{C++11 extension}}
+
+template<> float N0::X0<float>::member = 3.14f;
+
+namespace N1 {
+ template<> double N0::X0<double>::member = 3.14; // expected-error{{does not enclose namespace}}
+}
+
+// -- member class of a class template
+namespace N0 {
+
+ template<>
+ struct X0<void*>::Inner { };
+
+ template<>
+ struct X0<int>::Inner { };
+
+ template<>
+ struct X0<unsigned>::Inner;
+
+ template<>
+ struct X0<float>::Inner;
+
+ template<>
+ struct X0<double>::Inner; // expected-note{{forward declaration}}
+}
+
+template<>
+struct N0::X0<long>::Inner { }; // expected-warning{{C++11 extension}}
+
+template<>
+struct N0::X0<float>::Inner { };
+
+namespace N1 {
+ template<>
+ struct N0::X0<unsigned>::Inner { }; // expected-error{{member class specialization}}
+
+ template<>
+ struct N0::X0<unsigned long>::Inner { }; // expected-error{{member class specialization}}
+};
+
+N0::X0<void*>::Inner inner0;
+N0::X0<int>::Inner inner1;
+N0::X0<long>::Inner inner2;
+N0::X0<float>::Inner inner3;
+N0::X0<double>::Inner inner4; // expected-error{{incomplete}}
+
+// -- member class template of a class template
+namespace N0 {
+ template<>
+ template<>
+ struct X0<void*>::InnerTemplate<int> { };
+
+ template<> template<>
+ struct X0<int>::InnerTemplate<int>; // expected-note{{forward declaration}}
+
+ template<> template<>
+ struct X0<int>::InnerTemplate<long>;
+
+ template<> template<>
+ struct X0<int>::InnerTemplate<double>;
+}
+
+template<> template<>
+struct N0::X0<int>::InnerTemplate<long> { }; // okay
+
+template<> template<>
+struct N0::X0<int>::InnerTemplate<float> { }; // expected-warning{{class template specialization}}
+
+namespace N1 {
+ template<> template<>
+ struct N0::X0<int>::InnerTemplate<double> { }; // expected-error{{enclosing}}
+}
+
+N0::X0<void*>::InnerTemplate<int> inner_template0;
+N0::X0<int>::InnerTemplate<int> inner_template1; // expected-error{{incomplete}}
+N0::X0<int>::InnerTemplate<long> inner_template2;
+N0::X0<int>::InnerTemplate<unsigned long> inner_template3; // expected-note{{instantiation}}
+
+// -- member function template of a class template
+namespace N0 {
+ template<>
+ template<>
+ void X0<void*>::ft1(void*, const void*) { }
+
+ template<> template<>
+ void X0<void*>::ft1(void *, int);
+
+ template<> template<>
+ void X0<void*>::ft1(void *, unsigned);
+
+ template<> template<>
+ void X0<void*>::ft1(void *, long);
+}
+
+template<> template<>
+void N0::X0<void*>::ft1(void *, unsigned) { } // okay
+
+template<> template<>
+void N0::X0<void*>::ft1(void *, float) { } // expected-warning{{function template specialization}}
+
+namespace N1 {
+ template<> template<>
+ void N0::X0<void*>::ft1(void *, long) { } // expected-error{{does not enclose namespace}}
+}
+
+
+void test_func_template(N0::X0<void *> xvp, void *vp, const void *cvp,
+ int i, unsigned u) {
+ xvp.ft1(vp, cvp);
+ xvp.ft1(vp, i);
+ xvp.ft1(vp, u);
+}
+
+namespace PR8979 {
+ template<typename Z>
+ struct X0 {
+ template <class T, class U> class Inner;
+ struct OtherInner;
+ template<typename T, typename U> void f(Inner<T, U>&);
+
+ typedef Inner<OtherInner, OtherInner> MyInner;
+ template<> void f(MyInner&); // expected-error{{cannot specialize a function 'f' within class scope}}
+ };
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp
new file mode 100644
index 0000000..86cdcf8
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T>
+void f(T);
+
+template<typename T>
+struct A { };
+
+struct X {
+ template<> friend void f<int>(int); // expected-error{{in a friend}}
+ template<> friend class A<int>; // expected-error{{cannot be a friend}}
+
+ friend void f<float>(float); // okay
+ friend class A<float>; // okay
+};
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p21.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p21.cpp
new file mode 100644
index 0000000..ab26f40
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p21.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+struct X {
+ void mf1(T);
+ template<typename U> void mf2(T, U); // expected-note{{previous}}
+};
+
+template<>
+void X<int>::mf1(int i = 17) // expected-error{{default}}
+{
+}
+
+template<> template<>
+void X<int>::mf2(int, int = 17) // expected-error{{default}}
+{ }
+
+template<> template<typename U>
+void X<int>::mf2(int, U = U()) // expected-error{{default}}
+{
+}
+
+template<>
+struct X<float> {
+ void mf1(float);
+};
+
+void X<float>::mf1(float = 3.14f) // okay
+{
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp
new file mode 100644
index 0000000..84841cb
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace N {
+ template<class T> class X;
+}
+
+template<> class X<int> { /* ... */ }; // expected-error {{non-template class 'X'}}
+
+namespace N {
+
+template<> class X<char*> { /* ... */ }; // OK: X is a template
+
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp
new file mode 100644
index 0000000..772aef6
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct IntHolder { // expected-note{{here}} // expected-note 2{{candidate constructor (the implicit copy constructor)}}
+ IntHolder(int); // expected-note 2{{candidate constructor}}
+};
+
+template<typename T, typename U>
+struct X { // expected-note{{here}}
+ void f() {
+ T t; // expected-error{{no matching}}
+ }
+
+ void g() { }
+
+ struct Inner { // expected-error{{implicit default}}
+ T value; // expected-note {{member is declared here}}
+ };
+
+ static T value;
+};
+
+template<typename T, typename U>
+T X<T, U>::value; // expected-error{{no matching constructor}}
+
+IntHolder &test_X_IntHolderInt(X<IntHolder, int> xih) {
+ xih.g(); // okay
+ xih.f(); // expected-note{{instantiation}}
+
+ X<IntHolder, int>::Inner inner; // expected-note {{first required here}}
+
+ return X<IntHolder, int>::value; // expected-note{{instantiation}}
+}
+
+// Explicitly specialize the members of X<IntHolder, long> to not cause
+// problems with instantiation.
+template<>
+void X<IntHolder, long>::f() { }
+
+template<>
+struct X<IntHolder, long>::Inner {
+ Inner() : value(17) { }
+ IntHolder value;
+};
+
+template<>
+IntHolder X<IntHolder, long>::value = 17;
+
+IntHolder &test_X_IntHolderInt(X<IntHolder, long> xih) {
+ xih.g(); // okay
+ xih.f(); // okay, uses specialization
+
+ X<IntHolder, long>::Inner inner; // okay, uses specialization
+
+ return X<IntHolder, long>::value; // okay, uses specialization
+}
+
+template<>
+X<IntHolder, long>::X() { } // expected-error{{instantiated member}}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p5-example.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p5-example.cpp
new file mode 100644
index 0000000..f49190e
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p5-example.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<class T> struct A {
+ struct B { };
+ template<class U> struct C { };
+};
+ template<> struct A<int> {
+ void f(int);
+};
+void h() {
+ A<int> a;
+ a.f(16);
+}
+// A<int>::f must be defined somewhere
+// template<> not used for a member of an // explicitly specialized class template
+void A<int>::f(int) { /* ... */ }
+ template<> struct A<char>::B {
+ void f();
+};
+// template<> also not used when defining a member of // an explicitly specialized member class
+void A<char>::B::f() { /* ... */ }
+ template<> template<class U> struct A<char>::C {
+ void f();
+};
+
+template<>
+template<class U> void A<char>::C<U>::f() { /* ... */ }
+ template<> struct A<short>::B {
+ void f();
+};
+template<> void A<short>::B::f() { /* ... */ } // expected-error{{no function template matches function template specialization 'f'}}
+ template<> template<class U> struct A<short>::C {
+ void f();
+};
+template<class U> void A<short>::C<U>::f() { /* ... */ } // expected-error{{template parameter list matching the non-templated nested type 'A<short>' should be empty ('template<>')}}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p5.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p5.cpp
new file mode 100644
index 0000000..512ea47
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p5.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct IntHolder {
+ IntHolder(int);
+};
+
+template<typename T, typename U>
+struct X {
+ void f() {
+ T t;
+ }
+
+ void g() { }
+
+ struct Inner {
+ T value;
+ };
+
+ static T value;
+};
+
+template<typename T, typename U>
+T X<T, U>::value;
+
+// Explicitly specialize the members of X<IntHolder, long> to not cause
+// problems with instantiation, but only provide declarations (not definitions).
+template<>
+void X<IntHolder, long>::f();
+
+template<>
+struct X<IntHolder, long>::Inner; // expected-note{{forward declaration}}
+
+template<>
+IntHolder X<IntHolder, long>::value;
+
+IntHolder &test_X_IntHolderInt(X<IntHolder, long> xih) {
+ xih.g(); // okay
+ xih.f(); // okay, uses specialization
+
+ X<IntHolder, long>::Inner inner; // expected-error {{incomplete}}
+
+ return X<IntHolder, long>::value; // okay, uses specialization
+}
+
+
+template<class T> struct A {
+ void f(T) { /* ... */ }
+};
+
+template<> struct A<int> {
+ void f(int);
+};
+
+void h() {
+ A<int> a;
+ a.f(16); // A<int>::f must be defined somewhere
+}
+
+// explicit specialization syntax not used for a member of
+// explicitly specialized class template specialization
+void A<int>::f(int) { /* ... */ }
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p6.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p6.cpp
new file mode 100644
index 0000000..f539471
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p6.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+struct X0 {
+ void f();
+
+ template<typename U>
+ void g(U);
+
+ struct Nested {
+ };
+
+ static T member;
+};
+
+int &use_X0_int(X0<int> x0i, // expected-note{{implicit instantiation first required here}}
+ int i) {
+ x0i.f(); // expected-note{{implicit instantiation first required here}}
+ x0i.g(i); // expected-note{{implicit instantiation first required here}}
+ X0<int>::Nested nested; // expected-note{{implicit instantiation first required here}}
+ return X0<int>::member; // expected-note{{implicit instantiation first required here}}
+}
+
+template<>
+void X0<int>::f() { // expected-error{{after instantiation}}
+}
+
+template<> template<>
+void X0<int>::g(int) { // expected-error{{after instantiation}}
+}
+
+template<>
+struct X0<int>::Nested { }; // expected-error{{after instantiation}}
+
+template<>
+int X0<int>::member = 17; // expected-error{{after instantiation}}
+
+template<>
+struct X0<int> { }; // expected-error{{after instantiation}}
+
+// Example from the standard
+template<class T> class Array { /* ... */ };
+
+template<class T> void sort(Array<T>& v) { /* ... */ }
+
+struct String {};
+
+void f(Array<String>& v) {
+
+ sort(v); // expected-note{{required}}
+ // use primary template
+ // sort(Array<T>&), T is String
+}
+
+template<> void sort<String>(Array<String>& v); // // expected-error{{after instantiation}}
+template<> void sort<>(Array<char*>& v); // OK: sort<char*> not yet used
+
+namespace PR6160 {
+ template<typename T> void f(T);
+ template<> void f(int);
+ extern template void f(int);
+ template<> void f(int) { }
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p9.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p9.cpp
new file mode 100644
index 0000000..d4ce01f
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p9.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace N {
+ template<class T> class X { /* ... */ };
+ template<class T> class Y { /* ... */ };
+ template<> class X<int> { /* ... */ };
+ template<> class Y<double>;
+
+ const unsigned NumElements = 17;
+}
+
+template<> class N::Y<double> {
+ int array[NumElements];
+};
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
new file mode 100644
index 0000000..80f0598
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+template<typename T>
+struct X {
+ void f() {}
+};
+
+template inline void X<int>::f(); // expected-error{{explicit instantiation cannot be 'inline'}}
+
+template<typename T>
+struct Y {
+ constexpr int f() { return 0; }
+};
+
+template constexpr int Y<int>::f(); // expected-error{{explicit instantiation cannot be 'constexpr'}}
+
+template<typename T>
+struct Z {
+ enum E : T { e1, e2 };
+ T t; // expected-note {{refers here}}
+};
+
+template enum Z<int>::E; // expected-error {{enumerations cannot be explicitly instantiated}}
+template int Z<int>::t; // expected-error {{explicit instantiation of 't' does not refer to}}
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p1-emit.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p1-emit.cpp
new file mode 100644
index 0000000..d0df305
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p1-emit.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10 -o - %s | FileCheck %s
+template<typename T>
+struct X {
+ static T member1;
+ static T member2;
+ static T member3;
+};
+
+template<typename T>
+T X<T>::member1;
+
+template<typename T>
+T X<T>::member2 = 17;
+
+// CHECK: @_ZN1XIiE7member1E = weak_odr global i32 0
+template int X<int>::member1;
+
+// CHECK: @_ZN1XIiE7member2E = weak_odr global i32 17
+template int X<int>::member2;
+
+// For implicit instantiation of
+long& get(bool Cond1, bool Cond2) {
+ // CHECK: @_ZN1XIlE7member1E = weak_odr global i64 0
+ // CHECK: @_ZN1XIlE7member2E = weak_odr global i64 17
+ // CHECK: @_ZN1XIlE7member3E = external global i64
+ return Cond1? X<long>::member1
+ : Cond2? X<long>::member2
+ : X<long>::member3;
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp
new file mode 100644
index 0000000..b426339
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct C { };
+
+template<typename T>
+struct X0 {
+ T value; // expected-error{{incomplete}}
+};
+
+// Explicitly instantiate a class template specialization
+template struct X0<int>;
+template struct X0<void>; // expected-note{{instantiation}}
+
+// Explicitly instantiate a function template specialization
+template<typename T>
+void f0(T t) {
+ ++t; // expected-error{{cannot increment}}
+}
+
+template void f0(int);
+template void f0<long>(long);
+template void f0<>(unsigned);
+template void f0(int C::*); // expected-note{{instantiation}}
+
+// Explicitly instantiate a member template specialization
+template<typename T>
+struct X1 {
+ template<typename U>
+ struct Inner {
+ T member1;
+ U member2; // expected-error{{incomplete}}
+ };
+
+ template<typename U>
+ void f(T& t, U u) {
+ t = u; // expected-error{{incompatible}}
+ }
+};
+
+template struct X1<int>::Inner<float>;
+template struct X1<int>::Inner<double>;
+template struct X1<int>::Inner<void>; // expected-note{{instantiation}}
+
+template void X1<int>::f(int&, float);
+template void X1<int>::f<long>(int&, long);
+template void X1<int>::f<>(int&, double);
+template void X1<int>::f<>(int&, int*); // expected-note{{instantiation}}
+
+// Explicitly instantiate members of a class template
+struct Incomplete; // expected-note{{forward declaration}}
+struct NonDefaultConstructible { // expected-note{{candidate constructor (the implicit copy constructor) not viable}}
+ NonDefaultConstructible(int); // expected-note{{candidate constructor}}
+};
+
+template<typename T, typename U>
+struct X2 {
+ void f(T &t, U u) {
+ t = u; // expected-error{{incompatible}}
+ }
+
+ struct Inner {
+ T member1;
+ U member2; // expected-error{{incomplete}}
+ };
+
+ static T static_member1;
+ static U static_member2;
+};
+
+template<typename T, typename U>
+T X2<T, U>::static_member1 = 17; // expected-error{{cannot initialize}}
+
+template<typename T, typename U>
+U X2<T, U>::static_member2; // expected-error{{no matching}}
+
+template void X2<int, float>::f(int &, float);
+template void X2<int, float>::f(int &, double); // expected-error{{does not refer}}
+template void X2<int, int*>::f(int&, int*); // expected-note{{instantiation}}
+
+template struct X2<int, float>::Inner;
+template struct X2<int, Incomplete>::Inner; // expected-note{{instantiation}}
+
+template int X2<int, float>::static_member1;
+template int* X2<int*, float>::static_member1; // expected-note{{instantiation}}
+template
+ NonDefaultConstructible X2<NonDefaultConstructible, int>::static_member1;
+
+template
+ NonDefaultConstructible X2<int, NonDefaultConstructible>::static_member2; // expected-note{{instantiation}}
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p10.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p10.cpp
new file mode 100644
index 0000000..290a874
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p10.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+struct X0 {
+ void f(T&);
+
+ struct Inner;
+
+ static T static_var;
+};
+
+template<typename T>
+void X0<T>::f(T& t) {
+ t = 1; // expected-error{{incompatible type}}
+}
+
+template<typename T>
+struct X0<T>::Inner {
+ T member;
+};
+
+template<typename T>
+T X0<T>::static_var = 1; // expected-error{{cannot initialize}}
+
+extern template struct X0<void*>;
+template struct X0<void*>; // expected-note 2{{instantiation}}
+
+template struct X0<int>; // expected-note 4{{explicit instantiation definition is here}}
+
+extern template void X0<int>::f(int&); // expected-error{{follows explicit instantiation definition}}
+extern template struct X0<int>::Inner; // expected-error{{follows explicit instantiation definition}}
+extern template int X0<int>::static_var; // expected-error{{follows explicit instantiation definition}}
+extern template struct X0<int>; // expected-error{{follows explicit instantiation definition}}
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p11.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p11.cpp
new file mode 100644
index 0000000..4ca5428
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p11.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class X {
+ template <typename T> class Y {};
+};
+
+class A {
+ class B {};
+ class C {};
+};
+
+// C++0x [temp.explicit] 14.7.2/11:
+// The usual access checking rules do not apply to names used to specify
+// explicit instantiations.
+template class X::Y<A::B>;
+
+// As an extension, this rule is applied to explicit specializations as well.
+template <> class X::Y<A::C> {};
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p12.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p12.cpp
new file mode 100644
index 0000000..c756486
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p12.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+char* p = 0;
+template<class T> T g(T x = &p) { return x; }
+template int g<int>(int); // OK even though &p isn't an int.
+
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p2.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p2.cpp
new file mode 100644
index 0000000..1dfcf0c
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p2.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat %s
+
+// Example from the standard
+template<class T> class Array { void mf() { } };
+
+template class Array<char>;
+template void Array<int>::mf();
+template<class T> void sort(Array<T>& v) { /* ... */ }
+template void sort(Array<char>&);
+namespace N {
+ template<class T> void f(T&) { }
+}
+template void N::f<int>(int&);
+
+
+template<typename T>
+struct X0 {
+ struct Inner {};
+ void f() { }
+ static T value;
+};
+
+template<typename T>
+T X0<T>::value = 17;
+
+typedef X0<int> XInt;
+
+template struct XInt::Inner; // expected-warning{{template-id}}
+template void XInt::f(); // expected-warning{{template-id}}
+template int XInt::value; // expected-warning{{template-id}}
+
+namespace N {
+ template<typename T>
+ struct X1 { // expected-note{{explicit instantiation refers here}}
+ };
+
+ template<typename T>
+ void f1(T) {} // expected-note{{explicit instantiation refers here}}
+}
+using namespace N;
+
+template struct X1<int>; // expected-warning{{must occur in}}
+template void f1(int); // expected-warning{{must occur in}}
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p3-0x.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p3-0x.cpp
new file mode 100644
index 0000000..1028830
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p3-0x.cpp
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+// If the name declared in the explicit instantiation is an
+// unqualified name, the explicit instantiation shall appear in the
+// namespace where its template is declared or, if that namespace is
+// inline (7.3.1), any namespace from its enclosing namespace set.
+
+namespace has_inline_namespaces {
+ inline namespace inner {
+ template<class T> void f(T&) {}
+
+ template<class T>
+ struct X0 {
+ struct MemberClass {};
+
+ void mem_func() {}
+
+ template<typename U>
+ struct MemberClassTemplate {};
+
+ template<typename U>
+ void mem_func_template(U&) {}
+
+ static int value;
+ };
+ }
+
+ template<typename T> int X0<T>::value = 17;
+
+ struct X1 {};
+ struct X2 {};
+
+ template void f(X1&);
+ template void f<X2>(X2&);
+
+ template struct X0<X1>;
+
+ template struct X0<X2>::MemberClass;
+
+ template void X0<X2>::mem_func();
+
+ template struct X0<X2>::MemberClassTemplate<X1>;
+
+ template void X0<X2>::mem_func_template(X1&);
+
+ template int X0<X2>::value;
+}
+
+struct X3;
+struct X4;
+
+template void has_inline_namespaces::f(X3&);
+template void has_inline_namespaces::f<X4>(X4&);
+
+template struct has_inline_namespaces::X0<X3>;
+
+template struct has_inline_namespaces::X0<X4>::MemberClass;
+
+template void has_inline_namespaces::X0<X4>::mem_func();
+
+template
+struct has_inline_namespaces::X0<X4>::MemberClassTemplate<X3>;
+
+template
+void has_inline_namespaces::X0<X4>::mem_func_template(X3&);
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p3.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p3.cpp
new file mode 100644
index 0000000..38ae768
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p3.cpp
@@ -0,0 +1,81 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s
+
+// A declaration of a function template shall be in scope at the point of the
+// explicit instantiation of the function template.
+template<typename T> void f0(T);
+template void f0(int); // okay
+template<typename T> void f0(T) { }
+
+// A definition of the class or class template containing a member function
+// template shall be in scope at the point of the explicit instantiation of
+// the member function template.
+struct X0; // expected-note {{forward declaration}}
+template<typename> struct X1; // expected-note 5{{declared here}}
+
+template void X0::f0<int>(int); // expected-error {{incomplete type}}
+template void X1<int>::f0<int>(int); // expected-error {{implicit instantiation of undefined template}}
+
+// A definition of a class template or class member template shall be in scope
+// at the point of the explicit instantiation of the class template or class
+// member template.
+template struct X1<float>; // expected-error{{explicit instantiation of undefined template}}
+
+template<typename T>
+struct X2 { // expected-note 4{{refers here}}
+ template<typename U>
+ struct Inner; // expected-note{{declared here}}
+
+ struct InnerClass; // expected-note{{forward declaration}}
+};
+
+template struct X2<int>::Inner<float>; // expected-error{{explicit instantiation of undefined template}}
+
+// A definition of a class template shall be in scope at the point of an
+// explicit instantiation of a member function or a static data member of the
+// class template.
+template void X1<int>::f1(int); // expected-error {{undefined template}}
+template void X1<int>::f1<int>(int); // expected-error {{undefined template}}
+
+template int X1<int>::member; // expected-error {{undefined template}}
+
+// A definition of a member class of a class template shall be in scope at the
+// point of an explicit instantiation of the member class.
+template struct X2<float>::InnerClass; // expected-error{{undefined member}}
+
+// If the declaration of the explicit instantiation names an implicitly-declared
+// special member function (Clause 12), the program is ill-formed.
+template X2<int>::X2(); // expected-error{{not an instantiation}}
+template X2<int>::X2(const X2&); // expected-error{{not an instantiation}}
+template X2<int>::~X2(); // expected-error{{not an instantiation}}
+template X2<int> &X2<int>::operator=(const X2<int>&); // expected-error{{not an instantiation}}
+
+
+// A definition of a class template is sufficient to explicitly
+// instantiate a member of the class template which itself is not yet defined.
+namespace PR7979 {
+ template <typename T> struct S {
+ void f();
+ static void g();
+ static int i;
+ struct S2 {
+ void h();
+ };
+ };
+
+ template void S<int>::f();
+ template void S<int>::g();
+ template int S<int>::i;
+ template void S<int>::S2::h();
+
+ template <typename T> void S<T>::f() {}
+ template <typename T> void S<T>::g() {}
+ template <typename T> int S<T>::i;
+ template <typename T> void S<T>::S2::h() {}
+}
+
+namespace PR11599 {
+ template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}}
+
+ extern template class BasicStringPiece<int>; // expected-error{{explicit instantiation of undefined template 'PR11599::BasicStringPiece<int>}}
+ template class BasicStringPiece<int>;
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p4.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p4.cpp
new file mode 100644
index 0000000..09c428e
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p4.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+template<typename T> void f0(T); // expected-note{{here}}
+template void f0(int); // expected-error{{explicit instantiation of undefined function template}}
+
+template<typename T>
+struct X0 {
+ struct Inner;
+
+ void f1(); // expected-note{{here}}
+
+ static T value; // expected-note{{here}}
+};
+
+template void X0<int>::f1(); // expected-error{{explicit instantiation of undefined member function}}
+
+template int X0<int>::value; // expected-error{{explicit instantiation of undefined static data member}}
+
+template<> void f0(long); // expected-note{{previous template specialization is here}}
+template void f0(long); // expected-warning{{explicit instantiation of 'f0<long>' that occurs after an explicit specialization will be ignored}}
+
+template<> void X0<long>::f1(); // expected-note{{previous template specialization is here}}
+template void X0<long>::f1(); // expected-warning{{explicit instantiation of 'f1' that occurs after an explicit specialization will be ignored}}
+
+template<> struct X0<long>::Inner; // expected-note{{previous template specialization is here}}
+template struct X0<long>::Inner; // expected-warning{{explicit instantiation of 'Inner' that occurs after an explicit specialization will be ignored}}
+
+template<> long X0<long>::value; // expected-note{{previous template specialization is here}}
+template long X0<long>::value; // expected-warning{{explicit instantiation of 'value' that occurs after an explicit specialization will be ignored}}
+
+template<> struct X0<double>; // expected-note{{previous template specialization is here}}
+template struct X0<double>; // expected-warning{{explicit instantiation of 'X0<double>' that occurs after an explicit specialization will be ignored}}
+
+// PR 6458
+namespace test0 {
+ template <class T> class foo {
+ int compare(T x, T y);
+ };
+
+ template <> int foo<char>::compare(char x, char y);
+ template <class T> int foo<T>::compare(T x, T y) {
+ // invalid at T=char; if we get a diagnostic here, we're
+ // inappropriately instantiating this template.
+ void *ptr = x;
+ }
+ extern template class foo<char>; // expected-warning {{extern templates are a C++11 extension}}
+ template class foo<char>;
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p5.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p5.cpp
new file mode 100644
index 0000000..8422c51
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p5.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s
+
+namespace N {
+ template<class T> class Y { // expected-note{{explicit instantiation refers here}}
+ void mf() { }
+ };
+}
+
+template class Z<int>; // expected-error{{explicit instantiation of non-template class 'Z'}}
+
+// FIXME: This example from the standard is wrong; note posted to CWG reflector
+// on 10/27/2009
+using N::Y;
+template class Y<int>; // expected-warning{{must occur in}}
+
+template class N::Y<char*>;
+template void N::Y<double>::mf();
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p6.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p6.cpp
new file mode 100644
index 0000000..1382272
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p6.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<class T> class Array { /* ... */ };
+template<class T> void sort(Array<T>& v) { }
+
+// instantiate sort(Array<int>&) - template-argument deduced
+template void sort<>(Array<int>&);
+
+template void sort(Array<long>&);
+
+template<typename T, typename U> void f0(T, U*) { }
+
+template void f0<int>(int, float*);
+template void f0<>(double, float*);
+
+template<typename T> struct hash { };
+struct S {
+ bool operator==(const S&) const { return false; }
+};
+
+template<typename T> struct Hash_map {
+ void Method(const T& x) { h(x); }
+ hash<T> h;
+};
+
+Hash_map<S> *x;
+const Hash_map<S> *foo() {
+ return x;
+}
+
+template<> struct hash<S> {
+ int operator()(const S& k) const {
+ return 0;
+ }
+};
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p7.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p7.cpp
new file mode 100644
index 0000000..7398dca
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p7.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+struct X0 {
+ struct MemberClass {
+ T member; // expected-error{{with function type}}
+ };
+
+ T* f0(T* ptr) {
+ return ptr + 1; // expected-error{{pointer to the function}}
+ }
+
+ static T* static_member;
+};
+
+template<typename T>
+T* X0<T>::static_member = ((T*)0) + 1; // expected-error{{pointer to the function}}
+
+template class X0<int>; // okay
+
+template class X0<int(int)>; // expected-note 3{{requested here}}
+
+// Specialize everything, so that the explicit instantiation does not trigger
+// any diagnostics.
+template<>
+struct X0<int(long)>::MemberClass { };
+
+typedef int int_long_func(long);
+template<>
+int_long_func *X0<int_long_func>::f0(int_long_func *) { return 0; }
+
+template<>
+int_long_func *X0<int(long)>::static_member;
+
+template class X0<int(long)>;
+
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p8.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p8.cpp
new file mode 100644
index 0000000..550078a
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p8.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template<typename T>
+struct X0 {
+ struct MemberClass;
+
+ T* f0(T* ptr);
+
+ static T* static_member;
+};
+
+template class X0<int(int)>; // ok; nothing gets instantiated.
+
+template<typename T>
+struct X0<T>::MemberClass {
+ T member;
+};
+
+template<typename T>
+T* X0<T>::f0(T* ptr) {
+ return ptr + 1;
+}
+
+template<typename T>
+T* X0<T>::static_member = 0;
+
+template class X0<int>; // ok
+
+
+template<typename T>
+struct X1 {
+ enum class E {
+ e = T::error // expected-error 2{{no members}}
+ };
+};
+template struct X1<int>; // expected-note {{here}}
+
+extern template struct X1<char>; // ok
+
+template struct X1<char>; // expected-note {{here}}
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp
new file mode 100644
index 0000000..04e7df5
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -O1 -emit-llvm -std=c++11 -o - %s | FileCheck %s
+
+template<typename T>
+struct X0 {
+ void f(T &t) {
+ t = 0;
+ }
+
+ void g(T &t);
+
+ void h(T &t);
+
+ static T static_var;
+};
+
+template<typename T>
+inline void X0<T>::g(T & t) {
+ t = 0;
+}
+
+template<typename T>
+void X0<T>::h(T & t) {
+ t = 0;
+}
+
+template<typename T>
+T X0<T>::static_var = 0;
+
+extern template struct X0<int*>;
+
+int *&test(X0<int*> xi, int *ip) {
+ // CHECK: define available_externally void @_ZN2X0IPiE1fERS0_
+ xi.f(ip);
+ // CHECK: define available_externally void @_ZN2X0IPiE1gERS0_
+ xi.g(ip);
+ // CHECK: declare void @_ZN2X0IPiE1hERS0_
+ xi.h(ip);
+ return X0<int*>::static_var;
+}
+
+template<typename T>
+void f0(T& t) {
+ t = 0;
+}
+
+template<typename T>
+inline void f1(T& t) {
+ t = 0;
+}
+
+extern template void f0<>(int *&);
+extern template void f1<>(int *&);
+
+void test_f0(int *ip, float *fp) {
+ // CHECK: declare void @_Z2f0IPiEvRT_
+ f0(ip);
+ // CHECK: define linkonce_odr void @_Z2f0IPfEvRT_
+ f0(fp);
+}
+
+void test_f1(int *ip, float *fp) {
+ // CHECK: define available_externally void @_Z2f1IPiEvRT_
+ f1(ip);
+ // CHECK: define linkonce_odr void @_Z2f1IPfEvRT_
+ f1(fp);
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p9.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p9.cpp
new file mode 100644
index 0000000..8649017
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p9.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+template<typename T>
+struct X0 {
+ void f(T &t) {
+ t = 1; // expected-error{{incompatible type}}
+ }
+
+ void g(T &t);
+
+ void h(T &t);
+
+ static T static_var;
+};
+
+template<typename T>
+inline void X0<T>::g(T & t) {
+ t = 1; // expected-error{{incompatible type}}
+}
+
+template<typename T>
+void X0<T>::h(T & t) {
+ t = 1;
+}
+
+template<typename T>
+T X0<T>::static_var = 1;
+
+extern template struct X0<int*>;
+
+int *&test(X0<int*> xi, int *ip) {
+ xi.f(ip); // expected-note{{instantiation}}
+ xi.g(ip); // expected-note{{instantiation}}
+ xi.h(ip);
+ return X0<int*>::static_var;
+}
+
+template<typename T>
+void f0(T& t) {
+ t = 1; // expected-error{{incompatible type}}
+}
+
+template<typename T>
+inline void f1(T& t) {
+ t = 1; // expected-error 2{{incompatible type}}
+}
+
+extern template void f0<>(int *&);
+extern template void f1<>(int *&);
+
+void test_f0(int *ip, float *fp) {
+ f0(ip);
+ f0(fp); // expected-note{{instantiation}}
+}
+
+void test_f1(int *ip, float *fp) {
+ f1(ip); // expected-note{{instantiation}}
+ f1(fp); // expected-note{{instantiation}}
+}
diff --git a/clang/test/CXX/temp/temp.spec/temp.inst/p1.cpp b/clang/test/CXX/temp/temp.spec/temp.inst/p1.cpp
new file mode 100644
index 0000000..8684fc4
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.inst/p1.cpp
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+// The implicit specialization of a class template specialuzation causes the
+// implicit instantiation of the declarations, but not the definitions or
+// default arguments, of:
+
+// FIXME: Many omitted cases
+
+// - scoped member enumerations
+namespace ScopedEnum {
+ template<typename T> struct ScopedEnum1 {
+ enum class E {
+ e = T::error // expected-error {{'double' cannot be used prior to '::'}}
+ };
+ };
+ ScopedEnum1<int> se1; // ok
+
+ template<typename T> struct ScopedEnum2 {
+ enum class E : T { // expected-error {{non-integral type 'void *' is an invalid underlying type}}
+ e = 0
+ };
+ };
+ ScopedEnum2<void*> se2; // expected-note {{here}}
+
+ template<typename T> struct UnscopedEnum3 {
+ enum class E : T {
+ e = 4
+ };
+ int arr[(int)E::e];
+ };
+ UnscopedEnum3<int> ue3; // ok
+
+ ScopedEnum1<double>::E e1; // ok
+ ScopedEnum1<double>::E e2 = decltype(e2)::e; // expected-note {{in instantiation of enumeration 'ScopedEnum::ScopedEnum1<double>::E' requested here}}
+
+ // The behavior for enums defined within function templates is not clearly
+ // specified by the standard. We follow the rules for enums defined within
+ // class templates.
+ template<typename T>
+ int f() {
+ enum class E {
+ e = T::error
+ };
+ return (int)E();
+ }
+ int test1 = f<int>();
+
+ template<typename T>
+ int g() {
+ enum class E {
+ e = T::error // expected-error {{has no members}}
+ };
+ return E::e; // expected-note {{here}}
+ }
+ int test2 = g<int>(); // expected-note {{here}}
+}
+
+// And it cases the implicit instantiations of the definitions of:
+
+// - unscoped member enumerations
+namespace UnscopedEnum {
+ template<typename T> struct UnscopedEnum1 {
+ enum E {
+ e = T::error // expected-error {{'int' cannot be used prior to '::'}}
+ };
+ };
+ UnscopedEnum1<int> ue1; // expected-note {{here}}
+
+ template<typename T> struct UnscopedEnum2 {
+ enum E : T { // expected-error {{non-integral type 'void *' is an invalid underlying type}}
+ e = 0
+ };
+ };
+ UnscopedEnum2<void*> ue2; // expected-note {{here}}
+
+ template<typename T> struct UnscopedEnum3 {
+ enum E : T {
+ e = 4
+ };
+ int arr[E::e];
+ };
+ UnscopedEnum3<int> ue3; // ok
+
+ template<typename T>
+ int f() {
+ enum E {
+ e = T::error // expected-error {{has no members}}
+ };
+ return (int)E();
+ }
+ int test1 = f<int>(); // expected-note {{here}}
+
+ template<typename T>
+ int g() {
+ enum E {
+ e = T::error // expected-error {{has no members}}
+ };
+ return E::e;
+ }
+ int test2 = g<int>(); // expected-note {{here}}
+}
+
+// FIXME:
+//- - member anonymous unions
diff --git a/clang/test/CXX/temp/temp.spec/temp.inst/p11.cpp b/clang/test/CXX/temp/temp.spec/temp.inst/p11.cpp
new file mode 100644
index 0000000..8184071
--- /dev/null
+++ b/clang/test/CXX/temp/temp.spec/temp.inst/p11.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -verify -emit-llvm-only %s
+
+// rdar://problem/7838962
+namespace test0 {
+ template<typename T> unsigned f0() {
+ return T::MaxSize; // expected-error {{'int' cannot be used prior to '::'}}
+ };
+ template<typename T> struct A {
+ void Allocate(unsigned Alignment
+ = f0<T>()) // expected-note {{in instantiation}}
+ {}
+ };
+ void f1(A<int> x) { x.Allocate(); }
+
+}
diff --git a/clang/test/CXX/temp/temp.type/p1-0x.cpp b/clang/test/CXX/temp/temp.type/p1-0x.cpp
new file mode 100644
index 0000000..35d00c2
--- /dev/null
+++ b/clang/test/CXX/temp/temp.type/p1-0x.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+namespace Old {
+ template<template<class> class TT> struct X { };
+ template<class> struct Y { };
+ template<class T> using Z = Y<T>;
+ X<Y> y;
+ X<Z> z;
+
+ using SameType = decltype(y); // expected-note {{here}}
+ using SameType = decltype(z); // expected-error {{different types}}
+}
+
+namespace New {
+ template<class T> struct X { };
+ template<class> struct Y { };
+ template<class T> using Z = Y<T>;
+ X<Y<int>> y;
+ X<Z<int>> z;
+
+ using SameType = decltype(y);
+ using SameType = decltype(z); // ok
+}
diff --git a/clang/test/CodeCompletion/Inputs/macros.h b/clang/test/CodeCompletion/Inputs/macros.h
new file mode 100644
index 0000000..98b5ac6
--- /dev/null
+++ b/clang/test/CodeCompletion/Inputs/macros.h
@@ -0,0 +1,4 @@
+#define FOO
+#define BAR(X, Y) X, Y
+#define IDENTITY(X) X
+#define WIBBLE(...)
diff --git a/clang/test/CodeCompletion/Inputs/reserved.h b/clang/test/CodeCompletion/Inputs/reserved.h
new file mode 100644
index 0000000..fafe4ac
--- /dev/null
+++ b/clang/test/CodeCompletion/Inputs/reserved.h
@@ -0,0 +1,2 @@
+typedef int _INTEGER_TYPE;
+typedef float FLOATING_TYPE;
diff --git a/clang/test/CodeCompletion/PR9728.cpp b/clang/test/CodeCompletion/PR9728.cpp
new file mode 100644
index 0000000..91f49be
--- /dev/null
+++ b/clang/test/CodeCompletion/PR9728.cpp
@@ -0,0 +1,9 @@
+namespace N {
+struct SFoo;
+}
+
+struct brokenfile_t {
+ brokenfile_t (N::
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:6:20 %s -o - | FileCheck %s
+ // CHECK: SFoo
+
diff --git a/clang/test/CodeCompletion/call.c b/clang/test/CodeCompletion/call.c
new file mode 100644
index 0000000..8581414
--- /dev/null
+++ b/clang/test/CodeCompletion/call.c
@@ -0,0 +1,15 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+void f0(float x, float y);
+void f1();
+void test() {
+ f0(0, 0);
+ g0(0, 0);
+ f1(0, 0);
+ // RUN: %clang_cc1 -std=c89 -fsyntax-only -code-completion-at=%s:6:6 %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: f0(<#float x#>, float y)
+ // RUN: %clang_cc1 -std=c89 -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CC2 %s
+ // CHECK-CC2: f0(float x, <#float y#>)
+ // RUN: %clang_cc1 -std=c89 -fsyntax-only -code-completion-at=%s:8:6 %s -o - | FileCheck -check-prefix=CC3 %s
+ // CHECK-CC3: f1()
+}
diff --git a/clang/test/CodeCompletion/call.cpp b/clang/test/CodeCompletion/call.cpp
new file mode 100644
index 0000000..f06470f
--- /dev/null
+++ b/clang/test/CodeCompletion/call.cpp
@@ -0,0 +1,28 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+void f(float x, float y);
+void f(int i, int j, int k);
+struct X { };
+void f(X);
+namespace N {
+ struct Y {
+ Y(int = 0);
+
+ operator int() const;
+ };
+ void f(Y y, int ZZ);
+}
+typedef N::Y Y;
+void f();
+
+void test() {
+ f(Y(), 0, 0);
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
+ // CHECK-CC1: f(N::Y y, <#int ZZ#>)
+ // CHECK-CC1-NEXT: f(int i, <#int j#>, int k)
+ // CHECK-CC1-NEXT: f(float x, <#float y#>)
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CC2 %s
+ // CHECK-CC2-NOT: f(N::Y y, int ZZ)
+ // CHECK-CC2: f(int i, int j, <#int k#>)
+}
diff --git a/clang/test/CodeCompletion/enum-switch-case-qualified.cpp b/clang/test/CodeCompletion/enum-switch-case-qualified.cpp
new file mode 100644
index 0000000..e74ec9b
--- /dev/null
+++ b/clang/test/CodeCompletion/enum-switch-case-qualified.cpp
@@ -0,0 +1,32 @@
+namespace M {
+
+namespace N {
+ struct C {
+ enum Color {
+ Red,
+ Orange,
+ Yellow,
+ Green,
+ Blue,
+ Indigo,
+ Violet
+ };
+ };
+}
+
+}
+
+namespace M {
+
+void test(enum N::C::Color color) {
+ switch (color) {
+ case
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:23:8 %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: Blue : [#M::N::C::Color#]N::C::Blue
+ // CHECK-CC1-NEXT: Green : [#M::N::C::Color#]N::C::Green
+ // CHECK-CC1-NEXT: Indigo : [#M::N::C::Color#]N::C::Indigo
+ // CHECK-CC1-NEXT: Orange : [#M::N::C::Color#]N::C::Orange
+ // CHECK-CC1-NEXT: Red : [#M::N::C::Color#]N::C::Red
+ // CHECK-CC1-NEXT: Violet : [#M::N::C::Color#]N::C::Violet
+ // CHECK-CC1: Yellow : [#M::N::C::Color#]N::C::Yellow
+
diff --git a/clang/test/CodeCompletion/enum-switch-case.c b/clang/test/CodeCompletion/enum-switch-case.c
new file mode 100644
index 0000000..b83bd7f
--- /dev/null
+++ b/clang/test/CodeCompletion/enum-switch-case.c
@@ -0,0 +1,45 @@
+enum Color {
+ Red,
+ Orange,
+ Yellow,
+ Green,
+ Blue,
+ Indigo,
+ Violet
+};
+
+void test(enum Color color) {
+ switch (color) {
+ case Red:
+ break;
+
+ case Yellow:
+ break;
+
+ case Green:
+ break;
+ }
+
+ unsigned c2;
+ switch (c2) {
+ case
+ }
+
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:10 %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: Blue
+ // CHECK-CC1-NEXT: Green
+ // CHECK-CC1-NEXT: Indigo
+ // CHECK-CC1-NEXT: Orange
+ // CHECK-CC1-NEXT: Violet
+
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:25:10 %s -o - | FileCheck -check-prefix=CC2 %s
+ // CHECK-CC2: COMPLETION: Blue : [#enum Color#]Blue
+ // CHECK-CC2-NEXT: COMPLETION: c2 : [#unsigned int#]c2
+ // CHECK-CC2-NEXT: COMPLETION: color : [#enum Color#]color
+ // CHECK-CC2-NEXT: COMPLETION: Green : [#enum Color#]Green
+ // CHECK-CC2-NEXT: COMPLETION: Indigo : [#enum Color#]Indigo
+ // CHECK-CC2-NEXT: COMPLETION: Orange : [#enum Color#]Orange
+ // CHECK-CC2-NEXT: COMPLETION: Red : [#enum Color#]Red
+ // CHECK-CC2-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>)
+ // CHECK-CC2-NEXT: COMPLETION: Violet : [#enum Color#]Violet
+ // CHECK-CC2-NEXT: COMPLETION: Yellow : [#enum Color#]Yellow
diff --git a/clang/test/CodeCompletion/enum-switch-case.cpp b/clang/test/CodeCompletion/enum-switch-case.cpp
new file mode 100644
index 0000000..2677f33
--- /dev/null
+++ b/clang/test/CodeCompletion/enum-switch-case.cpp
@@ -0,0 +1,28 @@
+namespace N {
+ enum Color {
+ Red,
+ Orange,
+ Yellow,
+ Green,
+ Blue,
+ Indigo,
+ Violet
+ };
+}
+
+void test(enum N::Color color) {
+ switch (color) {
+ case N::Red:
+ break;
+
+ case N::Yellow:
+ break;
+
+ case
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:21:8 %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: Blue : [#N::Color#]N::Blue
+ // CHECK-CC1-NEXT: Green : [#N::Color#]N::Green
+ // CHECK-CC1-NEXT: Indigo : [#N::Color#]N::Indigo
+ // CHECK-CC1-NEXT: Orange : [#N::Color#]N::Orange
+ // CHECK-CC1-NEXT: Violet : [#N::Color#]N::Violet
+
diff --git a/clang/test/CodeCompletion/function-templates.cpp b/clang/test/CodeCompletion/function-templates.cpp
new file mode 100644
index 0000000..cdbbf75
--- /dev/null
+++ b/clang/test/CodeCompletion/function-templates.cpp
@@ -0,0 +1,23 @@
+namespace std {
+ template<typename RandomAccessIterator>
+ void sort(RandomAccessIterator first, RandomAccessIterator last);
+
+ template<class X, class Y>
+ X* dyn_cast(Y *Val);
+}
+
+class Foo {
+public:
+ template<typename T> T &getAs();
+};
+
+void f() {
+ std::sort(1, 2);
+ Foo().getAs<int>();
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:15:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+ // CHECK-CC1: dyn_cast<<#class X#>>(<#Y *Val#>)
+ // CHECK-CC1: sort(<#RandomAccessIterator first#>, <#RandomAccessIterator last#>
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:16:9 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+ // CHECK-CC2: getAs<<#typename T#>>()
+)
+
diff --git a/clang/test/CodeCompletion/functions.cpp b/clang/test/CodeCompletion/functions.cpp
new file mode 100644
index 0000000..fcab3dc
--- /dev/null
+++ b/clang/test/CodeCompletion/functions.cpp
@@ -0,0 +1,8 @@
+void f(int i, int j = 2, int k = 5);
+void f(float x, float y...);
+
+void test() {
+ ::
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:5 %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: f(<#int i#>{#, <#int j#>{#, <#int k#>#}#})
+ // CHECK-CC1: f(<#float x#>, <#float y, ...#>)
diff --git a/clang/test/CodeCompletion/macros.c b/clang/test/CodeCompletion/macros.c
new file mode 100644
index 0000000..0758bbf
--- /dev/null
+++ b/clang/test/CodeCompletion/macros.c
@@ -0,0 +1,34 @@
+enum Color {
+ Red, Green, Blue
+};
+
+struct Point {
+ float x, y, z;
+ enum Color color;
+};
+
+void test(struct Point *p) {
+ // RUN: %clang_cc1 -include %S/Inputs/macros.h -fsyntax-only -code-completion-macros -code-completion-at=%s:12:14 %s -o - | FileCheck -check-prefix=CC1 %s
+ switch (p->IDENTITY(color)) {
+ // RUN: %clang_cc1 -include %S/Inputs/macros.h -fsyntax-only -code-completion-macros -code-completion-at=%s:14:9 %s -o - | FileCheck -check-prefix=CC2 %s
+ case
+ }
+
+ // Run the same tests, this time with macros loaded from the PCH file.
+ // RUN: %clang_cc1 -emit-pch -o %t %S/Inputs/macros.h
+ // RUN: %clang_cc1 -include-pch %t -fsyntax-only -code-completion-macros -code-completion-at=%s:12:14 %s -o - | FileCheck -check-prefix=CC1 %s
+ // RUN: %clang_cc1 -include-pch %t -fsyntax-only -code-completion-macros -code-completion-at=%s:14:9 %s -o - | FileCheck -check-prefix=CC2 %s
+
+ // CC1: color
+ // CC1: x
+ // CC1: y
+ // CC1: z
+
+ // CC2: BAR(<#X#>, <#Y#>)
+ // CC2: Blue
+ // CC2: FOO
+ // CC2: Green
+ // CC2: IDENTITY(<#X#>)
+ // CC2: Red
+ // CC2: WIBBLE
+}
diff --git a/clang/test/CodeCompletion/member-access.c b/clang/test/CodeCompletion/member-access.c
new file mode 100644
index 0000000..f41c509
--- /dev/null
+++ b/clang/test/CodeCompletion/member-access.c
@@ -0,0 +1,12 @@
+struct Point {
+ float x;
+ float y;
+ float z;
+};
+
+void test(struct Point *p) {
+ p->
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:8:6 %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: x
+ // CHECK-CC1: y
+ // CHECK-CC1: z
diff --git a/clang/test/CodeCompletion/member-access.cpp b/clang/test/CodeCompletion/member-access.cpp
new file mode 100644
index 0000000..8f772c0
--- /dev/null
+++ b/clang/test/CodeCompletion/member-access.cpp
@@ -0,0 +1,42 @@
+struct Base1 {
+ int member1;
+ float member2;
+};
+
+struct Base2 {
+ int member1;
+ double member3;
+ void memfun1(int);
+};
+
+struct Base3 : Base1, Base2 {
+ void memfun1(float);
+ void memfun1(double) const;
+ void memfun2(int);
+};
+
+struct Derived : Base3 {
+ int member4;
+ int memfun3(int);
+};
+
+class Proxy {
+public:
+ Derived *operator->() const;
+};
+
+void test(const Proxy &p) {
+ p->
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:29:6 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+ // CHECK-CC1: Base1 : Base1::
+ // CHECK-CC1: member1 : [#int#][#Base1::#]member1
+ // CHECK-CC1: member1 : [#int#][#Base2::#]member1
+ // CHECK-CC1: member2 : [#float#][#Base1::#]member2
+ // CHECK-CC1: member3
+ // CHECK-CC1: member4
+ // CHECK-CC1: memfun1 : [#void#][#Base3::#]memfun1(<#float#>)
+ // CHECK-CC1: memfun1 : [#void#][#Base3::#]memfun1(<#double#>)[# const#]
+ // CHECK-CC1: memfun1 (Hidden) : [#void#]Base2::memfun1(<#int#>)
+ // CHECK-CC1: memfun2 : [#void#][#Base3::#]memfun2(<#int#>)
+ // CHECK-CC1: memfun3 : [#int#]memfun3(<#int#>)
+
diff --git a/clang/test/CodeCompletion/namespace-alias.cpp b/clang/test/CodeCompletion/namespace-alias.cpp
new file mode 100644
index 0000000..efbf996
--- /dev/null
+++ b/clang/test/CodeCompletion/namespace-alias.cpp
@@ -0,0 +1,20 @@
+namespace N4 {
+ namespace N3 { }
+}
+
+class N3;
+
+namespace N2 {
+ namespace I1 { }
+ namespace I4 = I1;
+ namespace I5 { }
+ namespace I1 { }
+
+ namespace New =
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:18 %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: I1
+ // CHECK-CC1: I4
+ // CHECK-CC1: I5
+ // CHECK-CC1: N2
+ // CHECK-CC1-NEXT: N4
+
diff --git a/clang/test/CodeCompletion/namespace.cpp b/clang/test/CodeCompletion/namespace.cpp
new file mode 100644
index 0000000..ecd8480
--- /dev/null
+++ b/clang/test/CodeCompletion/namespace.cpp
@@ -0,0 +1,14 @@
+namespace N3 {
+}
+
+namespace N2 {
+ namespace I1 { }
+ namespace I4 = I1;
+ namespace I5 { }
+ namespace I1 { }
+
+ namespace
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:12 %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: I1
+ // CHECK-CC1-NEXT: I5
+
diff --git a/clang/test/CodeCompletion/nested-name-specifier.cpp b/clang/test/CodeCompletion/nested-name-specifier.cpp
new file mode 100644
index 0000000..e09a14b
--- /dev/null
+++ b/clang/test/CodeCompletion/nested-name-specifier.cpp
@@ -0,0 +1,17 @@
+namespace N {
+ struct A { };
+ namespace M {
+ struct C { };
+ };
+}
+
+namespace N {
+ struct B { };
+}
+
+N::
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:4 %s -o - | FileCheck -check-prefix=CC1 %s
+// CHECK-CC1: A
+// CHECK-CC1: B
+// CHECK-CC1: M
+
diff --git a/clang/test/CodeCompletion/objc-message.m b/clang/test/CodeCompletion/objc-message.m
new file mode 100644
index 0000000..a7b111f
--- /dev/null
+++ b/clang/test/CodeCompletion/objc-message.m
@@ -0,0 +1,35 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+@protocol FooTestProtocol
++ protocolClassMethod;
+- protocolInstanceMethod;
+@end
+@interface Foo <FooTestProtocol> {
+ void *isa;
+}
++ (int)classMethod1:a withKeyword:b;
++ (void)classMethod2;
++ new;
+- instanceMethod1;
+@end
+
+@interface Foo (FooTestCategory)
++ categoryClassMethod;
+- categoryInstanceMethod;
+@end
+
+void func() {
+ Foo *obj = [Foo new];
+ [obj xx];
+}
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:23:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: categoryClassMethod
+// CHECK-CC1: classMethod1:withKeyword:
+// CHECK-CC1: classMethod2
+// CHECK-CC1: new
+// CHECK-CC1: protocolClassMethod
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:24:8 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: categoryInstanceMethod
+// CHECK-CC2: instanceMethod1
+// CHECK-CC2: protocolInstanceMethod
diff --git a/clang/test/CodeCompletion/operator.cpp b/clang/test/CodeCompletion/operator.cpp
new file mode 100644
index 0000000..05cd768
--- /dev/null
+++ b/clang/test/CodeCompletion/operator.cpp
@@ -0,0 +1,17 @@
+class T { };
+
+typedef int Integer;
+
+namespace N { }
+
+void f() {
+ typedef float Float;
+
+ operator
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:11 %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: +
+ // CHECK-CC1: Float
+ // CHECK-CC1: Integer
+ // CHECK-CC1: N
+ // CHECK-CC1: short
+ // CHECK-CC1: T
diff --git a/clang/test/CodeCompletion/ordinary-name.c b/clang/test/CodeCompletion/ordinary-name.c
new file mode 100644
index 0000000..dda7bb0
--- /dev/null
+++ b/clang/test/CodeCompletion/ordinary-name.c
@@ -0,0 +1,17 @@
+#include <reserved.h>
+struct X { int x; };
+typedef struct t TYPEDEF;
+typedef struct t _TYPEDEF;
+void foo() {
+ int y;
+ // RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+ // CHECK-CC1: _Imaginary
+ // CHECK-CC1-NOT: _INTEGER_TYPE;
+ // CHECK-CC1: _TYPEDEF
+ // CHECK-CC1: FLOATING_TYPE
+ // CHECK-CC1: foo
+ // CHECK-CC1: TYPEDEF
+ // CHECK-CC1: y
+
+ // PR8744
+ // RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -code-completion-at=%s:1:11 %s
diff --git a/clang/test/CodeCompletion/ordinary-name.cpp b/clang/test/CodeCompletion/ordinary-name.cpp
new file mode 100644
index 0000000..d0b09b5
--- /dev/null
+++ b/clang/test/CodeCompletion/ordinary-name.cpp
@@ -0,0 +1,229 @@
+struct X { int x; };
+void z(int);
+typedef struct t TYPEDEF;
+
+void foo() {
+ int y = 17;
+ // RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -code-completion-patterns -code-completion-at=%s:6:14 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+ // CHECK-CC1: COMPLETION: bool
+ // CHECK-CC1-NEXT: COMPLETION: char
+ // CHECK-CC1-NEXT: COMPLETION: class
+ // CHECK-CC1-NEXT: COMPLETION: const
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : const_cast<<#type#>>(<#expression#>)
+ // CHECK-CC1: COMPLETION: Pattern : [#void#]delete <#expression#>
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : [#void#]delete [] <#expression#>
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : do{<#statements#>
+ // CHECK-CC1: COMPLETION: double
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
+ // CHECK-CC1-NEXT: COMPLETION: enum
+ // CHECK-CC1-NEXT: COMPLETION: extern
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : [#bool#]false
+ // CHECK-CC1-NEXT: COMPLETION: float
+ // CHECK-CC1-NEXT: COMPLETION: foo : [#void#]foo()
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){
+ // CHECK-CC1: COMPLETION: Pattern : goto <#label#>
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : if(<#condition#>){<#statements#>
+ // CHECK-CC1: COMPLETION: int
+ // CHECK-CC1-NEXT: COMPLETION: long
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : new <#type#>(<#expressions#>)
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : new <#type#>[<#size#>](<#expressions#>)
+ // CHECK-CC1-NEXT: COMPLETION: operator
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : reinterpret_cast<<#type#>>(<#expression#>)
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : return
+ // CHECK-CC1-NEXT: COMPLETION: short
+ // CHECK-CC1-NEXT: COMPLETION: signed
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>)
+ // CHECK-CC1-NEXT: COMPLETION: static
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : static_cast<<#type#>>(<#expression#>)
+ // CHECK-CC1-NEXT: COMPLETION: struct
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : switch(<#condition#>){
+ // CHECK-CC1: COMPLETION: t : t
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : [#void#]throw <#expression#>
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : [#bool#]true
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : try{<#statements#>
+ // CHECK-CC1: COMPLETION: TYPEDEF : TYPEDEF
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>)
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof <#expression#>
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
+ // CHECK-CC1-NEXT: COMPLETION: union
+ // CHECK-CC1-NEXT: COMPLETION: unsigned
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>
+ // CHECK-CC1-NEXT: COMPLETION: void
+ // CHECK-CC1-NEXT: COMPLETION: volatile
+ // CHECK-CC1-NEXT: COMPLETION: wchar_t
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : while(<#condition#>){<#statements#>
+ // CHECK-CC1: COMPLETION: X : X
+ // CHECK-CC1-NEXT: COMPLETION: y : [#int#]y
+ // CHECK-CC1-NEXT: COMPLETION: z : [#void#]z(<#int#>)
+
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:4:1 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+ // CHECK-CC2: COMPLETION: Pattern : asm(<#string-literal#>)
+ // CHECK-CC2-NEXT: COMPLETION: bool
+ // CHECK-CC2-NEXT: COMPLETION: char
+ // CHECK-CC2-NEXT: COMPLETION: class
+ // CHECK-CC2-NEXT: COMPLETION: const
+ // CHECK-CC2-NEXT: COMPLETION: double
+ // CHECK-CC2-NEXT: COMPLETION: enum
+ // CHECK-CC2-NEXT: COMPLETION: extern
+ // CHECK-CC2-NEXT: COMPLETION: float
+ // CHECK-CC2-NEXT: COMPLETION: inline
+ // CHECK-CC2-NEXT: COMPLETION: int
+ // CHECK-CC2-NEXT: COMPLETION: long
+ // CHECK-CC2-NEXT: COMPLETION: Pattern : namespace <#identifier#>{<#declarations#>
+ // CHECK-CC2: COMPLETION: Pattern : namespace <#name#> = <#namespace#>
+ // CHECK-CC2-NEXT: COMPLETION: operator
+ // CHECK-CC2-NEXT: COMPLETION: short
+ // CHECK-CC2-NEXT: COMPLETION: signed
+ // CHECK-CC2-NEXT: COMPLETION: static
+ // CHECK-CC2-NEXT: COMPLETION: struct
+ // CHECK-CC2-NEXT: COMPLETION: t : t
+ // CHECK-CC2-NEXT: COMPLETION: Pattern : template <#declaration#>
+ // CHECK-CC2-NEXT: COMPLETION: Pattern : template<<#parameters#>>
+ // CHECK-CC2-NEXT: COMPLETION: TYPEDEF : TYPEDEF
+ // CHECK-CC2-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>
+ // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+ // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof <#expression#>
+ // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
+ // CHECK-CC2-NEXT: COMPLETION: union
+ // CHECK-CC2-NEXT: COMPLETION: unsigned
+ // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>
+ // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>
+ // CHECK-CC2-NEXT: COMPLETION: void
+ // CHECK-CC2-NEXT: COMPLETION: volatile
+ // CHECK-CC2-NEXT: COMPLETION: wchar_t
+ // CHECK-CC2-NEXT: COMPLETION: X : X
+
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:1:19 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+ // CHECK-CC3: COMPLETION: bool
+ // CHECK-CC3-NEXT: COMPLETION: char
+ // CHECK-CC3-NEXT: COMPLETION: class
+ // CHECK-CC3-NEXT: COMPLETION: const
+ // CHECK-CC3-NEXT: COMPLETION: double
+ // CHECK-CC3-NEXT: COMPLETION: enum
+ // CHECK-CC3-NEXT: COMPLETION: explicit
+ // CHECK-CC3-NEXT: COMPLETION: extern
+ // CHECK-CC3-NEXT: COMPLETION: float
+ // CHECK-CC3-NEXT: COMPLETION: friend
+ // CHECK-CC3-NEXT: COMPLETION: inline
+ // CHECK-CC3-NEXT: COMPLETION: int
+ // CHECK-CC3-NEXT: COMPLETION: long
+ // CHECK-CC3-NEXT: COMPLETION: mutable
+ // CHECK-CC3-NEXT: COMPLETION: operator
+ // CHECK-CC3-NEXT: COMPLETION: Pattern : private:
+ // CHECK-CC3-NEXT: COMPLETION: Pattern : protected:
+ // CHECK-CC3-NEXT: COMPLETION: Pattern : public:
+ // CHECK-CC3-NEXT: COMPLETION: short
+ // CHECK-CC3-NEXT: COMPLETION: signed
+ // CHECK-CC3-NEXT: COMPLETION: static
+ // CHECK-CC3-NEXT: COMPLETION: struct
+ // CHECK-CC3-NEXT: COMPLETION: Pattern : template<<#parameters#>>
+ // CHECK-CC3-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>
+ // CHECK-CC3-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+ // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof <#expression#>
+ // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof(<#type#>)
+ // CHECK-CC3-NEXT: COMPLETION: union
+ // CHECK-CC3-NEXT: COMPLETION: unsigned
+ // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>
+ // CHECK-CC3-NEXT: COMPLETION: virtual
+ // CHECK-CC3-NEXT: COMPLETION: void
+ // CHECK-CC3-NEXT: COMPLETION: volatile
+ // CHECK-CC3-NEXT: COMPLETION: wchar_t
+ // CHECK-CC3-NEXT: COMPLETION: X : X
+
+ // RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -code-completion-patterns -code-completion-at=%s:6:11 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+ // CHECK-CC4: COMPLETION: bool
+ // CHECK-CC4-NEXT: COMPLETION: char
+ // CHECK-CC4-NEXT: COMPLETION: class
+ // CHECK-CC4-NEXT: COMPLETION: const
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : const_cast<<#type#>>(<#expression#>)
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : [#void#]delete <#expression#>
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : [#void#]delete [] <#expression#>
+ // CHECK-CC4-NEXT: COMPLETION: double
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
+ // CHECK-CC4-NEXT: COMPLETION: enum
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : [#bool#]false
+ // CHECK-CC4-NEXT: COMPLETION: float
+ // CHECK-CC4-NEXT: COMPLETION: foo : [#void#]foo()
+ // CHECK-CC4-NEXT: COMPLETION: int
+ // CHECK-CC4-NEXT: COMPLETION: long
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : new <#type#>(<#expressions#>)
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : new <#type#>[<#size#>](<#expressions#>)
+ // CHECK-CC4-NEXT: COMPLETION: operator
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : reinterpret_cast<<#type#>>(<#expression#>)
+ // CHECK-CC4-NEXT: COMPLETION: short
+ // CHECK-CC4-NEXT: COMPLETION: signed
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>)
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : static_cast<<#type#>>(<#expression#>)
+ // CHECK-CC4-NEXT: COMPLETION: struct
+ // CHECK-CC4-NEXT: COMPLETION: t : t
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : [#void#]throw <#expression#>
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : [#bool#]true
+ // CHECK-CC4-NEXT: COMPLETION: TYPEDEF : TYPEDEF
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>)
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : typeof <#expression#>
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : typeof(<#type#>)
+ // CHECK-CC4-NEXT: COMPLETION: union
+ // CHECK-CC4-NEXT: COMPLETION: unsigned
+ // CHECK-CC4-NEXT: COMPLETION: void
+ // CHECK-CC4-NEXT: COMPLETION: volatile
+ // CHECK-CC4-NEXT: COMPLETION: wchar_t
+ // CHECK-CC4-NEXT: COMPLETION: X : X
+ // CHECK-CC4-NEXT: COMPLETION: y : [#int#]y
+ // CHECK-CC4-NEXT: COMPLETION: z : [#void#]z(<#int#>)
+
+ // RUN: %clang_cc1 -fsyntax-only -fno-rtti -code-completion-patterns -code-completion-at=%s:6:14 %s -o - | FileCheck -check-prefix=CHECK-NO-RTTI %s
+ // CHECK-NO-RTTI: COMPLETION: bool
+ // CHECK-NO-RTTI-NEXT: COMPLETION: char
+ // CHECK-NO-RTTI-NEXT: COMPLETION: class
+ // CHECK-NO-RTTI-NEXT: COMPLETION: const
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : const_cast<<#type#>>(<#expression#>)
+ // CHECK-NO-RTTI: COMPLETION: Pattern : [#void#]delete <#expression#>
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : [#void#]delete [] <#expression#>
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : do{<#statements#>
+ // CHECK-NO-RTTI: COMPLETION: double
+ // CHECK-NO-RTTI-NOT: dynamic_cast
+ // CHECK-NO-RTTI: COMPLETION: enum
+ // CHECK-NO-RTTI-NEXT: COMPLETION: extern
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : [#bool#]false
+ // CHECK-NO-RTTI-NEXT: COMPLETION: float
+ // CHECK-NO-RTTI-NEXT: COMPLETION: foo : [#void#]foo()
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){
+ // CHECK-NO-RTTI: COMPLETION: Pattern : goto <#label#>
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : if(<#condition#>){<#statements#>
+ // CHECK-NO-RTTI: COMPLETION: int
+ // CHECK-NO-RTTI-NEXT: COMPLETION: long
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : new <#type#>(<#expressions#>)
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : new <#type#>[<#size#>](<#expressions#>)
+ // CHECK-NO-RTTI-NEXT: COMPLETION: operator
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : reinterpret_cast<<#type#>>(<#expression#>)
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : return
+ // CHECK-NO-RTTI-NEXT: COMPLETION: short
+ // CHECK-NO-RTTI-NEXT: COMPLETION: signed
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>)
+ // CHECK-NO-RTTI-NEXT: COMPLETION: static
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : static_cast<<#type#>>(<#expression#>)
+ // CHECK-NO-RTTI-NEXT: COMPLETION: struct
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : switch(<#condition#>){
+ // CHECK-NO-RTTI: COMPLETION: t : t
+ // CHECK-NO-RTTI-NOT: throw
+ // CHECK-NO-RTTI: COMPLETION: Pattern : [#bool#]true
+ // CHECK-NO-RTTI-NOT: try
+ // CHECK-NO-RTTI: COMPLETION: TYPEDEF : TYPEDEF
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>
+ // CHECK-NO-RTTI-NOT: typeid
+ // CHECK-NO-RTTI: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof <#expression#>
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
+ // CHECK-NO-RTTI-NEXT: COMPLETION: union
+ // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#>
+ // CHECK-NO-RTTI-NEXT: COMPLETION: void
+ // CHECK-NO-RTTI-NEXT: COMPLETION: volatile
+ // CHECK-NO-RTTI-NEXT: COMPLETION: wchar_t
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : while(<#condition#>){<#statements#>
+ // CHECK-NO-RTTI: COMPLETION: X : X
+ // CHECK-NO-RTTI-NEXT: COMPLETION: y : [#int#]y
+ // CHECK-NO-RTTI-NEXT: COMPLETION: z : [#void#]z(<#int#>)
diff --git a/clang/test/CodeCompletion/preamble.c b/clang/test/CodeCompletion/preamble.c
new file mode 100644
index 0000000..f322e09
--- /dev/null
+++ b/clang/test/CodeCompletion/preamble.c
@@ -0,0 +1,7 @@
+#include "some_struct.h"
+void foo() {
+ struct X x;
+ x.
+
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:4:5 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: FieldDecl:{ResultType int}{TypedText m} (35) (parent: StructDecl 'X')
diff --git a/clang/test/CodeCompletion/some_struct.h b/clang/test/CodeCompletion/some_struct.h
new file mode 100644
index 0000000..63aa2a3
--- /dev/null
+++ b/clang/test/CodeCompletion/some_struct.h
@@ -0,0 +1 @@
+struct X { int m; };
diff --git a/clang/test/CodeCompletion/stdin.c b/clang/test/CodeCompletion/stdin.c
new file mode 100644
index 0000000..46495b2
--- /dev/null
+++ b/clang/test/CodeCompletion/stdin.c
@@ -0,0 +1,7 @@
+enum X { x };
+enum Y { y };
+
+enum
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=-:4:6 < %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: X
+ // CHECK-CC1: Y
diff --git a/clang/test/CodeCompletion/tag.c b/clang/test/CodeCompletion/tag.c
new file mode 100644
index 0000000..6ad2988
--- /dev/null
+++ b/clang/test/CodeCompletion/tag.c
@@ -0,0 +1,12 @@
+enum X { x };
+enum Y { y };
+struct Z { };
+
+void X();
+
+void test() {
+ enum X { x };
+ enum
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:9:7 %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: X
+ // CHECK-CC1: Y
diff --git a/clang/test/CodeCompletion/tag.cpp b/clang/test/CodeCompletion/tag.cpp
new file mode 100644
index 0000000..03fc0fd
--- /dev/null
+++ b/clang/test/CodeCompletion/tag.cpp
@@ -0,0 +1,27 @@
+class X { };
+struct Y { };
+
+namespace N {
+ template<typename> class Z;
+}
+
+namespace M {
+ class A;
+}
+using M::A;
+
+namespace N {
+ class Y;
+
+ void test() {
+ class
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:17:10 %s -o - | FileCheck -check-prefix=CC1 %s
+ // FIXME: the redundant Y is really annoying... it needs qualification to
+ // actually be useful. Here, it just looks redundant :(
+ // CHECK-CC1: A
+ // CHECK-CC1: M : M::
+ // CHECK-CC1: N : N::
+ // CHECK-CC1: X
+ // CHECK-CC1: Y
+ // CHECK-CC1: Y
+ // CHECK-CC1: Z
diff --git a/clang/test/CodeCompletion/templates.cpp b/clang/test/CodeCompletion/templates.cpp
new file mode 100644
index 0000000..32a7b21
--- /dev/null
+++ b/clang/test/CodeCompletion/templates.cpp
@@ -0,0 +1,28 @@
+namespace std {
+ template<typename T>
+ class allocator {
+ public:
+ void in_base();
+ };
+
+ template<typename T, typename Alloc = std::allocator<T> >
+ class vector : Alloc {
+ public:
+ void foo();
+ void stop();
+ };
+ template<typename Alloc> class vector<bool, Alloc>;
+}
+
+void f() {
+ std::vector<int> v;
+ v.foo();
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:18:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+ // CHECK-CC1: allocator<<#typename T#>>
+ // CHECK-CC1-NEXT: vector<<#typename T#>{#, <#typename Alloc#>#}>
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:5 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+ // CHECK-CC2: foo
+ // CHECK-CC2: in_base
+ // CHECK-CC2: stop
+
+
diff --git a/clang/test/CodeCompletion/truncation.c b/clang/test/CodeCompletion/truncation.c
new file mode 100644
index 0000000..473e858
--- /dev/null
+++ b/clang/test/CodeCompletion/truncation.c
@@ -0,0 +1,15 @@
+#include "truncation.c.h"
+
+/* foo */
+
+struct
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s.h:4:8 -o - %s | FileCheck -check-prefix=CC1 %s
+// CHECK-CC1: X
+// CHECK-CC1-NEXT: Y
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:8 -o - %s | FileCheck -check-prefix=CC2 %s
+// CHECK-CC2: X
+// CHECK-CC2: Xa
+// CHECK-CC2: Y
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:3:3 -o - %s
diff --git a/clang/test/CodeCompletion/truncation.c.h b/clang/test/CodeCompletion/truncation.c.h
new file mode 100644
index 0000000..a5ebbac
--- /dev/null
+++ b/clang/test/CodeCompletion/truncation.c.h
@@ -0,0 +1,5 @@
+struct X { };
+struct Y { };
+
+struct Xa { };
+
diff --git a/clang/test/CodeCompletion/using-namespace.cpp b/clang/test/CodeCompletion/using-namespace.cpp
new file mode 100644
index 0000000..eb1c2bd
--- /dev/null
+++ b/clang/test/CodeCompletion/using-namespace.cpp
@@ -0,0 +1,20 @@
+namespace N4 {
+ namespace N3 { }
+}
+
+class N3;
+
+namespace N2 {
+ namespace I1 { }
+ namespace I4 = I1;
+ namespace I5 { }
+ namespace I1 { }
+
+ void foo() {
+ using namespace
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:14:20 %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: I1
+ // CHECK-CC1: I4
+ // CHECK-CC1: I5
+ // CHECK-CC1: N2
+ // CHECK-CC1-NEXT: N4
diff --git a/clang/test/CodeCompletion/using.cpp b/clang/test/CodeCompletion/using.cpp
new file mode 100644
index 0000000..b84aa26
--- /dev/null
+++ b/clang/test/CodeCompletion/using.cpp
@@ -0,0 +1,24 @@
+namespace N4 {
+ namespace N3 { }
+}
+
+class N3;
+
+namespace N2 {
+ namespace I1 { }
+ namespace I4 = I1;
+ namespace I5 { }
+ namespace I1 { }
+
+ void foo() {
+ int N3;
+
+ using
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:16:10 %s -o - | FileCheck -check-prefix=CC1 %s
+ // CHECK-CC1: I1
+ // CHECK-CC1: I4
+ // CHECK-CC1: I5
+ // CHECK-CC1: N2
+ // CHECK-CC1: N3
+ // CHECK-CC1-NEXT: N4
+
diff --git a/clang/test/CodeGen/2002-01-23-LoadQISIReloadFailure.c b/clang/test/CodeGen/2002-01-23-LoadQISIReloadFailure.c
new file mode 100644
index 0000000..ec454c8
--- /dev/null
+++ b/clang/test/CodeGen/2002-01-23-LoadQISIReloadFailure.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* Regression test. Just compile .c -> .ll to test */
+int foo(void) {
+ unsigned char *pp;
+ unsigned w_cnt;
+
+ w_cnt += *pp;
+
+ return w_cnt;
+}
diff --git a/clang/test/CodeGen/2002-01-24-ComplexSpaceInType.c b/clang/test/CodeGen/2002-01-24-ComplexSpaceInType.c
new file mode 100644
index 0000000..9af533d
--- /dev/null
+++ b/clang/test/CodeGen/2002-01-24-ComplexSpaceInType.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+// This caused generation of the following type name:
+// %Array = uninitialized global [10 x %complex int]
+//
+// which caused problems because of the space int the complex int type
+//
+
+struct { int X, Y; } Array[10];
+
+void foo() {}
diff --git a/clang/test/CodeGen/2002-01-24-HandleCallInsnSEGV.c b/clang/test/CodeGen/2002-01-24-HandleCallInsnSEGV.c
new file mode 100644
index 0000000..739a841
--- /dev/null
+++ b/clang/test/CodeGen/2002-01-24-HandleCallInsnSEGV.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+void *dlclose(void*);
+
+void ap_os_dso_unload(void *handle)
+{
+ dlclose(handle);
+ return; /* This return triggers the bug: Weird */
+}
diff --git a/clang/test/CodeGen/2002-02-13-ConditionalInCall.c b/clang/test/CodeGen/2002-02-13-ConditionalInCall.c
new file mode 100644
index 0000000..d389371
--- /dev/null
+++ b/clang/test/CodeGen/2002-02-13-ConditionalInCall.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* Test problem where bad code was generated with a ?: statement was
+ in a function call argument */
+
+void foo(int, double, float);
+
+void bar(int x) {
+ foo(x, x ? 1.0 : 12.5, 1.0f);
+}
+
diff --git a/clang/test/CodeGen/2002-02-13-ReloadProblem.c b/clang/test/CodeGen/2002-02-13-ReloadProblem.c
new file mode 100644
index 0000000..da7f5e4
--- /dev/null
+++ b/clang/test/CodeGen/2002-02-13-ReloadProblem.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* This triggered a problem in reload, fixed by disabling most of the
+ * steps of compilation in GCC. Before this change, the code went through
+ * the entire backend of GCC, even though it was unnecessary for LLVM output
+ * now it is skipped entirely, and since reload doesn't run, it can't cause
+ * a problem.
+ */
+
+extern int tolower(int);
+
+const char *rangematch(const char *pattern, int test, int c) {
+
+ if ((c <= test) | (tolower(c) <= tolower((unsigned char)test)))
+ return 0;
+
+ return pattern;
+}
diff --git a/clang/test/CodeGen/2002-02-13-TypeVarNameCollision.c b/clang/test/CodeGen/2002-02-13-TypeVarNameCollision.c
new file mode 100644
index 0000000..c76aef0
--- /dev/null
+++ b/clang/test/CodeGen/2002-02-13-TypeVarNameCollision.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* This testcase causes a symbol table collision. Type names and variable
+ * names should be in distinct namespaces
+ */
+
+typedef struct foo {
+ int X, Y;
+} FOO;
+
+static FOO foo[100];
+
+int test() {
+ return foo[4].Y;
+}
+
diff --git a/clang/test/CodeGen/2002-02-13-UnnamedLocal.c b/clang/test/CodeGen/2002-02-13-UnnamedLocal.c
new file mode 100644
index 0000000..58a9f5a
--- /dev/null
+++ b/clang/test/CodeGen/2002-02-13-UnnamedLocal.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* Testcase for a problem where GCC allocated xqic to a register,
+ * and did not have a VAR_DECL that explained the stack slot to LLVM.
+ * Now the LLVM code synthesizes a stack slot if one is presented that
+ * has not been previously recognized. This is where alloca's named
+ * 'local' come from now.
+ */
+
+typedef struct {
+ short x;
+} foostruct;
+
+int foo(foostruct ic);
+
+void test() {
+ foostruct xqic;
+ foo(xqic);
+}
+
+
diff --git a/clang/test/CodeGen/2002-02-14-EntryNodePreds.c b/clang/test/CodeGen/2002-02-14-EntryNodePreds.c
new file mode 100644
index 0000000..60d1104
--- /dev/null
+++ b/clang/test/CodeGen/2002-02-14-EntryNodePreds.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* GCC Used to generate code that contained a branch to the entry node of
+ * the do_merge function. This is illegal LLVM code. To fix this, GCC now
+ * inserts an entry node regardless of whether or not it has to insert allocas.
+ */
+
+struct edge_rec
+{
+ struct VERTEX *v;
+ struct edge_rec *next;
+ int wasseen;
+ int more_data;
+};
+
+typedef struct edge_rec *QUAD_EDGE;
+
+typedef struct {
+ QUAD_EDGE left, right;
+} EDGE_PAIR;
+
+struct EDGE_STACK {
+ int ptr;
+ QUAD_EDGE *elts;
+ int stack_size;
+};
+
+int do_merge(QUAD_EDGE ldo, QUAD_EDGE rdo) {
+ int lvalid;
+ QUAD_EDGE basel,rcand;
+ while (1) {
+ if (!lvalid) {
+ return (int)basel->next;
+ }
+ }
+}
+
diff --git a/clang/test/CodeGen/2002-02-16-RenamingTest.c b/clang/test/CodeGen/2002-02-16-RenamingTest.c
new file mode 100644
index 0000000..bb23e68
--- /dev/null
+++ b/clang/test/CodeGen/2002-02-16-RenamingTest.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* test that locals are renamed with . notation */
+
+void abc(void *);
+
+void Test5(double X) {
+ abc(&X);
+ {
+ int X;
+ abc(&X);
+ {
+ float X;
+ abc(&X);
+ }
+ }
+}
+
diff --git a/clang/test/CodeGen/2002-02-17-ArgumentAddress.c b/clang/test/CodeGen/2002-02-17-ArgumentAddress.c
new file mode 100644
index 0000000..d1ad6a8
--- /dev/null
+++ b/clang/test/CodeGen/2002-02-17-ArgumentAddress.c
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+int test(int X) {
+ return X;
+}
+
+void abc(int *X);
+int def(int Y, int Z) {
+ abc(&Z);
+ return Y;
+}
+
+struct Test { short X, x; int Y, Z; };
+
+int Testing(struct Test *A) {
+ return A->X+A->Y;
+}
+
+int Test2(int X, struct Test A, int Y) {
+ return X+Y+A.X+A.Y;
+}
+int Test3(struct Test A, struct Test B) {
+ return A.X+A.Y+B.Y+B.Z;
+}
+
+struct Test Test4(struct Test A) {
+ return A;
+}
+
+int Test6() {
+ int B[200];
+ return B[4];
+}
+
+struct STest2 { int X; short Y[4]; double Z; };
+
+struct STest2 Test7(struct STest2 X) {
+ return X;
+}
diff --git a/clang/test/CodeGen/2002-02-18-64bitConstant.c b/clang/test/CodeGen/2002-02-18-64bitConstant.c
new file mode 100644
index 0000000..95da72d
--- /dev/null
+++ b/clang/test/CodeGen/2002-02-18-64bitConstant.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* GCC wasn't handling 64 bit constants right fixed */
+
+int printf(const char * restrict format, ...);
+
+int main() {
+ long long Var = 123455678902ll;
+ printf("%lld\n", Var);
+}
diff --git a/clang/test/CodeGen/2002-02-18-StaticData.c b/clang/test/CodeGen/2002-02-18-StaticData.c
new file mode 100644
index 0000000..d0cf524
--- /dev/null
+++ b/clang/test/CodeGen/2002-02-18-StaticData.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+double FOO = 17;
+double BAR = 12.0;
+float XX = 12.0f;
+
+static char *procnames[] = {
+ "EXIT"
+};
+
+void *Data[] = { &FOO, &BAR, &XX };
+
diff --git a/clang/test/CodeGen/2002-03-11-LargeCharInString.c b/clang/test/CodeGen/2002-03-11-LargeCharInString.c
new file mode 100644
index 0000000..9270873
--- /dev/null
+++ b/clang/test/CodeGen/2002-03-11-LargeCharInString.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+int strcmp(const char *s1, const char *s2);
+
+int test(char *X) {
+ /* LLVM-GCC used to emit:
+ %.LC0 = internal global [3 x sbyte] c"\1F\FFFFFF8B\00"
+ */
+ return strcmp(X, "\037\213");
+}
diff --git a/clang/test/CodeGen/2002-03-12-ArrayInitialization.c b/clang/test/CodeGen/2002-03-12-ArrayInitialization.c
new file mode 100644
index 0000000..f05b838
--- /dev/null
+++ b/clang/test/CodeGen/2002-03-12-ArrayInitialization.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* GCC would generate bad code if not enough initializers are
+ specified for an array.
+ */
+
+int a[10] = { 0, 2};
+
+char str[10] = "x";
+
+void *Arr[5] = { 0, 0 };
+
+float F[12] = { 1.23f, 34.7f };
+
+struct Test { int X; double Y; };
+
+struct Test Array[10] = { { 2, 12.0 }, { 3, 24.0 } };
+
+int B[4][4] = { { 1, 2, 3, 4}, { 5, 6, 7 }, { 8, 9 } };
diff --git a/clang/test/CodeGen/2002-03-12-StructInitialize.c b/clang/test/CodeGen/2002-03-12-StructInitialize.c
new file mode 100644
index 0000000..1316fbb
--- /dev/null
+++ b/clang/test/CodeGen/2002-03-12-StructInitialize.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+typedef struct Connection_Type {
+ long to;
+ char type[10];
+ long length;
+} Connection;
+
+Connection link[3]
+= { {1, "link1", 10},
+ {2, "link2", 20},
+ {3, "link3", 30} };
+
diff --git a/clang/test/CodeGen/2002-03-12-StructInitializer.c b/clang/test/CodeGen/2002-03-12-StructInitializer.c
new file mode 100644
index 0000000..a65675b
--- /dev/null
+++ b/clang/test/CodeGen/2002-03-12-StructInitializer.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* GCC was not emitting string constants of the correct length when
+ * embedded into a structure field like this. It thought the strlength
+ * was -1.
+ */
+
+typedef struct Connection_Type {
+ long to;
+ char type[10];
+ long length;
+} Connection;
+
+Connection link[3]
+= { {1, "link1", 10},
+ {2, "link2", 20},
+ {3, "link3", 30} };
+
diff --git a/clang/test/CodeGen/2002-03-14-BrokenPHINode.c b/clang/test/CodeGen/2002-03-14-BrokenPHINode.c
new file mode 100644
index 0000000..eb05859
--- /dev/null
+++ b/clang/test/CodeGen/2002-03-14-BrokenPHINode.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* GCC was generating PHI nodes with an arity < #pred of the basic block the
+ * PHI node lived in. This was breaking LLVM because the number of entries
+ * in a PHI node must equal the number of predecessors for a basic block.
+ */
+
+int trys(char *s, int x)
+{
+ int asa;
+ double Val;
+ int LLS;
+ if (x) {
+ asa = LLS + asa;
+ } else {
+ }
+ return asa+(int)Val;
+}
+
diff --git a/clang/test/CodeGen/2002-03-14-BrokenSSA.c b/clang/test/CodeGen/2002-03-14-BrokenSSA.c
new file mode 100644
index 0000000..65e5cfa
--- /dev/null
+++ b/clang/test/CodeGen/2002-03-14-BrokenSSA.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* This code used to break GCC's SSA computation code. It would create
+ uses of B & C that are not dominated by their definitions. See:
+ http://gcc.gnu.org/ml/gcc/2002-03/msg00697.html
+ */
+int bar();
+int foo()
+{
+ int a,b,c;
+
+ a = b + c;
+ b = bar();
+ c = bar();
+ return a + b + c;
+}
+
diff --git a/clang/test/CodeGen/2002-03-14-QuotesInStrConst.c b/clang/test/CodeGen/2002-03-14-QuotesInStrConst.c
new file mode 100644
index 0000000..de4bdd6
--- /dev/null
+++ b/clang/test/CodeGen/2002-03-14-QuotesInStrConst.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* GCC was not escaping quotes in string constants correctly, so this would
+ * get emitted:
+ * %.LC1 = internal global [32 x sbyte] c"*** Word "%s" on line %d is not\00"
+ */
+
+const char *Foo() {
+ return "*** Word \"%s\" on line %d is not";
+}
diff --git a/clang/test/CodeGen/2002-04-07-SwitchStmt.c b/clang/test/CodeGen/2002-04-07-SwitchStmt.c
new file mode 100644
index 0000000..cf1ec79
--- /dev/null
+++ b/clang/test/CodeGen/2002-04-07-SwitchStmt.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+int printf(const char *, ...);
+int foo();
+
+int main() {
+ while (foo()) {
+ switch (foo()) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ printf("3");
+ case 4: printf("4");
+ case 5:
+ case 6:
+ default:
+ break;
+ }
+ }
+ return 0;
+}
diff --git a/clang/test/CodeGen/2002-04-08-LocalArray.c b/clang/test/CodeGen/2002-04-08-LocalArray.c
new file mode 100644
index 0000000..9b5ef79
--- /dev/null
+++ b/clang/test/CodeGen/2002-04-08-LocalArray.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* GCC is not outputting the static array to the LLVM backend, so bad things
+ * happen. Note that if this is defined static, everything seems fine.
+ */
+double test(unsigned X) {
+ double student_t[30]={0.0 , 12.706 , 4.303 , 3.182 , 2.776 , 2.571 ,
+ 2.447 , 2.365 , 2.306 , 2.262 , 2.228 ,
+ 2.201 , 2.179 , 2.160 , 2.145 , 2.131 ,
+ 2.120 , 2.110 , 2.101 , 2.093 , 2.086 ,
+ 2.080 , 2.074 , 2.069 , 2.064 , 2.060 ,
+ 2.056 , 2.052 , 2.048 , 2.045 };
+ return student_t[X];
+}
diff --git a/clang/test/CodeGen/2002-04-09-StructRetVal.c b/clang/test/CodeGen/2002-04-09-StructRetVal.c
new file mode 100644
index 0000000..f043ab7
--- /dev/null
+++ b/clang/test/CodeGen/2002-04-09-StructRetVal.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+struct S {
+ int i;
+ short s1, s2;
+};
+
+struct S func_returning_struct(void);
+
+void loop(void) {
+ func_returning_struct();
+}
diff --git a/clang/test/CodeGen/2002-04-10-StructParameters.c b/clang/test/CodeGen/2002-04-10-StructParameters.c
new file mode 100644
index 0000000..72cebc6
--- /dev/null
+++ b/clang/test/CodeGen/2002-04-10-StructParameters.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+typedef struct {
+ char p;
+ short q;
+ char r;
+ int X;
+ short Y, Z;
+ int Q;
+} foo;
+
+int test(foo X, float);
+int testE(char,short,char,int,int,float);
+void test3(foo *X) {
+ X->q = 1;
+}
+
+void test2(foo Y) {
+ testE(Y.p, Y.q, Y.r, Y.X, Y.Y, 0.1f);
+ test(Y, 0.1f);
+ test2(Y);
+ test3(&Y);
+}
+
diff --git a/clang/test/CodeGen/2002-05-23-StaticValues.c b/clang/test/CodeGen/2002-05-23-StaticValues.c
new file mode 100644
index 0000000..b8c25b7
--- /dev/null
+++ b/clang/test/CodeGen/2002-05-23-StaticValues.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* Make sure the frontend is correctly marking static stuff as internal! */
+
+int X;
+static int Y = 12;
+
+static void foo(int Z) {
+ Y = Z;
+}
+
+void *test() {
+ foo(12);
+ return &Y;
+}
diff --git a/clang/test/CodeGen/2002-05-23-TypeNameCollision.c b/clang/test/CodeGen/2002-05-23-TypeNameCollision.c
new file mode 100644
index 0000000..c15c952
--- /dev/null
+++ b/clang/test/CodeGen/2002-05-23-TypeNameCollision.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* Testcase for when struct tag conflicts with typedef name... grr */
+
+typedef struct foo {
+ struct foo *X;
+ int Y;
+} * foo;
+
+foo F1;
+struct foo *F2;
+
+enum bar { test1, test2 };
+
+typedef float bar;
+
+enum bar B1;
+bar B2;
+
diff --git a/clang/test/CodeGen/2002-05-24-Alloca.c b/clang/test/CodeGen/2002-05-24-Alloca.c
new file mode 100644
index 0000000..30ba8bb
--- /dev/null
+++ b/clang/test/CodeGen/2002-05-24-Alloca.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+typedef __SIZE_TYPE__ size_t;
+void *alloca(size_t size);
+char *strcpy(char *restrict s1, const char *restrict s2);
+int puts(const char *s);
+int main(int argc, char **argv) {
+ char *C = (char*)alloca(argc);
+ strcpy(C, argv[0]);
+ puts(C);
+}
diff --git a/clang/test/CodeGen/2002-06-25-FWriteInterfaceFailure.c b/clang/test/CodeGen/2002-06-25-FWriteInterfaceFailure.c
new file mode 100644
index 0000000..24c67d1
--- /dev/null
+++ b/clang/test/CodeGen/2002-06-25-FWriteInterfaceFailure.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+typedef struct _IO_FILE FILE;
+extern FILE *stderr;
+int fprintf(FILE * restrict stream, const char * restrict format, ...);
+
+void test() {
+ fprintf(stderr, "testing\n");
+}
diff --git a/clang/test/CodeGen/2002-07-14-MiscListTests.c b/clang/test/CodeGen/2002-07-14-MiscListTests.c
new file mode 100644
index 0000000..901701a
--- /dev/null
+++ b/clang/test/CodeGen/2002-07-14-MiscListTests.c
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+// Test list stuff
+
+void *malloc(unsigned);
+
+// Test opaque structure support. the list type is defined later
+struct list;
+
+struct list *PassThroughList(struct list *L) {
+ return L;
+}
+
+
+// Recursive data structure tests...
+
+typedef struct list {
+ int Data;
+ struct list *Next;
+} list;
+
+list *Data;
+
+void foo() {
+ static int Foo = 0; // Test static local variable
+ Foo += 1; // Increment static variable
+
+ Data = (list*)malloc(12); // This is not a proper list allocation
+}
+
+extern list ListNode1;
+list ListNode3 = { 4, 0 };
+list ListNode2 = { 3, &ListNode3 };
+list ListNode0 = { 1, &ListNode1 };
+list ListNode1 = { 2, &ListNode2 };
+
+
+list ListArray[10];
+
+// Iterative insert fn
+void InsertIntoListTail(list **L, int Data) {
+ while (*L)
+ L = &(*L)->Next;
+ *L = (list*)malloc(sizeof(list));
+ (*L)->Data = Data;
+ (*L)->Next = 0;
+}
+
+// Recursive list search fn
+list *FindData(list *L, int Data) {
+ if (L == 0) return 0;
+ if (L->Data == Data) return L;
+ return FindData(L->Next, Data);
+}
+
+void foundIt(void);
+
+// Driver fn...
+void DoListStuff() {
+ list *MyList = 0;
+ InsertIntoListTail(&MyList, 100);
+ InsertIntoListTail(&MyList, 12);
+ InsertIntoListTail(&MyList, 42);
+ InsertIntoListTail(&MyList, 1123);
+ InsertIntoListTail(&MyList, 1213);
+
+ if (FindData(MyList, 75)) foundIt();
+ if (FindData(MyList, 42)) foundIt();
+ if (FindData(MyList, 700)) foundIt();
+}
+
diff --git a/clang/test/CodeGen/2002-07-14-MiscTests.c b/clang/test/CodeGen/2002-07-14-MiscTests.c
new file mode 100644
index 0000000..2a65124
--- /dev/null
+++ b/clang/test/CodeGen/2002-07-14-MiscTests.c
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -w -emit-llvm %s -o /dev/null
+
+/* These are random tests that I used when working on the GCC frontend
+ originally. */
+
+// test floating point comparison!
+int floatcomptest(double *X, double *Y, float *x, float *y) {
+ return *X < *Y || *x < *y;
+}
+
+extern void *malloc(unsigned);
+
+// Exposed a bug
+void *memset_impl(void *dstpp, int c, unsigned len) {
+ long long int dstp = (long long int) dstpp;
+
+ while (dstp % 4 != 0)
+ {
+ ((unsigned char *) dstp)[0] = c;
+ dstp += 1;
+ len -= 1;
+ }
+ return dstpp;
+}
+
+// TEST problem with signed/unsigned versions of the same constants being shared
+// incorrectly!
+//
+static char *temp;
+static int remaining;
+static char *localmalloc(int size) {
+ char *blah;
+
+ if (size>remaining)
+ {
+ temp = (char *) malloc(32768);
+ remaining = 32768;
+ return temp;
+ }
+ return 0;
+}
+
+typedef struct { double X; double Y; int Z; } PBVTest;
+
+PBVTest testRetStruct(float X, double Y, int Z) {
+ PBVTest T = { X, Y, Z };
+ return T;
+}
+PBVTest testRetStruct2(void); // external func no inlining
+
+
+double CallRetStruct(float X, double Y, int Z) {
+ PBVTest T = testRetStruct2();
+ return T.X+X+Y+Z;
+}
+
+
diff --git a/clang/test/CodeGen/2002-07-14-MiscTests2.c b/clang/test/CodeGen/2002-07-14-MiscTests2.c
new file mode 100644
index 0000000..ad13017
--- /dev/null
+++ b/clang/test/CodeGen/2002-07-14-MiscTests2.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+// Test ?: in function calls
+extern fp(int, char*);
+char *Ext;
+void
+__bb_exit_func (void)
+{
+ fp (12, Ext ? Ext : "<none>");
+}
+
+
diff --git a/clang/test/CodeGen/2002-07-14-MiscTests3.c b/clang/test/CodeGen/2002-07-14-MiscTests3.c
new file mode 100644
index 0000000..f7ded4e
--- /dev/null
+++ b/clang/test/CodeGen/2002-07-14-MiscTests3.c
@@ -0,0 +1,182 @@
+// RUN: %clang_cc1 -w -emit-llvm %s -o /dev/null
+
+void *malloc(unsigned);
+int puts(const char *s);
+
+struct FunStructTest {
+ int Test1;
+ char *Pointer;
+ int Array[12];
+};
+
+struct SubStruct {
+ short X, Y;
+};
+
+struct Quad {
+ int w;
+ struct SubStruct SS;
+ struct SubStruct *SSP;
+ char c;
+ int y;
+};
+
+struct Quad GlobalQuad = { 4, {1, 2}, 0, 3, 156 };
+
+typedef int (*FuncPtr)(int);
+
+unsigned PtrFunc(int (*Func)(int), int X) {
+ return Func(X);
+}
+
+char PtrFunc2(FuncPtr FuncTab[30], int Num) {
+ return FuncTab[Num]('b');
+}
+
+extern char SmallArgs2(char w, char x, long long Zrrk, char y, char z);
+extern int SomeFunc(void);
+char SmallArgs(char w, char x, char y, char z) {
+ SomeFunc();
+ return SmallArgs2(w-1, x+1, y, z, w);
+}
+
+static int F0(struct Quad Q, int i) { /* Pass Q by value */
+ struct Quad R;
+ if (i) R.SS = Q.SS;
+ Q.SSP = &R.SS;
+ Q.w = Q.y = Q.c = 1;
+ return Q.SS.Y + i + R.y - Q.c;
+}
+
+int F1(struct Quad *Q, int i) { /* Pass Q by address */
+ struct Quad R;
+#if 0
+ if (i) R.SS = Q->SS;
+#else
+ if (i) R = *Q;
+#endif
+ Q->w = Q->y = Q->c = 1;
+ return Q->SS.Y+i+R.y-Q->c;
+}
+
+
+int BadFunc(float Val) {
+ int Result;
+ if (Val > 12.345) Result = 4;
+ return Result; /* Test use of undefined value */
+}
+
+int RealFunc(void) {
+ return SomeUndefinedFunction(1, 4, 5);
+}
+
+extern int EF1(int *, char *, int *);
+
+int Func(int Param, long long Param2) {
+ int Result = Param;
+
+ {{{{
+ char c; int X;
+ EF1(&Result, &c, &X);
+ }}}
+
+ { // c & X are duplicate names!
+ char c; int X;
+ EF1(&Result, &c, &X);
+ }
+
+ }
+ return Result;
+}
+
+
+short FunFunc(long long x, char z) {
+ return x+z;
+}
+
+unsigned castTest(int X) { return X; }
+
+double TestAdd(double X, float Y) {
+ return X+Y+.5;
+}
+
+int func(int i, int j) {
+ while (i != 20)
+ i += 2;
+
+ j += func(2, i);
+ return (i * 3 + j*2)*j;
+}
+
+int SumArray(int Array[], int Num) {
+ int i, Result = 0;
+ for (i = 0; i < Num; ++i)
+ Result += Array[i];
+
+ return Result;
+}
+
+int ArrayParam(int Values[100]) {
+ return EF1((int*)Values[50], (char*)1, &Values[50]);
+}
+
+int ArrayToSum(void) {
+ int A[100], i;
+ for (i = 0; i < 100; ++i)
+ A[i] = i*4;
+
+ return A[A[0]]; //SumArray(A, 100);
+}
+
+
+int ExternFunc(long long, unsigned*, short, unsigned char);
+
+int main(int argc, char *argv[]) {
+ unsigned i;
+ puts("Hello world!\n");
+
+ ExternFunc(-1, 0, (short)argc, 2);
+ //func(argc, argc);
+
+ for (i = 0; i < 10; i++)
+ puts(argv[3]);
+ return 0;
+}
+
+double MathFunc(double X, double Y, double Z,
+ double AA, double BB, double CC, double DD,
+ double EE, double FF, double GG, double HH,
+ double aAA, double aBB, double aCC, double aDD,
+ double aEE, double aFF) {
+ return X + Y + Z + AA + BB + CC + DD + EE + FF + GG + HH
+ + aAA + aBB + aCC + aDD + aEE + aFF;
+}
+
+
+
+void strcpy(char *s1, char *s2) {
+ while (*s1++ = *s2++);
+}
+
+void strcat(char *s1, char *s2) {
+ while (*s1++);
+ s1--;
+ while (*s1++ = *s2++);
+}
+
+int strcmp(char *s1, char *s2) {
+ while (*s1++ == *s2++);
+ if (*s1 == 0) {
+ if (*s2 == 0) {
+ return 0;
+ } else {
+ return -1;
+ }
+ } else {
+ if (*s2 == 0) {
+ return 1;
+ } else {
+ return (*(--s1) - *(--s2));
+ }
+ }
+}
diff --git a/clang/test/CodeGen/2002-07-16-HardStringInit.c b/clang/test/CodeGen/2002-07-16-HardStringInit.c
new file mode 100644
index 0000000..b307359
--- /dev/null
+++ b/clang/test/CodeGen/2002-07-16-HardStringInit.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+ char auto_kibitz_list[100][20] = {
+ {"diepx"},
+ {"ferret"},
+ {"knightc"},
+ {"knightcap"}};
+
diff --git a/clang/test/CodeGen/2002-07-17-StringConstant.c b/clang/test/CodeGen/2002-07-17-StringConstant.c
new file mode 100644
index 0000000..5b86a5b
--- /dev/null
+++ b/clang/test/CodeGen/2002-07-17-StringConstant.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+char * foo() { return "\\begin{"; }
diff --git a/clang/test/CodeGen/2002-07-30-SubregSetAssertion.c b/clang/test/CodeGen/2002-07-30-SubregSetAssertion.c
new file mode 100644
index 0000000..39e97b3
--- /dev/null
+++ b/clang/test/CodeGen/2002-07-30-SubregSetAssertion.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+union X {
+ void *B;
+};
+
+union X foo() {
+ union X A;
+ A.B = (void*)123;
+ return A;
+}
diff --git a/clang/test/CodeGen/2002-07-30-UnionTest.c b/clang/test/CodeGen/2002-07-30-UnionTest.c
new file mode 100644
index 0000000..d5b92e7
--- /dev/null
+++ b/clang/test/CodeGen/2002-07-30-UnionTest.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+union X;
+struct Empty {};
+union F {};
+union Q { union Q *X; };
+union X {
+ char C;
+ int A, Z;
+ long long B;
+ void *b1;
+ struct { int A; long long Z; } Q;
+};
+
+union X foo(union X A) {
+ A.C = 123;
+ A.A = 39249;
+ //A.B = (void*)123040123321;
+ A.B = 12301230123123LL;
+ A.Z = 1;
+ return A;
+}
diff --git a/clang/test/CodeGen/2002-07-30-VarArgsCallFailure.c b/clang/test/CodeGen/2002-07-30-VarArgsCallFailure.c
new file mode 100644
index 0000000..784305d
--- /dev/null
+++ b/clang/test/CodeGen/2002-07-30-VarArgsCallFailure.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+int tcount;
+void test(char *, const char*, int);
+void foo() {
+ char Buf[10];
+ test(Buf, "n%%%d", tcount++);
+}
diff --git a/clang/test/CodeGen/2002-07-31-BadAssert.c b/clang/test/CodeGen/2002-07-31-BadAssert.c
new file mode 100644
index 0000000..512a63a
--- /dev/null
+++ b/clang/test/CodeGen/2002-07-31-BadAssert.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+typedef struct
+{
+ unsigned char type; /* Indicates, NORMAL, SUBNORMAL, etc. */
+} InternalFPF;
+
+
+static void SetInternalFPFZero(InternalFPF *dest) {
+ dest->type=0;
+}
+
+void denormalize(InternalFPF *ptr) {
+ SetInternalFPFZero(ptr);
+}
+
diff --git a/clang/test/CodeGen/2002-07-31-SubregFailure.c b/clang/test/CodeGen/2002-07-31-SubregFailure.c
new file mode 100644
index 0000000..5c7f38f
--- /dev/null
+++ b/clang/test/CodeGen/2002-07-31-SubregFailure.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+typedef union {
+ long (*ap)[4];
+} ptrs;
+
+void DoAssignIteration() {
+ ptrs abase;
+ abase.ap+=27;
+ Assignment(*abase.ap);
+}
+
+
diff --git a/clang/test/CodeGen/2002-08-02-UnionTest.c b/clang/test/CodeGen/2002-08-02-UnionTest.c
new file mode 100644
index 0000000..2be1499
--- /dev/null
+++ b/clang/test/CodeGen/2002-08-02-UnionTest.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* In this testcase, the return value of foo() is being promoted to a register
+ * which breaks stuff
+ */
+int printf(const char * restrict format, ...);
+
+union X { char X; void *B; int a, b, c, d;};
+
+union X foo() {
+ union X Global;
+ Global.B = (void*)123; /* Interesting part */
+ return Global;
+}
+
+int main() {
+ union X test = foo();
+ printf("0x%p", test.B);
+}
diff --git a/clang/test/CodeGen/2002-08-19-RecursiveLocals.c b/clang/test/CodeGen/2002-08-19-RecursiveLocals.c
new file mode 100644
index 0000000..89c67ba
--- /dev/null
+++ b/clang/test/CodeGen/2002-08-19-RecursiveLocals.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/* This testcase doesn't actually test a bug, it's just the result of me
+ * figuring out the syntax for forward declaring a static variable. */
+struct list {
+ int x;
+ struct list *Next;
+};
+
+static struct list B; /* Forward declare static */
+static struct list A = { 7, &B };
+static struct list B = { 8, &A };
+
+extern struct list D; /* forward declare normal var */
+
+struct list C = { 7, &D };
+struct list D = { 8, &C };
+
diff --git a/clang/test/CodeGen/2002-09-08-PointerShifts.c b/clang/test/CodeGen/2002-09-08-PointerShifts.c
new file mode 100644
index 0000000..7d1ba6e
--- /dev/null
+++ b/clang/test/CodeGen/2002-09-08-PointerShifts.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+int foo(int *A, unsigned X) {
+ return A[X];
+}
diff --git a/clang/test/CodeGen/2002-09-18-UnionProblem.c b/clang/test/CodeGen/2002-09-18-UnionProblem.c
new file mode 100644
index 0000000..d299c19
--- /dev/null
+++ b/clang/test/CodeGen/2002-09-18-UnionProblem.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+struct DWstruct {
+ char high, low;
+};
+
+typedef union {
+ struct DWstruct s;
+ short ll;
+} DWunion;
+
+short __udivmodhi4 (char n1, char bm) {
+ DWunion rr;
+
+ if (bm == 0)
+ {
+ rr.s.high = n1;
+ }
+ else
+ {
+ rr.s.high = bm;
+ }
+
+ return rr.ll;
+}
diff --git a/clang/test/CodeGen/2002-09-19-StarInLabel.c b/clang/test/CodeGen/2002-09-19-StarInLabel.c
new file mode 100644
index 0000000..e046e2b
--- /dev/null
+++ b/clang/test/CodeGen/2002-09-19-StarInLabel.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+extern void start() __asm__("start");
+extern void _start() __asm__("_start");
+extern void __start() __asm__("__start");
+void start() {}
+void _start() {}
+void __start() {}
+
diff --git a/clang/test/CodeGen/2002-10-12-TooManyArguments.c b/clang/test/CodeGen/2002-10-12-TooManyArguments.c
new file mode 100644
index 0000000..2324c2a
--- /dev/null
+++ b/clang/test/CodeGen/2002-10-12-TooManyArguments.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+void foo() {}
+
+void bar() {
+ foo(1, 2, 3); /* Too many arguments passed */
+}
diff --git a/clang/test/CodeGen/2002-12-15-GlobalBoolTest.c b/clang/test/CodeGen/2002-12-15-GlobalBoolTest.c
new file mode 100644
index 0000000..3c4133f
--- /dev/null
+++ b/clang/test/CodeGen/2002-12-15-GlobalBoolTest.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+_Bool X = 0;
+
diff --git a/clang/test/CodeGen/2002-12-15-GlobalConstantTest.c b/clang/test/CodeGen/2002-12-15-GlobalConstantTest.c
new file mode 100644
index 0000000..8203f56
--- /dev/null
+++ b/clang/test/CodeGen/2002-12-15-GlobalConstantTest.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+const char *W = "foo";
+const int X = 7;
+int Y = 8;
+const char * const Z = "bar";
+
diff --git a/clang/test/CodeGen/2002-12-15-GlobalRedefinition.c b/clang/test/CodeGen/2002-12-15-GlobalRedefinition.c
new file mode 100644
index 0000000..646e91e
--- /dev/null
+++ b/clang/test/CodeGen/2002-12-15-GlobalRedefinition.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+extern char algbrfile[9];
+char algbrfile[9] = "abcdefgh";
+
diff --git a/clang/test/CodeGen/2002-12-15-StructParameters.c b/clang/test/CodeGen/2002-12-15-StructParameters.c
new file mode 100644
index 0000000..f6b59de
--- /dev/null
+++ b/clang/test/CodeGen/2002-12-15-StructParameters.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+typedef struct
+{
+ void *stack;
+ unsigned size;
+ unsigned avail;
+} compile_stack_type;
+
+void foo(void*);
+void bar(compile_stack_type T, unsigned);
+
+void test() {
+ compile_stack_type CST;
+ foo(&CST);
+
+ bar(CST, 12);
+}
diff --git a/clang/test/CodeGen/2003-01-30-UnionInit.c b/clang/test/CodeGen/2003-01-30-UnionInit.c
new file mode 100644
index 0000000..98aee72
--- /dev/null
+++ b/clang/test/CodeGen/2003-01-30-UnionInit.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+union foo {
+ struct { char A, B; } X;
+ int C;
+};
+
+union foo V = { {1, 2} };
diff --git a/clang/test/CodeGen/2003-03-03-DeferredType.c b/clang/test/CodeGen/2003-03-03-DeferredType.c
new file mode 100644
index 0000000..a7a4ce3
--- /dev/null
+++ b/clang/test/CodeGen/2003-03-03-DeferredType.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+
+
+struct foo A;
+
+struct foo {
+ int x;
+double D;
+};
+
diff --git a/clang/test/CodeGen/2003-06-22-UnionCrash.c b/clang/test/CodeGen/2003-06-22-UnionCrash.c
new file mode 100644
index 0000000..eb5014c
--- /dev/null
+++ b/clang/test/CodeGen/2003-06-22-UnionCrash.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+struct Blend_Map_Entry {
+ union {
+ float Colour[5];
+ double Point_Slope[2];
+ } Vals;
+};
+
+void test(struct Blend_Map_Entry* Foo)
+{
+}
+
diff --git a/clang/test/CodeGen/2003-06-23-GCC-fold-infinite-recursion.c b/clang/test/CodeGen/2003-06-23-GCC-fold-infinite-recursion.c
new file mode 100644
index 0000000..51d4824
--- /dev/null
+++ b/clang/test/CodeGen/2003-06-23-GCC-fold-infinite-recursion.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+double Test(double A, double B, double C, double D) {
+ return -(A-B) - (C-D);
+}
+
diff --git a/clang/test/CodeGen/2003-06-26-CFECrash.c b/clang/test/CodeGen/2003-06-26-CFECrash.c
new file mode 100644
index 0000000..dd874b7
--- /dev/null
+++ b/clang/test/CodeGen/2003-06-26-CFECrash.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+typedef struct min_info {
+ long offset;
+ unsigned file_attr;
+} min_info;
+
+typedef struct Globals {
+ char answerbuf;
+ min_info info[1];
+ min_info *pInfo;
+} Uz_Globs;
+
+extern Uz_Globs G;
+
+int extract_or_test_files() {
+ G.pInfo = G.info;
+}
+
diff --git a/clang/test/CodeGen/2003-06-29-MultipleFunctionDefinition.c b/clang/test/CodeGen/2003-06-29-MultipleFunctionDefinition.c
new file mode 100644
index 0000000..99b3a7f
--- /dev/null
+++ b/clang/test/CodeGen/2003-06-29-MultipleFunctionDefinition.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=gnu89 -emit-llvm %s -o /dev/null
+
+/* This is apparently legal C.
+ */
+extern __inline__ void test() { }
+
+void test() {
+}
diff --git a/clang/test/CodeGen/2003-07-22-ArrayAccessTypeSafety.c b/clang/test/CodeGen/2003-07-22-ArrayAccessTypeSafety.c
new file mode 100644
index 0000000..d0703ef
--- /dev/null
+++ b/clang/test/CodeGen/2003-07-22-ArrayAccessTypeSafety.c
@@ -0,0 +1,7 @@
+/* RUN: %clang_cc1 %s -emit-llvm -o - | grep -v alloca | not grep bitcast
+ */
+
+void test(int* array, long long N) {
+ array[N] = N[array] = 33;
+}
+
diff --git a/clang/test/CodeGen/2003-08-06-BuiltinSetjmpLongjmp.c b/clang/test/CodeGen/2003-08-06-BuiltinSetjmpLongjmp.c
new file mode 100644
index 0000000..12bce26
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-06-BuiltinSetjmpLongjmp.c
@@ -0,0 +1,14 @@
+/* RUN: %clang_cc1 %s -emit-llvm -o - | not grep __builtin_
+ *
+ * __builtin_longjmp/setjmp should get transformed into llvm.setjmp/longjmp
+ * just like explicit setjmp/longjmp calls are.
+ */
+
+void jumpaway(int *ptr) {
+ __builtin_longjmp(ptr,1);
+}
+
+int main(void) {
+ __builtin_setjmp(0);
+ jumpaway(0);
+}
diff --git a/clang/test/CodeGen/2003-08-17-DeadCodeShortCircuit.c b/clang/test/CodeGen/2003-08-17-DeadCodeShortCircuit.c
new file mode 100644
index 0000000..031b530
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-17-DeadCodeShortCircuit.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -x c %s -emit-llvm -o /dev/null
+
+int test(_Bool pos, _Bool color) {
+ return 0;
+ return (pos && color);
+}
diff --git a/clang/test/CodeGen/2003-08-18-SigSetJmp.c b/clang/test/CodeGen/2003-08-18-SigSetJmp.c
new file mode 100644
index 0000000..1b1b18f
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-18-SigSetJmp.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o /dev/null
+
+#define _JBLEN ((9 * 2) + 3 + 16)
+typedef int sigjmp_buf[_JBLEN + 1];
+int sigsetjmp(sigjmp_buf env, int savemask);
+sigjmp_buf B;
+int foo() {
+ sigsetjmp(B, 1);
+ bar();
+}
diff --git a/clang/test/CodeGen/2003-08-18-StructAsValue.c b/clang/test/CodeGen/2003-08-18-StructAsValue.c
new file mode 100644
index 0000000..9b8b5a2
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-18-StructAsValue.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+typedef struct {
+ int op;
+} event_t;
+
+event_t test(int X) {
+ event_t foo = { 1 }, bar = { 2 };
+ return X ? foo : bar;
+}
diff --git a/clang/test/CodeGen/2003-08-20-BadBitfieldRef.c b/clang/test/CodeGen/2003-08-20-BadBitfieldRef.c
new file mode 100644
index 0000000..a001546
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-20-BadBitfieldRef.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+void foo()
+{
+ char *ap;
+ ap[1] == '-' && ap[2] == 0;
+}
+
diff --git a/clang/test/CodeGen/2003-08-20-PrototypeMismatch.c b/clang/test/CodeGen/2003-08-20-PrototypeMismatch.c
new file mode 100644
index 0000000..fa42ca5
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-20-PrototypeMismatch.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+
+static int foo(int);
+
+static int foo(C)
+char C;
+{
+ return C;
+}
+
+void test() {
+ foo(7);
+}
diff --git a/clang/test/CodeGen/2003-08-20-vfork-bug.c b/clang/test/CodeGen/2003-08-20-vfork-bug.c
new file mode 100644
index 0000000..7ec0048
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-20-vfork-bug.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+extern int vfork(void);
+test() {
+ vfork();
+}
diff --git a/clang/test/CodeGen/2003-08-21-BinOp-Type-Mismatch.c b/clang/test/CodeGen/2003-08-21-BinOp-Type-Mismatch.c
new file mode 100644
index 0000000..d86b024
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-21-BinOp-Type-Mismatch.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+struct bar;
+
+void foo()
+{
+ unsigned int frame, focus;
+ (struct bar *) focus == (focus ? ((struct bar *) frame) : 0);
+}
+
diff --git a/clang/test/CodeGen/2003-08-21-StmtExpr.c b/clang/test/CodeGen/2003-08-21-StmtExpr.c
new file mode 100644
index 0000000..39db694
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-21-StmtExpr.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+typedef struct {
+ unsigned long val;
+} structty;
+
+void bar(structty new_mask);
+static void foo() {
+ bar(({ structty mask; mask; }));
+}
+
diff --git a/clang/test/CodeGen/2003-08-21-WideString.c b/clang/test/CodeGen/2003-08-21-WideString.c
new file mode 100644
index 0000000..4071d17
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-21-WideString.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+// This bit is taken from Sema/wchar.c so we can avoid the wchar.h include.
+typedef __WCHAR_TYPE__ wchar_t;
+#if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
+ || defined(_M_X64) || defined(SHORT_WCHAR)
+ #define WCHAR_T_TYPE unsigned short
+#elif defined(__sun) || defined(__AuroraUX__)
+ #define WCHAR_T_TYPE long
+#else /* Solaris or AuroraUX. */
+ #define WCHAR_T_TYPE int
+#endif
+
+struct {
+ wchar_t *name;
+} syms = { L"NUL" };
diff --git a/clang/test/CodeGen/2003-08-23-LocalUnionTest.c b/clang/test/CodeGen/2003-08-23-LocalUnionTest.c
new file mode 100644
index 0000000..50b01e4
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-23-LocalUnionTest.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+
+union foo { int X; };
+
+int test(union foo* F) {
+ {
+ union foo { float X; } A;
+ }
+}
diff --git a/clang/test/CodeGen/2003-08-29-BitFieldStruct.c b/clang/test/CodeGen/2003-08-29-BitFieldStruct.c
new file mode 100644
index 0000000..d8995ea
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-29-BitFieldStruct.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+struct Word {
+ short bar;
+ short baz;
+ int final:1;
+ short quux;
+} *word_limit;
+
+void foo ()
+{
+ word_limit->final = (word_limit->final && word_limit->final);
+}
diff --git a/clang/test/CodeGen/2003-08-29-HugeCharConst.c b/clang/test/CodeGen/2003-08-29-HugeCharConst.c
new file mode 100644
index 0000000..cd3eb54
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-29-HugeCharConst.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+void foo() {
+ unsigned char int_latin1[] = "f\200\372b\200\343\200\340";
+}
diff --git a/clang/test/CodeGen/2003-08-29-StructLayoutBug.c b/clang/test/CodeGen/2003-08-29-StructLayoutBug.c
new file mode 100644
index 0000000..0f45fc9
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-29-StructLayoutBug.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+struct foo {
+ unsigned int I:1;
+ unsigned char J[1];
+ unsigned int K:1;
+ };
+
+void test(struct foo *X) {}
+
diff --git a/clang/test/CodeGen/2003-08-30-AggregateInitializer.c b/clang/test/CodeGen/2003-08-30-AggregateInitializer.c
new file mode 100644
index 0000000..5beb14e
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-30-AggregateInitializer.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+struct istruct {
+ unsigned char C;
+};
+
+struct foo {
+ unsigned int I:1;
+ struct istruct J;
+ unsigned char L[1];
+ unsigned int K:1;
+};
+
+struct foo F = { 1, { 7 }, { 123 } , 1 };
+
+
diff --git a/clang/test/CodeGen/2003-08-30-LargeIntegerBitfieldMember.c b/clang/test/CodeGen/2003-08-30-LargeIntegerBitfieldMember.c
new file mode 100644
index 0000000..483cb66
--- /dev/null
+++ b/clang/test/CodeGen/2003-08-30-LargeIntegerBitfieldMember.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+struct foo {
+ unsigned int I:1;
+ unsigned char J[1][123];
+ unsigned int K:1;
+ };
+
+struct foo F;
diff --git a/clang/test/CodeGen/2003-09-18-BitfieldTests.c b/clang/test/CodeGen/2003-09-18-BitfieldTests.c
new file mode 100644
index 0000000..6807f5a
--- /dev/null
+++ b/clang/test/CodeGen/2003-09-18-BitfieldTests.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -w -emit-llvm %s -o /dev/null
+
+
+typedef struct BF {
+ int A : 1;
+ char B;
+ int C : 13;
+} BF;
+
+char *test1(BF *b) {
+ return &b->B; // Must be able to address non-bitfield
+}
+
+void test2(BF *b) { // Increment and decrement operators
+ b->A++;
+ --b->C;
+}
+
+void test3(BF *b) {
+ b->C = 12345; // Store
+}
+
+int test4(BF *b) {
+ return b->C; // Load
+}
+
+void test5(BF *b, int i) { // array ref
+ b[i].C = 12345;
+}
+
diff --git a/clang/test/CodeGen/2003-09-30-StructLayout.c b/clang/test/CodeGen/2003-09-30-StructLayout.c
new file mode 100644
index 0000000..45ef69c
--- /dev/null
+++ b/clang/test/CodeGen/2003-09-30-StructLayout.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+enum En {
+ ENUM_VAL
+};
+
+struct St {
+ unsigned char A;
+ enum En B;
+ unsigned char C;
+ enum En D;
+ float E;
+};
+
+
+void func(struct St* A) {
+ A->D = ENUM_VAL;
+}
diff --git a/clang/test/CodeGen/2003-10-02-UnionLValueError.c b/clang/test/CodeGen/2003-10-02-UnionLValueError.c
new file mode 100644
index 0000000..180eb10
--- /dev/null
+++ b/clang/test/CodeGen/2003-10-02-UnionLValueError.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+int sprintf(char * restrict str, const char * restrict format, ...);
+union U{
+ int i[8];
+ char s[80];
+};
+
+void format_message(char *buffer, union U *u) {
+ sprintf(buffer, u->s);
+}
diff --git a/clang/test/CodeGen/2003-10-06-NegateExprType.c b/clang/test/CodeGen/2003-10-06-NegateExprType.c
new file mode 100644
index 0000000..6d692c1
--- /dev/null
+++ b/clang/test/CodeGen/2003-10-06-NegateExprType.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+extern int A[10];
+void Func(int *B) {
+ B - &A[5];
+}
+
diff --git a/clang/test/CodeGen/2003-10-09-UnionInitializerBug.c b/clang/test/CodeGen/2003-10-09-UnionInitializerBug.c
new file mode 100644
index 0000000..a14fd08
--- /dev/null
+++ b/clang/test/CodeGen/2003-10-09-UnionInitializerBug.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+struct Foo {
+ unsigned a;
+ unsigned b;
+ unsigned c;
+};
+
+struct Bar {
+ union {
+ void **a;
+ struct Foo b;
+ }u;
+};
+
+struct Bar test = {0};
+
diff --git a/clang/test/CodeGen/2003-10-28-ident.c b/clang/test/CodeGen/2003-10-28-ident.c
new file mode 100644
index 0000000..d1e5447
--- /dev/null
+++ b/clang/test/CodeGen/2003-10-28-ident.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+#ident "foo"
diff --git a/clang/test/CodeGen/2003-10-29-AsmRename.c b/clang/test/CodeGen/2003-10-29-AsmRename.c
new file mode 100644
index 0000000..d0f19af
--- /dev/null
+++ b/clang/test/CodeGen/2003-10-29-AsmRename.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-apple-darwin -o /dev/null
+
+
+struct foo { int X; };
+struct bar { int Y; };
+
+extern int Func(struct foo*) __asm__("Func64");
+extern int Func64(struct bar*);
+
+int Func(struct foo *F) {
+ return 1;
+}
+
+int Func64(struct bar* B) {
+ return 0;
+}
+
+
+int test() {
+ Func(0); /* should be renamed to call Func64 */
+ Func64(0);
+}
diff --git a/clang/test/CodeGen/2003-11-01-C99-CompoundLiteral.c b/clang/test/CodeGen/2003-11-01-C99-CompoundLiteral.c
new file mode 100644
index 0000000..f4d3824
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-01-C99-CompoundLiteral.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+typedef struct { int foo; } spinlock_t;
+typedef struct wait_queue_head_t { spinlock_t lock; } wait_queue_head_t;
+void call_usermodehelper(void) {
+ struct wait_queue_head_t work = { lock: (spinlock_t) { 0 }, };
+}
+
diff --git a/clang/test/CodeGen/2003-11-01-EmptyStructCrash.c b/clang/test/CodeGen/2003-11-01-EmptyStructCrash.c
new file mode 100644
index 0000000..e0f231a
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-01-EmptyStructCrash.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+typedef struct { } the_coolest_struct_in_the_world;
+extern the_coolest_struct_in_the_world xyzzy;
+void *foo() { return &xyzzy; }
+
diff --git a/clang/test/CodeGen/2003-11-01-GlobalUnionInit.c b/clang/test/CodeGen/2003-11-01-GlobalUnionInit.c
new file mode 100644
index 0000000..8290379
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-01-GlobalUnionInit.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+union bdflush_param {
+ struct { int x; } b_un;
+ int y[1];
+} bdf_prm = {{30}};
+
diff --git a/clang/test/CodeGen/2003-11-03-AddrArrayElement.c b/clang/test/CodeGen/2003-11-03-AddrArrayElement.c
new file mode 100644
index 0000000..50e81d6
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-03-AddrArrayElement.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// This should be turned into a tasty getelementptr instruction, not a nasty
+// series of casts and address arithmetic.
+
+char Global[100];
+
+char *test1(unsigned i) {
+ // CHECK: getelementptr
+ return &Global[i];
+}
diff --git a/clang/test/CodeGen/2003-11-04-EmptyStruct.c b/clang/test/CodeGen/2003-11-04-EmptyStruct.c
new file mode 100644
index 0000000..e771b88
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-04-EmptyStruct.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+typedef struct { } rwlock_t;
+struct fs_struct { rwlock_t lock; int umask; };
+void __copy_fs_struct(struct fs_struct *fs) { fs->lock = (rwlock_t) { }; }
+
diff --git a/clang/test/CodeGen/2003-11-04-OutOfMemory.c b/clang/test/CodeGen/2003-11-04-OutOfMemory.c
new file mode 100644
index 0000000..579c93d
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-04-OutOfMemory.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+void schedule_timeout(signed long timeout)
+{
+ switch (timeout)
+ {
+ case ((long)(~0UL>>1)): break;
+ }
+}
diff --git a/clang/test/CodeGen/2003-11-08-PointerSubNotGetelementptr.c b/clang/test/CodeGen/2003-11-08-PointerSubNotGetelementptr.c
new file mode 100644
index 0000000..9a9c642
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-08-PointerSubNotGetelementptr.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+char *test(char* C) {
+ // CHECK: getelementptr
+ return C-1; // Should turn into a GEP
+}
+
+int *test2(int* I) {
+ return I-1;
+}
diff --git a/clang/test/CodeGen/2003-11-12-VoidString.c b/clang/test/CodeGen/2003-11-12-VoidString.c
new file mode 100644
index 0000000..d22e9f4
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-12-VoidString.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+void query_newnamebuf(void) { ((void)"query_newnamebuf"); }
+
diff --git a/clang/test/CodeGen/2003-11-13-TypeSafety.c b/clang/test/CodeGen/2003-11-13-TypeSafety.c
new file mode 100644
index 0000000..b9add6c
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-13-TypeSafety.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | grep getelementptr
+
+int *test(int *X, int Y) {
+ return X + Y;
+}
diff --git a/clang/test/CodeGen/2003-11-16-StaticArrayInit.c b/clang/test/CodeGen/2003-11-16-StaticArrayInit.c
new file mode 100644
index 0000000..8a11c05
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-16-StaticArrayInit.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+void bar () {
+ static char x[10];
+ static char *xend = x + 10;
+}
+
+
diff --git a/clang/test/CodeGen/2003-11-18-CondExprLValue.c b/clang/test/CodeGen/2003-11-18-CondExprLValue.c
new file mode 100644
index 0000000..62968e5
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-18-CondExprLValue.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+typedef struct { unsigned long pgprot; } pgprot_t;
+
+void split_large_page(unsigned long addr, pgprot_t prot)
+{
+ (addr ? prot : ((pgprot_t) { 0x001 } )).pgprot;
+}
+
diff --git a/clang/test/CodeGen/2003-11-19-AddressOfRegister.c b/clang/test/CodeGen/2003-11-19-AddressOfRegister.c
new file mode 100644
index 0000000..e80ff65
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-19-AddressOfRegister.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -emit-llvm -o /dev/null
+
+struct item {
+ short delta[4];
+};
+
+int TEST(int nt) {
+ register struct item *aa;
+ aa[nt].delta;
+ return 1;
+}
diff --git a/clang/test/CodeGen/2003-11-19-BitFieldArray.c b/clang/test/CodeGen/2003-11-19-BitFieldArray.c
new file mode 100644
index 0000000..8411563
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-19-BitFieldArray.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+struct _GIOChannel {
+ int write_buf;
+ char partial_write_buf[6];
+ int d :1;
+};
+
+void g_io_channel_init (struct _GIOChannel *channel) {
+ channel->partial_write_buf[0];
+}
+
diff --git a/clang/test/CodeGen/2003-11-20-Bitfields.c b/clang/test/CodeGen/2003-11-20-Bitfields.c
new file mode 100644
index 0000000..5284cde
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-20-Bitfields.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+struct face_cachel {
+ unsigned int reverse :1;
+ unsigned char font_specified[1];
+};
+
+void
+ensure_face_cachel_contains_charset (struct face_cachel *cachel) {
+ cachel->font_specified[0] = 0;
+}
+
diff --git a/clang/test/CodeGen/2003-11-20-ComplexDivision.c b/clang/test/CodeGen/2003-11-20-ComplexDivision.c
new file mode 100644
index 0000000..ecd780b
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-20-ComplexDivision.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+int test() {
+ __complex__ double C;
+ double D;
+ C / D;
+}
diff --git a/clang/test/CodeGen/2003-11-20-UnionBitfield.c b/clang/test/CodeGen/2003-11-20-UnionBitfield.c
new file mode 100644
index 0000000..6ffe76a
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-20-UnionBitfield.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+struct printf_spec {
+ unsigned int minus_flag:1;
+ char converter;
+};
+
+void parse_doprnt_spec () {
+ struct printf_spec spec;
+ spec.minus_flag = 1;
+}
+
diff --git a/clang/test/CodeGen/2003-11-26-PointerShift.c b/clang/test/CodeGen/2003-11-26-PointerShift.c
new file mode 100644
index 0000000..530759e
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-26-PointerShift.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+unsigned long do_csum(const unsigned char *buff, int len, unsigned long result) {
+ if (2 & (unsigned long) buff) result += 1;
+ return result;
+}
diff --git a/clang/test/CodeGen/2003-11-27-ConstructorCast.c b/clang/test/CodeGen/2003-11-27-ConstructorCast.c
new file mode 100644
index 0000000..f04fa21
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-27-ConstructorCast.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+struct i387_soft_struct {
+ long cwd;
+};
+union i387_union {
+ struct i387_soft_struct soft;
+};
+struct thread_struct {
+ union i387_union i387;
+};
+void _init_task_union(void) {
+ struct thread_struct thread = (struct thread_struct) { {{0}} };
+}
diff --git a/clang/test/CodeGen/2003-11-27-UnionCtorInitialization.c b/clang/test/CodeGen/2003-11-27-UnionCtorInitialization.c
new file mode 100644
index 0000000..ca80173
--- /dev/null
+++ b/clang/test/CodeGen/2003-11-27-UnionCtorInitialization.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+struct i387_soft_struct {
+ long cwd;
+ long twd;
+ long fip;
+};
+union i387_union {
+ struct i387_soft_struct soft;
+};
+struct thread_struct {
+ union i387_union i387;
+};
+void _init_task_union(void) {
+ struct thread_struct thread = (struct thread_struct) { {{0}} };
+}
diff --git a/clang/test/CodeGen/2003-12-14-ExternInlineSupport.c b/clang/test/CodeGen/2003-12-14-ExternInlineSupport.c
new file mode 100644
index 0000000..eb3859c
--- /dev/null
+++ b/clang/test/CodeGen/2003-12-14-ExternInlineSupport.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -std=gnu89 %s -emit-llvm -o - | not grep dead_function
+
+extern __inline__ void dead_function() {}
diff --git a/clang/test/CodeGen/2004-01-01-UnknownInitSize.c b/clang/test/CodeGen/2004-01-01-UnknownInitSize.c
new file mode 100644
index 0000000..25ddebd
--- /dev/null
+++ b/clang/test/CodeGen/2004-01-01-UnknownInitSize.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+/*
+ * This regression test ensures that the C front end can compile initializers
+ * even when it cannot determine the size (as below).
+*/
+struct one
+{
+ int a;
+ int values [];
+};
+
+struct one hobbit = {5, {1, 2, 3}};
+
diff --git a/clang/test/CodeGen/2004-01-08-ExternInlineRedefine.c b/clang/test/CodeGen/2004-01-08-ExternInlineRedefine.c
new file mode 100644
index 0000000..358a9c2
--- /dev/null
+++ b/clang/test/CodeGen/2004-01-08-ExternInlineRedefine.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=gnu89 -emit-llvm %s -o /dev/null
+
+
+extern __inline long int
+__strtol_l (int a)
+{
+ return 0;
+}
+
+long int
+__strtol_l (int a)
+{
+ return 0;
+}
diff --git a/clang/test/CodeGen/2004-02-12-LargeAggregateCopy.c b/clang/test/CodeGen/2004-02-12-LargeAggregateCopy.c
new file mode 100644
index 0000000..811ee8e
--- /dev/null
+++ b/clang/test/CodeGen/2004-02-12-LargeAggregateCopy.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+struct X { int V[10000]; };
+struct X Global1, Global2;
+void test() {
+ // CHECK: llvm.memcpy
+ Global2 = Global1;
+}
diff --git a/clang/test/CodeGen/2004-02-13-BuiltinFrameReturnAddress.c b/clang/test/CodeGen/2004-02-13-BuiltinFrameReturnAddress.c
new file mode 100644
index 0000000..8c0b7ba
--- /dev/null
+++ b/clang/test/CodeGen/2004-02-13-BuiltinFrameReturnAddress.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+void *test1() {
+ // CHECK: call i8* @llvm.returnaddress
+ return __builtin_return_address(1);
+}
+void *test2() {
+ // CHECK: call i8* @llvm.frameaddress
+ return __builtin_frame_address(0);
+}
diff --git a/clang/test/CodeGen/2004-02-13-IllegalVararg.c b/clang/test/CodeGen/2004-02-13-IllegalVararg.c
new file mode 100644
index 0000000..cbc9151
--- /dev/null
+++ b/clang/test/CodeGen/2004-02-13-IllegalVararg.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -w -emit-llvm -o -
+
+float test(int X, ...) {
+ __builtin_va_list ap;
+ float F;
+ __builtin_va_start(ap, X);
+ F = __builtin_va_arg(ap, float);
+ return F;
+}
diff --git a/clang/test/CodeGen/2004-02-13-Memset.c b/clang/test/CodeGen/2004-02-13-Memset.c
new file mode 100644
index 0000000..23a4d3b
--- /dev/null
+++ b/clang/test/CodeGen/2004-02-13-Memset.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | grep llvm.memset | count 3
+
+typedef __SIZE_TYPE__ size_t;
+void *memset(void*, int, size_t);
+void bzero(void*, size_t);
+
+void test(int* X, char *Y) {
+ // CHECK: call i8* llvm.memset
+ memset(X, 4, 1000);
+ // CHECK: call void bzero
+ bzero(Y, 100);
+}
diff --git a/clang/test/CodeGen/2004-02-14-ZeroInitializer.c b/clang/test/CodeGen/2004-02-14-ZeroInitializer.c
new file mode 100644
index 0000000..3379a06
--- /dev/null
+++ b/clang/test/CodeGen/2004-02-14-ZeroInitializer.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: zeroinitializer
+int X[1000];
diff --git a/clang/test/CodeGen/2004-02-20-Builtins.c b/clang/test/CodeGen/2004-02-20-Builtins.c
new file mode 100644
index 0000000..9be0523
--- /dev/null
+++ b/clang/test/CodeGen/2004-02-20-Builtins.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | not grep builtin
+double sqrt(double x);
+void zsqrtxxx(float num) {
+ num = sqrt(num);
+}
diff --git a/clang/test/CodeGen/2004-03-07-ComplexDivEquals.c b/clang/test/CodeGen/2004-03-07-ComplexDivEquals.c
new file mode 100644
index 0000000..e2cd539
--- /dev/null
+++ b/clang/test/CodeGen/2004-03-07-ComplexDivEquals.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+void test(__complex__ double D, double X) {
+ D /= X;
+}
diff --git a/clang/test/CodeGen/2004-03-07-ExternalConstant.c b/clang/test/CodeGen/2004-03-07-ExternalConstant.c
new file mode 100644
index 0000000..2de3a69
--- /dev/null
+++ b/clang/test/CodeGen/2004-03-07-ExternalConstant.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: @a = external constan
+extern const int a[]; // 'a' should be marked constant even though it's external!
+int foo () {
+ return a[0];
+}
diff --git a/clang/test/CodeGen/2004-03-09-LargeArrayInitializers.c b/clang/test/CodeGen/2004-03-09-LargeArrayInitializers.c
new file mode 100644
index 0000000..b34af0d
--- /dev/null
+++ b/clang/test/CodeGen/2004-03-09-LargeArrayInitializers.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+// Test that these initializers are handled efficiently
+
+int test(int x) {
+ const int XX[1000] = { 0, 0 };
+ const char S [1000] = "foo";
+
+ const int array[] = {
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ 17, 23, 123, 123, 49, 17, 23, 123, 123, 49, 17, 23, 123, 123, 49,
+ };
+ return array[x];
+}
diff --git a/clang/test/CodeGen/2004-03-15-SimpleIndirectGoto.c b/clang/test/CodeGen/2004-03-15-SimpleIndirectGoto.c
new file mode 100644
index 0000000..93fb59f
--- /dev/null
+++ b/clang/test/CodeGen/2004-03-15-SimpleIndirectGoto.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+int code[]={0,0,0,0,1};
+void foo(int x) {
+ volatile int b;
+ b = 0xffffffff;
+}
+void bar(int *pc) {
+ static const void *l[] = {&&lab0, &&end};
+
+ foo(0);
+ goto *l[*pc];
+ lab0:
+ foo(0);
+ pc++;
+ goto *l[*pc];
+ end:
+ return;
+}
+int main() {
+ bar(code);
+ return 0;
+}
diff --git a/clang/test/CodeGen/2004-03-16-AsmRegisterCrash.c b/clang/test/CodeGen/2004-03-16-AsmRegisterCrash.c
new file mode 100644
index 0000000..515d243
--- /dev/null
+++ b/clang/test/CodeGen/2004-03-16-AsmRegisterCrash.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+// XFAIL: *
+// XTARGET: arm, i386, i686, x86_64
+
+int foo() {
+#ifdef __arm__
+ register int X __asm__("r1");
+#else
+ register int X __asm__("ebx");
+#endif
+ return X;
+}
diff --git a/clang/test/CodeGen/2004-05-07-VarArrays.c b/clang/test/CodeGen/2004-05-07-VarArrays.c
new file mode 100644
index 0000000..1ef5cf3
--- /dev/null
+++ b/clang/test/CodeGen/2004-05-07-VarArrays.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+int foo(int len, char arr[][len], int X) {
+ return arr[X][0];
+}
diff --git a/clang/test/CodeGen/2004-05-21-IncompleteEnum.c b/clang/test/CodeGen/2004-05-21-IncompleteEnum.c
new file mode 100644
index 0000000..41652d1
--- /dev/null
+++ b/clang/test/CodeGen/2004-05-21-IncompleteEnum.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -w -emit-llvm %s -o /dev/null
+
+void test(enum foo *X) {
+}
+
diff --git a/clang/test/CodeGen/2004-06-08-OpaqueStructArg.c b/clang/test/CodeGen/2004-06-08-OpaqueStructArg.c
new file mode 100644
index 0000000..cec4459
--- /dev/null
+++ b/clang/test/CodeGen/2004-06-08-OpaqueStructArg.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+ struct fu;
+ void foo(struct fu);
+ void bar() {
+ foo;
+ }
diff --git a/clang/test/CodeGen/2004-06-17-UnorderedBuiltins.c b/clang/test/CodeGen/2004-06-17-UnorderedBuiltins.c
new file mode 100644
index 0000000..90360c4
--- /dev/null
+++ b/clang/test/CodeGen/2004-06-17-UnorderedBuiltins.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+_Bool A, B, C, D, E, F, G, H;
+void TestF(float X, float Y) {
+ A = __builtin_isgreater(X, Y);
+ B = __builtin_isgreaterequal(X, Y);
+ C = __builtin_isless(X, Y);
+ D = __builtin_islessequal(X, Y);
+ E = __builtin_islessgreater(X, Y);
+ F = __builtin_isunordered(X, Y);
+ //G = __builtin_isordered(X, Y); // Our current snapshot of GCC doesn't include this builtin
+ H = __builtin_isunordered(X, Y);
+}
+void TestD(double X, double Y) {
+ A = __builtin_isgreater(X, Y);
+ B = __builtin_isgreaterequal(X, Y);
+ C = __builtin_isless(X, Y);
+ D = __builtin_islessequal(X, Y);
+ E = __builtin_islessgreater(X, Y);
+ F = __builtin_isunordered(X, Y);
+ //G = __builtin_isordered(X, Y); // Our current snapshot doesn't include this builtin. FIXME
+ H = __builtin_isunordered(X, Y);
+}
diff --git a/clang/test/CodeGen/2004-06-17-UnorderedCompares.c b/clang/test/CodeGen/2004-06-17-UnorderedCompares.c
new file mode 100644
index 0000000..7d2ba96
--- /dev/null
+++ b/clang/test/CodeGen/2004-06-17-UnorderedCompares.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c99 %s -emit-llvm -o - | grep -v llvm.isunordered | not grep call
+
+_Bool A, B, C, D, E, F;
+void TestF(float X, float Y) {
+ A = __builtin_isgreater(X, Y);
+ B = __builtin_isgreaterequal(X, Y);
+ C = __builtin_isless(X, Y);
+ D = __builtin_islessequal(X, Y);
+ E = __builtin_islessgreater(X, Y);
+ F = __builtin_isunordered(X, Y);
+}
+void TestD(double X, double Y) {
+ A = __builtin_isgreater(X, Y);
+ B = __builtin_isgreaterequal(X, Y);
+ C = __builtin_isless(X, Y);
+ D = __builtin_islessequal(X, Y);
+ E = __builtin_islessgreater(X, Y);
+ F = __builtin_isunordered(X, Y);
+}
diff --git a/clang/test/CodeGen/2004-06-18-VariableLengthArrayOfStructures.c b/clang/test/CodeGen/2004-06-18-VariableLengthArrayOfStructures.c
new file mode 100644
index 0000000..abf78fb
--- /dev/null
+++ b/clang/test/CodeGen/2004-06-18-VariableLengthArrayOfStructures.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+struct S { };
+
+int xxxx(int a) {
+ struct S comps[a];
+ comps[0];
+}
+
diff --git a/clang/test/CodeGen/2004-07-06-FunctionCast.c b/clang/test/CodeGen/2004-07-06-FunctionCast.c
new file mode 100644
index 0000000..32931e2
--- /dev/null
+++ b/clang/test/CodeGen/2004-07-06-FunctionCast.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+static int unused_func(void) {
+ return 1;
+}
+
+int foo(void) {
+ (void)unused_func; /* avoid compiler warning */
+ return 2;
+}
diff --git a/clang/test/CodeGen/2004-08-06-LargeStructTest.c b/clang/test/CodeGen/2004-08-06-LargeStructTest.c
new file mode 100644
index 0000000..ee57f0b
--- /dev/null
+++ b/clang/test/CodeGen/2004-08-06-LargeStructTest.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+
+#define A(X) int X;
+#define B(X) A(X##0) A(X##1) A(X##2) A(X##3) A(X##4) A(X##5) A(X##6) A(X##7) \
+ A(X##8) A(X##9) A(X##A) A(X##B) A(X##C) A(X##D) A(X##E) A(X##F)
+#define C(X) B(X##0) B(X##1) B(X##2) B(X##3) B(X##4) B(X##5) B(X##6) B(X##7) \
+ B(X##8) B(X##9) B(X##A) B(X##B) B(X##C) B(X##D) B(X##E) B(X##F)
+
+struct foo {
+ C(x); // 256
+ C(y); // 256
+ C(z);
+};
+
+
+int test(struct foo *F) {
+ return F->xA1 + F->yFF + F->zC4;
+}
diff --git a/clang/test/CodeGen/2004-11-25-UnnamedBitfieldPadding.c b/clang/test/CodeGen/2004-11-25-UnnamedBitfieldPadding.c
new file mode 100644
index 0000000..a6af2a5
--- /dev/null
+++ b/clang/test/CodeGen/2004-11-25-UnnamedBitfieldPadding.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+// This is a testcase for PR461
+typedef struct {
+ unsigned min_align: 1;
+ unsigned : 1;
+} addr_diff_vec_flags;
+
+addr_diff_vec_flags X;
diff --git a/clang/test/CodeGen/2004-11-27-InvalidConstantExpr.c b/clang/test/CodeGen/2004-11-27-InvalidConstantExpr.c
new file mode 100644
index 0000000..431dccf
--- /dev/null
+++ b/clang/test/CodeGen/2004-11-27-InvalidConstantExpr.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | not grep {foo\\* sub}
+// This should not produce a subtrace constantexpr of a pointer
+struct foo {
+ int Y;
+ char X[100];
+} F;
+
+int test(char *Y) {
+ return Y - F.X;
+}
diff --git a/clang/test/CodeGen/2004-11-27-StaticFunctionRedeclare.c b/clang/test/CodeGen/2004-11-27-StaticFunctionRedeclare.c
new file mode 100644
index 0000000..55efa86
--- /dev/null
+++ b/clang/test/CodeGen/2004-11-27-StaticFunctionRedeclare.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | \
+// RUN: opt -std-compile-opts -emit-llvm | not grep {declare i32.*func}
+
+// There should not be an unresolved reference to func here. Believe it or not,
+// the "expected result" is a function named 'func' which is internal and
+// referenced by bar().
+
+// This is PR244
+
+static int func();
+void bar() {
+ int func();
+ foo(func);
+}
+static int func(char** A, char ** B) {}
diff --git a/clang/test/CodeGen/2005-01-02-ConstantInits.c b/clang/test/CodeGen/2005-01-02-ConstantInits.c
new file mode 100644
index 0000000..d85f519
--- /dev/null
+++ b/clang/test/CodeGen/2005-01-02-ConstantInits.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+// This tests all kinds of hard cases with initializers and
+// array subscripts. This corresponds to PR487.
+
+struct X { int a[2]; };
+
+int test() {
+ static int i23 = (int) &(((struct X *)0)->a[1]);
+ return i23;
+}
+
+int i = (int) &( ((struct X *)0) -> a[1]);
+
+int Arr[100];
+
+int foo(int i) { return bar(&Arr[49])+bar(&Arr[i]); }
+int foo2(int i) {
+ static const int *X = &Arr[49];
+ static int i23 = (int) &( ((struct X *)0) -> a[0]);
+ int *P = Arr;
+ ++P;
+ return bar(Arr+i);
+}
diff --git a/clang/test/CodeGen/2005-01-02-PointerDifference.c b/clang/test/CodeGen/2005-01-02-PointerDifference.c
new file mode 100644
index 0000000..1114ef5
--- /dev/null
+++ b/clang/test/CodeGen/2005-01-02-PointerDifference.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: sdiv exact
+int Diff(int *P, int *Q) { return P-Q; }
diff --git a/clang/test/CodeGen/2005-01-02-VAArgError-ICE.c b/clang/test/CodeGen/2005-01-02-VAArgError-ICE.c
new file mode 100644
index 0000000..06377c2
--- /dev/null
+++ b/clang/test/CodeGen/2005-01-02-VAArgError-ICE.c
@@ -0,0 +1,9 @@
+// This file is erroneous, but should not cause the compiler to ICE.
+// PR481
+// RUN: %clang_cc1 %s -emit-llvm -o /dev/null
+
+int flags(int a, int b, ...) {
+ __builtin_va_list args;
+ __builtin_va_start(args,a); // not the last named arg
+ foo(args);
+}
diff --git a/clang/test/CodeGen/2005-02-20-AggregateSAVEEXPR.c b/clang/test/CodeGen/2005-02-20-AggregateSAVEEXPR.c
new file mode 100644
index 0000000..99efb1b
--- /dev/null
+++ b/clang/test/CodeGen/2005-02-20-AggregateSAVEEXPR.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -o /dev/null -emit-llvm
+
+int foo(__complex float c) {
+ return creal(c);
+}
diff --git a/clang/test/CodeGen/2005-02-27-MarkGlobalConstant.c b/clang/test/CodeGen/2005-02-27-MarkGlobalConstant.c
new file mode 100644
index 0000000..dc2cdbf
--- /dev/null
+++ b/clang/test/CodeGen/2005-02-27-MarkGlobalConstant.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// PR10414
+
+// The synthetic global made by the CFE for big initializer should be marked
+// constant.
+
+void bar();
+void foo() {
+ // CHECK: private unnamed_addr constant
+ char Blah[] = "asdlfkajsdlfkajsd;lfkajds;lfkjasd;flkajsd;lkfja;sdlkfjasd";
+ bar(Blah);
+}
diff --git a/clang/test/CodeGen/2005-03-05-OffsetOfHack.c b/clang/test/CodeGen/2005-03-05-OffsetOfHack.c
new file mode 100644
index 0000000..4420981
--- /dev/null
+++ b/clang/test/CodeGen/2005-03-05-OffsetOfHack.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+struct s {
+ unsigned long int field[0];
+};
+
+#define OFFS \
+ (((char *) &((struct s *) 0)->field[0]) - (char *) 0)
+
+int foo[OFFS];
+
+
diff --git a/clang/test/CodeGen/2005-03-06-OffsetOfStructCrash.c b/clang/test/CodeGen/2005-03-06-OffsetOfStructCrash.c
new file mode 100644
index 0000000..46968bb
--- /dev/null
+++ b/clang/test/CodeGen/2005-03-06-OffsetOfStructCrash.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+struct Y {};
+struct XXX {
+ struct Y F;
+};
+
+void test1() {
+ (int)&((struct XXX*)(((void *)0)))->F;
+}
+
+void test2() {
+ &((struct XXX*)(((void *)0)))->F;
+}
diff --git a/clang/test/CodeGen/2005-03-11-Prefetch.c b/clang/test/CodeGen/2005-03-11-Prefetch.c
new file mode 100644
index 0000000..8d7d12e
--- /dev/null
+++ b/clang/test/CodeGen/2005-03-11-Prefetch.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+void foo(int *P) {
+ // CHECK: llvm.prefetch
+ __builtin_prefetch(P);
+ __builtin_prefetch(P, 1);
+}
diff --git a/clang/test/CodeGen/2005-04-09-ComplexOps.c b/clang/test/CodeGen/2005-04-09-ComplexOps.c
new file mode 100644
index 0000000..23716d3
--- /dev/null
+++ b/clang/test/CodeGen/2005-04-09-ComplexOps.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+#define I 1.0iF
+
+double __complex test(double X) { return ~-(X*I); }
+
+_Bool EQ(double __complex A, double __complex B) { return A == B; }
+_Bool NE(double __complex A, double __complex B) { return A != B; }
diff --git a/clang/test/CodeGen/2005-05-10-GlobalUnionInit.c b/clang/test/CodeGen/2005-05-10-GlobalUnionInit.c
new file mode 100644
index 0000000..ddd7f5e
--- /dev/null
+++ b/clang/test/CodeGen/2005-05-10-GlobalUnionInit.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+union A { // { uint }
+ union B { double *C; } D;
+} E = { { (double*)12312 } };
+
diff --git a/clang/test/CodeGen/2005-06-15-ExpandGotoInternalProblem.c b/clang/test/CodeGen/2005-06-15-ExpandGotoInternalProblem.c
new file mode 100644
index 0000000..dd1acc5
--- /dev/null
+++ b/clang/test/CodeGen/2005-06-15-ExpandGotoInternalProblem.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c99 %s -emit-llvm -o - | \
+// RUN: opt -std-compile-opts -disable-output
+// PR580
+
+int X, Y;
+int foo() {
+ int i;
+ for (i=0; i<100; i++ )
+ {
+ break;
+ i = ( X || Y ) ;
+ }
+}
+
diff --git a/clang/test/CodeGen/2005-07-20-SqrtNoErrno.c b/clang/test/CodeGen/2005-07-20-SqrtNoErrno.c
new file mode 100644
index 0000000..f40f61d
--- /dev/null
+++ b/clang/test/CodeGen/2005-07-20-SqrtNoErrno.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// llvm.sqrt has undefined behavior on negative inputs, so it is
+// inappropriate to translate C/C++ sqrt to this.
+float sqrtf(float x);
+float foo(float X) {
+ // CHECK: foo
+ // CHECK: call float @sqrtf(float %
+ // Check that this is marked readonly when errno is ignored.
+ return sqrtf(X);
+}
diff --git a/clang/test/CodeGen/2005-07-26-UnionInitCrash.c b/clang/test/CodeGen/2005-07-26-UnionInitCrash.c
new file mode 100644
index 0000000..5572240
--- /dev/null
+++ b/clang/test/CodeGen/2005-07-26-UnionInitCrash.c
@@ -0,0 +1,3 @@
+// PR607
+// RUN: %clang_cc1 %s -emit-llvm -o -
+union { char bytes[8]; double alignment; }EQ1 = {0,0,0,0,0,0,0,0};
diff --git a/clang/test/CodeGen/2005-07-28-IncorrectWeakGlobal.c b/clang/test/CodeGen/2005-07-28-IncorrectWeakGlobal.c
new file mode 100644
index 0000000..cbacf22
--- /dev/null
+++ b/clang/test/CodeGen/2005-07-28-IncorrectWeakGlobal.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | grep TheGlobal | not grep weak
+
+extern int TheGlobal;
+int foo() { return TheGlobal; }
+int TheGlobal = 1;
diff --git a/clang/test/CodeGen/2005-09-20-ComplexConstants.c b/clang/test/CodeGen/2005-09-20-ComplexConstants.c
new file mode 100644
index 0000000..a23ccee
--- /dev/null
+++ b/clang/test/CodeGen/2005-09-20-ComplexConstants.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -emit-llvm -o /dev/null
+
+const double _Complex x[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+
diff --git a/clang/test/CodeGen/2005-09-24-AsmUserPrefix.c b/clang/test/CodeGen/2005-09-24-AsmUserPrefix.c
new file mode 100644
index 0000000..1628313
--- /dev/null
+++ b/clang/test/CodeGen/2005-09-24-AsmUserPrefix.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | opt -std-compile-opts | llc | \
+// RUN: not grep _foo2
+
+void foo() __asm__("foo2");
+
+void bar() {
+ foo();
+}
diff --git a/clang/test/CodeGen/2005-09-24-BitFieldCrash.c b/clang/test/CodeGen/2005-09-24-BitFieldCrash.c
new file mode 100644
index 0000000..d687d2f
--- /dev/null
+++ b/clang/test/CodeGen/2005-09-24-BitFieldCrash.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+struct tree_common {};
+
+struct tree_int_cst {
+ struct tree_common common;
+ struct tree_int_cst_lowhi {
+ unsigned long long low;
+ long long high;
+ } int_cst;
+};
+
+enum XXX { yyy };
+
+struct tree_function_decl {
+ struct tree_common common;
+ long long locus, y;
+ __extension__ enum XXX built_in_class : 2;
+
+};
+
+
+union tree_node {
+ struct tree_int_cst int_cst;
+ struct tree_function_decl function_decl;
+};
+
+
+void foo (union tree_node * decl) {
+ decl->function_decl.built_in_class != 0;
+}
+
+
diff --git a/clang/test/CodeGen/2005-12-04-AttributeUsed.c b/clang/test/CodeGen/2005-12-04-AttributeUsed.c
new file mode 100644
index 0000000..4be6b79
--- /dev/null
+++ b/clang/test/CodeGen/2005-12-04-AttributeUsed.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* @foo to i8*), i8* bitcast (i32* @X to i8*)], section "llvm.metadata"
+int X __attribute__((used));
+int Y;
+
+__attribute__((used)) void foo() {}
diff --git a/clang/test/CodeGen/2005-12-04-DeclarationLineNumbers.c b/clang/test/CodeGen/2005-12-04-DeclarationLineNumbers.c
new file mode 100644
index 0000000..596d3ee
--- /dev/null
+++ b/clang/test/CodeGen/2005-12-04-DeclarationLineNumbers.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -emit-llvm -g -o - | grep DW_TAG_compile_unit | count 1
+// PR664: ensure that line #'s are emitted for declarations
+
+
+short test(short br_data_0,
+short br_data_1,
+short br_data_2,
+short br_data_3,
+short br_data_4,
+short br_data_5,
+short br_data_6,
+short br_data_7) {
+
+short sm07 = br_data_0 + br_data_7;
+short sm16 = br_data_1 + br_data_6;
+short sm25 = br_data_2 + br_data_5;
+short sm34 = br_data_3 + br_data_4;
+short s0734 = sm07 + sm34;
+short s1625 = sm16 + sm25;
+
+return s0734 + s1625;
+}
+
diff --git a/clang/test/CodeGen/2006-01-13-Includes.c b/clang/test/CodeGen/2006-01-13-Includes.c
new file mode 100644
index 0000000..9cc45ce
--- /dev/null
+++ b/clang/test/CodeGen/2006-01-13-Includes.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -g -emit-llvm -o - | FileCheck %s
+// PR676
+
+int printf(const char * restrict format, ...);
+
+void test() {
+ printf("Hello World\n");
+}
+
+// CHECK: test{{[\\/]}}CodeGen
diff --git a/clang/test/CodeGen/2006-01-13-StackSave.c b/clang/test/CodeGen/2006-01-13-StackSave.c
new file mode 100644
index 0000000..7c506b3
--- /dev/null
+++ b/clang/test/CodeGen/2006-01-13-StackSave.c
@@ -0,0 +1,11 @@
+// PR691
+// RUN: %clang_cc1 %s -emit-llvm -o - | opt -std-compile-opts | \
+// RUN: llvm-dis | grep llvm.stacksave
+
+void test(int N) {
+ int i;
+ for (i = 0; i < N; ++i) {
+ int VLA[i];
+ external(VLA);
+ }
+}
diff --git a/clang/test/CodeGen/2006-01-16-BitCountIntrinsicsUnsigned.c b/clang/test/CodeGen/2006-01-16-BitCountIntrinsicsUnsigned.c
new file mode 100644
index 0000000..ba7820a
--- /dev/null
+++ b/clang/test/CodeGen/2006-01-16-BitCountIntrinsicsUnsigned.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+unsigned t2(unsigned X) {
+ // CHECK: t2
+ // CHECK: llvm.ctlz.i32
+ return __builtin_clz(X);
+}
+int t1(int X) {
+ // CHECK: t1
+ // CHECK: llvm.ctlz.i32
+ return __builtin_clz(X);
+}
diff --git a/clang/test/CodeGen/2006-01-23-FileScopeAsm.c b/clang/test/CodeGen/2006-01-23-FileScopeAsm.c
new file mode 100644
index 0000000..472b464
--- /dev/null
+++ b/clang/test/CodeGen/2006-01-23-FileScopeAsm.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: module asm "foo1"
+__asm__ ("foo1");
+// CHECK: module asm "foo2"
+__asm__ ("foo2");
+// CHECK: module asm "foo3"
+__asm__ ("foo3");
+// CHECK: module asm "foo4"
+__asm__ ("foo4");
+// CHECK: module asm "foo5"
+__asm__ ("foo5");
diff --git a/clang/test/CodeGen/2006-03-03-MissingInitializer.c b/clang/test/CodeGen/2006-03-03-MissingInitializer.c
new file mode 100644
index 0000000..d2317d3
--- /dev/null
+++ b/clang/test/CodeGen/2006-03-03-MissingInitializer.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+struct X { int *XX; int Y;};
+
+void foo() {
+ // CHECK: @foo.nate = internal global i32 0
+ static int nate = 0;
+ struct X bob = { &nate, 14 };
+ bar(&bob);
+}
diff --git a/clang/test/CodeGen/2006-03-16-VectorCtor.c b/clang/test/CodeGen/2006-03-16-VectorCtor.c
new file mode 100644
index 0000000..c04d4b9
--- /dev/null
+++ b/clang/test/CodeGen/2006-03-16-VectorCtor.c
@@ -0,0 +1,10 @@
+// Test that basic generic vector support works
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+typedef int v4si __attribute__ ((__vector_size__ (16)));
+void test(v4si *P, v4si *Q, float X) {
+ *P = (v4si){ X, X, X, X } * *Q;
+}
+
+v4si G = (v4si){ 0.1, 1.2, 4.2, 17.2 };
+
diff --git a/clang/test/CodeGen/2006-03-17-KnRMismatch.c b/clang/test/CodeGen/2006-03-17-KnRMismatch.c
new file mode 100644
index 0000000..f678e9f
--- /dev/null
+++ b/clang/test/CodeGen/2006-03-17-KnRMismatch.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+void regnode(int op);
+
+void regnode(op)
+char op;
+{
+}
diff --git a/clang/test/CodeGen/2006-05-19-SingleEltReturn.c b/clang/test/CodeGen/2006-05-19-SingleEltReturn.c
new file mode 100644
index 0000000..819237c
--- /dev/null
+++ b/clang/test/CodeGen/2006-05-19-SingleEltReturn.c
@@ -0,0 +1,23 @@
+// Test returning a single element aggregate value containing a double.
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+struct X {
+ double D;
+};
+
+struct Y {
+ struct X x;
+};
+
+struct Y bar();
+
+void foo(struct Y *P) {
+ *P = bar();
+}
+
+struct Y bar() {
+ struct Y a;
+ a.x.D = 0;
+ return a;
+}
+
diff --git a/clang/test/CodeGen/2006-07-31-PR854.c b/clang/test/CodeGen/2006-07-31-PR854.c
new file mode 100644
index 0000000..b3b4d8e
--- /dev/null
+++ b/clang/test/CodeGen/2006-07-31-PR854.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple i686-linux-gnu -w %s -emit-llvm -o -
+
+// PR854
+ struct kernel_symbol {
+ unsigned long value;
+ };
+ unsigned long loops_per_jiffy = (1<<12);
+ static const char __kstrtab_loops_per_jiffy[]
+__attribute__((section("__ksymtab_strings"))) = "loops_per_jiffy";
+ static const struct kernel_symbol __ksymtab_loops_per_jiffy
+__attribute__((__used__)) __attribute__((section("__ksymtab"))) = { (unsigned
+long)&loops_per_jiffy, __kstrtab_loops_per_jiffy };
diff --git a/clang/test/CodeGen/2006-09-11-BitfieldRefCrash.c b/clang/test/CodeGen/2006-09-11-BitfieldRefCrash.c
new file mode 100644
index 0000000..3d45d8b
--- /dev/null
+++ b/clang/test/CodeGen/2006-09-11-BitfieldRefCrash.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+// PR906
+
+struct state_struct {
+ unsigned long long phys_frame: 50;
+ unsigned valid : 2;
+} s;
+
+int mem_access(struct state_struct *p) {
+ return p->valid;
+}
+
diff --git a/clang/test/CodeGen/2006-09-18-fwrite-cast-crash.c b/clang/test/CodeGen/2006-09-18-fwrite-cast-crash.c
new file mode 100644
index 0000000..a12fd0b
--- /dev/null
+++ b/clang/test/CodeGen/2006-09-18-fwrite-cast-crash.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -o /dev/null
+// PR910
+
+struct l_struct_2E_FILE { char x; };
+unsigned fwrite(signed char *, unsigned , unsigned , signed char *);
+static signed char str301[39];
+static void Usage(signed char *ltmp_611_6) {
+ struct l_struct_2E_FILE *ltmp_6202_16;
+ unsigned ltmp_6203_92;
+ ltmp_6203_92 = /*tail*/ ((unsigned (*) (signed char *, unsigned , unsigned ,
+struct l_struct_2E_FILE *))(void*)fwrite)((&(str301[0u])), 38u, 1u, ltmp_6202_16);
+}
diff --git a/clang/test/CodeGen/2006-09-21-IncompleteElementType.c b/clang/test/CodeGen/2006-09-21-IncompleteElementType.c
new file mode 100644
index 0000000..1c71ea1
--- /dev/null
+++ b/clang/test/CodeGen/2006-09-21-IncompleteElementType.c
@@ -0,0 +1,3 @@
+// RUN: not %clang_cc1 %s -emit-llvm -o /dev/null
+
+struct A X[(927 - 37) / sizeof(struct A)];
diff --git a/clang/test/CodeGen/2006-09-25-DebugFilename.c b/clang/test/CodeGen/2006-09-25-DebugFilename.c
new file mode 100644
index 0000000..2edb63f
--- /dev/null
+++ b/clang/test/CodeGen/2006-09-25-DebugFilename.c
@@ -0,0 +1,4 @@
+// RUN: not %clang_cc1 %s -emit-llvm -o /dev/null
+#include "2006-09-25-DebugFilename.h"
+int func1() { return hfunc1(); }
+int func2() { fluffy; return hfunc1(); } // expected-error {{use of undeclared identifier 'fluffy'}}
diff --git a/clang/test/CodeGen/2006-09-25-DebugFilename.h b/clang/test/CodeGen/2006-09-25-DebugFilename.h
new file mode 100644
index 0000000..9b03666
--- /dev/null
+++ b/clang/test/CodeGen/2006-09-25-DebugFilename.h
@@ -0,0 +1,6 @@
+extern int exfunc(int a);
+
+static inline int hfunc1()
+{
+ return exfunc(1);
+}
diff --git a/clang/test/CodeGen/2006-09-28-SimpleAsm.c b/clang/test/CodeGen/2006-09-28-SimpleAsm.c
new file mode 100644
index 0000000..c3983af
--- /dev/null
+++ b/clang/test/CodeGen/2006-09-28-SimpleAsm.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// PR924
+
+void bar() {
+ // Extended asm
+ // CHECK: call void asm sideeffect "ext: xorl %eax, eax; movl eax, fs; movl eax, gs %blah
+ asm volatile ("ext: xorl %%eax, eax; movl eax, fs; movl eax, gs %%blah %= %\
+% " : : "r"(1));
+ // CHECK: call void asm sideeffect "nonext: xorl %eax, %eax; movl %eax, %fs; movl %eax, %gs %%blah %= %%
+ // Non-extended asm.
+ asm volatile ("nonext: xorl %eax, %eax; movl %eax, %fs; movl %eax, %gs %%blah %= %% ");
+}
diff --git a/clang/test/CodeGen/2006-10-30-ArrayCrash.c b/clang/test/CodeGen/2006-10-30-ArrayCrash.c
new file mode 100644
index 0000000..67446fd
--- /dev/null
+++ b/clang/test/CodeGen/2006-10-30-ArrayCrash.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -O3 -emit-llvm -o - %s
+// PR954, PR911
+
+extern void foo();
+
+struct S {
+ short f1[3];
+ unsigned int f2 : 1;
+};
+
+void bar()
+{
+ struct S *A;
+
+ if (A->f2)
+ foo();
+}
diff --git a/clang/test/CodeGen/2006-12-14-ordered_expr.c b/clang/test/CodeGen/2006-12-14-ordered_expr.c
new file mode 100644
index 0000000..c46ba85
--- /dev/null
+++ b/clang/test/CodeGen/2006-12-14-ordered_expr.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -O3 -emit-llvm %s -o - | FileCheck %s
+
+int test2(float X, float Y) {
+ // CHECK: fcmp ord float %X, %Y
+ return !__builtin_isunordered(X, Y);
+}
diff --git a/clang/test/CodeGen/2007-01-06-KNR-Proto.c b/clang/test/CodeGen/2007-01-06-KNR-Proto.c
new file mode 100644
index 0000000..d56a786
--- /dev/null
+++ b/clang/test/CodeGen/2007-01-06-KNR-Proto.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+// PR1083
+
+int svc_register (void (*dispatch) (int));
+
+int svc_register (dispatch)
+ void (*dispatch) ();
+{
+}
+
diff --git a/clang/test/CodeGen/2007-01-20-VectorICE.c b/clang/test/CodeGen/2007-01-20-VectorICE.c
new file mode 100644
index 0000000..286b8a1
--- /dev/null
+++ b/clang/test/CodeGen/2007-01-20-VectorICE.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+typedef float __m128 __attribute__((__vector_size__(16)));
+typedef long long __v2di __attribute__((__vector_size__(16)));
+typedef int __v4si __attribute__((__vector_size__(16)));
+
+__v2di bar(void);
+void foo(int X, __v4si *P) {
+ *P = X == 2 ? bar() : bar();
+}
+
diff --git a/clang/test/CodeGen/2007-01-24-InlineAsmCModifier.c b/clang/test/CodeGen/2007-01-24-InlineAsmCModifier.c
new file mode 100644
index 0000000..5158898
--- /dev/null
+++ b/clang/test/CodeGen/2007-01-24-InlineAsmCModifier.c
@@ -0,0 +1,12 @@
+// Verify that the %c modifier works and strips off any prefixes from
+// immediates.
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+void foo() {
+ // CHECK: i32 789514
+ __asm__ volatile("/* " "pickANumber" ": %c0 */"::"i"(0xC0C0A));
+
+ // Check that non-c modifiers work also
+ // CHECK: i32 123
+ __asm__ volatile("/* " "pickANumber2 " ": %0 */"::"i"(123));
+}
diff --git a/clang/test/CodeGen/2007-02-04-AddrLValue-2.c b/clang/test/CodeGen/2007-02-04-AddrLValue-2.c
new file mode 100644
index 0000000..bc44d14
--- /dev/null
+++ b/clang/test/CodeGen/2007-02-04-AddrLValue-2.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -O3 -emit-llvm -o -
+// PR1173
+
+struct S { char s; };
+struct T { struct S t; };
+
+struct S *const p = &((struct T * const) (0x4000))->t;
+
+void
+foo (void)
+{
+ p->s = 0;
+}
diff --git a/clang/test/CodeGen/2007-02-04-AddrLValue.c b/clang/test/CodeGen/2007-02-04-AddrLValue.c
new file mode 100644
index 0000000..400dcb6
--- /dev/null
+++ b/clang/test/CodeGen/2007-02-04-AddrLValue.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -O3 -emit-llvm -o -
+// PR1176
+
+typedef struct
+{
+ char *key;
+ char *value;
+} T1;
+
+typedef struct
+{
+ long type;
+ char *value;
+} T3;
+
+T1 a[] =
+{
+ {
+ "",
+ ((char *)&((T3) {1, (char *) 1}))
+ }
+};
+
diff --git a/clang/test/CodeGen/2007-02-04-EmptyStruct.c b/clang/test/CodeGen/2007-02-04-EmptyStruct.c
new file mode 100644
index 0000000..2b2896f
--- /dev/null
+++ b/clang/test/CodeGen/2007-02-04-EmptyStruct.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -O3 -emit-llvm -o -
+// PR1175
+
+struct empty { };
+
+void foo(struct empty *p) {
+ p++;
+}
+
diff --git a/clang/test/CodeGen/2007-02-07-AddrLabel.c b/clang/test/CodeGen/2007-02-07-AddrLabel.c
new file mode 100644
index 0000000..25eb894
--- /dev/null
+++ b/clang/test/CodeGen/2007-02-07-AddrLabel.c
@@ -0,0 +1,10 @@
+// PR947
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+void foo() {
+ void *ptr;
+ label:
+ ptr = &&label;
+
+ goto *ptr;
+ }
diff --git a/clang/test/CodeGen/2007-02-16-VoidPtrDiff.c b/clang/test/CodeGen/2007-02-16-VoidPtrDiff.c
new file mode 100644
index 0000000..c9f6714
--- /dev/null
+++ b/clang/test/CodeGen/2007-02-16-VoidPtrDiff.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+void foo(void *ptr, int test) {
+ (ptr - ((void *) test + 0x2000));
+}
diff --git a/clang/test/CodeGen/2007-02-25-C-DotDotDot.c b/clang/test/CodeGen/2007-02-25-C-DotDotDot.c
new file mode 100644
index 0000000..7b2e418
--- /dev/null
+++ b/clang/test/CodeGen/2007-02-25-C-DotDotDot.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -O0 %s -emit-llvm -o - | FileCheck %s
+
+// Make sure the call to foo is compiled as:
+// call float @foo()
+// not
+// call float (...)* bitcast (float ()* @foo to float (...)*)( )
+
+static float foo() { return 0.0; }
+// CHECK: call float @foo
+float bar() { return foo()*10.0;}
diff --git a/clang/test/CodeGen/2007-03-01-VarSizeArrayIdx.c b/clang/test/CodeGen/2007-03-01-VarSizeArrayIdx.c
new file mode 100644
index 0000000..7a9f89a
--- /dev/null
+++ b/clang/test/CodeGen/2007-03-01-VarSizeArrayIdx.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -O3 -emit-llvm -o - | grep mul
+// PR1233
+
+float foo(int w, float A[][w], int g, int h) {
+ return A[g][0];
+}
+
diff --git a/clang/test/CodeGen/2007-03-05-DataLayout.c b/clang/test/CodeGen/2007-03-05-DataLayout.c
new file mode 100644
index 0000000..7519624
--- /dev/null
+++ b/clang/test/CodeGen/2007-03-05-DataLayout.c
@@ -0,0 +1,55 @@
+// Testcase for PR1242
+// RUN: %clang_cc1 -emit-llvm %s -o - | grep datalayout | \
+// RUN: not grep {"\[Ee\]-p:\[36\]\[24\]:\[36\]\[24\]"}
+// END.
+
+typedef __SIZE_TYPE__ size_t;
+void * malloc(size_t size);
+#define NDIM 3
+#define BODY 01
+typedef double vector[NDIM];
+typedef struct bnode* bodyptr;
+// { i16, double, [3 x double], i32, i32, [3 x double], [3 x double], [3 x
+// double], double, \2 *, \2 * }
+struct bnode {
+ short int type;
+ double mass;
+ vector pos;
+ int proc;
+ int new_proc;
+ vector vel;
+ vector acc;
+ vector new_acc;
+ double phi;
+ bodyptr next;
+ bodyptr proc_next;
+} body;
+
+#define Type(x) ((x)->type)
+#define Mass(x) ((x)->mass)
+#define Pos(x) ((x)->pos)
+#define Proc(x) ((x)->proc)
+#define New_Proc(x) ((x)->new_proc)
+#define Vel(x) ((x)->vel)
+#define Acc(x) ((x)->acc)
+#define New_Acc(x) ((x)->new_acc)
+#define Phi(x) ((x)->phi)
+#define Next(x) ((x)->next)
+#define Proc_Next(x) ((x)->proc_next)
+
+bodyptr ubody_alloc(int p)
+{
+ register bodyptr tmp;
+ tmp = (bodyptr)malloc(sizeof(body));
+
+ Type(tmp) = BODY;
+ Proc(tmp) = p;
+ Proc_Next(tmp) = NULL;
+ New_Proc(tmp) = p;
+ return tmp;
+}
+
+int main(int argc, char** argv) {
+ bodyptr b = ubody_alloc(17);
+ return 0;
+}
diff --git a/clang/test/CodeGen/2007-03-26-BitfieldAfterZeroWidth.c b/clang/test/CodeGen/2007-03-26-BitfieldAfterZeroWidth.c
new file mode 100644
index 0000000..b4a42d9
--- /dev/null
+++ b/clang/test/CodeGen/2007-03-26-BitfieldAfterZeroWidth.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+struct W {};
+struct Y {
+ struct W w;
+ int i:1;
+} __attribute__ ((packed)) y;
diff --git a/clang/test/CodeGen/2007-03-26-ZeroWidthBitfield.c b/clang/test/CodeGen/2007-03-26-ZeroWidthBitfield.c
new file mode 100644
index 0000000..0bf42ad
--- /dev/null
+++ b/clang/test/CodeGen/2007-03-26-ZeroWidthBitfield.c
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+struct Z { int :0; } z;
diff --git a/clang/test/CodeGen/2007-03-27-VarLengthArray.c b/clang/test/CodeGen/2007-03-27-VarLengthArray.c
new file mode 100644
index 0000000..ec11f55
--- /dev/null
+++ b/clang/test/CodeGen/2007-03-27-VarLengthArray.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: getelementptr inbounds i32* %{{vla|[0-9]}}
+extern void f(int *);
+int e(int m, int n) {
+ int x[n];
+ f(x);
+ return x[m];
+}
diff --git a/clang/test/CodeGen/2007-04-05-PackedBitFields-2.c b/clang/test/CodeGen/2007-04-05-PackedBitFields-2.c
new file mode 100644
index 0000000..41e6b7d
--- /dev/null
+++ b/clang/test/CodeGen/2007-04-05-PackedBitFields-2.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+# define pck __attribute__((packed))
+
+
+struct pck F {
+ unsigned long long i : 12,
+ j : 23,
+ k : 27,
+ l;
+};
+struct F f1;
+
+void foo() {
+ f1.l = 5;
+}
diff --git a/clang/test/CodeGen/2007-04-05-PackedBitFields.c b/clang/test/CodeGen/2007-04-05-PackedBitFields.c
new file mode 100644
index 0000000..5c824a3
--- /dev/null
+++ b/clang/test/CodeGen/2007-04-05-PackedBitFields.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+# define pck __attribute__((packed))
+
+
+struct pck E {
+ unsigned long long l,
+ i : 12,
+ j : 23,
+ k : 29; };
+
+struct E e1;
+
+void foo() {
+ e1.k = 5;
+}
diff --git a/clang/test/CodeGen/2007-04-05-PackedStruct.c b/clang/test/CodeGen/2007-04-05-PackedStruct.c
new file mode 100644
index 0000000..1e9171e
--- /dev/null
+++ b/clang/test/CodeGen/2007-04-05-PackedStruct.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+#pragma pack(push, 2)
+
+enum {
+ tA = 0,
+ tB = 1
+};
+
+struct MyStruct {
+ unsigned long A;
+ char C;
+ void * B;
+};
+
+void bar(){
+struct MyStruct MS = { tB, 0 };
+}
diff --git a/clang/test/CodeGen/2007-04-05-PadBeforeZeroLengthField.c b/clang/test/CodeGen/2007-04-05-PadBeforeZeroLengthField.c
new file mode 100644
index 0000000..f3005b5
--- /dev/null
+++ b/clang/test/CodeGen/2007-04-05-PadBeforeZeroLengthField.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+struct c__ { unsigned int type:4; };
+union A { struct c__ c; } __attribute__((aligned(8)));
+struct B {
+ unsigned int retainCount;
+ union A objects[];
+};
+void foo(union A * objects, struct B *array, unsigned long k)
+{ array->objects[k] = objects[k]; }
diff --git a/clang/test/CodeGen/2007-04-05-UnPackedStruct.c b/clang/test/CodeGen/2007-04-05-UnPackedStruct.c
new file mode 100644
index 0000000..e7a8df6
--- /dev/null
+++ b/clang/test/CodeGen/2007-04-05-UnPackedStruct.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+
+enum {
+ tA = 0,
+ tB = 1
+};
+
+struct MyStruct {
+ unsigned long A;
+ void * B;
+};
+
+void bar(){
+struct MyStruct MS = { tB, 0 };
+}
diff --git a/clang/test/CodeGen/2007-04-11-InlineAsmStruct.c b/clang/test/CodeGen/2007-04-11-InlineAsmStruct.c
new file mode 100644
index 0000000..d617fee
--- /dev/null
+++ b/clang/test/CodeGen/2007-04-11-InlineAsmStruct.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+struct V { short X, Y; };
+int bar() {
+ struct V bar;
+ __asm__ volatile("foo %0\n" : "=r"(bar));
+ return bar.X;
+}
diff --git a/clang/test/CodeGen/2007-04-11-InlineAsmUnion.c b/clang/test/CodeGen/2007-04-11-InlineAsmUnion.c
new file mode 100644
index 0000000..6d24d93
--- /dev/null
+++ b/clang/test/CodeGen/2007-04-11-InlineAsmUnion.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+union U { int x; float p; };
+void foo() {
+ union U bar;
+ __asm__ volatile("foo %0\n" : "=r"(bar));
+}
diff --git a/clang/test/CodeGen/2007-04-11-PR1321.c b/clang/test/CodeGen/2007-04-11-PR1321.c
new file mode 100644
index 0000000..6207ecc
--- /dev/null
+++ b/clang/test/CodeGen/2007-04-11-PR1321.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -o /dev/null
+
+struct X {
+ unsigned int e0 : 17;
+ unsigned int e1 : 17;
+ unsigned int e2 : 17;
+ unsigned int e3 : 17;
+ unsigned int e4 : 17;
+ unsigned int e5 : 17;
+ unsigned int e6 : 17;
+ unsigned int e7 : 17;
+} __attribute__((packed)) x;
diff --git a/clang/test/CodeGen/2007-04-13-InlineAsmStruct2.c b/clang/test/CodeGen/2007-04-13-InlineAsmStruct2.c
new file mode 100644
index 0000000..c9a87ff
--- /dev/null
+++ b/clang/test/CodeGen/2007-04-13-InlineAsmStruct2.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+struct V { short X, Y; };
+int bar() {
+ struct V bar;
+ // CHECK: call void asm
+ __asm__ volatile("foo %0\n" :: "r"(bar));
+ return bar.X;
+}
diff --git a/clang/test/CodeGen/2007-04-13-InlineAsmUnion2.c b/clang/test/CodeGen/2007-04-13-InlineAsmUnion2.c
new file mode 100644
index 0000000..a8983b6
--- /dev/null
+++ b/clang/test/CodeGen/2007-04-13-InlineAsmUnion2.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+union U { int x; char* p; };
+void foo() {
+ union U bar;
+ // CHECK: call void asm
+ __asm__ volatile("foo %0\n" :: "r"(bar));
+}
diff --git a/clang/test/CodeGen/2007-04-14-FNoBuiltin.c b/clang/test/CodeGen/2007-04-14-FNoBuiltin.c
new file mode 100644
index 0000000..a5fda63
--- /dev/null
+++ b/clang/test/CodeGen/2007-04-14-FNoBuiltin.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -O2 -fno-builtin -o - | grep call.*printf
+// Check that -fno-builtin is honored.
+
+extern int printf(const char*, ...);
+void foo(const char *msg) {
+ printf("%s\n",msg);
+}
diff --git a/clang/test/CodeGen/2007-04-17-ZeroSizeBitFields.c b/clang/test/CodeGen/2007-04-17-ZeroSizeBitFields.c
new file mode 100644
index 0000000..91b4582
--- /dev/null
+++ b/clang/test/CodeGen/2007-04-17-ZeroSizeBitFields.c
@@ -0,0 +1,4 @@
+// PR 1332
+// RUN: %clang_cc1 %s -emit-llvm -o /dev/null
+
+struct Z { int a:1; int :0; int c:1; } z;
diff --git a/clang/test/CodeGen/2007-04-24-VolatileStructCopy.c b/clang/test/CodeGen/2007-04-24-VolatileStructCopy.c
new file mode 100644
index 0000000..5eeecce
--- /dev/null
+++ b/clang/test/CodeGen/2007-04-24-VolatileStructCopy.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// PR1352
+
+struct foo {
+ int x;
+};
+
+void copy(volatile struct foo *p, struct foo *q) {
+ // CHECK: call void @llvm.memcpy
+ *p = *q;
+}
diff --git a/clang/test/CodeGen/2007-04-24-bit-not-expr.c b/clang/test/CodeGen/2007-04-24-bit-not-expr.c
new file mode 100644
index 0000000..9d99caf
--- /dev/null
+++ b/clang/test/CodeGen/2007-04-24-bit-not-expr.c
@@ -0,0 +1,7 @@
+// PR 1346
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+extern bar(void *);
+
+void f(void *cd) {
+ bar(((void *)((unsigned long)(cd) ^ -1)));
+}
diff --git a/clang/test/CodeGen/2007-04-24-str-const.c b/clang/test/CodeGen/2007-04-24-str-const.c
new file mode 100644
index 0000000..1d86d1c
--- /dev/null
+++ b/clang/test/CodeGen/2007-04-24-str-const.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+static char *str;
+
+static const struct {
+ const char *name;
+ unsigned type;
+} scan_special[] = {
+ {"shift", 1},
+ {0, 0}
+};
+
+static void
+sb(void)
+{
+ while (*str == ' ' || *str == '\t')
+ str++;
+}
diff --git a/clang/test/CodeGen/2007-05-07-PaddingElements.c b/clang/test/CodeGen/2007-05-07-PaddingElements.c
new file mode 100644
index 0000000..574a377
--- /dev/null
+++ b/clang/test/CodeGen/2007-05-07-PaddingElements.c
@@ -0,0 +1,12 @@
+// PR 1278
+// RUN: %clang_cc1 %s -emit-llvm -O0 -o - | grep {struct.s} | not grep "4 x i8] zeroinitializer"
+// RUN: %clang_cc1 %s -emit-llvm -O0 -o - | not grep "i32 0, i32 2"
+struct s {
+ double d1;
+ int s1;
+};
+
+struct s foo(void) {
+ struct s S = {1.1, 2};
+ return S;
+}
diff --git a/clang/test/CodeGen/2007-05-08-PCH.c b/clang/test/CodeGen/2007-05-08-PCH.c
new file mode 100644
index 0000000..c45d57c
--- /dev/null
+++ b/clang/test/CodeGen/2007-05-08-PCH.c
@@ -0,0 +1,7 @@
+// PR 1400
+// RUN: %clang_cc1 -x c-header %s -o /dev/null
+
+int main() {
+ return 0;
+}
+
diff --git a/clang/test/CodeGen/2007-05-11-str-const.c b/clang/test/CodeGen/2007-05-11-str-const.c
new file mode 100644
index 0000000..731496d
--- /dev/null
+++ b/clang/test/CodeGen/2007-05-11-str-const.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm -g %s -o /dev/null
+
+static unsigned char out[]={0,1};
+static const unsigned char str1[]="1";
+
diff --git a/clang/test/CodeGen/2007-05-15-PaddingElement.c b/clang/test/CodeGen/2007-05-15-PaddingElement.c
new file mode 100644
index 0000000..5aa4f2e
--- /dev/null
+++ b/clang/test/CodeGen/2007-05-15-PaddingElement.c
@@ -0,0 +1,23 @@
+// PR 1419
+
+// RUN: %clang_cc1 -O2 %s -emit-llvm -o - | grep "ret i32 1"
+struct A {
+ short x;
+ long long :0;
+};
+
+struct B {
+ char a;
+ char b;
+ unsigned char i;
+};
+
+union X { struct A a; struct B b; };
+
+int check(void) {
+ union X x, y;
+
+ y.b.i = 0xff;
+ x = y;
+ return (x.b.i == 0xff);
+}
diff --git a/clang/test/CodeGen/2007-05-16-EmptyStruct.c b/clang/test/CodeGen/2007-05-16-EmptyStruct.c
new file mode 100644
index 0000000..14aaff0
--- /dev/null
+++ b/clang/test/CodeGen/2007-05-16-EmptyStruct.c
@@ -0,0 +1,5 @@
+// PR 1417
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: global %struct.anon* null
+struct { } *X;
diff --git a/clang/test/CodeGen/2007-05-29-UnionCopy.c b/clang/test/CodeGen/2007-05-29-UnionCopy.c
new file mode 100644
index 0000000..9f71687
--- /dev/null
+++ b/clang/test/CodeGen/2007-05-29-UnionCopy.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | grep memcpy
+// PR1421
+
+struct A {
+ char c;
+ int i;
+};
+
+struct B {
+ int c;
+ unsigned char x;
+};
+
+union U { struct A a; struct B b; };
+
+void check(union U *u, union U *v) {
+ *u = *v;
+}
diff --git a/clang/test/CodeGen/2007-06-05-NoInlineAttribute.c b/clang/test/CodeGen/2007-06-05-NoInlineAttribute.c
new file mode 100644
index 0000000..26aad88
--- /dev/null
+++ b/clang/test/CodeGen/2007-06-05-NoInlineAttribute.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -O2 -emit-llvm %s -o - | grep call
+
+static int bar(int x, int y) __attribute__((noinline));
+
+static int bar(int x, int y)
+{
+ return x + y;
+}
+
+int foo(int a, int b) {
+ return bar(b, a);
+}
+
diff --git a/clang/test/CodeGen/2007-06-15-AnnotateAttribute.c b/clang/test/CodeGen/2007-06-15-AnnotateAttribute.c
new file mode 100644
index 0000000..de34866
--- /dev/null
+++ b/clang/test/CodeGen/2007-06-15-AnnotateAttribute.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | grep llvm.global.annotations
+// RUN: %clang_cc1 -emit-llvm %s -o - | grep llvm.var.annotation | count 3
+
+/* Global variable with attribute */
+int X __attribute__((annotate("GlobalValAnnotation")));
+
+/* Function with attribute */
+int foo(int y) __attribute__((annotate("GlobalValAnnotation")))
+ __attribute__((noinline));
+
+int foo(int y __attribute__((annotate("LocalValAnnotation")))) {
+ int x __attribute__((annotate("LocalValAnnotation")));
+ x = 34;
+ return y + x;
+}
+
+int main() {
+ static int a __attribute__((annotate("GlobalValAnnotation")));
+ a = foo(2);
+ return 0;
+}
diff --git a/clang/test/CodeGen/2007-06-18-SextAttrAggregate.c b/clang/test/CodeGen/2007-06-18-SextAttrAggregate.c
new file mode 100644
index 0000000..27ae6a9
--- /dev/null
+++ b/clang/test/CodeGen/2007-06-18-SextAttrAggregate.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -o - -emit-llvm | FileCheck %s
+// PR1513
+
+struct s{
+long a;
+long b;
+};
+
+void f(struct s a, char *b, signed char C) {
+ // CHECK: i8 signext
+
+}
diff --git a/clang/test/CodeGen/2007-07-29-RestrictPtrArg.c b/clang/test/CodeGen/2007-07-29-RestrictPtrArg.c
new file mode 100644
index 0000000..b6d61a7
--- /dev/null
+++ b/clang/test/CodeGen/2007-07-29-RestrictPtrArg.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | grep noalias
+
+void foo(int * __restrict myptr1, int * myptr2) {
+ myptr1[0] = 0;
+ myptr2[0] = 0;
+}
diff --git a/clang/test/CodeGen/2007-08-01-LoadStoreAlign.c b/clang/test/CodeGen/2007-08-01-LoadStoreAlign.c
new file mode 100644
index 0000000..87cf163
--- /dev/null
+++ b/clang/test/CodeGen/2007-08-01-LoadStoreAlign.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+struct p {
+ char a;
+ int b;
+} __attribute__ ((packed));
+
+struct p t = { 1, 10 };
+struct p u;
+
+int main () {
+ // CHECK: align 1
+ // CHECK: align 1
+ int tmp = t.b;
+ u.b = tmp;
+ return tmp;
+
+}
diff --git a/clang/test/CodeGen/2007-08-21-ComplexCst.c b/clang/test/CodeGen/2007-08-21-ComplexCst.c
new file mode 100644
index 0000000..cd9ceb1
--- /dev/null
+++ b/clang/test/CodeGen/2007-08-21-ComplexCst.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -O2 -emit-llvm %s -o /dev/null
+void f(_Complex float z);
+void g() { f(1.0i); }
diff --git a/clang/test/CodeGen/2007-08-22-CTTZ.c b/clang/test/CodeGen/2007-08-22-CTTZ.c
new file mode 100644
index 0000000..9067c5a
--- /dev/null
+++ b/clang/test/CodeGen/2007-08-22-CTTZ.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+int bork(unsigned long long x) {
+ // CHECK: llvm.cttz.i64
+ // CHECK: llvm.cttz.i64
+ // CHECK-NOT: lshr
+ return __builtin_ctzll(x);
+}
diff --git a/clang/test/CodeGen/2007-09-05-ConstCtor.c b/clang/test/CodeGen/2007-09-05-ConstCtor.c
new file mode 100644
index 0000000..138b818
--- /dev/null
+++ b/clang/test/CodeGen/2007-09-05-ConstCtor.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -Os -emit-llvm %s -o /dev/null
+// PR1641
+
+struct A {
+ unsigned long l;
+};
+
+void bar(struct A *a);
+
+void bork() {
+ const unsigned long vcgt = 1234;
+ struct A a = { vcgt };
+ bar(&a);
+}
diff --git a/clang/test/CodeGen/2007-09-12-PragmaPack.c b/clang/test/CodeGen/2007-09-12-PragmaPack.c
new file mode 100644
index 0000000..71c7537
--- /dev/null
+++ b/clang/test/CodeGen/2007-09-12-PragmaPack.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+
+#pragma pack(push, 1)
+typedef struct
+{
+ uint32_t a;
+} foo;
+
+typedef struct {
+ uint8_t major;
+ uint8_t minor;
+ uint16_t build;
+} VERSION;
+
+typedef struct {
+ uint8_t a[5];
+ VERSION version;
+ uint8_t b;
+ foo d;
+ uint32_t guard;
+} bar;
+#pragma pack(pop)
+
+
+unsigned barsize(void) {
+ // CHECK: ret i32 18
+ return sizeof(bar);
+}
diff --git a/clang/test/CodeGen/2007-09-14-NegatePointer.c b/clang/test/CodeGen/2007-09-14-NegatePointer.c
new file mode 100644
index 0000000..52367e6
--- /dev/null
+++ b/clang/test/CodeGen/2007-09-14-NegatePointer.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+// PR1662
+
+int foo(unsigned char *test) {
+ return 0U - (unsigned int )test;
+}
+
diff --git a/clang/test/CodeGen/2007-09-17-WeakRef.c b/clang/test/CodeGen/2007-09-17-WeakRef.c
new file mode 100644
index 0000000..3047b7f
--- /dev/null
+++ b/clang/test/CodeGen/2007-09-17-WeakRef.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -O1 -emit-llvm %s -o - | grep icmp
+// PR1678
+
+extern void B (void);
+static __typeof(B) A __attribute__ ((__weakref__("B")));
+int active (void)
+{
+ static void *const p = __extension__ (void *) &A;
+ return p != 0;
+}
diff --git a/clang/test/CodeGen/2007-09-26-Alignment.c b/clang/test/CodeGen/2007-09-26-Alignment.c
new file mode 100644
index 0000000..8ab130b
--- /dev/null
+++ b/clang/test/CodeGen/2007-09-26-Alignment.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+extern p(int *);
+int q(void) {
+ // CHECK: alloca i32, align 16
+ int x __attribute__ ((aligned (16)));
+ p(&x);
+ return x;
+}
diff --git a/clang/test/CodeGen/2007-09-27-ComplexIntCompare.c b/clang/test/CodeGen/2007-09-27-ComplexIntCompare.c
new file mode 100644
index 0000000..d07aa0c
--- /dev/null
+++ b/clang/test/CodeGen/2007-09-27-ComplexIntCompare.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+// PR1708
+
+void __attribute__((noreturn)) abort(void);
+
+struct s { _Complex unsigned short x; };
+struct s gs = { 100 + 200i };
+struct s __attribute__((noinline)) foo (void) { return gs; }
+
+int main ()
+{
+ if (foo ().x != gs.x)
+ abort ();
+ exit (0);
+}
diff --git a/clang/test/CodeGen/2007-09-28-PackedUnionMember.c b/clang/test/CodeGen/2007-09-28-PackedUnionMember.c
new file mode 100644
index 0000000..f018306
--- /dev/null
+++ b/clang/test/CodeGen/2007-09-28-PackedUnionMember.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+#pragma pack(push, 2)
+struct H {
+ unsigned long f1;
+ unsigned long f2;
+ union {
+ struct opaque1 *f3;
+ struct opaque2 *f4;
+ struct {
+ struct opaque3 *f5;
+ unsigned short f6;
+ } f7;
+ } f8;
+};
+#pragma pack(pop)
+
+struct E {
+ unsigned long f1;
+ unsigned long f2;
+};
+
+typedef long (*FuncPtr) ();
+
+extern long bork(FuncPtr handler, const struct E *list);
+
+static long hndlr()
+{
+ struct H cmd = { 4, 412 };
+ struct H cmd2 = { 4, 412, 0 };
+ return 0;
+}
+void foo(void *inWindow) {
+ static const struct E events[] = {
+ { 123124, 1 }
+ };
+ bork(hndlr, events);
+}
diff --git a/clang/test/CodeGen/2007-10-02-VolatileArray.c b/clang/test/CodeGen/2007-10-02-VolatileArray.c
new file mode 100644
index 0000000..b1dcb7e
--- /dev/null
+++ b/clang/test/CodeGen/2007-10-02-VolatileArray.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | grep volatile
+// PR1647
+
+void foo(volatile int *p)
+{
+p[0] = 0;
+}
diff --git a/clang/test/CodeGen/2007-10-15-VoidPtr.c b/clang/test/CodeGen/2007-10-15-VoidPtr.c
new file mode 100644
index 0000000..0bbff3d
--- /dev/null
+++ b/clang/test/CodeGen/2007-10-15-VoidPtr.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+void bork(void **data) {
+ (*(unsigned short *) (&(data[37])[927]) = 0);
+}
diff --git a/clang/test/CodeGen/2007-10-30-Volatile.c b/clang/test/CodeGen/2007-10-30-Volatile.c
new file mode 100644
index 0000000..17aac1a
--- /dev/null
+++ b/clang/test/CodeGen/2007-10-30-Volatile.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null -Wall -Werror
+void bork() {
+ char * volatile p = 0;
+ volatile int cc = 0;
+ p += cc;
+}
diff --git a/clang/test/CodeGen/2007-11-07-AlignedMemcpy.c b/clang/test/CodeGen/2007-11-07-AlignedMemcpy.c
new file mode 100644
index 0000000..829b60c
--- /dev/null
+++ b/clang/test/CodeGen/2007-11-07-AlignedMemcpy.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+void bork() {
+ int Qux[33] = {0};
+}
diff --git a/clang/test/CodeGen/2007-11-07-CopyAggregateAlign.c b/clang/test/CodeGen/2007-11-07-CopyAggregateAlign.c
new file mode 100644
index 0000000..08d9770
--- /dev/null
+++ b/clang/test/CodeGen/2007-11-07-CopyAggregateAlign.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+struct A { char s, t, u, v; short a; };
+// CHECK: %a = alloca %struct.A, align 2
+// CHECK: %b = alloca %struct.A, align 2
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.{{.*}}, i32 2, i1 false)
+
+void q() { struct A a, b; a = b; }
diff --git a/clang/test/CodeGen/2007-11-07-ZeroAggregateAlign.c b/clang/test/CodeGen/2007-11-07-ZeroAggregateAlign.c
new file mode 100644
index 0000000..b059607
--- /dev/null
+++ b/clang/test/CodeGen/2007-11-07-ZeroAggregateAlign.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+struct A { short s; short t; int i; };
+// CHECK: %a = alloca %struct.A, align 4
+// CHECK: call void @llvm.memset.p0i8.{{.*}}i32 4, i1 false)
+void q() { struct A a = {0}; }
diff --git a/clang/test/CodeGen/2007-11-28-GlobalInitializer.c b/clang/test/CodeGen/2007-11-28-GlobalInitializer.c
new file mode 100644
index 0000000..a79ccdd
--- /dev/null
+++ b/clang/test/CodeGen/2007-11-28-GlobalInitializer.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+// PR1744
+typedef struct foo { int x; char *p; } FOO;
+extern FOO yy[];
+
+int *y = &((yy + 1)->x);
+void *z = &((yy + 1)->x);
+
diff --git a/clang/test/CodeGen/2007-11-29-ArraySizeFromInitializer.c b/clang/test/CodeGen/2007-11-29-ArraySizeFromInitializer.c
new file mode 100644
index 0000000..a1ec633
--- /dev/null
+++ b/clang/test/CodeGen/2007-11-29-ArraySizeFromInitializer.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+int array[] = {1, 2, 3, 4, 5};
+
diff --git a/clang/test/CodeGen/2007-12-16-AsmNoUnwind.c b/clang/test/CodeGen/2007-12-16-AsmNoUnwind.c
new file mode 100644
index 0000000..de078a2
--- /dev/null
+++ b/clang/test/CodeGen/2007-12-16-AsmNoUnwind.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | grep nounwind
+
+void bar() { asm (""); }
diff --git a/clang/test/CodeGen/2008-01-04-WideBitfield.c b/clang/test/CodeGen/2008-01-04-WideBitfield.c
new file mode 100644
index 0000000..e1c7a38
--- /dev/null
+++ b/clang/test/CodeGen/2008-01-04-WideBitfield.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+// PR1386
+typedef unsigned long long uint64_t;
+struct X {
+ unsigned char pad : 4;
+ uint64_t a : 64;
+} __attribute__((packed)) x;
+
+uint64_t f(void)
+{
+ return x.a;
+}
diff --git a/clang/test/CodeGen/2008-01-07-UnusualIntSize.c b/clang/test/CodeGen/2008-01-07-UnusualIntSize.c
new file mode 100644
index 0000000..bf0ca55
--- /dev/null
+++ b/clang/test/CodeGen/2008-01-07-UnusualIntSize.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// PR1721
+
+struct s {
+ unsigned long long u33: 33;
+} a, b;
+
+// This should have %0 and %1 truncated to 33 bits before any operation.
+// This can be done using i33 or an explicit and.
+_Bool test(void) {
+ // CHECK: and i64 %[[TMP1:[0-9]+]], 8589934591
+ // CHECK-NOT: and i64 [[TMP1]], 8589934591
+ // CHECK: and i64 %{{[0-9]}}, 8589934591
+ return a.u33 + b.u33 != 0;
+}
diff --git a/clang/test/CodeGen/2008-01-11-ChainConsistency.c b/clang/test/CodeGen/2008-01-11-ChainConsistency.c
new file mode 100644
index 0000000..9ae021f
--- /dev/null
+++ b/clang/test/CodeGen/2008-01-11-ChainConsistency.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -fnested-functions | not grep nest
+
+void n1(void) { void a(void) { a(); } a(); }
diff --git a/clang/test/CodeGen/2008-01-21-PackedBitFields.c b/clang/test/CodeGen/2008-01-21-PackedBitFields.c
new file mode 100644
index 0000000..a649475
--- /dev/null
+++ b/clang/test/CodeGen/2008-01-21-PackedBitFields.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+typedef double Al1Double __attribute__((aligned(1)));
+struct x { int a:23; Al1Double v; };
+struct x X = { 5, 3.0 };
+double foo() { return X.v; }
+
diff --git a/clang/test/CodeGen/2008-01-21-PackedStructField.c b/clang/test/CodeGen/2008-01-21-PackedStructField.c
new file mode 100644
index 0000000..aa1bee4
--- /dev/null
+++ b/clang/test/CodeGen/2008-01-21-PackedStructField.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+struct X { long double b; unsigned char c; double __attribute__((packed)) d; };
+struct X x = { 3.0L, 5, 3.0 };
+
+
+struct S2504 {
+ int e:17;
+ __attribute__((packed)) unsigned long long int f;
+} ;
+int fails;
+ extern struct S2504 s2504;
+void check2504va (int z) {
+ struct S2504 arg, *p;
+ long long int i = 0;
+ arg.f = i;
+}
+
diff --git a/clang/test/CodeGen/2008-01-24-StructAlignAndBitFields.c b/clang/test/CodeGen/2008-01-24-StructAlignAndBitFields.c
new file mode 100644
index 0000000..eae48b3
--- /dev/null
+++ b/clang/test/CodeGen/2008-01-24-StructAlignAndBitFields.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+struct U { char a; short b; int c:25; char d; } u;
+
diff --git a/clang/test/CodeGen/2008-01-25-ByValReadNone.c b/clang/test/CodeGen/2008-01-25-ByValReadNone.c
new file mode 100644
index 0000000..06ad1ee
--- /dev/null
+++ b/clang/test/CodeGen/2008-01-25-ByValReadNone.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | not grep readonly
+// RUN: %clang_cc1 -emit-llvm -o - %s | not grep readnone
+
+// XFAIL: arm
+
+// The struct being passed byval means that we cannot mark the
+// function readnone. Readnone would allow stores to the arg to
+// be deleted in the caller. We also don't allow readonly since
+// the callee might write to the byval parameter. The inliner
+// would have to assume the worse and introduce an explicit
+// temporary when inlining such a function, which is costly for
+// the common case in which the byval argument is not written.
+struct S { int A[1000]; };
+int __attribute__ ((const)) f(struct S x) { x.A[1] = 0; return x.A[0]; }
+int g(struct S x) __attribute__ ((pure));
+int h(struct S x) { return g(x); }
diff --git a/clang/test/CodeGen/2008-01-25-ZeroSizedAggregate.c b/clang/test/CodeGen/2008-01-25-ZeroSizedAggregate.c
new file mode 100644
index 0000000..d905985
--- /dev/null
+++ b/clang/test/CodeGen/2008-01-25-ZeroSizedAggregate.c
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+// Aggregates of size zero should be dropped from argument list.
+typedef long int Tlong;
+struct S2411 {
+ __attribute__((aligned)) Tlong:0;
+};
+
+extern struct S2411 a2411[5];
+extern void checkx2411(struct S2411);
+void test2411(void) {
+ checkx2411(a2411[0]);
+}
+
+// Proper handling of zero sized fields during type conversion.
+typedef unsigned long long int Tal2ullong __attribute__((aligned(2)));
+struct S2525 {
+ Tal2ullong: 0;
+ struct {
+ } e;
+};
+struct S2525 s2525;
+
+struct {
+ signed char f;
+ char :0;
+ struct{}h;
+ char * i[5];
+} data;
+
+// Taking address of a zero sized field.
+struct Z {};
+struct Y {
+ int i;
+ struct Z z;
+};
+void *f(struct Y *y) {
+ return &y->z;
+}
diff --git a/clang/test/CodeGen/2008-01-28-PragmaMark.c b/clang/test/CodeGen/2008-01-28-PragmaMark.c
new file mode 100644
index 0000000..399af95
--- /dev/null
+++ b/clang/test/CodeGen/2008-01-28-PragmaMark.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -Werror -emit-llvm %s -o /dev/null
+#pragma mark LLVM's world
+#ifdef DO_ERROR
+#error LLVM's world
+#endif
+int i;
diff --git a/clang/test/CodeGen/2008-01-28-UnionSize.c b/clang/test/CodeGen/2008-01-28-UnionSize.c
new file mode 100644
index 0000000..14f363d
--- /dev/null
+++ b/clang/test/CodeGen/2008-01-28-UnionSize.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+// PR 1861
+
+typedef unsigned char __u8;
+typedef unsigned int __u32;
+typedef unsigned short u16;
+typedef __u32 __le32;
+struct bcm43xx_plcp_hdr6 {
+ union {
+ __le32 data;
+ __u8 raw[6];
+ }
+ __attribute__((__packed__));
+}
+ __attribute__((__packed__));
+struct bcm43xx_txhdr {
+ union {
+ struct {
+ struct bcm43xx_plcp_hdr6 plcp;
+ };
+ };
+}
+ __attribute__((__packed__));
+static void bcm43xx_generate_rts(struct bcm43xx_txhdr *txhdr ) { }
diff --git a/clang/test/CodeGen/2008-02-07-bitfield-bug.c b/clang/test/CodeGen/2008-02-07-bitfield-bug.c
new file mode 100644
index 0000000..73e31e7
--- /dev/null
+++ b/clang/test/CodeGen/2008-02-07-bitfield-bug.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+// PR1990
+
+struct test {
+ char a[3];
+ unsigned char b:1;
+};
+
+void f(struct test *t) {
+ t->b = 1;
+}
diff --git a/clang/test/CodeGen/2008-02-08-bitfield-bug.c b/clang/test/CodeGen/2008-02-08-bitfield-bug.c
new file mode 100644
index 0000000..1549b72
--- /dev/null
+++ b/clang/test/CodeGen/2008-02-08-bitfield-bug.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+
+struct test {
+ unsigned a:1;
+ unsigned b:1;
+};
+
+struct test *t;
+
diff --git a/clang/test/CodeGen/2008-02-26-inline-asm-bug.c b/clang/test/CodeGen/2008-02-26-inline-asm-bug.c
new file mode 100644
index 0000000..1103e9b
--- /dev/null
+++ b/clang/test/CodeGen/2008-02-26-inline-asm-bug.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm < %s | grep "\$0,\$1"
+
+void f() {
+ int d1, d2;
+ asm("%0,%1": "=r" (d1) : "r" (d2));
+}
diff --git a/clang/test/CodeGen/2008-03-03-CtorAttrType.c b/clang/test/CodeGen/2008-03-03-CtorAttrType.c
new file mode 100644
index 0000000..dbd7bc0
--- /dev/null
+++ b/clang/test/CodeGen/2008-03-03-CtorAttrType.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | grep llvm.global_ctors
+int __attribute__((constructor)) foo(void) {
+ return 0;
+}
+void __attribute__((constructor)) bar(void) {}
+
diff --git a/clang/test/CodeGen/2008-03-05-syncPtr.c b/clang/test/CodeGen/2008-03-05-syncPtr.c
new file mode 100644
index 0000000..784295c
--- /dev/null
+++ b/clang/test/CodeGen/2008-03-05-syncPtr.c
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+int* foo(int** a, int* b, int* c) {
+return __sync_val_compare_and_swap (a, b, c);
+}
+// CHECK: define i32* @foo
+// CHECK: cmpxchg
+
+int foo2(int** a, int* b, int* c) {
+return __sync_bool_compare_and_swap (a, b, c);
+}
+// CHECK: define i32 @foo2
+// CHECK: cmpxchg
+
+int* foo3(int** a, int b) {
+ return __sync_fetch_and_add (a, b);
+}
+// CHECK: define i32* @foo3
+// CHECK: atomicrmw add
+
+
+int* foo4(int** a, int b) {
+ return __sync_fetch_and_sub (a, b);
+}
+// CHECK: define i32* @foo4
+// CHECK: atomicrmw sub
+
+
+int* foo5(int** a, int* b) {
+ return __sync_lock_test_and_set (a, b);
+}
+// CHECK: define i32* @foo5
+// CHECK: atomicrmw xchg
+
+
+int* foo6(int** a, int*** b) {
+ return __sync_lock_test_and_set (a, b);
+}
+// CHECK: define i32* @foo6
+// CHECK: atomicrmw xchg
diff --git a/clang/test/CodeGen/2008-03-24-BitField-And-Alloca.c b/clang/test/CodeGen/2008-03-24-BitField-And-Alloca.c
new file mode 100644
index 0000000..cb80d76
--- /dev/null
+++ b/clang/test/CodeGen/2008-03-24-BitField-And-Alloca.c
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -O2 -emit-llvm %s -o - | not grep alloca
+// RUN: %clang_cc1 -m32 -O2 -emit-llvm %s -o - | not grep {store }
+
+enum {
+ PP_C,
+ PP_D,
+ PP_R,
+ PP_2D,
+ PP_1D,
+ PP_SR,
+ PP_S2D,
+ PP_S1D,
+ PP_SC
+};
+
+enum {
+ G_VP,
+ G_FP,
+ G_VS,
+ G_GS,
+ G_FS
+};
+
+enum {
+ G_NONE,
+ G_B,
+ G_R
+};
+
+typedef union _Key {
+ struct {
+ unsigned int count : 2;
+ unsigned int Aconst : 1;
+ unsigned int Bconst : 1;
+ unsigned int Cconst : 1;
+ unsigned int Xused : 1;
+ unsigned int Yused : 1;
+ unsigned int Zused : 1;
+ unsigned int Wused : 1;
+ unsigned int ttype : 3;
+ unsigned int scalar : 1;
+ unsigned int AType : 4;
+ unsigned int BType : 4;
+ unsigned int CType : 4;
+ unsigned int RType : 4;
+ unsigned int Size : 2;
+ unsigned int prec : 1;
+
+ unsigned int ASize : 2;
+ unsigned int BSize : 2;
+ unsigned int CSize : 2;
+ unsigned int tTex : 4;
+ unsigned int proj : 1;
+ unsigned int lod : 2;
+ unsigned int dvts : 1;
+ unsigned int uipad : 18;
+ } key_io;
+ struct {
+ unsigned int key0;
+ unsigned int key1;
+ } key;
+ unsigned long long lkey;
+} Key;
+
+static void foo(const Key iospec, int* ret)
+{
+ *ret=0;
+ if(((iospec.key_io.lod == G_B) &&
+ (iospec.key_io.ttype != G_VS) &&
+ (iospec.key_io.ttype != G_GS) &&
+ (iospec.key_io.ttype != G_FS)) ||
+
+ (((iospec.key_io.tTex == PP_C) ||
+ (iospec.key_io.tTex == PP_SC)) &&
+ ((iospec.key_io.tTex == PP_SR) ||
+ (iospec.key_io.tTex == PP_S2D) ||
+ (iospec.key_io.tTex == PP_S1D) ||
+ (iospec.key_io.tTex == PP_SC))))
+ *ret=1;
+}
+
+
+extern int bar(unsigned long long key_token2)
+{
+ int ret;
+ __attribute__ ((unused)) Key iospec = (Key) key_token2;
+ foo(iospec, &ret);
+ return ret;
+}
diff --git a/clang/test/CodeGen/2008-03-26-PackedBitFields.c b/clang/test/CodeGen/2008-03-26-PackedBitFields.c
new file mode 100644
index 0000000..72e5cb1
--- /dev/null
+++ b/clang/test/CodeGen/2008-03-26-PackedBitFields.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+
+struct S1757 {
+ long double c;
+ long int __attribute__((packed)) e:28;
+} x;
diff --git a/clang/test/CodeGen/2008-04-08-NoExceptions.c b/clang/test/CodeGen/2008-04-08-NoExceptions.c
new file mode 100644
index 0000000..6d5d20f
--- /dev/null
+++ b/clang/test/CodeGen/2008-04-08-NoExceptions.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+void f(void);
+void g(void) {
+ // CHECK: define void @g() nounwind
+ // CHECK-NOT: call void @f() nounwind
+ f();
+}
+
+// CHECK-NOT: declare void @f() nounwind
diff --git a/clang/test/CodeGen/2008-05-06-CFECrash.c b/clang/test/CodeGen/2008-05-06-CFECrash.c
new file mode 100644
index 0000000..1177567
--- /dev/null
+++ b/clang/test/CodeGen/2008-05-06-CFECrash.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm -O2 %s -o /dev/null
+// PR2292.
+__inline__ __attribute__ ((__pure__)) int g (void) {}
+void f (int k) { k = g (); }
diff --git a/clang/test/CodeGen/2008-05-12-TempUsedBeforeDef.c b/clang/test/CodeGen/2008-05-12-TempUsedBeforeDef.c
new file mode 100644
index 0000000..bc2886e
--- /dev/null
+++ b/clang/test/CodeGen/2008-05-12-TempUsedBeforeDef.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -w -emit-llvm -o /dev/null %s
+// PR2264.
+unsigned foo = 8L;
+unsigned bar = 0L;
+volatile unsigned char baz = 6L;
+int test() {
+ char qux = 1L;
+ for (; baz >= -29; baz--)
+ bork(bar && foo, qux);
+}
diff --git a/clang/test/CodeGen/2008-05-19-AlwaysInline.c b/clang/test/CodeGen/2008-05-19-AlwaysInline.c
new file mode 100644
index 0000000..73a7691
--- /dev/null
+++ b/clang/test/CodeGen/2008-05-19-AlwaysInline.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -fno-unit-at-a-time -O0 -o - | not grep sabrina
+// RUN: %clang_cc1 %s -emit-llvm -funit-at-a-time -O0 -o - | not grep sabrina
+
+static inline int sabrina (void) __attribute__((always_inline));
+static inline int sabrina (void)
+{
+ return 13;
+}
+int bar (void)
+{
+ return sabrina () + 68;
+}
diff --git a/clang/test/CodeGen/2008-07-17-no-emit-on-error.c b/clang/test/CodeGen/2008-07-17-no-emit-on-error.c
new file mode 100644
index 0000000..2cae57b
--- /dev/null
+++ b/clang/test/CodeGen/2008-07-17-no-emit-on-error.c
@@ -0,0 +1,15 @@
+// RUN: rm -f %t1.bc
+// RUN: %clang_cc1 -DPASS %s -emit-llvm-bc -o %t1.bc
+// RUN: opt %t1.bc -disable-output
+// RUN: rm -f %t1.bc
+// RUN: not %clang_cc1 %s -emit-llvm-bc -o %t1.bc
+// RUN: not opt %t1.bc -disable-output
+
+void f() {
+}
+
+#ifndef PASS
+void g() {
+ *10;
+}
+#endif
diff --git a/clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c b/clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
new file mode 100644
index 0000000..ac13260
--- /dev/null
+++ b/clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+int g0, f0();
+int f1(), g1;
+
+// CHECK: @g0 = common global i32 0, align 4
+// CHECK: @g1 = common global i32 0, align 4
+
diff --git a/clang/test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c b/clang/test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c
new file mode 100644
index 0000000..33bd800
--- /dev/null
+++ b/clang/test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm -o - %s | FileCheck %s
+
+struct et7 {
+ float lv7[0];
+ char mv7:6;
+} yv7 = {
+ {},
+ 52,
+};
+
+// CHECK: @yv7 = global
+// CHECK: i8 52,
diff --git a/clang/test/CodeGen/2008-07-22-packed-bitfield-access.c b/clang/test/CodeGen/2008-07-22-packed-bitfield-access.c
new file mode 100644
index 0000000..76b942d
--- /dev/null
+++ b/clang/test/CodeGen/2008-07-22-packed-bitfield-access.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+int main () {
+ struct foo {
+ unsigned a:16;
+ unsigned b:32 __attribute__ ((packed));
+ } x;
+ x.b = 0x56789abcL;
+ return 0;
+}
diff --git a/clang/test/CodeGen/2008-07-29-override-alias-decl.c b/clang/test/CodeGen/2008-07-29-override-alias-decl.c
new file mode 100644
index 0000000..0c2d0c6
--- /dev/null
+++ b/clang/test/CodeGen/2008-07-29-override-alias-decl.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+int x() { return 1; }
+
+// CHECK: ret i32 1
+
+
+int f() __attribute__((weak, alias("x")));
+
+/* Test that we link to the alias correctly instead of making a new
+ forward definition. */
+int f();
+int h() {
+ return f();
+}
+
+// CHECK: [[call:%.*]] = call i32 (...)* @f()
+// CHECK: ret i32 [[call]]
+
diff --git a/clang/test/CodeGen/2008-07-30-implicit-initialization.c b/clang/test/CodeGen/2008-07-30-implicit-initialization.c
new file mode 100644
index 0000000..8c719bb
--- /dev/null
+++ b/clang/test/CodeGen/2008-07-30-implicit-initialization.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm-bc -o - %s | opt --std-compile-opts | llvm-dis > %t
+// RUN: grep "ret i32" %t | count 2
+// RUN: grep "ret i32 0" %t | count 2
+// <rdar://problem/6113085>
+
+struct s0 {
+ int x, y;
+};
+
+int f0() {
+ struct s0 x = {0};
+ return x.y;
+}
+
+#if 0
+/* Optimizer isn't smart enough to reduce this since we use
+ memset. Hrm. */
+int f1() {
+ struct s0 x[2] = { {0} };
+ return x[1].x;
+}
+#endif
+
+int f2() {
+ int x[2] = { 0 };
+ return x[1];
+}
+
diff --git a/clang/test/CodeGen/2008-07-30-redef-of-bitcasted-decl.c b/clang/test/CodeGen/2008-07-30-redef-of-bitcasted-decl.c
new file mode 100644
index 0000000..546590e
--- /dev/null
+++ b/clang/test/CodeGen/2008-07-30-redef-of-bitcasted-decl.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+// <rdar://problem/6108358>
+
+/* For posterity, the issue here begins initial "char []" decl for
+ * s. This is a tentative definition and so a global was being
+ * emitted, however the mapping in GlobalDeclMap referred to a bitcast
+ * of this global.
+ *
+ * The problem was that later when the correct definition for s is
+ * emitted we were doing a RAUW on the old global which was destroying
+ * the bitcast in the GlobalDeclMap (since it cannot be replaced
+ * properly), leaving a dangling pointer.
+ *
+ * The purpose of bar is just to trigger a use of the old decl
+ * sometime after the dangling pointer has been introduced.
+ */
+
+char s[];
+
+static void bar(void *db) {
+ eek(s);
+}
+
+char s[5] = "hi";
+
+int foo() {
+ bar(0);
+}
diff --git a/clang/test/CodeGen/2008-07-31-asm-labels.c b/clang/test/CodeGen/2008-07-31-asm-labels.c
new file mode 100644
index 0000000..130ad6b
--- /dev/null
+++ b/clang/test/CodeGen/2008-07-31-asm-labels.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: grep "@pipe()" %t | count 0
+// RUN: grep '_thisIsNotAPipe' %t | count 3
+// RUN: grep 'g0' %t | count 0
+// RUN: grep '_renamed' %t | count 2
+// RUN: %clang_cc1 -DUSE_DEF -emit-llvm -o %t %s
+// RUN: grep "@pipe()" %t | count 0
+// RUN: grep '_thisIsNotAPipe' %t | count 3
+// <rdr://6116729>
+
+void pipe() asm("_thisIsNotAPipe");
+
+void f0() {
+ pipe();
+}
+
+void pipe(int);
+
+void f1() {
+ pipe(1);
+}
+
+#ifdef USE_DEF
+void pipe(int arg) {
+ int x = 10;
+}
+#endif
+
+// PR3698
+extern int g0 asm("_renamed");
+int f2() {
+ return g0;
+}
diff --git a/clang/test/CodeGen/2008-07-31-promotion-of-compound-pointer-arithmetic.c b/clang/test/CodeGen/2008-07-31-promotion-of-compound-pointer-arithmetic.c
new file mode 100644
index 0000000..de06263
--- /dev/null
+++ b/clang/test/CodeGen/2008-07-31-promotion-of-compound-pointer-arithmetic.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm-bc -o - %s | opt -std-compile-opts | llvm-dis | grep "ret i32 1" | count 3
+// <rdr://6115726>
+
+int f0() {
+ int x;
+ unsigned short n = 1;
+ int *a = &x;
+ int *b = &x;
+ a = a - n;
+ b -= n;
+ return a == b;
+}
+
+int f1(int *a) {
+ long b = a - (int*) 1;
+ a -= (int*) 1;
+ return b == (long) a;
+}
+
+int f2(long n) {
+ int *b = n + (int*) 1;
+ n += (int*) 1;
+ return b == (int*) n;
+}
+
diff --git a/clang/test/CodeGen/2008-08-04-void-pointer-arithmetic.c b/clang/test/CodeGen/2008-08-04-void-pointer-arithmetic.c
new file mode 100644
index 0000000..dbfc107
--- /dev/null
+++ b/clang/test/CodeGen/2008-08-04-void-pointer-arithmetic.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+// <rdar://problem/6122967>
+
+int f0(void *a, void *b) {
+ return a - b;
+}
diff --git a/clang/test/CodeGen/2008-08-07-AlignPadding1.c b/clang/test/CodeGen/2008-08-07-AlignPadding1.c
new file mode 100644
index 0000000..2bb2e61
--- /dev/null
+++ b/clang/test/CodeGen/2008-08-07-AlignPadding1.c
@@ -0,0 +1,32 @@
+/* RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-darwin -o - | FileCheck %s
+
+The FE must generate padding here both at the end of each PyG_Head and
+between array elements. Reduced from Python. */
+
+typedef union _gc_head {
+ struct {
+ union _gc_head *gc_next;
+ union _gc_head *gc_prev;
+ long gc_refs;
+ } gc;
+ int dummy __attribute__((aligned(16)));
+} PyGC_Head;
+
+struct gc_generation {
+ PyGC_Head head;
+ int threshold;
+ int count;
+};
+
+#define GEN_HEAD(n) (&generations[n].head)
+
+// The idea is that there are 6 undefs in this structure initializer to cover
+// the padding between elements.
+// CHECK: @generations = global [3 x %struct.gc_generation] [%struct.gc_generation { %union._gc_head { %struct.anon { %union._gc_head* getelementptr inbounds ([3 x %struct.gc_generation]* @generations, i32 0, i32 0, i32 0), %union._gc_head* getelementptr inbounds ([3 x %struct.gc_generation]* @generations, i32 0, i32 0, i32 0), i64 0 }, [8 x i8] undef }, i32 700, i32 0, [8 x i8] undef }, %struct.gc_generation { %union._gc_head { %struct.anon { %union._gc_head* bitcast (i8* getelementptr (i8* bitcast ([3 x %struct.gc_generation]* @generations to i8*), i64 48) to %union._gc_head*), %union._gc_head* bitcast (i8* getelementptr (i8* bitcast ([3 x %struct.gc_generation]* @generations to i8*), i64 48) to %union._gc_head*), i64 0 }, [8 x i8] undef }, i32 10, i32 0, [8 x i8] undef }, %struct.gc_generation { %union._gc_head { %struct.anon { %union._gc_head* bitcast (i8* getelementptr (i8* bitcast ([3 x %struct.gc_generation]* @generations to i8*), i64 96) to %union._gc_head*), %union._gc_head* bitcast (i8* getelementptr (i8* bitcast ([3 x %struct.gc_generation]* @generations to i8*), i64 96) to %union._gc_head*), i64 0 }, [8 x i8] undef }, i32 10, i32 0, [8 x i8] undef }]
+/* linked lists of container objects */
+struct gc_generation generations[3] = {
+ /* PyGC_Head, threshold, count */
+ {{{GEN_HEAD(0), GEN_HEAD(0), 0}}, 700, 0},
+ {{{GEN_HEAD(1), GEN_HEAD(1), 0}}, 10, 0},
+ {{{GEN_HEAD(2), GEN_HEAD(2), 0}}, 10, 0},
+};
diff --git a/clang/test/CodeGen/2008-08-07-AlignPadding2.c b/clang/test/CodeGen/2008-08-07-AlignPadding2.c
new file mode 100644
index 0000000..ecf28dd
--- /dev/null
+++ b/clang/test/CodeGen/2008-08-07-AlignPadding2.c
@@ -0,0 +1,18 @@
+/* RUN: %clang_cc1 %s -emit-llvm -o - -O0 | grep zeroinitializer | count 1
+
+The FE must not generate padding here between array elements. PR 2533. */
+
+typedef struct {
+ const char *name;
+ int flags;
+ union {
+ int x;
+ } u;
+} OptionDef;
+
+const OptionDef options[] = {
+ /* main options */
+ { "a", 0, {3} },
+ { "b", 0, {4} },
+ { 0, },
+};
diff --git a/clang/test/CodeGen/2008-08-07-GEPIntToPtr.c b/clang/test/CodeGen/2008-08-07-GEPIntToPtr.c
new file mode 100644
index 0000000..6892be0
--- /dev/null
+++ b/clang/test/CodeGen/2008-08-07-GEPIntToPtr.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// PR2603
+
+struct A {
+ char num_fields;
+};
+
+struct B {
+ char a, b[1];
+};
+
+const struct A Foo = {
+ // CHECK: i8 1
+ (char *)(&( (struct B *)(16) )->b[0]) - (char *)(16)
+};
diff --git a/clang/test/CodeGen/2008-08-19-cast-of-typedef.c b/clang/test/CodeGen/2008-08-19-cast-of-typedef.c
new file mode 100644
index 0000000..740f48a
--- /dev/null
+++ b/clang/test/CodeGen/2008-08-19-cast-of-typedef.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+typedef short T[4];
+struct s {
+ T f0;
+};
+
+void foo(struct s *x) {
+ bar((long) x->f0);
+}
diff --git a/clang/test/CodeGen/2008-09-03-WeakAlias.c b/clang/test/CodeGen/2008-09-03-WeakAlias.c
new file mode 100644
index 0000000..4712a01
--- /dev/null
+++ b/clang/test/CodeGen/2008-09-03-WeakAlias.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm -O1 -o - %s | grep icmp
+// PR1678
+extern void B (void);
+static __typeof(B) A __attribute__ ((__weakref__("B")));
+int active (void)
+{
+ static void *const p = __extension__ (void *) &A;
+ return p != 0;
+}
diff --git a/clang/test/CodeGen/2008-09-22-bad-switch-type.c b/clang/test/CodeGen/2008-09-22-bad-switch-type.c
new file mode 100644
index 0000000..853e6bd
--- /dev/null
+++ b/clang/test/CodeGen/2008-09-22-bad-switch-type.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// PR2817
+
+void f0(void) {
+ switch (0) {
+ case (unsigned long long) 0 < 0:
+ break;
+ }
+
+ switch (0) {
+ case (unsigned long long) 0 > 0:
+ break;
+ }
+
+ switch (0) {
+ case (unsigned long long) 0 <= 0:
+ break;
+ }
+
+ switch (0) {
+ case (unsigned long long) 0 >= 0:
+ break;
+ }
+
+ switch (0) {
+ case (unsigned long long) 0 == 0:
+ break;
+ }
+
+ switch (0) {
+ case (unsigned long long) 0 != 0:
+ break;
+ }
+}
diff --git a/clang/test/CodeGen/2008-10-13-FrontendCrash.c b/clang/test/CodeGen/2008-10-13-FrontendCrash.c
new file mode 100644
index 0000000..cdd1229
--- /dev/null
+++ b/clang/test/CodeGen/2008-10-13-FrontendCrash.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+// PR2797
+
+unsigned int
+func_48 (signed char p_49)
+{
+ signed char l_340;
+ func_44 (1&((1 ^ 1 == (lshift_u_s (1)) != (l_340 < 1)) & 1L));
+}
diff --git a/clang/test/CodeGen/2008-10-30-ZeroPlacement.c b/clang/test/CodeGen/2008-10-30-ZeroPlacement.c
new file mode 100644
index 0000000..f3806d4
--- /dev/null
+++ b/clang/test/CodeGen/2008-10-30-ZeroPlacement.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+// PR2987
+struct S2045
+{
+ unsigned short int a;
+ union { } b;
+ union __attribute__ ((aligned (4))) { } c[0];
+};
+struct S2045 s2045;
diff --git a/clang/test/CodeGen/2008-11-02-WeakAlias.c b/clang/test/CodeGen/2008-11-02-WeakAlias.c
new file mode 100644
index 0000000..63fd4e1
--- /dev/null
+++ b/clang/test/CodeGen/2008-11-02-WeakAlias.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple=i686-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// PR2691
+
+// CHECK: weak
+void init_IRQ(void) __attribute__((weak, alias("native_init_IRQ")));
+void native_init_IRQ(void) {}
diff --git a/clang/test/CodeGen/2008-11-08-InstCombineSelect.c b/clang/test/CodeGen/2008-11-08-InstCombineSelect.c
new file mode 100644
index 0000000..3f4428e
--- /dev/null
+++ b/clang/test/CodeGen/2008-11-08-InstCombineSelect.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -emit-llvm -O2 -o -
+// PR3028
+
+int g_187;
+int g_204;
+int g_434;
+
+int func_89 (void)
+{
+ return 1;
+}
+
+void func_20 (int p_22)
+{
+ if (1 & p_22 | g_204 & (1 < g_187) - func_89 ())
+ g_434 = 1;
+}
diff --git a/clang/test/CodeGen/2008-12-23-AsmIntPointerTie.c b/clang/test/CodeGen/2008-12-23-AsmIntPointerTie.c
new file mode 100644
index 0000000..df646b7
--- /dev/null
+++ b/clang/test/CodeGen/2008-12-23-AsmIntPointerTie.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -O1 -o -
+
+typedef long intptr_t;
+int test(void *b) {
+ intptr_t a;
+ __asm__ __volatile__ ("%0 %1 " : "=r" (a): "0" (b));
+ return a;
+}
diff --git a/clang/test/CodeGen/2009-01-05-BlockInlining.c b/clang/test/CodeGen/2009-01-05-BlockInlining.c
new file mode 100644
index 0000000..2ae9b70
--- /dev/null
+++ b/clang/test/CodeGen/2009-01-05-BlockInlining.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -emit-llvm -fblocks -o - | FileCheck %s
+// rdar://5865221
+
+// These will be inlined by the optimizers provided the block descriptors
+// and block literals are internal constants.
+// CHECK: @__block_descriptor_tmp = internal constant
+// CHECK: @__block_literal_global = internal constant
+// CHECK: @__block_descriptor_tmp1 = internal constant
+// CHECK: @__block_literal_global2 = internal constant
+static int fun(int x) {
+ return x+1;
+}
+
+static int block(int x) {
+ return (^(int x){return x+1;})(x);
+}
+
+static void print(int result) {
+ printf("%d\n", result);
+}
+
+int main (int argc, const char * argv[]) {
+ int x = argc-1;
+ print(fun(x));
+ print(block(x));
+ int (^block_inline)(int) = ^(int x){return x+1;};
+ print(block_inline(x));
+ return 0;
+}
diff --git a/clang/test/CodeGen/2009-01-21-InvalidIterator.c b/clang/test/CodeGen/2009-01-21-InvalidIterator.c
new file mode 100644
index 0000000..f857b4d
--- /dev/null
+++ b/clang/test/CodeGen/2009-01-21-InvalidIterator.c
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 %s -emit-llvm -g -o /dev/null
+
+typedef long unsigned int size_t;
+typedef unsigned short int uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long int uint64_t;
+typedef uint16_t Elf64_Half;
+typedef uint32_t Elf64_Word;
+typedef uint64_t Elf64_Xword;
+typedef uint64_t Elf64_Addr;
+typedef uint64_t Elf64_Off;
+typedef struct
+{
+ Elf64_Word p_type;
+ Elf64_Off p_offset;
+ Elf64_Addr p_vaddr;
+ Elf64_Xword p_align;
+}
+Elf64_Phdr;
+struct dl_phdr_info
+{
+ const char *dlpi_name;
+ const Elf64_Phdr *dlpi_phdr;
+ Elf64_Half dlpi_phnum;
+ unsigned long long int dlpi_adds;
+};
+typedef unsigned _Unwind_Ptr;
+struct object
+{
+ union
+ {
+ const struct dwarf_fde *single;
+ struct dwarf_fde **array;
+ struct fde_vector *sort;
+ }
+ u;
+ union
+ {
+ struct
+ {
+ }
+ b;
+ }
+ s;
+ struct object *next;
+};
+typedef int sword;
+typedef unsigned int uword;
+struct dwarf_fde
+{
+ uword length;
+ sword CIE_delta;
+ unsigned char pc_begin[];
+};
+typedef struct dwarf_fde fde;
+struct unw_eh_callback_data
+{
+ const fde *ret;
+ struct frame_hdr_cache_element *link;
+}
+frame_hdr_cache[8];
+
+_Unwind_Ptr
+base_from_cb_data (struct unw_eh_callback_data *data)
+{
+}
+
+void
+_Unwind_IteratePhdrCallback (struct dl_phdr_info *info, size_t size, void *ptr)
+{
+ const unsigned char *p;
+ const struct unw_eh_frame_hdr *hdr;
+ struct object ob;
+}
diff --git a/clang/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c b/clang/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c
new file mode 100644
index 0000000..8787bd4
--- /dev/null
+++ b/clang/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -triple powerpc-pc-linux -emit-llvm -o - | grep {i32 32} | count 3
+// XFAIL: *
+// Every printf has 'i32 0' for the GEP of the string; no point counting those.
+typedef unsigned int Foo __attribute__((aligned(32)));
+typedef union{Foo:0;}a;
+typedef union{int x; Foo:0;}b;
+extern int printf(const char*, ...);
+main() {
+ printf("%ld\n", sizeof(a));
+ printf("%ld\n", __alignof__(a));
+ printf("%ld\n", sizeof(b));
+ printf("%ld\n", __alignof__(b));
+}
diff --git a/clang/test/CodeGen/2009-02-13-zerosize-union-field.c b/clang/test/CodeGen/2009-02-13-zerosize-union-field.c
new file mode 100644
index 0000000..b39a231
--- /dev/null
+++ b/clang/test/CodeGen/2009-02-13-zerosize-union-field.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -triple i686-apple-darwin -emit-llvm -o - | FileCheck %s
+// Every printf has 'i32 0' for the GEP of the string; no point counting those.
+typedef unsigned int Foo __attribute__((aligned(32)));
+typedef union{Foo:0;}a;
+typedef union{int x; Foo:0;}b;
+extern int printf(const char*, ...);
+int main() {
+ // CHECK: getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 0
+ printf("%ld\n", sizeof(a));
+ // CHECK: getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 1
+ printf("%ld\n", __alignof__(a));
+ // CHECK: getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 4
+ printf("%ld\n", sizeof(b));
+ // CHECK: getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 4
+ printf("%ld\n", __alignof__(b));
+}
diff --git a/clang/test/CodeGen/2009-03-01-MallocNoAlias.c b/clang/test/CodeGen/2009-03-01-MallocNoAlias.c
new file mode 100644
index 0000000..1c4878a
--- /dev/null
+++ b/clang/test/CodeGen/2009-03-01-MallocNoAlias.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | grep noalias
+
+void * __attribute__ ((malloc)) foo (void) { return 0; }
diff --git a/clang/test/CodeGen/2009-03-08-ZeroEltStructCrash.c b/clang/test/CodeGen/2009-03-08-ZeroEltStructCrash.c
new file mode 100644
index 0000000..b530eb7
--- /dev/null
+++ b/clang/test/CodeGen/2009-03-08-ZeroEltStructCrash.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+// PR3744
+struct Empty {};
+struct Union {
+ union {
+ int zero_arr[0];
+ } contents;
+};
+static inline void Foo(struct Union *u) {
+ int *array = u->contents.zero_arr;
+}
+static void Bar(struct Union *u) {
+ Foo(u);
+}
diff --git a/clang/test/CodeGen/2009-03-13-dbg.c b/clang/test/CodeGen/2009-03-13-dbg.c
new file mode 100644
index 0000000..8f48830
--- /dev/null
+++ b/clang/test/CodeGen/2009-03-13-dbg.c
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 %s -emit-llvm -g -o /dev/null
+void foo() {}
diff --git a/clang/test/CodeGen/2009-03-22-increment-bitfield.c b/clang/test/CodeGen/2009-03-22-increment-bitfield.c
new file mode 100644
index 0000000..407aea2
--- /dev/null
+++ b/clang/test/CodeGen/2009-03-22-increment-bitfield.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -O1 < %s | grep "ret i32 0"
+
+int a(void) {
+ return ++(struct x {unsigned x : 2;}){3}.x;
+}
+
+
diff --git a/clang/test/CodeGen/2009-04-23-dbg.c b/clang/test/CodeGen/2009-04-23-dbg.c
new file mode 100644
index 0000000..704aba2
--- /dev/null
+++ b/clang/test/CodeGen/2009-04-23-dbg.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -S -g -o %t %s
+# 1 "a.c"
+# 1 "a.c" 1
+# 1 "<built-in>" 1
+# 103 "<built-in>"
+# 103 "<command line>" 1
+
+# 1 "/private/tmp/a.h" 1
+int bar;
+# 105 "<command line>" 2
+# 105 "<built-in>" 2
+# 1 "a.c" 2
+# 1 "/private/tmp/a.h" 1
+int bar;
+# 2 "a.c" 2
+
+int main() {
+ bar = 0;
+ return 0;
+}
diff --git a/clang/test/CodeGen/2009-04-28-UnionArrayCrash.c b/clang/test/CodeGen/2009-04-28-UnionArrayCrash.c
new file mode 100644
index 0000000..4296b91
--- /dev/null
+++ b/clang/test/CodeGen/2009-04-28-UnionArrayCrash.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+// PR4082
+union U {
+ int I;
+ double F;
+};
+
+union U arr[] = { { .I = 4 }, { .F = 123.} };
+union U *P = &arr[0];
+
+
diff --git a/clang/test/CodeGen/2009-05-04-EnumInreg.c b/clang/test/CodeGen/2009-05-04-EnumInreg.c
new file mode 100644
index 0000000..2abc747
--- /dev/null
+++ b/clang/test/CodeGen/2009-05-04-EnumInreg.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm -triple i686-apple-darwin -mregparm 3 %s -o - | FileCheck %s
+// PR3967
+
+enum kobject_action {
+ KOBJ_ADD,
+ KOBJ_REMOVE,
+ KOBJ_CHANGE,
+ KOBJ_MOVE,
+ KOBJ_ONLINE,
+ KOBJ_OFFLINE,
+ KOBJ_MAX
+};
+
+struct kobject;
+
+// CHECK: i32 inreg %action
+int kobject_uevent(struct kobject *kobj, enum kobject_action action) {}
diff --git a/clang/test/CodeGen/2009-05-22-callingconv.c b/clang/test/CodeGen/2009-05-22-callingconv.c
new file mode 100644
index 0000000..3e616d9
--- /dev/null
+++ b/clang/test/CodeGen/2009-05-22-callingconv.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple i386-unknown-unknown | grep call | grep x86_stdcallcc
+void abort(void) __attribute__((__noreturn__));
+typedef void re_string_t;
+typedef void re_dfa_t;
+typedef int reg_errcode_t;
+static reg_errcode_t re_string_construct (re_string_t *pstr, const char *str,
+ int len, char * trans,
+ int icase, const re_dfa_t *dfa)
+ __attribute__ ((regparm (3), stdcall));
+static reg_errcode_t
+re_string_construct (pstr, str, len, trans, icase, dfa)
+ re_string_t *pstr;
+ const char *str;
+ int len, icase;
+ char * trans;
+ const re_dfa_t *dfa;
+{
+ if (dfa != (void*)0x282020c0)
+ abort();
+return 0;
+}
+int main()
+{
+ return re_string_construct(0, 0, 0, 0, 0, (void*)0x282020c0);
+}
diff --git a/clang/test/CodeGen/2009-05-28-const-typedef.c b/clang/test/CodeGen/2009-05-28-const-typedef.c
new file mode 100644
index 0000000..3464fde
--- /dev/null
+++ b/clang/test/CodeGen/2009-05-28-const-typedef.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+// PR4281
+
+typedef struct {
+ int i;
+} something;
+
+typedef const something const_something;
+
+something fail(void);
+
+int
+main(int argc, char *argv[])
+{
+ const_something R = fail();
+}
+
diff --git a/clang/test/CodeGen/2009-06-01-addrofknr.c b/clang/test/CodeGen/2009-06-01-addrofknr.c
new file mode 100644
index 0000000..17d6fdf
--- /dev/null
+++ b/clang/test/CodeGen/2009-06-01-addrofknr.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -o %t -emit-llvm -verify
+// PR4289
+
+struct funcptr {
+ int (*func)();
+};
+
+static int func(f)
+ void *f;
+{
+ return 0;
+}
+
+int
+main(int argc, char *argv[])
+{
+ struct funcptr fp;
+
+ fp.func = &func;
+ fp.func = func;
+}
diff --git a/clang/test/CodeGen/2009-06-14-HighlyAligned.c b/clang/test/CodeGen/2009-06-14-HighlyAligned.c
new file mode 100644
index 0000000..b5a7f5e
--- /dev/null
+++ b/clang/test/CodeGen/2009-06-14-HighlyAligned.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o /dev/null
+// PR4332
+
+static int highly_aligned __attribute__((aligned(4096)));
+
+int f() {
+ return highly_aligned;
+}
diff --git a/clang/test/CodeGen/2009-06-14-anonymous-union-init.c b/clang/test/CodeGen/2009-06-14-anonymous-union-init.c
new file mode 100644
index 0000000..8ccd7bc
--- /dev/null
+++ b/clang/test/CodeGen/2009-06-14-anonymous-union-init.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm < %s | grep "zeroinitializer, i16 16877"
+// PR4390
+struct sysfs_dirent {
+ union { struct sysfs_elem_dir {} s_dir; };
+ unsigned short s_mode;
+};
+struct sysfs_dirent sysfs_root = { {}, 16877 };
diff --git a/clang/test/CodeGen/2009-06-18-StaticInitTailPadPack.c b/clang/test/CodeGen/2009-06-18-StaticInitTailPadPack.c
new file mode 100644
index 0000000..be103ec
--- /dev/null
+++ b/clang/test/CodeGen/2009-06-18-StaticInitTailPadPack.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+// rdar://6983634
+
+ typedef struct A *Foo;
+#pragma pack(push, 2)
+ struct Bar {
+ Foo f1;
+ unsigned short f2;
+ float f3;
+ };
+ struct Baz {
+ struct Bar f1;
+ struct Bar f2;
+ };
+ struct Qux {
+ unsigned long f1;
+ struct Baz f2;
+ };
+extern const struct Qux Bork;
+const struct Qux Bork = {
+ 0,
+ {
+ {0},
+ {0}
+ }
+};
diff --git a/clang/test/CodeGen/2009-07-14-VoidPtr.c b/clang/test/CodeGen/2009-07-14-VoidPtr.c
new file mode 100644
index 0000000..5e8b23d
--- /dev/null
+++ b/clang/test/CodeGen/2009-07-14-VoidPtr.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+// PR4556
+
+extern void foo;
+void *bar = &foo;
+
diff --git a/clang/test/CodeGen/2009-07-15-pad-wchar_t-array.c b/clang/test/CodeGen/2009-07-15-pad-wchar_t-array.c
new file mode 100644
index 0000000..df12cae
--- /dev/null
+++ b/clang/test/CodeGen/2009-07-15-pad-wchar_t-array.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+// This bit is taken from Sema/wchar.c so we can avoid the wchar.h include.
+typedef __WCHAR_TYPE__ wchar_t;
+#if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
+ || defined(_M_X64) || defined(SHORT_WCHAR)
+ #define WCHAR_T_TYPE unsigned short
+#elif defined(__sun) || defined(__AuroraUX__)
+ #define WCHAR_T_TYPE long
+#else /* Solaris or AuroraUX. */
+ #define WCHAR_T_TYPE int
+#endif
+
+signed short _iodbcdm_sqlerror( )
+{
+ wchar_t _sqlState[6] = { L"\0" };
+}
diff --git a/clang/test/CodeGen/2009-07-22-StructLayout.c b/clang/test/CodeGen/2009-07-22-StructLayout.c
new file mode 100644
index 0000000..7b7b82c
--- /dev/null
+++ b/clang/test/CodeGen/2009-07-22-StructLayout.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 %s -triple i686-pc-linux-gnu -emit-llvm -o /dev/null
+// PR4590
+
+typedef unsigned char __u8;
+typedef unsigned int __le32;
+typedef unsigned int __u32;
+typedef unsigned short __le16;
+typedef unsigned short __u16;
+
+struct usb_cdc_ether_desc {
+ __u8 bLength;
+ __u8 bDescriptorType;
+ __u8 bDescriptorSubType;
+
+ __u8 iMACAddress;
+ __le32 bmEthernetStatistics;
+ __le16 wMaxSegmentSize;
+ __le16 wNumberMCFilters;
+ __u8 bNumberPowerFilters;
+} __attribute__ ((packed));
+
+
+static struct usb_cdc_ether_desc ecm_desc __attribute__ ((__section__(".init.data"))) = {
+ .bLength = sizeof ecm_desc,
+ .bDescriptorType = ((0x01 << 5) | 0x04),
+ .bDescriptorSubType = 0x0f,
+
+
+
+ .bmEthernetStatistics = (( __le32)(__u32)(0)),
+ .wMaxSegmentSize = (( __le16)(__u16)(1514)),
+ .wNumberMCFilters = (( __le16)(__u16)(0)),
+ .bNumberPowerFilters = 0,
+};
diff --git a/clang/test/CodeGen/2009-07-31-DbgDeclare.c b/clang/test/CodeGen/2009-07-31-DbgDeclare.c
new file mode 100644
index 0000000..3ccb263
--- /dev/null
+++ b/clang/test/CodeGen/2009-07-31-DbgDeclare.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -S -g -o %t.s %s
+void foo() {
+ int i = 0;
+ i = 42;
+}
diff --git a/clang/test/CodeGen/2009-08-14-vararray-crash.c b/clang/test/CodeGen/2009-08-14-vararray-crash.c
new file mode 100644
index 0000000..7f489bc
--- /dev/null
+++ b/clang/test/CodeGen/2009-08-14-vararray-crash.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm < %s
+
+void sum1(int rb) {
+ typedef unsigned char imgrow[rb];
+ typedef imgrow img[rb];
+
+ const img *br;
+ int y;
+
+ (*br)[y];
+}
diff --git a/clang/test/CodeGen/2009-09-24-SqrtErrno.c b/clang/test/CodeGen/2009-09-24-SqrtErrno.c
new file mode 100644
index 0000000..b4a04ff
--- /dev/null
+++ b/clang/test/CodeGen/2009-09-24-SqrtErrno.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -fmath-errno | FileCheck %s
+// llvm.sqrt has undefined behavior on negative inputs, so it is
+// inappropriate to translate C/C++ sqrt to this.
+
+float sqrtf(float x);
+float foo(float X) {
+// CHECK: foo
+// CHECK-NOT: readonly
+// CHECK: call float @sqrtf
+ // Check that this is not marked readonly when errno is used.
+ return sqrtf(X);
+}
diff --git a/clang/test/CodeGen/2009-10-20-GlobalDebug.c b/clang/test/CodeGen/2009-10-20-GlobalDebug.c
new file mode 100644
index 0000000..8828eef
--- /dev/null
+++ b/clang/test/CodeGen/2009-10-20-GlobalDebug.c
@@ -0,0 +1,10 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang -target i386-apple-darwin10 -flto -S -g %s -o - | FileCheck %s
+int global;
+int main() {
+ static int localstatic;
+ return 0;
+}
+
+// CHECK: !14 = metadata !{i32 {{.*}}, i32 0, metadata !5, metadata !"localstatic", metadata !"localstatic", metadata !"", metadata !6, i32 5, metadata !9, i32 1, i32 1, i32* @main.localstatic} ; [ DW_TAG_variable ]
+// CHECK: !15 = metadata !{i32 {{.*}}, i32 0, null, metadata !"global", metadata !"global", metadata !"", metadata !6, i32 3, metadata !9, i32 0, i32 1, i32* @global} ; [ DW_TAG_variable ]
diff --git a/clang/test/CodeGen/2009-12-07-BitFieldAlignment.c b/clang/test/CodeGen/2009-12-07-BitFieldAlignment.c
new file mode 100644
index 0000000..72c30e1
--- /dev/null
+++ b/clang/test/CodeGen/2009-12-07-BitFieldAlignment.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin %s -emit-llvm -o - | FileCheck %s
+// Set alignment on bitfield accesses.
+
+struct S {
+ int a, b;
+ void *c;
+ unsigned d : 8;
+ unsigned e : 8;
+};
+
+void f0(struct S *a) {
+// CHECK: load {{.*}}, align 4
+// CHECK: store {{.*}}, align 4
+ a->e = 0;
+}
diff --git a/clang/test/CodeGen/2010-01-13-MemBarrier.c b/clang/test/CodeGen/2010-01-13-MemBarrier.c
new file mode 100644
index 0000000..c2b0acd
--- /dev/null
+++ b/clang/test/CodeGen/2010-01-13-MemBarrier.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// XFAIL: sparc
+// rdar://7536390
+
+typedef unsigned __INT32_TYPE__ uint32_t;
+
+unsigned t(uint32_t *ptr, uint32_t val) {
+ // CHECK: @t
+ // CHECK: atomicrmw xchg i32* {{.*}} seq_cst
+ return __sync_lock_test_and_set(ptr, val);
+}
diff --git a/clang/test/CodeGen/2010-01-14-FnType-DebugInfo.c b/clang/test/CodeGen/2010-01-14-FnType-DebugInfo.c
new file mode 100644
index 0000000..964c031
--- /dev/null
+++ b/clang/test/CodeGen/2010-01-14-FnType-DebugInfo.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -emit-llvm -g -o /dev/null
+typedef void (*sigcatch_t)( struct sigcontext *);
+sigcatch_t sigcatch[50] = {(sigcatch_t) 0};
+
diff --git a/clang/test/CodeGen/2010-01-18-Inlined-Debug.c b/clang/test/CodeGen/2010-01-18-Inlined-Debug.c
new file mode 100644
index 0000000..cf00be7
--- /dev/null
+++ b/clang/test/CodeGen/2010-01-18-Inlined-Debug.c
@@ -0,0 +1,12 @@
+// PR: 6058
+// RUN: %clang_cc1 -g -emit-llvm %s -O0 -o /dev/null
+
+static inline int foo(double) __attribute__ ((always_inline));
+static inline int foo(double __x) { return __x; }
+
+void bar(double x) {
+ foo(x);
+}
+
+
+
diff --git a/clang/test/CodeGen/2010-02-10-PointerName.c b/clang/test/CodeGen/2010-02-10-PointerName.c
new file mode 100644
index 0000000..910dd30
--- /dev/null
+++ b/clang/test/CodeGen/2010-02-10-PointerName.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -emit-llvm -g -o - | grep DW_TAG_pointer_type | grep -v char
+
+char i = 1;
+void foo() {
+ char *cp = &i;
+}
+
diff --git a/clang/test/CodeGen/2010-02-15-DbgStaticVar.c b/clang/test/CodeGen/2010-02-15-DbgStaticVar.c
new file mode 100644
index 0000000..facd14e
--- /dev/null
+++ b/clang/test/CodeGen/2010-02-15-DbgStaticVar.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -g -emit-llvm %s -o - | grep "metadata ..b., metadata ..b., metadata ...,"
+// Test to check intentionally empty linkage name for a static variable.
+// Radar 7651244.
+static int foo(int a)
+{
+ static int b = 1;
+ return b+a;
+}
+
+int main() {
+ int j = foo(1);
+ return 0;
+}
diff --git a/clang/test/CodeGen/2010-02-16-DbgScopes.c b/clang/test/CodeGen/2010-02-16-DbgScopes.c
new file mode 100644
index 0000000..b11f920
--- /dev/null
+++ b/clang/test/CodeGen/2010-02-16-DbgScopes.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -g < %s | grep lexical | count 5
+// Test to check number of lexical scope identified in debug info.
+
+extern int bar();
+extern void foobar();
+void foo(int s) {
+ unsigned loc = 0;
+ if (s) {
+ if (bar()) {
+ foobar();
+ }
+ } else {
+ loc = 1;
+ if (bar()) {
+ loc = 2;
+ }
+ }
+}
diff --git a/clang/test/CodeGen/2010-02-18-Dbg-VectorType.c b/clang/test/CodeGen/2010-02-18-Dbg-VectorType.c
new file mode 100644
index 0000000..eb17d11
--- /dev/null
+++ b/clang/test/CodeGen/2010-02-18-Dbg-VectorType.c
@@ -0,0 +1,9 @@
+// RUN: %clang -emit-llvm -S -O0 -g %s -o - | grep DW_TAG_typedef | grep float4
+typedef float float4 __attribute__((vector_size(16)));
+
+int main(){
+ volatile float4 x = (float4) { 0.0f, 1.0f, 2.0f, 3.0f };
+ x += x;
+ return 0;
+}
+
diff --git a/clang/test/CodeGen/2010-03-09-DbgInfo.c b/clang/test/CodeGen/2010-03-09-DbgInfo.c
new file mode 100644
index 0000000..3541e5f
--- /dev/null
+++ b/clang/test/CodeGen/2010-03-09-DbgInfo.c
@@ -0,0 +1,2 @@
+// RUN: %clang -emit-llvm -S -O0 -g %s -o - | grep DW_TAG_variable
+unsigned char ctable1[1] = { 0001 };
diff --git a/clang/test/CodeGen/2010-03-5-LexicalScope.c b/clang/test/CodeGen/2010-03-5-LexicalScope.c
new file mode 100644
index 0000000..0f63ff6
--- /dev/null
+++ b/clang/test/CodeGen/2010-03-5-LexicalScope.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -g %s -o - | grep DW_TAG_lexical_block | count 3
+int foo(int i) {
+ if (i) {
+ int j = 2;
+ }
+ else {
+ int j = 3;
+ }
+ return i;
+}
diff --git a/clang/test/CodeGen/2010-05-26-AsmSideEffect.c b/clang/test/CodeGen/2010-05-26-AsmSideEffect.c
new file mode 100644
index 0000000..7dd86ae
--- /dev/null
+++ b/clang/test/CodeGen/2010-05-26-AsmSideEffect.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple arm-apple-darwin -o - | FileCheck %s
+// Radar 8026855
+
+int test (void *src) {
+ register int w0 asm ("0");
+ // CHECK: call i32 asm "ldr $0, [$1]", "={r0}{{.*}}(i8*
+ asm ("ldr %0, [%1]": "=r" (w0): "r" (src));
+ return w0;
+}
diff --git a/clang/test/CodeGen/2010-06-11-SaveExpr.c b/clang/test/CodeGen/2010-06-11-SaveExpr.c
new file mode 100644
index 0000000..bfe0f35
--- /dev/null
+++ b/clang/test/CodeGen/2010-06-11-SaveExpr.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+// Test case by Eric Postpischil!
+void foo(void)
+{
+ char a[1];
+ int t = 1;
+ ((char (*)[t]) a)[0][0] = 0;
+}
diff --git a/clang/test/CodeGen/2010-06-17-asmcrash.c b/clang/test/CodeGen/2010-06-17-asmcrash.c
new file mode 100644
index 0000000..8e9485b
--- /dev/null
+++ b/clang/test/CodeGen/2010-06-17-asmcrash.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | llc -mtriple=x86_64-apple-darwin | FileCheck %s
+// XFAIL: *
+// XTARGET: x86,i386,i686
+
+typedef long long int64_t;
+typedef unsigned char uint8_t;
+typedef int64_t x86_reg;
+
+void avg_pixels8_mmx2(uint8_t *block, const uint8_t *pixels, int line_size, int h)
+{
+ __asm__ volatile("# %0 %1 %2 %3"
+ :"+g"(h), "+S"(pixels), "+D"(block)
+ :"r" ((x86_reg)line_size)
+ :"%""rax", "memory");
+// CHECK: # %ecx %rsi %rdi %rdx
+ }
diff --git a/clang/test/CodeGen/2010-07-08-DeclDebugLineNo.c b/clang/test/CodeGen/2010-07-08-DeclDebugLineNo.c
new file mode 100644
index 0000000..1637a49
--- /dev/null
+++ b/clang/test/CodeGen/2010-07-08-DeclDebugLineNo.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -g %s -o - | FileCheck %s
+// Insure that dbg.declare lines for locals refer to correct line number records.
+// Radar 8152866.
+void foo() {
+ int l = 0; // line #4: CHECK: {{call.*llvm.dbg.declare.*%l.*\!dbg }}[[variable_l:![0-9]+]]
+ int p = 0; // line #5: CHECK: {{call.*llvm.dbg.declare.*%p.*\!dbg }}[[variable_p:![0-9]+]]
+}
+// Now match the line number records:
+// CHECK: {{^}}[[variable_l]]{{ = metadata ![{]i32 5,}}
+// CHECK: {{^}}[[variable_p]]{{ = metadata ![{]i32 6,}}
diff --git a/clang/test/CodeGen/2010-07-14-overconservative-align.c b/clang/test/CodeGen/2010-07-14-overconservative-align.c
new file mode 100644
index 0000000..5c8c056
--- /dev/null
+++ b/clang/test/CodeGen/2010-07-14-overconservative-align.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
+// PR 5995
+struct s {
+ int word;
+ struct {
+ int filler __attribute__ ((aligned (8)));
+ };
+};
+
+void func (struct s *s)
+{
+ // CHECK: load %struct.s**{{.*}}align 8
+ s->word = 0;
+}
diff --git a/clang/test/CodeGen/2010-07-14-ref-off-end.c b/clang/test/CodeGen/2010-07-14-ref-off-end.c
new file mode 100644
index 0000000..580ae88
--- /dev/null
+++ b/clang/test/CodeGen/2010-07-14-ref-off-end.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple i386-apple-darwin -o - | FileCheck %s
+extern void abort();
+extern void exit(int);
+struct T
+{
+unsigned i:8;
+unsigned c:24;
+};
+f(struct T t)
+{
+struct T s[1];
+s[0]=t;
+return(char)s->c;
+}
+main()
+{
+// CHECK: getelementptr inbounds [1 x %struct.T]* %s, i32 0, i32 0
+// CHECK: getelementptr inbounds [1 x %struct.T]* %s, i32 0, i32 0
+struct T t;
+t.i=0xff;
+t.c=0xffff11;
+if(f(t)!=0x11)abort();
+exit(0);
+}
diff --git a/clang/test/CodeGen/2010-08-10-DbgConstant.c b/clang/test/CodeGen/2010-08-10-DbgConstant.c
new file mode 100644
index 0000000..5b8f064
--- /dev/null
+++ b/clang/test/CodeGen/2010-08-10-DbgConstant.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -S -emit-llvm -g %s -o - | grep DW_TAG_variable
+
+static const unsigned int ro = 201;
+void bar(int);
+void foo() { bar(ro); }
diff --git a/clang/test/CodeGen/2010-08-12-asm-aggr-arg.c b/clang/test/CodeGen/2010-08-12-asm-aggr-arg.c
new file mode 100644
index 0000000..5ddc412
--- /dev/null
+++ b/clang/test/CodeGen/2010-08-12-asm-aggr-arg.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -emit-llvm -O0 -o - | FileCheck %s
+// Radar 8288710: A small aggregate can be passed as an integer. Make sure
+// we don't get an error with "input constraint with a matching output
+// constraint of incompatible type!"
+
+struct wrapper {
+ int i;
+};
+
+// CHECK: xyz
+int test(int i) {
+ struct wrapper w;
+ w.i = i;
+ __asm__("xyz" : "=r" (w) : "0" (w));
+ return w.i;
+}
diff --git a/clang/test/CodeGen/2010-12-01-CommonGlobal.c b/clang/test/CodeGen/2010-12-01-CommonGlobal.c
new file mode 100644
index 0000000..5eadbae
--- /dev/null
+++ b/clang/test/CodeGen/2010-12-01-CommonGlobal.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+// Don't crash on a common-linkage constant global.
+extern const int kABSourceTypeProperty;
+int foo(void) {
+ return kABSourceTypeProperty;
+}
+const int kABSourceTypeProperty;
diff --git a/clang/test/CodeGen/2011-02-21-DATA-common.c b/clang/test/CodeGen/2011-02-21-DATA-common.c
new file mode 100644
index 0000000..5079561
--- /dev/null
+++ b/clang/test/CodeGen/2011-02-21-DATA-common.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+struct rtxc_snapshot {
+ int a, b, c, d;
+};
+__attribute__ ((section("__DATA, __common"))) static struct rtxc_snapshot rtxc_log_A[4];
diff --git a/clang/test/CodeGen/2011-03-02-UnionInitializer.c b/clang/test/CodeGen/2011-03-02-UnionInitializer.c
new file mode 100644
index 0000000..3c112e0
--- /dev/null
+++ b/clang/test/CodeGen/2011-03-02-UnionInitializer.c
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+union { int :3; double f; } u17_017 = {17.17};
diff --git a/clang/test/CodeGen/2011-03-08-ZeroFieldUnionInitializer.c b/clang/test/CodeGen/2011-03-08-ZeroFieldUnionInitializer.c
new file mode 100644
index 0000000..ff570d8
--- /dev/null
+++ b/clang/test/CodeGen/2011-03-08-ZeroFieldUnionInitializer.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+typedef struct {
+ union {
+ struct { } __attribute((packed));
+ };
+} fenv_t;
+const fenv_t _FE_DFL_ENV = {{{ 0, 0, 0, 0 }}};
diff --git a/clang/test/CodeGen/2011-03-31-ArrayRefFolding.c b/clang/test/CodeGen/2011-03-31-ArrayRefFolding.c
new file mode 100644
index 0000000..31c0a68
--- /dev/null
+++ b/clang/test/CodeGen/2011-03-31-ArrayRefFolding.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple i386-apple-darwin %s | FileCheck %s
+// PR9571
+
+struct t {
+ int x;
+};
+
+extern struct t *cfun;
+
+int f(void) {
+ if (!(cfun + 0))
+ // CHECK: icmp ne %struct.t*
+ return 0;
+ return cfun->x;
+}
diff --git a/clang/test/CodeGen/3dnow-builtins.c b/clang/test/CodeGen/3dnow-builtins.c
new file mode 100644
index 0000000..294fbc0
--- /dev/null
+++ b/clang/test/CodeGen/3dnow-builtins.c
@@ -0,0 +1,156 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-unknown-unknown -target-feature +3dnow -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <x86intrin.h>
+
+__m64 test_m_pavgusb(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pavgusb
+ // CHECK: @llvm.x86.3dnow.pavgusb
+ return _m_pavgusb(m1, m2);
+}
+
+__m64 test_m_pf2id(__m64 m) {
+ // CHECK: define i64 @test_m_pf2id
+ // CHECK: @llvm.x86.3dnow.pf2id
+ return _m_pf2id(m);
+}
+
+__m64 test_m_pfacc(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfacc
+ // CHECK: @llvm.x86.3dnow.pfacc
+ return _m_pfacc(m1, m2);
+}
+
+__m64 test_m_pfadd(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfadd
+ // CHECK: @llvm.x86.3dnow.pfadd
+ return _m_pfadd(m1, m2);
+}
+
+__m64 test_m_pfcmpeq(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfcmpeq
+ // CHECK: @llvm.x86.3dnow.pfcmpeq
+ return _m_pfcmpeq(m1, m2);
+}
+
+__m64 test_m_pfcmpge(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfcmpge
+ // CHECK: @llvm.x86.3dnow.pfcmpge
+ return _m_pfcmpge(m1, m2);
+}
+
+__m64 test_m_pfcmpgt(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfcmpgt
+ // CHECK: @llvm.x86.3dnow.pfcmpgt
+ return _m_pfcmpgt(m1, m2);
+}
+
+__m64 test_m_pfmax(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfmax
+ // CHECK: @llvm.x86.3dnow.pfmax
+ return _m_pfmax(m1, m2);
+}
+
+__m64 test_m_pfmin(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfmin
+ // CHECK: @llvm.x86.3dnow.pfmin
+ return _m_pfmin(m1, m2);
+}
+
+__m64 test_m_pfmul(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfmul
+ // CHECK: @llvm.x86.3dnow.pfmul
+ return _m_pfmul(m1, m2);
+}
+
+__m64 test_m_pfrcp(__m64 m) {
+ // CHECK: define i64 @test_m_pfrcp
+ // CHECK: @llvm.x86.3dnow.pfrcp
+ return _m_pfrcp(m);
+}
+
+__m64 test_m_pfrcpit1(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfrcpit1
+ // CHECK: @llvm.x86.3dnow.pfrcpit1
+ return _m_pfrcpit1(m1, m2);
+}
+
+__m64 test_m_pfrcpit2(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfrcpit2
+ // CHECK: @llvm.x86.3dnow.pfrcpit2
+ return _m_pfrcpit2(m1, m2);
+}
+
+__m64 test_m_pfrsqrt(__m64 m) {
+ // CHECK: define i64 @test_m_pfrsqrt
+ // CHECK: @llvm.x86.3dnow.pfrsqrt
+ return _m_pfrsqrt(m);
+}
+
+__m64 test_m_pfrsqrtit1(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfrsqrtit1
+ // CHECK: @llvm.x86.3dnow.pfrsqit1
+ return _m_pfrsqrtit1(m1, m2);
+}
+
+__m64 test_m_pfsub(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfsub
+ // CHECK: @llvm.x86.3dnow.pfsub
+ return _m_pfsub(m1, m2);
+}
+
+__m64 test_m_pfsubr(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfsubr
+ // CHECK: @llvm.x86.3dnow.pfsubr
+ return _m_pfsubr(m1, m2);
+}
+
+__m64 test_m_pi2fd(__m64 m) {
+ // CHECK: define i64 @test_m_pi2fd
+ // CHECK: @llvm.x86.3dnow.pi2fd
+ return _m_pi2fd(m);
+}
+
+__m64 test_m_pmulhrw(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pmulhrw
+ // CHECK: @llvm.x86.3dnow.pmulhrw
+ return _m_pmulhrw(m1, m2);
+}
+
+__m64 test_m_pf2iw(__m64 m) {
+ // CHECK: define i64 @test_m_pf2iw
+ // CHECK: @llvm.x86.3dnowa.pf2iw
+ return _m_pf2iw(m);
+}
+
+__m64 test_m_pfnacc(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfnacc
+ // CHECK: @llvm.x86.3dnowa.pfnacc
+ return _m_pfnacc(m1, m2);
+}
+
+__m64 test_m_pfpnacc(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfpnacc
+ // CHECK: @llvm.x86.3dnowa.pfpnacc
+ return _m_pfpnacc(m1, m2);
+}
+
+__m64 test_m_pi2fw(__m64 m) {
+ // CHECK: define i64 @test_m_pi2fw
+ // CHECK: @llvm.x86.3dnowa.pi2fw
+ return _m_pi2fw(m);
+}
+
+__m64 test_m_pswapdsf(__m64 m) {
+ // CHECK: define i64 @test_m_pswapdsf
+ // CHECK: @llvm.x86.3dnowa.pswapd
+ return _m_pswapdsf(m);
+}
+
+__m64 test_m_pswapdsi(__m64 m) {
+ // CHECK: define i64 @test_m_pswapdsi
+ // CHECK: @llvm.x86.3dnowa.pswapd
+ return _m_pswapdsi(m);
+}
diff --git a/clang/test/CodeGen/Atomics.c b/clang/test/CodeGen/Atomics.c
new file mode 100644
index 0000000..c440b6c
--- /dev/null
+++ b/clang/test/CodeGen/Atomics.c
@@ -0,0 +1,203 @@
+// Test frontend handling of __sync builtins.
+// Modified from a gcc testcase.
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+signed char sc;
+unsigned char uc;
+signed short ss;
+unsigned short us;
+signed int si;
+unsigned int ui;
+signed long long sll;
+unsigned long long ull;
+
+void test_op_ignore (void) // CHECK: define void @test_op_ignore
+{
+ (void) __sync_fetch_and_add (&sc, 1); // CHECK: atomicrmw add i8
+ (void) __sync_fetch_and_add (&uc, 1); // CHECK: atomicrmw add i8
+ (void) __sync_fetch_and_add (&ss, 1); // CHECK: atomicrmw add i16
+ (void) __sync_fetch_and_add (&us, 1); // CHECK: atomicrmw add i16
+ (void) __sync_fetch_and_add (&si, 1); // CHECK: atomicrmw add i32
+ (void) __sync_fetch_and_add (&ui, 1); // CHECK: atomicrmw add i32
+ (void) __sync_fetch_and_add (&sll, 1); // CHECK: atomicrmw add i64
+ (void) __sync_fetch_and_add (&ull, 1); // CHECK: atomicrmw add i64
+
+ (void) __sync_fetch_and_sub (&sc, 1); // CHECK: atomicrmw sub i8
+ (void) __sync_fetch_and_sub (&uc, 1); // CHECK: atomicrmw sub i8
+ (void) __sync_fetch_and_sub (&ss, 1); // CHECK: atomicrmw sub i16
+ (void) __sync_fetch_and_sub (&us, 1); // CHECK: atomicrmw sub i16
+ (void) __sync_fetch_and_sub (&si, 1); // CHECK: atomicrmw sub i32
+ (void) __sync_fetch_and_sub (&ui, 1); // CHECK: atomicrmw sub i32
+ (void) __sync_fetch_and_sub (&sll, 1); // CHECK: atomicrmw sub i64
+ (void) __sync_fetch_and_sub (&ull, 1); // CHECK: atomicrmw sub i64
+
+ (void) __sync_fetch_and_or (&sc, 1); // CHECK: atomicrmw or i8
+ (void) __sync_fetch_and_or (&uc, 1); // CHECK: atomicrmw or i8
+ (void) __sync_fetch_and_or (&ss, 1); // CHECK: atomicrmw or i16
+ (void) __sync_fetch_and_or (&us, 1); // CHECK: atomicrmw or i16
+ (void) __sync_fetch_and_or (&si, 1); // CHECK: atomicrmw or i32
+ (void) __sync_fetch_and_or (&ui, 1); // CHECK: atomicrmw or i32
+ (void) __sync_fetch_and_or (&sll, 1); // CHECK: atomicrmw or i64
+ (void) __sync_fetch_and_or (&ull, 1); // CHECK: atomicrmw or i64
+
+ (void) __sync_fetch_and_xor (&sc, 1); // CHECK: atomicrmw xor i8
+ (void) __sync_fetch_and_xor (&uc, 1); // CHECK: atomicrmw xor i8
+ (void) __sync_fetch_and_xor (&ss, 1); // CHECK: atomicrmw xor i16
+ (void) __sync_fetch_and_xor (&us, 1); // CHECK: atomicrmw xor i16
+ (void) __sync_fetch_and_xor (&si, 1); // CHECK: atomicrmw xor i32
+ (void) __sync_fetch_and_xor (&ui, 1); // CHECK: atomicrmw xor i32
+ (void) __sync_fetch_and_xor (&sll, 1); // CHECK: atomicrmw xor i64
+ (void) __sync_fetch_and_xor (&ull, 1); // CHECK: atomicrmw xor i64
+
+ (void) __sync_fetch_and_and (&sc, 1); // CHECK: atomicrmw and i8
+ (void) __sync_fetch_and_and (&uc, 1); // CHECK: atomicrmw and i8
+ (void) __sync_fetch_and_and (&ss, 1); // CHECK: atomicrmw and i16
+ (void) __sync_fetch_and_and (&us, 1); // CHECK: atomicrmw and i16
+ (void) __sync_fetch_and_and (&si, 1); // CHECK: atomicrmw and i32
+ (void) __sync_fetch_and_and (&ui, 1); // CHECK: atomicrmw and i32
+ (void) __sync_fetch_and_and (&sll, 1); // CHECK: atomicrmw and i64
+ (void) __sync_fetch_and_and (&ull, 1); // CHECK: atomicrmw and i64
+
+}
+
+void test_fetch_and_op (void) // CHECK: define void @test_fetch_and_op
+{
+ sc = __sync_fetch_and_add (&sc, 11); // CHECK: atomicrmw add
+ uc = __sync_fetch_and_add (&uc, 11); // CHECK: atomicrmw add
+ ss = __sync_fetch_and_add (&ss, 11); // CHECK: atomicrmw add
+ us = __sync_fetch_and_add (&us, 11); // CHECK: atomicrmw add
+ si = __sync_fetch_and_add (&si, 11); // CHECK: atomicrmw add
+ ui = __sync_fetch_and_add (&ui, 11); // CHECK: atomicrmw add
+ sll = __sync_fetch_and_add (&sll, 11); // CHECK: atomicrmw add
+ ull = __sync_fetch_and_add (&ull, 11); // CHECK: atomicrmw add
+
+ sc = __sync_fetch_and_sub (&sc, 11); // CHECK: atomicrmw sub
+ uc = __sync_fetch_and_sub (&uc, 11); // CHECK: atomicrmw sub
+ ss = __sync_fetch_and_sub (&ss, 11); // CHECK: atomicrmw sub
+ us = __sync_fetch_and_sub (&us, 11); // CHECK: atomicrmw sub
+ si = __sync_fetch_and_sub (&si, 11); // CHECK: atomicrmw sub
+ ui = __sync_fetch_and_sub (&ui, 11); // CHECK: atomicrmw sub
+ sll = __sync_fetch_and_sub (&sll, 11); // CHECK: atomicrmw sub
+ ull = __sync_fetch_and_sub (&ull, 11); // CHECK: atomicrmw sub
+
+ sc = __sync_fetch_and_or (&sc, 11); // CHECK: atomicrmw or
+ uc = __sync_fetch_and_or (&uc, 11); // CHECK: atomicrmw or
+ ss = __sync_fetch_and_or (&ss, 11); // CHECK: atomicrmw or
+ us = __sync_fetch_and_or (&us, 11); // CHECK: atomicrmw or
+ si = __sync_fetch_and_or (&si, 11); // CHECK: atomicrmw or
+ ui = __sync_fetch_and_or (&ui, 11); // CHECK: atomicrmw or
+ sll = __sync_fetch_and_or (&sll, 11); // CHECK: atomicrmw or
+ ull = __sync_fetch_and_or (&ull, 11); // CHECK: atomicrmw or
+
+ sc = __sync_fetch_and_xor (&sc, 11); // CHECK: atomicrmw xor
+ uc = __sync_fetch_and_xor (&uc, 11); // CHECK: atomicrmw xor
+ ss = __sync_fetch_and_xor (&ss, 11); // CHECK: atomicrmw xor
+ us = __sync_fetch_and_xor (&us, 11); // CHECK: atomicrmw xor
+ si = __sync_fetch_and_xor (&si, 11); // CHECK: atomicrmw xor
+ ui = __sync_fetch_and_xor (&ui, 11); // CHECK: atomicrmw xor
+ sll = __sync_fetch_and_xor (&sll, 11); // CHECK: atomicrmw xor
+ ull = __sync_fetch_and_xor (&ull, 11); // CHECK: atomicrmw xor
+
+ sc = __sync_fetch_and_and (&sc, 11); // CHECK: atomicrmw and
+ uc = __sync_fetch_and_and (&uc, 11); // CHECK: atomicrmw and
+ ss = __sync_fetch_and_and (&ss, 11); // CHECK: atomicrmw and
+ us = __sync_fetch_and_and (&us, 11); // CHECK: atomicrmw and
+ si = __sync_fetch_and_and (&si, 11); // CHECK: atomicrmw and
+ ui = __sync_fetch_and_and (&ui, 11); // CHECK: atomicrmw and
+ sll = __sync_fetch_and_and (&sll, 11); // CHECK: atomicrmw and
+ ull = __sync_fetch_and_and (&ull, 11); // CHECK: atomicrmw and
+
+}
+
+void test_op_and_fetch (void)
+{
+ sc = __sync_add_and_fetch (&sc, uc); // CHECK: atomicrmw add
+ uc = __sync_add_and_fetch (&uc, uc); // CHECK: atomicrmw add
+ ss = __sync_add_and_fetch (&ss, uc); // CHECK: atomicrmw add
+ us = __sync_add_and_fetch (&us, uc); // CHECK: atomicrmw add
+ si = __sync_add_and_fetch (&si, uc); // CHECK: atomicrmw add
+ ui = __sync_add_and_fetch (&ui, uc); // CHECK: atomicrmw add
+ sll = __sync_add_and_fetch (&sll, uc); // CHECK: atomicrmw add
+ ull = __sync_add_and_fetch (&ull, uc); // CHECK: atomicrmw add
+
+ sc = __sync_sub_and_fetch (&sc, uc); // CHECK: atomicrmw sub
+ uc = __sync_sub_and_fetch (&uc, uc); // CHECK: atomicrmw sub
+ ss = __sync_sub_and_fetch (&ss, uc); // CHECK: atomicrmw sub
+ us = __sync_sub_and_fetch (&us, uc); // CHECK: atomicrmw sub
+ si = __sync_sub_and_fetch (&si, uc); // CHECK: atomicrmw sub
+ ui = __sync_sub_and_fetch (&ui, uc); // CHECK: atomicrmw sub
+ sll = __sync_sub_and_fetch (&sll, uc); // CHECK: atomicrmw sub
+ ull = __sync_sub_and_fetch (&ull, uc); // CHECK: atomicrmw sub
+
+ sc = __sync_or_and_fetch (&sc, uc); // CHECK: atomicrmw or
+ uc = __sync_or_and_fetch (&uc, uc); // CHECK: atomicrmw or
+ ss = __sync_or_and_fetch (&ss, uc); // CHECK: atomicrmw or
+ us = __sync_or_and_fetch (&us, uc); // CHECK: atomicrmw or
+ si = __sync_or_and_fetch (&si, uc); // CHECK: atomicrmw or
+ ui = __sync_or_and_fetch (&ui, uc); // CHECK: atomicrmw or
+ sll = __sync_or_and_fetch (&sll, uc); // CHECK: atomicrmw or
+ ull = __sync_or_and_fetch (&ull, uc); // CHECK: atomicrmw or
+
+ sc = __sync_xor_and_fetch (&sc, uc); // CHECK: atomicrmw xor
+ uc = __sync_xor_and_fetch (&uc, uc); // CHECK: atomicrmw xor
+ ss = __sync_xor_and_fetch (&ss, uc); // CHECK: atomicrmw xor
+ us = __sync_xor_and_fetch (&us, uc); // CHECK: atomicrmw xor
+ si = __sync_xor_and_fetch (&si, uc); // CHECK: atomicrmw xor
+ ui = __sync_xor_and_fetch (&ui, uc); // CHECK: atomicrmw xor
+ sll = __sync_xor_and_fetch (&sll, uc); // CHECK: atomicrmw xor
+ ull = __sync_xor_and_fetch (&ull, uc); // CHECK: atomicrmw xor
+
+ sc = __sync_and_and_fetch (&sc, uc); // CHECK: atomicrmw and
+ uc = __sync_and_and_fetch (&uc, uc); // CHECK: atomicrmw and
+ ss = __sync_and_and_fetch (&ss, uc); // CHECK: atomicrmw and
+ us = __sync_and_and_fetch (&us, uc); // CHECK: atomicrmw and
+ si = __sync_and_and_fetch (&si, uc); // CHECK: atomicrmw and
+ ui = __sync_and_and_fetch (&ui, uc); // CHECK: atomicrmw and
+ sll = __sync_and_and_fetch (&sll, uc); // CHECK: atomicrmw and
+ ull = __sync_and_and_fetch (&ull, uc); // CHECK: atomicrmw and
+
+}
+
+void test_compare_and_swap (void)
+{
+ sc = __sync_val_compare_and_swap (&sc, uc, sc); // CHECK: cmpxchg i8
+ uc = __sync_val_compare_and_swap (&uc, uc, sc); // CHECK: cmpxchg i8
+ ss = __sync_val_compare_and_swap (&ss, uc, sc); // CHECK: cmpxchg i16
+ us = __sync_val_compare_and_swap (&us, uc, sc); // CHECK: cmpxchg i16
+ si = __sync_val_compare_and_swap (&si, uc, sc); // CHECK: cmpxchg i32
+ ui = __sync_val_compare_and_swap (&ui, uc, sc); // CHECK: cmpxchg i32
+ sll = __sync_val_compare_and_swap (&sll, uc, sc); // CHECK: cmpxchg i64
+ ull = __sync_val_compare_and_swap (&ull, uc, sc); // CHECK: cmpxchg i64
+
+ ui = __sync_bool_compare_and_swap (&sc, uc, sc); // CHECK: cmpxchg
+ ui = __sync_bool_compare_and_swap (&uc, uc, sc); // CHECK: cmpxchg
+ ui = __sync_bool_compare_and_swap (&ss, uc, sc); // CHECK: cmpxchg
+ ui = __sync_bool_compare_and_swap (&us, uc, sc); // CHECK: cmpxchg
+ ui = __sync_bool_compare_and_swap (&si, uc, sc); // CHECK: cmpxchg
+ ui = __sync_bool_compare_and_swap (&ui, uc, sc); // CHECK: cmpxchg
+ ui = __sync_bool_compare_and_swap (&sll, uc, sc); // CHECK: cmpxchg
+ ui = __sync_bool_compare_and_swap (&ull, uc, sc); // CHECK: cmpxchg
+}
+
+void test_lock (void)
+{
+ sc = __sync_lock_test_and_set (&sc, 1); // CHECK: atomicrmw xchg i8
+ uc = __sync_lock_test_and_set (&uc, 1); // CHECK: atomicrmw xchg i8
+ ss = __sync_lock_test_and_set (&ss, 1); // CHECK: atomicrmw xchg i16
+ us = __sync_lock_test_and_set (&us, 1); // CHECK: atomicrmw xchg i16
+ si = __sync_lock_test_and_set (&si, 1); // CHECK: atomicrmw xchg i32
+ ui = __sync_lock_test_and_set (&ui, 1); // CHECK: atomicrmw xchg i32
+ sll = __sync_lock_test_and_set (&sll, 1); // CHECK: atomicrmw xchg i64
+ ull = __sync_lock_test_and_set (&ull, 1); // CHECK: atomicrmw xchg i64
+
+ __sync_synchronize (); // CHECK: fence seq_cst
+
+ __sync_lock_release (&sc); // CHECK: store atomic {{.*}} release, align 1
+ __sync_lock_release (&uc); // CHECK: store atomic {{.*}} release, align 1
+ __sync_lock_release (&ss); // CHECK: store atomic {{.*}} release, align 2
+ __sync_lock_release (&us); /// CHECK: store atomic {{.*}} release, align 2
+ __sync_lock_release (&si); // CHECK: store atomic {{.*}} release, align 4
+ __sync_lock_release (&ui); // CHECK: store atomic {{.*}} release, align 4
+ __sync_lock_release (&sll); // CHECK: store atomic {{.*}} release, align 8
+ __sync_lock_release (&ull); // CHECK: store atomic {{.*}} release, align 8
+}
diff --git a/clang/test/CodeGen/BasicInstrs.c b/clang/test/CodeGen/BasicInstrs.c
new file mode 100644
index 0000000..2b8a6f6
--- /dev/null
+++ b/clang/test/CodeGen/BasicInstrs.c
@@ -0,0 +1,25 @@
+// This file can be used to see what a native C compiler is generating for a
+// variety of interesting operations.
+//
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+unsigned int udiv(unsigned int X, unsigned int Y) {
+ return X/Y;
+}
+int sdiv(int X, int Y) {
+ return X/Y;
+}
+unsigned int urem(unsigned int X, unsigned int Y) {
+ return X%Y;
+}
+int srem(int X, int Y) {
+ return X%Y;
+}
+
+_Bool setlt(int X, int Y) {
+ return X < Y;
+}
+
+_Bool setgt(int X, int Y) {
+ return X > Y;
+}
diff --git a/clang/test/CodeGen/Inputs/stdio.h b/clang/test/CodeGen/Inputs/stdio.h
new file mode 100644
index 0000000..cfe3595
--- /dev/null
+++ b/clang/test/CodeGen/Inputs/stdio.h
@@ -0,0 +1,9 @@
+struct FILE;
+extern int vfprintf(struct FILE *s, const char *format, __builtin_va_list arg);
+extern int vprintf(const char *format, __builtin_va_list arg);
+
+extern __inline __attribute__((gnu_inline,always_inline)) int
+vprintf(const char *x, __builtin_va_list y)
+{
+ return vfprintf (0, 0, 0);
+}
diff --git a/clang/test/CodeGen/OpaqueStruct.c b/clang/test/CodeGen/OpaqueStruct.c
new file mode 100644
index 0000000..fe96126
--- /dev/null
+++ b/clang/test/CodeGen/OpaqueStruct.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+typedef struct a b;
+
+b* x;
+
+struct a {
+ b* p;
+};
+
+void f() {
+ b* z = x->p;
+}
diff --git a/clang/test/CodeGen/PR2001-bitfield-reload.c b/clang/test/CodeGen/PR2001-bitfield-reload.c
new file mode 100644
index 0000000..d05aef3
--- /dev/null
+++ b/clang/test/CodeGen/PR2001-bitfield-reload.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O3 -emit-llvm -o - %s | FileCheck %s
+// PR2001
+
+/* Test that the result of the assignment properly uses the value *in
+ the bitfield* as opposed to the RHS. */
+static int foo(int i) {
+ struct {
+ int f0 : 2;
+ } x;
+ return (x.f0 = i);
+}
+
+int bar() {
+ // CHECK: ret i32 1
+ return foo(-5) == -1;
+}
diff --git a/clang/test/CodeGen/PR2413-void-address-cast-error.c b/clang/test/CodeGen/PR2413-void-address-cast-error.c
new file mode 100644
index 0000000..3920dfd
--- /dev/null
+++ b/clang/test/CodeGen/PR2413-void-address-cast-error.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+void f()
+{
+ void *addr;
+ addr = (void *)( ((long int)addr + 7L) );
+}
diff --git a/clang/test/CodeGen/PR2643-null-store-to-bitfield.c b/clang/test/CodeGen/PR2643-null-store-to-bitfield.c
new file mode 100644
index 0000000..d6c2f36
--- /dev/null
+++ b/clang/test/CodeGen/PR2643-null-store-to-bitfield.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+// PR2643
+
+void foo() {
+ struct {
+ int a : 1;
+ int b : 1;
+ } entry = {0};
+}
+
diff --git a/clang/test/CodeGen/PR2743-reference-missing-static.c b/clang/test/CodeGen/PR2743-reference-missing-static.c
new file mode 100644
index 0000000..f32d6c5
--- /dev/null
+++ b/clang/test/CodeGen/PR2743-reference-missing-static.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// PR2743
+// <rdr://6094512>
+
+/* CodeGen should handle this even if it makes it past
+ sema. Unfortunately this test will become useless once sema starts
+ rejecting this. */
+
+static void e0();
+void f0() { e0(); }
+
+inline void e1();
+void f1() { e1(); }
+
+void e2() __attribute__((weak));
+void f2() { e2(); }
diff --git a/clang/test/CodeGen/PR3130-cond-constant.c b/clang/test/CodeGen/PR3130-cond-constant.c
new file mode 100644
index 0000000..dbec650
--- /dev/null
+++ b/clang/test/CodeGen/PR3130-cond-constant.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+int a = 2.0 ? 1 : 2;
diff --git a/clang/test/CodeGen/PR3589-freestanding-libcalls.c b/clang/test/CodeGen/PR3589-freestanding-libcalls.c
new file mode 100644
index 0000000..8b8282f
--- /dev/null
+++ b/clang/test/CodeGen/PR3589-freestanding-libcalls.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | grep 'declare i32 @printf' | count 1
+// RUN: %clang_cc1 -O2 -emit-llvm %s -o - | grep 'declare i32 @puts' | count 1
+// RUN: %clang_cc1 -ffreestanding -O2 -emit-llvm %s -o - | grep 'declare i32 @puts' | count 0
+
+int printf(const char *, ...);
+
+void f0() {
+ printf("hello\n");
+}
diff --git a/clang/test/CodeGen/PR3613-static-decl.c b/clang/test/CodeGen/PR3613-static-decl.c
new file mode 100644
index 0000000..7f6d979
--- /dev/null
+++ b/clang/test/CodeGen/PR3613-static-decl.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o %t %s
+// RUN: grep '@g0 = internal global %.truct.s0 { i32 3 }' %t | count 1
+
+struct s0 {
+ int a;
+};
+
+static struct s0 g0;
+
+static int f0(void) {
+ return g0.a;
+}
+
+static struct s0 g0 = {3};
+
+void *g1 = f0;
diff --git a/clang/test/CodeGen/PR3709-int-to-pointer-sign.c b/clang/test/CodeGen/PR3709-int-to-pointer-sign.c
new file mode 100644
index 0000000..f77737e
--- /dev/null
+++ b/clang/test/CodeGen/PR3709-int-to-pointer-sign.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -O1 -triple=x86_64-gnu-linux | grep "i64 -1"
+
+// PR3709
+long long a() { return (long long)(int*)-1;}
+
diff --git a/clang/test/CodeGen/PR4611-bitfield-layout.c b/clang/test/CodeGen/PR4611-bitfield-layout.c
new file mode 100644
index 0000000..3975ed0
--- /dev/null
+++ b/clang/test/CodeGen/PR4611-bitfield-layout.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o %t
+// RUN: grep "struct.object_entry = type { i8, \[2 x i8\], i8 }" %t
+
+struct object_entry {
+ unsigned int type:3, pack_id:16, depth:13;
+} entries;
diff --git a/clang/test/CodeGen/PR5060-align.c b/clang/test/CodeGen/PR5060-align.c
new file mode 100644
index 0000000..efd8520
--- /dev/null
+++ b/clang/test/CodeGen/PR5060-align.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -verify | FileCheck %s
+
+// CHECK: @foo.p = internal global i8 0, align 32
+char *foo(void) {
+ static char p __attribute__((aligned(32)));
+ return &p;
+}
+
+void bar(long n) {
+ // CHECK: align 32
+ char p[n] __attribute__((aligned(32)));
+}
+
diff --git a/clang/test/CodeGen/_Bool-conversion.c b/clang/test/CodeGen/_Bool-conversion.c
new file mode 100644
index 0000000..9e5e894
--- /dev/null
+++ b/clang/test/CodeGen/_Bool-conversion.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple i386 -emit-llvm -O2 -o - %s | FileCheck %s
+
+// CHECK: define i32 @f0()
+// CHECK: ret i32 1
+// CHECK: }
+
+static _Bool f0_0(void *a0) { return (_Bool) a0; }
+int f0() { return f0_0((void*) 0x2); }
+
+_Bool f1(void) {
+ return (_Bool) ({ void (*x)(); x = 0; });
+}
diff --git a/clang/test/CodeGen/address-safety-attr.cpp b/clang/test/CodeGen/address-safety-attr.cpp
new file mode 100644
index 0000000..9d0fb95
--- /dev/null
+++ b/clang/test/CodeGen/address-safety-attr.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - %s -faddress-sanitizer | FileCheck -check-prefix ASAN %s
+
+// The address_safety attribute should be attached to functions
+// when AddressSanitizer is enabled, unless no_address_safety_analysis attribute
+// is present.
+
+// CHECK-NOT: NoAddressSafety1{{.*}} address_safety
+// ASAN-NOT: NoAddressSafety1{{.*}} address_safety
+__attribute__((no_address_safety_analysis))
+int NoAddressSafety1(int *a) { return *a; }
+
+// CHECK-NOT: NoAddressSafety2{{.*}} address_safety
+// ASAN-NOT: NoAddressSafety2{{.*}} address_safety
+__attribute__((no_address_safety_analysis))
+int NoAddressSafety2(int *a);
+int NoAddressSafety2(int *a) { return *a; }
+
+// CHECK-NOT: AddressSafetyOk{{.*}} address_safety
+// ASAN: AddressSafetyOk{{.*}} address_safety
+int AddressSafetyOk(int *a) { return *a; }
+
+// CHECK-NOT: TemplateNoAddressSafety{{.*}} address_safety
+// ASAN-NOT: TemplateNoAddressSafety{{.*}} address_safety
+template<int i>
+__attribute__((no_address_safety_analysis))
+int TemplateNoAddressSafety() { return i; }
+
+// CHECK-NOT: TemplateAddressSafetyOk{{.*}} address_safety
+// ASAN: TemplateAddressSafetyOk{{.*}} address_safety
+template<int i>
+int TemplateAddressSafetyOk() { return i; }
+
+int force_instance = TemplateAddressSafetyOk<42>()
+ + TemplateNoAddressSafety<42>();
diff --git a/clang/test/CodeGen/address-space-cast.c b/clang/test/CodeGen/address-space-cast.c
new file mode 100644
index 0000000..076c2f1
--- /dev/null
+++ b/clang/test/CodeGen/address-space-cast.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm < %s
+
+volatile unsigned char* const __attribute__((address_space(1))) serial_ctrl = 0x02;
+
diff --git a/clang/test/CodeGen/address-space-compound-literal.c b/clang/test/CodeGen/address-space-compound-literal.c
new file mode 100644
index 0000000..37d9c7b
--- /dev/null
+++ b/clang/test/CodeGen/address-space-compound-literal.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm < %s | grep "internal addrspace(1) global i32 1"
+
+typedef int a __attribute__((address_space(1)));
+a* x = &(a){1};
+
diff --git a/clang/test/CodeGen/address-space-field1.c b/clang/test/CodeGen/address-space-field1.c
new file mode 100644
index 0000000..e9c1871
--- /dev/null
+++ b/clang/test/CodeGen/address-space-field1.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10 < %s -o - | FileCheck %s
+// CHECK:%struct.S = type { i32, i32 }
+// CHECK:define void @test_addrspace(%struct.S addrspace(1)* %p1, %struct.S addrspace(2)* %p2) nounwind
+// CHECK: [[p1addr:%.*]] = alloca %struct.S addrspace(1)*
+// CHECK: [[p2addr:%.*]] = alloca %struct.S addrspace(2)*
+// CHECK: store %struct.S addrspace(1)* %p1, %struct.S addrspace(1)** [[p1addr]]
+// CHECK: store %struct.S addrspace(2)* %p2, %struct.S addrspace(2)** [[p2addr]]
+// CHECK: [[t0:%.*]] = load %struct.S addrspace(2)** [[p2addr]], align 8
+// CHECK: [[t1:%.*]] = getelementptr inbounds %struct.S addrspace(2)* [[t0]], i32 0, i32 1
+// CHECK: [[t2:%.*]] = load i32 addrspace(2)* [[t1]], align 4
+// CHECK: [[t3:%.*]] = load %struct.S addrspace(1)** [[p1addr]], align 8
+// CHECK: [[t4:%.*]] = getelementptr inbounds %struct.S addrspace(1)* [[t3]], i32 0, i32 0
+// CHECK: store i32 [[t2]], i32 addrspace(1)* [[t4]], align 4
+// CHECK: [[t5:%.*]] = load %struct.S addrspace(2)** [[p2addr]], align 8
+// CHECK: [[t6:%.*]] = getelementptr inbounds %struct.S addrspace(2)* [[t5]], i32 0, i32 0
+// CHECK: [[t7:%.*]] = load i32 addrspace(2)* [[t6]], align 4
+// CHECK: [[t8:%.*]] = load %struct.S addrspace(1)** [[p1addr]], align 8
+// CHECK: [[t9:%.*]] = getelementptr inbounds %struct.S addrspace(1)* [[t8]], i32 0, i32 1
+// CHECK: store i32 [[t7]], i32 addrspace(1)* [[t9]], align 4
+// CHECK: ret void
+// CHECK:}
+
+// Check that we don't lose the address space when accessing a member
+// of a structure.
+
+#define __addr1 __attribute__((address_space(1)))
+#define __addr2 __attribute__((address_space(2)))
+
+typedef struct S {
+ int a;
+ int b;
+} S;
+
+void test_addrspace(__addr1 S* p1, __addr2 S*p2) {
+ // swap
+ p1->a = p2->b;
+ p1->b = p2->a;
+}
diff --git a/clang/test/CodeGen/address-space.c b/clang/test/CodeGen/address-space.c
new file mode 100644
index 0000000..04f88dc
--- /dev/null
+++ b/clang/test/CodeGen/address-space.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm < %s | grep 'load.*addrspace(2).. @A'
+// RUN: %clang_cc1 -emit-llvm < %s | grep 'load.*addrspace(2).. @B'
+
+
+// CHECK: @foo = common addrspace(1) global
+int foo __attribute__((address_space(1)));
+
+// CHECK: @ban = common addrspace(1) global
+int ban[10] __attribute__((address_space(1)));
+
+// CHECK: define i32 @test1()
+// CHECK: load i32 addrspace(1)* @foo
+int test1() { return foo; }
+
+// CHECK: define i32 @test2(i32 %i)
+// CHECK: load i32 addrspace(1)*
+// CHECK-NEXT: ret i32
+int test2(int i) { return ban[i]; }
+
+// Both A and B point into addrspace(2).
+__attribute__((address_space(2))) int *A, *B;
+
+// CHECK: define void @test3()
+// CHECK: load i32 addrspace(2)** @B
+// CHECK: load i32 addrspace(2)*
+// CHECK: load i32 addrspace(2)** @A
+// CHECK: store i32 {{.*}}, i32 addrspace(2)*
+void test3() {
+ *A = *B;
+}
+
+// PR7437
+typedef struct {
+ float aData[1];
+} MyStruct;
+
+// CHECK: define void @test4(
+// CHECK: call void @llvm.memcpy.p0i8.p2i8
+// CHECK: call void @llvm.memcpy.p2i8.p0i8
+void test4(MyStruct __attribute__((address_space(2))) *pPtr) {
+ MyStruct s = pPtr[0];
+ pPtr[0] = s;
+}
diff --git a/clang/test/CodeGen/alias.c b/clang/test/CodeGen/alias.c
new file mode 100644
index 0000000..f2e87a5
--- /dev/null
+++ b/clang/test/CodeGen/alias.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o %t %s
+// RUN: grep '@g0 = common global i32 0' %t
+// RUN: grep '@f1 = alias void ()\* @f0' %t
+// RUN: grep '@g1 = alias i32\* @g0' %t
+// RUN: grep 'define void @f0() nounwind {' %t
+
+void f0(void) { }
+extern void f1(void);
+extern void f1(void) __attribute((alias("f0")));
+
+int g0;
+extern int g1;
+extern int g1 __attribute((alias("g0")));
+
+// Make sure that aliases cause referenced values to be emitted.
+// PR3200
+// RUN: grep 'define internal i32 @foo1()' %t
+static inline int foo1() { return 0; }
+int foo() __attribute__((alias("foo1")));
+
+
+// RUN: grep '@bar1 = internal global i32 42' %t
+static int bar1 = 42;
+int bar() __attribute__((alias("bar1")));
+
+
+extern int test6();
+void test7() { test6(); } // test6 is emitted as extern.
+
+// test6 changes to alias.
+int test6() __attribute__((alias("test7")));
+
diff --git a/clang/test/CodeGen/align-local.c b/clang/test/CodeGen/align-local.c
new file mode 100644
index 0000000..b839ee1
--- /dev/null
+++ b/clang/test/CodeGen/align-local.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm < %s | grep "align 16" | count 2
+
+typedef struct __attribute((aligned(16))) {int x[4];} ff;
+
+int a() {
+ ff a;
+ struct {int x[4];} b __attribute((aligned(16)));
+}
diff --git a/clang/test/CodeGen/align-param.c b/clang/test/CodeGen/align-param.c
new file mode 100644
index 0000000..8907f66
--- /dev/null
+++ b/clang/test/CodeGen/align-param.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-apple-macosx10.7.2 < %s | FileCheck %s
+
+// The preferred alignment for a long long on x86-32 is 8; make sure the
+// alloca for x uses that alignment.
+int test (long long x) {
+ return (int)x;
+}
+// CHECK: define i32 @test
+// CHECK: alloca i64, align 8
+
+
+// Make sure we honor the aligned attribute.
+struct X { int x,y,z,a; };
+int test2(struct X x __attribute((aligned(16)))) {
+ return x.z;
+}
+// CHECK: define i32 @test2
+// CHECK: alloca %struct.X, align 16
diff --git a/clang/test/CodeGen/alignment.c b/clang/test/CodeGen/alignment.c
new file mode 100644
index 0000000..8882c91
--- /dev/null
+++ b/clang/test/CodeGen/alignment.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+__attribute((aligned(16))) float a[128];
+union {int a[4]; __attribute((aligned(16))) float b[4];} b;
+
+// CHECK: @a = {{.*}}zeroinitializer, align 16
+// CHECK: @b = {{.*}}zeroinitializer, align 16
+
+
+
+// PR5279 - Reduced alignment on typedef.
+typedef int myint __attribute__((aligned(1)));
+
+void test1(myint *p) {
+ *p = 0;
+}
+// CHECK: @test1(
+// CHECK: store i32 0, i32* {{.*}}, align 1
+// CHECK: ret void
+
+int test1a(myint *p) {
+ return *p;
+}
+// CHECK: @test1a(
+// CHECK: load i32* {{.*}}, align 1
+// CHECK: ret i32
+
+
+// PR5279 - Reduced alignment on typedef.
+typedef float __attribute__((vector_size(16), aligned(4))) packedfloat4;
+
+void test2(packedfloat4 *p) {
+ *p = (packedfloat4) { 3.2f, 2.3f, 0.1f, 0.0f };
+}
+// CHECK: @test2(
+// CHECK: store <4 x float> {{.*}}, align 4
+// CHECK: ret void
+
+
+// PR5279 - Reduced alignment on typedef.
+typedef float __attribute__((ext_vector_type(3), aligned(4))) packedfloat3;
+void test3(packedfloat3 *p) {
+ *p = (packedfloat3) { 3.2f, 2.3f, 0.1f };
+}
+// CHECK: @test3(
+// CHECK: store <3 x float> {{.*}}, align 4
+// CHECK: ret void
+
+
+
+typedef float __attribute__((vector_size(16), aligned(64))) float4align64;
+
+// rdar://10639962 - Typedef alignment lost in p[]-style dereferencing
+void test4(float4align64 *p) {
+ p[0] = (float4align64){ 3.2f, 2.3f, 0.1f, 0.0f };
+}
+// CHECK: @test4(
+// CHECK: store <4 x float> {{.*}}, <4 x float>* {{.*}}, align 64
+
diff --git a/clang/test/CodeGen/alignof.c b/clang/test/CodeGen/alignof.c
new file mode 100644
index 0000000..64d0c08
--- /dev/null
+++ b/clang/test/CodeGen/alignof.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O1 -emit-llvm -o %t %s
+// RUN: grep 'ret i32 4' %t
+
+enum e0 { E0 };
+struct s0 {
+ enum e0 a:31;
+};
+
+struct s0 t1_tmp;
+int f0() {
+ return __alignof__(t1_tmp);
+}
diff --git a/clang/test/CodeGen/altivec.c b/clang/test/CodeGen/altivec.c
new file mode 100644
index 0000000..2982303
--- /dev/null
+++ b/clang/test/CodeGen/altivec.c
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+// Check initialization
+
+vector int test0 = (vector int)(1); // CHECK: @test0 = global <4 x i32> <i32 1, i32 1, i32 1, i32 1>
+vector float test1 = (vector float)(1.0); // CHECK: @test1 = global <4 x float> <float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}>
+
+// CHECK: @v1 = global <16 x i8> <i8 0, i8 0, i8 0, i8 1, i8 0, i8 0, i8 0, i8 2, i8 0, i8 0, i8 0, i8 3, i8 0, i8 0, i8 0, i8 4>
+vector char v1 = (vector char)((vector int)(1, 2, 3, 4));
+// CHECK: @v2 = global <16 x i8> <i8 63, i8 -128, i8 0, i8 0, i8 64, i8 0, i8 0, i8 0, i8 64, i8 64, i8 0, i8 0, i8 64, i8 -128, i8 0, i8 0>
+vector char v2 = (vector char)((vector float)(1.0f, 2.0f, 3.0f, 4.0f));
+// CHECK: @v3 = global <16 x i8> <i8 0, i8 0, i8 0, i8 97, i8 0, i8 0, i8 0, i8 98, i8 0, i8 0, i8 0, i8 99, i8 0, i8 0, i8 0, i8 100>
+vector char v3 = (vector char)((vector int)('a', 'b', 'c', 'd'));
+// CHECK: @v4 = global <4 x i32> <i32 16909060, i32 0, i32 0, i32 0>
+vector int v4 = (vector char){1, 2, 3, 4};
+
+void test2()
+{
+ vector int vi;
+ vector float vf;
+ vi = (vector int)(1); // CHECK: <i32 1, i32 1, i32 1, i32 1>
+ vf = (vector float)(1.0); // CHECK: <float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}>
+ vi = (vector int)(1, 2, 3, 4); // CHECK: <i32 1, i32 2, i32 3, i32 4>
+ vi = (vector int)(1, 2, 3, 4, 5); // CHECK: <i32 1, i32 2, i32 3, i32 4>
+
+ vi = (vector int){1}; // CHECK: <i32 1, i32 0, i32 0, i32 0>
+ vi = (vector int){1, 2}; // CHECK: <i32 1, i32 2, i32 0, i32 0>
+ vi = (vector int){1, 2, 3, 4}; // CHECK: <i32 1, i32 2, i32 3, i32 4>
+
+}
+
+// Check pre/post increment/decrement
+void test3() {
+ vector int vi;
+ vi++; // CHECK: add <4 x i32> {{.*}} <i32 1, i32 1, i32 1, i32 1>
+ vector unsigned int vui;
+ --vui; // CHECK: add <4 x i32> {{.*}} <i32 -1, i32 -1, i32 -1, i32 -1>
+ vector float vf;
+ vf++; // CHECK: fadd <4 x float> {{.*}} <float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}>
+}
diff --git a/clang/test/CodeGen/always-inline.c b/clang/test/CodeGen/always-inline.c
new file mode 100644
index 0000000..dc74be5
--- /dev/null
+++ b/clang/test/CodeGen/always-inline.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | grep call | not grep foo
+
+void bar() {
+}
+
+inline void __attribute__((__always_inline__)) foo() {
+ bar();
+}
+
+void i_want_bar() {
+ foo();
+}
diff --git a/clang/test/CodeGen/always_inline.c b/clang/test/CodeGen/always_inline.c
new file mode 100644
index 0000000..c91fd43
--- /dev/null
+++ b/clang/test/CodeGen/always_inline.c
@@ -0,0 +1,20 @@
+// RUN: %clang -emit-llvm -S -o %t %s
+// RUN: not grep '@f0' %t
+// RUN: not grep 'call ' %t
+// RUN: %clang -mllvm -disable-llvm-optzns -emit-llvm -S -o %t %s
+// RUN: grep '@f0' %t | count 2
+
+//static int f0() {
+static int __attribute__((always_inline)) f0() {
+ return 1;
+}
+
+int f1() {
+ return f0();
+}
+
+// PR4372
+inline int f2() __attribute__((always_inline));
+int f2() { return 7; }
+int f3(void) { return f2(); }
+
diff --git a/clang/test/CodeGen/annotations-builtin.c b/clang/test/CodeGen/annotations-builtin.c
new file mode 100644
index 0000000..42421a0
--- /dev/null
+++ b/clang/test/CodeGen/annotations-builtin.c
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// END.
+
+static long long llfoo;
+static int intfoo;
+static short shortfoo;
+static char charfoo;
+
+// CHECK: private unnamed_addr constant [13 x i8] {{.*}}annotation_a{{.*}} section "llvm.metadata"
+// CHECK-NOT: {{.*}}annotation_a{{.*}}
+
+static int foo(int a) {
+ return a + 1;
+}
+
+int main(int argc, char **argv) {
+ char barray[16];
+ char *b = (char *) __builtin_annotation((int)barray, "annotation_a");
+// CHECK: ptrtoint i8* {{.*}} to i32
+// CHECK-NEXT: call i32 @llvm.annotation.i32
+// CHECK: inttoptr {{.*}} to i8*
+
+ int call = __builtin_annotation(foo(argc), "annotation_a");
+// CHECK: call {{.*}} @foo
+// CHECK: call i32 @llvm.annotation.i32
+
+ long long lla = __builtin_annotation(llfoo, "annotation_a");
+// CHECK: trunc i64 {{.*}} to i32
+// CHECK-NEXT: call i32 @llvm.annotation.i32
+// CHECK-NEXT: zext i32 {{.*}} to i64
+
+ int inta = __builtin_annotation(intfoo, "annotation_a");
+// CHECK: load i32* @intfoo
+// CHECK-NEXT: call i32 @llvm.annotation.i32
+// CHECK-NEXT: store
+
+ short shorta = __builtin_annotation(shortfoo, "annotation_a");
+// CHECK: sext i16 {{.*}} to i32
+// CHECK-NEXT: call i32 @llvm.annotation.i32
+// CHECK-NEXT: trunc i32 {{.*}} to i16
+
+ char chara = __builtin_annotation(charfoo, "annotation_a");
+// CHECK: sext i8 {{.*}} to i32
+// CHECK-NEXT: call i32 @llvm.annotation.i32
+// CHECK-NEXT: trunc i32 {{.*}} to i8
+//
+ char **arg = (char**) __builtin_annotation((int) argv, "annotation_a");
+// CHECK: ptrtoint i8** {{.*}} to
+// CHECK: call i32 @llvm.annotation.i32
+// CHECK: inttoptr {{.*}} to i8**
+ return 0;
+}
diff --git a/clang/test/CodeGen/annotations-field.c b/clang/test/CodeGen/annotations-field.c
new file mode 100644
index 0000000..6b44367
--- /dev/null
+++ b/clang/test/CodeGen/annotations-field.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// END.
+
+// CHECK: private unnamed_addr constant [8 x i8] c"v_ann_{{.}}\00", section "llvm.metadata"
+// CHECK: private unnamed_addr constant [8 x i8] c"v_ann_{{.}}\00", section "llvm.metadata"
+
+struct foo {
+ int v __attribute__((annotate("v_ann_0"))) __attribute__((annotate("v_ann_1")));
+};
+
+static struct foo gf;
+
+int main(int argc, char **argv) {
+ struct foo f;
+ f.v = argc;
+// CHECK: getelementptr inbounds %struct.foo* %f, i32 0, i32 0
+// CHECK-NEXT: bitcast i32* {{.*}} to i8*
+// CHECK-NEXT: call i8* @llvm.ptr.annotation.p0i8({{.*}}str{{.*}}str{{.*}}i32 8)
+// CHECK-NEXT: bitcast i8* {{.*}} to i32*
+// CHECK-NEXT: bitcast i32* {{.*}} to i8*
+// CHECK-NEXT: call i8* @llvm.ptr.annotation.p0i8({{.*}}str{{.*}}str{{.*}}i32 8)
+// CHECK-NEXT: bitcast i8* {{.*}} to i32*
+ gf.v = argc;
+// CHECK: bitcast i32* getelementptr inbounds (%struct.foo* @gf, i32 0, i32 0) to i8*
+// CHECK-NEXT: call i8* @llvm.ptr.annotation.p0i8({{.*}}str{{.*}}str{{.*}}i32 8)
+ return 0;
+}
diff --git a/clang/test/CodeGen/annotations-global.c b/clang/test/CodeGen/annotations-global.c
new file mode 100644
index 0000000..2782525
--- /dev/null
+++ b/clang/test/CodeGen/annotations-global.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t1
+// RUN: FileCheck --check-prefix=FOO %s < %t1
+// RUN: FileCheck --check-prefix=A %s < %t1
+// RUN: FileCheck --check-prefix=BAR %s < %t1
+// RUN: FileCheck --check-prefix=FOOS %s < %t1
+// END.
+
+static __attribute((annotate("sfoo_0"))) __attribute((annotate("sfoo_1"))) char sfoo;
+__attribute((annotate("foo_0"))) __attribute((annotate("foo_1"))) char foo;
+
+void __attribute((annotate("ann_a_0"))) __attribute((annotate("ann_a_1"))) __attribute((annotate("ann_a_2"))) __attribute((annotate("ann_a_3"))) a(char *a);
+void __attribute((annotate("ann_a_0"))) __attribute((annotate("ann_a_1"))) a(char *a) {
+ __attribute__((annotate("bar_0"))) __attribute__((annotate("bar_1"))) static char bar;
+ sfoo = 0;
+}
+
+// FOOS: target triple
+// FOOS: private unnamed_addr constant [7 x i8] c"sfoo_{{.}}\00", section "llvm.metadata"
+// FOOS: private unnamed_addr constant [7 x i8] c"sfoo_{{.}}\00", section "llvm.metadata"
+// FOOS-NOT: sfoo_
+// FOOS: @llvm.global.annotations = appending global [10 x { i8*, i8*, i8*, i32 }] {{.*}}i8* @sfoo{{.*}}i8* @sfoo{{.*}}, section "llvm.metadata"
+
+// FOO: target triple
+// FOO: private unnamed_addr constant [6 x i8] c"foo_{{.}}\00", section "llvm.metadata"
+// FOO: private unnamed_addr constant [6 x i8] c"foo_{{.}}\00", section "llvm.metadata"
+// FOO-NOT: foo_
+// FOO: @llvm.global.annotations = appending global [10 x { i8*, i8*, i8*, i32 }] {{.*}}i8* @foo{{.*}}i8* @foo{{.*}}, section "llvm.metadata"
+
+// A: target triple
+// A: private unnamed_addr constant [8 x i8] c"ann_a_{{.}}\00", section "llvm.metadata"
+// A: private unnamed_addr constant [8 x i8] c"ann_a_{{.}}\00", section "llvm.metadata"
+// A: private unnamed_addr constant [8 x i8] c"ann_a_{{.}}\00", section "llvm.metadata"
+// A: private unnamed_addr constant [8 x i8] c"ann_a_{{.}}\00", section "llvm.metadata"
+// A-NOT: ann_a_
+// A: @llvm.global.annotations = appending global [10 x { i8*, i8*, i8*, i32 }] {{.*}}i8* bitcast (void (i8*)* @a to i8*){{.*}}i8* bitcast (void (i8*)* @a to i8*){{.*}}i8* bitcast (void (i8*)* @a to i8*){{.*}}i8* bitcast (void (i8*)* @a to i8*){{.*}}, section "llvm.metadata"
+
+// BAR: target triple
+// BAR: private unnamed_addr constant [6 x i8] c"bar_{{.}}\00", section "llvm.metadata"
+// BAR: private unnamed_addr constant [6 x i8] c"bar_{{.}}\00", section "llvm.metadata"
+// BAR-NOT: bar_
+// BAR: @llvm.global.annotations = appending global [10 x { i8*, i8*, i8*, i32 }] {{.*}}i8* @a.bar{{.*}}i8* @a.bar{{.*}}, section "llvm.metadata"
diff --git a/clang/test/CodeGen/annotations-loc.c b/clang/test/CodeGen/annotations-loc.c
new file mode 100644
index 0000000..4644f0e
--- /dev/null
+++ b/clang/test/CodeGen/annotations-loc.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// END.
+# 1 "t.c"
+# 1 "<built-in>"
+# 1 "<command-line>"
+# 1 "t.c"
+int __attribute((annotate("foo"))) foo(void) { return 0; }
+
+// CHECK: private unnamed_addr constant [4 x i8] c"t.c\00"
+// CHECK: @llvm.global.annotations = {{.*}}, i32 1 }
diff --git a/clang/test/CodeGen/annotations-var.c b/clang/test/CodeGen/annotations-var.c
new file mode 100644
index 0000000..b8ada9f
--- /dev/null
+++ b/clang/test/CodeGen/annotations-var.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t1 %s
+// RUN: FileCheck --check-prefix=LOCAL %s < %t1
+// RUN: FileCheck --check-prefix=UNDEF %s < %t1
+// RUN: FileCheck --check-prefix=PARAM %s < %t1
+// END.
+
+// LOCAL: private unnamed_addr constant [15 x i8] c"localvar_ann_{{.}}\00", section "llvm.metadata"
+// LOCAL: private unnamed_addr constant [15 x i8] c"localvar_ann_{{.}}\00", section "llvm.metadata"
+
+// UNDEF: private unnamed_addr constant [15 x i8] c"undefvar_ann_0\00", section "llvm.metadata"
+
+// PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata"
+// PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata"
+// PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata"
+// PARAM: private unnamed_addr constant [12 x i8] c"param_ann_{{.}}\00", section "llvm.metadata"
+
+int foo(int v __attribute__((annotate("param_ann_2"))) __attribute__((annotate("param_ann_3"))));
+int foo(int v __attribute__((annotate("param_ann_0"))) __attribute__((annotate("param_ann_1")))) {
+ return v + 1;
+// PARAM: define {{.*}}@foo
+// PARAM: [[V:%.*]] = alloca i32
+// PARAM: bitcast i32* [[V]] to i8*
+// PARAM-NEXT: call void @llvm.var.annotation(
+// PARAM-NEXT: bitcast i32* [[V]] to i8*
+// PARAM-NEXT: call void @llvm.var.annotation(
+// PARAM-NEXT: bitcast i32* [[V]] to i8*
+// PARAM-NEXT: call void @llvm.var.annotation(
+// PARAM-NEXT: bitcast i32* [[V]] to i8*
+// PARAM-NEXT: call void @llvm.var.annotation(
+}
+
+void local(void) {
+ int localvar __attribute__((annotate("localvar_ann_0"))) __attribute__((annotate("localvar_ann_1"))) = 3;
+// LOCAL: define void @local()
+// LOCAL: [[LOCALVAR:%.*]] = alloca i32,
+// LOCAL-NEXT: [[T0:%.*]] = bitcast i32* [[LOCALVAR]] to i8*
+// LOCAL-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr inbounds ([15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), i32 33)
+// LOCAL-NEXT: [[T0:%.*]] = bitcast i32* [[LOCALVAR]] to i8*
+// LOCAL-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr inbounds ([15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), i32 33)
+}
+
+void undef(void) {
+ int undefvar __attribute__((annotate("undefvar_ann_0")));
+// UNDEF: define void @undef()
+// UNDEF: [[UNDEFVAR:%.*]] = alloca i32,
+// UNDEF-NEXT: [[T0:%.*]] = bitcast i32* [[UNDEFVAR]] to i8*
+// UNDEF-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr inbounds ([15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), i32 43)
+}
diff --git a/clang/test/CodeGen/arm-aapcs-vfp.c b/clang/test/CodeGen/arm-aapcs-vfp.c
new file mode 100644
index 0000000..017c145
--- /dev/null
+++ b/clang/test/CodeGen/arm-aapcs-vfp.c
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -triple thumbv7-apple-darwin9 \
+// RUN: -target-abi aapcs \
+// RUN: -target-cpu cortex-a8 \
+// RUN: -mfloat-abi hard \
+// RUN: -ffreestanding \
+// RUN: -emit-llvm -w -o - %s | FileCheck %s
+
+#include <arm_neon.h>
+
+struct homogeneous_struct {
+ float f[2];
+ float f3;
+ float f4;
+};
+// CHECK: define arm_aapcs_vfpcc %struct.homogeneous_struct @test_struct(float %{{.*}}, float %{{.*}}, float %{{.*}}, float %{{.*}})
+extern struct homogeneous_struct struct_callee(struct homogeneous_struct);
+struct homogeneous_struct test_struct(struct homogeneous_struct arg) {
+ return struct_callee(arg);
+}
+
+struct nested_array {
+ double d[4];
+};
+// CHECK: define arm_aapcs_vfpcc void @test_array(double %{{.*}}, double %{{.*}}, double %{{.*}}, double %{{.*}})
+extern void array_callee(struct nested_array);
+void test_array(struct nested_array arg) {
+ array_callee(arg);
+}
+
+extern void complex_callee(__complex__ double);
+// CHECK: define arm_aapcs_vfpcc void @test_complex(double %{{.*}}, double %{{.*}})
+void test_complex(__complex__ double cd) {
+ complex_callee(cd);
+}
+
+// Structs with more than 4 elements of the base type are not treated
+// as homogeneous aggregates. Test that.
+
+struct big_struct {
+ float f1;
+ float f[2];
+ float f3;
+ float f4;
+};
+// CHECK: define arm_aapcs_vfpcc void @test_big([5 x i32] %{{.*}})
+extern void big_callee(struct big_struct);
+void test_big(struct big_struct arg) {
+ big_callee(arg);
+}
+
+// Make sure that aggregates with multiple base types are not treated as
+// homogeneous aggregates.
+
+struct heterogeneous_struct {
+ float f1;
+ int i2;
+};
+// CHECK: define arm_aapcs_vfpcc void @test_hetero([2 x i32] %{{.*}})
+extern void hetero_callee(struct heterogeneous_struct);
+void test_hetero(struct heterogeneous_struct arg) {
+ hetero_callee(arg);
+}
+
+// Neon multi-vector types are homogeneous aggregates.
+// CHECK: define arm_aapcs_vfpcc <16 x i8> @f0(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+int8x16_t f0(int8x16x4_t v4) {
+ return vaddq_s8(v4.val[0], v4.val[3]);
+}
+
+// ...and it doesn't matter whether the vectors are exactly the same, as long
+// as they have the same size.
+
+struct neon_struct {
+ int8x8x2_t v12;
+ int32x2_t v3;
+ int16x4_t v4;
+};
+// CHECK: define arm_aapcs_vfpcc void @test_neon(<8 x i8> %{{.*}}, <8 x i8> %{{.*}}, <2 x i32> %{{.*}}, <4 x i16> %{{.*}})
+extern void neon_callee(struct neon_struct);
+void test_neon(struct neon_struct arg) {
+ neon_callee(arg);
+}
diff --git a/clang/test/CodeGen/arm-aapcs-zerolength-bitfield.c b/clang/test/CodeGen/arm-aapcs-zerolength-bitfield.c
new file mode 100644
index 0000000..9fece19
--- /dev/null
+++ b/clang/test/CodeGen/arm-aapcs-zerolength-bitfield.c
@@ -0,0 +1,236 @@
+// RUN: %clang_cc1 -target-abi aapcs -triple armv7-apple-darwin10 %s -verify
+
+#include <stddef.h>
+
+struct t1
+{
+ int foo : 1;
+ char : 0;
+ char bar;
+};
+static int arr1_offset[(offsetof(struct t1, bar) == 1) ? 0 : -1];
+static int arr1_sizeof[(sizeof(struct t1) == 4) ? 0 : -1];
+
+struct t2
+{
+ int foo : 1;
+ short : 0;
+ char bar;
+};
+static int arr2_offset[(offsetof(struct t2, bar) == 2) ? 0 : -1];
+static int arr2_sizeof[(sizeof(struct t2) == 4) ? 0 : -1];
+
+struct t3
+{
+ int foo : 1;
+ int : 0;
+ char bar;
+};
+static int arr3_offset[(offsetof(struct t3, bar) == 4) ? 0 : -1];
+static int arr3_sizeof[(sizeof(struct t3) == 8) ? 0 : -1];
+
+struct t4
+{
+ int foo : 1;
+ long : 0;
+ char bar;
+};
+static int arr4_offset[(offsetof(struct t4, bar) == 4) ? 0 : -1];
+static int arr4_sizeof[(sizeof(struct t4) == 8) ? 0 : -1];
+
+struct t5
+{
+ int foo : 1;
+ long long : 0;
+ char bar;
+};
+static int arr5_offset[(offsetof(struct t5, bar) == 8) ? 0 : -1];
+static int arr5_sizeof[(sizeof(struct t5) == 16) ? 0 : -1];
+
+struct t6
+{
+ int foo : 1;
+ char : 0;
+ char bar : 1;
+ char bar2;
+};
+static int arr6_offset[(offsetof(struct t6, bar2) == 2) ? 0 : -1];
+static int arr6_sizeof[(sizeof(struct t6) == 4) ? 0 : -1];
+
+struct t7
+{
+ int foo : 1;
+ short : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr7_offset[(offsetof(struct t7, bar2) == 3) ? 0 : -1];
+static int arr7_sizeof[(sizeof(struct t7) == 4) ? 0 : -1];
+
+struct t8
+{
+ int foo : 1;
+ int : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr8_offset[(offsetof(struct t8, bar2) == 5) ? 0 : -1];
+static int arr8_sizeof[(sizeof(struct t8) == 8) ? 0 : -1];
+
+struct t9
+{
+ int foo : 1;
+ long : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr9_offset[(offsetof(struct t9, bar2) == 5) ? 0 : -1];
+static int arr9_sizeof[(sizeof(struct t9) == 8) ? 0 : -1];
+
+struct t10
+{
+ int foo : 1;
+ long long : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr10_offset[(offsetof(struct t10, bar2) == 9) ? 0 : -1];
+static int arr10_sizeof[(sizeof(struct t10) == 16) ? 0 : -1];
+
+struct t11
+{
+ int foo : 1;
+ long long : 0;
+ char : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr11_offset[(offsetof(struct t11, bar2) == 9) ? 0 : -1];
+static int arr11_sizeof[(sizeof(struct t11) == 16) ? 0 : -1];
+
+struct t12
+{
+ int foo : 1;
+ char : 0;
+ long long : 0;
+ char : 0;
+ char bar;
+};
+static int arr12_offset[(offsetof(struct t12, bar) == 8) ? 0 : -1];
+static int arr12_sizeof[(sizeof(struct t12) == 16) ? 0 : -1];
+
+struct t13
+{
+ char foo;
+ long : 0;
+ char bar;
+};
+static int arr13_offset[(offsetof(struct t13, bar) == 4) ? 0 : -1];
+static int arr13_sizeof[(sizeof(struct t13) == 8) ? 0 : -1];
+
+struct t14
+{
+ char foo1;
+ int : 0;
+ char foo2 : 1;
+ short foo3 : 16;
+ char : 0;
+ short foo4 : 16;
+ char bar1;
+ int : 0;
+ char bar2;
+};
+static int arr14_bar1_offset[(offsetof(struct t14, bar1) == 10) ? 0 : -1];
+static int arr14_bar2_offset[(offsetof(struct t14, bar2) == 12) ? 0 : -1];
+static int arr14_sizeof[(sizeof(struct t14) == 16) ? 0 : -1];
+
+struct t15
+{
+ char foo;
+ char : 0;
+ int : 0;
+ char bar;
+ long : 0;
+ char : 0;
+};
+static int arr15_offset[(offsetof(struct t15, bar) == 4) ? 0 : -1];
+static int arr15_sizeof[(sizeof(struct t15) == 8) ? 0 : -1];
+
+struct t16
+{
+ long : 0;
+ char bar;
+};
+static int arr16_offset[(offsetof(struct t16, bar) == 0) ? 0 : -1];
+static int arr16_sizeof[(sizeof(struct t16) == 4) ? 0 : -1];
+
+struct t17
+{
+ char foo;
+ long : 0;
+ long : 0;
+ char : 0;
+ char bar;
+};
+static int arr17_offset[(offsetof(struct t17, bar) == 4) ? 0 : -1];
+static int arr17_sizeof[(sizeof(struct t17) == 8) ? 0 : -1];
+
+struct t18
+{
+ long : 0;
+ long : 0;
+ char : 0;
+};
+static int arr18_sizeof[(sizeof(struct t18) == 0) ? 0 : -1];
+
+struct t19
+{
+ char foo1;
+ long foo2 : 1;
+ char : 0;
+ long foo3 : 32;
+ char bar;
+};
+static int arr19_offset[(offsetof(struct t19, bar) == 8) ? 0 : -1];
+static int arr19_sizeof[(sizeof(struct t19) == 12) ? 0 : -1];
+
+struct t20
+{
+ short : 0;
+ int foo : 1;
+ long : 0;
+ char bar;
+};
+static int arr20_offset[(offsetof(struct t20, bar) == 4) ? 0 : -1];
+static int arr20_sizeof[(sizeof(struct t20) == 8) ? 0 : -1];
+
+struct t21
+{
+ short : 0;
+ int foo1 : 1;
+ char : 0;
+ int foo2 : 16;
+ long : 0;
+ char bar1;
+ int bar2;
+ long bar3;
+ char foo3 : 8;
+ char : 0;
+ long : 0;
+ int foo4 : 32;
+ short foo5: 1;
+ long bar4;
+ short foo6: 16;
+ short foo7: 16;
+ short foo8: 16;
+};
+static int arr21_bar1_offset[(offsetof(struct t21, bar1) == 4) ? 0 : -1];
+static int arr21_bar2_offset[(offsetof(struct t21, bar2) == 8) ? 0 : -1];
+static int arr21_bar3_offset[(offsetof(struct t21, bar3) == 12) ? 0 : -1];
+static int arr21_bar4_offset[(offsetof(struct t21, bar4) == 28) ? 0 : -1];
+static int arr21_sizeof[(sizeof(struct t21) == 40) ? 0 : -1];
+
+int main() {
+ return 0;
+}
+
diff --git a/clang/test/CodeGen/arm-apcs-zerolength-bitfield.c b/clang/test/CodeGen/arm-apcs-zerolength-bitfield.c
new file mode 100644
index 0000000..3f94525
--- /dev/null
+++ b/clang/test/CodeGen/arm-apcs-zerolength-bitfield.c
@@ -0,0 +1,240 @@
+// RUN: %clang_cc1 -target-abi apcs-gnu -triple armv7-apple-darwin10 %s -verify
+//
+// Note: gcc forces the alignment to 4 bytes, regardless of the type of the
+// zero length bitfield.
+// rdar://9859156
+
+#include <stddef.h>
+
+struct t1
+{
+ int foo : 1;
+ char : 0;
+ char bar;
+};
+static int arr1_offset[(offsetof(struct t1, bar) == 4) ? 0 : -1];
+static int arr1_sizeof[(sizeof(struct t1) == 8) ? 0 : -1];
+
+struct t2
+{
+ int foo : 1;
+ short : 0;
+ char bar;
+};
+static int arr2_offset[(offsetof(struct t2, bar) == 4) ? 0 : -1];
+static int arr2_sizeof[(sizeof(struct t2) == 8) ? 0 : -1];
+
+struct t3
+{
+ int foo : 1;
+ int : 0;
+ char bar;
+};
+static int arr3_offset[(offsetof(struct t3, bar) == 4) ? 0 : -1];
+static int arr3_sizeof[(sizeof(struct t3) == 8) ? 0 : -1];
+
+struct t4
+{
+ int foo : 1;
+ long : 0;
+ char bar;
+};
+static int arr4_offset[(offsetof(struct t4, bar) == 4) ? 0 : -1];
+static int arr4_sizeof[(sizeof(struct t4) == 8) ? 0 : -1];
+
+struct t5
+{
+ int foo : 1;
+ long long : 0;
+ char bar;
+};
+static int arr5_offset[(offsetof(struct t5, bar) == 4) ? 0 : -1];
+static int arr5_sizeof[(sizeof(struct t5) == 8) ? 0 : -1];
+
+struct t6
+{
+ int foo : 1;
+ char : 0;
+ char bar : 1;
+ char bar2;
+};
+static int arr6_offset[(offsetof(struct t6, bar2) == 5) ? 0 : -1];
+static int arr6_sizeof[(sizeof(struct t6) == 8) ? 0 : -1];
+
+struct t7
+{
+ int foo : 1;
+ short : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr7_offset[(offsetof(struct t7, bar2) == 5) ? 0 : -1];
+static int arr7_sizeof[(sizeof(struct t7) == 8) ? 0 : -1];
+
+struct t8
+{
+ int foo : 1;
+ int : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr8_offset[(offsetof(struct t8, bar2) == 5) ? 0 : -1];
+static int arr8_sizeof[(sizeof(struct t8) == 8) ? 0 : -1];
+
+struct t9
+{
+ int foo : 1;
+ long : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr9_offset[(offsetof(struct t9, bar2) == 5) ? 0 : -1];
+static int arr9_sizeof[(sizeof(struct t9) == 8) ? 0 : -1];
+
+struct t10
+{
+ int foo : 1;
+ long long : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr10_offset[(offsetof(struct t10, bar2) == 5) ? 0 : -1];
+static int arr10_sizeof[(sizeof(struct t10) == 8) ? 0 : -1];
+
+struct t11
+{
+ int foo : 1;
+ long long : 0;
+ char : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr11_offset[(offsetof(struct t11, bar2) == 5) ? 0 : -1];
+static int arr11_sizeof[(sizeof(struct t11) == 8) ? 0 : -1];
+
+struct t12
+{
+ int foo : 1;
+ char : 0;
+ long long : 0;
+ char : 0;
+ char bar;
+};
+static int arr12_offset[(offsetof(struct t12, bar) == 4) ? 0 : -1];
+static int arr12_sizeof[(sizeof(struct t12) == 8) ? 0 : -1];
+
+struct t13
+{
+ char foo;
+ long : 0;
+ char bar;
+};
+static int arr13_offset[(offsetof(struct t13, bar) == 4) ? 0 : -1];
+static int arr13_sizeof[(sizeof(struct t13) == 8) ? 0 : -1];
+
+struct t14
+{
+ char foo1;
+ int : 0;
+ char foo2 : 1;
+ short foo3 : 16;
+ char : 0;
+ short foo4 : 16;
+ char bar1;
+ int : 0;
+ char bar2;
+};
+static int arr14_bar1_offset[(offsetof(struct t14, bar1) == 10) ? 0 : -1];
+static int arr14_bar2_offset[(offsetof(struct t14, bar2) == 12) ? 0 : -1];
+static int arr14_sizeof[(sizeof(struct t14) == 16) ? 0 : -1];
+
+struct t15
+{
+ char foo;
+ char : 0;
+ int : 0;
+ char bar;
+ long : 0;
+ char : 0;
+};
+static int arr15_offset[(offsetof(struct t15, bar) == 4) ? 0 : -1];
+static int arr15_sizeof[(sizeof(struct t15) == 8) ? 0 : -1];
+
+struct t16
+{
+ long : 0;
+ char bar;
+};
+static int arr16_offset[(offsetof(struct t16, bar) == 0) ? 0 : -1];
+static int arr16_sizeof[(sizeof(struct t16) == 4) ? 0 : -1];
+
+struct t17
+{
+ char foo;
+ long : 0;
+ long : 0;
+ char : 0;
+ char bar;
+};
+static int arr17_offset[(offsetof(struct t17, bar) == 4) ? 0 : -1];
+static int arr17_sizeof[(sizeof(struct t17) == 8) ? 0 : -1];
+
+struct t18
+{
+ long : 0;
+ long : 0;
+ char : 0;
+};
+static int arr18_sizeof[(sizeof(struct t18) == 0) ? 0 : -1];
+
+struct t19
+{
+ char foo1;
+ long foo2 : 1;
+ char : 0;
+ long foo3 : 32;
+ char bar;
+};
+static int arr19_offset[(offsetof(struct t19, bar) == 8) ? 0 : -1];
+static int arr19_sizeof[(sizeof(struct t19) == 12) ? 0 : -1];
+
+struct t20
+{
+ short : 0;
+ int foo : 1;
+ long : 0;
+ char bar;
+};
+static int arr20_offset[(offsetof(struct t20, bar) == 4) ? 0 : -1];
+static int arr20_sizeof[(sizeof(struct t20) == 8) ? 0 : -1];
+
+struct t21
+{
+ short : 0;
+ int foo1 : 1;
+ char : 0;
+ int foo2 : 16;
+ long : 0;
+ char bar1;
+ int bar2;
+ long bar3;
+ char foo3 : 8;
+ char : 0;
+ long : 0;
+ int foo4 : 32;
+ short foo5: 1;
+ long bar4;
+ short foo6: 16;
+ short foo7: 16;
+ short foo8: 16;
+};
+static int arr21_bar1_offset[(offsetof(struct t21, bar1) == 8) ? 0 : -1];
+static int arr21_bar2_offset[(offsetof(struct t21, bar2) == 12) ? 0 : -1];
+static int arr21_bar3_offset[(offsetof(struct t21, bar3) == 16) ? 0 : -1];
+static int arr21_bar4_offset[(offsetof(struct t21, bar4) == 32) ? 0 : -1];
+static int arr21_sizeof[(sizeof(struct t21) == 44) ? 0 : -1];
+
+int main() {
+ return 0;
+}
+
diff --git a/clang/test/CodeGen/arm-arguments.c b/clang/test/CodeGen/arm-arguments.c
new file mode 100644
index 0000000..4686d4a
--- /dev/null
+++ b/clang/test/CodeGen/arm-arguments.c
@@ -0,0 +1,167 @@
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi apcs-gnu -emit-llvm -w -o - %s | FileCheck -check-prefix=APCS-GNU %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi aapcs -emit-llvm -w -o - %s | FileCheck -check-prefix=AAPCS %s
+
+// APCS-GNU: define signext i8 @f0()
+// AAPCS: define arm_aapcscc signext i8 @f0()
+char f0(void) {
+ return 0;
+}
+
+// APCS-GNU: define i8 @f1()
+// AAPCS: define arm_aapcscc i8 @f1()
+struct s1 { char f0; };
+struct s1 f1(void) {}
+
+// APCS-GNU: define i16 @f2()
+// AAPCS: define arm_aapcscc i16 @f2()
+struct s2 { short f0; };
+struct s2 f2(void) {}
+
+// APCS-GNU: define i32 @f3()
+// AAPCS: define arm_aapcscc i32 @f3()
+struct s3 { int f0; };
+struct s3 f3(void) {}
+
+// APCS-GNU: define i32 @f4()
+// AAPCS: define arm_aapcscc i32 @f4()
+struct s4 { struct s4_0 { int f0; } f0; };
+struct s4 f4(void) {}
+
+// APCS-GNU: define void @f5(
+// APCS-GNU: struct.s5* noalias sret
+// AAPCS: define arm_aapcscc i32 @f5()
+struct s5 { struct { } f0; int f1; };
+struct s5 f5(void) {}
+
+// APCS-GNU: define void @f6(
+// APCS-GNU: struct.s6* noalias sret
+// AAPCS: define arm_aapcscc i32 @f6()
+struct s6 { int f0[1]; };
+struct s6 f6(void) {}
+
+// APCS-GNU: define void @f7()
+// AAPCS: define arm_aapcscc void @f7()
+struct s7 { struct { int : 0; } f0; };
+struct s7 f7(void) {}
+
+// APCS-GNU: define void @f8(
+// APCS-GNU: struct.s8* noalias sret
+// AAPCS: define arm_aapcscc void @f8()
+struct s8 { struct { int : 0; } f0[1]; };
+struct s8 f8(void) {}
+
+// APCS-GNU: define i32 @f9()
+// AAPCS: define arm_aapcscc i32 @f9()
+struct s9 { int f0; int : 0; };
+struct s9 f9(void) {}
+
+// APCS-GNU: define i32 @f10()
+// AAPCS: define arm_aapcscc i32 @f10()
+struct s10 { int f0; int : 0; int : 0; };
+struct s10 f10(void) {}
+
+// APCS-GNU: define void @f11(
+// APCS-GNU: struct.s11* noalias sret
+// AAPCS: define arm_aapcscc i32 @f11()
+struct s11 { int : 0; int f0; };
+struct s11 f11(void) {}
+
+// APCS-GNU: define i32 @f12()
+// AAPCS: define arm_aapcscc i32 @f12()
+union u12 { char f0; short f1; int f2; };
+union u12 f12(void) {}
+
+// APCS-GNU: define void @f13(
+// APCS-GNU: struct.s13* noalias sret
+
+// FIXME: This should return a float.
+// AAPCS-FIXME: darm_aapcscc efine float @f13()
+struct s13 { float f0; };
+struct s13 f13(void) {}
+
+// APCS-GNU: define void @f14(
+// APCS-GNU: union.u14* noalias sret
+// AAPCS: define arm_aapcscc i32 @f14()
+union u14 { float f0; };
+union u14 f14(void) {}
+
+// APCS-GNU: define void @f15()
+// AAPCS: define arm_aapcscc void @f15()
+void f15(struct s7 a0) {}
+
+// APCS-GNU: define void @f16()
+// AAPCS: define arm_aapcscc void @f16()
+void f16(struct s8 a0) {}
+
+// APCS-GNU: define i32 @f17()
+// AAPCS: define arm_aapcscc i32 @f17()
+struct s17 { short f0 : 13; char f1 : 4; };
+struct s17 f17(void) {}
+
+// APCS-GNU: define i32 @f18()
+// AAPCS: define arm_aapcscc i32 @f18()
+struct s18 { short f0; char f1 : 4; };
+struct s18 f18(void) {}
+
+// APCS-GNU: define void @f19(
+// APCS-GNU: struct.s19* noalias sret
+// AAPCS: define arm_aapcscc i32 @f19()
+struct s19 { int f0; struct s8 f1; };
+struct s19 f19(void) {}
+
+// APCS-GNU: define void @f20(
+// APCS-GNU: struct.s20* noalias sret
+// AAPCS: define arm_aapcscc i32 @f20()
+struct s20 { struct s8 f1; int f0; };
+struct s20 f20(void) {}
+
+// APCS-GNU: define i8 @f21()
+// AAPCS: define arm_aapcscc i32 @f21()
+struct s21 { struct {} f1; int f0 : 4; };
+struct s21 f21(void) {}
+
+// APCS-GNU: define i16 @f22()
+// APCS-GNU: define i32 @f23()
+// APCS-GNU: define i64 @f24()
+// APCS-GNU: define i128 @f25()
+// APCS-GNU: define i64 @f26()
+// APCS-GNU: define i128 @f27()
+// AAPCS: define arm_aapcscc i16 @f22()
+// AAPCS: define arm_aapcscc i32 @f23()
+// AAPCS: define arm_aapcscc void @f24({{.*}} noalias sret
+// AAPCS: define arm_aapcscc void @f25({{.*}} noalias sret
+// AAPCS: define arm_aapcscc void @f26({{.*}} noalias sret
+// AAPCS: define arm_aapcscc void @f27({{.*}} noalias sret
+_Complex char f22(void) {}
+_Complex short f23(void) {}
+_Complex int f24(void) {}
+_Complex long long f25(void) {}
+_Complex float f26(void) {}
+_Complex double f27(void) {}
+
+// APCS-GNU: define i16 @f28()
+// AAPCS: define arm_aapcscc i16 @f28()
+struct s28 { _Complex char f0; };
+struct s28 f28() {}
+
+// APCS-GNU: define i32 @f29()
+// AAPCS: define arm_aapcscc i32 @f29()
+struct s29 { _Complex short f0; };
+struct s29 f29() {}
+
+// APCS-GNU: define void @f30({{.*}} noalias sret
+// AAPCS: define arm_aapcscc void @f30({{.*}} noalias sret
+struct s30 { _Complex int f0; };
+struct s30 f30() {}
+
+// PR11905
+struct s31 { char x; };
+void f31(struct s31 s) { }
+// AAPCS: @f31([1 x i32] %s.coerce)
+// AAPCS: %s = alloca %struct.s31, align 4
+// AAPCS: alloca [1 x i32]
+// AAPCS: store [1 x i32] %s.coerce, [1 x i32]*
+// APCS-GNU: @f31([1 x i32] %s.coerce)
+// APCS-GNU: %s = alloca %struct.s31, align 4
+// APCS-GNU: alloca [1 x i32]
+// APCS-GNU: store [1 x i32] %s.coerce, [1 x i32]*
diff --git a/clang/test/CodeGen/arm-asm-variable.c b/clang/test/CodeGen/arm-asm-variable.c
new file mode 100644
index 0000000..865d197
--- /dev/null
+++ b/clang/test/CodeGen/arm-asm-variable.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s
+
+typedef long long int64_t;
+typedef unsigned int uint32_t;
+
+int64_t foo(int64_t v, volatile int64_t *p)
+{
+ register uint32_t rl asm("r1");
+ register uint32_t rh asm("r2");
+
+ int64_t r;
+ uint32_t t;
+
+ __asm__ __volatile__( \
+ "ldrexd%[_rl], %[_rh], [%[_p]]" \
+ : [_rl] "=&r" (rl), [_rh] "=&r" (rh) \
+ : [_p] "p" (p) : "memory");
+
+ // CHECK: call { i32, i32 } asm sideeffect "ldrexd$0, $1, [$2]", "={r1},={r2},r,~{memory}"(i64*
+
+ return r;
+}
+
+// Make sure we translate register names properly.
+void bar (void) {
+ register unsigned int rn asm("r14");
+ register unsigned int d asm("r2");
+
+ // CHECK: call i32 asm sideeffect "sub $1, $1, #32", "={r2},{lr}"
+ asm volatile ("sub %1, %1, #32" : "=r"(d) : "r"(rn));
+}
diff --git a/clang/test/CodeGen/arm-asm.c b/clang/test/CodeGen/arm-asm.c
new file mode 100644
index 0000000..9b1082a
--- /dev/null
+++ b/clang/test/CodeGen/arm-asm.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple thumb %s -emit-llvm -o - | FileCheck %s
+int t1() {
+ static float k = 1.0f;
+ // CHECK: flds s15
+ __asm__ volatile ("flds s15, %[k] \n" :: [k] "Uv" (k) : "s15");
+ return 0;
+}
diff --git a/clang/test/CodeGen/arm-cc.c b/clang/test/CodeGen/arm-cc.c
new file mode 100644
index 0000000..74eecc7
--- /dev/null
+++ b/clang/test/CodeGen/arm-cc.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi apcs-gnu -emit-llvm -w -o - %s | FileCheck -check-prefix=DARWIN-APCS %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi aapcs -emit-llvm -w -o - %s | FileCheck -check-prefix=DARWIN-AAPCS %s
+// RUN: %clang_cc1 -triple arm-none-linux-gnueabi -target-abi apcs-gnu -emit-llvm -w -o - %s | FileCheck -check-prefix=LINUX-APCS %s
+// RUN: %clang_cc1 -triple arm-none-linux-gnueabi -target-abi aapcs -emit-llvm -w -o - %s | FileCheck -check-prefix=LINUX-AAPCS %s
+
+
+// DARWIN-APCS: define void @f()
+// DARWIN-APCS: call void @g
+// DARWIN-AAPCS: define arm_aapcscc void @f()
+// DARWIN-AAPCS: call arm_aapcscc void @g
+// LINUX-APCS: define arm_apcscc void @f()
+// LINUX-APCS: call arm_apcscc void @g
+// LINUX-AAPCS: define void @f()
+// LINUX-AAPCS: call void @g
+void g(void);
+void f(void) {
+ g();
+}
diff --git a/clang/test/CodeGen/arm-clear.c b/clang/test/CodeGen/arm-clear.c
new file mode 100644
index 0000000..eda64ce
--- /dev/null
+++ b/clang/test/CodeGen/arm-clear.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s
+
+void clear0(void *ptr) {
+ // CHECK: clear0
+ // CHECK-NOT: load i8**
+ __clear_cache();
+}
+
+void clear1(void *ptr) {
+ // CHECK: clear1
+ // CHECK: load i8**
+ // CHECK-NOT: load i8**
+ __clear_cache(ptr);
+}
+
+void clear2(void *ptr, void *ptr2) {
+ // CHECK: clear2
+ // CHECK: load i8**
+ // CHECK: load i8**
+ __clear_cache(ptr, ptr2);
+}
diff --git a/clang/test/CodeGen/arm-homogenous.c b/clang/test/CodeGen/arm-homogenous.c
new file mode 100644
index 0000000..eb3d5a6
--- /dev/null
+++ b/clang/test/CodeGen/arm-homogenous.c
@@ -0,0 +1,160 @@
+// RUN: %clang_cc1 -triple armv7---eabi -target-abi aapcs -mfloat-abi hard -emit-llvm %s -o - | FileCheck %s
+
+typedef long long int64_t;
+typedef unsigned int uint32_t;
+
+/* This is not a homogenous aggregate - fundamental types are different */
+typedef union {
+ float f[4];
+ uint32_t i[4];
+} union_with_first_floats;
+union_with_first_floats g_u_f;
+
+extern void takes_union_with_first_floats(union_with_first_floats a);
+extern union_with_first_floats returns_union_with_first_floats(void);
+
+void test_union_with_first_floats(void) {
+ takes_union_with_first_floats(g_u_f);
+}
+// CHECK: declare arm_aapcs_vfpcc void @takes_union_with_first_floats([4 x i32])
+
+void test_return_union_with_first_floats(void) {
+ g_u_f = returns_union_with_first_floats();
+}
+// CHECK: declare arm_aapcs_vfpcc void @returns_union_with_first_floats(%union.union_with_first_floats* sret)
+
+/* This is not a homogenous aggregate - fundamental types are different */
+typedef union {
+ uint32_t i[4];
+ float f[4];
+} union_with_non_first_floats;
+union_with_non_first_floats g_u_nf_f;
+
+extern void takes_union_with_non_first_floats(union_with_non_first_floats a);
+extern union_with_non_first_floats returns_union_with_non_first_floats(void);
+
+void test_union_with_non_first_floats(void) {
+ takes_union_with_non_first_floats(g_u_nf_f);
+}
+// CHECK: declare arm_aapcs_vfpcc void @takes_union_with_non_first_floats([4 x i32])
+
+void test_return_union_with_non_first_floats(void) {
+ g_u_nf_f = returns_union_with_non_first_floats();
+}
+// CHECK: declare arm_aapcs_vfpcc void @returns_union_with_non_first_floats(%union.union_with_non_first_floats* sret)
+
+/* This is not a homogenous aggregate - fundamental types are different */
+typedef struct {
+ float a;
+ union_with_first_floats b;
+} struct_with_union_with_first_floats;
+struct_with_union_with_first_floats g_s_f;
+
+extern void takes_struct_with_union_with_first_floats(struct_with_union_with_first_floats a);
+extern struct_with_union_with_first_floats returns_struct_with_union_with_first_floats(void);
+
+void test_struct_with_union_with_first_floats(void) {
+ takes_struct_with_union_with_first_floats(g_s_f);
+}
+// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_union_with_first_floats([5 x i32])
+
+void test_return_struct_with_union_with_first_floats(void) {
+ g_s_f = returns_struct_with_union_with_first_floats();
+}
+// CHECK: declare arm_aapcs_vfpcc void @returns_struct_with_union_with_first_floats(%struct.struct_with_union_with_first_floats* sret)
+
+/* This is not a homogenous aggregate - fundamental types are different */
+typedef struct {
+ float a;
+ union_with_non_first_floats b;
+} struct_with_union_with_non_first_floats;
+struct_with_union_with_non_first_floats g_s_nf_f;
+
+extern void takes_struct_with_union_with_non_first_floats(struct_with_union_with_non_first_floats a);
+extern struct_with_union_with_non_first_floats returns_struct_with_union_with_non_first_floats(void);
+
+void test_struct_with_union_with_non_first_floats(void) {
+ takes_struct_with_union_with_non_first_floats(g_s_nf_f);
+}
+// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_union_with_non_first_floats([5 x i32])
+
+void test_return_struct_with_union_with_non_first_floats(void) {
+ g_s_nf_f = returns_struct_with_union_with_non_first_floats();
+}
+// CHECK: declare arm_aapcs_vfpcc void @returns_struct_with_union_with_non_first_floats(%struct.struct_with_union_with_non_first_floats* sret)
+
+/* Plain array is not a homogenous aggregate */
+extern void takes_array_of_floats(float a[4]);
+void test_array_of_floats(void) {
+ float a[4] = {1.0, 2.0, 3.0, 4.0};
+ takes_array_of_floats(a);
+}
+// CHECK: declare arm_aapcs_vfpcc void @takes_array_of_floats(float*)
+
+/* Struct-type homogenous aggregate */
+typedef struct {
+ float x, y, z, w;
+} struct_with_fundamental_elems;
+struct_with_fundamental_elems g_s;
+
+extern void takes_struct_with_fundamental_elems(struct_with_fundamental_elems a);
+extern struct_with_fundamental_elems returns_struct_with_fundamental_elems(void);
+
+void test_struct_with_fundamental_elems(void) {
+ takes_struct_with_fundamental_elems(g_s);
+// CHECK: call arm_aapcs_vfpcc void @takes_struct_with_fundamental_elems(float {{.*}}, float {{.*}}, float{{.*}}, float {{.*}})
+}
+// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_fundamental_elems(float, float, float, float)
+
+void test_return_struct_with_fundamental_elems(void) {
+ g_s = returns_struct_with_fundamental_elems();
+// CHECK: call arm_aapcs_vfpcc %struct.struct_with_fundamental_elems @returns_struct_with_fundamental_elems()
+}
+// CHECK: declare arm_aapcs_vfpcc %struct.struct_with_fundamental_elems @returns_struct_with_fundamental_elems()
+
+/* Array-type homogenous aggregate */
+typedef struct {
+ float xyzw[4];
+} struct_with_array;
+struct_with_array g_s_a;
+
+extern void takes_struct_with_array(struct_with_array a);
+extern struct_with_array returns_struct_with_array(void);
+
+void test_struct_with_array(void) {
+ takes_struct_with_array(g_s_a);
+// CHECK: call arm_aapcs_vfpcc void @takes_struct_with_array(float {{.*}}, float {{.*}}, float {{.*}}, float {{.*}})
+}
+// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_array(float, float, float, float)
+
+void test_return_struct_with_array(void) {
+ g_s_a = returns_struct_with_array();
+// CHECK: call arm_aapcs_vfpcc %struct.struct_with_array @returns_struct_with_array()
+}
+// CHECK: declare arm_aapcs_vfpcc %struct.struct_with_array @returns_struct_with_array()
+
+/* This union is a homogenous aggregate. Check that it's passed properly */
+typedef union {
+ struct_with_fundamental_elems xyzw;
+ float a[3];
+} union_with_struct_with_fundamental_elems;
+union_with_struct_with_fundamental_elems g_u_s_fe;
+
+extern void takes_union_with_struct_with_fundamental_elems(union_with_struct_with_fundamental_elems a);
+extern union_with_struct_with_fundamental_elems returns_union_with_struct_with_fundamental_elems(void);
+
+void test_union_with_struct_with_fundamental_elems(void) {
+ takes_union_with_struct_with_fundamental_elems(g_u_s_fe);
+// CHECK: call arm_aapcs_vfpcc void @takes_union_with_struct_with_fundamental_elems(float {{.*}}, float {{.*}}, float {{.*}}, float {{.*}})
+}
+// CHECK: declare arm_aapcs_vfpcc void @takes_union_with_struct_with_fundamental_elems(float, float, float, float)
+
+void test_return_union_with_struct_with_fundamental_elems(void) {
+ g_u_s_fe = returns_union_with_struct_with_fundamental_elems();
+// CHECK: call arm_aapcs_vfpcc %union.union_with_struct_with_fundamental_elems @returns_union_with_struct_with_fundamental_elems()
+}
+// CHECK: declare arm_aapcs_vfpcc %union.union_with_struct_with_fundamental_elems @returns_union_with_struct_with_fundamental_elems()
+
+// FIXME: Tests necessary:
+// - Vectors
+// - C++ stuff \ No newline at end of file
diff --git a/clang/test/CodeGen/arm-inline-asm.c b/clang/test/CodeGen/arm-inline-asm.c
new file mode 100644
index 0000000..0152b05
--- /dev/null
+++ b/clang/test/CodeGen/arm-inline-asm.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s
+
+void t1 (void *f, int g) {
+ // CHECK: call void asm "str $1, $0", "=*Q,r"
+ asm("str %1, %0" : "=Q"(f) : "r"(g));
+}
diff --git a/clang/test/CodeGen/arm-pcs.c b/clang/test/CodeGen/arm-pcs.c
new file mode 100644
index 0000000..d722f84
--- /dev/null
+++ b/clang/test/CodeGen/arm-pcs.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple arm-none-linux-gnueabi -emit-llvm -w -o - < %s | FileCheck %s
+typedef int __attribute__((pcs("aapcs"))) (*aapcs_fn)(void);
+typedef int __attribute__((pcs("aapcs-vfp"))) (*aapcs_vfp_fn)(void);
+
+aapcs_fn bar;
+
+int foo(aapcs_vfp_fn baz) {
+// CHECK: define i32 @foo
+// CHECK: call arm_aapcscc
+// CHECK: call arm_aapcs_vfpcc
+ return bar() + baz();
+}
diff --git a/clang/test/CodeGen/arm-vaarg-align.c b/clang/test/CodeGen/arm-vaarg-align.c
new file mode 100644
index 0000000..1187c02
--- /dev/null
+++ b/clang/test/CodeGen/arm-vaarg-align.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple arm -target-abi aapcs %s -emit-llvm -o - | FileCheck -check-prefix=AAPCS %s
+// RUN: %clang_cc1 -triple arm -target-abi apcs-gnu %s -emit-llvm -o - | FileCheck -check-prefix=APCS-GNU %s
+/*
+ * Check that va_arg accesses stack according to ABI alignment
+ * long long and double require 8-byte alignment under AAPCS
+ * however, they only require 4-byte alignment under APCS
+ */
+long long t1(int i, ...) {
+ // AAPCS: t1
+ // APCS-GNU: t1
+ __builtin_va_list ap;
+ __builtin_va_start(ap, i);
+ // AAPCS: add i32 %{{.*}} 7
+ // AAPCS: and i32 %{{.*}} -8
+ // APCS-GNU-NOT: add i32 %{{.*}} 7
+ // APCS-GNU-NOT: and i32 %{{.*}} -8
+ long long ll = __builtin_va_arg(ap, long long);
+ __builtin_va_end(ap);
+ return ll;
+}
+double t2(int i, ...) {
+ // AAPCS: t2
+ // APCS-GNU: t2
+ __builtin_va_list ap;
+ __builtin_va_start(ap, i);
+ // AAPCS: add i32 %{{.*}} 7
+ // AAPCS: and i32 %{{.*}} -8
+ // APCS-GNU-NOT: add i32 %{{.*}} 7
+ // APCS-GNU-NOT: and i32 %{{.*}} -8
+ double ll = __builtin_va_arg(ap, double);
+ __builtin_va_end(ap);
+ return ll;
+}
diff --git a/clang/test/CodeGen/arm-vector-align.c b/clang/test/CodeGen/arm-vector-align.c
new file mode 100644
index 0000000..b481a0c
--- /dev/null
+++ b/clang/test/CodeGen/arm-vector-align.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple thumbv7-apple-darwin \
+// RUN: -target-abi apcs-gnu \
+// RUN: -target-cpu cortex-a8 \
+// RUN: -mfloat-abi soft \
+// RUN: -target-feature +soft-float-abi \
+// RUN: -ffreestanding \
+// RUN: -emit-llvm -w -o - %s | FileCheck %s
+
+#include <arm_neon.h>
+
+// Radar 9311427: Check that alignment specifier is used in Neon load/store
+// intrinsics.
+typedef float AlignedAddr __attribute__ ((aligned (16)));
+void t1(AlignedAddr *addr1, AlignedAddr *addr2) {
+// CHECK: @t1
+// CHECK: call <4 x float> @llvm.arm.neon.vld1.v4f32(i8* %{{.*}}, i32 16)
+ float32x4_t a = vld1q_f32(addr1);
+// CHECK: call void @llvm.arm.neon.vst1.v4f32(i8* %{{.*}}, <4 x float> %{{.*}}, i32 16)
+ vst1q_f32(addr2, a);
+}
+
+// Radar 10538555: Make sure unaligned load/stores do not gain alignment.
+void t2(char *addr) {
+// CHECK: @t2
+// CHECK: load i32* %{{.*}}, align 1
+ int32x2_t vec = vld1_dup_s32(addr);
+// CHECK: store i32 %{{.*}}, i32* {{.*}}, align 1
+ vst1_lane_s32(addr, vec, 1);
+}
diff --git a/clang/test/CodeGen/arm-vector-arguments.c b/clang/test/CodeGen/arm-vector-arguments.c
new file mode 100644
index 0000000..6bfb2f4
--- /dev/null
+++ b/clang/test/CodeGen/arm-vector-arguments.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple thumbv7-apple-darwin9 \
+// RUN: -target-abi apcs-gnu \
+// RUN: -target-cpu cortex-a8 \
+// RUN: -mfloat-abi soft \
+// RUN: -target-feature +soft-float-abi \
+// RUN: -ffreestanding \
+// RUN: -emit-llvm -w -o - %s | FileCheck %s
+
+#include <arm_neon.h>
+
+// CHECK: define void @f0(%struct.int8x16x2_t* noalias sret %agg.result, <16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+int8x16x2_t f0(int8x16_t a0, int8x16_t a1) {
+ return vzipq_s8(a0, a1);
+}
+
+// Test direct vector passing.
+
+typedef float T_float32x2 __attribute__ ((__vector_size__ (8)));
+typedef float T_float32x4 __attribute__ ((__vector_size__ (16)));
+typedef float T_float32x8 __attribute__ ((__vector_size__ (32)));
+typedef float T_float32x16 __attribute__ ((__vector_size__ (64)));
+
+// CHECK: define <2 x float> @f1_0(<2 x float> %{{.*}})
+T_float32x2 f1_0(T_float32x2 a0) { return a0; }
+// CHECK: define <4 x float> @f1_1(<4 x float> %{{.*}})
+T_float32x4 f1_1(T_float32x4 a0) { return a0; }
+// CHECK: define void @f1_2(<8 x float>* noalias sret %{{.*}}, <8 x float> %{{.*}})
+T_float32x8 f1_2(T_float32x8 a0) { return a0; }
+// CHECK: define void @f1_3(<16 x float>* noalias sret %{{.*}}, <16 x float> %{{.*}})
+T_float32x16 f1_3(T_float32x16 a0) { return a0; }
diff --git a/clang/test/CodeGen/array.c b/clang/test/CodeGen/array.c
new file mode 100644
index 0000000..0b401ea
--- /dev/null
+++ b/clang/test/CodeGen/array.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+void f() {
+ int a[2];
+ a[0] = 0;
+}
+
+void f2() {
+ int x = 0;
+ int y = 1;
+ int a[10] = { y, x, 2, 3};
+ int b[10] = { 2,4,x,6,y,8};
+ int c[5] = { 0,1,2,3};
+}
diff --git a/clang/test/CodeGen/arrayderef.c b/clang/test/CodeGen/arrayderef.c
new file mode 100644
index 0000000..effc0a6
--- /dev/null
+++ b/clang/test/CodeGen/arrayderef.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -emit-llvm -O1 -o - | FileCheck %s
+// The load here was getting lost because this code was close
+// enough to the traditional (wrong) implementation of offsetof
+// to confuse the gcc FE. 8629268.
+
+struct foo {
+ int x;
+ int *y;
+};
+
+struct foo Foo[1];
+
+int * bar(unsigned int ix) {
+// CHECK: load
+ return &Foo->y[ix];
+}
diff --git a/clang/test/CodeGen/asm-errors.c b/clang/test/CodeGen/asm-errors.c
new file mode 100644
index 0000000..438c82b
--- /dev/null
+++ b/clang/test/CodeGen/asm-errors.c
@@ -0,0 +1,11 @@
+// REQUIRES: x86-registered-target
+
+// RUN: true
+// UN: not %clang_cc1 -triple i386-apple-darwin10 -emit-obj %s -o /dev/null > %t 2>&1
+// UN: FileCheck %s < %t
+
+int test1(int X) {
+// CHECK: error: invalid instruction mnemonic 'abc'
+ __asm__ ("abc incl %0" : "+r" (X));
+ return X;
+}
diff --git a/clang/test/CodeGen/asm-inout.c b/clang/test/CodeGen/asm-inout.c
new file mode 100644
index 0000000..c7d1aec
--- /dev/null
+++ b/clang/test/CodeGen/asm-inout.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// PR3800
+int *foo(void);
+
+// CHECK: @test1
+void test1() {
+ // CHECK: [[REGCALLRESULT:%[a-zA-Z0-9\.]+]] = call i32* @foo()
+ // CHECK: call void asm "foobar", "=*m,*m,~{dirflag},~{fpsr},~{flags}"(i32* [[REGCALLRESULT]], i32* [[REGCALLRESULT]])
+ asm ("foobar" : "+m"(*foo()));
+}
+
+// CHECK: @test2
+void test2() {
+ // CHECK: [[REGCALLRESULT:%[a-zA-Z0-9\.]+]] = call i32* @foo()
+ // CHECK: load i32* [[REGCALLRESULT]]
+ // CHECK: call i32 asm
+ // CHECK: store i32 {{%[a-zA-Z0-9\.]+}}, i32* [[REGCALLRESULT]]
+ asm ("foobar" : "+r"(*foo()));
+}
+
+// PR7338
+// CHECK: @test3
+void test3(int *vout, int vin)
+{
+ // CHECK: call void asm "opr $0,$1", "=*r|m|r,r|m|r,~{edi},~{dirflag},~{fpsr},~{flags}"
+ asm ("opr %[vout],%[vin]"
+ : [vout] "=r,=m,=r" (*vout)
+ : [vin] "r,m,r" (vin)
+ : "edi");
+}
+
+// PR8959 - This should implicitly truncate the immediate to a byte.
+// CHECK: @test4
+int test4(volatile int *addr) {
+ unsigned char oldval;
+ // CHECK: call i8 asm "frob $0", "=r,0{{.*}}"(i8 -1)
+ __asm__ ("frob %0" : "=r"(oldval) : "0"(0xff));
+ return (int)oldval;
+}
+
+// <rdar://problem/10919182> - This should have both inputs be of type x86_mmx.
+// CHECK: @test5
+typedef long long __m64 __attribute__((__vector_size__(8)));
+__m64 test5(__m64 __A, __m64 __B) {
+ // CHECK: call x86_mmx asm "pmulhuw $1, $0\0A\09", "=y,y,0,~{dirflag},~{fpsr},~{flags}"(x86_mmx %{{.*}}, x86_mmx %{{.*}})
+ asm ("pmulhuw %1, %0\n\t" : "+y" (__A) : "y" (__B));
+ return __A;
+}
diff --git a/clang/test/CodeGen/asm-label.c b/clang/test/CodeGen/asm-label.c
new file mode 100644
index 0000000..c06f11f
--- /dev/null
+++ b/clang/test/CodeGen/asm-label.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple=i686-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=LINUX
+// RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm %s -o - | FileCheck %s --check-prefix=DARWIN
+
+char *strerror(int) asm("alias");
+int x __asm("foo");
+
+int *test(void) {
+ static int y __asm("bar");
+ strerror(-1);
+ return &y;
+}
+
+// LINUX: @bar = internal global i32 0
+// LINUX: @foo = common global i32 0
+// LINUX: declare i8* @alias(i32)
+
+// DARWIN: @"\01bar" = internal global i32 0
+// DARWIN: @"\01foo" = common global i32 0
+// DARWIN: declare i8* @"\01alias"(i32)
diff --git a/clang/test/CodeGen/asm-reg-var-local.c b/clang/test/CodeGen/asm-reg-var-local.c
new file mode 100644
index 0000000..9060e12
--- /dev/null
+++ b/clang/test/CodeGen/asm-reg-var-local.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
+// Exercise various use cases for local asm "register variables".
+
+int foo() {
+// CHECK: [[A:%[a-zA-Z0-9]+]] = alloca i32
+
+ register int a asm("rsi")=5;
+// CHECK: store i32 5, i32* [[A]]
+
+ asm volatile("; %0 This asm defines rsi" : "=r"(a));
+// CHECK: [[Z:%[a-zA-Z0-9]+]] = call i32 asm sideeffect "; $0 This asm defines rsi", "={rsi},~{dirflag},~{fpsr},~{flags}"()
+// CHECK: store i32 [[Z]], i32* [[A]]
+
+ a = 42;
+// CHECK: store i32 42, i32* [[A]]
+
+ asm volatile("; %0 This asm uses rsi" : : "r"(a));
+// CHECK: [[TMP:%[a-zA-Z0-9]+]] = load i32* [[A]]
+// CHECK: call void asm sideeffect "; $0 This asm uses rsi", "{rsi},~{dirflag},~{fpsr},~{flags}"(i32 [[TMP]])
+
+ return a;
+// CHECK: [[TMP1:%[a-zA-Z0-9]+]] = load i32* [[A]]
+// CHECK: ret i32 [[TMP1]]
+}
diff --git a/clang/test/CodeGen/asm-variable.c b/clang/test/CodeGen/asm-variable.c
new file mode 100644
index 0000000..dc087bd
--- /dev/null
+++ b/clang/test/CodeGen/asm-variable.c
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+unsigned long long foo(unsigned long long addr, unsigned long long a0,
+ unsigned long long a1, unsigned long long a2,
+ unsigned long long a3, unsigned long long a4,
+ unsigned long long a5) {
+ register unsigned long long result asm("rax");
+ register unsigned long long b0 asm("rdi");
+ register unsigned long long b1 asm("rsi");
+ register unsigned long long b2 asm("rdx");
+ register unsigned long long b3 asm("rcx");
+ register unsigned long long b4 asm("r8");
+ register unsigned long long b5 asm("r9");
+
+ b0 = a0;
+ b1 = a1;
+ b2 = a2;
+ b3 = a3;
+ b4 = a4;
+ b5 = a5;
+
+ asm("call *%1" : "=r" (result)
+ : "r"(addr), "r" (b0), "r" (b1), "r" (b2), "r" (b3), "r" (b4), "r" (b5));
+ return result;
+}
+
+// CHECK: call i64 asm "call *$1", "={rax},r,{rdi},{rsi},{rdx},{rcx},{r8},{r9},~{dirflag},~{fpsr},~{flags}"
+
+unsigned long long foo2(unsigned long long addr, double a0,
+ double a1, double a2,
+ double a3, double a4,
+ double a5, double a6, double a7) {
+ register double b0 asm("xmm0");
+ register double b1 asm("xmm1");
+ register double b2 asm("xmm2");
+ register double b3 asm("xmm3");
+ register double b4 asm("xmm4");
+ register double b5 asm("xmm5");
+ register double b6 asm("xmm6");
+ register double b7 asm("xmm7");
+
+ register unsigned long long result asm("rax");
+
+ b0 = a0;
+ b1 = a1;
+ b2 = a2;
+ b3 = a3;
+ b4 = a4;
+ b5 = a5;
+ b6 = a6;
+ b7 = a7;
+
+ asm("call *%1" : "=r" (result)
+ : "r"(addr), "x" (b0), "x" (b1), "x" (b2), "x" (b3), "x" (b4), "x" (b5), "x" (b6),
+ "x" (b7));
+ return result;
+}
+
+// CHECK: call i64 asm "call *$1", "={rax},r,{xmm0},{xmm1},{xmm2},{xmm3},{xmm4},{xmm5},{xmm6},{xmm7},~{dirflag},~{fpsr},~{flags}
+
+int randomvar asm("randomvar");
+void foo3() {
+ asm("vartest %0" : : "r"(randomvar));
+}
+// CHECK: call void asm sideeffect "vartest $0", "r,~{dirflag},~{fpsr},~{flags}"
diff --git a/clang/test/CodeGen/asm.c b/clang/test/CodeGen/asm.c
new file mode 100644
index 0000000..84f26e1
--- /dev/null
+++ b/clang/test/CodeGen/asm.c
@@ -0,0 +1,222 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+// PR10415
+__asm__ ("foo1");
+__asm__ ("foo2");
+__asm__ ("foo3");
+// CHECK: module asm "foo1"
+// CHECK-NEXT: module asm "foo2"
+// CHECK-NEXT: module asm "foo3"
+
+void t1(int len) {
+ __asm__ volatile("" : "=&r"(len), "+&r"(len));
+}
+
+void t2(unsigned long long t) {
+ __asm__ volatile("" : "+m"(t));
+}
+
+void t3(unsigned char *src, unsigned long long temp) {
+ __asm__ volatile("" : "+m"(temp), "+r"(src));
+}
+
+void t4() {
+ unsigned long long a;
+ struct reg { unsigned long long a, b; } b;
+
+ __asm__ volatile ("":: "m"(a), "m"(b));
+}
+
+// PR3417
+void t5(int i) {
+ asm("nop" : "=r"(i) : "0"(t5));
+}
+
+// PR3641
+void t6(void) {
+ __asm__ volatile("" : : "i" (t6));
+}
+
+void t7(int a) {
+ __asm__ volatile("T7 NAMED: %[input]" : "+r"(a): [input] "i" (4));
+ // CHECK: @t7(i32
+ // CHECK: T7 NAMED: $1
+}
+
+void t8() {
+ __asm__ volatile("T8 NAMED MODIFIER: %c[input]" :: [input] "i" (4));
+ // CHECK: @t8()
+ // CHECK: T8 NAMED MODIFIER: ${0:c}
+}
+
+// PR3682
+unsigned t9(unsigned int a) {
+ asm("bswap %0 %1" : "+r" (a));
+ return a;
+}
+
+// PR3908
+void t10(int r) {
+ __asm__("PR3908 %[lf] %[xx] %[li] %[r]" : [r] "+r" (r) : [lf] "mx" (0), [li] "mr" (0), [xx] "x" ((double)(0)));
+
+// CHECK: @t10(
+// CHECK:PR3908 $1 $3 $2 $0
+}
+
+// PR3373
+unsigned t11(signed char input) {
+ unsigned output;
+ __asm__("xyz"
+ : "=a" (output)
+ : "0" (input));
+ return output;
+}
+
+// PR3373
+unsigned char t12(unsigned input) {
+ unsigned char output;
+ __asm__("xyz"
+ : "=a" (output)
+ : "0" (input));
+ return output;
+}
+
+unsigned char t13(unsigned input) {
+ unsigned char output;
+ __asm__("xyz %1"
+ : "=a" (output)
+ : "0" (input));
+ return output;
+}
+
+struct large {
+ int x[1000];
+};
+
+unsigned long t15(int x, struct large *P) {
+ __asm__("xyz "
+ : "=r" (x)
+ : "m" (*P), "0" (x));
+ return x;
+}
+
+// bitfield destination of an asm.
+struct S {
+ int a : 4;
+};
+
+void t14(struct S *P) {
+ __asm__("abc %0" : "=r"(P->a) );
+}
+
+// PR4938
+int t16() {
+ int a,b;
+ asm ( "nop;"
+ :"=%c" (a)
+ : "r" (b)
+ );
+ return 0;
+}
+
+// PR6475
+void t17() {
+ int i;
+ __asm__ ( "nop": "=m"(i));
+
+// CHECK: @t17()
+// CHECK: call void asm "nop", "=*m,
+}
+
+// <rdar://problem/6841383>
+int t18(unsigned data) {
+ int a, b;
+
+ asm("xyz" :"=a"(a), "=d"(b) : "a"(data));
+ return a + b;
+// CHECK: t18(i32
+// CHECK: = call {{.*}}asm "xyz"
+// CHECK-NEXT: extractvalue
+// CHECK-NEXT: extractvalue
+}
+
+// PR6780
+int t19(unsigned data) {
+ int a, b;
+
+ asm("x{abc|def|ghi}z" :"=r"(a): "r"(data));
+ return a + b;
+ // CHECK: t19(i32
+ // CHECK: = call {{.*}}asm "x$(abc$|def$|ghi$)z"
+}
+
+// PR6845 - Mismatching source/dest fp types.
+double t20(double x) {
+ register long double result;
+ __asm __volatile ("frndint" : "=t" (result) : "0" (x));
+ return result;
+
+ // CHECK: @t20
+ // CHECK: fpext double {{.*}} to x86_fp80
+ // CHECK-NEXT: call x86_fp80 asm sideeffect "frndint"
+ // CHECK: fptrunc x86_fp80 {{.*}} to double
+}
+
+float t21(long double x) {
+ register float result;
+ __asm __volatile ("frndint" : "=t" (result) : "0" (x));
+ return result;
+ // CHECK: @t21
+ // CHECK: call x86_fp80 asm sideeffect "frndint"
+ // CHECK-NEXT: fptrunc x86_fp80 {{.*}} to float
+}
+
+// <rdar://problem/8348447> - accept 'l' constraint
+unsigned char t22(unsigned char a, unsigned char b) {
+ unsigned int la = a;
+ unsigned int lb = b;
+ unsigned int bigres;
+ unsigned char res;
+ __asm__ ("0:\n1:\n" : [bigres] "=la"(bigres) : [la] "0"(la), [lb] "c"(lb) :
+ "edx", "cc");
+ res = bigres;
+ return res;
+}
+
+// <rdar://problem/8348447> - accept 'l' constraint
+unsigned char t23(unsigned char a, unsigned char b) {
+ unsigned int la = a;
+ unsigned int lb = b;
+ unsigned char res;
+ __asm__ ("0:\n1:\n" : [res] "=la"(res) : [la] "0"(la), [lb] "c"(lb) :
+ "edx", "cc");
+ return res;
+}
+
+void *t24(char c) {
+ void *addr;
+ // CHECK: @t24
+ // CHECK: zext i8 {{.*}} to i32
+ // CHECK-NEXT: call i8* asm "foobar"
+ __asm__ ("foobar" : "=a" (addr) : "0" (c));
+ return addr;
+}
+
+// PR10299 - fpsr, fpcr
+void t25(void)
+{
+ __asm__ __volatile__( \
+ "finit" \
+ : \
+ : \
+ :"st","st(1)","st(2)","st(3)", \
+ "st(4)","st(5)","st(6)","st(7)", \
+ "fpsr","fpcr" \
+ );
+}
+
+// rdar://10510405 - AVX registers
+typedef long long __m256i __attribute__((__vector_size__(32)));
+void t26 (__m256i *p) {
+ __asm__ volatile("vmovaps %0, %%ymm0" :: "m" (*(__m256i*)p) : "ymm0");
+}
diff --git a/clang/test/CodeGen/asm_arm.c b/clang/test/CodeGen/asm_arm.c
new file mode 100644
index 0000000..633bf55
--- /dev/null
+++ b/clang/test/CodeGen/asm_arm.c
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -triple armv6-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+void test0(void) {
+ asm volatile("mov r0, r0" :: );
+}
+void test1(void) {
+ asm volatile("mov r0, r0" :::
+ "cc", "memory" );
+}
+void test2(void) {
+ asm volatile("mov r0, r0" :::
+ "r0", "r1", "r2", "r3");
+ asm volatile("mov r0, r0" :::
+ "r4", "r5", "r6", "r8");
+}
+void test3(void) {
+ asm volatile("mov r0, r0" :::
+ "a1", "a2", "a3", "a4");
+ asm volatile("mov r0, r0" :::
+ "v1", "v2", "v3", "v5");
+}
+
+
+// {} should not be treated as asm variants.
+void test4(float *a, float *b) {
+ // CHECK: @test4
+ // CHECK: call void asm sideeffect "vld1.32 {d8[],d9[]},
+ __asm__ volatile (
+ "vld1.32 {d8[],d9[]}, [%1,:32] \n\t"
+ "vst1.32 {q4}, [%0,:128] \n\t"
+ :: "r"(a), "r"(b));
+}
+
+// {sp, lr, pc} are the canonical names for {r13, r14, r15}.
+//
+// CHECK: @test5
+// CHECK: call void asm sideeffect "", "~{sp},~{lr},~{pc},~{sp},~{lr},~{pc}"()
+void test5() {
+ __asm__("" : : : "r13", "r14", "r15", "sp", "lr", "pc");
+}
+
+// CHECK: @test6
+// CHECK: call void asm sideeffect "", "
+// CHECK: ~{s0},~{s1},~{s2},~{s3},~{s4},~{s5},~{s6},~{s7},
+// CHECK: ~{s8},~{s9},~{s10},~{s11},~{s12},~{s13},~{s14},~{s15},
+// CHECK: ~{s16},~{s17},~{s18},~{s19},~{s20},~{s21},~{s22},~{s23},
+// CHECK: ~{s24},~{s25},~{s26},~{s27},~{s28},~{s29},~{s30},~{s31}"()
+void test6() {
+ __asm__("" : : :
+ "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
+ "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15",
+ "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
+ "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31");
+}
diff --git a/clang/test/CodeGen/assign.c b/clang/test/CodeGen/assign.c
new file mode 100644
index 0000000..fc00896
--- /dev/null
+++ b/clang/test/CodeGen/assign.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple x86_64 -emit-llvm -o - %s | FileCheck %s
+
+// Check that we don't generate unnecessary reloads.
+//
+// CHECK: define void @f0()
+// CHECK: [[x_0:%.*]] = alloca i32, align 4
+// CHECK-NEXT: [[y_0:%.*]] = alloca i32, align 4
+// CHECK-NEXT: store i32 1, i32* [[x_0]]
+// CHECK-NEXT: store i32 1, i32* [[x_0]]
+// CHECK-NEXT: store i32 1, i32* [[y_0]]
+// CHECK: }
+void f0() {
+ int x, y;
+ x = 1;
+ y = (x = 1);
+}
+
+// This used to test that we generate reloads for volatile access,
+// but that does not appear to be correct behavior for C.
+//
+// CHECK: define void @f1()
+// CHECK: [[x_1:%.*]] = alloca i32, align 4
+// CHECK-NEXT: [[y_1:%.*]] = alloca i32, align 4
+// CHECK-NEXT: store volatile i32 1, i32* [[x_1]]
+// CHECK-NEXT: store volatile i32 1, i32* [[x_1]]
+// CHECK-NEXT: store volatile i32 1, i32* [[y_1]]
+// CHECK: }
+void f1() {
+ volatile int x, y;
+ x = 1;
+ y = (x = 1);
+}
diff --git a/clang/test/CodeGen/atomic-ops.c b/clang/test/CodeGen/atomic-ops.c
new file mode 100644
index 0000000..1a9ed36
--- /dev/null
+++ b/clang/test/CodeGen/atomic-ops.c
@@ -0,0 +1,314 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin9 | FileCheck %s
+
+// Also test serialization of atomic operations here, to avoid duplicating the
+// test.
+// RUN: %clang_cc1 %s -emit-pch -o %t -triple=i686-apple-darwin9
+// RUN: %clang_cc1 %s -include-pch %t -triple=i686-apple-darwin9 -emit-llvm -o - | FileCheck %s
+#ifndef ALREADY_INCLUDED
+#define ALREADY_INCLUDED
+
+// Basic IRGen tests for __c11_atomic_* and GNU __atomic_*
+
+typedef enum memory_order {
+ memory_order_relaxed, memory_order_consume, memory_order_acquire,
+ memory_order_release, memory_order_acq_rel, memory_order_seq_cst
+} memory_order;
+
+int fi1(_Atomic(int) *i) {
+ // CHECK: @fi1
+ // CHECK: load atomic i32* {{.*}} seq_cst
+ return __c11_atomic_load(i, memory_order_seq_cst);
+}
+
+int fi1a(int *i) {
+ // CHECK: @fi1a
+ // CHECK: load atomic i32* {{.*}} seq_cst
+ int v;
+ __atomic_load(i, &v, memory_order_seq_cst);
+ return v;
+}
+
+int fi1b(int *i) {
+ // CHECK: @fi1b
+ // CHECK: load atomic i32* {{.*}} seq_cst
+ return __atomic_load_n(i, memory_order_seq_cst);
+}
+
+void fi2(_Atomic(int) *i) {
+ // CHECK: @fi2
+ // CHECK: store atomic i32 {{.*}} seq_cst
+ __c11_atomic_store(i, 1, memory_order_seq_cst);
+}
+
+void fi2a(int *i) {
+ // CHECK: @fi2a
+ // CHECK: store atomic i32 {{.*}} seq_cst
+ int v = 1;
+ __atomic_store(i, &v, memory_order_seq_cst);
+}
+
+void fi2b(int *i) {
+ // CHECK: @fi2b
+ // CHECK: store atomic i32 {{.*}} seq_cst
+ __atomic_store_n(i, 1, memory_order_seq_cst);
+}
+
+int fi3(_Atomic(int) *i) {
+ // CHECK: @fi3
+ // CHECK: atomicrmw and
+ // CHECK-NOT: and
+ return __c11_atomic_fetch_and(i, 1, memory_order_seq_cst);
+}
+
+int fi3a(int *i) {
+ // CHECK: @fi3a
+ // CHECK: atomicrmw xor
+ // CHECK-NOT: xor
+ return __atomic_fetch_xor(i, 1, memory_order_seq_cst);
+}
+
+int fi3b(int *i) {
+ // CHECK: @fi3b
+ // CHECK: atomicrmw add
+ // CHECK: add
+ return __atomic_add_fetch(i, 1, memory_order_seq_cst);
+}
+
+int fi3c(int *i) {
+ // CHECK: @fi3c
+ // CHECK: atomicrmw nand
+ // CHECK-NOT: and
+ return __atomic_fetch_nand(i, 1, memory_order_seq_cst);
+}
+
+int fi3d(int *i) {
+ // CHECK: @fi3d
+ // CHECK: atomicrmw nand
+ // CHECK: and
+ // CHECK: xor
+ return __atomic_nand_fetch(i, 1, memory_order_seq_cst);
+}
+
+_Bool fi4(_Atomic(int) *i) {
+ // CHECK: @fi4
+ // CHECK: cmpxchg i32*
+ int cmp = 0;
+ return __c11_atomic_compare_exchange_strong(i, &cmp, 1, memory_order_acquire, memory_order_acquire);
+}
+
+_Bool fi4a(int *i) {
+ // CHECK: @fi4
+ // CHECK: cmpxchg i32*
+ int cmp = 0;
+ int desired = 1;
+ return __atomic_compare_exchange(i, &cmp, &desired, 0, memory_order_acquire, memory_order_acquire);
+}
+
+_Bool fi4b(int *i) {
+ // CHECK: @fi4
+ // CHECK: cmpxchg i32*
+ int cmp = 0;
+ return __atomic_compare_exchange_n(i, &cmp, 1, 1, memory_order_acquire, memory_order_acquire);
+}
+
+float ff1(_Atomic(float) *d) {
+ // CHECK: @ff1
+ // CHECK: load atomic i32* {{.*}} monotonic
+ return __c11_atomic_load(d, memory_order_relaxed);
+}
+
+void ff2(_Atomic(float) *d) {
+ // CHECK: @ff2
+ // CHECK: store atomic i32 {{.*}} release
+ __c11_atomic_store(d, 1, memory_order_release);
+}
+
+float ff3(_Atomic(float) *d) {
+ return __c11_atomic_exchange(d, 2, memory_order_seq_cst);
+}
+
+int* fp1(_Atomic(int*) *p) {
+ // CHECK: @fp1
+ // CHECK: load atomic i32* {{.*}} seq_cst
+ return __c11_atomic_load(p, memory_order_seq_cst);
+}
+
+int* fp2(_Atomic(int*) *p) {
+ // CHECK: @fp2
+ // CHECK: store i32 4
+ // CHECK: atomicrmw add {{.*}} monotonic
+ return __c11_atomic_fetch_add(p, 1, memory_order_relaxed);
+}
+
+int *fp2a(int **p) {
+ // CHECK: @fp2a
+ // CHECK: store i32 4
+ // CHECK: atomicrmw sub {{.*}} monotonic
+ // Note, the GNU builtins do not multiply by sizeof(T)!
+ return __atomic_fetch_sub(p, 4, memory_order_relaxed);
+}
+
+_Complex float fc(_Atomic(_Complex float) *c) {
+ // CHECK: @fc
+ // CHECK: atomicrmw xchg i64*
+ return __c11_atomic_exchange(c, 2, memory_order_seq_cst);
+}
+
+typedef struct X { int x; } X;
+X fs(_Atomic(X) *c) {
+ // CHECK: @fs
+ // CHECK: atomicrmw xchg i32*
+ return __c11_atomic_exchange(c, (X){2}, memory_order_seq_cst);
+}
+
+X fsa(X *c, X *d) {
+ // CHECK: @fsa
+ // CHECK: atomicrmw xchg i32*
+ X ret;
+ __atomic_exchange(c, d, &ret, memory_order_seq_cst);
+ return ret;
+}
+
+_Bool fsb(_Bool *c) {
+ // CHECK: @fsb
+ // CHECK: atomicrmw xchg i8*
+ return __atomic_exchange_n(c, 1, memory_order_seq_cst);
+}
+
+char flag1;
+volatile char flag2;
+void test_and_set() {
+ // CHECK: atomicrmw xchg i8* @flag1, i8 1 seq_cst
+ __atomic_test_and_set(&flag1, memory_order_seq_cst);
+ // CHECK: atomicrmw volatile xchg i8* @flag2, i8 1 acquire
+ __atomic_test_and_set(&flag2, memory_order_acquire);
+ // CHECK: store atomic volatile i8 0, i8* @flag2 release
+ __atomic_clear(&flag2, memory_order_release);
+ // CHECK: store atomic i8 0, i8* @flag1 seq_cst
+ __atomic_clear(&flag1, memory_order_seq_cst);
+}
+
+struct Sixteen {
+ char c[16];
+} sixteen;
+struct Seventeen {
+ char c[17];
+} seventeen;
+
+int lock_free(struct Incomplete *incomplete) {
+ // CHECK: @lock_free
+
+ // CHECK: call i32 @__atomic_is_lock_free(i32 3, i8* null)
+ __c11_atomic_is_lock_free(3);
+
+ // CHECK: call i32 @__atomic_is_lock_free(i32 16, i8* {{.*}}@sixteen{{.*}})
+ __atomic_is_lock_free(16, &sixteen);
+
+ // CHECK: call i32 @__atomic_is_lock_free(i32 17, i8* {{.*}}@seventeen{{.*}})
+ __atomic_is_lock_free(17, &seventeen);
+
+ // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+ __atomic_is_lock_free(4, incomplete);
+
+ char cs[20];
+ // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+ __atomic_is_lock_free(4, cs+1);
+
+ // CHECK-NOT: call
+ __atomic_always_lock_free(3, 0);
+ __atomic_always_lock_free(16, 0);
+ __atomic_always_lock_free(17, 0);
+ __atomic_always_lock_free(16, &sixteen);
+ __atomic_always_lock_free(17, &seventeen);
+
+ int n;
+ __atomic_is_lock_free(4, &n);
+
+ // CHECK: ret i32 1
+ return __c11_atomic_is_lock_free(sizeof(_Atomic(int)));
+}
+
+// Tests for atomic operations on big values. These should call the functions
+// defined here:
+// http://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary#The_Library_interface
+
+struct foo {
+ int big[128];
+};
+struct bar {
+ char c[3];
+};
+
+struct bar smallThing, thing1, thing2;
+struct foo bigThing;
+_Atomic(struct foo) bigAtomic;
+
+void structAtomicStore() {
+ // CHECK: @structAtomicStore
+ struct foo f = {0};
+ __c11_atomic_store(&bigAtomic, f, 5);
+ // CHECK: call void @__atomic_store(i32 512, i8* bitcast ({{.*}} @bigAtomic to i8*),
+
+ struct bar b = {0};
+ __atomic_store(&smallThing, &b, 5);
+ // CHECK: call void @__atomic_store(i32 3, i8* {{.*}} @smallThing
+
+ __atomic_store(&bigThing, &f, 5);
+ // CHECK: call void @__atomic_store(i32 512, i8* {{.*}} @bigThing
+}
+void structAtomicLoad() {
+ // CHECK: @structAtomicLoad
+ struct foo f = __c11_atomic_load(&bigAtomic, 5);
+ // CHECK: call void @__atomic_load(i32 512, i8* bitcast ({{.*}} @bigAtomic to i8*),
+
+ struct bar b;
+ __atomic_load(&smallThing, &b, 5);
+ // CHECK: call void @__atomic_load(i32 3, i8* {{.*}} @smallThing
+
+ __atomic_load(&bigThing, &f, 5);
+ // CHECK: call void @__atomic_load(i32 512, i8* {{.*}} @bigThing
+}
+struct foo structAtomicExchange() {
+ // CHECK: @structAtomicExchange
+ struct foo f = {0};
+ struct foo old;
+ __atomic_exchange(&f, &bigThing, &old, 5);
+ // CHECK: call void @__atomic_exchange(i32 512, {{.*}}, i8* bitcast ({{.*}} @bigThing to i8*),
+
+ return __c11_atomic_exchange(&bigAtomic, f, 5);
+ // CHECK: call void @__atomic_exchange(i32 512, i8* bitcast ({{.*}} @bigAtomic to i8*),
+}
+int structAtomicCmpExchange() {
+ // CHECK: @structAtomicCmpExchange
+ _Bool x = __atomic_compare_exchange(&smallThing, &thing1, &thing2, 1, 5, 5);
+ // CHECK: call zeroext i1 @__atomic_compare_exchange(i32 3, {{.*}} @smallThing{{.*}} @thing1{{.*}} @thing2
+
+ struct foo f = {0};
+ struct foo g = {0};
+ g.big[12] = 12;
+ return x & __c11_atomic_compare_exchange_strong(&bigAtomic, &f, g, 5, 5);
+ // CHECK: call zeroext i1 @__atomic_compare_exchange(i32 512, i8* bitcast ({{.*}} @bigAtomic to i8*),
+}
+
+// Check that no atomic operations are used in any initialisation of _Atomic
+// types.
+_Atomic(int) atomic_init_i = 42;
+
+// CHECK: @atomic_init_foo
+void atomic_init_foo()
+{
+ // CHECK-NOT: }
+ // CHECK-NOT: atomic
+ // CHECK: store
+ _Atomic(int) j = 12;
+
+ // CHECK-NOT: }
+ // CHECK-NOT: atomic
+ // CHECK: store
+ __c11_atomic_init(&j, 42);
+
+ // CHECK-NOT: atomic
+ // CHECK: }
+}
+
+#endif
diff --git a/clang/test/CodeGen/atomic.c b/clang/test/CodeGen/atomic.c
new file mode 100644
index 0000000..ac3848f
--- /dev/null
+++ b/clang/test/CodeGen/atomic.c
@@ -0,0 +1,109 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin9 | FileCheck %s
+
+int atomic(void) {
+ // non-sensical test for sync functions
+ int old;
+ int val = 1;
+ char valc = 1;
+ _Bool valb = 0;
+ unsigned int uval = 1;
+ int cmp = 0;
+ int* ptrval;
+
+ old = __sync_fetch_and_add(&val, 1);
+ // CHECK: atomicrmw add i32* %val, i32 1 seq_cst
+
+ old = __sync_fetch_and_sub(&valc, 2);
+ // CHECK: atomicrmw sub i8* %valc, i8 2 seq_cst
+
+ old = __sync_fetch_and_min(&val, 3);
+ // CHECK: atomicrmw min i32* %val, i32 3 seq_cst
+
+ old = __sync_fetch_and_max(&val, 4);
+ // CHECK: atomicrmw max i32* %val, i32 4 seq_cst
+
+ old = __sync_fetch_and_umin(&uval, 5u);
+ // CHECK: atomicrmw umin i32* %uval, i32 5 seq_cst
+
+ old = __sync_fetch_and_umax(&uval, 6u);
+ // CHECK: atomicrmw umax i32* %uval, i32 6 seq_cst
+
+ old = __sync_lock_test_and_set(&val, 7);
+ // CHECK: atomicrmw xchg i32* %val, i32 7 seq_cst
+
+ old = __sync_swap(&val, 8);
+ // CHECK: atomicrmw xchg i32* %val, i32 8 seq_cst
+
+ old = __sync_val_compare_and_swap(&val, 4, 1976);
+ // CHECK: cmpxchg i32* %val, i32 4, i32 1976 seq_cst
+
+ old = __sync_bool_compare_and_swap(&val, 4, 1976);
+ // CHECK: cmpxchg i32* %val, i32 4, i32 1976 seq_cst
+
+ old = __sync_fetch_and_and(&val, 0x9);
+ // CHECK: atomicrmw and i32* %val, i32 9 seq_cst
+
+ old = __sync_fetch_and_or(&val, 0xa);
+ // CHECK: atomicrmw or i32* %val, i32 10 seq_cst
+
+ old = __sync_fetch_and_xor(&val, 0xb);
+ // CHECK: atomicrmw xor i32* %val, i32 11 seq_cst
+
+ old = __sync_add_and_fetch(&val, 1);
+ // CHECK: atomicrmw add i32* %val, i32 1 seq_cst
+
+ old = __sync_sub_and_fetch(&val, 2);
+ // CHECK: atomicrmw sub i32* %val, i32 2 seq_cst
+
+ old = __sync_and_and_fetch(&valc, 3);
+ // CHECK: atomicrmw and i8* %valc, i8 3 seq_cst
+
+ old = __sync_or_and_fetch(&valc, 4);
+ // CHECK: atomicrmw or i8* %valc, i8 4 seq_cst
+
+ old = __sync_xor_and_fetch(&valc, 5);
+ // CHECK: atomicrmw xor i8* %valc, i8 5 seq_cst
+
+ __sync_val_compare_and_swap((void **)0, (void *)0, (void *)0);
+ // CHECK: cmpxchg i32* null, i32 0, i32 0 seq_cst
+
+ if ( __sync_val_compare_and_swap(&valb, 0, 1)) {
+ // CHECK: cmpxchg i8* %valb, i8 0, i8 1 seq_cst
+ old = 42;
+ }
+
+ __sync_bool_compare_and_swap((void **)0, (void *)0, (void *)0);
+ // CHECK: cmpxchg i32* null, i32 0, i32 0 seq_cst
+
+ __sync_lock_release(&val);
+ // CHECK: store atomic i32 0, {{.*}} release, align 4
+
+ __sync_lock_release(&ptrval);
+ // CHECK: store atomic i32 0, {{.*}} release, align 4
+
+ __sync_synchronize ();
+ // CHECK: fence seq_cst
+
+ return old;
+}
+
+// CHECK: @release_return
+void release_return(int *lock) {
+ // Ensure this is actually returning void all the way through.
+ return __sync_lock_release(lock);
+ // CHECK: store atomic {{.*}} release, align 4
+}
+
+
+// rdar://8461279 - Atomics with address spaces.
+// CHECK: @addrspace
+void addrspace(int __attribute__((address_space(256))) * P) {
+ __sync_bool_compare_and_swap(P, 0, 1);
+ // CHECK: cmpxchg i32 addrspace(256)*{{.*}}, i32 0, i32 1 seq_cst
+
+ __sync_val_compare_and_swap(P, 0, 1);
+ // CHECK: cmpxchg i32 addrspace(256)*{{.*}}, i32 0, i32 1 seq_cst
+
+ __sync_xor_and_fetch(P, 123);
+ // CHECK: atomicrmw xor i32 addrspace(256)*{{.*}}, i32 123 seq_cst
+}
diff --git a/clang/test/CodeGen/atomic_ops.c b/clang/test/CodeGen/atomic_ops.c
new file mode 100644
index 0000000..9a18c9e
--- /dev/null
+++ b/clang/test/CodeGen/atomic_ops.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+void foo(void)
+{
+ _Atomic(int) i = 0;
+ // Check that multiply / divides on atomics produce a cmpxchg loop
+ i *= 2; // CHECK: cmpxchg
+ i /= 2; // CHECK: cmpxchg
+ // These should be emitting atomicrmw instructions, but they aren't yet
+ i += 2; // CHECK: cmpxchg
+ i -= 2; // CHECK: cmpxchg
+ i++; // CHECK: cmpxchg
+ i--; // CHECK: cmpxchg
+}
diff --git a/clang/test/CodeGen/attr-availability.c b/clang/test/CodeGen/attr-availability.c
new file mode 100644
index 0000000..6f9c045
--- /dev/null
+++ b/clang/test/CodeGen/attr-availability.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fvisibility hidden "-triple" "x86_64-apple-darwin8.0.0" -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-10_4 %s
+// RUN: %clang_cc1 -fvisibility hidden "-triple" "x86_64-apple-darwin9.0.0" -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-10_5 %s
+// RUN: %clang_cc1 -fvisibility hidden "-triple" "x86_64-apple-darwin10.0.0" -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-10_6 %s
+
+// CHECK-10_4: define hidden void @f2
+// CHECK-10_5: define hidden void @f2
+// CHECK-10_6: define hidden void @f2
+void f2();
+void f2() { }
+
+// CHECK-10_4: define void @f3
+// CHECK-10_5: define void @f3
+// CHECK-10_6: define void @f3
+void f3() __attribute__((availability(macosx,introduced=10.5)));
+void f3() { }
+
+// CHECK-10_4: declare extern_weak void @f0
+// CHECK-10_5: declare void @f0
+// CHECK-10_6: declare void @f0
+void f0() __attribute__((availability(macosx,introduced=10.5)));
+
+// CHECK-10_4: declare extern_weak void @f1
+// CHECK-10_5: declare extern_weak void @f1
+// CHECK-10_6: declare void @f1
+void f1() __attribute__((availability(macosx,introduced=10.6)));
+
+void test() {
+ f0();
+ f1();
+ f2();
+}
diff --git a/clang/test/CodeGen/attr-cleanup.c b/clang/test/CodeGen/attr-cleanup.c
new file mode 100644
index 0000000..7c2053d
--- /dev/null
+++ b/clang/test/CodeGen/attr-cleanup.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+// <rdar://problem/6827047>
+void f(void* arg);
+void g() {
+ __attribute__((cleanup(f))) void *g;
+}
+
diff --git a/clang/test/CodeGen/attr-naked.c b/clang/test/CodeGen/attr-naked.c
new file mode 100644
index 0000000..2387d28
--- /dev/null
+++ b/clang/test/CodeGen/attr-naked.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -o - | FileCheck %s
+
+void t1() __attribute__((naked));
+
+// Basic functionality check
+// (Note that naked needs to imply noinline to work properly.)
+// CHECK: define void @t1() nounwind noinline naked {
+void t1()
+{
+}
+
+// Make sure this doesn't explode in the verifier.
+// (It doesn't really make sense, but it isn't invalid.)
+// CHECK: define void @t2() nounwind noinline naked {
+__attribute((naked, always_inline)) void t2() {
+}
diff --git a/clang/test/CodeGen/attr-nodebug.c b/clang/test/CodeGen/attr-nodebug.c
new file mode 100644
index 0000000..66caa2b
--- /dev/null
+++ b/clang/test/CodeGen/attr-nodebug.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -g -emit-llvm -o %t %s
+// RUN: not grep 'call void @llvm.dbg.func.start' %t
+
+void t1() __attribute__((nodebug));
+
+void t1()
+{
+ int a = 10;
+
+ a++;
+}
+
diff --git a/clang/test/CodeGen/attr-noinline.c b/clang/test/CodeGen/attr-noinline.c
new file mode 100644
index 0000000..dbca71f
--- /dev/null
+++ b/clang/test/CodeGen/attr-noinline.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -g -emit-llvm -o %t %s
+// RUN: grep 'noinline' %t
+
+void t1() __attribute__((noinline));
+
+void t1()
+{
+}
+
diff --git a/clang/test/CodeGen/attr-used.c b/clang/test/CodeGen/attr-used.c
new file mode 100644
index 0000000..bc92b94
--- /dev/null
+++ b/clang/test/CodeGen/attr-used.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: grep '@llvm.used = .*@g0' %t
+// RUN: grep '@llvm.used = .*@f0' %t
+// RUN: grep '@llvm.used = .*@f1.l0' %t
+
+
+int g0 __attribute__((used));
+
+static void __attribute__((used)) f0(void) {
+}
+
+void f1() {
+ static int l0 __attribute__((used)) = 5225;
+}
diff --git a/clang/test/CodeGen/attr-weak-import.c b/clang/test/CodeGen/attr-weak-import.c
new file mode 100644
index 0000000..0707f59
--- /dev/null
+++ b/clang/test/CodeGen/attr-weak-import.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-darwin-apple -emit-llvm -o - %s | FileCheck %s
+// rdar://9538608
+
+extern int A __attribute__((weak_import));
+int A;
+
+extern int B __attribute__((weak_import));
+extern int B;
+
+int C;
+extern int C __attribute__((weak_import));
+
+extern int D __attribute__((weak_import));
+extern int D __attribute__((weak_import));
+int D;
+
+extern int E __attribute__((weak_import));
+int E;
+extern int E __attribute__((weak_import));
+
+// CHECK: @A = global i32
+// CHECK-NOT: @B =
+// CHECK: @C = common global i32
+// CHECK: @D = global i32
+// CHECK: @E = global i32
+
diff --git a/clang/test/CodeGen/attr-weakref.c b/clang/test/CodeGen/attr-weakref.c
new file mode 100644
index 0000000..c1cc03b
--- /dev/null
+++ b/clang/test/CodeGen/attr-weakref.c
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu -o %t %s
+// RUN: FileCheck --input-file=%t %s
+
+// CHECK: declare extern_weak void @test1_f()
+void test1_f(void);
+static void test1_g(void) __attribute__((weakref("test1_f")));
+void test1_h(void) {
+ test1_g();
+}
+
+// CHECK: define void @test2_f()
+void test2_f(void) {}
+static void test2_g(void) __attribute__((weakref("test2_f")));
+void test2_h(void) {
+ test2_g();
+}
+
+// CHECK: declare void @test3_f()
+void test3_f(void);
+static void test3_g(void) __attribute__((weakref("test3_f")));
+void test3_foo(void) {
+ test3_f();
+}
+void test3_h(void) {
+ test3_g();
+}
+
+// CHECK: define void @test4_f()
+void test4_f(void);
+static void test4_g(void) __attribute__((weakref("test4_f")));
+void test4_h(void) {
+ test4_g();
+}
+void test4_f(void) {}
+
+// CHECK: declare void @test5_f()
+void test5_f(void);
+static void test5_g(void) __attribute__((weakref("test5_f")));
+void test5_h(void) {
+ test5_g();
+}
+void test5_foo(void) {
+ test5_f();
+}
+
+// CHECK: declare extern_weak void @test6_f()
+void test6_f(void) __attribute__((weak));
+static void test6_g(void) __attribute__((weakref("test6_f")));
+void test6_h(void) {
+ test6_g();
+}
+void test6_foo(void) {
+ test6_f();
+}
+
+// CHECK: declare extern_weak void @test7_f()
+void test7_f(void);
+static void test7_g(void) __attribute__((weakref("test7_f")));
+static void *const test7_zed = (void *) &test7_g;
+void* test7_h(void) {
+ return test7_zed;
+}
diff --git a/clang/test/CodeGen/attr-weakref2.c b/clang/test/CodeGen/attr-weakref2.c
new file mode 100644
index 0000000..9976063
--- /dev/null
+++ b/clang/test/CodeGen/attr-weakref2.c
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu -o %t %s
+// RUN: FileCheck --input-file=%t %s
+
+// CHECK: @test1_f = extern_weak global i32
+extern int test1_f;
+static int test1_g __attribute__((weakref("test1_f")));
+int test1_h(void) {
+ return test1_g;
+}
+
+// CHECK: @test2_f = common global i32 0, align 4
+int test2_f;
+static int test2_g __attribute__((weakref("test2_f")));
+int test2_h(void) {
+ return test2_g;
+}
+
+// CHECK: @test3_f = external global i32
+extern int test3_f;
+static int test3_g __attribute__((weakref("test3_f")));
+int test3_foo(void) {
+ return test3_f;
+}
+int test3_h(void) {
+ return test3_g;
+}
+
+// CHECK: @test4_f = common global i32 0, align 4
+extern int test4_f;
+static int test4_g __attribute__((weakref("test4_f")));
+int test4_h(void) {
+ return test4_g;
+}
+int test4_f;
+
+// CHECK: @test5_f = external global i32
+extern int test5_f;
+static int test5_g __attribute__((weakref("test5_f")));
+int test5_h(void) {
+ return test5_g;
+}
+int test5_foo(void) {
+ return test5_f;
+}
+
+// CHECK: @test6_f = extern_weak global i32
+extern int test6_f __attribute__((weak));
+static int test6_g __attribute__((weakref("test6_f")));
+int test6_h(void) {
+ return test6_g;
+}
+int test6_foo(void) {
+ return test6_f;
+}
diff --git a/clang/test/CodeGen/attribute-section-data-common.c b/clang/test/CodeGen/attribute-section-data-common.c
new file mode 100644
index 0000000..2393bfb
--- /dev/null
+++ b/clang/test/CodeGen/attribute-section-data-common.c
@@ -0,0 +1,5 @@
+// RUN: %clang -S %s -o /dev/null
+struct rtxc_snapshot {
+ int a, b, c, d;
+};
+__attribute__ ((section("__DATA, __common"))) struct rtxc_snapshot rtxc_log_A[4];
diff --git a/clang/test/CodeGen/attribute_constructor.c b/clang/test/CodeGen/attribute_constructor.c
new file mode 100644
index 0000000..c82c263
--- /dev/null
+++ b/clang/test/CodeGen/attribute_constructor.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | grep llvm.global_ctors
+
+void foo() __attribute__((constructor));
+void foo() {
+ bar();
+}
diff --git a/clang/test/CodeGen/attributes.c b/clang/test/CodeGen/attributes.c
new file mode 100644
index 0000000..4e73af6
--- /dev/null
+++ b/clang/test/CodeGen/attributes.c
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu -o %t %s
+// RUN: FileCheck --input-file=%t %s
+
+// CHECK: @t5 = weak global i32 2
+int t5 __attribute__((weak)) = 2;
+
+// CHECK: @t13 = global %struct.s0 zeroinitializer, section "SECT"
+struct s0 { int x; };
+struct s0 t13 __attribute__((section("SECT"))) = { 0 };
+
+// CHECK: @t14.x = internal global i32 0, section "SECT"
+void t14(void) {
+ static int x __attribute__((section("SECT"))) = 0;
+}
+
+// CHECK: @t18 = global i32 1, align 4
+extern int t18 __attribute__((weak_import));
+int t18 = 1;
+
+// CHECK: @t16 = extern_weak global i32
+extern int t16 __attribute__((weak_import));
+
+// CHECK: @t6 = common protected global i32 0
+int t6 __attribute__((visibility("protected")));
+
+// CHECK: @t12 = global i32 0, section "SECT"
+int t12 __attribute__((section("SECT")));
+
+// CHECK: @t9 = alias weak bitcast (void ()* @__t8 to void (...)*)
+void __t8() {}
+void t9() __attribute__((weak, alias("__t8")));
+
+// CHECK: declare extern_weak i32 @t15()
+int __attribute__((weak_import)) t15(void);
+int t17() {
+ return t15() + t16;
+}
+
+// CHECK: define void @t1() noreturn nounwind {
+void t1() __attribute__((noreturn));
+void t1() { while (1) {} }
+
+// CHECK: define void @t2() nounwind {
+void t2() __attribute__((nothrow));
+void t2() {}
+
+// CHECK: define weak void @t3() nounwind {
+void t3() __attribute__((weak));
+void t3() {}
+
+// CHECK: define hidden void @t4() nounwind {
+void t4() __attribute__((visibility("hidden")));
+void t4() {}
+
+// CHECK: define void @t7() noreturn nounwind {
+void t7() __attribute__((noreturn, nothrow));
+void t7() { while (1) {} }
+
+// CHECK: define void @t10() nounwind section "SECT" {
+void t10(void) __attribute__((section("SECT")));
+void t10(void) {}
+// CHECK: define void @t11() nounwind section "SECT" {
+void __attribute__((section("SECT"))) t11(void) {}
+
+// CHECK: define i32 @t19() nounwind {
+extern int t19(void) __attribute__((weak_import));
+int t19(void) {
+ return 10;
+}
+
+// CHECK:define void @t20() nounwind {
+// CHECK: call void @abort()
+// CHECK-NEXT: unreachable
+void t20(void) {
+ __builtin_abort();
+}
+
+void (__attribute__((fastcall)) *fptr)(int);
+void t21(void) {
+ fptr(10);
+}
+// CHECK: [[FPTRVAR:%[a-z0-9]+]] = load void (i32)** @fptr
+// CHECK-NEXT: call x86_fastcallcc void [[FPTRVAR]](i32 10)
diff --git a/clang/test/CodeGen/available-externally-suppress.c b/clang/test/CodeGen/available-externally-suppress.c
new file mode 100644
index 0000000..46b6e74
--- /dev/null
+++ b/clang/test/CodeGen/available-externally-suppress.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple x86_64-apple-darwin10 %s | FileCheck %s
+
+// Ensure that we don't emit available_externally functions at -O0.
+int x;
+
+inline void f0(int y) { x = y; }
+
+// CHECK: define void @test()
+// CHECK: declare void @f0(i32)
+void test() {
+ f0(17);
+}
+
+inline int __attribute__((always_inline)) f1(int x) {
+ int blarg = 0;
+ for (int i = 0; i < x; ++i)
+ blarg = blarg + x * i;
+ return blarg;
+}
+
+// CHECK: @test1
+int test1(int x) {
+ // CHECK: br i1
+ // CHECK-NOT: call {{.*}} @f1
+ // CHECK: ret i32
+ return f1(x);
+}
diff --git a/clang/test/CodeGen/avx-builtins.c b/clang/test/CodeGen/avx-builtins.c
new file mode 100644
index 0000000..b963c97
--- /dev/null
+++ b/clang/test/CodeGen/avx-builtins.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +avx -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <immintrin.h>
+
+//
+// Test LLVM IR codegen of shuffle instructions
+//
+
+__m256 test__mm256_loadu_ps(void* p) {
+ // CHECK: load <8 x float>* %{{.*}}, align 1
+ return _mm256_loadu_ps(p);
+}
+
+__m256d test__mm256_loadu_pd(void* p) {
+ // CHECK: load <4 x double>* %{{.*}}, align 1
+ return _mm256_loadu_pd(p);
+}
+
+__m256i test__mm256_loadu_si256(void* p) {
+ // CHECK: load <4 x i64>* %{{.+}}, align 1
+ return _mm256_loadu_si256(p);
+}
diff --git a/clang/test/CodeGen/avx-cmp-builtins.c b/clang/test/CodeGen/avx-cmp-builtins.c
new file mode 100644
index 0000000..1ac1c31
--- /dev/null
+++ b/clang/test/CodeGen/avx-cmp-builtins.c
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +avx -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <immintrin.h>
+
+//
+// Test LLVM IR codegen of cmpXY instructions
+//
+
+__m128d test_cmp_pd(__m128d a, __m128d b) {
+ // Expects that the third argument in LLVM IR is immediate expression
+ // CHECK: @llvm.x86.sse2.cmp.pd({{.*}}, i8 13)
+ return _mm_cmp_pd(a, b, _CMP_GE_OS);
+}
+
+__m128d test_cmp_ps(__m128 a, __m128 b) {
+ // Expects that the third argument in LLVM IR is immediate expression
+ // CHECK: @llvm.x86.sse.cmp.ps({{.*}}, i8 13)
+ return _mm_cmp_ps(a, b, _CMP_GE_OS);
+}
+
+__m256d test_cmp_pd256(__m256d a, __m256d b) {
+ // Expects that the third argument in LLVM IR is immediate expression
+ // CHECK: @llvm.x86.avx.cmp.pd.256({{.*}}, i8 13)
+ return _mm256_cmp_pd(a, b, _CMP_GE_OS);
+}
+
+__m256d test_cmp_ps256(__m256 a, __m256 b) {
+ // Expects that the third argument in LLVM IR is immediate expression
+ // CHECK: @llvm.x86.avx.cmp.ps.256({{.*}}, i8 13)
+ return _mm256_cmp_ps(a, b, _CMP_GE_OS);
+}
+
+__m128d test_cmp_sd(__m128d a, __m128d b) {
+ // Expects that the third argument in LLVM IR is immediate expression
+ // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 13)
+ return _mm_cmp_sd(a, b, _CMP_GE_OS);
+}
+
+__m128d test_cmp_ss(__m128 a, __m128 b) {
+ // Expects that the third argument in LLVM IR is immediate expression
+ // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 13)
+ return _mm_cmp_ss(a, b, _CMP_GE_OS);
+}
diff --git a/clang/test/CodeGen/avx-shuffle-builtins.c b/clang/test/CodeGen/avx-shuffle-builtins.c
new file mode 100644
index 0000000..d071f82
--- /dev/null
+++ b/clang/test/CodeGen/avx-shuffle-builtins.c
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +avx -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <immintrin.h>
+
+//
+// Test LLVM IR codegen of shuffle instructions
+//
+
+__m256 x(__m256 a, __m256 b) {
+ // Check if the mask is correct
+ // CHECK: shufflevector{{.*}}<i32 3, i32 2, i32 8, i32 11, i32 7, i32 6, i32 12, i32 15>
+ return _mm256_shuffle_ps(a, b, 203);
+}
+
+__m128d test_mm_permute_pd(__m128d a) {
+ // Check if the mask is correct
+ // CHECK: shufflevector{{.*}}<i32 1, i32 0>
+ return _mm_permute_pd(a, 1);
+}
+
+__m256d test_mm256_permute_pd(__m256d a) {
+ // Check if the mask is correct
+ // CHECK: shufflevector{{.*}}<i32 1, i32 0, i32 3, i32 2>
+ return _mm256_permute_pd(a, 5);
+}
+
+__m128 test_mm_permute_ps(__m128 a) {
+ // Check if the mask is correct
+ // CHECK: shufflevector{{.*}}<i32 3, i32 2, i32 1, i32 0>
+ return _mm_permute_ps(a, 0x1b);
+}
+
+// Test case for PR12401
+__m128 test_mm_permute_ps2(__m128 a) {
+ // Check if the mask is correct
+ // CHECK: shufflevector{{.*}}<i32 2, i32 1, i32 2, i32 3>
+ return _mm_permute_ps(a, 0xe6);
+}
+
+__m256 test_mm256_permute_ps(__m256 a) {
+ // Check if the mask is correct
+ // CHECK: shufflevector{{.*}}<i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>
+ return _mm256_permute_ps(a, 0x1b);
+}
+
+__m256d test_mm256_permute2f128_pd(__m256d a, __m256d b) {
+ // Check if the mask is correct
+ // CHECK: @llvm.x86.avx.vperm2f128.pd.256
+ return _mm256_permute2f128_pd(a, b, 0x31);
+}
+
+__m256 test_mm256_permute2f128_ps(__m256 a, __m256 b) {
+ // Check if the mask is correct
+ // CHECK: @llvm.x86.avx.vperm2f128.ps.256
+ return _mm256_permute2f128_ps(a, b, 0x13);
+}
+
+__m256i test_mm256_permute2f128_si256(__m256i a, __m256i b) {
+ // Check if the mask is correct
+ // CHECK: @llvm.x86.avx.vperm2f128.si.256
+ return _mm256_permute2f128_si256(a, b, 0x20);
+}
diff --git a/clang/test/CodeGen/avx2-builtins.c b/clang/test/CodeGen/avx2-builtins.c
new file mode 100644
index 0000000..7d166b5
--- /dev/null
+++ b/clang/test/CodeGen/avx2-builtins.c
@@ -0,0 +1,782 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +avx2 -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <immintrin.h>
+
+__m256i test_mm256_mpsadbw_epu8(__m256i x, __m256i y) {
+ // CHECK: @llvm.x86.avx2.mpsadbw({{.*}}, {{.*}}, i32 3)
+ return _mm256_mpsadbw_epu8(x, y, 3);
+}
+
+__m256i test_mm256_abs_epi8(__m256i a) {
+ // CHECK: @llvm.x86.avx2.pabs.b
+ return _mm256_abs_epi8(a);
+}
+
+__m256i test_mm256_abs_epi16(__m256i a) {
+ // CHECK: @llvm.x86.avx2.pabs.w
+ return _mm256_abs_epi16(a);
+}
+
+__m256i test_mm256_abs_epi32(__m256i a) {
+ // CHECK: @llvm.x86.avx2.pabs.d
+ return _mm256_abs_epi32(a);
+}
+
+__m256i test_mm256_packs_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.packsswb
+ return _mm256_packs_epi16(a, b);
+}
+
+__m256i test_mm256_packs_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.packssdw
+ return _mm256_packs_epi32(a, b);
+}
+
+__m256i test_mm256_packs_epu16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.packuswb
+ return _mm256_packus_epi16(a, b);
+}
+
+__m256i test_mm256_packs_epu32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.packusdw
+ return _mm256_packus_epi32(a, b);
+}
+
+__m256i test_mm256_add_epi8(__m256i a, __m256i b) {
+ // CHECK: add <32 x i8>
+ return _mm256_add_epi8(a, b);
+}
+
+__m256i test_mm256_add_epi16(__m256i a, __m256i b) {
+ // CHECK: add <16 x i16>
+ return _mm256_add_epi16(a, b);
+}
+
+__m256i test_mm256_add_epi32(__m256i a, __m256i b) {
+ // CHECK: add <8 x i32>
+ return _mm256_add_epi32(a, b);
+}
+
+__m256i test_mm256_add_epi64(__m256i a, __m256i b) {
+ // CHECK: add <4 x i64>
+ return _mm256_add_epi64(a, b);
+}
+
+__m256i test_mm256_adds_epi8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.padds.b
+ return _mm256_adds_epi8(a, b);
+}
+
+__m256i test_mm256_adds_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.padds.w
+ return _mm256_adds_epi16(a, b);
+}
+
+__m256i test_mm256_adds_epu8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.paddus.b
+ return _mm256_adds_epu8(a, b);
+}
+
+__m256i test_mm256_adds_epu16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.paddus.w
+ return _mm256_adds_epu16(a, b);
+}
+
+__m256i test_mm256_alignr_epi8(__m256i a, __m256i b) {
+ // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 32, i32 33, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 48, i32 49>
+ return _mm256_alignr_epi8(a, b, 2);
+}
+
+__m256i test2_mm256_alignr_epi8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psrl.dq({{.*}}, i32 8)
+ return _mm256_alignr_epi8(a, b, 17);
+}
+
+__m256i test_mm256_sub_epi8(__m256i a, __m256i b) {
+ // CHECK: sub <32 x i8>
+ return _mm256_sub_epi8(a, b);
+}
+
+__m256i test_mm256_sub_epi16(__m256i a, __m256i b) {
+ // CHECK: sub <16 x i16>
+ return _mm256_sub_epi16(a, b);
+}
+
+__m256i test_mm256_sub_epi32(__m256i a, __m256i b) {
+ // CHECK: sub <8 x i32>
+ return _mm256_sub_epi32(a, b);
+}
+
+__m256i test_mm256_sub_epi64(__m256i a, __m256i b) {
+ // CHECK: sub <4 x i64>
+ return _mm256_sub_epi64(a, b);
+}
+
+__m256i test_mm256_subs_epi8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psubs.b
+ return _mm256_subs_epi8(a, b);
+}
+
+__m256i test_mm256_subs_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psubs.w
+ return _mm256_subs_epi16(a, b);
+}
+
+__m256i test_mm256_subs_epu8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psubus.b
+ return _mm256_subs_epu8(a, b);
+}
+
+__m256i test_mm256_subs_epu16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psubus.w
+ return _mm256_subs_epu16(a, b);
+}
+
+__m256i test_mm256_and_si256(__m256i a, __m256i b) {
+ // CHECK: and <4 x i64>
+ return _mm256_and_si256(a, b);
+}
+
+__m256i test_mm256_andnot_si256(__m256i a, __m256i b) {
+ // CHECK: xor <4 x i64>
+ // CHECK: and <4 x i64>
+ return _mm256_andnot_si256(a, b);
+}
+
+__m256i test_mm256_or_si256(__m256i a, __m256i b) {
+ // CHECK: or <4 x i64>
+ return _mm256_or_si256(a, b);
+}
+
+__m256i test_mm256_xor_si256(__m256i a, __m256i b) {
+ // CHECK: xor <4 x i64>
+ return _mm256_xor_si256(a, b);
+}
+
+__m256i test_mm256_avg_epu8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pavg.b
+ return _mm256_avg_epu8(a, b);
+}
+
+__m256i test_mm256_avg_epu16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pavg.w
+ return _mm256_avg_epu16(a, b);
+}
+
+__m256i test_mm256_blendv_epi8(__m256i a, __m256i b, __m256i m) {
+ // CHECK: @llvm.x86.avx2.pblendvb
+ return _mm256_blendv_epi8(a, b, m);
+}
+
+__m256i test_mm256_blend_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pblendw(<16 x i16> %{{.*}}, <16 x i16> %{{.*}}, i32 2)
+ return _mm256_blend_epi16(a, b, 2);
+}
+
+__m256i test_mm256_cmpeq_epi8(__m256i a, __m256i b) {
+ // CHECK: icmp eq <32 x i8>
+ return _mm256_cmpeq_epi8(a, b);
+}
+
+__m256i test_mm256_cmpeq_epi16(__m256i a, __m256i b) {
+ // CHECK: icmp eq <16 x i16>
+ return _mm256_cmpeq_epi16(a, b);
+}
+
+__m256i test_mm256_cmpeq_epi32(__m256i a, __m256i b) {
+ // CHECK: icmp eq <8 x i32>
+ return _mm256_cmpeq_epi32(a, b);
+}
+
+__m256i test_mm256_cmpeq_epi64(__m256i a, __m256i b) {
+ // CHECK: icmp eq <4 x i64>
+ return _mm256_cmpeq_epi64(a, b);
+}
+
+__m256i test_mm256_cmpgt_epi8(__m256i a, __m256i b) {
+ // CHECK: icmp sgt <32 x i8>
+ return _mm256_cmpgt_epi8(a, b);
+}
+
+__m256i test_mm256_cmpgt_epi16(__m256i a, __m256i b) {
+ // CHECK: icmp sgt <16 x i16>
+ return _mm256_cmpgt_epi16(a, b);
+}
+
+__m256i test_mm256_cmpgt_epi32(__m256i a, __m256i b) {
+ // CHECK: icmp sgt <8 x i32>
+ return _mm256_cmpgt_epi32(a, b);
+}
+
+__m256i test_mm256_cmpgt_epi64(__m256i a, __m256i b) {
+ // CHECK: icmp sgt <4 x i64>
+ return _mm256_cmpgt_epi64(a, b);
+}
+
+__m256i test_mm256_hadd_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.phadd.w
+ return _mm256_hadd_epi16(a, b);
+}
+
+__m256i test_mm256_hadd_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.phadd.d
+ return _mm256_hadd_epi32(a, b);
+}
+
+__m256i test_mm256_hadds_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.phadd.sw
+ return _mm256_hadds_epi16(a, b);
+}
+
+__m256i test_mm256_hsub_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.phsub.w
+ return _mm256_hsub_epi16(a, b);
+}
+
+__m256i test_mm256_hsub_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.phsub.d
+ return _mm256_hsub_epi32(a, b);
+}
+
+__m256i test_mm256_hsubs_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.phsub.sw
+ return _mm256_hsubs_epi16(a, b);
+}
+
+__m256i test_mm256_maddubs_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmadd.ub.sw
+ return _mm256_maddubs_epi16(a, b);
+}
+
+__m256i test_mm256_madd_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmadd.wd
+ return _mm256_madd_epi16(a, b);
+}
+
+__m256i test_mm256_max_epi8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmaxs.b
+ return _mm256_max_epi8(a, b);
+}
+
+__m256i test_mm256_max_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmaxs.w
+ return _mm256_max_epi16(a, b);
+}
+
+__m256i test_mm256_max_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmaxs.d
+ return _mm256_max_epi32(a, b);
+}
+
+__m256i test_mm256_max_epu8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmaxu.b
+ return _mm256_max_epu8(a, b);
+}
+
+__m256i test_mm256_max_epu16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmaxu.w
+ return _mm256_max_epu16(a, b);
+}
+
+__m256i test_mm256_max_epu32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmaxu.d
+ return _mm256_max_epu32(a, b);
+}
+
+__m256i test_mm256_min_epi8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmins.b
+ return _mm256_min_epi8(a, b);
+}
+
+__m256i test_mm256_min_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmins.w
+ return _mm256_min_epi16(a, b);
+}
+
+__m256i test_mm256_min_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmins.d
+ return _mm256_min_epi32(a, b);
+}
+
+__m256i test_mm256_min_epu8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pminu.b
+ return _mm256_min_epu8(a, b);
+}
+
+__m256i test_mm256_min_epu16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pminu.w
+ return _mm256_min_epu16(a, b);
+}
+
+__m256i test_mm256_min_epu32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pminu.d
+ return _mm256_min_epu32(a, b);
+}
+
+int test_mm256_movemask_epi8(__m256i a) {
+ // CHECK: @llvm.x86.avx2.pmovmskb
+ return _mm256_movemask_epi8(a);
+}
+
+__m256i test_mm256_cvtepi8_epi16(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovsxbw
+ return _mm256_cvtepi8_epi16(a);
+}
+
+__m256i test_mm256_cvtepi8_epi32(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovsxbd
+ return _mm256_cvtepi8_epi32(a);
+}
+
+__m256i test_mm256_cvtepi8_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovsxbq
+ return _mm256_cvtepi8_epi64(a);
+}
+
+__m256i test_mm256_cvtepi16_epi32(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovsxwd
+ return _mm256_cvtepi16_epi32(a);
+}
+
+__m256i test_mm256_cvtepi16_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovsxwq
+ return _mm256_cvtepi16_epi64(a);
+}
+
+__m256i test_mm256_cvtepi32_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovsxdq
+ return _mm256_cvtepi32_epi64(a);
+}
+
+__m256i test_mm256_cvtepu8_epi16(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovzxbw
+ return _mm256_cvtepu8_epi16(a);
+}
+
+__m256i test_mm256_cvtepu8_epi32(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovzxbd
+ return _mm256_cvtepu8_epi32(a);
+}
+
+__m256i test_mm256_cvtepu8_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovzxbq
+ return _mm256_cvtepu8_epi64(a);
+}
+
+__m256i test_mm256_cvtepu16_epi32(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovzxwd
+ return _mm256_cvtepu16_epi32(a);
+}
+
+__m256i test_mm256_cvtepu16_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovzxwq
+ return _mm256_cvtepu16_epi64(a);
+}
+
+__m256i test_mm256_cvtepu32_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovzxdq
+ return _mm256_cvtepu32_epi64(a);
+}
+
+__m256i test_mm256_mul_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmul.dq
+ return _mm256_mul_epi32(a, b);
+}
+
+__m256i test_mm256_mulhrs_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmul.hr.sw
+ return _mm256_mulhrs_epi16(a, b);
+}
+
+__m256i test_mm256_mulhi_epu16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmulhu.w
+ return _mm256_mulhi_epu16(a, b);
+}
+
+__m256i test_mm256_mulhi_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmulh.w
+ return _mm256_mulhi_epi16(a, b);
+}
+
+__m256i test_mm256_mullo_epi16(__m256i a, __m256i b) {
+ // CHECK: mul <16 x i16>
+ return _mm256_mullo_epi16(a, b);
+}
+
+__m256i test_mm256_mullo_epi32(__m256i a, __m256i b) {
+ // CHECK: mul <8 x i32>
+ return _mm256_mullo_epi32(a, b);
+}
+
+__m256i test_mm256_mul_epu32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmulu.dq
+ return _mm256_mul_epu32(a, b);
+}
+
+__m256i test_mm256_shuffle_epi8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pshuf.b
+ return _mm256_shuffle_epi8(a, b);
+}
+
+__m256i test_mm256_shuffle_epi32(__m256i a) {
+ // CHECK: shufflevector <8 x i32> %{{.*}}, <8 x i32> undef, <8 x i32> <i32 3, i32 3, i32 0, i32 0, i32 7, i32 7, i32 4, i32 4>
+ return _mm256_shuffle_epi32(a, 15);
+}
+
+__m256i test_mm256_shufflehi_epi16(__m256i a) {
+ // CHECK: shufflevector <16 x i16> %{{.*}}, <16 x i16> undef, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 7, i32 6, i32 6, i32 5, i32 8, i32 9, i32 10, i32 11, i32 15, i32 14, i32 14, i32 13>
+ return _mm256_shufflehi_epi16(a, 107);
+}
+
+__m256i test_mm256_shufflelo_epi16(__m256i a) {
+ // CHECK: shufflevector <16 x i16> %{{.*}}, <16 x i16> undef, <16 x i32> <i32 3, i32 0, i32 1, i32 1, i32 4, i32 5, i32 6, i32 7, i32 11, i32 8, i32 9, i32 9, i32 12, i32 13, i32 14, i32 15>
+ return _mm256_shufflelo_epi16(a, 83);
+}
+
+__m256i test_mm256_sign_epi8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psign.b
+ return _mm256_sign_epi8(a, b);
+}
+
+__m256i test_mm256_sign_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psign.w
+ return _mm256_sign_epi16(a, b);
+}
+
+__m256i test_mm256_sign_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psign.d
+ return _mm256_sign_epi32(a, b);
+}
+
+__m256i test_mm256_slli_si256(__m256i a) {
+ // CHECK: @llvm.x86.avx2.psll.dq
+ return _mm256_slli_si256(a, 3);
+}
+
+__m256i test_mm256_slli_epi16(__m256i a) {
+ // CHECK: @llvm.x86.avx2.pslli.w
+ return _mm256_slli_epi16(a, 3);
+}
+
+__m256i test_mm256_sll_epi16(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psll.w
+ return _mm256_sll_epi16(a, b);
+}
+
+__m256i test_mm256_slli_epi32(__m256i a) {
+ // CHECK: @llvm.x86.avx2.pslli.d
+ return _mm256_slli_epi32(a, 3);
+}
+
+__m256i test_mm256_sll_epi32(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psll.d
+ return _mm256_sll_epi32(a, b);
+}
+
+__m256i test_mm256_slli_epi64(__m256i a) {
+ // CHECK: @llvm.x86.avx2.pslli.q
+ return _mm256_slli_epi64(a, 3);
+}
+
+__m256i test_mm256_sll_epi64(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psll.q
+ return _mm256_sll_epi64(a, b);
+}
+
+__m256i test_mm256_srai_epi16(__m256i a) {
+ // CHECK: @llvm.x86.avx2.psrai.w
+ return _mm256_srai_epi16(a, 3);
+}
+
+__m256i test_mm256_sra_epi16(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psra.w
+ return _mm256_sra_epi16(a, b);
+}
+
+__m256i test_mm256_srai_epi32(__m256i a) {
+ // CHECK: @llvm.x86.avx2.psrai.d
+ return _mm256_srai_epi32(a, 3);
+}
+
+__m256i test_mm256_sra_epi32(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psra.d
+ return _mm256_sra_epi32(a, b);
+}
+
+__m256i test_mm256_srli_si256(__m256i a) {
+ // CHECK: @llvm.x86.avx2.psrl.dq
+ return _mm256_srli_si256(a, 3);
+}
+
+__m256i test_mm256_srli_epi16(__m256i a) {
+ // CHECK: @llvm.x86.avx2.psrli.w
+ return _mm256_srli_epi16(a, 3);
+}
+
+__m256i test_mm256_srl_epi16(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psrl.w
+ return _mm256_srl_epi16(a, b);
+}
+
+__m256i test_mm256_srli_epi32(__m256i a) {
+ // CHECK: @llvm.x86.avx2.psrli.d
+ return _mm256_srli_epi32(a, 3);
+}
+
+__m256i test_mm256_srl_epi32(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psrl.d
+ return _mm256_srl_epi32(a, b);
+}
+
+__m256i test_mm256_srli_epi64(__m256i a) {
+ // CHECK: @llvm.x86.avx2.psrli.q
+ return _mm256_srli_epi64(a, 3);
+}
+
+__m256i test_mm256_srl_epi64(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psrl.q
+ return _mm256_srl_epi64(a, b);
+}
+
+__m256i test_mm256_unpackhi_epi8(__m256i a, __m256i b) {
+ // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i32> <i32 8, i32 40, i32 9, i32 41, i32 10, i32 42, i32 11, i32 43, i32 12, i32 44, i32 13, i32 45, i32 14, i32 46, i32 15, i32 47, i32 24, i32 56, i32 25, i32 57, i32 26, i32 58, i32 27, i32 59, i32 28, i32 60, i32 29, i32 61, i32 30, i32 62, i32 31, i32 63>
+ return _mm256_unpackhi_epi8(a, b);
+}
+
+__m256i test_mm256_unpackhi_epi16(__m256i a, __m256i b) {
+ // CHECK: shufflevector <16 x i16> %{{.*}}, <16 x i16> %{{.*}}, <16 x i32> <i32 4, i32 20, i32 5, i32 21, i32 6, i32 22, i32 7, i32 23, i32 12, i32 28, i32 13, i32 29, i32 14, i32 30, i32 15, i32 31>
+ return _mm256_unpackhi_epi16(a, b);
+}
+
+__m256i test_mm256_unpackhi_epi32(__m256i a, __m256i b) {
+ // CHECK: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> <i32 2, i32 10, i32 3, i32 11, i32 6, i32 14, i32 7, i32 15>
+ return _mm256_unpackhi_epi32(a, b);
+}
+
+__m256i test_mm256_unpackhi_epi64(__m256i a, __m256i b) {
+ // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> <i32 1, i32 5, i32 3, i32 7>
+ return _mm256_unpackhi_epi64(a, b);
+}
+
+__m256i test_mm256_unpacklo_epi8(__m256i a, __m256i b) {
+ // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i32> <i32 0, i32 32, i32 1, i32 33, i32 2, i32 34, i32 3, i32 35, i32 4, i32 36, i32 5, i32 37, i32 6, i32 38, i32 7, i32 39, i32 16, i32 48, i32 17, i32 49, i32 18, i32 50, i32 19, i32 51, i32 20, i32 52, i32 21, i32 53, i32 22, i32 54, i32 23, i32 55>
+ return _mm256_unpacklo_epi8(a, b);
+}
+
+__m256i test_mm256_unpacklo_epi16(__m256i a, __m256i b) {
+ // CHECK: shufflevector <16 x i16> %{{.*}}, <16 x i16> %{{.*}}, <16 x i32> <i32 0, i32 16, i32 1, i32 17, i32 2, i32 18, i32 3, i32 19, i32 8, i32 24, i32 9, i32 25, i32 10, i32 26, i32 11, i32 27>
+ return _mm256_unpacklo_epi16(a, b);
+}
+
+__m256i test_mm256_unpacklo_epi32(__m256i a, __m256i b) {
+ // CHECK: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> <i32 0, i32 8, i32 1, i32 9, i32 4, i32 12, i32 5, i32 13>
+ return _mm256_unpacklo_epi32(a, b);
+}
+
+__m256i test_mm256_unpacklo_epi64(__m256i a, __m256i b) {
+ // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> <i32 0, i32 4, i32 2, i32 6>
+ return _mm256_unpacklo_epi64(a, b);
+}
+
+__m256i test_mm256_stream_load_si256(__m256i *a) {
+ // CHECK: @llvm.x86.avx2.movntdqa
+ return _mm256_stream_load_si256(a);
+}
+
+__m128 test_mm_broadcastss_ps(__m128 a) {
+ // CHECK: @llvm.x86.avx2.vbroadcast.ss.ps
+ return _mm_broadcastss_ps(a);
+}
+
+__m256 test_mm256_broadcastss_ps(__m128 a) {
+ // CHECK: @llvm.x86.avx2.vbroadcast.ss.ps.256
+ return _mm256_broadcastss_ps(a);
+}
+
+__m256d test_mm256_broadcastsd_pd(__m128d a) {
+ // check: @llvm.x86.avx2.vbroadcast.sd.pd.256
+ return _mm256_broadcastsd_pd(a);
+}
+
+__m256i test_mm_broadcastsi128_si256(__m128i *a) {
+ // CHECK: @llvm.x86.avx2.vbroadcasti128
+ return _mm_broadcastsi128_si256(a);
+}
+
+__m128i test_mm_blend_epi32(__m128i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.pblendd.128
+ return _mm_blend_epi32(a, b, 57);
+}
+
+__m256i test_mm256_blend_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pblendd.256
+ return _mm256_blend_epi32(a, b, 57);
+}
+
+__m256i test_mm256_broadcastb_epi8(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastb.256
+ return _mm256_broadcastb_epi8(a);
+}
+
+__m256i test_mm256_broadcastw_epi16(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastw.256
+ return _mm256_broadcastw_epi16(a);
+}
+
+__m256i test_mm256_broadcastd_epi32(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastd.256
+ return _mm256_broadcastd_epi32(a);
+}
+
+__m256i test_mm256_broadcastq_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastq.256
+ return _mm256_broadcastq_epi64(a);
+}
+
+__m128i test_mm_broadcastb_epi8(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastb.128
+ return _mm_broadcastb_epi8(a);
+}
+
+__m128i test_mm_broadcastw_epi16(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastw.128
+ return _mm_broadcastw_epi16(a);
+}
+
+__m128i test_mm_broadcastd_epi32(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastd.128
+ return _mm_broadcastd_epi32(a);
+}
+
+__m128i test_mm_broadcastq_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastq.128
+ return _mm_broadcastq_epi64(a);
+}
+
+__m256i test_mm256_permutevar8x32_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.permd
+ return _mm256_permutevar8x32_epi32(a, b);
+}
+
+__m256d test_mm256_permute4x64_pd(__m256d a) {
+ // CHECK: shufflevector{{.*}}<i32 1, i32 2, i32 1, i32 0>
+ return _mm256_permute4x64_pd(a, 25);
+}
+
+__m256 test_mm256_permutevar8x32_ps(__m256 a, __m256 b) {
+ // CHECK: @llvm.x86.avx2.permps
+ return _mm256_permutevar8x32_ps(a, b);
+}
+
+__m256i test_mm256_permute4x64_epi64(__m256i a) {
+ // CHECK: shufflevector{{.*}}<i32 3, i32 0, i32 2, i32 0>
+ return _mm256_permute4x64_epi64(a, 35);
+}
+
+__m256i test_mm256_permute2x128_si256(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.vperm2i128
+ return _mm256_permute2x128_si256(a, b, 0x31);
+}
+
+__m128i test_mm256_extracti128_si256(__m256i a) {
+ // CHECK: @llvm.x86.avx2.vextracti128
+ return _mm256_extracti128_si256(a, 1);
+}
+
+__m256i test_mm256_inserti128_si256(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.vinserti128
+ return _mm256_inserti128_si256(a, b, 1);
+}
+
+__m256i test_mm256_maskload_epi32(int const *a, __m256i m) {
+ // CHECK: @llvm.x86.avx2.maskload.d.256
+ return _mm256_maskload_epi32(a, m);
+}
+
+__m256i test_mm256_maskload_epi64(long long const *a, __m256i m) {
+ // CHECK: @llvm.x86.avx2.maskload.q.256
+ return _mm256_maskload_epi64(a, m);
+}
+
+__m128i test_mm_maskload_epi32(int const *a, __m128i m) {
+ // CHECK: @llvm.x86.avx2.maskload.d
+ return _mm_maskload_epi32(a, m);
+}
+
+__m128i test_mm_maskload_epi64(long long const *a, __m128i m) {
+ // CHECK: @llvm.x86.avx2.maskload.q
+ return _mm_maskload_epi64(a, m);
+}
+
+void test_mm256_maskstore_epi32(int *a, __m256i m, __m256i b) {
+ // CHECK: @llvm.x86.avx2.maskstore.d.256
+ _mm256_maskstore_epi32(a, m, b);
+}
+
+void test_mm256_maskstore_epi64(long long *a, __m256i m, __m256i b) {
+ // CHECK: @llvm.x86.avx2.maskstore.q.256
+ _mm256_maskstore_epi64(a, m, b);
+}
+
+void test_mm_maskstore_epi32(int *a, __m128i m, __m128i b) {
+ // CHECK: @llvm.x86.avx2.maskstore.d
+ _mm_maskstore_epi32(a, m, b);
+}
+
+void test_mm_maskstore_epi64(long long *a, __m128i m, __m128i b) {
+ // CHECK: @llvm.x86.avx2.maskstore.q
+ _mm_maskstore_epi64(a, m, b);
+}
+
+__m256i test_mm256_sllv_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psllv.d.256
+ return _mm256_sllv_epi32(a, b);
+}
+
+__m128i test_mm_sllv_epi32(__m128i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psllv.d
+ return _mm_sllv_epi32(a, b);
+}
+
+__m256i test_mm256_sllv_epi64(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psllv.q.256
+ return _mm256_sllv_epi64(a, b);
+}
+
+__m128i test_mm_sllv_epi64(__m128i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psllv.q
+ return _mm_sllv_epi64(a, b);
+}
+
+__m256i test_mm256_srav_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psrav.d.256
+ return _mm256_srav_epi32(a, b);
+}
+
+__m128i test_mm_srav_epi32(__m128i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psrav.d
+ return _mm_srav_epi32(a, b);
+}
+
+__m256i test_mm256_srlv_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psrlv.d.256
+ return _mm256_srlv_epi32(a, b);
+}
+
+__m128i test_mm_srlv_epi32(__m128i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psrlv.d
+ return _mm_srlv_epi32(a, b);
+}
+
+__m256i test_mm256_srlv_epi64(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psrlv.q.256
+ return _mm256_srlv_epi64(a, b);
+}
+
+__m128i test_mm_srlv_epi64(__m128i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psrlv.q
+ return _mm_srlv_epi64(a, b);
+}
diff --git a/clang/test/CodeGen/bitfield-2.c b/clang/test/CodeGen/bitfield-2.c
new file mode 100644
index 0000000..69ed5b1
--- /dev/null
+++ b/clang/test/CodeGen/bitfield-2.c
@@ -0,0 +1,368 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -O3 -o %t.opt.ll %s \
+// RUN: -fdump-record-layouts 2> %t.dump.txt
+// RUN: FileCheck -check-prefix=CHECK-RECORD < %t.dump.txt %s
+// RUN: FileCheck -check-prefix=CHECK-OPT < %t.opt.ll %s
+
+/****/
+
+// Check that we don't read off the end a packed 24-bit structure.
+// PR6176
+
+// CHECK-RECORD: *** Dumping IRgen Record Layout
+// CHECK-RECORD: Record: struct s0
+// CHECK-RECORD: Layout: <CGRecordLayout
+// CHECK-RECORD: LLVMType:%struct.s0 = type <{ [3 x i8] }>
+// CHECK-RECORD: IsZeroInitializable:1
+// CHECK-RECORD: BitFields:[
+// CHECK-RECORD: <CGBitFieldInfo Size:24 IsSigned:1
+// CHECK-RECORD: NumComponents:2 Components: [
+// CHECK-RECORD: <AccessInfo FieldIndex:0 FieldByteOffset:0 FieldBitStart:0 AccessWidth:16
+// CHECK-RECORD: AccessAlignment:1 TargetBitOffset:0 TargetBitWidth:16>
+// CHECK-RECORD: <AccessInfo FieldIndex:0 FieldByteOffset:2 FieldBitStart:0 AccessWidth:8
+// CHECK-RECORD: AccessAlignment:1 TargetBitOffset:16 TargetBitWidth:8>
+struct __attribute((packed)) s0 {
+ int f0 : 24;
+};
+
+struct s0 g0 = { 0xdeadbeef };
+
+int f0_load(struct s0 *a0) {
+ int size_check[sizeof(struct s0) == 3 ? 1 : -1];
+ return a0->f0;
+}
+int f0_store(struct s0 *a0) {
+ return (a0->f0 = 1);
+}
+int f0_reload(struct s0 *a0) {
+ return (a0->f0 += 1);
+}
+
+// CHECK-OPT: define i64 @test_0()
+// CHECK-OPT: ret i64 1
+// CHECK-OPT: }
+unsigned long long test_0() {
+ struct s0 g0 = { 0xdeadbeef };
+ unsigned long long res = 0;
+ res ^= g0.f0;
+ res ^= f0_load(&g0) ^ f0_store(&g0) ^ f0_reload(&g0);
+ res ^= g0.f0;
+ return res;
+}
+
+/****/
+
+// PR5591
+
+// CHECK-RECORD: *** Dumping IRgen Record Layout
+// CHECK-RECORD: Record: struct s1
+// CHECK-RECORD: Layout: <CGRecordLayout
+// CHECK-RECORD: LLVMType:%struct.s1 = type <{ [2 x i8], i8 }>
+// CHECK-RECORD: IsZeroInitializable:1
+// CHECK-RECORD: BitFields:[
+// CHECK-RECORD: <CGBitFieldInfo Size:10 IsSigned:1
+// CHECK-RECORD: NumComponents:1 Components: [
+// CHECK-RECORD: <AccessInfo FieldIndex:0 FieldByteOffset:0 FieldBitStart:0 AccessWidth:16
+// CHECK-RECORD: AccessAlignment:1 TargetBitOffset:0 TargetBitWidth:10>
+// CHECK-RECORD: ]>
+// CHECK-RECORD: <CGBitFieldInfo Size:10 IsSigned:1
+// CHECK-RECORD: NumComponents:2 Components: [
+// CHECK-RECORD: <AccessInfo FieldIndex:0 FieldByteOffset:0 FieldBitStart:10 AccessWidth:16
+// CHECK-RECORD: AccessAlignment:1 TargetBitOffset:0 TargetBitWidth:6>
+// CHECK-RECORD: <AccessInfo FieldIndex:0 FieldByteOffset:2 FieldBitStart:0 AccessWidth:8
+// CHECK-RECORD: AccessAlignment:1 TargetBitOffset:6 TargetBitWidth:4>
+
+#pragma pack(push)
+#pragma pack(1)
+struct __attribute((packed)) s1 {
+ signed f0 : 10;
+ signed f1 : 10;
+};
+#pragma pack(pop)
+
+struct s1 g1 = { 0xdeadbeef, 0xdeadbeef };
+
+int f1_load(struct s1 *a0) {
+ int size_check[sizeof(struct s1) == 3 ? 1 : -1];
+ return a0->f1;
+}
+int f1_store(struct s1 *a0) {
+ return (a0->f1 = 1234);
+}
+int f1_reload(struct s1 *a0) {
+ return (a0->f1 += 1234);
+}
+
+// CHECK-OPT: define i64 @test_1()
+// CHECK-OPT: ret i64 210
+// CHECK-OPT: }
+unsigned long long test_1() {
+ struct s1 g1 = { 0xdeadbeef, 0xdeadbeef };
+ unsigned long long res = 0;
+ res ^= g1.f0 ^ g1.f1;
+ res ^= f1_load(&g1) ^ f1_store(&g1) ^ f1_reload(&g1);
+ res ^= g1.f0 ^ g1.f1;
+ return res;
+}
+
+/****/
+
+// Check that we don't access beyond the bounds of a union.
+//
+// PR5567
+
+// CHECK-RECORD: *** Dumping IRgen Record Layout
+// CHECK-RECORD: Record: union u2
+// CHECK-RECORD: Layout: <CGRecordLayout
+// CHECK-RECORD: LLVMType:%union.u2 = type <{ i8 }>
+// CHECK-RECORD: IsZeroInitializable:1
+// CHECK-RECORD: BitFields:[
+// CHECK-RECORD: <CGBitFieldInfo Size:3 IsSigned:0
+// CHECK-RECORD: NumComponents:1 Components: [
+// CHECK-RECORD: <AccessInfo FieldIndex:0 FieldByteOffset:0 FieldBitStart:0 AccessWidth:8
+// CHECK-RECORD: AccessAlignment:1 TargetBitOffset:0 TargetBitWidth:3>
+
+union __attribute__((packed)) u2 {
+ unsigned long long f0 : 3;
+};
+
+union u2 g2 = { 0xdeadbeef };
+
+int f2_load(union u2 *a0) {
+ return a0->f0;
+}
+int f2_store(union u2 *a0) {
+ return (a0->f0 = 1234);
+}
+int f2_reload(union u2 *a0) {
+ return (a0->f0 += 1234);
+}
+
+// CHECK-OPT: define i64 @test_2()
+// CHECK-OPT: ret i64 2
+// CHECK-OPT: }
+unsigned long long test_2() {
+ union u2 g2 = { 0xdeadbeef };
+ unsigned long long res = 0;
+ res ^= g2.f0;
+ res ^= f2_load(&g2) ^ f2_store(&g2) ^ f2_reload(&g2);
+ res ^= g2.f0;
+ return res;
+}
+
+/***/
+
+// PR5039
+
+struct s3 {
+ long long f0 : 32;
+ long long f1 : 32;
+};
+
+struct s3 g3 = { 0xdeadbeef, 0xdeadbeef };
+
+int f3_load(struct s3 *a0) {
+ a0->f0 = 1;
+ return a0->f0;
+}
+int f3_store(struct s3 *a0) {
+ a0->f0 = 1;
+ return (a0->f0 = 1234);
+}
+int f3_reload(struct s3 *a0) {
+ a0->f0 = 1;
+ return (a0->f0 += 1234);
+}
+
+// CHECK-OPT: define i64 @test_3()
+// CHECK-OPT: ret i64 -559039940
+// CHECK-OPT: }
+unsigned long long test_3() {
+ struct s3 g3 = { 0xdeadbeef, 0xdeadbeef };
+ unsigned long long res = 0;
+ res ^= g3.f0 ^ g3.f1;
+ res ^= f3_load(&g3) ^ f3_store(&g3) ^ f3_reload(&g3);
+ res ^= g3.f0 ^ g3.f1;
+ return res;
+}
+
+/***/
+
+// This is a case where the bitfield access will straddle an alignment boundary
+// of its underlying type.
+
+struct s4 {
+ unsigned f0 : 16;
+ unsigned f1 : 28 __attribute__ ((packed));
+};
+
+struct s4 g4 = { 0xdeadbeef, 0xdeadbeef };
+
+int f4_load(struct s4 *a0) {
+ return a0->f0 ^ a0->f1;
+}
+int f4_store(struct s4 *a0) {
+ return (a0->f0 = 1234) ^ (a0->f1 = 5678);
+}
+int f4_reload(struct s4 *a0) {
+ return (a0->f0 += 1234) ^ (a0->f1 += 5678);
+}
+
+// CHECK-OPT: define i64 @test_4()
+// CHECK-OPT: ret i64 4860
+// CHECK-OPT: }
+unsigned long long test_4() {
+ struct s4 g4 = { 0xdeadbeef, 0xdeadbeef };
+ unsigned long long res = 0;
+ res ^= g4.f0 ^ g4.f1;
+ res ^= f4_load(&g4) ^ f4_store(&g4) ^ f4_reload(&g4);
+ res ^= g4.f0 ^ g4.f1;
+ return res;
+}
+
+/***/
+
+struct s5 {
+ unsigned f0 : 2;
+ _Bool f1 : 1;
+ _Bool f2 : 1;
+};
+
+struct s5 g5 = { 0xdeadbeef, 0xdeadbeef };
+
+int f5_load(struct s5 *a0) {
+ return a0->f0 ^ a0->f1;
+}
+int f5_store(struct s5 *a0) {
+ return (a0->f0 = 0xF) ^ (a0->f1 = 0xF) ^ (a0->f2 = 0xF);
+}
+int f5_reload(struct s5 *a0) {
+ return (a0->f0 += 0xF) ^ (a0->f1 += 0xF) ^ (a0->f2 += 0xF);
+}
+
+// CHECK-OPT: define i64 @test_5()
+// CHECK-OPT: ret i64 2
+// CHECK-OPT: }
+unsigned long long test_5() {
+ struct s5 g5 = { 0xdeadbeef, 0xdeadbeef, 0xdeadbeef };
+ unsigned long long res = 0;
+ res ^= g5.f0 ^ g5.f1 ^ g5.f2;
+ res ^= f5_load(&g5) ^ f5_store(&g5) ^ f5_reload(&g5);
+ res ^= g5.f0 ^ g5.f1 ^ g5.f2;
+ return res;
+}
+
+/***/
+
+struct s6 {
+ _Bool f0 : 2;
+};
+
+struct s6 g6 = { 0xF };
+
+int f6_load(struct s6 *a0) {
+ return a0->f0;
+}
+int f6_store(struct s6 *a0) {
+ return a0->f0 = 0x0;
+}
+int f6_reload(struct s6 *a0) {
+ return (a0->f0 += 0xF);
+}
+
+// CHECK-OPT: define zeroext i1 @test_6()
+// CHECK-OPT: ret i1 true
+// CHECK-OPT: }
+_Bool test_6() {
+ struct s6 g6 = { 0xF };
+ unsigned long long res = 0;
+ res ^= g6.f0;
+ res ^= f6_load(&g6);
+ res ^= g6.f0;
+ return res;
+}
+
+/***/
+
+// Check that we compute the best alignment possible for each access.
+//
+// CHECK-RECORD: *** Dumping IRgen Record Layout
+// CHECK-RECORD: Record: struct s7
+// CHECK-RECORD: Layout: <CGRecordLayout
+// CHECK-RECORD: LLVMType:%struct.s7 = type { i32, i32, i32, i8, [3 x i8], [4 x i8], [12 x i8] }
+// CHECK-RECORD: IsZeroInitializable:1
+// CHECK-RECORD: BitFields:[
+// CHECK-RECORD: <CGBitFieldInfo Size:5 IsSigned:1
+// CHECK-RECORD: NumComponents:1 Components: [
+// CHECK-RECORD: <AccessInfo FieldIndex:0 FieldByteOffset:12 FieldBitStart:0 AccessWidth:32
+// CHECK-RECORD: AccessAlignment:4 TargetBitOffset:0 TargetBitWidth:5>
+// CHECK-RECORD: ]>
+// CHECK-RECORD: <CGBitFieldInfo Size:29 IsSigned:1
+// CHECK-RECORD: NumComponents:1 Components: [
+// CHECK-RECORD: <AccessInfo FieldIndex:0 FieldByteOffset:16 FieldBitStart:0 AccessWidth:32
+// CHECK-RECORD: AccessAlignment:16 TargetBitOffset:0 TargetBitWidth:29>
+
+struct __attribute__((aligned(16))) s7 {
+ int a, b, c;
+ int f0 : 5;
+ int f1 : 29;
+};
+
+int f7_load(struct s7 *a0) {
+ return a0->f0;
+}
+
+/***/
+
+// This is a case where we narrow the access width immediately.
+
+struct __attribute__((packed)) s8 {
+ char f0 : 4;
+ char f1;
+ int f2 : 4;
+ char f3 : 4;
+};
+
+struct s8 g8 = { 0xF };
+
+int f8_load(struct s8 *a0) {
+ return a0->f0 ^ a0 ->f2 ^ a0->f3;
+}
+int f8_store(struct s8 *a0) {
+ return (a0->f0 = 0xFD) ^ (a0->f2 = 0xFD) ^ (a0->f3 = 0xFD);
+}
+int f8_reload(struct s8 *a0) {
+ return (a0->f0 += 0xFD) ^ (a0->f2 += 0xFD) ^ (a0->f3 += 0xFD);
+}
+
+// CHECK-OPT: define i32 @test_8()
+// CHECK-OPT: ret i32 -3
+// CHECK-OPT: }
+unsigned test_8() {
+ struct s8 g8 = { 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef };
+ unsigned long long res = 0;
+ res ^= g8.f0 ^ g8.f2 ^ g8.f3;
+ res ^= f8_load(&g8) ^ f8_store(&g8) ^ f8_reload(&g8);
+ res ^= g8.f0 ^ g8.f2 ^ g8.f3;
+ return res;
+}
+
+/***/
+
+// This is another case where we narrow the access width immediately.
+//
+// <rdar://problem/7893760>
+
+struct __attribute__((packed)) s9 {
+ unsigned f0 : 7;
+ unsigned f1 : 7;
+ unsigned f2 : 7;
+ unsigned f3 : 7;
+ unsigned f4 : 7;
+ unsigned f5 : 7;
+ unsigned f6 : 7;
+ unsigned f7 : 7;
+};
+
+int f9_load(struct s9 *a0) {
+ return a0->f7;
+}
diff --git a/clang/test/CodeGen/bitfield-assign.c b/clang/test/CodeGen/bitfield-assign.c
new file mode 100644
index 0000000..b8ab613
--- /dev/null
+++ b/clang/test/CodeGen/bitfield-assign.c
@@ -0,0 +1,44 @@
+/* Check that the result of a bitfield assignment is properly
+ truncated and does not generate a redundant load. */
+
+/* Check that we get one load for each simple assign and two for the
+ compound assign (load the old value before the add then load again
+ to store back). Also check that our g0 pattern is good. */
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O0 -emit-llvm -o %t %s
+// RUN: grep 'load ' %t | count 5
+// RUN: grep "@g0" %t | count 4
+
+// Check that we got the right value.
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O3 -emit-llvm -o %t %s
+// RUN: grep 'load ' %t | count 0
+// RUN: grep "@g0" %t | count 0
+
+struct s0 {
+ int f0 : 2;
+ _Bool f1 : 1;
+ unsigned f2 : 2;
+};
+
+int g0();
+
+void f0(void) {
+ struct s0 s;
+ if ((s.f0 = 3) != -1) g0();
+}
+
+void f1(void) {
+ struct s0 s;
+ if ((s.f1 = 3) != 1) g0();
+}
+
+void f2(void) {
+ struct s0 s;
+ if ((s.f2 = 3) != 3) g0();
+}
+
+void f3(void) {
+ struct s0 s;
+ // Just check this one for load counts.
+ s.f0 += 3;
+}
+
diff --git a/clang/test/CodeGen/bitfield-init.c b/clang/test/CodeGen/bitfield-init.c
new file mode 100644
index 0000000..bee4e7d
--- /dev/null
+++ b/clang/test/CodeGen/bitfield-init.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+typedef struct { unsigned int i: 1; } c;
+const c d = { 1 };
+
+// PR2310
+struct Token {
+ unsigned n : 31;
+};
+void sqlite3CodeSubselect(){
+ struct Token one = { 1 };
+}
+
+typedef union T0 { char field0 : 2; } T0;
+T0 T0_values = { 0 };
diff --git a/clang/test/CodeGen/bitfield-promote.c b/clang/test/CodeGen/bitfield-promote.c
new file mode 100644
index 0000000..4c3292c
--- /dev/null
+++ b/clang/test/CodeGen/bitfield-promote.c
@@ -0,0 +1,18 @@
+// RUN: %clang -O3 -emit-llvm -S -o %t %s
+// RUN: grep 'ret i64 4294967292' %t | count 2
+// RUN: grep 'ret i64 -4' %t | count 1
+
+long long f0(void) {
+ struct { unsigned f0 : 32; } x = { 18 };
+ return (long long) (x.f0 - (int) 22);
+}
+
+long long f1(void) {
+ struct { unsigned f0 : 31; } x = { 18 };
+ return (long long) (x.f0 - (int) 22);
+}
+
+long long f2(void) {
+ struct { unsigned f0 ; } x = { 18 };
+ return (long long) (x.f0 - (int) 22);
+}
diff --git a/clang/test/CodeGen/bitfield.c b/clang/test/CodeGen/bitfield.c
new file mode 100644
index 0000000..dea5e43
--- /dev/null
+++ b/clang/test/CodeGen/bitfield.c
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o %t -O3
+// RUN: grep "ret i32" %t | count 4
+// RUN: grep "ret i32 1" %t | count 4
+
+static int f0(int n) {
+ struct s0 {
+ int a : 30;
+ int b : 2;
+ long long c : 31;
+ } x = { 0xdeadbeef, 0xdeadbeef, 0xdeadbeef };
+
+ x.a += n;
+ x.b += n;
+ x.c += n;
+
+ return x.a + x.b + x.c;
+}
+
+int g0(void) {
+ return f0(-1) + 44335655;
+}
+
+static int f1(void) {
+ struct s1 {
+ int a:13;
+ char b;
+ unsigned short c:7;
+ } x;
+
+ x.a = -40;
+ x.b = 10;
+ x.c = 15;
+
+ return x.a + x.b + x.c;
+}
+
+int g1(void) {
+ return f1() + 16;
+}
+
+static int f2(void) {
+ struct s2 {
+ short a[3];
+ int b : 15;
+ } x;
+
+ x.a[0] = x.a[1] = x.a[2] = -40;
+ x.b = 10;
+
+ return x.b;
+}
+
+int g2(void) {
+ return f2() - 9;
+}
+
+static int f3(int n) {
+ struct s3 {
+ unsigned a:16;
+ unsigned b:28 __attribute__ ((packed));
+ } x = { 0xdeadbeef, 0xdeadbeef };
+ struct s4 {
+ signed a:16;
+ signed b:28 __attribute__ ((packed));
+ } y;
+ y.a = -0x56789abcL;
+ y.b = -0x56789abcL;
+ return ((y.a += x.a += n) +
+ (y.b += x.b += n));
+}
+
+int g3(void) {
+ return f3(20) + 130725747;
+}
diff --git a/clang/test/CodeGen/block-3.c b/clang/test/CodeGen/block-3.c
new file mode 100644
index 0000000..95cb6a7
--- /dev/null
+++ b/clang/test/CodeGen/block-3.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10
+// rdar://10001085
+
+int main() {
+ ^{
+ __attribute__((__blocks__(byref))) int index = ({ int __a; int __b; __a < __b ? __b : __a; });
+ };
+}
diff --git a/clang/test/CodeGen/block-byref-aggr.c b/clang/test/CodeGen/block-byref-aggr.c
new file mode 100644
index 0000000..3027df0
--- /dev/null
+++ b/clang/test/CodeGen/block-byref-aggr.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10 | FileCheck %s
+// rdar://9309454
+
+typedef struct { int v; } RetType;
+
+RetType func();
+
+int main () {
+ __attribute__((__blocks__(byref))) RetType a = {100};
+
+ a = func();
+}
+// CHECK: [[C1:%.*]] = call i32 (...)* @func()
+// CHECK-NEXT: [[CO:%.*]] = getelementptr
+// CHECK-NEXT: store i32 [[C1]], i32* [[CO]]
+// CHECK-NEXT: [[FORWARDING:%.*]] = getelementptr inbounds [[BR:%.*]]* [[A:%.*]], i32 0, i32 1
+// CHECK-NEXT: [[O:%.*]] = load [[BR]]** [[FORWARDING]]
diff --git a/clang/test/CodeGen/block-copy.c b/clang/test/CodeGen/block-copy.c
new file mode 100644
index 0000000..fba76ad
--- /dev/null
+++ b/clang/test/CodeGen/block-copy.c
@@ -0,0 +1,20 @@
+/* RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+ This should compile into a memcpy from a global, not 128 stores. */
+
+
+
+void foo();
+
+float bar() {
+ float lookupTable[] = {-1,-1,-1,0, -1,-1,0,-1, -1,-1,0,1, -1,-1,1,0,
+ -1,0,-1,-1, -1,0,-1,1, -1,0,1,-1, -1,0,1,1,
+ -1,1,-1,0, -1,1,0,-1, -1,1,0,1, -1,1,1,0,
+ 0,-1,-1,-1, 0,-1,-1,1, 0,-1,1,-1, 0,-1,1,1,
+ 1,-1,-1,0, 1,-1,0,-1, 1,-1,0,1, 1,-1,1,0,
+ 1,0,-1,-1, 1,0,-1,1, 1,0,1,-1, 1,0,1,1,
+ 1,1,-1,0, 1,1,0,-1, 1,1,0,1, 1,1,1,0,
+ 0,1,-1,-1, 0,1,-1,1, 0,1,1,-1, 0,1,1,1};
+ // CHECK: memcpy
+ foo(lookupTable);
+}
diff --git a/clang/test/CodeGen/blocks-1.c b/clang/test/CodeGen/blocks-1.c
new file mode 100644
index 0000000..350f7a3
--- /dev/null
+++ b/clang/test/CodeGen/blocks-1.c
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t -fblocks
+// RUN: grep "_Block_object_dispose" %t | count 17
+// RUN: grep "__copy_helper_block_" %t | count 14
+// RUN: grep "__destroy_helper_block_" %t | count 14
+// RUN: grep "__Block_byref_object_copy_" %t | count 2
+// RUN: grep "__Block_byref_object_dispose_" %t | count 2
+// RUN: grep "i32 135)" %t | count 2
+// RUN: grep "_Block_object_assign" %t | count 10
+
+int printf(const char *, ...);
+
+void test1() {
+ __block int a;
+ int b=2;
+ a=1;
+ printf("a is %d, b is %d\n", a, b);
+ ^{ a = 10; printf("a is %d, b is %d\n", a, b); }(); // needs copy/dispose
+ printf("a is %d, b is %d\n", a, b);
+ a = 1;
+ printf("a is %d, b is %d\n", a, b);
+}
+
+void test2() {
+ __block int a;
+ a=1;
+ printf("a is %d\n", a);
+ ^{ // needs copy/dispose
+ ^{ // needs copy/dispose
+ a = 10;
+ }();
+ }();
+ printf("a is %d\n", a);
+ a = 1;
+ printf("a is %d\n", a);
+}
+
+void test3() {
+ __block int k;
+ __block int (^j)(int);
+ ^{j=0; k=0;}(); // needs copy/dispose
+}
+
+int test4() {
+ extern int g;
+ static int i = 1;
+ ^(int j){ i = j; g = 0; }(0); // does not need copy/dispose
+ return i + g;
+}
+
+int g;
+
+void test5() {
+ __block struct { int i; } i;
+ ^{ (void)i; }(); // needs copy/dispose
+}
+
+void test6() {
+ __block int i;
+ ^{ i=1; }(); // needs copy/dispose
+ ^{}(); // does not need copy/dispose
+}
+
+void test7() {
+ ^{ // does not need copy/dispose
+ __block int i;
+ ^{ i = 1; }(); // needs copy/dispose
+ }();
+}
+
+int main() {
+ int rv = 0;
+ test1();
+ test2();
+ test3();
+ rv += test4();
+ test5();
+ return rv;
+}
diff --git a/clang/test/CodeGen/blocks-2.c b/clang/test/CodeGen/blocks-2.c
new file mode 100644
index 0000000..4e574da
--- /dev/null
+++ b/clang/test/CodeGen/blocks-2.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -g %s -emit-llvm -o %t -fblocks
+// RUN: grep "func.start" %t | count 4
+// RUN: %clang_cc1 -g %s -triple i386-unknown-unknown -emit-llvm -o %t -fblocks -fblock-introspection
+// RUN: grep "v8@?0i4" %t | count 1
+// RUN: %clang_cc1 -g %s -triple i386-unknown-unknown -emit-llvm -o %t -fblocks
+// RUN: grep "v8@?0i4" %t | count 0
+// 1 declaration, 1 bar, 1 test_block_dbg and 1 for the block.
+// XFAIL: *
+
+static __inline__ __attribute__((always_inline)) int bar(int va, int vb) { return (va == vb); }
+
+int test_block_dbg() {
+ extern int g;
+ static int i = 1;
+ ^(int j){ i = bar(3,4); }(0);
+ return i + g;
+}
+
diff --git a/clang/test/CodeGen/blocks-aligned-byref-variable.c b/clang/test/CodeGen/blocks-aligned-byref-variable.c
new file mode 100644
index 0000000..07d683c
--- /dev/null
+++ b/clang/test/CodeGen/blocks-aligned-byref-variable.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin10 -fblocks %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple i386-apple-darwin10 -fblocks %s
+typedef int __attribute__((aligned(32))) ai;
+
+void f() {
+ __block ai a = 10;
+
+ ^{
+ a = 20;
+ }();
+}
+
+void g() {
+ __block double a = 10;
+
+ ^{
+ a = 20;
+ }();
+}
diff --git a/clang/test/CodeGen/blocks-seq.c b/clang/test/CodeGen/blocks-seq.c
new file mode 100644
index 0000000..3557b48
--- /dev/null
+++ b/clang/test/CodeGen/blocks-seq.c
@@ -0,0 +1,18 @@
+// FIXME: We forcibly strip the names so that the test doesn't vary between
+// builds with and without asserts. We need a better solution for this.
+
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -emit-llvm-bc -o - %s | opt -strip | llvm-dis > %t
+// RUN: grep '%6 = call i32 (...)\* @rhs()' %t | count 1
+// RUN: grep '%7 = getelementptr inbounds %0\* %1, i32 0, i32 1' %t | count 1
+// RUN: grep '%8 = load %0\*\* %7' %t | count 1
+// RUN: grep '%10 = call i32 (...)\* @rhs()' %t | count 1
+// RUN: grep '%11 = getelementptr inbounds %0\* %1, i32 0, i32 1' %t | count 1
+// RUN: grep '%12 = load %0\*\* %11' %t | count 1
+
+int rhs();
+
+void foo() {
+ __block int i;
+ i = rhs();
+ i += rhs();
+}
diff --git a/clang/test/CodeGen/blocks.c b/clang/test/CodeGen/blocks.c
new file mode 100644
index 0000000..bef44c3
--- /dev/null
+++ b/clang/test/CodeGen/blocks.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - -fblocks | FileCheck %s
+void (^f)(void) = ^{};
+
+// rdar://6768379
+int f0(int (^a0)()) {
+ return a0(1, 2, 3);
+}
+
+// Verify that attributes on blocks are set correctly.
+typedef struct s0 T;
+struct s0 {
+ int a[64];
+};
+
+// CHECK: define internal void @__f2_block_invoke_0(%struct.s0* noalias sret {{%.*}}, i8* {{%.*}}, %struct.s0* byval align 4 {{.*}})
+struct s0 f2(struct s0 a0) {
+ return ^(struct s0 a1){ return a1; }(a0);
+}
+
+// This should not crash: rdar://6808051
+void *P = ^{
+ void *Q = __func__;
+};
+
+void (^test1)(void) = ^(void) {
+ __block int i;
+ ^ { i = 1; }();
+};
+
+typedef double ftype(double);
+// It's not clear that we *should* support this syntax, but until that decision
+// is made, we should support it properly and not crash.
+ftype ^test2 = ^ftype {
+ return 0;
+};
+
+// rdar://problem/8605032
+void f3_helper(void (^)(void));
+void f3() {
+ _Bool b = 0;
+ f3_helper(^{ if (b) {} });
+}
diff --git a/clang/test/CodeGen/blocksignature.c b/clang/test/CodeGen/blocksignature.c
new file mode 100644
index 0000000..63fe124
--- /dev/null
+++ b/clang/test/CodeGen/blocksignature.c
@@ -0,0 +1,96 @@
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin9 %s -emit-llvm -o - | FileCheck %s -check-prefix=X64
+// RUN: %clang_cc1 -fblocks -triple i686-apple-darwin9 %s -emit-llvm -o - | FileCheck %s -check-prefix=X32
+
+// X64: @.str = private unnamed_addr constant [6 x i8] c"v8@?0\00"
+// X64: @__block_literal_global = internal constant {{.*}} { i8** @_NSConcreteGlobalBlock, i32 1342177280,
+// X64: @.str1 = private unnamed_addr constant [12 x i8] c"i16@?0c8f12\00"
+// X64: store i32 1073741824, i32*
+
+// X32: [[STR1:@.*]] = private unnamed_addr constant [6 x i8] c"v4@?0\00"
+// X32: @__block_descriptor_tmp = internal constant [[FULL_DESCRIPTOR_T:.*]] { i32 0, i32 20, i8* getelementptr inbounds ([6 x i8]* [[STR1]], i32 0, i32 0), i8* null }
+// X32: @__block_literal_global = internal constant [[GLOBAL_LITERAL_T:.*]] { i8** @_NSConcreteGlobalBlock, i32 1342177280, i32 0, i8* bitcast (void (i8*)* @__block_global_{{.*}} to i8*), [[DESCRIPTOR_T:%.*]]* bitcast ([[FULL_DESCRIPTOR_T]]* @__block_descriptor_tmp to {{%.*}}*) }
+// X32: [[STR2:@.*]] = private unnamed_addr constant [11 x i8] c"i12@?0c4f8\00"
+// X32: @__block_descriptor_tmp{{.*}} = internal constant [[FULL_DESCRIPTOR_T]] { i32 0, i32 24, i8* getelementptr inbounds ([11 x i8]* [[STR2]], i32 0, i32 0), i8* null }
+// X32: store i32 1073741824, i32*
+
+// rdar://7635294
+
+
+int globalInt;
+void (^global)(void) = ^{ ++globalInt; };
+
+
+void foo(int param) {
+ extern int rand(void);
+ extern void rand_r(int (^b)(char x, float y)); // name a function present at runtime
+ while (param--)
+ rand_r(^(char x, float y){ return x + (int)y + param + rand(); }); // generate a local block binding param
+}
+
+#if 0
+#include <stdio.h>
+enum {
+ BLOCK_HAS_COPY_DISPOSE = (1 << 25),
+ BLOCK_HAS_CXX_OBJ = (1 << 26),
+ BLOCK_IS_GLOBAL = (1 << 28),
+ BLOCK_HAS_DESCRIPTOR = (1 << 29),
+ BLOCK_HAS_OBJC_TYPE = (1 << 30)
+};
+
+struct block_descriptor_big {
+ unsigned long int reserved;
+ unsigned long int size;
+ void (*copy)(void *dst, void *src); // conditional on BLOCK_HAS_COPY_DISPOSE
+ void (*dispose)(void *); // conditional on BLOCK_HAS_COPY_DISPOSE
+ const char *signature; // conditional on BLOCK_HAS_OBJC
+ const char *layout; // conditional on BLOCK_HAS_OBJC
+};
+struct block_descriptor_small {
+ unsigned long int reserved;
+ unsigned long int size;
+ const char *signature; // conditional on BLOCK_HAS_OBJC
+ const char *layout; // conditional on BLOCK_HAS_OBJC
+};
+
+struct block_layout_abi { // can't change
+ void *isa;
+ int flags;
+ int reserved;
+ void (*invoke)(void *, ...);
+ struct block_descriptor_big *descriptor;
+};
+
+const char *getBlockSignature(void *block) {
+ struct block_layout_abi *layout = (struct block_layout_abi *)block;
+ if ((layout->flags & BLOCK_HAS_OBJC_TYPE) != BLOCK_HAS_OBJC_TYPE) return NULL;
+ if (layout->flags & BLOCK_HAS_COPY_DISPOSE)
+ return layout->descriptor->signature;
+ else
+ return ((struct block_descriptor_small *)layout->descriptor)->signature;
+}
+
+
+
+int main(int argc, char *argv[]) {
+ printf("desired global flags: %d\n", BLOCK_IS_GLOBAL | BLOCK_HAS_OBJC_TYPE);
+ printf("desired stack flags: %d\n", BLOCK_HAS_OBJC_TYPE);
+
+ printf("types for global: %s\n", getBlockSignature(global));
+ printf("types for local: %s\n", getBlockSignature(^int(char x, float y) { return (int)(y + x); }));
+ return 0;
+}
+
+/*
+x86_64
+desired global flags: 1342177280
+desired stack flags: 1073741824
+types for global: v8@?0
+types for local: i16@?0c8f12
+
+i386
+desired global flags: 1342177280
+desired stack flags: 1073741824
+types for global: v4@?0
+types for local: i12@?0c4f8
+*/
+#endif
diff --git a/clang/test/CodeGen/blockstret.c b/clang/test/CodeGen/blockstret.c
new file mode 100644
index 0000000..d5dae6f
--- /dev/null
+++ b/clang/test/CodeGen/blockstret.c
@@ -0,0 +1,106 @@
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin9 %s -emit-llvm -o - | FileCheck %s -check-prefix=X64
+// RUN: %clang_cc1 -fblocks -triple i686-apple-darwin9 %s -emit-llvm -o - | FileCheck %s -check-prefix=X32
+
+// X64: internal constant {{.*}} { i8** @_NSConcreteGlobalBlock, i32 1879048192
+// X64: store i32 1610612736, i32* %want
+
+// X32: @_NSConcreteGlobalBlock, i32 1879048192, i32 0,
+// X32: store i32 1610612736, i32* %want
+
+// rdar://7677537
+int printf(const char *, ...);
+void *malloc(__SIZE_TYPE__ size);
+
+typedef struct bigbig {
+ int array[512];
+ char more[32];
+} BigStruct_t;
+
+BigStruct_t (^global)(void) = ^{ return *(BigStruct_t *)malloc(sizeof(struct bigbig)); };
+
+const char * getBlockSignature(void *);
+
+BigStruct_t foo(int param) {
+ BigStruct_t x;
+ BigStruct_t (^f)(int) = ^(int param) {
+ BigStruct_t *result = malloc(sizeof(BigStruct_t));
+ result->array[23] = param;
+ return *result;
+ };
+ getBlockSignature(f);
+ return x;
+}
+
+enum {
+ BLOCK_HAS_COPY_DISPOSE = (1 << 25),
+ BLOCK_HAS_CXX_OBJ = (1 << 26),
+ BLOCK_IS_GLOBAL = (1 << 28),
+ BLOCK_USE_STRET = (1 << 29),
+ BLOCK_HAS_OBJC_TYPE = (1 << 30)
+};
+
+struct block_descriptor_big {
+ unsigned long int reserved;
+ unsigned long int size;
+ void (*copy)(void *dst, void *src); // conditional on BLOCK_HAS_COPY_DISPOSE
+ void (*dispose)(void *); // conditional on BLOCK_HAS_COPY_DISPOSE
+ const char *signature; // conditional on BLOCK_HAS_OBJC
+ const char *layout; // conditional on BLOCK_HAS_OBJC
+};
+struct block_descriptor_small {
+ unsigned long int reserved;
+ unsigned long int size;
+ const char *signature; // conditional on BLOCK_HAS_OBJC
+ const char *layout; // conditional on BLOCK_HAS_OBJC
+};
+
+struct block_layout_abi { // can't change
+ void *isa;
+ int flags;
+ int reserved;
+ void (*invoke)(void *, ...);
+ struct block_descriptor_big *descriptor;
+};
+
+const char *getBlockSignature(void *block) {
+ struct block_layout_abi *layout = (struct block_layout_abi *)block;
+ if ((layout->flags & BLOCK_HAS_OBJC_TYPE) != BLOCK_HAS_OBJC_TYPE) return 0;
+ if (layout->flags & BLOCK_HAS_COPY_DISPOSE)
+ return layout->descriptor->signature;
+ else
+ return ((struct block_descriptor_small *)layout->descriptor)->signature;
+}
+
+int usesStruct(void *block) {
+ struct block_layout_abi *layout = (struct block_layout_abi *)block;
+ int want = BLOCK_HAS_OBJC_TYPE | BLOCK_USE_STRET;
+ return (layout->flags & want) == want;
+}
+
+
+int main(int argc, char *argv[]) {
+ printf("desired global flags: %d\n", BLOCK_USE_STRET | BLOCK_IS_GLOBAL | BLOCK_HAS_OBJC_TYPE);
+ printf("desired stack flags: %d\n", BLOCK_USE_STRET | BLOCK_HAS_OBJC_TYPE);
+
+ printf("should be non-zero: %d\n", usesStruct(global));
+ BigStruct_t x;
+ BigStruct_t (^local)(int) = ^(int param) {
+ BigStruct_t *result = (BigStruct_t *)malloc(sizeof(BigStruct_t));
+ result->array[23] = argc;
+ return *result;
+ };
+ printf("should be non-zero: %d\n", usesStruct(global));
+ printf("should be non-zero: %d\n", usesStruct(local));
+ printf("should be zero: %d\n", usesStruct(^void(int x){ }));
+ return 0;
+}
+
+/*
+desired global flags: 1879048192
+desired stack flags: 1610612736
+should be non-zero: 1
+should be non-zero: 1
+should be non-zero: 1
+should be zero: 0
+
+*/
diff --git a/clang/test/CodeGen/blockwithlocalstatic.c b/clang/test/CodeGen/blockwithlocalstatic.c
new file mode 100644
index 0000000..1fdaaf3
--- /dev/null
+++ b/clang/test/CodeGen/blockwithlocalstatic.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -emit-llvm -o - %s | FileCheck %s
+// pr8707
+
+// CHECK: @__block_global_0.test = internal global i32
+int (^block)(void) = ^ {
+ static int test=0;
+ return test;
+};
+// CHECK: @__block_global_1.test = internal global i32
+void (^block1)(void) = ^ {
+ static int test = 2;
+ return;
+};
+// CHECK: @__block_global_2.test = internal global i32
+int (^block2)(void) = ^ {
+ static int test = 5;
+ return test;
+};
+
diff --git a/clang/test/CodeGen/bmi-builtins.c b/clang/test/CodeGen/bmi-builtins.c
new file mode 100644
index 0000000..47b0da2
--- /dev/null
+++ b/clang/test/CodeGen/bmi-builtins.c
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +bmi -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <x86intrin.h>
+
+unsigned short test__tzcnt16(unsigned short __X) {
+ // CHECK: @llvm.cttz.i16
+ return __tzcnt16(__X);
+}
+
+unsigned int test__andn_u32(unsigned int __X, unsigned int __Y) {
+ // CHECK: [[DEST:%.*]] = xor i32 %{{.*}}, -1
+ // CHECK-NEXT: %{{.*}} = and i32 %{{.*}}, [[DEST]]
+ return __andn_u32(__X, __Y);
+}
+
+unsigned int test__bextr_u32(unsigned int __X, unsigned int __Y) {
+ // CHECK: @llvm.x86.bmi.bextr.32
+ return __bextr_u32(__X, __Y);
+}
+
+unsigned int test__blsi_u32(unsigned int __X) {
+ // CHECK: [[DEST:%.*]] = sub i32 0, [[SRC:%.*]]
+ // CHECK-NEXT: %{{.*}} = and i32 [[SRC]], [[DEST]]
+ return __blsi_u32(__X);
+}
+
+unsigned int test__blsmsk_u32(unsigned int __X) {
+ // CHECK: [[DEST:%.*]] = add i32 [[SRC:%.*]], -1
+ // CHECK-NEXT: %{{.*}} = xor i32 [[DEST]], [[SRC]]
+ return __blsmsk_u32(__X);
+}
+
+unsigned int test__blsr_u32(unsigned int __X) {
+ // CHECK: [[DEST:%.*]] = add i32 [[SRC:%.*]], -1
+ // CHECK-NEXT: %{{.*}} = and i32 [[DEST]], [[SRC]]
+ return __blsr_u32(__X);
+}
+
+unsigned int test_tzcnt32(unsigned int __X) {
+ // CHECK: @llvm.cttz.i32
+ return __tzcnt32(__X);
+}
+
+unsigned long long test__andn_u64(unsigned long __X, unsigned long __Y) {
+ // CHECK: [[DEST:%.*]] = xor i64 %{{.*}}, -1
+ // CHECK-NEXT: %{{.*}} = and i64 %{{.*}}, [[DEST]]
+ return __andn_u64(__X, __Y);
+}
+
+unsigned long long test__bextr_u64(unsigned long __X, unsigned long __Y) {
+ // CHECK: @llvm.x86.bmi.bextr.64
+ return __bextr_u64(__X, __Y);
+}
+
+unsigned long long test__blsi_u64(unsigned long long __X) {
+ // CHECK: [[DEST:%.*]] = sub i64 0, [[SRC:%.*]]
+ // CHECK-NEXT: %{{.*}} = and i64 [[SRC]], [[DEST]]
+ return __blsi_u64(__X);
+}
+
+unsigned long long test__blsmsk_u64(unsigned long long __X) {
+ // CHECK: [[DEST:%.*]] = add i64 [[SRC:%.*]], -1
+ // CHECK-NEXT: %{{.*}} = xor i64 [[DEST]], [[SRC]]
+ return __blsmsk_u64(__X);
+}
+
+unsigned long long test__blsr_u64(unsigned long long __X) {
+ // CHECK: [[DEST:%.*]] = add i64 [[SRC:%.*]], -1
+ // CHECK-NEXT: %{{.*}} = and i64 [[DEST]], [[SRC]]
+ return __blsr_u64(__X);
+}
+
+unsigned long long test__tzcnt64(unsigned long long __X) {
+ // CHECK: @llvm.cttz.i64
+ return __tzcnt64(__X);
+}
diff --git a/clang/test/CodeGen/bmi2-builtins.c b/clang/test/CodeGen/bmi2-builtins.c
new file mode 100644
index 0000000..18b2319
--- /dev/null
+++ b/clang/test/CodeGen/bmi2-builtins.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +bmi2 -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <x86intrin.h>
+
+unsigned int test_bzhi_u32(unsigned int __X, unsigned int __Y) {
+ // CHECK: @llvm.x86.bmi.bzhi.32
+ return _bzhi_u32(__X, __Y);
+}
+
+unsigned int test_pdep_u32(unsigned int __X, unsigned int __Y) {
+ // CHECK: @llvm.x86.bmi.pdep.32
+ return _pdep_u32(__X, __Y);
+}
+
+unsigned int test_pext_u32(unsigned int __X, unsigned int __Y) {
+ // CHECK: @llvm.x86.bmi.pext.32
+ return _pext_u32(__X, __Y);
+}
+
+unsigned long long test_bzhi_u64(unsigned long long __X, unsigned long long __Y) {
+ // CHECK: @llvm.x86.bmi.bzhi.64
+ return _bzhi_u64(__X, __Y);
+}
+
+unsigned long long test_pdep_u64(unsigned long long __X, unsigned long long __Y) {
+ // CHECK: @llvm.x86.bmi.pdep.64
+ return _pdep_u64(__X, __Y);
+}
+
+unsigned long long test_pext_u64(unsigned long long __X, unsigned long long __Y) {
+ // CHECK: @llvm.x86.bmi.pext.64
+ return _pext_u64(__X, __Y);
+}
diff --git a/clang/test/CodeGen/bool-bitfield.c b/clang/test/CodeGen/bool-bitfield.c
new file mode 100644
index 0000000..cb2d1db
--- /dev/null
+++ b/clang/test/CodeGen/bool-bitfield.c
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+// From GCC PR19331
+struct SysParams
+{
+ unsigned short tag;
+ unsigned short version;
+ unsigned int seqnum;
+ int contrast;
+ int igain_1, igain_2;
+ int oattn_1, oattn_2;
+ int max_out_vltg_1, max_out_vltg_2;
+ int max_mains_current;
+ int meters_mode;
+ int input_select;
+ _Bool input_parallelch2:1;
+ _Bool cliplmt_ch1:1;
+ _Bool cliplmt_ch2:1;
+ _Bool gate_ch1:1;
+ _Bool gate_ch2:1;
+ _Bool mute_ch1:1;
+ _Bool mute_ch2:1;
+ _Bool brownout:1;
+ _Bool power_on:1;
+ _Bool pwrup_mute:1;
+ _Bool keylock:1;
+ _Bool dsp_ch1:1;
+ _Bool dsp_ch2:1;
+ int dsp_preset;
+ long unlock_code;
+};
+extern struct SysParams params;
+
+void foo(void *);
+void kcmd_setParams(void)
+{
+ struct {
+ unsigned char igain_1;
+ unsigned char igain_2;
+ unsigned char max_out_vltg_1;
+ unsigned char max_out_vltg_2;
+ unsigned char max_imains;
+ unsigned char cliplmt_ch1:1;
+ unsigned char cliplmt_ch2:1;
+ unsigned char gate_ch1:1;
+ unsigned char gate_ch2:1;
+ } msg;
+ foo(&msg);
+ params.cliplmt_ch1 = msg.cliplmt_ch1;
+ params.cliplmt_ch2 = msg.cliplmt_ch2;
+ params.gate_ch1 = msg.gate_ch1;
+ params.gate_ch2 = msg.gate_ch2;
+}
+
diff --git a/clang/test/CodeGen/bool-convert.c b/clang/test/CodeGen/bool-convert.c
new file mode 100644
index 0000000..8bde837
--- /dev/null
+++ b/clang/test/CodeGen/bool-convert.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm < %s | grep i1 | count 1
+// All of these should uses the memory representation of _Bool
+struct teststruct1 {_Bool a, b;} test1;
+_Bool* test2;
+_Bool test3[10];
+_Bool (*test4)[];
+void f(int x) {
+ _Bool test5;
+ _Bool test6[x];
+}
diff --git a/clang/test/CodeGen/bool-init.c b/clang/test/CodeGen/bool-init.c
new file mode 100644
index 0000000..1a8f127
--- /dev/null
+++ b/clang/test/CodeGen/bool-init.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm < %s | grep i1 | count 1
+
+// Check that the type of this global isn't i1
+_Bool test = &test;
diff --git a/clang/test/CodeGen/bool_test.c b/clang/test/CodeGen/bool_test.c
new file mode 100644
index 0000000..ffaaef8
--- /dev/null
+++ b/clang/test/CodeGen/bool_test.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple powerpc-apple-darwin -emit-llvm -o - %s| FileCheck -check-prefix=DARWINPPC-CHECK %s
+
+int boolsize = sizeof(_Bool);
+//DARWINPPC-CHECK: boolsize = global i32 4, align 4
+
diff --git a/clang/test/CodeGen/boolassign.c b/clang/test/CodeGen/boolassign.c
new file mode 100644
index 0000000..8c56319
--- /dev/null
+++ b/clang/test/CodeGen/boolassign.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+
+int testBoolAssign(void) {
+ int ss;
+ if ((ss = ss && ss)) {}
+ return 1;
+}
diff --git a/clang/test/CodeGen/builtin-attributes.c b/clang/test/CodeGen/builtin-attributes.c
new file mode 100644
index 0000000..3781eba
--- /dev/null
+++ b/clang/test/CodeGen/builtin-attributes.c
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -triple arm-unknown-linux-gnueabi -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: declare i32 @printf(i8*, ...)
+void f0() {
+ printf("a\n");
+}
+
+// CHECK: call void @exit
+// CHECK: unreachable
+void f1() {
+ exit(1);
+}
+
+// CHECK: call i8* @strstr{{.*}} nounwind
+char* f2(char* a, char* b) {
+ return __builtin_strstr(a, b);
+}
+
+// frexp is NOT readnone. It writes to its pointer argument.
+// <rdar://problem/10070234>
+//
+// CHECK: f3
+// CHECK: call double @frexp(double %
+// CHECK-NOT: readnone
+// CHECK: call float @frexpf(float %
+// CHECK-NOT: readnone
+// CHECK: call double @frexpl(double %
+// CHECK-NOT: readnone
+//
+// Same thing for modf and friends.
+//
+// CHECK: call double @modf(double %
+// CHECK-NOT: readnone
+// CHECK: call float @modff(float %
+// CHECK-NOT: readnone
+// CHECK: call double @modfl(double %
+// CHECK-NOT: readnone
+//
+// CHECK: call double @remquo(double %
+// CHECK-NOT: readnone
+// CHECK: call float @remquof(float %
+// CHECK-NOT: readnone
+// CHECK: call double @remquol(double %
+// CHECK-NOT: readnone
+// CHECK: ret
+int f3(double x) {
+ int e;
+ __builtin_frexp(x, &e);
+ __builtin_frexpf(x, &e);
+ __builtin_frexpl(x, &e);
+ __builtin_modf(x, &e);
+ __builtin_modff(x, &e);
+ __builtin_modfl(x, &e);
+ __builtin_remquo(x, x, &e);
+ __builtin_remquof(x, x, &e);
+ __builtin_remquol(x, x, &e);
+ return e;
+}
diff --git a/clang/test/CodeGen/builtin-count-zeros.c b/clang/test/CodeGen/builtin-count-zeros.c
new file mode 100644
index 0000000..acd22e6
--- /dev/null
+++ b/clang/test/CodeGen/builtin-count-zeros.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple arm-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-ARM
+
+int a(int a) {return __builtin_ctz(a) + __builtin_clz(a);}
+// CHECK: call i32 @llvm.cttz.i32({{.*}}, i1 true)
+// CHECK: call i32 @llvm.ctlz.i32({{.*}}, i1 true)
+// CHECK-ARM: call i32 @llvm.cttz.i32({{.*}}, i1 false)
+// CHECK-ARM: call i32 @llvm.ctlz.i32({{.*}}, i1 false)
diff --git a/clang/test/CodeGen/builtin-expect.c b/clang/test/CodeGen/builtin-expect.c
new file mode 100644
index 0000000..664c6b6
--- /dev/null
+++ b/clang/test/CodeGen/builtin-expect.c
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+int x;
+int y(void);
+void foo();
+void FUNC() {
+// CHECK: [[call:%.*]] = call i32 @y
+ if (__builtin_expect (x, y()))
+ foo ();
+}
+
+// rdar://9330105
+void isigprocmask(void);
+long bar();
+
+int main() {
+ (void) __builtin_expect((isigprocmask(), 0), bar());
+}
+
+// CHECK: call void @isigprocmask()
+// CHECK: [[C:%.*]] = call i64 (...)* @bar()
+
+
+// CHECK: @test1
+int test1(int x) {
+// CHECK: @llvm.expect
+ if (__builtin_expect (x, 1))
+ return 0;
+ return x;
+}
+
+// CHECK: @test2
+int test2(int x) {
+// CHECK: @llvm.expect
+ switch(__builtin_expect(x, 5)) {
+ default:
+ return 0;
+ case 0:
+ case 1:
+ case 2:
+ return 1;
+ case 5:
+ return 5;
+ };
+
+ return 0;
+}
diff --git a/clang/test/CodeGen/builtin-memfns.c b/clang/test/CodeGen/builtin-memfns.c
new file mode 100644
index 0000000..72d3406
--- /dev/null
+++ b/clang/test/CodeGen/builtin-memfns.c
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm < %s| FileCheck %s
+
+// CHECK: @test1
+// CHECK: call void @llvm.memset.p0i8.i32
+// CHECK: call void @llvm.memset.p0i8.i32
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32
+// CHECK: call void @llvm.memmove.p0i8.p0i8.i32
+// CHECK-NOT: __builtin
+// CHECK: ret
+int test1(int argc, char **argv) {
+ unsigned char a = 0x11223344;
+ unsigned char b = 0x11223344;
+ __builtin_bzero(&a, sizeof(a));
+ __builtin_memset(&a, 0, sizeof(a));
+ __builtin_memcpy(&a, &b, sizeof(a));
+ __builtin_memmove(&a, &b, sizeof(a));
+ return 0;
+}
+
+// rdar://9289468
+
+// CHECK: @test2
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32
+char* test2(char* a, char* b) {
+ return __builtin_memcpy(a, b, 4);
+}
+
+// CHECK: @test3
+// CHECK: call void @llvm.memset
+void test3(char *P) {
+ __builtin___memset_chk(P, 42, 128, 128);
+}
+
+// CHECK: @test4
+// CHECK: call void @llvm.memcpy
+void test4(char *P, char *Q) {
+ __builtin___memcpy_chk(P, Q, 128, 128);
+}
+
+// CHECK: @test5
+// CHECK: call void @llvm.memmove
+void test5(char *P, char *Q) {
+ __builtin___memmove_chk(P, Q, 128, 128);
+}
+
+// CHECK: @test6
+// CHECK: call void @llvm.memcpy
+int test6(char *X) {
+ return __builtin___memcpy_chk(X, X, 42, 42) != 0;
+}
+
+// CHECK: @test7
+// PR12094
+int test7(int *p) {
+ struct snd_pcm_hw_params_t* hwparams; // incomplete type.
+
+ // CHECK: call void @llvm.memset{{.*}}256, i32 4, i1 false)
+ __builtin_memset(p, 0, 256); // Should be alignment = 4
+
+ // CHECK: call void @llvm.memset{{.*}}256, i32 1, i1 false)
+ __builtin_memset((char*)p, 0, 256); // Should be alignment = 1
+
+ __builtin_memset(hwparams, 0, 256); // No crash alignment = 1
+ // CHECK: call void @llvm.memset{{.*}}256, i32 1, i1 false)
+}
diff --git a/clang/test/CodeGen/builtin-nanf.c b/clang/test/CodeGen/builtin-nanf.c
new file mode 100644
index 0000000..ae37c9d
--- /dev/null
+++ b/clang/test/CodeGen/builtin-nanf.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-llvm -o %t %s
+// RUN: grep 'float 0x7FF8000000000000, float 0x7FF8000000000000, float 0x7FF8000020000000, float 0x7FF8000000000000, float 0x7FF80001E0000000, float 0x7FF8001E00000000, float 0x7FF801E000000000, float 0x7FF81E0000000000, float 0x7FF9E00000000000, float 0x7FFFFFFFE0000000' %t
+
+float n[] = {
+ __builtin_nanf("0"),
+ __builtin_nanf(""),
+ __builtin_nanf("1"),
+ __builtin_nanf("0x7fc00000"),
+ __builtin_nanf("0x7fc0000f"),
+ __builtin_nanf("0x7fc000f0"),
+ __builtin_nanf("0x7fc00f00"),
+ __builtin_nanf("0x7fc0f000"),
+ __builtin_nanf("0x7fcf0000"),
+ __builtin_nanf("0xffffffff"),
+};
diff --git a/clang/test/CodeGen/builtin-recursive.cc b/clang/test/CodeGen/builtin-recursive.cc
new file mode 100644
index 0000000..81e9b9a
--- /dev/null
+++ b/clang/test/CodeGen/builtin-recursive.cc
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -nostdsysteminc -nobuiltininc -isystem Inputs -emit-llvm-only %s
+
+// This used to cause a read past the end of a global variable.
+
+#include <stdio.h>
+
+void testcase(void) {
+ vprintf(0, 0);
+}
+
diff --git a/clang/test/CodeGen/builtin-rename.c b/clang/test/CodeGen/builtin-rename.c
new file mode 100644
index 0000000..0b71d88
--- /dev/null
+++ b/clang/test/CodeGen/builtin-rename.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | grep 'declare.*printf' | count 1
+// PR3612
+
+int printf(const char *, ...);
+
+int foo(void) {
+ return printf(printf);
+}
diff --git a/clang/test/CodeGen/builtin-stackaddress.c b/clang/test/CodeGen/builtin-stackaddress.c
new file mode 100644
index 0000000..f13b90e
--- /dev/null
+++ b/clang/test/CodeGen/builtin-stackaddress.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm < %s | grep "llvm.returnaddress"
+// RUN: %clang_cc1 -emit-llvm < %s | grep "llvm.frameaddress"
+void* a(unsigned x) {
+return __builtin_return_address(0);
+}
+
+void* c(unsigned x) {
+return __builtin_frame_address(0);
+}
diff --git a/clang/test/CodeGen/builtin-unwind-init.c b/clang/test/CodeGen/builtin-unwind-init.c
new file mode 100644
index 0000000..6fa7766
--- /dev/null
+++ b/clang/test/CodeGen/builtin-unwind-init.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm < %s -o - | FileCheck %s
+
+void a() { __builtin_unwind_init(); }
+
+// CHECK: call void @llvm.eh.unwind.init()
diff --git a/clang/test/CodeGen/builtins-arm.c b/clang/test/CodeGen/builtins-arm.c
new file mode 100644
index 0000000..09df1ef
--- /dev/null
+++ b/clang/test/CodeGen/builtins-arm.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -Wall -Werror -triple thumbv7-eabi -target-cpu cortex-a8 -O3 -emit-llvm -o - %s | FileCheck %s
+
+void *f0()
+{
+ return __builtin_thread_pointer();
+}
+
+void f1(char *a, char *b) {
+ __clear_cache(a,b);
+}
+
+// CHECK: call {{.*}} @__clear_cache
diff --git a/clang/test/CodeGen/builtins-ppc-altivec.c b/clang/test/CodeGen/builtins-ppc-altivec.c
new file mode 100644
index 0000000..b12ff01
--- /dev/null
+++ b/clang/test/CodeGen/builtins-ppc-altivec.c
@@ -0,0 +1,3115 @@
+// RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+vector bool char vbc = { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 };
+vector signed char vsc = { 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16 };
+vector unsigned char vuc = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+vector bool short vbs = { 1, 0, 1, 0, 1, 0, 1, 0 };
+vector short vs = { -1, 2, -3, 4, -5, 6, -7, 8 };
+vector unsigned short vus = { 1, 2, 3, 4, 5, 6, 7, 8 };
+vector pixel vp = { 1, 2, 3, 4, 5, 6, 7, 8 };
+vector bool int vbi = { 1, 0, 1, 0 };
+vector int vi = { -1, 2, -3, 4 };
+vector unsigned int vui = { 1, 2, 3, 4 };
+vector float vf = { -1.5, 2.5, -3.5, 4.5 };
+
+vector bool char res_vbc;
+vector signed char res_vsc;
+vector unsigned char res_vuc;
+vector bool short res_vbs;
+vector short res_vs;
+vector unsigned short res_vus;
+vector pixel res_vp;
+vector bool int res_vbi;
+vector int res_vi;
+vector unsigned int res_vui;
+vector float res_vf;
+
+signed char param_sc;
+unsigned char param_uc;
+short param_s;
+unsigned short param_us;
+int param_i;
+unsigned int param_ui;
+float param_f;
+
+int res_sc;
+int res_uc;
+int res_s;
+int res_us;
+int res_i;
+int res_ui;
+int res_f;
+
+// CHECK: define void @test1
+void test1() {
+
+ /* vec_abs */
+ vsc = vec_abs(vsc); // CHECK: sub <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vmaxsb
+
+ vs = vec_abs(vs); // CHECK: sub <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vmaxsh
+
+ vi = vec_abs(vi); // CHECK: sub <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vmaxsw
+
+ vf = vec_abs(vf); // CHECK: and <4 x i32>
+
+ /* vec_abs */
+ vsc = vec_abss(vsc); // CHECK: @llvm.ppc.altivec.vsubsbs
+ // CHECK: @llvm.ppc.altivec.vmaxsb
+
+ vs = vec_abss(vs); // CHECK: @llvm.ppc.altivec.vsubshs
+ // CHECK: @llvm.ppc.altivec.vmaxsh
+
+ vi = vec_abss(vi); // CHECK: @llvm.ppc.altivec.vsubsws
+ // CHECK: @llvm.ppc.altivec.vmaxsw
+
+ /* vec_add */
+ res_vsc = vec_add(vsc, vsc); // CHECK: add <16 x i8>
+ res_vsc = vec_add(vbc, vsc); // CHECK: add <16 x i8>
+ res_vsc = vec_add(vsc, vbc); // CHECK: add <16 x i8>
+ res_vuc = vec_add(vuc, vuc); // CHECK: add <16 x i8>
+ res_vuc = vec_add(vbc, vuc); // CHECK: add <16 x i8>
+ res_vuc = vec_add(vuc, vbc); // CHECK: add <16 x i8>
+ res_vs = vec_add(vs, vs); // CHECK: add <8 x i16>
+ res_vs = vec_add(vbs, vs); // CHECK: add <8 x i16>
+ res_vs = vec_add(vs, vbs); // CHECK: add <8 x i16>
+ res_vus = vec_add(vus, vus); // CHECK: add <8 x i16>
+ res_vus = vec_add(vbs, vus); // CHECK: add <8 x i16>
+ res_vus = vec_add(vus, vbs); // CHECK: add <8 x i16>
+ res_vi = vec_add(vi, vi); // CHECK: add <4 x i32>
+ res_vi = vec_add(vbi, vi); // CHECK: add <4 x i32>
+ res_vi = vec_add(vi, vbi); // CHECK: add <4 x i32>
+ res_vui = vec_add(vui, vui); // CHECK: add <4 x i32>
+ res_vui = vec_add(vbi, vui); // CHECK: add <4 x i32>
+ res_vui = vec_add(vui, vbi); // CHECK: add <4 x i32>
+ res_vf = vec_add(vf, vf); // CHECK: fadd <4 x float>
+ res_vsc = vec_vaddubm(vsc, vsc); // CHECK: add <16 x i8>
+ res_vsc = vec_vaddubm(vbc, vsc); // CHECK: add <16 x i8>
+ res_vsc = vec_vaddubm(vsc, vbc); // CHECK: add <16 x i8>
+ res_vuc = vec_vaddubm(vuc, vuc); // CHECK: add <16 x i8>
+ res_vuc = vec_vaddubm(vbc, vuc); // CHECK: add <16 x i8>
+ res_vuc = vec_vaddubm(vuc, vbc); // CHECK: add <16 x i8>
+ res_vs = vec_vadduhm(vs, vs); // CHECK: add <8 x i16>
+ res_vs = vec_vadduhm(vbs, vs); // CHECK: add <8 x i16>
+ res_vs = vec_vadduhm(vs, vbs); // CHECK: add <8 x i16>
+ res_vus = vec_vadduhm(vus, vus); // CHECK: add <8 x i16>
+ res_vus = vec_vadduhm(vbs, vus); // CHECK: add <8 x i16>
+ res_vus = vec_vadduhm(vus, vbs); // CHECK: add <8 x i16>
+ res_vi = vec_vadduwm(vi, vi); // CHECK: add <4 x i32>
+ res_vi = vec_vadduwm(vbi, vi); // CHECK: add <4 x i32>
+ res_vi = vec_vadduwm(vi, vbi); // CHECK: add <4 x i32>
+ res_vui = vec_vadduwm(vui, vui); // CHECK: add <4 x i32>
+ res_vui = vec_vadduwm(vbi, vui); // CHECK: add <4 x i32>
+ res_vui = vec_vadduwm(vui, vbi); // CHECK: add <4 x i32>
+ res_vf = vec_vaddfp(vf, vf); // CHECK: fadd <4 x float>
+
+ /* vec_addc */
+ res_vui = vec_addc(vui, vui); // HECK: @llvm.ppc.altivec.vaddcuw
+ res_vui = vec_vaddcuw(vui, vui); // HECK: @llvm.ppc.altivec.vaddcuw
+
+ /* vec_adds */
+ res_vsc = vec_adds(vsc, vsc); // CHECK: @llvm.ppc.altivec.vaddsbs
+ res_vsc = vec_adds(vbc, vsc); // CHECK: @llvm.ppc.altivec.vaddsbs
+ res_vsc = vec_adds(vsc, vbc); // CHECK: @llvm.ppc.altivec.vaddsbs
+ res_vuc = vec_adds(vuc, vuc); // CHECK: @llvm.ppc.altivec.vaddubs
+ res_vuc = vec_adds(vbc, vuc); // CHECK: @llvm.ppc.altivec.vaddubs
+ res_vuc = vec_adds(vuc, vbc); // CHECK: @llvm.ppc.altivec.vaddubs
+ res_vs = vec_adds(vs, vs); // CHECK: @llvm.ppc.altivec.vaddshs
+ res_vs = vec_adds(vbs, vs); // CHECK: @llvm.ppc.altivec.vaddshs
+ res_vs = vec_adds(vs, vbs); // CHECK: @llvm.ppc.altivec.vaddshs
+ res_vus = vec_adds(vus, vus); // CHECK: @llvm.ppc.altivec.vadduhs
+ res_vus = vec_adds(vbs, vus); // CHECK: @llvm.ppc.altivec.vadduhs
+ res_vus = vec_adds(vus, vbs); // CHECK: @llvm.ppc.altivec.vadduhs
+ res_vi = vec_adds(vi, vi); // CHECK: @llvm.ppc.altivec.vaddsws
+ res_vi = vec_adds(vbi, vi); // CHECK: @llvm.ppc.altivec.vaddsws
+ res_vi = vec_adds(vi, vbi); // CHECK: @llvm.ppc.altivec.vaddsws
+ res_vui = vec_adds(vui, vui); // CHECK: @llvm.ppc.altivec.vadduws
+ res_vui = vec_adds(vbi, vui); // CHECK: @llvm.ppc.altivec.vadduws
+ res_vui = vec_adds(vui, vbi); // CHECK: @llvm.ppc.altivec.vadduws
+ res_vsc = vec_vaddsbs(vsc, vsc); // CHECK: @llvm.ppc.altivec.vaddsbs
+ res_vsc = vec_vaddsbs(vbc, vsc); // CHECK: @llvm.ppc.altivec.vaddsbs
+ res_vsc = vec_vaddsbs(vsc, vbc); // CHECK: @llvm.ppc.altivec.vaddsbs
+ res_vuc = vec_vaddubs(vuc, vuc); // CHECK: @llvm.ppc.altivec.vaddubs
+ res_vuc = vec_vaddubs(vbc, vuc); // CHECK: @llvm.ppc.altivec.vaddubs
+ res_vuc = vec_vaddubs(vuc, vbc); // CHECK: @llvm.ppc.altivec.vaddubs
+ res_vs = vec_vaddshs(vs, vs); // CHECK: @llvm.ppc.altivec.vaddshs
+ res_vs = vec_vaddshs(vbs, vs); // CHECK: @llvm.ppc.altivec.vaddshs
+ res_vs = vec_vaddshs(vs, vbs); // CHECK: @llvm.ppc.altivec.vaddshs
+ res_vus = vec_vadduhs(vus, vus); // CHECK: @llvm.ppc.altivec.vadduhs
+ res_vus = vec_vadduhs(vbs, vus); // CHECK: @llvm.ppc.altivec.vadduhs
+ res_vus = vec_vadduhs(vus, vbs); // CHECK: @llvm.ppc.altivec.vadduhs
+ res_vi = vec_vaddsws(vi, vi); // CHECK: @llvm.ppc.altivec.vaddsws
+ res_vi = vec_vaddsws(vbi, vi); // CHECK: @llvm.ppc.altivec.vaddsws
+ res_vi = vec_vaddsws(vi, vbi); // CHECK: @llvm.ppc.altivec.vaddsws
+ res_vui = vec_vadduws(vui, vui); // CHECK: @llvm.ppc.altivec.vadduws
+ res_vui = vec_vadduws(vbi, vui); // CHECK: @llvm.ppc.altivec.vadduws
+ res_vui = vec_vadduws(vui, vbi); // CHECK: @llvm.ppc.altivec.vadduws
+
+ /* vec_and */
+ res_vsc = vec_and(vsc, vsc); // CHECK: and <16 x i8>
+ res_vsc = vec_and(vbc, vsc); // CHECK: and <16 x i8>
+ res_vsc = vec_and(vsc, vbc); // CHECK: and <16 x i8>
+ res_vuc = vec_and(vuc, vuc); // CHECK: and <16 x i8>
+ res_vuc = vec_and(vbc, vuc); // CHECK: and <16 x i8>
+ res_vuc = vec_and(vuc, vbc); // CHECK: and <16 x i8>
+ res_vbc = vec_and(vbc, vbc); // CHECK: and <16 x i8>
+ res_vs = vec_and(vs, vs); // CHECK: and <8 x i16>
+ res_vs = vec_and(vbs, vs); // CHECK: and <8 x i16>
+ res_vs = vec_and(vs, vbs); // CHECK: and <8 x i16>
+ res_vus = vec_and(vus, vus); // CHECK: and <8 x i16>
+ res_vus = vec_and(vbs, vus); // CHECK: and <8 x i16>
+ res_vus = vec_and(vus, vbs); // CHECK: and <8 x i16>
+ res_vbs = vec_and(vbs, vbs); // CHECK: and <8 x i16>
+ res_vi = vec_and(vi, vi); // CHECK: and <4 x i32>
+ res_vi = vec_and(vbi, vi); // CHECK: and <4 x i32>
+ res_vi = vec_and(vi, vbi); // CHECK: and <4 x i32>
+ res_vui = vec_and(vui, vui); // CHECK: and <4 x i32>
+ res_vui = vec_and(vbi, vui); // CHECK: and <4 x i32>
+ res_vui = vec_and(vui, vbi); // CHECK: and <4 x i32>
+ res_vbi = vec_and(vbi, vbi); // CHECK: and <4 x i32>
+ res_vsc = vec_vand(vsc, vsc); // CHECK: and <16 x i8>
+ res_vsc = vec_vand(vbc, vsc); // CHECK: and <16 x i8>
+ res_vsc = vec_vand(vsc, vbc); // CHECK: and <16 x i8>
+ res_vuc = vec_vand(vuc, vuc); // CHECK: and <16 x i8>
+ res_vuc = vec_vand(vbc, vuc); // CHECK: and <16 x i8>
+ res_vuc = vec_vand(vuc, vbc); // CHECK: and <16 x i8>
+ res_vbc = vec_vand(vbc, vbc); // CHECK: and <16 x i8>
+ res_vs = vec_vand(vs, vs); // CHECK: and <8 x i16>
+ res_vs = vec_vand(vbs, vs); // CHECK: and <8 x i16>
+ res_vs = vec_vand(vs, vbs); // CHECK: and <8 x i16>
+ res_vus = vec_vand(vus, vus); // CHECK: and <8 x i16>
+ res_vus = vec_vand(vbs, vus); // CHECK: and <8 x i16>
+ res_vus = vec_vand(vus, vbs); // CHECK: and <8 x i16>
+ res_vbs = vec_vand(vbs, vbs); // CHECK: and <8 x i16>
+ res_vi = vec_vand(vi, vi); // CHECK: and <4 x i32>
+ res_vi = vec_vand(vbi, vi); // CHECK: and <4 x i32>
+ res_vi = vec_vand(vi, vbi); // CHECK: and <4 x i32>
+ res_vui = vec_vand(vui, vui); // CHECK: and <4 x i32>
+ res_vui = vec_vand(vbi, vui); // CHECK: and <4 x i32>
+ res_vui = vec_vand(vui, vbi); // CHECK: and <4 x i32>
+ res_vbi = vec_vand(vbi, vbi); // CHECK: and <4 x i32>
+
+ /* vec_andc */
+ res_vsc = vec_andc(vsc, vsc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+
+ res_vsc = vec_andc(vbc, vsc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+
+ res_vsc = vec_andc(vsc, vbc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+
+ res_vuc = vec_andc(vuc, vuc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+
+ res_vuc = vec_andc(vbc, vuc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+
+ res_vuc = vec_andc(vuc, vbc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+
+ res_vbc = vec_andc(vbc, vbc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+
+ res_vs = vec_andc(vs, vs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+
+ res_vs = vec_andc(vbs, vs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+
+ res_vs = vec_andc(vs, vbs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+
+ res_vus = vec_andc(vus, vus); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+
+ res_vus = vec_andc(vbs, vus); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+
+ res_vus = vec_andc(vus, vbs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+
+ res_vbs = vec_andc(vbs, vbs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+
+ res_vi = vec_andc(vi, vi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vi = vec_andc(vbi, vi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vi = vec_andc(vi, vbi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vui = vec_andc(vui, vui); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vui = vec_andc(vbi, vui); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vui = vec_andc(vui, vbi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vf = vec_andc(vf, vf); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vf = vec_andc(vbi, vf); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vf = vec_andc(vf, vbi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vsc = vec_vandc(vsc, vsc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+
+ res_vsc = vec_vandc(vbc, vsc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+
+ res_vsc = vec_vandc(vsc, vbc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+
+ res_vuc = vec_vandc(vuc, vuc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+
+ res_vuc = vec_vandc(vbc, vuc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+
+ res_vuc = vec_vandc(vuc, vbc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+
+ res_vbc = vec_vandc(vbc, vbc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+
+ res_vs = vec_vandc(vs, vs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+
+ res_vs = vec_vandc(vbs, vs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+
+ res_vs = vec_vandc(vs, vbs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+
+ res_vus = vec_vandc(vus, vus); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+
+ res_vus = vec_vandc(vbs, vus); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+
+ res_vus = vec_vandc(vus, vbs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+
+ res_vbs = vec_vandc(vbs, vbs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+
+ res_vi = vec_vandc(vi, vi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vi = vec_vandc(vbi, vi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vi = vec_vandc(vi, vbi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vui = vec_vandc(vui, vui); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vui = vec_vandc(vbi, vui); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vui = vec_vandc(vui, vbi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vf = vec_vandc(vf, vf); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vf = vec_vandc(vbi, vf); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+ res_vf = vec_vandc(vf, vbi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+
+}
+
+// CHECK: define void @test2
+void test2() {
+ /* vec_avg */
+ res_vsc = vec_avg(vsc, vsc); // CHECK: @llvm.ppc.altivec.vavgsb
+ res_vuc = vec_avg(vuc, vuc); // CHECK: @llvm.ppc.altivec.vavgub
+ res_vs = vec_avg(vs, vs); // CHECK: @llvm.ppc.altivec.vavgsh
+ res_vus = vec_avg(vus, vus); // CHECK: @llvm.ppc.altivec.vavguh
+ res_vi = vec_avg(vi, vi); // CHECK: @llvm.ppc.altivec.vavgsw
+ res_vui = vec_avg(vui, vui); // CHECK: @llvm.ppc.altivec.vavguw
+ res_vsc = vec_vavgsb(vsc, vsc); // CHECK: @llvm.ppc.altivec.vavgsb
+ res_vuc = vec_vavgub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vavgub
+ res_vs = vec_vavgsh(vs, vs); // CHECK: @llvm.ppc.altivec.vavgsh
+ res_vus = vec_vavguh(vus, vus); // CHECK: @llvm.ppc.altivec.vavguh
+ res_vi = vec_vavgsw(vi, vi); // CHECK: @llvm.ppc.altivec.vavgsw
+ res_vui = vec_vavguw(vui, vui); // CHECK: @llvm.ppc.altivec.vavguw
+
+ /* vec_ceil */
+ res_vf = vec_ceil(vf); // CHECK: @llvm.ppc.altivec.vrfip
+ res_vf = vec_vrfip(vf); // CHECK: @llvm.ppc.altivec.vrfip
+
+ /* vec_cmpb */
+ res_vi = vec_cmpb(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpbfp
+ res_vi = vec_vcmpbfp(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpbfp
+
+ /* vec_cmpeq */
+ res_vbc = vec_cmpeq(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb
+ res_vbc = vec_cmpeq(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb
+ res_vbs = vec_cmpeq(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh
+ res_vbs = vec_cmpeq(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh
+ res_vbi = vec_cmpeq(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw
+ res_vbi = vec_cmpeq(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw
+ res_vbi = vec_cmpeq(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp
+
+ /* vec_cmpge */
+ res_vbi = vec_cmpge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp
+ res_vbi = vec_vcmpgefp(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp
+}
+
+// CHECK: define void @test5
+void test5() {
+
+ /* vec_cmpgt */
+ res_vbc = vec_cmpgt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb
+ res_vbc = vec_cmpgt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub
+ res_vbs = vec_cmpgt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh
+ res_vbs = vec_cmpgt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh
+ res_vbi = vec_cmpgt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw
+ res_vbi = vec_cmpgt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw
+ res_vbi = vec_cmpgt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp
+ res_vbc = vec_vcmpgtsb(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb
+ res_vbc = vec_vcmpgtub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub
+ res_vbs = vec_vcmpgtsh(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh
+ res_vbs = vec_vcmpgtuh(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh
+ res_vbi = vec_vcmpgtsw(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw
+ res_vbi = vec_vcmpgtuw(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw
+ res_vbi = vec_vcmpgtfp(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp
+
+ /* vec_cmple */
+ res_vbi = vec_cmple(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp
+}
+
+// CHECK: define void @test6
+void test6() {
+ /* vec_cmplt */
+ res_vbc = vec_cmplt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb
+ res_vbc = vec_cmplt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub
+ res_vbs = vec_cmplt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh
+ res_vbs = vec_cmplt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh
+ res_vbi = vec_cmplt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw
+ res_vbi = vec_cmplt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw
+ res_vbi = vec_cmplt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp
+
+ /* vec_ctf */
+ res_vf = vec_ctf(vi, param_i); // CHECK: @llvm.ppc.altivec.vcfsx
+ res_vf = vec_ctf(vui, 0); // CHECK: @llvm.ppc.altivec.vcfux
+ res_vf = vec_vcfsx(vi, 0); // CHECK: @llvm.ppc.altivec.vcfsx
+ res_vf = vec_vcfux(vui, 0); // CHECK: @llvm.ppc.altivec.vcfux
+
+ /* vec_cts */
+ res_vi = vec_cts(vf, 0); // CHECK: @llvm.ppc.altivec.vctsxs
+ res_vi = vec_vctsxs(vf, 0); // CHECK: @llvm.ppc.altivec.vctsxs
+
+ /* vec_ctu */
+ res_vui = vec_ctu(vf, 0); // CHECK: @llvm.ppc.altivec.vctuxs
+ res_vui = vec_vctuxs(vf, 0); // CHECK: @llvm.ppc.altivec.vctuxs
+
+ /* vec_dss */
+ vec_dss(param_i); // CHECK: @llvm.ppc.altivec.dss
+
+ /* vec_dssall */
+ vec_dssall(); // CHECK: @llvm.ppc.altivec.dssall
+
+ /* vec_dst */
+ vec_dst(&vsc, 0, 0); // CHECK: @llvm.ppc.altivec.dst
+
+ /* vec_dstst */
+ vec_dstst(&vs, 0, 0); // CHECK: @llvm.ppc.altivec.dstst
+
+ /* vec_dststt */
+ vec_dststt(&param_i, 0, 0); // CHECK: @llvm.ppc.altivec.dststt
+
+ /* vec_dstt */
+ vec_dstt(&vf, 0, 0); // CHECK: @llvm.ppc.altivec.dstt
+
+ /* vec_expte */
+ res_vf = vec_expte(vf); // CHECK: @llvm.ppc.altivec.vexptefp
+ res_vf = vec_vexptefp(vf); // CHECK: @llvm.ppc.altivec.vexptefp
+
+ /* vec_floor */
+ res_vf = vec_floor(vf); // CHECK: @llvm.ppc.altivec.vrfim
+ res_vf = vec_vrfim(vf); // CHECK: @llvm.ppc.altivec.vrfim
+
+ /* vec_ld */
+ res_vsc = vec_ld(0, &vsc); // CHECK: @llvm.ppc.altivec.lvx
+ res_vsc = vec_ld(0, &param_sc); // CHECK: @llvm.ppc.altivec.lvx
+ res_vuc = vec_ld(0, &vuc); // CHECK: @llvm.ppc.altivec.lvx
+ res_vuc = vec_ld(0, &param_uc); // CHECK: @llvm.ppc.altivec.lvx
+ res_vbc = vec_ld(0, &vbc); // CHECK: @llvm.ppc.altivec.lvx
+ res_vs = vec_ld(0, &vs); // CHECK: @llvm.ppc.altivec.lvx
+ res_vs = vec_ld(0, &param_s); // CHECK: @llvm.ppc.altivec.lvx
+ res_vus = vec_ld(0, &vus); // CHECK: @llvm.ppc.altivec.lvx
+ res_vus = vec_ld(0, &param_us); // CHECK: @llvm.ppc.altivec.lvx
+ res_vbs = vec_ld(0, &vbs); // CHECK: @llvm.ppc.altivec.lvx
+ res_vp = vec_ld(0, &vp); // CHECK: @llvm.ppc.altivec.lvx
+ res_vi = vec_ld(0, &vi); // CHECK: @llvm.ppc.altivec.lvx
+ res_vi = vec_ld(0, &param_i); // CHECK: @llvm.ppc.altivec.lvx
+ res_vui = vec_ld(0, &vui); // CHECK: @llvm.ppc.altivec.lvx
+ res_vui = vec_ld(0, &param_ui); // CHECK: @llvm.ppc.altivec.lvx
+ res_vbi = vec_ld(0, &vbi); // CHECK: @llvm.ppc.altivec.lvx
+ res_vf = vec_ld(0, &vf); // CHECK: @llvm.ppc.altivec.lvx
+ res_vf = vec_ld(0, &param_f); // CHECK: @llvm.ppc.altivec.lvx
+ res_vsc = vec_lvx(0, &vsc); // CHECK: @llvm.ppc.altivec.lvx
+ res_vsc = vec_lvx(0, &param_sc); // CHECK: @llvm.ppc.altivec.lvx
+ res_vuc = vec_lvx(0, &vuc); // CHECK: @llvm.ppc.altivec.lvx
+ res_vuc = vec_lvx(0, &param_uc); // CHECK: @llvm.ppc.altivec.lvx
+ res_vbc = vec_lvx(0, &vbc); // CHECK: @llvm.ppc.altivec.lvx
+ res_vs = vec_lvx(0, &vs); // CHECK: @llvm.ppc.altivec.lvx
+ res_vs = vec_lvx(0, &param_s); // CHECK: @llvm.ppc.altivec.lvx
+ res_vus = vec_lvx(0, &vus); // CHECK: @llvm.ppc.altivec.lvx
+ res_vus = vec_lvx(0, &param_us); // CHECK: @llvm.ppc.altivec.lvx
+ res_vbs = vec_lvx(0, &vbs); // CHECK: @llvm.ppc.altivec.lvx
+ res_vp = vec_lvx(0, &vp); // CHECK: @llvm.ppc.altivec.lvx
+ res_vi = vec_lvx(0, &vi); // CHECK: @llvm.ppc.altivec.lvx
+ res_vi = vec_lvx(0, &param_i); // CHECK: @llvm.ppc.altivec.lvx
+ res_vui = vec_lvx(0, &vui); // CHECK: @llvm.ppc.altivec.lvx
+ res_vui = vec_lvx(0, &param_ui); // CHECK: @llvm.ppc.altivec.lvx
+ res_vbi = vec_lvx(0, &vbi); // CHECK: @llvm.ppc.altivec.lvx
+ res_vf = vec_lvx(0, &vf); // CHECK: @llvm.ppc.altivec.lvx
+ res_vf = vec_lvx(0, &param_f); // CHECK: @llvm.ppc.altivec.lvx
+
+ /* vec_lde */
+ res_vsc = vec_lde(0, &vsc); // CHECK: @llvm.ppc.altivec.lvebx
+ res_vuc = vec_lde(0, &vuc); // CHECK: @llvm.ppc.altivec.lvebx
+ res_vs = vec_lde(0, &vs); // CHECK: @llvm.ppc.altivec.lvehx
+ res_vus = vec_lde(0, &vus); // CHECK: @llvm.ppc.altivec.lvehx
+ res_vi = vec_lde(0, &vi); // CHECK: @llvm.ppc.altivec.lvewx
+ res_vui = vec_lde(0, &vui); // CHECK: @llvm.ppc.altivec.lvewx
+ res_vf = vec_lde(0, &vf); // CHECK: @llvm.ppc.altivec.lvewx
+ res_vsc = vec_lvebx(0, &vsc); // CHECK: @llvm.ppc.altivec.lvebx
+ res_vuc = vec_lvebx(0, &vuc); // CHECK: @llvm.ppc.altivec.lvebx
+ res_vs = vec_lvehx(0, &vs); // CHECK: @llvm.ppc.altivec.lvehx
+ res_vus = vec_lvehx(0, &vus); // CHECK: @llvm.ppc.altivec.lvehx
+ res_vi = vec_lvewx(0, &vi); // CHECK: @llvm.ppc.altivec.lvewx
+ res_vui = vec_lvewx(0, &vui); // CHECK: @llvm.ppc.altivec.lvewx
+ res_vf = vec_lvewx(0, &vf); // CHECK: @llvm.ppc.altivec.lvewx
+
+ /* vec_ldl */
+ res_vsc = vec_ldl(0, &vsc); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vsc = vec_ldl(0, &param_sc); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vuc = vec_ldl(0, &vuc); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vuc = vec_ldl(0, &param_uc); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vbc = vec_ldl(0, &vbc); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vs = vec_ldl(0, &vs); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vs = vec_ldl(0, &param_s); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vus = vec_ldl(0, &vus); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vus = vec_ldl(0, &param_us); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vbs = vec_ldl(0, &vbs); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vp = vec_ldl(0, &vp); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vi = vec_ldl(0, &vi); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vi = vec_ldl(0, &param_i); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vui = vec_ldl(0, &vui); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vui = vec_ldl(0, &param_ui); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vbi = vec_ldl(0, &vbi); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vf = vec_ldl(0, &vf); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vf = vec_ldl(0, &param_f); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vsc = vec_lvxl(0, &vsc); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vsc = vec_lvxl(0, &param_sc); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vuc = vec_lvxl(0, &vuc); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vbc = vec_lvxl(0, &vbc); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vuc = vec_lvxl(0, &param_uc); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vs = vec_lvxl(0, &vs); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vs = vec_lvxl(0, &param_s); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vus = vec_lvxl(0, &vus); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vus = vec_lvxl(0, &param_us); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vbs = vec_lvxl(0, &vbs); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vp = vec_lvxl(0, &vp); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vi = vec_lvxl(0, &vi); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vi = vec_lvxl(0, &param_i); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vui = vec_lvxl(0, &vui); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vui = vec_lvxl(0, &param_ui); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vbi = vec_lvxl(0, &vbi); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vf = vec_lvxl(0, &vf); // CHECK: @llvm.ppc.altivec.lvxl
+ res_vf = vec_lvxl(0, &param_f); // CHECK: @llvm.ppc.altivec.lvxl
+
+ /* vec_loge */
+ res_vf = vec_loge(vf); // CHECK: @llvm.ppc.altivec.vlogefp
+ res_vf = vec_vlogefp(vf); // CHECK: @llvm.ppc.altivec.vlogefp
+
+ /* vec_lvsl */
+ res_vuc = vec_lvsl(0, &param_i); // CHECK: @llvm.ppc.altivec.lvsl
+
+ /* vec_lvsr */
+ res_vuc = vec_lvsr(0, &param_i); // CHECK: @llvm.ppc.altivec.lvsr
+
+ /* vec_madd */
+ res_vf =vec_madd(vf, vf, vf); // CHECK: @llvm.ppc.altivec.vmaddfp
+ res_vf = vec_vmaddfp(vf, vf, vf); // CHECK: @llvm.ppc.altivec.vmaddfp
+
+ /* vec_madds */
+ res_vs = vec_madds(vs, vs, vs); // CHECK: @llvm.ppc.altivec.vmhaddshs
+ res_vs = vec_vmhaddshs(vs, vs, vs); // CHECK: @llvm.ppc.altivec.vmhaddshs
+
+ /* vec_max */
+ res_vsc = vec_max(vsc, vsc); // CHECK: @llvm.ppc.altivec.vmaxsb
+ res_vsc = vec_max(vbc, vsc); // CHECK: @llvm.ppc.altivec.vmaxsb
+ res_vsc = vec_max(vsc, vbc); // CHECK: @llvm.ppc.altivec.vmaxsb
+ res_vuc = vec_max(vuc, vuc); // CHECK: @llvm.ppc.altivec.vmaxub
+ res_vuc = vec_max(vbc, vuc); // CHECK: @llvm.ppc.altivec.vmaxub
+ res_vuc = vec_max(vuc, vbc); // CHECK: @llvm.ppc.altivec.vmaxub
+ res_vs = vec_max(vs, vs); // CHECK: @llvm.ppc.altivec.vmaxsh
+ res_vs = vec_max(vbs, vs); // CHECK: @llvm.ppc.altivec.vmaxsh
+ res_vs = vec_max(vs, vbs); // CHECK: @llvm.ppc.altivec.vmaxsh
+ res_vus = vec_max(vus, vus); // CHECK: @llvm.ppc.altivec.vmaxuh
+ res_vus = vec_max(vbs, vus); // CHECK: @llvm.ppc.altivec.vmaxuh
+ res_vus = vec_max(vus, vbs); // CHECK: @llvm.ppc.altivec.vmaxuh
+ res_vi = vec_max(vi, vi); // CHECK: @llvm.ppc.altivec.vmaxsw
+ res_vi = vec_max(vbi, vi); // CHECK: @llvm.ppc.altivec.vmaxsw
+ res_vi = vec_max(vi, vbi); // CHECK: @llvm.ppc.altivec.vmaxsw
+ res_vui = vec_max(vui, vui); // CHECK: @llvm.ppc.altivec.vmaxuw
+ res_vui = vec_max(vbi, vui); // CHECK: @llvm.ppc.altivec.vmaxuw
+ res_vui = vec_max(vui, vbi); // CHECK: @llvm.ppc.altivec.vmaxuw
+ res_vf = vec_max(vf, vf); // CHECK: @llvm.ppc.altivec.vmaxfp
+ res_vsc = vec_vmaxsb(vsc, vsc); // CHECK: @llvm.ppc.altivec.vmaxsb
+ res_vsc = vec_vmaxsb(vbc, vsc); // CHECK: @llvm.ppc.altivec.vmaxsb
+ res_vsc = vec_vmaxsb(vsc, vbc); // CHECK: @llvm.ppc.altivec.vmaxsb
+ res_vuc = vec_vmaxub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vmaxub
+ res_vuc = vec_vmaxub(vbc, vuc); // CHECK: @llvm.ppc.altivec.vmaxub
+ res_vuc = vec_vmaxub(vuc, vbc); // CHECK: @llvm.ppc.altivec.vmaxub
+ res_vs = vec_vmaxsh(vs, vs); // CHECK: @llvm.ppc.altivec.vmaxsh
+ res_vs = vec_vmaxsh(vbs, vs); // CHECK: @llvm.ppc.altivec.vmaxsh
+ res_vs = vec_vmaxsh(vs, vbs); // CHECK: @llvm.ppc.altivec.vmaxsh
+ res_vus = vec_vmaxuh(vus, vus); // CHECK: @llvm.ppc.altivec.vmaxuh
+ res_vus = vec_vmaxuh(vbs, vus); // CHECK: @llvm.ppc.altivec.vmaxuh
+ res_vus = vec_vmaxuh(vus, vbs); // CHECK: @llvm.ppc.altivec.vmaxuh
+ res_vi = vec_vmaxsw(vi, vi); // CHECK: @llvm.ppc.altivec.vmaxsw
+ res_vi = vec_vmaxsw(vbi, vi); // CHECK: @llvm.ppc.altivec.vmaxsw
+ res_vi = vec_vmaxsw(vi, vbi); // CHECK: @llvm.ppc.altivec.vmaxsw
+ res_vui = vec_vmaxuw(vui, vui); // CHECK: @llvm.ppc.altivec.vmaxuw
+ res_vui = vec_vmaxuw(vbi, vui); // CHECK: @llvm.ppc.altivec.vmaxuw
+ res_vui = vec_vmaxuw(vui, vbi); // CHECK: @llvm.ppc.altivec.vmaxuw
+ res_vf = vec_vmaxfp(vf, vf); // CHECK: @llvm.ppc.altivec.vmaxfp
+
+ /* vec_mergeh */
+ res_vsc = vec_mergeh(vsc, vsc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vuc = vec_mergeh(vuc, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbc = vec_mergeh(vbc, vbc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vs = vec_mergeh(vs, vs); // CHECK: @llvm.ppc.altivec.vperm
+ res_vp = vec_mergeh(vp, vp); // CHECK: @llvm.ppc.altivec.vperm
+ res_vus = vec_mergeh(vus, vus); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbs = vec_mergeh(vbs, vbs); // CHECK: @llvm.ppc.altivec.vperm
+ res_vi = vec_mergeh(vi, vi); // CHECK: @llvm.ppc.altivec.vperm
+ res_vui = vec_mergeh(vui, vui); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbi = vec_mergeh(vbi, vbi); // CHECK: @llvm.ppc.altivec.vperm
+ res_vf = vec_mergeh(vf, vf); // CHECK: @llvm.ppc.altivec.vperm
+ res_vsc = vec_vmrghb(vsc, vsc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vuc = vec_vmrghb(vuc, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbc = vec_vmrghb(vbc, vbc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vs = vec_vmrghh(vs, vs); // CHECK: @llvm.ppc.altivec.vperm
+ res_vp = vec_vmrghh(vp, vp); // CHECK: @llvm.ppc.altivec.vperm
+ res_vus = vec_vmrghh(vus, vus); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbs = vec_vmrghh(vbs, vbs); // CHECK: @llvm.ppc.altivec.vperm
+ res_vi = vec_vmrghw(vi, vi); // CHECK: @llvm.ppc.altivec.vperm
+ res_vui = vec_vmrghw(vui, vui); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbi = vec_vmrghw(vbi, vbi); // CHECK: @llvm.ppc.altivec.vperm
+ res_vf = vec_vmrghw(vf, vf); // CHECK: @llvm.ppc.altivec.vperm
+
+ /* vec_mergel */
+ res_vsc = vec_mergel(vsc, vsc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vuc = vec_mergel(vuc, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbc = vec_mergel(vbc, vbc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vs = vec_mergel(vs, vs); // CHECK: @llvm.ppc.altivec.vperm
+ res_vp = vec_mergeh(vp, vp); // CHECK: @llvm.ppc.altivec.vperm
+ res_vus = vec_mergel(vus, vus); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbs = vec_mergel(vbs, vbs); // CHECK: @llvm.ppc.altivec.vperm
+ res_vi = vec_mergel(vi, vi); // CHECK: @llvm.ppc.altivec.vperm
+ res_vui = vec_mergel(vui, vui); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbi = vec_mergel(vbi, vbi); // CHECK: @llvm.ppc.altivec.vperm
+ res_vf = vec_mergel(vf, vf); // CHECK: @llvm.ppc.altivec.vperm
+ res_vsc = vec_vmrglb(vsc, vsc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vuc = vec_vmrglb(vuc, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbc = vec_vmrglb(vbc, vbc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vs = vec_vmrglh(vs, vs); // CHECK: @llvm.ppc.altivec.vperm
+ res_vp = vec_vmrglh(vp, vp); // CHECK: @llvm.ppc.altivec.vperm
+ res_vus = vec_vmrglh(vus, vus); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbs = vec_vmrglh(vbs, vbs); // CHECK: @llvm.ppc.altivec.vperm
+ res_vi = vec_vmrglw(vi, vi); // CHECK: @llvm.ppc.altivec.vperm
+ res_vui = vec_vmrglw(vui, vui); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbi = vec_vmrglw(vbi, vbi); // CHECK: @llvm.ppc.altivec.vperm
+ res_vf = vec_vmrglw(vf, vf); // CHECK: @llvm.ppc.altivec.vperm
+
+ /* vec_mfvscr */
+ vus = vec_mfvscr(); // CHECK: @llvm.ppc.altivec.mfvscr
+
+ /* vec_min */
+ res_vsc = vec_min(vsc, vsc); // CHECK: @llvm.ppc.altivec.vminsb
+ res_vsc = vec_min(vbc, vsc); // CHECK: @llvm.ppc.altivec.vminsb
+ res_vsc = vec_min(vsc, vbc); // CHECK: @llvm.ppc.altivec.vminsb
+ res_vuc = vec_min(vuc, vuc); // CHECK: @llvm.ppc.altivec.vminub
+ res_vuc = vec_min(vbc, vuc); // CHECK: @llvm.ppc.altivec.vminub
+ res_vuc = vec_min(vuc, vbc); // CHECK: @llvm.ppc.altivec.vminub
+ res_vs = vec_min(vs, vs); // CHECK: @llvm.ppc.altivec.vminsh
+ res_vs = vec_min(vbs, vs); // CHECK: @llvm.ppc.altivec.vminsh
+ res_vs = vec_min(vs, vbs); // CHECK: @llvm.ppc.altivec.vminsh
+ res_vus = vec_min(vus, vus); // CHECK: @llvm.ppc.altivec.vminuh
+ res_vus = vec_min(vbs, vus); // CHECK: @llvm.ppc.altivec.vminuh
+ res_vus = vec_min(vus, vbs); // CHECK: @llvm.ppc.altivec.vminuh
+ res_vi = vec_min(vi, vi); // CHECK: @llvm.ppc.altivec.vminsw
+ res_vi = vec_min(vbi, vi); // CHECK: @llvm.ppc.altivec.vminsw
+ res_vi = vec_min(vi, vbi); // CHECK: @llvm.ppc.altivec.vminsw
+ res_vui = vec_min(vui, vui); // CHECK: @llvm.ppc.altivec.vminuw
+ res_vui = vec_min(vbi, vui); // CHECK: @llvm.ppc.altivec.vminuw
+ res_vui = vec_min(vui, vbi); // CHECK: @llvm.ppc.altivec.vminuw
+ res_vf = vec_min(vf, vf); // CHECK: @llvm.ppc.altivec.vminfp
+ res_vsc = vec_vminsb(vsc, vsc); // CHECK: @llvm.ppc.altivec.vminsb
+ res_vsc = vec_vminsb(vbc, vsc); // CHECK: @llvm.ppc.altivec.vminsb
+ res_vsc = vec_vminsb(vsc, vbc); // CHECK: @llvm.ppc.altivec.vminsb
+ res_vuc = vec_vminub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vminub
+ res_vuc = vec_vminub(vbc, vuc); // CHECK: @llvm.ppc.altivec.vminub
+ res_vuc = vec_vminub(vuc, vbc); // CHECK: @llvm.ppc.altivec.vminub
+ res_vs = vec_vminsh(vs, vs); // CHECK: @llvm.ppc.altivec.vminsh
+ res_vs = vec_vminsh(vbs, vs); // CHECK: @llvm.ppc.altivec.vminsh
+ res_vs = vec_vminsh(vs, vbs); // CHECK: @llvm.ppc.altivec.vminsh
+ res_vus = vec_vminuh(vus, vus); // CHECK: @llvm.ppc.altivec.vminuh
+ res_vus = vec_vminuh(vbs, vus); // CHECK: @llvm.ppc.altivec.vminuh
+ res_vus = vec_vminuh(vus, vbs); // CHECK: @llvm.ppc.altivec.vminuh
+ res_vi = vec_vminsw(vi, vi); // CHECK: @llvm.ppc.altivec.vminsw
+ res_vi = vec_vminsw(vbi, vi); // CHECK: @llvm.ppc.altivec.vminsw
+ res_vi = vec_vminsw(vi, vbi); // CHECK: @llvm.ppc.altivec.vminsw
+ res_vui = vec_vminuw(vui, vui); // CHECK: @llvm.ppc.altivec.vminuw
+ res_vui = vec_vminuw(vbi, vui); // CHECK: @llvm.ppc.altivec.vminuw
+ res_vui = vec_vminuw(vui, vbi); // CHECK: @llvm.ppc.altivec.vminuw
+ res_vf = vec_vminfp(vf, vf); // CHECK: @llvm.ppc.altivec.vminfp
+
+ /* vec_mladd */
+ res_vus = vec_mladd(vus, vus, vus); // CHECK: mul <8 x i16>
+ // CHECK: add <8 x i16>
+
+ res_vs = vec_mladd(vus, vs, vs); // CHECK: mul <8 x i16>
+ // CHECK: add <8 x i16>
+
+ res_vs = vec_mladd(vs, vus, vus); // CHECK: mul <8 x i16>
+ // CHECK: add <8 x i16>
+
+ res_vs = vec_mladd(vs, vs, vs); // CHECK: mul <8 x i16>
+ // CHECK: add <8 x i16>
+
+ /* vec_mradds */
+ res_vs = vec_mradds(vs, vs, vs); // CHECK: @llvm.ppc.altivec.vmhraddshs
+ res_vs = vec_vmhraddshs(vs, vs, vs); // CHECK: @llvm.ppc.altivec.vmhraddshs
+
+ /* vec_msum */
+ res_vi = vec_msum(vsc, vuc, vi); // CHECK: @llvm.ppc.altivec.vmsummbm
+ res_vui = vec_msum(vuc, vuc, vui); // CHECK: @llvm.ppc.altivec.vmsumubm
+ res_vi = vec_msum(vs, vs, vi); // CHECK: @llvm.ppc.altivec.vmsumshm
+ res_vui = vec_msum(vus, vus, vui); // CHECK: @llvm.ppc.altivec.vmsumuhm
+ res_vi = vec_vmsummbm(vsc, vuc, vi); // CHECK: @llvm.ppc.altivec.vmsummbm
+ res_vui = vec_vmsumubm(vuc, vuc, vui); // CHECK: @llvm.ppc.altivec.vmsumubm
+ res_vi = vec_vmsumshm(vs, vs, vi); // CHECK: @llvm.ppc.altivec.vmsumshm
+ res_vui = vec_vmsumuhm(vus, vus, vui); // CHECK: @llvm.ppc.altivec.vmsumuhm
+
+ /* vec_msums */
+ res_vi = vec_msums(vs, vs, vi); // CHECK: @llvm.ppc.altivec.vmsumshs
+ res_vui = vec_msums(vus, vus, vui); // CHECK: @llvm.ppc.altivec.vmsumuhs
+ res_vi = vec_vmsumshs(vs, vs, vi); // CHECK: @llvm.ppc.altivec.vmsumshs
+ res_vui = vec_vmsumuhs(vus, vus, vui); // CHECK: @llvm.ppc.altivec.vmsumuhs
+
+ /* vec_mtvscr */
+ vec_mtvscr(vsc); // CHECK: @llvm.ppc.altivec.mtvscr
+ vec_mtvscr(vuc); // CHECK: @llvm.ppc.altivec.mtvscr
+ vec_mtvscr(vbc); // CHECK: @llvm.ppc.altivec.mtvscr
+ vec_mtvscr(vs); // CHECK: @llvm.ppc.altivec.mtvscr
+ vec_mtvscr(vus); // CHECK: @llvm.ppc.altivec.mtvscr
+ vec_mtvscr(vbs); // CHECK: @llvm.ppc.altivec.mtvscr
+ vec_mtvscr(vp); // CHECK: @llvm.ppc.altivec.mtvscr
+ vec_mtvscr(vi); // CHECK: @llvm.ppc.altivec.mtvscr
+ vec_mtvscr(vui); // CHECK: @llvm.ppc.altivec.mtvscr
+ vec_mtvscr(vbi); // CHECK: @llvm.ppc.altivec.mtvscr
+
+ /* vec_mule */
+ res_vs = vec_mule(vsc, vsc); // CHECK: @llvm.ppc.altivec.vmulesb
+ res_vus = vec_mule(vuc, vuc); // CHECK: @llvm.ppc.altivec.vmuleub
+ res_vi = vec_mule(vs, vs); // CHECK: @llvm.ppc.altivec.vmulesh
+ res_vui = vec_mule(vus, vus); // CHECK: @llvm.ppc.altivec.vmuleuh
+ res_vs = vec_vmulesb(vsc, vsc); // CHECK: @llvm.ppc.altivec.vmulesb
+ res_vus = vec_vmuleub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vmuleub
+ res_vi = vec_vmulesh(vs, vs); // CHECK: @llvm.ppc.altivec.vmulesh
+ res_vui = vec_vmuleuh(vus, vus); // CHECK: @llvm.ppc.altivec.vmuleuh
+
+ /* vec_mulo */
+ res_vs = vec_mulo(vsc, vsc); // CHECK: @llvm.ppc.altivec.vmulosb
+ res_vus = vec_mulo(vuc, vuc); // CHECK: @llvm.ppc.altivec.vmuloub
+ res_vi = vec_mulo(vs, vs); // CHECK: @llvm.ppc.altivec.vmulosh
+ res_vui = vec_mulo(vus, vus); // CHECK: @llvm.ppc.altivec.vmulouh
+ res_vs = vec_vmulosb(vsc, vsc); // CHECK: @llvm.ppc.altivec.vmulosb
+ res_vus = vec_vmuloub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vmuloub
+ res_vi = vec_vmulosh(vs, vs); // CHECK: @llvm.ppc.altivec.vmulosh
+ res_vui = vec_vmulouh(vus, vus); // CHECK: @llvm.ppc.altivec.vmulouh
+
+ /* vec_nmsub */
+ res_vf = vec_nmsub(vf, vf, vf); // CHECK: @llvm.ppc.altivec.vnmsubfp
+ res_vf = vec_vnmsubfp(vf, vf, vf); // CHECK: @llvm.ppc.altivec.vnmsubfp
+
+ /* vec_nor */
+ res_vsc = vec_nor(vsc, vsc); // CHECK: or <16 x i8>
+ // CHECK: xor <16 x i8>
+
+ res_vuc = vec_nor(vuc, vuc); // CHECK: or <16 x i8>
+ // CHECK: xor <16 x i8>
+
+ res_vuc = vec_nor(vbc, vbc); // CHECK: or <16 x i8>
+ // CHECK: xor <16 x i8>
+
+ res_vs = vec_nor(vs, vs); // CHECK: or <8 x i16>
+ // CHECK: xor <8 x i16>
+
+ res_vus = vec_nor(vus, vus); // CHECK: or <8 x i16>
+ // CHECK: xor <8 x i16>
+
+ res_vus = vec_nor(vbs, vbs); // CHECK: or <8 x i16>
+ // CHECK: xor <8 x i16>
+
+ res_vi = vec_nor(vi, vi); // CHECK: or <4 x i32>
+ // CHECK: xor <4 x i32>
+
+ res_vui = vec_nor(vui, vui); // CHECK: or <4 x i32>
+ // CHECK: xor <4 x i32>
+
+ res_vui = vec_nor(vbi, vbi); // CHECK: or <4 x i32>
+ // CHECK: xor <4 x i32>
+
+ res_vf = vec_nor(vf, vf); // CHECK: or <4 x i32>
+ // CHECK: xor <4 x i32>
+
+ res_vsc = vec_vnor(vsc, vsc); // CHECK: or <16 x i8>
+ // CHECK: xor <16 x i8>
+
+ res_vuc = vec_vnor(vuc, vuc); // CHECK: or <16 x i8>
+ // CHECK: xor <16 x i8>
+
+ res_vuc = vec_vnor(vbc, vbc); // CHECK: or <16 x i8>
+ // CHECK: xor <16 x i8>
+
+ res_vs = vec_vnor(vs, vs); // CHECK: or <8 x i16>
+ // CHECK: xor <8 x i16>
+
+ res_vus = vec_vnor(vus, vus); // CHECK: or <8 x i16>
+ // CHECK: xor <8 x i16>
+
+ res_vus = vec_vnor(vbs, vbs); // CHECK: or <8 x i16>
+ // CHECK: xor <8 x i16>
+
+ res_vi = vec_vnor(vi, vi); // CHECK: or <4 x i32>
+ // CHECK: xor <4 x i32>
+
+ res_vui = vec_vnor(vui, vui); // CHECK: or <4 x i32>
+ // CHECK: xor <4 x i32>
+
+ res_vui = vec_vnor(vbi, vbi); // CHECK: or <4 x i32>
+ // CHECK: xor <4 x i32>
+
+ res_vf = vec_vnor(vf, vf); // CHECK: or <4 x i32>
+ // CHECK: xor <4 x i32>
+
+ /* vec_or */
+ res_vsc = vec_or(vsc, vsc); // CHECK: or <16 x i8>
+ res_vsc = vec_or(vbc, vsc); // CHECK: or <16 x i8>
+ res_vsc = vec_or(vsc, vbc); // CHECK: or <16 x i8>
+ res_vuc = vec_or(vuc, vuc); // CHECK: or <16 x i8>
+ res_vuc = vec_or(vbc, vuc); // CHECK: or <16 x i8>
+ res_vuc = vec_or(vuc, vbc); // CHECK: or <16 x i8>
+ res_vbc = vec_or(vbc, vbc); // CHECK: or <16 x i8>
+ res_vs = vec_or(vs, vs); // CHECK: or <8 x i16>
+ res_vs = vec_or(vbs, vs); // CHECK: or <8 x i16>
+ res_vs = vec_or(vs, vbs); // CHECK: or <8 x i16>
+ res_vus = vec_or(vus, vus); // CHECK: or <8 x i16>
+ res_vus = vec_or(vbs, vus); // CHECK: or <8 x i16>
+ res_vus = vec_or(vus, vbs); // CHECK: or <8 x i16>
+ res_vbs = vec_or(vbs, vbs); // CHECK: or <8 x i16>
+ res_vi = vec_or(vi, vi); // CHECK: or <4 x i32>
+ res_vi = vec_or(vbi, vi); // CHECK: or <4 x i32>
+ res_vi = vec_or(vi, vbi); // CHECK: or <4 x i32>
+ res_vui = vec_or(vui, vui); // CHECK: or <4 x i32>
+ res_vui = vec_or(vbi, vui); // CHECK: or <4 x i32>
+ res_vui = vec_or(vui, vbi); // CHECK: or <4 x i32>
+ res_vbi = vec_or(vbi, vbi); // CHECK: or <4 x i32>
+ res_vf = vec_or(vf, vf); // CHECK: or <4 x i32>
+ res_vf = vec_or(vbi, vf); // CHECK: or <4 x i32>
+ res_vf = vec_or(vf, vbi); // CHECK: or <4 x i32>
+ res_vsc = vec_vor(vsc, vsc); // CHECK: or <16 x i8>
+ res_vsc = vec_vor(vbc, vsc); // CHECK: or <16 x i8>
+ res_vsc = vec_vor(vsc, vbc); // CHECK: or <16 x i8>
+ res_vuc = vec_vor(vuc, vuc); // CHECK: or <16 x i8>
+ res_vuc = vec_vor(vbc, vuc); // CHECK: or <16 x i8>
+ res_vuc = vec_vor(vuc, vbc); // CHECK: or <16 x i8>
+ res_vbc = vec_vor(vbc, vbc); // CHECK: or <16 x i8>
+ res_vs = vec_vor(vs, vs); // CHECK: or <8 x i16>
+ res_vs = vec_vor(vbs, vs); // CHECK: or <8 x i16>
+ res_vs = vec_vor(vs, vbs); // CHECK: or <8 x i16>
+ res_vus = vec_vor(vus, vus); // CHECK: or <8 x i16>
+ res_vus = vec_vor(vbs, vus); // CHECK: or <8 x i16>
+ res_vus = vec_vor(vus, vbs); // CHECK: or <8 x i16>
+ res_vbs = vec_vor(vbs, vbs); // CHECK: or <8 x i16>
+ res_vi = vec_vor(vi, vi); // CHECK: or <4 x i32>
+ res_vi = vec_vor(vbi, vi); // CHECK: or <4 x i32>
+ res_vi = vec_vor(vi, vbi); // CHECK: or <4 x i32>
+ res_vui = vec_vor(vui, vui); // CHECK: or <4 x i32>
+ res_vui = vec_vor(vbi, vui); // CHECK: or <4 x i32>
+ res_vui = vec_vor(vui, vbi); // CHECK: or <4 x i32>
+ res_vbi = vec_vor(vbi, vbi); // CHECK: or <4 x i32>
+ res_vf = vec_vor(vf, vf); // CHECK: or <4 x i32>
+ res_vf = vec_vor(vbi, vf); // CHECK: or <4 x i32>
+ res_vf = vec_vor(vf, vbi); // CHECK: or <4 x i32>
+
+ /* vec_pack */
+ res_vsc = vec_pack(vs, vs); // CHECK: @llvm.ppc.altivec.vperm
+ res_vuc = vec_pack(vus, vus); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbc = vec_pack(vbs, vbs); // CHECK: @llvm.ppc.altivec.vperm
+ res_vs = vec_pack(vi, vi); // CHECK: @llvm.ppc.altivec.vperm
+ res_vus = vec_pack(vui, vui); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbs = vec_pack(vbi, vbi); // CHECK: @llvm.ppc.altivec.vperm
+ res_vsc = vec_vpkuhum(vs, vs); // CHECK: @llvm.ppc.altivec.vperm
+ res_vuc = vec_vpkuhum(vus, vus); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbc = vec_vpkuhum(vbs, vbs); // CHECK: @llvm.ppc.altivec.vperm
+ res_vs = vec_vpkuwum(vi, vi); // CHECK: @llvm.ppc.altivec.vperm
+ res_vus = vec_vpkuwum(vui, vui); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbs = vec_vpkuwum(vbi, vbi); // CHECK: @llvm.ppc.altivec.vperm
+
+ /* vec_packpx */
+ res_vp = vec_packpx(vui, vui); // CHECK: @llvm.ppc.altivec.vpkpx
+ res_vp = vec_vpkpx(vui, vui); // CHECK: @llvm.ppc.altivec.vpkpx
+
+ /* vec_packs */
+ res_vsc = vec_packs(vs, vs); // CHECK: @llvm.ppc.altivec.vpkshss
+ res_vuc = vec_packs(vus, vus); // CHECK: @llvm.ppc.altivec.vpkuhus
+ res_vs = vec_packs(vi, vi); // CHECK: @llvm.ppc.altivec.vpkswss
+ res_vus = vec_packs(vui, vui); // CHECK: @llvm.ppc.altivec.vpkuwus
+ res_vsc = vec_vpkshss(vs, vs); // CHECK: @llvm.ppc.altivec.vpkshss
+ res_vuc = vec_vpkuhus(vus, vus); // CHECK: @llvm.ppc.altivec.vpkuhus
+ res_vs = vec_vpkswss(vi, vi); // CHECK: @llvm.ppc.altivec.vpkswss
+ res_vus = vec_vpkuwus(vui, vui); // CHECK: @llvm.ppc.altivec.vpkuwus
+
+ /* vec_packsu */
+ res_vuc = vec_packsu(vs, vs); // CHECK: @llvm.ppc.altivec.vpkshus
+ res_vuc = vec_packsu(vus, vus); // CHECK: @llvm.ppc.altivec.vpkuhus
+ res_vus = vec_packsu(vi, vi); // CHECK: @llvm.ppc.altivec.vpkswus
+ res_vus = vec_packsu(vui, vui); // CHECK: @llvm.ppc.altivec.vpkuwus
+ res_vuc = vec_vpkshus(vs, vs); // CHECK: @llvm.ppc.altivec.vpkshus
+ res_vuc = vec_vpkshus(vus, vus); // CHECK: @llvm.ppc.altivec.vpkuhus
+ res_vus = vec_vpkswus(vi, vi); // CHECK: @llvm.ppc.altivec.vpkswus
+ res_vus = vec_vpkswus(vui, vui); // CHECK: @llvm.ppc.altivec.vpkuwus
+
+ /* vec_perm */
+ res_vsc = vec_perm(vsc, vsc, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vuc = vec_perm(vuc, vuc, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbc = vec_perm(vbc, vbc, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vs = vec_perm(vs, vs, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vus = vec_perm(vus, vus, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbs = vec_perm(vbs, vbs, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vp = vec_perm(vp, vp, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vi = vec_perm(vi, vi, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vui = vec_perm(vui, vui, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbi = vec_perm(vbi, vbi, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vf = vec_perm(vf, vf, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vsc = vec_vperm(vsc, vsc, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vuc = vec_vperm(vuc, vuc, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbc = vec_vperm(vbc, vbc, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vs = vec_vperm(vs, vs, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vus = vec_vperm(vus, vus, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbs = vec_vperm(vbs, vbs, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vp = vec_vperm(vp, vp, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vi = vec_vperm(vi, vi, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vui = vec_vperm(vui, vui, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbi = vec_vperm(vbi, vbi, vuc); // CHECK: @llvm.ppc.altivec.vperm
+ res_vf = vec_vperm(vf, vf, vuc); // CHECK: @llvm.ppc.altivec.vperm
+
+ /* vec_re */
+ res_vf = vec_re(vf); // CHECK: @llvm.ppc.altivec.vrefp
+ res_vf = vec_vrefp(vf); // CHECK: @llvm.ppc.altivec.vrefp
+
+ /* vec_rl */
+ res_vsc = vec_rl(vsc, vuc); // CHECK: @llvm.ppc.altivec.vrlb
+ res_vuc = vec_rl(vuc, vuc); // CHECK: @llvm.ppc.altivec.vrlb
+ res_vs = vec_rl(vs, vus); // CHECK: @llvm.ppc.altivec.vrlh
+ res_vus = vec_rl(vus, vus); // CHECK: @llvm.ppc.altivec.vrlh
+ res_vi = vec_rl(vi, vui); // CHECK: @llvm.ppc.altivec.vrlw
+ res_vui = vec_rl(vui, vui); // CHECK: @llvm.ppc.altivec.vrlw
+ res_vsc = vec_vrlb(vsc, vuc); // CHECK: @llvm.ppc.altivec.vrlb
+ res_vuc = vec_vrlb(vuc, vuc); // CHECK: @llvm.ppc.altivec.vrlb
+ res_vs = vec_vrlh(vs, vus); // CHECK: @llvm.ppc.altivec.vrlh
+ res_vus = vec_vrlh(vus, vus); // CHECK: @llvm.ppc.altivec.vrlh
+ res_vi = vec_vrlw(vi, vui); // CHECK: @llvm.ppc.altivec.vrlw
+ res_vui = vec_vrlw(vui, vui); // CHECK: @llvm.ppc.altivec.vrlw
+
+ /* vec_round */
+ res_vf = vec_round(vf); // CHECK: @llvm.ppc.altivec.vrfin
+ res_vf = vec_vrfin(vf); // CHECK: @llvm.ppc.altivec.vrfin
+
+ /* vec_rsqrte */
+ res_vf = vec_rsqrte(vf); // CHECK: @llvm.ppc.altivec.vrsqrtefp
+ res_vf = vec_vrsqrtefp(vf); // CHECK: @llvm.ppc.altivec.vrsqrtefp
+
+ /* vec_sel */
+ res_vsc = vec_sel(vsc, vsc, vuc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: or <16 x i8>
+
+ res_vsc = vec_sel(vsc, vsc, vbc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: or <16 x i8>
+
+ res_vuc = vec_sel(vuc, vuc, vuc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: or <16 x i8>
+
+ res_vuc = vec_sel(vuc, vuc, vbc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: or <16 x i8>
+
+ res_vbc = vec_sel(vbc, vbc, vuc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: or <16 x i8>
+
+ res_vbc = vec_sel(vbc, vbc, vbc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: or <16 x i8>
+
+ res_vs = vec_sel(vs, vs, vus); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: or <8 x i16>
+
+ res_vs = vec_sel(vs, vs, vbs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: or <8 x i16>
+
+ res_vus = vec_sel(vus, vus, vus); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: or <8 x i16>
+
+ res_vus = vec_sel(vus, vus, vbs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: or <8 x i16>
+
+ res_vbs = vec_sel(vbs, vbs, vus); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: or <8 x i16>
+
+ res_vbs = vec_sel(vbs, vbs, vbs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: or <8 x i16>
+
+ res_vi = vec_sel(vi, vi, vui); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ res_vi = vec_sel(vi, vi, vbi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ res_vui = vec_sel(vui, vui, vui); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ res_vui = vec_sel(vui, vui, vbi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ res_vbi = vec_sel(vbi, vbi, vui); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ res_vbi = vec_sel(vbi, vbi, vbi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ res_vf = vec_sel(vf, vf, vui); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ res_vf = vec_sel(vf, vf, vbi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ res_vsc = vec_vsel(vsc, vsc, vuc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: or <16 x i8>
+
+ res_vsc = vec_vsel(vsc, vsc, vbc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: or <16 x i8>
+
+ res_vuc = vec_vsel(vuc, vuc, vuc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: or <16 x i8>
+
+ res_vuc = vec_vsel(vuc, vuc, vbc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: or <16 x i8>
+
+ res_vbc = vec_vsel(vbc, vbc, vuc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: or <16 x i8>
+
+ res_vbc = vec_vsel(vbc, vbc, vbc); // CHECK: xor <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: and <16 x i8>
+ // CHECK: or <16 x i8>
+
+ res_vs = vec_vsel(vs, vs, vus); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: or <8 x i16>
+
+ res_vs = vec_vsel(vs, vs, vbs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: or <8 x i16>
+
+ res_vus = vec_vsel(vus, vus, vus); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: or <8 x i16>
+
+ res_vus = vec_vsel(vus, vus, vbs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: or <8 x i16>
+
+ res_vbs = vec_vsel(vbs, vbs, vus); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: or <8 x i16>
+
+ res_vbs = vec_vsel(vbs, vbs, vbs); // CHECK: xor <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: and <8 x i16>
+ // CHECK: or <8 x i16>
+
+ res_vi = vec_vsel(vi, vi, vui); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ res_vi = vec_vsel(vi, vi, vbi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ res_vui = vec_vsel(vui, vui, vui); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ res_vui = vec_vsel(vui, vui, vbi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ res_vbi = vec_vsel(vbi, vbi, vui); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ res_vbi = vec_vsel(vbi, vbi, vbi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ res_vf = vec_vsel(vf, vf, vui); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ res_vf = vec_vsel(vf, vf, vbi); // CHECK: xor <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: and <4 x i32>
+ // CHECK: or <4 x i32>
+
+ /* vec_sl */
+ res_vsc = vec_sl(vsc, vuc); // CHECK: shl <16 x i8>
+ res_vuc = vec_sl(vuc, vuc); // CHECK: shl <16 x i8>
+ res_vs = vec_sl(vs, vus); // CHECK: shl <8 x i16>
+ res_vus = vec_sl(vus, vus); // CHECK: shl <8 x i16>
+ res_vi = vec_sl(vi, vui); // CHECK: shl <4 x i32>
+ res_vui = vec_sl(vui, vui); // CHECK: shl <4 x i32>
+ res_vsc = vec_vslb(vsc, vuc); // CHECK: shl <16 x i8>
+ res_vuc = vec_vslb(vuc, vuc); // CHECK: shl <16 x i8>
+ res_vs = vec_vslh(vs, vus); // CHECK: shl <8 x i16>
+ res_vus = vec_vslh(vus, vus); // CHECK: shl <8 x i16>
+ res_vi = vec_vslw(vi, vui); // CHECK: shl <4 x i32>
+ res_vui = vec_vslw(vui, vui); // CHECK: shl <4 x i32>
+
+ /* vec_sld */
+ res_vsc = vec_sld(vsc, vsc, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vuc = vec_sld(vuc, vuc, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vs = vec_sld(vs, vs, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vus = vec_sld(vus, vus, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vp = vec_sld(vp, vp, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vi = vec_sld(vi, vi, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vui = vec_sld(vui, vui, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vf = vec_sld(vf, vf, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vsc = vec_vsldoi(vsc, vsc, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vuc = vec_vsldoi(vuc, vuc, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vs = vec_vsldoi(vs, vs, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vus = vec_vsldoi(vus, vus, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vp = vec_vsldoi(vp, vp, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vi = vec_vsldoi(vi, vi, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vui = vec_vsldoi(vui, vui, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vf = vec_vsldoi(vf, vf, 0); // CHECK: @llvm.ppc.altivec.vperm
+
+ /* vec_sll */
+ res_vsc = vec_sll(vsc, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vsc = vec_sll(vsc, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vsc = vec_sll(vsc, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vuc = vec_sll(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vuc = vec_sll(vuc, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vuc = vec_sll(vuc, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbc = vec_sll(vbc, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbc = vec_sll(vbc, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbc = vec_sll(vbc, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vs = vec_sll(vs, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vs = vec_sll(vs, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vs = vec_sll(vs, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vus = vec_sll(vus, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vus = vec_sll(vus, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vus = vec_sll(vus, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbs = vec_sll(vbs, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbs = vec_sll(vbs, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbs = vec_sll(vbs, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vp = vec_sll(vp, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vp = vec_sll(vp, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vp = vec_sll(vp, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vi = vec_sll(vi, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vi = vec_sll(vi, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vi = vec_sll(vi, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vui = vec_sll(vui, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vui = vec_sll(vui, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vui = vec_sll(vui, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbi = vec_sll(vbi, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbi = vec_sll(vbi, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbi = vec_sll(vbi, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vsc = vec_vsl(vsc, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vsc = vec_vsl(vsc, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vsc = vec_vsl(vsc, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vuc = vec_vsl(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vuc = vec_vsl(vuc, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vuc = vec_vsl(vuc, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbc = vec_vsl(vbc, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbc = vec_vsl(vbc, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbc = vec_vsl(vbc, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vs = vec_vsl(vs, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vs = vec_vsl(vs, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vs = vec_vsl(vs, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vus = vec_vsl(vus, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vus = vec_vsl(vus, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vus = vec_vsl(vus, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbs = vec_vsl(vbs, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbs = vec_vsl(vbs, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbs = vec_vsl(vbs, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vp = vec_vsl(vp, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vp = vec_vsl(vp, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vp = vec_vsl(vp, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vi = vec_vsl(vi, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vi = vec_vsl(vi, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vi = vec_vsl(vi, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vui = vec_vsl(vui, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vui = vec_vsl(vui, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vui = vec_vsl(vui, vui); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbi = vec_vsl(vbi, vuc); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbi = vec_vsl(vbi, vus); // CHECK: @llvm.ppc.altivec.vsl
+ res_vbi = vec_vsl(vbi, vui); // CHECK: @llvm.ppc.altivec.vsl
+
+ /* vec_slo */
+ res_vsc = vec_slo(vsc, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vsc = vec_slo(vsc, vuc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vuc = vec_slo(vuc, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vuc = vec_slo(vuc, vuc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vs = vec_slo(vs, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vs = vec_slo(vs, vuc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vus = vec_slo(vus, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vus = vec_slo(vus, vuc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vp = vec_slo(vp, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vp = vec_slo(vp, vuc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vi = vec_slo(vi, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vi = vec_slo(vi, vuc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vui = vec_slo(vui, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vui = vec_slo(vui, vuc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vf = vec_slo(vf, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vf = vec_slo(vf, vuc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vsc = vec_vslo(vsc, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vsc = vec_vslo(vsc, vuc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vuc = vec_vslo(vuc, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vuc = vec_vslo(vuc, vuc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vs = vec_vslo(vs, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vs = vec_vslo(vs, vuc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vus = vec_vslo(vus, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vus = vec_vslo(vus, vuc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vp = vec_vslo(vp, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vp = vec_vslo(vp, vuc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vi = vec_vslo(vi, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vi = vec_vslo(vi, vuc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vui = vec_vslo(vui, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vui = vec_vslo(vui, vuc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vf = vec_vslo(vf, vsc); // CHECK: @llvm.ppc.altivec.vslo
+ res_vf = vec_vslo(vf, vuc); // CHECK: @llvm.ppc.altivec.vslo
+
+ /* vec_splat */
+ res_vsc = vec_splat(vsc, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vuc = vec_splat(vuc, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbc = vec_splat(vbc, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vs = vec_splat(vs, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vus = vec_splat(vus, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbs = vec_splat(vbs, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vp = vec_splat(vp, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vi = vec_splat(vi, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vui = vec_splat(vui, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbi = vec_splat(vbi, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vf = vec_splat(vf, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vsc = vec_vspltb(vsc, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vuc = vec_vspltb(vuc, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbc = vec_vspltb(vbc, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vs = vec_vsplth(vs, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vus = vec_vsplth(vus, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbs = vec_vsplth(vbs, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vp = vec_vsplth(vp, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vi = vec_vspltw(vi, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vui = vec_vspltw(vui, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vbi = vec_vspltw(vbi, 0); // CHECK: @llvm.ppc.altivec.vperm
+ res_vf = vec_vspltw(vf, 0); // CHECK: @llvm.ppc.altivec.vperm
+
+ /* vec_splat_s8 */
+ res_vsc = vec_splat_s8(0x09); // TODO: add check
+ res_vsc = vec_vspltisb(0x09); // TODO: add check
+
+ /* vec_splat_s16 */
+ res_vs = vec_splat_s16(0x09); // TODO: add check
+ res_vs = vec_vspltish(0x09); // TODO: add check
+
+ /* vec_splat_s32 */
+ res_vi = vec_splat_s32(0x09); // TODO: add check
+ res_vi = vec_vspltisw(0x09); // TODO: add check
+
+ /* vec_splat_u8 */
+ res_vuc = vec_splat_u8(0x09); // TODO: add check
+
+ /* vec_splat_u16 */
+ res_vus = vec_splat_u16(0x09); // TODO: add check
+
+ /* vec_splat_u32 */
+ res_vui = vec_splat_u32(0x09); // TODO: add check
+
+ /* vec_sr */
+ res_vsc = vec_sr(vsc, vuc); // CHECK: shr <16 x i8>
+ res_vuc = vec_sr(vuc, vuc); // CHECK: shr <16 x i8>
+ res_vs = vec_sr(vs, vus); // CHECK: shr <8 x i16>
+ res_vus = vec_sr(vus, vus); // CHECK: shr <8 x i16>
+ res_vi = vec_sr(vi, vui); // CHECK: shr <4 x i32>
+ res_vui = vec_sr(vui, vui); // CHECK: shr <4 x i32>
+ res_vsc = vec_vsrb(vsc, vuc); // CHECK: shr <16 x i8>
+ res_vuc = vec_vsrb(vuc, vuc); // CHECK: shr <16 x i8>
+ res_vs = vec_vsrh(vs, vus); // CHECK: shr <8 x i16>
+ res_vus = vec_vsrh(vus, vus); // CHECK: shr <8 x i16>
+ res_vi = vec_vsrw(vi, vui); // CHECK: shr <4 x i32>
+ res_vui = vec_vsrw(vui, vui); // CHECK: shr <4 x i32>
+
+ /* vec_sra */
+ res_vsc = vec_sra(vsc, vuc); // CHECK: @llvm.ppc.altivec.vsrab
+ res_vuc = vec_sra(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsrab
+ res_vs = vec_sra(vs, vus); // CHECK: @llvm.ppc.altivec.vsrah
+ res_vus = vec_sra(vus, vus); // CHECK: @llvm.ppc.altivec.vsrah
+ res_vi = vec_sra(vi, vui); // CHECK: @llvm.ppc.altivec.vsraw
+ res_vui = vec_sra(vui, vui); // CHECK: @llvm.ppc.altivec.vsraw
+ res_vsc = vec_vsrab(vsc, vuc); // CHECK: @llvm.ppc.altivec.vsrab
+ res_vuc = vec_vsrab(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsrab
+ res_vs = vec_vsrah(vs, vus); // CHECK: @llvm.ppc.altivec.vsrah
+ res_vus = vec_vsrah(vus, vus); // CHECK: @llvm.ppc.altivec.vsrah
+ res_vi = vec_vsraw(vi, vui); // CHECK: @llvm.ppc.altivec.vsraw
+ res_vui = vec_vsraw(vui, vui); // CHECK: @llvm.ppc.altivec.vsraw
+
+ /* vec_srl */
+ res_vsc = vec_srl(vsc, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vsc = vec_srl(vsc, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vsc = vec_srl(vsc, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vuc = vec_srl(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vuc = vec_srl(vuc, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vuc = vec_srl(vuc, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbc = vec_srl(vbc, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbc = vec_srl(vbc, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbc = vec_srl(vbc, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vs = vec_srl(vs, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vs = vec_srl(vs, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vs = vec_srl(vs, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vus = vec_srl(vus, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vus = vec_srl(vus, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vus = vec_srl(vus, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbs = vec_srl(vbs, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbs = vec_srl(vbs, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbs = vec_srl(vbs, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vp = vec_srl(vp, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vp = vec_srl(vp, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vp = vec_srl(vp, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vi = vec_srl(vi, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vi = vec_srl(vi, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vi = vec_srl(vi, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vui = vec_srl(vui, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vui = vec_srl(vui, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vui = vec_srl(vui, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbi = vec_srl(vbi, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbi = vec_srl(vbi, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbi = vec_srl(vbi, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vsc = vec_vsr(vsc, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vsc = vec_vsr(vsc, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vsc = vec_vsr(vsc, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vuc = vec_vsr(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vuc = vec_vsr(vuc, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vuc = vec_vsr(vuc, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbc = vec_vsr(vbc, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbc = vec_vsr(vbc, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbc = vec_vsr(vbc, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vs = vec_vsr(vs, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vs = vec_vsr(vs, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vs = vec_vsr(vs, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vus = vec_vsr(vus, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vus = vec_vsr(vus, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vus = vec_vsr(vus, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbs = vec_vsr(vbs, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbs = vec_vsr(vbs, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbs = vec_vsr(vbs, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vp = vec_vsr(vp, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vp = vec_vsr(vp, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vp = vec_vsr(vp, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vi = vec_vsr(vi, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vi = vec_vsr(vi, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vi = vec_vsr(vi, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vui = vec_vsr(vui, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vui = vec_vsr(vui, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vui = vec_vsr(vui, vui); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbi = vec_vsr(vbi, vuc); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbi = vec_vsr(vbi, vus); // CHECK: @llvm.ppc.altivec.vsr
+ res_vbi = vec_vsr(vbi, vui); // CHECK: @llvm.ppc.altivec.vsr
+
+ /* vec_sro */
+ res_vsc = vec_sro(vsc, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vsc = vec_sro(vsc, vuc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vuc = vec_sro(vuc, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vuc = vec_sro(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vs = vec_sro(vs, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vs = vec_sro(vs, vuc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vus = vec_sro(vus, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vus = vec_sro(vus, vuc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vp = vec_sro(vp, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vp = vec_sro(vp, vuc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vi = vec_sro(vi, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vi = vec_sro(vi, vuc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vui = vec_sro(vui, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vui = vec_sro(vui, vuc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vf = vec_sro(vf, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vf = vec_sro(vf, vuc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vsc = vec_vsro(vsc, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vsc = vec_vsro(vsc, vuc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vuc = vec_vsro(vuc, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vuc = vec_vsro(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vs = vec_vsro(vs, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vs = vec_vsro(vs, vuc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vus = vec_vsro(vus, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vus = vec_vsro(vus, vuc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vp = vec_vsro(vp, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vp = vec_vsro(vp, vuc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vi = vec_vsro(vi, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vi = vec_vsro(vi, vuc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vui = vec_vsro(vui, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vui = vec_vsro(vui, vuc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vf = vec_vsro(vf, vsc); // CHECK: @llvm.ppc.altivec.vsro
+ res_vf = vec_vsro(vf, vuc); // CHECK: @llvm.ppc.altivec.vsro
+
+ /* vec_st */
+ vec_st(vsc, 0, &vsc); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vsc, 0, &param_sc); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vuc, 0, &vuc); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vuc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vbc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vbc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vbc, 0, &vbc); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vs, 0, &vs); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vs, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vus, 0, &vus); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vus, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vbs, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vbs, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vbs, 0, &vbs); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vp, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vp, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vp, 0, &vp); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vi, 0, &vi); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vi, 0, &param_i); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vui, 0, &vui); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vui, 0, &param_ui); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vbi, 0, &param_i); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vbi, 0, &param_ui); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vbi, 0, &vbi); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vf, 0, &vf); // CHECK: @llvm.ppc.altivec.stvx
+ vec_st(vf, 0, &param_f); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vsc, 0, &vsc); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vsc, 0, &param_sc); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vuc, 0, &vuc); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vuc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vbc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vbc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vbc, 0, &vbc); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vs, 0, &vs); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vs, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vus, 0, &vus); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vus, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vbs, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vbs, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vbs, 0, &vbs); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vp, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vp, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vp, 0, &vp); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vi, 0, &vi); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vi, 0, &param_i); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vui, 0, &vui); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vui, 0, &param_ui); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vbi, 0, &param_i); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vbi, 0, &param_ui); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vbi, 0, &vbi); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vf, 0, &vf); // CHECK: @llvm.ppc.altivec.stvx
+ vec_stvx(vf, 0, &param_f); // CHECK: @llvm.ppc.altivec.stvx
+
+ /* vec_ste */
+ vec_ste(vsc, 0, &param_sc); // CHECK: @llvm.ppc.altivec.stvebx
+ vec_ste(vuc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.stvebx
+ vec_ste(vbc, 0, &param_sc); // CHECK: @llvm.ppc.altivec.stvebx
+ vec_ste(vbc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.stvebx
+ vec_ste(vs, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvehx
+ vec_ste(vus, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvehx
+ vec_ste(vbs, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvehx
+ vec_ste(vbs, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvehx
+ vec_ste(vp, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvehx
+ vec_ste(vp, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvehx
+ vec_ste(vi, 0, &param_i); // CHECK: @llvm.ppc.altivec.stvewx
+ vec_ste(vui, 0, &param_ui); // CHECK: @llvm.ppc.altivec.stvewx
+ vec_ste(vbi, 0, &param_i); // CHECK: @llvm.ppc.altivec.stvewx
+ vec_ste(vbi, 0, &param_ui); // CHECK: @llvm.ppc.altivec.stvewx
+ vec_ste(vf, 0, &param_f); // CHECK: @llvm.ppc.altivec.stvewx
+ vec_stvebx(vsc, 0, &param_sc); // CHECK: @llvm.ppc.altivec.stvebx
+ vec_stvebx(vuc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.stvebx
+ vec_stvebx(vbc, 0, &param_sc); // CHECK: @llvm.ppc.altivec.stvebx
+ vec_stvebx(vbc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.stvebx
+ vec_stvehx(vs, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvehx
+ vec_stvehx(vus, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvehx
+ vec_stvehx(vbs, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvehx
+ vec_stvehx(vbs, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvehx
+ vec_stvehx(vp, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvehx
+ vec_stvehx(vp, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvehx
+ vec_stvewx(vi, 0, &param_i); // CHECK: @llvm.ppc.altivec.stvewx
+ vec_stvewx(vui, 0, &param_ui); // CHECK: @llvm.ppc.altivec.stvewx
+ vec_stvewx(vbi, 0, &param_i); // CHECK: @llvm.ppc.altivec.stvewx
+ vec_stvewx(vbi, 0, &param_ui); // CHECK: @llvm.ppc.altivec.stvewx
+ vec_stvewx(vf, 0, &param_f); // CHECK: @llvm.ppc.altivec.stvewx
+
+ /* vec_stl */
+ vec_stl(vsc, 0, &vsc); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vsc, 0, &param_sc); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vuc, 0, &vuc); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vuc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vbc, 0, &param_sc); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vbc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vbc, 0, &vbc); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vs, 0, &vs); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vs, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vus, 0, &vus); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vus, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vbs, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vbs, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vbs, 0, &vbs); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vp, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vp, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vp, 0, &vp); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vi, 0, &vi); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vi, 0, &param_i); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vui, 0, &vui); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vui, 0, &param_ui); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vbi, 0, &param_i); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vbi, 0, &param_ui); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vbi, 0, &vbi); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vf, 0, &vf); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stl(vf, 0, &param_f); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vsc, 0, &vsc); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vsc, 0, &param_sc); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vuc, 0, &vuc); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vuc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vbc, 0, &param_sc); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vbc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vbc, 0, &vbc); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vs, 0, &vs); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vs, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vus, 0, &vus); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vus, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vbs, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vbs, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vbs, 0, &vbs); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vp, 0, &param_s); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vp, 0, &param_us); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vp, 0, &vp); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vi, 0, &vi); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vi, 0, &param_i); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vui, 0, &vui); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vui, 0, &param_ui); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vbi, 0, &param_i); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vbi, 0, &param_ui); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vbi, 0, &vbi); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vf, 0, &vf); // CHECK: @llvm.ppc.altivec.stvxl
+ vec_stvxl(vf, 0, &param_f); // CHECK: @llvm.ppc.altivec.stvxl
+
+ /* vec_sub */
+ res_vsc = vec_sub(vsc, vsc); // CHECK: sub <16 x i8>
+ res_vsc = vec_sub(vbc, vsc); // CHECK: sub <16 x i8>
+ res_vsc = vec_sub(vsc, vbc); // CHECK: sub <16 x i8>
+ res_vuc = vec_sub(vuc, vuc); // CHECK: sub <16 x i8>
+ res_vuc = vec_sub(vbc, vuc); // CHECK: sub <16 x i8>
+ res_vuc = vec_sub(vuc, vbc); // CHECK: sub <16 x i8>
+ res_vs = vec_sub(vs, vs); // CHECK: sub <8 x i16>
+ res_vs = vec_sub(vbs, vs); // CHECK: sub <8 x i16>
+ res_vs = vec_sub(vs, vbs); // CHECK: sub <8 x i16>
+ res_vus = vec_sub(vus, vus); // CHECK: sub <8 x i16>
+ res_vus = vec_sub(vbs, vus); // CHECK: sub <8 x i16>
+ res_vus = vec_sub(vus, vbs); // CHECK: sub <8 x i16>
+ res_vi = vec_sub(vi, vi); // CHECK: sub <4 x i32>
+ res_vi = vec_sub(vbi, vi); // CHECK: sub <4 x i32>
+ res_vi = vec_sub(vi, vbi); // CHECK: sub <4 x i32>
+ res_vui = vec_sub(vui, vui); // CHECK: sub <4 x i32>
+ res_vui = vec_sub(vbi, vui); // CHECK: sub <4 x i32>
+ res_vui = vec_sub(vui, vbi); // CHECK: sub <4 x i32>
+ res_vf = vec_sub(vf, vf); // CHECK: fsub <4 x float>
+ res_vsc = vec_vsububm(vsc, vsc); // CHECK: sub <16 x i8>
+ res_vsc = vec_vsububm(vbc, vsc); // CHECK: sub <16 x i8>
+ res_vsc = vec_vsububm(vsc, vbc); // CHECK: sub <16 x i8>
+ res_vuc = vec_vsububm(vuc, vuc); // CHECK: sub <16 x i8>
+ res_vuc = vec_vsububm(vbc, vuc); // CHECK: sub <16 x i8>
+ res_vuc = vec_vsububm(vuc, vbc); // CHECK: sub <16 x i8>
+ res_vs = vec_vsubuhm(vs, vs); // CHECK: sub <8 x i16>
+ res_vs = vec_vsubuhm(vbs, vus); // CHECK: sub <8 x i16>
+ res_vs = vec_vsubuhm(vus, vbs); // CHECK: sub <8 x i16>
+ res_vus = vec_vsubuhm(vus, vus); // CHECK: sub <8 x i16>
+ res_vus = vec_vsubuhm(vbs, vus); // CHECK: sub <8 x i16>
+ res_vus = vec_vsubuhm(vus, vbs); // CHECK: sub <8 x i16>
+ res_vi = vec_vsubuwm(vi, vi); // CHECK: sub <4 x i32>
+ res_vi = vec_vsubuwm(vbi, vi); // CHECK: sub <4 x i32>
+ res_vi = vec_vsubuwm(vi, vbi); // CHECK: sub <4 x i32>
+ res_vui = vec_vsubuwm(vui, vui); // CHECK: sub <4 x i32>
+ res_vui = vec_vsubuwm(vbi, vui); // CHECK: sub <4 x i32>
+ res_vui = vec_vsubuwm(vui, vbi); // CHECK: sub <4 x i32>
+ res_vf = vec_vsubfp(vf, vf); // CHECK: fsub <4 x float>
+
+ /* vec_subc */
+ res_vui = vec_subc(vui, vui); // CHECK: @llvm.ppc.altivec.vsubcuw
+ res_vui = vec_vsubcuw(vui, vui); // CHECK: @llvm.ppc.altivec.vsubcuw
+
+ /* vec_subs */
+ res_vsc = vec_subs(vsc, vsc); // CHECK: @llvm.ppc.altivec.vsubsbs
+ res_vsc = vec_subs(vbc, vsc); // CHECK: @llvm.ppc.altivec.vsubsbs
+ res_vsc = vec_subs(vsc, vbc); // CHECK: @llvm.ppc.altivec.vsubsbs
+ res_vuc = vec_subs(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsububs
+ res_vuc = vec_subs(vbc, vuc); // CHECK: @llvm.ppc.altivec.vsububs
+ res_vuc = vec_subs(vuc, vbc); // CHECK: @llvm.ppc.altivec.vsububs
+ res_vs = vec_subs(vs, vs); // CHECK: @llvm.ppc.altivec.vsubshs
+ res_vs = vec_subs(vbs, vs); // CHECK: @llvm.ppc.altivec.vsubshs
+ res_vs = vec_subs(vs, vbs); // CHECK: @llvm.ppc.altivec.vsubshs
+ res_vus = vec_subs(vus, vus); // CHECK: @llvm.ppc.altivec.vsubuhs
+ res_vus = vec_subs(vbs, vus); // CHECK: @llvm.ppc.altivec.vsubuhs
+ res_vus = vec_subs(vus, vbs); // CHECK: @llvm.ppc.altivec.vsubuhs
+ res_vi = vec_subs(vi, vi); // CHECK: @llvm.ppc.altivec.vsubsws
+ res_vi = vec_subs(vbi, vi); // CHECK: @llvm.ppc.altivec.vsubsws
+ res_vi = vec_subs(vi, vbi); // CHECK: @llvm.ppc.altivec.vsubsws
+ res_vui = vec_subs(vui, vui); // CHECK: @llvm.ppc.altivec.vsubuws
+ res_vui = vec_subs(vbi, vui); // CHECK: @llvm.ppc.altivec.vsubuws
+ res_vui = vec_subs(vui, vbi); // CHECK: @llvm.ppc.altivec.vsubuws
+ res_vsc = vec_vsubsbs(vsc, vsc); // CHECK: @llvm.ppc.altivec.vsubsbs
+ res_vsc = vec_vsubsbs(vbc, vsc); // CHECK: @llvm.ppc.altivec.vsubsbs
+ res_vsc = vec_vsubsbs(vsc, vbc); // CHECK: @llvm.ppc.altivec.vsubsbs
+ res_vuc = vec_vsububs(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsububs
+ res_vuc = vec_vsububs(vbc, vuc); // CHECK: @llvm.ppc.altivec.vsububs
+ res_vuc = vec_vsububs(vuc, vbc); // CHECK: @llvm.ppc.altivec.vsububs
+ res_vs = vec_vsubshs(vs, vs); // CHECK: @llvm.ppc.altivec.vsubshs
+ res_vs = vec_vsubshs(vbs, vs); // CHECK: @llvm.ppc.altivec.vsubshs
+ res_vs = vec_vsubshs(vs, vbs); // CHECK: @llvm.ppc.altivec.vsubshs
+ res_vus = vec_vsubuhs(vus, vus); // CHECK: @llvm.ppc.altivec.vsubuhs
+ res_vus = vec_vsubuhs(vbs, vus); // CHECK: @llvm.ppc.altivec.vsubuhs
+ res_vus = vec_vsubuhs(vus, vbs); // CHECK: @llvm.ppc.altivec.vsubuhs
+ res_vi = vec_vsubsws(vi, vi); // CHECK: @llvm.ppc.altivec.vsubsws
+ res_vi = vec_vsubsws(vbi, vi); // CHECK: @llvm.ppc.altivec.vsubsws
+ res_vi = vec_vsubsws(vi, vbi); // CHECK: @llvm.ppc.altivec.vsubsws
+ res_vui = vec_vsubuws(vui, vui); // CHECK: @llvm.ppc.altivec.vsubuws
+ res_vui = vec_vsubuws(vbi, vui); // CHECK: @llvm.ppc.altivec.vsubuws
+ res_vui = vec_vsubuws(vui, vbi); // CHECK: @llvm.ppc.altivec.vsubuws
+
+ /* vec_sum4s */
+ res_vi = vec_sum4s(vsc, vi); // CHECK: @llvm.ppc.altivec.vsum4sbs
+ res_vui = vec_sum4s(vuc, vui); // CHECK: @llvm.ppc.altivec.vsum4ubs
+ res_vi = vec_sum4s(vs, vi); // CHECK: @llvm.ppc.altivec.vsum4shs
+ res_vi = vec_vsum4sbs(vsc, vi); // CHECK: @llvm.ppc.altivec.vsum4sbs
+ res_vui = vec_vsum4ubs(vuc, vui); // CHECK: @llvm.ppc.altivec.vsum4ubs
+ res_vi = vec_vsum4shs(vs, vi); // CHECK: @llvm.ppc.altivec.vsum4shs
+
+ /* vec_sum2s */
+ res_vi = vec_sum2s(vi, vi); // CHECK: @llvm.ppc.altivec.vsum2sws
+ res_vi = vec_vsum2sws(vi, vi); // CHECK: @llvm.ppc.altivec.vsum2sws
+
+ /* vec_sums */
+ res_vi = vec_sums(vi, vi); // CHECK: @llvm.ppc.altivec.vsumsws
+ res_vi = vec_vsumsws(vi, vi); // CHECK: @llvm.ppc.altivec.vsumsws
+
+ /* vec_trunc */
+ res_vf = vec_trunc(vf); // CHECK: @llvm.ppc.altivec.vrfiz
+ res_vf = vec_vrfiz(vf); // CHECK: @llvm.ppc.altivec.vrfiz
+
+ /* vec_unpackh */
+ res_vs = vec_unpackh(vsc); // CHECK: @llvm.ppc.altivec.vupkhsb
+ res_vbs = vec_unpackh(vbc); // CHECK: @llvm.ppc.altivec.vupkhsb
+ res_vi = vec_unpackh(vs); // CHECK: @llvm.ppc.altivec.vupkhsh
+ res_vbi = vec_unpackh(vbs); // CHECK: @llvm.ppc.altivec.vupkhsh
+ res_vui = vec_unpackh(vp); // CHECK: @llvm.ppc.altivec.vupkhsh
+ res_vs = vec_vupkhsb(vsc); // CHECK: @llvm.ppc.altivec.vupkhsb
+ res_vbs = vec_vupkhsb(vbc); // CHECK: @llvm.ppc.altivec.vupkhsb
+ res_vi = vec_vupkhsh(vs); // CHECK: @llvm.ppc.altivec.vupkhsh
+ res_vbi = vec_vupkhsh(vbs); // CHECK: @llvm.ppc.altivec.vupkhsh
+ res_vui = vec_vupkhsh(vp); // CHECK: @llvm.ppc.altivec.vupkhsh
+
+ /* vec_unpackl */
+ res_vs = vec_unpackl(vsc); // CHECK: @llvm.ppc.altivec.vupklsb
+ res_vbs = vec_unpackl(vbc); // CHECK: @llvm.ppc.altivec.vupklsb
+ res_vi = vec_unpackl(vs); // CHECK: @llvm.ppc.altivec.vupklsh
+ res_vbi = vec_unpackl(vbs); // CHECK: @llvm.ppc.altivec.vupklsh
+ res_vui = vec_unpackl(vp); // CHECK: @llvm.ppc.altivec.vupklsh
+ res_vs = vec_vupklsb(vsc); // CHECK: @llvm.ppc.altivec.vupklsb
+ res_vbs = vec_vupklsb(vbc); // CHECK: @llvm.ppc.altivec.vupklsb
+ res_vi = vec_vupklsh(vs); // CHECK: @llvm.ppc.altivec.vupklsh
+ res_vbi = vec_vupklsh(vbs); // CHECK: @llvm.ppc.altivec.vupklsh
+ res_vui = vec_vupklsh(vp); // CHECK: @llvm.ppc.altivec.vupklsh
+
+ /* vec_xor */
+ res_vsc = vec_xor(vsc, vsc); // CHECK: xor <16 x i8>
+ res_vsc = vec_xor(vbc, vsc); // CHECK: xor <16 x i8>
+ res_vsc = vec_xor(vsc, vbc); // CHECK: xor <16 x i8>
+ res_vuc = vec_xor(vuc, vuc); // CHECK: xor <16 x i8>
+ res_vuc = vec_xor(vbc, vuc); // CHECK: xor <16 x i8>
+ res_vuc = vec_xor(vuc, vbc); // CHECK: xor <16 x i8>
+ res_vbc = vec_xor(vbc, vbc); // CHECK: xor <16 x i8>
+ res_vs = vec_xor(vs, vs); // CHECK: xor <8 x i16>
+ res_vs = vec_xor(vbs, vs); // CHECK: xor <8 x i16>
+ res_vs = vec_xor(vs, vbs); // CHECK: xor <8 x i16>
+ res_vus = vec_xor(vus, vus); // CHECK: xor <8 x i16>
+ res_vus = vec_xor(vbs, vus); // CHECK: xor <8 x i16>
+ res_vus = vec_xor(vus, vbs); // CHECK: xor <8 x i16>
+ res_vbs = vec_xor(vbs, vbs); // CHECK: xor <8 x i16>
+ res_vi = vec_xor(vi, vi); // CHECK: xor <4 x i32>
+ res_vi = vec_xor(vbi, vi); // CHECK: xor <4 x i32>
+ res_vi = vec_xor(vi, vbi); // CHECK: xor <4 x i32>
+ res_vui = vec_xor(vui, vui); // CHECK: xor <4 x i32>
+ res_vui = vec_xor(vbi, vui); // CHECK: xor <4 x i32>
+ res_vui = vec_xor(vui, vbi); // CHECK: xor <4 x i32>
+ res_vbi = vec_xor(vbi, vbi); // CHECK: xor <4 x i32>
+ res_vf = vec_xor(vf, vf); // CHECK: xor <4 x i32>
+ res_vf = vec_xor(vbi, vf); // CHECK: xor <4 x i32>
+ res_vf = vec_xor(vf, vbi); // CHECK: xor <4 x i32>
+ res_vsc = vec_vxor(vsc, vsc); // CHECK: xor <16 x i8>
+ res_vsc = vec_vxor(vbc, vsc); // CHECK: xor <16 x i8>
+ res_vsc = vec_vxor(vsc, vbc); // CHECK: xor <16 x i8>
+ res_vuc = vec_vxor(vuc, vuc); // CHECK: xor <16 x i8>
+ res_vuc = vec_vxor(vbc, vuc); // CHECK: xor <16 x i8>
+ res_vuc = vec_vxor(vuc, vbc); // CHECK: xor <16 x i8>
+ res_vbc = vec_vxor(vbc, vbc); // CHECK: xor <16 x i8>
+ res_vs = vec_vxor(vs, vs); // CHECK: xor <8 x i16>
+ res_vs = vec_vxor(vbs, vs); // CHECK: xor <8 x i16>
+ res_vs = vec_vxor(vs, vbs); // CHECK: xor <8 x i16>
+ res_vus = vec_vxor(vus, vus); // CHECK: xor <8 x i16>
+ res_vus = vec_vxor(vbs, vus); // CHECK: xor <8 x i16>
+ res_vus = vec_vxor(vus, vbs); // CHECK: xor <8 x i16>
+ res_vbs = vec_vxor(vbs, vbs); // CHECK: xor <8 x i16>
+ res_vi = vec_vxor(vi, vi); // CHECK: xor <4 x i32>
+ res_vi = vec_vxor(vbi, vi); // CHECK: xor <4 x i32>
+ res_vi = vec_vxor(vi, vbi); // CHECK: xor <4 x i32>
+ res_vui = vec_vxor(vui, vui); // CHECK: xor <4 x i32>
+ res_vui = vec_vxor(vbi, vui); // CHECK: xor <4 x i32>
+ res_vui = vec_vxor(vui, vbi); // CHECK: xor <4 x i32>
+ res_vbi = vec_vxor(vbi, vbi); // CHECK: xor <4 x i32>
+ res_vf = vec_vxor(vf, vf); // CHECK: xor <4 x i32>
+ res_vf = vec_vxor(vbi, vf); // CHECK: xor <4 x i32>
+ res_vf = vec_vxor(vf, vbi); // CHECK: xor <4 x i32>
+
+ /* ------------------------------ extensions -------------------------------------- */
+
+ /* vec_extract */
+ res_sc = vec_extract(vsc, param_i); // CHECK: extractelement <16 x i8>
+ res_uc = vec_extract(vuc, param_i); // CHECK: extractelement <16 x i8>
+ res_s = vec_extract(vs, param_i); // CHECK: extractelement <8 x i16>
+ res_us = vec_extract(vus, param_i); // CHECK: extractelement <8 x i16>
+ res_i = vec_extract(vi, param_i); // CHECK: extractelement <4 x i32>
+ res_ui = vec_extract(vui, param_i); // CHECK: extractelement <4 x i32>
+ res_f = vec_extract(vf, param_i); // CHECK: extractelement <4 x float>
+
+ /* vec_insert */
+ res_vsc = vec_insert(param_sc, vsc, param_i); // CHECK: insertelement <16 x i8>
+ res_vuc = vec_insert(param_uc, vuc, param_i); // CHECK: insertelement <16 x i8>
+ res_vs = vec_insert(param_s, vs, param_i); // CHECK: insertelement <8 x i16>
+ res_vus = vec_insert(param_us, vus, param_i); // CHECK: insertelement <8 x i16>
+ res_vi = vec_insert(param_i, vi, param_i); // CHECK: insertelement <4 x i32>
+ res_vui = vec_insert(param_ui, vui, param_i); // CHECK: insertelement <4 x i32>
+ res_vf = vec_insert(param_f, vf, param_i); // CHECK: insertelement <4 x float>
+
+ /* vec_lvlx */
+ res_vsc = vec_lvlx(0, &param_sc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vsc = vec_lvlx(0, &vsc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vuc = vec_lvlx(0, &param_uc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vuc = vec_lvlx(0, &vuc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vbc = vec_lvlx(0, &vbc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vs = vec_lvlx(0, &param_s); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vs = vec_lvlx(0, &vs); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vus = vec_lvlx(0, &param_us); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vus = vec_lvlx(0, &vus); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vbs = vec_lvlx(0, &vbs); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vp = vec_lvlx(0, &vp); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vi = vec_lvlx(0, &param_i); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vi = vec_lvlx(0, &vi); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vui = vec_lvlx(0, &param_ui); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vui = vec_lvlx(0, &vui); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vbi = vec_lvlx(0, &vbi); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vf = vec_lvlx(0, &vf); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x float> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ /* vec_lvlxl */
+ res_vsc = vec_lvlxl(0, &param_sc); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vsc = vec_lvlxl(0, &vsc); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vuc = vec_lvlxl(0, &param_uc); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vuc = vec_lvlxl(0, &vuc); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vbc = vec_lvlxl(0, &vbc); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vs = vec_lvlxl(0, &param_s); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vs = vec_lvlxl(0, &vs); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vus = vec_lvlxl(0, &param_us); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vus = vec_lvlxl(0, &vus); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vbs = vec_lvlxl(0, &vbs); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vp = vec_lvlxl(0, &vp); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vi = vec_lvlxl(0, &param_i); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vi = vec_lvlxl(0, &vi); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vui = vec_lvlxl(0, &param_ui); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vui = vec_lvlxl(0, &vui); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vbi = vec_lvlxl(0, &vbi); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vf = vec_lvlxl(0, &vf); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x float> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ /* vec_lvrx */
+ res_vsc = vec_lvrx(0, &param_sc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vsc = vec_lvrx(0, &vsc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vuc = vec_lvrx(0, &param_uc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vuc = vec_lvrx(0, &vuc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vbc = vec_lvrx(0, &vbc); // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vs = vec_lvrx(0, &param_s); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vs = vec_lvrx(0, &vs); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vus = vec_lvrx(0, &param_us); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vus = vec_lvrx(0, &vus); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vbs = vec_lvrx(0, &vbs); // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vp = vec_lvrx(0, &vp); // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vi = vec_lvrx(0, &param_i); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vi = vec_lvrx(0, &vi); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vui = vec_lvrx(0, &param_ui); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vui = vec_lvrx(0, &vui); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vbi = vec_lvrx(0, &vbi); // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vf = vec_lvrx(0, &vf); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x float> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ /* vec_lvrxl */
+ res_vsc = vec_lvrxl(0, &param_sc); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vsc = vec_lvrxl(0, &vsc); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vuc = vec_lvrxl(0, &param_uc); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vuc = vec_lvrxl(0, &vuc); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vbc = vec_lvrxl(0, &vbc); // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vs = vec_lvrxl(0, &param_s); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vs = vec_lvrxl(0, &vs); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vus = vec_lvrxl(0, &param_us); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vus = vec_lvrxl(0, &vus); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vbs = vec_lvrxl(0, &vbs); // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vp = vec_lvrxl(0, &vp); // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vi = vec_lvrxl(0, &param_i); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vi = vec_lvrxl(0, &vi); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vui = vec_lvrxl(0, &param_ui); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vui = vec_lvrxl(0, &vui); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vbi = vec_lvrxl(0, &vbi); // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ res_vf = vec_lvrxl(0, &vf); // CHECK: @llvm.ppc.altivec.lvxl
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x float> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+
+ /* vec_stvlx */
+ vec_stvlx(vsc, 0, &param_sc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vsc, 0, &vsc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vuc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vuc, 0, &vuc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vbc, 0, &vbc); // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vs, 0, &param_s); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vs, 0, &vs); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vus, 0, &param_us); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vus, 0, &vus); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vbs, 0, &vbs); // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vp, 0, &vp); // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vi, 0, &param_i); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vi, 0, &vi); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vui, 0, &param_ui); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vui, 0, &vui); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vbi, 0, &vbi); // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvlx(vf, 0, &vf); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x float> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ /* vec_stvlxl */
+ vec_stvlxl(vsc, 0, &param_sc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vsc, 0, &vsc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vuc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vuc, 0, &vuc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vbc, 0, &vbc); // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vs, 0, &param_s); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vs, 0, &vs); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vus, 0, &param_us); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vus, 0, &vus); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vbs, 0, &vbs); // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vp, 0, &vp); // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vi, 0, &param_i); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vi, 0, &vi); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vui, 0, &param_ui); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vui, 0, &vui); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vbi, 0, &vbi); // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvlxl(vf, 0, &vf); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x float> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ /* vec_stvrx */
+ vec_stvrx(vsc, 0, &param_sc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vsc, 0, &vsc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vuc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vuc, 0, &vuc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vbc, 0, &vbc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vs, 0, &param_s); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vs, 0, &vs); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vus, 0, &param_us); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vus, 0, &vus); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vbs, 0, &vbs); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vp, 0, &vp); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vi, 0, &param_i); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vi, 0, &vi); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vui, 0, &param_ui); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vui, 0, &vui); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vbi, 0, &vbi); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ vec_stvrx(vf, 0, &vf); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x float> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvx
+
+ /* vec_stvrxl */
+ vec_stvrxl(vsc, 0, &param_sc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vsc, 0, &vsc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vuc, 0, &param_uc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vuc, 0, &vuc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vbc, 0, &vbc); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vs, 0, &param_s); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vs, 0, &vs); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vus, 0, &param_us); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vus, 0, &vus); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vbs, 0, &vbs); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vp, 0, &vp); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vi, 0, &param_i); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vi, 0, &vi); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vui, 0, &param_ui); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vui, 0, &vui); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vbi, 0, &vbi); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ vec_stvrxl(vf, 0, &vf); // CHECK: @llvm.ppc.altivec.lvx
+ // CHECK: @llvm.ppc.altivec.lvsl
+ // CHECK: store <4 x float> zeroinitializer
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.lvsr
+ // CHECK: @llvm.ppc.altivec.vperm
+ // CHECK: @llvm.ppc.altivec.stvxl
+
+ /* vec_promote */
+ res_vsc = vec_promote(param_sc, 0); // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: insertelement <16 x i8>
+
+ res_vuc = vec_promote(param_uc, 0); // CHECK: store <16 x i8> zeroinitializer
+ // CHECK: insertelement <16 x i8>
+
+ res_vs = vec_promote(param_s, 0); // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: insertelement <8 x i16>
+
+ res_vus = vec_promote(param_us, 0); // CHECK: store <8 x i16> zeroinitializer
+ // CHECK: insertelement <8 x i16>
+
+ res_vi = vec_promote(param_i, 0); // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: insertelement <4 x i32>
+
+ res_vui = vec_promote(param_ui, 0); // CHECK: store <4 x i32> zeroinitializer
+ // CHECK: insertelement <4 x i32>
+
+ res_vf = vec_promote(param_f, 0); // CHECK: store <4 x float> zeroinitializer
+ // CHECK: insertelement <4 x float>
+
+ /* vec_splats */
+ res_vsc = vec_splats(param_sc); // CHECK: insertelement <16 x i8>
+
+ res_vuc = vec_splats(param_uc); // CHECK: insertelement <16 x i8>
+
+ res_vs = vec_splats(param_s); // CHECK: insertelement <8 x i16>
+
+ res_vus = vec_splats(param_us); // CHECK: insertelement <8 x i16>
+
+ res_vi = vec_splats(param_i); // CHECK: insertelement <4 x i32>
+
+ res_vui = vec_splats(param_ui); // CHECK: insertelement <4 x i32>
+
+ res_vf = vec_splats(param_f); // CHECK: insertelement <4 x float>
+
+ /* ------------------------------ predicates -------------------------------------- */
+
+ /* vec_all_eq */
+ res_i = vec_all_eq(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_all_eq(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_all_eq(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_all_eq(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_all_eq(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_all_eq(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_all_eq(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_all_eq(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_eq(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_eq(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_eq(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_eq(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_eq(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_eq(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_eq(vp, vp); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_eq(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_all_eq(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_all_eq(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_all_eq(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_all_eq(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_all_eq(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_all_eq(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_all_eq(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p
+
+ /* vec_all_ge */
+ res_i = vec_all_ge(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_all_ge(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_all_ge(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_ge(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_ge(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_ge(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_ge(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_ge(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_all_ge(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_all_ge(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_ge(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_ge(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_ge(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_ge(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_ge(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_all_ge(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_all_ge(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_ge(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_ge(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_ge(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_ge(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_ge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p
+
+ /* vec_all_gt */
+ res_i = vec_all_gt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_all_gt(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_all_gt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_gt(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_gt(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_gt(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_gt(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_gt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_all_gt(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_all_gt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_gt(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_gt(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_gt(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_gt(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_gt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_all_gt(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_all_gt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_gt(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_gt(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_gt(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_gt(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_gt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p
+
+ /* vec_all_in */
+ res_i = vec_all_in(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpbfp.p
+
+ /* vec_all_le */
+ res_i = vec_all_le(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_all_le(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_all_le(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_le(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_le(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_le(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_le(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_le(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_all_le(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_all_le(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_le(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_le(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_le(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_le(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_le(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_all_le(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_all_le(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_le(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_le(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_le(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_le(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_le(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p
+
+ /* vec_all_lt */
+ res_i = vec_all_lt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_all_lt(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_all_lt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_lt(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_lt(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_lt(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_lt(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_all_lt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_all_lt(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_all_lt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_lt(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_lt(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_lt(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_lt(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_all_lt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_all_lt(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_all_lt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_lt(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_lt(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_lt(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_lt(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_all_lt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p
+
+ /* vec_all_nan */
+ res_i = vec_all_nan(vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p
+
+ /* vec_all_ne */
+ res_i = vec_all_ne(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_all_ne(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_all_ne(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_all_ne(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_all_ne(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_all_ne(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_all_ne(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_all_ne(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_ne(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_ne(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_ne(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_ne(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_ne(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_ne(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_ne(vp, vp); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_all_ne(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_all_ne(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_all_ne(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_all_ne(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_all_ne(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_all_ne(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_all_ne(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_all_ne(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p
+
+ /* vec_all_nge */
+ res_i = vec_all_nge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p
+
+ /* vec_all_ngt */
+ res_i = vec_all_ngt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p
+
+ /* vec_all_nle */
+ res_i = vec_all_nle(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p
+
+ /* vec_all_nlt */
+ res_i = vec_all_nlt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p
+
+ /* vec_all_numeric */
+ res_i = vec_all_numeric(vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p
+
+ /* vec_any_eq */
+ res_i = vec_any_eq(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_any_eq(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_any_eq(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_any_eq(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_any_eq(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_any_eq(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_any_eq(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_any_eq(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_eq(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_eq(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_eq(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_eq(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_eq(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_eq(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_eq(vp, vp); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_eq(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_any_eq(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_any_eq(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_any_eq(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_any_eq(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_any_eq(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_any_eq(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_any_eq(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p
+
+ /* vec_any_ge */
+ res_i = vec_any_ge(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_any_ge(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_any_ge(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_ge(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_ge(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_ge(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_ge(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_ge(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_any_ge(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_any_ge(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_ge(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_ge(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_ge(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_ge(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_ge(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_any_ge(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_any_ge(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_ge(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_ge(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_ge(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_ge(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_ge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p
+
+ /* vec_any_gt */
+ res_i = vec_any_gt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_any_gt(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_any_gt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_gt(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_gt(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_gt(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_gt(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_gt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_any_gt(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_any_gt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_gt(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_gt(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_gt(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_gt(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_gt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_any_gt(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_any_gt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_gt(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_gt(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_gt(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_gt(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_gt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p
+
+ /* vec_any_le */
+ res_i = vec_any_le(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_any_le(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_any_le(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_le(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_le(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_le(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_le(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_le(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_any_le(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_any_le(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_le(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_le(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_le(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_le(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_le(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_any_le(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_any_le(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_le(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_le(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_le(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_le(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_le(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p
+
+ /* vec_any_lt */
+ res_i = vec_any_lt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_any_lt(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p
+ res_i = vec_any_lt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_lt(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_lt(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_lt(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_lt(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p
+ res_i = vec_any_lt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_any_lt(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p
+ res_i = vec_any_lt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_lt(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_lt(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_lt(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_lt(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p
+ res_i = vec_any_lt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_any_lt(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p
+ res_i = vec_any_lt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_lt(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_lt(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_lt(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_lt(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p
+ res_i = vec_any_lt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p
+
+ /* vec_any_nan */
+ res_i = vec_any_nan(vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p
+
+ /* vec_any_ne */
+ res_i = vec_any_ne(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_any_ne(vsc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_any_ne(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_any_ne(vuc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_any_ne(vbc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_any_ne(vbc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_any_ne(vbc, vbc); // CHECK: @llvm.ppc.altivec.vcmpequb.p
+ res_i = vec_any_ne(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_ne(vs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_ne(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_ne(vus, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_ne(vbs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_ne(vbs, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_ne(vbs, vbs); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_ne(vp, vp); // CHECK: @llvm.ppc.altivec.vcmpequh.p
+ res_i = vec_any_ne(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_any_ne(vi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_any_ne(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_any_ne(vui, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_any_ne(vbi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_any_ne(vbi, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_any_ne(vbi, vbi); // CHECK: @llvm.ppc.altivec.vcmpequw.p
+ res_i = vec_any_ne(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p
+
+ /* vec_any_nge */
+ res_i = vec_any_nge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p
+
+ /* vec_any_ngt */
+ res_i = vec_any_ngt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p
+
+ /* vec_any_nle */
+ res_i = vec_any_nle(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p
+
+ /* vec_any_nlt */
+ res_i = vec_any_nlt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p
+
+ /* vec_any_numeric */
+ res_i = vec_any_numeric(vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p
+
+ /* vec_any_out */
+ res_i = vec_any_out(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpbfp.p
+}
+
+/* ------------------------------ Relational Operators ------------------------------ */
+// CHECK: define void @test7
+void test7() {
+ vector signed char vsc1 = (vector signed char)(-1);
+ vector signed char vsc2 = (vector signed char)(-2);
+ res_i = (vsc1 == vsc2); // CHECK: @llvm.ppc.altivec.vcmpequb.p(i32 2
+ res_i = (vsc1 != vsc2); // CHECK: @llvm.ppc.altivec.vcmpequb.p(i32 0
+ res_i = (vsc1 < vsc2); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p(i32 2
+ res_i = (vsc1 > vsc2); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p(i32 2
+ res_i = (vsc1 <= vsc2); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p(i32 0
+ res_i = (vsc1 >= vsc2); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p(i32 0
+ vector unsigned char vuc1 = (vector unsigned char)(1);
+ vector unsigned char vuc2 = (vector unsigned char)(2);
+ res_i = (vuc1 == vuc2); // CHECK: @llvm.ppc.altivec.vcmpequb.p(i32 2
+ res_i = (vuc1 != vuc2); // CHECK: @llvm.ppc.altivec.vcmpequb.p(i32 0
+ res_i = (vuc1 < vuc2); // CHECK: @llvm.ppc.altivec.vcmpgtub.p(i32 2
+ res_i = (vuc1 > vuc2); // CHECK: @llvm.ppc.altivec.vcmpgtub.p(i32 2
+ res_i = (vuc1 <= vuc2); // CHECK: @llvm.ppc.altivec.vcmpgtub.p(i32 0
+ res_i = (vuc1 >= vuc2); // CHECK: @llvm.ppc.altivec.vcmpgtub.p(i32 0
+ vector short vs1 = (vector short)(-1);
+ vector short vs2 = (vector short)(-2);
+ res_i = (vs1 == vs2); // CHECK: @llvm.ppc.altivec.vcmpequh.p(i32 2
+ res_i = (vs1 != vs2); // CHECK: @llvm.ppc.altivec.vcmpequh.p(i32 0
+ res_i = (vs1 < vs2); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p(i32 2
+ res_i = (vs1 > vs2); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p(i32 2
+ res_i = (vs1 <= vs2); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p(i32 0
+ res_i = (vs1 >= vs2); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p(i32 0
+ vector unsigned short vus1 = (vector unsigned short)(1);
+ vector unsigned short vus2 = (vector unsigned short)(2);
+ res_i = (vus1 == vus2); // CHECK: @llvm.ppc.altivec.vcmpequh.p(i32 2
+ res_i = (vus1 != vus2); // CHECK: @llvm.ppc.altivec.vcmpequh.p(i32 0
+ res_i = (vus1 < vus2); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p(i32 2
+ res_i = (vus1 > vus2); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p(i32 2
+ res_i = (vus1 <= vus2); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p(i32 0
+ res_i = (vus1 >= vus2); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p(i32 0
+ vector int vi1 = (vector int)(-1);
+ vector int vi2 = (vector int)(-2);
+ res_i = (vi1 == vi2); // CHECK: @llvm.ppc.altivec.vcmpequw.p(i32 2
+ res_i = (vi1 != vi2); // CHECK: @llvm.ppc.altivec.vcmpequw.p(i32 0
+ res_i = (vi1 < vi2); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p(i32 2
+ res_i = (vi1 > vi2); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p(i32 2
+ res_i = (vi1 <= vi2); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p(i32 0
+ res_i = (vi1 >= vi2); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p(i32 0
+ vector unsigned int vui1 = (vector unsigned int)(1);
+ vector unsigned int vui2 = (vector unsigned int)(2);
+ res_i = (vui1 == vui2); // CHECK: @llvm.ppc.altivec.vcmpequw.p(i32 2
+ res_i = (vui1 != vui2); // CHECK: @llvm.ppc.altivec.vcmpequw.p(i32 0
+ res_i = (vui1 < vui2); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p(i32 2
+ res_i = (vui1 > vui2); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p(i32 2
+ res_i = (vui1 <= vui2); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p(i32 0
+ res_i = (vui1 >= vui2); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p(i32 0
+ vector float vf1 = (vector float)(1.0);
+ vector float vf2 = (vector float)(2.0);
+ res_i = (vf1 == vf2); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p(i32 2
+ res_i = (vf1 != vf2); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p(i32 0
+ res_i = (vf1 < vf2); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p(i32 2
+ res_i = (vf1 > vf2); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p(i32 2
+ res_i = (vf1 <= vf2); // CHECK: @llvm.ppc.altivec.vcmpgefp.p(i32 2
+ res_i = (vf1 >= vf2); // CHECK: @llvm.ppc.altivec.vcmpgefp.p(i32 2
+}
diff --git a/clang/test/CodeGen/builtins-ptx.c b/clang/test/CodeGen/builtins-ptx.c
new file mode 100644
index 0000000..6dd1018
--- /dev/null
+++ b/clang/test/CodeGen/builtins-ptx.c
@@ -0,0 +1,99 @@
+// RUN: %clang_cc1 -triple ptx32-unknown-unknown -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple ptx64-unknown-unknown -emit-llvm -o %t %s
+
+
+int read_tid() {
+
+ int x = __builtin_ptx_read_tid_x();
+ int y = __builtin_ptx_read_tid_y();
+ int z = __builtin_ptx_read_tid_z();
+ int w = __builtin_ptx_read_tid_w();
+
+ return x + y + z + w;
+
+}
+
+int read_ntid() {
+
+ int x = __builtin_ptx_read_ntid_x();
+ int y = __builtin_ptx_read_ntid_y();
+ int z = __builtin_ptx_read_ntid_z();
+ int w = __builtin_ptx_read_ntid_w();
+
+ return x + y + z + w;
+
+}
+
+int read_ctaid() {
+
+ int x = __builtin_ptx_read_ctaid_x();
+ int y = __builtin_ptx_read_ctaid_y();
+ int z = __builtin_ptx_read_ctaid_z();
+ int w = __builtin_ptx_read_ctaid_w();
+
+ return x + y + z + w;
+
+}
+
+int read_nctaid() {
+
+ int x = __builtin_ptx_read_nctaid_x();
+ int y = __builtin_ptx_read_nctaid_y();
+ int z = __builtin_ptx_read_nctaid_z();
+ int w = __builtin_ptx_read_nctaid_w();
+
+ return x + y + z + w;
+
+}
+
+int read_ids() {
+
+ int a = __builtin_ptx_read_laneid();
+ int b = __builtin_ptx_read_warpid();
+ int c = __builtin_ptx_read_nwarpid();
+ int d = __builtin_ptx_read_smid();
+ int e = __builtin_ptx_read_nsmid();
+ int f = __builtin_ptx_read_gridid();
+
+ return a + b + c + d + e + f;
+
+}
+
+int read_lanemasks() {
+
+ int a = __builtin_ptx_read_lanemask_eq();
+ int b = __builtin_ptx_read_lanemask_le();
+ int c = __builtin_ptx_read_lanemask_lt();
+ int d = __builtin_ptx_read_lanemask_ge();
+ int e = __builtin_ptx_read_lanemask_gt();
+
+ return a + b + c + d + e;
+
+}
+
+
+long read_clocks() {
+
+ int a = __builtin_ptx_read_clock();
+ long b = __builtin_ptx_read_clock64();
+
+ return (long)a + b;
+
+}
+
+int read_pms() {
+
+ int a = __builtin_ptx_read_pm0();
+ int b = __builtin_ptx_read_pm1();
+ int c = __builtin_ptx_read_pm2();
+ int d = __builtin_ptx_read_pm3();
+
+ return a + b + c + d;
+
+}
+
+void sync() {
+
+ __builtin_ptx_bar_sync(0);
+
+}
diff --git a/clang/test/CodeGen/builtins-x86.c b/clang/test/CodeGen/builtins-x86.c
new file mode 100644
index 0000000..acb5554
--- /dev/null
+++ b/clang/test/CodeGen/builtins-x86.c
@@ -0,0 +1,496 @@
+// RUN: %clang_cc1 -DUSE_64 -triple x86_64-unknown-unknown -emit-llvm -o %t %s
+// RUN: %clang_cc1 -DUSE_ALL -triple x86_64-unknown-unknown -fsyntax-only -o %t %s
+
+#ifdef USE_ALL
+#define USE_3DNOW
+#define USE_64
+#define USE_SSE4
+#endif
+
+// 64-bit
+typedef char V8c __attribute__((vector_size(8 * sizeof(char))));
+typedef signed short V4s __attribute__((vector_size(8)));
+typedef signed int V2i __attribute__((vector_size(8)));
+typedef signed long long V1LLi __attribute__((vector_size(8)));
+
+typedef float V2f __attribute__((vector_size(8)));
+
+// 128-bit
+typedef char V16c __attribute__((vector_size(16)));
+typedef signed short V8s __attribute__((vector_size(16)));
+typedef signed int V4i __attribute__((vector_size(16)));
+typedef signed long long V2LLi __attribute__((vector_size(16)));
+
+typedef float V4f __attribute__((vector_size(16)));
+typedef double V2d __attribute__((vector_size(16)));
+
+// 256-bit
+typedef char V32c __attribute__((vector_size(32)));
+typedef signed int V8i __attribute__((vector_size(32)));
+typedef signed long long V4LLi __attribute__((vector_size(32)));
+
+typedef double V4d __attribute__((vector_size(32)));
+typedef float V8f __attribute__((vector_size(32)));
+
+void f0() {
+ signed char tmp_c;
+// unsigned char tmp_Uc;
+ signed short tmp_s;
+#ifdef USE_ALL
+ unsigned short tmp_Us;
+#endif
+ signed int tmp_i;
+ unsigned int tmp_Ui;
+ signed long long tmp_LLi;
+// unsigned long long tmp_ULLi;
+ float tmp_f;
+ double tmp_d;
+
+ void* tmp_vp;
+ const void* tmp_vCp;
+ char* tmp_cp;
+ const char* tmp_cCp;
+ int* tmp_ip;
+ float* tmp_fp;
+ const float* tmp_fCp;
+ double* tmp_dp;
+ const double* tmp_dCp;
+
+#define imm_i 32
+#define imm_i_0_2 0
+#define imm_i_0_4 3
+#define imm_i_0_8 7
+#define imm_i_0_16 15
+ // Check this.
+#define imm_i_0_256 0
+
+ V2i* tmp_V2ip;
+ V1LLi* tmp_V1LLip;
+ V2LLi* tmp_V2LLip;
+
+ // 64-bit
+ V8c tmp_V8c;
+ V4s tmp_V4s;
+ V2i tmp_V2i;
+ V1LLi tmp_V1LLi;
+#ifdef USE_3DNOW
+ V2f tmp_V2f;
+#endif
+
+ // 128-bit
+ V16c tmp_V16c;
+ V8s tmp_V8s;
+ V4i tmp_V4i;
+ V2LLi tmp_V2LLi;
+ V4f tmp_V4f;
+ V2d tmp_V2d;
+ V2d* tmp_V2dp;
+ V4f* tmp_V4fp;
+ const V2d* tmp_V2dCp;
+ const V4f* tmp_V4fCp;
+
+ // 256-bit
+ V32c tmp_V32c;
+ V4d tmp_V4d;
+ V8f tmp_V8f;
+ V4LLi tmp_V4LLi;
+ V8i tmp_V8i;
+ V4LLi* tmp_V4LLip;
+ V4d* tmp_V4dp;
+ V8f* tmp_V8fp;
+ const V4d* tmp_V4dCp;
+ const V8f* tmp_V8fCp;
+
+ tmp_i = __builtin_ia32_comieq(tmp_V4f, tmp_V4f);
+ tmp_i = __builtin_ia32_comilt(tmp_V4f, tmp_V4f);
+ tmp_i = __builtin_ia32_comile(tmp_V4f, tmp_V4f);
+ tmp_i = __builtin_ia32_comigt(tmp_V4f, tmp_V4f);
+ tmp_i = __builtin_ia32_comige(tmp_V4f, tmp_V4f);
+ tmp_i = __builtin_ia32_comineq(tmp_V4f, tmp_V4f);
+ tmp_i = __builtin_ia32_ucomieq(tmp_V4f, tmp_V4f);
+ tmp_i = __builtin_ia32_ucomilt(tmp_V4f, tmp_V4f);
+ tmp_i = __builtin_ia32_ucomile(tmp_V4f, tmp_V4f);
+ tmp_i = __builtin_ia32_ucomigt(tmp_V4f, tmp_V4f);
+ tmp_i = __builtin_ia32_ucomige(tmp_V4f, tmp_V4f);
+ tmp_i = __builtin_ia32_ucomineq(tmp_V4f, tmp_V4f);
+ tmp_i = __builtin_ia32_comisdeq(tmp_V2d, tmp_V2d);
+ tmp_i = __builtin_ia32_comisdlt(tmp_V2d, tmp_V2d);
+ tmp_i = __builtin_ia32_comisdle(tmp_V2d, tmp_V2d);
+ tmp_i = __builtin_ia32_comisdgt(tmp_V2d, tmp_V2d);
+ tmp_i = __builtin_ia32_comisdge(tmp_V2d, tmp_V2d);
+ tmp_i = __builtin_ia32_comisdneq(tmp_V2d, tmp_V2d);
+ tmp_i = __builtin_ia32_ucomisdeq(tmp_V2d, tmp_V2d);
+ tmp_i = __builtin_ia32_ucomisdlt(tmp_V2d, tmp_V2d);
+ tmp_i = __builtin_ia32_ucomisdle(tmp_V2d, tmp_V2d);
+ tmp_i = __builtin_ia32_ucomisdgt(tmp_V2d, tmp_V2d);
+ tmp_i = __builtin_ia32_ucomisdge(tmp_V2d, tmp_V2d);
+ tmp_i = __builtin_ia32_ucomisdneq(tmp_V2d, tmp_V2d);
+ tmp_V4f = __builtin_ia32_cmpps(tmp_V4f, tmp_V4f, 0);
+ tmp_V4f = __builtin_ia32_cmpps(tmp_V4f, tmp_V4f, 1);
+ tmp_V4f = __builtin_ia32_cmpps(tmp_V4f, tmp_V4f, 2);
+ tmp_V4f = __builtin_ia32_cmpps(tmp_V4f, tmp_V4f, 3);
+ tmp_V4f = __builtin_ia32_cmpps(tmp_V4f, tmp_V4f, 4);
+ tmp_V4f = __builtin_ia32_cmpps(tmp_V4f, tmp_V4f, 5);
+ tmp_V4f = __builtin_ia32_cmpps(tmp_V4f, tmp_V4f, 6);
+ tmp_V4f = __builtin_ia32_cmpps(tmp_V4f, tmp_V4f, 7);
+ tmp_V4f = __builtin_ia32_cmpss(tmp_V4f, tmp_V4f, 0);
+ tmp_V4f = __builtin_ia32_cmpss(tmp_V4f, tmp_V4f, 1);
+ tmp_V4f = __builtin_ia32_cmpss(tmp_V4f, tmp_V4f, 2);
+ tmp_V4f = __builtin_ia32_cmpss(tmp_V4f, tmp_V4f, 3);
+ tmp_V4f = __builtin_ia32_cmpss(tmp_V4f, tmp_V4f, 4);
+ tmp_V4f = __builtin_ia32_cmpss(tmp_V4f, tmp_V4f, 5);
+ tmp_V4f = __builtin_ia32_cmpss(tmp_V4f, tmp_V4f, 6);
+ tmp_V4f = __builtin_ia32_cmpss(tmp_V4f, tmp_V4f, 7);
+ tmp_V4f = __builtin_ia32_minps(tmp_V4f, tmp_V4f);
+ tmp_V4f = __builtin_ia32_maxps(tmp_V4f, tmp_V4f);
+ tmp_V4f = __builtin_ia32_minss(tmp_V4f, tmp_V4f);
+ tmp_V4f = __builtin_ia32_maxss(tmp_V4f, tmp_V4f);
+
+ tmp_V8c = __builtin_ia32_paddsb(tmp_V8c, tmp_V8c);
+ tmp_V4s = __builtin_ia32_paddsw(tmp_V4s, tmp_V4s);
+ tmp_V8c = __builtin_ia32_psubsb(tmp_V8c, tmp_V8c);
+ tmp_V4s = __builtin_ia32_psubsw(tmp_V4s, tmp_V4s);
+ tmp_V8c = __builtin_ia32_paddusb(tmp_V8c, tmp_V8c);
+ tmp_V4s = __builtin_ia32_paddusw(tmp_V4s, tmp_V4s);
+ tmp_V8c = __builtin_ia32_psubusb(tmp_V8c, tmp_V8c);
+ tmp_V4s = __builtin_ia32_psubusw(tmp_V4s, tmp_V4s);
+ tmp_V4s = __builtin_ia32_pmulhw(tmp_V4s, tmp_V4s);
+ tmp_V4s = __builtin_ia32_pmulhuw(tmp_V4s, tmp_V4s);
+ tmp_V8c = __builtin_ia32_pavgb(tmp_V8c, tmp_V8c);
+ tmp_V4s = __builtin_ia32_pavgw(tmp_V4s, tmp_V4s);
+ tmp_V8c = __builtin_ia32_pcmpeqb(tmp_V8c, tmp_V8c);
+ tmp_V4s = __builtin_ia32_pcmpeqw(tmp_V4s, tmp_V4s);
+ tmp_V2i = __builtin_ia32_pcmpeqd(tmp_V2i, tmp_V2i);
+ tmp_V8c = __builtin_ia32_pcmpgtb(tmp_V8c, tmp_V8c);
+ tmp_V4s = __builtin_ia32_pcmpgtw(tmp_V4s, tmp_V4s);
+ tmp_V2i = __builtin_ia32_pcmpgtd(tmp_V2i, tmp_V2i);
+ tmp_V8c = __builtin_ia32_pmaxub(tmp_V8c, tmp_V8c);
+ tmp_V4s = __builtin_ia32_pmaxsw(tmp_V4s, tmp_V4s);
+ tmp_V8c = __builtin_ia32_pminub(tmp_V8c, tmp_V8c);
+ tmp_V4s = __builtin_ia32_pminsw(tmp_V4s, tmp_V4s);
+ tmp_V2d = __builtin_ia32_cmppd(tmp_V2d, tmp_V2d, 0);
+ tmp_V2d = __builtin_ia32_cmppd(tmp_V2d, tmp_V2d, 1);
+ tmp_V2d = __builtin_ia32_cmppd(tmp_V2d, tmp_V2d, 2);
+ tmp_V2d = __builtin_ia32_cmppd(tmp_V2d, tmp_V2d, 3);
+ tmp_V2d = __builtin_ia32_cmppd(tmp_V2d, tmp_V2d, 4);
+ tmp_V2d = __builtin_ia32_cmppd(tmp_V2d, tmp_V2d, 5);
+ tmp_V2d = __builtin_ia32_cmppd(tmp_V2d, tmp_V2d, 6);
+ tmp_V2d = __builtin_ia32_cmppd(tmp_V2d, tmp_V2d, 7);
+ tmp_V2d = __builtin_ia32_cmpsd(tmp_V2d, tmp_V2d, 0);
+ tmp_V2d = __builtin_ia32_cmpsd(tmp_V2d, tmp_V2d, 1);
+ tmp_V2d = __builtin_ia32_cmpsd(tmp_V2d, tmp_V2d, 2);
+ tmp_V2d = __builtin_ia32_cmpsd(tmp_V2d, tmp_V2d, 3);
+ tmp_V2d = __builtin_ia32_cmpsd(tmp_V2d, tmp_V2d, 4);
+ tmp_V2d = __builtin_ia32_cmpsd(tmp_V2d, tmp_V2d, 5);
+ tmp_V2d = __builtin_ia32_cmpsd(tmp_V2d, tmp_V2d, 6);
+ tmp_V2d = __builtin_ia32_cmpsd(tmp_V2d, tmp_V2d, 7);
+ tmp_V2d = __builtin_ia32_minpd(tmp_V2d, tmp_V2d);
+ tmp_V2d = __builtin_ia32_maxpd(tmp_V2d, tmp_V2d);
+ tmp_V2d = __builtin_ia32_minsd(tmp_V2d, tmp_V2d);
+ tmp_V2d = __builtin_ia32_maxsd(tmp_V2d, tmp_V2d);
+ tmp_V16c = __builtin_ia32_paddsb128(tmp_V16c, tmp_V16c);
+ tmp_V8s = __builtin_ia32_paddsw128(tmp_V8s, tmp_V8s);
+ tmp_V16c = __builtin_ia32_psubsb128(tmp_V16c, tmp_V16c);
+ tmp_V8s = __builtin_ia32_psubsw128(tmp_V8s, tmp_V8s);
+ tmp_V16c = __builtin_ia32_paddusb128(tmp_V16c, tmp_V16c);
+ tmp_V8s = __builtin_ia32_paddusw128(tmp_V8s, tmp_V8s);
+ tmp_V16c = __builtin_ia32_psubusb128(tmp_V16c, tmp_V16c);
+ tmp_V8s = __builtin_ia32_psubusw128(tmp_V8s, tmp_V8s);
+ tmp_V8s = __builtin_ia32_pmulhw128(tmp_V8s, tmp_V8s);
+ tmp_V16c = __builtin_ia32_pavgb128(tmp_V16c, tmp_V16c);
+ tmp_V8s = __builtin_ia32_pavgw128(tmp_V8s, tmp_V8s);
+ tmp_V16c = __builtin_ia32_pmaxub128(tmp_V16c, tmp_V16c);
+ tmp_V8s = __builtin_ia32_pmaxsw128(tmp_V8s, tmp_V8s);
+ tmp_V16c = __builtin_ia32_pminub128(tmp_V16c, tmp_V16c);
+ tmp_V8s = __builtin_ia32_pminsw128(tmp_V8s, tmp_V8s);
+ tmp_V8s = __builtin_ia32_packsswb128(tmp_V8s, tmp_V8s);
+ tmp_V4i = __builtin_ia32_packssdw128(tmp_V4i, tmp_V4i);
+ tmp_V8s = __builtin_ia32_packuswb128(tmp_V8s, tmp_V8s);
+ tmp_V8s = __builtin_ia32_pmulhuw128(tmp_V8s, tmp_V8s);
+ tmp_V4f = __builtin_ia32_addsubps(tmp_V4f, tmp_V4f);
+ tmp_V2d = __builtin_ia32_addsubpd(tmp_V2d, tmp_V2d);
+ tmp_V4f = __builtin_ia32_haddps(tmp_V4f, tmp_V4f);
+ tmp_V2d = __builtin_ia32_haddpd(tmp_V2d, tmp_V2d);
+ tmp_V4f = __builtin_ia32_hsubps(tmp_V4f, tmp_V4f);
+ tmp_V2d = __builtin_ia32_hsubpd(tmp_V2d, tmp_V2d);
+ tmp_V8s = __builtin_ia32_phaddw128(tmp_V8s, tmp_V8s);
+ tmp_V4s = __builtin_ia32_phaddw(tmp_V4s, tmp_V4s);
+ tmp_V4i = __builtin_ia32_phaddd128(tmp_V4i, tmp_V4i);
+ tmp_V2i = __builtin_ia32_phaddd(tmp_V2i, tmp_V2i);
+ tmp_V8s = __builtin_ia32_phaddsw128(tmp_V8s, tmp_V8s);
+ tmp_V4s = __builtin_ia32_phaddsw(tmp_V4s, tmp_V4s);
+ tmp_V8s = __builtin_ia32_phsubw128(tmp_V8s, tmp_V8s);
+ tmp_V4s = __builtin_ia32_phsubw(tmp_V4s, tmp_V4s);
+ tmp_V4i = __builtin_ia32_phsubd128(tmp_V4i, tmp_V4i);
+ tmp_V2i = __builtin_ia32_phsubd(tmp_V2i, tmp_V2i);
+ tmp_V8s = __builtin_ia32_phsubsw128(tmp_V8s, tmp_V8s);
+ tmp_V4s = __builtin_ia32_phsubsw(tmp_V4s, tmp_V4s);
+ tmp_V16c = __builtin_ia32_pmaddubsw128(tmp_V16c, tmp_V16c);
+ tmp_V8c = __builtin_ia32_pmaddubsw(tmp_V8c, tmp_V8c);
+ tmp_V8s = __builtin_ia32_pmulhrsw128(tmp_V8s, tmp_V8s);
+ tmp_V4s = __builtin_ia32_pmulhrsw(tmp_V4s, tmp_V4s);
+ tmp_V16c = __builtin_ia32_pshufb128(tmp_V16c, tmp_V16c);
+ tmp_V8c = __builtin_ia32_pshufb(tmp_V8c, tmp_V8c);
+ tmp_V16c = __builtin_ia32_psignb128(tmp_V16c, tmp_V16c);
+ tmp_V8c = __builtin_ia32_psignb(tmp_V8c, tmp_V8c);
+ tmp_V8s = __builtin_ia32_psignw128(tmp_V8s, tmp_V8s);
+ tmp_V4s = __builtin_ia32_psignw(tmp_V4s, tmp_V4s);
+ tmp_V4i = __builtin_ia32_psignd128(tmp_V4i, tmp_V4i);
+ tmp_V2i = __builtin_ia32_psignd(tmp_V2i, tmp_V2i);
+ tmp_V16c = __builtin_ia32_pabsb128(tmp_V16c);
+ tmp_V8c = __builtin_ia32_pabsb(tmp_V8c);
+ tmp_V8s = __builtin_ia32_pabsw128(tmp_V8s);
+ tmp_V4s = __builtin_ia32_pabsw(tmp_V4s);
+ tmp_V4i = __builtin_ia32_pabsd128(tmp_V4i);
+ tmp_V2i = __builtin_ia32_pabsd(tmp_V2i);
+ tmp_V4s = __builtin_ia32_psllw(tmp_V4s, tmp_V1LLi);
+ tmp_V2i = __builtin_ia32_pslld(tmp_V2i, tmp_V1LLi);
+ tmp_V1LLi = __builtin_ia32_psllq(tmp_V1LLi, tmp_V1LLi);
+ tmp_V4s = __builtin_ia32_psrlw(tmp_V4s, tmp_V1LLi);
+ tmp_V2i = __builtin_ia32_psrld(tmp_V2i, tmp_V1LLi);
+ tmp_V1LLi = __builtin_ia32_psrlq(tmp_V1LLi, tmp_V1LLi);
+ tmp_V4s = __builtin_ia32_psraw(tmp_V4s, tmp_V1LLi);
+ tmp_V2i = __builtin_ia32_psrad(tmp_V2i, tmp_V1LLi);
+ tmp_V2i = __builtin_ia32_pmaddwd(tmp_V4s, tmp_V4s);
+ tmp_V8c = __builtin_ia32_packsswb(tmp_V4s, tmp_V4s);
+ tmp_V4s = __builtin_ia32_packssdw(tmp_V2i, tmp_V2i);
+ tmp_V8c = __builtin_ia32_packuswb(tmp_V4s, tmp_V4s);
+ tmp_i = __builtin_ia32_vec_ext_v2si(tmp_V2i, 0);
+
+ (void) __builtin_ia32_ldmxcsr(tmp_Ui);
+ tmp_Ui = __builtin_ia32_stmxcsr();
+ tmp_V4f = __builtin_ia32_cvtpi2ps(tmp_V4f, tmp_V2i);
+ tmp_V2i = __builtin_ia32_cvtps2pi(tmp_V4f);
+ tmp_i = __builtin_ia32_cvtss2si(tmp_V4f);
+#ifdef USE_64
+ tmp_LLi = __builtin_ia32_cvtss2si64(tmp_V4f);
+#endif
+ tmp_V2i = __builtin_ia32_cvttps2pi(tmp_V4f);
+ (void) __builtin_ia32_maskmovq(tmp_V8c, tmp_V8c, tmp_cp);
+ (void) __builtin_ia32_storeups(tmp_fp, tmp_V4f);
+ (void) __builtin_ia32_storehps(tmp_V2ip, tmp_V4f);
+ (void) __builtin_ia32_storelps(tmp_V2ip, tmp_V4f);
+ tmp_i = __builtin_ia32_movmskps(tmp_V4f);
+ tmp_i = __builtin_ia32_pmovmskb(tmp_V8c);
+ (void) __builtin_ia32_movntps(tmp_fp, tmp_V4f);
+ (void) __builtin_ia32_movntq(tmp_V1LLip, tmp_V1LLi);
+ (void) __builtin_ia32_sfence();
+
+ tmp_V4s = __builtin_ia32_psadbw(tmp_V8c, tmp_V8c);
+ tmp_V4f = __builtin_ia32_rcpps(tmp_V4f);
+ tmp_V4f = __builtin_ia32_rcpss(tmp_V4f);
+ tmp_V4f = __builtin_ia32_rsqrtps(tmp_V4f);
+ tmp_V4f = __builtin_ia32_rsqrtss(tmp_V4f);
+ tmp_V4f = __builtin_ia32_sqrtps(tmp_V4f);
+ tmp_V4f = __builtin_ia32_sqrtss(tmp_V4f);
+ (void) __builtin_ia32_maskmovdqu(tmp_V16c, tmp_V16c, tmp_cp);
+ (void) __builtin_ia32_storeupd(tmp_dp, tmp_V2d);
+ tmp_i = __builtin_ia32_movmskpd(tmp_V2d);
+ tmp_i = __builtin_ia32_pmovmskb128(tmp_V16c);
+ (void) __builtin_ia32_movnti(tmp_ip, tmp_i);
+ (void) __builtin_ia32_movntpd(tmp_dp, tmp_V2d);
+ (void) __builtin_ia32_movntdq(tmp_V2LLip, tmp_V2LLi);
+ tmp_V2LLi = __builtin_ia32_psadbw128(tmp_V16c, tmp_V16c);
+ tmp_V2d = __builtin_ia32_sqrtpd(tmp_V2d);
+ tmp_V2d = __builtin_ia32_sqrtsd(tmp_V2d);
+ tmp_V2d = __builtin_ia32_cvtdq2pd(tmp_V4i);
+ tmp_V4f = __builtin_ia32_cvtdq2ps(tmp_V4i);
+ tmp_V2LLi = __builtin_ia32_cvtpd2dq(tmp_V2d);
+ tmp_V2i = __builtin_ia32_cvtpd2pi(tmp_V2d);
+ tmp_V4f = __builtin_ia32_cvtpd2ps(tmp_V2d);
+ tmp_V4i = __builtin_ia32_cvttpd2dq(tmp_V2d);
+ tmp_V2i = __builtin_ia32_cvttpd2pi(tmp_V2d);
+ tmp_V2d = __builtin_ia32_cvtpi2pd(tmp_V2i);
+ tmp_i = __builtin_ia32_cvtsd2si(tmp_V2d);
+#ifdef USE_64
+ tmp_LLi = __builtin_ia32_cvtsd2si64(tmp_V2d);
+#endif
+ tmp_V4i = __builtin_ia32_cvtps2dq(tmp_V4f);
+ tmp_V2d = __builtin_ia32_cvtps2pd(tmp_V4f);
+ tmp_V4i = __builtin_ia32_cvttps2dq(tmp_V4f);
+ (void) __builtin_ia32_clflush(tmp_vCp);
+ (void) __builtin_ia32_lfence();
+ (void) __builtin_ia32_mfence();
+ (void) __builtin_ia32_storedqu(tmp_cp, tmp_V16c);
+ tmp_V4s = __builtin_ia32_psllwi(tmp_V4s, tmp_i);
+ tmp_V2i = __builtin_ia32_pslldi(tmp_V2i, tmp_i);
+ tmp_V1LLi = __builtin_ia32_psllqi(tmp_V1LLi, tmp_i);
+ tmp_V4s = __builtin_ia32_psrawi(tmp_V4s, tmp_i);
+ tmp_V2i = __builtin_ia32_psradi(tmp_V2i, tmp_i);
+ tmp_V4s = __builtin_ia32_psrlwi(tmp_V4s, tmp_i);
+ tmp_V2i = __builtin_ia32_psrldi(tmp_V2i, tmp_i);
+ tmp_V1LLi = __builtin_ia32_psrlqi(tmp_V1LLi, tmp_i);
+ tmp_V1LLi = __builtin_ia32_pmuludq(tmp_V2i, tmp_V2i);
+ tmp_V2LLi = __builtin_ia32_pmuludq128(tmp_V4i, tmp_V4i);
+ tmp_V8s = __builtin_ia32_psraw128(tmp_V8s, tmp_V8s);
+ tmp_V4i = __builtin_ia32_psrad128(tmp_V4i, tmp_V4i);
+ tmp_V8s = __builtin_ia32_psrlw128(tmp_V8s, tmp_V8s);
+ tmp_V4i = __builtin_ia32_psrld128(tmp_V4i, tmp_V4i);
+ tmp_V2LLi = __builtin_ia32_psrlq128(tmp_V2LLi, tmp_V2LLi);
+ tmp_V8s = __builtin_ia32_psllw128(tmp_V8s, tmp_V8s);
+ tmp_V4i = __builtin_ia32_pslld128(tmp_V4i, tmp_V4i);
+ tmp_V2LLi = __builtin_ia32_psllq128(tmp_V2LLi, tmp_V2LLi);
+ tmp_V8s = __builtin_ia32_psllwi128(tmp_V8s, tmp_i);
+ tmp_V4i = __builtin_ia32_pslldi128(tmp_V4i, tmp_i);
+ tmp_V2LLi = __builtin_ia32_psllqi128(tmp_V2LLi, tmp_i);
+ tmp_V8s = __builtin_ia32_psrlwi128(tmp_V8s, tmp_i);
+ tmp_V4i = __builtin_ia32_psrldi128(tmp_V4i, tmp_i);
+ tmp_V2LLi = __builtin_ia32_psrlqi128(tmp_V2LLi, tmp_i);
+ tmp_V8s = __builtin_ia32_psrawi128(tmp_V8s, tmp_i);
+ tmp_V4i = __builtin_ia32_psradi128(tmp_V4i, tmp_i);
+ tmp_V8s = __builtin_ia32_pmaddwd128(tmp_V8s, tmp_V8s);
+ (void) __builtin_ia32_monitor(tmp_vp, tmp_Ui, tmp_Ui);
+ (void) __builtin_ia32_mwait(tmp_Ui, tmp_Ui);
+ tmp_V16c = __builtin_ia32_lddqu(tmp_cCp);
+ tmp_V2LLi = __builtin_ia32_palignr128(tmp_V2LLi, tmp_V2LLi, imm_i);
+ tmp_V1LLi = __builtin_ia32_palignr(tmp_V1LLi, tmp_V1LLi, imm_i);
+ (void) __builtin_ia32_storelv4si(tmp_V2ip, tmp_V2LLi);
+#ifdef USE_SSE4
+ tmp_V16c = __builtin_ia32_pblendvb128(tmp_V16c, tmp_V16c, tmp_V16c);
+ tmp_V8s = __builtin_ia32_pblendw128(tmp_V8s, tmp_V8s, imm_i_0_256);
+ tmp_V2d = __builtin_ia32_blendpd(tmp_V2d, tmp_V2d, imm_i_0_256);
+ tmp_V4f = __builtin_ia32_blendps(tmp_V4f, tmp_V4f, imm_i_0_256);
+ tmp_V2d = __builtin_ia32_blendvpd(tmp_V2d, tmp_V2d, tmp_V2d);
+ tmp_V4f = __builtin_ia32_blendvps(tmp_V4f, tmp_V4f, tmp_V4f);
+ tmp_V8s = __builtin_ia32_packusdw128(tmp_V4i, tmp_V4i);
+ tmp_V16c = __builtin_ia32_pmaxsb128(tmp_V16c, tmp_V16c);
+ tmp_V4i = __builtin_ia32_pmaxsd128(tmp_V4i, tmp_V4i);
+ tmp_V4i = __builtin_ia32_pmaxud128(tmp_V4i, tmp_V4i);
+ tmp_V8s = __builtin_ia32_pmaxuw128(tmp_V8s, tmp_V8s);
+ tmp_V16c = __builtin_ia32_pminsb128(tmp_V16c, tmp_V16c);
+ tmp_V4i = __builtin_ia32_pminsd128(tmp_V4i, tmp_V4i);
+ tmp_V4i = __builtin_ia32_pminud128(tmp_V4i, tmp_V4i);
+ tmp_V8s = __builtin_ia32_pminuw128(tmp_V8s, tmp_V8s);
+ tmp_V4i = __builtin_ia32_pmovsxbd128(tmp_V16c);
+ tmp_V2LLi = __builtin_ia32_pmovsxbq128(tmp_V16c);
+ tmp_V8s = __builtin_ia32_pmovsxbw128(tmp_V16c);
+ tmp_V2LLi = __builtin_ia32_pmovsxdq128(tmp_V4i);
+ tmp_V4i = __builtin_ia32_pmovsxwd128(tmp_V8s);
+ tmp_V2LLi = __builtin_ia32_pmovsxwq128(tmp_V8s);
+ tmp_V4i = __builtin_ia32_pmovzxbd128(tmp_V16c);
+ tmp_V2LLi = __builtin_ia32_pmovzxbq128(tmp_V16c);
+ tmp_V8s = __builtin_ia32_pmovzxbw128(tmp_V16c);
+ tmp_V2LLi = __builtin_ia32_pmovzxdq128(tmp_V4i);
+ tmp_V4i = __builtin_ia32_pmovzxwd128(tmp_V8s);
+ tmp_V2LLi = __builtin_ia32_pmovzxwq128(tmp_V8s);
+ tmp_V2LLi = __builtin_ia32_pmuldq128(tmp_V4i, tmp_V4i);
+ tmp_V4i = __builtin_ia32_pmulld128(tmp_V4i, tmp_V4i);
+ tmp_V4f = __builtin_ia32_roundps(tmp_V4f, imm_i_0_16);
+ tmp_V4f = __builtin_ia32_roundss(tmp_V4f, tmp_V4f, imm_i_0_16);
+ tmp_V2d = __builtin_ia32_roundsd(tmp_V2d, tmp_V2d, imm_i_0_16);
+ tmp_V2d = __builtin_ia32_roundpd(tmp_V2d, imm_i_0_16);
+ tmp_V4f = __builtin_ia32_insertps128(tmp_V4f, tmp_V4f, tmp_i);
+#endif
+
+ tmp_V4d = __builtin_ia32_addsubpd256(tmp_V4d, tmp_V4d);
+ tmp_V8f = __builtin_ia32_addsubps256(tmp_V8f, tmp_V8f);
+ tmp_V4d = __builtin_ia32_haddpd256(tmp_V4d, tmp_V4d);
+ tmp_V8f = __builtin_ia32_hsubps256(tmp_V8f, tmp_V8f);
+ tmp_V4d = __builtin_ia32_hsubpd256(tmp_V4d, tmp_V4d);
+ tmp_V8f = __builtin_ia32_haddps256(tmp_V8f, tmp_V8f);
+ tmp_V4d = __builtin_ia32_maxpd256(tmp_V4d, tmp_V4d);
+ tmp_V8f = __builtin_ia32_maxps256(tmp_V8f, tmp_V8f);
+ tmp_V4d = __builtin_ia32_minpd256(tmp_V4d, tmp_V4d);
+ tmp_V8f = __builtin_ia32_minps256(tmp_V8f, tmp_V8f);
+ tmp_V2d = __builtin_ia32_vpermilvarpd(tmp_V2d, tmp_V2LLi);
+ tmp_V4f = __builtin_ia32_vpermilvarps(tmp_V4f, tmp_V4i);
+ tmp_V4d = __builtin_ia32_vpermilvarpd256(tmp_V4d, tmp_V4LLi);
+ tmp_V8f = __builtin_ia32_vpermilvarps256(tmp_V8f, tmp_V8i);
+ tmp_V4d = __builtin_ia32_blendpd256(tmp_V4d, tmp_V4d, 0x7);
+ tmp_V8f = __builtin_ia32_blendps256(tmp_V8f, tmp_V8f, 0x7);
+ tmp_V4d = __builtin_ia32_blendvpd256(tmp_V4d, tmp_V4d, tmp_V4d);
+ tmp_V8f = __builtin_ia32_blendvps256(tmp_V8f, tmp_V8f, tmp_V8f);
+ tmp_V8f = __builtin_ia32_dpps256(tmp_V8f, tmp_V8f, 0x7);
+ tmp_V4d = __builtin_ia32_cmppd256(tmp_V4d, tmp_V4d, 0);
+ tmp_V8f = __builtin_ia32_cmpps256(tmp_V8f, tmp_V8f, 0);
+ tmp_V2d = __builtin_ia32_vextractf128_pd256(tmp_V4d, 0x7);
+ tmp_V4f = __builtin_ia32_vextractf128_ps256(tmp_V8f, 0x7);
+ tmp_V4i = __builtin_ia32_vextractf128_si256(tmp_V8i, 0x7);
+ tmp_V4d = __builtin_ia32_cvtdq2pd256(tmp_V4i);
+ tmp_V8f = __builtin_ia32_cvtdq2ps256(tmp_V8i);
+ tmp_V4f = __builtin_ia32_cvtpd2ps256(tmp_V4d);
+ tmp_V8i = __builtin_ia32_cvtps2dq256(tmp_V8f);
+ tmp_V4d = __builtin_ia32_cvtps2pd256(tmp_V4f);
+ tmp_V4i = __builtin_ia32_cvttpd2dq256(tmp_V4d);
+ tmp_V4i = __builtin_ia32_cvtpd2dq256(tmp_V4d);
+ tmp_V8i = __builtin_ia32_cvttps2dq256(tmp_V8f);
+ tmp_V4d = __builtin_ia32_vperm2f128_pd256(tmp_V4d, tmp_V4d, 0x7);
+ tmp_V8f = __builtin_ia32_vperm2f128_ps256(tmp_V8f, tmp_V8f, 0x7);
+ tmp_V8i = __builtin_ia32_vperm2f128_si256(tmp_V8i, tmp_V8i, 0x7);
+ tmp_V4d = __builtin_ia32_vinsertf128_pd256(tmp_V4d, tmp_V2d, 0x7);
+ tmp_V8f = __builtin_ia32_vinsertf128_ps256(tmp_V8f, tmp_V4f, 0x7);
+ tmp_V8i = __builtin_ia32_vinsertf128_si256(tmp_V8i, tmp_V4i, 0x7);
+ tmp_V4d = __builtin_ia32_sqrtpd256(tmp_V4d);
+ tmp_V8f = __builtin_ia32_sqrtps256(tmp_V8f);
+ tmp_V8f = __builtin_ia32_rsqrtps256(tmp_V8f);
+ tmp_V8f = __builtin_ia32_rcpps256(tmp_V8f);
+ tmp_V4d = __builtin_ia32_roundpd256(tmp_V4d, 0x1);
+ tmp_V8f = __builtin_ia32_roundps256(tmp_V8f, 0x1);
+ tmp_i = __builtin_ia32_vtestzpd(tmp_V2d, tmp_V2d);
+ tmp_i = __builtin_ia32_vtestcpd(tmp_V2d, tmp_V2d);
+ tmp_i = __builtin_ia32_vtestnzcpd(tmp_V2d, tmp_V2d);
+ tmp_i = __builtin_ia32_vtestzps(tmp_V4f, tmp_V4f);
+ tmp_i = __builtin_ia32_vtestcps(tmp_V4f, tmp_V4f);
+ tmp_i = __builtin_ia32_vtestnzcps(tmp_V4f, tmp_V4f);
+ tmp_i = __builtin_ia32_vtestzpd256(tmp_V4d, tmp_V4d);
+ tmp_i = __builtin_ia32_vtestcpd256(tmp_V4d, tmp_V4d);
+ tmp_i = __builtin_ia32_vtestnzcpd256(tmp_V4d, tmp_V4d);
+ tmp_i = __builtin_ia32_vtestzps256(tmp_V8f, tmp_V8f);
+ tmp_i = __builtin_ia32_vtestcps256(tmp_V8f, tmp_V8f);
+ tmp_i = __builtin_ia32_vtestnzcps256(tmp_V8f, tmp_V8f);
+ tmp_i = __builtin_ia32_ptestz256(tmp_V4LLi, tmp_V4LLi);
+ tmp_i = __builtin_ia32_ptestc256(tmp_V4LLi, tmp_V4LLi);
+ tmp_i = __builtin_ia32_ptestnzc256(tmp_V4LLi, tmp_V4LLi);
+ tmp_i = __builtin_ia32_movmskpd256(tmp_V4d);
+ tmp_i = __builtin_ia32_movmskps256(tmp_V8f);
+ __builtin_ia32_vzeroall();
+ __builtin_ia32_vzeroupper();
+ tmp_V4f = __builtin_ia32_vbroadcastss(tmp_fCp);
+ tmp_V4d = __builtin_ia32_vbroadcastsd256(tmp_dCp);
+ tmp_V8f = __builtin_ia32_vbroadcastss256(tmp_fCp);
+ tmp_V4d = __builtin_ia32_vbroadcastf128_pd256(tmp_V2dCp);
+ tmp_V8f = __builtin_ia32_vbroadcastf128_ps256(tmp_V4fCp);
+ __builtin_ia32_storeupd256(tmp_dp, tmp_V4d);
+ __builtin_ia32_storeups256(tmp_fp, tmp_V8f);
+ __builtin_ia32_storedqu256(tmp_cp, tmp_V32c);
+ tmp_V32c = __builtin_ia32_lddqu256(tmp_cCp);
+ __builtin_ia32_movntdq256(tmp_V4LLip, tmp_V4LLi);
+ __builtin_ia32_movntpd256(tmp_dp, tmp_V4d);
+ __builtin_ia32_movntps256(tmp_fp, tmp_V8f);
+ tmp_V2d = __builtin_ia32_maskloadpd(tmp_V2dCp, tmp_V2d);
+ tmp_V4f = __builtin_ia32_maskloadps(tmp_V4fCp, tmp_V4f);
+ tmp_V4d = __builtin_ia32_maskloadpd256(tmp_V4dCp, tmp_V4d);
+ tmp_V8f = __builtin_ia32_maskloadps256(tmp_V8fCp, tmp_V8f);
+ __builtin_ia32_maskstorepd(tmp_V2dp, tmp_V2d, tmp_V2d);
+ __builtin_ia32_maskstoreps(tmp_V4fp, tmp_V4f, tmp_V4f);
+ __builtin_ia32_maskstorepd256(tmp_V4dp, tmp_V4d, tmp_V4d);
+ __builtin_ia32_maskstoreps256(tmp_V8fp, tmp_V8f, tmp_V8f);
+
+#ifdef USE_3DNOW
+ tmp_V8c = __builtin_ia32_pavgusb(tmp_V8c, tmp_V8c);
+ tmp_V2i = __builtin_ia32_pf2id(tmp_V2f);
+ tmp_V2f = __builtin_ia32_pfacc(tmp_V2f, tmp_V2f);
+ tmp_V2f = __builtin_ia32_pfadd(tmp_V2f, tmp_V2f);
+ tmp_V2i = __builtin_ia32_pfcmpeq(tmp_V2f, tmp_V2f);
+ tmp_V2i = __builtin_ia32_pfcmpge(tmp_V2f, tmp_V2f);
+ tmp_V2i = __builtin_ia32_pfcmpgt(tmp_V2f, tmp_V2f);
+ tmp_V2f = __builtin_ia32_pfmax(tmp_V2f, tmp_V2f);
+ tmp_V2f = __builtin_ia32_pfmin(tmp_V2f, tmp_V2f);
+ tmp_V2f = __builtin_ia32_pfmul(tmp_V2f, tmp_V2f);
+ tmp_V2f = __builtin_ia32_pfrcp(tmp_V2f);
+ tmp_V2f = __builtin_ia32_pfrcpit1(tmp_V2f, tmp_V2f);
+ tmp_V2f = __builtin_ia32_pfrcpit2(tmp_V2f, tmp_V2f);
+ tmp_V2f = __builtin_ia32_pfrsqrt(tmp_V2f);
+ tmp_V2f = __builtin_ia32_pfrsqit1(tmp_V2f, tmp_V2f);
+ tmp_V2f = __builtin_ia32_pfsub(tmp_V2f, tmp_V2f);
+ tmp_V2f = __builtin_ia32_pfsubr(tmp_V2f, tmp_V2f);
+ tmp_V2f = __builtin_ia32_pi2fd(tmp_V2i);
+ tmp_V4s = __builtin_ia32_pmulhrw(tmp_V4s, tmp_V4s);
+ tmp_V2i = __builtin_ia32_pf2iw(tmp_V2f);
+ tmp_V2f = __builtin_ia32_pfnacc(tmp_V2f, tmp_V2f);
+ tmp_V2f = __builtin_ia32_pfpnacc(tmp_V2f, tmp_V2f);
+ tmp_V2f = __builtin_ia32_pi2fw(tmp_V2i);
+ tmp_V2f = __builtin_ia32_pswapdsf(tmp_V2f);
+ tmp_V2i = __builtin_ia32_pswapdsi(tmp_V2i);
+#endif
+}
diff --git a/clang/test/CodeGen/builtins.c b/clang/test/CodeGen/builtins.c
new file mode 100644
index 0000000..fca087e
--- /dev/null
+++ b/clang/test/CodeGen/builtins.c
@@ -0,0 +1,205 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: not grep __builtin %t
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-darwin-apple | FileCheck %s
+
+int printf(const char *, ...);
+
+void p(char *str, int x) {
+ printf("%s: %d\n", str, x);
+}
+void q(char *str, double x) {
+ printf("%s: %f\n", str, x);
+}
+void r(char *str, void *ptr) {
+ printf("%s: %p\n", str, ptr);
+}
+
+int random(void);
+
+int main() {
+ int N = random();
+#define P(n,args) p(#n #args, __builtin_##n args)
+#define Q(n,args) q(#n #args, __builtin_##n args)
+#define R(n,args) r(#n #args, __builtin_##n args)
+#define V(n,args) p(#n #args, (__builtin_##n args, 0))
+ P(types_compatible_p, (int, float));
+ P(choose_expr, (0, 10, 20));
+ P(constant_p, (sizeof(10)));
+ P(expect, (N == 12, 0));
+ V(prefetch, (&N));
+ V(prefetch, (&N, 1));
+ V(prefetch, (&N, 1, 0));
+
+ // Numeric Constants
+
+ Q(huge_val, ());
+ Q(huge_valf, ());
+ Q(huge_vall, ());
+ Q(inf, ());
+ Q(inff, ());
+ Q(infl, ());
+
+ P(fpclassify, (0, 1, 2, 3, 4, 1.0));
+ P(fpclassify, (0, 1, 2, 3, 4, 1.0f));
+ P(fpclassify, (0, 1, 2, 3, 4, 1.0l));
+ // FIXME:
+ // P(isinf_sign, (1.0));
+
+ Q(nan, (""));
+ Q(nanf, (""));
+ Q(nanl, (""));
+ Q(nans, (""));
+ Q(nan, ("10"));
+ Q(nanf, ("10"));
+ Q(nanl, ("10"));
+ Q(nans, ("10"));
+
+ P(isgreater, (1., 2.));
+ P(isgreaterequal, (1., 2.));
+ P(isless, (1., 2.));
+ P(islessequal, (1., 2.));
+ P(islessgreater, (1., 2.));
+ P(isunordered, (1., 2.));
+
+ P(isnan, (1.));
+
+ // Bitwise & Numeric Functions
+
+ P(abs, (N));
+
+ P(clz, (N));
+ P(clzl, (N));
+ P(clzll, (N));
+ P(ctz, (N));
+ P(ctzl, (N));
+ P(ctzll, (N));
+ P(ffs, (N));
+ P(ffsl, (N));
+ P(ffsll, (N));
+ P(parity, (N));
+ P(parityl, (N));
+ P(parityll, (N));
+ P(popcount, (N));
+ P(popcountl, (N));
+ P(popcountll, (N));
+ Q(powi, (1.2f, N));
+ Q(powif, (1.2f, N));
+ Q(powil, (1.2f, N));
+
+ // Lib functions
+ int a, b, n = random(); // Avoid optimizing out.
+ char s0[10], s1[] = "Hello";
+ V(strcat, (s0, s1));
+ V(strcmp, (s0, s1));
+ V(strncat, (s0, s1, n));
+ V(strchr, (s0, s1[0]));
+ V(strrchr, (s0, s1[0]));
+ V(strcpy, (s0, s1));
+ V(strncpy, (s0, s1, n));
+
+ // Object size checking
+ V(__memset_chk, (s0, 0, sizeof s0, n));
+ V(__memcpy_chk, (s0, s1, sizeof s0, n));
+ V(__memmove_chk, (s0, s1, sizeof s0, n));
+ V(__mempcpy_chk, (s0, s1, sizeof s0, n));
+ V(__strncpy_chk, (s0, s1, sizeof s0, n));
+ V(__strcpy_chk, (s0, s1, n));
+ s0[0] = 0;
+ V(__strcat_chk, (s0, s1, n));
+ P(object_size, (s0, 0));
+ P(object_size, (s0, 1));
+ P(object_size, (s0, 2));
+ P(object_size, (s0, 3));
+
+ // Whatever
+
+ P(bswap32, (N));
+ P(bswap64, (N));
+ // FIXME
+ // V(clear_cache, (&N, &N+1));
+ V(trap, ());
+ R(extract_return_addr, (&N));
+ P(signbit, (1.0));
+
+ return 0;
+}
+
+
+
+void foo() {
+ __builtin_strcat(0, 0);
+}
+
+// CHECK: define void @bar(
+void bar() {
+ float f;
+ double d;
+ long double ld;
+
+ // LLVM's hex representation of float constants is really unfortunate;
+ // basically it does a float-to-double "conversion" and then prints the
+ // hex form of that. That gives us weird artifacts like exponents
+ // that aren't numerically similar to the original exponent and
+ // significand bit-patterns that are offset by three bits (because
+ // the exponent was expanded from 8 bits to 11).
+ //
+ // 0xAE98 == 1010111010011000
+ // 0x15D3 == 1010111010011
+
+ f = __builtin_huge_valf(); // CHECK: float 0x7FF0000000000000
+ d = __builtin_huge_val(); // CHECK: double 0x7FF0000000000000
+ ld = __builtin_huge_vall(); // CHECK: x86_fp80 0xK7FFF8000000000000000
+ f = __builtin_nanf(""); // CHECK: float 0x7FF8000000000000
+ d = __builtin_nan(""); // CHECK: double 0x7FF8000000000000
+ ld = __builtin_nanl(""); // CHECK: x86_fp80 0xK7FFFC000000000000000
+ f = __builtin_nanf("0xAE98"); // CHECK: float 0x7FF815D300000000
+ d = __builtin_nan("0xAE98"); // CHECK: double 0x7FF800000000AE98
+ ld = __builtin_nanl("0xAE98"); // CHECK: x86_fp80 0xK7FFFC00000000000AE98
+ f = __builtin_nansf(""); // CHECK: float 0x7FF4000000000000
+ d = __builtin_nans(""); // CHECK: double 0x7FF4000000000000
+ ld = __builtin_nansl(""); // CHECK: x86_fp80 0xK7FFFA000000000000000
+ f = __builtin_nansf("0xAE98"); // CHECK: float 0x7FF015D300000000
+ d = __builtin_nans("0xAE98"); // CHECK: double 0x7FF000000000AE98
+ ld = __builtin_nansl("0xAE98");// CHECK: x86_fp80 0xK7FFF800000000000AE98
+
+}
+// CHECK: }
+
+
+// CHECK: define void @test_float_builtins
+void test_float_builtins(float F, double D, long double LD) {
+ volatile int res;
+ res = __builtin_isinf(F);
+ // CHECK: call float @fabsf(float
+ // CHECK: fcmp oeq float {{.*}}, 0x7FF0000000000000
+
+ res = __builtin_isinf(D);
+ // CHECK: call double @fabs(double
+ // CHECK: fcmp oeq double {{.*}}, 0x7FF0000000000000
+
+ res = __builtin_isinf(LD);
+ // CHECK: call x86_fp80 @fabsl(x86_fp80
+ // CHECK: fcmp oeq x86_fp80 {{.*}}, 0xK7FFF8000000000000000
+
+ res = __builtin_isfinite(F);
+ // CHECK: fcmp oeq float
+ // CHECK: call float @fabsf
+ // CHECK: fcmp une float {{.*}}, 0x7FF0000000000000
+ // CHECK: and i1
+
+ res = __builtin_isnormal(F);
+ // CHECK: fcmp oeq float
+ // CHECK: call float @fabsf
+ // CHECK: fcmp ult float {{.*}}, 0x7FF0000000000000
+ // CHECK: fcmp uge float {{.*}}, 0x3810000000000000
+ // CHECK: and i1
+ // CHECK: and i1
+}
+
+// CHECK: define void @test_builtin_longjmp
+void test_builtin_longjmp(void **buffer) {
+ // CHECK: [[BITCAST:%.*]] = bitcast
+ // CHECK-NEXT: call void @llvm.eh.sjlj.longjmp(i8* [[BITCAST]])
+ __builtin_longjmp(buffer, 1);
+ // CHECK-NEXT: unreachable
+}
diff --git a/clang/test/CodeGen/builtinshufflevector.c b/clang/test/CodeGen/builtinshufflevector.c
new file mode 100644
index 0000000..5c647df
--- /dev/null
+++ b/clang/test/CodeGen/builtinshufflevector.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm < %s | grep 'shufflevector' | count 1
+// RUN: %clang_cc1 -emit-llvm -ftrapv < %s | grep 'shufflevector' | count 1
+typedef int v4si __attribute__ ((vector_size (16)));
+
+v4si a(v4si x, v4si y) {return __builtin_shufflevector(x, y, 3, 2, 5, (2*3)+1);}
+
diff --git a/clang/test/CodeGen/builtinshufflevector2.c b/clang/test/CodeGen/builtinshufflevector2.c
new file mode 100644
index 0000000..faf7a3e
--- /dev/null
+++ b/clang/test/CodeGen/builtinshufflevector2.c
@@ -0,0 +1,35 @@
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck %s
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef unsigned int uint4 __attribute__((ext_vector_type(4)));
+
+// CHECK: define void @clang_shufflevector_v_v(
+void clang_shufflevector_v_v( float4* A, float4 x, uint4 mask ) {
+// CHECK: [[MASK:%.*]] = and <4 x i32> {{%.*}}, <i32 3, i32 3, i32 3, i32 3>
+// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i32 0
+// CHECK: [[E:%.*]] = extractelement <4 x float> [[X:%.*]], i32 [[I]]
+//
+// Here is where ToT Clang code generation makes a mistake.
+// It uses [[I]] as the insertion index instead of 0.
+// Similarly on the remaining insertelement.
+// CHECK: [[V:%[a-zA-Z0-9._]+]] = insertelement <4 x float> undef, float [[E]], i32 0
+
+// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i32 1
+// CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i32 [[I]]
+// CHECK: [[V:%.*]] = insertelement <4 x float> [[V]], float [[E]], i32 1
+// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i32 2
+// CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i32 [[I]]
+// CHECK: [[V:%.*]] = insertelement <4 x float> [[V]], float [[E]], i32 2
+// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i32 3
+// CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i32 [[I]]
+// CHECK: [[V:%.*]] = insertelement <4 x float> [[V]], float [[E]], i32 3
+// CHECK: store <4 x float> [[V]], <4 x float>* {{%.*}},
+ *A = __builtin_shufflevector( x, mask );
+}
+
+// CHECK: define void @clang_shufflevector_v_v_c(
+void clang_shufflevector_v_v_c( float4* A, float4 x, float4 y, uint4 mask ) {
+// CHECK: [[V:%.*]] = shufflevector <4 x float> {{%.*}}, <4 x float> {{%.*}}, <4 x i32> <i32 0, i32 4, i32 1, i32 5>
+// CHECK: store <4 x float> [[V]], <4 x float>* {{%.*}}
+ *A = __builtin_shufflevector( x, y, 0, 4, 1, 5 );
+}
diff --git a/clang/test/CodeGen/byval-memcpy-elim.c b/clang/test/CodeGen/byval-memcpy-elim.c
new file mode 100644
index 0000000..76cdafb
--- /dev/null
+++ b/clang/test/CodeGen/byval-memcpy-elim.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10 < %s | FileCheck %s
+
+struct Test1S {
+ long NumDecls;
+ long X;
+ long Y;
+};
+struct Test2S {
+ long NumDecls;
+ long X;
+};
+
+// Make sure we don't generate extra memcpy for lvalues
+void test1a(struct Test1S, struct Test2S);
+// CHECK: define void @test1(
+// CHECK-NOT: memcpy
+// CHECK: call void @test1a
+void test1(struct Test1S *A, struct Test2S *B) {
+ test1a(*A, *B);
+}
+
+// The above gets tricker when the byval argument requires higher alignment
+// than the natural alignment of the type in question.
+// rdar://9483886
+
+// Make sure we do generate a memcpy when we cannot guarantee alignment.
+struct Test3S {
+ int a,b,c,d,e,f,g,h,i,j,k,l;
+};
+void test2a(struct Test3S q);
+// CHECK: define void @test2(
+// CHECK: alloca %struct.Test3S, align 8
+// CHECK: memcpy
+// CHECK: call void @test2a
+void test2(struct Test3S *q) {
+ test2a(*q);
+}
+
+// But make sure we don't generate a memcpy when we can guarantee alignment.
+void fooey(void);
+// CHECK: define void @test3(
+// CHECK: alloca %struct.Test3S, align 8
+// CHECK: call void @fooey
+// CHECK-NOT: memcpy
+// CHECK: call void @test2a
+// CHECK-NOT: memcpy
+// CHECK: call void @test2a
+void test3(struct Test3S a) {
+ struct Test3S b = a;
+ fooey();
+ test2a(a);
+ test2a(b);
+}
diff --git a/clang/test/CodeGen/c-strings.c b/clang/test/CodeGen/c-strings.c
new file mode 100644
index 0000000..4fbeb7b
--- /dev/null
+++ b/clang/test/CodeGen/c-strings.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: grep "hello" %t | count 3
+// RUN: grep 'c"hello\\00"' %t | count 2
+// RUN: grep 'c"hello\\00\\00\\00"' %t | count 1
+// RUN: grep 'c"ola"' %t | count 1
+
+/* Should be 3 hello string, two global (of different sizes), the rest
+ are shared. */
+
+void f0() {
+ bar("hello");
+}
+
+void f1() {
+ static char *x = "hello";
+ bar(x);
+}
+
+void f2() {
+ static char x[] = "hello";
+ bar(x);
+}
+
+void f3() {
+ static char x[8] = "hello";
+ bar(x);
+}
+
+void f4() {
+ static struct s {
+ char *name;
+ } x = { "hello" };
+ gaz(&x);
+}
+
+char x[3] = "ola";
diff --git a/clang/test/CodeGen/call.c b/clang/test/CodeGen/call.c
new file mode 100644
index 0000000..ef32775
--- /dev/null
+++ b/clang/test/CodeGen/call.c
@@ -0,0 +1,39 @@
+// RUN: %clang %s -O0 -emit-llvm -S -o - | FileCheck %s
+
+// This should call rb_define_global_function, not rb_f_chop.
+void rb_define_global_function (const char*,void(*)(),int);
+static void rb_f_chop();
+void Init_String() {
+ rb_define_global_function("chop", rb_f_chop, 0);
+}
+static void rb_f_chop() {
+}
+
+// CHECK: call{{.*}}rb_define_global_function
+
+// PR10335
+typedef void (* JSErrorCallback)(void);
+void js_GetErrorMessage(void);
+void JS_ReportErrorNumber(JSErrorCallback errorCallback, ...);
+void Interpret() {
+ JS_ReportErrorNumber(js_GetErrorMessage, 0);
+
+ // CHECK: call void ({{.*}}, ...)* @JS_ReportErrorNumber({{.*}}@js_GetErrorMessage
+}
+
+
+
+
+// PR10337
+struct sigaction { int (*_sa_handler)(int); };
+typedef int SigHandler ();
+typedef struct sigaction sighandler_cxt;
+SigHandler *rl_set_sighandler(ohandler)
+sighandler_cxt *ohandler; {
+ return 0;
+}
+
+void rl_set_signals() {
+ SigHandler *oh;
+ oh = rl_set_sighandler(0);
+}
diff --git a/clang/test/CodeGen/capture-complex-expr-in-block.c b/clang/test/CodeGen/capture-complex-expr-in-block.c
new file mode 100644
index 0000000..9ce7570
--- /dev/null
+++ b/clang/test/CodeGen/capture-complex-expr-in-block.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10 | FileCheck %s
+// rdar://10033986
+
+typedef void (^BLOCK)(void);
+int main ()
+{
+ _Complex double c;
+ BLOCK b = ^() {
+ _Complex double z;
+ z = z + c;
+ };
+ b();
+}
+
+// CHECK: define internal void @__main_block_invoke_0
+// CHECK: [[C1:%.*]] = alloca { double, double }, align 8
+// CHECK: [[RP:%.*]] = getelementptr inbounds { double, double }* [[C1]], i32 0, i32 0
+// CHECK-NEXT: [[R:%.*]] = load double* [[RP]]
+// CHECK-NEXT: [[IP:%.*]] = getelementptr inbounds { double, double }* [[C1]], i32 0, i32 1
+// CHECK-NEXT: [[I:%.*]] = load double* [[IP]]
diff --git a/clang/test/CodeGen/cast-emit.c b/clang/test/CodeGen/cast-emit.c
new file mode 100644
index 0000000..4e33fa3
--- /dev/null
+++ b/clang/test/CodeGen/cast-emit.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+typedef union {
+ int i;
+ float f;
+} MyUnion;
+void unionf(MyUnion a);
+void uniontest(float a) {
+ f((MyUnion)1.0f);
+// CHECK: store float 1.000000e+00
+}
+
diff --git a/clang/test/CodeGen/cast.c b/clang/test/CodeGen/cast.c
new file mode 100644
index 0000000..5f340c5
--- /dev/null
+++ b/clang/test/CodeGen/cast.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+
+extern void go(const void *p);
+float v[2] = { 0.0, 1.0 };
+void foo(void) { go(v); }
+
diff --git a/clang/test/CodeGen/catch-undef-behavior.c b/clang/test/CodeGen/catch-undef-behavior.c
new file mode 100644
index 0000000..fef1587
--- /dev/null
+++ b/clang/test/CodeGen/catch-undef-behavior.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fcatch-undefined-behavior -emit-llvm-only %s
+
+// PR6805
+void foo() {
+ union { int i; } u;
+ u.i=1;
+}
diff --git a/clang/test/CodeGen/cfstring.c b/clang/test/CodeGen/cfstring.c
new file mode 100644
index 0000000..9d98b56
--- /dev/null
+++ b/clang/test/CodeGen/cfstring.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+// <rdar://problem/10657500>: Check that the backing store of CFStrings are
+// constant with the -fwritable-strings flag.
+//
+// RUN: %clang_cc1 -fwritable-strings -emit-llvm %s -o - | FileCheck %s
+//
+// CHECK: @.str = linker_private unnamed_addr constant [14 x i8] c"Hello, World!\00", align 1
+// CHECK: @.str1 = linker_private unnamed_addr constant [7 x i8] c"yo joe\00", align 1
+// CHECK: @.str3 = linker_private unnamed_addr constant [16 x i8] c"Goodbye, World!\00", align 1
+
+#define CFSTR __builtin___CFStringMakeConstantString
+
+void f() {
+ CFSTR("Hello, World!");
+}
+
+// rdar://6248329
+void *G = CFSTR("yo joe");
+
+void h() {
+ static void* h = CFSTR("Goodbye, World!");
+}
diff --git a/clang/test/CodeGen/cfstring2.c b/clang/test/CodeGen/cfstring2.c
new file mode 100644
index 0000000..c760f5d
--- /dev/null
+++ b/clang/test/CodeGen/cfstring2.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+typedef const struct __CFString * CFStringRef;
+
+#define CFSTR(x) (CFStringRef) __builtin___CFStringMakeConstantString (x)
+
+void f() {
+ CFSTR("Hello, World!");
+}
+
+// rdar://6151192
+void *G = CFSTR("yo joe");
+
diff --git a/clang/test/CodeGen/char-literal.c b/clang/test/CodeGen/char-literal.c
new file mode 100644
index 0000000..237d4b2
--- /dev/null
+++ b/clang/test/CodeGen/char-literal.c
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=C %s
+// RUN: %clang_cc1 -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=C %s
+// RUN: %clang_cc1 -x c++ -std=c++11 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CPP0X %s
+
+#include <stddef.h>
+
+int main() {
+ // CHECK-C: store i8 97
+ // CHECK-CPP0X: store i8 97
+ char a = 'a';
+
+ // Should truncate value (equal to last character).
+ // CHECK-C: store i8 98
+ // CHECK-CPP0X: store i8 98
+ char b = 'ab';
+
+ // Should get concatenated characters
+ // CHECK-C: store i32 24930
+ // CHECK-CPP0X: store i32 24930
+ int b1 = 'ab';
+
+ // Should get concatenated characters
+ // CHECK-C: store i32 808464432
+ // CHECK-CPP0X: store i32 808464432
+ int b2 = '0000';
+
+ // Should get truncated value (last four characters concatenated)
+ // CHECK-C: store i32 1919512167
+ // CHECK-CPP0X: store i32 1919512167
+ int b3 = 'somesillylongstring';
+
+ // CHECK-C: store i32 97
+ // CHECK-CPP0X: store i32 97
+ wchar_t wa = L'a';
+
+ // Should pick second character.
+ // CHECK-C: store i32 98
+ // CHECK-CPP0X: store i32 98
+ wchar_t wb = L'ab';
+
+#if __cplusplus >= 201103L
+ // CHECK-CPP0X: store i16 97
+ char16_t ua = u'a';
+
+ // CHECK-CPP0X: store i32 97
+ char32_t Ua = U'a';
+
+ // CHECK-CPP0X: store i16 1047
+ char16_t ua1 = u'З';
+ // CHECK-CPP0X: store i16 12538
+ char16_t ua2 = u'ヺ';
+ // CHECK-CPP0X: store i16 -27177
+ char16_t ua3 = u'闗';
+
+ // CHECK-CPP0X: store i32 181
+ char32_t Ua1 = U'µ';
+ // CHECK-CPP0X: store i32 38359
+ char32_t Ua2 = U'闗';
+ // CHECK-CPP0X: store i32 128128
+ char32_t Ua3 = U'💀';
+
+#endif
+
+ // CHECK-C: store i32 61451
+ // CHECK-CPP0X: store i32 61451
+ wchar_t wc = L'\uF00B';
+
+#if __cplusplus >= 201103L
+ // -4085 == 0xf00b
+ // CHECK-CPP0X: store i16 -4085
+ char16_t uc = u'\uF00B';
+
+ // CHECK-CPP0X: store i32 61451
+ char32_t Uc = U'\uF00B';
+#endif
+
+ // CHECK-C: store i32 1110027
+ // CHECK-CPP0X: store i32 1110027
+ wchar_t wd = L'\U0010F00B';
+
+#if __cplusplus >= 201103L
+ // CHECK-CPP0X: store i32 1110027
+ char32_t Ud = U'\U0010F00B';
+#endif
+
+ // Should pick second character.
+ // CHECK-C: store i32 1110027
+ // CHECK-CPP0X: store i32 1110027
+ wchar_t we = L'\u1234\U0010F00B';
+}
diff --git a/clang/test/CodeGen/cleanup-stack.c b/clang/test/CodeGen/cleanup-stack.c
new file mode 100644
index 0000000..72a1a6c
--- /dev/null
+++ b/clang/test/CodeGen/cleanup-stack.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O3 -emit-llvm %s -o %t
+// RUN: grep "ret i32 9" %t
+
+struct s0 {
+ int *var;
+ int addend;
+};
+
+static void f0(struct s0 *p) {
+ *p->var += p->addend;
+}
+
+int f1(void) {
+ int var = 0;
+
+ {
+ struct s0 x __attribute__((cleanup(f0))) = { &var, 2 };
+ struct s0 y __attribute__((cleanup(f0))) = { &var, 3 };
+ {
+ struct s0 y __attribute__((cleanup(f0))) = { &var, 4 };
+ }
+ }
+
+ return var;
+}
diff --git a/clang/test/CodeGen/complex-indirect.c b/clang/test/CodeGen/complex-indirect.c
new file mode 100644
index 0000000..0daa970
--- /dev/null
+++ b/clang/test/CodeGen/complex-indirect.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t -triple=x86_64-apple-darwin10
+// RUN: FileCheck < %t %s
+
+// Make sure this doesn't crash. We used to generate a byval here and wanted to
+// verify a valid alignment, but we now realize we can use an i16 and let the
+// backend guarantee the alignment.
+
+void a(int,int,int,int,int,int,__complex__ char);
+void b(__complex__ char *y) { a(0,0,0,0,0,0,*y); }
+// CHECK: define void @b
+// CHECK: alloca { i8, i8 }*, align 8
+// CHECK: call void @a(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i16 {{.*}})
diff --git a/clang/test/CodeGen/complex-init-list.c b/clang/test/CodeGen/complex-init-list.c
new file mode 100644
index 0000000..99c1c62
--- /dev/null
+++ b/clang/test/CodeGen/complex-init-list.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 | FileCheck %s
+
+// This file tests the clang extension which allows initializing the components
+// of a complex number individually using an initialization list. (There is a
+// extensive description and test in test/Sema/complex-init-list.c.)
+
+_Complex float x = { 1.0f, 1.0f/0.0f };
+// CHECK: @x = global { float, float } { float 1.000000e+00, float 0x7FF0000000000000 }, align 4
+
+_Complex float f(float x, float y) { _Complex float z = { x, y }; return z; }
+// CHECK: define <2 x float> @f
+// CHECK: alloca { float, float }
+// CHECK: alloca { float, float }
+
+_Complex float f2(float x, float y) { return (_Complex float){ x, y }; }
+// CHECK: define <2 x float> @f2
+// CHECK: alloca { float, float }
+// CHECK: alloca { float, float }
diff --git a/clang/test/CodeGen/complex.c b/clang/test/CodeGen/complex.c
new file mode 100644
index 0000000..1212660
--- /dev/null
+++ b/clang/test/CodeGen/complex.c
@@ -0,0 +1,99 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+
+int main(void)
+{
+ double _Complex a = 5;
+ double _Complex b = 42;
+
+ return a * b != b * a;
+}
+
+_Complex double bar(int);
+void test(_Complex double*);
+void takecomplex(_Complex double);
+
+void test2(int c) {
+ _Complex double X;
+ X = bar(1);
+ test(&X);
+ takecomplex(X);
+}
+
+_Complex double g1, g2;
+_Complex float cf;
+double D;
+
+void test3() {
+ g1 = g1 + g2;
+ g1 = g1 - g2;
+ g1 = g1 * g2;
+ g1 = +-~g1;
+
+ double Gr = __real g1;
+
+ cf += D;
+ // FIXME: Currently unsupported!
+ //D += cf;
+ cf /= g1;
+ g1 = g1 + D;
+ g1 = D + g1;
+}
+
+__complex__ int ci1, ci2;
+__complex__ short cs;
+int i;
+void test3int() {
+ ci1 = ci1 + ci2;
+ ci1 = ci1 - ci2;
+ ci1 = ci1 * ci2;
+ ci1 = +-~ci1;
+
+ i = __real ci1;
+
+ cs += i;
+ // FIXME: Currently unsupported!
+ //D += cf;
+ cs /= ci1;
+ ci1 = ci1 + i;
+ ci1 = i + ci1;
+}
+
+void t1() {
+ (__real__ cf) = 4.0;
+}
+
+void t2() {
+ (__imag__ cf) = 4.0;
+}
+
+// PR1960
+void t3() {
+ __complex__ long long v = 2;
+}
+
+// PR3131
+float _Complex t4();
+
+void t5() {
+ float _Complex x = t4();
+}
+
+void t6() {
+ g1++;
+ g1--;
+ ++g1;
+ --g1;
+ ci1++;
+ ci1--;
+ ++ci1;
+ --ci1;
+}
+
+// <rdar://problem/7958272>
+double t7(double _Complex c) {
+ return __builtin_fabs(__real__(c));
+}
+
+void t8() {
+ __complex__ int *x = &(__complex__ int){1};
+}
diff --git a/clang/test/CodeGen/compound-literal.c b/clang/test/CodeGen/compound-literal.c
new file mode 100644
index 0000000..969c5af
--- /dev/null
+++ b/clang/test/CodeGen/compound-literal.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+int* a = &(int){1};
+struct s {int a, b, c;} * b = &(struct s) {1, 2, 3};
+_Complex double * x = &(_Complex double){1.0f};
+typedef int v4i32 __attribute((vector_size(16)));
+v4i32 *y = &(v4i32){1,2,3,4};
+
+void xxx() {
+int* a = &(int){1};
+struct s {int a, b, c;} * b = &(struct s) {1, 2, 3};
+_Complex double * x = &(_Complex double){1.0f};
+}
+
+// CHECK: define void @f()
+void f() {
+ typedef struct S { int x,y; } S;
+ // CHECK: [[S:%[a-zA-Z0-9.]+]] = alloca [[STRUCT:%[a-zA-Z0-9.]+]],
+ struct S s;
+ // CHECK-NEXT: [[COMPOUNDLIT:%[a-zA-Z0-9.]+]] = alloca [[STRUCT]]
+ // CHECK-NEXT: [[CX:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[COMPOUNDLIT]], i32 0, i32 0
+ // CHECK-NEXT: [[SY:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[S]], i32 0, i32 1
+ // CHECK-NEXT: [[TMP:%[a-zA-Z0-9.]+]] = load i32* [[SY]]
+ // CHECK-NEXT: store i32 [[TMP]], i32* [[CX]]
+ // CHECK-NEXT: [[CY:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[COMPOUNDLIT]], i32 0, i32 1
+ // CHECK-NEXT: [[SX:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[S]], i32 0, i32 0
+ // CHECK-NEXT: [[TMP:%[a-zA-Z0-9.]+]] = load i32* [[SX]]
+ // CHECK-NEXT: store i32 [[TMP]], i32* [[CY]]
+ // CHECK-NEXT: [[SI8:%[a-zA-Z0-9.]+]] = bitcast [[STRUCT]]* [[S]] to i8*
+ // CHECK-NEXT: [[COMPOUNDLITI8:%[a-zA-Z0-9.]+]] = bitcast [[STRUCT]]* [[COMPOUNDLIT]] to i8*
+ // CHECK-NEXT: call void @llvm.memcpy{{.*}}(i8* [[SI8]], i8* [[COMPOUNDLITI8]]
+ s = (S){s.y,s.x};
+ // CHECK-NEXT: ret void
+}
diff --git a/clang/test/CodeGen/compound-type.c b/clang/test/CodeGen/compound-type.c
new file mode 100644
index 0000000..63ba694
--- /dev/null
+++ b/clang/test/CodeGen/compound-type.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 < %s -emit-llvm -triple i686-pc-linux-gnu > %t
+// RUN: grep "div i32" %t
+// RUN: grep "shl i32" %t
+
+unsigned char a,b;
+void c(void) {a <<= b;}
+void d(void) {a /= b;}
diff --git a/clang/test/CodeGen/compound.c b/clang/test/CodeGen/compound.c
new file mode 100644
index 0000000..960b2e8
--- /dev/null
+++ b/clang/test/CodeGen/compound.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 < %s -emit-llvm
+int A;
+long long B;
+int C;
+int *P;
+void test1() {
+ C = (A /= B);
+
+ P -= 4;
+
+ C = P - (P+10);
+}
+
+short x;
+void test2(char c) { x += c; }
+
+void foo(char *strbuf) {
+ int stufflen = 4;
+ strbuf += stufflen;
+}
+
+
+// Aggregate cast to void
+union uu { int a;}; void f(union uu p) { (void) p;}
+
diff --git a/clang/test/CodeGen/conditional-gnu-ext.c b/clang/test/CodeGen/conditional-gnu-ext.c
new file mode 100644
index 0000000..2e32d3a
--- /dev/null
+++ b/clang/test/CodeGen/conditional-gnu-ext.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+// PR1824
+
+int foo(int x, short y) {
+ return x ?: y;
+}
+
+// rdar://6586493
+float test(float x, int Y) {
+ return Y != 0 ? : x;
+}
+
+// rdar://8446940
+extern void abort();
+void test1 () {
+ char x[1];
+ char *y = x ? : 0;
+
+ if (x != y)
+ abort();
+}
+
+// rdar://8453812
+_Complex int getComplex(_Complex int val) {
+ static int count;
+ if (count++)
+ abort();
+ return val;
+}
+
+_Complex int complx() {
+ _Complex int cond;
+ _Complex int rhs;
+
+ return getComplex(1+2i) ? : rhs;
+}
diff --git a/clang/test/CodeGen/conditional.c b/clang/test/CodeGen/conditional.c
new file mode 100644
index 0000000..88538a2
--- /dev/null
+++ b/clang/test/CodeGen/conditional.c
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+float test1(int cond, float a, float b) {
+ return cond ? a : b;
+}
+
+double test2(int cond, float a, double b) {
+ return cond ? a : b;
+}
+
+void f();
+
+void test3(){
+ 1 ? f() : (void)0;
+}
+
+void test4() {
+ int i; short j;
+ float* k = 1 ? &i : &j;
+}
+
+void test5() {
+ const int* cip;
+ void* vp;
+ cip = 0 ? vp : cip;
+}
+
+void test6();
+void test7(int);
+void* test8() {return 1 ? test6 : test7;}
+
+
+void _efree(void *ptr);
+
+void _php_stream_free3() {
+ (1 ? free(0) : _efree(0));
+}
+
+void _php_stream_free4() {
+ 1 ? _efree(0) : free(0);
+}
+
+// PR5526
+struct test9 { int a; };
+void* test9spare();
+void test9(struct test9 *p) {
+ p ? p : test9spare();
+}
+
+// CHECK: @test10
+// CHECK: select i1 {{.*}}, i32 4, i32 5
+int test10(int c) {
+ return c ? 4 : 5;
+}
+enum { Gronk = 5 };
+
+// rdar://9289603
+// CHECK: @test11
+// CHECK: select i1 {{.*}}, i32 4, i32 5
+int test11(int c) {
+ return c ? 4 : Gronk;
+}
+
+// CHECK: @test12
+// CHECK: select i1 {{.*}}, double 4.0{{.*}}, double 2.0
+double test12(int c) {
+ return c ? 4.0 : 2.0;
+}
+// CHECK: @test13
+// CHECK: call {{.*}} @f2(
+int f2(void);
+void test13() {
+ f2() ? (void)0 : (void)0;
+}
diff --git a/clang/test/CodeGen/const-arithmetic.c b/clang/test/CodeGen/const-arithmetic.c
new file mode 100644
index 0000000..a28f73f
--- /dev/null
+++ b/clang/test/CodeGen/const-arithmetic.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @g1 = global [2 x i8*] [i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -2), i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -46)], align 16
+// CHECK: @g2 = global [2 x i8*] [i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -2), i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -46)], align 16
+
+extern struct { unsigned char a, b; } g0[];
+void *g1[] = {g0 + -1, g0 + -23 };
+void *g2[] = {g0 - 1, g0 - 23 };
diff --git a/clang/test/CodeGen/const-init.c b/clang/test/CodeGen/const-init.c
new file mode 100644
index 0000000..4f3f7ab
--- /dev/null
+++ b/clang/test/CodeGen/const-init.c
@@ -0,0 +1,146 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -ffreestanding -verify -emit-llvm -o - %s | FileCheck %s
+
+#include <stdint.h>
+
+// Brace-enclosed string array initializers
+char a[] = { "asdf" };
+// CHECK: @a = global [5 x i8] c"asdf\00"
+
+char a2[2][5] = { "asdf" };
+// CHECK: @a2 = global [2 x [5 x i8]] {{\[}}[5 x i8] c"asdf\00", [5 x i8] zeroinitializer]
+
+// Double-implicit-conversions of array/functions (not legal C, but
+// clang accepts it for gcc compat).
+intptr_t b = a; // expected-warning {{incompatible pointer to integer conversion}}
+int c();
+void *d = c;
+intptr_t e = c; // expected-warning {{incompatible pointer to integer conversion}}
+
+int f, *g = __extension__ &f, *h = (1 != 1) ? &f : &f;
+
+union s2 {
+ struct {
+ struct { } *f0;
+ } f0;
+};
+
+int g0 = (int)(&(((union s2 *) 0)->f0.f0) - 0);
+
+// CHECK: @g1x = global { double, double } { double 1.000000e+00{{[0]*}}, double 0.000000e+00{{[0]*}} }
+_Complex double g1x = 1.0f;
+// CHECK: @g1y = global { double, double } { double 0.000000e+00{{[0]*}}, double 1.000000e+00{{[0]*}} }
+_Complex double g1y = 1.0fi;
+// CHECK: @g1 = global { i8, i8 } { i8 1, i8 10 }
+_Complex char g1 = (char) 1 + (char) 10 * 1i;
+// CHECK: @g2 = global { i32, i32 } { i32 1, i32 10 }
+_Complex int g2 = 1 + 10i;
+// CHECK: @g3 = global { float, float } { float 1.000000e+00{{[0]*}}, float 1.000000e+0{{[0]*}}1 }
+_Complex float g3 = 1.0 + 10.0i;
+// CHECK: @g4 = global { double, double } { double 1.000000e+00{{[0]*}}, double 1.000000e+0{{[0]*}}1 }
+_Complex double g4 = 1.0 + 10.0i;
+// CHECK: @g5 = global { i32, i32 } zeroinitializer
+_Complex int g5 = (2 + 3i) == (5 + 7i);
+// CHECK: @g6 = global { double, double } { double -1.100000e+0{{[0]*}}1, double 2.900000e+0{{[0]*}}1 }
+_Complex double g6 = (2.0 + 3.0i) * (5.0 + 7.0i);
+// CHECK: @g7 = global i32 1
+int g7 = (2 + 3i) * (5 + 7i) == (-11 + 29i);
+// CHECK: @g8 = global i32 1
+int g8 = (2.0 + 3.0i) * (5.0 + 7.0i) == (-11.0 + 29.0i);
+// CHECK: @g9 = global i32 0
+int g9 = (2 + 3i) * (5 + 7i) != (-11 + 29i);
+// CHECK: @g10 = global i32 0
+int g10 = (2.0 + 3.0i) * (5.0 + 7.0i) != (-11.0 + 29.0i);
+
+// PR5108
+// CHECK: @gv1 = global %struct.anon <{ i32 0, i8 7 }>, align 1
+struct {
+ unsigned long a;
+ unsigned long b:3;
+} __attribute__((__packed__)) gv1 = { .a = 0x0, .b = 7, };
+
+// PR5118
+// CHECK: @gv2 = global %struct.anon.0 <{ i8 1, i8* null }>, align 1
+struct {
+ unsigned char a;
+ char *b;
+} __attribute__((__packed__)) gv2 = { 1, (void*)0 };
+
+// Global references
+// CHECK: @g11.l0 = internal global i32 ptrtoint (i32 ()* @g11 to i32)
+long g11() {
+ static long l0 = (long) g11;
+ return l0;
+}
+
+// CHECK: @g12 = global i32 ptrtoint (i8* @g12_tmp to i32)
+static char g12_tmp;
+long g12 = (long) &g12_tmp;
+
+// CHECK: @g13 = global [1 x %struct.g13_s0] [%struct.g13_s0 { i32 ptrtoint (i8* @g12_tmp to i32) }]
+struct g13_s0 {
+ long a;
+};
+struct g13_s0 g13[] = {
+ { (long) &g12_tmp }
+};
+
+// CHECK: @g14 = global i8* inttoptr (i64 100 to i8*)
+void *g14 = (void*) 100;
+
+// CHECK: @g15 = global i32 -1
+int g15 = (int) (char) ((void*) 0 + 255);
+
+// CHECK: @g16 = global i64 4294967295
+long long g16 = (long long) ((void*) 0xFFFFFFFF);
+
+// CHECK: @g17 = global i32* @g15
+int *g17 = (int *) ((long) &g15);
+
+// CHECK: @g18.p = internal global [1 x i32*] [i32* @g19]
+void g18(void) {
+ extern int g19;
+ static int *p[] = { &g19 };
+}
+
+// CHECK: @g20.l0 = internal global %struct.g20_s1 { %struct.g20_s0* null, %struct.g20_s0** getelementptr inbounds (%struct.g20_s1* @g20.l0, i32 0, i32 0) }
+struct g20_s0;
+struct g20_s1 {
+ struct g20_s0 *f0, **f1;
+};
+void *g20(void) {
+ static struct g20_s1 l0 = { ((void*) 0), &l0.f0 };
+ return l0.f1;
+}
+
+// PR4108
+struct g21 {int g21;};
+const struct g21 g21 = (struct g21){1};
+
+// PR5474
+struct g22 {int x;} __attribute((packed));
+struct g23 {char a; short b; char c; struct g22 d;};
+struct g23 g24 = {1,2,3,4};
+
+// CHECK: @g25.g26 = internal global i8* getelementptr inbounds ([4 x i8]* @__func__.g25, i32 0, i32 0)
+// CHECK: @__func__.g25 = private unnamed_addr constant [4 x i8] c"g25\00"
+int g25() {
+ static const char *g26 = __func__;
+ return *g26;
+}
+
+// CHECK: @g27.x = internal global i8* bitcast (i8** @g27.x to i8*), align 4
+void g27() { // PR8073
+ static void *x = &x;
+}
+
+void g28() {
+ typedef long long v1i64 __attribute((vector_size(8)));
+ typedef short v12i16 __attribute((vector_size(24)));
+ typedef long double v2f80 __attribute((vector_size(24)));
+ // CHECK: @g28.a = internal global <1 x i64> <i64 10>
+ // CHECK: @g28.b = internal global <12 x i16> <i16 0, i16 0, i16 0, i16 -32768, i16 16383, i16 0, i16 0, i16 0, i16 0, i16 -32768, i16 16384, i16 0>
+ // CHECK: @g28.c = internal global <2 x x86_fp80> <x86_fp80 0xK3FFF8000000000000000, x86_fp80 0xK40008000000000000000>, align 32
+ static v1i64 a = (v1i64)10LL;
+ static v12i16 b = (v2f80){1,2};
+ static v2f80 c = (v12i16){0,0,0,-32768,16383,0,0,0,0,-32768,16384,0};
+}
diff --git a/clang/test/CodeGen/const-label-addr.c b/clang/test/CodeGen/const-label-addr.c
new file mode 100644
index 0000000..9d99f88
--- /dev/null
+++ b/clang/test/CodeGen/const-label-addr.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+int a() {
+A:;static void* a = &&A;
+}
diff --git a/clang/test/CodeGen/const-unordered-compare.c b/clang/test/CodeGen/const-unordered-compare.c
new file mode 100644
index 0000000..ffd04db
--- /dev/null
+++ b/clang/test/CodeGen/const-unordered-compare.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+// Checks folding of an unordered comparison
+int nan_ne_check() {
+ // CHECK: ret i32 1
+ return (__builtin_nanf("") != __builtin_nanf("")) ? 1 : 0;
+}
diff --git a/clang/test/CodeGen/constant-comparison.c b/clang/test/CodeGen/constant-comparison.c
new file mode 100644
index 0000000..371cb17
--- /dev/null
+++ b/clang/test/CodeGen/constant-comparison.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - 2>&1 | not grep warning
+// RUN: %clang_cc1 -emit-llvm %s -o - | grep @b | count 1
+
+int a, b;
+int *c1 = 1 < 2 ? &a : &b;
+int *c2 = 3 != 3LL ? &b : &a;
+int *c3 = !(3 <= 4.0) ? &b : &a;
+int *c4 = &a - (6 * 5 > 30);
+int *c5 = &a + (6 * 5 >= 30);
+int c6 = 44 < 33;
+
+
diff --git a/clang/test/CodeGen/constructor-attribute.c b/clang/test/CodeGen/constructor-attribute.c
new file mode 100644
index 0000000..a1f0e60
--- /dev/null
+++ b/clang/test/CodeGen/constructor-attribute.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: grep -e "global_ctors.*@A" %t
+// RUN: grep -e "global_dtors.*@B" %t
+// RUN: grep -e "global_ctors.*@C" %t
+// RUN: grep -e "global_dtors.*@D" %t
+
+int printf(const char *, ...);
+
+void A() __attribute__((constructor));
+void B() __attribute__((destructor));
+
+void A() {
+ printf("A\n");
+}
+
+void B() {
+ printf("B\n");
+}
+
+static void C() __attribute__((constructor));
+
+static void D() __attribute__((destructor));
+
+static int foo() {
+ return 10;
+}
+
+static void C() {
+ printf("A: %d\n", foo());
+}
+
+static void D() {
+ printf("B\n");
+}
+
+int main() {
+ return 0;
+}
diff --git a/clang/test/CodeGen/count-builtins.c b/clang/test/CodeGen/count-builtins.c
new file mode 100644
index 0000000..e6133c5
--- /dev/null
+++ b/clang/test/CodeGen/count-builtins.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+int leading, trailing, pop;
+
+void test_i16(short P) {
+ leading = __builtin_clzs(P);
+ trailing = __builtin_ctzs(P);
+
+// CHECK: @test_i16
+// CHECK: call i16 @llvm.ctlz.i16
+// CHECK: call i16 @llvm.cttz.i16
+}
+
+void test_i32(int P) {
+ leading = __builtin_clz(P);
+ trailing = __builtin_ctz(P);
+ pop = __builtin_popcount(P);
+
+// CHECK: @test_i32
+// CHECK: call i32 @llvm.ctlz.i32
+// CHECK: call i32 @llvm.cttz.i32
+// CHECK: call i32 @llvm.ctpop.i32
+}
+
+void test_i64(float P) {
+ leading = __builtin_clzll(P);
+ trailing = __builtin_ctzll(P);
+ pop = __builtin_popcountll(P);
+// CHECK: @test_i64
+// CHECK: call i64 @llvm.ctlz.i64
+// CHECK: call i64 @llvm.cttz.i64
+// CHECK: call i64 @llvm.ctpop.i64
+}
diff --git a/clang/test/CodeGen/cxx-condition.cpp b/clang/test/CodeGen/cxx-condition.cpp
new file mode 100644
index 0000000..5aa0c5e
--- /dev/null
+++ b/clang/test/CodeGen/cxx-condition.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+void f() {
+ int a;
+ if (int x=a) ++a; else a=x;
+ while (int x=a) ++a;
+ for (; int x=a; --a) ;
+ switch (int x=0) { }
+}
diff --git a/clang/test/CodeGen/cxx-default-arg.cpp b/clang/test/CodeGen/cxx-default-arg.cpp
new file mode 100644
index 0000000..25b7c10
--- /dev/null
+++ b/clang/test/CodeGen/cxx-default-arg.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+// Note: define CLANG_GENERATE_KNOWN_GOOD and compile to generate code
+// that makes all of the defaulted arguments explicit. The resulting
+// byte code should be identical to the compilation without
+// CLANG_GENERATE_KNOWN_GOOD.
+#ifdef CLANG_GENERATE_KNOWN_GOOD
+# define DEFARG(...) __VA_ARGS__
+#else
+# define DEFARG(...)
+#endif
+
+extern int x;
+struct S { float x; float y; } s;
+double _Complex c;
+
+void f(int i = 0, int j = 1, int k = x, struct S t = s, double _Complex d = c);
+
+void g() {
+ f(0, 1, x, s DEFARG(, c));
+ f(0, 1, x DEFARG(, s, c));
+ f(0, 1 DEFARG(, x, s, c));
+ f(0 DEFARG(, 1, x, s, c));
+ f(DEFARG(0, 1, x, s, c));
+}
diff --git a/clang/test/CodeGen/cxx-value-init.cpp b/clang/test/CodeGen/cxx-value-init.cpp
new file mode 100644
index 0000000..6e4cc03
--- /dev/null
+++ b/clang/test/CodeGen/cxx-value-init.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+enum E {};
+int v1 = E();
+float v2 = float();
+
+void f() {
+ int v3 = int();
+ _Complex int v4 = typeof(_Complex int)();
+ _Complex float v5 = typeof(_Complex float)();
+}
diff --git a/clang/test/CodeGen/darwin-string-literals.c b/clang/test/CodeGen/darwin-string-literals.c
new file mode 100644
index 0000000..968386a
--- /dev/null
+++ b/clang/test/CodeGen/darwin-string-literals.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix LSB %s
+
+// CHECK-LSB: @.str = private unnamed_addr constant [8 x i8] c"string0\00"
+// CHECK-LSB: @.str1 = linker_private unnamed_addr constant [8 x i8] c"string1\00"
+// CHECK-LSB: @.str2 = internal unnamed_addr constant [18 x i16] [i16 104, i16 101, i16 108, i16 108, i16 111, i16 32, i16 8594, i16 32, i16 9731, i16 32, i16 8592, i16 32, i16 119, i16 111, i16 114, i16 108, i16 100, i16 0], align 2
+// CHECK-LSB: @.str4 = internal unnamed_addr constant [6 x i16] [i16 116, i16 101, i16 115, i16 116, i16 8482, i16 0], align 2
+
+
+// RUN: %clang_cc1 -triple powerpc-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix MSB %s
+
+// CHECK-MSB: @.str = private unnamed_addr constant [8 x i8] c"string0\00"
+// CHECK-MSB: @.str1 = linker_private unnamed_addr constant [8 x i8] c"string1\00"
+// CHECK-MSB: @.str2 = internal unnamed_addr constant [18 x i16] [i16 104, i16 101, i16 108, i16 108, i16 111, i16 32, i16 8594, i16 32, i16 9731, i16 32, i16 8592, i16 32, i16 119, i16 111, i16 114, i16 108, i16 100, i16 0], align 2
+// CHECK-MSB: @.str4 = internal unnamed_addr constant [6 x i16] [i16 116, i16 101, i16 115, i16 116, i16 8482, i16 0], align 2
+
+const char *g0 = "string0";
+const void *g1 = __builtin___CFStringMakeConstantString("string1");
+const void *g2 = __builtin___CFStringMakeConstantString("hello \u2192 \u2603 \u2190 world");
+const void *g3 = __builtin___CFStringMakeConstantString("test™");
diff --git a/clang/test/CodeGen/darwin-thread-specifier.c b/clang/test/CodeGen/darwin-thread-specifier.c
new file mode 100644
index 0000000..605d461
--- /dev/null
+++ b/clang/test/CodeGen/darwin-thread-specifier.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 -emit-llvm -o - %s | FileCheck %s
+// CHECK: @b = thread_local global i32 5, align 4
+__thread int b = 5;
diff --git a/clang/test/CodeGen/debug-dead-local-var.c b/clang/test/CodeGen/debug-dead-local-var.c
new file mode 100644
index 0000000..f9ca8f2
--- /dev/null
+++ b/clang/test/CodeGen/debug-dead-local-var.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -mllvm -asm-verbose -S -O2 -g %s -o - | FileCheck %s
+// Radar 8122864
+
+// Code is not generated for function foo, but preserve type information of
+// local variable xyz.
+static void foo() {
+// CHECK: DW_TAG_structure_type
+ struct X { int a; int b; } xyz;
+}
+
+int bar() {
+ foo();
+ return 1;
+}
diff --git a/clang/test/CodeGen/debug-info-args.c b/clang/test/CodeGen/debug-info-args.c
new file mode 100644
index 0000000..1d4ea10
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-args.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-unk-unk -o - -emit-llvm -g %s | FileCheck %s
+
+int somefunc(char *x, int y, double z) {
+
+ // CHECK: {{.*metadata !8, i32 0, i32 0}.*DW_TAG_subroutine_type}}
+ // CHECK: {{!8 = .*metadata ![^,]*, metadata ![^,]*, metadata ![^,]*, metadata ![^,]*}}
+
+ return y;
+}
diff --git a/clang/test/CodeGen/debug-info-block.c b/clang/test/CodeGen/debug-info-block.c
new file mode 100644
index 0000000..403e4aa
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-block.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fblocks -g -emit-llvm -o - %s | FileCheck %s
+// APPLE LOCAL file 5939894 */
+// Verify that the desired debugging type is generated for a structure
+// member that is a pointer to a block.
+
+// CHECK: __block_literal_generic{{.*}}DW_TAG_structure_type
+// CHECK: __block_descriptor{{.*}}DW_TAG_structure_type
+struct inStruct {
+ void (^genericBlockPtr)();
+} is;
+
diff --git a/clang/test/CodeGen/debug-info-compilation-dir.c b/clang/test/CodeGen/debug-info-compilation-dir.c
new file mode 100644
index 0000000..4b47299
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-compilation-dir.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fdebug-compilation-dir /nonsense -emit-llvm -g %s -o - | FileCheck -check-prefix=CHECK-NONSENSE %s
+// CHECK-NONSENSE: nonsense
+
+// RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck -check-prefix=CHECK-DIR %s
+// CHECK-DIR: CodeGen
+
diff --git a/clang/test/CodeGen/debug-info-crash.c b/clang/test/CodeGen/debug-info-crash.c
new file mode 100644
index 0000000..f04548b
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-crash.c
@@ -0,0 +1,31 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -fblocks -g -S %s -o -
+
+// rdar://7590323
+typedef struct dispatch_queue_s *dispatch_queue_t;
+__attribute__((visibility("default")))
+extern struct dispatch_queue_s _dispatch_main_q;
+typedef struct dispatch_item_s *dispatch_item_t;
+typedef void (^dispatch_legacy_block_t)(dispatch_item_t);
+dispatch_item_t LEGACY_dispatch_call(dispatch_queue_t dq,
+ dispatch_legacy_block_t dispatch_block,
+ dispatch_legacy_block_t callback_block) {
+ dispatch_queue_t lq = _dispatch_queue_get_current() ?: (&_dispatch_main_q);
+ dispatch_async(dq, ^{
+ if (callback_block) {
+ dispatch_async(lq, ^{
+ }
+ );
+ }
+ }
+ );
+}
+
+// radar://9008853
+typedef struct P {
+ int x;
+} PS;
+# 1 ""
+void foo() {
+ PS p2;
+}
diff --git a/clang/test/CodeGen/debug-info-enum.c b/clang/test/CodeGen/debug-info-enum.c
new file mode 100644
index 0000000..b4a1ce0
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-enum.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm -g %s -o %t
+// RUN: grep DW_TAG_enumeration_type %t
+// Radar 8195980
+
+enum vtag {
+ VT_ONE
+};
+
+int foo(int i) {
+ return i == VT_ONE;
+}
diff --git a/clang/test/CodeGen/debug-info-iv.c b/clang/test/CodeGen/debug-info-iv.c
new file mode 100644
index 0000000..6684fe3
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-iv.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -Os -S -g -o - %s | FileCheck %s
+// REQUIRES: x86-registered-target
+
+int calculate(int);
+static void test_indvars(int *Array1, int Array2[100][200]) {
+ unsigned i, j;
+ Array1[1] = Array2[3][6] = 12345;
+
+ for (i = 0; i < 100; i+=2)
+ Array1[i] = i; /* Step by non unit amount */
+
+ for (i = 3; i < 103; i++)
+ Array1[i] = i+4; /* Step with an offset */
+
+ for (i = 13; i < 100; i++)
+ for (j = 0; j < 100; j+=3) /* 2d array access */
+ Array2[i][j/3] = Array2[i][i];
+}
+
+
+int main() {
+ int Array[100][200], i, j;
+ double sum = 0.0;
+
+ for (i=0; i < 100; i+=2)
+ for (j=0; j < 200; j++)
+ Array[i][j] = 0;
+ test_indvars(Array[0], Array);
+
+//CHECK: .loc 2 31 8
+ for (i=0; i < 100; i+=2)
+ for (j=0; j < 200; j++)
+ sum += Array[i][j];
+
+ return calculate(sum);
+}
diff --git a/clang/test/CodeGen/debug-info-line.c b/clang/test/CodeGen/debug-info-line.c
new file mode 100644
index 0000000..9e6e971
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-line.c
@@ -0,0 +1,23 @@
+// RUN: %clang -emit-llvm -S -g %s -o - | FileCheck %s
+
+// Radar 8396182
+// There is only one lexical block, but we need a DILexicalBlock and two
+// DILexicalBlockFile to correctly represent file info. This means we have
+// two lexical blocks shown as the latter is also tagged as a lexical block.
+
+int foo() {
+ int i = 1;
+# 4 "m.c"
+# 1 "m.h" 1
+ int j = 2;
+# 2 "m.h"
+# 5 "m.c" 2
+ return i + j;
+}
+
+// CHECK: DW_TAG_lexical_block
+// CHECK: DW_TAG_lexical_block
+// CHECK: !"m.h"
+// CHECK: DW_TAG_lexical_block
+// CHECK: !"m.c"
+// CHECK-NOT: DW_TAG_lexical_block
diff --git a/clang/test/CodeGen/debug-info-line2.c b/clang/test/CodeGen/debug-info-line2.c
new file mode 100644
index 0000000..b5eba8a
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-line2.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-darwin-apple -g -emit-llvm -o - %s | FileCheck %s
+// Radar 9199234
+
+int bar();
+int foo(int i) {
+ int j = 0;
+ if (i) {
+ j = bar();
+//CHECK: store i32
+//CHECK-NOT: br label %{{%[a-zA-Z0-9\.]+}}, !dbg
+ }
+ else
+ {
+ j = bar() + 2;
+ }
+ return j;
+}
diff --git a/clang/test/CodeGen/debug-info-line3.c b/clang/test/CodeGen/debug-info-line3.c
new file mode 100644
index 0000000..645ffb9
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-line3.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -g -S -emit-llvm %s -o - | FileCheck %s
+
+void func(char c, char* d)
+{
+ *d = c + 1;
+ return;
+
+
+
+
+
+
+}
+
+// CHECK: ret void, !dbg !19
+// CHECK: !19 = metadata !{i32 6,
diff --git a/clang/test/CodeGen/debug-info-member.c b/clang/test/CodeGen/debug-info-member.c
new file mode 100644
index 0000000..43d26f8
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-member.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-llvm -g < %s | grep DW_TAG_member
+
+struct A { int x; } a;
diff --git a/clang/test/CodeGen/debug-info-scope.c b/clang/test/CodeGen/debug-info-scope.c
new file mode 100644
index 0000000..6051e6e
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-scope.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -g -emit-llvm < %s | FileCheck %s
+// Two variables with same name in separate scope.
+// Radar 8330217.
+int main() {
+ int j = 0;
+ int k = 0;
+// CHECK: DW_TAG_auto_variable
+// CHECK-NEXT: DW_TAG_lexical_block
+ for (int i = 0; i < 10; i++)
+ j++;
+ for (int i = 0; i < 10; i++)
+ k++;
+ return 0;
+}
diff --git a/clang/test/CodeGen/debug-info-static.c b/clang/test/CodeGen/debug-info-static.c
new file mode 100644
index 0000000..e75d20f
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-static.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -g -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: xyzzy} ; [ DW_TAG_variable ]
+void f(void)
+{
+ static int xyzzy;
+ xyzzy += 3;
+}
diff --git a/clang/test/CodeGen/debug-info-var-location.c b/clang/test/CodeGen/debug-info-var-location.c
new file mode 100644
index 0000000..12edb08
--- /dev/null
+++ b/clang/test/CodeGen/debug-info-var-location.c
@@ -0,0 +1,21 @@
+// RUN: %clang -S -g -fverbose-asm %s -o - | FileCheck %s
+// Radar 8461032
+// CHECK: DW_AT_location
+// CHECK-NEXT: byte 145
+
+// 145 is DW_OP_fbreg
+struct s {
+ int a;
+ struct s *next;
+};
+
+int foo(struct s *s) {
+ switch (s->a) {
+ case 1:
+ case 2: {
+ struct s *sp = s->next;
+ }
+ break;
+ }
+ return 1;
+}
diff --git a/clang/test/CodeGen/debug-info.c b/clang/test/CodeGen/debug-info.c
new file mode 100644
index 0000000..af2ce96
--- /dev/null
+++ b/clang/test/CodeGen/debug-info.c
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -triple x86_64-unk-unk -o %t -emit-llvm -g %s
+// RUN: FileCheck --input-file=%t %s
+
+// PR3023
+void convert(void) {
+ struct { typeof(0) f0; } v0;
+}
+
+
+// PR2784
+struct OPAQUE;
+typedef struct OPAQUE *PTR;
+PTR p;
+
+
+// PR2950
+struct s0;
+struct s0 { struct s0 *p; } g0;
+
+struct s0 *f0(struct s0 *a0) {
+ return a0->p;
+}
+
+
+// PR3134
+char xpto[];
+
+
+// PR3427
+struct foo {
+ int a;
+ void *ptrs[];
+};
+struct foo bar;
+
+
+// PR4143
+struct foo2 {
+ enum bar *bar;
+};
+
+struct foo2 foo2;
+
+
+// Radar 7325611
+// CHECK: "barfoo"
+typedef int barfoo;
+barfoo foo() {
+}
+
+// CHECK: __uint128_t
+__uint128_t foo128 ()
+{
+ __uint128_t int128 = 44;
+ return int128;
+}
+
+// CHECK: uint64x2_t
+typedef unsigned long long uint64_t;
+typedef uint64_t uint64x2_t __attribute__((ext_vector_type(2)));
+uint64x2_t extvectbar[4];
diff --git a/clang/test/CodeGen/debug-line-1.c b/clang/test/CodeGen/debug-line-1.c
new file mode 100644
index 0000000..00d4f42
--- /dev/null
+++ b/clang/test/CodeGen/debug-line-1.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -o - -emit-llvm -g %s | FileCheck %s
+// REQUIRES: asserts
+// PR9796
+
+// Check to make sure that we emit the block for the break so that we can count the line.
+// CHECK: sw.bb: ; preds = %entry
+// CHECK: br label %sw.epilog, !dbg !21
+
+extern int atoi(const char *);
+
+int f(char* arg) {
+ int x = atoi(arg);
+
+ switch(x) {
+ case 1:
+ break;
+ }
+
+ return 0;
+}
diff --git a/clang/test/CodeGen/decl-in-prototype.c b/clang/test/CodeGen/decl-in-prototype.c
new file mode 100644
index 0000000..949793d
--- /dev/null
+++ b/clang/test/CodeGen/decl-in-prototype.c
@@ -0,0 +1,21 @@
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck %s
+
+const int AA = 5;
+
+// CHECK: define i32 @f1
+int f1(enum {AA,BB} E) {
+ // CHECK: ret i32 1
+ return BB;
+}
+
+// CHECK: define i32 @f2
+int f2(enum {AA=7,BB} E) {
+ // CHECK: ret i32 7
+ return AA;
+}
+
+// Check nested function declarators work.
+int f(void (*g)(), enum {AA,BB} h) {
+ // CHECK: ret i32 0
+ return AA;
+}
diff --git a/clang/test/CodeGen/decl.c b/clang/test/CodeGen/decl.c
new file mode 100644
index 0000000..2065e33
--- /dev/null
+++ b/clang/test/CodeGen/decl.c
@@ -0,0 +1,119 @@
+// RUN: %clang_cc1 -w -emit-llvm < %s | FileCheck %s
+
+// CHECK: @test1.x = internal constant [12 x i32] [i32 1
+// CHECK: @test2.x = private unnamed_addr constant [13 x i32] [i32 1,
+// CHECK: @test5w = global { i32, [4 x i8] } { i32 2, [4 x i8] undef }
+// CHECK: @test5y = global { double } { double 7.300000e+0{{[0]*}}1 }
+
+// CHECK: @test6.x = private unnamed_addr constant %struct.SelectDest { i8 1, i8 2, i32 3, i32 0 }
+
+// CHECK: @test7 = global [2 x %struct.test7s] [%struct.test7s { i32 1, i32 2 }, %struct.test7s { i32 4, i32 0 }]
+
+void test1() {
+ // This should codegen as a "@test1.x" global.
+ const int x[] = { 1, 2, 3, 4, 6, 8, 9, 10, 123, 231, 123,23 };
+ foo(x);
+
+// CHECK: @test1()
+// CHECK: {{call.*@foo.*@test1.x}}
+}
+
+
+// rdar://7346691
+void test2() {
+ // This should codegen as a "@test2.x" global + memcpy.
+ int x[] = { 1, 2, 3, 4, 6, 8, 9, 10, 123, 231, 123,23, 24 };
+ foo(x);
+
+ // CHECK: @test2()
+ // CHECK: %x = alloca [13 x i32]
+ // CHECK: call void @llvm.memcpy
+ // CHECK: call{{.*}}@foo{{.*}}i32* %
+}
+
+
+void test3() {
+ // This should codegen as a memset.
+ int x[100] = { 0 };
+ foo(x);
+
+ // CHECK: @test3()
+ // CHECK: %x = alloca [100 x i32]
+ // CHECK: call void @llvm.memset
+}
+
+void test4(void) {
+ char a[10] = "asdf";
+ char b[10] = { "asdf" };
+ // CHECK: @test4()
+ // CHECK: %a = alloca [10 x i8]
+ // CHECK: %b = alloca [10 x i8]
+ // CHECK: call void @llvm.memcpy
+ // CHECK: call void @llvm.memcpy
+}
+
+
+union test5u { int i; double d; };
+
+void test5() {
+ union test5u ola = (union test5u) 351;
+ union test5u olb = (union test5u) 1.0;
+}
+
+union test5u test5w = (union test5u)2;
+union test5u test5y = (union test5u)73.0;
+
+
+
+// PR6660 - sqlite miscompile
+struct SelectDest {
+ unsigned char eDest;
+ unsigned char affinity;
+ int iParm;
+ int iMem;
+};
+
+void test6() {
+ struct SelectDest x = {1, 2, 3};
+ test6f(&x);
+}
+
+// rdar://7657600
+struct test7s { int a; int b; } test7[] = {
+ {1, 2},
+ {4},
+};
+
+// rdar://7872531
+#pragma pack(push, 2)
+struct test8s { int f0; char f1; } test8g = {};
+
+
+// PR7519
+
+struct S {
+ void (*x) (struct S *);
+};
+
+extern struct S *global_dc;
+void cp_diagnostic_starter(struct S *);
+
+void init_error(void) {
+ global_dc->x = cp_diagnostic_starter;
+}
+
+
+
+// rdar://8147692 - ABI crash in recursive struct-through-function-pointer.
+typedef struct {
+ int x5a;
+} x5;
+
+typedef struct x2 *x0;
+typedef long (*x1)(x0 x0a, x5 x6);
+struct x2 {
+ x1 x4;
+};
+long x3(x0 x0a, x5 a) {
+ return x0a->x4(x0a, a);
+}
diff --git a/clang/test/CodeGen/designated-initializers.c b/clang/test/CodeGen/designated-initializers.c
new file mode 100644
index 0000000..6561ce5
--- /dev/null
+++ b/clang/test/CodeGen/designated-initializers.c
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+
+struct foo {
+ void *a;
+ int b;
+};
+
+// CHECK: @u = global %union.anon zeroinitializer
+union { int i; float f; } u = { };
+
+// CHECK: @u2 = global { i32, [4 x i8] } { i32 0, [4 x i8] undef }
+union { int i; double f; } u2 = { };
+
+// CHECK: @u3 = global %union.anon.1 zeroinitializer
+union { double f; int i; } u3 = { };
+
+// CHECK: @b = global [2 x i32] [i32 0, i32 22]
+int b[2] = {
+ [1] = 22
+};
+
+// PR6955
+
+struct ds {
+ struct {
+ struct {
+ short a;
+ };
+ short b;
+ struct {
+ short c;
+ };
+ };
+};
+
+// Traditional C anonymous member init
+struct ds ds0 = { { { .a = 0 } } };
+// C1X lookup-based anonymous member init cases
+struct ds ds1 = { { .a = 1 } };
+struct ds ds2 = { { .b = 1 } };
+struct ds ds3 = { .a = 0 };
+// CHECK: @ds4 = global %struct.ds { %struct.anon.3 { %struct.anon zeroinitializer, i16 0, %struct.anon.2 { i16 1 } } }
+struct ds ds4 = { .c = 1 };
+struct ds ds5 = { { { .a = 0 } }, .b = 1 };
+struct ds ds6 = { { .a = 0, .b = 1 } };
+// CHECK: @ds7 = global %struct.ds { %struct.anon.3 { %struct.anon { i16 2 }, i16 3, %struct.anon.2 zeroinitializer } }
+struct ds ds7 = {
+ { {
+ .a = 1
+ } },
+ .a = 2,
+ .b = 3
+};
+
+void test1(int argc, char **argv)
+{
+ // CHECK: internal global %struct.foo { i8* null, i32 1024 }
+ static struct foo foo = {
+ .b = 1024,
+ };
+
+ // CHECK: bitcast %union.anon.4* %u2
+ // CHECK: call void @llvm.memset
+ union { int i; float f; } u2 = { };
+
+ // CHECK-NOT: call void @llvm.memset
+ union { int i; float f; } u3;
+
+ // CHECK: ret void
+}
+
+
+// PR7151
+struct S {
+ int nkeys;
+ int *keys;
+ union {
+ void *data;
+ };
+};
+
+void test2() {
+ struct S *btkr;
+
+ *btkr = (struct S) {
+ .keys = 0,
+ { .data = 0 },
+ };
+}
diff --git a/clang/test/CodeGen/dllimport-dllexport.c b/clang/test/CodeGen/dllimport-dllexport.c
new file mode 100644
index 0000000..c187503
--- /dev/null
+++ b/clang/test/CodeGen/dllimport-dllexport.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple i386-mingw32 -emit-llvm < %s | FileCheck %s
+
+void __attribute__((dllimport)) foo1();
+void __attribute__((dllexport)) foo1(){}
+// CHECK: define dllexport void @foo1
+void __attribute__((dllexport)) foo2();
+
+// PR6269
+__declspec(dllimport) void foo3();
+__declspec(dllexport) void foo3(){}
+// CHECK: define dllexport void @foo3
+__declspec(dllexport) void foo4();
diff --git a/clang/test/CodeGen/dostmt.c b/clang/test/CodeGen/dostmt.c
new file mode 100644
index 0000000..1a2e02a
--- /dev/null
+++ b/clang/test/CodeGen/dostmt.c
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+int bar();
+int test0() {
+ int i;
+ i = 1 + 2;
+ do {
+ i = bar();
+ i = bar();
+ } while(0);
+ return i;
+}
+
+
+int test1() {
+ int i;
+ i = 1 + 2;
+ do {
+ i = bar();
+ if (i == 42)
+ break;
+ i = bar();
+ } while(1);
+ return i;
+}
+
+
+int test2() {
+ int i;
+ i = 1 + 2;
+ do {
+ i = bar();
+ if (i == 42)
+ continue;
+ i = bar();
+ } while(1);
+ return i;
+}
+
+
+int test3() {
+ int i;
+ i = 1 + 2;
+ do {
+ i = bar();
+ if (i == 42)
+ break;
+ } while(0);
+ return i;
+}
+
+
+int test4() {
+ int i;
+ i = 1 + 2;
+ do {
+ i = bar();
+ if (i == 42)
+ continue;
+ } while(0);
+ return i;
+}
+
+// rdar://6103124
+void test5() {
+ do { break; } while(0);
+}
+
+
+
diff --git a/clang/test/CodeGen/emit-all-decls.c b/clang/test/CodeGen/emit-all-decls.c
new file mode 100644
index 0000000..deeb573
--- /dev/null
+++ b/clang/test/CodeGen/emit-all-decls.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: not grep "@foo" %t
+// RUN: %clang_cc1 -femit-all-decls -emit-llvm -o %t %s
+// RUN: grep "@foo" %t
+
+static void foo() {
+
+}
diff --git a/clang/test/CodeGen/empty-union-init.c b/clang/test/CodeGen/empty-union-init.c
new file mode 100644
index 0000000..a58354b
--- /dev/null
+++ b/clang/test/CodeGen/empty-union-init.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm < %s -o -
+// PR2419
+
+struct Mem {
+ union {
+ } u;
+};
+
+struct Mem *columnMem(){
+ static const struct Mem nullMem = { {} };
+}
+
+
diff --git a/clang/test/CodeGen/enum.c b/clang/test/CodeGen/enum.c
new file mode 100644
index 0000000..0e239f1
--- /dev/null
+++ b/clang/test/CodeGen/enum.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -O3 -emit-llvm -o - | grep 'ret i32 6'
+// RUN: %clang_cc1 -triple i386-unknown-unknown -x c++ %s -O3 -emit-llvm -o - | grep 'ret i32 7'
+
+// This test case illustrates a peculiarity of the promotion of
+// enumeration types in C and C++. In particular, the enumeration type
+// "z" below promotes to an unsigned int in C but int in C++.
+static enum { foo, bar = 1U } z;
+
+int main (void)
+{
+ int r = 0;
+
+ if (bar - 2 < 0)
+ r += 4;
+ if (foo - 1 < 0)
+ r += 2;
+ if (z - 1 < 0)
+ r++;
+
+ return r;
+}
+
diff --git a/clang/test/CodeGen/enum2.c b/clang/test/CodeGen/enum2.c
new file mode 100644
index 0000000..3203627
--- /dev/null
+++ b/clang/test/CodeGen/enum2.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -g -emit-llvm -o /dev/null
+int v;
+enum e { MAX };
+
+void foo (void)
+{
+ v = MAX;
+}
diff --git a/clang/test/CodeGen/exact-div-expr.c b/clang/test/CodeGen/exact-div-expr.c
new file mode 100644
index 0000000..a2c12a0
--- /dev/null
+++ b/clang/test/CodeGen/exact-div-expr.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -O1 | grep ashr
+// RUN: %clang_cc1 -emit-llvm %s -o - -O1 | not grep sdiv
+
+long long test(int *A, int *B) {
+ return A-B;
+}
diff --git a/clang/test/CodeGen/exceptions.c b/clang/test/CodeGen/exceptions.c
new file mode 100644
index 0000000..20eb706
--- /dev/null
+++ b/clang/test/CodeGen/exceptions.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fexceptions -fblocks | FileCheck %s
+// RUN: %clang_cc1 -triple armv7-apple-unknown -emit-llvm -o - %s -fexceptions -fsjlj-exceptions -fblocks | FileCheck %s -check-prefix=CHECK-ARM
+
+// rdar://problem/8621849
+void test1() {
+ extern void test1_helper(void (^)(int));
+
+ // CHECK: define void @test1()
+ // CHECK-ARM: define arm_aapcscc void @test1()
+
+ __block int x = 10;
+
+ // CHECK: invoke void @test1_helper(
+ // CHECK-ARM: invoke arm_aapcscc void @test1_helper(
+ test1_helper(^(int v) { x = v; });
+
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gcc_personality_v0 to i8*)
+ // CHECK-NEXT: cleanup
+ // CHECK-ARM: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gcc_personality_sj0 to i8*)
+ // CHECK-ARM-NEXT: cleanup
+}
diff --git a/clang/test/CodeGen/exprs.c b/clang/test/CodeGen/exprs.c
new file mode 100644
index 0000000..cc03be6
--- /dev/null
+++ b/clang/test/CodeGen/exprs.c
@@ -0,0 +1,176 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+
+// PR1895
+// sizeof function
+int zxcv(void);
+int x=sizeof(zxcv);
+int y=__alignof__(zxcv);
+
+
+void *test(int *i) {
+ short a = 1;
+ i += a;
+ i + a;
+ a + i;
+}
+
+_Bool test2b;
+int test2() { if (test2b); return 0; }
+
+// PR1921
+int test3() {
+ const unsigned char *bp;
+ bp -= (short)1;
+}
+
+// PR2080 - sizeof void
+int t1 = sizeof(void);
+int t2 = __alignof__(void);
+void test4() {
+ t1 = sizeof(void);
+ t2 = __alignof__(void);
+
+ t1 = sizeof(test4());
+ t2 = __alignof__(test4());
+}
+
+// 'const float' promotes to double in varargs.
+int test5(const float x, float float_number) {
+ return __builtin_isless(x, float_number);
+}
+
+// this one shouldn't fold
+int ola() {
+ int a=2;
+ if ((0, (int)a) & 2) { return 1; }
+ return 2;
+}
+
+// this one shouldn't fold as well
+void eMaisUma() {
+ double t[1];
+ if (*t)
+ return;
+}
+
+// rdar://6520707
+void f0(void (*fp)(void), void (*fp2)(void)) {
+ int x = fp - fp2;
+}
+
+// noop casts as lvalues.
+struct X {
+ int Y;
+};
+struct X foo();
+int bar() {
+ return ((struct X)foo()).Y + 1;
+}
+
+// PR3809: INC/DEC of function pointers.
+void f2(void);
+unsigned f1(void) {
+ void (*fp)(void) = f2;
+
+ ++fp;
+ fp++;
+ --fp;
+ fp--;
+ return (unsigned) fp;
+}
+
+union f3_x {int x; float y;};
+int f3() {return ((union f3_x)2).x;}
+
+union f4_y {int x; _Complex float y;};
+_Complex float f4() {return ((union f4_y)(_Complex float)2.0).y;}
+
+struct f5_a { int a; } f5_a;
+union f5_z {int x; struct f5_a y;};
+struct f5_a f5() {return ((union f5_z)f5_a).y;}
+
+// ?: in "lvalue"
+struct s6 { int f0; };
+int f6(int a0, struct s6 a1, struct s6 a2) {
+ return (a0 ? a1 : a2).f0;
+}
+
+// PR4026
+void f7() {
+ __func__;
+}
+
+// PR4067
+int f8() {
+ return ({ foo(); }).Y;
+}
+
+// rdar://6880558
+struct S;
+struct C {
+ int i;
+ struct S *tab[];
+};
+struct S { struct C c; };
+void f9(struct S *x) {
+ foo(((void)1, x->c).tab[0]);
+}
+
+void f10() {
+ __builtin_sin(0);
+}
+
+// rdar://7530813
+// CHECK: define i32 @f11
+int f11(long X) {
+ int A[100];
+ return A[X];
+
+// CHECK: [[Xaddr:%[^ ]+]] = alloca i64, align 8
+// CHECK: load {{.*}}* [[Xaddr]]
+// CHECK-NEXT: getelementptr inbounds [100 x i32]* %A, i32 0,
+// CHECK-NEXT: load i32*
+}
+
+int f12() {
+ // PR3150
+ // CHECK: define i32 @f12
+ // CHECK: ret i32 1
+ return 1||1;
+}
+
+// Make sure negate of fp uses -0.0 for proper -0 handling.
+double f13(double X) {
+ // CHECK: define double @f13
+ // CHECK: fsub double -0.0
+ return -X;
+}
+
+// Check operations on incomplete types.
+void f14(struct s14 *a) {
+ (void) &*a;
+}
+
+// CHECK: define void @f15
+void f15() {
+ extern void f15_start(void);
+ f15_start();
+ // CHECK: call void @f15_start()
+
+ extern void *f15_v(void);
+ extern const void *f15_cv(void);
+ extern volatile void *f15_vv(void);
+ *f15_v(); *f15_v(), *f15_v(); f15_v() ? *f15_v() : *f15_v();
+ *f15_cv(); *f15_cv(), *f15_cv(); f15_cv() ? *f15_cv() : *f15_cv();
+ *f15_vv(); *f15_vv(), *f15_vv(); f15_vv() ? *f15_vv() : *f15_vv();
+ // CHECK-NOT: load
+ // CHECK: ret void
+}
+
+// PR8967: this was crashing
+// CHECK: define void @f16()
+void f16() {
+ __extension__({ goto lbl; });
+ lbl:
+ ;
+}
diff --git a/clang/test/CodeGen/ext-vector-member-alignment.c b/clang/test/CodeGen/ext-vector-member-alignment.c
new file mode 100644
index 0000000..49e6997
--- /dev/null
+++ b/clang/test/CodeGen/ext-vector-member-alignment.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+
+struct __attribute__((packed, aligned(4))) struct1 {
+ float4 position;
+};
+int x = __alignof(struct struct1);
+
+float4 f(struct struct1* x) { return x->position; }
+
+void func(struct struct1* p, float *a, float *b, float c) {
+ p->position.x = c;
+ *a = p->position.y;
+ *b = p->position[0];
+ p->position[2] = c;
+ // FIXME: We should be able to come up with a more aggressive alignment
+ // estimate.
+ // CHECK: @func
+ // CHECK: load <4 x float>* {{%.*}}, align 1
+ // CHECK: store <4 x float> {{%.*}}, <4 x float>* {{%.*}}, align 1
+ // CHECK: load <4 x float>* {{%.*}}, align 1
+ // CHECK: load <4 x float>* {{%.*}}, align 1
+ // CHECK: load <4 x float>* {{%.*}}, align 1
+ // CHECK: store <4 x float> {{%.*}}, <4 x float>* {{%.*}}, align 1
+ // CHECK: ret void
+}
diff --git a/clang/test/CodeGen/ext-vector.c b/clang/test/CodeGen/ext-vector.c
new file mode 100644
index 0000000..a9fa151
--- /dev/null
+++ b/clang/test/CodeGen/ext-vector.c
@@ -0,0 +1,288 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+typedef __attribute__(( ext_vector_type(4) )) float float4;
+typedef __attribute__(( ext_vector_type(2) )) float float2;
+typedef __attribute__(( ext_vector_type(4) )) int int4;
+typedef __attribute__(( ext_vector_type(4) )) unsigned int uint4;
+
+// CHECK: @foo = global <4 x float> <float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00>
+float4 foo = (float4){ 1.0, 2.0, 3.0, 4.0 };
+
+// CHECK: @bar = constant <4 x float> <float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 0x7FF0000000000000>
+const float4 bar = (float4){ 1.0, 2.0, 3.0, __builtin_inff() };
+
+// CHECK: @test1
+// CHECK: fadd <4 x float>
+float4 test1(float4 V) {
+ return V.wzyx+V;
+}
+
+float2 vec2, vec2_2;
+float4 vec4, vec4_2;
+float f;
+
+// CHECK: @test2
+// CHECK: shufflevector {{.*}} <i32 0, i32 1>
+// CHECK: extractelement
+// CHECK: shufflevector {{.*}} <i32 1, i32 1, i32 1, i32 1>
+// CHECK: insertelement
+// CHECK: shufflevector {{.*}} <i32 1, i32 0>
+void test2() {
+ vec2 = vec4.xy; // shorten
+ f = vec2.x; // extract elt
+ vec4 = vec4.yyyy; // splat
+
+ vec2.x = f; // insert one.
+ vec2.yx = vec2; // reverse
+}
+
+// CHECK: @test3
+// CHECK: store <4 x float> <float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00>
+void test3(float4 *out) {
+ *out = ((float4) {1.0f, 2.0f, 3.0f, 4.0f });
+}
+
+// CHECK: @test4
+// CHECK: store <4 x float>
+// CHECK: store <4 x float>
+void test4(float4 *out) {
+ float a = 1.0f;
+ float b = 2.0f;
+ float c = 3.0f;
+ float d = 4.0f;
+ *out = ((float4) {a,b,c,d});
+}
+
+// CHECK: @test5
+// CHECK: shufflevector {{.*}} <4 x i32> zeroinitializer
+// CHECK: fmul <4 x float>
+// CHECK: fmul <4 x float>
+// CHECK: shufflevector {{.*}} <4 x i32> zeroinitializer
+// CHECK: fmul <4 x float>
+void test5(float4 *out) {
+ float a;
+ float4 b;
+
+ a = 1.0f;
+ b = a;
+ b = b * 5.0f;
+ b = 5.0f * b;
+ b *= a;
+
+ *out = b;
+}
+
+// CHECK: @test6
+void test6(float4 *ap, float4 *bp, float c) {
+ float4 a = *ap;
+ float4 b = *bp;
+
+ // CHECK: fadd <4 x float>
+ // CHECK: fsub <4 x float>
+ // CHECK: fmul <4 x float>
+ // CHECK: fdiv <4 x float>
+ a = a + b;
+ a = a - b;
+ a = a * b;
+ a = a / b;
+
+ // CHECK: fadd <4 x float>
+ // CHECK: fsub <4 x float>
+ // CHECK: fmul <4 x float>
+ // CHECK: fdiv <4 x float>
+ a = a + c;
+ a = a - c;
+ a = a * c;
+ a = a / c;
+
+ // CHECK: fadd <4 x float>
+ // CHECK: fsub <4 x float>
+ // CHECK: fmul <4 x float>
+ // CHECK: fdiv <4 x float>
+ a += b;
+ a -= b;
+ a *= b;
+ a /= b;
+
+ // CHECK: fadd <4 x float>
+ // CHECK: fsub <4 x float>
+ // CHECK: fmul <4 x float>
+ // CHECK: fdiv <4 x float>
+ a += c;
+ a -= c;
+ a *= c;
+ a /= c;
+
+ // Vector comparisons can sometimes crash the x86 backend: rdar://6326239,
+ // reject them until the implementation is stable.
+#if 0
+ int4 cmp;
+ cmp = a < b;
+ cmp = a <= b;
+ cmp = a < b;
+ cmp = a >= b;
+ cmp = a == b;
+ cmp = a != b;
+#endif
+}
+
+// CHECK: @test7
+void test7(int4 *ap, int4 *bp, int c) {
+ int4 a = *ap;
+ int4 b = *bp;
+
+ // CHECK: add <4 x i32>
+ // CHECK: sub <4 x i32>
+ // CHECK: mul <4 x i32>
+ // CHECK: sdiv <4 x i32>
+ // CHECK: srem <4 x i32>
+ a = a + b;
+ a = a - b;
+ a = a * b;
+ a = a / b;
+ a = a % b;
+
+ // CHECK: add <4 x i32>
+ // CHECK: sub <4 x i32>
+ // CHECK: mul <4 x i32>
+ // CHECK: sdiv <4 x i32>
+ // CHECK: srem <4 x i32>
+ a = a + c;
+ a = a - c;
+ a = a * c;
+ a = a / c;
+ a = a % c;
+
+ // CHECK: add <4 x i32>
+ // CHECK: sub <4 x i32>
+ // CHECK: mul <4 x i32>
+ // CHECK: sdiv <4 x i32>
+ // CHECK: srem <4 x i32>
+ a += b;
+ a -= b;
+ a *= b;
+ a /= b;
+ a %= b;
+
+ // CHECK: add <4 x i32>
+ // CHECK: sub <4 x i32>
+ // CHECK: mul <4 x i32>
+ // CHECK: sdiv <4 x i32>
+ // CHECK: srem <4 x i32>
+ a += c;
+ a -= c;
+ a *= c;
+ a /= c;
+ a %= c;
+
+
+ // Vector comparisons.
+ // CHECK: icmp slt
+ // CHECK: icmp sle
+ // CHECK: icmp sgt
+ // CHECK: icmp sge
+ // CHECK: icmp eq
+ // CHECK: icmp ne
+ int4 cmp;
+ cmp = a < b;
+ cmp = a <= b;
+ cmp = a > b;
+ cmp = a >= b;
+ cmp = a == b;
+ cmp = a != b;
+}
+
+// CHECK: @test8
+void test8(float4 *ap, float4 *bp, int c) {
+ float4 a = *ap;
+ float4 b = *bp;
+
+ // Vector comparisons.
+ // CHECK: fcmp olt
+ // CHECK: fcmp ole
+ // CHECK: fcmp ogt
+ // CHECK: fcmp oge
+ // CHECK: fcmp oeq
+ // CHECK: fcmp une
+ int4 cmp;
+ cmp = a < b;
+ cmp = a <= b;
+ cmp = a > b;
+ cmp = a >= b;
+ cmp = a == b;
+ cmp = a != b;
+}
+
+// CHECK: @test9
+// CHECK: extractelement <4 x i32>
+int test9(int4 V) {
+ return V.xy.x;
+}
+
+// CHECK: @test10
+// CHECK: add <4 x i32>
+// CHECK: extractelement <4 x i32>
+int test10(int4 V) {
+ return (V+V).x;
+}
+
+// CHECK: @test11
+// CHECK: extractelement <4 x i32>
+int4 test11a();
+int test11() {
+ return test11a().x;
+}
+
+// CHECK: @test12
+// CHECK: shufflevector {{.*}} <i32 2, i32 1, i32 0>
+// CHECK: shufflevector {{.*}} <i32 0, i32 1, i32 2, i32 undef>
+// CHECK: shufflevector {{.*}} <i32 4, i32 5, i32 6, i32 3>
+int4 test12(int4 V) {
+ V.xyz = V.zyx;
+ return V;
+}
+
+// CHECK: @test13
+// CHECK: shufflevector {{.*}} <i32 2, i32 1, i32 0, i32 3>
+int4 test13(int4 *V) {
+ return V->zyxw;
+}
+
+// CHECK: @test14
+void test14(uint4 *ap, uint4 *bp, unsigned c) {
+ uint4 a = *ap;
+ uint4 b = *bp;
+ int4 d;
+
+ // CHECK: udiv <4 x i32>
+ // CHECK: urem <4 x i32>
+ a = a / b;
+ a = a % b;
+
+ // CHECK: udiv <4 x i32>
+ // CHECK: urem <4 x i32>
+ a = a / c;
+ a = a % c;
+
+ // CHECK: icmp ult
+ // CHECK: icmp ule
+ // CHECK: icmp ugt
+ // CHECK: icmp uge
+ // CHECK: icmp eq
+ // CHECK: icmp ne
+ d = a < b;
+ d = a <= b;
+ d = a > b;
+ d = a >= b;
+ d = a == b;
+ d = a != b;
+}
+
+// CHECK: @test15
+int4 test15(uint4 V0) {
+ // CHECK: icmp eq <4 x i32>
+ int4 V = !V0;
+ V = V && V;
+ V = V || V;
+ return V;
+}
diff --git a/clang/test/CodeGen/extern-block-var.c b/clang/test/CodeGen/extern-block-var.c
new file mode 100644
index 0000000..329f109
--- /dev/null
+++ b/clang/test/CodeGen/extern-block-var.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+
+int f() {
+ extern int a;
+ return a;
+}
diff --git a/clang/test/CodeGen/extern-inline.c b/clang/test/CodeGen/extern-inline.c
new file mode 100644
index 0000000..e3df996
--- /dev/null
+++ b/clang/test/CodeGen/extern-inline.c
@@ -0,0 +1,26 @@
+// RUN: %clang -S -emit-llvm -std=gnu89 -o - %s | FileCheck %s
+// RUN: %clang -S -emit-llvm -fgnu89-inline -o - %s | FileCheck %s
+// PR5253
+
+// If an extern inline function is redefined, functions should call the
+// redefinition.
+extern inline int f(int a) {return a;}
+int g(void) {return f(0);}
+// CHECK: call i32 @f
+int f(int b) {return 1+b;}
+// CHECK: load i32* %{{.*}}
+// CHECK: add nsw i32 1, %{{.*}}
+int h(void) {return f(1);}
+// CHECK: call i32 @f
+
+// It shouldn't matter if the function was redefined static.
+extern inline int f2(int a, int b) {return a+b;}
+int g2(void) {return f2(0,1);}
+// CHECK: call i32 @f2
+static int f2(int a, int b) {return a*b;}
+// CHECK: load i32* %{{.*}}
+// CHECK: load i32* %{{.*}}
+// CHECK: mul nsw i32 %{{.*}}, %{{.*}}
+int h2(void) {return f2(1,2);}
+// CHECK: call i32 @f2
+
diff --git a/clang/test/CodeGen/extern-weak.c b/clang/test/CodeGen/extern-weak.c
new file mode 100644
index 0000000..6a78a33
--- /dev/null
+++ b/clang/test/CodeGen/extern-weak.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -O3 -emit-llvm -o - %s | grep extern_weak
+// RUN: %clang_cc1 -O3 -emit-llvm -o - %s | llc
+
+#if !defined(__linux__) && !defined(__FreeBSD__) && \
+ !defined(__OpenBSD__) && !defined(__CYGWIN__) && !defined(__DragonFly__)
+void foo() __attribute__((weak_import));
+#else
+void foo() __attribute__((weak));
+#endif
+
+void bar() { foo(); }
+
diff --git a/clang/test/CodeGen/flexible-array-init.c b/clang/test/CodeGen/flexible-array-init.c
new file mode 100644
index 0000000..d3079dc
--- /dev/null
+++ b/clang/test/CodeGen/flexible-array-init.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+struct { int x; int y[]; } a = { 1, 7, 11 };
+// CHECK: @a = global { i32, [2 x i32] } { i32 1, [2 x i32] [i32 7, i32 11] }
+
+struct { int x; int y[]; } b = { 1, { 13, 15 } };
+// CHECK: @b = global { i32, [2 x i32] } { i32 1, [2 x i32] [i32 13, i32 15] }
diff --git a/clang/test/CodeGen/fma4-builtins.c b/clang/test/CodeGen/fma4-builtins.c
new file mode 100644
index 0000000..ddbaba7
--- /dev/null
+++ b/clang/test/CodeGen/fma4-builtins.c
@@ -0,0 +1,166 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +fma4 -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <x86intrin.h>
+
+__m128 test_mm_macc_ps(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfmadd.ps
+ return _mm_macc_ps(a, b, c);
+}
+
+__m128d test_mm_macc_pd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfmadd.pd
+ return _mm_macc_pd(a, b, c);
+}
+
+__m128 test_mm_macc_ss(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfmadd.ss
+ return _mm_macc_ss(a, b, c);
+}
+
+__m128d test_mm_macc_sd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfmadd.sd
+ return _mm_macc_sd(a, b, c);
+}
+
+__m128 test_mm_msub_ps(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfmsub.ps
+ return _mm_msub_ps(a, b, c);
+}
+
+__m128d test_mm_msub_pd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfmsub.pd
+ return _mm_msub_pd(a, b, c);
+}
+
+__m128 test_mm_msub_ss(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfmsub.ss
+ return _mm_msub_ss(a, b, c);
+}
+
+__m128d test_mm_msub_sd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfmsub.sd
+ return _mm_msub_sd(a, b, c);
+}
+
+__m128 test_mm_nmacc_ps(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfnmadd.ps
+ return _mm_nmacc_ps(a, b, c);
+}
+
+__m128d test_mm_nmacc_pd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfnmadd.pd
+ return _mm_nmacc_pd(a, b, c);
+}
+
+__m128 test_mm_nmacc_ss(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfnmadd.ss
+ return _mm_nmacc_ss(a, b, c);
+}
+
+__m128d test_mm_nmacc_sd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfnmadd.sd
+ return _mm_nmacc_sd(a, b, c);
+}
+
+__m128 test_mm_nmsub_ps(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfnmsub.ps
+ return _mm_nmsub_ps(a, b, c);
+}
+
+__m128d test_mm_nmsub_pd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfnmsub.pd
+ return _mm_nmsub_pd(a, b, c);
+}
+
+__m128 test_mm_nmsub_ss(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfnmsub.ss
+ return _mm_nmsub_ss(a, b, c);
+}
+
+__m128d test_mm_nmsub_sd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfnmsub.sd
+ return _mm_nmsub_sd(a, b, c);
+}
+
+__m128 test_mm_maddsub_ps(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfmaddsub.ps
+ return _mm_maddsub_ps(a, b, c);
+}
+
+__m128d test_mm_maddsub_pd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfmaddsub.pd
+ return _mm_maddsub_pd(a, b, c);
+}
+
+__m128 test_mm_msubadd_ps(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfmsubadd.ps
+ return _mm_msubadd_ps(a, b, c);
+}
+
+__m128d test_mm_msubadd_pd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfmsubadd.pd
+ return _mm_msubadd_pd(a, b, c);
+}
+
+__m256 test_mm256_macc_ps(__m256 a, __m256 b, __m256 c) {
+ // CHECK: @llvm.x86.fma4.vfmadd.ps.256
+ return _mm256_macc_ps(a, b, c);
+}
+
+__m256d test_mm256_macc_pd(__m256d a, __m256d b, __m256d c) {
+ // CHECK: @llvm.x86.fma4.vfmadd.pd.256
+ return _mm256_macc_pd(a, b, c);
+}
+
+__m256 test_mm256_msub_ps(__m256 a, __m256 b, __m256 c) {
+ // CHECK: @llvm.x86.fma4.vfmsub.ps.256
+ return _mm256_msub_ps(a, b, c);
+}
+
+__m256d test_mm256_msub_pd(__m256d a, __m256d b, __m256d c) {
+ // CHECK: @llvm.x86.fma4.vfmsub.pd.256
+ return _mm256_msub_pd(a, b, c);
+}
+
+__m256 test_mm256_nmacc_ps(__m256 a, __m256 b, __m256 c) {
+ // CHECK: @llvm.x86.fma4.vfnmadd.ps.256
+ return _mm256_nmacc_ps(a, b, c);
+}
+
+__m256d test_mm256_nmacc_pd(__m256d a, __m256d b, __m256d c) {
+ // CHECK: @llvm.x86.fma4.vfnmadd.pd.256
+ return _mm256_nmacc_pd(a, b, c);
+}
+
+__m256 test_mm256_nmsub_ps(__m256 a, __m256 b, __m256 c) {
+ // CHECK: @llvm.x86.fma4.vfnmsub.ps.256
+ return _mm256_nmsub_ps(a, b, c);
+}
+
+__m256d test_mm256_nmsub_pd(__m256d a, __m256d b, __m256d c) {
+ // CHECK: @llvm.x86.fma4.vfnmsub.pd.256
+ return _mm256_nmsub_pd(a, b, c);
+}
+
+__m256 test_mm256_maddsub_ps(__m256 a, __m256 b, __m256 c) {
+ // CHECK: @llvm.x86.fma4.vfmaddsub.ps.256
+ return _mm256_maddsub_ps(a, b, c);
+}
+
+__m256d test_mm256_maddsub_pd(__m256d a, __m256d b, __m256d c) {
+ // CHECK: @llvm.x86.fma4.vfmaddsub.pd.256
+ return _mm256_maddsub_pd(a, b, c);
+}
+
+__m256 test_mm256_msubadd_ps(__m256 a, __m256 b, __m256 c) {
+ // CHECK: @llvm.x86.fma4.vfmsubadd.ps.256
+ return _mm256_msubadd_ps(a, b, c);
+}
+
+__m256d test_mm256_msubadd_pd(__m256d a, __m256d b, __m256d c) {
+ // CHECK: @llvm.x86.fma4.vfmsubadd.pd.256
+ return _mm256_msubadd_pd(a, b, c);
+}
diff --git a/clang/test/CodeGen/fold-const-declref.c b/clang/test/CodeGen/fold-const-declref.c
new file mode 100644
index 0000000..5a7ba8e
--- /dev/null
+++ b/clang/test/CodeGen/fold-const-declref.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -verify -emit-llvm-only
+
+// PR7242: Check that this doesn't crash.
+int main(void)
+{
+ int __negative = 1;
+ const int __max = __negative && 0 ;
+ __max / 0;
+}
diff --git a/clang/test/CodeGen/fp16-ops.c b/clang/test/CodeGen/fp16-ops.c
new file mode 100644
index 0000000..cbbfb88
--- /dev/null
+++ b/clang/test/CodeGen/fp16-ops.c
@@ -0,0 +1,283 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi %s | FileCheck %s
+typedef unsigned cond_t;
+
+volatile cond_t test;
+volatile __fp16 h0 = 0.0, h1 = 1.0, h2;
+volatile float f0, f1, f2;
+
+void foo(void) {
+ // CHECK: define void @foo()
+
+ // Check unary ops
+
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK fptoi float
+ test = (h0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp une float
+ test = (!h1);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fsub float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = -h1;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = +h1;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fadd float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1++;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fadd float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ ++h1;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fadd float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ --h1;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fadd float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1--;
+
+ // Check binary ops with various operands
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fmul float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = h0 * h2;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call i16 @llvm.convert.to.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fmul float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = h0 * (__fp16) -2.0;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fmul float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = h0 * f2;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fmul float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = f0 * h2;
+
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fdiv float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = (h0 / h2);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fdiv float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = (h0 / (__fp16) -2.0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fdiv float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = (h0 / f2);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fdiv float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = (f0 / h2);
+
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fadd float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = (h2 + h0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fadd float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = ((__fp16)-2.0 + h0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fadd float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = (h2 + f0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fadd float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = (f2 + h0);
+
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fsub float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = (h2 - h0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fsub float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = ((__fp16)-2.0 - h0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fsub float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = (h2 - f0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fsub float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = (f2 - h0);
+
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp olt
+ test = (h2 < h0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp olt
+ test = (h2 < (__fp16)42.0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp olt
+ test = (h2 < f0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp olt
+ test = (f2 < h0);
+
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp ogt
+ test = (h0 > h2);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp ogt
+ test = ((__fp16)42.0 > h2);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp ogt
+ test = (h0 > f2);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp ogt
+ test = (f0 > h2);
+
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp ole
+ test = (h2 <= h0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp ole
+ test = (h2 <= (__fp16)42.0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp ole
+ test = (h2 <= f0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp ole
+ test = (f2 <= h0);
+
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp oge
+ test = (h0 >= h2);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp oge
+ test = (h0 >= (__fp16)-2.0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp oge
+ test = (h0 >= f2);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp oge
+ test = (f0 >= h2);
+
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp oeq
+ test = (h1 == h2);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp oeq
+ test = (h1 == (__fp16)1.0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp oeq
+ test = (h1 == f1);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp oeq
+ test = (f1 == h1);
+
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp une
+ test = (h1 != h2);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp une
+ test = (h1 != (__fp16)1.0);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp une
+ test = (h1 != f1);
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp une
+ test = (f1 != h1);
+
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fcmp une
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h1 = (h1 ? h2 : h0);
+ // Check assignments (inc. compound)
+ h0 = h1;
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h0 = (__fp16)-2.0;
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h0 = f0;
+
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fadd float
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h0 += h1;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fadd
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h0 += (__fp16)1.0;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fadd
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h0 += f2;
+
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fsub
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h0 -= h1;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fsub
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h0 -= (__fp16)1.0;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fsub
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h0 -= f2;
+
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fmul
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h0 *= h1;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fmul
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h0 *= (__fp16)1.0;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fmul
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h0 *= f2;
+
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fdiv
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h0 /= h1;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fdiv
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h0 /= (__fp16)1.0;
+ // CHECK: call float @llvm.convert.from.fp16
+ // CHECK: fdiv
+ // CHECK: call i16 @llvm.convert.to.fp16
+ h0 /= f2;
+}
diff --git a/clang/test/CodeGen/frame-pointer-elim.c b/clang/test/CodeGen/frame-pointer-elim.c
new file mode 100644
index 0000000..b105a19
--- /dev/null
+++ b/clang/test/CodeGen/frame-pointer-elim.c
@@ -0,0 +1,40 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang -target i386-apple-darwin -S -o - %s | \
+// RUN: FileCheck --check-prefix=DARWIN %s
+// DARWIN: f0:
+// DARWIN: pushl %ebp
+// DARWIN: ret
+// DARWIN: f1:
+// DARWIN: pushl %ebp
+// DARWIN: ret
+
+// RUN: %clang -target i386-pc-linux-gnu -S -o - %s | \
+// RUN: FileCheck --check-prefix=LINUX %s
+// LINUX: f0:
+// LINUX-NOT: pushl %ebp
+// LINUX: ret
+// LINUX: f1:
+// LINUX: pushl %ebp
+// LINUX: ret
+
+// RUN: %clang -target i386-darwin -S -o - -fomit-frame-pointer %s | \
+// RUN: FileCheck --check-prefix=OMIT_ALL %s
+// OMIT_ALL: f0:
+// OMIT_ALL-NOT: pushl %ebp
+// OMIT_ALL: ret
+// OMIT_ALL: f1:
+// OMIT_ALL-NOT: pushl %ebp
+// OMIT_ALL: ret
+
+// RUN: %clang -target i386-darwin -S -o - -momit-leaf-frame-pointer %s | \
+// RUN: FileCheck --check-prefix=OMIT_LEAF %s
+// OMIT_LEAF: f0:
+// OMIT_LEAF-NOT: pushl %ebp
+// OMIT_LEAF: ret
+// OMIT_LEAF: f1:
+// OMIT_LEAF: pushl %ebp
+// OMIT_LEAF: ret
+
+void f0() {}
+void f1() { f0(); }
diff --git a/clang/test/CodeGen/func-aligned.c b/clang/test/CodeGen/func-aligned.c
new file mode 100644
index 0000000..f8a4a29
--- /dev/null
+++ b/clang/test/CodeGen/func-aligned.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// rdar://7270273
+void foo() __attribute__((aligned (64)));
+void foo() {
+// CHECK: define void @foo() {{.*}} align 64
+}
diff --git a/clang/test/CodeGen/func-decl-cleanup.c b/clang/test/CodeGen/func-decl-cleanup.c
new file mode 100644
index 0000000..0af8b69
--- /dev/null
+++ b/clang/test/CodeGen/func-decl-cleanup.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+
+// PR2360
+typedef void fn_t();
+
+fn_t a,b;
+
+void b()
+{
+}
+
diff --git a/clang/test/CodeGen/func-in-block.c b/clang/test/CodeGen/func-in-block.c
new file mode 100644
index 0000000..1900135
--- /dev/null
+++ b/clang/test/CodeGen/func-in-block.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -emit-llvm -o - %s | FileCheck %s
+// rdar: // 7860965
+
+extern void PRINTF(const char *);
+extern void B(void (^)(void));
+
+int main()
+{
+ PRINTF(__func__);
+ B(
+ ^{
+ PRINTF(__func__);
+ }
+ );
+ return 0; // not reached
+}
+
+// CHECK: @__func__.__main_block_invoke_0 = private unnamed_addr constant [22 x i8] c"__main_block_invoke_0\00"
+// CHECK: call void @PRINTF({{.*}}@__func__.__main_block_invoke_
diff --git a/clang/test/CodeGen/func-ptr-cast-decl.c b/clang/test/CodeGen/func-ptr-cast-decl.c
new file mode 100644
index 0000000..e630796
--- /dev/null
+++ b/clang/test/CodeGen/func-ptr-cast-decl.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm-only %s -verify
+// PR5882
+
+int q_sk_num(void *a);
+typedef int (*fptr)(double);
+void a() { ((fptr)q_sk_num)(0); }
diff --git a/clang/test/CodeGen/func-return-member.c b/clang/test/CodeGen/func-return-member.c
new file mode 100644
index 0000000..8c55a96
--- /dev/null
+++ b/clang/test/CodeGen/func-return-member.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+struct frk { float _Complex c; int x; };
+struct faz { struct frk f; };
+struct fuz { struct faz f; };
+
+extern struct fuz foo(void);
+
+int X;
+struct frk F;
+float _Complex C;
+
+// CHECK: define void @bar
+void bar(void) {
+ X = foo().f.f.x;
+}
+
+// CHECK: define void @bun
+void bun(void) {
+ F = foo().f.f;
+}
+
+// CHECK: define void @ban
+void ban(void) {
+ C = foo().f.f.c;
+}
diff --git a/clang/test/CodeGen/funccall.c b/clang/test/CodeGen/funccall.c
new file mode 100644
index 0000000..9735e34
--- /dev/null
+++ b/clang/test/CodeGen/funccall.c
@@ -0,0 +1,17 @@
+
+static int q;
+
+void foo() {
+ int t = q;
+ q = t + 1;
+}
+int main() {
+ q = 0;
+ foo();
+ q = q - 1;
+
+ return q;
+}
+
+// This is the source that corresponds to funccall.ll
+// RUN: echo foo
diff --git a/clang/test/CodeGen/function-attributes.c b/clang/test/CodeGen/function-attributes.c
new file mode 100644
index 0000000..6cbf40b
--- /dev/null
+++ b/clang/test/CodeGen/function-attributes.c
@@ -0,0 +1,113 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -Os -o - %s | FileCheck %s
+// CHECK: define signext i8 @f0(i32 %x) nounwind
+// CHECK: define zeroext i8 @f1(i32 %x) nounwind
+// CHECK: define void @f2(i8 signext %x) nounwind
+// CHECK: define void @f3(i8 zeroext %x) nounwind
+// CHECK: define signext i16 @f4(i32 %x) nounwind
+// CHECK: define zeroext i16 @f5(i32 %x) nounwind
+// CHECK: define void @f6(i16 signext %x) nounwind
+// CHECK: define void @f7(i16 zeroext %x) nounwind
+
+signed char f0(int x) { return x; }
+
+unsigned char f1(int x) { return x; }
+
+void f2(signed char x) { }
+
+void f3(unsigned char x) { }
+
+signed short f4(int x) { return x; }
+
+unsigned short f5(int x) { return x; }
+
+void f6(signed short x) { }
+
+void f7(unsigned short x) { }
+
+// CHECK: define void @f8()
+// CHECK: nounwind
+// CHECK: alwaysinline
+// CHECK: {
+void __attribute__((always_inline)) f8(void) { }
+
+// CHECK: call void @f9_t()
+// CHECK: noreturn
+// CHECK: {
+void __attribute__((noreturn)) f9_t(void);
+void f9(void) { f9_t(); }
+
+// FIXME: We should be setting nounwind on calls.
+// CHECK: call i32 @f10_t()
+// CHECK: readnone
+// CHECK: {
+int __attribute__((const)) f10_t(void);
+int f10(void) { return f10_t(); }
+int f11(void) {
+ exit:
+ return f10_t();
+}
+int f12(int arg) {
+ return arg ? 0 : f10_t();
+}
+
+// CHECK: define void @f13() nounwind readnone
+void f13(void) __attribute__((pure)) __attribute__((const));
+void f13(void){}
+
+
+// Ensure that these get inlined: rdar://6853279
+// CHECK: define void @f14
+// CHECK-NOT: @ai_
+// CHECK: call void @f14_end
+static __inline__ __attribute__((always_inline))
+int ai_1() { return 4; }
+
+static __inline__ __attribute__((always_inline))
+struct {
+ int a, b, c, d, e;
+} ai_2() { while (1) {} }
+
+void f14(int a) {
+ extern void f14_end(void);
+ if (a)
+ ai_2();
+ ai_1();
+ f14_end();
+}
+
+// <rdar://problem/7102668> [irgen] clang isn't setting the optsize bit on functions
+// CHECK: define void @f15
+// CHECK: optsize
+// CHECK: {
+void f15(void) {
+}
+
+// PR5254
+// CHECK: define void @f16
+// CHECK: alignstack(16)
+// CHECK: {
+void __attribute__((force_align_arg_pointer)) f16(void) {
+}
+
+// PR11038
+// CHECK: define void @f18()
+// CHECK: returns_twice
+// CHECK: {
+// CHECK: call void @f17()
+// CHECK: returns_twice
+// CHECK: ret void
+__attribute__ ((returns_twice)) void f17(void);
+__attribute__ ((returns_twice)) void f18(void) {
+ f17();
+}
+
+// CHECK: define void @f19()
+// CHECK: {
+// CHECK: call i32 @setjmp(i32* null)
+// CHECK: returns_twice
+// CHECK: ret void
+typedef int jmp_buf[((9 * 2) + 3 + 16)];
+int setjmp(jmp_buf);
+void f19(void) {
+ setjmp(0);
+}
diff --git a/clang/test/CodeGen/functions.c b/clang/test/CodeGen/functions.c
new file mode 100644
index 0000000..28e4bd0
--- /dev/null
+++ b/clang/test/CodeGen/functions.c
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 %s -triple i386-unknown-unknown -emit-llvm -o - -verify | FileCheck %s
+
+int g();
+
+int foo(int i) {
+ return g(i);
+}
+
+int g(int i) {
+ return g(i);
+}
+
+// rdar://6110827
+typedef void T(void);
+void test3(T f) {
+ f();
+}
+
+int a(int);
+int a() {return 1;}
+
+void f0() {}
+// CHECK: define void @f0()
+
+void f1();
+void f2(void) {
+// CHECK: call void bitcast (void ()* @f1 to void (i32, i32, i32)*)(i32 1, i32 2, i32 3)
+ f1(1, 2, 3);
+}
+// CHECK: define void @f1()
+void f1() {}
+
+// CHECK: define {{.*}} @f3{{\(\)|\(.*sret.*\)}}
+struct foo { int X, Y, Z; } f3() {
+ while (1) {}
+}
+
+// PR4423 - This shouldn't crash in codegen
+void f4() {}
+void f5() { f4(42); } //expected-warning {{too many arguments}}
+
+// Qualifiers on parameter types shouldn't make a difference.
+static void f6(const float f, const float g) {
+}
+void f7(float f, float g) {
+ f6(f, g);
+// CHECK: define void @f7(float{{.*}}, float{{.*}})
+// CHECK: call void @f6(float{{.*}}, float{{.*}})
+}
+
+// PR6911 - incomplete function types
+struct Incomplete;
+void f8_callback(struct Incomplete);
+void f8_user(void (*callback)(struct Incomplete));
+void f8_test() {
+ f8_user(&f8_callback);
+// CHECK: define void @f8_test()
+// CHECK: call void @f8_user({{.*}}* bitcast (void ()* @f8_callback to {{.*}}*))
+// CHECK: declare void @f8_user({{.*}}*)
+// CHECK: declare void @f8_callback()
+}
+
+// PR10204: don't crash
+static void test9_helper(void) {}
+void test9() {
+ (void) test9_helper;
+}
diff --git a/clang/test/CodeGen/global-decls.c b/clang/test/CodeGen/global-decls.c
new file mode 100644
index 0000000..89e899f
--- /dev/null
+++ b/clang/test/CodeGen/global-decls.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o %t %s
+
+// RUN: grep '@g0_ext = extern_weak global i32' %t
+extern int g0_ext __attribute__((weak));
+// RUN: grep 'declare extern_weak i32 @g1_ext()' %t
+extern int __attribute__((weak)) g1_ext (void);
+
+// RUN: grep '@g0_common = weak global i32' %t
+int g0_common __attribute__((weak));
+
+// RUN: grep '@g0_def = weak global i32' %t
+int g0_def __attribute__((weak)) = 52;
+// RUN: grep 'define weak i32 @g1_def()' %t
+int __attribute__((weak)) g1_def (void) { return 0; }
+
+// Force _ext references
+void f0() {
+ int a = g0_ext;
+ int b = g1_ext();
+}
+
diff --git a/clang/test/CodeGen/global-init.c b/clang/test/CodeGen/global-init.c
new file mode 100644
index 0000000..dab5a07
--- /dev/null
+++ b/clang/test/CodeGen/global-init.c
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple i386-linux-gnu %s | FileCheck %s
+
+// This checks that the global won't be marked as common.
+// (It shouldn't because it's being initialized).
+
+int a;
+int a = 242;
+// CHECK: @a = global i32 242
+
+// This should get normal weak linkage.
+int c __attribute__((weak))= 0;
+// CHECK: @c = weak global i32 0
+
+
+// Since this is marked const, it should get weak_odr linkage, since all
+// definitions have to be the same.
+// CHECK: @d = weak_odr constant i32 0
+const int d __attribute__((weak))= 0;
+
+// PR6168 "too many undefs"
+struct ManyFields {
+ int a;
+ int b;
+ int c;
+ char d;
+ int e;
+ int f;
+};
+
+// CHECK: global %struct.ManyFields { i32 1, i32 2, i32 0, i8 0, i32 0, i32 0 }
+struct ManyFields FewInits = {1, 2};
+
+
+// PR6766
+// CHECK: @l = global %struct.K { [6 x i32] [i32 102, i32 111, i32 111, i32 0, i32 0, i32 0], i32 1 }
+typedef __WCHAR_TYPE__ wchar_t;
+struct K {
+ wchar_t L[6];
+ int M;
+} l = { { L"foo" }, 1 };
+
+
+// CHECK: @yuv_types = global [4 x [6 x i8]] {{\[}}[6 x i8] c"4:0:0\00", [6 x i8] c"4:2:0\00", [6 x i8] c"4:2:2\00", [6 x i8] c"4:4:4\00"]
+char yuv_types[4][6]= {"4:0:0","4:2:0","4:2:2","4:4:4"};
+
+
+// NOTE: tentative definitions are processed at the end of the translation unit.
+
+// This shouldn't be emitted as common because it has an explicit section.
+// rdar://7119244
+// CHECK: @b = global i32 0, section "foo"
+int b __attribute__((section("foo")));
diff --git a/clang/test/CodeGen/global-with-initialiser.c b/clang/test/CodeGen/global-with-initialiser.c
new file mode 100644
index 0000000..27d209e
--- /dev/null
+++ b/clang/test/CodeGen/global-with-initialiser.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+const int globalInt = 1;
+int globalIntWithFloat = 1.5f;
+int globalIntArray[5] = { 1, 2 };
+int globalIntFromSizeOf = sizeof(globalIntArray);
+char globalChar = 'a';
+char globalCharArray[5] = { 'a', 'b' };
+float globalFloat = 1.0f;
+float globalFloatWithInt = 1;
+float globalFloatArray[5] = { 1.0f, 2.0f };
+double globalDouble = 1.0;
+double globalDoubleArray[5] = { 1.0, 2.0 };
+char *globalString = "abc";
+char *globalStringArray[5] = { "123", "abc" };
+long double globalLongDouble = 1;
+long double globalLongDoubleArray[5] = { 1.0, 2.0 };
+
+struct Struct {
+ int member1;
+ float member2;
+ char *member3;
+};
+
+struct Struct globalStruct = { 1, 2.0f, "foobar"};
diff --git a/clang/test/CodeGen/globalinit.c b/clang/test/CodeGen/globalinit.c
new file mode 100644
index 0000000..e07a419
--- /dev/null
+++ b/clang/test/CodeGen/globalinit.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+int A[10] = { 1,2,3,4,5 };
+
+
+extern int x[];
+void foo() { x[0] = 1; }
+int x[10];
+void bar() { x[0] = 1; }
+
+
+extern int y[];
+void *g = y;
+
+int latin_ptr2len (char *p);
+int (*mb_ptr2len) (char *p) = latin_ptr2len;
+
+
+char string[8] = "string"; // extend init
+char string2[4] = "string"; // truncate init
+
+char *test(int c) {
+ static char buf[10];
+ static char *bufptr = buf;
+
+ return c ? buf : bufptr;
+}
+
+
+_Bool booltest = 0;
+void booltest2() {
+ static _Bool booltest3 = 4;
+}
+
+// Scalars in braces.
+static int a = { 1 };
+
+// References to enums.
+enum {
+ EnumA, EnumB
+};
+
+int c[] = { EnumA, EnumB };
+
+// Binary operators
+int d[] = { EnumA | EnumB };
+
+// PR1968
+static int array[];
+static int array[4];
+
diff --git a/clang/test/CodeGen/hidden-visibility.c b/clang/test/CodeGen/hidden-visibility.c
new file mode 100644
index 0000000..65e6616
--- /dev/null
+++ b/clang/test/CodeGen/hidden-visibility.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: hidden global
+int X __attribute__ ((__visibility__ ("hidden"))) = 123;
diff --git a/clang/test/CodeGen/imaginary.c b/clang/test/CodeGen/imaginary.c
new file mode 100644
index 0000000..2649ceb
--- /dev/null
+++ b/clang/test/CodeGen/imaginary.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -verify -emit-llvm-only %s
+
+// Just verify that we don't crash until we support _Imaginary.
+double _Imaginary foo; // expected-error {{imaginary types are not supported}}
diff --git a/clang/test/CodeGen/implicit-arg.c b/clang/test/CodeGen/implicit-arg.c
new file mode 100644
index 0000000..52ab58e
--- /dev/null
+++ b/clang/test/CodeGen/implicit-arg.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -emit-llvm -O0 -o -
+// RUN: %clang_cc1 %s -emit-llvm -O1 -o -
+// rdar://6518089
+
+static int bar();
+void foo() {
+ int a = bar();
+}
+int bar(unsigned a) {
+}
diff --git a/clang/test/CodeGen/incomplete-function-type.c b/clang/test/CodeGen/incomplete-function-type.c
new file mode 100644
index 0000000..0ba6633
--- /dev/null
+++ b/clang/test/CodeGen/incomplete-function-type.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// CHECK: ModuleID
+// CHECK-NOT: opaque
+// CHECK: define void @f0
+
+enum teste1 test1f(void), (*test1)(void) = test1f;
+struct tests2 test2f(), (*test2)() = test2f;
+struct tests3;
+void test3f(struct tests3), (*test3)(struct tests3) = test3f;
+enum teste1 { TEST1 };
+struct tests2 { int x,y,z,a,b,c,d,e,f,g; };
+struct tests3 { float x; };
+
+void f0() {}
diff --git a/clang/test/CodeGen/indirect-goto.c b/clang/test/CodeGen/indirect-goto.c
new file mode 100644
index 0000000..7a3d717
--- /dev/null
+++ b/clang/test/CodeGen/indirect-goto.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O3 -emit-llvm -o - %s | grep "ret i32 2520"
+
+static int foo(unsigned i) {
+ void *addrs[] = { &&L1, &&L2, &&L3, &&L4, &&L5 };
+ int res = 1;
+
+ goto *addrs[i];
+ L5: res *= 11;
+ L4: res *= 7;
+ L3: res *= 5;
+ L2: res *= 3;
+ L1: res *= 2;
+ return res;
+}
+
+static int foo2(unsigned i) {
+ static const void *addrs[] = { &&L1, &&L2, &&L3, &&L4, &&L5 };
+ int res = 1;
+
+ goto *addrs[i];
+L5: res *= 11;
+L4: res *= 7;
+L3: res *= 5;
+L2: res *= 3;
+L1: res *= 2;
+ return res;
+}
+
+int main() {
+ return foo(3)+foo2(4);
+}
diff --git a/clang/test/CodeGen/init-with-member-expr.c b/clang/test/CodeGen/init-with-member-expr.c
new file mode 100644
index 0000000..fdc8c14
--- /dev/null
+++ b/clang/test/CodeGen/init-with-member-expr.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 < %s -emit-llvm
+struct test {
+ int a;
+};
+
+extern struct test t;
+
+int *b=&t.a;
+
+
+// PR2049
+typedef struct mark_header_tag {
+ unsigned char mark[7];
+} mark_header_t;
+int is_rar_archive(int fd) {
+ const mark_header_t rar_hdr[2] = {{0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00}, {'U', 'n', 'i', 'q', 'u', 'E', '!'}};
+ foo(rar_hdr);
+
+ return 0;
+}
+
diff --git a/clang/test/CodeGen/init.c b/clang/test/CodeGen/init.c
new file mode 100644
index 0000000..426233d
--- /dev/null
+++ b/clang/test/CodeGen/init.c
@@ -0,0 +1,132 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+void f1() {
+ // Scalars in braces.
+ int a = { 1 };
+}
+
+void f2() {
+ int a[2][2] = { { 1, 2 }, { 3, 4 } };
+ int b[3][3] = { { 1, 2 }, { 3, 4 } };
+ int *c[2] = { &a[1][1], &b[2][2] };
+ int *d[2][2] = { {&a[1][1], &b[2][2]}, {&a[0][0], &b[1][1]} };
+ int *e[3][3] = { {&a[1][1], &b[2][2]}, {&a[0][0], &b[1][1]} };
+ char ext[3][3] = {".Y",".U",".V"};
+}
+
+typedef void (* F)(void);
+extern void foo(void);
+struct S { F f; };
+void f3() {
+ struct S a[1] = { { foo } };
+}
+
+// Constants
+// CHECK: @g3 = constant i32 10
+// CHECK: @f4.g4 = internal constant i32 12
+const int g3 = 10;
+int f4() {
+ static const int g4 = 12;
+ return g4;
+}
+
+// PR6537
+typedef union vec3 {
+ struct { double x, y, z; };
+ double component[3];
+} vec3;
+vec3 f5(vec3 value) {
+ return (vec3) {{
+ .x = value.x
+ }};
+}
+
+// rdar://problem/8154689
+void f6() {
+ int x;
+ long ids[] = { (long) &x };
+}
+
+
+
+
+// CHECK: @test7 = global{{.*}}{ i32 0, [4 x i8] c"bar\00" }
+// PR8217
+struct a7 {
+ int b;
+ char v[];
+};
+
+struct a7 test7 = { .b = 0, .v = "bar" };
+
+
+// PR279 comment #3
+char test8(int X) {
+ char str[100000] = "abc"; // tail should be memset.
+ return str[X];
+// CHECK: @test8(
+// CHECK: call void @llvm.memset
+// CHECK: store i8 97
+// CHECK: store i8 98
+// CHECK: store i8 99
+}
+
+void bar(void*);
+
+// PR279
+int test9(int X) {
+ int Arr[100] = { X }; // Should use memset
+ bar(Arr);
+// CHECK: @test9
+// CHECK: call void @llvm.memset
+// CHECK-NOT: store i32 0
+// CHECK: call void @bar
+}
+
+struct a {
+ int a, b, c, d, e, f, g, h, i, j, k, *p;
+};
+
+struct b {
+ struct a a,b,c,d,e,f,g;
+};
+
+int test10(int X) {
+ struct b S = { .a.a = X, .d.e = X, .f.e = 0, .f.f = 0, .f.p = 0 };
+ bar(&S);
+
+ // CHECK: @test10
+ // CHECK: call void @llvm.memset
+ // CHECK-NOT: store i32 0
+ // CHECK: call void @bar
+}
+
+
+// PR9257
+struct test11S {
+ int A[10];
+};
+void test11(struct test11S *P) {
+ *P = (struct test11S) { .A = { [0 ... 3] = 4 } };
+ // CHECK: @test11
+ // CHECK: store i32 4
+ // CHECK: store i32 4
+ // CHECK: store i32 4
+ // CHECK: store i32 4
+ // CHECK: ret void
+}
+
+
+// Verify that we can convert a recursive struct with a memory that returns
+// an instance of the struct we're converting.
+struct test12 {
+ struct test12 (*p)(void);
+} test12g;
+
+
+void test13(int x) {
+ struct X { int a; int b : 10; int c; };
+ struct X y = {.c = x};
+ // CHECK: @test13
+ // CHECK: and i32 {{.*}}, -1024
+}
diff --git a/clang/test/CodeGen/inline-asm-mrv.c b/clang/test/CodeGen/inline-asm-mrv.c
new file mode 100644
index 0000000..929dd90
--- /dev/null
+++ b/clang/test/CodeGen/inline-asm-mrv.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -O | not grep alloca
+// PR2094
+
+int sad16_sse2(void *v, unsigned char *blk2, unsigned char *blk1,
+ int stride, int h) {
+ int ret;
+ asm volatile( "%0 %1 %2 %3"
+ : "+r" (h), "+r" (blk1), "+r" (blk2)
+ : "r" ((long)stride));
+ asm volatile("set %0 %1" : "=r"(ret) : "r"(blk1));
+ return ret;
+}
diff --git a/clang/test/CodeGen/inline.c b/clang/test/CodeGen/inline.c
new file mode 100644
index 0000000..2a01f25
--- /dev/null
+++ b/clang/test/CodeGen/inline.c
@@ -0,0 +1,129 @@
+// RUN: echo "GNU89 tests:"
+// RUN: %clang %s -O1 -emit-llvm -S -o %t -std=gnu89
+// RUN: grep "define available_externally i32 @ei()" %t
+// RUN: grep "define i32 @foo()" %t
+// RUN: grep "define i32 @bar()" %t
+// RUN: grep "define void @unreferenced1()" %t
+// RUN: not grep unreferenced2 %t
+// RUN: grep "define void @gnu_inline()" %t
+// RUN: grep "define available_externally void @gnu_ei_inline()" %t
+// RUN: grep "define i32 @test1" %t
+// RUN: grep "define i32 @test2" %t
+// RUN: grep "define void @test3()" %t
+// RUN: grep "define available_externally i32 @test4" %t
+// RUN: grep "define available_externally i32 @test5" %t
+// RUN: grep "define i32 @test6" %t
+// RUN: grep "define void @test7" %t
+// RUN: grep "define i.. @strlcpy" %t
+// RUN: not grep test9 %t
+// RUN: grep "define void @testA" %t
+// RUN: grep "define void @testB" %t
+// RUN: grep "define void @testC" %t
+
+// RUN: echo "C99 tests:"
+// RUN: %clang %s -O1 -emit-llvm -S -o %t -std=gnu99
+// RUN: grep "define i32 @ei()" %t
+// RUN: grep "define available_externally i32 @foo()" %t
+// RUN: grep "define i32 @bar()" %t
+// RUN: not grep unreferenced1 %t
+// RUN: grep "define void @unreferenced2()" %t
+// RUN: grep "define void @gnu_inline()" %t
+// RUN: grep "define available_externally void @gnu_ei_inline()" %t
+// RUN: grep "define i32 @test1" %t
+// RUN: grep "define i32 @test2" %t
+// RUN: grep "define void @test3" %t
+// RUN: grep "define available_externally i32 @test4" %t
+// RUN: grep "define available_externally i32 @test5" %t
+// RUN: grep "define i32 @test6" %t
+// RUN: grep "define void @test7" %t
+// RUN: grep "define available_externally i.. @strlcpy" %t
+// RUN: grep "define void @test9" %t
+// RUN: grep "define void @testA" %t
+// RUN: grep "define void @testB" %t
+// RUN: grep "define void @testC" %t
+
+// RUN: echo "C++ tests:"
+// RUN: %clang -x c++ %s -O1 -emit-llvm -S -o %t -std=c++98
+// RUN: grep "define linkonce_odr i32 @_Z2eiv()" %t
+// RUN: grep "define linkonce_odr i32 @_Z3foov()" %t
+// RUN: grep "define i32 @_Z3barv()" %t
+// RUN: not grep unreferenced %t
+// RUN: grep "define void @_Z10gnu_inlinev()" %t
+// RUN: grep "define available_externally void @_Z13gnu_ei_inlinev()" %t
+
+extern __inline int ei() { return 123; }
+
+__inline int foo() {
+ return ei();
+}
+
+int bar() { return foo(); }
+
+
+__inline void unreferenced1() {}
+extern __inline void unreferenced2() {}
+
+__inline __attribute((__gnu_inline__)) void gnu_inline() {}
+
+// PR3988
+extern __inline __attribute__((gnu_inline)) void gnu_ei_inline() {}
+void (*P)() = gnu_ei_inline;
+
+// <rdar://problem/6818429>
+int test1();
+__inline int test1() { return 4; }
+__inline int test2() { return 5; }
+__inline int test2();
+int test2();
+
+void test_test1() { test1(); }
+void test_test2() { test2(); }
+
+// PR3989
+extern __inline void test3() __attribute__((gnu_inline));
+__inline void __attribute__((gnu_inline)) test3() {}
+
+extern int test4(void);
+extern __inline __attribute__ ((__gnu_inline__)) int test4(void)
+{
+ return 0;
+}
+
+void test_test4() { test4(); }
+
+extern __inline int test5(void) __attribute__ ((__gnu_inline__));
+extern __inline int __attribute__ ((__gnu_inline__)) test5(void)
+{
+ return 0;
+}
+
+void test_test5() { test5(); }
+
+// PR10233
+
+__inline int test6() { return 0; }
+extern int test6();
+
+
+// No PR#, but this once crashed clang in C99 mode due to buggy extern inline
+// redeclaration detection.
+void test7() { }
+void test7();
+
+// PR11062; the fact that the function is named strlcpy matters here.
+inline __typeof(sizeof(int)) strlcpy(char *dest, const char *src, __typeof(sizeof(int)) size) { return 3; }
+void test8() { strlcpy(0,0,0); }
+
+// PR10657; the test crashed in C99 mode
+extern inline void test9() { }
+void test9();
+
+inline void testA() {}
+void testA();
+
+void testB();
+inline void testB() {}
+extern void testB();
+
+extern inline void testC() {}
+inline void testC();
diff --git a/clang/test/CodeGen/inline2.c b/clang/test/CodeGen/inline2.c
new file mode 100644
index 0000000..fca4fff
--- /dev/null
+++ b/clang/test/CodeGen/inline2.c
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -O1 -std=gnu89 -triple i386-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix GNU89 %s
+// RUN: %clang_cc1 -O1 -std=c99 -triple i386-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix C99 %s
+
+// CHECK-GNU89: define i32 @f0()
+// CHECK-C99: define i32 @f0()
+int f0(void);
+int f0(void) { return 0; }
+
+// CHECK-GNU89: define i32 @f1()
+// CHECK-C99: define i32 @f1()
+inline int f1(void);
+int f1(void) { return 0; }
+
+// CHECK-GNU89: define i32 @f2()
+// CHECK-C99: define i32 @f2()
+int f2(void);
+inline int f2(void) { return 0; }
+
+// CHECK-GNU89: define i32 @f3()
+// CHECK-C99: define i32 @f3()
+extern inline int f3(void);
+int f3(void) { return 0; }
+
+// CHECK-GNU89: define i32 @f5()
+// CHECK-C99: define i32 @f5()
+extern inline int f5(void);
+inline int f5(void) { return 0; }
+
+// CHECK-GNU89: define i32 @f6()
+// CHECK-C99: define i32 @f6()
+inline int f6(void);
+extern inline int f6(void) { return 0; }
+
+// CHECK-GNU89: define i32 @f7()
+// CHECK-C99: define i32 @f7()
+extern inline int f7(void);
+extern int f7(void) { return 0; }
+
+// CHECK-GNU89: define i32 @fA()
+inline int fA(void) { return 0; }
+
+// CHECK-GNU89: define available_externally i32 @f4()
+// CHECK-C99: define i32 @f4()
+int f4(void);
+extern inline int f4(void) { return 0; }
+
+// CHECK-GNU89: define available_externally i32 @f8()
+// CHECK-C99: define i32 @f8()
+extern int f8(void);
+extern inline int f8(void) { return 0; }
+
+// CHECK-GNU89: define available_externally i32 @f9()
+// CHECK-C99: define i32 @f9()
+extern inline int f9(void);
+extern inline int f9(void) { return 0; }
+
+// CHECK-C99: define available_externally i32 @fA()
+
+int test_all() {
+ return f0() + f1() + f2() + f3() + f4() + f5() + f6() + f7() + f8() + f9()
+ + fA();
+}
diff --git a/clang/test/CodeGen/instrument-functions.c b/clang/test/CodeGen/instrument-functions.c
new file mode 100644
index 0000000..d80385e
--- /dev/null
+++ b/clang/test/CodeGen/instrument-functions.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -S -emit-llvm -o - %s -finstrument-functions | FileCheck %s
+
+// CHECK: @test1
+int test1(int x) {
+// CHECK: __cyg_profile_func_enter
+// CHECK: __cyg_profile_func_exit
+// CHECK: ret
+ return x;
+}
+
+// CHECK: @test2
+int test2(int) __attribute__((no_instrument_function));
+int test2(int x) {
+// CHECK-NOT: __cyg_profile_func_enter
+// CHECK-NOT: __cyg_profile_func_exit
+// CHECK: ret
+ return x;
+}
diff --git a/clang/test/CodeGen/int-to-pointer.c b/clang/test/CodeGen/int-to-pointer.c
new file mode 100644
index 0000000..242a8a6
--- /dev/null
+++ b/clang/test/CodeGen/int-to-pointer.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+void *test(int i)
+{
+ return (void *)i;
+}
diff --git a/clang/test/CodeGen/integer-overflow.c b/clang/test/CodeGen/integer-overflow.c
new file mode 100644
index 0000000..1d46065
--- /dev/null
+++ b/clang/test/CodeGen/integer-overflow.c
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT
+// RUN: %clang_cc1 %s -emit-llvm -o - -fwrapv | FileCheck %s --check-prefix=WRAPV
+// RUN: %clang_cc1 %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV
+// RUN: %clang_cc1 %s -emit-llvm -o - -ftrapv -ftrapv-handler foo | FileCheck %s --check-prefix=TRAPV_HANDLER
+
+
+// Tests for signed integer overflow stuff.
+// rdar://7432000 rdar://7221421
+void test1() {
+ // DEFAULT: define void @test1
+ // WRAPV: define void @test1
+ // TRAPV: define void @test1
+ extern volatile int f11G, a, b;
+
+ // DEFAULT: add nsw i32
+ // WRAPV: add i32
+ // TRAPV: llvm.sadd.with.overflow.i32
+ // TRAPV_HANDLER: foo(
+ f11G = a + b;
+
+ // DEFAULT: sub nsw i32
+ // WRAPV: sub i32
+ // TRAPV: llvm.ssub.with.overflow.i32
+ // TRAPV_HANDLER: foo(
+ f11G = a - b;
+
+ // DEFAULT: mul nsw i32
+ // WRAPV: mul i32
+ // TRAPV: llvm.smul.with.overflow.i32
+ // TRAPV_HANDLER: foo(
+ f11G = a * b;
+
+ // DEFAULT: sub nsw i32 0,
+ // WRAPV: sub i32 0,
+ // TRAPV: llvm.ssub.with.overflow.i32(i32 0
+ // TRAPV_HANDLER: foo(
+ f11G = -a;
+
+ // PR7426 - Overflow checking for increments.
+
+ // DEFAULT: add nsw i32 {{.*}}, 1
+ // WRAPV: add i32 {{.*}}, 1
+ // TRAPV: llvm.sadd.with.overflow.i32({{.*}}, i32 1)
+ // TRAPV_HANDLER: foo(
+ ++a;
+
+ // DEFAULT: add nsw i32 {{.*}}, -1
+ // WRAPV: add i32 {{.*}}, -1
+ // TRAPV: llvm.sadd.with.overflow.i32({{.*}}, i32 -1)
+ // TRAPV_HANDLER: foo(
+ --a;
+
+ // -fwrapv should turn off inbounds for GEP's, PR9256
+ extern int* P;
+ ++P;
+ // DEFAULT: getelementptr inbounds i32*
+ // WRAPV: getelementptr i32*
+ // TRAPV: getelementptr inbounds i32*
+
+ // PR9350: char increment never overflows.
+ extern volatile signed char PR9350;
+ // DEFAULT: add i8 {{.*}}, 1
+ // WRAPV: add i8 {{.*}}, 1
+ // TRAPV: add i8 {{.*}}, 1
+ ++PR9350;
+}
diff --git a/clang/test/CodeGen/kr-func-promote.c b/clang/test/CodeGen/kr-func-promote.c
new file mode 100644
index 0000000..fcdbac3
--- /dev/null
+++ b/clang/test/CodeGen/kr-func-promote.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | grep "i32 @a(i32)"
+
+int a();
+int a(x) short x; {return x;}
+
diff --git a/clang/test/CodeGen/kr-style-block.c b/clang/test/CodeGen/kr-style-block.c
new file mode 100644
index 0000000..09efb37
--- /dev/null
+++ b/clang/test/CodeGen/kr-style-block.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t -fblocks
+
+void foo (void(^)());
+
+int main()
+{
+foo(
+ ^() { }
+);
+}
diff --git a/clang/test/CodeGen/libcalls-d.c b/clang/test/CodeGen/libcalls-d.c
new file mode 100644
index 0000000..b375f2b
--- /dev/null
+++ b/clang/test/CodeGen/libcalls-d.c
@@ -0,0 +1,16 @@
+// llvm-gcc -O1+ should run simplify libcalls, O0 shouldn't
+// and -fno-builtins shouldn't.
+// -fno-math-errno should emit an llvm intrinsic, -fmath-errno should not.
+// RUN: %clang_cc1 %s -emit-llvm -fno-math-errno -O0 -o - | grep {call.*exp2\\.f64}
+// RUN: %clang_cc1 %s -emit-llvm -fmath-errno -O0 -o - | grep {call.*exp2}
+// RUN: %clang_cc1 %s -emit-llvm -O1 -o - | grep {call.*ldexp}
+// RUN: %clang_cc1 %s -emit-llvm -O3 -fno-builtin -o - | grep {call.*exp2}
+
+// clang doesn't support this yet.
+// XFAIL: *
+
+double exp2(double);
+
+double t4(unsigned char x) {
+ return exp2(x);
+}
diff --git a/clang/test/CodeGen/libcalls-fno-builtin.c b/clang/test/CodeGen/libcalls-fno-builtin.c
new file mode 100644
index 0000000..ce10759
--- /dev/null
+++ b/clang/test/CodeGen/libcalls-fno-builtin.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -S -O3 -fno-builtin -o - %s | FileCheck %s
+// rdar://10551066
+
+double ceil(double x);
+double copysign(double,double);
+double cos(double x);
+double fabs(double x);
+double floor(double x);
+
+double t1(double x) { return ceil(x); }
+// CHECK: t1
+// CHECK: ceil
+
+double t2(double x, double y) { return copysign(x,y); }
+// CHECK: t2
+// CHECK: copysign
+
+double t3(double x) { return cos(x); }
+// CHECK: t3
+// CHECK: cos
+
+double t4(double x) { return fabs(x); }
+// CHECK: t4
+// CHECK: fabs
+
+double t5(double x) { return floor(x); }
+// CHECK: t5
+// CHECK: floor
diff --git a/clang/test/CodeGen/libcalls-ld.c b/clang/test/CodeGen/libcalls-ld.c
new file mode 100644
index 0000000..2758761
--- /dev/null
+++ b/clang/test/CodeGen/libcalls-ld.c
@@ -0,0 +1,19 @@
+// llvm-gcc -O1+ should run simplify libcalls, O0 shouldn't
+// and -fno-builtins shouldn't.
+// -fno-math-errno should emit an llvm intrinsic, -fmath-errno should not.
+// RUN: %clang_cc1 %s -emit-llvm -fno-math-errno -O0 -o - | grep {call.*exp2\\..*f}
+// RUN: %clang_cc1 %s -emit-llvm -fmath-errno -O0 -o - | grep {call.*exp2l}
+// RUN: %clang_cc1 %s -emit-llvm -O1 -o - | grep {call.*ldexp}
+// RUN: %clang_cc1 %s -emit-llvm -O3 -fno-builtin -o - | grep {call.*exp2l}
+
+// clang doesn't support this yet.
+// XFAIL: *
+
+// If this fails for you because your target doesn't support long double,
+// please xfail the test.
+
+long double exp2l(long double);
+
+long double t4(unsigned char x) {
+ return exp2l(x);
+}
diff --git a/clang/test/CodeGen/libcalls.c b/clang/test/CodeGen/libcalls.c
new file mode 100644
index 0000000..458c591
--- /dev/null
+++ b/clang/test/CodeGen/libcalls.c
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -fmath-errno -emit-llvm -o - %s -triple i386-unknown-unknown | FileCheck -check-prefix YES %s
+// RUN: %clang_cc1 -emit-llvm -o - %s -triple i386-unknown-unknown | FileCheck -check-prefix NO %s
+
+// CHECK-YES: define void @test_sqrt
+// CHECK-NO: define void @test_sqrt
+void test_sqrt(float a0, double a1, long double a2) {
+ // Following llvm-gcc's lead, we never emit these as intrinsics;
+ // no-math-errno isn't good enough. We could probably use intrinsics
+ // with appropriate guards if it proves worthwhile.
+
+ // CHECK-YES: call float @sqrtf
+ // CHECK-NO: call float @sqrtf
+ float l0 = sqrtf(a0);
+
+ // CHECK-YES: call double @sqrt
+ // CHECK-NO: call double @sqrt
+ double l1 = sqrt(a1);
+
+ // CHECK-YES: call x86_fp80 @sqrtl
+ // CHECK-NO: call x86_fp80 @sqrtl
+ long double l2 = sqrtl(a2);
+}
+
+// CHECK-YES: declare float @sqrtf(float)
+// CHECK-YES: declare double @sqrt(double)
+// CHECK-YES: declare x86_fp80 @sqrtl(x86_fp80)
+// CHECK-NO: declare float @sqrtf(float) nounwind readnone
+// CHECK-NO: declare double @sqrt(double) nounwind readnone
+// CHECK-NO: declare x86_fp80 @sqrtl(x86_fp80) nounwind readnone
+
+// CHECK-YES: define void @test_pow
+// CHECK-NO: define void @test_pow
+void test_pow(float a0, double a1, long double a2) {
+ // CHECK-YES: call float @powf
+ // CHECK-NO: call float @llvm.pow.f32
+ float l0 = powf(a0, a0);
+
+ // CHECK-YES: call double @pow
+ // CHECK-NO: call double @llvm.pow.f64
+ double l1 = pow(a1, a1);
+
+ // CHECK-YES: call x86_fp80 @powl
+ // CHECK-NO: call x86_fp80 @llvm.pow.f80
+ long double l2 = powl(a2, a2);
+}
+
+// CHECK-YES: declare float @powf(float, float)
+// CHECK-YES: declare double @pow(double, double)
+// CHECK-YES: declare x86_fp80 @powl(x86_fp80, x86_fp80)
+// CHECK-NO: declare float @llvm.pow.f32(float, float) nounwind readonly
+// CHECK-NO: declare double @llvm.pow.f64(double, double) nounwind readonly
+// CHECK-NO: declare x86_fp80 @llvm.pow.f80(x86_fp80, x86_fp80) nounwind readonly
+
+// CHECK-YES: define void @test_fma
+// CHECK-NO: define void @test_fma
+void test_fma(float a0, double a1, long double a2) {
+ // CHECK-YES: call float @llvm.fma.f32
+ // CHECK-NO: call float @llvm.fma.f32
+ float l0 = fmaf(a0, a0, a0);
+
+ // CHECK-YES: call double @llvm.fma.f64
+ // CHECK-NO: call double @llvm.fma.f64
+ double l1 = fma(a1, a1, a1);
+
+ // CHECK-YES: call x86_fp80 @llvm.fma.f80
+ // CHECK-NO: call x86_fp80 @llvm.fma.f80
+ long double l2 = fmal(a2, a2, a2);
+}
+
+// CHECK-YES: declare float @llvm.fma.f32(float, float, float) nounwind readnone
+// CHECK-YES: declare double @llvm.fma.f64(double, double, double) nounwind readnone
+// CHECK-YES: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) nounwind readnone
+// CHECK-NO: declare float @llvm.fma.f32(float, float, float) nounwind readnone
+// CHECK-NO: declare double @llvm.fma.f64(double, double, double) nounwind readnone
+// CHECK-NO: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) nounwind readnone
diff --git a/clang/test/CodeGen/lifetime.c b/clang/test/CodeGen/lifetime.c
new file mode 100644
index 0000000..2203840
--- /dev/null
+++ b/clang/test/CodeGen/lifetime.c
@@ -0,0 +1,23 @@
+// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefix=O0
+// RUN: %clang -S -emit-llvm -o - -O1 %s | FileCheck %s -check-prefix=O1
+// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefix=O2
+// RUN: %clang -S -emit-llvm -o - -O3 %s | FileCheck %s -check-prefix=O3
+
+extern void use(char *a);
+
+__attribute__((always_inline)) void helper_no_markers() {
+ char a;
+ use(&a);
+}
+
+void lifetime_test() {
+// O0: lifetime_test
+// O1: lifetime_test
+// O2: lifetime_test
+// O3: lifetime_test
+// O0-NOT: @llvm.lifetime.start
+// O1: @llvm.lifetime.start
+// O2: @llvm.lifetime.start
+// O3: @llvm.lifetime.start
+ helper_no_markers();
+}
diff --git a/clang/test/CodeGen/lineno-dbginfo.c b/clang/test/CodeGen/lineno-dbginfo.c
new file mode 100644
index 0000000..72fa337
--- /dev/null
+++ b/clang/test/CodeGen/lineno-dbginfo.c
@@ -0,0 +1,5 @@
+// RUN: echo "#include <stddef.h>" > %t.h
+// RUN: %clang -S -g -include %t.h %s -emit-llvm -o %t.ll
+// RUN: grep "i32 5" %t.ll
+// outer is at line number 5.
+int outer = 42;
diff --git a/clang/test/CodeGen/link-bitcode-file.c b/clang/test/CodeGen/link-bitcode-file.c
new file mode 100644
index 0000000..7740406
--- /dev/null
+++ b/clang/test/CodeGen/link-bitcode-file.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -DBITCODE -emit-llvm-bc -o %t.bc %s
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -mlink-bitcode-file %t.bc -O3 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NO-BC %s
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -DBITCODE -mlink-bitcode-file %t.bc -O3 -emit-llvm -o - %s 2>&1 | FileCheck -check-prefix=CHECK-BC %s
+
+int f(void);
+
+#ifdef BITCODE
+
+// CHECK-BC: 'f': symbol multiply defined
+int f(void) {
+ return 42;
+}
+
+#else
+
+// CHECK-NO-BC: define i32 @g
+// CHECK-NO-BC: ret i32 42
+int g(void) {
+ return f();
+}
+
+// CHECK-NO-BC: define i32 @f
+
+#endif
diff --git a/clang/test/CodeGen/linkage-redecl.c b/clang/test/CodeGen/linkage-redecl.c
new file mode 100644
index 0000000..09b51f0
--- /dev/null
+++ b/clang/test/CodeGen/linkage-redecl.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - |grep internal
+
+// C99 6.2.2p3
+// PR3425
+static void f(int x);
+
+void g0() {
+ f(5);
+}
+
+extern void f(int x) { } // still has internal linkage
diff --git a/clang/test/CodeGen/long-double-x86.c b/clang/test/CodeGen/long-double-x86.c
new file mode 100644
index 0000000..f040207
--- /dev/null
+++ b/clang/test/CodeGen/long-double-x86.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin9 | grep x86_fp80
+
+long double x = 0;
+int checksize[sizeof(x) == 16 ? 1 : -1];
diff --git a/clang/test/CodeGen/lzcnt-builtins.c b/clang/test/CodeGen/lzcnt-builtins.c
new file mode 100644
index 0000000..a43c4ee
--- /dev/null
+++ b/clang/test/CodeGen/lzcnt-builtins.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +lzcnt -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <x86intrin.h>
+
+unsigned short test__lzcnt16(unsigned short __X)
+{
+ // CHECK: @llvm.ctlz.i16
+ return __lzcnt16(__X);
+}
+
+unsigned int test_lzcnt32(unsigned int __X)
+{
+ // CHECK: @llvm.ctlz.i32
+ return __lzcnt32(__X);
+}
+
+unsigned long long test__lzcnt64(unsigned long long __X)
+{
+ // CHECK: @llvm.ctlz.i64
+ return __lzcnt64(__X);
+}
diff --git a/clang/test/CodeGen/mandel.c b/clang/test/CodeGen/mandel.c
new file mode 100644
index 0000000..8ecf8f2
--- /dev/null
+++ b/clang/test/CodeGen/mandel.c
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+/* Sparc is not C99-compliant */
+#if defined(sparc) || defined(__sparc__) || defined(__sparcv9)
+
+int main() { return 0; }
+
+#else /* sparc */
+
+#define ESCAPE 2
+#define IMAGE_WIDTH 150
+#define IMAGE_HEIGHT 50
+#if 1
+#define IMAGE_SIZE 60
+#else
+#define IMAGE_SIZE 5000
+#endif
+#define START_X -2.1
+#define END_X 1.0
+#define START_Y -1.25
+#define MAX_ITER 100
+
+#define step_X ((END_X - START_X)/IMAGE_WIDTH)
+#define step_Y ((-START_Y - START_Y)/IMAGE_HEIGHT)
+
+#define I 1.0iF
+
+int putchar(char c);
+
+volatile double __complex__ accum;
+
+void mandel() {
+ int x, y, n;
+ for (y = 0; y < IMAGE_HEIGHT; ++y) {
+ for (x = 0; x < IMAGE_WIDTH; ++x) {
+ double __complex__ c = (START_X+x*step_X) + (START_Y+y*step_Y) * I;
+ double __complex__ z = 0.0;
+
+ for (n = 0; n < MAX_ITER; ++n) {
+ z = z * z + c;
+ if (hypot(__real__ z, __imag__ z) >= ESCAPE)
+ break;
+ }
+
+ if (n == MAX_ITER)
+ putchar(' ');
+ else if (n > 6)
+ putchar('.');
+ else if (n > 3)
+ putchar('+');
+ else if (n > 2)
+ putchar('x');
+ else
+ putchar('*');
+ }
+ putchar('\n');
+ }
+}
+
+int main() {
+ mandel();
+ return 0;
+}
+
+#endif /* sparc */
diff --git a/clang/test/CodeGen/mangle.c b/clang/test/CodeGen/mangle.c
new file mode 100644
index 0000000..46ef512
--- /dev/null
+++ b/clang/test/CodeGen/mangle.c
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @foo
+
+// Make sure we mangle overloadable, even in C system headers.
+# 1 "somesystemheader.h" 1 3 4
+// CHECK: @_Z2f0i
+void __attribute__((__overloadable__)) f0(int a) {}
+// CHECK: @_Z2f0l
+void __attribute__((__overloadable__)) f0(long b) {}
+
+// CHECK: @bar
+
+// These should get merged.
+void foo() __asm__("bar");
+void foo2() __asm__("bar");
+
+int nux __asm__("foo");
+extern float nux2 __asm__("foo");
+
+int test() {
+ foo();
+ foo2();
+
+ return nux + nux2;
+}
+
+
+// Function becomes a variable.
+void foo3() __asm__("var");
+
+void test2() {
+ foo3();
+}
+int foo4 __asm__("var") = 4;
+
+
+// Variable becomes a function
+extern int foo5 __asm__("var2");
+
+void test3() {
+ foo5 = 1;
+}
+
+void foo6() __asm__("var2");
+void foo6() {
+}
+
+
+
+int foo7 __asm__("foo7") __attribute__((used));
+float foo8 __asm__("foo7") = 42;
+
+// PR4412
+int func(void);
+extern int func (void) __asm__ ("FUNC");
+
+// CHECK: @FUNC
+int func(void) {
+ return 42;
+}
+
+// CHECK: @_Z4foo9Dv4_f
+typedef __attribute__(( vector_size(16) )) float float4;
+void __attribute__((__overloadable__)) foo9(float4 f) {}
+
+// Intrinsic calls.
+extern int llvm_cas(volatile int*, int, int)
+ __asm__("llvm.atomic.cmp.swap.i32.p0i32");
+
+int foo10(volatile int* add, int from, int to) {
+ // CHECK: call i32 @llvm.atomic.cmp.swap.i32.p0i32
+ return llvm_cas(add, from, to);
+}
diff --git a/clang/test/CodeGen/may-alias.c b/clang/test/CodeGen/may-alias.c
new file mode 100644
index 0000000..b73ee15
--- /dev/null
+++ b/clang/test/CodeGen/may-alias.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 -disable-llvm-optzns -o %t %s
+// RUN: FileCheck < %t %s
+
+// Types with the may_alias attribute should be considered equivalent
+// to char for aliasing.
+
+typedef int __attribute__((may_alias)) aliasing_int;
+
+void test0(aliasing_int *ai, int *i)
+{
+// CHECK: store i32 0, i32* %{{.*}}, !tbaa !1
+ *ai = 0;
+// CHECK: store i32 1, i32* %{{.*}}, !tbaa !3
+ *i = 1;
+}
+
+// PR9307
+struct Test1 { int x; };
+struct Test1MA { int x; } __attribute__((may_alias));
+void test1(struct Test1MA *p1, struct Test1 *p2) {
+ // CHECK: store i32 2, i32* {{%.*}}, !tbaa !1
+ p1->x = 2;
+ // CHECK: store i32 3, i32* {{%.*}}, !tbaa !3
+ p2->x = 3;
+}
+
+// CHECK: !0 = metadata !{metadata !"any pointer", metadata !1}
+// CHECK: !1 = metadata !{metadata !"omnipotent char", metadata !2}
+// CHECK: !2 = metadata !{metadata !"Simple C/C++ TBAA"}
+// CHECK: !3 = metadata !{metadata !"int", metadata !1}
diff --git a/clang/test/CodeGen/mcount.c b/clang/test/CodeGen/mcount.c
new file mode 100644
index 0000000..1cf3d6a
--- /dev/null
+++ b/clang/test/CodeGen/mcount.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -pg -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+void foo(void) {
+// CHECK: call void @mcount()
+}
diff --git a/clang/test/CodeGen/merge-attrs.c b/clang/test/CodeGen/merge-attrs.c
new file mode 100644
index 0000000..474b172
--- /dev/null
+++ b/clang/test/CodeGen/merge-attrs.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+
+void *malloc(__SIZE_TYPE__ size) __attribute__ ((__nothrow__));
+
+inline static void __zend_malloc() {
+ malloc(1);
+}
+
+void *malloc(__SIZE_TYPE__ size) __attribute__ ((__nothrow__));
+
+void fontFetch() {
+ __zend_malloc(1);
+}
diff --git a/clang/test/CodeGen/merge-statics.c b/clang/test/CodeGen/merge-statics.c
new file mode 100644
index 0000000..6716935
--- /dev/null
+++ b/clang/test/CodeGen/merge-statics.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 < %s -emit-llvm | grep internal | count 1
+
+// The two decls for 'a' should merge into one llvm GlobalVariable.
+
+struct s { int x; };
+static struct s a;
+
+struct s *ap1 = &a;
+
+static struct s a = {
+ 10
+};
+
diff --git a/clang/test/CodeGen/microsoft-call-conv.c b/clang/test/CodeGen/microsoft-call-conv.c
new file mode 100644
index 0000000..390c3be
--- /dev/null
+++ b/clang/test/CodeGen/microsoft-call-conv.c
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s
+
+void __fastcall f1(void);
+void __stdcall f2(void);
+void __thiscall f3(void);
+void __fastcall f4(void) {
+// CHECK: define x86_fastcallcc void @f4()
+ f1();
+// CHECK: call x86_fastcallcc void @f1()
+}
+void __stdcall f5(void) {
+// CHECK: define x86_stdcallcc void @f5()
+ f2();
+// CHECK: call x86_stdcallcc void @f2()
+}
+void __thiscall f6(void) {
+// CHECK: define x86_thiscallcc void @f6()
+ f3();
+// CHECK: call x86_thiscallcc void @f3()
+}
+
+// PR5280
+void (__fastcall *pf1)(void) = f1;
+void (__stdcall *pf2)(void) = f2;
+void (__thiscall *pf3)(void) = f3;
+void (__fastcall *pf4)(void) = f4;
+void (__stdcall *pf5)(void) = f5;
+void (__thiscall *pf6)(void) = f6;
+
+int main(void) {
+ f4(); f5(); f6();
+ // CHECK: call x86_fastcallcc void @f4()
+ // CHECK: call x86_stdcallcc void @f5()
+ // CHECK: call x86_thiscallcc void @f6()
+ pf1(); pf2(); pf3(); pf4(); pf5(); pf6();
+ // CHECK: call x86_fastcallcc void %{{.*}}()
+ // CHECK: call x86_stdcallcc void %{{.*}}()
+ // CHECK: call x86_thiscallcc void %{{.*}}()
+ // CHECK: call x86_fastcallcc void %{{.*}}()
+ // CHECK: call x86_stdcallcc void %{{.*}}()
+ // CHECK: call x86_thiscallcc void %{{.*}}()
+ return 0;
+}
+
+// PR7117
+void __stdcall f7(foo) int foo; {}
+void f8(void) {
+ f7(0);
+ // CHECK: call x86_stdcallcc void @f7(i32 0)
+}
diff --git a/clang/test/CodeGen/mips-clobber-reg.c b/clang/test/CodeGen/mips-clobber-reg.c
new file mode 100644
index 0000000..2a06e53
--- /dev/null
+++ b/clang/test/CodeGen/mips-clobber-reg.c
@@ -0,0 +1,80 @@
+// RUN: %clang -target mipsel-unknown-linux -ccc-clang-archs mipsel -S -o - -emit-llvm %s
+
+/*
+ This checks that the frontend will accept both
+ enumerated and symbolic Mips GPR register names.
+
+ Any bad names will make the frontend choke.
+ */
+
+main()
+{
+
+ __asm__ __volatile__ (".set noat \n\t addi $7,$at,77":::"at");
+ __asm__ __volatile__ ("addi $7,$v0,77":::"v0");
+ __asm__ __volatile__ ("addi $7,$v1,77":::"v1");
+ __asm__ __volatile__ ("addi $7,$a0,77":::"a0");
+ __asm__ __volatile__ ("addi $7,$a1,77":::"a1");
+ __asm__ __volatile__ ("addi $7,$a2,77":::"a2");
+ __asm__ __volatile__ ("addi $7,$a3,77":::"a3");
+ __asm__ __volatile__ ("addi $7,$t0,77":::"t0");
+ __asm__ __volatile__ ("addi $7,$t1,77":::"t1");
+ __asm__ __volatile__ ("addi $7,$t2,77":::"t2");
+ __asm__ __volatile__ ("addi $7,$t3,77":::"t3");
+ __asm__ __volatile__ ("addi $7,$t4,77":::"t4");
+ __asm__ __volatile__ ("addi $7,$t5,77":::"t5");
+ __asm__ __volatile__ ("addi $7,$t6,77":::"t6");
+ __asm__ __volatile__ ("addi $7,$t7,77":::"t7");
+ __asm__ __volatile__ ("addi $7,$s0,77":::"s0");
+ __asm__ __volatile__ ("addi $7,$s1,77":::"s1");
+ __asm__ __volatile__ ("addi $7,$s2,77":::"s2");
+ __asm__ __volatile__ ("addi $7,$s3,77":::"s3");
+ __asm__ __volatile__ ("addi $7,$s4,77":::"s4");
+ __asm__ __volatile__ ("addi $7,$s5,77":::"s5");
+ __asm__ __volatile__ ("addi $7,$s6,77":::"s6");
+ __asm__ __volatile__ ("addi $7,$s7,77":::"s7");
+ __asm__ __volatile__ ("addi $7,$t8,77":::"t8");
+ __asm__ __volatile__ ("addi $7,$t9,77":::"t9");
+ __asm__ __volatile__ ("addi $7,$k0,77":::"k0");
+ __asm__ __volatile__ ("addi $7,$k1,77":::"k1");
+ __asm__ __volatile__ ("addi $7,$gp,77":::"gp");
+ __asm__ __volatile__ ("addi $7,$sp,77":::"sp");
+ __asm__ __volatile__ ("addi $7,$fp,77":::"fp");
+ __asm__ __volatile__ ("addi $7,$sp,77":::"$sp");
+ __asm__ __volatile__ ("addi $7,$fp,77":::"$fp");
+ __asm__ __volatile__ ("addi $7,$ra,77":::"ra");
+
+ __asm__ __volatile__ ("addi $7,$0,77":::"$0");
+ __asm__ __volatile__ (".set noat \n\t addi $7,$1,77":::"$1");
+ __asm__ __volatile__ ("addi $7,$2,77":::"$2");
+ __asm__ __volatile__ ("addi $7,$3,77":::"$3");
+ __asm__ __volatile__ ("addi $7,$4,77":::"$4");
+ __asm__ __volatile__ ("addi $7,$5,77":::"$5");
+ __asm__ __volatile__ ("addi $7,$6,77":::"$6");
+ __asm__ __volatile__ ("addi $7,$7,77":::"$7");
+ __asm__ __volatile__ ("addi $7,$8,77":::"$8");
+ __asm__ __volatile__ ("addi $7,$9,77":::"$9");
+ __asm__ __volatile__ ("addi $7,$10,77":::"$10");
+ __asm__ __volatile__ ("addi $7,$11,77":::"$10");
+ __asm__ __volatile__ ("addi $7,$12,77":::"$12");
+ __asm__ __volatile__ ("addi $7,$13,77":::"$13");
+ __asm__ __volatile__ ("addi $7,$14,77":::"$14");
+ __asm__ __volatile__ ("addi $7,$15,77":::"$15");
+ __asm__ __volatile__ ("addi $7,$16,77":::"$16");
+ __asm__ __volatile__ ("addi $7,$17,77":::"$17");
+ __asm__ __volatile__ ("addi $7,$18,77":::"$18");
+ __asm__ __volatile__ ("addi $7,$19,77":::"$19");
+ __asm__ __volatile__ ("addi $7,$20,77":::"$20");
+ __asm__ __volatile__ ("addi $7,$21,77":::"$21");
+ __asm__ __volatile__ ("addi $7,$22,77":::"$22");
+ __asm__ __volatile__ ("addi $7,$23,77":::"$23");
+ __asm__ __volatile__ ("addi $7,$24,77":::"$24");
+ __asm__ __volatile__ ("addi $7,$25,77":::"$25");
+ __asm__ __volatile__ ("addi $7,$26,77":::"$26");
+ __asm__ __volatile__ ("addi $7,$27,77":::"$27");
+ __asm__ __volatile__ ("addi $7,$28,77":::"$28");
+ __asm__ __volatile__ ("addi $7,$29,77":::"$29");
+ __asm__ __volatile__ ("addi $7,$30,77":::"$30");
+ __asm__ __volatile__ ("addi $7,$31,77":::"$31");
+
+}
diff --git a/clang/test/CodeGen/mips-constraint-regs.c b/clang/test/CodeGen/mips-constraint-regs.c
new file mode 100644
index 0000000..075be05
--- /dev/null
+++ b/clang/test/CodeGen/mips-constraint-regs.c
@@ -0,0 +1,44 @@
+// RUN: %clang -target mipsel-unknown-linux -ccc-clang-archs mipsel -S -o - -emit-llvm %s
+
+// This checks that the frontend will accept inline asm constraints
+// c', 'l' and 'x'. Semantic checking will happen in the
+// llvm backend. Any bad constraint letters will cause the frontend to
+// error out.
+
+int main()
+{
+ // 'c': 16 bit address register for Mips16, GPR for all others
+ // I am using 'c' to constrain both the target and one of the source
+ // registers. We are looking for syntactical correctness.
+ int __s, __v = 17;
+ int __t;
+ __asm__ __volatile__(
+ "addi %0,%1,%2 \n\t\t"
+ : "=c" (__t)
+ : "c" (__s), "I" (__v));
+
+ // 'l': lo register
+ // We are making it clear that destination register is lo with the
+ // use of the 'l' constraint ("=l").
+ int i_temp = 44;
+ int i_result;
+ __asm__ __volatile__(
+ "mtlo %1 \n\t\t"
+ : "=l" (i_result)
+ : "r" (i_temp)
+ : "lo");
+
+ // 'x': Combined lo/hi registers
+ // We are specifying that destination registers are the hi/lo pair with the
+ // use of the 'x' constraint ("=x").
+ int i_hi = 3;
+ int i_lo = 2;
+ long long ll_result = 0;
+ __asm__ __volatile__(
+ "mthi %1 \n\t\t"
+ "mtlo %2 \n\t\t"
+ : "=x" (ll_result)
+ : "r" (i_hi), "r" (i_lo)
+ : );
+ return 0;
+}
diff --git a/clang/test/CodeGen/mips64-class-return.cpp b/clang/test/CodeGen/mips64-class-return.cpp
new file mode 100644
index 0000000..dc9ec0f
--- /dev/null
+++ b/clang/test/CodeGen/mips64-class-return.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang -target mips64el-unknown-linux -ccc-clang-archs mips64el -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s
+
+class B0 {
+ double d;
+};
+
+class D0 : public B0 {
+ float f;
+};
+
+class B1 {
+};
+
+class D1 : public B1 {
+ double d;
+ float f;
+};
+
+class D2 : public B0 {
+ double d2;
+};
+
+extern D0 gd0;
+extern D1 gd1;
+extern D2 gd2;
+
+// CHECK: define { i64, i64 } @_Z4foo1v()
+D0 foo1(void) {
+ return gd0;
+}
+
+// CHECK: define { double, float } @_Z4foo2v()
+D1 foo2(void) {
+ return gd1;
+}
+
+// CHECK: define void @_Z4foo32D2(i64 %a0.coerce0, double %a0.coerce1)
+void foo3(D2 a0) {
+ gd2 = a0;
+}
+
+// CHECK: define void @_Z4foo42D0(%class.D0* nocapture byval %a0)
+void foo4(D0 a0) {
+ gd0 = a0;
+}
+
diff --git a/clang/test/CodeGen/mips64-f128-literal.c b/clang/test/CodeGen/mips64-f128-literal.c
new file mode 100644
index 0000000..2f01520
--- /dev/null
+++ b/clang/test/CodeGen/mips64-f128-literal.c
@@ -0,0 +1,9 @@
+// RUN: %clang -target mips64el-unknown-linux -ccc-clang-archs mips64el -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s
+
+typedef long double LD;
+
+// CHECK: ret fp128
+
+LD foo0() {
+ return 2.625L;
+}
diff --git a/clang/test/CodeGen/mips64-nontrivial-return.cpp b/clang/test/CodeGen/mips64-nontrivial-return.cpp
new file mode 100644
index 0000000..8aff9ab
--- /dev/null
+++ b/clang/test/CodeGen/mips64-nontrivial-return.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang -target mips64el-unknown-linux -ccc-clang-archs mips64el -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s
+
+class B {
+public:
+ virtual ~B() {}
+};
+
+class D : public B {
+};
+
+extern D gd0;
+
+// CHECK: _Z4foo1v(%class.D* noalias nocapture sret
+
+D foo1(void) {
+ return gd0;
+}
diff --git a/clang/test/CodeGen/mips64-padding-arg.c b/clang/test/CodeGen/mips64-padding-arg.c
new file mode 100644
index 0000000..b4dcfba
--- /dev/null
+++ b/clang/test/CodeGen/mips64-padding-arg.c
@@ -0,0 +1,43 @@
+// RUN: %clang -target mips64el-unknown-linux -ccc-clang-archs mips64el -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s
+
+typedef struct {
+ double d;
+ long double ld;
+} S0;
+
+// Insert padding to ensure arguments of type S0 are aligned to 16-byte boundaries.
+
+// CHECK: define void @foo1(i32 %a0, i64, double %a1.coerce0, i64 %a1.coerce1, i64 %a1.coerce2, i64 %a1.coerce3, double %a2.coerce0, i64 %a2.coerce1, i64 %a2.coerce2, i64 %a2.coerce3, i32 %b, i64, double %a3.coerce0, i64 %a3.coerce1, i64 %a3.coerce2, i64 %a3.coerce3)
+// CHECK: tail call void @foo2(i32 1, i32 2, i32 %a0, i64 undef, double %a1.coerce0, i64 %a1.coerce1, i64 %a1.coerce2, i64 %a1.coerce3, double %a2.coerce0, i64 %a2.coerce1, i64 %a2.coerce2, i64 %a2.coerce3, i32 3, i64 undef, double %a3.coerce0, i64 %a3.coerce1, i64 %a3.coerce2, i64 %a3.coerce3)
+// CHECK: declare void @foo2(i32, i32, i32, i64, double, i64, i64, i64, double, i64, i64, i64, i32, i64, double, i64, i64, i64)
+
+extern void foo2(int, int, int, S0, S0, int, S0);
+
+void foo1(int a0, S0 a1, S0 a2, int b, S0 a3) {
+ foo2(1, 2, a0, a1, a2, 3, a3);
+}
+
+// Insert padding before long double argument.
+//
+// CHECK: define void @foo3(i32 %a0, i64, fp128 %a1)
+// CHECK: tail call void @foo4(i32 1, i32 2, i32 %a0, i64 undef, fp128 %a1)
+// CHECK: declare void @foo4(i32, i32, i32, i64, fp128)
+
+extern void foo4(int, int, int, long double);
+
+void foo3(int a0, long double a1) {
+ foo4(1, 2, a0, a1);
+}
+
+// Insert padding after hidden argument.
+//
+// CHECK: define void @foo5(%struct.S0* noalias sret %agg.result, i64, fp128 %a0)
+// CHECK: call void @foo6(%struct.S0* sret %agg.result, i32 1, i32 2, i64 undef, fp128 %a0)
+// CHECK: declare void @foo6(%struct.S0* sret, i32, i32, i64, fp128)
+
+extern S0 foo6(int, int, long double);
+
+S0 foo5(long double a0) {
+ return foo6(1, 2, a0);
+}
+
diff --git a/clang/test/CodeGen/misaligned-param.c b/clang/test/CodeGen/misaligned-param.c
new file mode 100644
index 0000000..53f1f29
--- /dev/null
+++ b/clang/test/CodeGen/misaligned-param.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -triple i386-apple-darwin -emit-llvm -o - | FileCheck %s
+// Misaligned parameter must be memcpy'd to correctly aligned temporary.
+
+struct s { int x; long double y; };
+long double foo(struct s x, int i, struct s y) {
+// CHECK: foo
+// CHECK: %x = alloca %struct.s, align 16
+// CHECK: %y = alloca %struct.s, align 16
+// CHECK: memcpy
+// CHECK: memcpy
+// CHECK: bar
+ return bar(&x, &y);
+}
diff --git a/clang/test/CodeGen/mms-bitfields.c b/clang/test/CodeGen/mms-bitfields.c
new file mode 100644
index 0000000..1617e8a
--- /dev/null
+++ b/clang/test/CodeGen/mms-bitfields.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -mms-bitfields -emit-llvm %s -o - | FileCheck %s
+
+struct s1 {
+ int f32;
+ long long f64;
+} s1;
+
+// CHECK: %struct.s1 = type { i32, [4 x i8], i64 }
+
+struct s2 {
+ int f32;
+ long long f64[4];
+} s2;
+
+// CHECK: %struct.s2 = type { i32, [4 x i8], [4 x i64] }
+
+struct s3 {
+ int f32;
+ struct s1 s;
+} s3;
+
+// CHECK: %struct.s3 = type { i32, [4 x i8], %struct.s1 }
diff --git a/clang/test/CodeGen/mmx-builtins.c b/clang/test/CodeGen/mmx-builtins.c
new file mode 100644
index 0000000..b142684
--- /dev/null
+++ b/clang/test/CodeGen/mmx-builtins.c
@@ -0,0 +1,453 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +ssse3 -S -o - | FileCheck %s
+
+// FIXME: Disable inclusion of mm_malloc.h, our current implementation is broken
+// on win32 since we don't generally know how to find errno.h.
+#define __MM_MALLOC_H
+
+#include <tmmintrin.h>
+
+__m64 test1(__m64 a, __m64 b) {
+ // CHECK: phaddw
+ return _mm_hadd_pi16(a, b);
+}
+
+__m64 test2(__m64 a, __m64 b) {
+ // CHECK: phaddd
+ return _mm_hadd_pi32(a, b);
+}
+
+__m64 test3(__m64 a, __m64 b) {
+ // CHECK: phaddsw
+ return _mm_hadds_pi16(a, b);
+}
+
+__m64 test4(__m64 a, __m64 b) {
+ // CHECK: phsubw
+ return _mm_hsub_pi16(a, b);
+}
+
+__m64 test5(__m64 a, __m64 b) {
+ // CHECK: phsubd
+ return _mm_hsub_pi32(a, b);
+}
+
+__m64 test6(__m64 a, __m64 b) {
+ // CHECK: phsubsw
+ return _mm_hsubs_pi16(a, b);
+}
+
+__m64 test7(__m64 a, __m64 b) {
+ // CHECK: pmaddubsw
+ return _mm_maddubs_pi16(a, b);
+}
+
+__m64 test8(__m64 a, __m64 b) {
+ // CHECK: pmulhrsw
+ return _mm_mulhrs_pi16(a, b);
+}
+
+__m64 test9(__m64 a, __m64 b) {
+ // CHECK: pshufb
+ return _mm_shuffle_pi8(a, b);
+}
+
+__m64 test10(__m64 a, __m64 b) {
+ // CHECK: psignb
+ return _mm_sign_pi8(a, b);
+}
+
+__m64 test11(__m64 a, __m64 b) {
+ // CHECK: psignw
+ return _mm_sign_pi16(a, b);
+}
+
+__m64 test12(__m64 a, __m64 b) {
+ // CHECK: psignd
+ return _mm_sign_pi32(a, b);
+}
+
+__m64 test13(__m64 a) {
+ // CHECK: pabsb
+ return _mm_abs_pi8(a);
+}
+
+__m64 test14(__m64 a) {
+ // CHECK: pabsw
+ return _mm_abs_pi16(a);
+}
+
+__m64 test15(__m64 a) {
+ // CHECK: pabsd
+ return _mm_abs_pi32(a);
+}
+
+__m64 test16(__m64 a, __m64 b) {
+ // CHECK: palignr
+ return _mm_alignr_pi8(a, b, 2);
+}
+
+__m64 test17(__m128d a) {
+ // CHECK: cvtpd2pi
+ return _mm_cvtpd_pi32(a);
+}
+
+__m64 test18(__m128d a) {
+ // CHECK: cvttpd2pi
+ return _mm_cvttpd_pi32(a);
+}
+
+__m128d test19(__m64 a) {
+ // CHECK: cvtpi2pd
+ return _mm_cvtpi32_pd(a);
+}
+
+__m64 test20(__m64 a, __m64 b) {
+ // CHECK: pmuludq
+ return _mm_mul_su32(a, b);
+}
+
+__m64 test21(__m64 a) {
+ // CHECK: pshufw
+ return _mm_shuffle_pi16(a, 3);
+}
+
+__m64 test22(__m64 a, __m64 b) {
+ // CHECK: pmulhuw
+ return _mm_mulhi_pu16(a, b);
+}
+
+void test23(__m64 d, __m64 n, char *p) {
+ // CHECK: maskmovq
+ _mm_maskmove_si64(d, n, p);
+}
+
+int test24(__m64 a) {
+ // CHECK: pmovmskb
+ return _mm_movemask_pi8(a);
+}
+
+void test25(__m64 *p, __m64 a) {
+ // CHECK: movntq
+ _mm_stream_pi(p, a);
+}
+
+__m64 test26(__m64 a, __m64 b) {
+ // CHECK: pavgb
+ return _mm_avg_pu8(a, b);
+}
+
+__m64 test27(__m64 a, __m64 b) {
+ // CHECK: pavgw
+ return _mm_avg_pu16(a, b);
+}
+
+__m64 test28(__m64 a, __m64 b) {
+ // CHECK: pmaxub
+ return _mm_max_pu8(a, b);
+}
+
+__m64 test29(__m64 a, __m64 b) {
+ // CHECK: pmaxsw
+ return _mm_max_pi16(a, b);
+}
+
+__m64 test30(__m64 a, __m64 b) {
+ // CHECK: pminub
+ return _mm_min_pu8(a, b);
+}
+
+__m64 test31(__m64 a, __m64 b) {
+ // CHECK: pminsw
+ return _mm_min_pi16(a, b);
+}
+
+__m64 test32(__m64 a, __m64 b) {
+ // CHECK: psadbw
+ return _mm_sad_pu8(a, b);
+}
+
+__m64 test33(__m64 a, __m64 b) {
+ // CHECK: paddb
+ return _mm_add_pi8(a, b);
+}
+
+__m64 test34(__m64 a, __m64 b) {
+ // CHECK: paddw
+ return _mm_add_pi16(a, b);
+}
+
+__m64 test35(__m64 a, __m64 b) {
+ // CHECK: paddd
+ return _mm_add_pi32(a, b);
+}
+
+__m64 test36(__m64 a, __m64 b) {
+ // CHECK: paddq
+ return __builtin_ia32_paddq(a, b);
+}
+
+__m64 test37(__m64 a, __m64 b) {
+ // CHECK: paddsb
+ return _mm_adds_pi8(a, b);
+}
+
+__m64 test38(__m64 a, __m64 b) {
+ // CHECK: paddsw
+ return _mm_adds_pi16(a, b);
+}
+
+__m64 test39(__m64 a, __m64 b) {
+ // CHECK: paddusb
+ return _mm_adds_pu8(a, b);
+}
+
+__m64 test40(__m64 a, __m64 b) {
+ // CHECK: paddusw
+ return _mm_adds_pu16(a, b);
+}
+
+__m64 test41(__m64 a, __m64 b) {
+ // CHECK: psubb
+ return _mm_sub_pi8(a, b);
+}
+
+__m64 test42(__m64 a, __m64 b) {
+ // CHECK: psubw
+ return _mm_sub_pi16(a, b);
+}
+
+__m64 test43(__m64 a, __m64 b) {
+ // CHECK: psubd
+ return _mm_sub_pi32(a, b);
+}
+
+__m64 test44(__m64 a, __m64 b) {
+ // CHECK: psubq
+ return __builtin_ia32_psubq(a, b);
+}
+
+__m64 test45(__m64 a, __m64 b) {
+ // CHECK: psubsb
+ return _mm_subs_pi8(a, b);
+}
+
+__m64 test46(__m64 a, __m64 b) {
+ // CHECK: psubsw
+ return _mm_subs_pi16(a, b);
+}
+
+__m64 test47(__m64 a, __m64 b) {
+ // CHECK: psubusb
+ return _mm_subs_pu8(a, b);
+}
+
+__m64 test48(__m64 a, __m64 b) {
+ // CHECK: psubusw
+ return _mm_subs_pu16(a, b);
+}
+
+__m64 test49(__m64 a, __m64 b) {
+ // CHECK: pmaddwd
+ return _mm_madd_pi16(a, b);
+}
+
+__m64 test50(__m64 a, __m64 b) {
+ // CHECK: pmulhw
+ return _mm_mulhi_pi16(a, b);
+}
+
+__m64 test51(__m64 a, __m64 b) {
+ // CHECK: pmullw
+ return _mm_mullo_pi16(a, b);
+}
+
+__m64 test52(__m64 a, __m64 b) {
+ // CHECK: pmullw
+ return _mm_mullo_pi16(a, b);
+}
+
+__m64 test53(__m64 a, __m64 b) {
+ // CHECK: pand
+ return _mm_and_si64(a, b);
+}
+
+__m64 test54(__m64 a, __m64 b) {
+ // CHECK: pandn
+ return _mm_andnot_si64(a, b);
+}
+
+__m64 test55(__m64 a, __m64 b) {
+ // CHECK: por
+ return _mm_or_si64(a, b);
+}
+
+__m64 test56(__m64 a, __m64 b) {
+ // CHECK: pxor
+ return _mm_xor_si64(a, b);
+}
+
+__m64 test57(__m64 a, __m64 b) {
+ // CHECK: pavgb
+ return _mm_avg_pu8(a, b);
+}
+
+__m64 test58(__m64 a, __m64 b) {
+ // CHECK: pavgw
+ return _mm_avg_pu16(a, b);
+}
+
+__m64 test59(__m64 a, __m64 b) {
+ // CHECK: psllw
+ return _mm_sll_pi16(a, b);
+}
+
+__m64 test60(__m64 a, __m64 b) {
+ // CHECK: pslld
+ return _mm_sll_pi32(a, b);
+}
+
+__m64 test61(__m64 a, __m64 b) {
+ // CHECK: psllq
+ return _mm_sll_si64(a, b);
+}
+
+__m64 test62(__m64 a, __m64 b) {
+ // CHECK: psrlw
+ return _mm_srl_pi16(a, b);
+}
+
+__m64 test63(__m64 a, __m64 b) {
+ // CHECK: psrld
+ return _mm_srl_pi32(a, b);
+}
+
+__m64 test64(__m64 a, __m64 b) {
+ // CHECK: psrlq
+ return _mm_srl_si64(a, b);
+}
+
+__m64 test65(__m64 a, __m64 b) {
+ // CHECK: psraw
+ return _mm_sra_pi16(a, b);
+}
+
+__m64 test66(__m64 a, __m64 b) {
+ // CHECK: psrad
+ return _mm_sra_pi32(a, b);
+}
+
+__m64 test67(__m64 a) {
+ // CHECK: psllw
+ return _mm_slli_pi16(a, 3);
+}
+
+__m64 test68(__m64 a) {
+ // CHECK: pslld
+ return _mm_slli_pi32(a, 3);
+}
+
+__m64 test69(__m64 a) {
+ // CHECK: psllq
+ return _mm_slli_si64(a, 3);
+}
+
+__m64 test70(__m64 a) {
+ // CHECK: psrlw
+ return _mm_srli_pi16(a, 3);
+}
+
+__m64 test71(__m64 a) {
+ // CHECK: psrld
+ return _mm_srli_pi32(a, 3);
+}
+
+__m64 test72(__m64 a) {
+ // CHECK: psrlq
+ return _mm_srli_si64(a, 3);
+}
+
+__m64 test73(__m64 a) {
+ // CHECK: psraw
+ return _mm_srai_pi16(a, 3);
+}
+
+__m64 test74(__m64 a) {
+ // CHECK: psrad
+ return _mm_srai_pi32(a, 3);
+}
+
+__m64 test75(__m64 a, __m64 b) {
+ // CHECK: packsswb
+ return _mm_packs_pi16(a, b);
+}
+
+__m64 test76(__m64 a, __m64 b) {
+ // CHECK: packssdw
+ return _mm_packs_pi32(a, b);
+}
+
+__m64 test77(__m64 a, __m64 b) {
+ // CHECK: packuswb
+ return _mm_packs_pu16(a, b);
+}
+
+__m64 test78(__m64 a, __m64 b) {
+ // CHECK: punpckhbw
+ return _mm_unpackhi_pi8(a, b);
+}
+
+__m64 test79(__m64 a, __m64 b) {
+ // CHECK: punpckhwd
+ return _mm_unpackhi_pi16(a, b);
+}
+
+__m64 test80(__m64 a, __m64 b) {
+ // CHECK: punpckhdq
+ return _mm_unpackhi_pi32(a, b);
+}
+
+__m64 test81(__m64 a, __m64 b) {
+ // CHECK: punpcklbw
+ return _mm_unpacklo_pi8(a, b);
+}
+
+__m64 test82(__m64 a, __m64 b) {
+ // CHECK: punpcklwd
+ return _mm_unpacklo_pi16(a, b);
+}
+
+__m64 test83(__m64 a, __m64 b) {
+ // CHECK: punpckldq
+ return _mm_unpacklo_pi32(a, b);
+}
+
+__m64 test84(__m64 a, __m64 b) {
+ // CHECK: pcmpeqb
+ return _mm_cmpeq_pi8(a, b);
+}
+
+__m64 test85(__m64 a, __m64 b) {
+ // CHECK: pcmpeqw
+ return _mm_cmpeq_pi16(a, b);
+}
+
+__m64 test86(__m64 a, __m64 b) {
+ // CHECK: pcmpeqd
+ return _mm_cmpeq_pi32(a, b);
+}
+
+__m64 test87(__m64 a, __m64 b) {
+ // CHECK: pcmpgtb
+ return _mm_cmpgt_pi8(a, b);
+}
+
+__m64 test88(__m64 a, __m64 b) {
+ // CHECK: pcmpgtw
+ return _mm_cmpgt_pi16(a, b);
+}
+
+__m64 test89(__m64 a, __m64 b) {
+ // CHECK: pcmpgtd
+ return _mm_cmpgt_pi32(a, b);
+}
diff --git a/clang/test/CodeGen/mmx-inline-asm.c b/clang/test/CodeGen/mmx-inline-asm.c
new file mode 100644
index 0000000..635e2a6
--- /dev/null
+++ b/clang/test/CodeGen/mmx-inline-asm.c
@@ -0,0 +1,22 @@
+// RUN: %clang -mmmx -target i386-unknown-unknown -emit-llvm -S %s -o - | FileCheck %s
+// <rdar://problem/9091220>
+#include <mmintrin.h>
+
+// CHECK: { x86_mmx, x86_mmx, x86_mmx, x86_mmx, x86_mmx, x86_mmx, x86_mmx }
+
+void foo(long long fill) {
+ __m64 vfill = _mm_cvtsi64_m64(fill);
+ __m64 v1, v2, v3, v4, v5, v6, v7;
+
+ __asm__ __volatile__ (
+ "\tmovq %7, %0\n"
+ "\tmovq %7, %1\n"
+ "\tmovq %7, %2\n"
+ "\tmovq %7, %3\n"
+ "\tmovq %7, %4\n"
+ "\tmovq %7, %5\n"
+ "\tmovq %7, %6"
+ : "=&y" (v1), "=&y" (v2), "=&y" (v3),
+ "=&y" (v4), "=&y" (v5), "=&y" (v6), "=y" (v7)
+ : "y" (vfill));
+}
diff --git a/clang/test/CodeGen/mmx-shift-with-immediate.c b/clang/test/CodeGen/mmx-shift-with-immediate.c
new file mode 100644
index 0000000..ecd1881
--- /dev/null
+++ b/clang/test/CodeGen/mmx-shift-with-immediate.c
@@ -0,0 +1,23 @@
+// RUN: %clang -mmmx -target i386-unknown-unknown -emit-llvm -S %s -o - | FileCheck %s
+#include <mmintrin.h>
+
+void shift(__m64 a, __m64 b, int c) {
+ // CHECK: x86_mmx @llvm.x86.mmx.pslli.w(x86_mmx %{{.*}}, i32 {{.*}})
+ _mm_slli_pi16(a, c);
+ // CHECK: x86_mmx @llvm.x86.mmx.pslli.d(x86_mmx %{{.*}}, i32 {{.*}})
+ _mm_slli_pi32(a, c);
+ // CHECK: x86_mmx @llvm.x86.mmx.pslli.q(x86_mmx %{{.*}}, i32 {{.*}})
+ _mm_slli_si64(a, c);
+
+ // CHECK: x86_mmx @llvm.x86.mmx.psrli.w(x86_mmx %{{.*}}, i32 {{.*}})
+ _mm_srli_pi16(a, c);
+ // CHECK: x86_mmx @llvm.x86.mmx.psrli.d(x86_mmx %{{.*}}, i32 {{.*}})
+ _mm_srli_pi32(a, c);
+ // CHECK: x86_mmx @llvm.x86.mmx.psrli.q(x86_mmx %{{.*}}, i32 {{.*}})
+ _mm_srli_si64(a, c);
+
+ // CHECK: x86_mmx @llvm.x86.mmx.psrai.w(x86_mmx %{{.*}}, i32 {{.*}})
+ _mm_srai_pi16(a, c);
+ // CHECK: x86_mmx @llvm.x86.mmx.psrai.d(x86_mmx %{{.*}}, i32 {{.*}})
+ _mm_srai_pi32(a, c);
+}
diff --git a/clang/test/CodeGen/mrtd.c b/clang/test/CodeGen/mrtd.c
new file mode 100644
index 0000000..d7729a5
--- /dev/null
+++ b/clang/test/CodeGen/mrtd.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -mrtd -triple i386-unknown-freebsd9.0 -emit-llvm -o - %s | FileCheck %s
+
+void baz(int arg);
+
+// CHECK: define x86_stdcallcc void @foo(i32 %arg) nounwind
+void foo(int arg) {
+// CHECK: call x86_stdcallcc i32 bitcast (i32 (...)* @bar to i32 (i32)*)(
+ bar(arg);
+// CHECK: call x86_stdcallcc void @baz(i32
+ baz(arg);
+}
+
+// CHECK: declare x86_stdcallcc i32 @bar(...)
+
+// CHECK: declare x86_stdcallcc void @baz(i32)
diff --git a/clang/test/CodeGen/ms-anonymous-struct.c b/clang/test/CodeGen/ms-anonymous-struct.c
new file mode 100644
index 0000000..b41caab
--- /dev/null
+++ b/clang/test/CodeGen/ms-anonymous-struct.c
@@ -0,0 +1,99 @@
+// RUN: %clang_cc1 -fms-extensions -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: %struct.test = type { i32, %struct.nested2, i32 }
+// CHECK: %struct.nested2 = type { i32, %struct.nested1, i32 }
+// CHECK: %struct.nested1 = type { i32, i32 }
+typedef struct nested1 {
+ int a1;
+ int b1;
+} NESTED1;
+
+struct nested2 {
+ int a;
+ NESTED1;
+ int b;
+};
+
+struct test {
+ int x;
+ struct nested2;
+ int y;
+};
+
+
+void foo()
+{
+ // CHECK: %var = alloca %struct.test, align 4
+ struct test var;
+
+ // CHECK: getelementptr inbounds %struct.test* %var, i32 0, i32 1
+ // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 0
+ // CHECK-NEXT: load i32* %{{.*}}, align 4
+ var.a;
+
+ // CHECK-NEXT: getelementptr inbounds %struct.test* %var, i32 0, i32 1
+ // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 2
+ // CHECK-NEXT: load i32* %{{.*}}, align 4
+ var.b;
+
+ // CHECK-NEXT: getelementptr inbounds %struct.test* %var, i32 0, i32 1
+ // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 1
+ // CHECK-NEXT: getelementptr inbounds %struct.nested1* %{{.*}}, i32 0, i32 0
+ // CHECK-NEXT: load i32* %{{.*}}, align 4
+ var.a1;
+
+ // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}var, i32 0, i32 1
+ // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 1
+ // CHECK-NEXT: getelementptr inbounds %struct.nested1* %{{.*}}, i32 0, i32 1
+ // CHECK-NEXT: load i32* %{{.*}}, align 4
+ var.b1;
+
+ // CHECK-NEXT: getelementptr inbounds %struct.test* %var, i32 0, i32 0
+ // CHECK-NEXT: load i32* %{{.*}}, align 4
+ var.x;
+
+ // CHECK-NEXT: getelementptr inbounds %struct.test* %var, i32 0, i32 2
+ // CHECK-NEXT: load i32* %{{.*}}, align 4
+ var.y;
+}
+
+void foo2(struct test* var)
+{
+ // CHECK: alloca %struct.test*, align
+ // CHECK-NEXT: store %struct.test* %var, %struct.test** %{{.*}}, align
+ // CHECK-NEXT: load %struct.test** %{{.*}}, align
+ // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 1
+ // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 0
+ // CHECK-NEXT: load i32* %{{.*}}, align 4
+ var->a;
+
+ // CHECK-NEXT: load %struct.test** %{{.*}}, align
+ // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 1
+ // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 2
+ // CHECK-NEXT: load i32* %{{.*}}, align 4
+ var->b;
+
+ // CHECK-NEXT: load %struct.test** %{{.*}}, align
+ // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 1
+ // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 1
+ // CHECK-NEXT: getelementptr inbounds %struct.nested1* %{{.*}}, i32 0, i32 0
+ // CHECK-NEXT: load i32* %{{.*}}, align 4
+ var->a1;
+
+ // CHECK-NEXT: load %struct.test** %{{.*}}, align
+ // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 1
+ // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 1
+ // CHECK-NEXT: getelementptr inbounds %struct.nested1* %{{.*}}, i32 0, i32 1
+ // CHECK-NEXT: load i32* %{{.*}}, align 4
+ var->b1;
+
+ // CHECK-NEXT: load %struct.test** %{{.*}}, align
+ // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 0
+ // CHECK-NEXT: load i32* %{{.*}}, align 4
+ var->x;
+
+ // CHECK-NEXT: load %struct.test** %{{.*}}, align
+ // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 2
+ // CHECK-NEXT: load i32* %{{.*}}, align 4
+ var->y;
+}
diff --git a/clang/test/CodeGen/ms-declspecs.c b/clang/test/CodeGen/ms-declspecs.c
new file mode 100644
index 0000000..d3235ae
--- /dev/null
+++ b/clang/test/CodeGen/ms-declspecs.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -fms-compatibility -o - | FileCheck %s
+
+// CHECK: define void @t3() nounwind noinline naked {
+__declspec(naked) void t3() {}
+
+// CHECK: define void @t22() nounwind
+void __declspec(nothrow) t22();
+void t22() {}
+
+// CHECK: define void @t2() nounwind noinline {
+__declspec(noinline) void t2() {}
+
+// CHECK: call void @f20_t()
+// CHECK: noreturn
+__declspec(noreturn) void f20_t(void);
+void f20(void) { f20_t(); }
diff --git a/clang/test/CodeGen/ms_struct-bitfield-1.c b/clang/test/CodeGen/ms_struct-bitfield-1.c
new file mode 100644
index 0000000..25c0ba2
--- /dev/null
+++ b/clang/test/CodeGen/ms_struct-bitfield-1.c
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-darwin9 %s
+// rdar://8823265
+
+#define ATTR __attribute__((__ms_struct__))
+
+struct {
+ unsigned int bf_1 : 12;
+ unsigned int : 0;
+ unsigned int bf_2 : 12;
+} ATTR t1;
+static int a1[(sizeof(t1) == 8) -1];
+
+struct
+{
+ char foo : 4;
+ short : 0;
+ char bar;
+} ATTR t2;
+static int a2[(sizeof(t2) == 4) -1];
+
+#pragma ms_struct on
+struct
+{
+ char foo : 4;
+ short : 0;
+ char bar;
+} t3;
+#pragma ms_struct off
+static int a3[(sizeof(t3) == 4) -1];
+
+struct
+{
+ char foo : 6;
+ long : 0;
+} ATTR t4;
+static int a4[(sizeof(t4) == 8) -1];
+
+struct
+{
+ char foo : 4;
+ short : 0;
+ char bar : 8;
+} ATTR t5;
+static int a5[(sizeof(t5) == 4) -1];
+
+struct
+{
+ char foo : 4;
+ short : 0;
+ long : 0;
+ char bar;
+} ATTR t6;
+static int a6[(sizeof(t6) == 4) -1];
+
+struct
+{
+ char foo : 4;
+ long : 0;
+ short : 0;
+ char bar;
+} ATTR t7;
+static int a7[(sizeof(t7) == 16) -1];
+
+struct
+{
+ char foo : 4;
+ short : 0;
+ long : 0;
+ char bar:7;
+} ATTR t8;
+static int a8[(sizeof(t8) == 4) -1];
+
+struct
+{
+ char foo : 4;
+ long : 0;
+ short : 0;
+ char bar: 8;
+} ATTR t9;
+static int a9[(sizeof(t9) == 16) -1];
+
+struct
+{
+ char foo : 4;
+ char : 0;
+ short : 0;
+ int : 0;
+ long :0;
+ char bar;
+} ATTR t10;
+static int a10[(sizeof(t10) == 2) -1];
diff --git a/clang/test/CodeGen/ms_struct-bitfield-2.c b/clang/test/CodeGen/ms_struct-bitfield-2.c
new file mode 100644
index 0000000..36e0172
--- /dev/null
+++ b/clang/test/CodeGen/ms_struct-bitfield-2.c
@@ -0,0 +1,135 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-darwin9 %s
+// rdar://8823265
+
+#define ATTR __attribute__((__ms_struct__))
+
+#define size_struct_0 1
+#define size_struct_1 4
+#define size_struct_2 24
+#define size_struct_3 8
+#define size_struct_4 32
+#define size_struct_5 12
+#define size_struct_6 40
+#define size_struct_7 8
+#define size_struct_8 20
+#define size_struct_9 32
+
+struct _struct_0
+{
+ char member_0;
+} ATTR;
+typedef struct _struct_0 struct_0;
+
+struct _struct_1
+{
+ char member_0;
+ short member_1:13;
+} ATTR;
+typedef struct _struct_1 struct_1;
+
+struct _struct_2
+{
+ double member_0;
+ unsigned char member_1:8;
+ int member_2:32;
+ unsigned char member_3:5;
+ short member_4:14;
+ short member_5:13;
+ unsigned char:0;
+} ATTR;
+typedef struct _struct_2 struct_2;
+
+struct _struct_3
+{
+ unsigned int member_0:26;
+ unsigned char member_1:2;
+
+} ATTR;
+typedef struct _struct_3 struct_3;
+
+struct _struct_4
+{
+ unsigned char member_0:7;
+ double member_1;
+ double member_2;
+ short member_3:5;
+ char member_4:2;
+
+} ATTR;
+typedef struct _struct_4 struct_4;
+
+struct _struct_5
+{
+ unsigned short member_0:12;
+ int member_1:1;
+ unsigned short member_2:6;
+
+} ATTR;
+typedef struct _struct_5 struct_5;
+
+struct _struct_6
+{
+ unsigned char member_0:7;
+ unsigned int member_1:25;
+ char member_2:1;
+ double member_3;
+ short member_4:9;
+ double member_5;
+
+} ATTR;
+typedef struct _struct_6 struct_6;
+
+struct _struct_7
+{
+ double member_0;
+
+} ATTR;
+typedef struct _struct_7 struct_7;
+
+struct _struct_8
+{
+ unsigned char member_0:7;
+ int member_1:11;
+ int member_2:5;
+ int:0;
+ char member_4:8;
+ unsigned short member_5:4;
+ unsigned char member_6:3;
+ int member_7:23;
+
+} ATTR;
+typedef struct _struct_8 struct_8;
+
+struct _struct_9
+{
+ double member_0;
+ unsigned int member_1:6;
+ int member_2:17;
+ double member_3;
+ unsigned int member_4:22;
+
+} ATTR;
+typedef struct _struct_9 struct_9;
+
+struct_0 test_struct_0 = { 123 };
+struct_1 test_struct_1 = { 82, 1081 };
+struct_2 test_struct_2 = { 20.0, 31, 407760, 1, 14916, 6712 };
+struct_3 test_struct_3 = { 64616999, 1 };
+struct_4 test_struct_4 = { 61, 20.0, 20.0, 12, 0 };
+struct_5 test_struct_5 = { 909, 1, 57 };
+struct_6 test_struct_6 = { 12, 21355796, 0, 20.0, 467, 20.0 };
+struct_7 test_struct_7 = { 20.0 };
+struct_8 test_struct_8 = { 126, 1821, 22, 125, 6, 0, 2432638 };
+struct_9 test_struct_9 = { 20.0, 3, 23957, 20.0, 1001631 };
+
+
+static int a0[(sizeof (struct_0) == size_struct_0) -1];
+static int a1[(sizeof (struct_1) == size_struct_1) -1];
+static int a2[(sizeof (struct_2) == size_struct_2) -1];
+static int a3[(sizeof (struct_3) == size_struct_3) -1];
+static int a4[(sizeof (struct_4) == size_struct_4) -1];
+static int a5[(sizeof (struct_5) == size_struct_5) -1];
+static int a6[(sizeof (struct_6) == size_struct_6) -1];
+static int a7[(sizeof (struct_7) == size_struct_7) -1];
+static int a8[(sizeof (struct_8) == size_struct_8) -1];
+static int a9[(sizeof (struct_9) == size_struct_9) -1];
diff --git a/clang/test/CodeGen/ms_struct-bitfield-3.c b/clang/test/CodeGen/ms_struct-bitfield-3.c
new file mode 100644
index 0000000..0eba435
--- /dev/null
+++ b/clang/test/CodeGen/ms_struct-bitfield-3.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple i386-apple-darwin9 %s
+// rdar://8823265
+
+#define ATTR __attribute__((__ms_struct__))
+
+struct _struct_0
+{
+ int member_0 : 25 ;
+ short member_1 : 6 ;
+ char member_2 : 2 ;
+ unsigned short member_3 : 1 ;
+ unsigned char member_4 : 7 ;
+ short member_5 : 16 ;
+ int : 0 ;
+ char member_7 ;
+
+} ATTR;
+
+typedef struct _struct_0 struct_0;
+
+#define size_struct_0 20
+
+struct_0 test_struct_0 = { 18557917, 17, 3, 0, 80, 6487, 93 };
+static int a[(size_struct_0 == sizeof (struct_0)) -1];
+
+struct _struct_1 {
+ int d;
+ unsigned char a;
+ unsigned short b:7;
+ char c;
+} ATTR;
+
+typedef struct _struct_1 struct_1;
+
+#define size_struct_1 12
+
+struct_1 test_struct_1 = { 18557917, 'a', 3, 'b' };
+
+static int a1[(size_struct_1 == sizeof (struct_1)) -1];
+
+struct ten {
+ long long a:3;
+ long long b:3;
+ char c;
+} __attribute__ ((ms_struct));
+
+#define size_struct_2 16
+
+static int a2[(size_struct_2 == sizeof (struct ten)) -1];
diff --git a/clang/test/CodeGen/ms_struct-bitfield-init.c b/clang/test/CodeGen/ms_struct-bitfield-init.c
new file mode 100644
index 0000000..7a483fb
--- /dev/null
+++ b/clang/test/CodeGen/ms_struct-bitfield-init.c
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-darwin9 %s
+// rdar://8823265
+
+extern void abort(void);
+#define ATTR __attribute__((__ms_struct__))
+
+struct
+{
+ char foo;
+ long : 0;
+ char : 0;
+ int : 0;
+ char bar;
+} ATTR t1 = {'a', 'b'};
+
+struct
+{
+ char bar0;
+ long : 0;
+ int : 0;
+ char bar1;
+ char bar2;
+ long : 0;
+ char bar3;
+ char bar4;
+ char : 0;
+ char bar5;
+ char bar6;
+ char : 0;
+ char bar7;
+ char bar8;
+} ATTR t2 = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'};
+
+struct {
+ int : 0;
+ int i1;
+ int : 0;
+ int i2;
+ int : 0;
+ int i3;
+ int : 0;
+ int i4;
+} t3 = {1,2,3,4};
+
+int main() {
+ if (sizeof(t1) != 2)
+ abort();
+ if (t1.foo != 'a')
+ abort();
+ if (t1.bar != 'b')
+ abort();
+ t1.foo = 'c';
+ t1.bar = 'd';
+ if (t1.foo != 'c')
+ abort();
+ if (t1.bar != 'd')
+ abort();
+ if (sizeof(t2) != 9)
+ abort();
+ if (t2.bar0 != 'a' || t2.bar8 != 'i')
+ abort();
+ if (sizeof(t3) != 16)
+ abort();
+ if (t3.i1 != 1 || t3.i4 != 4)
+ abort();
+ return 0;
+}
+
diff --git a/clang/test/CodeGen/ms_struct-bitfield.c b/clang/test/CodeGen/ms_struct-bitfield.c
new file mode 100644
index 0000000..a8f4c91
--- /dev/null
+++ b/clang/test/CodeGen/ms_struct-bitfield.c
@@ -0,0 +1,131 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-darwin9 %s
+// rdar://8823265
+
+#define ATTR __attribute__((__ms_struct__))
+
+struct
+{
+ char foo;
+ long : 0;
+ char bar;
+} ATTR t1;
+
+struct
+{
+ char foo;
+ long : 0;
+ char : 0;
+ int : 0;
+ char bar;
+} ATTR t2;
+
+struct
+{
+ char foo;
+ long : 0;
+ char : 0;
+ int : 0;
+ char bar;
+ long : 0;
+ char : 0;
+} ATTR t3;
+
+struct
+{
+ long : 0;
+ char bar;
+} ATTR t4;
+
+struct
+{
+ long : 0;
+ long : 0;
+ char : 0;
+ char bar;
+} ATTR t5;
+
+struct
+{
+ long : 0;
+ long : 0;
+ char : 0;
+ char bar;
+} ATTR t6;
+
+struct
+{
+ char foo;
+ long : 0;
+ int : 0;
+ char bar;
+ char bar1;
+ long : 0;
+ char bar2;
+ char bar3;
+ char : 0;
+ char bar4;
+ char bar5;
+ char : 0;
+ char bar6;
+ char bar7;
+} ATTR t7;
+
+struct
+{
+ long : 0;
+ long : 0;
+ char : 0;
+} ATTR t8;
+
+struct
+{
+ char foo;
+ long : 0;
+ int : 0;
+ char bar;
+ char bar1;
+ long : 0;
+ char bar2;
+ char bar3;
+ char : 0;
+ char bar4;
+ char bar5;
+ char : 0;
+ char bar6;
+ char bar7;
+ int i1;
+ char : 0;
+ long : 0;
+ char :4;
+ char bar8;
+ char : 0;
+ char bar9;
+ char bar10;
+ int i2;
+ char : 0;
+ long : 0;
+ char :4;
+} ATTR t9;
+
+struct
+{
+ char foo: 8;
+ long : 0;
+ char bar;
+} ATTR t10;
+
+static int arr1[(sizeof(t1) == 2) -1];
+static int arr2[(sizeof(t2) == 2) -1];
+static int arr3[(sizeof(t3) == 2) -1];
+static int arr4[(sizeof(t4) == 1) -1];
+static int arr5[(sizeof(t5) == 1) -1];
+static int arr6[(sizeof(t6) == 1) -1];
+static int arr7[(sizeof(t7) == 9) -1];
+static int arr8[(sizeof(t8) == 0) -1];
+static int arr9[(sizeof(t9) == 28) -1];
+static int arr10[(sizeof(t10) == 16) -1];
+
+int main() {
+ return 0;
+}
+
diff --git a/clang/test/CodeGen/ms_struct-pack.c b/clang/test/CodeGen/ms_struct-pack.c
new file mode 100644
index 0000000..da94f54
--- /dev/null
+++ b/clang/test/CodeGen/ms_struct-pack.c
@@ -0,0 +1,125 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple i386-apple-darwin9 %s
+// rdar://8823265
+
+#pragma pack(1)
+struct _one_ms {
+ short m:9; // size is 2
+ int q:27; // size is 6
+ short w:13; // size is 8
+ short e:3; // size is 8
+ char r:4; // size is 9
+ char t:7; // size is 10
+ short y:16; // size is 12
+ short u:1; // size is 14
+ char i:2; // size is 15
+ int a; // size is 19
+ char o:6; // size is 20
+ char s:2; // size is 20
+ short d:10; // size is 22
+ short f:4; // size is 22
+ char b; // size is 23
+ char g:1; // size is 24
+ short h:13; // size is 26
+ char j:8; // size is 27
+ char k:5; // size is 28
+ char c; // size is 29
+ int l:28; // size is 33
+ char z:7; // size is 34
+ int x:20; // size is 38
+} __attribute__((__ms_struct__));
+typedef struct _one_ms one_ms;
+
+static int a1[(sizeof(one_ms) == 38) - 1];
+
+#pragma pack(2)
+struct _two_ms {
+ short m:9;
+ int q:27;
+ short w:13;
+ short e:3;
+ char r:4;
+ char t:7;
+ short y:16;
+ short u:1;
+ char i:2;
+ int a;
+ char o:6;
+ char s:2;
+ short d:10;
+ short f:4;
+ char b;
+ char g:1;
+ short h:13;
+ char j:8;
+ char k:5;
+ char c;
+ int l:28;
+ char z:7;
+ int x:20;
+} __attribute__((__ms_struct__));
+
+typedef struct _two_ms two_ms;
+
+static int a2[(sizeof(two_ms) == 42) - 1];
+
+#pragma pack(4)
+struct _four_ms {
+ short m:9;
+ int q:27;
+ short w:13;
+ short e:3;
+ char r:4;
+ char t:7;
+ short y:16;
+ short u:1;
+ char i:2;
+ int a;
+ char o:6;
+ char s:2;
+ short d:10;
+ short f:4;
+ char b;
+ char g:1;
+ short h:13;
+ char j:8;
+ char k:5;
+ char c;
+ int l:28;
+ char z:7;
+ int x:20;
+} __attribute__((__ms_struct__));
+typedef struct _four_ms four_ms;
+
+static int a4[(sizeof(four_ms) == 48) - 1];
+
+#pragma pack(8)
+struct _eight_ms {
+ short m:9;
+ int q:27;
+ short w:13;
+ short e:3;
+ char r:4;
+ char t:7;
+ short y:16;
+ short u:1;
+ char i:2;
+ int a;
+ char o:6;
+ char s:2;
+ short d:10;
+ short f:4;
+ char b;
+ char g:1;
+ short h:13;
+ char j:8;
+ char k:5;
+ char c;
+ int l:28;
+ char z:7;
+ int x:20;
+} __attribute__((__ms_struct__));
+
+typedef struct _eight_ms eight_ms;
+
+static int a8[(sizeof(eight_ms) == 48) - 1];
+
diff --git a/clang/test/CodeGen/ms_struct.c b/clang/test/CodeGen/ms_struct.c
new file mode 100644
index 0000000..a5f9606
--- /dev/null
+++ b/clang/test/CodeGen/ms_struct.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -emit-llvm %s -o - | FileCheck %s
+
+#define ATTR __attribute__((__ms_struct__))
+struct s1 {
+ int f32;
+ long long f64;
+} ATTR s1;
+
+// CHECK: %struct.s1 = type { i32, [4 x i8], i64 }
+
+struct s2 {
+ int f32;
+ long long f64[4];
+} ATTR s2;
+
+// CHECK: %struct.s2 = type { i32, [4 x i8], [4 x i64] }
+
+struct s3 {
+ int f32;
+ struct s1 s;
+} ATTR s3;
+
+// CHECK: %struct.s3 = type { i32, [4 x i8], %struct.s1 }
diff --git a/clang/test/CodeGen/mult-alt-generic.c b/clang/test/CodeGen/mult-alt-generic.c
new file mode 100644
index 0000000..1665f9c
--- /dev/null
+++ b/clang/test/CodeGen/mult-alt-generic.c
@@ -0,0 +1,281 @@
+// RUN: %clang_cc1 -triple i686 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple arm %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple cellspu %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple mblaze %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple mips %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple mipsel %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple sparc %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple thumb %s -emit-llvm -o - | FileCheck %s
+
+int mout0;
+int min1;
+int marray[2];
+
+// CHECK: @single_m
+void single_m()
+{
+ // CHECK: call void asm "foo $1,$0", "=*m,*m[[CLOBBERS:[a-zA-Z0-9@%{},~_ ]*\"]](i32* {{[a-zA-Z0-9@%]+}}, i32* {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=m" (mout0) : "m" (min1));
+}
+
+// CHECK: @single_o
+void single_o()
+{
+ register int out0 = 0;
+ register int index = 1;
+ // Doesn't really do an offset...
+ //asm("foo %1, %2,%0" : "=r" (out0) : "o" (min1));
+}
+
+// CHECK: @single_V
+void single_V()
+{
+// asm("foo %1,%0" : "=m" (mout0) : "V" (min1));
+}
+
+// CHECK: @single_lt
+void single_lt()
+{
+ register int out0 = 0;
+ register int in1 = 1;
+ // CHECK: call i32 asm "foo $1,$0", "=r,<r[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r" (out0) : "<r" (in1));
+ // CHECK: call i32 asm "foo $1,$0", "=r,r<[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r" (out0) : "r<" (in1));
+}
+
+// CHECK: @single_gt
+void single_gt()
+{
+ register int out0 = 0;
+ register int in1 = 1;
+ // CHECK: call i32 asm "foo $1,$0", "=r,>r[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r" (out0) : ">r" (in1));
+ // CHECK: call i32 asm "foo $1,$0", "=r,r>[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r" (out0) : "r>" (in1));
+}
+
+// CHECK: @single_r
+void single_r()
+{
+ register int out0 = 0;
+ register int in1 = 1;
+ // CHECK: call i32 asm "foo $1,$0", "=r,r[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r" (out0) : "r" (in1));
+}
+
+// CHECK: @single_i
+void single_i()
+{
+ register int out0 = 0;
+ // CHECK: call i32 asm "foo $1,$0", "=r,i[[CLOBBERS]](i32 1)
+ asm("foo %1,%0" : "=r" (out0) : "i" (1));
+}
+
+// CHECK: @single_n
+void single_n()
+{
+ register int out0 = 0;
+ // CHECK: call i32 asm "foo $1,$0", "=r,n[[CLOBBERS]](i32 1)
+ asm("foo %1,%0" : "=r" (out0) : "n" (1));
+}
+
+// CHECK: @single_E
+void single_E()
+{
+ register double out0 = 0.0;
+ // CHECK: call double asm "foo $1,$0", "=r,E[[CLOBBERS]](double {{[0-9.eE+-]+}})
+ asm("foo %1,%0" : "=r" (out0) : "E" (1.0e+01));
+}
+
+// CHECK: @single_F
+void single_F()
+{
+ register double out0 = 0.0;
+ // CHECK: call double asm "foo $1,$0", "=r,F[[CLOBBERS]](double {{[0-9.eE+-]+}})
+ asm("foo %1,%0" : "=r" (out0) : "F" (1.0));
+}
+
+// CHECK: @single_s
+void single_s()
+{
+ register int out0 = 0;
+ //asm("foo %1,%0" : "=r" (out0) : "s" (single_s));
+}
+
+// CHECK: @single_g
+void single_g()
+{
+ register int out0 = 0;
+ register int in1 = 1;
+ // CHECK: call i32 asm "foo $1,$0", "=r,imr[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r" (out0) : "g" (in1));
+ // CHECK: call i32 asm "foo $1,$0", "=r,imr[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r" (out0) : "g" (min1));
+ // CHECK: call i32 asm "foo $1,$0", "=r,imr[[CLOBBERS]](i32 1)
+ asm("foo %1,%0" : "=r" (out0) : "g" (1));
+}
+
+// CHECK: @single_X
+void single_X()
+{
+ register int out0 = 0;
+ register int in1 = 1;
+ // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r" (out0) : "X" (in1));
+ // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r" (out0) : "X" (min1));
+ // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](i32 1)
+ asm("foo %1,%0" : "=r" (out0) : "X" (1));
+ // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](i32* getelementptr inbounds ([2 x i32]* {{[a-zA-Z0-9@%]+}}, i32 0, i32 0))
+ asm("foo %1,%0" : "=r" (out0) : "X" (marray));
+ // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](double {{[0-9.eE+-]+}})
+ asm("foo %1,%0" : "=r" (out0) : "X" (1.0e+01));
+ // CHECK: call i32 asm "foo $1,$0", "=r,X[[CLOBBERS]](double {{[0-9.eE+-]+}})
+ asm("foo %1,%0" : "=r" (out0) : "X" (1.0));
+}
+
+// CHECK: @single_p
+void single_p()
+{
+ register int out0 = 0;
+ // Constraint converted differently on different platforms moved to platform-specific.
+ // : call i32 asm "foo $1,$0", "=r,im[[CLOBBERS]](i32* getelementptr inbounds ([2 x i32]* {{[a-zA-Z0-9@%]+}}, i32 0, i32 0))
+ asm("foo %1,%0" : "=r" (out0) : "p" (marray));
+}
+
+// CHECK: @multi_m
+void multi_m()
+{
+ // CHECK: call void asm "foo $1,$0", "=*m|r,m|r[[CLOBBERS]](i32* {{[a-zA-Z0-9@%]+}}, i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=m,r" (mout0) : "m,r" (min1));
+}
+
+// CHECK: @multi_o
+void multi_o()
+{
+ register int out0 = 0;
+ register int index = 1;
+ // Doesn't really do an offset...
+ //asm("foo %1, %2,%0" : "=r,r" (out0) : "r,o" (min1));
+}
+
+// CHECK: @multi_V
+void multi_V()
+{
+// asm("foo %1,%0" : "=m,r" (mout0) : "r,V" (min1));
+}
+
+// CHECK: @multi_lt
+void multi_lt()
+{
+ register int out0 = 0;
+ register int in1 = 1;
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|<r[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,r" (out0) : "r,<r" (in1));
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|r<[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,r" (out0) : "r,r<" (in1));
+}
+
+// CHECK: @multi_gt
+void multi_gt()
+{
+ register int out0 = 0;
+ register int in1 = 1;
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|>r[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,r" (out0) : "r,>r" (in1));
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|r>[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,r" (out0) : "r,r>" (in1));
+}
+
+// CHECK: @multi_r
+void multi_r()
+{
+ register int out0 = 0;
+ register int in1 = 1;
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|m[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,r" (out0) : "r,m" (in1));
+}
+
+// CHECK: @multi_i
+void multi_i()
+{
+ register int out0 = 0;
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|i[[CLOBBERS]](i32 1)
+ asm("foo %1,%0" : "=r,r" (out0) : "r,i" (1));
+}
+
+// CHECK: @multi_n
+void multi_n()
+{
+ register int out0 = 0;
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|n[[CLOBBERS]](i32 1)
+ asm("foo %1,%0" : "=r,r" (out0) : "r,n" (1));
+}
+
+// CHECK: @multi_E
+void multi_E()
+{
+ register double out0 = 0.0;
+ // CHECK: call double asm "foo $1,$0", "=r|r,r|E[[CLOBBERS]](double {{[0-9.eE+-]+}})
+ asm("foo %1,%0" : "=r,r" (out0) : "r,E" (1.0e+01));
+}
+
+// CHECK: @multi_F
+void multi_F()
+{
+ register double out0 = 0.0;
+ // CHECK: call double asm "foo $1,$0", "=r|r,r|F[[CLOBBERS]](double {{[0-9.eE+-]+}})
+ asm("foo %1,%0" : "=r,r" (out0) : "r,F" (1.0));
+}
+
+// CHECK: @multi_s
+void multi_s()
+{
+ register int out0 = 0;
+ //asm("foo %1,%0" : "=r,r" (out0) : "r,s" (multi_s));
+}
+
+// CHECK: @multi_g
+void multi_g()
+{
+ register int out0 = 0;
+ register int in1 = 1;
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|imr[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,r" (out0) : "r,g" (in1));
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|imr[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,r" (out0) : "r,g" (min1));
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|imr[[CLOBBERS]](i32 1)
+ asm("foo %1,%0" : "=r,r" (out0) : "r,g" (1));
+}
+
+// CHECK: @multi_X
+void multi_X()
+{
+ register int out0 = 0;
+ register int in1 = 1;
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,r" (out0) : "r,X" (in1));
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,r" (out0) : "r,X" (min1));
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](i32 1)
+ asm("foo %1,%0" : "=r,r" (out0) : "r,X" (1));
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](i32* getelementptr inbounds ([2 x i32]* {{[a-zA-Z0-9@%]+}}, i32 0, i32 0))
+ asm("foo %1,%0" : "=r,r" (out0) : "r,X" (marray));
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](double {{[0-9.eE+-]+}})
+ asm("foo %1,%0" : "=r,r" (out0) : "r,X" (1.0e+01));
+ // CHECK: call i32 asm "foo $1,$0", "=r|r,r|X[[CLOBBERS]](double {{[0-9.eE+-]+}})
+ asm("foo %1,%0" : "=r,r" (out0) : "r,X" (1.0));
+}
+
+// CHECK: @multi_p
+void multi_p()
+{
+ register int out0 = 0;
+ // Constraint converted differently on different platforms moved to platform-specific.
+ // : call i32 asm "foo $1,$0", "=r|r,r|im[[CLOBBERS]](i32* getelementptr inbounds ([2 x i32]* {{[a-zA-Z0-9@%]+}}, i32 0, i32 0))
+ asm("foo %1,%0" : "=r,r" (out0) : "r,p" (marray));
+}
diff --git a/clang/test/CodeGen/mult-alt-x86.c b/clang/test/CodeGen/mult-alt-x86.c
new file mode 100644
index 0000000..4e2a69d
--- /dev/null
+++ b/clang/test/CodeGen/mult-alt-x86.c
@@ -0,0 +1,374 @@
+// RUN: %clang_cc1 -triple i686 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64 -emit-llvm %s -o - | FileCheck %s
+
+int mout0;
+int min1;
+int marray[2];
+double dout0;
+double din1;
+
+// CHECK: @single_R
+void single_R()
+{
+ // CHECK: asm "foo $1,$0", "=R,R[[CLOBBERS:[a-zA-Z0-9@%{},~_ ]*\"]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=R" (mout0) : "R" (min1));
+}
+
+// CHECK: @single_q
+void single_q()
+{
+ // CHECK: asm "foo $1,$0", "=q,q[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=q" (mout0) : "q" (min1));
+}
+
+// CHECK: @single_Q
+void single_Q()
+{
+ // CHECK: asm "foo $1,$0", "=Q,Q[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=Q" (mout0) : "Q" (min1));
+}
+
+// CHECK: @single_a
+void single_a()
+{
+ // CHECK: asm "foo $1,$0", "={ax},{ax}[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=a" (mout0) : "a" (min1));
+}
+
+// CHECK: @single_b
+void single_b()
+{
+ // CHECK: asm "foo $1,$0", "={bx},{bx}[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=b" (mout0) : "b" (min1));
+}
+
+// CHECK: @single_c
+void single_c()
+{
+ // CHECK: asm "foo $1,$0", "={cx},{cx}[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=c" (mout0) : "c" (min1));
+}
+
+// CHECK: @single_d
+void single_d()
+{
+ // CHECK: asm "foo $1,$0", "={dx},{dx}[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=d" (mout0) : "d" (min1));
+}
+
+// CHECK: @single_S
+void single_S()
+{
+ // CHECK: asm "foo $1,$0", "={si},{si}[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=S" (mout0) : "S" (min1));
+}
+
+// CHECK: @single_D
+void single_D()
+{
+ // CHECK: asm "foo $1,$0", "={di},{di}[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=D" (mout0) : "D" (min1));
+}
+
+// CHECK: @single_A
+void single_A()
+{
+ // CHECK: asm "foo $1,$0", "=A,A[[CLOBBERS]](i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=A" (mout0) : "A" (min1));
+}
+
+// CHECK: @single_f
+void single_f()
+{
+//FIXME: I don't know how to do an 80387 floating point stack register operation, which I think is fp80.
+}
+
+// CHECK: @single_t
+void single_t()
+{
+//FIXME: I don't know how to do an 80387 floating point stack register operation, which I think is fp80.
+}
+
+// CHECK: @single_u
+void single_u()
+{
+//FIXME: I don't know how to do an 80387 floating point stack register operation, which I think is fp80.
+}
+
+// CHECK: @single_y
+void single_y()
+{
+ // CHECK: call double asm "foo $1,$0", "=y,y[[CLOBBERS]](double {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=y" (dout0) : "y" (din1));
+}
+
+// CHECK: @single_x
+void single_x()
+{
+ // CHECK: asm "foo $1,$0", "=x,x[[CLOBBERS]](double {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=x" (dout0) : "x" (din1));
+}
+
+// CHECK: @single_Y
+void single_Y0()
+{
+ // Y constraint currently broken.
+ //asm("foo %1,%0" : "=Y0" (mout0) : "Y0" (min1));
+ //asm("foo %1,%0" : "=Yz" (mout0) : "Yz" (min1));
+ //asm("foo %1,%0" : "=Yt" (mout0) : "Yt" (min1));
+ //asm("foo %1,%0" : "=Yi" (mout0) : "Yi" (min1));
+ //asm("foo %1,%0" : "=Ym" (mout0) : "Ym" (min1));
+}
+
+// CHECK: @single_I
+void single_I()
+{
+ // CHECK: asm "foo $1,$0", "=*m,I[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=m" (mout0) : "I" (1));
+}
+
+// CHECK: @single_J
+void single_J()
+{
+ // CHECK: asm "foo $1,$0", "=*m,J[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=m" (mout0) : "J" (1));
+}
+
+// CHECK: @single_K
+void single_K()
+{
+ // CHECK: asm "foo $1,$0", "=*m,K[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=m" (mout0) : "K" (1));
+}
+
+// CHECK: @single_L
+void single_L()
+{
+ // CHECK: asm "foo $1,$0", "=*m,L[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=m" (mout0) : "L" (1));
+}
+
+// CHECK: @single_M
+void single_M()
+{
+ // CHECK: asm "foo $1,$0", "=*m,M[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=m" (mout0) : "M" (1));
+}
+
+// CHECK: @single_N
+void single_N()
+{
+ // CHECK: asm "foo $1,$0", "=*m,N[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=m" (mout0) : "N" (1));
+}
+
+// CHECK: @single_G
+void single_G()
+{
+ // CHECK: asm "foo $1,$0", "=*m,G[[CLOBBERS]](i32* @mout0, double {{1.[0]+e[+]*[0]+}})
+ asm("foo %1,%0" : "=m" (mout0) : "G" (1.0));
+}
+
+// CHECK: @single_C
+void single_C()
+{
+ // CHECK: asm "foo $1,$0", "=*m,C[[CLOBBERS]](i32* @mout0, double {{1.[0]+e[+]*[0]+}})
+ asm("foo %1,%0" : "=m" (mout0) : "C" (1.0));
+}
+
+// CHECK: @single_e
+void single_e()
+{
+ // CHECK: asm "foo $1,$0", "=*m,e[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=m" (mout0) : "e" (1));
+}
+
+// CHECK: @single_Z
+void single_Z()
+{
+ // CHECK: asm "foo $1,$0", "=*m,Z[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=m" (mout0) : "Z" (1));
+}
+
+// CHECK: @multi_R
+void multi_R()
+{
+ // CHECK: asm "foo $1,$0", "=*r|R|m,r|R|m[[CLOBBERS]](i32* @mout0, i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,R,m" (mout0) : "r,R,m" (min1));
+}
+
+// CHECK: @multi_q
+void multi_q()
+{
+ // CHECK: asm "foo $1,$0", "=*r|q|m,r|q|m[[CLOBBERS]](i32* @mout0, i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,q,m" (mout0) : "r,q,m" (min1));
+}
+
+// CHECK: @multi_Q
+void multi_Q()
+{
+ // CHECK: asm "foo $1,$0", "=*r|Q|m,r|Q|m[[CLOBBERS]](i32* @mout0, i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,Q,m" (mout0) : "r,Q,m" (min1));
+}
+
+// CHECK: @multi_a
+void multi_a()
+{
+ // CHECK: asm "foo $1,$0", "=*r|{ax}|m,r|{ax}|m[[CLOBBERS]](i32* @mout0, i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,a,m" (mout0) : "r,a,m" (min1));
+}
+
+// CHECK: @multi_b
+void multi_b()
+{
+ // CHECK: asm "foo $1,$0", "=*r|{bx}|m,r|{bx}|m[[CLOBBERS]](i32* @mout0, i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,b,m" (mout0) : "r,b,m" (min1));
+}
+
+// CHECK: @multi_c
+void multi_c()
+{
+ // CHECK: asm "foo $1,$0", "=*r|{cx}|m,r|{cx}|m[[CLOBBERS]](i32* @mout0, i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,c,m" (mout0) : "r,c,m" (min1));
+}
+
+// CHECK: @multi_d
+void multi_d()
+{
+ // CHECK: asm "foo $1,$0", "=*r|{dx}|m,r|{dx}|m[[CLOBBERS]](i32* @mout0, i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,d,m" (mout0) : "r,d,m" (min1));
+}
+
+// CHECK: @multi_S
+void multi_S()
+{
+ // CHECK: asm "foo $1,$0", "=*r|{si}|m,r|{si}|m[[CLOBBERS]](i32* @mout0, i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,S,m" (mout0) : "r,S,m" (min1));
+}
+
+// CHECK: @multi_D
+void multi_D()
+{
+ // CHECK: asm "foo $1,$0", "=*r|{di}|m,r|{di}|m[[CLOBBERS]](i32* @mout0, i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,D,m" (mout0) : "r,D,m" (min1));
+}
+
+// CHECK: @multi_A
+void multi_A()
+{
+ // CHECK: asm "foo $1,$0", "=*r|A|m,r|A|m[[CLOBBERS]](i32* @mout0, i32 {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,A,m" (mout0) : "r,A,m" (min1));
+}
+
+// CHECK: @multi_f
+void multi_f()
+{
+//FIXME: I don't know how to do an 80387 floating point stack register operation, which I think is fp80.
+}
+
+// CHECK: @multi_t
+void multi_t()
+{
+//FIXME: I don't know how to do an 80387 floating point stack register operation, which I think is fp80.
+}
+
+// CHECK: @multi_u
+void multi_u()
+{
+//FIXME: I don't know how to do an 80387 floating point stack register operation, which I think is fp80.
+}
+
+// CHECK: @multi_y
+void multi_y()
+{
+ // CHECK: asm "foo $1,$0", "=*r|y|m,r|y|m[[CLOBBERS]](double* @dout0, double {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,y,m" (dout0) : "r,y,m" (din1));
+}
+
+// CHECK: @multi_x
+void multi_x()
+{
+ // CHECK: asm "foo $1,$0", "=*r|x|m,r|x|m[[CLOBBERS]](double* @dout0, double {{[a-zA-Z0-9@%]+}})
+ asm("foo %1,%0" : "=r,x,m" (dout0) : "r,x,m" (din1));
+}
+
+// CHECK: @multi_Y
+void multi_Y0()
+{
+ // Y constraint currently broken.
+ //asm("foo %1,%0" : "=r,Y0,m" (mout0) : "r,Y0,m" (min1));
+ //asm("foo %1,%0" : "=r,Yz,m" (mout0) : "r,Yz,m" (min1));
+ //asm("foo %1,%0" : "=r,Yt,m" (mout0) : "r,Yt,m" (min1));
+ //asm("foo %1,%0" : "=r,Yi,m" (mout0) : "r,Yi,m" (min1));
+ //asm("foo %1,%0" : "=r,Ym,m" (mout0) : "r,Ym,m" (min1));
+}
+
+// CHECK: @multi_I
+void multi_I()
+{
+ // CHECK: asm "foo $1,$0", "=*r|m|m,r|I|m[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=r,m,m" (mout0) : "r,I,m" (1));
+}
+
+// CHECK: @multi_J
+void multi_J()
+{
+ // CHECK: asm "foo $1,$0", "=*r|m|m,r|J|m[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=r,m,m" (mout0) : "r,J,m" (1));
+}
+
+// CHECK: @multi_K
+void multi_K()
+{
+ // CHECK: asm "foo $1,$0", "=*r|m|m,r|K|m[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=r,m,m" (mout0) : "r,K,m" (1));
+}
+
+// CHECK: @multi_L
+void multi_L()
+{
+ // CHECK: asm "foo $1,$0", "=*r|m|m,r|L|m[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=r,m,m" (mout0) : "r,L,m" (1));
+}
+
+// CHECK: @multi_M
+void multi_M()
+{
+ // CHECK: asm "foo $1,$0", "=*r|m|m,r|M|m[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=r,m,m" (mout0) : "r,M,m" (1));
+}
+
+// CHECK: @multi_N
+void multi_N()
+{
+ // CHECK: asm "foo $1,$0", "=*r|m|m,r|N|m[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=r,m,m" (mout0) : "r,N,m" (1));
+}
+
+// CHECK: @multi_G
+void multi_G()
+{
+ // CHECK: asm "foo $1,$0", "=*r|m|m,r|G|m[[CLOBBERS]](i32* @mout0, double {{1.[0]+e[+]*[0]+}})
+ asm("foo %1,%0" : "=r,m,m" (mout0) : "r,G,m" (1.0));
+}
+
+// CHECK: @multi_C
+void multi_C()
+{
+ // CHECK: asm "foo $1,$0", "=*r|m|m,r|C|m[[CLOBBERS]](i32* @mout0, double {{1.[0]+e[+]*[0]+}})
+ asm("foo %1,%0" : "=r,m,m" (mout0) : "r,C,m" (1.0));
+}
+
+// CHECK: @multi_e
+void multi_e()
+{
+ // CHECK: asm "foo $1,$0", "=*r|m|m,r|e|m[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=r,m,m" (mout0) : "r,e,m" (1));
+}
+
+// CHECK: @multi_Z
+void multi_Z()
+{
+ // CHECK: asm "foo $1,$0", "=*r|m|m,r|Z|m[[CLOBBERS]](i32* @mout0, i32 1)
+ asm("foo %1,%0" : "=r,m,m" (mout0) : "r,Z,m" (1));
+}
diff --git a/clang/test/CodeGen/no-common.c b/clang/test/CodeGen/no-common.c
new file mode 100644
index 0000000..7beefc7
--- /dev/null
+++ b/clang/test/CodeGen/no-common.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-DEFAULT
+// RUN: %clang_cc1 %s -fno-common -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-NOCOMMON
+
+// CHECK-DEFAULT: @x = common global
+// CHECK-NOCOMMON: @x = global
+int x;
+
+// CHECK-DEFAULT: @ABC = global
+// CHECK-NOCOMMON: @ABC = global
+typedef void* (*fn_t)(long a, long b, char *f, int c);
+fn_t ABC __attribute__ ((nocommon));
+
+// CHECK-DEFAULT: @y = common global
+// CHECK-NOCOMMON: @y = common global
+int y __attribute__((common)); \ No newline at end of file
diff --git a/clang/test/CodeGen/noinline.c b/clang/test/CodeGen/noinline.c
new file mode 100644
index 0000000..e64a1a5
--- /dev/null
+++ b/clang/test/CodeGen/noinline.c
@@ -0,0 +1,14 @@
+// Make sure -fno-inline-functions is behaving correctly.
+// rdar://10972766
+
+// RUN: %clang_cc1 -O3 -fno-inline -fno-inline-functions -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
+
+inline int dont_inline_me(int a, int b) { return(a+b); }
+
+volatile int *pa = (int*) 0x1000;
+void foo() {
+// NOINLINE: @foo
+// NOINLINE: dont_inline_me
+// NOINLINE-NOT: inlinehint
+ pa[0] = dont_inline_me(pa[1],pa[2]);
+}
diff --git a/clang/test/CodeGen/object-size.c b/clang/test/CodeGen/object-size.c
new file mode 100644
index 0000000..1f16d02
--- /dev/null
+++ b/clang/test/CodeGen/object-size.c
@@ -0,0 +1,136 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s
+
+#define strcpy(dest, src) \
+ ((__builtin_object_size(dest, 0) != -1ULL) \
+ ? __builtin___strcpy_chk (dest, src, __builtin_object_size(dest, 1)) \
+ : __inline_strcpy_chk(dest, src))
+
+static char *__inline_strcpy_chk (char *dest, const char *src) {
+ return __builtin___strcpy_chk(dest, src, __builtin_object_size(dest, 1));
+}
+
+char gbuf[63];
+char *gp;
+int gi, gj;
+
+// CHECK: define void @test1
+void test1() {
+ // CHECK: = call i8* @__strcpy_chk(i8* getelementptr inbounds ([63 x i8]* @gbuf, i32 0, i64 4), i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i64 59)
+ strcpy(&gbuf[4], "Hi there");
+}
+
+// CHECK: define void @test2
+void test2() {
+ // CHECK: = call i8* @__strcpy_chk(i8* getelementptr inbounds ([63 x i8]* @gbuf, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i64 63)
+ strcpy(gbuf, "Hi there");
+}
+
+// CHECK: define void @test3
+void test3() {
+ // CHECK: = call i8* @__strcpy_chk(i8* getelementptr inbounds ([63 x i8]* @gbuf, i64 1, i64 37), i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i64 0)
+ strcpy(&gbuf[100], "Hi there");
+}
+
+// CHECK: define void @test4
+void test4() {
+ // CHECK: = call i8* @__strcpy_chk(i8* getelementptr inbounds ([63 x i8]* @gbuf, i32 0, i64 -1), i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i64 0)
+ strcpy((char*)(void*)&gbuf[-1], "Hi there");
+}
+
+// CHECK: define void @test5
+void test5() {
+ // CHECK: = load i8** @gp
+ // CHECK-NEXT:= call i64 @llvm.objectsize.i64(i8* %{{.*}}, i1 false)
+ strcpy(gp, "Hi there");
+}
+
+// CHECK: define void @test6
+void test6() {
+ char buf[57];
+
+ // CHECK: = call i8* @__strcpy_chk(i8* %{{.*}}, i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i64 53)
+ strcpy(&buf[4], "Hi there");
+}
+
+// CHECK: define void @test7
+void test7() {
+ int i;
+ // CHECK: = call i64 @llvm.objectsize.i64(i8* {{.*}}@gbuf{{.*}}, i1 false)
+ strcpy((++i, gbuf), "Hi there");
+}
+
+// CHECK: define void @test8
+void test8() {
+ char *buf[50];
+ // CHECK-NOT: __strcpy_chk
+ // CHECK: = call i8* @__inline_strcpy_chk(i8* %{{.*}}, i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0))
+ strcpy(buf[++gi], "Hi there");
+}
+
+// CHECK: define void @test9
+void test9() {
+ // CHECK-NOT: __strcpy_chk
+ // CHECK: = call i8* @__inline_strcpy_chk(i8* %{{.*}}, i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0))
+ strcpy((char *)((++gi) + gj), "Hi there");
+}
+
+// CHECK: define void @test10
+char **p;
+void test10() {
+ // CHECK-NOT: __strcpy_chk
+ // CHECK: = call i8* @__inline_strcpy_chk(i8* %{{.*}}, i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0))
+ strcpy(*(++p), "Hi there");
+}
+
+// CHECK: define void @test11
+void test11() {
+ // CHECK-NOT: __strcpy_chk
+ // CHECK: = call i8* @__inline_strcpy_chk(i8* getelementptr inbounds ([63 x i8]* @gbuf, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0))
+ strcpy(gp = gbuf, "Hi there");
+}
+
+// CHECK: define void @test12
+void test12() {
+ // CHECK-NOT: __strcpy_chk
+ // CHECK: = call i8* @__inline_strcpy_chk(i8* %{{.*}}, i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0))
+ strcpy(++gp, "Hi there");
+}
+
+// CHECK: define void @test13
+void test13() {
+ // CHECK-NOT: __strcpy_chk
+ // CHECK: = call i8* @__inline_strcpy_chk(i8* %{{.*}}, i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0))
+ strcpy(gp++, "Hi there");
+}
+
+// CHECK: define void @test14
+void test14() {
+ // CHECK-NOT: __strcpy_chk
+ // CHECK: = call i8* @__inline_strcpy_chk(i8* %{{.*}}, i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0))
+ strcpy(--gp, "Hi there");
+}
+
+// CHECK: define void @test15
+void test15() {
+ // CHECK-NOT: __strcpy_chk
+ // CHECK: = call i8* @__inline_strcpy_chk(i8* %{{..*}}, i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0))
+ strcpy(gp--, "Hi there");
+}
+
+// CHECK: define void @test16
+void test16() {
+ // CHECK-NOT: __strcpy_chk
+ // CHECK: = call i8* @__inline_strcpy_chk(i8* %{{.*}}, i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0))
+ strcpy(gp += 1, "Hi there");
+}
+
+void test17() {
+ // CHECK: store i32 -1
+ gi = __builtin_object_size(gp++, 0);
+ // CHECK: store i32 -1
+ gi = __builtin_object_size(gp++, 1);
+ // CHECK: store i32 0
+ gi = __builtin_object_size(gp++, 2);
+ // CHECK: store i32 0
+ gi = __builtin_object_size(gp++, 3);
+}
diff --git a/clang/test/CodeGen/offsetof.c b/clang/test/CodeGen/offsetof.c
new file mode 100644
index 0000000..c279e22
--- /dev/null
+++ b/clang/test/CodeGen/offsetof.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+
+// PR2910
+struct sockaddr_un {
+ unsigned char sun_len;
+ char sun_path[104];
+};
+
+int test(int len) {
+ return __builtin_offsetof(struct sockaddr_un, sun_path[len+1]);
+}
+
diff --git a/clang/test/CodeGen/opaque-pointer.c b/clang/test/CodeGen/opaque-pointer.c
new file mode 100644
index 0000000..d658db1
--- /dev/null
+++ b/clang/test/CodeGen/opaque-pointer.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+struct test;
+
+typedef void (*my_func) (struct test *);
+my_func handler;
+
+struct test {
+ char a;
+};
+
+char f(struct test *t) {
+ return t->a;
+}
diff --git a/clang/test/CodeGen/overloadable.c b/clang/test/CodeGen/overloadable.c
new file mode 100644
index 0000000..1ed72b1
--- /dev/null
+++ b/clang/test/CodeGen/overloadable.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | grep _Z1fPA10_1X
+int __attribute__((overloadable)) f(int x) { return x; }
+float __attribute__((overloadable)) f(float x) { return x; }
+double __attribute__((overloadable)) f(double x) { return x; }
+double _Complex __attribute__((overloadable)) f(double _Complex x) { return x; }
+typedef short v4hi __attribute__ ((__vector_size__ (8)));
+v4hi __attribute__((overloadable)) f(v4hi x) { return x; }
+
+struct X { };
+void __attribute__((overloadable)) f(struct X (*ptr)[10]) { }
+
+void __attribute__((overloadable)) f(int x, int y, ...) { }
+
+int main() {
+ int iv = 17;
+ float fv = 3.0f;
+ double dv = 4.0;
+ double _Complex cdv;
+ v4hi vv;
+
+ iv = f(iv);
+ fv = f(fv);
+ dv = f(dv);
+ cdv = f(cdv);
+ vv = f(vv);
+}
diff --git a/clang/test/CodeGen/override-layout.c b/clang/test/CodeGen/override-layout.c
new file mode 100644
index 0000000..99c2cd6
--- /dev/null
+++ b/clang/test/CodeGen/override-layout.c
@@ -0,0 +1,174 @@
+// RUN: %clang_cc1 -w -fdump-record-layouts %s 2> %t.layouts
+// RUN: %clang_cc1 -w -fdump-record-layouts-simple %s > %t.before 2>&1
+// RUN: %clang_cc1 -w -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after 2>&1
+// RUN: diff %t.before %t.after
+// RUN: FileCheck %s < %t.after
+
+// If not explicitly disabled, set PACKED to the packed attribute.
+#ifndef PACKED
+# define PACKED __attribute__((packed))
+#endif
+
+// If not explicitly disabled, set ALIGNED16 to 16-byte alignment.
+#ifndef ALIGNED16
+# define ALIGNED16 __attribute__((aligned(16)))
+#endif
+
+// CHECK: Type: struct X0
+struct X0 {
+ int x[6] PACKED;
+};
+
+// CHECK: Type: struct X1
+struct X1 {
+ char x[13];
+ struct X0 y;
+} PACKED;
+
+// CHECK: Type: struct X2
+struct PACKED X2 {
+ short x;
+ int y;
+};
+
+// CHECK: Type: struct X3
+struct X3 {
+ short x PACKED;
+ int y;
+};
+
+#pragma pack(push,2)
+// CHECK: Type: struct X4
+struct X4 {
+ int x;
+ int y;
+};
+#pragma pack(pop)
+
+// CHECK: Type: struct X5
+struct PACKED X5 { double a[19]; signed char b; };
+
+// CHECK: Type: struct X6
+struct PACKED X6 { long double a; char b; };
+
+// CHECK: Type: struct X7
+struct X7 {
+ unsigned x;
+ unsigned char y;
+} PACKED;
+
+// CHECK: Type: union X8
+union X8 {
+ struct X7 x;
+ unsigned y;
+} PACKED;
+
+// CHECK: Type: struct X9
+struct X9 {
+ unsigned int x[2] PACKED;
+ unsigned int y;
+ unsigned int z PACKED;
+};
+
+// CHECK: Type: struct X10
+struct X10 {
+ unsigned int x[2] PACKED;
+ unsigned int y PACKED;
+ unsigned int z PACKED;
+};
+
+// CHECK: Type: struct X11
+struct PACKED X11 {
+ unsigned int x[2];
+ unsigned int y;
+ unsigned int z;
+};
+
+// CHECK: Type: struct X12
+struct PACKED X12 {
+ int x : 24;
+};
+
+// CHECK: Type: struct X13
+struct PACKED X13 {
+ signed x : 10;
+ signed y : 10;
+};
+
+// CHECK: Type: union X14
+union PACKED X14 {
+ unsigned long long x : 3;
+};
+
+// CHECK: Type: struct X15
+struct X15 {
+ unsigned x : 16;
+ unsigned y : 28 PACKED;
+};
+
+// CHECK: Type: struct X16
+struct ALIGNED16 X16 {
+ int a, b, c;
+ int x : 5;
+ int y : 29;
+};
+
+void use_structs() {
+ struct X0 x0;
+ x0.x[5] = sizeof(struct X0);
+
+ struct X1 x1;
+ x1.x[5] = sizeof(struct X1);
+
+ struct X2 x2;
+ x2.y = sizeof(struct X2);
+
+ struct X3 x3;
+ x3.y = sizeof(struct X3);
+
+ struct X4 x4;
+ x4.y = sizeof(struct X4);
+
+ struct X5 x5;
+ x5.b = sizeof(struct X5);
+
+ struct X6 x6;
+ x6.b = sizeof(struct X6);
+
+ struct X7 x7;
+ typedef int X7array[sizeof(struct X7)];
+ x7.x = sizeof(struct X7);
+ x7.y = x7.x;
+
+ union X8 x8;
+ typedef int X8array[sizeof(union X8)];
+ x8.y = sizeof(union X8);
+ x8.x.x = x8.y;
+
+ struct X9 x9;
+ typedef int X9array[sizeof(struct X9)];
+ x9.y = sizeof(struct X9);
+
+ struct X10 x10;
+ typedef int X10array[sizeof(struct X10)];
+ x10.y = sizeof(struct X10);
+
+ struct X11 x11;
+ typedef int X11array[sizeof(struct X11)];
+ x11.y = sizeof(struct X11);
+
+ struct X12 x12;
+ x12.x = sizeof(struct X12);
+
+ struct X13 x13;
+ x13.x = sizeof(struct X13);
+
+ union X14 x14;
+ x14.x = sizeof(union X14);
+
+ struct X15 x15;
+ x15.x = sizeof(struct X15);
+
+ struct X16 x16;
+ x16.x = sizeof(struct X16);
+}
diff --git a/clang/test/CodeGen/packed-arrays.c b/clang/test/CodeGen/packed-arrays.c
new file mode 100644
index 0000000..0c8bb6c
--- /dev/null
+++ b/clang/test/CodeGen/packed-arrays.c
@@ -0,0 +1,155 @@
+// RUN: %clang_cc1 -triple x86_64-unk-unk -emit-llvm -Os -o %t %s
+// RUN: FileCheck < %t %s
+
+struct s0 {
+ unsigned int x[2] __attribute__((packed));
+};
+
+struct s1 {
+ unsigned int x[2] __attribute__((packed));
+ unsigned int y;
+ unsigned int z __attribute__((packed));
+};
+
+struct s2 {
+ unsigned int x[2] __attribute__((packed));
+ unsigned int y __attribute__((packed));
+ unsigned int z __attribute__((packed));
+};
+
+struct __attribute__((packed)) s3 {
+ unsigned int x[2];
+ unsigned int y;
+ unsigned int z;
+};
+
+// CHECK: @align0 = global i32 1
+int align0 = __alignof(struct s0);
+// CHECK: @align1 = global i32 4
+int align1 = __alignof(struct s1);
+// CHECK: @align2 = global i32 1
+int align2 = __alignof(struct s2);
+// CHECK: @align3 = global i32 1
+int align3 = __alignof(struct s3);
+
+// CHECK: @align0_x = global i32 1
+int align0_x = __alignof(((struct s0*) 0)->x);
+//
+// CHECK: @align1_x = global i32 1
+int align1_x = __alignof(((struct s1*) 0)->x);
+// CHECK: @align2_x = global i32 1
+int align2_x = __alignof(((struct s2*) 0)->x);
+// CHECK: @align3_x = global i32 1
+int align3_x = __alignof(((struct s3*) 0)->x);
+
+// CHECK: @align0_x0 = global i32 4
+int align0_x0 = __alignof(((struct s0*) 0)->x[0]);
+// CHECK: @align1_x0 = global i32 4
+int align1_x0 = __alignof(((struct s1*) 0)->x[0]);
+// CHECK: @align2_x0 = global i32 4
+int align2_x0 = __alignof(((struct s2*) 0)->x[0]);
+// CHECK: @align3_x0 = global i32 4
+int align3_x0 = __alignof(((struct s3*) 0)->x[0]);
+
+// CHECK: define i32 @f0_a
+// CHECK: load i32* %{{.*}}, align 1
+// CHECK: }
+// CHECK: define i32 @f0_b
+// CHECK: load i32* %{{.*}}, align 4
+// CHECK: }
+int f0_a(struct s0 *a) {
+ return a->x[1];
+}
+int f0_b(struct s0 *a) {
+ return *(a->x + 1);
+}
+
+// Note that we are incompatible with GCC on this example.
+//
+// CHECK: define i32 @f1_a
+// CHECK: load i32* %{{.*}}, align 1
+// CHECK: }
+// CHECK: define i32 @f1_b
+// CHECK: load i32* %{{.*}}, align 4
+// CHECK: }
+
+// Note that we are incompatible with GCC on this example.
+//
+// CHECK: define i32 @f1_c
+// CHECK: load i32* %{{.*}}, align 4
+// CHECK: }
+// CHECK: define i32 @f1_d
+// CHECK: load i32* %{{.*}}, align 1
+// CHECK: }
+int f1_a(struct s1 *a) {
+ return a->x[1];
+}
+int f1_b(struct s1 *a) {
+ return *(a->x + 1);
+}
+int f1_c(struct s1 *a) {
+ return a->y;
+}
+int f1_d(struct s1 *a) {
+ return a->z;
+}
+
+// CHECK: define i32 @f2_a
+// CHECK: load i32* %{{.*}}, align 1
+// CHECK: }
+// CHECK: define i32 @f2_b
+// CHECK: load i32* %{{.*}}, align 4
+// CHECK: }
+// CHECK: define i32 @f2_c
+// CHECK: load i32* %{{.*}}, align 1
+// CHECK: }
+// CHECK: define i32 @f2_d
+// CHECK: load i32* %{{.*}}, align 1
+// CHECK: }
+int f2_a(struct s2 *a) {
+ return a->x[1];
+}
+int f2_b(struct s2 *a) {
+ return *(a->x + 1);
+}
+int f2_c(struct s2 *a) {
+ return a->y;
+}
+int f2_d(struct s2 *a) {
+ return a->z;
+}
+
+// CHECK: define i32 @f3_a
+// CHECK: load i32* %{{.*}}, align 1
+// CHECK: }
+// CHECK: define i32 @f3_b
+// CHECK: load i32* %{{.*}}, align 4
+// CHECK: }
+// CHECK: define i32 @f3_c
+// CHECK: load i32* %{{.*}}, align 1
+// CHECK: }
+// CHECK: define i32 @f3_d
+// CHECK: load i32* %{{.*}}, align 1
+// CHECK: }
+int f3_a(struct s3 *a) {
+ return a->x[1];
+}
+int f3_b(struct s3 *a) {
+ return *(a->x + 1);
+}
+int f3_c(struct s3 *a) {
+ return a->y;
+}
+int f3_d(struct s3 *a) {
+ return a->z;
+}
+
+// Verify we don't claim things are overaligned.
+//
+// CHECK: define double @f4
+// CHECK: load double* {{.*}}, align 8
+// CHECK: }
+extern double g4[5] __attribute__((aligned(16)));
+double f4() {
+ return g4[1];
+}
diff --git a/clang/test/CodeGen/packed-nest-unpacked.c b/clang/test/CodeGen/packed-nest-unpacked.c
new file mode 100644
index 0000000..0ccc0c4
--- /dev/null
+++ b/clang/test/CodeGen/packed-nest-unpacked.c
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-macosx10.7.2 -emit-llvm -o - | FileCheck %s
+
+struct X { int x[6]; };
+struct Y { char x[13]; struct X y; } __attribute((packed));
+struct Y g;
+void f(struct X);
+struct X foo(void);
+
+// <rdar://problem/10463337>
+struct X test1() {
+ // CHECK: @test1
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i64 24, i32 1, i1 false)
+ return g.y;
+}
+struct X test2() {
+ // CHECK: @test2
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i64 24, i32 1, i1 false)
+ struct X a = g.y;
+ return a;
+}
+
+void test3(struct X a) {
+ // CHECK: @test3
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i8* {{.*}}, i64 24, i32 1, i1 false)
+ g.y = a;
+}
+
+// <rdar://problem/10530444>
+void test4() {
+ // CHECK: @test4
+ // FIXME: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i64 24, i32 1, i1 false)
+ f(g.y);
+}
+
+// PR12395
+int test5() {
+ // CHECK: @test5
+ // CHECK: load i32* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1, i32 0, i64 0), align 1
+ return g.y.x[0];
+}
+
+// <rdar://problem/11220251>
+void test6() {
+ // CHECK: @test6
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i8* %{{.*}}, i64 24, i32 1, i1 false)
+ g.y = foo();
+}
diff --git a/clang/test/CodeGen/packed-structure.c b/clang/test/CodeGen/packed-structure.c
new file mode 100644
index 0000000..3aeaa23
--- /dev/null
+++ b/clang/test/CodeGen/packed-structure.c
@@ -0,0 +1,101 @@
+// RUN: %clang_cc1 -triple x86_64 -emit-llvm -o - %s | opt -S -strip -o %t
+// RUX: llvm-gcc -flto -S -O3 -o %t %s
+// RUN: FileCheck --check-prefix=CHECK-GLOBAL < %t %s
+// RUN: FileCheck --check-prefix=CHECK-FUNCTIONS < %t %s
+
+struct s0 {
+ int x;
+ int y __attribute__((packed));
+};
+
+// CHECK-GLOBAL: @s0_align_x = global i32 4
+
+// CHECK-GLOBAL: @s0_align_y = global i32 1
+
+// CHECK-GLOBAL: @s0_align = global i32 4
+int s0_align_x = __alignof(((struct s0*)0)->x);
+int s0_align_y = __alignof(((struct s0*)0)->y);
+int s0_align = __alignof(struct s0);
+
+// CHECK-FUNCTIONS: define i32 @s0_load_x
+// CHECK-FUNCTIONS: [[s0_load_x:%.*]] = load i32* {{.*}}, align 4
+// CHECK-FUNCTIONS: ret i32 [[s0_load_x]]
+int s0_load_x(struct s0 *a) { return a->x; }
+// FIXME: This seems like it should be align 1. This is actually something which
+// has changed in llvm-gcc recently, previously both x and y would be loaded
+// with align 1 (in 2363.1 at least).
+//
+// CHECK-FUNCTIONS: define i32 @s0_load_y
+// CHECK-FUNCTIONS: [[s0_load_y:%.*]] = load i32* {{.*}}, align 1
+// CHECK-FUNCTIONS: ret i32 [[s0_load_y]]
+int s0_load_y(struct s0 *a) { return a->y; }
+// CHECK-FUNCTIONS: define void @s0_copy
+// CHECK-FUNCTIONS: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 8, i32 4, i1 false)
+void s0_copy(struct s0 *a, struct s0 *b) { *b = *a; }
+
+//
+
+struct s1 {
+ int x;
+ int y;
+} __attribute__((packed));
+
+// CHECK-GLOBAL: @s1_align_x = global i32 1
+// CHECK-GLOBAL: @s1_align_y = global i32 1
+// CHECK-GLOBAL: @s1_align = global i32 1
+int s1_align_x = __alignof(((struct s1*)0)->x);
+int s1_align_y = __alignof(((struct s1*)0)->y);
+int s1_align = __alignof(struct s1);
+
+// CHECK-FUNCTIONS: define i32 @s1_load_x
+// CHECK-FUNCTIONS: [[s1_load_x:%.*]] = load i32* {{.*}}, align 1
+// CHECK-FUNCTIONS: ret i32 [[s1_load_x]]
+int s1_load_x(struct s1 *a) { return a->x; }
+// CHECK-FUNCTIONS: define i32 @s1_load_y
+// CHECK-FUNCTIONS: [[s1_load_y:%.*]] = load i32* {{.*}}, align 1
+// CHECK-FUNCTIONS: ret i32 [[s1_load_y]]
+int s1_load_y(struct s1 *a) { return a->y; }
+// CHECK-FUNCTIONS: define void @s1_copy
+// CHECK-FUNCTIONS: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 8, i32 1, i1 false)
+void s1_copy(struct s1 *a, struct s1 *b) { *b = *a; }
+
+//
+
+#pragma pack(push,2)
+struct s2 {
+ int x;
+ int y;
+};
+#pragma pack(pop)
+
+// CHECK-GLOBAL: @s2_align_x = global i32 2
+// CHECK-GLOBAL: @s2_align_y = global i32 2
+// CHECK-GLOBAL: @s2_align = global i32 2
+int s2_align_x = __alignof(((struct s2*)0)->x);
+int s2_align_y = __alignof(((struct s2*)0)->y);
+int s2_align = __alignof(struct s2);
+
+// CHECK-FUNCTIONS: define i32 @s2_load_x
+// CHECK-FUNCTIONS: [[s2_load_y:%.*]] = load i32* {{.*}}, align 2
+// CHECK-FUNCTIONS: ret i32 [[s2_load_y]]
+int s2_load_x(struct s2 *a) { return a->x; }
+// CHECK-FUNCTIONS: define i32 @s2_load_y
+// CHECK-FUNCTIONS: [[s2_load_y:%.*]] = load i32* {{.*}}, align 2
+// CHECK-FUNCTIONS: ret i32 [[s2_load_y]]
+int s2_load_y(struct s2 *a) { return a->y; }
+// CHECK-FUNCTIONS: define void @s2_copy
+// CHECK-FUNCTIONS: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 8, i32 2, i1 false)
+void s2_copy(struct s2 *a, struct s2 *b) { *b = *a; }
+
+struct __attribute__((packed, aligned)) s3 {
+ short aShort;
+ int anInt;
+};
+// CHECK-GLOBAL: @s3_1 = global i32 1
+int s3_1 = __alignof(((struct s3*) 0)->anInt);
+// CHECK-FUNCTIONS: define i32 @test3(
+int test3(struct s3 *ptr) {
+ // CHECK-FUNCTIONS: [[PTR:%.*]] = getelementptr inbounds {{%.*}}* {{%.*}}, i32 0, i32 1
+ // CHECK-FUNCTIONS-NEXT: load i32* [[PTR]], align 1
+ return ptr->anInt;
+}
diff --git a/clang/test/CodeGen/packed-union.c b/clang/test/CodeGen/packed-union.c
new file mode 100644
index 0000000..31ce614
--- /dev/null
+++ b/clang/test/CodeGen/packed-union.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm %s -o %t
+
+typedef struct _attrs {
+ unsigned file_attributes;
+ unsigned char filename_length;
+} __attribute__((__packed__)) attrs;
+
+// RUN: grep "union._attr_union = type <{ i32, i8 }>" %t
+typedef union _attr_union {
+ attrs file_attrs;
+ unsigned owner_id;
+} __attribute__((__packed__)) attr_union;
+
+attr_union u;
+
diff --git a/clang/test/CodeGen/palignr.c b/clang/test/CodeGen/palignr.c
new file mode 100644
index 0000000..1712df5
--- /dev/null
+++ b/clang/test/CodeGen/palignr.c
@@ -0,0 +1,31 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -triple=i686-apple-darwin -target-feature +ssse3 -O1 -S -o - | FileCheck %s
+
+#define _mm_alignr_epi8(a, b, n) (__builtin_ia32_palignr128((a), (b), (n)))
+typedef __attribute__((vector_size(16))) int int4;
+
+// CHECK: palignr
+int4 align1(int4 a, int4 b) { return _mm_alignr_epi8(a, b, 15); }
+// CHECK: ret
+// CHECK: ret
+// CHECK-NOT: palignr
+int4 align2(int4 a, int4 b) { return _mm_alignr_epi8(a, b, 16); }
+// CHECK: psrldq
+int4 align3(int4 a, int4 b) { return _mm_alignr_epi8(a, b, 17); }
+// CHECK: xor
+int4 align4(int4 a, int4 b) { return _mm_alignr_epi8(a, b, 32); }
+
+#define _mm_alignr_pi8(a, b, n) (__builtin_ia32_palignr((a), (b), (n)))
+typedef __attribute__((vector_size(8))) int int2;
+
+// CHECK: palignr
+int2 align5(int2 a, int2 b) { return _mm_alignr_pi8(a, b, 8); }
+
+// CHECK: palignr
+int2 align6(int2 a, int2 b) { return _mm_alignr_pi8(a, b, 9); }
+
+// CHECK: palignr
+int2 align7(int2 a, int2 b) { return _mm_alignr_pi8(a, b, 16); }
+
+// CHECK: palignr
+int2 align8(int2 a, int2 b) { return _mm_alignr_pi8(a, b, 7); }
diff --git a/clang/test/CodeGen/parameter-passing.c b/clang/test/CodeGen/parameter-passing.c
new file mode 100644
index 0000000..e48815b
--- /dev/null
+++ b/clang/test/CodeGen/parameter-passing.c
@@ -0,0 +1,56 @@
+// Check the various ways in which the three classes of values
+// (scalar, complex, aggregate) interact with parameter passing
+// (function entry, function return, call argument, call result).
+//
+// We also check _Bool and empty structures, as these can have annoying
+// corner cases.
+
+// RUN: %clang_cc1 %s -triple i386-unknown-unknown -O3 -emit-llvm -o %t
+// RUN: not grep '@g0' %t
+
+// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -O3 -emit-llvm -o %t
+// RUN: not grep '@g0' %t
+
+// RUN: %clang_cc1 %s -triple powerpc-unknown-unknown -O3 -emit-llvm -o %t
+// RUN: not grep '@g0' %t
+
+typedef _Bool BoolTy;
+typedef int ScalarTy;
+typedef _Complex int ComplexTy;
+typedef struct { int a, b, c; } AggrTy;
+typedef struct { int a[0]; } EmptyTy;
+
+static int result;
+
+static BoolTy bool_id(BoolTy a) { return a; }
+static AggrTy aggr_id(AggrTy a) { return a; }
+static EmptyTy empty_id(EmptyTy a) { return a; }
+static ScalarTy scalar_id(ScalarTy a) { return a; }
+static ComplexTy complex_id(ComplexTy a) { return a; }
+
+static void bool_mul(BoolTy a) { result *= a; }
+
+static void aggr_mul(AggrTy a) { result *= a.a * a.b * a.c; }
+
+static void empty_mul(EmptyTy a) { result *= 53; }
+
+static void scalar_mul(ScalarTy a) { result *= a; }
+
+static void complex_mul(ComplexTy a) { result *= __real a * __imag a; }
+
+extern void g0(void);
+
+void f0(void) {
+ result = 1;
+
+ bool_mul(bool_id(1));
+ aggr_mul(aggr_id((AggrTy) { 2, 3, 5}));
+ empty_mul(empty_id((EmptyTy) {}));
+ scalar_mul(scalar_id(7));
+ complex_mul(complex_id(11 + 13i));
+
+ // This call should be eliminated.
+ if (result != 2 * 3 * 5 * 7 * 11 * 13 * 53)
+ g0();
+}
+
diff --git a/clang/test/CodeGen/pascal-string.c b/clang/test/CodeGen/pascal-string.c
new file mode 100644
index 0000000..0a9ee67
--- /dev/null
+++ b/clang/test/CodeGen/pascal-string.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s -fpascal-strings | grep "05Hello"
+
+unsigned char * Foo( void )
+{
+ static unsigned char s[256] = "\pHello";
+ return s;
+}
+
diff --git a/clang/test/CodeGen/pascal-wchar-string.c b/clang/test/CodeGen/pascal-wchar-string.c
new file mode 100644
index 0000000..626fc99
--- /dev/null
+++ b/clang/test/CodeGen/pascal-wchar-string.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s -fpascal-strings -fshort-wchar | FileCheck %s
+// rdar://8020384
+
+#include <stddef.h>
+
+extern void abort (void);
+
+typedef unsigned short UInt16;
+
+typedef UInt16 UniChar;
+
+int main(int argc, char* argv[])
+{
+
+ char st[] = "\pfoo"; // pascal string
+ UniChar wt[] = L"\pbar"; // pascal Unicode string
+ UniChar wt1[] = L"\p";
+ UniChar wt2[] = L"\pgorf";
+
+ if (st[0] != 3)
+ abort ();
+ if (wt[0] != 3)
+ abort ();
+ if (wt1[0] != 0)
+ abort ();
+ if (wt2[0] != 4)
+ abort ();
+
+ return 0;
+}
+
+// CHECK: [i16 3, i16 98, i16 97, i16 114, i16 0]
+// CHECK: [i16 4, i16 103, i16 111, i16 114, i16 102, i16 0]
+
+
+// PR8856 - -fshort-wchar makes wchar_t be unsigned.
+// CHECK: @test2
+// CHECK: store volatile i32 1, i32* %isUnsigned
+void test2() {
+ volatile int isUnsigned = (wchar_t)-1 > (wchar_t)0;
+}
diff --git a/clang/test/CodeGen/pointer-arithmetic.c b/clang/test/CodeGen/pointer-arithmetic.c
new file mode 100644
index 0000000..f67a36d
--- /dev/null
+++ b/clang/test/CodeGen/pointer-arithmetic.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -S %s -o -
+
+typedef int Int;
+
+int f0(int *a, Int *b) { return a - b; }
+
+int f1(const char *a, char *b) { return b - a; }
+
+// GNU extensions
+typedef void (*FP)(void);
+void *f2(void *a, int b) { return a + b; }
+void *f2_0(void *a, int b) { return &a[b]; }
+void *f2_1(void *a, int b) { return (a += b); }
+void *f3(int a, void *b) { return a + b; }
+void *f3_1(int a, void *b) { return (a += b); }
+void *f4(void *a, int b) { return a - b; }
+void *f4_1(void *a, int b) { return (a -= b); }
+FP f5(FP a, int b) { return a + b; }
+FP f5_1(FP a, int b) { return (a += b); }
+FP f6(int a, FP b) { return a + b; }
+FP f6_1(int a, FP b) { return (a += b); }
+FP f7(FP a, int b) { return a - b; }
+FP f7_1(FP a, int b) { return (a -= b); }
+void f8(void *a, int b) { return *(a + b); }
+void f8_1(void *a, int b) { return a[b]; }
diff --git a/clang/test/CodeGen/pointer-cmp-type.c b/clang/test/CodeGen/pointer-cmp-type.c
new file mode 100644
index 0000000..59b2712
--- /dev/null
+++ b/clang/test/CodeGen/pointer-cmp-type.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | grep "icmp ult"
+
+int a(char* a, char* b) {return a<b;}
diff --git a/clang/test/CodeGen/pointer-signext.c b/clang/test/CodeGen/pointer-signext.c
new file mode 100644
index 0000000..e809eff
--- /dev/null
+++ b/clang/test/CodeGen/pointer-signext.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple x86_64-pc-win32 -emit-llvm -O2 -o - %s | FileCheck %s
+
+// Under Windows 64, int and long are 32-bits. Make sure pointer math doesn't
+// cause any sign extensions.
+
+// CHECK: [[P:%.*]] = add i64 %param, -8
+// CHECK-NEXT: [[Q:%.*]] = inttoptr i64 [[P]] to [[R:%.*\*]]
+// CHECK-NEXT: {{%.*}} = getelementptr inbounds [[R]] [[Q]], i64 0, i32 0
+
+#define CR(Record, TYPE, Field) \
+ ((TYPE *) ((unsigned char *) (Record) - (unsigned char *) &(((TYPE *) 0)->Field)))
+
+typedef struct _LIST_ENTRY {
+ struct _LIST_ENTRY *ForwardLink;
+ struct _LIST_ENTRY *BackLink;
+} LIST_ENTRY;
+
+typedef struct {
+ unsigned long long Signature;
+ LIST_ENTRY Link;
+} MEMORY_MAP;
+
+int test(unsigned long long param)
+{
+ LIST_ENTRY *Link;
+ MEMORY_MAP *Entry;
+
+ Link = (LIST_ENTRY *) param;
+
+ Entry = CR (Link, MEMORY_MAP, Link);
+ return (int) Entry->Signature;
+}
diff --git a/clang/test/CodeGen/pointer-to-int.c b/clang/test/CodeGen/pointer-to-int.c
new file mode 100644
index 0000000..30a6db2
--- /dev/null
+++ b/clang/test/CodeGen/pointer-to-int.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+int test(void* i)
+{
+ return (int)i;
+}
+
+// rdar://6093986
+int test2(void) {
+ float x[2];
+ return x;
+}
+
diff --git a/clang/test/CodeGen/popcnt-builtins.c b/clang/test/CodeGen/popcnt-builtins.c
new file mode 100644
index 0000000..f072b29
--- /dev/null
+++ b/clang/test/CodeGen/popcnt-builtins.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <x86intrin.h>
+
+unsigned int test_mm_popcnt_u32(unsigned int __X) {
+ // CHECK: @llvm.ctpop.i32
+ return _mm_popcnt_u32(__X);
+}
+
+unsigned long long test_mm_popcnt_u64(unsigned long long __X) {
+ // CHECK: @llvm.ctpop.i64
+ return _mm_popcnt_u64(__X);
+}
diff --git a/clang/test/CodeGen/powerpc_types.c b/clang/test/CodeGen/powerpc_types.c
new file mode 100644
index 0000000..b7d0f5d
--- /dev/null
+++ b/clang/test/CodeGen/powerpc_types.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple powerpc-unknown-freebsd -emit-llvm -o - %s| FileCheck -check-prefix=SVR4-CHECK %s
+
+#include <stdarg.h>
+
+int va_list_size = sizeof(va_list);
+// SVR4-CHECK: va_list_size = global i32 12, align 4
+int long_double_size = sizeof(long double);
+// SVR4-CHECK: long_double_size = global i32 8, align 4
+int double_size = sizeof(double);
+// SVR4-CHECK: double_size = global i32 8, align 4
diff --git a/clang/test/CodeGen/pr12251.c b/clang/test/CodeGen/pr12251.c
new file mode 100644
index 0000000..a644bb7
--- /dev/null
+++ b/clang/test/CodeGen/pr12251.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -emit-llvm -O1 -relaxed-aliasing -o - | FileCheck %s
+
+enum e1 {e1_a = -1 };
+enum e1 g1(enum e1 *x) {
+ return *x;
+}
+
+// CHECK: define i32 @g1
+// CHECK: load i32* %x, align 4
+// CHECK-NOT: range
+// CHECK: ret
diff --git a/clang/test/CodeGen/pr2394.c b/clang/test/CodeGen/pr2394.c
new file mode 100644
index 0000000..e43281a
--- /dev/null
+++ b/clang/test/CodeGen/pr2394.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+struct __attribute((packed)) x {int a : 24;};
+int a(struct x* g) {
+ // CHECK: load i16
+ // CHECK: load i8
+ return g->a;
+}
diff --git a/clang/test/CodeGen/pr3518.c b/clang/test/CodeGen/pr3518.c
new file mode 100644
index 0000000..f96a5aa
--- /dev/null
+++ b/clang/test/CodeGen/pr3518.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -emit-llvm -O0 -o - | FileCheck %s
+// PR 3518
+// Some of the objects were coming out as unintialized (external) before 3518
+// was fixed. Internal names are different between llvm-gcc and clang so they
+// are not tested.
+
+extern void abort (void);
+
+// CHECK: @.compoundliteral = internal global %struct.A { i32 1, i32 2 }
+// CHECK: @.compoundliteral1 = internal global %struct.A { i32 3, i32 4 }
+// CHECK: @.compoundliteral2 = internal global %struct.B { %struct.A* @.compoundliteral, %struct.A* @.compoundliteral1 }
+// CHECK: @.compoundliteral3 = internal global %struct.A { i32 5, i32 6 }
+
+struct A { int i; int j; };
+struct B { struct A *a; struct A *b; };
+struct C { struct B *c; struct A *d; };
+struct C e = { &(struct B) { &(struct A) { 1, 2 }, &(struct A) { 3, 4 } }, &(struct A) { 5, 6 } };
+
+int
+main (void)
+{
+ if (e.c->a->i != 1 || e.c->a->j != 2)
+ abort ();
+ if (e.c->b->i != 3 || e.c->b->j != 4)
+ abort ();
+ if (e.d->i != 5 || e.d->j != 6)
+ abort ();
+ return 0;
+}
diff --git a/clang/test/CodeGen/pr4349.c b/clang/test/CodeGen/pr4349.c
new file mode 100644
index 0000000..94b4fbd
--- /dev/null
+++ b/clang/test/CodeGen/pr4349.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 %s -emit-llvm -O0 -o - | FileCheck %s
+// PR 4349
+
+union reg
+{
+ unsigned char b[2][2];
+ unsigned short w[2];
+ unsigned int d;
+};
+struct cpu
+{
+ union reg pc;
+};
+extern struct cpu cpu;
+struct svar
+{
+ void *ptr;
+};
+// CHECK: @svars1 = global [1 x %struct.svar] [%struct.svar { i8* bitcast (%struct.cpu* @cpu to i8*) }]
+struct svar svars1[] =
+{
+ { &((cpu.pc).w[0]) }
+};
+// CHECK: @svars2 = global [1 x %struct.svar] [%struct.svar { i8* getelementptr (i8* bitcast (%struct.cpu* @cpu to i8*), i64 1) }]
+struct svar svars2[] =
+{
+ { &((cpu.pc).b[0][1]) }
+};
+// CHECK: @svars3 = global [1 x %struct.svar] [%struct.svar { i8* getelementptr (i8* bitcast (%struct.cpu* @cpu to i8*), i64 2) }]
+struct svar svars3[] =
+{
+ { &((cpu.pc).w[1]) }
+};
+// CHECK: @svars4 = global [1 x %struct.svar] [%struct.svar { i8* getelementptr (i8* bitcast (%struct.cpu* @cpu to i8*), i64 3) }]
+struct svar svars4[] =
+{
+ { &((cpu.pc).b[1][1]) }
+};
diff --git a/clang/test/CodeGen/pr5406.c b/clang/test/CodeGen/pr5406.c
new file mode 100644
index 0000000..da74d6b
--- /dev/null
+++ b/clang/test/CodeGen/pr5406.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple arm-apple-darwin -o - | FileCheck %s
+// PR 5406
+
+typedef struct { char x[3]; } A0;
+void foo (int i, ...);
+
+
+// CHECK: call arm_aapcscc void (i32, ...)* @foo(i32 1, [1 x i32] {{.*}})
+int main (void)
+{
+ A0 a3;
+ a3.x[0] = 0;
+ a3.x[0] = 0;
+ a3.x[2] = 26;
+ foo (1, a3 );
+ return 0;
+}
diff --git a/clang/test/CodeGen/pr9614.c b/clang/test/CodeGen/pr9614.c
new file mode 100644
index 0000000..8fdb2f2
--- /dev/null
+++ b/clang/test/CodeGen/pr9614.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm %s -o - | FileCheck %s
+
+extern void foo_alias (void) __asm ("foo");
+inline void foo (void) {
+ return foo_alias ();
+}
+extern void bar_alias (void) __asm ("bar");
+inline __attribute__ ((__always_inline__)) void bar (void) {
+ return bar_alias ();
+}
+extern char *strrchr_foo (const char *__s, int __c) __asm ("strrchr");
+extern inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * strrchr_foo (const char *__s, int __c) {
+ return __builtin_strrchr (__s, __c);
+}
+void f(void) {
+ foo();
+ bar();
+ strrchr_foo("", '.');
+}
+
+// CHECK: define void @f()
+// CHECK: call void @foo()
+// CHECK-NEXT: call void @bar()
+// CHECK-NEXT: call i8* @strrchr(
+// CHECK-NEXT: ret void
+
+// CHECK: declare void @foo()
+// CHECK: declare void @bar()
+// CHECK: declare i8* @strrchr(i8*, i32)
diff --git a/clang/test/CodeGen/pragma-pack-1.c b/clang/test/CodeGen/pragma-pack-1.c
new file mode 100644
index 0000000..c30a62a
--- /dev/null
+++ b/clang/test/CodeGen/pragma-pack-1.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+
+// PR4610
+#pragma pack(4)
+struct ref {
+ struct ref *next;
+} refs;
diff --git a/clang/test/CodeGen/pragma-pack-2.c b/clang/test/CodeGen/pragma-pack-2.c
new file mode 100644
index 0000000..bfb34d7
--- /dev/null
+++ b/clang/test/CodeGen/pragma-pack-2.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 %s -emit-llvm -o - | FileCheck -check-prefix X32 %s
+// CHECK-X32: %struct.s0 = type { i64, i64, i32, [12 x i32] }
+// CHECK-X32: %struct.s1 = type { [15 x i32], %struct.s0 }
+
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -emit-llvm -o - | FileCheck -check-prefix X64 %s
+// CHECK-X64: %struct.s0 = type <{ i64, i64, i32, [12 x i32] }>
+// CHECK-X64: %struct.s1 = type <{ [15 x i32], %struct.s0 }>
+
+// rdar://problem/7095436
+#pragma pack(4)
+
+struct s0 {
+ long long a __attribute__((aligned(8)));
+ long long b __attribute__((aligned(8)));
+ unsigned int c __attribute__((aligned(8)));
+ int d[12];
+} a;
+
+struct s1 {
+ int a[15];
+ struct s0 b;
+} b;
+
diff --git a/clang/test/CodeGen/pragma-pack-3.c b/clang/test/CodeGen/pragma-pack-3.c
new file mode 100644
index 0000000..04b636e
--- /dev/null
+++ b/clang/test/CodeGen/pragma-pack-3.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 %s -emit-llvm -o - | FileCheck -check-prefix X32 %s
+// CHECK-X32: %union.command = type <{ i8*, [2 x i8] }>
+
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -emit-llvm -o - | FileCheck -check-prefix X64 %s
+// CHECK-X64: %union.command = type <{ i8*, [2 x i8] }>
+
+// <rdar://problem/7184250>
+#pragma pack(push, 2)
+typedef union command {
+ void *windowRef;
+ struct menu {
+ void *menuRef;
+ unsigned char menuItemIndex;
+ } menu;
+} command;
+
+command c;
diff --git a/clang/test/CodeGen/pragma-visibility.c b/clang/test/CodeGen/pragma-visibility.c
new file mode 100644
index 0000000..16460a2
--- /dev/null
+++ b/clang/test/CodeGen/pragma-visibility.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+#pragma GCC visibility push(hidden)
+int x = 2;
+// CHECK: @x = hidden global
+
+extern int y;
+#pragma GCC visibility pop
+int y = 4;
+// CHECK: @y = hidden global
+
+#pragma GCC visibility push(hidden)
+extern __attribute((visibility("default"))) int z;
+int z = 0;
+// CHECK: @z = global
+#pragma GCC visibility pop
+
+#pragma GCC visibility push(hidden)
+void f() {}
+// CHECK: define hidden void @f
+
+__attribute((visibility("default"))) void g();
+void g() {}
+// CHECK: define void @g
diff --git a/clang/test/CodeGen/pragma-weak.c b/clang/test/CodeGen/pragma-weak.c
new file mode 100644
index 0000000..7ad2b77
--- /dev/null
+++ b/clang/test/CodeGen/pragma-weak.c
@@ -0,0 +1,172 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm %s -o - -verify | FileCheck %s
+
+// CHECK: @weakvar = weak global
+// CHECK: @__weakvar_alias = common global
+// CHECK: @correct_linkage = weak global
+
+
+// CHECK: @both = alias void ()* @__both
+// CHECK: @both2 = alias void ()* @__both2
+// CHECK: @both3 = alias weak void ()* @__both3
+// CHECK: @a3 = alias weak void ()* @__a3
+// CHECK: @weakvar_alias = alias weak i32* @__weakvar_alias
+// CHECK: @foo = alias weak void ()* @__foo
+// CHECK: @foo2 = alias weak void ()* @__foo2
+// CHECK: @stutter = alias weak void ()* @__stutter
+// CHECK: @stutter2 = alias weak void ()* @__stutter2
+// CHECK: @declfirst = alias weak void ()* @__declfirst
+// CHECK: @declfirstattr = alias weak void ()* @__declfirstattr
+// CHECK: @mix2 = alias weak void ()* @__mix2
+// CHECK: @a1 = alias weak void ()* @__a1
+// CHECK: @xxx = alias weak void ()* @__xxx
+
+
+
+// CHECK: define weak void @weakdef()
+
+
+#pragma weak weakvar
+int weakvar;
+
+#pragma weak weakdef
+void weakdef(void) {}
+
+#pragma weak param // expected-warning {{weak identifier 'param' never declared}}
+#pragma weak correct_linkage
+void f(int param) {
+ int correct_linkage;
+}
+
+#pragma weak weakvar_alias = __weakvar_alias
+int __weakvar_alias;
+
+#pragma weak foo = __foo
+void __foo(void) {}
+// CHECK: define void @__foo()
+
+
+void __foo2(void) {}
+#pragma weak foo2 = __foo2
+// CHECK: define void @__foo2()
+
+
+///// test errors
+
+#pragma weak unused // expected-warning {{weak identifier 'unused' never declared}}
+#pragma weak unused_alias = __unused_alias // expected-warning {{weak identifier '__unused_alias' never declared}}
+
+#pragma weak td // expected-warning {{weak identifier 'td' never declared}}
+typedef int td;
+
+#pragma weak td2 = __td2 // expected-warning {{weak identifier '__td2' never declared}}
+typedef int __td2;
+
+
+///// test weird cases
+
+// test repeats
+
+#pragma weak stutter = __stutter
+#pragma weak stutter = __stutter
+void __stutter(void) {}
+// CHECK: define void @__stutter()
+
+void __stutter2(void) {}
+#pragma weak stutter2 = __stutter2
+#pragma weak stutter2 = __stutter2
+// CHECK: define void @__stutter2()
+
+
+// test decl/pragma weak order
+
+void __declfirst(void);
+#pragma weak declfirst = __declfirst
+void __declfirst(void) {}
+// CHECK: define void @__declfirst()
+
+void __declfirstattr(void) __attribute((noinline));
+#pragma weak declfirstattr = __declfirstattr
+void __declfirstattr(void) {}
+// CHECK: define void @__declfirstattr()
+
+//// test that other attributes are preserved
+
+//// ensure that pragma weak/__attribute((weak)) play nice
+
+void mix(void);
+#pragma weak mix
+__attribute((weak)) void mix(void) { }
+// CHECK: define weak void @mix()
+
+// ensure following __attributes are preserved and that only a single
+// alias is generated
+#pragma weak mix2 = __mix2
+void __mix2(void) __attribute((noinline));
+void __mix2(void) __attribute((noinline));
+void __mix2(void) {}
+// CHECK: define void @__mix2()
+
+////////////// test #pragma weak/__attribute combinations
+
+// if the SAME ALIAS is already declared then it overrides #pragma weak
+// resulting in a non-weak alias in this case
+void both(void) __attribute((alias("__both")));
+#pragma weak both = __both
+void __both(void) {}
+// CHECK: define void @__both()
+
+// if the TARGET is previously declared then whichever aliasing method
+// comes first applies and subsequent aliases are discarded.
+// TODO: warn about this
+
+void __both2(void);
+void both2(void) __attribute((alias("__both2"))); // first, wins
+#pragma weak both2 = __both2
+void __both2(void) {}
+// CHECK: define void @__both2()
+
+void __both3(void);
+#pragma weak both3 = __both3 // first, wins
+void both3(void) __attribute((alias("__both3")));
+void __both3(void) {}
+// CHECK: define void @__both3()
+
+///////////// ensure that #pragma weak does not alter existing __attributes()
+
+void __a1(void) __attribute((noinline));
+#pragma weak a1 = __a1
+void __a1(void) {}
+// CHECK: define void @__a1() {{.*}} noinline
+
+// attributes introduced BEFORE a combination of #pragma weak and alias()
+// hold...
+void __a3(void) __attribute((noinline));
+#pragma weak a3 = __a3
+void a3(void) __attribute((alias("__a3")));
+void __a3(void) {}
+// CHECK: define void @__a3() {{.*}} noinline
+
+#pragma weak xxx = __xxx
+__attribute((pure,noinline,const,fastcall)) void __xxx(void) { }
+// CHECK: void @__xxx() {{.*}} noinline
+
+///////////// PR10878: Make sure we can call a weak alias
+void SHA512Pad(void *context) {}
+#pragma weak SHA384Pad = SHA512Pad
+void PR10878() { SHA384Pad(0); }
+// CHECK: call void @SHA384Pad(i8* null)
+
+
+///////////// TODO: stuff that still doesn't work
+
+// due to the fact that disparate TopLevelDecls cannot affect each other
+// (due to clang's Parser and ASTConsumer behavior, and quite reasonable)
+// #pragma weak must appear before or within the same TopLevelDecl as it
+// references.
+void yyy(void){}
+void zzz(void){}
+#pragma weak yyy
+// NOTE: weak doesn't apply, not before or in same TopLevelDec(!)
+// CHECK: define void @yyy()
+
+int correct_linkage;
diff --git a/clang/test/CodeGen/predefined-expr.c b/clang/test/CodeGen/predefined-expr.c
new file mode 100644
index 0000000..e2826b6
--- /dev/null
+++ b/clang/test/CodeGen/predefined-expr.c
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: @__func__.plainFunction = private unnamed_addr constant [14 x i8] c"plainFunction\00"
+// CHECK: @__PRETTY_FUNCTION__.plainFunction = private unnamed_addr constant [21 x i8] c"void plainFunction()\00"
+// CHECK: @__func__.externFunction = private unnamed_addr constant [15 x i8] c"externFunction\00"
+// CHECK: @__PRETTY_FUNCTION__.externFunction = private unnamed_addr constant [22 x i8] c"void externFunction()\00"
+// CHECK: @__func__.privateExternFunction = private unnamed_addr constant [22 x i8] c"privateExternFunction\00"
+// CHECK: @__PRETTY_FUNCTION__.privateExternFunction = private unnamed_addr constant [29 x i8] c"void privateExternFunction()\00"
+// CHECK: @__func__.staticFunction = private unnamed_addr constant [15 x i8] c"staticFunction\00"
+// CHECK: @__PRETTY_FUNCTION__.staticFunction = private unnamed_addr constant [22 x i8] c"void staticFunction()\00"
+
+int printf(const char *, ...);
+
+void plainFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+extern void externFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+__private_extern__ void privateExternFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+static void staticFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+int main() {
+ plainFunction();
+ externFunction();
+ privateExternFunction();
+ staticFunction();
+
+ return 0;
+}
diff --git a/clang/test/CodeGen/private-extern-redef.c b/clang/test/CodeGen/private-extern-redef.c
new file mode 100644
index 0000000..580ce9b
--- /dev/null
+++ b/clang/test/CodeGen/private-extern-redef.c
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple x86_64-darwin-apple -emit-llvm -o - %s | FileCheck %s
+// rdar://9609649
+
+__private_extern__ const int I;
+__private_extern__ const int J = 927;
+
+__private_extern__ const int K;
+const int K = 37;
+
+const int L = 10;
+__private_extern__ const int L;
+
+__private_extern__ int M;
+int M = 20;
+
+__private_extern__ int N;
+int N;
+
+__private_extern__ int O;
+int O=1;
+
+__private_extern__ int P;
+extern int P;
+
+void bar(int);
+
+void foo() {
+ bar(I);
+}
+
+// CHECK: @J = hidden constant
+// CHECK: @K = hidden constant
+// CHECK: @L = constant
+// CHECK: @M = hidden global
+// CHECK: @O = hidden global
+// CHECK: @I = external hidden
+// CHECK: @N = common hidden global
+// CHECK-NOT: @P
+
diff --git a/clang/test/CodeGen/private-extern.c b/clang/test/CodeGen/private-extern.c
new file mode 100644
index 0000000..2d34d54
--- /dev/null
+++ b/clang/test/CodeGen/private-extern.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: grep '@g0 = external hidden constant i32' %t
+// RUN: grep '@g1 = hidden constant i32 1' %t
+
+__private_extern__ const int g0;
+__private_extern__ const int g1 = 1;
+
+int f0(void) {
+ return g0;
+}
diff --git a/clang/test/CodeGen/ptx-cc.c b/clang/test/CodeGen/ptx-cc.c
new file mode 100644
index 0000000..2212d42
--- /dev/null
+++ b/clang/test/CodeGen/ptx-cc.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple ptx32-unknown-unknown -O3 -S -o %t %s -emit-llvm
+// RUN: %clang_cc1 -triple ptx64-unknown-unknown -O3 -S -o %t %s -emit-llvm
+
+// Just make sure Clang uses the proper calling convention for the PTX back-end.
+// If something is wrong, the back-end will fail.
+void foo(float* a,
+ float* b) {
+ a[0] = b[0];
+}
diff --git a/clang/test/CodeGen/redef-ext-inline.c b/clang/test/CodeGen/redef-ext-inline.c
new file mode 100644
index 0000000..b8e2f36
--- /dev/null
+++ b/clang/test/CodeGen/redef-ext-inline.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -std=gnu89
+// rdar://7208839
+
+extern inline int f1 (void) {return 1;}
+int f3 (void) {return f1();}
+int f1 (void) {return 0;}
diff --git a/clang/test/CodeGen/redefine_extname.c b/clang/test/CodeGen/redefine_extname.c
new file mode 100644
index 0000000..e73a3ad
--- /dev/null
+++ b/clang/test/CodeGen/redefine_extname.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple=i386-pc-solaris2.11 -w -emit-llvm %s -o - | FileCheck %s
+
+#pragma redefine_extname fake real
+#pragma redefine_extname name alias
+
+extern int fake(void);
+
+int name;
+
+// __PRAGMA_REDEFINE_EXTNAME should be defined. This will fail if it isn't...
+int fish() { return fake() + __PRAGMA_REDEFINE_EXTNAME + name; }
+// Check that the call to fake() is emitted as a call to real()
+// CHECK: call i32 @real()
+// Check that this also works with variables names
+// CHECK: load i32* @alias
diff --git a/clang/test/CodeGen/regparm-flag.c b/clang/test/CodeGen/regparm-flag.c
new file mode 100644
index 0000000..8ecf539
--- /dev/null
+++ b/clang/test/CodeGen/regparm-flag.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 4 %s -emit-llvm -o %t
+// RUN: FileCheck < %t %s
+
+void f1(int a, int b, int c, int d,
+ int e, int f, int g, int h);
+
+void f2(int a, int b) __attribute((regparm(0)));
+
+void f0() {
+// CHECK: call void @f1(i32 inreg 1, i32 inreg 2, i32 inreg 3, i32 inreg 4,
+// CHECK: i32 5, i32 6, i32 7, i32 8)
+ f1(1, 2, 3, 4, 5, 6, 7, 8);
+// CHECK: call void @f2(i32 1, i32 2)
+ f2(1, 2);
+}
+
+// CHECK: declare void @f1(i32 inreg, i32 inreg, i32 inreg, i32 inreg,
+// CHECK: i32, i32, i32, i32)
+// CHECK: declare void @f2(i32, i32)
+
diff --git a/clang/test/CodeGen/regparm.c b/clang/test/CodeGen/regparm.c
new file mode 100644
index 0000000..d628b68
--- /dev/null
+++ b/clang/test/CodeGen/regparm.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+
+#define FASTCALL __attribute__((regparm(2)))
+
+typedef struct {
+ int aaa;
+ double bbbb;
+ int ccc[200];
+} foo;
+
+typedef void (*FType)(int, int) __attribute ((regparm (3), stdcall));
+FType bar;
+
+extern void FASTCALL reduced(char b, double c, foo* d, double e, int f);
+
+// PR7025
+void FASTCALL f1(int i, int j, int k);
+// CHECK: define void @f1(i32 inreg %i, i32 inreg %j, i32 %k)
+void f1(int i, int j, int k) { }
+
+int
+main(void) {
+ // CHECK: call void @reduced(i8 signext inreg 0, {{.*}} %struct.foo* inreg null
+ reduced(0, 0.0, 0, 0.0, 0);
+ // CHECK: call x86_stdcallcc void {{.*}}(i32 inreg 1, i32 inreg 2)
+ bar(1,2);
+}
diff --git a/clang/test/CodeGen/restrict.c b/clang/test/CodeGen/restrict.c
new file mode 100644
index 0000000..8bbff24
--- /dev/null
+++ b/clang/test/CodeGen/restrict.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-darwin-apple -emit-llvm %s -o - | FileCheck %s
+
+// PR6695
+
+// CHECK: define void @test0(i32* %{{.*}}, i32 %{{.*}})
+void test0(int *x, int y) {
+}
+
+// CHECK: define void @test1(i32* noalias %{{.*}}, i32 %{{.*}})
+void test1(int * restrict x, int y) {
+}
+
+// CHECK: define void @test2(i32* %{{.*}}, i32* noalias %{{.*}})
+void test2(int *x, int * restrict y) {
+}
+
+typedef int * restrict rp;
+
+// CHECK: define void @test3(i32* noalias %{{.*}}, i32 %{{.*}})
+void test3(rp x, int y) {
+}
+
+// CHECK: define void @test4(i32* %{{.*}}, i32* noalias %{{.*}})
+void test4(int *x, rp y) {
+}
+
diff --git a/clang/test/CodeGen/shared-string-literals.c b/clang/test/CodeGen/shared-string-literals.c
new file mode 100644
index 0000000..00636b0
--- /dev/null
+++ b/clang/test/CodeGen/shared-string-literals.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+char *globalString = "abc";
+char *globalStringArray[5] = { "123", "abc" };
+char *anotherGlobalString = "123";
+
+int main() {
+ printf("123");
+}
diff --git a/clang/test/CodeGen/sizeof-vla.c b/clang/test/CodeGen/sizeof-vla.c
new file mode 100644
index 0000000..c5fc912
--- /dev/null
+++ b/clang/test/CodeGen/sizeof-vla.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o %t %s
+
+// PR3442
+
+void *g(unsigned long len);
+
+void
+f(int n)
+{
+ unsigned begin_set[n];
+
+ g(sizeof(begin_set));
+}
diff --git a/clang/test/CodeGen/sret.c b/clang/test/CodeGen/sret.c
new file mode 100644
index 0000000..ed1f9a4
--- /dev/null
+++ b/clang/test/CodeGen/sret.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -emit-llvm -O0 -o - | grep sret | count 5
+
+struct abc {
+ long a;
+ long b;
+ long c;
+};
+
+struct abc foo1(void);
+struct abc foo2();
+
+void bar() {
+ struct abc dummy1 = foo1();
+ struct abc dummy2 = foo2();
+}
diff --git a/clang/test/CodeGen/sret2.c b/clang/test/CodeGen/sret2.c
new file mode 100644
index 0000000..c96ce4d
--- /dev/null
+++ b/clang/test/CodeGen/sret2.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -emit-llvm -O0 -o - | grep sret | count 2
+
+struct abc {
+ long a;
+ long b;
+ long c;
+};
+
+struct abc foo2(){}
diff --git a/clang/test/CodeGen/sse-builtins.c b/clang/test/CodeGen/sse-builtins.c
new file mode 100644
index 0000000..2d57425
--- /dev/null
+++ b/clang/test/CodeGen/sse-builtins.c
@@ -0,0 +1,153 @@
+// RUN: %clang_cc1 -ffreestanding -triple i386-apple-darwin9 -target-cpu pentium4 -target-feature +sse4.1 -g -emit-llvm %s -o - | FileCheck %s
+
+#include <emmintrin.h>
+#include <smmintrin.h>
+
+__m128 test_loadl_pi(__m128 x, void* y) {
+ // CHECK: define {{.*}} @test_loadl_pi
+ // CHECK: load <2 x float>* {{.*}}, align 1{{$}}
+ // CHECK: shufflevector {{.*}} <4 x i32> <i32 0, i32 1
+ // CHECK: shufflevector {{.*}} <4 x i32> <i32 4, i32 5, i32 2, i32 3>
+ return _mm_loadl_pi(x,y);
+}
+
+__m128 test_loadh_pi(__m128 x, void* y) {
+ // CHECK: define {{.*}} @test_loadh_pi
+ // CHECK: load <2 x float>* {{.*}}, align 1{{$}}
+ // CHECK: shufflevector {{.*}} <4 x i32> <i32 0, i32 1
+ // CHECK: shufflevector {{.*}} <4 x i32> <i32 0, i32 1, i32 4, i32 5>
+ return _mm_loadh_pi(x,y);
+}
+
+__m128 test_load_ss(void* y) {
+ // CHECK: define {{.*}} @test_load_ss
+ // CHECK: load float* {{.*}}, align 1{{$}}
+ return _mm_load_ss(y);
+}
+
+__m128 test_load1_ps(void* y) {
+ // CHECK: define {{.*}} @test_load1_ps
+ // CHECK: load float* {{.*}}, align 1{{$}}
+ return _mm_load1_ps(y);
+}
+
+void test_store_ss(__m128 x, void* y) {
+ // CHECK: define void @test_store_ss
+ // CHECK: store {{.*}} float* {{.*}}, align 1,
+ _mm_store_ss(y, x);
+}
+
+__m128d test_load1_pd(__m128 x, void* y) {
+ // CHECK: define {{.*}} @test_load1_pd
+ // CHECK: load double* {{.*}}, align 1{{$}}
+ return _mm_load1_pd(y);
+}
+
+__m128d test_loadr_pd(__m128 x, void* y) {
+ // CHECK: define {{.*}} @test_loadr_pd
+ // CHECK: load <2 x double>* {{.*}}, align 16{{$}}
+ return _mm_loadr_pd(y);
+}
+
+__m128d test_load_sd(void* y) {
+ // CHECK: define {{.*}} @test_load_sd
+ // CHECK: load double* {{.*}}, align 1{{$}}
+ return _mm_load_sd(y);
+}
+
+__m128d test_loadh_pd(__m128d x, void* y) {
+ // CHECK: define {{.*}} @test_loadh_pd
+ // CHECK: load double* {{.*}}, align 1{{$}}
+ return _mm_loadh_pd(x, y);
+}
+
+__m128d test_loadl_pd(__m128d x, void* y) {
+ // CHECK: define {{.*}} @test_loadl_pd
+ // CHECK: load double* {{.*}}, align 1{{$}}
+ return _mm_loadl_pd(x, y);
+}
+
+void test_store_sd(__m128d x, void* y) {
+ // CHECK: define void @test_store_sd
+ // CHECK: store {{.*}} double* {{.*}}, align 1{{$}}
+ _mm_store_sd(y, x);
+}
+
+void test_store1_pd(__m128d x, void* y) {
+ // CHECK: define void @test_store1_pd
+ // CHECK: store {{.*}} double* {{.*}}, align 1{{$}}
+ // CHECK: store {{.*}} double* {{.*}}, align 1{{$}}
+ _mm_store1_pd(y, x);
+}
+
+void test_storer_pd(__m128d x, void* y) {
+ // CHECK: define void @test_storer_pd
+ // CHECK: store {{.*}} <2 x double>* {{.*}}, align 16{{$}}
+ _mm_storer_pd(y, x);
+}
+
+void test_storeh_pd(__m128d x, void* y) {
+ // CHECK: define void @test_storeh_pd
+ // CHECK: store {{.*}} double* {{.*}}, align 1{{$}}
+ _mm_storeh_pd(y, x);
+}
+
+void test_storel_pd(__m128d x, void* y) {
+ // CHECK: define void @test_storel_pd
+ // CHECK: store {{.*}} double* {{.*}}, align 1{{$}}
+ _mm_storel_pd(y, x);
+}
+
+__m128i test_loadl_epi64(void* y) {
+ // CHECK: define {{.*}} @test_loadl_epi64
+ // CHECK: load i64* {{.*}}, align 1{{$}}
+ return _mm_loadl_epi64(y);
+}
+
+__m128i test_mm_minpos_epu16(__m128i x) {
+ // CHECK: define {{.*}} @test_mm_minpos_epu16
+ // CHECK: @llvm.x86.sse41.phminposuw
+ return _mm_minpos_epu16(x);
+}
+
+__m128i test_mm_mpsadbw_epu8(__m128i x, __m128i y) {
+ // CHECK: define {{.*}} @test_mm_mpsadbw_epu8
+ // CHECK: @llvm.x86.sse41.mpsadbw
+ return _mm_mpsadbw_epu8(x, y, 1);
+}
+
+__m128 test_mm_dp_ps(__m128 x, __m128 y) {
+ // CHECK: define {{.*}} @test_mm_dp_ps
+ // CHECK: @llvm.x86.sse41.dpps
+ return _mm_dp_ps(x, y, 2);
+}
+
+__m128d test_mm_dp_pd(__m128d x, __m128d y) {
+ // CHECK: define {{.*}} @test_mm_dp_pd
+ // CHECK: @llvm.x86.sse41.dppd
+ return _mm_dp_pd(x, y, 2);
+}
+
+__m128 test_mm_round_ps(__m128 x) {
+ // CHECK: define {{.*}} @test_mm_round_ps
+ // CHECK: @llvm.x86.sse41.round.ps
+ return _mm_round_ps(x, 2);
+}
+
+__m128 test_mm_round_ss(__m128 x, __m128 y) {
+ // CHECK: define {{.*}} @test_mm_round_ss
+ // CHECK: @llvm.x86.sse41.round.ss
+ return _mm_round_ss(x, y, 2);
+}
+
+__m128d test_mm_round_pd(__m128d x) {
+ // CHECK: define {{.*}} @test_mm_round_pd
+ // CHECK: @llvm.x86.sse41.round.pd
+ return _mm_round_pd(x, 2);
+}
+
+__m128d test_mm_round_sd(__m128d x, __m128d y) {
+ // CHECK: define {{.*}} @test_mm_round_sd
+ // CHECK: @llvm.x86.sse41.round.sd
+ return _mm_round_sd(x, y, 2);
+}
diff --git a/clang/test/CodeGen/stack-protector.c b/clang/test/CodeGen/stack-protector.c
new file mode 100644
index 0000000..eb4cea2
--- /dev/null
+++ b/clang/test/CodeGen/stack-protector.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 0 | FileCheck -check-prefix=NOSSP %s
+// NOSSP: define void @test1(i8* %msg) nounwind {
+// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 1 | FileCheck -check-prefix=WITHSSP %s
+// WITHSSP: define void @test1(i8* %msg) nounwind ssp {
+// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 2 | FileCheck -check-prefix=SSPREQ %s
+// SSPREQ: define void @test1(i8* %msg) nounwind sspreq {
+
+int printf(const char * _Format, ...);
+
+void test1(const char *msg) {
+ char a[strlen(msg) + 1];
+ strcpy(a, msg);
+ printf("%s\n", a);
+}
diff --git a/clang/test/CodeGen/statements.c b/clang/test/CodeGen/statements.c
new file mode 100644
index 0000000..e2bbb5a
--- /dev/null
+++ b/clang/test/CodeGen/statements.c
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -Wno-error=return-type %s -emit-llvm-only
+
+void test1(int x) {
+switch (x) {
+case 111111111111111111111111111111111111111:
+bar();
+}
+}
+
+// Mismatched type between return and function result.
+int test2() { return; }
+void test3() { return 4; }
+
+
+void test4() {
+bar:
+baz:
+blong:
+bing:
+ ;
+
+// PR5131
+static long x = &&bar - &&baz;
+static long y = &&baz;
+ &&bing;
+ &&blong;
+ if (y)
+ goto *y;
+
+ goto *x;
+}
+
+// PR3869
+int test5(long long b) {
+ static void *lbls[] = { &&lbl };
+ goto *b;
+ lbl:
+ return 0;
+}
+
diff --git a/clang/test/CodeGen/static-forward-decl-fun.c b/clang/test/CodeGen/static-forward-decl-fun.c
new file mode 100644
index 0000000..e33ee62
--- /dev/null
+++ b/clang/test/CodeGen/static-forward-decl-fun.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+
+static int staticfun(void);
+int (*staticuse1)(void) = staticfun;
+static int staticfun() {return 1;}
+int (*staticuse2)(void) = staticfun;
diff --git a/clang/test/CodeGen/static-forward-decl.c b/clang/test/CodeGen/static-forward-decl.c
new file mode 100644
index 0000000..0d35061
--- /dev/null
+++ b/clang/test/CodeGen/static-forward-decl.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin9 | grep "global i32 10"
+
+static int i;
+int*j=&i;
+static int i = 10;
diff --git a/clang/test/CodeGen/static-local-union.c b/clang/test/CodeGen/static-local-union.c
new file mode 100644
index 0000000..bd32519
--- /dev/null
+++ b/clang/test/CodeGen/static-local-union.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm < %s
+
+int a() {static union{int a;} r[2] = {1,2};return r[1].a;}
+
diff --git a/clang/test/CodeGen/static-order.c b/clang/test/CodeGen/static-order.c
new file mode 100644
index 0000000..e7f9814
--- /dev/null
+++ b/clang/test/CodeGen/static-order.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// CHECK: ModuleID
+// CHECK-NOT: zeroinitializer
+// CHECK: define i8* @f
+
+struct s {
+ int a;
+};
+
+static void *v;
+
+static struct s a;
+
+static struct s a = {
+ 10
+};
+
+void *f()
+{
+ if (a.a)
+ return v;
+}
diff --git a/clang/test/CodeGen/staticinit.c b/clang/test/CodeGen/staticinit.c
new file mode 100644
index 0000000..8c5cdd0
--- /dev/null
+++ b/clang/test/CodeGen/staticinit.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o %t %s
+// RUN: grep "g.b = internal global i8. getelementptr" %t
+
+struct AStruct {
+ int i;
+ char *s;
+ double d;
+};
+
+void f() {
+ static int i = 42;
+ static int is[] = { 1, 2, 3, 4 };
+ static char* str = "forty-two";
+ static char* strs[] = { "one", "two", "three", "four" };
+ static struct AStruct myStruct = { 1, "two", 3.0 };
+}
+
+void g() {
+ static char a[10];
+ static char *b = a;
+}
+
+struct s { void *p; };
+
+void foo(void) {
+ static struct s var = {((void*)&((char*)0)[0])};
+}
+
+// RUN: grep "f1.l0 = internal global i32 ptrtoint (i32 ()\* @f1 to i32)" %t
+int f1(void) { static int l0 = (unsigned) f1; }
+
+// PR7044
+char *f2(char key) {
+ switch (key) {
+ static char _msg[40];
+ case '\014':
+ return _msg;
+ }
+
+ return 0;
+}
diff --git a/clang/test/CodeGen/stdcall-fastcall.c b/clang/test/CodeGen/stdcall-fastcall.c
new file mode 100644
index 0000000..3de7b67
--- /dev/null
+++ b/clang/test/CodeGen/stdcall-fastcall.c
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s
+
+void __attribute__((fastcall)) f1(void);
+void __attribute__((stdcall)) f2(void);
+void __attribute__((thiscall)) f3(void);
+void __attribute__((fastcall)) f4(void) {
+// CHECK: define x86_fastcallcc void @f4()
+ f1();
+// CHECK: call x86_fastcallcc void @f1()
+}
+void __attribute__((stdcall)) f5(void) {
+// CHECK: define x86_stdcallcc void @f5()
+ f2();
+// CHECK: call x86_stdcallcc void @f2()
+}
+void __attribute__((thiscall)) f6(void) {
+// CHECK: define x86_thiscallcc void @f6()
+ f3();
+// CHECK: call x86_thiscallcc void @f3()
+}
+
+// PR5280
+void (__attribute__((fastcall)) *pf1)(void) = f1;
+void (__attribute__((stdcall)) *pf2)(void) = f2;
+void (__attribute__((thiscall)) *pf3)(void) = f3;
+void (__attribute__((fastcall)) *pf4)(void) = f4;
+void (__attribute__((stdcall)) *pf5)(void) = f5;
+void (__attribute__((thiscall)) *pf6)(void) = f6;
+
+int main(void) {
+ f4(); f5(); f6();
+ // CHECK: call x86_fastcallcc void @f4()
+ // CHECK: call x86_stdcallcc void @f5()
+ // CHECK: call x86_thiscallcc void @f6()
+ pf1(); pf2(); pf3(); pf4(); pf5(); pf6();
+ // CHECK: call x86_fastcallcc void %{{.*}}()
+ // CHECK: call x86_stdcallcc void %{{.*}}()
+ // CHECK: call x86_thiscallcc void %{{.*}}()
+ // CHECK: call x86_fastcallcc void %{{.*}}()
+ // CHECK: call x86_stdcallcc void %{{.*}}()
+ // CHECK: call x86_thiscallcc void %{{.*}}()
+ return 0;
+}
+
+// PR7117
+void __attribute((stdcall)) f7(foo) int foo; {}
+void f8(void) {
+ f7(0);
+ // CHECK: call x86_stdcallcc void @f7(i32 0)
+}
diff --git a/clang/test/CodeGen/string-literal-short-wstring.c b/clang/test/CodeGen/string-literal-short-wstring.c
new file mode 100644
index 0000000..88e4a1e
--- /dev/null
+++ b/clang/test/CodeGen/string-literal-short-wstring.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -x c++ -emit-llvm -fshort-wchar %s -o - | FileCheck %s
+// Runs in c++ mode so that wchar_t is available.
+
+int main() {
+ // This should convert to utf8.
+ // CHECK: private unnamed_addr constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1
+ char b[10] = "\u1120\u0220\U00102030";
+
+ // CHECK: private unnamed_addr constant [3 x i16] [i16 65, i16 66, i16 0]
+ const wchar_t *foo = L"AB";
+
+ // This should convert to utf16.
+ // CHECK: private unnamed_addr constant [5 x i16] [i16 4384, i16 544, i16 -9272, i16 -9168, i16 0]
+ const wchar_t *bar = L"\u1120\u0220\U00102030";
+
+
+
+ // Should pick second character.
+ // CHECK: store i8 98
+ char c = 'ab';
+
+ // CHECK: store i16 97
+ wchar_t wa = L'a';
+
+ // Should pick second character.
+ // CHECK: store i16 98
+ wchar_t wb = L'ab';
+
+ // -4085 == 0xf00b
+ // CHECK: store i16 -4085
+ wchar_t wc = L'\uF00B';
+}
diff --git a/clang/test/CodeGen/string-literal-unicode-conversion.c b/clang/test/CodeGen/string-literal-unicode-conversion.c
new file mode 100644
index 0000000..3e5b7fb
--- /dev/null
+++ b/clang/test/CodeGen/string-literal-unicode-conversion.c
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=C %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CPP0X %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -fshort-wchar -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=SHORTWCHAR %s
+
+// This file contains a mix of ISO-8859-1 and UTF-8 encoded data.
+// the literal assigned to 'aa' should be the ISO-8859-1 encoding for the code
+// points U+00C0 U+00E9 U+00EE U+00F5 U+00FC
+
+// The rest of the literals should contain the UTF-8 encoding for U+041A U+043E
+// U+0448 U+043A U+0430
+
+#ifndef __cplusplus
+#include <stddef.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"
+#endif
+void f() {
+ // CHECK-C: private unnamed_addr constant [6 x i8] c"\C0\E9\EE\F5\FC\00", align 1
+ // CHECK-CPP0X: private unnamed_addr constant [6 x i8] c"\C0\E9\EE\F5\FC\00", align 1
+ char const *aa = "";
+
+ // CHECK-C: private unnamed_addr constant [11 x i8] c"\D0\9A\D0\BE\D1\88\D0\BA\D0\B0\00", align 1
+ // CHECK-CPP0X: private unnamed_addr constant [11 x i8] c"\D0\9A\D0\BE\D1\88\D0\BA\D0\B0\00", align 1
+ char const *a = "Кошка";
+
+ // CHECK-C: private unnamed_addr constant [6 x i32] [i32 1050, i32 1086, i32 1096, i32 1082, i32 1072, i32 0], align 4
+ // CHECK-SHORTWCHAR: private unnamed_addr constant [6 x i16] [i16 1050, i16 1086, i16 1096, i16 1082, i16 1072, i16 0], align 2
+ // CHECK-CPP0X: private unnamed_addr constant [6 x i32] [i32 1050, i32 1086, i32 1096, i32 1082, i32 1072, i32 0], align 4
+ wchar_t const *b = L"Кошка";
+
+ // CHECK-C: private unnamed_addr constant [4 x i32] [i32 20320, i32 22909, i32 66304, i32 0], align 4
+ // CHECK-SHORTWCHAR: private unnamed_addr constant [4 x i16] [i16 20320, i16 22909, i16 768, i16 0], align 2
+ // CHECK-CPP0X: private unnamed_addr constant [4 x i32] [i32 20320, i32 22909, i32 66304, i32 0], align 4
+ wchar_t const *b2 = L"\x4f60\x597d\x10300";
+
+#if __cplusplus >= 201103L
+
+ // CHECK-CPP0X: private unnamed_addr constant [12 x i8] c"1\D0\9A\D0\BE\D1\88\D0\BA\D0\B0\00", align 1
+ char const *c = u8"1Кошка";
+
+ // CHECK-CPP0X: private unnamed_addr constant [7 x i16] [i16 50, i16 1050, i16 1086, i16 1096, i16 1082, i16 1072, i16 0], align 2
+ char16_t const *e = u"2Кошка";
+
+ // CHECK-CPP0X: private unnamed_addr constant [7 x i32] [i32 51, i32 1050, i32 1086, i32 1096, i32 1082, i32 1072, i32 0], align 4
+ char32_t const *f = U"3Кошка";
+
+ // CHECK-CPP0X: private unnamed_addr constant [12 x i8] c"4\D0\9A\D0\BE\D1\88\D0\BA\D0\B0\00", align 1
+ char const *d = u8R"(4Кошка)";
+
+ // CHECK-CPP0X: private unnamed_addr constant [7 x i16] [i16 53, i16 1050, i16 1086, i16 1096, i16 1082, i16 1072, i16 0], align 2
+ char16_t const *g = uR"(5Кошка)";
+
+ // CHECK-CPP0X: private unnamed_addr constant [7 x i32] [i32 54, i32 1050, i32 1086, i32 1096, i32 1082, i32 1072, i32 0], align 4
+ char32_t const *h = UR"(6Кошка)";
+
+ // CHECK-SHORTWCHAR: private unnamed_addr constant [7 x i16] [i16 55, i16 1050, i16 1086, i16 1096, i16 1082, i16 1072, i16 0], align 2
+ // CHECK-CPP0X: private unnamed_addr constant [7 x i32] [i32 55, i32 1050, i32 1086, i32 1096, i32 1082, i32 1072, i32 0], align 4
+ wchar_t const *i = LR"(7Кошка)";
+
+#endif
+}
diff --git a/clang/test/CodeGen/string-literal.c b/clang/test/CodeGen/string-literal.c
new file mode 100644
index 0000000..12d431a
--- /dev/null
+++ b/clang/test/CodeGen/string-literal.c
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=C %s
+// RUN: %clang_cc1 -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=C %s
+// RUN: %clang_cc1 -x c++ -std=c++11 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CPP0X %s
+
+#include <stddef.h>
+
+int main() {
+ // CHECK-C: private unnamed_addr constant [10 x i8] c"abc\00\00\00\00\00\00\00", align 1
+ // CHECK-CPP0X: private unnamed_addr constant [10 x i8] c"abc\00\00\00\00\00\00\00", align 1
+ char a[10] = "abc";
+
+ // This should convert to utf8.
+ // CHECK-C: private unnamed_addr constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1
+ // CHECK-CPP0X: private unnamed_addr constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1
+ char b[10] = "\u1120\u0220\U00102030";
+
+ // CHECK-C: private unnamed_addr constant [3 x i32] [i32 65, i32 66, i32 0], align 4
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 65, i32 66, i32 0], align 4
+ const wchar_t *foo = L"AB";
+
+ // CHECK-C: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110027, i32 0], align 4
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110027, i32 0], align 4
+ const wchar_t *bar = L"\u1234\U0010F00B";
+
+ // CHECK-C: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110028, i32 0], align 4
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110028, i32 0], align 4
+ const wchar_t *baz = L"\u1234" "\U0010F00C";
+
+#if __cplusplus >= 201103L
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 67, i32 68, i32 0], align 4
+ const char32_t *c = U"CD";
+
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 4661, i32 1110028, i32 0], align 4
+ const char32_t *d = U"\u1235\U0010F00C";
+
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 4661, i32 1110027, i32 0], align 4
+ const char32_t *o = "\u1235" U"\U0010F00B";
+
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i16] [i16 69, i16 70, i16 0], align 2
+ const char16_t *e = u"EF";
+
+ // This should convert to utf16.
+ // CHECK-CPP0X: private unnamed_addr constant [5 x i16] [i16 4384, i16 544, i16 -9272, i16 -9168, i16 0], align 2
+ const char16_t *f = u"\u1120\u0220\U00102030";
+
+ // This should convert to utf16.
+ // CHECK-CPP0X: private unnamed_addr constant [5 x i16] [i16 4384, i16 800, i16 -9272, i16 -9168, i16 0], align 2
+ const char16_t *p = u"\u1120\u0320" "\U00102030";
+
+ // CHECK-CPP0X: private unnamed_addr constant [4 x i8] c"def\00", align 1
+ const char *g = u8"def";
+
+ // CHECK-CPP0X: private unnamed_addr constant [4 x i8] c"ghi\00", align 1
+ const char *h = R"foo(ghi)foo";
+
+ // CHECK-CPP0X: private unnamed_addr constant [4 x i8] c"jkl\00", align 1
+ const char *i = u8R"bar(jkl)bar";
+
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i16] [i16 71, i16 72, i16 0], align 2
+ const char16_t *j = uR"foo(GH)foo";
+
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 73, i32 74, i32 0], align 4
+ const char32_t *k = UR"bar(IJ)bar";
+
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 75, i32 76, i32 0], align 4
+ const wchar_t *l = LR"bar(KL)bar";
+
+ // CHECK-CPP0X: private unnamed_addr constant [9 x i8] c"abc\5Cndef\00", align 1
+ const char *m = R"(abc\ndef)";
+
+ // CHECK-CPP0X: private unnamed_addr constant [8 x i8] c"abc\0Adef\00", align 1
+ const char *n = R"(abc
+def)";
+
+ // CHECK-CPP0X: private unnamed_addr constant [11 x i8] c"abc\0Adefghi\00", align 1
+ const char *q = R"(abc
+def)" "ghi";
+
+#endif
+}
diff --git a/clang/test/CodeGen/struct-comma.c b/clang/test/CodeGen/struct-comma.c
new file mode 100644
index 0000000..e5b5151
--- /dev/null
+++ b/clang/test/CodeGen/struct-comma.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+struct S {int a, b;} x;
+void a(struct S* b) {*b = (r(), x);}
diff --git a/clang/test/CodeGen/struct-copy.c b/clang/test/CodeGen/struct-copy.c
new file mode 100644
index 0000000..6f3b664
--- /dev/null
+++ b/clang/test/CodeGen/struct-copy.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | grep 'call.*llvm.memcpy'
+struct x { int a[100]; };
+
+
+void foo(struct x *P, struct x *Q) {
+ *P = *Q;
+}
diff --git a/clang/test/CodeGen/struct-init.c b/clang/test/CodeGen/struct-init.c
new file mode 100644
index 0000000..6247729
--- /dev/null
+++ b/clang/test/CodeGen/struct-init.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -S -triple armv7-apple-darwin %s -emit-llvm -o - | FileCheck %s
+
+typedef struct _zend_ini_entry zend_ini_entry;
+struct _zend_ini_entry {
+ void *mh_arg1;
+};
+
+char a;
+
+const zend_ini_entry ini_entries[] = {
+ { ((char*)&((zend_ini_entry*)0)->mh_arg1 - (char*)(void*)0)},
+};
+
+// PR7564
+struct GLGENH {
+ int : 27;
+ int EMHJAA : 1;
+};
+
+struct GLGENH ABHFBF = {1};
+
+typedef __attribute__(( ext_vector_type(2) )) unsigned int uint2;
+typedef __attribute__(( __vector_size__(8) )) unsigned int __neon_uint32x2_t;
+
+// rdar://8183908
+typedef unsigned int uint32_t;
+typedef __attribute__((neon_vector_type(2))) uint32_t uint32x2_t;
+void foo() {
+ const uint32x2_t signBit = { (uint2) 0x80000000 };
+}
+
+// CHECK: %struct.fp_struct_foo = type { void ([1 x i32])* }
+struct fp_struct_bar { int a; };
+
+struct fp_struct_foo {
+ void (*FP)(struct fp_struct_bar);
+} G;
diff --git a/clang/test/CodeGen/struct-matching-constraint.c b/clang/test/CodeGen/struct-matching-constraint.c
new file mode 100644
index 0000000..40c444f
--- /dev/null
+++ b/clang/test/CodeGen/struct-matching-constraint.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -S -emit-llvm -triple armv7a-apple-darwin %s -o /dev/null
+typedef unsigned short uint16_t;
+typedef __attribute__((neon_vector_type(8))) uint16_t uint16x8_t;
+
+void b(uint16x8_t sat, uint16x8_t luma)
+{
+ __asm__("vmov.16 %1, %0 \n\t"
+ "vtrn.16 %0, %1 \n\t"
+ :"=w"(luma), "=w"(sat)
+ :"0"(luma)
+ );
+
+}
diff --git a/clang/test/CodeGen/struct-passing.c b/clang/test/CodeGen/struct-passing.c
new file mode 100644
index 0000000..efb00ef
--- /dev/null
+++ b/clang/test/CodeGen/struct-passing.c
@@ -0,0 +1,24 @@
+// This verifies that structs returned from functions by value are passed
+// correctly according to their attributes and the ABI.
+// SEE: PR3835
+
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+typedef int T0;
+typedef struct { int a[16]; } T1;
+
+T0 __attribute__((const)) f0(void);
+T0 __attribute__((pure)) f1(void);
+T1 __attribute__((const)) f2(void);
+T1 __attribute__((pure)) f3(void);
+void __attribute__((const)) f4(T1 a);
+void __attribute__((pure)) f5(T1 a);
+
+void *ps[] = { f0, f1, f2, f3, f4, f5 };
+
+// CHECK: declare i32 @f0() nounwind readnone
+// CHECK: declare i32 @f1() nounwind readonly
+// CHECK: declare void @f2({{.*}} sret)
+// CHECK: declare void @f3({{.*}} sret)
+// CHECK: declare void @f4({{.*}} byval align 4)
+// CHECK: declare void @f5({{.*}} byval align 4)
diff --git a/clang/test/CodeGen/struct-x86-darwin.c b/clang/test/CodeGen/struct-x86-darwin.c
new file mode 100644
index 0000000..afdcb8a
--- /dev/null
+++ b/clang/test/CodeGen/struct-x86-darwin.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 < %s -emit-llvm > %t1 -triple=i686-apple-darwin9
+// RUN: grep "STest1 = type { i32, \[4 x i16\], double }" %t1
+// RUN: grep "STest2 = type { i16, i16, i32, i32 }" %t1
+// RUN: grep "STest3 = type { i8, i16, i32 }" %t1
+// RUN: grep "STestB1 = type { i8, i8 }" %t1
+// RUN: grep "STestB2 = type { i8, i8, i8 }" %t1
+// RUN: grep "STestB3 = type { i8, i8 }" %t1
+// RUN: grep "STestB4 = type { i8, i8, i8, i8 }" %t1
+// RUN: grep "STestB5 = type { i8, i8, \[2 x i8\], i8, i8 }" %t1
+// RUN: grep "STestB6 = type { i8, i8, \[2 x i8\] }" %t1
+// Test struct layout for x86-darwin target
+
+struct STest1 {int x; short y[4]; double z; } st1;
+struct STest2 {short a,b; int c,d; } st2;
+struct STest3 {char a; short b; int c; } st3;
+
+// Bitfields
+struct STestB1 {char a; char b:2; } stb1;
+struct STestB2 {char a; char b:5; char c:4; } stb2;
+struct STestB3 {char a; char b:2; } stb3;
+struct STestB4 {char a; short b:2; char c; } stb4;
+struct STestB5 {char a; short b:10; char c; } stb5;
+struct STestB6 {int a:1; char b; int c:13 } stb6;
+
+// Packed struct STestP1 {char a; short b; int c; } __attribute__((__packed__)) stp1;
diff --git a/clang/test/CodeGen/struct.c b/clang/test/CodeGen/struct.c
new file mode 100644
index 0000000..e173931
--- /dev/null
+++ b/clang/test/CodeGen/struct.c
@@ -0,0 +1,196 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o -
+
+struct {
+ int x;
+ int y;
+} point;
+
+void fn1() {
+ point.x = 42;
+}
+
+/* Nested member */
+struct {
+ struct {
+ int a;
+ int b;
+ } p1;
+} point2;
+
+void fn2() {
+ point2.p1.a = 42;
+}
+
+/* Indirect reference */
+typedef struct __sf {
+ unsigned char *c;
+ short flags;
+} F;
+
+typedef struct __sf2 {
+ F *ff;
+} F2;
+
+int fn3(F2 *c) {
+ if (c->ff->c >= 0)
+ return 1;
+ else
+ return 0;
+}
+
+/* Nested structs */
+typedef struct NA {
+ int data;
+ struct NA *next;
+} NA;
+void f1() { NA a; }
+
+typedef struct NB {
+ int d1;
+ struct _B2 {
+ int d2;
+ struct NB *n2;
+ } B2;
+} NB;
+
+void f2() { NB b; }
+
+extern NB *f3();
+void f4() {
+ f3()->d1 = 42;
+}
+
+void f5() {
+ (f3())->d1 = 42;
+}
+
+/* Function calls */
+typedef struct {
+ int location;
+ int length;
+} range;
+extern range f6();
+void f7() {
+ range r = f6();
+}
+
+/* Member expressions */
+typedef struct {
+ range range1;
+ range range2;
+} rangepair;
+
+void f8() {
+ rangepair p;
+
+ range r = p.range1;
+}
+
+void f9(range *p) {
+ range r = *p;
+}
+
+void f10(range *p) {
+ range r = p[0];
+}
+
+/* _Bool types */
+
+struct _w {
+ short a,b;
+ short c,d;
+ short e,f;
+ short g;
+
+ unsigned int h,i;
+
+ _Bool j,k;
+} ws;
+
+/* Implicit casts (due to typedefs) */
+typedef struct _a {
+ int a;
+} a;
+
+void f11() {
+ struct _a a1;
+ a a2;
+
+ a1 = a2;
+ a2 = a1;
+}
+
+/* Implicit casts (due to const) */
+void f12() {
+ struct _a a1;
+ const struct _a a2;
+
+ a1 = a2;
+}
+
+/* struct initialization */
+struct a13 {int b; int c;};
+struct a13 c13 = {5};
+typedef struct a13 a13;
+struct a14 { short a; int b; } x = {1, 1};
+
+/* flexible array members */
+struct a15 {char a; int b[];} c15;
+int a16(void) {c15.a = 1;}
+
+/* compound literals */
+void f13() {
+ a13 x; x = (a13){1,2};
+}
+
+/* va_arg */
+int f14(int i, ...) {
+ __builtin_va_list l;
+ __builtin_va_start(l,i);
+ a13 b = __builtin_va_arg(l, a13);
+ int c = __builtin_va_arg(l, a13).c;
+ return b.b;
+}
+
+/* Attribute packed */
+struct __attribute__((packed)) S2839 { double a[19]; signed char b; } s2839[5];
+
+struct __attribute__((packed)) SS { long double a; char b; } SS;
+
+
+/* As lvalue */
+
+int f15() {
+ extern range f15_ext();
+ return f15_ext().location;
+}
+
+range f16() {
+ extern rangepair f16_ext();
+ return f16_ext().range1;
+}
+
+int f17() {
+ extern range f17_ext();
+ range r;
+ return (r = f17_ext()).location;
+}
+
+range f18() {
+ extern rangepair f18_ext();
+ rangepair rp;
+ return (rp = f18_ext()).range1;
+}
+
+
+
+// Complex forward reference of struct.
+struct f19S;
+extern struct f19T {
+ struct f19S (*p)(void);
+} t;
+struct f19S { int i; };
+void f19(void) {
+ t.p();
+}
+
diff --git a/clang/test/CodeGen/switch-dce.c b/clang/test/CodeGen/switch-dce.c
new file mode 100644
index 0000000..a18d3bc
--- /dev/null
+++ b/clang/test/CodeGen/switch-dce.c
@@ -0,0 +1,234 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O0 %s -emit-llvm -o - | FileCheck %s
+
+// PR9322 and rdar://6970405
+
+// CHECK: @test1
+// CHECK-NOT: switch
+// CHECK-NOT: @dead
+// CHECK: add nsw i32 {{.*}}, 1
+// CHECK-NOT: switch
+// CHECK-NOT: @dead
+// CHECK: ret void
+int i;
+void dead();
+
+void test1() {
+ switch (1)
+ case 1:
+ ++i;
+
+ switch (0)
+ case 1:
+ dead();
+}
+
+
+// CHECK: @test2
+// CHECK-NOT: switch
+// CHECK-NOT: @dead
+// CHECK: add nsw i32 {{.*}}, 2
+// CHECK-NOT: switch
+// CHECK-NOT: @dead
+// CHECK: ret void
+void test2() {
+ switch (4) {
+ case 1:
+ dead();
+ break;
+ case 4:
+ i += 2;
+ // Fall off the end of the switch.
+ }
+}
+
+
+// CHECK: @test3
+// CHECK-NOT: switch
+// CHECK-NOT: @dead
+// CHECK: add nsw i32 {{.*}}, 2
+// CHECK-NOT: switch
+// CHECK-NOT: @dead
+// CHECK: ret void
+void test3() {
+ switch (4) {
+ case 1:
+ dead();
+ break;
+ case 4: {
+ i += 2;
+ break;
+ }
+ }
+}
+
+// CHECK: @test4
+// CHECK-NOT: switch
+// CHECK-NOT: @dead
+// CHECK: add nsw i32 {{.*}}, 2
+// CHECK-NOT: switch
+// CHECK-NOT: @dead
+// CHECK: ret void
+void test4() {
+ switch (4) {
+ case 1:
+ dead();
+ break;
+ default: {
+ i += 2;
+ break;
+ }
+ }
+}
+
+// This shouldn't crash codegen, but we don't have to optimize out the switch
+// in this case.
+void test5() {
+ switch (1) {
+ int x; // eliding var decl?
+ case 1:
+ x = 4;
+ i = x;
+ break;
+ }
+}
+
+// CHECK: @test6
+// CHECK-NOT: switch
+// CHECK-NOT: @dead
+// CHECK: ret void
+void test6() {
+ // Neither case is reachable.
+ switch (40) {
+ case 1:
+ dead();
+ break;
+ case 4: {
+ dead();
+ break;
+ }
+ }
+}
+
+// CHECK: @test7
+// CHECK-NOT: switch
+// CHECK-NOT: @dead
+// CHECK: add nsw i32
+// CHECK-NOT: switch
+// CHECK-NOT: @dead
+// CHECK: ret void
+void test7() {
+ switch (4) {
+ case 1:
+ dead();
+ break;
+ {
+ case 4: // crazy brace scenario
+ ++i;
+ }
+ break;
+ }
+}
+
+// CHECK: @test8
+// CHECK-NOT: switch
+// CHECK-NOT: @dead
+// CHECK: add nsw i32
+// CHECK-NOT: switch
+// CHECK-NOT: @dead
+// CHECK: ret void
+void test8() {
+ switch (4) {
+ case 1:
+ dead();
+ break;
+ case 4:
+ ++i;
+ // Fall off the end of the switch.
+ }
+}
+
+// CHECK: @test9
+// CHECK-NOT: switch
+// CHECK-NOT: @dead
+// CHECK: add nsw i32
+// CHECK: add nsw i32
+// CHECK-NOT: switch
+// CHECK-NOT: @dead
+// CHECK: ret void
+void test9(int i) {
+ switch (1) {
+ case 5:
+ dead();
+ case 1:
+ ++i;
+ // Fall through is fine.
+ case 4:
+ ++i;
+ break;
+ }
+}
+
+// CHECK: @test10
+// CHECK-NOT: switch
+// CHECK: ret i32
+int test10(void) {
+ switch(8) {
+ case 8:
+ break;
+ case 4:
+ break;
+ default:
+ dead();
+ }
+
+ return 0;
+}
+
+// CHECK: @test11
+// CHECK-NOT: switch
+// CHECK: ret void
+void test11() {
+ switch (1) {
+ case 1:
+ break;
+ case 42: ;
+ int x; // eliding var decl?
+ x = 4;
+ break;
+ }
+}
+
+// CHECK: @test12
+// CHECK-NOT: switch
+// CHECK: ret void
+void test12() {
+ switch (1) {
+ case 2: {
+ int a; // Ok to skip this vardecl.
+ a = 42;
+ }
+ case 1:
+ break;
+ case 42: ;
+ int x; // eliding var decl?
+ x = 4;
+ break;
+ }
+}
+
+// Verify that case 42 only calls test14 once.
+// CHECK: @test13
+// CHECK: call void @test13(i32 97)
+// CHECK-NEXT: br label %[[EPILOG2:[0-9.a-z]+]]
+// CHECK: [[EPILOG2]]
+// CHECK-NEXT: br label [[EPILOG:%[0-9.a-z]+]]
+// CHECK: call void @test13(i32 42)
+// CHECK-NEXT: br label [[EPILOG]]
+void test13(int x) {
+ switch (x) {
+ case 42: test13(97); // fallthrough
+ case 11: break;
+ default: test13(42); break;
+ }
+}
+
diff --git a/clang/test/CodeGen/switch.c b/clang/test/CodeGen/switch.c
new file mode 100644
index 0000000..8b94a09
--- /dev/null
+++ b/clang/test/CodeGen/switch.c
@@ -0,0 +1,213 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O3 %s -emit-llvm -o - | FileCheck %s
+
+int foo(int i) {
+ int j = 0;
+ switch (i) {
+ case -1:
+ j = 1; break;
+ case 1 :
+ j = 2; break;
+ case 2:
+ j = 3; break;
+ default:
+ j = 42; break;
+ }
+ j = j + 1;
+ return j;
+}
+
+int foo2(int i) {
+ int j = 0;
+ switch (i) {
+ case 1 :
+ j = 2; break;
+ case 2 ... 10:
+ j = 3; break;
+ default:
+ j = 42; break;
+ }
+ j = j + 1;
+ return j;
+}
+
+int foo3(int i) {
+ int j = 0;
+ switch (i) {
+ default:
+ j = 42; break;
+ case 111:
+ j = 111; break;
+ case 0 ... 100:
+ j = 1; break;
+ case 222:
+ j = 222; break;
+ }
+ return j;
+}
+
+
+static int foo4(int i) {
+ int j = 0;
+ switch (i) {
+ case 111:
+ j = 111; break;
+ case 0 ... 100:
+ j = 1; break;
+ case 222:
+ j = 222; break;
+ default:
+ j = 42; break;
+ case 501 ... 600:
+ j = 5; break;
+ }
+ return j;
+}
+
+// CHECK: define i32 @foo4t()
+// CHECK: ret i32 376
+// CHECK: }
+int foo4t() {
+ // 111 + 1 + 222 + 42 = 376
+ return foo4(111) + foo4(99) + foo4(222) + foo4(601);
+}
+
+// CHECK: define void @foo5()
+// CHECK-NOT: switch
+// CHECK: }
+void foo5(){
+ switch(0){
+ default:
+ if (0) {
+
+ }
+ }
+}
+
+// CHECK: define void @foo6()
+// CHECK-NOT: switch
+// CHECK: }
+void foo6(){
+ switch(0){
+ }
+}
+
+// CHECK: define void @foo7()
+// CHECK-NOT: switch
+// CHECK: }
+void foo7(){
+ switch(0){
+ foo7();
+ }
+}
+
+
+// CHECK: define i32 @f8(
+// CHECK: ret i32 3
+// CHECK: }
+int f8(unsigned x) {
+ switch(x) {
+ default:
+ return 3;
+ case 0xFFFFFFFF ... 1: // This range should be empty because x is unsigned.
+ return 0;
+ }
+}
+
+// Ensure that default after a case range is not ignored.
+//
+// CHECK: define i32 @f9()
+// CHECK: ret i32 10
+// CHECK: }
+static int f9_0(unsigned x) {
+ switch(x) {
+ case 10 ... 0xFFFFFFFF:
+ return 0;
+ default:
+ return 10;
+ }
+}
+int f9() {
+ return f9_0(2);
+}
+
+// Ensure that this doesn't compile to infinite loop in g() due to
+// miscompilation of fallthrough from default to a (tested) case
+// range.
+//
+// CHECK: define i32 @f10()
+// CHECK: ret i32 10
+// CHECK: }
+static int f10_0(unsigned x) {
+ switch(x) {
+ default:
+ x += 1;
+ case 10 ... 0xFFFFFFFF:
+ return 0;
+ }
+}
+
+int f10() {
+ f10_0(1);
+ return 10;
+}
+
+// This generated incorrect code because of poor switch chaining.
+//
+// CHECK: define i32 @f11(
+// CHECK: ret i32 3
+// CHECK: }
+int f11(int x) {
+ switch(x) {
+ default:
+ return 3;
+ case 10 ... 0xFFFFFFFF:
+ return 0;
+ }
+}
+
+// This just asserted because of the way case ranges were calculated.
+//
+// CHECK: define i32 @f12(
+// CHECK: ret i32 3
+// CHECK: }
+int f12(int x) {
+ switch (x) {
+ default:
+ return 3;
+ case 10 ... -1:
+ return 0;
+ }
+}
+
+// Make sure return is not constant (if empty range is skipped or miscompiled)
+//
+// CHECK: define i32 @f13(
+// CHECK: ret i32 %
+// CHECK: }
+int f13(unsigned x) {
+ switch(x) {
+ case 2:
+ // fallthrough empty range
+ case 10 ... 9:
+ return 10;
+ default:
+ return 0;
+ }
+}
+
+// Don't delete a basic block that we want to introduce later references to.
+// This isn't really specific to switches, but it's easy to show with them.
+// rdar://problem/8837067
+int f14(int x) {
+ switch (x) {
+
+ // case range so that the case block has no predecessors
+ case 0 ... 15:
+ // any expression which doesn't introduce a new block
+ (void) 0;
+ // kaboom
+
+ default:
+ return x;
+ }
+}
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
new file mode 100644
index 0000000..fc8f758
--- /dev/null
+++ b/clang/test/CodeGen/target-data.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i686-unknown-unknown -emit-llvm -o %t %s
+// RUN: grep 'target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128"' %t
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -emit-llvm -o %t %s
+// RUN: grep 'target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32-S128"' %t
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o %t %s
+// RUN: grep 'target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"' %t
diff --git a/clang/test/CodeGen/tbaa-for-vptr.cpp b/clang/test/CodeGen/tbaa-for-vptr.cpp
new file mode 100644
index 0000000..5ce6bf3
--- /dev/null
+++ b/clang/test/CodeGen/tbaa-for-vptr.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm -o - -O1 %s | FileCheck %s
+// Check that we generate TBAA for vtable pointer loads and stores.
+struct A {
+ virtual int foo() const ;
+ virtual ~A();
+};
+
+void CreateA() {
+ new A;
+}
+
+void CallFoo(A *a) {
+ a->foo();
+}
+
+// CHECK: %{{.*}} = load {{.*}} !tbaa !0
+// CHECK: store {{.*}} !tbaa !0
+// CHECK: !0 = metadata !{metadata !"vtable pointer", metadata !1}
+// CHECK: !1 = metadata !{metadata !"Simple C/C++ TBAA"}
diff --git a/clang/test/CodeGen/tentative-decls.c b/clang/test/CodeGen/tentative-decls.c
new file mode 100644
index 0000000..d88c346
--- /dev/null
+++ b/clang/test/CodeGen/tentative-decls.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+// RUN: grep '@r = common global \[1 x .*\] zeroinitializer' %t
+
+int r[];
+int (*a)[] = &r;
+
+struct s0;
+struct s0 x;
+// RUN: grep '@x = common global .struct.s0 zeroinitializer' %t
+
+struct s0 y;
+// RUN: grep '@y = common global .struct.s0 zeroinitializer' %t
+struct s0 *f0() {
+ return &y;
+}
+
+struct s0 {
+ int x;
+};
+
+// RUN: grep '@b = common global \[1 x .*\] zeroinitializer' %t
+int b[];
+int *f1() {
+ return b;
+}
+
+// Check that the most recent tentative definition wins.
+// RUN: grep '@c = common global \[4 x .*\] zeroinitializer' %t
+int c[];
+int c[4];
+
+// Check that we emit static tentative definitions
+// RUN: grep '@c5 = internal global \[1 x .*\] zeroinitializer' %t
+static int c5[];
+static int func() { return c5[0]; }
+int callfunc() { return func(); }
+
diff --git a/clang/test/CodeGen/thread-specifier.c b/clang/test/CodeGen/thread-specifier.c
new file mode 100644
index 0000000..a1f3e16
--- /dev/null
+++ b/clang/test/CodeGen/thread-specifier.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @b = external thread_local global
+// CHECK: @d.e = internal thread_local global
+// CHECK: @d.f = internal thread_local global
+// CHECK: @a = thread_local global
+__thread int a;
+extern __thread int b;
+int c() { return *&b; }
+int d() {
+ __thread static int e;
+ __thread static union {float a; int b;} f = {.b = 1};
+ return 0;
+}
+
diff --git a/clang/test/CodeGen/transparent-union.c b/clang/test/CodeGen/transparent-union.c
new file mode 100644
index 0000000..afdb3d6
--- /dev/null
+++ b/clang/test/CodeGen/transparent-union.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -o %t %s
+// RUN: FileCheck < %t %s
+//
+// FIXME: Note that we don't currently get the ABI right here. f0() should be
+// f0(i8*).
+
+typedef union {
+ void *f0;
+} transp_t0 __attribute__((transparent_union));
+
+void f0(transp_t0 obj);
+
+// CHECK: define void @f1_0(i32* %a0)
+// CHECK: call void @f0(%union.transp_t0* byval align 4 %{{.*}})
+// CHECK: call void %{{.*}}(i8* %{{[a-z0-9]*}})
+// CHECK: }
+void f1_0(int *a0) {
+ void (*f0p)(void *) = f0;
+ f0(a0);
+ f0p(a0);
+}
+
+void f1_1(int *a0) {
+ f0((transp_t0) { a0 });
+}
diff --git a/clang/test/CodeGen/trapv.c b/clang/test/CodeGen/trapv.c
new file mode 100644
index 0000000..f52dad5
--- /dev/null
+++ b/clang/test/CodeGen/trapv.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -ftrapv %s -emit-llvm -o - | FileCheck %s
+
+unsigned int ui, uj, uk;
+int i, j, k;
+
+// CHECK: define void @test0()
+void test0() {
+ // -ftrapv doesn't affect unsigned arithmetic.
+ // CHECK: [[T1:%.*]] = load i32* @uj
+ // CHECK-NEXT: [[T2:%.*]] = load i32* @uk
+ // CHECK-NEXT: [[T3:%.*]] = add i32 [[T1]], [[T2]]
+ // CHECK-NEXT: store i32 [[T3]], i32* @ui
+ ui = uj + uk;
+
+ // CHECK: [[T1:%.*]] = load i32* @j
+ // CHECK-NEXT: [[T2:%.*]] = load i32* @k
+ // CHECK-NEXT: [[T3:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 [[T2]])
+ // CHECK-NEXT: [[T4:%.*]] = extractvalue { i32, i1 } [[T3]], 0
+ // CHECK-NEXT: [[T5:%.*]] = extractvalue { i32, i1 } [[T3]], 1
+ // CHECK-NEXT: br i1 [[T5]]
+ // CHECK: call void @llvm.trap()
+ i = j + k;
+}
+
+// CHECK: define void @test1()
+void test1() {
+ extern void opaque(int);
+ opaque(i++);
+
+ // CHECK: [[T1:%.*]] = load i32* @i
+ // CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 1)
+ // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 0
+ // CHECK-NEXT: [[T4:%.*]] = extractvalue { i32, i1 } [[T2]], 1
+ // CHECK-NEXT: br i1 [[T4]]
+ // CHECK: call void @llvm.trap()
+}
+
+// CHECK: define void @test2()
+void test2() {
+ extern void opaque(int);
+ opaque(++i);
+
+ // CHECK: [[T1:%.*]] = load i32* @i
+ // CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[T1]], i32 1)
+ // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 0
+ // CHECK-NEXT: [[T4:%.*]] = extractvalue { i32, i1 } [[T2]], 1
+ // CHECK-NEXT: br i1 [[T4]]
+ // CHECK: call void @llvm.trap()
+}
diff --git a/clang/test/CodeGen/typedef-func.c b/clang/test/CodeGen/typedef-func.c
new file mode 100644
index 0000000..1467e8b
--- /dev/null
+++ b/clang/test/CodeGen/typedef-func.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm < %s
+
+// PR2414
+struct mad_frame{};
+enum mad_flow {ont};
+
+typedef enum mad_flow filter_func_t(void *, struct mad_frame *);
+
+filter_func_t mono_filter;
+
+void addfilter2(filter_func_t *func){}
+
+void setup_filters()
+{
+ addfilter2( mono_filter);
+}
diff --git a/clang/test/CodeGen/typedef.c b/clang/test/CodeGen/typedef.c
new file mode 100644
index 0000000..4af9d81
--- /dev/null
+++ b/clang/test/CodeGen/typedef.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+typedef struct { int i; } Value;
+typedef Value *PValue;
+
+int get_value(PValue v) {
+ return v->i;
+}
diff --git a/clang/test/CodeGen/types.c b/clang/test/CodeGen/types.c
new file mode 100644
index 0000000..55b806c
--- /dev/null
+++ b/clang/test/CodeGen/types.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -emit-llvm <%s
+
+struct FileName {
+ struct FileName *next;
+} *fnhead;
+
+
+struct ieeeExternal {
+ struct ieeeExternal *next;
+} *exthead;
+
+
+void test1()
+{
+ struct ieeeExternal *exttmp = exthead;
+}
+
+struct MpegEncContext;
+typedef struct MpegEncContext {int pb;} MpegEncContext;
+static void test2(void) {MpegEncContext s; s.pb;}
+
+
+struct Village;
+
+struct List {
+ struct Village *v;
+};
+
+struct Village {
+ struct List returned;
+};
+
+void test3(struct List a) {
+}
diff --git a/clang/test/CodeGen/uint128_t.c b/clang/test/CodeGen/uint128_t.c
new file mode 100644
index 0000000..92cb5fa
--- /dev/null
+++ b/clang/test/CodeGen/uint128_t.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin9
+
+typedef unsigned long long uint64_t;
+extern uint64_t numer;
+extern uint64_t denom;
+
+uint64_t
+f(uint64_t val)
+{
+ __uint128_t tmp;
+
+ tmp = val;
+ tmp *= numer;
+ tmp /= denom;
+
+ return tmp;
+}
+
diff --git a/clang/test/CodeGen/unaligned-memcpy.c b/clang/test/CodeGen/unaligned-memcpy.c
new file mode 100644
index 0000000..0373b56
--- /dev/null
+++ b/clang/test/CodeGen/unaligned-memcpy.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+void bork() {
+ char Qux[33] = {0};
+}
diff --git a/clang/test/CodeGen/union-align.c b/clang/test/CodeGen/union-align.c
new file mode 100644
index 0000000..89a9456
--- /dev/null
+++ b/clang/test/CodeGen/union-align.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | grep load | grep "4 x float" | not grep "align 4"
+// RUN: %clang_cc1 -emit-llvm %s -o - | grep load | grep "4 x float" | grep "align 16"
+// PR3432
+// rdar://6536377
+
+typedef float __m128 __attribute__ ((__vector_size__ (16)));
+
+typedef union
+{
+ int i[4];
+ float f[4];
+ __m128 v;
+} u_t;
+
+__m128 t(u_t *a) {
+ return a->v;
+}
diff --git a/clang/test/CodeGen/union-init.c b/clang/test/CodeGen/union-init.c
new file mode 100644
index 0000000..60906b5
--- /dev/null
+++ b/clang/test/CodeGen/union-init.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -emit-llvm < %s -o -
+
+// A nice and complicated initialization example with unions from Python
+typedef int Py_ssize_t;
+
+typedef union _gc_head {
+ struct {
+ union _gc_head *gc_next;
+ union _gc_head *gc_prev;
+ Py_ssize_t gc_refs;
+ } gc;
+ long double dummy; /* force worst-case alignment */
+} PyGC_Head;
+
+struct gc_generation {
+ PyGC_Head head;
+ int threshold; /* collection threshold */
+ int count; /* count of allocations or collections of younger
+ generations */
+};
+
+#define NUM_GENERATIONS 3
+#define GEN_HEAD(n) (&generations[n].head)
+
+/* linked lists of container objects */
+struct gc_generation generations[NUM_GENERATIONS] = {
+ /* PyGC_Head, threshold, count */
+ {{{GEN_HEAD(0), GEN_HEAD(0), 0}}, 700, 0},
+ {{{GEN_HEAD(1), GEN_HEAD(1), 0}}, 10, 0},
+ {{{GEN_HEAD(2), GEN_HEAD(2), 0}}, 10, 0},
+};
diff --git a/clang/test/CodeGen/union-init2.c b/clang/test/CodeGen/union-init2.c
new file mode 100644
index 0000000..bf20696
--- /dev/null
+++ b/clang/test/CodeGen/union-init2.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple i686-pc-linux-gnu | FileCheck %s
+
+// Make sure we generate something sane instead of a ptrtoint
+// CHECK: bitcast ({ %union.x*, [4 x i8] }* @r to %union.x*), [4 x i8] undef
+union x {long long b;union x* a;} r = {.a = &r};
+
+
+// CHECK: global { [3 x i8], [5 x i8] } { [3 x i8] zeroinitializer, [5 x i8] undef }
+union z {
+ char a[3];
+ long long b;
+};
+union z y = {};
diff --git a/clang/test/CodeGen/union.c b/clang/test/CodeGen/union.c
new file mode 100644
index 0000000..5c89e2d
--- /dev/null
+++ b/clang/test/CodeGen/union.c
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+union u_tag {
+ int a;
+ float b;
+} u;
+
+void f() {
+ u.b = 11;
+}
+
+float get_b(union u_tag *my_u) {
+ return my_u->b;
+}
+
+int f2( float __x ) {
+ union{
+ float __f;
+ unsigned int __u;
+ }__u;
+ return (int)(__u.__u >> 31);
+}
+
+typedef union { int i; int *j; } value;
+
+int f3(value v) {
+ return *v.j;
+}
+
+enum E9 { one, two };
+union S65 { enum E9 a; } ; union S65 s65;
+void fS65() { enum E9 e = s65.a; }
+
+typedef union{
+ unsigned char x[65536];
+} q;
+int qfunc() {q buf; unsigned char* x = buf.x;}
+
+union RR {_Bool a : 1;} RRU;
+int RRF(void) {return RRU.a;}
+
+// PR6164
+typedef union T0 { unsigned int : 0; } T0;
+T0 t0;
+
+union { int large_bitfield: 31; char c } u2;
diff --git a/clang/test/CodeGen/unreachable.c b/clang/test/CodeGen/unreachable.c
new file mode 100644
index 0000000..5e9fa6a
--- /dev/null
+++ b/clang/test/CodeGen/unreachable.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: grep '@unreachable' %t | count 0
+
+extern void abort() __attribute__((noreturn));
+extern int unreachable();
+
+int f0() {
+ return 0;
+ unreachable();
+}
+
+int f1(int i) {
+ goto L0;
+ int a = unreachable();
+ L0:
+ return 0;
+}
+
+int f2(int i) {
+ goto L0;
+ unreachable();
+ int a;
+ unreachable();
+ L0:
+ a = i + 1;
+ return a;
+}
+
+int f3(int i) {
+ if (i) {
+ return 0;
+ } else {
+ abort();
+ }
+ unreachable();
+ return 3;
+}
diff --git a/clang/test/CodeGen/unwind-attr.c b/clang/test/CodeGen/unwind-attr.c
new file mode 100644
index 0000000..c588ca8
--- /dev/null
+++ b/clang/test/CodeGen/unwind-attr.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fexceptions -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix NOEXC %s
+
+int opaque();
+
+// CHECK: define [[INT:i.*]] @test0() {
+// CHECK-NOEXC: define [[INT:i.*]] @test0() nounwind {
+int test0(void) {
+ return opaque();
+}
+
+// <rdar://problem/8087431>: locally infer nounwind at -O0
+// CHECK: define [[INT:i.*]] @test1() nounwind {
+// CHECK-NOEXC: define [[INT:i.*]] @test1() nounwind {
+int test1(void) {
+ return 0;
+}
+
+// <rdar://problem/8283071>: not for weak functions
+// CHECK: define weak [[INT:i.*]] @test2() {
+// CHECK-NOEXC: define weak [[INT:i.*]] @test2() nounwind {
+__attribute__((weak)) int test2(void) {
+ return 0;
+}
diff --git a/clang/test/CodeGen/utf16-cfstrings.c b/clang/test/CodeGen/utf16-cfstrings.c
new file mode 100644
index 0000000..d4f214b
--- /dev/null
+++ b/clang/test/CodeGen/utf16-cfstrings.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s
+// <rdar://problem/10655949>
+
+// CHECK: @.str = internal unnamed_addr constant [9 x i16] [i16 252, i16 98, i16 101, i16 114, i16 104, i16 117, i16 110, i16 100, i16 0], align 2
+
+#define CFSTR __builtin___CFStringMakeConstantString
+
+void foo() {
+ CFSTR("überhund");
+}
diff --git a/clang/test/CodeGen/varargs.c b/clang/test/CodeGen/varargs.c
new file mode 100644
index 0000000..b3dba24
--- /dev/null
+++ b/clang/test/CodeGen/varargs.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+
+
+// PR6433 - Don't crash on va_arg(typedef).
+typedef double gdouble;
+void focus_changed_cb () {
+ __builtin_va_list pa;
+ double mfloat;
+ mfloat = __builtin_va_arg((pa), gdouble);
+}
+
diff --git a/clang/test/CodeGen/variable-array.c b/clang/test/CodeGen/variable-array.c
new file mode 100644
index 0000000..80ca78d
--- /dev/null
+++ b/clang/test/CodeGen/variable-array.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm < %s | grep puts | count 4
+
+// PR3248
+int a(int x)
+{
+ int (*y)[x];
+ return sizeof(*(puts("asdf"),y));
+}
+
+// PR3247
+int b() {
+ return sizeof(*(char(*)[puts("asdf")])0);
+}
+
+// PR3247
+int c() {
+ static int (*y)[puts("asdf")];
+ return sizeof(*y);
+}
diff --git a/clang/test/CodeGen/vector.c b/clang/test/CodeGen/vector.c
new file mode 100644
index 0000000..3fa5f14
--- /dev/null
+++ b/clang/test/CodeGen/vector.c
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -O1 -target-cpu pentium4 -target-feature +sse4.1 -g -emit-llvm %s -o - | FileCheck %s
+typedef short __v4hi __attribute__ ((__vector_size__ (8)));
+
+void test1() {
+ __v4hi A = (__v4hi)0LL;
+}
+
+__v4hi x = {1,2,3};
+__v4hi y = {1,2,3,4};
+
+typedef int vty __attribute((vector_size(16)));
+int test2() { vty b; return b[2LL]; }
+
+// PR4339
+typedef float vec4 __attribute__((vector_size(16)));
+
+void test3 ( vec4* a, char b, float c ) {
+ (*a)[b] = c;
+}
+
+
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <mmintrin.h>
+
+int test4(int argc, char *argv[]) {
+ int array[16] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
+ __m64 *p = (__m64 *)array;
+
+ __m64 accum = _mm_setzero_si64();
+
+ for (int i=0; i<8; ++i)
+ accum = _mm_add_pi32(p[i], accum);
+
+ __m64 accum2 = _mm_unpackhi_pi32(accum, accum);
+ accum = _mm_add_pi32(accum, accum2);
+
+ int result = _mm_cvtsi64_si32(accum);
+ _mm_empty();
+
+ return result;
+}
+
+#include <smmintrin.h>
+
+unsigned long test_epi8(__m128i x) { return _mm_extract_epi8(x, 4); }
+// CHECK: @test_epi8
+// CHECK: extractelement <16 x i8> {{.*}}, i32 4
+// CHECK: zext i8 {{.*}} to i32
+
+unsigned long test_epi16(__m128i x) { return _mm_extract_epi16(x, 3); }
+
+// CHECK: @test_epi16
+// CHECK: extractelement <8 x i16> {{.*}}, i32 3
+// CHECK: zext i16 {{.*}} to i32
diff --git a/clang/test/CodeGen/vfprintf.c b/clang/test/CodeGen/vfprintf.c
new file mode 100644
index 0000000..7c583b5
--- /dev/null
+++ b/clang/test/CodeGen/vfprintf.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+
+typedef struct _IO_FILE FILE;
+int vfprintf(FILE*restrict,const char*restrict, __builtin_va_list);
+void foo(__builtin_va_list ap) {
+ vfprintf(0, " ", ap);
+}
+
diff --git a/clang/test/CodeGen/visibility.c b/clang/test/CodeGen/visibility.c
new file mode 100644
index 0000000..fa4b599
--- /dev/null
+++ b/clang/test/CodeGen/visibility.c
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility default -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-DEFAULT
+// RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility protected -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-PROTECTED
+// RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN
+
+// CHECK-DEFAULT: @g_def = global i32 0
+// CHECK-DEFAULT: @g_com = common global i32 0
+// CHECK-DEFAULT: @g_ext = external global i32
+// CHECK-DEFAULT: @g_deferred = internal global
+// CHECK-PROTECTED: @g_def = protected global i32 0
+// CHECK-PROTECTED: @g_com = common protected global i32 0
+// CHECK-PROTECTED: @g_ext = external global i32
+// CHECK-PROTECTED: @g_deferred = internal global
+// CHECK-HIDDEN: @g_def = hidden global i32 0
+// CHECK-HIDDEN: @g_com = common hidden global i32 0
+// CHECK-HIDDEN: @g_ext = external global i32
+// CHECK-HIDDEN: @g_deferred = internal global
+int g_com;
+int g_def = 0;
+extern int g_ext;
+static char g_deferred[] = "hello";
+
+// CHECK-DEFAULT: @test4 = hidden global i32 10
+// CHECK-PROTECTED: @test4 = hidden global i32 10
+// CHECK-HIDDEN: @test4 = hidden global i32 10
+
+// CHECK-DEFAULT: define i32 @f_def()
+// CHECK-DEFAULT: declare void @f_ext()
+// CHECK-DEFAULT: define internal void @f_deferred()
+// CHECK-PROTECTED: define protected i32 @f_def()
+// CHECK-PROTECTED: declare void @f_ext()
+// CHECK-PROTECTED: define internal void @f_deferred()
+// CHECK-HIDDEN: define hidden i32 @f_def()
+// CHECK-HIDDEN: declare void @f_ext()
+// CHECK-HIDDEN: define internal void @f_deferred()
+
+extern void f_ext(void);
+
+static void f_deferred(void) {
+}
+
+int f_def(void) {
+ f_ext();
+ f_deferred();
+ return g_com + g_def + g_ext + g_deferred[0];
+}
+
+// PR8457
+// CHECK-DEFAULT: define void @test1(
+// CHECK-PROTECTED: define void @test1(
+// CHECK-HIDDEN: define void @test1(
+struct Test1 { int field; };
+void __attribute__((visibility("default"))) test1(struct Test1 *v) { }
+
+// rdar://problem/8595231
+// CHECK-DEFAULT: define void @test2()
+// CHECK-PROTECTED: define void @test2()
+// CHECK-HIDDEN: define void @test2()
+void test2(void);
+void __attribute__((visibility("default"))) test2(void) {}
+
+// CHECK-DEFAULT: define hidden void @test3()
+// CHECK-PROTECTED: define hidden void @test3()
+// CHECK-HIDDEN: define hidden void @test3()
+extern void test3(void);
+__private_extern__ void test3(void) {}
+
+// Top of file.
+extern int test4;
+__private_extern__ int test4 = 10;
diff --git a/clang/test/CodeGen/vla-2.c b/clang/test/CodeGen/vla-2.c
new file mode 100644
index 0000000..0a74907
--- /dev/null
+++ b/clang/test/CodeGen/vla-2.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=gnu99 %s -emit-llvm -o - | grep ".*alloca.*align 16"
+
+extern void bar(int[]);
+
+void foo(int a)
+{
+ int var[a] __attribute__((__aligned__(16)));
+ bar(var);
+ return;
+}
diff --git a/clang/test/CodeGen/vla-3.c b/clang/test/CodeGen/vla-3.c
new file mode 100644
index 0000000..4927b46
--- /dev/null
+++ b/clang/test/CodeGen/vla-3.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -std=gnu99 %s -emit-llvm -o - | grep ".*alloca.*align 16"
+
+void adr(char *);
+
+void vlaalign(int size)
+{
+ char __attribute__((aligned(16))) tmp[size+32];
+ char tmp2[size+16];
+
+ adr(tmp);
+}
diff --git a/clang/test/CodeGen/vla-4.c b/clang/test/CodeGen/vla-4.c
new file mode 100644
index 0000000..6e4ca98
--- /dev/null
+++ b/clang/test/CodeGen/vla-4.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+
+int f();
+int h();
+
+void t1() {
+ _Atomic(typeof((int (*)[f()]) h())) v;
+ // CHECK: [[N:%.*]] = alloca i32*, align 4
+ // CHECK-NEXT: [[P:%.*]] = call i32 bitcast (i32 (...)* @f to i32 ()*)()
+ // CHECK-NEXT: [[P:%.*]] = call i32 bitcast (i32 (...)* @h to i32 ()*)()
+}
+
+void t2() {
+ typeof(typeof((int (*)[f()]) h())) v;
+ // CHECK: [[N:%.*]] = alloca i32*, align 4
+ // CHECK-NEXT: [[P:%.*]] = call i32 bitcast (i32 (...)* @f to i32 ()*)()
+ // CHECK-NEXT: [[P:%.*]] = call i32 bitcast (i32 (...)* @h to i32 ()*)()
+}
+
+void t3(typeof((int (*)[f()]) h()) v) {
+ // CHECK: store i32* %v, i32** %{{[.0-9A-Za-z]+}}, align 4
+ // CHECK-NEXT: [[P:%.*]] = call i32 bitcast (i32 (...)* @f to i32 ()*)()
+ // CHECK-NEXT: [[P:%.*]] = call i32 bitcast (i32 (...)* @h to i32 ()*)()
+}
diff --git a/clang/test/CodeGen/vla.c b/clang/test/CodeGen/vla.c
new file mode 100644
index 0000000..9e62da5
--- /dev/null
+++ b/clang/test/CodeGen/vla.c
@@ -0,0 +1,144 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+
+int b(char* x);
+
+// Extremely basic VLA test
+void a(int x) {
+ char arry[x];
+ arry[0] = 10;
+ b(arry);
+}
+
+int c(int n)
+{
+ return sizeof(int[n]);
+}
+
+int f0(int x) {
+ int vla[x];
+ return vla[x-1];
+}
+
+void
+f(int count)
+{
+ int a[count];
+
+ do { } while (0);
+
+ if (a[0] != 3) {
+ }
+}
+
+void g(int count) {
+ // Make sure we emit sizes correctly in some obscure cases
+ int (*a[5])[count];
+ int (*b)[][count];
+}
+
+// rdar://8403108
+// CHECK: define void @f_8403108
+void f_8403108(unsigned x) {
+ // CHECK: call i8* @llvm.stacksave()
+ char s1[x];
+ while (1) {
+ // CHECK: call i8* @llvm.stacksave()
+ char s2[x];
+ if (1)
+ break;
+ // CHECK: call void @llvm.stackrestore(i8*
+ }
+ // CHECK: call void @llvm.stackrestore(i8*
+}
+
+// pr7827
+void function(short width, int data[][width]) {} // expected-note {{passing argument to parameter 'data' here}}
+
+void test() {
+ int bork[4][13];
+ // CHECK: call void @function(i16 signext 1, i32* null)
+ function(1, 0);
+ // CHECK: call void @function(i16 signext 1, i32* inttoptr
+ function(1, 0xbadbeef); // expected-warning {{incompatible integer to pointer conversion passing}}
+ // CHECK: call void @function(i16 signext 1, i32* {{.*}})
+ function(1, bork);
+}
+
+void function1(short width, int data[][width][width]) {}
+void test1() {
+ int bork[4][13][15];
+ // CHECK: call void @function1(i16 signext 1, i32* {{.*}})
+ function1(1, bork);
+ // CHECK: call void @function(i16 signext 1, i32* {{.*}})
+ function(1, bork[2]);
+}
+
+// rdar://8476159
+static int GLOB;
+int test2(int n)
+{
+ GLOB = 0;
+ char b[1][n+3]; /* Variable length array. */
+ // CHECK: [[tmp_1:%.*]] = load i32* @GLOB, align 4
+ // CHECK-NEXT: add nsw i32 [[tmp_1]], 1
+ __typeof__(b[GLOB++]) c;
+ return GLOB;
+}
+
+// http://llvm.org/PR8567
+// CHECK: define double @test_PR8567
+double test_PR8567(int n, double (*p)[n][5]) {
+ // CHECK: [[NV:%.*]] = alloca i32, align 4
+ // CHECK-NEXT: [[PV:%.*]] = alloca [5 x double]*, align 4
+ // CHECK-NEXT: store
+ // CHECK-NEXT: store
+ // CHECK-NEXT: [[N:%.*]] = load i32* [[NV]], align 4
+ // CHECK-NEXT: [[P:%.*]] = load [5 x double]** [[PV]], align 4
+ // CHECK-NEXT: [[T0:%.*]] = mul nsw i32 1, [[N]]
+ // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [5 x double]* [[P]], i32 [[T0]]
+ // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [5 x double]* [[T1]], i32 2
+ // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds [5 x double]* [[T2]], i32 0, i32 3
+ // CHECK-NEXT: [[T4:%.*]] = load double* [[T3]]
+ // CHECK-NEXT: ret double [[T4]]
+ return p[1][2][3];
+}
+
+int test4(unsigned n, char (*p)[n][n+1][6]) {
+ // CHECK: define i32 @test4(
+ // CHECK: [[N:%.*]] = alloca i32, align 4
+ // CHECK-NEXT: [[P:%.*]] = alloca [6 x i8]*, align 4
+ // CHECK-NEXT: [[P2:%.*]] = alloca [6 x i8]*, align 4
+ // CHECK-NEXT: store i32
+ // CHECK-NEXT: store [6 x i8]*
+
+ // VLA captures.
+ // CHECK-NEXT: [[DIM0:%.*]] = load i32* [[N]], align 4
+ // CHECK-NEXT: [[T0:%.*]] = load i32* [[N]], align 4
+ // CHECK-NEXT: [[DIM1:%.*]] = add i32 [[T0]], 1
+
+ // CHECK-NEXT: [[T0:%.*]] = load [6 x i8]** [[P]], align 4
+ // CHECK-NEXT: [[T1:%.*]] = load i32* [[N]], align 4
+ // CHECK-NEXT: [[T2:%.*]] = udiv i32 [[T1]], 2
+ // CHECK-NEXT: [[T3:%.*]] = mul nuw i32 [[DIM0]], [[DIM1]]
+ // CHECK-NEXT: [[T4:%.*]] = mul nsw i32 [[T2]], [[T3]]
+ // CHECK-NEXT: [[T5:%.*]] = getelementptr inbounds [6 x i8]* [[T0]], i32 [[T4]]
+ // CHECK-NEXT: [[T6:%.*]] = load i32* [[N]], align 4
+ // CHECK-NEXT: [[T7:%.*]] = udiv i32 [[T6]], 4
+ // CHECK-NEXT: [[T8:%.*]] = sub i32 0, [[T7]]
+ // CHECK-NEXT: [[T9:%.*]] = mul nuw i32 [[DIM0]], [[DIM1]]
+ // CHECK-NEXT: [[T10:%.*]] = mul nsw i32 [[T8]], [[T9]]
+ // CHECK-NEXT: [[T11:%.*]] = getelementptr inbounds [6 x i8]* [[T5]], i32 [[T10]]
+ // CHECK-NEXT: store [6 x i8]* [[T11]], [6 x i8]** [[P2]], align 4
+ __typeof(p) p2 = (p + n/2) - n/4;
+
+ // CHECK-NEXT: [[T0:%.*]] = load [6 x i8]** [[P2]], align 4
+ // CHECK-NEXT: [[T1:%.*]] = load [6 x i8]** [[P]], align 4
+ // CHECK-NEXT: [[T2:%.*]] = ptrtoint [6 x i8]* [[T0]] to i32
+ // CHECK-NEXT: [[T3:%.*]] = ptrtoint [6 x i8]* [[T1]] to i32
+ // CHECK-NEXT: [[T4:%.*]] = sub i32 [[T2]], [[T3]]
+ // CHECK-NEXT: [[T5:%.*]] = mul nuw i32 [[DIM0]], [[DIM1]]
+ // CHECK-NEXT: [[T6:%.*]] = mul nuw i32 6, [[T5]]
+ // CHECK-NEXT: [[T7:%.*]] = sdiv exact i32 [[T4]], [[T6]]
+ // CHECK-NEXT: ret i32 [[T7]]
+ return p2 - p;
+}
diff --git a/clang/test/CodeGen/vld_dup.c b/clang/test/CodeGen/vld_dup.c
new file mode 100644
index 0000000..e1d63cc
--- /dev/null
+++ b/clang/test/CodeGen/vld_dup.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple armv7a-linux-gnueabi \
+// RUN: -target-cpu cortex-a8 \
+// RUN: -emit-llvm -O0 -o - %s | FileCheck %s
+#include <arm_neon.h>
+int main(){
+ int32_t v0[3];
+ int32x2x3_t v1;
+ int32_t v2[4];
+ int32x2x4_t v3;
+ int64x1x3_t v4;
+ int64x1x4_t v5;
+ int64_t v6[3];
+ int64_t v7[4];
+
+ v1 = vld3_dup_s32(v0);
+// CHECK: [[T168:%.*]] = call { <2 x i32>, <2 x i32>, <2 x i32> } @llvm.arm.neon.vld3lane.v2i32(i8* {{.*}}, <2 x i32> undef, <2 x i32> undef, <2 x i32> undef, i32 {{[0-9]+}}, i32 {{[0-9]+}})
+// CHECK-NEXT: [[T169:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32> } [[T168]], 0
+// CHECK-NEXT: [[T170:%.*]] = shufflevector <2 x i32> [[T169]], <2 x i32> [[T169]], <2 x i32> zeroinitializer
+// CHECK-NEXT: [[T171:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32> } [[T168]], <2 x i32> [[T170]], 0
+// CHECK-NEXT: [[T172:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32> } [[T171]], 1
+// CHECK-NEXT: [[T173:%.*]] = shufflevector <2 x i32> [[T172]], <2 x i32> [[T172]], <2 x i32> zeroinitializer
+// CHECK-NEXT: [[T174:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32> } [[T171]], <2 x i32> [[T173]], 1
+// CHECK-NEXT: [[T175:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32> } [[T174]], 2
+// CHECK-NEXT: [[T176:%.*]] = shufflevector <2 x i32> [[T175]], <2 x i32> [[T175]], <2 x i32> zeroinitializer
+// CHECK-NEXT: [[T177:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32> } [[T174]], <2 x i32> [[T176]], 2
+
+ v3 = vld4_dup_s32(v2);
+// CHECK: [[T178:%.*]] = call { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } @llvm.arm.neon.vld4lane.v2i32(i8* {{.*}}, <2 x i32> undef, <2 x i32> undef, <2 x i32> undef, <2 x i32> undef, i32 {{[0-9]+}}, i32 {{[0-9]+}})
+// CHECK-NEXT: [[T179:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T178]], 0
+// CHECK-NEXT: [[T180:%.*]] = shufflevector <2 x i32> [[T179]], <2 x i32> [[T179]], <2 x i32> zeroinitializer
+// CHECK-NEXT: [[T181:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T178]], <2 x i32> [[T180]], 0
+// CHECK-NEXT: [[T182:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T181]], 1
+// CHECK-NEXT: [[T183:%.*]] = shufflevector <2 x i32> [[T182]], <2 x i32> [[T182]], <2 x i32> zeroinitializer
+// CHECK-NEXT: [[T184:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T181]], <2 x i32> [[T183]], 1
+// CHECK-NEXT: [[T185:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T184]], 2
+// CHECK-NEXT: [[T186:%.*]] = shufflevector <2 x i32> [[T185]], <2 x i32> [[T185]], <2 x i32> zeroinitializer
+// CHECK-NEXT: [[T187:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T184]], <2 x i32> [[T186]], 2
+// CHECK-NEXT: [[T188:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T187]], 3
+// CHECK-NEXT: [[T189:%.*]] = shufflevector <2 x i32> [[T188]], <2 x i32> [[T188]], <2 x i32> zeroinitializer
+// CHECK-NEXT: [[T190:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T187]], <2 x i32> [[T189]], 3
+
+ v4 = vld3_dup_s64(v6);
+// CHECK: {{%.*}} = call { <1 x i64>, <1 x i64>, <1 x i64> } @llvm.arm.neon.vld3.v1i64(i8* {{.*}}, i32 {{[0-9]+}})
+
+ v5 = vld4_dup_s64(v7);
+// CHECK: {{%.*}} = call { <1 x i64>, <1 x i64>, <1 x i64>, <1 x i64> } @llvm.arm.neon.vld4.v1i64(i8* {{.*}}, i32 {{[0-9]+}})
+
+ return 0;
+}
diff --git a/clang/test/CodeGen/volatile-1.c b/clang/test/CodeGen/volatile-1.c
new file mode 100644
index 0000000..6551159
--- /dev/null
+++ b/clang/test/CodeGen/volatile-1.c
@@ -0,0 +1,315 @@
+// RUN: %clang_cc1 -Wno-return-type -Wno-unused-value -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: @i = common global [[INT:i[0-9]+]] 0
+volatile int i, j, k;
+volatile int ar[5];
+volatile char c;
+// CHECK: @ci = common global [[CINT:.*]] zeroinitializer
+volatile _Complex int ci;
+volatile struct S {
+#ifdef __cplusplus
+ void operator =(volatile struct S&o) volatile;
+#endif
+ int i;
+} a, b;
+
+//void operator =(volatile struct S&o1, volatile struct S&o2) volatile;
+int printf(const char *, ...);
+
+
+// Note that these test results are very much specific to C!
+// Assignments in C++ yield l-values, not r-values, and the situations
+// that do implicit lvalue-to-rvalue conversion are substantially
+// reduced.
+
+// CHECK: define void @test()
+void test() {
+ // CHECK: load volatile [[INT]]* @i
+ i;
+ // CHECK-NEXT: load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: sitofp [[INT]]
+ (float)(ci);
+ // CHECK-NEXT: load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ (void)ci;
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: memcpy
+ (void)a;
+ // CHECK-NEXT: [[R:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: [[I:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: store volatile [[INT]] [[R]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: store volatile [[INT]] [[I]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ (void)(ci=ci);
+ // CHECK-NEXT: [[T:%.*]] = load volatile [[INT]]* @j
+ // CHECK-NEXT: store volatile [[INT]] [[T]], [[INT]]* @i
+ (void)(i=j);
+ // CHECK-NEXT: [[R1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: [[I1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: [[R2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: [[I2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // Not sure why they're ordered this way.
+ // CHECK-NEXT: [[R:%.*]] = add [[INT]] [[R2]], [[R1]]
+ // CHECK-NEXT: [[I:%.*]] = add [[INT]] [[I2]], [[I1]]
+ // CHECK-NEXT: store volatile [[INT]] [[R]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: store volatile [[INT]] [[I]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ ci+=ci;
+
+ // CHECK-NEXT: [[R1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: [[I1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: [[R2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: [[I2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: [[R:%.*]] = add [[INT]] [[R2]], [[R1]]
+ // CHECK-NEXT: [[I:%.*]] = add [[INT]] [[I2]], [[I1]]
+ // CHECK-NEXT: store volatile [[INT]] [[R]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: store volatile [[INT]] [[I]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: [[R2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: [[I2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // These additions can be elided
+ // CHECK-NEXT: add [[INT]] [[R]], [[R2]]
+ // CHECK-NEXT: add [[INT]] [[I]], [[I2]]
+ (ci += ci) + ci;
+ // CHECK-NEXT: call void asm
+ asm("nop");
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add nsw [[INT]]
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add nsw [[INT]]
+ (i += j) + k;
+ // CHECK-NEXT: call void asm
+ asm("nop");
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add nsw [[INT]]
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: add nsw [[INT]]
+ (i += j) + 1;
+ // CHECK-NEXT: call void asm
+ asm("nop");
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add [[INT]]
+ // CHECK-NEXT: add [[INT]]
+ ci+ci;
+
+ // CHECK-NEXT: load volatile
+ __real i;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ +ci;
+ // CHECK-NEXT: call void asm
+ asm("nop");
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ (void)(i=i);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: sitofp
+ (float)(i=i);
+ // CHECK-NEXT: load volatile
+ (void)i;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ i=i;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: store volatile
+ i=i=i;
+#ifndef __cplusplus
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ (void)__builtin_choose_expr(0, i=i, j=j);
+#endif
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: icmp
+ // CHECK-NEXT: br i1
+ // CHECK: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: br label
+ // CHECK: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: br label
+ k ? (i=i) : (j=j);
+ // CHECK: phi
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ (void)(i,(i=i));
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ i=i,i;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ (i=j,k=j);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ (i=j,k);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ (i,j);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: trunc
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: sext
+ // CHECK-NEXT: store volatile
+ i=c=k;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add nsw [[INT]]
+ // CHECK-NEXT: store volatile
+ i+=k;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ ci;
+#ifndef __cplusplus
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ (int)ci;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: icmp ne
+ // CHECK-NEXT: icmp ne
+ // CHECK-NEXT: or i1
+ (_Bool)ci;
+#endif
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: store volatile
+ ci=ci;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: store volatile
+ ci=ci=ci;
+ // CHECK-NEXT: [[T:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: store volatile [[INT]] [[T]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: store volatile [[INT]] [[T]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ __imag ci = __imag ci = __imag ci;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ __real (i = j);
+ // CHECK-NEXT: load volatile
+ __imag i;
+
+ // ============================================================
+ // FIXME: Test cases we get wrong.
+
+ // A use. We load all of a into a copy of a, then load i. gcc forgets to do
+ // the assignment.
+ // (a = a).i;
+
+ // ============================================================
+ // Test cases where we intentionally differ from gcc, due to suspected bugs in
+ // gcc.
+
+ // Not a use. gcc forgets to do the assignment.
+ // CHECK-NEXT: call void @llvm.memcpy{{.*}}, i1 true
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: call void @llvm.memcpy{{.*}}, i1 true
+ ((a=a),a);
+
+ // Not a use. gcc gets this wrong, it doesn't emit the copy!
+ // (void)(a=a);
+
+ // Not a use. gcc got this wrong in 4.2 and omitted the side effects
+ // entirely, but it is fixed in 4.4.0.
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ __imag (i = j);
+
+#ifndef __cplusplus
+ // A use of the real part
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: sitofp
+ (float)(ci=ci);
+ // Not a use, bug? gcc treats this as not a use, that's probably a bug due to
+ // tree folding ignoring volatile.
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: store volatile
+ (int)(ci=ci);
+#endif
+
+ // A use.
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: sitofp
+ (float)(i=i);
+ // A use. gcc treats this as not a use, that's probably a bug due to tree
+ // folding ignoring volatile.
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ (int)(i=i);
+
+ // A use.
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: sub
+ -(i=j);
+ // A use. gcc treats this a not a use, that's probably a bug due to tree
+ // folding ignoring volatile.
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ +(i=k);
+
+ // A use. gcc treats this a not a use, that's probably a bug due to tree
+ // folding ignoring volatile.
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: store volatile
+ __real (ci=ci);
+
+ // A use.
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add
+ i + 0;
+ // A use.
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add
+ (i=j) + i;
+ // A use. gcc treats this as not a use, that's probably a bug due to tree
+ // folding ignoring volatile.
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: add
+ (i=j) + 0;
+
+#ifdef __cplusplus
+ (i,j)=k;
+ (j=k,i)=i;
+ struct { int x; } s, s1;
+ printf("s is at %p\n", &s);
+ printf("s is at %p\n", &(s = s1));
+ printf("s.x is at %p\n", &((s = s1).x));
+#endif
+}
+
+extern volatile enum X x;
+// CHECK: define void @test1()
+void test1() {
+ extern void test1_helper(void);
+ test1_helper();
+ // CHECK: call void @test1_helper()
+ // CHECK-NEXT: ret void
+ x;
+ (void) x;
+ return x;
+}
diff --git a/clang/test/CodeGen/volatile-2.c b/clang/test/CodeGen/volatile-2.c
new file mode 100644
index 0000000..3d342de
--- /dev/null
+++ b/clang/test/CodeGen/volatile-2.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+
+void test0() {
+ // CHECK: define void @test0()
+ // CHECK: [[F:%.*]] = alloca float
+ // CHECK-NEXT: [[REAL:%.*]] = load volatile float* getelementptr inbounds ({ float, float }* @test0_v, i32 0, i32 0)
+ // CHECK-NEXT: load volatile float* getelementptr inbounds ({{.*}} @test0_v, i32 0, i32 1)
+ // CHECK-NEXT: store float [[REAL]], float* [[F]], align 4
+ // CHECK-NEXT: ret void
+ extern volatile _Complex float test0_v;
+ float f = (float) test0_v;
+}
+
+void test1() {
+ // CHECK: define void @test1()
+ // CHECK: [[REAL:%.*]] = load volatile float* getelementptr inbounds ({{.*}} @test1_v, i32 0, i32 0)
+ // CHECK-NEXT: [[IMAG:%.*]] = load volatile float* getelementptr inbounds ({{.*}} @test1_v, i32 0, i32 1)
+ // CHECK-NEXT: store volatile float [[REAL]], float* getelementptr inbounds ({{.*}} @test1_v, i32 0, i32 0)
+ // CHECK-NEXT: store volatile float [[IMAG]], float* getelementptr inbounds ({{.*}} @test1_v, i32 0, i32 1)
+ // CHECK-NEXT: ret void
+ extern volatile _Complex float test1_v;
+ test1_v = test1_v;
+}
diff --git a/clang/test/CodeGen/volatile.c b/clang/test/CodeGen/volatile.c
new file mode 100644
index 0000000..1a996de
--- /dev/null
+++ b/clang/test/CodeGen/volatile.c
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -emit-llvm < %s -o %t
+// RUN: grep volatile %t | count 28
+// RUN: grep memcpy %t | count 7
+
+// The number 28 comes from the current codegen for volatile loads;
+// if this number changes, it's not necessarily something wrong, but
+// something has changed to affect volatile load/store codegen
+
+int S;
+volatile int vS;
+
+int* pS;
+volatile int* pvS;
+
+int A[10];
+volatile int vA[10];
+
+struct { int x; } F;
+struct { volatile int x; } vF;
+
+struct { int x; } F2;
+volatile struct { int x; } vF2;
+volatile struct { int x; } *vpF2;
+
+struct { struct { int y; } x; } F3;
+volatile struct { struct { int y; } x; } vF3;
+
+struct { int x:3; } BF;
+struct { volatile int x:3; } vBF;
+
+typedef int v4si __attribute__ ((vector_size (16)));
+v4si V;
+volatile v4si vV;
+
+typedef __attribute__(( ext_vector_type(4) )) int extv4;
+extv4 VE;
+volatile extv4 vVE;
+
+volatile struct {int x;} aggFct(void);
+
+typedef volatile int volatile_int;
+volatile_int vtS;
+
+int main() {
+ int i;
+
+ // load
+ i=S;
+ i=vS;
+ i=*pS;
+ i=*pvS;
+ i=A[2];
+ i=vA[2];
+ i=F.x;
+ i=vF.x;
+ i=F2.x;
+ i=vF2.x;
+ i=vpF2->x;
+ i=F3.x.y;
+ i=vF3.x.y;
+ i=BF.x;
+ i=vBF.x;
+ i=V[3];
+ i=vV[3];
+ i=VE.yx[1];
+ i=vVE.zy[1];
+ i = aggFct().x; // Note: not volatile
+ i=vtS;
+
+
+ // store
+ S=i;
+ vS=i;
+ *pS=i;
+ *pvS=i;
+ A[2]=i;
+ vA[2]=i;
+ F.x=i;
+ vF.x=i;
+ F2.x=i;
+ vF2.x=i;
+ vpF2->x=i;
+ vF3.x.y=i;
+ BF.x=i;
+ vBF.x=i;
+ V[3]=i;
+ vV[3]=i;
+ vtS=i;
+
+ // other ops:
+ ++S;
+ ++vS;
+ i+=S;
+ i+=vS;
+ ++vtS;
+ (void)vF2;
+ vF2 = vF2;
+ vF2 = vF2 = vF2;
+ vF2 = (vF2, vF2);
+}
diff --git a/clang/test/CodeGen/wchar-const.c b/clang/test/CodeGen/wchar-const.c
new file mode 100644
index 0000000..a9e7e52
--- /dev/null
+++ b/clang/test/CodeGen/wchar-const.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple i386-pc-win32 | FileCheck %s --check-prefix=WIN
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-apple-darwin | FileCheck %s --check-prefix=DAR
+// This should pass for any endianness combination of host and target.
+
+// This bit is taken from Sema/wchar.c so we can avoid the wchar.h include.
+typedef __WCHAR_TYPE__ wchar_t;
+#if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
+ || defined(_M_X64) || defined(SHORT_WCHAR)
+ #define WCHAR_T_TYPE unsigned short
+#elif defined(__sun) || defined(__AuroraUX__)
+ #define WCHAR_T_TYPE long
+#else /* Solaris or AuroraUX. */
+ #define WCHAR_T_TYPE int
+#endif
+
+
+// CHECK-DAR: private unnamed_addr constant [18 x i32] [i32 84,
+// CHECK-WIN: private unnamed_addr constant [18 x i16] [i16 84,
+extern void foo(const wchar_t* p);
+int main (int argc, const char * argv[])
+{
+ foo(L"This is some text");
+ return 0;
+}
diff --git a/clang/test/CodeGen/weak-global.c b/clang/test/CodeGen/weak-global.c
new file mode 100644
index 0000000..f972cea
--- /dev/null
+++ b/clang/test/CodeGen/weak-global.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-llvm < %s | grep common
+
+int i;
diff --git a/clang/test/CodeGen/weak-incomplete.c b/clang/test/CodeGen/weak-incomplete.c
new file mode 100644
index 0000000..af91ae7
--- /dev/null
+++ b/clang/test/CodeGen/weak-incomplete.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm < %s | grep 'extern_weak' | count 1
+
+struct S;
+void __attribute__((weak)) foo1(struct S);
+void (*foo2)(struct S) = foo1;
diff --git a/clang/test/CodeGen/weak_constant.c b/clang/test/CodeGen/weak_constant.c
new file mode 100644
index 0000000..726d2ef
--- /dev/null
+++ b/clang/test/CodeGen/weak_constant.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -w -emit-llvm %s -O1 -o - | FileCheck %s
+// Check for bug compatibility with gcc.
+
+const int x __attribute((weak)) = 123;
+
+int* f(void) {
+ return &x;
+}
+
+int g(void) {
+ // CHECK: ret i32 123
+ return *f();
+}
diff --git a/clang/test/CodeGen/whilestmt.c b/clang/test/CodeGen/whilestmt.c
new file mode 100644
index 0000000..3973b28
--- /dev/null
+++ b/clang/test/CodeGen/whilestmt.c
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+int bar();
+int foo() {
+ int i;
+ i = 1 + 2;
+ while(1) {
+ i = bar();
+ i = bar();
+ };
+ return i;
+}
+
+
+int foo1() {
+ int i;
+ i = 1 + 2;
+ while(1) {
+ i = bar();
+ if (i == 42)
+ break;
+ i = bar();
+ };
+ return i;
+}
+
+
+int foo2() {
+ int i;
+ i = 1 + 2;
+ while(1) {
+ i = bar();
+ if (i == 42)
+ continue;
+ i = bar();
+ };
+ return i;
+}
+
+
+int foo3() {
+ int i;
+ i = 1 + 2;
+ while(1) {
+ i = bar();
+ if (i == 42)
+ break;
+ };
+ return i;
+}
+
+
+int foo4() {
+ int i;
+ i = 1 + 2;
+ while(1) {
+ i = bar();
+ if (i == 42)
+ continue;
+ };
+ return i;
+}
diff --git a/clang/test/CodeGen/writable-strings.c b/clang/test/CodeGen/writable-strings.c
new file mode 100644
index 0000000..693fa5e
--- /dev/null
+++ b/clang/test/CodeGen/writable-strings.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm -o - -fwritable-strings %s
+
+int main() {
+ char *str = "abc";
+ str[0] = '1';
+ printf("%s", str);
+}
+
diff --git a/clang/test/CodeGen/x86.c b/clang/test/CodeGen/x86.c
new file mode 100644
index 0000000..e97d537
--- /dev/null
+++ b/clang/test/CodeGen/x86.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -triple=i686-pc-linux-gnu -emit-llvm -o - > %t1
+// RUN: grep "ax" %t1
+// RUN: grep "bx" %t1
+// RUN: grep "cx" %t1
+// RUN: grep "dx" %t1
+// RUN: grep "di" %t1
+// RUN: grep "si" %t1
+// RUN: grep "st" %t1
+// RUN: grep "st(1)" %t1
+
+void test1() {
+ int d1, d2;
+ asm ("" : "=a" (d1), "=b" (d2) :
+ "c" (0), "d" (0), "S" (0), "D" (0), "t" (0), "u" (0));
+}
diff --git a/clang/test/CodeGen/x86_32-arguments-darwin.c b/clang/test/CodeGen/x86_32-arguments-darwin.c
new file mode 100644
index 0000000..0ac18b7
--- /dev/null
+++ b/clang/test/CodeGen/x86_32-arguments-darwin.c
@@ -0,0 +1,326 @@
+// RUN: %clang_cc1 -w -fblocks -triple i386-apple-darwin9 -target-cpu yonah -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define signext i8 @f0()
+char f0(void) {
+ return 0;
+}
+
+// CHECK: define signext i16 @f1()
+short f1(void) {
+ return 0;
+}
+
+// CHECK: define i32 @f2()
+int f2(void) {
+ return 0;
+}
+
+// CHECK: define float @f3()
+float f3(void) {
+ return 0;
+}
+
+// CHECK: define double @f4()
+double f4(void) {
+ return 0;
+}
+
+// CHECK: define x86_fp80 @f5()
+long double f5(void) {
+ return 0;
+}
+
+// CHECK: define void @f6(i8 signext %a0, i16 signext %a1, i32 %a2, i64 %a3, i8* %a4)
+void f6(char a0, short a1, int a2, long long a3, void *a4) {}
+
+// CHECK: define void @f7(i32 %a0)
+typedef enum { A, B, C } e7;
+void f7(e7 a0) {}
+
+// CHECK: define i64 @f8_1()
+// CHECK: define void @f8_2(i32 %a0.0, i32 %a0.1)
+struct s8 {
+ int a;
+ int b;
+};
+struct s8 f8_1(void) { while (1) {} }
+void f8_2(struct s8 a0) {}
+
+// This should be passed just as s8.
+
+// CHECK: define i64 @f9_1()
+
+// FIXME: llvm-gcc expands this, this may have some value for the
+// backend in terms of optimization but doesn't change the ABI.
+// CHECK: define void @f9_2(%struct.s9* byval align 4 %a0)
+struct s9 {
+ int a : 17;
+ int b;
+};
+struct s9 f9_1(void) { while (1) {} }
+void f9_2(struct s9 a0) {}
+
+// Return of small structures and unions
+
+// CHECK: float @f10()
+struct s10 {
+ union { };
+ float f;
+} f10(void) { while (1) {} }
+
+// Small vectors and 1 x {i64,double} are returned in registers
+
+// CHECK: i32 @f11()
+// CHECK: void @f12(<2 x i32>* noalias sret %agg.result)
+// CHECK: i64 @f13()
+// CHECK: i64 @f14()
+// CHECK: <2 x i64> @f15()
+// CHECK: <2 x i64> @f16()
+typedef short T11 __attribute__ ((vector_size (4)));
+T11 f11(void) { while (1) {} }
+typedef int T12 __attribute__ ((vector_size (8)));
+T12 f12(void) { while (1) {} }
+typedef long long T13 __attribute__ ((vector_size (8)));
+T13 f13(void) { while (1) {} }
+typedef double T14 __attribute__ ((vector_size (8)));
+T14 f14(void) { while (1) {} }
+typedef long long T15 __attribute__ ((vector_size (16)));
+T15 f15(void) { while (1) {} }
+typedef double T16 __attribute__ ((vector_size (16)));
+T16 f16(void) { while (1) {} }
+
+// And when the single element in a struct (but not for 64 and
+// 128-bits).
+
+// CHECK: i32 @f17()
+// CHECK: void @f18(%{{.*}}* noalias sret %agg.result)
+// CHECK: void @f19(%{{.*}}* noalias sret %agg.result)
+// CHECK: void @f20(%{{.*}}* noalias sret %agg.result)
+// CHECK: void @f21(%{{.*}}* noalias sret %agg.result)
+// CHECK: void @f22(%{{.*}}* noalias sret %agg.result)
+struct { T11 a; } f17(void) { while (1) {} }
+struct { T12 a; } f18(void) { while (1) {} }
+struct { T13 a; } f19(void) { while (1) {} }
+struct { T14 a; } f20(void) { while (1) {} }
+struct { T15 a; } f21(void) { while (1) {} }
+struct { T16 a; } f22(void) { while (1) {} }
+
+// Single element structures are handled specially
+
+// CHECK: float @f23()
+// CHECK: float @f24()
+// CHECK: float @f25()
+struct { float a; } f23(void) { while (1) {} }
+struct { float a[1]; } f24(void) { while (1) {} }
+struct { struct {} a; struct { float a[1]; } b; } f25(void) { while (1) {} }
+
+// Small structures are handled recursively
+// CHECK: i32 @f26()
+// CHECK: void @f27(%struct.s27* noalias sret %agg.result)
+struct s26 { struct { char a, b; } a; struct { char a, b; } b; } f26(void) { while (1) {} }
+struct s27 { struct { char a, b, c; } a; struct { char a; } b; } f27(void) { while (1) {} }
+
+// CHECK: void @f28(%struct.s28* noalias sret %agg.result)
+struct s28 { int a; int b[]; } f28(void) { while (1) {} }
+
+// CHECK: define i16 @f29()
+struct s29 { struct { } a[1]; char b; char c; } f29(void) { while (1) {} }
+
+// CHECK: define i16 @f30()
+struct s30 { char a; char b : 4; } f30(void) { while (1) {} }
+
+// CHECK: define float @f31()
+struct s31 { char : 0; float b; char : 0; } f31(void) { while (1) {} }
+
+// CHECK: define i32 @f32()
+struct s32 { char a; unsigned : 0; } f32(void) { while (1) {} }
+
+// CHECK: define float @f33()
+struct s33 { float a; long long : 0; } f33(void) { while (1) {} }
+
+// CHECK: define float @f34()
+struct s34 { struct { int : 0; } a; float b; } f34(void) { while (1) {} }
+
+// CHECK: define i16 @f35()
+struct s35 { struct { int : 0; } a; char b; char c; } f35(void) { while (1) {} }
+
+// CHECK: define i16 @f36()
+struct s36 { struct { int : 0; } a[2][10]; char b; char c; } f36(void) { while (1) {} }
+
+// CHECK: define float @f37()
+struct s37 { float c[1][1]; } f37(void) { while (1) {} }
+
+// CHECK: define void @f38(%struct.s38* noalias sret %agg.result)
+struct s38 { char a[3]; short b; } f38(void) { while (1) {} }
+
+// CHECK: define void @f39(%struct.s39* byval align 16 %x)
+typedef int v39 __attribute((vector_size(16)));
+struct s39 { v39 x; };
+void f39(struct s39 x) {}
+
+// <rdar://problem/7247671>
+// CHECK: define i32 @f40()
+enum e40 { ec0 = 0 };
+enum e40 f40(void) { }
+
+// CHECK: define void ()* @f41()
+typedef void (^vvbp)(void);
+vvbp f41(void) { }
+
+// CHECK: define i32 @f42()
+struct s42 { enum e40 f0; } f42(void) { }
+
+// CHECK: define i64 @f43()
+struct s43 { enum e40 f0; int f1; } f43(void) { }
+
+// CHECK: define void ()* @f44()
+struct s44 { vvbp f0; } f44(void) { }
+
+// CHECK: define i64 @f45()
+struct s45 { vvbp f0; int f1; } f45(void) { }
+
+// CHECK: define void @f46(i32 %a0)
+void f46(enum e40 a0) { }
+
+// CHECK: define void @f47(void ()* %a1)
+void f47(vvbp a1) { }
+
+// CHECK: define void @f48(i32 %a0.0)
+struct s48 { enum e40 f0; };
+void f48(struct s48 a0) { }
+
+// CHECK: define void @f49(i32 %a0.0, i32 %a0.1)
+struct s49 { enum e40 f0; int f1; };
+void f49(struct s49 a0) { }
+
+// CHECK: define void @f50(void ()* %a0.0)
+struct s50 { vvbp f0; };
+void f50(struct s50 a0) { }
+
+// CHECK: define void @f51(void ()* %a0.0, i32 %a0.1)
+struct s51 { vvbp f0; int f1; };
+void f51(struct s51 a0) { }
+
+// CHECK: define void @f52(%struct.s52* byval align 4)
+struct s52 {
+ long double a;
+};
+void f52(struct s52 x) {}
+
+// CHECK: define void @f53(%struct.s53* byval align 4)
+struct __attribute__((aligned(32))) s53 {
+ int x;
+ int y;
+};
+void f53(struct s53 x) {}
+
+typedef unsigned short v2i16 __attribute__((__vector_size__(4)));
+
+// CHECK: define i32 @f54(i32 %arg.coerce)
+// rdar://8359483
+v2i16 f54(v2i16 arg) { return arg+arg; }
+
+
+typedef int v4i32 __attribute__((__vector_size__(16)));
+
+// CHECK: define <2 x i64> @f55(<4 x i32> %arg)
+// PR8029
+v4i32 f55(v4i32 arg) { return arg+arg; }
+
+// CHECK: define void @f56(
+// CHECK: i8 signext %a0, %struct.s56_0* byval align 4 %a1,
+// CHECK: x86_mmx %a2.coerce, %struct.s56_1* byval align 4,
+// CHECK: i64 %a4.coerce, %struct.s56_2* byval align 4,
+// CHECK: <4 x i32> %a6, %struct.s56_3* byval align 16 %a7,
+// CHECK: <2 x double> %a8, %struct.s56_4* byval align 16 %a9,
+// CHECK: <8 x i32> %a10, %struct.s56_5* byval align 4,
+// CHECK: <4 x double> %a12, %struct.s56_6* byval align 4)
+
+// CHECK: call void (i32, ...)* @f56_0(i32 1,
+// CHECK: i32 %{{[^ ]*}}, %struct.s56_0* byval align 4 %{{[^ ]*}},
+// CHECK: x86_mmx %{{[^ ]*}}, %struct.s56_1* byval align 4 %{{[^ ]*}},
+// CHECK: i64 %{{[^ ]*}}, %struct.s56_2* byval align 4 %{{[^ ]*}},
+// CHECK: <4 x i32> %{{[^ ]*}}, %struct.s56_3* byval align 16 %{{[^ ]*}},
+// CHECK: <2 x double> %{{[^ ]*}}, %struct.s56_4* byval align 16 %{{[^ ]*}},
+// CHECK: <8 x i32> {{[^ ]*}}, %struct.s56_5* byval align 4 %{{[^ ]*}},
+// CHECK: <4 x double> {{[^ ]*}}, %struct.s56_6* byval align 4 %{{[^ ]*}})
+// CHECK: }
+//
+// <rdar://problem/7964854> [i386] clang misaligns long double in structures
+// when passed byval
+// <rdar://problem/8431367> clang misaligns parameters on stack
+typedef int __attribute__((vector_size (8))) t56_v2i;
+typedef double __attribute__((vector_size (8))) t56_v1d;
+typedef int __attribute__((vector_size (16))) t56_v4i;
+typedef double __attribute__((vector_size (16))) t56_v2d;
+typedef int __attribute__((vector_size (32))) t56_v8i;
+typedef double __attribute__((vector_size (32))) t56_v4d;
+
+struct s56_0 { char a; };
+struct s56_1 { t56_v2i a; };
+struct s56_2 { t56_v1d a; };
+struct s56_3 { t56_v4i a; };
+struct s56_4 { t56_v2d a; };
+struct s56_5 { t56_v8i a; };
+struct s56_6 { t56_v4d a; };
+
+void f56(char a0, struct s56_0 a1,
+ t56_v2i a2, struct s56_1 a3,
+ t56_v1d a4, struct s56_2 a5,
+ t56_v4i a6, struct s56_3 a7,
+ t56_v2d a8, struct s56_4 a9,
+ t56_v8i a10, struct s56_5 a11,
+ t56_v4d a12, struct s56_6 a13) {
+ extern void f56_0(int x, ...);
+ f56_0(1, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
+ a10, a11, a12, a13);
+}
+
+// CHECK: define void @f57(i32 %x.0, i32 %x.1)
+// CHECK: call void @f57(
+struct s57 { _Complex int x; };
+void f57(struct s57 x) {} void f57a(void) { f57((struct s57){1}); }
+
+// CHECK: define void @f58()
+union u58 {};
+void f58(union u58 x) {}
+
+// CHECK: define i64 @f59()
+struct s59 { float x __attribute((aligned(8))); };
+struct s59 f59() { while (1) {} }
+
+// CHECK: define void @f60(%struct.s60* byval align 4, i32 %y)
+struct s60 { int x __attribute((aligned(8))); };
+void f60(struct s60 x, int y) {}
+
+// CHECK: define void @f61(i32 %x, %struct.s61* byval align 16 %y)
+typedef int T61 __attribute((vector_size(16)));
+struct s61 { T61 x; int y; };
+void f61(int x, struct s61 y) {}
+
+// CHECK: define void @f62(i32 %x, %struct.s62* byval align 4)
+typedef int T62 __attribute((vector_size(16)));
+struct s62 { T62 x; int y; } __attribute((packed, aligned(8)));
+void f62(int x, struct s62 y) {}
+
+// CHECK: define i32 @f63
+// CHECK: ptrtoint
+// CHECK: and {{.*}}, -16
+// CHECK: inttoptr
+typedef int T63 __attribute((vector_size(16)));
+struct s63 { T63 x; int y; };
+int f63(int i, ...) {
+ __builtin_va_list ap;
+ __builtin_va_start(ap, i);
+ struct s63 s = __builtin_va_arg(ap, struct s63);
+ __builtin_va_end(ap);
+ return s.y;
+}
+
+// CHECK: define void @f64(%struct.s64* byval align 4 %x)
+struct s64 { signed char a[0]; signed char b[]; };
+void f64(struct s64 x) {}
+
+// CHECK: define float @f65()
+struct s65 { signed char a[0]; float b; };
+struct s65 f65() { return (struct s65){{},2}; }
diff --git a/clang/test/CodeGen/x86_32-arguments-linux.c b/clang/test/CodeGen/x86_32-arguments-linux.c
new file mode 100644
index 0000000..81dcaf6
--- /dev/null
+++ b/clang/test/CodeGen/x86_32-arguments-linux.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -w -fblocks -triple i386-pc-linux-gnu -target-cpu pentium4 -emit-llvm -o %t %s
+// RUN: FileCheck < %t %s
+
+// CHECK: define void @f56(
+// CHECK: i8 signext %a0, %struct.s56_0* byval align 4 %a1,
+// CHECK: x86_mmx %a2.coerce, %struct.s56_1* byval align 4,
+// CHECK: <1 x double> %a4, %struct.s56_2* byval align 4,
+// CHECK: <4 x i32> %a6, %struct.s56_3* byval align 4,
+// CHECK: <2 x double> %a8, %struct.s56_4* byval align 4,
+// CHECK: <8 x i32> %a10, %struct.s56_5* byval align 4,
+// CHECK: <4 x double> %a12, %struct.s56_6* byval align 4)
+
+// CHECK: call void (i32, ...)* @f56_0(i32 1,
+// CHECK: i32 %{{.*}}, %struct.s56_0* byval align 4 %{{[^ ]*}},
+// CHECK: x86_mmx %{{[^ ]*}}, %struct.s56_1* byval align 4 %{{[^ ]*}},
+// CHECK: <1 x double> %{{[^ ]*}}, %struct.s56_2* byval align 4 %{{[^ ]*}},
+// CHECK: <4 x i32> %{{[^ ]*}}, %struct.s56_3* byval align 4 %{{[^ ]*}},
+// CHECK: <2 x double> %{{[^ ]*}}, %struct.s56_4* byval align 4 %{{[^ ]*}},
+// CHECK: <8 x i32> %{{[^ ]*}}, %struct.s56_5* byval align 4 %{{[^ ]*}},
+// CHECK: <4 x double> %{{[^ ]*}}, %struct.s56_6* byval align 4 %{{[^ ]*}})
+// CHECK: }
+//
+// <rdar://problem/7964854> [i386] clang misaligns long double in structures
+// when passed byval
+// <rdar://problem/8431367> clang misaligns parameters on stack
+typedef int __attribute__((vector_size (8))) t56_v2i;
+typedef double __attribute__((vector_size (8))) t56_v1d;
+typedef int __attribute__((vector_size (16))) t56_v4i;
+typedef double __attribute__((vector_size (16))) t56_v2d;
+typedef int __attribute__((vector_size (32))) t56_v8i;
+typedef double __attribute__((vector_size (32))) t56_v4d;
+
+struct s56_0 { char a; };
+struct s56_1 { t56_v2i a; };
+struct s56_2 { t56_v1d a; };
+struct s56_3 { t56_v4i a; };
+struct s56_4 { t56_v2d a; };
+struct s56_5 { t56_v8i a; };
+struct s56_6 { t56_v4d a; };
+
+void f56(char a0, struct s56_0 a1,
+ t56_v2i a2, struct s56_1 a3,
+ t56_v1d a4, struct s56_2 a5,
+ t56_v4i a6, struct s56_3 a7,
+ t56_v2d a8, struct s56_4 a9,
+ t56_v8i a10, struct s56_5 a11,
+ t56_v4d a12, struct s56_6 a13) {
+ extern void f56_0(int x, ...);
+ f56_0(1, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
+ a10, a11, a12, a13);
+}
diff --git a/clang/test/CodeGen/x86_32-arguments-nommx.c b/clang/test/CodeGen/x86_32-arguments-nommx.c
new file mode 100644
index 0000000..40362f7
--- /dev/null
+++ b/clang/test/CodeGen/x86_32-arguments-nommx.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature -mmx -target-feature +sse2 -triple i686-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+// no-mmx should put mmx into memory
+typedef int __attribute__((vector_size (8))) i32v2;
+int a(i32v2 x) { return x[0]; }
+// CHECK: define i32 @a(i64 %x.coerce)
+
+// but SSE2 vectors should still go into an SSE2 register
+typedef int __attribute__((vector_size (16))) i32v4;
+int b(i32v4 x) { return x[0]; }
+// CHECK: define i32 @b(<4 x i32> %x)
diff --git a/clang/test/CodeGen/x86_32-arguments-realign.c b/clang/test/CodeGen/x86_32-arguments-realign.c
new file mode 100644
index 0000000..b08862e
--- /dev/null
+++ b/clang/test/CodeGen/x86_32-arguments-realign.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -w -fblocks -triple i386-apple-darwin9 -emit-llvm -o %t %s
+// RUN: FileCheck < %t %s
+
+// CHECK: define void @f0(%struct.s0* byval align 4)
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %{{.*}}, i8* %{{.*}}, i32 16, i32 4, i1 false)
+// CHECK: }
+struct s0 { long double a; };
+void f0(struct s0 a0) {
+ extern long double f0_g0;
+ f0_g0 = a0.a;
+}
diff --git a/clang/test/CodeGen/x86_32-arguments-win32.c b/clang/test/CodeGen/x86_32-arguments-win32.c
new file mode 100644
index 0000000..f18bb30
--- /dev/null
+++ b/clang/test/CodeGen/x86_32-arguments-win32.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -w -triple i386-pc-win32 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define i64 @f1_1()
+// CHECK: define void @f1_2(i32 %a0.0, i32 %a0.1)
+struct s1 {
+ int a;
+ int b;
+};
+struct s1 f1_1(void) { while (1) {} }
+void f1_2(struct s1 a0) {}
+
+// CHECK: define i32 @f2_1()
+struct s2 {
+ short a;
+ short b;
+};
+struct s2 f2_1(void) { while (1) {} }
+
+// CHECK: define i16 @f3_1()
+struct s3 {
+ char a;
+ char b;
+};
+struct s3 f3_1(void) { while (1) {} }
+
+// CHECK: define i8 @f4_1()
+struct s4 {
+ char a:4;
+ char b:4;
+};
+struct s4 f4_1(void) { while (1) {} }
+
+// CHECK: define i64 @f5_1()
+// CHECK: define void @f5_2(double %a0.0)
+struct s5 {
+ double a;
+};
+struct s5 f5_1(void) { while (1) {} }
+void f5_2(struct s5 a0) {}
+
+// CHECK: define i32 @f6_1()
+// CHECK: define void @f6_2(float %a0.0)
+struct s6 {
+ float a;
+};
+struct s6 f6_1(void) { while (1) {} }
+void f6_2(struct s6 a0) {}
+
diff --git a/clang/test/CodeGen/x86_64-arguments-darwin.c b/clang/test/CodeGen/x86_64-arguments-darwin.c
new file mode 100644
index 0000000..2f804e6
--- /dev/null
+++ b/clang/test/CodeGen/x86_64-arguments-darwin.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s| FileCheck %s
+
+// rdar://9122143
+// CHECK: declare void @func(i64, double)
+typedef struct _str {
+ union {
+ long double a;
+ long c;
+ };
+} str;
+
+void func(str s);
+str ss;
+void f9122143()
+{
+ func(ss);
+}
diff --git a/clang/test/CodeGen/x86_64-arguments.c b/clang/test/CodeGen/x86_64-arguments.c
new file mode 100644
index 0000000..f73e1f0
--- /dev/null
+++ b/clang/test/CodeGen/x86_64-arguments.c
@@ -0,0 +1,356 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s| FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-feature +avx | FileCheck %s -check-prefix=AVX
+#include <stdarg.h>
+
+// CHECK: define signext i8 @f0()
+char f0(void) {
+ return 0;
+}
+
+// CHECK: define signext i16 @f1()
+short f1(void) {
+ return 0;
+}
+
+// CHECK: define i32 @f2()
+int f2(void) {
+ return 0;
+}
+
+// CHECK: define float @f3()
+float f3(void) {
+ return 0;
+}
+
+// CHECK: define double @f4()
+double f4(void) {
+ return 0;
+}
+
+// CHECK: define x86_fp80 @f5()
+long double f5(void) {
+ return 0;
+}
+
+// CHECK: define void @f6(i8 signext %a0, i16 signext %a1, i32 %a2, i64 %a3, i8* %a4)
+void f6(char a0, short a1, int a2, long long a3, void *a4) {
+}
+
+// CHECK: define void @f7(i32 %a0)
+typedef enum { A, B, C } e7;
+void f7(e7 a0) {
+}
+
+// Test merging/passing of upper eightbyte with X87 class.
+//
+// CHECK: define void @f8_1(%union.u8* noalias sret %agg.result)
+// CHECK: define void @f8_2(%union.u8* byval align 16 %a0)
+union u8 {
+ long double a;
+ int b;
+};
+union u8 f8_1() { while (1) {} }
+void f8_2(union u8 a0) {}
+
+// CHECK: define i64 @f9()
+struct s9 { int a; int b; int : 0; } f9(void) { while (1) {} }
+
+// CHECK: define void @f10(i64 %a0.coerce)
+struct s10 { int a; int b; int : 0; };
+void f10(struct s10 a0) {}
+
+// CHECK: define void @f11(%union.anon* noalias sret %agg.result)
+union { long double a; float b; } f11() { while (1) {} }
+
+// CHECK: define i32 @f12_0()
+// CHECK: define void @f12_1(i32 %a0.coerce)
+struct s12 { int a __attribute__((aligned(16))); };
+struct s12 f12_0(void) { while (1) {} }
+void f12_1(struct s12 a0) {}
+
+// Check that sret parameter is accounted for when checking available integer
+// registers.
+// CHECK: define void @f13(%struct.s13_0* noalias sret %agg.result, i32 %a, i32 %b, i32 %c, i32 %d, {{.*}}* byval align 8 %e, i32 %f)
+
+struct s13_0 { long long f0[3]; };
+struct s13_1 { long long f0[2]; };
+struct s13_0 f13(int a, int b, int c, int d,
+ struct s13_1 e, int f) { while (1) {} }
+
+// CHECK: define void @f14({{.*}}, i8 signext %X)
+void f14(int a, int b, int c, int d, int e, int f, char X) {}
+
+// CHECK: define void @f15({{.*}}, i8* %X)
+void f15(int a, int b, int c, int d, int e, int f, void *X) {}
+
+// CHECK: define void @f16({{.*}}, float %X)
+void f16(float a, float b, float c, float d, float e, float f, float g, float h,
+ float X) {}
+
+// CHECK: define void @f17({{.*}}, x86_fp80 %X)
+void f17(float a, float b, float c, float d, float e, float f, float g, float h,
+ long double X) {}
+
+// Check for valid coercion. The struct should be passed/returned as i32, not
+// as i64 for better code quality.
+// rdar://8135035
+// CHECK: define void @f18(i32 %a, i32 %f18_arg1.coerce)
+struct f18_s0 { int f0; };
+void f18(int a, struct f18_s0 f18_arg1) { while (1) {} }
+
+// Check byval alignment.
+
+// CHECK: define void @f19(%struct.s19* byval align 16 %x)
+struct s19 {
+ long double a;
+};
+void f19(struct s19 x) {}
+
+// CHECK: define void @f20(%struct.s20* byval align 32 %x)
+struct __attribute__((aligned(32))) s20 {
+ int x;
+ int y;
+};
+void f20(struct s20 x) {}
+
+struct StringRef {
+ long x;
+ const char *Ptr;
+};
+
+// rdar://7375902
+// CHECK: define i8* @f21(i64 %S.coerce0, i8* %S.coerce1)
+const char *f21(struct StringRef S) { return S.x+S.Ptr; }
+
+// PR7567
+typedef __attribute__ ((aligned(16))) struct f22s { unsigned long long x[2]; } L;
+void f22(L x, L y) { }
+// CHECK: @f22
+// CHECK: %x = alloca{{.*}}, align 16
+// CHECK: %y = alloca{{.*}}, align 16
+
+
+
+// PR7714
+struct f23S {
+ short f0;
+ unsigned f1;
+ int f2;
+};
+
+
+void f23(int A, struct f23S B) {
+ // CHECK: define void @f23(i32 %A, i64 %B.coerce0, i32 %B.coerce1)
+}
+
+struct f24s { long a; int b; };
+
+struct f23S f24(struct f23S *X, struct f24s *P2) {
+ return *X;
+
+ // CHECK: define { i64, i32 } @f24(%struct.f23S* %X, %struct.f24s* %P2)
+}
+
+// rdar://8248065
+typedef float v4f32 __attribute__((__vector_size__(16)));
+v4f32 f25(v4f32 X) {
+ // CHECK: define <4 x float> @f25(<4 x float> %X)
+ // CHECK-NOT: alloca
+ // CHECK: alloca <4 x float>
+ // CHECK-NOT: alloca
+ // CHECK: store <4 x float> %X, <4 x float>*
+ // CHECK-NOT: store
+ // CHECK: ret <4 x float>
+ return X+X;
+}
+
+struct foo26 {
+ int *X;
+ float *Y;
+};
+
+struct foo26 f26(struct foo26 *P) {
+ // CHECK: define { i32*, float* } @f26(%struct.foo26* %P)
+ return *P;
+}
+
+
+struct v4f32wrapper {
+ v4f32 v;
+};
+
+struct v4f32wrapper f27(struct v4f32wrapper X) {
+ // CHECK: define <4 x float> @f27(<4 x float> %X.coerce)
+ return X;
+}
+
+// rdar://5711709
+struct f28c {
+ double x;
+ int y;
+};
+void f28(struct f28c C) {
+ // CHECK: define void @f28(double %C.coerce0, i32 %C.coerce1)
+}
+
+struct f29a {
+ struct c {
+ double x;
+ int y;
+ } x[1];
+};
+
+void f29a(struct f29a A) {
+ // CHECK: define void @f29a(double %A.coerce0, i32 %A.coerce1)
+}
+
+// rdar://8249586
+struct S0 { char f0[8]; char f2; char f3; char f4; };
+void f30(struct S0 p_4) {
+ // CHECK: define void @f30(i64 %p_4.coerce0, i24 %p_4.coerce1)
+}
+
+// Pass the third element as a float when followed by tail padding.
+// rdar://8251384
+struct f31foo { float a, b, c; };
+float f31(struct f31foo X) {
+ // CHECK: define float @f31(<2 x float> %X.coerce0, float %X.coerce1)
+ return X.c;
+}
+
+_Complex float f32(_Complex float A, _Complex float B) {
+ // rdar://6379669
+ // CHECK: define <2 x float> @f32(<2 x float> %A.coerce, <2 x float> %B.coerce)
+ return A+B;
+}
+
+
+// rdar://8357396
+struct f33s { long x; float c,d; };
+
+void f33(va_list X) {
+ va_arg(X, struct f33s);
+}
+
+typedef unsigned long long v1i64 __attribute__((__vector_size__(8)));
+
+// rdar://8359248
+// CHECK: define i64 @f34(i64 %arg.coerce)
+v1i64 f34(v1i64 arg) { return arg; }
+
+
+// rdar://8358475
+// CHECK: define i64 @f35(i64 %arg.coerce)
+typedef unsigned long v1i64_2 __attribute__((__vector_size__(8)));
+v1i64_2 f35(v1i64_2 arg) { return arg+arg; }
+
+// rdar://9122143
+// CHECK: declare void @func(%struct._str* byval align 16)
+typedef struct _str {
+ union {
+ long double a;
+ long c;
+ };
+} str;
+
+void func(str s);
+str ss;
+void f9122143()
+{
+ func(ss);
+}
+
+// CHECK: define double @f36(double %arg.coerce)
+typedef unsigned v2i32 __attribute((__vector_size__(8)));
+v2i32 f36(v2i32 arg) { return arg; }
+
+// AVX: declare void @f38(<8 x float>)
+// AVX: declare void @f37(<8 x float>)
+// CHECK: declare void @f38(%struct.s256* byval align 32)
+// CHECK: declare void @f37(<8 x float>* byval align 32)
+typedef float __m256 __attribute__ ((__vector_size__ (32)));
+typedef struct {
+ __m256 m;
+} s256;
+
+s256 x38;
+__m256 x37;
+
+void f38(s256 x);
+void f37(__m256 x);
+void f39() { f38(x38); f37(x37); }
+
+// The two next tests make sure that the struct below is passed
+// in the same way regardless of avx being used
+
+// CHECK: declare void @func40(%struct.t128* byval align 16)
+typedef float __m128 __attribute__ ((__vector_size__ (16)));
+typedef struct t128 {
+ __m128 m;
+ __m128 n;
+} two128;
+
+extern void func40(two128 s);
+void func41(two128 s) {
+ func40(s);
+}
+
+// CHECK: declare void @func42(%struct.t128_2* byval align 16)
+typedef struct xxx {
+ __m128 array[2];
+} Atwo128;
+typedef struct t128_2 {
+ Atwo128 x;
+} SA;
+
+extern void func42(SA s);
+void func43(SA s) {
+ func42(s);
+}
+
+// CHECK: define i32 @f44
+// CHECK: ptrtoint
+// CHECK-NEXT: and {{.*}}, -32
+// CHECK-NEXT: inttoptr
+typedef int T44 __attribute((vector_size(32)));
+struct s44 { T44 x; int y; };
+int f44(int i, ...) {
+ __builtin_va_list ap;
+ __builtin_va_start(ap, i);
+ struct s44 s = __builtin_va_arg(ap, struct s44);
+ __builtin_va_end(ap);
+ return s.y;
+}
+
+// Text that vec3 returns the correct LLVM IR type.
+// AVX: define i32 @foo(<3 x i64> %X)
+typedef long long3 __attribute((ext_vector_type(3)));
+int foo(long3 X)
+{
+ return 0;
+}
+
+// Make sure we don't use a varargs convention for a function without a
+// prototype where AVX types are involved.
+// AVX: @test45
+// AVX: call i32 bitcast (i32 (...)* @f45 to i32 (<8 x float>)*)
+int f45();
+__m256 x45;
+void test45() { f45(x45); }
+
+// Make sure we use byval to pass 64-bit vectors in memory; the LLVM call
+// lowering can't handle this case correctly because it runs after legalization.
+// CHECK: @test46
+// CHECK: call void @f46({{.*}}<2 x float>* byval align 8 {{.*}}, <2 x float>* byval align 8 {{.*}})
+typedef float v46 __attribute((vector_size(8)));
+void f46(v46,v46,v46,v46,v46,v46,v46,v46,v46,v46);
+void test46() { v46 x = {1,2}; f46(x,x,x,x,x,x,x,x,x,x); }
+
+// Check that we pass the struct below without using byval, which helps out
+// codegen.
+//
+// CHECK: @test47
+// CHECK: call void @f47(i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}})
+struct s47 { unsigned a; };
+void f47(int,int,int,int,int,int,struct s47);
+void test47(int a, struct s47 b) { f47(a, a, a, a, a, a, b); }
diff --git a/clang/test/CodeGenCUDA/device-stub.cu b/clang/test/CodeGenCUDA/device-stub.cu
new file mode 100644
index 0000000..af73ea9
--- /dev/null
+++ b/clang/test/CodeGenCUDA/device-stub.cu
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+#include "../SemaCUDA/cuda.h"
+
+// Test that we build the correct number of calls to cudaSetupArgument followed
+// by a call to cudaLaunch.
+
+// CHECK: define{{.*}}kernelfunc
+// CHECK: call{{.*}}cudaSetupArgument
+// CHECK: call{{.*}}cudaSetupArgument
+// CHECK: call{{.*}}cudaSetupArgument
+// CHECK: call{{.*}}cudaLaunch
+__global__ void kernelfunc(int i, int j, int k) {}
diff --git a/clang/test/CodeGenCUDA/filter-decl.cu b/clang/test/CodeGenCUDA/filter-decl.cu
new file mode 100644
index 0000000..b758632
--- /dev/null
+++ b/clang/test/CodeGenCUDA/filter-decl.cu
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-HOST %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -fcuda-is-device | FileCheck -check-prefix=CHECK-DEVICE %s
+
+#include "../SemaCUDA/cuda.h"
+
+// CHECK-HOST-NOT: constantdata = global
+// CHECK-DEVICE: constantdata = global
+__constant__ char constantdata[256];
+
+// CHECK-HOST-NOT: devicedata = global
+// CHECK-DEVICE: devicedata = global
+__device__ char devicedata[256];
+
+// CHECK-HOST-NOT: shareddata = global
+// CHECK-DEVICE: shareddata = global
+__shared__ char shareddata[256];
+
+// CHECK-HOST: hostdata = global
+// CHECK-DEVICE-NOT: hostdata = global
+char hostdata[256];
+
+// CHECK-HOST: define{{.*}}implicithostonlyfunc
+// CHECK-DEVICE-NOT: define{{.*}}implicithostonlyfunc
+void implicithostonlyfunc(void) {}
+
+// CHECK-HOST: define{{.*}}explicithostonlyfunc
+// CHECK-DEVICE-NOT: define{{.*}}explicithostonlyfunc
+__host__ void explicithostonlyfunc(void) {}
+
+// CHECK-HOST-NOT: define{{.*}}deviceonlyfunc
+// CHECK-DEVICE: define{{.*}}deviceonlyfunc
+__device__ void deviceonlyfunc(void) {}
+
+// CHECK-HOST: define{{.*}}hostdevicefunc
+// CHECK-DEVICE: define{{.*}}hostdevicefunc
+__host__ __device__ void hostdevicefunc(void) {}
+
+// CHECK-HOST: define{{.*}}globalfunc
+// CHECK-DEVICE: define{{.*}}globalfunc
+__global__ void globalfunc(void) {}
diff --git a/clang/test/CodeGenCUDA/kernel-call.cu b/clang/test/CodeGenCUDA/kernel-call.cu
new file mode 100644
index 0000000..f134624
--- /dev/null
+++ b/clang/test/CodeGenCUDA/kernel-call.cu
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+#include "../SemaCUDA/cuda.h"
+
+__global__ void g1(int x) {}
+
+int main(void) {
+ // CHECK: call{{.*}}cudaConfigureCall
+ // CHECK: icmp
+ // CHECK: br
+ // CHECK: call{{.*}}g1
+ g1<<<1, 1>>>(42);
+}
diff --git a/clang/test/CodeGenCUDA/ptx-kernels.cu b/clang/test/CodeGenCUDA/ptx-kernels.cu
new file mode 100644
index 0000000..ecca851
--- /dev/null
+++ b/clang/test/CodeGenCUDA/ptx-kernels.cu
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -triple ptx32-unknown-unknown -fcuda-is-device -emit-llvm -o - | FileCheck %s
+
+#include "../SemaCUDA/cuda.h"
+
+// CHECK: define ptx_device{{.*}}device_function
+__device__ void device_function() {}
+
+// CHECK: define ptx_kernel{{.*}}global_function
+__global__ void global_function() {
+ // CHECK: call ptx_device{{.*}}device_function
+ device_function();
+}
diff --git a/clang/test/CodeGenCXX/2003-11-02-WeakLinkage.cpp b/clang/test/CodeGenCXX/2003-11-02-WeakLinkage.cpp
new file mode 100644
index 0000000..02f9fc6
--- /dev/null
+++ b/clang/test/CodeGenCXX/2003-11-02-WeakLinkage.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// The template should compile to linkonce linkage, not weak linkage.
+
+// CHECK-NOT: weak
+template<class T>
+void thefunc();
+
+template<class T>
+inline void thefunc() {}
+
+void test() {
+ thefunc<int>();
+}
diff --git a/clang/test/CodeGenCXX/2003-11-18-PtrMemConstantInitializer.cpp b/clang/test/CodeGenCXX/2003-11-18-PtrMemConstantInitializer.cpp
new file mode 100644
index 0000000..9cecf48
--- /dev/null
+++ b/clang/test/CodeGenCXX/2003-11-18-PtrMemConstantInitializer.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+struct Gfx {
+ void opMoveSetShowText();
+};
+
+struct Operator {
+ void (Gfx::*func)();
+};
+
+Operator opTab[] = {
+ {&Gfx::opMoveSetShowText},
+};
diff --git a/clang/test/CodeGenCXX/2003-11-27-MultipleInheritanceThunk.cpp b/clang/test/CodeGenCXX/2003-11-27-MultipleInheritanceThunk.cpp
new file mode 100644
index 0000000..3e53397
--- /dev/null
+++ b/clang/test/CodeGenCXX/2003-11-27-MultipleInheritanceThunk.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+
+struct CallSite {
+ int X;
+
+ CallSite(const CallSite &CS);
+};
+
+struct AliasAnalysis {
+ int TD;
+
+ virtual int getModRefInfo(CallSite CS);
+};
+
+
+struct Pass {
+ int X;
+ virtual int foo();
+};
+
+struct AliasAnalysisCounter : public Pass, public AliasAnalysis {
+ int getModRefInfo(CallSite CS) {
+ return 0;
+ }
+};
+
+AliasAnalysisCounter AAC;
diff --git a/clang/test/CodeGenCXX/2003-11-29-DuplicatedCleanupTest.cpp b/clang/test/CodeGenCXX/2003-11-29-DuplicatedCleanupTest.cpp
new file mode 100644
index 0000000..45325bc
--- /dev/null
+++ b/clang/test/CodeGenCXX/2003-11-29-DuplicatedCleanupTest.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+
+void doesntThrow() throw();
+struct F {
+ ~F() { doesntThrow(); }
+};
+
+void atest() {
+ F A;
+lab:
+ F B;
+ goto lab;
+}
+
+void test(int val) {
+label: {
+ F A;
+ F B;
+ if (val == 0) goto label;
+ if (val == 1) goto label;
+}
+}
+
+void test3(int val) {
+label: {
+ F A;
+ F B;
+ if (val == 0) { doesntThrow(); goto label; }
+ if (val == 1) { doesntThrow(); goto label; }
+}
+}
+
+void test4(int val) {
+label: {
+ F A;
+ F B;
+ if (val == 0) { F C; goto label; }
+ if (val == 1) { F D; goto label; }
+}
+}
diff --git a/clang/test/CodeGenCXX/2003-12-08-ArrayOfPtrToMemberFunc.cpp b/clang/test/CodeGenCXX/2003-12-08-ArrayOfPtrToMemberFunc.cpp
new file mode 100644
index 0000000..38de271
--- /dev/null
+++ b/clang/test/CodeGenCXX/2003-12-08-ArrayOfPtrToMemberFunc.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+struct Evil {
+ void fun ();
+};
+int foo();
+typedef void (Evil::*memfunptr) ();
+static memfunptr jumpTable[] = { &Evil::fun };
+
+void Evil::fun() {
+ (this->*jumpTable[foo()]) ();
+}
diff --git a/clang/test/CodeGenCXX/2004-01-11-DynamicInitializedConstant.cpp b/clang/test/CodeGenCXX/2004-01-11-DynamicInitializedConstant.cpp
new file mode 100644
index 0000000..0c9333f
--- /dev/null
+++ b/clang/test/CodeGenCXX/2004-01-11-DynamicInitializedConstant.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-NOT: constant
+extern int X;
+const int Y = X;
+const int* foo() { return &Y; }
diff --git a/clang/test/CodeGenCXX/2004-03-08-ReinterpretCastCopy.cpp b/clang/test/CodeGenCXX/2004-03-08-ReinterpretCastCopy.cpp
new file mode 100644
index 0000000..a6e2e30
--- /dev/null
+++ b/clang/test/CodeGenCXX/2004-03-08-ReinterpretCastCopy.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+struct A {
+ virtual void Method() = 0;
+};
+
+struct B : public A {
+ virtual void Method() { }
+};
+
+typedef void (A::*fn_type_a)(void);
+typedef void (B::*fn_type_b)(void);
+
+int main(int argc, char **argv)
+{
+ fn_type_a f = reinterpret_cast<fn_type_a>(&B::Method);
+ fn_type_b g = reinterpret_cast<fn_type_b>(f);
+ B b;
+ (b.*g)();
+ return 0;
+}
diff --git a/clang/test/CodeGenCXX/2004-03-09-UnmangledBuiltinMethods.cpp b/clang/test/CodeGenCXX/2004-03-09-UnmangledBuiltinMethods.cpp
new file mode 100644
index 0000000..5d8c8b0
--- /dev/null
+++ b/clang/test/CodeGenCXX/2004-03-09-UnmangledBuiltinMethods.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: _ZN11AccessFlags6strlenEv
+struct AccessFlags {
+ void strlen();
+};
+
+void AccessFlags::strlen() { }
diff --git a/clang/test/CodeGenCXX/2004-03-15-CleanupsAndGotos.cpp b/clang/test/CodeGenCXX/2004-03-15-CleanupsAndGotos.cpp
new file mode 100644
index 0000000..01350c0
--- /dev/null
+++ b/clang/test/CodeGenCXX/2004-03-15-CleanupsAndGotos.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+// Testcase from Bug 291
+
+struct X {
+ ~X();
+};
+
+void foo() {
+ X v;
+
+TryAgain:
+ goto TryAgain;
+}
diff --git a/clang/test/CodeGenCXX/2004-06-08-LateTemplateInstantiation.cpp b/clang/test/CodeGenCXX/2004-06-08-LateTemplateInstantiation.cpp
new file mode 100644
index 0000000..97254c1
--- /dev/null
+++ b/clang/test/CodeGenCXX/2004-06-08-LateTemplateInstantiation.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+
+template<typename Ty>
+struct normal_iterator {
+ int FIELD;
+};
+
+void foo(normal_iterator<int>);
+normal_iterator<int> baz();
+
+void bar() {
+ foo(baz());
+}
+
+void *bar2() {
+ return (void*)foo;
+}
diff --git a/clang/test/CodeGenCXX/2004-09-27-DidntEmitTemplate.cpp b/clang/test/CodeGenCXX/2004-09-27-DidntEmitTemplate.cpp
new file mode 100644
index 0000000..618894f
--- /dev/null
+++ b/clang/test/CodeGenCXX/2004-09-27-DidntEmitTemplate.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+// This is a testcase for LLVM PR445, which was a problem where the
+// instantiation of callDefaultCtor was not being emitted correctly.
+
+// CHECK-NOT: declare{{.*}}callDefaultCtor
+struct Pass {};
+
+template<typename PassName>
+Pass *callDefaultCtor() { return new Pass(); }
+
+void foo(Pass *(*C)());
+
+struct basic_string {
+ bool empty() const { return true; }
+};
+
+
+bool foo2(basic_string &X) {
+ return X.empty();
+}
+void baz() { foo(callDefaultCtor<Pass>); }
diff --git a/clang/test/CodeGenCXX/2004-11-27-ExceptionCleanupAssertion.cpp b/clang/test/CodeGenCXX/2004-11-27-ExceptionCleanupAssertion.cpp
new file mode 100644
index 0000000..ebcce77
--- /dev/null
+++ b/clang/test/CodeGenCXX/2004-11-27-ExceptionCleanupAssertion.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -emit-llvm -o /dev/null
+
+// This is PR421
+
+struct Strongbad {
+ Strongbad(const char *str );
+ ~Strongbad();
+ operator const char *() const;
+};
+
+void TheCheat () {
+ Strongbad foo(0);
+ Strongbad dirs[] = { Strongbad(0) + 1};
+}
diff --git a/clang/test/CodeGenCXX/2004-11-27-FriendDefaultArgCrash.cpp b/clang/test/CodeGenCXX/2004-11-27-FriendDefaultArgCrash.cpp
new file mode 100644
index 0000000..3bfecd5
--- /dev/null
+++ b/clang/test/CodeGenCXX/2004-11-27-FriendDefaultArgCrash.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+// PR447
+
+namespace nm {
+ struct str {
+ friend int foo(int arg = 0);
+ };
+}
diff --git a/clang/test/CodeGenCXX/2005-01-03-StaticInitializers.cpp b/clang/test/CodeGenCXX/2005-01-03-StaticInitializers.cpp
new file mode 100644
index 0000000..875c412
--- /dev/null
+++ b/clang/test/CodeGenCXX/2005-01-03-StaticInitializers.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+struct S {
+ int A[2];
+};
+
+// CHECK-NOT: llvm.global_ctor
+int XX = (int)(long)&(((struct S*)0)->A[1]);
diff --git a/clang/test/CodeGenCXX/2005-02-11-AnonymousUnion.cpp b/clang/test/CodeGenCXX/2005-02-11-AnonymousUnion.cpp
new file mode 100644
index 0000000..dee5817
--- /dev/null
+++ b/clang/test/CodeGenCXX/2005-02-11-AnonymousUnion.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+// Test anonymous union with members of the same size.
+int test1(float F) {
+ union {
+ float G;
+ int i;
+ };
+ G = F;
+ return i;
+}
+
+// test anonymous union with members of differing size.
+int test2(short F) {
+ volatile union {
+ short G;
+ int i;
+ };
+ G = F;
+ return i;
+}
+
+// Make sure that normal unions work. duh :)
+volatile union U_t {
+ short S;
+ int i;
+} U;
+
+int test3(short s) {
+ U.S = s;
+ return U.i;
+}
diff --git a/clang/test/CodeGenCXX/2005-02-13-BadDynamicInit.cpp b/clang/test/CodeGenCXX/2005-02-13-BadDynamicInit.cpp
new file mode 100644
index 0000000..b1db67a
--- /dev/null
+++ b/clang/test/CodeGenCXX/2005-02-13-BadDynamicInit.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// This testcase corresponds to PR509
+struct Data {
+ unsigned *data;
+ unsigned array[1];
+};
+
+// CHECK-NOT: llvm.global_ctors
+Data shared_null = { shared_null.array };
diff --git a/clang/test/CodeGenCXX/2005-02-14-BitFieldOffset.cpp b/clang/test/CodeGenCXX/2005-02-14-BitFieldOffset.cpp
new file mode 100644
index 0000000..c37f5dc
--- /dev/null
+++ b/clang/test/CodeGenCXX/2005-02-14-BitFieldOffset.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-NOT: i32 6
+struct QVectorTypedData {
+ int size;
+ unsigned int sharable : 1;
+ unsigned short array[1];
+};
+
+void foo(QVectorTypedData *X) {
+ X->array[0] = 123;
+}
diff --git a/clang/test/CodeGenCXX/2005-02-19-BitfieldStructCrash.cpp b/clang/test/CodeGenCXX/2005-02-19-BitfieldStructCrash.cpp
new file mode 100644
index 0000000..937a300
--- /dev/null
+++ b/clang/test/CodeGenCXX/2005-02-19-BitfieldStructCrash.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+struct QChar {unsigned short X; QChar(unsigned short); } ;
+
+struct Command {
+ Command(QChar c) : c(c) {}
+ unsigned int type : 4;
+ QChar c;
+ };
+
+Command X(QChar('c'));
+
+void Foo(QChar );
+void bar() { Foo(X.c); }
diff --git a/clang/test/CodeGenCXX/2005-02-19-UnnamedVirtualThunkArgument.cpp b/clang/test/CodeGenCXX/2005-02-19-UnnamedVirtualThunkArgument.cpp
new file mode 100644
index 0000000..986001a
--- /dev/null
+++ b/clang/test/CodeGenCXX/2005-02-19-UnnamedVirtualThunkArgument.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+struct Foo {
+ Foo();
+ virtual ~Foo();
+};
+
+struct Bar {
+ Bar();
+ virtual ~Bar();
+ virtual bool test(bool) const;
+};
+
+struct Baz : public Foo, public Bar {
+ Baz();
+ virtual ~Baz();
+ virtual bool test(bool) const;
+};
+
+bool Baz::test(bool) const {
+ return true;
+}
diff --git a/clang/test/CodeGenCXX/2005-02-20-BrokenReferenceTest.cpp b/clang/test/CodeGenCXX/2005-02-20-BrokenReferenceTest.cpp
new file mode 100644
index 0000000..36f911e
--- /dev/null
+++ b/clang/test/CodeGenCXX/2005-02-20-BrokenReferenceTest.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+void test(unsigned char *b, int rb) {
+ typedef unsigned char imgfoo[10][rb];
+ imgfoo &br = *(imgfoo *)b;
+
+ br[0][0] = 1;
+
+ rb = br[0][0];
+}
diff --git a/clang/test/CodeGenCXX/2006-03-01-GimplifyCrash.cpp b/clang/test/CodeGenCXX/2006-03-01-GimplifyCrash.cpp
new file mode 100644
index 0000000..b809751
--- /dev/null
+++ b/clang/test/CodeGenCXX/2006-03-01-GimplifyCrash.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+struct PrefMapElem {
+ virtual ~PrefMapElem();
+ unsigned int fPrefId;
+};
+
+int foo() {
+ PrefMapElem* fMap;
+ if (fMap[0].fPrefId == 1)
+ return 1;
+
+ return 0;
+}
diff --git a/clang/test/CodeGenCXX/2006-03-06-C++RecurseCrash.cpp b/clang/test/CodeGenCXX/2006-03-06-C++RecurseCrash.cpp
new file mode 100644
index 0000000..01476b7
--- /dev/null
+++ b/clang/test/CodeGenCXX/2006-03-06-C++RecurseCrash.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+namespace std {
+ class exception { };
+
+ class type_info {
+ public:
+ virtual ~type_info();
+ };
+
+}
+
+namespace __cxxabiv1 {
+ class __si_class_type_info : public std::type_info {
+ ~__si_class_type_info();
+ };
+}
+
+class recursive_init: public std::exception {
+public:
+ virtual ~recursive_init() throw ();
+};
+
+recursive_init::~recursive_init() throw() { }
diff --git a/clang/test/CodeGenCXX/2006-09-12-OpaqueStructCrash.cpp b/clang/test/CodeGenCXX/2006-09-12-OpaqueStructCrash.cpp
new file mode 100644
index 0000000..bd270dd
--- /dev/null
+++ b/clang/test/CodeGenCXX/2006-09-12-OpaqueStructCrash.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+
+struct A {
+ virtual ~A();
+};
+
+template <typename Ty>
+struct B : public A {
+ ~B () { delete [] val; }
+private:
+ Ty* val;
+};
+
+template <typename Ty>
+struct C : public A {
+ C ();
+ ~C ();
+};
+
+template <typename Ty>
+struct D : public A {
+ D () {}
+ private:
+ B<C<Ty> > blocks;
+};
+
+template class D<double>;
diff --git a/clang/test/CodeGenCXX/2006-10-30-ClassBitfield.cpp b/clang/test/CodeGenCXX/2006-10-30-ClassBitfield.cpp
new file mode 100644
index 0000000..8f61f7b
--- /dev/null
+++ b/clang/test/CodeGenCXX/2006-10-30-ClassBitfield.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+// PR954
+
+struct _Refcount_Base {
+ unsigned long _M_ref_count;
+ int _M_ref_count_lock;
+ _Refcount_Base() : _M_ref_count(0) {}
+};
+
+struct _Rope_RopeRep : public _Refcount_Base
+{
+public:
+ int _M_tag:8;
+};
+
+int foo(_Rope_RopeRep* r) { return r->_M_tag; }
diff --git a/clang/test/CodeGenCXX/2006-11-20-GlobalSymbols.cpp b/clang/test/CodeGenCXX/2006-11-20-GlobalSymbols.cpp
new file mode 100644
index 0000000..34594f4
--- /dev/null
+++ b/clang/test/CodeGenCXX/2006-11-20-GlobalSymbols.cpp
@@ -0,0 +1,11 @@
+// PR1013
+// Check to make sure debug symbols use the correct name for globals and
+// functions. Will not assemble if it fails to.
+// RUN: %clang_cc1 -emit-llvm -g -o - %s | FileCheck %s
+
+// CHECK: f\01oo"
+int foo __asm__("f\001oo");
+
+int bar() {
+ return foo;
+}
diff --git a/clang/test/CodeGenCXX/2006-11-30-ConstantExprCrash.cpp b/clang/test/CodeGenCXX/2006-11-30-ConstantExprCrash.cpp
new file mode 100644
index 0000000..2088e63
--- /dev/null
+++ b/clang/test/CodeGenCXX/2006-11-30-ConstantExprCrash.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+// PR1027
+
+struct sys_var {
+ unsigned name_length;
+
+ bool no_support_one_shot;
+ sys_var() {}
+};
+
+
+struct sys_var_thd : public sys_var {
+};
+
+extern sys_var_thd sys_auto_is_null;
+
+sys_var *getsys_variables() {
+ return &sys_auto_is_null;
+}
+
+sys_var *sys_variables = &sys_auto_is_null;
diff --git a/clang/test/CodeGenCXX/2007-01-02-UnboundedArray.cpp b/clang/test/CodeGenCXX/2007-01-02-UnboundedArray.cpp
new file mode 100644
index 0000000..0cd83fa
--- /dev/null
+++ b/clang/test/CodeGenCXX/2007-01-02-UnboundedArray.cpp
@@ -0,0 +1,14 @@
+// Make sure unbounded arrays compile with debug information.
+//
+// RUN: %clang_cc1 -emit-llvm -g %s -o -
+
+// PR1068
+
+struct Object {
+ char buffer[];
+};
+
+int main(int argc, char** argv) {
+ new Object;
+ return 0;
+}
diff --git a/clang/test/CodeGenCXX/2007-01-06-PtrMethodInit.cpp b/clang/test/CodeGenCXX/2007-01-06-PtrMethodInit.cpp
new file mode 100644
index 0000000..37005c5
--- /dev/null
+++ b/clang/test/CodeGenCXX/2007-01-06-PtrMethodInit.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple i386-apple-macosx10.7.2
+// PR1084
+
+extern "C"
+{
+ typedef unsigned char PRUint8;
+ typedef unsigned int PRUint32;
+}
+typedef PRUint32 nsresult;
+struct nsID
+{
+};
+typedef nsID nsIID;
+class nsISupports
+{
+};
+extern "C++"
+{
+ template < class T > struct nsCOMTypeInfo
+ {
+ static const nsIID & GetIID ()
+ {
+ }
+ };
+}
+
+class nsIDOMEvent:public nsISupports
+{
+};
+class nsIDOMEventListener:public nsISupports
+{
+public:static const nsIID & GetIID ()
+ {
+ }
+ virtual nsresult
+ __attribute__ ((regparm (0), cdecl)) HandleEvent (nsIDOMEvent * event) =
+ 0;
+};
+class nsIDOMMouseListener:public nsIDOMEventListener
+{
+public:static const nsIID & GetIID ()
+ {
+ static const nsIID iid = {
+ };
+ }
+ virtual nsresult
+ __attribute__ ((regparm (0),
+ cdecl)) MouseDown (nsIDOMEvent * aMouseEvent) = 0;
+};
+typedef
+typeof (&nsIDOMEventListener::HandleEvent)
+ GenericHandler;
+ struct EventDispatchData
+ {
+ PRUint32 message;
+ GenericHandler method;
+ PRUint8 bits;
+ };
+ struct EventTypeData
+ {
+ const EventDispatchData *events;
+ int numEvents;
+ const nsIID *iid;
+ };
+ static const EventDispatchData sMouseEvents[] = {
+ {
+ (300 + 2),
+ reinterpret_cast < GenericHandler > (&nsIDOMMouseListener::MouseDown),
+ 0x01}
+ };
+static const EventTypeData sEventTypes[] = {
+ {
+ sMouseEvents, (sizeof (sMouseEvents) / sizeof (sMouseEvents[0])),
+ &nsCOMTypeInfo < nsIDOMMouseListener >::GetIID ()}
+};
diff --git a/clang/test/CodeGenCXX/2007-04-05-PackedBitFields-1.cpp b/clang/test/CodeGenCXX/2007-04-05-PackedBitFields-1.cpp
new file mode 100644
index 0000000..6c39b55
--- /dev/null
+++ b/clang/test/CodeGenCXX/2007-04-05-PackedBitFields-1.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+#ifdef PACKED
+#define P __attribute__((packed))
+#else
+#define P
+#endif
+
+struct P M_Packed {
+ unsigned int l_Packed;
+ unsigned short k_Packed : 6,
+ i_Packed : 15,
+ j_Packed : 11;
+
+};
+
+struct M_Packed sM_Packed;
+
+int testM_Packed (void) {
+ struct M_Packed x;
+ return (x.i_Packed != 0);
+}
diff --git a/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap-2.cpp b/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap-2.cpp
new file mode 100644
index 0000000..d7b0eae
--- /dev/null
+++ b/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap-2.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+#ifdef PACKED
+#define P __attribute__((packed))
+#else
+#define P
+#endif
+
+struct P M_Packed {
+ unsigned long sorted : 1;
+ unsigned long from_array : 1;
+ unsigned long mixed_encoding : 1;
+ unsigned long encoding : 8;
+ unsigned long count : 21;
+
+};
+
+struct M_Packed sM_Packed;
+
+int testM_Packed (void) {
+ struct M_Packed x;
+ return (x.count != 0);
+}
diff --git a/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap.cpp b/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap.cpp
new file mode 100644
index 0000000..6911767
--- /dev/null
+++ b/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsOverlap.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+
+#ifdef PACKED
+#define P __attribute__((packed))
+#else
+#define P
+#endif
+
+struct P M_Packed {
+ unsigned int l_Packed;
+ unsigned short k_Packed : 6,
+ i_Packed : 15;
+ char c;
+
+};
+
+struct M_Packed sM_Packed;
+
+int testM_Packed (void) {
+ struct M_Packed x;
+ return (x.i_Packed != 0);
+}
diff --git a/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsSmall.cpp b/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsSmall.cpp
new file mode 100644
index 0000000..b31f95f
--- /dev/null
+++ b/clang/test/CodeGenCXX/2007-04-05-PackedBitFieldsSmall.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+
+#ifdef PACKED
+// This is an example where size of Packed struct is smaller then
+// the size of bit field type.
+#define P __attribute__((packed))
+#else
+#define P
+#endif
+
+struct P M_Packed {
+ unsigned long long X:50;
+ unsigned Y:2;
+};
+
+struct M_Packed sM_Packed;
+
+int testM_Packed (void) {
+ struct M_Packed x;
+ return (0 != x.Y);
+}
+
+int testM_Packed2 (void) {
+ struct M_Packed x;
+ return (0 != x.X);
+}
diff --git a/clang/test/CodeGenCXX/2007-04-05-StructPackedFieldUnpacked.cpp b/clang/test/CodeGenCXX/2007-04-05-StructPackedFieldUnpacked.cpp
new file mode 100644
index 0000000..c848e7c
--- /dev/null
+++ b/clang/test/CodeGenCXX/2007-04-05-StructPackedFieldUnpacked.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+
+#ifdef PACKED
+#define P __attribute__((packed))
+#else
+#define P
+#endif
+
+struct UnPacked {
+ int X;
+ int Y;
+};
+
+struct P M_Packed {
+ unsigned char A;
+ struct UnPacked B;
+};
+
+struct M_Packed sM_Packed;
+
+int testM_Packed (void) {
+ struct M_Packed x;
+ return (x.B.Y != 0);
+}
diff --git a/clang/test/CodeGenCXX/2007-04-10-PackedUnion.cpp b/clang/test/CodeGenCXX/2007-04-10-PackedUnion.cpp
new file mode 100644
index 0000000..863fc82
--- /dev/null
+++ b/clang/test/CodeGenCXX/2007-04-10-PackedUnion.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+extern "C" {
+
+#pragma pack(push, 2)
+ typedef struct ABC* abc;
+
+ struct ABCS {
+ float red;
+ float green;
+ float blue;
+ float alpha;
+ };
+
+ typedef void (*XYZ)();
+#pragma pack(pop)
+}
+
+
+union ABCU {
+ ABCS color;
+ XYZ bg;
+};
+
+struct AData {
+ ABCU data;
+};
+
+class L {
+ public:
+ L() {}
+ L(const L& other);
+
+ private:
+ AData fdata;
+};
+
+
+L::L(const L& other)
+{
+ fdata = other.fdata;
+}
diff --git a/clang/test/CodeGenCXX/2007-04-14-FNoBuiltin.cpp b/clang/test/CodeGenCXX/2007-04-14-FNoBuiltin.cpp
new file mode 100644
index 0000000..4475fda
--- /dev/null
+++ b/clang/test/CodeGenCXX/2007-04-14-FNoBuiltin.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -fno-builtin -o - | FileCheck %s
+// Check that -fno-builtin is honored.
+
+extern "C" int printf(const char*, ...);
+void foo(const char *msg) {
+ // CHECK: call{{.*}}printf
+ printf("%s\n",msg);
+}
diff --git a/clang/test/CodeGenCXX/2007-05-03-VectorInit.cpp b/clang/test/CodeGenCXX/2007-05-03-VectorInit.cpp
new file mode 100644
index 0000000..5bc196f
--- /dev/null
+++ b/clang/test/CodeGenCXX/2007-05-03-VectorInit.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm %s -O0 -o -
+// PR1378
+
+typedef float v4sf __attribute__((vector_size(16)));
+
+typedef v4sf float4;
+
+static float4 splat4(float a)
+{
+ float4 tmp = {a,a,a,a};
+ return tmp;
+}
+
+float4 foo(float a)
+{
+ return splat4(a);
+}
diff --git a/clang/test/CodeGenCXX/2007-07-29-RestrictPtrArg.cpp b/clang/test/CodeGenCXX/2007-07-29-RestrictPtrArg.cpp
new file mode 100644
index 0000000..d7c96f5
--- /dev/null
+++ b/clang/test/CodeGenCXX/2007-07-29-RestrictPtrArg.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+void foo(int * __restrict myptr1, int * myptr2) {
+ // CHECK: noalias
+ myptr1[0] = 0;
+ myptr2[0] = 0;
+}
diff --git a/clang/test/CodeGenCXX/2007-07-29-RestrictRefArg.cpp b/clang/test/CodeGenCXX/2007-07-29-RestrictRefArg.cpp
new file mode 100644
index 0000000..aa9f48b
--- /dev/null
+++ b/clang/test/CodeGenCXX/2007-07-29-RestrictRefArg.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+void foo(int & __restrict myptr1, int & myptr2) {
+ // CHECK: noalias
+ myptr1 = 0;
+ myptr2 = 0;
+}
diff --git a/clang/test/CodeGenCXX/2007-09-10-RecursiveTypeResolution.cpp b/clang/test/CodeGenCXX/2007-09-10-RecursiveTypeResolution.cpp
new file mode 100644
index 0000000..ec8a516
--- /dev/null
+++ b/clang/test/CodeGenCXX/2007-09-10-RecursiveTypeResolution.cpp
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+// PR1634
+
+namespace Manta
+{
+ class CallbackHandle
+ {
+ protected:virtual ~ CallbackHandle (void)
+ {
+ }
+ };
+template < typename Data1 > class CallbackBase_1Data:public CallbackHandle
+ {
+ };
+}
+
+namespace __gnu_cxx
+{
+ template < typename _Iterator, typename _Container >
+ class __normal_iterator
+ {
+ _Iterator _M_current;
+ };
+}
+
+namespace std
+{
+ template < typename _Tp > struct allocator
+ {
+ typedef _Tp *pointer;
+ };
+ template < typename _InputIterator,
+ typename _Tp > inline void find (_InputIterator __last,
+ const _Tp & __val)
+ {
+ };
+}
+
+namespace Manta
+{
+ template < typename _Tp, typename _Alloc> struct _Vector_base
+ {
+ struct _Vector_impl
+ {
+ _Tp *_M_start;
+ };
+ public:
+ _Vector_impl _M_impl;
+ };
+ template < typename _Tp, typename _Alloc = std::allocator < _Tp > >
+ class vector:protected _Vector_base < _Tp,_Alloc >
+ {
+ public:
+ typedef __gnu_cxx::__normal_iterator < typename _Alloc::pointer,
+ vector < _Tp, _Alloc > > iterator;
+ iterator end ()
+ {
+ }
+ };
+ class MantaInterface
+ {
+ };
+ class RTRT
+ {
+ virtual CallbackHandle *registerTerminationCallback (CallbackBase_1Data <
+ MantaInterface * >*);
+ virtual void unregisterCallback (CallbackHandle *);
+ typedef vector < CallbackBase_1Data < int >*>PRCallbackMapType;
+ PRCallbackMapType parallelPreRenderCallbacks;
+ };
+}
+using namespace Manta;
+CallbackHandle *
+RTRT::registerTerminationCallback (CallbackBase_1Data < MantaInterface * >*cb)
+{
+ return cb;
+}
+
+void
+RTRT::unregisterCallback (CallbackHandle * callback)
+{
+ {
+ typedef CallbackBase_1Data < int > callback_t;
+ callback_t *cb = static_cast < callback_t * >(callback);
+ find (parallelPreRenderCallbacks.end (), cb);
+ }
+}
diff --git a/clang/test/CodeGenCXX/2007-10-01-StructResize.cpp b/clang/test/CodeGenCXX/2007-10-01-StructResize.cpp
new file mode 100644
index 0000000..8e5750d
--- /dev/null
+++ b/clang/test/CodeGenCXX/2007-10-01-StructResize.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+#pragma pack(4)
+
+struct Bork {
+ unsigned int f1 : 3;
+ unsigned int f2 : 30;
+};
+
+int Foo(Bork *hdr) {
+ hdr->f1 = 7;
+ hdr->f2 = 927;
+}
diff --git a/clang/test/CodeGenCXX/2008-01-12-VecInit.cpp b/clang/test/CodeGenCXX/2008-01-12-VecInit.cpp
new file mode 100644
index 0000000..92bfd51
--- /dev/null
+++ b/clang/test/CodeGenCXX/2008-01-12-VecInit.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+// rdar://5685492
+
+typedef int __attribute__((vector_size(16))) v;
+v vt = {1, 2, 3, 4};
diff --git a/clang/test/CodeGenCXX/2008-05-07-CrazyOffsetOf.cpp b/clang/test/CodeGenCXX/2008-05-07-CrazyOffsetOf.cpp
new file mode 100644
index 0000000..f842f95
--- /dev/null
+++ b/clang/test/CodeGenCXX/2008-05-07-CrazyOffsetOf.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+// rdar://5914926
+
+struct bork {
+ struct bork *next_local;
+ char * query;
+};
+int offset = (char *) &(((struct bork *) 0x10)->query) - (char *) 0x10;
diff --git a/clang/test/CodeGenCXX/2009-03-17-dbg.cpp b/clang/test/CodeGenCXX/2009-03-17-dbg.cpp
new file mode 100644
index 0000000..e2e6c5a
--- /dev/null
+++ b/clang/test/CodeGenCXX/2009-03-17-dbg.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null -g
+
+template <typename T1,typename T2>
+inline void f(const T1&,const T2&) { }
+
+template <typename T1,typename T2,void F(const T1&,const T2&)>
+struct A {
+ template <typename T> void g(T& i) { }
+};
+
+int main() {
+ int i;
+ A<int,int,f> a;
+ a.g(i);
+}
diff --git a/clang/test/CodeGenCXX/2009-04-23-bool2.cpp b/clang/test/CodeGenCXX/2009-04-23-bool2.cpp
new file mode 100644
index 0000000..cf81cc4
--- /dev/null
+++ b/clang/test/CodeGenCXX/2009-04-23-bool2.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+// g++.old-deja/g++.jason/bool2.C from gcc testsuite.
+// Crashed before 67975 went in.
+struct F {
+ bool b1 : 1;
+ bool b2 : 7;
+};
+
+int main()
+{
+ F f = { true, true };
+
+ if (int (f.b1) != 1)
+ return 1;
+}
diff --git a/clang/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp b/clang/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp
new file mode 100644
index 0000000..8361680
--- /dev/null
+++ b/clang/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fexceptions -emit-llvm %s -o - | FileCheck %s
+int c(void) __attribute__((const));
+int p(void) __attribute__((pure));
+int t(void);
+
+// CHECK: define i32 @_Z1fv() {
+int f(void) {
+ // CHECK: call i32 @_Z1cv() nounwind readnone
+ // CHECK: call i32 @_Z1pv() nounwind readonly
+ return c() + p() + t();
+}
+
+// CHECK: declare i32 @_Z1cv() nounwind readnone
+// CHECK: declare i32 @_Z1pv() nounwind readonly
+// CHECK-NOT: declare i32 @_Z1tv() nounwind
diff --git a/clang/test/CodeGenCXX/2009-06-16-DebugInfoCrash.cpp b/clang/test/CodeGenCXX/2009-06-16-DebugInfoCrash.cpp
new file mode 100644
index 0000000..500520b
--- /dev/null
+++ b/clang/test/CodeGenCXX/2009-06-16-DebugInfoCrash.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null -g
+// This crashes if we try to emit debug info for TEMPLATE_DECL members.
+template <class T> class K2PtrVectorBase {};
+template <class T> class K2Vector {};
+template <class U > class K2Vector<U*> : public K2PtrVectorBase<U*> {};
+class ScriptInfoManager {
+ void PostRegister() ;
+ template <class SI> short ReplaceExistingElement(K2Vector<SI*>& v);
+};
+void ScriptInfoManager::PostRegister() {}
diff --git a/clang/test/CodeGenCXX/2009-07-16-Using.cpp b/clang/test/CodeGenCXX/2009-07-16-Using.cpp
new file mode 100644
index 0000000..a692d4d
--- /dev/null
+++ b/clang/test/CodeGenCXX/2009-07-16-Using.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+namespace A {
+ typedef int B;
+}
+struct B {
+};
+using ::A::B;
diff --git a/clang/test/CodeGenCXX/2009-08-05-ZeroInitWidth.cpp b/clang/test/CodeGenCXX/2009-08-05-ZeroInitWidth.cpp
new file mode 100644
index 0000000..4404d4a
--- /dev/null
+++ b/clang/test/CodeGenCXX/2009-08-05-ZeroInitWidth.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+// rdar://7114564
+struct A {
+ unsigned long long : (sizeof(unsigned long long) * 8) - 16;
+};
+struct B {
+ A a;
+};
+struct B b = {
+ {}
+};
diff --git a/clang/test/CodeGenCXX/2009-08-11-VectorRetTy.cpp b/clang/test/CodeGenCXX/2009-08-11-VectorRetTy.cpp
new file mode 100644
index 0000000..21b88c9
--- /dev/null
+++ b/clang/test/CodeGenCXX/2009-08-11-VectorRetTy.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -emit-llvm -o /dev/null
+// <rdar://problem/7096460>
+typedef void (*Func) ();
+typedef long long m64 __attribute__((__vector_size__(8), __may_alias__));
+static inline m64 __attribute__((__always_inline__, __nodebug__)) _mm_set1_pi16() {}
+template <class MM>
+static void Bork() {
+ const m64 mmx_0x00ff = _mm_set1_pi16();
+}
+struct A {};
+Func arr[] = {
+ Bork<A>
+};
diff --git a/clang/test/CodeGenCXX/2009-09-09-packed-layout.cpp b/clang/test/CodeGenCXX/2009-09-09-packed-layout.cpp
new file mode 100644
index 0000000..9de2f61
--- /dev/null
+++ b/clang/test/CodeGenCXX/2009-09-09-packed-layout.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-apple-darwin11 %s -o /dev/null
+class X {
+ public:
+ virtual ~X();
+ short y;
+};
+#pragma pack(push, 1)
+class Z : public X {
+ public: enum { foo = ('x') };
+ virtual int y() const;
+};
+#pragma pack(pop)
+class Y : public X {
+public: enum { foo = ('y'), bar = 0 };
+};
+X x;
+Y y;
+Z z;
diff --git a/clang/test/CodeGenCXX/2009-10-27-crash.cpp b/clang/test/CodeGenCXX/2009-10-27-crash.cpp
new file mode 100644
index 0000000..482bb75
--- /dev/null
+++ b/clang/test/CodeGenCXX/2009-10-27-crash.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+// Radar 7328944
+
+typedef struct
+{
+ unsigned short a : 1;
+ unsigned short b : 2;
+ unsigned short c : 1;
+ unsigned short d : 1;
+ unsigned short e : 1;
+ unsigned short f : 1;
+ unsigned short g : 2;
+ unsigned short : 7;
+ union
+ {
+ struct
+ {
+ unsigned char h : 1;
+ unsigned char i : 1;
+ unsigned char j : 1;
+ unsigned char : 5;
+ };
+ struct
+ {
+ unsigned char k : 3;
+ unsigned char : 5;
+ };
+ };
+ unsigned char : 8;
+} tt;
+
+typedef struct
+{
+ unsigned char s;
+ tt t;
+ unsigned int u;
+} ttt;
+
+ttt X = {
+ 4,
+ { 0 },
+ 55,
+};
diff --git a/clang/test/CodeGenCXX/2009-12-23-MissingSext.cpp b/clang/test/CodeGenCXX/2009-12-23-MissingSext.cpp
new file mode 100644
index 0000000..e6ff7b3
--- /dev/null
+++ b/clang/test/CodeGenCXX/2009-12-23-MissingSext.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// The store of p.y into the temporary was not
+// getting extended to 32 bits, so uninitialized
+// bits of the temporary were used. 7366161.
+struct foo {
+ char x:8;
+ signed int y:24;
+};
+int bar(struct foo p, int x) {
+// CHECK: bar
+// CHECK: and {{.*}} 16777215
+// CHECK: and {{.*}} 16777215
+ x = (p.y > x ? x : p.y);
+ return x;
+// CHECK: ret
+}
diff --git a/clang/test/CodeGenCXX/2010-03-09-AnonAggregate.cpp b/clang/test/CodeGenCXX/2010-03-09-AnonAggregate.cpp
new file mode 100644
index 0000000..99883d8
--- /dev/null
+++ b/clang/test/CodeGenCXX/2010-03-09-AnonAggregate.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -g -S -o %t %s
+// PR: 6554
+// More then one anonymous aggregates on one line creates chaos when MDNode uniquness is
+// combined with RAUW operation.
+// This test case causes crashes if malloc is configured to trip buffer overruns.
+class MO {
+
+ union { struct { union { int BA; } Val; int Offset; } OffsetedInfo; } Contents;
+
+};
+
+class MO m;
diff --git a/clang/test/CodeGenCXX/2010-05-10-Var-DbgInfo.cpp b/clang/test/CodeGenCXX/2010-05-10-Var-DbgInfo.cpp
new file mode 100644
index 0000000..7c05535
--- /dev/null
+++ b/clang/test/CodeGenCXX/2010-05-10-Var-DbgInfo.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -emit-llvm -O0 -g %s -o /dev/null
+// PR 7104
+
+struct A {
+ int Ai;
+};
+
+struct B : public A {};
+struct C : public B {};
+
+const char * f(int C::*){ return ""; }
+int f(int B::*) { return 1; }
+
+struct D : public C {};
+
+const char * g(int B::*){ return ""; }
+int g(int D::*) { return 1; }
+
+void test()
+{
+ int i = f(&A::Ai);
+
+ const char * str = g(&A::Ai);
+}
+
+// conversion of B::* to C::* is better than conversion of A::* to C::*
+typedef void (A::*pmfa)();
+typedef void (B::*pmfb)();
+typedef void (C::*pmfc)();
+
+struct X {
+ operator pmfa();
+ operator pmfb();
+};
+
+
+void g(pmfc);
+
+void test2(X x)
+{
+ g(x);
+}
diff --git a/clang/test/CodeGenCXX/2010-05-11-alwaysinlineinstantiation.cpp b/clang/test/CodeGenCXX/2010-05-11-alwaysinlineinstantiation.cpp
new file mode 100644
index 0000000..fe0740b
--- /dev/null
+++ b/clang/test/CodeGenCXX/2010-05-11-alwaysinlineinstantiation.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-NOT: ZN12basic_stringIcEC1Ev
+// CHECK: ZN12basic_stringIcED1Ev
+// CHECK: ZN12basic_stringIcED1Ev
+template<class charT>
+class basic_string
+{
+public:
+ basic_string();
+ ~basic_string();
+};
+
+template <class charT>
+__attribute__ ((__visibility__("hidden"), __always_inline__)) inline
+basic_string<charT>::basic_string()
+{
+}
+
+template <class charT>
+inline
+basic_string<charT>::~basic_string()
+{
+}
+
+typedef basic_string<char> string;
+
+extern template class basic_string<char>;
+
+int main()
+{
+ string s;
+}
diff --git a/clang/test/CodeGenCXX/2010-05-12-PtrToMember-Dbg.cpp b/clang/test/CodeGenCXX/2010-05-12-PtrToMember-Dbg.cpp
new file mode 100644
index 0000000..048811f
--- /dev/null
+++ b/clang/test/CodeGenCXX/2010-05-12-PtrToMember-Dbg.cpp
@@ -0,0 +1,17 @@
+//RUN: %clang_cc1 -emit-llvm -g -o - %s | FileCheck %s
+//CHECK: DW_TAG_auto_variable
+class Foo
+{
+ public:
+ int x;
+ int y;
+ Foo (int i, int j) { x = i; y = j; }
+};
+
+
+Foo foo(10, 11);
+
+int main() {
+ int Foo::* pmi = &Foo::y;
+ return foo.*pmi;
+}
diff --git a/clang/test/CodeGenCXX/2010-06-21-LocalVarDbg.cpp b/clang/test/CodeGenCXX/2010-06-21-LocalVarDbg.cpp
new file mode 100644
index 0000000..2542378
--- /dev/null
+++ b/clang/test/CodeGenCXX/2010-06-21-LocalVarDbg.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -g -emit-llvm %s -o - | FileCheck %s
+// Do not use function name to create named metadata used to hold
+// local variable info. For example. llvm.dbg.lv.~A is an invalid name.
+
+// CHECK-NOT: llvm.dbg.lv.~A
+class A {
+public:
+ ~A() { int i = 0; i++; }
+};
+
+int foo(int i) {
+ A a;
+ return 0;
+}
diff --git a/clang/test/CodeGenCXX/2010-06-22-BitfieldInit.cpp b/clang/test/CodeGenCXX/2010-06-22-BitfieldInit.cpp
new file mode 100644
index 0000000..f82e527
--- /dev/null
+++ b/clang/test/CodeGenCXX/2010-06-22-BitfieldInit.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm -g %s -o -
+struct TEST2
+{
+ int subid:32;
+ int :0;
+};
+
+typedef struct _TEST3
+{
+ TEST2 foo;
+ TEST2 foo2;
+} TEST3;
+
+TEST3 test =
+ {
+ {0},
+ {0}
+ };
+
+int main() { return 0; }
diff --git a/clang/test/CodeGenCXX/2010-06-22-ZeroBitfield.cpp b/clang/test/CodeGenCXX/2010-06-22-ZeroBitfield.cpp
new file mode 100644
index 0000000..c2f37f7
--- /dev/null
+++ b/clang/test/CodeGenCXX/2010-06-22-ZeroBitfield.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm -g %s -o -
+struct s8_0 { unsigned : 0; };
+struct s8_1 { double x; };
+struct s8 { s8_0 a; s8_1 b; };
+s8 f8() { return s8(); }
diff --git a/clang/test/CodeGenCXX/2010-07-23-DeclLoc.cpp b/clang/test/CodeGenCXX/2010-07-23-DeclLoc.cpp
new file mode 100644
index 0000000..7405448
--- /dev/null
+++ b/clang/test/CodeGenCXX/2010-07-23-DeclLoc.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck %s
+// Require the template function declaration refer to the correct filename.
+// First, locate the function decl in metadata, and pluck out the file handle:
+// CHECK: {{extract_dwarf_data_from_header.*extract_dwarf_data_from_header.*extract_dwarf_data_from_header.*[^ ]+", metadata !}}[[filehandle:[0-9]+]],
+// Second: Require that filehandle refer to the correct filename:
+// CHECK: {{^!}}[[filehandle]] = metadata {{![{].*}} metadata !"decl_should_be_here.hpp",
+typedef long unsigned int __darwin_size_t;
+typedef __darwin_size_t size_t;
+typedef unsigned char uint8_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+namespace std {
+ template<typename _Tp> class auto_ptr {
+ _Tp* _M_ptr;
+ public:
+ typedef _Tp element_type;
+ auto_ptr(element_type* __p = 0) throw() : _M_ptr(__p) { }
+ element_type& operator*() const throw() { }
+ };
+}
+class Pointer32 {
+public:
+ typedef uint32_t ptr_t;
+ typedef uint32_t size_t;
+};
+class Pointer64 {
+public:
+ typedef uint64_t ptr_t;
+ typedef uint64_t size_t;
+};
+class BigEndian {};
+class LittleEndian {};
+template <typename _SIZE, typename _ENDIANNESS> class SizeAndEndianness {
+public:
+ typedef _SIZE SIZE;
+};
+typedef SizeAndEndianness<Pointer32, LittleEndian> ISA32Little;
+typedef SizeAndEndianness<Pointer32, BigEndian> ISA32Big;
+typedef SizeAndEndianness<Pointer64, LittleEndian> ISA64Little;
+typedef SizeAndEndianness<Pointer64, BigEndian> ISA64Big;
+template <typename SIZE> class TRange {
+protected:
+ typename SIZE::ptr_t _location;
+ typename SIZE::size_t _length;
+ TRange(typename SIZE::ptr_t location, typename SIZE::size_t length) : _location(location), _length(length) { }
+};
+template <typename SIZE, typename T> class TRangeValue : public TRange<SIZE> {
+ T _value;
+public:
+ TRangeValue(typename SIZE::ptr_t location, typename SIZE::size_t length, T value) : TRange<SIZE>(location, length), _value(value) {};
+};
+template <typename SIZE> class TAddressRelocator {};
+class CSCppSymbolOwner{};
+class CSCppSymbolOwnerData{};
+template <typename SIZE> class TRawSymbolOwnerData
+{
+ TRangeValue< SIZE, uint8_t* > _TEXT_text_section;
+ const char* _dsym_path;
+ uint32_t _dylib_current_version;
+ uint32_t _dylib_compatibility_version;
+public:
+ TRawSymbolOwnerData() :
+ _TEXT_text_section(0, 0, __null), _dsym_path(__null), _dylib_current_version(0), _dylib_compatibility_version(0) {}
+};
+template <typename SIZE_AND_ENDIANNESS> class TExtendedMachOHeader {};
+# 16 "decl_should_be_here.hpp"
+template <typename SIZE_AND_ENDIANNESS> void extract_dwarf_data_from_header(TExtendedMachOHeader<SIZE_AND_ENDIANNESS>& header,
+ TRawSymbolOwnerData<typename SIZE_AND_ENDIANNESS::SIZE>& symbol_owner_data,
+ TAddressRelocator<typename SIZE_AND_ENDIANNESS::SIZE>* address_relocator) {}
+struct CSCppSymbolOwnerHashFunctor {
+ size_t operator()(const CSCppSymbolOwner& symbol_owner) const {
+# 97 "wrong_place_for_decl.cpp"
+ }
+};
+template <typename SIZE_AND_ENDIANNESS> CSCppSymbolOwnerData* create_symbol_owner_data_arch_specific(CSCppSymbolOwner* symbol_owner, const char* dsym_path) {
+ typedef typename SIZE_AND_ENDIANNESS::SIZE SIZE;
+ std::auto_ptr< TRawSymbolOwnerData<SIZE> > data(new TRawSymbolOwnerData<SIZE>());
+ std::auto_ptr< TExtendedMachOHeader<SIZE_AND_ENDIANNESS> > header;
+ extract_dwarf_data_from_header(*header, *data, (TAddressRelocator<typename SIZE_AND_ENDIANNESS::SIZE>*)__null);
+}
+CSCppSymbolOwnerData* create_symbol_owner_data2(CSCppSymbolOwner* symbol_owner, const char* dsym_path) {
+ create_symbol_owner_data_arch_specific< ISA32Little >(symbol_owner, dsym_path);
+ create_symbol_owner_data_arch_specific< ISA32Big >(symbol_owner, dsym_path);
+ create_symbol_owner_data_arch_specific< ISA64Little >(symbol_owner, dsym_path);
+ create_symbol_owner_data_arch_specific< ISA64Big >(symbol_owner, dsym_path);
+}
diff --git a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
new file mode 100644
index 0000000..a853a57
--- /dev/null
+++ b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s
+
+struct A {
+ A(const char *);
+};
+
+// CHECK: @arr = global [3 x %struct.S] zeroinitializer
+// CHECK: @.str = {{.*}}constant [6 x i8] c"hello\00"
+// CHECK: @.str1 = {{.*}}constant [6 x i8] c"world\00"
+// CHECK: @.str2 = {{.*}}constant [8 x i8] c"goodbye\00"
+
+struct S {
+ int n;
+ A s;
+} arr[] = {
+ { 0, "hello" },
+ { 1, "world" },
+ { 2, "goodbye" }
+};
+
+// CHECK: store i32 0, i32* getelementptr inbounds ([3 x %struct.S]* @arr, i64 0, i64 0, i32 0)
+// CHECK: call void @_ZN1AC1EPKc(%struct.A* getelementptr inbounds ([3 x %struct.S]* @arr, i64 0, i64 0, i32 1), i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0))
+// CHECK: store i32 1, i32* getelementptr inbounds ([3 x %struct.S]* @arr, i64 0, i64 1, i32 0)
+// CHECK: call void @_ZN1AC1EPKc(%struct.A* getelementptr inbounds ([3 x %struct.S]* @arr, i64 0, i64 1, i32 1), i8* getelementptr inbounds ([6 x i8]* @.str1, i32 0, i32 0))
+// CHECK: store i32 2, i32* getelementptr inbounds ([3 x %struct.S]* @arr, i64 0, i64 2, i32 0)
+// CHECK: call void @_ZN1AC1EPKc(%struct.A* getelementptr inbounds ([3 x %struct.S]* @arr, i64 0, i64 2, i32 1), i8* getelementptr inbounds ([8 x i8]* @.str2, i32 0, i32 0))
diff --git a/clang/test/CodeGenCXX/2012-02-06-VecInitialization.cpp b/clang/test/CodeGenCXX/2012-02-06-VecInitialization.cpp
new file mode 100644
index 0000000..720420e
--- /dev/null
+++ b/clang/test/CodeGenCXX/2012-02-06-VecInitialization.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple i386-apple-darwin %s | FileCheck %s
+// PR11930
+
+typedef char vec_t __attribute__ ((__ext_vector_type__ (8)));
+void h() {
+// CHECK: store <8 x i8>
+ vec_t v(0);
+}
diff --git a/clang/test/CodeGenCXX/2012-03-16-StoreAlign.cpp b/clang/test/CodeGenCXX/2012-03-16-StoreAlign.cpp
new file mode 100644
index 0000000..a6375f8
--- /dev/null
+++ b/clang/test/CodeGenCXX/2012-03-16-StoreAlign.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin %s | FileCheck %s
+// <rdar://problem/11043589>
+
+struct Length {
+ Length(double v) {
+ m_floatValue = static_cast<float>(v);
+ }
+
+ bool operator==(const Length& o) const {
+ return getFloatValue() == o.getFloatValue();
+ }
+ bool operator!=(const Length& o) const { return !(*this == o); }
+private:
+ float getFloatValue() const {
+ return m_floatValue;
+ }
+ float m_floatValue;
+};
+
+
+struct Foo {
+ static Length inchLength(double inch);
+ static bool getPageSizeFromName(const Length &A) {
+ static const Length legalWidth = inchLength(8.5);
+ if (A != legalWidth) return true;
+ return false;
+ }
+};
+
+// CHECK: @_ZZN3Foo19getPageSizeFromNameERK6LengthE10legalWidth = linkonce_odr global %struct.Length zeroinitializer, align 4
+// CHECK: store float %{{.*}}, float* getelementptr inbounds (%struct.Length* @_ZZN3Foo19getPageSizeFromNameERK6LengthE10legalWidth, i32 0, i32 0), align 1
+
+bool bar(Length &b) {
+ Foo f;
+ return f.getPageSizeFromName(b);
+}
diff --git a/clang/test/CodeGenCXX/DynArrayInit.cpp b/clang/test/CodeGenCXX/DynArrayInit.cpp
new file mode 100644
index 0000000..4b4c2ec
--- /dev/null
+++ b/clang/test/CodeGenCXX/DynArrayInit.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -O3 -emit-llvm -o - %s | FileCheck %s
+// PR7490
+
+// CHECK: define signext i8 @_Z2f0v
+// CHECK: ret i8 0
+// CHECK: }
+inline void* operator new[](unsigned long, void* __p) { return __p; }
+static void f0_a(char *a) {
+ new (a) char[4]();
+}
+char f0() {
+ char a[4];
+ f0_a(a);
+ return a[0] + a[1] + a[2] + a[3];
+}
diff --git a/clang/test/CodeGenCXX/PR4827-cast.cpp b/clang/test/CodeGenCXX/PR4827-cast.cpp
new file mode 100644
index 0000000..34a840c
--- /dev/null
+++ b/clang/test/CodeGenCXX/PR4827-cast.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+struct A;
+struct B;
+extern A *f();
+void a() { (B *) f(); }
diff --git a/clang/test/CodeGenCXX/PR4983-constructor-conversion.cpp b/clang/test/CodeGenCXX/PR4983-constructor-conversion.cpp
new file mode 100644
index 0000000..797a1ba
--- /dev/null
+++ b/clang/test/CodeGenCXX/PR4983-constructor-conversion.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+
+struct A {
+ A(const char *s){}
+};
+
+struct B {
+ A a;
+
+ B() : a("test") { }
+};
+
+void f() {
+ A a("test");
+}
+
diff --git a/clang/test/CodeGenCXX/PR5050-constructor-conversion.cpp b/clang/test/CodeGenCXX/PR5050-constructor-conversion.cpp
new file mode 100644
index 0000000..c50dafb
--- /dev/null
+++ b/clang/test/CodeGenCXX/PR5050-constructor-conversion.cpp
@@ -0,0 +1,19 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+struct A { A(const A&, int i1 = 1); };
+
+struct B : A { };
+
+A f(const B &b) {
+ return b;
+}
+
+// CHECK-LP64: callq __ZN1AC1ERKS_i
+
+// CHECK-LP32: calll L__ZN1AC1ERKS_i
+
+
diff --git a/clang/test/CodeGenCXX/PR5093-static-member-function.cpp b/clang/test/CodeGenCXX/PR5093-static-member-function.cpp
new file mode 100644
index 0000000..ceab852
--- /dev/null
+++ b/clang/test/CodeGenCXX/PR5093-static-member-function.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+struct a {
+ static void f();
+};
+
+void g(a *a) {
+ // CHECK: call void @_ZN1a1fEv()
+ a->f();
+}
diff --git a/clang/test/CodeGenCXX/PR5834-constructor-conversion.cpp b/clang/test/CodeGenCXX/PR5834-constructor-conversion.cpp
new file mode 100644
index 0000000..044d8e5
--- /dev/null
+++ b/clang/test/CodeGenCXX/PR5834-constructor-conversion.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+
+// PR5834
+struct ASTMultiMover {};
+struct ASTMultiPtr {
+ ASTMultiPtr();
+ ASTMultiPtr(ASTMultiPtr&);
+ ASTMultiPtr(ASTMultiMover mover);
+ operator ASTMultiMover();
+};
+void f1() {
+ extern void f0(ASTMultiPtr);
+ f0(ASTMultiPtr());
+}
diff --git a/clang/test/CodeGenCXX/PR5863-unreachable-block.cpp b/clang/test/CodeGenCXX/PR5863-unreachable-block.cpp
new file mode 100644
index 0000000..3f32d75
--- /dev/null
+++ b/clang/test/CodeGenCXX/PR5863-unreachable-block.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -emit-llvm-only %s
+
+// PR5863
+class E { };
+
+void P1() {
+ try {
+ int a=0, b=0;
+ if (a > b) // simply filling in 0 or 1 doesn't trigger the assertion
+ throw E(); // commenting out 'if' or 'throw' 'fixes' the assertion failure
+ try { } catch (...) { } // empty try/catch block needed for failure
+ } catch (...) { } // this try/catch block needed for failure
+}
diff --git a/clang/test/CodeGenCXX/PR6474.cpp b/clang/test/CodeGenCXX/PR6474.cpp
new file mode 100644
index 0000000..0b155ce
--- /dev/null
+++ b/clang/test/CodeGenCXX/PR6474.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -emit-llvm-only
+
+namespace test0 {
+template <typename T> struct X {
+ virtual void foo();
+ virtual void bar();
+ virtual void baz();
+};
+
+template <typename T> void X<T>::foo() {}
+template <typename T> void X<T>::bar() {}
+template <typename T> void X<T>::baz() {}
+
+template <> void X<char>::foo() {}
+template <> void X<char>::bar() {}
+}
+
+namespace test1 {
+template <typename T> struct X {
+ virtual void foo();
+ virtual void bar();
+ virtual void baz();
+};
+
+template <typename T> void X<T>::foo() {}
+template <typename T> void X<T>::bar() {}
+template <typename T> void X<T>::baz() {}
+
+template <> void X<char>::bar() {}
+template <> void X<char>::foo() {}
+}
diff --git a/clang/test/CodeGenCXX/__null.cpp b/clang/test/CodeGenCXX/__null.cpp
new file mode 100644
index 0000000..8a17797
--- /dev/null
+++ b/clang/test/CodeGenCXX/__null.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+
+int* a = __null;
+int b = __null;
+
+void f() {
+ int* c = __null;
+ int d = __null;
+}
diff --git a/clang/test/CodeGenCXX/abstract-class-ctors-dtors.cpp b/clang/test/CodeGenCXX/abstract-class-ctors-dtors.cpp
new file mode 100644
index 0000000..012c223
--- /dev/null
+++ b/clang/test/CodeGenCXX/abstract-class-ctors-dtors.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// Check that we dont emit the complete constructor/destructor for this class.
+struct A {
+ virtual void f() = 0;
+ A();
+ ~A();
+};
+
+// CHECK-NOT: define void @_ZN1AC1Ev
+// CHECK: define void @_ZN1AC2Ev
+// CHECK: define void @_ZN1AD1Ev
+// CHECK: define void @_ZN1AD2Ev
+A::A() { }
+
+A::~A() { }
diff --git a/clang/test/CodeGenCXX/address-of-fntemplate.cpp b/clang/test/CodeGenCXX/address-of-fntemplate.cpp
new file mode 100644
index 0000000..162c6e5
--- /dev/null
+++ b/clang/test/CodeGenCXX/address-of-fntemplate.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+template <typename T> void f(T) {}
+template <typename T> void f() { }
+
+void test() {
+ // CHECK: @_Z1fIiEvT_
+ void (*p)(int) = &f;
+
+ // CHECK: @_Z1fIiEvv
+ void (*p2)() = f<int>;
+}
+// CHECK: define linkonce_odr void @_Z1fIiEvT_
+// CHECK: define linkonce_odr void @_Z1fIiEvv
+
+namespace PR6973 {
+ template<typename T>
+ struct X {
+ void f(const T&);
+ };
+
+ template<typename T>
+ int g();
+
+ void h(X<int (*)()> xf) {
+ xf.f(&g<int>);
+ }
+}
diff --git a/clang/test/CodeGenCXX/alloca-align.cpp b/clang/test/CodeGenCXX/alloca-align.cpp
new file mode 100644
index 0000000..99d6ab5
--- /dev/null
+++ b/clang/test/CodeGenCXX/alloca-align.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+struct s0 {
+ int Start, End;
+ unsigned Alignment;
+ int TheStores __attribute__((aligned(16)));
+};
+
+// CHECK: define void @f0
+// CHECK: alloca %struct.s0, align 16
+extern "C" void f0() {
+ (void) s0();
+}
+
+// CHECK: define void @f1
+// CHECK: alloca %struct.s0, align 16
+extern "C" void f1() {
+ (void) (struct s0) { 0, 0, 0, 0 };
+}
+
+// CHECK: define i32 @f2
+// CHECK: alloca %struct.s1, align 2
+struct s1 { short x; short y; };
+extern "C" struct s1 f2(int a, struct s1 *x, struct s1 *y) {
+ if (a)
+ return *x;
+ return *y;
+}
diff --git a/clang/test/CodeGenCXX/anonymous-namespaces.cpp b/clang/test/CodeGenCXX/anonymous-namespaces.cpp
new file mode 100644
index 0000000..32e17a3
--- /dev/null
+++ b/clang/test/CodeGenCXX/anonymous-namespaces.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -emit-llvm %s -o - > %t
+// RUN: FileCheck %s -check-prefix=1 < %t
+// RUN: FileCheck %s -check-prefix=2 < %t
+
+int f();
+
+namespace {
+ // CHECK-1: @_ZN12_GLOBAL__N_11bE = internal global i32 0
+ // CHECK-1: @_ZN12_GLOBAL__N_1L1cE = internal global i32 0
+ // CHECK-1: @_ZN12_GLOBAL__N_11D1dE = internal global i32 0
+ // CHECK-1: @_ZN12_GLOBAL__N_11aE = internal global i32 0
+ int a = 0;
+
+ int b = f();
+
+ static int c = f();
+
+ class D {
+ static int d;
+ };
+
+ int D::d = f();
+
+ // Check for generation of a VTT with internal linkage
+ // CHECK-1: @_ZTSN12_GLOBAL__N_11X1EE = internal constant
+ struct X {
+ struct EBase { };
+ struct E : public virtual EBase { virtual ~E() {} };
+ };
+
+ // CHECK-1: define internal i32 @_ZN12_GLOBAL__N_13fooEv()
+ int foo() {
+ return 32;
+ }
+
+ // CHECK-1: define internal i32 @_ZN12_GLOBAL__N_11A3fooEv()
+ namespace A {
+ int foo() {
+ return 45;
+ }
+ }
+}
+
+int concrete() {
+ return a + foo() + A::foo();
+}
+
+void test_XE() { throw X::E(); }
+
+// Miscompile on llvmc plugins.
+namespace test2 {
+ struct A {
+ template <class T> struct B {
+ static void foo() {}
+ };
+ };
+ namespace {
+ struct C;
+ }
+
+ // CHECK-2: define void @_ZN5test24testEv()
+ // CHECK-2: call void @_ZN5test21A1BINS_12_GLOBAL__N_11CEE3fooEv()
+ void test() {
+ A::B<C>::foo();
+ }
+
+ // CHECK-2: define internal void @_ZN5test21A1BINS_12_GLOBAL__N_11CEE3fooEv()
+}
diff --git a/clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp b/clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp
new file mode 100644
index 0000000..a12ae53
--- /dev/null
+++ b/clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp
@@ -0,0 +1,181 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+
+// rdar://8818236
+namespace rdar8818236 {
+struct S {
+ char c2;
+ union {
+ char c;
+ int i;
+ };
+};
+
+// CHECK: @_ZN11rdar88182363fooE = global i64 4
+char S::*foo = &S::c;
+}
+
+struct A {
+ union {
+ int a;
+ void* b;
+ };
+
+ A() : a(0) { }
+};
+
+A a;
+
+namespace PR7021 {
+ struct X
+ {
+ union { long l; };
+ };
+
+ // CHECK: define void @_ZN6PR70211fENS_1XES0_
+ void f(X x, X z) {
+ X x1;
+
+ // CHECK: store i64 1, i64
+ x1.l = 1;
+
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
+ X x2(x1);
+
+ X x3;
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
+ x3 = x1;
+
+ // CHECK: ret void
+ }
+}
+
+namespace test2 {
+ struct A {
+ struct {
+ union {
+ int b;
+ };
+ };
+
+ A();
+ };
+
+ A::A() : b(10) { }
+ // CHECK: define void @_ZN5test21AC2Ev(
+ // CHECK-NOT: }
+ // CHECK: store i32 10
+ // CHECK: }
+}
+
+namespace PR10512 {
+ struct A {
+ A();
+ A(int);
+ A(long);
+
+ struct {
+ struct {int x;};
+ struct {int y;};
+ };
+ };
+
+ // CHECK: define void @_ZN7PR105121AC2Ev
+ // CHECK: [[THISADDR:%[a-zA-z0-9.]+]] = alloca [[A:%"struct[A-Za-z0-9:.]+"]]
+ // CHECK-NEXT: store [[A]]* [[THIS:%[a-zA-z0-9.]+]], [[A]]** [[THISADDR]]
+ // CHECK-NEXT: [[THIS1:%[a-zA-z0-9.]+]] = load [[A]]** [[THISADDR]]
+ // CHECK-NEXT: ret void
+ A::A() {}
+
+ // CHECK: define void @_ZN7PR105121AC2Ei
+ // CHECK: [[THISADDR:%[a-zA-z0-9.]+]] = alloca [[A:%"struct[A-Za-z0-9:.]+"]]
+ // CHECK-NEXT: [[XADDR:%[a-zA-z0-9.]+]] = alloca i32
+ // CHECK-NEXT: store [[A]]* [[THIS:%[a-zA-z0-9.]+]], [[A]]** [[THISADDR]]
+ // CHECK-NEXT: store i32 [[X:%[a-zA-z0-9.]+]], i32* [[XADDR]]
+ // CHECK-NEXT: [[THIS1:%[a-zA-z0-9.]+]] = load [[A]]** [[THISADDR]]
+ // CHECK-NEXT: {{getelementptr inbounds.*i32 0, i32 0}}
+ // CHECK-NEXT: {{getelementptr inbounds.*i32 0, i32 0}}
+ // CHECK-NEXT: {{getelementptr inbounds.*i32 0, i32 0}}
+ // CHECK-NEXT: [[TMP:%[a-zA-z0-9.]+]] = load i32* [[XADDR]]
+ // CHECK-NEXT: store i32 [[TMP]]
+ // CHECK-NEXT: ret void
+ A::A(int x) : x(x) { }
+
+ // CHECK: define void @_ZN7PR105121AC2El
+ // CHECK: [[THISADDR:%[a-zA-z0-9.]+]] = alloca [[A:%"struct[A-Za-z0-9:.]+"]]
+ // CHECK-NEXT: [[XADDR:%[a-zA-z0-9.]+]] = alloca i64
+ // CHECK-NEXT: store [[A]]* [[THIS:%[a-zA-z0-9.]+]], [[A]]** [[THISADDR]]
+ // CHECK-NEXT: store i64 [[X:%[a-zA-z0-9.]+]], i64* [[XADDR]]
+ // CHECK-NEXT: [[THIS1:%[a-zA-z0-9.]+]] = load [[A]]** [[THISADDR]]
+ // CHECK-NEXT: {{getelementptr inbounds.*i32 0, i32 0}}
+ // CHECK-NEXT: {{getelementptr inbounds.*i32 0, i32 1}}
+ // CHECK-NEXT: {{getelementptr inbounds.*i32 0, i32 0}}
+ // CHECK-NEXT: [[TMP:%[a-zA-z0-9.]+]] = load i64* [[XADDR]]
+ // CHECK-NEXT: [[CONV:%[a-zA-z0-9.]+]] = trunc i64 [[TMP]] to i32
+ // CHECK-NEXT: store i32 [[CONV]]
+ // CHECK-NEXT: ret void
+ A::A(long y) : y(y) { }
+}
+
+namespace test3 {
+ struct A {
+ union {
+ mutable char fibers[100];
+ struct {
+ void (*callback)(void*);
+ void *callback_value;
+ };
+ };
+
+ A();
+ };
+
+ A::A() : callback(0), callback_value(0) {}
+ // CHECK: define void @_ZN5test31AC2Ev(
+ // CHECK: [[THIS:%.*]] = load
+ // CHECK-NEXT: [[UNION:%.*]] = getelementptr inbounds {{.*}} [[THIS]], i32 0, i32 0
+ // CHECK-NEXT: [[STRUCT:%.*]] = bitcast {{.*}}* [[UNION]] to
+ // CHECK-NEXT: [[CALLBACK:%.*]] = getelementptr inbounds {{.*}} [[STRUCT]], i32 0, i32 0
+ // CHECK: store
+ // CHECK-NEXT: [[UNION:%.*]] = getelementptr inbounds {{.*}} [[THIS]], i32 0, i32 0
+ // CHECK-NEXT: [[STRUCT:%.*]] = bitcast {{.*}}* [[UNION]] to
+ // CHECK-NEXT: [[CVALUE:%.*]] = getelementptr inbounds {{.*}} [[STRUCT]], i32 0, i32 1
+ // CHECK-NEXT: store i8* null, i8** [[CVALUE]]
+}
+
+struct S {
+ // CHECK: store i32 42
+ // CHECK: store i32 55
+ S() : x(42), y(55) {}
+ union {
+ struct {
+ int x;
+ union { int y; };
+ };
+ };
+} s;
+
+
+//PR8760
+template <typename T> struct Foo {
+ Foo() : ptr(__nullptr) {}
+ union {
+ T *ptr;
+ };
+};
+Foo<int> f;
+
+namespace PR9683 {
+ struct QueueEntry {
+ union {
+ struct {
+ void* mPtr;
+ union {
+ unsigned mSubmissionTag;
+ };
+ };
+ unsigned mValue;
+ };
+ QueueEntry() {}
+ };
+ QueueEntry QE;
+}
diff --git a/clang/test/CodeGenCXX/apple-kext-guard-variable.cpp b/clang/test/CodeGenCXX/apple-kext-guard-variable.cpp
new file mode 100644
index 0000000..76875a0
--- /dev/null
+++ b/clang/test/CodeGenCXX/apple-kext-guard-variable.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang -target x86_64-apple-darwin10 -S -o %t.s -mkernel -Xclang -verify %s
+
+// rdar://problem/9143356
+
+int foo();
+void test() {
+ static int y = 0;
+ static int x = foo(); // expected-error {{this initialization requires a guard variable, which the kernel does not support}}
+}
diff --git a/clang/test/CodeGenCXX/apple-kext-indirect-call-2.C b/clang/test/CodeGenCXX/apple-kext-indirect-call-2.C
new file mode 100644
index 0000000..7e25200
--- /dev/null
+++ b/clang/test/CodeGenCXX/apple-kext-indirect-call-2.C
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -fno-rtti -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @_ZTV1A = unnamed_addr constant [4 x i8*] [i8* null, i8* null, i8* bitcast (i8* (%struct.A*)* @_ZNK1A3abcEv to i8*), i8* null]
+// CHECK: @_ZTV4Base = unnamed_addr constant [4 x i8*] [i8* null, i8* null, i8* bitcast (i8* (%struct.A*)* @_ZNK4Base3abcEv to i8*), i8* null]
+// CHECK: @_ZTV8Derived2 = unnamed_addr constant [5 x i8*] [i8* null, i8* null, i8* null, i8* bitcast (i8* (%struct.A*)* @_ZNK8Derived23efgEv to i8*), i8* null]
+// CHECK: @_ZTV2D2 = unnamed_addr constant [5 x i8*] [i8* null, i8* null, i8* null, i8* bitcast (i8* (%struct.A*)* @_ZNK2D23abcEv to i8*), i8* null]
+
+struct A {
+ virtual const char* abc(void) const;
+};
+
+const char* A::abc(void) const {return "A"; };
+
+struct B : virtual A {
+ virtual void VF();
+};
+
+void B::VF() {}
+
+void FUNC(B* p) {
+// CHECK: [[T1:%.*]] = load i8* (%struct.A*)** getelementptr inbounds (i8* (%struct.A*)** bitcast ([4 x i8*]* @_ZTV1A to i8* (%struct.A*)**), i64 2)
+// CHECK-NEXT: [[T2:%.*]] = call i8* [[T1]]
+ const char* c = p->A::abc();
+}
+
+
+// Test2
+struct Base { virtual char* abc(void) const; };
+
+char* Base::abc() const { return 0; }
+
+struct Derived : public Base {
+};
+
+void FUNC1(Derived* p) {
+// CHECK: [[U1:%.*]] = load i8* (%struct.A*)** getelementptr inbounds (i8* (%struct.A*)** bitcast ([4 x i8*]* @_ZTV4Base to i8* (%struct.A*)**), i64 2)
+// CHECK-NEXT: [[U2:%.*]] = call i8* [[U1]]
+ char* c = p->Base::abc();
+}
+
+
+// Test3
+struct Base2 { };
+
+struct Derived2 : virtual Base2 {
+ virtual char* efg(void) const;
+};
+
+char* Derived2::efg(void) const { return 0; }
+
+void FUNC2(Derived2* p) {
+// CHECK: [[V1:%.*]] = load i8* (%struct.A*)** getelementptr inbounds (i8* (%struct.A*)** bitcast ([5 x i8*]* @_ZTV8Derived2 to i8* (%struct.A*)**), i64 3)
+// CHECK-NEXT: [[V2:%.*]] = call i8* [[V1]]
+ char* c = p->Derived2::efg();
+}
+
+// Test4
+struct Base3 { };
+
+struct D1 : virtual Base3 {
+};
+
+struct D2 : virtual Base3 {
+ virtual char *abc(void) const;
+};
+
+struct Sub : D1, D2 {
+};
+
+char* D2::abc(void) const { return 0; }
+
+void FUNC3(Sub* p) {
+// CHECK: [[W1:%.*]] = load i8* (%struct.A*)** getelementptr inbounds (i8* (%struct.A*)** bitcast ([5 x i8*]* @_ZTV2D2 to i8* (%struct.A*)**), i64 3)
+// CHECK-NEXT: [[W2:%.*]] = call i8* [[W1]]
+ char* c = p->D2::abc();
+}
+
diff --git a/clang/test/CodeGenCXX/apple-kext-indirect-call.C b/clang/test/CodeGenCXX/apple-kext-indirect-call.C
new file mode 100644
index 0000000..2dbb0b8
--- /dev/null
+++ b/clang/test/CodeGenCXX/apple-kext-indirect-call.C
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -emit-llvm -o - %s | FileCheck %s
+
+struct Base {
+ virtual void abc(void) const;
+};
+
+void Base::abc(void) const {}
+
+void FUNC(Base* p) {
+ p->Base::abc();
+}
+
+// CHECK: getelementptr inbounds (void (%struct.Base*)** bitcast ([3 x i8*]* @_ZTV4Base to void (%struct.Base*)**), i64 2)
+// CHECK-NOT: call void @_ZNK4Base3abcEv
diff --git a/clang/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp b/clang/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp
new file mode 100644
index 0000000..bd275f1
--- /dev/null
+++ b/clang/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -fno-rtti -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @_ZN2B1D0Ev
+// CHECK: [[T1:%.*]] = load void (%struct.B1*)** getelementptr inbounds (void (%struct.B1*)** bitcast ([5 x i8*]* @_ZTV2B1 to void (%struct.B1*)**), i64 2)
+// CHECK-NEXT: call void [[T1]](%struct.B1* [[T2:%.*]])
+// CHECK: define void @_Z6DELETEP2B1
+// CHECK: [[T3:%.*]] = load void (%struct.B1*)** getelementptr inbounds (void (%struct.B1*)** bitcast ([5 x i8*]* @_ZTV2B1 to void (%struct.B1*)**), i64 2)
+// CHECK-NEXT: call void [[T3]](%struct.B1* [[T4:%.*]])
+
+
+struct B1 {
+ virtual ~B1();
+};
+
+B1::~B1() {}
+
+void DELETE(B1 *pb1) {
+ pb1->B1::~B1();
+}
diff --git a/clang/test/CodeGenCXX/apple-kext-linkage.C b/clang/test/CodeGenCXX/apple-kext-linkage.C
new file mode 100644
index 0000000..59d228e
--- /dev/null
+++ b/clang/test/CodeGenCXX/apple-kext-linkage.C
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -emit-llvm -o - %s | FileCheck %s
+
+struct Base {
+ virtual ~Base();
+} ;
+
+struct Derived : Base {
+ void operator delete(void *) { }
+ Derived();
+};
+
+void foo() {
+ Derived d1; // ok
+}
+
+// CHECK: define internal i32 @_Z1fj(
+inline unsigned f(unsigned n) { return n == 0 ? 0 : n + f(n-1); }
+
+unsigned g(unsigned n) { return f(n); }
+
+// rdar://problem/10133200: give explicit instantiations external linkage in kernel mode
+// CHECK: define void @_Z3barIiEvv()
+template <typename T> void bar() {}
+template void bar<int>();
+
+// CHECK: define internal i32 @_Z5identIiET_S0_(
+template <typename X> X ident(X x) { return x; }
+
+int foo(int n) { return ident(n); }
+
+// CHECK: define internal void @_ZN7DerivedD1Ev(
+// CHECK: define internal void @_ZN7DerivedD0Ev(
+// CHECK: define internal void @_ZN7DeriveddlEPv(
diff --git a/clang/test/CodeGenCXX/apple-kext-no-staticinit-section.C b/clang/test/CodeGenCXX/apple-kext-no-staticinit-section.C
new file mode 100644
index 0000000..0401d49
--- /dev/null
+++ b/clang/test/CodeGenCXX/apple-kext-no-staticinit-section.C
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -fno-rtti -emit-llvm -o - %s | FileCheck %s
+// rdar://8825235
+/**
+1) Normally, global object construction code ends up in __StaticInit segment of text section
+ .section __TEXT,__StaticInit,regular,pure_instructions
+ In kext mode, they end up in the __text segment.
+*/
+
+class foo {
+public:
+ foo();
+ virtual ~foo();
+};
+
+foo a;
+foo b;
+foo c;
+foo::~foo() {}
+
+// CHECK-NOT: __TEXT,__StaticInit,regular,pure_instructions
diff --git a/clang/test/CodeGenCXX/apple-kext.cpp b/clang/test/CodeGenCXX/apple-kext.cpp
new file mode 100644
index 0000000..03506a8
--- /dev/null
+++ b/clang/test/CodeGenCXX/apple-kext.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fno-use-cxa-atexit -fapple-kext -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @_ZN5test01aE = global [[A:%.*]] zeroinitializer
+// CHECK: @llvm.global_ctors = appending global {{.*}} { i32 65535, void ()* [[CTOR0:@.*]] }
+// CHECK: @llvm.global_dtors = appending global {{.*}} { i32 65535, void ()* [[DTOR0:@.*]] }
+
+// rdar://11241230
+namespace test0 {
+ struct A { A(); ~A(); };
+ A a;
+}
+// CHECK: define internal void [[CTOR0_:@.*]]()
+// CHECK: call void @_ZN5test01AC1Ev([[A]]* @_ZN5test01aE)
+// CHECK-NEXT: ret void
+
+// CHECK: define internal void [[CTOR0]]()
+// CHECK: call void [[CTOR0_]]()
+// CHECK-NEXT: ret void
+
+// CHECK: define internal void [[DTOR0]]()
+// CHECK: call void @_ZN5test01AD1Ev([[A]]* @_ZN5test01aE)
+// CHECK-NEXT: ret void
diff --git a/clang/test/CodeGenCXX/arm-cc.cpp b/clang/test/CodeGenCXX/arm-cc.cpp
new file mode 100644
index 0000000..6027746
--- /dev/null
+++ b/clang/test/CodeGenCXX/arm-cc.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple=arm-unknown-linux-gnueabi -target-abi aapcs -emit-llvm -o - | FileCheck %s
+
+class SMLoc {
+ const char *Ptr;
+public:
+ SMLoc();
+ SMLoc(const SMLoc &RHS);
+};
+SMLoc foo(void *p);
+void bar(void *x) {
+ foo(x);
+}
+void zed(SMLoc x);
+void baz() {
+ SMLoc a;
+ zed(a);
+}
+
+// CHECK: declare void @_Z3fooPv(%class.SMLoc* sret, i8*)
+// CHECK: declare void @_Z3zed5SMLoc(%class.SMLoc*)
diff --git a/clang/test/CodeGenCXX/arm.cpp b/clang/test/CodeGenCXX/arm.cpp
new file mode 100644
index 0000000..6c60f30
--- /dev/null
+++ b/clang/test/CodeGenCXX/arm.cpp
@@ -0,0 +1,369 @@
+// RUN: %clang_cc1 %s -triple=thumbv7-apple-ios3.0 -fno-use-cxa-atexit -target-abi apcs-gnu -emit-llvm -o - -fexceptions | FileCheck %s
+
+// CHECK: @_ZZN5test74testEvE1x = internal global i32 0, align 4
+// CHECK: @_ZGVZN5test74testEvE1x = internal global i32 0
+// CHECK: @_ZZN5test84testEvE1x = internal global [[TEST8A:.*]] zeroinitializer, align 1
+// CHECK: @_ZGVZN5test84testEvE1x = internal global i32 0
+
+typedef typeof(sizeof(int)) size_t;
+
+class foo {
+public:
+ foo();
+ virtual ~foo();
+};
+
+class bar : public foo {
+public:
+ bar();
+};
+
+// The global dtor needs the right calling conv with -fno-use-cxa-atexit
+// rdar://7817590
+bar baz;
+
+// PR9593
+// Make sure atexit(3) is used for global dtors.
+
+// CHECK: call [[BAR:%.*]]* @_ZN3barC1Ev(
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor_baz)
+
+// CHECK: define internal void @__dtor_baz()
+// CHECK: call [[BAR]]* @_ZN3barD1Ev([[BAR]]* @baz)
+
+// Destructors and constructors must return this.
+namespace test1 {
+ void foo();
+
+ struct A {
+ A(int i) { foo(); }
+ ~A() { foo(); }
+ void bar() { foo(); }
+ };
+
+ // CHECK: define void @_ZN5test14testEv()
+ void test() {
+ // CHECK: [[AV:%.*]] = alloca [[A:%.*]], align 1
+ // CHECK: call [[A]]* @_ZN5test11AC1Ei([[A]]* [[AV]], i32 10)
+ // CHECK: invoke void @_ZN5test11A3barEv([[A]]* [[AV]])
+ // CHECK: call [[A]]* @_ZN5test11AD1Ev([[A]]* [[AV]])
+ // CHECK: ret void
+ A a = 10;
+ a.bar();
+ }
+
+ // CHECK: define linkonce_odr [[A]]* @_ZN5test11AC1Ei([[A]]* %this, i32 %i) unnamed_addr
+ // CHECK: [[THIS:%.*]] = alloca [[A]]*, align 4
+ // CHECK: store [[A]]* {{.*}}, [[A]]** [[THIS]]
+ // CHECK: [[THIS1:%.*]] = load [[A]]** [[THIS]]
+ // CHECK: call [[A]]* @_ZN5test11AC2Ei(
+ // CHECK: ret [[A]]* [[THIS1]]
+
+ // CHECK: define linkonce_odr [[A]]* @_ZN5test11AD1Ev([[A]]* %this) unnamed_addr
+ // CHECK: [[THIS:%.*]] = alloca [[A]]*, align 4
+ // CHECK: store [[A]]* {{.*}}, [[A]]** [[THIS]]
+ // CHECK: [[THIS1:%.*]] = load [[A]]** [[THIS]]
+ // CHECK: call [[A]]* @_ZN5test11AD2Ev(
+ // CHECK: ret [[A]]* [[THIS1]]
+}
+
+// Awkward virtual cases.
+namespace test2 {
+ void foo();
+
+ struct A {
+ int x;
+
+ A(int);
+ virtual ~A() { foo(); }
+ };
+
+ struct B {
+ int y;
+ int z;
+
+ B(int);
+ virtual ~B() { foo(); }
+ };
+
+ struct C : A, virtual B {
+ int q;
+
+ C(int i) : A(i), B(i) { foo(); }
+ ~C() { foo(); }
+ };
+
+ void test() {
+ C c = 10;
+ }
+
+ // Tests at eof
+}
+
+namespace test3 {
+ struct A {
+ int x;
+ ~A();
+ };
+
+ void a() {
+ // CHECK: define void @_ZN5test31aEv()
+ // CHECK: call noalias i8* @_Znam(i32 48)
+ // CHECK: store i32 4
+ // CHECK: store i32 10
+ A *x = new A[10];
+ }
+
+ void b(int n) {
+ // CHECK: define void @_ZN5test31bEi(
+ // CHECK: [[N:%.*]] = load i32*
+ // CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 4)
+ // CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8)
+ // CHECK: [[OR:%.*]] = or i1
+ // CHECK: [[SZ:%.*]] = select i1 [[OR]]
+ // CHECK: call noalias i8* @_Znam(i32 [[SZ]])
+ // CHECK: store i32 4
+ // CHECK: store i32 [[N]]
+ A *x = new A[n];
+ }
+
+ void c() {
+ // CHECK: define void @_ZN5test31cEv()
+ // CHECK: call noalias i8* @_Znam(i32 808)
+ // CHECK: store i32 4
+ // CHECK: store i32 200
+ A (*x)[20] = new A[10][20];
+ }
+
+ void d(int n) {
+ // CHECK: define void @_ZN5test31dEi(
+ // CHECK: [[N:%.*]] = load i32*
+ // CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 80)
+ // CHECK: [[NE:%.*]] = mul i32 [[N]], 20
+ // CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8)
+ // CHECK: [[SZ:%.*]] = select
+ // CHECK: call noalias i8* @_Znam(i32 [[SZ]])
+ // CHECK: store i32 4
+ // CHECK: store i32 [[NE]]
+ A (*x)[20] = new A[n][20];
+ }
+
+ void e(A *x) {
+ // CHECK: define void @_ZN5test31eEPNS_1AE(
+ // CHECK: icmp eq {{.*}}, null
+ // CHECK: getelementptr {{.*}}, i64 -8
+ // CHECK: getelementptr {{.*}}, i64 4
+ // CHECK: bitcast {{.*}} to i32*
+ // CHECK: load
+ // CHECK: invoke {{.*}} @_ZN5test31AD1Ev
+ // CHECK: call void @_ZdaPv
+ delete [] x;
+ }
+
+ void f(A (*x)[20]) {
+ // CHECK: define void @_ZN5test31fEPA20_NS_1AE(
+ // CHECK: icmp eq {{.*}}, null
+ // CHECK: getelementptr {{.*}}, i64 -8
+ // CHECK: getelementptr {{.*}}, i64 4
+ // CHECK: bitcast {{.*}} to i32*
+ // CHECK: load
+ // CHECK: invoke {{.*}} @_ZN5test31AD1Ev
+ // CHECK: call void @_ZdaPv
+ delete [] x;
+ }
+}
+
+namespace test4 {
+ struct A {
+ int x;
+ void operator delete[](void *, size_t sz);
+ };
+
+ void a() {
+ // CHECK: define void @_ZN5test41aEv()
+ // CHECK: call noalias i8* @_Znam(i32 48)
+ // CHECK: store i32 4
+ // CHECK: store i32 10
+ A *x = new A[10];
+ }
+
+ void b(int n) {
+ // CHECK: define void @_ZN5test41bEi(
+ // CHECK: [[N:%.*]] = load i32*
+ // CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 4)
+ // CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8)
+ // CHECK: [[SZ:%.*]] = select
+ // CHECK: call noalias i8* @_Znam(i32 [[SZ]])
+ // CHECK: store i32 4
+ // CHECK: store i32 [[N]]
+ A *x = new A[n];
+ }
+
+ void c() {
+ // CHECK: define void @_ZN5test41cEv()
+ // CHECK: call noalias i8* @_Znam(i32 808)
+ // CHECK: store i32 4
+ // CHECK: store i32 200
+ A (*x)[20] = new A[10][20];
+ }
+
+ void d(int n) {
+ // CHECK: define void @_ZN5test41dEi(
+ // CHECK: [[N:%.*]] = load i32*
+ // CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 80)
+ // CHECK: [[NE:%.*]] = mul i32 [[N]], 20
+ // CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8)
+ // CHECK: [[SZ:%.*]] = select
+ // CHECK: call noalias i8* @_Znam(i32 [[SZ]])
+ // CHECK: store i32 4
+ // CHECK: store i32 [[NE]]
+ A (*x)[20] = new A[n][20];
+ }
+
+ void e(A *x) {
+ // CHECK: define void @_ZN5test41eEPNS_1AE(
+ // CHECK: [[ALLOC:%.*]] = getelementptr inbounds {{.*}}, i64 -8
+ // CHECK: getelementptr inbounds {{.*}}, i64 4
+ // CHECK: bitcast
+ // CHECK: [[T0:%.*]] = load i32*
+ // CHECK: [[T1:%.*]] = mul i32 4, [[T0]]
+ // CHECK: [[T2:%.*]] = add i32 [[T1]], 8
+ // CHECK: call void @_ZN5test41AdaEPvm(i8* [[ALLOC]], i32 [[T2]])
+ delete [] x;
+ }
+
+ void f(A (*x)[20]) {
+ // CHECK: define void @_ZN5test41fEPA20_NS_1AE(
+ // CHECK: [[ALLOC:%.*]] = getelementptr inbounds {{.*}}, i64 -8
+ // CHECK: getelementptr inbounds {{.*}}, i64 4
+ // CHECK: bitcast
+ // CHECK: [[T0:%.*]] = load i32*
+ // CHECK: [[T1:%.*]] = mul i32 4, [[T0]]
+ // CHECK: [[T2:%.*]] = add i32 [[T1]], 8
+ // CHECK: call void @_ZN5test41AdaEPvm(i8* [[ALLOC]], i32 [[T2]])
+ delete [] x;
+ }
+}
+
+// <rdar://problem/8386802>: don't crash
+namespace test5 {
+ struct A {
+ ~A();
+ };
+
+ // CHECK: define void @_ZN5test54testEPNS_1AE
+ void test(A *a) {
+ // CHECK: [[PTR:%.*]] = alloca [[A:%.*]]*, align 4
+ // CHECK-NEXT: store [[A]]* {{.*}}, [[A]]** [[PTR]], align 4
+ // CHECK-NEXT: [[TMP:%.*]] = load [[A]]** [[PTR]], align 4
+ // CHECK-NEXT: call [[A]]* @_ZN5test51AD1Ev([[A]]* [[TMP]])
+ // CHECK-NEXT: ret void
+ a->~A();
+ }
+}
+
+namespace test6 {
+ struct A {
+ virtual ~A();
+ };
+
+ // CHECK: define void @_ZN5test64testEPNS_1AE
+ void test(A *a) {
+ // CHECK: [[AVAR:%.*]] = alloca [[A:%.*]]*, align 4
+ // CHECK-NEXT: store [[A]]* {{.*}}, [[A]]** [[AVAR]], align 4
+ // CHECK-NEXT: [[V:%.*]] = load [[A]]** [[AVAR]], align 4
+ // CHECK-NEXT: [[ISNULL:%.*]] = icmp eq [[A]]* [[V]], null
+ // CHECK-NEXT: br i1 [[ISNULL]]
+ // CHECK: [[T0:%.*]] = bitcast [[A]]* [[V]] to [[A]]* ([[A]]*)***
+ // CHECK-NEXT: [[T1:%.*]] = load [[A]]* ([[A]]*)*** [[T0]]
+ // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[A]]* ([[A]]*)** [[T1]], i64 1
+ // CHECK-NEXT: [[T3:%.*]] = load [[A]]* ([[A]]*)** [[T2]]
+ // CHECK-NEXT: call [[A]]* [[T3]]([[A]]* [[V]])
+ // CHECK-NEXT: br label
+ // CHECK: ret void
+ delete a;
+ }
+}
+
+namespace test7 {
+ int foo();
+
+ // Static and guard tested at top of file
+
+ // CHECK: define void @_ZN5test74testEv()
+ void test() {
+ // CHECK: [[T0:%.*]] = load i32* @_ZGVZN5test74testEvE1x
+ // CHECK-NEXT: [[T1:%.*]] = and i32 [[T0]], 1
+ // CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0
+ // CHECK-NEXT: br i1 [[T2]]
+ // -> fallthrough, end
+ // CHECK: [[T3:%.*]] = call i32 @__cxa_guard_acquire(i32* @_ZGVZN5test74testEvE1x)
+ // CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 0
+ // CHECK-NEXT: br i1 [[T4]]
+ // -> fallthrough, end
+ // CHECK: [[INIT:%.*]] = invoke i32 @_ZN5test73fooEv()
+ // CHECK: store i32 [[INIT]], i32* @_ZZN5test74testEvE1x, align 4
+ // CHECK-NEXT: call void @__cxa_guard_release(i32* @_ZGVZN5test74testEvE1x)
+ // CHECK-NEXT: br label
+ // -> end
+ // end:
+ // CHECK: ret void
+ static int x = foo();
+
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-NEXT: cleanup
+ // CHECK: call void @__cxa_guard_abort(i32* @_ZGVZN5test74testEvE1x)
+ // CHECK: resume { i8*, i32 }
+ }
+}
+
+namespace test8 {
+ struct A {
+ A();
+ ~A();
+ };
+
+ // Static and guard tested at top of file
+
+ // CHECK: define void @_ZN5test84testEv()
+ void test() {
+ // CHECK: [[T0:%.*]] = load i32* @_ZGVZN5test84testEvE1x
+ // CHECK-NEXT: [[T1:%.*]] = and i32 [[T0]], 1
+ // CHECK-NEXT: [[T2:%.*]] = icmp eq i32 [[T1]], 0
+ // CHECK-NEXT: br i1 [[T2]]
+ // -> fallthrough, end
+ // CHECK: [[T3:%.*]] = call i32 @__cxa_guard_acquire(i32* @_ZGVZN5test84testEvE1x)
+ // CHECK-NEXT: [[T4:%.*]] = icmp ne i32 [[T3]], 0
+ // CHECK-NEXT: br i1 [[T4]]
+ // -> fallthrough, end
+ // CHECK: [[INIT:%.*]] = invoke [[TEST8A]]* @_ZN5test81AC1Ev([[TEST8A]]* @_ZZN5test84testEvE1x)
+
+ // FIXME: Here we register a global destructor that
+ // unconditionally calls the destructor. That's what we've always
+ // done for -fno-use-cxa-atexit here, but that's really not
+ // semantically correct at all.
+
+ // CHECK: call void @__cxa_guard_release(i32* @_ZGVZN5test84testEvE1x)
+ // CHECK-NEXT: br label
+ // -> end
+ // end:
+ // CHECK: ret void
+ static A x;
+
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-NEXT: cleanup
+ // CHECK: call void @__cxa_guard_abort(i32* @_ZGVZN5test84testEvE1x)
+ // CHECK: resume { i8*, i32 }
+ }
+}
+
+ // CHECK: define linkonce_odr [[C:%.*]]* @_ZTv0_n12_N5test21CD1Ev(
+ // CHECK: call [[C]]* @_ZN5test21CD1Ev(
+ // CHECK: ret [[C]]* undef
+
+ // CHECK: define linkonce_odr void @_ZTv0_n12_N5test21CD0Ev(
+ // CHECK: call void @_ZN5test21CD0Ev(
+ // CHECK: ret void
+
+// CH_ECK: @_GLOBAL__D_a()
+// CH_ECK: call %class.bar* @_ZN3barD1Ev(%class.bar* @baz)
diff --git a/clang/test/CodeGenCXX/array-construction.cpp b/clang/test/CodeGenCXX/array-construction.cpp
new file mode 100644
index 0000000..7b565a4
--- /dev/null
+++ b/clang/test/CodeGenCXX/array-construction.cpp
@@ -0,0 +1,37 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+extern "C" int printf(...);
+
+static int count;
+static float fcount;
+
+class xpto {
+public:
+ xpto() : i(count++), f(fcount++) {
+ printf("xpto::xpto()\n");
+ }
+ int i;
+ float f;
+
+ ~xpto() {
+ printf("xpto::~xpto()\n");
+ }
+};
+
+int main() {
+ xpto array[2][3][4];
+ for (int h = 0; h < 2; h++)
+ for (int i = 0; i < 3; i++)
+ for (int j = 0; j < 4; j++)
+ printf("array[%d][%d][%d] = {%d, %f}\n",
+ h, i, j, array[h][i][j].i, array[h][i][j].f);
+}
+
+// CHECK-LP64: callq __ZN4xptoC1Ev
+
+// CHECK-LP32: calll L__ZN4xptoC1Ev
+
diff --git a/clang/test/CodeGenCXX/array-operator-delete-call.cpp b/clang/test/CodeGenCXX/array-operator-delete-call.cpp
new file mode 100644
index 0000000..1b23c4d
--- /dev/null
+++ b/clang/test/CodeGenCXX/array-operator-delete-call.cpp
@@ -0,0 +1,64 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+extern "C" int printf(...);
+
+int count;
+
+struct S {
+ S() : iS (++count) { printf("S::S(%d)\n", iS); }
+ ~S() { printf("S::~S(%d)\n", iS); }
+ int iS;
+};
+
+struct V {
+ V() : iV (++count) { printf("V::V(%d)\n", iV); }
+ virtual ~V() { printf("V::~V(%d)\n", iV); }
+ int iV;
+};
+
+struct COST
+{
+ S *cost;
+ V *vcost;
+ unsigned *cost_val;
+
+ ~COST();
+ COST();
+};
+
+
+COST::COST()
+{
+ cost = new S[3];
+ vcost = new V[4];
+ cost_val = new unsigned[10];
+}
+
+COST::~COST()
+{
+ if (cost) {
+ delete [] cost;
+ }
+ if (vcost) {
+ delete [] vcost;
+ }
+ if (cost_val)
+ delete [] cost_val;
+}
+
+COST c1;
+
+int main()
+{
+ COST c3;
+}
+COST c2;
+
+// CHECK-LP64: callq __ZdaPv
+
+// CHECK-LP32: calll L__ZdaPv
+
diff --git a/clang/test/CodeGenCXX/array-pointer-decay.cpp b/clang/test/CodeGenCXX/array-pointer-decay.cpp
new file mode 100644
index 0000000..3fe6b72
--- /dev/null
+++ b/clang/test/CodeGenCXX/array-pointer-decay.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+void f(const char*);
+
+void g() {
+ f("hello");
+}
diff --git a/clang/test/CodeGenCXX/array-value-initialize.cpp b/clang/test/CodeGenCXX/array-value-initialize.cpp
new file mode 100644
index 0000000..27607c1
--- /dev/null
+++ b/clang/test/CodeGenCXX/array-value-initialize.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -emit-llvm -o - %s
+
+// PR5463
+extern "C" int printf(...);
+
+struct S {
+ double filler;
+};
+
+struct Foo {
+ Foo(void) : bar_(), dbar_(), sbar_() {
+ for (int i = 0; i < 5; i++) {
+ printf("bar_[%d] = %d\n", i, bar_[i]);
+ printf("dbar_[%d] = %f\n", i, dbar_[i]);
+ printf("sbar_[%d].filler = %f\n", i, sbar_[i].filler);
+ }
+ }
+
+ int bar_[5];
+ double dbar_[5];
+ S sbar_[5];
+};
+
+int test1(void) {
+ Foo a;
+}
+
+// PR7063
+
+
+struct Unit
+{
+ Unit() {}
+ Unit(const Unit& v) {}
+};
+
+
+struct Stuff
+{
+ Unit leafPos[1];
+};
+
+
+int main()
+{
+
+ Stuff a;
+ Stuff b = a;
+
+ return 0;
+}
diff --git a/clang/test/CodeGenCXX/asm.cpp b/clang/test/CodeGenCXX/asm.cpp
new file mode 100644
index 0000000..3b745a7
--- /dev/null
+++ b/clang/test/CodeGenCXX/asm.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+struct A
+{
+ ~A();
+};
+int foo(A);
+
+void bar(A &a)
+{
+ // CHECK: call void asm
+ asm("" : : "r"(foo(a)) ); // rdar://8540491
+ // CHECK: call void @_ZN1AD1Ev
+}
diff --git a/clang/test/CodeGenCXX/assign-operator.cpp b/clang/test/CodeGenCXX/assign-operator.cpp
new file mode 100644
index 0000000..e19df27
--- /dev/null
+++ b/clang/test/CodeGenCXX/assign-operator.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -verify -o - |FileCheck %s
+
+class x {
+public: int operator=(int);
+};
+void a() {
+ x a;
+ a = 1u;
+}
+
+void f(int i, int j) {
+ // CHECK: load i32
+ // CHECK: load i32
+ // CHECK: add nsw i32
+ // CHECK: store i32
+ // CHECK: store i32 17, i32
+ // CHECK: ret
+ (i += j) = 17;
+}
+
+// Taken from g++.old-deja/g++.jason/net.C
+namespace test1 {
+ template <class T> void fn (T t) { }
+ template <class T> struct A {
+ void (*p)(T);
+ A() { p = fn; }
+ };
+
+ A<int> a;
+}
diff --git a/clang/test/CodeGenCXX/atomic.cpp b/clang/test/CodeGenCXX/atomic.cpp
new file mode 100644
index 0000000..36bb4ef
--- /dev/null
+++ b/clang/test/CodeGenCXX/atomic.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin9 | FileCheck %s
+
+namespace PR11411 {
+ template<typename _Tp> struct Ptr {
+ void f();
+ };
+
+ // CHECK: define linkonce_odr void @_ZN7PR114113PtrIiE1fEv
+ // CHECK-NOT: ret
+ template<typename _Tp> inline void Ptr<_Tp>::f() {
+ int* _refcount;
+ // CHECK: atomicrmw add i32*
+ __sync_fetch_and_add(_refcount, 1);
+ // CHECK-NEXT: ret void
+ }
+ void f(Ptr<int> *a) { a->f(); }
+}
diff --git a/clang/test/CodeGenCXX/atomicinit.cpp b/clang/test/CodeGenCXX/atomicinit.cpp
new file mode 100644
index 0000000..38d012e
--- /dev/null
+++ b/clang/test/CodeGenCXX/atomicinit.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 %s -emit-llvm -O1 -o - -triple=i686-apple-darwin9 | FileCheck %s
+struct A {
+ _Atomic(int) i;
+ A(int j);
+ void v(int j);
+};
+// Storing to atomic values should be atomic
+// CHECK: store atomic i32
+void A::v(int j) { i = j; }
+// Initialising atomic values should not be atomic
+// CHECK-NOT: store atomic
+A::A(int j) : i(j) {}
+
+struct B {
+ int i;
+ B(int x) : i(x) {}
+};
+
+_Atomic(B) b;
+
+// CHECK: define void @_Z11atomic_initR1Ai
+void atomic_init(A& a, int i) {
+ // CHECK-NOT: atomic
+ // CHECK: tail call void @_ZN1BC1Ei
+ __c11_atomic_init(&b, B(i));
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @_Z16atomic_init_boolPU7_Atomicbb
+void atomic_init_bool(_Atomic(bool) *ab, bool b) {
+ // CHECK-NOT: atomic
+ // CHECK: {{zext i1.*to i8}}
+ // CHECK-NEXT: store i8
+ __c11_atomic_init(ab, b);
+ // CHECK-NEXT: ret void
+}
+
+struct AtomicBoolMember {
+ _Atomic(bool) ab;
+ AtomicBoolMember(bool b);
+};
+
+// CHECK: define void @_ZN16AtomicBoolMemberC2Eb
+// CHECK: {{zext i1.*to i8}}
+// CHECK-NEXT: store i8
+// CHECK-NEXT: ret void
+AtomicBoolMember::AtomicBoolMember(bool b) : ab(b) { }
+
diff --git a/clang/test/CodeGenCXX/attr-used.cpp b/clang/test/CodeGenCXX/attr-used.cpp
new file mode 100644
index 0000000..2c82184
--- /dev/null
+++ b/clang/test/CodeGenCXX/attr-used.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+// <rdar://problem/8684363>: clang++ not respecting __attribute__((used)) on destructors
+struct X0 {
+ // CHECK: define linkonce_odr {{.*}} @_ZN2X0C1Ev
+ __attribute__((used)) X0() {}
+ // CHECK: define linkonce_odr {{.*}} @_ZN2X0D1Ev
+ __attribute__((used)) ~X0() {}
+};
diff --git a/clang/test/CodeGenCXX/attr.cpp b/clang/test/CodeGenCXX/attr.cpp
new file mode 100644
index 0000000..9e8740e
--- /dev/null
+++ b/clang/test/CodeGenCXX/attr.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @test2 = alias i32 ()* @_Z5test1v
+
+// CHECK: define i32 @_Z3foov() nounwind align 1024
+int foo() __attribute__((aligned(1024)));
+int foo() { }
+
+class C {
+ virtual void bar1() __attribute__((aligned(1)));
+ virtual void bar2() __attribute__((aligned(2)));
+ virtual void bar3() __attribute__((aligned(1024)));
+} c;
+
+// CHECK: define void @_ZN1C4bar1Ev(%class.C* %this) nounwind align 2
+void C::bar1() { }
+
+// CHECK: define void @_ZN1C4bar2Ev(%class.C* %this) nounwind align 2
+void C::bar2() { }
+
+// CHECK: define void @_ZN1C4bar3Ev(%class.C* %this) nounwind align 1024
+void C::bar3() { }
+
+// PR6635
+// CHECK: define i32 @_Z5test1v()
+int test1() { return 10; }
+// CHECK at top of file
+extern "C" int test2() __attribute__((alias("_Z5test1v")));
diff --git a/clang/test/CodeGenCXX/bitfield-layout.cpp b/clang/test/CodeGenCXX/bitfield-layout.cpp
new file mode 100644
index 0000000..15f33d2
--- /dev/null
+++ b/clang/test/CodeGenCXX/bitfield-layout.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -O3 | FileCheck -check-prefix LP64 %s
+// RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - -O3 | FileCheck -check-prefix LP32 %s
+
+// CHECK-LP64: %union.Test1 = type { i32, [4 x i8] }
+union Test1 {
+ int a;
+ int b: 39;
+} t1;
+
+// CHECK-LP64: %union.Test2 = type { i8 }
+union Test2 {
+ int : 6;
+} t2;
+
+// CHECK-LP64: %union.Test3 = type { [2 x i8] }
+union Test3 {
+ int : 9;
+} t3;
+
+
+#define CHECK(x) if (!(x)) return __LINE__
+
+int f() {
+ struct {
+ int a;
+
+ unsigned long long b : 65;
+
+ int c;
+ } c;
+
+ c.a = 0;
+ c.b = (unsigned long long)-1;
+ c.c = 0;
+
+ CHECK(c.a == 0);
+ CHECK(c.b == (unsigned long long)-1);
+ CHECK(c.c == 0);
+
+// CHECK-LP64: ret i32 0
+// CHECK-LP32: ret i32 0
+ return 0;
+}
diff --git a/clang/test/CodeGenCXX/block-byref-cxx-objc.cpp b/clang/test/CodeGenCXX/block-byref-cxx-objc.cpp
new file mode 100644
index 0000000..30f1f07
--- /dev/null
+++ b/clang/test/CodeGenCXX/block-byref-cxx-objc.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks | FileCheck %s
+// rdar://8594790
+
+struct A {
+ int x;
+ A(const A &);
+ A();
+ ~A();
+};
+
+int main()
+{
+ __block A BYREF_VAR;
+ ^{ BYREF_VAR.x = 1234; };
+ return 0;
+}
+
+// CHECK: define internal void @__Block_byref_object_copy_
+// CHECK: call {{.*}} @_ZN1AC1ERKS_
+// CHECK: define internal void @__Block_byref_object_dispose_
+// CHECK: call {{.*}} @_ZN1AD1Ev
+// CHECK: define internal void @__copy_helper_block_
+// CHECK: call void @_Block_object_assign
+// CHECK: define internal void @__destroy_helper_block_
+// CHECK: call void @_Block_object_dispose
+
+// rdar://problem/11135650
+namespace test1 {
+ struct A { int x; A(); ~A(); };
+
+ void test() {
+ return;
+ __block A a;
+ }
+}
diff --git a/clang/test/CodeGenCXX/block-destruct.cpp b/clang/test/CodeGenCXX/block-destruct.cpp
new file mode 100644
index 0000000..f809ca2
--- /dev/null
+++ b/clang/test/CodeGenCXX/block-destruct.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fblocks -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
+
+struct A { ~A(); };
+
+void f() {
+ __block A a;
+}
+
+// CHECK: call void @_ZN1AD1Ev
diff --git a/clang/test/CodeGenCXX/block-in-ctor-dtor.cpp b/clang/test/CodeGenCXX/block-in-ctor-dtor.cpp
new file mode 100644
index 0000000..e4389a4
--- /dev/null
+++ b/clang/test/CodeGenCXX/block-in-ctor-dtor.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 %s -fblocks -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
+
+typedef void (^dispatch_block_t)(void);
+
+void dispatch_once(dispatch_block_t);
+
+class Zone {
+public:
+ Zone();
+ ~Zone();
+};
+
+Zone::Zone() {
+ dispatch_once(^{});
+ dispatch_once(^{});
+}
+
+Zone::~Zone() {
+ dispatch_once(^{});
+ dispatch_once(^{});
+}
+
+class X : public virtual Zone {
+ X();
+ ~X();
+};
+
+X::X() {
+ dispatch_once(^{});
+ dispatch_once(^{});
+};
+
+X::~X() {
+ dispatch_once(^{});
+ dispatch_once(^{});
+};
+
+
+// CHECK: define internal void @___ZN4ZoneC2Ev_block_invoke_
+// CHECK: define internal void @___ZN4ZoneC2Ev_block_invoke_
+// CHECK: define internal void @___ZN4ZoneD2Ev_block_invoke_
+// CHECK: define internal void @___ZN4ZoneD2Ev_block_invoke_
+// CHECK: define internal void @___ZN1XC1Ev_block_invoke_
+// CHECK: define internal void @___ZN1XC1Ev_block_invoke_
+// CHECK: define internal void @___ZN1XC2Ev_block_invoke_
+// CHECK: define internal void @___ZN1XC2Ev_block_invoke_
+// CHECK: define internal void @___ZN1XD2Ev_block_invoke_
+// CHECK: define internal void @___ZN1XD2Ev_block_invoke_
diff --git a/clang/test/CodeGenCXX/block.cpp b/clang/test/CodeGenCXX/block.cpp
new file mode 100644
index 0000000..619d8b0
--- /dev/null
+++ b/clang/test/CodeGenCXX/block.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks
+// Just test that this doesn't crash the compiler...
+
+void func(void*);
+
+struct Test
+{
+ virtual void use() { func((void*)this); }
+ Test(Test&c) { func((void*)this); }
+ Test() { func((void*)this); }
+};
+
+void useBlock(void (^)(void));
+
+int main (void) {
+ __block Test t;
+ useBlock(^(void) { t.use(); });
+}
+
diff --git a/clang/test/CodeGenCXX/blocks-cxx11.cpp b/clang/test/CodeGenCXX/blocks-cxx11.cpp
new file mode 100644
index 0000000..996db1a
--- /dev/null
+++ b/clang/test/CodeGenCXX/blocks-cxx11.cpp
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 %s -fblocks -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - | FileCheck %s
+
+template <class T> void takeItByValue(T);
+void takeABlock(void (^)());
+
+// rdar://problem/11022704
+namespace test_int {
+ void test() {
+ const int x = 100;
+ takeABlock(^{ takeItByValue(x); });
+ // CHECK: call void @_Z13takeItByValueIiEvT_(i32 100)
+ }
+}
+
+namespace test_int_ref {
+ void test() {
+ const int y = 200;
+ const int &x = y;
+ takeABlock(^{ takeItByValue(x); });
+
+ // TODO: there's no good reason that this isn't foldable.
+ // CHECK: call void @_Z13takeItByValueIiEvT_(i32 {{%.*}})
+ }
+}
+
+namespace test_float {
+ void test() {
+ const float x = 1;
+ takeABlock(^{ takeItByValue(x); });
+ // CHECK: call void @_Z13takeItByValueIfEvT_(float 1.0
+ }
+}
+
+namespace test_float_ref {
+ void test() {
+ const float y = 100;
+ const float &x = y;
+ takeABlock(^{ takeItByValue(x); });
+
+ // TODO: there's no good reason that this isn't foldable.
+ // CHECK: call void @_Z13takeItByValueIfEvT_(float {{%.*}})
+ }
+}
+
+namespace test_complex_int {
+ void test() {
+ constexpr _Complex int x = 500;
+ takeABlock(^{ takeItByValue(x); });
+ // CHECK: store i32 500,
+
+ // CHECK: store i32 500,
+ // CHECK-NEXT: store i32 0,
+ // CHECK-NEXT: [[COERCE:%.*]] = bitcast
+ // CHECK-NEXT: [[CVAL:%.*]] = load i64* [[COERCE]]
+ // CHECK-NEXT: call void @_Z13takeItByValueICiEvT_(i64 [[CVAL]])
+ }
+}
+
+namespace test_complex_int_ref {
+ void test() {
+ const _Complex int y = 100;
+ const _Complex int &x = y;
+ takeABlock(^{ takeItByValue(x); });
+ // CHECK: call void @_Z13takeItByValueICiEvT_(i64
+ }
+}
+
+namespace test_complex_int_ref_mutable {
+ _Complex int y = 100;
+ void test() {
+ const _Complex int &x = y;
+ takeABlock(^{ takeItByValue(x); });
+ // CHECK: [[R:%.*]] = load i32* getelementptr inbounds ({ i32, i32 }* @_ZN28test_complex_int_ref_mutable1yE, i32 0, i32 0)
+ // CHECK-NEXT: [[I:%.*]] = load i32* getelementptr inbounds ({ i32, i32 }* @_ZN28test_complex_int_ref_mutable1yE, i32 0, i32 1)
+ // CHECK-NEXT: [[RSLOT:%.*]] = getelementptr inbounds { i32, i32 }* [[CSLOT:%.*]], i32 0, i32 0
+ // CHECK-NEXT: [[ISLOT:%.*]] = getelementptr inbounds { i32, i32 }* [[CSLOT]], i32 0, i32 1
+ // CHECK-NEXT: store i32 [[R]], i32* [[RSLOT]]
+ // CHECK-NEXT: store i32 [[I]], i32* [[ISLOT]]
+ // CHECK-NEXT: [[COERCE:%.*]] = bitcast { i32, i32 }* [[CSLOT]] to i64*
+ // CHECK-NEXT: [[CVAL:%.*]] = load i64* [[COERCE]],
+ // CHECK-NEXT: call void @_Z13takeItByValueICiEvT_(i64 [[CVAL]])
+ }
+}
+
diff --git a/clang/test/CodeGenCXX/blocks.cpp b/clang/test/CodeGenCXX/blocks.cpp
new file mode 100644
index 0000000..eb54478
--- /dev/null
+++ b/clang/test/CodeGenCXX/blocks.cpp
@@ -0,0 +1,228 @@
+// RUN: %clang_cc1 %s -fblocks -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
+
+namespace test0 {
+ // CHECK: define void @_ZN5test04testEi(
+ // CHECK: define internal void @__test_block_invoke_{{.*}}(
+ // CHECK: define internal void @__block_global_{{.*}}(
+ void test(int x) {
+ ^{ ^{ (void) x; }; };
+ }
+}
+
+extern void (^out)();
+
+namespace test1 {
+ // Capturing const objects doesn't require a local block.
+ // CHECK: define void @_ZN5test15test1Ev()
+ // CHECK: store void ()* bitcast ({{.*}} @__block_literal_global{{.*}} to void ()*), void ()** @out
+ void test1() {
+ const int NumHorsemen = 4;
+ out = ^{ (void) NumHorsemen; };
+ }
+
+ // That applies to structs too...
+ // CHECK: define void @_ZN5test15test2Ev()
+ // CHECK: store void ()* bitcast ({{.*}} @__block_literal_global{{.*}} to void ()*), void ()** @out
+ struct loc { double x, y; };
+ void test2() {
+ const loc target = { 5, 6 };
+ out = ^{ (void) target; };
+ }
+
+ // ...unless they have mutable fields...
+ // CHECK: define void @_ZN5test15test3Ev()
+ // CHECK: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+ // CHECK: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to void ()*
+ // CHECK: store void ()* [[T0]], void ()** @out
+ struct mut { mutable int x; };
+ void test3() {
+ const mut obj = { 5 };
+ out = ^{ (void) obj; };
+ }
+
+ // ...or non-trivial destructors...
+ // CHECK: define void @_ZN5test15test4Ev()
+ // CHECK: [[OBJ:%.*]] = alloca
+ // CHECK: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+ // CHECK: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to void ()*
+ // CHECK: store void ()* [[T0]], void ()** @out
+ struct scope { int x; ~scope(); };
+ void test4() {
+ const scope obj = { 5 };
+ out = ^{ (void) obj; };
+ }
+
+ // ...or non-trivial copy constructors, but it's not clear how to do
+ // that and still have a constant initializer in '03.
+}
+
+namespace test2 {
+ struct A {
+ A();
+ A(const A &);
+ ~A();
+ };
+
+ struct B {
+ B();
+ B(const B &);
+ ~B();
+ };
+
+ // CHECK: define void @_ZN5test24testEv()
+ void test() {
+ __block A a;
+ __block B b;
+ }
+
+ // CHECK: define internal void @__Block_byref_object_copy
+ // CHECK: call void @_ZN5test21AC1ERKS0_(
+
+ // CHECK: define internal void @__Block_byref_object_dispose
+ // CHECK: call void @_ZN5test21AD1Ev(
+
+ // CHECK: define internal void @__Block_byref_object_copy
+ // CHECK: call void @_ZN5test21BC1ERKS0_(
+
+ // CHECK: define internal void @__Block_byref_object_dispose
+ // CHECK: call void @_ZN5test21BD1Ev(
+}
+
+// rdar://problem/9334739
+// Make sure we mark destructors for parameters captured in blocks.
+namespace test3 {
+ struct A {
+ A(const A&);
+ ~A();
+ };
+
+ struct B : A {
+ };
+
+ void test(B b) {
+ extern void consume(void(^)());
+ consume(^{ (void) b; });
+ }
+}
+
+// rdar://problem/9971485
+namespace test4 {
+ struct A {
+ A();
+ ~A();
+ };
+
+ void foo(A a);
+
+ void test() {
+ extern void consume(void(^)());
+ consume(^{ return foo(A()); });
+ }
+ // CHECK: define void @_ZN5test44testEv()
+ // CHECK: define internal void @__test_block_invoke
+ // CHECK: [[TMP:%.*]] = alloca [[A:%.*]], align 1
+ // CHECK-NEXT: bitcast i8*
+ // CHECK-NEXT: call void @_ZN5test41AC1Ev([[A]]* [[TMP]])
+ // CHECK-NEXT: call void @_ZN5test43fooENS_1AE([[A]]* [[TMP]])
+ // CHECK-NEXT: call void @_ZN5test41AD1Ev([[A]]* [[TMP]])
+ // CHECK-NEXT: ret void
+}
+
+namespace test5 {
+ struct A {
+ unsigned afield;
+ A();
+ A(const A&);
+ ~A();
+ void foo() const;
+ };
+
+ void doWithBlock(void(^)());
+
+ void test(bool cond) {
+ A x;
+ void (^b)() = (cond ? ^{ x.foo(); } : (void(^)()) 0);
+ doWithBlock(b);
+ }
+
+ // CHECK: define void @_ZN5test54testEb(
+ // CHECK: [[COND:%.*]] = alloca i8
+ // CHECK-NEXT: [[X:%.*]] = alloca [[A:%.*]], align 4
+ // CHECK-NEXT: [[B:%.*]] = alloca void ()*, align 8
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:.*]], align 8
+ // CHECK-NEXT: [[CLEANUP_ACTIVE:%.*]] = alloca i1
+ // CHECK-NEXT: [[T0:%.*]] = zext i1
+ // CHECK-NEXT: store i8 [[T0]], i8* [[COND]], align 1
+ // CHECK-NEXT: call void @_ZN5test51AC1Ev([[A]]* [[X]])
+ // CHECK-NEXT: [[CLEANUP_ADDR:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+ // CHECK-NEXT: [[T0:%.*]] = load i8* [[COND]], align 1
+ // CHECK-NEXT: [[T1:%.*]] = trunc i8 [[T0]] to i1
+ // CHECK-NEXT: store i1 false, i1* [[CLEANUP_ACTIVE]]
+ // CHECK-NEXT: br i1 [[T1]],
+
+ // CHECK-NOT: br
+ // CHECK: [[CAPTURE:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+ // CHECK-NEXT: call void @_ZN5test51AC1ERKS0_([[A]]* [[CAPTURE]], [[A]]* [[X]])
+ // CHECK-NEXT: store i1 true, i1* [[CLEANUP_ACTIVE]]
+ // CHECK-NEXT: bitcast [[BLOCK_T]]* [[BLOCK]] to void ()*
+ // CHECK-NEXT: br label
+ // CHECK: br label
+ // CHECK: phi
+ // CHECK-NEXT: store
+ // CHECK-NEXT: load
+ // CHECK-NEXT: call void @_ZN5test511doWithBlockEU13block_pointerFvvE(
+ // CHECK-NEXT: [[T0:%.*]] = load i1* [[CLEANUP_ACTIVE]]
+ // CHECK-NEXT: br i1 [[T0]]
+ // CHECK: call void @_ZN5test51AD1Ev([[A]]* [[CLEANUP_ADDR]])
+ // CHECK-NEXT: br label
+ // CHECK: call void @_ZN5test51AD1Ev([[A]]* [[X]])
+ // CHECK-NEXT: ret void
+}
+
+namespace test6 {
+ struct A {
+ A();
+ ~A();
+ };
+
+ void foo(const A &, void (^)());
+ void bar();
+
+ void test() {
+ // Make sure that the temporary cleanup isn't somehow captured
+ // within the block.
+ foo(A(), ^{ bar(); });
+ bar();
+ }
+
+ // CHECK: define void @_ZN5test64testEv()
+ // CHECK: [[TEMP:%.*]] = alloca [[A:%.*]], align 1
+ // CHECK-NEXT: call void @_ZN5test61AC1Ev([[A]]* [[TEMP]])
+ // CHECK-NEXT: call void @_ZN5test63fooERKNS_1AEU13block_pointerFvvE(
+ // CHECK-NEXT: call void @_ZN5test61AD1Ev([[A]]* [[TEMP]])
+ // CHECK-NEXT: call void @_ZN5test63barEv()
+ // CHECK-NEXT: ret void
+}
+
+namespace test7 {
+ int f() {
+ static int n;
+ int *const p = &n;
+ return ^{ return *p; }();
+ }
+}
+
+namespace test8 {
+ // <rdar://problem/10832617>: failure to capture this after skipping rebuild
+ // of the 'this' pointer.
+ struct X {
+ int x;
+
+ template<typename T>
+ int foo() {
+ return ^ { return x; }();
+ }
+ };
+
+ template int X::foo<int>();
+}
diff --git a/clang/test/CodeGenCXX/builtins.cpp b/clang/test/CodeGenCXX/builtins.cpp
new file mode 100644
index 0000000..4542563
--- /dev/null
+++ b/clang/test/CodeGenCXX/builtins.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+// PR8839
+extern "C" char memmove();
+
+int main() {
+ // CHECK: call signext i8 @memmove()
+ return memmove();
+}
+
+// <rdar://problem/10063539>
+
+template<int (*Compare)(const char *s1, const char *s2)>
+int equal(const char *s1, const char *s2) {
+ return Compare(s1, s2) == 0;
+}
+
+// CHECK: define weak_odr i32 @_Z5equalIXadL_Z16__builtin_strcmpPKcS1_EEEiS1_S1_
+// CHECK: call i32 @strcmp
+template int equal<&__builtin_strcmp>(const char*, const char*);
+
diff --git a/clang/test/CodeGenCXX/c-linkage.cpp b/clang/test/CodeGenCXX/c-linkage.cpp
new file mode 100644
index 0000000..b1f07b7
--- /dev/null
+++ b/clang/test/CodeGenCXX/c-linkage.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// pr6644
+
+extern "C" {
+ namespace N {
+ struct X {
+ virtual void f();
+ };
+ void X::f() { }
+ }
+}
+
+// CHECK: define void @_ZN1N1X1fEv
diff --git a/clang/test/CodeGenCXX/c99-variable-length-array.cpp b/clang/test/CodeGenCXX/c99-variable-length-array.cpp
new file mode 100644
index 0000000..d486f9b
--- /dev/null
+++ b/clang/test/CodeGenCXX/c99-variable-length-array.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+struct X {
+ X();
+ ~X();
+};
+
+struct Y {
+ Y();
+ ~Y();
+};
+
+// CHECK: define void @_Z1fiPPKc(
+void f(int argc, const char* argv[]) {
+ // CHECK: call void @_ZN1XC1Ev
+ X x;
+ // CHECK: call i8* @llvm.stacksave(
+ const char *argv2[argc];
+ // CHECK: call void @_ZN1YC1Ev
+ Y y;
+ for (int i = 0; i != argc; ++i)
+ argv2[i] = argv[i];
+
+ // CHECK: call void @_ZN1YD1Ev
+ // CHECK: call void @llvm.stackrestore
+ // CHECK: call void @_ZN1XD1Ev
+ // CHECK: ret void
+}
+
+namespace PR11744 {
+ // Make sure this doesn't crash; there was a use-after-free issue
+ // for this testcase.
+ template<typename T> int f(int n) {
+ T arr[3][n];
+ return 3;
+ }
+ int test = f<int>(0);
+}
diff --git a/clang/test/CodeGenCXX/call-arg-zero-temp.cpp b/clang/test/CodeGenCXX/call-arg-zero-temp.cpp
new file mode 100644
index 0000000..101e81f
--- /dev/null
+++ b/clang/test/CodeGenCXX/call-arg-zero-temp.cpp
@@ -0,0 +1,23 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+
+extern "C" int printf(...);
+
+struct obj{ int a; float b; double d; };
+
+void foo(obj o) {
+ printf("%d %f %f\n", o.a, o.b, o.d);
+}
+
+int main() {
+ obj o = obj();
+ foo(obj());
+}
+
+// CHECK-LP64: callq __Z3foo3obj
+
+// CHECK-LP32: calll __Z3foo3obj
diff --git a/clang/test/CodeGenCXX/cast-conversion.cpp b/clang/test/CodeGenCXX/cast-conversion.cpp
new file mode 100644
index 0000000..d023b9a
--- /dev/null
+++ b/clang/test/CodeGenCXX/cast-conversion.cpp
@@ -0,0 +1,33 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+struct A {
+ A(int);
+};
+
+struct B {
+ B(A);
+};
+
+int main () {
+ (B)10;
+ B(10);
+ static_cast<B>(10);
+}
+
+// CHECK-LP64: callq __ZN1AC1Ei
+// CHECK-LP64: callq __ZN1BC1E1A
+// CHECK-LP64: callq __ZN1AC1Ei
+// CHECK-LP64: callq __ZN1BC1E1A
+// CHECK-LP64: callq __ZN1AC1Ei
+// CHECK-LP64: callq __ZN1BC1E1A
+
+// CHECK-LP32: calll L__ZN1AC1Ei
+// CHECK-LP32: calll L__ZN1BC1E1A
+// CHECK-LP32: calll L__ZN1AC1Ei
+// CHECK-LP32: calll L__ZN1BC1E1A
+// CHECK-LP32: calll L__ZN1AC1Ei
+// CHECK-LP32: calll L__ZN1BC1E1A
diff --git a/clang/test/CodeGenCXX/casts.cpp b/clang/test/CodeGenCXX/casts.cpp
new file mode 100644
index 0000000..436b722
--- /dev/null
+++ b/clang/test/CodeGenCXX/casts.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+
+// PR5248
+namespace PR5248 {
+struct A {
+ void copyFrom(const A &src);
+ void addRef(void);
+
+ A& operator=(int);
+};
+
+void A::copyFrom(const A &src) {
+ ((A &)src).addRef();
+}
+}
+
+// reinterpret_cast to self
+void test(PR5248::A* a) {
+ reinterpret_cast<PR5248::A&>(*a) = 17;
+}
diff --git a/clang/test/CodeGenCXX/class-layout.cpp b/clang/test/CodeGenCXX/class-layout.cpp
new file mode 100644
index 0000000..dac0a0a
--- /dev/null
+++ b/clang/test/CodeGenCXX/class-layout.cpp
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// An extra byte should be allocated for an empty class.
+namespace Test1 {
+ // CHECK: %"struct.Test1::A" = type { i8 }
+ struct A { } *a;
+}
+
+namespace Test2 {
+ // No need to add tail padding here.
+ // CHECK: %"struct.Test2::A" = type { i8*, i32 }
+ struct A { void *a; int b; } *a;
+}
+
+namespace Test3 {
+ // C should have a vtable pointer.
+ // CHECK: %"struct.Test3::A" = type { i32 (...)**, i32 }
+ struct A { virtual void f(); int a; } *a;
+}
+
+namespace Test4 {
+ // Test from PR5589.
+ // CHECK: %"struct.Test4::B" = type { %"struct.Test4::A", i16, double }
+ // CHECK: %"struct.Test4::A" = type { i32, i8, float }
+ struct A {
+ int a;
+ char c;
+ float b;
+ };
+ struct B : public A {
+ short d;
+ double e;
+ } *b;
+}
+
+namespace Test5 {
+ struct A {
+ virtual void f();
+ char a;
+ };
+
+ // CHECK: %"struct.Test5::B" = type { [9 x i8], i8, i8, [5 x i8] }
+ struct B : A {
+ char b : 1;
+ char c;
+ } *b;
+}
+
+// PR10912: don't crash
+namespace Test6 {
+ template <typename T> class A {
+ // If T is complete, IR-gen will want to translate it recursively
+ // when translating T*.
+ T *foo;
+ };
+
+ class B;
+
+ // This causes IR-gen to have an incomplete translation of A<B>
+ // sitting around.
+ A<B> *a;
+
+ class C {};
+ class B : public C {
+ // This forces Sema to instantiate A<B>, which triggers a callback
+ // to IR-gen. Because of the previous, incomplete translation,
+ // IR-gen actually cares, and it immediately tries to complete
+ // A<B>'s IR type. That, in turn, causes the translation of B*.
+ // B isn't complete yet, but it has a definition, and if we try to
+ // compute a record layout for that definition then we'll really
+ // regret it later.
+ A<B> a;
+ };
+
+ // The derived class E and empty base class C are required to
+ // provoke the original assertion.
+ class E : public B {};
+ E *e;
+}
diff --git a/clang/test/CodeGenCXX/compound-literals.cpp b/clang/test/CodeGenCXX/compound-literals.cpp
new file mode 100644
index 0000000..17a3114
--- /dev/null
+++ b/clang/test/CodeGenCXX/compound-literals.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+struct X {
+ X();
+ X(const X&);
+ X(const char*);
+ ~X();
+};
+
+struct Y {
+ int i;
+ X x;
+};
+
+// CHECK: define i32 @_Z1fv()
+int f() {
+ // CHECK: [[LVALUE:%[a-z0-9.]+]] = alloca
+ // CHECK-NEXT: [[I:%[a-z0-9]+]] = getelementptr inbounds {{.*}}* [[LVALUE]], i32 0, i32 0
+ // CHECK-NEXT: store i32 17, i32* [[I]]
+ // CHECK-NEXT: [[X:%[a-z0-9]+]] = getelementptr inbounds {{.*}} [[LVALUE]], i32 0, i32 1
+ // CHECK-NEXT: call void @_ZN1XC1EPKc({{.*}}[[X]]
+ // CHECK-NEXT: [[I:%[a-z0-9]+]] = getelementptr inbounds {{.*}} [[LVALUE]], i32 0, i32 0
+ // CHECK-NEXT: [[RESULT:%[a-z0-9]+]] = load i32*
+ // CHECK-NEXT: call void @_ZN1YD1Ev
+ // CHECK-NEXT: ret i32 [[RESULT]]
+ return ((Y){17, "seventeen"}).i;
+}
+
+// CHECK: define i32 @_Z1gv()
+int g() {
+ // CHECK: store [2 x i32]* %{{[a-z0-9.]+}}, [2 x i32]** [[V:%[a-z0-9.]+]]
+ const int (&v)[2] = (int [2]) {1,2};
+
+ // CHECK: [[A:%[a-z0-9.]+]] = load [2 x i32]** [[V]]
+ // CHECK-NEXT: [[A0ADDR:%[a-z0-9.]+]] = getelementptr inbounds [2 x i32]* [[A]], i32 0, {{.*}} 0
+ // CHECK-NEXT: [[A0:%[a-z0-9.]+]] = load i32* [[A0ADDR]]
+ // CHECK-NEXT: ret i32 [[A0]]
+ return v[0];
+}
+
+struct Z { int i[3]; };
+int *p = (Z){ {1, 2, 3} }.i;
+// CHECK: define {{.*}}__cxx_global_var_init()
+// CHECK: store i32* getelementptr inbounds (%struct.Z* @.compoundliteral, i32 0, i32 0, i32 0), i32** @p
diff --git a/clang/test/CodeGenCXX/condition.cpp b/clang/test/CodeGenCXX/condition.cpp
new file mode 100644
index 0000000..cc2eaf5
--- /dev/null
+++ b/clang/test/CodeGenCXX/condition.cpp
@@ -0,0 +1,317 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+void *f();
+
+template <typename T> T* g() {
+ if (T* t = f())
+ return t;
+
+ return 0;
+}
+
+void h() {
+ void *a = g<void>();
+}
+
+struct X {
+ X();
+ X(const X&);
+ ~X();
+ operator bool();
+};
+
+struct Y {
+ Y();
+ ~Y();
+};
+
+X getX();
+
+// CHECK: define void @_Z11if_destructi(
+void if_destruct(int z) {
+ // Verify that the condition variable is destroyed at the end of the
+ // "if" statement.
+ // CHECK: call void @_ZN1XC1Ev
+ // CHECK: call zeroext i1 @_ZN1XcvbEv
+ if (X x = X()) {
+ // CHECK: store i32 18
+ z = 18;
+ }
+ // CHECK: call void @_ZN1XD1Ev
+ // CHECK: store i32 17
+ z = 17;
+
+ // CHECK: call void @_ZN1XC1Ev
+ if (X x = X())
+ Y y;
+ // CHECK: br
+ // CHECK: call void @_ZN1YC1Ev
+ // CHECK: call void @_ZN1YD1Ev
+ // CHECK: br
+ // CHECK: call void @_ZN1XD1Ev
+
+ // CHECK: call void @_Z4getXv
+ // CHECK: call zeroext i1 @_ZN1XcvbEv
+ // CHECK: call void @_ZN1XD1Ev
+ // CHECK: br
+ if (getX()) { }
+
+ // CHECK: ret
+}
+
+struct ConvertibleToInt {
+ ConvertibleToInt();
+ ~ConvertibleToInt();
+ operator int();
+};
+
+ConvertibleToInt getConvToInt();
+
+void switch_destruct(int z) {
+ // CHECK: call void @_ZN16ConvertibleToIntC1Ev
+ switch (ConvertibleToInt conv = ConvertibleToInt()) {
+ case 0:
+ break;
+
+ default:
+ // CHECK: store i32 19
+ z = 19;
+ break;
+ }
+ // CHECK: call void @_ZN16ConvertibleToIntD1Ev
+ // CHECK: store i32 20
+ z = 20;
+
+ // CHECK: call void @_Z12getConvToIntv
+ // CHECK: call i32 @_ZN16ConvertibleToIntcviEv
+ // CHECK: call void @_ZN16ConvertibleToIntD1Ev
+ switch(getConvToInt()) {
+ case 0:
+ break;
+ }
+ // CHECK: store i32 27
+ z = 27;
+ // CHECK: ret
+}
+
+int foo();
+
+// CHECK: define void @_Z14while_destructi
+void while_destruct(int z) {
+ // CHECK: [[Z:%.*]] = alloca i32
+ // CHECK: [[CLEANUPDEST:%.*]] = alloca i32
+ while (X x = X()) {
+ // CHECK: call void @_ZN1XC1Ev
+ // CHECK-NEXT: [[COND:%.*]] = call zeroext i1 @_ZN1XcvbEv
+ // CHECK-NEXT: br i1 [[COND]]
+
+ // Loop-exit staging block.
+ // CHECK: store i32 3, i32* [[CLEANUPDEST]]
+ // CHECK-NEXT: br
+
+ // While body.
+ // CHECK: store i32 21, i32* [[Z]]
+ // CHECK: store i32 0, i32* [[CLEANUPDEST]]
+ // CHECK-NEXT: br
+ z = 21;
+
+ // Cleanup.
+ // CHECK: call void @_ZN1XD1Ev
+ // CHECK-NEXT: [[DEST:%.*]] = load i32* [[CLEANUPDEST]]
+ // CHECK-NEXT: switch i32 [[DEST]]
+ }
+
+ // CHECK: store i32 22, i32* [[Z]]
+ z = 22;
+
+ // CHECK: call void @_Z4getXv
+ // CHECK-NEXT: call zeroext i1 @_ZN1XcvbEv
+ // CHECK-NEXT: call void @_ZN1XD1Ev
+ // CHECK-NEXT: br
+ while(getX()) { }
+
+ // CHECK: store i32 25, i32* [[Z]]
+ z = 25;
+
+ // CHECK: ret
+}
+
+// CHECK: define void @_Z12for_destructi(
+void for_destruct(int z) {
+ // CHECK: [[Z:%.*]] = alloca i32
+ // CHECK: [[CLEANUPDEST:%.*]] = alloca i32
+ // CHECK: [[I:%.*]] = alloca i32
+ // CHECK: call void @_ZN1YC1Ev
+ // CHECK-NEXT: br
+ // -> %for.cond
+
+ for(Y y = Y(); X x = X(); ++z) {
+ // %for.cond: The loop condition.
+ // CHECK: call void @_ZN1XC1Ev
+ // CHECK-NEXT: [[COND:%.*]] = call zeroext i1 @_ZN1XcvbEv(
+ // CHECK-NEXT: br i1 [[COND]]
+ // -> %for.body, %for.cond.cleanup
+
+ // %for.cond.cleanup: Exit cleanup staging.
+ // CHECK: store i32 2, i32* [[CLEANUPDEST]]
+ // CHECK-NEXT: br
+ // -> %cleanup
+
+ // %for.body:
+ // CHECK: store i32 23, i32* [[Z]]
+ // CHECK-NEXT: br
+ // -> %for.inc
+ z = 23;
+
+ // %for.inc:
+ // CHECK: [[TMP:%.*]] = load i32* [[Z]]
+ // CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[TMP]], 1
+ // CHECK-NEXT: store i32 [[INC]], i32* [[Z]]
+ // CHECK-NEXT: store i32 0, i32* [[CLEANUPDEST]]
+ // CHECK-NEXT: br
+ // -> %cleanup
+
+ // %cleanup: Destroys X.
+ // CHECK: call void @_ZN1XD1Ev
+ // CHECK-NEXT: [[YDESTTMP:%.*]] = load i32* [[CLEANUPDEST]]
+ // CHECK-NEXT: switch i32 [[YDESTTMP]]
+ // 0 -> %cleanup.cont, default -> %cleanup1
+
+ // %cleanup.cont: (eliminable)
+ // CHECK: br
+ // -> %for.cond
+
+ // %cleanup1: Destroys Y.
+ // CHECK: call void @_ZN1YD1Ev(
+ // CHECK-NEXT: br
+ // -> %for.end
+ }
+
+ // %for.end:
+ // CHECK: store i32 24
+ z = 24;
+
+ // CHECK-NEXT: store i32 0, i32* [[I]]
+ // CHECK-NEXT: br
+ // -> %for.cond6
+
+ // %for.cond6:
+ // CHECK: call void @_Z4getXv
+ // CHECK-NEXT: call zeroext i1 @_ZN1XcvbEv
+ // CHECK-NEXT: call void @_ZN1XD1Ev
+ // CHECK-NEXT: br
+ // -> %for.body10, %for.end16
+
+ // %for.body10:
+ // CHECK: br
+ // -> %for.inc11
+
+ // %for.inc11:
+ // CHECK: call void @_Z4getXv
+ // CHECK-NEXT: load i32* [[I]]
+ // CHECK-NEXT: add
+ // CHECK-NEXT: store
+ // CHECK-NEXT: call void @_ZN1XD1Ev
+ // CHECK-NEXT: br
+ // -> %for.cond6
+ int i = 0;
+ for(; getX(); getX(), ++i) { }
+
+ // %for.end16
+ // CHECK: store i32 26
+ z = 26;
+
+ // CHECK-NEXT: ret void
+}
+
+void do_destruct(int z) {
+ // CHECK: define void @_Z11do_destruct
+ do {
+ // CHECK: store i32 77
+ z = 77;
+ // CHECK: call void @_Z4getXv
+ // CHECK: call zeroext i1 @_ZN1XcvbEv
+ // CHECK: call void @_ZN1XD1Ev
+ // CHECK: br
+ } while (getX());
+ // CHECK: store i32 99
+ z = 99;
+ // CHECK: ret
+}
+
+int f(X);
+
+template<typename T>
+int instantiated(T x) {
+ int result;
+
+ // CHECK: call void @_ZN1XC1ERKS_
+ // CHECK: call i32 @_Z1f1X
+ // CHECK: call void @_ZN1XD1Ev
+ // CHECK: br
+ // CHECK: store i32 2
+ // CHECK: br
+ // CHECK: store i32 3
+ if (f(x)) { result = 2; } else { result = 3; }
+
+ // CHECK: call void @_ZN1XC1ERKS_
+ // CHECK: call i32 @_Z1f1X
+ // CHECK: call void @_ZN1XD1Ev
+ // CHECK: br
+ // CHECK: store i32 4
+ // CHECK: br
+ while (f(x)) { result = 4; }
+
+ // CHECK: call void @_ZN1XC1ERKS_
+ // CHECK: call i32 @_Z1f1X
+ // CHECK: call void @_ZN1XD1Ev
+ // CHECK: br
+ // CHECK: store i32 6
+ // CHECK: br
+ // CHECK: call void @_ZN1XC1ERKS_
+ // CHECK: call i32 @_Z1f1X
+ // CHECK: store i32 5
+ // CHECK: call void @_ZN1XD1Ev
+ // CHECK: br
+ for (; f(x); f(x), result = 5) {
+ result = 6;
+ }
+
+ // CHECK: call void @_ZN1XC1ERKS_
+ // CHECK: call i32 @_Z1f1X
+ // CHECK: call void @_ZN1XD1Ev
+ // CHECK: switch i32
+ // CHECK: store i32 7
+ // CHECK: store i32 8
+ switch (f(x)) {
+ case 0:
+ result = 7;
+ break;
+
+ case 1:
+ result = 8;
+ }
+
+ // CHECK: store i32 9
+ // CHECK: br
+ // CHECK: call void @_ZN1XC1ERKS_
+ // CHECK: call i32 @_Z1f1X
+ // CHECK: call void @_ZN1XD1Ev
+ // CHECK: br
+ do {
+ result = 9;
+ } while (f(x));
+
+ // CHECK: store i32 10
+ // CHECK: call void @_ZN1XC1ERKS_
+ // CHECK: call zeroext i1 @_ZN1XcvbEv
+ // CHECK: call void @_ZN1XD1Ev
+ // CHECK: br
+ do {
+ result = 10;
+ } while (X(x));
+
+ // CHECK: ret i32
+ return result;
+}
+
+template int instantiated(X);
diff --git a/clang/test/CodeGenCXX/conditional-expr-lvalue.cpp b/clang/test/CodeGenCXX/conditional-expr-lvalue.cpp
new file mode 100644
index 0000000..96aa8b0
--- /dev/null
+++ b/clang/test/CodeGenCXX/conditional-expr-lvalue.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+void f(bool flag) {
+ int a = 1;
+ int b = 2;
+
+ (flag ? a : b) = 3;
+}
+
+// PR10756
+namespace test0 {
+ struct A {
+ A(const A &);
+ A &operator=(const A &);
+ A sub() const;
+ void foo() const;
+ };
+ void foo(bool cond, const A &a) {
+ (cond ? a : a.sub()).foo();
+ }
+}
diff --git a/clang/test/CodeGenCXX/conditional-gnu-ext.cpp b/clang/test/CodeGenCXX/conditional-gnu-ext.cpp
new file mode 100644
index 0000000..104a91d
--- /dev/null
+++ b/clang/test/CodeGenCXX/conditional-gnu-ext.cpp
@@ -0,0 +1,150 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+// rdar: // 8353567
+// pr7726
+
+extern "C" int printf(...);
+
+void test0() {
+// CHECK: call i32 (...)* @printf({{.*}}, i8* inttoptr (i64 3735928559 to i8*))
+ printf("%p\n", (void *)0xdeadbeef ? : (void *)0xaaaaaa);
+}
+
+// rdar://8446940
+namespace radar8446940 {
+extern "C" void abort();
+
+int main () {
+ char x[1];
+ char *y = x ? : 0;
+
+ if (x != y)
+ abort();
+}
+}
+
+namespace radar8453812 {
+extern "C" void abort();
+_Complex int getComplex(_Complex int val) {
+ static int count;
+ if (count++)
+ abort();
+ return val;
+}
+
+_Complex int cmplx() {
+ _Complex int cond;
+ _Complex int rhs;
+
+ return getComplex(1+2i) ? : rhs;
+}
+
+// lvalue test
+void foo (int& lv) {
+ ++lv;
+}
+
+int global = 1;
+
+int &cond() {
+ static int count;
+ if (count++)
+ abort();
+ return global;
+}
+
+
+int main() {
+ cmplx();
+ int rhs = 10;
+ foo (cond()? : rhs);
+ return global-2;
+}
+}
+
+namespace test3 {
+ struct A {
+ A();
+ A(const A&);
+ ~A();
+ };
+
+ struct B {
+ B();
+ B(const B&);
+ ~B();
+ operator bool();
+ operator A();
+ };
+
+ B test0(B &x) {
+ // CHECK: define void @_ZN5test35test0ERNS_1BE(
+ // CHECK: [[X:%.*]] = alloca [[B:%.*]]*,
+ // CHECK-NEXT: store [[B]]* {{%.*}}, [[B]]** [[X]]
+ // CHECK-NEXT: [[T0:%.*]] = load [[B]]** [[X]]
+ // CHECK-NEXT: [[BOOL:%.*]] = call zeroext i1 @_ZN5test31BcvbEv([[B]]* [[T0]])
+ // CHECK-NEXT: br i1 [[BOOL]]
+ // CHECK: call void @_ZN5test31BC1ERKS0_([[B]]* [[RESULT:%.*]], [[B]]* [[T0]])
+ // CHECK-NEXT: br label
+ // CHECK: call void @_ZN5test31BC1Ev([[B]]* [[RESULT]])
+ // CHECK-NEXT: br label
+ // CHECK: ret void
+ return x ?: B();
+ }
+
+ B test1() {
+ // CHECK: define void @_ZN5test35test1Ev(
+ // CHECK: [[TEMP:%.*]] = alloca [[B]],
+ // CHECK-NEXT: call void @_ZN5test312test1_helperEv([[B]]* sret [[TEMP]])
+ // CHECK-NEXT: [[BOOL:%.*]] = call zeroext i1 @_ZN5test31BcvbEv([[B]]* [[TEMP]])
+ // CHECK-NEXT: br i1 [[BOOL]]
+ // CHECK: call void @_ZN5test31BC1ERKS0_([[B]]* [[RESULT:%.*]], [[B]]* [[TEMP]])
+ // CHECK-NEXT: br label
+ // CHECK: call void @_ZN5test31BC1Ev([[B]]* [[RESULT]])
+ // CHECK-NEXT: br label
+ // CHECK: call void @_ZN5test31BD1Ev([[B]]* [[TEMP]])
+ // CHECK-NEXT: ret void
+ extern B test1_helper();
+ return test1_helper() ?: B();
+ }
+
+
+ A test2(B &x) {
+ // CHECK: define void @_ZN5test35test2ERNS_1BE(
+ // CHECK: [[X:%.*]] = alloca [[B]]*,
+ // CHECK-NEXT: store [[B]]* {{%.*}}, [[B]]** [[X]]
+ // CHECK-NEXT: [[T0:%.*]] = load [[B]]** [[X]]
+ // CHECK-NEXT: [[BOOL:%.*]] = call zeroext i1 @_ZN5test31BcvbEv([[B]]* [[T0]])
+ // CHECK-NEXT: br i1 [[BOOL]]
+ // CHECK: call void @_ZN5test31BcvNS_1AEEv([[A:%.*]]* sret [[RESULT:%.*]], [[B]]* [[T0]])
+ // CHECK-NEXT: br label
+ // CHECK: call void @_ZN5test31AC1Ev([[A]]* [[RESULT]])
+ // CHECK-NEXT: br label
+ // CHECK: ret void
+ return x ?: A();
+ }
+
+ A test3() {
+ // CHECK: define void @_ZN5test35test3Ev(
+ // CHECK: [[TEMP:%.*]] = alloca [[B]],
+ // CHECK-NEXT: call void @_ZN5test312test3_helperEv([[B]]* sret [[TEMP]])
+ // CHECK-NEXT: [[BOOL:%.*]] = call zeroext i1 @_ZN5test31BcvbEv([[B]]* [[TEMP]])
+ // CHECK-NEXT: br i1 [[BOOL]]
+ // CHECK: call void @_ZN5test31BcvNS_1AEEv([[A]]* sret [[RESULT:%.*]], [[B]]* [[TEMP]])
+ // CHECK-NEXT: br label
+ // CHECK: call void @_ZN5test31AC1Ev([[A]]* [[RESULT]])
+ // CHECK-NEXT: br label
+ // CHECK: call void @_ZN5test31BD1Ev([[B]]* [[TEMP]])
+ // CHECK-NEXT: ret void
+ extern B test3_helper();
+ return test3_helper() ?: A();
+ }
+
+}
+
+namespace test4 {
+ // Make sure this doesn't crash.
+ void f() {
+ const int a = 10, b = 20;
+ const int *c = &(a ?: b);
+ }
+}
diff --git a/clang/test/CodeGenCXX/conditional-temporaries.cpp b/clang/test/CodeGenCXX/conditional-temporaries.cpp
new file mode 100644
index 0000000..d538287
--- /dev/null
+++ b/clang/test/CodeGenCXX/conditional-temporaries.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -O3 | FileCheck %s
+
+namespace {
+
+static int ctorcalls;
+static int dtorcalls;
+
+struct A {
+ A() : i(0) { ctorcalls++; }
+ ~A() { dtorcalls++; }
+ int i;
+
+ friend const A& operator<<(const A& a, int n) {
+ return a;
+ }
+};
+
+void g(int) { }
+void g(const A&) { }
+
+void f1(bool b) {
+ g(b ? A().i : 0);
+ g(b || A().i);
+ g(b && A().i);
+ g(b ? A() << 1 : A() << 2);
+}
+
+struct Checker {
+ Checker() {
+ f1(true);
+ f1(false);
+ }
+};
+
+Checker c;
+
+}
+
+// CHECK: define i32 @_Z12getCtorCallsv()
+int getCtorCalls() {
+ // CHECK: ret i32 5
+ return ctorcalls;
+}
+
+// CHECK: define i32 @_Z12getDtorCallsv()
+int getDtorCalls() {
+ // CHECK: ret i32 5
+ return dtorcalls;
+}
+
+// CHECK: define zeroext i1 @_Z7successv()
+bool success() {
+ // CHECK: ret i1 true
+ return ctorcalls == dtorcalls;
+}
diff --git a/clang/test/CodeGenCXX/const-base-cast.cpp b/clang/test/CodeGenCXX/const-base-cast.cpp
new file mode 100644
index 0000000..320c790
--- /dev/null
+++ b/clang/test/CodeGenCXX/const-base-cast.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+// Check that the following construct, which is similar to one which occurs
+// in Firefox, is folded correctly.
+struct A { char x; };
+struct B { char y; };
+struct C : A,B {};
+unsigned char x = ((char*)(B*)(C*)0x1000) - (char*)0x1000;
+
+// CHECK: @x = global i8 1
diff --git a/clang/test/CodeGenCXX/const-global-linkage.cpp b/clang/test/CodeGenCXX/const-global-linkage.cpp
new file mode 100644
index 0000000..d0a055b
--- /dev/null
+++ b/clang/test/CodeGenCXX/const-global-linkage.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+const int x = 10;
+const int y = 20;
+// CHECK-NOT: @x
+// CHECK: @_ZL1y = internal constant i32 20
+const int& b() { return y; }
+
+const char z1[] = "asdf";
+const char z2[] = "zxcv";
+// CHECK-NOT: @z1
+// CHECK: @_ZL2z2 = internal constant
+const char* b2() { return z2; }
diff --git a/clang/test/CodeGenCXX/const-init-cxx11.cpp b/clang/test/CodeGenCXX/const-init-cxx11.cpp
new file mode 100644
index 0000000..62a345a
--- /dev/null
+++ b/clang/test/CodeGenCXX/const-init-cxx11.cpp
@@ -0,0 +1,428 @@
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s -std=c++11 | FileCheck %s
+
+// FIXME: The padding in all these objects should be zero-initialized.
+namespace StructUnion {
+ struct A {
+ int n;
+ double d;
+ union U {
+ constexpr U(int x) : x(x) {}
+ constexpr U(const char *y) : y(y) {}
+ int x;
+ const char *y;
+ } u;
+
+ constexpr A(int n, double d, int x) : n(n), d(d), u(x) {}
+ constexpr A(int n, double d, const char *y) : n(n), d(d), u(y) {}
+ };
+
+ // CHECK: @_ZN11StructUnion1aE = constant {{.*}} { i32 1, double 2.000000e+00, {{.*}} { i32 3, [4 x i8] undef } }
+ extern constexpr A a(1, 2.0, 3);
+
+ // CHECK: @_ZN11StructUnion1bE = constant {{.*}} { i32 4, double 5.000000e+00, {{.*}} { i8* getelementptr inbounds ([6 x i8]* @{{.*}}, i32 0, i32 0) } }
+ extern constexpr A b(4, 5, "hello");
+
+ struct B {
+ int n;
+ };
+
+ // CHECK: @_ZN11StructUnion1cE = global {{.*}} zeroinitializer
+ // CHECK: @_ZN11StructUnion2c2E = global {{.*}} zeroinitializer
+ B c;
+ B c2 = B();
+
+ // CHECK: @_ZN11StructUnion1dE = global {{.*}} zeroinitializer
+ B d[10];
+
+ struct C {
+ constexpr C() : c(0) {}
+ int c;
+ };
+
+ // CHECK: @_ZN11StructUnion1eE = global {{.*}} zeroinitializer
+ C e[10];
+
+ struct D {
+ constexpr D() : d(5) {}
+ int d;
+ };
+
+ // CHECK: @_ZN11StructUnion1fE = global {{.*}} { i32 5 }
+ D f;
+}
+
+namespace BaseClass {
+ template<typename T, unsigned> struct X : T {};
+ struct C { char c = 1; };
+ template<unsigned... Ns> struct Cs : X<C,Ns>... {};
+ struct N { int n = 3; };
+ struct D { double d = 4.0; };
+
+ template<typename ...Ts>
+ struct Test : Ts... { constexpr Test() : Ts()..., n(5) {} int n; };
+
+ using Test1 = Test<N, C, Cs<1,2>, D, X<C,1>>;
+ // CHECK: @_ZN9BaseClass2t1E = constant {{.*}} { i32 3, i8 1, i8 1, i8 1, double 4.000000e+00, i8 1, i32 5 }, align 8
+ extern constexpr Test1 t1 = Test1();
+
+ struct DN : D, N {};
+ struct DND : DN, X<D,0> {};
+ struct DNN : DN, X<N,0> {};
+ // CHECK: @_ZN9BaseClass3dndE = constant {{.*}} { double 4.000000e+00, i32 3, double 4.000000e+00 }
+ extern constexpr DND dnd = DND();
+ // Note, N subobject is laid out in DN subobject's tail padding.
+ // CHECK: @_ZN9BaseClass3dnnE = constant {{.*}} { double 4.000000e+00, i32 3, i32 3 }
+ extern constexpr DNN dnn = DNN();
+
+ struct E {};
+ struct Test2 : X<E,0>, X<E,1>, X<E,2>, X<E,3> {};
+ // CHECK: @_ZN9BaseClass2t2E = constant {{.*}} undef
+ extern constexpr Test2 t2 = Test2();
+
+ struct __attribute((packed)) PackedD { double y = 2; };
+ struct Test3 : C, PackedD { constexpr Test3() {} };
+ // CHECK: @_ZN9BaseClass2t3E = constant <{ i8, double }> <{ i8 1, double 2.000000e+00 }>
+ extern constexpr Test3 t3 = Test3();
+}
+
+namespace Array {
+ // CHECK: @_ZN5Array3arrE = constant [2 x i32] [i32 4, i32 0]
+ extern constexpr int arr[2] = { 4 };
+
+ // CHECK: @_ZN5Array1cE = constant [6 x [4 x i8]] [{{.*}} c"foo\00", [4 x i8] c"a\00\00\00", [4 x i8] c"bar\00", [4 x i8] c"xyz\00", [4 x i8] c"b\00\00\00", [4 x i8] c"123\00"]
+ extern constexpr char c[6][4] = { "foo", "a", { "bar" }, { 'x', 'y', 'z' }, { "b" }, '1', '2', '3' };
+
+ // CHECK: @_ZN5Array2ucE = constant [4 x i8] c"foo\00"
+ extern constexpr unsigned char uc[] = { "foo" };
+
+ struct C { constexpr C() : n(5) {} int n, m = 3 * n + 1; };
+ // CHECK: @_ZN5Array5ctorsE = constant [3 x {{.*}}] [{{.*}} { i32 5, i32 16 }, {{.*}} { i32 5, i32 16 }, {{.*}} { i32 5, i32 16 }]
+ extern const C ctors[3];
+ constexpr C ctors[3];
+
+ // CHECK: @_ZN5Array1dE = constant {{.*}} { [2 x i32] [i32 1, i32 2], [3 x i32] [i32 3, i32 4, i32 5] }
+ struct D { int n[2]; int m[3]; } extern constexpr d = { 1, 2, 3, 4, 5 };
+
+ struct E {
+ char c[4];
+ char d[4];
+ constexpr E() : c("foo"), d("x") {}
+ };
+ // CHECK: @_ZN5Array1eE = constant {{.*}} { [4 x i8] c"foo\00", [4 x i8] c"x\00\00\00" }
+ extern constexpr E e = E();
+}
+
+namespace MemberPtr {
+ struct B1 {
+ int a, b;
+ virtual void f();
+ void g();
+ };
+ struct B2 {
+ int c, d;
+ virtual void h();
+ void i();
+ };
+ struct C : B1 {
+ int e;
+ virtual void j();
+ void k();
+ };
+ struct D : C, B2 {
+ int z;
+ virtual void l();
+ void m();
+ };
+
+ // CHECK: @_ZN9MemberPtr2daE = constant i64 8
+ // CHECK: @_ZN9MemberPtr2dbE = constant i64 12
+ // CHECK: @_ZN9MemberPtr2dcE = constant i64 32
+ // CHECK: @_ZN9MemberPtr2ddE = constant i64 36
+ // CHECK: @_ZN9MemberPtr2deE = constant i64 16
+ // CHECK: @_ZN9MemberPtr2dzE = constant i64 40
+ extern constexpr int (D::*da) = &B1::a;
+ extern constexpr int (D::*db) = &C::b;
+ extern constexpr int (D::*dc) = &B2::c;
+ extern constexpr int (D::*dd) = &D::d;
+ extern constexpr int (D::*de) = &C::e;
+ extern constexpr int (D::*dz) = &D::z;
+
+ // CHECK: @_ZN9MemberPtr2baE = constant i64 8
+ // CHECK: @_ZN9MemberPtr2bbE = constant i64 12
+ // CHECK: @_ZN9MemberPtr2bcE = constant i64 8
+ // CHECK: @_ZN9MemberPtr2bdE = constant i64 12
+ // CHECK: @_ZN9MemberPtr2beE = constant i64 16
+ // CHECK: @_ZN9MemberPtr3b1zE = constant i64 40
+ // CHECK: @_ZN9MemberPtr3b2zE = constant i64 16
+ extern constexpr int (B1::*ba) = (int(B1::*))&B1::a;
+ extern constexpr int (B1::*bb) = (int(B1::*))&C::b;
+ extern constexpr int (B2::*bc) = (int(B2::*))&B2::c;
+ extern constexpr int (B2::*bd) = (int(B2::*))&D::d;
+ extern constexpr int (B1::*be) = (int(B1::*))&C::e;
+ extern constexpr int (B1::*b1z) = (int(B1::*))&D::z;
+ extern constexpr int (B2::*b2z) = (int(B2::*))&D::z;
+
+ // CHECK: @_ZN9MemberPtr2dfE = constant {{.*}} { i64 1, i64 0 }
+ // CHECK: @_ZN9MemberPtr2dgE = constant {{.*}} { i64 {{.*}}2B11gEv{{.*}}, i64 0 }
+ // CHECK: @_ZN9MemberPtr2dhE = constant {{.*}} { i64 1, i64 24 }
+ // CHECK: @_ZN9MemberPtr2diE = constant {{.*}} { i64 {{.*}}2B21iEv{{.*}}, i64 24 }
+ // CHECK: @_ZN9MemberPtr2djE = constant {{.*}} { i64 9, i64 0 }
+ // CHECK: @_ZN9MemberPtr2dkE = constant {{.*}} { i64 {{.*}}1C1kEv{{.*}}, i64 0 }
+ // CHECK: @_ZN9MemberPtr2dlE = constant {{.*}} { i64 17, i64 0 }
+ // CHECK: @_ZN9MemberPtr2dmE = constant {{.*}} { i64 {{.*}}1D1mEv{{.*}}, i64 0 }
+ extern constexpr void (D::*df)() = &C::f;
+ extern constexpr void (D::*dg)() = &B1::g;
+ extern constexpr void (D::*dh)() = &B2::h;
+ extern constexpr void (D::*di)() = &D::i;
+ extern constexpr void (D::*dj)() = &C::j;
+ extern constexpr void (D::*dk)() = &C::k;
+ extern constexpr void (D::*dl)() = &D::l;
+ extern constexpr void (D::*dm)() = &D::m;
+
+ // CHECK: @_ZN9MemberPtr2bfE = constant {{.*}} { i64 1, i64 0 }
+ // CHECK: @_ZN9MemberPtr2bgE = constant {{.*}} { i64 {{.*}}2B11gEv{{.*}}, i64 0 }
+ // CHECK: @_ZN9MemberPtr2bhE = constant {{.*}} { i64 1, i64 0 }
+ // CHECK: @_ZN9MemberPtr2biE = constant {{.*}} { i64 {{.*}}2B21iEv{{.*}}, i64 0 }
+ // CHECK: @_ZN9MemberPtr2bjE = constant {{.*}} { i64 9, i64 0 }
+ // CHECK: @_ZN9MemberPtr2bkE = constant {{.*}} { i64 {{.*}}1C1kEv{{.*}}, i64 0 }
+ // CHECK: @_ZN9MemberPtr3b1lE = constant {{.*}} { i64 17, i64 0 }
+ // CHECK: @_ZN9MemberPtr3b1mE = constant {{.*}} { i64 {{.*}}1D1mEv{{.*}}, i64 0 }
+ // CHECK: @_ZN9MemberPtr3b2lE = constant {{.*}} { i64 17, i64 -24 }
+ // CHECK: @_ZN9MemberPtr3b2mE = constant {{.*}} { i64 {{.*}}1D1mEv{{.*}}, i64 -24 }
+ extern constexpr void (B1::*bf)() = (void(B1::*)())&C::f;
+ extern constexpr void (B1::*bg)() = (void(B1::*)())&B1::g;
+ extern constexpr void (B2::*bh)() = (void(B2::*)())&B2::h;
+ extern constexpr void (B2::*bi)() = (void(B2::*)())&D::i;
+ extern constexpr void (B1::*bj)() = (void(B1::*)())&C::j;
+ extern constexpr void (B1::*bk)() = (void(B1::*)())&C::k;
+ extern constexpr void (B1::*b1l)() = (void(B1::*)())&D::l;
+ extern constexpr void (B1::*b1m)() = (void(B1::*)())&D::m;
+ extern constexpr void (B2::*b2l)() = (void(B2::*)())&D::l;
+ extern constexpr void (B2::*b2m)() = (void(B2::*)())&D::m;
+}
+
+namespace LiteralReference {
+ struct Lit {
+ constexpr Lit() : n(5) {}
+ int n;
+ };
+ // FIXME: This should have static initialization, but we do not implement
+ // that yet. For now, just check that we don't set the (pointer) value of
+ // the reference to 5!
+ //
+ // CHECK: @_ZN16LiteralReference3litE = global {{.*}} null
+ const Lit &lit = Lit();
+}
+
+namespace NonLiteralConstexpr {
+ constexpr int factorial(int n) {
+ return n ? factorial(n-1) * n : 1;
+ }
+ extern void f(int *p);
+
+ struct NonTrivialDtor {
+ constexpr NonTrivialDtor() : n(factorial(5)), p(&n) {}
+ ~NonTrivialDtor() {
+ f(p);
+ }
+
+ int n;
+ int *p;
+ };
+ static_assert(!__is_literal(NonTrivialDtor), "");
+ // CHECK: @_ZN19NonLiteralConstexpr3ntdE = global {{.*}} { i32 120, i32* getelementptr
+ NonTrivialDtor ntd;
+
+ struct VolatileMember {
+ constexpr VolatileMember() : n(5) {}
+ volatile int n;
+ };
+ static_assert(!__is_literal(VolatileMember), "");
+ // CHECK: @_ZN19NonLiteralConstexpr2vmE = global {{.*}} { i32 5 }
+ VolatileMember vm;
+
+ struct Both {
+ constexpr Both() : n(10) {}
+ ~Both();
+ volatile int n;
+ };
+ // CHECK: @_ZN19NonLiteralConstexpr1bE = global {{.*}} { i32 10 }
+ Both b;
+
+ void StaticVars() {
+ // CHECK: @_ZZN19NonLiteralConstexpr10StaticVarsEvE3ntd = {{.*}} { i32 120, i32* getelementptr {{.*}}
+ // CHECK: @_ZGVZN19NonLiteralConstexpr10StaticVarsEvE3ntd =
+ static NonTrivialDtor ntd;
+ // CHECK: @_ZZN19NonLiteralConstexpr10StaticVarsEvE2vm = {{.*}} { i32 5 }
+ // CHECK-NOT: @_ZGVZN19NonLiteralConstexpr10StaticVarsEvE2vm =
+ static VolatileMember vm;
+ // CHECK: @_ZZN19NonLiteralConstexpr10StaticVarsEvE1b = {{.*}} { i32 10 }
+ // CHECK: @_ZGVZN19NonLiteralConstexpr10StaticVarsEvE1b =
+ static Both b;
+ }
+}
+
+// PR12067
+namespace VirtualMembers {
+ struct A {
+ constexpr A(double d) : d(d) {}
+ virtual void f();
+ double d;
+ };
+ struct B : A {
+ constexpr B() : A(2.0), c{'h', 'e', 'l', 'l', 'o'} {}
+ constexpr B(int n) : A(n), c{'w', 'o', 'r', 'l', 'd'} {}
+ virtual void g();
+ char c[5];
+ };
+ struct C {
+ constexpr C() : n(64) {}
+ int n;
+ };
+ struct D : C, A, B {
+ constexpr D() : A(1.0), B(), s(5) {}
+ short s;
+ };
+ struct E : D, B {
+ constexpr E() : B(3), c{'b','y','e'} {}
+ char c[3];
+ };
+
+ // CHECK: @_ZN14VirtualMembers1eE = global { i8**, double, i32, i8**, double, [5 x i8], i16, i8**, double, [5 x i8], [3 x i8] } { i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 2), double 1.000000e+00, i32 64, i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 5), double 2.000000e+00, [5 x i8] c"hello", i16 5, i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 9), double 3.000000e+00, [5 x i8] c"world", [3 x i8] c"bye" }
+ E e;
+
+ struct nsMemoryImpl {
+ virtual void f();
+ };
+ // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global { i8** } { i8** getelementptr inbounds ([3 x i8*]* @_ZTVN14VirtualMembers12nsMemoryImplE, i64 0, i64 2) }
+ static nsMemoryImpl sGlobalMemory;
+}
+
+// Constant initialization tests go before this point,
+// dynamic initialization tests go after.
+
+// We must emit a constant initializer for NonLiteralConstexpr::ntd, but also
+// emit an initializer to register its destructor.
+// CHECK: define {{.*}}cxx_global_var_init{{.*}}
+// CHECK-NOT: NonLiteralConstexpr
+// CHECK: call {{.*}}cxa_atexit{{.*}} @_ZN19NonLiteralConstexpr14NonTrivialDtorD1Ev {{.*}} @_ZN19NonLiteralConstexpr3ntdE
+// CHECK-NEXT: ret void
+
+// We don't need to emit any dynamic initialization for NonLiteralConstexpr::vm.
+// CHECK-NOT: NonLiteralConstexpr2vm
+
+// We must emit a constant initializer for NonLiteralConstexpr::b, but also
+// emit an initializer to register its destructor.
+// CHECK: define {{.*}}cxx_global_var_init{{.*}}
+// CHECK-NOT: NonLiteralConstexpr
+// CHECK: call {{.*}}cxa_atexit{{.*}} @_ZN19NonLiteralConstexpr4BothD1Ev {{.*}} @_ZN19NonLiteralConstexpr1bE
+// CHECK-NEXT: ret void
+
+// CHECK: define {{.*}}NonLiteralConstexpr10StaticVars
+// CHECK-NOT: }
+// CHECK: call {{.*}}cxa_atexit{{.*}}@_ZN19NonLiteralConstexpr14NonTrivialDtorD1Ev
+// CHECK-NOT: }
+// CHECK: call {{.*}}cxa_atexit{{.*}}@_ZN19NonLiteralConstexpr4BothD1Ev
+
+namespace CrossFuncLabelDiff {
+ // Make sure we refuse to constant-fold the variable b.
+ constexpr long a(bool x) { return x ? 0 : (long)&&lbl + (0 && ({lbl: 0;})); }
+ void test() { static long b = (long)&&lbl - a(false); lbl: return; }
+ // CHECK: sub nsw i64 ptrtoint (i8* blockaddress(@_ZN18CrossFuncLabelDiff4testEv, {{.*}}) to i64),
+ // CHECK: store i64 {{.*}}, i64* @_ZZN18CrossFuncLabelDiff4testEvE1b, align 8
+}
+
+// PR12012
+namespace VirtualBase {
+ struct B {};
+ struct D : virtual B {};
+ D d;
+ // CHECK: call {{.*}}@_ZN11VirtualBase1DC1Ev
+
+ template<typename T> struct X : T {
+ constexpr X() : T() {}
+ };
+ X<D> x;
+ // CHECK: call {{.*}}@_ZN11VirtualBase1XINS_1DEEC1Ev
+}
+
+// PR12145
+namespace Unreferenced {
+ int n;
+ constexpr int *p = &n;
+ // We must not emit a load of 'p' here, since it's not odr-used.
+ int q = *p;
+ // CHECK-NOT: _ZN12Unreferenced1pE
+ // CHECK: = load i32* @_ZN12Unreferenced1nE
+ // CHECK-NEXT: store i32 {{.*}}, i32* @_ZN12Unreferenced1qE
+ // CHECK-NOT: _ZN12Unreferenced1pE
+
+ // Technically, we are not required to substitute variables of reference types
+ // initialized by constant expressions, because the special case for odr-use
+ // of variables in [basic.def.odr]p2 only applies to objects. But we do so
+ // anyway.
+
+ constexpr int &r = n;
+ // CHECK-NOT: _ZN12Unreferenced1rE
+ int s = r;
+
+ const int t = 1;
+ const int &rt = t;
+ int f(int);
+ int u = f(rt);
+ // CHECK: call i32 @_ZN12Unreferenced1fEi(i32 1)
+}
+
+namespace InitFromConst {
+ template<typename T> void consume(T);
+
+ const bool b = true;
+ const int n = 5;
+ constexpr double d = 4.3;
+
+ struct S { int n = 7; S *p = 0; };
+ constexpr S s = S();
+ const S &r = s;
+ constexpr const S *p = &r;
+ constexpr int S::*mp = &S::n;
+ constexpr int a[3] = { 1, 4, 9 };
+
+ void test() {
+ // CHECK: call void @_ZN13InitFromConst7consumeIbEEvT_(i1 zeroext true)
+ consume(b);
+
+ // CHECK: call void @_ZN13InitFromConst7consumeIiEEvT_(i32 5)
+ consume(n);
+
+ // CHECK: call void @_ZN13InitFromConst7consumeIdEEvT_(double 4.300000e+00)
+ consume(d);
+
+ // CHECK: call void @_ZN13InitFromConst7consumeIRKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
+ consume<const S&>(s);
+
+ // FIXME CHECK-NOT: call void @_ZN13InitFromConst7consumeIRKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
+ // There's no lvalue-to-rvalue conversion here, so 'r' is odr-used, and
+ // we're permitted to emit a load of it. This seems likely to be a defect
+ // in the standard. If we start emitting a direct reference to 's', update
+ // this test.
+ consume<const S&>(r);
+
+ // CHECK: call void @_ZN13InitFromConst7consumeIPKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
+ consume(p);
+
+ // CHECK: call void @_ZN13InitFromConst7consumeIMNS_1SEiEEvT_(i64 0)
+ consume(mp);
+
+ // CHECK: call void @_ZN13InitFromConst7consumeIPKiEEvT_(i32* getelementptr inbounds ([3 x i32]* @_ZN13InitFromConstL1aE, i32 0, i32 0))
+ consume(a);
+ }
+}
+
+namespace Null {
+ decltype(nullptr) null();
+ // CHECK: call {{.*}} @_ZN4Null4nullEv(
+ int *p = null();
+ struct S {};
+ // CHECK: call {{.*}} @_ZN4Null4nullEv(
+ int S::*q = null();
+}
diff --git a/clang/test/CodeGenCXX/const-init.cpp b/clang/test/CodeGenCXX/const-init.cpp
new file mode 100644
index 0000000..201ce8f
--- /dev/null
+++ b/clang/test/CodeGenCXX/const-init.cpp
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @a = global i32 10
+int a = 10;
+// CHECK: @ar = constant i32* @a
+int &ar = a;
+
+void f();
+// CHECK: @fr = constant void ()* @_Z1fv
+void (&fr)() = f;
+
+struct S { int& a; };
+// CHECK: @s = global %struct.S { i32* @a }
+S s = { a };
+
+// PR5581
+namespace PR5581 {
+class C {
+public:
+ enum { e0, e1 };
+ unsigned f;
+};
+
+// CHECK: @_ZN6PR55812g0E = global %"class.PR5581::C" { i32 1 }
+C g0 = { C::e1 };
+}
+
+namespace test2 {
+ struct A {
+ static const double d = 1.0;
+ static const float f = d / 2;
+ static int g();
+ } a;
+
+ // CHECK: @_ZN5test22t0E = global double {{1\.0+e\+0+}}, align 8
+ // CHECK: @_ZN5test22t1E = global [2 x double] [double {{1\.0+e\+0+}}, double {{5\.0+e-0*}}1], align 16
+ // CHECK: @_ZN5test22t2E = global double* @_ZN5test21A1d
+ // CHECK: @_ZN5test22t3E = global {{.*}} @_ZN5test21A1g
+ double t0 = A::d;
+ double t1[] = { A::d, A::f };
+ const double *t2 = &a.d;
+ int (*t3)() = &a.g;
+}
+
+// We don't expect to fold this in the frontend, but make sure it doesn't crash.
+// CHECK: @PR9558 = global float 0.000000e+0
+float PR9558 = reinterpret_cast<const float&>("asd");
+
+// An initialized const automatic variable cannot be promoted to a constant
+// global if it has a mutable member.
+struct MutableMember {
+ mutable int n;
+};
+int writeToMutable() {
+ // CHECK-NOT: {{.*}}MM{{.*}} = {{.*}}constant
+ const MutableMember MM = { 0 };
+ return ++MM.n;
+}
+
+// Make sure we don't try to fold this in the frontend; the backend can't
+// handle it.
+// CHECK: @PR11705 = global i128 0
+__int128_t PR11705 = (__int128_t)&PR11705;
+
+// Make sure we don't try to fold this either.
+// CHECK: @_ZZ23UnfoldableAddrLabelDiffvE1x = internal global i128 0
+void UnfoldableAddrLabelDiff() { static __int128_t x = (long)&&a-(long)&&b; a:b:return;}
+
+// But make sure we do fold this.
+// CHECK: @_ZZ21FoldableAddrLabelDiffvE1x = internal global i64 sub (i64 ptrtoint (i8* blockaddress(@_Z21FoldableAddrLabelDiffv
+void FoldableAddrLabelDiff() { static long x = (long)&&a-(long)&&b; a:b:return;}
+
+// CHECK: @i = constant i32* bitcast (float* @PR9558 to i32*)
+int &i = reinterpret_cast<int&>(PR9558);
+
+int arr[2];
+// CHECK: @pastEnd = constant i32* bitcast (i8* getelementptr (i8* bitcast ([2 x i32]* @arr to i8*), i64 8) to i32*)
+int &pastEnd = arr[2];
diff --git a/clang/test/CodeGenCXX/constructor-attr.cpp b/clang/test/CodeGenCXX/constructor-attr.cpp
new file mode 100644
index 0000000..691795f
--- /dev/null
+++ b/clang/test/CodeGenCXX/constructor-attr.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @llvm.global_ctors
+
+// PR6521
+void bar();
+struct Foo {
+ // CHECK: define linkonce_odr void @_ZN3Foo3fooEv
+ static void foo() __attribute__((constructor)) {
+ bar();
+ }
+};
diff --git a/clang/test/CodeGenCXX/constructor-conversion.cpp b/clang/test/CodeGenCXX/constructor-conversion.cpp
new file mode 100644
index 0000000..f503463
--- /dev/null
+++ b/clang/test/CodeGenCXX/constructor-conversion.cpp
@@ -0,0 +1,55 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+extern "C" int printf(...);
+
+class X { // ...
+public:
+ X(int) : iX(2), fX(2.3) , name("HELLO\n") { }
+
+ X(const char* arg, int ix=0) { iX = ix; fX = 6.0; name = arg+ix; }
+ X(): iX(100), fX(1.2) {}
+ int iX;
+ float fX;
+ const char *name;
+ void pr(void) {
+ printf("iX = %d fX = %f name = %s\n", iX, fX, name);
+ }
+};
+
+void g(X arg) {
+ arg.pr();
+}
+
+void f(X arg) {
+ X a = 1; // a = X(1)
+
+ a.pr();
+
+ X b = "Jessie"; // b=X("Jessie",0)
+
+ b.pr();
+
+
+ a = 2; // a = X(2)
+
+ a.pr();
+}
+
+
+int main() {
+ X x;
+ f(x);
+ g(3); // g(X(3))
+}
+
+// CHECK-LP64: callq __ZN1XC1Ei
+// CHECK-LP64: callq __ZN1XC1EPKci
+// CHECK-LP64: callq __ZN1XC1Ev
+
+// CHECK-LP32: calll L__ZN1XC1Ei
+// CHECK-LP32: calll L__ZN1XC1EPKci
+// CHECK-LP32: calll L__ZN1XC1Ev
diff --git a/clang/test/CodeGenCXX/constructor-convert.cpp b/clang/test/CodeGenCXX/constructor-convert.cpp
new file mode 100644
index 0000000..7feeaa9
--- /dev/null
+++ b/clang/test/CodeGenCXX/constructor-convert.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+
+// PR5775
+class Twine {
+public:
+ Twine(const char *Str) { }
+};
+
+static void error(const Twine &Message) {}
+
+template<typename>
+struct opt_storage {
+ void f() {
+ error("cl::location(x) specified more than once!");
+ }
+};
+
+void f(opt_storage<int> o) {
+ o.f();
+}
diff --git a/clang/test/CodeGenCXX/constructor-default-arg.cpp b/clang/test/CodeGenCXX/constructor-default-arg.cpp
new file mode 100644
index 0000000..32086c1
--- /dev/null
+++ b/clang/test/CodeGenCXX/constructor-default-arg.cpp
@@ -0,0 +1,40 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+extern "C" int printf(...);
+
+
+struct C {
+ C() : iC(6) {}
+ int iC;
+};
+
+int foo() {
+ return 6;
+};
+
+class X { // ...
+public:
+ X(int) {}
+ X(const X&, int i = 1, int j = 2, int k = foo()) {
+ printf("X(const X&, %d, %d, %d)\n", i, j, k);
+ }
+};
+
+int main() {
+ X a(1);
+ X b(a, 2);
+ X c = b;
+ X d(a, 5, 6);
+}
+
+// CHECK-LP64: callq __ZN1XC1ERKS_iii
+// CHECK-LP64: callq __ZN1XC1ERKS_iii
+// CHECK-LP64: callq __ZN1XC1ERKS_iii
+
+// CHECK-LP32: calll L__ZN1XC1ERKS_iii
+// CHECK-LP32: calll L__ZN1XC1ERKS_iii
+// CHECK-LP32: calll L__ZN1XC1ERKS_iii
diff --git a/clang/test/CodeGenCXX/constructor-direct-call.cpp b/clang/test/CodeGenCXX/constructor-direct-call.cpp
new file mode 100644
index 0000000..75e6f21
--- /dev/null
+++ b/clang/test/CodeGenCXX/constructor-direct-call.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -Wmicrosoft %s -emit-llvm -o - | FileCheck %s
+
+class Test1 {
+public:
+ int a;
+};
+
+void f1() {
+ Test1 var;
+ var.Test1::Test1();
+
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %{{.*}}, i8* %{{.*}}, i32 4, i32 4, i1 false)
+ var.Test1::Test1(var);
+}
+
+class Test2 {
+public:
+ Test2() { a = 10; b = 10; }
+ int a;
+ int b;
+};
+
+void f2() {
+ // CHECK: %var = alloca %class.Test2, align 4
+ // CHECK-NEXT: call void @_ZN5Test2C1Ev(%class.Test2* %var)
+ Test2 var;
+
+ // CHECK-NEXT: call void @_ZN5Test2C1Ev(%class.Test2* %var)
+ var.Test2::Test2();
+
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %{{.*}}, i8* %{{.*}}, i32 8, i32 4, i1 false)
+ var.Test2::Test2(var);
+}
+
+
+
+
+class Test3 {
+public:
+ Test3() { a = 10; b = 15; c = 20; }
+ Test3(const Test3& that) { a = that.a; b = that.b; c = that.c; }
+ int a;
+ int b;
+ int c;
+};
+
+void f3() {
+ // CHECK: call void @_ZN5Test3C1Ev(%class.Test3* %var)
+ Test3 var;
+
+ // CHECK-NEXT: call void @_ZN5Test3C1Ev(%class.Test3* %var2)
+ Test3 var2;
+
+ // CHECK-NEXT: call void @_ZN5Test3C1Ev(%class.Test3* %var)
+ var.Test3::Test3();
+
+ // CHECK-NEXT: call void @_ZN5Test3C1ERKS_(%class.Test3* %var, %class.Test3* %var2)
+ var.Test3::Test3(var2);
+}
+
diff --git a/clang/test/CodeGenCXX/constructor-for-array-members.cpp b/clang/test/CodeGenCXX/constructor-for-array-members.cpp
new file mode 100644
index 0000000..7a365cd
--- /dev/null
+++ b/clang/test/CodeGenCXX/constructor-for-array-members.cpp
@@ -0,0 +1,44 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+extern "C" int printf(...);
+
+int i = 1234;
+float vf = 1.00;
+
+struct S {
+ S() : iS(i++), f1(vf++) {printf("S::S()\n");}
+ ~S(){printf("S::~S(iS = %d f1 = %f)\n", iS, f1); }
+ int iS;
+ float f1;
+};
+
+struct M {
+ double dM;
+ S ARR_S[3];
+ void pr() {
+ for (int i = 0; i < 3; i++)
+ printf("ARR_S[%d].iS = %d ARR_S[%d].f1 = %f\n", i, ARR_S[i].iS, i, ARR_S[i].f1);
+
+ for (int i = 0; i < 2; i++)
+ for (int j = 0; j < 3; j++)
+ for (int k = 0; k < 4; k++)
+ printf("MULTI_ARR[%d][%d][%d].iS = %d MULTI_ARR[%d][%d][%d].f1 = %f\n",
+ i,j,k, MULTI_ARR[i][j][k].iS, i,j,k, MULTI_ARR[i][j][k].f1);
+
+ }
+
+ S MULTI_ARR[2][3][4];
+};
+
+int main() {
+ M m1;
+ m1.pr();
+}
+
+// CHECK-LP64: callq __ZN1SC1Ev
+
+// CHECK-LP32: calll L__ZN1SC1Ev
diff --git a/clang/test/CodeGenCXX/constructor-init-reference.cpp b/clang/test/CodeGenCXX/constructor-init-reference.cpp
new file mode 100644
index 0000000..5e75159
--- /dev/null
+++ b/clang/test/CodeGenCXX/constructor-init-reference.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | grep "store i32\* @x, i32\*\*"
+
+int x;
+struct A {
+ int& y;
+ A() : y(x) {}
+};
+A z;
+
diff --git a/clang/test/CodeGenCXX/constructor-init.cpp b/clang/test/CodeGenCXX/constructor-init.cpp
new file mode 100644
index 0000000..9f808f6
--- /dev/null
+++ b/clang/test/CodeGenCXX/constructor-init.cpp
@@ -0,0 +1,222 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 %s -emit-llvm -o %t
+// RUN: FileCheck %s < %t
+// RUN: FileCheck -check-prefix=CHECK-PR10720 %s < %t
+
+extern "C" int printf(...);
+
+struct M {
+ M() { printf("M()\n"); }
+ M(int i) { iM = i; printf("M(%d)\n", i); }
+ int iM;
+ void MPR() {printf("iM = %d\n", iM); };
+};
+
+struct P {
+ P() { printf("P()\n"); }
+ P(int i) { iP = i; printf("P(%d)\n", i); }
+ int iP;
+ void PPR() {printf("iP = %d\n", iP); };
+};
+
+struct Q {
+ Q() { printf("Q()\n"); }
+ Q(int i) { iQ = i; printf("Q(%d)\n", i); }
+ int iQ;
+ void QPR() {printf("iQ = %d\n", iQ); };
+};
+
+struct N : M , P, Q {
+ N() : f1(1.314), P(2000), ld(00.1234+f1), M(1000), Q(3000),
+ d1(3.4567), i1(1234), m1(100) { printf("N()\n"); }
+ M m1;
+ M m2;
+ float f1;
+ int i1;
+ float d1;
+ void PR() {
+ printf("f1 = %f d1 = %f i1 = %d ld = %f \n", f1,d1,i1, ld);
+ MPR();
+ PPR();
+ QPR();
+ printf("iQ = %d\n", iQ);
+ printf("iP = %d\n", iP);
+ printf("iM = %d\n", iM);
+ // FIXME. We don't yet support this syntax.
+ // printf("iQ = %d\n", (*this).iQ);
+ printf("iQ = %d\n", this->iQ);
+ printf("iP = %d\n", this->iP);
+ printf("iM = %d\n", this->iM);
+ }
+ float ld;
+ float ff;
+ M arr_m[3];
+ P arr_p[1][3];
+ Q arr_q[2][3][4];
+};
+
+int main() {
+ M m1;
+
+ N n1;
+ n1.PR();
+}
+
+// PR5826
+template <class T> struct A {
+ A() {}
+ A(int) {}
+ A(const A&) {}
+ ~A() {}
+ operator int() {return 0;}
+};
+
+// CHECK: define void @_Z1fv()
+void f() {
+ // CHECK: call void @_ZN1AIsEC1Ei
+ A<short> a4 = 97;
+
+ // CHECK-NEXT: store i32 17
+ int i = 17;
+
+ // CHECK-NEXT: call void @_ZN1AIsED1Ev
+ // CHECK-NOT: call void @_ZN1AIsED1Ev
+ // CHECK: ret void
+}
+
+// Make sure we initialize the vtable pointer if it's required by a
+// base initializer.
+namespace InitVTable {
+ struct A { A(int); };
+ struct B : A {
+ virtual int foo();
+ B();
+ B(int);
+ };
+
+ // CHECK: define void @_ZN10InitVTable1BC2Ev(%"struct.InitVTable::B"* %this) unnamed_addr
+ // CHECK: [[T0:%.*]] = bitcast [[B:%.*]]* [[THIS:%.*]] to i8***
+ // CHECK-NEXT: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN10InitVTable1BE, i64 0, i64 2), i8*** [[T0]]
+ // CHECK: [[VTBL:%.*]] = load i32 ([[B]]*)*** {{%.*}}
+ // CHECK-NEXT: [[FNP:%.*]] = getelementptr inbounds i32 ([[B]]*)** [[VTBL]], i64 0
+ // CHECK-NEXT: [[FN:%.*]] = load i32 ([[B]]*)** [[FNP]]
+ // CHECK-NEXT: [[ARG:%.*]] = call i32 [[FN]]([[B]]* [[THIS]])
+ // CHECK-NEXT: call void @_ZN10InitVTable1AC2Ei({{.*}}* {{%.*}}, i32 [[ARG]])
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [[B]]* [[THIS]] to i8***
+ // CHECK-NEXT: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN10InitVTable1BE, i64 0, i64 2), i8*** [[T0]]
+ // CHECK-NEXT: ret void
+ B::B() : A(foo()) {}
+
+ // CHECK: define void @_ZN10InitVTable1BC2Ei(%"struct.InitVTable::B"* %this, i32 %x) unnamed_addr
+ // CHECK: [[ARG:%.*]] = add nsw i32 {{%.*}}, 5
+ // CHECK-NEXT: call void @_ZN10InitVTable1AC2Ei({{.*}}* {{%.*}}, i32 [[ARG]])
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [[B]]* {{%.*}} to i8***
+ // CHECK-NEXT: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN10InitVTable1BE, i64 0, i64 2), i8*** [[T0]]
+ // CHECK-NEXT: ret void
+ B::B(int x) : A(x + 5) {}
+}
+
+namespace rdar9694300 {
+ struct X {
+ int x;
+ };
+
+ // CHECK: define void @_ZN11rdar96943001fEv
+ void f() {
+ // CHECK: alloca
+ X x;
+ // CHECK-NEXT: [[I:%.*]] = alloca i32
+ // CHECK-NEXT: store i32 17, i32* [[I]]
+ int i = 17;
+ // CHECK-NEXT: ret void
+ }
+}
+
+template<typename T>
+struct X {
+ X(const X &);
+
+ T *start;
+ T *end;
+};
+
+template<typename T> struct X;
+
+// Make sure that the instantiated constructor initializes start and
+// end properly.
+// CHECK: define linkonce_odr void @_ZN1XIiEC2ERKS0_(%struct.X* %this, %struct.X* %other) unnamed_addr
+// CHECK: {{store.*null}}
+// CHECK: {{store.*null}}
+// CHECK: ret
+template<typename T>
+X<T>::X(const X &other) : start(0), end(0) { }
+
+X<int> get_X(X<int> x) { return x; }
+
+namespace PR10720 {
+ struct X {
+ X(const X&);
+ X(X&&);
+ X& operator=(const X&);
+ X& operator=(X&&);
+ ~X();
+ };
+
+ struct pair2 {
+ X second[4];
+
+ // CHECK-PR10720: define linkonce_odr {{.*}} @_ZN7PR107205pair2aSERKS0_
+ // CHECK-PR10720: load
+ // CHECK-PR10720: icmp ne
+ // CHECK-PR10720-NEXT: br i1
+ // CHECK-PR10720: call {{.*}} @_ZN7PR107201XaSERKS0_
+ // CHECK-PR10720: ret
+ pair2 &operator=(const pair2&) = default;
+
+ // CHECK-PR10720: define linkonce_odr {{.*}} @_ZN7PR107205pair2aSEOS0_
+ // CHECK-PR10720: load
+ // CHECK-PR10720: icmp ne
+ // CHECK-PR10720-NEXT: br i1
+ // CHECK-PR10720: call {{.*}} @_ZN7PR107201XaSEOS0_
+ // CHECK-PR10720: ret
+ pair2 &operator=(pair2&&) = default;
+
+ // CHECK-PR10720: define linkonce_odr void @_ZN7PR107205pair2C2EOS0_
+ // CHECK-PR10720-NOT: ret
+ // CHECK-PR10720: load
+ // CHECK-PR10720: icmp ult
+ // CHECK-PR10720-NEXT: br i1
+ // CHECK-PR10720: call void @_ZN7PR107201XC1EOS0_
+ // CHECK-PR10720-NEXT: br label
+ // CHECK-PR10720: ret void
+ pair2(pair2&&) = default;
+
+ // CHECK-PR10720: define linkonce_odr void @_ZN7PR107205pair2C2ERKS0_
+ // CHECK-PR10720-NOT: ret
+ // CHECK-PR10720: load
+ // CHECK-PR10720: icmp ult
+ // CHECK-PR10720-NEXT: br i1
+ // CHECK-PR10720: call void @_ZN7PR107201XC1ERKS0_
+ // CHECK-PR10720-NEXT: br label
+ // CHECK-PR10720: ret void
+ pair2(const pair2&) = default;
+ };
+
+ struct pair : X { // Make the copy constructor non-trivial, so we actually generate it.
+ int second[4];
+ // CHECK-PR10720: define linkonce_odr void @_ZN7PR107204pairC2ERKS0_
+ // CHECK-PR10720-NOT: ret
+ // CHECK-PR10720: call void @llvm.memcpy
+ // CHECK-PR10720-NEXT: ret void
+ pair(const pair&) = default;
+ };
+
+ void foo(const pair &x, const pair2 &x2) {
+ pair y(x);
+ pair2 y2(x2);
+ pair2 y2m(static_cast<pair2&&>(y2));
+
+ y2 = x2;
+ y2m = static_cast<pair2&&>(y2);
+ }
+
+}
diff --git a/clang/test/CodeGenCXX/constructor-template.cpp b/clang/test/CodeGenCXX/constructor-template.cpp
new file mode 100644
index 0000000..fe4687c
--- /dev/null
+++ b/clang/test/CodeGenCXX/constructor-template.cpp
@@ -0,0 +1,54 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+// PR4826
+struct A {
+ A() {
+ }
+};
+
+template<typename T>
+struct B {
+ B(T) {}
+
+ A nodes;
+};
+
+
+// PR4853
+template <typename T> class List {
+public:
+ List(){ } // List<BinomialNode<int>*>::List() remains undefined.
+ ~List() {}
+};
+
+template <typename T> class Node {
+ int i;
+public:
+ Node(){ } // Node<BinomialNode<int>*>::Node() remains undefined.
+ ~Node() {}
+};
+
+
+template<typename T> class BinomialNode : Node<BinomialNode<T>*> {
+public:
+ BinomialNode(T value) {}
+ List<BinomialNode<T>*> nodes;
+};
+
+int main() {
+ B<int> *n = new B<int>(4);
+ BinomialNode<int> *node = new BinomialNode<int>(1);
+ delete node;
+}
+
+// CHECK-LP64: __ZN4NodeIP12BinomialNodeIiEEC2Ev:
+// CHECK-LP64: __ZN4ListIP12BinomialNodeIiEEC1Ev:
+// CHECK-LP64: __ZN4ListIP12BinomialNodeIiEED1Ev:
+
+// CHECK-LP32: __ZN4NodeIP12BinomialNodeIiEEC2Ev:
+// CHECK-LP32: __ZN4ListIP12BinomialNodeIiEEC1Ev:
+// CHECK-LP32: __ZN4ListIP12BinomialNodeIiEED1Ev:
diff --git a/clang/test/CodeGenCXX/constructors.cpp b/clang/test/CodeGenCXX/constructors.cpp
new file mode 100644
index 0000000..9e2da31
--- /dev/null
+++ b/clang/test/CodeGenCXX/constructors.cpp
@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -emit-llvm -o - | FileCheck %s
+
+struct Member { int x; Member(); Member(int); Member(const Member &); };
+struct VBase { int x; VBase(); VBase(int); VBase(const VBase &); };
+
+struct ValueClass {
+ ValueClass(int x, int y) : x(x), y(y) {}
+ int x;
+ int y;
+}; // subject to ABI trickery
+
+
+
+/* Test basic functionality. */
+struct A {
+ A(struct Undeclared &);
+ A(ValueClass);
+ Member mem;
+};
+
+A::A(struct Undeclared &ref) : mem(0) {}
+
+// Check that delegation works.
+// CHECK: define void @_ZN1AC1ER10Undeclared(%struct.A* %this, %struct.Undeclared* %ref) unnamed_addr
+// CHECK: call void @_ZN1AC2ER10Undeclared(
+
+// CHECK: define void @_ZN1AC2ER10Undeclared(%struct.A* %this, %struct.Undeclared* %ref) unnamed_addr
+// CHECK: call void @_ZN6MemberC1Ei(
+
+A::A(ValueClass v) : mem(v.y - v.x) {}
+
+// CHECK: define void @_ZN1AC1E10ValueClass(%struct.A* %this, i64 %v.coerce) unnamed_addr
+// CHECK: call void @_ZN1AC2E10ValueClass(
+
+// CHECK: define void @_ZN1AC2E10ValueClass(%struct.A* %this, i64 %v.coerce) unnamed_addr
+// CHECK: call void @_ZN6MemberC1Ei(
+
+
+/* Test that things work for inheritance. */
+struct B : A {
+ B(struct Undeclared &);
+ Member mem;
+};
+
+B::B(struct Undeclared &ref) : A(ref), mem(1) {}
+
+// CHECK: define void @_ZN1BC1ER10Undeclared(%struct.B* %this, %struct.Undeclared* %ref) unnamed_addr
+// CHECK: call void @_ZN1BC2ER10Undeclared(
+
+// CHECK: define void @_ZN1BC2ER10Undeclared(%struct.B* %this, %struct.Undeclared* %ref) unnamed_addr
+// CHECK: call void @_ZN1AC2ER10Undeclared(
+// CHECK: call void @_ZN6MemberC1Ei(
+
+
+
+/* Test that the delegation optimization is disabled for classes with
+ virtual bases (for now). This is necessary because a vbase
+ initializer could access one of the parameter variables by
+ reference. That's a solvable problem, but let's not solve it right
+ now. */
+struct C : virtual A {
+ C(int);
+ Member mem;
+};
+C::C(int x) : A(ValueClass(x, x+1)), mem(x * x) {}
+
+// CHECK: define void @_ZN1CC1Ei(%struct.C* %this, i32 %x) unnamed_addr
+// CHECK: call void @_ZN10ValueClassC1Eii(
+// CHECK: call void @_ZN1AC2E10ValueClass(
+// CHECK: call void @_ZN6MemberC1Ei(
+
+// CHECK: define void @_ZN1CC2Ei(%struct.C* %this, i8** %vtt, i32 %x) unnamed_addr
+// CHECK: call void @_ZN6MemberC1Ei(
+
+
+
+/* Test that the delegation optimization is disabled for varargs
+ constructors. */
+struct D : A {
+ D(int, ...);
+ Member mem;
+};
+
+D::D(int x, ...) : A(ValueClass(x, x+1)), mem(x*x) {}
+
+// CHECK: define void @_ZN1DC1Eiz(%struct.D* %this, i32 %x, ...) unnamed_addr
+// CHECK: call void @_ZN10ValueClassC1Eii(
+// CHECK: call void @_ZN1AC2E10ValueClass(
+// CHECK: call void @_ZN6MemberC1Ei(
+
+// CHECK: define void @_ZN1DC2Eiz(%struct.D* %this, i32 %x, ...) unnamed_addr
+// CHECK: call void @_ZN10ValueClassC1Eii(
+// CHECK: call void @_ZN1AC2E10ValueClass(
+// CHECK: call void @_ZN6MemberC1Ei(
+
+
+// PR6622: this shouldn't crash
+namespace test0 {
+ struct A {};
+ struct B : virtual A { int x; };
+ struct C : B {};
+
+ void test(C &in) {
+ C tmp = in;
+ }
+}
+
+namespace test1 {
+ struct A { A(); void *ptr; };
+ struct B { B(); int x; A a[0]; };
+ B::B() {}
+ // CHECK: define void @_ZN5test11BC2Ev(
+ // CHECK: [[THIS:%.*]] = load [[B:%.*]]**
+ // CHECK-NEXT: ret void
+}
diff --git a/clang/test/CodeGenCXX/conversion-function.cpp b/clang/test/CodeGenCXX/conversion-function.cpp
new file mode 100644
index 0000000..76d9e02
--- /dev/null
+++ b/clang/test/CodeGenCXX/conversion-function.cpp
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+// XFAIL: *
+extern "C" int printf(...);
+struct S {
+ operator int();
+};
+
+S::operator int() {
+ return 10;
+}
+
+int f(S s) {
+ return s;
+}
+
+class X { // ...
+ public: operator int() { printf("operator int()\n"); return iX; }
+ public: operator float() { printf("operator float()\n"); return fX; }
+ X() : iX(100), fX(1.234) {}
+ int iX;
+ float fX;
+};
+
+X x;
+
+struct Z {
+ operator X() { printf("perator X()\n"); x.iX += iZ; x.fX += fZ; return x; }
+ int iZ;
+ float fZ;
+ Z() : iZ(1), fZ(1.00) {}
+};
+
+Z z;
+
+class Y { // ...
+ public: operator Z(){printf("perator Z()\n"); return z; }
+};
+
+Y y;
+
+int count=0;
+class O { // ...
+public:
+ operator int(){ return ++iO; }
+ O() : iO(count++) {}
+ int iO;
+};
+
+void g(O a, O b) {
+ int i = (a) ? 1+a : 0;
+ int j = (a&&b) ? a+b : i;
+ if (a) { }
+ printf("i = %d j = %d a.iO = %d b.iO = %d\n", i, j, a.iO, b.iO);
+}
+
+int main() {
+ int c = X(Z(y)); // OK: y.operator Z().operator X().operator int()
+ printf("c = %d\n", c);
+ float f = X(Z(y));
+ printf("f = %f\n", f);
+ int i = x;
+ printf("i = %d float = %f\n", i, float(x));
+ i = int(X(Z(y)));
+ f = float(X(Z(y)));
+ printf("i = %d float = %f\n", i,f);
+ f = (float)x;
+ i = (int)x;
+ printf("i = %d float = %f\n", i,f);
+
+ int d = (X)((Z)y);
+ printf("d = %d\n", d);
+
+ int e = (int)((X)((Z)y));
+ printf("e = %d\n", e);
+ O o1, o2;
+ g(o1, o2);
+}
+
+// Test. Conversion in base class is visible in derived class.
+class XB {
+ int a;
+public:
+ operator int();
+};
+
+class Yb : public XB {
+ double b;
+public:
+ operator char();
+};
+
+void f(Yb& a) {
+ int i = a; // OK. calls XB::operator int();
+ char ch = a; // OK. calls Yb::operator char();
+}
+
+struct A {
+ operator int() const;
+};
+
+// CHECK-LP64: .globl __ZN1ScviEv
+// CHECK-LP64-NEXT: __ZN1ScviEv:
+// CHECK-LP64: callq __ZN1Ycv1ZEv
+// CHECK-LP64: callq __ZN1Zcv1XEv
+// CHECK-LP64: callq __ZN1XcviEv
+// CHECK-LP64: callq __ZN1XcvfEv
+// CHECK-LP64: callq __ZN2XBcviEv
+// CHECK-LP64: callq __ZN2YbcvcEv
+
+// CHECK-LP32: .globl __ZN1ScviEv
+// CHECK-LP32-NEXT: __ZN1ScviEv:
+// CHECK-LP32: call L__ZN1Ycv1ZEv
+// CHECK-LP32: call L__ZN1Zcv1XEv
+// CHECK-LP32: call L__ZN1XcviEv
+// CHECK-LP32: call L__ZN1XcvfEv
+// CHECK-LP32: call L__ZN2XBcviEv
+// CHECK-LP32: call L__ZN2YbcvcEv
diff --git a/clang/test/CodeGenCXX/conversion-operator-base.cpp b/clang/test/CodeGenCXX/conversion-operator-base.cpp
new file mode 100644
index 0000000..8fbeadf
--- /dev/null
+++ b/clang/test/CodeGenCXX/conversion-operator-base.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm-only %s -verify
+// PR5730
+
+struct A { operator int(); float y; };
+struct B : A { double z; };
+void a() { switch(B()) {} }
+
diff --git a/clang/test/CodeGenCXX/convert-to-fptr.cpp b/clang/test/CodeGenCXX/convert-to-fptr.cpp
new file mode 100644
index 0000000..425f79d
--- /dev/null
+++ b/clang/test/CodeGenCXX/convert-to-fptr.cpp
@@ -0,0 +1,47 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+extern "C" int printf(...);
+
+int f1(int arg) { return arg; };
+
+int f2(float arg) { return int(arg); };
+
+typedef int (*fp1)(int);
+
+typedef int (*fp2)(float);
+
+struct A {
+ operator fp1() { return f1; }
+ operator fp2() { return f2; }
+} a;
+
+
+// Test for function reference.
+typedef int (&fr1)(int);
+typedef int (&fr2)(float);
+
+struct B {
+ operator fr1() { return f1; }
+ operator fr2() { return f2; }
+} b;
+
+int main()
+{
+ int i = a(10); // Calls f1 via pointer returned from conversion function
+ printf("i = %d\n", i);
+
+ int j = b(20); // Calls f1 via pointer returned from conversion function
+ printf("j = %d\n", j);
+ return 0;
+}
+
+// CHECK-LP64: callq __ZN1AcvPFiiEEv
+// CHECK-LP64: callq __ZN1BcvRFiiEEv
+
+// CHECK-LP32: calll L__ZN1AcvPFiiEEv
+// CHECK-LP32: calll L__ZN1BcvRFiiEEv
+
diff --git a/clang/test/CodeGenCXX/copy-assign-synthesis-1.cpp b/clang/test/CodeGenCXX/copy-assign-synthesis-1.cpp
new file mode 100644
index 0000000..46d0483
--- /dev/null
+++ b/clang/test/CodeGenCXX/copy-assign-synthesis-1.cpp
@@ -0,0 +1,109 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+extern "C" int printf(...);
+
+struct B {
+ B() : B1(3.14), B2(3.15), auB2(3.16) {}
+ float B1;
+ float B2;
+ void pr() {
+ printf("B1 = %f B2 = %f auB1 = %f\n", B1, B2, auB1);
+ }
+
+ B& operator=(const B& arg) { B1 = arg.B1; B2 = arg.B2;
+ auB1 = arg.auB1; return *this; }
+ union {
+ float auB1;
+ float auB2;
+ };
+};
+
+struct M {
+ M() : M1(10), M2(11) , auM1(12) {}
+ int M1;
+ int M2;
+ void pr() {
+ printf("M1 = %d M2 = %d auM1 = %d auM2 = %d\n", M1, M2, auM1, auM2);
+ }
+ union {
+ int auM1;
+ int auM2;
+ };
+};
+
+struct N : B {
+ N() : N1(20), N2(21) {}
+ int N1;
+ int N2;
+ void pr() {
+ printf("N1 = %d N2 = %d\n", N1, N2);
+ for (unsigned i = 0; i < 3; i++)
+ for (unsigned j = 0; j < 2; j++)
+ printf("arr_b[%d][%d] = %f\n", i,j,arr_b[i][j].B1);
+ B::pr();
+ }
+ N& operator=(const N& arg) {
+ N1 = arg.N1; N2 = arg.N2;
+ for (unsigned i = 0; i < 3; i++)
+ for (unsigned j = 0; j < 2; j++)
+ arr_b[i][j] = arg.arr_b[i][j];
+ return *this;
+ }
+ B arr_b[3][2];
+};
+
+struct Q : B {
+ Q() : Q1(30), Q2(31) {}
+ int Q1;
+ int Q2;
+ void pr() {
+ printf("Q1 = %d Q2 = %d\n", Q1, Q2);
+ }
+};
+
+
+struct X : M , N {
+ X() : d(0.0), d1(1.1), d2(1.2), d3(1.3) {}
+ double d;
+ double d1;
+ double d2;
+ double d3;
+ void pr() {
+ printf("d = %f d1 = %f d2 = %f d3 = %f\n", d, d1,d2,d3);
+ M::pr(); N::pr();
+ q1.pr(); q2.pr();
+ }
+
+ Q q1, q2;
+};
+
+
+X srcX;
+X dstX;
+X dstY;
+
+int main() {
+ dstY = dstX = srcX;
+ srcX.pr();
+ dstX.pr();
+ dstY.pr();
+}
+
+// CHECK-LP64: .globl __ZN1XaSERKS_
+// CHECK-LP64: .weak_definition __ZN1XaSERKS_
+// CHECK-LP64: __ZN1XaSERKS_:
+// CHECK-LP64: .globl __ZN1QaSERKS_
+// CHECK-LP64: .weak_definition __ZN1QaSERKS_
+// CHECK-LP64: __ZN1QaSERKS_:
+
+// CHECK-LP32: .globl __ZN1XaSERKS_
+// CHECK-LP32: .weak_definition __ZN1XaSERKS_
+// CHECK-LP32: __ZN1XaSERKS_:
+// CHECK-LP32: .globl __ZN1QaSERKS_
+// CHECK-LP32: .weak_definition __ZN1QaSERKS_
+// CHECK-LP32: __ZN1QaSERKS_:
+
diff --git a/clang/test/CodeGenCXX/copy-assign-synthesis-2.cpp b/clang/test/CodeGenCXX/copy-assign-synthesis-2.cpp
new file mode 100644
index 0000000..c25e046
--- /dev/null
+++ b/clang/test/CodeGenCXX/copy-assign-synthesis-2.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+struct A {};
+A& (A::*x)(const A&) = &A::operator=;
+// CHECK: define linkonce_odr %struct.A* @_ZN1AaSERKS_
diff --git a/clang/test/CodeGenCXX/copy-assign-synthesis-3.cpp b/clang/test/CodeGenCXX/copy-assign-synthesis-3.cpp
new file mode 100644
index 0000000..ce4640a
--- /dev/null
+++ b/clang/test/CodeGenCXX/copy-assign-synthesis-3.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm-only -verify %s
+
+struct A {
+ A& operator=(A&);
+};
+
+struct B {
+ void operator=(B);
+};
+
+struct C {
+ A a;
+ B b;
+ float c;
+ int (A::*d)();
+ _Complex float e;
+ int f[10];
+ A g[2];
+ B h[2];
+};
+void a(C& x, C& y) {
+ x = y;
+}
+
diff --git a/clang/test/CodeGenCXX/copy-assign-synthesis.cpp b/clang/test/CodeGenCXX/copy-assign-synthesis.cpp
new file mode 100644
index 0000000..e9fc0c3
--- /dev/null
+++ b/clang/test/CodeGenCXX/copy-assign-synthesis.cpp
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: grep "_ZN1XaSERK1X" %t | count 0
+
+extern "C" int printf(...);
+
+struct B {
+ B() : B1(3.14), B2(3.15), auB2(3.16) {}
+ float B1;
+ float B2;
+ void pr() {
+ printf("B1 = %f B2 = %f auB1 = %f\n", B1, B2, auB1);
+ }
+
+ union {
+ float auB1;
+ float auB2;
+ };
+};
+
+struct M {
+ M() : M1(10), M2(11) , auM1(12) {}
+ int M1;
+ int M2;
+ void pr() {
+ printf("M1 = %d M2 = %d auM1 = %d auM2 = %d\n", M1, M2, auM1, auM2);
+ }
+ union {
+ int auM1;
+ int auM2;
+ };
+};
+
+struct N : B {
+ N() : N1(20), N2(21) {}
+ int N1;
+ int N2;
+ void pr() {
+ printf("N1 = %d N2 = %d\n", N1, N2);
+ B::pr();
+ }
+};
+
+struct Q {
+ Q() : Q1(30), Q2(31) {}
+ int Q1;
+ int Q2;
+ void pr() {
+ printf("Q1 = %d Q2 = %d\n", Q1, Q2);
+ }
+};
+
+
+struct X : M , N {
+ X() : d(0.0), d1(1.1), d2(1.2), d3(1.3) {}
+ double d;
+ double d1;
+ double d2;
+ double d3;
+ void pr() {
+ printf("d = %f d1 = %f d2 = %f d3 = %f\n", d, d1,d2,d3);
+ M::pr(); N::pr();
+ q1.pr(); q2.pr();
+ }
+
+ Q q1, q2;
+};
+
+
+X srcX;
+X dstX;
+X dstY;
+
+int main() {
+ dstY = dstX = srcX;
+ srcX.pr();
+ dstX.pr();
+ dstY.pr();
+}
+
diff --git a/clang/test/CodeGenCXX/copy-assign-volatile-synthesis.cpp b/clang/test/CodeGenCXX/copy-assign-volatile-synthesis.cpp
new file mode 100644
index 0000000..eb13503
--- /dev/null
+++ b/clang/test/CodeGenCXX/copy-assign-volatile-synthesis.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// rdar://9894548
+
+typedef unsigned long word_t;
+typedef unsigned long u64_t;
+typedef unsigned int u32_t;
+
+class ioapic_redir_t {
+public:
+ union {
+ struct {
+ word_t vector : 8;
+
+ word_t delivery_mode : 3;
+ word_t dest_mode : 1;
+
+ word_t delivery_status : 1;
+ word_t polarity : 1;
+ word_t irr : 1;
+ word_t trigger_mode : 1;
+
+ word_t mask : 1;
+ word_t _pad0 : 15;
+
+ word_t dest : 8;
+ };
+ volatile u32_t raw[2];
+ volatile u64_t raw64;
+ };
+};
+
+struct ioapic_shadow_struct
+{
+ ioapic_redir_t redirs[24];
+} ioapic_shadow[16];
+
+void init_ioapic(unsigned long ioapic_id)
+{
+ ioapic_redir_t entry;
+ ioapic_shadow[ioapic_id].redirs[3] = entry;
+}
+
+// CHECK: call void @llvm.memcpy
diff --git a/clang/test/CodeGenCXX/copy-constructor-elim-2.cpp b/clang/test/CodeGenCXX/copy-constructor-elim-2.cpp
new file mode 100644
index 0000000..9480cbf
--- /dev/null
+++ b/clang/test/CodeGenCXX/copy-constructor-elim-2.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+struct A { int x; A(int); ~A(); };
+A f() { return A(0); }
+// CHECK: define void @_Z1fv
+// CHECK: call {{.*}} @_ZN1AC1Ei
+// CHECK-NEXT: ret void
+
+// Verify that we do not elide copies when constructing a base class.
+namespace no_elide_base {
+ struct Base {
+ Base(const Base&);
+ ~Base();
+ };
+
+ struct Other {
+ operator Base() const;
+ };
+
+ struct Derived : public virtual Base {
+ Derived(const Other &O);
+ };
+
+ // CHECK: define {{.*}} @_ZN13no_elide_base7DerivedC1ERKNS_5OtherE(%"struct.no_elide_base::Derived"* %this, %"struct.no_elide_base::Other"* %O) unnamed_addr
+ Derived::Derived(const Other &O)
+ // CHECK: call {{.*}} @_ZNK13no_elide_base5OthercvNS_4BaseEEv
+ // CHECK: call {{.*}} @_ZN13no_elide_base4BaseC2ERKS0_
+ // CHECK: call {{.*}} @_ZN13no_elide_base4BaseD1Ev
+ : Base(O)
+ {
+ // CHECK: ret
+ }
+}
+
+// PR8683.
+
+namespace PR8683 {
+
+struct A {
+ A();
+ A(const A&);
+ A& operator=(const A&);
+};
+
+struct B {
+ A a;
+};
+
+void f() {
+ // Verify that we don't mark the copy constructor in this expression as elidable.
+ // CHECK: call {{.*}} @_ZN6PR86831AC1ERKS0_
+ A a = (B().a);
+}
+
+}
+
+namespace PR12139 {
+ struct A {
+ A() : value(1) { }
+ A(A const &, int value = 2) : value(value) { }
+ int value;
+
+ static A makeA() { A a; a.value = 2; return a; }
+ };
+
+ // CHECK: define i32 @_ZN7PR121394testEv
+ int test() {
+ // CHECK: call void @_ZN7PR121391A5makeAEv
+ // CHECK-NEXT: call void @_ZN7PR121391AC1ERKS0_i
+ A a(A::makeA(), 3);
+ // CHECK-NEXT: getelementptr inbounds
+ // CHECK-NEXT: load
+ // CHECK-NEXT: ret i32
+ return a.value;
+ }
+}
+
diff --git a/clang/test/CodeGenCXX/copy-constructor-elim.cpp b/clang/test/CodeGenCXX/copy-constructor-elim.cpp
new file mode 100644
index 0000000..c883584
--- /dev/null
+++ b/clang/test/CodeGenCXX/copy-constructor-elim.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: grep "_ZN1CC1ERK1C" %t | count 0
+// RUN: grep "_ZN1SC1ERK1S" %t | count 0
+
+extern "C" int printf(...);
+
+
+struct C {
+ C() : iC(6) {printf("C()\n"); }
+ C(const C& c) { printf("C(const C& c)\n"); }
+ int iC;
+};
+
+C foo() {
+ return C();
+};
+
+class X { // ...
+public:
+ X(int) {}
+ X(const X&, int i = 1, int j = 2, C c = foo()) {
+ printf("X(const X&, %d, %d, %d)\n", i, j, c.iC);
+ }
+};
+
+
+struct S {
+ S();
+};
+
+S::S() { printf("S()\n"); }
+
+void Call(S) {};
+
+int main() {
+ X a(1);
+ X b(a, 2);
+ X c = b;
+ X d(a, 5, 6);
+ S s;
+ Call(s);
+}
diff --git a/clang/test/CodeGenCXX/copy-constructor-synthesis-2.cpp b/clang/test/CodeGenCXX/copy-constructor-synthesis-2.cpp
new file mode 100644
index 0000000..d028a28
--- /dev/null
+++ b/clang/test/CodeGenCXX/copy-constructor-synthesis-2.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+struct A { virtual void a(); };
+A x(A& y) { return y; }
+
+// CHECK: define linkonce_odr {{.*}} @_ZN1AC1ERKS_(%struct.A* %this, %struct.A*) unnamed_addr
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTV1A, i64 0, i64 2)
diff --git a/clang/test/CodeGenCXX/copy-constructor-synthesis.cpp b/clang/test/CodeGenCXX/copy-constructor-synthesis.cpp
new file mode 100644
index 0000000..68f6805
--- /dev/null
+++ b/clang/test/CodeGenCXX/copy-constructor-synthesis.cpp
@@ -0,0 +1,156 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s
+
+extern "C" int printf(...);
+
+int init = 100;
+
+struct M {
+ int iM;
+ M() : iM(init++) {}
+};
+
+struct N {
+ int iN;
+ N() : iN(200) {}
+ N(N const & arg){this->iN = arg.iN; }
+};
+
+struct P {
+ int iP;
+ P() : iP(init++) {}
+};
+
+
+// CHECK: define linkonce_odr void @_ZN1XC1ERKS_(%struct.X* %this, %struct.X*) unnamed_addr
+struct X : M, N, P { // ...
+ X() : f1(1.0), d1(2.0), i1(3), name("HELLO"), bf1(0xff), bf2(0xabcd),
+ au_i1(1234), au1_4("MASKED") {}
+ P p0;
+ void pr() {
+ printf("iM = %d iN = %d, m1.iM = %d\n", iM, iN, m1.iM);
+ printf("im = %d p0.iP = %d, p1.iP = %d\n", iP, p0.iP, p1.iP);
+ printf("f1 = %f d1 = %f i1 = %d name(%s) \n", f1, d1, i1, name);
+ printf("bf1 = %x bf2 = %x\n", bf1, bf2);
+ printf("au_i2 = %d\n", au_i2);
+ printf("au1_1 = %s\n", au1_1);
+ }
+ M m1;
+ P p1;
+ float f1;
+ double d1;
+ int i1;
+ const char *name;
+ unsigned bf1 : 8;
+ unsigned bf2 : 16;
+ int arr[2];
+ _Complex float complex;
+
+ union {
+ int au_i1;
+ int au_i2;
+ };
+ union {
+ const char * au1_1;
+ float au1_2;
+ int au1_3;
+ const char * au1_4;
+ };
+};
+
+static int ix = 1;
+// class with user-defined copy constructor.
+struct S {
+ S() : iS(ix++) { }
+ S(const S& arg) { *this = arg; }
+ int iS;
+};
+
+// class with trivial copy constructor.
+struct I {
+ I() : iI(ix++) { }
+ int iI;
+};
+
+struct XM {
+ XM() { }
+ double dXM;
+ S ARR_S[3][4][2];
+ void pr() {
+ for (unsigned i = 0; i < 3; i++)
+ for (unsigned j = 0; j < 4; j++)
+ for (unsigned k = 0; k < 2; k++)
+ printf("ARR_S[%d][%d][%d] = %d\n", i,j,k, ARR_S[i][j][k].iS);
+ for (unsigned i = 0; i < 3; i++)
+ for (unsigned k = 0; k < 2; k++)
+ printf("ARR_I[%d][%d] = %d\n", i,k, ARR_I[i][k].iI);
+ }
+ I ARR_I[3][2];
+};
+
+int main() {
+ X a;
+ X b(a);
+ b.pr();
+ X x;
+ X c(x);
+ c.pr();
+
+ XM m0;
+ XM m1 = m0;
+ m1.pr();
+}
+
+struct A {
+};
+
+struct B : A {
+ A &a;
+};
+
+void f(const B &b1) {
+ B b2(b1);
+}
+
+// PR6628
+namespace PR6628 {
+
+struct T {
+ T();
+ ~T();
+
+ double d;
+};
+
+struct A {
+ A(const A &other, const T &t = T(), const T& t2 = T());
+};
+
+struct B : A {
+ A a1;
+ A a2;
+ A a[10];
+};
+
+// Force the copy constructor to be synthesized.
+void f(B b1) {
+ B b2 = b1;
+}
+
+// CHECK: define linkonce_odr void @_ZN6PR66281BC2ERKS0_(%"struct.PR6628::B"* %this, %"struct.PR6628::B"*) unnamed_addr
+// CHECK: call void @_ZN6PR66281TC1Ev
+// CHECK: call void @_ZN6PR66281TC1Ev
+// CHECK: call void @_ZN6PR66281AC2ERKS0_RKNS_1TES5_
+// CHECK: call void @_ZN6PR66281TD1Ev
+// CHECK: call void @_ZN6PR66281TD1Ev
+// CHECK: call void @_ZN6PR66281TC1Ev
+// CHECK: call void @_ZN6PR66281TC1Ev
+// CHECK: call void @_ZN6PR66281AC1ERKS0_RKNS_1TES5_
+// CHECK: call void @_ZN6PR66281TD1Ev
+// CHECK: call void @_ZN6PR66281TD1Ev
+// CHECK: call void @_ZN6PR66281TC1Ev
+// CHECK: call void @_ZN6PR66281TC1Ev
+// CHECK: call void @_ZN6PR66281AC1ERKS0_RKNS_1TES5_
+// CHECK: call void @_ZN6PR66281TD1Ev
+// CHECK: call void @_ZN6PR66281TD1Ev
+}
+
diff --git a/clang/test/CodeGenCXX/copy-in-cplus-object.cpp b/clang/test/CodeGenCXX/copy-in-cplus-object.cpp
new file mode 100644
index 0000000..bdfca5e
--- /dev/null
+++ b/clang/test/CodeGenCXX/copy-in-cplus-object.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 %s -fblocks -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
+
+struct S {
+ S(const char *);
+ ~S();
+};
+
+struct TestObject
+{
+ TestObject(const TestObject& inObj, int def = 100, const S &Silly = "silly");
+ TestObject();
+ ~TestObject();
+ TestObject& operator=(const TestObject& inObj);
+ int version() const;
+
+};
+
+void testRoutine() {
+ TestObject one;
+ int (^V)() = ^{ return one.version(); };
+}
+
+// CHECK: call void @_ZN10TestObjectC1Ev
+// CHECK: call void @_ZN1SC1EPKc
+// CHECK: call void @_ZN10TestObjectC1ERKS_iRK1S
+// CHECK: call void @_ZN1SD1Ev
+// CHECK: call void @_ZN10TestObjectD1Ev
+// CHECK: call void @_ZN10TestObjectD1Ev
diff --git a/clang/test/CodeGenCXX/copy-initialization.cpp b/clang/test/CodeGenCXX/copy-initialization.cpp
new file mode 100644
index 0000000..aecd64e
--- /dev/null
+++ b/clang/test/CodeGenCXX/copy-initialization.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+
+struct Foo {
+ Foo();
+ Foo(const Foo&);
+};
+
+struct Bar {
+ Bar();
+ operator const Foo&() const;
+};
+
+void f(Foo);
+
+// CHECK: define void @_Z1g3Foo(%struct.Foo* %foo)
+void g(Foo foo) {
+ // CHECK: call void @_ZN3BarC1Ev
+ // CHECK: @_ZNK3BarcvRK3FooEv
+ // CHECK: call void @_Z1f3Foo
+ f(Bar());
+ // CHECK: call void @_ZN3FooC1Ev
+ // CHECK: call void @_Z1f3Foo
+ f(Foo());
+ // CHECK: call void @_ZN3FooC1ERKS_
+ // CHECK: call void @_Z1f3Foo
+ f(foo);
+ // CHECK: ret
+}
+
diff --git a/clang/test/CodeGenCXX/cxx-apple-kext.cpp b/clang/test/CodeGenCXX/cxx-apple-kext.cpp
new file mode 100644
index 0000000..e5ec78b
--- /dev/null
+++ b/clang/test/CodeGenCXX/cxx-apple-kext.cpp
@@ -0,0 +1,36 @@
+// RUN: %clangxx -target x86_64-apple-darwin10 %s -flto -S -o - |\
+// RUN: FileCheck --check-prefix=CHECK-NO-KEXT %s
+// RUN: %clangxx -target x86_64-apple-darwin10 %s -fapple-kext -flto -S -o - |\
+// RUN: FileCheck --check-prefix=CHECK-KEXT %s
+
+// CHECK-NO-KEXT-NOT: _GLOBAL__D_a
+// CHECK-NO-KEXT: @is_hosted = global
+// CHECK-NO-KEXT: @_ZTI3foo = {{.*}} @_ZTVN10__cxxabiv117
+// CHECK-NO-KEXT: call i32 @__cxa_atexit({{.*}} @_ZN3fooD1Ev
+// CHECK-NO-KEXT: declare i32 @__cxa_atexit
+
+// CHECK-KEXT: @_ZTV3foo =
+// CHECK-KEXT-NOT: @_ZTVN10__cxxabiv117
+// CHECK-KEXT-NOT: call i32 @__cxa_atexit({{.*}} @_ZN3fooD1Ev
+// CHECK-KEXT-NOT: declare i32 @__cxa_atexit
+// CHECK-KEXT: @is_freestanding = global
+// CHECK-KEXT: _GLOBAL__D_a
+// CHECK-KEXT: call void @_ZN3fooD1Ev(%class.foo* @a)
+
+class foo {
+public:
+ foo();
+ virtual ~foo();
+};
+
+foo a;
+foo::~foo() {}
+
+#if !(__STDC_HOSTED__ == 1)
+int is_freestanding = 1;
+#else
+int is_hosted = 1;
+#endif
+
+extern "C" void f1() {
+}
diff --git a/clang/test/CodeGenCXX/cxx-block-objects.cpp b/clang/test/CodeGenCXX/cxx-block-objects.cpp
new file mode 100644
index 0000000..b989065
--- /dev/null
+++ b/clang/test/CodeGenCXX/cxx-block-objects.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -fblocks -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
+// rdar://8594790
+
+extern "C" {
+extern "C" void *_Block_copy(const void *aBlock);
+extern "C" void _Block_release(const void *aBlock);
+}
+
+class A {
+public:
+ int x;
+ A(const A &o);
+ A();
+ virtual ~A();
+ void hello() const;
+};
+
+int
+main()
+{
+ A a;
+ void (^c)(void) = ((__typeof(^{ a.hello(); }))_Block_copy((const void *)(^{ a.hello(); })));
+ c();
+ _Block_release((const void *)(c));
+ return 0;
+}
+
+// CHECK: define internal void @__copy_helper_block_
+// CHECK: call void @_ZN1AC1ERKS_
+
+
+// CHECK:define internal void @__destroy_helper_block_
+// CHECK: call void @_ZN1AD1Ev
diff --git a/clang/test/CodeGenCXX/cxx0x-defaulted-templates.cpp b/clang/test/CodeGenCXX/cxx0x-defaulted-templates.cpp
new file mode 100644
index 0000000..f4d5ccc
--- /dev/null
+++ b/clang/test/CodeGenCXX/cxx0x-defaulted-templates.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+template <typename T>
+struct X {
+ X();
+};
+
+// CHECK: define {{.*}} @_ZN1XIbEC1Ev
+// CHECK: define {{.*}} @_ZN1XIbEC2Ev
+template <> X<bool>::X() = default;
+
+// CHECK: define weak_odr {{.*}} @_ZN1XIiEC1Ev
+// CHECK: define weak_odr {{.*}} @_ZN1XIiEC2Ev
+template <typename T> X<T>::X() = default;
+template X<int>::X();
+
+// CHECK: define linkonce_odr {{.*}} @_ZN1XIcEC1Ev
+// CHECK: define linkonce_odr {{.*}} @_ZN1XIcEC2Ev
+X<char> x;
diff --git a/clang/test/CodeGenCXX/cxx0x-delegating-ctors.cpp b/clang/test/CodeGenCXX/cxx0x-delegating-ctors.cpp
new file mode 100644
index 0000000..f5684d9
--- /dev/null
+++ b/clang/test/CodeGenCXX/cxx0x-delegating-ctors.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -emit-llvm -fexceptions -fcxx-exceptions -std=c++11 -o - %s | FileCheck %s
+
+struct non_trivial {
+ non_trivial();
+ ~non_trivial() noexcept(false);
+};
+non_trivial::non_trivial() {}
+non_trivial::~non_trivial() noexcept(false) {}
+
+// We use a virtual base to ensure that the constructor
+// delegation optimization (complete->base) can't be
+// performed.
+struct delegator {
+ non_trivial n;
+ delegator();
+ delegator(int);
+ delegator(char);
+ delegator(bool);
+};
+
+delegator::delegator() {
+ throw 0;
+}
+
+
+delegator::delegator(bool)
+{}
+
+// CHECK: define {{.*}} @_ZN9delegatorC1Ec
+// CHECK: {{.*}} @_ZN9delegatorC1Eb
+// CHECK: void @__cxa_throw
+// CHECK: void @_ZSt9terminatev
+// CHECK: {{.*}} @_ZN9delegatorD1Ev
+// CHECK: define {{.*}} @_ZN9delegatorC2Ec
+// CHECK: {{.*}} @_ZN9delegatorC2Eb
+// CHECK: void @__cxa_throw
+// CHECK: void @_ZSt9terminatev
+// CHECK: {{.*}} @_ZN9delegatorD2Ev
+delegator::delegator(char)
+ : delegator(true) {
+ throw 0;
+}
+
+// CHECK: define {{.*}} @_ZN9delegatorC1Ei
+// CHECK: {{.*}} @_ZN9delegatorC1Ev
+// CHECK-NOT: void @_ZSt9terminatev
+// CHECK: ret
+// CHECK-NOT: void @_ZSt9terminatev
+// CHECK: define {{.*}} @_ZN9delegatorC2Ei
+// CHECK: {{.*}} @_ZN9delegatorC2Ev
+// CHECK-NOT: void @_ZSt9terminatev
+// CHECK: ret
+// CHECK-NOT: void @_ZSt9terminatev
+delegator::delegator(int)
+ : delegator()
+{}
diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-array.cpp b/clang/test/CodeGenCXX/cxx0x-initializer-array.cpp
new file mode 100644
index 0000000..b773178
--- /dev/null
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-array.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s | FileCheck %s
+
+struct A { int a[1]; };
+typedef A x[];
+int f() {
+ x{{{1}}};
+ // CHECK: define i32 @_Z1fv
+ // CHECK: store i32 1
+ // (It's okay if the output changes here, as long as we don't crash.)
+}
diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-references.cpp b/clang/test/CodeGenCXX/cxx0x-initializer-references.cpp
new file mode 100644
index 0000000..4c847b8
--- /dev/null
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-references.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s | FileCheck %s
+
+namespace reference {
+ struct A {
+ int i1, i2;
+ };
+
+ void single_init() {
+ // No superfluous instructions allowed here, they could be
+ // hiding extra temporaries.
+
+ // CHECK: store i32 1, i32*
+ // CHECK-NEXT: store i32* %{{.*}}, i32**
+ const int &cri2a = 1;
+
+ // CHECK-NEXT: store i32 1, i32*
+ // CHECK-NEXT: store i32* %{{.*}}, i32**
+ const int &cri1a = {1};
+
+ // CHECK-NEXT: store i32 1, i32*
+ int i = 1;
+ // CHECK-NEXT: store i32* %{{.*}}, i32**
+ int &ri1a = {i};
+
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: memcpy
+ A a{1, 2};
+ // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** %
+ A &ra1a = {a};
+
+ // CHECK-NEXT: ret
+ }
+
+ void reference_to_aggregate() {
+ // CHECK: getelementptr {{.*}}, i32 0, i32 0
+ // CHECK-NEXT: store i32 1
+ // CHECK-NEXT: getelementptr {{.*}}, i32 0, i32 1
+ // CHECK-NEXT: store i32 2
+ // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** %{{.*}}, align
+ const A &ra1{1, 2};
+
+ // CHECK-NEXT: getelementptr inbounds [3 x i32]* %{{.*}}, i{{32|64}} 0, i{{32|64}} 0
+ // CHECK-NEXT: store i32 1
+ // CHECK-NEXT: getelementptr inbounds i32* %{{.*}}, i{{32|64}} 1
+ // CHECK-NEXT: store i32 2
+ // CHECK-NEXT: getelementptr inbounds i32* %{{.*}}, i{{32|64}} 1
+ // CHECK-NEXT: store i32 3
+ // CHECK-NEXT: store [3 x i32]* %{{.*}}, [3 x i32]** %{{.*}}, align
+ const int (&arrayRef)[] = {1, 2, 3};
+
+ // CHECK-NEXT: ret
+ }
+
+ struct B {
+ B();
+ ~B();
+ };
+
+ void single_init_temp_cleanup()
+ {
+ // Ensure lifetime extension.
+
+ // CHECK: call void @_ZN9reference1BC1Ev
+ // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** %
+ const B &rb{ B() };
+ // CHECK: call void @_ZN9reference1BD1Ev
+ }
+
+}
diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp b/clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp
new file mode 100644
index 0000000..10c6966
--- /dev/null
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s | FileCheck %s
+
+void f()
+{
+ // CHECK: store i32 0
+ int i{};
+}
diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
new file mode 100644
index 0000000..14d2f77
--- /dev/null
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - -verify %s
+
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b),
+ __size_(__s)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+}
+
+std::initializer_list<std::initializer_list<int>> pleasefail = {
+ {1, 2}, {3, 4}, {5, 6} // expected-error {{cannot compile}}
+};
diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp
new file mode 100644
index 0000000..c533e45
--- /dev/null
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s | FileCheck %s
+
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation with __size_ replaced by __end_
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ const _E* __end_;
+
+ initializer_list(const _E* __b, const _E* __e)
+ : __begin_(__b),
+ __end_(__e)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __end_(nullptr) {}
+
+ size_t size() const {return __end_ - __begin_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __end_;}
+ };
+}
+
+// CHECK: @_ZL25globalInitList1__initlist = internal global [3 x i32] [i32 1, i32 2, i32 3]
+// CHECK: @globalInitList1 = global {{[^ ]+}} { i32* getelementptr inbounds ([3 x i32]* @_ZL25globalInitList1__initlist, {{[^)]*}}), i32*
+std::initializer_list<int> globalInitList1 = {1, 2, 3};
+
+void fn1(int i) {
+ // CHECK: define void @_Z3fn1i
+ // temporary array
+ // CHECK: [[array:%[^ ]+]] = alloca [3 x i32]
+ // CHECK: getelementptr inbounds [3 x i32]* [[array]], i{{32|64}} 0
+ // CHECK-NEXT: store i32 1, i32*
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: store
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: load
+ // CHECK-NEXT: store
+ // init the list
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: getelementptr inbounds [3 x i32]*
+ // CHECK-NEXT: store i32*
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: getelementptr inbounds [3 x i32]* [[array]], i{{32|64}} 0, i{{32|64}} 3
+ // CHECK-NEXT: store i32*
+ std::initializer_list<int> intlist{1, 2, i};
+}
+
+struct destroyme1 {
+ ~destroyme1();
+};
+struct destroyme2 {
+ ~destroyme2();
+};
+
+
+void fn2() {
+ // CHECK: define void @_Z3fn2v
+ void target(std::initializer_list<destroyme1>);
+ // objects should be destroyed before dm2, after call returns
+ target({ destroyme1(), destroyme1() });
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+}
+
+void fn3() {
+ // CHECK: define void @_Z3fn3v
+ // objects should be destroyed after dm2
+ auto list = { destroyme1(), destroyme1() };
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+ // CHECK: call void @_ZN10destroyme1D1Ev
+}
diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
new file mode 100644
index 0000000..81ce559
--- /dev/null
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -0,0 +1,252 @@
+// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s | FileCheck %s
+
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b),
+ __size_(__s)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+}
+
+struct destroyme1 {
+ ~destroyme1();
+};
+struct destroyme2 {
+ ~destroyme2();
+};
+struct witharg1 {
+ witharg1(const destroyme1&);
+ ~witharg1();
+};
+struct wantslist1 {
+ wantslist1(std::initializer_list<destroyme1>);
+ ~wantslist1();
+};
+
+// CHECK: @_ZL25globalInitList1__initlist = internal global [3 x i32] [i32 1, i32 2, i32 3]
+// CHECK: @globalInitList1 = global %{{[^ ]+}} { i32* getelementptr inbounds ([3 x i32]* @_ZL25globalInitList1__initlist, i32 0, i32 0), i{{32|64}} 3 }
+std::initializer_list<int> globalInitList1 = {1, 2, 3};
+
+// CHECK: @_ZL25globalInitList2__initlist = internal global [2 x %{{[^ ]*}}] zeroinitializer
+// CHECK: @globalInitList2 = global %{{[^ ]+}} { %[[WITHARG:[^ *]+]]* getelementptr inbounds ([2 x
+// CHECK: appending global
+// CHECK: define internal void
+// CHECK: call void @_ZN8witharg1C1ERK10destroyme1(%[[WITHARG]]* getelementptr inbounds ([2 x %[[WITHARG]]]* @_ZL25globalInitList2__initlist, i{{32|64}} 0, i{{32|64}} 0
+// CHECK: call void @_ZN8witharg1C1ERK10destroyme1(%[[WITHARG]]* getelementptr inbounds ([2 x %[[WITHARG]]]* @_ZL25globalInitList2__initlist, i{{32|64}} 0, i{{32|64}} 1
+// CHECK: __cxa_atexit
+// CHECK: call void @_ZN10destroyme1D1Ev
+// CHECK: call void @_ZN10destroyme1D1Ev
+std::initializer_list<witharg1> globalInitList2 = {
+ witharg1(destroyme1()), witharg1(destroyme1())
+};
+
+void fn1(int i) {
+ // CHECK: define void @_Z3fn1i
+ // temporary array
+ // CHECK: [[array:%[^ ]+]] = alloca [3 x i32]
+ // CHECK: getelementptr inbounds [3 x i32]* [[array]], i{{32|64}} 0
+ // CHECK-NEXT: store i32 1, i32*
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: store
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: load
+ // CHECK-NEXT: store
+ // init the list
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: getelementptr inbounds [3 x i32]*
+ // CHECK-NEXT: store i32*
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: store i{{32|64}} 3
+ std::initializer_list<int> intlist{1, 2, i};
+}
+
+void fn2() {
+ // CHECK: define void @_Z3fn2v
+ void target(std::initializer_list<destroyme1>);
+ // objects should be destroyed before dm2, after call returns
+ // CHECK: call void @_Z6targetSt16initializer_listI10destroyme1E
+ target({ destroyme1(), destroyme1() });
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+}
+
+void fn3() {
+ // CHECK: define void @_Z3fn3v
+ // objects should be destroyed after dm2
+ auto list = { destroyme1(), destroyme1() };
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+ // CHECK: call void @_ZN10destroyme1D1Ev
+}
+
+void fn4() {
+ // CHECK: define void @_Z3fn4v
+ void target(std::initializer_list<witharg1>);
+ // objects should be destroyed before dm2, after call returns
+ // CHECK: call void @_ZN8witharg1C1ERK10destroyme1
+ // CHECK: call void @_Z6targetSt16initializer_listI8witharg1E
+ target({ witharg1(destroyme1()), witharg1(destroyme1()) });
+ // CHECK: call void @_ZN8witharg1D1Ev
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+}
+
+void fn5() {
+ // CHECK: define void @_Z3fn5v
+ // temps should be destroyed before dm2
+ // objects should be destroyed after dm2
+ // CHECK: call void @_ZN8witharg1C1ERK10destroyme1
+ auto list = { witharg1(destroyme1()), witharg1(destroyme1()) };
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+ // CHECK: call void @_ZN8witharg1D1Ev
+}
+
+void fn6() {
+ // CHECK: define void @_Z3fn6v
+ void target(const wantslist1&);
+ // objects should be destroyed before dm2, after call returns
+ // CHECK: call void @_ZN10wantslist1C1ESt16initializer_listI10destroyme1E
+ // CHECK: call void @_Z6targetRK10wantslist1
+ target({ destroyme1(), destroyme1() });
+ // CHECK: call void @_ZN10wantslist1D1Ev
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+}
+
+void fn7() {
+ // CHECK: define void @_Z3fn7v
+ // temps should be destroyed before dm2
+ // object should be destroyed after dm2
+ // CHECK: call void @_ZN10wantslist1C1ESt16initializer_listI10destroyme1E
+ wantslist1 wl = { destroyme1(), destroyme1() };
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+ // CHECK: call void @_ZN10wantslist1D1Ev
+}
+
+void fn8() {
+ // CHECK: define void @_Z3fn8v
+ void target(std::initializer_list<std::initializer_list<destroyme1>>);
+ // objects should be destroyed before dm2, after call returns
+ // CHECK: call void @_Z6targetSt16initializer_listIS_I10destroyme1EE
+ std::initializer_list<destroyme1> inner;
+ target({ inner, { destroyme1() } });
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ // Only one destroy loop, since only one inner init list is directly inited.
+ // CHECK-NOT: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+}
+
+void fn9() {
+ // CHECK: define void @_Z3fn9v
+ // objects should be destroyed after dm2
+ std::initializer_list<destroyme1> inner;
+ std::initializer_list<std::initializer_list<destroyme1>> list =
+ { inner, { destroyme1() } };
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ // Only one destroy loop, since only one inner init list is directly inited.
+ // CHECK-NOT: call void @_ZN10destroyme1D1Ev
+ // CHECK: ret void
+}
+
+struct haslist1 {
+ std::initializer_list<int> il;
+ haslist1();
+};
+
+// CHECK: define void @_ZN8haslist1C2Ev
+haslist1::haslist1()
+// CHECK: alloca [3 x i32]
+// CHECK: store i32 1
+// CHECK: store i32 2
+// CHECK: store i32 3
+// CHECK: store i{{32|64}} 3
+ : il{1, 2, 3}
+{
+ destroyme2 dm2;
+}
+
+struct haslist2 {
+ std::initializer_list<destroyme1> il;
+ haslist2();
+};
+
+// CHECK: define void @_ZN8haslist2C2Ev
+haslist2::haslist2()
+ : il{destroyme1(), destroyme1()}
+{
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+ // CHECK: call void @_ZN10destroyme1D1Ev
+}
+
+void fn10() {
+ // CHECK: define void @_Z4fn10v
+ // CHECK: alloca [3 x i32]
+ // CHECK: call noalias i8* @_Znw{{[jm]}}
+ // CHECK: store i32 1
+ // CHECK: store i32 2
+ // CHECK: store i32 3
+ // CHECK: store i32*
+ // CHECK: store i{{32|64}} 3
+ (void) new std::initializer_list<int> {1, 2, 3};
+}
+
+void fn11() {
+ // CHECK: define void @_Z4fn11v
+ (void) new std::initializer_list<destroyme1> {destroyme1(), destroyme1()};
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+}
+
+namespace PR12178 {
+ struct string {
+ string(int);
+ ~string();
+ };
+
+ struct pair {
+ string a;
+ int b;
+ };
+
+ struct map {
+ map(std::initializer_list<pair>);
+ };
+
+ map m{ {1, 2}, {3, 4} };
+}
diff --git a/clang/test/CodeGenCXX/cxx11-exception-spec.cpp b/clang/test/CodeGenCXX/cxx11-exception-spec.cpp
new file mode 100644
index 0000000..194b80c
--- /dev/null
+++ b/clang/test/CodeGenCXX/cxx11-exception-spec.cpp
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -verify -fexceptions -fcxx-exceptions -triple x86_64-linux-gnu | FileCheck %s
+
+void h();
+
+template<typename T> void f() noexcept(sizeof(T) == 4) { h(); }
+template<typename T> void g() noexcept(sizeof(T) == 4);
+
+template<typename T> struct S {
+ static void f() noexcept(sizeof(T) == 4) { h(); }
+ static void g() noexcept(sizeof(T) == 4);
+};
+
+// CHECK: define {{.*}} @_Z1fIsEvv() {
+template<> void f<short>() { h(); }
+// CHECK: define {{.*}} @_Z1fIA2_sEvv() nounwind {
+template<> void f<short[2]>() noexcept { h(); }
+
+// CHECK: define {{.*}} @_ZN1SIsE1fEv()
+// CHECK-NOT: nounwind
+template<> void S<short>::f() { h(); }
+// CHECK: define {{.*}} @_ZN1SIA2_sE1fEv() nounwind
+template<> void S<short[2]>::f() noexcept { h(); }
+
+// CHECK: define {{.*}} @_Z1fIDsEvv() {
+template void f<char16_t>();
+// CHECK: define {{.*}} @_Z1fIA2_DsEvv() nounwind {
+template void f<char16_t[2]>();
+
+// CHECK: define {{.*}} @_ZN1SIDsE1fEv()
+// CHECK-NOT: nounwind
+template void S<char16_t>::f();
+// CHECK: define {{.*}} @_ZN1SIA2_DsE1fEv() nounwind
+template void S<char16_t[2]>::f();
+
+void h() {
+ // CHECK: define {{.*}} @_Z1fIiEvv() nounwind {
+ f<int>();
+ // CHECK: define {{.*}} @_Z1fIA2_iEvv() {
+ f<int[2]>();
+
+ // CHECK: define {{.*}} @_ZN1SIiE1fEv() nounwind
+ S<int>::f();
+ // CHECK: define {{.*}} @_ZN1SIA2_iE1fEv()
+ // CHECK-NOT: nounwind
+ S<int[2]>::f();
+
+ // CHECK: define {{.*}} @_Z1fIfEvv() nounwind {
+ void (*f1)() = &f<float>;
+ // CHECK: define {{.*}} @_Z1fIdEvv() {
+ void (*f2)() = &f<double>;
+
+ // CHECK: define {{.*}} @_ZN1SIfE1fEv() nounwind
+ void (*f3)() = &S<float>::f;
+ // CHECK: define {{.*}} @_ZN1SIdE1fEv()
+ // CHECK-NOT: nounwind
+ void (*f4)() = &S<double>::f;
+
+ // CHECK: define {{.*}} @_Z1fIA4_cEvv() nounwind {
+ (void)&f<char[4]>;
+ // CHECK: define {{.*}} @_Z1fIcEvv() {
+ (void)&f<char>;
+
+ // CHECK: define {{.*}} @_ZN1SIA4_cE1fEv() nounwind
+ (void)&S<char[4]>::f;
+ // CHECK: define {{.*}} @_ZN1SIcE1fEv()
+ // CHECK-NOT: nounwind
+ (void)&S<char>::f;
+}
+
+// CHECK: define {{.*}} @_Z1iv
+void i() {
+ // CHECK: declare {{.*}} @_Z1gIiEvv() nounwind
+ g<int>();
+ // CHECK: declare {{.*}} @_Z1gIA2_iEvv()
+ // CHECK-NOT: nounwind
+ g<int[2]>();
+
+ // CHECK: declare {{.*}} @_ZN1SIiE1gEv() nounwind
+ S<int>::g();
+ // CHECK: declare {{.*}} @_ZN1SIA2_iE1gEv()
+ // CHECK-NOT: nounwind
+ S<int[2]>::g();
+
+ // CHECK: declare {{.*}} @_Z1gIfEvv() nounwind
+ void (*g1)() = &g<float>;
+ // CHECK: declare {{.*}} @_Z1gIdEvv()
+ // CHECK-NOT: nounwind
+ void (*g2)() = &g<double>;
+
+ // CHECK: declare {{.*}} @_ZN1SIfE1gEv() nounwind
+ void (*g3)() = &S<float>::g;
+ // CHECK: declare {{.*}} @_ZN1SIdE1gEv()
+ // CHECK-NOT: nounwind
+ void (*g4)() = &S<double>::g;
+
+ // CHECK: declare {{.*}} @_Z1gIA4_cEvv() nounwind
+ (void)&g<char[4]>;
+ // CHECK: declare {{.*}} @_Z1gIcEvv()
+ // CHECK-NOT: nounwind
+ (void)&g<char>;
+
+ // CHECK: declare {{.*}} @_ZN1SIA4_cE1gEv() nounwind
+ (void)&S<char[4]>::g;
+ // CHECK: declare {{.*}} @_ZN1SIcE1gEv()
+ // CHECK-NOT: nounwind
+ (void)&S<char>::g;
+}
+
+template<typename T> struct Nested {
+ template<bool b, typename U> void f() noexcept(sizeof(T) == sizeof(U));
+};
+
+// CHECK: define {{.*}} @_Z1jv
+void j() {
+ // CHECK: declare {{.*}} @_ZN6NestedIiE1fILb1EcEEvv(
+ // CHECK-NOT: nounwind
+ Nested<int>().f<true, char>();
+ // CHECK: declare {{.*}} @_ZN6NestedIlE1fILb0ElEEvv({{.*}}) nounwind
+ Nested<long>().f<false, long>();
+}
diff --git a/clang/test/CodeGenCXX/cxx11-unrestricted-union.cpp b/clang/test/CodeGenCXX/cxx11-unrestricted-union.cpp
new file mode 100644
index 0000000..0397775
--- /dev/null
+++ b/clang/test/CodeGenCXX/cxx11-unrestricted-union.cpp
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - | FileCheck %s
+
+struct A {
+ A(); A(const A&); A(A&&); A &operator=(const A&); A &operator=(A&&); ~A();
+};
+struct B {
+ B(); B(const B&); B(B&&); B &operator=(const B&); B &operator=(B&&); ~B();
+};
+
+union U {
+ U();
+ U(const U &);
+ U(U &&);
+ U &operator=(const U&);
+ U &operator=(U&&);
+ ~U();
+
+ A a;
+ int n;
+};
+
+// CHECK-NOT: _ZN1A
+U::U() {}
+U::U(const U&) {}
+U::U(U&&) {}
+U &U::operator=(const U&) { return *this; }
+U &U::operator=(U &&) { return *this; }
+U::~U() {}
+
+struct S {
+ S();
+ S(const S &);
+ S(S &&);
+ S &operator=(const S&);
+ S &operator=(S&&);
+ ~S();
+
+ union {
+ A a;
+ int n;
+ };
+ B b;
+ int m;
+};
+
+// CHECK: _ZN1SC2Ev
+// CHECK-NOT: _ZN1A
+// CHECK: _ZN1BC1Ev
+S::S() {}
+
+// CHECK-NOT: _ZN1A
+
+// CHECK: _ZN1SC2ERKS_
+// CHECK-NOT: _ZN1A
+// CHECK: _ZN1BC1Ev
+S::S(const S&) {}
+
+// CHECK-NOT: _ZN1A
+
+// CHECK: _ZN1SC2EOS_
+// CHECK-NOT: _ZN1A
+// CHECK: _ZN1BC1Ev
+S::S(S&&) {}
+
+// CHECK-NOT: _ZN1A
+// CHECK-NOT: _ZN1B
+S &S::operator=(const S&) { return *this; }
+
+S &S::operator=(S &&) { return *this; }
+
+// CHECK: _ZN1SD2Ev
+// CHECK-NOT: _ZN1A
+// CHECK: _ZN1BD1Ev
+S::~S() {}
+
+// CHECK-NOT: _ZN1A
diff --git a/clang/test/CodeGenCXX/cxx11-user-defined-literal.cpp b/clang/test/CodeGenCXX/cxx11-user-defined-literal.cpp
new file mode 100644
index 0000000..347ffe9
--- /dev/null
+++ b/clang/test/CodeGenCXX/cxx11-user-defined-literal.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s
+
+struct S { S(); ~S(); S(const S &); void operator()(int); };
+using size_t = decltype(sizeof(int));
+S operator"" _x(const char *, size_t);
+S operator"" _y(wchar_t);
+S operator"" _z(unsigned long long);
+S operator"" _f(long double);
+S operator"" _r(const char *);
+template<char...Cs> S operator"" _t() { return S(); }
+
+// CHECK: @[[s_foo:.*]] = {{.*}} constant [4 x i8] c"foo\00"
+// CHECK: @[[s_bar:.*]] = {{.*}} constant [4 x i8] c"bar\00"
+// CHECK: @[[s_123:.*]] = {{.*}} constant [4 x i8] c"123\00"
+// CHECK: @[[s_4_9:.*]] = {{.*}} constant [4 x i8] c"4.9\00"
+// CHECK: @[[s_0xffffeeee:.*]] = {{.*}} constant [11 x i8] c"0xffffeeee\00"
+
+void f() {
+ // CHECK: call void @_Zli2_xPKcm({{.*}}, i8* getelementptr inbounds ([4 x i8]* @[[s_foo]], i32 0, i32 0), i64 3)
+ // CHECK: call void @_Zli2_xPKcm({{.*}}, i8* getelementptr inbounds ([4 x i8]* @[[s_bar]], i32 0, i32 0), i64 3)
+ // CHECK: call void @_Zli2_yw({{.*}} 97)
+ // CHECK: call void @_Zli2_zy({{.*}} 42)
+ // CHECK: call void @_Zli2_fe({{.*}} x86_fp80 0xK3FFF8000000000000000)
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ "foo"_x, "bar"_x, L'a'_y, 42_z, 1.0_f;
+
+ // CHECK: call void @_Zli2_rPKc({{.*}}, i8* getelementptr inbounds ([4 x i8]* @[[s_123]], i32 0, i32 0))
+ // CHECK: call void @_Zli2_rPKc({{.*}}, i8* getelementptr inbounds ([4 x i8]* @[[s_4_9]], i32 0, i32 0))
+ // CHECK: call void @_Zli2_rPKc({{.*}}, i8* getelementptr inbounds ([11 x i8]* @[[s_0xffffeeee]], i32 0, i32 0))
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ 123_r, 4.9_r, 0xffff\
+eeee_r;
+
+ // FIXME: This mangling is insane. Maybe we should have a special case for
+ // char parameter packs?
+ // CHECK: call void @_Zli2_tIJLc48ELc120ELc49ELc50ELc51ELc52ELc53ELc54ELc55ELc56EEE1Sv({{.*}})
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ 0x12345678_t;
+}
+
+// CHECK: define {{.*}} @_Zli2_tIJLc48ELc120ELc49ELc50ELc51ELc52ELc53ELc54ELc55ELc56EEE1Sv(
+
+template<typename T> auto g(T t) -> decltype("foo"_x(t)) { return "foo"_x(t); }
+template<typename T> auto i(T t) -> decltype(operator"" _x("foo", 3)(t)) { return operator"" _x("foo", 3)(t); }
+
+void h() {
+ g(42);
+ i(42);
+}
+
+// CHECK: define {{.*}} @_Z1hv()
+// CHECK: call void @_Z1gIiEDTclclL_Zli2_xPKcmELA4_S0_ELm3EEfp_EET_(i32 42)
+// CHECK: call void @_Z1iIiEDTclclL_Zli2_xPKcmELA4_S0_ELi3EEfp_EET_(i32 42)
+
+// CHECK: define {{.*}} @_Z1gIiEDTclclL_Zli2_xPKcmELA4_S0_ELm3EEfp_EET_(i32
+// CHECK: call void @_Zli2_xPKcm({{.*}}, i8* getelementptr inbounds ([4 x i8]* @{{.*}}, i32 0, i32 0), i64 3)
+// CHECK: call void @_ZN1SclEi
+// CHECK: call void @_ZN1SD1Ev
+
+// CHECK: define {{.*}} @_Z1iIiEDTclclL_Zli2_xPKcmELA4_S0_ELi3EEfp_EET_(i32
+// CHECK: call void @_Zli2_xPKcm({{.*}}, i8* getelementptr inbounds ([4 x i8]* @{{.*}}, i32 0, i32 0), i64 3)
+// CHECK: call void @_ZN1SclEi
+// CHECK: call void @_ZN1SD1Ev
diff --git a/clang/test/CodeGenCXX/debug-info-artificial-arg.cpp b/clang/test/CodeGenCXX/debug-info-artificial-arg.cpp
new file mode 100644
index 0000000..92d1b16
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-artificial-arg.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
+
+template<class X> class B {
+public:
+ explicit B(X* p = 0);
+};
+
+class A
+{
+public:
+ A(int value) : m_a_value(value) {};
+ A(int value, A* client_A) : m_a_value (value), m_client_A (client_A) {}
+
+ virtual ~A() {}
+
+private:
+ int m_a_value;
+ B<A> m_client_A;
+};
+
+int main(int argc, char **argv) {
+ A reallyA (500);
+}
+
+// FIXME: The numbers are truly awful.
+// CHECK: !18 = metadata !{i32 {{.*}}, i32 0, metadata !"", i32 0, i32 0, i64 64, i64 64, i64 0, i32 64, metadata !19} ; [ DW_TAG_pointer_type ]
+// CHECK: !19 = metadata !{i32 {{.*}}, null, metadata !"A", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !20, i32 0, metadata !19, null} ; [ DW_TAG_class_type ]
+// CHECK: metadata !19, metadata !"A", metadata !"A", metadata !"", metadata !6, i32 12, metadata !45, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !47, i32 12} ; [ DW_TAG_subprogram ]
+// CHECK: metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !46, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
+// CHECK: !46 = metadata !{null, metadata !18, metadata !9, metadata !34}
diff --git a/clang/test/CodeGenCXX/debug-info-byval.cpp b/clang/test/CodeGenCXX/debug-info-byval.cpp
new file mode 100644
index 0000000..56ffe13
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-byval.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang -g -S %s -o - | FileCheck %s
+// Test to check presence of debug info for byval parameter.
+// Radar 8350436.
+class DAG {
+public:
+ int i;
+ int j;
+};
+
+class EVT {
+public:
+ int a;
+ int b;
+ int c;
+};
+
+class VAL {
+public:
+ int x;
+ int y;
+};
+void foo(EVT e);
+EVT bar();
+
+void get(int *i, unsigned dl, VAL v, VAL *p, unsigned n, EVT missing_arg) {
+//CHECK: .asciz "missing_arg"
+ EVT e = bar();
+ if (dl == n)
+ foo(missing_arg);
+}
+
diff --git a/clang/test/CodeGenCXX/debug-info-char16.cpp b/clang/test/CodeGenCXX/debug-info-char16.cpp
new file mode 100644
index 0000000..24216f9
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-char16.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -std=c++11 -g %s -o -| FileCheck %s
+
+// 16 is DW_ATE_UTF (0x10) encoding attribute.
+char16_t char_a = u'h';
+
+// CHECK: !7 = metadata !{i32 {{.*}}, null, metadata !"char16_t", null, i32 0, i64 16, i64 16, i64 0, i32 0, i32 16} ; [ DW_TAG_base_type ]
diff --git a/clang/test/CodeGenCXX/debug-info-class.cpp b/clang/test/CodeGenCXX/debug-info-class.cpp
new file mode 100644
index 0000000..151c5f9
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-class.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang -emit-llvm -g -S %s -o - | grep HdrSize
+struct A {
+ int one;
+ static const int HdrSize = 52;
+ int two;
+ A() {
+ int x = 1;
+ }
+};
+int main() {
+ A a;
+}
diff --git a/clang/test/CodeGenCXX/debug-info-context.cpp b/clang/test/CodeGenCXX/debug-info-context.cpp
new file mode 100644
index 0000000..d6d44a1
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-context.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// PR11345
+
+class locale {
+private:
+ void _M_add_reference() const throw() {
+ }
+};
+class ios_base {
+ locale _M_ios_locale;
+public:
+ class Init {
+ };
+};
+static ios_base::Init __ioinit;
+
+// CHECK-NOT: _M_ios_locale
diff --git a/clang/test/CodeGenCXX/debug-info-ctor.cpp b/clang/test/CodeGenCXX/debug-info-ctor.cpp
new file mode 100644
index 0000000..c31eebe
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-ctor.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s
+
+struct X {
+ X(int v);
+
+ int value;
+};
+
+X::X(int v) {
+ // CHECK_TEMPORARILY_DISABLED: call void @_ZN1XC2Ei(%struct.X* %this1, i32 %tmp), !dbg
+ // TEMPORARY CHECK: X
+ value = v;
+}
+
diff --git a/clang/test/CodeGenCXX/debug-info-ctor2.cpp b/clang/test/CodeGenCXX/debug-info-ctor2.cpp
new file mode 100644
index 0000000..19bd64b
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-ctor2.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang -fverbose-asm -g -S %s -o - | grep AT_explicit
+
+
+class MyClass
+{
+public:
+ explicit MyClass (int i) :
+ m_i (i)
+ {}
+private:
+ int m_i;
+};
+
+MyClass m(1);
+
diff --git a/clang/test/CodeGenCXX/debug-info-cxx0x.cpp b/clang/test/CodeGenCXX/debug-info-cxx0x.cpp
new file mode 100644
index 0000000..37ccdb0
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-cxx0x.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm-only -std=c++11 -g %s
+
+namespace PR9414 {
+ int f() {
+ auto x = 0;
+ return x;
+ }
+}
diff --git a/clang/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp b/clang/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
new file mode 100644
index 0000000..e67987b
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin -fno-limit-debug-info %s -o - | FileCheck %s
+
+class Test
+{
+public:
+ Test () : reserved (new data()) {}
+
+ unsigned
+ getID() const
+ {
+ return reserved->objectID;
+ }
+protected:
+ struct data {
+ unsigned objectID;
+ };
+ data* reserved;
+};
+
+Test t;
+
+// CHECK: metadata !"", null, i32 0, i64 64, i64 64, i64 0, i32 0, metadata {{.*}} [ DW_TAG_pointer_type ]
+// CHECK: metadata !"data", metadata !6, i32 14, i64 32, i64 32, i32 0, i32 0
+// CHECK-NOT: metadata !"data", metadata {{.*}}, i32 14, i64 0, i64 0, i32 0, i32 4,
diff --git a/clang/test/CodeGenCXX/debug-info-enum.cpp b/clang/test/CodeGenCXX/debug-info-enum.cpp
new file mode 100644
index 0000000..c08fc35
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-enum.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang -fverbose-asm -S -g %s -o - | grep DW_TAG_enumeration_type
+
+int v;
+enum index { MAX };
+void foo(void)
+{
+ v = MAX;
+}
diff --git a/clang/test/CodeGenCXX/debug-info-fn-template.cpp b/clang/test/CodeGenCXX/debug-info-fn-template.cpp
new file mode 100644
index 0000000..bef9fe1
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-fn-template.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s
+
+template<typename T>
+struct XF {
+ T member;
+};
+
+template<typename T>
+T fx(XF<T> xi) {
+ return xi.member;
+}
+
+//CHECK: XF<int>
+//CHECK: DW_TAG_template_type_parameter
+template int fx(XF<int>);
diff --git a/clang/test/CodeGenCXX/debug-info-friend.cpp b/clang/test/CodeGenCXX/debug-info-friend.cpp
new file mode 100644
index 0000000..c50f281
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-friend.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang -fverbose-asm -S -g %s -o - | grep DW_TAG_friend
+
+class MyFriend;
+
+class SomeClass
+{
+ friend class MyFriend;
+};
+
+SomeClass sc;
+
diff --git a/clang/test/CodeGenCXX/debug-info-fwd-ref.cpp b/clang/test/CodeGenCXX/debug-info-fwd-ref.cpp
new file mode 100644
index 0000000..5480c6b
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-fwd-ref.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
+
+struct baz {
+ int h;
+ baz(int a) : h(a) {}
+};
+
+struct bar {
+ baz b;
+ baz& b_ref;
+ bar(int x) : b(x), b_ref(b) {}
+};
+
+int main(int argc, char** argv) {
+ bar myBar(1);
+ return 0;
+}
+
+// Make sure we have two DW_TAG_class_types for baz and bar and no forward
+// references.
+// FIXME: These should be struct types to match the declaration.
+// CHECK: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !20, i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: metadata !{i32 {{.*}}, null, metadata !"baz", metadata !6, i32 3, i64 32, i64 32, i32 0, i32 0, null, metadata !23, i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK-NOT: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 9, i64 0, i64 0, i32 0, i32 4, i32 0, null, i32 0, i32 0} ; [ DW_TAG_class_type ]
+// CHECK-NOT: metadata !{i32 {{.*}}, null, metadata !"baz", metadata !6, i32 3, i64 0, i64 0, i32 0, i32 4, null, null, i32 0, null, null} ; [ DW_TAG_class_type ]
+
diff --git a/clang/test/CodeGenCXX/debug-info-large-constant.cpp b/clang/test/CodeGenCXX/debug-info-large-constant.cpp
new file mode 100644
index 0000000..2daa189
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-large-constant.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -g -triple=x86_64-apple-darwin %s -o /dev/null
+// PR 8913
+
+typedef __uint128_t word128;
+static const word128 m126 = 0xffffffffffffffffULL;
+word128 foo() {
+ return m126;
+}
diff --git a/clang/test/CodeGenCXX/debug-info-limit-type.cpp b/clang/test/CodeGenCXX/debug-info-limit-type.cpp
new file mode 100644
index 0000000..e03024f
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-limit-type.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s
+// XFAIL: *
+
+class B {
+public:
+ int bb;
+ void fn2() {}
+};
+
+class A {
+public:
+ int aa;
+ void fn1(B b) { b.fn2(); }
+};
+
+void foo(A *aptr) {
+}
+
+void bar() {
+ A a;
+}
+
+// B should only be emitted as a forward reference (i32 4).
+// CHECK: metadata !"B", metadata !6, i32 3, i32 0, i32 0, i32 0, i32 4} ; [ DW_TAG_class_type ]
diff --git a/clang/test/CodeGenCXX/debug-info-limit.cpp b/clang/test/CodeGenCXX/debug-info-limit.cpp
new file mode 100644
index 0000000..bca887b
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-limit.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s
+
+// TAG_member is used to encode debug info for class constructor.
+// CHECK: TAG_member
+class A {
+public:
+ int z;
+};
+
+A *foo (A* x) {
+ A *a = new A(*x);
+ return a;
+}
+
diff --git a/clang/test/CodeGenCXX/debug-info-member.cpp b/clang/test/CodeGenCXX/debug-info-member.cpp
new file mode 100644
index 0000000..8c2e3eb
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-member.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang -fverbose-asm -g -S %s -o - | grep DW_ACCESS_public
+class A {
+public:
+ int x;
+};
+A a;
diff --git a/clang/test/CodeGenCXX/debug-info-method-spec.cpp b/clang/test/CodeGenCXX/debug-info-method-spec.cpp
new file mode 100644
index 0000000..2068c5c
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-method-spec.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang -fverbose-asm -g -S %s -o - | grep DW_AT_specification
+// Radar 9254491
+class A {
+public:
+ void doSomething(int i) { ++i; }
+};
+
+void foo(A *a) {
+ a->doSomething(2);
+}
diff --git a/clang/test/CodeGenCXX/debug-info-method.cpp b/clang/test/CodeGenCXX/debug-info-method.cpp
new file mode 100644
index 0000000..cb022bc
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-method.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang -fverbose-asm -g -S %s -o - | grep DW_ACCESS_protected
+class A {
+protected:
+ int foo();
+};
+A a;
diff --git a/clang/test/CodeGenCXX/debug-info-method2.cpp b/clang/test/CodeGenCXX/debug-info-method2.cpp
new file mode 100644
index 0000000..a927c49
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-method2.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -flimit-debug-info -x c++ -g -S -emit-llvm < %s | FileCheck %s
+// rdar://10336845
+// Preserve type qualifiers in -flimit-debug-info mode.
+
+// CHECK: DW_TAG_const_type
+class A {
+public:
+ int bar(int arg) const;
+};
+
+int A::bar(int arg) const{
+ return arg+2;
+}
+
+int main() {
+ A a;
+ int i = a.bar(2);
+ return i;
+}
diff --git a/clang/test/CodeGenCXX/debug-info-namespace.cpp b/clang/test/CodeGenCXX/debug-info-namespace.cpp
new file mode 100644
index 0000000..27f5eae
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-namespace.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang -g -S -fverbose-asm %s -o - | FileCheck %s
+
+// CHECK: TAG_namespace
+namespace A {
+ enum numbers {
+ ZERO,
+ ONE
+ };
+}
+
+using namespace A;
+numbers n;
diff --git a/clang/test/CodeGenCXX/debug-info-nullptr.cpp b/clang/test/CodeGenCXX/debug-info-nullptr.cpp
new file mode 100644
index 0000000..5540a92
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-nullptr.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -std=c++11 -g %s -o -| FileCheck %s
+
+void foo() {
+ decltype(nullptr) t = 0;
+}
+
+// CHECK: !13 = metadata !{i32 {{.*}}, null, metadata !"nullptr_t", null, i32 0, i64 0, i64 0, i64 0, i32 0, i32 0} ; [ DW_TAG_unspecified_type ]
diff --git a/clang/test/CodeGenCXX/debug-info-pubtypes.cpp b/clang/test/CodeGenCXX/debug-info-pubtypes.cpp
new file mode 100644
index 0000000..a7abade
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-pubtypes.cpp
@@ -0,0 +1,17 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang -cc1 -triple x86_64-apple-darwin10 -g -fno-limit-debug-info -S %s -o %t
+// RUN: FileCheck %s < %t
+
+// FIXME: This testcase shouldn't rely on assembly emission.
+//CHECK: Lpubtypes_begin1:
+//CHECK: .asciz "G"
+//CHECK-NEXT: .long 0
+//CHECK-NEXT: Lpubtypes_end1:
+
+class G {
+public:
+ void foo();
+};
+
+void G::foo() {
+}
diff --git a/clang/test/CodeGenCXX/debug-info-static-fns.cpp b/clang/test/CodeGenCXX/debug-info-static-fns.cpp
new file mode 100644
index 0000000..485d28a
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-static-fns.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
+
+namespace A {
+ static int a(int b) { return b + 4; }
+
+ int b(int c) { return c + a(c); }
+}
+
+// Verify that a is present and mangled.
+// CHECK: metadata !{i32 786478, i32 0, metadata !6, metadata !"a", metadata !"a", metadata !"_ZN1AL1aEi", metadata !7, i32 4, metadata !8, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_ZN1AL1aEi, null, null, metadata !14, i32 4} ; [ DW_TAG_subprogram ]
diff --git a/clang/test/CodeGenCXX/debug-info-template-limit.cpp b/clang/test/CodeGenCXX/debug-info-template-limit.cpp
new file mode 100644
index 0000000..796a80f
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-template-limit.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang -flimit-debug-info -emit-llvm -g -S %s -o - | FileCheck %s
+
+// Check that this pointer type is TC<int>
+// CHECK: !10} ; [ DW_TAG_pointer_type
+// CHECK-NEXT: !10 ={{.*}}"TC<int>"
+
+template<typename T>
+class TC {
+public:
+ TC(const TC &) {}
+ TC() {}
+};
+
+TC<int> tci;
+
diff --git a/clang/test/CodeGenCXX/debug-info-template-member.cpp b/clang/test/CodeGenCXX/debug-info-template-member.cpp
new file mode 100644
index 0000000..6208c80
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-template-member.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
+
+class MyClass
+{
+public:
+ int add2(int j)
+ {
+ return add<2>(j);
+ }
+private:
+ template <int i> int add(int j)
+ {
+ return i + j;
+ }
+};
+
+MyClass m;
+
+// CHECK: metadata !{i32 {{.*}}, null, metadata !"MyClass", metadata {{.*}}, i32 {{.*}}, i64 8, i64 8, i32 0, i32 0, null, metadata [[C_MEM:.*]], i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: [[C_MEM]] = metadata !{metadata {{.*}}, metadata [[C_TEMP:.*]], metadata {{.*}}}
+// CHECK: [[C_TEMP]] = metadata !{i32 {{.*}}, i32 0, metadata {{.*}}, metadata !"add<2>", metadata !"add<2>", metadata !"_ZN7MyClass3addILi2EEEii", metadata {{.*}}
diff --git a/clang/test/CodeGenCXX/debug-info-template-recursive.cpp b/clang/test/CodeGenCXX/debug-info-template-recursive.cpp
new file mode 100644
index 0000000..ef04d03
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-template-recursive.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
+
+class base { };
+
+template <class T> class foo : public base {
+ void operator=(const foo r) { }
+};
+
+class bar : public foo<void> { };
+bar filters;
+
+// For now check that it simply doesn't crash.
+// CHECK: {{.*}}
diff --git a/clang/test/CodeGenCXX/debug-info-template.cpp b/clang/test/CodeGenCXX/debug-info-template.cpp
new file mode 100644
index 0000000..9d52159
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-template.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s
+
+//CHECK: TC<int>
+//CHECK: DW_TAG_template_type_parameter
+
+template<typename T>
+class TC {
+public:
+ TC(const TC &) {}
+ TC() {}
+};
+
+TC<int> tci;
+
+//CHECK: TU<2>
+//CHECK: DW_TAG_template_value_parameter
+template<unsigned >
+class TU {
+ int b;
+};
+
+TU<2> u2;
+
+// PR9600
+template<typename T> class vector {};
+class Foo;
+typedef vector<Foo*> FooVector[3];
+struct Test {
+ virtual void foo(FooVector *);
+};
+static Test test;
+
+// PR9608
+template <int i> struct TheTemplate {
+ struct Empty2 {};
+ typedef const Empty2 DependentType[i];
+ TheTemplate() {}
+};
+
+class TheTemplateTest : public TheTemplate<42> {
+ TheTemplateTest();
+ void method(const TheTemplate<42>::DependentType *) {}
+};
+
+TheTemplateTest::TheTemplateTest() : TheTemplate<42>() {}
+
diff --git a/clang/test/CodeGenCXX/debug-info-this.cpp b/clang/test/CodeGenCXX/debug-info-this.cpp
new file mode 100644
index 0000000..a2842d0
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-this.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s
+// Radar 9239104
+class Class
+{
+public:
+//CHECK: DW_TAG_const_type
+ int foo (int p) const {
+ return p+m_int;
+ }
+
+protected:
+ int m_int;
+};
+
+Class c;
diff --git a/clang/test/CodeGenCXX/debug-info-use-after-free.cpp b/clang/test/CodeGenCXX/debug-info-use-after-free.cpp
new file mode 100644
index 0000000..9757ca4
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-use-after-free.cpp
@@ -0,0 +1,312 @@
+// RUN: %clang_cc1 -g -emit-llvm-only %s
+// Check that we don't crash.
+// PR12305, PR12315
+
+# 1 "a.h" 3
+template < typename T1 > struct Types1
+{
+ typedef T1 Head;
+};
+template < typename > struct Types;
+template < template < typename > class Tmpl > struct TemplateSel
+{
+ template < typename T > struct Bind
+ {
+ typedef Tmpl < T > type;
+ };
+};
+template < typename > struct NoneT;
+template < template < typename > class T1, template < typename > class > struct Templates2
+{
+ typedef TemplateSel < T1 > Head;
+};
+template < template < typename > class, template < typename > class =
+ NoneT, template < typename > class = NoneT, template < typename > class =
+ NoneT > struct Templates;
+template < template < typename > class T1,
+ template < typename > class T2 > struct Templates <T1, T2 >
+{
+ typedef Templates2 < T1, T2 > type;
+};
+template < typename T > struct TypeList
+{
+ typedef Types1 < T > type;
+};
+template < template < typename > class, class TestSel,
+ typename Types > class TypeParameterizedTest
+{
+public:static bool Register ()
+ {
+ typedef typename Types::Head Type;
+ typename TestSel::template Bind < Type >::type TestClass;
+}};
+
+template < template < typename > class Fixture, typename Tests,
+ typename Types > class TypeParameterizedTestCase
+{
+public:static bool Register (char *, char *, int *)
+ {
+ typedef typename Tests::Head Head;
+ TypeParameterizedTest < Fixture, Head, Types >::Register;
+}};
+
+template < typename > class TypedTestP1
+{
+};
+
+namespace gtest_case_TypedTestP1_
+{
+ template < typename gtest_TypeParam_ > class A:TypedTestP1 <
+ gtest_TypeParam_ >
+ {
+ };
+template < typename gtest_TypeParam_ > class B:TypedTestP1 <
+ gtest_TypeParam_ >
+ {
+ };
+ typedef Templates < A >::type gtest_AllTests_;
+}
+
+template < typename > class TypedTestP2
+{
+};
+
+namespace gtest_case_TypedTestP2_
+{
+ template < typename gtest_TypeParam_ > class A:TypedTestP2 <
+ gtest_TypeParam_ >
+ {
+ };
+ typedef Templates < A >::type gtest_AllTests_;
+}
+
+bool gtest_Int_TypedTestP1 =
+ TypeParameterizedTestCase < TypedTestP1,
+ gtest_case_TypedTestP1_::gtest_AllTests_,
+ TypeList < int >::type >::Register ("Int", "TypedTestP1", 0);
+bool gtest_Int_TypedTestP2 =
+ TypeParameterizedTestCase < TypedTestP2,
+ gtest_case_TypedTestP2_::gtest_AllTests_,
+ TypeList < Types < int > >::type >::Register ("Int", "TypedTestP2", 0);
+
+template < typename _Tp > struct new_allocator
+{
+ typedef _Tp *pointer;
+ template < typename > struct rebind {
+ typedef new_allocator other;
+ };
+};
+template < typename _Tp > struct allocator:new_allocator < _Tp > {
+};
+template < typename _Tp, typename _Alloc > struct _Vector_base {
+ typedef typename _Alloc::template rebind < _Tp >::other _Tp_alloc_type;
+ struct _Vector_impl {
+ typename _Tp_alloc_type::pointer _M_end_of_storage;
+ };
+ _Vector_base () {
+ foo((int *) this->_M_impl._M_end_of_storage);
+ }
+ void foo(int *);
+ _Vector_impl _M_impl;
+};
+template < typename _Tp, typename _Alloc =
+allocator < _Tp > >struct vector:_Vector_base < _Tp, _Alloc > { };
+
+
+template < class T> struct HHH {};
+struct DDD { int x_;};
+struct Data;
+struct X1;
+struct CCC:DDD { virtual void xxx (HHH < X1 >); };
+template < class SSS > struct EEE:vector < HHH < SSS > > { };
+template < class SSS, class = EEE < SSS > >class FFF { };
+template < class SSS, class GGG = EEE < SSS > >class AAA:FFF <GGG> { };
+class BBB:virtual CCC {
+ void xxx (HHH < X1 >);
+ vector < HHH < X1 > >aaa;
+};
+class ZZZ:AAA < Data >, BBB { virtual ZZZ *ppp () ; };
+ZZZ * ZZZ::ppp () { return new ZZZ; }
+
+namespace std
+{
+ template < class, class > struct pair;
+}
+namespace __gnu_cxx {
+template < typename > class new_allocator;
+}
+namespace std {
+template < typename _Tp > class allocator:__gnu_cxx::new_allocator < _Tp > {
+};
+template < typename, typename > struct _Vector_base {
+};
+template < typename _Tp, typename _Alloc = std::allocator < _Tp > >class vector:_Vector_base < _Tp,
+ _Alloc
+ > {
+ };
+}
+
+namespace
+std {
+ template <
+ typename,
+ typename > struct unary_function;
+ template <
+ typename,
+ typename,
+ typename > struct binary_function;
+ template <
+ typename
+ _Tp > struct equal_to:
+ binary_function <
+ _Tp,
+ _Tp,
+ bool > {
+ };
+ template <
+ typename
+ _Pair > struct _Select1st:
+ unary_function <
+ _Pair,
+ typename
+ _Pair::first_type > {
+ };
+}
+# 1 "f.h" 3
+using
+std::pair;
+namespace
+__gnu_cxx {
+ template <
+ class > struct hash;
+ template <
+ class,
+ class,
+ class,
+ class,
+ class
+ _EqualKey,
+ class >
+ class
+ hashtable {
+ public:
+ typedef _EqualKey
+ key_equal;
+ };
+ using
+ std::equal_to;
+ using
+ std::allocator;
+ using
+ std::_Select1st;
+ template < class _Key, class _Tp, class _HashFn =
+ hash < _Key >, class _EqualKey = equal_to < _Key >, class _Alloc =
+ allocator < _Tp > >class hash_map {
+ typedef
+ hashtable <
+ pair <
+ _Key,
+ _Tp >,
+ _Key,
+ _HashFn,
+ _Select1st <
+ pair <
+ _Key,
+ _Tp > >,
+ _EqualKey,
+ _Alloc >
+ _Ht;
+ public:
+ typename _Ht::key_type;
+ typedef typename
+ _Ht::key_equal
+ key_equal;
+ };
+}
+using
+__gnu_cxx::hash_map;
+class
+C2;
+template < class > class scoped_ptr {
+};
+namespace {
+class
+ AAA {
+ virtual ~
+ AAA () {
+ }};
+}
+template < typename > class EEE;
+template < typename CCC, typename =
+typename CCC::key_equal, typename =
+EEE < CCC > >class III {
+};
+namespace
+util {
+ class
+ EEE {
+ };
+}
+namespace {
+class
+ C1:
+ util::EEE {
+ public:
+ class
+ C3:
+ AAA {
+ struct FFF;
+ typedef
+ III <
+ hash_map <
+ C2,
+ FFF > >
+ GGG;
+ GGG
+ aaa;
+ friend
+ C1;
+ };
+ void
+ HHH (C3::GGG &);
+ };
+}
+namespace
+n1 {
+ class
+ Test {
+ };
+ template <
+ typename >
+ class
+ C7 {
+ };
+ class
+ C4:
+ n1::Test {
+ vector <
+ C1::C3 * >
+ a1;
+ };
+ enum C5 { };
+ class
+ C6:
+ C4,
+ n1::C7 <
+ C5 > {
+ };
+ class
+ C8:
+ C6 {
+ };
+ class
+ C9:
+ C8 {
+ void
+ TestBody ();
+ };
+ void
+ C9::TestBody () {
+ scoped_ptr < C1::C3 > context;
+ }
+}
diff --git a/clang/test/CodeGenCXX/debug-info-wchar.cpp b/clang/test/CodeGenCXX/debug-info-wchar.cpp
new file mode 100644
index 0000000..6f53849
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-wchar.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm -g %s -o -| FileCheck %s
+void foo() {
+// CHECK: metadata !"wchar_t",
+ const wchar_t w = L'x';
+}
diff --git a/clang/test/CodeGenCXX/debug-info.cpp b/clang/test/CodeGenCXX/debug-info.cpp
new file mode 100644
index 0000000..33b5278
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -emit-llvm-only -g %s
+template<typename T> struct Identity {
+ typedef T Type;
+};
+
+void f(Identity<int>::Type a) {}
+void f(Identity<int> a) {}
+void f(int& a) { }
+
+template<typename T> struct A {
+ A<T> *next;
+};
+void f(A<int>) { }
+
+struct B { };
+
+void f() {
+ int B::*a = 0;
+ void (B::*b)() = 0;
+}
+
+namespace EmptyNameCrash {
+ struct A { A(); };
+ typedef struct { A x; } B;
+ B x;
+}
+
+// PR4890
+namespace PR4890 {
+ struct X {
+ ~X();
+ };
+
+ X::~X() { }
+}
+
+namespace VirtualDtor {
+ struct Y {
+ virtual ~Y();
+ };
+
+ Y::~Y() { }
+}
+
+namespace VirtualBase {
+ struct A { };
+ struct B : virtual A { };
+
+ void f() {
+ B b;
+ }
+}
+
+void foo() {
+ const wchar_t c = L'x';
+ wchar_t d = c;
+}
+
+namespace b5249287 {
+template <typename T> class A {
+ struct B;
+};
+
+class Cls {
+ template <typename T> friend class A<T>::B;
+};
+
+Cls obj;
+}
diff --git a/clang/test/CodeGenCXX/debug-lambda-expressions.cpp b/clang/test/CodeGenCXX/debug-lambda-expressions.cpp
new file mode 100644
index 0000000..859a71b
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-lambda-expressions.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -g | FileCheck %s
+
+auto var = [](int i) { return i+1; };
+
+extern "C" auto cvar = []{};
+
+int a() { return []{ return 1; }(); }
+
+int b(int x) { return [x]{return x;}(); }
+
+int c(int x) { return [&x]{return x;}(); }
+
+struct D { D(); D(const D&); int x; };
+int d(int x) { D y[10]; [x,y] { return y[x].x; }(); }
+
+
+// A: 5
+// CHECK: [[A_FUNC:.*]] = metadata !{i32 {{.*}}, i32 0, metadata [[FILE:.*]], metadata !"a", metadata !"a", metadata !"_Z1av", metadata {{.*}}, i32 [[A_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @_Z1av, null, null, {{.*}} [ DW_TAG_subprogram ]
+
+// Randomness for file. -- 6
+// CHECK: [[FILE]] = metadata !{i32 {{.*}}, metadata !{{.*}}debug-lambda-expressions.cpp{{.*}}; [ DW_TAG_file_type ]
+
+// B: 12
+// CHECK: [[B_FUNC:.*]] = metadata !{i32 786478, i32 0, metadata [[FILE]], metadata !"b", metadata !"b", metadata !"_Z1bi", metadata [[FILE]], i32 [[B_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z1bi, null, null, {{.*}} ; [ DW_TAG_subprogram ]
+
+// C: 17
+// CHECK: [[C_FUNC:.*]] = metadata !{i32 {{.*}}, i32 0, metadata [[FILE]], metadata !"c", metadata !"c", metadata !"_Z1ci", metadata [[FILE]], i32 [[C_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z1ci, null, null, metadata {{.*}} ; [ DW_TAG_subprogram ]
+
+// D: 20
+// CHECK: [[D_FUNC:.*]] = metadata !{i32 {{.*}}, i32 0, metadata [[FILE]], metadata !"d", metadata !"d", metadata !"_Z1di", metadata [[FILE]], i32 [[D_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z1di, null, null, metadata {{.*}} ; [ DW_TAG_subprogram ]
+
+// Back to D. -- 120
+// CHECK: [[LAM_D:.*]] = metadata !{i32 {{.*}}, metadata [[D_FUNC]], metadata !"", metadata [[FILE]], i32 [[D_LINE]], i64 352, i64 32, i32 0, i32 0, null, metadata [[LAM_D_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: [[LAM_D_ARGS]] = metadata !{metadata [[CAP_D_X:.*]], metadata [[CAP_D_Y:.*]], metadata [[CON_LAM_D:.*]], metadata [[DES_LAM_D:.*]]}
+// CHECK: [[CAP_D_X]] = metadata !{i32 {{.*}}, metadata [[LAM_D]], metadata !"x", metadata [[FILE]], i32 14, i64 32, i64 32, i64 0, i32 1, metadata {{.*}} ; [ DW_TAG_member ]
+// CHECK: [[CAP_D_Y]] = metadata !{i32 {{.*}}, metadata [[LAM_D]], metadata !"y", metadata [[FILE]], i32 14, i64 320, i64 32, i64 32, i32 1, metadata {{.*}} ; [ DW_TAG_member ]
+// CHECK: [[CON_LAM_D]] = metadata {{.*}}[[LAM_D]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ]
+// CHECK: [[DES_LAM_D]] = metadata {{.*}}[[LAM_D]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ]
+
+
+// Back to C. -- 159
+// CHECK: [[LAM_C:.*]] = metadata !{i32 {{.*}}, metadata [[C_FUNC]], metadata !"", metadata [[FILE]], i32 [[C_LINE]], i64 64, i64 64, i32 0, i32 0, null, metadata [[LAM_C_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: [[LAM_C_ARGS]] = metadata !{metadata [[CAP_C:.*]], metadata [[CON_LAM_C:.*]], metadata [[DES_LAM_C:.*]]}
+// Ignoring the member type for now.
+// CHECK: [[CAP_C]] = metadata !{i32 {{.*}}, metadata [[LAM_C]], metadata !"x", metadata [[FILE]], i32 [[C_LINE]], i64 64, i64 64, i64 0, i32 1, metadata {{.*}}} ; [ DW_TAG_member ]
+// CHECK: [[CON_LAM_C]] = metadata {{.*}}[[LAM_C]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ]
+// CHECK: [[DES_LAM_C]] = metadata {{.*}}[[LAM_C]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ]
+
+
+// Back to B. -- 179
+// CHECK: [[LAM_B:.*]] = metadata !{i32 {{.*}}, metadata [[B_FUNC]], metadata !"", metadata [[FILE]], i32 [[B_LINE]], i64 32, i64 32, i32 0, i32 0, null, metadata [[LAM_B_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: [[LAM_B_ARGS]] = metadata !{metadata [[CAP_B:.*]], metadata [[CON_LAM_B:.*]], metadata [[DES_LAM_B:.*]]}
+// CHECK: [[CAP_B]] = metadata !{i32 {{.*}}, metadata [[LAM_B]], metadata !"x", metadata [[FILE]], i32 [[B_LINE]], i64 32, i64 32, i64 0, i32 1, metadata {{.*}}} ; [ DW_TAG_member ]
+// CHECK: [[CON_LAM_B]] = metadata {{.*}}[[LAM_B]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ]
+// CHECK: [[DES_LAM_B]] = metadata {{.*}}[[LAM_B]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ]
+
+// Back to A. -- 204
+// CHECK: [[LAM_A:.*]] = metadata !{i32 {{.*}}, metadata [[A_FUNC]], metadata !"", metadata [[FILE]], i32 [[A_LINE]], i64 8, i64 8, i32 0, i32 0, null, metadata [[LAM_A_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: [[LAM_A_ARGS]] = metadata !{metadata [[CON_LAM_A:.*]], metadata [[DES_LAM_A:.*]]}
+// CHECK: [[CON_LAM_A]] = metadata {{.*}}[[LAM_A]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ]
+// CHECK: [[DES_LAM_A]] = metadata {{.*}}[[LAM_A]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ]
+
+// VAR:
+// CHECK: metadata !{i32 {{.*}}, i32 0, null, metadata !"var", metadata !"var", metadata !"", metadata [[FILE]], i32 [[VAR_LINE:.*]], metadata ![[VAR_T:.*]], i32 1, i32 1, %class.anon* @var} ; [ DW_TAG_variable ]
+// CHECK: [[VAR_T]] = metadata !{i32 {{.*}}, null, metadata !"", metadata [[FILE]], i32 [[VAR_LINE]], i64 8, i64 8, i32 0, i32 0, null, metadata ![[VAR_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: [[VAR_ARGS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata !{{.*}}}
+
+// CVAR:
+// CHECK: metadata !{i32 {{.*}}, i32 0, null, metadata !"cvar", metadata !"cvar", metadata !"", metadata [[FILE]], i32 [[CVAR_LINE:.*]], metadata ![[CVAR_T:.*]], i32 0, i32 1, %class.anon.0* @cvar} ; [ DW_TAG_variable ]
+// CHECK: [[CVAR_T]] = metadata !{i32 {{.*}}, null, metadata !"", metadata [[FILE]], i32 [[CVAR_LINE]], i64 8, i64 8, i32 0, i32 0, null, metadata ![[CVAR_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: [[CVAR_ARGS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata !{{.*}}}
diff --git a/clang/test/CodeGenCXX/decl-ref-init.cpp b/clang/test/CodeGenCXX/decl-ref-init.cpp
new file mode 100644
index 0000000..a066fbb
--- /dev/null
+++ b/clang/test/CodeGenCXX/decl-ref-init.cpp
@@ -0,0 +1,31 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+struct A {};
+
+struct B
+{
+ operator A&();
+};
+
+
+struct D : public B {
+ operator A();
+};
+
+extern B f();
+extern D d();
+
+int main() {
+ const A& rca = f();
+ const A& rca2 = d();
+}
+
+// CHECK-LP64: callq __ZN1BcvR1AEv
+// CHECK-LP64: callq __ZN1BcvR1AEv
+
+// CHECK-LP32: calll L__ZN1BcvR1AEv
+// CHECK-LP32: calll L__ZN1BcvR1AEv
diff --git a/clang/test/CodeGenCXX/default-arg-temps.cpp b/clang/test/CodeGenCXX/default-arg-temps.cpp
new file mode 100644
index 0000000..3d741d5
--- /dev/null
+++ b/clang/test/CodeGenCXX/default-arg-temps.cpp
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+
+struct T {
+ T();
+ ~T();
+};
+
+void f(const T& t = T());
+
+class X { // ...
+public:
+ X();
+ X(const X&, const T& t = T());
+};
+
+// CHECK: define void @_Z1gv()
+void g() {
+ // CHECK: call void @_ZN1TC1Ev([[T:%.*]]* [[AGG1:%.*]])
+ // CHECK-NEXT: call void @_Z1fRK1T([[T]]* [[AGG1]])
+ // CHECK-NEXT: call void @_ZN1TD1Ev([[T]]* [[AGG1]])
+ f();
+
+ // CHECK-NEXT: call void @_ZN1TC1Ev([[T:%.*]]* [[AGG2:%.*]])
+ // CHECK-NEXT: call void @_Z1fRK1T([[T]]* [[AGG2]])
+ // CHECK-NEXT: call void @_ZN1TD1Ev([[T]]* [[AGG2]])
+ f();
+
+ // CHECK-NEXT: call void @_ZN1XC1Ev(
+ X a;
+
+ // CHECK-NEXT: call void @_ZN1TC1Ev(
+ // CHECK-NEXT: call void @_ZN1XC1ERKS_RK1T(
+ // CHECK-NEXT: call void @_ZN1TD1Ev(
+ X b(a);
+
+ // CHECK-NEXT: call void @_ZN1TC1Ev(
+ // CHECK-NEXT: call void @_ZN1XC1ERKS_RK1T(
+ // CHECK-NEXT: call void @_ZN1TD1Ev(
+ X c = a;
+}
+
+
+class obj{ int a; float b; double d; };
+// CHECK: define void @_Z1hv()
+void h() {
+ // CHECK: call void @llvm.memset.p0i8.i64(
+ obj o = obj();
+}
+
+// PR7028 - mostly this shouldn't crash
+namespace test1 {
+ struct A { A(); };
+ struct B { B(); ~B(); };
+
+ struct C {
+ C(const B &file = B());
+ };
+ C::C(const B &file) {}
+
+ struct D {
+ C c;
+ A a;
+
+ // CHECK: define linkonce_odr void @_ZN5test11DC2Ev(%"struct.test1::D"* %this) unnamed_addr
+ // CHECK: call void @_ZN5test11BC1Ev(
+ // CHECK-NEXT: call void @_ZN5test11CC1ERKNS_1BE(
+ // CHECK-NEXT: call void @_ZN5test11BD1Ev(
+ // CHECK: call void @_ZN5test11AC1Ev(
+ D() : c(), a() {}
+ };
+
+ D d;
+}
diff --git a/clang/test/CodeGenCXX/default-arguments.cpp b/clang/test/CodeGenCXX/default-arguments.cpp
new file mode 100644
index 0000000..206d4d6
--- /dev/null
+++ b/clang/test/CodeGenCXX/default-arguments.cpp
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// PR5484
+namespace PR5484 {
+struct A { };
+extern A a;
+
+void f(const A & = a);
+
+void g() {
+ f();
+}
+}
+
+struct A1 {
+ A1();
+ ~A1();
+};
+
+struct A2 {
+ A2();
+ ~A2();
+};
+
+struct B {
+ B(const A1& = A1(), const A2& = A2());
+};
+
+// CHECK: define void @_Z2f1v()
+void f1() {
+
+ // CHECK: call void @_ZN2A1C1Ev(
+ // CHECK: call void @_ZN2A2C1Ev(
+ // CHECK: call void @_ZN1BC1ERK2A1RK2A2(
+ // CHECK: call void @_ZN2A2D1Ev
+ // CHECK: call void @_ZN2A1D1Ev
+ B bs[2];
+}
+
+struct C {
+ B bs[2];
+ C();
+};
+
+// CHECK: define void @_ZN1CC1Ev(%struct.C* %this) unnamed_addr
+// CHECK: call void @_ZN1CC2Ev(
+
+// CHECK: define void @_ZN1CC2Ev(%struct.C* %this) unnamed_addr
+// CHECK: call void @_ZN2A1C1Ev(
+// CHECK: call void @_ZN2A2C1Ev(
+// CHECK: call void @_ZN1BC1ERK2A1RK2A2(
+// CHECK: call void @_ZN2A2D1Ev
+// CHECK: call void @_ZN2A1D1Ev
+C::C() { }
+
+// CHECK: define void @_Z2f3v()
+void f3() {
+ // CHECK: call void @_ZN2A1C1Ev(
+ // CHECK: call void @_ZN2A2C1Ev(
+ // CHECK: call void @_ZN1BC1ERK2A1RK2A2(
+ // CHECK: call void @_ZN2A2D1Ev
+ // CHECK: call void @_ZN2A1D1Ev
+ B *bs = new B[2];
+ delete bs;
+}
+
+void f4() {
+ void g4(int a, int b = 7);
+ {
+ void g4(int a, int b = 5);
+ }
+ void g4(int a = 5, int b);
+
+ // CHECK: call void @_Z2g4ii(i32 5, i32 7)
+ g4();
+}
diff --git a/clang/test/CodeGenCXX/default-constructor-default-argument.cpp b/clang/test/CodeGenCXX/default-constructor-default-argument.cpp
new file mode 100644
index 0000000..374a967
--- /dev/null
+++ b/clang/test/CodeGenCXX/default-constructor-default-argument.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// Check that call to constructor for struct A is generated correctly.
+struct A { A(int x = 2); };
+struct B : public A {};
+B x;
+
+// CHECK: call {{.*}} @_ZN1AC2Ei
diff --git a/clang/test/CodeGenCXX/default-constructor-for-members.cpp b/clang/test/CodeGenCXX/default-constructor-for-members.cpp
new file mode 100644
index 0000000..714811f
--- /dev/null
+++ b/clang/test/CodeGenCXX/default-constructor-for-members.cpp
@@ -0,0 +1,24 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+extern "C" int printf(...);
+
+struct S {
+ S() { printf("S::S()\n"); }
+ int iS;
+};
+
+struct M {
+ S ARR_S;
+};
+
+int main() {
+ M m1;
+}
+
+// CHECK-LP64: callq __ZN1SC1Ev
+
+// CHECK-LP32: calll L__ZN1SC1Ev
diff --git a/clang/test/CodeGenCXX/default-constructor-template-member.cpp b/clang/test/CodeGenCXX/default-constructor-template-member.cpp
new file mode 100644
index 0000000..0dd64df
--- /dev/null
+++ b/clang/test/CodeGenCXX/default-constructor-template-member.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+template <class T> struct A { A(); };
+struct B { A<int> x; };
+void a() {
+ B b;
+}
+// CHECK: call {{.*}} @_ZN1BC1Ev
+// CHECK: define linkonce_odr {{.*}} @_ZN1BC1Ev(%struct.B* %this) unnamed_addr
+// CHECK: call {{.*}} @_ZN1AIiEC1Ev
diff --git a/clang/test/CodeGenCXX/default-destructor-nested.cpp b/clang/test/CodeGenCXX/default-destructor-nested.cpp
new file mode 100644
index 0000000..565a727
--- /dev/null
+++ b/clang/test/CodeGenCXX/default-destructor-nested.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -emit-llvm-only
+// PR6294
+
+class A {
+public: virtual ~A();
+};
+class B {
+ class C;
+};
+class B::C : public A {
+ C();
+};
+B::C::C() {}
diff --git a/clang/test/CodeGenCXX/default-destructor-synthesis.cpp b/clang/test/CodeGenCXX/default-destructor-synthesis.cpp
new file mode 100644
index 0000000..fac5cc0
--- /dev/null
+++ b/clang/test/CodeGenCXX/default-destructor-synthesis.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -O2 -o - | FileCheck %s
+static int count = 0;
+
+struct S {
+ S() { count++; }
+ ~S() { count--; }
+};
+
+struct P {
+ P() { count++; }
+ ~P() { count--; }
+};
+
+struct Q {
+ Q() { count++; }
+ ~Q() { count--; }
+};
+
+struct M : Q, P {
+ S s;
+ Q q;
+ P p;
+ P p_arr[3];
+ Q q_arr[2][3];
+};
+
+// CHECK: define i32 @_Z1fv() nounwind
+int f() {
+ {
+ count = 1;
+ M a;
+ }
+
+ // CHECK: ret i32 1
+ return count;
+}
diff --git a/clang/test/CodeGenCXX/deferred-global-init.cpp b/clang/test/CodeGenCXX/deferred-global-init.cpp
new file mode 100644
index 0000000..24c8c67
--- /dev/null
+++ b/clang/test/CodeGenCXX/deferred-global-init.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// PR5967
+
+extern void* foo;
+static void* const a = foo;
+void* bar() { return a; }
+
+// CHECK: @_ZL1a = internal global i8* null
+
+// CHECK: define internal void @__cxx_global_var_init
+// CHECK: load i8** @foo
+// CHECK: ret void
+
+// CHECK: define internal void @_GLOBAL__I_a
+// CHECK: call void @__cxx_global_var_init()
+// CHECK: ret void
diff --git a/clang/test/CodeGenCXX/delete-two-arg.cpp b/clang/test/CodeGenCXX/delete-two-arg.cpp
new file mode 100644
index 0000000..b82e9ba
--- /dev/null
+++ b/clang/test/CodeGenCXX/delete-two-arg.cpp
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu %s -o - -emit-llvm -verify | FileCheck %s
+
+typedef __typeof(sizeof(int)) size_t;
+
+namespace test1 {
+ struct A { void operator delete(void*,size_t); int x; };
+
+ // CHECK: define void @_ZN5test11aEPNS_1AE(
+ void a(A *x) {
+ // CHECK: load
+ // CHECK-NEXT: icmp eq {{.*}}, null
+ // CHECK-NEXT: br i1
+ // CHECK: call void @_ZN5test11AdlEPvj(i8* %{{.*}}, i32 4)
+ delete x;
+ }
+}
+
+// Check that we make cookies for the two-arg delete even when using
+// the global allocator and deallocator.
+namespace test2 {
+ struct A {
+ int x;
+ void *operator new[](size_t);
+ void operator delete[](void *, size_t);
+ };
+
+ // CHECK: define [[A:%.*]]* @_ZN5test24testEv()
+ A *test() {
+ // CHECK: [[NEW:%.*]] = call noalias i8* @_Znaj(i32 44)
+ // CHECK-NEXT: [[T0:%.*]] = bitcast i8* [[NEW]] to i32*
+ // CHECK-NEXT: store i32 10, i32* [[T0]]
+ // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8* [[NEW]], i64 4
+ // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to [[A]]*
+ // CHECK-NEXT: ret [[A]]* [[T2]]
+ return ::new A[10];
+ }
+
+ // CHECK: define void @_ZN5test24testEPNS_1AE(
+ void test(A *p) {
+ // CHECK: [[P:%.*]] = alloca [[A]]*, align 4
+ // CHECK-NEXT: store [[A]]* {{%.*}}, [[A]]** [[P]], align 4
+ // CHECK-NEXT: [[T0:%.*]] = load [[A]]** [[P]], align 4
+ // CHECK-NEXT: [[T1:%.*]] = icmp eq [[A]]* [[T0]], null
+ // CHECK-NEXT: br i1 [[T1]],
+ // CHECK: [[T2:%.*]] = bitcast [[A]]* [[T0]] to i8*
+ // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8* [[T2]], i64 -4
+ // CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i32*
+ // CHECK-NEXT: [[T5:%.*]] = load i32* [[T4]]
+ // CHECK-NEXT: call void @_ZdaPv(i8* [[T3]])
+ // CHECK-NEXT: br label
+ ::delete[] p;
+ }
+}
+
+// rdar://problem/8913519
+namespace test3 {
+ struct A {
+ int x;
+ void operator delete[](void *, size_t);
+ };
+ struct B : A {};
+
+ // CHECK: define void @_ZN5test34testEv()
+ void test() {
+ // CHECK: call noalias i8* @_Znaj(i32 24)
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: store i32 5
+ (void) new B[5];
+ }
+}
diff --git a/clang/test/CodeGenCXX/delete.cpp b/clang/test/CodeGenCXX/delete.cpp
new file mode 100644
index 0000000..5a88f9f
--- /dev/null
+++ b/clang/test/CodeGenCXX/delete.cpp
@@ -0,0 +1,135 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -emit-llvm -o - | FileCheck %s
+
+void t1(int *a) {
+ delete a;
+}
+
+struct S {
+ int a;
+};
+
+// POD types.
+void t3(S *s) {
+ delete s;
+}
+
+// Non-POD
+struct T {
+ ~T();
+ int a;
+};
+
+// CHECK: define void @_Z2t4P1T
+void t4(T *t) {
+ // CHECK: call void @_ZN1TD1Ev
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: call void @_ZdlPv
+ delete t;
+}
+
+// PR5102
+template <typename T>
+class A {
+ public: operator T *() const;
+};
+
+void f() {
+ A<char*> a;
+
+ delete a;
+}
+
+namespace test0 {
+ struct A {
+ void *operator new(__SIZE_TYPE__ sz);
+ void operator delete(void *p) { ::operator delete(p); }
+ ~A() {}
+ };
+
+ // CHECK: define void @_ZN5test04testEPNS_1AE(
+ void test(A *a) {
+ // CHECK: call void @_ZN5test01AD1Ev
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: call void @_ZN5test01AdlEPv
+ delete a;
+ }
+
+ // CHECK: define linkonce_odr void @_ZN5test01AD1Ev(%"struct.test0::A"* %this) unnamed_addr
+ // CHECK: define linkonce_odr void @_ZN5test01AdlEPv
+}
+
+namespace test1 {
+ struct A {
+ int x;
+ ~A();
+ };
+
+ // CHECK: define void @_ZN5test14testEPA10_A20_NS_1AE(
+ void test(A (*arr)[10][20]) {
+ delete [] arr;
+ // CHECK: icmp eq [10 x [20 x [[A:%.*]]]]* [[PTR:%.*]], null
+ // CHECK-NEXT: br i1
+
+ // CHECK: [[BEGIN:%.*]] = getelementptr inbounds [10 x [20 x [[A]]]]* [[PTR]], i32 0, i32 0, i32 0
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [[A]]* [[BEGIN]] to i8*
+ // CHECK-NEXT: [[ALLOC:%.*]] = getelementptr inbounds i8* [[T0]], i64 -8
+ // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[ALLOC]] to i64*
+ // CHECK-NEXT: [[COUNT:%.*]] = load i64* [[T1]]
+ // CHECK: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 [[COUNT]]
+ // CHECK-NEXT: [[ISEMPTY:%.*]] = icmp eq [[A]]* [[BEGIN]], [[END]]
+ // CHECK-NEXT: br i1 [[ISEMPTY]],
+ // CHECK: [[PAST:%.*]] = phi [[A]]* [ [[END]], {{%.*}} ], [ [[CUR:%.*]], {{%.*}} ]
+ // CHECK-NEXT: [[CUR:%.*]] = getelementptr inbounds [[A]]* [[PAST]], i64 -1
+ // CHECK-NEXT: call void @_ZN5test11AD1Ev([[A]]* [[CUR]])
+ // CHECK-NEXT: [[ISDONE:%.*]] = icmp eq [[A]]* [[CUR]], [[BEGIN]]
+ // CHECK-NEXT: br i1 [[ISDONE]]
+ // CHECK: call void @_ZdaPv(i8* [[ALLOC]])
+ }
+}
+
+namespace test2 {
+ // CHECK: define void @_ZN5test21fEPb
+ void f(bool *b) {
+ // CHECK: call void @_ZdlPv(i8*
+ delete b;
+ // CHECK: call void @_ZdaPv(i8*
+ delete [] b;
+ }
+}
+
+namespace test3 {
+ void f(int a[10][20]) {
+ // CHECK: call void @_ZdaPv(i8*
+ delete a;
+ }
+}
+
+namespace test4 {
+ // PR10341: ::delete with a virtual destructor
+ struct X {
+ virtual ~X();
+ void operator delete (void *);
+ };
+
+ // CHECK: define void @_ZN5test421global_delete_virtualEPNS_1XE
+ void global_delete_virtual(X *xp) {
+ // CHECK: [[VTABLE:%.*]] = load void ([[X:%.*]])***
+ // CHECK-NEXT: [[VFN:%.*]] = getelementptr inbounds void ([[X]])** [[VTABLE]], i64 0
+ // CHECK-NEXT: [[VFNPTR:%.*]] = load void ([[X]])** [[VFN]]
+ // CHECK-NEXT: call void [[VFNPTR]]([[X]] [[OBJ:%.*]])
+ // CHECK-NEXT: [[OBJVOID:%.*]] = bitcast [[X]] [[OBJ]] to i8*
+ // CHECK-NEXT: call void @_ZdlPv(i8* [[OBJVOID]]) nounwind
+ ::delete xp;
+ }
+}
+
+namespace test5 {
+ struct Incomplete;
+ // CHECK: define void @_ZN5test523array_delete_incompleteEPNS_10IncompleteES1_
+ void array_delete_incomplete(Incomplete *p1, Incomplete *p2) {
+ // CHECK: call void @_ZdlPv
+ delete p1;
+ // CHECK: call void @_ZdaPv
+ delete [] p2;
+ }
+}
diff --git a/clang/test/CodeGenCXX/dependent-type-member-pointer.cpp b/clang/test/CodeGenCXX/dependent-type-member-pointer.cpp
new file mode 100644
index 0000000..41bb5e2
--- /dev/null
+++ b/clang/test/CodeGenCXX/dependent-type-member-pointer.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm-only -verify %s
+// PR7736
+
+template <class scriptmemberptr> int InitMember(scriptmemberptr);
+
+template <class>
+struct contentmap
+{
+ static void InitDataMap()
+ { InitMember(&contentmap::SizeHolder); }
+ int SizeHolder;
+};
+
+void ReadFrom( )
+{
+ contentmap<int>::InitDataMap();
+}
+
diff --git a/clang/test/CodeGenCXX/derived-to-base-conv.cpp b/clang/test/CodeGenCXX/derived-to-base-conv.cpp
new file mode 100644
index 0000000..8c51809
--- /dev/null
+++ b/clang/test/CodeGenCXX/derived-to-base-conv.cpp
@@ -0,0 +1,85 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+extern "C" int printf(...);
+extern "C" void exit(int);
+
+struct A {
+ A (const A&) { printf("A::A(const A&)\n"); }
+ A() {};
+ ~A() { printf("A::~A()\n"); }
+};
+
+struct B : public A {
+ B() {};
+ B(const B& Other) : A(Other) { printf("B::B(const B&)\n"); }
+ ~B() { printf("B::~B()\n"); }
+};
+
+struct C : public B {
+ C() {};
+ C(const C& Other) : B(Other) { printf("C::C(const C&)\n"); }
+ ~C() { printf("C::~C()\n"); }
+};
+
+struct X {
+ operator B&() {printf("X::operator B&()\n"); return b; }
+ operator C&() {printf("X::operator C&()\n"); return c; }
+ X (const X&) { printf("X::X(const X&)\n"); }
+ X () { printf("X::X()\n"); }
+ ~X () { printf("X::~X()\n"); }
+ B b;
+ C c;
+};
+
+void f(A) {
+ printf("f(A)\n");
+}
+
+
+void func(X x)
+{
+ f (x);
+}
+
+int main()
+{
+ X x;
+ func(x);
+}
+
+struct Base;
+
+struct Root {
+ operator Base&() { exit(1); }
+};
+
+struct Derived;
+
+struct Base : Root {
+ Base(const Base&) { printf("Base::(const Base&)\n"); }
+ Base() { printf("Base::Base()\n"); }
+ operator Derived&() { exit(1); }
+};
+
+struct Derived : Base {
+};
+
+void foo(Base) {}
+
+void test(Derived bb)
+{
+ // CHECK-LP64-NOT: callq __ZN4BasecvR7DerivedEv
+ // CHECK-LP32-NOT: callq L__ZN4BasecvR7DerivedEv
+ foo(bb);
+}
+// CHECK-LP64: callq __ZN1XcvR1BEv
+// CHECK-LP64: callq __ZN1AC1ERKS_
+
+// CHECK-LP32: calll L__ZN1XcvR1BEv
+// CHECK-LP32: calll L__ZN1AC1ERKS_
+
+
diff --git a/clang/test/CodeGenCXX/derived-to-base.cpp b/clang/test/CodeGenCXX/derived-to-base.cpp
new file mode 100644
index 0000000..76b79fc
--- /dev/null
+++ b/clang/test/CodeGenCXX/derived-to-base.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+struct A {
+ void f();
+
+ int a;
+};
+
+struct B : A {
+ double b;
+};
+
+void f() {
+ B b;
+
+ b.f();
+}
+
+// CHECK: define %struct.B* @_Z1fP1A(%struct.A* %a) nounwind
+B *f(A *a) {
+ // CHECK-NOT: br label
+ // CHECK: ret %struct.B*
+ return static_cast<B*>(a);
+}
+
+// PR5965
+namespace PR5965 {
+
+// CHECK: define %struct.A* @_ZN6PR59651fEP1B(%struct.B* %b) nounwind
+A *f(B* b) {
+ // CHECK-NOT: br label
+ // CHECK: ret %struct.A*
+ return b;
+}
+
+}
+
+// Don't crash on a derived-to-base conversion of an r-value
+// aggregate.
+namespace test3 {
+ struct A {};
+ struct B : A {};
+
+ void foo(A a);
+ void test() {
+ foo(B());
+ }
+}
diff --git a/clang/test/CodeGenCXX/derived-to-virtual-base-class-calls-final.cpp b/clang/test/CodeGenCXX/derived-to-virtual-base-class-calls-final.cpp
new file mode 100644
index 0000000..0e15302
--- /dev/null
+++ b/clang/test/CodeGenCXX/derived-to-virtual-base-class-calls-final.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+struct A { int i; };
+struct B { char j; };
+struct C : A, B { int k; };
+
+struct D final : virtual C {
+ D();
+ virtual void f();
+};
+
+// CHECK: define %struct.B* @_Z1fR1D
+B &f(D &d) {
+ // CHECK-NOT: load i8**
+ return d;
+}
diff --git a/clang/test/CodeGenCXX/destructor-calls.cpp b/clang/test/CodeGenCXX/destructor-calls.cpp
new file mode 100644
index 0000000..4da46a4
--- /dev/null
+++ b/clang/test/CodeGenCXX/destructor-calls.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+
+extern "C" int printf(...);
+
+static int val;
+
+struct B {
+ B() : iB(++val) { printf("B()\n"); }
+ int iB;
+ ~B() { printf("~B(%d)\n", iB); --val; }
+};
+
+struct M : B {
+ M() : iM(++val) { printf("M()\n"); }
+ int iM;
+ ~M() { printf("~M(%d)\n", iM); --val; }
+};
+
+struct P {
+ P() : iP(++val) { printf("P()\n"); }
+ int iP;
+ ~P() { printf("~P(%d)\n", iP); --val; }
+};
+
+struct N : M, P {
+ N() { printf("N()\n"); iN = ++val; }
+ ~N() { printf("~N(%d) val = %d\n", iN, --val); }
+ int iN;
+ M m;
+ P p;
+};
+
+struct O : B {
+ ~O() { return; }
+};
+
+int main() {
+ N n1;
+ N n2;
+ O o;
+}
diff --git a/clang/test/CodeGenCXX/destructor-debug-info.cpp b/clang/test/CodeGenCXX/destructor-debug-info.cpp
new file mode 100644
index 0000000..9e32275
--- /dev/null
+++ b/clang/test/CodeGenCXX/destructor-debug-info.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -g -S -emit-llvm -o %t %s
+// RUN: grep "i32 20, i32 3, metadata" %t | count 1
+// Check there is a line number entry for line 20 where b1 is destructed.
+class A { int a; };
+class B {
+public:
+ B() { a = new A; }
+ ~B() { delete a; }
+private:
+ A *a;
+};
+
+void fn(B b);
+
+int i;
+void foo() {
+ if (i) {
+ B b1;
+ fn (b1);
+ }
+}
diff --git a/clang/test/CodeGenCXX/destructors.cpp b/clang/test/CodeGenCXX/destructors.cpp
new file mode 100644
index 0000000..d9962e6
--- /dev/null
+++ b/clang/test/CodeGenCXX/destructors.cpp
@@ -0,0 +1,403 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - -mconstructor-aliases -fcxx-exceptions -fexceptions | FileCheck %s
+
+// CHECK: @_ZN5test01AD1Ev = alias {{.*}} @_ZN5test01AD2Ev
+// CHECK: @_ZN5test11MD2Ev = alias {{.*}} @_ZN5test11AD2Ev
+// CHECK: @_ZN5test11ND2Ev = alias {{.*}} @_ZN5test11AD2Ev
+// CHECK: @_ZN5test11OD2Ev = alias {{.*}} @_ZN5test11AD2Ev
+// CHECK: @_ZN5test11SD2Ev = alias bitcast {{.*}} @_ZN5test11AD2Ev
+
+// CHECK: @_ZN5test312_GLOBAL__N_11DD1Ev = alias internal {{.*}} @_ZN5test312_GLOBAL__N_11DD2Ev
+// CHECK: @_ZN5test312_GLOBAL__N_11DD2Ev = alias internal bitcast {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
+// CHECK: @_ZN5test312_GLOBAL__N_11CD1Ev = alias internal {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
+
+struct A {
+ int a;
+
+ ~A();
+};
+
+// Base with non-trivial destructor
+struct B : A {
+ ~B();
+};
+
+B::~B() { }
+
+// Field with non-trivial destructor
+struct C {
+ A a;
+
+ ~C();
+};
+
+C::~C() { }
+
+namespace PR7526 {
+ extern void foo();
+ struct allocator {
+ ~allocator() throw();
+ };
+
+ struct allocator_derived : allocator { };
+
+ // CHECK: define void @_ZN6PR75269allocatorD2Ev(%"struct.PR7526::allocator"* %this) unnamed_addr
+ // CHECK: call void @__cxa_call_unexpected
+ allocator::~allocator() throw() { foo(); }
+
+ // CHECK: define linkonce_odr void @_ZN6PR752617allocator_derivedD1Ev(%"struct.PR7526::allocator_derived"* %this) unnamed_addr
+ // CHECK-NOT: call void @__cxa_call_unexpected
+ // CHECK: }
+ void foo() {
+ allocator_derived ad;
+ }
+}
+
+// PR5084
+template<typename T>
+class A1 {
+ ~A1();
+};
+
+template<> A1<char>::~A1();
+
+// PR5529
+namespace PR5529 {
+ struct A {
+ ~A();
+ };
+
+ A::~A() { }
+ struct B : A {
+ virtual ~B();
+ };
+
+ B::~B() {}
+}
+
+// FIXME: there's a known problem in the codegen here where, if one
+// destructor throws, the remaining destructors aren't run. Fix it,
+// then make this code check for it.
+namespace test0 {
+ void foo();
+ struct VBase { ~VBase(); };
+ struct Base { ~Base(); };
+ struct Member { ~Member(); };
+
+ struct A : Base {
+ Member M;
+ ~A();
+ };
+
+ // The function-try-block won't suppress -mconstructor-aliases here.
+ A::~A() try { } catch (int i) {}
+
+// complete destructor alias tested above
+
+// CHECK: define void @_ZN5test01AD2Ev(%"struct.test0::A"* %this) unnamed_addr
+// CHECK: invoke void @_ZN5test06MemberD1Ev
+// CHECK: unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]]
+// CHECK: invoke void @_ZN5test04BaseD2Ev
+// CHECK: unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
+
+ struct B : Base, virtual VBase {
+ Member M;
+ ~B();
+ };
+ B::~B() try { } catch (int i) {}
+ // It will suppress the delegation optimization here, though.
+
+// CHECK: define void @_ZN5test01BD1Ev(%"struct.test0::B"* %this) unnamed_addr
+// CHECK: invoke void @_ZN5test06MemberD1Ev
+// CHECK: unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]]
+// CHECK: invoke void @_ZN5test04BaseD2Ev
+// CHECK: unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
+// CHECK: invoke void @_ZN5test05VBaseD2Ev
+// CHECK: unwind label [[VBASE_UNWIND:%[a-zA-Z0-9.]+]]
+
+// CHECK: define void @_ZN5test01BD2Ev(%"struct.test0::B"* %this, i8** %vtt) unnamed_addr
+// CHECK: invoke void @_ZN5test06MemberD1Ev
+// CHECK: unwind label [[MEM_UNWIND:%[a-zA-Z0-9.]+]]
+// CHECK: invoke void @_ZN5test04BaseD2Ev
+// CHECK: unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
+}
+
+// Test base-class aliasing.
+namespace test1 {
+ struct A { ~A(); char ***m; }; // non-trivial destructor
+ struct B { ~B(); }; // non-trivial destructor
+ struct Empty { }; // trivial destructor, empty
+ struct NonEmpty { int x; }; // trivial destructor, non-empty
+
+ // There must be a definition in this translation unit for the alias
+ // optimization to apply.
+ A::~A() { delete m; }
+
+ struct M : A { ~M(); };
+ M::~M() {} // alias tested above
+
+ struct N : A, Empty { ~N(); };
+ N::~N() {} // alias tested above
+
+ struct O : Empty, A { ~O(); };
+ O::~O() {} // alias tested above
+
+ struct P : NonEmpty, A { ~P(); };
+ P::~P() {} // CHECK: define void @_ZN5test11PD2Ev(%"struct.test1::P"* %this) unnamed_addr
+
+ struct Q : A, B { ~Q(); };
+ Q::~Q() {} // CHECK: define void @_ZN5test11QD2Ev(%"struct.test1::Q"* %this) unnamed_addr
+
+ struct R : A { ~R(); };
+ R::~R() { A a; } // CHECK: define void @_ZN5test11RD2Ev(%"struct.test1::R"* %this) unnamed_addr
+
+ struct S : A { ~S(); int x; };
+ S::~S() {} // alias tested above
+
+ struct T : A { ~T(); B x; };
+ T::~T() {} // CHECK: define void @_ZN5test11TD2Ev(%"struct.test1::T"* %this) unnamed_addr
+
+ // The VTT parameter prevents this. We could still make this work
+ // for calling conventions that are safe against extra parameters.
+ struct U : A, virtual B { ~U(); };
+ U::~U() {} // CHECK: define void @_ZN5test11UD2Ev(%"struct.test1::U"* %this, i8** %vtt) unnamed_addr
+}
+
+// PR6471
+namespace test2 {
+ struct A { ~A(); char ***m; };
+ struct B : A { ~B(); };
+
+ B::~B() {}
+ // CHECK: define void @_ZN5test21BD2Ev(%"struct.test2::B"* %this) unnamed_addr
+ // CHECK: call void @_ZN5test21AD2Ev
+}
+
+// PR7142
+namespace test3 {
+ struct A { virtual ~A(); };
+ struct B { virtual ~B(); };
+ namespace { // internal linkage => deferred
+ struct C : A, B {}; // ~B() in D requires a this-adjustment thunk
+ struct D : C {}; // D::~D() is an alias to C::~C()
+ }
+
+ void test() {
+ new D; // Force emission of D's vtable
+ }
+
+ // Checked at top of file:
+ // @_ZN5test312_GLOBAL__N_11CD1Ev = alias internal {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
+
+ // More checks at end of file.
+
+}
+
+namespace test4 {
+ struct A { ~A(); };
+
+ // CHECK: define void @_ZN5test43fooEv()
+ // CHECK: call void @_ZN5test41AD1Ev
+ // CHECK: ret void
+ void foo() {
+ {
+ A a;
+ goto failure;
+ }
+
+ failure:
+ return;
+ }
+
+ // CHECK: define void @_ZN5test43barEi(
+ // CHECK: [[X:%.*]] = alloca i32
+ // CHECK-NEXT: [[A:%.*]] = alloca
+ // CHECK: br label
+ // CHECK: [[TMP:%.*]] = load i32* [[X]]
+ // CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[TMP]], 0
+ // CHECK-NEXT: br i1
+ // CHECK: call void @_ZN5test41AD1Ev(
+ // CHECK: br label
+ // CHECK: [[TMP:%.*]] = load i32* [[X]]
+ // CHECK: [[TMP2:%.*]] = add nsw i32 [[TMP]], -1
+ // CHECK: store i32 [[TMP2]], i32* [[X]]
+ // CHECK: br label
+ // CHECK: ret void
+ void bar(int x) {
+ for (A a; x; ) {
+ x--;
+ }
+ }
+}
+
+// PR7575
+namespace test5 {
+ struct A { ~A(); };
+
+ // CHECK: define void @_ZN5test53fooEv()
+ // CHECK: [[ELEMS:%.*]] = alloca [5 x [[A:%.*]]], align
+ // CHECK-NEXT: [[EXN:%.*]] = alloca i8*
+ // CHECK-NEXT: [[SEL:%.*]] = alloca i32
+ // CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [5 x [[A]]]* [[ELEMS]], i32 0, i32 0
+ // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 5
+ // CHECK-NEXT: br label
+ // CHECK: [[POST:%.*]] = phi [[A]]* [ [[END]], {{%.*}} ], [ [[ELT:%.*]], {{%.*}} ]
+ // CHECK-NEXT: [[ELT]] = getelementptr inbounds [[A]]* [[POST]], i64 -1
+ // CHECK-NEXT: invoke void @_ZN5test51AD1Ev([[A]]* [[ELT]])
+ // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[ELT]], [[BEGIN]]
+ // CHECK-NEXT: br i1 [[T0]],
+ // CHECK: ret void
+ // lpad
+ // CHECK: [[EMPTY:%.*]] = icmp eq [[A]]* [[BEGIN]], [[ELT]]
+ // CHECK-NEXT: br i1 [[EMPTY]]
+ // CHECK: [[AFTER:%.*]] = phi [[A]]* [ [[ELT]], {{%.*}} ], [ [[CUR:%.*]], {{%.*}} ]
+ // CHECK-NEXT: [[CUR:%.*]] = getelementptr inbounds [[A]]* [[AFTER]], i64 -1
+ // CHECK-NEXT: invoke void @_ZN5test51AD1Ev([[A]]* [[CUR]])
+ // CHECK: [[DONE:%.*]] = icmp eq [[A]]* [[CUR]], [[BEGIN]]
+ // CHECK-NEXT: br i1 [[DONE]],
+ void foo() {
+ A elems[5];
+ }
+}
+
+namespace test6 {
+ void opaque();
+
+ struct A { ~A(); };
+ template <unsigned> struct B { B(); ~B(); int _; };
+ struct C : B<0>, B<1>, virtual B<2>, virtual B<3> {
+ A x, y, z;
+
+ C();
+ ~C();
+ };
+
+ C::C() { opaque(); }
+ // CHECK: define void @_ZN5test61CC1Ev(%"struct.test6::C"* %this) unnamed_addr
+ // CHECK: call void @_ZN5test61BILj2EEC2Ev
+ // CHECK: invoke void @_ZN5test61BILj3EEC2Ev
+ // CHECK: invoke void @_ZN5test61BILj0EEC2Ev
+ // CHECK: invoke void @_ZN5test61BILj1EEC2Ev
+ // CHECK: invoke void @_ZN5test66opaqueEv
+ // CHECK: ret void
+ // FIXME: way too much EH cleanup code follows
+
+ C::~C() { opaque(); }
+ // CHECK: define void @_ZN5test61CD1Ev(%"struct.test6::C"* %this) unnamed_addr
+ // CHECK: invoke void @_ZN5test61CD2Ev
+ // CHECK: invoke void @_ZN5test61BILj3EED2Ev
+ // CHECK: call void @_ZN5test61BILj2EED2Ev
+ // CHECK: ret void
+ // CHECK: invoke void @_ZN5test61BILj3EED2Ev
+ // CHECK: invoke void @_ZN5test61BILj2EED2Ev
+
+ // CHECK: define void @_ZN5test61CD2Ev(%"struct.test6::C"* %this, i8** %vtt) unnamed_addr
+ // CHECK: invoke void @_ZN5test66opaqueEv
+ // CHECK: invoke void @_ZN5test61AD1Ev
+ // CHECK: invoke void @_ZN5test61AD1Ev
+ // CHECK: invoke void @_ZN5test61AD1Ev
+ // CHECK: invoke void @_ZN5test61BILj1EED2Ev
+ // CHECK: call void @_ZN5test61BILj0EED2Ev
+ // CHECK: ret void
+ // CHECK: invoke void @_ZN5test61AD1Ev
+ // CHECK: invoke void @_ZN5test61AD1Ev
+ // CHECK: invoke void @_ZN5test61AD1Ev
+ // CHECK: invoke void @_ZN5test61BILj1EED2Ev
+ // CHECK: invoke void @_ZN5test61BILj0EED2Ev
+}
+
+// PR 9197
+namespace test7 {
+ struct D { ~D(); };
+
+ struct A { ~A(); };
+ A::~A() { }
+
+ struct B : public A {
+ ~B();
+ D arr[1];
+ };
+
+ // Verify that this doesn't get emitted as an alias
+ // CHECK: define void @_ZN5test71BD2Ev(
+ // CHECK: invoke void @_ZN5test71DD1Ev(
+ // CHECK: call void @_ZN5test71AD2Ev(
+ B::~B() {}
+}
+
+// PR10467
+namespace test8 {
+ struct A { A(); ~A(); };
+
+ void die() __attribute__((noreturn));
+ void test() {
+ A x;
+ while (1) {
+ A y;
+ goto l;
+ }
+ l: die();
+ }
+
+ // CHECK: define void @_ZN5test84testEv()
+ // CHECK: [[X:%.*]] = alloca [[A:%.*]], align 1
+ // CHECK-NEXT: [[Y:%.*]] = alloca [[A:%.*]], align 1
+ // CHECK: call void @_ZN5test81AC1Ev([[A]]* [[X]])
+ // CHECK-NEXT: br label
+ // CHECK: invoke void @_ZN5test81AC1Ev([[A]]* [[Y]])
+ // CHECK: invoke void @_ZN5test81AD1Ev([[A]]* [[Y]])
+ // CHECK-NOT: switch
+ // CHECK: invoke void @_ZN5test83dieEv()
+ // CHECK: unreachable
+}
+
+// Checks from test3:
+
+ // CHECK: define internal void @_ZN5test312_GLOBAL__N_11DD0Ev(%"struct.test3::<anonymous namespace>::D"* %this) unnamed_addr
+ // CHECK: invoke void @_ZN5test312_GLOBAL__N_11DD1Ev(
+ // CHECK: call void @_ZdlPv({{.*}}) nounwind
+ // CHECK: ret void
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-NEXT: cleanup
+ // CHECK: call void @_ZdlPv({{.*}}) nounwind
+ // CHECK: resume { i8*, i32 }
+
+ // Checked at top of file:
+ // @_ZN5test312_GLOBAL__N_11DD1Ev = alias internal {{.*}} @_ZN5test312_GLOBAL__N_11DD2Ev
+ // @_ZN5test312_GLOBAL__N_11DD2Ev = alias internal bitcast {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
+
+ // CHECK: define internal void @_ZThn8_N5test312_GLOBAL__N_11DD1Ev(
+ // CHECK: getelementptr inbounds i8* {{.*}}, i64 -8
+ // CHECK: call void @_ZN5test312_GLOBAL__N_11DD1Ev(
+ // CHECK: ret void
+
+ // CHECK: define internal void @_ZThn8_N5test312_GLOBAL__N_11DD0Ev(
+ // CHECK: getelementptr inbounds i8* {{.*}}, i64 -8
+ // CHECK: call void @_ZN5test312_GLOBAL__N_11DD0Ev(
+ // CHECK: ret void
+
+ // CHECK: define internal void @_ZN5test312_GLOBAL__N_11CD2Ev(%"struct.test3::<anonymous namespace>::C"* %this) unnamed_addr
+ // CHECK: invoke void @_ZN5test31BD2Ev(
+ // CHECK: call void @_ZN5test31AD2Ev(
+ // CHECK: ret void
+
+ // CHECK: declare void @_ZN5test31BD2Ev(
+ // CHECK: declare void @_ZN5test31AD2Ev(
+
+ // CHECK: define internal void @_ZN5test312_GLOBAL__N_11CD0Ev(%"struct.test3::<anonymous namespace>::C"* %this) unnamed_addr
+ // CHECK: invoke void @_ZN5test312_GLOBAL__N_11CD1Ev(
+ // CHECK: call void @_ZdlPv({{.*}}) nounwind
+ // CHECK: ret void
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-NEXT: cleanup
+ // CHECK: call void @_ZdlPv({{.*}}) nounwind
+ // CHECK: resume { i8*, i32 }
+
+ // CHECK: define internal void @_ZThn8_N5test312_GLOBAL__N_11CD1Ev(
+ // CHECK: getelementptr inbounds i8* {{.*}}, i64 -8
+ // CHECK: call void @_ZN5test312_GLOBAL__N_11CD1Ev(
+ // CHECK: ret void
+
+ // CHECK: define internal void @_ZThn8_N5test312_GLOBAL__N_11CD0Ev(
+ // CHECK: getelementptr inbounds i8* {{.*}}, i64 -8
+ // CHECK: call void @_ZN5test312_GLOBAL__N_11CD0Ev(
+ // CHECK: ret void
diff --git a/clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp b/clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
new file mode 100644
index 0000000..3de75ed
--- /dev/null
+++ b/clang/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+namespace Test1 {
+ struct A {
+ virtual int f() final;
+ };
+
+ // CHECK: define i32 @_ZN5Test11fEPNS_1AE
+ int f(A *a) {
+ // CHECK: call i32 @_ZN5Test11A1fEv
+ return a->f();
+ }
+}
+
+namespace Test2 {
+ struct A final {
+ virtual int f();
+ };
+
+ // CHECK: define i32 @_ZN5Test21fEPNS_1AE
+ int f(A *a) {
+ // CHECK: call i32 @_ZN5Test21A1fEv
+ return a->f();
+ }
+}
+
+namespace Test3 {
+ struct A {
+ virtual int f();
+ };
+
+ struct B final : A { };
+
+ // CHECK: define i32 @_ZN5Test31fEPNS_1BE
+ int f(B *b) {
+ // CHECK: call i32 @_ZN5Test31A1fEv
+ return b->f();
+ }
+
+ // CHECK: define i32 @_ZN5Test31fERNS_1BE
+ int f(B &b) {
+ // CHECK: call i32 @_ZN5Test31A1fEv
+ return b.f();
+ }
+
+ // CHECK: define i32 @_ZN5Test31fEPv
+ int f(void *v) {
+ // CHECK: call i32 @_ZN5Test31A1fEv
+ return static_cast<B*>(v)->f();
+ }
+}
diff --git a/clang/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp b/clang/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp
new file mode 100644
index 0000000..5eede66
--- /dev/null
+++ b/clang/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+struct A {
+ virtual void f();
+ virtual void f_const() const;
+
+ A h();
+};
+
+A g();
+
+void f(A a, A *ap, A& ar) {
+ // This should not be a virtual function call.
+
+ // CHECK: call void @_ZN1A1fEv(%struct.A* %a)
+ a.f();
+
+ // CHECK: call void %
+ ap->f();
+
+ // CHECK: call void %
+ ar.f();
+
+ // CHECK: call void @_ZN1A1fEv
+ A().f();
+
+ // CHECK: call void @_ZN1A1fEv
+ g().f();
+
+ // CHECK: call void @_ZN1A1fEv
+ a.h().f();
+
+ // CHECK: call void @_ZNK1A7f_constEv
+ a.f_const();
+
+ // CHECK: call void @_ZN1A1fEv
+ (a).f();
+}
+
+struct B {
+ virtual void f();
+ ~B();
+
+ B h();
+};
+
+
+void f() {
+ // CHECK: call void @_ZN1B1fEv
+ B().f();
+
+ // CHECK: call void @_ZN1B1fEv
+ B().h().f();
+}
+
diff --git a/clang/test/CodeGenCXX/dynamic-cast-always-null.cpp b/clang/test/CodeGenCXX/dynamic-cast-always-null.cpp
new file mode 100644
index 0000000..2c3ea13
--- /dev/null
+++ b/clang/test/CodeGenCXX/dynamic-cast-always-null.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm -fcxx-exceptions -fexceptions -std=c++11 -o - | FileCheck %s
+struct A { virtual ~A(); };
+struct B final : A { };
+struct C { virtual ~C(); int c; };
+
+// CHECK: @_Z1fP1B
+C *f(B* b) {
+ // CHECK-NOT: call i8* @__dynamic_cast
+ // CHECK: ret %struct.C* null
+ return dynamic_cast<C*>(b);
+}
+
+// CHECK: @_Z1fR1B
+C &f(B& b) {
+ // CHECK-NOT: call i8* @__dynamic_cast
+ // CHECK: call void @__cxa_bad_cast() noreturn
+ // CHECK: ret %struct.C* undef
+ return dynamic_cast<C&>(b);
+}
diff --git a/clang/test/CodeGenCXX/dynamic-cast.cpp b/clang/test/CodeGenCXX/dynamic-cast.cpp
new file mode 100644
index 0000000..813e36e
--- /dev/null
+++ b/clang/test/CodeGenCXX/dynamic-cast.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm -fcxx-exceptions -fexceptions -o - | FileCheck %s
+struct A { virtual void f(); };
+struct B : A { };
+
+// CHECK: {{define.*@_Z1fP1A}}
+B fail;
+const B& f(A *a) {
+ try {
+ // CHECK: call i8* @__dynamic_cast
+ // CHECK: br i1
+ // CHECK: invoke void @__cxa_bad_cast() noreturn
+ dynamic_cast<const B&>(*a);
+ } catch (...) {
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-NEXT: catch i8* null
+ }
+ return fail;
+}
diff --git a/clang/test/CodeGenCXX/eh.cpp b/clang/test/CodeGenCXX/eh.cpp
new file mode 100644
index 0000000..584af40
--- /dev/null
+++ b/clang/test/CodeGenCXX/eh.cpp
@@ -0,0 +1,446 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s
+
+struct test1_D {
+ double d;
+} d1;
+
+void test1() {
+ throw d1;
+}
+
+// CHECK: define void @_Z5test1v()
+// CHECK: [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 8)
+// CHECK-NEXT: [[EXN:%.*]] = bitcast i8* [[EXNOBJ]] to [[DSTAR:%[^*]*\*]]
+// CHECK-NEXT: [[EXN2:%.*]] = bitcast [[DSTAR]] [[EXN]] to i8*
+// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[EXN2]], i8* bitcast ([[DSTAR]] @d1 to i8*), i64 8, i32 8, i1 false)
+// CHECK-NEXT: call void @__cxa_throw(i8* [[EXNOBJ]], i8* bitcast ({ i8*, i8* }* @_ZTI7test1_D to i8*), i8* null) noreturn
+// CHECK-NEXT: unreachable
+
+
+struct test2_D {
+ test2_D(const test2_D&o);
+ test2_D();
+ virtual void bar() { }
+ int i; int j;
+} d2;
+
+void test2() {
+ throw d2;
+}
+
+// CHECK: define void @_Z5test2v()
+// CHECK: [[EXNVAR:%.*]] = alloca i8*
+// CHECK-NEXT: [[SELECTORVAR:%.*]] = alloca i32
+// CHECK-NEXT: [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 16)
+// CHECK-NEXT: [[EXN:%.*]] = bitcast i8* [[EXNOBJ]] to [[DSTAR:%[^*]*\*]]
+// CHECK-NEXT: invoke void @_ZN7test2_DC1ERKS_([[DSTAR]] [[EXN]], [[DSTAR]] @d2)
+// CHECK-NEXT: to label %[[CONT:.*]] unwind label %{{.*}}
+// : [[CONT]]: (can't check this in Release-Asserts builds)
+// CHECK: call void @__cxa_throw(i8* [[EXNOBJ]], i8* bitcast ({{.*}}* @_ZTI7test2_D to i8*), i8* null) noreturn
+// CHECK-NEXT: unreachable
+
+
+struct test3_D {
+ test3_D() { }
+ test3_D(volatile test3_D&o);
+ virtual void bar();
+};
+
+void test3() {
+ throw (volatile test3_D *)0;
+}
+
+// CHECK: define void @_Z5test3v()
+// CHECK: [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 8)
+// CHECK-NEXT: [[EXN:%.*]] = bitcast i8* [[EXNOBJ]] to [[D:%[^*]+]]**
+// CHECK-NEXT: store [[D]]* null, [[D]]** [[EXN]]
+// CHECK-NEXT: call void @__cxa_throw(i8* [[EXNOBJ]], i8* bitcast ({ i8*, i8*, i32, i8* }* @_ZTIPV7test3_D to i8*), i8* null) noreturn
+// CHECK-NEXT: unreachable
+
+
+void test4() {
+ throw;
+}
+
+// CHECK: define void @_Z5test4v()
+// CHECK: call void @__cxa_rethrow() noreturn
+// CHECK-NEXT: unreachable
+
+
+// rdar://problem/7696549
+namespace test5 {
+ struct A {
+ A();
+ A(const A&);
+ ~A();
+ };
+
+ void test() {
+ try { throw A(); } catch (A &x) {}
+ }
+// CHECK: define void @_ZN5test54testEv()
+// CHECK: [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 1)
+// CHECK: [[EXNCAST:%.*]] = bitcast i8* [[EXNOBJ]] to [[A:%[^*]*]]*
+// CHECK-NEXT: invoke void @_ZN5test51AC1Ev([[A]]* [[EXNCAST]])
+// CHECK: invoke void @__cxa_throw(i8* [[EXNOBJ]], i8* bitcast ({{.*}}* @_ZTIN5test51AE to i8*), i8* bitcast (void ([[A]]*)* @_ZN5test51AD1Ev to i8*)) noreturn
+// CHECK-NEXT: to label {{%.*}} unwind label %[[HANDLER:[^ ]*]]
+// : [[HANDLER]]: (can't check this in Release-Asserts builds)
+// CHECK: {{%.*}} = call i32 @llvm.eh.typeid.for(i8* bitcast ({{.*}}* @_ZTIN5test51AE to i8*))
+}
+
+namespace test6 {
+ template <class T> struct allocator {
+ ~allocator() throw() { }
+ };
+
+ void foo() {
+ allocator<int> a;
+ }
+}
+
+// PR7127
+namespace test7 {
+// CHECK: define i32 @_ZN5test73fooEv()
+ int foo() {
+// CHECK: [[CAUGHTEXNVAR:%.*]] = alloca i8*
+// CHECK-NEXT: [[SELECTORVAR:%.*]] = alloca i32
+// CHECK-NEXT: [[INTCATCHVAR:%.*]] = alloca i32
+ try {
+ try {
+// CHECK-NEXT: [[EXNALLOC:%.*]] = call i8* @__cxa_allocate_exception
+// CHECK-NEXT: bitcast i8* [[EXNALLOC]] to i32*
+// CHECK-NEXT: store i32 1, i32*
+// CHECK-NEXT: invoke void @__cxa_throw(i8* [[EXNALLOC]], i8* bitcast (i8** @_ZTIi to i8*), i8* null
+ throw 1;
+ }
+
+// CHECK: [[CAUGHTVAL:%.*]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+// CHECK-NEXT: catch i8* bitcast (i8** @_ZTIi to i8*)
+// CHECK-NEXT: catch i8* null
+// CHECK-NEXT: [[CAUGHTEXN:%.*]] = extractvalue { i8*, i32 } [[CAUGHTVAL]], 0
+// CHECK-NEXT: store i8* [[CAUGHTEXN]], i8** [[CAUGHTEXNVAR]]
+// CHECK-NEXT: [[SELECTOR:%.*]] = extractvalue { i8*, i32 } [[CAUGHTVAL]], 1
+// CHECK-NEXT: store i32 [[SELECTOR]], i32* [[SELECTORVAR]]
+// CHECK-NEXT: br label
+// CHECK: [[SELECTOR:%.*]] = load i32* [[SELECTORVAR]]
+// CHECK-NEXT: [[T0:%.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
+// CHECK-NEXT: icmp eq i32 [[SELECTOR]], [[T0]]
+// CHECK-NEXT: br i1
+// CHECK: [[T0:%.*]] = load i8** [[CAUGHTEXNVAR]]
+// CHECK-NEXT: [[T1:%.*]] = call i8* @__cxa_begin_catch(i8* [[T0]])
+// CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to i32*
+// CHECK-NEXT: [[T3:%.*]] = load i32* [[T2]]
+// CHECK-NEXT: store i32 [[T3]], i32* {{%.*}}, align 4
+// CHECK-NEXT: invoke void @__cxa_rethrow
+ catch (int) {
+ throw;
+ }
+ }
+// CHECK: [[CAUGHTVAL:%.*]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+// CHECK-NEXT: catch i8* null
+// CHECK-NEXT: [[CAUGHTEXN:%.*]] = extractvalue { i8*, i32 } [[CAUGHTVAL]], 0
+// CHECK-NEXT: store i8* [[CAUGHTEXN]], i8** [[CAUGHTEXNVAR]]
+// CHECK-NEXT: [[SELECTOR:%.*]] = extractvalue { i8*, i32 } [[CAUGHTVAL]], 1
+// CHECK-NEXT: store i32 [[SELECTOR]], i32* [[SELECTORVAR]]
+// CHECK-NEXT: call void @__cxa_end_catch()
+// CHECK-NEXT: br label
+// CHECK: load i8** [[CAUGHTEXNVAR]]
+// CHECK-NEXT: call i8* @__cxa_begin_catch
+// CHECK-NEXT: call void @__cxa_end_catch
+ catch (...) {
+ }
+// CHECK: ret i32 0
+ return 0;
+ }
+}
+
+// Ordering of destructors in a catch handler.
+namespace test8 {
+ struct A { A(const A&); ~A(); };
+ void bar();
+
+ // CHECK: define void @_ZN5test83fooEv()
+ void foo() {
+ try {
+ // CHECK: invoke void @_ZN5test83barEv()
+ bar();
+ } catch (A a) {
+ // CHECK: call i8* @__cxa_get_exception_ptr
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: invoke void @_ZN5test81AC1ERKS0_(
+ // CHECK: call i8* @__cxa_begin_catch
+ // CHECK-NEXT: call void @_ZN5test81AD1Ev(
+ // CHECK: call void @__cxa_end_catch()
+ // CHECK: ret void
+ }
+ }
+}
+
+// Constructor function-try-block must rethrow on fallthrough.
+// rdar://problem/7696603
+namespace test9 {
+ void opaque();
+
+ struct A { A(); };
+
+ // CHECK: define void @_ZN5test91AC1Ev(%"struct.test9::A"* %this) unnamed_addr
+ // CHECK: call void @_ZN5test91AC2Ev
+ // CHECK-NEXT: ret void
+
+ // CHECK: define void @_ZN5test91AC2Ev(%"struct.test9::A"* %this) unnamed_addr
+ A::A() try {
+ // CHECK: invoke void @_ZN5test96opaqueEv()
+ opaque();
+ } catch (int x) {
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-NEXT: catch i8* bitcast (i8** @_ZTIi to i8*)
+
+ // CHECK: call i8* @__cxa_begin_catch
+ // CHECK: invoke void @_ZN5test96opaqueEv()
+ // CHECK: invoke void @__cxa_rethrow()
+ opaque();
+ }
+}
+
+// __cxa_end_catch can throw for some kinds of caught exceptions.
+namespace test10 {
+ void opaque();
+
+ struct A { ~A(); };
+ struct B { int x; };
+
+ // CHECK: define void @_ZN6test103fooEv()
+ void foo() {
+ A a; // force a cleanup context
+
+ try {
+ // CHECK: invoke void @_ZN6test106opaqueEv()
+ opaque();
+ } catch (int i) {
+ // CHECK: call i8* @__cxa_begin_catch
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: load i32*
+ // CHECK-NEXT: store i32
+ // CHECK-NEXT: call void @__cxa_end_catch() nounwind
+ } catch (B a) {
+ // CHECK: call i8* @__cxa_begin_catch
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: call void @llvm.memcpy
+ // CHECK-NEXT: invoke void @__cxa_end_catch()
+ } catch (...) {
+ // CHECK: call i8* @__cxa_begin_catch
+ // CHECK-NEXT: invoke void @__cxa_end_catch()
+ }
+
+ // CHECK: call void @_ZN6test101AD1Ev(
+ }
+}
+
+// __cxa_begin_catch returns pointers by value, even when catching by reference
+// <rdar://problem/8212123>
+namespace test11 {
+ void opaque();
+
+ // CHECK: define void @_ZN6test113fooEv()
+ void foo() {
+ try {
+ // CHECK: invoke void @_ZN6test116opaqueEv()
+ opaque();
+ } catch (int**&p) {
+ // CHECK: [[EXN:%.*]] = load i8**
+ // CHECK-NEXT: call i8* @__cxa_begin_catch(i8* [[EXN]]) nounwind
+ // CHECK-NEXT: [[ADJ1:%.*]] = getelementptr i8* [[EXN]], i32 32
+ // CHECK-NEXT: [[ADJ2:%.*]] = bitcast i8* [[ADJ1]] to i32***
+ // CHECK-NEXT: store i32*** [[ADJ2]], i32**** [[P:%.*]]
+ // CHECK-NEXT: call void @__cxa_end_catch() nounwind
+ }
+ }
+
+ struct A {};
+
+ // CHECK: define void @_ZN6test113barEv()
+ void bar() {
+ try {
+ // CHECK: [[EXNSLOT:%.*]] = alloca i8*
+ // CHECK-NEXT: [[SELECTORSLOT:%.*]] = alloca i32
+ // CHECK-NEXT: [[P:%.*]] = alloca [[A:%.*]]**,
+ // CHECK-NEXT: [[TMP:%.*]] = alloca [[A]]*
+ // CHECK-NEXT: invoke void @_ZN6test116opaqueEv()
+ opaque();
+ } catch (A*&p) {
+ // CHECK: [[EXN:%.*]] = load i8** [[EXNSLOT]]
+ // CHECK-NEXT: [[ADJ1:%.*]] = call i8* @__cxa_begin_catch(i8* [[EXN]]) nounwind
+ // CHECK-NEXT: [[ADJ2:%.*]] = bitcast i8* [[ADJ1]] to [[A]]*
+ // CHECK-NEXT: store [[A]]* [[ADJ2]], [[A]]** [[TMP]]
+ // CHECK-NEXT: store [[A]]** [[TMP]], [[A]]*** [[P]]
+ // CHECK-NEXT: call void @__cxa_end_catch() nounwind
+ }
+ }
+}
+
+// PR7686
+namespace test12 {
+ struct A { ~A() noexcept(false); };
+ bool opaque(const A&);
+
+ // CHECK: define void @_ZN6test124testEv()
+ void test() {
+ // CHECK: [[X:%.*]] = alloca [[A:%.*]],
+ // CHECK: [[EHCLEANUPDEST:%.*]] = alloca i32
+ // CHECK: [[Y:%.*]] = alloca [[A]]
+ // CHECK: [[Z:%.*]] = alloca [[A]]
+ // CHECK: [[CLEANUPDEST:%.*]] = alloca i32
+
+ A x;
+ // CHECK: invoke zeroext i1 @_ZN6test126opaqueERKNS_1AE(
+ if (opaque(x)) {
+ A y;
+ A z;
+
+ // CHECK: invoke void @_ZN6test121AD1Ev([[A]]* [[Z]])
+ // CHECK: invoke void @_ZN6test121AD1Ev([[A]]* [[Y]])
+ // CHECK-NOT: switch
+ goto success;
+ }
+
+ success:
+ bool _ = true;
+
+ // CHECK: call void @_ZN6test121AD1Ev([[A]]* [[X]])
+ // CHECK-NEXT: ret void
+ }
+}
+
+// Reduced from some TableGen code that was causing a self-host crash.
+namespace test13 {
+ struct A { ~A(); };
+
+ void test0(int x) {
+ try {
+ switch (x) {
+ case 0:
+ break;
+ case 1:{
+ A a;
+ break;
+ }
+ default:
+ return;
+ }
+ return;
+ } catch (int x) {
+ }
+ return;
+ }
+
+ void test1(int x) {
+ A y;
+ try {
+ switch (x) {
+ default: break;
+ }
+ } catch (int x) {}
+ }
+}
+
+// rdar://problem/8231514
+namespace test14 {
+ struct A { ~A(); };
+ struct B { ~B(); };
+
+ B b();
+ void opaque();
+
+ void foo() {
+ A a;
+ try {
+ B str = b();
+ opaque();
+ } catch (int x) {
+ }
+ }
+}
+
+// rdar://problem/8231514
+// JumpDests shouldn't get confused by scopes that aren't normal cleanups.
+namespace test15 {
+ struct A { ~A(); };
+
+ bool opaque(int);
+
+ // CHECK: define void @_ZN6test153fooEv()
+ void foo() {
+ A a;
+
+ try {
+ // CHECK: [[X:%.*]] = alloca i32
+ // CHECK: store i32 10, i32* [[X]]
+ // CHECK-NEXT: br label
+ // -> while.cond
+ int x = 10;
+
+ while (true) {
+ // CHECK: load i32* [[X]]
+ // CHECK-NEXT: [[COND:%.*]] = invoke zeroext i1 @_ZN6test156opaqueEi
+ // CHECK: br i1 [[COND]]
+ if (opaque(x))
+ // CHECK: br label
+ break;
+
+ // CHECK: br label
+ }
+ // CHECK: br label
+ } catch (int x) { }
+
+ // CHECK: call void @_ZN6test151AD1Ev
+ }
+}
+
+namespace test16 {
+ struct A { A(); ~A() noexcept(false); };
+ struct B { int x; B(const A &); ~B() noexcept(false); };
+ void foo();
+ bool cond();
+
+ // CHECK: define void @_ZN6test163barEv()
+ void bar() {
+ // CHECK: [[EXN_SAVE:%.*]] = alloca i8*
+ // CHECK-NEXT: [[EXN_ACTIVE:%.*]] = alloca i1
+ // CHECK-NEXT: [[TEMP:%.*]] = alloca [[A:%.*]],
+ // CHECK-NEXT: [[EXNSLOT:%.*]] = alloca i8*
+ // CHECK-NEXT: [[SELECTORSLOT:%.*]] = alloca i32
+ // CHECK-NEXT: [[TEMP_ACTIVE:%.*]] = alloca i1
+
+ cond() ? throw B(A()) : foo();
+
+ // CHECK-NEXT: [[COND:%.*]] = call zeroext i1 @_ZN6test164condEv()
+ // CHECK-NEXT: store i1 false, i1* [[EXN_ACTIVE]]
+ // CHECK-NEXT: store i1 false, i1* [[TEMP_ACTIVE]]
+ // CHECK-NEXT: br i1 [[COND]],
+
+ // CHECK: [[EXN:%.*]] = call i8* @__cxa_allocate_exception(i64 4)
+ // CHECK-NEXT: store i8* [[EXN]], i8** [[EXN_SAVE]]
+ // CHECK-NEXT: store i1 true, i1* [[EXN_ACTIVE]]
+ // CHECK-NEXT: [[T0:%.*]] = bitcast i8* [[EXN]] to [[B:%.*]]*
+ // CHECK-NEXT: invoke void @_ZN6test161AC1Ev([[A]]* [[TEMP]])
+ // CHECK: store i1 true, i1* [[TEMP_ACTIVE]]
+ // CHECK-NEXT: invoke void @_ZN6test161BC1ERKNS_1AE([[B]]* [[T0]], [[A]]* [[TEMP]])
+ // CHECK: store i1 false, i1* [[EXN_ACTIVE]]
+ // CHECK-NEXT: invoke void @__cxa_throw(i8* [[EXN]],
+
+ // CHECK: invoke void @_ZN6test163fooEv()
+ // CHECK: br label
+
+ // CHECK: invoke void @_ZN6test161AD1Ev([[A]]* [[TEMP]])
+ // CHECK: ret void
+
+ // CHECK: [[T0:%.*]] = load i1* [[EXN_ACTIVE]]
+ // CHECK-NEXT: br i1 [[T0]]
+ // CHECK: [[T1:%.*]] = load i8** [[EXN_SAVE]]
+ // CHECK-NEXT: call void @__cxa_free_exception(i8* [[T1]])
+ // CHECK-NEXT: br label
+ }
+}
diff --git a/clang/test/CodeGenCXX/elide-call-reference.cpp b/clang/test/CodeGenCXX/elide-call-reference.cpp
new file mode 100644
index 0000000..55d30e2
--- /dev/null
+++ b/clang/test/CodeGenCXX/elide-call-reference.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// PR5695
+
+struct A { A(const A&); ~A(); };
+A& a();
+void b() {
+ A x = a();
+}
+
+// CHECK: call {{.*}} @_ZN1AC1ERKS_
+// CHECK: call {{.*}} @_ZN1AD1Ev
diff --git a/clang/test/CodeGenCXX/empty-classes.cpp b/clang/test/CodeGenCXX/empty-classes.cpp
new file mode 100644
index 0000000..1ce1dad
--- /dev/null
+++ b/clang/test/CodeGenCXX/empty-classes.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o - | FileCheck %s
+
+struct Empty { };
+
+struct A {
+ explicit A(unsigned a = 0xffffffff) : a(a) { }
+
+ unsigned a;
+};
+
+struct B : A, Empty {
+ B() : A(), Empty() { }
+};
+
+struct C : A, Empty {
+ C() : A(), Empty() { }
+ C(const C& other) : A(0x12345678), Empty(other) { }
+};
+
+struct D : A, Empty {
+ D& operator=(const D& other) {
+ a = 0x87654321;
+ Empty::operator=(other);
+
+ return *this;
+ }
+};
+
+#define CHECK(x) if (!(x)) return __LINE__
+
+// PR7012
+// CHECK: define i32 @_Z1fv()
+int f() {
+ B b1;
+
+ // Check that A::a is not overwritten by the Empty default constructor.
+ CHECK(b1.a == 0xffffffff);
+
+ C c1;
+ C c2(c1);
+
+ // Check that A::a has the value set in the C::C copy constructor.
+ CHECK(c2.a == 0x12345678);
+
+ D d1, d2;
+ d2 = d1;
+
+ // Check that A::as has the value set in the D copy assignment operator.
+ CHECK(d2.a == 0x87654321);
+
+ // Success!
+ // CHECK: ret i32 0
+ return 0;
+}
+
+namespace PR8796 {
+ struct FreeCell {
+ };
+ union ThingOrCell {
+ FreeCell t;
+ FreeCell cell;
+ };
+ struct Things {
+ ThingOrCell things;
+ };
+ Things x;
+}
+
+#ifdef HARNESS
+extern "C" void printf(const char *, ...);
+
+int main() {
+ int result = f();
+
+ if (result == 0)
+ printf("success!\n");
+ else
+ printf("test on line %d failed!\n", result);
+
+ return result;
+}
+#endif
diff --git a/clang/test/CodeGenCXX/empty-union.cpp b/clang/test/CodeGenCXX/empty-union.cpp
new file mode 100644
index 0000000..7f3e6cc
--- /dev/null
+++ b/clang/test/CodeGenCXX/empty-union.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+
+union sigval { };
+union sigval Test1;
+
+union NonPODUnion { ~NonPODUnion(); };
+union NonPODUnion Test2;
diff --git a/clang/test/CodeGenCXX/enum.cpp b/clang/test/CodeGenCXX/enum.cpp
new file mode 100644
index 0000000..cfcd264
--- /dev/null
+++ b/clang/test/CodeGenCXX/enum.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm-only -verify %s
+
+enum A { a } __attribute((packed));
+int func(A x) { return x==a; }
diff --git a/clang/test/CodeGenCXX/eval-recursive-constant.cpp b/clang/test/CodeGenCXX/eval-recursive-constant.cpp
new file mode 100644
index 0000000..608c95d
--- /dev/null
+++ b/clang/test/CodeGenCXX/eval-recursive-constant.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -emit-llvm-only
+
+extern const int a,b;
+const int a=b,b=a;
+int c() { if (a) return 1; return 0; }
diff --git a/clang/test/CodeGenCXX/exceptions-no-rtti.cpp b/clang/test/CodeGenCXX/exceptions-no-rtti.cpp
new file mode 100644
index 0000000..902d6ac
--- /dev/null
+++ b/clang/test/CodeGenCXX/exceptions-no-rtti.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fno-rtti -fcxx-exceptions -fexceptions %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// CHECK: @_ZTIN5test11AE = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTIN5test11BE = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTIN5test11CE = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTIN5test11DE = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTIPN5test11DE = linkonce_odr unnamed_addr constant {{.*}} @_ZTIN5test11DE
+
+// PR6974: this shouldn't crash
+namespace test0 {
+ class err {};
+
+ void f(void) {
+ try {
+ } catch (err &) {
+ }
+ }
+}
+
+namespace test1 {
+ // These classes have key functions defined out-of-line. Under
+ // normal circumstances, we wouldn't generate RTTI for them; under
+ // -fno-rtti, we generate RTTI only when required by EH. But
+ // everything gets hidden visibility because we assume that all
+ // users are also compiled under -fno-rtti and therefore will be
+ // emitting RTTI regardless of key function.
+ class A { virtual void foo(); };
+ class B { virtual void foo(); };
+ class C { virtual void foo(); };
+ class D { virtual void foo(); };
+
+ void opaque();
+
+ void test0() {
+ throw A();
+ }
+
+ void test1() throw(B) {
+ opaque();
+ }
+
+ void test2() {
+ try {
+ opaque();
+ } catch (C&) {}
+ }
+
+ void test3(D *ptr) {
+ throw ptr;
+ };
+}
diff --git a/clang/test/CodeGenCXX/exceptions.cpp b/clang/test/CodeGenCXX/exceptions.cpp
new file mode 100644
index 0000000..079c1e5
--- /dev/null
+++ b/clang/test/CodeGenCXX/exceptions.cpp
@@ -0,0 +1,416 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s
+
+typedef typeof(sizeof(0)) size_t;
+
+// This just shouldn't crash.
+namespace test0 {
+ struct allocator {
+ allocator();
+ allocator(const allocator&);
+ ~allocator();
+ };
+
+ void f();
+ void g(bool b, bool c) {
+ if (b) {
+ if (!c)
+ throw allocator();
+
+ return;
+ }
+ f();
+ }
+}
+
+namespace test1 {
+ struct A { A(int); A(int, int); ~A(); void *p; };
+
+ A *a() {
+ // CHECK: define [[A:%.*]]* @_ZN5test11aEv()
+ // CHECK: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
+ // CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
+ // CHECK-NEXT: invoke void @_ZN5test11AC1Ei([[A]]* [[CAST]], i32 5)
+ // CHECK: ret [[A]]* [[CAST]]
+ // CHECK: call void @_ZdlPv(i8* [[NEW]])
+ return new A(5);
+ }
+
+ A *b() {
+ // CHECK: define [[A:%.*]]* @_ZN5test11bEv()
+ // CHECK: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
+ // CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
+ // CHECK-NEXT: [[FOO:%.*]] = invoke i32 @_ZN5test13fooEv()
+ // CHECK: invoke void @_ZN5test11AC1Ei([[A]]* [[CAST]], i32 [[FOO]])
+ // CHECK: ret [[A]]* [[CAST]]
+ // CHECK: call void @_ZdlPv(i8* [[NEW]])
+ extern int foo();
+ return new A(foo());
+ }
+
+ struct B { B(); ~B(); operator int(); int x; };
+ B makeB();
+
+ A *c() {
+ // CHECK: define [[A:%.*]]* @_ZN5test11cEv()
+ // CHECK: [[ACTIVE:%.*]] = alloca i1
+ // CHECK-NEXT: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
+ // CHECK-NEXT: store i1 true, i1* [[ACTIVE]]
+ // CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
+ // CHECK-NEXT: invoke void @_ZN5test11BC1Ev([[B:%.*]]* [[T0:%.*]])
+ // CHECK: [[T1:%.*]] = getelementptr inbounds [[B]]* [[T0]], i32 0, i32 0
+ // CHECK-NEXT: [[T2:%.*]] = load i32* [[T1]], align 4
+ // CHECK-NEXT: invoke void @_ZN5test11AC1Ei([[A]]* [[CAST]], i32 [[T2]])
+ // CHECK: store i1 false, i1* [[ACTIVE]]
+ // CHECK-NEXT: invoke void @_ZN5test11BD1Ev([[B]]* [[T0]])
+ // CHECK: ret [[A]]* [[CAST]]
+ // CHECK: [[ISACTIVE:%.*]] = load i1* [[ACTIVE]]
+ // CHECK-NEXT: br i1 [[ISACTIVE]]
+ // CHECK: call void @_ZdlPv(i8* [[NEW]])
+ return new A(B().x);
+ }
+
+ A *d() {
+ // CHECK: define [[A:%.*]]* @_ZN5test11dEv()
+ // CHECK: [[ACTIVE:%.*]] = alloca i1
+ // CHECK-NEXT: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
+ // CHECK-NEXT: store i1 true, i1* [[ACTIVE]]
+ // CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
+ // CHECK-NEXT: invoke void @_ZN5test11BC1Ev([[B:%.*]]* [[T0:%.*]])
+ // CHECK: [[T1:%.*]] = invoke i32 @_ZN5test11BcviEv([[B]]* [[T0]])
+ // CHECK: invoke void @_ZN5test11AC1Ei([[A]]* [[CAST]], i32 [[T1]])
+ // CHECK: store i1 false, i1* [[ACTIVE]]
+ // CHECK-NEXT: invoke void @_ZN5test11BD1Ev([[B]]* [[T0]])
+ // CHECK: ret [[A]]* [[CAST]]
+ // CHECK: [[ISACTIVE:%.*]] = load i1* [[ACTIVE]]
+ // CHECK-NEXT: br i1 [[ISACTIVE]]
+ // CHECK: call void @_ZdlPv(i8* [[NEW]])
+ return new A(B());
+ }
+
+ A *e() {
+ // CHECK: define [[A:%.*]]* @_ZN5test11eEv()
+ // CHECK: [[ACTIVE:%.*]] = alloca i1
+ // CHECK-NEXT: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
+ // CHECK-NEXT: store i1 true, i1* [[ACTIVE]]
+ // CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
+ // CHECK-NEXT: invoke void @_ZN5test11BC1Ev([[B:%.*]]* [[T0:%.*]])
+ // CHECK: [[T1:%.*]] = invoke i32 @_ZN5test11BcviEv([[B]]* [[T0]])
+ // CHECK: invoke void @_ZN5test11BC1Ev([[B]]* [[T2:%.*]])
+ // CHECK: [[T3:%.*]] = invoke i32 @_ZN5test11BcviEv([[B]]* [[T2]])
+ // CHECK: invoke void @_ZN5test11AC1Eii([[A]]* [[CAST]], i32 [[T1]], i32 [[T3]])
+ // CHECK: store i1 false, i1* [[ACTIVE]]
+ // CHECK-NEXT: invoke void @_ZN5test11BD1Ev([[B]]* [[T2]])
+ // CHECK: invoke void @_ZN5test11BD1Ev([[B]]* [[T0]])
+ // CHECK: ret [[A]]* [[CAST]]
+ // CHECK: [[ISACTIVE:%.*]] = load i1* [[ACTIVE]]
+ // CHECK-NEXT: br i1 [[ISACTIVE]]
+ // CHECK: call void @_ZdlPv(i8* [[NEW]])
+ return new A(B(), B());
+ }
+ A *f() {
+ return new A(makeB().x);
+ }
+ A *g() {
+ return new A(makeB());
+ }
+ A *h() {
+ return new A(makeB(), makeB());
+ }
+
+ A *i() {
+ // CHECK: define [[A:%.*]]* @_ZN5test11iEv()
+ // CHECK: [[X:%.*]] = alloca [[A]]*, align 8
+ // CHECK: [[ACTIVE:%.*]] = alloca i1
+ // CHECK: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
+ // CHECK-NEXT: store i1 true, i1* [[ACTIVE]]
+ // CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
+ // CHECK-NEXT: invoke void @_ZN5test15makeBEv([[B:%.*]]* sret [[T0:%.*]])
+ // CHECK: [[T1:%.*]] = invoke i32 @_ZN5test11BcviEv([[B]]* [[T0]])
+ // CHECK: invoke void @_ZN5test11AC1Ei([[A]]* [[CAST]], i32 [[T1]])
+ // CHECK: store i1 false, i1* [[ACTIVE]]
+ // CHECK-NEXT: store [[A]]* [[CAST]], [[A]]** [[X]], align 8
+ // CHECK: invoke void @_ZN5test15makeBEv([[B:%.*]]* sret [[T2:%.*]])
+ // CHECK: [[RET:%.*]] = load [[A]]** [[X]], align 8
+ // CHECK: invoke void @_ZN5test11BD1Ev([[B]]* [[T2]])
+ // CHECK: invoke void @_ZN5test11BD1Ev([[B]]* [[T0]])
+ // CHECK: ret [[A]]* [[RET]]
+ // CHECK: [[ISACTIVE:%.*]] = load i1* [[ACTIVE]]
+ // CHECK-NEXT: br i1 [[ISACTIVE]]
+ // CHECK: call void @_ZdlPv(i8* [[NEW]])
+ A *x;
+ return (x = new A(makeB()), makeB(), x);
+ }
+}
+
+namespace test2 {
+ struct A {
+ A(int); A(int, int); ~A();
+ void *p;
+ void *operator new(size_t);
+ void operator delete(void*, size_t);
+ };
+
+ A *a() {
+ // CHECK: define [[A:%.*]]* @_ZN5test21aEv()
+ // CHECK: [[NEW:%.*]] = call i8* @_ZN5test21AnwEm(i64 8)
+ // CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
+ // CHECK-NEXT: invoke void @_ZN5test21AC1Ei([[A]]* [[CAST]], i32 5)
+ // CHECK: ret [[A]]* [[CAST]]
+ // CHECK: invoke void @_ZN5test21AdlEPvm(i8* [[NEW]], i64 8)
+ // CHECK: call void @_ZSt9terminatev()
+ return new A(5);
+ }
+}
+
+namespace test3 {
+ struct A {
+ A(int); A(int, int); A(const A&); ~A();
+ void *p;
+ void *operator new(size_t, void*, double);
+ void operator delete(void*, void*, double);
+ };
+
+ void *foo();
+ double bar();
+ A makeA(), *makeAPtr();
+
+ A *a() {
+ // CHECK: define [[A:%.*]]* @_ZN5test31aEv()
+ // CHECK: [[FOO:%.*]] = call i8* @_ZN5test33fooEv()
+ // CHECK: [[BAR:%.*]] = call double @_ZN5test33barEv()
+ // CHECK: [[NEW:%.*]] = call i8* @_ZN5test31AnwEmPvd(i64 8, i8* [[FOO]], double [[BAR]])
+ // CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
+ // CHECK-NEXT: invoke void @_ZN5test31AC1Ei([[A]]* [[CAST]], i32 5)
+ // CHECK: ret [[A]]* [[CAST]]
+ // CHECK: invoke void @_ZN5test31AdlEPvS1_d(i8* [[NEW]], i8* [[FOO]], double [[BAR]])
+ // CHECK: call void @_ZSt9terminatev()
+ return new(foo(),bar()) A(5);
+ }
+
+ // rdar://problem/8439196
+ A *b(bool cond) {
+
+ // CHECK: define [[A:%.*]]* @_ZN5test31bEb(i1 zeroext
+ // CHECK: [[SAVED0:%.*]] = alloca i8*
+ // CHECK-NEXT: [[SAVED1:%.*]] = alloca i8*
+ // CHECK-NEXT: [[CLEANUPACTIVE:%.*]] = alloca i1
+
+ // CHECK: [[COND:%.*]] = trunc i8 {{.*}} to i1
+ // CHECK-NEXT: store i1 false, i1* [[CLEANUPACTIVE]]
+ // CHECK-NEXT: br i1 [[COND]]
+ return (cond ?
+
+ // CHECK: [[FOO:%.*]] = call i8* @_ZN5test33fooEv()
+ // CHECK-NEXT: [[NEW:%.*]] = call i8* @_ZN5test31AnwEmPvd(i64 8, i8* [[FOO]], double [[CONST:.*]])
+ // CHECK-NEXT: store i8* [[NEW]], i8** [[SAVED0]]
+ // CHECK-NEXT: store i8* [[FOO]], i8** [[SAVED1]]
+ // CHECK-NEXT: store i1 true, i1* [[CLEANUPACTIVE]]
+ // CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
+ // CHECK-NEXT: invoke void @_ZN5test35makeAEv([[A]]* sret [[CAST]])
+ // CHECK: br label
+ // -> cond.end
+ new(foo(),10.0) A(makeA()) :
+
+ // CHECK: [[MAKE:%.*]] = call [[A]]* @_ZN5test38makeAPtrEv()
+ // CHECK: br label
+ // -> cond.end
+ makeAPtr());
+
+ // cond.end:
+ // CHECK: [[RESULT:%.*]] = phi [[A]]* {{.*}}[[CAST]]{{.*}}[[MAKE]]
+ // CHECK: ret [[A]]* [[RESULT]]
+
+ // in the EH path:
+ // CHECK: [[ISACTIVE:%.*]] = load i1* [[CLEANUPACTIVE]]
+ // CHECK-NEXT: br i1 [[ISACTIVE]]
+ // CHECK: [[V0:%.*]] = load i8** [[SAVED0]]
+ // CHECK-NEXT: [[V1:%.*]] = load i8** [[SAVED1]]
+ // CHECK-NEXT: invoke void @_ZN5test31AdlEPvS1_d(i8* [[V0]], i8* [[V1]], double [[CONST]])
+ }
+}
+
+namespace test4 {
+ struct A {
+ A(int); A(int, int); ~A();
+ void *p;
+ void *operator new(size_t, void*, void*);
+ void operator delete(void*, size_t, void*, void*); // not a match
+ };
+
+ A *a() {
+ // CHECK: define [[A:%.*]]* @_ZN5test41aEv()
+ // CHECK: [[FOO:%.*]] = call i8* @_ZN5test43fooEv()
+ // CHECK-NEXT: [[BAR:%.*]] = call i8* @_ZN5test43barEv()
+ // CHECK-NEXT: [[NEW:%.*]] = call i8* @_ZN5test41AnwEmPvS1_(i64 8, i8* [[FOO]], i8* [[BAR]])
+ // CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
+ // CHECK-NEXT: call void @_ZN5test41AC1Ei([[A]]* [[CAST]], i32 5)
+ // CHECK-NEXT: ret [[A]]* [[CAST]]
+ extern void *foo(), *bar();
+
+ return new(foo(),bar()) A(5);
+ }
+}
+
+// PR7908
+namespace test5 {
+ struct T { T(); ~T(); };
+
+ struct A {
+ A(const A &x, const T &t = T());
+ ~A();
+ };
+
+ void foo();
+
+ // CHECK: define void @_ZN5test54testEv()
+ // CHECK: [[EXNSLOT:%.*]] = alloca i8*
+ // CHECK-NEXT: [[SELECTORSLOT:%.*]] = alloca i32
+ // CHECK-NEXT: [[A:%.*]] = alloca [[A_T:%.*]], align 1
+ // CHECK-NEXT: [[T:%.*]] = alloca [[T_T:%.*]], align 1
+ // CHECK-NEXT: invoke void @_ZN5test53fooEv()
+ // CHECK: [[EXN:%.*]] = load i8** [[EXNSLOT]]
+ // CHECK-NEXT: [[ADJ:%.*]] = call i8* @__cxa_get_exception_ptr(i8* [[EXN]])
+ // CHECK-NEXT: [[SRC:%.*]] = bitcast i8* [[ADJ]] to [[A_T]]*
+ // CHECK-NEXT: invoke void @_ZN5test51TC1Ev([[T_T]]* [[T]])
+ // CHECK: invoke void @_ZN5test51AC1ERKS0_RKNS_1TE([[A_T]]* [[A]], [[A_T]]* [[SRC]], [[T_T]]* [[T]])
+ // CHECK: invoke void @_ZN5test51TD1Ev([[T_T]]* [[T]])
+ // CHECK: call i8* @__cxa_begin_catch(i8* [[EXN]]) nounwind
+ // CHECK-NEXT: invoke void @_ZN5test51AD1Ev([[A_T]]* [[A]])
+ // CHECK: call void @__cxa_end_catch()
+ void test() {
+ try {
+ foo();
+ } catch (A a) {
+ }
+ }
+}
+
+// PR9303: invalid assert on this
+namespace test6 {
+ bool cond();
+ void test() {
+ try {
+ lbl:
+ if (cond()) goto lbl;
+ } catch (...) {
+ }
+ }
+}
+
+// PR9298
+namespace test7 {
+ struct A { A(); ~A(); };
+ struct B {
+ // The throw() operator means that a bad allocation is signalled
+ // with a null return, which means that the initializer is
+ // evaluated conditionally.
+ static void *operator new(size_t size) throw();
+ B(const A&, B*);
+ ~B();
+ };
+
+ B *test() {
+ // CHECK: define [[B:%.*]]* @_ZN5test74testEv()
+ // CHECK: [[OUTER_NEW:%.*]] = alloca i1
+ // CHECK-NEXT: alloca [[A:%.*]],
+ // CHECK-NEXT: alloca i8*
+ // CHECK-NEXT: alloca i32
+ // CHECK-NEXT: [[OUTER_A:%.*]] = alloca i1
+ // CHECK-NEXT: alloca i8*
+ // CHECK-NEXT: [[INNER_NEW:%.*]] = alloca i1
+ // CHECK-NEXT: alloca [[A]]
+ // CHECK-NEXT: [[INNER_A:%.*]] = alloca i1
+
+ // Allocate the outer object.
+ // CHECK-NEXT: [[NEW:%.*]] = call i8* @_ZN5test71BnwEm(
+ // CHECK-NEXT: icmp eq i8* [[NEW]], null
+
+ // These stores, emitted before the outermost conditional branch,
+ // deactivate the temporary cleanups.
+ // CHECK-NEXT: store i1 false, i1* [[OUTER_NEW]]
+ // CHECK-NEXT: store i1 false, i1* [[OUTER_A]]
+ // CHECK-NEXT: store i1 false, i1* [[INNER_NEW]]
+ // CHECK-NEXT: store i1 false, i1* [[INNER_A]]
+ // CHECK-NEXT: br i1
+
+ // We passed the first null check; activate that cleanup and continue.
+ // CHECK: store i1 true, i1* [[OUTER_NEW]]
+ // CHECK-NEXT: bitcast
+
+ // Create the first A temporary and activate that cleanup.
+ // CHECK-NEXT: invoke void @_ZN5test71AC1Ev(
+ // CHECK: store i1 true, i1* [[OUTER_A]]
+
+ // Allocate the inner object.
+ // CHECK-NEXT: [[NEW:%.*]] = call i8* @_ZN5test71BnwEm(
+ // CHECK-NEXT: icmp eq i8* [[NEW]], null
+ // CHECK-NEXT: br i1
+
+ // We passed the second null check; save that pointer, activate
+ // that cleanup, and continue.
+ // CHECK: store i8* [[NEW]]
+ // CHECK-NEXT: store i1 true, i1* [[INNER_NEW]]
+ // CHECK-NEXT: bitcast
+
+ // Build the second A temporary and activate that cleanup.
+ // CHECK-NEXT: invoke void @_ZN5test71AC1Ev(
+ // CHECK: store i1 true, i1* [[INNER_A]]
+
+ // Build the inner B object and deactivate the inner delete cleanup.
+ // CHECK-NEXT: invoke void @_ZN5test71BC1ERKNS_1AEPS0_(
+ // CHECK: store i1 false, i1* [[INNER_NEW]]
+ // CHECK: phi
+
+ // Build the outer B object and deactivate the outer delete cleanup.
+ // CHECK-NEXT: invoke void @_ZN5test71BC1ERKNS_1AEPS0_(
+ // CHECK: store i1 false, i1* [[OUTER_NEW]]
+ // CHECK: phi
+
+ // Destroy the inner A object.
+ // CHECK-NEXT: load i1* [[INNER_A]]
+ // CHECK-NEXT: br i1
+ // CHECK: invoke void @_ZN5test71AD1Ev(
+
+ // Destroy the outer A object.
+ // CHECK: load i1* [[OUTER_A]]
+ // CHECK-NEXT: br i1
+ // CHECK: invoke void @_ZN5test71AD1Ev(
+
+ return new B(A(), new B(A(), 0));
+ }
+}
+
+// Just don't crash.
+namespace test8 {
+ struct A {
+ // Having both of these is required to trigger the assert we're
+ // trying to avoid.
+ A(const A&);
+ A&operator=(const A&);
+
+ ~A();
+ };
+
+ A makeA();
+ void test() {
+ throw makeA();
+ }
+ // CHECK: define void @_ZN5test84testEv
+}
+
+// Make sure we generate the correct code for the delete[] call which
+// happens if A::A() throws. (We were previously calling delete[] on
+// a pointer to the first array element, not the pointer returned by new[].)
+// PR10870
+namespace test9 {
+ struct A {
+ A();
+ ~A();
+ };
+ A* test() {
+ return new A[10];
+ }
+ // CHECK: define {{%.*}}* @_ZN5test94testEv
+ // CHECK: [[TEST9_NEW:%.*]] = call noalias i8* @_Znam
+ // CHECK: call void @_ZdaPv(i8* [[TEST9_NEW]])
+}
diff --git a/clang/test/CodeGenCXX/explicit-instantiation.cpp b/clang/test/CodeGenCXX/explicit-instantiation.cpp
new file mode 100644
index 0000000..8daf3c6
--- /dev/null
+++ b/clang/test/CodeGenCXX/explicit-instantiation.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -emit-llvm -triple i686-pc-linux-gnu -o - %s | FileCheck %s
+
+// This check logically is attached to 'template int S<int>::i;' below.
+// CHECK: @_ZN1SIiE1iE = weak_odr global i32
+
+template<typename T, typename U, typename Result>
+struct plus {
+ Result operator()(const T& t, const U& u) const;
+};
+
+template<typename T, typename U, typename Result>
+Result plus<T, U, Result>::operator()(const T& t, const U& u) const {
+ return t + u;
+}
+
+// CHECK: define weak_odr i32 @_ZNK4plusIillEclERKiRKl
+template struct plus<int, long, long>;
+
+// Check that we emit definitions from explicit instantiations even when they
+// occur prior to the definition itself.
+template <typename T> struct S {
+ void f();
+ static void g();
+ static int i;
+ struct S2 {
+ void h();
+ };
+};
+
+// CHECK: define weak_odr void @_ZN1SIiE1fEv
+template void S<int>::f();
+
+// CHECK: define weak_odr void @_ZN1SIiE1gEv
+template void S<int>::g();
+
+// See the check line at the top of the file.
+template int S<int>::i;
+
+// CHECK: define weak_odr void @_ZN1SIiE2S21hEv
+template void S<int>::S2::h();
+
+template <typename T> void S<T>::f() {}
+template <typename T> void S<T>::g() {}
+template <typename T> int S<T>::i;
+template <typename T> void S<T>::S2::h() {}
diff --git a/clang/test/CodeGenCXX/expr.cpp b/clang/test/CodeGenCXX/expr.cpp
new file mode 100644
index 0000000..33e8e63
--- /dev/null
+++ b/clang/test/CodeGenCXX/expr.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -emit-llvm -x c++ < %s
+
+void test0(int x) {
+ if (x != 0) return;
+}
+
+
+// PR5211
+void test1() {
+ char *xpto;
+ while ( true && xpto[0] );
+}
+
+// PR5514
+int a;
+void test2() { ++a+=10; }
+
+// PR7892
+int test3(const char*);
+int test3g = test3(__PRETTY_FUNCTION__);
+
+
+// PR7889
+struct test4A {
+ int j : 2;
+};
+int test4() {
+ test4A a;
+ (a.j = 2) = 3;
+}
+
+// Incomplete type in conditional operator.
+// Check operations on incomplete types.
+struct s5;
+struct s5 &f5_0(bool cond, struct s5 &a, struct s5 &b) {
+ return cond ? a : b;
+}
diff --git a/clang/test/CodeGenCXX/extern-c.cpp b/clang/test/CodeGenCXX/extern-c.cpp
new file mode 100644
index 0000000..ca5cd73
--- /dev/null
+++ b/clang/test/CodeGenCXX/extern-c.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+namespace foo {
+
+// RUN: not grep "@a = global i32" %t
+extern "C" int a;
+
+// RUN: not grep "@_ZN3foo1bE = global i32" %t
+extern int b;
+
+// RUN: grep "@_ZN3foo1cE = global i32" %t | count 1
+int c = 5;
+
+// RUN: not grep "@_ZN3foo1dE" %t
+extern "C" struct d;
+
+}
diff --git a/clang/test/CodeGenCXX/field-access-debug-info.cpp b/clang/test/CodeGenCXX/field-access-debug-info.cpp
new file mode 100644
index 0000000..fd899ed
--- /dev/null
+++ b/clang/test/CodeGenCXX/field-access-debug-info.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -g -S -masm-verbose -o - %s | FileCheck %s
+
+// CHECK: abbrev_begin:
+// CHECK: DW_AT_accessibility
+// CHECK-NEXT: DW_FORM_data1
+
+class A {
+public:
+ int p;
+private:
+ int pr;
+};
+
+A a;
diff --git a/clang/test/CodeGenCXX/for-range-temporaries.cpp b/clang/test/CodeGenCXX/for-range-temporaries.cpp
new file mode 100644
index 0000000..a03bb0a
--- /dev/null
+++ b/clang/test/CodeGenCXX/for-range-temporaries.cpp
@@ -0,0 +1,146 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -UDESUGAR %s | opt -instnamer -S | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -DDESUGAR %s | opt -instnamer -S | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -UDESUGAR -DTEMPLATE %s | opt -instnamer -S | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -DDESUGAR -DTEMPLATE %s | opt -instnamer -S | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -UDESUGAR -DTEMPLATE -DDEPENDENT %s | opt -instnamer -S | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -DDESUGAR -DTEMPLATE -DDEPENDENT %s | opt -instnamer -S | FileCheck %s
+
+struct A {
+ A();
+ A(const A &);
+ ~A();
+};
+
+struct B {
+ B();
+ B(const B &);
+ ~B();
+};
+
+struct C {
+ C(const B &);
+ C(const C &);
+ ~C();
+};
+
+struct E;
+struct D {
+ D(const C &);
+ D(const D &);
+ ~D();
+};
+E begin(D);
+E end(D);
+
+struct F;
+struct G;
+struct H;
+struct E {
+ E(const E &);
+ ~E();
+ F operator*();
+ G operator++();
+ H operator!=(const E &o);
+};
+
+struct I;
+struct F {
+ F(const F &);
+ ~F();
+ operator I();
+};
+
+struct G {
+ G(const G &);
+ ~G();
+ operator bool();
+};
+
+struct H {
+ H(const H &);
+ ~H();
+ operator bool();
+};
+
+struct I {
+ I(const I &);
+ ~I();
+};
+
+void body(const I &);
+
+#ifdef TEMPLATE
+#ifdef DEPENDENT
+template<typename D>
+#else
+template<typename>
+#endif
+#endif
+void for_temps() {
+ A a;
+#ifdef DESUGAR
+ {
+ auto && __range = D(B());
+ for (auto __begin = begin(__range), __end = end(__range);
+ __begin != __end; ++__begin) {
+ I i = *__begin;
+ body(i);
+ }
+ }
+#else
+ for (I i : D(B())) {
+ body(i);
+ }
+#endif
+}
+
+#ifdef TEMPLATE
+template void for_temps<D>();
+#endif
+
+// CHECK: define {{.*}}for_temps
+// CHECK: call void @_ZN1AC1Ev(
+// CHECK: call void @_ZN1BC1Ev(
+// CHECK: call void @_ZN1CC1ERK1B(
+// CHECK: call void @_ZN1DC1ERK1C(
+// CHECK: call void @_ZN1CD1Ev(
+// CHECK: call void @_ZN1BD1Ev(
+// CHECK: call void @_ZN1DC1ERKS_(
+// CHECK: call void @_Z5begin1D(
+// CHECK: call void @_ZN1DD1Ev(
+// CHECK: call void @_ZN1DC1ERKS_(
+// CHECK: call void @_Z3end1D(
+// CHECK: call void @_ZN1DD1Ev(
+// CHECK: br label %[[COND:.*]]
+
+// CHECK: [[COND]]:
+// CHECK: call void @_ZN1EneERKS_(
+// CHECK: %[[CMP:.*]] = call zeroext i1 @_ZN1HcvbEv(
+// CHECK: call void @_ZN1HD1Ev(
+// CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[CLEANUP:.*]]
+
+// CHECK: [[CLEANUP]]:
+// CHECK: call void @_ZN1ED1Ev(
+// CHECK: call void @_ZN1ED1Ev(
+// In for-range:
+// call void @_ZN1DD1Ev(
+// CHECK: br label %[[END:.*]]
+
+// CHECK: [[BODY]]:
+// CHECK: call void @_ZN1EdeEv(
+// CHECK: call void @_ZN1Fcv1IEv(
+// CHECK: call void @_ZN1FD1Ev(
+// CHECK: call void @_Z4bodyRK1I(
+// CHECK: call void @_ZN1ID1Ev(
+// CHECK: br label %[[INC:.*]]
+
+// CHECK: [[INC]]:
+// CHECK: call void @_ZN1EppEv(
+// CHECK: call void @_ZN1GD1Ev(
+// CHECK: br label %[[COND]]
+
+// CHECK: [[END]]:
+// In desugared version:
+// call void @_ZN1DD1Ev(
+// CHECK: call void @_ZN1AD1Ev(
+// CHECK: ret void
diff --git a/clang/test/CodeGenCXX/for-range.cpp b/clang/test/CodeGenCXX/for-range.cpp
new file mode 100644
index 0000000..0f35dda7
--- /dev/null
+++ b/clang/test/CodeGenCXX/for-range.cpp
@@ -0,0 +1,128 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - %s | opt -instnamer -S | FileCheck %s
+
+struct A {
+ A();
+ A(const A&);
+ ~A();
+};
+
+struct B {
+ B();
+ B(const B&);
+ ~B();
+};
+
+struct C {
+ C();
+ C(const C&);
+ ~C();
+};
+
+struct D {
+ D();
+ D(const D&);
+ ~D();
+
+ B *begin();
+ B *end();
+};
+
+namespace std {
+ B *begin(C&);
+ B *end(C&);
+}
+
+extern B array[5];
+
+// CHECK: define void @_Z9for_arrayv(
+void for_array() {
+ // CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]])
+ A a;
+ for (B b : array) {
+ // CHECK-NOT: 5begin
+ // CHECK-NOT: 3end
+ // CHECK: getelementptr {{.*}}, i32 0
+ // CHECK: getelementptr {{.*}}, i64 5
+ // CHECK: br label %[[COND:.*]]
+
+ // CHECK: [[COND]]:
+ // CHECK: %[[CMP:.*]] = icmp ne
+ // CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[END:.*]]
+
+ // CHECK: [[BODY]]:
+ // CHECK: call void @_ZN1BC1ERKS_(
+ // CHECK: call void @_ZN1BD1Ev(
+ // CHECK: br label %[[INC:.*]]
+
+ // CHECK: [[INC]]:
+ // CHECK: getelementptr {{.*}} i32 1
+ // CHECK: br label %[[COND]]
+ }
+ // CHECK: [[END]]:
+ // CHECK: call void @_ZN1AD1Ev(%struct.A* [[A]])
+ // CHECK: ret void
+}
+
+// CHECK: define void @_Z9for_rangev(
+void for_range() {
+ // CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]])
+ A a;
+ for (B b : C()) {
+ // CHECK: call void @_ZN1CC1Ev(
+ // CHECK: = call %struct.B* @_ZSt5beginR1C(
+ // CHECK: = call %struct.B* @_ZSt3endR1C(
+ // CHECK: br label %[[COND:.*]]
+
+ // CHECK: [[COND]]:
+ // CHECK: %[[CMP:.*]] = icmp ne
+ // CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[CLEANUP:.*]]
+
+ // CHECK: [[CLEANUP]]:
+ // CHECK: call void @_ZN1CD1Ev(
+ // CHECK: br label %[[END:.*]]
+
+ // CHECK: [[BODY]]:
+ // CHECK: call void @_ZN1BC1ERKS_(
+ // CHECK: call void @_ZN1BD1Ev(
+ // CHECK: br label %[[INC:.*]]
+
+ // CHECK: [[INC]]:
+ // CHECK: getelementptr {{.*}} i32 1
+ // CHECK: br label %[[COND]]
+ }
+ // CHECK: [[END]]:
+ // CHECK: call void @_ZN1AD1Ev(%struct.A* [[A]])
+ // CHECK: ret void
+}
+
+// CHECK: define void @_Z16for_member_rangev(
+void for_member_range() {
+ // CHECK: call void @_ZN1AC1Ev(%struct.A* [[A:.*]])
+ A a;
+ for (B b : D()) {
+ // CHECK: call void @_ZN1DC1Ev(
+ // CHECK: = call %struct.B* @_ZN1D5beginEv(
+ // CHECK: = call %struct.B* @_ZN1D3endEv(
+ // CHECK: br label %[[COND:.*]]
+
+ // CHECK: [[COND]]:
+ // CHECK: %[[CMP:.*]] = icmp ne
+ // CHECK: br i1 %[[CMP]], label %[[BODY:.*]], label %[[CLEANUP:.*]]
+
+ // CHECK: [[CLEANUP]]:
+ // CHECK: call void @_ZN1DD1Ev(
+ // CHECK: br label %[[END:.*]]
+
+ // CHECK: [[BODY]]:
+ // CHECK: call void @_ZN1BC1ERKS_(
+ // CHECK: call void @_ZN1BD1Ev(
+ // CHECK: br label %[[INC:.*]]
+
+ // CHECK: [[INC]]:
+ // CHECK: getelementptr {{.*}} i32 1
+ // CHECK: br label %[[COND]]
+ }
+ // CHECK: [[END]]:
+ // CHECK: call void @_ZN1AD1Ev(%struct.A* [[A]])
+ // CHECK: ret void
+}
diff --git a/clang/test/CodeGenCXX/forward-enum.cpp b/clang/test/CodeGenCXX/forward-enum.cpp
new file mode 100644
index 0000000..c1169e0
--- /dev/null
+++ b/clang/test/CodeGenCXX/forward-enum.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11.0.0 -emit-llvm -o - %s | FileCheck %s
+
+enum MyEnum : char;
+void bar(MyEnum value) { }
+
+// CHECK: define void @_Z3foo6MyEnum
+void foo(MyEnum value)
+{
+ // CHECK: call void @_Z3bar6MyEnum(i8 signext
+ bar(value);
+}
diff --git a/clang/test/CodeGenCXX/fp16-mangle.cpp b/clang/test/CodeGenCXX/fp16-mangle.cpp
new file mode 100644
index 0000000..4a056d6
--- /dev/null
+++ b/clang/test/CodeGenCXX/fp16-mangle.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi %s | FileCheck %s
+
+// CHECK: @_ZN1SIDhDhE1iE = global i32 3
+template <typename T, typename U> struct S { static int i; };
+template <> int S<__fp16, __fp16>::i = 3;
+
+// CHECK: define void @_Z1fPDh(i16* %x)
+void f (__fp16 *x) { }
+
+// CHECK: define void @_Z1gPDhS_(i16* %x, i16* %y)
+void g (__fp16 *x, __fp16 *y) { }
+
diff --git a/clang/test/CodeGenCXX/fp16-overload.cpp b/clang/test/CodeGenCXX/fp16-overload.cpp
new file mode 100644
index 0000000..7562210
--- /dev/null
+++ b/clang/test/CodeGenCXX/fp16-overload.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi %s | FileCheck %s
+
+extern int foo(float x);
+extern int foo(double x);
+
+__fp16 a;
+
+// CHECK: call i32 @_Z3foof
+// CHECK-NOT: call i32 @_Z3food
+int bar (void) { return foo(a); }
diff --git a/clang/test/CodeGenCXX/friend-redecl.cpp b/clang/test/CodeGenCXX/friend-redecl.cpp
new file mode 100644
index 0000000..18292cd
--- /dev/null
+++ b/clang/test/CodeGenCXX/friend-redecl.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// PR8864
+
+struct Foo {
+ friend bool TryFoo(Foo *f2) { return TryFoo(0, f2); }
+
+// CHECK: define{{.*}}Z6TryFooP3Foo
+// CHECK-NOT: ret
+// CHECK: call{{.*}}Z6TryFooiP3Foo
+// CHECK: ret
+
+ friend bool TryFoo(int, Foo *f3);
+};
+bool TryFoo(Foo *f5);
+int main(void) {
+ Foo f;
+ TryFoo(&f);
+}
diff --git a/clang/test/CodeGenCXX/function-template-explicit-specialization.cpp b/clang/test/CodeGenCXX/function-template-explicit-specialization.cpp
new file mode 100644
index 0000000..21f0127
--- /dev/null
+++ b/clang/test/CodeGenCXX/function-template-explicit-specialization.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+template<typename T> void a(T);
+template<> void a(int) {}
+
+// CHECK: define void @_Z1aIiEvT_
+
+namespace X {
+template<typename T> void b(T);
+template<> void b(int) {}
+}
+
+// CHECK: define void @_ZN1X1bIiEEvT_
diff --git a/clang/test/CodeGenCXX/function-template-specialization.cpp b/clang/test/CodeGenCXX/function-template-specialization.cpp
new file mode 100644
index 0000000..4a79fb1
--- /dev/null
+++ b/clang/test/CodeGenCXX/function-template-specialization.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+template<typename T, typename U>
+T* next(T* ptr, const U& diff);
+
+template<typename T, typename U>
+T* next(T* ptr, const U& diff) {
+ return ptr + diff;
+}
+
+void test(int *iptr, float *fptr, int diff) {
+ // CHECK: _Z4nextIiiEPT_S1_RKT0_
+ iptr = next(iptr, diff);
+
+ // CHECK: _Z4nextIfiEPT_S1_RKT0_
+ fptr = next(fptr, diff);
+}
+
+template<typename T, typename U>
+T* next(T* ptr, const U& diff);
+
+void test2(int *iptr, double *dptr, int diff) {
+ iptr = next(iptr, diff);
+
+ // CHECK: _Z4nextIdiEPT_S1_RKT0_
+ dptr = next(dptr, diff);
+}
diff --git a/clang/test/CodeGenCXX/global-array-destruction.cpp b/clang/test/CodeGenCXX/global-array-destruction.cpp
new file mode 100644
index 0000000..5b5dfac
--- /dev/null
+++ b/clang/test/CodeGenCXX/global-array-destruction.cpp
@@ -0,0 +1,34 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+
+extern "C" int printf(...);
+
+int count;
+
+struct S {
+ S() : iS(++count) { printf("S::S(%d)\n", iS); }
+ ~S() { printf("S::~S(%d)\n", iS); }
+ int iS;
+};
+
+
+S arr[2][1];
+S s1;
+S arr1[3];
+static S sarr[4];
+
+int main () {}
+S arr2[2];
+static S sarr1[4];
+S s2;
+S arr3[3];
+
+// CHECK-LP64: callq ___cxa_atexit
+// CHECK-LP64: callq ___cxa_atexit
+// CHECK-LP64: callq ___cxa_atexit
+// CHECK-LP64: callq ___cxa_atexit
+// CHECK-LP64: callq ___cxa_atexit
+// CHECK-LP64: callq ___cxa_atexit
+// CHECK-LP64: callq ___cxa_atexit
+// CHECK-LP64: callq ___cxa_atexit
diff --git a/clang/test/CodeGenCXX/global-dtor-no-atexit.cpp b/clang/test/CodeGenCXX/global-dtor-no-atexit.cpp
new file mode 100644
index 0000000..def97b2
--- /dev/null
+++ b/clang/test/CodeGenCXX/global-dtor-no-atexit.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -triple x86_64 %s -fno-use-cxa-atexit -emit-llvm -o - | FileCheck %s
+
+// PR7097
+// RUN: %clang_cc1 -triple x86_64 %s -fno-use-cxa-atexit -mconstructor-aliases -emit-llvm -o - | FileCheck %s
+
+// CHECK: call void @_ZN1AC1Ev([[A:%.*]]* @a)
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor_a)
+// CHECK: define internal void @__dtor_a() nounwind
+// CHECK: call void @_ZN1AD1Ev([[A]]* @a)
+
+// CHECK: call void @_ZN1AC1Ev([[A]]* @b)
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor_b)
+// CHECK: define internal void @__dtor_b() nounwind
+// CHECK: call void @_ZN1AD1Ev([[A]]* @b)
+
+class A {
+public:
+ A();
+ ~A();
+};
+
+A a, b;
+
+// PR9593
+// CHECK: define void @_Z4funcv()
+// CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVZ4funcvE2a1)
+// CHECK: call void @_ZN1AC1Ev([[A]]* @_ZZ4funcvE2a1)
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor__ZZ4funcvE2a1)
+// CHECK-NEXT: call void @__cxa_guard_release(i64* @_ZGVZ4funcvE2a1)
+
+// CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVZ4funcvE2a2)
+// CHECK: call void @_ZN1AC1Ev([[A]]* @_ZZ4funcvE2a2)
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor__ZZ4funcvE2a2)
+// CHECK-NEXT: call void @__cxa_guard_release(i64* @_ZGVZ4funcvE2a2)
+
+// CHECK: define internal void @__dtor__ZZ4funcvE2a1() nounwind
+// CHECK: call void @_ZN1AD1Ev([[A]]* @_ZZ4funcvE2a1)
+
+// CHECK: define internal void @__dtor__ZZ4funcvE2a2() nounwind
+// CHECK: call void @_ZN1AD1Ev([[A]]* @_ZZ4funcvE2a2)
+
+void func() {
+ static A a1, a2;
+}
diff --git a/clang/test/CodeGenCXX/global-init-darwin.cpp b/clang/test/CodeGenCXX/global-init-darwin.cpp
new file mode 100644
index 0000000..20c13c6
--- /dev/null
+++ b/clang/test/CodeGenCXX/global-init-darwin.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm %s -o - |FileCheck %s
+
+struct A {
+ A();
+ ~A();
+};
+
+A a;
+A as[2];
+
+struct B {
+ B();
+ ~B();
+ int f();
+};
+
+int i = B().f();
+
+// CHECK: "__TEXT,__StaticInit,regular,pure_instructions" {
+// CHECK: "__TEXT,__StaticInit,regular,pure_instructions" {
+// CHECK: "__TEXT,__StaticInit,regular,pure_instructions" {
+// CHECK: "__TEXT,__StaticInit,regular,pure_instructions" {
+// CHECK: "__TEXT,__StaticInit,regular,pure_instructions" {
diff --git a/clang/test/CodeGenCXX/global-init.cpp b/clang/test/CodeGenCXX/global-init.cpp
new file mode 100644
index 0000000..8e6ef77
--- /dev/null
+++ b/clang/test/CodeGenCXX/global-init.cpp
@@ -0,0 +1,122 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -fexceptions %s -o - |FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm %s -o - |FileCheck -check-prefix NOEXC %s
+
+struct A {
+ A();
+ ~A();
+};
+
+struct B { B(); ~B(); };
+
+struct C { void *field; };
+
+struct D { ~D(); };
+
+// CHECK: @__dso_handle = external unnamed_addr global i8
+// CHECK: @c = global %struct.C zeroinitializer, align 8
+
+// It's okay if we ever implement the IR-generation optimization to remove this.
+// CHECK: @_ZN5test3L3varE = internal constant i8* getelementptr inbounds ([7 x i8]*
+
+// PR6205: The casts should not require global initializers
+// CHECK: @_ZN6PR59741cE = external global %"struct.PR5974::C"
+// CHECK: @_ZN6PR59741aE = global %"struct.PR5974::A"* getelementptr inbounds (%"struct.PR5974::C"* @_ZN6PR59741cE, i32 0, i32 0)
+// CHECK: @_ZN6PR59741bE = global %"struct.PR5974::B"* bitcast (i8* getelementptr (i8* bitcast (%"struct.PR5974::C"* @_ZN6PR59741cE to i8*), i64 4) to %"struct.PR5974::B"*), align 8
+
+// CHECK: call void @_ZN1AC1Ev(%struct.A* @a)
+// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @a, i32 0, i32 0), i8* @__dso_handle)
+A a;
+
+// CHECK: call void @_ZN1BC1Ev(%struct.B* @b)
+// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.B*)* @_ZN1BD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.B* @b, i32 0, i32 0), i8* @__dso_handle)
+B b;
+
+// PR6205: this should not require a global initializer
+// CHECK-NOT: call void @_ZN1CC1Ev(%struct.C* @c)
+C c;
+
+// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.D*)* @_ZN1DD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.D* @d, i32 0, i32 0), i8* @__dso_handle)
+D d;
+
+// <rdar://problem/7458115>
+namespace test1 {
+ int f();
+ const int x = f(); // This has side-effects and gets emitted immediately.
+ const int y = x - 1; // This gets deferred.
+ const int z = ~y; // This also gets deferred, but gets "undeferred" before y.
+ int test() { return z; }
+// CHECK: define i32 @_ZN5test14testEv()
+
+ // All of these initializers end up delayed, so we check them later.
+}
+
+// <rdar://problem/8246444>
+namespace test2 {
+ struct allocator { allocator(); ~allocator(); };
+ struct A { A(const allocator &a = allocator()); ~A(); };
+
+ A a;
+// CHECK: call void @_ZN5test29allocatorC1Ev(
+// CHECK: invoke void @_ZN5test21AC1ERKNS_9allocatorE(
+// CHECK: call void @_ZN5test29allocatorD1Ev(
+// CHECK: call i32 @__cxa_atexit({{.*}} @_ZN5test21AD1Ev {{.*}} @_ZN5test21aE
+}
+
+namespace test3 {
+ // Tested at the beginning of the file.
+ const char * const var = "string";
+ extern const char * const var;
+
+ const char *test() { return var; }
+}
+
+namespace test6 {
+ struct A {
+ A();
+ };
+ extern int foo();
+
+ // This needs an initialization function and guard variables.
+ // CHECK: load i8* bitcast (i64* @_ZGVN5test61xE
+ // CHECK: [[CALL:%.*]] = call i32 @_ZN5test63fooEv
+ // CHECK-NEXT: store i32 [[CALL]], i32* @_ZN5test61xE
+ // CHECK-NEXT: store i64 1, i64* @_ZGVN5test61xE
+ __attribute__((weak)) int x = foo();
+}
+
+namespace PR5974 {
+ struct A { int a; };
+ struct B { int b; };
+ struct C : A, B { int c; };
+
+ extern C c;
+
+ // These should not require global initializers.
+ A* a = &c;
+ B* b = &c;
+}
+// CHECK: define internal void [[TEST1_Z_INIT:@.*]]()
+// CHECK: load i32* @_ZN5test1L1yE
+// CHECK-NEXT: xor
+// CHECK-NEXT: store i32 {{.*}}, i32* @_ZN5test1L1zE
+// CHECK: define internal void [[TEST1_Y_INIT:@.*]]()
+// CHECK: load i32* @_ZN5test1L1xE
+// CHECK-NEXT: sub
+// CHECK-NEXT: store i32 {{.*}}, i32* @_ZN5test1L1yE
+
+// PR9570: the indirect field shouldn't crash IR gen.
+namespace test5 {
+ static union {
+ unsigned bar[4096] __attribute__((aligned(128)));
+ };
+}
+
+
+// At the end of the file, we check that y is initialized before z.
+
+// CHECK: define internal void @_GLOBAL__I_a() section "__TEXT,__StaticInit,regular,pure_instructions" {
+// CHECK: call void [[TEST1_Y_INIT]]
+// CHECK: call void [[TEST1_Z_INIT]]
+
+// rdar://problem/8090834: this should be nounwind
+// CHECK-NOEXC: define internal void @_GLOBAL__I_a() nounwind section "__TEXT,__StaticInit,regular,pure_instructions" {
diff --git a/clang/test/CodeGenCXX/global-llvm-constant.cpp b/clang/test/CodeGenCXX/global-llvm-constant.cpp
new file mode 100644
index 0000000..2bd43b9
--- /dev/null
+++ b/clang/test/CodeGenCXX/global-llvm-constant.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+struct A {
+ A() { x = 10; }
+ int x;
+};
+
+const A x;
+
+// CHECK: @_ZL1x = internal global
+
+struct X {
+ int (*fp)(int, int);
+};
+
+int add(int x, int y) { return x + y; }
+
+// CHECK: @x2 = constant
+extern const X x2;
+const X x2 = { &add };
+
+struct X1 {
+ mutable int i;
+};
+
+struct X2 {
+ X1 array[3];
+};
+
+// CHECK: @x2b = global
+extern const X2 x2b;
+const X2 x2b = { { { 1 }, { 2 }, { 3 } } };
diff --git a/clang/test/CodeGenCXX/goto.cpp b/clang/test/CodeGenCXX/goto.cpp
new file mode 100644
index 0000000..77b6166
--- /dev/null
+++ b/clang/test/CodeGenCXX/goto.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fcxx-exceptions -fexceptions -emit-llvm -o - | FileCheck %s
+
+// Reduced from a crash on boost::interprocess's node_allocator_test.cpp.
+namespace test0 {
+ struct A { A(); ~A(); };
+ struct V { V(const A &a = A()); ~V(); };
+
+ // CHECK: define linkonce_odr i32 @_ZN5test04testILi0EEEii
+ template<int X> int test(int x) {
+ // CHECK: [[RET:%.*]] = alloca i32
+ // CHECK-NEXT: [[X:%.*]] = alloca i32
+ // CHECK-NEXT: [[Y:%.*]] = alloca [[A:%.*]],
+ // CHECK-NEXT: [[Z:%.*]] = alloca [[A]]
+ // CHECK-NEXT: [[EXN:%.*]] = alloca i8*
+ // CHECK-NEXT: [[SEL:%.*]] = alloca i32
+ // CHECK-NEXT: [[V:%.*]] = alloca [[V:%.*]]*,
+ // CHECK-NEXT: [[TMP:%.*]] = alloca [[A]]
+ // CHECK-NEXT: [[CLEANUPACTIVE:%.*]] = alloca i1
+ // CHECK: call void @_ZN5test01AC1Ev([[A]]* [[Y]])
+ // CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[Z]])
+ // CHECK: [[NEW:%.*]] = invoke noalias i8* @_Znwm(i64 1)
+ // CHECK: store i1 true, i1* [[CLEANUPACTIVE]]
+ // CHECK: [[NEWCAST:%.*]] = bitcast i8* [[NEW]] to [[V]]*
+ // CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[TMP]])
+ // CHECK: invoke void @_ZN5test01VC1ERKNS_1AE([[V]]* [[NEWCAST]], [[A]]* [[TMP]])
+ // CHECK: store i1 false, i1* [[CLEANUPACTIVE]]
+ // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[TMP]])
+ A y;
+ try {
+ A z;
+ V *v = new V();
+
+ if (x) return 1;
+ } catch (int ex) {
+ return 1;
+ }
+ return 0;
+ }
+
+ int test() {
+ return test<0>(5);
+ }
+}
diff --git a/clang/test/CodeGenCXX/implicit-copy-assign-operator.cpp b/clang/test/CodeGenCXX/implicit-copy-assign-operator.cpp
new file mode 100644
index 0000000..0ec89fc
--- /dev/null
+++ b/clang/test/CodeGenCXX/implicit-copy-assign-operator.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10.0.0 -o - %s | FileCheck %s
+struct A {
+ A &operator=(const A&);
+ A &operator=(A&);
+};
+
+struct B {
+ B &operator=(B&);
+};
+
+struct C {
+ virtual C& operator=(const C&);
+};
+
+struct POD {
+ int array[3][4];
+};
+
+struct CopyByValue {
+ CopyByValue(const CopyByValue&);
+ CopyByValue &operator=(CopyByValue);
+};
+
+struct D : A, B, virtual C {
+ int scalar;
+ int scalar_array[2][3];
+ B class_member;
+ C class_member_array[2][3];
+ POD pod_array[2][3];
+
+ union {
+ int x;
+ float f[3];
+ };
+
+ CopyByValue by_value;
+};
+
+void test_D(D d1, D d2) {
+ d1 = d2;
+}
+
+// CHECK: define linkonce_odr %struct.D* @_ZN1DaSERS_
+// CHECK: {{call.*_ZN1AaSERS_}}
+// CHECK: {{call.*_ZN1BaSERS_}}
+// CHECK: {{call.*_ZN1CaSERKS_}}
+// CHECK: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 24}}
+// CHECK: {{call.*_ZN1BaSERS_}}
+// CHECK: br
+// CHECK: {{call.*_ZN1CaSERKS_}}
+// CHECK: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 288}}
+// CHECK: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 12}}
+// CHECK: call void @_ZN11CopyByValueC1ERKS_
+// CHECK: {{call.*_ZN11CopyByValueaSES_}}
+// CHECK: ret
+
diff --git a/clang/test/CodeGenCXX/implicit-copy-constructor.cpp b/clang/test/CodeGenCXX/implicit-copy-constructor.cpp
new file mode 100644
index 0000000..8bc84a5
--- /dev/null
+++ b/clang/test/CodeGenCXX/implicit-copy-constructor.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+
+struct A {
+ A();
+ A(const A&);
+ A(A&);
+ ~A();
+};
+
+struct B {
+ B();
+ B(B&);
+};
+
+struct C {
+ C() {}
+ C(C& other, A a = A());
+ int i, j;
+};
+
+struct POD {
+ int array[3][4];
+};
+
+struct D : A, B, virtual C {
+ D();
+ int scalar;
+ int scalar_array[2][3];
+ B class_member;
+ C class_member_array[2][3];
+ POD pod_array[2][3];
+
+ union {
+ int x;
+ float f[3];
+ };
+};
+
+void f(D d) {
+ D d2(d);
+}
+
+// CHECK: define linkonce_odr void @_ZN1DC1ERS_(%struct.D* %this, %struct.D*) unnamed_addr
+// CHECK: call void @_ZN1AC1Ev
+// CHECK: call void @_ZN1CC2ERS_1A
+// CHECK: call void @_ZN1AD1Ev
+// CHECK: call void @_ZN1AC2ERS_
+// CHECK: call void @_ZN1BC2ERS_
+// CHECK: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 24}}
+// CHECK: call void @_ZN1BC1ERS_
+// CHECK: br
+// CHECK: {{icmp ult.*, 2}}
+// CHECK: {{icmp ult.*, 3}}
+// CHECK: call void @_ZN1AC1Ev
+// CHECK: call void @_ZN1CC1ERS_1A
+// CHECK: call void @_ZN1AD1Ev
+// CHECK: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 288}}
+// CHECK: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 12}}
+// CHECK: ret void
+
+
+template<class T> struct X0 { void f0(T * ) { } };
+template <class > struct X1 { X1( X1& , int = 0 ) { } };
+struct X2 { X1<int> result; };
+void test_X2()
+{
+ typedef X2 impl;
+ typedef X0<impl> pimpl;
+ impl* i;
+ pimpl pdata;
+ pdata.f0( new impl(*i));
+}
+
+// rdar://problem/9598341
+namespace test3 {
+ struct A { A(const A&); A&operator=(const A&); };
+ struct B { A a; unsigned : 0; };
+ void test(const B &x) {
+ B y = x;
+ y = x;
+ }
+}
diff --git a/clang/test/CodeGenCXX/implicit-instantiation-1.cpp b/clang/test/CodeGenCXX/implicit-instantiation-1.cpp
new file mode 100644
index 0000000..0c826e4
--- /dev/null
+++ b/clang/test/CodeGenCXX/implicit-instantiation-1.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+template<typename T>
+struct X {
+ void f(T) { }
+ void f(char) { }
+
+ void g(T) { }
+
+ void h(T) { }
+};
+
+void foo(X<int> &xi, X<float> *xfp, int i, float f) {
+ // RUN: grep "linkonce_odr.*_ZN1XIiE1fEi" %t | count 1
+ xi.f(i);
+
+ // RUN: grep "linkonce_odr.*_ZN1XIiE1gEi" %t | count 1
+ xi.g(f);
+
+ // RUN: grep "linkonce_odr.*_ZN1XIfE1fEf" %t | count 1
+ xfp->f(f);
+
+ // RUN: grep "linkonce_odr.*_ZN1XIfE1hEf" %t | count 0
+
+}
+
+
+
diff --git a/clang/test/CodeGenCXX/incomplete-member-function-pointer.cpp b/clang/test/CodeGenCXX/incomplete-member-function-pointer.cpp
new file mode 100644
index 0000000..b97e44c
--- /dev/null
+++ b/clang/test/CodeGenCXX/incomplete-member-function-pointer.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -emit-llvm-only
+// PR7040
+struct fake_tuple;
+struct connection {
+ void bar(fake_tuple);
+};
+void (connection::*a)(fake_tuple) = &connection::bar;
+void f() {
+ void (connection::*b)(fake_tuple) = &connection::bar;
+}
diff --git a/clang/test/CodeGenCXX/incomplete-types.cpp b/clang/test/CodeGenCXX/incomplete-types.cpp
new file mode 100644
index 0000000..1d4f430
--- /dev/null
+++ b/clang/test/CodeGenCXX/incomplete-types.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 %s -emit-llvm-only -verify
+// PR5489
+
+template<typename E>
+struct Bar {
+ int x_;
+};
+
+static struct Bar<int> bar[1] = {
+ { 0 }
+};
+
+
+
+namespace incomplete_type_refs {
+ struct A;
+ extern A g[];
+ void foo(A*);
+ void f(void) {
+ foo(g); // Reference to array with unknown element type.
+ }
+
+ struct A { // define the element type.
+ int a,b,c;
+ };
+
+ A *f2() {
+ return &g[1];
+ }
+
+}
+
+namespace PR10395 {
+ struct T;
+ extern T x[];
+ T* f() { return x; }
+}
+
+namespace PR10384 {
+ struct X;
+ extern X x[1];
+ X* f() { return x; }
+}
diff --git a/clang/test/CodeGenCXX/inheriting-constructor.cpp b/clang/test/CodeGenCXX/inheriting-constructor.cpp
new file mode 100644
index 0000000..a998402
--- /dev/null
+++ b/clang/test/CodeGenCXX/inheriting-constructor.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+
+// XFAIL: *
+
+// PR12219
+struct A { A(int); virtual ~A(); };
+struct B : A { using A::A; ~B(); };
+B::~B() {}
+// CHECK: define void @_ZN1BD0Ev
+// CHECK: define void @_ZN1BD1Ev
+// CHECK: define void @_ZN1BD2Ev
diff --git a/clang/test/CodeGenCXX/init-invariant.cpp b/clang/test/CodeGenCXX/init-invariant.cpp
new file mode 100644
index 0000000..9eb1989
--- /dev/null
+++ b/clang/test/CodeGenCXX/init-invariant.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -triple i686-linux-gnu -emit-llvm %s -O0 -o - | FileCheck %s --check-prefix=CHECK-O0
+// RUN: %clang_cc1 -triple i686-linux-gnu -emit-llvm %s -O1 -o - | FileCheck %s
+
+// Check that we add an llvm.invariant.start to mark when a global becomes
+// read-only. If globalopt can fold the initializer, it will then mark the
+// variable as constant.
+
+// Do not produce markers at -O0.
+// CHECK-O0-NOT: llvm.invariant.start
+
+struct A {
+ A();
+ int n;
+};
+
+// CHECK: @a = global {{.*}} zeroinitializer
+extern const A a = A();
+
+struct B {
+ B();
+ mutable int n;
+};
+
+// CHECK: @b = global {{.*}} zeroinitializer
+extern const B b = B();
+
+struct C {
+ C();
+ ~C();
+ int n;
+};
+
+// CHECK: @c = global {{.*}} zeroinitializer
+extern const C c = C();
+
+int f();
+// CHECK: @d = global i32 0
+extern const int d = f();
+
+void e() {
+ static const A a = A();
+}
+
+// CHECK: call void @_ZN1AC1Ev({{.*}}* @a)
+// CHECK: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @a to i8*))
+
+// CHECK: call void @_ZN1BC1Ev({{.*}}* @b)
+// CHECK-NOT: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @b to i8*))
+
+// CHECK: call void @_ZN1CC1Ev({{.*}}* @c)
+// CHECK-NOT: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @c to i8*))
+
+// CHECK: call i32 @_Z1fv(
+// CHECK: store {{.*}}, i32* @d
+// CHECK: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @d to i8*))
+
+// CHECK: define void @_Z1ev(
+// CHECK: call void @_ZN1AC1Ev(%struct.A* @_ZZ1evE1a)
+// CHECK: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @_ZZ1evE1a to i8*))
+// CHECK-NOT: llvm.invariant.end
diff --git a/clang/test/CodeGenCXX/inline-functions.cpp b/clang/test/CodeGenCXX/inline-functions.cpp
new file mode 100644
index 0000000..69dfe0d
--- /dev/null
+++ b/clang/test/CodeGenCXX/inline-functions.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// CHECK: ; ModuleID
+
+struct A {
+ inline void f();
+};
+
+// CHECK-NOT: define void @_ZN1A1fEv
+void A::f() { }
+
+template<typename> struct B { };
+
+template<> struct B<char> {
+ inline void f();
+};
+
+// CHECK-NOT: _ZN1BIcE1fEv
+void B<char>::f() { }
+
+// We need a final CHECK line here.
+
+// CHECK: define void @_Z1fv
+void f() { }
+
+// <rdar://problem/8740363>
+inline void f1(int);
+
+// CHECK: define linkonce_odr void @_Z2f1i
+void f1(int) { }
+
+void test_f1() { f1(17); }
+
+// PR8789
+namespace test1 {
+ template <typename T> class ClassTemplate {
+ private:
+ friend void T::func();
+ void g() {}
+ };
+
+ // CHECK: define linkonce_odr void @_ZN5test11C4funcEv(
+
+ class C {
+ public:
+ void func() {
+ ClassTemplate<C> ct;
+ ct.g();
+ }
+ };
+
+ void f() {
+ C c;
+ c.func();
+ }
+}
diff --git a/clang/test/CodeGenCXX/instantiate-blocks.cpp b/clang/test/CodeGenCXX/instantiate-blocks.cpp
new file mode 100644
index 0000000..e206582
--- /dev/null
+++ b/clang/test/CodeGenCXX/instantiate-blocks.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -fblocks -emit-llvm -o - %s
+// rdar : // 6182276
+
+template <typename T> T foo(T t)
+{
+ void (^block)(int);
+ return 1;
+}
+
+int test1(void)
+{
+ int i = 1;
+ int b = 2;
+ i = foo(b);
+ return 0;
+}
+
+template <typename T, typename T1> void foo(T t, T1 r)
+{
+ T block_arg;
+ __block T1 byref_block_arg;
+
+ T1 (^block)(char, T, T1, double) =
+ ^ T1 (char ch, T arg, T1 arg2, double d1) { byref_block_arg = arg2;
+ return byref_block_arg + block_arg + arg; };
+
+ void (^block2)() = ^{};
+}
+
+void test2(void)
+{
+ foo(100, 'a');
+}
+
+namespace rdar6182276 {
+extern "C" {
+int printf(const char *, ...);
+}
+
+template <typename T> T foo(T t)
+{
+ void (^testing)(int) = ^(int bar) { printf("bar is %d\n", bar); };
+ printf("bar is\n");
+ return 1;
+}
+
+template <typename T> void gorf(T t)
+{
+ foo(t);
+}
+
+
+void test(void)
+{
+ gorf(2);
+}
+}
+
+
diff --git a/clang/test/CodeGenCXX/instantiate-init-list.cpp b/clang/test/CodeGenCXX/instantiate-init-list.cpp
new file mode 100644
index 0000000..49c6f51
--- /dev/null
+++ b/clang/test/CodeGenCXX/instantiate-init-list.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -emit-llvm-only -verify
+
+struct F {
+ void (*x)();
+};
+void G();
+template<class T> class A {
+public: A();
+};
+template<class T> A<T>::A() {
+ static F f = { G };
+}
+A<int> a;
diff --git a/clang/test/CodeGenCXX/instantiate-temporaries.cpp b/clang/test/CodeGenCXX/instantiate-temporaries.cpp
new file mode 100644
index 0000000..29cfc07
--- /dev/null
+++ b/clang/test/CodeGenCXX/instantiate-temporaries.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 -emit-llvm -o - %s | FileCheck %s
+
+struct X {
+ X();
+ ~X();
+};
+
+struct Y {
+ X get();
+};
+
+struct X2 {
+ X x;
+};
+
+template<typename T>
+void call() {
+ Y().get();
+}
+
+// CHECK: define weak_odr void @_Z4callIiEvv
+// CHECK: call void @_ZN1Y3getEv
+// CHECK-NEXT: call void @_ZN1XD1Ev
+// CHECK-NEXT: ret void
+template void call<int>();
+
+template<typename T>
+void compound_literal() {
+ (X2){};
+}
+
+// CHECK: define weak_odr void @_Z16compound_literalIiEvv
+// CHECK: call void @_ZN1XC1Ev
+// CHECK-NEXT: call void @_ZN2X2D1Ev
+// CHECK-NEXT: ret void
+template void compound_literal<int>();
+
diff --git a/clang/test/CodeGenCXX/instrument-functions.cpp b/clang/test/CodeGenCXX/instrument-functions.cpp
new file mode 100644
index 0000000..253e096
--- /dev/null
+++ b/clang/test/CodeGenCXX/instrument-functions.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -S -emit-llvm -o - %s -finstrument-functions | FileCheck %s
+
+// CHECK: @_Z5test1i
+int test1(int x) {
+// CHECK: __cyg_profile_func_enter
+// CHECK: __cyg_profile_func_exit
+// CHECK: ret
+ return x;
+}
+
+// CHECK: @_Z5test2i
+int test2(int) __attribute__((no_instrument_function));
+int test2(int x) {
+// CHECK-NOT: __cyg_profile_func_enter
+// CHECK-NOT: __cyg_profile_func_exit
+// CHECK: ret
+ return x;
+}
+
+// This test case previously crashed code generation. It exists solely
+// to test -finstrument-function does not crash codegen for this trivial
+// case.
+namespace rdar9445102 {
+ class Rdar9445102 {
+ public:
+ Rdar9445102();
+ };
+}
+static rdar9445102::Rdar9445102 s_rdar9445102Initializer;
+
diff --git a/clang/test/CodeGenCXX/internal-linkage.cpp b/clang/test/CodeGenCXX/internal-linkage.cpp
new file mode 100644
index 0000000..56cb810
--- /dev/null
+++ b/clang/test/CodeGenCXX/internal-linkage.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+struct Global { Global(); };
+template<typename T> struct X { X() {} };
+
+
+namespace {
+ struct Anon { Anon() {} };
+
+ // CHECK: @_ZN12_GLOBAL__N_15anon0E = internal global
+ Global anon0;
+}
+
+// CHECK: @anon1 = internal global
+Anon anon1;
+
+// CHECK: @anon2 = internal global
+X<Anon> anon2;
+
+// rdar: // 8071804
+char const * const xyzzy = "Hello, world!";
+extern char const * const xyzzy;
+
+char const * const *test1()
+{
+ // CHECK: @_ZL5xyzzy = internal constant
+ return &xyzzy;
+}
+
+static char const * const static_xyzzy = "Hello, world!";
+extern char const * const static_xyzzy;
+
+char const * const *test2()
+{
+ // CHECK: @_ZL12static_xyzzy = internal constant
+ return &static_xyzzy;
+}
+
+static char const * static_nonconst_xyzzy = "Hello, world!";
+extern char const * static_nonconst_xyzzy;
+
+char const * *test3()
+{
+ // CHECK: @_ZL21static_nonconst_xyzzy = internal global
+ return &static_nonconst_xyzzy;
+}
+
+
+char const * extern_nonconst_xyzzy = "Hello, world!";
+extern char const * extern_nonconst_xyzzy;
+
+char const * *test4()
+{
+ // CHECK: @extern_nonconst_xyzzy = global
+ return &extern_nonconst_xyzzy;
+}
+
+// PR10120
+template <typename T> class klass {
+ virtual void f();
+};
+namespace { struct S; }
+void foo () { klass<S> x; }
+// CHECK: @_ZTV5klassIN12_GLOBAL__N_11SEE = internal unnamed_addr constant
diff --git a/clang/test/CodeGenCXX/key-function-vtable.cpp b/clang/test/CodeGenCXX/key-function-vtable.cpp
new file mode 100644
index 0000000..8e474bd
--- /dev/null
+++ b/clang/test/CodeGenCXX/key-function-vtable.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// Simple key function test
+struct testa { virtual void a(); };
+void testa::a() {}
+
+// Simple key function test
+struct testb { virtual void a() {} };
+testb *testbvar = new testb;
+
+// Key function with out-of-line inline definition
+struct testc { virtual void a(); };
+inline void testc::a() {}
+
+// Functions with inline specifier are not key functions (PR5705)
+struct testd { inline virtual void a(); };
+void testd::a() {}
+
+// Functions with inline specifier are not key functions (PR5705)
+struct teste { inline virtual void a(); };
+teste *testevar = new teste;
+
+// Key functions with namespace (PR5711)
+namespace {
+ struct testf { virtual void a(); };
+}
+void testf::a() {}
+
+// Key functions with namespace (PR5711)
+namespace {
+ struct testg { virtual void a(); };
+}
+void testg::a() {}
+testg *testgvar = new testg;
+
+struct X0 { virtual ~X0(); };
+struct X1 : X0 {
+ virtual void f();
+};
+
+inline void X1::f() { }
+
+void use_X1(X1 *x1) { x1->f(); }
+
+// FIXME: The checks are extremely difficult to get right when the globals
+// aren't alphabetized
+// CHECK: @_ZTV2X1 = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTV5testa = unnamed_addr constant [3 x i8*] [i8* null
+// CHECK: @_ZTV5testc = linkonce_odr unnamed_addr constant [3 x i8*] [i8* null
+// CHECK: @_ZTVN12_GLOBAL__N_15testgE = internal unnamed_addr constant [3 x i8*] [i8* null
+// CHECK: @_ZTV5teste = linkonce_odr unnamed_addr constant [3 x i8*] [i8* null
+// CHECK: @_ZTV5testb = linkonce_odr unnamed_addr constant [3 x i8*] [i8* null
diff --git a/clang/test/CodeGenCXX/lambda-expressions.cpp b/clang/test/CodeGenCXX/lambda-expressions.cpp
new file mode 100644
index 0000000..797cbf4
--- /dev/null
+++ b/clang/test/CodeGenCXX/lambda-expressions.cpp
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 | FileCheck %s
+
+// CHECK: @var = internal global
+auto var = [](int i) { return i+1; };
+
+// CHECK: @cvar = global
+extern "C" auto cvar = []{};
+
+int a() { return []{ return 1; }(); }
+// CHECK: define i32 @_Z1av
+// CHECK: call i32 @"_ZZ1avENK3$_0clEv"
+// CHECK: define internal i32 @"_ZZ1avENK3$_0clEv"
+// CHECK: ret i32 1
+
+int b(int x) { return [x]{return x;}(); }
+// CHECK: define i32 @_Z1bi
+// CHECK: store i32
+// CHECK: load i32*
+// CHECK: store i32
+// CHECK: call i32 @"_ZZ1biENK3$_1clEv"
+// CHECK: define internal i32 @"_ZZ1biENK3$_1clEv"
+// CHECK: load i32*
+// CHECK: ret i32
+
+int c(int x) { return [&x]{return x;}(); }
+// CHECK: define i32 @_Z1ci
+// CHECK: store i32
+// CHECK: store i32*
+// CHECK: call i32 @"_ZZ1ciENK3$_2clEv"
+// CHECK: define internal i32 @"_ZZ1ciENK3$_2clEv"
+// CHECK: load i32**
+// CHECK: load i32*
+// CHECK: ret i32
+
+struct D { D(); D(const D&); int x; };
+int d(int x) { D y[10]; [x,y] { return y[x].x; }(); }
+
+// CHECK: define i32 @_Z1di
+// CHECK: call void @_ZN1DC1Ev
+// CHECK: icmp ult i64 %{{.*}}, 10
+// CHECK: call void @_ZN1DC1ERKS_
+// CHECK: call i32 @"_ZZ1diENK3$_3clEv"
+// CHECK: define internal i32 @"_ZZ1diENK3$_3clEv"
+// CHECK: load i32*
+// CHECK: load i32*
+// CHECK: ret i32
+
+struct E { E(); E(const E&); ~E(); int x; };
+int e(E a, E b, bool cond) { [a,b,cond](){ return (cond ? a : b).x; }(); }
+// CHECK: define i32 @_Z1e1ES_b
+// CHECK: call void @_ZN1EC1ERKS_
+// CHECK: invoke void @_ZN1EC1ERKS_
+// CHECK: invoke i32 @"_ZZ1e1ES_bENK3$_4clEv"
+// CHECK: call void @"_ZZ1e1ES_bEN3$_4D1Ev"
+// CHECK: call void @"_ZZ1e1ES_bEN3$_4D1Ev"
+
+// CHECK: define internal i32 @"_ZZ1e1ES_bENK3$_4clEv"
+// CHECK: trunc i8
+// CHECK: load i32*
+// CHECK: ret i32
+
+void f() {
+ // CHECK: define void @_Z1fv()
+ // CHECK: @"_ZZ1fvENK3$_5cvPFiiiEEv"
+ // CHECK-NEXT: store i32 (i32, i32)*
+ // CHECK-NEXT: ret void
+ int (*fp)(int, int) = [](int x, int y){ return x + y; };
+}
+
+// CHECK: define internal i32 @"_ZZ1fvEN3$_58__invokeEii"
+// CHECK: store i32
+// CHECK-NEXT: store i32
+// CHECK-NEXT: load i32*
+// CHECK-NEXT: load i32*
+// CHECK-NEXT: call i32 @"_ZZ1fvENK3$_5clEii"
+// CHECK-NEXT: ret i32
+
+// CHECK: define internal void @"_ZZ1e1ES_bEN3$_4D2Ev"
diff --git a/clang/test/CodeGenCXX/lvalue-bitcasts.cpp b/clang/test/CodeGenCXX/lvalue-bitcasts.cpp
new file mode 100644
index 0000000..8c5fa4a
--- /dev/null
+++ b/clang/test/CodeGenCXX/lvalue-bitcasts.cpp
@@ -0,0 +1,163 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s | FileCheck %s
+
+struct X { int i; float f; };
+struct Y { X x; };
+
+// CHECK: define void @_Z21reinterpret_cast_testRiRfR1X
+void reinterpret_cast_test(int &ir, float &fr, X &xr) {
+ // CHECK: load float**
+ // CHECK: bitcast float*
+ // CHECK: load i32*
+ ir = reinterpret_cast<int&>(fr);
+ // CHECK: load
+ // CHECK: {{bitcast.*to i32\*}}
+ // CHECK: load i32*
+ ir = reinterpret_cast<int&>(xr);
+ // CHECK: load i32
+ // CHECK: {{bitcast.*to float\*}}
+ // CHECK: load float*
+ fr = reinterpret_cast<float&>(ir);
+ // CHECK: load
+ // CHECK: {{bitcast.*to float\*}}
+ // CHECK: load float*
+ fr = reinterpret_cast<float&>(xr);
+ // CHECK: load i32**
+ // CHECK: bitcast i32*
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
+ xr = reinterpret_cast<X&>(ir);
+ // CHECK: load float**
+ // CHECK: bitcast float*
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
+ xr = reinterpret_cast<X&>(fr);
+ _Complex float cf;
+ _Complex float &cfr = cf;
+ // CHECK: load i32**
+ // CHECK: bitcast i32*
+ // CHECK: load float*
+ // CHECK: load float*
+ cfr = reinterpret_cast<_Complex float&>(ir);
+ // CHECK: load float**
+ // CHECK: bitcast float*
+ // CHECK: load float*
+ // CHECK: load float*
+ cfr = reinterpret_cast<_Complex float&>(fr);
+ // CHECK: bitcast
+ // CHECK: load float*
+ // CHECK: load float*
+ cfr = reinterpret_cast<_Complex float&>(xr);
+ // CHECK: ret void
+}
+
+// CHECK: define void @_Z6c_castRiRfR1X
+void c_cast(int &ir, float &fr, X &xr) {
+ // CHECK: load float**
+ // CHECK: bitcast float*
+ // CHECK: load i32*
+ ir = (int&)fr;
+ // CHECK: load
+ // CHECK: {{bitcast.*to i32\*}}
+ // CHECK: load i32*
+ ir = (int&)xr;
+ // CHECK: load i32
+ // CHECK: {{bitcast.*to float\*}}
+ // CHECK: load float*
+ fr = (float&)ir;
+ // CHECK: load
+ // CHECK: {{bitcast.*to float\*}}
+ // CHECK: load float*
+ fr = (float&)xr;
+ // CHECK: load i32**
+ // CHECK: bitcast i32*
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
+ xr = (X&)ir;
+ // CHECK: load float**
+ // CHECK: bitcast float*
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
+ xr = (X&)fr;
+ _Complex float cf;
+ _Complex float &cfr = cf;
+ // CHECK: load i32**
+ // CHECK: bitcast i32*
+ // CHECK: load float*
+ // CHECK: load float*
+ cfr = (_Complex float&)ir;
+ // CHECK: load float**
+ // CHECK: bitcast float*
+ // CHECK: load float*
+ // CHECK: load float*
+ cfr = (_Complex float&)fr;
+ // CHECK: bitcast
+ // CHECK: load float*
+ // CHECK: load float*
+ cfr = (_Complex float&)xr;
+ // CHECK: ret void
+}
+
+// CHECK: define void @_Z15functional_castRiRfR1X
+void functional_cast(int &ir, float &fr, X &xr) {
+ typedef int &intref;
+ typedef float &floatref;
+ typedef X &Xref;
+ // CHECK: load float**
+ // CHECK: bitcast float*
+ // CHECK: load i32*
+ ir = intref(fr);
+ // CHECK: load
+ // CHECK: {{bitcast.*to i32\*}}
+ // CHECK: load i32*
+ ir = intref(xr);
+ // CHECK: load i32
+ // CHECK: {{bitcast.*to float\*}}
+ // CHECK: load float*
+ fr = floatref(ir);
+ // CHECK: load
+ // CHECK: {{bitcast.*to float\*}}
+ // CHECK: load float*
+ fr = floatref(xr);
+ // CHECK: load i32**
+ // CHECK: bitcast i32*
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
+ xr = Xref(ir);
+ // CHECK: load float**
+ // CHECK: bitcast float*
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
+ xr = Xref(fr);
+ typedef _Complex float &complex_float_ref;
+ _Complex float cf;
+ _Complex float &cfr = cf;
+ // CHECK: load i32**
+ // CHECK: bitcast i32*
+ // CHECK: load float*
+ // CHECK: load float*
+ cfr = complex_float_ref(ir);
+ // CHECK: load float**
+ // CHECK: bitcast float*
+ // CHECK: load float*
+ // CHECK: load float*
+ cfr = complex_float_ref(fr);
+ // CHECK: bitcast
+ // CHECK: load float*
+ // CHECK: load float*
+ cfr = complex_float_ref(xr);
+ // CHECK: ret void
+}
+
+namespace PR6437 {
+ struct in_addr {};
+ void copy( const struct in_addr &new_addr ) {
+ int addr = (int&)new_addr;
+ }
+}
+
+namespace PR7593 {
+ void foo(double &X, char *A) {
+ X = reinterpret_cast<double&>(A[4]);
+ }
+}
+
+namespace PR7344 {
+ void serialize_annotatable_id( void*& id )
+ {
+ unsigned long l_id = (unsigned long&)id;
+ }
+}
diff --git a/clang/test/CodeGenCXX/m64-ptr.cpp b/clang/test/CodeGenCXX/m64-ptr.cpp
new file mode 100644
index 0000000..29916bf
--- /dev/null
+++ b/clang/test/CodeGenCXX/m64-ptr.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-darwin -o - | FileCheck %s
+
+// Make sure pointers are passed as pointers, not converted to int.
+// The first load should be of type i8** in either 32 or 64 bit mode.
+// This formerly happened on x86-64, 7375899.
+
+class StringRef {
+public:
+ const char *Data;
+ long Len;
+};
+void foo(StringRef X);
+void bar(StringRef &A) {
+// CHECK: @_Z3barR9StringRef
+// CHECK: load i8**
+ foo(A);
+// CHECK: ret void
+}
diff --git a/clang/test/CodeGenCXX/mangle-98.cpp b/clang/test/CodeGenCXX/mangle-98.cpp
new file mode 100644
index 0000000..a9ab6ca
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-98.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -std=c++98 | FileCheck %s
+
+template <bool B> struct S3 {};
+
+// CHECK: define void @_Z1f2S3ILb1EE
+void f(S3<true>) {}
+
+// CHECK: define void @_Z1f2S3ILb0EE
+void f(S3<false>) {}
+
+// CHECK: define void @_Z2f22S3ILb1EE
+void f2(S3<100>) {}
diff --git a/clang/test/CodeGenCXX/mangle-abi-examples.cpp b/clang/test/CodeGenCXX/mangle-abi-examples.cpp
new file mode 100644
index 0000000..7124078
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-abi-examples.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: @_ZTVZ3foovEN1C1DE =
+// CHECK: @_ZTVZN1A3fooEiE1B =
+// CHECK: define {{.*}} @_ZZZ3foovEN1C3barEvEN1E3bazEv(
+
+// Itanium C++ ABI examples.
+struct A {
+ void foo (int) {
+ struct B { virtual ~B() {} };
+ B();
+ }
+};
+void foo () {
+ struct C {
+ struct D { virtual ~D() {} };
+ void bar () {
+ struct E {
+ void baz() { }
+ };
+ E().baz();
+ }
+ };
+ A().foo(0);
+ C::D();
+ C().bar();
+}
diff --git a/clang/test/CodeGenCXX/mangle-address-space.cpp b/clang/test/CodeGenCXX/mangle-address-space.cpp
new file mode 100644
index 0000000..ff23c20
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-address-space.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @_Z2f0Pc
+void f0(char *p) { }
+// CHECK: define void @_Z2f0PU3AS1c
+void f0(char __attribute__((address_space(1))) *p) { }
+
+struct OpaqueType;
+typedef OpaqueType __attribute__((address_space(100))) * OpaqueTypePtr;
+
+// CHECK: define void @_Z2f0PU5AS10010OpaqueType
+void f0(OpaqueTypePtr) { }
diff --git a/clang/test/CodeGenCXX/mangle-alias-template.cpp b/clang/test/CodeGenCXX/mangle-alias-template.cpp
new file mode 100644
index 0000000..5ace0b0
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-alias-template.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+
+template<typename T> struct alloc {};
+template<typename T> using Alloc = alloc<T>;
+template<typename T, typename A = Alloc<T>> struct vector {};
+
+template<typename T> using Vec = vector<T>;
+
+template<typename T> void f(Vec<T> v);
+template<typename T> void g(T);
+
+template<template<typename> class F> void h(F<int>);
+
+template<typename,typename,typename> struct S {};
+template<typename T, typename U> using U = S<T, int, U>;
+template<typename...Ts> void h(U<Ts...>, Ts...);
+
+// CHECK: define void @_Z1zv(
+void z() {
+ vector<int> VI;
+ f(VI);
+ // CHECK: call void @_Z1fIiEv6vectorIT_5allocIS1_EE(
+
+ Vec<double> VD;
+ g(VD);
+ // CHECK: call void @_Z1gI6vectorId5allocIdEEEvT_(
+
+ h<Vec>(VI);
+ // CHECK: call void @_Z1hI3VecEvT_IiE(
+
+ Alloc<int> AC;
+ h(AC);
+ // CHECK: call void @_Z1hI5allocEvT_IiE(
+
+ h<Alloc>(AC);
+ // CHECK: call void @_Z1hI5AllocEvT_IiE(
+
+ Vec<char> VC;
+ g<Vec<char>>(VC);
+ // CHECK: call void @_Z1gI6vectorIc5allocIcEEEvT_(
+
+ Vec<Vec<int>> VVI;
+ g(VVI);
+ // CHECK: call void @_Z1gI6vectorIS0_Ii5allocIiEES1_IS3_EEEvT_(
+
+ // CHECK: call void @_Z1hIJidEEv1UIDpT_ES2_
+ h({}, 0, 0.0);
+}
diff --git a/clang/test/CodeGenCXX/mangle-exprs.cpp b/clang/test/CodeGenCXX/mangle-exprs.cpp
new file mode 100644
index 0000000..30da4fb
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-exprs.cpp
@@ -0,0 +1,193 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b),
+ __size_(__s)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+}
+
+template < bool condition, typename T = void >
+struct enable_if { typedef T type; };
+
+template< typename T >
+struct enable_if< false, T > {};
+
+// PR5876
+namespace Casts {
+ template< unsigned O >
+ void implicit(typename enable_if< O <= 4 >::type* = 0) {
+ }
+
+ template< unsigned O >
+ void cstyle(typename enable_if< O <= (unsigned)4 >::type* = 0) {
+ }
+
+ template< unsigned O >
+ void functional(typename enable_if< O <= unsigned(4) >::type* = 0) {
+ }
+
+ template< unsigned O >
+ void static_(typename enable_if< O <= static_cast<unsigned>(4) >::type* = 0) {
+ }
+
+ template< typename T >
+ void auto_(decltype(new auto(T()))) {
+ }
+
+ template< typename T >
+ void scalar_(decltype(T(), int())) {
+ }
+
+ // FIXME: Test const_cast, reinterpret_cast, dynamic_cast, which are
+ // a bit harder to use in template arguments.
+ template <unsigned N> struct T {};
+
+ template <int N> T<N> f() { return T<N>(); }
+
+ // CHECK: define weak_odr void @_ZN5Casts8implicitILj4EEEvPN9enable_ifIXleT_Li4EEvE4typeE
+ template void implicit<4>(void*);
+ // CHECK: define weak_odr void @_ZN5Casts6cstyleILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE
+ template void cstyle<4>(void*);
+ // CHECK: define weak_odr void @_ZN5Casts10functionalILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE
+ template void functional<4>(void*);
+ // CHECK: define weak_odr void @_ZN5Casts7static_ILj4EEEvPN9enable_ifIXleT_cvjLi4EEvE4typeE
+ template void static_<4>(void*);
+
+ // CHECK: define weak_odr void @_ZN5Casts1fILi6EEENS_1TIXT_EEEv
+ template T<6> f<6>();
+
+ // CHECK: define weak_odr void @_ZN5Casts5auto_IiEEvDTnw_DapicvT__EEE(
+ template void auto_<int>(int*);
+
+ // CHECK: define weak_odr void @_ZN5Casts7scalar_IiEEvDTcmcvT__Ecvi_EE(
+ template void scalar_<int>(int);
+}
+
+namespace test1 {
+ short foo(short);
+ int foo(int);
+
+ // CHECK: define linkonce_odr signext i16 @_ZN5test11aIsEEDTcl3foocvT__EEES1_(
+ template <class T> auto a(T t) -> decltype(foo(T())) { return foo(t); }
+
+ // CHECK: define linkonce_odr signext i16 @_ZN5test11bIsEEDTcp3foocvT__EEES1_(
+ template <class T> auto b(T t) -> decltype((foo)(T())) { return (foo)(t); }
+
+ void test(short s) {
+ a(s);
+ b(s);
+ }
+}
+
+namespace test2 {
+ template <class T> void a(T x, decltype(x()) y) {}
+ template <class T> auto b(T x) -> decltype(x()) { return x(); }
+ template <class T> void c(T x, void (*p)(decltype(x()))) {}
+ template <class T> void d(T x, auto (*p)() -> decltype(x())) {}
+ template <class T> void e(auto (*p)(T y) -> decltype(y())) {}
+ template <class T> void f(void (*p)(T x, decltype(x()) y)) {}
+ template <class T> void g(T x, decltype(x()) y) {
+ static decltype(x()) variable;
+ variable = 0;
+ }
+ template <class T> void h(T x, decltype((decltype(x())(*)()) 0) y) {}
+ template <class T> void i(decltype((auto (*)(T x) -> decltype(x())) 0) y) {}
+
+ float foo();
+ void bar(float);
+ float baz(float(*)());
+ void fred(float(*)(), float);
+
+ // CHECK: define void @_ZN5test211instantiateEv
+ void instantiate() {
+ // CHECK: call void @_ZN5test21aIPFfvEEEvT_DTclfL0p_EE(
+ a(foo, 0.0f);
+ // CHECK: call float @_ZN5test21bIPFfvEEEDTclfp_EET_(
+ (void) b(foo);
+ // CHECK: call void @_ZN5test21cIPFfvEEEvT_PFvDTclfL1p_EEE(
+ c(foo, bar);
+ // CHECK: call void @_ZN5test21dIPFfvEEEvT_PFDTclfL0p_EEvE(
+ d(foo, foo);
+ // CHECK: call void @_ZN5test21eIPFfvEEEvPFDTclfp_EET_E(
+ e(baz);
+ // CHECK: call void @_ZN5test21fIPFfvEEEvPFvT_DTclfL0p_EEE(
+ f(fred);
+ // CHECK: call void @_ZN5test21gIPFfvEEEvT_DTclfL0p_EE(
+ g(foo, 0.0f);
+ // CHECK: call void @_ZN5test21hIPFfvEEEvT_DTcvPFDTclfL0p_EEvELi0EE(
+ h(foo, foo);
+ // CHECK: call void @_ZN5test21iIPFfvEEEvDTcvPFDTclfp_EET_ELi0EE(
+ i<float(*)()>(baz);
+ }
+
+ // CHECK: store float {{.*}}, float* @_ZZN5test21gIPFfvEEEvT_DTclfL0p_EEE8variable,
+}
+
+namespace test3 {
+ template <class T, class U> void a(T x, U y, decltype(x.*y) z) {}
+
+ struct X {
+ int *member;
+ };
+
+ // CHECK: define void @_ZN5test311instantiateEv
+ void instantiate() {
+ X x;
+ int *ip;
+ // CHECK: call void @_ZN5test31aINS_1XEMS1_PiEEvT_T0_DTdsfL0p_fL0p0_E
+ a(x, &X::member, ip);
+ }
+}
+
+namespace test4 {
+ struct X {
+ X(int);
+ };
+
+ template <typename T>
+ void tf1(decltype(new T(1)) p)
+ {}
+
+ template <typename T>
+ void tf2(decltype(new T({1})) p)
+ {}
+
+ template <typename T>
+ void tf3(decltype(new T{1}) p)
+ {}
+
+ // CHECK: void @_ZN5test43tf1INS_1XEEEvDTnw_T_piLi1EEE
+ template void tf1<X>(X*);
+
+ // CHECK: void @_ZN5test43tf2INS_1XEEEvDTnw_T_piilLi1EEEE
+ template void tf2<X>(X*);
+
+ // CHECK: void @_ZN5test43tf3INS_1XEEEvDTnw_T_ilLi1EEE
+ template void tf3<X>(X*);
+}
diff --git a/clang/test/CodeGenCXX/mangle-extern-local.cpp b/clang/test/CodeGenCXX/mangle-extern-local.cpp
new file mode 100644
index 0000000..ed91da4
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-extern-local.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: @var1 = external global i32
+// CHECK: @_ZN1N4var2E = external global i32
+// CHECK: @var5 = external global i32
+// CHECK: @_ZN1N4var3E = external global i32
+// CHECK: @_ZN1N4var4E = external global i32
+
+// CHECK: declare i32 @_Z5func1v()
+// CHECK: declare i32 @_ZN1N5func2Ev()
+// CHECK: declare i32 @func4()
+// CHECK: declare i32 @_ZN1N5func3Ev()
+
+int f1() {
+ extern int var1, func1();
+ return var1 + func1();
+}
+
+namespace N {
+
+int f2() {
+ extern int var2, func2();
+ return var2 + func2();
+}
+
+struct S {
+ static int f3() {
+ extern int var3, func3();
+ struct LC { int localfunc() { extern int var4; return var4; } };
+ LC localobj;
+ return var3 + func3() + localobj.localfunc();
+ }
+};
+
+int anchorf3() { return S::f3(); }
+
+extern "C" {
+int f4() {
+ extern int var5, func4();
+ return var5 + func4();
+}
+}
+
+}
+
diff --git a/clang/test/CodeGenCXX/mangle-extreme.cpp b/clang/test/CodeGenCXX/mangle-extreme.cpp
new file mode 100644
index 0000000..ef2d466
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-extreme.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+
+struct X { };
+
+// CHECK: define void @_Z1fPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP1XS13_S12_S11_S10_SZ_SY_SX_SW_SV_SU_ST_SS_SR_SQ_SP_SO_SN_SM_SL_SK_SJ_SI_SH_SG_SF_SE_SD_SC_SB_SA_S9_S8_S7_S6_S5_S4_S3_S2_S1_S0_S_(
+void f(X****************************************,
+ X****************************************,
+ X***************************************,
+ X**************************************,
+ X*************************************,
+ X************************************,
+ X***********************************,
+ X**********************************,
+ X*********************************,
+ X********************************,
+ X*******************************,
+ X******************************,
+ X*****************************,
+ X****************************,
+ X***************************,
+ X**************************,
+ X*************************,
+ X************************,
+ X***********************,
+ X**********************,
+ X*********************,
+ X********************,
+ X*******************,
+ X******************,
+ X*****************,
+ X****************,
+ X***************,
+ X**************,
+ X*************,
+ X************,
+ X***********,
+ X**********,
+ X*********,
+ X********,
+ X*******,
+ X******,
+ X*****,
+ X****,
+ X***,
+ X**,
+ X*,
+ X) { }
diff --git a/clang/test/CodeGenCXX/mangle-lambdas.cpp b/clang/test/CodeGenCXX/mangle-lambdas.cpp
new file mode 100644
index 0000000..cc53b01
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-lambdas.cpp
@@ -0,0 +1,202 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-macosx10.7.0 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define linkonce_odr void @_Z11inline_funci
+inline void inline_func(int n) {
+ // CHECK: call i32 @_ZZ11inline_funciENKUlvE_clEv
+ int i = []{ return 1; }();
+
+ // CHECK: call i32 @_ZZ11inline_funciENKUlvE0_clEv
+ int j = [=] { return n + i; }();
+
+ // CHECK: call double @_ZZ11inline_funciENKUlvE1_clEv
+ int k = [=] () -> double { return n + i; }();
+
+ // CHECK: call i32 @_ZZ11inline_funciENKUliE_clEi
+ int l = [=] (int x) -> int { return x + i; }(n);
+
+ int inner(int i = []{ return 17; }());
+ // CHECK: call i32 @_ZZ11inline_funciENKUlvE2_clEv
+ // CHECK-NEXT: call i32 @_Z5inneri
+ inner();
+
+ // CHECK-NEXT: ret void
+}
+
+void call_inline_func() {
+ inline_func(17);
+}
+
+struct S {
+ void f(int = []{return 1;}()
+ + []{return 2;}(),
+ int = []{return 3;}());
+ void g(int, int);
+};
+
+void S::g(int i = []{return 1;}(),
+ int j = []{return 2; }()) {}
+
+// CHECK: define void @_Z6test_S1S
+void test_S(S s) {
+ // CHECK: call i32 @_ZZN1S1fEiiEd0_NKUlvE_clEv
+ // CHECK-NEXT: call i32 @_ZZN1S1fEiiEd0_NKUlvE0_clEv
+ // CHECK-NEXT: add nsw i32
+ // CHECK-NEXT: call i32 @_ZZN1S1fEiiEd_NKUlvE_clEv
+ // CHECK-NEXT: call void @_ZN1S1fEii
+ s.f();
+
+ // NOTE: These manglings don't actually matter that much, because
+ // the lambdas in the default arguments of g() won't be seen by
+ // multiple translation units. We check them mainly to ensure that they don't
+ // get the special mangling for lambdas in in-class default arguments.
+ // CHECK: call i32 @"_ZNK1S3$_0clEv"
+ // CHECK-NEXT: call i32 @"_ZNK1S3$_1clEv"
+ // CHECK-NEXT: call void @_ZN1S1gEi
+ s.g();
+
+ // CHECK-NEXT: ret void
+}
+
+// Check the linkage of the lambda call operators used in test_S.
+// CHECK: define linkonce_odr i32 @_ZZN1S1fEiiEd0_NKUlvE_clEv
+// CHECK: ret i32 1
+// CHECK: define linkonce_odr i32 @_ZZN1S1fEiiEd0_NKUlvE0_clEv
+// CHECK: ret i32 2
+// CHECK: define linkonce_odr i32 @_ZZN1S1fEiiEd_NKUlvE_clEv
+// CHECK: ret i32 3
+// CHECK: define internal i32 @"_ZNK1S3$_0clEv"
+// CHECK: ret i32 1
+// CHECK: define internal i32 @"_ZNK1S3$_1clEv"
+// CHECK: ret i32 2
+
+template<typename T>
+struct ST {
+ void f(T = []{return T() + 1;}()
+ + []{return T() + 2;}(),
+ T = []{return T(3);}());
+};
+
+// CHECK: define void @_Z7test_ST2STIdE
+void test_ST(ST<double> st) {
+ // CHECK: call double @_ZZN2ST1fET_S0_Ed0_NKUlvE_clEv
+ // CHECK-NEXT: call double @_ZZN2ST1fET_S0_Ed0_NKUlvE0_clEv
+ // CHECK-NEXT: fadd double
+ // CHECK-NEXT: call double @_ZZN2ST1fET_S0_Ed_NKUlvE_clEv
+ // CHECK-NEXT: call void @_ZN2STIdE1fEdd
+ st.f();
+
+ // CHECK-NEXT: ret void
+}
+
+// Check the linkage of the lambda call operators used in test_ST.
+// CHECK: define linkonce_odr double @_ZZN2ST1fET_S0_Ed0_NKUlvE_clEv
+// CHECK: ret double 1
+// CHECK: define linkonce_odr double @_ZZN2ST1fET_S0_Ed0_NKUlvE0_clEv
+// CHECK: ret double 2
+// CHECK: define linkonce_odr double @_ZZN2ST1fET_S0_Ed_NKUlvE_clEv
+// CHECK: ret double 3
+
+template<typename T>
+struct StaticMembers {
+ static T x;
+ static T y;
+ static T z;
+};
+
+template<typename T> int accept_lambda(T);
+
+template<typename T>
+T StaticMembers<T>::x = []{return 1;}() + []{return 2;}();
+
+template<typename T>
+T StaticMembers<T>::y = []{return 3;}();
+
+template<typename T>
+T StaticMembers<T>::z = accept_lambda([]{return 4;});
+
+// CHECK: define internal void @__cxx_global_var_init()
+// CHECK: call i32 @_ZNK13StaticMembersIfE1xMUlvE_clEv
+// CHECK-NEXT: call i32 @_ZNK13StaticMembersIfE1xMUlvE0_clEv
+// CHECK-NEXT: add nsw
+// CHECK: define linkonce_odr i32 @_ZNK13StaticMembersIfE1xMUlvE_clEv
+// CHECK: ret i32 1
+// CHECK: define linkonce_odr i32 @_ZNK13StaticMembersIfE1xMUlvE0_clEv
+// CHECK: ret i32 2
+template float StaticMembers<float>::x;
+
+// CHECK: define internal void @__cxx_global_var_init1()
+// CHECK: call i32 @_ZNK13StaticMembersIfE1yMUlvE_clEv
+// CHECK: define linkonce_odr i32 @_ZNK13StaticMembersIfE1yMUlvE_clEv
+// CHECK: ret i32 3
+template float StaticMembers<float>::y;
+
+// CHECK: define internal void @__cxx_global_var_init2()
+// CHECK: call i32 @_Z13accept_lambdaIN13StaticMembersIfE1zMUlvE_EEiT_
+// CHECK: declare i32 @_Z13accept_lambdaIN13StaticMembersIfE1zMUlvE_EEiT_()
+template float StaticMembers<float>::z;
+
+// CHECK: define internal void @__cxx_global_var_init3
+// CHECK: call i32 @"_ZNK13StaticMembersIdE3$_2clEv"
+// CHECK: define internal i32 @"_ZNK13StaticMembersIdE3$_2clEv"
+// CHECK: ret i32 42
+template<> double StaticMembers<double>::z = []{return 42; }();
+
+template<typename T>
+void func_template(T = []{ return T(); }());
+
+// CHECK: define void @_Z17use_func_templatev()
+void use_func_template() {
+ // CHECK: call i32 @"_ZZ13func_templateIiEvT_ENKS_IiE3$_3clEv"
+ func_template<int>();
+}
+
+// CHECK: define linkonce_odr void @_Z1fIZZNK23TestNestedInstantiationclEvENKUlvE_clEvEUlvE_EvT_
+
+struct Members {
+ int x = [] { return 1; }() + [] { return 2; }();
+ int y = [] { return 3; }();
+};
+
+void test_Members() {
+ // CHECK: define linkonce_odr void @_ZN7MembersC2Ev
+ // CHECK: call i32 @_ZNK7Members1xMUlvE_clEv
+ // CHECK-NEXT: call i32 @_ZNK7Members1xMUlvE0_clE
+ // CHECK-NEXT: add nsw i32
+ // CHECK: call i32 @_ZNK7Members1yMUlvE_clEv
+ Members members;
+ // CHECK: ret void
+}
+
+template<typename P> void f(P) { }
+
+struct TestNestedInstantiation {
+ void operator()() const {
+ []() -> void {
+ return f([]{});
+ }();
+ }
+};
+
+void test_NestedInstantiation() {
+ TestNestedInstantiation()();
+}
+
+// Check the linkage of the lambdas used in test_Members.
+// CHECK: define linkonce_odr i32 @_ZNK7Members1xMUlvE_clEv
+// CHECK: ret i32 1
+// CHECK: define linkonce_odr i32 @_ZNK7Members1xMUlvE0_clEv
+// CHECK: ret i32 2
+// CHECK: define linkonce_odr i32 @_ZNK7Members1yMUlvE_clEv
+// CHECK: ret i32 3
+
+// Check linkage of the various lambdas.
+// CHECK: define linkonce_odr i32 @_ZZ11inline_funciENKUlvE_clEv
+// CHECK: ret i32 1
+// CHECK: define linkonce_odr i32 @_ZZ11inline_funciENKUlvE0_clEv
+// CHECK: ret i32
+// CHECK: define linkonce_odr double @_ZZ11inline_funciENKUlvE1_clEv
+// CHECK: ret double
+// CHECK: define linkonce_odr i32 @_ZZ11inline_funciENKUliE_clEi
+// CHECK: ret i32
+// CHECK: define linkonce_odr i32 @_ZZ11inline_funciENKUlvE2_clEv
+// CHECK: ret i32 17
diff --git a/clang/test/CodeGenCXX/mangle-local-class-names.cpp b/clang/test/CodeGenCXX/mangle-local-class-names.cpp
new file mode 100644
index 0000000..3321460
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-local-class-names.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: @_ZZ4FUNCvEN4SSSSC1ERKf
+// CHECK: @_ZZ4FUNCvEN4SSSSC2E_0RKf
+// CHECK: @_ZZ4GORFfEN4SSSSC1ERKf
+// CHECK: @_ZZ4GORFfEN4SSSSC2E_0RKf
+
+void FUNC ()
+{
+ {
+ float IVAR1 ;
+
+ struct SSSS
+ {
+ float bv;
+ SSSS( const float& from): bv(from) { }
+ };
+
+ SSSS VAR1(IVAR1);
+ }
+
+ {
+ float IVAR2 ;
+
+ struct SSSS
+ {
+ SSSS( const float& from) {}
+ };
+
+ SSSS VAR2(IVAR2);
+ }
+}
+
+void GORF (float IVAR1)
+{
+ {
+ struct SSSS
+ {
+ float bv;
+ SSSS( const float& from): bv(from) { }
+ };
+
+ SSSS VAR1(IVAR1);
+ }
+
+ {
+ float IVAR2 ;
+
+ struct SSSS
+ {
+ SSSS( const float& from) {}
+ };
+
+ SSSS VAR2(IVAR2);
+ }
+}
+
diff --git a/clang/test/CodeGenCXX/mangle-local-class-vtables.cpp b/clang/test/CodeGenCXX/mangle-local-class-vtables.cpp
new file mode 100644
index 0000000..d9d3afe
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-local-class-vtables.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: @_ZTVZN1J1KEvE1C = {{.*}} @_ZTIZN1J1KEvE1C {{.*}} @_ZZN1J1KEvENK1C1FEv
+// CHECK: @_ZTIZN1J1KEvE1C = {{.*}} @_ZTSZN1J1KEvE1C
+// CHECK: @_ZTVZ1GvE1C_1 = {{.*}} @_ZTIZ1GvE1C_1 {{.*}} @_ZZ1GvENK1C1FE_1v
+// CHECK: @_ZTIZ1GvE1C_1 = {{.*}} @_ZTSZ1GvE1C_1
+// CHECK: @_ZTVZ1GvE1C_0 = {{.*}} @_ZTIZ1GvE1C_0 {{.*}} @_ZZ1GvENK1C1FE_0v
+// CHECK: @_ZTIZ1GvE1C_0 = {{.*}} @_ZTSZ1GvE1C_0
+// CHECK: @_ZTVZ1GvE1C = {{.*}} @_ZTIZ1GvE1C {{.*}} @_ZZ1GvENK1C1FEv
+// CHECK: @_ZTIZ1GvE1C = {{.*}} @_ZTSZ1GvE1C
+
+// CHECK: define {{.*}} @_ZZN1J1KEvEN1CC2Ev(
+// CHECK: define {{.*}} @_ZZN1J1KEvENK1C1FEv(
+// CHECK: define {{.*}} @_ZZ1GvEN1CC2E_1v(
+// CHECK: define {{.*}} @_ZZ1GvENK1C1FE_1v(
+// CHECK: define {{.*}} @_ZZ1GvENK1C1HE_1v(
+// CHECK: define {{.*}} @_ZZ1GvEN1CC2E_0v(
+// CHECK: define {{.*}} @_ZZ1GvENK1C1FE_0v(
+// CHECK: define {{.*}} @_ZZ1GvENK1C1GE_0v(
+// CHECK: define {{.*}} @_ZZ1GvEN1CC2Ev(
+// CHECK: define {{.*}} @_ZZ1GvENK1C1FEv(
+
+struct I {
+ virtual void F() const = 0;
+};
+
+void Go(const I &i);
+
+void G() {
+ {
+ struct C : I {
+ void F() const {}
+ };
+ Go(C());
+ }
+ {
+ struct C : I {
+ void F() const { G(); }
+ void G() const {}
+ };
+ Go(C());
+ }
+ {
+ struct C : I {
+ void F() const { H(); }
+ void H() const {}
+ };
+ Go(C());
+ }
+}
+
+struct J {
+ void K();
+};
+
+void J::K() {
+ struct C : I {
+ void F() const {}
+ };
+ Go(C());
+}
diff --git a/clang/test/CodeGenCXX/mangle-local-classes-nested.cpp b/clang/test/CodeGenCXX/mangle-local-classes-nested.cpp
new file mode 100644
index 0000000..fafa5d4
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-local-classes-nested.cpp
@@ -0,0 +1,81 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: @_ZTVZZ1HvEN1S1IEvE1S =
+
+// CHECK: define {{.*}} @_Z2L1v(
+// CHECK: define {{.*}} @_ZZ2L1vEN1S2L2Ev(
+// CHECK: define {{.*}} @_ZZ2L1vEN1S2L2E_0v(
+// CHECK: define {{.*}} @_ZZ1FvEN1S1T1S1T1GEv(
+// CHECK: define {{.*}} @_ZZZ2L1vEN1S2L2E_0vEN1S3L3cEv(
+// CHECK: define {{.*}} @_ZZZ2L1vEN1S2L2E_0vEN1S3L3dE_0v(
+// CHECK: define {{.*}} @_ZZZ2L1vEN1S2L2EvEN1S3L3aEv(
+// CHECK: define {{.*}} @_ZZZ2L1vEN1S2L2EvEN1S3L3bE_0v(
+
+void L1() {
+ {
+ struct S {
+ void L2() {
+ {
+ struct S {
+ void L3a() {}
+ };
+ S().L3a();
+ }
+ {
+ struct S {
+ void L3b() {}
+ };
+ S().L3b();
+ }
+ }
+ };
+ S().L2();
+ }
+ {
+ struct S {
+ void L2() {
+ {
+ struct S {
+ void L3c() {}
+ };
+ S().L3c();
+ }
+ {
+ struct S {
+ void L3d() {}
+ };
+ S().L3d();
+ }
+ }
+ };
+ S().L2();
+ }
+}
+
+void F() {
+ struct S {
+ struct T {
+ struct S {
+ struct T {
+ void G() {}
+ };
+ };
+ };
+ };
+ S::T::S::T().G();
+}
+
+struct B { virtual void Foo() = 0; };
+void G(const B &);
+
+void H() {
+ struct S {
+ void I() {
+ struct S : B {
+ virtual void Foo() {}
+ };
+ G(S());
+ }
+ };
+ S().I();
+}
diff --git a/clang/test/CodeGenCXX/mangle-ms.cpp b/clang/test/CodeGenCXX/mangle-ms.cpp
new file mode 100644
index 0000000..fe5fde1
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-ms.cpp
@@ -0,0 +1,105 @@
+// RUN: %clang_cc1 -fms-extensions -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s
+
+// CHECK: @"\01?a@@3HA"
+// CHECK: @"\01?b@N@@3HA"
+// CHECK: @c
+// CHECK: @"\01?d@foo@@0FB"
+// CHECK: @"\01?e@foo@@1JC"
+// CHECK: @"\01?f@foo@@2DD"
+// CHECK: @"\01?g@bar@@2HA"
+// CHECK: @"\01?h@@3QAHA"
+// CHECK: @"\01?i@@3PAY0BE@HA"
+// CHECK: @"\01?j@@3P6GHCE@ZA"
+// CHECK: @"\01?k@@3PTfoo@@DA"
+// CHECK: @"\01?l@@3P8foo@@AEHH@ZA"
+
+int a;
+
+namespace N { int b; }
+
+static int c;
+int _c(void) {return c;}
+// CHECK: @"\01?_c@@YAHXZ"
+
+class foo {
+ static const short d;
+protected:
+ static volatile long e;
+public:
+ static const volatile char f;
+ int operator+(int a);
+ foo(){}
+//CHECK: @"\01??0foo@@QAE@XZ"
+
+ ~foo(){}
+//CHECK: @"\01??1foo@@QAE@XZ"
+
+ foo(int i){}
+//CHECK: @"\01??0foo@@QAE@H@Z"
+
+ foo(char *q){}
+//CHECK: @"\01??0foo@@QAE@PAD@Z"
+}f,s1(1),s2((char*)0);
+
+struct bar {
+ static int g;
+};
+
+union baz {
+ int a;
+ char b;
+ double c;
+};
+
+enum quux {
+ qone,
+ qtwo,
+ qthree
+};
+
+int foo::operator+(int a) {return a;}
+// CHECK: @"\01??Hfoo@@QAEHH@Z"
+
+const short foo::d = 0;
+volatile long foo::e;
+const volatile char foo::f = 'C';
+
+int bar::g;
+
+extern int * const h = &a;
+
+int i[10][20];
+
+int (__stdcall *j)(signed char, unsigned char);
+
+const volatile char foo::*k;
+
+int (foo::*l)(int);
+
+// Static functions are mangled, too.
+// Also make sure calling conventions, arglists, and throw specs work.
+static void __stdcall alpha(float a, double b) throw() {}
+bool __fastcall beta(long long a, wchar_t b) throw(signed char, unsigned char) {
+// CHECK: @"\01?beta@@YI_N_J_W@Z"
+ alpha(0.f, 0.0);
+ return false;
+}
+
+// CHECK: @"\01?alpha@@YGXMN@Z"
+
+// Make sure tag-type mangling works.
+void gamma(class foo, struct bar, union baz, enum quux) {}
+// CHECK: @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z"
+
+// Make sure pointer/reference-type mangling works.
+void delta(int * const a, const long &) {}
+// CHECK: @"\01?delta@@YAXQAHABJ@Z"
+
+// Array mangling.
+void epsilon(int a[][10][20]) {}
+// CHECK: @"\01?epsilon@@YAXQAY19BE@H@Z"
+
+// Blocks mangling (Clang extension).
+void zeta(int (^)(int, int)) {}
+// CHECK: @"\01?zeta@@YAXP_EAHHH@Z@Z"
+
diff --git a/clang/test/CodeGenCXX/mangle-neon-vectors.cpp b/clang/test/CodeGenCXX/mangle-neon-vectors.cpp
new file mode 100644
index 0000000..3723deb
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-neon-vectors.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+typedef float float32_t;
+typedef signed char poly8_t;
+typedef short poly16_t;
+typedef unsigned long long uint64_t;
+
+typedef __attribute__((neon_vector_type(2))) int int32x2_t;
+typedef __attribute__((neon_vector_type(4))) int int32x4_t;
+typedef __attribute__((neon_vector_type(1))) uint64_t uint64x1_t;
+typedef __attribute__((neon_vector_type(2))) uint64_t uint64x2_t;
+typedef __attribute__((neon_vector_type(2))) float32_t float32x2_t;
+typedef __attribute__((neon_vector_type(4))) float32_t float32x4_t;
+typedef __attribute__((neon_polyvector_type(16))) poly8_t poly8x16_t;
+typedef __attribute__((neon_polyvector_type(8))) poly16_t poly16x8_t;
+
+// CHECK: 16__simd64_int32_t
+void f1(int32x2_t v) { }
+// CHECK: 17__simd128_int32_t
+void f2(int32x4_t v) { }
+// CHECK: 17__simd64_uint64_t
+void f3(uint64x1_t v) { }
+// CHECK: 18__simd128_uint64_t
+void f4(uint64x2_t v) { }
+// CHECK: 18__simd64_float32_t
+void f5(float32x2_t v) { }
+// CHECK: 19__simd128_float32_t
+void f6(float32x4_t v) { }
+// CHECK: 17__simd128_poly8_t
+void f7(poly8x16_t v) { }
+// CHECK: 18__simd128_poly16_t
+void f8(poly16x8_t v) { }
diff --git a/clang/test/CodeGenCXX/mangle-nullptr-arg.cpp b/clang/test/CodeGenCXX/mangle-nullptr-arg.cpp
new file mode 100644
index 0000000..393de0b
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-nullptr-arg.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+template<int *ip> struct IP {};
+
+// CHECK: define void @_Z5test12IPILPi0EE
+void test1(IP<nullptr>) {}
+
+struct X{ };
+template<int X::*pm> struct PM {};
+
+// CHECK: define void @_Z5test22PMILM1Xi0EE
+void test2(PM<nullptr>) { }
+
diff --git a/clang/test/CodeGenCXX/mangle-ref-qualifiers.cpp b/clang/test/CodeGenCXX/mangle-ref-qualifiers.cpp
new file mode 100644
index 0000000..568cf9f
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-ref-qualifiers.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+struct X {
+ int f() &;
+ int g() &&;
+ int h() const &&;
+};
+
+// CHECK: define i32 @_ZNR1X1fEv
+int X::f() & { return 0; }
+// CHECK: define i32 @_ZNO1X1gEv
+int X::g() && { return 0; }
+// CHECK: define i32 @_ZNKO1X1hEv
+int X::h() const && { return 0; }
+
+// CHECK: define void @_Z1fM1XRFivEMS_OFivEMS_KOFivE
+void f(int (X::*)() &, int (X::*)() &&, int (X::*)() const&&) { }
diff --git a/clang/test/CodeGenCXX/mangle-std-externc.cpp b/clang/test/CodeGenCXX/mangle-std-externc.cpp
new file mode 100644
index 0000000..a478dee
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-std-externc.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -DNS=std -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-STD
+// RUN: %clang_cc1 %s -DNS=n -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-N
+
+// _ZNSt1DISt1CE1iE = std::D<std::C>::i
+// CHECK-STD: @_ZNSt1DISt1CE1iE =
+
+// _ZN1n1DINS_1CEE1iE == n::D<n::C>::i
+// CHECK-N: @_ZN1n1DINS_1CEE1iE =
+
+namespace NS {
+ extern "C" {
+ class C {
+ };
+ }
+
+ template <class T>
+ class D {
+ public:
+ static int i;
+ };
+
+}
+
+
+int f() {
+ return NS::D<NS::C>::i;
+}
diff --git a/clang/test/CodeGenCXX/mangle-subst-std.cpp b/clang/test/CodeGenCXX/mangle-subst-std.cpp
new file mode 100644
index 0000000..04e3e84
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-subst-std.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+
+// Check mangling of Vtables, VTTs, and construction vtables that
+// involve standard substitutions.
+
+// CHECK: @_ZTVSd = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTTSd = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTCSd0_Si = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTCSd16_So = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTVSo = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTTSo = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTVSi = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTTSi = linkonce_odr unnamed_addr constant
+
+namespace std {
+ struct A { A(); };
+
+ // CHECK: define void @_ZNSt1AC1Ev(%"struct.std::A"* %this) unnamed_addr
+ // CHECK: define void @_ZNSt1AC2Ev(%"struct.std::A"* %this) unnamed_addr
+ A::A() { }
+};
+
+namespace std {
+ template<typename> struct allocator { };
+}
+
+// CHECK: define void @_Z1fSaIcESaIiE
+void f(std::allocator<char>, std::allocator<int>) { }
+
+namespace std {
+ template<typename, typename, typename> struct basic_string { };
+}
+
+// CHECK: define void @_Z1fSbIcciE
+void f(std::basic_string<char, char, int>) { }
+
+namespace std {
+ template<typename> struct char_traits { };
+
+ typedef std::basic_string<char, std::char_traits<char>, std::allocator<char> > string;
+}
+
+// CHECK: _Z1fSs
+void f(std::string) { }
+
+namespace std {
+ template<typename, typename> struct basic_ios {
+ basic_ios(int);
+ virtual ~basic_ios();
+ };
+ template<typename charT, typename traits = char_traits<charT> >
+ struct basic_istream : virtual public basic_ios<charT, traits> {
+ basic_istream(int x) : basic_ios<charT, traits>(x), stored(x) { }
+
+ int stored;
+ };
+ template<typename charT, typename traits = char_traits<charT> >
+ struct basic_ostream : virtual public basic_ios<charT, traits> {
+ basic_ostream(int x) : basic_ios<charT, traits>(x), stored(x) { }
+
+ float stored;
+ };
+
+ template<typename charT, typename traits = char_traits<charT> >
+ struct basic_iostream : public basic_istream<charT, traits>,
+ public basic_ostream<charT, traits> {
+ basic_iostream(int x) : basic_istream<charT, traits>(x),
+ basic_ostream<charT, traits>(x),
+ basic_ios<charT, traits>(x) { }
+ };
+}
+
+// CHECK: _Z1fSi
+void f(std::basic_istream<char, std::char_traits<char> >) { }
+
+// CHECK: _Z1fSo
+void f(std::basic_ostream<char, std::char_traits<char> >) { }
+
+// CHECK: _Z1fSd
+void f(std::basic_iostream<char, std::char_traits<char> >) { }
+
+extern "C++" {
+namespace std
+{
+ typedef void (*terminate_handler) ();
+
+ // CHECK: _ZSt13set_terminatePFvvE
+ terminate_handler set_terminate(terminate_handler) { return 0; }
+}
+}
+
+// Make sure we don't treat the following like std::string
+// CHECK: define void @_Z1f12basic_stringIcSt11char_traitsIcESaIcEE
+template<typename, typename, typename> struct basic_string { };
+typedef basic_string<char, std::char_traits<char>, std::allocator<char> > not_string;
+void f(not_string) { }
+
+// Manglings for instantiations caused by this function are at the
+// top of the test.
+void create_streams() {
+ std::basic_iostream<char> bio(17);
+}
+
+// Make sure we don't mangle 'std' as 'St' here.
+namespace N {
+ namespace std {
+ struct A { void f(); };
+
+ // CHECK: define void @_ZN1N3std1A1fEv
+ void A::f() { }
+ }
+}
diff --git a/clang/test/CodeGenCXX/mangle-subst.cpp b/clang/test/CodeGenCXX/mangle-subst.cpp
new file mode 100644
index 0000000..d83a081
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-subst.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+
+struct X {};
+
+// CHECK: define void @_Z1f1XS_(
+void f(X, X) { }
+
+// CHECK: define void @_Z1fR1XS0_(
+void f(X&, X&) { }
+
+// CHECK: define void @_Z1fRK1XS1_(
+void f(const X&, const X&) { }
+
+typedef void T();
+struct S {};
+
+// CHECK: define void @_Z1fPFvvEM1SFvvE(
+void f(T*, T (S::*)) {}
+
+namespace A {
+ struct A { };
+ struct B { };
+};
+
+// CHECK: define void @_Z1fN1A1AENS_1BE(
+void f(A::A a, A::B b) { }
+
+struct C {
+ struct D { };
+};
+
+// CHECK: define void @_Z1fN1C1DERS_PS_S1_(
+void f(C::D, C&, C*, C&) { }
+
+template<typename T>
+struct V {
+ typedef int U;
+};
+
+template <typename T> void f1(typename V<T>::U, V<T>) { }
+
+// CHECK: @_Z2f1IiEvN1VIT_E1UES2_
+template void f1<int>(int, V<int>);
+
+template <typename T> void f2(V<T>, typename V<T>::U) { }
+
+// CHECK: @_Z2f2IiEv1VIT_ENS2_1UE
+template void f2<int>(V<int>, int);
+
+namespace NS {
+template <typename T> struct S1 {};
+template<typename T> void ft3(S1<T>, S1<char>) { }
+
+// CHECK: @_ZN2NS3ft3IiEEvNS_2S1IT_EENS1_IcEE
+template void ft3<int>(S1<int>, S1<char>);
+}
+
+// PR5196
+// CHECK: @_Z1fPKcS0_
+void f(const char*, const char*) {}
+
+namespace NS {
+ class C;
+}
+
+namespace NS {
+ // CHECK: @_ZN2NS1fERNS_1CE
+ void f(C&) { }
+}
+
+namespace Test1 {
+
+struct A { };
+struct B { };
+
+// CHECK: @_ZN5Test11fEMNS_1BEFvvENS_1AES3_
+void f(void (B::*)(), A, A) { }
+
+// CHECK: @_ZN5Test11fEMNS_1BEFvvENS_1AES3_MS0_FvS3_EMS3_FvvE
+void f(void (B::*)(), A, A, void (B::*)(A), void (A::*)()) { }
+
+}
diff --git a/clang/test/CodeGenCXX/mangle-system-header.cpp b/clang/test/CodeGenCXX/mangle-system-header.cpp
new file mode 100644
index 0000000..6716b58
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-system-header.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+
+// PR5420
+
+# 1 "fake_system_header.h" 1 3 4
+// CHECK: define void @_ZdlPvS_(
+void operator delete (void*, void*) {}
+
+// PR6217
+// CHECK: define void @_Z3barv()
+void bar() { }
diff --git a/clang/test/CodeGenCXX/mangle-template.cpp b/clang/test/CodeGenCXX/mangle-template.cpp
new file mode 100644
index 0000000..05c3a58
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-template.cpp
@@ -0,0 +1,172 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+namespace test1 {
+int x;
+template <int& D> class T { };
+// CHECK: void @_ZN5test12f0ENS_1TILZNS_1xEEEE(
+void f0(T<x> a0) {}
+}
+
+namespace test1 {
+// CHECK: void @_ZN5test12f0Ef
+void f0(float) {}
+template<void (&)(float)> struct t1 {};
+// CHECK: void @_ZN5test12f1ENS_2t1ILZNS_2f0EfEEE(
+void f1(t1<f0> a0) {}
+}
+
+namespace test2 {
+// CHECK: void @_ZN5test22f0Ef
+void f0(float) {}
+template<void (*)(float)> struct t1 {};
+// FIXME: Fails because we don't treat as an expression.
+// CHECK-FIXME: void @_ZN5test22f1ENS_2t1IXadL_ZNS_2f0EfEEEE(
+void f1(t1<f0> a0) {}
+}
+
+namespace test3 {
+// CHECK: void @test3_f0
+extern "C" void test3_f0(float) {}
+template<void (&)(float)> struct t1 {};
+// FIXME: Fails because we tack on a namespace.
+// CHECK-FIXME: void @_ZN5test32f1ENS_2t1ILZ8test3_f0EEE(
+void f1(t1<test3_f0> a0) {}
+}
+
+namespace test4 {
+// CHECK: void @test4_f0
+extern "C" void test4_f0(float) {}
+template<void (*)(float)> struct t1 {};
+// FIXME: Fails because we don't treat as an expression.
+// CHECK-FIXME: void @_ZN5test42f1ENS_2t1IXadL_Z8test4_f0EEEE(
+void f1(t1<test4_f0> a0) {}
+}
+
+// CHECK: void @test5_f0
+extern "C" void test5_f0(float) {}
+int main(int) {}
+
+namespace test5 {
+template<void (&)(float)> struct t1 {};
+// CHECK: void @_ZN5test52f1ENS_2t1ILZ8test5_f0EEE(
+void f1(t1<test5_f0> a0) {}
+
+template<int (&)(int)> struct t2 {};
+// CHECK: void @_ZN5test52f2ENS_2t2ILZ4mainEEE
+void f2(t2<main> a0) {}
+}
+
+// FIXME: This fails.
+namespace test6 {
+struct A { void im0(float); };
+// CHECK: void @_ZN5test61A3im0Ef
+void A::im0(float) {}
+template <void(A::*)(float)> class T { };
+// FIXME: Fails because we don't treat as an expression.
+// CHECK-FAIL: void @_ZN5test62f0ENS_1TIXadL_ZNS_1A3im0EfEEEE(
+void f0(T<&A::im0> a0) {}
+}
+
+namespace test7 {
+ template<typename T>
+ struct meta {
+ static const unsigned value = sizeof(T);
+ };
+
+ template<unsigned> struct int_c {
+ typedef float type;
+ };
+
+ template<typename T>
+ struct X {
+ template<typename U>
+ X(U*, typename int_c<(meta<T>::value + meta<U>::value)>::type *) { }
+ };
+
+ // CHECK: define weak_odr {{.*}} @_ZN5test71XIiEC1IdEEPT_PNS_5int_cIXplL_ZNS_4metaIiE5valueEEsr4metaIS3_EE5valueEE4typeE(%"struct.test7::X"* %this, double*, float*) unnamed_addr
+ template X<int>::X(double*, float*);
+}
+
+namespace test8 {
+ template<typename T>
+ struct meta {
+ struct type {
+ static const unsigned value = sizeof(T);
+ };
+ };
+
+ template<unsigned> struct int_c {
+ typedef float type;
+ };
+
+ template<typename T>
+ void f(int_c<meta<T>::type::value>) { }
+
+ // CHECK: define weak_odr void @_ZN5test81fIiEEvNS_5int_cIXsr4metaIT_E4typeE5valueEEE
+ template void f<int>(int_c<sizeof(int)>);
+}
+
+namespace test9 {
+ template<typename T>
+ struct supermeta {
+ template<typename U>
+ struct apply {
+ typedef T U::*type;
+ };
+ };
+
+ struct X { };
+
+ template<typename T, typename U>
+ typename supermeta<T>::template apply<U>::type f();
+
+ void test_f() {
+ // CHECK: @_ZN5test91fIiNS_1XEEENS_9supermetaIT_E5applyIT0_E4typeEv()
+ // Note: GCC incorrectly mangles this as
+ // _ZN5test91fIiNS_1XEEENS_9supermetaIT_E5apply4typeEv, while EDG
+ // gets it right.
+ f<int, X>();
+ }
+}
+
+namespace test10 {
+ template<typename T>
+ struct X {
+ template<typename U>
+ struct definition {
+ };
+ };
+
+ // CHECK: _ZN6test101fIidEENS_1XIT_E10definitionIT0_EES2_S5_
+ template<typename T, typename U>
+ typename X<T>::template definition<U> f(T, U) { }
+
+ void g(int i, double d) {
+ f(i, d);
+ }
+}
+
+// Report from Jason Merrill on cxx-abi-dev, 2012.01.04.
+namespace test11 {
+ int cmp(char a, char b);
+ template <typename T, int (*cmp)(T, T)> struct A {};
+ template <typename T> void f(A<T,cmp> &) {}
+ template void f<char>(A<char,cmp> &);
+ // CHECK: @_ZN6test111fIcEEvRNS_1AIT_L_ZNS_3cmpEccEEE(
+}
+
+namespace test12 {
+ // Make sure we can mangle non-type template args with internal linkage.
+ static int f();
+ const int n = 10;
+ template<typename T, T v> void test() {}
+ void use() {
+ // CHECK: define internal void @_ZN6test124testIFivEXadL_ZNS_L1fEvEEEEvv(
+ test<int(), &f>();
+ // CHECK: define internal void @_ZN6test124testIRFivEXadL_ZNS_L1fEvEEEEvv(
+ test<int(&)(), f>();
+ // CHECK: define internal void @_ZN6test124testIPKiXadL_ZNS_L1nEEEEEvv(
+ test<const int*, &n>();
+ // CHECK: define internal void @_ZN6test124testIRKiXadL_ZNS_L1nEEEEEvv(
+ test<const int&, n>();
+ }
+}
diff --git a/clang/test/CodeGenCXX/mangle-this-cxx11.cpp b/clang/test/CodeGenCXX/mangle-this-cxx11.cpp
new file mode 100644
index 0000000..f9e9479
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-this-cxx11.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+
+struct B {
+ template <class U> U f();
+};
+
+struct A {
+ B b;
+ // implicitly rewritten to (*this).b.f<U>()
+ template <class U> auto f() -> decltype (b.f<U>());
+ template <class U> auto g() -> decltype (this->b.f<U>());
+};
+
+int main() {
+ A a;
+ // CHECK: call i32 @_ZN1A1fIiEEDTcldtdtdefpT1b1fIT_EEEv
+ a.f<int>();
+ // CHECK: call i32 @_ZN1A1gIiEEDTcldtptfpT1b1fIT_EEEv
+ a.g<int>();
+}
diff --git a/clang/test/CodeGenCXX/mangle-unnameable-conversions.cpp b/clang/test/CodeGenCXX/mangle-unnameable-conversions.cpp
new file mode 100644
index 0000000..2ecded0
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-unnameable-conversions.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+
+template<typename T> using id = T;
+struct S {
+ template<typename T, int N>
+ operator id<T[N]>&();
+ template<typename T, typename U>
+ operator id<T (U::*)()>() const;
+};
+
+void f() {
+ int (&a)[42] = S(); // CHECK: @_ZN1ScvRAT0__T_IiLi42EEEv(
+ char (S::*fp)() = S(); // CHECK: @_ZNK1ScvMT0_FT_vEIcS_EEv(
+};
diff --git a/clang/test/CodeGenCXX/mangle-unnamed.cpp b/clang/test/CodeGenCXX/mangle-unnamed.cpp
new file mode 100644
index 0000000..53f381c
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-unnamed.cpp
@@ -0,0 +1,92 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 | FileCheck %s
+
+struct S {
+ virtual ~S() { }
+};
+
+// PR5706
+// Make sure this doesn't crash; the mangling doesn't matter because the name
+// doesn't have linkage.
+static struct : S { } obj8;
+
+void f() {
+ // Make sure this doesn't crash; the mangling doesn't matter because the
+ // generated vtable/etc. aren't modifiable (although it would be nice for
+ // codesize to make it consistent inside inline functions).
+ static struct : S { } obj8;
+}
+
+inline int f2() {
+ // FIXME: We don't mangle the names of a or x correctly!
+ static struct { int a() { static int x; return ++x; } } obj;
+ return obj.a();
+}
+
+int f3() { return f2(); }
+
+struct A {
+ typedef struct { int x; } *ptr;
+ ptr m;
+ int a() {
+ static struct x {
+ // FIXME: We don't mangle the names of a or x correctly!
+ int a(ptr A::*memp) { static int x; return ++x; }
+ } a;
+ return a.a(&A::m);
+ }
+};
+
+int f4() { return A().a(); }
+
+int f5() {
+ static union {
+ int a;
+ };
+
+ // CHECK: _ZZ2f5vE1a
+ return a;
+}
+
+int f6() {
+ static union {
+ union {
+ int : 1;
+ };
+ int b;
+ };
+
+ // CHECK: _ZZ2f6vE1b
+ return b;
+}
+
+int f7() {
+ static union {
+ union {
+ int b;
+ } a;
+ };
+
+ // CHECK: _ZZ2f7vE1a
+ return a.b;
+}
+
+// This used to cause an assert because the typedef-for-anonymous-tag
+// code was trying to claim the enum for the template.
+enum { T8 };
+template <class T> struct Test8 {
+ typedef T type;
+ Test8(type t) {} // tested later
+};
+template <class T> void make_test8(T value) { Test8<T> t(value); }
+void test8() { make_test8(T8); }
+
+// CHECK: define internal void @"_ZNV3$_35test9Ev"(
+typedef volatile struct {
+ void test9() volatile {}
+} Test9;
+void test9() {
+ Test9 a;
+ a.test9();
+}
+
+// CHECK: define internal void @"_ZN5Test8I3$_2EC1ES0_"(
diff --git a/clang/test/CodeGenCXX/mangle-variadic-templates.cpp b/clang/test/CodeGenCXX/mangle-variadic-templates.cpp
new file mode 100644
index 0000000..b5bdae2
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-variadic-templates.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -triple=x86_64-apple-darwin9 -o - %s | FileCheck %s
+
+template<unsigned I, typename ...Types>
+struct X { };
+
+template<typename T> struct identity { };
+template<typename T> struct add_reference;
+template<typename ...Types> struct tuple { };
+template<int ...Values> struct int_tuple { };
+template<template<typename> class ...Templates> struct template_tuple { };
+
+// CHECK: define weak_odr void @_Z2f0IJEEv1XIXsZT_EJDpRT_EE
+template<typename ...Types>
+void f0(X<sizeof...(Types), Types&...>) { }
+
+template void f0(X<0>);
+
+// CHECK: define weak_odr void @_Z2f0IJifdEEv1XIXsZT_EJDpRT_EE
+template void f0<int, float, double>(X<3, int&, float&, double&>);
+
+// Mangling for template argument packs
+template<typename ...Types> void f1() {}
+// CHECK: define weak_odr void @_Z2f1IJEEvv
+template void f1<>();
+// CHECK: define weak_odr void @_Z2f1IJiEEvv
+template void f1<int>();
+// CHECK: define weak_odr void @_Z2f1IJifEEvv
+template void f1<int, float>();
+
+// Mangling function parameter packs
+template<typename ...Types> void f2(Types...) {}
+// CHECK: define weak_odr void @_Z2f2IJEEvDpT_
+template void f2<>();
+// CHECK: define weak_odr void @_Z2f2IJiEEvDpT_
+template void f2<int>(int);
+// CHECK: define weak_odr void @_Z2f2IJifEEvDpT_
+template void f2<int, float>(int, float);
+
+// Mangling non-trivial function parameter packs
+template<typename ...Types> void f3(const Types *...) {}
+// CHECK: define weak_odr void @_Z2f3IJEEvDpPKT_
+template void f3<>();
+// CHECK: define weak_odr void @_Z2f3IJiEEvDpPKT_
+template void f3<int>(const int*);
+// CHECK: define weak_odr void @_Z2f3IJifEEvDpPKT_
+template void f3<int, float>(const int*, const float*);
+
+// Mangling of type pack expansions in a template argument
+template<typename ...Types> tuple<Types...> f4() {}
+// CHECK: define weak_odr void @_Z2f4IJifdEE5tupleIJDpT_EEv
+template tuple<int, float, double> f4();
+
+// Mangling of type pack expansions in a function type
+template<typename R, typename ...ArgTypes> identity<R(ArgTypes...)> f5() {}
+// CHECK: define weak_odr void @_Z2f5IiJifdEE8identityIFT_DpT0_EEv
+template identity<int(int, float, double)> f5();
+
+// Mangling of non-type template argument expansions
+template<int ...Values> int_tuple<Values...> f6() {}
+// CHECK: define weak_odr void @_Z2f6IJLi1ELi2ELi3EEE9int_tupleIJXspT_EEEv
+template int_tuple<1, 2, 3> f6();
+
+// Mangling of template template argument expansions
+template<template<typename> class ...Templates>
+template_tuple<Templates...> f7() {}
+// CHECK: define weak_odr void @_Z2f7IJ8identity13add_referenceEE14template_tupleIJDpT_EEv
+template template_tuple<identity, add_reference> f7();
diff --git a/clang/test/CodeGenCXX/mangle.cpp b/clang/test/CodeGenCXX/mangle.cpp
new file mode 100644
index 0000000..ba1b3bf
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle.cpp
@@ -0,0 +1,854 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -fblocks -std=c++11 | FileCheck %s
+struct X { };
+struct Y { };
+
+// CHECK: @unmangled_variable = global
+// CHECK: @_ZN1N1iE = global
+// CHECK: @_ZZN1N1fEiiE1b = internal global
+// CHECK: @_ZZN1N1gEvE1a = internal global
+// CHECK: @_ZGVZN1N1gEvE1a = internal global
+
+//CHECK: @pr5966_i = external global
+//CHECK: @_ZL8pr5966_i = internal global
+
+// CHECK: define zeroext i1 @_ZplRK1YRA100_P1X
+bool operator+(const Y&, X* (&xs)[100]) { return false; }
+
+// CHECK: define void @_Z1f1s
+typedef struct { int a; } s;
+void f(s) { }
+
+// CHECK: define void @_Z1f1e
+typedef enum { foo } e;
+void f(e) { }
+
+// CHECK: define void @_Z1f1u
+typedef union { int a; } u;
+void f(u) { }
+
+// CHECK: define void @_Z1f1x
+typedef struct { int a; } x,y;
+void f(y) { }
+
+// CHECK: define void @_Z1fv
+void f() { }
+
+// CHECK: define void @_ZN1N1fEv
+namespace N { void f() { } }
+
+// CHECK: define void @_ZN1N1N1fEv
+namespace N { namespace N { void f() { } } }
+
+// CHECK: define void @unmangled_function
+extern "C" { namespace N { void unmangled_function() { } } }
+
+extern "C" { namespace N { int unmangled_variable = 10; } }
+
+namespace N { int i; }
+
+namespace N { int f(int, int) { static int b; return b; } }
+
+namespace N { int h(); void g() { static int a = h(); } }
+
+// CHECK: define void @_Z1fno
+void f(__int128_t, __uint128_t) { }
+
+template <typename T> struct S1 {};
+
+// CHECK: define void @_Z1f2S1IiE
+void f(S1<int>) {}
+
+// CHECK: define void @_Z1f2S1IdE
+void f(S1<double>) {}
+
+template <int N> struct S2 {};
+// CHECK: define void @_Z1f2S2ILi100EE
+void f(S2<100>) {}
+
+// CHECK: define void @_Z1f2S2ILin100EE
+void f(S2<-100>) {}
+
+template <bool B> struct S3 {};
+
+// CHECK: define void @_Z1f2S3ILb1EE
+void f(S3<true>) {}
+
+// CHECK: define void @_Z1f2S3ILb0EE
+void f(S3<false>) {}
+
+struct S;
+
+// CHECK: define void @_Z1fM1SKFvvE
+void f(void (S::*)() const) {}
+
+// CHECK: define void @_Z1fM1SFvvE
+void f(void (S::*)()) {}
+
+// CHECK: define void @_Z1fi
+void f(const int) { }
+
+template<typename T, typename U> void ft1(U u, T t) { }
+
+template<typename T> void ft2(T t, void (*)(T), void (*)(T)) { }
+
+template<typename T, typename U = S1<T> > struct S4 { };
+template<typename T> void ft3(S4<T>*) { }
+
+namespace NS {
+ template<typename T> void ft1(T) { }
+}
+
+void g1() {
+ // CHECK: @_Z3ft1IidEvT0_T_
+ ft1<int, double>(1, 0);
+
+ // CHECK: @_Z3ft2IcEvT_PFvS0_ES2_
+ ft2<char>(1, 0, 0);
+
+ // CHECK: @_Z3ft3IiEvP2S4IT_2S1IS1_EE
+ ft3<int>(0);
+
+ // CHECK: @_ZN2NS3ft1IiEEvT_
+ NS::ft1<int>(1);
+}
+
+// Expressions
+template<int I> struct S5 { };
+
+template<int I> void ft4(S5<I>) { }
+void g2() {
+ // CHECK: @_Z3ft4ILi10EEv2S5IXT_EE
+ ft4(S5<10>());
+
+ // CHECK: @_Z3ft4ILi20EEv2S5IXT_EE
+ ft4(S5<20>());
+}
+
+extern "C++" {
+ // CHECK: @_Z1hv
+ void h() { }
+}
+
+// PR5019
+extern "C" { struct a { int b; }; }
+
+// CHECK: @_Z1fP1a
+int f(struct a *x) {
+ return x->b;
+}
+
+// PR5017
+extern "C" {
+struct Debug {
+ const Debug& operator<< (unsigned a) const { return *this; }
+};
+Debug dbg;
+// CHECK: @_ZNK5DebuglsEj
+int main(void) { dbg << 32 ;}
+}
+
+template<typename T> struct S6 {
+ typedef int B;
+};
+
+template<typename T> void ft5(typename S6<T>::B) { }
+// CHECK: @_Z3ft5IiEvN2S6IT_E1BE
+template void ft5<int>(int);
+
+template<typename T> class A {};
+
+namespace NS {
+template<typename T> bool operator==(const A<T>&, const A<T>&) { return true; }
+}
+
+// CHECK: @_ZN2NSeqIcEEbRK1AIT_ES5_
+template bool NS::operator==(const ::A<char>&, const ::A<char>&);
+
+namespace std {
+template<typename T> bool operator==(const A<T>&, const A<T>&) { return true; }
+}
+
+// CHECK: @_ZSteqIcEbRK1AIT_ES4_
+template bool std::operator==(const ::A<char>&, const ::A<char>&);
+
+struct S {
+ typedef int U;
+};
+
+template <typename T> typename T::U ft6(const T&) { return 0; }
+
+// CHECK: @_Z3ft6I1SENT_1UERKS1_
+template int ft6<S>(const S&);
+
+template<typename> struct __is_scalar_type {
+ enum { __value = 1 };
+};
+
+template<bool, typename> struct __enable_if { };
+
+template<typename T> struct __enable_if<true, T> {
+ typedef T __type;
+};
+
+// PR5063
+template<typename T> typename __enable_if<__is_scalar_type<T>::__value, void>::__type ft7() { }
+
+// CHECK: @_Z3ft7IiEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv
+template void ft7<int>();
+// CHECK: @_Z3ft7IPvEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv
+template void ft7<void*>();
+
+// PR5144
+extern "C" {
+void extern_f(void);
+};
+
+// CHECK: @extern_f
+void extern_f(void) { }
+
+struct S7 {
+ S7();
+
+ struct S { S(); };
+ struct {
+ S s;
+ } a;
+};
+
+// PR5139
+// CHECK: @_ZN2S7C1Ev
+// CHECK: @_ZN2S7C2Ev
+// CHECK: @"_ZN2S73$_0C1Ev"
+S7::S7() {}
+
+// PR5063
+template<typename T> typename __enable_if<(__is_scalar_type<T>::__value), void>::__type ft8() { }
+// CHECK: @_Z3ft8IiEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv
+template void ft8<int>();
+// CHECK: @_Z3ft8IPvEN11__enable_ifIXsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv
+template void ft8<void*>();
+
+// PR5796
+namespace PR5796 {
+template<typename> struct __is_scalar_type {
+ enum { __value = 0 };
+};
+
+template<bool, typename> struct __enable_if {};
+template<typename T> struct __enable_if<true, T> { typedef T __type; };
+template<typename T>
+
+// CHECK: define linkonce_odr void @_ZN6PR57968__fill_aIiEENS_11__enable_ifIXntsr16__is_scalar_typeIT_EE7__valueEvE6__typeEv
+typename __enable_if<!__is_scalar_type<T>::__value, void>::__type __fill_a() { };
+
+void f() { __fill_a<int>(); }
+}
+
+namespace Expressions {
+// Unary operators.
+
+// CHECK: define weak_odr void @_ZN11Expressions2f1ILi1EEEvPAplngT_Li2E_i
+template <int i> void f1(int (*)[(-i) + 2]) { };
+template void f1<1>(int (*)[1]);
+
+// CHECK: define weak_odr void @_ZN11Expressions2f2ILi1EEEvPApsT__i
+template <int i> void f2(int (*)[+i]) { };
+template void f2<1>(int (*)[1]);
+
+// Binary operators.
+
+// CHECK: define weak_odr void @_ZN11Expressions2f3ILi1EEEvPAplT_T__i
+template <int i> void f3(int (*)[i+i]) { };
+template void f3<1>(int (*)[2]);
+
+// CHECK: define weak_odr void @_ZN11Expressions2f4ILi1EEEvPAplplLi2ET_T__i
+template <int i> void f4(int (*)[2 + i+i]) { };
+template void f4<1>(int (*)[4]);
+
+// The ternary operator.
+// CHECK: define weak_odr void @_ZN11Expressions2f4ILb1EEEvPAquT_Li1ELi2E_i
+template <bool b> void f4(int (*)[b ? 1 : 2]) { };
+template void f4<true>(int (*)[1]);
+}
+
+struct Ops {
+ Ops& operator+(const Ops&);
+ Ops& operator-(const Ops&);
+ Ops& operator&(const Ops&);
+ Ops& operator*(const Ops&);
+
+ void *v;
+};
+
+// CHECK: define %struct.Ops* @_ZN3OpsplERKS_
+Ops& Ops::operator+(const Ops&) { return *this; }
+// CHECK: define %struct.Ops* @_ZN3OpsmiERKS_
+Ops& Ops::operator-(const Ops&) { return *this; }
+// CHECK: define %struct.Ops* @_ZN3OpsanERKS_
+Ops& Ops::operator&(const Ops&) { return *this; }
+// CHECK: define %struct.Ops* @_ZN3OpsmlERKS_
+Ops& Ops::operator*(const Ops&) { return *this; }
+
+// PR5861
+namespace PR5861 {
+template<bool> class P;
+template<> class P<true> {};
+
+template<template <bool> class, bool>
+struct Policy { };
+
+template<typename T, typename = Policy<P, true> > class Alloc
+{
+ T *allocate(int, const void*) { return 0; }
+};
+
+// CHECK: define weak_odr i8* @_ZN6PR58615AllocIcNS_6PolicyINS_1PELb1EEEE8allocateEiPKv
+template class Alloc<char>;
+}
+
+// CHECK: define void @_Z1fU13block_pointerFiiiE
+void f(int (^)(int, int)) { }
+
+void pr5966_foo() {
+ extern int pr5966_i;
+ pr5966_i = 0;
+}
+
+static int pr5966_i;
+
+void pr5966_bar() {
+ pr5966_i = 0;
+}
+
+namespace test0 {
+ int ovl(int x);
+ char ovl(double x);
+
+ template <class T> void f(T, char (&buffer)[sizeof(ovl(T()))]) {}
+
+ void test0() {
+ char buffer[1];
+ f(0.0, buffer);
+ }
+ // CHECK: define void @_ZN5test05test0Ev()
+ // CHECK: define linkonce_odr void @_ZN5test01fIdEEvT_RAszcl3ovlcvS1__EE_c(
+
+ void test1() {
+ char buffer[sizeof(int)];
+ f(1, buffer);
+ }
+ // CHECK: define void @_ZN5test05test1Ev()
+ // CHECK: define linkonce_odr void @_ZN5test01fIiEEvT_RAszcl3ovlcvS1__EE_c(
+
+ template <class T> void g(char (&buffer)[sizeof(T() + 5.0f)]) {}
+ void test2() {
+ char buffer[sizeof(float)];
+ g<float>(buffer);
+ }
+ // CHECK: define linkonce_odr void @_ZN5test01gIfEEvRAszplcvT__ELf40a00000E_c(
+
+ template <class T> void h(char (&buffer)[sizeof(T() + 5.0)]) {}
+ void test3() {
+ char buffer[sizeof(double)];
+ h<float>(buffer);
+ }
+ // CHECK: define linkonce_odr void @_ZN5test01hIfEEvRAszplcvT__ELd4014000000000000E_c(
+
+ template <class T> void j(char (&buffer)[sizeof(T().buffer)]) {}
+ struct A { double buffer[128]; };
+ void test4() {
+ char buffer[1024];
+ j<A>(buffer);
+ }
+ // CHECK: define linkonce_odr void @_ZN5test01jINS_1AEEEvRAszdtcvT__E6buffer_c(
+
+ template <class T> void k(char (&buffer)[sizeof(T() + 0.0f)]) {}
+ void test5() {
+ char buffer[sizeof(float)];
+ k<float>(buffer);
+ }
+ // CHECK: define linkonce_odr void @_ZN5test01kIfEEvRAszplcvT__ELf00000000E_c(
+
+}
+
+namespace test1 {
+ template<typename T> struct X { };
+ template<template<class> class Y, typename T> void f(Y<T>) { }
+ // CHECK: define weak_odr void @_ZN5test11fINS_1XEiEEvT_IT0_E
+ template void f(X<int>);
+}
+
+// CHECK: define internal void @_ZL27functionWithInternalLinkagev()
+static void functionWithInternalLinkage() { }
+void g() { functionWithInternalLinkage(); }
+
+namespace test2 {
+ template <class T> decltype(((T*) 0)->member) read_member(T& obj) {
+ return obj.member;
+ }
+
+ struct A { int member; } obj;
+ int test() {
+ return read_member(obj);
+ }
+
+ // CHECK: define linkonce_odr i32 @_ZN5test211read_memberINS_1AEEEDtptcvPT_Li0E6memberERS2_(
+}
+
+// rdar://problem/9280586
+namespace test3 {
+ struct AmbiguousBase { int ab; };
+ struct Path1 : AmbiguousBase { float p; };
+ struct Path2 : AmbiguousBase { double p; };
+ struct Derived : Path1, Path2 { };
+
+ // CHECK: define linkonce_odr i32 @_ZN5test38get_ab_1INS_7DerivedEEEDtptcvPT_Li0Esr5Path1E2abERS2_(
+ template <class T> decltype(((T*) 0)->Path1::ab) get_ab_1(T &ref) { return ref.Path1::ab; }
+
+ // CHECK: define linkonce_odr i32 @_ZN5test38get_ab_2INS_7DerivedEEEDtptcvPT_Li0Esr5Path2E2abERS2_(
+ template <class T> decltype(((T*) 0)->Path2::ab) get_ab_2(T &ref) { return ref.Path2::ab; }
+
+ // CHECK: define linkonce_odr float @_ZN5test37get_p_1INS_7DerivedEEEDtptcvPT_Li0Esr5Path1E1pERS2_(
+ template <class T> decltype(((T*) 0)->Path1::p) get_p_1(T &ref) { return ref.Path1::p; }
+
+ // CHECK: define linkonce_odr double @_ZN5test37get_p_2INS_7DerivedEEEDtptcvPT_Li0Esr5Path2E1pERS2_(
+ template <class T> decltype(((T*) 0)->Path2::p) get_p_2(T &ref) { return ref.Path2::p; }
+
+ Derived obj;
+ void test() {
+ get_ab_1(obj);
+ get_ab_2(obj);
+ get_p_1(obj);
+ get_p_2(obj);
+ }
+}
+
+// CHECK: define void @_ZN5test41gEPNS_3zedIXadL_ZNS_3foo3barEEEEE
+namespace test4 {
+ struct foo { int bar; };
+ template <int (foo::*)>
+ struct zed {};
+ void g(zed<&foo::bar>*)
+ {}
+}
+// CHECK: define void @_ZN5test51gEPNS_3zedIXadL_ZNS_3foo3barEEEEE
+namespace test5 {
+ struct foo { static int bar; };
+ template <int *>
+ struct zed {};
+ void g(zed<&foo::bar>*)
+ {}
+}
+// CHECK: define void @_ZN5test61gEPNS_3zedIXadL_ZNS_3foo3barEvEEEE
+namespace test6 {
+ struct foo { int bar(); };
+ template <int (foo::*)()>
+ struct zed {};
+ void g(zed<&foo::bar>*)
+ {}
+}
+// CHECK: define void @_ZN5test71gEPNS_3zedIXadL_ZNS_3foo3barEvEEEE
+namespace test7 {
+ struct foo { static int bar(); };
+ template <int (*f)()>
+ struct zed {};
+ void g(zed<&foo::bar>*)
+ {}
+}
+// CHECK: define weak_odr void @_ZN5test81AILZNS_1B5valueEEE3incEv
+namespace test8 {
+ template <int &counter> class A { void inc() { counter++; } };
+ class B { public: static int value; };
+ template class A<B::value>;
+}
+// CHECK: declare void @_ZN5test91fIiNS_3barEEEvRKNT0_3baz1XE
+namespace test9 {
+ template<class T>
+ struct foo {
+ typedef T X;
+ };
+ struct bar {
+ typedef foo<int> baz;
+ };
+ template <class zaz, class zed>
+ void f(const typename zed::baz::X&);
+ void g() {
+ f<int, bar>( 0);
+ }
+}
+
+// <rdar://problem/7825453>
+namespace test10 {
+ template <char P1> struct S {};
+ template <char P2> void f(struct S<false ? 'a' : P2> ) {}
+
+ // CHECK: define weak_odr void @_ZN6test101fILc3EEEvNS_1SIXquLb0ELc97ET_EEE(
+ template void f<(char) 3>(struct S<3>);
+}
+
+namespace test11 {
+ // CHECK: @_ZN6test111fEz
+ void f(...) { }
+
+ struct A {
+ void f(...);
+ };
+
+ // CHECK: @_ZN6test111A1fEz
+ void A::f(...) { }
+}
+
+namespace test12 {
+
+ // CHECK: _ZN6test121fENS_1AILt33000EEE
+ template <unsigned short> struct A { };
+ void f(A<33000>) { }
+}
+
+// PR7446
+namespace test13 {
+ template <template <class> class T> class A {};
+ template <class U> class B {};
+
+ template <template<class> class T> void foo(const A<T> &a) {}
+
+ // CHECK: define weak_odr void @_ZN6test133fooINS_1BEEEvRKNS_1AIT_EE(
+ template void foo(const A<B> &a);
+}
+
+namespace test14 {
+ extern "C" {
+ struct S {
+ static int a(), x;
+ };
+ // CHECK: define i32 @_ZN6test141S1aEv
+ // CHECK: load i32* @_ZN6test141S1xE
+ int S::a() { return S::x; }
+ }
+}
+
+// rdar://problem/8204122
+namespace test15 {
+ enum E { e = 3 };
+ template <int I> struct S {};
+
+ template <int I> void f(S<I + e>) {}
+
+ // CHECK: define weak_odr void @_ZN6test151fILi7EEEvNS_1SIXplT_LNS_1EE3EEEE(
+ template void f<7>(S<7 + e>);
+}
+
+// rdar://problem/8302148
+namespace test17 {
+ template <int N> struct A {};
+
+ struct B {
+ static int foo(void);
+ };
+
+ template <class T> A<sizeof(T::foo())> func(void);
+
+ // CHECK: define void @_ZN6test174testEv()
+ // CHECK: call {{.*}} @_ZN6test174funcINS_1BEEENS_1AIXszclsrT_3fooEEEEv()
+ void test() {
+ func<B>();
+ }
+}
+
+// PR7891
+namespace test18 {
+ struct A {
+ int operator+();
+ int operator-();
+ int operator*();
+ int operator&();
+ };
+ template <int (A::*)()> struct S {};
+
+ template <typename T> void f(S<&T::operator+>) {}
+ template void f<A>(S<&A::operator+>);
+
+ template <typename T> void f(S<&T::operator- >) {}
+ template void f<A>(S<&A::operator- >);
+
+ template <typename T> void f(S<&T::operator*>) {}
+ template void f<A>(S<&A::operator*>);
+
+ template <typename T> void f(S<&T::operator&>) {}
+ template void f<A>(S<&A::operator&>);
+
+ // CHECK: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_plEEE
+ // CHECK: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_miEEE
+ // CHECK: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_mlEEE
+ // CHECK: define weak_odr void @_ZN6test181fINS_1AEEEvNS_1SIXadsrT_anEEE
+}
+
+// rdar://problem/8332117
+namespace test19 {
+ struct A {
+ template <typename T> int f();
+ int operator+();
+ operator int();
+ template <typename T> int operator-();
+ };
+
+ template <int (A::*)()> struct S {};
+
+ template <typename T> void g (S<&T::template f<int> >) {}
+ template <typename T> void g (S<&T::operator+ >) {}
+ template <typename T> void g (S<&T::operator int>) {}
+ template <typename T> void g (S<&T::template operator- <double> >) {}
+
+ // CHECK: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_1fIiEEEE(
+ template void g<A>(S<&A::f<int> >);
+ // CHECK: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_plEEE(
+ template void g<A>(S<&A::operator+>);
+ // CHECK: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_cviEEE(
+ template void g<A>(S<&A::operator int>);
+ // CHECK: define weak_odr void @_ZN6test191gINS_1AEEEvNS_1SIXadsrT_miIdEEEE(
+ template void g<A>(S<&A::operator-<double> >);
+}
+
+namespace test20 {
+ template <class T> T *f(const T&);
+ template <class T> T *f(T*);
+
+ // CHECK: define weak_odr void @_ZN6test205test0IiEEvDTcl1fIPT_ELi0EEE(
+ template <class T> void test0(decltype(f<T*>(0))) {}
+ template void test0<int>(decltype(f<int*>(0)));
+
+ // CHECK: define weak_odr void @_ZN6test205test1IiEEvDTcl1fIEcvT__EEE(
+ template <class T> void test1(decltype(f<>(T()))) {}
+ template void test1<int>(decltype(f<>(int())));
+}
+
+// rdar:// 8620510
+namespace test21 {
+ // CHECK: define void @_ZN6test2112vla_arg_funcEiPA_i(
+ void vla_arg_func(int X, int a[X][X]) {}
+}
+
+namespace test22 {
+ // CHECK: define void @_ZN6test221fEDn(
+ void f(decltype(nullptr)) { }
+}
+
+// rdar://problem/8913416
+namespace test23 {
+ typedef void * const vpc;
+
+ // CHECK: define void @_ZN6test231fERA10_KPv(
+ void f(vpc (&)[10]) {}
+
+ typedef vpc vpca5[5];
+ void f(vpca5 volatile (&)[10]) {}
+ // CHECK: define void @_ZN6test231fERA10_A5_VKPv(
+}
+
+namespace test24 {
+ void test0() {
+ extern int foo();
+ // CHECK: call i32 @_ZN6test243fooEv()
+ foo();
+ }
+
+ static char foo() {}
+ void test1() {
+ // CHECK: call signext i8 @_ZN6test24L3fooEv()
+ foo();
+ }
+}
+
+// rdar://problem/8806641
+namespace test25 {
+ template <void (*fn)()> struct A {
+ static void call() { fn(); }
+ };
+ void foo();
+ void test() {
+ // CHECK: call void @_ZN6test251AIXadL_ZNS_3fooEvEEE4callEv()
+ A<foo>::call();
+ }
+}
+
+namespace test26 {
+ template <template <class> class T> void foo(decltype(T<float>::object) &object) {}
+
+ template <class T> struct holder { static T object; };
+
+ void test() {
+ float f;
+
+ // CHECK: call void @_ZN6test263fooINS_6holderEEEvRDtsrT_IfE6objectE(
+ foo<holder>(f);
+ }
+}
+
+namespace test27 {
+ struct A {
+ struct inner {
+ float object;
+ };
+
+ float meth();
+ };
+ typedef A Alias;
+
+ template <class T> void a(decltype(T::inner::object) &object) {}
+ template <class T> void b(decltype(T().Alias::meth()) &object) {}
+
+ void test() {
+ float f;
+ // CHECK: call void @_ZN6test271aINS_1AEEEvRDtsrNT_5innerE6objectE(
+ a<A>(f);
+ // CHECK: call void @_ZN6test271bINS_1AEEEvRDTcldtcvT__Esr5AliasE4methEE(
+ b<A>(f);
+ }
+}
+
+// An injected class name type in a unresolved-name.
+namespace test28 {
+ template <class T> struct A {
+ enum { bit };
+ };
+
+ template <class T> void foo(decltype(A<T>::A::bit) x);
+
+ void test() {
+ foo<char>(A<char>::bit);
+ // CHECK: call void @_ZN6test283fooIcEEvDtsr1AIT_E1AE3bitE(
+ }
+}
+
+// An enclosing template type parameter in an unresolved-name.
+namespace test29 {
+ template <class T> struct A {
+ template <class U> static void foo(decltype(T::fn(U())) x);
+ };
+ struct B { static int fn(int); static long fn(long); };
+
+ void test() {
+ A<B>::foo<int>(0);
+ // CHECK: call void @_ZN6test291AINS_1BEE3fooIiEEvDTclsrS1_2fncvT__EEE(
+ }
+}
+
+// An enclosing template template parameter in an unresolved-name.
+namespace test30 {
+ template <template <class> class T> struct A {
+ template <class U> static void foo(decltype(T<U>::fn()) x);
+ };
+ template <class T> struct B { static T fn(); };
+
+ void test() {
+ A<B>::foo<int>(0);
+ // CHECK: call void @_ZN6test301AINS_1BEE3fooIiEEvDTclsrS1_IT_EE2fnEE(
+ }
+}
+
+namespace test31 { // instantiation-dependent mangling of decltype
+ int x;
+ template<class T> auto f1(T p)->decltype(x) { return 0; }
+ // The return type in the mangling of the template signature
+ // is encoded as "i".
+ template<class T> auto f2(T p)->decltype(p) { return 0; }
+ // The return type in the mangling of the template signature
+ // is encoded as "Dtfp_E".
+ void g(int);
+ template<class T> auto f3(T p)->decltype(g(p)) {}
+
+ // CHECK: define weak_odr i32 @_ZN6test312f1IiEEiT_(
+ template int f1(int);
+ // CHECK: define weak_odr i32 @_ZN6test312f2IiEEDtfp_ET_
+ template int f2(int);
+ // CHECK: define weak_odr void @_ZN6test312f3IiEEDTcl1gfp_EET_
+ template void f3(int);
+}
+
+// PR10205
+namespace test32 {
+ template<typename T, int=T::value> struct A {
+ typedef int type;
+ };
+ struct B { enum { value = 4 }; };
+
+ template <class T> typename A<T>::type foo() { return 0; }
+ void test() {
+ foo<B>();
+ // CHECK: call i32 @_ZN6test323fooINS_1BEEENS_1AIT_XsrS3_5valueEE4typeEv()
+ }
+}
+
+namespace test33 {
+ template <class T> struct X {
+ enum { value = T::value };
+ };
+
+ template<typename T, int=X<T>::value> struct A {
+ typedef int type;
+ };
+ struct B { enum { value = 4 }; };
+
+ template <class T> typename A<T>::type foo() { return 0; }
+
+ void test() {
+ foo<B>();
+ // CHECK: call i32 @_ZN6test333fooINS_1BEEENS_1AIT_Xsr1XIS3_EE5valueEE4typeEv()
+ }
+}
+
+namespace test34 {
+ // Mangling for instantiation-dependent decltype expressions.
+ template<typename T>
+ void f(decltype(sizeof(decltype(T() + T())))) {}
+
+ // CHECK: define weak_odr void @_ZN6test341fIiEEvDTstDTplcvT__EcvS1__EEE
+ template void f<int>(decltype(sizeof(1)));
+
+ // Mangling for non-instantiation-dependent sizeof expressions.
+ template<unsigned N>
+ void f2(int (&)[N + sizeof(int*)]) {}
+
+ // CHECK: define weak_odr void @_ZN6test342f2ILj4EEEvRAplT_Lm8E_i
+ template void f2<4>(int (&)[4 + sizeof(int*)]);
+
+ // Mangling for non-instantiation-dependent sizeof expressions
+ // involving an implicit conversion of the result of the sizeof.
+ template<unsigned long long N>
+ void f3(int (&)[N + sizeof(int*)]) {}
+
+ // CHECK: define weak_odr void @_ZN6test342f3ILy4EEEvRAplT_Ly8E_i
+ template void f3<4>(int (&)[4 + sizeof(int*)]);
+
+ // Mangling for instantiation-dependent sizeof() expressions as
+ // template arguments.
+ template<unsigned> struct A { };
+
+ template<typename T> void f4(::test34::A<sizeof(sizeof(decltype(T() + T())))>) { }
+
+ // CHECK: define weak_odr void @_ZN6test342f4IiEEvNS_1AIXszstDTplcvT__EcvS2__EEEEE
+ template void f4<int>(A<sizeof(sizeof(int))>);
+}
+
+namespace test35 {
+ // Dependent operator names of unknown arity.
+ struct A {
+ template<typename U> A operator+(U) const;
+ };
+
+ template<typename T>
+ void f1(decltype(sizeof(&T::template operator+<int>))) {}
+
+ // CHECK: define weak_odr void @_ZN6test352f1INS_1AEEEvDTszadsrT_plIiEE
+ template void f1<A>(__SIZE_TYPE__);
+}
+
+namespace test36 {
+ template<unsigned> struct A { };
+
+ template<typename ...Types>
+ auto f1(Types... values) -> A<sizeof...(values)> { }
+
+ // CHECK: define weak_odr {{.*}} @_ZN6test362f1IJifEEENS_1AIXsZfp_EEEDpT_
+ template A<2> f1(int, float);
+}
diff --git a/clang/test/CodeGenCXX/member-alignment.cpp b/clang/test/CodeGenCXX/member-alignment.cpp
new file mode 100644
index 0000000..8e120f7
--- /dev/null
+++ b/clang/test/CodeGenCXX/member-alignment.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// XFAIL: arm,powerpc
+
+// rdar://7268289
+
+class t {
+public:
+ virtual void foo(void);
+ void bar(void);
+};
+
+void
+t::bar(void) {
+// CHECK: _ZN1t3barEv{{.*}} align 2
+}
+
+void
+t::foo(void) {
+// CHECK: _ZN1t3fooEv{{.*}} align 2
+}
diff --git a/clang/test/CodeGenCXX/member-call-parens.cpp b/clang/test/CodeGenCXX/member-call-parens.cpp
new file mode 100644
index 0000000..2054137
--- /dev/null
+++ b/clang/test/CodeGenCXX/member-call-parens.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm-only -verify %s
+
+struct A { int a(); };
+typedef int B;
+void a() {
+ A x;
+ ((x.a))();
+ ((x.*&A::a))();
+ B y;
+ // FIXME: Sema doesn't like this for some reason...
+ //(y.~B)();
+}
diff --git a/clang/test/CodeGenCXX/member-expressions.cpp b/clang/test/CodeGenCXX/member-expressions.cpp
new file mode 100644
index 0000000..d9fb394
--- /dev/null
+++ b/clang/test/CodeGenCXX/member-expressions.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 | FileCheck %s
+
+// PR5392
+namespace PR5392 {
+struct A
+{
+ static int a;
+};
+
+A a1;
+void f()
+{
+ // CHECK: store i32 10, i32* @_ZN6PR53921A1aE
+ a1.a = 10;
+ // CHECK: store i32 20, i32* @_ZN6PR53921A1aE
+ A().a = 20;
+}
+
+}
+
+struct A {
+ A();
+ ~A();
+ enum E { Foo };
+};
+
+A *g();
+
+void f(A *a) {
+ A::E e1 = a->Foo;
+
+ // CHECK: call %struct.A* @_Z1gv()
+ A::E e2 = g()->Foo;
+ // CHECK: call void @_ZN1AC1Ev(
+ // CHECK: call void @_ZN1AD1Ev(
+ A::E e3 = A().Foo;
+}
+
+namespace test3 {
+struct A {
+ static int foo();
+};
+int f() {
+ return A().foo();
+}
+}
+
+namespace test4 {
+ struct A {
+ int x;
+ };
+ struct B {
+ int x;
+ void foo();
+ };
+ struct C : A, B {
+ };
+
+ extern C *c_ptr;
+
+ // CHECK: define i32 @_ZN5test44testEv()
+ int test() {
+ // CHECK: load {{.*}} @_ZN5test45c_ptrE
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: call void @_ZN5test41B3fooEv
+ c_ptr->B::foo();
+
+ // CHECK: load {{.*}} @_ZN5test45c_ptrE
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: store i32 5
+ c_ptr->B::x = 5;
+
+ // CHECK: load {{.*}} @_ZN5test45c_ptrE
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: load i32*
+ return c_ptr->B::x;
+ }
+}
diff --git a/clang/test/CodeGenCXX/member-function-pointer-calls.cpp b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
new file mode 100644
index 0000000..f8960aa
--- /dev/null
+++ b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o - | FileCheck %s
+struct A {
+ virtual int vf1() { return 1; }
+ virtual int vf2() { return 2; }
+};
+
+int f(A* a, int (A::*fp)()) {
+ return (a->*fp)();
+}
+
+// CHECK: define i32 @_Z2g1v()
+// CHECK: ret i32 1
+int g1() {
+ A a;
+ return f(&a, &A::vf1);
+}
+
+// CHECK: define i32 @_Z2g2v()
+// CHECK: ret i32 2
+int g2() {
+ A a;
+ return f(&a, &A::vf2);
+}
diff --git a/clang/test/CodeGenCXX/member-function-pointers.cpp b/clang/test/CodeGenCXX/member-function-pointers.cpp
new file mode 100644
index 0000000..2417aa4
--- /dev/null
+++ b/clang/test/CodeGenCXX/member-function-pointers.cpp
@@ -0,0 +1,274 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i386-apple-darwin9 | FileCheck -check-prefix LP32 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-unknown | FileCheck -check-prefix ARM %s
+
+struct A { int a; void f(); virtual void vf1(); virtual void vf2(); };
+struct B { int b; virtual void g(); };
+struct C : B, A { };
+
+void (A::*pa)();
+void (A::*volatile vpa)();
+void (B::*pb)();
+void (C::*pc)();
+
+// CHECK: @pa2 = global { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 }, align 8
+void (A::*pa2)() = &A::f;
+
+// CHECK: @pa3 = global { i64, i64 } { i64 1, i64 0 }, align 8
+// CHECK-LP32: @pa3 = global { i32, i32 } { i32 1, i32 0 }, align 4
+void (A::*pa3)() = &A::vf1;
+
+// CHECK: @pa4 = global { i64, i64 } { i64 9, i64 0 }, align 8
+// CHECK-LP32: @pa4 = global { i32, i32 } { i32 5, i32 0 }, align 4
+void (A::*pa4)() = &A::vf2;
+
+// CHECK: @pc2 = global { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 16 }, align 8
+void (C::*pc2)() = &C::f;
+
+// CHECK: @pc3 = global { i64, i64 } { i64 1, i64 0 }, align 8
+void (A::*pc3)() = &A::vf1;
+
+// Tests for test10.
+// CHECK: @_ZN6test101aE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 0 }, align 8
+// CHECK: @_ZN6test101bE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8
+// CHECK: @_ZN6test101cE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8
+// CHECK: @_ZN6test101dE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 16 }, align 8
+// CHECK-LP32: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4
+// CHECK-LP32: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4
+// CHECK-LP32: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4
+// CHECK-LP32: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4
+
+void f() {
+ // CHECK: store { i64, i64 } zeroinitializer, { i64, i64 }* @pa
+ pa = 0;
+
+ // Is this okay? What are LLVM's volatile semantics for structs?
+ // CHECK: store volatile { i64, i64 } zeroinitializer, { i64, i64 }* @vpa
+ vpa = 0;
+
+ // CHECK: [[TMP:%.*]] = load { i64, i64 }* @pa, align 8
+ // CHECK: [[TMPADJ:%.*]] = extractvalue { i64, i64 } [[TMP]], 1
+ // CHECK: [[ADJ:%.*]] = add nsw i64 [[TMPADJ]], 16
+ // CHECK: [[RES:%.*]] = insertvalue { i64, i64 } [[TMP]], i64 [[ADJ]], 1
+ // CHECK: store { i64, i64 } [[RES]], { i64, i64 }* @pc, align 8
+ pc = pa;
+
+ // CHECK: [[TMP:%.*]] = load { i64, i64 }* @pc, align 8
+ // CHECK: [[TMPADJ:%.*]] = extractvalue { i64, i64 } [[TMP]], 1
+ // CHECK: [[ADJ:%.*]] = sub nsw i64 [[TMPADJ]], 16
+ // CHECK: [[RES:%.*]] = insertvalue { i64, i64 } [[TMP]], i64 [[ADJ]], 1
+ // CHECK: store { i64, i64 } [[RES]], { i64, i64 }* @pa, align 8
+ pa = static_cast<void (A::*)()>(pc);
+}
+
+void f2() {
+ // CHECK: store { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 }
+ void (A::*pa2)() = &A::f;
+
+ // CHECK: store { i64, i64 } { i64 1, i64 0 }
+ // CHECK-LP32: store { i32, i32 } { i32 1, i32 0 }
+ void (A::*pa3)() = &A::vf1;
+
+ // CHECK: store { i64, i64 } { i64 9, i64 0 }
+ // CHECK-LP32: store { i32, i32 } { i32 5, i32 0 }
+ void (A::*pa4)() = &A::vf2;
+}
+
+void f3(A *a, A &ar) {
+ (a->*pa)();
+ (ar.*pa)();
+}
+
+bool f4() {
+ return pa;
+}
+
+// PR5177
+namespace PR5177 {
+ struct A {
+ bool foo(int*) const;
+ } a;
+
+ struct B1 {
+ bool (A::*pmf)(int*) const;
+ const A* pa;
+
+ B1() : pmf(&A::foo), pa(&a) {}
+ bool operator()() const { return (pa->*pmf)(new int); }
+ };
+
+ void bar(B1 b2) { while (b2()) ; }
+}
+
+// PR5138
+namespace PR5138 {
+ struct foo {
+ virtual void bar(foo *);
+ };
+
+ extern "C" {
+ void baz(foo *);
+ }
+
+ void (foo::*ptr1)(void *) = (void (foo::*)(void *))&foo::bar;
+ void (*ptr2)(void *) = (void (*)(void *))&baz;
+
+ void (foo::*ptr3)(void) = (void (foo::*)(void))&foo::bar;
+}
+
+// PR5593
+namespace PR5593 {
+ struct A { };
+
+ bool f(void (A::*f)()) {
+ return f && f;
+ }
+}
+
+namespace PR5718 {
+ struct A { };
+
+ bool f(void (A::*f)(), void (A::*g)()) {
+ return f == g;
+ }
+}
+
+namespace BoolMemberPointer {
+ struct A { };
+
+ bool f(void (A::*f)()) {
+ return !f;
+ }
+
+ bool g(void (A::*f)()) {
+ if (!!f)
+ return true;
+ return false;
+ }
+}
+
+// PR5940
+namespace PR5940 {
+ class foo {
+ public:
+ virtual void baz(void);
+ };
+
+ void foo::baz(void) {
+ void (foo::*ptr)(void) = &foo::baz;
+ }
+}
+
+namespace MemberPointerImpCast {
+ struct A {
+ int x;
+ };
+ struct B : public A {
+ };
+ void f(B* obj, void (A::*method)()) {
+ (obj->*method)();
+ }
+}
+
+// PR6258
+namespace PR6258 {
+
+ struct A {
+ void f(bool);
+ };
+
+ void (A::*pf)(bool) = &A::f;
+
+ void f() {
+ void (A::*pf)(bool) = &A::f;
+ }
+}
+
+// PR7027
+namespace PR7027 {
+ struct X { void test( ); };
+ void testX() { &X::test; }
+}
+
+namespace test7 {
+ struct A { void foo(); virtual void vfoo(); };
+ struct B { void foo(); virtual void vfoo(); };
+ struct C : A, B { void foo(); virtual void vfoo(); };
+
+ // CHECK-ARM: @_ZN5test74ptr0E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71A3fooEv to i32), i32 0 }
+ // CHECK-ARM: @_ZN5test74ptr1E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71B3fooEv to i32), i32 8 }
+ // CHECK-ARM: @_ZN5test74ptr2E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71C3fooEv to i32), i32 0 }
+ // CHECK-ARM: @_ZN5test74ptr3E = global {{.*}} { i32 0, i32 1 }
+ // CHECK-ARM: @_ZN5test74ptr4E = global {{.*}} { i32 0, i32 9 }
+ // CHECK-ARM: @_ZN5test74ptr5E = global {{.*}} { i32 0, i32 1 }
+ void (C::*ptr0)() = &A::foo;
+ void (C::*ptr1)() = &B::foo;
+ void (C::*ptr2)() = &C::foo;
+ void (C::*ptr3)() = &A::vfoo;
+ void (C::*ptr4)() = &B::vfoo;
+ void (C::*ptr5)() = &C::vfoo;
+}
+
+namespace test8 {
+ struct X { };
+ typedef int (X::*pmf)(int);
+
+ // CHECK: {{define.*_ZN5test81fEv}}
+ pmf f() {
+ // CHECK: {{ret.*zeroinitializer}}
+ return pmf();
+ }
+}
+
+namespace test9 {
+ struct A {
+ void foo();
+ };
+ struct B : A {
+ void foo();
+ };
+
+ typedef void (A::*fooptr)();
+
+ struct S {
+ fooptr p;
+ };
+
+ // CHECK: define void @_ZN5test94testEv(
+ // CHECK: alloca i32
+ // CHECK-NEXT: ret void
+ void test() {
+ int x;
+ static S array[] = { (fooptr) &B::foo };
+ }
+}
+
+// rdar://problem/10815683 - Verify that we can emit reinterprets of
+// member pointers as constant initializers. For added trickiness,
+// we also add some non-trivial adjustments.
+namespace test10 {
+ struct A {
+ int nonEmpty;
+ void foo();
+ };
+ struct B : public A {
+ virtual void requireNonZeroAdjustment();
+ };
+ struct C {
+ int nonEmpty;
+ };
+ struct D : public C {
+ virtual void requireNonZeroAdjustment();
+ };
+
+ // Non-ARM tests at top of file.
+ void (A::*a)() = &A::foo;
+ void (B::*b)() = (void (B::*)()) &A::foo;
+ void (C::*c)() = (void (C::*)()) (void (B::*)()) &A::foo;
+ void (D::*d)() = (void (C::*)()) (void (B::*)()) &A::foo;
+}
+// It's not that the offsets are doubled on ARM, it's that they're left-shifted by 1.
+// CHECK-ARM: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4
+// CHECK-ARM: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4
+// CHECK-ARM: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4
+// CHECK-ARM: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 16 }, align 4
diff --git a/clang/test/CodeGenCXX/member-functions.cpp b/clang/test/CodeGenCXX/member-functions.cpp
new file mode 100644
index 0000000..b95763c
--- /dev/null
+++ b/clang/test/CodeGenCXX/member-functions.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-apple-darwin9 -o %t
+struct C {
+ void f();
+ void g(int, ...);
+};
+
+// RUN: grep "define void @_ZN1C1fEv" %t | count 1
+void C::f() {
+}
+
+void test1() {
+ C c;
+
+// RUN: grep "call void @_ZN1C1fEv" %t | count 1
+ c.f();
+
+// RUN: grep "call void (.struct.C\*, i32, ...)\* @_ZN1C1gEiz" %t | count 1
+ c.g(1, 2, 3);
+}
+
+
+struct S {
+ // RUN: grep "define linkonce_odr void @_ZN1SC1Ev.*unnamed_addr" %t
+ inline S() { }
+ // RUN: grep "define linkonce_odr void @_ZN1SC1Ev.*unnamed_addr" %t
+ inline ~S() { }
+
+
+ // RUN: grep "define linkonce_odr void @_ZN1S9f_inline1Ev" %t
+ void f_inline1() { }
+ // RUN: grep "define linkonce_odr void @_ZN1S9f_inline2Ev" %t
+ inline void f_inline2() { }
+
+ // RUN: grep "define linkonce_odr void @_ZN1S1gEv" %t
+ static void g() { }
+
+ static void f();
+};
+
+// RUN: grep "define void @_ZN1S1fEv" %t
+void S::f() {
+}
+
+void test2() {
+ S s;
+
+ s.f_inline1();
+ s.f_inline2();
+
+ S::g();
+
+}
+
+struct T {
+ T operator+(const T&);
+};
+
+void test3() {
+ T t1, t2;
+
+ // RUN: grep "call void @_ZN1TplERKS_" %t
+ T result = t1 + t2;
+}
diff --git a/clang/test/CodeGenCXX/member-init-anon-union.cpp b/clang/test/CodeGenCXX/member-init-anon-union.cpp
new file mode 100644
index 0000000..1ff7537
--- /dev/null
+++ b/clang/test/CodeGenCXX/member-init-anon-union.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - | FileCheck %s
+
+// PR10531.
+
+static union {
+ int a = 42;
+ char *b;
+};
+
+int f() { return a; }
+
+// CHECK: define internal void @__cxx_global_var_init
+// CHECK-NOT: }
+// CHECK: call {{.*}}@"[[CONSTRUCT_GLOBAL:.*]]C1Ev"
+
+
+int g() {
+ union {
+ int a;
+ int b = 81;
+ };
+ // CHECK: define {{.*}}_Z1gv
+ // CHECK-NOT: }
+ // CHECK: call {{.*}}@"[[CONSTRUCT_LOCAL:.*]]C1Ev"
+ return b;
+}
+
+
+// CHECK: define {{.*}}@"[[CONSTRUCT_LOCAL]]C2Ev"
+// CHECK-NOT: }
+// CHECK: store i32 81
+
+// CHECK: define {{.*}}@"[[CONSTRUCT_GLOBAL]]C2Ev"
+// CHECK-NOT: }
+// CHECK: store i32 42
diff --git a/clang/test/CodeGenCXX/member-init-assignment.cpp b/clang/test/CodeGenCXX/member-init-assignment.cpp
new file mode 100644
index 0000000..84c4a36
--- /dev/null
+++ b/clang/test/CodeGenCXX/member-init-assignment.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// PR7291
+
+struct Foo {
+ unsigned file_id;
+
+ Foo(unsigned arg);
+};
+
+Foo::Foo(unsigned arg) : file_id(arg = 42)
+{ }
+
+// CHECK: define {{.*}} @_ZN3FooC2Ej(%struct.Foo* %this, i32 %arg) unnamed_addr
+// CHECK: [[ARG:%.*]] = alloca i32
+// CHECK: store i32 42, i32* [[ARG]]
+// CHECK: store i32 42, i32* %{{.*}}
+// CHECK: ret {{void|%struct.Foo}}
diff --git a/clang/test/CodeGenCXX/member-init-ctor.cpp b/clang/test/CodeGenCXX/member-init-ctor.cpp
new file mode 100644
index 0000000..2172394
--- /dev/null
+++ b/clang/test/CodeGenCXX/member-init-ctor.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - | FileCheck %s
+
+bool b();
+struct S {
+ int n = b() ? S().n + 1 : 0;
+};
+
+S s;
+
+// CHECK: define {{.*}} @_ZN1SC2Ev(
+// CHECK-NOT }
+// CHECK: call {{.*}} @_Z1bv()
+// CHECK-NOT }
+// CHECK: call {{.*}} @_ZN1SC1Ev(
diff --git a/clang/test/CodeGenCXX/member-init-struct.cpp b/clang/test/CodeGenCXX/member-init-struct.cpp
new file mode 100644
index 0000000..688d92d
--- /dev/null
+++ b/clang/test/CodeGenCXX/member-init-struct.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -emit-llvm-only -verify
+
+struct A {int a;};
+struct B {float a;};
+struct C {
+ union {
+ A a;
+ B b[10];
+ };
+ _Complex float c;
+ int d[10];
+ void (C::*e)();
+ C() : a(), c(), d(), e() {}
+ C(A x) : a(x) {}
+ C(void (C::*x)(), int y) : b(), c(y), e(x) {}
+};
+A x;
+C a, b(x), c(0, 2);
diff --git a/clang/test/CodeGenCXX/member-init-union.cpp b/clang/test/CodeGenCXX/member-init-union.cpp
new file mode 100644
index 0000000..2c50e18
--- /dev/null
+++ b/clang/test/CodeGenCXX/member-init-union.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -emit-llvm-only -verify
+
+union x {
+ int a;
+ float b;
+ x(float y) : b(y) {}
+ x(int y) : a(y) {}
+};
+x a(1), b(1.0f);
+
diff --git a/clang/test/CodeGenCXX/member-initializers.cpp b/clang/test/CodeGenCXX/member-initializers.cpp
new file mode 100644
index 0000000..244a164
--- /dev/null
+++ b/clang/test/CodeGenCXX/member-initializers.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 -O3 | FileCheck %s
+
+struct A {
+ virtual int f() { return 1; }
+};
+
+struct B : A {
+ B() : i(f()) { }
+
+ virtual int f() { return 2; }
+
+ int i;
+};
+
+// CHECK: define i32 @_Z1fv() nounwind
+int f() {
+ B b;
+
+ // CHECK: ret i32 2
+ return b.i;
+}
+
+// Test that we don't try to fold the default value of j when initializing i.
+// CHECK: define i32 @_Z9test_foldv() nounwind
+int test_fold() {
+ struct A {
+ A(const int j = 1) : i(j) { }
+ int i;
+ };
+
+ // CHECK: ret i32 2
+ return A(2).i;
+}
+
diff --git a/clang/test/CodeGenCXX/member-pointer-type-convert.cpp b/clang/test/CodeGenCXX/member-pointer-type-convert.cpp
new file mode 100644
index 0000000..2970a2e
--- /dev/null
+++ b/clang/test/CodeGenCXX/member-pointer-type-convert.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+struct A;
+typedef int A::*param_t;
+struct {
+ const char *name;
+ param_t par;
+} *ptr;
+void test_ptr() { (void) ptr; } // forced use
+
+// CHECK: type { i8*, {{i..}} }
diff --git a/clang/test/CodeGenCXX/member-templates.cpp b/clang/test/CodeGenCXX/member-templates.cpp
new file mode 100644
index 0000000..7e4bdca
--- /dev/null
+++ b/clang/test/CodeGenCXX/member-templates.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// CHECK: ; ModuleID
+struct A {
+ template<typename T>
+ A(T);
+};
+
+template<typename T> A::A(T) {}
+
+struct B {
+ template<typename T>
+ B(T);
+};
+
+template<typename T> B::B(T) {}
+
+// CHECK: define weak_odr void @_ZN1BC1IiEET_(%struct.B* %this, i32) unnamed_addr
+// CHECK: define weak_odr void @_ZN1BC2IiEET_(%struct.B* %this, i32) unnamed_addr
+template B::B(int);
+
+template<typename T>
+struct C {
+ void f() {
+ int a[] = { 1, 2, 3 };
+ }
+};
+
+void f(C<int>& c) {
+ c.f();
+}
diff --git a/clang/test/CodeGenCXX/multi-dim-operator-new.cpp b/clang/test/CodeGenCXX/multi-dim-operator-new.cpp
new file mode 100644
index 0000000..7a235e8
--- /dev/null
+++ b/clang/test/CodeGenCXX/multi-dim-operator-new.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s
+// PR6641
+
+extern "C" int printf(const char *, ...);
+
+struct Foo {
+ Foo() : iFoo (2) {
+ printf("%p\n", this);
+ }
+ int iFoo;
+};
+
+
+typedef Foo (*T)[3][4];
+
+T bar() {
+ return new Foo[2][3][4];
+}
+
+T bug(int i) {
+ return new Foo[i][3][4];
+}
+
+void pr(T a) {
+ for (int i = 0; i < 3; i++)
+ for (int j = 0; j < 4; j++)
+ printf("%p\n", a[i][j]);
+}
+
+Foo *test() {
+ return new Foo[5];
+}
+
+int main() {
+ T f = bar();
+ pr(f);
+ f = bug(3);
+ pr(f);
+
+ Foo * g = test();
+ for (int i = 0; i < 5; i++)
+ printf("%d\n", g[i].iFoo);
+ return 0;
+}
+
+// CHECK: call noalias i8* @_Znam
+// CHECK: call noalias i8* @_Znam
+// CHECK: call noalias i8* @_Znam
+
diff --git a/clang/test/CodeGenCXX/namespace-aliases.cpp b/clang/test/CodeGenCXX/namespace-aliases.cpp
new file mode 100644
index 0000000..8624eb7
--- /dev/null
+++ b/clang/test/CodeGenCXX/namespace-aliases.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+namespace A { }
+namespace B = A;
+
+namespace b {}
+
+void foo() {
+ namespace a = b;
+}
diff --git a/clang/test/CodeGenCXX/nested-base-member-access.cpp b/clang/test/CodeGenCXX/nested-base-member-access.cpp
new file mode 100644
index 0000000..f1c7dd9
--- /dev/null
+++ b/clang/test/CodeGenCXX/nested-base-member-access.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+
+extern "C" int printf(...);
+
+struct M {
+ M(int i){ iM = i; }
+ int iM;
+ void MPR() { printf("iM = %d\n", iM); }
+
+};
+
+struct Q {
+ Q(int i){ iQ = i; }
+ int iQ;
+ void QPR() { printf("iQ = %d\n", iQ); }
+};
+
+struct IQ {
+ IQ(int i) { iIQ = i; }
+ void IQPR() { printf("iIQ = %d\n", iIQ); }
+ int iIQ;
+};
+
+struct L : IQ {
+ L(int i) : IQ(i+100) { iL = i; }
+ int iL;
+};
+
+struct P : Q, L {
+ P(int i) : Q(i+100), L(i+200) { iP = i; }
+ int iP;
+ void PPR() { printf("iP = %d\n", iP); }
+};
+
+
+struct N : M,P {
+ N() : M(100), P(200) {}
+ void PR() {
+ this->MPR(); this->PPR(); this->QPR();
+ IQPR();
+ printf("iM = %d\n", iM);
+ printf("iP = %d\n", iP);
+ printf("iQ = %d\n", iQ);
+ printf("iL = %d\n", iL);
+ printf("iIQ = %d\n", iIQ);
+ }
+};
+
+int main() {
+ N n1;
+ n1.PR();
+}
diff --git a/clang/test/CodeGenCXX/new-array-init-exceptions.cpp b/clang/test/CodeGenCXX/new-array-init-exceptions.cpp
new file mode 100644
index 0000000..5d9cc9f
--- /dev/null
+++ b/clang/test/CodeGenCXX/new-array-init-exceptions.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++11 -triple i386-unknown-unknown -fexceptions -fcxx-exceptions %s -emit-llvm -o - | FileCheck %s
+// REQUIRES: asserts
+
+struct Throws {
+ Throws(int);
+ Throws();
+ ~Throws();
+};
+
+// CHECK: define void @_Z7cleanupi
+void cleanup(int n) {
+ // CHECK: invoke void @_ZN6ThrowsC1Ei
+ // CHECK-NEXT: to label %{{[^ ]+}} unwind label %[[LPAD:[^ ]+]]
+ // CHECK: invoke void @_ZN6ThrowsC1Ei
+ // CHECK-NEXT: to label %{{[^ ]+}} unwind label %[[LPAD]]
+ // CHECK: invoke void @_ZN6ThrowsC1Ei
+ // CHECK-NEXT: to label %{{[^ ]+}} unwind label %[[LPAD]]
+ // CHECK: invoke void @_ZN6ThrowsC1Ev
+ // CHECK-NEXT: to label %{{[^ ]+}} unwind label %[[LPAD]]
+ new Throws[n] { 1, 2, 3 };
+ // CHECK: [[LPAD]]:
+ // CHECK-NEXT: landingpad
+ // CHECK: call void @_ZN6ThrowsD1Ev
+ // CHECK: call void @_ZdaPv
+}
+
+
+// CHECK: define void @_Z7cleanupv
+void cleanup() {
+ // CHECK: invoke void @_ZN6ThrowsC1Ei
+ // CHECK-NEXT: to label %{{[^ ]+}} unwind label %[[LPAD2:[^ ]+]]
+ // CHECK: invoke void @_ZN6ThrowsC1Ei
+ // CHECK-NEXT: to label %{{[^ ]+}} unwind label %[[LPAD2]]
+ // CHECK: invoke void @_ZN6ThrowsC1Ei
+ // CHECK-NEXT: to label %{{[^ ]+}} unwind label %[[LPAD2]]
+ new Throws[3] { 1, 2, 3 };
+ // CHECK: [[LPAD2]]:
+ // CHECK-NEXT: landingpad
+ // CHECK: call void @_ZN6ThrowsD1Ev
+ // CHECK: call void @_ZdaPv
+}
diff --git a/clang/test/CodeGenCXX/new-array-init.cpp b/clang/test/CodeGenCXX/new-array-init.cpp
new file mode 100644
index 0000000..231df24
--- /dev/null
+++ b/clang/test/CodeGenCXX/new-array-init.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++11 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: define void @_Z2fni
+void fn(int n) {
+ // CHECK: icmp ult i{{32|64}} %{{[^ ]+}}, 3
+ // CHECK: store i32 1
+ // CHECK: store i32 2
+ // CHECK: store i32 3
+ // CHECK: icmp eq i32*
+ // CHECK-NEXT: br i1
+ new int[n] { 1, 2, 3 };
+}
+
+// CHECK: define void @_Z15const_underflowv
+void const_underflow() {
+ // CHECK-NOT: icmp ult i{{32|64}} %{{[^ ]+}}, 3
+ // CHECK: call noalias i8* @_Zna{{.}}(i{{32|64}} -1)
+ new int[2] { 1, 2, 3 };
+}
+
+// CHECK: define void @_Z11const_exactv
+void const_exact() {
+ // CHECK-NOT: icmp ult i{{32|64}} %{{[^ ]+}}, 3
+ // CHECK-NOT: icmp eq i32*
+ new int[3] { 1, 2, 3 };
+}
+
+// CHECK: define void @_Z16const_sufficientv
+void const_sufficient() {
+ // CHECK-NOT: icmp ult i{{32|64}} %{{[^ ]+}}, 3
+ new int[4] { 1, 2, 3 };
+ // CHECK: ret void
+}
diff --git a/clang/test/CodeGenCXX/new-operator-phi.cpp b/clang/test/CodeGenCXX/new-operator-phi.cpp
new file mode 100644
index 0000000..49859ac
--- /dev/null
+++ b/clang/test/CodeGenCXX/new-operator-phi.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm-only -verify %s
+// PR5454
+#include <stddef.h>
+
+struct X {static void * operator new(size_t size) throw(); X(int); };
+int a(), b();
+void b(int x)
+{
+ new X(x ? a() : b());
+}
+
diff --git a/clang/test/CodeGenCXX/new-overflow.cpp b/clang/test/CodeGenCXX/new-overflow.cpp
new file mode 100644
index 0000000..68f89c3
--- /dev/null
+++ b/clang/test/CodeGenCXX/new-overflow.cpp
@@ -0,0 +1,209 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+
+// rdar://problem/9246208
+
+// Basic test.
+namespace test0 {
+ struct A {
+ A();
+ int x;
+ };
+
+ typedef A elt;
+
+ // CHECK: define [[A:%.*]]* @_ZN5test04testEs(i16 signext
+ // CHECK: [[N:%.*]] = sext i16 {{%.*}} to i32
+ // CHECK-NEXT: [[T0:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[N]], i32 4)
+ // CHECK-NEXT: [[T1:%.*]] = extractvalue { i32, i1 } [[T0]], 1
+ // CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 0
+ // CHECK-NEXT: [[T3:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]
+ // CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T3]])
+ // CHECK: getelementptr inbounds {{.*}}, i32 [[N]]
+ elt *test(short s) {
+ return new elt[s];
+ }
+}
+
+// test0 with a nested array.
+namespace test1 {
+ struct A {
+ A();
+ int x;
+ };
+
+ typedef A elt[100];
+
+ // CHECK: define [100 x [[A:%.*]]]* @_ZN5test14testEs(i16 signext
+ // CHECK: [[N:%.*]] = sext i16 {{%.*}} to i32
+ // CHECK-NEXT: [[T0:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[N]], i32 400)
+ // CHECK-NEXT: [[T1:%.*]] = extractvalue { i32, i1 } [[T0]], 1
+ // CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 0
+ // CHECK-NEXT: [[T3:%.*]] = mul i32 [[N]], 100
+ // CHECK-NEXT: [[T4:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]
+ // CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T4]])
+ // CHECK: getelementptr inbounds {{.*}}, i32 [[T3]]
+ elt *test(short s) {
+ return new elt[s];
+ }
+}
+
+// test1 with an array cookie.
+namespace test2 {
+ struct A {
+ A();
+ ~A();
+ int x;
+ };
+
+ typedef A elt[100];
+
+ // CHECK: define [100 x [[A:%.*]]]* @_ZN5test24testEs(i16 signext
+ // CHECK: [[N:%.*]] = sext i16 {{%.*}} to i32
+ // CHECK-NEXT: [[T0:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[N]], i32 400)
+ // CHECK-NEXT: [[T1:%.*]] = extractvalue { i32, i1 } [[T0]], 1
+ // CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 0
+ // CHECK-NEXT: [[T3:%.*]] = mul i32 [[N]], 100
+ // CHECK-NEXT: [[T4:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 [[T2]], i32 4)
+ // CHECK-NEXT: [[T5:%.*]] = extractvalue { i32, i1 } [[T4]], 1
+ // CHECK-NEXT: [[T6:%.*]] = or i1 [[T1]], [[T5]]
+ // CHECK-NEXT: [[T7:%.*]] = extractvalue { i32, i1 } [[T4]], 0
+ // CHECK-NEXT: [[T8:%.*]] = select i1 [[T6]], i32 -1, i32 [[T7]]
+ // CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T8]])
+ // CHECK: getelementptr inbounds {{.*}}, i32 [[T3]]
+ elt *test(short s) {
+ return new elt[s];
+ }
+}
+
+// test0 with a 1-byte element.
+namespace test4 {
+ struct A {
+ A();
+ };
+
+ typedef A elt;
+
+ // CHECK: define [[A:%.*]]* @_ZN5test44testEs(i16 signext
+ // CHECK: [[N:%.*]] = sext i16 {{%.*}} to i32
+ // CHECK-NEXT: [[T0:%.*]] = icmp slt i32 [[N]], 0
+ // CHECK-NEXT: [[T1:%.*]] = select i1 [[T0]], i32 -1, i32 [[N]]
+ // CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T1]])
+ // CHECK: getelementptr inbounds {{.*}}, i32 [[N]]
+ elt *test(short s) {
+ return new elt[s];
+ }
+}
+
+// test4 with no sext required.
+namespace test5 {
+ struct A {
+ A();
+ };
+
+ typedef A elt;
+
+ // CHECK: define [[A:%.*]]* @_ZN5test54testEi(i32
+ // CHECK: [[N:%.*]] = load i32*
+ // CHECK-NEXT: [[T0:%.*]] = icmp slt i32 [[N]], 0
+ // CHECK-NEXT: [[T1:%.*]] = select i1 [[T0]], i32 -1, i32 [[N]]
+ // CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T1]])
+ // CHECK: getelementptr inbounds {{.*}}, i32 [[N]]
+ elt *test(int s) {
+ return new elt[s];
+ }
+}
+
+// test0 with an unsigned size.
+namespace test6 {
+ struct A {
+ A();
+ int x;
+ };
+
+ typedef A elt;
+
+ // CHECK: define [[A:%.*]]* @_ZN5test64testEt(i16 zeroext
+ // CHECK: [[N:%.*]] = zext i16 {{%.*}} to i32
+ // CHECK-NEXT: [[T0:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[N]], i32 4)
+ // CHECK-NEXT: [[T1:%.*]] = extractvalue { i32, i1 } [[T0]], 1
+ // CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 0
+ // CHECK-NEXT: [[T3:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]
+ // CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T3]])
+ // CHECK: getelementptr inbounds {{.*}}, i32 [[N]]
+ elt *test(unsigned short s) {
+ return new elt[s];
+ }
+}
+
+// test1 with an unsigned size.
+namespace test7 {
+ struct A {
+ A();
+ int x;
+ };
+
+ typedef A elt[100];
+
+ // CHECK: define [100 x [[A:%.*]]]* @_ZN5test74testEt(i16 zeroext
+ // CHECK: [[N:%.*]] = zext i16 {{%.*}} to i32
+ // CHECK-NEXT: [[T0:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[N]], i32 400)
+ // CHECK-NEXT: [[T1:%.*]] = extractvalue { i32, i1 } [[T0]], 1
+ // CHECK-NEXT: [[T2:%.*]] = extractvalue { i32, i1 } [[T0]], 0
+ // CHECK-NEXT: [[T3:%.*]] = mul i32 [[N]], 100
+ // CHECK-NEXT: [[T4:%.*]] = select i1 [[T1]], i32 -1, i32 [[T2]]
+ // CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T4]])
+ // CHECK: getelementptr inbounds {{.*}}, i32 [[T3]]
+ elt *test(unsigned short s) {
+ return new elt[s];
+ }
+}
+
+// test0 with a signed type larger than size_t.
+namespace test8 {
+ struct A {
+ A();
+ int x;
+ };
+
+ typedef A elt;
+
+ // CHECK: define [[A:%.*]]* @_ZN5test84testEx(i64
+ // CHECK: [[N:%.*]] = load i64*
+ // CHECK-NEXT: [[T0:%.*]] = icmp uge i64 [[N]], 4294967296
+ // CHECK-NEXT: [[T1:%.*]] = trunc i64 [[N]] to i32
+ // CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[T1]], i32 4)
+ // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 1
+ // CHECK-NEXT: [[T4:%.*]] = or i1 [[T0]], [[T3]]
+ // CHECK-NEXT: [[T5:%.*]] = extractvalue { i32, i1 } [[T2]], 0
+ // CHECK-NEXT: [[T6:%.*]] = select i1 [[T4]], i32 -1, i32 [[T5]]
+ // CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T6]])
+ // CHECK: getelementptr inbounds {{.*}}, i32 [[T1]]
+ elt *test(long long s) {
+ return new elt[s];
+ }
+}
+
+// test8 with an unsigned type.
+namespace test9 {
+ struct A {
+ A();
+ int x;
+ };
+
+ typedef A elt;
+
+ // CHECK: define [[A:%.*]]* @_ZN5test94testEy(i64
+ // CHECK: [[N:%.*]] = load i64*
+ // CHECK-NEXT: [[T0:%.*]] = icmp uge i64 [[N]], 4294967296
+ // CHECK-NEXT: [[T1:%.*]] = trunc i64 [[N]] to i32
+ // CHECK-NEXT: [[T2:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[T1]], i32 4)
+ // CHECK-NEXT: [[T3:%.*]] = extractvalue { i32, i1 } [[T2]], 1
+ // CHECK-NEXT: [[T4:%.*]] = or i1 [[T0]], [[T3]]
+ // CHECK-NEXT: [[T5:%.*]] = extractvalue { i32, i1 } [[T2]], 0
+ // CHECK-NEXT: [[T6:%.*]] = select i1 [[T4]], i32 -1, i32 [[T5]]
+ // CHECK-NEXT: call noalias i8* @_Znaj(i32 [[T6]])
+ // CHECK: getelementptr inbounds {{.*}}, i32 [[T1]]
+ elt *test(unsigned long long s) {
+ return new elt[s];
+ }
+}
diff --git a/clang/test/CodeGenCXX/new-with-default-arg.cpp b/clang/test/CodeGenCXX/new-with-default-arg.cpp
new file mode 100644
index 0000000..248cc9e
--- /dev/null
+++ b/clang/test/CodeGenCXX/new-with-default-arg.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+// pr5547
+
+struct A {
+ void* operator new(__typeof(sizeof(int)));
+ A();
+};
+
+A* x() {
+ return new A;
+}
+
+struct B {
+ void* operator new(__typeof(sizeof(int)), int = 1, int = 4);
+ B(float);
+};
+
+B* y() {
+ new (3,4) B(1);
+ return new(1) B(2);
+}
+
+struct C {
+ void* operator new(__typeof(sizeof(int)), int, int = 4);
+ C();
+};
+
+C* z() {
+ new (3,4) C;
+ return new(1) C;
+}
+
+
diff --git a/clang/test/CodeGenCXX/new.cpp b/clang/test/CodeGenCXX/new.cpp
new file mode 100644
index 0000000..8d9f641
--- /dev/null
+++ b/clang/test/CodeGenCXX/new.cpp
@@ -0,0 +1,252 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+
+typedef __typeof__(sizeof(0)) size_t;
+
+void t1() {
+ int* a = new int;
+}
+
+// Declare the reserved placement operators.
+void *operator new(size_t, void*) throw();
+void operator delete(void*, void*) throw();
+void *operator new[](size_t, void*) throw();
+void operator delete[](void*, void*) throw();
+
+void t2(int* a) {
+ int* b = new (a) int;
+}
+
+struct S {
+ int a;
+};
+
+// POD types.
+void t3() {
+ int *a = new int(10);
+ _Complex int* b = new _Complex int(10i);
+
+ S s;
+ s.a = 10;
+ S *sp = new S(s);
+}
+
+// Non-POD
+struct T {
+ T();
+ int a;
+};
+
+void t4() {
+ // CHECK: call void @_ZN1TC1Ev
+ T *t = new T;
+}
+
+struct T2 {
+ int a;
+ T2(int, int);
+};
+
+void t5() {
+ // CHECK: call void @_ZN2T2C1Eii
+ T2 *t2 = new T2(10, 10);
+}
+
+int *t6() {
+ // Null check.
+ return new (0) int(10);
+}
+
+void t7() {
+ new int();
+}
+
+struct U {
+ ~U();
+};
+
+void t8(int n) {
+ new int[10];
+ new int[n];
+
+ // Non-POD
+ new T[10];
+ new T[n];
+
+ // Cookie required
+ new U[10];
+ new U[n];
+}
+
+// noalias
+// CHECK: declare noalias i8* @_Znam
+void *operator new[](size_t);
+
+void t9() {
+ bool b;
+
+ new bool(true);
+ new (&b) bool(true);
+}
+
+struct A {
+ void* operator new(__typeof(sizeof(int)), int, float, ...);
+ A();
+};
+
+A* t10() {
+ // CHECK: @_ZN1AnwEmifz
+ return new(1, 2, 3.45, 100) A;
+}
+
+// CHECK: define void @_Z3t11i
+struct B { int a; };
+struct Bmemptr { int Bmemptr::* memptr; int a; };
+
+void t11(int n) {
+ // CHECK: call noalias i8* @_Znwm
+ // CHECK: call void @llvm.memset.p0i8.i64(
+ B* b = new B();
+
+ // CHECK: call noalias i8* @_Znam
+ // CHECK: {{call void.*llvm.memset.p0i8.i64.*i8 0, i64 %}}
+ B *b2 = new B[n]();
+
+ // CHECK: call noalias i8* @_Znam
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
+ // CHECK: br
+ Bmemptr *b_memptr = new Bmemptr[n]();
+
+ // CHECK: ret void
+}
+
+struct Empty { };
+
+// We don't need to initialize an empty class.
+// CHECK: define void @_Z3t12v
+void t12() {
+ // CHECK: call noalias i8* @_Znam
+ // CHECK-NOT: br
+ (void)new Empty[10];
+
+ // CHECK: call noalias i8* @_Znam
+ // CHECK-NOT: br
+ (void)new Empty[10]();
+
+ // CHECK: ret void
+}
+
+// Zero-initialization
+// CHECK: define void @_Z3t13i
+void t13(int n) {
+ // CHECK: call noalias i8* @_Znwm
+ // CHECK: store i32 0, i32*
+ (void)new int();
+
+ // CHECK: call noalias i8* @_Znam
+ // CHECK: {{call void.*llvm.memset.p0i8.i64.*i8 0, i64 %}}
+ (void)new int[n]();
+
+ // CHECK-NEXT: ret void
+}
+
+struct Alloc{
+ int x;
+ void* operator new[](size_t size);
+ void operator delete[](void* p);
+ ~Alloc();
+};
+
+void f() {
+ // CHECK: call i8* @_ZN5AllocnaEm(i64 808)
+ // CHECK: store i64 200
+ // CHECK: call void @_ZN5AllocD1Ev(
+ // CHECK: call void @_ZN5AllocdaEPv(i8*
+ delete[] new Alloc[10][20];
+ // CHECK: call noalias i8* @_Znwm
+ // CHECK: call void @_ZdlPv(i8*
+ delete new bool;
+ // CHECK: ret void
+}
+
+namespace test15 {
+ struct A { A(); ~A(); };
+
+ // CHECK: define void @_ZN6test155test0EPv(
+ // CHECK: [[P:%.*]] = load i8*
+ // CHECK-NEXT: icmp eq i8* [[P]], null
+ // CHECK-NEXT: br i1
+ // CHECK: [[T0:%.*]] = bitcast i8* [[P]] to [[A:%.*]]*
+ // CHECK-NEXT: call void @_ZN6test151AC1Ev([[A]]* [[T0]])
+ void test0(void *p) {
+ new (p) A();
+ }
+
+ // CHECK: define void @_ZN6test155test1EPv(
+ // CHECK: [[P:%.*]] = load i8**
+ // CHECK-NEXT: icmp eq i8* [[P]], null
+ // CHECK-NEXT: br i1
+ // CHECK: [[BEGIN:%.*]] = bitcast i8* [[P]] to [[A:%.*]]*
+ // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 5
+ // CHECK-NEXT: br label
+ // CHECK: [[CUR:%.*]] = phi [[A]]* [ [[BEGIN]], {{%.*}} ], [ [[NEXT:%.*]], {{%.*}} ]
+ // CHECK-NEXT: call void @_ZN6test151AC1Ev([[A]]* [[CUR]])
+ // CHECK-NEXT: [[NEXT]] = getelementptr inbounds [[A]]* [[CUR]], i64 1
+ // CHECK-NEXT: [[DONE:%.*]] = icmp eq [[A]]* [[NEXT]], [[END]]
+ // CHECK-NEXT: br i1 [[DONE]]
+ void test1(void *p) {
+ new (p) A[5];
+ }
+
+ // TODO: it's okay if all these size calculations get dropped.
+ // FIXME: maybe we should try to throw on overflow?
+ // CHECK: define void @_ZN6test155test2EPvi(
+ // CHECK: [[N:%.*]] = load i32*
+ // CHECK-NEXT: [[T0:%.*]] = sext i32 [[N]] to i64
+ // CHECK-NEXT: [[T1:%.*]] = icmp slt i64 [[T0]], 0
+ // CHECK-NEXT: [[T2:%.*]] = select i1 [[T1]], i64 -1, i64 [[T0]]
+ // CHECK-NEXT: [[P:%.*]] = load i8*
+ // CHECK-NEXT: icmp eq i8* [[P]], null
+ // CHECK-NEXT: br i1
+ // CHECK: [[BEGIN:%.*]] = bitcast i8* [[P]] to [[A:%.*]]*
+ // CHECK-NEXT: [[ISEMPTY:%.*]] = icmp eq i64 [[T0]], 0
+ // CHECK-NEXT: br i1 [[ISEMPTY]],
+ // CHECK: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 [[T0]]
+ // CHECK-NEXT: br label
+ // CHECK: [[CUR:%.*]] = phi [[A]]* [ [[BEGIN]],
+ // CHECK-NEXT: call void @_ZN6test151AC1Ev([[A]]* [[CUR]])
+ void test2(void *p, int n) {
+ new (p) A[n];
+ }
+}
+
+namespace PR10197 {
+ // CHECK: define weak_odr void @_ZN7PR101971fIiEEvv()
+ template<typename T>
+ void f() {
+ // CHECK: [[CALL:%.*]] = call noalias i8* @_Znwm
+ // CHECK-NEXT: [[CASTED:%.*]] = bitcast i8* [[CALL]] to
+ new T;
+ // CHECK-NEXT: ret void
+ }
+
+ template void f<int>();
+}
+
+namespace PR11523 {
+ class MyClass;
+ typedef int MyClass::* NewTy;
+ // CHECK: define i64* @_ZN7PR115231fEv
+ // CHECK: store i64 -1
+ NewTy* f() { return new NewTy[2](); }
+}
+
+namespace PR11757 {
+ // Make sure we elide the copy construction.
+ struct X { X(); X(const X&); };
+ X* a(X* x) { return new X(X()); }
+ // CHECK: define {{.*}} @_ZN7PR117571aEPNS_1XE
+ // CHECK: [[CALL:%.*]] = call noalias i8* @_Znwm
+ // CHECK-NEXT: [[CASTED:%.*]] = bitcast i8* [[CALL]] to
+ // CHECK-NEXT: call void @_ZN7PR117571XC1Ev({{.*}}* [[CASTED]])
+ // CHECK-NEXT: ret {{.*}} [[CASTED]]
+}
diff --git a/clang/test/CodeGenCXX/no-exceptions.cpp b/clang/test/CodeGenCXX/no-exceptions.cpp
new file mode 100644
index 0000000..da672c4
--- /dev/null
+++ b/clang/test/CodeGenCXX/no-exceptions.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+void g();
+
+// CHECK: define void @_Z1fv() nounwind
+void f() throw (int) {
+
+ // CHECK-NOT: invoke void @_Z1gv
+ g();
+ // CHECK: call void @_Z1gv()
+ // CHECK: ret void
+}
diff --git a/clang/test/CodeGenCXX/noinline-template.cpp b/clang/test/CodeGenCXX/noinline-template.cpp
new file mode 100644
index 0000000..6ee3935
--- /dev/null
+++ b/clang/test/CodeGenCXX/noinline-template.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// This was a problem in Sema, but only shows up as noinline missing
+// in CodeGen.
+
+// CHECK: define linkonce_odr void @_ZN6VectorIiE13growStorageByEv(%struct.Vector* %this) nounwind noinline
+
+template <class Ty> struct Vector {
+ void growStorageBy();
+};
+template <class T> __attribute__((noinline)) void Vector<T>::growStorageBy() {
+}
+void foo() {
+ Vector<int> strs;
+ strs.growStorageBy();
+}
diff --git a/clang/test/CodeGenCXX/nonconst-init.cpp b/clang/test/CodeGenCXX/nonconst-init.cpp
new file mode 100644
index 0000000..21129b9
--- /dev/null
+++ b/clang/test/CodeGenCXX/nonconst-init.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+int a();
+// CHECK: call i32 @_Z1av()
+struct x {int x, y : 10;} x = {1, a()};
diff --git a/clang/test/CodeGenCXX/nrvo-noreturn.cc b/clang/test/CodeGenCXX/nrvo-noreturn.cc
new file mode 100644
index 0000000..a8259ca
--- /dev/null
+++ b/clang/test/CodeGenCXX/nrvo-noreturn.cc
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+// PR9178
+
+void abort() __attribute__((__noreturn__));
+struct CoinModelLink {
+ CoinModelLink();
+ ~CoinModelLink();
+};
+class CoinModel {
+ CoinModelLink firstInQuadraticColumn();
+};
+CoinModelLink CoinModel::firstInQuadraticColumn() {
+ abort();
+ CoinModelLink x;
+ return x;
+}
+
diff --git a/clang/test/CodeGenCXX/nrvo.cpp b/clang/test/CodeGenCXX/nrvo.cpp
new file mode 100644
index 0000000..2feaf68
--- /dev/null
+++ b/clang/test/CodeGenCXX/nrvo.cpp
@@ -0,0 +1,161 @@
+// RUN: %clang_cc1 -emit-llvm -O1 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O1 -fcxx-exceptions -fexceptions -o - %s | FileCheck --check-prefix=CHECK-EH %s
+
+// Test code generation for the named return value optimization.
+class X {
+public:
+ X();
+ X(const X&);
+ ~X();
+};
+
+// CHECK: define void @_Z5test0v
+// CHECK-EH: define void @_Z5test0v
+X test0() {
+ X x;
+ // CHECK: call {{.*}} @_ZN1XC1Ev
+ // CHECK-NEXT: ret void
+
+ // CHECK-EH: call {{.*}} @_ZN1XC1Ev
+ // CHECK-EH-NEXT: ret void
+ return x;
+}
+
+// CHECK: define void @_Z5test1b(
+// CHECK-EH: define void @_Z5test1b(
+X test1(bool B) {
+ // CHECK: tail call {{.*}} @_ZN1XC1Ev
+ // CHECK-NEXT: ret void
+ X x;
+ if (B)
+ return (x);
+ return x;
+ // CHECK-EH: tail call {{.*}} @_ZN1XC1Ev
+ // CHECK-EH-NEXT: ret void
+}
+
+// CHECK: define void @_Z5test2b
+// CHECK-EH: define void @_Z5test2b
+X test2(bool B) {
+ // No NRVO.
+
+ X x;
+ X y;
+ if (B)
+ return y;
+ return x;
+
+ // CHECK: call {{.*}} @_ZN1XC1Ev
+ // CHECK-NEXT: call {{.*}} @_ZN1XC1Ev
+ // CHECK: call {{.*}} @_ZN1XC1ERKS_
+ // CHECK: call {{.*}} @_ZN1XC1ERKS_
+ // CHECK: call {{.*}} @_ZN1XD1Ev
+ // CHECK: call {{.*}} @_ZN1XD1Ev
+ // CHECK: ret void
+
+ // The block ordering in the -fexceptions IR is unfortunate.
+
+ // CHECK-EH: call {{.*}} @_ZN1XC1Ev
+ // CHECK-EH-NEXT: invoke {{.*}} @_ZN1XC1Ev
+ // -> %invoke.cont, %lpad
+
+ // %invoke.cont:
+ // CHECK-EH: br i1
+ // -> %if.then, %if.end
+
+ // %if.then: returning 'x'
+ // CHECK-EH: invoke {{.*}} @_ZN1XC1ERKS_
+ // -> %cleanup, %lpad1
+
+ // %lpad: landing pad for ctor of 'y', dtor of 'y'
+ // CHECK-EH: [[CAUGHTVAL:%.*]] = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-EH-NEXT: cleanup
+ // CHECK-EH-NEXT: extractvalue { i8*, i32 } [[CAUGHTVAL]], 0
+ // CHECK-EH-NEXT: extractvalue { i8*, i32 } [[CAUGHTVAL]], 1
+ // CHECK-EH-NEXT: br label
+ // -> %eh.cleanup
+
+ // %lpad1: landing pad for return copy ctors, EH cleanup for 'y'
+ // CHECK-EH: invoke {{.*}} @_ZN1XD1Ev
+ // -> %eh.cleanup, %terminate.lpad
+
+ // %if.end: returning 'y'
+ // CHECK-EH: invoke {{.*}} @_ZN1XC1ERKS_
+ // -> %cleanup, %lpad1
+
+ // %cleanup: normal cleanup for 'y'
+ // CHECK-EH: invoke {{.*}} @_ZN1XD1Ev
+ // -> %invoke.cont11, %lpad
+
+ // %invoke.cont11: normal cleanup for 'x'
+ // CHECK-EH: call {{.*}} @_ZN1XD1Ev
+ // CHECK-EH-NEXT: ret void
+
+ // %eh.cleanup: EH cleanup for 'x'
+ // CHECK-EH: invoke {{.*}} @_ZN1XD1Ev
+ // -> %invoke.cont17, %terminate.lpad
+
+ // %invoke.cont17: rethrow block for %eh.cleanup.
+ // This really should be elsewhere in the function.
+ // CHECK-EH: resume { i8*, i32 }
+
+ // %terminate.lpad: terminate landing pad.
+ // CHECK-EH: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-EH-NEXT: catch i8* null
+ // CHECK-EH-NEXT: call void @_ZSt9terminatev()
+ // CHECK-EH-NEXT: unreachable
+
+}
+
+X test3(bool B) {
+ // FIXME: We don't manage to apply NRVO here, although we could.
+ {
+ X y;
+ return y;
+ }
+ X x;
+ return x;
+}
+
+extern "C" void exit(int) throw();
+
+// CHECK: define void @_Z5test4b
+X test4(bool B) {
+ {
+ // CHECK: tail call {{.*}} @_ZN1XC1Ev
+ X x;
+ // CHECK: br i1
+ if (B)
+ return x;
+ }
+ // CHECK: tail call {{.*}} @_ZN1XD1Ev
+ // CHECK: tail call void @exit(i32 1)
+ exit(1);
+}
+
+#ifdef __EXCEPTIONS
+// CHECK-EH: define void @_Z5test5
+void may_throw();
+X test5() {
+ try {
+ may_throw();
+ } catch (X x) {
+ // CHECK-EH: invoke {{.*}} @_ZN1XC1ERKS_
+ // CHECK-EH: call void @__cxa_end_catch()
+ // CHECK-EH: ret void
+ return x;
+ }
+}
+#endif
+
+// rdar://problem/10430868
+// CHECK: define void @_Z5test6v
+X test6() {
+ X a __attribute__((aligned(8)));
+ return a;
+ // CHECK: [[A:%.*]] = alloca [[X:%.*]], align 8
+ // CHECK-NEXT: call {{.*}} @_ZN1XC1Ev([[X]]* [[A]])
+ // CHECK-NEXT: call {{.*}} @_ZN1XC1ERKS_([[X]]* {{%.*}}, [[X]]* [[A]])
+ // CHECK-NEXT: call {{.*}} @_ZN1XD1Ev([[X]]* [[A]])
+ // CHECK-NEXT: ret void
+}
diff --git a/clang/test/CodeGenCXX/nullptr.cpp b/clang/test/CodeGenCXX/nullptr.cpp
new file mode 100644
index 0000000..e93f706
--- /dev/null
+++ b/clang/test/CodeGenCXX/nullptr.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -I%S -emit-llvm -o - %s | FileCheck %s
+
+#include <typeinfo>
+
+// CHECK: @_ZTIDn = external constant i8*
+int* a = nullptr;
+
+void f() {
+ int* a = nullptr;
+}
+
+typedef decltype(nullptr) nullptr_t;
+
+nullptr_t get_nullptr();
+
+struct X { };
+void g() {
+ // CHECK: call i8* @_Z11get_nullptrv()
+ int (X::*pmf)(int) = get_nullptr();
+}
+
+const std::type_info& f2() {
+ return typeid(nullptr_t);
+}
diff --git a/clang/test/CodeGenCXX/operator-new.cpp b/clang/test/CodeGenCXX/operator-new.cpp
new file mode 100644
index 0000000..db56cda
--- /dev/null
+++ b/clang/test/CodeGenCXX/operator-new.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -emit-llvm -o %t-1.ll %s
+// RUN: FileCheck -check-prefix SANE --input-file=%t-1.ll %s
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -emit-llvm -fno-assume-sane-operator-new -o %t-2.ll %s
+// RUN: FileCheck -check-prefix SANENOT --input-file=%t-2.ll %s
+
+
+class teste {
+ int A;
+public:
+ teste() : A(2) {}
+};
+
+void f1() {
+ // SANE: declare noalias i8* @_Znwj(
+ // SANENOT: declare i8* @_Znwj(
+ new teste();
+}
+
+
+// rdar://5739832 - operator new should check for overflow in multiply.
+void *f2(long N) {
+ return new int[N];
+
+// SANE: [[UWO:%.*]] = call {{.*}} @llvm.umul.with.overflow
+// SANE-NEXT: [[OVER:%.*]] = extractvalue {{.*}} [[UWO]], 1
+// SANE-NEXT: [[SUM:%.*]] = extractvalue {{.*}} [[UWO]], 0
+// SANE-NEXT: [[RESULT:%.*]] = select i1 [[OVER]], i32 -1, i32 [[SUM]]
+// SANE-NEXT: call noalias i8* @_Znaj(i32 [[RESULT]])
+}
diff --git a/clang/test/CodeGenCXX/overload-binop-implicitconvert.cpp b/clang/test/CodeGenCXX/overload-binop-implicitconvert.cpp
new file mode 100644
index 0000000..0eb7a06
--- /dev/null
+++ b/clang/test/CodeGenCXX/overload-binop-implicitconvert.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -emit-llvm-only
+class T
+{};
+
+void print(const char *t);
+
+T& operator<< (T& t,const char* c)
+{
+ print(c);
+ return t;
+}
+
+
+int main()
+{
+ T t;
+ print("foo");
+ t<<"foo";
+
+ return 0;
+}
+
diff --git a/clang/test/CodeGenCXX/override-layout.cpp b/clang/test/CodeGenCXX/override-layout.cpp
new file mode 100644
index 0000000..d432885
--- /dev/null
+++ b/clang/test/CodeGenCXX/override-layout.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -fdump-record-layouts-simple %s 2> %t.layouts
+// RUN: %clang_cc1 -fdump-record-layouts-simple %s > %t.before 2>&1
+// RUN: %clang_cc1 -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after 2>&1
+// RUN: diff %t.before %t.after
+// RUN: FileCheck %s < %t.after
+
+// If not explicitly disabled, set PACKED to the packed attribute.
+#ifndef PACKED
+# define PACKED __attribute__((packed))
+#endif
+
+struct Empty1 { };
+struct Empty2 { };
+
+// CHECK: Type: struct X0
+struct X0 : public Empty1 {
+ int x[6] PACKED;
+};
+
+// CHECK: Type: struct X1
+struct X1 : public X0, public Empty2 {
+ char x[13];
+ struct X0 y;
+} PACKED;
+
+// CHECK: Type: struct X2
+struct PACKED X2 : public X1, public X0, public Empty1 {
+ short x;
+ int y;
+};
+
+// CHECK: Type: struct X3
+struct PACKED X3 : virtual public X1, public X0 {
+ short x;
+ int y;
+};
+
+// CHECK: Type: struct X4
+struct PACKED X4 {
+ unsigned int a : 1;
+ unsigned int b : 1;
+ unsigned int c : 1;
+ unsigned int d : 1;
+ unsigned int e : 1;
+ unsigned int f : 1;
+ unsigned int g : 1;
+ unsigned int h : 1;
+ unsigned int i : 1;
+ unsigned int j : 1;
+ unsigned int k : 1;
+ unsigned int l : 1;
+ unsigned int m : 1;
+ unsigned int n : 1;
+ X4();
+};
+
+void use_structs() {
+ X0 x0s[sizeof(X0)];
+ X1 x1s[sizeof(X1)];
+ X2 x2s[sizeof(X2)];
+ X3 x3s[sizeof(X3)];
+ X4 x4s[sizeof(X4)];
+ x4s[1].a = 1;
+}
diff --git a/clang/test/CodeGenCXX/partial-destruction.cpp b/clang/test/CodeGenCXX/partial-destruction.cpp
new file mode 100644
index 0000000..f232a15
--- /dev/null
+++ b/clang/test/CodeGenCXX/partial-destruction.cpp
@@ -0,0 +1,172 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s
+
+// Test IR generation for partial destruction of aggregates.
+
+void opaque();
+
+// Initializer lists.
+namespace test0 {
+ struct A { A(int); A(); ~A(); void *v; };
+ void test() {
+ A as[10] = { 5, 7 };
+ opaque();
+ }
+ // CHECK: define void @_ZN5test04testEv()
+ // CHECK: [[AS:%.*]] = alloca [10 x [[A:%.*]]], align
+ // CHECK-NEXT: [[ENDVAR:%.*]] = alloca [[A]]*
+ // CHECK-NEXT: [[EXN:%.*]] = alloca i8*
+ // CHECK-NEXT: [[SEL:%.*]] = alloca i32
+
+ // Initialize.
+ // CHECK-NEXT: [[E_BEGIN:%.*]] = getelementptr inbounds [10 x [[A]]]* [[AS]], i64 0, i64 0
+ // CHECK-NEXT: store [[A]]* [[E_BEGIN]], [[A]]** [[ENDVAR]]
+ // CHECK-NEXT: invoke void @_ZN5test01AC1Ei([[A]]* [[E_BEGIN]], i32 5)
+ // CHECK: [[E1:%.*]] = getelementptr inbounds [[A]]* [[E_BEGIN]], i64 1
+ // CHECK-NEXT: store [[A]]* [[E1]], [[A]]** [[ENDVAR]]
+ // CHECK-NEXT: invoke void @_ZN5test01AC1Ei([[A]]* [[E1]], i32 7)
+ // CHECK: [[E2:%.*]] = getelementptr inbounds [[A]]* [[E1]], i64 1
+ // CHECK-NEXT: store [[A]]* [[E2]], [[A]]** [[ENDVAR]]
+ // CHECK-NEXT: [[E_END:%.*]] = getelementptr inbounds [[A]]* [[E_BEGIN]], i64 10
+ // CHECK-NEXT: br label
+ // CHECK: [[E_CUR:%.*]] = phi [[A]]* [ [[E2]], {{%.*}} ], [ [[E_NEXT:%.*]], {{%.*}} ]
+ // CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[E_CUR]])
+ // CHECK: [[E_NEXT]] = getelementptr inbounds [[A]]* [[E_CUR]], i64 1
+ // CHECK-NEXT: store [[A]]* [[E_NEXT]], [[A]]** [[ENDVAR]]
+ // CHECK-NEXT: [[T0:%.*]] = icmp eq [[A]]* [[E_NEXT]], [[E_END]]
+ // CHECK-NEXT: br i1 [[T0]],
+
+ // Run.
+ // CHECK: invoke void @_Z6opaquev()
+
+ // Normal destroy.
+ // CHECK: [[ED_BEGIN:%.*]] = getelementptr inbounds [10 x [[A]]]* [[AS]], i32 0, i32 0
+ // CHECK-NEXT: [[ED_END:%.*]] = getelementptr inbounds [[A]]* [[ED_BEGIN]], i64 10
+ // CHECK-NEXT: br label
+ // CHECK: [[ED_AFTER:%.*]] = phi [[A]]* [ [[ED_END]], {{%.*}} ], [ [[ED_CUR:%.*]], {{%.*}} ]
+ // CHECK-NEXT: [[ED_CUR]] = getelementptr inbounds [[A]]* [[ED_AFTER]], i64 -1
+ // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[ED_CUR]])
+ // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[ED_CUR]], [[ED_BEGIN]]
+ // CHECK-NEXT: br i1 [[T0]],
+ // CHECK: ret void
+
+ // Partial destroy for initialization.
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-NEXT: cleanup
+ // CHECK: [[PARTIAL_END:%.*]] = load [[A]]** [[ENDVAR]]
+ // CHECK-NEXT: [[T0:%.*]] = icmp eq [[A]]* [[E_BEGIN]], [[PARTIAL_END]]
+ // CHECK-NEXT: br i1 [[T0]],
+ // CHECK: [[E_AFTER:%.*]] = phi [[A]]* [ [[PARTIAL_END]], {{%.*}} ], [ [[E_CUR:%.*]], {{%.*}} ]
+ // CHECK-NEXT: [[E_CUR]] = getelementptr inbounds [[A]]* [[E_AFTER]], i64 -1
+ // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[E_CUR]])
+ // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[E_CUR]], [[E_BEGIN]]
+ // CHECK-NEXT: br i1 [[T0]],
+
+ // Primary EH destructor.
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-NEXT: cleanup
+ // CHECK: [[E0:%.*]] = getelementptr inbounds [10 x [[A]]]* [[AS]], i32 0, i32 0
+ // CHECK-NEXT: [[E_END:%.*]] = getelementptr inbounds [[A]]* [[E0]], i64 10
+ // CHECK-NEXT: br label
+
+ // Partial destructor for primary normal destructor.
+ // FIXME: There's some really bad block ordering here which causes
+ // the partial destroy for the primary normal destructor to fall
+ // within the primary EH destructor.
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-NEXT: cleanup
+ // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[ED_BEGIN]], [[ED_CUR]]
+ // CHECK-NEXT: br i1 [[T0]]
+ // CHECK: [[EDD_AFTER:%.*]] = phi [[A]]* [ [[ED_CUR]], {{%.*}} ], [ [[EDD_CUR:%.*]], {{%.*}} ]
+ // CHECK-NEXT: [[EDD_CUR]] = getelementptr inbounds [[A]]* [[EDD_AFTER]], i64 -1
+ // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[EDD_CUR]])
+ // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[EDD_CUR]], [[ED_BEGIN]]
+ // CHECK-NEXT: br i1 [[T0]]
+
+ // Back to the primary EH destructor.
+ // CHECK: [[E_AFTER:%.*]] = phi [[A]]* [ [[E_END]], {{%.*}} ], [ [[E_CUR:%.*]], {{%.*}} ]
+ // CHECK-NEXT: [[E_CUR]] = getelementptr inbounds [[A]]* [[E_AFTER]], i64 -1
+ // CHECK-NEXT: invoke void @_ZN5test01AD1Ev([[A]]* [[E_CUR]])
+ // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[E_CUR]], [[E0]]
+ // CHECK-NEXT: br i1 [[T0]],
+
+}
+
+namespace test1 {
+ struct A { A(); A(int); ~A(); };
+ struct B { A x, y, z; int w; };
+
+ void test() {
+ B v = { 5, 6, 7, 8 };
+ }
+ // CHECK: define void @_ZN5test14testEv()
+ // CHECK: [[V:%.*]] = alloca [[B:%.*]], align 4
+ // CHECK-NEXT: alloca i8*
+ // CHECK-NEXT: alloca i32
+ // CHECK-NEXT: [[X:%.*]] = getelementptr inbounds [[B]]* [[V]], i32 0, i32 0
+ // CHECK-NEXT: call void @_ZN5test11AC1Ei([[A:%.*]]* [[X]], i32 5)
+ // CHECK-NEXT: [[Y:%.*]] = getelementptr inbounds [[B]]* [[V]], i32 0, i32 1
+ // CHECK-NEXT: invoke void @_ZN5test11AC1Ei([[A]]* [[Y]], i32 6)
+ // CHECK: [[Z:%.*]] = getelementptr inbounds [[B]]* [[V]], i32 0, i32 2
+ // CHECK-NEXT: invoke void @_ZN5test11AC1Ei([[A]]* [[Z]], i32 7)
+ // CHECK: [[W:%.*]] = getelementptr inbounds [[B]]* [[V]], i32 0, i32 3
+ // CHECK-NEXT: store i32 8, i32* [[W]], align 4
+ // CHECK-NEXT: call void @_ZN5test11BD1Ev([[B]]* [[V]])
+ // CHECK-NEXT: ret void
+
+ // FIXME: again, the block ordering is pretty bad here
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-NEXT: cleanup
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-NEXT: cleanup
+ // CHECK: invoke void @_ZN5test11AD1Ev([[A]]* [[Y]])
+ // CHECK: invoke void @_ZN5test11AD1Ev([[A]]* [[X]])
+}
+
+namespace test2 {
+ struct A { A(); ~A(); };
+
+ void test() {
+ A v[4][7];
+
+ // CHECK: define void @_ZN5test24testEv()
+ // CHECK: [[V:%.*]] = alloca [4 x [7 x [[A:%.*]]]], align 1
+ // CHECK-NEXT: alloca i8*
+ // CHECK-NEXT: alloca i32
+
+ // Main initialization loop.
+ // CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [4 x [7 x [[A]]]]* [[V]], i32 0, i32 0, i32 0
+ // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 28
+ // CHECK-NEXT: br label
+ // CHECK: [[CUR:%.*]] = phi [[A]]* [ [[BEGIN]], {{%.*}} ], [ [[NEXT:%.*]], {{%.*}} ]
+ // CHECK-NEXT: invoke void @_ZN5test21AC1Ev([[A]]* [[CUR]])
+ // CHECK: [[NEXT:%.*]] = getelementptr inbounds [[A]]* [[CUR]], i64 1
+ // CHECK-NEXT: [[DONE:%.*]] = icmp eq [[A]]* [[NEXT]], [[END]]
+ // CHECK-NEXT: br i1 [[DONE]],
+
+ // Partial destruction landing pad.
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-NEXT: cleanup
+ // CHECK: [[EMPTY:%.*]] = icmp eq [[A]]* [[BEGIN]], [[CUR]]
+ // CHECK-NEXT: br i1 [[EMPTY]],
+ // CHECK: [[PAST:%.*]] = phi [[A]]* [ [[CUR]], {{%.*}} ], [ [[DEL:%.*]], {{%.*}} ]
+ // CHECK-NEXT: [[DEL]] = getelementptr inbounds [[A]]* [[PAST]], i64 -1
+ // CHECK-NEXT: invoke void @_ZN5test21AD1Ev([[A]]* [[DEL]])
+ // CHECK: [[T0:%.*]] = icmp eq [[A]]* [[DEL]], [[BEGIN]]
+ // CHECK-NEXT: br i1 [[T0]],
+ }
+
+}
+
+// PR10351
+namespace test3 {
+ struct A { A(); ~A(); void *p; };
+ struct B {
+ B() {}
+ A a;
+ };
+
+ B *test() {
+ return new B[10];
+ // invoke void @_ZN5test31BD1Ev(
+ }
+}
diff --git a/clang/test/CodeGenCXX/pointers-to-data-members.cpp b/clang/test/CodeGenCXX/pointers-to-data-members.cpp
new file mode 100644
index 0000000..90024e4
--- /dev/null
+++ b/clang/test/CodeGenCXX/pointers-to-data-members.cpp
@@ -0,0 +1,242 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t.ll -triple=x86_64-apple-darwin10
+// RUN: FileCheck %s < %t.ll
+// RUN: FileCheck -check-prefix=CHECK-GLOBAL %s < %t.ll
+// RUN: %clang_cc1 %s -emit-llvm -o %t-opt.ll -triple=x86_64-apple-darwin10 -O3
+// RUN: FileCheck --check-prefix=CHECK-O3 %s < %t-opt.ll
+
+struct A { int a; int b; };
+struct B { int b; };
+struct C : B, A { };
+
+// Zero init.
+namespace ZeroInit {
+ // CHECK-GLOBAL: @_ZN8ZeroInit1aE = global i64 -1
+ int A::* a;
+
+ // CHECK-GLOBAL: @_ZN8ZeroInit2aaE = global [2 x i64] [i64 -1, i64 -1]
+ int A::* aa[2];
+
+ // CHECK-GLOBAL: @_ZN8ZeroInit3aaaE = global [2 x [2 x i64]] {{\[}}[2 x i64] [i64 -1, i64 -1], [2 x i64] [i64 -1, i64 -1]]
+ int A::* aaa[2][2];
+
+ // CHECK-GLOBAL: @_ZN8ZeroInit1bE = global i64 -1,
+ int A::* b = 0;
+
+ // CHECK-GLOBAL: @_ZN8ZeroInit2saE = internal global %struct.anon { i64 -1 }
+ struct {
+ int A::*a;
+ } sa;
+ void test_sa() { (void) sa; } // force emission
+
+ // CHECK-GLOBAL: @_ZN8ZeroInit3ssaE = internal
+ // CHECK-GLOBAL: [2 x i64] [i64 -1, i64 -1]
+ struct {
+ int A::*aa[2];
+ } ssa[2];
+ void test_ssa() { (void) ssa; }
+
+ // CHECK-GLOBAL: @_ZN8ZeroInit2ssE = internal global %struct.anon.1 { %struct.anon.2 { i64 -1 } }
+ struct {
+ struct {
+ int A::*pa;
+ } s;
+ } ss;
+ void test_ss() { (void) ss; }
+
+ struct A {
+ int A::*a;
+ int b;
+ };
+
+ struct B {
+ A a[10];
+ char c;
+ int B::*b;
+ };
+
+ struct C : A, B { int j; };
+ // CHECK-GLOBAL: @_ZN8ZeroInit1cE = global {{%.*}} { %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::B" { [10 x %"struct.ZeroInit::A"] [%"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }, %"struct.ZeroInit::A" { i64 -1, i32 0 }], i8 0, i64 -1 }, i32 0 }, align 8
+ C c;
+}
+
+// PR5674
+namespace PR5674 {
+ // CHECK-GLOBAL: @_ZN6PR56742pbE = global i64 4
+ int A::*pb = &A::b;
+}
+
+// Casts.
+namespace Casts {
+
+int A::*pa;
+int C::*pc;
+
+void f() {
+ // CHECK: store i64 -1, i64* @_ZN5Casts2paE
+ pa = 0;
+
+ // CHECK-NEXT: [[TMP:%.*]] = load i64* @_ZN5Casts2paE, align 8
+ // CHECK-NEXT: [[ADJ:%.*]] = add nsw i64 [[TMP]], 4
+ // CHECK-NEXT: [[ISNULL:%.*]] = icmp eq i64 [[TMP]], -1
+ // CHECK-NEXT: [[RES:%.*]] = select i1 [[ISNULL]], i64 [[TMP]], i64 [[ADJ]]
+ // CHECK-NEXT: store i64 [[RES]], i64* @_ZN5Casts2pcE
+ pc = pa;
+
+ // CHECK-NEXT: [[TMP:%.*]] = load i64* @_ZN5Casts2pcE, align 8
+ // CHECK-NEXT: [[ADJ:%.*]] = sub nsw i64 [[TMP]], 4
+ // CHECK-NEXT: [[ISNULL:%.*]] = icmp eq i64 [[TMP]], -1
+ // CHECK-NEXT: [[RES:%.*]] = select i1 [[ISNULL]], i64 [[TMP]], i64 [[ADJ]]
+ // CHECK-NEXT: store i64 [[RES]], i64* @_ZN5Casts2paE
+ pa = static_cast<int A::*>(pc);
+}
+
+}
+
+// Comparisons
+namespace Comparisons {
+ void f() {
+ int A::*a;
+
+ // CHECK: icmp ne i64 {{.*}}, -1
+ if (a) { }
+
+ // CHECK: icmp ne i64 {{.*}}, -1
+ if (a != 0) { }
+
+ // CHECK: icmp ne i64 -1, {{.*}}
+ if (0 != a) { }
+
+ // CHECK: icmp eq i64 {{.*}}, -1
+ if (a == 0) { }
+
+ // CHECK: icmp eq i64 -1, {{.*}}
+ if (0 == a) { }
+ }
+}
+
+namespace ValueInit {
+
+struct A {
+ int A::*a;
+
+ char c;
+
+ A();
+};
+
+// CHECK: define void @_ZN9ValueInit1AC2Ev(%"struct.ValueInit::A"* %this) unnamed_addr
+// CHECK: store i64 -1, i64*
+// CHECK: ret void
+A::A() : a() {}
+
+}
+
+namespace PR7139 {
+
+struct pair {
+ int first;
+ int second;
+};
+
+typedef int pair::*ptr_to_member_type;
+
+struct ptr_to_member_struct {
+ ptr_to_member_type data;
+ int i;
+};
+
+struct A {
+ ptr_to_member_struct a;
+
+ A() : a() {}
+};
+
+// CHECK-O3: define zeroext i1 @_ZN6PR71395checkEv() nounwind readnone
+bool check() {
+ // CHECK-O3: ret i1 true
+ return A().a.data == 0;
+}
+
+// CHECK-O3: define zeroext i1 @_ZN6PR71396check2Ev() nounwind readnone
+bool check2() {
+ // CHECK-O3: ret i1 true
+ return ptr_to_member_type() == 0;
+}
+
+}
+
+namespace VirtualBases {
+
+struct A {
+ char c;
+ int A::*i;
+};
+
+// CHECK-GLOBAL: @_ZN12VirtualBases1bE = global %"struct.VirtualBases::B" { i32 (...)** null, %"struct.VirtualBases::A" { i8 0, i64 -1 } }, align 8
+struct B : virtual A { };
+B b;
+
+// CHECK-GLOBAL: @_ZN12VirtualBases1cE = global %"struct.VirtualBases::C" { i32 (...)** null, i64 -1, %"struct.VirtualBases::A" { i8 0, i64 -1 } }, align 8
+struct C : virtual A { int A::*i; };
+C c;
+
+// CHECK-GLOBAL: @_ZN12VirtualBases1dE = global %"struct.VirtualBases::D" { %"struct.VirtualBases::C.base" { i32 (...)** null, i64 -1 }, i64 -1, %"struct.VirtualBases::A" { i8 0, i64 -1 } }, align 8
+struct D : C { int A::*i; };
+D d;
+
+}
+
+namespace Test1 {
+
+// Don't crash when A contains a bit-field.
+struct A {
+ int A::* a;
+ int b : 10;
+};
+A a;
+
+}
+
+namespace BoolPtrToMember {
+ struct X {
+ bool member;
+ };
+
+ // CHECK: define i8* @_ZN15BoolPtrToMember1fERNS_1XEMS0_b
+ bool &f(X &x, bool X::*member) {
+ // CHECK: {{bitcast.* to i8\*}}
+ // CHECK-NEXT: getelementptr inbounds i8*
+ // CHECK-NEXT: ret i8*
+ return x.*member;
+ }
+}
+
+namespace PR8507 {
+
+struct S;
+void f(S* p, double S::*pm) {
+ if (0 < p->*pm) {
+ }
+}
+
+}
+
+namespace test4 {
+ struct A { int A_i; };
+ struct B : virtual A { int A::*B_p; };
+ struct C : virtual B { int *C_p; };
+ struct D : C { int *D_p; };
+
+ // CHECK-GLOBAL: @_ZN5test41dE = global %"struct.test4::D" { %"struct.test4::C.base" zeroinitializer, i32* null, %"struct.test4::B.base" { i32 (...)** null, i64 -1 }, %"struct.test4::A" zeroinitializer }, align 8
+ D d;
+}
+
+namespace PR11487 {
+ union U
+ {
+ int U::* mptr;
+ char x[16];
+ } x;
+ // CHECK-GLOBAL: @_ZN7PR114871xE = global %"union.PR11487::U" { i64 -1, [8 x i8] zeroinitializer }, align 8
+
+}
diff --git a/clang/test/CodeGenCXX/pr11676.cpp b/clang/test/CodeGenCXX/pr11676.cpp
new file mode 100644
index 0000000..896751a
--- /dev/null
+++ b/clang/test/CodeGenCXX/pr11676.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -std=c++11 -emit-llvm-only
+// CHECK that we don't crash.
+
+// PR11676's example is ill-formed:
+/*
+union _XEvent {
+};
+void ProcessEvent() {
+ _XEvent pluginEvent = _XEvent();
+}
+*/
+
+// Example from PR11665:
+void f() {
+ union U { int field; } u = U();
+ (void)U().field;
+}
diff --git a/clang/test/CodeGenCXX/pr11797.cpp b/clang/test/CodeGenCXX/pr11797.cpp
new file mode 100644
index 0000000..05221ac
--- /dev/null
+++ b/clang/test/CodeGenCXX/pr11797.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -fvisibility hidden -emit-llvm -o - | FileCheck %s
+
+namespace std __attribute__ ((__visibility__ ("default"))) {}
+#pragma GCC visibility push(default)
+void foo() {
+}
+#pragma GCC visibility pop
+// CHECK: define void @_Z3foov()
diff --git a/clang/test/CodeGenCXX/pr12104.cpp b/clang/test/CodeGenCXX/pr12104.cpp
new file mode 100644
index 0000000..a62f04b
--- /dev/null
+++ b/clang/test/CodeGenCXX/pr12104.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -include %S/pr12104.h %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -emit-pch -o %t %S/pr12104.h
+// RUN: %clang_cc1 -include-pch %t %s -emit-llvm -o - | FileCheck %s
+
+template struct Patch<1>;
+
+// CHECK: _ZN5PatchILi1EE11no_neighborE
diff --git a/clang/test/CodeGenCXX/pr12104.h b/clang/test/CodeGenCXX/pr12104.h
new file mode 100644
index 0000000..f3e9363
--- /dev/null
+++ b/clang/test/CodeGenCXX/pr12104.h
@@ -0,0 +1,9 @@
+template <int dimm> struct Patch {
+ static const unsigned int no_neighbor = 1;
+};
+template <int dim>
+const unsigned int Patch<dim>::no_neighbor;
+void f(const unsigned int);
+void g() {
+ f(Patch<1>::no_neighbor);
+}
diff --git a/clang/test/CodeGenCXX/pr12251.cpp b/clang/test/CodeGenCXX/pr12251.cpp
new file mode 100644
index 0000000..a9920c0
--- /dev/null
+++ b/clang/test/CodeGenCXX/pr12251.cpp
@@ -0,0 +1,146 @@
+// RUN: %clang_cc1 %s -emit-llvm -O1 -relaxed-aliasing -fstrict-enums -std=c++11 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -O1 -relaxed-aliasing -std=c++11 -o - | FileCheck --check-prefix=NO-STRICT-ENUMS %s
+
+bool f(bool *x) {
+ return *x;
+}
+// CHECK: define zeroext i1 @_Z1fPb
+// CHECK: load i8* %{{.*}}, align 1, !range !0
+
+// Only enum-tests follow. Ensure that after the bool test, no further range
+// metadata shows up when strict enums are disabled.
+// NO-STRICT-ENUMS: define zeroext i1 @_Z1fPb
+// NO-STRICT-ENUMS: load i8* %{{.*}}, align 1, !range !0
+// NO-STRICT-ENUMS-NOT: !range
+
+enum e1 { };
+e1 g1(e1 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g1P2e1
+// CHECK: load i32* %x, align 4, !range !1
+
+enum e2 { e2_a = 0 };
+e2 g2(e2 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g2P2e2
+// CHECK: load i32* %x, align 4, !range !1
+
+enum e3 { e3_a = 16 };
+e3 g3(e3 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g3P2e3
+// CHECK: load i32* %x, align 4, !range !2
+
+enum e4 { e4_a = -16};
+e4 g4(e4 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g4P2e4
+// CHECK: load i32* %x, align 4, !range !3
+
+enum e5 { e5_a = -16, e5_b = 16};
+e5 g5(e5 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g5P2e5
+// CHECK: load i32* %x, align 4, !range !4
+
+enum e6 { e6_a = -1 };
+e6 g6(e6 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g6P2e6
+// CHECK: load i32* %x, align 4, !range !5
+
+enum e7 { e7_a = -16, e7_b = 2};
+e7 g7(e7 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g7P2e7
+// CHECK: load i32* %x, align 4, !range !3
+
+enum e8 { e8_a = -17};
+e8 g8(e8 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g8P2e8
+// CHECK: load i32* %x, align 4, !range !4
+
+enum e9 { e9_a = 17};
+e9 g9(e9 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g9P2e9
+// CHECK: load i32* %x, align 4, !range !2
+
+enum e10 { e10_a = -16, e10_b = 32};
+e10 g10(e10 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z3g10P3e10
+// CHECK: load i32* %x, align 4, !range !6
+
+enum e11 {e11_a = 4294967296 };
+enum e11 g11(enum e11 *x) {
+ return *x;
+}
+// CHECK: define i64 @_Z3g11P3e11
+// CHECK: load i64* %x, align {{[84]}}, !range !7
+
+enum e12 {e12_a = 9223372036854775808U };
+enum e12 g12(enum e12 *x) {
+ return *x;
+}
+// CHECK: define i64 @_Z3g12P3e12
+// CHECK: load i64* %x, align {{[84]}}
+// CHECK-NOT: range
+// CHECK: ret
+
+enum e13 : char {e13_a = -1 };
+e13 g13(e13 *x) {
+ return *x;
+}
+// CHECK: define signext i8 @_Z3g13P3e13
+// CHECK: load i8* %x, align 1
+// CHECK-NOT: range
+// CHECK: ret
+
+enum class e14 {e14_a = 1};
+e14 g14(e14 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z3g14P3e14
+// CHECK: load i32* %x, align 4
+// CHECK-NOT: range
+// CHECK: ret
+
+enum e15 { e15_a = 2147483648 };
+e15 g15(e15 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z3g15P3e15
+// CHECK: load i32* %x, align 4
+// CHECK-NOT: range
+// CHECK: ret
+
+enum e16 { e16_a = -2147483648 };
+e16 g16(e16 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z3g16P3e16
+// CHECK: load i32* %x, align 4
+// CHECK-NOT: range
+// CHECK: ret
+
+
+// CHECK: !0 = metadata !{i8 0, i8 2}
+// CHECK: !1 = metadata !{i32 0, i32 1}
+// CHECK: !2 = metadata !{i32 0, i32 32}
+// CHECK: !3 = metadata !{i32 -16, i32 16}
+// CHECK: !4 = metadata !{i32 -32, i32 32}
+// CHECK: !5 = metadata !{i32 -1, i32 1}
+// CHECK: !6 = metadata !{i32 -64, i32 64}
+// CHECK: !7 = metadata !{i64 0, i64 8589934592}
diff --git a/clang/test/CodeGenCXX/pr9130.cpp b/clang/test/CodeGenCXX/pr9130.cpp
new file mode 100644
index 0000000..b28f394
--- /dev/null
+++ b/clang/test/CodeGenCXX/pr9130.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+class nsOggCodecState {
+ virtual int StartTime() {
+ return -1;
+ }
+};
+class nsVorbisState : public nsOggCodecState {
+ virtual ~nsVorbisState();
+};
+nsVorbisState::~nsVorbisState() {
+}
+
+// CHECK: define linkonce_odr i32 @_ZN15nsOggCodecState9StartTimeEv
diff --git a/clang/test/CodeGenCXX/pr9965.cpp b/clang/test/CodeGenCXX/pr9965.cpp
new file mode 100644
index 0000000..0d267ff
--- /dev/null
+++ b/clang/test/CodeGenCXX/pr9965.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s | FileCheck %s
+struct A { A(); };
+template<typename T>
+struct X : A // default constructor is not trivial
+{
+ X() = default;
+ ~X() {} // not a literal type
+};
+
+X<int> x;
+// CHECK: define internal void @__cxx_global_var_init()
+// CHECK: call {{.*}} @_ZN1XIiEC1Ev
+// CHECK: define linkonce_odr {{.*}} @_ZN1XIiEC1Ev
+// CHECK: define linkonce_odr {{.*}} @_ZN1XIiEC2Ev
diff --git a/clang/test/CodeGenCXX/pragma-pack-2.cpp b/clang/test/CodeGenCXX/pragma-pack-2.cpp
new file mode 100644
index 0000000..9c09d5b
--- /dev/null
+++ b/clang/test/CodeGenCXX/pragma-pack-2.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.2 %s -emit-llvm -o - | FileCheck %s
+// <rdar://problem/10551376>
+
+struct FOO {
+ unsigned int x;
+};
+
+#pragma pack(push, 2)
+
+// CHECK: %struct.BAR = type <{ %struct.FOO, i8, i8 }>
+struct BAR : FOO {
+ char y;
+};
+
+#pragma pack(pop)
+
+BAR* x = 0; \ No newline at end of file
diff --git a/clang/test/CodeGenCXX/pragma-pack.cpp b/clang/test/CodeGenCXX/pragma-pack.cpp
new file mode 100644
index 0000000..c0b0259
--- /dev/null
+++ b/clang/test/CodeGenCXX/pragma-pack.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -triple=i686-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+struct Base {
+ virtual ~Base();
+ int x;
+};
+
+#pragma pack(1)
+struct Sub : virtual Base {
+ char c;
+};
+
+// CHECK: %struct.Sub = type <{ i32 (...)**, i8, %struct.Base }>
+void f(Sub*) { }
+
+static int i[sizeof(Sub) == 13 ? 1 : -1];
diff --git a/clang/test/CodeGenCXX/pragma-visibility.cpp b/clang/test/CodeGenCXX/pragma-visibility.cpp
new file mode 100644
index 0000000..e54626e
--- /dev/null
+++ b/clang/test/CodeGenCXX/pragma-visibility.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+#pragma GCC visibility push(hidden)
+struct x {
+ static int y;
+};
+#pragma GCC visibility pop
+int x::y = 10;
+// CHECK: @_ZN1x1yE = hidden global
+
+#pragma GCC visibility push(hidden)
+struct __attribute((visibility("default"))) x2 {
+ static int y;
+};
+int x2::y = 10;
+// CHECK: @_ZN2x21yE = global
+#pragma GCC visibility pop
+
+#pragma GCC visibility push(hidden)
+struct x3 {
+ static int y;
+} __attribute((visibility("default")));
+int x3::y = 10;
+// CHECK: @_ZN2x31yE = global
+#pragma GCC visibility pop
+
+#pragma GCC visibility push(hidden)
+template<class T> struct x4 {
+ static int y;
+};
+#pragma GCC visibility pop
+template<> int x4<int>::y = 10;
+// CHECK: @_ZN2x4IiE1yE = hidden global i32
+
+#pragma GCC visibility push(hidden)
+template<int x> int f() { return x; }
+extern "C" int g() { return f<3>(); }
+#pragma GCC visibility pop
+// CHECK: define hidden i32 @g()
+// CHECK: define linkonce_odr hidden i32 @_Z1fILi3EEiv()
+
+#pragma GCC visibility push(hidden)
+template<class T> struct x5 {
+ void y();
+};
+#pragma GCC visibility pop
+template<> void x5<int>::y() {}
+// CHECK: define hidden void @_ZN2x5IiE1yEv
+
+#pragma GCC visibility push(hidden)
+namespace n __attribute((visibility("default"))) {
+ void f() {}
+ // CHECK: define void @_ZN1n1fEv
+}
+#pragma GCC visibility pop
+
+namespace n __attribute((visibility("default"))) {
+#pragma GCC visibility push(hidden)
+ void g() {}
+ // CHECK: define hidden void @_ZN1n1gEv
+#pragma GCC visibility pop
+}
diff --git a/clang/test/CodeGenCXX/predefined-expr-sizeof.cpp b/clang/test/CodeGenCXX/predefined-expr-sizeof.cpp
new file mode 100644
index 0000000..b4712ad
--- /dev/null
+++ b/clang/test/CodeGenCXX/predefined-expr-sizeof.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: store i32 59, i32* %size
+// CHECK: store i32 65, i32* %size
+template<typename T>
+class TemplateClass {
+public:
+ void templateClassFunction() {
+ int size = sizeof(__PRETTY_FUNCTION__);
+ }
+};
+
+// CHECK: store i32 35, i32* %size
+// CHECK: store i32 38, i32* %size
+template<typename T>
+void functionTemplate(T t) {
+ int size = sizeof(__PRETTY_FUNCTION__);
+}
+
+int main() {
+ TemplateClass<int> t1;
+ t1.templateClassFunction();
+ TemplateClass<double> t2;
+ t2.templateClassFunction();
+
+ functionTemplate<int>(0);
+ functionTemplate(0.0);
+
+ return 0;
+}
diff --git a/clang/test/CodeGenCXX/predefined-expr.cpp b/clang/test/CodeGenCXX/predefined-expr.cpp
new file mode 100644
index 0000000..1795ec8
--- /dev/null
+++ b/clang/test/CodeGenCXX/predefined-expr.cpp
@@ -0,0 +1,517 @@
+// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: private unnamed_addr constant [15 x i8] c"externFunction\00"
+// CHECK: private unnamed_addr constant [26 x i8] c"void NS::externFunction()\00"
+// CHECK: private unnamed_addr constant [49 x i8] c"void functionTemplateExplicitSpecialization(int)\00"
+
+// CHECK: private unnamed_addr constant [95 x i8] c"void SpecializedClassTemplate<char>::memberFunctionTemplate(T, U) const [T = char, U = double]\00"
+// CHECK: private unnamed_addr constant [85 x i8] c"void SpecializedClassTemplate<int>::memberFunctionTemplate(int, U) const [U = float]\00"
+// CHECK: private unnamed_addr constant [57 x i8] c"void NonTypeTemplateParam<42>::size() const [Count = 42]\00"
+// CHECK: private unnamed_addr constant [122 x i8] c"static void ClassWithTemplateTemplateParam<char, NS::ClassTemplate>::staticMember() [T = char, Param = NS::ClassTemplate]\00"
+// CHECK: private unnamed_addr constant [106 x i8] c"void OuterClass<int *>::MiddleClass::InnerClass<float>::memberFunction(T, U) const [T = int *, U = float]\00"
+// CHECK: private unnamed_addr constant [65 x i8] c"void functionTemplateWithUnnamedTemplateParameter(T) [T = float]\00"
+
+// CHECK: private unnamed_addr constant [60 x i8] c"void functionTemplateExplicitSpecialization(T) [T = double]\00"
+// CHECK: private unnamed_addr constant [52 x i8] c"T *functionTemplateWithCompoundTypes(T *) [T = int]\00"
+// CHECK: private unnamed_addr constant [54 x i8] c"T functionTemplateWithTemplateReturnType() [T = char]\00"
+// CHECK: private unnamed_addr constant [57 x i8] c"void functionTemplateWithoutParameterList() [T = double]\00"
+// CHECK: private unnamed_addr constant [62 x i8] c"void functionTemplateWithTwoParams(T, U) [T = int, U = float]\00"
+
+// CHECK: private unnamed_addr constant [22 x i8] c"classTemplateFunction\00"
+// CHECK: private unnamed_addr constant [77 x i8] c"void NS::ClassTemplate<NS::Base *>::classTemplateFunction() [T = NS::Base *]\00"
+// CHECK: private unnamed_addr constant [63 x i8] c"void NS::ClassTemplate<int>::classTemplateFunction() [T = int]\00"
+
+// CHECK: private unnamed_addr constant [18 x i8] c"functionTemplate1\00"
+// CHECK: private unnamed_addr constant [53 x i8] c"void NS::Base::functionTemplate1(T) [T = NS::Base *]\00"
+// CHECK: private unnamed_addr constant [46 x i8] c"void NS::Base::functionTemplate1(T) [T = int]\00"
+
+// CHECK: private unnamed_addr constant [23 x i8] c"anonymousUnionFunction\00"
+// CHECK: private unnamed_addr constant [83 x i8] c"void NS::ContainerForAnonymousRecords::<anonymous union>::anonymousUnionFunction()\00"
+
+// CHECK: private unnamed_addr constant [24 x i8] c"anonymousStructFunction\00"
+// CHECK: private unnamed_addr constant [85 x i8] c"void NS::ContainerForAnonymousRecords::<anonymous struct>::anonymousStructFunction()\00"
+
+// CHECK: private unnamed_addr constant [23 x i8] c"anonymousClassFunction\00"
+// CHECK: private unnamed_addr constant [83 x i8] c"void NS::ContainerForAnonymousRecords::<anonymous class>::anonymousClassFunction()\00"
+
+// CHECK: private unnamed_addr constant [12 x i8] c"~Destructor\00"
+// CHECK: private unnamed_addr constant [30 x i8] c"NS::Destructor::~Destructor()\00"
+
+// CHECK: private unnamed_addr constant [12 x i8] c"Constructor\00"
+// CHECK: private unnamed_addr constant [41 x i8] c"NS::Constructor::Constructor(NS::Base *)\00"
+// CHECK: private unnamed_addr constant [34 x i8] c"NS::Constructor::Constructor(int)\00"
+// CHECK: private unnamed_addr constant [31 x i8] c"NS::Constructor::Constructor()\00"
+
+// CHECK: private unnamed_addr constant [16 x i8] c"virtualFunction\00"
+// CHECK: private unnamed_addr constant [44 x i8] c"virtual void NS::Derived::virtualFunction()\00"
+
+// CHECK: private unnamed_addr constant [21 x i8] c"refQualifiedFunction\00"
+// CHECK: private unnamed_addr constant [41 x i8] c"void NS::Base::refQualifiedFunction() &&\00"
+// CHECK: private unnamed_addr constant [40 x i8] c"void NS::Base::refQualifiedFunction() &\00"
+
+// CHECK: private unnamed_addr constant [22 x i8] c"constVolatileFunction\00"
+// CHECK: private unnamed_addr constant [54 x i8] c"void NS::Base::constVolatileFunction() const volatile\00"
+
+// CHECK: private unnamed_addr constant [17 x i8] c"volatileFunction\00"
+// CHECK: private unnamed_addr constant [43 x i8] c"void NS::Base::volatileFunction() volatile\00"
+
+// CHECK: private unnamed_addr constant [14 x i8] c"constFunction\00"
+// CHECK: private unnamed_addr constant [37 x i8] c"void NS::Base::constFunction() const\00"
+
+// CHECK: private unnamed_addr constant [26 x i8] c"functionReturingTemplate2\00"
+// CHECK: private unnamed_addr constant [64 x i8] c"ClassTemplate<NS::Base *> NS::Base::functionReturingTemplate2()\00"
+
+// CHECK: private unnamed_addr constant [26 x i8] c"functionReturingTemplate1\00"
+// CHECK: private unnamed_addr constant [57 x i8] c"ClassTemplate<int> NS::Base::functionReturingTemplate1()\00"
+
+// CHECK: private unnamed_addr constant [23 x i8] c"withTemplateParameter2\00"
+// CHECK: private unnamed_addr constant [65 x i8] c"void NS::Base::withTemplateParameter2(ClassTemplate<NS::Base *>)\00"
+
+// CHECK: private unnamed_addr constant [23 x i8] c"withTemplateParameter1\00"
+// CHECK: private unnamed_addr constant [58 x i8] c"void NS::Base::withTemplateParameter1(ClassTemplate<int>)\00"
+
+// CHECK: private unnamed_addr constant [23 x i8] c"functionReturningClass\00"
+// CHECK: private unnamed_addr constant [45 x i8] c"NS::Base *NS::Base::functionReturningClass()\00"
+
+// CHECK: private unnamed_addr constant [23 x i8] c"functionWithParameters\00"
+// CHECK: private unnamed_addr constant [64 x i8] c"void NS::Base::functionWithParameters(int, float *, NS::Base *)\00"
+
+// CHECK: private unnamed_addr constant [17 x i8] c"variadicFunction\00"
+// CHECK: private unnamed_addr constant [42 x i8] c"void NS::Base::variadicFunction(int, ...)\00"
+
+// CHECK: private unnamed_addr constant [41 x i8] c"virtual void NS::Base::virtualFunction()\00"
+
+// CHECK: private unnamed_addr constant [15 x i8] c"inlineFunction\00"
+// CHECK: private unnamed_addr constant [32 x i8] c"void NS::Base::inlineFunction()\00"
+
+// CHECK: private unnamed_addr constant [15 x i8] c"staticFunction\00"
+// CHECK: private unnamed_addr constant [39 x i8] c"static void NS::Base::staticFunction()\00"
+
+// CHECK: private unnamed_addr constant [26 x i8] c"topLevelNamespaceFunction\00"
+// CHECK: private unnamed_addr constant [59 x i8] c"void ClassInTopLevelNamespace::topLevelNamespaceFunction()\00"
+
+// CHECK: private unnamed_addr constant [27 x i8] c"anonymousNamespaceFunction\00"
+// CHECK: private unnamed_addr constant [84 x i8] c"void <anonymous namespace>::ClassInAnonymousNamespace::anonymousNamespaceFunction()\00"
+
+// CHECK: private unnamed_addr constant [19 x i8] c"localClassFunction\00"
+// CHECK: private unnamed_addr constant [59 x i8] c"void NS::localClass(int)::LocalClass::localClassFunction()\00"
+
+
+
+int printf(const char * _Format, ...);
+
+class ClassInTopLevelNamespace {
+public:
+ void topLevelNamespaceFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+};
+
+namespace {
+
+ class ClassInAnonymousNamespace {
+ public:
+ void anonymousNamespaceFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+ };
+
+} // end anonymous namespace
+
+namespace NS {
+
+template<typename T>
+class ClassTemplate {
+public:
+ void classTemplateFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+};
+
+class Base {
+public:
+ static void staticFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ inline void inlineFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ virtual void virtualFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ void functionWithParameters(int, float*, Base* base) {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ Base *functionReturningClass() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ return 0;
+ }
+
+ void variadicFunction(int, ...) {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ void withTemplateParameter1(ClassTemplate<int>) {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ void withTemplateParameter2(ClassTemplate<Base *>) {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ ClassTemplate<int> functionReturingTemplate1() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ return ClassTemplate<int>();
+ }
+
+ ClassTemplate<Base *> functionReturingTemplate2() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ return ClassTemplate<Base *>();
+ }
+
+ template<typename T>
+ void functionTemplate1(T t) {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ void constFunction() const {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ void volatileFunction() volatile {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ void constVolatileFunction() const volatile {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ void refQualifiedFunction() & {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ void refQualifiedFunction() && {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+};
+
+class Derived : public Base {
+public:
+ // Virtual function without being explicitly written.
+ void virtualFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+};
+
+class Constructor {
+public:
+ Constructor() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ Constructor(int) {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ Constructor(Base *) {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+};
+
+class Destructor {
+public:
+ ~Destructor() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+};
+
+class ContainerForAnonymousRecords {
+public:
+ class {
+ public:
+ void anonymousClassFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+ } anonymousClass;
+
+ struct {
+ void anonymousStructFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+ } anonymousStruct;
+
+ union {
+ void anonymousUnionFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+ } anonymousUnion;
+};
+
+void localClass(int) {
+ class LocalClass {
+ public:
+ void localClassFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+ };
+ LocalClass lc;
+ lc.localClassFunction();
+}
+
+extern void externFunction() {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+} // end NS namespace
+
+// additional tests for __PRETTY_FUNCTION__
+template <typename T, typename U>
+void functionTemplateWithTwoParams(T, U)
+{
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+template <typename T>
+void functionTemplateWithoutParameterList()
+{
+ T t = T();
+
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+template <typename T>
+T functionTemplateWithTemplateReturnType()
+{
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+
+ return T();
+}
+
+template <typename T>
+T * functionTemplateWithCompoundTypes(T a[])
+{
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+
+ return 0;
+}
+
+template <typename T>
+void functionTemplateExplicitSpecialization(T t)
+{
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+template <>
+void functionTemplateExplicitSpecialization<int>(int i)
+{
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+template <typename, typename T>
+void functionTemplateWithUnnamedTemplateParameter(T t)
+{
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+template <typename T>
+class OuterClass
+{
+public:
+ class MiddleClass
+ {
+ public:
+ template <typename U>
+ class InnerClass
+ {
+ public:
+ void memberFunction(T x, U y) const
+ {
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+ };
+ };
+};
+
+template <typename T, template <typename> class Param = NS::ClassTemplate>
+class ClassWithTemplateTemplateParam
+{
+public:
+ static void staticMember()
+ {
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+};
+
+template <int Count>
+class NonTypeTemplateParam
+{
+public:
+ void size() const
+ {
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+};
+
+template <typename T>
+class SpecializedClassTemplate
+{
+public:
+ template <typename U>
+ void memberFunctionTemplate(T t, U u) const
+ {
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+};
+
+template <>
+class SpecializedClassTemplate<int>
+{
+public:
+ template <typename U>
+ void memberFunctionTemplate(int i, U u) const
+ {
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+};
+
+int main() {
+ ClassInAnonymousNamespace anonymousNamespace;
+ anonymousNamespace.anonymousNamespaceFunction();
+
+ ClassInTopLevelNamespace topLevelNamespace;
+ topLevelNamespace.topLevelNamespaceFunction();
+
+ NS::Base::staticFunction();
+
+ NS::Base b;
+ b.inlineFunction();
+ b.virtualFunction();
+ b.variadicFunction(0);
+ b.functionWithParameters(0, 0, 0);
+ b.functionReturningClass();
+
+ b.withTemplateParameter1(NS::ClassTemplate<int>());
+ b.withTemplateParameter2(NS::ClassTemplate<NS::Base *>());
+ b.functionReturingTemplate1();
+ b.functionReturingTemplate2();
+ b.functionTemplate1<int>(0);
+ b.functionTemplate1<NS::Base *>(0);
+ b.constFunction();
+ b.volatileFunction();
+ b.constVolatileFunction();
+ b.refQualifiedFunction();
+ NS::Base().refQualifiedFunction();
+
+ NS::Derived d;
+ d.virtualFunction();
+
+ NS::ClassTemplate<int> t1;
+ t1.classTemplateFunction();
+ NS::ClassTemplate<NS::Base *> t2;
+ t2.classTemplateFunction();
+
+ NS::Constructor c1;
+ NS::Constructor c2(0);
+ NS::Constructor c3((NS::Base *)0);
+
+ {
+ NS::Destructor destructor;
+ }
+
+ NS::ContainerForAnonymousRecords anonymous;
+ anonymous.anonymousClass.anonymousClassFunction();
+ anonymous.anonymousStruct.anonymousStructFunction();
+ anonymous.anonymousUnion.anonymousUnionFunction();
+
+ NS::localClass(0);
+
+ NS::externFunction();
+
+ // additional tests for __PRETTY_FUNCTION__
+
+ functionTemplateWithTwoParams(0, 0.0f);
+ functionTemplateWithoutParameterList<double>();
+ functionTemplateWithTemplateReturnType<char>();
+ int array[] = { 1, 2, 3 };
+ functionTemplateWithCompoundTypes(array);
+ functionTemplateExplicitSpecialization(0);
+ functionTemplateExplicitSpecialization(0.0);
+ functionTemplateWithUnnamedTemplateParameter<int, float>(0.0f);
+
+ OuterClass<int *>::MiddleClass::InnerClass<float> omi;
+ omi.memberFunction(0, 0.0f);
+
+ ClassWithTemplateTemplateParam<char>::staticMember();
+
+ NonTypeTemplateParam<42> ntt;
+ ntt.size();
+
+ SpecializedClassTemplate<int> sct1;
+ sct1.memberFunctionTemplate(0, 0.0f);
+ SpecializedClassTemplate<char> sct2;
+ sct2.memberFunctionTemplate('0', 0.0);
+
+ return 0;
+}
diff --git a/clang/test/CodeGenCXX/ptr-to-datamember.cpp b/clang/test/CodeGenCXX/ptr-to-datamember.cpp
new file mode 100644
index 0000000..a6f523e
--- /dev/null
+++ b/clang/test/CodeGenCXX/ptr-to-datamember.cpp
@@ -0,0 +1,99 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+
+extern "C" int printf(...);
+
+struct F {
+ F() : iF(1), fF(2.0) {}
+ int iF;
+ float fF;
+};
+
+struct V {
+ double d;
+ int iV;
+};
+
+struct B : virtual V{
+ double d;
+ int iB;
+};
+
+struct B1 : virtual V{
+ double d;
+ int iB1;
+};
+
+class A : public B, public B1 {
+public:
+ A() : f(1.0), d(2.0), Ai(3) {}
+ float f;
+ double d;
+ int Ai;
+ F Af;
+};
+
+template <typename T> struct TT {
+ int T::t::*pti;
+};
+
+struct I {
+ typedef I t;
+ int x;
+};
+
+void pr(const F& b) {
+ printf(" %d %f\n", b.iF, b.fF);
+}
+
+void test_aggr_pdata(A& a1) {
+ F A::* af = &A::Af;
+ pr(a1.*af);
+
+ (a1.*af).iF = 100;
+ (a1.*af).fF = 200.00;
+ printf(" %d %f\n", (a1.*af).iF, (a1.*af).fF);
+ pr(a1.*af);
+
+ (a1.*af).iF++;
+ (a1.*af).fF--;
+ --(a1.*af).fF;
+ pr(a1.*af);
+}
+
+void test_aggr_pdata_1(A* pa) {
+ F A::* af = &A::Af;
+ pr(pa->*af);
+
+ (pa->*af).iF = 100;
+ (pa->*af).fF = 200.00;
+ printf(" %d %f\n", (pa->*af).iF, (pa->*af).fF);
+ pr(pa->*af);
+
+ (pa->*af).iF++;
+ (pa->*af).fF--;
+ --(pa->*af).fF;
+ pr(pa->*af);
+}
+
+int main()
+{
+ A a1;
+ TT<I> tt;
+ I i;
+ int A::* pa = &A::Ai;
+ float A::* pf = &A::f;
+ double A::* pd = &A::d;
+ tt.pti = &I::x;
+ printf("%d %d %d\n", &A::Ai, &A::f, &A::d);
+ printf("%d\n", &A::B::iB);
+ printf("%d\n", &A::B1::iB1);
+ printf("%d\n", &A::f);
+ printf("%d\n", &A::B::iV);
+ printf("%d\n", &A::B1::iV);
+ printf("%d\n", &A::B::V::iV);
+ printf("%d\n", &A::B1::V::iV);
+ printf("%d, %f, %f \n", a1.*pa, a1.*pf, a1.*pd);
+ printf("%d\n", i.*tt.pti);
+ test_aggr_pdata(a1);
+ test_aggr_pdata_1(&a1);
+}
diff --git a/clang/test/CodeGenCXX/ptr-to-member-function.cpp b/clang/test/CodeGenCXX/ptr-to-member-function.cpp
new file mode 100644
index 0000000..3989c03
--- /dev/null
+++ b/clang/test/CodeGenCXX/ptr-to-member-function.cpp
@@ -0,0 +1,71 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+// 13.3.3.2 Ranking implicit conversion sequences
+
+extern "C" int printf(...);
+
+struct A {
+int Ai;
+bool foo(int* arg) const;
+};
+
+bool A::foo(int* arg) const {
+ printf("A::foo(%d)\n", *arg);
+ return true;
+}
+
+struct B : public A {
+ void bf() { printf("B::bf called\n"); }
+};
+
+struct C : public B { };
+
+// conversion of B::* to C::* is better than conversion of A::* to C::*
+typedef void (A::*pmfa)();
+typedef void (B::*pmfb)();
+typedef void (C::*pmfc)();
+
+struct X {
+ operator pmfa();
+ operator pmfb() {
+ return &B::bf;
+ }
+};
+
+
+void g(pmfc pm) {
+ C c;
+ (c.*pm)();
+}
+
+void test2(X x)
+{
+ g(x);
+}
+
+struct B1 {
+ bool (A::*pmf)(int*) const;
+
+ B1(int i) : pmf(&A::foo), im(i) {
+ ((A*)this->*pmf)(&im);
+ }
+
+ int im;
+};
+
+int main()
+{
+ X x;
+ test2(x);
+ B1 b = B1(1);
+ B1 c = B1(2);
+}
+
+// CHECK-LP64: callq __ZN1XcvM1BFvvEEv
+// CHECK-LP64: callq __Z1gM1CFvvE
+
+// CHECK-LP32: calll L__ZN1XcvM1BFvvEEv
+// CHECK-LP32: calll __Z1gM1CFvvE
diff --git a/clang/test/CodeGenCXX/reference-bind-default-argument.cpp b/clang/test/CodeGenCXX/reference-bind-default-argument.cpp
new file mode 100644
index 0000000..acce962
--- /dev/null
+++ b/clang/test/CodeGenCXX/reference-bind-default-argument.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -emit-llvm-only -verify
+
+struct A {};
+struct B : A {};
+void a(const A& x = B());
+void b() { a(); }
diff --git a/clang/test/CodeGenCXX/reference-cast.cpp b/clang/test/CodeGenCXX/reference-cast.cpp
new file mode 100644
index 0000000..1d08b2b
--- /dev/null
+++ b/clang/test/CodeGenCXX/reference-cast.cpp
@@ -0,0 +1,194 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10 -o - %s | FileCheck %s
+
+// PR6024
+extern int i;
+
+// CHECK: define i32* @_Z16lvalue_noop_castv() nounwind
+const int &lvalue_noop_cast() {
+ if (i == 0)
+ // CHECK: store i32 17, i32*
+ return (const int&)17;
+ else if (i == 1)
+ // CHECK: store i32 17, i32*
+ return static_cast<const int&>(17);
+ // CHECK: store i32 17, i32*
+ return 17;
+}
+
+// CHECK: define i16* @_Z20lvalue_integral_castv()
+const short &lvalue_integral_cast() {
+ if (i == 0)
+ // CHECK: store i16 17, i16*
+ return (const short&)17;
+ else if (i == 1)
+ // CHECK: store i16 17, i16*
+ return static_cast<const short&>(17);
+ // CHECK: store i16 17, i16*
+ return 17;
+}
+
+// CHECK: define i16* @_Z29lvalue_floating_integral_castv()
+const short &lvalue_floating_integral_cast() {
+ if (i == 0)
+ // CHECK: store i16 17, i16*
+ return (const short&)17.5;
+ else if (i == 1)
+ // CHECK: store i16 17, i16*
+ return static_cast<const short&>(17.5);
+ // CHECK: store i16 17, i16*
+ return 17.5;
+}
+
+// CHECK: define float* @_Z29lvalue_integral_floating_castv()
+const float &lvalue_integral_floating_cast() {
+ if (i == 0)
+ // CHECK: store float 1.700000e+{{0*}}1, float*
+ return (const float&)17;
+ else if (i == 1)
+ // CHECK: store float 1.700000e+{{0*}}1, float*
+ return static_cast<const float&>(17);
+ // CHECK: store float 1.700000e+{{0*}}1, float*
+ return 17;
+}
+
+// CHECK: define float* @_Z20lvalue_floating_castv()
+const float &lvalue_floating_cast() {
+ if (i == 0)
+ // CHECK: store float 1.700000e+{{0*}}1, float*
+ return (const float&)17.0;
+ else if (i == 1)
+ // CHECK: store float 1.700000e+{{0*}}1, float*
+ return static_cast<const float&>(17.0);
+ // CHECK: store float 1.700000e+{{0*}}1, float*
+ return 17.0;
+}
+
+int get_int();
+
+// CHECK: define i8* @_Z24lvalue_integer_bool_castv()
+const bool &lvalue_integer_bool_cast() {
+ if (i == 0)
+ // CHECK: call i32 @_Z7get_intv()
+ // CHECK: store i8
+ return (const bool&)get_int();
+ else if (i == 1)
+ // CHECK: call i32 @_Z7get_intv()
+ // CHECK: store i8
+ return static_cast<const bool&>(get_int());
+ // CHECK: call i32 @_Z7get_intv()
+ // CHECK: store i8
+ return get_int();
+}
+
+float get_float();
+
+// CHECK: define i8* @_Z25lvalue_floating_bool_castv()
+const bool &lvalue_floating_bool_cast() {
+ if (i == 0)
+ // CHECK: call float @_Z9get_floatv()
+ // CHECK: fcmp une float
+ // CHECK: store i8
+ return (const bool&)get_float();
+ else if (i == 1)
+ // CHECK: call float @_Z9get_floatv()
+ // CHECK: fcmp une float
+ // CHECK: store i8
+ return static_cast<const bool&>(get_float());
+ // CHECK: call float @_Z9get_floatv()
+ // CHECK: fcmp une float
+ // CHECK: store i8
+ return get_float();
+}
+
+struct X { };
+typedef int X::*pm;
+typedef int (X::*pmf)(int);
+
+pm get_pointer_to_member_data();
+pmf get_pointer_to_member_function();
+
+// CHECK: define i8* @_Z26lvalue_ptrmem_to_bool_castv()
+const bool &lvalue_ptrmem_to_bool_cast() {
+ if (i == 0)
+ // CHECK: call i64 @_Z26get_pointer_to_member_datav()
+ // CHECK: store i8
+ // CHECK: store i8*
+ return (const bool&)get_pointer_to_member_data();
+ else if (i == 1)
+ // CHECK: call i64 @_Z26get_pointer_to_member_datav()
+ // CHECK: store i8
+ // CHECK: store i8*
+ return static_cast<const bool&>(get_pointer_to_member_data());
+ // CHECK: call i64 @_Z26get_pointer_to_member_datav()
+ // CHECK: store i8
+ // CHECK: store i8*
+ return get_pointer_to_member_data();
+}
+
+// CHECK: define i8* @_Z27lvalue_ptrmem_to_bool_cast2v
+const bool &lvalue_ptrmem_to_bool_cast2() {
+ if (i == 0)
+ // CHECK: {{call.*_Z30get_pointer_to_member_functionv}}
+ // CHECK: store i8
+ // CHECK: store i8*
+ return (const bool&)get_pointer_to_member_function();
+ else if (i == 1)
+ // CHECK: {{call.*_Z30get_pointer_to_member_functionv}}
+ // CHECK: store i8
+ // CHECK: store i8*
+ return static_cast<const bool&>(get_pointer_to_member_function());
+ // CHECK: {{call.*_Z30get_pointer_to_member_functionv}}
+ // CHECK: store i8
+ // CHECK: store i8*
+ return get_pointer_to_member_function();
+}
+
+_Complex double get_complex_double();
+
+// CHECK: {{define.*_Z2f1v}}
+const _Complex float &f1() {
+ if (i == 0)
+ // CHECK: {{call.*_Z18get_complex_doublev}}
+ // CHECK: fptrunc
+ // CHECK: fptrunc
+ // CHECK: store float
+ // CHECK: store float
+ return (const _Complex float&)get_complex_double();
+ else if (i == 1)
+ // CHECK: {{call.*_Z18get_complex_doublev}}
+ // CHECK: fptrunc
+ // CHECK: fptrunc
+ // CHECK: store float
+ // CHECK: store float
+ return static_cast<const _Complex float&>(get_complex_double());
+ // CHECK: {{call.*_Z18get_complex_doublev}}
+ // CHECK: fptrunc
+ // CHECK: fptrunc
+ // CHECK: store float
+ // CHECK: store float
+ return get_complex_double();
+}
+
+// CHECK: define i32 @_Z7pr10592RKi(i32*
+unsigned pr10592(const int &v) {
+ // CHECK: [[VADDR:%[a-zA-Z0-9.]+]] = alloca i32*
+ // CHECK-NEXT: [[REFTMP:%[a-zA-Z0-9.]+]] = alloca i32
+ // CHECK-NEXT: store i32* [[V:%[a-zA-Z0-9.]+]], i32** [[VADDR]]
+ // CHECK-NEXT: [[VADDR_1:%[a-zA-Z0-9.]+]] = load i32** [[VADDR]]
+ // CHECK-NEXT: [[VVAL:%[a-zA-Z0-9.]+]] = load i32* [[VADDR_1]]
+ // CHECK-NEXT: store i32 [[VVAL]], i32* [[REFTMP]]
+ // CHECK-NEXT: [[VVAL_I:%[a-zA-Z0-9.]+]] = load i32* [[REFTMP]]
+ // CHECK-NEXT: ret i32 [[VVAL_I]]
+ return static_cast<const unsigned &>(v);
+}
+
+namespace PR10650 {
+ struct Helper {
+ unsigned long long id();
+ };
+ unsigned long long test(Helper *obj) {
+ return static_cast<const unsigned long long&>(obj->id());
+ }
+ // CHECK: define i64 @_ZN7PR106504testEPNS_6HelperE
+ // CHECK: store i64
+}
diff --git a/clang/test/CodeGenCXX/reference-field.cpp b/clang/test/CodeGenCXX/reference-field.cpp
new file mode 100644
index 0000000..0312029
--- /dev/null
+++ b/clang/test/CodeGenCXX/reference-field.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s -O2 | grep "@_Z1bv"
+
+// Make sure the call to b() doesn't get optimized out.
+extern struct x {char& x,y;}y;
+int b();
+int a() { if (!&y.x) b(); }
diff --git a/clang/test/CodeGenCXX/reference-in-block-args.cpp b/clang/test/CodeGenCXX/reference-in-block-args.cpp
new file mode 100644
index 0000000..1ff1ae2
--- /dev/null
+++ b/clang/test/CodeGenCXX/reference-in-block-args.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fblocks %s -emit-llvm -o %t
+// rdar: // 8041962
+
+extern "C" int printf(const char*, ...);
+
+struct ST {
+ int filler;
+ int referrer;
+};
+
+void OUTER_BLOCK(void (^fixer)(ST& ref)) {
+ ST ref = {2, 100};
+ fixer(ref);
+}
+
+void INNER_BLOCK(int (^largeDo) ()) {
+ printf("%d\n", largeDo());
+}
+
+void scan() {
+ OUTER_BLOCK(^(ST &ref) {
+ INNER_BLOCK(^() { return ref.referrer + ref.filler; });
+ });
+
+}
+
+int main() {
+ scan();
+}
diff --git a/clang/test/CodeGenCXX/reference-in-blocks.cpp b/clang/test/CodeGenCXX/reference-in-blocks.cpp
new file mode 100644
index 0000000..388ec7c
--- /dev/null
+++ b/clang/test/CodeGenCXX/reference-in-blocks.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fblocks %s -emit-llvm -o %t
+
+extern "C" int printf(const char*, ...);
+
+template<typename T> class range {
+public:
+T _i;
+ range(T i) {_i = i;};
+ T get() {return _i;};
+};
+
+// rdar: // 7495203
+class A {
+ public:
+ A() : field(10), d1(3.14) {}
+ void F();
+ void S() {
+ printf(" field = %d\n", field);
+ printf(" field = %f\n", d1);
+ }
+ int field;
+ double d1;
+};
+
+void A::F()
+ {
+ __block A &tlc = *this;
+ // crashed in code gen (radar 7495203)
+ ^{ tlc.S(); }();
+ }
+
+int main() {
+
+ // works
+ void (^bl)(range<int> ) = ^(range<int> i){printf("Hello Blocks %d\n", i.get()); };
+
+ //crashes in godegen?
+ void (^bl2)(range<int>& ) = ^(range<int>& i){printf("Hello Blocks %d\n", i.get()); };
+
+ A *a = new A;
+ a->F();
+ return 0;
+}
diff --git a/clang/test/CodeGenCXX/reference-init.cpp b/clang/test/CodeGenCXX/reference-init.cpp
new file mode 100644
index 0000000..9469c84
--- /dev/null
+++ b/clang/test/CodeGenCXX/reference-init.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm-only -verify %s
+
+struct XPTParamDescriptor {};
+struct nsXPTParamInfo {
+ nsXPTParamInfo(const XPTParamDescriptor& desc);
+};
+void a(XPTParamDescriptor *params) {
+ const nsXPTParamInfo& paramInfo = params[0];
+}
+
+// CodeGen of reference initialized const arrays.
+namespace PR5911 {
+ template <typename T, int N> int f(const T (&a)[N]) { return N; }
+ int iarr[] = { 1 };
+ int test() { return f(iarr); }
+}
+
+// radar 7574896
+struct Foo { int foo; };
+Foo& ignoreSetMutex = *(new Foo);
+
+// Binding to a bit-field that requires a temporary.
+struct { int bitfield : 3; } s = { 3 };
+const int &s2 = s.bitfield;
diff --git a/clang/test/CodeGenCXX/references.cpp b/clang/test/CodeGenCXX/references.cpp
new file mode 100644
index 0000000..d315f71
--- /dev/null
+++ b/clang/test/CodeGenCXX/references.cpp
@@ -0,0 +1,313 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -verify -emit-llvm -o - %s | FileCheck %s
+void t1() {
+ // CHECK: define void @_Z2t1v
+ // CHECK: [[REFLOAD:%.*]] = load i32** @a, align 8
+ // CHECK: load i32* [[REFLOAD]], align 4
+ extern int& a;
+ int b = a;
+}
+
+void t2(int& a) {
+ // CHECK: define void @_Z2t2Ri
+ // CHECK: [[REFLOAD2:%.*]] = load i32** {{.*}}, align 8
+ // CHECK: load i32* [[REFLOAD2]], align 4
+ int b = a;
+}
+
+int g;
+int& gr = g;
+int& grr = gr;
+void t3() {
+ int b = gr;
+}
+
+// Test reference binding.
+
+struct C { int a; };
+void f(const bool&);
+void f(const int&);
+void f(const _Complex int&);
+void f(const C&);
+
+C aggregate_return();
+
+bool& bool_reference_return();
+int& int_reference_return();
+_Complex int& complex_int_reference_return();
+C& aggregate_reference_return();
+
+void test_bool() {
+ bool a = true;
+ f(a);
+
+ f(true);
+
+ bool_reference_return() = true;
+ a = bool_reference_return();
+
+ struct { const bool& b; } b = { true };
+}
+
+void test_scalar() {
+ int a = 10;
+ f(a);
+
+ struct { int bitfield : 3; } s = { 3 };
+ f(s.bitfield);
+
+ f(10);
+
+ __attribute((vector_size(16))) typedef int vec4;
+ f((vec4){1,2,3,4}[0]);
+
+ int_reference_return() = 10;
+ a = int_reference_return();
+
+ struct { const int& a; } agg = { 10 };
+}
+
+void test_complex() {
+ _Complex int a = 10i;
+ f(a);
+
+ f(10i);
+
+ complex_int_reference_return() = 10i;
+ a = complex_int_reference_return();
+
+ struct { const _Complex int &a; } agg = { 10i };
+}
+
+void test_aggregate() {
+ C c;
+ f(c);
+
+ f(aggregate_return());
+ aggregate_reference_return().a = 10;
+
+ c = aggregate_reference_return();
+
+ struct { const C& a; } agg = { C() };
+}
+
+int& reference_return() {
+ return g;
+}
+
+int reference_decl() {
+ int& a = g;
+ const int& b = 1;
+ return a+b;
+}
+
+struct A {
+ int& b();
+};
+
+void f(A* a) {
+ int b = a->b();
+}
+
+// PR5122
+void *foo = 0;
+void * const & kFoo = foo;
+
+struct D : C { D(); ~D(); };
+
+void h() {
+ // CHECK: call void @_ZN1DD1Ev
+ const C& c = D();
+}
+
+namespace T {
+ struct A {
+ A();
+ ~A();
+ };
+
+ struct B {
+ B();
+ ~B();
+ A f();
+ };
+
+ void f() {
+ // CHECK: call void @_ZN1T1BC1Ev
+ // CHECK: call void @_ZN1T1B1fEv
+ // CHECK: call void @_ZN1T1BD1Ev
+ const A& a = B().f();
+ // CHECK: call void @_ZN1T1fEv
+ f();
+ // CHECK: call void @_ZN1T1AD1Ev
+ }
+}
+
+// PR5227.
+namespace PR5227 {
+void f(int &a) {
+ (a = 10) = 20;
+}
+}
+
+// PR5590
+struct s0;
+struct s1 { struct s0 &s0; };
+void f0(s1 a) { s1 b = a; }
+
+// PR6024
+// CHECK: @_Z2f2v()
+// CHECK: alloca i32,
+// CHECK-NEXT: store
+// CHECK-NEXT: ret
+const int &f2() { return 0; }
+
+// Don't constant fold const reference parameters with default arguments to
+// their default arguments.
+namespace N1 {
+ const int foo = 1;
+ // CHECK: @_ZN2N14test
+ void test(const int& arg = foo) {
+ // Ensure this array is on the stack where we can set values instead of
+ // being a global constant.
+ // CHECK: %args_array = alloca
+ const int* const args_array[] = { &arg };
+ }
+}
+
+// Bind to subobjects while extending the life of the complete object.
+namespace N2 {
+ class X {
+ public:
+ X(const X&);
+ X &operator=(const X&);
+ ~X();
+ };
+
+ struct P {
+ X first;
+ };
+
+ P getP();
+
+ // CHECK: define void @_ZN2N21fEi
+ // CHECK: call void @_ZN2N24getPEv
+ // CHECK: getelementptr inbounds
+ // CHECK: store i32 17
+ // CHECK: call void @_ZN2N21PD1Ev
+ void f(int i) {
+ const X& xr = getP().first;
+ i = 17;
+ }
+
+ struct SpaceWaster {
+ int i, j;
+ };
+
+ struct ReallyHasX {
+ X x;
+ };
+
+ struct HasX : ReallyHasX { };
+
+ struct HasXContainer {
+ HasX has;
+ };
+
+ struct Y : SpaceWaster, HasXContainer { };
+ struct Z : SpaceWaster, Y { };
+
+ Z getZ();
+
+ // CHECK: define void @_ZN2N21gEi
+ // CHECK: call void @_ZN2N24getZEv
+ // CHECK: {{getelementptr inbounds.*i32 0, i32 0}}
+ // CHECK: {{getelementptr inbounds.*i32 0, i32 0}}
+ // CHECK: store i32 19
+ // CHECK: call void @_ZN2N21ZD1Ev
+ // CHECK: ret void
+ void g(int i) {
+ const X &xr = getZ().has.x;
+ i = 19;
+ }
+}
+
+namespace N3 {
+
+// PR7326
+
+struct A {
+ explicit A(int);
+ ~A();
+};
+
+// CHECK: define internal void @__cxx_global_var_init
+// CHECK: call void @_ZN2N31AC1Ei(%"struct.N3::A"* @_ZGRN2N35sA123E, i32 123)
+// CHECK: call i32 @__cxa_atexit
+// CHECK: ret void
+const A &sA123 = A(123);
+}
+
+namespace N4 {
+
+struct A {
+ A();
+ ~A();
+};
+
+void f() {
+ // CHECK: define void @_ZN2N41fEv
+ // CHECK: call void @_ZN2N41AC1Ev(%"struct.N4::A"* @_ZGRZN2N41fEvE2ar)
+ // CHECK: call i32 @__cxa_atexit
+ // CHECK: ret void
+ static const A& ar = A();
+
+}
+}
+
+// PR9494
+namespace N5 {
+struct AnyS { bool b; };
+void f(const bool&);
+AnyS g();
+void h() {
+ // CHECK: call i8 @_ZN2N51gEv()
+ // CHECK: call void @_ZN2N51fERKb(i8*
+ f(g().b);
+}
+}
+
+// PR9565
+namespace PR9565 {
+ struct a { int a : 10, b : 10; };
+ // CHECK: define void @_ZN6PR95651fEv()
+ void f() {
+ // CHECK: call void @llvm.memcpy
+ a x = { 0, 0 };
+ // CHECK: [[WITH_SEVENTEEN:%[a-zA-Z0-9]+]] = or i32 [[WITHOUT_SEVENTEEN:%[a-zA-Z0-9]+]], 17
+ // CHECK: store i32 [[WITH_SEVENTEEN]], i32* [[XA:%[a-zA-Z0-9]+]]
+ x.a = 17;
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: load
+ // CHECK-NEXT: and
+ // CHECK-NEXT: shl
+ // CHECK-NEXT: ashr
+ // CHECK-NEXT: store i32
+ // CHECK-NEXT: store i32*
+ const int &y = x.a;
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: load
+ // CHECK-NEXT: and
+ // CHECK-NEXT: or
+ // CHECK-NEXT: store i32
+ x.b = 19;
+ // CHECK-NEXT: ret void
+ }
+}
+
+namespace N6 {
+ extern struct x {char& x;}y;
+ int a() { return y.x; }
+ // CHECK: define i32 @_ZN2N61aEv
+ // CHECK: [[REFLOAD3:%.*]] = load i8** getelementptr inbounds (%"struct.N6::x"* @_ZN2N61yE, i32 0, i32 0), align 8
+ // CHECK: load i8* [[REFLOAD3]], align 1
+}
diff --git a/clang/test/CodeGenCXX/regparm.cpp b/clang/test/CodeGenCXX/regparm.cpp
new file mode 100644
index 0000000..f0ebd2b
--- /dev/null
+++ b/clang/test/CodeGenCXX/regparm.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+
+
+// CHECK: _Z3fooRi(i32* inreg
+void __attribute__ ((regparm (1))) foo(int &a) {
+}
diff --git a/clang/test/CodeGenCXX/reinterpret-cast.cpp b/clang/test/CodeGenCXX/reinterpret-cast.cpp
new file mode 100644
index 0000000..dafa675
--- /dev/null
+++ b/clang/test/CodeGenCXX/reinterpret-cast.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s -std=c++11
+void *f1(unsigned long l) {
+ return reinterpret_cast<void *>(l);
+}
+
+unsigned long f2() {
+ return reinterpret_cast<unsigned long>(nullptr);
+}
+
+unsigned long f3(void *p) {
+ return reinterpret_cast<unsigned long>(p);
+}
+
+void f4(int*&);
+void f5(void*& u) {
+ f4(reinterpret_cast<int*&>(u));
+}
diff --git a/clang/test/CodeGenCXX/rtti-fundamental.cpp b/clang/test/CodeGenCXX/rtti-fundamental.cpp
new file mode 100644
index 0000000..2495e96
--- /dev/null
+++ b/clang/test/CodeGenCXX/rtti-fundamental.cpp
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+#include <typeinfo>
+
+std::type_info foo() {
+ return typeid(void);
+}
+
+namespace __cxxabiv1 {
+ struct __fundamental_type_info {
+ virtual ~__fundamental_type_info();
+ };
+
+ __fundamental_type_info::~__fundamental_type_info() { }
+}
+
+// void
+// CHECK: @_ZTIv = unnamed_addr constant
+// CHECK: @_ZTIPv = unnamed_addr constant
+// CHECK: @_ZTIPKv = unnamed_addr constant
+
+// std::nullptr_t
+// CHECK: @_ZTIDn = unnamed_addr constant
+// CHECK: @_ZTIPDn = unnamed_addr constant
+// CHECK: @_ZTIPKDn = unnamed_addr constant
+
+// bool
+// CHECK: @_ZTIb = unnamed_addr constant
+// CHECK: @_ZTIPb = unnamed_addr constant
+// CHECK: @_ZTIPKb = unnamed_addr constant
+
+// wchar_t
+// CHECK: @_ZTIw = unnamed_addr constant
+// CHECK: @_ZTIPw = unnamed_addr constant
+// CHECK: @_ZTIPKw = unnamed_addr constant
+
+// char
+// CHECK: @_ZTIc = unnamed_addr constant
+// CHECK: @_ZTIPc = unnamed_addr constant
+// CHECK: @_ZTIPKc = unnamed_addr constant
+
+// unsigned char
+// CHECK: @_ZTIh = unnamed_addr constant
+// CHECK: @_ZTIPh = unnamed_addr constant
+// CHECK: @_ZTIPKh = unnamed_addr constant
+
+// signed char
+// CHECK: @_ZTIa = unnamed_addr constant
+// CHECK: @_ZTIPa = unnamed_addr constant
+// CHECK: @_ZTIPKa = unnamed_addr constant
+
+// short
+// CHECK: @_ZTIs = unnamed_addr constant
+// CHECK: @_ZTIPs = unnamed_addr constant
+// CHECK: @_ZTIPKs = unnamed_addr constant
+
+// unsigned short
+// CHECK: @_ZTIt = unnamed_addr constant
+// CHECK: @_ZTIPt = unnamed_addr constant
+// CHECK: @_ZTIPKt = unnamed_addr constant
+
+// int
+// CHECK: @_ZTIi = unnamed_addr constant
+// CHECK: @_ZTIPi = unnamed_addr constant
+// CHECK: @_ZTIPKi = unnamed_addr constant
+
+// unsigned int
+// CHECK: @_ZTIj = unnamed_addr constant
+// CHECK: @_ZTIPj = unnamed_addr constant
+// CHECK: @_ZTIPKj = unnamed_addr constant
+
+// long
+// CHECK: @_ZTIl = unnamed_addr constant
+// CHECK: @_ZTIPl = unnamed_addr constant
+// CHECK: @_ZTIPKl = unnamed_addr constant
+
+// unsigned long
+// CHECK: @_ZTIm = unnamed_addr constant
+// CHECK: @_ZTIPm = unnamed_addr constant
+// CHECK: @_ZTIPKm = unnamed_addr constant
+
+// long long
+// CHECK: @_ZTIx = unnamed_addr constant
+// CHECK: @_ZTIPx = unnamed_addr constant
+// CHECK: @_ZTIPKx = unnamed_addr constant
+
+// unsigned long long
+// CHECK: @_ZTIy = unnamed_addr constant
+// CHECK: @_ZTIPy = unnamed_addr constant
+// CHECK: @_ZTIPKy = unnamed_addr constant
+
+// float
+// CHECK: @_ZTIf = unnamed_addr constant
+// CHECK: @_ZTIPf = unnamed_addr constant
+// CHECK: @_ZTIPKf = unnamed_addr constant
+
+// double
+// CHECK: @_ZTId = unnamed_addr constant
+// CHECK: @_ZTIPd = unnamed_addr constant
+// CHECK: @_ZTIPKd = unnamed_addr constant
+
+// long double
+// CHECK: @_ZTIe = unnamed_addr constant
+// CHECK: @_ZTIPe = unnamed_addr constant
+// CHECK: @_ZTIPKe = unnamed_addr constant
+
+// char16_t
+// CHECK: @_ZTIDs = unnamed_addr constant
+// CHECK: @_ZTIPDs = unnamed_addr constant
+// CHECK: @_ZTIPKDs = unnamed_addr constant
+
+// char32_t
+// CHECK: @_ZTIDi = unnamed_addr constant
+// CHECK: @_ZTIPDi = unnamed_addr constant
+// CHECK: @_ZTIPKDi = unnamed_addr constant
+
diff --git a/clang/test/CodeGenCXX/rtti-layout.cpp b/clang/test/CodeGenCXX/rtti-layout.cpp
new file mode 100644
index 0000000..7128c4e
--- /dev/null
+++ b/clang/test/CodeGenCXX/rtti-layout.cpp
@@ -0,0 +1,205 @@
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o - | FileCheck %s
+#include <typeinfo>
+
+// vtables.
+extern "C" {
+ const void *_ZTVN10__cxxabiv123__fundamental_type_infoE;
+ const void *_ZTVN10__cxxabiv117__class_type_infoE;
+ const void *_ZTVN10__cxxabiv120__si_class_type_infoE;
+ const void *_ZTVN10__cxxabiv121__vmi_class_type_infoE;
+ const void *_ZTVN10__cxxabiv119__pointer_type_infoE;
+ const void *_ZTVN10__cxxabiv129__pointer_to_member_type_infoE;
+};
+#define fundamental_type_info_vtable _ZTVN10__cxxabiv123__fundamental_type_infoE
+#define class_type_info_vtable _ZTVN10__cxxabiv117__class_type_infoE
+#define si_class_type_info_vtable _ZTVN10__cxxabiv120__si_class_type_infoE
+#define vmi_class_type_info_vtable _ZTVN10__cxxabiv121__vmi_class_type_infoE
+#define pointer_type_info_vtable _ZTVN10__cxxabiv119__pointer_type_infoE
+#define pointer_to_member_type_info_vtable _ZTVN10__cxxabiv129__pointer_to_member_type_infoE
+
+class __pbase_type_info : public std::type_info {
+public:
+ unsigned int __flags;
+ const std::type_info *__pointee;
+
+ enum __masks {
+ __const_mask = 0x1,
+ __volatile_mask = 0x2,
+ __restrict_mask = 0x4,
+ __incomplete_mask = 0x8,
+ __incomplete_class_mask = 0x10
+ };
+};
+
+class __class_type_info : public std::type_info { };
+
+class __si_class_type_info : public __class_type_info {
+public:
+ const __class_type_info *__base_type;
+};
+
+struct __base_class_type_info {
+public:
+ const __class_type_info *__base_type;
+ long __offset_flags;
+
+ enum __offset_flags_masks {
+ __virtual_mask = 0x1,
+ __public_mask = 0x2,
+ __offset_shift = 8
+ };
+};
+
+class __vmi_class_type_info : public __class_type_info {
+public:
+ unsigned int __flags;
+ unsigned int __base_count;
+ __base_class_type_info __base_info[1];
+
+ enum __flags_masks {
+ __non_diamond_repeat_mask = 0x1,
+ __diamond_shaped_mask = 0x2
+ };
+};
+
+template<typename T> const T& to(const std::type_info &info) {
+return static_cast<const T&>(info);
+}
+struct Incomplete;
+
+struct A { int a; };
+struct Empty { };
+
+struct SI1 : A { };
+struct SI2 : Empty { };
+struct SI3 : Empty { virtual void f() { } };
+
+struct VMI1 : private A { };
+struct VMI2 : virtual A { };
+struct VMI3 : A { virtual void f() { } };
+struct VMI4 : A, Empty { };
+
+struct VMIBase1 { int a; };
+struct VMIBase2 : VMIBase1 { int a; };
+struct VMI5 : VMIBase1, VMIBase2 { int a; };
+
+struct VMIBase3 : virtual VMIBase1 { int a; };
+struct VMI6 : virtual VMIBase1, VMIBase3 { int a; };
+
+struct VMI7 : VMIBase1, VMI5, private VMI6 { };
+
+#define CHECK(x) if (!(x)) return __LINE__
+#define CHECK_VTABLE(type, vtable) CHECK(&vtable##_type_info_vtable + 2 == (((void **)&(typeid(type)))[0]))
+#define CHECK_BASE_INFO_TYPE(type, index, base) CHECK(to<__vmi_class_type_info>(typeid(type)).__base_info[(index)].__base_type == &typeid(base))
+#define CHECK_BASE_INFO_OFFSET_FLAGS(type, index, offset, flags) CHECK(to<__vmi_class_type_info>(typeid(type)).__base_info[(index)].__offset_flags == (((offset) << 8) | (flags)))
+
+struct B {
+ static int const volatile (*a)[10];
+ static int (*b)[10];
+
+ static int const volatile (B::*c)[10];
+ static int (B::*d)[10];
+};
+
+// CHECK: define i32 @_Z1fv()
+int f() {
+ // Vectors should be treated as fundamental types.
+ typedef short __v4hi __attribute__ ((__vector_size__ (8)));
+ CHECK_VTABLE(__v4hi, fundamental);
+
+ // A does not have any bases.
+ CHECK_VTABLE(A, class);
+
+ // SI1 has a single public base.
+ CHECK_VTABLE(SI1, si_class);
+ CHECK(to<__si_class_type_info>(typeid(SI1)).__base_type == &typeid(A));
+
+ // SI2 has a single public empty base.
+ CHECK_VTABLE(SI2, si_class);
+ CHECK(to<__si_class_type_info>(typeid(SI2)).__base_type == &typeid(Empty));
+
+ // SI3 has a single public empty base. SI3 is dynamic whereas Empty is not, but since Empty is
+ // an empty class, it will still be at offset zero.
+ CHECK_VTABLE(SI3, si_class);
+ CHECK(to<__si_class_type_info>(typeid(SI3)).__base_type == &typeid(Empty));
+
+ // VMI1 has a single base, but it is private.
+ CHECK_VTABLE(VMI1, vmi_class);
+
+ // VMI2 has a single base, but it is virtual.
+ CHECK_VTABLE(VMI2, vmi_class);
+
+ // VMI3 has a single base, but VMI3 is dynamic whereas A is not, and A is not empty.
+ CHECK_VTABLE(VMI3, vmi_class);
+
+ // VMI4 has two bases.
+ CHECK_VTABLE(VMI4, vmi_class);
+
+ // VMI5 has non-diamond shaped inheritance.
+ CHECK_VTABLE(VMI5, vmi_class);
+ CHECK(to<__vmi_class_type_info>(typeid(VMI5)).__flags == __vmi_class_type_info::__non_diamond_repeat_mask);
+ CHECK(to<__vmi_class_type_info>(typeid(VMI5)).__base_count == 2);
+ CHECK_BASE_INFO_TYPE(VMI5, 0, VMIBase1);
+ CHECK_BASE_INFO_OFFSET_FLAGS(VMI5, 0, 0, __base_class_type_info::__public_mask);
+ CHECK_BASE_INFO_TYPE(VMI5, 1, VMIBase2);
+ CHECK_BASE_INFO_OFFSET_FLAGS(VMI5, 1, 4, __base_class_type_info::__public_mask);
+
+ // VMI6 has diamond shaped inheritance.
+ CHECK_VTABLE(VMI6, vmi_class);
+ CHECK(to<__vmi_class_type_info>(typeid(VMI6)).__flags == __vmi_class_type_info::__diamond_shaped_mask);
+ CHECK(to<__vmi_class_type_info>(typeid(VMI6)).__base_count == 2);
+ CHECK_BASE_INFO_TYPE(VMI6, 0, VMIBase1);
+ CHECK_BASE_INFO_OFFSET_FLAGS(VMI6, 0, -24, __base_class_type_info::__public_mask | __base_class_type_info::__virtual_mask);
+ CHECK_BASE_INFO_TYPE(VMI6, 1, VMIBase3);
+ CHECK_BASE_INFO_OFFSET_FLAGS(VMI6, 1, 0, __base_class_type_info::__public_mask);
+
+ // VMI7 has both non-diamond and diamond shaped inheritance.
+ CHECK_VTABLE(VMI7, vmi_class);
+ CHECK(to<__vmi_class_type_info>(typeid(VMI7)).__flags == (__vmi_class_type_info::__non_diamond_repeat_mask | __vmi_class_type_info::__diamond_shaped_mask));
+ CHECK(to<__vmi_class_type_info>(typeid(VMI7)).__base_count == 3);
+ CHECK_BASE_INFO_TYPE(VMI7, 0, VMIBase1);
+ CHECK_BASE_INFO_OFFSET_FLAGS(VMI7, 0, 16, __base_class_type_info::__public_mask);
+ CHECK_BASE_INFO_TYPE(VMI7, 1, VMI5);
+ CHECK_BASE_INFO_OFFSET_FLAGS(VMI7, 1, 20, __base_class_type_info::__public_mask);
+ CHECK_BASE_INFO_TYPE(VMI7, 2, VMI6);
+ CHECK_BASE_INFO_OFFSET_FLAGS(VMI7, 2, 0, 0);
+
+ // Pointers to incomplete classes.
+ CHECK_VTABLE(Incomplete *, pointer);
+ CHECK(to<__pbase_type_info>(typeid(Incomplete *)).__flags == __pbase_type_info::__incomplete_mask);
+ CHECK(to<__pbase_type_info>(typeid(Incomplete **)).__flags == __pbase_type_info::__incomplete_mask);
+ CHECK(to<__pbase_type_info>(typeid(Incomplete ***)).__flags == __pbase_type_info::__incomplete_mask);
+
+ // Member pointers.
+ CHECK_VTABLE(int Incomplete::*, pointer_to_member);
+ CHECK(to<__pbase_type_info>(typeid(int Incomplete::*)).__flags == __pbase_type_info::__incomplete_class_mask);
+ CHECK(to<__pbase_type_info>(typeid(Incomplete Incomplete::*)).__flags == (__pbase_type_info::__incomplete_class_mask | __pbase_type_info::__incomplete_mask));
+ CHECK(to<__pbase_type_info>(typeid(Incomplete A::*)).__flags == (__pbase_type_info::__incomplete_mask));
+
+ // Check that when stripping qualifiers off the pointee type, we correctly handle arrays.
+ CHECK(to<__pbase_type_info>(typeid(B::a)).__flags == (__pbase_type_info::__const_mask | __pbase_type_info::__volatile_mask));
+ CHECK(to<__pbase_type_info>(typeid(B::a)).__pointee == to<__pbase_type_info>(typeid(B::b)).__pointee);
+ CHECK(to<__pbase_type_info>(typeid(B::c)).__flags == (__pbase_type_info::__const_mask | __pbase_type_info::__volatile_mask));
+ CHECK(to<__pbase_type_info>(typeid(B::c)).__pointee == to<__pbase_type_info>(typeid(B::d)).__pointee);
+
+ // Success!
+ // CHECK: ret i32 0
+ return 0;
+}
+
+#ifdef HARNESS
+extern "C" void printf(const char *, ...);
+
+int main() {
+ int result = f();
+
+ if (result == 0)
+ printf("success!\n");
+ else
+ printf("test on line %d failed!\n", result);
+
+ return result;
+}
+#endif
+
+
diff --git a/clang/test/CodeGenCXX/rtti-linkage.cpp b/clang/test/CodeGenCXX/rtti-linkage.cpp
new file mode 100644
index 0000000..42fe435
--- /dev/null
+++ b/clang/test/CodeGenCXX/rtti-linkage.cpp
@@ -0,0 +1,140 @@
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fhidden-weak-vtables -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fvisibility hidden -fhidden-weak-vtables -emit-llvm -o - | FileCheck -check-prefix=CHECK-WITH-HIDDEN %s
+
+#include <typeinfo>
+
+// CHECK-WITH-HIDDEN: _ZTSFN12_GLOBAL__N_11DEvE = internal constant
+// CHECK-WITH-HIDDEN: @_ZTSPK2T4 = linkonce_odr hidden constant
+// CHECK-WITH-HIDDEN: @_ZTS2T4 = linkonce_odr hidden constant
+// CHECK-WITH-HIDDEN: @_ZTI2T4 = linkonce_odr hidden unnamed_addr constant
+// CHECK-WITH-HIDDEN: @_ZTIPK2T4 = linkonce_odr hidden unnamed_addr constant
+
+// CHECK: _ZTSP1C = internal constant
+// CHECK: _ZTS1C = internal constant
+// CHECK: _ZTI1C = internal unnamed_addr constant
+// CHECK: _ZTIP1C = internal unnamed_addr constant
+// CHECK: _ZTSPP1C = internal constant
+// CHECK: _ZTIPP1C = internal unnamed_addr constant
+// CHECK: _ZTSM1Ci = internal constant
+// CHECK: _ZTIM1Ci = internal unnamed_addr constant
+// CHECK: _ZTSPM1Ci = internal constant
+// CHECK: _ZTIPM1Ci = internal unnamed_addr constant
+// CHECK: _ZTSM1CS_ = internal constant
+// CHECK: _ZTIM1CS_ = internal unnamed_addr constant
+// CHECK: _ZTSM1CPS_ = internal constant
+// CHECK: _ZTIM1CPS_ = internal unnamed_addr constant
+// CHECK: _ZTSM1A1C = internal constant
+// CHECK: _ZTS1A = linkonce_odr constant
+// CHECK: _ZTI1A = linkonce_odr hidden unnamed_addr constant
+// CHECK: _ZTIM1A1C = internal unnamed_addr constant
+// CHECK: _ZTSM1AP1C = internal constant
+// CHECK: _ZTIM1AP1C = internal unnamed_addr constant
+// CHECK: _ZTSN12_GLOBAL__N_11DE = internal constant
+// CHECK: _ZTIN12_GLOBAL__N_11DE = internal unnamed_addr constant
+// CHECK: _ZTSPN12_GLOBAL__N_11DE = internal constant
+// CHECK: _ZTIPN12_GLOBAL__N_11DE = internal unnamed_addr constant
+// CHECK: _ZTSFN12_GLOBAL__N_11DEvE = internal constant
+// CHECK: _ZTIFN12_GLOBAL__N_11DEvE = internal unnamed_addr constant
+// CHECK: _ZTSFvN12_GLOBAL__N_11DEE = internal constant
+// CHECK: _ZTIFvN12_GLOBAL__N_11DEE = internal unnamed_addr constant
+// CHECK: _ZTSPFvvE = linkonce_odr constant
+// CHECK: _ZTSFvvE = linkonce_odr constant
+// CHECK: _ZTIFvvE = linkonce_odr hidden unnamed_addr constant
+// CHECK: _ZTIPFvvE = linkonce_odr hidden unnamed_addr constant
+// CHECK: _ZTSN12_GLOBAL__N_11EE = internal constant
+// CHECK: _ZTIN12_GLOBAL__N_11EE = internal unnamed_addr constant
+// CHECK: _ZTSA10_i = linkonce_odr constant
+// CHECK: _ZTIA10_i = linkonce_odr hidden unnamed_addr constant
+// CHECK: _ZTI1TILj0EE = linkonce_odr unnamed_addr constant
+// CHECK: _ZTI1TILj1EE = weak_odr unnamed_addr constant
+// CHECK: _ZTI1TILj2EE = external constant
+// CHECK: _ZTS1B = constant
+// CHECK: _ZTI1B = unnamed_addr constant
+// CHECK: _ZTS1F = linkonce_odr constant
+
+// CHECK: _ZTIN12_GLOBAL__N_11DE to
+
+// A has no key function, so its RTTI data should be linkonce_odr.
+struct A { };
+
+// B has a key function defined in the translation unit, so the RTTI data should
+// be emitted in this translation unit and have external linkage.
+struct B : A {
+ virtual void f();
+};
+void B::f() { }
+
+// C is an incomplete class type, so any direct or indirect pointer types should have
+// internal linkage, as should the type info for C itself.
+struct C;
+
+void t1() {
+ (void)typeid(C*);
+ (void)typeid(C**);
+ (void)typeid(int C::*);
+ (void)typeid(int C::**);
+ (void)typeid(C C::*);
+ (void)typeid(C *C::*);
+ (void)typeid(C A::*);
+ (void)typeid(C* A::*);
+}
+
+namespace {
+ // D is inside an anonymous namespace, so all type information related to D should have
+ // internal linkage.
+ struct D { };
+
+ // E is also inside an anonymous namespace.
+ enum E { };
+
+};
+
+// F has a key function defined in the translation unit, but it is inline so the RTTI
+// data should be emitted with linkonce_odr linkage.
+struct F {
+ virtual void f();
+};
+
+inline void F::f() { }
+const D getD();
+
+const std::type_info &t2() {
+ (void)typeid(const D);
+ (void)typeid(D *);
+ (void)typeid(D (*)());
+ (void)typeid(void (*)(D));
+ (void)typeid(void (*)(D&));
+ // The exception specification is not part of the RTTI descriptor, so it should not have
+ // internal linkage.
+ (void)typeid(void (*)() throw (D));
+
+ (void)typeid(E);
+
+ return typeid(getD());
+}
+
+namespace Arrays {
+ struct A {
+ static const int a[10];
+ };
+ const std::type_info &f() {
+ return typeid(A::a);
+ }
+}
+
+template <unsigned N> class T {
+ virtual void anchor() {}
+};
+template class T<1>;
+template <> class T<2> { virtual void anchor(); };
+void t3() {
+ (void) typeid(T<0>);
+ (void) typeid(T<1>);
+ (void) typeid(T<2>);
+}
+
+// rdar://problem/8778973
+struct T4 {};
+void t4(const T4 *ptr) {
+ const void *value = &typeid(ptr);
+}
diff --git a/clang/test/CodeGenCXX/rtti-visibility.cpp b/clang/test/CodeGenCXX/rtti-visibility.cpp
new file mode 100644
index 0000000..40cee06
--- /dev/null
+++ b/clang/test/CodeGenCXX/rtti-visibility.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -o %t
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fhidden-weak-vtables -emit-llvm -o %t.hidden
+// RUN: FileCheck --check-prefix=CHECK-TEST1 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-TEST2 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-TEST2-HIDDEN %s < %t.hidden
+
+#include <typeinfo>
+
+namespace Test1 {
+ // A is explicitly marked hidden, so all RTTI data should also be marked hidden.
+ // CHECK-TEST1: @_ZTSN5Test11AE = linkonce_odr hidden constant
+ // CHECK-TEST1: @_ZTIN5Test11AE = linkonce_odr hidden unnamed_addr constant
+ // CHECK-TEST1: @_ZTSPN5Test11AE = linkonce_odr hidden constant
+ // CHECK-TEST1: @_ZTIPN5Test11AE = linkonce_odr hidden unnamed_addr constant
+ struct __attribute__((visibility("hidden"))) A { };
+
+ void f() {
+ (void)typeid(A);
+ (void)typeid(A *);
+ }
+}
+
+namespace Test2 {
+ // A is weak, so its linkage should be linkoce_odr, but not marked hidden.
+ // CHECK-TEST2: @_ZTSN5Test21AE = linkonce_odr constant
+ // CHECK-TEST2: @_ZTIN5Test21AE = linkonce_odr unnamed_addr constant
+ struct A { };
+
+ // With -fhidden-weak-vtables, the typeinfo for A is marked hidden, but not its name.
+ // CHECK-TEST2-HIDDEN: _ZTSN5Test21AE = linkonce_odr constant
+ // CHECK-TEST2-HIDDEN: @_ZTIN5Test21AE = linkonce_odr hidden unnamed_addr constant
+ void f() {
+ (void)typeid(A);
+ }
+}
diff --git a/clang/test/CodeGenCXX/rvalue-references.cpp b/clang/test/CodeGenCXX/rvalue-references.cpp
new file mode 100644
index 0000000..1c25543
--- /dev/null
+++ b/clang/test/CodeGenCXX/rvalue-references.cpp
@@ -0,0 +1,111 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+
+
+struct Spacer { int x; };
+struct A { double array[2]; };
+struct B : Spacer, A { };
+
+B &getB();
+
+// CHECK: define %struct.A* @_Z4getAv()
+// CHECK: call %struct.B* @_Z4getBv()
+// CHECK-NEXT: bitcast %struct.B*
+// CHECK-NEXT: getelementptr i8*
+// CHECK-NEXT: bitcast i8* {{.*}} to %struct.A*
+// CHECK-NEXT: ret %struct.A*
+A &&getA() { return static_cast<A&&>(getB()); }
+
+int &getIntLValue();
+int &&getIntXValue();
+int getIntPRValue();
+
+// CHECK: define i32* @_Z2f0v()
+// CHECK: call i32* @_Z12getIntLValuev()
+// CHECK-NEXT: ret i32*
+int &&f0() { return static_cast<int&&>(getIntLValue()); }
+
+// CHECK: define i32* @_Z2f1v()
+// CHECK: call i32* @_Z12getIntXValuev()
+// CHECK-NEXT: ret i32*
+int &&f1() { return static_cast<int&&>(getIntXValue()); }
+
+// CHECK: define i32* @_Z2f2v
+// CHECK: call i32 @_Z13getIntPRValuev()
+// CHECK-NEXT: store i32 {{.*}}, i32*
+// CHECK-NEXT: ret i32*
+int &&f2() { return static_cast<int&&>(getIntPRValue()); }
+
+bool ok;
+
+class C
+{
+ int* state_;
+
+ C(const C&) = delete;
+ C& operator=(const C&) = delete;
+public:
+ C(int state) : state_(new int(state)) { }
+
+ C(C&& a) {
+ state_ = a.state_;
+ a.state_ = 0;
+ }
+
+ ~C() {
+ delete state_;
+ state_ = 0;
+ }
+};
+
+C test();
+
+// CHECK: define void @_Z15elide_copy_initv
+void elide_copy_init() {
+ ok = false;
+ // CHECK: call void @_Z4testv
+ C a = test();
+ // CHECK-NEXT: call void @_ZN1CD1Ev
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @_Z16test_move_returnv
+C test_move_return() {
+ // CHECK: call void @_ZN1CC1Ei
+ C a1(3);
+ // CHECK: call void @_ZN1CC1Ei
+ C a2(4);
+ if (ok)
+ // CHECK: call void @_ZN1CC1EOS_
+ return a1;
+ // CHECK: call void @_ZN1CC1EOS_
+ return a2;
+ // CHECK: call void @_ZN1CD1Ev
+ // CHECK: call void @_ZN1CD1Ev
+ //CHECK: ret void
+}
+
+// PR10800: don't crash
+namespace test1 {
+ int &&move(int&);
+
+ struct A { A(int); };
+ struct B {
+ A a;
+ B(int i);
+ };
+
+ // CHECK: define void @_ZN5test11BC2Ei(
+ // CHECK: [[T0:%.*]] = call i32* @_ZN5test14moveERi(
+ // CHECK-NEXT: [[T1:%.*]] = load i32* [[T0]]
+ // CHECK-NEXT: call void @_ZN5test11AC1Ei({{.*}}, i32 [[T1]])
+ // CHECK-NEXT: ret void
+ B::B(int i) : a(move(i)) {}
+}
+
+// PR11009
+struct MoveConvertible {
+ operator int&& () const;
+};
+void moveConstruct() {
+ (void)(int)MoveConvertible();
+}
diff --git a/clang/test/CodeGenCXX/scoped-enums.cpp b/clang/test/CodeGenCXX/scoped-enums.cpp
new file mode 100644
index 0000000..fca0509
--- /dev/null
+++ b/clang/test/CodeGenCXX/scoped-enums.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s
+
+// PR9923
+enum class Color { red, blue, green };
+
+void f(Color);
+void g() {
+ f(Color::red);
+}
diff --git a/clang/test/CodeGenCXX/sel-address.mm b/clang/test/CodeGenCXX/sel-address.mm
new file mode 100644
index 0000000..c3db9a7
--- /dev/null
+++ b/clang/test/CodeGenCXX/sel-address.mm
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -verify -emit-llvm -o %t
+// pr7390
+
+void f(const SEL& v2) {}
+void g() {
+ f(@selector(dealloc));
+
+ SEL s = @selector(dealloc);
+ SEL* ps = &s;
+
+ @selector(dealloc) = s; // expected-error {{expression is not assignable}}
+
+ SEL* ps2 = &@selector(dealloc);
+}
diff --git a/clang/test/CodeGenCXX/sizeof-unwind-exception.cpp b/clang/test/CodeGenCXX/sizeof-unwind-exception.cpp
new file mode 100644
index 0000000..5db4df7
--- /dev/null
+++ b/clang/test/CodeGenCXX/sizeof-unwind-exception.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fcxx-exceptions -fexceptions %s -O2 -o - | FileCheck %s --check-prefix=X86-64
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fcxx-exceptions -fexceptions %s -O2 -o - | FileCheck %s --check-prefix=X86-32
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fcxx-exceptions -fexceptions %s -O2 -o - | FileCheck %s --check-prefix=ARM-DARWIN
+// RUN: %clang_cc1 -triple arm-unknown-gnueabi -emit-llvm -fcxx-exceptions -fexceptions %s -O2 -o - | FileCheck %s --check-prefix=ARM-EABI
+// RUN: %clang_cc1 -triple mipsel-unknown-unknown -emit-llvm -fcxx-exceptions -fexceptions %s -O2 -o - | FileCheck %s --check-prefix=MIPS
+
+void foo();
+void test() {
+ try {
+ foo();
+ } catch (int *&i) {
+ *i = 5;
+ }
+}
+
+// PR10789: different platforms have different sizes for struct UnwindException.
+
+// X86-64: [[T0:%.*]] = tail call i8* @__cxa_begin_catch(i8* [[EXN:%.*]]) nounwind
+// X86-64-NEXT: [[T1:%.*]] = getelementptr i8* [[EXN]], i64 32
+// X86-32: [[T0:%.*]] = tail call i8* @__cxa_begin_catch(i8* [[EXN:%.*]]) nounwind
+// X86-32-NEXT: [[T1:%.*]] = getelementptr i8* [[EXN]], i64 32
+// ARM-DARWIN: [[T0:%.*]] = tail call i8* @__cxa_begin_catch(i8* [[EXN:%.*]]) nounwind
+// ARM-DARWIN-NEXT: [[T1:%.*]] = getelementptr i8* [[EXN]], i64 32
+// ARM-EABI: [[T0:%.*]] = tail call i8* @__cxa_begin_catch(i8* [[EXN:%.*]]) nounwind
+// ARM-EABI-NEXT: [[T1:%.*]] = getelementptr i8* [[EXN]], i32 88
+// MIPS: [[T0:%.*]] = tail call i8* @__cxa_begin_catch(i8* [[EXN:%.*]]) nounwind
+// MIPS-NEXT: [[T1:%.*]] = getelementptr i8* [[EXN]], i32 24
+
diff --git a/clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp b/clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp
new file mode 100644
index 0000000..84697be
--- /dev/null
+++ b/clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp
@@ -0,0 +1,200 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// See Test9 for test description.
+// CHECK: @_ZTTN5Test91BE = linkonce_odr unnamed_addr constant
+namespace Test1 {
+
+// Check that we don't initialize the vtable pointer in A::~A(), since the destructor body is trivial.
+struct A {
+ virtual void f();
+ ~A();
+};
+
+// CHECK: define void @_ZN5Test11AD2Ev
+// CHECK-NOT: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test11AE, i64 0, i64 2), i8***
+A::~A()
+{
+}
+
+}
+
+namespace Test2 {
+
+// Check that we do initialize the vtable pointer in A::~A() since the destructor body isn't trivial.
+struct A {
+ virtual void f();
+ ~A();
+};
+
+// CHECK: define void @_ZN5Test21AD2Ev
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test21AE, i64 0, i64 2), i8***
+A::~A() {
+ f();
+}
+
+}
+
+namespace Test3 {
+
+// Check that we don't initialize the vtable pointer in A::~A(), since the destructor body is trivial
+// and Field's destructor body is also trivial.
+struct Field {
+ ~Field() { }
+};
+
+struct A {
+ virtual void f();
+ ~A();
+
+ Field field;
+};
+
+// CHECK: define void @_ZN5Test31AD2Ev
+// CHECK-NOT: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test31AE, i64 0, i64 2), i8***
+A::~A() {
+
+}
+
+}
+
+namespace Test4 {
+
+// Check that we do initialize the vtable pointer in A::~A(), since Field's destructor body
+// isn't trivial.
+
+void f();
+
+struct Field {
+ ~Field() { f(); }
+};
+
+struct A {
+ virtual void f();
+ ~A();
+
+ Field field;
+};
+
+// CHECK: define void @_ZN5Test41AD2Ev
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test41AE, i64 0, i64 2), i8***
+A::~A()
+{
+}
+
+}
+
+namespace Test5 {
+
+// Check that we do initialize the vtable pointer in A::~A(), since Field's destructor isn't
+// available in this translation unit.
+
+struct Field {
+ ~Field();
+};
+
+struct A {
+ virtual void f();
+ ~A();
+
+ Field field;
+};
+
+// CHECK: define void @_ZN5Test51AD2Ev
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test51AE, i64 0, i64 2), i8***
+A::~A()
+{
+}
+
+}
+
+namespace Test6 {
+
+// Check that we do initialize the vtable pointer in A::~A(), since Field has a member
+// variable with a non-trivial destructor body.
+
+struct NonTrivialDestructorBody {
+ ~NonTrivialDestructorBody();
+};
+
+struct Field {
+ NonTrivialDestructorBody nonTrivialDestructorBody;
+};
+
+struct A {
+ virtual void f();
+ ~A();
+
+ Field field;
+};
+
+// CHECK: define void @_ZN5Test61AD2Ev
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test61AE, i64 0, i64 2), i8***
+A::~A()
+{
+}
+
+}
+
+namespace Test7 {
+
+// Check that we do initialize the vtable pointer in A::~A(), since Field has a base
+// class with a non-trivial destructor body.
+
+struct NonTrivialDestructorBody {
+ ~NonTrivialDestructorBody();
+};
+
+struct Field : NonTrivialDestructorBody { };
+
+struct A {
+ virtual void f();
+ ~A();
+
+ Field field;
+};
+
+// CHECK: define void @_ZN5Test71AD2Ev
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test71AE, i64 0, i64 2), i8***
+A::~A()
+{
+}
+
+}
+
+namespace Test8 {
+
+// Check that we do initialize the vtable pointer in A::~A(), since Field has a virtual base
+// class with a non-trivial destructor body.
+
+struct NonTrivialDestructorBody {
+ ~NonTrivialDestructorBody();
+};
+
+struct Field : virtual NonTrivialDestructorBody { };
+
+struct A {
+ virtual void f();
+ ~A();
+
+ Field field;
+};
+
+// CHECK: define void @_ZN5Test81AD2Ev
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test81AE, i64 0, i64 2), i8***
+A::~A()
+{
+}
+
+}
+
+namespace Test9 {
+
+// Check that we emit a VTT for B, even though we don't initialize the vtable pointer in the destructor.
+struct A { virtual ~A () { } };
+struct B : virtual A {};
+struct C : virtual B {
+ virtual ~C();
+};
+C::~C() {}
+
+}
diff --git a/clang/test/CodeGenCXX/specialized-static-data-mem-init.cpp b/clang/test/CodeGenCXX/specialized-static-data-mem-init.cpp
new file mode 100644
index 0000000..c2a2ddb
--- /dev/null
+++ b/clang/test/CodeGenCXX/specialized-static-data-mem-init.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// rdar: // 8562966
+// pr8409
+
+// CHECK: @_ZN1CIiE11needs_guardE = weak_odr global
+// CHECK: @_ZGVN1CIiE11needs_guardE = weak_odr global
+
+struct K
+{
+ K();
+ K(const K &);
+ ~K();
+ void PrintNumK();
+};
+
+template<typename T>
+struct C
+{
+ void Go() { needs_guard.PrintNumK(); }
+ static K needs_guard;
+};
+
+template<typename T> K C<T>::needs_guard;
+
+void F()
+{
+ C<int>().Go();
+}
+
diff --git a/clang/test/CodeGenCXX/static-assert.cpp b/clang/test/CodeGenCXX/static-assert.cpp
new file mode 100644
index 0000000..53dc9a7
--- /dev/null
+++ b/clang/test/CodeGenCXX/static-assert.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -std=c++11 -verify
+
+static_assert(true, "");
+
+void f() {
+ static_assert(true, "");
+}
diff --git a/clang/test/CodeGenCXX/static-data-member.cpp b/clang/test/CodeGenCXX/static-data-member.cpp
new file mode 100644
index 0000000..4ad339d
--- /dev/null
+++ b/clang/test/CodeGenCXX/static-data-member.cpp
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @_ZN5test11A1aE = constant i32 10, align 4
+// CHECK: @_ZN5test212_GLOBAL__N_11AIiE1xE = internal global i32 0, align 4
+// CHECK: @_ZN5test31AIiE1xE = weak_odr global i32 0, align 4
+// CHECK: @_ZGVN5test31AIiE1xE = weak_odr global i64 0
+
+// CHECK: _ZN5test51U2k0E = global i32 0
+// CHECK: _ZN5test51U2k1E = global i32 0
+// CHECK: _ZN5test51U2k2E = constant i32 76
+// CHECK-NOT: test51U2k3E
+// CHECK-NOT: test51U2k4E
+
+// PR5564.
+namespace test1 {
+ struct A {
+ static const int a = 10;
+ };
+
+ const int A::a;
+
+ struct S {
+ static int i;
+ };
+
+ void f() {
+ int a = S::i;
+ }
+}
+
+// Test that we don't use guards for initializing template static data
+// members with internal linkage.
+namespace test2 {
+ int foo();
+
+ namespace {
+ template <class T> struct A {
+ static int x;
+ };
+
+ template <class T> int A<T>::x = foo();
+ template struct A<int>;
+ }
+
+ // CHECK: define internal void @__cxx_global_var_init()
+ // CHECK: [[TMP:%.*]] = call i32 @_ZN5test23fooEv()
+ // CHECK-NEXT: store i32 [[TMP]], i32* @_ZN5test212_GLOBAL__N_11AIiE1xE, align 4
+ // CHECK-NEXT: ret void
+}
+
+// Test that we don't use threadsafe statics when initializing
+// template static data members.
+namespace test3 {
+ int foo();
+
+ template <class T> struct A {
+ static int x;
+ };
+
+ template <class T> int A<T>::x = foo();
+ template struct A<int>;
+
+ // CHECK: define internal void @__cxx_global_var_init1()
+ // CHECK: [[GUARDBYTE:%.*]] = load i8* bitcast (i64* @_ZGVN5test31AIiE1xE to i8*)
+ // CHECK-NEXT: [[UNINITIALIZED:%.*]] = icmp eq i8 [[GUARDBYTE]], 0
+ // CHECK-NEXT: br i1 [[UNINITIALIZED]]
+ // CHECK: [[TMP:%.*]] = call i32 @_ZN5test33fooEv()
+ // CHECK-NEXT: store i32 [[TMP]], i32* @_ZN5test31AIiE1xE, align 4
+ // CHECK-NEXT: store i64 1, i64* @_ZGVN5test31AIiE1xE
+ // CHECK-NEXT: br label
+ // CHECK: ret void
+}
+
+// Test that we can fold member lookup expressions which resolve to static data
+// members.
+namespace test4 {
+ struct A {
+ static const int n = 76;
+ };
+
+ int f(A *a) {
+ // CHECK: define i32 @_ZN5test41fEPNS_1AE
+ // CHECK: ret i32 76
+ return a->n;
+ }
+}
+
+// Test that static data members in unions behave properly.
+namespace test5 {
+ union U {
+ static int k0;
+ static const int k1;
+ static const int k2 = 76;
+ static const int k3;
+ static const int k4 = 81;
+ };
+ int U::k0;
+ const int U::k1 = (k0 = 9, 42);
+ const int U::k2;
+
+ // CHECK: store i32 9, i32* @_ZN5test51U2k0E
+ // CHECK: store i32 {{.*}}, i32* @_ZN5test51U2k1E
+ // CHECK-NOT: store {{.*}} i32* @_ZN5test51U2k2E
+}
diff --git a/clang/test/CodeGenCXX/static-init-1.cpp b/clang/test/CodeGenCXX/static-init-1.cpp
new file mode 100644
index 0000000..a926c0a
--- /dev/null
+++ b/clang/test/CodeGenCXX/static-init-1.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin9 -emit-llvm %s -o %t
+// RUN: grep "call i32 @_Z5func1i" %t | count 3
+
+extern "C" int printf(...);
+
+static int count;
+
+int func2(int c) { return printf("loading the func2(%d)\n", c); };
+int func1(int c) { return printf("loading the func1(%d)\n", c); }
+
+static int loader_1 = func1(++count);
+
+int loader_2 = func2(++count);
+
+static int loader_3 = func1(++count);
+
+
+int main() {}
+
+int loader_4 = func2(++count);
+static int loader_5 = func1(++count);
+int loader_6 = func2(++count);
+
diff --git a/clang/test/CodeGenCXX/static-init-2.cpp b/clang/test/CodeGenCXX/static-init-2.cpp
new file mode 100644
index 0000000..768e6de
--- /dev/null
+++ b/clang/test/CodeGenCXX/static-init-2.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm-only -verify %s
+
+// Make sure we don't crash generating y; its value is constant, but the
+// initializer has side effects, so EmitConstantExpr should fail.
+int x();
+int y = x() & 0;
diff --git a/clang/test/CodeGenCXX/static-init-3.cpp b/clang/test/CodeGenCXX/static-init-3.cpp
new file mode 100644
index 0000000..dc28d5a
--- /dev/null
+++ b/clang/test/CodeGenCXX/static-init-3.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10.0.0 -o - %s | FileCheck %s
+
+// PR7050
+template<class T> struct X0 : public T { };
+
+template <class T>
+struct X1
+{
+ static T & instance;
+ // include this to provoke instantiation at pre-execution time
+ static void use(T const &) {}
+ static T & get() {
+ static X0<T> t;
+ use(instance);
+ return static_cast<T &>(t);
+ }
+};
+
+// CHECK: @_ZN2X1I2X2I1BEE8instanceE = weak_odr global %struct.X2* null, align 8
+// CHECJ: @_ZN2X1I2X2I1AEE8instanceE = weak_odr global %struct.X2* null, align 8
+template<class T> T & X1<T>::instance = X1<T>::get();
+
+class A { };
+class B : public A { };
+
+template<typename T> struct X2 {};
+X2< B > bg = X1< X2< B > >::get();
+X2< A > ag = X1< X2< A > >::get();
diff --git a/clang/test/CodeGenCXX/static-init.cpp b/clang/test/CodeGenCXX/static-init.cpp
new file mode 100644
index 0000000..74278f7
--- /dev/null
+++ b/clang/test/CodeGenCXX/static-init.cpp
@@ -0,0 +1,154 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// CHECK: @_ZZ1hvE1i = internal global i32 0, align 4
+// CHECK: @base_req = global [4 x i8] c"foo\00", align 1
+// CHECK: @base_req_uchar = global [4 x i8] c"bar\00", align 1
+
+// CHECK: @_ZZN5test31BC1EvE1u = internal global { i8, [3 x i8] } { i8 97, [3 x i8] undef }, align 4
+// CHECK: @_ZZN5test1L6getvarEiE3var = internal constant [4 x i32] [i32 1, i32 0, i32 2, i32 4], align 16
+// CHECK: @_ZZ2h2vE1i = linkonce_odr global i32 0
+// CHECK: @_ZGVZ2h2vE1i = linkonce_odr global i64 0
+
+struct A {
+ A();
+ ~A();
+};
+
+void f() {
+ // CHECK: load atomic i8* bitcast (i64* @_ZGVZ1fvE1a to i8*) acquire, align 1
+ // CHECK: call i32 @__cxa_guard_acquire
+ // CHECK: call void @_ZN1AC1Ev
+ // CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @_ZZ1fvE1a, i32 0, i32 0), i8* @__dso_handle)
+ // CHECK: call void @__cxa_guard_release
+ static A a;
+}
+
+void g() {
+ // CHECK: call noalias i8* @_Znwm(i64 1)
+ // CHECK: call void @_ZN1AC1Ev(
+ static A& a = *new A;
+}
+
+int a();
+void h() {
+ static const int i = a();
+}
+
+inline void h2() {
+ static int i = a();
+}
+
+void h3() {
+ h2();
+}
+
+// PR6980: this shouldn't crash
+namespace test0 {
+ struct A { A(); };
+ __attribute__((noreturn)) int throw_exception();
+
+ void test() {
+ throw_exception();
+ static A r;
+ }
+}
+
+namespace test1 {
+ // CHECK: define internal i32 @_ZN5test1L6getvarEi(
+ static inline int getvar(int index) {
+ static const int var[] = { 1, 0, 2, 4 };
+ return var[index];
+ }
+
+ void test() { (void) getvar(2); }
+}
+
+// Make sure we emit the initializer correctly for the following:
+char base_req[] = { "foo" };
+unsigned char base_req_uchar[] = { "bar" };
+
+namespace union_static_local {
+ // CHECK: define internal void @_ZZN18union_static_local4testEvEN1c4mainEv
+ // CHECK: call void @_ZN18union_static_local1fEPNS_1xE(%"union.union_static_local::x"* bitcast ({ [2 x i8*] }* @_ZZN18union_static_local4testEvE3foo to %"union.union_static_local::x"*))
+ union x { long double y; const char *x[2]; };
+ void f(union x*);
+ void test() {
+ static union x foo = { .x = { "a", "b" } };
+ struct c {
+ static void main() {
+ f(&foo);
+ }
+ };
+ c::main();
+ }
+}
+
+// rdar://problem/11091093
+// Static variables should be consistent across constructor
+// or destructor variants.
+namespace test2 {
+ struct A {
+ A();
+ ~A();
+ };
+
+ struct B : virtual A {
+ B();
+ ~B();
+ };
+
+ // If we ever implement this as a delegate ctor call, just change
+ // this to take variadic arguments or something.
+ extern int foo();
+ B::B() {
+ static int x = foo();
+ }
+ // CHECK: define void @_ZN5test21BC1Ev
+ // CHECK: load atomic i8* bitcast (i64* @_ZGVZN5test21BC1EvE1x to i8*) acquire,
+ // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVZN5test21BC1EvE1x)
+ // CHECK: [[T0:%.*]] = call i32 @_ZN5test23fooEv()
+ // CHECK: store i32 [[T0]], i32* @_ZZN5test21BC1EvE1x,
+ // CHECK: call void @__cxa_guard_release(i64* @_ZGVZN5test21BC1EvE1x)
+
+ // CHECK: define void @_ZN5test21BC2Ev
+ // CHECK: load atomic i8* bitcast (i64* @_ZGVZN5test21BC1EvE1x to i8*) acquire,
+ // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVZN5test21BC1EvE1x)
+ // CHECK: [[T0:%.*]] = call i32 @_ZN5test23fooEv()
+ // CHECK: store i32 [[T0]], i32* @_ZZN5test21BC1EvE1x,
+ // CHECK: call void @__cxa_guard_release(i64* @_ZGVZN5test21BC1EvE1x)
+
+ // This is just for completeness, because we actually emit this
+ // using a delegate dtor call.
+ B::~B() {
+ static int y = foo();
+ }
+ // CHECK: define void @_ZN5test21BD1Ev(
+ // CHECK: call void @_ZN5test21BD2Ev(
+
+ // CHECK: define void @_ZN5test21BD2Ev(
+ // CHECK: load atomic i8* bitcast (i64* @_ZGVZN5test21BD1EvE1y to i8*) acquire,
+ // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVZN5test21BD1EvE1y)
+ // CHECK: [[T0:%.*]] = call i32 @_ZN5test23fooEv()
+ // CHECK: store i32 [[T0]], i32* @_ZZN5test21BD1EvE1y,
+ // CHECK: call void @__cxa_guard_release(i64* @_ZGVZN5test21BD1EvE1y)
+}
+
+// This shouldn't error out.
+namespace test3 {
+ struct A {
+ A();
+ ~A();
+ };
+
+ struct B : virtual A {
+ B();
+ ~B();
+ };
+
+ B::B() {
+ union U { char x; int i; };
+ static U u = { 'a' };
+ }
+ // CHECK: define void @_ZN5test31BC1Ev(
+ // CHECK: define void @_ZN5test31BC2Ev(
+}
diff --git a/clang/test/CodeGenCXX/static-local-in-local-class.cpp b/clang/test/CodeGenCXX/static-local-in-local-class.cpp
new file mode 100644
index 0000000..ebf560a
--- /dev/null
+++ b/clang/test/CodeGenCXX/static-local-in-local-class.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// PR6769
+
+struct X {
+ static void f();
+};
+
+void X::f() {
+ static int *i;
+ {
+ struct Y {
+ static void g() {
+ i = new int();
+ *i = 100;
+ (*i) = (*i) +1;
+ }
+ };
+ (void)Y::g();
+ }
+ (void)i;
+}
+
+// pr7101
+void foo() {
+ static int n = 0;
+ struct Helper {
+ static void Execute() {
+ n++;
+ }
+ };
+ Helper::Execute();
+}
+
diff --git a/clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp b/clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
new file mode 100644
index 0000000..94fd9aa
--- /dev/null
+++ b/clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// CHECK: ; ModuleID
+template<typename> struct A { static int a; };
+
+// CHECK-NOT: @_ZN1AIcE1aE
+template<> int A<char>::a;
+
+// CHECK: @_ZN1AIbE1aE = global i32 10
+template<> int A<bool>::a = 10;
+
+
diff --git a/clang/test/CodeGenCXX/static-mutable.cpp b/clang/test/CodeGenCXX/static-mutable.cpp
new file mode 100644
index 0000000..6d51f24
--- /dev/null
+++ b/clang/test/CodeGenCXX/static-mutable.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -triple=i686-linux-gnu -emit-llvm -o - | FileCheck %s
+
+struct S {
+ mutable int n;
+};
+int f() {
+ // The purpose of this test is to ensure that this variable is a global
+ // not a constant.
+ // CHECK: @_ZZ1fvE1s = internal global {{.*}} { i32 12 }
+ static const S s = { 12 };
+ return ++s.n;
+}
diff --git a/clang/test/CodeGenCXX/stmtexpr.cpp b/clang/test/CodeGenCXX/stmtexpr.cpp
new file mode 100644
index 0000000..1f0e4ac
--- /dev/null
+++ b/clang/test/CodeGenCXX/stmtexpr.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -Wno-unused-value -emit-llvm -o - %s | FileCheck %s
+// rdar: //8540501
+extern "C" int printf(...);
+extern "C" void abort();
+
+struct A
+{
+ int i;
+ A (int j) : i(j) {printf("this = %p A(%d)\n", this, j);}
+ A (const A &j) : i(j.i) {printf("this = %p const A&(%d)\n", this, i);}
+ A& operator= (const A &j) { i = j.i; abort(); return *this; }
+ ~A() { printf("this = %p ~A(%d)\n", this, i); }
+};
+
+struct B
+{
+ int i;
+ B (const A& a) { i = a.i; }
+ B() {printf("this = %p B()\n", this);}
+ B (const B &j) : i(j.i) {printf("this = %p const B&(%d)\n", this, i);}
+ ~B() { printf("this = %p ~B(%d)\n", this, i); }
+};
+
+A foo(int j)
+{
+ return ({ j ? A(1) : A(0); });
+}
+
+
+void foo2()
+{
+ A b = ({ A a(1); A a1(2); A a2(3); a1; a2; a; });
+ if (b.i != 1)
+ abort();
+ A c = ({ A a(1); A a1(2); A a2(3); a1; a2; a; A a3(4); a2; a3; });
+ if (c.i != 4)
+ abort();
+}
+
+void foo3()
+{
+ const A &b = ({ A a(1); a; });
+ if (b.i != 1)
+ abort();
+}
+
+void foo4()
+{
+// CHECK: call {{.*}} @_ZN1AC1Ei
+// CHECK: call {{.*}} @_ZN1AC1ERKS_
+// CHECK: call {{.*}} @_ZN1AD1Ev
+// CHECK: call {{.*}} @_ZN1BC1ERK1A
+// CHECK: call {{.*}} @_ZN1AD1Ev
+ const B &b = ({ A a(1); a; });
+ if (b.i != 1)
+ abort();
+}
+
+int main()
+{
+ foo2();
+ foo3();
+ foo4();
+ return foo(1).i-1;
+}
+
+// rdar: // 8600553
+int a[128];
+int* foo5() {
+// CHECK-NOT: memcpy
+ // Check that array-to-pointer conversion occurs in a
+ // statement-expression.
+ return (({ a; }));
+}
+
diff --git a/clang/test/CodeGenCXX/switch-case-folding-1.cpp b/clang/test/CodeGenCXX/switch-case-folding-1.cpp
new file mode 100644
index 0000000..1daeecf
--- /dev/null
+++ b/clang/test/CodeGenCXX/switch-case-folding-1.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -emit-llvm-only
+// CHECK that we don't crash.
+
+int test(int val){
+ int x = 12;
+ // Make sure we don't crash when constant folding the case 4
+ // statement due to the case 5 statement contained in the do loop
+ switch (val) {
+ case 4: do {
+ switch (6) {
+ case 6: {
+ case 5: x++;
+ };
+ };
+ } while (x < 100);
+ }
+ return x;
+}
+
+int main(void) {
+ return test(4);
+}
diff --git a/clang/test/CodeGenCXX/switch-case-folding-2.cpp b/clang/test/CodeGenCXX/switch-case-folding-2.cpp
new file mode 100644
index 0000000..7c0283f
--- /dev/null
+++ b/clang/test/CodeGenCXX/switch-case-folding-2.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// CHECK that we don't crash.
+
+extern int printf(const char*, ...);
+int test(int val){
+ switch (val) {
+ case 4:
+ do {
+ switch (6) {
+ case 6: do { case 5: printf("bad\n"); } while (0);
+ };
+ } while (0);
+ }
+ return 0;
+}
+
+int main(void) {
+ return test(5);
+}
+
+// CHECK: call i32 (i8*, ...)* @_Z6printfPKcz
diff --git a/clang/test/CodeGenCXX/switch-case-folding.cpp b/clang/test/CodeGenCXX/switch-case-folding.cpp
new file mode 100644
index 0000000..d4444b1
--- /dev/null
+++ b/clang/test/CodeGenCXX/switch-case-folding.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -emit-llvm-only
+// CHECK that we don't crash.
+
+int main(void){
+ int x = 12;
+ // Make sure we don't crash when constant folding the case 4
+ // statement due to the case 5 statement contained in the do loop
+ switch (4) {
+ case 4: do {
+ switch (6) {
+ case 6: {
+ case 5: x++;
+ };
+ };
+ } while (x < 100);
+ }
+ return x;
+}
diff --git a/clang/test/CodeGenCXX/temp-order.cpp b/clang/test/CodeGenCXX/temp-order.cpp
new file mode 100644
index 0000000..341cd0c
--- /dev/null
+++ b/clang/test/CodeGenCXX/temp-order.cpp
@@ -0,0 +1,226 @@
+// Output file should have no calls to error() with folding.
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O3 -emit-llvm -o %t %s
+// RUN: FileCheck %s < %t
+
+static unsigned pow(unsigned Base, unsigned Power) {
+ unsigned Val = 1;
+ while (Power--)
+ Val *= Base;
+ return Val;
+}
+
+struct TempTracker {
+ unsigned Product, Index;
+
+ TempTracker() : Product(1), Index(0) {}
+
+};
+
+// FIXME: This can be used to check elision as well, if P = 0 hacks are removed.
+struct A {
+ TempTracker &TT;
+ mutable unsigned P;
+ bool Truth;
+
+ A(TempTracker &_TT, unsigned _P, bool _Truth = true)
+ : TT(_TT), P(_P), Truth(_Truth) {}
+ A(const A &RHS) : TT(RHS.TT), P(RHS.P), Truth(RHS.Truth) { RHS.P = 0; }
+ ~A() {
+ if (P)
+ TT.Product *= pow(P, ++TT.Index);
+ }
+
+ A &operator=(const A &RHS) {
+ TT = RHS.TT;
+ P = RHS.P;
+ Truth = RHS.Truth;
+ RHS.P = 0;
+ return *this;
+ }
+
+ operator bool () { return Truth; }
+};
+
+// 3, 7, 2
+static unsigned f0(bool val = false) {
+ TempTracker tt;
+ {
+ A a(tt, 2);
+ if ((A(tt, 3), val))
+ A b(tt, 5);
+ A c(tt, 7);
+ }
+ return tt.Product;
+}
+
+// 3, 5, 7, 2
+static unsigned f1(bool val = true) {
+ TempTracker tt;
+ {
+ A a(tt, 2);
+ if ((A(tt, 3), val))
+ A b(tt, 5);
+ A c(tt, 7);
+ }
+ return tt.Product;
+}
+
+// 5, 3, 7, 2
+static unsigned f2() {
+ TempTracker tt;
+ {
+ A a(tt, 2);
+ if (A b = A(tt, 3))
+ A c(tt, 5);
+ A d(tt, 7);
+ }
+ return tt.Product;
+}
+
+// 7, 3, 11, 2
+static unsigned f3() {
+ TempTracker tt;
+ {
+ A a(tt, 2);
+ if (A b = A(tt, 3, false))
+ A c(tt, 5);
+ else
+ A c(tt, 7);
+ A d(tt, 11);
+ }
+ return tt.Product;
+}
+
+// 3, 7, 2
+static unsigned f4() {
+ TempTracker tt;
+ {
+ A a(tt, 2);
+ while (A b = A(tt, 3, false))
+ A c(tt, 5);
+ A c(tt, 7);
+ }
+ return tt.Product;
+}
+
+// 5, 3, 7, 2
+static unsigned f5() {
+ TempTracker tt;
+ {
+ A a(tt, 2);
+ while (A b = A(tt, 3, true)) {
+ A c(tt, 5);
+ break;
+ }
+ A c(tt, 7);
+ }
+ return tt.Product;
+}
+
+// 3, 7, 11, 5, 13, 2
+static unsigned f6() {
+ TempTracker tt;
+ {
+ A a(tt, 2);
+ for (A b = (A(tt, 3), A(tt, 5)), c = (A(tt, 7), A(tt, 11));;)
+ break;
+ A c(tt, 13);
+ }
+ return tt.Product;
+}
+
+// 5, 2
+static unsigned f7() {
+ TempTracker tt;
+ {
+ (void)((A(tt, 2, false) && A(tt, 3, false)) || A(tt, 5, false));
+ }
+ return tt.Product;
+}
+
+// 5, 2
+static unsigned f8() {
+ TempTracker tt;
+
+ {
+ (void)((A(tt, 2) || A(tt, 3)) && A(tt, 5));
+ }
+ return tt.Product;
+}
+
+extern "C" void error();
+extern "C" void print(const char *Name, unsigned N);
+
+#define ORDER2(a, b) (pow(a, 1) * pow(b, 2))
+#define ORDER3(a, b, c) (ORDER2(a, b) * pow(c, 3))
+#define ORDER4(a, b, c, d) (ORDER3(a, b, c) * pow(d, 4))
+#define ORDER5(a, b, c, d, e) (ORDER4(a, b, c, d) * pow(e, 5))
+#define ORDER6(a, b, c, d, e, f) (ORDER5(a, b, c, d, e) * pow(f, 6))
+void test() {
+// CHECK: call void @print(i8* {{.*}}, i32 1176)
+ print("f0", f0());
+ if (f0() != ORDER3(3, 7, 2))
+ error();
+
+// CHECK: call void @print(i8* {{.*}}, i32 411600)
+ print("f1", f1());
+ if (f1() != ORDER4(3, 5, 7, 2))
+ error();
+
+// CHECK: call void @print(i8* {{.*}}, i32 246960)
+ print("f2", f2());
+ if (f2() != ORDER4(5, 3, 7, 2))
+ error();
+
+// CHECK: call void @print(i8* {{.*}}, i32 1341648)
+ print("f3", f3());
+ if (f3() != ORDER4(7, 3, 11, 2))
+ error();
+
+// CHECK: call void @print(i8* {{.*}}, i32 1176)
+ print("f4", f4());
+ if (f4() != ORDER3(3, 7, 2))
+ error();
+
+// CHECK: call void @print(i8* {{.*}}, i32 246960)
+ print("f5", f5());
+ if (f5() != ORDER4(5, 3, 7, 2))
+ error();
+
+// CHECK: call void @print(i8* {{.*}}, i32 1251552576)
+ print("f6", f6());
+ if (f6() != ORDER6(3, 7, 11, 5, 13, 2))
+ error();
+
+// CHECK: call void @print(i8* {{.*}}, i32 20)
+ print("f7", f7());
+ if (f7() != ORDER2(5, 2))
+ error();
+
+// CHECK: call void @print(i8* {{.*}}, i32 20)
+ print("f8", f8());
+ if (f8() != ORDER2(5, 2))
+ error();
+}
+
+
+
+#ifdef HARNESS
+
+#include <cstdlib>
+#include <cstdio>
+
+extern "C" void error() {
+ abort();
+}
+
+extern "C" void print(const char *name, unsigned N) {
+ printf("%s: %d\n", name, N);
+}
+
+int main() {
+ test();
+ return 0;
+}
+
+#endif
diff --git a/clang/test/CodeGenCXX/template-anonymous-types.cpp b/clang/test/CodeGenCXX/template-anonymous-types.cpp
new file mode 100644
index 0000000..72fe090
--- /dev/null
+++ b/clang/test/CodeGenCXX/template-anonymous-types.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -o - | FileCheck %s
+
+struct S {
+ enum { FOO = 42 };
+ enum { BAR = 42 };
+};
+
+template <typename T> struct X {
+ T value;
+ X(T t) : value(t) {}
+ int f() { return value; }
+};
+
+template <typename T> int f(T t) {
+ X<T> x(t);
+ return x.f();
+}
+
+void test() {
+ // Look for two instantiations, entirely internal to this TU, one for FOO's
+ // type and one for BAR's.
+ // CHECK: define internal i32 @"_Z1fIN1S3$_0EEiT_"(i32 %t)
+ (void)f(S::FOO);
+ // CHECK: define internal i32 @"_Z1fIN1S3$_1EEiT_"(i32 %t)
+ (void)f(S::BAR);
+
+ // Now check for the class template instantiations. Annoyingly, they are in
+ // reverse order.
+ //
+ // BAR's instantiation of X:
+ // CHECK: define internal i32 @"_ZN1XIN1S3$_1EE1fEv"(%struct.X* %this)
+ // CHECK: define internal void @"_ZN1XIN1S3$_1EEC2ES1_"(%struct.X* %this, i32 %t) unnamed_addr
+ //
+ // FOO's instantiation of X:
+ // CHECK: define internal i32 @"_ZN1XIN1S3$_0EE1fEv"(%struct.X.0* %this)
+ // CHECK: define internal void @"_ZN1XIN1S3$_0EEC2ES1_"(%struct.X.0* %this, i32 %t) unnamed_addr
+}
diff --git a/clang/test/CodeGenCXX/template-anonymous-union-member-initializer.cpp b/clang/test/CodeGenCXX/template-anonymous-union-member-initializer.cpp
new file mode 100644
index 0000000..41ae084
--- /dev/null
+++ b/clang/test/CodeGenCXX/template-anonymous-union-member-initializer.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+template <typename T>
+class A
+{
+ union { void *d; };
+
+public:
+ A() : d(0) { }
+};
+
+A<int> a0;
diff --git a/clang/test/CodeGenCXX/template-dependent-bind-temporary.cpp b/clang/test/CodeGenCXX/template-dependent-bind-temporary.cpp
new file mode 100644
index 0000000..cc1ce86
--- /dev/null
+++ b/clang/test/CodeGenCXX/template-dependent-bind-temporary.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// rdar: //8620524
+// PR7851
+struct string {
+ string (const string& );
+ string ();
+ ~string();
+};
+
+string operator + (char ch, const string&);
+
+template <class T>
+void IntToString(T a)
+{
+ string result;
+ T digit;
+ char((digit < 10 ? '0' : 'a') + digit) + result;
+}
+
+int main() {
+// CHECK: define linkonce_odr void @_Z11IntToStringIcEvT_(
+ IntToString('a');
+}
+
diff --git a/clang/test/CodeGenCXX/template-inner-struct-visibility-hidden.cpp b/clang/test/CodeGenCXX/template-inner-struct-visibility-hidden.cpp
new file mode 100644
index 0000000..2c62b60
--- /dev/null
+++ b/clang/test/CodeGenCXX/template-inner-struct-visibility-hidden.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fvisibility hidden -emit-llvm -o - %s | FileCheck %s
+
+// Verify that symbols are hidden.
+// CHECK: @_ZN1CIiE5Inner6Inner26StaticE = weak_odr hidden global
+// CHECK: define weak_odr hidden void @_ZN1CIiE5Inner1fEv
+// CHECK: define weak_odr hidden void @_ZN1CIiE5Inner6Inner21gEv
+
+template<typename T>
+struct C {
+ struct Inner {
+ void f();
+ struct Inner2 {
+ void g();
+ static int Static;
+ };
+ };
+};
+
+template<typename T> void C<T>::Inner::f() { }
+template<typename T> void C<T>::Inner::Inner2::g() { }
+template<typename T> int C<T>::Inner::Inner2::Static;
+
+extern template struct C<int>;
+template struct C<int>;
diff --git a/clang/test/CodeGenCXX/template-instantiation.cpp b/clang/test/CodeGenCXX/template-instantiation.cpp
new file mode 100644
index 0000000..09b3a4f
--- /dev/null
+++ b/clang/test/CodeGenCXX/template-instantiation.cpp
@@ -0,0 +1,190 @@
+// RUN: %clang_cc1 %s -O1 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// CHECK: @_ZN7PR100011xE = global
+// CHECK-NOT: @_ZN7PR100014kBarE = external global i32
+//
+// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
+// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
+// CHECK: @_ZTVN5test018stdio_sync_filebufIwEE = unnamed_addr constant
+
+// CHECK: @_ZN7PR100011SIiE3arrE = weak_odr global [3 x i32]
+// CHECK-NOT: @_ZN7PR100011SIiE3arr2E = weak_odr global [3 x i32]A
+
+// CHECK-NOT: _ZTVN5test31SIiEE
+// CHECK-NOT: _ZTSN5test31SIiEE
+
+// CHECK: define linkonce_odr void @_ZN5test21CIiEC1Ev(%"class.test2::C"* nocapture %this) unnamed_addr
+// CHECK: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_(
+// CHECK: define available_externally void @_ZN5test21CIiE6zedbarEd(
+
+// CHECK: define linkonce_odr void @_ZN7PR106662g1ENS_1SILi1EEE()
+// CHECK: define linkonce_odr void @_ZN7PR106662g1ENS_1SILi2EEE()
+// CHECK: define linkonce_odr void @_ZN7PR106662g1ENS_1SILi3EEE()
+// CHECK: define linkonce_odr void @_ZN7PR106662g2ENS_1SILi1EEE()
+// CHECK: define linkonce_odr void @_ZN7PR106662g2ENS_1SILi2EEE()
+// CHECK: define linkonce_odr void @_ZN7PR106662g2ENS_1SILi3EEE()
+// CHECK: declare void @_ZN7PR106662h1ENS_1SILi1EEE()
+// CHECK: declare void @_ZN7PR106662h1ENS_1SILi2EEE()
+// CHECK: declare void @_ZN7PR106662h1ENS_1SILi3EEE()
+// CHECK: declare void @_ZN7PR106662h2ENS_1SILi1EEE()
+// CHECK: declare void @_ZN7PR106662h2ENS_1SILi2EEE()
+// CHECK: declare void @_ZN7PR106662h2ENS_1SILi3EEE()
+
+namespace test0 {
+ struct basic_streambuf {
+ virtual ~basic_streambuf();
+ };
+ template<typename _CharT >
+ struct stdio_sync_filebuf : public basic_streambuf {
+ virtual void xsgetn();
+ };
+
+ // This specialization should cause the vtable to be emitted, even with
+ // the following extern template declaration.
+ template<> void stdio_sync_filebuf<wchar_t>::xsgetn() {
+ }
+ extern template class stdio_sync_filebuf<wchar_t>;
+}
+
+namespace test1 {
+ struct basic_streambuf {
+ virtual ~basic_streambuf();
+ };
+ template<typename _CharT >
+ struct stdio_sync_filebuf : public basic_streambuf {
+ virtual void xsgetn();
+ };
+
+ // Just a declaration should not force the vtable to be emitted.
+ template<> void stdio_sync_filebuf<wchar_t>::xsgetn();
+}
+
+namespace test2 {
+ template<typename T1>
+ class C {
+ public:
+ virtual ~C();
+ void zedbar(double) {
+ }
+ template<typename T2>
+ void foobar(T2 foo) {
+ }
+ };
+ extern template class C<int>;
+ void g() {
+ // The extern template declaration should not prevent us from producing
+ // the implicit constructor (test at the top).
+ C<int> a;
+
+ // or foobar(test at the top).
+ a.foobar(0.0);
+
+ // But it should prevent zebbar
+ // (test at the top).
+ a.zedbar(0.0);
+ }
+}
+
+namespace test3 {
+ template<typename T>
+ class basic_fstreamXX {
+ virtual void foo(){}
+ virtual void is_open() const { }
+ };
+
+ extern template class basic_fstreamXX<char>;
+ // This template instantiation should not cause us to produce a vtable.
+ // (test at the top).
+ template void basic_fstreamXX<char>::is_open() const;
+}
+
+namespace test3 {
+ template <typename T>
+ struct S {
+ virtual void m();
+ };
+
+ template<typename T>
+ void S<T>::m() { }
+
+ // Should not cause us to produce vtable because template instantiations
+ // don't have key functions.
+ template void S<int>::m();
+}
+
+namespace test4 {
+ template <class T> struct A { static void foo(); };
+
+ class B {
+ template <class T> friend void A<T>::foo();
+ B();
+ };
+
+ template <class T> void A<T>::foo() {
+ B b;
+ }
+
+ unsigned test() {
+ A<int>::foo();
+ }
+}
+
+namespace PR8505 {
+// Hits an assertion due to bogus instantiation of class B.
+template <int i> class A {
+ class B* g;
+};
+class B {
+ void f () {}
+};
+// Should not instantiate class B since it is introduced in namespace scope.
+// CHECK-NOT: _ZN6PR85051AILi0EE1B1fEv
+template class A<0>;
+}
+
+// Ensure that when instantiating initializers for static data members to
+// complete their type in an unevaluated context, we *do* emit initializers with
+// side-effects, but *don't* emit initializers and variables which are otherwise
+// unused in the program.
+namespace PR10001 {
+ template <typename T> struct S {
+ static const int arr[];
+ static const int arr2[];
+ static const int x, y;
+ static int f();
+ };
+
+ extern int foo();
+ extern int kBar;
+
+ template <typename T> const int S<T>::arr[] = { 1, 2, foo() }; // possible side effects
+ template <typename T> const int S<T>::arr2[] = { 1, 2, kBar }; // no side effects
+ template <typename T> const int S<T>::x = sizeof(arr) / sizeof(arr[0]);
+ template <typename T> const int S<T>::y = sizeof(arr2) / sizeof(arr2[0]);
+ template <typename T> int S<T>::f() { return x + y; }
+
+ int x = S<int>::f();
+}
+
+// Ensure that definitions are emitted for all friend functions defined within
+// class templates. Order of declaration is extremely important here. Different
+// instantiations of the class happen at different points during the deferred
+// method body parsing and afterward. Those different points of instantiation
+// change the exact form the class template appears to have.
+namespace PR10666 {
+ template <int N> struct S {
+ void f1() { S<1> s; }
+ friend void g1(S s) {}
+ friend void h1(S s);
+ void f2() { S<2> s; }
+ friend void g2(S s) {}
+ friend void h2(S s);
+ void f3() { S<3> s; }
+ };
+ void test(S<1> s1, S<2> s2, S<3> s3) {
+ g1(s1); g1(s2); g1(s3);
+ g2(s1); g2(s2); g2(s3);
+ h1(s1); h1(s2); h1(s3);
+ h2(s1); h2(s2); h2(s3);
+ }
+}
diff --git a/clang/test/CodeGenCXX/template-linkage.cpp b/clang/test/CodeGenCXX/template-linkage.cpp
new file mode 100644
index 0000000..20508c1
--- /dev/null
+++ b/clang/test/CodeGenCXX/template-linkage.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+template<typename T> struct A {
+ virtual void f(T) { }
+ inline void g() { }
+};
+
+// Explicit instantiations have external linkage.
+
+// CHECK: define weak_odr void @_ZN1AIiE1gEv(
+template void A<int>::g();
+
+// CHECK: define weak_odr void @_ZN1AIfE1fEf(
+// CHECK: define weak_odr void @_ZN1AIfE1gEv(
+// FIXME: This should also emit the vtable.
+template struct A<float>;
+
+// CHECK: define weak_odr void @_Z1fIiEvT_
+template <typename T> void f(T) { }
+template void f<int>(int);
+
+// CHECK: define weak_odr void @_Z1gIiEvT_
+template <typename T> inline void g(T) { }
+template void g<int>(int);
+
+template<typename T>
+struct X0 {
+ virtual ~X0() { }
+};
+
+template<typename T>
+struct X1 : X0<T> {
+ virtual void blarg();
+};
+
+template<typename T> void X1<T>::blarg() { }
+
+extern template struct X0<char>;
+extern template struct X1<char>;
+
+// CHECK: define linkonce_odr void @_ZN2X1IcED1Ev(%struct.X1* %this) unnamed_addr
+void test_X1() {
+ X1<char> i1c;
+}
+
diff --git a/clang/test/CodeGenCXX/template-static-var-defer.cpp b/clang/test/CodeGenCXX/template-static-var-defer.cpp
new file mode 100644
index 0000000..fe18c21
--- /dev/null
+++ b/clang/test/CodeGenCXX/template-static-var-defer.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | not grep define
+// PR7415
+class X {
+ template <class Dummy> struct COMTypeInfo {
+ static const int kIID;
+ };
+ static const int& GetIID() {return COMTypeInfo<int>::kIID;}
+};
+template <class Dummy> const int X::COMTypeInfo<Dummy>::kIID = 10;
+
+
+
diff --git a/clang/test/CodeGenCXX/temporaries.cpp b/clang/test/CodeGenCXX/temporaries.cpp
new file mode 100644
index 0000000..e90c947
--- /dev/null
+++ b/clang/test/CodeGenCXX/temporaries.cpp
@@ -0,0 +1,539 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+struct A {
+ A();
+ ~A();
+ void f();
+};
+
+void f1() {
+ // CHECK: call void @_ZN1AC1Ev
+ // CHECK: call void @_ZN1AD1Ev
+ (void)A();
+
+ // CHECK: call void @_ZN1AC1Ev
+ // CHECK: call void @_ZN1AD1Ev
+ A().f();
+}
+
+// Function calls
+struct B {
+ B();
+ ~B();
+};
+
+B g();
+
+void f2() {
+ // CHECK-NOT: call void @_ZN1BC1Ev
+ // CHECK: call void @_ZN1BD1Ev
+ (void)g();
+}
+
+// Member function calls
+struct C {
+ C();
+ ~C();
+
+ C f();
+};
+
+void f3() {
+ // CHECK: call void @_ZN1CC1Ev
+ // CHECK: call void @_ZN1CD1Ev
+ // CHECK: call void @_ZN1CD1Ev
+ C().f();
+}
+
+// Function call operator
+struct D {
+ D();
+ ~D();
+
+ D operator()();
+};
+
+void f4() {
+ // CHECK: call void @_ZN1DC1Ev
+ // CHECK: call void @_ZN1DD1Ev
+ // CHECK: call void @_ZN1DD1Ev
+ D()();
+}
+
+// Overloaded operators
+struct E {
+ E();
+ ~E();
+ E operator+(const E&);
+ E operator!();
+};
+
+void f5() {
+ // CHECK: call void @_ZN1EC1Ev
+ // CHECK: call void @_ZN1EC1Ev
+ // CHECK: call void @_ZN1ED1Ev
+ // CHECK: call void @_ZN1ED1Ev
+ // CHECK: call void @_ZN1ED1Ev
+ E() + E();
+
+ // CHECK: call void @_ZN1EC1Ev
+ // CHECK: call void @_ZN1ED1Ev
+ // CHECK: call void @_ZN1ED1Ev
+ !E();
+}
+
+struct F {
+ F();
+ ~F();
+ F& f();
+};
+
+void f6() {
+ // CHECK: call void @_ZN1FC1Ev
+ // CHECK: call void @_ZN1FD1Ev
+ F().f();
+}
+
+struct G {
+ G();
+ G(A);
+ ~G();
+ operator A();
+};
+
+void a(const A&);
+
+void f7() {
+ // CHECK: call void @_ZN1AC1Ev
+ // CHECK: call void @_Z1aRK1A
+ // CHECK: call void @_ZN1AD1Ev
+ a(A());
+
+ // CHECK: call void @_ZN1GC1Ev
+ // CHECK: call void @_ZN1Gcv1AEv
+ // CHECK: call void @_Z1aRK1A
+ // CHECK: call void @_ZN1AD1Ev
+ // CHECK: call void @_ZN1GD1Ev
+ a(G());
+}
+
+namespace PR5077 {
+
+struct A {
+ A();
+ ~A();
+ int f();
+};
+
+void f();
+int g(const A&);
+
+struct B {
+ int a1;
+ int a2;
+ B();
+ ~B();
+};
+
+B::B()
+ // CHECK: call void @_ZN6PR50771AC1Ev
+ // CHECK: call i32 @_ZN6PR50771A1fEv
+ // CHECK: call void @_ZN6PR50771AD1Ev
+ : a1(A().f())
+ // CHECK: call void @_ZN6PR50771AC1Ev
+ // CHECK: call i32 @_ZN6PR50771gERKNS_1AE
+ // CHECK: call void @_ZN6PR50771AD1Ev
+ , a2(g(A()))
+{
+ // CHECK: call void @_ZN6PR50771fEv
+ f();
+}
+
+struct C {
+ C();
+
+ const B& b;
+};
+
+C::C()
+ // CHECK: call void @_ZN6PR50771BC1Ev
+ : b(B()) {
+ // CHECK: call void @_ZN6PR50771fEv
+ f();
+
+ // CHECK: call void @_ZN6PR50771BD1Ev
+}
+}
+
+A f8() {
+ // CHECK: call void @_ZN1AC1Ev
+ // CHECK-NOT: call void @_ZN1AD1Ev
+ return A();
+ // CHECK: ret void
+}
+
+struct H {
+ H();
+ ~H();
+ H(const H&);
+};
+
+void f9(H h) {
+ // CHECK: call void @_ZN1HC1Ev
+ // CHECK: call void @_Z2f91H
+ // CHECK: call void @_ZN1HD1Ev
+ f9(H());
+
+ // CHECK: call void @_ZN1HC1ERKS_
+ // CHECK: call void @_Z2f91H
+ // CHECK: call void @_ZN1HD1Ev
+ f9(h);
+}
+
+void f10(const H&);
+
+void f11(H h) {
+ // CHECK: call void @_ZN1HC1Ev
+ // CHECK: call void @_Z3f10RK1H
+ // CHECK: call void @_ZN1HD1Ev
+ f10(H());
+
+ // CHECK: call void @_Z3f10RK1H
+ // CHECK-NOT: call void @_ZN1HD1Ev
+ // CHECK: ret void
+ f10(h);
+}
+
+// PR5808
+struct I {
+ I(const char *);
+ ~I();
+};
+
+// CHECK: _Z3f12v
+I f12() {
+ // CHECK: call void @_ZN1IC1EPKc
+ // CHECK-NOT: call void @_ZN1ID1Ev
+ // CHECK: ret void
+ return "Hello";
+}
+
+// PR5867
+namespace PR5867 {
+ struct S {
+ S();
+ S(const S &);
+ ~S();
+ };
+
+ void f(S, int);
+ // CHECK: define void @_ZN6PR58671gEv
+ void g() {
+ // CHECK: call void @_ZN6PR58671SC1Ev
+ // CHECK-NEXT: call void @_ZN6PR58671fENS_1SEi
+ // CHECK-NEXT: call void @_ZN6PR58671SD1Ev
+ // CHECK-NEXT: ret void
+ (f)(S(), 0);
+ }
+
+ // CHECK: define linkonce_odr void @_ZN6PR58672g2IiEEvT_
+ template<typename T>
+ void g2(T) {
+ // CHECK: call void @_ZN6PR58671SC1Ev
+ // CHECK-NEXT: call void @_ZN6PR58671fENS_1SEi
+ // CHECK-NEXT: call void @_ZN6PR58671SD1Ev
+ // CHECK-NEXT: ret void
+ (f)(S(), 0);
+ }
+
+ void h() {
+ g2(17);
+ }
+}
+
+// PR6199
+namespace PR6199 {
+ struct A { ~A(); };
+
+ struct B { operator A(); };
+
+ // CHECK: define weak_odr void @_ZN6PR61992f2IiEENS_1AET_
+ template<typename T> A f2(T) {
+ B b;
+ // CHECK: call void @_ZN6PR61991BcvNS_1AEEv
+ // CHECK-NEXT: ret void
+ return b;
+ }
+
+ template A f2<int>(int);
+
+}
+
+namespace T12 {
+
+struct A {
+ A();
+ ~A();
+ int f();
+};
+
+int& f(int);
+
+// CHECK: define void @_ZN3T121gEv
+void g() {
+ // CHECK: call void @_ZN3T121AC1Ev
+ // CHECK-NEXT: call i32 @_ZN3T121A1fEv(
+ // CHECK-NEXT: call i32* @_ZN3T121fEi(
+ // CHECK-NEXT: call void @_ZN3T121AD1Ev(
+ int& i = f(A().f());
+}
+
+}
+
+namespace PR6648 {
+ struct B {
+ ~B();
+ };
+ B foo;
+ struct D;
+ D& zed(B);
+ void foobar() {
+ // CHECK: call %"struct.PR6648::D"* @_ZN6PR66483zedENS_1BE
+ zed(foo);
+ }
+}
+
+namespace UserConvertToValue {
+ struct X {
+ X(int);
+ X(const X&);
+ ~X();
+ };
+
+ void f(X);
+
+ // CHECK: void @_ZN18UserConvertToValue1gEv()
+ void g() {
+ // CHECK: call void @_ZN18UserConvertToValue1XC1Ei
+ // CHECK: call void @_ZN18UserConvertToValue1fENS_1XE
+ // CHECK: call void @_ZN18UserConvertToValue1XD1Ev
+ // CHECK: ret void
+ f(1);
+ }
+}
+
+namespace PR7556 {
+ struct A { ~A(); };
+ struct B { int i; ~B(); };
+ struct C { int C::*pm; ~C(); };
+ // CHECK: define void @_ZN6PR75563fooEv()
+ void foo() {
+ // CHECK: call void @_ZN6PR75561AD1Ev
+ A();
+ // CHECK: call void @llvm.memset.p0i8.i64
+ // CHECK: call void @_ZN6PR75561BD1Ev
+ B();
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
+ // CHECK: call void @_ZN6PR75561CD1Ev
+ C();
+ // CHECK-NEXT: ret void
+ }
+}
+
+namespace Elision {
+ struct A {
+ A(); A(const A &); ~A();
+ void *p;
+ void foo() const;
+ };
+
+ void foo();
+ A fooA();
+ void takeA(A a);
+
+ // CHECK: define void @_ZN7Elision5test0Ev()
+ void test0() {
+ // CHECK: [[I:%.*]] = alloca [[A:%.*]], align 8
+ // CHECK-NEXT: [[J:%.*]] = alloca [[A]], align 8
+ // CHECK-NEXT: [[T0:%.*]] = alloca [[A]], align 8
+ // CHECK-NEXT: [[K:%.*]] = alloca [[A]], align 8
+ // CHECK-NEXT: [[T1:%.*]] = alloca [[A]], align 8
+
+ // CHECK-NEXT: call void @_ZN7Elision3fooEv()
+ // CHECK-NEXT: call void @_ZN7Elision1AC1Ev([[A]]* [[I]])
+ A i = (foo(), A());
+
+ // CHECK-NEXT: call void @_ZN7Elision4fooAEv([[A]]* sret [[T0]])
+ // CHECK-NEXT: call void @_ZN7Elision1AC1Ev([[A]]* [[J]])
+ // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[T0]])
+ A j = (fooA(), A());
+
+ // CHECK-NEXT: call void @_ZN7Elision1AC1Ev([[A]]* [[T1]])
+ // CHECK-NEXT: call void @_ZN7Elision4fooAEv([[A]]* sret [[K]])
+ // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[T1]])
+ A k = (A(), fooA());
+
+ // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[K]])
+ // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[J]])
+ // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[I]])
+ }
+
+
+ // CHECK: define void @_ZN7Elision5test1EbNS_1AE(
+ void test1(bool c, A x) {
+ // CHECK: [[I:%.*]] = alloca [[A]], align 8
+ // CHECK-NEXT: [[J:%.*]] = alloca [[A]], align 8
+
+ // CHECK: call void @_ZN7Elision1AC1Ev([[A]]* [[I]])
+ // CHECK: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[I]], [[A]]* [[X:%.*]])
+ A i = (c ? A() : x);
+
+ // CHECK: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[J]], [[A]]* [[X]])
+ // CHECK: call void @_ZN7Elision1AC1Ev([[A]]* [[J]])
+ A j = (c ? x : A());
+
+ // CHECK: call void @_ZN7Elision1AD1Ev([[A]]* [[J]])
+ // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[I]])
+ }
+
+ // CHECK: define void @_ZN7Elision5test2Ev([[A]]* noalias sret
+ A test2() {
+ // CHECK: call void @_ZN7Elision3fooEv()
+ // CHECK-NEXT: call void @_ZN7Elision1AC1Ev([[A]]* [[RET:%.*]])
+ // CHECK-NEXT: ret void
+ return (foo(), A());
+ }
+
+ // CHECK: define void @_ZN7Elision5test3EiNS_1AE([[A]]* noalias sret
+ A test3(int v, A x) {
+ if (v < 5)
+ // CHECK: call void @_ZN7Elision1AC1Ev([[A]]* [[RET:%.*]])
+ // CHECK: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[RET]], [[A]]* [[X:%.*]])
+ return (v < 0 ? A() : x);
+ else
+ // CHECK: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[RET]], [[A]]* [[X]])
+ // CHECK: call void @_ZN7Elision1AC1Ev([[A]]* [[RET]])
+ return (v > 10 ? x : A());
+
+ // CHECK: ret void
+ }
+
+ // CHECK: define void @_ZN7Elision5test4Ev()
+ void test4() {
+ // CHECK: [[X:%.*]] = alloca [[A]], align 8
+ // CHECK-NEXT: [[XS:%.*]] = alloca [2 x [[A]]], align 16
+
+ // CHECK-NEXT: call void @_ZN7Elision1AC1Ev([[A]]* [[X]])
+ A x;
+
+ // CHECK-NEXT: [[XS0:%.*]] = getelementptr inbounds [2 x [[A]]]* [[XS]], i64 0, i64 0
+ // CHECK-NEXT: call void @_ZN7Elision1AC1Ev([[A]]* [[XS0]])
+ // CHECK-NEXT: [[XS1:%.*]] = getelementptr inbounds [[A]]* [[XS0]], i64 1
+ // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[XS1]], [[A]]* [[X]])
+ A xs[] = { A(), x };
+
+ // CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [2 x [[A]]]* [[XS]], i32 0, i32 0
+ // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 2
+ // CHECK-NEXT: br label
+ // CHECK: [[AFTER:%.*]] = phi [[A]]*
+ // CHECK-NEXT: [[CUR:%.*]] = getelementptr inbounds [[A]]* [[AFTER]], i64 -1
+ // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[CUR]])
+ // CHECK-NEXT: [[T0:%.*]] = icmp eq [[A]]* [[CUR]], [[BEGIN]]
+ // CHECK-NEXT: br i1 [[T0]],
+
+ // CHECK: call void @_ZN7Elision1AD1Ev([[A]]* [[X]])
+ }
+
+ // rdar://problem/8433352
+ // CHECK: define void @_ZN7Elision5test5Ev([[A]]* noalias sret
+ struct B { A a; B(); };
+ A test5() {
+ // CHECK: [[AT0:%.*]] = alloca [[A]], align 8
+ // CHECK-NEXT: [[BT0:%.*]] = alloca [[B:%.*]], align 8
+ // CHECK-NEXT: [[X:%.*]] = alloca [[A]], align 8
+ // CHECK-NEXT: [[BT1:%.*]] = alloca [[B]], align 8
+ // CHECK-NEXT: [[BT2:%.*]] = alloca [[B]], align 8
+
+ // CHECK: call void @_ZN7Elision1BC1Ev([[B]]* [[BT0]])
+ // CHECK-NEXT: [[AM:%.*]] = getelementptr inbounds [[B]]* [[BT0]], i32 0, i32 0
+ // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[AT0]], [[A]]* [[AM]])
+ // CHECK-NEXT: call void @_ZN7Elision5takeAENS_1AE([[A]]* [[AT0]])
+ // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[AT0]])
+ // CHECK-NEXT: call void @_ZN7Elision1BD1Ev([[B]]* [[BT0]])
+ takeA(B().a);
+
+ // CHECK-NEXT: call void @_ZN7Elision1BC1Ev([[B]]* [[BT1]])
+ // CHECK-NEXT: [[AM:%.*]] = getelementptr inbounds [[B]]* [[BT1]], i32 0, i32 0
+ // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[X]], [[A]]* [[AM]])
+ // CHECK-NEXT: call void @_ZN7Elision1BD1Ev([[B]]* [[BT1]])
+ A x = B().a;
+
+ // CHECK-NEXT: call void @_ZN7Elision1BC1Ev([[B]]* [[BT2]])
+ // CHECK-NEXT: [[AM:%.*]] = getelementptr inbounds [[B]]* [[BT2]], i32 0, i32 0
+ // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[RET:%.*]], [[A]]* [[AM]])
+ // CHECK-NEXT: call void @_ZN7Elision1BD1Ev([[B]]* [[BT2]])
+ return B().a;
+
+ // CHECK: call void @_ZN7Elision1AD1Ev([[A]]* [[X]])
+ }
+
+ // Reduced from webkit.
+ // CHECK: define void @_ZN7Elision5test6EPKNS_1CE([[C:%.*]]*
+ struct C { operator A() const; };
+ void test6(const C *x) {
+ // CHECK: [[T0:%.*]] = alloca [[A]], align 8
+ // CHECK: [[X:%.*]] = load [[C]]** {{%.*}}, align 8
+ // CHECK-NEXT: call void @_ZNK7Elision1CcvNS_1AEEv([[A]]* sret [[T0]], [[C]]* [[X]])
+ // CHECK-NEXT: call void @_ZNK7Elision1A3fooEv([[A]]* [[T0]])
+ // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[T0]])
+ // CHECK-NEXT: ret void
+ A(*x).foo();
+ }
+}
+
+namespace PR8623 {
+ struct A { A(int); ~A(); };
+
+ // CHECK: define void @_ZN6PR86233fooEb(
+ void foo(bool b) {
+ // CHECK: [[TMP:%.*]] = alloca [[A:%.*]], align 1
+ // CHECK-NEXT: [[LCONS:%.*]] = alloca i1
+ // CHECK-NEXT: [[RCONS:%.*]] = alloca i1
+ // CHECK: store i1 false, i1* [[LCONS]]
+ // CHECK-NEXT: store i1 false, i1* [[RCONS]]
+ // CHECK-NEXT: br i1
+ // CHECK: call void @_ZN6PR86231AC1Ei([[A]]* [[TMP]], i32 2)
+ // CHECK-NEXT: store i1 true, i1* [[LCONS]]
+ // CHECK-NEXT: br label
+ // CHECK: call void @_ZN6PR86231AC1Ei([[A]]* [[TMP]], i32 3)
+ // CHECK-NEXT: store i1 true, i1* [[RCONS]]
+ // CHECK-NEXT: br label
+ // CHECK: load i1* [[RCONS]]
+ // CHECK-NEXT: br i1
+ // CHECK: call void @_ZN6PR86231AD1Ev([[A]]* [[TMP]])
+ // CHECK-NEXT: br label
+ // CHECK: load i1* [[LCONS]]
+ // CHECK-NEXT: br i1
+ // CHECK: call void @_ZN6PR86231AD1Ev([[A]]* [[TMP]])
+ // CHECK-NEXT: br label
+ // CHECK: ret void
+ b ? A(2) : A(3);
+ }
+}
+
+namespace PR11365 {
+ struct A { A(); ~A(); };
+
+ // CHECK: define void @_ZN7PR113653fooEv(
+ void foo() {
+ // CHECK: [[BEGIN:%.*]] = getelementptr inbounds [3 x [[A:%.*]]]* {{.*}}, i32 0, i32 0
+ // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 3
+ // CHECK-NEXT: br label
+
+ // CHECK: [[PHI:%.*]] = phi
+ // CHECK-NEXT: [[ELEM:%.*]] = getelementptr inbounds [[A]]* [[PHI]], i64 -1
+ // CHECK-NEXT: call void @_ZN7PR113651AD1Ev([[A]]* [[ELEM]])
+ // CHECK-NEXT: icmp eq [[A]]* [[ELEM]], [[BEGIN]]
+ // CHECK-NEXT: br i1
+ (void) (A [3]) {};
+ }
+}
diff --git a/clang/test/CodeGenCXX/thiscall-struct-return.cpp b/clang/test/CodeGenCXX/thiscall-struct-return.cpp
new file mode 100644
index 0000000..ff53125
--- /dev/null
+++ b/clang/test/CodeGenCXX/thiscall-struct-return.cpp
@@ -0,0 +1,41 @@
+// For MSVC ABI compatibility, all structures returned by value using the
+// thiscall calling convention must use the hidden parameter.
+//
+// RUN: %clang_cc1 -triple i386-PC-Win32 %s -fms-compatibility -O0 -emit-llvm -o - | FileCheck %s
+
+// This structure would normally be returned via EAX
+struct S {
+ int i;
+};
+
+// This structure would normally be returned via EAX/EDX
+struct M {
+ int i;
+ int j;
+};
+
+class C {
+public:
+ C() {}
+
+ struct S __attribute__((thiscall)) Small() const {
+ struct S s = { 0 };
+ return s;
+ }
+
+ struct M __attribute__((thiscall)) Medium() const {
+ struct M m = { 0 };
+ return m;
+ }
+};
+
+// CHECK: define void @_Z4testv()
+void test( void ) {
+// CHECK: call void @_ZN1CC1Ev(%class.C* [[C:%.+]])
+ C c;
+
+// CHECK: call x86_thiscallcc void @_ZNK1C5SmallEv(%struct.S* sret %{{.+}}, %class.C* [[C]])
+ (void)c.Small();
+// CHECK: call x86_thiscallcc void @_ZNK1C6MediumEv(%struct.M* sret %{{.+}}, %class.C* [[C]])
+ (void)c.Medium();
+}
diff --git a/clang/test/CodeGenCXX/threadsafe-statics-exceptions.cpp b/clang/test/CodeGenCXX/threadsafe-statics-exceptions.cpp
new file mode 100644
index 0000000..769d120
--- /dev/null
+++ b/clang/test/CodeGenCXX/threadsafe-statics-exceptions.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -emit-llvm -o - -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 %s | FileCheck %s
+
+struct X {
+ X();
+ ~X();
+};
+
+struct Y { };
+
+// CHECK: define void @_Z1fv
+void f() {
+ // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVZ1fvE1x)
+ // CHECK: invoke void @_ZN1XC1Ev
+ // CHECK: call i32 @__cxa_atexit
+ // CHECK-NEXT: call void @__cxa_guard_release(i64* @_ZGVZ1fvE1x)
+ // CHECK: br
+ static X x;
+
+ // CHECK: call i8* @__cxa_allocate_exception
+ // CHECK: call void @__cxa_throw
+ throw Y();
+
+ // Finally, the landing pad.
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK: cleanup
+ // CHECK: call void @__cxa_guard_abort(i64* @_ZGVZ1fvE1x)
+ // CHECK: resume { i8*, i32 }
+}
diff --git a/clang/test/CodeGenCXX/threadsafe-statics.cpp b/clang/test/CodeGenCXX/threadsafe-statics.cpp
new file mode 100644
index 0000000..8afc274
--- /dev/null
+++ b/clang/test/CodeGenCXX/threadsafe-statics.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -emit-llvm -triple=x86_64-apple-darwin10 -o - %s | FileCheck -check-prefix=WITH-TSS %s
+// RUN: %clang_cc1 -emit-llvm -triple=x86_64-apple-darwin10 -o - %s -fno-threadsafe-statics | FileCheck -check-prefix=NO-TSS %s
+
+int f();
+
+// WITH-TSS: @_ZZ1gvE1a = internal global i32 0, align 4
+// WITH-TSS: @_ZGVZ1gvE1a = internal global i64 0
+
+// WITH-TSS: define void @_Z1gv() nounwind
+// WITH-TSS: call i32 @__cxa_guard_acquire
+// WITH-TSS: call void @__cxa_guard_release
+// WITH-TSS: ret void
+void g() {
+ static int a = f();
+}
+
+// NO-TSS: @_ZZ1gvE1a = internal global i32 0, align 4
+// NO-TSS: @_ZGVZ1gvE1a = internal global i8 0
+
+// NO-TSS: define void @_Z1gv() nounwind
+// NO-TSS-NOT: call i32 @__cxa_guard_acquire
+// NO-TSS-NOT: call void @__cxa_guard_release
+// NO-TSS: ret void
diff --git a/clang/test/CodeGenCXX/throw-expression-dtor.cpp b/clang/test/CodeGenCXX/throw-expression-dtor.cpp
new file mode 100644
index 0000000..0de6683
--- /dev/null
+++ b/clang/test/CodeGenCXX/throw-expression-dtor.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -emit-llvm-only -verify -fcxx-exceptions -fexceptions
+// PR7281
+
+class A {
+public:
+ ~A();
+};
+class B : public A {
+ void ice_throw();
+};
+void B::ice_throw() {
+ throw *this;
+}
diff --git a/clang/test/CodeGenCXX/throw-expressions.cpp b/clang/test/CodeGenCXX/throw-expressions.cpp
new file mode 100644
index 0000000..2515acb
--- /dev/null
+++ b/clang/test/CodeGenCXX/throw-expressions.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -emit-llvm-only -verify %s -Wno-unreachable-code
+
+int val = 42;
+int& test1() {
+ return throw val, val;
+}
+
+int test2() {
+ return val ? throw val : val;
+}
+
+// rdar://problem/8608801
+void test3() {
+ throw false;
+}
+
+// PR10582
+int test4() {
+ return 1 ? throw val : val;
+}
diff --git a/clang/test/CodeGenCXX/thunk-linkonce-odr.cpp b/clang/test/CodeGenCXX/thunk-linkonce-odr.cpp
new file mode 100644
index 0000000..4f4d61d
--- /dev/null
+++ b/clang/test/CodeGenCXX/thunk-linkonce-odr.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// <rdar://problem/7929157> & <rdar://problem/8104369>
+
+struct A {
+ virtual int f() { return 1; }
+};
+
+struct B {
+ virtual int f() { return 2; }
+};
+
+struct C : A, B {
+ virtual int f() { return 3; }
+};
+
+struct D : C {
+ virtual int f() { return 4; }
+};
+
+static int f(D* d) {
+ B* b = d;
+ return b->f();
+};
+
+int g() {
+ D d;
+ return f(&d);
+}
+
+// Thunks should be marked as "linkonce ODR" not "weak".
+//
+// CHECK: define linkonce_odr i32 @_ZThn{{[48]}}_N1D1fEv
+// CHECK: define linkonce_odr i32 @_ZThn{{[48]}}_N1C1fEv
diff --git a/clang/test/CodeGenCXX/thunk-use-after-free.cpp b/clang/test/CodeGenCXX/thunk-use-after-free.cpp
new file mode 100644
index 0000000..d70e902
--- /dev/null
+++ b/clang/test/CodeGenCXX/thunk-use-after-free.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -emit-llvm-only -O1 %s
+// This used to crash under asan and valgrind.
+// PR12284
+
+template < typename _Tp > struct new_allocator
+{
+ typedef _Tp *pointer;
+ template < typename > struct rebind {
+ typedef new_allocator other;
+ };
+};
+template < typename _Tp > struct allocator:new_allocator < _Tp > {
+};
+template < typename _Tp, typename _Alloc > struct _Vector_base {
+ typedef typename _Alloc::template rebind < _Tp >::other _Tp_alloc_type;
+ struct _Vector_impl {
+ typename _Tp_alloc_type::pointer _M_end_of_storage;
+ };
+ _Vector_base () {
+ foo((int *) this->_M_impl._M_end_of_storage);
+ }
+ void foo(int *);
+ _Vector_impl _M_impl;
+};
+template < typename _Tp, typename _Alloc =
+allocator < _Tp > >struct vector:_Vector_base < _Tp, _Alloc > { };
+
+
+template < class T> struct HHH {};
+struct DDD { int x_;};
+struct Data;
+struct X1;
+struct CCC:DDD { virtual void xxx (HHH < X1 >); };
+template < class SSS > struct EEE:vector < HHH < SSS > > { };
+template < class SSS, class = EEE < SSS > >class FFF { };
+template < class SSS, class GGG = EEE < SSS > >class AAA:FFF <GGG> { };
+class BBB:virtual CCC {
+ void xxx (HHH < X1 >);
+ vector < HHH < X1 > >aaa;
+};
+class ZZZ:AAA < Data >, BBB { virtual ZZZ *ppp () ; };
+ZZZ * ZZZ::ppp () { return new ZZZ; }
diff --git a/clang/test/CodeGenCXX/thunks-available-externally.cpp b/clang/test/CodeGenCXX/thunks-available-externally.cpp
new file mode 100644
index 0000000..dfdb786
--- /dev/null
+++ b/clang/test/CodeGenCXX/thunks-available-externally.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o - | FileCheck %s
+
+// Check that we don't assert on this case.
+namespace Test1 {
+
+struct Incomplete;
+
+struct A {
+ virtual void f();
+ virtual void g(Incomplete);
+ virtual void h();
+ virtual void i();
+ int a;
+};
+
+struct B {
+ virtual void f();
+ virtual void g(Incomplete);
+ virtual void h();
+ virtual void i();
+ int b;
+};
+
+struct C : A, B {
+ C();
+
+ virtual void f();
+ virtual void g(Incomplete);
+ virtual void h();
+ virtual void i();
+};
+
+void C::h() { }
+
+C::C() { }
+
+void C::i() { }
+
+}
+
+namespace Test2 {
+
+struct A {
+ virtual void f();
+ int a;
+};
+
+struct B {
+ virtual void f();
+ int b;
+};
+
+struct C : A, B {
+ virtual void f();
+};
+
+static void f(B* b) {
+ b->f();
+}
+
+// CHECK: define void @_ZN5Test21fEv()
+// CHECK: call void @_ZN5Test21C1fEv
+// CHECK: ret void
+// CHECK: define available_externally void @_ZThn16_N5Test21C1fEv
+void f() {
+ C c;
+ f(&c);
+}
+
+}
+
+// Test that we don't assert.
+namespace Test3 {
+
+struct A {
+ virtual ~A();
+
+ int a;
+};
+
+struct B : A { };
+struct C : virtual B { };
+
+void f() {
+ C c;
+}
+
+}
diff --git a/clang/test/CodeGenCXX/thunks.cpp b/clang/test/CodeGenCXX/thunks.cpp
new file mode 100644
index 0000000..04d0820
--- /dev/null
+++ b/clang/test/CodeGenCXX/thunks.cpp
@@ -0,0 +1,308 @@
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -fhidden-weak-vtables -emit-llvm -o - | FileCheck -check-prefix=HIDDEN %s
+
+namespace Test1 {
+
+// Check that we emit a non-virtual thunk for C::f.
+
+struct A {
+ virtual void f();
+};
+
+struct B {
+ virtual void f();
+};
+
+struct C : A, B {
+ virtual void c();
+
+ virtual void f();
+};
+
+// CHECK: define void @_ZThn8_N5Test11C1fEv(
+void C::f() { }
+
+}
+
+namespace Test2 {
+
+// Check that we emit a thunk for B::f since it's overriding a virtual base.
+
+struct A {
+ virtual void f();
+};
+
+struct B : virtual A {
+ virtual void b();
+ virtual void f();
+};
+
+// CHECK: define void @_ZTv0_n24_N5Test21B1fEv(
+void B::f() { }
+
+}
+
+namespace Test3 {
+
+// Check that we emit a covariant thunk for B::f.
+
+struct V1 { };
+struct V2 : virtual V1 { };
+
+struct A {
+ virtual V1 *f();
+};
+
+struct B : A {
+ virtual void b();
+
+ virtual V2 *f();
+};
+
+// CHECK: define %{{.*}}* @_ZTch0_v0_n24_N5Test31B1fEv(
+V2 *B::f() { return 0; }
+
+}
+
+namespace Test4 {
+
+// Check that the thunk for 'C::f' has the same visibility as the function itself.
+
+struct A {
+ virtual void f();
+};
+
+struct B {
+ virtual void f();
+};
+
+struct __attribute__((visibility("protected"))) C : A, B {
+ virtual void c();
+
+ virtual void f();
+};
+
+// CHECK: define protected void @_ZThn8_N5Test41C1fEv(
+void C::f() { }
+
+}
+
+// Check that the thunk gets internal linkage.
+namespace Test4B {
+ struct A {
+ virtual void f();
+ };
+
+ struct B {
+ virtual void f();
+ };
+
+ namespace {
+ struct C : A, B {
+ virtual void c();
+ virtual void f();
+ };
+ }
+ void C::c() {}
+ void C::f() {}
+
+ // Force C::f to be used.
+ void f() {
+ C c;
+ c.f();
+ }
+}
+
+namespace Test5 {
+
+// Check that the thunk for 'B::f' gets the same linkage as the function itself.
+struct A {
+ virtual void f();
+};
+
+struct B : virtual A {
+ virtual void f() { }
+};
+
+void f(B b) {
+ b.f();
+}
+}
+
+namespace Test6 {
+ struct X {
+ X();
+ X(const X&);
+ X &operator=(const X&);
+ ~X();
+ };
+
+ struct P {
+ P();
+ P(const P&);
+ ~P();
+ X first;
+ X second;
+ };
+
+ P getP();
+
+ struct Base1 {
+ int i;
+
+ virtual X f() { return X(); }
+ };
+
+ struct Base2 {
+ float real;
+
+ virtual X f() { return X(); }
+ };
+
+ struct Thunks : Base1, Base2 {
+ long l;
+
+ virtual X f();
+ };
+
+ // CHECK: define void @_ZThn16_N5Test66Thunks1fEv
+ // CHECK-NOT: memcpy
+ // CHECK: {{call void @_ZN5Test66Thunks1fEv.*sret}}
+ // CHECK: ret void
+ X Thunks::f() { return X(); }
+}
+
+namespace Test7 {
+ // PR7188
+ struct X {
+ X();
+ X(const X&);
+ X &operator=(const X&);
+ ~X();
+ };
+
+ struct Small { short s; };
+ struct Large {
+ char array[1024];
+ };
+
+ class A {
+ protected:
+ virtual void foo() = 0;
+ };
+
+ class B : public A {
+ protected:
+ virtual void bar() = 0;
+ };
+
+ class C : public A {
+ protected:
+ virtual void baz(X, X&, _Complex float, Small, Small&, Large) = 0;
+ };
+
+ class D : public B,
+ public C {
+
+ void foo() {}
+ void bar() {}
+ void baz(X, X&, _Complex float, Small, Small&, Large);
+ };
+
+ void D::baz(X, X&, _Complex float, Small, Small&, Large) { }
+
+ // CHECK: define void @_ZThn8_N5Test71D3bazENS_1XERS1_CfNS_5SmallERS4_NS_5LargeE(
+ // CHECK-NOT: memcpy
+ // CHECK: ret void
+ void testD() { D d; }
+}
+
+namespace Test8 {
+ struct NonPOD { ~NonPOD(); int x, y, z; };
+ struct A { virtual void foo(); };
+ struct B { virtual void bar(NonPOD); };
+ struct C : A, B { virtual void bar(NonPOD); static void helper(NonPOD); };
+
+ // CHECK: define void @_ZN5Test81C6helperENS_6NonPODE([[NONPODTYPE:%.*]]*
+ void C::helper(NonPOD var) {}
+
+ // CHECK: define void @_ZThn8_N5Test81C3barENS_6NonPODE(
+ // CHECK-NOT: load [[NONPODTYPE]]*
+ // CHECK-NOT: memcpy
+ // CHECK: ret void
+ void C::bar(NonPOD var) {}
+}
+
+// PR7241: Emitting thunks for a method shouldn't require the vtable for
+// that class to be emitted.
+namespace Test9 {
+ struct A { virtual ~A() { } };
+ struct B : A { virtual void test() const {} };
+ struct C : B { C(); ~C(); };
+ struct D : C { D() {} };
+ void test() {
+ D d;
+ }
+}
+
+namespace Test10 {
+ struct A { virtual void foo(); };
+ struct B { virtual void foo(); };
+ struct C : A, B { void foo() {} };
+
+ // CHECK-HIDDEN: define linkonce_odr void @_ZN6Test101C3fooEv
+ // CHECK-HIDDEN: define linkonce_odr hidden void @_ZThn8_N6Test101C3fooEv
+
+ void test() {
+ C c;
+ }
+}
+
+// PR7611
+namespace Test11 {
+ struct A { virtual A* f(); };
+ struct B : virtual A { virtual A* f(); };
+ struct C : B { virtual C* f(); };
+ C* C::f() { return 0; }
+
+ // C::f itself.
+ // CHECK: define {{.*}} @_ZN6Test111C1fEv(
+
+ // The this-adjustment and return-adjustment thunk required when
+ // C::f appears in a vtable where A is at a nonzero offset from C.
+ // CHECK: define {{.*}} @_ZTcv0_n24_v0_n32_N6Test111C1fEv(
+
+ // The return-adjustment thunk required when C::f appears in a vtable
+ // where A is at a zero offset from C.
+ // CHECK: define {{.*}} @_ZTch0_v0_n32_N6Test111C1fEv(
+}
+
+// Varargs thunk test.
+namespace Test12 {
+ struct A {
+ virtual A* f(int x, ...);
+ };
+ struct B {
+ virtual B* f(int x, ...);
+ };
+ struct C : A, B {
+ virtual void c();
+ virtual C* f(int x, ...);
+ };
+ C* C::f(int x, ...) { return this; }
+
+ // C::f
+ // CHECK: define {{.*}} @_ZN6Test121C1fEiz
+
+ // Varargs thunk; check that both the this and covariant adjustments
+ // are generated.
+ // CHECK: define {{.*}} @_ZTchn8_h8_N6Test121C1fEiz
+ // CHECK: getelementptr inbounds i8* {{.*}}, i64 -8
+ // CHECK: getelementptr inbounds i8* {{.*}}, i64 8
+}
+
+/**** The following has to go at the end of the file ****/
+
+// This is from Test5:
+// CHECK: define linkonce_odr void @_ZTv0_n24_N5Test51B1fEv
+// CHECK: define internal void @_ZThn8_N6Test4B12_GLOBAL__N_11C1fEv(
diff --git a/clang/test/CodeGenCXX/trivial-constructor-init.cpp b/clang/test/CodeGenCXX/trivial-constructor-init.cpp
new file mode 100644
index 0000000..343dc65
--- /dev/null
+++ b/clang/test/CodeGenCXX/trivial-constructor-init.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -S %s -o %t-64.s
+// RUN: %clang_cc1 -S %s -o %t-32.s
+
+extern "C" int printf(...);
+
+struct S {
+ S() { printf("S::S\n"); }
+};
+
+struct A {
+ double x;
+ A() : x(), y(), s() { printf("x = %f y = %x \n", x, y); }
+ int *y;
+ S s;
+};
+
+A a;
+
+int main() {
+}
diff --git a/clang/test/CodeGenCXX/try-catch.cpp b/clang/test/CodeGenCXX/try-catch.cpp
new file mode 100644
index 0000000..89f229f
--- /dev/null
+++ b/clang/test/CodeGenCXX/try-catch.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s
+
+struct X { };
+
+const X g();
+
+void f() {
+ try {
+ throw g();
+ // CHECK: @_ZTI1X to i8
+ } catch (const X x) {
+ }
+}
diff --git a/clang/test/CodeGenCXX/typeid-cxx11.cpp b/clang/test/CodeGenCXX/typeid-cxx11.cpp
new file mode 100644
index 0000000..940274e
--- /dev/null
+++ b/clang/test/CodeGenCXX/typeid-cxx11.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm -std=c++11 -o - | FileCheck %s
+#include <typeinfo>
+
+namespace Test1 {
+
+struct Item {
+ const std::type_info &ti;
+ const char *name;
+ void *(*make)();
+};
+
+template<typename T> void *make_impl() { return new T; }
+template<typename T> constexpr Item item(const char *name) {
+ return { typeid(T), name, make_impl<T> };
+}
+
+struct A { virtual ~A(); };
+struct B : virtual A {};
+struct C { int n; };
+
+// FIXME: check we produce a constant array for this, once we support IRGen of
+// folded structs and arrays.
+constexpr Item items[] = {
+ item<A>("A"), item<B>("B"), item<C>("C"), item<int>("int")
+};
+
+// CHECK: @_ZN5Test11xE = constant %"class.std::type_info"* bitcast (i8** @_ZTIN5Test11AE to %"class.std::type_info"*), align 8
+constexpr auto &x = items[0].ti;
+
+}
diff --git a/clang/test/CodeGenCXX/typeid.cpp b/clang/test/CodeGenCXX/typeid.cpp
new file mode 100644
index 0000000..fce3795
--- /dev/null
+++ b/clang/test/CodeGenCXX/typeid.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm -fcxx-exceptions -fexceptions -o - | FileCheck %s
+#include <typeinfo>
+
+namespace Test1 {
+
+// PR7400
+struct A { virtual void f(); };
+
+// CHECK: @_ZN5Test16int_tiE = constant %"class.std::type_info"* bitcast (i8** @_ZTIi to %"class.std::type_info"*), align 8
+const std::type_info &int_ti = typeid(int);
+
+// CHECK: @_ZN5Test14A_tiE = constant %"class.std::type_info"* bitcast (i8** @_ZTIN5Test11AE to %"class.std::type_info"*), align 8
+const std::type_info &A_ti = typeid(const volatile A &);
+
+volatile char c;
+
+// CHECK: @_ZN5Test14c_tiE = constant %"class.std::type_info"* bitcast (i8** @_ZTIc to %"class.std::type_info"*), align 8
+const std::type_info &c_ti = typeid(c);
+
+extern const double &d;
+
+// CHECK: @_ZN5Test14d_tiE = constant %"class.std::type_info"* bitcast (i8** @_ZTId to %"class.std::type_info"*), align 8
+const std::type_info &d_ti = typeid(d);
+
+extern A &a;
+
+// CHECK: @_ZN5Test14a_tiE = global
+const std::type_info &a_ti = typeid(a);
+
+// CHECK: define i8* @_ZN5Test11fEv
+const char *f() {
+ try {
+ // CHECK: br i1
+ // CHECK: invoke void @__cxa_bad_typeid() noreturn
+ return typeid(*static_cast<A *>(0)).name();
+ } catch (...) {
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-NEXT: catch i8* null
+ }
+
+ return 0;
+}
+
+}
diff --git a/clang/test/CodeGenCXX/typeinfo b/clang/test/CodeGenCXX/typeinfo
new file mode 100644
index 0000000..7af23cf
--- /dev/null
+++ b/clang/test/CodeGenCXX/typeinfo
@@ -0,0 +1,16 @@
+namespace std {
+ class type_info {
+ public:
+ virtual ~type_info();
+ const char* name() const { return __name; }
+ bool operator==(const type_info& __arg) const {
+ return __name == __arg.__name;
+ }
+
+ bool operator!=(const type_info& __arg) const {
+ return !operator==(__arg);
+ }
+ protected:
+ const char *__name;
+ };
+}
diff --git a/clang/test/CodeGenCXX/unary-type-trait.cpp b/clang/test/CodeGenCXX/unary-type-trait.cpp
new file mode 100644
index 0000000..a11c67e
--- /dev/null
+++ b/clang/test/CodeGenCXX/unary-type-trait.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-llvm-only -verify %s
+
+bool a() { return __is_pod(int); }
diff --git a/clang/test/CodeGenCXX/uncode-string.cpp b/clang/test/CodeGenCXX/uncode-string.cpp
new file mode 100644
index 0000000..1d83999
--- /dev/null
+++ b/clang/test/CodeGenCXX/uncode-string.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// rdar://8360841
+
+wchar_t s[] = L"\u2722";
+
+// CHECK: @s = global [2 x i32] [i32 10018, i32 0], align 4
diff --git a/clang/test/CodeGenCXX/union-dtor.cpp b/clang/test/CodeGenCXX/union-dtor.cpp
new file mode 100644
index 0000000..a0b822a
--- /dev/null
+++ b/clang/test/CodeGenCXX/union-dtor.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -std=c++11 %s -S -o - -emit-llvm | FileCheck %s
+
+// PR10304: destructors should not call destructors for variant members.
+
+template<bool b = false>
+struct Foo {
+ Foo() { static_assert(b, "Foo::Foo used"); }
+ ~Foo() { static_assert(b, "Foo::~Foo used"); }
+};
+
+struct Bar {
+ Bar();
+ ~Bar();
+};
+
+union FooBar {
+ FooBar() {}
+ ~FooBar() {}
+ Foo<> foo;
+ Bar bar;
+};
+
+struct Variant {
+ Variant() {}
+ ~Variant() {}
+ union {
+ Foo<> foo;
+ Bar bar;
+ };
+};
+
+FooBar foobar;
+Variant variant;
+
+// The ctor and dtor of Foo<> and Bar should not be mentioned in the resulting
+// code.
+//
+// CHECK-NOT: 3FooILb1EEC1
+// CHECK-NOT: 3BarC1
+//
+// CHECK-NOT: 3FooILb1EED1
+// CHECK-NOT: 3BarD1
diff --git a/clang/test/CodeGenCXX/unknown-anytype.cpp b/clang/test/CodeGenCXX/unknown-anytype.cpp
new file mode 100644
index 0000000..902cc8d
--- /dev/null
+++ b/clang/test/CodeGenCXX/unknown-anytype.cpp
@@ -0,0 +1,99 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -funknown-anytype -emit-llvm -o - %s | FileCheck %s
+
+int test0() {
+ extern __unknown_anytype test0_any;
+ // CHECK: load i32* @test0_any
+ return (int) test0_any;
+}
+
+int test1() {
+ extern __unknown_anytype test1_any();
+ // CHECK: call i32 @_Z9test1_anyv()
+ return (int) test1_any();
+}
+
+extern "C" __unknown_anytype test2_any(...);
+float test2() {
+ // CHECK: call float (...)* @test2_any(double {{[^,]+}})
+ return (float) test2_any(0.5f);
+}
+
+extern "C" __unknown_anytype test2a_any(...);
+float test2a() {
+ // CHECK: call float (...)* @test2a_any(float {{[^,]+}})
+ return (float) test2a_any((float) 0.5f);
+}
+
+float test3() {
+ extern __unknown_anytype test3_any;
+ // CHECK: [[FN:%.*]] = load float (i32)** @test3_any,
+ // CHECK: call float [[FN]](i32 5)
+ return ((float(*)(int)) test3_any)(5);
+}
+
+namespace test4 {
+ extern __unknown_anytype test4_any1;
+ extern __unknown_anytype test4_any2;
+
+ int test() {
+ // CHECK: load i32* @_ZN5test410test4_any1E
+ // CHECK: load i8* @_ZN5test410test4_any2E
+ return (int) test4_any1 + (char) test4_any2;
+ }
+}
+
+extern "C" __unknown_anytype test5_any();
+void test5() {
+ // CHECK: call void @test5_any()
+ return (void) test5_any();
+}
+
+extern "C" __unknown_anytype test6_any(float *);
+long test6() {
+ // CHECK: call i64 @test6_any(float* null)
+ return (long) test6_any(0);
+}
+
+struct Test7 {
+ ~Test7();
+};
+extern "C" __unknown_anytype test7_any(int);
+Test7 test7() {
+ // CHECK: call void @test7_any({{%.*}}* sret {{%.*}}, i32 5)
+ return (Test7) test7_any(5);
+}
+
+struct Test8 {
+ __unknown_anytype foo();
+ __unknown_anytype foo(int);
+
+ void test();
+};
+void Test8::test() {
+ float f;
+ // CHECK: call i32 @_ZN5Test83fooEv(
+ f = (int) foo();
+ // CHECK: call i32 @_ZN5Test83fooEi(
+ f = (int) foo(5);
+ // CHECK: call i32 @_ZN5Test83fooEv(
+ f = (float) this->foo();
+ // CHECK: call i32 @_ZN5Test83fooEi(
+ f = (float) this->foo(5);
+}
+void test8(Test8 *p) {
+ double d;
+ // CHECK: call i32 @_ZN5Test83fooEv(
+ d = (double) p->foo();
+ // CHECK: call i32 @_ZN5Test83fooEi(
+ d = (double) p->foo(5);
+ // CHECK: call i32 @_ZN5Test83fooEv(
+ d = (bool) (*p).foo();
+ // CHECK: call i32 @_ZN5Test83fooEi(
+ d = (bool) (*p).foo(5);
+}
+
+extern "C" __unknown_anytype test9_foo;
+void *test9() {
+ // CHECK: ret i8* bitcast (i32* @test9_foo to i8*)
+ return (int*) &test9_foo;
+}
diff --git a/clang/test/CodeGenCXX/value-init.cpp b/clang/test/CodeGenCXX/value-init.cpp
new file mode 100644
index 0000000..6e60f80
--- /dev/null
+++ b/clang/test/CodeGenCXX/value-init.cpp
@@ -0,0 +1,262 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+struct A {
+ virtual ~A();
+};
+
+struct B : A { };
+
+struct C {
+ int i;
+ B b;
+};
+
+// CHECK: _Z15test_value_initv
+void test_value_init() {
+ // This value initialization requires zero initialization of the 'B'
+ // subobject followed by a call to its constructor.
+ // PR5800
+
+ // CHECK: store i32 17
+ // CHECK: call void @llvm.memset.p0i8.i64
+ // CHECK: call void @_ZN1BC1Ev
+ C c = { 17 } ;
+ // CHECK: call void @_ZN1CD1Ev
+}
+
+enum enum_type { negative_number = -1, magic_number = 42 };
+
+class enum_holder
+{
+ enum_type m_enum;
+
+public:
+ enum_holder() : m_enum(magic_number) { }
+};
+
+struct enum_holder_and_int
+{
+ enum_holder e;
+ int i;
+};
+
+// CHECK: _Z24test_enum_holder_and_intv()
+void test_enum_holder_and_int() {
+ // CHECK: alloca
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: call void @llvm.memset
+ // CHECK-NEXT: call void @_ZN19enum_holder_and_intC1Ev
+ enum_holder_and_int();
+ // CHECK-NEXT: ret void
+}
+
+// PR7834: don't crash.
+namespace test1 {
+ struct A {
+ int A::*f;
+ A();
+ A(const A&);
+ A &operator=(const A &);
+ };
+
+ struct B {
+ A base;
+ };
+
+ void foo() {
+ B();
+ }
+}
+
+namespace ptrmem {
+ struct S {
+ int mem1;
+ int S::*mem2;
+ };
+
+ // CHECK: define i32 @_ZN6ptrmem4testEPNS_1SE
+ int test(S *s) {
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
+ // CHECK: getelementptr
+ // CHECK: ret
+ return s->*S().mem2;
+ }
+}
+
+namespace PR9801 {
+
+struct Test {
+ Test() : i(10) {}
+ Test(int i) : i(i) {}
+ int i;
+private:
+ int j;
+};
+
+struct Test2 {
+ Test t;
+};
+
+struct Test3 : public Test { };
+
+// CHECK: define void @_ZN6PR98011fEv
+void f() {
+ // CHECK-NOT: call void @llvm.memset.p0i8.i64
+ // CHECK: call void @_ZN6PR98014TestC1Ei
+ // CHECK-NOT: call void @llvm.memset.p0i8.i64
+ // CHECK: call void @_ZN6PR98014TestC1Ev
+ Test partial[3] = { 1 };
+
+ // CHECK-NOT: call void @llvm.memset.p0i8.i64
+ // CHECK: call void @_ZN6PR98014TestC1Ev
+ // CHECK-NOT: call void @_ZN6PR98014TestC1Ev
+ Test empty[3] = {};
+
+ // CHECK: call void @llvm.memset.p0i8.i64
+ // CHECK-NOT: call void @llvm.memset.p0i8.i64
+ // CHECK: call void @_ZN6PR98015Test2C1Ev
+ // CHECK-NOT: call void @_ZN6PR98015Test2C1Ev
+ Test2 empty2[3] = {};
+
+ // CHECK: call void @llvm.memset.p0i8.i64
+ // CHECK-NOT: call void @llvm.memset.p0i8.i64
+ // CHECK: call void @_ZN6PR98015Test3C1Ev
+ // CHECK-NOT: call void @llvm.memset.p0i8.i64
+ // CHECK-NOT: call void @_ZN6PR98015Test3C1Ev
+ Test3 empty3[3] = {};
+}
+
+}
+
+namespace zeroinit {
+ struct S { int i; };
+
+ // CHECK: define i32 @_ZN8zeroinit4testEv()
+ int test() {
+ // CHECK: call void @llvm.memset.p0i8.i64
+ // CHECK: ret i32 0
+ return S().i;
+ }
+
+ struct X0 {
+ X0() { }
+ int x;
+ };
+
+ struct X1 : X0 {
+ int x1;
+ void f();
+ };
+
+ // CHECK: define void @_ZN8zeroinit9testX0_X1Ev
+ void testX0_X1() {
+ // CHECK: call void @llvm.memset.p0i8.i64
+ // CHECK-NEXT: call void @_ZN8zeroinit2X1C1Ev
+ // CHECK-NEXT: call void @_ZN8zeroinit2X11fEv
+ X1().f();
+ }
+
+ template<typename>
+ struct X2 : X0 {
+ int x2;
+ void f();
+ };
+
+ template<typename>
+ struct X3 : X2<int> {
+ X3() : X2<int>() { }
+ int i;
+ };
+
+
+ // CHECK: define void @_ZN8zeroinit9testX0_X3Ev
+ void testX0_X3() {
+ // CHECK-NOT: call void @llvm.memset
+ // CHECK: call void @_ZN8zeroinit2X3IiEC1Ev
+ // CHECK: call void @_ZN8zeroinit2X2IiE1fEv
+ // CHECK-NEXT: ret void
+ X3<int>().f();
+ }
+
+ // More checks at EOF
+}
+
+namespace PR8726 {
+class C;
+struct S {
+ const C &c1;
+ int i;
+ const C &c2;
+};
+void f(const C& c) {
+ S s = {c, 42, c};
+}
+
+}
+
+// rdar://problem/9355931
+namespace test6 {
+ struct A { A(); A(int); };
+
+ void test() {
+ A arr[10][20] = { 5 };
+ };
+ // CHECK: define void @_ZN5test64testEv()
+ // CHECK: [[ARR:%.*]] = alloca [10 x [20 x [[A:%.*]]]],
+
+ // CHECK-NEXT: [[INNER:%.*]] = getelementptr inbounds [10 x [20 x [[A]]]]* [[ARR]], i64 0, i64 0
+ // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [20 x [[A]]]* [[INNER]], i64 0, i64 0
+ // CHECK-NEXT: call void @_ZN5test61AC1Ei([[A]]* [[T0]], i32 5)
+ // CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [[A]]* [[T0]], i64 1
+ // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]]* [[T0]], i64 20
+ // CHECK-NEXT: br label
+ // CHECK: [[CUR:%.*]] = phi [[A]]* [ [[BEGIN]], {{%.*}} ], [ [[NEXT:%.*]], {{%.*}} ]
+ // CHECK-NEXT: call void @_ZN5test61AC1Ev([[A]]* [[CUR]])
+ // CHECK-NEXT: [[NEXT]] = getelementptr inbounds [[A]]* [[CUR]], i64 1
+ // CHECK-NEXT: [[T0:%.*]] = icmp eq [[A]]* [[NEXT]], [[END]]
+ // CHECK-NEXT: br i1
+
+ // CHECK: [[BEGIN:%.*]] = getelementptr inbounds [20 x [[A]]]* [[INNER]], i64 1
+ // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [20 x [[A]]]* [[INNER]], i64 10
+ // CHECK-NEXT: br label
+ // CHECK: [[CUR:%.*]] = phi [20 x [[A]]]* [ [[BEGIN]], {{%.*}} ], [ [[NEXT:%.*]], {{%.*}} ]
+
+ // Inner loop.
+ // CHECK-NEXT: [[IBEGIN:%.*]] = getelementptr inbounds [20 x [[A]]]* [[CUR]], i32 0, i32 0
+ // CHECK-NEXT: [[IEND:%.*]] = getelementptr inbounds [[A]]* [[IBEGIN]], i64 20
+ // CHECK-NEXT: br label
+ // CHECK: [[ICUR:%.*]] = phi [[A]]* [ [[IBEGIN]], {{%.*}} ], [ [[INEXT:%.*]], {{%.*}} ]
+ // CHECK-NEXT: call void @_ZN5test61AC1Ev([[A]]* [[ICUR]])
+ // CHECK-NEXT: [[INEXT:%.*]] = getelementptr inbounds [[A]]* [[ICUR]], i64 1
+ // CHECK-NEXT: [[T0:%.*]] = icmp eq [[A]]* [[INEXT]], [[IEND]]
+ // CHECK-NEXT: br i1 [[T0]],
+
+ // CHECK: [[NEXT]] = getelementptr inbounds [20 x [[A]]]* [[CUR]], i64 1
+ // CHECK-NEXT: [[T0:%.*]] = icmp eq [20 x [[A]]]* [[NEXT]], [[END]]
+ // CHECK-NEXT: br i1 [[T0]]
+ // CHECK: ret void
+}
+
+namespace PR11124 {
+ // Make sure C::C doesn't overwrite parts of A while it is zero-initializing B
+ struct A { int a; A(); A(int); };
+ struct B : virtual A { int b; };
+ struct C : B { C(); };
+ C::C() : A(3), B() {}
+ // CHECK: define void @_ZN7PR111241CC1Ev
+ // CHECK: call void @llvm.memset.p0i8.i64(i8* {{.*}}, i8 0, i64 12, i32 8, i1 false)
+ // CHECK-NEXT: call void @_ZN7PR111241BC2Ev
+ // Make sure C::C doesn't overwrite parts of A while it is zero-initializing B
+
+ struct B2 : virtual A { int B::*b; };
+ struct C2 : B2 { C2(); };
+ C2::C2() : A(3), B2() {}
+ // CHECK: define void @_ZN7PR111242C2C1Ev
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %{{.*}}, i8* {{.*}}, i64 16, i32 8, i1 false)
+ // CHECK-NEXT: call void @_ZN7PR111242B2C2Ev
+}
+
+// CHECK: define linkonce_odr void @_ZN8zeroinit2X3IiEC2Ev(%"struct.zeroinit::X3"* %this) unnamed_addr
+// CHECK: call void @llvm.memset.p0i8.i64
+// CHECK-NEXT: call void @_ZN8zeroinit2X2IiEC2Ev
+// CHECK-NEXT: ret void
diff --git a/clang/test/CodeGenCXX/vararg-conversion-ctor.cpp b/clang/test/CodeGenCXX/vararg-conversion-ctor.cpp
new file mode 100644
index 0000000..a49b1db
--- /dev/null
+++ b/clang/test/CodeGenCXX/vararg-conversion-ctor.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o %t-64.ll
+// RUN: FileCheck -check-prefix LPLL64 --input-file=%t-64.ll %s
+
+extern "C" int printf(...);
+
+struct A {
+ A(...) {
+ printf("A::A(...)\n");
+ }
+};
+
+A a(1.34);
+
+A b = 2.34;
+
+int main()
+{
+ A c[3];
+}
+
+// CHECK-LPLL64: call void (%struct.A*, ...)
+// CHECK-LPLL64: call void (%struct.A*, ...)
+// CHECK-LPLL64: call void (%struct.A*, ...)
diff --git a/clang/test/CodeGenCXX/vararg-non-pod.cpp b/clang/test/CodeGenCXX/vararg-non-pod.cpp
new file mode 100644
index 0000000..6c6f459
--- /dev/null
+++ b/clang/test/CodeGenCXX/vararg-non-pod.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -Wno-error=non-pod-varargs -emit-llvm -o - %s | FileCheck %s
+
+struct X {
+ X();
+ X(const X&);
+ ~X();
+};
+
+void vararg(...);
+
+// CHECK: define void @_Z4test1X
+void test(X x) {
+ // CHECK: call void @llvm.trap()
+ vararg(x);
+ // CHECK: ret void
+}
diff --git a/clang/test/CodeGenCXX/varargs.cpp b/clang/test/CodeGenCXX/varargs.cpp
new file mode 100644
index 0000000..af34336
--- /dev/null
+++ b/clang/test/CodeGenCXX/varargs.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s
+
+// rdar://7309675
+// PR4678
+namespace test0 {
+ // test1 should be compmiled to be a varargs function in the IR even
+ // though there is no way to do a va_begin. Otherwise, the optimizer
+ // will warn about 'dropped arguments' at the call site.
+
+ // CHECK: define i32 @_ZN5test05test1Ez(...)
+ int test1(...) {
+ return -1;
+ }
+
+ // CHECK: call i32 (...)* @_ZN5test05test1Ez(i32 0)
+ void test() {
+ test1(0);
+ }
+}
+
+namespace test1 {
+ struct A {
+ int x;
+ int y;
+ };
+
+ void foo(...);
+
+ void test() {
+ A x;
+ foo(x);
+ }
+ // CHECK: define void @_ZN5test14testEv()
+ // CHECK: [[X:%.*]] = alloca [[A:%.*]], align 4
+ // CHECK-NEXT: [[TMP:%.*]] = alloca [[A]], align 4
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [[A]]* [[TMP]] to i8*
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[A]]* [[X]] to i8*
+ // CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[T0]], i8* [[T1]], i64 8, i32 4, i1 false)
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [[A]]* [[TMP]] to i64*
+ // CHECK-NEXT: [[T1:%.*]] = load i64* [[T0]], align 1
+ // CHECK-NEXT: call void (...)* @_ZN5test13fooEz(i64 [[T1]])
+ // CHECK-NEXT: ret void
+}
diff --git a/clang/test/CodeGenCXX/variadic-templates.cpp b/clang/test/CodeGenCXX/variadic-templates.cpp
new file mode 100644
index 0000000..c56bec3
--- /dev/null
+++ b/clang/test/CodeGenCXX/variadic-templates.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+
+template<typename ...Types>
+int get_num_types(Types...) {
+ return sizeof...(Types);
+}
+
+// CHECK: define weak_odr i32 @_Z13get_num_typesIJifdEEiDpT_
+// CHECK: ret i32 3
+template int get_num_types(int, float, double);
+
+// PR10260 - argument packs that expand to nothing
+namespace test1 {
+ template <class... T> void foo() {
+ int values[sizeof...(T)+1] = { T::value... };
+ // CHECK: define linkonce_odr void @_ZN5test13fooIJEEEvv()
+ // CHECK: alloca [1 x i32], align 4
+ }
+
+ void test() {
+ foo<>();
+ }
+}
diff --git a/clang/test/CodeGenCXX/virt-call-offsets.cpp b/clang/test/CodeGenCXX/virt-call-offsets.cpp
new file mode 100644
index 0000000..5eef6fe
--- /dev/null
+++ b/clang/test/CodeGenCXX/virt-call-offsets.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+struct A { virtual void a(); };
+struct B : A {};
+struct C : B { virtual void a(); };
+void (C::*x)() = &C::a;
+
+// CHECK: @x = global { i{{[0-9]+}}, i{{[0-9]+}} } { i{{[0-9]+}} 1, i{{[0-9]+}} 0 }
diff --git a/clang/test/CodeGenCXX/virt-canonical-decl.cpp b/clang/test/CodeGenCXX/virt-canonical-decl.cpp
new file mode 100644
index 0000000..dfc3619
--- /dev/null
+++ b/clang/test/CodeGenCXX/virt-canonical-decl.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -emit-llvm-only
+
+class Base {
+public:
+ virtual ~Base();
+};
+
+Base::~Base()
+{
+}
+
+class Foo : public Base {
+public:
+ virtual ~Foo();
+};
+
+Foo::~Foo()
+{
+}
diff --git a/clang/test/CodeGenCXX/virt-dtor-gen.cpp b/clang/test/CodeGenCXX/virt-dtor-gen.cpp
new file mode 100644
index 0000000..1a6c583
--- /dev/null
+++ b/clang/test/CodeGenCXX/virt-dtor-gen.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -o - -emit-llvm %s | FileCheck %s
+// PR5483
+
+// Make sure we generate all three forms of the destructor when it is virtual.
+class Foo {
+ virtual ~Foo();
+};
+Foo::~Foo() {}
+
+// CHECK: define void @_ZN3FooD0Ev(%class.Foo* %this) unnamed_addr
diff --git a/clang/test/CodeGenCXX/virt-dtor-key.cpp b/clang/test/CodeGenCXX/virt-dtor-key.cpp
new file mode 100644
index 0000000..a8fa371
--- /dev/null
+++ b/clang/test/CodeGenCXX/virt-dtor-key.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// CHECK: @_ZTI3foo = unnamed_addr constant
+class foo {
+ foo();
+ virtual ~foo();
+};
+
+foo::~foo() {
+}
diff --git a/clang/test/CodeGenCXX/virt-template-vtable.cpp b/clang/test/CodeGenCXX/virt-template-vtable.cpp
new file mode 100644
index 0000000..25736fd
--- /dev/null
+++ b/clang/test/CodeGenCXX/virt-template-vtable.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+template<class T> class A {
+public:
+ A() {}
+ virtual void a() {}
+};
+class B : A<int> {
+ B();
+};
+B::B() {}
+
+template class A<long>;
+
+extern template class A<short>;
+template class A<short>;
+
+
+// CHECK: @_ZTV1B = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTV1AIlE = weak_odr unnamed_addr constant
+// CHECK: @_ZTV1AIsE = weak_odr unnamed_addr constant
+// CHECK: @_ZTV1AIiE = linkonce_odr unnamed_addr constant
diff --git a/clang/test/CodeGenCXX/virt-thunk-reference.cpp b/clang/test/CodeGenCXX/virt-thunk-reference.cpp
new file mode 100644
index 0000000..0cd958b
--- /dev/null
+++ b/clang/test/CodeGenCXX/virt-thunk-reference.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+
+struct A { int a; virtual void aa(int&); };
+struct B { int b; virtual void bb(int&); };
+struct C : A,B { virtual void aa(int&), bb(int&); };
+void C::aa(int&) {}
+void C::bb(int&) {}
diff --git a/clang/test/CodeGenCXX/virtual-base-cast.cpp b/clang/test/CodeGenCXX/virtual-base-cast.cpp
new file mode 100644
index 0000000..73b7c1c
--- /dev/null
+++ b/clang/test/CodeGenCXX/virtual-base-cast.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple i686-pc-linux-gnu | FileCheck %s
+
+struct A { int a; virtual int aa(); };
+struct B { int b; virtual int bb(); };
+struct C : virtual A, virtual B { int c; virtual int aa(); virtual int bb(); };
+struct AA { int a; virtual int aa(); };
+struct BB { int b; virtual int bb(); };
+struct CC : AA, BB { virtual int aa(); virtual int bb(); virtual int cc(); };
+struct D : virtual C, virtual CC { int e; };
+
+D* x;
+
+A* a() { return x; }
+// CHECK: @_Z1av() nounwind
+// CHECK: [[VBASEOFFSETPTRA:%[a-zA-Z0-9\.]+]] = getelementptr i8* {{.*}}, i64 -16
+// CHECK: [[CASTVBASEOFFSETPTRA:%[a-zA-Z0-9\.]+]] = bitcast i8* [[VBASEOFFSETPTRA]] to i32*
+// CHECK: load i32* [[CASTVBASEOFFSETPTRA]]
+// CHECK: }
+
+B* b() { return x; }
+// CHECK: @_Z1bv() nounwind
+// CHECK: [[VBASEOFFSETPTRA:%[a-zA-Z0-9\.]+]] = getelementptr i8* {{.*}}, i64 -20
+// CHECK: [[CASTVBASEOFFSETPTRA:%[a-zA-Z0-9\.]+]] = bitcast i8* [[VBASEOFFSETPTRA]] to i32*
+// CHECK: load i32* [[CASTVBASEOFFSETPTRA]]
+// CHECK: }
+
+BB* c() { return x; }
+// CHECK: @_Z1cv() nounwind
+// CHECK: [[VBASEOFFSETPTRC:%[a-zA-Z0-9\.]+]] = getelementptr i8* {{.*}}, i64 -24
+// CHECK: [[CASTVBASEOFFSETPTRC:%[a-zA-Z0-9\.]+]] = bitcast i8* [[VBASEOFFSETPTRC]] to i32*
+// CHECK: [[VBASEOFFSETC:%[a-zA-Z0-9\.]+]] = load i32* [[CASTVBASEOFFSETPTRC]]
+// CHECK: add i32 [[VBASEOFFSETC]], 8
+// CHECK: }
diff --git a/clang/test/CodeGenCXX/virtual-base-ctor.cpp b/clang/test/CodeGenCXX/virtual-base-ctor.cpp
new file mode 100644
index 0000000..2d81ebd
--- /dev/null
+++ b/clang/test/CodeGenCXX/virtual-base-ctor.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -O2 | FileCheck %s
+
+struct B;
+extern B x;
+char y;
+typedef __typeof(sizeof(int)) size_t;
+struct A { int a; A() { y = ((size_t)this - (size_t)&x) / sizeof(void*); } };
+struct B : virtual A { void* x; };
+B x;
+
+// CHECK: @y = global i8 2
diff --git a/clang/test/CodeGenCXX/virtual-base-destructor-call.cpp b/clang/test/CodeGenCXX/virtual-base-destructor-call.cpp
new file mode 100644
index 0000000..2424d21
--- /dev/null
+++ b/clang/test/CodeGenCXX/virtual-base-destructor-call.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+struct basic_ios{~basic_ios(); };
+
+template<typename _CharT> struct basic_istream : virtual public basic_ios {
+ virtual ~basic_istream(){}
+};
+
+template<typename _CharT> struct basic_iostream : public basic_istream<_CharT>
+{
+ virtual ~basic_iostream(){}
+};
+
+basic_iostream<char> res;
+
+int main() {
+}
+
+// basic_iostream's complete dtor calls its base dtor, then its
+// virtual base's dtor.
+// CHECK: define linkonce_odr {{.*}} @_ZN14basic_iostreamIcED1Ev(%struct.basic_iostream* %this) unnamed_addr
+// CHECK: call {{.*}} @_ZN14basic_iostreamIcED2Ev
+// CHECK: call {{.*}} @_ZN9basic_iosD2Ev
+
+// basic_iostream's base dtor calls its non-virtual base dtor.
+// CHECK: define linkonce_odr {{.*}} @_ZN14basic_iostreamIcED2Ev(%struct.basic_iostream* %this, i8** %vtt) unnamed_addr
+// CHECK: call {{.*}} @_ZN13basic_istreamIcED2Ev
+// CHECK: }
+
+// basic_iostream's deleting dtor calls its complete dtor, then
+// operator delete().
+// CHECK: define linkonce_odr {{.*}} @_ZN14basic_iostreamIcED0Ev(%struct.basic_iostream* %this) unnamed_addr
+// CHECK: call {{.*}} @_ZN14basic_iostreamIcED1Ev
+// CHECK: call {{.*}} @_ZdlPv
+
+// basic_istream's complete dtor calls the base dtor,
+// then its virtual base's base dtor.
+// CHECK: define linkonce_odr {{.*}} @_ZN13basic_istreamIcED1Ev(%struct.basic_istream* %this) unnamed_addr
+// CHECK: call {{.*}} @_ZN13basic_istreamIcED2Ev
+// CHECK: call {{.*}} @_ZN9basic_iosD2Ev
+
+// basic_istream's deleting dtor calls the complete dtor, then
+// operator delete().
+// CHECK: define linkonce_odr {{.*}} @_ZN13basic_istreamIcED0Ev(%struct.basic_istream* %this) unnamed_addr
+// CHECK: call {{.*}} @_ZN13basic_istreamIcED1Ev
+// CHECK: call {{.*}} @_ZdlPv
+
+// basic_istream's base dtor is a no-op.
+// CHECK: define linkonce_odr {{.*}} @_ZN13basic_istreamIcED2Ev(%struct.basic_istream* %this, i8** %vtt) unnamed_addr
+// CHECK-NOT: call
+// CHECK: }
diff --git a/clang/test/CodeGenCXX/virtual-bases.cpp b/clang/test/CodeGenCXX/virtual-bases.cpp
new file mode 100644
index 0000000..c9f13f8
--- /dev/null
+++ b/clang/test/CodeGenCXX/virtual-bases.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 -mconstructor-aliases | FileCheck %s
+
+struct A {
+ A();
+};
+
+// CHECK: @_ZN1AC1Ev = alias {{.*}} @_ZN1AC2Ev
+// CHECK: define void @_ZN1AC2Ev(%struct.A* %this) unnamed_addr
+A::A() { }
+
+struct B : virtual A {
+ B();
+};
+
+// CHECK: define void @_ZN1BC1Ev(%struct.B* %this) unnamed_addr
+// CHECK: define void @_ZN1BC2Ev(%struct.B* %this, i8** %vtt) unnamed_addr
+B::B() { }
+
+struct C : virtual A {
+ C(bool);
+};
+
+// CHECK: define void @_ZN1CC1Eb(%struct.C* %this, i1 zeroext) unnamed_addr
+// CHECK: define void @_ZN1CC2Eb(%struct.C* %this, i8** %vtt, i1 zeroext) unnamed_addr
+C::C(bool) { }
+
+// PR6251
+namespace PR6251 {
+
+// Test that we don't call the A<char> constructor twice.
+
+template<typename T>
+struct A { A(); };
+
+struct B : virtual A<char> { };
+struct C : virtual A<char> { };
+
+struct D : B, C {
+ D();
+};
+
+// CHECK: define void @_ZN6PR62511DC1Ev(%"struct.PR6251::D"* %this) unnamed_addr
+// CHECK: call void @_ZN6PR62511AIcEC2Ev
+// CHECK-NOT: call void @_ZN6PR62511AIcEC2Ev
+// CHECK: ret void
+D::D() { }
+
+}
diff --git a/clang/test/CodeGenCXX/virtual-destructor-calls.cpp b/clang/test/CodeGenCXX/virtual-destructor-calls.cpp
new file mode 100644
index 0000000..1cc8bcc
--- /dev/null
+++ b/clang/test/CodeGenCXX/virtual-destructor-calls.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 -mconstructor-aliases | FileCheck %s
+
+struct Member {
+ ~Member();
+};
+
+struct A {
+ virtual ~A();
+};
+
+struct B : A {
+ Member m;
+ virtual ~B();
+};
+
+// Complete dtor: just an alias because there are no virtual bases.
+// CHECK: @_ZN1BD1Ev = alias {{.*}} @_ZN1BD2Ev
+
+// (aliases from C)
+// CHECK: @_ZN1CD1Ev = alias {{.*}} @_ZN1CD2Ev
+// CHECK: @_ZN1CD2Ev = alias bitcast {{.*}} @_ZN1BD2Ev
+
+// Deleting dtor: defers to the complete dtor.
+// CHECK: define void @_ZN1BD0Ev(%struct.B* %this) unnamed_addr
+// CHECK: call void @_ZN1BD1Ev
+// CHECK: call void @_ZdlPv
+
+// Base dtor: actually calls A's base dtor.
+// CHECK: define void @_ZN1BD2Ev(%struct.B* %this) unnamed_addr
+// CHECK: call void @_ZN6MemberD1Ev
+// CHECK: call void @_ZN1AD2Ev
+
+B::~B() { }
+
+struct C : B {
+ ~C();
+};
+
+C::~C() { }
+
+// Complete dtor: just an alias (checked above).
+
+// Deleting dtor: defers to the complete dtor.
+// CHECK: define void @_ZN1CD0Ev(%struct.C* %this) unnamed_addr
+// CHECK: call void @_ZN1CD1Ev
+// CHECK: call void @_ZdlPv
+
+// Base dtor: just an alias to B's base dtor.
diff --git a/clang/test/CodeGenCXX/virtual-destructor-synthesis.cpp b/clang/test/CodeGenCXX/virtual-destructor-synthesis.cpp
new file mode 100644
index 0000000..90f66a8
--- /dev/null
+++ b/clang/test/CodeGenCXX/virtual-destructor-synthesis.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+struct box {
+ virtual ~box();
+};
+
+struct pile_box : public box {
+ pile_box(box *);
+};
+
+pile_box::pile_box(box *pp)
+{
+}
+
+// CHECK: call void @_ZdlPv
+
diff --git a/clang/test/CodeGenCXX/virtual-function-calls.cpp b/clang/test/CodeGenCXX/virtual-function-calls.cpp
new file mode 100644
index 0000000..46e7b2d
--- /dev/null
+++ b/clang/test/CodeGenCXX/virtual-function-calls.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// PR5021
+namespace PR5021 {
+
+struct A {
+ virtual void f(char);
+};
+
+void f(A *a) {
+ // CHECK: call void %
+ a->f('c');
+}
+
+struct B : virtual A {
+ virtual void f();
+};
+
+void f(B * b) {
+ b->f();
+}
+
+}
+
+namespace Test1 {
+ struct A {
+ virtual ~A();
+ };
+
+ struct B : A {
+ virtual ~B();
+ virtual void f();
+ };
+
+ void f(B *b) {
+ b->f();
+ }
+}
diff --git a/clang/test/CodeGenCXX/virtual-functions-incomplete-types.cpp b/clang/test/CodeGenCXX/virtual-functions-incomplete-types.cpp
new file mode 100644
index 0000000..afa658f
--- /dev/null
+++ b/clang/test/CodeGenCXX/virtual-functions-incomplete-types.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+struct A;
+
+struct B {
+ virtual void f();
+ virtual A g();
+};
+
+void B::f() { }
+
+// CHECK: define i32 @_ZN1D1gEv(%struct.D* %this)
+// CHECK: declare void @_ZN1B1gEv()
+
+struct C;
+
+struct D {
+ virtual void f();
+ virtual C g();
+};
+
+void D::f() { }
+
+struct C {
+ int a;
+};
+
+C D::g() {
+ return C();
+}
diff --git a/clang/test/CodeGenCXX/virtual-implicit-copy-assignment.cpp b/clang/test/CodeGenCXX/virtual-implicit-copy-assignment.cpp
new file mode 100644
index 0000000..70bc6fc
--- /dev/null
+++ b/clang/test/CodeGenCXX/virtual-implicit-copy-assignment.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+struct D;
+struct B {
+ virtual D& operator = (const D&);
+};
+struct D : B { D(); virtual void a(); };
+void D::a() {}
+
+// CHECK: @_ZTV1D = {{.*}} @_ZN1DaSERKS_
+// CHECK: define linkonce_odr {{.*}} @_ZN1DaSERKS_
diff --git a/clang/test/CodeGenCXX/virtual-implicit-move-assignment.cpp b/clang/test/CodeGenCXX/virtual-implicit-move-assignment.cpp
new file mode 100644
index 0000000..d8ac1ed
--- /dev/null
+++ b/clang/test/CodeGenCXX/virtual-implicit-move-assignment.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm -std=c++11 -o - %s | FileCheck %s
+
+struct D;
+struct B {
+ virtual D &operator=(D&&) = 0;
+};
+struct D : B { D(); virtual void a(); };
+void D::a() {}
+D d;
+
+// CHECK: @_ZTV1D = {{.*}} @_ZN1DaSEOS_
+// CHECK: define linkonce_odr {{.*}} @_ZN1DaSEOS_
diff --git a/clang/test/CodeGenCXX/virtual-inherited-destructor.cpp b/clang/test/CodeGenCXX/virtual-inherited-destructor.cpp
new file mode 100644
index 0000000..509d40a
--- /dev/null
+++ b/clang/test/CodeGenCXX/virtual-inherited-destructor.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -emit-llvm-only
+
+struct A { virtual ~A(); };
+struct B : A {
+ ~B() { }
+};
+B x;
+
diff --git a/clang/test/CodeGenCXX/virtual-operator-call.cpp b/clang/test/CodeGenCXX/virtual-operator-call.cpp
new file mode 100644
index 0000000..42d38e5
--- /dev/null
+++ b/clang/test/CodeGenCXX/virtual-operator-call.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+struct A {
+ virtual int operator-() = 0;
+};
+
+void f(A *a) {
+ // CHECK: call i32 %
+ -*a;
+}
diff --git a/clang/test/CodeGenCXX/virtual-pseudo-destructor-call.cpp b/clang/test/CodeGenCXX/virtual-pseudo-destructor-call.cpp
new file mode 100644
index 0000000..0d3574e
--- /dev/null
+++ b/clang/test/CodeGenCXX/virtual-pseudo-destructor-call.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+struct A {
+ virtual ~A();
+};
+
+void f(A *a) {
+ // CHECK: define {{.*}} @_Z1fP1A
+ // CHECK: load
+ // CHECK: load
+ // CHECK: [[CALLEE:%[a-zA-Z0-9.]*]] = load
+ // CHECK: call {{.*}} [[CALLEE]](
+ a->~A();
+}
diff --git a/clang/test/CodeGenCXX/visibility-hidden-extern-templates.cpp b/clang/test/CodeGenCXX/visibility-hidden-extern-templates.cpp
new file mode 100644
index 0000000..7629b77
--- /dev/null
+++ b/clang/test/CodeGenCXX/visibility-hidden-extern-templates.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -O1 -emit-llvm -o - -fvisibility hidden %s | FileCheck %s
+
+template<typename T>
+struct X {
+ void f();
+ void g() { }
+};
+
+template<typename T> void X<T>::f() { }
+
+extern template struct X<int>;
+template struct X<int>;
+extern template struct X<char>;
+
+// <rdar://problem/8109763>
+void test_X(X<int> xi, X<char> xc) {
+ // CHECK: define weak_odr hidden void @_ZN1XIiE1fEv
+ xi.f();
+ // CHECK: define weak_odr hidden void @_ZN1XIiE1gEv
+ xi.g();
+ // CHECK: declare void @_ZN1XIcE1fEv
+ xc.f();
+ // CHECK: define available_externally void @_ZN1XIcE1gEv
+ xc.g();
+}
+
diff --git a/clang/test/CodeGenCXX/visibility-inlines-hidden.cpp b/clang/test/CodeGenCXX/visibility-inlines-hidden.cpp
new file mode 100644
index 0000000..d660b1b
--- /dev/null
+++ b/clang/test/CodeGenCXX/visibility-inlines-hidden.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -fvisibility-inlines-hidden -emit-llvm -o - %s -O2 -disable-llvm-optzns | FileCheck %s
+
+// The trickery with optimization in the run line is to get IR
+// generation to emit available_externally function bodies, but not
+// actually inline them (and thus remove the emitted bodies).
+
+struct X0 {
+ void __attribute__((visibility("default"))) f1() { }
+ void f2() { }
+ void f3();
+ static void f5() { }
+ virtual void f6() { }
+};
+
+inline void X0::f3() { }
+
+template<typename T>
+struct X1 {
+ void __attribute__((visibility("default"))) f1() { }
+ void f2() { }
+ void f3();
+ void f4();
+ static void f5() { }
+ virtual void f6() { }
+};
+
+template<typename T>
+inline void X1<T>::f3() { }
+
+template<>
+inline void X1<int>::f4() { }
+
+struct __attribute__((visibility("default"))) X2 {
+ void f2() { }
+};
+
+extern template struct X1<float>;
+
+void use(X0 *x0, X1<int> *x1, X2 *x2, X1<float> *x3) {
+ // CHECK: define linkonce_odr void @_ZN2X02f1Ev
+ x0->f1();
+ // CHECK: define linkonce_odr hidden void @_ZN2X02f2Ev
+ x0->f2();
+ // CHECK: define linkonce_odr hidden void @_ZN2X02f3Ev
+ x0->f3();
+ // CHECK: define linkonce_odr hidden void @_ZN2X02f5Ev
+ X0::f5();
+ // CHECK: define linkonce_odr hidden void @_ZN2X02f6Ev
+ x0->X0::f6();
+ // CHECK: define linkonce_odr void @_ZN2X1IiE2f1Ev
+ x1->f1();
+ // CHECK: define linkonce_odr hidden void @_ZN2X1IiE2f2Ev
+ x1->f2();
+ // CHECK: define linkonce_odr hidden void @_ZN2X1IiE2f3Ev
+ x1->f3();
+ // CHECK: define linkonce_odr hidden void @_ZN2X1IiE2f4Ev
+ x1->f4();
+ // CHECK: define linkonce_odr hidden void @_ZN2X1IiE2f5Ev
+ X1<int>::f5();
+ // CHECK: define linkonce_odr hidden void @_ZN2X1IiE2f6Ev
+ x1->X1::f6();
+ // CHECK: define linkonce_odr hidden void @_ZN2X22f2Ev
+ x2->f2();
+ // CHECK: define available_externally void @_ZN2X1IfE2f2Ev
+ x3->f2();
+}
+
+// rdar://problem/8614470
+namespace test1 {
+ struct __attribute__((visibility("default"))) A {
+ inline void foo();
+ ~A();
+ };
+
+ void test() {
+ A a;
+ a.foo();
+ }
+// CHECK: declare void @_ZN5test11A3fooEv
+// CHECK: declare {{.*}} @_ZN5test11AD1Ev
+}
+
+// PR8713
+namespace test2 {
+ struct A {};
+ template <class T> class B {};
+ typedef B<A> arg;
+
+ namespace ns __attribute__((visibility("default"))) {
+ template <class T> inline void foo() {}
+ extern template void foo<arg>();
+ }
+
+ void test() {
+ ns::foo<arg>();
+ }
+
+ // CHECK: define available_externally void @_ZN5test22ns3fooINS_1BINS_1AEEEEEvv()
+}
+
+namespace PR11642 {
+ template <typename T>
+ class Foo {
+ public:
+ T foo(T x) { return x; }
+ };
+ extern template class Foo<int>;
+ template class Foo<int>;
+ // CHECK: define weak_odr i32 @_ZN7PR116423FooIiE3fooEi
+}
diff --git a/clang/test/CodeGenCXX/visibility.cpp b/clang/test/CodeGenCXX/visibility.cpp
new file mode 100644
index 0000000..59fd7c2
--- /dev/null
+++ b/clang/test/CodeGenCXX/visibility.cpp
@@ -0,0 +1,607 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN
+
+#define HIDDEN __attribute__((visibility("hidden")))
+#define PROTECTED __attribute__((visibility("protected")))
+#define DEFAULT __attribute__((visibility("default")))
+
+namespace test25 {
+ template<typename T>
+ struct X {
+ template<typename U>
+ struct definition {
+ };
+ };
+
+ class DEFAULT A { };
+
+ X<int>::definition<A> a;
+ // CHECK: @_ZN6test251aE = global
+ // CHECK-HIDDEN: @_ZN6test251aE = hidden global
+}
+
+namespace test28 {
+ class DEFAULT foo {
+ };
+ foo myvec;
+ // CHECK: @_ZN6test285myvecE = global
+ // CHECK-HIDDEN: @_ZN6test285myvecE = hidden global
+}
+
+// CHECK: @_ZN5Test425VariableInHiddenNamespaceE = hidden global i32 10
+// CHECK: @_ZN5Test71aE = hidden global
+// CHECK: @_ZN5Test71bE = global
+// CHECK: @test9_var = global
+// CHECK-HIDDEN: @test9_var = global
+// CHECK: @_ZN6Test121A6hiddenE = external hidden global
+// CHECK: @_ZN6Test121A7visibleE = external global
+// CHECK-HIDDEN: @_ZN6Test121A6hiddenE = external hidden global
+// CHECK-HIDDEN: @_ZN6Test121A7visibleE = external global
+// CHECK: @_ZN6Test131B1aE = hidden global
+// CHECK: @_ZN6Test131C1aE = global
+// CHECK-HIDDEN: @_ZN6Test131B1aE = hidden global
+// CHECK-HIDDEN: @_ZN6Test131C1aE = global
+// CHECK: @_ZN6Test143varE = external global
+// CHECK-HIDDEN: @_ZN6Test143varE = external global
+// CHECK: @_ZN6Test154TempINS_1AEE5Inner6bufferE = external global [0 x i8]
+// CHECK-HIDDEN: @_ZN6Test154TempINS_1AEE5Inner6bufferE = external global [0 x i8]
+
+namespace test27 {
+ template<typename T>
+ class C {
+ class __attribute__((visibility("default"))) D {
+ void f();
+ };
+ };
+
+ template<>
+ class C<int>::D {
+ virtual void g();
+ };
+
+ void C<int>::D::g() {
+ }
+ // CHECK: _ZTVN6test271CIiE1DE = unnamed_addr constant
+ // CHECK-HIDDEN: _ZTVN6test271CIiE1DE = unnamed_addr constant
+}
+
+// CHECK: @_ZZN6Test193fooIiEEvvE1a = linkonce_odr global
+// CHECK: @_ZGVZN6Test193fooIiEEvvE1a = linkonce_odr global i64
+// CHECK-HIDDEN: @_ZZN6Test193fooIiEEvvE1a = linkonce_odr hidden global
+// CHECK-HIDDEN: @_ZGVZN6Test193fooIiEEvvE1a = linkonce_odr hidden global i64
+// CHECK-HIDDEN: @_ZTVN6Test161AIcEE = external unnamed_addr constant
+// CHECK-HIDDEN: @_ZTTN6Test161AIcEE = external unnamed_addr constant
+// CHECK: @_ZTVN5Test63fooE = linkonce_odr hidden unnamed_addr constant
+
+namespace Test1 {
+ // CHECK: define hidden void @_ZN5Test11fEv
+ void HIDDEN f() { }
+
+}
+
+namespace Test2 {
+ struct HIDDEN A {
+ void f();
+ };
+
+ // A::f is a member function of a hidden class.
+ // CHECK: define hidden void @_ZN5Test21A1fEv
+ void A::f() { }
+}
+
+namespace Test3 {
+ struct HIDDEN A {
+ struct B {
+ void f();
+ };
+ };
+
+ // B is a nested class where its parent class is hidden.
+ // CHECK: define hidden void @_ZN5Test31A1B1fEv
+ void A::B::f() { }
+}
+
+namespace Test4 HIDDEN {
+ int VariableInHiddenNamespace = 10;
+
+ // Test4::g is in a hidden namespace.
+ // CHECK: define hidden void @_ZN5Test41gEv
+ void g() { }
+
+ struct DEFAULT A {
+ void f();
+ };
+
+ // A has default visibility.
+ // CHECK: define void @_ZN5Test41A1fEv
+ void A::f() { }
+}
+
+namespace Test5 {
+
+ namespace NS HIDDEN {
+ // f is in NS which is hidden.
+ // CHECK: define hidden void @_ZN5Test52NS1fEv()
+ void f() { }
+ }
+
+ namespace NS {
+ // g is in NS, but this NS decl is not hidden.
+ // CHECK: define void @_ZN5Test52NS1gEv
+ void g() { }
+ }
+}
+
+// <rdar://problem/8091955>
+namespace Test6 {
+ struct HIDDEN foo {
+ foo() { }
+ void bonk();
+ virtual void bar() = 0;
+
+ virtual void zonk() {}
+ };
+
+ struct barc : public foo {
+ barc();
+ virtual void bar();
+ };
+
+ barc::barc() {}
+}
+
+namespace Test7 {
+ class HIDDEN A {};
+ A a; // top of file
+
+ template <A&> struct Aref {
+ static void foo() {}
+ };
+
+ class B : public A {};
+ B b; // top of file
+
+ // CHECK: define linkonce_odr hidden void @_ZN5Test74ArefILZNS_1aEEE3fooEv()
+ void test() {
+ Aref<a>::foo();
+ }
+}
+
+namespace Test8 {
+ void foo();
+ void bar() {}
+ // CHECK-HIDDEN: define hidden void @_ZN5Test83barEv()
+ // CHECK-HIDDEN: declare void @_ZN5Test83fooEv()
+
+ void test() {
+ foo();
+ bar();
+ }
+}
+
+// PR8457
+namespace Test9 {
+ extern "C" {
+ struct A { int field; };
+ void DEFAULT test9_fun(struct A *a) { }
+ struct A DEFAULT test9_var; // above
+ }
+ // CHECK: define void @test9_fun(
+ // CHECK-HIDDEN: define void @test9_fun(
+
+ void test() {
+ A a = test9_var;
+ test9_fun(&a);
+ }
+}
+
+// PR8478
+namespace Test10 {
+ struct A;
+
+ class DEFAULT B {
+ void foo(A*);
+ };
+
+ // CHECK: define void @_ZN6Test101B3fooEPNS_1AE(
+ // CHECK-HIDDEN: define void @_ZN6Test101B3fooEPNS_1AE(
+ void B::foo(A*) {}
+}
+
+// PR8492
+namespace Test11 {
+ struct A {
+ void foo() {}
+ void DEFAULT bar() {}
+ };
+
+ void test() {
+ A a;
+ a.foo();
+ a.bar();
+ }
+
+ // CHECK: define linkonce_odr void @_ZN6Test111A3fooEv(
+ // CHECK: define linkonce_odr void @_ZN6Test111A3barEv(
+ // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6Test111A3fooEv(
+ // CHECK-HIDDEN: define linkonce_odr void @_ZN6Test111A3barEv(
+}
+
+// Tested at top of file.
+namespace Test12 {
+ struct A {
+ // This is hidden in all cases: the explicit attribute takes
+ // priority over -fvisibility on the parent.
+ static int hidden HIDDEN;
+
+ // This is default in all cases because it's only a declaration.
+ static int visible;
+ };
+
+ void test() {
+ A::hidden = 0;
+ A::visible = 0;
+ }
+}
+
+// Tested at top of file.
+namespace Test13 {
+ struct HIDDEN A {};
+
+ // Should be hidden in all cases.
+ struct B {
+ static A a;
+ };
+ A B::a;
+
+ // Should be default in all cases.
+ struct DEFAULT C {
+ static A a;
+ };
+ A C::a;
+};
+
+// Tested at top of file.
+namespace Test14 {
+ // Neither the visibility of the type nor -fvisibility=hidden should
+ // apply to declarations.
+ extern struct A *var;
+
+ struct A *test() { return var; }
+}
+
+// rdar://problem/8613093
+namespace Test15 {
+ struct A {};
+ template <class T> struct Temp {
+ struct Inner {
+ static char buffer[0];
+ };
+ };
+
+ char *test() {
+ return Temp<A>::Inner::buffer;
+ }
+}
+
+namespace Test16 {
+ struct Base1 { virtual void foo(); };
+ struct Base2 : virtual Base1 { virtual void foo(); };
+ template <class T> struct A : virtual Base1, Base2 {
+ virtual void foo();
+ };
+ extern template struct A<char>;
+
+ void test() {
+ A<char> a;
+ a.foo();
+ }
+}
+
+namespace Test17 {
+ struct HIDDEN A {
+ static void foo();
+ static void DEFAULT bar();
+ static void HIDDEN baz();
+
+ struct DEFAULT B {
+ static void foo();
+ static void DEFAULT bar();
+ static void HIDDEN baz();
+ };
+ };
+
+ void test() {
+ A::foo();
+ A::bar();
+ A::baz();
+ A::B::foo();
+ A::B::bar();
+ A::B::baz();
+ }
+ // CHECK: declare hidden void @_ZN6Test171A3fooEv()
+ // CHECK: declare void @_ZN6Test171A3barEv()
+ // CHECK: declare hidden void @_ZN6Test171A3bazEv()
+ // CHECK: declare void @_ZN6Test171A1B3fooEv()
+ // CHECK: declare void @_ZN6Test171A1B3barEv()
+ // CHECK: declare hidden void @_ZN6Test171A1B3bazEv()
+ // CHECK-HIDDEN: declare hidden void @_ZN6Test171A3fooEv()
+ // CHECK-HIDDEN: declare void @_ZN6Test171A3barEv()
+ // CHECK-HIDDEN: declare hidden void @_ZN6Test171A3bazEv()
+ // CHECK-HIDDEN: declare void @_ZN6Test171A1B3fooEv()
+ // CHECK-HIDDEN: declare void @_ZN6Test171A1B3barEv()
+ // CHECK-HIDDEN: declare hidden void @_ZN6Test171A1B3bazEv()
+}
+
+namespace Test18 {
+ template <class T> struct HIDDEN A {
+ static void foo();
+ static void DEFAULT bar();
+ static void HIDDEN baz();
+
+ struct DEFAULT B {
+ static void foo();
+ static void DEFAULT bar();
+ static void HIDDEN baz();
+ };
+ };
+ struct HIDDEN H;
+
+ void test() {
+ A<int>::foo();
+ A<int>::bar();
+ A<int>::baz();
+ A<int>::B::foo();
+ A<int>::B::bar();
+ A<int>::B::baz();
+ A<H>::foo();
+ A<H>::bar();
+ A<H>::baz();
+ A<H>::B::foo();
+ A<H>::B::bar();
+ A<H>::B::baz();
+ }
+ // CHECK: declare hidden void @_ZN6Test181AIiE3fooEv()
+ // CHECK: declare void @_ZN6Test181AIiE3barEv()
+ // CHECK: declare hidden void @_ZN6Test181AIiE3bazEv()
+ // CHECK: declare void @_ZN6Test181AIiE1B3fooEv()
+ // CHECK: declare void @_ZN6Test181AIiE1B3barEv()
+ // CHECK: declare hidden void @_ZN6Test181AIiE1B3bazEv()
+ // CHECK: declare hidden void @_ZN6Test181AINS_1HEE3fooEv()
+ // CHECK: declare hidden void @_ZN6Test181AINS_1HEE3barEv()
+ // CHECK: declare hidden void @_ZN6Test181AINS_1HEE3bazEv()
+ // CHECK: declare hidden void @_ZN6Test181AINS_1HEE1B3fooEv()
+ // CHECK: declare hidden void @_ZN6Test181AINS_1HEE1B3barEv()
+ // CHECK: declare hidden void @_ZN6Test181AINS_1HEE1B3bazEv()
+ // CHECK-HIDDEN: declare hidden void @_ZN6Test181AIiE3fooEv()
+ // CHECK-HIDDEN: declare void @_ZN6Test181AIiE3barEv()
+ // CHECK-HIDDEN: declare hidden void @_ZN6Test181AIiE3bazEv()
+ // CHECK-HIDDEN: declare void @_ZN6Test181AIiE1B3fooEv()
+ // CHECK-HIDDEN: declare void @_ZN6Test181AIiE1B3barEv()
+ // CHECK-HIDDEN: declare hidden void @_ZN6Test181AIiE1B3bazEv()
+ // CHECK-HIDDEN: declare hidden void @_ZN6Test181AINS_1HEE3fooEv()
+ // CHECK-HIDDEN: declare hidden void @_ZN6Test181AINS_1HEE3barEv()
+ // CHECK-HIDDEN: declare hidden void @_ZN6Test181AINS_1HEE3bazEv()
+ // CHECK-HIDDEN: declare hidden void @_ZN6Test181AINS_1HEE1B3fooEv()
+ // CHECK-HIDDEN: declare hidden void @_ZN6Test181AINS_1HEE1B3barEv()
+ // CHECK-HIDDEN: declare hidden void @_ZN6Test181AINS_1HEE1B3bazEv()
+}
+
+namespace Test19 {
+ struct A { A(); ~A(); };
+
+ // Tested at top of file.
+ template <class T> void foo() {
+ static A a;
+ }
+
+ void test() {
+ foo<int>();
+ }
+}
+
+// Various things with class template specializations.
+namespace Test20 {
+ template <unsigned> struct HIDDEN A {};
+
+ // An explicit specialization inherits the explicit visibility of
+ // the template.
+ template <> struct A<0> {
+ static void test0();
+ static void test1();
+ };
+
+ // CHECK: define hidden void @_ZN6Test201AILj0EE5test0Ev()
+ void A<0>::test0() {}
+
+ // CHECK: declare hidden void @_ZN6Test201AILj0EE5test1Ev()
+ void test1() {
+ A<0>::test1();
+ }
+
+ // ...unless that's explicitly overridden.
+ template <> struct DEFAULT A<1> {
+ static void test2();
+ static void test3();
+ };
+
+ // CHECK: define void @_ZN6Test201AILj1EE5test2Ev()
+ void A<1>::test2() {}
+
+ // CHECK: declare void @_ZN6Test201AILj1EE5test3Ev()
+ void test3() {
+ A<1>::test3();
+ }
+
+ // <rdar://problem/8778497>
+ // But we should assume that an unknown specialization has the
+ // explicit visibility settings of the template.
+ template <class T> struct B {
+ static void test4() {}
+ static void test5();
+ };
+
+ // CHECK: define linkonce_odr hidden void @_ZN6Test201BINS_1AILj2EEEE5test4Ev()
+ void test4() {
+ B<A<2> >::test4();
+ }
+
+ // CHECK: declare hidden void @_ZN6Test201BINS_1AILj2EEEE5test5Ev()
+ void test5() {
+ B<A<2> >::test5();
+ }
+}
+
+// PR9371
+namespace test21 {
+ enum En { en };
+ template<En> struct A {
+ __attribute__((visibility("default"))) void foo() {}
+ };
+
+ // CHECK: define weak_odr void @_ZN6test211AILNS_2EnE0EE3fooEv(
+ template void A<en>::foo();
+}
+
+// rdar://problem/9616154
+// Visibility on explicit specializations should take precedence.
+namespace test22 {
+ class A1 {};
+ class A2 {};
+
+ template <class T> struct B {};
+ template <> struct DEFAULT B<A1> {
+ static void foo();
+ static void bar() {}
+ };
+ template <> struct B<A2> {
+ static void foo();
+ static void bar() {}
+ };
+
+ void test() {
+ B<A1>::foo();
+ B<A1>::bar();
+ B<A2>::foo();
+ B<A2>::bar();
+ }
+ // CHECK: declare void @_ZN6test221BINS_2A1EE3fooEv()
+ // CHECK: define linkonce_odr void @_ZN6test221BINS_2A1EE3barEv()
+ // CHECK: declare void @_ZN6test221BINS_2A2EE3fooEv()
+ // CHECK: define linkonce_odr void @_ZN6test221BINS_2A2EE3barEv()
+ // CHECK-HIDDEN: declare void @_ZN6test221BINS_2A1EE3fooEv()
+ // CHECK-HIDDEN: define linkonce_odr void @_ZN6test221BINS_2A1EE3barEv()
+ // CHECK-HIDDEN: declare void @_ZN6test221BINS_2A2EE3fooEv()
+ // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test221BINS_2A2EE3barEv()
+}
+
+namespace PR10113 {
+ namespace foo DEFAULT {
+ template<typename T>
+ class bar {
+ void zed() {}
+ };
+ }
+ template class foo::bar<char>;
+ // CHECK: define weak_odr void @_ZN7PR101133foo3barIcE3zedEv
+ // CHECK-HIDDEN: define weak_odr void @_ZN7PR101133foo3barIcE3zedEv
+
+ struct zed {
+ };
+ template class foo::bar<zed>;
+ // CHECK: define weak_odr void @_ZN7PR101133foo3barINS_3zedEE3zedEv
+ // CHECK-HIDDEN: define weak_odr void @_ZN7PR101133foo3barINS_3zedEE3zedEv
+}
+
+namespace PR11690 {
+ template<class T> struct Class {
+ void size() const {
+ }
+ };
+ template class DEFAULT Class<char>;
+ // CHECK: define weak_odr void @_ZNK7PR116905ClassIcE4sizeEv
+ // CHECK-HIDDEN: define weak_odr void @_ZNK7PR116905ClassIcE4sizeEv
+
+ template<class T> void Method() {}
+ template DEFAULT void Method<char>();
+ // CHECK: define weak_odr void @_ZN7PR116906MethodIcEEvv
+ // CHECK-HIDDEN: define weak_odr void @_ZN7PR116906MethodIcEEvv
+}
+
+namespace PR11690_2 {
+ namespace foo DEFAULT {
+ class bar;
+ template<typename T1, typename T2 = bar>
+ class zed {
+ void bar() {
+ }
+ };
+ }
+ struct baz {
+ };
+ template class foo::zed<baz>;
+ // CHECK: define weak_odr void @_ZN9PR11690_23foo3zedINS_3bazENS0_3barEE3barEv
+ // CHECK-HIDDEN: define weak_odr void @_ZN9PR11690_23foo3zedINS_3bazENS0_3barEE3barEv
+}
+
+namespace test23 {
+ // Having a template argument that is explicitly visible should not make
+ // the template instantiation visible.
+ template <typename T>
+ struct X {
+ static void f() {
+ }
+ };
+
+ class DEFAULT A;
+
+ void g() {
+ X<A> y;
+ y.f();
+ }
+ // CHECK: define linkonce_odr void @_ZN6test231XINS_1AEE1fEv
+ // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test231XINS_1AEE1fEv
+}
+
+namespace PR12001 {
+ template <typename P1>
+ void Bind(const P1& p1) {
+ }
+
+ class DEFAULT Version { };
+
+ void f() {
+ Bind(Version());
+ }
+ // CHECK: define linkonce_odr void @_ZN7PR120014BindINS_7VersionEEEvRKT_
+ // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN7PR120014BindINS_7VersionEEEvRKT_
+}
+
+namespace test24 {
+ class DEFAULT A { };
+
+ struct S {
+ template <typename T>
+ void mem() {}
+ };
+
+ void test() {
+ S s;
+ s.mem<A>();
+ }
+ // CHECK: define linkonce_odr void @_ZN6test241S3memINS_1AEEEvv
+ // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test241S3memINS_1AEEEvv
+}
+
+namespace test26 {
+ template<typename T>
+ class C {
+ __attribute__((visibility("default"))) void f();
+ };
+
+ template<>
+ void C<int>::f() { }
+
+ // CHECK: define void @_ZN6test261CIiE1fEv
+ // CHECK-HIDDEN: define void @_ZN6test261CIiE1fEv
+}
diff --git a/clang/test/CodeGenCXX/vla.cpp b/clang/test/CodeGenCXX/vla.cpp
new file mode 100644
index 0000000..b523c76
--- /dev/null
+++ b/clang/test/CodeGenCXX/vla.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s
+
+template<typename T>
+struct S {
+ static int n;
+};
+template<typename T> int S<T>::n = 5;
+
+int f() {
+ // Make sure that the reference here is enough to trigger the instantiation of
+ // the static data member.
+ // CHECK: @_ZN1SIiE1nE = weak_odr global i32 5
+ int a[S<int>::n];
+ return sizeof a;
+}
+
+// rdar://problem/9506377
+void test0(void *array, int n) {
+ // CHECK: define void @_Z5test0Pvi(
+ // CHECK: [[ARRAY:%.*]] = alloca i8*, align 8
+ // CHECK-NEXT: [[N:%.*]] = alloca i32, align 4
+ // CHECK-NEXT: [[REF:%.*]] = alloca i16*, align 8
+ // CHECK-NEXT: [[S:%.*]] = alloca i16, align 2
+ // CHECK-NEXT: store i8*
+ // CHECK-NEXT: store i32
+
+ // Capture the bounds.
+ // CHECK-NEXT: [[T0:%.*]] = load i32* [[N]], align 4
+ // CHECK-NEXT: [[DIM0:%.*]] = zext i32 [[T0]] to i64
+ // CHECK-NEXT: [[T0:%.*]] = load i32* [[N]], align 4
+ // CHECK-NEXT: [[T1:%.*]] = add nsw i32 [[T0]], 1
+ // CHECK-NEXT: [[DIM1:%.*]] = zext i32 [[T1]] to i64
+ typedef short array_t[n][n+1];
+
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[ARRAY]], align 8
+ // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to i16*
+ // CHECK-NEXT: store i16* [[T1]], i16** [[REF]], align 8
+ array_t &ref = *(array_t*) array;
+
+ // CHECK-NEXT: [[T0:%.*]] = load i16** [[REF]]
+ // CHECK-NEXT: [[T1:%.*]] = mul nsw i64 1, [[DIM1]]
+ // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds i16* [[T0]], i64 [[T1]]
+ // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i16* [[T2]], i64 2
+ // CHECK-NEXT: store i16 3, i16* [[T3]]
+ ref[1][2] = 3;
+
+ // CHECK-NEXT: [[T0:%.*]] = load i16** [[REF]]
+ // CHECK-NEXT: [[T1:%.*]] = mul nsw i64 4, [[DIM1]]
+ // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds i16* [[T0]], i64 [[T1]]
+ // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i16* [[T2]], i64 5
+ // CHECK-NEXT: [[T4:%.*]] = load i16* [[T3]]
+ // CHECK-NEXT: store i16 [[T4]], i16* [[S]], align 2
+ short s = ref[4][5];
+
+ // CHECK-NEXT: ret void
+}
diff --git a/clang/test/CodeGenCXX/volatile-1.cpp b/clang/test/CodeGenCXX/volatile-1.cpp
new file mode 100644
index 0000000..71ff1ed
--- /dev/null
+++ b/clang/test/CodeGenCXX/volatile-1.cpp
@@ -0,0 +1,352 @@
+// RUN: %clang_cc1 -Wno-unused-value -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: @i = global [[INT:i[0-9]+]] 0
+volatile int i, j, k;
+volatile int ar[5];
+volatile char c;
+// CHECK: @ci = global [[CINT:.*]] zeroinitializer
+volatile _Complex int ci;
+volatile struct S {
+#ifdef __cplusplus
+ void operator =(volatile struct S&o) volatile;
+#endif
+ int i;
+} a, b;
+
+//void operator =(volatile struct S&o1, volatile struct S&o2) volatile;
+int printf(const char *, ...);
+
+
+// CHECK: define void @{{.*}}test
+void test() {
+
+ asm("nop"); // CHECK: call void asm
+
+ // should not load
+ i;
+
+ (float)(ci);
+ // CHECK-NEXT: load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: sitofp [[INT]]
+
+ // These are not uses in C++:
+ // [expr.static.cast]p6:
+ // The lvalue-to-rvalue . . . conversions are not applied to the expression.
+ (void)ci;
+ (void)a;
+
+ (void)(ci=ci);
+ // CHECK-NEXT: [[R:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: [[I:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: store volatile [[INT]] [[R]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: store volatile [[INT]] [[I]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+
+ (void)(i=j);
+ // CHECK-NEXT: [[T:%.*]] = load volatile [[INT]]* @j
+ // CHECK-NEXT: store volatile [[INT]] [[T]], [[INT]]* @i
+
+ ci+=ci;
+ // CHECK-NEXT: [[R1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: [[I1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: [[R2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: [[I2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // Not sure why they're ordered this way.
+ // CHECK-NEXT: [[R:%.*]] = add [[INT]] [[R2]], [[R1]]
+ // CHECK-NEXT: [[I:%.*]] = add [[INT]] [[I2]], [[I1]]
+ // CHECK-NEXT: store volatile [[INT]] [[R]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: store volatile [[INT]] [[I]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+
+ // Note that C++ requires an extra load volatile over C from the LHS of the '+'.
+ (ci += ci) + ci;
+ // CHECK-NEXT: [[R1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: [[I1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: [[R2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: [[I2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: [[R:%.*]] = add [[INT]] [[R2]], [[R1]]
+ // CHECK-NEXT: [[I:%.*]] = add [[INT]] [[I2]], [[I1]]
+ // CHECK-NEXT: store volatile [[INT]] [[R]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: store volatile [[INT]] [[I]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: [[R1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: [[I1:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: [[R2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 0)
+ // CHECK-NEXT: [[I2:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // These additions can be elided.
+ // CHECK-NEXT: add [[INT]] [[R1]], [[R2]]
+ // CHECK-NEXT: add [[INT]] [[I1]], [[I2]]
+
+ asm("nop"); // CHECK-NEXT: call void asm
+
+ // Extra load volatile in C++.
+ (i += j) + k;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add nsw [[INT]]
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add nsw [[INT]]
+
+ asm("nop"); // CHECK-NEXT: call void asm
+
+ // Extra load volatile in C++.
+ (i += j) + 1;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add nsw [[INT]]
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add nsw [[INT]]
+
+ asm("nop"); // CHECK-NEXT: call void asm
+
+ ci+ci;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add [[INT]]
+ // CHECK-NEXT: add [[INT]]
+
+ __real i;
+
+ +ci;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+
+ asm("nop"); // CHECK-NEXT: call void asm
+
+ (void)(i=i);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+
+ (float)(i=i);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: sitofp
+
+ (void)i;
+
+ i=i;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+
+ // Extra load volatile in C++.
+ i=i=i;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+
+ (void)__builtin_choose_expr(0, i=i, j=j);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+
+ k ? (i=i) : (j=j);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: icmp
+ // CHECK-NEXT: br i1
+ // CHECK: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: br label
+ // CHECK: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: br label
+ // CHECK: phi
+
+ (void)(i,(i=i));
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+
+ i=i,k;
+ // CHECK-NEXT: load volatile [[INT]]* @i
+ // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @i
+
+ (i=j,k=j);
+ // CHECK-NEXT: load volatile [[INT]]* @j
+ // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @i
+ // CHECK-NEXT: load volatile [[INT]]* @j
+ // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @k
+
+ (i=j,k);
+ // CHECK-NEXT: load volatile [[INT]]* @j
+ // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @i
+
+ (i,j);
+
+ // Extra load in C++.
+ i=c=k;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: trunc
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: sext
+ // CHECK-NEXT: store volatile
+
+ i+=k;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add nsw [[INT]]
+ // CHECK-NEXT: store volatile
+
+ ci;
+
+ asm("nop"); // CHECK-NEXT: call void asm
+
+ (int)ci;
+ // CHECK-NEXT: load volatile {{.*}} @ci, i32 0, i32 0
+ // CHECK-NEXT: load volatile {{.*}} @ci, i32 0, i32 1
+
+ (bool)ci;
+ // CHECK-NEXT: load volatile {{.*}} @ci, i32 0, i32 0
+ // CHECK-NEXT: load volatile {{.*}} @ci, i32 0, i32 1
+ // CHECK-NEXT: icmp ne
+ // CHECK-NEXT: icmp ne
+ // CHECK-NEXT: or i1
+
+ ci=ci;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: store volatile
+
+ asm("nop"); // CHECK-NEXT: call void asm
+
+ // Extra load in C++.
+ ci=ci=ci;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: store volatile
+
+ __imag ci = __imag ci = __imag ci;
+ // CHECK-NEXT: [[T:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: store volatile [[INT]] [[T]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: [[T:%.*]] = load volatile [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+ // CHECK-NEXT: store volatile [[INT]] [[T]], [[INT]]* getelementptr inbounds ([[CINT]]* @ci, i32 0, i32 1)
+
+ __real (i = j);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+
+ __imag i;
+
+ // ============================================================
+ // FIXME: Test cases we get wrong.
+
+ // A use. We load all of a into a copy of a, then load i. gcc forgets to do
+ // the assignment.
+ // (a = a).i;
+
+ // ============================================================
+ // Test cases where we intentionally differ from gcc, due to suspected bugs in
+ // gcc.
+
+ // Not a use. gcc forgets to do the assignment.
+ // CHECK-NEXT: call
+ ((a=a),a);
+
+ // Not a use. gcc gets this wrong, it doesn't emit the copy!
+ // CHECK-NEXT: call
+ (void)(a=a);
+
+ // Not a use. gcc got this wrong in 4.2 and omitted the side effects
+ // entirely, but it is fixed in 4.4.0.
+ __imag (i = j);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+
+ // C++ does an extra load here. Note that we have to do full loads.
+ (float)(ci=ci);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: sitofp
+
+ // Not a use, bug? gcc treats this as not a use, that's probably a
+ // bug due to tree folding ignoring volatile.
+ (int)(ci=ci);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+
+ // A use.
+ (float)(i=i);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: sitofp
+
+ // A use. gcc treats this as not a use, that's probably a bug due to tree
+ // folding ignoring volatile.
+ (int)(i=i);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+
+ // A use.
+ -(i=j);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: sub
+
+ // A use. gcc treats this a not a use, that's probably a bug due to tree
+ // folding ignoring volatile.
+ +(i=k);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+
+ // A use. gcc treats this a not a use, that's probably a bug due to tree
+ // folding ignoring volatile.
+ __real (ci=ci);
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: store volatile
+
+ // A use.
+ i + 0;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add
+
+ // A use.
+ (i=j) + i;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add
+
+ // A use. gcc treats this as not a use, that's probably a bug due to tree
+ // folding ignoring volatile.
+ (i=j) + 0;
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: store volatile
+ // CHECK-NEXT: load volatile
+ // CHECK-NEXT: add
+
+ (i,j)=k;
+ // CHECK-NEXT: load volatile [[INT]]* @k
+ // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @j
+
+ (j=k,i)=i;
+ // CHECK-NEXT: load volatile [[INT]]* @i
+ // CHECK-NEXT: load volatile [[INT]]* @k
+ // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @j
+ // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @i
+
+ // CHECK-NEXT: ret void
+}
diff --git a/clang/test/CodeGenCXX/volatile.cpp b/clang/test/CodeGenCXX/volatile.cpp
new file mode 100644
index 0000000..6ebb2f1
--- /dev/null
+++ b/clang/test/CodeGenCXX/volatile.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// Check that IR gen doesn't try to do an lvalue-to-rvalue conversion
+// on a volatile reference result. rdar://problem/8338198
+namespace test0 {
+ struct A {
+ A(const A& t);
+ A& operator=(const A& t);
+ volatile A& operator=(const volatile A& t) volatile;
+ };
+
+ volatile A *array;
+
+ // CHECK: define void @_ZN5test04testENS_1AE(
+ void test(A t) {
+ // CHECK: [[ARR:%.*]] = load [[A:%.*]]** @_ZN5test05arrayE, align 8
+ // CHECK-NEXT: [[IDX:%.*]] = getelementptr inbounds [[A]]* [[ARR]], i64 0
+ // CHECK-NEXT: [[TMP:%.*]] = call [[A]]* @_ZNV5test01AaSERVKS0_([[A]]* [[IDX]], [[A]]* [[T:%.*]])
+ // CHECK-NEXT: ret void
+ array[0] = t;
+ }
+}
+
+namespace test1 {
+ volatile int *x;
+
+ // CHECK: define void @_ZN5test14testEv()
+ void test() {
+ // CHECK: [[TMP:%.*]] = load i32** @_ZN5test11xE, align 8
+ // CHECK-NEXT: ret void
+ *x;
+ }
+}
diff --git a/clang/test/CodeGenCXX/vtable-available-externally.cpp b/clang/test/CodeGenCXX/vtable-available-externally.cpp
new file mode 100644
index 0000000..23baac9
--- /dev/null
+++ b/clang/test/CodeGenCXX/vtable-available-externally.cpp
@@ -0,0 +1,171 @@
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o %t
+// RUN: FileCheck --check-prefix=CHECK-TEST1 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-TEST2 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-TEST5 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-TEST7 %s < %t
+
+#include <typeinfo>
+
+// Test1::A's key function (f) is not defined in this translation unit, but in
+// order to devirtualize calls, we emit the class related data with
+// available_externally linkage.
+
+// CHECK-TEST1: @_ZTVN5Test11AE = available_externally
+// CHECK-TEST1: @_ZTSN5Test11AE = available_externally
+// CHECK-TEST1: @_ZTIN5Test11AE = available_externally
+namespace Test1 {
+
+struct A {
+ A();
+ virtual void f();
+ virtual ~A() { }
+};
+
+A::A() { }
+
+void f(A* a) {
+ a->f();
+};
+
+// CHECK: define void @_ZN5Test11gEv
+// CHECK: call void @_ZN5Test11A1fEv
+void g() {
+ A a;
+ f(&a);
+}
+
+}
+
+// Test2::A's key function (f) is defined in this translation unit, but when
+// we're doing codegen for the typeid(A) call, we don't know that yet.
+// This tests mainly that the typeinfo and typename constants have their linkage
+// updated correctly.
+
+// CHECK-TEST2: @_ZTSN5Test21AE = constant
+// CHECK-TEST2: @_ZTIN5Test21AE = unnamed_addr constant
+// CHECK-TEST2: @_ZTVN5Test21AE = unnamed_addr constant
+namespace Test2 {
+ struct A {
+ virtual void f();
+ };
+
+ const std::type_info &g() {
+ return typeid(A);
+ };
+
+ void A::f() { }
+}
+
+// Test that we don't assert on this test.
+namespace Test3 {
+
+struct A {
+ virtual void f();
+ virtual ~A() { }
+};
+
+struct B : A {
+ B();
+ virtual void f();
+};
+
+B::B() { }
+
+void g(A* a) {
+ a->f();
+};
+
+}
+
+// PR9114, test that we don't try to instantiate RefPtr<Node>.
+namespace Test4 {
+
+template <class T> struct RefPtr {
+ T* p;
+ ~RefPtr() {
+ p->deref();
+ }
+};
+
+struct A {
+ virtual ~A();
+};
+
+struct Node;
+
+struct B : A {
+ virtual void deref();
+ RefPtr<Node> m;
+};
+
+void f() {
+ RefPtr<B> b;
+}
+
+}
+
+// PR9130, test that we emit a definition of A::f.
+// CHECK-TEST5: define linkonce_odr void @_ZN5Test51A1fEv
+namespace Test5 {
+
+struct A {
+ virtual void f() { }
+};
+
+struct B : A {
+ virtual ~B();
+};
+
+B::~B() { }
+
+}
+
+// Check that we don't assert on this test.
+namespace Test6 {
+
+struct A {
+ virtual ~A();
+ int a;
+};
+
+struct B {
+ virtual ~B();
+ int b;
+};
+
+struct C : A, B {
+ C();
+};
+
+struct D : C {
+ virtual void f();
+ D();
+};
+
+D::D() { }
+
+}
+
+namespace Test7 {
+
+struct c1 {};
+struct c10 : c1{
+ virtual void foo ();
+};
+struct c11 : c10, c1{
+ virtual void f6 ();
+};
+struct c28 : virtual c11{
+ void f6 ();
+};
+
+// CHECK-TEST7: define void @_ZN5Test79check_c28Ev
+// CHECK-TEST7: call void @_ZN5Test73c282f6Ev
+// CHECK-TEST7: ret void
+void check_c28 () {
+ c28 obj;
+ c11 *ptr = &obj;
+ ptr->f6 ();
+}
+
+}
diff --git a/clang/test/CodeGenCXX/vtable-cast-crash.cpp b/clang/test/CodeGenCXX/vtable-cast-crash.cpp
new file mode 100644
index 0000000..cc419fd
--- /dev/null
+++ b/clang/test/CodeGenCXX/vtable-cast-crash.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+struct A
+{
+A();
+virtual ~A();
+};
+
+struct B: A
+{
+ B();
+ ~B();
+};
+
+B::B()
+{
+}
+
+B::~B()
+{
+}
+
diff --git a/clang/test/CodeGenCXX/vtable-debug-info.cpp b/clang/test/CodeGenCXX/vtable-debug-info.cpp
new file mode 100644
index 0000000..9294d20
--- /dev/null
+++ b/clang/test/CodeGenCXX/vtable-debug-info.cpp
@@ -0,0 +1,319 @@
+// RUN: %clang -c -g %s -o /dev/null
+// Radar 8730409
+// XFAIL: win32
+
+// FIXME: This test crashes on *-pc-win32
+// for lack of debugging support on -integrated-as (MCCOFF).
+#ifdef _MSC_VER
+
+#error this test must xfail
+
+#else
+class foo {
+public:
+#define x(a) virtual void v ## a (void)
+x(1);
+x(2);
+x(3);
+x(4);
+x(5);
+x(6);
+x(7);
+x(8);
+x(9);
+x(10);
+x(11);
+x(12);
+x(13);
+x(14);
+x(15);
+x(16);
+x(17);
+x(18);
+x(19);
+x(20);
+x(21);
+x(22);
+x(23);
+x(24);
+x(25);
+x(26);
+x(27);
+x(28);
+x(29);
+x(30);
+x(31);
+x(32);
+x(33);
+x(34);
+x(35);
+x(36);
+x(37);
+x(38);
+x(39);
+x(40);
+x(41);
+x(42);
+x(43);
+x(44);
+x(45);
+x(46);
+x(47);
+x(48);
+x(49);
+x(50);
+x(51);
+x(52);
+x(53);
+x(54);
+x(55);
+x(56);
+x(57);
+x(58);
+x(59);
+x(60);
+x(61);
+x(62);
+x(63);
+x(64);
+x(65);
+x(66);
+x(67);
+x(68);
+x(69);
+x(70);
+x(71);
+x(72);
+x(73);
+x(74);
+x(75);
+x(76);
+x(77);
+x(78);
+x(79);
+x(80);
+x(81);
+x(82);
+x(83);
+x(84);
+x(85);
+x(86);
+x(87);
+x(88);
+x(89);
+x(90);
+x(91);
+x(92);
+x(93);
+x(94);
+x(95);
+x(96);
+x(97);
+x(98);
+x(99);
+x(100);
+x(101);
+x(102);
+x(103);
+x(104);
+x(105);
+x(106);
+x(107);
+x(108);
+x(109);
+x(110);
+x(111);
+x(112);
+x(113);
+x(114);
+x(115);
+x(116);
+x(117);
+x(118);
+x(119);
+x(120);
+x(121);
+x(122);
+x(123);
+x(124);
+x(125);
+x(126);
+x(127);
+x(128);
+x(129);
+x(130);
+x(131);
+x(132);
+x(133);
+x(134);
+x(135);
+x(136);
+x(137);
+x(138);
+x(139);
+x(140);
+x(141);
+x(142);
+x(143);
+x(144);
+x(145);
+x(146);
+x(147);
+x(148);
+x(149);
+x(150);
+x(151);
+x(152);
+x(153);
+x(154);
+x(155);
+x(156);
+x(157);
+x(158);
+x(159);
+x(160);
+x(161);
+x(162);
+x(163);
+x(164);
+x(165);
+x(166);
+x(167);
+x(168);
+x(169);
+x(170);
+x(171);
+x(172);
+x(173);
+x(174);
+x(175);
+x(176);
+x(177);
+x(178);
+x(179);
+x(180);
+x(181);
+x(182);
+x(183);
+x(184);
+x(185);
+x(186);
+x(187);
+x(188);
+x(189);
+x(190);
+x(191);
+x(192);
+x(193);
+x(194);
+x(195);
+x(196);
+x(197);
+x(198);
+x(199);
+x(200);
+x(201);
+x(202);
+x(203);
+x(204);
+x(205);
+x(206);
+x(207);
+x(208);
+x(209);
+x(210);
+x(211);
+x(212);
+x(213);
+x(214);
+x(215);
+x(216);
+x(217);
+x(218);
+x(219);
+x(220);
+x(221);
+x(222);
+x(223);
+x(224);
+x(225);
+x(226);
+x(227);
+x(228);
+x(229);
+x(230);
+x(231);
+x(232);
+x(233);
+x(234);
+x(235);
+x(236);
+x(237);
+x(238);
+x(239);
+x(240);
+x(241);
+x(242);
+x(243);
+x(244);
+x(245);
+x(246);
+x(247);
+x(248);
+x(249);
+x(250);
+x(251);
+x(252);
+x(253);
+x(254);
+x(255);
+x(256);
+x(257);
+x(258);
+x(259);
+x(260);
+x(261);
+x(262);
+x(263);
+x(264);
+x(265);
+x(266);
+x(267);
+x(268);
+x(269);
+x(270);
+x(271);
+x(272);
+x(273);
+x(274);
+x(275);
+x(276);
+x(277);
+x(278);
+x(279);
+x(280);
+x(281);
+x(282);
+x(283);
+x(284);
+x(285);
+x(286);
+x(287);
+x(288);
+x(289);
+x(290);
+x(291);
+x(292);
+x(293);
+x(294);
+x(295);
+x(296);
+x(297);
+x(298);
+x(299);
+x(300);
+};
+
+foo b;
+
+#endif
diff --git a/clang/test/CodeGenCXX/vtable-key-function.cpp b/clang/test/CodeGenCXX/vtable-key-function.cpp
new file mode 100644
index 0000000..bf2e679
--- /dev/null
+++ b/clang/test/CodeGenCXX/vtable-key-function.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// PR5697
+namespace PR5697 {
+struct A {
+ virtual void f() { }
+ A();
+ A(int);
+};
+
+// A does not have a key function, so the first constructor we emit should
+// cause the vtable to be defined (without assertions.)
+// CHECK: @_ZTVN6PR56971AE = linkonce_odr unnamed_addr constant
+A::A() { }
+A::A(int) { }
+}
+
+// Make sure that we don't assert when building the vtable for a class
+// template specialization or explicit instantiation with a key
+// function.
+template<typename T>
+struct Base {
+ virtual ~Base();
+};
+
+template<typename T>
+struct Derived : public Base<T> { };
+
+template<>
+struct Derived<char> : public Base<char> {
+ virtual void anchor();
+};
+
+void Derived<char>::anchor() { }
diff --git a/clang/test/CodeGenCXX/vtable-layout-abi-examples.cpp b/clang/test/CodeGenCXX/vtable-layout-abi-examples.cpp
new file mode 100644
index 0000000..8f084a9
--- /dev/null
+++ b/clang/test/CodeGenCXX/vtable-layout-abi-examples.cpp
@@ -0,0 +1,322 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm-only -fdump-vtable-layouts > %t 2>&1
+// RUN: FileCheck --check-prefix=CHECK-1 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-2 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-3 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-4 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-5 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-6 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-7 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-8 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-9 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-10 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-11 %s < %t
+
+/// Examples from the Itanium C++ ABI specification.
+/// http://www.codesourcery.com/public/cxx-abi/
+
+namespace Test1 {
+
+// This is from http://www.codesourcery.com/public/cxx-abi/cxx-vtable-ex.html
+
+// CHECK-1: Vtable for 'Test1::A' (5 entries).
+// CHECK-1-NEXT: 0 | offset_to_top (0)
+// CHECK-1-NEXT: 1 | Test1::A RTTI
+// CHECK-1-NEXT: -- (Test1::A, 0) vtable address --
+// CHECK-1-NEXT: 2 | void Test1::A::f()
+// CHECK-1-NEXT: 3 | void Test1::A::g()
+// CHECK-1-NEXT: 4 | void Test1::A::h()
+struct A {
+ virtual void f ();
+ virtual void g ();
+ virtual void h ();
+ int ia;
+};
+void A::f() {}
+
+// CHECK-2: Vtable for 'Test1::B' (13 entries).
+// CHECK-2-NEXT: 0 | vbase_offset (16)
+// CHECK-2-NEXT: 1 | offset_to_top (0)
+// CHECK-2-NEXT: 2 | Test1::B RTTI
+// CHECK-2-NEXT: -- (Test1::B, 0) vtable address --
+// CHECK-2-NEXT: 3 | void Test1::B::f()
+// CHECK-2-NEXT: 4 | void Test1::B::h()
+// CHECK-2-NEXT: 5 | vcall_offset (-16)
+// CHECK-2-NEXT: 6 | vcall_offset (0)
+// CHECK-2-NEXT: 7 | vcall_offset (-16)
+// CHECK-2-NEXT: 8 | offset_to_top (-16)
+// CHECK-2-NEXT: 9 | Test1::B RTTI
+// CHECK-2-NEXT: -- (Test1::A, 16) vtable address --
+// CHECK-2-NEXT: 10 | void Test1::B::f()
+// CHECK-2-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+// CHECK-2-NEXT: 11 | void Test1::A::g()
+// CHECK-2-NEXT: 12 | void Test1::B::h()
+// CHECK-2-NEXT: [this adjustment: 0 non-virtual, -40 vcall offset offset]
+struct B: public virtual A {
+ void f ();
+ void h ();
+ int ib;
+};
+void B::f() {}
+
+// CHECK-3: Vtable for 'Test1::C' (13 entries).
+// CHECK-3-NEXT: 0 | vbase_offset (16)
+// CHECK-3-NEXT: 1 | offset_to_top (0)
+// CHECK-3-NEXT: 2 | Test1::C RTTI
+// CHECK-3-NEXT: -- (Test1::C, 0) vtable address --
+// CHECK-3-NEXT: 3 | void Test1::C::g()
+// CHECK-3-NEXT: 4 | void Test1::C::h()
+// CHECK-3-NEXT: 5 | vcall_offset (-16)
+// CHECK-3-NEXT: 6 | vcall_offset (-16)
+// CHECK-3-NEXT: 7 | vcall_offset (0)
+// CHECK-3-NEXT: 8 | offset_to_top (-16)
+// CHECK-3-NEXT: 9 | Test1::C RTTI
+// CHECK-3-NEXT: -- (Test1::A, 16) vtable address --
+// CHECK-3-NEXT: 10 | void Test1::A::f()
+// CHECK-3-NEXT: 11 | void Test1::C::g()
+// CHECK-3-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
+// CHECK-3-NEXT: 12 | void Test1::C::h()
+// CHECK-3-NEXT: [this adjustment: 0 non-virtual, -40 vcall offset offset]
+struct C: public virtual A {
+ void g ();
+ void h ();
+ int ic;
+};
+void C::g() {}
+
+// CHECK-4: Vtable for 'Test1::D' (18 entries).
+// CHECK-4-NEXT: 0 | vbase_offset (32)
+// CHECK-4-NEXT: 1 | offset_to_top (0)
+// CHECK-4-NEXT: 2 | Test1::D RTTI
+// CHECK-4-NEXT: -- (Test1::B, 0) vtable address --
+// CHECK-4-NEXT: -- (Test1::D, 0) vtable address --
+// CHECK-4-NEXT: 3 | void Test1::B::f()
+// CHECK-4-NEXT: 4 | void Test1::D::h()
+// CHECK-4-NEXT: 5 | vbase_offset (16)
+// CHECK-4-NEXT: 6 | offset_to_top (-16)
+// CHECK-4-NEXT: 7 | Test1::D RTTI
+// CHECK-4-NEXT: -- (Test1::C, 16) vtable address --
+// CHECK-4-NEXT: 8 | void Test1::C::g()
+// CHECK-4-NEXT: 9 | void Test1::D::h()
+// CHECK-4-NEXT: [this adjustment: -16 non-virtual]
+// CHECK-4-NEXT: 10 | vcall_offset (-32)
+// CHECK-4-NEXT: 11 | vcall_offset (-16)
+// CHECK-4-NEXT: 12 | vcall_offset (-32)
+// CHECK-4-NEXT: 13 | offset_to_top (-32)
+// CHECK-4-NEXT: 14 | Test1::D RTTI
+// CHECK-4-NEXT: -- (Test1::A, 32) vtable address --
+// CHECK-4-NEXT: 15 | void Test1::B::f()
+// CHECK-4-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+// CHECK-4-NEXT: 16 | void Test1::C::g()
+// CHECK-4-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
+// CHECK-4-NEXT: 17 | void Test1::D::h()
+// CHECK-4-NEXT: [this adjustment: 0 non-virtual, -40 vcall offset offset]
+struct D: public B, public C {
+ void h ();
+ int id;
+};
+void D::h() { }
+
+struct X {
+ int ix;
+ virtual void x();
+};
+
+// CHECK-5: Vtable for 'Test1::E' (24 entries).
+// CHECK-5-NEXT: 0 | vbase_offset (56)
+// CHECK-5-NEXT: 1 | offset_to_top (0)
+// CHECK-5-NEXT: 2 | Test1::E RTTI
+// CHECK-5-NEXT: -- (Test1::E, 0) vtable address --
+// CHECK-5-NEXT: -- (Test1::X, 0) vtable address --
+// CHECK-5-NEXT: 3 | void Test1::X::x()
+// CHECK-5-NEXT: 4 | void Test1::E::f()
+// CHECK-5-NEXT: 5 | void Test1::E::h()
+// CHECK-5-NEXT: 6 | vbase_offset (40)
+// CHECK-5-NEXT: 7 | offset_to_top (-16)
+// CHECK-5-NEXT: 8 | Test1::E RTTI
+// CHECK-5-NEXT: -- (Test1::B, 16) vtable address --
+// CHECK-5-NEXT: -- (Test1::D, 16) vtable address --
+// CHECK-5-NEXT: 9 | void Test1::E::f()
+// CHECK-5-NEXT: [this adjustment: -16 non-virtual]
+// CHECK-5-NEXT: 10 | void Test1::E::h()
+// CHECK-5-NEXT: [this adjustment: -16 non-virtual]
+// CHECK-5-NEXT: 11 | vbase_offset (24)
+// CHECK-5-NEXT: 12 | offset_to_top (-32)
+// CHECK-5-NEXT: 13 | Test1::E RTTI
+// CHECK-5-NEXT: -- (Test1::C, 32) vtable address --
+// CHECK-5-NEXT: 14 | void Test1::C::g()
+// CHECK-5-NEXT: 15 | void Test1::E::h()
+// CHECK-5-NEXT: [this adjustment: -32 non-virtual]
+// CHECK-5-NEXT: 16 | vcall_offset (-56)
+// CHECK-5-NEXT: 17 | vcall_offset (-24)
+// CHECK-5-NEXT: 18 | vcall_offset (-56)
+// CHECK-5-NEXT: 19 | offset_to_top (-56)
+// CHECK-5-NEXT: 20 | Test1::E RTTI
+// CHECK-5-NEXT: -- (Test1::A, 56) vtable address --
+// CHECK-5-NEXT: 21 | void Test1::E::f()
+// CHECK-5-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+// CHECK-5-NEXT: 22 | void Test1::C::g()
+// CHECK-5-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
+// CHECK-5-NEXT: 23 | void Test1::E::h()
+// CHECK-5-NEXT: [this adjustment: 0 non-virtual, -40 vcall offset offset]
+struct E : X, D {
+ int ie;
+ void f();
+ void h ();
+};
+void E::f() { }
+
+}
+
+namespace Test2 {
+
+// From http://www.codesourcery.com/public/cxx-abi/abi.html#class-types.
+
+struct A { virtual void f(); };
+struct B : virtual public A { int i; };
+struct C : virtual public A { int j; };
+
+// CHECK-6: Vtable for 'Test2::D' (11 entries).
+// CHECK-6-NEXT: 0 | vbase_offset (0)
+// CHECK-6-NEXT: 1 | vcall_offset (0)
+// CHECK-6-NEXT: 2 | offset_to_top (0)
+// CHECK-6-NEXT: 3 | Test2::D RTTI
+// CHECK-6-NEXT: -- (Test2::A, 0) vtable address --
+// CHECK-6-NEXT: -- (Test2::B, 0) vtable address --
+// CHECK-6-NEXT: -- (Test2::D, 0) vtable address --
+// CHECK-6-NEXT: 4 | void Test2::A::f()
+// CHECK-6-NEXT: 5 | void Test2::D::d()
+// CHECK-6-NEXT: 6 | vbase_offset (-16)
+// CHECK-6-NEXT: 7 | vcall_offset (-16)
+// CHECK-6-NEXT: 8 | offset_to_top (-16)
+// CHECK-6-NEXT: 9 | Test2::D RTTI
+// CHECK-6-NEXT: -- (Test2::C, 16) vtable address --
+// CHECK-6-NEXT: 10 | [unused] void Test2::A::f()
+struct D : public B, public C {
+ virtual void d();
+};
+void D::d() { }
+
+}
+
+namespace Test3 {
+
+// From http://www.codesourcery.com/public/cxx-abi/abi-examples.html#vtable-ctor
+
+struct V1 {
+ int v1;
+ virtual void f();
+};
+
+struct V2 : virtual V1 {
+ int v2;
+ virtual void f();
+};
+
+// CHECK-7: Vtable for 'Test3::C' (14 entries).
+// CHECK-7-NEXT: 0 | vbase_offset (32)
+// CHECK-7-NEXT: 1 | vbase_offset (16)
+// CHECK-7-NEXT: 2 | offset_to_top (0)
+// CHECK-7-NEXT: 3 | Test3::C RTTI
+// CHECK-7-NEXT: -- (Test3::C, 0) vtable address --
+// CHECK-7-NEXT: 4 | void Test3::C::f()
+// CHECK-7-NEXT: 5 | vcall_offset (-16)
+// CHECK-7-NEXT: 6 | offset_to_top (-16)
+// CHECK-7-NEXT: 7 | Test3::C RTTI
+// CHECK-7-NEXT: -- (Test3::V1, 16) vtable address --
+// CHECK-7-NEXT: 8 | void Test3::C::f()
+// CHECK-7-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+// CHECK-7-NEXT: 9 | vcall_offset (-32)
+// CHECK-7-NEXT: 10 | vbase_offset (-16)
+// CHECK-7-NEXT: 11 | offset_to_top (-32)
+// CHECK-7-NEXT: 12 | Test3::C RTTI
+// CHECK-7-NEXT: -- (Test3::V2, 32) vtable address --
+// CHECK-7-NEXT: 13 | void Test3::C::f()
+// CHECK-7-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
+
+// CHECK-8: Construction vtable for ('Test3::V2', 32) in 'Test3::C' (9 entries).
+// CHECK-8-NEXT: 0 | vcall_offset (0)
+// CHECK-8-NEXT: 1 | vbase_offset (-16)
+// CHECK-8-NEXT: 2 | offset_to_top (0)
+// CHECK-8-NEXT: 3 | Test3::V2 RTTI
+// CHECK-8-NEXT: -- (Test3::V2, 32) vtable address --
+// CHECK-8-NEXT: 4 | void Test3::V2::f()
+// CHECK-8-NEXT: 5 | vcall_offset (16)
+// CHECK-8-NEXT: 6 | offset_to_top (16)
+// CHECK-8-NEXT: 7 | Test3::V2 RTTI
+// CHECK-8-NEXT: -- (Test3::V1, 16) vtable address --
+// CHECK-8-NEXT: 8 | void Test3::V2::f()
+// CHECK-8-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+struct C : virtual V1, virtual V2 {
+ int c;
+ virtual void f();
+};
+void C::f() { }
+
+struct B {
+ int b;
+};
+
+// CHECK-9: Vtable for 'Test3::D' (15 entries).
+// CHECK-9-NEXT: 0 | vbase_offset (40)
+// CHECK-9-NEXT: 1 | vbase_offset (24)
+// CHECK-9-NEXT: 2 | offset_to_top (0)
+// CHECK-9-NEXT: 3 | Test3::D RTTI
+// CHECK-9-NEXT: -- (Test3::C, 0) vtable address --
+// CHECK-9-NEXT: -- (Test3::D, 0) vtable address --
+// CHECK-9-NEXT: 4 | void Test3::C::f()
+// CHECK-9-NEXT: 5 | void Test3::D::g()
+// CHECK-9-NEXT: 6 | vcall_offset (-24)
+// CHECK-9-NEXT: 7 | offset_to_top (-24)
+// CHECK-9-NEXT: 8 | Test3::D RTTI
+// CHECK-9-NEXT: -- (Test3::V1, 24) vtable address --
+// CHECK-9-NEXT: 9 | void Test3::C::f()
+// CHECK-9-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+// CHECK-9-NEXT: 10 | vcall_offset (-40)
+// CHECK-9-NEXT: 11 | vbase_offset (-16)
+// CHECK-9-NEXT: 12 | offset_to_top (-40)
+// CHECK-9-NEXT: 13 | Test3::D RTTI
+// CHECK-9-NEXT: -- (Test3::V2, 40) vtable address --
+// CHECK-9-NEXT: 14 | void Test3::C::f()
+// CHECK-9-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
+
+// CHECK-10: Construction vtable for ('Test3::C', 0) in 'Test3::D' (14 entries).
+// CHECK-10-NEXT: 0 | vbase_offset (40)
+// CHECK-10-NEXT: 1 | vbase_offset (24)
+// CHECK-10-NEXT: 2 | offset_to_top (0)
+// CHECK-10-NEXT: 3 | Test3::C RTTI
+// CHECK-10-NEXT: -- (Test3::C, 0) vtable address --
+// CHECK-10-NEXT: 4 | void Test3::C::f()
+// CHECK-10-NEXT: 5 | vcall_offset (-24)
+// CHECK-10-NEXT: 6 | offset_to_top (-24)
+// CHECK-10-NEXT: 7 | Test3::C RTTI
+// CHECK-10-NEXT: -- (Test3::V1, 24) vtable address --
+// CHECK-10-NEXT: 8 | void Test3::C::f()
+// CHECK-10-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+// CHECK-10-NEXT: 9 | vcall_offset (-40)
+// CHECK-10-NEXT: 10 | vbase_offset (-16)
+// CHECK-10-NEXT: 11 | offset_to_top (-40)
+// CHECK-10-NEXT: 12 | Test3::C RTTI
+// CHECK-10-NEXT: -- (Test3::V2, 40) vtable address --
+// CHECK-10-NEXT: 13 | void Test3::C::f()
+// CHECK-10-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
+
+// CHECK-11: Construction vtable for ('Test3::V2', 40) in 'Test3::D' (9 entries).
+// CHECK-11-NEXT: 0 | vcall_offset (0)
+// CHECK-11-NEXT: 1 | vbase_offset (-16)
+// CHECK-11-NEXT: 2 | offset_to_top (0)
+// CHECK-11-NEXT: 3 | Test3::V2 RTTI
+// CHECK-11-NEXT: -- (Test3::V2, 40) vtable address --
+// CHECK-11-NEXT: 4 | void Test3::V2::f()
+// CHECK-11-NEXT: 5 | vcall_offset (16)
+// CHECK-11-NEXT: 6 | offset_to_top (16)
+// CHECK-11-NEXT: 7 | Test3::V2 RTTI
+// CHECK-11-NEXT: -- (Test3::V1, 24) vtable address --
+// CHECK-11-NEXT: 8 | void Test3::V2::f()
+// CHECK-11-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+struct D : B, C {
+ int d;
+ virtual void g();
+};
+void D::g() { }
+
+}
diff --git a/clang/test/CodeGenCXX/vtable-layout-extreme.cpp b/clang/test/CodeGenCXX/vtable-layout-extreme.cpp
new file mode 100644
index 0000000..14e7879
--- /dev/null
+++ b/clang/test/CodeGenCXX/vtable-layout-extreme.cpp
@@ -0,0 +1,210 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm-only -fdump-vtable-layouts 2>&1 | FileCheck %s
+
+// A collection of big class hierarchies and their vtables.
+
+namespace Test1 {
+
+class C0
+{
+};
+class C1
+ : virtual public C0
+{
+ int k0;
+};
+class C2
+ : public C0
+ , virtual public C1
+{
+ int k0;
+};
+class C3
+ : virtual public C0
+ , virtual public C1
+ , public C2
+{
+ int k0;
+ int k1;
+ int k2;
+ int k3;
+};
+class C4
+ : public C2
+ , virtual public C3
+ , public C0
+{
+ int k0;
+};
+class C5
+ : public C0
+ , virtual public C4
+ , public C2
+ , public C1
+ , virtual public C3
+{
+ int k0;
+};
+class C6
+ : virtual public C3
+ , public C0
+ , public C5
+ , public C4
+ , public C1
+{
+ int k0;
+};
+class C7
+ : virtual public C5
+ , virtual public C6
+ , virtual public C3
+ , public C4
+ , virtual public C2
+{
+ int k0;
+ int k1;
+};
+class C8
+ : public C7
+ , public C5
+ , public C3
+ , virtual public C4
+ , public C1
+ , public C2
+{
+ int k0;
+ int k1;
+};
+
+// CHECK: Vtable for 'Test1::C9' (87 entries).
+// CHECK-NEXT: 0 | vbase_offset (344)
+// CHECK-NEXT: 1 | vbase_offset (312)
+// CHECK-NEXT: 2 | vbase_offset (184)
+// CHECK-NEXT: 3 | vbase_offset (168)
+// CHECK-NEXT: 4 | vbase_offset (120)
+// CHECK-NEXT: 5 | vbase_offset (48)
+// CHECK-NEXT: 6 | vbase_offset (148)
+// CHECK-NEXT: 7 | vbase_offset (152)
+// CHECK-NEXT: 8 | offset_to_top (0)
+// CHECK-NEXT: 9 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C2, 0) vtable address --
+// CHECK-NEXT: -- (Test1::C9, 0) vtable address --
+// CHECK-NEXT: 10 | void Test1::C9::f()
+// CHECK-NEXT: 11 | vbase_offset (104)
+// CHECK-NEXT: 12 | vbase_offset (132)
+// CHECK-NEXT: 13 | vbase_offset (136)
+// CHECK-NEXT: 14 | offset_to_top (-16)
+// CHECK-NEXT: 15 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C2, 16) vtable address --
+// CHECK-NEXT: -- (Test1::C4, 16) vtable address --
+// CHECK-NEXT: 16 | vbase_offset (72)
+// CHECK-NEXT: 17 | vbase_offset (120)
+// CHECK-NEXT: 18 | vbase_offset (100)
+// CHECK-NEXT: 19 | vbase_offset (104)
+// CHECK-NEXT: 20 | offset_to_top (-48)
+// CHECK-NEXT: 21 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C2, 48) vtable address --
+// CHECK-NEXT: -- (Test1::C5, 48) vtable address --
+// CHECK-NEXT: -- (Test1::C6, 48) vtable address --
+// CHECK-NEXT: 22 | vbase_offset (84)
+// CHECK-NEXT: 23 | offset_to_top (-64)
+// CHECK-NEXT: 24 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C1, 64) vtable address --
+// CHECK-NEXT: 25 | vbase_offset (32)
+// CHECK-NEXT: 26 | vbase_offset (60)
+// CHECK-NEXT: 27 | vbase_offset (64)
+// CHECK-NEXT: 28 | offset_to_top (-88)
+// CHECK-NEXT: 29 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C2, 88) vtable address --
+// CHECK-NEXT: -- (Test1::C4, 88) vtable address --
+// CHECK-NEXT: 30 | vbase_offset (44)
+// CHECK-NEXT: 31 | offset_to_top (-104)
+// CHECK-NEXT: 32 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C1, 104) vtable address --
+// CHECK-NEXT: 33 | vbase_offset (28)
+// CHECK-NEXT: 34 | vbase_offset (32)
+// CHECK-NEXT: 35 | offset_to_top (-120)
+// CHECK-NEXT: 36 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C2, 120) vtable address --
+// CHECK-NEXT: -- (Test1::C3, 120) vtable address --
+// CHECK-NEXT: 37 | vbase_offset (-4)
+// CHECK-NEXT: 38 | offset_to_top (-152)
+// CHECK-NEXT: 39 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C1, 152) vtable address --
+// CHECK-NEXT: 40 | vbase_offset (-48)
+// CHECK-NEXT: 41 | vbase_offset (-20)
+// CHECK-NEXT: 42 | vbase_offset (-16)
+// CHECK-NEXT: 43 | offset_to_top (-168)
+// CHECK-NEXT: 44 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C2, 168) vtable address --
+// CHECK-NEXT: -- (Test1::C4, 168) vtable address --
+// CHECK-NEXT: 45 | vbase_offset (160)
+// CHECK-NEXT: 46 | vbase_offset (-136)
+// CHECK-NEXT: 47 | vbase_offset (-16)
+// CHECK-NEXT: 48 | vbase_offset (128)
+// CHECK-NEXT: 49 | vbase_offset (-64)
+// CHECK-NEXT: 50 | vbase_offset (-36)
+// CHECK-NEXT: 51 | vbase_offset (-32)
+// CHECK-NEXT: 52 | offset_to_top (-184)
+// CHECK-NEXT: 53 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C2, 184) vtable address --
+// CHECK-NEXT: -- (Test1::C4, 184) vtable address --
+// CHECK-NEXT: -- (Test1::C7, 184) vtable address --
+// CHECK-NEXT: -- (Test1::C8, 184) vtable address --
+// CHECK-NEXT: 54 | vbase_offset (-88)
+// CHECK-NEXT: 55 | vbase_offset (-40)
+// CHECK-NEXT: 56 | vbase_offset (-60)
+// CHECK-NEXT: 57 | vbase_offset (-56)
+// CHECK-NEXT: 58 | offset_to_top (-208)
+// CHECK-NEXT: 59 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C2, 208) vtable address --
+// CHECK-NEXT: -- (Test1::C5, 208) vtable address --
+// CHECK-NEXT: 60 | vbase_offset (-76)
+// CHECK-NEXT: 61 | offset_to_top (-224)
+// CHECK-NEXT: 62 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C1, 224) vtable address --
+// CHECK-NEXT: 63 | vbase_offset (-92)
+// CHECK-NEXT: 64 | vbase_offset (-88)
+// CHECK-NEXT: 65 | offset_to_top (-240)
+// CHECK-NEXT: 66 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C2, 240) vtable address --
+// CHECK-NEXT: -- (Test1::C3, 240) vtable address --
+// CHECK-NEXT: 67 | vbase_offset (-124)
+// CHECK-NEXT: 68 | offset_to_top (-272)
+// CHECK-NEXT: 69 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C1, 272) vtable address --
+// CHECK-NEXT: 70 | vbase_offset (-140)
+// CHECK-NEXT: 71 | vbase_offset (-136)
+// CHECK-NEXT: 72 | offset_to_top (-288)
+// CHECK-NEXT: 73 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C2, 288) vtable address --
+// CHECK-NEXT: 74 | vbase_offset (-192)
+// CHECK-NEXT: 75 | vbase_offset (-144)
+// CHECK-NEXT: 76 | vbase_offset (-164)
+// CHECK-NEXT: 77 | vbase_offset (-160)
+// CHECK-NEXT: 78 | offset_to_top (-312)
+// CHECK-NEXT: 79 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C2, 312) vtable address --
+// CHECK-NEXT: -- (Test1::C5, 312) vtable address --
+// CHECK-NEXT: 80 | vbase_offset (-180)
+// CHECK-NEXT: 81 | offset_to_top (-328)
+// CHECK-NEXT: 82 | Test1::C9 RTTI
+// CHECK-NEXT: -- (Test1::C1, 328) vtable address --
+// CHECK-NEXT: 83 | vbase_offset (-196)
+// CHECK-NEXT: 84 | vbase_offset (-192)
+// CHECK-NEXT: 85 | offset_to_top (-344)
+// CHECK-NEXT: 86 | Test1::C9 RTTI
+class C9
+ : virtual public C6
+ , public C2
+ , public C4
+ , virtual public C8
+{
+ int k0;
+ int k1;
+ int k2;
+ int k3;
+ virtual void f();
+};
+void C9::f() { }
+
+}
diff --git a/clang/test/CodeGenCXX/vtable-layout.cpp b/clang/test/CodeGenCXX/vtable-layout.cpp
new file mode 100644
index 0000000..d7644b9
--- /dev/null
+++ b/clang/test/CodeGenCXX/vtable-layout.cpp
@@ -0,0 +1,1729 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm-only -fdump-vtable-layouts > %t 2>&1
+// RUN: FileCheck --check-prefix=CHECK-1 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-2 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-3 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-4 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-5 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-6 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-7 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-8 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-9 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-10 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-11 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-12 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-13 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-14 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-15 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-16 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-17 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-18 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-19 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-20 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-21 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-22 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-23 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-24 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-25 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-26 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-27 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-28 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-29 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-30 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-31 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-32 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-33 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-34 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-35 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-36 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-37 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-38 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-39 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-40 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-41 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-42 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-43 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-44 %s < %t
+
+// For now, just verify this doesn't crash.
+namespace test0 {
+ struct Obj {};
+
+ struct Base { virtual const Obj *foo() = 0; };
+ struct Derived : Base { virtual Obj *foo() { return new Obj(); } };
+
+ void test(Derived *D) { D->foo(); }
+}
+
+namespace Test1 {
+// CHECK-1: Vtable for 'Test1::A' (3 entries).
+// CHECK-1-NEXT: 0 | offset_to_top (0)
+// CHECK-1-NEXT: 1 | Test1::A RTTI
+// CHECK-1-NEXT: -- (Test1::A, 0) vtable address --
+// CHECK-1-NEXT: 2 | void Test1::A::f()
+struct A {
+ virtual void f();
+};
+void A::f() { }
+
+}
+
+namespace Test2 {
+
+// This is a smoke test of the vtable dumper.
+// CHECK-2: Vtable for 'Test2::A' (9 entries).
+// CHECK-2-NEXT: 0 | offset_to_top (0)
+// CHECK-2-NEXT: 1 | Test2::A RTTI
+// CHECK-2-NEXT: -- (Test2::A, 0) vtable address --
+// CHECK-2-NEXT: 2 | void Test2::A::f()
+// CHECK-2-NEXT: 3 | void Test2::A::f() const
+// CHECK-2-NEXT: 4 | Test2::A *Test2::A::g(int)
+// CHECK-2-NEXT: 5 | Test2::A::~A() [complete]
+// CHECK-2-NEXT: 6 | Test2::A::~A() [deleting]
+// CHECK-2-NEXT: 7 | void Test2::A::h()
+// CHECK-2-NEXT: 8 | Test2::A &Test2::A::operator=(const Test2::A &)
+struct A {
+ virtual void f();
+ virtual void f() const;
+
+ virtual A* g(int a);
+ virtual ~A();
+ virtual void h();
+ virtual A& operator=(const A&);
+};
+void A::f() { }
+
+// Another simple vtable dumper test.
+
+// CHECK-3: Vtable for 'Test2::B' (6 entries).
+// CHECK-3-NEXT: 0 | offset_to_top (0)
+// CHECK-3-NEXT: 1 | Test2::B RTTI
+// CHECK-3-NEXT: -- (Test2::B, 0) vtable address --
+// CHECK-3-NEXT: 2 | void Test2::B::f()
+// CHECK-3-NEXT: 3 | void Test2::B::g() [pure]
+// CHECK-3-NEXT: 4 | Test2::B::~B() [complete] [pure]
+// CHECK-3-NEXT: 5 | Test2::B::~B() [deleting] [pure]
+struct B {
+ virtual void f();
+ virtual void g() = 0;
+ virtual ~B() = 0;
+};
+void B::f() { }
+
+}
+
+namespace Test3 {
+
+// If a function in a derived class overrides a function in a primary base,
+// then the function should not have an entry in the derived class (unless the return
+// value requires adjusting).
+
+// CHECK-4: Vtable for 'Test3::A' (3 entries).
+// CHECK-4-NEXT: 0 | offset_to_top (0)
+// CHECK-4-NEXT: 1 | Test3::A RTTI
+// CHECK-4-NEXT: -- (Test3::A, 0) vtable address --
+// CHECK-4-NEXT: 2 | void Test3::A::f()
+struct A {
+ virtual void f();
+};
+void A::f() { }
+
+// CHECK-5: Vtable for 'Test3::B' (4 entries).
+// CHECK-5-NEXT: 0 | offset_to_top (0)
+// CHECK-5-NEXT: 1 | Test3::B RTTI
+// CHECK-5-NEXT: -- (Test3::A, 0) vtable address --
+// CHECK-5-NEXT: -- (Test3::B, 0) vtable address --
+// CHECK-5-NEXT: 2 | void Test3::B::f()
+// CHECK-5-NEXT: 3 | void Test3::B::g()
+struct B : A {
+ virtual void f();
+ virtual void g();
+};
+void B::f() { }
+
+// CHECK-6: Vtable for 'Test3::C' (5 entries).
+// CHECK-6-NEXT: 0 | offset_to_top (0)
+// CHECK-6-NEXT: 1 | Test3::C RTTI
+// CHECK-6-NEXT: -- (Test3::A, 0) vtable address --
+// CHECK-6-NEXT: -- (Test3::C, 0) vtable address --
+// CHECK-6-NEXT: 2 | void Test3::A::f()
+// CHECK-6-NEXT: 3 | void Test3::C::g()
+// CHECK-6-NEXT: 4 | void Test3::C::h()
+struct C : A {
+ virtual void g();
+ virtual void h();
+};
+void C::g() { }
+
+// CHECK-7: Vtable for 'Test3::D' (5 entries).
+// CHECK-7-NEXT: 0 | offset_to_top (0)
+// CHECK-7-NEXT: 1 | Test3::D RTTI
+// CHECK-7-NEXT: -- (Test3::A, 0) vtable address --
+// CHECK-7-NEXT: -- (Test3::B, 0) vtable address --
+// CHECK-7-NEXT: -- (Test3::D, 0) vtable address --
+// CHECK-7-NEXT: 2 | void Test3::D::f()
+// CHECK-7-NEXT: 3 | void Test3::D::g()
+// CHECK-7-NEXT: 4 | void Test3::D::h()
+struct D : B {
+ virtual void f();
+ virtual void g();
+ virtual void h();
+};
+
+void D::f() { }
+}
+
+namespace Test4 {
+
+// Test non-virtual result adjustments.
+
+struct R1 { int r1; };
+struct R2 { int r2; };
+struct R3 : R1, R2 { int r3; };
+
+struct A {
+ virtual R2 *f();
+};
+
+// CHECK-8: Vtable for 'Test4::B' (4 entries).
+// CHECK-8-NEXT: 0 | offset_to_top (0)
+// CHECK-8-NEXT: 1 | Test4::B RTTI
+// CHECK-8-NEXT: -- (Test4::A, 0) vtable address --
+// CHECK-8-NEXT: -- (Test4::B, 0) vtable address --
+// CHECK-8-NEXT: 2 | Test4::R3 *Test4::B::f()
+// CHECK-8-NEXT: [return adjustment: 4 non-virtual]
+// CHECK-8-NEXT: 3 | Test4::R3 *Test4::B::f()
+
+struct B : A {
+ virtual R3 *f();
+};
+R3 *B::f() { return 0; }
+
+// Test virtual result adjustments.
+struct V1 { int v1; };
+struct V2 : virtual V1 { int v1; };
+
+struct C {
+ virtual V1 *f();
+};
+
+// CHECK-9: Vtable for 'Test4::D' (4 entries).
+// CHECK-9-NEXT: 0 | offset_to_top (0)
+// CHECK-9-NEXT: 1 | Test4::D RTTI
+// CHECK-9-NEXT: -- (Test4::C, 0) vtable address --
+// CHECK-9-NEXT: -- (Test4::D, 0) vtable address --
+// CHECK-9-NEXT: 2 | Test4::V2 *Test4::D::f()
+// CHECK-9-NEXT: [return adjustment: 0 non-virtual, -24 vbase offset offset]
+// CHECK-9-NEXT: 3 | Test4::V2 *Test4::D::f()
+struct D : C {
+ virtual V2 *f();
+};
+V2 *D::f() { return 0; };
+
+// Virtual result adjustments with an additional non-virtual adjustment.
+struct V3 : virtual R3 { int r3; };
+
+// CHECK-10: Vtable for 'Test4::E' (4 entries).
+// CHECK-10-NEXT: 0 | offset_to_top (0)
+// CHECK-10-NEXT: 1 | Test4::E RTTI
+// CHECK-10-NEXT: -- (Test4::A, 0) vtable address --
+// CHECK-10-NEXT: -- (Test4::E, 0) vtable address --
+// CHECK-10-NEXT: 2 | Test4::V3 *Test4::E::f()
+// CHECK-10-NEXT: [return adjustment: 4 non-virtual, -24 vbase offset offset]
+// CHECK-10-NEXT: 3 | Test4::V3 *Test4::E::f()
+
+struct E : A {
+ virtual V3 *f();
+};
+V3 *E::f() { return 0;}
+
+// Test that a pure virtual member doesn't get a thunk.
+
+// CHECK-11: Vtable for 'Test4::F' (5 entries).
+// CHECK-11-NEXT: 0 | offset_to_top (0)
+// CHECK-11-NEXT: 1 | Test4::F RTTI
+// CHECK-11-NEXT: -- (Test4::A, 0) vtable address --
+// CHECK-11-NEXT: -- (Test4::F, 0) vtable address --
+// CHECK-11-NEXT: 2 | Test4::R3 *Test4::F::f() [pure]
+// CHECK-11-NEXT: 3 | void Test4::F::g()
+// CHECK-11-NEXT: 4 | Test4::R3 *Test4::F::f() [pure]
+struct F : A {
+ virtual void g();
+ virtual R3 *f() = 0;
+};
+void F::g() { }
+
+}
+
+namespace Test5 {
+
+// Simple secondary vtables without 'this' pointer adjustments.
+struct A {
+ virtual void f();
+ virtual void g();
+ int a;
+};
+
+struct B1 : A {
+ virtual void f();
+ int b1;
+};
+
+struct B2 : A {
+ virtual void g();
+ int b2;
+};
+
+// CHECK-12: Vtable for 'Test5::C' (9 entries).
+// CHECK-12-NEXT: 0 | offset_to_top (0)
+// CHECK-12-NEXT: 1 | Test5::C RTTI
+// CHECK-12-NEXT: -- (Test5::A, 0) vtable address --
+// CHECK-12-NEXT: -- (Test5::B1, 0) vtable address --
+// CHECK-12-NEXT: -- (Test5::C, 0) vtable address --
+// CHECK-12-NEXT: 2 | void Test5::B1::f()
+// CHECK-12-NEXT: 3 | void Test5::A::g()
+// CHECK-12-NEXT: 4 | void Test5::C::h()
+// CHECK-12-NEXT: 5 | offset_to_top (-16)
+// CHECK-12-NEXT: 6 | Test5::C RTTI
+// CHECK-12-NEXT: -- (Test5::A, 16) vtable address --
+// CHECK-12-NEXT: -- (Test5::B2, 16) vtable address --
+// CHECK-12-NEXT: 7 | void Test5::A::f()
+// CHECK-12-NEXT: 8 | void Test5::B2::g()
+struct C : B1, B2 {
+ virtual void h();
+};
+void C::h() { }
+}
+
+namespace Test6 {
+
+// Simple non-virtual 'this' pointer adjustments.
+struct A1 {
+ virtual void f();
+ int a;
+};
+
+struct A2 {
+ virtual void f();
+ int a;
+};
+
+// CHECK-13: Vtable for 'Test6::C' (6 entries).
+// CHECK-13-NEXT: 0 | offset_to_top (0)
+// CHECK-13-NEXT: 1 | Test6::C RTTI
+// CHECK-13-NEXT: -- (Test6::A1, 0) vtable address --
+// CHECK-13-NEXT: -- (Test6::C, 0) vtable address --
+// CHECK-13-NEXT: 2 | void Test6::C::f()
+// CHECK-13-NEXT: 3 | offset_to_top (-16)
+// CHECK-13-NEXT: 4 | Test6::C RTTI
+// CHECK-13-NEXT: -- (Test6::A2, 16) vtable address --
+// CHECK-13-NEXT: 5 | void Test6::C::f()
+// CHECK-13-NEXT: [this adjustment: -16 non-virtual]
+struct C : A1, A2 {
+ virtual void f();
+};
+void C::f() { }
+
+}
+
+namespace Test7 {
+
+// Test that the D::f overrider for A::f have different 'this' pointer
+// adjustments in the two A base subobjects.
+
+struct A {
+ virtual void f();
+ int a;
+};
+
+struct B1 : A { };
+struct B2 : A { };
+
+struct C { virtual void c(); };
+
+// CHECK-14: Vtable for 'Test7::D' (10 entries).
+// CHECK-14-NEXT: 0 | offset_to_top (0)
+// CHECK-14-NEXT: 1 | Test7::D RTTI
+// CHECK-14-NEXT: -- (Test7::C, 0) vtable address --
+// CHECK-14-NEXT: -- (Test7::D, 0) vtable address --
+// CHECK-14-NEXT: 2 | void Test7::C::c()
+// CHECK-14-NEXT: 3 | void Test7::D::f()
+// CHECK-14-NEXT: 4 | offset_to_top (-8)
+// CHECK-14-NEXT: 5 | Test7::D RTTI
+// CHECK-14-NEXT: -- (Test7::A, 8) vtable address --
+// CHECK-14-NEXT: -- (Test7::B1, 8) vtable address --
+// CHECK-14-NEXT: 6 | void Test7::D::f()
+// CHECK-14-NEXT: [this adjustment: -8 non-virtual]
+// CHECK-14-NEXT: 7 | offset_to_top (-24)
+// CHECK-14-NEXT: 8 | Test7::D RTTI
+// CHECK-14-NEXT: -- (Test7::A, 24) vtable address --
+// CHECK-14-NEXT: -- (Test7::B2, 24) vtable address --
+// CHECK-14-NEXT: 9 | void Test7::D::f()
+// CHECK-14-NEXT: [this adjustment: -24 non-virtual]
+struct D : C, B1, B2 {
+ virtual void f();
+};
+void D::f() { }
+
+}
+
+namespace Test8 {
+
+// Test that we don't try to layout vtables for classes that don't have
+// virtual bases or virtual member functions.
+
+struct A { };
+
+// CHECK-15: Vtable for 'Test8::B' (3 entries).
+// CHECK-15-NEXT: 0 | offset_to_top (0)
+// CHECK-15-NEXT: 1 | Test8::B RTTI
+// CHECK-15-NEXT: -- (Test8::B, 0) vtable address --
+// CHECK-15-NEXT: 2 | void Test8::B::f()
+struct B : A {
+ virtual void f();
+};
+void B::f() { }
+
+}
+
+namespace Test9 {
+
+// Simple test of vbase offsets.
+
+struct A1 { int a1; };
+struct A2 { int a2; };
+
+// CHECK-16: Vtable for 'Test9::B' (5 entries).
+// CHECK-16-NEXT: 0 | vbase_offset (16)
+// CHECK-16-NEXT: 1 | vbase_offset (12)
+// CHECK-16-NEXT: 2 | offset_to_top (0)
+// CHECK-16-NEXT: 3 | Test9::B RTTI
+// CHECK-16-NEXT: -- (Test9::B, 0) vtable address --
+// CHECK-16-NEXT: 4 | void Test9::B::f()
+struct B : virtual A1, virtual A2 {
+ int b;
+
+ virtual void f();
+};
+
+
+void B::f() { }
+
+}
+
+namespace Test10 {
+
+// Test for a bug where we would not emit secondary vtables for bases
+// of a primary base.
+struct A1 { virtual void a1(); };
+struct A2 { virtual void a2(); };
+
+// CHECK-17: Vtable for 'Test10::C' (7 entries).
+// CHECK-17-NEXT: 0 | offset_to_top (0)
+// CHECK-17-NEXT: 1 | Test10::C RTTI
+// CHECK-17-NEXT: -- (Test10::A1, 0) vtable address --
+// CHECK-17-NEXT: -- (Test10::B, 0) vtable address --
+// CHECK-17-NEXT: -- (Test10::C, 0) vtable address --
+// CHECK-17-NEXT: 2 | void Test10::A1::a1()
+// CHECK-17-NEXT: 3 | void Test10::C::f()
+// CHECK-17-NEXT: 4 | offset_to_top (-8)
+// CHECK-17-NEXT: 5 | Test10::C RTTI
+// CHECK-17-NEXT: -- (Test10::A2, 8) vtable address --
+// CHECK-17-NEXT: 6 | void Test10::A2::a2()
+struct B : A1, A2 {
+ int b;
+};
+
+struct C : B {
+ virtual void f();
+};
+void C::f() { }
+
+}
+
+namespace Test11 {
+
+// Very simple test of vtables for virtual bases.
+struct A1 { int a; };
+struct A2 { int b; };
+
+struct B : A1, virtual A2 {
+ int b;
+};
+
+// CHECK-18: Vtable for 'Test11::C' (8 entries).
+// CHECK-18-NEXT: 0 | vbase_offset (24)
+// CHECK-18-NEXT: 1 | vbase_offset (8)
+// CHECK-18-NEXT: 2 | offset_to_top (0)
+// CHECK-18-NEXT: 3 | Test11::C RTTI
+// CHECK-18-NEXT: -- (Test11::C, 0) vtable address --
+// CHECK-18-NEXT: 4 | void Test11::C::f()
+// CHECK-18-NEXT: 5 | vbase_offset (16)
+// CHECK-18-NEXT: 6 | offset_to_top (-8)
+// CHECK-18-NEXT: 7 | Test11::C RTTI
+struct C : virtual B {
+ virtual void f();
+};
+void C::f() { }
+
+}
+
+namespace Test12 {
+
+// Test that the right vcall offsets are generated in the right order.
+
+// CHECK-19: Vtable for 'Test12::B' (19 entries).
+// CHECK-19-NEXT: 0 | vbase_offset (8)
+// CHECK-19-NEXT: 1 | offset_to_top (0)
+// CHECK-19-NEXT: 2 | Test12::B RTTI
+// CHECK-19-NEXT: -- (Test12::B, 0) vtable address --
+// CHECK-19-NEXT: 3 | void Test12::B::f()
+// CHECK-19-NEXT: 4 | void Test12::B::a()
+// CHECK-19-NEXT: 5 | vcall_offset (32)
+// CHECK-19-NEXT: 6 | vcall_offset (16)
+// CHECK-19-NEXT: 7 | vcall_offset (-8)
+// CHECK-19-NEXT: 8 | vcall_offset (0)
+// CHECK-19-NEXT: 9 | offset_to_top (-8)
+// CHECK-19-NEXT: 10 | Test12::B RTTI
+// CHECK-19-NEXT: -- (Test12::A, 8) vtable address --
+// CHECK-19-NEXT: -- (Test12::A1, 8) vtable address --
+// CHECK-19-NEXT: 11 | void Test12::A1::a1()
+// CHECK-19-NEXT: 12 | void Test12::B::a()
+// CHECK-19-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
+// CHECK-19-NEXT: 13 | offset_to_top (-24)
+// CHECK-19-NEXT: 14 | Test12::B RTTI
+// CHECK-19-NEXT: -- (Test12::A2, 24) vtable address --
+// CHECK-19-NEXT: 15 | void Test12::A2::a2()
+// CHECK-19-NEXT: 16 | offset_to_top (-40)
+// CHECK-19-NEXT: 17 | Test12::B RTTI
+// CHECK-19-NEXT: -- (Test12::A3, 40) vtable address --
+// CHECK-19-NEXT: 18 | void Test12::A3::a3()
+struct A1 {
+ virtual void a1();
+ int a;
+};
+
+struct A2 {
+ virtual void a2();
+ int a;
+};
+
+struct A3 {
+ virtual void a3();
+ int a;
+};
+
+struct A : A1, A2, A3 {
+ virtual void a();
+ int i;
+};
+
+struct B : virtual A {
+ virtual void f();
+
+ virtual void a();
+};
+void B::f() { }
+
+}
+
+namespace Test13 {
+
+// Test that we don't try to emit a vtable for 'A' twice.
+struct A {
+ virtual void f();
+};
+
+struct B : virtual A {
+ virtual void f();
+};
+
+// CHECK-20: Vtable for 'Test13::C' (6 entries).
+// CHECK-20-NEXT: 0 | vbase_offset (0)
+// CHECK-20-NEXT: 1 | vbase_offset (0)
+// CHECK-20-NEXT: 2 | vcall_offset (0)
+// CHECK-20-NEXT: 3 | offset_to_top (0)
+// CHECK-20-NEXT: 4 | Test13::C RTTI
+// CHECK-20-NEXT: -- (Test13::A, 0) vtable address --
+// CHECK-20-NEXT: -- (Test13::B, 0) vtable address --
+// CHECK-20-NEXT: -- (Test13::C, 0) vtable address --
+// CHECK-20-NEXT: 5 | void Test13::C::f()
+struct C : virtual B, virtual A {
+ virtual void f();
+};
+void C::f() { }
+
+}
+
+namespace Test14 {
+
+// Verify that we handle A being a non-virtual base of B, which is a virtual base.
+
+struct A {
+ virtual void f();
+};
+
+struct B : A { };
+
+struct C : virtual B { };
+
+// CHECK-21: Vtable for 'Test14::D' (5 entries).
+// CHECK-21-NEXT: 0 | vbase_offset (0)
+// CHECK-21-NEXT: 1 | vcall_offset (0)
+// CHECK-21-NEXT: 2 | offset_to_top (0)
+// CHECK-21-NEXT: 3 | Test14::D RTTI
+// CHECK-21-NEXT: -- (Test14::A, 0) vtable address --
+// CHECK-21-NEXT: -- (Test14::B, 0) vtable address --
+// CHECK-21-NEXT: -- (Test14::C, 0) vtable address --
+// CHECK-21-NEXT: -- (Test14::D, 0) vtable address --
+// CHECK-21-NEXT: 4 | void Test14::D::f()
+struct D : C, virtual B {
+ virtual void f();
+};
+void D::f() { }
+
+}
+
+namespace Test15 {
+
+// Test that we don't emit an extra vtable for B since it's a primary base of C.
+struct A { virtual void a(); };
+struct B { virtual void b(); };
+
+struct C : virtual B { };
+
+// CHECK-22: Vtable for 'Test15::D' (11 entries).
+// CHECK-22-NEXT: 0 | vbase_offset (8)
+// CHECK-22-NEXT: 1 | vbase_offset (8)
+// CHECK-22-NEXT: 2 | offset_to_top (0)
+// CHECK-22-NEXT: 3 | Test15::D RTTI
+// CHECK-22-NEXT: -- (Test15::A, 0) vtable address --
+// CHECK-22-NEXT: -- (Test15::D, 0) vtable address --
+// CHECK-22-NEXT: 4 | void Test15::A::a()
+// CHECK-22-NEXT: 5 | void Test15::D::f()
+// CHECK-22-NEXT: 6 | vbase_offset (0)
+// CHECK-22-NEXT: 7 | vcall_offset (0)
+// CHECK-22-NEXT: 8 | offset_to_top (-8)
+// CHECK-22-NEXT: 9 | Test15::D RTTI
+// CHECK-22-NEXT: -- (Test15::B, 8) vtable address --
+// CHECK-22-NEXT: -- (Test15::C, 8) vtable address --
+// CHECK-22-NEXT: 10 | void Test15::B::b()
+struct D : A, virtual B, virtual C {
+ virtual void f();
+};
+void D::f() { }
+
+}
+
+namespace Test16 {
+
+// Test that destructors share vcall offsets.
+
+struct A { virtual ~A(); };
+struct B { virtual ~B(); };
+
+struct C : A, B { virtual ~C(); };
+
+// CHECK-23: Vtable for 'Test16::D' (15 entries).
+// CHECK-23-NEXT: 0 | vbase_offset (8)
+// CHECK-23-NEXT: 1 | offset_to_top (0)
+// CHECK-23-NEXT: 2 | Test16::D RTTI
+// CHECK-23-NEXT: -- (Test16::D, 0) vtable address --
+// CHECK-23-NEXT: 3 | void Test16::D::f()
+// CHECK-23-NEXT: 4 | Test16::D::~D() [complete]
+// CHECK-23-NEXT: 5 | Test16::D::~D() [deleting]
+// CHECK-23-NEXT: 6 | vcall_offset (-8)
+// CHECK-23-NEXT: 7 | offset_to_top (-8)
+// CHECK-23-NEXT: 8 | Test16::D RTTI
+// CHECK-23-NEXT: -- (Test16::A, 8) vtable address --
+// CHECK-23-NEXT: -- (Test16::C, 8) vtable address --
+// CHECK-23-NEXT: 9 | Test16::D::~D() [complete]
+// CHECK-23-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+// CHECK-23-NEXT: 10 | Test16::D::~D() [deleting]
+// CHECK-23-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+// CHECK-23-NEXT: 11 | offset_to_top (-16)
+// CHECK-23-NEXT: 12 | Test16::D RTTI
+// CHECK-23-NEXT: -- (Test16::B, 16) vtable address --
+// CHECK-23-NEXT: 13 | Test16::D::~D() [complete]
+// CHECK-23-NEXT: [this adjustment: -8 non-virtual, -24 vcall offset offset]
+// CHECK-23-NEXT: 14 | Test16::D::~D() [deleting]
+// CHECK-23-NEXT: [this adjustment: -8 non-virtual, -24 vcall offset offset]
+struct D : virtual C {
+ virtual void f();
+};
+void D::f() { }
+
+}
+
+namespace Test17 {
+
+// Test that we don't mark E::f in the C-in-E vtable as unused.
+struct A { virtual void f(); };
+struct B : virtual A { virtual void f(); };
+struct C : virtual A { virtual void f(); };
+struct D : virtual B, virtual C { virtual void f(); };
+
+// CHECK-24: Vtable for 'Test17::E' (13 entries).
+// CHECK-24-NEXT: 0 | vbase_offset (0)
+// CHECK-24-NEXT: 1 | vbase_offset (8)
+// CHECK-24-NEXT: 2 | vbase_offset (0)
+// CHECK-24-NEXT: 3 | vbase_offset (0)
+// CHECK-24-NEXT: 4 | vcall_offset (0)
+// CHECK-24-NEXT: 5 | offset_to_top (0)
+// CHECK-24-NEXT: 6 | Test17::E RTTI
+// CHECK-24-NEXT: -- (Test17::A, 0) vtable address --
+// CHECK-24-NEXT: -- (Test17::B, 0) vtable address --
+// CHECK-24-NEXT: -- (Test17::D, 0) vtable address --
+// CHECK-24-NEXT: -- (Test17::E, 0) vtable address --
+// CHECK-24-NEXT: 7 | void Test17::E::f()
+// CHECK-24-NEXT: 8 | vbase_offset (-8)
+// CHECK-24-NEXT: 9 | vcall_offset (-8)
+// CHECK-24-NEXT: 10 | offset_to_top (-8)
+// CHECK-24-NEXT: 11 | Test17::E RTTI
+// CHECK-24-NEXT: -- (Test17::C, 8) vtable address --
+// CHECK-24-NEXT: 12 | void Test17::E::f()
+// CHECK-24-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+class E : virtual D {
+ virtual void f();
+};
+void E::f() {}
+
+}
+
+namespace Test18 {
+
+// Test that we compute the right 'this' adjustment offsets.
+
+struct A {
+ virtual void f();
+ virtual void g();
+};
+
+struct B : virtual A {
+ virtual void f();
+};
+
+struct C : A, B {
+ virtual void g();
+};
+
+// CHECK-25: Vtable for 'Test18::D' (24 entries).
+// CHECK-25-NEXT: 0 | vbase_offset (8)
+// CHECK-25-NEXT: 1 | vbase_offset (0)
+// CHECK-25-NEXT: 2 | vbase_offset (0)
+// CHECK-25-NEXT: 3 | vcall_offset (8)
+// CHECK-25-NEXT: 4 | vcall_offset (0)
+// CHECK-25-NEXT: 5 | offset_to_top (0)
+// CHECK-25-NEXT: 6 | Test18::D RTTI
+// CHECK-25-NEXT: -- (Test18::A, 0) vtable address --
+// CHECK-25-NEXT: -- (Test18::B, 0) vtable address --
+// CHECK-25-NEXT: -- (Test18::D, 0) vtable address --
+// CHECK-25-NEXT: 7 | void Test18::D::f()
+// CHECK-25-NEXT: 8 | void Test18::C::g()
+// CHECK-25-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
+// CHECK-25-NEXT: 9 | void Test18::D::h()
+// CHECK-25-NEXT: 10 | vcall_offset (0)
+// CHECK-25-NEXT: 11 | vcall_offset (-8)
+// CHECK-25-NEXT: 12 | vbase_offset (-8)
+// CHECK-25-NEXT: 13 | offset_to_top (-8)
+// CHECK-25-NEXT: 14 | Test18::D RTTI
+// CHECK-25-NEXT: -- (Test18::A, 8) vtable address --
+// CHECK-25-NEXT: -- (Test18::C, 8) vtable address --
+// CHECK-25-NEXT: 15 | void Test18::D::f()
+// CHECK-25-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
+// CHECK-25-NEXT: 16 | void Test18::C::g()
+// CHECK-25-NEXT: 17 | vbase_offset (-16)
+// CHECK-25-NEXT: 18 | vcall_offset (-8)
+// CHECK-25-NEXT: 19 | vcall_offset (-16)
+// CHECK-25-NEXT: 20 | offset_to_top (-16)
+// CHECK-25-NEXT: 21 | Test18::D RTTI
+// CHECK-25-NEXT: -- (Test18::B, 16) vtable address --
+// CHECK-25-NEXT: 22 | void Test18::D::f()
+// CHECK-25-NEXT: [this adjustment: -8 non-virtual, -32 vcall offset offset]
+// CHECK-25-NEXT: 23 | [unused] void Test18::C::g()
+
+// CHECK-25: Construction vtable for ('Test18::B', 0) in 'Test18::D' (7 entries).
+// CHECK-25-NEXT: 0 | vbase_offset (0)
+// CHECK-25-NEXT: 1 | vcall_offset (0)
+// CHECK-25-NEXT: 2 | vcall_offset (0)
+// CHECK-25-NEXT: 3 | offset_to_top (0)
+// CHECK-25-NEXT: 4 | Test18::B RTTI
+// CHECK-25-NEXT: -- (Test18::A, 0) vtable address --
+// CHECK-25-NEXT: -- (Test18::B, 0) vtable address --
+// CHECK-25-NEXT: 5 | void Test18::B::f()
+// CHECK-25-NEXT: 6 | void Test18::A::g()
+
+// CHECK-25: Construction vtable for ('Test18::C', 8) in 'Test18::D' (20 entries).
+// CHECK-25-NEXT: 0 | vcall_offset (0)
+// CHECK-25-NEXT: 1 | vcall_offset (0)
+// CHECK-25-NEXT: 2 | vbase_offset (-8)
+// CHECK-25-NEXT: 3 | offset_to_top (0)
+// CHECK-25-NEXT: 4 | Test18::C RTTI
+// CHECK-25-NEXT: -- (Test18::A, 8) vtable address --
+// CHECK-25-NEXT: -- (Test18::C, 8) vtable address --
+// CHECK-25-NEXT: 5 | void Test18::A::f()
+// CHECK-25-NEXT: 6 | void Test18::C::g()
+// CHECK-25-NEXT: 7 | vbase_offset (-16)
+// CHECK-25-NEXT: 8 | vcall_offset (-8)
+// CHECK-25-NEXT: 9 | vcall_offset (0)
+// CHECK-25-NEXT: 10 | offset_to_top (-8)
+// CHECK-25-NEXT: 11 | Test18::C RTTI
+// CHECK-25-NEXT: -- (Test18::B, 16) vtable address --
+// CHECK-25-NEXT: 12 | void Test18::B::f()
+// CHECK-25-NEXT: 13 | [unused] void Test18::C::g()
+// CHECK-25-NEXT: 14 | vcall_offset (8)
+// CHECK-25-NEXT: 15 | vcall_offset (16)
+// CHECK-25-NEXT: 16 | offset_to_top (8)
+// CHECK-25-NEXT: 17 | Test18::C RTTI
+// CHECK-25-NEXT: -- (Test18::A, 0) vtable address --
+// CHECK-25-NEXT: 18 | void Test18::B::f()
+// CHECK-25-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+// CHECK-25-NEXT: 19 | void Test18::C::g()
+// CHECK-25-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
+
+// CHECK-25: Construction vtable for ('Test18::B', 16) in 'Test18::D' (13 entries).
+// CHECK-25-NEXT: 0 | vbase_offset (-16)
+// CHECK-25-NEXT: 1 | vcall_offset (-16)
+// CHECK-25-NEXT: 2 | vcall_offset (0)
+// CHECK-25-NEXT: 3 | offset_to_top (0)
+// CHECK-25-NEXT: 4 | Test18::B RTTI
+// CHECK-25-NEXT: -- (Test18::B, 16) vtable address --
+// CHECK-25-NEXT: 5 | void Test18::B::f()
+// CHECK-25-NEXT: 6 | [unused] void Test18::A::g()
+// CHECK-25-NEXT: 7 | vcall_offset (0)
+// CHECK-25-NEXT: 8 | vcall_offset (16)
+// CHECK-25-NEXT: 9 | offset_to_top (16)
+// CHECK-25-NEXT: 10 | Test18::B RTTI
+// CHECK-25-NEXT: -- (Test18::A, 0) vtable address --
+// CHECK-25-NEXT: 11 | void Test18::B::f()
+// CHECK-25-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+// CHECK-25-NEXT: 12 | void Test18::A::g()
+struct D : virtual B, virtual C, virtual A
+{
+ virtual void f();
+ virtual void h();
+};
+void D::f() {}
+
+}
+
+namespace Test19 {
+
+// Another 'this' adjustment test.
+
+struct A {
+ int a;
+
+ virtual void f();
+};
+
+struct B : A {
+ int b;
+
+ virtual void g();
+};
+
+struct C {
+ virtual void c();
+};
+
+// CHECK-26: Vtable for 'Test19::D' (13 entries).
+// CHECK-26-NEXT: 0 | vbase_offset (24)
+// CHECK-26-NEXT: 1 | offset_to_top (0)
+// CHECK-26-NEXT: 2 | Test19::D RTTI
+// CHECK-26-NEXT: -- (Test19::C, 0) vtable address --
+// CHECK-26-NEXT: -- (Test19::D, 0) vtable address --
+// CHECK-26-NEXT: 3 | void Test19::C::c()
+// CHECK-26-NEXT: 4 | void Test19::D::f()
+// CHECK-26-NEXT: 5 | offset_to_top (-8)
+// CHECK-26-NEXT: 6 | Test19::D RTTI
+// CHECK-26-NEXT: -- (Test19::A, 8) vtable address --
+// CHECK-26-NEXT: -- (Test19::B, 8) vtable address --
+// CHECK-26-NEXT: 7 | void Test19::D::f()
+// CHECK-26-NEXT: [this adjustment: -8 non-virtual]
+// CHECK-26-NEXT: 8 | void Test19::B::g()
+// CHECK-26-NEXT: 9 | vcall_offset (-24)
+// CHECK-26-NEXT: 10 | offset_to_top (-24)
+// CHECK-26-NEXT: 11 | Test19::D RTTI
+// CHECK-26-NEXT: -- (Test19::A, 24) vtable address --
+// CHECK-26-NEXT: 12 | void Test19::D::f()
+// CHECK-26-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+struct D : C, B, virtual A {
+ virtual void f();
+};
+void D::f() { }
+
+}
+
+namespace Test20 {
+
+// pure virtual member functions should never have 'this' adjustments.
+
+struct A {
+ virtual void f() = 0;
+ virtual void g();
+};
+
+struct B : A { };
+
+// CHECK-27: Vtable for 'Test20::C' (9 entries).
+// CHECK-27-NEXT: 0 | offset_to_top (0)
+// CHECK-27-NEXT: 1 | Test20::C RTTI
+// CHECK-27-NEXT: -- (Test20::A, 0) vtable address --
+// CHECK-27-NEXT: -- (Test20::C, 0) vtable address --
+// CHECK-27-NEXT: 2 | void Test20::C::f() [pure]
+// CHECK-27-NEXT: 3 | void Test20::A::g()
+// CHECK-27-NEXT: 4 | void Test20::C::h()
+// CHECK-27-NEXT: 5 | offset_to_top (-8)
+// CHECK-27-NEXT: 6 | Test20::C RTTI
+// CHECK-27-NEXT: -- (Test20::A, 8) vtable address --
+// CHECK-27-NEXT: -- (Test20::B, 8) vtable address --
+// CHECK-27-NEXT: 7 | void Test20::C::f() [pure]
+// CHECK-27-NEXT: 8 | void Test20::A::g()
+struct C : A, B {
+ virtual void f() = 0;
+ virtual void h();
+};
+void C::h() { }
+
+}
+
+namespace Test21 {
+
+// Test that we get vbase offsets right in secondary vtables.
+struct A {
+ virtual void f();
+};
+
+struct B : virtual A { };
+class C : virtual B { };
+class D : virtual C { };
+
+class E : virtual C { };
+
+// CHECK-28: Vtable for 'Test21::F' (16 entries).
+// CHECK-28-NEXT: 0 | vbase_offset (8)
+// CHECK-28-NEXT: 1 | vbase_offset (0)
+// CHECK-28-NEXT: 2 | vbase_offset (0)
+// CHECK-28-NEXT: 3 | vbase_offset (0)
+// CHECK-28-NEXT: 4 | vbase_offset (0)
+// CHECK-28-NEXT: 5 | vcall_offset (0)
+// CHECK-28-NEXT: 6 | offset_to_top (0)
+// CHECK-28-NEXT: 7 | Test21::F RTTI
+// CHECK-28-NEXT: -- (Test21::A, 0) vtable address --
+// CHECK-28-NEXT: -- (Test21::B, 0) vtable address --
+// CHECK-28-NEXT: -- (Test21::C, 0) vtable address --
+// CHECK-28-NEXT: -- (Test21::D, 0) vtable address --
+// CHECK-28-NEXT: -- (Test21::F, 0) vtable address --
+// CHECK-28-NEXT: 8 | void Test21::F::f()
+// CHECK-28-NEXT: 9 | vbase_offset (-8)
+// CHECK-28-NEXT: 10 | vbase_offset (-8)
+// CHECK-28-NEXT: 11 | vbase_offset (-8)
+// CHECK-28-NEXT: 12 | vcall_offset (-8)
+// CHECK-28-NEXT: 13 | offset_to_top (-8)
+// CHECK-28-NEXT: 14 | Test21::F RTTI
+// CHECK-28-NEXT: -- (Test21::E, 8) vtable address --
+// CHECK-28-NEXT: 15 | [unused] void Test21::F::f()
+//
+// CHECK-28: Virtual base offset offsets for 'Test21::F' (5 entries).
+// CHECK-28-NEXT: Test21::A | -32
+// CHECK-28-NEXT: Test21::B | -40
+// CHECK-28-NEXT: Test21::C | -48
+// CHECK-28-NEXT: Test21::D | -56
+// CHECK-28-NEXT: Test21::E | -64
+class F : virtual D, virtual E {
+ virtual void f();
+};
+void F::f() { }
+
+}
+
+namespace Test22 {
+
+// Very simple construction vtable test.
+struct V1 {
+ int v1;
+};
+
+struct V2 : virtual V1 {
+ int v2;
+};
+
+// CHECK-29: Vtable for 'Test22::C' (8 entries).
+// CHECK-29-NEXT: 0 | vbase_offset (16)
+// CHECK-29-NEXT: 1 | vbase_offset (12)
+// CHECK-29-NEXT: 2 | offset_to_top (0)
+// CHECK-29-NEXT: 3 | Test22::C RTTI
+// CHECK-29-NEXT: -- (Test22::C, 0) vtable address --
+// CHECK-29-NEXT: 4 | void Test22::C::f()
+// CHECK-29-NEXT: 5 | vbase_offset (-4)
+// CHECK-29-NEXT: 6 | offset_to_top (-16)
+// CHECK-29-NEXT: 7 | Test22::C RTTI
+// CHECK-29-NEXT: -- (Test22::V2, 16) vtable address --
+
+// CHECK-29: Construction vtable for ('Test22::V2', 16) in 'Test22::C' (3 entries).
+// CHECK-29-NEXT: 0 | vbase_offset (-4)
+// CHECK-29-NEXT: 1 | offset_to_top (0)
+// CHECK-29-NEXT: 2 | Test22::V2 RTTI
+
+struct C : virtual V1, virtual V2 {
+ int c;
+ virtual void f();
+};
+void C::f() { }
+
+}
+
+namespace Test23 {
+
+struct A {
+ int a;
+};
+
+struct B : virtual A {
+ int b;
+};
+
+struct C : A, virtual B {
+ int c;
+};
+
+// CHECK-30: Vtable for 'Test23::D' (7 entries).
+// CHECK-30-NEXT: 0 | vbase_offset (20)
+// CHECK-30-NEXT: 1 | vbase_offset (24)
+// CHECK-30-NEXT: 2 | offset_to_top (0)
+// CHECK-30-NEXT: 3 | Test23::D RTTI
+// CHECK-30-NEXT: -- (Test23::C, 0) vtable address --
+// CHECK-30-NEXT: -- (Test23::D, 0) vtable address --
+// CHECK-30-NEXT: 4 | vbase_offset (-4)
+// CHECK-30-NEXT: 5 | offset_to_top (-24)
+// CHECK-30-NEXT: 6 | Test23::D RTTI
+// CHECK-30-NEXT: -- (Test23::B, 24) vtable address --
+
+// CHECK-30: Construction vtable for ('Test23::C', 0) in 'Test23::D' (7 entries).
+// CHECK-30-NEXT: 0 | vbase_offset (20)
+// CHECK-30-NEXT: 1 | vbase_offset (24)
+// CHECK-30-NEXT: 2 | offset_to_top (0)
+// CHECK-30-NEXT: 3 | Test23::C RTTI
+// CHECK-30-NEXT: -- (Test23::C, 0) vtable address --
+// CHECK-30-NEXT: 4 | vbase_offset (-4)
+// CHECK-30-NEXT: 5 | offset_to_top (-24)
+// CHECK-30-NEXT: 6 | Test23::C RTTI
+// CHECK-30-NEXT: -- (Test23::B, 24) vtable address --
+
+// CHECK-30: Construction vtable for ('Test23::B', 24) in 'Test23::D' (3 entries).
+// CHECK-30-NEXT: 0 | vbase_offset (-4)
+// CHECK-30-NEXT: 1 | offset_to_top (0)
+// CHECK-30-NEXT: 2 | Test23::B RTTI
+// CHECK-30-NEXT: -- (Test23::B, 24) vtable address --
+
+struct D : virtual A, virtual B, C {
+ int d;
+
+ void f();
+};
+void D::f() { }
+ D d;
+}
+
+namespace Test24 {
+
+// Another construction vtable test.
+
+struct A {
+ virtual void f();
+};
+
+struct B : virtual A { };
+struct C : virtual A { };
+
+// CHECK-31: Vtable for 'Test24::D' (10 entries).
+// CHECK-31-NEXT: 0 | vbase_offset (0)
+// CHECK-31-NEXT: 1 | vcall_offset (0)
+// CHECK-31-NEXT: 2 | offset_to_top (0)
+// CHECK-31-NEXT: 3 | Test24::D RTTI
+// CHECK-31-NEXT: -- (Test24::A, 0) vtable address --
+// CHECK-31-NEXT: -- (Test24::B, 0) vtable address --
+// CHECK-31-NEXT: -- (Test24::D, 0) vtable address --
+// CHECK-31-NEXT: 4 | void Test24::D::f()
+// CHECK-31-NEXT: 5 | vbase_offset (-8)
+// CHECK-31-NEXT: 6 | vcall_offset (-8)
+// CHECK-31-NEXT: 7 | offset_to_top (-8)
+// CHECK-31-NEXT: 8 | Test24::D RTTI
+// CHECK-31-NEXT: -- (Test24::C, 8) vtable address --
+// CHECK-31-NEXT: 9 | [unused] void Test24::D::f()
+
+// CHECK-31: Construction vtable for ('Test24::B', 0) in 'Test24::D' (5 entries).
+// CHECK-31-NEXT: 0 | vbase_offset (0)
+// CHECK-31-NEXT: 1 | vcall_offset (0)
+// CHECK-31-NEXT: 2 | offset_to_top (0)
+// CHECK-31-NEXT: 3 | Test24::B RTTI
+// CHECK-31-NEXT: -- (Test24::A, 0) vtable address --
+// CHECK-31-NEXT: -- (Test24::B, 0) vtable address --
+// CHECK-31-NEXT: 4 | void Test24::A::f()
+
+// CHECK-31: Construction vtable for ('Test24::C', 8) in 'Test24::D' (9 entries).
+// CHECK-31-NEXT: 0 | vbase_offset (-8)
+// CHECK-31-NEXT: 1 | vcall_offset (-8)
+// CHECK-31-NEXT: 2 | offset_to_top (0)
+// CHECK-31-NEXT: 3 | Test24::C RTTI
+// CHECK-31-NEXT: -- (Test24::C, 8) vtable address --
+// CHECK-31-NEXT: 4 | [unused] void Test24::A::f()
+// CHECK-31-NEXT: 5 | vcall_offset (0)
+// CHECK-31-NEXT: 6 | offset_to_top (8)
+// CHECK-31-NEXT: 7 | Test24::C RTTI
+// CHECK-31-NEXT: -- (Test24::A, 0) vtable address --
+// CHECK-31-NEXT: 8 | void Test24::A::f()
+struct D : B, C {
+ virtual void f();
+};
+void D::f() { }
+
+}
+
+namespace Test25 {
+
+// This mainly tests that we don't assert on this class hierarchy.
+
+struct V {
+ virtual void f();
+};
+
+struct A : virtual V { };
+struct B : virtual V { };
+
+// CHECK-32: Vtable for 'Test25::C' (11 entries).
+// CHECK-32-NEXT: 0 | vbase_offset (0)
+// CHECK-32-NEXT: 1 | vcall_offset (0)
+// CHECK-32-NEXT: 2 | offset_to_top (0)
+// CHECK-32-NEXT: 3 | Test25::C RTTI
+// CHECK-32-NEXT: -- (Test25::A, 0) vtable address --
+// CHECK-32-NEXT: -- (Test25::C, 0) vtable address --
+// CHECK-32-NEXT: -- (Test25::V, 0) vtable address --
+// CHECK-32-NEXT: 4 | void Test25::V::f()
+// CHECK-32-NEXT: 5 | void Test25::C::g()
+// CHECK-32-NEXT: 6 | vbase_offset (-8)
+// CHECK-32-NEXT: 7 | vcall_offset (-8)
+// CHECK-32-NEXT: 8 | offset_to_top (-8)
+// CHECK-32-NEXT: 9 | Test25::C RTTI
+// CHECK-32-NEXT: -- (Test25::B, 8) vtable address --
+// CHECK-32-NEXT: 10 | [unused] void Test25::V::f()
+
+// CHECK-32: Construction vtable for ('Test25::A', 0) in 'Test25::C' (5 entries).
+// CHECK-32-NEXT: 0 | vbase_offset (0)
+// CHECK-32-NEXT: 1 | vcall_offset (0)
+// CHECK-32-NEXT: 2 | offset_to_top (0)
+// CHECK-32-NEXT: 3 | Test25::A RTTI
+// CHECK-32-NEXT: -- (Test25::A, 0) vtable address --
+// CHECK-32-NEXT: -- (Test25::V, 0) vtable address --
+// CHECK-32-NEXT: 4 | void Test25::V::f()
+
+// CHECK-32: Construction vtable for ('Test25::B', 8) in 'Test25::C' (9 entries).
+// CHECK-32-NEXT: 0 | vbase_offset (-8)
+// CHECK-32-NEXT: 1 | vcall_offset (-8)
+// CHECK-32-NEXT: 2 | offset_to_top (0)
+// CHECK-32-NEXT: 3 | Test25::B RTTI
+// CHECK-32-NEXT: -- (Test25::B, 8) vtable address --
+// CHECK-32-NEXT: 4 | [unused] void Test25::V::f()
+// CHECK-32-NEXT: 5 | vcall_offset (0)
+// CHECK-32-NEXT: 6 | offset_to_top (8)
+// CHECK-32-NEXT: 7 | Test25::B RTTI
+// CHECK-32-NEXT: -- (Test25::V, 0) vtable address --
+// CHECK-32-NEXT: 8 | void Test25::V::f()
+struct C : A, virtual V, B {
+ virtual void g();
+};
+void C::g() { }
+
+}
+
+namespace Test26 {
+
+// Test that we generate the right number of entries in the C-in-D construction vtable, and that
+// we don't mark A::a as unused.
+
+struct A {
+ virtual void a();
+};
+
+struct B {
+ virtual void c();
+};
+
+struct C : virtual A {
+ virtual void b();
+};
+
+// CHECK-33: Vtable for 'Test26::D' (15 entries).
+// CHECK-33-NEXT: 0 | vbase_offset (8)
+// CHECK-33-NEXT: 1 | vbase_offset (8)
+// CHECK-33-NEXT: 2 | vbase_offset (0)
+// CHECK-33-NEXT: 3 | vcall_offset (0)
+// CHECK-33-NEXT: 4 | offset_to_top (0)
+// CHECK-33-NEXT: 5 | Test26::D RTTI
+// CHECK-33-NEXT: -- (Test26::B, 0) vtable address --
+// CHECK-33-NEXT: -- (Test26::D, 0) vtable address --
+// CHECK-33-NEXT: 6 | void Test26::B::c()
+// CHECK-33-NEXT: 7 | void Test26::D::d()
+// CHECK-33-NEXT: 8 | vcall_offset (0)
+// CHECK-33-NEXT: 9 | vbase_offset (0)
+// CHECK-33-NEXT: 10 | vcall_offset (0)
+// CHECK-33-NEXT: 11 | offset_to_top (-8)
+// CHECK-33-NEXT: 12 | Test26::D RTTI
+// CHECK-33-NEXT: -- (Test26::A, 8) vtable address --
+// CHECK-33-NEXT: -- (Test26::C, 8) vtable address --
+// CHECK-33-NEXT: 13 | void Test26::A::a()
+// CHECK-33-NEXT: 14 | void Test26::C::b()
+
+// CHECK-33: Construction vtable for ('Test26::C', 8) in 'Test26::D' (7 entries).
+// CHECK-33-NEXT: 0 | vcall_offset (0)
+// CHECK-33-NEXT: 1 | vbase_offset (0)
+// CHECK-33-NEXT: 2 | vcall_offset (0)
+// CHECK-33-NEXT: 3 | offset_to_top (0)
+// CHECK-33-NEXT: 4 | Test26::C RTTI
+// CHECK-33-NEXT: -- (Test26::A, 8) vtable address --
+// CHECK-33-NEXT: -- (Test26::C, 8) vtable address --
+// CHECK-33-NEXT: 5 | void Test26::A::a()
+// CHECK-33-NEXT: 6 | void Test26::C::b()
+class D : virtual B, virtual C {
+ virtual void d();
+};
+void D::d() { }
+
+}
+
+namespace Test27 {
+
+// Test that we don't generate a secondary vtable for C in the D-in-E vtable, since
+// C doesn't have any virtual bases.
+
+struct A {
+ virtual void a();
+};
+
+struct B {
+ virtual void b();
+};
+
+struct C {
+ virtual void c();
+};
+
+struct D : A, virtual B, C {
+ virtual void d();
+};
+
+// CHECK-34: Vtable for 'Test27::E' (13 entries).
+// CHECK-34-NEXT: 0 | vbase_offset (16)
+// CHECK-34-NEXT: 1 | offset_to_top (0)
+// CHECK-34-NEXT: 2 | Test27::E RTTI
+// CHECK-34-NEXT: -- (Test27::A, 0) vtable address --
+// CHECK-34-NEXT: -- (Test27::D, 0) vtable address --
+// CHECK-34-NEXT: -- (Test27::E, 0) vtable address --
+// CHECK-34-NEXT: 3 | void Test27::A::a()
+// CHECK-34-NEXT: 4 | void Test27::D::d()
+// CHECK-34-NEXT: 5 | void Test27::E::e()
+// CHECK-34-NEXT: 6 | offset_to_top (-8)
+// CHECK-34-NEXT: 7 | Test27::E RTTI
+// CHECK-34-NEXT: -- (Test27::C, 8) vtable address --
+// CHECK-34-NEXT: 8 | void Test27::C::c()
+// CHECK-34-NEXT: 9 | vcall_offset (0)
+// CHECK-34-NEXT: 10 | offset_to_top (-16)
+// CHECK-34-NEXT: 11 | Test27::E RTTI
+// CHECK-34-NEXT: -- (Test27::B, 16) vtable address --
+// CHECK-34-NEXT: 12 | void Test27::B::b()
+
+// CHECK-34: Construction vtable for ('Test27::D', 0) in 'Test27::E' (9 entries).
+// CHECK-34-NEXT: 0 | vbase_offset (16)
+// CHECK-34-NEXT: 1 | offset_to_top (0)
+// CHECK-34-NEXT: 2 | Test27::D RTTI
+// CHECK-34-NEXT: -- (Test27::A, 0) vtable address --
+// CHECK-34-NEXT: -- (Test27::D, 0) vtable address --
+// CHECK-34-NEXT: 3 | void Test27::A::a()
+// CHECK-34-NEXT: 4 | void Test27::D::d()
+// CHECK-34-NEXT: 5 | vcall_offset (0)
+// CHECK-34-NEXT: 6 | offset_to_top (-16)
+// CHECK-34-NEXT: 7 | Test27::D RTTI
+// CHECK-34-NEXT: -- (Test27::B, 16) vtable address --
+// CHECK-34-NEXT: 8 | void Test27::B::b()
+struct E : D {
+ virtual void e();
+};
+void E::e() { }
+
+}
+
+namespace Test28 {
+
+// Check that we do include the vtable for B in the D-in-E construction vtable, since
+// B is a base class of a virtual base (C).
+
+struct A {
+ virtual void a();
+};
+
+struct B {
+ virtual void b();
+};
+
+struct C : A, B {
+ virtual void c();
+};
+
+struct D : virtual C {
+};
+
+// CHECK-35: Vtable for 'Test28::E' (14 entries).
+// CHECK-35-NEXT: 0 | vbase_offset (8)
+// CHECK-35-NEXT: 1 | offset_to_top (0)
+// CHECK-35-NEXT: 2 | Test28::E RTTI
+// CHECK-35-NEXT: -- (Test28::D, 0) vtable address --
+// CHECK-35-NEXT: -- (Test28::E, 0) vtable address --
+// CHECK-35-NEXT: 3 | void Test28::E::e()
+// CHECK-35-NEXT: 4 | vcall_offset (8)
+// CHECK-35-NEXT: 5 | vcall_offset (0)
+// CHECK-35-NEXT: 6 | vcall_offset (0)
+// CHECK-35-NEXT: 7 | offset_to_top (-8)
+// CHECK-35-NEXT: 8 | Test28::E RTTI
+// CHECK-35-NEXT: -- (Test28::A, 8) vtable address --
+// CHECK-35-NEXT: -- (Test28::C, 8) vtable address --
+// CHECK-35-NEXT: 9 | void Test28::A::a()
+// CHECK-35-NEXT: 10 | void Test28::C::c()
+// CHECK-35-NEXT: 11 | offset_to_top (-16)
+// CHECK-35-NEXT: 12 | Test28::E RTTI
+// CHECK-35-NEXT: -- (Test28::B, 16) vtable address --
+// CHECK-35-NEXT: 13 | void Test28::B::b()
+
+// CHECK-35: Construction vtable for ('Test28::D', 0) in 'Test28::E' (13 entries).
+// CHECK-35-NEXT: 0 | vbase_offset (8)
+// CHECK-35-NEXT: 1 | offset_to_top (0)
+// CHECK-35-NEXT: 2 | Test28::D RTTI
+// CHECK-35-NEXT: -- (Test28::D, 0) vtable address --
+// CHECK-35-NEXT: 3 | vcall_offset (8)
+// CHECK-35-NEXT: 4 | vcall_offset (0)
+// CHECK-35-NEXT: 5 | vcall_offset (0)
+// CHECK-35-NEXT: 6 | offset_to_top (-8)
+// CHECK-35-NEXT: 7 | Test28::D RTTI
+// CHECK-35-NEXT: -- (Test28::A, 8) vtable address --
+// CHECK-35-NEXT: -- (Test28::C, 8) vtable address --
+// CHECK-35-NEXT: 8 | void Test28::A::a()
+// CHECK-35-NEXT: 9 | void Test28::C::c()
+// CHECK-35-NEXT: 10 | offset_to_top (-16)
+// CHECK-35-NEXT: 11 | Test28::D RTTI
+// CHECK-35-NEXT: -- (Test28::B, 16) vtable address --
+// CHECK-35-NEXT: 12 | void Test28::B::b()
+struct E : D {
+ virtual void e();
+};
+void E::e() { }
+
+}
+
+namespace Test29 {
+
+// Test that the covariant return thunk for B::f will have a virtual 'this' adjustment,
+// matching gcc.
+
+struct V1 { };
+struct V2 : virtual V1 { };
+
+struct A {
+ virtual V1 *f();
+};
+
+// CHECK-36: Vtable for 'Test29::B' (6 entries).
+// CHECK-36-NEXT: 0 | vbase_offset (0)
+// CHECK-36-NEXT: 1 | vcall_offset (0)
+// CHECK-36-NEXT: 2 | offset_to_top (0)
+// CHECK-36-NEXT: 3 | Test29::B RTTI
+// CHECK-36-NEXT: -- (Test29::A, 0) vtable address --
+// CHECK-36-NEXT: -- (Test29::B, 0) vtable address --
+// CHECK-36-NEXT: 4 | Test29::V2 *Test29::B::f()
+// CHECK-36-NEXT: [return adjustment: 0 non-virtual, -24 vbase offset offset]
+// CHECK-36-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+// CHECK-36-NEXT: 5 | Test29::V2 *Test29::B::f()
+struct B : virtual A {
+ virtual V2 *f();
+};
+V2 *B::f() { return 0; }
+
+}
+
+namespace Test30 {
+
+// Test that we don't assert when generating a vtable for F.
+struct A { };
+
+struct B : virtual A {
+ int i;
+};
+
+struct C {
+ virtual void f();
+};
+
+struct D : virtual C, B { };
+struct E : virtual D { };
+
+struct F : E {
+ virtual void f();
+};
+void F::f() { }
+
+}
+
+namespace Test31 {
+
+// Test that we don't add D::f twice to the primary vtable.
+struct A {
+ int a;
+};
+
+struct B {
+ virtual void f();
+};
+
+struct C : A, virtual B {
+ virtual void f();
+};
+
+// CHECK-37: Vtable for 'Test31::D' (11 entries).
+// CHECK-37-NEXT: 0 | vbase_offset (0)
+// CHECK-37-NEXT: 1 | vbase_offset (8)
+// CHECK-37-NEXT: 2 | vcall_offset (0)
+// CHECK-37-NEXT: 3 | offset_to_top (0)
+// CHECK-37-NEXT: 4 | Test31::D RTTI
+// CHECK-37-NEXT: -- (Test31::B, 0) vtable address --
+// CHECK-37-NEXT: -- (Test31::D, 0) vtable address --
+// CHECK-37-NEXT: 5 | void Test31::D::f()
+// CHECK-37-NEXT: 6 | vbase_offset (-8)
+// CHECK-37-NEXT: 7 | vcall_offset (-8)
+// CHECK-37-NEXT: 8 | offset_to_top (-8)
+// CHECK-37-NEXT: 9 | Test31::D RTTI
+// CHECK-37-NEXT: -- (Test31::C, 8) vtable address --
+// CHECK-37-NEXT: 10 | void Test31::D::f()
+// CHECK-37-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+struct D : virtual C {
+ virtual void f();
+};
+void D::f() { }
+
+}
+
+namespace Test32 {
+
+// Check that we correctly lay out the virtual bases of 'Test32::D'.
+
+struct A {
+ virtual void f();
+};
+
+struct B : virtual A { };
+struct C : A, virtual B { };
+struct D : virtual B { };
+
+// CHECK-38: Virtual base offset offsets for 'Test32::E' (3 entries).
+// CHECK-38-NEXT: Test32::A | -32
+// CHECK-38-NEXT: Test32::B | -24
+// CHECK-38-NEXT: Test32::D | -40
+struct E : C, virtual D {
+ virtual void f();
+};
+void E::f() { }
+
+}
+
+namespace Test33 {
+
+// Test that we don't emit too many vcall offsets in 'Test32::F'.
+
+struct A {
+ virtual void a();
+};
+
+struct B {
+ virtual void b();
+};
+
+struct C : virtual A, virtual B {
+ virtual void c();
+};
+
+struct D : virtual C { };
+
+struct E : A, D {
+ virtual void e();
+};
+
+// CHECK-39: Vtable for 'Test33::F' (30 entries).
+// CHECK-39-NEXT: 0 | vbase_offset (24)
+// CHECK-39-NEXT: 1 | vbase_offset (16)
+// CHECK-39-NEXT: 2 | vbase_offset (16)
+// CHECK-39-NEXT: 3 | vbase_offset (8)
+// CHECK-39-NEXT: 4 | offset_to_top (0)
+// CHECK-39-NEXT: 5 | Test33::F RTTI
+// CHECK-39-NEXT: -- (Test33::A, 0) vtable address --
+// CHECK-39-NEXT: -- (Test33::F, 0) vtable address --
+// CHECK-39-NEXT: 6 | void Test33::A::a()
+// CHECK-39-NEXT: 7 | void Test33::F::f()
+// CHECK-39-NEXT: 8 | vcall_offset (0)
+// CHECK-39-NEXT: 9 | vcall_offset (0)
+// CHECK-39-NEXT: 10 | vbase_offset (16)
+// CHECK-39-NEXT: 11 | vbase_offset (8)
+// CHECK-39-NEXT: 12 | vbase_offset (8)
+// CHECK-39-NEXT: 13 | offset_to_top (-8)
+// CHECK-39-NEXT: 14 | Test33::F RTTI
+// CHECK-39-NEXT: -- (Test33::A, 8) vtable address --
+// CHECK-39-NEXT: -- (Test33::E, 8) vtable address --
+// CHECK-39-NEXT: 15 | void Test33::A::a()
+// CHECK-39-NEXT: 16 | void Test33::E::e()
+// CHECK-39-NEXT: 17 | vbase_offset (0)
+// CHECK-39-NEXT: 18 | vcall_offset (0)
+// CHECK-39-NEXT: 19 | vbase_offset (8)
+// CHECK-39-NEXT: 20 | vbase_offset (0)
+// CHECK-39-NEXT: 21 | vcall_offset (0)
+// CHECK-39-NEXT: 22 | offset_to_top (-16)
+// CHECK-39-NEXT: 23 | Test33::F RTTI
+// CHECK-39-NEXT: -- (Test33::A, 16) vtable address --
+// CHECK-39-NEXT: -- (Test33::C, 16) vtable address --
+// CHECK-39-NEXT: -- (Test33::D, 16) vtable address --
+// CHECK-39-NEXT: 24 | void Test33::A::a()
+// CHECK-39-NEXT: 25 | void Test33::C::c()
+// CHECK-39-NEXT: 26 | vcall_offset (0)
+// CHECK-39-NEXT: 27 | offset_to_top (-24)
+// CHECK-39-NEXT: 28 | Test33::F RTTI
+// CHECK-39-NEXT: -- (Test33::B, 24) vtable address --
+// CHECK-39-NEXT: 29 | void Test33::B::b()
+struct F : virtual E, A {
+ virtual void f();
+};
+void F::f() { }
+
+}
+
+namespace Test34 {
+
+// Test that we lay out the construction vtable for 'Test34::E' in 'Test34::F' correctly.
+
+struct A {
+ virtual void a();
+};
+struct B : virtual A { };
+
+struct C : B, A {
+ virtual void c();
+};
+
+struct D : A, C { };
+
+struct E : virtual D {
+ virtual void e();
+};
+
+// CHECK-40: Construction vtable for ('Test34::E', 0) in 'Test34::F' (22 entries).
+// CHECK-40-NEXT: 0 | vbase_offset (0)
+// CHECK-40-NEXT: 1 | vbase_offset (8)
+// CHECK-40-NEXT: 2 | vcall_offset (0)
+// CHECK-40-NEXT: 3 | offset_to_top (0)
+// CHECK-40-NEXT: 4 | Test34::E RTTI
+// CHECK-40-NEXT: -- (Test34::A, 0) vtable address --
+// CHECK-40-NEXT: -- (Test34::E, 0) vtable address --
+// CHECK-40-NEXT: 5 | void Test34::A::a()
+// CHECK-40-NEXT: 6 | void Test34::E::e()
+// CHECK-40-NEXT: 7 | vcall_offset (8)
+// CHECK-40-NEXT: 8 | vcall_offset (0)
+// CHECK-40-NEXT: 9 | vbase_offset (-8)
+// CHECK-40-NEXT: 10 | offset_to_top (-8)
+// CHECK-40-NEXT: 11 | Test34::E RTTI
+// CHECK-40-NEXT: -- (Test34::A, 8) vtable address --
+// CHECK-40-NEXT: -- (Test34::D, 8) vtable address --
+// CHECK-40-NEXT: 12 | void Test34::A::a()
+// CHECK-40-NEXT: 13 | vbase_offset (-16)
+// CHECK-40-NEXT: 14 | vcall_offset (-16)
+// CHECK-40-NEXT: 15 | offset_to_top (-16)
+// CHECK-40-NEXT: 16 | Test34::E RTTI
+// CHECK-40-NEXT: -- (Test34::B, 16) vtable address --
+// CHECK-40-NEXT: -- (Test34::C, 16) vtable address --
+// CHECK-40-NEXT: 17 | [unused] void Test34::A::a()
+// CHECK-40-NEXT: 18 | void Test34::C::c()
+// CHECK-40-NEXT: 19 | offset_to_top (-24)
+// CHECK-40-NEXT: 20 | Test34::E RTTI
+// CHECK-40-NEXT: -- (Test34::A, 24) vtable address --
+// CHECK-40-NEXT: 21 | void Test34::A::a()
+struct F : E {
+ virtual void f();
+};
+void F::f() { }
+
+}
+
+namespace Test35 {
+
+// Test that we lay out the virtual bases of 'Test35::H' in the correct order.
+
+struct A {
+ virtual void a();
+
+ int i;
+};
+
+struct B : virtual A {
+ virtual void b();
+};
+
+struct C {
+ virtual void c();
+};
+
+struct D : C, virtual B {
+ virtual void d();
+};
+
+struct E : D {
+ virtual void e();
+
+ bool b;
+};
+
+struct F : virtual D { };
+struct G : virtual E { };
+
+// CHECK-41: Vtable for 'Test35::H' (32 entries).
+// CHECK-41-NEXT: 0 | vbase_offset (32)
+// CHECK-41-NEXT: 1 | vbase_offset (0)
+// CHECK-41-NEXT: 2 | vcall_offset (0)
+// CHECK-41-NEXT: 3 | vcall_offset (0)
+// CHECK-41-NEXT: 4 | vbase_offset (16)
+// CHECK-41-NEXT: 5 | vbase_offset (8)
+// CHECK-41-NEXT: 6 | offset_to_top (0)
+// CHECK-41-NEXT: 7 | Test35::H RTTI
+// CHECK-41-NEXT: -- (Test35::C, 0) vtable address --
+// CHECK-41-NEXT: -- (Test35::D, 0) vtable address --
+// CHECK-41-NEXT: -- (Test35::F, 0) vtable address --
+// CHECK-41-NEXT: -- (Test35::H, 0) vtable address --
+// CHECK-41-NEXT: 8 | void Test35::C::c()
+// CHECK-41-NEXT: 9 | void Test35::D::d()
+// CHECK-41-NEXT: 10 | void Test35::H::h()
+// CHECK-41-NEXT: 11 | vbase_offset (0)
+// CHECK-41-NEXT: 12 | vbase_offset (24)
+// CHECK-41-NEXT: 13 | vcall_offset (0)
+// CHECK-41-NEXT: 14 | vbase_offset (8)
+// CHECK-41-NEXT: 15 | offset_to_top (-8)
+// CHECK-41-NEXT: 16 | Test35::H RTTI
+// CHECK-41-NEXT: -- (Test35::B, 8) vtable address --
+// CHECK-41-NEXT: -- (Test35::G, 8) vtable address --
+// CHECK-41-NEXT: 17 | void Test35::B::b()
+// CHECK-41-NEXT: 18 | vcall_offset (0)
+// CHECK-41-NEXT: 19 | offset_to_top (-16)
+// CHECK-41-NEXT: 20 | Test35::H RTTI
+// CHECK-41-NEXT: -- (Test35::A, 16) vtable address --
+// CHECK-41-NEXT: 21 | void Test35::A::a()
+// CHECK-41-NEXT: 22 | vcall_offset (0)
+// CHECK-41-NEXT: 23 | vcall_offset (0)
+// CHECK-41-NEXT: 24 | vcall_offset (0)
+// CHECK-41-NEXT: 25 | vbase_offset (-16)
+// CHECK-41-NEXT: 26 | vbase_offset (-24)
+// CHECK-41-NEXT: 27 | offset_to_top (-32)
+// CHECK-41-NEXT: 28 | Test35::H RTTI
+// CHECK-41-NEXT: -- (Test35::C, 32) vtable address --
+// CHECK-41-NEXT: -- (Test35::D, 32) vtable address --
+// CHECK-41-NEXT: -- (Test35::E, 32) vtable address --
+// CHECK-41-NEXT: 29 | void Test35::C::c()
+// CHECK-41-NEXT: 30 | void Test35::D::d()
+// CHECK-41-NEXT: 31 | void Test35::E::e()
+
+// CHECK-41: Virtual base offset offsets for 'Test35::H' (4 entries).
+// CHECK-41-NEXT: Test35::A | -32
+// CHECK-41-NEXT: Test35::B | -24
+// CHECK-41-NEXT: Test35::D | -56
+// CHECK-41-NEXT: Test35::E | -64
+struct H : F, G {
+ virtual void h();
+};
+void H::h() { }
+
+}
+
+namespace Test36 {
+
+// Test that we don't mark B::f as unused in the vtable for D.
+
+struct A {
+ virtual void f();
+};
+
+struct B : virtual A { };
+
+struct C : virtual A {
+ virtual void f();
+};
+
+// CHECK-42: Vtable for 'Test36::D' (12 entries).
+// CHECK-42-NEXT: 0 | vbase_offset (8)
+// CHECK-42-NEXT: 1 | vbase_offset (8)
+// CHECK-42-NEXT: 2 | vcall_offset (0)
+// CHECK-42-NEXT: 3 | offset_to_top (0)
+// CHECK-42-NEXT: 4 | Test36::D RTTI
+// CHECK-42-NEXT: -- (Test36::C, 0) vtable address --
+// CHECK-42-NEXT: -- (Test36::D, 0) vtable address --
+// CHECK-42-NEXT: 5 | void Test36::C::f()
+// CHECK-42-NEXT: 6 | void Test36::D::g()
+// CHECK-42-NEXT: 7 | vbase_offset (0)
+// CHECK-42-NEXT: 8 | vcall_offset (-8)
+// CHECK-42-NEXT: 9 | offset_to_top (-8)
+// CHECK-42-NEXT: 10 | Test36::D RTTI
+// CHECK-42-NEXT: -- (Test36::A, 8) vtable address --
+// CHECK-42-NEXT: -- (Test36::B, 8) vtable address --
+// CHECK-42-NEXT: 11 | void Test36::C::f()
+// CHECK-42-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
+struct D : virtual B, C {
+ virtual void g();
+};
+void D::g() { }
+
+}
+
+namespace Test37 {
+
+// Test that we give C::f the right vtable index. (PR9660).
+struct A {
+ virtual A* f() = 0;
+};
+
+struct B : virtual A {
+ virtual B* f();
+};
+
+// CHECK-43: VTable indices for 'Test37::C' (1 entries).
+// CHECK-43-NEXT: 1 | Test37::C *Test37::C::f()
+struct C : B {
+ virtual C* f();
+};
+
+C* C::f() { return 0; }
+
+}
+
+// rdar://problem/10959710
+namespace Test38 {
+ struct A {
+ virtual void *foo();
+ virtual const void *foo() const;
+ };
+
+ // CHECK-44: Vtable for 'Test38::B' (7 entries).
+ // CHECK-44-NEXT: 0 | vbase_offset (0)
+ // CHECK-44-NEXT: 1 | vcall_offset (0)
+ // CHECK-44-NEXT: 2 | vcall_offset (0)
+ // CHECK-44-NEXT: 3 | offset_to_top (0)
+ // CHECK-44-NEXT: 4 | Test38::B RTTI
+ // CHECK-44-NEXT: -- (Test38::A, 0) vtable address --
+ // CHECK-44-NEXT: -- (Test38::B, 0) vtable address --
+ // CHECK-44-NEXT: 5 | void *Test38::B::foo()
+ // CHECK-44-NEXT: 6 | const void *Test38::B::foo() const
+ class B : virtual public A {
+ void *foo();
+ const void *foo() const;
+ };
+
+ void *B::foo() { return 0; }
+}
diff --git a/clang/test/CodeGenCXX/vtable-linkage.cpp b/clang/test/CodeGenCXX/vtable-linkage.cpp
new file mode 100644
index 0000000..4633a3f
--- /dev/null
+++ b/clang/test/CodeGenCXX/vtable-linkage.cpp
@@ -0,0 +1,216 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o %t
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fhidden-weak-vtables -emit-llvm -o %t.hidden
+// RUN: FileCheck --check-prefix=CHECK-1 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-2 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-2-HIDDEN %s < %t.hidden
+// RUN: FileCheck --check-prefix=CHECK-3 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-4 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-5 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-5-HIDDEN %s < %t.hidden
+// RUN: FileCheck --check-prefix=CHECK-6 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-6-HIDDEN %s < %t.hidden
+// RUN: FileCheck --check-prefix=CHECK-7 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-8 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-9 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-10 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-11 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-12 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-13 %s < %t
+
+namespace {
+ struct A {
+ virtual void f() { }
+ };
+}
+
+void f() { A b; }
+
+struct B {
+ B();
+ virtual void f();
+};
+
+B::B() { }
+
+struct C : virtual B {
+ C();
+ virtual void f() { }
+};
+
+C::C() { }
+
+struct D {
+ virtual void f();
+};
+
+void D::f() { }
+
+static struct : D { } e;
+
+// The destructor is the key function.
+template<typename T>
+struct E {
+ virtual ~E();
+};
+
+template<typename T> E<T>::~E() { }
+
+// Anchor is the key function
+template<>
+struct E<char> {
+ virtual void anchor();
+};
+
+void E<char>::anchor() { }
+
+template struct E<short>;
+extern template struct E<int>;
+
+void use_E() {
+ E<int> ei;
+ (void)ei;
+ E<long> el;
+ (void)el;
+}
+
+// No key function
+template<typename T>
+struct F {
+ virtual void foo() { }
+};
+
+// No key function
+template<>
+struct F<char> {
+ virtual void foo() { }
+};
+
+template struct F<short>;
+extern template struct F<int>;
+
+void use_F() {
+ F<char> fc;
+ fc.foo();
+ F<int> fi;
+ fi.foo();
+ F<long> fl;
+ (void)fl;
+}
+
+// B has a key function that is not defined in this translation unit so its vtable
+// has external linkage.
+// CHECK-1: @_ZTV1B = external unnamed_addr constant
+
+// C has no key function, so its vtable should have weak_odr linkage
+// and hidden visibility (rdar://problem/7523229).
+// CHECK-2: @_ZTV1C = linkonce_odr unnamed_addr constant
+// CHECK-2: @_ZTS1C = linkonce_odr constant
+// CHECK-2: @_ZTI1C = linkonce_odr unnamed_addr constant
+// CHECK-2: @_ZTT1C = linkonce_odr unnamed_addr constant
+// CHECK-2-HIDDEN: @_ZTV1C = linkonce_odr hidden unnamed_addr constant
+// CHECK-2-HIDDEN: @_ZTS1C = linkonce_odr constant
+// CHECK-2-HIDDEN: @_ZTI1C = linkonce_odr hidden unnamed_addr constant
+// CHECK-2-HIDDEN: @_ZTT1C = linkonce_odr hidden unnamed_addr constant
+
+// D has a key function that is defined in this translation unit so its vtable is
+// defined in the translation unit.
+// CHECK-3: @_ZTV1D = unnamed_addr constant
+// CHECK-3: @_ZTS1D = constant
+// CHECK-3: @_ZTI1D = unnamed_addr constant
+
+// E<char> is an explicit specialization with a key function defined
+// in this translation unit, so its vtable should have external
+// linkage.
+// CHECK-4: @_ZTV1EIcE = unnamed_addr constant
+// CHECK-4: @_ZTS1EIcE = constant
+// CHECK-4: @_ZTI1EIcE = unnamed_addr constant
+
+// E<short> is an explicit template instantiation with a key function
+// defined in this translation unit, so its vtable should have
+// weak_odr linkage.
+// CHECK-5: @_ZTV1EIsE = weak_odr unnamed_addr constant
+// CHECK-5: @_ZTS1EIsE = weak_odr constant
+// CHECK-5: @_ZTI1EIsE = weak_odr unnamed_addr constant
+// CHECK-5-HIDDEN: @_ZTV1EIsE = weak_odr unnamed_addr constant
+// CHECK-5-HIDDEN: @_ZTS1EIsE = weak_odr constant
+// CHECK-5-HIDDEN: @_ZTI1EIsE = weak_odr unnamed_addr constant
+
+// F<short> is an explicit template instantiation without a key
+// function, so its vtable should have weak_odr linkage
+// CHECK-6: @_ZTV1FIsE = weak_odr unnamed_addr constant
+// CHECK-6: @_ZTS1FIsE = weak_odr constant
+// CHECK-6: @_ZTI1FIsE = weak_odr unnamed_addr constant
+// CHECK-6-HIDDEN: @_ZTV1FIsE = weak_odr unnamed_addr constant
+// CHECK-6-HIDDEN: @_ZTS1FIsE = weak_odr constant
+// CHECK-6-HIDDEN: @_ZTI1FIsE = weak_odr unnamed_addr constant
+
+// E<long> is an implicit template instantiation with a key function
+// defined in this translation unit, so its vtable should have
+// linkonce_odr linkage.
+// CHECK-7: @_ZTV1EIlE = linkonce_odr unnamed_addr constant
+// CHECK-7: @_ZTS1EIlE = linkonce_odr constant
+// CHECK-7: @_ZTI1EIlE = linkonce_odr unnamed_addr constant
+
+// F<long> is an implicit template instantiation with no key function,
+// so its vtable should have linkonce_odr linkage.
+// CHECK-8: @_ZTV1FIlE = linkonce_odr unnamed_addr constant
+// CHECK-8: @_ZTS1FIlE = linkonce_odr constant
+// CHECK-8: @_ZTI1FIlE = linkonce_odr unnamed_addr constant
+
+// F<int> is an explicit template instantiation declaration without a
+// key function, so its vtable should have external linkage.
+// CHECK-9: @_ZTV1FIiE = external unnamed_addr constant
+
+// E<int> is an explicit template instantiation declaration. It has a
+// key function that is not instantiated, so we should only reference
+// its vtable, not define it.
+// CHECK-10: @_ZTV1EIiE = external unnamed_addr constant
+
+// The anonymous struct for e has no linkage, so the vtable should have
+// internal linkage.
+// CHECK-11: @"_ZTV3$_0" = internal unnamed_addr constant
+// CHECK-11: @"_ZTS3$_0" = internal constant
+// CHECK-11: @"_ZTI3$_0" = internal unnamed_addr constant
+
+// The A vtable should have internal linkage since it is inside an anonymous
+// namespace.
+// CHECK-12: @_ZTVN12_GLOBAL__N_11AE = internal unnamed_addr constant
+// CHECK-12: @_ZTSN12_GLOBAL__N_11AE = internal constant
+// CHECK-12: @_ZTIN12_GLOBAL__N_11AE = internal unnamed_addr constant
+
+// F<char> is an explicit specialization without a key function, so
+// its vtable should have linkonce_odr linkage.
+// CHECK-13: @_ZTV1FIcE = linkonce_odr unnamed_addr constant
+// CHECK-13: @_ZTS1FIcE = linkonce_odr constant
+// CHECK-13: @_ZTI1FIcE = linkonce_odr unnamed_addr constant
+
+// RUN: FileCheck --check-prefix=CHECK-G %s < %t
+//
+// CHECK-G: @_ZTV1GIiE = linkonce_odr unnamed_addr constant
+template <typename T>
+class G {
+public:
+ G() {}
+ virtual void f0();
+ virtual void f1();
+};
+template <>
+void G<int>::f1() {}
+template <typename T>
+void G<T>::f0() {}
+void G_f0() { new G<int>(); }
+
+// RUN: FileCheck --check-prefix=CHECK-H %s < %t
+
+// H<int> has a key function without a body but it's a template instantiation
+// so its VTable must be emitted.
+// CHECK-H: @_ZTV1HIiE = linkonce_odr unnamed_addr constant
+template <typename T>
+class H {
+public:
+ virtual ~H();
+};
+
+void use_H() {
+ H<int> h;
+}
diff --git a/clang/test/CodeGenCXX/vtable-pointer-initialization.cpp b/clang/test/CodeGenCXX/vtable-pointer-initialization.cpp
new file mode 100644
index 0000000..9b1eaa5
--- /dev/null
+++ b/clang/test/CodeGenCXX/vtable-pointer-initialization.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+struct Field {
+ Field();
+ ~Field();
+};
+
+struct Base {
+ Base();
+ ~Base();
+};
+
+struct A : Base {
+ A();
+ ~A();
+
+ virtual void f();
+
+ Field field;
+};
+
+// CHECK: define void @_ZN1AC2Ev(%struct.A* %this) unnamed_addr
+// CHECK: call void @_ZN4BaseC2Ev(
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTV1A, i64 0, i64 2)
+// CHECK: call void @_ZN5FieldC1Ev(
+// CHECK: ret void
+A::A() { }
+
+// CHECK: define void @_ZN1AD2Ev(%struct.A* %this) unnamed_addr
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTV1A, i64 0, i64 2)
+// CHECK: call void @_ZN5FieldD1Ev(
+// CHECK: call void @_ZN4BaseD2Ev(
+// CHECK: ret void
+A::~A() { }
+
+struct B : Base {
+ virtual void f();
+
+ Field field;
+};
+
+void f() { B b; }
+
+// CHECK: define linkonce_odr void @_ZN1BC1Ev(%struct.B* %this) unnamed_addr
+// CHECK: call void @_ZN1BC2Ev(
+
+// CHECK: define linkonce_odr void @_ZN1BD1Ev(%struct.B* %this) unnamed_addr
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTV1B, i64 0, i64 2)
+// CHECK: call void @_ZN5FieldD1Ev(
+// CHECK: call void @_ZN4BaseD2Ev(
+// CHECK: ret void
+
+// CHECK: define linkonce_odr void @_ZN1BC2Ev(%struct.B* %this) unnamed_addr
+// CHECK: call void @_ZN4BaseC2Ev(
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTV1B, i64 0, i64 2)
+// CHECK: call void @_ZN5FieldC1Ev
+// CHECK: ret void
diff --git a/clang/test/CodeGenCXX/vtt-layout.cpp b/clang/test/CodeGenCXX/vtt-layout.cpp
new file mode 100644
index 0000000..ace7b74
--- /dev/null
+++ b/clang/test/CodeGenCXX/vtt-layout.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// Test1::B should just have a single entry in its VTT, which points to the vtable.
+namespace Test1 {
+struct A { };
+
+struct B : virtual A {
+ virtual void f();
+};
+
+void B::f() { }
+}
+
+// Check that we don't add a secondary virtual pointer for Test2::A, since Test2::A doesn't have any virtual member functions or bases.
+namespace Test2 {
+ struct A { };
+
+ struct B : A { virtual void f(); };
+ struct C : virtual B { };
+
+ C c;
+}
+
+// This is the sample from the C++ Itanium ABI, p2.6.2.
+namespace Test3 {
+ class A1 { int i; };
+ class A2 { int i; virtual void f(); };
+ class V1 : public A1, public A2 { int i; };
+ class B1 { int i; };
+ class B2 { int i; };
+ class V2 : public B1, public B2, public virtual V1 { int i; };
+ class V3 {virtual void g(); };
+ class C1 : public virtual V1 { int i; };
+ class C2 : public virtual V3, virtual V2 { int i; };
+ class X1 { int i; };
+ class C3 : public X1 { int i; };
+ class D : public C1, public C2, public C3 { int i; };
+
+ D d;
+}
+
+// This is the sample from the C++ Itanium ABI, p2.6.2, with the change suggested
+// (making A2 a virtual base of V1)
+namespace Test4 {
+ class A1 { int i; };
+ class A2 { int i; virtual void f(); };
+ class V1 : public A1, public virtual A2 { int i; };
+ class B1 { int i; };
+ class B2 { int i; };
+ class V2 : public B1, public B2, public virtual V1 { int i; };
+ class V3 {virtual void g(); };
+ class C1 : public virtual V1 { int i; };
+ class C2 : public virtual V3, virtual V2 { int i; };
+ class X1 { int i; };
+ class C3 : public X1 { int i; };
+ class D : public C1, public C2, public C3 { int i; };
+
+ D d;
+}
+
+// CHECK: @_ZTTN5Test11BE = unnamed_addr constant [1 x i8*] [i8* bitcast (i8** getelementptr inbounds ([4 x i8*]* @_ZTVN5Test11BE, i64 0, i64 3) to i8*)]
+// CHECK: @_ZTTN5Test41DE = linkonce_odr unnamed_addr constant [19 x i8*] [i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE0_NS_2C1E, i64 0, i64 10) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 12) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 15) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTCN5Test41DE16_NS_2C2E, i64 0, i64 18) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 17) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 20) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTVN5Test41DE, i64 1, i64 0) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test41DE40_NS_2V1E, i64 0, i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test41DE40_NS_2V1E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 7) to i8*), i8* bitcast (i8** getelementptr inbounds ([11 x i8*]* @_ZTCN5Test41DE72_NS_2V2E, i64 0, i64 10) to i8*)]
+// CHECK: @_ZTTN5Test31DE = linkonce_odr unnamed_addr constant [13 x i8*] [i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 5) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i64 0, i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE0_NS_2C1E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 6) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 10) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTCN5Test31DE16_NS_2C2E, i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 15) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 11) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 0, i64 11) to i8*), i8* bitcast (i8** getelementptr inbounds ([19 x i8*]* @_ZTVN5Test31DE, i64 1, i64 0) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE64_NS_2V2E, i64 0, i64 3) to i8*), i8* bitcast (i8** getelementptr inbounds ([7 x i8*]* @_ZTCN5Test31DE64_NS_2V2E, i64 0, i64 6) to i8*)]
+// CHECK: @_ZTTN5Test21CE = linkonce_odr unnamed_addr constant [2 x i8*] [i8* bitcast (i8** getelementptr inbounds ([5 x i8*]* @_ZTVN5Test21CE, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([5 x i8*]* @_ZTVN5Test21CE, i64 0, i64 4) to i8*)]
diff --git a/clang/test/CodeGenCXX/warn-padded-packed.cpp b/clang/test/CodeGenCXX/warn-padded-packed.cpp
new file mode 100644
index 0000000..4203bb3
--- /dev/null
+++ b/clang/test/CodeGenCXX/warn-padded-packed.cpp
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -triple=x86_64-none-none -Wpadded -Wpacked -verify %s -emit-llvm-only
+
+struct S1 {
+ char c;
+ short s; // expected-warning {{padding struct 'S1' with 1 byte to align 's'}}
+ long l; // expected-warning {{padding struct 'S1' with 4 bytes to align 'l'}}
+};
+
+struct S2 { // expected-warning {{padding size of 'S2' with 3 bytes to alignment boundary}}
+ int i;
+ char c;
+};
+
+struct S3 {
+ char c;
+ int i;
+} __attribute__((packed));
+
+struct S4 {
+ int i; // expected-warning {{packed attribute is unnecessary for 'i'}}
+ char c;
+} __attribute__((packed));
+
+struct S5 {
+ char c;
+ union {
+ char c;
+ int i;
+ } u; // expected-warning {{padding struct 'S5' with 3 bytes to align 'u'}}
+};
+
+struct S6 { // expected-warning {{padding size of 'S6' with 30 bits to alignment boundary}}
+ int i : 2;
+};
+
+struct S7 { // expected-warning {{padding size of 'S7' with 7 bytes to alignment boundary}}
+ char c;
+ virtual void m();
+};
+
+struct B {
+ char c;
+};
+
+struct S8 : B {
+ int i; // expected-warning {{padding struct 'S8' with 3 bytes to align 'i'}}
+};
+
+struct S9 { // expected-warning {{packed attribute is unnecessary for 'S9'}}
+ int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
+ int y; // expected-warning {{packed attribute is unnecessary for 'y'}}
+} __attribute__((packed));
+
+struct S10 { // expected-warning {{packed attribute is unnecessary for 'S10'}}
+ int x; // expected-warning {{packed attribute is unnecessary for 'x'}}
+ char a,b,c,d;
+} __attribute__((packed));
+
+
+struct S11 {
+ bool x;
+ char a,b,c,d;
+} __attribute__((packed));
+
+struct S12 {
+ bool b : 1;
+ char c; // expected-warning {{padding struct 'S12' with 7 bits to align 'c'}}
+};
+
+struct S13 { // expected-warning {{padding size of 'S13' with 6 bits to alignment boundary}}
+ char c;
+ bool b : 10; // expected-warning {{size of bit-field 'b' (10 bits) exceeds the size of its type}}
+};
+
+// The warnings are emitted when the layout of the structs is computed, so we have to use them.
+void f(S1*, S2*, S3*, S4*, S5*, S6*, S7*, S8*, S9*, S10*, S11*, S12*, S13*) { }
diff --git a/clang/test/CodeGenCXX/weak-extern-typeinfo.cpp b/clang/test/CodeGenCXX/weak-extern-typeinfo.cpp
new file mode 100644
index 0000000..3c3406e
--- /dev/null
+++ b/clang/test/CodeGenCXX/weak-extern-typeinfo.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// rdar://10246395
+
+#define WEAK __attribute__ ((weak))
+
+class WEAK A {
+ virtual void foo();
+};
+
+class B : public A {
+ virtual void foo();
+};
+void A::foo() { }
+void B::foo() { }
+
+class T {};
+class T1 {};
+
+class C : public T1, public B, public T {
+ virtual void foo();
+};
+void C::foo() { }
+
+class V1 : public virtual A {
+ virtual void foo();
+};
+
+class V2 : public virtual V1 {
+ virtual void foo();
+};
+void V1::foo() { }
+void V2::foo() { }
+
+// CHECK: @_ZTS1A = weak_odr constant
+// CHECK: @_ZTI1A = weak_odr unnamed_addr constant
+// CHECK: @_ZTS1B = weak_odr constant
+// CHECK: @_ZTI1B = weak_odr unnamed_addr constant
+// CHECK: @_ZTS1C = weak_odr constant
+// CHECK: @_ZTS2T1 = linkonce_odr constant
+// CHECK: @_ZTI2T1 = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTS1T = linkonce_odr constant
+// CHECK: @_ZTI1T = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTI1C = weak_odr unnamed_addr constant
+// CHECK: @_ZTS2V1 = weak_odr constant
+// CHECK: @_ZTI2V1 = weak_odr unnamed_addr constant
+// CHECK: @_ZTS2V2 = weak_odr constant
+// CHECK: @_ZTI2V2 = weak_odr unnamed_addr constant
diff --git a/clang/test/CodeGenCXX/weak-external.cpp b/clang/test/CodeGenCXX/weak-external.cpp
new file mode 100644
index 0000000..dad54f6
--- /dev/null
+++ b/clang/test/CodeGenCXX/weak-external.cpp
@@ -0,0 +1,66 @@
+// RUN: %clang -fexceptions %s -S -emit-llvm -o - | FileCheck %s
+// PR4262
+
+// CHECK-NOT: _ZNSs12_S_constructIPKcEEPcT_S3_RKSaIcESt20forward_iterator_tag
+
+// The "basic_string" extern template instantiation declaration is supposed to
+// suppress the implicit instantiation of non-inline member functions. Make sure
+// that we suppress the implicit instantiation of non-inline member functions
+// defined out-of-line. That we aren't instantiating the basic_string
+// constructor when we shouldn't be. Such an instantiation forces the implicit
+// instantiation of _S_construct<const char*>. Since _S_construct is a member
+// template, it's instantiation is *not* suppressed (despite being in
+// basic_string<char>), so we would emit it as a weak definition.
+
+#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
+#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
+#define _LIBCPP_VISIBLE __attribute__ ((__visibility__("default")))
+#if (__has_feature(cxx_noexcept))
+# define _NOEXCEPT noexcept
+# define _NOEXCEPT_(x) noexcept(x)
+#else
+# define _NOEXCEPT throw()
+# define _NOEXCEPT_(x)
+#endif
+
+namespace std // purposefully not using versioning namespace
+{
+
+template<class charT> struct char_traits;
+template<class T> class allocator;
+template <class _CharT,
+ class _Traits = char_traits<_CharT>,
+ class _Allocator = allocator<_CharT> >
+ class _LIBCPP_VISIBLE basic_string;
+typedef basic_string<char, char_traits<char>, allocator<char> > string;
+
+class _LIBCPP_EXCEPTION_ABI exception
+{
+public:
+ _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {}
+ virtual ~exception() _NOEXCEPT;
+ virtual const char* what() const _NOEXCEPT;
+};
+
+class _LIBCPP_EXCEPTION_ABI runtime_error
+ : public exception
+{
+private:
+ void* __imp_;
+public:
+ explicit runtime_error(const string&);
+ explicit runtime_error(const char*);
+
+ runtime_error(const runtime_error&) _NOEXCEPT;
+ runtime_error& operator=(const runtime_error&) _NOEXCEPT;
+
+ virtual ~runtime_error() _NOEXCEPT;
+
+ virtual const char* what() const _NOEXCEPT;
+};
+
+}
+
+void dummysymbol() {
+ throw(std::runtime_error("string"));
+}
diff --git a/clang/test/CodeGenCXX/x86_32-arguments.cpp b/clang/test/CodeGenCXX/x86_32-arguments.cpp
new file mode 100644
index 0000000..4404de0
--- /dev/null
+++ b/clang/test/CodeGenCXX/x86_32-arguments.cpp
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -o - %s | FileCheck %s
+
+// Non-trivial dtors, should both be passed indirectly.
+struct S {
+ ~S();
+ short s;
+};
+
+// CHECK: define void @_Z1fv(%struct.S* noalias sret %
+S f() { return S(); }
+// CHECK: define void @_Z1f1S(%struct.S*)
+void f(S) { }
+
+// Non-trivial dtors, should both be passed indirectly.
+class C {
+public:
+ ~C();
+ double c;
+};
+
+// CHECK: define void @_Z1gv(%class.C* noalias sret %
+C g() { return C(); }
+
+// CHECK: define void @_Z1f1C(%class.C*)
+void f(C) { }
+
+
+
+
+// PR7058 - Missing byval on MI thunk definition.
+
+// CHECK: define void @_ZThn4_N18BasicAliasAnalysis13getModRefInfoE8CallSite
+// ...
+// CHECK: %struct.CallSite* byval align 4 %CS)
+struct CallSite {
+ unsigned Ptr;
+ CallSite(unsigned XX) : Ptr(XX) {}
+};
+
+struct AliasAnalysis {
+ virtual void xyz();
+ virtual void getModRefInfo(CallSite CS) = 0;
+};
+
+struct ModulePass {
+ virtual void xx();
+};
+
+struct BasicAliasAnalysis : public ModulePass, public AliasAnalysis {
+ void getModRefInfo(CallSite CS);
+};
+
+void BasicAliasAnalysis::getModRefInfo(CallSite CS) {
+}
+
+// Check various single element struct type conditions.
+//
+// PR7098.
+
+// CHECK: define i64 @_Z2f0v()
+struct s0_0 { int x; };
+struct s0_1 : s0_0 { int* y; };
+s0_1 f0() { return s0_1(); }
+
+// CHECK: define i32 @_Z2f1v()
+struct s1_0 { int x; };
+struct s1_1 : s1_0 { };
+s1_1 f1() { return s1_1(); }
+
+// CHECK: define double @_Z2f2v()
+struct s2_0 { double x; };
+struct s2_1 : s2_0 { };
+s2_1 f2() { return s2_1(); }
+
+// CHECK: define double @_Z2f3v()
+struct s3_0 { };
+struct s3_1 { double x; };
+struct s3_2 : s3_0, s3_1 { };
+s3_2 f3() { return s3_2(); }
+
+// CHECK: define i64 @_Z2f4v()
+struct s4_0 { float x; };
+struct s4_1 { float x; };
+struct s4_2 : s4_0, s4_1 { };
+s4_2 f4() { return s4_2(); }
+
+// CHECK: define i32* @_Z2f5v()
+struct s5 { s5(); int &x; };
+s5 f5() { return s5(); }
+
+// CHECK: define i32 @_Z4f6_0M2s6i(i32 %a)
+// CHECK: define i64 @_Z4f6_1M2s6FivE({ i32, i32 }* byval align 4)
+// FIXME: It would be nice to avoid byval on the previous case.
+struct s6 {};
+typedef int s6::* s6_mdp;
+typedef int (s6::*s6_mfp)();
+s6_mdp f6_0(s6_mdp a) { return a; }
+s6_mfp f6_1(s6_mfp a) { return a; }
+
+// CHECK: define double @_Z2f7v()
+struct s7_0 { unsigned : 0; };
+struct s7_1 { double x; };
+struct s7 : s7_0, s7_1 { };
+s7 f7() { return s7(); }
+
+// CHECK: define void @_Z2f8v(%struct.s8* noalias sret %agg.result)
+struct s8_0 { };
+struct s8_1 { double x; };
+struct s8 { s8_0 a; s8_1 b; };
+s8 f8() { return s8(); }
+
+// CHECK: define void @_Z2f9v(%struct.s9* noalias sret %agg.result)
+struct s9_0 { unsigned : 0; };
+struct s9_1 { double x; };
+struct s9 { s9_0 a; s9_1 b; };
+s9 f9() { return s9(); }
diff --git a/clang/test/CodeGenCXX/x86_64-arguments.cpp b/clang/test/CodeGenCXX/x86_64-arguments.cpp
new file mode 100644
index 0000000..6721803
--- /dev/null
+++ b/clang/test/CodeGenCXX/x86_64-arguments.cpp
@@ -0,0 +1,183 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+// Basic base class test.
+struct f0_s0 { unsigned a; };
+struct f0_s1 : public f0_s0 { void *b; };
+// CHECK: define void @_Z2f05f0_s1(i32 %a0.coerce0, i8* %a0.coerce1)
+void f0(f0_s1 a0) { }
+
+// Check with two eight-bytes in base class.
+struct f1_s0 { unsigned a; unsigned b; float c; };
+struct f1_s1 : public f1_s0 { float d;};
+// CHECK: define void @_Z2f15f1_s1(i64 %a0.coerce0, <2 x float> %a0.coerce1)
+void f1(f1_s1 a0) { }
+
+// Check with two eight-bytes in base class and merge.
+struct f2_s0 { unsigned a; unsigned b; float c; };
+struct f2_s1 : public f2_s0 { char d;};
+// CHECK: define void @_Z2f25f2_s1(i64 %a0.coerce0, i64 %a0.coerce1)
+void f2(f2_s1 a0) { }
+
+// PR5831
+// CHECK: define void @_Z2f34s3_1(i64 %x.coerce)
+struct s3_0 {};
+struct s3_1 { struct s3_0 a; long b; };
+void f3(struct s3_1 x) {}
+
+// CHECK: define i64 @_Z4f4_0M2s4i(i64 %a)
+// CHECK: define {{.*}} @_Z4f4_1M2s4FivE(i64 %a.coerce0, i64 %a.coerce1)
+struct s4 {};
+typedef int s4::* s4_mdp;
+typedef int (s4::*s4_mfp)();
+s4_mdp f4_0(s4_mdp a) { return a; }
+s4_mfp f4_1(s4_mfp a) { return a; }
+
+
+namespace PR7523 {
+struct StringRef {
+ char *a;
+};
+
+void AddKeyword(StringRef, int x);
+
+void foo() {
+ // CHECK: define void @_ZN6PR75233fooEv()
+ // CHECK: call void @_ZN6PR752310AddKeywordENS_9StringRefEi(i8* {{.*}}, i32 4)
+ AddKeyword(StringRef(), 4);
+}
+}
+
+namespace PR7742 { // Also rdar://8250764
+ struct s2 {
+ float a[2];
+ };
+
+ struct c2 : public s2 {};
+
+ // CHECK: define <2 x float> @_ZN6PR77423fooEPNS_2c2E(%"struct.PR7742::c2"* %P)
+ c2 foo(c2 *P) {
+ return c2();
+ }
+
+}
+
+namespace PR5179 {
+ struct B {};
+
+ struct B1 : B {
+ int* pa;
+ };
+
+ struct B2 : B {
+ B1 b1;
+ };
+
+ // CHECK: define i8* @_ZN6PR51793barENS_2B2E(i32* %b2.coerce)
+ const void *bar(B2 b2) {
+ return b2.b1.pa;
+ }
+}
+
+namespace test5 {
+ struct Xbase { };
+ struct Empty { };
+ struct Y;
+ struct X : public Xbase {
+ Empty empty;
+ Y f();
+ };
+ struct Y : public X {
+ Empty empty;
+ };
+ X getX();
+ int takeY(const Y&, int y);
+ void g() {
+ // rdar://8340348 - The temporary for the X object needs to have a defined
+ // address when passed into X::f as 'this'.
+ takeY(getX().f(), 42);
+ }
+ // CHECK: void @_ZN5test51gEv()
+ // CHECK: alloca %"struct.test5::Y"
+ // CHECK: alloca %"struct.test5::X"
+ // CHECK: alloca %"struct.test5::Y"
+}
+
+
+// rdar://8360877
+namespace test6 {
+ struct outer {
+ int x;
+ struct epsilon_matcher {} e;
+ int f;
+ };
+
+ int test(outer x) {
+ return x.x + x.f;
+ }
+ // CHECK: define i32 @_ZN5test64testENS_5outerE(i64 %x.coerce0, i32 %x.coerce1)
+}
+
+namespace test7 {
+ struct StringRef {char* ptr; long len; };
+ class A { public: ~A(); };
+ A x(A, A, long, long, StringRef) { return A(); }
+ // Check that the StringRef is passed byval instead of expanded
+ // (which would split it between registers and memory).
+ // rdar://problem/9686430
+ // CHECK: define void @_ZN5test71xENS_1AES0_llNS_9StringRefE({{.*}} byval align 8)
+
+ // And a couple extra related tests:
+ A y(A, long double, long, long, StringRef) { return A(); }
+ // CHECK: define void @_ZN5test71yENS_1AEellNS_9StringRefE({{.*}} i8*
+ struct StringDouble {char * ptr; double d;};
+ A z(A, A, A, A, A, StringDouble) { return A(); }
+ A zz(A, A, A, A, StringDouble) { return A(); }
+ // CHECK: define void @_ZN5test71zENS_1AES0_S0_S0_S0_NS_12StringDoubleE({{.*}} byval align 8)
+ // CHECK: define void @_ZN5test72zzENS_1AES0_S0_S0_NS_12StringDoubleE({{.*}} i8*
+}
+
+namespace test8 {
+ // CHECK: declare void @_ZN5test83fooENS_1BE(%"class.test8::B"* byval align 8)
+ class A {
+ char big[17];
+ };
+
+ class B : public A {};
+
+ void foo(B b);
+ void bar() {
+ B b;
+ foo(b);
+ }
+}
+
+// PR4242
+namespace test9 {
+ // Large enough to be passed indirectly.
+ struct S { void *data[3]; };
+
+ struct T { void *data[2]; };
+
+ // CHECK: define void @_ZN5test93fooEPNS_1SEPNS_1TE([[S:%.*]]*, [[T:%.*]]*)
+ void foo(S*, T*) {}
+
+ // CHECK: define void @_ZN5test91aEiiiiNS_1TEPv([[S]]* noalias sret {{%.*}}, i32, i32, i32, i32, [[T]]* byval align 8, i8*)
+ S a(int, int, int, int, T, void*) {
+ return S();
+ }
+
+ // CHECK: define [[S]]* @_ZN5test91bEPNS_1SEiiiiNS_1TEPv([[S]]* {{%.*}}, i32, i32, i32, i32, [[T:%.*]]* byval align 8, i8*)
+ S* b(S* sret, int, int, int, int, T, void*) {
+ return sret;
+ }
+
+ // CHECK: define void @_ZN5test91cEiiiNS_1TEPv([[S]]* noalias sret {{%.*}}, i32, i32, i32, i8* {{%.*}}, i8* {{%.*}}, i8*)
+ S c(int, int, int, T, void*) {
+ return S();
+ }
+
+ // CHECK: define [[S]]* @_ZN5test91dEPNS_1SEiiiNS_1TEPv([[S]]* {{%.*}}, i32, i32, i32, i8* {{%.*}}, i8* {{%.*}}, i8*)
+ S* d(S* sret, int, int, int, T, void*) {
+ return sret;
+ }
+}
diff --git a/clang/test/CodeGenObjC/2007-04-03-ObjcEH.m b/clang/test/CodeGenObjC/2007-04-03-ObjcEH.m
new file mode 100644
index 0000000..f86ff49
--- /dev/null
+++ b/clang/test/CodeGenObjC/2007-04-03-ObjcEH.m
@@ -0,0 +1,27 @@
+// RUN: %clang -fexceptions -S -emit-llvm %s -o -
+
+@interface B
+-(int)bar;
+@end
+
+@interface A
+-(void) Foo:(int) state;
+@end
+
+@implementation A
+- (void) Foo:(int) state {
+
+ int wasResponded = 0;
+ @try {
+ if (state) {
+ B * b = 0;
+ @try { }
+ @finally {
+ wasResponded = ![b bar];
+ }
+ }
+ }
+ @finally {
+ }
+}
+@end
diff --git a/clang/test/CodeGenObjC/2007-05-02-Strong.m b/clang/test/CodeGenObjC/2007-05-02-Strong.m
new file mode 100644
index 0000000..31553df
--- /dev/null
+++ b/clang/test/CodeGenObjC/2007-05-02-Strong.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -S %s -fobjc-gc -o /dev/null
+typedef int NSInteger;
+typedef struct _NSRect {
+ int origin;
+ int size;
+} NSRect;
+
+__attribute__((objc_gc(strong))) NSRect *_cachedRectArray;
+extern const NSRect NSZeroRect;
+@interface A{
+}
+-(void)bar:(NSInteger *)rectCount;
+@end
+
+@implementation A
+
+-(void)bar:(NSInteger *)rectCount {
+ NSRect appendRect = NSZeroRect;
+
+ _cachedRectArray[*rectCount - 1] = NSZeroRect;
+}
+
+@end
diff --git a/clang/test/CodeGenObjC/2007-10-18-ProDescriptor.m b/clang/test/CodeGenObjC/2007-10-18-ProDescriptor.m
new file mode 100644
index 0000000..35a0df3
--- /dev/null
+++ b/clang/test/CodeGenObjC/2007-10-18-ProDescriptor.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+@protocol O
+@end
+@interface O < O > {
+}
+@end
+struct A {
+};
+@protocol AB
+- (unsigned) ver;
+@end
+@interface AGy:O < AB > {
+}
+@end
+@implementation AGy
+- (unsigned) ver {
+}
+@end
diff --git a/clang/test/CodeGenObjC/2007-10-23-GC-WriteBarrier.m b/clang/test/CodeGenObjC/2007-10-23-GC-WriteBarrier.m
new file mode 100644
index 0000000..af8508b
--- /dev/null
+++ b/clang/test/CodeGenObjC/2007-10-23-GC-WriteBarrier.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null -fobjc-gc
+// rdar://5541393
+
+typedef unsigned int NSUInteger;
+__attribute__((objc_gc(strong))) float *_scores;
+
+void foo(int i, float f) {
+ _scores[i] = f;
+}
diff --git a/clang/test/CodeGenObjC/2008-08-25-incompatible-cond-expr.m b/clang/test/CodeGenObjC/2008-08-25-incompatible-cond-expr.m
new file mode 100644
index 0000000..f285cca
--- /dev/null
+++ b/clang/test/CodeGenObjC/2008-08-25-incompatible-cond-expr.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@protocol P0
+@end
+@interface A <P0>
+@end
+
+id f0(int a, id<P0> x, A* p) {
+ return a ? x : p;
+}
diff --git a/clang/test/CodeGenObjC/2008-10-23-invalid-icmp.m b/clang/test/CodeGenObjC/2008-10-23-invalid-icmp.m
new file mode 100644
index 0000000..ce01bdb
--- /dev/null
+++ b/clang/test/CodeGenObjC/2008-10-23-invalid-icmp.m
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@protocol P @end
+
+int f0(id<P> d) {
+ return (d != ((void*) 0));
+}
diff --git a/clang/test/CodeGenObjC/2008-10-3-EhValue.m b/clang/test/CodeGenObjC/2008-10-3-EhValue.m
new file mode 100644
index 0000000..0ed0d89
--- /dev/null
+++ b/clang/test/CodeGenObjC/2008-10-3-EhValue.m
@@ -0,0 +1,50 @@
+// RUN: %clang -fexceptions -S -emit-llvm %s -o /dev/null
+
+@interface Object {
+@public
+ Class isa;
+}
++initialize;
++alloc;
++new;
++free;
+-free;
++(Class)class;
+-(Class)class;
+-init;
+-superclass;
+-(const char *)name;
+@end
+
+@interface Frob: Object
+@end
+
+@implementation Frob: Object
+@end
+
+static Frob* _connection = ((void *)0);
+
+extern void abort(void);
+
+void test (Object* sendPort)
+{
+ int cleanupPorts = 1;
+ Frob* receivePort = ((void *)0);
+
+ @try {
+ receivePort = (Frob *) -1;
+ _connection = (Frob *) -1;
+ receivePort = ((void *)0);
+ sendPort = ((void *)0);
+ cleanupPorts = 0;
+ @throw [Object new];
+ }
+ @catch(Frob *obj) {
+ if(!(0)) abort();
+ }
+ @catch(id exc) {
+ if(!(!receivePort)) abort();
+ if(!(!sendPort)) abort();
+ if(!(!cleanupPorts)) abort();
+ }
+}
diff --git a/clang/test/CodeGenObjC/2008-11-12-Metadata.m b/clang/test/CodeGenObjC/2008-11-12-Metadata.m
new file mode 100644
index 0000000..afd7ce0
--- /dev/null
+++ b/clang/test/CodeGenObjC/2008-11-12-Metadata.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -fobjc-fragile-abi %s -o /dev/null
+
+@interface A
+@end
+@protocol P
+@end
+@interface B : A <P>
+{
+}
+@end
+@implementation B
+- (void)test {
+}
+@end
diff --git a/clang/test/CodeGenObjC/2008-11-24-ConstCFStrings.m b/clang/test/CodeGenObjC/2008-11-24-ConstCFStrings.m
new file mode 100644
index 0000000..b37f66c
--- /dev/null
+++ b/clang/test/CodeGenObjC/2008-11-24-ConstCFStrings.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -fobjc-fragile-abi %s -o - | FileCheck %s
+
+// CHECK: _unnamed_cfstring_
+
+@class NSString;
+
+@interface A
+- (void)bork:(NSString*)msg;
+@end
+
+void func(A *a) {
+ [a bork:@"Hello world!"];
+}
diff --git a/clang/test/CodeGenObjC/2008-11-25-Blocks.m b/clang/test/CodeGenObjC/2008-11-25-Blocks.m
new file mode 100644
index 0000000..39364d5
--- /dev/null
+++ b/clang/test/CodeGenObjC/2008-11-25-Blocks.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fblocks -emit-llvm %s -o /dev/null
+// rdar://6394879
+
+@interface bork
+- (id)B:(void (^)())blk;
+- (void)C;
+@end
+@implementation bork
+- (id)B:(void (^)())blk {
+ __attribute__((__blocks__(byref))) bork* new = ((void *)0);
+ blk();
+}
+- (void)C {
+ __attribute__((__blocks__(byref))) id var;
+ [self B:^() {}];
+}
+@end
diff --git a/clang/test/CodeGenObjC/2009-01-21-invalid-debug-info.m b/clang/test/CodeGenObjC/2009-01-21-invalid-debug-info.m
new file mode 100644
index 0000000..af912e2
--- /dev/null
+++ b/clang/test/CodeGenObjC/2009-01-21-invalid-debug-info.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -S -g -o %t.s %s
+
+// FIXME: This test case can be removed at some point (since it will
+// no longer effectively test anything). The reason it was causing
+// trouble was the synthesized self decl in im1 was causing the debug
+// info for I1* to be generated, but referring to an invalid compile
+// unit. This was later referred to by f1 and created ill formed debug
+// information.
+
+@interface I1 @end
+
+@implementation I1
+-im0 { return 0; }
+@end
+
+I1 *f1(void) { return 0; }
diff --git a/clang/test/CodeGenObjC/2009-01-26-WriteBarrier-2.m b/clang/test/CodeGenObjC/2009-01-26-WriteBarrier-2.m
new file mode 100644
index 0000000..d7219f1
--- /dev/null
+++ b/clang/test/CodeGenObjC/2009-01-26-WriteBarrier-2.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fblocks -emit-llvm %s -fobjc-gc -o - | FileCheck %s
+
+// CHECK: objc_assign_strongCast
+// rdar://5541393
+
+typedef __SIZE_TYPE__ size_t;
+void * malloc(size_t size);
+
+typedef struct {
+ void (^ivarBlock)(void);
+} StructWithBlock_t;
+
+int main(int argc, char *argv[]) {
+ StructWithBlock_t *swbp = (StructWithBlock_t *)malloc(sizeof(StructWithBlock_t*));
+ __block int i = 10;
+ // assigning a Block into an struct slot should elicit a write-barrier under GC
+ swbp->ivarBlock = ^ { ++i; };
+ return 0;
+}
diff --git a/clang/test/CodeGenObjC/2009-02-05-VolatileProp.m b/clang/test/CodeGenObjC/2009-02-05-VolatileProp.m
new file mode 100644
index 0000000..1f696ac
--- /dev/null
+++ b/clang/test/CodeGenObjC/2009-02-05-VolatileProp.m
@@ -0,0 +1,10 @@
+// RUN: %clang -fexceptions -S -emit-llvm %s -o /dev/null -pedantic-errors
+// rdar://6551276
+
+void foo(const unsigned short *);
+void bar() {
+ unsigned short *s[3];
+ int i;
+ @try { } @catch (id anException) { }
+ foo(2+s[i]);
+}
diff --git a/clang/test/CodeGenObjC/2009-08-05-utf16.m b/clang/test/CodeGenObjC/2009-08-05-utf16.m
new file mode 100644
index 0000000..06458e7
--- /dev/null
+++ b/clang/test/CodeGenObjC/2009-08-05-utf16.m
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm -w -x objective-c %s -o - | FileCheck %s
+// rdar://7095855 rdar://7115749
+
+// CHECK: internal unnamed_addr constant [6 x i16] [i16 105, i16 80, i16 111, i16 100, i16 8482, i16 0], align 2
+void *P = @"iPod™";
diff --git a/clang/test/CodeGenObjC/2010-02-01-utf16-with-null.m b/clang/test/CodeGenObjC/2010-02-01-utf16-with-null.m
new file mode 100644
index 0000000..1863984
--- /dev/null
+++ b/clang/test/CodeGenObjC/2010-02-01-utf16-with-null.m
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// rdar://7589850
+
+// CHECK-NOT: __ustring
+void *P = @"good\0bye";
diff --git a/clang/test/CodeGenObjC/2010-02-09-DbgSelf.m b/clang/test/CodeGenObjC/2010-02-09-DbgSelf.m
new file mode 100644
index 0000000..e09adac
--- /dev/null
+++ b/clang/test/CodeGenObjC/2010-02-09-DbgSelf.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x objective-c -emit-llvm -g < %s | grep "\"self\", metadata"
+// Test to check that "self" argument is assigned a location.
+
+@interface Foo
+-(void) Bar: (int)x ;
+@end
+
+
+@implementation Foo
+-(void) Bar: (int)x
+{
+}
+@end
+
diff --git a/clang/test/CodeGenObjC/2010-02-15-Dbg-MethodStart.m b/clang/test/CodeGenObjC/2010-02-15-Dbg-MethodStart.m
new file mode 100644
index 0000000..5186b20
--- /dev/null
+++ b/clang/test/CodeGenObjC/2010-02-15-Dbg-MethodStart.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -x objective-c -emit-llvm -g < %s | grep subprogram | grep "i32 9"
+// Test to check that subprogram start location.
+
+@interface Foo
+-(int) barMethod;
+@end
+
+@implementation Foo
+-(int) barMethod {
+ int i = 0;
+ int j = 1;
+ int k = 1;
+ return i + j + k;
+}
+@end
diff --git a/clang/test/CodeGenObjC/2010-02-23-DbgInheritance.m b/clang/test/CodeGenObjC/2010-02-23-DbgInheritance.m
new file mode 100644
index 0000000..7d31b30
--- /dev/null
+++ b/clang/test/CodeGenObjC/2010-02-23-DbgInheritance.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -g -o - | FileCheck %s
+// CHECK-NOT: DW_TAG_member
+// Interface P should not be a member of interface I in debug info.
+@interface P
+@end
+
+@interface I : P
+@end
+
+void fn(I *iptr) {}
diff --git a/clang/test/CodeGenObjC/2010-03-17-StructRef.m b/clang/test/CodeGenObjC/2010-03-17-StructRef.m
new file mode 100644
index 0000000..fd0e646
--- /dev/null
+++ b/clang/test/CodeGenObjC/2010-03-17-StructRef.m
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-darwin -fobjc-fragile-abi -o - | FileCheck %s
+// Bitfield references must not touch memory outside of the enclosing
+// struct. Radar 7639995
+typedef signed char BOOL;
+@protocol NSObject
+- (id)init;
+@end
+@interface NSObject <NSObject> {}
+@end
+@interface IMAVChatParticipant : NSObject {
+ int _ardRole;
+ int _state;
+ int _avRelayStatus;
+ int _chatEndedReason;
+ int _chatError;
+ unsigned _sendingAudio:1;
+ unsigned _sendingVideo:1;
+ unsigned _sendingAuxVideo:1;
+ unsigned _audioMuted:1;
+ unsigned _videoPaused:1;
+ unsigned _networkStalled:1;
+ unsigned _isInitiator:1;
+ unsigned _isAOLInterop:1;
+ unsigned _isRecording:1;
+ unsigned _isUsingICE:1;
+}
+@end
+@implementation IMAVChatParticipant
+- (id) init {
+ self = [super init];
+ if ( self ) {
+ BOOL blah = (BOOL)1;
+ // We're expecting these three bitfield assignments will generate i8 stores.
+ _sendingAudio = (BOOL)1;
+ _isUsingICE = (BOOL)1;
+ _isUsingICE = blah;
+ // CHECK: store i8
+ // CHECK: store i8
+ // CHECK: store i8
+ }
+ return self;
+}
+@end
diff --git a/clang/test/CodeGenObjC/2011-03-08-IVarLookup.m b/clang/test/CodeGenObjC/2011-03-08-IVarLookup.m
new file mode 100644
index 0000000..a24b98c
--- /dev/null
+++ b/clang/test/CodeGenObjC/2011-03-08-IVarLookup.m
@@ -0,0 +1,30 @@
+// RUN: %clang -S -emit-llvm -m64 -fobjc-abi-version=2 %s -o /dev/null
+
+typedef unsigned int UInt_t;
+
+@interface A
+{
+@protected
+ UInt_t _f1;
+}
+@end
+
+@interface B : A { }
+@end
+
+@interface A ()
+@property (assign) UInt_t f1;
+@end
+
+@interface B ()
+@property (assign) int x;
+@end
+
+@implementation B
+@synthesize x;
+- (id) init
+{
+ _f1 = 0;
+ return self;
+}
+@end
diff --git a/clang/test/CodeGenObjC/Inputs/literal-support.h b/clang/test/CodeGenObjC/Inputs/literal-support.h
new file mode 100644
index 0000000..5680a20
--- /dev/null
+++ b/clang/test/CodeGenObjC/Inputs/literal-support.h
@@ -0,0 +1,35 @@
+#ifndef OBJC_LITERAL_SUPPORT_H
+#define OBJC_LITERAL_SUPPORT_H
+
+typedef unsigned char BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
++ (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;
+@end
+
+@interface NSArray
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+#endif // OBJC_LITERAL_SUPPORT_H
diff --git a/clang/test/CodeGenObjC/arc-arm.m b/clang/test/CodeGenObjC/arc-arm.m
new file mode 100644
index 0000000..23da3be
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-arm.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple armv7-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -o - %s | FileCheck %s
+
+id test0(void) {
+ extern id test0_helper(void);
+ // CHECK: [[T0:%.*]] = call arm_aapcscc i8* @test0_helper()
+ // CHECK-NEXT: ret i8* [[T0]]
+ return test0_helper();
+}
+
+void test1(void) {
+ extern id test1_helper(void);
+ // CHECK: [[T0:%.*]] = call arm_aapcscc i8* @test1_helper()
+ // CHECK-NEXT: call void asm sideeffect "mov\09r7, r7
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: store i8* [[T1]],
+ // CHECK-NEXT: load
+ // CHECK-NEXT: call void @objc_release
+ // CHECK-NEXT: ret void
+ id x = test1_helper();
+}
diff --git a/clang/test/CodeGenObjC/arc-block-copy-escape.m b/clang/test/CodeGenObjC/arc-block-copy-escape.m
new file mode 100644
index 0000000..15c0d1d
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-block-copy-escape.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fobjc-arc -fblocks -emit-llvm %s -o - | FileCheck %s
+
+typedef void (^block_t)(void);
+void use_block(block_t);
+void use_int(int);
+
+// rdar://problem/10211676
+
+void test0(int i) {
+ block_t block = ^{ use_int(i); };
+ // CHECK: define void @test0(
+ // CHECK: call i8* @objc_retainBlock(i8* {{%.*}}) nounwind, !clang.arc.copy_on_escape
+ // CHECK: ret void
+}
+
+void test1(int i) {
+ id block = ^{ use_int(i); };
+ // CHECK: define void @test1(
+ // CHECK: call i8* @objc_retainBlock(i8* {{%.*}}) nounwind
+ // CHECK-NOT: !clang.arc.copy_on_escape
+ // CHECK: ret void
+}
diff --git a/clang/test/CodeGenObjC/arc-block-ivar-layout.m b/clang/test/CodeGenObjC/arc-block-ivar-layout.m
new file mode 100644
index 0000000..6c82f29
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-block-ivar-layout.m
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak -triple x86_64-apple-darwin -O0 -emit-llvm %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// rdar://8991729
+
+__weak id wid;
+void x(id y) {}
+void y(int a) {}
+
+extern id opaque_id();
+
+void f() {
+ __block int byref_int = 0;
+ char ch = 'a';
+ char ch1 = 'b';
+ char ch2 = 'c';
+ short sh = 2;
+ const id bar = (id) opaque_id();
+ id baz = 0;
+ __strong id strong_void_sta;
+ __block id byref_bab = (id)0;
+ __block id bl_var1;
+ int i; double dob;
+
+// The patterns here are a sequence of bytes, each saying first how
+// many sizeof(void*) chunks to skip (high nibble) and then how many
+// to scan (low nibble). A zero byte says that we've reached the end
+// of the pattern.
+//
+// All of these patterns start with 01 3x because the block header on
+// LP64 consists of an isa pointer (which we're supposed to scan for
+// some reason) followed by three words (2 ints, a function pointer,
+// and a descriptor pointer).
+
+// Test 1
+// byref int, short, char, char, char, id, id, strong id, byref id
+// 01 35 10 00
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [4 x i8] c"\015\10\00"
+ void (^b)() = ^{
+ byref_int = sh + ch+ch1+ch2 ;
+ x(bar);
+ x(baz);
+ x((id)strong_void_sta);
+ x(byref_bab);
+ };
+ b();
+
+// Test 2
+// byref int, short, char, char, char, id, id, strong id, byref void*, byref id
+// 01 36 10 00
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [4 x i8] c"\016\10\00"
+ void (^c)() = ^{
+ byref_int = sh + ch+ch1+ch2 ;
+ x(bar);
+ x(baz);
+ x((id)strong_void_sta);
+ x(wid);
+ bl_var1 = 0;
+ x(byref_bab);
+ };
+}
diff --git a/clang/test/CodeGenObjC/arc-blocks.m b/clang/test/CodeGenObjC/arc-blocks.m
new file mode 100644
index 0000000..06acf01
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-blocks.m
@@ -0,0 +1,523 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+
+// This shouldn't crash.
+void test0(id (^maker)(void)) {
+ maker();
+}
+
+int (^test1(int x))(void) {
+ // CHECK: define i32 ()* @test1(
+ // CHECK: [[X:%.*]] = alloca i32,
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+ // CHECK-NEXT: store i32 {{%.*}}, i32* [[X]]
+ // CHECK: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to i32 ()*
+ // CHECK-NEXT: [[T1:%.*]] = bitcast i32 ()* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainBlock(i8* [[T1]]) nounwind
+ // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to i32 ()*
+ // CHECK-NEXT: [[T4:%.*]] = bitcast i32 ()* [[T3]] to i8*
+ // CHECK-NEXT: [[T5:%.*]] = call i8* @objc_autoreleaseReturnValue(i8* [[T4]]) nounwind
+ // CHECK-NEXT: [[T6:%.*]] = bitcast i8* [[T5]] to i32 ()*
+ // CHECK-NEXT: ret i32 ()* [[T6]]
+ return ^{ return x; };
+}
+
+void test2(id x) {
+// CHECK: define void @test2(
+// CHECK: [[X:%.*]] = alloca i8*,
+// CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+// CHECK-NEXT: [[PARM:%.*]] = call i8* @objc_retain(i8* {{%.*}})
+// CHECK-NEXT: store i8* [[PARM]], i8** [[X]]
+// CHECK-NEXT: [[SLOTREL:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK-NEXT: [[T0:%.*]] = load i8** [[X]],
+// CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
+// CHECK-NEXT: store i8* [[T1]], i8** [[SLOT]],
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: call void @test2_helper(
+// CHECK-NEXT: [[T0:%.*]] = load i8** [[SLOTREL]]
+// CHECK-NEXT: call void @objc_release(i8* [[T0]]) nounwind, !clang.imprecise_release
+// CHECK-NEXT: [[T0:%.*]] = load i8** [[X]]
+// CHECK-NEXT: call void @objc_release(i8* [[T0]]) nounwind, !clang.imprecise_release
+// CHECK-NEXT: ret void
+ extern void test2_helper(id (^)(void));
+ test2_helper(^{ return x; });
+}
+
+void test3(void (^sink)(id*)) {
+ __strong id strong;
+ sink(&strong);
+
+ // CHECK: define void @test3(
+ // CHECK: [[SINK:%.*]] = alloca void (i8**)*
+ // CHECK-NEXT: [[STRONG:%.*]] = alloca i8*
+ // CHECK-NEXT: [[TEMP:%.*]] = alloca i8*
+ // CHECK-NEXT: bitcast void (i8**)* {{%.*}} to i8*
+ // CHECK-NEXT: call i8* @objc_retain(
+ // CHECK-NEXT: bitcast i8*
+ // CHECK-NEXT: store void (i8**)* {{%.*}}, void (i8**)** [[SINK]]
+ // CHECK-NEXT: store i8* null, i8** [[STRONG]]
+
+ // CHECK-NEXT: load void (i8**)** [[SINK]]
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: [[BLOCK:%.*]] = bitcast
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[STRONG]]
+ // CHECK-NEXT: store i8* [[T0]], i8** [[TEMP]]
+ // CHECK-NEXT: [[F0:%.*]] = load i8**
+ // CHECK-NEXT: [[F1:%.*]] = bitcast i8* [[F0]] to void (i8*, i8**)*
+ // CHECK-NEXT: call void [[F1]](i8* [[BLOCK]], i8** [[TEMP]])
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[TEMP]]
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
+ // CHECK-NEXT: [[T2:%.*]] = load i8** [[STRONG]]
+ // CHECK-NEXT: store i8* [[T1]], i8** [[STRONG]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T2]])
+
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[STRONG]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+
+ // CHECK-NEXT: load void (i8**)** [[SINK]]
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: call void @objc_release
+ // CHECK-NEXT: ret void
+
+}
+
+void test4(void) {
+ id test4_source(void);
+ void test4_helper(void (^)(void));
+ __block id var = test4_source();
+ test4_helper(^{ var = 0; });
+
+ // CHECK: define void @test4()
+ // CHECK: [[VAR:%.*]] = alloca [[BYREF_T:%.*]],
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 2
+ // 0x02000000 - has copy/dispose helpers
+ // CHECK-NEXT: store i32 33554432, i32* [[T0]]
+ // CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 6
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @test4_source()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: store i8* [[T1]], i8** [[SLOT]]
+ // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 6
+ // 0x42000000 - has signature, copy/dispose helpers
+ // CHECK: store i32 1107296256,
+ // CHECK: [[T0:%.*]] = bitcast [[BYREF_T]]* [[VAR]] to i8*
+ // CHECK-NEXT: store i8* [[T0]], i8**
+ // CHECK: call void @test4_helper(
+ // CHECK: [[T0:%.*]] = bitcast [[BYREF_T]]* [[VAR]] to i8*
+ // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8)
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[SLOT]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: ret void
+
+ // CHECK: define internal void @__Block_byref_object_copy_
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
+ // CHECK-NEXT: load i8**
+ // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]*
+ // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
+ // CHECK-NEXT: [[T2:%.*]] = load i8** [[T1]]
+ // CHECK-NEXT: store i8* [[T2]], i8** [[T0]]
+ // CHECK-NEXT: store i8* null, i8** [[T1]]
+
+ // CHECK: define internal void @__Block_byref_object_dispose_
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
+ // CHECK-NEXT: [[T1:%.*]] = load i8** [[T0]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+
+ // CHECK: define internal void @__test4_block_invoke_
+ // CHECK: [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[SLOT]], align 8
+ // CHECK-NEXT: store i8* null, i8** [[SLOT]],
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: ret void
+
+ // CHECK: define internal void @__copy_helper_block_
+ // CHECK: call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8)
+
+ // CHECK: define internal void @__destroy_helper_block_
+ // CHECK: call void @_Block_object_dispose(i8* {{%.*}}, i32 8)
+}
+
+void test5(void) {
+ extern id test5_source(void);
+ void test5_helper(void (^)(void));
+ __unsafe_unretained id var = test5_source();
+ test5_helper(^{ (void) var; });
+
+ // CHECK: define void @test5()
+ // CHECK: [[VAR:%.*]] = alloca i8*
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+ // CHECK: [[T0:%.*]] = call i8* @test5_source()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: store i8* [[T1]], i8** [[VAR]],
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ // 0x40000000 - has signature but no copy/dispose
+ // CHECK: store i32 1073741824, i32*
+ // CHECK: [[CAPTURE:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[VAR]]
+ // CHECK-NEXT: store i8* [[T0]], i8** [[CAPTURE]]
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to
+ // CHECK: call void @test5_helper
+ // CHECK-NEXT: ret void
+}
+
+void test6(void) {
+ id test6_source(void);
+ void test6_helper(void (^)(void));
+ __block __weak id var = test6_source();
+ test6_helper(^{ var = 0; });
+
+ // CHECK: define void @test6()
+ // CHECK: [[VAR:%.*]] = alloca [[BYREF_T:%.*]],
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 2
+ // 0x02000000 - has copy/dispose helpers
+ // CHECK-NEXT: store i32 33554432, i32* [[T0]]
+ // CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 6
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @test6_source()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: call i8* @objc_initWeak(i8** [[SLOT]], i8* [[T1]])
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 6
+ // 0x42000000 - has signature, copy/dispose helpers
+ // CHECK: store i32 1107296256,
+ // CHECK: [[T0:%.*]] = bitcast [[BYREF_T]]* [[VAR]] to i8*
+ // CHECK-NEXT: store i8* [[T0]], i8**
+ // CHECK: call void @test6_helper(
+ // CHECK: [[T0:%.*]] = bitcast [[BYREF_T]]* [[VAR]] to i8*
+ // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8)
+ // CHECK-NEXT: call void @objc_destroyWeak(i8** [[SLOT]])
+ // CHECK-NEXT: ret void
+
+ // CHECK: define internal void @__Block_byref_object_copy_
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
+ // CHECK-NEXT: load i8**
+ // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]*
+ // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
+ // CHECK-NEXT: call void @objc_moveWeak(i8** [[T0]], i8** [[T1]])
+
+ // CHECK: define internal void @__Block_byref_object_dispose_
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
+ // CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]])
+
+ // CHECK: define internal void @__test6_block_invoke_
+ // CHECK: [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6
+ // CHECK-NEXT: call i8* @objc_storeWeak(i8** [[SLOT]], i8* null)
+ // CHECK-NEXT: ret void
+
+ // CHECK: define internal void @__copy_helper_block_
+ // 0x8 - FIELD_IS_BYREF (no FIELD_IS_WEAK because clang in control)
+ // CHECK: call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8)
+
+ // CHECK: define internal void @__destroy_helper_block_
+ // 0x8 - FIELD_IS_BYREF (no FIELD_IS_WEAK because clang in control)
+ // CHECK: call void @_Block_object_dispose(i8* {{%.*}}, i32 8)
+}
+
+void test7(void) {
+ id test7_source(void);
+ void test7_helper(void (^)(void));
+ void test7_consume(id);
+ __weak id var = test7_source();
+ test7_helper(^{ test7_consume(var); });
+
+ // CHECK: define void @test7()
+ // CHECK: [[VAR:%.*]] = alloca i8*,
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+ // CHECK: [[T0:%.*]] = call i8* @test7_source()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: call i8* @objc_initWeak(i8** [[VAR]], i8* [[T1]])
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ // 0x42000000 - has signature, copy/dispose helpers
+ // CHECK: store i32 1107296256,
+ // CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_loadWeak(i8** [[VAR]])
+ // CHECK-NEXT: call i8* @objc_initWeak(i8** [[SLOT]], i8* [[T0]])
+ // CHECK: call void @test7_helper(
+ // CHECK-NEXT: call void @objc_destroyWeak(i8** {{%.*}})
+ // CHECK-NEXT: call void @objc_destroyWeak(i8** [[VAR]])
+ // CHECK-NEXT: ret void
+
+ // CHECK: define internal void @__test7_block_invoke_
+ // CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BLOCK_T]]* {{%.*}}, i32 0, i32 5
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_loadWeak(i8** [[SLOT]])
+ // CHECK-NEXT: call void @test7_consume(i8* [[T0]])
+ // CHECK-NEXT: ret void
+
+ // CHECK: define internal void @__copy_helper_block_
+ // CHECK: getelementptr
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: call void @objc_copyWeak(
+
+ // CHECK: define internal void @__destroy_helper_block_
+ // CHECK: getelementptr
+ // CHECK-NEXT: call void @objc_destroyWeak(
+}
+
+@interface Test8 @end
+@implementation Test8
+- (void) test {
+// CHECK: define internal void @"\01-[Test8 test]"
+// CHECK: [[SELF:%.*]] = alloca [[TEST8:%.*]]*,
+// CHECK-NEXT: alloca i8*
+// CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+// CHECK: store
+// CHECK-NEXT: store
+// CHECK: [[D0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK-NEXT: [[T1:%.*]] = load [[TEST8]]** [[SELF]],
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST8]]* [[T1]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retain(i8* [[T2]])
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to [[TEST8]]*
+// CHECK-NEXT: store [[TEST8]]* [[T4]], [[TEST8]]** [[T0]]
+// CHECK-NEXT: bitcast [[BLOCK_T]]* [[BLOCK]] to
+// CHECK: call void @test8_helper(
+// CHECK-NEXT: [[T1:%.*]] = load [[TEST8]]** [[D0]]
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST8]]* [[T1]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T2]])
+// CHECK-NEXT: ret void
+
+ extern void test8_helper(void (^)(void));
+ test8_helper(^{ (void) self; });
+}
+@end
+
+id test9(void) {
+ typedef id __attribute__((ns_returns_retained)) blocktype(void);
+ extern void test9_consume_block(blocktype^);
+ return ^blocktype {
+ extern id test9_produce(void);
+ return test9_produce();
+ }();
+
+// CHECK: define i8* @test9(
+// CHECK: load i8** getelementptr
+// CHECK-NEXT: bitcast i8*
+// CHECK-NEXT: call i8*
+// CHECK-NEXT: call i8* @objc_autoreleaseReturnValue
+// CHECK-NEXT: ret i8*
+
+// CHECK: call i8* @test9_produce()
+// CHECK-NEXT: call i8* @objc_retain
+// CHECK-NEXT: ret i8*
+}
+
+// rdar://problem/9814099
+// Test that we correctly initialize __block variables
+// when the initialization captures the variable.
+void test10a(void) {
+ __block void (^block)(void) = ^{ block(); };
+ // CHECK: define void @test10a()
+ // CHECK: [[BYREF:%.*]] = alloca [[BYREF_T:%.*]],
+
+ // Zero-initialization before running the initializer.
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 6
+ // CHECK-NEXT: store void ()* null, void ()** [[T0]], align 8
+
+ // Run the initializer as an assignment.
+ // CHECK: [[T0:%.*]] = bitcast void ()* {{%.*}} to i8*
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainBlock(i8* [[T0]])
+ // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to void ()*
+ // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 1
+ // CHECK-NEXT: [[T4:%.*]] = load [[BYREF_T]]** [[T3]]
+ // CHECK-NEXT: [[T5:%.*]] = getelementptr inbounds [[BYREF_T]]* [[T4]], i32 0, i32 6
+ // CHECK-NEXT: [[T6:%.*]] = load void ()** [[T5]], align 8
+ // CHECK-NEXT: store void ()* {{%.*}}, void ()** [[T5]], align 8
+ // CHECK-NEXT: [[T7:%.*]] = bitcast void ()* [[T6]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T7]])
+
+ // Destroy at end of function.
+ // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 6
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [[BYREF_T]]* [[BYREF]] to i8*
+ // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8)
+ // CHECK-NEXT: [[T1:%.*]] = load void ()** [[SLOT]]
+ // CHECK-NEXT: [[T2:%.*]] = bitcast void ()* [[T1]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T2]])
+ // CHECK-NEXT: ret void
+}
+
+// <rdar://problem/10402698>: do this copy and dispose with
+// objc_retainBlock/release instead of _Block_object_assign/destroy.
+// We can also use _Block_object_assign/destroy with
+// BLOCK_FIELD_IS_BLOCK as long as we don't pass BLOCK_BYREF_CALLER.
+
+// CHECK: define internal void @__Block_byref_object_copy
+// CHECK: [[D0:%.*]] = load i8** {{%.*}}
+// CHECK-NEXT: [[D1:%.*]] = bitcast i8* [[D0]] to [[BYREF_T]]*
+// CHECK-NEXT: [[D2:%.*]] = getelementptr inbounds [[BYREF_T]]* [[D1]], i32 0, i32 6
+// CHECK-NEXT: [[S0:%.*]] = load i8** {{%.*}}
+// CHECK-NEXT: [[S1:%.*]] = bitcast i8* [[S0]] to [[BYREF_T]]*
+// CHECK-NEXT: [[S2:%.*]] = getelementptr inbounds [[BYREF_T]]* [[S1]], i32 0, i32 6
+// CHECK-NEXT: [[T0:%.*]] = load void ()** [[S2]], align 8
+// CHECK-NEXT: [[T1:%.*]] = bitcast void ()* [[T0]] to i8*
+// CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainBlock(i8* [[T1]])
+// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to void ()*
+// CHECK-NEXT: store void ()* [[T3]], void ()** [[D2]], align 8
+// CHECK-NEXT: ret void
+
+// CHECK: define internal void @__Block_byref_object_dispose
+// CHECK: [[T0:%.*]] = load i8** {{%.*}}
+// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[BYREF_T]]*
+// CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[BYREF_T]]* [[T1]], i32 0, i32 6
+// CHECK-NEXT: [[T3:%.*]] = load void ()** [[T2]], align 8
+// CHECK-NEXT: [[T4:%.*]] = bitcast void ()* [[T3]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T4]])
+// CHECK-NEXT: ret void
+
+// Test that we correctly assign to __block variables when the
+// assignment captures the variable.
+void test10b(void) {
+ __block void (^block)(void);
+ block = ^{ block(); };
+
+ // CHECK: define void @test10b()
+ // CHECK: [[BYREF:%.*]] = alloca [[BYREF_T:%.*]],
+
+ // Zero-initialize.
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 6
+ // CHECK-NEXT: store void ()* null, void ()** [[T0]], align 8
+
+ // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 6
+
+ // The assignment.
+ // CHECK: [[T0:%.*]] = bitcast void ()* {{%.*}} to i8*
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainBlock(i8* [[T0]])
+ // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to void ()*
+ // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 1
+ // CHECK-NEXT: [[T4:%.*]] = load [[BYREF_T]]** [[T3]]
+ // CHECK-NEXT: [[T5:%.*]] = getelementptr inbounds [[BYREF_T]]* [[T4]], i32 0, i32 6
+ // CHECK-NEXT: [[T6:%.*]] = load void ()** [[T5]], align 8
+ // CHECK-NEXT: store void ()* {{%.*}}, void ()** [[T5]], align 8
+ // CHECK-NEXT: [[T7:%.*]] = bitcast void ()* [[T6]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T7]])
+
+ // Destroy at end of function.
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [[BYREF_T]]* [[BYREF]] to i8*
+ // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8)
+ // CHECK-NEXT: [[T1:%.*]] = load void ()** [[SLOT]]
+ // CHECK-NEXT: [[T2:%.*]] = bitcast void ()* [[T1]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T2]])
+ // CHECK-NEXT: ret void
+}
+
+// rdar://problem/10088932
+void test11_helper(id);
+void test11a(void) {
+ int x;
+ test11_helper(^{ (void) x; });
+
+ // CHECK: define void @test11a()
+ // CHECK: [[X:%.*]] = alloca i32, align 4
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]], align 8
+ // CHECK: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to void ()*
+ // CHECK-NEXT: [[T1:%.*]] = bitcast void ()* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainBlock(i8* [[T1]])
+ // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to void ()*
+ // CHECK-NEXT: [[T4:%.*]] = bitcast void ()* [[T3]] to i8*
+ // CHECK-NEXT: call void @test11_helper(i8* [[T4]])
+ // CHECK-NEXT: [[T5:%.*]] = bitcast void ()* [[T3]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T5]])
+ // CHECK-NEXT: ret void
+}
+void test11b(void) {
+ int x;
+ id b = ^{ (void) x; };
+
+ // CHECK: define void @test11b()
+ // CHECK: [[X:%.*]] = alloca i32, align 4
+ // CHECK-NEXT: [[B:%.*]] = alloca i8*, align 8
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]], align 8
+ // CHECK: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to void ()*
+ // CHECK-NEXT: [[T1:%.*]] = bitcast void ()* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainBlock(i8* [[T1]])
+ // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to void ()*
+ // CHECK-NEXT: [[T4:%.*]] = bitcast void ()* [[T3]] to i8*
+ // CHECK-NEXT: store i8* [[T4]], i8** [[B]], align 8
+ // CHECK-NEXT: [[T5:%.*]] = load i8** [[B]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T5]])
+ // CHECK-NEXT: ret void
+}
+
+// rdar://problem/9979150
+@interface Test12
+@property (strong) void(^ablock)(void);
+@property (nonatomic, strong) void(^nblock)(void);
+@end
+@implementation Test12
+@synthesize ablock, nblock;
+// CHECK: define internal void ()* @"\01-[Test12 ablock]"(
+// CHECK: call i8* @objc_getProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i1 zeroext true)
+
+// CHECK: define internal void @"\01-[Test12 setAblock:]"(
+// CHECK: call void @objc_setProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i8* {{%.*}}, i1 zeroext true, i1 zeroext true)
+
+// CHECK: define internal void ()* @"\01-[Test12 nblock]"(
+// CHECK: call i8* @objc_getProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i1 zeroext false)
+
+// CHECK: define internal void @"\01-[Test12 setNblock:]"(
+// CHECK: call void @objc_setProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i8* {{%.*}}, i1 zeroext false, i1 zeroext true)
+@end
+
+// rdar://problem/10131784
+void test13(id x) {
+ extern void test13_helper(id);
+ extern void test13_use(void(^)(void));
+
+ void (^b)(void) = (x ? ^{test13_helper(x);} : 0);
+ test13_use(b);
+
+ // CHECK: define void @test13(
+ // CHECK: [[X:%.*]] = alloca i8*, align 8
+ // CHECK-NEXT: [[B:%.*]] = alloca void ()*, align 8
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:.*]], align 8
+ // CHECK-NEXT: [[CLEANUP_ACTIVE:%.*]] = alloca i1
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_retain(i8* {{%.*}})
+ // CHECK-NEXT: store i8* [[T0]], i8** [[X]], align 8
+ // CHECK-NEXT: [[CLEANUP_ADDR:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[X]], align 8
+ // CHECK-NEXT: [[T1:%.*]] = icmp ne i8* [[T0]], null
+ // CHECK-NEXT: store i1 false, i1* [[CLEANUP_ACTIVE]]
+ // CHECK-NEXT: br i1 [[T1]],
+
+ // CHECK-NOT: br
+ // CHECK: [[CAPTURE:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[X]], align 8
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
+ // CHECK-NEXT: store i8* [[T1]], i8** [[CAPTURE]], align 8
+ // CHECK-NEXT: store i1 true, i1* [[CLEANUP_ACTIVE]]
+ // CHECK-NEXT: bitcast [[BLOCK_T]]* [[BLOCK]] to void ()*
+ // CHECK-NEXT: br label
+ // CHECK: br label
+ // CHECK: [[T0:%.*]] = phi void ()*
+ // CHECK-NEXT: [[T1:%.*]] = bitcast void ()* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainBlock(i8* [[T1]])
+ // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to void ()*
+ // CHECK-NEXT: store void ()* [[T3]], void ()** [[B]], align 8
+ // CHECK-NEXT: [[T0:%.*]] = load void ()** [[B]], align 8
+ // CHECK-NEXT: call void @test13_use(void ()* [[T0]])
+ // CHECK-NEXT: [[T0:%.*]] = load void ()** [[B]]
+ // CHECK-NEXT: [[T1:%.*]] = bitcast void ()* [[T0]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+
+ // CHECK-NEXT: [[T0:%.*]] = load i1* [[CLEANUP_ACTIVE]]
+ // CHECK-NEXT: br i1 [[T0]]
+ // CHECK: [[T0:%.*]] = load i8** [[CLEANUP_ADDR]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: br label
+
+ // CHECK: [[T0:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: ret void
+}
+
+// <rdar://problem/10907510>
+void test14() {
+ void (^const x[1])(void) = { ^{} };
+}
+
+// rdar://11149025
+// Don't make invalid ASTs and crash.
+void test15_helper(void (^block)(void), int x);
+void test15(int a) {
+ test15_helper(^{ (void) a; }, ({ a; }));
+}
diff --git a/clang/test/CodeGenObjC/arc-bridged-cast.m b/clang/test/CodeGenObjC/arc-bridged-cast.m
new file mode 100644
index 0000000..eb9045d
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-bridged-cast.m
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+
+typedef const void *CFTypeRef;
+typedef const struct __CFString *CFStringRef;
+
+@interface NSString
+@end
+
+CFTypeRef CFCreateSomething(void);
+CFStringRef CFCreateString(void);
+CFTypeRef CFGetSomething(void);
+CFStringRef CFGetString(void);
+
+id CreateSomething(void);
+NSString *CreateNSString(void);
+
+// CHECK: define void @bridge_transfer_from_cf
+void bridge_transfer_from_cf(int *i) {
+ // CHECK: store i32 7
+ *i = 7;
+ // CHECK: call i8* @CFCreateSomething()
+ id obj1 = (__bridge_transfer id)CFCreateSomething();
+ // CHECK-NOT: retain
+ // CHECK: store i32 11
+ *i = 11;
+ // CHECK: call i8* @CFCreateSomething()
+ // CHECK-NOT: retain
+ // CHECK: store i32 13
+ (void)(__bridge_transfer id)CFCreateSomething(), *i = 13;
+ // CHECK: call void @objc_release
+ // CHECK: store i32 17
+ *i = 17;
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @bridge_from_cf
+void bridge_from_cf(int *i) {
+ // CHECK: store i32 7
+ *i = 7;
+ // CHECK: call i8* @CFCreateSomething()
+ id obj1 = (__bridge id)CFCreateSomething();
+ // CHECK: objc_retainAutoreleasedReturnValue
+ // CHECK: store i32 11
+ *i = 11;
+ // CHECK: call i8* @CFCreateSomething()
+ // CHECK-NOT: release
+ // CHECK: store i32 13
+ (void)(__bridge id)CFCreateSomething(), *i = 13;
+ // CHECK: store i32 17
+ *i = 17;
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @bridge_retained_of_cf
+void bridge_retained_of_cf(int *i) {
+ *i = 7;
+ // CHECK: call i8* @CreateSomething()
+ CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething();
+ // CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue
+ // CHECK: store i32 11
+ *i = 11;
+ // CHECK: call i8* @CreateSomething()
+ (__bridge_retained CFTypeRef)CreateSomething(), *i = 13;
+ // CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue
+ // CHECK: store i32 13
+ // CHECK: store i32 17
+ *i = 17;
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @bridge_of_cf
+void bridge_of_cf(int *i) {
+ // CHECK: store i32 7
+ *i = 7;
+ // CHECK: call i8* @CreateSomething()
+ CFTypeRef cf1 = (__bridge CFTypeRef)CreateSomething();
+ // CHECK-NOT: retain
+ // CHECK: store i32 11
+ *i = 11;
+ // CHECK: call i8* @CreateSomething
+ (__bridge CFTypeRef)CreateSomething(), *i = 13;
+ // CHECK: store i32 13
+ // CHECK-NOT: release
+ // CHECK: store i32 17
+ *i = 17;
+ // CHECK-NEXT: ret void
+}
+
diff --git a/clang/test/CodeGenObjC/arc-compound-stmt.m b/clang/test/CodeGenObjC/arc-compound-stmt.m
new file mode 100644
index 0000000..573ee44
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-compound-stmt.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -o - %s
+// rdar://9694706
+
+typedef unsigned long NSUInteger;
+
+@interface NSString
+- (NSString *)stringByAppendingString:(NSString *)aString;
+- (NSString *)substringFromIndex:(NSUInteger)from;
+@end
+
+@interface MyClass
+- (void)inst;
+@end
+
+@implementation MyClass
+
+- (void)inst;
+{
+ NSString *propName;
+
+ NSString *capitalPropName = ({
+ NSString *cap;
+ if (propName)
+ cap = [cap stringByAppendingString:[propName substringFromIndex:1]];
+ cap;
+ });
+}
+
+@end
diff --git a/clang/test/CodeGenObjC/arc-cond-stmt.m b/clang/test/CodeGenObjC/arc-cond-stmt.m
new file mode 100644
index 0000000..d8ee6bb
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-cond-stmt.m
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -o - %s
+// rdar://10327068
+
+@class NSString;
+
+@interface NSAssertionHandler {
+}
+
++ (NSAssertionHandler *)currentHandler;
+
+- (void)handleFailureInMethod:(SEL)selector object:(id)object file:(NSString *)fileName lineNumber:(int)line ,...;
+
+@end
+
+typedef enum
+{
+ MWRaceOrder_MeetName,
+ MWRaceOrder_MeetPosition,
+ MWRaceOrder_MeetDistance,
+ MWRaceOrder_Name,
+ MWRaceOrder_Position,
+ MWRaceOrder_Distance,
+ MWRaceOrder_Default = MWRaceOrder_Name,
+ MWRaceOrder_MeetDefault = MWRaceOrder_MeetName,
+} MWRaceOrder;
+
+@interface MWViewMeetController
+@property (nonatomic, assign) MWRaceOrder raceOrder;
+@end
+
+@implementation MWViewMeetController
+
+- (int)orderSegment
+{
+ switch (self.raceOrder)
+ {
+
+ default:
+ { [(NSAssertionHandler *)0 handleFailureInMethod:_cmd object:self file:(NSString*)0 lineNumber:192 ]; };
+ break;
+ }
+
+ return 0;
+}
+
+@synthesize raceOrder;
+
+@end
diff --git a/clang/test/CodeGenObjC/arc-exceptions.m b/clang/test/CodeGenObjC/arc-exceptions.m
new file mode 100644
index 0000000..5ef5aba
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-exceptions.m
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fexceptions -fobjc-exceptions -fobjc-runtime-has-weak -o - %s | FileCheck %s
+
+@class Ety;
+
+// These first two tests are all PR11732 / rdar://problem/10667070.
+
+void test0_helper(void);
+void test0(void) {
+ @try {
+ test0_helper();
+ } @catch (Ety *e) {
+ }
+}
+// CHECK: define void @test0()
+// CHECK: [[E:%.*]] = alloca [[ETY:%.*]]*, align 8
+// CHECK-NEXT: invoke void @test0_helper()
+// CHECK: [[T0:%.*]] = call i8* @objc_begin_catch(
+// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[ETY]]*
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[ETY]]* [[T1]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retain(i8* [[T2]]) nounwind
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to [[ETY]]*
+// CHECK-NEXT: store [[ETY]]* [[T4]], [[ETY]]** [[E]]
+// CHECK-NEXT: [[T0:%.*]] = load [[ETY]]** [[E]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[ETY]]* [[T0]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind
+// CHECK-NEXT: call void @objc_end_catch() nounwind
+
+void test1_helper(void);
+void test1(void) {
+ @try {
+ test1_helper();
+ } @catch (__weak Ety *e) {
+ }
+}
+// CHECK: define void @test1()
+// CHECK: [[E:%.*]] = alloca [[ETY:%.*]]*, align 8
+// CHECK-NEXT: invoke void @test1_helper()
+// CHECK: [[T0:%.*]] = call i8* @objc_begin_catch(
+// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[ETY]]*
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[ETY]]** [[E]] to i8**
+// CHECK-NEXT: [[T3:%.*]] = bitcast [[ETY]]* [[T1]] to i8*
+// CHECK-NEXT: call i8* @objc_initWeak(i8** [[T2]], i8* [[T3]]) nounwind
+// CHECK-NEXT: [[T0:%.*]] = bitcast [[ETY]]** [[E]] to i8**
+// CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]]) nounwind
+// CHECK-NEXT: call void @objc_end_catch() nounwind
diff --git a/clang/test/CodeGenObjC/arc-foreach.m b/clang/test/CodeGenObjC/arc-foreach.m
new file mode 100644
index 0000000..67fad4d
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-foreach.m
@@ -0,0 +1,173 @@
+// RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak -triple x86_64-apple-darwin -O0 -emit-llvm %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// rdar://9503326
+// rdar://9606600
+
+extern void use(id);
+extern void use_block(void (^)(void));
+
+struct NSFastEnumerationState;
+@interface NSArray
+- (unsigned long) countByEnumeratingWithState: (struct NSFastEnumerationState*) state
+ objects: (id*) buffer
+ count: (unsigned long) bufferSize;
+@end;
+
+void test0(NSArray *array) {
+ // 'x' should be initialized without a retain.
+ // We should actually do a non-constant capture, and that
+ // capture should require a retain.
+ for (id x in array) {
+ use_block(^{ use(x); });
+ }
+}
+
+// CHECK-LP64: define void @test0(
+// CHECK-LP64: [[ARRAY:%.*]] = alloca [[ARRAY_T:%.*]]*,
+// CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
+// CHECK-LP64-NEXT: [[STATE:%.*]] = alloca [[STATE_T:%.*]],
+// CHECK-LP64-NEXT: [[BUFFER:%.*]] = alloca [16 x i8*], align 8
+// CHECK-LP64-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+
+// Initialize 'array'.
+// CHECK-LP64-NEXT: [[T0:%.*]] = bitcast [[ARRAY_T:%.*]]* {{%.*}} to i8*
+// CHECK-LP64-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
+// CHECK-LP64-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to [[ARRAY_T]]*
+// CHECK-LP64-NEXT: store [[ARRAY_T]]* [[T2]], [[ARRAY_T]]** [[ARRAY]], align 8
+
+// Initialize the fast enumaration state.
+// CHECK-LP64-NEXT: [[T0:%.*]] = bitcast [[STATE_T]]* [[STATE]] to i8*
+// CHECK-LP64-NEXT: call void @llvm.memset.p0i8.i64(i8* [[T0]], i8 0, i64 64, i32 8, i1 false)
+
+// Evaluate the collection expression and retain.
+// CHECK-LP64-NEXT: [[T0:%.*]] = load [[ARRAY_T]]** [[ARRAY]], align 8
+// CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[ARRAY_T]]* [[T0]] to i8*
+// CHECK-LP64-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]])
+// CHECK-LP64-NEXT: [[SAVED_ARRAY:%.*]] = bitcast i8* [[T2]] to [[ARRAY_T]]*
+
+// Call the enumeration method.
+// CHECK-LP64-NEXT: [[T0:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[ARRAY_T]]* [[SAVED_ARRAY]] to i8*
+// CHECK-LP64-NEXT: [[SIZE:%.*]] = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, [[STATE_T]]*, [16 x i8*]*, i64)*)(i8* [[T1]], i8* [[T0]], [[STATE_T]]* [[STATE]], [16 x i8*]* [[BUFFER]], i64 16)
+
+// Check for a nonzero result.
+// CHECK-LP64-NEXT: [[T0:%.*]] = icmp eq i64 [[SIZE]], 0
+// CHECK-LP64-NEXT: br i1 [[T0]]
+
+// CHECK-LP64: [[T0:%.*]] = getelementptr inbounds [[STATE_T]]* [[STATE]], i32 0, i32 1
+// CHECK-LP64-NEXT: [[T1:%.*]] = load i8*** [[T0]]
+// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr i8** [[T1]], i64
+// CHECK-LP64-NEXT: [[T3:%.*]] = load i8** [[T2]]
+// CHECK-LP64-NEXT: store i8* [[T3]], i8** [[X]]
+
+// CHECK-LP64: [[D0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK-LP64: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK-LP64-NEXT: [[T1:%.*]] = load i8** [[X]]
+// CHECK-LP64-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]])
+// CHECK-LP64-NEXT: store i8* [[T2]], i8** [[T0]]
+// CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]]
+// CHECK-LP64: call void @use_block(
+// CHECK-LP64-NEXT: [[T1:%.*]] = load i8** [[D0]]
+// CHECK-LP64-NEXT: call void @objc_release(i8* [[T1]])
+
+// CHECK-LP64: [[T0:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[ARRAY_T]]* [[SAVED_ARRAY]] to i8*
+// CHECK-LP64-NEXT: [[SIZE:%.*]] = call i64 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i64 (i8*, i8*, [[STATE_T]]*, [16 x i8*]*, i64)*)(i8* [[T1]], i8* [[T0]], [[STATE_T]]* [[STATE]], [16 x i8*]* [[BUFFER]], i64 16)
+
+// Release the array.
+// CHECK-LP64: [[T0:%.*]] = bitcast [[ARRAY_T]]* [[SAVED_ARRAY]] to i8*
+// CHECK-LP64-NEXT: call void @objc_release(i8* [[T0]])
+
+// Destroy 'array'.
+// CHECK-LP64: [[T0:%.*]] = load [[ARRAY_T]]** [[ARRAY]]
+// CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[ARRAY_T]]* [[T0]] to i8*
+// CHECK-LP64-NEXT: call void @objc_release(i8* [[T1]])
+// CHECK-LP64-NEXT: ret void
+
+// CHECK-LP64: define internal void @__test0_block_invoke
+// CHECK-LP64: [[BLOCK:%.*]] = bitcast i8* {{%.*}} to [[BLOCK_T]]*
+// CHECK-LP64-NEXT: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK-LP64-NEXT: [[T2:%.*]] = load i8** [[T0]], align 8
+// CHECK-LP64-NEXT: call void @use(i8* [[T2]])
+
+void test1(NSArray *array) {
+ for (__weak id x in array) {
+ use_block(^{ use(x); });
+ }
+}
+
+// CHECK-LP64: define void @test1(
+// CHECK-LP64: alloca [[ARRAY_T:%.*]]*,
+// CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
+// CHECK-LP64-NEXT: [[STATE:%.*]] = alloca [[STATE_T:%.*]],
+// CHECK-LP64-NEXT: alloca [16 x i8*], align 8
+// CHECK-LP64-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+
+// CHECK-LP64: [[T0:%.*]] = getelementptr inbounds [[STATE_T]]* [[STATE]], i32 0, i32 1
+// CHECK-LP64-NEXT: [[T1:%.*]] = load i8*** [[T0]]
+// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr i8** [[T1]], i64
+// CHECK-LP64-NEXT: [[T3:%.*]] = load i8** [[T2]]
+// CHECK-LP64-NEXT: call i8* @objc_initWeak(i8** [[X]], i8* [[T3]])
+
+// CHECK-LP64: [[D0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK-LP64: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK-LP64-NEXT: [[T1:%.*]] = call i8* @objc_loadWeak(i8** [[X]])
+// CHECK-LP64-NEXT: call i8* @objc_initWeak(i8** [[T0]], i8* [[T1]])
+// CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to
+// CHECK-LP64: call void @use_block
+// CHECK-LP64-NEXT: call void @objc_destroyWeak(i8** [[D0]])
+// CHECK-LP64-NEXT: call void @objc_destroyWeak(i8** [[X]])
+
+// rdar://problem/9817306
+@interface Test2
+- (NSArray *) array;
+@end
+void test2(Test2 *a) {
+ for (id x in a.array) {
+ use(x);
+ }
+}
+
+// CHECK-LP64: define void @test2(
+// CHECK-LP64: [[T0:%.*]] = call [[ARRAY_T]]* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to [[ARRAY_T]]* (i8*, i8*)*)(
+// CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[ARRAY_T]]* [[T0]] to i8*
+// CHECK-LP64-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
+// CHECK-LP64-NEXT: [[COLL:%.*]] = bitcast i8* [[T2]] to [[ARRAY_T]]*
+
+// Make sure it's not immediately released before starting the iteration.
+// CHECK-LP64-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK-LP64-NEXT: [[T0:%.*]] = bitcast [[ARRAY_T]]* [[COLL]] to i8*
+// CHECK-LP64-NEXT: @objc_msgSend
+
+// This bitcast is for the mutation check.
+// CHECK-LP64: [[T0:%.*]] = bitcast [[ARRAY_T]]* [[COLL]] to i8*
+// CHECK-LP64-NEXT: @objc_enumerationMutation
+
+// This bitcast is for the 'next' message send.
+// CHECK-LP64: [[T0:%.*]] = bitcast [[ARRAY_T]]* [[COLL]] to i8*
+// CHECK-LP64-NEXT: @objc_msgSend
+
+// This bitcast is for the final release.
+// CHECK-LP64: [[T0:%.*]] = bitcast [[ARRAY_T]]* [[COLL]] to i8*
+// CHECK-LP64-NEXT: call void @objc_release(i8* [[T0]])
+
+
+// Check that the 'continue' label is positioned appropriately
+// relative to the collection clenaup.
+void test3(NSArray *array) {
+ for (id x in array) {
+ if (!x) continue;
+ use(x);
+ }
+
+ // CHECK-LP64: define void @test3(
+ // CHECK-LP64: [[ARRAY:%.*]] = alloca [[ARRAY_T]]*, align 8
+ // CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*, align 8
+ // CHECK-LP64: [[T0:%.*]] = load i8** [[X]], align 8
+ // CHECK-LP64-NEXT: [[T1:%.*]] = icmp ne i8* [[T0]], null
+ // CHECK-LP64-NEXT: br i1 [[T1]],
+ // CHECK-LP64: br label [[L:%[^ ]+]]
+ // CHECK-LP64: [[T0:%.*]] = load i8** [[X]], align 8
+ // CHECK-LP64-NEXT: call void @use(i8* [[T0]])
+ // CHECK-LP64-NEXT: br label [[L]]
+}
diff --git a/clang/test/CodeGenObjC/arc-ivar-layout.m b/clang/test/CodeGenObjC/arc-ivar-layout.m
new file mode 100644
index 0000000..7f58a0c
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-ivar-layout.m
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -triple x86_64-apple-darwin -O0 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// rdar://8991729
+
+@interface NSObject {
+ id isa;
+}
+@end
+
+@interface AllPointers : NSObject {
+ id foo;
+ id __strong bar;
+ NSObject *bletch;
+}
+@end
+
+@implementation AllPointers
+@end
+// CHECK-LP64: L_OBJC_CLASS_NAME_1:
+// CHECK-LP64-NEXT: .asciz "\003"
+
+@class NSString, NSNumber;
+@interface A : NSObject {
+ NSString *foo;
+ NSNumber *bar;
+ unsigned int bletch;
+ __weak id delegate;
+}
+@end
+
+@interface B : A {
+ unsigned int x;
+ NSString *y;
+ NSString *z;
+}
+@end
+
+@implementation A @end
+
+@implementation B @end
+
+// CHECK-LP64: L_OBJC_CLASS_NAME_15:
+// CHECK-LP64-NEXT: .asciz "\022"
+
+@interface UnsafePerson {
+@public
+ __unsafe_unretained id name;
+ __unsafe_unretained id age;
+ id value;
+}
+@end
+
+@implementation UnsafePerson @end
+// CHECK-LP64: L_OBJC_CLASS_NAME_20:
+// CHECK-LP64-NEXT: .asciz "!"
diff --git a/clang/test/CodeGenObjC/arc-literals.m b/clang/test/CodeGenObjC/arc-literals.m
new file mode 100644
index 0000000..203c2ad
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-literals.m
@@ -0,0 +1,121 @@
+// RUN: %clang_cc1 -I %S/Inputs -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+
+#include "literal-support.h"
+
+// Check the various selector names we'll be using, in order.
+
+// CHECK: c"numberWithInt:\00"
+// CHECK: c"numberWithUnsignedInt:\00"
+// CHECK: c"numberWithUnsignedLongLong:\00"
+// CHECK: c"numberWithChar:\00"
+// CHECK: c"arrayWithObjects:count:\00"
+// CHECK: c"dictionaryWithObjects:forKeys:count:\00"
+// CHECK: c"prop\00"
+
+// CHECK: define void @test_numeric()
+void test_numeric() {
+ // CHECK: {{call.*objc_msgSend.*i32 17}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id ilit = @17;
+ // CHECK: {{call.*objc_msgSend.*i32 25}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id ulit = @25u;
+ // CHECK: {{call.*objc_msgSend.*i64 42}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id ulllit = @42ull;
+ // CHECK: {{call.*objc_msgSend.*i8 signext 97}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id charlit = @'a';
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @test_array
+void test_array(id a, id b) {
+ // Retaining parameters
+ // CHECK: call i8* @objc_retain(i8*
+ // CHECK: call i8* @objc_retain(i8*
+
+ // Constructing the array
+ // CHECK: getelementptr inbounds [2 x i8*]* [[OBJECTS:%[A-Za-z0-9]+]], i32 0, i32 0
+ // CHECK: store i8*
+ // CHECK: getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 1
+ // CHECK: store i8*
+
+ // CHECK: {{call i8*.*objc_msgSend.*i64 2}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id arr = @[a, b];
+
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @test_dictionary
+void test_dictionary(id k1, id o1, id k2, id o2) {
+ // Retaining parameters
+ // CHECK: call i8* @objc_retain(i8*
+ // CHECK: call i8* @objc_retain(i8*
+ // CHECK: call i8* @objc_retain(i8*
+ // CHECK: call i8* @objc_retain(i8*
+
+ // Constructing the arrays
+ // CHECK: getelementptr inbounds [2 x i8*]* [[KEYS:%[A-Za-z0-9]+]], i32 0, i32 0
+ // CHECK: store i8*
+ // CHECK: getelementptr inbounds [2 x i8*]* [[OBJECTS:%[A-Za-z0-9]+]], i32 0, i32 0
+ // CHECK: store i8*
+ // CHECK: getelementptr inbounds [2 x i8*]* [[KEYS]], i32 0, i32 1
+ // CHECK: store i8*
+ // CHECK: getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 1
+ // CHECK: store i8*
+
+ // Constructing the dictionary
+ // CHECK: {{call i8.*@objc_msgSend}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id dict = @{ k1 : o1, k2 : o2 };
+
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+}
+
+@interface A
+@end
+
+@interface B
+@property (retain) A* prop;
+@end
+
+// CHECK: define void @test_property
+void test_property(B *b) {
+ // Retain parameter
+ // CHECK: call i8* @objc_retain
+
+ // Invoke 'prop'
+ // CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+ // CHECK: {{call.*@objc_msgSend}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+
+ // Invoke arrayWithObjects:count:
+ // CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+ // CHECK: {{call.*objc_msgSend}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id arr = @[ b.prop ];
+
+ // Release b.prop
+ // CHECK: call void @objc_release
+
+ // Destroy arr
+ // CHECK: call void @objc_release
+
+ // Destroy b
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+}
diff --git a/clang/test/CodeGenObjC/arc-no-arc-exceptions.m b/clang/test/CodeGenObjC/arc-no-arc-exceptions.m
new file mode 100644
index 0000000..7ae061f
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-no-arc-exceptions.m
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fblocks -fexceptions -fobjc-exceptions -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fblocks -fexceptions -fobjc-exceptions -O0 -disable-llvm-optzns -o - %s | FileCheck -check-prefix=NO-METADATA %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fblocks -fexceptions -fobjc-exceptions -O2 -disable-llvm-optzns -o - %s -fobjc-arc-exceptions | FileCheck -check-prefix=NO-METADATA %s
+
+// The front-end should emit clang.arc.no_objc_arc_exceptions in -fobjc-arc-exceptions
+// mode when optimization is enabled, and not otherwise.
+
+void thrower(void);
+void not(void) __attribute__((nothrow));
+
+// CHECK: define void @test0(
+// CHECK: call void @thrower(), !clang.arc.no_objc_arc_exceptions !
+// CHECK: call void @not() nounwind, !clang.arc.no_objc_arc_exceptions !
+// NO-METADATA: define void @test0(
+// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
+// NO-METADATA: }
+void test0(void) {
+ thrower();
+ not();
+}
+
+// CHECK: define void @test1(
+// CHECK: call void @thrower(), !clang.arc.no_objc_arc_exceptions !
+// CHECK: call void @not() nounwind, !clang.arc.no_objc_arc_exceptions !
+// NO-METADATA: define void @test1(
+// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
+// NO-METADATA: }
+void test1(id x) {
+ id y = x;
+ thrower();
+ not();
+}
+
+void NSLog(id, ...);
+
+// CHECK: define void @test2(
+// CHECK: invoke void (i8*, ...)* @NSLog(i8* bitcast (%struct.NSConstantString* @_unnamed_cfstring_ to i8*), i32* %{{.*}})
+// CHECK: to label %{{.*}} unwind label %{{.*}}, !clang.arc.no_objc_arc_exceptions !
+// NO-METADATA: define void @test2(
+// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
+// NO-METADATA: }
+void test2(void) {
+ @autoreleasepool {
+ __attribute__((__blocks__(byref))) int x;
+ NSLog(@"Address of x outside of block: %p", &x);
+ }
+}
+
+// CHECK: define void @test3(
+// CHECK: invoke void %{{.*}}(i8* %{{.*}})
+// CHECK: to label %{{.*}} unwind label %{{.*}}, !clang.arc.no_objc_arc_exceptions !
+// NO-METADATA: define void @test3(
+// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
+// NO-METADATA: }
+void test3(void) {
+ @autoreleasepool {
+ __attribute__((__blocks__(byref))) int x;
+ ^{
+ NSLog(@"Address of x in non-assigned block: %p", &x);
+ }();
+ }
+}
+
+// CHECK: define void @test4(
+// CHECK: invoke void %{{.*}}(i8* %{{.*}})
+// CHECK: to label %{{.*}} unwind label %{{.*}}, !clang.arc.no_objc_arc_exceptions !
+// NO-METADATA: define void @test4(
+// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
+// NO-METADATA: }
+void test4(void) {
+ @autoreleasepool {
+ __attribute__((__blocks__(byref))) int x;
+ void (^b)(void) = ^{
+ NSLog(@"Address of x in assigned block: %p", &x);
+ };
+ b();
+ }
+}
diff --git a/clang/test/CodeGenObjC/arc-no-runtime.m b/clang/test/CodeGenObjC/arc-no-runtime.m
new file mode 100644
index 0000000..3c85e87
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-no-runtime.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -emit-llvm %s -o - | FileCheck %s
+
+// rdar://problem/9224855
+void test0() {
+ id x = 0;
+ // CHECK: call void @objc_release(
+}
+
+// CHECK: declare extern_weak void @objc_release(
diff --git a/clang/test/CodeGenObjC/arc-property.m b/clang/test/CodeGenObjC/arc-property.m
new file mode 100644
index 0000000..6c5180b
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-property.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -emit-llvm %s -o - | FileCheck %s
+
+// rdar://problem/10290317
+@interface Test0
+- (void) setValue: (id) x;
+@end
+void test0(Test0 *t0, id value) {
+ t0.value = value;
+}
+// CHECK: define void @test0(
+// CHECK: call i8* @objc_retain(
+// CHECK: call i8* @objc_retain(
+// CHECK: @objc_msgSend
+// CHECK: call void @objc_release(
+// CHECK: call void @objc_release(
diff --git a/clang/test/CodeGenObjC/arc-related-result-type.m b/clang/test/CodeGenObjC/arc-related-result-type.m
new file mode 100644
index 0000000..f73aa50
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-related-result-type.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -o - %s | FileCheck %s
+
+@interface Test0
+- (id) self;
+@end
+void test0(Test0 *val) {
+ Test0 *x = [val self];
+
+// CHECK: define void @test0(
+// CHECK: [[VAL:%.*]] = alloca [[TEST0:%.*]]*
+// CHECK-NEXT: [[X:%.*]] = alloca [[TEST0]]*
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: call i8* @objc_retain(
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: store
+// CHECK-NEXT: load [[TEST0]]** [[VAL]],
+// CHECK-NEXT: load
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: [[T0:%.*]] = call i8* bitcast (
+// CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+// CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to [[TEST0]]*
+// CHECK-NEXT: store [[TEST0]]* [[T2]], [[TEST0]]** [[X]]
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST0]]** [[X]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST0]]* [[T0]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T1]])
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST0]]** [[VAL]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST0]]* [[T0]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T1]])
+// CHECK-NEXT: ret void
+}
diff --git a/clang/test/CodeGenObjC/arc-unbridged-cast.m b/clang/test/CodeGenObjC/arc-unbridged-cast.m
new file mode 100644
index 0000000..5ab5d02
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-unbridged-cast.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -emit-llvm -fobjc-arc -o - %s | FileCheck %s
+// rdar://9744349
+
+typedef const struct __CFString * CFStringRef;
+
+@interface I
+@property CFStringRef P;
+- (CFStringRef) CFMeth __attribute__((cf_returns_retained));
+- (CFStringRef) newSomething;
+- (CFStringRef) P __attribute__((cf_returns_retained));
+@end
+
+@implementation I
+@synthesize P;
+- (id) Meth {
+ I* p1 = (id)[p1 P];
+ id p2 = (id)[p1 CFMeth];
+ id p3 = (id)[p1 newSomething];
+ return (id) p1.P;
+}
+- (CFStringRef) CFMeth { return 0; }
+- (CFStringRef) newSomething { return 0; }
+- (CFStringRef) P { return 0; }
+- (void) setP : (CFStringRef)arg {}
+@end
+
+// rdar://9544832
+CFStringRef SomeOtherFunc() __attribute__((cf_returns_retained));
+id MMM()
+{
+ id obj = (id)((CFStringRef) __builtin___CFStringMakeConstantString ("" "Some CF String" ""));
+ return 0;
+}
+
+// CHECK-NOT: call i8* @objc_retainAutoreleasedReturnValue
diff --git a/clang/test/CodeGenObjC/arc-unopt.m b/clang/test/CodeGenObjC/arc-unopt.m
new file mode 100644
index 0000000..c319bf2
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-unopt.m
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck %s
+
+// A test to ensure that we generate fused calls at -O0.
+
+@class Test0;
+Test0 *test0(void) {
+ extern Test0 *test0_helper;
+ return test0_helper;
+
+ // CHECK: [[LD:%.*]] = load [[TEST0:%.*]]** @test0_helper
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [[TEST0]]* [[LD]] to i8*
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleaseReturnValue(i8* [[T0]])
+ // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to [[TEST0]]*
+ // CHECK-NEXT: ret [[TEST0]]* [[T2]]
+}
+
+id test1(void) {
+ extern id test1_helper;
+ return test1_helper;
+
+ // CHECK: [[LD:%.*]] = load i8** @test1_helper
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_retainAutoreleaseReturnValue(i8* [[LD]])
+ // CHECK-NEXT: ret i8* [[T0]]
+}
+
+void test2(void) {
+ // CHECK: [[X:%.*]] = alloca i8*
+ // CHECK-NEXT: store i8* null, i8** [[X]]
+ // CHECK-NEXT: call void @objc_destroyWeak(i8** [[X]])
+ // CHECK-NEXT: ret void
+ __weak id x;
+}
+
+id test3(void) {
+ extern id test3_helper(void);
+ // CHECK: [[T0:%.*]] = call i8* @test3_helper()
+ // CHECK-NEXT: ret i8* [[T0]]
+ return test3_helper();
+}
+
+@interface Test4 { id x; } @end
+@interface Test4_sub : Test4 { id y; } @end
+Test4 *test4(void) {
+ extern Test4_sub *test4_helper(void);
+ // CHECK: [[T0:%.*]] = call [[TEST4S:%.*]]* @test4_helper()
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST4S]]* [[T0]] to [[TEST4:%.*]]*
+ // CHECK-NEXT: ret [[TEST4]]* [[T1]]
+ return test4_helper();
+}
+
+// rdar://problem/9418404
+@class Test5;
+void test5(void) {
+ Test5 *x, *y;
+ if ((x = y))
+ y = 0;
+
+// CHECK: define void @test5()
+// CHECK: [[X:%.*]] = alloca [[TEST5:%.*]]*,
+// CHECK-NEXT: [[Y:%.*]] = alloca [[TEST5:%.*]]*,
+// CHECK-NEXT: store [[TEST5]]* null, [[TEST5]]** [[X]],
+// CHECK-NEXT: store [[TEST5]]* null, [[TEST5]]** [[Y]],
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST5]]** [[Y]],
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST5]]** [[X]] to i8**
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST5]]* [[T0]] to i8*
+// CHECK-NEXT: call void @objc_storeStrong(i8** [[T1]], i8* [[T2]])
+// CHECK-NEXT: [[T3:%.*]] = icmp ne [[TEST5]]* [[T0]], null
+// CHECK-NEXT: br i1 [[T3]],
+}
diff --git a/clang/test/CodeGenObjC/arc-weak-property.m b/clang/test/CodeGenObjC/arc-weak-property.m
new file mode 100644
index 0000000..0a6b2a6
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-weak-property.m
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck %s
+// rdar://8899430
+
+@interface WeakPropertyTest {
+ __weak id PROP;
+}
+@property () __weak id PROP;
+@end
+
+@implementation WeakPropertyTest
+@synthesize PROP;
+@end
+
+// CHECK: define internal i8* @"\01-[WeakPropertyTest PROP]"
+// CHECK: [[SELF:%.*]] = alloca [[WPT:%.*]]*,
+// CHECK-NEXT: [[CMD:%.*]] = alloca i8*,
+// CHECK-NEXT: store [[WPT]]* {{%.*}}, [[WPT]]** [[SELF]]
+// CHECK-NEXT: store i8* {{%.*}}, i8** [[CMD]]
+// CHECK-NEXT: [[T0:%.*]] = load [[WPT]]** [[SELF]]
+// CHECK-NEXT: [[T1:%.*]] = load i64* @"OBJC_IVAR_$_WeakPropertyTest.PROP"
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[WPT]]* [[T0]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8* [[T2]], i64 [[T1]]
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i8**
+// CHECK-NEXT: [[T5:%.*]] = call i8* @objc_loadWeakRetained(i8** [[T4]])
+// CHECK-NEXT: [[T6:%.*]] = call i8* @objc_autoreleaseReturnValue(i8* [[T5]])
+// CHECK-NEXT: ret i8* [[T6]]
+
+// CHECK: define internal void @"\01-[WeakPropertyTest setPROP:]"
+// CHECK: [[SELF:%.*]] = alloca [[WPT:%.*]]*,
+// CHECK-NEXT: [[CMD:%.*]] = alloca i8*,
+// CHECK-NEXT: [[PROP:%.*]] = alloca i8*,
+// CHECK-NEXT: store [[WPT]]* {{%.*}}, [[WPT]]** [[SELF]]
+// CHECK-NEXT: store i8* {{%.*}}, i8** [[CMD]]
+// CHECK-NEXT: store i8* {{%.*}}, i8** [[PROP]]
+// CHECK-NEXT: [[V:%.*]] = load i8** [[PROP]]
+// CHECK-NEXT: [[T0:%.*]] = load [[WPT]]** [[SELF]]
+// CHECK-NEXT: [[T1:%.*]] = load i64* @"OBJC_IVAR_$_WeakPropertyTest.PROP"
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[WPT]]* [[T0]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8* [[T2]], i64 [[T1]]
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i8**
+// CHECK-NEXT: call i8* @objc_storeWeak(i8** [[T4]], i8* [[V]])
+// CHECK-NEXT: ret void
+
+// CHECK: define internal void @"\01-[WeakPropertyTest .cxx_destruct]"
+// CHECK: [[SELF:%.*]] = alloca [[WPT:%.*]]*,
+// CHECK-NEXT: [[CMD:%.*]] = alloca i8*,
+// CHECK-NEXT: store [[WPT]]* {{%.*}}, [[WPT]]** [[SELF]]
+// CHECK-NEXT: store i8* {{%.*}}, i8** [[CMD]]
+// CHECK-NEXT: [[T0:%.*]] = load [[WPT]]** [[SELF]]
+// CHECK-NEXT: [[T1:%.*]] = load i64* @"OBJC_IVAR_$_WeakPropertyTest.PROP"
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[WPT]]* [[T0]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8* [[T2]], i64 [[T1]]
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i8**
+// CHECK-NEXT: call void @objc_destroyWeak(i8** [[T4]])
+// CHECK-NEXT: ret void
diff --git a/clang/test/CodeGenObjC/arc-with-atthrow.m b/clang/test/CodeGenObjC/arc-with-atthrow.m
new file mode 100644
index 0000000..213b05b
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc-with-atthrow.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-exceptions -o - %s | FileCheck %s
+// pr10411
+// rdar://10042689
+
+id make(void);
+void test() {
+ @throw make();
+}
+
+// TODO: We should probably emit this specific pattern without the reclaim.
+
+// CHECK: define void @test()
+// CHECK: [[T0:%.*]] = call i8* @make()
+// CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+// CHECK-NEXT: [[T2:%.*]] = call i8* @objc_autorelease(i8* [[T1]])
+// CHECK-NEXT: call void @objc_exception_throw(i8* [[T2]]) noreturn
+// CHECK-NEXT: unreachable
diff --git a/clang/test/CodeGenObjC/arc.m b/clang/test/CodeGenObjC/arc.m
new file mode 100644
index 0000000..2a98b10
--- /dev/null
+++ b/clang/test/CodeGenObjC/arc.m
@@ -0,0 +1,1539 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -o - %s | FileCheck -check-prefix=CHECK-GLOBALS %s
+
+// CHECK: define void @test0
+void test0(id x) {
+ // CHECK: [[X:%.*]] = alloca i8*
+ // CHECK-NEXT: [[PARM:%.*]] = call i8* @objc_retain(i8* {{.*}})
+ // CHECK-NEXT: store i8* [[PARM]], i8** [[X]]
+ // CHECK-NEXT: [[TMP:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[TMP]])
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define i8* @test1(i8*
+id test1(id x) {
+ // CHECK: [[X:%.*]] = alloca i8*
+ // CHECK-NEXT: [[Y:%.*]] = alloca i8*
+ // CHECK-NEXT: alloca i32
+ // CHECK-NEXT: [[PARM:%.*]] = call i8* @objc_retain(i8* {{%.*}})
+ // CHECK-NEXT: store i8* [[PARM]], i8** [[X]]
+ // CHECK-NEXT: store i8* null, i8** [[Y]]
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[Y]]
+ // CHECK-NEXT: [[RET:%.*]] = call i8* @objc_retain(i8* [[T0]])
+ // CHECK-NEXT: store i32
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[Y]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: [[T1:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_autoreleaseReturnValue(i8* [[RET]])
+ // CHECK-NEXT: ret i8* [[T1]]
+ id y;
+ return y;
+}
+
+@interface Test2
++ (void) class_method;
+- (void) inst_method;
+@end
+@implementation Test2
+
+// The self pointer of a class method is not retained.
+// CHECK: define internal void @"\01+[Test2 class_method]"
+// CHECK: alloca
+// CHECK-NEXT: alloca
+// CHECK-NEXT: store
+// CHECK-NEXT: store
+// CHECK-NEXT: ret void
++ (void) class_method {}
+
+// The self pointer of an instance method is not retained.
+// CHECK: define internal void @"\01-[Test2 inst_method]"
+// CHECK: alloca
+// CHECK-NEXT: alloca
+// CHECK-NEXT: store
+// CHECK-NEXT: store
+// CHECK-NEXT: ret void
+- (void) inst_method {}
+@end
+
+@interface Test3
++ (id) alloc;
+- (id) initWith: (int) x;
+- (id) copy;
+@end
+
+// CHECK: define void @test3_unelided()
+void test3_unelided() {
+ extern void test3_helper(void);
+
+ // CHECK: [[X:%.*]] = alloca [[TEST3:%.*]]*
+ // CHECK-NEXT: store [[TEST3]]* null, [[TEST3]]** [[X]], align
+ Test3 *x;
+
+ // Call to +alloc.
+ // CHECK-NEXT: load {{.*}}* @"\01L_OBJC_CLASSLIST_REFERENCES_
+ // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: [[ALLOC:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: call void @objc_release(i8*
+ [Test3 alloc];
+
+ // CHECK-NEXT: [[T0:%.*]] = load [[TEST3]]** [[X]]
+ // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST3]]* [[T0]] to i8*
+ // CHECK-NEXT: [[COPY:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend {{.*}})(i8* [[T1]],
+ // CHECK-NEXT: call void @objc_release(i8* [[COPY]]) nounwind
+ [x copy];
+
+ // CHECK-NEXT: [[T0:%.*]] = load [[TEST3]]** [[X]]
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST3]]* [[T0]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @test3()
+void test3() {
+ // CHECK: [[X:%.*]] = alloca i8*
+
+ id x = [[Test3 alloc] initWith: 5];
+
+ // Call to +alloc.
+ // CHECK-NEXT: load {{.*}}* @"\01L_OBJC_CLASSLIST_REFERENCES_
+ // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: [[ALLOC:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+ // CHECK-NEXT: bitcast
+
+ // Call to -initWith: with elided retain of consumed argument.
+ // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: [[INIT:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i32)*)(i8*
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: [[INIT:%.*]] = bitcast
+ // Assignment for initialization, retention elided.
+ // CHECK-NEXT: store i8* [[INIT]], i8** [[X]]
+
+ // Call to -copy.
+ // CHECK-NEXT: [[V:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: [[COPY:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend {{.*}})(i8* [[V]],
+
+ // Assignment to x.
+ // CHECK-NEXT: [[TMP:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: store i8* [[COPY]], i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[TMP]]) nounwind
+
+ x = [x copy];
+
+ // Cleanup for x.
+ // CHECK-NEXT: [[TMP:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[TMP]]) nounwind
+
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define i8* @test4()
+id test4() {
+ // Call to +alloc.
+ // CHECK: load {{.*}}* @"\01L_OBJC_CLASSLIST_REFERENCES_
+ // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: [[ALLOC:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+ // CHECK-NEXT: [[ALLOC:%.*]] = bitcast
+
+ // Call to -initWith: with elided retain of consumed argument.
+ // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: [[ALLOC:%.*]] = bitcast
+ // CHECK-NEXT: [[INIT:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i32)*)(i8* [[ALLOC]],
+
+ // Initialization of return value, occuring within full-expression.
+ // Retain/release elided.
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: [[INIT:%.*]] = bitcast
+ // CHECK-NEXT: [[RET:%.*]] = call i8* @objc_autoreleaseReturnValue(i8* [[INIT]])
+
+ // CHECK-NEXT: ret i8* [[RET]]
+
+ return [[Test3 alloc] initWith: 6];
+}
+
+@interface Test5 {
+@public
+ id var;
+}
+@end
+
+// CHECK: define void @test5
+void test5(Test5 *x, id y) {
+ // Prologue.
+ // CHECK: [[X:%.*]] = alloca [[TEST5:%.*]]*,
+ // CHECK-NEXT: [[Y:%.*]] = alloca i8*
+ // CHECK-NEXT: bitcast [[TEST5]]* {{%.*}} to i8*
+ // CHECK-NEXT: call i8* @objc_retain
+ // CHECK-NEXT: [[PARMX:%.*]] = bitcast i8* {{%.*}} to [[TEST5]]*
+ // CHECK-NEXT: store [[TEST5]]* [[PARMX]], [[TEST5]]** [[X]]
+ // CHECK-NEXT: call i8* @objc_retain
+ // CHECK-NEXT: store
+
+ // CHECK-NEXT: load [[TEST5]]** [[X]]
+ // CHECK-NEXT: load i64* @"OBJC_IVAR_$_Test5.var"
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: [[VAR:%.*]] = bitcast
+ // CHECK-NEXT: [[TMP:%.*]] = load i8** [[VAR]]
+ // CHECK-NEXT: store i8* null, i8** [[VAR]]
+ // CHECK-NEXT: call void @objc_release(i8* [[TMP]]) nounwind
+ x->var = 0;
+
+ // CHECK-NEXT: [[YVAL:%.*]] = load i8** [[Y]]
+ // CHECK-NEXT: load [[TEST5]]** [[X]]
+ // CHECK-NEXT: load i64* @"OBJC_IVAR_$_Test5.var"
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: [[VAR:%.*]] = bitcast
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_retain(i8* [[YVAL]]) nounwind
+ // CHECK-NEXT: [[TMP:%.*]] = load i8** [[VAR]]
+ // CHECK-NEXT: store i8* [[T0]], i8** [[VAR]]
+ // CHECK-NEXT: call void @objc_release(i8* [[TMP]]) nounwind
+ x->var = y;
+
+ // Epilogue.
+ // CHECK-NEXT: [[TMP:%.*]] = load i8** [[Y]]
+ // CHECK-NEXT: call void @objc_release(i8* [[TMP]]) nounwind
+ // CHECK-NEXT: [[T0:%.*]] = load [[TEST5]]** [[X]]
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST5]]* [[T0]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind
+ // CHECK-NEXT: ret void
+}
+
+id test6_helper(void) __attribute__((ns_returns_retained));
+// CHECK: define void @test6()
+void test6() {
+ // CHECK: [[X:%.*]] = alloca i8*
+ // CHECK-NEXT: [[CALL:%.*]] = call i8* @test6_helper()
+ // CHECK-NEXT: store i8* [[CALL]], i8** [[X]]
+ // CHECK-NEXT: [[T1:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind, !clang.imprecise_release
+ // CHECK-NEXT: ret void
+ id x = test6_helper();
+}
+
+void test7_helper(id __attribute__((ns_consumed)));
+// CHECK: define void @test7()
+void test7() {
+ // CHECK: [[X:%.*]] = alloca i8*
+ // CHECK-NEXT: store i8* null, i8** [[X]]
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]]) nounwind
+ // CHECK-NEXT: call void @test7_helper(i8* [[T1]])
+ // CHECK-NEXT: [[T1:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind, !clang.imprecise_release
+ // CHECK-NEXT: ret void
+ id x;
+ test7_helper(x);
+}
+
+id test8_helper(void) __attribute__((ns_returns_retained));
+void test8() {
+ __unsafe_unretained id x = test8_helper();
+ // CHECK: [[X:%.*]] = alloca i8*
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @test8_helper()
+ // CHECK-NEXT: store i8* [[T0]], i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]]) nounwind
+ // CHECK-NOT: imprecise_release
+ // CHECK-NEXT: ret void
+}
+
+id test9_helper(void) __attribute__((ns_returns_retained));
+void test9() {
+ id x __attribute__((objc_precise_lifetime)) = test9_helper();
+ x = 0;
+ // CHECK: [[X:%.*]] = alloca i8*
+ // CHECK-NEXT: [[CALL:%.*]] = call i8* @test9_helper()
+ // CHECK-NEXT: store i8* [[CALL]], i8** [[X]]
+
+ // CHECK-NEXT: [[T1:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: store i8* null, i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind, !clang.imprecise_release
+
+ // CHECK-NEXT: [[T1:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind
+ // CHECK-NOT: clang.imprecise_release
+
+ // CHECK-NEXT: ret void
+}
+
+@interface Test10
+@property (retain) Test10 *me;
+@end
+void test10() {
+ Test10 *x;
+ id y = x.me.me;
+
+ // CHECK: define void @test10()
+ // CHECK: [[X:%.*]] = alloca [[TEST10:%.*]]*, align
+ // CHECK-NEXT: [[Y:%.*]] = alloca i8*, align
+ // CHECK-NEXT: store [[TEST10]]* null, [[TEST10]]** [[X]]
+ // CHECK-NEXT: load [[TEST10]]** [[X]], align
+ // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_{{[0-9]*}}"
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: [[T0:%.*]] = call [[TEST10]]* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST10]]* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
+ // CHECK-NEXT: [[V:%.*]] = bitcast i8* [[T2]] to [[TEST10]]*
+ // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_{{[0-9]*}}"
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: [[T0:%.*]] = call [[TEST10]]* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST10]]* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
+ // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST10]]*
+ // CHECK-NEXT: [[T4:%.*]] = bitcast [[TEST10]]* [[T3]] to i8*
+ // CHECK-NEXT: store i8* [[T4]], i8** [[Y]]
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [[TEST10]]* [[V]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[Y]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: [[T0:%.*]] = load [[TEST10]]** [[X]]
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST10]]* [[T0]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ // CHECK-NEXT: ret void
+}
+
+void test11(id (*f)(void) __attribute__((ns_returns_retained))) {
+ // CHECK: define void @test11(
+ // CHECK: [[F:%.*]] = alloca i8* ()*, align
+ // CHECK-NEXT: [[X:%.*]] = alloca i8*, align
+ // CHECK-NEXT: store i8* ()* {{%.*}}, i8* ()** [[F]], align
+ // CHECK-NEXT: [[T0:%.*]] = load i8* ()** [[F]], align
+ // CHECK-NEXT: [[T1:%.*]] = call i8* [[T0]]()
+ // CHECK-NEXT: store i8* [[T1]], i8** [[X]], align
+ // CHECK-NEXT: [[T3:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T3]]) nounwind, !clang.imprecise_release
+ // CHECK-NEXT: ret void
+ id x = f();
+}
+
+void test12(void) {
+ extern id test12_helper(void);
+
+ // CHECK: define void @test12()
+ // CHECK: [[X:%.*]] = alloca i8*, align
+ // CHECK-NEXT: [[Y:%.*]] = alloca i8*, align
+
+ __weak id x = test12_helper();
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @test12_helper()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: call i8* @objc_initWeak(i8** [[X]], i8* [[T1]])
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+
+ x = test12_helper();
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @test12_helper()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: call i8* @objc_storeWeak(i8** [[X]], i8* [[T1]])
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+
+ id y = x;
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_loadWeakRetained(i8** [[X]])
+ // CHECK-NEXT: store i8* [[T2]], i8** [[Y]], align
+
+ // CHECK-NEXT: [[T4:%.*]] = load i8** [[Y]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T4]]) nounwind, !clang.imprecise_release
+ // CHECK-NEXT: call void @objc_destroyWeak(i8** [[X]])
+ // CHECK-NEXT: ret void
+}
+
+// Indirect consuming calls.
+void test13(void) {
+ // CHECK: define void @test13()
+ // CHECK: [[X:%.*]] = alloca i8*, align
+ // CHECK-NEXT: store i8* null, i8** [[X]], align
+ id x;
+
+ typedef void fnty(id __attribute__((ns_consumed)));
+ extern fnty *test13_func;
+ // CHECK-NEXT: [[FN:%.*]] = load void (i8*)** @test13_func, align
+ // CHECK-NEXT: [[X_VAL:%.*]] = load i8** [[X]], align
+ // CHECK-NEXT: [[X_TMP:%.*]] = call i8* @objc_retain(i8* [[X_VAL]]) nounwind
+ // CHECK-NEXT: call void [[FN]](i8* [[X_TMP]])
+ test13_func(x);
+
+ extern fnty ^test13_block;
+ // CHECK-NEXT: [[TMP:%.*]] = load void (i8*)** @test13_block, align
+ // CHECK-NEXT: [[BLOCK:%.*]] = bitcast void (i8*)* [[TMP]] to [[BLOCKTY:%.*]]*
+ // CHECK-NEXT: [[BLOCK_FN_PTR:%.*]] = getelementptr inbounds [[BLOCKTY]]* [[BLOCK]], i32 0, i32 3
+ // CHECK-NEXT: [[BLOCK_OPAQUE:%.*]] = bitcast [[BLOCKTY]]* [[BLOCK]] to i8*
+ // CHECK-NEXT: [[X_VAL:%.*]] = load i8** [[X]], align
+ // CHECK-NEXT: [[X_TMP:%.*]] = call i8* @objc_retain(i8* [[X_VAL]]) nounwind
+ // CHECK-NEXT: [[BLOCK_FN_TMP:%.*]] = load i8** [[BLOCK_FN_PTR]]
+ // CHECK-NEXT: [[BLOCK_FN:%.*]] = bitcast i8* [[BLOCK_FN_TMP]] to void (i8*, i8*)*
+ // CHECK-NEXT: call void [[BLOCK_FN]](i8* [[BLOCK_OPAQUE]], i8* [[X_TMP]])
+ test13_block(x);
+
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]]) nounwind
+ // CHECK-NEXT: ret void
+}
+
+@interface Test16_super @end
+@interface Test16 : Test16_super {
+ id z;
+}
+@property (assign) int x;
+@property (retain) id y;
+- (void) dealloc;
+@end
+@implementation Test16
+@synthesize x;
+@synthesize y;
+- (void) dealloc {
+ // CHECK: define internal void @"\01-[Test16 dealloc]"(
+ // CHECK: [[SELF:%.*]] = alloca [[TEST16:%.*]]*, align
+ // CHECK-NEXT: [[CMD:%.*]] = alloca i8*, align
+ // CHECK-NEXT: alloca
+ // CHECK-NEXT: store [[TEST16]]* {{%.*}}, [[TEST16]]** [[SELF]], align
+ // CHECK-NEXT: store i8* {{%.*}}, i8** [[CMD]]
+ // CHECK-NEXT: [[BASE:%.*]] = load [[TEST16]]** [[SELF]]
+
+ // Call super.
+ // CHECK-NEXT: [[BASE2:%.*]] = bitcast [[TEST16]]* [[BASE]] to i8*
+ // CHECK-NEXT: [[T0:%.*]] = getelementptr
+ // CHECK-NEXT: store i8* [[BASE2]], i8** [[T0]]
+ // CHECK-NEXT: load {{%.*}}** @"\01L_OBJC_CLASSLIST_SUP_REFS_$_
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: store
+ // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: call void bitcast (i8* ({{.*}})* @objc_msgSendSuper2 to void (
+ // CHECK-NEXT: ret void
+}
+
+// .cxx_destruct
+ // CHECK: define internal void @"\01-[Test16 .cxx_destruct]"(
+ // CHECK: [[SELF:%.*]] = alloca [[TEST16:%.*]]*, align
+ // CHECK-NEXT: [[CMD:%.*]] = alloca i8*, align
+ // CHECK-NEXT: store [[TEST16]]* {{%.*}}, [[TEST16]]** [[SELF]], align
+ // CHECK-NEXT: store i8* {{%.*}}, i8** [[CMD]]
+ // CHECK-NEXT: [[BASE:%.*]] = load [[TEST16]]** [[SELF]]
+
+ // Destroy y.
+ // CHECK-NEXT: [[Y_OFF:%.*]] = load i64* @"OBJC_IVAR_$_Test16.y"
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [[TEST16]]* [[BASE]] to i8*
+ // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8* [[T0]], i64 [[Y_OFF]]
+ // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to i8**
+ // CHECK-NEXT: call void @objc_storeStrong(i8** [[T2]], i8* null) nounwind
+
+ // Destroy z.
+ // CHECK-NEXT: [[Z_OFF:%.*]] = load i64* @"OBJC_IVAR_$_Test16.z"
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [[TEST16]]* [[BASE]] to i8*
+ // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8* [[T0]], i64 [[Z_OFF]]
+ // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to i8**
+ // CHECK-NEXT: call void @objc_storeStrong(i8** [[T2]], i8* null) nounwind
+
+ // CHECK-NEXT: ret void
+
+@end
+
+// This shouldn't crash.
+@interface Test17A
+@property (assign) int x;
+@end
+@interface Test17B : Test17A
+@end
+@implementation Test17B
+- (int) x { return super.x + 1; }
+@end
+
+void test19() {
+ // CHECK: define void @test19()
+ // CHECK: [[X:%.*]] = alloca [5 x i8*], align 16
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [5 x i8*]* [[X]] to i8*
+ // CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[T0]], i8 0, i64 40, i32 16, i1 false)
+ id x[5];
+
+ extern id test19_helper(void);
+ x[2] = test19_helper();
+
+ // CHECK-NEXT: [[CALL:%.*]] = call i8* @test19_helper()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[CALL]]) nounwind
+ // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [5 x i8*]* [[X]], i32 0, i64 2
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[SLOT]]
+ // CHECK-NEXT: store i8* [[T1]], i8** [[SLOT]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]]) nounwind
+
+ // CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [5 x i8*]* [[X]], i32 0, i32 0
+ // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds i8** [[BEGIN]], i64 5
+ // CHECK-NEXT: br label
+
+ // CHECK: [[AFTER:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[NEXT:%.*]], {{%.*}} ]
+ // CHECK-NEXT: [[CUR:%.*]] = getelementptr inbounds i8** [[AFTER]], i64 -1
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[CUR]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]]) nounwind, !clang.imprecise_release
+ // CHECK-NEXT: [[EQ:%.*]] = icmp eq i8** [[CUR]], [[BEGIN]]
+ // CHECK-NEXT: br i1 [[EQ]],
+
+ // CHECK: ret void
+}
+
+void test20(unsigned n) {
+ // CHECK: define void @test20
+ // CHECK: [[N:%.*]] = alloca i32, align 4
+ // CHECK-NEXT: [[SAVED_STACK:%.*]] = alloca i8*
+ // CHECK-NEXT: store i32 {{%.*}}, i32* [[N]], align 4
+
+ id x[n];
+
+ // Capture the VLA size.
+ // CHECK-NEXT: [[T0:%.*]] = load i32* [[N]], align 4
+ // CHECK-NEXT: [[DIM:%.*]] = zext i32 [[T0]] to i64
+
+ // Save the stack pointer.
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @llvm.stacksave()
+ // CHECK-NEXT: store i8* [[T0]], i8** [[SAVED_STACK]]
+
+ // Allocate the VLA.
+ // CHECK-NEXT: [[VLA:%.*]] = alloca i8*, i64 [[DIM]], align 16
+
+ // Zero-initialize.
+ // CHECK-NEXT: [[T0:%.*]] = bitcast i8** [[VLA]] to i8*
+ // CHECK-NEXT: [[T1:%.*]] = mul nuw i64 [[DIM]], 8
+ // CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[T0]], i8 0, i64 [[T1]], i32 8, i1 false)
+
+ // Destroy.
+ // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds i8** [[VLA]], i64 [[DIM]]
+ // CHECK-NEXT: [[EMPTY:%.*]] = icmp eq i8** [[VLA]], [[END]]
+ // CHECK-NEXT: br i1 [[EMPTY]]
+
+ // CHECK: [[AFTER:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]], {{%.*}} ]
+ // CHECK-NEXT: [[CUR:%.*]] = getelementptr inbounds i8** [[AFTER]], i64 -1
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[CUR]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]]) nounwind, !clang.imprecise_release
+ // CHECK-NEXT: [[EQ:%.*]] = icmp eq i8** [[CUR]], [[VLA]]
+ // CHECK-NEXT: br i1 [[EQ]],
+
+ // CHECK: [[T0:%.*]] = load i8** [[SAVED_STACK]]
+ // CHECK-NEXT: call void @llvm.stackrestore(i8* [[T0]])
+ // CHECK-NEXT: ret void
+}
+
+void test21(unsigned n) {
+ // CHECK: define void @test21
+ // CHECK: [[N:%.*]] = alloca i32, align 4
+ // CHECK-NEXT: [[SAVED_STACK:%.*]] = alloca i8*
+ // CHECK-NEXT: store i32 {{%.*}}, i32* [[N]], align 4
+
+ id x[2][n][3];
+
+ // Capture the VLA size.
+ // CHECK-NEXT: [[T0:%.*]] = load i32* [[N]], align 4
+ // CHECK-NEXT: [[DIM:%.*]] = zext i32 [[T0]] to i64
+
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @llvm.stacksave()
+ // CHECK-NEXT: store i8* [[T0]], i8** [[SAVED_STACK]]
+
+
+ // Allocate the VLA.
+ // CHECK-NEXT: [[T0:%.*]] = mul nuw i64 2, [[DIM]]
+ // CHECK-NEXT: [[VLA:%.*]] = alloca [3 x i8*], i64 [[T0]], align 16
+
+ // Zero-initialize.
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [3 x i8*]* [[VLA]] to i8*
+ // CHECK-NEXT: [[T1:%.*]] = mul nuw i64 2, [[DIM]]
+ // CHECK-NEXT: [[T2:%.*]] = mul nuw i64 [[T1]], 24
+ // CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[T0]], i8 0, i64 [[T2]], i32 8, i1 false)
+
+ // Destroy.
+ // CHECK-NEXT: [[T0:%.*]] = mul nuw i64 2, [[DIM]]
+ // CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [3 x i8*]* [[VLA]], i32 0, i32 0
+ // CHECK-NEXT: [[T1:%.*]] = mul nuw i64 [[T0]], 3
+ // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds i8** [[BEGIN]], i64 [[T1]]
+ // CHECK-NEXT: [[EMPTY:%.*]] = icmp eq i8** [[BEGIN]], [[END]]
+ // CHECK-NEXT: br i1 [[EMPTY]]
+
+ // CHECK: [[AFTER:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]], {{%.*}} ]
+ // CHECK-NEXT: [[CUR:%.*]] = getelementptr inbounds i8** [[AFTER]], i64 -1
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[CUR]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]]) nounwind, !clang.imprecise_release
+ // CHECK-NEXT: [[EQ:%.*]] = icmp eq i8** [[CUR]], [[BEGIN]]
+ // CHECK-NEXT: br i1 [[EQ]],
+
+ // CHECK: [[T0:%.*]] = load i8** [[SAVED_STACK]]
+ // CHECK-NEXT: call void @llvm.stackrestore(i8* [[T0]])
+ // CHECK-NEXT: ret void
+}
+
+void test22(_Bool cond) {
+ id test22_helper(void) __attribute__((ns_returns_retained));
+
+ // CHECK: define void @test22(
+ // CHECK: [[COND:%.*]] = alloca i8,
+ // CHECK-NEXT: [[X:%.*]] = alloca i8*,
+ // CHECK-NEXT: [[RELVAL:%.*]] = alloca i8*
+ // CHECK-NEXT: [[RELCOND:%.*]] = alloca i1
+ // CHECK-NEXT: zext
+ // CHECK-NEXT: store
+ // CHECK-NEXT: [[T0:%.*]] = load i8* [[COND]]
+ // CHECK-NEXT: [[T1:%.*]] = trunc i8 [[T0]] to i1
+ // CHECK-NEXT: store i1 false, i1* [[RELCOND]]
+ // CHECK-NEXT: br i1 [[T1]],
+ // CHECK: br label
+ // CHECK: [[CALL:%.*]] = call i8* @test22_helper()
+ // CHECK-NEXT: store i8* [[CALL]], i8** [[RELVAL]]
+ // CHECK-NEXT: store i1 true, i1* [[RELCOND]]
+ // CHECK-NEXT: br label
+ // CHECK: [[T0:%.*]] = phi i8* [ null, {{%.*}} ], [ [[CALL]], {{%.*}} ]
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]]) nounwind
+ // CHECK-NEXT: store i8* [[T1]], i8** [[X]],
+ // CHECK-NEXT: [[REL:%.*]] = load i1* [[RELCOND]]
+ // CHECK-NEXT: br i1 [[REL]],
+ // CHECK: [[T0:%.*]] = load i8** [[RELVAL]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]]) nounwind
+ // CHECK-NEXT: br label
+ // CHECK: [[T0:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]]) nounwind
+ // CHECK-NEXT: ret void
+ id x = (cond ? 0 : test22_helper());
+}
+
+// rdar://problem/8922540
+// Note that we no longer emit .release_ivars flags.
+// CHECK-GLOBALS: @"\01l_OBJC_CLASS_RO_$_Test23" = internal global [[RO_T:%.*]] { i32 134,
+@interface Test23 { id x; } @end
+@implementation Test23 @end
+
+// CHECK-GLOBALS: @"\01l_OBJC_CLASS_RO_$_Test24" = internal global [[RO_T:%.*]] { i32 130,
+@interface Test24 {} @end
+@implementation Test24 @end
+
+// rdar://problem/8941012
+@interface Test26 { id x[4]; } @end
+@implementation Test26 @end
+// CHECK: define internal void @"\01-[Test26 .cxx_destruct]"(
+// CHECK: [[SELF:%.*]] = load [[TEST26:%.*]]**
+// CHECK-NEXT: [[OFFSET:%.*]] = load i64* @"OBJC_IVAR_$_Test26.x"
+// CHECK-NEXT: [[T0:%.*]] = bitcast [[TEST26]]* [[SELF]] to i8*
+// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8* [[T0]], i64 [[OFFSET]]
+// CHECK-NEXT: [[X:%.*]] = bitcast i8* [[T1]] to [4 x i8*]*
+// CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [4 x i8*]* [[X]], i32 0, i32 0
+// CHECK-NEXT: [[END:%.*]] = getelementptr inbounds i8** [[BEGIN]], i64 4
+// CHECK-NEXT: br label
+// CHECK: [[PAST:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]], {{%.*}} ]
+// CHECK-NEXT: [[CUR]] = getelementptr inbounds i8** [[PAST]], i64 -1
+// CHECK-NEXT: call void @objc_storeStrong(i8** [[CUR]], i8* null)
+// CHECK-NEXT: [[ISDONE:%.*]] = icmp eq i8** [[CUR]], [[BEGIN]]
+// CHECK-NEXT: br i1 [[ISDONE]],
+// CHECK: ret void
+
+// Check that 'init' retains self.
+@interface Test27
+- (id) init;
+@end
+@implementation Test27
+- (id) init { return self; }
+// CHECK: define internal i8* @"\01-[Test27 init]"
+// CHECK: [[SELF:%.*]] = alloca [[TEST27:%.*]]*,
+// CHECK-NEXT: [[CMD:%.*]] = alloca i8*,
+// CHECK-NEXT: [[DEST:%.*]] = alloca i32
+// CHECK-NEXT: store [[TEST27]]* {{%.*}}, [[TEST27]]** [[SELF]]
+// CHECK-NEXT: store i8* {{%.*}}, i8** [[CMD]]
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST27]]** [[SELF]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST27]]* [[T0]] to i8*
+// CHECK-NEXT: [[RET:%.*]] = call i8* @objc_retain(i8* [[T1]])
+// CHECK-NEXT: store i32 {{[0-9]+}}, i32* [[DEST]]
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST27]]** [[SELF]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST27]]* [[T0]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T1]])
+// CHECK-NEXT: ret i8* [[RET]]
+
+@end
+
+// rdar://problem/8087194
+@interface Test28
+@property (copy) id prop;
+@end
+@implementation Test28
+@synthesize prop;
+@end
+// CHECK: define internal void @"\01-[Test28 .cxx_destruct]"
+// CHECK: [[SELF:%.*]] = load [[TEST28:%.*]]**
+// CHECK-NEXT: [[OFFSET:%.*]] = load i64* @"OBJC_IVAR_$_Test28.prop"
+// CHECK-NEXT: [[T0:%.*]] = bitcast [[TEST28]]* [[SELF]] to i8*
+// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8* [[T0]], i64 [[OFFSET]]
+// CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to i8**
+// CHECK-NEXT: call void @objc_storeStrong(i8** [[T2]], i8* null)
+// CHECK-NEXT: ret void
+
+@interface Test29_super
+- (id) initWithAllocator: (id) allocator;
+@end
+@interface Test29 : Test29_super
+- (id) init;
+- (id) initWithAllocator: (id) allocator;
+@end
+@implementation Test29
+static id _test29_allocator = 0;
+- (id) init {
+// CHECK: define internal i8* @"\01-[Test29 init]"([[TEST29:%.*]]* {{%.*}},
+// CHECK: [[SELF:%.*]] = alloca [[TEST29]]*, align 8
+// CHECK-NEXT: [[CMD:%.*]] = alloca i8*, align 8
+// CHECK-NEXT: [[CLEANUP:%.*]] = alloca i32
+// CHECK-NEXT: store [[TEST29]]* {{%.*}}, [[TEST29]]** [[SELF]]
+// CHECK-NEXT: store i8* {{%.*}}, i8** [[CMD]]
+
+// Evaluate arguments. Note that the send argument is evaluated
+// before the zeroing of self.
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST29]]** [[SELF]], align 8
+// CHECK-NEXT: [[T1:%.*]] = load i8** @_test29_allocator, align 8
+
+// Implicit null of 'self', i.e. direct transfer of ownership.
+// CHECK-NEXT: store [[TEST29]]* null, [[TEST29]]** [[SELF]]
+
+// Actual message send.
+// CHECK-NEXT: [[T2:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK-NEXT: [[T3:%.*]] = bitcast [[TEST29]]* [[T0]] to i8*
+// CHECK-NEXT: [[CALL:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8*)*)(i8* [[T3]], i8* [[T2]], i8* [[T1]])
+
+// Implicit write of result back into 'self'. This is not supposed to
+// be detectable because we're supposed to ban accesses to the old
+// self value past the delegate init call.
+// CHECK-NEXT: [[T0:%.*]] = bitcast i8* [[CALL]] to [[TEST29]]*
+// CHECK-NEXT: store [[TEST29]]* [[T0]], [[TEST29]]** [[SELF]]
+
+// Return statement.
+// CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[CALL]]
+// CHECK-NEXT: [[CALL:%.*]] = bitcast
+// CHECK-NEXT: [[RET:%.*]] = call i8* @objc_retain(i8* [[CALL]]) nounwind
+// CHECK-NEXT: store i32 1, i32* [[CLEANUP]]
+
+// Cleanup.
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST29]]** [[SELF]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST29]]* [[T0]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind, !clang.imprecise_release
+
+// Return.
+// CHECK-NEXT: ret i8* [[RET]]
+ return [self initWithAllocator: _test29_allocator];
+}
+- (id) initWithAllocator: (id) allocator {
+// CHECK: define internal i8* @"\01-[Test29 initWithAllocator:]"(
+// CHECK: [[SELF:%.*]] = alloca [[TEST29]]*, align 8
+// CHECK-NEXT: [[CMD:%.*]] = alloca i8*, align 8
+// CHECK-NEXT: [[ALLOCATOR:%.*]] = alloca i8*, align 8
+// CHECK-NEXT: alloca
+// CHECK-NEXT: [[CLEANUP:%.*]] = alloca i32
+// CHECK-NEXT: store [[TEST29]]* {{%.*}}, [[TEST29]]** [[SELF]]
+// CHECK-NEXT: store i8* {{%.*}}, i8** [[CMD]]
+// CHECK-NEXT: [[T0:%.*]] = call i8* @objc_retain(i8* {{%.*}})
+// CHECK-NEXT: store i8* [[T0]], i8** [[ALLOCATOR]]
+
+// Evaluate arguments. Note that the send argument is evaluated
+// before the zeroing of self.
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST29]]** [[SELF]]
+// CHECK-NEXT: [[T1:%.*]] = load i8** [[ALLOCATOR]], align 8
+
+// Implicit null of 'self', i.e. direct transfer of ownership.
+// CHECK-NEXT: store [[TEST29]]* null, [[TEST29]]** [[SELF]]
+
+// Actual message send.
+// CHECK: [[CALL:%.*]] = call {{.*}} @objc_msgSendSuper2
+
+// Implicit write of result back into 'self'. This is not supposed to
+// be detectable because we're supposed to ban accesses to the old
+// self value past the delegate init call.
+// CHECK-NEXT: [[T0:%.*]] = bitcast i8* [[CALL]] to [[TEST29]]*
+// CHECK-NEXT: store [[TEST29]]* [[T0]], [[TEST29]]** [[SELF]]
+
+// Assignment.
+// CHECK-NEXT: [[T0:%.*]] = bitcast i8* [[CALL]] to [[TEST29]]*
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST29]]* [[T0]] to i8*
+// CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]]) nounwind
+// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST29]]*
+// CHECK-NEXT: [[T4:%.*]] = load [[TEST29]]** [[SELF]], align
+// CHECK-NEXT: store [[TEST29]]* [[T3]], [[TEST29]]** [[SELF]], align
+// CHECK-NEXT: [[T5:%.*]] = bitcast [[TEST29]]* [[T4]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T5]])
+
+// Return statement.
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST29]]** [[SELF]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST29]]* [[T0]] to i8*
+// CHECK-NEXT: [[RET:%.*]] = call i8* @objc_retain(i8* [[T1]]) nounwind
+// CHECK-NEXT: store i32 1, i32* [[CLEANUP]]
+
+// Cleanup.
+// CHECK-NEXT: [[T0:%.*]] = load i8** [[ALLOCATOR]]
+// CHECK-NEXT: call void @objc_release(i8* [[T0]]) nounwind, !clang.imprecise_release
+
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST29]]** [[SELF]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST29]]* [[T0]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind, !clang.imprecise_release
+
+// Return.
+// CHECK-NEXT: ret i8* [[RET]]
+ self = [super initWithAllocator: allocator];
+ return self;
+}
+@end
+
+typedef struct Test30_helper Test30_helper;
+@interface Test30
+- (id) init;
+- (Test30_helper*) initHelper;
+@end
+@implementation Test30 {
+char *helper;
+}
+- (id) init {
+// CHECK: define internal i8* @"\01-[Test30 init]"([[TEST30:%.*]]* {{%.*}},
+// CHECK: [[RET:%.*]] = alloca [[TEST30]]*
+// CHECK-NEXT: alloca i8*
+// CHECK-NEXT: alloca i32
+// CHECK-NEXT: store [[TEST30]]* {{%.*}}, [[TEST30]]** [[SELF]]
+// CHECK-NEXT: store
+
+// Call.
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST30]]** [[SELF]]
+// CHECK-NEXT: [[T1:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST30]]* [[T0]] to i8*
+// CHECK-NEXT: [[CALL:%.*]] = call [[TEST30_HELPER:%.*]]* bitcast {{.*}} @objc_msgSend {{.*}}(i8* [[T2]], i8* [[T1]])
+
+// Assignment.
+// CHECK-NEXT: [[T0:%.*]] = bitcast [[TEST30_HELPER]]* [[CALL]] to i8*
+// CHECK-NEXT: [[T1:%.*]] = load [[TEST30]]** [[SELF]]
+// CHECK-NEXT: [[IVAR:%.*]] = load i64* @"OBJC_IVAR_$_Test30.helper"
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST30]]* [[T1]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8* [[T2]], i64 [[IVAR]]
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i8**
+// CHECK-NEXT#: [[T5:%.*]] = load i8** [[T4]]
+// CHECK-NEXT#: [[T6:%.*]] = call i8* @objc_retain(i8* [[T0]])
+// CHECK-NEXT#: call void @objc_release(i8* [[T5]])
+// CHECK-NEXT: store i8* [[T0]], i8** [[T4]]
+
+// Return.
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST30]]** [[SELF]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST30]]* [[T0]] to i8*
+// CHECK-NEXT: [[RET:%.*]] = call i8* @objc_retain(i8* [[T1]])
+// CHECK-NEXT: store i32 1
+
+// Cleanup.
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST30]]** [[SELF]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST30]]* [[T0]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T1]])
+
+// Epilogue.
+// CHECK-NEXT: ret i8* [[RET]]
+ self->helper = [self initHelper];
+ return self;
+}
+- (Test30_helper*) initHelper {
+// CHECK: define internal [[TEST30_HELPER]]* @"\01-[Test30 initHelper]"(
+// CHECK: alloca
+// CHECK-NEXT: alloca
+// CHECK-NEXT: store
+// CHECK-NEXT: store
+// CHECK-NEXT: ret [[TEST30_HELPER]]* null
+ return 0;
+}
+
+@end
+
+__attribute__((ns_returns_retained)) id test32(void) {
+// CHECK: define i8* @test32()
+// CHECK: [[CALL:%.*]] = call i8* @test32_helper()
+// CHECK-NEXT: [[T0:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[CALL]])
+// CHECK-NEXT: ret i8* [[T0]]
+ extern id test32_helper(void);
+ return test32_helper();
+}
+
+@class Test33_a;
+@interface Test33
+- (void) give: (Test33_a **) x;
+- (void) take: (Test33_a **) x;
+- (void) giveStrong: (out __strong Test33_a **) x;
+- (void) takeStrong: (inout __strong Test33_a **) x;
+- (void) giveOut: (out Test33_a **) x;
+@end
+void test33(Test33 *ptr) {
+ Test33_a *a;
+ [ptr give: &a];
+ [ptr take: &a];
+ [ptr giveStrong: &a];
+ [ptr takeStrong: &a];
+ [ptr giveOut: &a];
+
+ // CHECK: define void @test33([[TEST33:%.*]]*
+ // CHECK: [[PTR:%.*]] = alloca [[TEST33]]*
+ // CHECK-NEXT: [[A:%.*]] = alloca [[A_T:%.*]]*
+ // CHECK-NEXT: [[TEMP0:%.*]] = alloca [[A_T]]*
+ // CHECK-NEXT: [[TEMP1:%.*]] = alloca [[A_T]]*
+ // CHECK-NEXT: [[TEMP2:%.*]] = alloca [[A_T]]*
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: objc_retain
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: store
+ // CHECK-NEXT: store [[A_T]]* null, [[A_T]]** [[A]]
+
+ // CHECK-NEXT: load [[TEST33]]** [[PTR]]
+ // CHECK-NEXT: [[T0:%.*]] = load [[A_T]]** [[A]]
+ // CHECK-NEXT: store [[A_T]]* [[T0]], [[A_T]]** [[TEMP0]]
+ // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: objc_msgSend{{.*}}, [[A_T]]** [[TEMP0]])
+ // CHECK-NEXT: [[T0:%.*]] = load [[A_T]]** [[TEMP0]]
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[A_T]]* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]])
+ // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[A_T]]*
+ // CHECK-NEXT: [[T4:%.*]] = load [[A_T]]** [[A]]
+ // CHECK-NEXT: store [[A_T]]* [[T3]], [[A_T]]** [[A]]
+ // CHECK-NEXT: [[T5:%.*]] = bitcast [[A_T]]* [[T4]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T5]])
+
+ // CHECK-NEXT: load [[TEST33]]** [[PTR]]
+ // CHECK-NEXT: [[T0:%.*]] = load [[A_T]]** [[A]]
+ // CHECK-NEXT: store [[A_T]]* [[T0]], [[A_T]]** [[TEMP1]]
+ // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: objc_msgSend{{.*}}, [[A_T]]** [[TEMP1]])
+ // CHECK-NEXT: [[T0:%.*]] = load [[A_T]]** [[TEMP1]]
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[A_T]]* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]])
+ // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[A_T]]*
+ // CHECK-NEXT: [[T4:%.*]] = load [[A_T]]** [[A]]
+ // CHECK-NEXT: store [[A_T]]* [[T3]], [[A_T]]** [[A]]
+ // CHECK-NEXT: [[T5:%.*]] = bitcast [[A_T]]* [[T4]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T5]])
+
+ // CHECK-NEXT: load [[TEST33]]** [[PTR]]
+ // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: objc_msgSend{{.*}}, [[A_T]]** [[A]])
+
+ // CHECK-NEXT: load [[TEST33]]** [[PTR]]
+ // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: objc_msgSend{{.*}}, [[A_T]]** [[A]])
+
+ // 'out'
+ // CHECK-NEXT: load [[TEST33]]** [[PTR]]
+ // CHECK-NEXT: store [[A_T]]* null, [[A_T]]** [[TEMP2]]
+ // CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: objc_msgSend{{.*}}, [[A_T]]** [[TEMP2]])
+ // CHECK-NEXT: [[T0:%.*]] = load [[A_T]]** [[TEMP2]]
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[A_T]]* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]])
+ // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[A_T]]*
+ // CHECK-NEXT: [[T4:%.*]] = load [[A_T]]** [[A]]
+ // CHECK-NEXT: store [[A_T]]* [[T3]], [[A_T]]** [[A]]
+ // CHECK-NEXT: [[T5:%.*]] = bitcast [[A_T]]* [[T4]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T5]])
+
+ // CHECK-NEXT: load
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: objc_release
+ // CHECK-NEXT: load
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: objc_release
+ // CHECK-NEXT: ret void
+}
+
+void test34(int cond) {
+ __strong id strong;
+ __weak id weak;
+ extern void test34_sink(id *);
+ test34_sink(cond ? &strong : 0);
+ test34_sink(cond ? &weak : 0);
+
+ // CHECK: define void @test34(
+ // CHECK: [[COND:%.*]] = alloca i32
+ // CHECK-NEXT: [[STRONG:%.*]] = alloca i8*
+ // CHECK-NEXT: [[WEAK:%.*]] = alloca i8*
+ // CHECK-NEXT: [[TEMP1:%.*]] = alloca i8*
+ // CHECK-NEXT: [[TEMP2:%.*]] = alloca i8*
+ // CHECK-NEXT: store i32
+ // CHECK-NEXT: store i8* null, i8** [[STRONG]]
+ // CHECK-NEXT: call i8* @objc_initWeak(i8** [[WEAK]], i8* null)
+
+ // CHECK-NEXT: [[T0:%.*]] = load i32* [[COND]]
+ // CHECK-NEXT: [[T1:%.*]] = icmp ne i32 [[T0]], 0
+ // CHECK: [[ARG:%.*]] = phi i8**
+ // CHECK-NEXT: [[T0:%.*]] = icmp eq i8** [[ARG]], null
+ // CHECK-NEXT: [[T1:%.*]] = select i1 [[T0]], i8** null, i8** [[TEMP1]]
+ // CHECK-NEXT: br i1 [[T0]],
+ // CHECK: [[T0:%.*]] = load i8** [[ARG]]
+ // CHECK-NEXT: store i8* [[T0]], i8** [[TEMP1]]
+ // CHECK-NEXT: br label
+ // CHECK: call void @test34_sink(i8** [[T1]])
+ // CHECK-NEXT: [[T0:%.*]] = icmp eq i8** [[ARG]], null
+ // CHECK-NEXT: br i1 [[T0]],
+ // CHECK: [[T0:%.*]] = load i8** [[TEMP1]]
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
+ // CHECK-NEXT: [[T2:%.*]] = load i8** [[ARG]]
+ // CHECK-NEXT: store i8* [[T1]], i8** [[ARG]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T2]])
+ // CHECK-NEXT: br label
+
+ // CHECK: [[T0:%.*]] = load i32* [[COND]]
+ // CHECK-NEXT: [[T1:%.*]] = icmp ne i32 [[T0]], 0
+ // CHECK: [[ARG:%.*]] = phi i8**
+ // CHECK-NEXT: [[T0:%.*]] = icmp eq i8** [[ARG]], null
+ // CHECK-NEXT: [[T1:%.*]] = select i1 [[T0]], i8** null, i8** [[TEMP2]]
+ // CHECK-NEXT: br i1 [[T0]],
+ // CHECK: [[T0:%.*]] = call i8* @objc_loadWeak(i8** [[ARG]])
+ // CHECK-NEXT: store i8* [[T0]], i8** [[TEMP2]]
+ // CHECK-NEXT: br label
+ // CHECK: call void @test34_sink(i8** [[T1]])
+ // CHECK-NEXT: [[T0:%.*]] = icmp eq i8** [[ARG]], null
+ // CHECK-NEXT: br i1 [[T0]],
+ // CHECK: [[T0:%.*]] = load i8** [[TEMP2]]
+ // CHECK-NEXT: call i8* @objc_storeWeak(i8** [[ARG]], i8* [[T0]])
+ // CHECK-NEXT: br label
+
+ // CHECK: call void @objc_destroyWeak(i8** [[WEAK]])
+ // CHECK: ret void
+}
+
+// CHECK: define void @test36
+void test36(id x) {
+ // CHECK: [[X:%.*]] = alloca i8*
+
+ // CHECK: call i8* @objc_retain
+ // CHECK: call i8* @objc_retain
+ // CHECK: call i8* @objc_retain
+ id array[3] = { @"A", x, @"y" };
+
+ // CHECK: [[T0:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: store i8* null, i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ x = 0;
+
+ // CHECK: br label
+ // CHECK: call void @objc_release
+ // CHECK: br i1
+
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+}
+
+@class Test37;
+void test37(void) {
+ extern void test37_helper(id *);
+ Test37 *var;
+ test37_helper(&var);
+
+ // CHECK: define void @test37()
+ // CHECK: [[VAR:%.*]] = alloca [[TEST37:%.*]]*,
+ // CHECK-NEXT: [[TEMP:%.*]] = alloca i8*
+ // CHECK-NEXT: store [[TEST37]]* null, [[TEST37]]** [[VAR]]
+
+ // CHECK-NEXT: [[T0:%.*]] = load [[TEST37]]** [[VAR]]
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST37]]* [[T0]] to i8*
+ // CHECK-NEXT: store i8* [[T1]], i8** [[TEMP]]
+ // CHECK-NEXT: call void @test37_helper(i8** [[TEMP]])
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[TEMP]]
+ // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[TEST37]]*
+ // CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST37]]* [[T1]] to i8*
+ // CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retain(i8* [[T2]])
+ // CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to [[TEST37]]*
+ // CHECK-NEXT: [[T5:%.*]] = load [[TEST37]]** [[VAR]]
+ // CHECK-NEXT: store [[TEST37]]* [[T4]], [[TEST37]]** [[VAR]]
+ // CHECK-NEXT: [[T6:%.*]] = bitcast [[TEST37]]* [[T5]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T6]])
+
+ // CHECK-NEXT: [[T0:%.*]] = load [[TEST37]]** [[VAR]]
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST37]]* [[T0]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ // CHECK-NEXT: ret void
+}
+
+@interface Test43 @end
+@implementation Test43
+- (id) test __attribute__((ns_returns_retained)) {
+ extern id test43_produce(void);
+ return test43_produce();
+ // CHECK: call i8* @test43_produce()
+ // CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue(
+ // CHECK-NEXT: ret
+}
+@end
+
+@interface Test45
+@property (retain) id x;
+@end
+@implementation Test45
+@synthesize x;
+@end
+// CHECK: define internal i8* @"\01-[Test45 x]"(
+// CHECK: [[CALL:%.*]] = call i8* @objc_getProperty(
+// CHECK-NEXT: ret i8* [[CALL]]
+
+// rdar://problem/9315552
+void test46(__weak id *wp, __weak volatile id *wvp) {
+ extern id test46_helper(void);
+
+ // TODO: this is sub-optimal, we should retain at the actual call site.
+
+ // CHECK: [[T0:%.*]] = call i8* @test46_helper()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: [[T2:%.*]] = load i8*** {{%.*}}, align 8
+ // CHECK-NEXT: [[T3:%.*]] = call i8* @objc_storeWeak(i8** [[T2]], i8* [[T1]])
+ // CHECK-NEXT: [[T4:%.*]] = call i8* @objc_retain(i8* [[T3]])
+ // CHECK-NEXT: store i8* [[T4]], i8**
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ id x = *wp = test46_helper();
+
+ // CHECK: [[T0:%.*]] = call i8* @test46_helper()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: [[T2:%.*]] = load i8*** {{%.*}}, align 8
+ // CHECK-NEXT: [[T3:%.*]] = call i8* @objc_storeWeak(i8** [[T2]], i8* [[T1]])
+ // CHECK-NEXT: [[T4:%.*]] = call i8* @objc_retain(i8* [[T3]])
+ // CHECK-NEXT: store i8* [[T4]], i8**
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ id y = *wvp = test46_helper();
+}
+
+// rdar://problem/9378887
+void test47(void) {
+ extern id test47_helper(void);
+ id x = x = test47_helper();
+
+ // CHECK: define void @test47()
+ // CHECK: [[X:%.*]] = alloca i8*
+ // CHECK-NEXT: store i8* null, i8** [[X]]
+ // CHECK-NEXT: [[CALL:%.*]] = call i8* @test47_helper()
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[CALL]])
+ // CHECK-NEXT: [[T1:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: store i8* [[T0]], i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T0]])
+ // CHECK-NEXT: [[T3:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: store i8* [[T2]], i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T3]])
+ // CHECK-NEXT: [[T4:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T4]])
+ // CHECK-NEXT: ret void
+}
+
+void test48(void) {
+ extern id test48_helper(void);
+ __weak id x = x = test48_helper();
+ // CHECK: define void @test48()
+ // CHECK: [[X:%.*]] = alloca i8*
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_initWeak(i8** [[X]], i8* null)
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @test48_helper()
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
+ // CHECK-NEXT: [[T3:%.*]] = call i8* @objc_storeWeak(i8** [[X]], i8* [[T2]])
+ // CHECK-NEXT: [[T4:%.*]] = call i8* @objc_storeWeak(i8** [[X]], i8* [[T3]])
+ // CHECK-NEXT: call void @objc_release(i8* [[T2]])
+ // CHECK-NEXT: call void @objc_destroyWeak(i8** [[X]])
+ // CHECK-NEXT: ret void
+}
+
+void test49(void) {
+ extern id test49_helper(void);
+ __autoreleasing id x = x = test49_helper();
+ // CHECK: define void @test49()
+ // CHECK: [[X:%.*]] = alloca i8*
+ // CHECK-NEXT: store i8* null, i8** [[X]]
+ // CHECK-NEXT: [[CALL:%.*]] = call i8* @test49_helper()
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[CALL]])
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_autorelease(i8* [[T0]])
+ // CHECK-NEXT: store i8* [[T2]], i8** [[X]]
+ // CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retainAutorelease(i8* [[T1]])
+ // CHECK-NEXT: store i8* [[T3]], i8** [[X]]
+ // CHECK-NEXT: ret void
+}
+
+// rdar://9380136
+id x();
+void test50(id y) {
+ ({x();});
+// CHECK: [[T0:%.*]] = call i8* @objc_retain
+// CHECK: call void @objc_release
+}
+
+
+// rdar://9400762
+struct CGPoint {
+ float x;
+ float y;
+};
+typedef struct CGPoint CGPoint;
+
+@interface Foo
+@property (assign) CGPoint point;
+@end
+
+@implementation Foo
+@synthesize point;
+@end
+
+// rdar://problem/9400398
+id test52(void) {
+ id test52_helper(int) __attribute__((ns_returns_retained));
+ return ({ int x = 5; test52_helper(x); });
+
+// CHECK: define i8* @test52()
+// CHECK: [[X:%.*]] = alloca i32
+// CHECK-NEXT: store i32 5, i32* [[X]],
+// CHECK-NEXT: [[T0:%.*]] = load i32* [[X]],
+// CHECK-NEXT: [[T1:%.*]] = call i8* @test52_helper(i32 [[T0]])
+// CHECK-NEXT: [[T2:%.*]] = call i8* @objc_autoreleaseReturnValue(i8* [[T1]])
+// CHECK-NEXT: ret i8* [[T2]]
+}
+
+// rdar://problem/9400644
+void test53(void) {
+ id test53_helper(void);
+ id x = ({ id y = test53_helper(); y; });
+ (void) x;
+// CHECK: define void @test53()
+// CHECK: [[X:%.*]] = alloca i8*,
+// CHECK-NEXT: [[Y:%.*]] = alloca i8*,
+// CHECK-NEXT: [[T0:%.*]] = call i8* @test53_helper()
+// CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+// CHECK-NEXT: store i8* [[T1]], i8** [[Y]],
+// CHECK-NEXT: [[T0:%.*]] = load i8** [[Y]],
+// CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
+// CHECK-NEXT: [[T2:%.*]] = load i8** [[Y]]
+// CHECK-NEXT: call void @objc_release(i8* [[T2]])
+// CHECK-NEXT: store i8* [[T1]], i8** [[X]],
+// CHECK-NEXT: load i8** [[X]],
+// CHECK-NEXT: [[T0:%.*]] = load i8** [[X]]
+// CHECK-NEXT: call void @objc_release(i8* [[T0]])
+// CHECK-NEXT: ret void
+}
+
+// <rdar://problem/9758798>
+// CHECK: define void @test54(i32 %first, ...)
+void test54(int first, ...) {
+ __builtin_va_list arglist;
+ // CHECK: call void @llvm.va_start
+ __builtin_va_start(arglist, first);
+ // CHECK: call i8* @objc_retain
+ id obj = __builtin_va_arg(arglist, id);
+ // CHECK: call void @llvm.va_end
+ __builtin_va_end(arglist);
+ // CHECK: call void @objc_release
+ // CHECK: ret void
+}
+
+// PR10228
+@interface Test55Base @end
+@interface Test55 : Test55Base @end
+@implementation Test55 (Category)
+- (void) dealloc {}
+@end
+// CHECK: define internal void @"\01-[Test55(Category) dealloc]"(
+// CHECK-NOT: ret
+// CHECK: call void bitcast (i8* ({{%.*}}*, i8*, ...)* @objc_msgSendSuper2 to void ({{%.*}}*, i8*)*)(
+
+// rdar://problem/8024350
+@protocol Test56Protocol
++ (id) make __attribute__((ns_returns_retained));
+@end
+@interface Test56<Test56Protocol> @end
+@implementation Test56
+// CHECK: define internal i8* @"\01+[Test56 make]"(
++ (id) make {
+ extern id test56_helper(void);
+ // CHECK: [[T0:%.*]] = call i8* @test56_helper()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: ret i8* [[T1]]
+ return test56_helper();
+}
+@end
+void test56_test(void) {
+ id x = [Test56 make];
+ // CHECK: define void @test56_test()
+ // CHECK: [[X:%.*]] = alloca i8*, align 8
+ // CHECK: [[T0:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(
+ // CHECK-NEXT: store i8* [[T0]], i8** [[X]]
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: ret void
+}
+
+// rdar://problem/9784964
+@interface Test57
+@property (nonatomic, strong) id strong;
+@property (nonatomic, weak) id weak;
+@property (nonatomic, unsafe_unretained) id unsafe;
+@end
+@implementation Test57
+@synthesize strong, weak, unsafe;
+@end
+// CHECK: define internal i8* @"\01-[Test57 strong]"(
+// CHECK: [[T0:%.*]] = load [[TEST57:%.*]]** {{%.*}}
+// CHECK-NEXT: [[T1:%.*]] = load i64* @"OBJC_IVAR_$_Test57.strong"
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST57]]* [[T0]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8* [[T2]], i64 [[T1]]
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i8**
+// CHECK-NEXT: [[T5:%.*]] = load i8** [[T4]]
+// CHECK-NEXT: ret i8* [[T5]]
+
+// CHECK: define internal i8* @"\01-[Test57 weak]"(
+// CHECK: [[T0:%.*]] = load [[TEST57]]** {{%.*}}
+// CHECK-NEXT: [[T1:%.*]] = load i64* @"OBJC_IVAR_$_Test57.weak"
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST57]]* [[T0]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8* [[T2]], i64 [[T1]]
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i8**
+// CHECK-NEXT: [[T5:%.*]] = call i8* @objc_loadWeakRetained(i8** [[T4]])
+// CHECK-NEXT: [[T6:%.*]] = call i8* @objc_autoreleaseReturnValue(i8* [[T5]])
+// CHECK-NEXT: ret i8* [[T6]]
+
+// CHECK: define internal i8* @"\01-[Test57 unsafe]"(
+// CHECK: [[T0:%.*]] = load [[TEST57]]** {{%.*}}
+// CHECK-NEXT: [[T1:%.*]] = load i64* @"OBJC_IVAR_$_Test57.unsafe"
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST57]]* [[T0]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds i8* [[T2]], i64 [[T1]]
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i8**
+// CHECK-NEXT: [[T5:%.*]] = load i8** [[T4]]
+// CHECK-NEXT: ret i8* [[T5]]
+
+// rdar://problem/9821110
+@interface Test58
+- (char*) interior __attribute__((objc_returns_inner_pointer));
+// Should we allow this on properties?
+@end
+extern Test58 *test58_helper(void);
+
+// CHECK: define void @test58a()
+void test58a(void) {
+ // CHECK: [[T0:%.*]] = call [[TEST58:%.*]]* @test58_helper()
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST58]]* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
+ // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST58]]*
+ // CHECK-NEXT: store [[TEST58]]* [[T3]]
+ // CHECK-NEXT: [[T0:%.*]] = load [[TEST58]]**
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST58]]* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutorelease(i8* [[T1]])
+ // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST58]]*
+ // CHECK-NEXT: [[T4:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: [[T5:%.*]] = bitcast [[TEST58]]* [[T3]] to i8*
+ // CHECK-NEXT: [[T6:%.*]] = call i8* bitcast
+ // CHECK-NEXT: store i8* [[T6]], i8**
+ // CHECK-NEXT: [[T0:%.*]] = load [[TEST58]]**
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST58]]* [[T0]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind, !clang.imprecise_release
+ // CHECK-NEXT: ret void
+ Test58 *ptr = test58_helper();
+ char *c = [(ptr) interior];
+}
+
+// CHECK: define void @test58b()
+void test58b(void) {
+ // CHECK: [[T0:%.*]] = call [[TEST58:%.*]]* @test58_helper()
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST58]]* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
+ // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST58]]*
+ // CHECK-NEXT: store [[TEST58]]* [[T3]]
+ // CHECK-NEXT: [[T0:%.*]] = load [[TEST58]]**
+ // CHECK-NEXT: [[T1:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST58]]* [[T0]] to i8*
+ // CHECK-NEXT: [[T3:%.*]] = call i8* bitcast
+ // CHECK-NEXT: store i8* [[T3]], i8**
+ // CHECK-NEXT: [[T0:%.*]] = load [[TEST58]]**
+ // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST58]]* [[T0]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind
+ // CHECK-NOT: clang.imprecise_release
+ // CHECK-NEXT: ret void
+ __attribute__((objc_precise_lifetime)) Test58 *ptr = test58_helper();
+ char *c = [ptr interior];
+}
+
+// rdar://problem/9842343
+void test59(void) {
+ extern id test59_getlock(void);
+ extern void test59_body(void);
+ @synchronized (test59_getlock()) {
+ test59_body();
+ }
+
+ // CHECK: define void @test59()
+ // CHECK: [[T0:%.*]] = call i8* @test59_getlock()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: call void @objc_sync_enter(i8* [[T1]])
+ // CHECK-NEXT: call void @test59_body()
+ // CHECK-NEXT: call void @objc_sync_exit(i8* [[T1]])
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ // CHECK-NEXT: ret void
+}
+
+// Verify that we don't try to reclaim the result of performSelector.
+// rdar://problem/9887545
+@interface Test61
+- (id) performSelector: (SEL) selector;
+- (void) test61_void;
+- (id) test61_id;
+@end
+void test61(void) {
+ // CHECK: define void @test61()
+ // CHECK: [[Y:%.*]] = alloca i8*, align 8
+
+ extern id test61_make(void);
+
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @test61_make()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: [[T2:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: [[T3:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: [[T4:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8*)*)(i8* [[T1]], i8* [[T3]], i8* [[T2]])
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ [test61_make() performSelector: @selector(test61_void)];
+
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @test61_make()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: [[T2:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: [[T3:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+ // CHECK-NEXT: [[T4:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8*)*)(i8* [[T1]], i8* [[T3]], i8* [[T2]])
+ // CHECK-NEXT: [[T5:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T4]])
+ // CHECK-NEXT: store i8* [[T5]], i8** [[Y]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ id y = [test61_make() performSelector: @selector(test61_id)];
+
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[Y]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: ret void
+}
+
+// rdar://problem/9891815
+void test62(void) {
+ // CHECK: define void @test62()
+ // CHECK: [[I:%.*]] = alloca i32, align 4
+ // CHECK-NEXT: [[CLEANUP_VALUE:%.*]] = alloca i8*
+ // CHECK-NEXT: [[CLEANUP_REQUIRED:%.*]] = alloca i1
+ extern id test62_make(void);
+ extern void test62_body(void);
+
+ // CHECK-NEXT: store i32 0, i32* [[I]], align 4
+ // CHECK-NEXT: br label
+
+ // CHECK: [[T0:%.*]] = load i32* [[I]], align 4
+ // CHECK-NEXT: [[T1:%.*]] = icmp ne i32 [[T0]], 20
+ // CHECK-NEXT: br i1 [[T1]],
+
+ for (unsigned i = 0; i != 20; ++i) {
+ // CHECK: [[T0:%.*]] = load i32* [[I]], align 4
+ // CHECK-NEXT: [[T1:%.*]] = icmp ne i32 [[T0]], 0
+ // CHECK-NEXT: store i1 false, i1* [[CLEANUP_REQUIRED]]
+ // CHECK-NEXT: br i1 [[T1]],
+ // CHECK: [[T0:%.*]] = call i8* @test62_make()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: store i8* [[T1]], i8** [[CLEANUP_VALUE]]
+ // CHECK-NEXT: store i1 true, i1* [[CLEANUP_REQUIRED]]
+ // CHECK-NEXT: [[T2:%.*]] = icmp ne i8* [[T1]], null
+ // CHECK-NEXT: br label
+ // CHECK: [[COND:%.*]] = phi i1 [ false, {{%.*}} ], [ [[T2]], {{%.*}} ]
+ // CHECK-NEXT: [[T0:%.*]] = load i1* [[CLEANUP_REQUIRED]]
+ // CHECK-NEXT: br i1 [[T0]],
+ // CHECK: [[T0:%.*]] = load i8** [[CLEANUP_VALUE]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: br label
+ // CHECK: br i1 [[COND]]
+ // CHECK: call void @test62_body()
+ // CHECK-NEXT: br label
+ // CHECK: br label
+ if (i != 0 && test62_make() != 0)
+ test62_body();
+ }
+
+ // CHECK: [[T0:%.*]] = load i32* [[I]], align 4
+ // CHECK-NEXT: [[T1:%.*]] = add i32 [[T0]], 1
+ // CHECK-NEXT: store i32 [[T1]], i32* [[I]]
+ // CHECK-NEXT: br label
+
+ // CHECK: ret void
+}
+
+// rdar://9971982
+@class NSString;
+
+@interface Person {
+ NSString *name;
+}
+@property NSString *address;
+@end
+
+@implementation Person
+@synthesize address;
+@end
+// CHECK: call i8* @objc_getProperty
+// CHECK: call void @objc_setProperty
+
+// Verify that we successfully parse and preserve this attribute in
+// this position.
+@interface Test66
+- (void) consume: (id __attribute__((ns_consumed))) ptr;
+@end
+void test66(void) {
+ extern Test66 *test66_receiver(void);
+ extern id test66_arg(void);
+ [test66_receiver() consume: test66_arg()];
+}
+// CHECK: define void @test66()
+// CHECK: [[T0:%.*]] = call [[TEST66:%.*]]* @test66_receiver()
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST66]]* [[T0]] to i8*
+// CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
+// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST66]]*
+// CHECK-NEXT: [[T4:%.*]] = call i8* @test66_arg()
+// CHECK-NEXT: [[T5:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T4]])
+// CHECK-NEXT: [[T6:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[T7:%.*]] = bitcast [[TEST66]]* [[T3]] to i8*
+// CHECK-NEXT: [[SIX:%.*]] = icmp eq i8* [[T7]], null
+// CHECK-NEXT: br i1 [[SIX]], label [[NULINIT:%.*]], label [[CALL:%.*]]
+// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*)*)(i8* [[T7]], i8* [[T6]], i8* [[T5]])
+// CHECK-NEXT: br label [[CONT:%.*]]
+// CHECK: call void @objc_release(i8* [[T5]]) nounwind
+// CHECK-NEXT: br label [[CONT:%.*]]
+// CHECK: [[T8:%.*]] = bitcast [[TEST66]]* [[T3]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T8]])
+// CHECK-NEXT: ret void
+
+// rdar://problem/9953540
+Class test67_helper(void);
+void test67(void) {
+ Class cl = test67_helper();
+}
+// CHECK: define void @test67()
+// CHECK: [[CL:%.*]] = alloca i8*, align 8
+// CHECK-NEXT: [[T0:%.*]] = call i8* @test67_helper()
+// CHECK-NEXT: store i8* [[T0]], i8** [[CL]], align 8
+// CHECK-NEXT: ret void
+
+Class test68_helper(void);
+void test68(void) {
+ __strong Class cl = test67_helper();
+}
+// CHECK: define void @test68()
+// CHECK: [[CL:%.*]] = alloca i8*, align 8
+// CHECK-NEXT: [[T0:%.*]] = call i8* @test67_helper()
+// CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+// CHECK-NEXT: store i8* [[T1]], i8** [[CL]], align 8
+// CHECK-NEXT: [[T2:%.*]] = load i8** [[CL]]
+// CHECK-NEXT: call void @objc_release(i8* [[T2]])
+// CHECK-NEXT: ret void
+
+// rdar://problem/10564852
+@interface Test69 @end
+@implementation Test69
+- (id) foo { return self; }
+@end
+// CHECK: define internal i8* @"\01-[Test69 foo]"(
+// CHECK: [[SELF:%.*]] = alloca [[TEST69:%.*]]*, align 8
+// CHECK: [[T0:%.*]] = load [[TEST69]]** [[SELF]], align 8
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST69]]* [[T0]] to i8*
+// CHECK-NEXT: ret i8* [[T1]]
+
+// rdar://problem/10907547
+void test70(id i) {
+ // CHECK: define void @test70
+ // CHECK: store i8* null, i8**
+ // CHECK: store i8* null, i8**
+ // CHECK: [[ID:%.*]] = call i8* @objc_retain(i8*
+ // CHECK: store i8* [[ID]], i8**
+ id x[3] = {
+ [2] = i
+ };
+}
diff --git a/clang/test/CodeGenObjC/arm-atomic-scalar-setter-getter.m b/clang/test/CodeGenObjC/arm-atomic-scalar-setter-getter.m
new file mode 100644
index 0000000..535cbbb
--- /dev/null
+++ b/clang/test/CodeGenObjC/arm-atomic-scalar-setter-getter.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple armv7-apple-darwin10 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-ARM %s
+// rdar://7761305
+
+@interface I
+@property long long LONG_PROP;
+@end
+
+@implementation I
+@synthesize LONG_PROP;
+@end
+// CHECK-ARM: call arm_aapcscc void @objc_copyStruct(i8* %{{.*}}, i8* %{{.*}}, i32 8, i1 zeroext true, i1 zeroext false)
+// CHECK-ARM: call arm_aapcscc void @objc_copyStruct(i8* %{{.*}}, i8* %{{.*}}, i32 8, i1 zeroext true, i1 zeroext false)
+
diff --git a/clang/test/CodeGenObjC/assign.m b/clang/test/CodeGenObjC/assign.m
new file mode 100644
index 0000000..82da800
--- /dev/null
+++ b/clang/test/CodeGenObjC/assign.m
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -triple x86_64 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s
+
+struct s0 {
+ int x;
+};
+
+@interface C0
+@property int x0;
+@property _Complex int x1;
+@property struct s0 x2;
+@end
+
+// Check that we get exactly the message sends we expect, and no more.
+//
+// CHECK: define void @f0
+void f0(C0 *a) {
+// CHECK: objc_msgSend
+ int l0 = (a.x0 = 1);
+
+// CHECK: objc_msgSend
+ _Complex int l1 = (a.x1 = 1);
+
+// CHECK: objc_msgSend
+ struct s0 l2 = (a.x2 = (struct s0) { 1 });
+
+// CHECK: objc_msgSend
+// CHECK: objc_msgSend
+ int l3 = (a.x0 += 1);
+
+// CHECK: objc_msgSend
+// CHECK: objc_msgSend
+ _Complex int l4 = (a.x1 += 1);
+
+// CHECK-NOT: objc_msgSend
+// CHECK: }
+}
diff --git a/clang/test/CodeGenObjC/atomic-aggregate-property.m b/clang/test/CodeGenObjC/atomic-aggregate-property.m
new file mode 100644
index 0000000..978299b
--- /dev/null
+++ b/clang/test/CodeGenObjC/atomic-aggregate-property.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s
+// rdar: // 7849824
+
+struct s {
+ double a, b, c, d;
+};
+
+struct s1 {
+ int i;
+ id j;
+ id k;
+};
+
+@interface A
+@property (readwrite) double x;
+@property (readwrite) struct s y;
+@property (nonatomic, readwrite) struct s1 z;
+@end
+
+@implementation A
+@synthesize x;
+@synthesize y;
+@synthesize z;
+@end
+// CHECK-LP64: define internal double @"\01-[A x]"(
+// CHECK-LP64: load atomic i64* {{%.*}} unordered, align 8
+
+// CHECK-LP64: define internal void @"\01-[A setX:]"(
+// CHECK-LP64: store atomic i64 {{%.*}}, i64* {{%.*}} unordered, align 8
+
+// CHECK-LP64: define internal void @"\01-[A y]"(
+// CHECK-LP64: call void @objc_copyStruct(i8* {{%.*}}, i8* {{%.*}}, i64 32, i1 zeroext true, i1 zeroext false)
+
+// CHECK-LP64: define internal void @"\01-[A setY:]"(
+// CHECK-LP64: call void @objc_copyStruct(i8* {{%.*}}, i8* {{%.*}}, i64 32, i1 zeroext true, i1 zeroext false)
+
+// CHECK-LP64: define internal void @"\01-[A z]"(
+// CHECK-LP64: call i8* @objc_memmove_collectable(
+
+// CHECK-LP64: define internal void @"\01-[A setZ:]"(
+// CHECK-LP64: call i8* @objc_memmove_collectable(
diff --git a/clang/test/CodeGenObjC/attr-availability.m b/clang/test/CodeGenObjC/attr-availability.m
new file mode 100644
index 0000000..375a5be
--- /dev/null
+++ b/clang/test/CodeGenObjC/attr-availability.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fvisibility hidden "-triple" "x86_64-apple-darwin8.0.0" -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-10_4 %s
+// RUN: %clang_cc1 -fvisibility hidden "-triple" "x86_64-apple-darwin9.0.0" -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-10_5 %s
+// RUN: %clang_cc1 -fvisibility hidden "-triple" "x86_64-apple-darwin10.0.0" -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-10_6 %s
+
+// CHECK-10_4: @"OBJC_CLASS_$_WeakClass1" = extern_weak global
+// CHECK-10_5: @"OBJC_CLASS_$_WeakClass1" = external global
+// CHECK-10_6: @"OBJC_CLASS_$_WeakClass1" = external global
+__attribute__((availability(macosx,introduced=10.5)))
+@interface WeakClass1 @end
+
+@implementation WeakClass1(MyCategory) @end
+
+@implementation WeakClass1(YourCategory) @end
+
+// CHECK-10_4: @"OBJC_CLASS_$_WeakClass2" = extern_weak global
+// CHECK-10_5: @"OBJC_CLASS_$_WeakClass2" = extern_weak global
+// CHECK-10_6: @"OBJC_CLASS_$_WeakClass2" = external global
+__attribute__((availability(macosx,introduced=10.6)))
+@interface WeakClass2 @end
+
+@implementation WeakClass2(MyCategory) @end
+
+@implementation WeakClass2(YourCategory) @end
+
diff --git a/clang/test/CodeGenObjC/attr-strong.c b/clang/test/CodeGenObjC/attr-strong.c
new file mode 100644
index 0000000..f1474bc
--- /dev/null
+++ b/clang/test/CodeGenObjC/attr-strong.c
@@ -0,0 +1,9 @@
+// RUN: %clang -emit-llvm -S -o %t %s
+
+struct s0 {
+ void *a;
+};
+struct s0 * __attribute__((objc_gc(strong))) g0;
+void f0(void) {
+ g0->a = 0;
+}
diff --git a/clang/test/CodeGenObjC/auto-property-synthesize-protocol.m b/clang/test/CodeGenObjC/auto-property-synthesize-protocol.m
new file mode 100644
index 0000000..49a4037
--- /dev/null
+++ b/clang/test/CodeGenObjC/auto-property-synthesize-protocol.m
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fobjc-default-synthesize-properties -emit-llvm %s -o - | FileCheck %s
+// rdar://10907410
+
+@protocol P
+@optional
+@property int auto_opt_window;
+@property int no_auto_opt_window;
+@end
+
+@interface I<P>
+@property int auto_opt_window;
+@end
+
+@implementation I
+@end
+
+@protocol P1
+@property int auto_req_window;
+@property int no_auto_req_window; // expected-note {{property declared here}}
+@end
+
+@interface I1<P1>
+@property int auto_req_window;
+@end
+
+@implementation I1 // expected-warning {{auto property synthesis will not synthesize property declared in a protocol}}
+@end
+
+// CHECK: define internal i32 @"\01-[I auto_opt_window]"(
+// CHECK: define internal void @"\01-[I setAuto_opt_window:]"(
+// CHECK: define internal i32 @"\01-[I1 auto_req_window]"(
+// CHECK: define internal void @"\01-[I1 setAuto_req_window:]"(
+
+// CHECK-NOT: define internal i32 @"\01-[I1 no_auto_opt_window]"(
+// CHECK-NOT: define internal void @"\01-[I1 setNo_auto_opt_window:]"(
+// CHECK-NOT: define internal i32 @"\01-[I no_auto_req_window]"(
+// CHECK-NOT: define internal void @"\01-[I setNo_auto_req_window:]"(
diff --git a/clang/test/CodeGenObjC/autorelease.m b/clang/test/CodeGenObjC/autorelease.m
new file mode 100644
index 0000000..9260c3f
--- /dev/null
+++ b/clang/test/CodeGenObjC/autorelease.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-runtime-has-arc -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -emit-llvm -fobjc-runtime-has-arc -o - %s | FileCheck %s
+// rdar://8881826
+// rdar://9412038
+
+@interface I
+{
+ id ivar;
+}
+- (id) Meth;
++ (id) MyAlloc;;
+@end
+
+@implementation I
+- (id) Meth {
+ @autoreleasepool {
+ id p = [I MyAlloc];
+ if (!p)
+ return ivar;
+ }
+ return 0;
+}
++ (id) MyAlloc {
+ return 0;
+}
+@end
+
+// CHECK: call i8* @objc_autoreleasePoolPush
+// CHECK: [[T:%.*]] = load i8** [[A:%.*]]
+// CHECK: call void @objc_autoreleasePoolPop
diff --git a/clang/test/CodeGenObjC/bitfield-1.m b/clang/test/CodeGenObjC/bitfield-1.m
new file mode 100644
index 0000000..648ab2a
--- /dev/null
+++ b/clang/test/CodeGenObjC/bitfield-1.m
@@ -0,0 +1,81 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fobjc-fragile-abi -emit-llvm -o %t %s
+
+@interface Object
+- (id) alloc;
+- (id) init;
+@end
+
+extern void abort(void);
+
+#define CHECK_IF(expr) if(!(expr)) abort();
+
+@interface Base: Object
+{
+ int full;
+ int full2: 32;
+ int _refs: 8;
+ int field2: 3;
+ unsigned f3: 8;
+ short cc;
+ unsigned g: 16;
+ int r2: 8;
+ int r3: 8;
+ int r4: 2;
+ int r5: 8;
+ char c;
+}
+- (void)setValues;
+@end
+
+@interface Derived: Base
+{
+ char d;
+ int _field3: 6;
+}
+- (void)checkValues;
+@end
+
+@implementation Base
+-(void)setValues {
+ full = 1;
+ full2 = 2;
+ _refs = 3;
+ field2 = 1;
+ f3 = 6;
+ cc = 7;
+ g = 8;
+ r2 = 9;
+ r3 = 10;
+ r4 = 1;
+ r5 = 12;
+ c = 13;
+}
+@end
+
+@implementation Derived
+-(void)checkValues {
+ CHECK_IF(full == 1);
+ CHECK_IF(full2 == 2);
+ CHECK_IF(_refs == 3);
+ CHECK_IF(field2 == 1);
+ CHECK_IF(f3 == 6);
+ CHECK_IF(cc == 7);
+ CHECK_IF(g == 8);
+ CHECK_IF(r2 == 9);
+ CHECK_IF(r3 == 10);
+ CHECK_IF(r4 == 1);
+ CHECK_IF(r5 == 12);
+ CHECK_IF(c == 13);
+}
+@end
+
+int main(void) {
+ Derived *obj = [[Derived alloc] init];
+
+ [obj setValues];
+ [obj checkValues];
+
+ return 0;
+}
diff --git a/clang/test/CodeGenObjC/bitfield-access.m b/clang/test/CodeGenObjC/bitfield-access.m
new file mode 100644
index 0000000..521d2e5
--- /dev/null
+++ b/clang/test/CodeGenObjC/bitfield-access.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o %t1 %s
+// RUN: FileCheck -check-prefix=CHECK-I386 < %t1 %s
+
+// RUN: %clang_cc1 -triple armv6-apple-darwin10 -fobjc-fragile-abi -target-abi apcs-gnu -emit-llvm -o %t2 %s
+// RUN: FileCheck -check-prefix=CHECK-ARM < %t2 %s
+
+@interface I0 {
+@public
+ unsigned x:15;
+ unsigned y: 1;
+}
+@end
+
+// Check that we don't try to use an i32 load here, which would reach beyond the
+// end of the structure.
+//
+// CHECK-I386: define i32 @f0(
+// CHECK-I386: [[t0_0:%.*]] = load i16* {{.*}}, align 1
+// CHECK-I386: lshr i16 [[t0_0]], 7
+// CHECK-I386: }
+int f0(I0 *a) {
+ return a->y;
+}
+
+// Check that we can handled straddled loads.
+//
+// CHECK-ARM: define i32 @f1(
+// CHECK-ARM: [[t1_ptr:%.*]] = getelementptr
+// CHECK-ARM: [[t1_base:%.*]] = bitcast i8* [[t1_ptr]] to i32*
+// CHECK-ARM: [[t1_0:%.*]] = load i32* [[t1_base]], align 1
+// CHECK-ARM: lshr i32 [[t1_0]], 1
+// CHECK-ARM: [[t1_base_2_cast:%.*]] = bitcast i32* %{{.*}} to i8*
+// CHECK-ARM: [[t1_base_2:%.*]] = getelementptr i8* [[t1_base_2_cast]]
+// CHECK-ARM: [[t1_1:%.*]] = load i8* [[t1_base_2]], align 1
+// CHECK-ARM: and i8 [[t1_1:%.*]], 1
+// CHECK-ARM: }
+@interface I1 {
+@public
+ unsigned x: 1;
+ unsigned y:32;
+}
+@end
+
+int f1(I1 *a) { return a->y; }
diff --git a/clang/test/CodeGenObjC/bitfield-gnu.m b/clang/test/CodeGenObjC/bitfield-gnu.m
new file mode 100644
index 0000000..7935bda
--- /dev/null
+++ b/clang/test/CodeGenObjC/bitfield-gnu.m
@@ -0,0 +1,5 @@
+// RUN: %clang -S -emit-llvm -fgnu-runtime -o %t %s
+typedef enum { A1, A2 } A;
+typedef struct { A a : 1; } B;
+@interface Obj { B *b; } @end
+@implementation Obj @end
diff --git a/clang/test/CodeGenObjC/bitfield-ivar-metadata.m b/clang/test/CodeGenObjC/bitfield-ivar-metadata.m
new file mode 100644
index 0000000..9ab3fef
--- /dev/null
+++ b/clang/test/CodeGenObjC/bitfield-ivar-metadata.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@interface INTF
+{
+ unsigned ivar1;
+ unsigned ivar2;
+ unsigned char BDIVAR3:1;
+ unsigned char BDIVAR4:1;
+}
+@end
+
+@implementation INTF
+@end
+
+
diff --git a/clang/test/CodeGenObjC/bitfield-ivar-offsets.m b/clang/test/CodeGenObjC/bitfield-ivar-offsets.m
new file mode 100644
index 0000000..b0c848f
--- /dev/null
+++ b/clang/test/CodeGenObjC/bitfield-ivar-offsets.m
@@ -0,0 +1,25 @@
+// RUNX: llvm-gcc -m64 -emit-llvm -S -o %t %s &&
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s
+// RUN: grep -F '@"OBJC_IVAR_$_I0._b0" = global i64 0, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep -F '@"OBJC_IVAR_$_I0._b1" = global i64 0, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep -F '@"OBJC_IVAR_$_I0._b2" = global i64 1, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep -F '@"OBJC_IVAR_$_I0._x" = global i64 2, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep -F '@"OBJC_IVAR_$_I0._b3" = global i64 4, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep -F '@"OBJC_IVAR_$_I0._y" = global i64 6, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep -F '@"OBJC_IVAR_$_I0._b4" = global i64 7, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep -F '@"OBJC_IVAR_$_I0." = global' %t | count 0
+
+@interface I0 {
+ unsigned _b0:4;
+ unsigned _b1:5;
+ unsigned _b2:5;
+ char _x;
+ unsigned _b3:9;
+ char _y;
+ char _b4:3;
+ char : 0;
+}
+@end
+
+@implementation I0
+@end
diff --git a/clang/test/CodeGenObjC/bitfield_encoding.m b/clang/test/CodeGenObjC/bitfield_encoding.m
new file mode 100644
index 0000000..17fd4a4
--- /dev/null
+++ b/clang/test/CodeGenObjC/bitfield_encoding.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-fragile-abi -emit-llvm -o %t %s
+// RUN: grep "ib1b14" %t | count 1
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-fragile-abi -fgnu-runtime -emit-llvm -o %t %s
+// RUN: grep "ib32i1b33i14" %t | count 1
+
+struct foo{
+ int a;
+ int b:1;
+ int c:14;
+};
+
+const char *encoding = @encode(struct foo);
diff --git a/clang/test/CodeGenObjC/block-6.m b/clang/test/CodeGenObjC/block-6.m
new file mode 100644
index 0000000..140fa88
--- /dev/null
+++ b/clang/test/CodeGenObjC/block-6.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10 -fobjc-fragile-abi | FileCheck %s
+// rdar://8893785
+
+void MYFUNC() {
+// CHECK: define void @MYFUNC()
+// CHECK: [[OBSERVER_SLOT:%.*]] = alloca [[OBSERVER_T:%.*]], align 8
+
+// CHECK: [[T0:%.*]] = getelementptr inbounds [[OBSERVER_T]]* [[OBSERVER_SLOT]], i32 0, i32 1
+// CHECK: store [[OBSERVER_T]]* [[OBSERVER_SLOT]], [[OBSERVER_T]]** [[T0]]
+
+// CHECK: [[T1:%.*]] = bitcast i8* ()*
+// CHECK: [[FORWARDING:%.*]] = getelementptr inbounds [[OBSERVER_T]]* [[OBSERVER_SLOT]], i32 0, i32 1
+// CHECK-NEXT: [[T0:%.*]] = load [[OBSERVER_T]]** [[FORWARDING]]
+// CHECK-NEXT: [[OBSERVER:%.*]] = getelementptr inbounds [[OBSERVER_T]]* [[T0]], i32 0, i32 6
+// CHECK-NEXT: store i8* [[T1]], i8** [[OBSERVER]]
+ __block id observer = ^{ return observer; };
+}
+
diff --git a/clang/test/CodeGenObjC/block-var-layout.m b/clang/test/CodeGenObjC/block-var-layout.m
new file mode 100644
index 0000000..1d0ce2d
--- /dev/null
+++ b/clang/test/CodeGenObjC/block-var-layout.m
@@ -0,0 +1,166 @@
+// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -O0 -emit-llvm %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+
+struct S {
+ int i1;
+ id o1;
+ struct V {
+ int i2;
+ id o2;
+ } v1;
+ int i3;
+ id o3;
+};
+
+__weak id wid;
+void x(id y) {}
+void y(int a) {}
+
+extern id opaque_id();
+
+void f() {
+ __block int byref_int = 0;
+ char ch = 'a';
+ char ch1 = 'b';
+ char ch2 = 'c';
+ short sh = 2;
+ const id bar = (id) opaque_id();
+ id baz = 0;
+ __strong void *strong_void_sta;
+ __block id byref_bab = (id)0;
+ __block void *bl_var1;
+ int i; double dob;
+
+// The patterns here are a sequence of bytes, each saying first how
+// many sizeof(void*) chunks to skip (high nibble) and then how many
+// to scan (low nibble). A zero byte says that we've reached the end
+// of the pattern.
+//
+// All of these patterns start with 01 3x because the block header on
+// LP64 consists of an isa pointer (which we're supposed to scan for
+// some reason) followed by three words (2 ints, a function pointer,
+// and a descriptor pointer).
+
+// FIXME: do these really have to be named L_OBJC_CLASS_NAME_xxx?
+// FIXME: sequences should never end in x0 00 instead of just 00
+
+// Test 1
+// byref int, short, char, char, char, id, id, strong void*, byref id
+// 01 35 10 00
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [4 x i8] c"\015\10\00"
+ void (^b)() = ^{
+ byref_int = sh + ch+ch1+ch2 ;
+ x(bar);
+ x(baz);
+ x((id)strong_void_sta);
+ x(byref_bab);
+ };
+ b();
+
+// Test 2
+// byref int, short, char, char, char, id, id, strong void*, byref void*, byref id
+// 01 36 10 00
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [4 x i8] c"\016\10\00"
+ void (^c)() = ^{
+ byref_int = sh + ch+ch1+ch2 ;
+ x(bar);
+ x(baz);
+ x((id)strong_void_sta);
+ x(wid);
+ bl_var1 = 0;
+ x(byref_bab);
+ };
+ c();
+
+// Test 3
+// byref int, short, char, char, char, id, id, byref void*, int, double, byref id
+// 01 34 11 30 00
+// FIXME: we'd get a better format here if we sorted by scannability, not just alignment
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [5 x i8] c"\014\11 \00"
+ void (^d)() = ^{
+ byref_int = sh + ch+ch1+ch2 ;
+ x(bar);
+ x(baz);
+ x(wid);
+ bl_var1 = 0;
+ y(i + dob);
+ x(byref_bab);
+ };
+ d();
+
+// Test 4
+// struct S (int, id, int, id, int, id)
+// 01 41 11 11
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [5 x i8] c"\01A\11\11\00"
+ struct S s2;
+ void (^e)() = ^{
+ x(s2.o1);
+ };
+ e();
+}
+
+// Test 5 (unions/structs and their nesting):
+void Test5() {
+ struct S5 {
+ int i1;
+ id o1;
+ struct V {
+ int i2;
+ id o2;
+ } v1;
+ int i3;
+ union UI {
+ void * i1;
+ id o1;
+ int i3;
+ id o3;
+ }ui;
+ };
+
+ union U {
+ void * i1;
+ id o1;
+ int i3;
+ id o3;
+ }ui;
+
+ struct S5 s2;
+ union U u2;
+
+// struct s2 (int, id, int, id, int, id?), union u2 (id?)
+// 01 41 11 12 70 00
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [6 x i8] c"\01A\11\12p\00"
+ void (^c)() = ^{
+ x(s2.ui.o1);
+ x(u2.o1);
+ };
+ c();
+}
+
+// rdar: //8417746
+void CFRelease(id);
+void notifyBlock(id dependentBlock) {
+ id singleObservationToken;
+ id token;
+ void (^b)();
+
+// id, id, void(^)()
+// 01 33 00
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [3 x i8] c"\013\00"
+ void (^wrapperBlock)() = ^() {
+ CFRelease(singleObservationToken);
+ CFRelease(singleObservationToken);
+ CFRelease(token);
+ CFRelease(singleObservationToken);
+ b();
+ };
+ wrapperBlock();
+}
+
+void test_empty_block() {
+// 01 00
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [2 x i8] c"\01\00"
+ void (^wrapperBlock)() = ^() {
+ };
+ wrapperBlock();
+}
diff --git a/clang/test/CodeGenObjC/blocks-1.m b/clang/test/CodeGenObjC/blocks-1.m
new file mode 100644
index 0000000..64da359
--- /dev/null
+++ b/clang/test/CodeGenObjC/blocks-1.m
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-fragile-abi
+// RUN: grep "_Block_object_dispose" %t | count 6
+// RUN: grep "__copy_helper_block_" %t | count 4
+// RUN: grep "__destroy_helper_block_" %t | count 4
+// RUN: grep "__Block_byref_object_copy_" %t | count 2
+// RUN: grep "__Block_byref_object_dispose_" %t | count 2
+// RUN: grep "i32 135)" %t | count 0
+// RUN: grep "_Block_object_assign" %t | count 4
+// RUN: grep "objc_read_weak" %t | count 2
+// RUN: grep "objc_assign_weak" %t | count 3
+// RUN: %clang_cc1 -x objective-c++ %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-fragile-abi
+// RUN: grep "_Block_object_dispose" %t | count 6
+// RUN: grep "__copy_helper_block_" %t | count 4
+// RUN: grep "__destroy_helper_block_" %t | count 4
+// RUN: grep "__Block_byref_object_copy_" %t | count 2
+// RUN: grep "__Block_byref_object_dispose_" %t | count 2
+// RUN: grep "i32 135)" %t | count 0
+// RUN: grep "_Block_object_assign" %t | count 4
+// RUN: grep "objc_read_weak" %t | count 2
+// RUN: grep "objc_assign_weak" %t | count 3
+
+@interface NSDictionary @end
+
+void test1(NSDictionary * dict) {
+ ^{ (void)dict; }();
+}
+
+@interface D
+@end
+
+void foo() {
+ __block __weak D *weakSelf;
+ D *l;
+ l = weakSelf;
+ weakSelf = l;
+}
+
+void (^__weak b)(void);
+
+void test2() {
+ __block int i = 0;
+ b = ^ { ++i; };
+}
diff --git a/clang/test/CodeGenObjC/blocks-2.m b/clang/test/CodeGenObjC/blocks-2.m
new file mode 100644
index 0000000..591d63b
--- /dev/null
+++ b/clang/test/CodeGenObjC/blocks-2.m
@@ -0,0 +1,38 @@
+// We run this twice, once as Objective-C and once as Objective-C++.
+// RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 -fobjc-fragile-abi | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 -fobjc-fragile-abi -x objective-c++ | FileCheck %s
+
+
+// CHECK: define i8* @{{.*}}test0
+// CHECK: define internal void @__test0_block_invoke_0(
+// CHECK: call i8* @objc_assign_strongCast(
+// CHECK-NEXT: ret void
+id test0(id x) {
+ __block id result;
+ ^{ result = x; }();
+ return result;
+}
+
+// <rdar://problem/8224178>: cleanup __block variables on EH path
+// CHECK: define void @{{.*}}test1
+void test1() {
+ extern void test1_help(void (^x)(void));
+
+ // CHECK: [[N:%.*]] = alloca [[N_T:%.*]], align 8
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[N_T]]* [[N]], i32 0, i32 4
+ // CHECK-NEXT: store double 1.000000e+{{0?}}01, double* [[T0]], align 8
+ __block double n = 10;
+
+ // CHECK: invoke void @{{.*}}test1_help
+ test1_help(^{ n = 20; });
+
+ // CHECK: [[T1:%.*]] = bitcast [[N_T]]* [[N]] to i8*
+ // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T1]], i32 8)
+ // CHECK-NEXT: ret void
+
+ // CHECK: landingpad { i8*, i32 } personality
+ // CHECK-NEXT: cleanup
+ // CHECK: [[T1:%.*]] = bitcast [[N_T]]* [[N]] to i8*
+ // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T1]], i32 8)
+ // CHECK: resume { i8*, i32 }
+}
diff --git a/clang/test/CodeGenObjC/blocks-3.m b/clang/test/CodeGenObjC/blocks-3.m
new file mode 100644
index 0000000..55e215c
--- /dev/null
+++ b/clang/test/CodeGenObjC/blocks-3.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fblocks -o %t %s
+
+// 1x for the declaration
+// 1x for the object-pointer byref copy helper
+// 1x for the block-pointer byref copy helper
+// 8x for the block copy helper
+// RUN: grep 'object_assign' %t | count 11
+
+// RUN: grep 'object_dispose' %t | count 29
+
+int main() {
+ typedef id aid __attribute__((aligned(1)));
+ __block aid a1;
+ __block id a2 __attribute__((aligned(2)));
+ __block id a3 __attribute__((aligned(4)));
+ __block id a4 __attribute__((aligned(8)));
+ __block id a5, a6, a7;
+ __block void (^b)();
+ ^{ a1=a2=a3=a4=a5=a6=a7=0; b = 0; }();
+ return 0;
+}
diff --git a/clang/test/CodeGenObjC/blocks-4.m b/clang/test/CodeGenObjC/blocks-4.m
new file mode 100644
index 0000000..b3d0998
--- /dev/null
+++ b/clang/test/CodeGenObjC/blocks-4.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fobjc-exceptions -fblocks -o %t %s
+// rdar://7590273
+
+void EXIT(id e);
+
+@interface NSBlockOperation {
+}
++(id)blockOperationWithBlock:(void (^)(void))block ;
+@end
+
+void FUNC() {
+ [NSBlockOperation blockOperationWithBlock:^{
+ @try {
+
+ }
+ @catch (id exception) {
+ EXIT(exception);
+ }
+ }];
+
+}
diff --git a/clang/test/CodeGenObjC/blocks-5.m b/clang/test/CodeGenObjC/blocks-5.m
new file mode 100644
index 0000000..caa8d66
--- /dev/null
+++ b/clang/test/CodeGenObjC/blocks-5.m
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fblocks -o %t %s
+
+// rdar: // 8064140
+
+@interface IDEWorkspaceDocument
+{
+ id _defaultEditorStateTree;
+}
+- (void)enumerateKeysAndObjectsUsingBlock:(void (^)(id key, id obj, unsigned char *stop))block ;
+@end
+
+
+
+int foo();
+extern void DVT (volatile const void * object, volatile const void * selector, const char * functionName);
+@implementation IDEWorkspaceDocument
+
+- (void)stateSavingDefaultEditorStatesForURLs {
+ [_defaultEditorStateTree enumerateKeysAndObjectsUsingBlock:^(id identifier, id urlsToEditorStates, unsigned char *stop) {
+ do{
+if (foo() )
+ DVT(&self,&_cmd,__PRETTY_FUNCTION__);
+
+}while(0);
+
+ do{
+ DVT(&self,&_cmd,__PRETTY_FUNCTION__);
+ }while(0);
+
+
+ }];
+
+}
+
+- (void)enumerateKeysAndObjectsUsingBlock:(void (^)(id key, id obj, unsigned char *stop))block {}
+
+@end
diff --git a/clang/test/CodeGenObjC/blocks-ivar-debug.m b/clang/test/CodeGenObjC/blocks-ivar-debug.m
new file mode 100644
index 0000000..d0cf1f1
--- /dev/null
+++ b/clang/test/CodeGenObjC/blocks-ivar-debug.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -g %s -fblocks -S -o %t
+// Radar 7959934
+
+@interface NSObject {
+ struct objc_object *isa;
+}
+@end
+@interface Foo : NSObject {
+ int _prop;
+}
+@end
+
+@implementation Foo
+- (int)doSomething {
+ int (^blk)(void) = ^{ return _prop; };
+ return blk();
+}
+
+@end
+
diff --git a/clang/test/CodeGenObjC/blocks.m b/clang/test/CodeGenObjC/blocks.m
new file mode 100644
index 0000000..f478c07
--- /dev/null
+++ b/clang/test/CodeGenObjC/blocks.m
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fblocks -o - %s | FileCheck %s
+
+// test1. All of this is somehow testing rdar://6676764
+struct S {
+ void (^F)(struct S*);
+} P;
+
+
+@interface T
+ - (int)foo: (T (^)(T*)) x;
+@end
+
+void foo(T *P) {
+ [P foo: 0];
+}
+
+@interface A
+-(void) im0;
+@end
+
+// CHECK: define internal i32 @"__8-[A im0]_block_invoke_0"(
+@implementation A
+-(void) im0 {
+ (void) ^{ return 1; }();
+}
+@end
+
+@interface B : A @end
+@implementation B
+-(void) im1 {
+ ^(void) { [self im0]; }();
+}
+-(void) im2 {
+ ^{ [super im0]; }();
+}
+-(void) im3 {
+ ^{ ^{[super im0];}(); }();
+}
+@end
+
+// rdar://problem/9006315
+// In-depth test for the initialization of a __weak __block variable.
+@interface Test2 -(void) destroy; @end
+void test2(Test2 *x) {
+ extern void test2_helper(void (^)(void));
+ // CHECK: define void @test2(
+ // CHECK: [[X:%.*]] = alloca [[TEST2:%.*]]*,
+ // CHECK-NEXT: [[WEAKX:%.*]] = alloca [[WEAK_T:%.*]],
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+ // CHECK-NEXT: store [[TEST2]]*
+
+ // isa=1 for weak byrefs.
+ // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[WEAK_T]]* [[WEAKX]], i32 0, i32 0
+ // CHECK-NEXT: store i8* inttoptr (i32 1 to i8*), i8** [[T0]]
+
+ // Forwarding.
+ // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[WEAK_T]]* [[WEAKX]], i32 0, i32 1
+ // CHECK-NEXT: store [[WEAK_T]]* [[WEAKX]], [[WEAK_T]]** [[T1]]
+
+ // Flags. This is just BLOCK_HAS_COPY_DISPOSE.
+ // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[WEAK_T]]* [[WEAKX]], i32 0, i32 2
+ // CHECK-NEXT: store i32 33554432, i32* [[T2]]
+
+ // Size.
+ // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds [[WEAK_T]]* [[WEAKX]], i32 0, i32 3
+ // CHECK-NEXT: store i32 28, i32* [[T3]]
+
+ // Copy and dipose helpers.
+ // CHECK-NEXT: [[T4:%.*]] = getelementptr inbounds [[WEAK_T]]* [[WEAKX]], i32 0, i32 4
+ // CHECK-NEXT: store i8* bitcast (void (i8*, i8*)* @__Block_byref_object_copy_{{.*}} to i8*), i8** [[T4]]
+ // CHECK-NEXT: [[T5:%.*]] = getelementptr inbounds [[WEAK_T]]* [[WEAKX]], i32 0, i32 5
+ // CHECK-NEXT: store i8* bitcast (void (i8*)* @__Block_byref_object_dispose_{{.*}} to i8*), i8** [[T5]]
+
+ // Actually capture the value.
+ // CHECK-NEXT: [[T6:%.*]] = getelementptr inbounds [[WEAK_T]]* [[WEAKX]], i32 0, i32 6
+ // CHECK-NEXT: [[CAPTURE:%.*]] = load [[TEST2]]** [[X]]
+ // CHECK-NEXT: store [[TEST2]]* [[CAPTURE]], [[TEST2]]** [[T6]]
+
+ // Then we initialize the block, blah blah blah.
+ // CHECK: call void @test2_helper(
+
+ // Finally, kill the variable with BLOCK_FIELD_IS_BYREF. We're not
+ // supposed to pass BLOCK_FIELD_IS_WEAK here.
+ // CHECK: [[T0:%.*]] = bitcast [[WEAK_T]]* [[WEAKX]] to i8*
+ // CHECK: call void @_Block_object_dispose(i8* [[T0]], i32 8)
+
+ __weak __block Test2 *weakX = x;
+ test2_helper(^{ [weakX destroy]; });
+}
+
+// rdar://problem/9124263
+// In the test above, check that the use in the invocation function
+// doesn't require a read barrier.
+// CHECK: define internal void @__test2_block_invoke_
+// CHECK: [[BLOCK:%.*]] = bitcast i8* {{%.*}} to [[BLOCK_T]]*
+// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK-NEXT: [[T1:%.*]] = load i8** [[T0]]
+// CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to [[WEAK_T]]{{.*}}*
+// CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds [[WEAK_T]]{{.*}}* [[T2]], i32 0, i32 1
+// CHECK-NEXT: [[T4:%.*]] = load [[WEAK_T]]{{.*}}** [[T3]]
+// CHECK-NEXT: [[WEAKX:%.*]] = getelementptr inbounds [[WEAK_T]]{{.*}}* [[T4]], i32 0, i32 6
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST2]]** [[WEAKX]], align 4
diff --git a/clang/test/CodeGenObjC/builtins.m b/clang/test/CodeGenObjC/builtins.m
new file mode 100644
index 0000000..cb2995d
--- /dev/null
+++ b/clang/test/CodeGenObjC/builtins.m
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s
+
+void test0(id receiver, SEL sel, const char *str) {
+ short s = ((short (*)(id, SEL, const char*)) objc_msgSend)(receiver, sel, str);
+}
+// CHECK: define void @test0(
+// CHECK: call signext i16 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i16 (i8*, i8*, i8*)*)(
diff --git a/clang/test/CodeGenObjC/catch-lexical-block.m b/clang/test/CodeGenObjC/catch-lexical-block.m
new file mode 100644
index 0000000..f4a6a22
--- /dev/null
+++ b/clang/test/CodeGenObjC/catch-lexical-block.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -g -fobjc-exceptions -emit-llvm %s -o - | FileCheck %s
+@interface Foo @end
+void f0() {
+ @try {
+ @throw @"a";
+ } @catch(Foo *e) {
+ }
+}
+
+// We should have 4 lexical blocks here at the moment, including one
+// for the catch block.
+// CHECK: lexical_block
+// CHECK: lexical_block
+// CHECK: lexical_block
+// CHECK: auto_variable
+// CHECK: lexical_block
diff --git a/clang/test/CodeGenObjC/category-class.m b/clang/test/CodeGenObjC/category-class.m
new file mode 100644
index 0000000..5a82c14
--- /dev/null
+++ b/clang/test/CodeGenObjC/category-class.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s
+// PR7431
+
+// CHECK: module asm "\09.lazy_reference .objc_class_name_A"
+// CHECK: module asm "\09.objc_category_name_A_foo=0"
+// CHECK: module asm "\09.globl .objc_category_name_A_foo"
+
+@interface A
+@end
+@interface A(foo)
+- (void)foo_myStuff;
+@end
+@implementation A(foo)
+- (void)foo_myStuff {
+}
+@end
+
diff --git a/clang/test/CodeGenObjC/category-super-class-meth.m b/clang/test/CodeGenObjC/category-super-class-meth.m
new file mode 100644
index 0000000..6f02aff
--- /dev/null
+++ b/clang/test/CodeGenObjC/category-super-class-meth.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@interface BASE
++ (int) BaseMeth;
+@end
+
+@interface Child: BASE
+@end
+
+@interface Child (Categ)
++ (int) flushCache2;
+@end
+
+@implementation Child @end
+
+@implementation Child (Categ)
++ (int) flushCache2 { [super BaseMeth]; }
+@end
+
diff --git a/clang/test/CodeGenObjC/class-getter-dotsyntax.m b/clang/test/CodeGenObjC/class-getter-dotsyntax.m
new file mode 100644
index 0000000..bc142ce
--- /dev/null
+++ b/clang/test/CodeGenObjC/class-getter-dotsyntax.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@interface Test { }
++ (Test *)crash;
++ (void)setCrash: (int)value;
+@end
+
+@implementation Test
+static int _value;
+- (void)cachesPath
+{
+ static Test *cachesPath;
+
+ if (!cachesPath) {
+ Test *crash = Test.crash;
+ }
+}
++ (Test *)crash{ return 0; }
++ (void)setCrash: (int)value{ _value = value; }
+@end
+
diff --git a/clang/test/CodeGenObjC/class-type.m b/clang/test/CodeGenObjC/class-type.m
new file mode 100644
index 0000000..45aae25
--- /dev/null
+++ b/clang/test/CodeGenObjC/class-type.m
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-fragile-abi -emit-llvm -o - %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s
+
+
+@interface I0 {
+ struct { int a; } a;
+}
+@end
+
+@class I2;
+
+@interface I1 {
+ I2 *_imageBrowser;
+}
+@end
+
+@implementation I1
+@end
+
+@interface I2 : I0
+@end
+
+@implementation I2
+@end
+
+
+// Implementations without interface declarations.
+// rdar://6804402
+@class foo;
+@implementation foo
+@end
+
+@implementation bar
+@end
+
diff --git a/clang/test/CodeGenObjC/compatibility-alias.m b/clang/test/CodeGenObjC/compatibility-alias.m
new file mode 100644
index 0000000..fcc53b8
--- /dev/null
+++ b/clang/test/CodeGenObjC/compatibility-alias.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@interface Int1 @end
+
+typedef Int1 Int1Typedef;
+@compatibility_alias Int1Alias Int1Typedef;
+
+@implementation Int1Alias @end
diff --git a/clang/test/CodeGenObjC/complex-double-abi.m b/clang/test/CodeGenObjC/complex-double-abi.m
new file mode 100644
index 0000000..08246d5
--- /dev/null
+++ b/clang/test/CodeGenObjC/complex-double-abi.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-apple-macosx10.7.2 %s -o - | FileCheck %s
+// rdar://10331109
+
+@interface CNumber
+- (double _Complex)sum;
+@end
+
+double _Complex foo(CNumber *x) {
+ return [x sum];
+}
+
+// CHECK: [[T4:%.*]] = phi double [ 0.000000e+00, [[NULLINIT:%.*]] ], [ [[R1:%.*]], [[MSGCALL:%.*]] ]
+// CHECK: [[T5:%.*]] = phi double [ 0.000000e+00, [[NULLINIT:%.*]] ], [ [[I1:%.*]], [[MSGCALL:%.*]] ]
+
+// CHECK: store double [[T4]]
+// CHECK: store double [[T5]]
diff --git a/clang/test/CodeGenObjC/complex-property.m b/clang/test/CodeGenObjC/complex-property.m
new file mode 100644
index 0000000..8c3aef9
--- /dev/null
+++ b/clang/test/CodeGenObjC/complex-property.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s
+// rdar: // 7351147
+
+@interface A
+@property __complex int COMPLEX_PROP;
+- (__complex int)y;
+- (void) setY : (__complex int)rhs;
+@end
+
+void f0(A *a) {
+ _Complex int a1 = 25 + 10i;
+ a.COMPLEX_PROP += a1;
+ a.y += a1;
+}
+
+// CHECK-LP64: internal global [13 x i8] c"COMPLEX_PROP
+// CHECK-LP64: internal global [17 x i8] c"setCOMPLEX_PROP
+
+// rdar: // 7351147
+@interface B
+@property (assign) _Complex float f_complex_ivar;
+@end
+
+@implementation B
+
+@synthesize f_complex_ivar = _f_complex_ivar;
+-(void) unary_f_complex: (_Complex float) a0 {
+ self.f_complex_ivar = a0;
+}
+
+@end
+
diff --git a/clang/test/CodeGenObjC/constant-string-class-1.m b/clang/test/CodeGenObjC/constant-string-class-1.m
new file mode 100644
index 0000000..5f1e882
--- /dev/null
+++ b/clang/test/CodeGenObjC/constant-string-class-1.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fno-constant-cfstrings -fconstant-string-class OFConstantString -emit-llvm -o %t %s
+// pr9914
+
+@interface OFConstantString
++ class;
+@end
+
+@interface OFString
+- (void)XMLElementBySerializing;
+@end
+
+@implementation OFString
+
+- (void)XMLElementBySerializing
+{
+ id str = @"object";
+
+ [OFConstantString class];
+}
+
+@end
+
+// CHECK: @"OBJC_CLASS_$_OFConstantString" = external global
diff --git a/clang/test/CodeGenObjC/constant-string-class.m b/clang/test/CodeGenObjC/constant-string-class.m
new file mode 100644
index 0000000..ea049a5
--- /dev/null
+++ b/clang/test/CodeGenObjC/constant-string-class.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fno-constant-cfstrings -fconstant-string-class Foo -emit-llvm -o %t %s
+// RUN: FileCheck --check-prefix CHECK-FRAGILE < %t %s
+
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fno-constant-cfstrings -fconstant-string-class Foo -emit-llvm -o %t %s
+// RUN: FileCheck --check-prefix CHECK-NONFRAGILE < %t %s
+
+// rdar: // 8564463
+// PR6056
+
+@interface Object {
+ id isa;
+}
+@end
+
+@interface Foo : Object{
+ char *cString;
+ unsigned int len;
+}
+- (char *)customString;
+@end
+
+id _FooClassReference[20];
+
+@implementation Foo
+- (char *)customString { return cString ; }
+@end
+
+int main () {
+ Foo *string = @"bla";
+ return 0;
+}
+
+// CHECK-FRAGILE: @_FooClassReference = common global
+// CHECK-NONFRAGILE: @"OBJC_CLASS_$_Object" = external global
+// CHECK-NONFRAGILE: "OBJC_CLASS_$_Foo" = global
diff --git a/clang/test/CodeGenObjC/constant-strings.m b/clang/test/CodeGenObjC/constant-strings.m
new file mode 100644
index 0000000..c308d7a
--- /dev/null
+++ b/clang/test/CodeGenObjC/constant-strings.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: FileCheck --check-prefix=CHECK-NEXT < %t %s
+
+// Check that we set alignment 1 on the string.
+//
+// CHECK-NEXT: @.str = {{.*}}constant [13 x i8] c"Hello World!\00", align 1
+
+// RUN: %clang_cc1 -fgnu-runtime -emit-llvm -o %t %s
+// RUN: FileCheck --check-prefix=CHECK-GNU < %t %s
+// CHECK-GNU: NXConstantString
+
+// RUN: %clang_cc1 -fgnu-runtime -fconstant-string-class NSConstantString -emit-llvm -o %t %s
+// RUN: FileCheck --check-prefix=CHECK-GNU-WITH-CLASS < %t %s
+// CHECK-GNU-WITH-CLASS: NSConstantString
+id a = @"Hello World!";
+
diff --git a/clang/test/CodeGenObjC/continuation-class.m b/clang/test/CodeGenObjC/continuation-class.m
new file mode 100644
index 0000000..6f903a0
--- /dev/null
+++ b/clang/test/CodeGenObjC/continuation-class.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@interface Object
+- (id)new;
+@end
+
+@interface ReadOnly : Object
+{
+ int _object;
+ int _Anotherobject;
+}
+@property(readonly) int object;
+@property(readonly) int Anotherobject;
+@end
+
+@interface ReadOnly ()
+@property(readwrite) int object;
+@property(readwrite, setter = myAnotherobjectSetter:) int Anotherobject;
+@end
+
+@implementation ReadOnly
+@synthesize object = _object;
+@synthesize Anotherobject = _Anotherobject;
+- (void) myAnotherobjectSetter : (int)val {
+ _Anotherobject = val;
+}
+@end
+
+int main(int argc, char **argv) {
+ ReadOnly *test = [ReadOnly new];
+ test.object = 12345;
+ test.Anotherobject = 200;
+ return test.object - 12345 + test.Anotherobject - 200;
+}
+
diff --git a/clang/test/CodeGenObjC/deadcode_strip_used_var.m b/clang/test/CodeGenObjC/deadcode_strip_used_var.m
new file mode 100644
index 0000000..3137ceb
--- /dev/null
+++ b/clang/test/CodeGenObjC/deadcode_strip_used_var.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t -triple i386-apple-darwin10 -fobjc-fragile-abi
+// RUN: grep "llvm.used" %t | count 1
+// RUN: %clang_cc1 %s -emit-llvm -o %t -triple x86_64-apple-darwin10 -fobjc-fragile-abi
+// RUN: grep "llvm.used" %t | count 1
+
+
+__attribute__((used)) static int XXXXXX __attribute__ ((section ("__DATA,__Xinterpose"))) ;
+__attribute__((used)) static int YYYY __attribute__ ((section ("__DATA,__Xinterpose"))) ;
+
diff --git a/clang/test/CodeGenObjC/debug-info-block-helper.m b/clang/test/CodeGenObjC/debug-info-block-helper.m
new file mode 100644
index 0000000..83db0c9
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-block-helper.m
@@ -0,0 +1,30 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang_cc1 -emit-llvm -fblocks -g -triple x86_64-apple-darwin10 -fobjc-fragile-abi %s -o - | FileCheck %s
+extern void foo(void(^)(void));
+
+// CHECK: metadata !{i32 786478, i32 0, metadata !27, metadata !"__destroy_helper_block_", metadata !"__destroy_helper_block_", metadata !"", metadata !27, i32 24, metadata !43, i1 true, i1 true, i32 0, i32 0, null, i32 0, i1 false, void (i8*)* @__destroy_helper_block_, null, null, metadata !45, i32 24} ; [ DW_TAG_subprogram ]
+
+@interface NSObject {
+ struct objc_object *isa;
+}
+@end
+
+@interface A:NSObject @end
+@implementation A
+- (void) helper {
+ int master = 0;
+ __block int m2 = 0;
+ __block int dbTransaction = 0;
+ int (^x)(void) = ^(void) { (void) self;
+ (void) master;
+ (void) dbTransaction;
+ m2++;
+ return m2;
+
+ };
+ master = x();
+}
+@end
+
+void foo(void(^x)(void)) {}
+
diff --git a/clang/test/CodeGenObjC/debug-info-blocks.m b/clang/test/CodeGenObjC/debug-info-blocks.m
new file mode 100644
index 0000000..71ae8a6
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-blocks.m
@@ -0,0 +1,55 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang_cc1 -masm-verbose -S -fblocks -g -triple x86_64-apple-darwin10 -fobjc-dispatch-method=mixed %s -o - | FileCheck %s
+
+//Radar 9279956
+//CHECK: ## DW_OP_deref
+//CHECK-NEXT: ## DW_OP_plus_uconst
+
+typedef unsigned int NSUInteger;
+
+@protocol NSObject
+@end
+
+@interface NSObject <NSObject>
+- (id)init;
++ (id)alloc;
+@end
+
+@interface NSDictionary : NSObject
+- (NSUInteger)count;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+@end
+
+@interface A : NSObject {
+@public
+ int ivar;
+}
+@end
+
+static void run(void (^block)(void))
+{
+ block();
+}
+
+@implementation A
+
+- (id)init
+{
+ if ((self = [super init])) {
+ run(^{
+ NSMutableDictionary *d = [[NSMutableDictionary alloc] init];
+ ivar = 42 + (int)[d count];
+ });
+ }
+ return self;
+}
+
+@end
+
+int main()
+{
+ A *a = [[A alloc] init];
+ return 0;
+}
diff --git a/clang/test/CodeGenObjC/debug-info-class-extension.m b/clang/test/CodeGenObjC/debug-info-class-extension.m
new file mode 100644
index 0000000..e1573f0
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-class-extension.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -masm-verbose -S -g %s -o - | FileCheck %s
+
+// CHECK: AT_APPLE_objc_complete_type
+
+@interface I1
+@end
+
+@implementation I1 {
+int myi2;
+}
+int myi;
+@end
+
+void foo(I1 *iptr) {}
+
diff --git a/clang/test/CodeGenObjC/debug-info-class-extension2.m b/clang/test/CodeGenObjC/debug-info-class-extension2.m
new file mode 100644
index 0000000..bae12dc
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-class-extension2.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -masm-verbose -S -g %s -o - | FileCheck %s
+// CHECK: AT_APPLE_objc_complete_type
+
+@interface Foo {} @end
+
+@interface Foo () {
+ int *bar;
+}
+@end
+
+@implementation Foo
+@end
+
+void bar(Foo *fptr) {}
diff --git a/clang/test/CodeGenObjC/debug-info-class-extension3.m b/clang/test/CodeGenObjC/debug-info-class-extension3.m
new file mode 100644
index 0000000..f49bef8
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-class-extension3.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -masm-verbose -S -g %s -o - | FileCheck %s
+
+// CHECK-NOT: AT_APPLE_objc_complete_type
+
+@interface Foo {} @end
+
+@interface Foo () {
+ int *bar;
+}
+@end
+
+void bar(Foo *fptr) {}
diff --git a/clang/test/CodeGenObjC/debug-info-crash-2.m b/clang/test/CodeGenObjC/debug-info-crash-2.m
new file mode 100644
index 0000000..a2acd9d
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-crash-2.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -g -S %s -o -
+@class Bar;
+@interface Foo
+@property (strong, nonatomic) Bar *window;
+@end
+
+@interface Foo__ : Foo
+@end
+@implementation Foo__
+@end
+
+@implementation Foo
+@synthesize window = _window;
+@end
+
diff --git a/clang/test/CodeGenObjC/debug-info-crash.m b/clang/test/CodeGenObjC/debug-info-crash.m
new file mode 100644
index 0000000..5504356
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-crash.m
@@ -0,0 +1,41 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-fragile-abi -fblocks -g -S %s -o -
+
+// rdar://7556129
+@implementation test
+- (void)wait {
+ ^{};
+}
+@end
+
+// PR4894
+@interface I0 {
+ I0 *_iv0;
+}
+@end
+@protocol P0 @end
+
+@interface I1 @end
+@implementation I1
+- (I0<P0> *) im0 {
+ // CHECK: @"\01-[I1 im0]"
+ // CHECK: llvm.dbg.func.start
+ return 0;
+}
+@end
+
+// PR4541
+@class NSString;
+@interface NSAttributedString
+- (NSString *)string;
+@end
+@interface NSMutableAttributedString : NSAttributedString
+@end
+@class NSImage;
+@implementation CYObjectsController
++ (void)initialize {
+}
++ (NSAttributedString *)attributedStringWithString:(id)string image:(NSImage *)image {
+ NSMutableAttributedString *attrStr;
+}
+@end
diff --git a/clang/test/CodeGenObjC/debug-info-default-synth-ivar.m b/clang/test/CodeGenObjC/debug-info-default-synth-ivar.m
new file mode 100644
index 0000000..30d751e
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-default-synth-ivar.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-default-synthesize-properties -emit-llvm -g %s -o %t
+// RUN: grep DW_TAG_member %t | count 5
+// rdar://8493239
+
+@class NSString;
+
+@interface InstanceVariablesEverywhereButTheInterface
+@end
+
+@interface InstanceVariablesEverywhereButTheInterface()
+{
+ NSString *_someString;
+}
+
+@property(readonly) NSString *someString;
+@property(readonly) unsigned long someNumber;
+@end
+
+@implementation InstanceVariablesEverywhereButTheInterface
+{
+ unsigned long _someNumber;
+}
+@synthesize someString = _someString, someNumber = _someNumber;
+@end
+
+@interface AutomaticSynthesis
+{
+ int real_ivar;
+}
+@property(copy) NSString *someString;
+@property unsigned long someNumber;
+@end
+
+@implementation AutomaticSynthesis
+@end
diff --git a/clang/test/CodeGenObjC/debug-info-fwddecl.m b/clang/test/CodeGenObjC/debug-info-fwddecl.m
new file mode 100644
index 0000000..ebdc5f2
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-fwddecl.m
@@ -0,0 +1,5 @@
+// RUN: %clang -fverbose-asm -g -S -emit-llvm %s -o - | FileCheck %s
+@class ForwardObjcClass;
+ForwardObjcClass *ptr = 0;
+
+// CHECK: metadata !{i32 {{.*}}, null, metadata !"ForwardObjcClass", metadata !{{.*}}, i32 2, i32 0, i32 0, i32 0, i32 4, null, null, i32 16} ; [ DW_TAG_structure_type ]
diff --git a/clang/test/CodeGenObjC/debug-info-getter-name.m b/clang/test/CodeGenObjC/debug-info-getter-name.m
new file mode 100644
index 0000000..3939f35
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-getter-name.m
@@ -0,0 +1,54 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10 -fexceptions -fobjc-exceptions -g %s -o - | FileCheck %s
+
+// CHECK: {{.*}}, metadata !"-[InstanceVariablesEverywhereButTheInterface someString]", {{.*}}} ; [ DW_TAG_subprogram ]
+
+//rdar: //8498026
+
+@class NSString;
+
+@interface InstanceVariablesEverywhereButTheInterface
+@end
+
+@interface InstanceVariablesEverywhereButTheInterface()
+{
+ NSString *_someString;
+}
+
+@property(readonly) NSString *someString;
+@property(readonly) unsigned long someNumber;
+@end
+
+@implementation InstanceVariablesEverywhereButTheInterface
+{
+ unsigned long _someNumber;
+}
+
+@synthesize someString = _someString, someNumber = _someNumber;
+
+- init {
+ return self;
+}
+@end
+
+@interface AutomaticSynthesis
+{
+ int real_ivar;
+}
+@property(copy) NSString *someString;
+@property unsigned long someNumber;
+@end
+
+@implementation AutomaticSynthesis
+@synthesize someString;
+@synthesize someNumber;
+- init
+{
+ return self;
+}
+@end
+
+int main()
+{
+ return 0;
+}
diff --git a/clang/test/CodeGenObjC/debug-info-impl.m b/clang/test/CodeGenObjC/debug-info-impl.m
new file mode 100644
index 0000000..8ad5903
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-impl.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -g -S -emit-llvm %s -o - | FileCheck %s
+// CHECK: metadata !{i32 {{.*}}, metadata {{.*}}, metadata !"Circle", metadata {{.*}}, i32 11, i64 64, i64 64, i32 0, i32 512, null, metadata {{.*}}, i32 16, i32 0} ; [ DW_TAG_structure_type ]
+@interface NSObject {
+ struct objc_object *isa;
+}
+@end
+
+@interface Shape : NSObject
+
+@end
+@interface Circle : Shape
+
+@end
+@implementation Circle
+
+@end
diff --git a/clang/test/CodeGenObjC/debug-info-linkagename.m b/clang/test/CodeGenObjC/debug-info-linkagename.m
new file mode 100644
index 0000000..b606e5d
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-linkagename.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -g -S -o %t %s
+// RUN: not grep "001-[F bar" %t
+// Linkage name should not use 001 prefix in debug info.
+
+@interface F
+-(int) bar;
+@end
+
+@implementation F
+-(int) bar {
+ return 42;
+}
+@end
+
+extern int f(F *fn) {
+ return [fn bar];
+}
+
diff --git a/clang/test/CodeGenObjC/debug-info-property.m b/clang/test/CodeGenObjC/debug-info-property.m
new file mode 100644
index 0000000..dd105a5
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-property.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -masm-verbose -S -g %s -o - | FileCheck %s
+
+// CHECK: AT_APPLE_property_name
+// CHECK: AT_APPLE_property_attribute
+// CHECK: AT_APPLE_property
+@interface I1 {
+int p1;
+}
+@property int p1;
+@end
+
+@implementation I1
+@synthesize p1;
+@end
diff --git a/clang/test/CodeGenObjC/debug-info-property2.m b/clang/test/CodeGenObjC/debug-info-property2.m
new file mode 100644
index 0000000..4cd76c1
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-property2.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -masm-verbose -S -g %s -o - | FileCheck %s
+
+// CHECK: AT_APPLE_property_name
+@interface C {
+ int _base;
+}
+@property int base;
+@end
+
+@implementation C
+@synthesize base = _base;
+@end
+
+void foo(C *cptr) {}
diff --git a/clang/test/CodeGenObjC/debug-info-property3.m b/clang/test/CodeGenObjC/debug-info-property3.m
new file mode 100644
index 0000000..f96ec44
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-property3.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -S -emit-llvm -g %s -o - | FileCheck %s
+
+// CHECK: metadata !"p1", metadata !6, i32 5, metadata !"", metadata !"", i32 2316, metadata !9} ; [ DW_TAG_APPLE_property ]
+@interface I1
+@property int p1;
+@end
+
+@implementation I1
+@synthesize p1;
+@end
+
+void foo(I1 *iptr) {}
diff --git a/clang/test/CodeGenObjC/debug-info-property4.m b/clang/test/CodeGenObjC/debug-info-property4.m
new file mode 100644
index 0000000..6d9973c
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-property4.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fobjc-default-synthesize-properties -masm-verbose -S -g %s -o - | FileCheck %s
+
+// CHECK: AT_APPLE_property_name
+// CHECK-NOT: AT_APPLE_property_getter
+// CHECK-NOT: AT_APPLE_property_setter
+// CHECK: AT_APPLE_property_attribute
+// CHECK: AT_APPLE_property
+
+
+@interface I1
+@property int p1;
+@end
+
+@implementation I1
+@end
+
+void foo(I1 *ptr) {}
diff --git a/clang/test/CodeGenObjC/debug-info-property5.m b/clang/test/CodeGenObjC/debug-info-property5.m
new file mode 100644
index 0000000..3521574
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-property5.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fobjc-default-synthesize-properties -masm-verbose -S -g %s -o - | FileCheck %s
+
+// CHECK: AT_APPLE_property_name
+// CHECK: AT_APPLE_property_getter
+// CHECK: AT_APPLE_property_setter
+// CHECK: AT_APPLE_property_attribute
+// CHECK: AT_APPLE_property
+
+@interface BaseClass2
+{
+ int _baseInt;
+}
+- (int) myGetBaseInt;
+- (void) mySetBaseInt: (int) in_int;
+@property(getter=myGetBaseInt,setter=mySetBaseInt:) int baseInt;
+@end
+
+@implementation BaseClass2
+
+- (int) myGetBaseInt
+{
+ return _baseInt;
+}
+
+- (void) mySetBaseInt: (int) in_int
+{
+ _baseInt = 2 * in_int;
+}
+@end
+
+
+void foo(BaseClass2 *ptr) {}
diff --git a/clang/test/CodeGenObjC/debug-info-pubtypes.m b/clang/test/CodeGenObjC/debug-info-pubtypes.m
new file mode 100644
index 0000000..658430d
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-pubtypes.m
@@ -0,0 +1,14 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang -cc1 -triple x86_64-apple-darwin10 -g -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: !5 = metadata !{i32 {{.*}}, metadata !6, metadata !"H", metadata !6, i32 6, i64 0, i64 8, i32 0, i32 512, null, metadata !2, i32 16, i32 0} ; [ DW_TAG_structure_type ]
+
+@interface H
+-(void) foo;
+@end
+
+@implementation H
+-(void) foo {
+}
+@end
+
diff --git a/clang/test/CodeGenObjC/debug-info-selector.m b/clang/test/CodeGenObjC/debug-info-selector.m
new file mode 100644
index 0000000..67642ac
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-selector.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck %s
+// Radar 8494540
+
+// CHECK: objc_selector
+@interface MyClass {
+}
+- (id)init;
+@end
+
+@implementation MyClass
+- (id) init
+{
+ return self;
+}
+@end
diff --git a/clang/test/CodeGenObjC/debug-info-self.m b/clang/test/CodeGenObjC/debug-info-self.m
new file mode 100644
index 0000000..9146ab3
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-self.m
@@ -0,0 +1,16 @@
+// RUN: %clang -fverbose-asm -g -S %s -o - | grep DW_AT_artificial | count 3
+// self and _cmd are marked as DW_AT_artificial.
+// abbrev code emits another DT_artificial comment.
+// myarg is not marked as DW_AT_artificial.
+
+@interface MyClass {
+}
+- (id)init:(int) myarg;
+@end
+
+@implementation MyClass
+- (id) init:(int) myarg
+{
+ return self;
+}
+@end
diff --git a/clang/test/CodeGenObjC/debug-info-static-var.m b/clang/test/CodeGenObjC/debug-info-static-var.m
new file mode 100644
index 0000000..c65e77c
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-static-var.m
@@ -0,0 +1,23 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang_cc1 -g -triple x86_64-apple-darwin10 -fobjc-fragile-abi -S -masm-verbose -o - %s | FileCheck %s
+// Radar 8801045
+// Do not emit AT_MIPS_linkage_name for static variable i
+
+// CHECK: Lset6 = Lstring3-Lsection_str ## DW_AT_name
+// CHECK-NEXT: .long Lset6
+// CHECK-NEXT: DW_AT_type
+// CHECK-NEXT: DW_AT_decl_file
+// CHECK-NEXT: DW_AT_decl_line
+// CHECK-NEXT: DW_AT_location
+
+@interface A {
+}
+-(void) foo;
+@end
+
+@implementation A
+-(void)foo {
+ static int i = 1;
+}
+@end
+
diff --git a/clang/test/CodeGenObjC/debug-info-synthesis.m b/clang/test/CodeGenObjC/debug-info-synthesis.m
new file mode 100644
index 0000000..7e263cf
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-synthesis.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -emit-llvm -g -w -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
+# 1 "foo.m" 1
+# 1 "foo.m" 2
+# 1 "./foo.h" 1
+@interface NSObject {
+ struct objc_object *isa;
+}
+@end
+@class NSDictionary;
+
+@interface Foo : NSObject {}
+@property (strong, nonatomic) NSDictionary *dict;
+@end
+# 2 "foo.m" 2
+
+
+
+
+@implementation Foo
+@synthesize dict = _dict;
+
+- (void) bork {
+}
+@end
+
+int main(int argc, char *argv[]) {
+ @autoreleasepool {
+ Foo *f = [Foo new];
+ [f bork];
+ }
+}
+
+// CHECK: !7 = metadata !{i32 {{.*}}, metadata !"./foo.h"
+// CHECK: !31 = metadata !{i32 {{.*}}, i32 0, metadata !7, metadata !"-[Foo dict]", metadata !"-[Foo dict]", metadata !"", metadata !7, i32 8, metadata !32, i1 true, i1 true, i32 0, i32 0, null, i32 320, i1 false, %1* (%0*, i8*)* @"\01-[Foo dict]", null, null, metadata !34, i32 8} ; [ DW_TAG_subprogram ]
diff --git a/clang/test/CodeGenObjC/debug-property-synth.m b/clang/test/CodeGenObjC/debug-property-synth.m
new file mode 100644
index 0000000..954620a
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-property-synth.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -masm-verbose -S -g %s -o - | FileCheck %s
+// Radar 9468526
+@interface I {
+ int _p1;
+}
+@property int p1;
+@end
+
+@implementation I
+@synthesize p1 = _p1;
+@end
+
+int main() {
+ I *myi;
+ myi.p1 = 2;
+ return 0;
+}
+
+// FIXME: Make this test ir files.
+// CHECK: .loc 2 6 0
diff --git a/clang/test/CodeGenObjC/default-property-synthesis.m b/clang/test/CodeGenObjC/default-property-synthesis.m
new file mode 100644
index 0000000..7d7296b
--- /dev/null
+++ b/clang/test/CodeGenObjC/default-property-synthesis.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s
+// rdar://7923851.
+
+// Superclass declares property. Subclass redeclares the same property.
+// Do not @synthesize-by-default in the subclass. P1
+// Superclass declares a property. Subclass declares a different property with the same name
+// (such as different type or attributes). Do not @synthesize-by-default in the subclass. P2
+// Superclass conforms to a protocol that declares a property. Subclass redeclares the
+// same property. Do not @synthesize-by-default in the subclass. P3
+// Superclass conforms to a protocol that declares a property. Subclass conforms to the
+// same protocol or a derived protocol. Do not @synthesize-by-default in the subclass. P4
+
+
+@protocol PROTO
+ @property int P3;
+ @property int P4;
+@end
+
+@protocol PROTO1 <PROTO>
+ @property int IMP1;
+@end
+
+@interface Super <PROTO>
+ @property int P1;
+ @property (copy) id P2;
+@end
+
+@interface Sub : Super <PROTO1>
+ @property int P1;
+ @property (nonatomic, retain) id P2; // expected-warning {{property 'P2' 'copy' attribute does not match the property inherited from 'Super'}} \
+ // expected-warning {{property 'P2' 'atomic' attribute does not match the property inherited from 'Super'}}
+ @property int P3;
+ @property int IMP2;
+@end
+
+@implementation Sub
+@end
+
diff --git a/clang/test/CodeGenObjC/dot-syntax-1.m b/clang/test/CodeGenObjC/dot-syntax-1.m
new file mode 100644
index 0000000..417bcb4
--- /dev/null
+++ b/clang/test/CodeGenObjC/dot-syntax-1.m
@@ -0,0 +1,264 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+int printf(const char *, ...);
+
+@interface Root
+-(id) alloc;
+-(id) init;
+@end
+
+// Property above methods...
+
+@interface Top0 : Root
+@property(getter=_getX,setter=_setX:) int x;
+@end
+
+@interface Bot0 : Top0
+-(int) x;
+-(void) setX: (int) arg;
+@end
+
+@implementation Top0
+-(int) _getX {
+ printf("-[ Top0 _getX ]\n");
+ return 0;
+}
+-(void) _setX: (int) arg {
+ printf("-[ Top0 _setX: %d ]\n", arg);
+}
+@end
+
+@implementation Bot0
+-(int) x {
+ printf("-[ Bot0 _getX ]\n");
+ return 0;
+}
+-(void) setX: (int) arg {
+ printf("-[ Bot0 _setX: %d ]\n", arg);
+}
+@end
+
+// Methods above property...
+
+@interface Top1 : Root
+-(int) x;
+-(void) setX: (int) arg;
+@end
+
+@interface Bot1 : Top1
+@property(getter=_getX,setter=_setX:) int x;
+@end
+
+@implementation Top1
+-(int) x {
+ printf("-[ Top1 x ]\n");
+ return 0;
+}
+-(void) setX: (int) arg {
+ printf("-[ Top1 setX: %d ]\n", arg);
+}
+@end
+
+@implementation Bot1
+-(int) _getX {
+ printf("-[ Bot1 _getX ]\n");
+ return 0;
+}
+-(void) _setX: (int) arg {
+ printf("-[ Bot1 _setX: %d ]\n", arg);
+}
+@end
+
+// Mixed setter & getter (variant 1)
+
+@interface Top2 : Root
+-(int) x;
+-(void) _setX: (int) arg;
+@end
+
+@interface Bot2 : Top2
+@property(getter=_getX,setter=_setX:) int x;
+@end
+
+@implementation Top2
+-(int) x {
+ printf("-[ Top2 x ]\n");
+ return 0;
+}
+-(void) _setX: (int) arg {
+ printf("-[ Top2 _setX: %d ]\n", arg);
+}
+@end
+
+@implementation Bot2
+-(int) _getX {
+ printf("-[ Bot2 _getX ]\n");
+ return 0;
+}
+-(void) setX: (int) arg {
+ printf("-[ Bot2 setX: %d ]\n", arg);
+}
+@end
+
+// Mixed setter & getter (variant 2)
+
+@interface Top3 : Root
+-(int) _getX;
+-(void) setX: (int) arg;
+@end
+
+@interface Bot3 : Top3
+@property(getter=_getX,setter=_setX:) int x;
+@end
+
+@implementation Top3
+-(int) _getX {
+ printf("-[ Top3 _getX ]\n");
+ return 0;
+}
+-(void) setX: (int) arg {
+ printf("-[ Top3 setX: %d ]\n", arg);
+}
+@end
+
+@implementation Bot3
+-(int) x {
+ printf("-[ Bot3 x ]\n");
+ return 0;
+}
+-(void) _setX: (int) arg {
+ printf("-[ Bot3 _setX: %d ]\n", arg);
+}
+@end
+
+// Mixed setter & getter (variant 3)
+
+@interface Top4 : Root
+@property(getter=_getX,setter=_setX:) int x;
+@end
+
+@interface Bot4 : Top4
+-(int) _getX;
+-(void) setX: (int) arg;
+@end
+
+@implementation Top4
+-(int) x {
+ printf("-[ Top4 x ]\n");
+ return 0;
+}
+-(void) _setX: (int) arg {
+ printf("-[ Top4 _setX: %d ]\n", arg);
+}
+@end
+
+@implementation Bot4
+-(int) _getX {
+ printf("-[ Bot4 _getX ]\n");
+ return 0;
+}
+-(void) setX: (int) arg {
+ printf("-[ Bot4 setX: %d ]\n", arg);
+}
+@end
+
+// Mixed setter & getter (variant 4)
+
+@interface Top5 : Root
+@property(getter=_getX,setter=_setX:) int x;
+@end
+
+@interface Bot5 : Top5
+-(int) x;
+-(void) _setX: (int) arg;
+@end
+
+@implementation Top5
+-(int) _getX {
+ printf("-[ Top5 _getX ]\n");
+ return 0;
+}
+-(void) setX: (int) arg {
+ printf("-[ Top5 setX: %d ]\n", arg);
+}
+@end
+
+@implementation Bot5
+-(int) x {
+ printf("-[ Bot5 x ]\n");
+ return 0;
+}
+-(void) _setX: (int) arg {
+ printf("-[ Bot5 _setX: %d ]\n", arg);
+}
+@end
+
+// Mixed level calls (variant 1)
+
+@interface Top6 : Root
+-(int) x;
+@end
+
+@interface Bot6 : Top6
+-(void) setX: (int) arg;
+@end
+
+@implementation Top6
+-(int) x {
+ printf("-[ Top6 x ]\n");
+ return 0;
+}
+@end
+
+@implementation Bot6
+-(void) setX: (int) arg {
+ printf("-[ Bot5 setX: %d ]\n", arg);
+}
+@end
+
+// Mixed level calls (variant 1)
+
+@interface Top7 : Root
+-(void) setX: (int) arg;
+@end
+
+@interface Bot7 : Top7
+-(int) x;
+@end
+
+@implementation Top7
+-(void) setX: (int) arg {
+ printf("-[ Top7 setX: %d ]\n", arg);
+}
+@end
+
+@implementation Bot7
+-(int) x {
+ printf("-[ Bot7 x ]\n");
+ return 0;
+}
+@end
+
+//
+
+// FIXME: Two more (thats it?) interesting cases. Method access on
+// getter w/o setter and method access on setter w/o getter.
+
+int main() {
+#define test(N) { \
+ Bot##N *ob = [[Bot##N alloc] init]; \
+ int x = ob.x; \
+ ob.x = 10; }
+
+ test(0);
+ test(1);
+ test(2);
+ test(3);
+ test(4);
+ test(5);
+ // test(6);
+ // test(7);
+
+ return 0;
+}
+
diff --git a/clang/test/CodeGenObjC/dot-syntax-2.m b/clang/test/CodeGenObjC/dot-syntax-2.m
new file mode 100644
index 0000000..020868a
--- /dev/null
+++ b/clang/test/CodeGenObjC/dot-syntax-2.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// rdar: // 8062778
+
+@interface NSDictionary @end
+
+@interface NSMutableDictionary : NSDictionary
+@end
+
+@interface MutableMyClass
+- (NSMutableDictionary *)myDict;
+- (void)setMyDict:(NSDictionary *)myDict;
+
+- (NSMutableDictionary *)myLang;
+- (void)setMyLang:(NSDictionary *)myLang;
+@end
+
+@interface AnotherClass @end
+
+@implementation AnotherClass
+- (void)foo
+{
+ MutableMyClass * myObject;
+ NSDictionary * newDict;
+ myObject.myDict = newDict;
+ myObject.myLang = newDict;
+}
+@end
diff --git a/clang/test/CodeGenObjC/dot-syntax.m b/clang/test/CodeGenObjC/dot-syntax.m
new file mode 100644
index 0000000..6282ea4
--- /dev/null
+++ b/clang/test/CodeGenObjC/dot-syntax.m
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+int printf(const char *, ...);
+
+@interface Root
+-(id) alloc;
+-(id) init;
+@end
+
+typedef struct {
+ float x, y, z[2];
+} S;
+
+@interface A : Root {
+ int myX;
+ // __complex myY;
+ S myZ;
+}
+
+@property int x;
+//@property __complex int y;
+@property S z;
+@end
+
+@implementation A
+-(int) x {
+ printf("-[A x] = %d\n", myX);
+ return myX;
+}
+-(void) setX: (int) arg {
+ myX = arg;
+ printf("-[A setX: %d]\n", myX);
+}
+
+// FIXME: Add back
+#if 0
+-(__complex int) y {
+ printf("-[A y] = (%d, %d)\n", __real myY, __imag myY);
+ return myY;
+}
+-(void) setY: (__complex int) arg {
+ myY = arg;
+ printf("-[A setY: (%d, %d)]\n", __real myY, __imag myY);
+}
+#endif
+
+-(S) z {
+ printf("-[A z] = { %f, %f, { %f, %f } }\n",
+ myZ.x, myZ.y, myZ.z[0], myZ.z[1]);
+ return myZ;
+}
+-(void) setZ: (S) arg {
+ myZ = arg;
+ printf("-[A setZ: { %f, %f, { %f, %f } } ]\n",
+ myZ.x, myZ.y, myZ.z[0], myZ.z[1]);
+}
+
+@end
+
+int main() {
+#define SWAP(T,a,b) { T a_tmp = a; a = b; b = a_tmp; }
+ A *a = [[A alloc] init];
+ A *b = [[A alloc] init];
+ int a0 = 23;
+ // __complex a1 = 25 + 10i;
+ S a2 = { 246, 458, {275, 12} };
+ int b0 = 42673;
+ // __complex b1 = 15 + 13i;
+ S b2 = { 26, 2, {367, 13} };
+
+ a.x = a0;
+ // a.y = a1;
+ a.z = a2;
+
+ a.x += a0;
+ // a.y += a1;
+ // Yay, no compound assign of structures. A GCC extension in the
+ // works, perhaps?
+
+ b.x = b0;
+ // b.y = b1;
+ b.z = b2;
+
+ int x0 = (b.x = b0);
+ printf("(b.x = b0): %d\n", x0);
+
+ // int x1 = __real (b.y = b1);
+ // printf("__real (b.y = b1) = %d\n", x1);
+
+ float x2 = (b.z = b2).x;
+ printf("(b.z = b2).x: %f\n", x2);
+
+ SWAP(int, a.x, b.x);
+ // SWAP(__complex int, a.y, b.y);
+ SWAP(S, a.z, b.z);
+
+ return 0;
+}
diff --git a/clang/test/CodeGenObjC/encode-cstyle-method.m b/clang/test/CodeGenObjC/encode-cstyle-method.m
new file mode 100644
index 0000000..ea63023
--- /dev/null
+++ b/clang/test/CodeGenObjC/encode-cstyle-method.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s
+// rdar: // 7445205
+
+@interface Foo
+- (id)test:(id)one, id two;
+@end
+
+@implementation Foo
+- (id)test:(id )one, id two {return two; } @end
+
+// CHECK-LP64: internal global [11 x i8] c"@24@0:8@16
diff --git a/clang/test/CodeGenObjC/encode-test-2.m b/clang/test/CodeGenObjC/encode-test-2.m
new file mode 100644
index 0000000..9e14237
--- /dev/null
+++ b/clang/test/CodeGenObjC/encode-test-2.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm -o %t %s
+// RUN: grep -e "@\\\22<X>\\\22" %t
+// RUN: grep -e "@\\\22<X><Y>\\\22" %t
+// RUN: grep -e "@\\\22<X><Y><Z>\\\22" %t
+// RUN: grep -e "@\\\22Foo<X><Y><Z>\\\22" %t
+// RUN: grep -e "{Intf=@@@@#}" %t
+
+@protocol X, Y, Z;
+@class Foo;
+
+@protocol Proto
+@end
+
+@interface Intf <Proto>
+{
+id <X> IVAR_x;
+id <X, Y> IVAR_xy;
+id <X, Y, Z> IVAR_xyz;
+Foo <X, Y, Z> *IVAR_Fooxyz;
+Class <X> IVAR_Classx;
+}
+@end
+
+@implementation Intf
+@end
+
+int main()
+{
+ const char * en = @encode(Intf);
+}
diff --git a/clang/test/CodeGenObjC/encode-test-3.m b/clang/test/CodeGenObjC/encode-test-3.m
new file mode 100644
index 0000000..4b39cd7
--- /dev/null
+++ b/clang/test/CodeGenObjC/encode-test-3.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm -o %t %s
+// RUN: grep -e "\^i" %t | count 1
+// RUN: grep -e "\[0i\]" %t | count 1
+
+int main() {
+ int n;
+
+ const char * inc = @encode(int[]);
+ const char * vla = @encode(int[n]);
+}
+
+// PR3648
+int a[sizeof(@encode(int)) == 2 ? 1 : -1]; // Type is char[2]
+const char *B = @encode(int);
+char (*c)[2] = &@encode(int); // @encode is an lvalue
+
+char d[] = @encode(int); // infer size.
+char e[1] = @encode(int); // truncate
+char f[2] = @encode(int); // fits
+char g[3] = @encode(int); // zero fill
+
diff --git a/clang/test/CodeGenObjC/encode-test-4.m b/clang/test/CodeGenObjC/encode-test-4.m
new file mode 100644
index 0000000..2624bc7
--- /dev/null
+++ b/clang/test/CodeGenObjC/encode-test-4.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s -O2 | grep "ret i32 1"
+typedef long Integer;
+typedef enum : Integer { Red, Green, Blue} Color;
+typedef enum { Cyan, Magenta, Yellow, Key } PrintColor;
+
+int a() {
+ return @encode(int) == @encode(int) &&
+ @encode(Color) == @encode(long) &&
+ @encode(PrintColor) == @encode(int);
+}
diff --git a/clang/test/CodeGenObjC/encode-test-5.m b/clang/test/CodeGenObjC/encode-test-5.m
new file mode 100644
index 0000000..a27ffb7
--- /dev/null
+++ b/clang/test/CodeGenObjC/encode-test-5.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin9 -emit-llvm -o %t %s
+
+// RUN: grep ji.00 %t | count 1
+char *a = @encode(_Complex int);
+
+// RUN: grep jf.00 %t | count 1
+char *b = @encode(_Complex float);
+
+// RUN: grep jd.00 %t | count 1
+char *c = @encode(_Complex double);
+
+// RUN: grep "t.00" %t | count 1
+char *e = @encode(__int128_t);
+
+// RUN: grep "T.00" %t | count 1
+char *f = @encode(__uint128_t);
diff --git a/clang/test/CodeGenObjC/encode-test.m b/clang/test/CodeGenObjC/encode-test.m
new file mode 100644
index 0000000..02af5da
--- /dev/null
+++ b/clang/test/CodeGenObjC/encode-test.m
@@ -0,0 +1,167 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s
+// RUN: FileCheck < %t %s
+//
+// CHECK: @"\01L_OBJC_METH_VAR_TYPE_34" = internal global [16 x i8] c"v12@0:4[3[4@]]8\00"
+
+@class Int1;
+
+struct Innermost {
+ unsigned char a, b;
+};
+
+@interface Int1 {
+ signed char a, b;
+ struct Innermost *innermost;
+}
+@end
+
+@implementation Int1
+@end
+
+@interface Base
+{
+ struct objc_class *isa;
+ int full;
+ int full2: 32;
+ int _refs: 8;
+ int field2: 3;
+ unsigned f3: 8;
+ short cc;
+ unsigned g: 16;
+ int r2: 8;
+ int r3: 8;
+ int r4: 2;
+ int r5: 8;
+ char c;
+}
+@end
+
+@interface Derived: Base
+{
+ char d;
+ int _field3: 6;
+}
+@end
+
+@implementation Base
+@end
+
+@implementation Derived
+@end
+
+@interface B1
+{
+ struct objc_class *isa;
+ Int1 *sBase;
+ char c;
+}
+@end
+
+@implementation B1
+@end
+
+@interface Test
+{
+ int ivar;
+ __attribute__((objc_gc(weak))) SEL selector;
+}
+-(void) test3: (Test* [3] [4])b ;
+- (SEL**) meth : (SEL) arg : (SEL*****) arg1 : (SEL*)arg2 : (SEL**) arg3;
+@end
+
+@implementation Test
+-(void) test3: (Test* [3] [4])b {}
+- (SEL**) meth : (SEL) arg : (SEL*****) arg1 : (SEL*)arg2 : (SEL**) arg3 {}
+@end
+
+struct S { int iS; };
+
+@interface Object
+{
+ Class isa;
+}
+@end
+typedef Object MyObj;
+
+int main()
+{
+ const char *en = @encode(Derived);
+ const char *eb = @encode(B1);
+ const char *es = @encode(const struct S *);
+ const char *ec = @encode(const struct S);
+ const char *ee = @encode(MyObj *const);
+}
+
+// CHECK: @g0 = constant [15 x i8] c"{Innermost=CC}\00"
+const char g0[] = @encode(struct Innermost);
+
+// CHECK: @g1 = constant [38 x i8] c"{Derived=#ib32b8b3b8sb16b8b8b2b8ccb6}\00"
+const char g1[] = @encode(Derived);
+
+// CHECK: @g2 = constant [9 x i8] c"{B1=#@c}\00"
+const char g2[] = @encode(B1);
+
+// CHECK: @g3 = constant [8 x i8] c"r^{S=i}\00"
+const char g3[] = @encode(const struct S *);
+
+// CHECK: @g4 = constant [6 x i8] c"{S=i}\00"
+const char g4[] = @encode(const struct S);
+
+// CHECK: @g5 = constant [12 x i8] c"^{Object=#}\00"
+const char g5[] = @encode(MyObj * const);
+
+////
+
+enum Enum1X { one, two, three, four };
+
+@interface Base1X {
+ unsigned a: 2;
+ int b: 3;
+ enum Enum1X c: 4;
+ unsigned d: 5;
+}
+@end
+
+@interface Derived1X: Base1X {
+ signed e: 5;
+ int f: 4;
+ enum Enum1X g: 3;
+}
+@end
+
+@implementation Base1X @end
+
+@implementation Derived1X @end
+
+// CHECK: @g6 = constant [18 x i8] c"{Base1X=b2b3b4b5}\00"
+const char g6[] = @encode(Base1X);
+
+// CHECK: @g7 = constant [27 x i8] c"{Derived1X=b2b3b4b5b5b4b3}\00"
+const char g7[] = @encode(Derived1X);
+
+// CHECK: @g8 = constant [7 x i8] c"{s8=D}\00"
+struct s8 {
+ long double x;
+};
+const char g8[] = @encode(struct s8);
+
+// CHECK: @g9 = constant [11 x i8] c"{S9=i[0i]}\00"
+struct S9 {
+ int x;
+ int flex[];
+};
+const char g9[] = @encode(struct S9);
+
+struct f
+{
+ int i;
+ struct{} g[4];
+ int tt;
+};
+
+// CHECK: @g10 = constant [14 x i8] c"{f=i[0{?=}]i}\00"
+const char g10[] = @encode(struct f);
+
+// rdar://9622422
+// CHECK: @g11 = constant [2 x i8] c"v\00"
+const char g11[] = @encode(void);
diff --git a/clang/test/CodeGenObjC/exceptions-nonfragile.m b/clang/test/CodeGenObjC/exceptions-nonfragile.m
new file mode 100644
index 0000000..1f38926
--- /dev/null
+++ b/clang/test/CodeGenObjC/exceptions-nonfragile.m
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck %s
+
+// rdar://problem/8535238
+// CHECK: declare void @objc_exception_rethrow()
+
+void protos() {
+ extern void foo();
+ @try {
+ foo();
+ } @catch (id e) {
+ @throw;
+ }
+}
+
+void throwing() {
+ @throw(@"error!");
+}
+
+// rdar://problem/9431547
+void die(void) __attribute__((nothrow, noreturn));
+void test2(void) {
+ @try {
+ die();
+ } @finally {
+ extern void test2_helper(void);
+ test2_helper();
+ }
+
+ // CHECK: define void @test2()
+ // CHECK-NOT: call void @test2_helper()
+}
diff --git a/clang/test/CodeGenObjC/exceptions.m b/clang/test/CodeGenObjC/exceptions.m
new file mode 100644
index 0000000..24fb657
--- /dev/null
+++ b/clang/test/CodeGenObjC/exceptions.m
@@ -0,0 +1,183 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -fexceptions -fobjc-exceptions -O2 -o - %s | FileCheck %s
+//
+// <rdar://problem/7471679> [irgen] [eh] Exception code built with clang (x86_64) crashes
+
+// Just check that we don't emit any dead blocks.
+@interface NSArray @end
+void f0() {
+ @try {
+ @try {
+ @throw @"a";
+ } @catch(NSArray *e) {
+ }
+ } @catch (id e) {
+ }
+}
+
+// CHECK: define void @f1()
+void f1() {
+ extern void foo(void);
+
+ while (1) {
+ // CHECK: call void @objc_exception_try_enter
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: call i32 @_setjmp(
+ // CHECK-NEXT: icmp
+ // CHECK-NEXT: br i1
+ @try {
+ // CHECK: call void asm sideeffect "", "*m"
+ // CHECK-NEXT: call void @foo()
+ foo();
+ // CHECK-NEXT: call void @objc_exception_try_exit
+
+ // CHECK: call void asm sideeffect "", "=*m"
+ } @finally {
+ break;
+ }
+ }
+}
+
+// Test that modifications to local variables are respected under
+// optimization. rdar://problem/8160285
+
+// CHECK: define i32 @f2()
+int f2() {
+ extern void foo(void);
+
+ // CHECK: [[X:%.*]] = alloca i32
+ // CHECK: store i32 5, i32* [[X]]
+ int x = 0;
+ x += 5;
+
+ // CHECK: [[SETJMP:%.*]] = call i32 @_setjmp
+ // CHECK-NEXT: [[CAUGHT:%.*]] = icmp eq i32 [[SETJMP]], 0
+ // CHECK-NEXT: br i1 [[CAUGHT]]
+ @try {
+ // CHECK: store i32 6, i32* [[X]]
+ x++;
+ // CHECK-NEXT: call void asm sideeffect "", "*m,*m"(i32* [[X]]
+ // CHECK-NEXT: call void @foo()
+ // CHECK-NEXT: call void @objc_exception_try_exit
+ // CHECK-NEXT: [[T:%.*]] = load i32* [[X]]
+ foo();
+ } @catch (id) {
+ // Landing pad. Note that we elide the re-enter.
+ // CHECK: call void asm sideeffect "", "=*m,=*m"(i32* [[X]]
+ // CHECK-NEXT: call i8* @objc_exception_extract
+ // CHECK-NEXT: [[T1:%.*]] = load i32* [[X]]
+ // CHECK-NEXT: [[T2:%.*]] = add nsw i32 [[T1]], -1
+
+ // This store is dead.
+ // CHECK-NEXT: store i32 [[T2]], i32* [[X]]
+ x--;
+ }
+
+ return x;
+}
+
+// Test that the cleanup destination is saved when entering a finally
+// block. rdar://problem/8293901
+// CHECK: define void @f3()
+void f3() {
+ extern void f3_helper(int, int*);
+
+ // CHECK: [[X:%.*]] = alloca i32
+ // CHECK: store i32 0, i32* [[X]]
+ int x = 0;
+
+ // CHECK: call void @objc_exception_try_enter(
+ // CHECK: call i32 @_setjmp
+ // CHECK-NEXT: icmp eq
+ // CHECK-NEXT: br i1
+
+ @try {
+ // CHECK: call void @f3_helper(i32 0, i32* [[X]])
+ // CHECK: call void @objc_exception_try_exit(
+ f3_helper(0, &x);
+ } @finally {
+ // CHECK: [[DEST1:%.*]] = phi i32 [ 0, {{%.*}} ], [ 3, {{%.*}} ]
+ // CHECK: call void @objc_exception_try_enter
+ // CHECK: call i32 @_setjmp
+ @try {
+ // CHECK: call void @f3_helper(i32 1, i32* [[X]])
+ // CHECK: call void @objc_exception_try_exit(
+ f3_helper(1, &x);
+ } @finally {
+ // CHECK: [[DEST2:%.*]] = phi i32 [ 0, {{%.*}} ], [ 5, {{%.*}} ]
+ // CHECK: call void @f3_helper(i32 2, i32* [[X]])
+ f3_helper(2, &x);
+
+ // This loop is large enough to dissuade the optimizer from just
+ // duplicating the finally block.
+ while (x) f3_helper(3, &x);
+
+ // This is a switch or maybe some chained branches, but relying
+ // on a specific result from the optimizer is really unstable.
+ // CHECK: [[DEST2]]
+ }
+
+ // This is a switch or maybe some chained branches, but relying
+ // on a specific result from the optimizer is really unstable.
+ // CHECK: [[DEST1]]
+ }
+
+ // CHECK: call void @f3_helper(i32 4, i32* [[X]])
+ // CHECK-NEXT: ret void
+ f3_helper(4, &x);
+}
+
+// rdar://problem/8440970
+void f4() {
+ extern void f4_help(int);
+
+ // CHECK: define void @f4()
+ // CHECK: [[EXNDATA:%.*]] = alloca [[EXNDATA_T:%.*]], align
+ // CHECK: call void @objc_exception_try_enter([[EXNDATA_T]]* [[EXNDATA]])
+ // CHECK: call i32 @_setjmp
+ @try {
+ // CHECK: call void @f4_help(i32 0)
+ f4_help(0);
+
+ // The finally cleanup has two threaded entrypoints after optimization:
+
+ // finally.no-call-exit: Predecessor is when the catch throws.
+ // CHECK: call i8* @objc_exception_extract([[EXNDATA_T]]* [[EXNDATA]])
+ // CHECK-NEXT: call void @f4_help(i32 2)
+ // CHECK-NEXT: br label
+ // -> rethrow
+
+ // finally.call-exit: Predecessors are the @try and @catch fallthroughs
+ // as well as the no-match case in the catch mechanism. The i1 is whether
+ // to rethrow and should be true only in the last case.
+ // CHECK: phi i1
+ // CHECK-NEXT: phi i8*
+ // CHECK-NEXT: call void @objc_exception_try_exit([[EXNDATA_T]]* [[EXNDATA]])
+ // CHECK-NEXT: call void @f4_help(i32 2)
+ // CHECK-NEXT: br i1
+ // -> ret, rethrow
+
+ // ret:
+ // CHECK: ret void
+
+ // Catch mechanism:
+ // CHECK: call i8* @objc_exception_extract([[EXNDATA_T]]* [[EXNDATA]])
+ // CHECK-NEXT: call void @objc_exception_try_enter([[EXNDATA_T]]* [[EXNDATA]])
+ // CHECK: call i32 @_setjmp
+ // -> next, finally.no-call-exit
+ // CHECK: call i32 @objc_exception_match
+ // -> finally.call-exit, match
+ } @catch (NSArray *a) {
+ // match:
+ // CHECK: call void @f4_help(i32 1)
+ // CHECK-NEXT: br label
+ // -> finally.call-exit
+ f4_help(1);
+ } @finally {
+ f4_help(2);
+ }
+
+ // rethrow:
+ // CHECK: phi i8*
+ // CHECK-NEXT: call void @objc_exception_throw(i8*
+ // CHECK-NEXT: unreachable
+}
diff --git a/clang/test/CodeGenObjC/for-in.m b/clang/test/CodeGenObjC/for-in.m
new file mode 100644
index 0000000..26fe792
--- /dev/null
+++ b/clang/test/CodeGenObjC/for-in.m
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+void p(const char*, ...);
+
+@interface NSArray
++(NSArray*) arrayWithObjects: (id) first, ...;
+-(unsigned) count;
+@end
+@interface NSString
+-(const char*) cString;
+@end
+
+#define S(n) @#n
+#define L1(n) S(n+0),S(n+1)
+#define L2(n) L1(n+0),L1(n+2)
+#define L3(n) L2(n+0),L2(n+4)
+#define L4(n) L3(n+0),L3(n+8)
+#define L5(n) L4(n+0),L4(n+16)
+#define L6(n) L5(n+0),L5(n+32)
+
+void t0() {
+ NSArray *array = [NSArray arrayWithObjects: L1(0), (void*)0];
+
+ p("array.length: %d\n", [array count]);
+ unsigned index = 0;
+ for (NSString *i in array) { // expected-warning {{collection expression type 'NSArray *' may not respond}}
+ p("element %d: %s\n", index++, [i cString]);
+ }
+}
+
+void t1() {
+ NSArray *array = [NSArray arrayWithObjects: L6(0), (void*)0];
+
+ p("array.length: %d\n", [array count]);
+ unsigned index = 0;
+ for (NSString *i in array) { // expected-warning {{collection expression type 'NSArray *' may not respond}}
+ index++;
+ if (index == 10)
+ continue;
+ p("element %d: %s\n", index, [i cString]);
+ if (index == 55)
+ break;
+ }
+}
+
+// rdar://problem/9027663
+void t2(NSArray *array) {
+ for (NSArray *array in array) { // expected-warning {{collection expression type 'NSArray *' may not respond}}
+ }
+}
diff --git a/clang/test/CodeGenObjC/forward-class-impl-metadata.m b/clang/test/CodeGenObjC/forward-class-impl-metadata.m
new file mode 100644
index 0000000..371abf2
--- /dev/null
+++ b/clang/test/CodeGenObjC/forward-class-impl-metadata.m
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@interface BASE {
+@private
+ void* _reserved;
+}
+@end
+
+@class PVR;
+
+@interface PVRHandldler
+{
+ PVR *_imageBrowser;
+}
+@end
+
+@implementation PVRHandldler @end
+
+
+@interface PVR : BASE
+@end
+
+@implementation PVR
+@end
+
+// Reopen of an interface after use.
+
+@interface A {
+@public
+ int x;
+}
+@property int p0;
+@end
+
+int f0(A *a) {
+ return a.p0;
+}
+
+@implementation A
+@synthesize p0 = _p0;
+@end
+
+@interface B
+@end
+@class B;
+@implementation B
+@end
diff --git a/clang/test/CodeGenObjC/forward-decl-param.m b/clang/test/CodeGenObjC/forward-decl-param.m
new file mode 100644
index 0000000..d54a888
--- /dev/null
+++ b/clang/test/CodeGenObjC/forward-decl-param.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+// <rdar://problem/9123036> crash due to forward-declared struct in
+// protocol method parameter.
+
+@protocol P
+- (void) A:(struct z) z;
+@end
+@interface I < P >
+@end
+@implementation I
+@end
+
+@interface I2
+- (void) A:(struct z2) z2;
+@end
+@implementation I2
+@end
+
diff --git a/clang/test/CodeGenObjC/fp2ret.m b/clang/test/CodeGenObjC/fp2ret.m
new file mode 100644
index 0000000..9c956ae
--- /dev/null
+++ b/clang/test/CodeGenObjC/fp2ret.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | \
+// RUN: FileCheck --check-prefix=CHECK-X86_32 %s
+//
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | \
+// RUN: FileCheck --check-prefix=CHECK-X86_64 %s
+//
+// RUN: %clang_cc1 -triple armv7-apple-darwin10 -fobjc-fragile-abi -emit-llvm -target-abi apcs-gnu -o - %s | \
+// RUN: FileCheck --check-prefix=CHECK-ARMV7 %s
+
+@interface A
+-(_Complex long double) complexLongDoubleValue;
+@end
+
+
+// CHECK-X86_32: define void @t0()
+// CHECK-X86_32: call void bitcast {{.*}} @objc_msgSend_stret to
+// CHECK-X86_32: }
+//
+// CHECK-X86_64: define void @t0()
+// CHECK-X86_64: call { x86_fp80, x86_fp80 } bitcast {{.*}} @objc_msgSend_fp2ret to
+// CHECK-X86_64: }
+//
+// CHECK-ARMV7: define void @t0()
+// CHECK-ARMV7: call i128 bitcast {{.*}} @objc_msgSend to
+// CHECK-ARMV7: }
+void t0() {
+ [(A*)0 complexLongDoubleValue];
+}
diff --git a/clang/test/CodeGenObjC/fpret.m b/clang/test/CodeGenObjC/fpret.m
new file mode 100644
index 0000000..bf111e0
--- /dev/null
+++ b/clang/test/CodeGenObjC/fpret.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | \
+// RUN: FileCheck --check-prefix=CHECK-X86_32 %s
+//
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | \
+// RUN: FileCheck --check-prefix=CHECK-X86_64 %s
+//
+// RUN: %clang_cc1 -triple armv7-apple-darwin10 -fobjc-fragile-abi -emit-llvm -target-abi apcs-gnu -o - %s | \
+// RUN: FileCheck --check-prefix=CHECK-ARMV7 %s
+
+@interface A
+-(float) floatValue;
+-(double) doubleValue;
+-(long double) longDoubleValue;
+@end
+
+
+// CHECK-X86_32: define void @t0()
+// CHECK-X86_32: call float bitcast {{.*}} @objc_msgSend_fpret to
+// CHECK-X86_32: call double bitcast {{.*}} @objc_msgSend_fpret to
+// CHECK-X86_32: call x86_fp80 bitcast {{.*}} @objc_msgSend_fpret to
+// CHECK-X86_32: }
+//
+// CHECK-X86_64: define void @t0()
+// CHECK-X86_64: call float bitcast {{.*}} @objc_msgSend to
+// CHECK-X86_64: call double bitcast {{.*}} @objc_msgSend to
+// CHECK-X86_64: call x86_fp80 bitcast {{.*}} @objc_msgSend_fpret to
+// CHECK-X86_64: }
+//
+// CHECK-ARMV7: define void @t0()
+// CHECK-ARMV7: call float bitcast {{.*}} @objc_msgSend to
+// CHECK-ARMV7: call double bitcast {{.*}} @objc_msgSend to
+// CHECK-ARMV7: call double bitcast {{.*}} @objc_msgSend to
+// CHECK-ARMV7: }
+void t0() {
+ [(A*)0 floatValue];
+ [(A*)0 doubleValue];
+ [(A*)0 longDoubleValue];
+}
diff --git a/clang/test/CodeGenObjC/function-decay.m b/clang/test/CodeGenObjC/function-decay.m
new file mode 100644
index 0000000..161f907
--- /dev/null
+++ b/clang/test/CodeGenObjC/function-decay.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+@interface I0 @end
+@implementation I0
+- (void) im0: (int (void)) a0 {
+}
+@end
+
+void func(int pf(void)) {
+}
diff --git a/clang/test/CodeGenObjC/gc-weak-attribute.m b/clang/test/CodeGenObjC/gc-weak-attribute.m
new file mode 100644
index 0000000..032c7c6
--- /dev/null
+++ b/clang/test/CodeGenObjC/gc-weak-attribute.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o - %s | FileCheck %s
+// rdar://10073896
+
+@interface I
+{
+ __weak id wObject;
+}
+@property (readwrite, weak) id representedObject;
+@property (readwrite, weak) id wObject;
+@property (readwrite, weak) __weak id wRandom;
+@property (readwrite, assign) __weak id wAnother;
+@end
+
+@implementation I
+@synthesize representedObject;
+@synthesize wObject;
+@synthesize wRandom;
+@synthesize wAnother;
+@end
+// CHECK: call i8* @objc_read_weak
+// CHECK: call i8* @objc_assign_weak
+// CHECK: call i8* @objc_read_weak
+// CHECK: call i8* @objc_assign_weak
+// CHECK: call i8* @objc_read_weak
+// CHECK: call i8* @objc_assign_weak
+// CHECK: call i8* @objc_read_weak
+// CHECK: call i8* @objc_assign_weak
+
diff --git a/clang/test/CodeGenObjC/gc.m b/clang/test/CodeGenObjC/gc.m
new file mode 100644
index 0000000..b672181
--- /dev/null
+++ b/clang/test/CodeGenObjC/gc.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o - %s | FileCheck %s
+
+void test0(void) {
+ extern id test0_helper(void);
+ __attribute__((objc_precise_lifetime)) id x = test0_helper();
+ test0_helper();
+ // CHECK: define void @test0()
+ // CHECK: [[T0:%.*]] = call i8* @test0_helper()
+ // CHECK-NEXT: store i8* [[T0]], i8** [[X:%.*]], align 8
+ // CHECK-NEXT: call i8* @test0_helper()
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[X]], align 8
+ // CHECK-NEXT: call void asm sideeffect "", "r"(i8* [[T0]]) nounwind
+ // CHECK-NEXT: ret void
+}
diff --git a/clang/test/CodeGenObjC/gnu-exceptions.m b/clang/test/CodeGenObjC/gnu-exceptions.m
new file mode 100644
index 0000000..8917bf3
--- /dev/null
+++ b/clang/test/CodeGenObjC/gnu-exceptions.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fexceptions -fobjc-exceptions -fgnu-runtime -o - %s | FileCheck %s
+
+void opaque(void);
+void log(int i);
+
+@class C;
+
+// CHECK: define void @test0() {
+void test0() {
+ @try {
+ // CHECK: invoke void @opaque()
+ opaque();
+
+ // CHECK: call void @log(i32 1)
+
+ } @catch (C *c) {
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gnu_objc_personality_v0 to i8*)
+ // CHECK-NEXT: catch i8* getelementptr inbounds ([2 x i8]* @0, i64 0, i64 0)
+ // CHECK: br i1
+
+ // CHECK: call void @log(i32 0)
+
+ // CHECK: call void @objc_exception_throw
+
+ log(0);
+ }
+
+ log(1);
+}
diff --git a/clang/test/CodeGenObjC/hidden-visibility.m b/clang/test/CodeGenObjC/hidden-visibility.m
new file mode 100644
index 0000000..9f5071d
--- /dev/null
+++ b/clang/test/CodeGenObjC/hidden-visibility.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fvisibility hidden -emit-llvm -o - %s | FileCheck %s
+// CHECK: @"OBJC_IVAR_$_I.P" = hidden
+// CHECK: @"OBJC_CLASS_$_I" = hidden
+// CHECK: @"OBJC_METACLASS_$_I" = hidden
+// CHECK: @"\01l_OBJC_PROTOCOL_$_Prot0" = weak hidden
+
+@interface I {
+ int P;
+}
+
+@property int P;
+@end
+
+@implementation I
+@synthesize P;
+@end
+
+
+@protocol Prot0;
+
+id f0() {
+ return @protocol(Prot0);
+}
+
+
diff --git a/clang/test/CodeGenObjC/hidden.m b/clang/test/CodeGenObjC/hidden.m
new file mode 100644
index 0000000..0b77e73
--- /dev/null
+++ b/clang/test/CodeGenObjC/hidden.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+__attribute__((visibility("hidden")))
+@interface Hidden
++(void) bar;
+@end
+
+@implementation Hidden
++(void) bar {}
+@end
+
+__attribute__((visibility("default")))
+@interface Default
++(void) bar;
+@end
+
+@implementation Default
++(void) bar {}
+@end
diff --git a/clang/test/CodeGenObjC/id-isa-codegen.m b/clang/test/CodeGenObjC/id-isa-codegen.m
new file mode 100644
index 0000000..8cac750
--- /dev/null
+++ b/clang/test/CodeGenObjC/id-isa-codegen.m
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck -check-prefix LP32 %s
+
+typedef struct objc_class *Class;
+
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+@interface I
++ (Class) class;
+- (void)meth : (id)object : (id)src_object;
++ (unsigned char) isSubclassOfClass:(Class)aClass ;
+@end
+
+@implementation I
++ (Class) class {return 0;}
++ (unsigned char) isSubclassOfClass:(Class)aClass {return 0;}
+- (void)meth : (id)object : (id)src_object {
+ [object->isa isSubclassOfClass:[I class]];
+
+ [(*object).isa isSubclassOfClass:[I class]];
+
+ object->isa = src_object->isa;
+ (*src_object).isa = (*object).isa;
+}
+@end
+
+
+// rdar 7470820
+static Class MyClass;
+
+Class Test(const void *inObject1) {
+ if(((id)inObject1)->isa == MyClass)
+ return ((id)inObject1)->isa;
+ return (id)0;
+}
+
+// rdar 7609722
+@interface Foo {
+@public
+ id isa;
+}
++(id)method;
+@end
+
+id Test2() {
+ if([Foo method]->isa)
+ return (*[Foo method]).isa;
+ return [Foo method]->isa;
+}
+
+// rdar 7709015
+@interface Cat {}
+@end
+
+@interface SuperCat : Cat {}
++(void)geneticallyAlterCat:(Cat *)cat;
+@end
+
+@implementation SuperCat
++ (void)geneticallyAlterCat:(Cat *)cat {
+ Class dynamicSubclass;
+ ((id)cat)->isa = dynamicSubclass;
+}
+@end
+// CHECK-LP64: %{{.*}} = load i8** %
+// CHECK-NEXT: %{{.*}} = bitcast i8* %{{.*}} to i8**
+// CHECK-NEXT: store i8* %{{.*}}, i8** %{{.*}}
+
+// CHECK-LP32: %{{.*}} = load i8** %
+// CHECK-NEXT: %{{.*}} = bitcast i8* %{{.*}} to i8**
+// CHECK-NEXT: store i8* %{{.*}}, i8** %{{.*}}
diff --git a/clang/test/CodeGenObjC/illegal-UTF8.m b/clang/test/CodeGenObjC/illegal-UTF8.m
new file mode 100644
index 0000000..4762e80
--- /dev/null
+++ b/clang/test/CodeGenObjC/illegal-UTF8.m
@@ -0,0 +1,6 @@
+// RUN: %clang %s -S -m64 -o -
+
+@class NSString;
+
+
+NSString *S = @"\xff\xff___WAIT___"; // expected-warning {{input conversion stopped due to an input byte that does not belong to the input codeset UTF-8}}
diff --git a/clang/test/CodeGenObjC/image-info.m b/clang/test/CodeGenObjC/image-info.m
new file mode 100644
index 0000000..613b272
--- /dev/null
+++ b/clang/test/CodeGenObjC/image-info.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s
+// RUN: FileCheck --check-prefix CHECK-FRAGILE < %t %s
+
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s
+// RUN: FileCheck --check-prefix CHECK-NONFRAGILE < %t %s
+
+// CHECK-FRAGILE: !llvm.module.flags = !{!0, !1, !2, !3}
+// CHECK-FRAGILE: !0 = metadata !{i32 1, metadata !"Objective-C Version", i32 1}
+// CHECK-FRAGILE-NEXT: !1 = metadata !{i32 1, metadata !"Objective-C Image Info Version", i32 0}
+// CHECK-FRAGILE-NEXT: !2 = metadata !{i32 1, metadata !"Objective-C Image Info Section", metadata !"__OBJC, __image_info,regular"}
+// CHECK-FRAGILE-NEXT: !3 = metadata !{i32 4, metadata !"Objective-C Garbage Collection", i32 0}
+
+// CHECK-NONFRAGILE: !llvm.module.flags = !{!0, !1, !2, !3}
+// CHECK-NONFRAGILE: !0 = metadata !{i32 1, metadata !"Objective-C Version", i32 2}
+// CHECK-NONFRAGILE-NEXT: !1 = metadata !{i32 1, metadata !"Objective-C Image Info Version", i32 0}
+// CHECK-NONFRAGILE-NEXT: !2 = metadata !{i32 1, metadata !"Objective-C Image Info Section", metadata !"__DATA, __objc_imageinfo, regular, no_dead_strip"}
+// CHECK-NONFRAGILE-NEXT: !3 = metadata !{i32 4, metadata !"Objective-C Garbage Collection", i32 0}
diff --git a/clang/test/CodeGenObjC/implicit-objc_msgSend.m b/clang/test/CodeGenObjC/implicit-objc_msgSend.m
new file mode 100644
index 0000000..aff0fe4
--- /dev/null
+++ b/clang/test/CodeGenObjC/implicit-objc_msgSend.m
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s
+// RUN: grep -F 'declare i8* @objc_msgSend(i8*, i8*, ...)' %t
+
+typedef struct objc_selector *SEL;
+id f0(id x, SEL s) {
+ return objc_msgSend(x, s);
+}
diff --git a/clang/test/CodeGenObjC/implicit-property.m b/clang/test/CodeGenObjC/implicit-property.m
new file mode 100644
index 0000000..db1da31
--- /dev/null
+++ b/clang/test/CodeGenObjC/implicit-property.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -triple=i686-apple-darwin8 -o %t %s
+// RUNX: %clang_cc1 -emit-llvm -o %t %s
+
+@interface A
+ -(void) setOk:(int)arg;
+ -(int) ok;
+
+ -(void) setX:(int)arg;
+ -(int) x;
+@end
+
+void f0(A *a) {
+ a.x = 1;
+ a.ok = a.x;
+}
+
diff --git a/clang/test/CodeGenObjC/instance-method-metadata.m b/clang/test/CodeGenObjC/instance-method-metadata.m
new file mode 100644
index 0000000..ec24c28
--- /dev/null
+++ b/clang/test/CodeGenObjC/instance-method-metadata.m
@@ -0,0 +1,35 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S -o %t %s
+// RUN: FileCheck < %t %s
+
+// rdar://9072317
+
+/** The problem looks like clang getting confused when a single translation unit
+ contains a protocol with a property and two classes that implement that protocol
+ and synthesize the property.
+*/
+
+@protocol Proto
+@property (assign) id prop;
+@end
+
+@interface NSObject @end
+
+@interface Foo : NSObject <Proto> { int x; } @end
+
+@interface Bar : NSObject <Proto> @end
+
+@implementation Foo
+@synthesize prop;
+@end
+
+@implementation Bar
+@synthesize prop;
+@end
+
+// CHECK: l_OBJC_$_INSTANCE_METHODS_Bar:
+// CHECK-NEXT .long 24
+// CHECK-NEXT .long 2
+// CHECK-NEXT .quad L_OBJC_METH_VAR_NAME_
+// CHECK-NEXT .quad L_OBJC_METH_VAR_TYPE_
+// CHECK-NEXT .quad "-[Bar prop]"
diff --git a/clang/test/CodeGenObjC/interface-layout-64.m b/clang/test/CodeGenObjC/interface-layout-64.m
new file mode 100644
index 0000000..4fdda45
--- /dev/null
+++ b/clang/test/CodeGenObjC/interface-layout-64.m
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s
+// RUNX: llvm-gcc -m64 -emit-llvm -S -o %t %s &&
+
+// RUN: grep '@"OBJC_IVAR_$_I3._iv2" = global i64 8, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I3._iv3" = global i64 12, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I4._iv4" = global i64 13, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I5._iv5" = global i64 14, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I5._iv6_synth" = hidden global i64 16, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I5._iv7_synth" = hidden global i64 20, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I6.iv0" = global i64 0, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I8.b" = global i64 8, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I9.iv0" = global i64 0, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I10.iv1" = global i64 4, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I12.iv2" = global i64 8, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '_OBJC_CLASS_RO_$_I3" = internal global .* { i32 0, i32 8, i32 13, .*' %t
+// RUN: grep '_OBJC_CLASS_RO_$_I4" = internal global .* { i32 0, i32 13, i32 14, .*' %t
+// RUN: grep '_OBJC_CLASS_RO_$_I5" = internal global .* { i32 0, i32 14, i32 24, .*' %t
+// RUN: grep '_OBJC_CLASS_RO_$_I6" = internal global .* { i32 2, i32 0, i32 1, .*' %t
+// RUN: grep '_OBJC_CLASS_RO_$_I8" = internal global .* { i32 0, i32 8, i32 16, .*' %t
+// RUN: grep '_OBJC_CLASS_RO_$_I9" = internal global .* { i32 2, i32 0, i32 4, .*' %t
+// RUN: grep '_OBJC_CLASS_RO_$_I10" = internal global .* { i32 0, i32 4, i32 5, .*' %t
+// RUN: grep '_OBJC_CLASS_RO_$_I11" = internal global .* { i32 0, i32 5, i32 5, .*' %t
+// RUN: grep '_OBJC_CLASS_RO_$_I12" = internal global .* { i32 0, i32 8, i32 12, .*' %t
+
+
+/*
+ Compare to:
+ gcc -m64 -S -o - interface-layout-64.m | grep '^_OBJC_IVAR_$_*.*' -A 1
+ and
+ gcc -m64 -S -o - interface-layout-64.m | grep '^l.*_CLASS_RO_$_I[0-9]*' -A 3
+ */
+
+struct s0 {
+ double x;
+};
+
+@interface I2 {
+ struct s0 _iv1;
+}
+@end
+
+@interface I3 : I2 {
+ unsigned int _iv2 :1;
+ unsigned : 0;
+ unsigned int _iv3 : 3;
+}
+@end
+
+@interface I4 : I3 {
+ char _iv4;
+}
+@end
+
+@interface I5 : I4 {
+ char _iv5;
+}
+
+@property int prop0;
+@end
+
+@implementation I3
+@end
+
+@implementation I4
+@end
+
+@interface I5 ()
+@property int prop1;
+@property char prop2;
+@end
+
+@implementation I5
+@synthesize prop0 = _iv6_synth;
+@synthesize prop1 = _iv7_synth;
+@synthesize prop2 = _iv5;
+@end
+
+// The size rounds up to the next available byte.
+@interface I6 {
+ unsigned iv0 : 2;
+}
+@end
+@implementation I6
+@end
+
+// The start of the subclass includes padding for its own alignment.
+@interface I7 {
+ char a;
+}
+@end
+@interface I8 : I7 {
+ double b;
+}
+@end
+@implementation I8
+@end
+
+// Padding bit-fields
+@interface I9 {
+ unsigned iv0 : 2;
+ unsigned : 0;
+}
+@end
+@implementation I9
+@end
+@interface I10 : I9 {
+ unsigned iv1 : 2;
+}
+@end
+@implementation I10
+@end
+
+// Empty structures
+@interface I11 : I10
+@end
+@implementation I11
+@end
+@interface I12 : I11 {
+ unsigned iv2;
+}
+@end
+@implementation I12
+@end
diff --git a/clang/test/CodeGenObjC/interface.m b/clang/test/CodeGenObjC/interface.m
new file mode 100644
index 0000000..0ca64ec
--- /dev/null
+++ b/clang/test/CodeGenObjC/interface.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -O3 -emit-llvm -o %t %s
+// RUN: grep 'ret i32 385' %t
+
+void *alloca();
+
+@interface I0 {
+@public
+ int iv0;
+ int iv1;
+ int iv2;
+}
+@end
+
+static int f0(I0 *a0) {
+ return (*(a0 + 2)).iv0;
+}
+
+static int f1(I0 *a0) {
+ return a0[2].iv1;
+}
+
+static int f2(I0 *a0) {
+ return (*(a0 - 1)).iv2;
+}
+
+int g0(void) {
+ I0 *a = alloca(sizeof(*a) * 4);
+ a[2].iv0 = 5;
+ a[2].iv1 = 7;
+ a[2].iv2 = 11;
+ return f0(a) * f1(a) * f2(&a[3]);
+}
+
+
diff --git a/clang/test/CodeGenObjC/ivar-base-as-invariant-load.m b/clang/test/CodeGenObjC/ivar-base-as-invariant-load.m
new file mode 100644
index 0000000..8b660cf
--- /dev/null
+++ b/clang/test/CodeGenObjC/ivar-base-as-invariant-load.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -x objective-c %s -o - | FileCheck %s
+// rdar://10840980
+
+@interface A {
+ struct {
+ unsigned char a : 1;
+ unsigned char b : 1;
+ unsigned char c : 1;
+ } _flags;
+}
+
+@end
+
+@implementation A
+
+- (id)init {
+ _flags.a = 1;
+ _flags.b = 1;
+ _flags.c = 1;
+
+ return self;
+}
+
+@end
+
+// CHECK: [[T1:%.*]] = load i64* @"OBJC_IVAR_$_A._flags", !invariant.load !4
+// CHECK: [[T2:%.*]] = load i64* @"OBJC_IVAR_$_A._flags", !invariant.load !4
+// CHECK: [[T3:%.*]] = load i64* @"OBJC_IVAR_$_A._flags", !invariant.load !4
+
diff --git a/clang/test/CodeGenObjC/ivar-layout-64-bitfields.m b/clang/test/CodeGenObjC/ivar-layout-64-bitfields.m
new file mode 100644
index 0000000..acc734a
--- /dev/null
+++ b/clang/test/CodeGenObjC/ivar-layout-64-bitfields.m
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+
+#ifdef __cplusplus
+typedef bool _Bool;
+#endif
+
+@interface I
+{
+ struct {
+ unsigned int d : 1;
+ } bitfield;
+}
+@end
+
+@implementation I
+@end
+
+@interface J
+{
+ struct {
+ unsigned short _reserved : 16;
+
+ _Bool _draggedNodesAreDeletable: 1;
+ _Bool _draggedOutsideOutlineView : 1;
+ _Bool _adapterRespondsTo_addRootPaths : 1;
+ _Bool _adapterRespondsTo_moveDataNodes : 1;
+ _Bool _adapterRespondsTo_removeRootDataNode : 1;
+ _Bool _adapterRespondsTo_doubleClickDataNode : 1;
+ _Bool _adapterRespondsTo_selectDataNode : 1;
+ _Bool _adapterRespondsTo_textDidEndEditing : 1;
+
+ _Bool _adapterRespondsTo_updateAndSaveRoots : 1;
+ _Bool _adapterRespondsTo_askToDeleteRootNodes : 1;
+ _Bool _adapterRespondsTo_contextMenuForSelectedNodes : 1;
+ _Bool _adapterRespondsTo_pasteboardFilenamesForNodes : 1;
+ _Bool _adapterRespondsTo_writeItemsToPasteboard : 1;
+ _Bool _adapterRespondsTo_writeItemsToPasteboardXXXX : 1;
+ } _flags;
+}
+@end
+
+@implementation J
+@end
+
+
diff --git a/clang/test/CodeGenObjC/ivar-layout-64.m b/clang/test/CodeGenObjC/ivar-layout-64.m
new file mode 100644
index 0000000..ea4cdce
--- /dev/null
+++ b/clang/test/CodeGenObjC/ivar-layout-64.m
@@ -0,0 +1,94 @@
+// RUNX: llvm-gcc -m64 -fobjc-gc -emit-llvm -S -o %t %s &&
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"A\\00"' %t
+// RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"\\11q\\10\\00"' %t
+// RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"!q\\00"' %t
+// RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"\\01\\14\\00"' %t
+// RUNX: llvm-gcc -ObjC++ -m64 -fobjc-gc -emit-llvm -S -o %t %s &&
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"A\\00"' %t
+// RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"\\11q\\10\\00"' %t
+// RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"!q\\00"' %t
+// RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"\\01\\14\\00"' %t
+
+/*
+
+Here is a handy command for looking at llvm-gcc's output:
+llvm-gcc -m64 -fobjc-gc -emit-llvm -S -o - ivar-layout-64.m | \
+ grep 'OBJC_CLASS_NAME.* =.*global' | \
+ sed -e 's#, section.*# ...#' | \
+ sed -e 's#_[0-9]*"#_NNN#' | \
+ sort
+
+*/
+
+@interface B @end
+
+@interface A {
+ struct s0 {
+ int f0;
+ int f1;
+ } f0;
+ id f1;
+__weak B *f2;
+ int f3 : 5;
+ struct s1 {
+ int *f0;
+ int *f1;
+ } f4[2][1];
+}
+@end
+
+@interface C : A
+@property int p3;
+@end
+
+@implementation C
+@synthesize p3 = _p3;
+@end
+
+@interface A()
+@property int p0;
+@property (assign) __strong id p1;
+@property (assign) __weak id p2;
+@end
+
+// FIXME: Check layout for this class, once it is clear what the right
+// answer is.
+@implementation A
+@synthesize p0 = _p0;
+@synthesize p1 = _p1;
+@synthesize p2 = _p2;
+@end
+
+@interface D : A
+@property int p3;
+@end
+
+// FIXME: Check layout for this class, once it is clear what the right
+// answer is.
+@implementation D
+@synthesize p3 = _p3;
+@end
+
+typedef unsigned short UInt16;
+
+
+typedef signed char BOOL;
+typedef unsigned int FSCatalogInfoBitmap;
+
+@interface NSFileLocationComponent {
+ @private
+
+ id _specifierOrStandardizedPath;
+ BOOL _carbonCatalogInfoAndNameAreValid;
+ FSCatalogInfoBitmap _carbonCatalogInfoMask;
+ id _name;
+ id _containerComponent;
+ id _presentableName;
+ id _iconAsAttributedString;
+}
+@end
+
+@implementation NSFileLocationComponent @end
+
diff --git a/clang/test/CodeGenObjC/ivar-layout-array0-struct.m b/clang/test/CodeGenObjC/ivar-layout-array0-struct.m
new file mode 100644
index 0000000..7ef32f6
--- /dev/null
+++ b/clang/test/CodeGenObjC/ivar-layout-array0-struct.m
@@ -0,0 +1,23 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -O0 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+
+// rdar://8800513
+@interface NSObject {
+ id isa;
+}
+@end
+
+typedef struct {
+ id b;
+} st;
+
+@interface Test : NSObject {
+ int a;
+ st b[0];
+}
+@end
+
+@implementation Test @end
+// CHECK-LP64: L_OBJC_CLASS_NAME_4:
+// CHECK-LP64-NEXT: .asciz "\001\020"
diff --git a/clang/test/CodeGenObjC/ivar-layout-no-optimize.m b/clang/test/CodeGenObjC/ivar-layout-no-optimize.m
new file mode 100644
index 0000000..85bba8a
--- /dev/null
+++ b/clang/test/CodeGenObjC/ivar-layout-no-optimize.m
@@ -0,0 +1,20 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -O0 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -x objective-c++ -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -O0 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+
+@interface NSObject {
+ id isa;
+}
+@end
+
+@interface AllPointers : NSObject {
+ id foo;
+ void *__strong bar; NSObject *bletch;}
+@end
+@implementation AllPointers
+@end
+
+// CHECK-LP64: L_OBJC_CLASS_NAME_6:
+// CHECK-LP64-NEXT: .asciz "\004"
diff --git a/clang/test/CodeGenObjC/ivar-layout-nonfragile-abi2.m b/clang/test/CodeGenObjC/ivar-layout-nonfragile-abi2.m
new file mode 100644
index 0000000..65e17a8
--- /dev/null
+++ b/clang/test/CodeGenObjC/ivar-layout-nonfragile-abi2.m
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -emit-llvm -o %t %s
+// rdar: // 7824380
+
+@interface Super {
+ int ivar_super_a : 5;
+}
+@end
+
+@interface A : Super {
+@public
+ int ivar_a : 5;
+}
+@end
+
+int f0(A *a) {
+ return a->ivar_a;
+}
+
+@interface A () {
+@public
+ int ivar_ext_a : 5;
+ int ivar_ext_b : 5;
+}@end
+
+int f1(A *a) {
+ return a->ivar_ext_a + a->ivar_a;
+}
+
+@interface A () {
+@public
+ int ivar_ext2_a : 5;
+ int ivar_ext2_b : 5;
+}@end
+
+int f2(A* a) {
+ return a->ivar_ext2_a + a->ivar_ext_a + a->ivar_a;
+}
+
+@implementation A {
+@public
+ int ivar_b : 5;
+ int ivar_c : 5;
+ int ivar_d : 5;
+}
+@end
+
+int f3(A *a) {
+ return a->ivar_d + a->ivar_ext2_a + a->ivar_ext_a + a->ivar_a;
+}
+
diff --git a/clang/test/CodeGenObjC/ivars.m b/clang/test/CodeGenObjC/ivars.m
new file mode 100644
index 0000000..6c8a72d
--- /dev/null
+++ b/clang/test/CodeGenObjC/ivars.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s
+// RUN: %clang_cc1 -fobjc-gc -emit-llvm -o - %s
+
+// rdar://6800926
+@interface ITF {
+@public
+ unsigned field :1 ;
+ _Bool boolfield :1 ;
+}
+@end
+
+void foo(ITF *P) {
+ P->boolfield = 1;
+}
+
+// rdar://8368320
+@interface R {
+ struct {
+ union {
+ int x;
+ char c;
+ };
+ } _union;
+}
+@end
+
+@implementation R
+@end
diff --git a/clang/test/CodeGenObjC/link-errors.m b/clang/test/CodeGenObjC/link-errors.m
new file mode 100644
index 0000000..0d19681
--- /dev/null
+++ b/clang/test/CodeGenObjC/link-errors.m
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s
+// RUN: grep '.lazy_reference .objc_class_name_A' %t | count 1
+// RUN: grep '.lazy_reference .objc_class_name_Unknown' %t | count 1
+// RUN: grep '.lazy_reference .objc_class_name_Protocol' %t | count 1
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -DWITH_IMPL -emit-llvm -o %t %s
+// RUN: grep '.lazy_reference .objc_class_name_Root' %t | count 1
+
+@interface Root
+-(id) alloc;
+-(id) init;
+@end
+
+@protocol P;
+
+@interface A : Root
+@end
+
+@interface A (Category)
++(void) foo;
+@end
+
+#ifdef WITH_IMPL
+@implementation A
+@end
+#endif
+
+@interface Unknown
++test;
+@end
+
+
+int main() {
+ id x = @protocol(P);
+ [ A alloc ];
+ [ A foo ];
+ [ Unknown test ];
+ return 0;
+}
+
diff --git a/clang/test/CodeGenObjC/local-static-block.m b/clang/test/CodeGenObjC/local-static-block.m
new file mode 100644
index 0000000..7a7b6f6
--- /dev/null
+++ b/clang/test/CodeGenObjC/local-static-block.m
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -fobjc-fragile-abi -emit-llvm %s -o %t-64.ll
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.ll %s
+// rdar: // 8390455
+
+@class NSArray;
+
+static NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSArray *addresses, unsigned long level) {
+
+ for(id rawAddress in addresses)
+ {
+ NSArray *separatedAddresses = ((NSArray*)0);
+ separatedAddresses = ArrayRecurs((NSArray *)rawAddress, level+1);
+ }
+ return (NSArray *)0;
+};
+
+void FUNC()
+{
+ static NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSArray *addresses, unsigned long level) {
+
+ for(id rawAddress in addresses)
+ {
+ NSArray *separatedAddresses = ((NSArray*)0);
+ separatedAddresses = ArrayRecurs((NSArray *)rawAddress, level+1);
+ }
+ return (NSArray *)0;
+ };
+
+ if (ArrayRecurs) {
+ static NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSArray *addresses, unsigned long level) {
+
+ for(id rawAddress in addresses)
+ {
+ NSArray *separatedAddresses = ((NSArray*)0);
+ separatedAddresses = ArrayRecurs((NSArray *)rawAddress, level+1);
+ }
+ return (NSArray *)0;
+ };
+ }
+}
+
+void FUNC1()
+{
+ static NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSArray *addresses, unsigned long level) {
+
+ for(id rawAddress in addresses)
+ {
+ NSArray *separatedAddresses = ((NSArray*)0);
+ separatedAddresses = ArrayRecurs((NSArray *)rawAddress, level+1);
+ }
+ return (NSArray *)0;
+ };
+}
+// CHECK-LP64: @ArrayRecurs = internal global
+// CHECK-LP64: @FUNC.ArrayRecurs = internal global
+// CHECK-LP64: @FUNC.ArrayRecurs3 = internal global
+// CHECK-LP64: @FUNC1.ArrayRecurs = internal global
diff --git a/clang/test/CodeGenObjC/message-arrays.m b/clang/test/CodeGenObjC/message-arrays.m
new file mode 100644
index 0000000..3e8697f
--- /dev/null
+++ b/clang/test/CodeGenObjC/message-arrays.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+void f0(id a) {
+ // This should have an implicit cast
+ [ a print: "hello" ];
+}
+
+@interface A
+-(void) m: (int) arg0, ...;
+@end
+
+int f1(A *a) {
+ // This should also get an implicit cast (for the vararg)
+ [a m: 1, "test"];
+}
diff --git a/clang/test/CodeGenObjC/messages-2.m b/clang/test/CodeGenObjC/messages-2.m
new file mode 100644
index 0000000..7c9d81c
--- /dev/null
+++ b/clang/test/CodeGenObjC/messages-2.m
@@ -0,0 +1,175 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NF
+
+// Most of this test is apparently just verifying that we don't crash.
+
+int printf(const char *, ...);
+
+@interface Root
+@end
+
+typedef struct {
+ int x, y, z[10];
+} MyPoint;
+typedef struct {
+ float width, height;
+} MySize;
+
+@interface A : Root
++(void) printThisInt: (int) arg0 andThatFloat: (float) arg1 andADouble: (double) arg2 andAPoint: (MyPoint) arg3;
++(float) returnAFloat;
++(double) returnADouble;
++(MyPoint) returnAPoint;
++(void) printThisSize: (MySize) arg0;
++(MySize) returnASize;
+
+-(void) printThisInt: (int) arg0 andThatFloat: (float) arg1 andADouble: (double) arg2 andAPoint: (MyPoint) arg3;
+-(float) returnAFloat;
+-(double) returnADouble;
+-(MyPoint) returnAPoint;
+-(void) printThisSize: (MySize) arg0;
+-(MySize) returnASize;
+@end
+@interface B : A
+@end
+
+@implementation A
++(void) printThisInt: (int) arg0 andThatFloat: (float) arg1 andADouble: (double) arg2 andAPoint: (MyPoint) arg3 {
+ printf("(CLASS) theInt: %d, theFloat: %f, theDouble: %f, thePoint: { %d, %d }\n",
+ arg0, arg1, arg2, arg3.x, arg3.y);
+}
++(float) returnAFloat {
+ return 15.;
+}
++(double) returnADouble {
+ return 25.;
+}
++(MyPoint) returnAPoint {
+ MyPoint x = { 35, 45 };
+ return x;
+}
++(void) printThisSize: (MySize) arg0 {
+ printf("(CLASS) theSize: { %f, %f }\n",
+ arg0.width, arg0.height);
+}
++(MySize) returnASize {
+ MySize x = { 32, 44 };
+ return x;
+}
+
+-(void) printThisInt: (int) arg0 andThatFloat: (float) arg1 andADouble: (double) arg2 andAPoint: (MyPoint) arg3 {
+ printf("theInt: %d, theFloat: %f, theDouble: %f, thePoint: { %d, %d }\n",
+ arg0, arg1, arg2, arg3.x, arg3.y);
+}
+-(float) returnAFloat {
+ return 10.;
+}
+-(double) returnADouble {
+ return 20.;
+}
+-(MyPoint) returnAPoint {
+ MyPoint x = { 30, 40 };
+ return x;
+}
+-(void) printThisSize: (MySize) arg0 {
+ printf("theSize: { %f, %f }\n",
+ arg0.width, arg0.height);
+}
+-(MySize) returnASize {
+ MySize x = { 22, 34 };
+ return x;
+}
+@end
+
+@implementation B
++(void) printThisInt: (int) arg0 andThatFloat: (float) arg1 andADouble: (double) arg2 andAPoint: (MyPoint) arg3 {
+ arg3.x *= 2;
+ arg3.y *= 2;
+ [ super printThisInt: arg0*2 andThatFloat: arg1*2 andADouble: arg2*2 andAPoint: arg3 ];
+}
++(void) printThisSize: (MySize) arg0 {
+ arg0.width *= 2;
+ arg0.height *= 2;
+ [ super printThisSize: arg0 ];
+}
++(float) returnAFloat {
+ return [ super returnAFloat ]*2;
+}
++(double) returnADouble {
+ return [ super returnADouble ]*2;
+}
++(MyPoint) returnAPoint {
+ MyPoint x = [ super returnAPoint ];
+ x.x *= 2;
+ x.y *= 2;
+ return x;
+}
++(MySize) returnASize {
+ MySize x = [ super returnASize ];
+ x.width *= 2;
+ x.height *= 2;
+ return x;
+}
+
+-(void) printThisInt: (int) arg0 andThatFloat: (float) arg1 andADouble: (double) arg2 andAPoint: (MyPoint) arg3 {
+ arg3.x *= 2;
+ arg3.y *= 2;
+ [ super printThisInt: arg0*2 andThatFloat: arg1*2 andADouble: arg2*2 andAPoint: arg3 ];
+}
+-(void) printThisSize: (MySize) arg0 {
+ arg0.width *= 2;
+ arg0.height *= 2;
+ [ super printThisSize: arg0 ];
+}
+-(float) returnAFloat {
+ return [ super returnAFloat ]*2;
+}
+-(double) returnADouble {
+ return [ super returnADouble ]*2;
+}
+-(MyPoint) returnAPoint {
+ MyPoint x = [ super returnAPoint ];
+ x.x *= 2;
+ x.y *= 2;
+ return x;
+}
+-(MySize) returnASize {
+ MySize x = [ super returnASize ];
+ x.width *= 2;
+ x.height *= 2;
+ return x;
+}
+-(const float) returnAConstFloat {
+ return 5;
+}
+@end
+
+// rdar://problem/7854674
+// CHECK: define void @test0([[A:%.*]]*
+// CHECK-NF: define void @test0([[A:%.*]]*
+void test0(A *x) {
+ // CHECK: [[X:%.*]] = alloca [[A]]*
+ // CHECK-NEXT: [[POINT:%.*]] = alloca [[POINT_T:%.*]],
+ // CHECK: [[T0:%.*]] = load [[A]]** [[X]]
+ // CHECK: [[T1:%.*]] = bitcast [[A]]* [[T0]] to i8*
+ // CHECK-NEXT: icmp eq i8* [[T1]], null
+ // CHECK-NEXT: br i1
+ // CHECK: call {{.*}} @objc_msgSend_stret to
+ // CHECK-NEXT: br label
+ // CHECK: [[T0:%.*]] = bitcast [[POINT_T]]* [[POINT]] to i8*
+ // CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[T0]], i8 0, i64 48, i32 4, i1 false)
+ // CHECK-NEXT: br label
+
+ // CHECK-NF: [[X:%.*]] = alloca [[A]]*
+ // CHECK-NF-NEXT: [[POINT:%.*]] = alloca [[POINT_T:%.*]],
+ // CHECK-NF: [[T0:%.*]] = load [[A]]** [[X]]
+ // CHECK-NF: [[T1:%.*]] = bitcast [[A]]* [[T0]] to i8*
+ // CHECK-NF-NEXT: icmp eq i8* [[T1]], null
+ // CHECK-NF-NEXT: br i1
+ // CHECK-NF: call {{.*}} @objc_msgSend_stret to
+ // CHECK-NF-NEXT: br label
+ // CHECK-NF: [[T0:%.*]] = bitcast [[POINT_T]]* [[POINT]] to i8*
+ // CHECK-NF-NEXT: call void @llvm.memset.p0i8.i64(i8* [[T0]], i8 0, i64 48, i32 4, i1 false)
+ // CHECK-NF-NEXT: br label
+ MyPoint point = [x returnAPoint];
+}
diff --git a/clang/test/CodeGenObjC/messages.m b/clang/test/CodeGenObjC/messages.m
new file mode 100644
index 0000000..6f39602
--- /dev/null
+++ b/clang/test/CodeGenObjC/messages.m
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-MAC
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-MAC-NF
+// RUN: %clang_cc1 -fobjc-fragile-abi -fgnu-runtime -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-GNU
+// RUN: %clang_cc1 -fgnu-runtime -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-GNU-NF
+
+typedef struct {
+ int x;
+ int y;
+ int z[10];
+} MyPoint;
+
+void f0(id a) {
+ int i;
+ MyPoint pt = { 1, 2};
+
+ // CHECK-MAC: call {{.*}} @objc_msgSend to
+ // CHECK-MAC-NF: call {{.*}} @objc_msgSend to
+ // CHECK-GNU: call {{.*}} @objc_msg_lookup(
+ // CHECK-GNU-NF: call {{.*}} @objc_msg_lookup_sender(
+ [a print0];
+
+ // CHECK-MAC: call {{.*}} @objc_msgSend to
+ // CHECK-MAC-NF: call {{.*}} @objc_msgSend to
+ // CHECK-GNU: call {{.*}} @objc_msg_lookup(
+ // CHECK-GNU-NF: call {{.*}} @objc_msg_lookup_sender(
+ [a print1: 10];
+
+ // CHECK-MAC: call {{.*}} @objc_msgSend to
+ // CHECK-MAC-NF: call {{.*}} @objc_msgSend to
+ // CHECK-GNU: call {{.*}} @objc_msg_lookup(
+ // CHECK-GNU-NF: call {{.*}} @objc_msg_lookup_sender(
+ [a print2: 10 and: "hello" and: 2.2];
+
+ // CHECK-MAC: call {{.*}} @objc_msgSend to
+ // CHECK-MAC-NF: call {{.*}} @objc_msgSend to
+ // CHECK-GNU: call {{.*}} @objc_msg_lookup(
+ // CHECK-GNU-NF: call {{.*}} @objc_msg_lookup_sender(
+ [a takeStruct: pt ];
+
+ void *s = @selector(print0);
+ for (i=0; i<2; ++i)
+ // CHECK-MAC: call {{.*}} @objc_msgSend to
+ // CHECK-MAC-NF: call {{.*}} @objc_msgSend to
+ // CHECK-GNU: call {{.*}} @objc_msg_lookup(
+ // CHECK-GNU-NF: call {{.*}} @objc_msg_lookup_sender(
+ [a performSelector:s];
+}
diff --git a/clang/test/CodeGenObjC/metadata-symbols-32.m b/clang/test/CodeGenObjC/metadata-symbols-32.m
new file mode 100644
index 0000000..a7bcf01
--- /dev/null
+++ b/clang/test/CodeGenObjC/metadata-symbols-32.m
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s
+// RUNX: llvm-gcc -m32 -emit-llvm -S -o %t %s &&
+
+// RUN: grep '@"\\01L_OBJC_CATEGORY_A_Cat" = internal global .*section "__OBJC,__category,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_CATEGORY_CLASS_METHODS_A_Cat" = internal global .*section "__OBJC,__cat_cls_meth,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_CATEGORY_INSTANCE_METHODS_A_Cat" = internal global .*section "__OBJC,__cat_inst_meth,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_CLASSEXT_A" = internal global .*section "__OBJC,__class_ext,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_CLASS_A" = internal global .*section "__OBJC,__class,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_CLASS_METHODS_A" = internal global .*section "__OBJC,__cls_meth,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_CLASS_NAME_[0-9]*" = internal global .*section "__TEXT,__cstring,cstring_literals", align 1' %t
+// RUN: grep '@"\\01L_OBJC_CLASS_PROTOCOLS_A" = internal global .*section "__OBJC,__cat_cls_meth,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_CLASS_REFERENCES_[0-9]*" = internal global .*section "__OBJC,__cls_refs,literal_pointers,no_dead_strip", align 4' %t
+
+// Clang's Obj-C 32-bit doesn't emit ivars for the root class.
+// RUNX: grep '@"\\01L_OBJC_CLASS_VARIABLES_A" = internal global .*section "__OBJC,__class_vars,regular,no_dead_strip", align 4' %t &&
+
+// RUN: grep '@"\\01L_OBJC_INSTANCE_METHODS_A" = internal global .*section "__OBJC,__inst_meth,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_INSTANCE_VARIABLES_A" = internal global .*section "__OBJC,__instance_vars,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_METACLASS_A" = internal global .*section "__OBJC,__meta_class,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_METH_VAR_NAME_[0-9]*" = internal global .*section "__TEXT,__cstring,cstring_literals", align 1' %t
+// RUN: grep '@"\\01L_OBJC_METH_VAR_TYPE_[0-9]*" = internal global .*section "__TEXT,__cstring,cstring_literals", align 1' %t
+// RUN: grep '@"\\01L_OBJC_MODULES" = internal global .*section "__OBJC,__module_info,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_PROP_NAME_ATTR_[0-9]*" = internal global .*section "__TEXT,__cstring,cstring_literals", align 1' %t
+// RUN: grep '@"\\01L_OBJC_PROTOCOL_CLASS_METHODS_P" = internal global .*section "__OBJC,__cat_cls_meth,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_PROTOCOL_INSTANCE_METHODS_P" = internal global .*section "__OBJC,__cat_inst_meth,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_PROTOCOL_P" = internal global .*section "__OBJC,__protocol,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_SELECTOR_REFERENCES_[0-9]*" = internal global .*section "__OBJC,__message_refs,literal_pointers,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_SYMBOLS" = internal global .*section "__OBJC,__symbols,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01l_OBJC_$_PROP_LIST_A" = internal global .*section "__OBJC,__property,regular,no_dead_strip", align 4' %t
+// RUN: grep "\.lazy_reference \.objc_class_name_J0" %t
+
+
+/*
+
+Here is a handy command for looking at llvm-gcc's output:
+llvm-gcc -m32 -emit-llvm -S -o - metadata-symbols-32.m | \
+ grep '=.*global' | \
+ sed -e 's#global.*, section#global ... section#' | \
+ sort
+
+*/
+
+@interface B
+@end
+@interface C
+@end
+
+@protocol P
++(void) fm0;
+-(void) im0;
+@end
+
+@interface A<P> {
+ int _ivar;
+}
+
+@property (assign) int ivar;
+
++(void) fm0;
+-(void) im0;
+@end
+
+@implementation A
+@synthesize ivar = _ivar;
++(void) fm0 {
+}
+-(void) im0 {
+}
+@end
+
+@implementation A (Cat)
++(void) fm1 {
+}
+-(void) im1 {
+}
+@end
+
+@interface J0
+@end
+
+@implementation J0(Category) @end
+
+void *f0() {
+ [B im0];
+ [C im1];
+}
+
diff --git a/clang/test/CodeGenObjC/metadata-symbols-64.m b/clang/test/CodeGenObjC/metadata-symbols-64.m
new file mode 100644
index 0000000..57f5d50
--- /dev/null
+++ b/clang/test/CodeGenObjC/metadata-symbols-64.m
@@ -0,0 +1,129 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-dispatch-method=mixed -emit-llvm -o %t %s
+// RUNX: llvm-gcc -m64 -emit-llvm -S -o %t %s &&
+
+// RUN: grep '@"OBJC_CLASS_$_A" = global' %t
+// RUN: grep '@"OBJC_CLASS_$_B" = external global' %t
+// RUN: grep '@"OBJC_IVAR_$_A._ivar" = global .* section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_METACLASS_$_A" = global .* section "__DATA, __objc_data", align 8' %t
+// RUN: grep '@"\\01L_OBJC_CLASSLIST_REFERENCES_$_[0-9]*" = internal global .* section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8' %t
+// RUN: grep '@"\\01L_OBJC_CLASSLIST_SUP_REFS_$_[0-9]*" = internal global .* section "__DATA, __objc_superrefs, regular, no_dead_strip", align 8' %t | count 2
+// RUN: grep '@"\\01L_OBJC_CLASS_NAME_[0-9]*" = internal global .* section "__TEXT,__objc_classname,cstring_literals", align 1' %t
+// RUN: grep '@"\\01L_OBJC_LABEL_CATEGORY_$" = internal global .* section "__DATA, __objc_catlist, regular, no_dead_strip", align 8' %t
+// RUN: grep '@"\\01L_OBJC_LABEL_CLASS_$" = internal global .* section "__DATA, __objc_classlist, regular, no_dead_strip", align 8' %t
+// RUN: grep '@"\\01L_OBJC_METH_VAR_NAME_[0-9]*" = internal global .* section "__TEXT,__objc_methname,cstring_literals", align 1' %t
+// RUN: grep '@"\\01L_OBJC_METH_VAR_TYPE_[0-9]*" = internal global .* section "__TEXT,__objc_methtype,cstring_literals", align 1' %t
+// RUN: grep '@"\\01L_OBJC_PROP_NAME_ATTR_[0-9]*" = internal global .* section "__TEXT,__cstring,cstring_literals", align 1' %t
+// RUN: grep '@"\\01L_OBJC_SELECTOR_REFERENCES_*" = internal global .* section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"' %t
+// RUN: grep '@"\\01l_OBJC_$_CATEGORY_A_$_Cat" = internal global .* section "__DATA, __objc_const", align 8' %t
+// RUN: grep '@"\\01l_OBJC_$_CATEGORY_CLASS_METHODS_A_$_Cat" = internal global .* section "__DATA, __objc_const", align 8' %t
+// RUN: grep '@"\\01l_OBJC_$_CATEGORY_INSTANCE_METHODS_A_$_Cat" = internal global .* section "__DATA, __objc_const", align 8' %t
+// RUN: grep '@"\\01l_OBJC_$_CLASS_METHODS_A" = internal global .* section "__DATA, __objc_const", align 8' %t
+// RUN: grep '@"\\01l_OBJC_$_INSTANCE_METHODS_A" = internal global .* section "__DATA, __objc_const", align 8' %t
+// RUN: grep '@"\\01l_OBJC_$_INSTANCE_VARIABLES_A" = internal global .* section "__DATA, __objc_const", align 8' %t
+// RUN: grep '@"\\01l_OBJC_$_PROP_LIST_A" = internal global .* section "__DATA, __objc_const", align 8' %t
+// RUN: grep '@"\\01l_OBJC_$_PROTOCOL_CLASS_METHODS_P" = internal global .* section "__DATA, __objc_const", align 8' %t
+// RUN: grep '@"\\01l_OBJC_$_PROTOCOL_INSTANCE_METHODS_P" = internal global .* section "__DATA, __objc_const", align 8' %t
+// RUN: grep '@"\\01l_OBJC_CLASS_PROTOCOLS_$_A" = internal global .* section "__DATA, __objc_const", align 8' %t
+// RUN: grep '@"\\01l_OBJC_CLASS_RO_$_A" = internal global .* section "__DATA, __objc_const", align 8' %t
+// RUN: grep '@"\\01l_OBJC_LABEL_PROTOCOL_$_P" = weak hidden global .* section "__DATA, __objc_protolist, coalesced, no_dead_strip", align 8' %t
+// RUN: grep '@"\\01l_OBJC_METACLASS_RO_$_A" = internal global .* section "__DATA, __objc_const", align 8' %t
+// RUN: grep '@"\\01l_OBJC_PROTOCOL_$_P" = weak hidden global .* section "__DATA,__datacoal_nt,coalesced", align 8' %t
+// RUN: grep '@"\\01l_objc_msgSend_fixup_alloc" = weak hidden global .* section "__DATA, __objc_msgrefs, coalesced", align 16' %t
+// RUN: grep '@_objc_empty_cache = external global' %t
+// RUN: grep '@_objc_empty_vtable = external global' %t
+// RUN: grep '@objc_msgSend_fixup(' %t
+// RUN: grep '@objc_msgSend_fpret(' %t
+
+
+/*
+
+Here is a handy command for looking at llvm-gcc's output:
+llvm-gcc -m64 -emit-llvm -S -o - metadata-symbols-64.m | \
+ grep '=.*global' | \
+ sed -e 's#global.*, section#global ... section#' | \
+ sort
+
+*/
+
+@interface B
+@end
+@interface C
+@end
+
+@protocol P
++(void) fm0;
+-(void) im0;
+@end
+
+@interface A<P> {
+ int _ivar;
+}
+
+@property (assign) int ivar;
+
++(void) fm0;
+-(void) im0;
+@end
+
+@implementation A
+@synthesize ivar = _ivar;
++(void) fm0 {
+}
+-(void) im0 {
+}
+@end
+
+@implementation A (Cat)
++(void) fm1 {
+}
+-(void) im1 {
+}
+@end
+
+@interface D : A
+@end
+
+@implementation D
++(void) fm2 {
+ [super fm1];
+}
+-(void) im2 {
+ [super im1];
+}
+@end
+
+// Test for FP dispatch method APIs
+@interface Example
+@end
+
+float FLOAT;
+double DOUBLE;
+long double LONGDOUBLE;
+id ID;
+
+@implementation Example
+ - (double) RET_DOUBLE
+ {
+ return DOUBLE;
+ }
+ - (float) RET_FLOAT
+ {
+ return FLOAT;
+ }
+ - (long double) RET_LONGDOUBLE
+ {
+ return LONGDOUBLE;
+ }
+@end
+
+void *f0(id x) {
+ Example* pe;
+ double dd = [pe RET_DOUBLE];
+ dd = [pe RET_FLOAT];
+ dd = [pe RET_LONGDOUBLE];
+
+ [B im0];
+ [C im1];
+ [D alloc];
+}
+
diff --git a/clang/test/CodeGenObjC/metadata_symbols.m b/clang/test/CodeGenObjC/metadata_symbols.m
new file mode 100644
index 0000000..576a55b
--- /dev/null
+++ b/clang/test/CodeGenObjC/metadata_symbols.m
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fexceptions -fobjc-exceptions -o %t %s
+// RUN: FileCheck -check-prefix=CHECK-X86_64 < %t %s
+// RUN: grep '@"OBJC_EHTYPE_$_EH3"' %t | count 3
+
+// CHECK-X86_64: @"OBJC_CLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 8
+// CHECK-X86_64: @"OBJC_METACLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 8
+// CHECK-X86_64: @"\01L_OBJC_CLASS_NAME_" = {{.*}}, section "__TEXT,__objc_classname,cstring_literals", align 1
+// CHECK-X86_64: @"OBJC_EHTYPE_$_EH1" = weak global {{.*}}, section "__DATA,__datacoal_nt,coalesced", align 8
+// CHECK-X86_64: @"OBJC_EHTYPE_$_EH2" = external global
+// CHECK-X86_64: @"OBJC_EHTYPE_$_EH3" = global {{.*}}, section "__DATA,__objc_const", align 8
+// CHECK-X86_64: @"\01L_OBJC_LABEL_CLASS_$" = internal global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 8
+// CHECK-X86_64: define internal void @"\01-[A im0]"
+// CHECK-X86_64: define internal void @"\01-[A(Cat) im1]"
+
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-exceptions -fvisibility hidden -emit-llvm -o %t %s
+// RUN: FileCheck -check-prefix=CHECK-X86_64-HIDDEN < %t %s
+
+// CHECK-X86_64-HIDDEN: @"OBJC_CLASS_$_A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8
+// CHECK-X86_64-HIDDEN: @"OBJC_METACLASS_$_A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8
+// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_EH1" = weak hidden global {{.*}}, section "__DATA,__datacoal_nt,coalesced"
+// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_EH2" = external global
+// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_EH3" = hidden global {{.*}}, section "__DATA,__objc_const", align 8
+// CHECK-X86_64-HIDDEN: define internal void @"\01-[A im0]"
+// CHECK-X86_64-HIDDEN: define internal void @"\01-[A(Cat) im1]"
+
+// RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu -fobjc-exceptions -emit-llvm -o %t %s
+// RUN: FileCheck -check-prefix=CHECK-ARMV6 < %t %s
+
+// CHECK-ARMV6: @"OBJC_CLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 4
+// CHECK-ARMV6: @"OBJC_METACLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 4
+// CHECK-ARMV6: @"\01L_OBJC_CLASS_NAME_" = {{.*}}, section "__TEXT,__objc_classname,cstring_literals", align 1
+// CHECK-ARMV6: @"OBJC_EHTYPE_$_EH1" = weak global {{.*}}, section "__DATA,__datacoal_nt,coalesced", align 4
+// CHECK-ARMV6: @"OBJC_EHTYPE_$_EH2" = external global
+// CHECK-ARMV6: @"OBJC_EHTYPE_$_EH3" = global {{.*}}, section "__DATA,__objc_const", align 4
+// CHECK-ARMV6: @"\01L_OBJC_LABEL_CLASS_$" = internal global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 4
+// CHECK-ARMV6: define internal void @"\01-[A im0]"
+// CHECK-ARMV6: define internal void @"\01-[A(Cat) im1]"
+
+@interface A
+@end
+
+@implementation A
+-(void) im0 {
+}
+@end
+
+@implementation A (Cat)
+-(void) im1 {
+}
+@end
+
+@interface EH1
+@end
+
+__attribute__((__objc_exception__))
+@interface EH2
+@end
+
+__attribute__((__objc_exception__))
+@interface EH3
+@end
+
+void f1();
+
+void f0(id x) {
+ @try {
+ f1();
+ } @catch (EH1 *x) {
+ } @catch (EH2 *x) {
+ } @catch (EH3 *x) {
+ }
+}
+
+@implementation EH3
+@end
diff --git a/clang/test/CodeGenObjC/misc-atomic-property.m b/clang/test/CodeGenObjC/misc-atomic-property.m
new file mode 100644
index 0000000..f2645dc
--- /dev/null
+++ b/clang/test/CodeGenObjC/misc-atomic-property.m
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s
+// rdar: //8808439
+
+typedef struct {
+#ifdef __LP64__
+ unsigned char b[15];
+#else
+ unsigned char b[7];
+#endif
+} bools_minus_one;
+
+typedef struct {
+#ifdef __LP64__
+ unsigned char b[16];
+#else
+ unsigned char b[8];
+#endif
+} bools;
+
+
+@interface Foo
+{
+#ifndef __LP64__
+ bools x;
+ bools_minus_one y;
+#endif
+}
+@property(assign) bools bools_p;
+@property(assign) bools_minus_one bools_minus_one_p;
+@end
+
+@implementation Foo
+@synthesize bools_p=x;
+@synthesize bools_minus_one_p=y;
+@end
+
+#ifdef __LP64__
+typedef __int128_t dword;
+#else
+typedef long long int dword;
+#endif
+
+@interface Test_dwords
+{
+#ifndef __LP64__
+ dword dw;
+#endif
+}
+@property(assign) dword dword_p;
+@end
+
+@implementation Test_dwords
+@synthesize dword_p=dw;
+@end
+
+
+@interface Test_floats
+{
+ float fl;
+ double d;
+ long double ld;
+}
+@property(assign) float fl_p;
+@property(assign) double d_p;
+@property(assign) long double ld_p;
+@end
+
+@implementation Test_floats
+@synthesize fl_p = fl;
+@synthesize d_p = d;
+@synthesize ld_p = ld;
+@end
+
+// CHECK: call void @objc_copyStruct
+// CHECK: call void @objc_copyStruct
+// CHECK: call void @objc_copyStruct
+// CHECK: call void @objc_copyStruct
+// CHECK: call void @objc_copyStruct
+// CHECK: call void @objc_copyStruct
diff --git a/clang/test/CodeGenObjC/mrr-autorelease.m b/clang/test/CodeGenObjC/mrr-autorelease.m
new file mode 100644
index 0000000..f7a13fd
--- /dev/null
+++ b/clang/test/CodeGenObjC/mrr-autorelease.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s
+// rdar://8881826
+// rdar://9423507
+
+@interface I
+{
+ id ivar;
+}
+- (id) Meth;
+@end
+
+@implementation I
+- (id) Meth {
+ @autoreleasepool {
+ }
+ return 0;
+}
+@end
+
+// CHECK-NOT: call i8* @objc_getClass
+// CHECK: call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
diff --git a/clang/test/CodeGenObjC/nested-rethrow.m b/clang/test/CodeGenObjC/nested-rethrow.m
new file mode 100644
index 0000000..5576c16
--- /dev/null
+++ b/clang/test/CodeGenObjC/nested-rethrow.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fobjc-exceptions %s -o - | FileCheck %s
+
+
+extern int printf(const char*, ...);
+
+int main()
+{
+ @try {
+ @throw @"foo";
+ } @catch (id e) {
+ @try {
+// CHECK: call void @objc_exception_throw
+ @throw;
+ } @catch (id e) {
+ if (e) {
+ printf("caught \n");
+ } else {
+ printf("caught (WRONG)\n");
+ }
+ } @catch (...) {
+ printf("caught nothing (WRONG)\n");
+ }
+ }
+}
+
diff --git a/clang/test/CodeGenObjC/newproperty-nested-synthesis-1.m b/clang/test/CodeGenObjC/newproperty-nested-synthesis-1.m
new file mode 100644
index 0000000..4831c22
--- /dev/null
+++ b/clang/test/CodeGenObjC/newproperty-nested-synthesis-1.m
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@interface Object
+- (id) new;
+@end
+
+@interface Tester : Object
+@property char PropertyAtomic_char;
+@property short PropertyAtomic_short;
+@property int PropertyAtomic_int;
+@property long PropertyAtomic_long;
+@property long long PropertyAtomic_longlong;
+@property float PropertyAtomic_float;
+@property double PropertyAtomic_double;
+@property(assign) id PropertyAtomic_id;
+@property(retain) id PropertyAtomicRetained_id;
+@property(copy) id PropertyAtomicRetainedCopied_id;
+@property(retain) id PropertyAtomicRetainedGCOnly_id;
+@property(copy) id PropertyAtomicRetainedCopiedGCOnly_id;
+@end
+
+@implementation Tester
+@dynamic PropertyAtomic_char;
+@dynamic PropertyAtomic_short;
+@dynamic PropertyAtomic_int;
+@dynamic PropertyAtomic_long;
+@dynamic PropertyAtomic_longlong;
+@dynamic PropertyAtomic_float;
+@dynamic PropertyAtomic_double;
+@dynamic PropertyAtomic_id;
+@dynamic PropertyAtomicRetained_id;
+@dynamic PropertyAtomicRetainedCopied_id;
+@dynamic PropertyAtomicRetainedGCOnly_id;
+@dynamic PropertyAtomicRetainedCopiedGCOnly_id;
+@end
+
+@interface SubClass : Tester
+{
+ char PropertyAtomic_char;
+ short PropertyAtomic_short;
+ int PropertyAtomic_int;
+ long PropertyAtomic_long;
+ long long PropertyAtomic_longlong;
+ float PropertyAtomic_float;
+ double PropertyAtomic_double;
+ id PropertyAtomic_id;
+ id PropertyAtomicRetained_id;
+ id PropertyAtomicRetainedCopied_id;
+ id PropertyAtomicRetainedGCOnly_id;
+ id PropertyAtomicRetainedCopiedGCOnly_id;
+}
+@end
+
+@implementation SubClass
+@synthesize PropertyAtomic_char;
+@synthesize PropertyAtomic_short;
+@synthesize PropertyAtomic_int;
+@synthesize PropertyAtomic_long;
+@synthesize PropertyAtomic_longlong;
+@synthesize PropertyAtomic_float;
+@synthesize PropertyAtomic_double;
+@synthesize PropertyAtomic_id;
+@synthesize PropertyAtomicRetained_id;
+@synthesize PropertyAtomicRetainedCopied_id;
+@synthesize PropertyAtomicRetainedGCOnly_id;
+@synthesize PropertyAtomicRetainedCopiedGCOnly_id;
+@end
+
+int main()
+{
+ SubClass *f = [SubClass new];
+ f.PropertyAtomic_int = 1;
+
+ f.PropertyAtomic_int += 3;
+
+ f.PropertyAtomic_int -= 4;
+ return f.PropertyAtomic_int;
+}
diff --git a/clang/test/CodeGenObjC/next-objc-dispatch.m b/clang/test/CodeGenObjC/next-objc-dispatch.m
new file mode 100644
index 0000000..4288b2d
--- /dev/null
+++ b/clang/test/CodeGenObjC/next-objc-dispatch.m
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s \
+// RUN: -fobjc-dispatch-method=legacy | \
+// RUN: FileCheck -check-prefix CHECK-FRAGILE_LEGACY %s
+//
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-llvm -o - %s \
+// RUN: -fobjc-dispatch-method=legacy | \
+// RUN: FileCheck -check-prefix CHECK-NONFRAGILE_LEGACY %s
+//
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-llvm -o - %s \
+// RUN: -fobjc-dispatch-method=non-legacy | \
+// RUN: FileCheck -check-prefix CHECK-NONFRAGILE_NONLEGACY %s
+//
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-llvm -o - %s \
+// RUN: -fobjc-dispatch-method=mixed | \
+// RUN: FileCheck -check-prefix CHECK-NONFRAGILE_MIXED %s
+//
+// <rdar://problem/7866951>
+
+// There are basically four ways that we end up doing message dispatch for the
+// NeXT runtime. They are:
+// (1) fragile ABI, legacy dispatch
+// (2) non-fragile ABI, legacy dispatch
+// (2) non-fragile ABI, non-legacy dispatch
+// (2) non-fragile ABI, mixed dispatch
+//
+// Note that fragile ABI and non-fragile ABI legacy dispatch are not the same,
+// they use some different API calls (objc_msgSendSuper vs objc_msgSendSuper2).
+
+// CHECK-FRAGILE_LEGACY: ModuleID
+// CHECK-FRAGILE_LEGACY-NOT: declare i8* @objc_msgSendSuper2_fixup(
+// CHECK-FRAGILE_LEGACY-NOT: declare i8* @objc_msgSend_fixup(
+// CHECK-FRAGILE_LEGACY: declare i8* @objc_msgSendSuper(
+// CHECK-FRAGILE_LEGACY: declare i8* @objc_msgSend(
+
+// CHECK-NONFRAGILE_LEGACY: ModuleID
+// CHECK-NONFRAGILE_LEGACY-NOT: declare i8* @objc_msgSendSuper2_fixup(
+// CHECK-NONFRAGILE_LEGACY-NOT: declare i8* @objc_msgSend_fixup(
+// CHECK-NONFRAGILE_LEGACY: declare i8* @objc_msgSendSuper2(
+// CHECK-NONFRAGILE_LEGACY: declare i8* @objc_msgSend(
+
+// CHECK-NONFRAGILE_NONLEGACY: ModuleID
+// CHECK-NONFRAGILE_NONLEGACY: declare i8* @objc_msgSendSuper2_fixup(
+// CHECK-NONFRAGILE_NONLEGACY: declare i8* @objc_msgSend_fixup(
+
+// CHECK-NONFRAGILE_MIXED: declare i8* @objc_msgSendSuper2_fixup(
+// CHECK-NONFRAGILE_MIXED: declare i8* @objc_msgSendSuper2(
+// CHECK-NONFRAGILE_MIXED: declare i8* @objc_msgSend_fixup(
+// CHECK-NONFRAGILE_MIXED: declare i8* @objc_msgSend(
+
+@interface NSObject
++ (id)alloc;
+- (id)init;
+@end
+
+@interface I0 : NSObject
+-(void) im0;
+@end
+
+@implementation I0
++(id) alloc {
+ return [super alloc];
+}
+-(id) init {
+ [super init];
+ return self;
+}
+-(void) im0 {}
+@end
+
+void f0(I0 *a) {
+ [I0 alloc];
+ [a im0];
+}
diff --git a/clang/test/CodeGenObjC/no-category-class.m b/clang/test/CodeGenObjC/no-category-class.m
new file mode 100644
index 0000000..3969f91
--- /dev/null
+++ b/clang/test/CodeGenObjC/no-category-class.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-fragile-abi -emit-llvm -o %t %s
+
+@interface NSObject
+@end
+
+@implementation NSObject(IBXLIFFIntegration)
+@end
+
diff --git a/clang/test/CodeGenObjC/no-vararg-messaging.m b/clang/test/CodeGenObjC/no-vararg-messaging.m
new file mode 100644
index 0000000..3f9d934
--- /dev/null
+++ b/clang/test/CodeGenObjC/no-vararg-messaging.m
@@ -0,0 +1,19 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S -o - %s | FileCheck %s
+// rdar://9048030
+
+@interface Foo
++(id)alloc;
+-(id)init;
+-(id)self;
+-(id)retain;
+-(void)release;
+-(id)autorelease;
+@end
+
+void test(void)
+{
+ [[[[[[Foo alloc] init] retain] autorelease] self] release];
+}
+
+// CHECK-NOT: xorb
diff --git a/clang/test/CodeGenObjC/non-lazy-classes.m b/clang/test/CodeGenObjC/non-lazy-classes.m
new file mode 100644
index 0000000..5d82901
--- /dev/null
+++ b/clang/test/CodeGenObjC/non-lazy-classes.m
@@ -0,0 +1,32 @@
+// RUNX: llvm-gcc -m64 -emit-llvm -S -o %t %s &&
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s
+// RUN: grep '@".01L_OBJC_LABEL_NONLAZY_CLASS_$" = internal global \[1 x .*\] .*@"OBJC_CLASS_$_A".*, section "__DATA, __objc_nlclslist, regular, no_dead_strip", align 8' %t
+// RUN: grep '@".01L_OBJC_LABEL_NONLAZY_CATEGORY_$" = internal global \[1 x .*\] .*@".01l_OBJC_$_CATEGORY_A_$_Cat".*, section "__DATA, __objc_nlcatlist, regular, no_dead_strip", align 8' %t
+
+@interface A @end
+@implementation A
++(void) load {
+}
+@end
+
+@interface A (Cat) @end
+@implementation A (Cat)
++(void) load {
+}
+@end
+
+@interface B @end
+@implementation B
+-(void) load {
+}
+@end
+
+@interface B (Cat) @end
+@implementation B (Cat)
+-(void) load {
+}
+@end
+
+@interface C : A @end
+@implementation C
+@end
diff --git a/clang/test/CodeGenObjC/nonlazy-msgSend.m b/clang/test/CodeGenObjC/nonlazy-msgSend.m
new file mode 100644
index 0000000..73157c7
--- /dev/null
+++ b/clang/test/CodeGenObjC/nonlazy-msgSend.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s
+// RUN: grep -F 'declare i8* @objc_msgSend(i8*, i8*, ...) nonlazybind' %t
+
+void f0(id x) {
+ [x foo];
+}
diff --git a/clang/test/CodeGenObjC/ns-constant-strings.m b/clang/test/CodeGenObjC/ns-constant-strings.m
new file mode 100644
index 0000000..d04793c
--- /dev/null
+++ b/clang/test/CodeGenObjC/ns-constant-strings.m
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fno-constant-cfstrings -emit-llvm -o %t %s
+// RUN: FileCheck --check-prefix CHECK-FRAGILE < %t %s
+
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fno-constant-cfstrings -emit-llvm -o %t %s
+// RUN: FileCheck --check-prefix CHECK-NONFRAGILE < %t %s
+
+@interface NSString @end
+
+@interface NSSimpleCString : NSString {
+@protected
+ char *bytes;
+ unsigned int numBytes;
+}
+@end
+
+@interface NSConstantString : NSSimpleCString
+@end
+
+#if OBJC_API_VERSION >= 2
+extern Class _NSConstantStringClassReference;
+#else
+extern struct objc_class _NSConstantStringClassReference;
+#endif
+
+const NSConstantString *appKey = @"MyApp";
+
+int main() {
+ const NSConstantString *appKey = @"MyApp";
+ const NSConstantString *appKey1 = @"MyApp1";
+}
+
+// CHECK-FRAGILE: @_NSConstantStringClassReference = external global
+// CHECK-NONFRAGILE: @"OBJC_CLASS_$_NSConstantString" = external global
+
+// CHECK-FRAGILE: @.str = private unnamed_addr constant [6 x i8] c"MyApp\00"
+// CHECK-FRAGILE: @.str1 = private unnamed_addr constant [7 x i8] c"MyApp1\00"
+
+// CHECK-NONFRAGILE: @.str = private unnamed_addr constant [6 x i8] c"MyApp\00"
+// CHECK-NONFRAGILE: @.str1 = private unnamed_addr constant [7 x i8] c"MyApp1\00"
diff --git a/clang/test/CodeGenObjC/ns_consume_null_check.m b/clang/test/CodeGenObjC/ns_consume_null_check.m
new file mode 100644
index 0000000..e3b6075
--- /dev/null
+++ b/clang/test/CodeGenObjC/ns_consume_null_check.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-dispatch-method=mixed -o - %s | FileCheck %s
+// rdar://10444476
+
+@interface NSObject
+- (id) new;
+@end
+
+@interface MyObject : NSObject
+- (char)isEqual:(id) __attribute__((ns_consumed)) object;
+@end
+
+MyObject *x;
+
+void foo()
+{
+ id obj = [NSObject new];
+ [x isEqual : obj];
+}
+
+// CHECK: [[TMP:%.*]] = alloca i8
+// CHECK: [[FIVE:%.*]] = call i8* @objc_retain
+// CHECK-NEXT: [[SIX:%.*]] = bitcast
+// CHECK-NEXT: [[SEVEN:%.*]] = icmp eq i8* [[SIX]], null
+// CHECK-NEXT: br i1 [[SEVEN]], label [[NULLINIT:%.*]], label [[CALL_LABEL:%.*]]
+// CHECK: [[FN:%.*]] = load i8** getelementptr inbounds
+// CHECK-NEXT: [[EIGHT:%.*]] = bitcast i8* [[FN]]
+// CHECK-NEXT: [[CALL:%.*]] = call signext i8 [[EIGHT]]
+// CHECK-NEXT store i8 [[CALL]], i8* [[TMP]]
+// CHECK-NEXT br label [[CONT:%.*]]
+// CHECK: call void @objc_release(i8* [[FIVE]]) nounwind
+// CHECK-NEXT: call void @llvm.memset
+// CHECK-NEXT br label [[CONT]]
diff --git a/clang/test/CodeGenObjC/objc-align.m b/clang/test/CodeGenObjC/objc-align.m
new file mode 100644
index 0000000..f3c586e
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc-align.m
@@ -0,0 +1,44 @@
+// 32-bit
+
+// RUNX: llvm-gcc -m32 -emit-llvm -S -o %t %s &&
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s
+// RUN: grep '@"\\01L_OBJC_CATEGORY_A_Cat" = internal global .*, section "__OBJC,__category,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_CLASS_A" = internal global .*, section "__OBJC,__class,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_CLASS_C" = internal global .*, section "__OBJC,__class,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_CLASS_PROTOCOLS_C" = internal global .*, section "__OBJC,__cat_cls_meth,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_METACLASS_A" = internal global .*, section "__OBJC,__meta_class,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_METACLASS_C" = internal global .*, section "__OBJC,__meta_class,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_MODULES" = internal global .*, section "__OBJC,__module_info,regular,no_dead_strip", align 4' %t
+// RUN: grep '@"\\01L_OBJC_PROTOCOL_P" = internal global .*, section "__OBJC,__protocol,regular,no_dead_strip", align 4' %t
+
+// 64-bit
+
+// RUNX: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -o %t %s &&
+// RUNX: grep '@"OBJC_CLASS_$_A" = global' %t &&
+// RUNX: grep '@"OBJC_CLASS_$_C" = global' %t &&
+// RUNX: grep '@"OBJC_METACLASS_$_A" = global' %t &&
+// RUNX: grep '@"OBJC_METACLASS_$_C" = global' %t &&
+// RUNX: grep '@"\\01L_OBJC_CLASSLIST_REFERENCES_$_0" = internal global .*, section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8' %t &&
+// RUNX: grep '@"\\01L_OBJC_LABEL_CATEGORY_$" = internal global .*, section "__DATA, __objc_catlist, regular, no_dead_strip", align 8' %t &&
+// RUNX: grep '@"\\01L_OBJC_LABEL_CLASS_$" = internal global .*, section "__DATA, __objc_classlist, regular, no_dead_strip", align 8' %t &&
+// RUNX: grep '@"\\01l_OBJC_$_CATEGORY_A_$_Cat" = internal global .*, section "__DATA, __objc_const", align 8' %t &&
+// RUNX: grep '@"\\01l_OBJC_CLASS_PROTOCOLS_$_C" = internal global .*, section "__DATA, __objc_const", align 8' %t &&
+// RUNX: grep '@"\\01l_OBJC_CLASS_RO_$_A" = internal global .*, section "__DATA, __objc_const", align 8' %t &&
+// RUNX: grep '@"\\01l_OBJC_CLASS_RO_$_C" = internal global .*, section "__DATA, __objc_const", align 8' %t &&
+// RUNX: grep '@"\\01l_OBJC_LABEL_PROTOCOL_$_P" = weak hidden global .*, section "__DATA, __objc_protolist, coalesced, no_dead_strip", align 8' %t &&
+// RUNX: grep '@"\\01l_OBJC_METACLASS_RO_$_A" = internal global .*, section "__DATA, __objc_const", align 8' %t &&
+// RUNX: grep '@"\\01l_OBJC_METACLASS_RO_$_C" = internal global .*, section "__DATA, __objc_const", align 8' %t &&
+// RUNX: grep '@"\\01l_OBJC_PROTOCOL_$_P" = weak hidden global .*, section "__DATA,__datacoal_nt,coalesced", align 8' %t &&
+
+
+@interface A @end
+@implementation A
+@end
+@implementation A (Cat)
+@end
+@protocol P
+@end
+@interface C <P>
+@end
+@implementation C
+@end
diff --git a/clang/test/CodeGenObjC/objc-arc-container-subscripting.m b/clang/test/CodeGenObjC/objc-arc-container-subscripting.m
new file mode 100644
index 0000000..8924916
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc-arc-container-subscripting.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fobjc-arc -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(int)index;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+id func() {
+ NSMutableArray *array;
+ array[3] = 0;
+ return array[3];
+}
+
+// CHECK: [[call:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: [[SIX:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[call]]) nounwind
+// CHECK: [[ARRAY:%.*]] = load %0**
+// CHECK: [[ARRAY_CASTED:%.*]] = bitcast{{.*}}[[ARRAY]] to i8*
+// CHECK: call void @objc_release(i8* [[ARRAY_CASTED]])
+// CHECK: [[EIGHT:%.*]] = call i8* @objc_autoreleaseReturnValue(i8* [[SIX]]) nounwind
+// CHECK: ret i8* [[EIGHT]]
+
diff --git a/clang/test/CodeGenObjC/objc-assign-ivar.m b/clang/test/CodeGenObjC/objc-assign-ivar.m
new file mode 100644
index 0000000..d0a1a0f
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc-assign-ivar.m
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep -F '@objc_assign_ivar' %t | count 14
+
+typedef struct {
+ id element;
+ id elementArray[10];
+ __strong id cfElement;
+ __strong id cfElementArray[10];
+} struct_with_ids_t;
+
+
+@interface NSString @end
+
+@interface Foo {
+@public
+// assignments to any/all of these fields should generate objc_assign_ivar
+ __strong id dict;
+ __strong id dictArray[3];
+ id ivar;
+ id array[10];
+ id nsobject;
+ NSString *stringArray[10];
+ struct_with_ids_t inner;
+
+ Foo *obj[20];
+ short idx[5];
+}
+@end
+
+// The test cases
+int IvarAssigns;
+void *rhs = 0;
+#define ASSIGNTEST(expr, global) expr = rhs
+
+void testIvars() {
+ Foo *foo;
+ ASSIGNTEST(foo->ivar, IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->dict, IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->dictArray[0], IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->array[0], IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->nsobject, IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->stringArray[0], IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->inner.element, IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->inner.elementArray[0], IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->inner.cfElement, IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->inner.cfElementArray[0], IvarAssigns); // objc_assign_ivar
+ int counter=1;
+ ASSIGNTEST(foo->obj[5], IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->obj[++counter], IvarAssigns); // objc_assign_ivar
+ foo->idx[++counter] = 15;
+ ASSIGNTEST(foo->obj[foo->idx[2]], IvarAssigns); // objc_assign_ivar
+}
diff --git a/clang/test/CodeGenObjC/objc-container-subscripting-1.m b/clang/test/CodeGenObjC/objc-container-subscripting-1.m
new file mode 100644
index 0000000..91b7f46
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc-container-subscripting-1.m
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s
+
+typedef unsigned int size_t;
+@protocol P @end
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+@end
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id)key;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+int main() {
+ NSMutableArray *array;
+ id val;
+
+ id oldObject = array[10];
+// CHECK: [[ARR:%.*]] = load {{%.*}} [[array:%.*]], align 8
+// CHECK-NEXT: [[SEL:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_"
+// CHECK-NEXT: [[ARRC:%.*]] = bitcast {{%.*}} [[ARR]] to i8*
+// CHECK-NEXT: [[CALL:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i32)*)(i8* [[ARRC]], i8* [[SEL]], i32 10)
+// CHECK-NEXT: store i8* [[CALL]], i8** [[OLDOBJ:%.*]], align 8
+
+ val = (array[10] = oldObject);
+// CHECK: [[THREE:%.*]] = load {{%.*}} [[array:%.*]], align 8
+// CHECK-NEXT: [[FOUR:%.*]] = load i8** [[oldObject:%.*]], align 8
+// CHECK-NEXT: [[FIVE:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_2"
+// CHECK-NEXT: [[SIX:%.*]] = bitcast {{%.*}} [[THREE]] to i8*
+// CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*, i32)*)(i8* [[SIX]], i8* [[FIVE]], i8* [[FOUR]], i32 10)
+// CHECK-NEXT: store i8* [[FOUR]], i8** [[val:%.*]]
+
+ NSMutableDictionary *dictionary;
+ id key;
+ id newObject;
+ oldObject = dictionary[key];
+// CHECK: [[SEVEN:%.*]] = load {{%.*}} [[DICTIONARY:%.*]], align 8
+// CHECK-NEXT: [[EIGHT:%.*]] = load i8** [[KEY:%.*]], align 8
+// CHECK-NEXT: [[TEN:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_4"
+// CHECK-NEXT: [[ELEVEN:%.*]] = bitcast {{%.*}} [[SEVEN]] to i8*
+// CHECK-NEXT: [[CALL1:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8*)*)(i8* [[ELEVEN]], i8* [[TEN]], i8* [[EIGHT]])
+// CHECK-NEXT: store i8* [[CALL1]], i8** [[oldObject:%.*]], align 8
+
+
+ val = (dictionary[key] = newObject);
+// CHECK: [[TWELVE:%.*]] = load {{%.*}} [[DICTIONARY]], align 8
+// CHECK-NEXT: [[THIRTEEN:%.*]] = load i8** [[KEY]], align 8
+// CHECK-NEXT: [[FOURTEEN:%.*]] = load i8** [[NEWOBJECT:%.*]], align 8
+// CHECK-NEXT: [[SIXTEEN:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_6"
+// CHECK-NEXT: [[SEVENTEEN:%.*]] = bitcast {{%.*}} [[TWELVE]] to i8*
+// CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*, i8*)*)(i8* [[SEVENTEEN]], i8* [[SIXTEEN]], i8* [[FOURTEEN]], i8* [[THIRTEEN]])
+// CHECK-NEXT: store i8* [[FOURTEEN]], i8** [[val:%.*]]
+}
+
diff --git a/clang/test/CodeGenObjC/objc-container-subscripting.m b/clang/test/CodeGenObjC/objc-container-subscripting.m
new file mode 100644
index 0000000..fd8f8ef
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc-container-subscripting.m
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin %s -o /dev/null
+
+typedef unsigned int size_t;
+@protocol P @end
+
+@interface NSMutableArray
+#if __has_feature(objc_subscripting)
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+#endif
+@end
+
+#if __has_feature(objc_subscripting)
+@interface XNSMutableArray
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+#endif
+@end
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id)key;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@class NSString;
+
+int main() {
+ NSMutableArray<P> * array;
+ id oldObject = array[10];
+
+ array[10] = oldObject;
+
+ id unknown_array;
+ oldObject = unknown_array[1];
+
+ unknown_array[1] = oldObject;
+
+ NSMutableDictionary *dictionary;
+ NSString *key;
+ id newObject;
+ oldObject = dictionary[key];
+ dictionary[key] = newObject; // replace oldObject with newObject
+
+}
+
diff --git a/clang/test/CodeGenObjC/objc-dictionary-literal.m b/clang/test/CodeGenObjC/objc-dictionary-literal.m
new file mode 100644
index 0000000..b335582
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc-dictionary-literal.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin10 -fblocks -emit-llvm %s -o /dev/null
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fblocks -emit-llvm %s -o /dev/null
+// rdar://10614657
+
+@interface NSNumber
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+@protocol NSCopying @end
+typedef unsigned long NSUInteger;
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
+@end
+
+@interface NSString<NSCopying>
+@end
+
+int main() {
+ NSDictionary *dict = @{ @"name":@666 };
+ NSDictionary *dict1 = @{ @"name":@666 };
+ NSDictionary *dict2 = @{ @"name":@666 };
+ return 0;
+}
diff --git a/clang/test/CodeGenObjC/objc-gc-aggr-assign.m b/clang/test/CodeGenObjC/objc-gc-aggr-assign.m
new file mode 100644
index 0000000..dfdf02e
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc-gc-aggr-assign.m
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix C %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix CP %s
+
+static int count;
+
+typedef struct S {
+ int ii;
+} SS;
+
+struct type_s {
+ SS may_recurse;
+ id id_val;
+};
+
+@interface NamedObject
+{
+ struct type_s type_s_ivar;
+}
+- (void) setSome : (struct type_s) arg;
+- (struct type_s) getSome;
+@property(assign) struct type_s aggre_prop;
+@end
+
+@implementation NamedObject
+- (void) setSome : (struct type_s) arg
+ {
+ type_s_ivar = arg;
+ }
+- (struct type_s) getSome
+ {
+ return type_s_ivar;
+ }
+@synthesize aggre_prop = type_s_ivar;
+@end
+
+struct type_s some = {{1234}, (id)0};
+
+struct type_s get(void)
+{
+ return some;
+}
+
+void f(const struct type_s *in, struct type_s *out) {
+ *out = *in;
+}
+
+#ifdef __cplusplus
+struct Derived : type_s { };
+
+void foo(Derived* src, Derived* dest) {
+ *dest = *src;
+}
+#endif
+
+// CHECK-C: call i8* @objc_memmove_collectable
+// CHECK-C: call i8* @objc_memmove_collectable
+// CHECK-C: call i8* @objc_memmove_collectable
+
+// CHECK-CP: call i8* @objc_memmove_collectable
+// CHECK-CP: call i8* @objc_memmove_collectable
+// CHECK-CP: call i8* @objc_memmove_collectable
+// CHECK-CP: call i8* @objc_memmove_collectable
diff --git a/clang/test/CodeGenObjC/objc-literal-debugger-test.m b/clang/test/CodeGenObjC/objc-literal-debugger-test.m
new file mode 100644
index 0000000..389ef22
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc-literal-debugger-test.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdebugger-objc-literal -emit-llvm -o - %s | FileCheck %s
+
+int main() {
+ id l = @'a';
+ l = @'a';
+ l = @42;
+ l = @-42;
+ l = @42u;
+ l = @3.141592654f;
+ l = @__objc_yes;
+ l = @__objc_no;
+ l = @{ @"name":@666 };
+ l = @[ @"foo", @"bar" ];
+}
+
+// CHECK: declare i8* @objc_msgSend(i8*, i8*, ...) nonlazybind
diff --git a/clang/test/CodeGenObjC/objc-literal-tests.m b/clang/test/CodeGenObjC/objc-literal-tests.m
new file mode 100644
index 0000000..c513d49
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc-literal-tests.m
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin10 -fblocks -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fblocks -emit-llvm %s -o - | FileCheck %s
+// rdar://10111397
+
+#if __has_feature(objc_bool)
+#define YES __objc_yes
+#define NO __objc_no
+#else
+#define YES ((BOOL)1)
+#define NO ((BOOL)0)
+#endif
+
+#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
+typedef unsigned long NSUInteger;
+typedef long NSInteger;
+#else
+typedef unsigned int NSUInteger;
+typedef int NSInteger;
+#endif
+typedef signed char BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
+#if __has_feature(objc_array_literals)
++ (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 ;
+#endif
+@end
+
+@interface NSDate
++ (NSDate *) date;
+@end
+
+#if __has_feature(objc_dictionary_literals)
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(NSUInteger)cnt;
+@end
+#endif
+
+id NSUserName();
+
+// CHECK: define i32 @main() nounwind
+int main() {
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i8 signext 97
+ NSNumber *aNumber = @'a';
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i32 42
+ NSNumber *fortyTwo = @42;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i32 -42
+ NSNumber *negativeFortyTwo = @-42;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i32 42
+ NSNumber *positiveFortyTwo = @+42;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i32 42
+ NSNumber *fortyTwoUnsigned = @42u;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i64 42
+ NSNumber *fortyTwoLong = @42l;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i64 42
+ NSNumber *fortyTwoLongLong = @42ll;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}float 0x400921FB60000000
+ NSNumber *piFloat = @3.141592654f;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}double 0x400921FB54411744
+ NSNumber *piDouble = @3.1415926535;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i8 signext 1
+ NSNumber *yesNumber = @__objc_yes;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i8 signext 0
+ NSNumber *noNumber = @__objc_no;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i8 signext 1
+ NSNumber *yesNumber1 = @YES;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i8 signext 0
+ NSNumber *noNumber1 = @NO;
+NSDictionary *dictionary = @{@"name" : NSUserName(),
+ @"date" : [NSDate date] };
+ return __objc_yes == __objc_no;
+}
+
+// rdar://10579122
+typedef BOOL (^foo)(void);
+extern void bar(foo a);
+
+void baz(void) {
+ bar(^(void) { return YES; });
+}
diff --git a/clang/test/CodeGenObjC/objc-read-weak-byref.m b/clang/test/CodeGenObjC/objc-read-weak-byref.m
new file mode 100644
index 0000000..8fe1436
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc-read-weak-byref.m
@@ -0,0 +1,26 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -fblocks -fobjc-gc -triple i386-apple-darwin -fobjc-fragile-abi -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+@interface NSObject
+- copy;
+@end
+
+int main() {
+ NSObject *object = 0;
+ __weak __block NSObject* weak_object = object;
+ void (^callback) (void) = [^{
+ if (weak_object)
+ [weak_object copy];
+ } copy];
+ callback();
+ return 0;
+}
+
+// CHECK-LP64: callq _objc_read_weak
+// CHECK-LP64: callq _objc_read_weak
+
+// CHECK-LP32: calll L_objc_read_weak
+// CHECK-LP32: calll L_objc_read_weak
diff --git a/clang/test/CodeGenObjC/objc2-assign-global.m b/clang/test/CodeGenObjC/objc2-assign-global.m
new file mode 100644
index 0000000..36c95f7
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-assign-global.m
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep -F '@objc_assign_global' %t | count 26
+
+@class NSObject;
+typedef const struct __CFDictionary * CFDictionaryRef;
+typedef struct {
+ id element;
+ id elementArray[10];
+ __strong CFDictionaryRef cfElement;
+ __strong CFDictionaryRef cfElementArray[10];
+} struct_with_ids_t;
+
+
+// assignments to these should generate objc_assign_global
+@interface A
+@end
+
+typedef struct s0 {
+ A *a[4];
+} T;
+
+T g0;
+
+extern id FileExternID;
+static id FileStaticID;
+id GlobalId;
+id GlobalArray[20];
+NSObject *GlobalObject;
+NSObject *GlobalObjectArray[20];
+__strong CFDictionaryRef Gdict;
+__strong CFDictionaryRef Gdictarray[10];
+struct_with_ids_t GlobalStruct;
+struct_with_ids_t GlobalStructArray[10];
+
+#define ASSIGNTEST(expr, global) expr = rhs
+void *rhs = 0;
+
+int main() {
+ static id staticGlobalId;
+ static id staticGlobalArray[20];
+ static NSObject *staticGlobalObject;
+ static NSObject *staticGlobalObjectArray[20];
+ static __strong CFDictionaryRef staticGdict;
+ static __strong CFDictionaryRef staticGdictarray[10];
+ static struct_with_ids_t staticGlobalStruct;
+ static struct_with_ids_t staticGlobalStructArray[10];
+ extern id ExID;
+ id localID;
+
+ ASSIGNTEST(GlobalId, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(GlobalArray[0], GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(GlobalObject, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(GlobalObjectArray[0], GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(Gdict, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(Gdictarray[1], GlobalAssigns); // objc_assign_global
+
+ ASSIGNTEST(GlobalStruct.element, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(GlobalStruct.elementArray[0], GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(GlobalStruct.cfElement, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(GlobalStruct.cfElementArray[0], GlobalAssigns); // objc_assign_global
+
+ ASSIGNTEST(staticGlobalId, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGlobalArray[0], GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGlobalObject, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGlobalObjectArray[0], GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGdict, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGdictarray[1], GlobalAssigns); // objc_assign_global
+
+ ASSIGNTEST(staticGlobalStruct.element, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGlobalStruct.elementArray[0], GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGlobalStruct.cfElement, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGlobalStruct.cfElementArray[0], GlobalAssigns); // objc_assign_global
+
+ ExID = 0;
+ localID = 0;
+ FileStaticID = 0;
+ FileExternID=0;
+ g0.a[0] = 0;
+ ((T*) &g0)->a[0] = 0;
+}
diff --git a/clang/test/CodeGenObjC/objc2-ivar-assign.m b/clang/test/CodeGenObjC/objc2-ivar-assign.m
new file mode 100644
index 0000000..af76800
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-ivar-assign.m
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep objc_assign_ivar %t | count 6
+
+@interface I @end
+
+typedef I TI;
+typedef I* TPI;
+
+typedef id ID;
+
+@interface MyClass {
+}
+
+@property id property;
+@property I* propertyI;
+
+@property TI* propertyTI;
+
+@property TPI propertyTPI;
+
+@property ID propertyID;
+@end
+
+@implementation MyClass
+ @synthesize property=_property;
+ @synthesize propertyI;
+ @synthesize propertyTI=_propertyTI;
+ @synthesize propertyTPI=_propertyTPI;
+ @synthesize propertyID = _propertyID;
+@end
+
+int main () {
+ MyClass *myObj;
+ myObj.property = 0;
+ myObj.propertyI = 0;
+ myObj.propertyTI = 0;
+ myObj.propertyTPI = 0;
+ myObj.propertyID = 0;
+ return 0;
+}
diff --git a/clang/test/CodeGenObjC/objc2-legacy-dispatch.m b/clang/test/CodeGenObjC/objc2-legacy-dispatch.m
new file mode 100644
index 0000000..a6b2000
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-legacy-dispatch.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fobjc-dispatch-method=mixed -triple i386-apple-darwin10 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK_NEW_DISPATCH %s
+//
+// CHECK_NEW_DISPATCH: define void @f0
+// CHECK_NEW_DISPATCH: bitcast {{.*}}objc_msgSend_fixup_alloc
+// CHECK_NEW_DISPATCH: define void @f1
+// CHECK_NEW_DISPATCH: load {{.*}}OBJC_SELECTOR_REFERENCES
+//
+// RUN: %clang_cc1 -fobjc-dispatch-method=legacy -emit-llvm -o - %s | FileCheck -check-prefix=CHECK_OLD_DISPATCH %s
+//
+// CHECK_OLD_DISPATCH: define void @f0
+// CHECK_OLD_DISPATCH: load {{.*}}OBJC_SELECTOR_REFERENCES
+// CHECK_OLD_DISPATCH: define void @f1
+// CHECK_OLD_DISPATCH: load {{.*}}OBJC_SELECTOR_REFERENCES
+
+@interface A
++(id) alloc;
+-(int) im0;
+@end
+
+void f0(void) {
+ [A alloc];
+}
+
+void f1(A *a) {
+ [a im0];
+}
diff --git a/clang/test/CodeGenObjC/objc2-new-gc-api-strongcast.m b/clang/test/CodeGenObjC/objc2-new-gc-api-strongcast.m
new file mode 100644
index 0000000..1044ba5
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-new-gc-api-strongcast.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fblocks -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep -F '@objc_assign_strongCast' %t | count 4
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fblocks -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep -F '@objc_assign_strongCast' %t | count 4
+
+@interface DSATextSearch @end
+
+DSATextSearch **_uniqueIdToIdentifierArray = (0);
+void foo (int _nextId)
+{
+ _uniqueIdToIdentifierArray[_nextId] = 0; // objc_assign_strongCast
+}
+
+typedef struct {
+ unsigned long state;
+ id *itemsPtr;
+ void (^bp)();
+ unsigned long *mutationsPtr;
+ unsigned long extra[5];
+} NSFastEnumerationState;
+
+void foo1 (NSFastEnumerationState * state)
+{
+ state->itemsPtr = 0;
+ state->bp = ^{};
+}
+
diff --git a/clang/test/CodeGenObjC/objc2-no-strong-cast.m b/clang/test/CodeGenObjC/objc2-no-strong-cast.m
new file mode 100644
index 0000000..0824f40
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-no-strong-cast.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@interface PDFViewPrivateVars
+{
+@public
+ __attribute__((objc_gc(strong))) char *addedTooltips;
+}
+@end
+
+@interface PDFView
+{
+ PDFViewPrivateVars *_pdfPriv;
+}
+@end
+
+@implementation PDFView
+- (void) addTooltipsForPage
+{
+ _pdfPriv->addedTooltips[4] = 1;
+}
+@end
+
diff --git a/clang/test/CodeGenObjC/objc2-no-write-barrier.m b/clang/test/CodeGenObjC/objc2-no-write-barrier.m
new file mode 100644
index 0000000..d439368
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-no-write-barrier.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep 'objc_assign' %t | count 0
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep 'objc_assign' %t | count 0
+
+typedef struct {
+ int ival;
+ id submenu;
+} XCBinderContextMenuItem;
+
+id actionMenuForDataNode(void) {
+ XCBinderContextMenuItem menusToCreate[] = {
+ {1, 0}
+ };
+ return 0;
+}
+
+XCBinderContextMenuItem GmenusToCreate[] = {
+ {1, 0}
+};
diff --git a/clang/test/CodeGenObjC/objc2-nonfragile-abi-impl.m b/clang/test/CodeGenObjC/objc2-nonfragile-abi-impl.m
new file mode 100644
index 0000000..c785a5d
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-nonfragile-abi-impl.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s
+// rdar://7547942.
+
+@interface Base @end
+
+@interface Sub1 : Base @end
+
+@implementation Sub1 @end
+
+@implementation Base {
+@private
+ id ivar;
+}
+@end
+
diff --git a/clang/test/CodeGenObjC/objc2-property-encode.m b/clang/test/CodeGenObjC/objc2-property-encode.m
new file mode 100644
index 0000000..0f18d6f
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-property-encode.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm -o %t %s
+// RUN: grep -e "T@\\\\22NSString\\\\22" %t
+@interface NSString @end
+
+typedef NSString StoreVersionID ;
+
+@interface Parent
+ @property(retain) StoreVersionID* foo;
+@end
+
+@implementation Parent
+@dynamic foo;
+@end
diff --git a/clang/test/CodeGenObjC/objc2-protocol-enc.m b/clang/test/CodeGenObjC/objc2-protocol-enc.m
new file mode 100644
index 0000000..0db0cb8
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-protocol-enc.m
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm -o %t %s
+// RUN: grep -e "T@\\\22<X>\\\22" %t
+// RUN: grep -e "T@\\\22<X><Y>\\\22" %t
+// RUN: grep -e "T@\\\22<X><Y><Z>\\\22" %t
+// RUN: grep -e "T@\\\22Foo<X><Y><Z>\\\22" %t
+
+@protocol X, Y, Z;
+@class Foo;
+
+@protocol Proto
+@property (copy) id <X> x;
+@property (copy) id <X, Y> xy;
+@property (copy) id <X, Y, Z> xyz;
+@property(copy) Foo <X, Y, Z> *fooxyz;
+@end
+
+@interface Intf <Proto>
+{
+id <X> IVAR_x;
+id <X, Y> IVAR_xy;
+id <X, Y, Z> IVAR_xyz;
+Foo <X, Y, Z> *IVAR_Fooxyz;
+}
+@end
+
+@implementation Intf
+@dynamic x, xy, xyz, fooxyz;
+@end
+
+/**
+This protocol should generate the following metadata:
+struct objc_property_list __Protocol_Test_metadata = {
+ sizeof(struct objc_property), 4,
+ {
+ { "x", "T@\"<X>\"" },
+ { "xy", "T@\"<X><Y>\"" },
+ { "xyz", "T@\"<X><Y><Z>\"" },
+ { "fooxyz", "T@\"Foo<X><Y><Z>\"" }
+ }
+};
+
+"T@\"<X><Y><Z>\",D
+*/
diff --git a/clang/test/CodeGenObjC/objc2-retain-codegen.m b/clang/test/CodeGenObjC/objc2-retain-codegen.m
new file mode 100644
index 0000000..d5b473e
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-retain-codegen.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-fragile-abi -fobjc-gc-only -emit-llvm -o %t %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-unknown-unknown -fobjc-fragile-abi -fobjc-gc-only -emit-llvm -o %t %s
+
+@interface I0 {
+ I0 *_f0;
+}
+@property (retain) id p0;
+@end
+
+@implementation I0
+ @synthesize p0 = _f0;
+@end
+
diff --git a/clang/test/CodeGenObjC/objc2-strong-cast-1.m b/clang/test/CodeGenObjC/objc2-strong-cast-1.m
new file mode 100644
index 0000000..9bb750f
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-strong-cast-1.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-unknown-unknown -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+
+@interface I {
+ __attribute__((objc_gc(strong))) int *i_IdocumentIDs;
+ __attribute__((objc_gc(strong))) long *l_IdocumentIDs;
+ __attribute__((objc_gc(strong))) long long *ll_IdocumentIDs;
+ __attribute__((objc_gc(strong))) float *IdocumentIDs;
+ __attribute__((objc_gc(strong))) double *d_IdocumentIDs;
+}
+- (void) _getResultsOfMatches;
+@end
+
+@implementation I
+-(void) _getResultsOfMatches {
+ IdocumentIDs[2] = IdocumentIDs[3];
+ d_IdocumentIDs[2] = d_IdocumentIDs[3];
+ l_IdocumentIDs[2] = l_IdocumentIDs[3];
+ ll_IdocumentIDs[2] = ll_IdocumentIDs[3];
+ i_IdocumentIDs[2] = i_IdocumentIDs[3];
+}
+
+@end
+
diff --git a/clang/test/CodeGenObjC/objc2-strong-cast-block-import.m b/clang/test/CodeGenObjC/objc2-strong-cast-block-import.m
new file mode 100644
index 0000000..adec376
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-strong-cast-block-import.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc-only -fblocks -emit-llvm -o - %s | FileCheck %s
+// rdar://10150823
+
+@interface Test {
+@package
+ Test ** __strong objects;
+}
+@end
+
+id newObject();
+void runWithBlock(void(^)(int i));
+
+@implementation Test
+
+- (void)testWithObjectInBlock {
+ Test **children = objects;
+ runWithBlock(^(int i){
+ children[i] = newObject();
+ });
+}
+
+@end
+// CHECK: call i8* @objc_assign_strongCast
+// CHECK: call i8* @objc_assign_strongCast
+
diff --git a/clang/test/CodeGenObjC/objc2-strong-cast.m b/clang/test/CodeGenObjC/objc2-strong-cast.m
new file mode 100644
index 0000000..7291c4e
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-strong-cast.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fobjc-gc -emit-llvm -o %t %s
+// RUN: %clang_cc1 -x objective-c++ -fobjc-gc -emit-llvm -o %t %s
+
+@interface I {
+ __attribute__((objc_gc(strong))) signed long *_documentIDs;
+ __attribute__((objc_gc(strong))) id *IdocumentIDs;
+}
+- (void) _getResultsOfMatches;
+@end
+
+@implementation I
+-(void) _getResultsOfMatches {
+ _documentIDs[2] = _documentIDs[3];
+ IdocumentIDs[2] = IdocumentIDs[3];
+}
+
+@end
+
diff --git a/clang/test/CodeGenObjC/objc2-weak-assign.m b/clang/test/CodeGenObjC/objc2-weak-assign.m
new file mode 100644
index 0000000..e5c67c5
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-weak-assign.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep -e "objc_assign_weak" %t | grep -e "call" | count 6
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep -e "objc_assign_weak" %t | grep -e "call" | count 6
+
+__weak id* x;
+id* __weak y;
+id* __weak* z;
+
+__weak id* a1[20];
+id* __weak a2[30];
+id** __weak a3[40];
+
+void foo (__weak id *param) {
+ *param = 0;
+}
+
+int main()
+{
+ *x = 0;
+ *y = 0;
+ **z = 0;
+
+ a1[3] = 0;
+ a2[3] = 0;
+ a3[3][4] = 0;
+}
+
diff --git a/clang/test/CodeGenObjC/objc2-weak-block-call.m b/clang/test/CodeGenObjC/objc2-weak-block-call.m
new file mode 100644
index 0000000..94c54e7
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-weak-block-call.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -emit-llvm %s -o - | FileCheck -check-prefix LP64 %s
+// RUN: %clang_cc1 -fblocks -fobjc-gc -triple i386-apple-darwin -fobjc-fragile-abi -emit-llvm %s -o - | FileCheck -check-prefix LP64 %s
+
+@interface MyView
+- (void)MyView_sharedInit;
+@end
+
+void foo(MyView *(^obj)(void)) ;
+
+@implementation MyView
+- (void)MyView_sharedInit {
+
+ __block __weak MyView *weakSelf = self;
+ foo(
+ ^{
+ return weakSelf;
+ });
+
+}
+@end
+
+// CHECK-LP64: call i8* @objc_read_weak
+// CHECK-LP32: call i8* @objc_read_weak
+
diff --git a/clang/test/CodeGenObjC/objc2-weak-compare.m b/clang/test/CodeGenObjC/objc2-weak-compare.m
new file mode 100644
index 0000000..75cf689
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-weak-compare.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+
+@interface PBXTarget
+{
+
+PBXTarget * __weak _lastKnownTarget;
+PBXTarget * __weak _KnownTarget;
+PBXTarget * result;
+}
+- Meth;
+@end
+
+extern void foo();
+@implementation PBXTarget
+- Meth {
+ if (_lastKnownTarget != result)
+ foo();
+ if (result != _lastKnownTarget)
+ foo();
+
+ if (_lastKnownTarget != _KnownTarget)
+ foo();
+}
+
+@end
diff --git a/clang/test/CodeGenObjC/objc2-weak-import-attribute.m b/clang/test/CodeGenObjC/objc2-weak-import-attribute.m
new file mode 100644
index 0000000..201e24b
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-weak-import-attribute.m
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-X86-64 %s
+
+__attribute__((weak_import)) @interface WeakRootClass @end
+
+__attribute__((weak_import)) @interface WeakClass : WeakRootClass
+@end
+
+@interface MySubclass : WeakClass @end
+
+@implementation MySubclass @end
+
+@implementation WeakClass(MyCategory) @end
+
+
+__attribute__((weak_import))
+@interface WeakClass1 @end
+
+@implementation WeakClass1(MyCategory) @end
+
+@implementation WeakClass1(YourCategory) @end
+
+ __attribute__((weak_import))
+@interface WeakClass3
++ message;
+@end
+
+int main() {
+ [WeakClass3 message];
+}
+
+// CHECK-X86-64: OBJC_METACLASS_$_WeakRootClass" = extern_weak global
+// CHECK-X86-64: OBJC_METACLASS_$_WeakClass" = extern_weak global
+// CHECK-X86-64: OBJC_CLASS_$_WeakClass" = extern_weak global
+// CHECK-X86-64: OBJC_CLASS_$_WeakClass1" = extern_weak global
+// CHECK-X86-64: OBJC_CLASS_$_WeakClass3" = extern_weak global
+
+// Root is being implemented here. No extern_weak.
+__attribute__((weak_import)) @interface Root @end
+
+@interface Super : Root @end
+
+@interface Sub : Super @end
+
+@implementation Sub @end
+
+@implementation Root @end
+
+// CHECK-NOT-X86-64: OBJC_METACLASS_$_Root" = extern_weak global
diff --git a/clang/test/CodeGenObjC/objc2-weak-ivar-debug.m b/clang/test/CodeGenObjC/objc2-weak-ivar-debug.m
new file mode 100644
index 0000000..83262a8
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-weak-ivar-debug.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -g -emit-llvm -o - %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -g -emit-llvm -o - %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -g -emit-llvm -o - %s
+// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -g -emit-llvm -o - %s
+
+// rdar://7252252
+@interface Loop {
+@public
+ __weak Loop *_loop;
+}
+@end
+
+@implementation Loop @end
+
+void loop(Loop *L) {
+ L->_loop = 0;
+}
diff --git a/clang/test/CodeGenObjC/objc2-weak-ivar.m b/clang/test/CodeGenObjC/objc2-weak-ivar.m
new file mode 100644
index 0000000..78ccdf8
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-weak-ivar.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+@class NSObject;
+
+@interface Foo {
+@public
+ __weak NSObject *nsobject;
+}
+@end
+
+@implementation Foo @end
diff --git a/clang/test/CodeGenObjC/objc2-write-barrier-2.m b/clang/test/CodeGenObjC/objc2-write-barrier-2.m
new file mode 100644
index 0000000..eae2551
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-write-barrier-2.m
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep -F '@objc_assign_global' %t | count 7
+// RUN: grep -F '@objc_assign_ivar' %t | count 5
+// RUN: grep -F '@objc_assign_strongCast' %t | count 8
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep -F '@objc_assign_global' %t | count 7
+// RUN: grep -F '@objc_assign_ivar' %t | count 5
+// RUN: grep -F '@objc_assign_strongCast' %t | count 8
+
+extern id **somefunc(void);
+extern id *somefunc2(void);
+
+
+// Globals
+
+id W, *X, **Y;
+
+void func(id a, id *b, id **c) {
+ static id w, *x, **y;
+ W = a;
+ w = a;
+ X = b;
+ x = b;
+ Y = c;
+ y = c;
+}
+
+// Instances
+
+@interface something {
+ id w, *x, **y;
+}
+@end
+
+@implementation something
+- (void)amethod {
+ id badIdea = *somefunc2();
+ w = badIdea;
+ x = &badIdea;
+ y = &x;
+}
+@end
+
+typedef struct {
+ int junk;
+ id alfred;
+} AStruct;
+
+void funct2(AStruct *aptr) {
+ id **ppptr = somefunc();
+ aptr->alfred = 0;
+ **ppptr = aptr->alfred;
+ *ppptr = somefunc2();
+}
+
+typedef const struct __CFString * CFStringRef;
+@interface DSATextSearch {
+__strong CFStringRef *_documentNames;
+ struct {
+ id *innerNames;
+ struct {
+ id *nestedDeeperNames;
+ struct I {
+ id *is1;
+ id is2[5];
+ } arrI [3];
+ } inner_most;
+ } inner;
+
+}
+- filter;
+@end
+@implementation DSATextSearch
+- filter {
+ int filteredPos = 0;
+ _documentNames[filteredPos] = 0; // storing into an element of array ivar. objc_assign_strongCast is needed.
+ inner.innerNames[filteredPos] = 0;
+ inner.inner_most.nestedDeeperNames[filteredPos] = 0;
+ inner.inner_most.arrI[3].is1[5] = 0;
+ inner.inner_most.arrI[3].is2[5] = 0;
+}
+@end
+
diff --git a/clang/test/CodeGenObjC/objc2-write-barrier-3.m b/clang/test/CodeGenObjC/objc2-write-barrier-3.m
new file mode 100644
index 0000000..4ef1b8a
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-write-barrier-3.m
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep objc_assign_ivar %t | count 3
+// RUN: grep objc_assign_strongCast %t | count 6
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fblocks -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep objc_assign_ivar %t | count 3
+// RUN: grep objc_assign_strongCast %t | count 6
+
+struct Slice {
+ void *__strong * items;
+};
+
+typedef struct Slice Slice;
+
+@interface ISlice {
+@public
+ void *__strong * IvarItem;
+}
+@end
+
+typedef void (^observer_block_t)(id object);
+@interface Observer {
+@public
+ observer_block_t block;
+}
+@end
+
+
+void foo (int i) {
+ // storing into an array of strong pointer types.
+ void *__strong* items;
+ items[i] = 0;
+
+ // storing indirectly into an array of strong pointer types.
+ void *__strong* *vitems;
+ *vitems[i] = 0;
+
+ Slice *slice;
+ slice->items = 0;
+ // storing into a struct element of an array of strong pointer types.
+ slice->items[i] = 0;
+
+ ISlice *islice;
+ islice->IvarItem = 0;
+ // Storing into an ivar of an array of strong pointer types.
+ islice->IvarItem[i] = (void*)0;
+
+ Observer *observer;
+ observer->block = 0;
+}
diff --git a/clang/test/CodeGenObjC/objc2-write-barrier-4.m b/clang/test/CodeGenObjC/objc2-write-barrier-4.m
new file mode 100644
index 0000000..4089920
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-write-barrier-4.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep objc_assign_global %t | count 3
+// RUN: grep objc_assign_strongCast %t | count 2
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep objc_assign_global %t | count 3
+// RUN: grep objc_assign_strongCast %t | count 2
+
+@interface A
+@end
+
+typedef struct s0 {
+ A *a[4];
+} T;
+
+T g0;
+
+void f0(id x) {
+ g0.a[0] = x;
+}
+
+void f1(id x) {
+ ((T*) &g0)->a[0] = x;
+}
+
+void f2(unsigned idx)
+{
+ id *keys;
+ keys[idx] = 0;
+}
+
diff --git a/clang/test/CodeGenObjC/objc2-write-barrier-5.m b/clang/test/CodeGenObjC/objc2-write-barrier-5.m
new file mode 100644
index 0000000..122fa9f
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-write-barrier-5.m
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep objc_assign_ivar %t | count 0
+// RUN: grep objc_assign_strongCast %t | count 8
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep objc_assign_ivar %t | count 0
+// RUN: grep objc_assign_strongCast %t | count 8
+
+@interface TestUnarchiver
+{
+ void *allUnarchivedObjects;
+}
+@end
+
+@implementation TestUnarchiver
+
+struct unarchive_list {
+ int ifield;
+ id *list;
+};
+
+- (id)init {
+ (*((struct unarchive_list *)allUnarchivedObjects)).list = 0;
+ ((struct unarchive_list *)allUnarchivedObjects)->list = 0;
+ (**((struct unarchive_list **)allUnarchivedObjects)).list = 0;
+ (*((struct unarchive_list **)allUnarchivedObjects))->list = 0;
+ return 0;
+}
+
+@end
+
+// rdar://10191569
+@interface I
+{
+ struct S {
+ id _timer;
+ } *p_animationState;
+}
+@end
+
+@implementation I
+- (void) Meth {
+ p_animationState->_timer = 0;
+ (*p_animationState)._timer = 0;
+ (&(*p_animationState))->_timer = 0;
+}
+@end
diff --git a/clang/test/CodeGenObjC/objc2-write-barrier.m b/clang/test/CodeGenObjC/objc2-write-barrier.m
new file mode 100644
index 0000000..bf2dfb9
--- /dev/null
+++ b/clang/test/CodeGenObjC/objc2-write-barrier.m
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep -F '@objc_assign_global' %t | count 21
+// RUN: grep -F '@objc_assign_ivar' %t | count 11
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s
+// RUN: grep -F '@objc_assign_global' %t | count 21
+// RUN: grep -F '@objc_assign_ivar' %t | count 11
+
+
+typedef const struct __CFDictionary * CFDictionaryRef;
+
+// callouts to these are generated with cc -fobjc-gc
+
+int GlobalAssigns;
+int IvarAssigns;
+int StrongCastAssigns;
+
+
+// The test case elements;
+@class NSObject;
+@class NSString;
+
+typedef struct {
+ id element;
+ id elementArray[10];
+ __strong CFDictionaryRef cfElement;
+ __strong CFDictionaryRef cfElementArray[10];
+} struct_with_ids_t;
+
+@interface Foo {
+@public
+// assignments to any/all of these fields should generate objc_assign_ivar
+ __strong CFDictionaryRef dict;
+ __strong CFDictionaryRef dictArray[3];
+ id ivar;
+ id array[10];
+ NSObject *nsobject;
+ NSString *stringArray[10];
+ struct_with_ids_t inner;
+}
+
+@end
+
+// assignments to these should generate objc_assign_global
+id GlobalId;
+id GlobalArray[20];
+NSObject *GlobalObject;
+NSObject *GlobalObjectArray[20];
+__strong CFDictionaryRef Gdict;
+__strong CFDictionaryRef Gdictarray[10];
+struct_with_ids_t GlobalStruct;
+struct_with_ids_t GlobalStructArray[10];
+
+
+// The test cases
+void* rhs = 0;
+
+#define ASSIGNTEST(expr, global) expr = (typeof(expr))rhs
+
+int testGlobals() {
+ // Everything in this function generates assign_global intercepts
+ int counter = 0;
+
+ static id staticGlobalId;
+ static id staticGlobalArray[20];
+ static NSObject *staticGlobalObject;
+ static NSObject *staticGlobalObjectArray[20];
+ static __strong CFDictionaryRef staticGdict;
+ static __strong CFDictionaryRef staticGdictarray[10];
+ static struct_with_ids_t staticGlobalStruct;
+ static struct_with_ids_t staticGlobalStructArray[10];
+
+ ASSIGNTEST(GlobalId, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(GlobalArray[0], GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(GlobalObject, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(GlobalObjectArray[0], GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(Gdict, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(Gdictarray[1], GlobalAssigns); // objc_assign_global
+
+ ASSIGNTEST(GlobalStruct.element, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(GlobalStruct.elementArray[0], GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(GlobalStruct.cfElement, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(GlobalStruct.cfElementArray[0], GlobalAssigns); // objc_assign_global
+
+ ASSIGNTEST(staticGlobalId, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGlobalArray[0], GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGlobalObject, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGlobalObjectArray[0], GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGdict, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGdictarray[1], GlobalAssigns); // objc_assign_global
+
+ ASSIGNTEST(staticGlobalStruct.element, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGlobalStruct.elementArray[0], GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGlobalStruct.cfElement, GlobalAssigns); // objc_assign_global
+ ASSIGNTEST(staticGlobalStruct.cfElementArray[0], GlobalAssigns); // objc_assign_global
+
+ return counter;
+}
+
+
+int testIvars() {
+ Foo *foo;
+ int counter = 0;
+
+ ASSIGNTEST(foo->ivar, IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->dict, IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->dictArray[0], IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->array[0], IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->nsobject, IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->stringArray[0], IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->inner.element, IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->inner.elementArray[0], IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->inner.cfElement, IvarAssigns); // objc_assign_ivar
+ ASSIGNTEST(foo->inner.cfElementArray[0], IvarAssigns); // objc_assign_ivar
+
+ return counter;
+}
diff --git a/clang/test/CodeGenObjC/object-incr-decr-1.m b/clang/test/CodeGenObjC/object-incr-decr-1.m
new file mode 100644
index 0000000..19c12cb
--- /dev/null
+++ b/clang/test/CodeGenObjC/object-incr-decr-1.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm %s -o %t
+
+@interface Foo
+{
+ double d1,d3,d4;
+}
+@end
+
+Foo* foo()
+{
+ Foo *f;
+
+ // Both of these crash clang nicely
+ ++f;
+ --f;
+ f--;
+ f++;
+ return f;
+}
diff --git a/clang/test/CodeGenObjC/optimized-setter.m b/clang/test/CodeGenObjC/optimized-setter.m
new file mode 100644
index 0000000..0e1b388
--- /dev/null
+++ b/clang/test/CodeGenObjC/optimized-setter.m
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-macosx10.8.0 -o - | FileCheck %s
+// rdar://10179974
+
+@interface I
+// void objc_setProperty_nonatomic(id self, SEL _cmd, id newValue, ptrdiff_t offset);
+// objc_setProperty(..., NO, NO)
+@property (nonatomic, retain) id nonatomicProperty;
+
+// void objc_setProperty_nonatomic_copy(id self, SEL _cmd, id newValue, ptrdiff_t offset);
+// objc_setProperty(..., NO, YES)
+@property (nonatomic, copy) id nonatomicPropertyCopy;
+
+// void objc_setProperty_atomic(id self, SEL _cmd, id newValue, ptrdiff_t offset);
+// objc_setProperty(..., YES, NO)
+@property (retain) id atomicProperty;
+
+// void objc_setProperty_atomic_copy(id self, SEL _cmd, id newValue, ptrdiff_t offset);
+// objc_setProperty(..., YES, YES)
+@property (copy) id atomicPropertyCopy;
+@end
+
+@implementation I
+@synthesize nonatomicProperty;
+@synthesize nonatomicPropertyCopy;
+@synthesize atomicProperty;
+@synthesize atomicPropertyCopy;
+@end
+
+// CHECK: call void @objc_setProperty_nonatomic
+// CHECK: call void @objc_setProperty_nonatomic_copy
+// CHECK: call void @objc_setProperty_atomic
+// CHECK: call void @objc_setProperty_atomic_copy
+
diff --git a/clang/test/CodeGenObjC/overloadable.m b/clang/test/CodeGenObjC/overloadable.m
new file mode 100644
index 0000000..4fd1429
--- /dev/null
+++ b/clang/test/CodeGenObjC/overloadable.m
@@ -0,0 +1,10 @@
+// rdar://6657613
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+@class C;
+
+// RUN: grep _Z1fP11objc_object %t | count 1
+void __attribute__((overloadable)) f(id c) { }
+
+// RUN: grep _Z1fP1C %t | count 1
+void __attribute__((overloadable)) f(C *c) { }
diff --git a/clang/test/CodeGenObjC/predefined-expr.m b/clang/test/CodeGenObjC/predefined-expr.m
new file mode 100644
index 0000000..009bbcd
--- /dev/null
+++ b/clang/test/CodeGenObjC/predefined-expr.m
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: @"__func__.-[Foo instanceTest1]" = private unnamed_addr constant [21 x i8] c"-[Foo instanceTest1]\00"
+// CHECK: @"__func__.-[Foo instanceTest2:]" = private unnamed_addr constant [22 x i8] c"-[Foo instanceTest2:]\00"
+// CHECK: @"__func__.-[Foo instanceTest3:withB:]" = private unnamed_addr constant [28 x i8] c"-[Foo instanceTest3:withB:]\00"
+// CHECK: @"__func__.-[Foo instanceTest4]" = private unnamed_addr constant [21 x i8] c"-[Foo instanceTest4]\00"
+// CHECK: @"__func__.+[Foo classTest1]" = private unnamed_addr constant [18 x i8] c"+[Foo classTest1]\00"
+// CHECK: @"__func__.+[Foo classTest2:]" = private unnamed_addr constant [19 x i8] c"+[Foo classTest2:]\00"
+// CHECK: @"__func__.+[Foo classTest3:withB:]" = private unnamed_addr constant [25 x i8] c"+[Foo classTest3:withB:]\00"
+// CHECK: @"__func__.+[Foo classTest4]" = private unnamed_addr constant [18 x i8] c"+[Foo classTest4]\00"
+// CHECK: @"__func__.-[Foo(Category) instanceTestWithCategory]" = private unnamed_addr constant [42 x i8] c"-[Foo(Category) instanceTestWithCategory]\00"
+// CHECK: @"__func__.+[Foo(Category) classTestWithCategory]" = private unnamed_addr constant [39 x i8] c"+[Foo(Category) classTestWithCategory]\00"
+
+int printf(const char * _Format, ...);
+
+@interface Foo
+@end
+
+@implementation Foo
+
+- (void)instanceTest1 {
+ printf("__func__: %s\n", __func__);
+ printf("__FUNCTION__: %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__);
+}
+
+- (void)instanceTest2:(int)i {
+ printf("__func__: %s\n", __func__);
+ printf("__FUNCTION__: %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__);
+}
+
+- (void)instanceTest3:(int)a withB:(double)b {
+ printf("__func__: %s\n", __func__);
+ printf("__FUNCTION__: %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__);
+}
+
+- (int)instanceTest4 {
+ printf("__func__: %s\n", __func__);
+ printf("__FUNCTION__: %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__);
+ return 0;
+}
+
++ (void)classTest1 {
+ printf("__func__: %s\n", __func__);
+ printf("__FUNCTION__: %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__);
+}
+
++ (void)classTest2:(int)i {
+ printf("__func__: %s\n", __func__);
+ printf("__FUNCTION__: %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__);
+}
+
++ (void)classTest3:(int)a withB:(double)b {
+ printf("__func__: %s\n", __func__);
+ printf("__FUNCTION__: %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__);
+}
+
++ (int)classTest4 {
+ printf("__func__: %s\n", __func__);
+ printf("__FUNCTION__: %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__);
+ return 0;
+}
+
+@end
+
+@interface Foo (Category)
+@end
+
+@implementation Foo (Category)
+
+- (void)instanceTestWithCategory {
+ printf("__func__: %s\n", __func__);
+ printf("__FUNCTION__: %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__);
+}
+
++ (void)classTestWithCategory {
+ printf("__func__: %s\n", __func__);
+ printf("__FUNCTION__: %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__: %s\n\n", __PRETTY_FUNCTION__);
+}
+
+@end
diff --git a/clang/test/CodeGenObjC/property-aggregate.m b/clang/test/CodeGenObjC/property-aggregate.m
new file mode 100644
index 0000000..f4211b6
--- /dev/null
+++ b/clang/test/CodeGenObjC/property-aggregate.m
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s
+
+// This structure's size is not a power of two, so the property does
+// not get native atomics, even though x86-64 can do unaligned atomics
+// with a lock prefix.
+struct s3 { char c[3]; };
+
+// This structure's size is, so it does, because it can.
+// FIXME: But we don't at the moment; the backend doesn't know how to generate
+// correct code.
+struct s4 { char c[4]; };
+
+@interface Test0
+@property struct s3 s3;
+@property struct s4 s4;
+@end
+@implementation Test0
+@synthesize s3, s4;
+@end
+
+// CHECK: define internal i24 @"\01-[Test0 s3]"(
+// CHECK: call void @objc_copyStruct
+
+// CHECK: define internal void @"\01-[Test0 setS3:]"(
+// CHECK: call void @objc_copyStruct
+
+// CHECK: define internal i32 @"\01-[Test0 s4]"(
+// CHECK: call void @objc_copyStruct
+
+// CHECK: define internal void @"\01-[Test0 setS4:]"(
+// CHECK: call void @objc_copyStruct
diff --git a/clang/test/CodeGenObjC/property-agrr-getter.m b/clang/test/CodeGenObjC/property-agrr-getter.m
new file mode 100644
index 0000000..6d8f1d6
--- /dev/null
+++ b/clang/test/CodeGenObjC/property-agrr-getter.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+
+typedef struct {
+ unsigned f0;
+} s0;
+
+@interface A
+- (s0) f0;
+@end
+
+@implementation A
+-(s0) f0{ while (1) {} }
+- (unsigned) bar {
+ return self.f0.f0;
+}
+@end
+
+
+typedef struct _NSSize {
+ float width;
+ float height;
+} NSSize;
+
+
+@interface AnObject
+{
+ NSSize size;
+}
+
+@property NSSize size;
+
+@end
+
+float f ()
+{
+ AnObject* obj;
+ return (obj.size).width;
+}
+
+// rdar://problem/9272392
+void test3(AnObject *obj) {
+ obj.size;
+ (void) obj.size;
+}
diff --git a/clang/test/CodeGenObjC/property-category-impl.m b/clang/test/CodeGenObjC/property-category-impl.m
new file mode 100644
index 0000000..734f9a3
--- /dev/null
+++ b/clang/test/CodeGenObjC/property-category-impl.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+
+// rdar : // 8093297
+
+@interface Foo @end
+
+@protocol Proto
+@property (readonly) int proto_property;
+@end
+
+@interface Foo (Category) <Proto> @end
+
+@implementation Foo (Category)
+-(int)proto_property { return 0; }
+@end
+
+
+// CHECK: l_OBJC_$_PROP_LIST_Foo_$_Category" = internal global
+// CHECK: l_OBJC_$_CATEGORY_Foo_$_Category" = internal global
+// CHECK: l_OBJC_$_PROP_LIST_Foo_$_Category
diff --git a/clang/test/CodeGenObjC/property-complex.m b/clang/test/CodeGenObjC/property-complex.m
new file mode 100644
index 0000000..3cdd2ec
--- /dev/null
+++ b/clang/test/CodeGenObjC/property-complex.m
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s
+
+@interface I0 {
+@public
+ _Complex float iv0;
+}
+
+@property(assign) _Complex float p0;
+
+-(_Complex float) im0;
+-(void) setIm0: (_Complex float) a0;
+@end
+
+@implementation I0
+@dynamic p0;
+
+-(id) init {
+ self->iv0 = 5.0 + 2.0i;
+ return self;
+}
+
+-(_Complex float) im0 {
+ printf("im0: %.2f + %.2fi\n", __real iv0, __imag iv0);
+ return iv0 + (.1 + .2i);
+}
+-(void) setIm0: (_Complex float) a0 {
+ printf("setIm0: %.2f + %.2fi\n", __real a0, __imag a0);
+ iv0 = a0 + (.3 + .4i);
+}
+
+-(_Complex float) p0 {
+ printf("p0: %.2f + %.2fi\n", __real iv0, __imag iv0);
+ return iv0 + (.5 + .6i);
+}
+-(void) setP0: (_Complex float) a0 {
+ printf("setP0: %.2f + %.2fi\n", __real a0, __imag a0);
+ iv0 = a0 + (.7 + .8i);
+}
+@end
+
+void f0(I0 *a0) {
+ float l0 = __real a0.im0;
+ float l1 = __imag a0->iv0;
+ _Complex float l2 = (a0.im0 = a0.im0);
+ _Complex float l3 = a0->iv0;
+ _Complex float l4 = (a0->iv0 = a0->iv0);
+ _Complex float l5 = a0->iv0;
+ _Complex float l6 = (a0.p0 = a0.p0);
+ _Complex float l7 = a0->iv0;
+ _Complex float l8 = [a0 im0];
+ printf("l0: %.2f + %.2fi\n", __real l0, __imag l0);
+ printf("l1: %.2f + %.2fi\n", __real l1, __imag l1);
+ printf("l2: %.2f + %.2fi\n", __real l2, __imag l2);
+ printf("l3: %.2f + %.2fi\n", __real l3, __imag l3);
+ printf("l4: %.2f + %.2fi\n", __real l4, __imag l4);
+ printf("l5: %.2f + %.2fi\n", __real l5, __imag l5);
+ printf("l6: %.2f + %.2fi\n", __real l6, __imag l6);
+ printf("l7: %.2f + %.2fi\n", __real l7, __imag l7);
+ printf("l8: %.2f + %.2fi\n", __real l8, __imag l8);
+}
diff --git a/clang/test/CodeGenObjC/property-dbg.m b/clang/test/CodeGenObjC/property-dbg.m
new file mode 100644
index 0000000..42ab611
--- /dev/null
+++ b/clang/test/CodeGenObjC/property-dbg.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -S -g -masm-verbose -x objective-c < %s | grep DW_AT_name
+@interface Foo {
+ int i;
+}
+@property int i;
+@end
+
+@implementation Foo
+@synthesize i;
+@end
+
+int bar(Foo *f) {
+ int i = 1;
+ f.i = 2;
+ i = f.i;
+ return i;
+}
diff --git a/clang/test/CodeGenObjC/property-getter-dot-syntax.m b/clang/test/CodeGenObjC/property-getter-dot-syntax.m
new file mode 100644
index 0000000..f22b051
--- /dev/null
+++ b/clang/test/CodeGenObjC/property-getter-dot-syntax.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@protocol NSObject
+- (void *)description;
+@end
+
+int main()
+{
+ id<NSObject> eggs;
+ void *eggsText= eggs.description;
+}
diff --git a/clang/test/CodeGenObjC/property-incr-decr-1.m b/clang/test/CodeGenObjC/property-incr-decr-1.m
new file mode 100644
index 0000000..d75c02e
--- /dev/null
+++ b/clang/test/CodeGenObjC/property-incr-decr-1.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@interface Object
+- (id) new;
+@end
+
+@interface SomeClass : Object
+{
+ int _myValue;
+}
+@property int myValue;
+@end
+
+@implementation SomeClass
+@synthesize myValue=_myValue;
+@end
+
+int main()
+{
+ int val;
+ SomeClass *o = [SomeClass new];
+ o.myValue = -1;
+ val = o.myValue++; /* val -1, o.myValue 0 */
+ val += o.myValue--; /* val -1. o.myValue -1 */
+ val += ++o.myValue; /* val -1, o.myValue 0 */
+ val += --o.myValue; /* val -2, o.myValue -1 */
+ return ++o.myValue + (val+2);
+}
+
diff --git a/clang/test/CodeGenObjC/property-list-in-class.m b/clang/test/CodeGenObjC/property-list-in-class.m
new file mode 100644
index 0000000..e801485
--- /dev/null
+++ b/clang/test/CodeGenObjC/property-list-in-class.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s
+// CHECK: l_OBJC_$_PROP_LIST_C2" = internal global { i32, i32, [3 x %struct._prop_t] } { i32 16, i32 3
+
+@protocol P
+@property int i;
+@end
+
+@protocol P1
+@property int i1;
+@end
+
+@protocol P2 < P1>
+@property int i2;
+@end
+
+@interface C1 { id isa; } @end
+
+@interface C2 : C1 <P, P2> {
+ int i;
+}
+@property int i2;
+@end
+
+@implementation C1
++(void)initialize { }
+@end
+
+@implementation C2
+@synthesize i;
+@synthesize i1;
+@synthesize i2;
+@end
diff --git a/clang/test/CodeGenObjC/property-ref-cast-to-void.m b/clang/test/CodeGenObjC/property-ref-cast-to-void.m
new file mode 100644
index 0000000..ad1689f
--- /dev/null
+++ b/clang/test/CodeGenObjC/property-ref-cast-to-void.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s
+
+// rdar: // 8399655
+@interface TestClass
+@property (readonly) int myProperty;
+- (int)myProperty;
+- (double)myGetter;
+@end
+
+void FUNC () {
+ TestClass *obj;
+ (void)obj.myProperty;
+ (void)obj.myGetter;
+}
+
+// CHECK: call i32 bitcast
+// CHECK: call double bitcast
diff --git a/clang/test/CodeGenObjC/property-setter-attr.m b/clang/test/CodeGenObjC/property-setter-attr.m
new file mode 100644
index 0000000..d155ca8
--- /dev/null
+++ b/clang/test/CodeGenObjC/property-setter-attr.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -triple=i686-apple-darwin8 -o %t %s
+// RUN: grep -e "SiSetOtherThings:" %t
+
+@interface A
+@property(setter=iSetOtherThings:) int otherThings;
+@end
+
+@implementation A
+@dynamic otherThings;
+@end
diff --git a/clang/test/CodeGenObjC/property-type-mismatch.m b/clang/test/CodeGenObjC/property-type-mismatch.m
new file mode 100644
index 0000000..b920b45
--- /dev/null
+++ b/clang/test/CodeGenObjC/property-type-mismatch.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// rdar://8966864
+
+@interface Foo
+-(float)myfo;
+-(void)setMyfo: (int)p;
+@end
+
+void bar(Foo *x) {
+ x.myfo++;
+}
+
+// CHECK: [[C1:%.*]] = call float bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: [[I:%.*]] = fadd float [[C1]], 1.000000e+00
+// CHECK: [[CONV:%.*]] = fptosi float [[I]] to i32
+// CHECK: [[T3:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_2"
+// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
diff --git a/clang/test/CodeGenObjC/property.m b/clang/test/CodeGenObjC/property.m
new file mode 100644
index 0000000..16881d6
--- /dev/null
+++ b/clang/test/CodeGenObjC/property.m
@@ -0,0 +1,168 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+// TODO: actually test most of this instead of just emitting it
+
+int printf(const char *, ...);
+
+@interface Root
+-(id) alloc;
+-(id) init;
+@end
+
+@interface A : Root {
+ int x;
+ int y, ro, z;
+ id ob0, ob1, ob2, ob3, ob4;
+}
+@property int x;
+@property int y;
+@property int z;
+@property(readonly) int ro;
+@property(assign) id ob0;
+@property(retain) id ob1;
+@property(copy) id ob2;
+@property(retain, nonatomic) id ob3;
+@property(copy, nonatomic) id ob4;
+@end
+
+@implementation A
+@dynamic x;
+@synthesize y;
+@synthesize z = z;
+@synthesize ro;
+@synthesize ob0;
+@synthesize ob1;
+@synthesize ob2;
+@synthesize ob3;
+@synthesize ob4;
+-(int) y {
+ return x + 1;
+}
+-(void) setZ: (int) arg {
+ x = arg - 1;
+}
+@end
+
+@interface A (Cat)
+@property int dyn;
+@end
+
+@implementation A (Cat)
+-(int) dyn {
+ return 10;
+}
+@end
+
+// Test that compound operations only compute the base once.
+// CHECK: define void @test2
+A *test2_helper(void);
+void test2() {
+ // CHECK: [[BASE:%.*]] = call [[A:%.*]]* @test2_helper()
+ // CHECK-NEXT: [[SEL:%.*]] = load i8**
+ // CHECK-NEXT: [[BASETMP:%.*]] = bitcast [[A]]* [[BASE]] to i8*
+ // CHECK-NEXT: [[LD:%.*]] = call i32 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 (i8*, i8*)*)(i8* [[BASETMP]], i8* [[SEL]])
+ // CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[LD]], 1
+ // CHECK-NEXT: [[SEL:%.*]] = load i8**
+ // CHECK-NEXT: [[BASETMP:%.*]] = bitcast [[A]]* [[BASE]] to i8*
+ // CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i32)*)(i8* [[BASETMP]], i8* [[SEL]], i32 [[ADD]])
+ test2_helper().dyn++;
+
+ // CHECK: [[BASE:%.*]] = call [[A]]* @test2_helper()
+ // CHECK-NEXT: [[SEL:%.*]] = load i8**
+ // CHECK-NEXT: [[BASETMP:%.*]] = bitcast [[A]]* [[BASE]] to i8*
+ // CHECK-NEXT: [[LD:%.*]] = call i32 bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 (i8*, i8*)*)(i8* [[BASETMP]], i8* [[SEL]])
+ // CHECK-NEXT: [[ADD:%.*]] = mul nsw i32 [[LD]], 10
+ // CHECK-NEXT: [[SEL:%.*]] = load i8**
+ // CHECK-NEXT: [[BASETMP:%.*]] = bitcast [[A]]* [[BASE]] to i8*
+ // CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i32)*)(i8* [[BASETMP]], i8* [[SEL]], i32 [[ADD]])
+ test2_helper().dyn *= 10;
+}
+
+// Test aggregate initialization from property reads.
+// Not crashing is good enough for the property-specific test.
+struct test3_struct { int x,y,z; };
+struct test3_nested { struct test3_struct t; };
+@interface test3_object
+@property struct test3_struct s;
+@end
+void test3(test3_object *p) {
+ struct test3_struct array[1] = { p.s };
+ struct test3_nested agg = { p.s };
+}
+
+// PR8742
+@interface Test4 {}
+@property float f;
+@end
+// CHECK: define void @test4
+void test4(Test4 *t) {
+ extern int test4_printf(const char *, ...);
+ // CHECK: [[TMP:%.*]] = call float {{.*}} @objc_msgSend
+ // CHECK-NEXT: [[EXT:%.*]] = fpext float [[TMP]] to double
+ // CHECK-NEXT: call i32 (i8*, ...)* @test4_printf(i8* {{.*}}, double [[EXT]])
+ // CHECK-NEXT: ret void
+ test4_printf("%.2f", t.f);
+}
+
+@interface Test5 {
+ unsigned _x : 5;
+}
+@property unsigned x;
+@end
+@implementation Test5
+@synthesize x = _x;
+@end
+
+// rdar://problem/10410531
+@interface Test6
+@property void (*prop)(void);
+@end
+
+void test6_func(void);
+void test6(Test6 *a) {
+ a.prop = test6_func;
+}
+
+// rdar://problem/10507455
+@interface Test7
+@property unsigned char x;
+@end
+void test7(Test7 *t) {
+ t.x &= 2;
+ t.x |= 5;
+ t.x ^= 8;
+}
+// CHECK: define void @test7([[TEST7:%.*]]*
+// CHECK: [[T:%.*]] = alloca [[TEST7]]*,
+// CHECK-NEXT: store
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST7]]** [[T]], align
+// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
+// CHECK-NEXT: [[T2:%.*]] = call zeroext i8 bitcast
+// CHECK-NEXT: [[T3:%.*]] = zext i8 [[T2]] to i32
+// CHECK-NEXT: [[T4:%.*]] = and i32 [[T3]], 2
+// CHECK-NEXT: [[T5:%.*]] = trunc i32 [[T4]] to i8
+// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[T6:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
+// CHECK-NEXT: call void bitcast
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST7]]** [[T]], align
+// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
+// CHECK-NEXT: [[T2:%.*]] = call zeroext i8 bitcast
+// CHECK-NEXT: [[T3:%.*]] = zext i8 [[T2]] to i32
+// CHECK-NEXT: [[T4:%.*]] = or i32 [[T3]], 5
+// CHECK-NEXT: [[T5:%.*]] = trunc i32 [[T4]] to i8
+// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[T6:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
+// CHECK-NEXT: call void bitcast
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST7]]** [[T]], align
+// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
+// CHECK-NEXT: [[T2:%.*]] = call zeroext i8 bitcast
+// CHECK-NEXT: [[T3:%.*]] = zext i8 [[T2]] to i32
+// CHECK-NEXT: [[T4:%.*]] = xor i32 [[T3]], 8
+// CHECK-NEXT: [[T5:%.*]] = trunc i32 [[T4]] to i8
+// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[T6:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
+// CHECK-NEXT: call void bitcast
+// CHECK-NEXT: ret void
diff --git a/clang/test/CodeGenObjC/protocol-in-extended-class.m b/clang/test/CodeGenObjC/protocol-in-extended-class.m
new file mode 100644
index 0000000..a924084
--- /dev/null
+++ b/clang/test/CodeGenObjC/protocol-in-extended-class.m
@@ -0,0 +1,29 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S %s -o %t-64.s
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
+// RUN: %clang_cc1 -triple i386-apple-darwin -fobjc-fragile-abi -S %s -o %t-32.s
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s
+
+@protocol MyProtocol
+@end
+
+@protocol ExtendedProtocol
+@end
+
+@interface ItDoesntWork<MyProtocol> {
+}
+-(void) Meth;
+@end
+
+@interface ItDoesntWork() <MyProtocol, ExtendedProtocol>
+@end
+
+@implementation ItDoesntWork
+-(void) Meth {
+ ItDoesntWork <MyProtocol, ExtendedProtocol> *p = 0;
+ }
+@end
+
+// CHECK-LP64: l_OBJC_PROTOCOL_$_ExtendedProtocol:
+
+// CHECK-LP32: L_OBJC_PROTOCOL_ExtendedProtocol:
diff --git a/clang/test/CodeGenObjC/protocol-property-synth.m b/clang/test/CodeGenObjC/protocol-property-synth.m
new file mode 100644
index 0000000..c998d63
--- /dev/null
+++ b/clang/test/CodeGenObjC/protocol-property-synth.m
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@interface BaseClass {
+ id _delegate;
+}
+@end
+
+@protocol MyProtocol
+@optional
+@property(assign) id delegate;
+@end
+
+@protocol AnotherProtocol
+@optional
+@property(assign) id myanother;
+@end
+
+@protocol SubProtocol <MyProtocol>
+@property(assign) id another;
+@end
+
+@interface SubClass : BaseClass <SubProtocol, AnotherProtocol> {
+}
+
+@end
+
+@implementation BaseClass @end
+
+@implementation SubClass
+@synthesize delegate = _Subdelegate;
+@synthesize another;
+@synthesize myanother;
+@end
diff --git a/clang/test/CodeGenObjC/protocols-lazy.m b/clang/test/CodeGenObjC/protocols-lazy.m
new file mode 100644
index 0000000..1c551fb
--- /dev/null
+++ b/clang/test/CodeGenObjC/protocols-lazy.m
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -emit-llvm -triple i686-apple-darwin8 -fobjc-fragile-abi -o %t %s
+// RUNX: llvm-gcc -S -emit-llvm -o %t %s &&
+
+// No object generated
+// RUN: grep OBJC_PROTOCOL_P0 %t | count 0
+@protocol P0;
+
+// No object generated
+// RUN: grep OBJC_PROTOCOL_P1 %t | count 0
+@protocol P1 -im1; @end
+
+// Definition triggered by protocol reference.
+// RUN: grep OBJC_PROTOCOL_P2 %t | count 3
+// RUN: grep OBJC_PROTOCOL_INSTANCE_METHODS_P2 %t | count 3
+@protocol P2 -im1; @end
+void f0() { id x = @protocol(P2); }
+
+// Forward definition triggered by protocol reference.
+// RUN: grep OBJC_PROTOCOL_P3 %t | count 3
+// RUN: grep OBJC_PROTOCOL_INSTANCE_METHODS_P3 %t | count 0
+@protocol P3;
+void f1() { id x = @protocol(P3); }
+
+// Definition triggered by class reference.
+// RUN: grep OBJC_PROTOCOL_P4 %t | count 3
+// RUN: grep OBJC_PROTOCOL_INSTANCE_METHODS_P4 %t | count 3
+@protocol P4 -im1; @end
+@interface I0<P4> @end
+@implementation I0 -im1 { return 0; }; @end
+
+// Definition following forward reference.
+// RUN: grep OBJC_PROTOCOL_P5 %t | count 3
+// RUN: grep OBJC_PROTOCOL_INSTANCE_METHODS_P5 %t | count 3
+@protocol P5;
+void f2() { id x = @protocol(P5); } // This generates a forward
+ // reference, which has to be
+ // updated on the next line.
+@protocol P5 -im1; @end
+
+// Protocol reference following definition.
+// RUN: grep OBJC_PROTOCOL_P6 %t | count 4
+// RUN: grep OBJC_PROTOCOL_INSTANCE_METHODS_P6 %t | count 3
+@protocol P6 -im1; @end
+@interface I1<P6> @end
+@implementation I1 -im1 { return 0; }; @end
+void f3() { id x = @protocol(P6); }
+
diff --git a/clang/test/CodeGenObjC/protocols.m b/clang/test/CodeGenObjC/protocols.m
new file mode 100644
index 0000000..6dadb11
--- /dev/null
+++ b/clang/test/CodeGenObjC/protocols.m
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+
+void p(const char*, ...);
+
+@interface Root
++(int) maxValue;
+-(int) conformsTo: (id) x;
+@end
+
+@protocol P0;
+
+@protocol P1
++(void) classMethodReq0;
+-(void) methodReq0;
+@optional
++(void) classMethodOpt1;
+-(void) methodOpt1;
+@required
++(void) classMethodReq2;
+-(void) methodReq2;
+@end
+
+@protocol P2
+//@property(readwrite) int x;
+@end
+
+@protocol P3<P1, P2>
+-(id <P1>) print0;
+-(void) print1;
+@end
+
+void foo(const id a) {
+ void *p = @protocol(P3);
+}
+
+int main() {
+ Protocol *P0 = @protocol(P0);
+ Protocol *P1 = @protocol(P1);
+ Protocol *P2 = @protocol(P2);
+ Protocol *P3 = @protocol(P3);
+
+#define Pbool(X) p(#X ": %s\n", X ? "yes" : "no");
+ Pbool([P0 conformsTo: P1]);
+ Pbool([P1 conformsTo: P0]);
+ Pbool([P1 conformsTo: P2]);
+ Pbool([P2 conformsTo: P1]);
+ Pbool([P3 conformsTo: P1]);
+ Pbool([P1 conformsTo: P3]);
+
+ return 0;
+}
+
+// rdar://problem/7992749
+typedef Root<P1> P1Object;
+int test10() {
+ return [P1Object maxValue];
+}
diff --git a/clang/test/CodeGenObjC/rdr-6732143-dangling-block-reference.m b/clang/test/CodeGenObjC/rdr-6732143-dangling-block-reference.m
new file mode 100644
index 0000000..a93ca03
--- /dev/null
+++ b/clang/test/CodeGenObjC/rdr-6732143-dangling-block-reference.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fobjc-exceptions %s -o -
+
+void f0(id x) {
+ @synchronized (x) {
+ do { ; } while(0);
+ @try {
+ } @finally {
+ }
+ }
+}
diff --git a/clang/test/CodeGenObjC/related-result-type.m b/clang/test/CodeGenObjC/related-result-type.m
new file mode 100644
index 0000000..ef38661
--- /dev/null
+++ b/clang/test/CodeGenObjC/related-result-type.m
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+@interface NSObject
++ (id)alloc;
+- (id)init;
+- (id)retain;
+@end
+
+@interface NSString : NSObject
+@end
+
+// CHECK: define void @test1()
+void test1() {
+ // CHECK: {{call.*@objc_msgSend}}
+ // CHECK: {{call.*@objc_msgSend}}
+ // CHECK: {{call.*@objc_msgSend}}
+ // CHECK: bitcast i8*
+ NSString *str1 = [[[NSString alloc] init] retain];
+}
+
+// CHECK: define void @test2()
+void test2() {
+ // CHECK: {{call.*@objc_msgSend}}
+ // CHECK: {{call.*@objc_msgSend}}
+ // CHECK: {{call.*@objc_msgSend}}
+ // CHECK: bitcast i8*
+ NSString *str1 = NSString.alloc.init.retain;
+}
+
+@interface Test2 : NSString
+- (id)init;
+@end
+
+@implementation Test2
+// CHECK: define internal i8* @"\01-[Test2 init]"
+- (id)init {
+ // CHECK: {{call.*@objc_msgSendSuper}}
+ // CHECK-NEXT: bitcast i8*
+ return [super init];
+}
+@end
+
+@interface Test3 : NSString
+- (id)init;
+@end
+
+@implementation Test3
+// CHECK: define internal i8* @"\01-[Test3 init]"
+- (id)init {
+ // CHECK: {{call.*@objc_msgSendSuper}}
+ // CHECK-NEXT: bitcast i8*
+ return [super init];
+}
+@end
diff --git a/clang/test/CodeGenObjC/return-objc-object.mm b/clang/test/CodeGenObjC/return-objc-object.mm
new file mode 100644
index 0000000..95cce23
--- /dev/null
+++ b/clang/test/CodeGenObjC/return-objc-object.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64 -emit-llvm -o - %s | FileCheck %s
+
+@protocol P1 @end
+@interface NSOperationQueue
+{
+ char ch[64];
+ double d;
+}
+@end
+
+NSOperationQueue &f();
+NSOperationQueue<P1> &f1();
+
+void call_once() {
+ f();
+ f1();
+}
+// CHECK: call %0* @_Z1fv()
+// CHECK: call %0* @_Z2f1v()
diff --git a/clang/test/CodeGenObjC/runtime-fns.m b/clang/test/CodeGenObjC/runtime-fns.m
new file mode 100644
index 0000000..203d87f
--- /dev/null
+++ b/clang/test/CodeGenObjC/runtime-fns.m
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: grep -e "^de.*objc_msgSend[0-9]*(" %t | count 1
+// RUN: %clang_cc1 -DWITHDEF -emit-llvm -o %t %s
+// RUN: grep -e "^de.*objc_msgSend[0-9]*(" %t | count 1
+
+id objc_msgSend(int x);
+
+@interface A @end
+
+@implementation A
+-(void) f0 {
+ objc_msgSend(12);
+}
+
+-(void) hello {
+}
+@end
+
+void f0(id x) {
+ [x hello];
+}
+
+#ifdef WITHDEF
+// This isn't a very good send function.
+id objc_msgSend(int x) {
+ return 0;
+}
+
+// rdar://6800430
+void objc_assign_weak(id value, id *location) {
+}
+
+#endif
diff --git a/clang/test/CodeGenObjC/sel-as-builtin-type.m b/clang/test/CodeGenObjC/sel-as-builtin-type.m
new file mode 100644
index 0000000..72a8564
--- /dev/null
+++ b/clang/test/CodeGenObjC/sel-as-builtin-type.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// pr5025
+// radar 7405040
+
+typedef const struct objc_selector {
+ void *sel_id;
+ const char *sel_types;
+} *SEL;
+
+@interface I2
++(id) dictionary;
+@end
+
+@implementation I3; // expected-warning {{cannot find interface declaration for 'I3'}}
++(void) initialize {
+ I2 *a0 = [I2 dictionary];
+}
+@end
+
+int func(SEL s1, SEL s2)
+{
+ return s1->sel_id == s2->sel_id;
+}
diff --git a/clang/test/CodeGenObjC/selector-ref-invariance.m b/clang/test/CodeGenObjC/selector-ref-invariance.m
new file mode 100644
index 0000000..e356419
--- /dev/null
+++ b/clang/test/CodeGenObjC/selector-ref-invariance.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -emit-llvm -fblocks -o - %s | FileCheck %s
+
+// rdar://6027699
+
+void test(id x) {
+// CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_", !invariant.load
+// CHECK: @objc_msgSend
+ [x foo];
+}
diff --git a/clang/test/CodeGenObjC/simplify-exceptions.mm b/clang/test/CodeGenObjC/simplify-exceptions.mm
new file mode 100644
index 0000000..d0baf80
--- /dev/null
+++ b/clang/test/CodeGenObjC/simplify-exceptions.mm
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm \
+// RUN: -fexceptions -fobjc-exceptions \
+// RUN: -o %t %s
+// RUN: FileCheck < %t %s
+//
+// <rdar://problem/7471679> [irgen] [eh] Exception code built with clang (x86_64) crashes
+
+// Check that we don't emit unnecessary personality function references.
+struct t0_A { t0_A(); };
+struct t0_B { t0_A a; };
+
+// CHECK: define {{.*}} @_Z2t0v(){{.*}} {
+// CHECK-NOT: objc_personality
+// CHECK: }
+t0_B& t0() {
+ static t0_B x;
+ return x;
+}
diff --git a/clang/test/CodeGenObjC/stand-alone-implementation.m b/clang/test/CodeGenObjC/stand-alone-implementation.m
new file mode 100644
index 0000000..8245f01
--- /dev/null
+++ b/clang/test/CodeGenObjC/stand-alone-implementation.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-X86-64 %s
+
+// radar 7547942
+// Allow injection of ivars into implementation's implicit class.
+
+@implementation INTFSTANDALONE // expected-warning {{cannot find interface declaration for 'INTFSTANDALONE'}}
+{
+ id IVAR1;
+ id IVAR2;
+}
+- (id) Meth { return IVAR1; }
+@end
+
+// CHECK-X86-64: @"OBJC_IVAR_$_INTFSTANDALONE.IVAR1"
+// CHECK-X86-64: @"OBJC_IVAR_$_INTFSTANDALONE.IVAR2"
+
diff --git a/clang/test/CodeGenObjC/super-classmethod-category.m b/clang/test/CodeGenObjC/super-classmethod-category.m
new file mode 100644
index 0000000..c19663c
--- /dev/null
+++ b/clang/test/CodeGenObjC/super-classmethod-category.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@interface SUPER
++ (void)Meth;
+@end
+
+@interface CURRENT : SUPER
++ (void)Meth;
+@end
+
+@implementation CURRENT(CAT)
++ (void)Meth { [super Meth]; }
+@end
diff --git a/clang/test/CodeGenObjC/super-dotsyntax-property.m b/clang/test/CodeGenObjC/super-dotsyntax-property.m
new file mode 100644
index 0000000..9dfde2d
--- /dev/null
+++ b/clang/test/CodeGenObjC/super-dotsyntax-property.m
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@interface B
+{
+ int _parent;
+}
+@property int parent;
+ +(int) classGetter;
+ +(void) setClassGetter:(int) arg;
+
+ -(int) getter;
+ -(void) setGetter:(int)arg;
+@end
+
+@interface A : B
+@end
+
+@implementation A
++(int) classGetter {
+ return 0;
+}
+
++(int) classGetter2 {
+ super.classGetter = 100;
+ return super.classGetter;
+}
+
+-(void) method {
+ super.getter = 200;
+ int x = super.getter;
+}
+-(void) setParent : (int) arg {
+ super.parent = arg + super.parent;
+
+}
+@end
+
+void f0() {
+ int l1 = A.classGetter;
+ int l2 = [A classGetter2];
+}
diff --git a/clang/test/CodeGenObjC/super-dotsyntax-struct-property.m b/clang/test/CodeGenObjC/super-dotsyntax-struct-property.m
new file mode 100644
index 0000000..a7910a0
--- /dev/null
+++ b/clang/test/CodeGenObjC/super-dotsyntax-struct-property.m
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s
+// rdar: // 8203426
+
+
+typedef double CGFloat;
+struct CGPoint {
+ CGFloat x;
+ CGFloat y;
+};
+typedef struct CGPoint CGPoint;
+
+
+
+struct CGSize {
+ CGFloat width;
+ CGFloat height;
+};
+typedef struct CGSize CGSize;
+
+
+struct CGRect {
+ CGPoint origin;
+ CGSize size;
+};
+typedef struct CGRect CGRect;
+
+@interface UIView {
+}
+@property CGRect frame;
+@end
+
+@interface crashclass : UIView {
+
+}
+
+@end
+
+@implementation crashclass
+- (void)setFrame:(CGRect)frame
+{
+ super.frame = frame;
+ [super setFrame:frame];
+}
+
+@end
+// CHECK-NOT: declare void @objc_msgSendSuper2_stret
+// CHECK: declare i8* @objc_msgSendSuper2
diff --git a/clang/test/CodeGenObjC/super-message-fragileabi.m b/clang/test/CodeGenObjC/super-message-fragileabi.m
new file mode 100644
index 0000000..0135919
--- /dev/null
+++ b/clang/test/CodeGenObjC/super-message-fragileabi.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm %s -o - | FileCheck %s
+
+@class Some;
+
+@protocol Proto
+- (id)initSome:(Some *)anArg;
+@end
+
+
+@interface Table <Proto>
+@end
+
+@interface BetterTable: Table
+
+- (id)initSome:(Some *)arg;
+
+@end
+
+@implementation BetterTable
+
+- (id)initSome:(Some *)arg {
+
+ if(self=[super initSome:arg])
+ {
+ ;
+ }
+// CHECK: load %struct._objc_class** getelementptr inbounds (%struct._objc_class* @"\01L_OBJC_CLASS_BetterTable", i32 0, i32 1)
+
+ return self;
+}
+@end
+
diff --git a/clang/test/CodeGenObjC/synchronized.m b/clang/test/CodeGenObjC/synchronized.m
new file mode 100644
index 0000000..4997bb7
--- /dev/null
+++ b/clang/test/CodeGenObjC/synchronized.m
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 -emit-llvm -triple i686-apple-darwin9 -fobjc-fragile-abi -o - %s -O2 | FileCheck %s
+
+@interface MyClass
+{
+}
+- (void)method;
+@end
+
+@implementation MyClass
+
+// CHECK: define internal void @"\01-[MyClass method]"
+- (void)method
+{
+ // CHECK: call void @objc_sync_enter
+ // CHECK: call void @objc_exception_try_enter
+ // CHECK: call i32 @_setjmp
+ @synchronized(self) {
+ }
+}
+
+@end
+
+// CHECK: define void @foo(
+void foo(id a) {
+ // CHECK: [[A:%.*]] = alloca i8*
+ // CHECK: [[SYNC:%.*]] = alloca i8*
+
+ // CHECK: store i8* [[AVAL:%.*]], i8** [[A]]
+ // CHECK-NEXT: call void @objc_sync_enter(i8* [[AVAL]])
+ // CHECK-NEXT: store i8* [[AVAL]], i8** [[SYNC]]
+ // CHECK-NEXT: call void @objc_exception_try_enter
+ // CHECK: call i32 @_setjmp
+ @synchronized(a) {
+ // This is unreachable, but the optimizers can't know that.
+ // CHECK: call void asm sideeffect "", "=*m,=*m,=*m"(i8** [[A]], i8** [[SYNC]]
+ // CHECK: call void @objc_sync_exit
+ // CHECK: call i8* @objc_exception_extract
+ // CHECK: call void @objc_exception_throw
+ // CHECK: unreachable
+
+ // CHECK: call void @objc_exception_try_exit
+ // CHECK: [[T:%.*]] = load i8** [[SYNC]]
+ // CHECK-NEXT: call void @objc_sync_exit
+ // CHECK: ret void
+ return;
+ }
+
+}
+
+// CHECK: define i32 @f0(
+int f0(id a) {
+ // TODO: we can optimize the ret to a constant if we can figure out
+ // either that x isn't stored to within the synchronized block or
+ // that the synchronized block can't longjmp.
+
+ // CHECK: [[X:%.*]] = alloca i32
+ // CHECK: store i32 1, i32* [[X]]
+ int x = 0;
+ @synchronized((x++, a)) {
+ }
+
+ // CHECK: [[T:%.*]] = load i32* [[X]]
+ // CHECK: ret i32 [[T]]
+ return x;
+}
+
+// CHECK: define void @f1(
+void f1(id a) {
+ // Check that the return doesn't go through the cleanup.
+ extern void opaque(void);
+ opaque();
+
+ // CHECK: call void @opaque()
+ // CHECK-NEXT: ret void
+
+ @synchronized(({ return; }), a) {
+ return;
+ }
+}
diff --git a/clang/test/CodeGenObjC/synthesize_ivar-cont-class.m b/clang/test/CodeGenObjC/synthesize_ivar-cont-class.m
new file mode 100644
index 0000000..6bc7ac8
--- /dev/null
+++ b/clang/test/CodeGenObjC/synthesize_ivar-cont-class.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: grep '@"OBJC_IVAR_$_XCOrganizerDeviceNodeInfo.viewController"' %t
+
+@interface XCOrganizerNodeInfo
+@property (readonly, retain) id viewController;
+@end
+
+@interface XCOrganizerDeviceNodeInfo : XCOrganizerNodeInfo
+@end
+
+@interface XCOrganizerDeviceNodeInfo()
+@property (retain) id viewController;
+@end
+
+@implementation XCOrganizerDeviceNodeInfo
+@synthesize viewController;
+@end
+
diff --git a/clang/test/CodeGenObjC/synthesize_ivar.m b/clang/test/CodeGenObjC/synthesize_ivar.m
new file mode 100644
index 0000000..e4fbe10
--- /dev/null
+++ b/clang/test/CodeGenObjC/synthesize_ivar.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+
+@interface I
+@property int IP;
+@end
+
+@implementation I
+@synthesize IP;
+- (int) Meth {
+ return IP;
+}
+@end
+
+// Test for synthesis of ivar for a property
+// declared in continuation class.
+@interface OrganizerViolatorView
+@end
+
+@interface OrganizerViolatorView()
+@property (retain) id bindingInfo;
+@end
+
+@implementation OrganizerViolatorView
+@synthesize bindingInfo;
+@end
+
+// <rdar://problem/7336352> [irgen] crash in synthesized property construction
+
+@interface I0 @end
+@protocol P0 @end
+@interface I1 {
+ I0<P0> *iv0;
+}
+@property (assign, readwrite) id p0;
+@end
+@implementation I1
+@synthesize p0 = iv0;
+@end
diff --git a/clang/test/CodeGenObjC/terminate.m b/clang/test/CodeGenObjC/terminate.m
new file mode 100644
index 0000000..a862058
--- /dev/null
+++ b/clang/test/CodeGenObjC/terminate.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -fexceptions -fobjc-exceptions -fobjc-runtime-has-terminate -o - %s | FileCheck %s -check-prefix=CHECK-WITH
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck %s -check-prefix=CHECK-WITHOUT
+
+void destroy(void**);
+
+// rdar://problem/9519113
+void test0(void) {
+ void test0_helper(void);
+ void *ptr __attribute__((cleanup(destroy)));
+ test0_helper();
+
+ // CHECK-WITH: define void @test0()
+ // CHECK-WITH: [[PTR:%.*]] = alloca i8*,
+ // CHECK-WITH: call void @destroy(i8** [[PTR]])
+ // CHECK-WITH-NEXT: ret void
+ // CHECK-WITH: invoke void @destroy(i8** [[PTR]])
+ // CHECK-WITH: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gcc_personality_v0 to i8*)
+ // CHECK-WITH-NEXT: catch i8* null
+ // CHECK-WITH-NEXT: call void @objc_terminate()
+
+ // CHECK-WITHOUT: define void @test0()
+ // CHECK-WITHOUT: [[PTR:%.*]] = alloca i8*,
+ // CHECK-WITHOUT: call void @destroy(i8** [[PTR]])
+ // CHECK-WITHOUT-NEXT: ret void
+ // CHECK-WITHOUT: invoke void @destroy(i8** [[PTR]])
+ // CHECK-WITHOUT: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gcc_personality_v0 to i8*)
+ // CHECK-WITHOUT-NEXT: catch i8* null
+ // CHECK-WITHOUT-NEXT: call void @abort()
+}
diff --git a/clang/test/CodeGenObjC/try.m b/clang/test/CodeGenObjC/try.m
new file mode 100644
index 0000000..56b8e64
--- /dev/null
+++ b/clang/test/CodeGenObjC/try.m
@@ -0,0 +1,10 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
+// RUN: %clang_cc1 %s -fobjc-exceptions -S -o - -triple=i686-apple-darwin9
+// RUN: %clang_cc1 %s -fobjc-exceptions -S -o - -triple=x86_64-apple-darwin9
+
+// rdar://6757213 - Don't crash if the internal proto for
+// __objc_personality_v0 mismatches with an actual one.
+void __objc_personality_v0() { }
+void test1(void) {
+ @try { } @catch (...) { }
+}
diff --git a/clang/test/CodeGenObjC/undefined-protocol.m b/clang/test/CodeGenObjC/undefined-protocol.m
new file mode 100644
index 0000000..d87a5c9
--- /dev/null
+++ b/clang/test/CodeGenObjC/undefined-protocol.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -emit-llvm-only -fgnu-runtime %s
+
+@protocol MadeUpProtocol;
+
+@interface Object <MadeUpProtocol> @end
+@implementation Object @end
diff --git a/clang/test/CodeGenObjC/unname-bf-metadata.m b/clang/test/CodeGenObjC/unname-bf-metadata.m
new file mode 100644
index 0000000..c1208c1
--- /dev/null
+++ b/clang/test/CodeGenObjC/unname-bf-metadata.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm -o %t %s
+// Test that meta-data for ivar lists with unnamed bitfield are generated.
+//
+@interface Foo {
+@private
+ int first;
+ int :1;
+ int third :1;
+ int :1;
+ int fifth :1;
+}
+@end
+@implementation Foo
+@end
diff --git a/clang/test/CodeGenObjC/variadic-sends.m b/clang/test/CodeGenObjC/variadic-sends.m
new file mode 100644
index 0000000..94d7baf
--- /dev/null
+++ b/clang/test/CodeGenObjC/variadic-sends.m
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-X86-32 %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-X86-64 %s
+
+@interface A
+-(void) im0;
+-(void) im1: (int) x;
+-(void) im2: (int) x, ...;
+@end
+
+void f0(A *a) {
+ // CHECK-X86-32: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*)*)
+ // CHECK-X86-64: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*)*)
+ [a im0];
+}
+
+void f1(A *a) {
+ // CHECK-X86-32: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i32)*)
+ // CHECK-X86-64: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i32)*)
+ [a im1: 1];
+}
+
+void f2(A *a) {
+ // CHECK-X86-32: call void (i8*, i8*, i32, ...)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i32, ...)*)
+ // CHECK-X86-64: call void (i8*, i8*, i32, ...)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i32, ...)*)
+ [a im2: 1, 2];
+}
+
+@interface B : A @end
+@implementation B : A
+-(void) foo {
+ // CHECK-X86-32: call void bitcast (i8* (%struct._objc_super*, i8*, ...)* @objc_msgSendSuper to void (%struct._objc_super*, i8*, i32)*)
+ // CHECK-X86-64: call void bitcast (i8* (%struct._objc_super*, i8*, ...)* @objc_msgSendSuper to void (%struct._objc_super*, i8*, i32)*)
+ [super im1: 1];
+}
+-(void) bar {
+ // CHECK-X86-32: call void (%struct._objc_super*, i8*, i32, ...)* bitcast (i8* (%struct._objc_super*, i8*, ...)* @objc_msgSendSuper to void (%struct._objc_super*, i8*, i32, ...)*)
+ // CHECK-X86-64: call void (%struct._objc_super*, i8*, i32, ...)* bitcast (i8* (%struct._objc_super*, i8*, ...)* @objc_msgSendSuper to void (%struct._objc_super*, i8*, i32, ...)*)
+ [super im2: 1, 2];
+}
+
+@end
diff --git a/clang/test/CodeGenObjC/x86_64-struct-return-gc.m b/clang/test/CodeGenObjC/x86_64-struct-return-gc.m
new file mode 100644
index 0000000..76407d6
--- /dev/null
+++ b/clang/test/CodeGenObjC/x86_64-struct-return-gc.m
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o - %s | FileCheck %s
+struct Coerce {
+ id a;
+};
+
+struct Coerce coerce_func(void);
+
+// CHECK: define void @Coerce_test()
+void Coerce_test(void) {
+ struct Coerce c;
+
+ // CHECK: call i8* @coerce_func
+ // CHECK: call i8* @objc_memmove_collectable(
+ c = coerce_func();
+}
+
+struct Indirect {
+ id a;
+ int b[10];
+};
+
+struct Indirect indirect_func(void);
+
+// CHECK: define void @Indirect_test()
+void Indirect_test(void) {
+ struct Indirect i;
+
+ // CHECK: call void @indirect_func(%struct.Indirect* sret
+ // CHECK: call i8* @objc_memmove_collectable(
+ i = indirect_func();
+}
diff --git a/clang/test/CodeGenObjCXX/2007-10-03-MetadataPointers.mm b/clang/test/CodeGenObjCXX/2007-10-03-MetadataPointers.mm
new file mode 100644
index 0000000..2564d67
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/2007-10-03-MetadataPointers.mm
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o /dev/null
+
+@class NSImage;
+void bork() {
+ NSImage *nsimage;
+ [nsimage release];
+}
diff --git a/clang/test/CodeGenObjCXX/2010-08-04-Template.mm b/clang/test/CodeGenObjCXX/2010-08-04-Template.mm
new file mode 100644
index 0000000..c53e3cb
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/2010-08-04-Template.mm
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+struct TRunSoon {
+ template <class P1> static void Post() {}
+};
+
+@implementation TPrivsTableViewMainController
+- (void) applyToEnclosed {
+ TRunSoon::Post<int>();
+}
+@end
diff --git a/clang/test/CodeGenObjCXX/2010-08-06-X.Y-syntax.mm b/clang/test/CodeGenObjCXX/2010-08-06-X.Y-syntax.mm
new file mode 100644
index 0000000..290aaf6
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/2010-08-06-X.Y-syntax.mm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm %s -o -
+struct TFENode {
+ TFENode(const TFENode& inNode);
+};
+
+@interface TIconViewController
+- (const TFENode&) target;
+@end
+
+void sortAllChildrenForNode(const TFENode&node);
+
+@implementation TIconViewController
+- (void) setArrangeBy {
+ sortAllChildrenForNode(self.target);
+}
+@end
diff --git a/clang/test/CodeGenObjCXX/Inputs/literal-support.h b/clang/test/CodeGenObjCXX/Inputs/literal-support.h
new file mode 100644
index 0000000..5680a20
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/Inputs/literal-support.h
@@ -0,0 +1,35 @@
+#ifndef OBJC_LITERAL_SUPPORT_H
+#define OBJC_LITERAL_SUPPORT_H
+
+typedef unsigned char BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
++ (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;
+@end
+
+@interface NSArray
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+#endif // OBJC_LITERAL_SUPPORT_H
diff --git a/clang/test/CodeGenObjCXX/address-safety-attr.mm b/clang/test/CodeGenObjCXX/address-safety-attr.mm
new file mode 100644
index 0000000..a54ca99
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/address-safety-attr.mm
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - %s -faddress-sanitizer | FileCheck -check-prefix ASAN %s
+
+@interface MyClass
++ (int) addressSafety:(int*)a;
+@end
+
+@implementation MyClass
+
+// CHECK-NOT: +[MyClass load]{{.*}} address_safety
+// CHECK: +[MyClass load]{{.*}}
+// ASAN: +[MyClass load]{{.*}} address_safety
++(void) load { }
+
+// CHECK-NOT: +[MyClass addressSafety:]{{.*}} address_safety
+// CHECK: +[MyClass addressSafety:]{{.*}}
+// ASAN: +[MyClass addressSafety:]{{.*}} address_safety
++ (int) addressSafety:(int*)a { return *a; }
+
+@end
diff --git a/clang/test/CodeGenObjCXX/arc-exceptions.mm b/clang/test/CodeGenObjCXX/arc-exceptions.mm
new file mode 100644
index 0000000..b1fa8ca
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/arc-exceptions.mm
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime-has-weak -o - %s | FileCheck %s
+
+@class Ety;
+
+// These first four tests are all PR11732 / rdar://problem/10667070.
+
+void test0_helper(void);
+void test0(void) {
+ @try {
+ test0_helper();
+ } @catch (Ety *e) {
+ }
+}
+// CHECK: define void @_Z5test0v()
+// CHECK: [[E:%.*]] = alloca [[ETY:%.*]]*, align 8
+// CHECK-NEXT: invoke void @_Z12test0_helperv()
+// CHECK: [[T0:%.*]] = call i8* @objc_begin_catch(
+// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[ETY]]*
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[ETY]]* [[T1]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retain(i8* [[T2]]) nounwind
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to [[ETY]]*
+// CHECK-NEXT: store [[ETY]]* [[T4]], [[ETY]]** [[E]]
+// CHECK-NEXT: [[T0:%.*]] = load [[ETY]]** [[E]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[ETY]]* [[T0]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind
+// CHECK-NEXT: call void @objc_end_catch() nounwind
+
+void test1_helper(void);
+void test1(void) {
+ @try {
+ test1_helper();
+ } @catch (__weak Ety *e) {
+ }
+}
+// CHECK: define void @_Z5test1v()
+// CHECK: [[E:%.*]] = alloca [[ETY:%.*]]*, align 8
+// CHECK-NEXT: invoke void @_Z12test1_helperv()
+// CHECK: [[T0:%.*]] = call i8* @objc_begin_catch(
+// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[ETY]]*
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[ETY]]** [[E]] to i8**
+// CHECK-NEXT: [[T3:%.*]] = bitcast [[ETY]]* [[T1]] to i8*
+// CHECK-NEXT: call i8* @objc_initWeak(i8** [[T2]], i8* [[T3]]) nounwind
+// CHECK-NEXT: [[T0:%.*]] = bitcast [[ETY]]** [[E]] to i8**
+// CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]]) nounwind
+// CHECK-NEXT: call void @objc_end_catch() nounwind
+
+void test2_helper(void);
+void test2(void) {
+ try {
+ test2_helper();
+ } catch (Ety *e) {
+ }
+}
+// CHECK: define void @_Z5test2v()
+// CHECK: [[E:%.*]] = alloca [[ETY:%.*]]*, align 8
+// CHECK-NEXT: invoke void @_Z12test2_helperv()
+// CHECK: [[T0:%.*]] = call i8* @__cxa_begin_catch(
+// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[ETY]]*
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[ETY]]* [[T1]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retain(i8* [[T2]]) nounwind
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to [[ETY]]*
+// CHECK-NEXT: store [[ETY]]* [[T4]], [[ETY]]** [[E]]
+// CHECK-NEXT: [[T0:%.*]] = load [[ETY]]** [[E]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[ETY]]* [[T0]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind
+// CHECK-NEXT: call void @__cxa_end_catch() nounwind
+
+void test3_helper(void);
+void test3(void) {
+ try {
+ test3_helper();
+ } catch (Ety * __weak e) {
+ }
+}
+// CHECK: define void @_Z5test3v()
+// CHECK: [[E:%.*]] = alloca [[ETY:%.*]]*, align 8
+// CHECK-NEXT: invoke void @_Z12test3_helperv()
+// CHECK: [[T0:%.*]] = call i8* @__cxa_begin_catch(
+// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[ETY]]*
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[ETY]]** [[E]] to i8**
+// CHECK-NEXT: [[T3:%.*]] = bitcast [[ETY]]* [[T1]] to i8*
+// CHECK-NEXT: call i8* @objc_initWeak(i8** [[T2]], i8* [[T3]]) nounwind
+// CHECK-NEXT: [[T0:%.*]] = bitcast [[ETY]]** [[E]] to i8**
+// CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]]) nounwind
+// CHECK-NEXT: call void @__cxa_end_catch() nounwind
diff --git a/clang/test/CodeGenObjCXX/arc-globals.mm b/clang/test/CodeGenObjCXX/arc-globals.mm
new file mode 100644
index 0000000..958d1d8
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/arc-globals.mm
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+
+// Test that we're properly retaining lifetime-qualified pointers
+// initialized statically and wrapping up those initialization in an
+// autorelease pool.
+id getObject();
+
+// CHECK: define internal void @__cxx_global_var_init
+// CHECK: call i8* @_Z9getObjectv
+// CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue
+// CHECK-NEXT: {{store i8*.*@global_obj}}
+// CHECK-NEXT: ret void
+id global_obj = getObject();
+
+// CHECK: define internal void @__cxx_global_var_init
+// CHECK: call i8* @_Z9getObjectv
+// CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue
+// CHECK-NEXT: {{store i8*.*@global_obj2}}
+// CHECK-NEXT: ret void
+id global_obj2 = getObject();
+
+// CHECK: define internal void @_GLOBAL__I_a
+// CHECK: call i8* @objc_autoreleasePoolPush()
+// CHECK-NEXT: call void @__cxx_global_var_init
+// CHECK-NEXT: call void @__cxx_global_var_init1
+// CHECK-NEXT: call void @objc_autoreleasePoolPop(
+// CHECK-NEXT: ret void
diff --git a/clang/test/CodeGenObjCXX/arc-mangle.mm b/clang/test/CodeGenObjCXX/arc-mangle.mm
new file mode 100644
index 0000000..c2b5817
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/arc-mangle.mm
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @_Z1fPU8__strongP11objc_object(i8**)
+void f(__strong id *) {}
+// CHECK: define void @_Z1fPU6__weakP11objc_object(i8**)
+void f(__weak id *) {}
+// CHECK: define void @_Z1fPU15__autoreleasingP11objc_object(i8**)
+void f(__autoreleasing id *) {}
+// CHECK: define void @_Z1fPP11objc_object(i8**)
+void f(__unsafe_unretained id *) {}
+// CHECK: define void @_Z1fPKU8__strongP11objc_object(i8**)
+void f(const __strong id *) {}
+// CHECK: define void @_Z1fPKU6__weakP11objc_object(i8**)
+void f(const __weak id *) {}
+// CHECK: define void @_Z1fPKU15__autoreleasingP11objc_object(i8**)
+void f(const __autoreleasing id *) {}
+// CHECK: define void @_Z1fPKP11objc_object(i8**)
+void f(const __unsafe_unretained id *) {}
+
+
+template<unsigned N> struct unsigned_c { };
+
+// CHECK: define weak_odr void @_Z1gIKvEvP10unsigned_cIXplszv1U8__bridgecvPT_v1U8__bridgecvP11objc_objectcvS3_Li0ELi1EEE
+template<typename T>void g(unsigned_c<sizeof((__bridge T*)(__bridge id)(T*)0) + 1>*) {}
+template void g<const void>(unsigned_c<sizeof(id) + 1> *);
diff --git a/clang/test/CodeGenObjCXX/arc-move.mm b/clang/test/CodeGenObjCXX/arc-move.mm
new file mode 100644
index 0000000..cf3051d
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/arc-move.mm
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -O2 -std=c++11 -disable-llvm-optzns -o - %s | FileCheck %s
+
+// define void @_Z11simple_moveRU8__strongP11objc_objectS2_
+void simple_move(__strong id &x, __strong id &y) {
+ // CHECK: = load i8**
+ // CHECK: store i8* null
+ // CHECK: = load i8**
+ // CHECK: store i8*
+ // CHECK-NEXT: call void @objc_release
+ x = static_cast<__strong id&&>(y);
+ // CHECK-NEXT: ret void
+}
+
+template<typename T>
+struct remove_reference {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_reference<T&> {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_reference<T&&> {
+ typedef T type;
+};
+
+template<typename T>
+typename remove_reference<T>::type&& move(T &&x) {
+ return static_cast<typename remove_reference<T>::type&&>(x);
+}
+
+// CHECK: define void @_Z12library_moveRU8__strongP11objc_objectS2_
+void library_move(__strong id &x, __strong id &y) {
+ // CHECK: call i8** @_Z4moveIRU8__strongP11objc_objectEON16remove_referenceIT_E4typeEOS5_
+ // CHECK: load i8**
+ // CHECK: store i8* null, i8**
+ // CHECK: load i8***
+ // CHECK-NEXT: load i8**
+ // CHECK-NEXT: store i8*
+ // CHECK-NEXT: call void @objc_release
+ // CHECK-NEXT: ret void
+ x = move(y);
+}
+
+// CHECK: define void @_Z12library_moveRU8__strongP11objc_object
+void library_move(__strong id &y) {
+ // CHECK: [[Y:%[a-zA-Z0-9]+]] = call i8** @_Z4moveIRU8__strongP11objc_objectEON16remove_referenceIT_E4typeEOS5_
+ // Load the object
+ // CHECK-NEXT: [[OBJ:%[a-zA-Z0-9]+]] = load i8** [[Y]]
+ // Null out y
+ // CHECK-NEXT: store i8* null, i8** [[Y]]
+ // Initialize x with the object
+ // CHECK-NEXT: store i8* [[OBJ]], i8** [[X:%[a-zA-Z0-9]+]]
+ id x = move(y);
+
+ // CHECK-NEXT: store i32 17
+ int i = 17;
+ // CHECK-NEXT: [[OBJ:%[a-zA-Z0-9]+]] = load i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[OBJ]])
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @_Z10const_moveRKU8__strongP11objc_object(
+void const_move(const __strong id &x) {
+ // CHECK: [[Y:%.*]] = alloca i8*,
+ // CHECK: [[X:%.*]] = call i8** @_Z4moveIRKU8__strongP11objc_objectEON16remove_referenceIT_E4typeEOS5_(
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
+ // CHECK-NEXT: store i8* [[T1]], i8** [[Y]]
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[Y]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ id y = move(x);
+}
diff --git a/clang/test/CodeGenObjCXX/arc-new-delete.mm b/clang/test/CodeGenObjCXX/arc-new-delete.mm
new file mode 100644
index 0000000..a778bca
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/arc-new-delete.mm
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -fblocks -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s | FileCheck %s
+
+typedef __strong id strong_id;
+typedef __weak id weak_id;
+
+// CHECK: define void @_Z8test_newP11objc_object
+void test_new(id invalue) {
+ // CHECK: alloca i8*
+ // CHECK-NEXT: call i8* @objc_retain
+
+ // CHECK: call noalias i8* @_Znwm
+ // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
+ // CHECK-NEXT: store i8* null, i8**
+ new strong_id;
+ // CHECK: call noalias i8* @_Znwm
+ // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
+ // CHECK-NEXT: store i8* null, i8**
+ new weak_id;
+
+ // CHECK: call noalias i8* @_Znwm
+ // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
+ // CHECK-NEXT: store i8* null, i8**
+ new __strong id;
+ // CHECK: call noalias i8* @_Znwm
+ // CHECK-NEXT: {{bitcast i8\*.*to i8\*\*}}
+ // CHECK-NEXT: store i8* null, i8**
+ new __weak id;
+
+ // CHECK: call noalias i8* @_Znwm
+ // CHECK: call i8* @objc_retain
+ // CHECK: store i8*
+ new __strong id(invalue);
+
+ // CHECK: call noalias i8* @_Znwm
+ // CHECK: call i8* @objc_initWeak
+ new __weak id(invalue);
+
+ // CHECK: call void @objc_release
+ // CHECK: ret void
+}
+
+// CHECK: define void @_Z14test_array_new
+void test_array_new() {
+ // CHECK: call noalias i8* @_Znam
+ // CHECK: store i64 17, i64*
+ // CHECK: call void @llvm.memset.p0i8.i64
+ new strong_id[17];
+
+ // CHECK: call noalias i8* @_Znam
+ // CHECK: store i64 17, i64*
+ // CHECK: call void @llvm.memset.p0i8.i64
+ new weak_id[17];
+ // CHECK: ret void
+}
+
+// CHECK: define void @_Z11test_deletePU8__strongP11objc_objectPU6__weakS0_
+void test_delete(__strong id *sptr, __weak id *wptr) {
+ // CHECK: br i1
+ // CHECK: load i8**
+ // CHECK-NEXT: call void @objc_release
+ // CHECK: call void @_ZdlPv
+ delete sptr;
+
+ // CHECK: call void @objc_destroyWeak
+ // CHECK: call void @_ZdlPv
+ delete wptr;
+
+ // CHECK: ret void
+}
+
+// CHECK: define void @_Z17test_array_deletePU8__strongP11objc_objectPU6__weakS0_
+void test_array_delete(__strong id *sptr, __weak id *wptr) {
+ // CHECK: icmp eq i8** [[BEGIN:%.*]], null
+ // CHECK: [[LEN:%.*]] = load i64* {{%.*}}
+ // CHECK: [[END:%.*]] = getelementptr inbounds i8** [[BEGIN]], i64 [[LEN]]
+ // CHECK-NEXT: icmp eq i8** [[BEGIN]], [[END]]
+ // CHECK: [[PAST:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]],
+ // CHECK-NEXT: [[CUR]] = getelementptr inbounds i8** [[PAST]], i64 -1
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[CUR]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: icmp eq i8** [[CUR]], [[BEGIN]]
+ // CHECK: call void @_ZdaPv
+ delete [] sptr;
+
+ // CHECK: icmp eq i8** [[BEGIN:%.*]], null
+ // CHECK: [[LEN:%.*]] = load i64* {{%.*}}
+ // CHECK: [[END:%.*]] = getelementptr inbounds i8** [[BEGIN]], i64 [[LEN]]
+ // CHECK-NEXT: icmp eq i8** [[BEGIN]], [[END]]
+ // CHECK: [[PAST:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]],
+ // CHECK-NEXT: [[CUR]] = getelementptr inbounds i8** [[PAST]], i64 -1
+ // CHECK-NEXT: call void @objc_destroyWeak(i8** [[CUR]])
+ // CHECK-NEXT: icmp eq i8** [[CUR]], [[BEGIN]]
+ // CHECK: call void @_ZdaPv
+ delete [] wptr;
+}
diff --git a/clang/test/CodeGenObjCXX/arc-pseudo-destructors.mm b/clang/test/CodeGenObjCXX/arc-pseudo-destructors.mm
new file mode 100644
index 0000000..2f8d9e1
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/arc-pseudo-destructors.mm
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -fblocks -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @_Z28test_objc_object_pseudo_dtorPU8__strongP11objc_objectPU6__weakS0_
+void test_objc_object_pseudo_dtor(__strong id *ptr, __weak id *wptr) {
+ // CHECK: load i8***
+ // CHECK-NEXT: load i8**
+ // CHECK-NEXT: call void @objc_release
+ ptr->~id();
+
+ // CHECK: call void @objc_destroyWeak(i8** {{%.*}})
+ wptr->~id();
+
+ // CHECK: load i8***
+ // CHECK-NEXT: load i8**
+ // CHECK-NEXT: call void @objc_release
+ (*ptr).~id();
+
+ // CHECK: call void @objc_destroyWeak(i8** {{%.*}})
+ (*wptr).~id();
+ // CHECK: ret void
+}
diff --git a/clang/test/CodeGenObjCXX/arc-references.mm b/clang/test/CodeGenObjCXX/arc-references.mm
new file mode 100644
index 0000000..954c02a
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/arc-references.mm
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+
+@interface A
+@end
+
+id getObject();
+void callee();
+
+// Lifetime extension for binding a reference to an rvalue
+// CHECK: define void @_Z5test0v()
+void test0() {
+ // CHECK: call i8* @_Z9getObjectv
+ // CHECK-NEXT:: call i8* @objc_retainAutoreleasedReturnValue
+ const __strong id &ref1 = getObject();
+ // CHECK: call void @_Z6calleev
+ callee();
+ // CHECK: call i8* @_Z9getObjectv
+ // CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue
+ // CHECK-NEXT: call i8* @objc_autorelease
+ const __autoreleasing id &ref2 = getObject();
+ // CHECK: call void @_Z6calleev
+ callee();
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret
+}
+
+// No lifetime extension when we're binding a reference to an lvalue.
+// CHECK: define void @_Z5test1RU8__strongP11objc_objectRU6__weakS0_
+void test1(__strong id &x, __weak id &y) {
+ // CHECK-NOT: release
+ const __strong id &ref1 = x;
+ const __autoreleasing id &ref2 = x;
+ const __weak id &ref3 = y;
+ // CHECK: ret void
+}
+
+typedef __strong id strong_id;
+
+//CHECK: define void @_Z5test3v
+void test3() {
+ // CHECK: call i8* @objc_initWeak
+ // CHECK-NEXT: store i8**
+ const __weak id &ref = strong_id();
+ // CHECK-NEXT: call void @_Z6calleev()
+ callee();
+ // CHECK-NEXT: call void @objc_destroyWeak
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @_Z5test4RU8__strongP11objc_object
+void test4(__strong id &x) {
+ // CHECK: call i8* @objc_retain
+ __strong A* const &ar = x;
+ // CHECK: store i32 17, i32*
+ int i = 17;
+ // CHECK: call void @objc_release(
+ // CHECK: ret void
+}
+
+void sink(__strong A* &&);
+
+// CHECK: define void @_Z5test5RU8__strongP11objc_object
+void test5(__strong id &x) {
+ // CHECK: [[REFTMP:%.*]] = alloca {{%.*}}*, align 8
+ // CHECK: [[OBJ_ID:%.*]] = call i8* @objc_retain(
+ // CHECK-NEXT: [[OBJ_A:%.*]] = bitcast i8* [[OBJ_ID]] to [[A:%[a-zA-Z0-9]+]]*
+ // CHECK-NEXT: store [[A]]* [[OBJ_A]], [[A]]** [[REFTMP:%[a-zA-Z0-9]+]]
+ // CHECK-NEXT: call void @_Z4sinkOU8__strongP1A
+ sink(x);
+ // CHECK-NEXT: [[OBJ_A:%[a-zA-Z0-9]+]] = load [[A]]** [[REFTMP]]
+ // CHECK-NEXT: [[OBJ_ID:%[a-zA-Z0-9]+]] = bitcast [[A]]* [[OBJ_A]] to i8*
+ // CHECK-NEXT: call void @objc_release
+ // CHECK-NEXT: store i32 17, i32
+ int i = 17;
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define internal void @__cxx_global_var_init(
+// CHECK: call i8* @_Z9getObjectv
+// CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue
+const __strong id &global_ref = getObject();
+
+// Note: we intentionally don't release the object.
+
diff --git a/clang/test/CodeGenObjCXX/arc-returns-inner-reference-ptr.mm b/clang/test/CodeGenObjCXX/arc-returns-inner-reference-ptr.mm
new file mode 100644
index 0000000..c4ab34e
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/arc-returns-inner-reference-ptr.mm
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -o - %s | FileCheck %s
+// rdar://10139365
+
+@interface Test58
+- (char* &) interior __attribute__((objc_returns_inner_pointer));
+- (int&)reference_to_interior_int __attribute__((objc_returns_inner_pointer));
+@end
+
+void foo() {
+ Test58 *ptr;
+ char *c = [(ptr) interior];
+
+ int i = [(ptr) reference_to_interior_int];
+}
+
+// CHECK: [[T0:%.*]] = load {{%.*}} {{%.*}}, align 8
+// CHECK: [[T1:%.*]] = bitcast {{%.*}} [[T0]] to i8*
+// call i8* @objc_retainAutorelease(i8* [[T1]]) nounwind
+// CHECK: [[T2:%.*]] = load {{%.*}} {{%.*}}, align 8
+// CHECK: [[T3:%.*]] = bitcast {{%.*}} [[T2]] to i8*
+// call i8* @objc_retainAutorelease(i8* [[T3]]) nounwind
+
diff --git a/clang/test/CodeGenObjCXX/arc-special-member-functions.mm b/clang/test/CodeGenObjCXX/arc-special-member-functions.mm
new file mode 100644
index 0000000..421a9fe
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/arc-special-member-functions.mm
@@ -0,0 +1,165 @@
+// RUN: %clang_cc1 -fobjc-arc -fblocks -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s | FileCheck %s
+
+struct ObjCMember {
+ id member;
+};
+
+struct ObjCArrayMember {
+ id member[2][3];
+};
+
+struct ObjCBlockMember {
+ int (^bp)(int);
+};
+
+// CHECK: define void @_Z42test_ObjCMember_default_construct_destructv(
+void test_ObjCMember_default_construct_destruct() {
+ // CHECK: call void @_ZN10ObjCMemberC1Ev
+ // CHECK: call void @_ZN10ObjCMemberD1Ev
+ ObjCMember m1;
+}
+
+// CHECK: define void @_Z39test_ObjCMember_copy_construct_destruct10ObjCMember
+void test_ObjCMember_copy_construct_destruct(ObjCMember m1) {
+ // CHECK: call void @_ZN10ObjCMemberC1ERKS_
+ // CHECK: call void @_ZN10ObjCMemberD1Ev
+ ObjCMember m2 = m1;
+ // CHECK: ret void
+}
+
+// CHECK: define void @_Z27test_ObjCMember_copy_assign10ObjCMemberS_
+void test_ObjCMember_copy_assign(ObjCMember m1, ObjCMember m2) {
+ // CHECK: {{call.*_ZN10ObjCMemberaSERKS_}}
+ m1 = m2;
+ // CHECK-NEXT: ret void
+}
+
+// Implicitly-generated copy assignment operator for ObjCMember
+// CHECK: {{define linkonce_odr.*@_ZN10ObjCMemberaSERKS_}}
+// CHECK: call void @objc_storeStrong
+// CHECK: ret
+
+// CHECK: define void @_Z47test_ObjCArrayMember_default_construct_destructv
+void test_ObjCArrayMember_default_construct_destruct() {
+ // CHECK: call void @_ZN15ObjCArrayMemberC1Ev
+ ObjCArrayMember m1;
+ // CHECK: call void @_ZN15ObjCArrayMemberD1Ev
+ // CHECK: ret void
+}
+
+// CHECK: define void @_Z44test_ObjCArrayMember_copy_construct_destruct15ObjCArrayMember
+void test_ObjCArrayMember_copy_construct_destruct(ObjCArrayMember m1) {
+ // CHECK: call void @_ZN15ObjCArrayMemberC1ERKS_
+ ObjCArrayMember m2 = m1;
+ // CHECK: call void @_ZN15ObjCArrayMemberD1Ev
+ // CHECK: ret void
+}
+
+void test_ObjCArrayMember_copy_assign(ObjCArrayMember m1, ObjCArrayMember m2) {
+ // CHECK: {{call.*@_ZN15ObjCArrayMemberaSERKS_}}
+ m1 = m2;
+ // CHECK-NEXT: ret void
+}
+
+// Implicitly-generated copy assignment operator for ObjCArrayMember
+// CHECK: {{define linkonce_odr.*@_ZN15ObjCArrayMemberaSERKS_}}
+// CHECK: call void @objc_storeStrong
+// CHECK-NEXT: br label
+// CHECK: ret
+
+// CHECK: define void @_Z47test_ObjCBlockMember_default_construct_destructv
+void test_ObjCBlockMember_default_construct_destruct() {
+ // CHECK: call void @_ZN15ObjCBlockMemberC1Ev
+ ObjCBlockMember m;
+ // CHECK-NEXT: call void @_ZN15ObjCBlockMemberD1Ev
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @_Z44test_ObjCBlockMember_copy_construct_destruct15ObjCBlockMember
+void test_ObjCBlockMember_copy_construct_destruct(ObjCBlockMember m1) {
+ // CHECK: call void @_ZN15ObjCBlockMemberC1ERKS_
+ ObjCBlockMember m2 = m1;
+ // CHECK-NEXT: call void @_ZN15ObjCBlockMemberD1Ev
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @_Z32test_ObjCBlockMember_copy_assign15ObjCBlockMemberS_
+void test_ObjCBlockMember_copy_assign(ObjCBlockMember m1, ObjCBlockMember m2) {
+ // CHECK: {{call.*_ZN15ObjCBlockMemberaSERKS_}}
+ m1 = m2;
+ // CHECK-NEXT: ret void
+}
+
+// Implicitly-generated copy assignment operator for ObjCBlockMember
+// CHECK: define linkonce_odr {{%.*}}* @_ZN15ObjCBlockMemberaSERKS_(
+// CHECK: [[T0:%.*]] = getelementptr inbounds [[T:%.*]]* {{%.*}}, i32 0, i32 0
+// CHECK-NEXT: [[T1:%.*]] = load i32 (i32)** [[T0]], align 8
+// CHECK-NEXT: [[T2:%.*]] = bitcast i32 (i32)* [[T1]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retainBlock(i8* [[T2]])
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to i32 (i32)*
+// CHECK-NEXT: [[T5:%.*]] = getelementptr inbounds [[T]]* {{%.*}}, i32 0, i32 0
+// CHECK-NEXT: [[T6:%.*]] = load i32 (i32)** [[T5]], align 8
+// CHECK-NEXT: store i32 (i32)* [[T4]], i32 (i32)** [[T5]]
+// CHECK-NEXT: [[T7:%.*]] = bitcast i32 (i32)* [[T6]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T7]])
+// CHECK-NEXT: ret
+
+// Implicitly-generated copy constructor for ObjCBlockMember
+// CHECK: define linkonce_odr void @_ZN15ObjCBlockMemberC2ERKS_
+// CHECK: call i8* @objc_retainBlock
+// CHECK: ret
+
+// Implicitly-generated destructor for ObjCBlockMember
+// CHECK: define linkonce_odr void @_ZN15ObjCBlockMemberD2Ev
+// CHECK: call void @objc_release(i8*
+// CHECK: ret
+
+// Implicitly-generated default constructor for ObjCBlockMember
+// CHECK: define linkonce_odr void @_ZN15ObjCBlockMemberC2Ev
+// CHECK: store {{.*}} null,
+// CHECK-NEXT: ret void
+
+// Implicitly-generated copy constructor for ObjCArrayMember
+// CHECK: define linkonce_odr void @_ZN15ObjCArrayMemberC2ERKS_
+// CHECK: br i1
+// CHECK: call i8* @objc_retain
+// CHECK-NEXT: store i8*
+// CHECK-NEXT: br label
+// CHECK: ret
+
+// Implicitly-generated destructor for ObjCArrayMember
+// CHECK: define linkonce_odr void @_ZN15ObjCArrayMemberD2Ev
+// CHECK: [[BEGIN:%.*]] = getelementptr inbounds [2 x [3 x i8*]]*
+// CHECK-NEXT: [[END:%.*]] = getelementptr inbounds i8** [[BEGIN]], i64 6
+// CHECK-NEXT: br label
+// CHECK: [[PAST:%.*]] = phi i8** [ [[END]], {{%.*}} ], [ [[CUR:%.*]], {{%.*}} ]
+// CHECK-NEXT: [[CUR]] = getelementptr inbounds i8** [[PAST]], i64 -1
+// CHECK-NEXT: [[T0:%.*]] = load i8** [[CUR]]
+// CHECK-NEXT: call void @objc_release(i8* [[T0]])
+// CHECK-NEXT: [[T1:%.*]] = icmp eq i8** [[CUR]], [[BEGIN]]
+// CHECK-NEXT: br i1 [[T1]],
+// CHECK: ret void
+
+// Implicitly-generated default constructor for ObjCArrayMember
+// CHECK: define linkonce_odr void @_ZN15ObjCArrayMemberC2Ev
+// CHECK: call void @llvm.memset.p0i8.i64
+// CHECK: ret
+
+// Implicitly-generated copy constructor for ObjCMember
+// CHECK: define linkonce_odr void @_ZN10ObjCMemberC2ERKS_
+// CHECK-NOT: objc_release
+// CHECK: call i8* @objc_retain
+// CHECK-NEXT: store i8*
+// CHECK-NEXT: ret void
+
+// Implicitly-generated destructor for ObjCMember
+// CHECK: define linkonce_odr void @_ZN10ObjCMemberD2Ev
+// CHECK: call void @objc_release
+// CHECK: ret void
+
+// Implicitly-generated default constructor for ObjCMember
+// CHECK: define linkonce_odr void @_ZN10ObjCMemberC2Ev
+// CHECK-NOT: objc_release
+// CHECK: store i8* null
+// CHECK-NEXT: ret void
+
diff --git a/clang/test/CodeGenObjCXX/arc.mm b/clang/test/CodeGenObjCXX/arc.mm
new file mode 100644
index 0000000..45211a2
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/arc.mm
@@ -0,0 +1,254 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+
+struct NSFastEnumerationState;
+@interface NSArray
+- (unsigned long) countByEnumeratingWithState: (struct NSFastEnumerationState*) state
+ objects: (id*) buffer
+ count: (unsigned long) bufferSize;
+@end;
+NSArray *nsarray() { return 0; }
+// CHECK: define [[NSARRAY:%.*]]* @_Z7nsarrayv()
+
+void use(id);
+
+// rdar://problem/9315552
+// The analogous ObjC testcase test46 in arr.m.
+void test0(__weak id *wp, __weak volatile id *wvp) {
+ extern id test0_helper(void);
+
+ // TODO: this is sub-optimal, we should retain at the actual call site.
+ // TODO: in the non-volatile case, we do not need to be reloading.
+
+ // CHECK: [[T0:%.*]] = call i8* @_Z12test0_helperv()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: [[T2:%.*]] = load i8*** {{%.*}}, align 8
+ // CHECK-NEXT: [[T3:%.*]] = call i8* @objc_storeWeak(i8** [[T2]], i8* [[T1]])
+ // CHECK-NEXT: [[T4:%.*]] = call i8* @objc_retain(i8* [[T3]])
+ // CHECK-NEXT: store i8* [[T4]], i8**
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ id x = *wp = test0_helper();
+
+ // CHECK: [[T0:%.*]] = call i8* @_Z12test0_helperv()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: [[T2:%.*]] = load i8*** {{%.*}}, align 8
+ // CHECK-NEXT: [[T3:%.*]] = call i8* @objc_storeWeak(i8** [[T2]], i8* [[T1]])
+ // CHECK-NEXT: [[T4:%.*]] = call i8* @objc_loadWeakRetained(i8** [[T2]])
+ // CHECK-NEXT: store i8* [[T4]], i8**
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ id y = *wvp = test0_helper();
+}
+
+// rdar://problem/9320648
+struct Test1_helper { Test1_helper(); };
+@interface Test1 @end
+@implementation Test1 { Test1_helper x; } @end
+// CHECK: define internal i8* @"\01-[Test1 .cxx_construct]"(
+// CHECK: call void @_ZN12Test1_helperC1Ev(
+// CHECK-NEXT: load
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: ret i8*
+
+void test34(int cond) {
+ __strong id strong;
+ __weak id weak;
+ extern void test34_sink(id *);
+ test34_sink(cond ? &strong : 0);
+ test34_sink(cond ? &weak : 0);
+
+ // CHECK: define void @_Z6test34i(
+ // CHECK: [[COND:%.*]] = alloca i32
+ // CHECK-NEXT: [[STRONG:%.*]] = alloca i8*
+ // CHECK-NEXT: [[WEAK:%.*]] = alloca i8*
+ // CHECK-NEXT: [[TEMP1:%.*]] = alloca i8*
+ // CHECK-NEXT: [[TEMP2:%.*]] = alloca i8*
+ // CHECK-NEXT: store i32
+ // CHECK-NEXT: store i8* null, i8** [[STRONG]]
+ // CHECK-NEXT: call i8* @objc_initWeak(i8** [[WEAK]], i8* null)
+
+ // CHECK-NEXT: [[T0:%.*]] = load i32* [[COND]]
+ // CHECK-NEXT: [[T1:%.*]] = icmp ne i32 [[T0]], 0
+ // CHECK: [[ARG:%.*]] = phi i8**
+ // CHECK-NEXT: [[T0:%.*]] = icmp eq i8** [[ARG]], null
+ // CHECK-NEXT: [[T1:%.*]] = select i1 [[T0]], i8** null, i8** [[TEMP1]]
+ // CHECK-NEXT: br i1 [[T0]],
+ // CHECK: [[T0:%.*]] = load i8** [[ARG]]
+ // CHECK-NEXT: store i8* [[T0]], i8** [[TEMP1]]
+ // CHECK-NEXT: br label
+ // CHECK: call void @_Z11test34_sinkPU15__autoreleasingP11objc_object(i8** [[T1]])
+ // CHECK-NEXT: [[T0:%.*]] = icmp eq i8** [[ARG]], null
+ // CHECK-NEXT: br i1 [[T0]],
+ // CHECK: [[T0:%.*]] = load i8** [[TEMP1]]
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
+ // CHECK-NEXT: [[T2:%.*]] = load i8** [[ARG]]
+ // CHECK-NEXT: store i8* [[T1]], i8** [[ARG]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T2]])
+ // CHECK-NEXT: br label
+
+ // CHECK: [[T0:%.*]] = load i32* [[COND]]
+ // CHECK-NEXT: [[T1:%.*]] = icmp ne i32 [[T0]], 0
+ // CHECK: [[ARG:%.*]] = phi i8**
+ // CHECK-NEXT: [[T0:%.*]] = icmp eq i8** [[ARG]], null
+ // CHECK-NEXT: [[T1:%.*]] = select i1 [[T0]], i8** null, i8** [[TEMP2]]
+ // CHECK-NEXT: br i1 [[T0]],
+ // CHECK: [[T0:%.*]] = call i8* @objc_loadWeak(i8** [[ARG]])
+ // CHECK-NEXT: store i8* [[T0]], i8** [[TEMP2]]
+ // CHECK-NEXT: br label
+ // CHECK: call void @_Z11test34_sinkPU15__autoreleasingP11objc_object(i8** [[T1]])
+ // CHECK-NEXT: [[T0:%.*]] = icmp eq i8** [[ARG]], null
+ // CHECK-NEXT: br i1 [[T0]],
+ // CHECK: [[T0:%.*]] = load i8** [[TEMP2]]
+ // CHECK-NEXT: call i8* @objc_storeWeak(i8** [[ARG]], i8* [[T0]])
+ // CHECK-NEXT: br label
+
+ // CHECK: call void @objc_destroyWeak(i8** [[WEAK]])
+ // CHECK: ret void
+}
+
+struct Test35_Helper {
+ static id makeObject1() __attribute__((ns_returns_retained));
+ id makeObject2() __attribute__((ns_returns_retained));
+ static id makeObject3();
+ id makeObject4();
+};
+
+// CHECK: define void @_Z6test3513Test35_HelperPS_
+void test35(Test35_Helper x0, Test35_Helper *x0p) {
+ // CHECK: call i8* @_ZN13Test35_Helper11makeObject1Ev
+ // CHECK-NOT: call i8* @objc_retain
+ id obj1 = Test35_Helper::makeObject1();
+ // CHECK: call i8* @_ZN13Test35_Helper11makeObject2Ev
+ // CHECK-NOT: call i8* @objc_retain
+ id obj2 = x0.makeObject2();
+ // CHECK: call i8* @_ZN13Test35_Helper11makeObject2Ev
+ // CHECK-NOT: call i8* @objc_retain
+ id obj3 = x0p->makeObject2();
+ id (Test35_Helper::*pmf)() __attribute__((ns_returns_retained))
+ = &Test35_Helper::makeObject2;
+ // CHECK: call i8* %
+ // CHECK-NOT: call i8* @objc_retain
+ id obj4 = (x0.*pmf)();
+ // CHECK: call i8* %
+ // CHECK-NOT: call i8* @objc_retain
+ id obj5 = (x0p->*pmf)();
+
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @_Z7test35b13Test35_HelperPS_
+void test35b(Test35_Helper x0, Test35_Helper *x0p) {
+ // CHECK: call i8* @_ZN13Test35_Helper11makeObject3Ev
+ // CHECK: call i8* @objc_retain
+ id obj1 = Test35_Helper::makeObject3();
+ // CHECK: call i8* @_ZN13Test35_Helper11makeObject4Ev
+ // CHECK: call i8* @objc_retain
+ id obj2 = x0.makeObject4();
+ // CHECK: call i8* @_ZN13Test35_Helper11makeObject4Ev
+ // CHECK: call i8* @objc_retain
+ id obj3 = x0p->makeObject4();
+ id (Test35_Helper::*pmf)() = &Test35_Helper::makeObject4;
+ // CHECK: call i8* %
+ // CHECK: call i8* @objc_retain
+ id obj4 = (x0.*pmf)();
+ // CHECK: call i8* %
+ // CHECK: call i8* @objc_retain
+ id obj5 = (x0p->*pmf)();
+
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+}
+
+// rdar://problem/9603128
+// CHECK: define i8* @_Z6test36P11objc_object(
+id test36(id z) {
+ // CHECK: objc_retain
+ // CHECK: objc_retain
+ // CHECK: objc_release
+ // CHECK: objc_autoreleaseReturnValue
+ return z;
+}
+
+// Template instantiation side of rdar://problem/9817306
+@interface Test37
++ alloc;
+- init;
+- (NSArray *) array;
+@end
+template <class T> void test37(T *a) {
+ for (id x in a.array) {
+ use(x);
+ }
+}
+extern template void test37<Test37>(Test37 *a);
+template void test37<Test37>(Test37 *a);
+// CHECK: define weak_odr void @_Z6test37I6Test37EvPT_(
+// CHECK: [[T0:%.*]] = call [[NSARRAY]]* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to [[NSARRAY]]* (i8*, i8*)*)(
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[NSARRAY]]* [[T0]] to i8*
+// CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
+// CHECK-NEXT: [[COLL:%.*]] = bitcast i8* [[T2]] to [[NSARRAY]]*
+
+// Make sure it's not immediately released before starting the iteration.
+// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK-NEXT: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
+// CHECK-NEXT: @objc_msgSend
+
+// This bitcast is for the mutation check.
+// CHECK: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
+// CHECK-NEXT: @objc_enumerationMutation
+
+// This bitcast is for the 'next' message send.
+// CHECK: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
+// CHECK-NEXT: @objc_msgSend
+
+// This bitcast is for the final release.
+// CHECK: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T0]])
+
+template<typename T>
+void send_release() {
+ [Test37 array];
+}
+
+// CHECK: define weak_odr void @_Z12send_releaseIiEvv(
+// CHECK: call %0* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: call void @objc_release
+// CHECK-NEXT: ret void
+template void send_release<int>();
+
+template<typename T>
+Test37 *instantiate_init() {
+ Test37 *result = [[Test37 alloc] init];
+ return result;
+}
+
+// CHECK: define weak_odr %2* @_Z16instantiate_initIiEP6Test37v
+// CHECK: call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: call i8* @objc_retain
+// CHECK: call void @objc_release
+// CHECK: call i8* @objc_autoreleaseReturnValue
+template Test37* instantiate_init<int>();
+
+// Just make sure that the AST invariants hold properly here,
+// i.e. that we don't crash.
+// The block should get bound in the full-expression outside
+// the statement-expression.
+template <class T> class Test38 {
+ void test(T x) {
+ ^{ (void) x; }, ({ x; });
+ }
+};
+// CHECK: define weak_odr void @_ZN6Test38IiE4testEi(
+template class Test38<int>;
diff --git a/clang/test/CodeGenObjCXX/block-in-template-inst.mm b/clang/test/CodeGenObjCXX/block-in-template-inst.mm
new file mode 100644
index 0000000..93a0e49
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/block-in-template-inst.mm
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -emit-llvm-only -std=c++11 -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-fragile-abi %s
+// rdar://9362021
+
+@class DYFuture;
+@interface NSCache
+- (void)setObject:(id)obj forKey:(id)key;
+@end
+
+template <typename T>
+class ResourceManager
+{
+public:
+ ~ResourceManager();
+ DYFuture* XXX();
+ NSCache* _spDeviceCache;
+};
+
+template <typename T>
+DYFuture* ResourceManager<T>::XXX()
+{
+ ^ {
+ [_spDeviceCache setObject:0 forKey:0];
+ }();
+
+ return 0;
+}
+
+struct AnalyzerBaseObjectTypes { };
+
+void FUNC()
+{
+ ResourceManager<AnalyzerBaseObjectTypes> *rm;
+ ^(void) { rm->XXX(); }();
+}
+
+namespace PR9982 {
+ template<typename T> struct Curry;
+
+ template<typename R, typename Arg0, typename Arg1, typename Arg2>
+ struct Curry<R (^)(Arg0, Arg1, Arg2)>
+ {
+ typedef R (^FType)(Arg0, Arg1, Arg2);
+
+ Curry(FType _f) : f(_f) {}
+ ~Curry() {;}
+
+ R (^(^operator()(Arg0 a))(Arg1))(Arg2)
+ {
+ auto block = ^(Arg1 b) {
+ auto inner_block = ^(Arg2 c) {
+ return f(a, b, c);
+ };
+ return inner_block;
+ };
+ return block;
+ }
+
+ private:
+ FType f;
+ };
+
+ auto add = ^(int a, int b, int c)
+ {
+ return a + b + c;
+ };
+
+ void curry() {
+ Curry<__decltype(add)> c = Curry<__decltype(add)>(add);
+ auto t = c(1)(10)(100);
+ }
+}
diff --git a/clang/test/CodeGenObjCXX/block-var-layout.mm b/clang/test/CodeGenObjCXX/block-var-layout.mm
new file mode 100644
index 0000000..a8f8be0
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/block-var-layout.mm
@@ -0,0 +1,157 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -emit-llvm %s -o %t-64.ll
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.ll %s
+
+// See commentary in test/CodeGenObjC/block-var-layout.m, from which
+// this is largely cloned.
+
+struct S {
+ int i1;
+ id o1;
+ struct V {
+ int i2;
+ id o2;
+ } v1;
+ int i3;
+ id o3;
+};
+
+__weak id wid;
+void x(id y) {}
+void y(int a) {}
+
+extern id opaque_id();
+
+void f() {
+ __block int byref_int = 0;
+ char ch = 'a';
+ char ch1 = 'b';
+ char ch2 = 'c';
+ short sh = 2;
+ const id bar = (id) opaque_id();
+ id baz = 0;
+ __strong void *strong_void_sta;
+ __block id byref_bab = (id)0;
+ __block void *bl_var1;
+ int i; double dob;
+
+// Test 1
+// byref int, short, char, char, char, id, id, strong void*, byref id
+// 01 35 10 00
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [4 x i8] c"\015\10\00"
+ void (^b)() = ^{
+ byref_int = sh + ch+ch1+ch2 ;
+ x(bar);
+ x(baz);
+ x((id)strong_void_sta);
+ x(byref_bab);
+ };
+ b();
+
+// Test 2
+// byref int, short, char, char, char, id, id, strong void*, byref void*, byref id
+// 01 36 10 00
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [4 x i8] c"\016\10\00"
+ void (^c)() = ^{
+ byref_int = sh + ch+ch1+ch2 ;
+ x(bar);
+ x(baz);
+ x((id)strong_void_sta);
+ x(wid);
+ bl_var1 = 0;
+ x(byref_bab);
+ };
+ c();
+
+// Test 3
+// byref int, short, char, char, char, id, id, byref void*, int, double, byref id
+// 01 34 11 30 00
+// FIXME: we'd get a better format here if we sorted by scannability, not just alignment
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [5 x i8] c"\014\11 \00"
+void (^d)() = ^{
+ byref_int = sh + ch+ch1+ch2 ;
+ x(bar);
+ x(baz);
+ x(wid);
+ bl_var1 = 0;
+ y(i + dob);
+ x(byref_bab);
+ };
+ d();
+
+// Test4
+// struct S (int, id, int, id, int, id)
+// 01 41 11 11
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [5 x i8] c"\01A\11\11\00"
+ struct S s2;
+ void (^e)() = ^{
+ x(s2.o1);
+ };
+ e();
+}
+
+// Test 5 (unions/structs and their nesting):
+void Test5() {
+ struct S5 {
+ int i1;
+ id o1;
+ struct V {
+ int i2;
+ id o2;
+ } v1;
+ int i3;
+ union UI {
+ void * i1;
+ id o1;
+ int i3;
+ id o3;
+ }ui;
+ };
+
+ union U {
+ void * i1;
+ id o1;
+ int i3;
+ id o3;
+ }ui;
+
+ struct S5 s2;
+ union U u2;
+
+// struct s2 (int, id, int, id, int, id?), union u2 (id?)
+// 01 41 11 12 70 00
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [6 x i8] c"\01A\11\12p\00"
+ void (^c)() = ^{
+ x(s2.ui.o1);
+ x(u2.o1);
+ };
+ c();
+
+}
+
+// rdar: //8417746
+void CFRelease(id);
+void notifyBlock(id dependentBlock) {
+ id singleObservationToken;
+ id token;
+ void (^b)();
+
+// id, id, void(^)()
+// 01 33 00
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [3 x i8] c"\013\00"
+ void (^wrapperBlock)() = ^() {
+ CFRelease(singleObservationToken);
+ CFRelease(singleObservationToken);
+ CFRelease(token);
+ CFRelease(singleObservationToken);
+ b();
+ };
+ wrapperBlock();
+}
+
+void test_empty_block() {
+// 01 00
+// CHECK-LP64: @"\01L_OBJC_CLASS_NAME_{{.*}}" = internal global [2 x i8] c"\01\00"
+ void (^wrapperBlock)() = ^() {
+ };
+ wrapperBlock();
+}
diff --git a/clang/test/CodeGenObjCXX/blocks.mm b/clang/test/CodeGenObjCXX/blocks.mm
new file mode 100644
index 0000000..126931d
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/blocks.mm
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin -fobjc-fragile-abi %s -verify -emit-llvm -o %t
+// rdar://8979379
+
+@interface A
+@end
+
+@interface B : A
+@end
+
+void f(int (^bl)(B* b));
+
+// Test1
+void g() {
+ f(^(A* a) { return 0; });
+}
+
+// Test2
+void g1() {
+ int (^bl)(B* b) = ^(A* a) { return 0; };
+}
+
+// Test3
+@protocol NSObject;
+
+void bar(id(^)(void));
+
+void foo(id <NSObject>(^objectCreationBlock)(void)) {
+ return bar(objectCreationBlock);
+}
+
+// Test4
+struct S {
+ S *(^a)() = ^{ // expected-warning {{C++11}}
+ return this;
+ };
+};
+S s;
+
+// Test5
+struct X {
+ void f() {
+ ^ {
+ struct Nested { Nested *ptr = this; }; // expected-warning {{C++11}}
+ } ();
+ };
+};
diff --git a/clang/test/CodeGenObjCXX/catch-id-type.mm b/clang/test/CodeGenObjCXX/catch-id-type.mm
new file mode 100644
index 0000000..a5fa3e7
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/catch-id-type.mm
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -triple i386-apple-macosx10.6.6 -fobjc-fragile-abi -emit-llvm -fobjc-exceptions -fcxx-exceptions -fexceptions -o - %s | FileCheck %s
+// rdar://8940528
+
+@interface ns_array
++ (id) array;
+@end
+
+@implementation ns_array
++ (id) array { return 0; }
+@end
+
+id Groups();
+
+@protocol P @end;
+
+@interface INTF<P> {
+ double dd;
+}
+@end
+
+id FUNC() {
+ id groups;
+ try
+ {
+ groups = Groups(); // throws on errors.
+ }
+ catch( INTF<P>* error )
+ {
+ Groups();
+ }
+ catch( id error )
+ {
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ // CHECK-NEXT: catch i8* bitcast ({ i8*, i8*, i32, i8* }* @_ZTIP4INTF to i8*)
+ // CHECK-NEXT: catch i8* bitcast ({ i8*, i8*, i32, i8* }* @_ZTIP11objc_object to i8*)
+ // CHECK-NEXT: catch i8* bitcast ({ i8*, i8*, i32, i8* }* @_ZTIP10objc_class to i8*)
+ error = error;
+ groups = [ns_array array];
+ }
+ catch (Class cl) {
+ cl = cl;
+ groups = [ns_array array];
+ }
+ return groups;
+
+}
+
+int main() {
+ FUNC();
+ return 0;
+}
diff --git a/clang/test/CodeGenObjCXX/copy.mm b/clang/test/CodeGenObjCXX/copy.mm
new file mode 100644
index 0000000..9382ee8
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/copy.mm
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s
+
+// rdar://problem/9158302
+// This should not use a memmove_collectable in non-GC mode.
+namespace test0 {
+ struct A {
+ id x;
+ };
+
+ // CHECK: define [[A:%.*]]* @_ZN5test04testENS_1AE(
+ // CHECK: alloca
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: store
+ // CHECK-NEXT: call noalias i8* @_Znwm(
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(
+ // CHECK-NEXT: ret
+ A *test(A a) {
+ return new A(a);
+ }
+}
+
+
+// rdar://9780211
+@protocol bork
+@end
+
+namespace test1 {
+template<typename T> struct RetainPtr {
+ RetainPtr() {}
+};
+
+
+RetainPtr<id<bork> > x;
+RetainPtr<id> y;
+
+}
diff --git a/clang/test/CodeGenObjCXX/copyable-property-object.mm b/clang/test/CodeGenObjCXX/copyable-property-object.mm
new file mode 100644
index 0000000..03c0c06
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/copyable-property-object.mm
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s
+
+struct POD {
+ int array[3][4];
+ id objc_obj;
+};
+
+struct D {
+ POD pod_array[2][3];
+};
+
+@interface I
+{
+ D Property1;
+}
+@property D Property1;
+- (D) val;
+- (void) set : (D) d1;
+@end
+
+@implementation I
+@synthesize Property1;
+- (D) val { return Property1; }
+- (void) set : (D) d1 { Property1 = d1; }
+@end
+// CHECK: {{call.*@objc_memmove_collectable}}
+// CHECK: {{call.*@objc_memmove_collectable}}
+
diff --git a/clang/test/CodeGenObjCXX/debug-info.mm b/clang/test/CodeGenObjCXX/debug-info.mm
new file mode 100644
index 0000000..04cf66f
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/debug-info.mm
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -g -emit-llvm %s -o /dev/null
+
+// This test passes if clang doesn't crash.
+
+template <class C> class scoped_ptr {
+public:
+ C* operator->() const { return 0; }
+};
+
+@class NSWindow;
+@class NSImage;
+@interface NSWindow {
+ NSImage *_miniIcon;
+}
+-(id)windowController;
+@end
+
+class AutomationResourceTracker {
+public:
+ NSWindow* GetResource(int handle) { return 0; }
+};
+
+# 13 "automation/automation_window_tracker.h"
+class AutomationWindowTracker : public AutomationResourceTracker { };
+
+template<typename NST> class scoped_nsobject { };
+
+@interface TabStripController{
+ scoped_nsobject<NSImage> defaultFavicon_;
+}
+@end
+
+@interface BrowserWindowController {
+ TabStripController* tabStripController_;
+}
+@end
+
+void WindowGetViewBounds(scoped_ptr<AutomationWindowTracker> window_tracker_) {
+ NSWindow* window = window_tracker_->GetResource(42);
+ BrowserWindowController* controller = [window windowController];
+}
diff --git a/clang/test/CodeGenObjCXX/encode.mm b/clang/test/CodeGenObjCXX/encode.mm
new file mode 100644
index 0000000..8391c04
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/encode.mm
@@ -0,0 +1,189 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// CHECK: v17@0:8{vector<float, float, float>=}16
+// CHECK: {vector<float, float, float>=}
+// CHECK: v24@0:816
+
+template <typename T1, typename T2, typename T3> struct vector {
+ vector();
+ vector(T1,T2,T3);
+};
+
+typedef vector< float, float, float > vector3f;
+
+@interface SceneNode
+{
+ vector3f position;
+}
+
+@property (assign, nonatomic) vector3f position;
+
+@end
+
+@interface MyOpenGLView
+{
+@public
+ vector3f position;
+}
+@property vector3f position;
+@end
+
+@implementation MyOpenGLView
+
+@synthesize position;
+
+-(void)awakeFromNib {
+ SceneNode *sn;
+ vector3f VF3(1.0, 1.0, 1.0);
+ [sn setPosition:VF3];
+}
+@end
+
+
+class Int3 { int x, y, z; };
+
+// Enforce @encoding for member pointers.
+@interface MemPtr {}
+- (void) foo: (int (Int3::*)) member;
+@end
+@implementation MemPtr
+- (void) foo: (int (Int3::*)) member {
+}
+@end
+
+// rdar: // 8519948
+typedef float HGVec4f __attribute__ ((vector_size(16)));
+
+@interface RedBalloonHGXFormWrapper {
+ HGVec4f m_Transform[4];
+}
+@end
+
+@implementation RedBalloonHGXFormWrapper
+@end
+
+// rdar://9357400
+namespace rdar9357400 {
+ template<int Dim1 = -1, int Dim2 = -1> struct fixed {
+ template<int D> struct rebind { typedef fixed<D> other; };
+ };
+
+ template<typename Element, int Size>
+ class fixed_1D
+ {
+ public:
+ typedef Element value_type;
+ typedef value_type array_impl[Size];
+ protected:
+ array_impl m_data;
+ };
+
+ template<typename Element, typename Alloc>
+ class vector;
+
+ template<typename Element, int Size>
+ class vector< Element, fixed<Size> >
+ : public fixed_1D<Element,Size> { };
+
+ typedef vector< float, fixed<4> > vector4f;
+
+ // CHECK: @_ZN11rdar9357400L2ggE = internal constant [49 x i8] c"{vector<float, rdar9357400::fixed<4, -1> >=[4f]}\00"
+ const char gg[] = @encode(vector4f);
+}
+
+// rdar://9624314
+namespace rdar9624314 {
+ struct B2 { int x; };
+ struct B3 {};
+ struct S : B2, B3 {};
+
+ // CHECK: @_ZN11rdar9624314L2ggE = internal constant [6 x i8] c"{S=i}\00"
+ const char gg[] = @encode(S);
+
+ struct S2 { unsigned : 0; int x; unsigned : 0; };
+ // CHECK: @_ZN11rdar9624314L2g2E = internal constant [11 x i8] c"{S2=b0ib0}\00"
+ const char g2[] = @encode(S2);
+}
+
+namespace test {
+ class Foo {
+ public:
+ virtual void f() {};
+ };
+
+ class Bar {
+ public:
+ virtual void g() {};
+ };
+
+ class Zoo : virtual public Foo, virtual public Bar {
+ public:
+ int x;
+ int y;
+ };
+
+ // CHECK: @_ZN4testL3ecdE = internal constant [15 x i8] c"{Zoo=^^?ii^^?}\00"
+ const char ecd[] = @encode(Zoo);
+}
+
+struct Base1 {
+ char x;
+};
+
+struct DBase : public Base1 {
+ double x;
+ virtual ~DBase();
+};
+
+struct Sub_with_virt : virtual DBase {
+ long x;
+};
+
+struct Sub2 : public Sub_with_virt, public Base1, virtual DBase {
+ float x;
+};
+
+// CHECK: @_ZL2g1 = internal constant [10 x i8] c"{Base1=c}\00"
+const char g1[] = @encode(Base1);
+
+// CHECK: @_ZL2g2 = internal constant [14 x i8] c"{DBase=^^?cd}\00"
+const char g2[] = @encode(DBase);
+
+// CHECK: @_ZL2g3 = internal constant [26 x i8] c"{Sub_with_virt=^^?q^^?cd}\00"
+const char g3[] = @encode(Sub_with_virt);
+
+// CHECK: @_ZL2g4 = internal constant [19 x i8] c"{Sub2=^^?qcf^^?cd}\00"
+const char g4[] = @encode(Sub2);
+
+// http://llvm.org/PR9927
+class allocator {
+};
+class basic_string {
+struct _Alloc_hider : allocator {
+char* _M_p;
+};
+_Alloc_hider _M_dataplus;
+};
+
+// CHECK: @_ZL2g5 = internal constant [32 x i8] c"{basic_string={_Alloc_hider=*}}\00"
+const char g5[] = @encode(basic_string);
+
+
+// PR10990
+class CefBase {
+ virtual ~CefBase() {}
+};
+class CefBrowser : public virtual CefBase {};
+class CefBrowserImpl : public CefBrowser {};
+// CHECK: @_ZL2g6 = internal constant [21 x i8] c"{CefBrowserImpl=^^?}\00"
+const char g6[] = @encode(CefBrowserImpl);
+
+// PR10990_2
+class CefBase2 {
+ virtual ~CefBase2() {}
+ int i;
+};
+class CefBrowser2 : public virtual CefBase2 {};
+class CefBrowserImpl2 : public CefBrowser2 {};
+// CHECK: @_ZL2g7 = internal constant [26 x i8] c"{CefBrowserImpl2=^^?^^?i}\00"
+const char g7[] = @encode(CefBrowserImpl2);
diff --git a/clang/test/CodeGenObjCXX/exceptions.mm b/clang/test/CodeGenObjCXX/exceptions.mm
new file mode 100644
index 0000000..ce6d20a
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/exceptions.mm
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fcxx-exceptions -fexceptions -o - %s | FileCheck %s
+
+@interface OCType @end
+void opaque();
+
+namespace test0 {
+
+ // CHECK: define void @_ZN5test03fooEv
+ void foo() {
+ try {
+ // CHECK: invoke void @_Z6opaquev
+ opaque();
+ } catch (OCType *T) {
+ // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__objc_personality_v0 to i8*)
+ // CHECK-NEXT: catch %struct._objc_typeinfo* @"OBJC_EHTYPE_$_OCType"
+ }
+ }
+}
diff --git a/clang/test/CodeGenObjCXX/foreach-statement.mm b/clang/test/CodeGenObjCXX/foreach-statement.mm
new file mode 100644
index 0000000..d0ad5b3
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/foreach-statement.mm
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// rdar: // 8027844
+
+// CHECK: call void @llvm.memset
+
+int main() {
+ id foo;
+ for (id a in foo) {
+ }
+}
diff --git a/clang/test/CodeGenObjCXX/gc.mm b/clang/test/CodeGenObjCXX/gc.mm
new file mode 100644
index 0000000..1e9fe00
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/gc.mm
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s
+
+namespace test0 {
+ extern id x;
+
+ struct A {
+ id x;
+ A();
+ };
+ A::A() : x(test0::x) {}
+
+// CHECK: define void @_ZN5test01AC2Ev(
+// CHECK: [[THIS:%.*]] = alloca [[TEST0:%.*]]*, align 8
+// CHECK-NEXT: store
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST0]]** [[THIS]]
+// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[TEST0]]* [[T0]], i32 0, i32 0
+// CHECK-NEXT: [[T2:%.*]] = load i8** @_ZN5test01xE
+// CHECK-NEXT: call i8* @objc_assign_strongCast(i8* [[T2]], i8** [[T1]])
+// CHECK-NEXT: ret void
+}
diff --git a/clang/test/CodeGenObjCXX/implicit-copy-assign-operator.mm b/clang/test/CodeGenObjCXX/implicit-copy-assign-operator.mm
new file mode 100644
index 0000000..0a6e08e
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/implicit-copy-assign-operator.mm
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fobjc-gc -emit-llvm -triple x86_64-apple-darwin10.0.0 -fobjc-fragile-abi -o - %s | FileCheck %s
+struct A {
+ A &operator=(const A&);
+ A &operator=(A&);
+};
+
+struct B {
+ B &operator=(B&);
+};
+
+struct C {
+ virtual C& operator=(const C&);
+};
+
+struct POD {
+ id myobjc;
+ int array[3][4];
+};
+
+struct CopyByValue {
+ CopyByValue(const CopyByValue&);
+ CopyByValue &operator=(CopyByValue);
+};
+
+struct D : A, B, virtual C {
+ int scalar;
+ int scalar_array[2][3];
+ B class_member;
+ C class_member_array[2][3];
+ POD pod_array[2][3];
+
+ union {
+ int x;
+ float f[3];
+ };
+
+ CopyByValue by_value;
+};
+
+void test_D(D d1, D d2) {
+ d1 = d2;
+}
+
+// CHECK: define linkonce_odr %struct.D* @_ZN1DaSERS_
+// CHECK: {{call.*_ZN1AaSERS_}}
+// CHECK: {{call.*_ZN1BaSERS_}}
+// CHECK: {{call.*_ZN1CaSERKS_}}
+// CHECK: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 24}}
+// CHECK: {{call.*_ZN1BaSERS_}}
+// CHECK: br
+// CHECK: {{call.*_ZN1CaSERKS_}}
+// CHECK: {{call.*@objc_memmove_collectable}}
+// CHECK: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 12}}
+// CHECK: call void @_ZN11CopyByValueC1ERKS_
+// CHECK: {{call.*_ZN11CopyByValueaSES_}}
+// CHECK: ret
+
diff --git a/clang/test/CodeGenObjCXX/implicit-copy-constructor.mm b/clang/test/CodeGenObjCXX/implicit-copy-constructor.mm
new file mode 100644
index 0000000..63dd4f0
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/implicit-copy-constructor.mm
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s
+
+struct A {
+ A();
+ A(const A&);
+ A(A&);
+ ~A();
+};
+
+struct B {
+ B();
+ B(B&);
+};
+
+struct C {
+ C() {}
+ C(C& other, A a = A());
+ int i, j;
+};
+
+struct POD {
+ id myobjc;
+ int array[3][4];
+};
+
+struct D : A, B, virtual C {
+ D();
+ int scalar;
+ int scalar_array[2][3];
+ B class_member;
+ C class_member_array[2][3];
+ POD pod_array[2][3];
+
+ union {
+ int x;
+ float f[3];
+ };
+};
+
+void f(D d) {
+ D d2(d);
+}
+
+// CHECK: define linkonce_odr void @_ZN1DC1ERS_(%struct.D* %this, %struct.D*) unnamed_addr
+// CHECK: call void @_ZN1AC1Ev
+// CHECK: call void @_ZN1CC2ERS_1A
+// CHECK: call void @_ZN1AD1Ev
+// CHECK: call void @_ZN1AC2ERS_
+// CHECK: call void @_ZN1BC2ERS_
+// CHECK: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 24}}
+// CHECK: call void @_ZN1BC1ERS_
+// CHECK: br
+// CHECK: {{icmp ult.*, 2}}
+// CHECK: {{icmp ult.*, 3}}
+// CHECK: call void @_ZN1AC1Ev
+// CHECK: call void @_ZN1CC1ERS_1A
+// CHECK: call void @_ZN1AD1Ev
+// CHECK: {{call.*@objc_memmove_collectable}}
+// CHECK: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 12}}
+// CHECK: ret void
+
+
+template<class T> struct X0 { void f0(T * ) { } };
+template <class > struct X1 { X1( X1& , int = 0 ) { } };
+struct X2 { X1<int> result; };
+void test_X2()
+{
+ typedef X2 impl;
+ typedef X0<impl> pimpl;
+ impl* i;
+ pimpl pdata;
+ pdata.f0( new impl(*i));
+}
diff --git a/clang/test/CodeGenObjCXX/ivar-objects.mm b/clang/test/CodeGenObjCXX/ivar-objects.mm
new file mode 100644
index 0000000..d05763b
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/ivar-objects.mm
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// CHECK: -[A .cxx_construct]
+// CHECK: -[A .cxx_destruct]
+// CHECK: -[B .cxx_construct]
+// CHECK-NOT: -[B .cxx_destruct]
+// CHECK-NOT: -[C .cxx_construct]
+// CHECK: -[C .cxx_destruct]
+
+@interface NSObject
+- alloc;
+- init;
+- (void) release;
+@end
+
+extern "C" int printf(const char *, ...);
+
+int count = 17;
+struct X {
+ X() : value(count++) { printf( "X::X()\n"); }
+ ~X() { printf( "X::~X()\n"); }
+ int value;
+};
+
+struct Y {
+ Y() : value(count++) { printf( "Y::Y()\n"); }
+ ~Y() { printf( "Y::~Y()\n"); }
+ int value;
+};
+
+@interface Super : NSObject {
+ Y yvar;
+ Y yvar1;
+ Y ya[3];
+}
+- (void)finalize;
+@end
+
+@interface A : Super {
+ X xvar;
+ X xvar1;
+ X xvar2;
+ X xa[2][2];
+}
+
+- (void)print;
+- (void)finalize;
+@end
+
+@implementation Super
+- (void)print {
+ printf( "yvar.value = %d\n", yvar.value);
+ printf( "yvar1.value = %d\n", yvar1.value);
+ printf( "ya[0..2] = %d %d %d\n", ya[0].value, ya[1].value, ya[2].value);
+}
+- (void)finalize {}
+@end
+
+@implementation A
+- (void)print {
+ printf( "xvar.value = %d\n", xvar.value);
+ printf( "xvar1.value = %d\n", xvar1.value);
+ printf( "xvar2.value = %d\n", xvar2.value);
+ printf( "xa[0..1][0..1] = %d %d %d %d\n",
+ xa[0][0].value, xa[0][1].value, xa[1][0].value, xa[1][1].value);
+ [super print];
+}
+- (void)finalize { [super finalize]; }
+@end
+
+int main() {
+ A *a = [[A alloc] init];
+ [a print];
+ [a release];
+}
+
+// rdar: // 7468090
+class S {
+public:
+ S& operator = (const S&);
+};
+
+@interface I {
+ S position;
+}
+@property(assign, nonatomic) S position;
+@end
+
+@implementation I
+ @synthesize position;
+@end
+
+// This class should have a .cxx_construct but no .cxx_destruct.
+namespace test3 { struct S { S(); }; }
+@implementation B {
+ test3::S s;
+}
+@end
+
+// This class should have a .cxx_destruct but no .cxx_construct.
+namespace test4 { struct S { ~S(); }; }
+@implementation C {
+ test4::S s;
+}
+@end
diff --git a/clang/test/CodeGenObjCXX/lambda-expressions.mm b/clang/test/CodeGenObjCXX/lambda-expressions.mm
new file mode 100644
index 0000000..858cb74
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/lambda-expressions.mm
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -fblocks -fobjc-arc | FileCheck -check-prefix=ARC %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -fblocks | FileCheck -check-prefix=MRC %s
+
+typedef int (^fp)();
+fp f() { auto x = []{ return 3; }; return x; }
+
+// MRC: @"\01L_OBJC_METH_VAR_NAME{{.*}}" = internal global [5 x i8] c"copy\00"
+// MRC: @"\01L_OBJC_METH_VAR_NAME{{.*}}" = internal global [12 x i8] c"autorelease\00"
+// MRC: define i32 ()* @_Z1fv(
+// MRC: define internal i32 ()* @"_ZZ1fvENK3$_0cvU13block_pointerFivEEv"
+// MRC: store i8* bitcast (i8** @_NSConcreteStackBlock to i8*)
+// MRC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke_0" to i8*)
+// MRC: call i32 ()* (i8*, i8*)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 ()* (i8*, i8*)*)
+// MRC: call i32 ()* (i8*, i8*)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 ()* (i8*, i8*)*)
+// MRC: ret i32 ()*
+
+// ARC: define i32 ()* @_Z1fv(
+// ARC: define internal i32 ()* @"_ZZ1fvENK3$_0cvU13block_pointerFivEEv"
+// ARC: store i8* bitcast (i8** @_NSConcreteStackBlock to i8*)
+// ARC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke_0" to i8*)
+// ARC: call i8* @objc_retainBlock
+// ARC: call i8* @objc_autoreleaseReturnValue
+
+typedef int (^fp)();
+fp global;
+void f2() { global = []{ return 3; }; }
+
+// MRC: define void @_Z2f2v() nounwind {
+// MRC: store i8* bitcast (i32 (i8*)* @__f2_block_invoke_0 to i8*),
+// MRC-NOT: call
+// MRC: ret void
+// ("global" contains a dangling pointer after this function runs.)
+
+// ARC: define void @_Z2f2v() nounwind {
+// ARC: store i8* bitcast (i32 (i8*)* @__f2_block_invoke_0 to i8*),
+// ARC: call i8* @objc_retainBlock
+// ARC: call void @objc_release
+// ARC: define internal i32 @__f2_block_invoke_0
+// ARC: call i32 @"_ZZ2f2vENK3$_1clEv
diff --git a/clang/test/CodeGenObjCXX/literals.mm b/clang/test/CodeGenObjCXX/literals.mm
new file mode 100644
index 0000000..b8946fa
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/literals.mm
@@ -0,0 +1,111 @@
+// RUN: %clang_cc1 -I %S/Inputs -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-arc-exceptions -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+
+#include "literal-support.h"
+
+struct X {
+ X();
+ ~X();
+ operator id() const;
+};
+
+struct Y {
+ Y();
+ ~Y();
+ operator id() const;
+};
+
+// CHECK: define void @_Z10test_arrayv
+void test_array() {
+ // CHECK: [[OBJECTS:%[a-zA-Z0-9.]+]] = alloca [2 x i8*]
+
+ // Initializing first element
+ // CHECK: [[ELEMENT0:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 0
+ // CHECK-NEXT: call void @_ZN1XC1Ev
+ // CHECK-NEXT: [[OBJECT0:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1XcvP11objc_objectEv
+ // CHECK: [[RET0:%[a-zA-Z0-9.]+]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[OBJECT0]])
+ // CHECK: store i8* [[RET0]], i8** [[ELEMENT0]]
+
+ // Initializing the second element
+ // CHECK: [[ELEMENT1:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 1
+ // CHECK-NEXT: invoke void @_ZN1YC1Ev
+ // CHECK: [[OBJECT1:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1YcvP11objc_objectEv
+ // CHECK: [[RET1:%[a-zA-Z0-9.]+]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[OBJECT1]])
+ // CHECK: store i8* [[RET1]], i8** [[ELEMENT1]]
+
+ // Build the array
+ // CHECK: {{invoke.*@objc_msgSend}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id arr = @[ X(), Y() ];
+
+ // Destroy temporaries
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NOT: ret void
+ // CHECK: invoke void @_ZN1YD1Ev
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: call void @_ZN1XD1Ev
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+
+ // Check cleanups
+ // CHECK: call void @objc_release
+ // CHECK-NOT: call void @objc_release
+ // CHECK: invoke void @_ZN1YD1Ev
+ // CHECK: call void @objc_release
+ // CHECK-NOT: call void @objc_release
+ // CHECK: invoke void @_ZN1XD1Ev
+ // CHECK-NOT: call void @objc_release
+ // CHECK: unreachable
+}
+
+// CHECK: define weak_odr void @_Z24test_array_instantiationIiEvv
+template<typename T>
+void test_array_instantiation() {
+ // CHECK: [[OBJECTS:%[a-zA-Z0-9.]+]] = alloca [2 x i8*]
+
+ // Initializing first element
+ // CHECK: [[ELEMENT0:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 0
+ // CHECK-NEXT: call void @_ZN1XC1Ev
+ // CHECK-NEXT: [[OBJECT0:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1XcvP11objc_objectEv
+ // CHECK: [[RET0:%[a-zA-Z0-9.]+]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[OBJECT0]])
+ // CHECK: store i8* [[RET0]], i8** [[ELEMENT0]]
+
+ // Initializing the second element
+ // CHECK: [[ELEMENT1:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 1
+ // CHECK-NEXT: invoke void @_ZN1YC1Ev
+ // CHECK: [[OBJECT1:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1YcvP11objc_objectEv
+ // CHECK: [[RET1:%[a-zA-Z0-9.]+]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[OBJECT1]])
+ // CHECK: store i8* [[RET1]], i8** [[ELEMENT1]]
+
+ // Build the array
+ // CHECK: {{invoke.*@objc_msgSend}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id arr = @[ X(), Y() ];
+
+ // Destroy temporaries
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NOT: ret void
+ // CHECK: invoke void @_ZN1YD1Ev
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: call void @_ZN1XD1Ev
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+
+ // Check cleanups
+ // CHECK: call void @objc_release
+ // CHECK-NOT: call void @objc_release
+ // CHECK: invoke void @_ZN1YD1Ev
+ // CHECK: call void @objc_release
+ // CHECK-NOT: call void @objc_release
+ // CHECK: invoke void @_ZN1XD1Ev
+ // CHECK-NOT: call void @objc_release
+ // CHECK: unreachable
+}
+
+template void test_array_instantiation<int>();
+
diff --git a/clang/test/CodeGenObjCXX/lvalue-reference-getter.mm b/clang/test/CodeGenObjCXX/lvalue-reference-getter.mm
new file mode 100644
index 0000000..83d3b93
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/lvalue-reference-getter.mm
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// rdar://10153365
+
+static int gint;
+struct SetSection {
+ int & at(int __n) { return gint; }
+ const int& at(int __n) const { return gint; }
+};
+
+static SetSection gSetSection;
+
+@interface SetShow
+- (SetSection&)sections;
+@end
+
+@implementation SetShow
+- (SetSection&) sections {
+// [self sections].at(100);
+ self.sections.at(100);
+ return gSetSection;
+}
+@end
+
+// CHECK: [[SELF:%.*]] = alloca [[T6:%.*]]*, align
+// CHECK: [[T0:%.*]] = load {{.*}}* [[SELF]], align
+// CHECK: [[T1:%.*]] = load {{.*}}* @"\01L_OBJC_SELECTOR_REFERENCES_"
+// CHECK: [[C:%.*]] = call %struct.SetSection* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: call i32* @_ZN10SetSection2atEi(%struct.SetSection* [[C]]
diff --git a/clang/test/CodeGenObjCXX/mangle-blocks.mm b/clang/test/CodeGenObjCXX/mangle-blocks.mm
new file mode 100644
index 0000000..fcbc608
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/mangle-blocks.mm
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-fragile-abi %s | FileCheck %s
+
+// CHECK: @_ZGVN3foo20__foo_block_invoke_05valueE = internal global i64 0
+
+int f();
+
+void foo() {
+ // CHECK: define internal i32 @__foo_block_invoke_0
+ // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVN3foo20__foo_block_invoke_05value
+ (void)^(int x) {
+ static int value = f();
+ return x + value;
+ };
+}
+
+// CHECK: define internal i32 @__block_global_0
+int i = ^(int x) { return x;}(i);
+
+@interface A
+- (void)method;
+@end
+
+@implementation A
+- (void)method {
+ // CHECK: define internal signext i8 @"__11-[A method]_block_invoke_0"
+ (void)^(int x) {
+ // CHECK: @"_ZN11-[A method]30__11-[A method]_block_invoke_04nameE"
+ static const char *name = "hello";
+ return name[x];
+ };
+}
+@end
+
+void foo(int) {
+ (void)^(int x) {
+ static const char *name = "hello";
+ return name[x];
+ };
+}
+
+namespace N {
+ // CHECK: define internal signext i8 @__bar_block_invoke_0
+ void bar() {
+ (void)^(int x) {
+ // CHECK: @_ZN1N3bar20__bar_block_invoke_04nameE
+ static const char *name = "hello";
+ return name[x];
+ };
+ }
+}
diff --git a/clang/test/CodeGenObjCXX/mangle.mm b/clang/test/CodeGenObjCXX/mangle.mm
new file mode 100644
index 0000000..2521c60
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/mangle.mm
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// CHECK: @"_ZZ11+[A shared]E1a" = internal global
+// CHECK: @"_ZZ11-[A(Foo) f]E1a" = internal global
+// CHECK: v56@0:8i16i20i24i28i32i36i40i44^i48
+
+@interface A
+@end
+
+@implementation A
+
++ (A *)shared {
+ static A* a;
+
+ return a;
+}
+
+@end
+
+@interface A(Foo)
+@end
+
+@implementation A(Foo)
+- (int)f {
+ // FIXME: Add a member function to s and make sure that it's mangled correctly.
+ struct s {
+ };
+
+ static s a;
+
+ return 0;
+}
+@end
+
+// PR6468
+@interface Test
+- (void) process: (int)r3 :(int)r4 :(int)r5 :(int)r6 :(int)r7 :(int)r8 :(int)r9 :(int)r10 :(int &)i;
+@end
+
+@implementation Test
+- (void) process: (int)r3 :(int)r4 :(int)r5 :(int)r6 :(int)r7 :(int)r8 :(int)r9 :(int)r10 :(int &)i {
+}
+@end
+
+// rdar://9566314
+@interface NX
+- (void)Meth;
+@end
+
+@implementation NX
+- (void)Meth {
+ void uiIsVisible();
+// CHECK: call void @_Z11uiIsVisiblev
+ uiIsVisible();
+}
+@end
diff --git a/clang/test/CodeGenObjCXX/message-reference.mm b/clang/test/CodeGenObjCXX/message-reference.mm
new file mode 100644
index 0000000..fa41fef
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/message-reference.mm
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s
+// rdar://8604515
+
+@interface I {}
+-(unsigned int&)referenceCount;
+@end
+
+@interface MyClass
++(int)writeBlip:(I*)srcBlip;
+@end
+
+@implementation MyClass
++(int)writeBlip:(I*)srcBlip{
+ return ([srcBlip referenceCount] == 0);
+}
+@end
+
+// CHECK: [[T:%.*]] = call i32* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: [[U:%.*]] = load i32* [[T]]
+// CHECK [[V:%.*]] = icmp eq i32 [[U]], 0
diff --git a/clang/test/CodeGenObjCXX/method-local-extern-mangle.mm b/clang/test/CodeGenObjCXX/method-local-extern-mangle.mm
new file mode 100644
index 0000000..794075d
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/method-local-extern-mangle.mm
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// CHECK: @gGlobals = external global
+
+@interface I
+- (int) Meth;
+@end
+
+@implementation I
+- (int) Meth {
+ extern int gGlobals;
+ return gGlobals;
+}
+@end
diff --git a/clang/test/CodeGenObjCXX/nrvo.mm b/clang/test/CodeGenObjCXX/nrvo.mm
new file mode 100644
index 0000000..ef5052e
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/nrvo.mm
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -emit-llvm -o - -fblocks %s -O1 -triple x86_64-apple-darwin10.0.0 -fobjc-fragile-abi | FileCheck %s
+
+// PR10835 / <rdar://problem/10050178>
+struct X {
+ X();
+ X(const X&);
+ ~X();
+};
+
+@interface NRVO
+@end
+
+@implementation NRVO
+// CHECK: define internal void @"\01-[NRVO getNRVO]"
+- (X)getNRVO {
+ X x;
+ // CHECK: tail call void @_ZN1XC1Ev
+ // CHECK-NEXT: ret void
+ return x;
+}
+@end
+
+X blocksNRVO() {
+ return ^{
+ // CHECK: define internal void @__blocksNRVO_block_invoke_0
+ X x;
+ // CHECK: tail call void @_ZN1XC1Ev
+ // CHECK-NEXT: ret void
+ return x;
+ }() ;
+}
+
diff --git a/clang/test/CodeGenObjCXX/objc-container-subscripting-1.mm b/clang/test/CodeGenObjCXX/objc-container-subscripting-1.mm
new file mode 100644
index 0000000..c0dd0f8
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/objc-container-subscripting-1.mm
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s
+
+typedef unsigned int size_t;
+@protocol P @end
+@protocol NSCopying @end
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+@end
+
+struct S {
+ operator unsigned int ();
+ operator id ();
+};
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id<NSCopying>)key;
+- (void)setObject:(id)object forKeyedSubscript:(id<NSCopying>)key;
+@end
+
+int main() {
+ NSMutableArray<P> * array;
+ S s;
+ id oldObject = array[(int)s];
+
+ NSMutableDictionary<P> *dict;
+ dict[(id)s] = oldObject;
+ oldObject = dict[(id)s];
+
+}
+
+template <class T> void test2(NSMutableArray *a) {
+ a[10] = 0;
+}
+template void test2<int>(NSMutableArray*);
+// CHECK: define weak_odr void @_Z5test2IiEvP14NSMutableArray
+// CHECK: @objc_msgSend
+// CHECK: ret void
+
+
+template <class T> void test3(NSMutableArray *a) {
+ a[sizeof(T)] = 0;
+}
+
+template void test3<int>(NSMutableArray*);
+// CHECK: define weak_odr void @_Z5test3IiEvP14NSMutableArray
+// CHECK: @objc_msgSend
+// CHECK: ret void
+
diff --git a/clang/test/CodeGenObjCXX/objc-container-subscripting.mm b/clang/test/CodeGenObjCXX/objc-container-subscripting.mm
new file mode 100644
index 0000000..dfe48e9
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/objc-container-subscripting.mm
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s
+
+typedef unsigned int size_t;
+@protocol P @end
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+@end
+
+struct S {
+ operator unsigned int ();
+ operator id ();
+};
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id)key;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+int main() {
+ NSMutableArray<P> * array;
+ S s;
+ id oldObject = array[(int)s];
+
+ NSMutableDictionary<P> *dict;
+ dict[(id)s] = oldObject;
+ oldObject = dict[(id)s];
+
+}
+
+template <class T> void test2(NSMutableArray *a) {
+ a[10] = 0;
+}
+template void test2<int>(NSMutableArray*);
+// CHECK: define weak_odr void @_Z5test2IiEvP14NSMutableArray
+// CHECK: @objc_msgSend
+// CHECK: ret void
+
+
+template <class T> void test3(NSMutableArray *a) {
+ a[sizeof(T)] = 0;
+}
+
+template void test3<int>(NSMutableArray*);
+// CHECK: define weak_odr void @_Z5test3IiEvP14NSMutableArray
+// CHECK: @objc_msgSend
+// CHECK: ret void
+
+// CHECK: define void @_Z11static_dataP14NSMutableArray
+void static_data(NSMutableArray *array) {
+ // CHECK: call i32 @__cxa_guard_acquire
+ // CHECK: {{call i8*.*@objc_msgSend }}
+ // CHECK: call void @__cxa_guard_release
+ static id x = array[4];
+ // CHECK: ret void
+}
diff --git a/clang/test/CodeGenObjCXX/property-derived-to-base-conv.mm b/clang/test/CodeGenObjCXX/property-derived-to-base-conv.mm
new file mode 100644
index 0000000..ddca857
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/property-derived-to-base-conv.mm
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s
+// rdar: // 7501812
+
+struct A {
+ int member;
+ void foo();
+ A *operator->();
+};
+struct B : A { };
+
+@interface BInt {
+@private
+ B *b;
+}
+- (B)value;
+- (void)setValue : (B) arg;
+@property B value;
+@end
+
+void g(BInt *bint) {
+ bint.value.foo();
+ bint.value->member = 17;
+ int x = bint.value.member;
+}
+
diff --git a/clang/test/CodeGenObjCXX/property-dot-copy.mm b/clang/test/CodeGenObjCXX/property-dot-copy.mm
new file mode 100644
index 0000000..c0ff258
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/property-dot-copy.mm
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// rdar://8427922
+
+struct Vector3D
+{
+ float x, y, z;
+ Vector3D();
+ Vector3D(const Vector3D &inVector);
+ Vector3D(float initX, float initY, float initZ);
+ Vector3D &operator=(const Vector3D & rhs);
+};
+
+@interface Object3D
+{
+ Vector3D position;
+ Vector3D length;
+}
+@property (assign) Vector3D position;
+- (Vector3D) length;
+- (void) setLength: (Vector3D)arg;
+@end
+
+int main ()
+{
+ Object3D *myObject;
+ Vector3D V3D(1.0f, 1.0f, 1.0f);
+// CHECK: call void @_ZN8Vector3DC1ERKS_
+ myObject.position = V3D;
+
+// CHECK: call void @_ZN8Vector3DC1ERKS_
+ myObject.length = V3D;
+
+ return 0;
+}
+
+// rdar: // 8437253
+extern "C" void exit(...);
+
+struct CGPoint {
+ float x;
+ float y;
+};
+typedef struct CGPoint CGPoint;
+
+extern "C" const CGPoint CGPointZero;
+
+bool operator==(const CGPoint& a, const CGPoint& b);
+
+@interface TIconViewSettings
+@property (assign, nonatomic) CGPoint gridOffset;
+@end
+
+@implementation TIconViewSettings
+- (CGPoint) gridOffset
+{
+ return CGPointZero;
+}
+
+- (void) foo
+{
+ if ((self.gridOffset) == CGPointZero)
+ exit(1);
+
+ if (self.gridOffset == CGPointZero)
+ exit(1);
+}
+@end
+
diff --git a/clang/test/CodeGenObjCXX/property-dot-reference.mm b/clang/test/CodeGenObjCXX/property-dot-reference.mm
new file mode 100644
index 0000000..e64b397
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/property-dot-reference.mm
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fexceptions -o - %s | FileCheck %s
+// rdar://8409336
+
+struct TFENode {
+void GetURL() const;
+};
+
+@interface TNodeIconAndNameCell
+- (const TFENode&) node;
+@end
+
+@implementation TNodeIconAndNameCell
+- (const TFENode&) node {
+// CHECK: call %struct.TFENode* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK-NEXT: call void @_ZNK7TFENode6GetURLEv(%struct.TFENode* %{{.*}})
+ self.node.GetURL();
+} // expected-warning {{control reaches end of non-void function}}
+@end
+
+// rdar://8437240
+struct X {
+ int x;
+};
+
+void f0(const X &parent);
+@interface A
+- (const X&) target;
+@end
+void f1(A *a) {
+// CHECK: [[PRP:%.*]] = call %struct.X* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK-NEXT:call void @_Z2f0RK1X(%struct.X* [[PRP]])
+ f0(a.target);
+
+// CHECK: [[MSG:%.*]] = call %struct.X* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK-NEXT:call void @_Z2f0RK1X(%struct.X* [[MSG]])
+ f0([a target]);
+}
+
+@interface Test2
+@property (readonly) int myProperty;
+- (int) myProperty;
+- (double) myGetter;
+@end
+void test2() {
+ Test2 *obj;
+ (void) obj.myProperty;
+ (void) obj.myGetter;
+ static_cast<void>(obj.myProperty);
+ static_cast<void>(obj.myGetter);
+ void(obj.myProperty);
+ void(obj.myGetter);
+}
+// CHECK: define void @_Z5test2v()
+// CHECK: call i32 bitcast
+// CHECK: call double bitcast
+// CHECK: call i32 bitcast
+// CHECK: call double bitcast
+// CHECK: call i32 bitcast
+// CHECK: call double bitcast
+
+// PR8751
+int test3(Test2 *obj) { return obj.myProperty; }
diff --git a/clang/test/CodeGenObjCXX/property-object-conditional-exp.mm b/clang/test/CodeGenObjCXX/property-object-conditional-exp.mm
new file mode 100644
index 0000000..281076e
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/property-object-conditional-exp.mm
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s
+
+struct CGRect {
+ char* origin;
+ unsigned size;
+};
+typedef struct CGRect CGRect;
+
+extern "C" bool CGRectIsEmpty(CGRect);
+
+@interface Foo {
+ CGRect out;
+}
+@property CGRect bounds;
+- (CGRect) out;
+@end
+
+
+@implementation Foo
+
+- (void)bar {
+ CGRect dataRect;
+ CGRect virtualBounds;
+
+// CHECK: [[SRC:%.*]] = call { i8*, i32 } bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK-NEXT: bitcast
+// CHECK-NEXT:getelementptr { i8*, i32 }* [[SRC:%.*]]
+// CHECK-NEXT:extractvalue
+// CHECK-NEXT:store
+// CHECK-NEXT:getelementptr { i8*, i32 }* [[SRC:%.*]]
+// CHECK-NEXT:extractvalue
+// CHECK-NEXT:store
+ dataRect = CGRectIsEmpty(virtualBounds) ? self.bounds : virtualBounds;
+ dataRect = CGRectIsEmpty(virtualBounds) ? [self bounds] : virtualBounds;
+ dataRect = CGRectIsEmpty(virtualBounds) ? virtualBounds : self.bounds;
+
+ dataRect = CGRectIsEmpty(virtualBounds) ? self.out : virtualBounds;
+ dataRect = CGRectIsEmpty(virtualBounds) ? [self out] : virtualBounds;
+ dataRect = CGRectIsEmpty(virtualBounds) ? virtualBounds : self.out;
+}
+
+@dynamic bounds;
+- (CGRect) out { return out; }
+@end
diff --git a/clang/test/CodeGenObjCXX/property-object-reference-1.mm b/clang/test/CodeGenObjCXX/property-object-reference-1.mm
new file mode 100644
index 0000000..79bf9e4
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/property-object-reference-1.mm
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -x objective-c++ %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// rdar://6137845
+
+struct TCPPObject
+{
+ TCPPObject(const TCPPObject& inObj);
+ TCPPObject();
+ ~TCPPObject();
+ int filler[64];
+};
+
+
+@interface MyDocument
+{
+@private
+ TCPPObject _cppObject;
+}
+@property (atomic, assign, readwrite) const TCPPObject& cppObject;
+@end
+
+@implementation MyDocument
+
+@synthesize cppObject = _cppObject;
+
+@end
+
+// CHECK: [[cppObjectaddr:%.*]] = alloca %struct.TCPPObject*, align 8
+// CHECK: store %struct.TCPPObject* [[cppObject:%.*]], %struct.TCPPObject** [[cppObjectaddr]], align 8
+// CHECK: [[THREE:%.*]] = load %struct.TCPPObject** [[cppObjectaddr]], align 8
+// CHECK: [[FOUR:%.*]] = bitcast %struct.TCPPObject* [[THREE]] to i8*
+// CHECK: call void @objc_copyStruct(i8* [[TWO:%.*]], i8* [[FOUR]], i64 256, i1 zeroext true, i1 zeroext false)
diff --git a/clang/test/CodeGenObjCXX/property-object-reference-2.mm b/clang/test/CodeGenObjCXX/property-object-reference-2.mm
new file mode 100644
index 0000000..b150a3e
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/property-object-reference-2.mm
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// rdar://6137845
+
+extern int DEFAULT();
+
+struct TCPPObject
+{
+ TCPPObject();
+ ~TCPPObject();
+ TCPPObject(const TCPPObject& inObj, int i = DEFAULT());
+ TCPPObject& operator=(const TCPPObject& inObj);
+ int filler[64];
+};
+
+
+@interface MyDocument
+{
+@private
+ TCPPObject _cppObject;
+ TCPPObject _cppObject1;
+}
+@property (assign, readwrite, atomic) const TCPPObject MyProperty;
+@property (assign, readwrite, atomic) const TCPPObject MyProperty1;
+@end
+
+@implementation MyDocument
+ @synthesize MyProperty = _cppObject;
+ @synthesize MyProperty1 = _cppObject1;
+@end
+
+// CHECK: define internal void @__copy_helper_atomic_property_(
+// CHECK: [[TWO:%.*]] = load %struct.TCPPObject** [[ADDR:%.*]], align 8
+// CHECK: [[THREE:%.*]] = load %struct.TCPPObject** [[ADDR1:%.*]], align 8
+// CHECK: [[CALL:%.*]] = call i32 @_Z7DEFAULTv()
+// CHECK: call void @_ZN10TCPPObjectC1ERKS_i(%struct.TCPPObject* [[TWO]], %struct.TCPPObject* [[THREE]], i32 [[CALL]])
+// CHECK: ret void
+
+// CHECK: define internal void @"\01-[MyDocument MyProperty]"(
+// CHECK: [[ONE:%.*]] = bitcast i8* [[ADDPTR:%.*]] to %struct.TCPPObject*
+// CHECK: [[TWO:%.*]] = bitcast %struct.TCPPObject* [[ONE]] to i8*
+// CHECK: [[THREE:%.*]] = bitcast %struct.TCPPObject* [[AGGRESULT:%.*]] to i8*
+// CHECK: call void @objc_copyCppObjectAtomic(i8* [[THREE]], i8* [[TWO]], i8* bitcast (void (%struct.TCPPObject*, %struct.TCPPObject*)* @__copy_helper_atomic_property_ to i8*))
+// CHECK: ret void
+
+// CHECK: define internal void @__assign_helper_atomic_property_(
+// CHECK: [[TWO:%.*]] = load %struct.TCPPObject** [[ADDR:%.*]], align 8
+// CHECK: [[THREE:%.*]] = load %struct.TCPPObject** [[ADDR1:%.*]], align 8
+// CHECK: [[CALL:%.*]] = call %struct.TCPPObject* @_ZN10TCPPObjectaSERKS_(%struct.TCPPObject* [[TWO]], %struct.TCPPObject* [[THREE]])
+// CHECK: ret void
+
+// CHECK: define internal void @"\01-[MyDocument setMyProperty:]"(
+// CHECK: [[ONE:%.*]] = bitcast i8* [[ADDRPTR:%.*]] to %struct.TCPPObject*
+// CHECK: [[TWO:%.*]] = bitcast %struct.TCPPObject* [[ONE]] to i8*
+// CHECK: [[THREE:%.*]] = bitcast %struct.TCPPObject* [[MYPROPERTY:%.*]] to i8*
+// CHECK: call void @objc_copyCppObjectAtomic(i8* [[TWO]], i8* [[THREE]], i8* bitcast (void (%struct.TCPPObject*, %struct.TCPPObject*)* @__assign_helper_atomic_property_ to i8*))
+// CHECK: ret void
diff --git a/clang/test/CodeGenObjCXX/property-object-reference.mm b/clang/test/CodeGenObjCXX/property-object-reference.mm
new file mode 100644
index 0000000..0bd8fb8
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/property-object-reference.mm
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - | FileCheck %s
+// rdar://10188258
+
+struct Foo {int i;};
+static Foo gFoo;
+
+
+@interface ObjCTest { }
+@property (nonatomic, readonly) Foo& FooRefProperty;
+@property (nonatomic) Foo FooProperty;
+- (Foo &) FooProperty;
+- (void)setFooProperty : (Foo &) arg;
+@end
+
+
+@implementation ObjCTest
+@dynamic FooRefProperty;
+
+-(void) test {
+ Foo& f = self.FooRefProperty;
+ Foo& f1 = self.FooProperty;
+}
+- (Foo &) FooProperty { return gFoo; }
+- (void)setFooProperty : (Foo &) arg { };
+@end
+
+// CHECK: [[T0:%.*]] = load {{%.*}} [[S0:%.*]]
+// CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK: [[T2:%.*]] = bitcast {{%.*}} [[T0]] to i8*
+// CHECK: @objc_msgSend
+// CHECK: [[R0:%.*]] = load {{%.*}} [[U0:%.*]]
+// CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK: [[R2:%.*]] = bitcast {{%.*}} [[R0]] to i8*
+// CHECK: @objc_msgSend
+
diff --git a/clang/test/CodeGenObjCXX/property-objects.mm b/clang/test/CodeGenObjCXX/property-objects.mm
new file mode 100644
index 0000000..6dfcc27
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/property-objects.mm
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// CHECK-NOT: callq _objc_msgSend_stret
+// CHECK: call void @_ZN1SC1ERKS_
+// CHECK: call %class.S* @_ZN1SaSERKS_
+// CHECK: call %struct.CGRect* @_ZN6CGRectaSERKS_
+
+class S {
+public:
+ S& operator = (const S&);
+ S (const S&);
+ S ();
+};
+
+struct CGRect {
+ CGRect & operator = (const CGRect &);
+};
+
+@interface I {
+ S position;
+ CGRect bounds;
+}
+@property(assign, nonatomic) S position;
+@property CGRect bounds;
+@property CGRect frame;
+- (void)setFrame:(CGRect)frameRect;
+- (CGRect)frame;
+- (void) initWithOwner;
+- (struct CGRect)extent;
+- (void)dealloc;
+@end
+
+@implementation I
+@synthesize position;
+@synthesize bounds;
+@synthesize frame;
+- (void)setFrame:(CGRect)frameRect {}
+- (CGRect)frame {return bounds;}
+
+- (void)initWithOwner {
+ I* _labelLayer;
+ CGRect labelLayerFrame = self.bounds;
+ labelLayerFrame = self.bounds;
+ _labelLayer.frame = labelLayerFrame;
+}
+// rdar://8366604
+- (void)dealloc
+ {
+ CGRect cgrect = self.extent;
+ }
+- (struct CGRect)extent {return bounds;}
+@end
+
+int main() {
+ I *i;
+ S s1;
+ i.position = s1;
+ return 0;
+}
+
+// rdar://8379892
+// CHECK: define void @_Z1fP1A
+// CHECK: @objc_msgSend to void
+struct X {
+ X();
+ X(const X&);
+ ~X();
+};
+
+@interface A {
+ X xval;
+}
+- (X)x;
+- (void)setX:(X)x;
+@end
+
+void f(A* a) {
+ a.x = X();
+}
diff --git a/clang/test/CodeGenObjCXX/property-reference.mm b/clang/test/CodeGenObjCXX/property-reference.mm
new file mode 100644
index 0000000..4897f6d
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/property-reference.mm
@@ -0,0 +1,96 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - | FileCheck %s
+// rdar://9208606
+
+struct MyStruct {
+ int x;
+ int y;
+ int z;
+};
+
+@interface MyClass {
+ MyStruct _foo;
+}
+
+@property (assign, readwrite) const MyStruct& foo;
+
+- (const MyStruct&) foo;
+- (void) setFoo:(const MyStruct&)inFoo;
+@end
+
+void test0() {
+ MyClass* myClass;
+ MyStruct myStruct;
+
+ myClass.foo = myStruct;
+
+ const MyStruct& currentMyStruct = myClass.foo;
+}
+
+// CHECK: [[C:%.*]] = call %struct.MyStruct* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: store %struct.MyStruct* [[C]], %struct.MyStruct** [[D:%.*]]
+
+namespace test1 {
+ struct A { A(); A(const A&); A&operator=(const A&); ~A(); };
+}
+@interface Test1 {
+ test1::A ivar;
+}
+@property (nonatomic) const test1::A &prop1;
+@end
+@implementation Test1
+@synthesize prop1 = ivar;
+@end
+// CHECK: define internal [[A:%.*]]* @"\01-[Test1 prop1]"(
+// CHECK: [[SELF:%.*]] = alloca [[TEST1:%.*]]*, align 8
+// CHECK: [[T0:%.*]] = load [[TEST1]]** [[SELF]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
+// CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds i8* [[T1]], i64 0
+// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[A]]*
+// CHECK-NEXT: ret [[A]]* [[T3]]
+
+// CHECK: define internal void @"\01-[Test1 setProp1:]"(
+// CHECK: call [[A]]* @_ZN5test11AaSERKS0_(
+// CHECK-NEXT: ret void
+
+// rdar://problem/10497174
+@interface Test2
+@property int prop;
+@end
+
+// The fact that these are all non-dependent is critical.
+template <class T> void test2(Test2 *a) {
+ int x = a.prop;
+ a.prop = x;
+ a.prop += x;
+}
+template void test2<int>(Test2*);
+// CHECK: define weak_odr void @_Z5test2IiEvP5Test2(
+// CHECK: [[X:%.*]] = alloca i32,
+// CHECK: @objc_msgSend
+// CHECK: store i32 {{%.*}}, i32* [[X]],
+// CHECK: load i32* [[X]],
+// CHECK: @objc_msgSend
+// CHECK: @objc_msgSend
+// CHECK: load i32* [[X]],
+// CHECK-NEXT: add nsw
+// CHECK: @objc_msgSend
+// CHECK-NEXT: ret void
+
+// Same as the previous test, but instantiation-dependent.
+template <class T> void test3(Test2 *a) {
+ int x = (sizeof(T), a).prop;
+ a.prop = (sizeof(T), x);
+ a.prop += (sizeof(T), x);
+}
+template void test3<int>(Test2*);
+// CHECK: define weak_odr void @_Z5test3IiEvP5Test2(
+// CHECK: [[X:%.*]] = alloca i32,
+// CHECK: @objc_msgSend
+// CHECK: store i32 {{%.*}}, i32* [[X]],
+// CHECK: load i32* [[X]],
+// CHECK: @objc_msgSend
+// CHECK: @objc_msgSend
+// CHECK: load i32* [[X]],
+// CHECK-NEXT: add nsw
+// CHECK: @objc_msgSend
+// CHECK-NEXT: ret void
diff --git a/clang/test/CodeGenObjCXX/refence-assign-write-barrier.mm b/clang/test/CodeGenObjCXX/refence-assign-write-barrier.mm
new file mode 100644
index 0000000..206ecb0
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/refence-assign-write-barrier.mm
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s
+// rdar://8681766
+
+@interface NSArray
+- (NSArray*) retain;
+- (void) release;
+@end
+
+void NSAssignArray(NSArray*& target, NSArray* newValue)
+{
+ if (target == newValue)
+ return;
+
+ NSArray* oldValue = target;
+
+ target = [newValue retain];
+
+ [oldValue release];
+}
+// CHECK: {{call.* @objc_assign_strongCast}}
diff --git a/clang/test/CodeGenObjCXX/references.mm b/clang/test/CodeGenObjCXX/references.mm
new file mode 100644
index 0000000..6265c7b
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/references.mm
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+struct A { ~A(); };
+
+@interface B {
+ A a;
+}
+
+- (const A&)getA;
+@end
+
+@implementation B
+
+- (const A&)getA {
+ return a;
+}
+
+@end
+
+// CHECK: define void @_Z1fP1B
+// CHECK: objc_msgSend to
+// CHECK-NOT: call void @_ZN1AD1Ev
+// CHECK: ret void
+void f(B* b) {
+ (void)[b getA];
+}
+
+// PR7741
+@protocol P1 @end
+@protocol P2 @end
+@protocol P3 @end
+@interface foo<P1> {} @end
+@interface bar : foo <P1, P2, P3> {} @end
+typedef bar baz;
+void f5(foo&);
+void f5b(foo<P1>&);
+void f5c(foo<P2>&);
+void f5d(foo<P3>&);
+void f6(baz* x) {
+ f5(*x);
+ f5b(*x);
+ f5c(*x);
+ f5d(*x);
+ (void)((foo&)*x);
+}
diff --git a/clang/test/CodeGenObjCXX/rtti.mm b/clang/test/CodeGenObjCXX/rtti.mm
new file mode 100644
index 0000000..72de3ac
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/rtti.mm
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// PR7864. This all follows GCC's lead.
+
+namespace std { class type_info; }
+
+// CHECK: @_ZTI1A = linkonce_odr unnamed_addr constant {{.*}}@_ZTVN10__cxxabiv117__class_type_infoE{{.*}}@_ZTS1A
+@interface A
+@end
+
+// CHECK: @_ZTI1B = linkonce_odr unnamed_addr constant {{.*}}@_ZTVN10__cxxabiv120__si_class_type_infoE{{.*}}@_ZTS1B{{.*}}@_ZTI1A
+@interface B : A
+@end
+
+// CHECK: @_ZTIP1B = linkonce_odr unnamed_addr constant {{.*}}@_ZTVN10__cxxabiv119__pointer_type_infoE{{.*}}@_ZTSP1B{{.*}}), i32 0, {{.*}}@_ZTI1B
+// CHECK: @_ZTI11objc_object = linkonce_odr unnamed_addr constant {{.*}}@_ZTVN10__cxxabiv117__class_type_infoE{{.*}}@_ZTS11objc_object
+// CHECK: @_ZTIP11objc_object = linkonce_odr unnamed_addr constant {{.*}}@_ZTVN10__cxxabiv119__pointer_type_infoE{{.*}}@_ZTSP11objc_object{{.*}}@_ZTI11objc_object
+// CHECK: @_ZTI10objc_class = linkonce_odr unnamed_addr constant {{.*}}@_ZTVN10__cxxabiv117__class_type_infoE{{.*}}@_ZTS10objc_class
+// CHECK: @_ZTIP10objc_class = linkonce_odr unnamed_addr constant {{.*}}@_ZTVN10__cxxabiv119__pointer_type_infoE{{.*}}@_ZTSP10objc_class{{.*}}@_ZTI10objc_class
+
+@protocol P;
+
+int main() {
+ // CHECK: store {{.*}} @_ZTIP1B
+ // CHECK: store {{.*}} @_ZTI1B
+ const std::type_info &t1 = typeid(B*);
+ const std::type_info &t2 = typeid(B);
+
+ // CHECK: store {{.*}} @_ZTIP11objc_object
+ // CHECK: store {{.*}} @_ZTI11objc_object
+ id i = 0;
+ const std::type_info &t3 = typeid(i);
+ const std::type_info &t4 = typeid(*i);
+
+ // CHECK: store {{.*}} @_ZTIP10objc_class
+ // CHECK: store {{.*}} @_ZTI10objc_class
+ Class c = 0;
+ const std::type_info &t5 = typeid(c);
+ const std::type_info &t6 = typeid(*c);
+
+ // CHECK: store {{.*}} @_ZTIP11objc_object
+ // CHECK: store {{.*}} @_ZTI11objc_object
+ id<P> i2 = 0;
+ const std::type_info &t7 = typeid(i2);
+ const std::type_info &t8 = typeid(*i2);
+
+ // CHECK: store {{.*}} @_ZTIP10objc_class
+ // CHECK: store {{.*}} @_ZTI10objc_class
+ Class<P> c2 = 0;
+ const std::type_info &t9 = typeid(c2);
+ const std::type_info &t10 = typeid(*c2);
+}
diff --git a/clang/test/CodeGenObjCXX/selector-expr-lvalue.mm b/clang/test/CodeGenObjCXX/selector-expr-lvalue.mm
new file mode 100644
index 0000000..3e3bf4e
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/selector-expr-lvalue.mm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s
+// PR7390
+
+@interface NSObject {}
+- (void)respondsToSelector:(const SEL&)s : (SEL*)s1;
+- (void) setPriority:(int)p;
+- (void)Meth;
+@end
+
+@implementation NSObject
+- (void)Meth {
+ [self respondsToSelector:@selector(setPriority:) : &@selector(setPriority:)];
+}
+- (void) setPriority:(int)p{}
+- (void)respondsToSelector:(const SEL&)s : (SEL*)s1 {}
+@end
diff --git a/clang/test/CodeGenObjCXX/write-barrier-global-assign.mm b/clang/test/CodeGenObjCXX/write-barrier-global-assign.mm
new file mode 100644
index 0000000..cb563f3
--- /dev/null
+++ b/clang/test/CodeGenObjCXX/write-barrier-global-assign.mm
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s
+// rdar://8761767
+
+@class CPDestUser;
+
+CPDestUser* FUNC();
+
+// CHECK: {{call.* @objc_assign_global}}
+CPDestUser* globalUser = FUNC();
+
+// CHECK: {{call.* @objc_assign_weak}}
+__weak CPDestUser* weakUser = FUNC();
+
+
+// CHECK: {{call.* @objc_assign_global}}
+static CPDestUser* staticUser = FUNC();
+
+CPDestUser* GetDestUser()
+{
+// CHECK: {{call.* @objc_assign_global}}
+ static CPDestUser* gUser = FUNC();
+// CHECK: {{call.* @objc_assign_weak}}
+ static __weak CPDestUser* wUser = FUNC();
+ if (wUser)
+ return wUser;
+ if (staticUser)
+ return staticUser;
+ return gUser;
+}
diff --git a/clang/test/CodeGenOpenCL/2011-04-15-vec-init-from-vec.cl b/clang/test/CodeGenOpenCL/2011-04-15-vec-init-from-vec.cl
new file mode 100644
index 0000000..fbe3d89
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/2011-04-15-vec-init-from-vec.cl
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+
+typedef __attribute__((ext_vector_type(4))) unsigned char uchar4;
+typedef __attribute__((ext_vector_type(8))) unsigned char uchar8;
+
+// OpenCL allows vectors to be initialized by vectors Handle bug in
+// VisitInitListExpr for this case below.
+void foo( uchar8 x )
+{
+ uchar4 val[4] = {{(uchar4){x.lo}}};
+}
diff --git a/clang/test/CodeGenOpenCL/address-spaces.cl b/clang/test/CodeGenOpenCL/address-spaces.cl
new file mode 100644
index 0000000..e030c77
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/address-spaces.cl
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -ffake-address-space-map -emit-llvm -o - | FileCheck %s
+
+void f__p(__private int *arg) { }
+// CHECK: i32* nocapture %arg
+
+void f__g(__global int *arg) { }
+// CHECK: i32 addrspace(1)* nocapture %arg
+
+void f__l(__local int *arg) { }
+// CHECK: i32 addrspace(2)* nocapture %arg
+
+void f__c(__constant int *arg) { }
+// CHECK: i32 addrspace(3)* nocapture %arg
+
+
+void fp(private int *arg) { }
+// CHECK: i32* nocapture %arg
+
+void fg(global int *arg) { }
+// CHECK: i32 addrspace(1)* nocapture %arg
+
+void fl(local int *arg) { }
+// CHECK: i32 addrspace(2)* nocapture %arg
+
+void fc(constant int *arg) { }
+// CHECK: i32 addrspace(3)* nocapture %arg
+
diff --git a/clang/test/CodeGenOpenCL/ext-vector-shuffle.cl b/clang/test/CodeGenOpenCL/ext-vector-shuffle.cl
new file mode 100644
index 0000000..ee88ba3
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/ext-vector-shuffle.cl
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -cl-opt-disable -emit-llvm -o - | not grep 'extractelement'
+// RUN: %clang_cc1 %s -cl-opt-disable -emit-llvm -o - | not grep 'insertelement'
+// RUN: %clang_cc1 %s -cl-opt-disable -emit-llvm -o - | grep 'shufflevector'
+
+typedef __attribute__(( ext_vector_type(2) )) float float2;
+typedef __attribute__(( ext_vector_type(4) )) float float4;
+
+float2 test1(float4 V) {
+ return V.xy + V.wz;
+}
+
+float4 test2(float4 V) {
+ float2 W = V.ww;
+ return W.xyxy + W.yxyx;
+}
+
+float4 test3(float4 V1, float4 V2) { return (float4)(V1.zw, V2.xy); }
diff --git a/clang/test/CodeGenOpenCL/fpmath.cl b/clang/test/CodeGenOpenCL/fpmath.cl
new file mode 100644
index 0000000..704fcd7
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/fpmath.cl
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+typedef __attribute__(( ext_vector_type(4) )) float float4;
+
+float spscalardiv(float a, float b) {
+ // CHECK: @spscalardiv
+ // CHECK: fdiv{{.*}}, !fpmath ![[MD:[0-9]+]]
+ return a / b;
+}
+
+float4 spvectordiv(float4 a, float4 b) {
+ // CHECK: @spvectordiv
+ // CHECK: fdiv{{.*}}, !fpmath ![[MD]]
+ return a / b;
+}
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+double dpscalardiv(double a, double b) {
+ // CHECK: @dpscalardiv
+ // CHECK-NOT: !fpmath
+ return a / b;
+}
+
+// CHECK: ![[MD]] = metadata !{float 2.500000e+00}
diff --git a/clang/test/CodeGenOpenCL/kernel-metadata.cl b/clang/test/CodeGenOpenCL/kernel-metadata.cl
new file mode 100644
index 0000000..3e10a11
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/kernel-metadata.cl
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+void normal_function() {
+}
+
+__kernel void kernel_function() {
+}
+
+// CHECK: !opencl.kernels = !{!0}
+// CHECK: !0 = metadata !{void ()* @kernel_function}
diff --git a/clang/test/CodeGenOpenCL/local.cl b/clang/test/CodeGenOpenCL/local.cl
new file mode 100644
index 0000000..32fa7be
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/local.cl
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -ffake-address-space-map -emit-llvm -o - | FileCheck %s
+
+__kernel void foo(void) {
+ // CHECK: @foo.i = internal addrspace(2)
+ __local int i;
+ ++i;
+}
diff --git a/clang/test/CodeGenOpenCL/ptx-calls.cl b/clang/test/CodeGenOpenCL/ptx-calls.cl
new file mode 100644
index 0000000..6f33640
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/ptx-calls.cl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -triple ptx32-unknown-unknown -emit-llvm -O0 -o - | FileCheck %s
+
+void device_function() {
+}
+// CHECK: define ptx_device void @device_function()
+
+__kernel void kernel_function() {
+ device_function();
+}
+// CHECK: define ptx_kernel void @kernel_function()
+// CHECK: call ptx_device void @device_function()
+
diff --git a/clang/test/CodeGenOpenCL/ptx-kernels.cl b/clang/test/CodeGenOpenCL/ptx-kernels.cl
new file mode 100644
index 0000000..4d6fa10
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/ptx-kernels.cl
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -triple ptx32-unknown-unknown -emit-llvm -o - | FileCheck %s
+
+void device_function() {
+}
+// CHECK: define ptx_device void @device_function()
+
+__kernel void kernel_function() {
+}
+// CHECK: define ptx_kernel void @kernel_function()
+
diff --git a/clang/test/CodeGenOpenCL/single-precision-constant.cl b/clang/test/CodeGenOpenCL/single-precision-constant.cl
new file mode 100644
index 0000000..62b37c1
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/single-precision-constant.cl
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -cl-single-precision-constant -emit-llvm -o - | FileCheck %s
+
+float fn(float f) {
+ // CHECK: fmul float
+ // CHECK: fadd float
+ return f*2. + 1.;
+}
diff --git a/clang/test/CodeGenOpenCL/vector_literals_nested.cl b/clang/test/CodeGenOpenCL/vector_literals_nested.cl
new file mode 100644
index 0000000..b9013d0
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/vector_literals_nested.cl
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -emit-llvm -O3 -o - | FileCheck %s
+
+typedef int int2 __attribute((ext_vector_type(2)));
+typedef int int4 __attribute((ext_vector_type(4)));
+
+__constant const int4 itest1 = (int4)(1, 2, ((int2)(3, 4)));
+// CHECK: constant <4 x i32> <i32 1, i32 2, i32 3, i32 4>
+__constant const int4 itest2 = (int4)(1, 2, ((int2)(3)));
+// CHECK: constant <4 x i32> <i32 1, i32 2, i32 3, i32 3>
+
+typedef float float2 __attribute((ext_vector_type(2)));
+typedef float float4 __attribute((ext_vector_type(4)));
+
+void ftest1(float4 *p) {
+ *p = (float4)(1.1f, 1.2f, ((float2)(1.3f, 1.4f)));
+// CHECK: store <4 x float> <float 0x3FF19999A0000000, float 0x3FF3333340000000, float 0x3FF4CCCCC0000000, float 0x3FF6666660000000>
+}
+
+float4 ftest2(float4 *p) {
+ *p = (float4)(1.1f, 1.2f, ((float2)(1.3f)));
+// CHECK: store <4 x float> <float 0x3FF19999A0000000, float 0x3FF3333340000000, float 0x3FF4CCCCC0000000, float 0x3FF4CCCCC0000000>
+}
+
diff --git a/clang/test/CodeGenOpenCL/vector_literals_valid.cl b/clang/test/CodeGenOpenCL/vector_literals_valid.cl
new file mode 100644
index 0000000..bba5b23
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/vector_literals_valid.cl
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+typedef __attribute__(( ext_vector_type(2) )) int int2;
+typedef __attribute__(( ext_vector_type(3) )) int int3;
+typedef __attribute__(( ext_vector_type(4) )) int int4;
+typedef __attribute__(( ext_vector_type(8) )) int int8;
+typedef __attribute__(( ext_vector_type(4) )) float float4;
+
+void vector_literals_valid() {
+ int4 a_1_1_1_1 = (int4)(1,2,3,4);
+ int4 a_2_1_1 = (int4)((int2)(1,2),3,4);
+ int4 a_1_2_1 = (int4)(1,(int2)(2,3),4);
+ int4 a_1_1_2 = (int4)(1,2,(int2)(3,4));
+ int4 a_2_2 = (int4)((int2)(1,2),(int2)(3,4));
+ int4 a_3_1 = (int4)((int3)(1,2,3),4);
+ int4 a_1_3 = (int4)(1,(int3)(2,3,4));
+ int4 a = (int4)(1);
+ int8 b = (int8)(1,2,a.xy,a);
+ float4 V2 = (float4) (1);
+}
+
+
diff --git a/clang/test/CodeGenOpenCL/vector_logops.cl b/clang/test/CodeGenOpenCL/vector_logops.cl
new file mode 100644
index 0000000..388f1d7
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/vector_logops.cl
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -O3 %s -emit-llvm -o - | FileCheck %s
+
+typedef int int2 __attribute((ext_vector_type(2)));
+
+int test1()
+{
+ int2 a = (int2)(1,0);
+ int2 b = (int2)(1,1);
+ return (a&&b).x + (a||b).y;
+ // CHECK: ret i32 -2
+}
+
+int test2()
+{
+ int2 a = (int2)(1,0);
+ return (!a).y;
+ // CHECK: ret i32 -1
+}
+
diff --git a/clang/test/Coverage/ast-printing.c b/clang/test/Coverage/ast-printing.c
new file mode 100644
index 0000000..ecaf3ab
--- /dev/null
+++ b/clang/test/Coverage/ast-printing.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -ast-print %s
+// RUN: %clang_cc1 -ast-dump %s
+// RUN: %clang_cc1 -print-decl-contexts %s
+
+#include "c-language-features.inc"
diff --git a/clang/test/Coverage/ast-printing.cpp b/clang/test/Coverage/ast-printing.cpp
new file mode 100644
index 0000000..3205078
--- /dev/null
+++ b/clang/test/Coverage/ast-printing.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -ast-print %s
+// RUN: %clang_cc1 -ast-dump %s
+// RUN: %clang_cc1 -print-decl-contexts %s
+// RUN: %clang_cc1 -fdump-record-layouts %s
+
+#include "cxx-language-features.inc"
diff --git a/clang/test/Coverage/ast-printing.m b/clang/test/Coverage/ast-printing.m
new file mode 100644
index 0000000..81c3a6b
--- /dev/null
+++ b/clang/test/Coverage/ast-printing.m
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-exceptions %s
+// RUN: %clang_cc1 -ast-print -fobjc-exceptions %s
+// RUN: %clang_cc1 -ast-dump -fobjc-exceptions %s
+
+#include "objc-language-features.inc"
diff --git a/clang/test/Coverage/c-language-features.inc b/clang/test/Coverage/c-language-features.inc
new file mode 100644
index 0000000..0ff1237
--- /dev/null
+++ b/clang/test/Coverage/c-language-features.inc
@@ -0,0 +1,198 @@
+//-*- C -*-
+
+/* This is a
+ multiline comment */
+
+// Intended to exercise all syntactic parts of the C language.
+
+int g0;
+int g1, g2;
+
+struct s0;
+
+struct s0 {
+ int x;
+};
+
+int g3 = 10;
+
+__asm("");
+
+typedef int td0;
+
+td0 g4;
+
+enum e0 {
+ ec0
+};
+
+static void f0(int x) {
+}
+
+inline void f0_0(int x) {
+ ;
+}
+
+extern void f0_1(int x) {
+}
+
+void f1(int, ...);
+
+// Statements.
+void f2() {
+ for (;;) {
+ break;
+ continue;
+ }
+
+ while (0) {
+ }
+
+ do {
+ } while (0);
+
+ void *label = &&theif;
+ goto *label;
+
+ goto theif;
+theif:
+ if (0) {
+ ;
+ } else if (0) {
+ } else {
+ }
+
+ switch(0) {
+ case 0:
+ case 1 ... 2:
+ break;
+ default:
+ break;
+ }
+
+ asm ("nop");
+
+ return;
+}
+
+// Expressions.
+
+#include <stdarg.h>
+
+typedef struct ipair {
+ int first, second;
+} ipair;
+
+void f4(int a0, int a1, int a2, va_list ap) {
+ int t0 = a0 ? a1 : a2;
+ float t1 = (float) a0;
+ ipair t2 = {1, 2};
+ ipair t2a = { .second = 2 };
+ int t3 = sizeof(ipair);
+ ipair t4;
+ t4 = (ipair) {1, 2};
+ extern int g(int);
+ int t5 = g(a0);
+ int t6 = t4.first;
+ int t7[10];
+ int t8 = t7[a0];
+ t8++;
+ const char *t9 = __FUNCTION__;
+ char t10 = 'x';
+ int t11 = __builtin_offsetof(ipair, first);
+ int t12 = __builtin_types_compatible_p(ipair, int);
+ int t12_0 = __builtin_classify_type(t0);
+ int t12_1 = __builtin_classify_type(t1);
+ int t12_2 = __builtin_classify_type(t2);
+ // FIXME: Add _Complex and aggregate cases.
+ int t13 = va_arg(ap, int);
+ va_list t13_0;
+ va_copy(t13_0, ap);
+ int t14 = __extension__(t13);
+ int t15 = +t13;
+ unsigned t16 = t14 ^ t15;
+ int t17 = t14 % t15;
+ int t17_0 = t16 % t16;
+ float t18;
+ int t19 = t18 ? 0 : 1;
+ char *t20; ++t20; --t20;
+ float t21; ++t21; --t21;
+ double t22; ++t22; --t22;
+ long double t23; ++t23; --t23;
+ int t24 = !t19;
+ int t25 = __real t24;
+ int t26 = __imag t24;
+ const char *t27 = t9;
+ t27 += (unsigned char) 0xFF;
+ t27 += (signed char) 0xFF;
+
+ struct { char f0[10]; } *t28;
+ int t29 = t28 - t28;
+ char *t30 = &t28->f0[1];
+
+ struct s1 { int f0; };
+ struct s1 t31_a, t31_b;
+ int t31_cond;
+ int t31 = (t31_cond ? t31_a : t31_b).f0;
+
+ _Complex float t32_a, t32_b;
+ int t32_cond;
+ int t32 = __real (t32_cond ? t32_a : t32_b);
+
+ struct { int x, y; } t33, *t34, t35[12], t36(int, float);
+ float t37, *t38, t39[9], t40(double);
+}
+
+// Extended vectors
+
+typedef __attribute__((ext_vector_type(2))) float float2;
+typedef __attribute__((ext_vector_type(4))) float float4;
+
+void f5() {
+ float4 t0 = (float4) { 0, 1, 2, 3 };
+ float4 t1 = t0;
+ t0.lo.even = t1.hi.x;
+
+ // irgen doesn't support this yet.
+#if 0
+ int t2_cond;
+ float2 t2 = (t2_cond ? t0 : t1).lo;
+#endif
+}
+
+void f6() {
+ const char *s0 = __func__;
+ const char *s1 = __FUNCTION__;
+ const char *s2 = __PRETTY_FUNCTION__;
+}
+
+// Arg mismatch with passed type.
+void f7(x)
+ float x;
+{
+}
+
+void f8(x)
+ short x;
+{
+}
+
+// Function which inputs an array
+void f9(int x[]) { }
+
+// Object literals.
+void f10() {
+ struct f10_s0 {
+ char iv0[10];
+ } x;
+
+ x = (struct f10_s0) { .iv0 = "name" };
+}
+
+// Nested structures.
+struct s11 {
+ struct s11_2 {
+ int f0;
+ } f0;
+ int f1;
+};
diff --git a/clang/test/Coverage/codegen-gnu.m b/clang/test/Coverage/codegen-gnu.m
new file mode 100644
index 0000000..432637c
--- /dev/null
+++ b/clang/test/Coverage/codegen-gnu.m
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-exceptions -fgnu-runtime -emit-llvm -o %t %s
+
+#include "objc-language-features.inc"
diff --git a/clang/test/Coverage/codegen-next.m b/clang/test/Coverage/codegen-next.m
new file mode 100644
index 0000000..8f6645d
--- /dev/null
+++ b/clang/test/Coverage/codegen-next.m
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -emit-llvm -fobjc-exceptions -o %t %s
+// RUN: %clang_cc1 -g -emit-llvm -fobjc-exceptions -o %t %s
+
+#include "objc-language-features.inc"
diff --git a/clang/test/Coverage/codegen.c b/clang/test/Coverage/codegen.c
new file mode 100644
index 0000000..8e5195c
--- /dev/null
+++ b/clang/test/Coverage/codegen.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm-bc -o %t %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -g -emit-llvm-bc -o %t %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm-bc -o %t %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -g -emit-llvm-bc -o %t %s
+
+#include "c-language-features.inc"
diff --git a/clang/test/Coverage/cxx-language-features.inc b/clang/test/Coverage/cxx-language-features.inc
new file mode 100644
index 0000000..31b50be
--- /dev/null
+++ b/clang/test/Coverage/cxx-language-features.inc
@@ -0,0 +1,27 @@
+//-*- C++ -*-
+
+// Intended to exercise all syntactic parts of the C++ language that
+// aren't part of C.
+
+namespace std {
+ namespace debug {
+ }
+}
+
+using namespace std::debug;
+using namespace std;
+
+namespace safestl = ::std::debug;
+
+class Base1 {
+};
+
+class Base2 { };
+
+class Derived1 : Base1, virtual public Base2 { };
+
+/* Template classes, template functions */
+enum E1 { EC1 };
+template <E1 v> class C1 {};
+template <E1 v> C1<v> f1() { return C1<v>(); }
+void f2() { f1<EC1>(); }
diff --git a/clang/test/Coverage/html-diagnostics.c b/clang/test/Coverage/html-diagnostics.c
new file mode 100644
index 0000000..4f1b0e3
--- /dev/null
+++ b/clang/test/Coverage/html-diagnostics.c
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t %s
+// RUN: cat %t/*.html | FileCheck %s
+
+// CHECK: <h3>Annotated Source Code</h3>
+
+// Without tweaking expr, the expr would hit to the line below
+// emitted to the output as comment.
+// CHECK: {{[D]ereference of null pointer}}
+
+void f0(int x) {
+ int *p = &x;
+
+ if (x > 10) {
+ if (x == 22)
+ p = 0;
+ }
+
+ *p = 10;
+}
+
+
diff --git a/clang/test/Coverage/html-print.c b/clang/test/Coverage/html-print.c
new file mode 100644
index 0000000..a3f29c6
--- /dev/null
+++ b/clang/test/Coverage/html-print.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-html -o %t %s
+
+#include "c-language-features.inc"
diff --git a/clang/test/Coverage/objc-language-features.inc b/clang/test/Coverage/objc-language-features.inc
new file mode 100644
index 0000000..dbbf205
--- /dev/null
+++ b/clang/test/Coverage/objc-language-features.inc
@@ -0,0 +1,87 @@
+//-*- ObjC -*-
+
+@protocol P0;
+
+@protocol P1
+-(void) fm0;
+@end
+
+@class B;
+
+@interface Root
+@end
+
+@interface A : Root <P1> {
+ int iv0;
+ B *iv1;
+ B<P1> *iv2;
+}
+
+@property(readonly) int p0;
+@property(assign,nonatomic,readwrite) int p1;
+@property(copy) id p2;
+@property(retain) id p3;
+@property(assign, getter=getme, setter=setme:) id p4;
+@property(assign, readwrite) id p5;
+@end
+
+@implementation A
+@dynamic p0;
+@synthesize p1 = iv0;
+
+// Property type can differ from ivar type.
+@synthesize p5 = iv2;
+
++(void) fm0 {
+ [super fm0];
+}
+-(void) im0 {
+ const char *s0 = __func__;
+ const char *s1 = __FUNCTION__;
+ const char *s2 = __PRETTY_FUNCTION__;
+ [super im0];
+ int x = super.p0;
+}
+-(void) im1: (int) x, ... {
+}
+@end
+
+@implementation C : A
+@end
+
+@interface A (Cat)
+@end
+
+@implementation A (Cat)
+@end
+
+@interface B
+@end
+
+int f0(id x) {
+ @synchronized(x) {
+ }
+
+ @try {
+ @throw x;
+
+ } @catch(A *e) {
+ @throw;
+
+ // @catch param doesn't require name.
+ } @catch(B *) {
+
+ } @finally {
+ ;
+ }
+
+ for (id y in x) {
+ break;
+ }
+}
+
+#ifndef __OBJC2__
+struct s0 {
+ @defs(A);
+};
+#endif
diff --git a/clang/test/Coverage/targets.c b/clang/test/Coverage/targets.c
new file mode 100644
index 0000000..7c05122
--- /dev/null
+++ b/clang/test/Coverage/targets.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -g -triple armv6-apple-darwin9 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple armv6-unknown-unknown -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple i686-apple-darwin9 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple i686-pc-linux-gnu -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple i686-unknown-dragonfly -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple i686-unknown-unknown -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple i686-unknown-win32 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple powerpc-apple-darwin9 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple powerpc-unknown-unknown -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple powerpc64-apple-darwin9 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple powerpc64-unknown-unknown -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple sparc-unknown-solaris -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple sparc-unknown-unknown -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple x86_64-apple-darwin9 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple x86_64-pc-linux-gnu -emit-llvm -o %t %s
+// RUN: %clang_cc1 -g -triple x86_64-unknown-unknown -emit-llvm -o %t %s
+
+// <rdar://problem/7181838> clang 1.0 fails to compile Python 2.6
+// RUN: %clang -target x86_64-apple-darwin9 -### -S %s -mmacosx-version-min=10.4
+
diff --git a/clang/test/Coverage/verbose.c b/clang/test/Coverage/verbose.c
new file mode 100644
index 0000000..72451d4
--- /dev/null
+++ b/clang/test/Coverage/verbose.c
@@ -0,0 +1 @@
+// RUN: %clang_cc1 -fsyntax-only -v %s
diff --git a/clang/test/Driver/Inputs/basic_freebsd64_tree/lib/.keep b/clang/test/Driver/Inputs/basic_freebsd64_tree/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_freebsd64_tree/lib/.keep
diff --git a/clang/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/.keep b/clang/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/.keep
diff --git a/clang/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/crt1.o b/clang/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/crt1.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/crt1.o
diff --git a/clang/test/Driver/Inputs/basic_freebsd64_tree/usr/lib32/.keep b/clang/test/Driver/Inputs/basic_freebsd64_tree/usr/lib32/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_freebsd64_tree/usr/lib32/.keep
diff --git a/clang/test/Driver/Inputs/basic_freebsd_tree/lib/.keep b/clang/test/Driver/Inputs/basic_freebsd_tree/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_freebsd_tree/lib/.keep
diff --git a/clang/test/Driver/Inputs/basic_freebsd_tree/usr/lib/.keep b/clang/test/Driver/Inputs/basic_freebsd_tree/usr/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_freebsd_tree/usr/lib/.keep
diff --git a/clang/test/Driver/Inputs/basic_freebsd_tree/usr/lib/crt1.o b/clang/test/Driver/Inputs/basic_freebsd_tree/usr/lib/crt1.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_freebsd_tree/usr/lib/crt1.o
diff --git a/clang/test/Driver/Inputs/basic_freebsd_tree/usr/lib32/.keep b/clang/test/Driver/Inputs/basic_freebsd_tree/usr/lib32/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_freebsd_tree/usr/lib32/.keep
diff --git a/clang/test/Driver/Inputs/basic_linux_tree/lib/.keep b/clang/test/Driver/Inputs/basic_linux_tree/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_linux_tree/lib/.keep
diff --git a/clang/test/Driver/Inputs/basic_linux_tree/usr/i386-unknown-linux/lib/.keep b/clang/test/Driver/Inputs/basic_linux_tree/usr/i386-unknown-linux/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_linux_tree/usr/i386-unknown-linux/lib/.keep
diff --git a/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/.keep b/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/.keep
diff --git a/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o b/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o
diff --git a/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o b/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o
diff --git a/clang/test/Driver/Inputs/basic_linux_tree/usr/x86_64-unknown-linux/lib/.keep b/clang/test/Driver/Inputs/basic_linux_tree/usr/x86_64-unknown-linux/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_linux_tree/usr/x86_64-unknown-linux/lib/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/lib/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/lib/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/lib/i386-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/lib/i386-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/lib/i386-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc64-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc64-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/lib/x86_64-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/lib/x86_64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/lib/x86_64-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/backward/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/backward/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/backward/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc64-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc64-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/x86_64-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/x86_64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/x86_64-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc64-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc64-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/x86_64-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/x86_64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/x86_64-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/i386-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/i386-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/i386-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc64-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc64-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/x86_64-linux-gnu/.keep b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/x86_64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/x86_64-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/fake_install_tree/bin/.keep b/clang/test/Driver/Inputs/fake_install_tree/bin/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/fake_install_tree/bin/.keep
diff --git a/clang/test/Driver/Inputs/fake_install_tree/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o b/clang/test/Driver/Inputs/fake_install_tree/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/fake_install_tree/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o
diff --git a/clang/test/Driver/Inputs/fake_install_tree/lib/gcc/x86_64-unknown-linux/4.5.0/crtbegin.o b/clang/test/Driver/Inputs/fake_install_tree/lib/gcc/x86_64-unknown-linux/4.5.0/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/fake_install_tree/lib/gcc/x86_64-unknown-linux/4.5.0/crtbegin.o
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing1/bin/.keep b/clang/test/Driver/Inputs/gcc_version_parsing1/bin/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing1/bin/.keep
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.6.99/crtbegin.o b/clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.6.99/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.6.99/crtbegin.o
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.6/crtbegin.o b/clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.6/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.6/crtbegin.o
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o b/clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7.1/crtbegin.o b/clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7.1/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7.1/crtbegin.o
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7/crtbegin.o b/clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing1/lib/gcc/i386-unknown-linux/4.7/crtbegin.o
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing2/bin/.keep b/clang/test/Driver/Inputs/gcc_version_parsing2/bin/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing2/bin/.keep
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.6.99/crtbegin.o b/clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.6.99/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.6.99/crtbegin.o
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.6.x/crtbegin.o b/clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.6.x/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.6.x/crtbegin.o
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o b/clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.1/crtbegin.o b/clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.1/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.1/crtbegin.o
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o b/clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing2/lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing3/bin/.keep b/clang/test/Driver/Inputs/gcc_version_parsing3/bin/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing3/bin/.keep
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.98/crtbegin.o b/clang/test/Driver/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.98/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.98/crtbegin.o
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o b/clang/test/Driver/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing3/lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing4/bin/.keep b/clang/test/Driver/Inputs/gcc_version_parsing4/bin/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing4/bin/.keep
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing4/lib/gcc/i386-unknown-linux/4.7.98/crtbegin.o b/clang/test/Driver/Inputs/gcc_version_parsing4/lib/gcc/i386-unknown-linux/4.7.98/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing4/lib/gcc/i386-unknown-linux/4.7.98/crtbegin.o
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing4/lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o b/clang/test/Driver/Inputs/gcc_version_parsing4/lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing4/lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o
diff --git a/clang/test/Driver/Inputs/gcc_version_parsing4/lib/gcc/i386-unknown-linux/4.7.99/crtbegin.o b/clang/test/Driver/Inputs/gcc_version_parsing4/lib/gcc/i386-unknown-linux/4.7.99/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/gcc_version_parsing4/lib/gcc/i386-unknown-linux/4.7.99/crtbegin.o
diff --git a/clang/test/Driver/Inputs/multiarch_freebsd64_tree/lib/.keep b/clang/test/Driver/Inputs/multiarch_freebsd64_tree/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multiarch_freebsd64_tree/lib/.keep
diff --git a/clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/.keep b/clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/.keep
diff --git a/clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/crt1.o b/clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/crt1.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/crt1.o
diff --git a/clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/.keep b/clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/.keep
diff --git a/clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/crt1.o b/clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/crt1.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/crt1.o
diff --git a/clang/test/Driver/Inputs/multilib_32bit_linux_tree/lib/.keep b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/lib/.keep
diff --git a/clang/test/Driver/Inputs/multilib_32bit_linux_tree/lib32/.keep b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/lib32/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/lib32/.keep
diff --git a/clang/test/Driver/Inputs/multilib_32bit_linux_tree/lib64/.keep b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/lib64/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/lib64/.keep
diff --git a/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib/.keep b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib/.keep
diff --git a/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib32/.keep b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib32/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib32/.keep
diff --git a/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib64/.keep b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib64/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib64/.keep
diff --git a/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/.keep b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/.keep
diff --git a/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/64/crtbegin.o b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/64/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/64/crtbegin.o
diff --git a/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o
diff --git a/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib32/.keep b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib32/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib32/.keep
diff --git a/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib64/.keep b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib64/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib64/.keep
diff --git a/clang/test/Driver/Inputs/multilib_64bit_linux_tree/lib/.keep b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/lib/.keep
diff --git a/clang/test/Driver/Inputs/multilib_64bit_linux_tree/lib32/.keep b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/lib32/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/lib32/.keep
diff --git a/clang/test/Driver/Inputs/multilib_64bit_linux_tree/lib64/.keep b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/lib64/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/lib64/.keep
diff --git a/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib/.keep b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib/.keep
diff --git a/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32/crtbegin.o b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32/crtbegin.o
diff --git a/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o
diff --git a/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib32/.keep b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib32/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib32/.keep
diff --git a/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib64/.keep b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib64/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/lib64/.keep
diff --git a/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/lib/.keep b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/lib/.keep
diff --git a/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/lib32/.keep b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/lib32/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/lib32/.keep
diff --git a/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/lib64/.keep b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/lib64/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/lib64/.keep
diff --git a/clang/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-as b/clang/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-as
new file mode 100755
index 0000000..d901134
--- /dev/null
+++ b/clang/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-as
@@ -0,0 +1,2 @@
+#!/bin/sh
+# This file must be executable to be picked up by GetProgramPath
diff --git a/clang/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-ld b/clang/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-ld
new file mode 100755
index 0000000..d901134
--- /dev/null
+++ b/clang/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-ld
@@ -0,0 +1,2 @@
+#!/bin/sh
+# This file must be executable to be picked up by GetProgramPath
diff --git a/clang/test/Driver/Inputs/suse_10.3_ppc64_tree/lib/.keep b/clang/test/Driver/Inputs/suse_10.3_ppc64_tree/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/suse_10.3_ppc64_tree/lib/.keep
diff --git a/clang/test/Driver/Inputs/suse_10.3_ppc64_tree/lib64/.keep b/clang/test/Driver/Inputs/suse_10.3_ppc64_tree/lib64/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/suse_10.3_ppc64_tree/lib64/.keep
diff --git a/clang/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/64/crtbegin.o b/clang/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/64/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/64/crtbegin.o
diff --git a/clang/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/crtbegin.o b/clang/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/crtbegin.o
diff --git a/clang/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib64/.keep b/clang/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib64/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib64/.keep
diff --git a/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/.keep b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/.keep
diff --git a/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/i386-linux-gnu/.keep b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/i386-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/i386-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/.keep b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/.keep
diff --git a/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/.keep b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/.keep
diff --git a/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/backward/.keep b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/backward/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/backward/.keep
diff --git a/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/i386-linux-gnu/.keep b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/i386-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/i386-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/.keep b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/.keep
diff --git a/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/.keep b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/.keep
diff --git a/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o
diff --git a/clang/test/Driver/Wp-args.c b/clang/test/Driver/Wp-args.c
new file mode 100644
index 0000000..0ab85b4
--- /dev/null
+++ b/clang/test/Driver/Wp-args.c
@@ -0,0 +1,13 @@
+// Check that we extract -MD from '-Wp,-MD,FOO', which is used by a number of
+// major projects (e.g., FireFox and the Linux Kernel).
+
+// RUN: %clang --target i386-pc-linux-gnu -### \
+// RUN: -Wp,-MD,FOO.d -fsyntax-only %s 2> %t
+// RUN: FileCheck < %t %s
+//
+// CHECK: "-cc1"
+// CHECK-NOT: -MD
+// CHECK: "-dependency-file" "FOO.d"
+// CHECK: "-MT"
+//
+// PR4062
diff --git a/clang/test/Driver/Xarch.c b/clang/test/Driver/Xarch.c
new file mode 100644
index 0000000..2523f5a
--- /dev/null
+++ b/clang/test/Driver/Xarch.c
@@ -0,0 +1,9 @@
+// RUN: %clang -target i386-apple-darwin9 -m32 -Xarch_i386 -O2 %s -S -### 2> %t.log
+// RUN: grep ' "-O2" ' %t.log | count 1
+// RUN: %clang -target i386-apple-darwin9 -m64 -Xarch_i386 -O2 %s -S -### 2> %t.log
+// RUN: grep ' "-O2" ' %t.log | count 0
+// RUN: grep "argument unused during compilation: '-Xarch_i386 -O2'" %t.log
+// RUN: not %clang -target i386-apple-darwin9 -m32 -Xarch_i386 -o -Xarch_i386 -S %s -S -Xarch_i386 -o 2> %t.log
+// RUN: grep "error: invalid Xarch argument: '-Xarch_i386 -o'" %t.log | count 2
+// RUN: grep "error: invalid Xarch argument: '-Xarch_i386 -S'" %t.log
+
diff --git a/clang/test/Driver/Xlinker-args.c b/clang/test/Driver/Xlinker-args.c
new file mode 100644
index 0000000..b4e5a9b
--- /dev/null
+++ b/clang/test/Driver/Xlinker-args.c
@@ -0,0 +1,9 @@
+// Check that we extract --no-demangle from '-Xlinker' and '-Wl,', since that
+// was a collect2 argument.
+
+// RUN: %clang -target i386-apple-darwin9 -### \
+// RUN: -Xlinker one -Xlinker --no-demangle \
+// RUN: -Wl,two,--no-demangle,three -Xlinker four %s 2> %t
+// RUN: FileCheck < %t %s
+//
+// CHECK: "one" "two" "three" "four"
diff --git a/clang/test/Driver/altivec.cpp b/clang/test/Driver/altivec.cpp
new file mode 100644
index 0000000..6059ad0
--- /dev/null
+++ b/clang/test/Driver/altivec.cpp
@@ -0,0 +1,14 @@
+// Check that we error when -faltivec is specified on non-ppc platforms.
+
+// RUN: %clang -ccc-clang-archs powerpc -target powerpc-apple-darwin -faltivec -fsyntax-only %s
+// RUN: %clang -ccc-clang-archs powerpc64 -target powerpc64-linux-gnu -faltivec -fsyntax-only %s
+
+// RUN: %clang -target i386-pc-win32 -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-unknown-freebsd -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -target armv6-apple-darwin -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -target armv7-apple-darwin -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -ccc-clang-archs mips -target mips-linux-gnu -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -ccc-clang-archs mips64 -target mips64-linux-gnu -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -ccc-clang-archs sparc -target sparc-unknown-solaris -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: invalid argument '-faltivec' only allowed with 'ppc/ppc64'
diff --git a/clang/test/Driver/analyze.c b/clang/test/Driver/analyze.c
new file mode 100644
index 0000000..68fa218
--- /dev/null
+++ b/clang/test/Driver/analyze.c
@@ -0,0 +1,8 @@
+// Verify that the analyzer gets the same flags as normal compilation
+// (at least for a few key ones).
+
+// RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 %clang -target i386-apple-darwin9 -### --analyze -o /dev/null %s -msse 2> %t.log
+// RUN: FileCheck --input-file=%t.log %s
+
+// CHECK: "-analyze"
+// CHECK: "-target-feature" "+sse"
diff --git a/clang/test/Driver/apple-kext-i386.cpp b/clang/test/Driver/apple-kext-i386.cpp
new file mode 100644
index 0000000..c11a136
--- /dev/null
+++ b/clang/test/Driver/apple-kext-i386.cpp
@@ -0,0 +1,50 @@
+// Check that we transparently fallback to llvm-gcc for i386 kexts, we don't
+// support the ABI they use (yet).
+
+// RUN: %clang -target i386-apple-darwin10 \
+// RUN: -fapple-kext -### -fsyntax-only %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK < %t %s
+
+// CHECK: cc1plus"
+// CHECK: "-fapple-kext"
+
+// RUN: %clang -target i386-apple-darwin10 \
+// RUN: -mkernel -### -fsyntax-only %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-MKERNEL < %t %s
+
+// CHECK-MKERNEL: cc1plus"
+// CHECK-MKERNEL: "-mkernel"
+
+// RUN: %clang -target i386-apple-darwin10 \
+// RUN: -Wno-self-assign -Wc++11-extensions -Wno-microsoft -Wmicrosoft -Wvla \
+// RUN: -faltivec -mthumb -mcpu=G4 -mlongcall -mno-longcall -msoft-float \
+// RUN: -fapple-kext -### -fsyntax-only %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNSUPPORTED < %t %s
+
+// CHECK-UNSUPPORTED: cc1plus"
+// CHECK-UNSUPPORTED-NOT: "-Wno-self-assign"
+// CHECK-UNSUPPORTED-NOT: "-Wc++11-extensions"
+// CHECK-UNSUPPORTED-NOT: "-Wno-microsoft"
+// CHECK-UNSUPPORTED-NOT: "-Wmicrosoft"
+// CHECK-UNSUPPORTED-NOT: "-Wvla"
+// CHECK-UNSUPPORTED-NOT: "-faltivec"
+// CHECK-UNSUPPORTED-NOT: "-mthumb"
+// CHECK-UNSUPPORTED-NOT: "-mlongcall"
+// CHECK-UNSUPPORTED: "-mno-longcall"
+// CHECK-UNSUPPORTED: "-msoft-float"
+
+// RUN: %clang -target i386-apple-darwin10 \
+// RUN: -Wconstant-logical-operand -save-temps \
+// RUN: -fapple-kext -### -fsyntax-only %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-UNSUPPORTED2 < %t %s
+
+// CHECK-UNSUPPORTED2: cc1plus"
+// CHECK-UNSUPPORTED2-NOT: "-Wconstant-logical-operand"
+
+// Check that --serialize-diagnostics does not cause an "argument unused" error.
+// RUN: %clang -target i386-apple-darwin10 \
+// RUN: -Wall -fapple-kext -### --serialize-diagnostics %t.dia -c %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-UNUSED %s
+
+// CHECK-UNUSED-NOT: argument unused
+// CHECK-UNUSED: cc1plus
diff --git a/clang/test/Driver/apple-kext-mkernel.c b/clang/test/Driver/apple-kext-mkernel.c
new file mode 100644
index 0000000..f8b7b90
--- /dev/null
+++ b/clang/test/Driver/apple-kext-mkernel.c
@@ -0,0 +1,22 @@
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -mkernel -### -fsyntax-only %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-X86 < %t %s
+
+// CHECK-X86: "-disable-red-zone"
+// CHECK-X86: "-fno-builtin"
+// CHECK-X86: "-fno-rtti"
+// CHECK-X86: "-fno-common"
+
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -arch armv7 -mkernel -### -fsyntax-only %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ARM < %t %s
+
+// CHECK-ARM: "-backend-option" "-arm-long-calls"
+// CHECK-ARM: "-backend-option" "-arm-strict-align"
+// CHECK-ARM: "-fno-builtin"
+// CHECK-ARM: "-fno-rtti"
+// CHECK-ARM: "-fno-common"
+
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -Werror -fno-builtin -fno-exceptions -fno-common -fno-rtti \
+// RUN: -mkernel -fsyntax-only %s
diff --git a/clang/test/Driver/arc-exceptions.m b/clang/test/Driver/arc-exceptions.m
new file mode 100644
index 0000000..4501ccd
--- /dev/null
+++ b/clang/test/Driver/arc-exceptions.m
@@ -0,0 +1,5 @@
+// RUN: %clang -### -x objective-c -arch x86_64 -fobjc-arc -fsyntax-only %s 2> %t.log
+// RUN: grep objective-c %t.log
+// RUN: not grep "fobjc-arc-exceptions" %t.log
+// RUN: %clang -### -x objective-c++ -arch x86_64 -fobjc-arc -fsyntax-only %s 2> %t.log
+// RUN: grep "fobjc-arc-exceptions" %t.log
diff --git a/clang/test/Driver/arc.c b/clang/test/Driver/arc.c
new file mode 100644
index 0000000..f2c1127
--- /dev/null
+++ b/clang/test/Driver/arc.c
@@ -0,0 +1,17 @@
+// RUN: %clang -ObjC -target i386-apple-darwin10 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -x objective-c -target i386-apple-darwin10 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -x objective-c++ -target i386-apple-darwin10 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -x c -target i386-apple-darwin10 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s
+// RUN: %clang -x c++ -target i386-apple-darwin10 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s
+// RUN: %clang -x objective-c -target x86_64-apple-darwin11 -mmacosx-version-min=10.5 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix UNSUPPORTED %s
+
+// Just to test clang is working.
+# foo
+
+// CHECK: error: -fobjc-arc is not supported with fragile abi
+// CHECK-NOT: invalid preprocessing directive
+
+// NOTOBJC-NOT: error: -fobjc-arc is not supported with fragile abi
+// NOTOBJC: invalid preprocessing directive
+
+// UNSUPPORTED: error: -fobjc-arc is not supported on current deployment target
diff --git a/clang/test/Driver/arch.c b/clang/test/Driver/arch.c
new file mode 100644
index 0000000..df9a3e1
--- /dev/null
+++ b/clang/test/Driver/arch.c
@@ -0,0 +1,3 @@
+// RUN: %clang -target armv7a-unknown-linux-gnueabi -S -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: target triple = "armv7-unknown-linux-gnueabi"
diff --git a/clang/test/Driver/arclite-link.c b/clang/test/Driver/arclite-link.c
new file mode 100644
index 0000000..9cf1efe
--- /dev/null
+++ b/clang/test/Driver/arclite-link.c
@@ -0,0 +1,8 @@
+// RUN: touch %t.o
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.8 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
+// RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
+
+// CHECK-ARCLITE-OSX: libarclite_macosx.a
+// CHECK-ARCLITE-OSX: -lobjc
+// CHECK-NOARCLITE-NOT: libarclite
diff --git a/clang/test/Driver/arm-darwin-builtin.c b/clang/test/Driver/arm-darwin-builtin.c
new file mode 100644
index 0000000..41f13f3
--- /dev/null
+++ b/clang/test/Driver/arm-darwin-builtin.c
@@ -0,0 +1,14 @@
+// FIXME: Disable pending PR4941.
+// RUX: clang -target x86_64-apple-darwin9 -arch arm -### -fsyntax-only %s 2> %t &&
+// RUX: grep -- "-fno-builtin-strcat" %t &&
+// RUX: grep -- "-fno-builtin-strcpy" %t &&
+
+// FIXME: Disable pending PR4941.
+// RUX: clang -target x86_64-apple-darwin9 -arch arm -### -fsyntax-only %s -fbuiltin-strcat -fbuiltin-strcpy 2> %t &&
+// RUX: not grep -- "-fno-builtin-strcat" %t &&
+// RUX: not grep -- "-fno-builtin-strcpy" %t &&
+
+// RUN: %clang -ccc-no-clang -target x86_64-apple-darwin9 -arch arm -### -fsyntax-only %s -fbuiltin-strcat -fbuiltin-strcpy 2> %t
+// RUN: not grep -- "-fno-builtin-strcat" %t
+// RUN: not grep -- "-fno-builtin-strcpy" %t
+
diff --git a/clang/test/Driver/arm-mfpmath.c b/clang/test/Driver/arm-mfpmath.c
new file mode 100644
index 0000000..0421046
--- /dev/null
+++ b/clang/test/Driver/arm-mfpmath.c
@@ -0,0 +1,29 @@
+// Test different values of -mfpmath.
+
+// RUN: %clang -target arm-apple-darwin10 -mfpmath=vfp %s -### -c -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP %s
+// CHECK-VFP: "-target-feature" "-neonfp"
+
+// RUN: %clang -target arm-apple-darwin10 -mfpmath=vfp2 %s -### -c -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP2 %s
+// CHECK-VFP2: "-target-feature" "-neonfp"
+
+// RUN: %clang -target arm-apple-darwin10 -mfpmath=vfp3 %s -### -c -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP3 %s
+// CHECK-VFP3: "-target-feature" "-neonfp"
+
+// RUN: %clang -target arm-apple-darwin10 -mfpmath=vfp4 %s -### -c -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP4 %s
+// CHECK-VFP4: "-target-feature" "-neonfp"
+
+// RUN: %clang -target arm-apple-darwin10 -mfpmath=neon %s -### -c -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NEON %s
+// CHECK-NEON: "-target-feature" "+neonfp"
+
+// RUN: %clang -target arm-apple-darwin10 -mfpmath=foo %s -### -c -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-ERROR %s
+// CHECK-ERROR: clang compiler does not support '-mfpmath=foo'
+
+// RUN: %clang -target arm-apple-darwin10 -mcpu=arm1136j-s -mfpmath=neon %s -### -c -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-MCPU-ERROR %s
+// CHECK-MCPU-ERROR: error: invalid feature '-mfpmath=neon' for CPU 'arm1136j-s'
diff --git a/clang/test/Driver/arm-mfpu.c b/clang/test/Driver/arm-mfpu.c
new file mode 100644
index 0000000..f51c41e
--- /dev/null
+++ b/clang/test/Driver/arm-mfpu.c
@@ -0,0 +1,48 @@
+// Test that different values of -mfpu pick correct ARM FPU target-feature(s).
+
+// RUN: %clang -target arm-linux-eabi %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-DEFAULT %s
+// CHECK-DEFAULT-NOT: "-target-feature" "+vfp2"
+// CHECK-DEFAULT-NOT: "-target-feature" "+vfp3"
+// CHECK-DEFAULT-NOT: "-target-feature" "+d16"
+// CHECK-DEFAULT-NOT: "-target-feature" "+neon"
+
+// RUN: %clang -target arm-linux-eabi -mfpu=fpa %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-FPA %s
+// RUN: %clang -target arm-linux-eabi -mfpu=fpe2 %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-FPA %s
+// RUN: %clang -target arm-linux-eabi -mfpu=fpe3 %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-FPA %s
+// RUN: %clang -target arm-linux-eabi -mfpu=maverick %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-FPA %s
+// CHECK-FPA: "-target-feature" "-vfp2"
+// CHECK-FPA: "-target-feature" "-vfp3"
+// CHECK-FPA: "-target-feature" "-neon"
+
+// RUN: %clang -target arm-linux-eabi -mfpu=vfp3-d16 %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP3-D16 %s
+// RUN: %clang -target arm-linux-eabi -mfpu=vfpv3-d16 %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP3-D16 %s
+// CHECK-VFP3-D16: "-target-feature" "+vfp3"
+// CHECK-VFP3-D16: "-target-feature" "+d16"
+// CHECK-VFP3-D16: "-target-feature" "-neon"
+
+// RUN: %clang -target arm-linux-eabi -mfpu=vfp %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP %s
+// CHECK-VFP: "-target-feature" "+vfp2"
+// CHECK-VFP: "-target-feature" "-neon"
+
+// RUN: %clang -target arm-linux-eabi -mfpu=vfp3 %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP3 %s
+// RUN: %clang -target arm-linux-eabi -mfpu=vfpv3 %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP3 %s
+// CHECK-VFP3: "-target-feature" "+vfp3"
+// CHECK-VFP3: "-target-feature" "-neon"
+
+// RUN: %clang -target arm-linux-eabi -mfpu=neon %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NEON %s
+// CHECK-NEON: "-target-feature" "+neon"
+
+// RUN: %clang -target arm-linux-eabi -msoft-float %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-SOFT-FLOAT %s
+// CHECK-SOFT-FLOAT: "-target-feature" "-neon"
diff --git a/clang/test/Driver/asan.c b/clang/test/Driver/asan.c
new file mode 100644
index 0000000..4c9a1b6
--- /dev/null
+++ b/clang/test/Driver/asan.c
@@ -0,0 +1,8 @@
+// RUN: %clang -target i386-unknown-unknown -faddress-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O1 -target i386-unknown-unknown -faddress-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O2 -target i386-unknown-unknown -faddress-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O3 -target i386-unknown-unknown -faddress-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// Verify that -faddress-sanitizer invokes asan instrumentation.
+
+int foo(int *a) { return *a; }
+// CHECK: __asan_init
diff --git a/clang/test/Driver/ast.c b/clang/test/Driver/ast.c
new file mode 100644
index 0000000..83dfcc3
--- /dev/null
+++ b/clang/test/Driver/ast.c
@@ -0,0 +1,26 @@
+// RUN: %clang -target i386-unknown-unknown -ccc-print-phases -emit-ast %s 2> %t
+// RUN: echo 'END' >> %t
+// RUN: FileCheck -check-prefix EMIT-AST-PHASES -input-file %t %s
+
+// EMIT-AST-PHASES: 0: input,
+// EMIT-AST-PHASES: , c
+// EMIT-AST-PHASES: 1: preprocessor, {0}, cpp-output
+// EMIT-AST-PHASES: 2: compiler, {1}, ast
+// EMIT-AST-PHASES-NOT: 3:
+// EMIT-AST-PHASES: END
+
+// RUN: touch %t.ast
+// RUN: %clang -target i386-unknown-unknown -ccc-print-phases -c %t.ast 2> %t
+// RUN: echo 'END' >> %t
+// RUN: FileCheck -check-prefix COMPILE-AST-PHASES -input-file %t %s
+
+// COMPILE-AST-PHASES: 0: input,
+// COMPILE-AST-PHASES: , ast
+// COMPILE-AST-PHASES: 1: compiler, {0}, assembler
+// COMPILE-AST-PHASES: 2: assembler, {1}, object
+// COMPILE-AST-PHASES-NOT: 3:
+// COMPILE-AST-PHASES: END
+
+// FIXME: There is a problem with compiling AST's in that the input language is
+// not available for use by other tools (for example, to automatically add
+// -lstdc++). We may need -x [objective-]c++-ast and all that goodness. :(
diff --git a/clang/test/Driver/at_file.c b/clang/test/Driver/at_file.c
new file mode 100644
index 0000000..4ad2a5f
--- /dev/null
+++ b/clang/test/Driver/at_file.c
@@ -0,0 +1,30 @@
+// RUN: %clang -E %s @%s.args -o %t.log
+// RUN: FileCheck --input-file=%t.log %s
+
+// CHECK: bar1
+// CHECK-NEXT: bar2 zed2
+// CHECK-NEXT: bar3 zed3
+// CHECK-NEXT: bar4 zed4
+// CHECK-NEXT: bar5 zed5
+// CHECK-NEXT: 'bar6 zed6'
+// CHECK-NEXT: "bar7 zed7"
+// CHECK-NEXT: foo8bar8zed8
+// CHECK-NEXT: foo9'bar9'zed9
+// CHECK-NEXT: foo10"bar10"zed10
+// CHECK: bar
+// CHECK: zed12
+
+foo1
+foo2
+foo3
+foo4
+foo5
+foo6
+foo7
+foo8
+foo9
+foo10
+#ifdef foo11
+bar
+#endif
+foo12
diff --git a/clang/test/Driver/at_file.c.args b/clang/test/Driver/at_file.c.args
new file mode 100644
index 0000000..9a2b4ee
--- /dev/null
+++ b/clang/test/Driver/at_file.c.args
@@ -0,0 +1,11 @@
+-Dfoo1=bar1 -Dfoo2="bar2 zed2"
+-Dfoo3='bar3 zed3'
+"-Dfoo4=bar4 zed4"
+'-Dfoo5=bar5 zed5'
+-Dfoo6="'bar6 zed6'"
+-Dfoo7='"bar7 zed7"'
+-Dfoo8=foo8"bar8"zed8
+-Dfoo9=foo9\'bar9\'zed9
+-Dfoo10=foo10\"bar10\"zed10
+-D foo11
+-Dfoo12=zed12\
diff --git a/clang/test/Driver/bindings.c b/clang/test/Driver/bindings.c
new file mode 100644
index 0000000..a7cda19
--- /dev/null
+++ b/clang/test/Driver/bindings.c
@@ -0,0 +1,49 @@
+// Basic binding.
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings %s 2> %t
+// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: ".*\.s"' %t
+// RUN: grep '"gcc::Assemble", inputs: \[".*\.s"\], output: ".*\.o"' %t
+// RUN: grep '"gcc::Link", inputs: \[".*\.o"\], output: "a.out"' %t
+
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -ccc-no-clang %s 2> %t
+// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: ".*\.s"' %t
+// RUN: grep '"gcc::Assemble", inputs: \[".*\.s"\], output: ".*\.o"' %t
+// RUN: grep '"gcc::Link", inputs: \[".*\.o"\], output: "a.out"' %t
+
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -ccc-no-clang -no-integrated-cpp %s 2> %t
+// RUN: grep '"gcc::Preprocess", inputs: \[".*bindings.c"\], output: ".*\.i"' %t
+// RUN: grep '"gcc::Compile", inputs: \[".*\.i"\], output: ".*\.s"' %t
+// RUN: grep '"gcc::Assemble", inputs: \[".*\.s"\], output: ".*\.o"' %t
+// RUN: grep '"gcc::Link", inputs: \[".*\.o"\], output: "a.out"' %t
+
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -ccc-no-clang -x c-header %s 2> %t
+// RUN: grep '"gcc::Precompile", inputs: \[".*bindings.c"\], output: ".*bindings.c.gch' %t
+
+// Clang control options
+
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -fsyntax-only %s 2> %t
+// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: (nothing)' %t
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -ccc-no-clang -fsyntax-only %s 2> %t
+// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: (nothing)' %t
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -ccc-no-clang-cxx -fsyntax-only -x c++ %s 2> %t
+// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: (nothing)' %t
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -ccc-clang-cxx -fsyntax-only -x c++ %s 2> %t
+// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: (nothing)' %t
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -ccc-no-clang-cpp -fsyntax-only -no-integrated-cpp %s 2> %t
+// RUN: grep '"gcc::Preprocess", inputs: \[".*bindings.c"\], output: ".*\.i"' %t
+// RUN: grep '"clang", inputs: \[".*\.i"\], output: (nothing)' %t
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-bindings -ccc-clang-archs i386 %s -S -arch ppc 2> %t
+// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: "bindings.s"' %t
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-bindings -ccc-clang-archs powerpc %s -S -arch ppc 2> %t
+// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: "bindings.s"' %t
+
+// RUN: %clang -target powerpc-unknown-unknown -ccc-print-bindings -ccc-clang-archs "" %s -S 2> %t
+// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: "bindings.s"' %t
+// RUN: %clang -target powerpc-unknown-unknown -ccc-print-bindings -ccc-clang-archs "i386" %s -S 2> %t
+// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: "bindings.s"' %t
+
+// Darwin bindings
+// RUN: %clang -target i386-apple-darwin9 -no-integrated-as -ccc-print-bindings %s 2> %t
+// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: ".*\.s"' %t
+// RUN: grep '"darwin::Assemble", inputs: \[".*\.s"\], output: ".*\.o"' %t
+// RUN: grep '"darwin::Link", inputs: \[".*\.o"\], output: "a.out"' %t
+
diff --git a/clang/test/Driver/cc-log-diagnostics.c b/clang/test/Driver/cc-log-diagnostics.c
new file mode 100644
index 0000000..88c99f5
--- /dev/null
+++ b/clang/test/Driver/cc-log-diagnostics.c
@@ -0,0 +1,35 @@
+// RUN: rm -f %t.log
+// RUN: env RC_DEBUG_OPTIONS=1 \
+// RUN: CC_LOG_DIAGNOSTICS=1 CC_LOG_DIAGNOSTICS_FILE=%t.log \
+// RUN: %clang -Wfoobar -no-canonical-prefixes -target x86_64-apple-darwin10 -fsyntax-only %s
+// RUN: FileCheck %s < %t.log
+
+int f0() {}
+
+// CHECK: <dict>
+// CHECK: <key>main-file</key>
+// CHECK: <string>{{.*}}cc-log-diagnostics.c</string>
+// CHECK: <key>dwarf-debug-flags</key>
+// CHECK: <string>{{.*}}clang{{.*}}-fsyntax-only{{.*}}</string>
+// CHECK: <key>diagnostics</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>level</key>
+// CHECK: <string>warning</string>
+// CHECK: <key>message</key>
+// CHECK: <string>unknown warning option &apos;-Wfoobar&apos;; did you mean &apos;-W{{.*}}&apos;?</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>level</key>
+// CHECK: <string>warning</string>
+// CHECK: <key>filename</key>
+// CHECK: <string>{{.*}}cc-log-diagnostics.c</string>
+// CHECK: <key>line</key>
+// CHECK: <integer>7</integer>
+// CHECK: <key>column</key>
+// CHECK: <integer>11</integer>
+// CHECK: <key>message</key>
+// CHECK: <string>control reaches end of non-void function</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
diff --git a/clang/test/Driver/cc-print-options.c b/clang/test/Driver/cc-print-options.c
new file mode 100644
index 0000000..77dd0fe
--- /dev/null
+++ b/clang/test/Driver/cc-print-options.c
@@ -0,0 +1,7 @@
+// RUN: env CC_PRINT_OPTIONS=1 \
+// RUN: CC_PRINT_OPTIONS_FILE=%t.log \
+// RUN: %clang -no-canonical-prefixes -S -o %t.s %s
+// RUN: FileCheck %s < %t.log
+
+// CHECK: [Logging clang options]{{.*}}clang{{.*}}"-S"
+
diff --git a/clang/test/Driver/ccc-add-args.c b/clang/test/Driver/ccc-add-args.c
new file mode 100644
index 0000000..d9a16cb
--- /dev/null
+++ b/clang/test/Driver/ccc-add-args.c
@@ -0,0 +1,5 @@
+// RUN: env CCC_ADD_ARGS="-ccc-echo,-ccc-print-options,,-v" %clang -### 2>&1 | FileCheck %s
+// CHECK: Option 0 - Name: "-ccc-echo", Values: {}
+// CHECK: Option 1 - Name: "-ccc-print-options", Values: {}
+// CHECK: Option 2 - Name: "-v", Values: {}
+// CHECK: Option 3 - Name: "-###", Values: {}
diff --git a/clang/test/Driver/ccc-host-triple-no-integrated-as.c b/clang/test/Driver/ccc-host-triple-no-integrated-as.c
new file mode 100644
index 0000000..1677b71
--- /dev/null
+++ b/clang/test/Driver/ccc-host-triple-no-integrated-as.c
@@ -0,0 +1,17 @@
+// Check that -no-integrated-as works when -target i386-pc-win32-macho or
+// -target x86_64-pc-win32-macho is specified.
+
+// RUN: %clang -### -c -target i386-pc-win32-macho -no-integrated-as %s 2> %t1
+// RUN: FileCheck -check-prefix=X86 < %t1 %s
+// RUN: %clang -### -c -target x86_64-pc-win32-macho -no-integrated-as %s 2> %t2
+// RUN: FileCheck -check-prefix=X86_64 < %t2 %s
+//
+// X86: "-cc1"
+// X86-NOT: "-cc1as"
+// X86: "-arch"
+// X86: "i386"
+//
+// X86_64: "-cc1"
+// X86_64-NOT: "-cc1as"
+// X86_64: "-arch"
+// X86_64: "x86_64"
diff --git a/clang/test/Driver/cfi.c b/clang/test/Driver/cfi.c
new file mode 100644
index 0000000..c33d190
--- /dev/null
+++ b/clang/test/Driver/cfi.c
@@ -0,0 +1,9 @@
+// RUN: %clang -target i386-apple-darwin10 \
+// RUN: -no-integrated-as -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-DARWIN %s
+
+// RUN: %clang -target i386-pc-linux-gnu -static -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-LINUX %s
+
+// CHECK-DARWIN: -fno-dwarf2-cfi-asm
+// CHECK-LINUX-NOT: -fno-dwarf2-cfi-asm
diff --git a/clang/test/Driver/clang-c-as-cxx.c b/clang/test/Driver/clang-c-as-cxx.c
new file mode 100644
index 0000000..0e28178
--- /dev/null
+++ b/clang/test/Driver/clang-c-as-cxx.c
@@ -0,0 +1,6 @@
+// RUN: %clangxx -### %s 2>&1 | FileCheck %s
+//
+// PR5803
+//
+// CHECK: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
+// CHECK: "-cc1" {{.*}} "-x" "c++"
diff --git a/clang/test/Driver/clang-exception-flags.cpp b/clang/test/Driver/clang-exception-flags.cpp
new file mode 100644
index 0000000..90a9ebf
--- /dev/null
+++ b/clang/test/Driver/clang-exception-flags.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
+// DEFAULT: "-cc1" {{.*}} "-fcxx-exceptions" "-fexceptions"
+//
+// RUN: %clang -### -fexceptions %s 2>&1 | FileCheck %s -check-prefix=ON1
+// ON1: "-cc1" {{.*}} "-fcxx-exceptions" "-fexceptions"
+//
+// RUN: %clang -### -fno-exceptions -fcxx-exceptions %s 2>&1 | FileCheck %s -check-prefix=ON2
+// ON2: "-cc1" {{.*}} "-fcxx-exceptions" "-fexceptions"
+//
+// RUN: %clang -### -fno-cxx-exceptions -fexceptions %s 2>&1 | FileCheck %s -check-prefix=ON3
+// ON3: "-cc1" {{.*}} "-fcxx-exceptions" "-fexceptions"
+//
+// RUN: %clang -### -fno-exceptions %s 2>&1 | FileCheck %s -check-prefix=OFF1
+// OFF1-NOT: "-cc1" {{.*}} "-fcxx-exceptions"
+//
+// RUN: %clang -### -fno-cxx-exceptions %s 2>&1 | FileCheck %s -check-prefix=OFF2
+// OFF2-NOT: "-cc1" {{.*}} "-fcxx-exceptions"
+//
+// RUN: %clang -### -fcxx-exceptions -fno-exceptions %s 2>&1 | FileCheck %s -check-prefix=OFF3
+// OFF3-NOT: "-cc1" {{.*}} "-fcxx-exceptions"
+//
+// RUN: %clang -### -fexceptions -fno-cxx-exceptions %s 2>&1 | FileCheck %s -check-prefix=OFF4
+// OFF4-NOT: "-cc1" {{.*}} "-fcxx-exceptions"
diff --git a/clang/test/Driver/clang-g-opts.c b/clang/test/Driver/clang-g-opts.c
new file mode 100644
index 0000000..4dbdf61
--- /dev/null
+++ b/clang/test/Driver/clang-g-opts.c
@@ -0,0 +1,5 @@
+// RUN: %clang -S -v -o %t %s 2>&1 | not grep -w -- -g
+// RUN: %clang -S -v -o %t %s -g 2>&1 | grep -w -- -g
+// RUN: %clang -S -v -o %t %s -g0 2>&1 | not grep -w -- -g
+// RUN: %clang -S -v -o %t %s -g -g0 2>&1 | not grep -w -- -g
+// RUN: %clang -S -v -o %t %s -g0 -g 2>&1 | grep -w -- -g
diff --git a/clang/test/Driver/clang-translation.c b/clang/test/Driver/clang-translation.c
new file mode 100644
index 0000000..0e82de4
--- /dev/null
+++ b/clang/test/Driver/clang-translation.c
@@ -0,0 +1,46 @@
+// RUN: %clang -target i386-unknown-unknown -### -S -O0 -Os %s -o %t.s -fverbose-asm -funwind-tables -fvisibility=hidden 2> %t.log
+// RUN: grep '"-triple" "i386-unknown-unknown"' %t.log
+// RUN: grep '"-S"' %t.log
+// RUN: grep '"-disable-free"' %t.log
+// RUN: grep '"-mrelocation-model" "static"' %t.log
+// RUN: grep '"-mdisable-fp-elim"' %t.log
+// RUN: grep '"-munwind-tables"' %t.log
+// RUN: grep '"-Os"' %t.log
+// RUN: grep '"-o" .*clang-translation.*' %t.log
+// RUN: grep '"-masm-verbose"' %t.log
+// RUN: grep '"-fvisibility" "hidden"' %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -S %s -o %t.s 2> %t.log
+// RUN: grep '"-target-cpu" "yonah"' %t.log
+// RUN: %clang -target x86_64-apple-darwin9 -### -S %s -o %t.s 2> %t.log
+// RUN: grep '"-target-cpu" "core2"' %t.log
+
+// RUN: %clang -target x86_64-apple-darwin10 -### -S %s 2> %t.log \
+// RUN: -arch armv7
+// RUN: FileCheck -check-prefix=ARMV7_DEFAULT %s < %t.log
+// ARMV7_DEFAULT: clang
+// ARMV7_DEFAULT: "-cc1"
+// ARMV7_DEFAULT-NOT: "-msoft-float"
+// ARMV7_DEFAULT: "-mfloat-abi" "soft"
+// ARMV7_DEFAULT-NOT: "-msoft-float"
+// ARMV7_DEFAULT: "-x" "c"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### -S %s 2> %t.log \
+// RUN: -arch armv7 -msoft-float
+// RUN: FileCheck -check-prefix=ARMV7_SOFTFLOAT %s < %t.log
+// ARMV7_SOFTFLOAT: clang
+// ARMV7_SOFTFLOAT: "-cc1"
+// ARMV7_SOFTFLOAT: "-msoft-float"
+// ARMV7_SOFTFLOAT: "-mfloat-abi" "soft"
+// ARMV7_SOFTFLOAT: "-target-feature"
+// ARMV7_SOFTFLOAT: "-neon"
+// ARMV7_SOFTFLOAT: "-x" "c"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### -S %s 2> %t.log \
+// RUN: -arch armv7 -mhard-float
+// RUN: FileCheck -check-prefix=ARMV7_HARDFLOAT %s < %t.log
+// ARMV7_HARDFLOAT: clang
+// ARMV7_HARDFLOAT: "-cc1"
+// ARMV7_HARDFLOAT-NOT: "-msoft-float"
+// ARMV7_HARDFLOAT: "-mfloat-abi" "hard"
+// ARMV7_HARDFLOAT-NOT: "-msoft-float"
+// ARMV7_HARDFLOAT: "-x" "c"
diff --git a/clang/test/Driver/clang_cpp.c b/clang/test/Driver/clang_cpp.c
new file mode 100644
index 0000000..79b2f55
--- /dev/null
+++ b/clang/test/Driver/clang_cpp.c
@@ -0,0 +1,4 @@
+// Verify that -include isn't included twice with -save-temps.
+// RUN: %clang -S -o - %s -include %t.h -save-temps -### 2> %t.log
+// RUN: grep '"-include' %t.log | count 1
+
diff --git a/clang/test/Driver/clang_f_opts.c b/clang/test/Driver/clang_f_opts.c
new file mode 100644
index 0000000..4eed4aa
--- /dev/null
+++ b/clang/test/Driver/clang_f_opts.c
@@ -0,0 +1,31 @@
+// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
+// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
+
+// CHECK-OPTIONS1: -fgnu-keywords
+// CHECK-OPTIONS1: -fblocks
+// CHECK-OPTIONS1: -fpascal-strings
+
+// CHECK_OPTIONS2: -fno-gnu-keywords
+// CHECK-OPTIONS2: -fmath-errno
+// CHECK-OPTIONS2: -fno-builtin
+// CHECK-OPTIONS2: -fshort-enums
+// CHECK-OPTIONS2: -fshort-wchar
+// CHECK-OPTIONS2: -fno-common
+// CHECK-OPTIONS2: -fno-show-source-location
+
+// RUN: %clang -### -S -Wwrite-strings %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS1 %s
+// WRITE-STRINGS1: -fconst-strings
+// RUN: %clang -### -S -Wwrite-strings -Wno-write-strings %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS2 %s
+// WRITE-STRINGS2-NOT: -fconst-strings
+// RUN: %clang -### -S -Wwrite-strings -w %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS3 %s
+// WRITE-STRINGS3: -fconst-strings
+
+// RUN: %clang -### -x c++ -c %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
+// RUN: %clang -### -x c++ -c -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
+// RUN: %clang -### -x c++ -c -Wno-deprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s
+// RUN: %clang -### -x c++ -c -Wno-deprecated -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
+// RUN: %clang -### -x c++ -c -w %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s
+// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s
+// RUN: %clang -### -c -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s
+// DEPRECATED-ON-CHECK: -fdeprecated-macro
+// DEPRECATED-OFF-CHECK-NOT: -fdeprecated-macro
diff --git a/clang/test/Driver/clang_wrapv_opts.c b/clang/test/Driver/clang_wrapv_opts.c
new file mode 100644
index 0000000..826468e
--- /dev/null
+++ b/clang/test/Driver/clang_wrapv_opts.c
@@ -0,0 +1,11 @@
+// RUN: %clang -### -S -fwrapv -fno-wrapv -fwrapv %s 2>&1 | FileCheck -check-prefix=CHECK1 %s
+// CHECK1: -fwrapv
+//
+// RUN: %clang -### -S -fstrict-overflow -fno-strict-overflow %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
+// CHECK2: -fwrapv
+//
+// RUN: %clang -### -S -fwrapv -fstrict-overflow %s 2>&1 | FileCheck -check-prefix=CHECK3 %s
+// CHECK3: -fwrapv
+//
+// RUN: %clang -### -S -fno-wrapv -fno-strict-overflow %s 2>&1 | FileCheck -check-prefix=CHECK4 %s
+// CHECK4-NOT: -fwrapv
diff --git a/clang/test/Driver/cpath.c b/clang/test/Driver/cpath.c
new file mode 100644
index 0000000..bd7c8d0
--- /dev/null
+++ b/clang/test/Driver/cpath.c
@@ -0,0 +1,22 @@
+// RUN: mkdir -p %T/test1 %T/test2 %T/test3
+
+// RUN: env "CPATH=%T/test1%{pathsep}%T/test2" %clang -x c -E -v %s 2>&1 | FileCheck %s -check-prefix=CPATH
+// CPATH: -I {{.*}}/test1
+// CPATH: -I {{.*}}/test2
+// CPATH: search starts here
+// CPATH: test1
+// CPATH: test2
+
+// RUN: env "OBJC_INCLUDE_PATH=%T/test1%{pathsep}%T/test2" OBJCPLUS_INCLUDE_PATH=%T/test1 "CPLUS_INCLUDE_PATH=%T/test1%{pathsep}%t/test2" C_INCLUDE_PATH=%T/test3 %clang -x c -E -v %s 2>&1 | FileCheck %s -check-prefix=C_INCLUDE_PATH
+// C_INCLUDE_PATH: -c-isystem {{"?.*}}/test3{{"?}} -cxx-isystem {{"?.*}}/test1{{"?}} -cxx-isystem {{"?.*}}/test2{{"?}} -objc-isystem {{"?.*}}/test1{{"?}} -objc-isystem {{"?.*}}/test2{{"?}} -objcxx-isystem {{"?.*}}/test1{{"?}}
+// C_INCLUDE_PATH: search starts here
+// C_INCLUDE_PATH-NOT: test1
+// C_INCLUDE_PATH: test3
+// C_INCLUDE_PATH-NOT: test1
+
+// RUN: env OBJC_INCLUDE_PATH=%T/test1 OBJCPLUS_INCLUDE_PATH=%T/test3 CPLUS_INCLUDE_PATH=%T/test3 C_INCLUDE_PATH=%T/test1 %clang -x objective-c++ -E -v %s 2>&1 | FileCheck %s -check-prefix=OBJCPLUS_INCLUDE_PATH
+// OBJCPLUS_INCLUDE_PATH: -c-isystem {{"?.*}}/test1{{"?}} -cxx-isystem {{"?.*}}/test3{{"?}} -objc-isystem {{"?.*}}/test1{{"?}} -objcxx-isystem {{"?.*}}/test3{{"?}}
+// OBJCPLUS_INCLUDE_PATH: search starts here
+// OBJCPLUS_INCLUDE_PATH-NOT: test1
+// OBJCPLUS_INCLUDE_PATH: test3
+// OBJCPLUS_INCLUDE_PATH-NOT: test1
diff --git a/clang/test/Driver/cpp-precomp.c b/clang/test/Driver/cpp-precomp.c
new file mode 100644
index 0000000..a384a35
--- /dev/null
+++ b/clang/test/Driver/cpp-precomp.c
@@ -0,0 +1,5 @@
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -Werror -cpp-precomp -fsyntax-only %s
+
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -Werror -no-cpp-precomp -fsyntax-only %s
diff --git a/clang/test/Driver/darwin-as.c b/clang/test/Driver/darwin-as.c
new file mode 100644
index 0000000..92c7641
--- /dev/null
+++ b/clang/test/Driver/darwin-as.c
@@ -0,0 +1,17 @@
+// RUN: %clang -target i386-apple-darwin10 -### -x assembler -c %s \
+// RUN: -no-integrated-as -static -dynamic 2>%t
+// RUN: FileCheck -check-prefix=STATIC_AND_DYNAMIC-32 --input-file %t %s
+//
+// CHECK-STATIC_AND_DYNAMIC-32: as{{(.exe)?}}" "-arch" "i386" "-force_cpusubtype_ALL" "-static" "-o"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### -x assembler -c %s \
+// RUN: -no-integrated-as -static 2>%t
+// RUN: FileCheck -check-prefix=STATIC-64 --input-file %t %s
+//
+// CHECK-STATIC-64: as{{(.exe)?}}" "-arch" "x86_64" "-force_cpusubtype_ALL" "-o"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### \
+// RUN: -arch armv6 -no-integrated-as -x assembler -c %s 2>%t
+// RUN: FileCheck -check-prefix=ARMV6 --input-file %t %s
+//
+// CHECK-ARMV6: as{{(.exe)?}}" "-arch" "armv6" "-o"
diff --git a/clang/test/Driver/darwin-cc.c b/clang/test/Driver/darwin-cc.c
new file mode 100644
index 0000000..85cdf12
--- /dev/null
+++ b/clang/test/Driver/darwin-cc.c
@@ -0,0 +1,4 @@
+// RUN: %clang -ccc-no-clang -target i386-apple-darwin10 -m32 -### -MD -g -fast -Q -dA -mkernel -ansi -aFOO -S -o /tmp/OUTPUTNAME -g0 -gfull -O2 -Werror -pedantic -Wmost -w -std=c99 -trigraphs -v -pg -fFOO -undef -Qn --param a=b -fmudflap -coverage -save-temps -nostdinc -I ARG0 -F ARG1 -I ARG2 -P -MF ARG3 -MG -MP -remap -g3 -H -D ARG4 -U ARG5 -A ARG6 -D ARG7 -U ARG8 -A ARG9 -include ARG10 -pthread %s 2> %t.log
+// RUN: FileCheck %s < %t.log
+// CHECK: {{ ".*cc1.*" "-E" "-nostdinc" "-v" "-I" "ARG0" "-FARG1" "-I" "ARG2" "-P" "-MD" "[^"]*/OUTPUTNAME.d" "-MF" "ARG3" "-MG" "-MP" "-MQ" "[^"]*/OUTPUTNAME" "-remap" "-dD" "-H" "-D__STATIC__" "-D_REENTRANT" "-D" "ARG4" "-U" "ARG5" "-A" "ARG6" "-D" "ARG7" "-U" "ARG8" "-A" "ARG9" "-include" "ARG10" ".*darwin-cc.c" "-D_MUDFLAP" "-include" "mf-runtime.h" "-m32" "-mkernel" "-mtune=core2" "-mmacosx-version-min=10.6.0" "-ansi" "-std=c99" "-trigraphs" "-Werror" "-pedantic" "-Wmost" "-w" "-fast" "-fno-eliminate-unused-debug-symbols" "-fFOO" "-fmudflap" "-O2" "-undef" "-fpch-preprocess" "-o" ".*darwin-cc.i"}}
+// CHECK: {{ ".*cc1.*" "-fpreprocessed" ".*darwin-cc.i" "-O3" "-dumpbase" ".*darwin-cc.c" "-dA" "-m32" "-mkernel" "-mtune=core2" "-mmacosx-version-min=10.6.0" "-ansi" "-aFOO" "-auxbase-strip" "[^"]*/OUTPUTNAME" "-g" "-g0" "-g" "-g3" "-O2" "-Werror" "-pedantic" "-Wmost" "-w" "-ansi" "-std=c99" "-trigraphs" "-version" "-p" "-fast" "-fno-eliminate-unused-debug-symbols" "-fFOO" "-fmudflap" "-undef" "-fno-ident" "-o" "[^"]*/OUTPUTNAME" "--param" "a=b" "-fno-builtin" "-fno-merge-constants" "-fprofile-arcs" "-ftest-coverage"}}
diff --git a/clang/test/Driver/darwin-debug-flags.c b/clang/test/Driver/darwin-debug-flags.c
new file mode 100644
index 0000000..baf2847
--- /dev/null
+++ b/clang/test/Driver/darwin-debug-flags.c
@@ -0,0 +1,13 @@
+// RUN: env RC_DEBUG_OPTIONS=1 %clang -target i386-apple-darwin9 -g -Os %s -emit-llvm -S -o - | FileCheck %s
+// <rdar://problem/7256886>
+// RUN: touch %t.s
+// RUN: env RC_DEBUG_OPTIONS=1 %clang -### -target i386-apple-darwin9 -c -g %t.s 2>&1 | FileCheck -check-prefix=S %s
+
+// CHECK: !0 = metadata !{
+// CHECK: -g -Os
+// CHECK: -mmacosx-version-min=10.5.0
+// CHECK: [ DW_TAG_compile_unit ]
+
+int x;
+
+// S: "-dwarf-debug-flags"
diff --git a/clang/test/Driver/darwin-dsymutil.c b/clang/test/Driver/darwin-dsymutil.c
new file mode 100644
index 0000000..4409866
--- /dev/null
+++ b/clang/test/Driver/darwin-dsymutil.c
@@ -0,0 +1,45 @@
+// Check that we run dsymutil properly with multiple -arch options.
+//
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-phases \
+// RUN: -arch i386 -arch x86_64 %s -g 2> %t
+// RUN: FileCheck -check-prefix=CHECK-MULTIARCH-ACTIONS < %t %s
+//
+// CHECK-MULTIARCH-ACTIONS: 0: input, "{{.*}}darwin-dsymutil.c", c
+// CHECK-MULTIARCH-ACTIONS: 1: preprocessor, {0}, cpp-output
+// CHECK-MULTIARCH-ACTIONS: 2: compiler, {1}, assembler
+// CHECK-MULTIARCH-ACTIONS: 3: assembler, {2}, object
+// CHECK-MULTIARCH-ACTIONS: 4: linker, {3}, image
+// CHECK-MULTIARCH-ACTIONS: 5: bind-arch, "i386", {4}, image
+// CHECK-MULTIARCH-ACTIONS: 6: bind-arch, "x86_64", {4}, image
+// CHECK-MULTIARCH-ACTIONS: 7: lipo, {5, 6}, image
+// CHECK-MULTIARCH-ACTIONS: 8: dsymutil, {7}, dSYM
+//
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN: -arch i386 -arch x86_64 %s -g 2> %t
+// RUN: FileCheck -check-prefix=CHECK-MULTIARCH-BINDINGS < %t %s
+//
+// CHECK-MULTIARCH-BINDINGS: "x86_64-apple-darwin10" - "darwin::Lipo", inputs: [{{.*}}, {{.*}}], output: "a.out"
+// CHECK-MULTIARCH-BINDINGS: # "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["a.out"], output: "a.out.dSYM"
+
+// Check output name derivation.
+//
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN: -o foo %s -g 2> %t
+// RUN: FileCheck -check-prefix=CHECK-OUTPUT-NAME < %t %s
+//
+// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Link", inputs: [{{.*}}], output: "foo"
+// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["foo"], output: "foo.dSYM"
+
+// Check that we only use dsymutil when needed.
+//
+// RUN: touch %t.o
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN: -o foo %t.o -g 2> %t
+// RUN: grep "Dsymutil" %t | count 0
+
+// Check that we put the .dSYM in the right place.
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN: -o bar/foo %s -g 2> %t
+// RUN: FileCheck -check-prefix=CHECK-LOCATION < %t %s
+
+// CHECK-LOCATION: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["bar/foo"], output: "bar/foo.dSYM"
diff --git a/clang/test/Driver/darwin-iphone-defaults.m b/clang/test/Driver/darwin-iphone-defaults.m
new file mode 100644
index 0000000..bba0cc0
--- /dev/null
+++ b/clang/test/Driver/darwin-iphone-defaults.m
@@ -0,0 +1,28 @@
+// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 -arch armv7 -flto -S -o - %s | FileCheck %s
+
+// CHECK: @f0() ssp
+// CHECK: @__f0_block_invoke
+// CHECK: void @f1
+// CHECK-NOT: msgSend_fixup_alloc
+// CHECK: OBJC_SELECTOR_REFERENCES
+
+int f0() {
+ return ^(){ return 0; }();
+}
+
+@interface I0
+@property (assign) int p0;
+@end
+
+@implementation I0
+@synthesize p0 = __sythesized_p0;
+@end
+
+@interface I1
++(id) alloc;
+@end
+
+void f1() {
+ [I1 alloc];
+}
+
diff --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
new file mode 100644
index 0000000..3206f65
--- /dev/null
+++ b/clang/test/Driver/darwin-ld.c
@@ -0,0 +1,123 @@
+// Check that ld gets arch_multiple.
+
+// RUN: %clang -target i386-apple-darwin9 -arch i386 -arch x86_64 %s -### -o foo 2> %t.log
+// RUN: grep '".*ld.*" .*"-arch_multiple" "-final_output" "foo"' %t.log
+
+// Make sure we run dsymutil on source input files.
+// RUN: %clang -target i386-apple-darwin9 -### -g %s -o BAR 2> %t.log
+// RUN: grep '".*dsymutil" "-o" "BAR.dSYM" "BAR"' %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -g -filelist FOO %s -o BAR 2> %t.log
+// RUN: grep '".*dsymutil" "-o" "BAR.dSYM" "BAR"' %t.log
+
+// Check linker changes that came with new linkedit format.
+// RUN: touch %t.o
+// RUN: %clang -target i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 %t.o 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 -dynamiclib %t.o 2>> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 -bundle %t.o 2>> %t.log
+// RUN: FileCheck -check-prefix=LINK_IPHONE_3_0 %s < %t.log
+
+// LINK_IPHONE_3_0: {{ld(.exe)?"}}
+// LINK_IPHONE_3_0-NOT: -lcrt1.3.1.o
+// LINK_IPHONE_3_0: -lcrt1.o
+// LINK_IPHONE_3_0: -lSystem
+// LINK_IPHONE_3_0: {{ld(.exe)?"}}
+// LINK_IPHONE_3_0: -dylib
+// LINK_IPHONE_3_0: -ldylib1.o
+// LINK_IPHONE_3_0: -lSystem
+// LINK_IPHONE_3_0: {{ld(.exe)?"}}
+// LINK_IPHONE_3_0: -lbundle1.o
+// LINK_IPHONE_3_0: -lSystem
+
+// RUN: %clang -target i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 %t.o 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 -dynamiclib %t.o 2>> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 -bundle %t.o 2>> %t.log
+// RUN: FileCheck -check-prefix=LINK_IPHONE_3_1 %s < %t.log
+
+// LINK_IPHONE_3_1: {{ld(.exe)?"}}
+// LINK_IPHONE_3_1-NOT: -lcrt1.o
+// LINK_IPHONE_3_1: -lcrt1.3.1.o
+// LINK_IPHONE_3_1: -lSystem
+// LINK_IPHONE_3_1: {{ld(.exe)?"}}
+// LINK_IPHONE_3_1: -dylib
+// LINK_IPHONE_3_1-NOT: -ldylib1.o
+// LINK_IPHONE_3_1: -lSystem
+// LINK_IPHONE_3_1: {{ld(.exe)?"}}
+// LINK_IPHONE_3_1-NOT: -lbundle1.o
+// LINK_IPHONE_3_1: -lSystem
+
+// RUN: %clang -target i386-apple-darwin9 -### -fpie %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_EXPLICIT_PIE %s < %t.log
+//
+// LINK_EXPLICIT_PIE: {{ld(.exe)?"}}
+// LINK_EXPLICIT_PIE: "-pie"
+
+// RUN: %clang -target i386-apple-darwin9 -### -fno-pie %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_EXPLICIT_NO_PIE %s < %t.log
+//
+// LINK_EXPLICIT_NO_PIE: {{ld(.exe)?"}}
+// LINK_EXPLICIT_NO_PIE: "-no_pie"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
+// RUN: -mlinker-version=100 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_NEWER_DEMANGLE %s < %t.log
+//
+// LINK_NEWER_DEMANGLE: {{ld(.exe)?"}}
+// LINK_NEWER_DEMANGLE: "-demangle"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
+// RUN: -mlinker-version=100 -Wl,--no-demangle 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_NEWER_NODEMANGLE %s < %t.log
+//
+// LINK_NEWER_NODEMANGLE: {{ld(.exe)?"}}
+// LINK_NEWER_NODEMANGLE-NOT: "-demangle"
+// LINK_NEWER_NODEMANGLE: "-lSystem"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
+// RUN: -mlinker-version=95 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_OLDER_NODEMANGLE %s < %t.log
+//
+// LINK_OLDER_NODEMANGLE: {{ld(.exe)?"}}
+// LINK_OLDER_NODEMANGLE-NOT: "-demangle"
+// LINK_OLDER_NODEMANGLE: "-lSystem"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
+// RUN: -mlinker-version=117 -flto 2> %t.log
+// RUN: cat %t.log
+// RUN: FileCheck -check-prefix=LINK_OBJECT_LTO_PATH %s < %t.log
+//
+// LINK_OBJECT_LTO_PATH: {{ld(.exe)?"}}
+// LINK_OBJECT_LTO_PATH: "-object_path_lto"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
+// RUN: -force_load a -force_load b 2> %t.log
+// RUN: cat %t.log
+// RUN: FileCheck -check-prefix=FORCE_LOAD %s < %t.log
+//
+// FORCE_LOAD: {{ld(.exe)?"}}
+// FORCE_LOAD: "-force_load" "a" "-force_load" "b"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
+// RUN: -lazy_framework Framework 2> %t.log
+//
+// RUN: FileCheck -check-prefix=LINK_LAZY_FRAMEWORK %s < %t.log
+// LINK_LAZY_FRAMEWORK: {{ld(.exe)?"}}
+// LINK_LAZY_FRAMEWORK: "-lazy_framework" "Framework"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
+// RUN: -lazy_library Library 2> %t.log
+//
+// RUN: FileCheck -check-prefix=LINK_LAZY_LIBRARY %s < %t.log
+// LINK_LAZY_LIBRARY: {{ld(.exe)?"}}
+// LINK_LAZY_LIBRARY: "-lazy_library" "Library"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o 2> %t.log
+// RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log
+// RUN: FileCheck -check-prefix=LINK_VERSION_MIN %s < %t.log
+// LINK_VERSION_MIN: {{ld(.exe)?"}}
+// LINK_VERSION_MIN: "-macosx_version_min" "10.6.0"
+// LINK_VERSION_MIN: {{ld(.exe)?"}}
+// LINK_VERSION_MIN: "-macosx_version_min" "10.7.0"
+
+// RUN: %clang -target x86_64-apple-darwin12 -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_NO_CRT1 %s < %t.log
+// LINK_NO_CRT1-NOT: crt
diff --git a/clang/test/Driver/darwin-objc-defaults.m b/clang/test/Driver/darwin-objc-defaults.m
new file mode 100644
index 0000000..49fe8f9
--- /dev/null
+++ b/clang/test/Driver/darwin-objc-defaults.m
@@ -0,0 +1,88 @@
+// Check non-fragile ABI and dispatch method defaults.
+
+// i386
+
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
+// RUN: -arch i386 -mmacosx-version-min=10.5 2> %t
+// RUN: FileCheck --check-prefix CHECK-I386_OSX10_5 < %t %s
+
+// CHECK-CHECK-I386_OSX10_5: "-cc1"
+// CHECK-CHECK-I386_OSX10_5: -fobjc-fragile-abi
+// CHECK-CHECK-I386_OSX10_5-NOT: -fobjc-dispatch-method
+// CHECK-CHECK-I386_OSX10_5: darwin-objc-defaults
+
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
+// RUN: -arch i386 -mmacosx-version-min=10.6 2> %t
+// RUN: FileCheck --check-prefix CHECK-I386_OSX10_6 < %t %s
+
+// CHECK-CHECK-I386_OSX10_6: "-cc1"
+// CHECK-CHECK-I386_OSX10_6: -fobjc-fragile-abi
+// CHECK-CHECK-I386_OSX10_6-NOT: -fobjc-dispatch-method
+// CHECK-CHECK-I386_OSX10_6: darwin-objc-defaults
+
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
+// RUN: -arch i386 -miphoneos-version-min=3.0 2> %t
+// RUN: FileCheck --check-prefix CHECK-I386_IPHONE3_0 < %t %s
+
+// CHECK-CHECK-I386_IPHONE3_0: "-cc1"
+// CHECK-CHECK-I386_IPHONE3_0: -fobjc-fragile-abi
+// CHECK-CHECK-I386_IPHONE3_0-NOT: -fobjc-dispatch-method
+// CHECK-CHECK-I386_IPHONE3_0: darwin-objc-defaults
+
+// x86_64
+
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
+// RUN: -arch x86_64 -mmacosx-version-min=10.5 2> %t
+// RUN: FileCheck --check-prefix CHECK-X86_64_OSX10_5 < %t %s
+
+// CHECK-CHECK-X86_64_OSX10_5: "-cc1"
+// CHECK-CHECK-X86_64_OSX10_5-NOT: -fobjc-fragile-abi
+// CHECK-CHECK-X86_64_OSX10_5: -fobjc-dispatch-method=non-legacy
+// CHECK-CHECK-X86_64_OSX10_5: darwin-objc-defaults
+
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
+// RUN: -arch x86_64 -mmacosx-version-min=10.6 2> %t
+// RUN: FileCheck --check-prefix CHECK-X86_64_OSX10_6 < %t %s
+
+// CHECK-CHECK-X86_64_OSX10_6: "-cc1"
+// CHECK-CHECK-X86_64_OSX10_6-NOT: -fobjc-fragile-abi
+// CHECK-CHECK-X86_64_OSX10_6: -fobjc-dispatch-method=mixed
+// CHECK-CHECK-X86_64_OSX10_6: darwin-objc-defaults
+
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
+// RUN: -arch x86_64 -miphoneos-version-min=3.0 2> %t
+// RUN: FileCheck --check-prefix CHECK-X86_64_IPHONE3_0 < %t %s
+
+// CHECK-CHECK-X86_64_IPHONE3_0: "-cc1"
+// CHECK-CHECK-X86_64_IPHONE3_0-NOT: -fobjc-fragile-abi
+// CHECK-CHECK-X86_64_IPHONE3_0: -fobjc-dispatch-method=mixed
+// CHECK-CHECK-X86_64_IPHONE3_0: darwin-objc-defaults
+
+// armv7
+
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
+// RUN: -arch armv7 -mmacosx-version-min=10.5 2> %t
+// RUN: FileCheck --check-prefix CHECK-ARMV7_OSX10_5 < %t %s
+
+// CHECK-CHECK-ARMV7_OSX10_5: "-cc1"
+// CHECK-CHECK-ARMV7_OSX10_5-NOT: -fobjc-fragile-abi
+// CHECK-CHECK-ARMV7_OSX10_5-NOT: -fobjc-dispatch-method
+// CHECK-CHECK-ARMV7_OSX10_5: darwin-objc-defaults
+
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
+// RUN: -arch armv7 -mmacosx-version-min=10.6 2> %t
+// RUN: FileCheck --check-prefix CHECK-ARMV7_OSX10_6 < %t %s
+
+// CHECK-CHECK-ARMV7_OSX10_6: "-cc1"
+// CHECK-CHECK-ARMV7_OSX10_6-NOT: -fobjc-fragile-abi
+// CHECK-CHECK-ARMV7_OSX10_6-NOT: -fobjc-dispatch-method
+// CHECK-CHECK-ARMV7_OSX10_6: darwin-objc-defaults
+
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
+// RUN: -arch armv7 -miphoneos-version-min=3.0 2> %t
+// RUN: FileCheck --check-prefix CHECK-ARMV7_IPHONE3_0 < %t %s
+
+// CHECK-CHECK-ARMV7_IPHONE3_0: "-cc1"
+// CHECK-CHECK-ARMV7_IPHONE3_0-NOT: -fobjc-fragile-abi
+// CHECK-CHECK-ARMV7_IPHONE3_0-NOT: -fobjc-dispatch-method
+// CHECK-CHECK-ARMV7_IPHONE3_0: darwin-objc-defaults
diff --git a/clang/test/Driver/darwin-objc-gc.m b/clang/test/Driver/darwin-objc-gc.m
new file mode 100644
index 0000000..06e3aea
--- /dev/null
+++ b/clang/test/Driver/darwin-objc-gc.m
@@ -0,0 +1,19 @@
+// Check that we warn, but accept, -fobjc-gc for iPhone OS.
+
+// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 -fobjc-gc -flto -S -o %t %s 2> %t.err
+// RUN: FileCheck --check-prefix=IPHONE_OBJC_GC_LL %s < %t
+// RUN: FileCheck --check-prefix=IPHONE_OBJC_GC_STDERR %s < %t.err
+
+// IPHONE_OBJC_GC_LL: define void @f0
+// IPHONE_OBJC_GC_LL-NOT: objc_assign_ivar
+// IPHONE_OBJC_GC_LL: }
+
+// IPHONE_OBJC_GC_STDERR: warning: Objective-C garbage collection is not supported on this platform, ignoring '-fobjc-gc'
+
+@interface A {
+@public
+ id x;
+}
+@end
+
+void f0(A *a, id x) { a->x = x; }
diff --git a/clang/test/Driver/darwin-objc-options.m b/clang/test/Driver/darwin-objc-options.m
new file mode 100644
index 0000000..5b421d8
--- /dev/null
+++ b/clang/test/Driver/darwin-objc-options.m
@@ -0,0 +1,21 @@
+// Check miscellaneous Objective-C options.
+
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
+// RUN: -arch x86_64 -fobjc-abi-version=1 2> %t
+// RUN: FileCheck --check-prefix CHECK-X86_64_ABI1 < %t %s
+
+// CHECK-CHECK-X86_64_ABI1: "-cc1"
+// CHECK-CHECK-X86_64_ABI1: -fobjc-fragile-abi
+// CHECK-CHECK-X86_64_ABI1-NOT: -fobjc-dispatch-method
+// CHECK-CHECK-X86_64_ABI1: darwin-objc-options
+
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
+// RUN: -arch i386 -fobjc-abi-version=2 2> %t
+// RUN: FileCheck --check-prefix CHECK-I386_ABI2 < %t %s
+
+// CHECK-CHECK-I386_ABI2: "-cc1"
+// CHECK-CHECK-I386_ABI2-NOT: -fobjc-fragile-abi
+// CHECK-CHECK-I386_ABI2: -fobjc-exceptions
+// CHECK-CHECK-I386_ABI2: -fexceptions
+// CHECK-CHECK-I386_ABI2-NOT: -fobjc-dispatch-method
+// CHECK-CHECK-I386_ABI2: darwin-objc-options
diff --git a/clang/test/Driver/darwin-verify-debug.c b/clang/test/Driver/darwin-verify-debug.c
new file mode 100644
index 0000000..677419a
--- /dev/null
+++ b/clang/test/Driver/darwin-verify-debug.c
@@ -0,0 +1,34 @@
+// Check that we verify debug output properly with multiple -arch options.
+//
+// REQUIRES: asserts
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-phases \
+// RUN: -verify -arch i386 -arch x86_64 %s -g 2> %t
+// RUN: FileCheck -check-prefix=CHECK-MULTIARCH-ACTIONS < %t %s
+//
+// CHECK-MULTIARCH-ACTIONS: 0: input, "{{.*}}darwin-verify-debug.c", c
+// CHECK-MULTIARCH-ACTIONS: 8: dsymutil, {7}, dSYM
+// CHECK-MULTIARCH-ACTIONS: 9: verify, {8}, none
+//
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN: -verify -arch i386 -arch x86_64 %s -g 2> %t
+// RUN: FileCheck -check-prefix=CHECK-MULTIARCH-BINDINGS < %t %s
+//
+// CHECK-MULTIARCH-BINDINGS: # "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["a.out"], output: "a.out.dSYM"
+// CHECK-MULTIARCH-BINDINGS: # "x86_64-apple-darwin10" - "darwin::VerifyDebug", inputs: ["a.out.dSYM"], output: (nothing)
+
+// Check output name derivation.
+//
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN: -verify -o foo %s -g 2> %t
+// RUN: FileCheck -check-prefix=CHECK-OUTPUT-NAME < %t %s
+//
+// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Link", inputs: [{{.*}}], output: "foo"
+// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["foo"], output: "foo.dSYM"
+// CHECK-OUTPUT-NAME: "x86_64-apple-darwin10" - "darwin::VerifyDebug", inputs: ["foo.dSYM"], output: (nothing)
+
+// Check that we only verify when needed.
+//
+// RUN: touch %t.o
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN: -verify -o foo %t.o -g 2> %t
+// RUN: grep "Verify" %t | count 0
diff --git a/clang/test/Driver/darwin-version.c b/clang/test/Driver/darwin-version.c
new file mode 100644
index 0000000..2478a99
--- /dev/null
+++ b/clang/test/Driver/darwin-version.c
@@ -0,0 +1,31 @@
+// RUN: env MACOSX_DEPLOYMENT_TARGET=10.1 \
+// RUN: %clang -target i386-apple-darwin9 -DTEST0 -E %s
+#ifdef TEST0
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1010
+#error Invalid version
+#endif
+#endif
+
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=2.0 \
+// RUN: %clang -target i386-apple-darwin9 -DTEST1 -E %s
+#ifdef TEST1
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ != 20000
+#error Invalid version
+#endif
+#endif
+
+// RUN: env IPHONEOS_DEPLOYMENT_TARGET=2.3.1 \
+// RUN: %clang -target i386-apple-darwin9 -DTEST2 -E %s
+#ifdef TEST2
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ != 20301
+#error Invalid version
+#endif
+#endif
+
+// RUN: env MACOSX_DEPLOYMENT_TARGET=10.4.10 \
+// RUN: %clang -target i386-apple-darwin9 -DTEST3 -E %s
+#ifdef TEST3
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1049
+#error Invalid version
+#endif
+#endif
diff --git a/clang/test/Driver/darwin-xarch.c b/clang/test/Driver/darwin-xarch.c
new file mode 100644
index 0000000..3014236
--- /dev/null
+++ b/clang/test/Driver/darwin-xarch.c
@@ -0,0 +1,20 @@
+// RUN: %clang -target x86_64-apple-darwin10 -### \
+// RUN: -arch i386 -Xarch_i386 -mmacosx-version-min=10.4 \
+// RUN: -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 \
+// RUN: -c %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-COMPILE < %t %s
+//
+// CHECK-COMPILE: clang{{.*}}" "-cc1" "-triple" "i386-apple-macosx10.4.0"
+// CHECK-COMPILE: clang{{.*}}" "-cc1" "-triple" "x86_64-apple-macosx10.5.0"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### \
+// RUN: -arch i386 -Xarch_i386 -Wl,-some-linker-arg -filelist X 2> %t
+// RUN: FileCheck --check-prefix=CHECK-LINK < %t %s
+//
+// CHECK-LINK: ld{{.*}} "-arch" "i386"{{.*}} "-some-linker-arg"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### \
+// RUN: -arch armv7 -Xarch_armv7 -Wl,-some-linker-arg -filelist X 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ARMV7-LINK < %t %s
+//
+// CHECK-ARMV7-LINK: ld{{.*}} "-arch" "armv7"{{.*}} "-some-linker-arg"
diff --git a/clang/test/Driver/debug-options-as.c b/clang/test/Driver/debug-options-as.c
new file mode 100644
index 0000000..a1dbe2e
--- /dev/null
+++ b/clang/test/Driver/debug-options-as.c
@@ -0,0 +1,18 @@
+// cygming have not supported integrated-as yet.
+// XFAIL: cygwin,mingw32
+//
+// Check to make sure clang is somewhat picky about -g options.
+// (Delived from debug-options.c)
+// rdar://10383444
+// RUN: %clang -### -c -save-temps -g %s 2>&1 | FileCheck -check-prefix=SAVE %s
+//
+// SAVE: "-cc1as"
+// SAVE-NOT: "-g"
+
+// Check to make sure clang with -g on a .s file gets passed.
+// rdar://9275556
+// RUN: touch %t.s
+// RUN: %clang -### -c -g %t.s 2>&1 | FileCheck -check-prefix=S %s
+//
+// S: "-cc1as"
+// S: "-g"
diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c
new file mode 100644
index 0000000..5dad8e9
--- /dev/null
+++ b/clang/test/Driver/debug-options.c
@@ -0,0 +1,27 @@
+// Check to make sure clang is somewhat picky about -g options.
+// rdar://10383444
+
+// RUN: %clang -### -c -g %s 2>&1 | FileCheck -check-prefix=G %s
+// RUN: %clang -### -c -g2 %s 2>&1 | FileCheck -check-prefix=G2 %s
+// RUN: %clang -### -c -g3 %s 2>&1 | FileCheck -check-prefix=G3 %s
+// RUN: %clang -### -c -ganything %s 2>&1 | FileCheck -check-prefix=GANY %s
+// RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=GGDB %s
+// RUN: %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=GFOO %s
+//
+// G: "-cc1"
+// G: "-g"
+//
+// G2: "-cc1"
+// G2: "-g"
+//
+// G3: "-cc1"
+// G3: "-g"
+//
+// GANY: "-cc1"
+// GANY-NOT: "-g"
+//
+// GGDB: "-cc1"
+// GGDB: "-g"
+//
+// GFOO: "-cc1"
+// GFOO-NOT: "-g"
diff --git a/clang/test/Driver/debug.c b/clang/test/Driver/debug.c
new file mode 100644
index 0000000..ca1ca30
--- /dev/null
+++ b/clang/test/Driver/debug.c
@@ -0,0 +1,11 @@
+// RUN: cd %S && %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-PWD %s
+// CHECK-PWD: {{"-fdebug-compilation-dir" ".*Driver.*"}}
+
+// RUN: env PWD=/foo %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-FOO %s
+// CHECK-FOO: {{"-fdebug-compilation-dir" ".*foo"}}
+
+// "PWD=/foo gcc" wouldn't necessarily work. You would need to pick a different
+// path to the same directory (try a symlink).
+
+// This depends on host's behavior how $PWD would be set.
+// REQUIRES: shell
diff --git a/clang/test/Driver/default-toolchain.c b/clang/test/Driver/default-toolchain.c
new file mode 100644
index 0000000..b9111a6
--- /dev/null
+++ b/clang/test/Driver/default-toolchain.c
@@ -0,0 +1,8 @@
+// RUN: %clang -target i386-unknown-unknown -m64 -v 2> %t
+// RUN: grep 'Target: x86_64-unknown-unknown' %t
+
+// RUN: %clang -target i386-apple-darwin9 -arch ppc -m64 -v 2> %t
+// RUN: grep 'Target: powerpc64-apple-darwin9' %t
+
+// RUN: %clang -target i386-apple-darwin9 -arch ppc64 -m32 -v 2> %t
+// RUN: grep 'Target: powerpc-apple-darwin9' %t
diff --git a/clang/test/Driver/diagnostics.c b/clang/test/Driver/diagnostics.c
new file mode 100644
index 0000000..8500fad
--- /dev/null
+++ b/clang/test/Driver/diagnostics.c
@@ -0,0 +1,9 @@
+// Parse diagnostic arguments in the driver
+// PR12181
+
+// RUN: not %clang -target x86_64-apple-darwin10 \
+// RUN: -fsyntax-only -fzyzzybalubah \
+// RUN: -Werror=unused-command-line-argument %s
+
+// RUN: not %clang -target x86_64-apple-darwin10 \
+// RUN: -fsyntax-only -fzyzzybalubah -Werror %s
diff --git a/clang/test/Driver/dragonfly.c b/clang/test/Driver/dragonfly.c
new file mode 100644
index 0000000..8a629da
--- /dev/null
+++ b/clang/test/Driver/dragonfly.c
@@ -0,0 +1,7 @@
+// RUN: %clang -no-canonical-prefixes -target amd64-pc-dragonfly %s -### 2> %t.log
+// RUN: FileCheck -input-file %t.log %s
+
+// CHECK: clang{{.*}}" "-cc1" "-triple" "amd64-pc-dragonfly"
+// CHECK: ld{{.*}}" "-dynamic-linker" "{{.*}}ld-elf.{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-L{{.*}}/gcc{{.*}}" {{.*}} "-lc" "-lgcc" "{{.*}}crtend.o" "{{.*}}crtn.o"
+
+
diff --git a/clang/test/Driver/dwarf2-cfi-asm.c b/clang/test/Driver/dwarf2-cfi-asm.c
new file mode 100644
index 0000000..a5c4878
--- /dev/null
+++ b/clang/test/Driver/dwarf2-cfi-asm.c
@@ -0,0 +1,35 @@
+// RUN: %clang -target x86_64-apple-darwin -### -S -integrated-as %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-DARWIN-MC-DEFAULT %s
+// RUN: %clang -target x86_64-apple-darwin -### -S -integrated-as -fdwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-DARWIN-MC-CFI %s
+// RUN: %clang -target x86_64-apple-darwin -### -S -integrated-as -fno-dwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-DARWIN-MC-NOCFI %s
+
+// RUN: %clang -target x86_64-apple-darwin -### -S -no-integrated-as %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-DARWIN-AS-DEFAULT %s
+// RUN: %clang -target x86_64-apple-darwin -### -S -no-integrated-as -fdwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-DARWIN-AS-CFI %s
+// RUN: %clang -target x86_64-apple-darwin -### -S -no-integrated-as -fno-dwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-DARWIN-AS-NOCFI %s
+
+
+// RUN: %clang -target x86_64-pc-linux -### -S -integrated-as %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-LINUX-MC-DEFAULT %s
+// RUN: %clang -target x86_64-pc-linux -### -S -integrated-as -fdwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-LINUX-MC-CFI %s
+// RUN: %clang -target x86_64-pc-linux -### -S -integrated-as -fno-dwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-LINUX-MC-NOCFI %s
+
+// RUN: %clang -target x86_64-pc-linux -### -S -no-integrated-as %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-LINUX-AS-DEFAULT %s
+// RUN: %clang -target x86_64-pc-linux -### -S -no-integrated-as -fdwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-LINUX-AS-CFI %s
+// RUN: %clang -target x86_64-pc-linux -### -S -no-integrated-as -fno-dwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-LINUX-AS-NOCFI %s
+
+
+
+// CHECK-DARWIN-MC-DEFAULT-NOT: -fno-dwarf2-cfi-asm
+// CHECK-DARWIN-MC-CFI-NOT: -fno-dwarf2-cfi-asm
+// CHECK-DARWIN-MC-NOCFI: -fno-dwarf2-cfi-asm
+
+// CHECK-DARWIN-AS-DEFAULT: -fno-dwarf2-cfi-asm
+// CHECK-DARWIN-AS-CFI-NOT: -fno-dwarf2-cfi-asm
+// CHECK-DARWIN-AS-NOCFI: -fno-dwarf2-cfi-asm
+
+
+// CHECK-LINUX-MC-DEFAULT-NOT: -fno-dwarf2-cfi-asmx
+// CHECK-LINUX-MC-CFI-NOT: -fno-dwarf2-cfi-asm
+// CHECK-LINUX-MC-NOCFI: -fno-dwarf2-cfi-asm
+
+// CHECK-LINUX-AS-DEFAULT-NOT: -fno-dwarf2-cfi-asm
+// CHECK-LINUX-AS-CFI-NOT: -fno-dwarf2-cfi-asm
+// CHECK-LINUX-AS-NOCFI: -fno-dwarf2-cfi-asm
diff --git a/clang/test/Driver/emit-llvm.c b/clang/test/Driver/emit-llvm.c
new file mode 100644
index 0000000..76ea059
--- /dev/null
+++ b/clang/test/Driver/emit-llvm.c
@@ -0,0 +1,10 @@
+// Check that -O4 is only honored as the effective -O option.
+// <rdar://problem/7046672> clang/loader problem
+
+// RUN: %clang -ccc-print-phases -c -O4 -O0 %s 2> %t
+// RUN: FileCheck --check-prefix=O4_AND_O0 %s < %t
+
+// O4_AND_O0: 0: input, "{{.*}}", c
+// O4_AND_O0: 1: preprocessor, {0}, cpp-output
+// O4_AND_O0: 2: compiler, {1}, assembler
+// O4_AND_O0: 3: assembler, {2}, object
diff --git a/clang/test/Driver/exceptions.m b/clang/test/Driver/exceptions.m
new file mode 100644
index 0000000..9b747bb
--- /dev/null
+++ b/clang/test/Driver/exceptions.m
@@ -0,0 +1,19 @@
+// RUN: %clang -target x86_64-apple-darwin9 \
+// RUN: -fsyntax-only -fno-exceptions %s
+
+void f1() {
+ @throw @"A";
+}
+
+void f0() {
+ @try {
+ f1();
+ } @catch (id x) {
+ ;
+ }
+}
+
+int main() {
+ f0();
+ return 0;
+}
diff --git a/clang/test/Driver/fast-math.c b/clang/test/Driver/fast-math.c
new file mode 100644
index 0000000..aef7cc3
--- /dev/null
+++ b/clang/test/Driver/fast-math.c
@@ -0,0 +1,119 @@
+// Test that the GCC fast-math floating point flags get lowered to the correct
+// permutation of Clang frontend flags. This is non-trivial for a few reasons.
+// First, the GCC flags have many different and surprising effects. Second,
+// LLVM only supports three switches which is more coarse grained than GCC's
+// support.
+//
+// RUN: %clang -### -fno-honor-infinities -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s
+// CHECK-NO-INFS: "-cc1"
+// CHECK-NO-INFS: "-menable-no-infs"
+//
+// RUN: %clang -### -fno-honor-nans -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s
+// CHECK-NO-NANS: "-cc1"
+// CHECK-NO-NANS: "-menable-no-nans"
+//
+// RUN: %clang -### -fmath-errno -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-MATH-ERRNO %s
+// CHECK-MATH-ERRNO: "-cc1"
+// CHECK-MATH-ERRNO: "-fmath-errno"
+//
+// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
+// RUN: -fno-trapping-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s
+// CHECK-UNSAFE-MATH: "-cc1"
+// CHECK-UNSAFE-MATH: "-menable-unsafe-fp-math"
+//
+// Check that various umbrella flags also enable these frontend options.
+// RUN: %clang -### -ffast-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s
+// RUN: %clang -### -ffast-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s
+// RUN: %clang -### -ffast-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s
+// RUN: %clang -### -ffinite-math-only -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s
+// RUN: %clang -### -ffinite-math-only -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s
+// RUN: %clang -### -funsafe-math-optimizations -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s
+//
+// One umbrella flag is *really* weird and also changes the semantics of the
+// program by adding a special preprocessor macro. Check that the frontend flag
+// modeling this semantic change is provided. Also check that the semantic
+// impact remains even if every optimization is disabled.
+// RUN: %clang -### -ffast-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s
+// RUN: %clang -### -ffast-math -fno-finite-math-only \
+// RUN: -fno-unsafe-math-optimizations -fmath-errno -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s
+// CHECK-FAST-MATH: "-cc1"
+// CHECK-FAST-MATH: "-ffast-math"
+//
+// Check various means of disabling these flags, including disabling them after
+// they've been enabled via an umbrella flag.
+// RUN: %clang -### -fno-honor-infinities -fhonor-infinities -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
+// RUN: %clang -### -ffinite-math-only -fhonor-infinities -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
+// RUN: %clang -### -ffinite-math-only -fno-finite-math-only -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
+// RUN: %clang -### -ffast-math -fhonor-infinities -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
+// RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
+// CHECK-NO-NO-INFS: "-cc1"
+// CHECK-NO-NO-INFS-NOT: "-menable-no-infs"
+// CHECK-NO-NO-INFS: "-o"
+//
+// RUN: %clang -### -fno-honor-nans -fhonor-nans -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
+// RUN: %clang -### -ffinite-math-only -fhonor-nans -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
+// RUN: %clang -### -ffinite-math-only -fno-finite-math-only -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
+// RUN: %clang -### -ffast-math -fhonor-nans -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
+// RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
+// CHECK-NO-NO-NANS: "-cc1"
+// CHECK-NO-NO-NANS-NOT: "-menable-no-nans"
+// CHECK-NO-NO-NANS: "-o"
+//
+// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
+// RUN: -fno-trapping-math -fno-associative-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
+// RUN: -fno-trapping-math -fno-reciprocal-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
+// RUN: -fno-trapping-math -fsigned-zeros -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
+// RUN: -fno-trapping-math -ftrapping-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -funsafe-math-optimizations -fno-associative-math -c %s \
+// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -funsafe-math-optimizations -fno-reciprocal-math -c %s \
+// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -funsafe-math-optimizations -fsigned-zeros -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -funsafe-math-optimizations -ftrapping-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -funsafe-math-optimizations -fno-unsafe-math-optimizations \
+// RUN: -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -ffast-math -fno-associative-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -ffast-math -fno-reciprocal-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -ffast-math -fsigned-zeros -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -ffast-math -ftrapping-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -ffast-math -fno-unsafe-math-optimizations -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// CHECK-NO-UNSAFE-MATH: "-cc1"
+// CHECK-NO-UNSAFE-MATH-NOT: "-menable-unsafe-fp-math"
+// CHECK-NO-UNSAFE-MATH: "-o"
diff --git a/clang/test/Driver/flags.c b/clang/test/Driver/flags.c
new file mode 100644
index 0000000..7a885b6
--- /dev/null
+++ b/clang/test/Driver/flags.c
@@ -0,0 +1,9 @@
+// RUN: %clang -target i386-apple-darwin9 -### -S -msoft-float %s 2> %t.log
+// RUN: grep '"-no-implicit-float"' %t.log
+
+// RUN: %clang -target i386-apple-darwin9 -### -S -msoft-float -mno-soft-float %s 2> %t.log
+// RUN: grep '"-no-implicit-float"' %t.log | count 0
+
+// RUN: %clang -target i386-apple-darwin9 -### -S -mno-soft-float %s -msoft-float 2> %t.log
+// RUN: grep '"-no-implicit-float"' %t.log
+
diff --git a/clang/test/Driver/frame-pointer.c b/clang/test/Driver/frame-pointer.c
new file mode 100644
index 0000000..6be395c
--- /dev/null
+++ b/clang/test/Driver/frame-pointer.c
@@ -0,0 +1,24 @@
+// RUN: %clang -target i386-pc-linux -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s
+// RUN: %clang -target i386-pc-linux -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s
+// RUN: %clang -target i386-pc-linux -### -S -O2 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK2-32 %s
+// RUN: %clang -target i386-pc-linux -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-32 %s
+// RUN: %clang -target i386-pc-linux -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-32 %s
+
+
+// RUN: %clang -target x86_64-pc-linux -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-64 %s
+// RUN: %clang -target x86_64-pc-linux -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-64 %s
+// RUN: %clang -target x86_64-pc-linux -### -S -O2 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK2-64 %s
+// RUN: %clang -target x86_64-pc-linux -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s
+// RUN: %clang -target x86_64-pc-linux -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
+
+// CHECK0-32: -mdisable-fp-elim
+// CHECK1-32-NOT: -mdisable-fp-elim
+// CHECK2-32-NOT: -mdisable-fp-elim
+// CHECK3-32-NOT: -mdisable-fp-elim
+// CHECKs-32-NOT: -mdisable-fp-elim
+
+// CHECK0-64: -mdisable-fp-elim
+// CHECK1-64-NOT: -mdisable-fp-elim
+// CHECK2-64-NOT: -mdisable-fp-elim
+// CHECK3-64-NOT: -mdisable-fp-elim
+// CHECKs-64-NOT: -mdisable-fp-elim
diff --git a/clang/test/Driver/freebsd.c b/clang/test/Driver/freebsd.c
new file mode 100644
index 0000000..1fb84a0
--- /dev/null
+++ b/clang/test/Driver/freebsd.c
@@ -0,0 +1,30 @@
+// REQUIRES: ppc32-registered-target,ppc64-registered-target
+// RUN: %clang -ccc-clang-archs powerpc -no-canonical-prefixes \
+// RUN: -target powerpc-pc-freebsd8 %s \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-PPC %s
+// CHECK-PPC: clang{{.*}}" "-cc1" "-triple" "powerpc-pc-freebsd8"
+// CHECK-PPC: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-PPC: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
+//
+// RUN: %clang -ccc-clang-archs powerpc64 -no-canonical-prefixes \
+// RUN: -target powerpc64-pc-freebsd8 %s \
+// RUN: --sysroot=%S/Inputs/basic_freebsd64_tree -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-PPC64 %s
+// CHECK-PPC64: clang{{.*}}" "-cc1" "-triple" "powerpc64-pc-freebsd8"
+// CHECK-PPC64: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-PPC64: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
+//
+//
+// Check that -m32 properly adjusts the toolchain flags.
+//
+// RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \
+// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-LIB32 %s
+// CHECK-LIB32: clang{{.*}}" "-cc1" "-triple" "i386-pc-freebsd8"
+// CHECK-LIB32: ld{{.*}}" {{.*}} "-m" "elf_i386_fbsd"
+//
+// RUN: %clang -target x86_64-pc-freebsd8 -m32 %s 2>&1 \
+// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-LIB32PATHS %s
+// CHECK-LIB32PATHS: libraries: ={{.*:?}}/usr/lib32
diff --git a/clang/test/Driver/gcc-toolchain.cpp b/clang/test/Driver/gcc-toolchain.cpp
new file mode 100644
index 0000000..e122dac
--- /dev/null
+++ b/clang/test/Driver/gcc-toolchain.cpp
@@ -0,0 +1,23 @@
+// Test that gcc-toolchain option is working correctly
+//
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: -gcc-toolchain %S/Inputs/ubuntu_11.04_multiarch_tree/usr \
+// RUN: | FileCheck %s
+//
+// Test for header search toolchain detection.
+// CHECK: "-internal-isystem"
+// CHECK: "[[TOOLCHAIN:[^"]+]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5"
+// CHECK: "-internal-isystem"
+// CHECK: "[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5/i686-linux-gnu"
+// CHECK: "-internal-isystem"
+// CHECK: "[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5/backward"
+// CHECK: "-internal-isystem" "/usr/local/include"
+//
+// Test for linker toolchain detection. Note that only the '-L' flags will use
+// the same precise formatting of the path as the '-internal-system' flags
+// above, so we just blanket wildcard match the 'crtbegin.o'.
+// CHECK: "{{[^"]*}}ld{{(.exe)?}}"
+// CHECK: "{{[^"]*}}/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o"
+// CHECK: "-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5"
+// CHECK: "-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../.."
diff --git a/clang/test/Driver/gcc_forward.c b/clang/test/Driver/gcc_forward.c
new file mode 100644
index 0000000..77f401b
--- /dev/null
+++ b/clang/test/Driver/gcc_forward.c
@@ -0,0 +1,13 @@
+// Check that we don't try to forward -Xclang or -mlinker-version to GCC.
+//
+// RUN: %clang -target powerpc-unknown-unknown \
+// RUN: -ccc-clang-archs i386 -c %s \
+// RUN: -Xclang foo-bar \
+// RUN: -mlinker-version=10 -### 2> %t
+// RUN: FileCheck < %t %s
+//
+// CHECK: gcc{{.*}}"
+// CHECK-NOT: "-mlinker-version=10"
+// CHECK-NOT: "-Xclang"
+// CHECK-NOT: "foo-bar"
+// CHECK: gcc_forward
diff --git a/clang/test/Driver/gnu-runtime.m b/clang/test/Driver/gnu-runtime.m
new file mode 100644
index 0000000..12426d9
--- /dev/null
+++ b/clang/test/Driver/gnu-runtime.m
@@ -0,0 +1,5 @@
+// RUN: %clang -target i386-apple-darwin10 -### -fsyntax-only -fgnu-runtime %s 2>&1 | FileCheck %s
+// RUN: %clang -target i386-apple-darwin10 -### -x objective-c++ -fsyntax-only -fgnu-runtime %s 2>&1 | FileCheck %s
+// CHECK: -fgnu-runtime
+// CHECK: -fobjc-runtime-has-arc
+// CHECK: -fobjc-runtime-has-weak
diff --git a/clang/test/Driver/gold-lto.c b/clang/test/Driver/gold-lto.c
new file mode 100644
index 0000000..05ac27a
--- /dev/null
+++ b/clang/test/Driver/gold-lto.c
@@ -0,0 +1,6 @@
+// RUN: touch %t.o
+// RUN: %clang -target x86_64-pc-linux-gnu -### %t.o -O4 -Wl,-plugin-opt=foo 2> %t.log
+// RUN: FileCheck %s < %t.log
+
+// CHECK: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK: "-plugin-opt=foo"
diff --git a/clang/test/Driver/hello.c b/clang/test/Driver/hello.c
new file mode 100644
index 0000000..c2260e5
--- /dev/null
+++ b/clang/test/Driver/hello.c
@@ -0,0 +1,18 @@
+// RUN: %clang -ccc-echo -o %t.exe %s 2> %t.log
+
+// Make sure we used clang.
+// RUN: grep 'clang\(-[0-9.]\+\)\?\(\.[Ee][Xx][Ee]\)\?" -cc1 .*hello.c' %t.log
+
+// RUN: %t.exe > %t.out
+// RUN: grep "I'm a little driver, short and stout." %t.out
+
+// FIXME: We don't have a usable assembler on Windows, so we can't build real
+// apps yet.
+// XFAIL: win32
+
+#include <stdio.h>
+
+int main() {
+ printf("I'm a little driver, short and stout.");
+ return 0;
+}
diff --git a/clang/test/Driver/immediate-options.c b/clang/test/Driver/immediate-options.c
new file mode 100644
index 0000000..5a3ec87
--- /dev/null
+++ b/clang/test/Driver/immediate-options.c
@@ -0,0 +1,4 @@
+// RUN: %clang --help
+// RUN: %clang --help-hidden
+// RUN: %clang -dumpversion
+// RUN: %clang -print-search-dirs
diff --git a/clang/test/Driver/index-header-map.c b/clang/test/Driver/index-header-map.c
new file mode 100644
index 0000000..8bd677a
--- /dev/null
+++ b/clang/test/Driver/index-header-map.c
@@ -0,0 +1,4 @@
+// RUN: %clang -I%S/Before -index-header-map -I%S/Index -I%S/After %s -### 2>> %t.log
+// RUN: FileCheck %s < %t.log
+
+// CHECK: {{-I.*Before.*-index-header-map.*-I.*Index.*-I.*After}}
diff --git a/clang/test/Driver/invalid-o-level.c b/clang/test/Driver/invalid-o-level.c
new file mode 100644
index 0000000..d5242c7
--- /dev/null
+++ b/clang/test/Driver/invalid-o-level.c
@@ -0,0 +1,4 @@
+// RUN: not %clang_cc1 %s -O900 2> %t.log
+// RUN: FileCheck %s -input-file=%t.log
+
+// CHECK: invalid value '900' in '-O900'
diff --git a/clang/test/Driver/ios-simulator-arcruntime.c b/clang/test/Driver/ios-simulator-arcruntime.c
new file mode 100644
index 0000000..9bf2091
--- /dev/null
+++ b/clang/test/Driver/ios-simulator-arcruntime.c
@@ -0,0 +1,6 @@
+// RUN: %clang -### -x objective-c -target i386-apple-darwin10 -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=40201 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
+// RUN: %clang -### -x objective-c -target i386-apple-darwin10 -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
+//
+
+// CHECK-OPTIONS1-NOT: -fobjc-runtime-has-weak
+// CHECK-OPTIONS2: -fobjc-runtime-has-weak
diff --git a/clang/test/Driver/le32-unknown-nacl.cpp b/clang/test/Driver/le32-unknown-nacl.cpp
new file mode 100644
index 0000000..f68b220
--- /dev/null
+++ b/clang/test/Driver/le32-unknown-nacl.cpp
@@ -0,0 +1,146 @@
+// RUN: %clang -target le32-unknown-nacl -ccc-clang-archs le32 -ccc-echo %s -emit-llvm-only -c 2>&1 | FileCheck %s -check-prefix=ECHO
+// RUN: %clang -target le32-unknown-nacl -ccc-clang-archs le32 %s -emit-llvm -S -c -o - | FileCheck %s
+// RUN: %clang -target le32-unknown-nacl -ccc-clang-archs le32 %s -emit-llvm -S -c -pthread -o - | FileCheck %s -check-prefix=THREADS
+
+// ECHO: {{.*}} -cc1 {{.*}}le32-unknown-nacl.c
+
+// Check platform defines
+#include <stdarg.h>
+#include <stddef.h>
+
+extern "C" {
+
+// CHECK: @align_c = global i32 1
+int align_c = __alignof(char);
+
+// CHECK: @align_s = global i32 2
+int align_s = __alignof(short);
+
+// CHECK: @align_i = global i32 4
+int align_i = __alignof(int);
+
+// CHECK: @align_l = global i32 4
+int align_l = __alignof(long);
+
+// CHECK: @align_ll = global i32 8
+int align_ll = __alignof(long long);
+
+// CHECK: @align_p = global i32 4
+int align_p = __alignof(void*);
+
+// CHECK: @align_f = global i32 4
+int align_f = __alignof(float);
+
+// CHECK: @align_d = global i32 8
+int align_d = __alignof(double);
+
+// CHECK: @align_ld = global i32 8
+int align_ld = __alignof(long double);
+
+// CHECK: @align_vl = global i32 4
+int align_vl = __alignof(va_list);
+
+// CHECK: __LITTLE_ENDIAN__defined
+#ifdef __LITTLE_ENDIAN__
+void __LITTLE_ENDIAN__defined() {}
+#endif
+
+// CHECK: __native_client__defined
+#ifdef __native_client__
+void __native_client__defined() {}
+#endif
+
+// CHECK: __le32__defined
+#ifdef __le32__
+void __le32__defined() {}
+#endif
+
+// CHECK: __pnacl__defined
+#ifdef __pnacl__
+void __pnacl__defined() {}
+#endif
+
+// CHECK: unixdefined
+#ifdef unix
+void unixdefined() {}
+#endif
+
+// CHECK: __ELF__defined
+#ifdef __ELF__
+void __ELF__defined() {}
+#endif
+
+// CHECK: _GNU_SOURCEdefined
+#ifdef _GNU_SOURCE
+void _GNU_SOURCEdefined() {}
+#endif
+
+// THREADS: _REENTRANTdefined
+// CHECK: _REENTRANTundefined
+#ifdef _REENTRANT
+void _REENTRANTdefined() {}
+#else
+void _REENTRANTundefined() {}
+#endif
+
+// Check types
+
+// CHECK: signext i8 @check_char()
+char check_char() { return 0; }
+
+// CHECK: signext i16 @check_short()
+short check_short() { return 0; }
+
+// CHECK: i32 @check_int()
+int check_int() { return 0; }
+
+// CHECK: i32 @check_long()
+long check_long() { return 0; }
+
+// CHECK: i64 @check_longlong()
+long long check_longlong() { return 0; }
+
+// CHECK: zeroext i8 @check_uchar()
+unsigned char check_uchar() { return 0; }
+
+// CHECK: zeroext i16 @check_ushort()
+unsigned short check_ushort() { return 0; }
+
+// CHECK: i32 @check_uint()
+unsigned int check_uint() { return 0; }
+
+// CHECK: i32 @check_ulong()
+unsigned long check_ulong() { return 0; }
+
+// CHECK: i64 @check_ulonglong()
+unsigned long long check_ulonglong() { return 0; }
+
+// CHECK: i32 @check_size_t()
+size_t check_size_t() { return 0; }
+
+// CHECK: float @check_float()
+float check_float() { return 0; }
+
+// CHECK: double @check_double()
+double check_double() { return 0; }
+
+// CHECK: double @check_longdouble()
+long double check_longdouble() { return 0; }
+
+}
+
+template<int> void Switch();
+template<> void Switch<4>();
+template<> void Switch<8>();
+template<> void Switch<16>();
+
+void check_pointer_size() {
+ // CHECK: SwitchILi4
+ Switch<sizeof(void*)>();
+
+ // CHECK: SwitchILi8
+ Switch<sizeof(long long)>();
+
+ // CHECK: SwitchILi16
+ Switch<sizeof(va_list)>();
+}
diff --git a/clang/test/Driver/linker-opts.c b/clang/test/Driver/linker-opts.c
new file mode 100644
index 0000000..d036dfd
--- /dev/null
+++ b/clang/test/Driver/linker-opts.c
@@ -0,0 +1,5 @@
+// RUN: env LIBRARY_PATH=%T/test1 %clang -x c %s -### 2>&1 | FileCheck %s
+// CHECK: "-L" "{{.*}}/test1"
+
+// GCC driver is used as linker on cygming. It should be aware of LIBRARY_PATH.
+// XFAIL: cygwin,mingw32
diff --git a/clang/test/Driver/linux-as.c b/clang/test/Driver/linux-as.c
new file mode 100644
index 0000000..22eac0d
--- /dev/null
+++ b/clang/test/Driver/linux-as.c
@@ -0,0 +1,31 @@
+// Check passing options to the assembler for ARM targets.
+//
+// RUN: %clang -target arm-linux -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=ARM %s
+// CHECK-ARM: as{{(.exe)?}}"
+//
+// RUN: %clang -target arm-linux -mcpu=cortex-a8 -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=ARM-MCPU %s
+// CHECK-ARM-MCPU: as{{(.exe)?}}" "-mcpu=cortex-a8"
+//
+// RUN: %clang -target arm-linux -mfpu=neon -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=ARM-MFPU %s
+// CHECK-ARM-MFPU: as{{(.exe)?}}" "-mfpu=neon"
+//
+// RUN: %clang -target arm-linux -march=armv7-a -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=ARM-MARCH %s
+// CHECK-ARM-MARCH: as{{(.exe)?}}" "-march=armv7-a"
+//
+// RUN: %clang -target arm-linux -mcpu=cortex-a8 -mfpu=neon -march=armv7-a -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=ARM-ALL %s
+// CHECK-ARM-ALL: as{{(.exe)?}}" "-march=armv7-a" "-mcpu=cortex-a8" "-mfpu=neon"
+//
+// RUN: %clang -target armv7-linux -mcpu=cortex-a8 -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=ARM-TARGET %s
+// CHECK-ARM-TARGET: as{{(.exe)?}}" "-mfpu=neon" "-mcpu=cortex-a8"
diff --git a/clang/test/Driver/linux-header-search.cpp b/clang/test/Driver/linux-header-search.cpp
new file mode 100644
index 0000000..ea82660
--- /dev/null
+++ b/clang/test/Driver/linux-header-search.cpp
@@ -0,0 +1,75 @@
+// General tests that the header search paths detected by the driver and passed
+// to CC1 are sane.
+//
+// Test a very broken version of multiarch that shipped in Ubuntu 11.04.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: --sysroot=%S/Inputs/ubuntu_11.04_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-UBUNTU-11-04 %s
+// CHECK-UBUNTU-11-04: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK-UBUNTU-11-04: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-UBUNTU-11-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5"
+// CHECK-UBUNTU-11-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5/i686-linux-gnu"
+// CHECK-UBUNTU-11-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5/backward"
+// CHECK-UBUNTU-11-04: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-UBUNTU-11-04: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-UBUNTU-11-04: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-UBUNTU-11-04: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+//
+// Thoroughly exercise the Debian multiarch environment.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target i686-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-X86 %s
+// CHECK-DEBIAN-X86: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-DEBIAN-X86: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-X86: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../../../include/c++/4.5"
+// CHECK-DEBIAN-X86: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../../../include/c++/4.5/i686-linux-gnu"
+// CHECK-DEBIAN-X86: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../../../include/c++/4.5/backward"
+// CHECK-DEBIAN-X86: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-DEBIAN-X86: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-DEBIAN-X86: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/i386-linux-gnu"
+// CHECK-DEBIAN-X86: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-DEBIAN-X86: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-X86-64 %s
+// CHECK-DEBIAN-X86-64: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-DEBIAN-X86-64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-X86-64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../../../include/c++/4.5"
+// CHECK-DEBIAN-X86-64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../../../include/c++/4.5/x86_64-linux-gnu"
+// CHECK-DEBIAN-X86-64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../../../include/c++/4.5/backward"
+// CHECK-DEBIAN-X86-64: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-DEBIAN-X86-64: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-DEBIAN-X86-64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/x86_64-linux-gnu"
+// CHECK-DEBIAN-X86-64: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-DEBIAN-X86-64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// RUN: %clang -ccc-clang-archs powerpc -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target powerpc-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-PPC %s
+// CHECK-DEBIAN-PPC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-DEBIAN-PPC: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-PPC: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../../../include/c++/4.5"
+// CHECK-DEBIAN-PPC: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../../../include/c++/4.5/powerpc-linux-gnu"
+// CHECK-DEBIAN-PPC: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../../../include/c++/4.5/backward"
+// CHECK-DEBIAN-PPC: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-DEBIAN-PPC: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-DEBIAN-PPC: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/powerpc-linux-gnu"
+// CHECK-DEBIAN-PPC: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-DEBIAN-PPC: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// RUN: %clang -ccc-clang-archs powerpc64 -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target powerpc64-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-PPC64 %s
+// CHECK-DEBIAN-PPC64: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-DEBIAN-PPC64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../../../include/c++/4.5"
+// CHECK-DEBIAN-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../../../include/c++/4.5/powerpc64-linux-gnu"
+// CHECK-DEBIAN-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../../../include/c++/4.5/backward"
+// CHECK-DEBIAN-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-DEBIAN-PPC64: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-DEBIAN-PPC64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/powerpc64-linux-gnu"
+// CHECK-DEBIAN-PPC64: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-DEBIAN-PPC64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
new file mode 100644
index 0000000..9a35d5d
--- /dev/null
+++ b/clang/test/Driver/linux-ld.c
@@ -0,0 +1,270 @@
+// General tests that ld invocations on Linux targets sane. Note that we use
+// sysroot to make these tests independent of the host system.
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LD-32 %s
+// CHECK-LD-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o"
+// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0"
+// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib"
+// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.."
+// CHECK-LD-32: "-L[[SYSROOT]]/lib"
+// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LD-64 %s
+// CHECK-LD-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o"
+// CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
+// CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib"
+// CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.."
+// CHECK-LD-64: "-L[[SYSROOT]]/lib"
+// CHECK-LD-64: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -m32 \
+// RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-32-TO-32 %s
+// CHECK-32-TO-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-32-TO-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o"
+// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0"
+// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib/../lib32"
+// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../lib32"
+// CHECK-32-TO-32: "-L[[SYSROOT]]/lib/../lib32"
+// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/../lib32"
+// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib"
+// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.."
+// CHECK-32-TO-32: "-L[[SYSROOT]]/lib"
+// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -m64 \
+// RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-32-TO-64 %s
+// CHECK-32-TO-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-32-TO-64: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0/64/crtbegin.o"
+// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/64"
+// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib/../lib64"
+// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../lib64"
+// CHECK-32-TO-64: "-L[[SYSROOT]]/lib/../lib64"
+// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/../lib64"
+// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0"
+// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib"
+// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.."
+// CHECK-32-TO-64: "-L[[SYSROOT]]/lib"
+// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -m64 \
+// RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-64-TO-64 %s
+// CHECK-64-TO-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-64-TO-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o"
+// CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
+// CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib/../lib64"
+// CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../lib64"
+// CHECK-64-TO-64: "-L[[SYSROOT]]/lib/../lib64"
+// CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/../lib64"
+// CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib"
+// CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.."
+// CHECK-64-TO-64: "-L[[SYSROOT]]/lib"
+// CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -m32 \
+// RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-64-TO-32 %s
+// CHECK-64-TO-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-64-TO-32: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32/crtbegin.o"
+// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32"
+// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib/../lib32"
+// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../lib32"
+// CHECK-64-TO-32: "-L[[SYSROOT]]/lib/../lib32"
+// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/../lib32"
+// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
+// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib"
+// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.."
+// CHECK-64-TO-32: "-L[[SYSROOT]]/lib"
+// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -m32 \
+// RUN: -gcc-toolchain %S/Inputs/multilib_64bit_linux_tree/usr \
+// RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-64-TO-32-SYSROOT %s
+// CHECK-64-TO-32-SYSROOT: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-64-TO-32-SYSROOT: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32/crtbegin.o"
+// CHECK-64-TO-32-SYSROOT: "-L{{[^"]*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32"
+// CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/lib/../lib32"
+// CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/usr/lib/../lib32"
+// CHECK-64-TO-32-SYSROOT: "-L{{[^"]*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
+// CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/lib"
+// CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -m32 \
+// RUN: -ccc-install-dir %S/Inputs/fake_install_tree/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-INSTALL-DIR-32 %s
+// CHECK-INSTALL-DIR-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-INSTALL-DIR-32: "{{.*}}/Inputs/fake_install_tree/bin/../lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o"
+// CHECK-INSTALL-DIR-32: "-L{{.*}}/Inputs/fake_install_tree/bin/../lib/gcc/i386-unknown-linux/4.7.0"
+//
+// Check that with 64-bit builds, we don't actually use the install directory
+// as its version of GCC is lower than our sysrooted version.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -m64 \
+// RUN: -ccc-install-dir %S/Inputs/fake_install_tree/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-INSTALL-DIR-64 %s
+// CHECK-INSTALL-DIR-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-INSTALL-DIR-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o"
+// CHECK-INSTALL-DIR-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
+//
+// Check that we support unusual patch version formats, including missing that
+// component.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -m32 \
+// RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing1/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION1 %s
+// CHECK-GCC-VERSION1: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-GCC-VERSION1: "{{.*}}/Inputs/gcc_version_parsing1/bin/../lib/gcc/i386-unknown-linux/4.7/crtbegin.o"
+// CHECK-GCC-VERSION1: "-L{{.*}}/Inputs/gcc_version_parsing1/bin/../lib/gcc/i386-unknown-linux/4.7"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -m32 \
+// RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing2/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION2 %s
+// CHECK-GCC-VERSION2: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-GCC-VERSION2: "{{.*}}/Inputs/gcc_version_parsing2/bin/../lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o"
+// CHECK-GCC-VERSION2: "-L{{.*}}/Inputs/gcc_version_parsing2/bin/../lib/gcc/i386-unknown-linux/4.7.x"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -m32 \
+// RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing3/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION3 %s
+// CHECK-GCC-VERSION3: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-GCC-VERSION3: "{{.*}}/Inputs/gcc_version_parsing3/bin/../lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o"
+// CHECK-GCC-VERSION3: "-L{{.*}}/Inputs/gcc_version_parsing3/bin/../lib/gcc/i386-unknown-linux/4.7.99-rc5"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -m32 \
+// RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing4/bin \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION4 %s
+// CHECK-GCC-VERSION4: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-GCC-VERSION4: "{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99/crtbegin.o"
+// CHECK-GCC-VERSION4: "-L{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99"
+//
+// Test a very broken version of multiarch that shipped in Ubuntu 11.04.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: --sysroot=%S/Inputs/ubuntu_11.04_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-UBUNTU-11-04 %s
+// CHECK-UBUNTU-11-04: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-UBUNTU-11-04: "{{.*}}/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o"
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5"
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../i386-linux-gnu"
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu"
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../.."
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/lib"
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib"
+//
+// Test the setup that shipped in SUSE 10.3 on ppc64.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target powerpc64-suse-linux \
+// RUN: --sysroot=%S/Inputs/suse_10.3_ppc64_tree \
+// RUN: | FileCheck --check-prefix=CHECK-SUSE-10-3-PPC64 %s
+// CHECK-SUSE-10-3-PPC64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-SUSE-10-3-PPC64: "{{.*}}/usr/lib/gcc/powerpc64-suse-linux/4.1.2/64/crtbegin.o"
+// CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-suse-linux/4.1.2/64"
+// CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-suse-linux/4.1.2/../../../../lib64"
+// CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/lib/../lib64"
+// CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/usr/lib/../lib64"
+//
+// Check that we do not pass --hash-style=gnu and --hash-style=both to linker
+// and provide correct path to the dynamic linker and emulation mode when build
+// for MIPS platforms.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -ccc-clang-archs mips \
+// RUN: | FileCheck --check-prefix=CHECK-MIPS %s
+// CHECK-MIPS: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPS: "-m" "elf32btsmip"
+// CHECK-MIPS: "-dynamic-linker" "{{.*}}/lib/ld.so.1"
+// CHECK-MIPS-NOT: "--hash-style={{gnu|both}}"
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: -target mipsel-linux-gnu -ccc-clang-archs mipsel \
+// RUN: | FileCheck --check-prefix=CHECK-MIPSEL %s
+// CHECK-MIPSEL: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPSEL: "-m" "elf32ltsmip"
+// CHECK-MIPSEL: "-dynamic-linker" "{{.*}}/lib/ld.so.1"
+// CHECK-MIPSEL-NOT: "--hash-style={{gnu|both}}"
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: -target mips64-linux-gnu -ccc-clang-archs mips64 \
+// RUN: | FileCheck --check-prefix=CHECK-MIPS64 %s
+// CHECK-MIPS64: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPS64: "-m" "elf64btsmip"
+// CHECK-MIPS64: "-dynamic-linker" "{{.*}}/lib64/ld.so.1"
+// CHECK-MIPS64-NOT: "--hash-style={{gnu|both}}"
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: -target mips64el-linux-gnu -ccc-clang-archs mips64el \
+// RUN: | FileCheck --check-prefix=CHECK-MIPS64EL %s
+// CHECK-MIPS64EL: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPS64EL: "-m" "elf64ltsmip"
+// CHECK-MIPS64EL: "-dynamic-linker" "{{.*}}/lib64/ld.so.1"
+// CHECK-MIPS64EL-NOT: "--hash-style={{gnu|both}}"
+//
+// Thoroughly exercise the Debian multiarch environment.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i686-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-X86 %s
+// CHECK-DEBIAN-X86: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-X86: "{{.*}}/usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o"
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5"
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../../i386-linux-gnu"
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu"
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../.."
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-X86-64 %s
+// CHECK-DEBIAN-X86-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-X86-64: "{{.*}}/usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o"
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5"
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../../x86_64-linux-gnu"
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/x86_64-linux-gnu"
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../.."
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target powerpc-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-PPC %s
+// CHECK-DEBIAN-PPC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-PPC: "{{.*}}/usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o"
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5"
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../../powerpc-linux-gnu"
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/powerpc-linux-gnu"
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../.."
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target powerpc64-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-PPC64 %s
+// CHECK-DEBIAN-PPC64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-PPC64: "{{.*}}/usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o"
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5"
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../../powerpc64-linux-gnu"
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/powerpc64-linux-gnu"
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../.."
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib"
+//
diff --git a/clang/test/Driver/lto.c b/clang/test/Driver/lto.c
new file mode 100644
index 0000000..22b4788
--- /dev/null
+++ b/clang/test/Driver/lto.c
@@ -0,0 +1,23 @@
+// -emit-llvm, -flto, and -O4 all cause a switch to llvm-bc object files.
+// RUN: %clang -ccc-print-phases -c %s -flto 2> %t.log
+// RUN: grep '2: compiler, {1}, lto-bc' %t.log
+// RUN: %clang -ccc-print-phases -c %s -O4 2> %t.log
+// RUN: grep '2: compiler, {1}, lto-bc' %t.log
+
+// and -emit-llvm doesn't alter pipeline (unfortunately?).
+// RUN: %clang -ccc-print-phases %s -emit-llvm 2> %t.log
+// RUN: grep '0: input, ".*lto.c", c' %t.log
+// RUN: grep '1: preprocessor, {0}, cpp-output' %t.log
+// RUN: grep '2: compiler, {1}, lto-bc' %t.log
+// RUN: grep '3: linker, {2}, image' %t.log
+
+// llvm-bc and llvm-ll outputs need to match regular suffixes
+// (unfortunately).
+// RUN: %clang %s -emit-llvm -save-temps -### 2> %t.log
+// RUN: grep '"-o" ".*lto\.i" "-x" "c" ".*lto\.c"' %t.log
+// RUN: grep '"-o" ".*lto\.o" .*".*lto\.i"' %t.log
+// RUN: grep '".*a.out" .*".*lto\.o"' %t.log
+
+// RUN: %clang %s -emit-llvm -S -### 2> %t.log
+// RUN: grep '"-o" ".*lto\.s" "-x" "c" ".*lto\.c"' %t.log
+
diff --git a/clang/test/Driver/m_and_mm.c b/clang/test/Driver/m_and_mm.c
new file mode 100644
index 0000000..eab2a04
--- /dev/null
+++ b/clang/test/Driver/m_and_mm.c
@@ -0,0 +1,3 @@
+// RUN: %clang -### \
+// RUN: -M -MM %s 2> %t
+// RUN: grep '"-sys-header-deps"' %t | count 0
diff --git a/clang/test/Driver/mg.c b/clang/test/Driver/mg.c
new file mode 100644
index 0000000..4f43814
--- /dev/null
+++ b/clang/test/Driver/mg.c
@@ -0,0 +1,5 @@
+// RUN: %clang -M -MG -include nonexistent-preinclude.h %s > %t
+// RUN: fgrep nonexistent-preinclude.h %t
+// RUN: fgrep nonexistent-ppinclude.h %t
+
+#include "nonexistent-ppinclude.h"
diff --git a/clang/test/Driver/mips-as.c b/clang/test/Driver/mips-as.c
new file mode 100644
index 0000000..44b8d8d
--- /dev/null
+++ b/clang/test/Driver/mips-as.c
@@ -0,0 +1,31 @@
+// Check passing options to the assembler for MIPS targets.
+//
+// RUN: %clang -target mips-linux-gnu -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS32-EB-AS %s
+// CHECK-MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB"
+//
+// RUN: %clang -target mipsel-linux-gnu -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS32-EL-AS %s
+// CHECK-MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL"
+//
+// RUN: %clang -target mips64-linux-gnu -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS64-EB-AS %s
+// CHECK-MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB"
+//
+// RUN: %clang -target mips64el-linux-gnu -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS64-EL-AS %s
+// CHECK-MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL"
+//
+// RUN: %clang -target mips-linux-gnu -mabi=eabi -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS-EABI %s
+// CHECK-MIPS-EABI: as{{(.exe)?}}" "-march" "mips32" "-mabi" "eabi" "-EB"
+//
+// RUN: %clang -target mips64-linux-gnu -mabi=n32 -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS-N32 %s
+// CHECK-MIPS-N32: as{{(.exe)?}}" "-march" "mips64" "-mabi" "n32" "-EB"
diff --git a/clang/test/Driver/mips-float.c b/clang/test/Driver/mips-float.c
new file mode 100644
index 0000000..c9e107f
--- /dev/null
+++ b/clang/test/Driver/mips-float.c
@@ -0,0 +1,42 @@
+// Check handling -mhard-float / -msoft-float / -mfloat-abi options
+// when build for MIPS platforms.
+//
+// Default
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu \
+// RUN: | FileCheck --check-prefix=CHECK-DEF %s
+// CHECK-DEF: "-mfloat-abi" "hard"
+//
+// -mhard-float
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -mhard-float \
+// RUN: | FileCheck --check-prefix=CHECK-HARD %s
+// CHECK-HARD: "-mfloat-abi" "hard"
+//
+// -msoft-float
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -msoft-float \
+// RUN: | FileCheck --check-prefix=CHECK-SOFT %s
+// CHECK-SOFT: "-msoft-float"
+// CHECK-SOFT: "-mfloat-abi" "soft"
+// CHECK-SOFT: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=hard
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -mfloat-abi=hard \
+// RUN: | FileCheck --check-prefix=CHECK-ABI-HARD %s
+// CHECK-ABI-HARD: "-mfloat-abi" "hard"
+//
+// -mfloat-abi=soft
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -mfloat-abi=soft \
+// RUN: | FileCheck --check-prefix=CHECK-ABI-SOFT %s
+// CHECK-ABI-SOFT: "-msoft-float"
+// CHECK-ABI-SOFT: "-mfloat-abi" "soft"
+// CHECK-ABI-SOFT: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=single
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -mfloat-abi=single \
+// RUN: | FileCheck --check-prefix=CHECK-ABI-SINGLE %s
+// CHECK-ABI-SINGLE: "-target-feature" "+single-float"
diff --git a/clang/test/Driver/mno-global-merge.c b/clang/test/Driver/mno-global-merge.c
new file mode 100644
index 0000000..ec9f69e
--- /dev/null
+++ b/clang/test/Driver/mno-global-merge.c
@@ -0,0 +1,12 @@
+// RUN: %clang -target armv7-apple-darwin10 \
+// RUN: -mno-global-merge -### -fsyntax-only %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-NGM < %t %s
+
+// CHECK-NGM: "-mno-global-merge"
+
+// RUN: %clang -target armv7-apple-darwin10 \
+// RUN: -mglobal-merge -### -fsyntax-only %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-GM < %t %s
+
+// CHECK-GM-NOT: "-mglobal-merge"
+
diff --git a/clang/test/Driver/modules.m b/clang/test/Driver/modules.m
new file mode 100644
index 0000000..b93054d
--- /dev/null
+++ b/clang/test/Driver/modules.m
@@ -0,0 +1,6 @@
+// RUN: %clang -fmodules -fno-modules -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MODULES %s
+// CHECK-NO-MODULES-NOT: -fmodules
+
+// RUN: %clang -fmodules -fno-modules -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-MODULES %s
+// CHECK-HAS-MODULES: -fmodules
+
diff --git a/clang/test/Driver/modules.mm b/clang/test/Driver/modules.mm
new file mode 100644
index 0000000..b2948c4
--- /dev/null
+++ b/clang/test/Driver/modules.mm
@@ -0,0 +1,6 @@
+// RUN: %clang -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MODULES %s
+// RUN: %clang -fcxx-modules -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MODULES %s
+// CHECK-NO-MODULES-NOT: -fmodules
+
+// RUN: %clang -fcxx-modules -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-MODULES %s
+// CHECK-HAS-MODULES: -fmodules
diff --git a/clang/test/Driver/no-objc-arr.m b/clang/test/Driver/no-objc-arr.m
new file mode 100644
index 0000000..e449393
--- /dev/null
+++ b/clang/test/Driver/no-objc-arr.m
@@ -0,0 +1,8 @@
+// RUN: %clang -Werror -fobjc-arc -fsyntax-only -fno-objc-arc -Xclang -verify %s
+// rdar://8949617
+
+void * FOO() {
+ id string = @"Hello World.\n";
+ void *pointer = string; // No error must be issued
+ return pointer;
+}
diff --git a/clang/test/Driver/no-objc-default-synthesize-properties.m b/clang/test/Driver/no-objc-default-synthesize-properties.m
new file mode 100644
index 0000000..e380514
--- /dev/null
+++ b/clang/test/Driver/no-objc-default-synthesize-properties.m
@@ -0,0 +1,10 @@
+// RUN: %clang -fsyntax-only -fno-objc-default-synthesize-properties -fobjc-default-synthesize-properties %s 2>&1 | FileCheck %s
+
+@interface I
+@property int P;
+@end
+
+@implementation I
+@end
+// CHECK: warning: argument unused during compilation: '-fno-objc-default-synthesize-properties'
+// CHECK: warning: argument unused during compilation: '-fobjc-default-synthesize-properties'
diff --git a/clang/test/Driver/no-sibling-calls.c b/clang/test/Driver/no-sibling-calls.c
new file mode 100644
index 0000000..c248990
--- /dev/null
+++ b/clang/test/Driver/no-sibling-calls.c
@@ -0,0 +1,8 @@
+// RUN: %clang -### %s -fno-optimize-sibling-calls 2> %t
+// RUN: FileCheck --check-prefix=CHECK-NOSC < %t %s
+// CHECK-NOSC: "-mdisable-tail-calls"
+
+// RUN: %clang -### -foptimize-sibling-calls %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-OSC < %t %s
+// CHECK-OSC-NOT: "-mdisable-tail-calls"
+
diff --git a/clang/test/Driver/noexecstack.c b/clang/test/Driver/noexecstack.c
new file mode 100644
index 0000000..1f47728
--- /dev/null
+++ b/clang/test/Driver/noexecstack.c
@@ -0,0 +1 @@
+// RUN: %clang -### %s -c -o tmp.o -triple i686-pc-linux-gnu -integrated-as -Wa,--noexecstack 2>&1 | grep "mnoexecstack"
diff --git a/clang/test/Driver/noinline.c b/clang/test/Driver/noinline.c
new file mode 100644
index 0000000..e665b2f
--- /dev/null
+++ b/clang/test/Driver/noinline.c
@@ -0,0 +1,10 @@
+// Make sure the driver is correctly passing -fno-inline-functions
+// rdar://10972766
+
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -fno-inline -fno-inline-functions -### -fsyntax-only %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK < %t %s
+
+// CHECK: clang
+// CHECK: "-fno-inline"
+// CHECK: "-fno-inline-functions"
diff --git a/clang/test/Driver/nostdincxx.cpp b/clang/test/Driver/nostdincxx.cpp
new file mode 100644
index 0000000..7e00555
--- /dev/null
+++ b/clang/test/Driver/nostdincxx.cpp
@@ -0,0 +1,4 @@
+// RUN: %clangxx -nostdinc++ %s 2>&1 | FileCheck %s
+// XFAIL: win32
+// CHECK: file not found
+#include <vector>
diff --git a/clang/test/Driver/nostdlib.c b/clang/test/Driver/nostdlib.c
new file mode 100644
index 0000000..e9ada31
--- /dev/null
+++ b/clang/test/Driver/nostdlib.c
@@ -0,0 +1,4 @@
+// RUN: %clang -target i686-pc-linux-gnu -### -nostdlib %s 2> %t
+// RUN: FileCheck < %t %s
+//
+// CHECK-NOT: start-group
diff --git a/clang/test/Driver/nostdlibinc.c b/clang/test/Driver/nostdlibinc.c
new file mode 100644
index 0000000..5b6fab6
--- /dev/null
+++ b/clang/test/Driver/nostdlibinc.c
@@ -0,0 +1,10 @@
+// RUN: %clang -target x86_64-unknown-unknown \
+// RUN: -nostdlibinc -ffreestanding -fsyntax-only %s
+
+#if !__has_include("stddef.h")
+#error "expected to be able to find compiler builtin headers!"
+#endif
+
+#if __has_include("stdlib.h")
+#error "expected to *not* be able to find standard C headers"
+#endif
diff --git a/clang/test/Driver/objc++-cpp-output.mm b/clang/test/Driver/objc++-cpp-output.mm
new file mode 100644
index 0000000..bb88144
--- /dev/null
+++ b/clang/test/Driver/objc++-cpp-output.mm
@@ -0,0 +1,8 @@
+// RUN: %clang -x objc++-cpp-output -c %s -o /dev/null
+
+// Should compile without errors
+@protocol P
+- (void)m;
+@end
+void f() {}
+class C {};
diff --git a/clang/test/Driver/objc-cpp-output.m b/clang/test/Driver/objc-cpp-output.m
new file mode 100644
index 0000000..6d97483
--- /dev/null
+++ b/clang/test/Driver/objc-cpp-output.m
@@ -0,0 +1,7 @@
+// RUN: %clang -x objc-cpp-output -c %s -o /dev/null
+
+// Should compile without errors
+@protocol P
+- (void)m;
+@end
+void f() {}
diff --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
new file mode 100644
index 0000000..911c452
--- /dev/null
+++ b/clang/test/Driver/openbsd.c
@@ -0,0 +1,5 @@
+// RUN: %clang -no-canonical-prefixes -ccc-clang-archs "" -target i686-pc-openbsd %s -### 2> %t.log
+// RUN: FileCheck -input-file %t.log %s
+
+// CHECK: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
+// CHECK: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lgcc" "-lc" "-lgcc" "{{.*}}crtend.o"
diff --git a/clang/test/Driver/option-aliases.c b/clang/test/Driver/option-aliases.c
new file mode 100644
index 0000000..38bf4b1
--- /dev/null
+++ b/clang/test/Driver/option-aliases.c
@@ -0,0 +1,11 @@
+// RUN: %clang -ccc-print-options \
+// RUN: --save-temps --undefine-macro=FOO --undefine-macro FOO \
+// RUN: --param=FOO --output=FOO 2> %t
+// RUN: FileCheck --check-prefix=CHECK-OPTIONS < %t %s
+
+// CHECK-OPTIONS: Option 0 - Name: "-ccc-print-options", Values: {}
+// CHECK-OPTIONS: Option 1 - Name: "-save-temps", Values: {}
+// CHECK-OPTIONS: Option 2 - Name: "-U", Values: {"FOO"}
+// CHECK-OPTIONS: Option 3 - Name: "-U", Values: {"FOO"}
+// CHECK-OPTIONS: Option 4 - Name: "--param", Values: {"FOO"}
+// CHECK-OPTIONS: Option 5 - Name: "-o", Values: {"FOO"}
diff --git a/clang/test/Driver/output-file-cleanup.c b/clang/test/Driver/output-file-cleanup.c
new file mode 100644
index 0000000..0a0c960
--- /dev/null
+++ b/clang/test/Driver/output-file-cleanup.c
@@ -0,0 +1,25 @@
+// RUN: touch %t.o
+// RUN: not %clang -DCRASH -o %t.o -MMD -MF %t.d %s
+// RUN: test ! -f %t.o
+// RUN: test ! -f %t.d
+
+// RUN: touch %t.o
+// RUN: not %clang -DMISSING -o %t.o -MMD -MF %t.d %s
+// RUN: test ! -f %t.o
+// RUN: test ! -f %t.d
+
+// RUN: touch %t.o
+// RUN: not %clang -o %t.o -MMD -MF %t.d %s
+// RUN: test ! -f %t.o
+// RUN: test -f %t.d
+
+// REQUIRES: shell
+// REQUIRES: crash-recovery
+
+#ifdef CRASH
+#pragma clang __debug crash
+#elif defined(MISSING)
+#include "nonexistent.h"
+#else
+invalid C code
+#endif
diff --git a/clang/test/Driver/parsing.c b/clang/test/Driver/parsing.c
new file mode 100644
index 0000000..eceba37
--- /dev/null
+++ b/clang/test/Driver/parsing.c
@@ -0,0 +1,22 @@
+// RUN: %clang -ccc-print-options input -Yunknown -m32 -arch ppc -djoined -A separate -Ajoined -Wp,one,two -Xarch_joined AndSeparate -sectalign 1 2 3 2> %t
+// RUN: grep 'Option 0 - Name: "-ccc-print-options", Values: {}' %t
+// RUN: grep 'Option 1 - Name: "<input>", Values: {"input"}' %t
+// RUN: grep 'Option 2 - Name: "<unknown>", Values: {"-Yunknown"}' %t
+// RUN: grep 'Option 3 - Name: "-m32", Values: {}' %t
+// RUN: grep 'Option 4 - Name: "-arch", Values: {"ppc"}' %t
+// RUN: grep 'Option 5 - Name: "-d", Values: {"joined"}' %t
+// RUN: grep 'Option 6 - Name: "-A", Values: {"separate"}' %t
+// RUN: grep 'Option 7 - Name: "-A", Values: {"joined"}' %t
+// RUN: grep 'Option 8 - Name: "-Wp,", Values: {"one", "two"}' %t
+// RUN: grep 'Option 9 - Name: "-Xarch_", Values: {"joined", "AndSeparate"}' %t
+// RUN: grep 'Option 10 - Name: "-sectalign", Values: {"1", "2", "3"}' %t
+
+// RUN: not %clang -V 2> %t
+// RUN: grep "error: argument to '-V' is missing (expected 1 value)" %t
+// RUN: not %clang -sectalign 1 2 2> %t
+// RUN: grep "error: argument to '-sectalign' is missing (expected 3 values)" %t
+
+// Verify that search continues after find the first option.
+// RUN: %clang -ccc-print-options -Wally 2> %t
+// RUN: grep 'Option 0 - Name: "-ccc-print-options", Values: {}' %t
+// RUN: grep 'Option 1 - Name: "-W", Values: {"ally"}' %t
diff --git a/clang/test/Driver/phases.c b/clang/test/Driver/phases.c
new file mode 100644
index 0000000..4c480d5
--- /dev/null
+++ b/clang/test/Driver/phases.c
@@ -0,0 +1,78 @@
+// Basic compilation for various types of files.
+// RUN: %clang -target i386-unknown-unknown -ccc-print-phases -x c %s -x objective-c %s -x c++ %s -x objective-c++ -x assembler %s -x assembler-with-cpp %s -x none %s 2>&1 | FileCheck -check-prefix=BASIC %s
+// BASIC: 0: input, "{{.*}}phases.c", c
+// BASIC: 1: preprocessor, {0}, cpp-output
+// BASIC: 2: compiler, {1}, assembler
+// BASIC: 3: assembler, {2}, object
+// BASIC: 4: input, "{{.*}}phases.c", objective-c
+// BASIC: 5: preprocessor, {4}, objective-c-cpp-output
+// BASIC: 6: compiler, {5}, assembler
+// BASIC: 7: assembler, {6}, object
+// BASIC: 8: input, "{{.*}}phases.c", c++
+// BASIC: 9: preprocessor, {8}, c++-cpp-output
+// BASIC: 10: compiler, {9}, assembler
+// BASIC: 11: assembler, {10}, object
+// BASIC: 12: input, "{{.*}}phases.c", assembler
+// BASIC: 13: assembler, {12}, object
+// BASIC: 14: input, "{{.*}}phases.c", assembler-with-cpp
+// BASIC: 15: preprocessor, {14}, assembler
+// BASIC: 16: assembler, {15}, object
+// BASIC: 17: input, "{{.*}}phases.c", c
+// BASIC: 18: preprocessor, {17}, cpp-output
+// BASIC: 19: compiler, {18}, assembler
+// BASIC: 20: assembler, {19}, object
+// BASIC: 21: linker, {3, 7, 11, 13, 16, 20}, image
+
+// Universal linked image.
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-phases -x c %s -arch ppc -arch i386 2>&1 | FileCheck -check-prefix=ULI %s
+// ULI: 0: input, "{{.*}}phases.c", c
+// ULI: 1: preprocessor, {0}, cpp-output
+// ULI: 2: compiler, {1}, assembler
+// ULI: 3: assembler, {2}, object
+// ULI: 4: linker, {3}, image
+// ULI: 5: bind-arch, "ppc", {4}, image
+// ULI: 6: bind-arch, "i386", {4}, image
+// ULI: 7: lipo, {5, 6}, image
+
+// Universal object file.
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-phases -c -x c %s -arch ppc -arch i386 2>&1 | FileCheck -check-prefix=UOF %s
+// UOF: 0: input, "{{.*}}phases.c", c
+// UOF: 1: preprocessor, {0}, cpp-output
+// UOF: 2: compiler, {1}, assembler
+// UOF: 3: assembler, {2}, object
+// UOF: 4: bind-arch, "ppc", {3}, object
+// UOF: 5: bind-arch, "i386", {3}, object
+// UOF: 6: lipo, {4, 5}, object
+
+// Arch defaulting
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-phases -c -x assembler %s 2>&1 | FileCheck -check-prefix=ARCH1 %s
+// ARCH1: 2: bind-arch, "i386", {1}, object
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-phases -c -x assembler %s -m32 -m64 2>&1 | FileCheck -check-prefix=ARCH2 %s
+// ARCH2: 2: bind-arch, "x86_64", {1}, object
+// RUN: %clang -target x86_64-apple-darwin9 -ccc-print-phases -c -x assembler %s 2>&1 | FileCheck -check-prefix=ARCH3 %s
+// ARCH3: 2: bind-arch, "x86_64", {1}, object
+// RUN: %clang -target x86_64-apple-darwin9 -ccc-print-phases -c -x assembler %s -m64 -m32 2>&1 | FileCheck -check-prefix=ARCH4 %s
+// ARCH4: 2: bind-arch, "i386", {1}, object
+
+// Analyzer
+// RUN: %clang -target i386-unknown-unknown -ccc-print-phases --analyze %s 2>&1 | FileCheck -check-prefix=ANALYZE %s
+// ANALYZE: 0: input, "{{.*}}phases.c", c
+// ANALYZE: 1: preprocessor, {0}, cpp-output
+// ANALYZE: 2: analyzer, {1}, plist
+
+// Precompiler
+// RUN: %clang -target i386-unknown-unknown -ccc-print-phases -x c-header %s 2>&1 | FileCheck -check-prefix=PCH %s
+// PCH: 0: input, "{{.*}}phases.c", c-header
+// PCH: 1: preprocessor, {0}, c-header-cpp-output
+// PCH: 2: precompiler, {1}, precompiled-header
+
+// Darwin overrides the handling for .s
+// RUN: touch %t.s
+// RUN: %clang -target i386-unknown-unknown -ccc-print-phases -c %t.s 2>&1 | FileCheck -check-prefix=DARWIN1 %s
+// DARWIN1: 0: input, "{{.*}}.s", assembler
+// DARWIN1: 1: assembler, {0}, object
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-phases -c %t.s 2>&1 | FileCheck -check-prefix=DARWIN2 %s
+// DARWIN2: 0: input, "{{.*}}.s", assembler-with-cpp
+// DARWIN2: 1: preprocessor, {0}, assembler
+// DARWIN2: 2: assembler, {1}, object
+
diff --git a/clang/test/Driver/pic.c b/clang/test/Driver/pic.c
new file mode 100644
index 0000000..3952f85
--- /dev/null
+++ b/clang/test/Driver/pic.c
@@ -0,0 +1,81 @@
+// Test the driver's control over the PIC behavior. These consist of tests of
+// the relocation model flags and the pic level flags passed to CC1.
+//
+// CHECK-NO-PIC: "-mrelocation-model" "static"
+// CHECK-NO-PIC-NOT: "-pic-level"
+// CHECK-NO-PIC-NOT: "-pie-level"
+//
+// CHECK-DYNAMIC-NO-PIC1: "-mrelocation-model" "dynamic-no-pic"
+// CHECK-DYNAMIC-NO-PIC1: "-pic-level" "1"
+//
+// CHECK-DYNAMIC-NO-PIC2: "-mrelocation-model" "dynamic-no-pic"
+// CHECK-DYNAMIC-NO-PIC2: "-pic-level" "2"
+//
+// CHECK-PIC1-NOT: "-mrelocation-model"
+// CHECK-PIC1: "-pic-level" "1"
+//
+// CHECK-PIC2-NOT: "-mrelocation-model"
+// CHECK-PIC2: "-pic-level" "2"
+//
+// CHECK-PIE1-NOT: "-mrelocation-model"
+// CHECK-PIE1: "-pie-level" "1"
+//
+// CHECK-PIE2-NOT: "-mrelocation-model"
+// CHECK-PIE2: "-pie-level" "2"
+//
+// RUN: %clang -c %s -target i386-unknown-unknown -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fpic -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIC1
+// RUN: %clang -c %s -target i386-unknown-unknown -fPIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target i386-unknown-unknown -fpie -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIE1
+// RUN: %clang -c %s -target i386-unknown-unknown -fPIE -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target i386-unknown-unknown -fpic -fno-pic -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fPIC -fno-PIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fpic -fno-PIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fPIC -fno-pic -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fpie -fno-pie -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fPIE -fno-PIE -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fpie -fno-PIE -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fPIE -fno-pie -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fpie -fno-pic -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fpic -fno-pie -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fpic -fPIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target i386-unknown-unknown -fPIC -fpic -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIC1
+// RUN: %clang -c %s -target i386-unknown-unknown -fpic -fPIE -fpie -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIE1
+// RUN: %clang -c %s -target i386-unknown-unknown -fpie -fPIC -fPIE -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIE2
+//
+// Defaults change for Darwin.
+// RUN: %clang -c %s -target i386-apple-darwin -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target i386-apple-darwin -fno-pic -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-apple-darwin -fno-PIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+//
+// Disregard any of the PIC-specific flags if we have a trump-card flag.
+// RUN: %clang -c %s -target i386-unknown-unknown -mkernel -fPIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -static -fPIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -mdynamic-no-pic -fPIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-DYNAMIC-NO-PIC1
+// RUN: %clang -c %s -target i386-apple-darwin -mdynamic-no-pic -fPIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-DYNAMIC-NO-PIC2
diff --git a/clang/test/Driver/prefixed-tools.c b/clang/test/Driver/prefixed-tools.c
new file mode 100644
index 0000000..d7c342a
--- /dev/null
+++ b/clang/test/Driver/prefixed-tools.c
@@ -0,0 +1,12 @@
+// RUN: %clang -### -B%S/Inputs/prefixed_tools_tree -o %t.o -no-integrated-as \
+// RUN: -target x86_64--linux %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-M64 %s
+
+// RUN: %clang -### -B%S/Inputs/prefixed_tools_tree -o %t.o -no-integrated-as \
+// RUN: -m32 -target x86_64--linux %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-M32 %s
+
+// CHECK-M64: "{{.*}}{{[/\\]}}prefixed_tools_tree{{[/\\]}}x86_64--linux-as"
+// CHECK-M64: "{{.*}}{{[/\\]}}prefixed_tools_tree{{[/\\]}}x86_64--linux-ld"
+// CHECK-M32: "{{.*}}{{[/\\]}}prefixed_tools_tree{{[/\\]}}x86_64--linux-as"
+// CHECK-M32: "{{.*}}{{[/\\]}}prefixed_tools_tree{{[/\\]}}x86_64--linux-ld"
diff --git a/clang/test/Driver/preprocessor.c b/clang/test/Driver/preprocessor.c
new file mode 100644
index 0000000..09c1f6c
--- /dev/null
+++ b/clang/test/Driver/preprocessor.c
@@ -0,0 +1,6 @@
+// RUN: %clang -E -x c-header %s > %t
+// RUN: grep 'B B' %t
+
+#define A B
+A A
+
diff --git a/clang/test/Driver/pth.c b/clang/test/Driver/pth.c
new file mode 100644
index 0000000..4350f46
--- /dev/null
+++ b/clang/test/Driver/pth.c
@@ -0,0 +1,12 @@
+// Test transparent PTH support.
+
+// RUN: %clang -no-canonical-prefixes -ccc-pch-is-pth -x c-header %s -o %t.h.pth -### 2> %t.log
+// RUN: FileCheck -check-prefix CHECK1 -input-file %t.log %s
+
+// CHECK1: "{{.*}}/clang{{.*}}" "-cc1" {{.*}} "-o" "{{.*}}.h.pth" "-x" "c-header" "{{.*}}pth.c"
+
+// RUN: touch %t.h.pth
+// RUN: %clang -no-canonical-prefixes -ccc-pch-is-pth -E -include %t.h %s -### 2> %t.log
+// RUN: FileCheck -check-prefix CHECK2 -input-file %t.log %s
+
+// CHECK2: "{{.*}}/clang{{.*}}" "-cc1" {{.*}}"-include-pth" "{{.*}}.h.pth" {{.*}}"-x" "c" "{{.*}}pth.c"
diff --git a/clang/test/Driver/qa_override.c b/clang/test/Driver/qa_override.c
new file mode 100644
index 0000000..5f96976
--- /dev/null
+++ b/clang/test/Driver/qa_override.c
@@ -0,0 +1,6 @@
+// RUN: env QA_OVERRIDE_GCC3_OPTIONS="#+-Os +-Oz +-O +-O3 +-Oignore +a +b +c xb Xa Omagic ^-ccc-print-options " %clang x -O2 b -O3 2>&1 | FileCheck %s
+// CHECK-NOT: ###
+// CHECK: Option 0 - Name: "-ccc-print-options", Values: {}
+// CHECK-NEXT: Option 1 - Name: "<input>", Values: {"x"}
+// CHECK-NEXT: Option 2 - Name: "-O", Values: {"ignore"}
+// CHECK-NEXT: Option 3 - Name: "-O", Values: {"magic"}
diff --git a/clang/test/Driver/redundant-args.c b/clang/test/Driver/redundant-args.c
new file mode 100644
index 0000000..7bf98e1
--- /dev/null
+++ b/clang/test/Driver/redundant-args.c
@@ -0,0 +1,2 @@
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -Werror -x c -x c -fsyntax-only %s
diff --git a/clang/test/Driver/redzone.c b/clang/test/Driver/redzone.c
new file mode 100644
index 0000000..7d6d424
--- /dev/null
+++ b/clang/test/Driver/redzone.c
@@ -0,0 +1,6 @@
+// RUN: %clang -target i386-unknown-unknown -mno-red-zone %s -S -emit-llvm -o %t.log
+// RUN: grep 'noredzone' %t.log
+// RUN: %clang -target i386-unknown-unknown -mred-zone %s -S -emit-llvm -o %t.log
+// RUN: grep -v 'noredzone' %t.log
+
+int foo() { return 42; }
diff --git a/clang/test/Driver/rewrite-legacy-objc.m b/clang/test/Driver/rewrite-legacy-objc.m
new file mode 100644
index 0000000..af59ff6
--- /dev/null
+++ b/clang/test/Driver/rewrite-legacy-objc.m
@@ -0,0 +1,15 @@
+// RUN: %clang -no-canonical-prefixes -target x86_64-apple-macosx10.7.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
+// RUN: FileCheck -check-prefix=TEST0 %s
+// TEST0: clang{{.*}}" "-cc1"
+// TEST0: "-rewrite-objc"
+// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-fragile-abi" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
+// TEST0: rewrite-legacy-objc.m"
+
+// RUN: not %clang -ccc-no-clang -target unknown -rewrite-legacy-objc %s -o - -### 2>&1 | \
+// RUN: FileCheck -check-prefix=TEST1 %s
+// TEST1: invalid output type 'rewritten-legacy-objc' for use with gcc
+
+// RUN: not %clang -ccc-no-clang -target i386-apple-darwin10 -rewrite-legacy-objc %s -o - -### 2>&1 | \
+// RUN: FileCheck -check-prefix=TEST2 %s
+// TEST2: invalid output type 'rewritten-legacy-objc' for use with gcc
diff --git a/clang/test/Driver/rewrite-objc.m b/clang/test/Driver/rewrite-objc.m
new file mode 100644
index 0000000..7b080fc
--- /dev/null
+++ b/clang/test/Driver/rewrite-objc.m
@@ -0,0 +1,15 @@
+// RUN: %clang -no-canonical-prefixes -target x86_64-apple-macosx10.7.0 -rewrite-objc %s -o - -### 2>&1 | \
+// RUN: FileCheck -check-prefix=TEST0 %s
+// TEST0: clang{{.*}}" "-cc1"
+// TEST0: "-rewrite-objc"
+// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-dispatch-method=mixed" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
+// TEST0: rewrite-objc.m"
+
+// RUN: not %clang -ccc-no-clang -target unknown -rewrite-objc %s -o - -### 2>&1 | \
+// RUN: FileCheck -check-prefix=TEST1 %s
+// TEST1: invalid output type 'rewritten-objc' for use with gcc
+
+// RUN: not %clang -ccc-no-clang -target i386-apple-darwin10 -rewrite-objc %s -o - -### 2>&1 | \
+// RUN: FileCheck -check-prefix=TEST2 %s
+// TEST2: invalid output type 'rewritten-objc' for use with gcc
diff --git a/clang/test/Driver/stackrealign.c b/clang/test/Driver/stackrealign.c
new file mode 100644
index 0000000..c5221d6
--- /dev/null
+++ b/clang/test/Driver/stackrealign.c
@@ -0,0 +1,12 @@
+// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=NORMAL
+// NORMAL-NOT: -force-align-stack
+// NORMAL: -mstackrealign
+
+// RUN: %clang -### -mstackrealign %s 2>&1 | FileCheck %s -check-prefix=MREALIGN
+// MREALIGN: -force-align-stack
+// MREALIGN: -mstackrealign
+
+// RUN: %clang -### -mno-stackrealign %s 2>&1 | \
+// RUN: FileCheck %s -check-prefix=MNOREALIGN
+// MNOREALIGN-NOT: -force-align-stack
+// MNOREALIGN-NOT: -mstackrealign
diff --git a/clang/test/Driver/std.c b/clang/test/Driver/std.c
new file mode 100644
index 0000000..c82e9f1
--- /dev/null
+++ b/clang/test/Driver/std.c
@@ -0,0 +1,8 @@
+// RUN: %clang -std=c99 -trigraphs -std=gnu99 %s -E -o - | FileCheck -check-prefix=OVERRIDE %s
+// OVERRIDE: ??(??)
+// RUN: %clang -ansi %s -E -o - | FileCheck -check-prefix=ANSI %s
+// ANSI: []
+// RUN: %clang -std=gnu99 -trigraphs %s -E -o - | FileCheck -check-prefix=EXPLICIT %s
+// EXPLICIT: []
+
+??(??)
diff --git a/clang/test/Driver/std.cpp b/clang/test/Driver/std.cpp
new file mode 100644
index 0000000..7704c8d
--- /dev/null
+++ b/clang/test/Driver/std.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang -std=c++98 %s -Wno-c++0x-compat -fsyntax-only 2>&1 | FileCheck -check-prefix=CXX98 %s
+// RUN: %clang -std=gnu++98 %s -Wno-c++0x-compat -fsyntax-only 2>&1 | FileCheck -check-prefix=GNUXX98 %s
+// RUN: %clang -std=c++03 %s -Wno-c++0x-compat -fsyntax-only 2>&1 | FileCheck -check-prefix=CXX98 %s
+// RUN: %clang -std=c++0x %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CXX11 %s
+// RUN: %clang -std=gnu++0x %s -fsyntax-only 2>&1 | FileCheck -check-prefix=GNUXX11 %s
+// RUN: %clang -std=c++11 %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CXX11 %s
+// RUN: %clang -std=gnu++11 %s -fsyntax-only 2>&1 | FileCheck -check-prefix=GNUXX11 %s
+
+void f(int n) {
+ typeof(n)();
+ decltype(n)();
+}
+
+// CXX98: undeclared identifier 'typeof'
+// CXX98: undeclared identifier 'decltype'
+
+// GNUXX98-NOT: undeclared identifier 'typeof'
+// GNUXX98: undeclared identifier 'decltype'
+
+// CXX11: undeclared identifier 'typeof'
+// CXX11-NOT: undeclared identifier 'decltype'
+
+// GNUXX11-NOT: undeclared identifier 'typeof'
+// GNUXX11-NOT: undeclared identifier 'decltype'
diff --git a/clang/test/Driver/sysroot-flags.c b/clang/test/Driver/sysroot-flags.c
new file mode 100644
index 0000000..b0a10bf
--- /dev/null
+++ b/clang/test/Driver/sysroot-flags.c
@@ -0,0 +1,28 @@
+// Check for proper handling of --sysroot and -isysroot flags.
+
+// RUN: %clang -### -fsyntax-only -isysroot /foo/bar %s 2>&1 | \
+// RUN: FileCheck %s -check-prefix=ISYSROOT
+// ISYSROOT: "-isysroot" "{{[^"]*}}/foo/bar"
+
+// Check that we get both isysroot for headers, and pass --sysroot on to GCC to
+// produce the final binary.
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
+// RUN: --sysroot=/foo/bar -o /dev/null %s 2>&1 | \
+// RUN: FileCheck %s -check-prefix=SYSROOT_EQ
+// SYSROOT_EQ: "-isysroot" "{{[^"]*}}/foo/bar"
+// SYSROOT_EQ: "--sysroot{{" "|=}}{{[^"]*}}/foo/bar"
+
+// Check for overriding the header sysroot by providing both --sysroot and
+// -isysroot.
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -isysroot /baz \
+// RUN: --sysroot=/foo/bar -o /dev/null %s 2>&1 | FileCheck %s \
+// RUN: -check-prefix=ISYSROOT_AND_SYSROOT
+// ISYSROOT_AND_SYSROOT: "-isysroot" "{{[^"]*}}/baz"
+// ISYSROOT_AND_SYSROOT: "--sysroot{{" "|=}}{{[^"]*}}/foo/bar"
+
+// Check that omitting the equals works as well.
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
+// RUN: --sysroot /foo/bar -o /dev/null %s 2>&1 | \
+// RUN: FileCheck %s -check-prefix=SYSROOT_SEPARATE
+// SYSROOT_SEPARATE: "-isysroot" "{{[^"]*}}/foo/bar"
+// SYSROOT_SEPARATE: "--sysroot{{" "|=}}{{[^"]*}}/foo/bar"
diff --git a/clang/test/Driver/sysroot.c b/clang/test/Driver/sysroot.c
new file mode 100644
index 0000000..3080f76
--- /dev/null
+++ b/clang/test/Driver/sysroot.c
@@ -0,0 +1,18 @@
+// Check that --sysroot= also applies to header search paths.
+// RUN: %clang -target i386-unk-unk --sysroot=/FOO -### -E %s 2> %t1
+// RUN: FileCheck --check-prefix=CHECK-SYSROOTEQ < %t1 %s
+// CHECK-SYSROOTEQ: "-cc1"{{.*}} "-isysroot" "{{[^"]*}}/FOO"
+
+// Apple Darwin uses -isysroot as the syslib root, too.
+// RUN: touch %t2.o
+// RUN: %clang -target i386-apple-darwin10 \
+// RUN: -isysroot /FOO -### %t2.o 2> %t2
+// RUN: FileCheck --check-prefix=CHECK-APPLE-ISYSROOT < %t2 %s
+// CHECK-APPLE-ISYSROOT: "-arch" "i386"{{.*}} "-syslibroot" "{{[^"]*}}/FOO"
+
+// Check that honor --sysroot= over -isysroot, for Apple Darwin.
+// RUN: touch %t3.o
+// RUN: %clang -target i386-apple-darwin10 \
+// RUN: -isysroot /FOO --sysroot=/BAR -### %t3.o 2> %t3
+// RUN: FileCheck --check-prefix=CHECK-APPLE-SYSROOT < %t3 %s
+// CHECK-APPLE-SYSROOT: "-arch" "i386"{{.*}} "-syslibroot" "{{[^"]*}}/BAR"
diff --git a/clang/test/Driver/target.c b/clang/test/Driver/target.c
new file mode 100644
index 0000000..59147e0
--- /dev/null
+++ b/clang/test/Driver/target.c
@@ -0,0 +1,11 @@
+// RUN: %clang -no-canonical-prefixes -target unknown-unknown-unknown -c %s \
+// RUN: -o %t.o -### 2>&1 | FileCheck %s
+//
+// Ensure we get a crazy triple here as we asked for one.
+// CHECK: Target: unknown-unknown-unknown
+//
+// Also, ensure we don't blindly hand our target selection logic down to GCC.
+// CHECK: "{{.*gcc(\.[Ee][Xx][Ee])?}}"
+// CHECK-NOT: "-target"
+// CHECK-NOT: "unknown-unknown-unknown"
+// CHECK: "-x" "assembler"
diff --git a/clang/test/Driver/tsan.c b/clang/test/Driver/tsan.c
new file mode 100644
index 0000000..1dadb8e
--- /dev/null
+++ b/clang/test/Driver/tsan.c
@@ -0,0 +1,8 @@
+// RUN: %clang -target i386-unknown-unknown -fthread-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O1 -target i386-unknown-unknown -fthread-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O2 -target i386-unknown-unknown -fthread-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O3 -target i386-unknown-unknown -fthread-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// Verify that -fthread-sanitizer invokes tsan instrumentation.
+
+int foo(int *a) { return *a; }
+// CHECK: __tsan_init
diff --git a/clang/test/Driver/unknown-arg.c b/clang/test/Driver/unknown-arg.c
new file mode 100644
index 0000000..5d0f7af
--- /dev/null
+++ b/clang/test/Driver/unknown-arg.c
@@ -0,0 +1,4 @@
+// RUN: not %clang_cc1 %s -cake-is-lie 2> %t.log
+// RUN: FileCheck %s -input-file=%t.log
+
+// CHECK: unknown argument
diff --git a/clang/test/Driver/unknown-gcc-arch.c b/clang/test/Driver/unknown-gcc-arch.c
new file mode 100644
index 0000000..5e4746b
--- /dev/null
+++ b/clang/test/Driver/unknown-gcc-arch.c
@@ -0,0 +1,8 @@
+// RUN: %clang -target x86_64-unknown-unknown -c -x assembler %s -### 2> %t.log
+// RUN: grep '.*gcc.*"-m64"' %t.log
+// RUN: %clang -target x86_64-unknown-unknown -c -x assembler %s -### -m32 2> %t.log
+// RUN: grep '.*gcc.*"-m32"' %t.log
+// RUN: %clang -target i386-unknown-unknown -c -x assembler %s -### 2> %t.log
+// RUN: grep '.*gcc.*"-m32"' %t.log
+// RUN: %clang -target i386-unknown-unknown -c -x assembler %s -### -m64 2> %t.log
+// RUN: grep '.*gcc.*"-m64"' %t.log
diff --git a/clang/test/Driver/working-directory.c b/clang/test/Driver/working-directory.c
new file mode 100644
index 0000000..38a87a6
--- /dev/null
+++ b/clang/test/Driver/working-directory.c
@@ -0,0 +1,4 @@
+// RUN: %clang -ccc-print-options -working-directory "C:\Test" input 2>&1 | FileCheck %s
+// CHECK: Option 0 - Name: "-ccc-print-options", Values: {}
+// CHECK: Option 1 - Name: "-working-directory", Values: {"C:\Test"}
+// CHECK: Option 2 - Name: "<input>", Values: {"input"}
diff --git a/clang/test/Driver/x86_features.c b/clang/test/Driver/x86_features.c
new file mode 100644
index 0000000..5c65e31
--- /dev/null
+++ b/clang/test/Driver/x86_features.c
@@ -0,0 +1,3 @@
+// RUN: %clang -target i386-unknown-unknown -### -S %s -msse -msse4 -mno-sse -mno-mmx -msse 2> %t
+// RUN: grep '"pentium4" "-target-feature" "+sse4" "-target-feature" "-mmx" "-target-feature" "+sse"' %t
+// Note that we filter out all but the last -m(no)sse.
diff --git a/clang/test/FixIt/atomic-property.m b/clang/test/FixIt/atomic-property.m
new file mode 100644
index 0000000..9ede7f1
--- /dev/null
+++ b/clang/test/FixIt/atomic-property.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c -fobjc-arc %s 2>&1 | FileCheck %s
+
+@interface I
+@property id prop;
+@property (atomic) id atomic_prop;
+- (id) prop;
+- (id) atomic_prop;
+
+@property ( ) id prop1;
+
+@property (copy, atomic, readwrite) id atomic_prop1;
+
+@property (copy, readwrite) id prop2;
+@end
+
+@implementation I
+@synthesize prop, prop1, prop2;
+@synthesize atomic_prop, atomic_prop1;
+- (id) prop { return 0; }
+- (id) prop1 { return 0; }
+- (id) prop2 { return 0; }
+- (id) atomic_prop { return 0; }
+- (id) atomic_prop1 { return 0; }
+@end
+
+// CHECK: {4:1-4:10}:"@property (nonatomic) "
+// CHECK: {9:1-9:12}:"@property (nonatomic"
+// CHECK: {13:1-13:12}:"@property (nonatomic, "
+
diff --git a/clang/test/FixIt/auto-fixit.m b/clang/test/FixIt/auto-fixit.m
new file mode 100644
index 0000000..d09f04c
--- /dev/null
+++ b/clang/test/FixIt/auto-fixit.m
@@ -0,0 +1,11 @@
+/* RUN: cp %s %t
+ RUN: %clang_cc1 -x objective-c -fixit %t
+ RUN: %clang_cc1 -x objective-c -Werror %t
+ */
+
+// rdar://9036633
+
+int main() {
+ auto int i = 0;
+ return i;
+}
diff --git a/clang/test/FixIt/dereference-addressof.c b/clang/test/FixIt/dereference-addressof.c
new file mode 100644
index 0000000..950fadc
--- /dev/null
+++ b/clang/test/FixIt/dereference-addressof.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -fsyntax-only -fixit -x c %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -x c %t
+
+void ip(int *aPtr) {} // expected-note{{passing argument to parameter 'aPtr' here}}
+void i(int a) {} // expected-note{{passing argument to parameter 'a' here}}
+void ii(int a) {} // expected-note{{passing argument to parameter 'a' here}}
+void fp(float *aPtr) {} // expected-note{{passing argument to parameter 'aPtr' here}}
+void f(float a) {} // expected-note{{passing argument to parameter 'a' here}}
+
+void f2(int *aPtr, int a, float *bPtr, char c) {
+ float fl = 0;
+ ip(a); // expected-warning{{incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'; take the address with &}}
+ i(aPtr); // expected-warning{{incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; dereference with *}}
+ ii(&a); // expected-warning{{incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; remove &}}
+ fp(*bPtr); // expected-error{{passing 'float' to parameter of incompatible type 'float *'; remove *}}
+ f(bPtr); // expected-error{{passing 'float *' to parameter of incompatible type 'float'; dereference with *}}
+ a = aPtr; // expected-warning{{incompatible pointer to integer conversion assigning to 'int' from 'int *'; dereference with *}}
+ fl = bPtr + a; // expected-error{{assigning to 'float' from incompatible type 'float *'; dereference with *}}
+ bPtr = bPtr[a]; // expected-error{{assigning to 'float *' from incompatible type 'float'; take the address with &}}
+}
diff --git a/clang/test/FixIt/fixit-c90.c b/clang/test/FixIt/fixit-c90.c
new file mode 100644
index 0000000..0bc1fad
--- /dev/null
+++ b/clang/test/FixIt/fixit-c90.c
@@ -0,0 +1,17 @@
+/* RUN: cp %s %t
+ RUN: %clang_cc1 -std=c90 -pedantic -fixit %t
+ RUN: %clang_cc1 -pedantic -x c -std=c90 -Werror %t
+ */
+/* XPASS: *
+ This test passes because clang merely warns for this syntax error even with
+ -pedantic -Werror -std=c90.
+ */
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+enum e0 {
+ e1,
+};
diff --git a/clang/test/FixIt/fixit-cxx0x.cpp b/clang/test/FixIt/fixit-cxx0x.cpp
new file mode 100644
index 0000000..b6cc2c0
--- /dev/null
+++ b/clang/test/FixIt/fixit-cxx0x.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -x c++ -std=c++11 -fixit %t
+// RUN: %clang_cc1 -Wall -pedantic -x c++ -std=c++11 %t
+
+/* This is a test of the various code modification hints that only
+ apply in C++0x. */
+struct A {
+ explicit operator int(); // expected-note{{conversion to integral type}}
+};
+
+void x() {
+ switch(A()) { // expected-error{{explicit conversion to}}
+ }
+}
+
+using ::T = void; // expected-error {{name defined in alias declaration must be an identifier}}
+using typename U = void; // expected-error {{name defined in alias declaration must be an identifier}}
+using typename ::V = void; // expected-error {{name defined in alias declaration must be an identifier}}
+
+namespace SemiCommaTypo {
+ int m {},
+ n [[]], // expected-error {{expected ';' at end of declaration}}
+ int o;
+
+ struct Base {
+ virtual void f2(), f3();
+ };
+ struct MemberDeclarator : Base {
+ int k : 4,
+ //[[]] : 1, FIXME: test this once we support attributes here
+ : 9, // expected-error {{expected ';' at end of declaration}}
+ char c, // expected-error {{expected ';' at end of declaration}}
+ typedef void F(), // expected-error {{expected ';' at end of declaration}}
+ F f1,
+ f2 final,
+ f3 override, // expected-error {{expected ';' at end of declaration}}
+ };
+}
+
+namespace ScopedEnum {
+ enum class E { a };
+
+ enum class E b = E::a; // expected-error {{must use 'enum' not 'enum class'}}
+ struct S {
+ friend enum class E; // expected-error {{must use 'enum' not 'enum class'}}
+ };
+}
+
+struct S2 {
+ void f(int i);
+ void g(int i);
+};
+
+void S2::f(int i) {
+ (void)[&, &i, &i]{}; // expected-error 2{{'&' cannot precede a capture when the capture default is '&'}}
+ (void)[=, this]{ this->g(5); }; // expected-error{{'this' cannot be explicitly captured}}
+ (void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
+ (void)[&, i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
+ (void)[] mutable { }; // expected-error{{lambda requires '()' before 'mutable'}}
+ (void)[] -> int { }; // expected-error{{lambda requires '()' before return type}}
+}
+
+#define bar "bar"
+const char *p = "foo"bar; // expected-error {{requires a space between}}
+#define ord - '0'
+int k = '4'ord; // expected-error {{requires a space between}}
+
+void operator""_x(char); // expected-error {{requires a space}}
+void operator"x" _y(char); // expected-error {{must be '""'}}
+void operator L"" _z(char); // expected-error {{encoding prefix}}
+void operator "x" "y" U"z" ""_whoops "z" "y"(char); // expected-error {{must be '""'}}
+
+void f() {
+ 'a'_x;
+ 'b'_y;
+ 'c'_z;
+ 'd'_whoops;
+}
+
+template<typename ...Ts> struct MisplacedEllipsis {
+ int a(Ts ...(x)); // expected-error {{'...' must immediately precede declared identifier}}
+ int b(Ts ...&x); // expected-error {{'...' must immediately precede declared identifier}}
+ int c(Ts ...&); // expected-error {{'...' must be innermost component of anonymous pack declaration}}
+ int d(Ts ...(...&...)); // expected-error 2{{'...' must be innermost component of anonymous pack declaration}}
+ int e(Ts ...*[]); // expected-error {{'...' must be innermost component of anonymous pack declaration}}
+ int f(Ts ...(...*)()); // expected-error 2{{'...' must be innermost component of anonymous pack declaration}}
+ int g(Ts ...()); // ok
+};
+namespace TestMisplacedEllipsisRecovery {
+ MisplacedEllipsis<int, char> me;
+ int i; char k;
+ int *ip; char *kp;
+ int ifn(); char kfn();
+ int a = me.a(i, k);
+ int b = me.b(i, k);
+ int c = me.c(i, k);
+ int d = me.d(i, k);
+ int e = me.e(&ip, &kp);
+ int f = me.f(ifn, kfn);
+ int g = me.g(ifn, kfn);
+}
+
+template<template<typename> ...Foo, // expected-error {{template template parameter requires 'class' after the parameter list}}
+ template<template<template<typename>>>> // expected-error 3 {{template template parameter requires 'class' after the parameter list}}
+void func();
+
+template<int *ip> struct IP { }; // expected-note{{declared here}}
+IP<0> ip0; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}}
+
diff --git a/clang/test/FixIt/fixit-cxx11-compat.cpp b/clang/test/FixIt/fixit-cxx11-compat.cpp
new file mode 100644
index 0000000..39ae439
--- /dev/null
+++ b/clang/test/FixIt/fixit-cxx11-compat.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -Wc++11-compat -verify -std=c++98 %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -Wc++11-compat -Werror -x c++ -std=c++98 -fixit %t
+// RUN: %clang_cc1 -Wall -pedantic-errors -Wc++11-compat -Werror -x c++ -std=c++98 %t
+
+// This is a test of the code modification hints for C++11-compatibility problems.
+
+#define bar "bar"
+const char *p = "foo"bar; // expected-warning {{will be treated as a reserved user-defined literal suffix}}
+#define _bar "_bar"
+const char *q = "foo"_bar; // expected-warning {{will be treated as a user-defined literal suffix}}
diff --git a/clang/test/FixIt/fixit-errors-1.c b/clang/test/FixIt/fixit-errors-1.c
new file mode 100644
index 0000000..96f27eb
--- /dev/null
+++ b/clang/test/FixIt/fixit-errors-1.c
@@ -0,0 +1,16 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -pedantic -fixit %t
+// RUN: echo %clang_cc1 -pedantic -Werror -x c %t
+/* XPASS: * */
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+// FIXME: If you put a space at the end of the line, it doesn't work yet!
+char *s = "hi\
+there";
+
+// The following line isn't terminated, don't fix it.
+int i; // expected-error{{no newline at end of file}}
diff --git a/clang/test/FixIt/fixit-errors.c b/clang/test/FixIt/fixit-errors.c
new file mode 100644
index 0000000..356e862
--- /dev/null
+++ b/clang/test/FixIt/fixit-errors.c
@@ -0,0 +1,23 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -pedantic -verify -fixit -x c %t
+// RUN: %clang_cc1 -pedantic -Werror -x c %t
+// XFAIL: *
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+struct s; // expected-note{{previous use is here}}
+
+union s *s1; // expected-error{{use of 's' with tag type that does not match previous declaration}}
+
+struct Point {
+ float x, y, z;
+};
+
+struct Point *get_origin();
+
+void test_point() {
+ (void)get_origin->x;
+}
diff --git a/clang/test/FixIt/fixit-function-call.cpp b/clang/test/FixIt/fixit-function-call.cpp
new file mode 100644
index 0000000..273e4a4
--- /dev/null
+++ b/clang/test/FixIt/fixit-function-call.cpp
@@ -0,0 +1,118 @@
+// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2> %t
+// RUN: FileCheck %s < %t
+// PR5941
+// END.
+
+/* Test fixits for * and & mismatch in function arguments.
+ * Since fixits are on the notes, they cannot be applied automatically. */
+
+typedef int intTy;
+typedef int intTy2;
+
+void f0(int *a);
+void f1(double *a);
+void f1(intTy &a);
+
+void f2(intTy2 *a) {
+// CHECK: error: no matching function for call to 'f1
+// CHECK: dereference the argument with *
+// CHECK: void f1(intTy &a);
+// CHECK: fix-it{{.*}}*(
+// CHECK-NEXT: fix-it{{.*}})
+// CHECK: void f1(double *a);
+ f1(a + 1);
+
+// This call cannot be fixed since without resulting in null pointer dereference.
+// CHECK: error: no matching function for call to 'f1
+// CHECK-NOT: dereference the argument with *
+// CHECK-NOT: fix-it
+ f1((int *)0);
+}
+
+void f3(int &a) {
+// CHECK: error: no matching function for call to 'f0
+// CHECK: fix-it{{.*}}&
+ f0(a);
+}
+
+
+void m(int *a, const int *b); // match 2
+void m(double *a, int *b); // no match
+void m(int *a, double *b); // no match
+void m(intTy &a, int *b); // match 1
+
+void mcaller(intTy2 a, int b) {
+// CHECK: error: no matching function for call to 'm
+// CHECK: take the address of the argument with &
+// CHECK: fix-it{{.*}}&
+// CHECK: take the address of the argument with &
+// CHECK: fix-it{{.*}}&
+// CHECK: fix-it{{.*}}&
+ m(a, b);
+
+// This call cannot be fixed because (a + 1) is not an l-value.
+// CHECK: error: no matching function for call to 'm
+// CHECK-NOT: fix-it
+ m(a + 1, b);
+}
+
+// Test derived to base conversions.
+struct A {
+ int xx;
+};
+
+struct B : public A {
+ double y;
+};
+
+class C : A {};
+
+bool br(A &a);
+bool bp(A *a);
+bool dv(B b);
+
+void u(int x);
+void u(const C *x);
+void u(double x);
+
+void dbcaller(A *ptra, B *ptrb, C &c, B &refb) {
+ B b;
+
+// CHECK: error: no matching function for call to 'br
+// CHECK: fix-it{{.*}}*
+ br(ptrb); // good
+
+// CHECK: error: no matching function for call to 'bp
+// CHECK: fix-it{{.*}}&
+ bp(b); // good
+
+// CHECK: error: no matching function for call to 'dv
+// CHECK-NOT: fix-it
+ dv(ptra); // bad: base to derived
+
+// CHECK: error: no matching function for call to 'dv
+// CHECK: remove &
+ dv(&b);
+
+// CHECK: error: no matching function for call to 'bp
+// CHECK: remove *
+ bp(*ptra);
+
+// CHECK: error: no viable overloaded '='
+// CHECK: remove &
+ b = &refb;
+
+// TODO: Test that we do not provide a fixit when inheritance is private.
+// CHECK: error: no matching function for call to 'bp
+// There should not be a fixit here:
+// CHECK: fix-it
+ bp(c);
+
+// CHECK: no matching function for call to 'u'
+// CHECK: candidate function not viable: no known conversion from 'C' to 'const C *' for 1st argument; take the address of the argument with &
+// CHECK: candidate function not viable
+// CHECK: candidate function not viable
+ u(c);
+}
+
+// CHECK: errors generated
diff --git a/clang/test/FixIt/fixit-missing-method-return-type.m b/clang/test/FixIt/fixit-missing-method-return-type.m
new file mode 100644
index 0000000..769fbe8
--- /dev/null
+++ b/clang/test/FixIt/fixit-missing-method-return-type.m
@@ -0,0 +1,24 @@
+// Objective-C recovery
+// RUN: cp %s %t
+// RUN: %clang_cc1 -Wmissing-method-return-type -fixit -x objective-c -Wno-objc-root-class %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wmissing-method-return-type -Werror -x objective-c -Wno-objc-root-class %t
+
+// Objective-C++ recovery
+// RUN: cp %s %t
+// RUN: %clang_cc1 -Wmissing-method-return-type -fixit -x objective-c++ -Wno-objc-root-class %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wmissing-method-return-type -Werror -x objective-c++ -Wno-objc-root-class %t
+// rdar://9615045
+
+@interface I
+- initWithFoo:(id)foo; // expected-warning {{method has no return type specified; defaults to 'id' [-Wmissing-method-return-type]}}
+- Meth;
+-Meth1;
+@end
+
+@implementation I
+- initWithFoo:(id)foo { return 0; } // expected-warning {{method has no return type specified; defaults to 'id' [-Wmissing-method-return-type]}}
+
+-Meth { return 0;}
+- Meth1 { return 0;}
+@end
+
diff --git a/clang/test/FixIt/fixit-objc-message.m b/clang/test/FixIt/fixit-objc-message.m
new file mode 100644
index 0000000..a3680e4
--- /dev/null
+++ b/clang/test/FixIt/fixit-objc-message.m
@@ -0,0 +1,38 @@
+// Objective-C recovery
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -pedantic -Wall -fixit -x objective-c %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -x objective-c %t
+
+// Objective-C++ recovery
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -pedantic -Wall -fixit -x objective-c++ %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -x objective-c++ %t
+
+@interface A
+- (int)method1:(int)x second:(float)y;
++ (int)method2:(int)x second:(double)y;
+- (int)getBlah;
+@end
+
+void f(A *a, int i, int j) {
+ a method1:5+2 second:+(3.14159)];
+ a method1:[a method1:3 second:j] second:i++]
+ a getBlah];
+
+ int array[17];
+ (void)array[a method1:5+2 second:+(3.14159)]];
+ (A method2:5+2 second:3.14159]);
+ A method2:5+2 second:3.14159]
+ if (A method2:5+2 second:3.14159]) { }
+}
+
+@interface B : A
+- (int)method1:(int)x second:(float)y;
+@end
+
+@implementation B
+- (int)method1:(int)x second:(float)y {
+ super method1:x second:y];
+ return super getBlah];
+}
+@end
diff --git a/clang/test/FixIt/fixit-objc.m b/clang/test/FixIt/fixit-objc.m
new file mode 100644
index 0000000..df591c7
--- /dev/null
+++ b/clang/test/FixIt/fixit-objc.m
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -pedantic -verify %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -pedantic -fixit -x objective-c %t
+// RUN: %clang_cc1 -pedantic -Werror -x objective-c %t
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+@protocol X;
+
+void foo() {
+ <X> *P; // expected-warning{{protocol qualifiers without 'id' is archaic}}
+}
+
+@class A;
+@class NSString;
+
+@interface Test
+- (void)test:(NSString *)string; // expected-note{{passing argument to parameter 'string' here}}
+
+@property (copy) NSString *property;
+@end
+
+void g(NSString *a); // expected-note{{passing argument to parameter 'a' here}}
+void h(id a); // expected-note 2{{passing argument to parameter 'a' here}}
+
+void f(Test *t) {
+ NSString *a = "Foo"; // expected-warning {{incompatible pointer types initializing 'NSString *' with an expression of type 'char [4]'}}
+ id b = "Foo"; // expected-warning {{incompatible pointer types initializing 'id' with an expression of type 'char [4]'}}
+ g("Foo"); // expected-warning{{incompatible pointer types passing 'char [4]' to parameter of type 'NSString *'}}
+ h("Foo"); // expected-warning{{incompatible pointer types passing 'char [4]' to parameter of type 'id'}}
+ h(("Foo")); // expected-warning{{incompatible pointer types passing 'char [4]' to parameter of type 'id'}}
+ [t test:"Foo"]; // expected-warning{{incompatible pointer types sending 'char [4]' to parameter of type 'NSString *'}}
+ t.property = "Foo"; // expected-warning{{incompatible pointer types assigning to 'NSString *' from 'char [4]'}}
+
+ // <rdar://problem/6896493>
+ [t test:@"Foo"]]; // expected-error{{extraneous ']' before ';'}}
+ g(@"Foo")); // expected-error{{extraneous ')' before ';'}}
+}
+
+// rdar://7861841
+@interface Radar7861841 {
+@public
+ int x;
+}
+
+@property (assign) int y;
+@end
+
+int f0(Radar7861841 *a) { return a.x; } // expected-error {{property 'x' not found on object of type 'Radar7861841 *'; did you mean to access ivar 'x'}}
+
+int f1(Radar7861841 *a) { return a->y; } // expected-error {{property 'y' found on object of type 'Radar7861841 *'; did you mean to access it with the "." operator?}}
+
+
+#define nil ((void*)0)
+#define NULL ((void*)0)
+
+void sentinel(int x, ...) __attribute__((sentinel)); // expected-note{{function has been explicitly marked sentinel here}}
+
+@interface Sentinel
+- (void)sentinel:(int)x, ... __attribute__((sentinel)); // expected-note{{method has been explicitly marked sentinel here}}
+@end
+
+void sentinel_test(Sentinel *a) {
+ sentinel(1, 2, 3); // expected-warning{{missing sentinel in function call}}
+ [a sentinel:1, 2, 3]; // expected-warning{{missing sentinel in method dispatch}}
+}
diff --git a/clang/test/FixIt/fixit-pmem.cpp b/clang/test/FixIt/fixit-pmem.cpp
new file mode 100644
index 0000000..b69eadf
--- /dev/null
+++ b/clang/test/FixIt/fixit-pmem.cpp
@@ -0,0 +1,26 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -pedantic -fixit -x c++ %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ %t
+// XFAIL: *
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+struct S {
+ int i;
+};
+
+int foo(int S::* ps, S s, S* p)
+{
+ p.*ps = 1;
+ return s->*ps;
+}
+
+void foo1(int (S::*ps)(), S s, S* p)
+{
+ (p.*ps)();
+ (s->*ps)();
+}
+
diff --git a/clang/test/FixIt/fixit-recompile.c b/clang/test/FixIt/fixit-recompile.c
new file mode 100644
index 0000000..a2e62fb
--- /dev/null
+++ b/clang/test/FixIt/fixit-recompile.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -Werror -pedantic %s -fixit-recompile -fixit-to-temporary -E -o - | FileCheck %s
+// RUN: not %clang_cc1 -Werror -pedantic %s -fixit-recompile -fixit-to-temporary -fix-only-warnings
+
+_Complex cd;
+
+// CHECK: _Complex double cd;
diff --git a/clang/test/FixIt/fixit-recursive-block.c b/clang/test/FixIt/fixit-recursive-block.c
new file mode 100644
index 0000000..b276b41
--- /dev/null
+++ b/clang/test/FixIt/fixit-recursive-block.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wuninitialized -fblocks -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wuninitialized -fblocks -verify %s
+
+// rdar://10817031
+
+int main() {
+ void (^arc_fail)() = ^() { // expected-warning {{block pointer variable 'arc_fail' is uninitialized when captured by block}} \
+ // expected-note {{maybe you meant to use __block 'arc_fail'}}
+ arc_fail(); // BOOM
+ };
+}
+// CHECK: {7:12-7:12}:"__block "
diff --git a/clang/test/FixIt/fixit-static-object-decl.m b/clang/test/FixIt/fixit-static-object-decl.m
new file mode 100644
index 0000000..e13900f
--- /dev/null
+++ b/clang/test/FixIt/fixit-static-object-decl.m
@@ -0,0 +1,29 @@
+// Objective-C recovery
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -fixit -x objective-c %t
+// RUN: %clang_cc1 -fsyntax-only -Werror -x objective-c %t
+
+// Objective-C++ recovery
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -fixit -x objective-c++ %t
+// RUN: %clang_cc1 -fsyntax-only -Werror -x objective-c++ %t
+// rdar://9603056
+
+@interface S @end
+
+@interface NSArray
+{
+@public
+ S iS;
+}
++ (id) arrayWithObjects;
+@end
+
+NSArray func() {
+ NSArray P;
+ return P;
+}
+
+int main() {
+ NSArray pluginNames = [NSArray arrayWithObjects];
+}
diff --git a/clang/test/FixIt/fixit-suffix.c b/clang/test/FixIt/fixit-suffix.c
new file mode 100644
index 0000000..a1a747a
--- /dev/null
+++ b/clang/test/FixIt/fixit-suffix.c
@@ -0,0 +1,5 @@
+// RUN: cp %s %t.extrasuffix
+// RUN: %clang_cc1 -fixit=fixed -x c %t.extrasuffix
+// RUN: %clang_cc1 -Werror -pedantic -x c %t.fixed.extrasuffix
+
+_Complex cd;
diff --git a/clang/test/FixIt/fixit-unrecoverable.c b/clang/test/FixIt/fixit-unrecoverable.c
new file mode 100644
index 0000000..fb6c4e2
--- /dev/null
+++ b/clang/test/FixIt/fixit-unrecoverable.c
@@ -0,0 +1,8 @@
+/* FIXME: This is a file containing various typos for which we can
+ suggest corrections but are unable to actually recover from
+ them. Ideally, we would eliminate all such cases and move these
+ tests elsewhere. */
+
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+unsinged x = 17; // expected-error{{unknown type name 'unsinged'; did you mean 'unsigned'?}}
diff --git a/clang/test/FixIt/fixit-unrecoverable.cpp b/clang/test/FixIt/fixit-unrecoverable.cpp
new file mode 100644
index 0000000..1e1f1b8
--- /dev/null
+++ b/clang/test/FixIt/fixit-unrecoverable.cpp
@@ -0,0 +1,12 @@
+/* FIXME: This is a file containing various typos for which we can
+ suggest corrections but are unable to actually recover from
+ them. Ideally, we would eliminate all such cases and move these
+ tests elsewhere. */
+
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+float f(int y) {
+ return static_cst<float>(y); // expected-error{{use of undeclared identifier 'static_cst'; did you mean 'static_cast'?}} \
+ // expected-error{{for function-style cast or type construction}}
+}
+
diff --git a/clang/test/FixIt/fixit-vexing-parse-cxx0x.cpp b/clang/test/FixIt/fixit-vexing-parse-cxx0x.cpp
new file mode 100644
index 0000000..a870794
--- /dev/null
+++ b/clang/test/FixIt/fixit-vexing-parse-cxx0x.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -x c++ -std=c++11 %s
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -x c++ -std=c++11 %s 2>&1 | FileCheck %s
+
+struct X {
+ int i;
+};
+
+void func() {
+ // CHECK: fix-it:"{{.*}}":{10:6-10:8}:"{}"
+ X x(); // expected-warning {{function declaration}} expected-note{{replace parentheses with an initializer}}
+
+ typedef int *Ptr;
+ // CHECK: fix-it:"{{.*}}":{14:8-14:10}:" = nullptr"
+ Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{17:15-17:17}:" = u'\\0'"
+ char16_t u16(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{20:15-20:17}:" = U'\\0'"
+ char32_t u32(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+}
diff --git a/clang/test/FixIt/fixit-vexing-parse.cpp b/clang/test/FixIt/fixit-vexing-parse.cpp
new file mode 100644
index 0000000..8450590
--- /dev/null
+++ b/clang/test/FixIt/fixit-vexing-parse.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -verify -x c++ %s
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s
+
+struct S {
+ int n;
+};
+
+struct T {
+ T();
+ int n;
+};
+
+struct U {
+ ~U();
+ int n;
+};
+
+struct V {
+ ~V();
+};
+
+struct W : V {
+};
+
+struct X : U {
+};
+
+int F1();
+S F2();
+
+namespace N {
+ void test() {
+ // CHECK: fix-it:"{{.*}}":{34:9-34:11}:" = {}"
+ S s1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{38:9-38:10}:";"
+ // CHECK: fix-it:"{{.*}}":{39:7-39:9}:" = {}"
+ S s2, // expected-note {{change this ',' to a ';' to call 'F2'}}
+ F2(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{43:9-43:11}:""
+ // CHECK: fix-it:"{{.*}}":{44:9-44:11}:""
+ T t1(), // expected-warning {{function declaration}} expected-note {{remove parentheses}}
+ t2(); // expected-warning {{function declaration}} expected-note {{remove parentheses}}
+
+ // CHECK: fix-it:"{{.*}}":{47:8-47:10}:" = {}"
+ U u(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{50:8-50:10}:""
+ V v(); // expected-warning {{function declaration}} expected-note {{remove parentheses}}
+
+ // CHECK: fix-it:"{{.*}}":{53:8-53:10}:""
+ W w(); // expected-warning {{function declaration}} expected-note {{remove parentheses}}
+
+ // TODO: Removing the parens here would not initialize U::n.
+ // Maybe suggest an " = X()" initializer for this case?
+ // Maybe suggest removing the parens anyway?
+ X x(); // expected-warning {{function declaration}}
+
+ // CHECK: fix-it:"{{.*}}":{61:11-61:13}:" = 0"
+ int n1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{65:11-65:12}:";"
+ // CHECK: fix-it:"{{.*}}":{66:7-66:9}:" = 0"
+ int n2, // expected-note {{change this ',' to a ';' to call 'F1'}}
+ F1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{69:13-69:15}:" = 0.0"
+ double d(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ typedef void *Ptr;
+
+ // CHECK: fix-it:"{{.*}}":{74:10-74:12}:" = 0"
+ Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+#define NULL 0
+ // CHECK: fix-it:"{{.*}}":{78:10-78:12}:" = NULL"
+ Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{81:11-81:13}:" = false"
+ bool b(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{84:11-84:13}:" = '\\0'"
+ char c(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{87:15-87:17}:" = L'\\0'"
+ wchar_t wc(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+ }
+}
diff --git a/clang/test/FixIt/fixit.c b/clang/test/FixIt/fixit.c
new file mode 100644
index 0000000..5e4947b
--- /dev/null
+++ b/clang/test/FixIt/fixit.c
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -pedantic -Wunused-label -verify -x c %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -pedantic -Wunused-label -fixit -x c %t
+// RUN: grep -v CHECK %t > %t2
+// RUN: %clang_cc1 -pedantic -Wunused-label -Werror -x c %t
+// RUN: FileCheck -input-file=%t2 %t
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+// FIXME: FIX-IT should add #include <string.h>?
+int strcmp(const char *s1, const char *s2);
+
+void f0(void) { }; // expected-warning {{';'}}
+
+struct s {
+ int x, y;; // expected-warning {{extra ';'}}
+};
+
+// CHECK: _Complex double cd;
+_Complex cd; // expected-warning {{assuming '_Complex double'}}
+
+// CHECK: struct s s0 = { .y = 5 };
+struct s s0 = { y: 5 }; // expected-warning {{GNU old-style}}
+
+// CHECK: int array0[5] = { [3] = 3 };
+int array0[5] = { [3] 3 }; // expected-warning {{GNU 'missing ='}}
+
+// CHECK: int x
+// CHECK: int y
+void f1(x, y) // expected-warning 2{{defaulting to type 'int'}}
+{
+}
+
+int i0 = { 17 };
+
+#define ONE 1
+#define TWO 2
+
+int test_cond(int y, int fooBar) { // expected-note {{here}}
+// CHECK: int x = y ? 1 : 4+fooBar;
+ int x = y ? 1 4+foobar; // expected-error {{expected ':'}} expected-error {{undeclared identifier}} expected-note {{to match}}
+// CHECK: x = y ? ONE : TWO;
+ x = y ? ONE TWO; // expected-error {{':'}} expected-note {{to match}}
+ return x;
+}
+
+// CHECK: const typedef int int_t;
+const typedef typedef int int_t; // expected-warning {{duplicate 'typedef'}}
+
+// <rdar://problem/7159693>
+enum Color {
+ Red // expected-error{{missing ',' between enumerators}}
+ Green = 17 // expected-error{{missing ',' between enumerators}}
+ Blue,
+};
+
+// rdar://9295072
+struct test_struct {
+ // CHECK: struct test_struct *struct_ptr;
+ test_struct *struct_ptr; // expected-error {{must use 'struct' tag to refer to type 'test_struct'}}
+};
+
+void removeUnusedLabels(char c) {
+ L0 /*removed comment*/: c++; // expected-warning {{unused label}}
+ removeUnusedLabels(c);
+ L1: // expected-warning {{unused label}}
+ c++;
+ /*preserved comment*/ L2 : c++; // expected-warning {{unused label}}
+ LL // expected-warning {{unused label}}
+ : c++;
+ c = c + 3; L4: return; // expected-warning {{unused label}}
+}
+
+int oopsAComma = 0, // expected-error {{';'}}
+void oopsMoreCommas() {
+ static int a[] = { 0, 1, 2 }, // expected-error {{';'}}
+ static int b[] = { 3, 4, 5 }, // expected-error {{';'}}
+ &a == &b ? oopsMoreCommas() : removeUnusedLabels(a[0]);
+}
+
+int noSemiAfterLabel(int n) {
+ switch (n) {
+ default:
+ return n % 4;
+ case 0:
+ case 1:
+ case 2:
+ // CHECK: /*FOO*/ case 3: ;
+ /*FOO*/ case 3: // expected-error {{expected statement}}
+ }
+ switch (n) {
+ case 1:
+ case 2:
+ return 0;
+ // CHECK: /*BAR*/ default: ;
+ /*BAR*/ default: // expected-error {{expected statement}}
+ }
+ return 1;
+}
diff --git a/clang/test/FixIt/fixit.cpp b/clang/test/FixIt/fixit.cpp
new file mode 100644
index 0000000..7d531a5
--- /dev/null
+++ b/clang/test/FixIt/fixit.cpp
@@ -0,0 +1,206 @@
+// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ %t
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+struct C1 {
+ virtual void f();
+ static void g();
+};
+struct C2 : virtual public virtual C1 { }; // expected-error{{duplicate}}
+
+virtual void C1::f() { } // expected-error{{'virtual' can only be specified inside the class definition}}
+
+static void C1::g() { } // expected-error{{'static' can only be specified inside the class definition}}
+
+template<int Value> struct CT { }; // expected-note{{previous use is here}}
+
+CT<10 >> 2> ct; // expected-warning{{require parentheses}}
+
+class C3 {
+public:
+ C3(C3, int i = 0); // expected-error{{copy constructor must pass its first argument by reference}}
+};
+
+struct CT<0> { }; // expected-error{{'template<>'}}
+
+template<> union CT<1> { }; // expected-error{{tag type}}
+
+// Access declarations
+class A {
+protected:
+ int foo();
+};
+
+class B : public A {
+ A::foo; // expected-warning{{access declarations are deprecated}}
+};
+
+void f() throw(); // expected-note{{previous}}
+void f(); // expected-warning{{missing exception specification}}
+
+namespace rdar7853795 {
+ struct A {
+ bool getNumComponents() const; // expected-note{{declared here}}
+ void dump() const {
+ getNumComponenets(); // expected-error{{use of undeclared identifier 'getNumComponenets'; did you mean 'getNumComponents'?}}
+ }
+ };
+}
+
+namespace rdar7796492 {
+ class A { int x, y; A(); };
+
+ A::A()
+ : x(1) y(2) { // expected-error{{missing ',' between base or member initializers}}
+ }
+
+}
+
+// extra qualification on member
+class C {
+ int C::foo(); // expected-warning {{extra qualification}}
+};
+
+namespace rdar8488464 {
+int x = 0;
+int x1 &= 0; // expected-error {{invalid '&=' at end of declaration; did you mean '='?}}
+int x2 *= 0; // expected-error {{invalid '*=' at end of declaration; did you mean '='?}}
+int x3 += 0; // expected-error {{invalid '+=' at end of declaration; did you mean '='?}}
+int x4 -= 0; // expected-error {{invalid '-=' at end of declaration; did you mean '='?}}
+int x5 != 0; // expected-error {{invalid '!=' at end of declaration; did you mean '='?}}
+int x6 /= 0; // expected-error {{invalid '/=' at end of declaration; did you mean '='?}}
+int x7 %= 0; // expected-error {{invalid '%=' at end of declaration; did you mean '='?}}
+int x8 <= 0; // expected-error {{invalid '<=' at end of declaration; did you mean '='?}}
+int x9 <<= 0; // expected-error {{invalid '<<=' at end of declaration; did you mean '='?}}
+int x10 >= 0; // expected-error {{invalid '>=' at end of declaration; did you mean '='?}}
+int x11 >>= 0; // expected-error {{invalid '>>=' at end of declaration; did you mean '='?}}
+int x12 ^= 0; // expected-error {{invalid '^=' at end of declaration; did you mean '='?}}
+int x13 |= 0; // expected-error {{invalid '|=' at end of declaration; did you mean '='?}}
+int x14 == 0; // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
+
+void f() {
+ int x = 0;
+ (void)x;
+ int x1 &= 0; // expected-error {{invalid '&=' at end of declaration; did you mean '='?}}
+ (void)x1;
+ int x2 *= 0; // expected-error {{invalid '*=' at end of declaration; did you mean '='?}}
+ (void)x2;
+ int x3 += 0; // expected-error {{invalid '+=' at end of declaration; did you mean '='?}}
+ (void)x3;
+ int x4 -= 0; // expected-error {{invalid '-=' at end of declaration; did you mean '='?}}
+ (void)x4;
+ int x5 != 0; // expected-error {{invalid '!=' at end of declaration; did you mean '='?}}
+ (void)x5;
+ int x6 /= 0; // expected-error {{invalid '/=' at end of declaration; did you mean '='?}}
+ (void)x6;
+ int x7 %= 0; // expected-error {{invalid '%=' at end of declaration; did you mean '='?}}
+ (void)x7;
+ int x8 <= 0; // expected-error {{invalid '<=' at end of declaration; did you mean '='?}}
+ (void)x8;
+ int x9 <<= 0; // expected-error {{invalid '<<=' at end of declaration; did you mean '='?}}
+ (void)x9;
+ int x10 >= 0; // expected-error {{invalid '>=' at end of declaration; did you mean '='?}}
+ (void)x10;
+ int x11 >>= 0; // expected-error {{invalid '>>=' at end of declaration; did you mean '='?}}
+ (void)x11;
+ int x12 ^= 0; // expected-error {{invalid '^=' at end of declaration; did you mean '='?}}
+ (void)x12;
+ int x13 |= 0; // expected-error {{invalid '|=' at end of declaration; did you mean '='?}}
+ (void)x13;
+ int x14 == 0; // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
+ (void)x14;
+ if (int x = 0) { (void)x; }
+ if (int x1 &= 0) { (void)x1; } // expected-error {{invalid '&=' at end of declaration; did you mean '='?}}
+ if (int x2 *= 0) { (void)x2; } // expected-error {{invalid '*=' at end of declaration; did you mean '='?}}
+ if (int x3 += 0) { (void)x3; } // expected-error {{invalid '+=' at end of declaration; did you mean '='?}}
+ if (int x4 -= 0) { (void)x4; } // expected-error {{invalid '-=' at end of declaration; did you mean '='?}}
+ if (int x5 != 0) { (void)x5; } // expected-error {{invalid '!=' at end of declaration; did you mean '='?}}
+ if (int x6 /= 0) { (void)x6; } // expected-error {{invalid '/=' at end of declaration; did you mean '='?}}
+ if (int x7 %= 0) { (void)x7; } // expected-error {{invalid '%=' at end of declaration; did you mean '='?}}
+ if (int x8 <= 0) { (void)x8; } // expected-error {{invalid '<=' at end of declaration; did you mean '='?}}
+ if (int x9 <<= 0) { (void)x9; } // expected-error {{invalid '<<=' at end of declaration; did you mean '='?}}
+ if (int x10 >= 0) { (void)x10; } // expected-error {{invalid '>=' at end of declaration; did you mean '='?}}
+ if (int x11 >>= 0) { (void)x11; } // expected-error {{invalid '>>=' at end of declaration; did you mean '='?}}
+ if (int x12 ^= 0) { (void)x12; } // expected-error {{invalid '^=' at end of declaration; did you mean '='?}}
+ if (int x13 |= 0) { (void)x13; } // expected-error {{invalid '|=' at end of declaration; did you mean '='?}}
+ if (int x14 == 0) { (void)x14; } // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
+}
+}
+
+template <class A>
+class F1 {
+public:
+ template <int B>
+ class Iterator {
+ };
+};
+
+template<class T>
+class F2 {
+ typename F1<T>:: /*template*/ Iterator<0> Mypos; // expected-error {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
+};
+
+template <class T>
+void f(){
+ typename F1<T>:: /*template*/ Iterator<0> Mypos; // expected-error {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
+}
+
+// Tests for &/* fixits radar 7113438.
+class AD {};
+class BD: public AD {};
+
+void test (BD &br) {
+ AD* aPtr;
+ BD b;
+ aPtr = b; // expected-error {{assigning to 'AD *' from incompatible type 'BD'; take the address with &}}
+ aPtr = br; // expected-error {{assigning to 'AD *' from incompatible type 'BD'; take the address with &}}
+}
+
+void foo1() const {} // expected-error {{non-member function cannot have 'const' qualifier}}
+void foo2() volatile {} // expected-error {{non-member function cannot have 'volatile' qualifier}}
+void foo3() const volatile {} // expected-error {{non-member function cannot have 'const volatile' qualifier}}
+
+struct S { void f(int, char); };
+int itsAComma,
+itsAComma2 = 0,
+oopsAComma(42), // expected-error {{expected ';' at end of declaration}}
+AD oopsMoreCommas() {
+ static int n = 0, // expected-error {{expected ';' at end of declaration}}
+ static char c,
+ &d = c, // expected-error {{expected ';' at end of declaration}}
+ S s, // expected-error {{expected ';' at end of declaration}}
+ s.f(n, d);
+ AD ad, // expected-error {{expected ';' at end of declaration}}
+ return ad;
+}
+struct MoreAccidentalCommas {
+ int a : 5,
+ b : 7,
+ : 4, // expected-error {{expected ';' at end of declaration}}
+ char c, // expected-error {{expected ';' at end of declaration}}
+ double d, // expected-error {{expected ';' at end of declaration}}
+ MoreAccidentalCommas *next, // expected-error {{expected ';' at end of declaration}}
+public:
+ int k, // expected-error {{expected ';' at end of declaration}}
+ friend void f(MoreAccidentalCommas) {}
+ int k2, // expected-error {{expected ';' at end of declaration}}
+ virtual void g(), // expected-error {{expected ';' at end of declaration}}
+};
+
+template<class T> struct Mystery;
+template<class T> typedef Mystery<T>::type getMysteriousThing() { // \
+ expected-error {{function definition declared 'typedef'}} \
+ expected-error {{missing 'typename' prior to dependent}}
+ return Mystery<T>::get();
+}
+
+template<template<typename> Foo, // expected-error {{template template parameter requires 'class' after the parameter list}}
+ template<typename> typename Bar, // expected-error {{template template parameter requires 'class' after the parameter list}}
+ template<typename> struct Baz> // expected-error {{template template parameter requires 'class' after the parameter list}}
+void func();
diff --git a/clang/test/FixIt/no-fixit.cpp b/clang/test/FixIt/no-fixit.cpp
new file mode 100644
index 0000000..c95c867
--- /dev/null
+++ b/clang/test/FixIt/no-fixit.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -x c++ -std=c++11 %s 2>&1 | FileCheck %s
+
+// test that the diagnostics produced by this code do not include fixit hints
+
+// CHECK-NOT: fix-it:
+
+template<template<typename> +> void func();
diff --git a/clang/test/FixIt/no-macro-fixit.c b/clang/test/FixIt/no-macro-fixit.c
new file mode 100644
index 0000000..b6a9285
--- /dev/null
+++ b/clang/test/FixIt/no-macro-fixit.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -pedantic -fixit -x c %s
+// rdar://9091893
+
+#define va_arg(ap, type) __builtin_va_arg(ap, type)
+typedef __builtin_va_list va_list;
+
+void myFunc() {
+ va_list values;
+
+ int value;
+
+ while (value = va_arg(values, int)) { // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note {{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note {{place parentheses around the assignment to silence this warning}}
+ }
+}
diff --git a/clang/test/FixIt/no-typo.c b/clang/test/FixIt/no-typo.c
new file mode 100644
index 0000000..05947e8
--- /dev/null
+++ b/clang/test/FixIt/no-typo.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -fno-spell-checking -verify %s
+typedef struct {
+ float x, y;
+} Point;
+
+point p1; // expected-error{{unknown type name 'point'}}
diff --git a/clang/test/FixIt/objc-literals.m b/clang/test/FixIt/objc-literals.m
new file mode 100644
index 0000000..03d64b1
--- /dev/null
+++ b/clang/test/FixIt/objc-literals.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -fsyntax-only -fixit -x objective-c %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x objective-c %t
+// RUN: grep arrayWithObjects %t
+
+typedef unsigned char BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
++ (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;
+@end
+
+@interface NSArray
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+void fixes() {
+ id arr = @[
+ 17, // expected-error{{numeric literal must be prefixed by '@' in a collection}}
+ 'a', // expected-error{{character literal must be prefixed by '@'}}
+ "blah" // expected-error{{string literal must be prefixed by '@'}}
+ ];
+}
diff --git a/clang/test/FixIt/typo-crash.cpp b/clang/test/FixIt/typo-crash.cpp
new file mode 100644
index 0000000..c154e3b
--- /dev/null
+++ b/clang/test/FixIt/typo-crash.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// FIXME: The diagnostics and recovery here are very, very poor.
+
+// PR10355
+template<typename T> void template_id1() { // expected-note {{'template_id1' declared here}} \
+ // expected-note {{possible target for call}}
+ template_id2<> t; // expected-error {{no template named 'template_id2'; did you mean 'template_id1'?}} \
+ // expected-error {{expected ';' after expression}} \
+ // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} \
+ // expected-error {{use of undeclared identifier 't'}}
+ }
+
+// FIXME: It would be nice if we could get this correction right.
+namespace PR12297 {
+ namespace A {
+ typedef short T;
+
+ namespace B {
+ typedef short T;
+
+ T global(); // expected-note {{'A::B::global' declared here}}
+ }
+ }
+
+ using namespace A::B;
+
+ T A::global(); // expected-error {{out-of-line definition of 'global' does not match any declaration in namespace 'PR12297::A'; did you mean 'A::B::global'?}}
+}
diff --git a/clang/test/FixIt/typo-crash.m b/clang/test/FixIt/typo-crash.m
new file mode 100644
index 0000000..f10fe61
--- /dev/null
+++ b/clang/test/FixIt/typo-crash.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/7605289>
+@implementation Unknown (Blarg) // expected-error{{cannot find interface declaration for 'Unknown'}}
+- (int)method { return ivar; } // expected-error{{use of undeclared identifier 'ivar'}}
+@end
diff --git a/clang/test/FixIt/typo.c b/clang/test/FixIt/typo.c
new file mode 100644
index 0000000..0bafd1b
--- /dev/null
+++ b/clang/test/FixIt/typo.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -fsyntax-only -fixit -x c %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c %t
+// RUN: grep "Rectangle" %t
+struct Point {
+ float x, y;
+};
+
+struct Rectangle {
+ struct Point top_left, // expected-note{{'top_left' declared here}}
+ bottom_right;
+};
+
+enum Color { Red, Green, Blue };
+
+struct Window {
+ struct Rectangle bounds; // expected-note{{'bounds' declared here}}
+ enum Color color;
+};
+
+struct Window window = {
+ .bunds. // expected-error{{field designator 'bunds' does not refer to any field in type 'struct Window'; did you mean 'bounds'?}}
+ topleft.x = 3.14, // expected-error{{field designator 'topleft' does not refer to any field in type 'struct Rectangle'; did you mean 'top_left'?}}
+ 2.71818, 5.0, 6.0, Red
+};
+
+void test() {
+ Rectangle r1; // expected-error{{must use 'struct' tag to refer to type 'Rectangle'}}
+ r1.top_left.x = 0;
+
+ typedef struct Rectangle Rectangle; // expected-note{{'Rectangle' declared here}}
+ rectangle *r2 = &r1; // expected-error{{unknown type name 'rectangle'; did you mean 'Rectangle'?}}
+ r2->top_left.y = 0;
+ unsinged *ptr = 0; // expected-error{{use of undeclared identifier 'unsinged'; did you mean 'unsigned'?}}
+ *ptr = 17;
+}
diff --git a/clang/test/FixIt/typo.cpp b/clang/test/FixIt/typo.cpp
new file mode 100644
index 0000000..3d40da8
--- /dev/null
+++ b/clang/test/FixIt/typo.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -fsyntax-only -fixit -x c++ %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ %t
+// RUN: grep test_string %t
+
+namespace std {
+ template<typename T> class basic_string { // expected-note 2{{'basic_string' declared here}}
+ public:
+ int find(const char *substr); // expected-note{{'find' declared here}}
+ static const int npos = -1; // expected-note{{'npos' declared here}}
+ };
+
+ typedef basic_string<char> string; // expected-note 2{{'string' declared here}}
+}
+
+namespace otherstd { // expected-note 2{{'otherstd' declared here}} \
+ // expected-note{{namespace 'otherstd' defined here}}
+ using namespace std;
+}
+
+using namespace std;
+
+other_std::strng str1; // expected-error{{use of undeclared identifier 'other_std'; did you mean 'otherstd'?}} \
+// expected-error{{no type named 'strng' in namespace 'otherstd'; did you mean 'string'?}}
+tring str2; // expected-error{{unknown type name 'tring'; did you mean 'string'?}}
+
+::other_std::string str3; // expected-error{{no member named 'other_std' in the global namespace; did you mean 'otherstd'?}}
+
+float area(float radius, // expected-note{{'radius' declared here}}
+ float pi) {
+ return radious * pi; // expected-error{{did you mean 'radius'?}}
+}
+
+using namespace othestd; // expected-error{{no namespace named 'othestd'; did you mean 'otherstd'?}}
+namespace blargh = otherstd; // expected-note 3{{namespace 'blargh' defined here}}
+using namespace ::blarg; // expected-error{{no namespace named 'blarg' in the global namespace; did you mean 'blargh'?}}
+
+namespace wibble = blarg; // expected-error{{no namespace named 'blarg'; did you mean 'blargh'?}}
+namespace wobble = ::blarg; // expected-error{{no namespace named 'blarg' in the global namespace; did you mean 'blargh'?}}
+
+bool test_string(std::string s) {
+ basc_string<char> b1; // expected-error{{no template named 'basc_string'; did you mean 'basic_string'?}}
+ std::basic_sting<char> b2; // expected-error{{no template named 'basic_sting' in namespace 'std'; did you mean 'basic_string'?}}
+ (void)b1;
+ (void)b2;
+ return s.fnd("hello") // expected-error{{no member named 'fnd' in 'std::basic_string<char>'; did you mean 'find'?}}
+ == std::string::pos; // expected-error{{no member named 'pos' in 'std::basic_string<char>'; did you mean 'npos'?}}
+}
+
+struct Base { };
+struct Derived : public Base { // expected-note{{base class 'Base' specified here}}
+ int member; // expected-note 3{{'member' declared here}}
+
+ Derived() : base(), // expected-error{{initializer 'base' does not name a non-static data member or base class; did you mean the base class 'Base'?}}
+ ember() { } // expected-error{{initializer 'ember' does not name a non-static data member or base class; did you mean the member 'member'?}}
+
+ int getMember() const {
+ return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
+ }
+
+ int &getMember();
+};
+
+int &Derived::getMember() {
+ return ember; // expected-error{{use of undeclared identifier 'ember'; did you mean 'member'?}}
+}
+
+typedef int Integer; // expected-note{{'Integer' declared here}}
+int global_value; // expected-note{{'global_value' declared here}}
+
+int foo() {
+ integer * i = 0; // expected-error{{unknown type name 'integer'; did you mean 'Integer'?}}
+ unsinged *ptr = 0; // expected-error{{use of undeclared identifier 'unsinged'; did you mean 'unsigned'?}}
+ return *i + *ptr + global_val; // expected-error{{use of undeclared identifier 'global_val'; did you mean 'global_value'?}}
+}
+
+namespace nonstd {
+ typedef std::basic_string<char> yarn; // expected-note{{'nonstd::yarn' declared here}}
+}
+
+yarn str4; // expected-error{{unknown type name 'yarn'; did you mean 'nonstd::yarn'?}}
+
+namespace check_bool {
+ void f() {
+ Bool b; // expected-error{{use of undeclared identifier 'Bool'; did you mean 'bool'?}}
+ }
+}
diff --git a/clang/test/FixIt/typo.m b/clang/test/FixIt/typo.m
new file mode 100644
index 0000000..381233f
--- /dev/null
+++ b/clang/test/FixIt/typo.m
@@ -0,0 +1,167 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -DNON_FIXITS -verify -Wno-objc-root-class %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fixit -Wno-objc-root-class %t
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -pedantic -Werror -Wno-objc-root-class %t
+// RUN: grep "@implementation Sub3" %t
+
+@interface NSString // expected-note 2{{'NSString' declared here}}
++ (int)method:(int)x;
+@end
+
+void test() {
+ NSstring *str = @"A string"; // expected-error{{unknown type name 'NSstring'; did you mean 'NSString'?}}
+}
+
+@protocol P1
+@optional
+@property int *sprop; // expected-note{{'sprop' declared here}}
+@end
+
+@interface A
+{
+ int his_ivar; // expected-note 2{{'his_ivar' declared here}}
+ float wibble;
+}
+- (void)methodA;
++ (void)methodA;
+@property int his_prop; // expected-note{{'his_prop' declared here}}
+@end
+
+@interface B : A <P1>
+{
+ int her_ivar; // expected-note 2{{'her_ivar' declared here}}
+}
+
+@property int her_prop; // expected-note{{'her_prop' declared here}}
+- (void)inst_method1:(int)a;
++ (void)class_method1;
+@end
+
+@implementation A
+@synthesize his_prop = his_ivar;
+- (void)methodA { }
++ (void)methodA { }
+@end
+
+@implementation B
+@synthesize her_prop = her_ivar;
+
+-(void)inst_method1:(int)a {
+ herivar = a; // expected-error{{use of undeclared identifier 'herivar'; did you mean 'her_ivar'?}}
+ hisivar = a; // expected-error{{use of undeclared identifier 'hisivar'; did you mean 'his_ivar'?}}
+ self->herivar = a; // expected-error{{'B' does not have a member named 'herivar'; did you mean 'her_ivar'?}}
+ self->hisivar = a; // expected-error{{'B' does not have a member named 'hisivar'; did you mean 'his_ivar'?}}
+ self.hisprop = 0; // expected-error{{property 'hisprop' not found on object of type 'B *'; did you mean 'his_prop'?}}
+ self.herprop = 0; // expected-error{{property 'herprop' not found on object of type 'B *'; did you mean 'her_prop'?}}
+ self.s_prop = 0; // expected-error{{property 's_prop' not found on object of type 'B *'; did you mean 'sprop'?}}
+}
+
++(void)class_method1 {
+}
+@end
+
+void test_message_send(B* b) {
+ [NSstring method:17]; // expected-error{{unknown receiver 'NSstring'; did you mean 'NSString'?}}
+}
+
+@interface Collide // expected-note{{'Collide' declared here}}
+{
+@public
+ int value; // expected-note{{'value' declared here}}
+}
+
+@property int value; // expected-note{{'value' declared here}}
+@end
+
+@implementation Collide
+@synthesize value = value;
+@end
+
+void test2(Collide *a) {
+ a.valu = 17; // expected-error{{property 'valu' not found on object of type 'Collide *'; did you mean 'value'?}}
+ a->vale = 17; // expected-error{{'Collide' does not have a member named 'vale'; did you mean 'value'?}}
+}
+
+#ifdef NON_FIXITS
+@interface Derived : Collid // expected-error{{cannot find interface declaration for 'Collid', superclass of 'Derived'; did you mean 'Collide'?}}
+@end
+#endif
+
+#ifdef NON_FIXITS
+@protocol NetworkSocket // expected-note{{'NetworkSocket' declared here}}
+- (int)send:(void*)buffer bytes:(int)bytes;
+@end
+
+@interface IPv6 <Network_Socket> // expected-error{{cannot find protocol declaration for 'Network_Socket'; did you mean 'NetworkSocket'?}}
+@end
+#endif
+
+@interface Super
+- (int)method; // expected-note{{using}}
+- (int)method2;
+- (int)method3:(id)x;
+@end
+
+@interface Sub : Super
+- (int)method;
+@end
+
+@implementation Sub
+- (int)method {
+ return [supper method]; // expected-error{{unknown receiver 'supper'; did you mean 'super'?}}
+}
+
+@end
+
+double *isupper(int);
+
+@interface Sub2 : Super
+- (int)method2;
+@end
+
+@implementation Sub2
+- (int)method2 {
+ return [supper method2]; // expected-error{{unknown receiver 'supper'; did you mean 'super'?}}
+}
+@end
+
+@interface Ivar
+@end
+
+@protocol Proto
+@property (retain) id ivar;
+@end
+
+#ifdef NON_FIXITS
+@interface User <Proto>
+- (void)method; // expected-note{{also found}}
+@end
+
+@implementation User
+@synthesize ivar;
+
+- (void)method {
+ // Test that we don't correct 'ivar' to 'Ivar' e
+ [ivar method]; // expected-warning{{multiple methods named 'method' found}}
+}
+@end
+#endif
+
+void f(A *a) {
+ f(a) // expected-error{{expected ';' after expression}}
+ [a methodA] // expected-error{{expected ';' after expression}}
+ [A methodA] // expected-error{{expected ';' after expression}}
+}
+
+#ifdef NON_FIXITS
+@interface Sub3 : Super
+- (int)method3;
+@end
+
+@implementation Sub3
+- (int)method3 {
+ int x = super; // expected-error{{use of undeclared identifier 'super'}}
+ return 0;
+}
+@end
+#endif
diff --git a/clang/test/Frontend/Inputs/TestFramework.framework/Headers/TestFramework.h b/clang/test/Frontend/Inputs/TestFramework.framework/Headers/TestFramework.h
new file mode 100644
index 0000000..49048ca
--- /dev/null
+++ b/clang/test/Frontend/Inputs/TestFramework.framework/Headers/TestFramework.h
@@ -0,0 +1 @@
+static int f0(void) {}
diff --git a/clang/test/Frontend/Inputs/lit.local.cfg b/clang/test/Frontend/Inputs/lit.local.cfg
new file mode 100644
index 0000000..e6f55ee
--- /dev/null
+++ b/clang/test/Frontend/Inputs/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = []
diff --git a/clang/test/Frontend/Inputs/test.h b/clang/test/Frontend/Inputs/test.h
new file mode 100644
index 0000000..98cc459
--- /dev/null
+++ b/clang/test/Frontend/Inputs/test.h
@@ -0,0 +1 @@
+#include "test2.h"
diff --git a/clang/test/Frontend/Inputs/test2.h b/clang/test/Frontend/Inputs/test2.h
new file mode 100644
index 0000000..6d1a0d4
--- /dev/null
+++ b/clang/test/Frontend/Inputs/test2.h
@@ -0,0 +1 @@
+int x;
diff --git a/clang/test/Frontend/Inputs/test3.h b/clang/test/Frontend/Inputs/test3.h
new file mode 100644
index 0000000..92ff4b8
--- /dev/null
+++ b/clang/test/Frontend/Inputs/test3.h
@@ -0,0 +1 @@
+int y;
diff --git a/clang/test/Frontend/Weverything.c b/clang/test/Frontend/Weverything.c
new file mode 100644
index 0000000..32f3147
--- /dev/null
+++ b/clang/test/Frontend/Weverything.c
@@ -0,0 +1,9 @@
+// Regression check that -pedantic-errors doesn't cause other diagnostics to
+// become errors.
+//
+// RUN: %clang_cc1 -verify -Weverything -pedantic-errors %s
+
+int f0(int, unsigned);
+int f0(int x, unsigned y) {
+ return x < y; // expected-warning {{comparison of integers}}
+}
diff --git a/clang/test/Frontend/Wno-everything.c b/clang/test/Frontend/Wno-everything.c
new file mode 100644
index 0000000..ca70ca4
--- /dev/null
+++ b/clang/test/Frontend/Wno-everything.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -verify -Wno-everything -Wsign-compare %s
+
+int f0(int, unsigned);
+int f0(int x, unsigned y) {
+ if (x=3);
+ return x < y; // expected-warning {{comparison of integers}}
+}
diff --git a/clang/test/Frontend/ast-codegen.c b/clang/test/Frontend/ast-codegen.c
new file mode 100644
index 0000000..b5b2157
--- /dev/null
+++ b/clang/test/Frontend/ast-codegen.c
@@ -0,0 +1,12 @@
+// RUN: %clang -emit-ast -o %t.ast %s
+// RUN: %clang -emit-llvm -S -o - %t.ast | FileCheck %s
+
+// CHECK: module asm "foo"
+__asm__("foo");
+
+// CHECK: @g0 = common global i32 0, align 4
+int g0;
+
+// CHECK: define i32 @f0()
+int f0() {
+}
diff --git a/clang/test/Frontend/ast-main.c b/clang/test/Frontend/ast-main.c
new file mode 100644
index 0000000..43237a1
--- /dev/null
+++ b/clang/test/Frontend/ast-main.c
@@ -0,0 +1,8 @@
+// RUN: %clang -emit-llvm -S -o %t1.ll -x c - < %s
+// RUN: %clang -emit-ast -o %t.ast %s
+// RUN: %clang -emit-llvm -S -o %t2.ll -x ast - < %t.ast
+// RUN: diff %t1.ll %t2.ll
+
+int main() {
+ return 0;
+}
diff --git a/clang/test/Frontend/cpp-output.c b/clang/test/Frontend/cpp-output.c
new file mode 100644
index 0000000..e44095b
--- /dev/null
+++ b/clang/test/Frontend/cpp-output.c
@@ -0,0 +1,14 @@
+// RUN: %clang -E -o %t -C %s
+// RUN: grep '^int x; // comment' %t
+// RUN: grep '^x x' %t
+// RUN: %clang -E -o %t -CC %s
+// RUN: grep '^int x; // comment' %t
+// RUN: grep '^x /\* comment \*/ x /\* comment \*/' %t
+
+int x; // comment
+
+#define A(foo, bar) foo bar
+#define B x // comment
+
+A(B, B)
+
diff --git a/clang/test/Frontend/darwin-version.c b/clang/test/Frontend/darwin-version.c
new file mode 100644
index 0000000..f9ce54b
--- /dev/null
+++ b/clang/test/Frontend/darwin-version.c
@@ -0,0 +1,25 @@
+// RUN: %clang -target armv6-apple-darwin9 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | count 0
+// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1050' | count 1
+// RUN: %clang -target armv6-apple-darwin9 -miphoneos-version-min=3.0 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '30000' | count 1
+// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | count 0
+// RUN: %clang -target armv6-apple-darwin9 -miphoneos-version-min=2.0 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '20000' | count 1
+// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | count 0
+// RUN: %clang -target armv6-apple-darwin9 -miphoneos-version-min=2.2 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '20200' | count 1
+// RUN: %clang -target i686-apple-darwin8 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | count 0
+// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1040' | count 1
+// RUN: %clang -target i686-apple-darwin9 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1050' | count 1
+// RUN: %clang -target i686-apple-darwin10 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1060' | count 1
+// RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.4 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | count 0
+// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1040' | count 1
+// RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.5 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1050' | count 1
+// RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.6 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1060' | count 1
diff --git a/clang/test/Frontend/dependency-gen.c b/clang/test/Frontend/dependency-gen.c
new file mode 100644
index 0000000..5883ec5
--- /dev/null
+++ b/clang/test/Frontend/dependency-gen.c
@@ -0,0 +1,27 @@
+// REQUIRES: shell
+// Basic test
+// RUN: rm -rf %t.dir
+// RUN: mkdir -p %t.dir/a/b
+// RUN: echo > %t.dir/a/b/x.h
+// RUN: cd %t.dir
+// RUN: %clang -MD -MF - %s -fsyntax-only -I a/b | FileCheck -check-prefix=CHECK-ONE %s
+// CHECK-ONE: {{ }}a/b{{[/\\]}}x.h
+
+// PR8974 (-include flag)
+// RUN: %clang -MD -MF - %s -fsyntax-only -include a/b/x.h -DINCLUDE_FLAG_TEST | FileCheck -check-prefix=CHECK-TWO %s
+// CHECK-TWO: {{ }}a/b/x.h
+
+// rdar://problem/9734352 (paths involving ".")
+// RUN: %clang -MD -MF - %s -fsyntax-only -I ./a/b | FileCheck -check-prefix=CHECK-THREE %s
+// CHECK-THREE: {{ }}a/b{{[/\\]}}x.h
+// RUN: %clang -MD -MF - %s -fsyntax-only -I .//./a/b/ | FileCheck -check-prefix=CHECK-FOUR %s
+// CHECK-FOUR: {{ }}a/b{{[/\\]}}x.h
+// RUN: %clang -MD -MF - %s -fsyntax-only -I a/b/. | FileCheck -check-prefix=CHECK-FIVE %s
+// CHECK-FIVE: {{ }}a/b/.{{[/\\]}}x.h
+// RUN: cd a/b
+// RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s
+// CHECK-SIX: {{ }}x.h
+
+#ifndef INCLUDE_FLAG_TEST
+#include <x.h>
+#endif
diff --git a/clang/test/Frontend/dependency-generation-crash.c b/clang/test/Frontend/dependency-generation-crash.c
new file mode 100644
index 0000000..181bb71
--- /dev/null
+++ b/clang/test/Frontend/dependency-generation-crash.c
@@ -0,0 +1,4 @@
+// RUN: touch %t
+// RUN: chmod 0 %t
+// %clang -E -dependency-file bla -MT %t -MP -o %t -x c /dev/null
+// rdar://9286457
diff --git a/clang/test/Frontend/diagnostics-option-names.c b/clang/test/Frontend/diagnostics-option-names.c
new file mode 100644
index 0000000..ed0d2ed
--- /dev/null
+++ b/clang/test/Frontend/diagnostics-option-names.c
@@ -0,0 +1,8 @@
+// RUN: not %clang_cc1 -fdiagnostics-show-option -Werror -Weverything %s 2> %t
+// RUN: FileCheck < %t %s
+
+int f0(int, unsigned);
+int f0(int x, unsigned y) {
+// CHECK: comparison of integers of different signs{{.*}} [-Werror,-Wsign-compare]
+ return x < y; // expected-error {{ : 'int' and 'unsigned int' }}
+}
diff --git a/clang/test/Frontend/iframework.c b/clang/test/Frontend/iframework.c
new file mode 100644
index 0000000..0c241fd
--- /dev/null
+++ b/clang/test/Frontend/iframework.c
@@ -0,0 +1,3 @@
+// RUN: %clang -fsyntax-only -iframework%S/Inputs %s -Xclang -verify
+
+#include <TestFramework/TestFramework.h>
diff --git a/clang/test/Frontend/ir-support-codegen.ll b/clang/test/Frontend/ir-support-codegen.ll
new file mode 100644
index 0000000..e5e5b62
--- /dev/null
+++ b/clang/test/Frontend/ir-support-codegen.ll
@@ -0,0 +1,9 @@
+; REQUIRES: x86-64-registered-target
+; RUN: %clang_cc1 -S -o - %s | FileCheck %s
+
+target triple = "x86_64-apple-darwin10"
+
+; CHECK: .globl _f0
+define i32 @f0() nounwind ssp {
+ ret i32 0
+}
diff --git a/clang/test/Frontend/ir-support-errors.ll b/clang/test/Frontend/ir-support-errors.ll
new file mode 100644
index 0000000..cb5913c
--- /dev/null
+++ b/clang/test/Frontend/ir-support-errors.ll
@@ -0,0 +1,8 @@
+; RUN: %clang_cc1 -S -o - %s 2>&1 | FileCheck %s
+
+target triple = "x86_64-apple-darwin10"
+
+define i32 @f0() nounwind ssp {
+; CHECK: {{.*}}ir-support-errors.ll:7:16: error: use of undefined value '%x'
+ ret i32 %x
+}
diff --git a/clang/test/Frontend/lit.local.cfg b/clang/test/Frontend/lit.local.cfg
new file mode 100644
index 0000000..4c13598
--- /dev/null
+++ b/clang/test/Frontend/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.bc']
diff --git a/clang/test/Frontend/macros.c b/clang/test/Frontend/macros.c
new file mode 100644
index 0000000..3170797
--- /dev/null
+++ b/clang/test/Frontend/macros.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -DA= -DB=1 -verify -fsyntax-only %s
+
+int a[(B A) == 1 ? 1 : -1];
+
diff --git a/clang/test/Frontend/output-failures.c b/clang/test/Frontend/output-failures.c
new file mode 100644
index 0000000..e2af7c7
--- /dev/null
+++ b/clang/test/Frontend/output-failures.c
@@ -0,0 +1,4 @@
+// RUN: not %clang_cc1 -emit-llvm -o %S/doesnotexist/somename %s 2> %t
+// RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
+
+// OUTPUTFAIL: Error opening output file '{{.*}}doesnotexist{{.*}}'
diff --git a/clang/test/Frontend/preprocessed-output-macro-first-token.c b/clang/test/Frontend/preprocessed-output-macro-first-token.c
new file mode 100644
index 0000000..06b78c2
--- /dev/null
+++ b/clang/test/Frontend/preprocessed-output-macro-first-token.c
@@ -0,0 +1,5 @@
+// This is the first thing other than comments and preprocessor stuff in the
+// file.
+//
+// RUN: %clang_cc1 -fms-extensions -E %s
+#pragma comment(lib, "somelib")
diff --git a/clang/test/Frontend/print-header-includes.c b/clang/test/Frontend/print-header-includes.c
new file mode 100644
index 0000000..7773d20
--- /dev/null
+++ b/clang/test/Frontend/print-header-includes.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -include Inputs/test3.h -E -H -o %t.out %s 2> %t.err
+// RUN: FileCheck < %t.err %s
+
+// CHECK-NOT: test3.h
+// CHECK: . {{.*test.h}}
+// CHECK: .. {{.*test2.h}}
+
+#include "Inputs/test.h"
diff --git a/clang/test/Frontend/rewrite-macros.c b/clang/test/Frontend/rewrite-macros.c
new file mode 100644
index 0000000..bc74796
--- /dev/null
+++ b/clang/test/Frontend/rewrite-macros.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -verify -rewrite-macros -o %t %s
+
+#define A(a,b) a ## b
+
+// RUN: grep '12 */\*A\*/ /\*(1,2)\*/' %t
+A(1,2)
+
+// RUN: grep '/\*_Pragma("mark")\*/' %t
+_Pragma("mark")
+
+// RUN: grep "//#warning eek" %t
+/* expected-warning {{eek}} */ #warning eek
+
+// RUN: grep "//#pragma mark mark" %t
+#pragma mark mark
+
+
diff --git a/clang/test/Frontend/stdin.c b/clang/test/Frontend/stdin.c
new file mode 100644
index 0000000..2d0a237
--- /dev/null
+++ b/clang/test/Frontend/stdin.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -E - < /dev/null > %t
+// RUN: grep '<built-in>' %t
+
diff --git a/clang/test/Frontend/undef.c b/clang/test/Frontend/undef.c
new file mode 100644
index 0000000..f539cdc
--- /dev/null
+++ b/clang/test/Frontend/undef.c
@@ -0,0 +1,4 @@
+// RUN: %clang -undef -x assembler-with-cpp -E %s
+#ifndef __ASSEMBLER__
+#error "Must be preprocessed as assembler."
+#endif
diff --git a/clang/test/Frontend/unknown-pragmas.c b/clang/test/Frontend/unknown-pragmas.c
new file mode 100644
index 0000000..53a5a45
--- /dev/null
+++ b/clang/test/Frontend/unknown-pragmas.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -Eonly -Wall -verify %s
+// RUN: %clang_cc1 -E -dM -Wall -verify %s
+
+#pragma adgohweopihweotnwet
diff --git a/clang/test/Frontend/warning-mapping-1.c b/clang/test/Frontend/warning-mapping-1.c
new file mode 100644
index 0000000..883dafb
--- /dev/null
+++ b/clang/test/Frontend/warning-mapping-1.c
@@ -0,0 +1,6 @@
+// Check that -w has higher priority than -Werror.
+// RUN: %clang_cc1 -verify -Wsign-compare -Werror -w %s
+
+int f0(int x, unsigned y) {
+ return x < y;
+}
diff --git a/clang/test/Frontend/warning-mapping-2.c b/clang/test/Frontend/warning-mapping-2.c
new file mode 100644
index 0000000..39ba499
--- /dev/null
+++ b/clang/test/Frontend/warning-mapping-2.c
@@ -0,0 +1,5 @@
+// Check that -w has lower priority than -pedantic-errors.
+// RUN: %clang_cc1 -verify -pedantic-errors -w %s
+
+void f0() { f1(); } // expected-error {{implicit declaration of function}}
+
diff --git a/clang/test/Frontend/warning-mapping-3.c b/clang/test/Frontend/warning-mapping-3.c
new file mode 100644
index 0000000..8c70190
--- /dev/null
+++ b/clang/test/Frontend/warning-mapping-3.c
@@ -0,0 +1,10 @@
+// Check that -Werror and -Wfatal-error interact properly.
+//
+// Verify mode doesn't work with fatal errors, just use FileCheck here.
+//
+// RUN: not %clang_cc1 -Wunused-function -Werror -Wfatal-errors %s 2> %t.err
+// RUN: FileCheck < %t.err %s
+// CHECK: fatal error: unused function
+// CHECK: 1 error generated
+
+static void f0(void) {} // expected-fatal {{unused function}}
diff --git a/clang/test/Frontend/warning-mapping-4.c b/clang/test/Frontend/warning-mapping-4.c
new file mode 100644
index 0000000..d8d2769
--- /dev/null
+++ b/clang/test/Frontend/warning-mapping-4.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -verify -Wno-error=sign-compare %s
+// RUN: %clang_cc1 -verify -Wsign-compare -w -Wno-error=sign-compare %s
+
+int f0(int x, unsigned y) {
+ return x < y;
+}
diff --git a/clang/test/Frontend/warning-mapping-5.c b/clang/test/Frontend/warning-mapping-5.c
new file mode 100644
index 0000000..27d53dc
--- /dev/null
+++ b/clang/test/Frontend/warning-mapping-5.c
@@ -0,0 +1,9 @@
+// Check that #pragma diagnostic warning overrides -Werror. This matches GCC's
+// original documentation, but not its earlier implementations.
+//
+// RUN: %clang_cc1 -verify -Werror %s
+
+#pragma clang diagnostic warning "-Wsign-compare"
+int f0(int x, unsigned y) {
+ return x < y; // expected-warning {{comparison of integers}}
+}
diff --git a/clang/test/Headers/arm-neon-header.c b/clang/test/Headers/arm-neon-header.c
new file mode 100644
index 0000000..90ea22b
--- /dev/null
+++ b/clang/test/Headers/arm-neon-header.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -Wvector-conversions -ffreestanding %s
+// RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -fno-lax-vector-conversions -ffreestanding %s
+// RUN: %clang_cc1 -x c++ -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -Wvector-conversions -ffreestanding %s
+
+#include <arm_neon.h>
diff --git a/clang/test/Headers/c89.c b/clang/test/Headers/c89.c
new file mode 100644
index 0000000..eea8d44
--- /dev/null
+++ b/clang/test/Headers/c89.c
@@ -0,0 +1,10 @@
+// RUN: %clang -target i386-apple-darwin10 -fsyntax-only -Xclang -verify -std=c89 %s
+
+// FIXME: Disable inclusion of mm_malloc.h, our current implementation is broken
+// on win32 since we don't generally know how to find errno.h.
+
+#define __MM_MALLOC_H
+
+// PR6658
+#include <xmmintrin.h>
+
diff --git a/clang/test/Headers/int64-type.c b/clang/test/Headers/int64-type.c
new file mode 100644
index 0000000..16b42d2
--- /dev/null
+++ b/clang/test/Headers/int64-type.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -verify %s -ffreestanding
+
+#include <stdint.h>
+typedef unsigned long long uint64_t;
diff --git a/clang/test/Headers/stdbool.cpp b/clang/test/Headers/stdbool.cpp
new file mode 100644
index 0000000..a252cca
--- /dev/null
+++ b/clang/test/Headers/stdbool.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -E -dM %s | FileCheck --check-prefix=CHECK-GNU-COMPAT %s
+// RUN: %clang_cc1 -std=c++98 -E -dM %s | FileCheck --check-prefix=CHECK-CONFORMING %s
+#include <stdbool.h>
+#define zzz
+
+// CHECK-GNU-COMPAT: #define _Bool bool
+// CHECK-GNU-COMPAT: #define bool bool
+// CHECK-GNU-COMPAT: #define false false
+// CHECK-GNU-COMPAT: #define true true
+
+// CHECK-CONFORMING-NOT: #define _Bool
+// CHECK-CONFORMING: #define __CHAR_BIT__
+// CHECK-CONFORMING-NOT: #define false false
+// CHECK-CONFORMING: #define zzz
diff --git a/clang/test/Headers/typedef_guards.c b/clang/test/Headers/typedef_guards.c
new file mode 100644
index 0000000..646b2ca
--- /dev/null
+++ b/clang/test/Headers/typedef_guards.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// NULL is rdefined in stddef.h
+#define NULL ((void*) 0)
+
+// These are headers bundled with Clang.
+#include <stdarg.h>
+#include <stddef.h>
+
+#ifndef _VA_LIST
+typedef __builtin_va_list va_list;
+#endif
+
+#ifndef _SIZE_T
+typedef __typeof__(sizeof(int)) size_t;
+#endif
+
+#ifndef _WCHAR_T
+typedef __typeof__(*L"") wchar_t;
+#endif
+
+extern void foo(wchar_t x);
+extern void bar(size_t x);
+void *baz() { return NULL; }
+void quz() {
+ va_list y;
+}
+
diff --git a/clang/test/Headers/wchar_limits.cpp b/clang/test/Headers/wchar_limits.cpp
new file mode 100644
index 0000000..93a99ad
--- /dev/null
+++ b/clang/test/Headers/wchar_limits.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify -fshort-wchar %s
+
+#include <stdint.h>
+
+const bool swchar = (wchar_t)-1 > (wchar_t)0;
+
+int max_test[WCHAR_MAX == (swchar ? -(WCHAR_MIN+1) : (wchar_t)-1)];
+int min_test[WCHAR_MIN == (swchar ? 0 : -WCHAR_MAX-1)];
diff --git a/clang/test/Headers/wmmintrin.c b/clang/test/Headers/wmmintrin.c
new file mode 100644
index 0000000..6aa8be4
--- /dev/null
+++ b/clang/test/Headers/wmmintrin.c
@@ -0,0 +1,4 @@
+// Check that wmmintrin.h is includable with just -maes.
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -verify %s -ffreestanding -target-feature +aes
+#include <wmmintrin.h>
diff --git a/clang/test/Headers/x86-intrinsics-headers.c b/clang/test/Headers/x86-intrinsics-headers.c
new file mode 100644
index 0000000..bdffdde
--- /dev/null
+++ b/clang/test/Headers/x86-intrinsics-headers.c
@@ -0,0 +1,15 @@
+// RUN: %clang -fsyntax-only -ffreestanding %s
+// RUN: %clang -fsyntax-only -ffreestanding -fno-lax-vector-conversions %s
+// RUN: %clangxx -fsyntax-only -ffreestanding -x c++ %s
+
+#if defined(i386) || defined(__x86_64__)
+
+#ifdef __SSE4_2__
+// nmmintrin forwards to smmintrin.
+#include <nmmintrin.h>
+#endif
+
+// immintrin includes all other intel intrinsic headers.
+#include <immintrin.h>
+
+#endif
diff --git a/clang/test/Index/IBOutletCollection.m b/clang/test/Index/IBOutletCollection.m
new file mode 100644
index 0000000..a95df86
--- /dev/null
+++ b/clang/test/Index/IBOutletCollection.m
@@ -0,0 +1,18 @@
+#define IBOutletCollection(ClassName) __attribute__((iboutletcollection(ClassName)))
+
+@interface Test {
+ IBOutletCollection(Test) Test *anOutletCollection;
+}
+@end
+
+// RUN: c-index-test -cursor-at=%s:4:24 %s | FileCheck -check-prefix=CHECK-CURSOR %s
+// CHECK-CURSOR: ObjCClassRef=Test:3:12
+
+// RUN: c-index-test -test-annotate-tokens=%s:4:1:5:1 %s | FileCheck -check-prefix=CHECK-TOK %s
+// CHECK-TOK: Identifier: "IBOutletCollection" [4:3 - 4:21] macro expansion=IBOutletCollection:1:9
+// CHECK-TOK: Punctuation: "(" [4:21 - 4:22] ObjCInterfaceDecl=Test:3:12
+// CHECK-TOK: Identifier: "Test" [4:22 - 4:26] ObjCClassRef=Test:3:12
+// CHECK-TOK: Punctuation: ")" [4:26 - 4:27] ObjCIvarDecl=anOutletCollection:4:34 (Definition)
+// CHECK-TOK: Identifier: "Test" [4:28 - 4:32] ObjCClassRef=Test:3:12
+// CHECK-TOK: Punctuation: "*" [4:33 - 4:34] ObjCIvarDecl=anOutletCollection:4:34 (Definition)
+// CHECK-TOK: Identifier: "anOutletCollection" [4:34 - 4:52] ObjCIvarDecl=anOutletCollection:4:34 (Definition)
diff --git a/clang/test/Index/Inputs/Frameworks/Framework.framework/Headers/Framework.h b/clang/test/Index/Inputs/Frameworks/Framework.framework/Headers/Framework.h
new file mode 100644
index 0000000..3e3830a
--- /dev/null
+++ b/clang/test/Index/Inputs/Frameworks/Framework.framework/Headers/Framework.h
@@ -0,0 +1,2 @@
+int *getFrameworkVersion();
+
diff --git a/clang/test/Index/Inputs/Headers/a.h b/clang/test/Index/Inputs/Headers/a.h
new file mode 100644
index 0000000..33c3417
--- /dev/null
+++ b/clang/test/Index/Inputs/Headers/a.h
@@ -0,0 +1,2 @@
+int *getA();
+
diff --git a/clang/test/Index/Inputs/Headers/a_extensions.h b/clang/test/Index/Inputs/Headers/a_extensions.h
new file mode 100644
index 0000000..2155787
--- /dev/null
+++ b/clang/test/Index/Inputs/Headers/a_extensions.h
@@ -0,0 +1 @@
+int *getAExtensions();
diff --git a/clang/test/Index/Inputs/Headers/crash.h b/clang/test/Index/Inputs/Headers/crash.h
new file mode 100644
index 0000000..238359a
--- /dev/null
+++ b/clang/test/Index/Inputs/Headers/crash.h
@@ -0,0 +1,6 @@
+// Produce a crash if CRASH is defined.
+#ifdef CRASH
+# pragma clang __debug crash
+#endif
+
+const char *getCrashString();
diff --git a/clang/test/Index/Inputs/Headers/module.map b/clang/test/Index/Inputs/Headers/module.map
new file mode 100644
index 0000000..55f8eb7
--- /dev/null
+++ b/clang/test/Index/Inputs/Headers/module.map
@@ -0,0 +1,10 @@
+module LibA {
+ header "a.h"
+ module Extensions {
+ header "a_extensions.h"
+ }
+}
+
+module Crash {
+ header "crash.h"
+}
diff --git a/clang/test/Index/Inputs/Headers/nested/module.map b/clang/test/Index/Inputs/Headers/nested/module.map
new file mode 100644
index 0000000..bd239f1
--- /dev/null
+++ b/clang/test/Index/Inputs/Headers/nested/module.map
@@ -0,0 +1,4 @@
+module nested {
+ header "nested.h"
+}
+
diff --git a/clang/test/Index/Inputs/Headers/nested/nested.h b/clang/test/Index/Inputs/Headers/nested/nested.h
new file mode 100644
index 0000000..01716d1
--- /dev/null
+++ b/clang/test/Index/Inputs/Headers/nested/nested.h
@@ -0,0 +1 @@
+int *getNested();
diff --git a/clang/test/Index/Inputs/a.h b/clang/test/Index/Inputs/a.h
new file mode 100644
index 0000000..70ace8c
--- /dev/null
+++ b/clang/test/Index/Inputs/a.h
@@ -0,0 +1,4 @@
+#ifndef A_H
+#define A_H
+typedef int A;
+#endif
diff --git a/clang/test/Index/Inputs/b.h b/clang/test/Index/Inputs/b.h
new file mode 100644
index 0000000..02591d2
--- /dev/null
+++ b/clang/test/Index/Inputs/b.h
@@ -0,0 +1 @@
+typedef float B;
diff --git a/clang/test/Index/Inputs/c-index-pch.h b/clang/test/Index/Inputs/c-index-pch.h
new file mode 100644
index 0000000..6dda180
--- /dev/null
+++ b/clang/test/Index/Inputs/c-index-pch.h
@@ -0,0 +1,7 @@
+#ifndef C_INDEX_PCH_H
+#define C_INDEX_PCH_H
+
+void foo(int i, float f);
+extern int bar;
+
+#endif // C_INDEX_PCH_H
diff --git a/clang/test/Index/Inputs/cindex-from-source.h b/clang/test/Index/Inputs/cindex-from-source.h
new file mode 100644
index 0000000..d13d397
--- /dev/null
+++ b/clang/test/Index/Inputs/cindex-from-source.h
@@ -0,0 +1 @@
+typedef int t0;
diff --git a/clang/test/Index/Inputs/complete-pch.h b/clang/test/Index/Inputs/complete-pch.h
new file mode 100644
index 0000000..ddf5253
--- /dev/null
+++ b/clang/test/Index/Inputs/complete-pch.h
@@ -0,0 +1,10 @@
+@interface A
+- (int)instanceMethod1:(int)x;
++ (int)classMethod1:(double)d;
+@end
+
+@interface B
+- (int)instanceMethod2:(int)x;
++ (int)classMethod2:(float)f;
+@end
+
diff --git a/clang/test/Index/Inputs/crash-recovery-code-complete-remap.c b/clang/test/Index/Inputs/crash-recovery-code-complete-remap.c
new file mode 100644
index 0000000..50a8658
--- /dev/null
+++ b/clang/test/Index/Inputs/crash-recovery-code-complete-remap.c
@@ -0,0 +1,12 @@
+// RUN: echo env CINDEXTEST_EDITING=1 \
+// RUN: not c-index-test -test-load-source-reparse 1 local \
+// RUN: -remap-file="%s;%S/Inputs/crash-recovery-code-complete-remap.c" \
+// RUN: %s 2> %t.err
+// RUN: FileCheck < %t.err -check-prefix=CHECK-CODE-COMPLETE-CRASH %s
+// CHECK-CODE-COMPLETE-CRASH: Unable to reparse translation unit
+//
+// XFAIL: win32
+
+#warning parsing original file
+
+#pragma clang __debug crash
diff --git a/clang/test/Index/Inputs/crash-recovery-reparse-remap.c b/clang/test/Index/Inputs/crash-recovery-reparse-remap.c
new file mode 100644
index 0000000..0357dbe
--- /dev/null
+++ b/clang/test/Index/Inputs/crash-recovery-reparse-remap.c
@@ -0,0 +1,11 @@
+
+#warning parsing remapped file
+
+
+
+int x;
+
+#pragma clang __debug crash
+
+int x;
+
diff --git a/clang/test/Index/Inputs/foo.h b/clang/test/Index/Inputs/foo.h
new file mode 100644
index 0000000..7670c00
--- /dev/null
+++ b/clang/test/Index/Inputs/foo.h
@@ -0,0 +1,8 @@
+extern int global_var;
+
+void foo_func(int param1);
+void bar_func(void);
+
+struct MyStruct {
+ int field_var;
+};
diff --git a/clang/test/Index/Inputs/get-cursor-includes-1.h b/clang/test/Index/Inputs/get-cursor-includes-1.h
new file mode 100644
index 0000000..48439d2
--- /dev/null
+++ b/clang/test/Index/Inputs/get-cursor-includes-1.h
@@ -0,0 +1,6 @@
+#ifndef GET_CURSOR_INCLUDES_1_H
+#define GET_CURSOR_INCLUDES_1_H
+
+extern int blah;
+
+#endif // GET_CURSOR_INCLUDES_1_H
diff --git a/clang/test/Index/Inputs/get-cursor-includes-2.h b/clang/test/Index/Inputs/get-cursor-includes-2.h
new file mode 100644
index 0000000..cf95c18
--- /dev/null
+++ b/clang/test/Index/Inputs/get-cursor-includes-2.h
@@ -0,0 +1,2 @@
+#include "get-cursor-includes-1.h"
+#include "get-cursor-includes-1.h"
diff --git a/clang/test/Index/Inputs/guarded.h b/clang/test/Index/Inputs/guarded.h
new file mode 100644
index 0000000..0a1a6ac
--- /dev/null
+++ b/clang/test/Index/Inputs/guarded.h
@@ -0,0 +1,6 @@
+#ifndef GUARDED_HEADER_H
+#define GUARDED_HEADER_H
+
+int y;
+
+#endif // GUARDED_HEADER_H
diff --git a/clang/test/Index/Inputs/lit.local.cfg b/clang/test/Index/Inputs/lit.local.cfg
new file mode 100644
index 0000000..e6f55ee
--- /dev/null
+++ b/clang/test/Index/Inputs/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = []
diff --git a/clang/test/Index/Inputs/objc.h b/clang/test/Index/Inputs/objc.h
new file mode 100644
index 0000000..c671add
--- /dev/null
+++ b/clang/test/Index/Inputs/objc.h
@@ -0,0 +1,11 @@
+@interface Base {
+ int my_var;
+}
+-(int) my_var;
+-(void) my_method: (int)param;
++(void) my_method: (int)param;
+@end
+
+@interface Sub : Base
+-(void) my_method: (int)param;
+@end
diff --git a/clang/test/Index/Inputs/pragma-once.h b/clang/test/Index/Inputs/pragma-once.h
new file mode 100644
index 0000000..503cb3f
--- /dev/null
+++ b/clang/test/Index/Inputs/pragma-once.h
@@ -0,0 +1,3 @@
+#pragma once
+int i;
+
diff --git a/clang/test/Index/Inputs/pragma_disable_warning.h b/clang/test/Index/Inputs/pragma_disable_warning.h
new file mode 100644
index 0000000..b40e9e7
--- /dev/null
+++ b/clang/test/Index/Inputs/pragma_disable_warning.h
@@ -0,0 +1 @@
+#pragma clang diagnostic ignored "-Wunused-parameter"
diff --git a/clang/test/Index/Inputs/preamble-reparse-1.c b/clang/test/Index/Inputs/preamble-reparse-1.c
new file mode 100644
index 0000000..139597f
--- /dev/null
+++ b/clang/test/Index/Inputs/preamble-reparse-1.c
@@ -0,0 +1,2 @@
+
+
diff --git a/clang/test/Index/Inputs/preamble-reparse-2.c b/clang/test/Index/Inputs/preamble-reparse-2.c
new file mode 100644
index 0000000..6d1a0d4
--- /dev/null
+++ b/clang/test/Index/Inputs/preamble-reparse-2.c
@@ -0,0 +1 @@
+int x;
diff --git a/clang/test/Index/Inputs/preamble.h b/clang/test/Index/Inputs/preamble.h
new file mode 100644
index 0000000..b59c234
--- /dev/null
+++ b/clang/test/Index/Inputs/preamble.h
@@ -0,0 +1,6 @@
+inline int bar(int i) {
+ int *ptr = 0;
+ float *ptr1;
+ ptr = ptr1;
+ return 0;
+}
diff --git a/clang/test/Index/Inputs/preamble_macro_template.h b/clang/test/Index/Inputs/preamble_macro_template.h
new file mode 100644
index 0000000..18b076d
--- /dev/null
+++ b/clang/test/Index/Inputs/preamble_macro_template.h
@@ -0,0 +1,6 @@
+#define STATIC_CAST static_cast
+
+template<typename T>
+void foo(T *p) {
+ (void)STATIC_CAST<T*>(0);
+}
diff --git a/clang/test/Index/Inputs/prefix.h b/clang/test/Index/Inputs/prefix.h
new file mode 100644
index 0000000..82ba2da
--- /dev/null
+++ b/clang/test/Index/Inputs/prefix.h
@@ -0,0 +1,4 @@
+#ifndef PREFIX_H
+#define PREFIX_H
+int foo(int);
+#endif
diff --git a/clang/test/Index/Inputs/redeclarations.h b/clang/test/Index/Inputs/redeclarations.h
new file mode 100644
index 0000000..7f0d7ae
--- /dev/null
+++ b/clang/test/Index/Inputs/redeclarations.h
@@ -0,0 +1,21 @@
+class X
+{
+ friend class A;
+};
+
+
+template <typename T1, typename T2>
+class B
+{
+};
+
+template <class T>
+struct C
+{
+};
+
+class D
+{
+ B<D, class A> x;
+ friend struct C<A>;
+};
diff --git a/clang/test/Index/Inputs/remap-complete-to.c b/clang/test/Index/Inputs/remap-complete-to.c
new file mode 100644
index 0000000..30199db
--- /dev/null
+++ b/clang/test/Index/Inputs/remap-complete-to.c
@@ -0,0 +1,6 @@
+int f0(int *pointer1, float *pointer2) {
+ return pointer2 - pointer1;
+}
+
+void g() {
+
diff --git a/clang/test/Index/Inputs/remap-load-to.c b/clang/test/Index/Inputs/remap-load-to.c
new file mode 100644
index 0000000..8f9e1eb
--- /dev/null
+++ b/clang/test/Index/Inputs/remap-load-to.c
@@ -0,0 +1,3 @@
+int foo(int parm1, float parm2) {
+ return parm1 + parm2;
+}
diff --git a/clang/test/Index/Inputs/reparse-instantiate.h b/clang/test/Index/Inputs/reparse-instantiate.h
new file mode 100644
index 0000000..df90a6d
--- /dev/null
+++ b/clang/test/Index/Inputs/reparse-instantiate.h
@@ -0,0 +1,14 @@
+template <typename T> struct S;
+
+template<typename T> void c(T)
+{
+}
+
+template <> struct S <int>
+{
+ void a()
+ {
+ c(&S<int>::b);
+ }
+ void b() {}
+};
diff --git a/clang/test/Index/Inputs/t1.c b/clang/test/Index/Inputs/t1.c
new file mode 100644
index 0000000..ceaad4c
--- /dev/null
+++ b/clang/test/Index/Inputs/t1.c
@@ -0,0 +1,28 @@
+#include "foo.h"
+
+void foo_func(int param1) {
+ int local_var = global_var;
+ for (int for_var = 100; for_var < 500; ++for_var) {
+ local_var = param1 + for_var;
+ }
+ bar_func();
+}
+
+struct S1 {
+ int x;
+};
+
+struct S2 {
+ int x;
+};
+
+void field_test(void) {
+ struct S1 s1;
+ s1.x = 0;
+ ((struct S2 *)0)->x = 0;
+
+ struct MyStruct ms;
+ ms.field_var = 10;
+}
+
+int (^CP)(int) = ^(int x) { return x * global_var; };
diff --git a/clang/test/Index/Inputs/t1.m b/clang/test/Index/Inputs/t1.m
new file mode 100644
index 0000000..b7c86cd
--- /dev/null
+++ b/clang/test/Index/Inputs/t1.m
@@ -0,0 +1,20 @@
+#include "objc.h"
+
+static void foo() {
+ Base *base;
+ int x = [base my_var];
+ [base my_method:x];
+ [Base my_method:x];
+}
+
+@implementation Base
+-(int) my_var {
+ return my_var;
+}
+
+-(void) my_method: (int)param {
+}
+
++(void) my_method: (int)param {
+}
+@end
diff --git a/clang/test/Index/Inputs/t2.c b/clang/test/Index/Inputs/t2.c
new file mode 100644
index 0000000..76d5d6c
--- /dev/null
+++ b/clang/test/Index/Inputs/t2.c
@@ -0,0 +1,11 @@
+#include "foo.h"
+
+int global_var = 10;
+
+void bar_func(void) {
+ global_var += 100;
+ foo_func(global_var);
+
+ struct MyStruct *ms;
+ ms->field_var = 10;
+}
diff --git a/clang/test/Index/Inputs/t2.m b/clang/test/Index/Inputs/t2.m
new file mode 100644
index 0000000..3f103ee
--- /dev/null
+++ b/clang/test/Index/Inputs/t2.m
@@ -0,0 +1,13 @@
+#include "objc.h"
+
+static void foo() {
+ Sub *sub;
+ int x = [sub my_var];
+ [sub my_method:x];
+ [Sub my_method:x];
+}
+
+@implementation Sub
+-(void) my_method: (int)param {
+}
+@end
diff --git a/clang/test/Index/TestClassDecl.m b/clang/test/Index/TestClassDecl.m
new file mode 100644
index 0000000..038353b
--- /dev/null
+++ b/clang/test/Index/TestClassDecl.m
@@ -0,0 +1,33 @@
+// RUN: c-index-test -write-pch %t.ast -fobjc-nonfragile-abi -fblocks -x objective-c %s
+// RUN: c-index-test -test-file-scan %t.ast %s | FileCheck -check-prefix=scan %s
+// RUN: c-index-test -test-load-tu %t.ast local | FileCheck -check-prefix=load %s
+
+// This test checks how the @class resolves as a cursor when there is a real definition
+// that follows. <rdar://problem/7383421>
+
+@class Foo;
+
+@interface Foo
+@end
+
+void function(Foo * arg)
+{
+ // nothing here.
+}
+
+// CHECK-scan: [1:1 - 8:1] Invalid Cursor => NoDeclFound
+// CHECK-scan: [8:1 - 8:8] ObjCInterfaceDecl=Foo:8:8
+// CHECK-scan: [8:8 - 8:11] ObjCClassRef=Foo:10:12
+// CHECK-scan: [8:11 - 10:1] Invalid Cursor => NoDeclFound
+// CHECK-scan: [10:1 - 11:5] ObjCInterfaceDecl=Foo:10:12
+// CHECK-scan: [11:5 - 13:1] Invalid Cursor => NoDeclFound
+// CHECK-scan: [13:1 - 13:15] FunctionDecl=function:13:6 (Definition)
+// CHECK-scan: [13:15 - 13:18] ObjCClassRef=Foo:10:12
+// CHECK-scan: [13:18 - 13:24] ParmDecl=arg:13:21 (Definition)
+// CHECK-scan: [13:24 - 14:1] FunctionDecl=function:13:6 (Definition)
+// CHECK-scan: [14:1 - 16:2] CompoundStmt=
+
+// CHECK-load: TestClassDecl.m:10:12: ObjCInterfaceDecl=Foo:10:12 Extent=[10:1 - 11:5]
+// CHECK-load: TestClassDecl.m:13:6: FunctionDecl=function:13:6 (Definition) Extent=[13:1 - 16:2]
+// CHECK-load: TestClassDecl.m:13:21: ParmDecl=arg:13:21 (Definition) Extent=[13:15 - 13:24]
+
diff --git a/clang/test/Index/TestClassForwardDecl.m b/clang/test/Index/TestClassForwardDecl.m
new file mode 100644
index 0000000..2f32d33
--- /dev/null
+++ b/clang/test/Index/TestClassForwardDecl.m
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -emit-pch -x objective-c %s -o %t.ast
+// RUN: c-index-test -test-file-scan %t.ast %s | FileCheck -check-prefix=scan %s
+// RUN: c-index-test -test-load-tu %t.ast local | FileCheck -check-prefix=load %s
+
+// This test checks how the @class resolves as a cursor when the @interface is implicitly defined.
+// See TestClassDecl.m for the corresponding test case. (<rdar://problem/7383421>)
+
+@class Foo;
+
+void function(Foo * arg)
+{
+ // nothing here.
+}
+
+// CHECK-scan: [1:1 - 8:1] Invalid Cursor => NoDeclFound
+// CHECK-scan: [8:1 - 8:8] ObjCInterfaceDecl=Foo:8:8
+// CHECK-scan: [8:8 - 8:11] ObjCClassRef=Foo:8:8
+// CHECK-scan: [8:11 - 10:1] Invalid Cursor => NoDeclFound
+// CHECK-scan: [10:1 - 10:15] FunctionDecl=function:10:6 (Definition)
+// CHECK-scan: [10:15 - 10:18] ObjCClassRef=Foo:8:8
+// CHECK-scan: [10:18 - 10:24] ParmDecl=arg:10:21 (Definition)
+// CHECK-scan: [10:24 - 11:1] FunctionDecl=function:10:6 (Definition)
+// CHECK: [11:1 - 13:2] CompundStmt=
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+// CHECK-load: TestClassForwardDecl.m:10:6: FunctionDecl=function:10:6 (Definition)
+// CHECK-load: TestClassForwardDecl.m:10:21: ParmDecl=arg:10:21
+
diff --git a/clang/test/Index/annotate-attribute.cpp b/clang/test/Index/annotate-attribute.cpp
new file mode 100644
index 0000000..d822210
--- /dev/null
+++ b/clang/test/Index/annotate-attribute.cpp
@@ -0,0 +1,33 @@
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+
+class Test {
+public:
+ __attribute__((annotate("spiffy_method"))) void aMethod();
+
+public __attribute__((annotate("works"))):
+ void anotherMethod(); // annotation attribute should be propagated.
+
+private __attribute__((annotate("investigations"))):
+ //propagated annotation should have changed from "works" to "investigations"
+ void inlineMethod() {}
+
+protected:
+ // attribute propagation should have stopped here
+ void methodWithoutAttribute();
+};
+
+// CHECK: ClassDecl=Test:3:7 (Definition) Extent=[3:1 - 17:2]
+// CHECK-NEXT: CXXAccessSpecifier=:4:1 (Definition) Extent=[4:1 - 4:8]
+// CHECK-NEXT: CXXMethod=aMethod:5:51 Extent=[5:3 - 5:60]
+// CHECK-NEXT: attribute(annotate)=spiffy_method Extent=[5:18 - 5:43]
+// CHECK-NEXT: CXXAccessSpecifier=:7:1 (Definition) Extent=[7:1 - 7:43]
+// CHECK-NEXT: attribute(annotate)=works Extent=[7:23 - 7:40]
+// CHECK-NEXT: CXXMethod=anotherMethod:8:8 Extent=[8:3 - 8:23]
+// CHECK-NEXT: attribute(annotate)=works Extent=[7:23 - 7:40]
+// CHECK-NEXT: CXXAccessSpecifier=:10:1 (Definition) Extent=[10:1 - 10:53]
+// CHECK-NEXT: attribute(annotate)=investigations Extent=[10:24 - 10:50]
+// CHECK-NEXT: CXXMethod=inlineMethod:12:8 (Definition) Extent=[12:3 - 12:25]
+// CHECK-NEXT: attribute(annotate)=investigations Extent=[10:24 - 10:50]
+// CHECK-NEXT: CompoundStmt= Extent=[12:23 - 12:25]
+// CHECK-NEXT: CXXAccessSpecifier=:14:1 (Definition) Extent=[14:1 - 14:11]
+// CHECK-NEXT: CXXMethod=methodWithoutAttribute:16:8 Extent=[16:3 - 16:32]
diff --git a/clang/test/Index/annotate-context-sensitive.cpp b/clang/test/Index/annotate-context-sensitive.cpp
new file mode 100644
index 0000000..34e67a2
--- /dev/null
+++ b/clang/test/Index/annotate-context-sensitive.cpp
@@ -0,0 +1,42 @@
+class Base {
+public:
+ virtual void f();
+};
+
+class Derived final : public Base {
+ virtual void f() override final;
+
+ struct final { };
+};
+
+typedef int override;
+struct Base2 {
+ virtual int override();
+};
+
+struct Derived2 : Base2 {
+ ::override override() override;
+};
+
+// RUN: c-index-test -test-annotate-tokens=%s:6:1:19:1 %s | FileCheck -check-prefix=CHECK-OVERRIDE-FINAL %s
+
+// CHECK-OVERRIDE-FINAL: Keyword: "class" [6:1 - 6:6] ClassDecl=Derived:6:7 (Definition)
+// CHECK-OVERRIDE-FINAL: Identifier: "Derived" [6:7 - 6:14] ClassDecl=Derived:6:7 (Definition)
+// CHECK-OVERRIDE-FINAL: Keyword: "final" [6:15 - 6:20] attribute(final)=
+// CHECK-OVERRIDE-FINAL: Punctuation: ":" [6:21 - 6:22] ClassDecl=Derived:6:7 (Definition)
+// CHECK-OVERRIDE-FINAL: Keyword: "public" [6:23 - 6:29] C++ base class specifier=class Base:1:7 [access=public isVirtual=false]
+// CHECK-OVERRIDE-FINAL: Identifier: "Base" [6:30 - 6:34] TypeRef=class Base:1:7
+// CHECK-OVERRIDE-FINAL: Punctuation: "{" [6:35 - 6:36] ClassDecl=Derived:6:7 (Definition)
+// CHECK-OVERRIDE-FINAL: Keyword: "virtual" [7:3 - 7:10] ClassDecl=Derived:6:7 (Definition)
+// CHECK-OVERRIDE-FINAL: Keyword: "void" [7:11 - 7:15] CXXMethod=f:7:16 (virtual) [Overrides @3:16]
+// CHECK-OVERRIDE-FINAL: Identifier: "f" [7:16 - 7:17] CXXMethod=f:7:16 (virtual) [Overrides @3:16]
+// CHECK-OVERRIDE-FINAL: Punctuation: "(" [7:17 - 7:18] CXXMethod=f:7:16 (virtual) [Overrides @3:16]
+// CHECK-OVERRIDE-FINAL: Punctuation: ")" [7:18 - 7:19] CXXMethod=f:7:16 (virtual) [Overrides @3:16]
+// CHECK-OVERRIDE-FINAL: Keyword: "override" [7:20 - 7:28] attribute(override)=
+// CHECK-OVERRIDE-FINAL: Keyword: "final" [7:29 - 7:34] attribute(final)=
+// CHECK-OVERRIDE-FINAL: Punctuation: ";" [7:34 - 7:35] ClassDecl=Derived:6:7 (Definition)
+// CHECK-OVERRIDE-FINAL: Keyword: "struct" [9:3 - 9:9] StructDecl=final:9:10 (Definition)
+// CHECK-OVERRIDE-FINAL: Identifier: "final" [9:10 - 9:15] StructDecl=final:9:10 (Definition)
+// CHECK-OVERRIDE-FINAL: Punctuation: "{" [9:16 - 9:17] StructDecl=final:9:10 (Definition)
+// CHECK-OVERRIDE-FINAL: Punctuation: "}" [9:18 - 9:19] StructDecl=final:9:10 (Definition)
+// CHECK-OVERRIDE-FINAL: Punctuation: ";" [9:19 - 9:20] ClassDecl=Derived:6:7 (Definition)
diff --git a/clang/test/Index/annotate-literals.m b/clang/test/Index/annotate-literals.m
new file mode 100644
index 0000000..20bfd2c
--- /dev/null
+++ b/clang/test/Index/annotate-literals.m
@@ -0,0 +1,72 @@
+typedef unsigned char BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
++ (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;
+@end
+
+@interface NSArray
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+void test_literals(id k1, id o1, id k2, id o2, id k3) {
+ id objects = @[ o1, o2 ];
+ id dict = @{ k1 : o1,
+ k2 : o2,
+ k3 : @17 };
+}
+
+
+// RUN: c-index-test -test-annotate-tokens=%s:33:1:37:1 %s | FileCheck -check-prefix=CHECK-LITERALS %s
+
+// CHECK-LITERALS: Identifier: "id" [33:3 - 33:5] TypeRef=id:0:0
+// CHECK-LITERALS: Identifier: "objects" [33:6 - 33:13] VarDecl=objects:33:6 (Definition)
+// CHECK-LITERALS: Punctuation: "=" [33:14 - 33:15] VarDecl=objects:33:6 (Definition)
+// CHECK-LITERALS: Punctuation: "@" [33:16 - 33:17] UnexposedExpr=
+// CHECK-LITERALS: Punctuation: "[" [33:17 - 33:18] UnexposedExpr=
+// CHECK-LITERALS: Identifier: "o1" [33:19 - 33:21] DeclRefExpr=o1:32:30
+// CHECK-LITERALS: Punctuation: "," [33:21 - 33:22] UnexposedExpr=
+// CHECK-LITERALS: Identifier: "o2" [33:23 - 33:25] DeclRefExpr=o2:32:44
+// CHECK-LITERALS: Punctuation: "]" [33:26 - 33:27] UnexposedExpr=
+// CHECK-LITERALS: Punctuation: ";" [33:27 - 33:28] DeclStmt=
+// CHECK-LITERALS: Identifier: "id" [34:3 - 34:5] TypeRef=id:0:0
+// CHECK-LITERALS: Identifier: "dict" [34:6 - 34:10] VarDecl=dict:34:6 (Definition)
+// CHECK-LITERALS: Punctuation: "=" [34:11 - 34:12] VarDecl=dict:34:6 (Definition)
+// CHECK-LITERALS: Punctuation: "@" [34:13 - 34:14] UnexposedExpr=
+// CHECK-LITERALS: Punctuation: "{" [34:14 - 34:15] UnexposedExpr=
+// CHECK-LITERALS: Identifier: "k1" [34:16 - 34:18] DeclRefExpr=k1:32:23
+// CHECK-LITERALS: Punctuation: ":" [34:19 - 34:20] UnexposedExpr=
+// CHECK-LITERALS: Identifier: "o1" [34:21 - 34:23] DeclRefExpr=o1:32:30
+// CHECK-LITERALS: Punctuation: "," [34:23 - 34:24] UnexposedExpr=
+// CHECK-LITERALS: Identifier: "k2" [35:16 - 35:18] DeclRefExpr=k2:32:37
+// CHECK-LITERALS: Punctuation: ":" [35:19 - 35:20] UnexposedExpr=
+// CHECK-LITERALS: Identifier: "o2" [35:21 - 35:23] DeclRefExpr=o2:32:44
+// CHECK-LITERALS: Punctuation: "," [35:23 - 35:24] UnexposedExpr=
+// CHECK-LITERALS: Identifier: "k3" [36:16 - 36:18] DeclRefExpr=k3:32:51
+// CHECK-LITERALS: Punctuation: ":" [36:19 - 36:20] UnexposedExpr=
+// CHECK-LITERALS: Punctuation: "@" [36:21 - 36:22] UnexposedExpr=
+// CHECK-LITERALS: Literal: "17" [36:22 - 36:24] IntegerLiteral=
+// CHECK-LITERALS: Punctuation: "}" [36:25 - 36:26] UnexposedExpr=
+// CHECK-LITERALS: Punctuation: ";" [36:26 - 36:27] DeclStmt=
+// CHECK-LITERALS: Punctuation: "}" [37:1 - 37:2] CompoundStmt=
+
diff --git a/clang/test/Index/annotate-macro-args.h b/clang/test/Index/annotate-macro-args.h
new file mode 100644
index 0000000..40ec8dc
--- /dev/null
+++ b/clang/test/Index/annotate-macro-args.h
@@ -0,0 +1,16 @@
+@interface MyClass
++(void)meth;
+@end
+
+#define MACRO2(x) x
+#define MACRO(x) MACRO2(x)
+
+void test() {
+ MACRO([MyClass meth]);
+}
+
+#define INVOKE(METHOD, CLASS) [CLASS METHOD]
+
+void test2() {
+ INVOKE(meth, MyClass);
+}
diff --git a/clang/test/Index/annotate-macro-args.m b/clang/test/Index/annotate-macro-args.m
new file mode 100644
index 0000000..b92c0b2
--- /dev/null
+++ b/clang/test/Index/annotate-macro-args.m
@@ -0,0 +1,23 @@
+// Test without PCH
+// RUN: c-index-test -test-annotate-tokens=%S/annotate-macro-args.h:9:1:10:1 %s -include annotate-macro-args.h | FileCheck -check-prefix=CHECK1 %s
+// RUN: c-index-test -test-annotate-tokens=%S/annotate-macro-args.h:15:1:16:1 %s -include annotate-macro-args.h | FileCheck -check-prefix=CHECK2 %s
+
+// Test with PCH
+// RUN: c-index-test -write-pch %t.pch -x objective-c-header %S/annotate-macro-args.h -Xclang -detailed-preprocessing-record
+// RUN: c-index-test -test-annotate-tokens=%S/annotate-macro-args.h:9:1:10:1 %s -include-pch %t.pch | FileCheck -check-prefix=CHECK1 %s
+// RUN: c-index-test -test-annotate-tokens=%S/annotate-macro-args.h:15:1:16:1 %s -include-pch %t.pch | FileCheck -check-prefix=CHECK2 %s
+
+// CHECK1: Identifier: "MACRO" [9:3 - 9:8] macro expansion=MACRO:6:9
+// CHECK1: Punctuation: "(" [9:8 - 9:9]
+// CHECK1: Punctuation: "[" [9:9 - 9:10] ObjCMessageExpr=meth:2:8
+// CHECK1: Identifier: "MyClass" [9:10 - 9:17] ObjCClassRef=MyClass:1:12
+// CHECK1: Identifier: "meth" [9:18 - 9:22] ObjCMessageExpr=meth:2:8
+// CHECK1: Punctuation: "]" [9:22 - 9:23] ObjCMessageExpr=meth:2:8
+// CHECK1: Punctuation: ")" [9:23 - 9:24]
+
+// CHECK2: Identifier: "INVOKE" [15:3 - 15:9] macro expansion=INVOKE:12:9
+// CHECK2: Punctuation: "(" [15:9 - 15:10]
+// CHECK2: Identifier: "meth" [15:10 - 15:14] ObjCMessageExpr=meth:2:8
+// CHECK2: Punctuation: "," [15:14 - 15:15]
+// CHECK2: Identifier: "MyClass" [15:16 - 15:23] ObjCClassRef=MyClass:1:12
+// CHECK2: Punctuation: ")" [15:23 - 15:24]
diff --git a/clang/test/Index/annotate-nested-name-specifier.cpp b/clang/test/Index/annotate-nested-name-specifier.cpp
new file mode 100644
index 0000000..c4f60e3
--- /dev/null
+++ b/clang/test/Index/annotate-nested-name-specifier.cpp
@@ -0,0 +1,466 @@
+namespace outer {
+ namespace inner {
+ template<typename T>
+ struct vector {
+ typedef T* iterator;
+ };
+ }
+}
+
+namespace outer_alias = outer;
+
+struct X { };
+
+using outer_alias::inner::vector;
+
+struct X_vector : outer_alias::inner::vector<X> {
+ using outer_alias::inner::vector<X>::iterator;
+};
+
+namespace outer {
+ namespace inner {
+ template<typename T, unsigned N>
+ struct array {
+ void foo();
+ static int max_size;
+ };
+ }
+}
+
+template<typename T, unsigned N>
+void outer::inner::array<T, N>::foo() {
+}
+
+template<typename T, unsigned N>
+int outer::inner::array<T, N>::max_size = 17;
+
+template<typename T>
+struct X2 : outer::inner::vector<T> {
+ typedef T type;
+ using typename outer::inner::vector<type>::iterator;
+ using outer::inner::vector<type>::push_back;
+};
+
+namespace outer {
+ namespace inner {
+ namespace secret {
+ }
+ }
+}
+
+using namespace outer_alias::inner::secret;
+namespace super_secret = outer_alias::inner::secret;
+
+template<typename T>
+struct X3 {
+ void f(T *t) {
+ t->::outer_alias::inner::template vector<T>::~vector<T>();
+ }
+};
+
+namespace outer {
+ namespace inner {
+ void f(int);
+ void f(double);
+ }
+}
+
+template<typename T>
+struct X4 {
+ typedef T type;
+ void g(int);
+ void g(float);
+
+ void h(T t) {
+ ::outer_alias::inner::f(t);
+ ::X4<type>::g(t);
+ this->::X4<type>::g(t);
+ }
+};
+
+typedef int Integer;
+template<>
+struct X4<Integer> {
+ typedef Integer type;
+
+ void g(int);
+ void g(float);
+
+ void h(type t) {
+ ::outer_alias::inner::f(t);
+ ::X4<type>::g(t);
+ this->::X4<type>::g(t);
+ }
+};
+
+
+template<typename T>
+struct X5 {
+ typedef T type;
+ typedef typename outer_alias::inner::vector<type>::iterator iter_type;
+ typedef typename outer_alias::inner::vector<int>::iterator int_ptr_type;
+};
+
+template<typename T>
+struct X6 {
+ typedef T* type;
+ typedef typename outer_alias::inner::vector<type>::template rebind<type> type1;
+ typedef typename outer_alias::inner::vector<type>::template rebind<type>::other type2;
+ typedef class outer_alias::inner::vector<type>::template rebind<type> type3;
+ typedef class outer_alias::inner::vector<type>::template rebind<type>::other type4;
+};
+
+namespace outer {
+ namespace inner {
+ template<typename T, template<class> class TT>
+ struct apply_meta {
+ typedef typename TT<T>::type type;
+ };
+ }
+}
+
+template<typename T, typename U>
+struct X7 {
+ typedef T T_type;
+ typedef U U_type;
+ typedef outer_alias::inner::apply_meta<T_type, U_type::template apply> type;
+};
+
+struct X8 {
+ void f();
+};
+
+struct X9 : X8 {
+ typedef X8 inherited;
+ void f() {
+ inherited::f();
+ }
+};
+
+// RUN: c-index-test -test-annotate-tokens=%s:13:1:137:1 -fno-delayed-template-parsing %s | FileCheck %s
+
+// CHECK: Keyword: "using" [14:1 - 14:6] UsingDeclaration=vector[4:12]
+// CHECK: Identifier: "outer_alias" [14:7 - 14:18] NamespaceRef=outer_alias:10:11
+// CHECK: Punctuation: "::" [14:18 - 14:20] UsingDeclaration=vector[4:12]
+// CHECK: Identifier: "inner" [14:20 - 14:25] NamespaceRef=inner:2:13
+// CHECK: Punctuation: "::" [14:25 - 14:27] UsingDeclaration=vector[4:12]
+// CHECK: Identifier: "vector" [14:27 - 14:33] OverloadedDeclRef=vector[4:12]
+// CHECK: Punctuation: ";" [14:33 - 14:34]
+
+// Base specifiers
+// CHECK: Identifier: "outer_alias" [16:19 - 16:30] NamespaceRef=outer_alias:10:11
+// CHECK: Punctuation: "::" [16:30 - 16:32] C++ base class specifier=outer_alias::inner::vector<X>:4:12 [access=public isVirtual=false]
+// CHECK: Identifier: "inner" [16:32 - 16:37] NamespaceRef=inner:2:13
+// CHECK: Punctuation: "::" [16:37 - 16:39] C++ base class specifier=outer_alias::inner::vector<X>:4:12 [access=public isVirtual=false]
+// CHECK: Identifier: "vector" [16:39 - 16:45] TemplateRef=vector:4:12
+// CHECK: Punctuation: "<" [16:45 - 16:46] C++ base class specifier=outer_alias::inner::vector<X>:4:12 [access=public isVirtual=false]
+// CHECK: Identifier: "X" [16:46 - 16:47] TypeRef=struct X:12:8
+// CHECK: Punctuation: ">" [16:47 - 16:48] C++ base class specifier=outer_alias::inner::vector<X>:4:12 [access=public isVirtual=false]
+
+
+// CHECK: Keyword: "using" [17:3 - 17:8] UsingDeclaration=iterator[5:18]
+// CHECK: Identifier: "outer_alias" [17:9 - 17:20] NamespaceRef=outer_alias:10:11
+// CHECK: Punctuation: "::" [17:20 - 17:22] UsingDeclaration=iterator[5:18]
+// CHECK: Identifier: "inner" [17:22 - 17:27] NamespaceRef=inner:2:13
+// CHECK: Punctuation: "::" [17:27 - 17:29] UsingDeclaration=iterator[5:18]
+// CHECK: Identifier: "vector" [17:29 - 17:35] TemplateRef=vector:4:12
+// CHECK: Punctuation: "<" [17:35 - 17:36] UsingDeclaration=iterator[5:18]
+// CHECK: Identifier: "X" [17:36 - 17:37] TypeRef=struct X:12:8
+// CHECK: Punctuation: ">" [17:37 - 17:38] UsingDeclaration=iterator[5:18]
+// CHECK: Punctuation: "::" [17:38 - 17:40] UsingDeclaration=iterator[5:18]
+// CHECK: Identifier: "iterator" [17:40 - 17:48] OverloadedDeclRef=iterator[5:18]
+
+// CHECK: Keyword: "void" [31:1 - 31:5] CXXMethod=foo:31:33 (Definition)
+// CHECK: Identifier: "outer" [31:6 - 31:11] NamespaceRef=outer:20:11
+// CHECK: Punctuation: "::" [31:11 - 31:13] CXXMethod=foo:31:33 (Definition)
+// CHECK: Identifier: "inner" [31:13 - 31:18] NamespaceRef=inner:21:13
+// CHECK: Punctuation: "::" [31:18 - 31:20] CXXMethod=foo:31:33 (Definition)
+// CHECK: Identifier: "array" [31:20 - 31:25] TemplateRef=array:23:12
+// CHECK: Punctuation: "<" [31:25 - 31:26] CXXMethod=foo:31:33 (Definition)
+// CHECK: Identifier: "T" [31:26 - 31:27] TypeRef=T:30:19
+// CHECK: Punctuation: "," [31:27 - 31:28] CXXMethod=foo:31:33 (Definition)
+// CHECK: Identifier: "N" [31:29 - 31:30] DeclRefExpr=N:30:31
+// CHECK: Punctuation: ">" [31:30 - 31:31] CXXMethod=foo:31:33 (Definition)
+// CHECK: Punctuation: "::" [31:31 - 31:33] CXXMethod=foo:31:33 (Definition)
+// CHECK: Identifier: "foo" [31:33 - 31:36] CXXMethod=foo:31:33 (Definition)
+// CHECK: Punctuation: "(" [31:36 - 31:37] CXXMethod=foo:31:33 (Definition)
+// CHECK: Punctuation: ")" [31:37 - 31:38] CXXMethod=foo:31:33 (Definition)
+
+// CHECK: Keyword: "int" [35:1 - 35:4] VarDecl=max_size:35:32 (Definition)
+// CHECK: Identifier: "outer" [35:5 - 35:10] NamespaceRef=outer:20:11
+// CHECK: Punctuation: "::" [35:10 - 35:12] VarDecl=max_size:35:32 (Definition)
+// CHECK: Identifier: "inner" [35:12 - 35:17] NamespaceRef=inner:21:13
+// CHECK: Punctuation: "::" [35:17 - 35:19] VarDecl=max_size:35:32 (Definition)
+// CHECK: Identifier: "array" [35:19 - 35:24] TemplateRef=array:23:12
+// CHECK: Punctuation: "<" [35:24 - 35:25] VarDecl=max_size:35:32 (Definition)
+// CHECK: Identifier: "T" [35:25 - 35:26] TypeRef=T:34:19
+// CHECK: Punctuation: "," [35:26 - 35:27] VarDecl=max_size:35:32 (Definition)
+// CHECK: Identifier: "N" [35:28 - 35:29] DeclRefExpr=N:34:31
+// CHECK: Punctuation: ">" [35:29 - 35:30] VarDecl=max_size:35:32 (Definition)
+// CHECK: Punctuation: "::" [35:30 - 35:32] VarDecl=max_size:35:32 (Definition)
+// CHECK: Identifier: "max_size" [35:32 - 35:40] VarDecl=max_size:35:32 (Definition)
+// CHECK: Punctuation: "=" [35:41 - 35:42] VarDecl=max_size:35:32 (Definition)
+// CHECK: Literal: "17" [35:43 - 35:45] IntegerLiteral=
+// CHECK: Punctuation: ";" [35:45 - 35:46]
+
+// CHECK: Keyword: "using" [40:3 - 40:8] UsingDeclaration=iterator:40:46
+// CHECK: Keyword: "typename" [40:9 - 40:17] UsingDeclaration=iterator:40:46
+// CHECK: Identifier: "outer" [40:18 - 40:23] NamespaceRef=outer:20:11
+// CHECK: Punctuation: "::" [40:23 - 40:25] UsingDeclaration=iterator:40:46
+// CHECK: Identifier: "inner" [40:25 - 40:30] NamespaceRef=inner:21:13
+// CHECK: Punctuation: "::" [40:30 - 40:32] UsingDeclaration=iterator:40:46
+// CHECK: Identifier: "vector" [40:32 - 40:38] TemplateRef=vector:4:12
+// CHECK: Punctuation: "<" [40:38 - 40:39] UsingDeclaration=iterator:40:46
+// CHECK: Identifier: "type" [40:39 - 40:43] TypeRef=type:39:13
+// CHECK: Punctuation: ">" [40:43 - 40:44] UsingDeclaration=iterator:40:46
+// CHECK: Punctuation: "::" [40:44 - 40:46] UsingDeclaration=iterator:40:46
+// CHECK: Identifier: "iterator" [40:46 - 40:54] UsingDeclaration=iterator:40:46
+// CHECK: Punctuation: ";" [40:54 - 40:55] ClassTemplate=X2:38:8 (Definition)
+// CHECK: Keyword: "using" [41:3 - 41:8] UsingDeclaration=push_back:41:37
+// CHECK: Identifier: "outer" [41:9 - 41:14] NamespaceRef=outer:20:11
+// CHECK: Punctuation: "::" [41:14 - 41:16] UsingDeclaration=push_back:41:37
+// CHECK: Identifier: "inner" [41:16 - 41:21] NamespaceRef=inner:21:13
+// CHECK: Punctuation: "::" [41:21 - 41:23] UsingDeclaration=push_back:41:37
+// CHECK: Identifier: "vector" [41:23 - 41:29] TemplateRef=vector:4:12
+// CHECK: Punctuation: "<" [41:29 - 41:30] UsingDeclaration=push_back:41:37
+// CHECK: Identifier: "type" [41:30 - 41:34] TypeRef=type:39:13
+// CHECK: Punctuation: ">" [41:34 - 41:35] UsingDeclaration=push_back:41:37
+// CHECK: Punctuation: "::" [41:35 - 41:37] UsingDeclaration=push_back:41:37
+// CHECK: Identifier: "push_back" [41:37 - 41:46] UsingDeclaration=push_back:41:37
+
+// Using directive
+// CHECK: Keyword: "using" [51:1 - 51:6] UsingDirective=:51:37
+// CHECK: Keyword: "namespace" [51:7 - 51:16] UsingDirective=:51:37
+// CHECK: Identifier: "outer_alias" [51:17 - 51:28] NamespaceRef=outer_alias:10:11
+// CHECK: Punctuation: "::" [51:28 - 51:30] UsingDirective=:51:37
+// CHECK: Identifier: "inner" [51:30 - 51:35] NamespaceRef=inner:45:13
+// CHECK: Punctuation: "::" [51:35 - 51:37] UsingDirective=:51:37
+// CHECK: Identifier: "secret" [51:37 - 51:43] NamespaceRef=secret:46:15
+
+// Namespace alias
+// CHECK: Keyword: "namespace" [52:1 - 52:10] NamespaceAlias=super_secret:52:11
+// CHECK: Identifier: "super_secret" [52:11 - 52:23] NamespaceAlias=super_secret:52:11
+// CHECK: Punctuation: "=" [52:24 - 52:25] NamespaceAlias=super_secret:52:11
+// CHECK: Identifier: "outer_alias" [52:26 - 52:37] NamespaceRef=outer_alias:10:11
+// CHECK: Punctuation: "::" [52:37 - 52:39] NamespaceAlias=super_secret:52:11
+// CHECK: Identifier: "inner" [52:39 - 52:44] NamespaceRef=inner:45:13
+// CHECK: Punctuation: "::" [52:44 - 52:46] NamespaceAlias=super_secret:52:11
+// CHECK: Identifier: "secret" [52:46 - 52:52] NamespaceRef=secret:46:15
+// CHECK: Punctuation: ";" [52:52 - 52:53]
+
+// Pseudo-destructor
+// CHECK: Identifier: "t" [57:5 - 57:6] DeclRefExpr=t:56:13
+// CHECK: Punctuation: "->" [57:6 - 57:8] MemberRefExpr=
+// CHECK: Punctuation: "::" [57:8 - 57:10] MemberRefExpr=
+// CHECK: Identifier: "outer_alias" [57:10 - 57:21] NamespaceRef=outer_alias:10:11
+// CHECK: Punctuation: "::" [57:21 - 57:23] MemberRefExpr=
+// CHECK: Identifier: "inner" [57:23 - 57:28] NamespaceRef=inner:45:13
+// CHECK: Punctuation: "::" [57:28 - 57:30] MemberRefExpr=
+// CHECK: Keyword: "template" [57:30 - 57:38] MemberRefExpr=
+// CHECK: Identifier: "vector" [57:39 - 57:45] TemplateRef=vector:4:12
+// CHECK: Punctuation: "<" [57:45 - 57:46] MemberRefExpr=
+// CHECK: Identifier: "T" [57:46 - 57:47] TypeRef=T:54:19
+// CHECK: Punctuation: ">" [57:47 - 57:48] MemberRefExpr=
+// CHECK: Punctuation: "::" [57:48 - 57:50] MemberRefExpr=
+// CHECK: Punctuation: "~" [57:50 - 57:51] MemberRefExpr=
+// CHECK: Identifier: "vector" [57:51 - 57:57] TemplateRef=vector:4:12
+// CHECK: Punctuation: "<" [57:57 - 57:58] MemberRefExpr=
+// CHECK: Identifier: "T" [57:58 - 57:59] TypeRef=T:54:19
+// CHECK: Punctuation: ">" [57:59 - 57:60] CallExpr=
+// CHECK: Punctuation: "(" [57:60 - 57:61] CallExpr=
+// CHECK: Punctuation: ")" [57:61 - 57:62] CallExpr=
+
+// Unresolved member and non-member references
+// CHECK: Punctuation: "::" [75:5 - 75:7] DeclRefExpr=[63:10, 64:10]
+// CHECK: Identifier: "outer_alias" [75:7 - 75:18] NamespaceRef=outer_alias:10:11
+// CHECK: Punctuation: "::" [75:18 - 75:20] DeclRefExpr=[63:10, 64:10]
+// CHECK: Identifier: "inner" [75:20 - 75:25] NamespaceRef=inner:62:13
+// CHECK: Punctuation: "::" [75:25 - 75:27] DeclRefExpr=[63:10, 64:10]
+// CHECK: Identifier: "f" [75:27 - 75:28] OverloadedDeclRef=f[63:10, 64:10]
+// CHECK: Punctuation: "(" [75:28 - 75:29] CallExpr=
+// CHECK: Identifier: "t" [75:29 - 75:30] DeclRefExpr=t:74:12
+// CHECK: Punctuation: ")" [75:30 - 75:31] CallExpr=
+// CHECK: Punctuation: "::" [76:5 - 76:7] MemberRefExpr=[71:8, 72:8]
+// CHECK: Identifier: "X4" [76:7 - 76:9] TemplateRef=X4:69:8
+// CHECK: Punctuation: "<" [76:9 - 76:10] MemberRefExpr=[71:8, 72:8]
+// CHECK: Identifier: "type" [76:10 - 76:14] TypeRef=type:70:13
+// CHECK: Punctuation: ">" [76:14 - 76:15] MemberRefExpr=[71:8, 72:8]
+// CHECK: Punctuation: "::" [76:15 - 76:17] MemberRefExpr=[71:8, 72:8]
+// CHECK: Identifier: "g" [76:17 - 76:18] OverloadedDeclRef=g[71:8, 72:8]
+// CHECK: Punctuation: "(" [76:18 - 76:19] CallExpr=
+// CHECK: Identifier: "t" [76:19 - 76:20] DeclRefExpr=t:74:12
+// CHECK: Punctuation: ")" [76:20 - 76:21] CallExpr=
+// CHECK: Punctuation: ";" [76:21 - 76:22] CompoundStmt=
+// CHECK: Keyword: "this" [77:5 - 77:9] CXXThisExpr=
+// CHECK: Punctuation: "->" [77:9 - 77:11] MemberRefExpr=
+// CHECK: Punctuation: "::" [77:11 - 77:13] MemberRefExpr=
+// CHECK: Identifier: "X4" [77:13 - 77:15] TemplateRef=X4:69:8
+// CHECK: Punctuation: "<" [77:15 - 77:16] MemberRefExpr=
+// CHECK: Identifier: "type" [77:16 - 77:20] TypeRef=type:70:13
+// CHECK: Punctuation: ">" [77:20 - 77:21] MemberRefExpr=
+// CHECK: Punctuation: "::" [77:21 - 77:23] MemberRefExpr=
+// CHECK: Identifier: "g" [77:23 - 77:24] MemberRefExpr=
+// CHECK: Punctuation: "(" [77:24 - 77:25] CallExpr=
+// CHECK: Identifier: "t" [77:25 - 77:26] DeclRefExpr=t:74:12
+// CHECK: Punctuation: ")" [77:26 - 77:27] CallExpr=
+
+// Resolved member and non-member references
+// CHECK: Punctuation: "::" [90:5 - 90:7] DeclRefExpr=f:63:10
+// CHECK: Identifier: "outer_alias" [90:7 - 90:18] NamespaceRef=outer_alias:10:11
+// CHECK: Punctuation: "::" [90:18 - 90:20] DeclRefExpr=f:63:10
+// CHECK: Identifier: "inner" [90:20 - 90:25] NamespaceRef=inner:62:13
+// CHECK: Punctuation: "::" [90:25 - 90:27] DeclRefExpr=f:63:10
+// CHECK: Identifier: "f" [90:27 - 90:28] DeclRefExpr=f:63:10
+// CHECK: Punctuation: "(" [90:28 - 90:29] CallExpr=f:63:10
+// CHECK: Identifier: "t" [90:29 - 90:30] DeclRefExpr=t:89:15
+// CHECK: Punctuation: ")" [90:30 - 90:31] CallExpr=f:63:10
+// CHECK: Punctuation: ";" [90:31 - 90:32] CompoundStmt=
+// CHECK: Punctuation: "::" [91:5 - 91:7] MemberRefExpr=g:86:8
+// CHECK: Identifier: "X4" [91:7 - 91:9] TemplateRef=X4:69:8
+// CHECK: Punctuation: "<" [91:9 - 91:10] MemberRefExpr=g:86:8
+// CHECK: Identifier: "type" [91:10 - 91:14] TypeRef=type:84:19
+// CHECK: Punctuation: ">" [91:14 - 91:15] MemberRefExpr=g:86:8
+// CHECK: Punctuation: "::" [91:15 - 91:17] MemberRefExpr=g:86:8
+// CHECK: Identifier: "g" [91:17 - 91:18] MemberRefExpr=g:86:8
+// CHECK: Punctuation: "(" [91:18 - 91:19] CallExpr=g:86:8
+// CHECK: Identifier: "t" [91:19 - 91:20] DeclRefExpr=t:89:15
+// CHECK: Punctuation: ")" [91:20 - 91:21] CallExpr=g:86:8
+// CHECK: Punctuation: ";" [91:21 - 91:22] CompoundStmt=
+// CHECK: Keyword: "this" [92:5 - 92:9] CXXThisExpr=
+// CHECK: Punctuation: "->" [92:9 - 92:11] MemberRefExpr=g:86:8
+// CHECK: Punctuation: "::" [92:11 - 92:13] MemberRefExpr=g:86:8
+// CHECK: Identifier: "X4" [92:13 - 92:15] TemplateRef=X4:69:8
+// CHECK: Punctuation: "<" [92:15 - 92:16] MemberRefExpr=g:86:8
+// CHECK: Identifier: "type" [92:16 - 92:20] TypeRef=type:84:19
+// CHECK: Punctuation: ">" [92:20 - 92:21] MemberRefExpr=g:86:8
+// CHECK: Punctuation: "::" [92:21 - 92:23] MemberRefExpr=g:86:8
+// CHECK: Identifier: "g" [92:23 - 92:24] MemberRefExpr=g:86:8
+// CHECK: Punctuation: "(" [92:24 - 92:25] CallExpr=g:86:8
+// CHECK: Identifier: "t" [92:25 - 92:26] DeclRefExpr=t:89:15
+// CHECK: Punctuation: ")" [92:26 - 92:27] CallExpr=g:86:8
+
+// Dependent name type
+// CHECK: Keyword: "typedef" [100:3 - 100:10] ClassTemplate=X5:98:8 (Definition)
+// CHECK: Keyword: "typename" [100:11 - 100:19] TypedefDecl=iter_type:100:63 (Definition)
+// CHECK: Identifier: "outer_alias" [100:20 - 100:31] NamespaceRef=outer_alias:10:11
+// CHECK: Punctuation: "::" [100:31 - 100:33] TypedefDecl=iter_type:100:63 (Definition)
+// CHECK: Identifier: "inner" [100:33 - 100:38] NamespaceRef=inner:62:13
+// CHECK: Punctuation: "::" [100:38 - 100:40] TypedefDecl=iter_type:100:63 (Definition)
+// CHECK: Identifier: "vector" [100:40 - 100:46] TemplateRef=vector:4:12
+// CHECK: Punctuation: "<" [100:46 - 100:47] TypedefDecl=iter_type:100:63 (Definition)
+// CHECK: Identifier: "type" [100:47 - 100:51] TypeRef=type:99:13
+// CHECK: Punctuation: ">" [100:51 - 100:52] TypedefDecl=iter_type:100:63 (Definition)
+// CHECK: Punctuation: "::" [100:52 - 100:54] TypedefDecl=iter_type:100:63 (Definition)
+// CHECK: Identifier: "iterator" [100:54 - 100:62] TypedefDecl=iter_type:100:63 (Definition)
+// CHECK: Identifier: "iter_type" [100:63 - 100:72] TypedefDecl=iter_type:100:63 (Definition)
+
+// CHECK: Keyword: "typedef" [101:3 - 101:10] ClassTemplate=X5:98:8 (Definition)
+// CHECK: Keyword: "typename" [101:11 - 101:19] TypedefDecl=int_ptr_type:101:62 (Definition)
+// CHECK: Identifier: "outer_alias" [101:20 - 101:31] NamespaceRef=outer_alias:10:11
+// CHECK: Punctuation: "::" [101:31 - 101:33] TypedefDecl=int_ptr_type:101:62 (Definition)
+// CHECK: Identifier: "inner" [101:33 - 101:38] NamespaceRef=inner:62:13
+// CHECK: Punctuation: "::" [101:38 - 101:40] TypedefDecl=int_ptr_type:101:62 (Definition)
+// CHECK: Identifier: "vector" [101:40 - 101:46] TemplateRef=vector:4:12
+// CHECK: Punctuation: "<" [101:46 - 101:47] TypedefDecl=int_ptr_type:101:62 (Definition)
+// CHECK: Keyword: "int" [101:47 - 101:50] TypedefDecl=int_ptr_type:101:62 (Definition)
+// CHECK: Punctuation: ">" [101:50 - 101:51] TypedefDecl=int_ptr_type:101:62 (Definition)
+// CHECK: Punctuation: "::" [101:51 - 101:53] TypedefDecl=int_ptr_type:101:62 (Definition)
+// CHECK: Identifier: "iterator" [101:53 - 101:61] TypeRef=iterator:5:18
+// CHECK: Identifier: "int_ptr_type" [101:62 - 101:74] TypedefDecl=int_ptr_type:101:62 (Definition)
+
+// Dependent template specialization types
+// CHECK: Keyword: "typename" [107:11 - 107:19] TypedefDecl=type1:107:76 (Definition)
+// CHECK: Identifier: "outer_alias" [107:20 - 107:31] NamespaceRef=outer_alias:10:11
+// CHECK: Punctuation: "::" [107:31 - 107:33] TypedefDecl=type1:107:76 (Definition)
+// CHECK: Identifier: "inner" [107:33 - 107:38] NamespaceRef=inner:62:13
+// CHECK: Punctuation: "::" [107:38 - 107:40] TypedefDecl=type1:107:76 (Definition)
+// CHECK: Identifier: "vector" [107:40 - 107:46] TemplateRef=vector:4:12
+// CHECK: Punctuation: "<" [107:46 - 107:47] TypedefDecl=type1:107:76 (Definition)
+// CHECK: Identifier: "type" [107:47 - 107:51] TypeRef=type:106:14
+// CHECK: Punctuation: ">" [107:51 - 107:52] TypedefDecl=type1:107:76 (Definition)
+// CHECK: Punctuation: "::" [107:52 - 107:54] TypedefDecl=type1:107:76 (Definition)
+// CHECK: Keyword: "template" [107:54 - 107:62] TypedefDecl=type1:107:76 (Definition)
+// CHECK: Identifier: "rebind" [107:63 - 107:69] TypedefDecl=type1:107:76 (Definition)
+// CHECK: Punctuation: "<" [107:69 - 107:70] TypedefDecl=type1:107:76 (Definition)
+// CHECK: Identifier: "type" [107:70 - 107:74] TypeRef=type:106:14
+// CHECK: Punctuation: ">" [107:74 - 107:75] TypedefDecl=type1:107:76 (Definition)
+// CHECK: Identifier: "type1" [107:76 - 107:81] TypedefDecl=type1:107:76 (Definition)
+
+// CHECK: Keyword: "typedef" [108:3 - 108:10] ClassTemplate=X6:105:8 (Definition)
+// CHECK: Keyword: "typename" [108:11 - 108:19] TypedefDecl=type2:108:83 (Definition)
+// CHECK: Identifier: "outer_alias" [108:20 - 108:31] NamespaceRef=outer_alias:10:11
+// CHECK: Punctuation: "::" [108:31 - 108:33] TypedefDecl=type2:108:83 (Definition)
+// CHECK: Identifier: "inner" [108:33 - 108:38] NamespaceRef=inner:62:13
+// CHECK: Punctuation: "::" [108:38 - 108:40] TypedefDecl=type2:108:83 (Definition)
+// CHECK: Identifier: "vector" [108:40 - 108:46] TemplateRef=vector:4:12
+// CHECK: Punctuation: "<" [108:46 - 108:47] TypedefDecl=type2:108:83 (Definition)
+// CHECK: Identifier: "type" [108:47 - 108:51] TypeRef=type:106:14
+// CHECK: Punctuation: ">" [108:51 - 108:52] TypedefDecl=type2:108:83 (Definition)
+// CHECK: Punctuation: "::" [108:52 - 108:54] TypedefDecl=type2:108:83 (Definition)
+// CHECK: Keyword: "template" [108:54 - 108:62] TypedefDecl=type2:108:83 (Definition)
+// CHECK: Identifier: "rebind" [108:63 - 108:69] TypedefDecl=type2:108:83 (Definition)
+// CHECK: Punctuation: "<" [108:69 - 108:70] TypedefDecl=type2:108:83 (Definition)
+// CHECK: Identifier: "type" [108:70 - 108:74] TypeRef=type:106:14
+// CHECK: Punctuation: ">" [108:74 - 108:75] TypedefDecl=type2:108:83 (Definition)
+// CHECK: Punctuation: "::" [108:75 - 108:77] TypedefDecl=type2:108:83 (Definition)
+// CHECK: Identifier: "other" [108:77 - 108:82] TypedefDecl=type2:108:83 (Definition)
+// CHECK: Identifier: "type2" [108:83 - 108:88] TypedefDecl=type2:108:83 (Definition)
+
+// CHECK: Keyword: "typedef" [109:3 - 109:10] ClassTemplate=X6:105:8 (Definition)
+// CHECK: Keyword: "class" [109:11 - 109:16] TypedefDecl=type3:109:73 (Definition)
+// CHECK: Identifier: "outer_alias" [109:17 - 109:28] NamespaceRef=outer_alias:10:11
+// CHECK: Punctuation: "::" [109:28 - 109:30] TypedefDecl=type3:109:73 (Definition)
+// CHECK: Identifier: "inner" [109:30 - 109:35] NamespaceRef=inner:62:13
+// CHECK: Punctuation: "::" [109:35 - 109:37] TypedefDecl=type3:109:73 (Definition)
+// CHECK: Identifier: "vector" [109:37 - 109:43] TemplateRef=vector:4:12
+// CHECK: Punctuation: "<" [109:43 - 109:44] TypedefDecl=type3:109:73 (Definition)
+// CHECK: Identifier: "type" [109:44 - 109:48] TypeRef=type:106:14
+// CHECK: Punctuation: ">" [109:48 - 109:49] TypedefDecl=type3:109:73 (Definition)
+// CHECK: Punctuation: "::" [109:49 - 109:51] TypedefDecl=type3:109:73 (Definition)
+// CHECK: Keyword: "template" [109:51 - 109:59] TypedefDecl=type3:109:73 (Definition)
+// CHECK: Identifier: "rebind" [109:60 - 109:66] TypedefDecl=type3:109:73 (Definition)
+// CHECK: Punctuation: "<" [109:66 - 109:67] TypedefDecl=type3:109:73 (Definition)
+// CHECK: Identifier: "type" [109:67 - 109:71] TypeRef=type:106:14
+// CHECK: Punctuation: ">" [109:71 - 109:72] TypedefDecl=type3:109:73 (Definition)
+// CHECK: Identifier: "type3" [109:73 - 109:78] TypedefDecl=type3:109:73 (Definition)
+
+// CHECK: Keyword: "class" [110:11 - 110:16] TypedefDecl=type4:110:80 (Definition)
+// CHECK: Identifier: "outer_alias" [110:17 - 110:28] NamespaceRef=outer_alias:10:11
+// CHECK: Punctuation: "::" [110:28 - 110:30] TypedefDecl=type4:110:80 (Definition)
+// CHECK: Identifier: "inner" [110:30 - 110:35] NamespaceRef=inner:62:13
+// CHECK: Punctuation: "::" [110:35 - 110:37] TypedefDecl=type4:110:80 (Definition)
+// CHECK: Identifier: "vector" [110:37 - 110:43] TemplateRef=vector:4:12
+// CHECK: Punctuation: "<" [110:43 - 110:44] TypedefDecl=type4:110:80 (Definition)
+// CHECK: Identifier: "type" [110:44 - 110:48] TypeRef=type:106:14
+// CHECK: Punctuation: ">" [110:48 - 110:49] TypedefDecl=type4:110:80 (Definition)
+// CHECK: Punctuation: "::" [110:49 - 110:51] TypedefDecl=type4:110:80 (Definition)
+// CHECK: Keyword: "template" [110:51 - 110:59] TypedefDecl=type4:110:80 (Definition)
+// CHECK: Identifier: "rebind" [110:60 - 110:66] TypedefDecl=type4:110:80 (Definition)
+// CHECK: Punctuation: "<" [110:66 - 110:67] TypedefDecl=type4:110:80 (Definition)
+// CHECK: Identifier: "type" [110:67 - 110:71] TypeRef=type:106:14
+// CHECK: Punctuation: ">" [110:71 - 110:72] TypedefDecl=type4:110:80 (Definition)
+// CHECK: Punctuation: "::" [110:72 - 110:74] TypedefDecl=type4:110:80 (Definition)
+// CHECK: Identifier: "other" [110:74 - 110:79] TypedefDecl=type4:110:80 (Definition)
+// CHECK: Identifier: "type4" [110:80 - 110:85] TypedefDecl=type4:110:80 (Definition)
+
+// Template template arguments
+// CHECK: Keyword: "typedef" [126:3 - 126:10] ClassTemplate=X7:123:8 (Definition)
+// CHECK: Identifier: "outer_alias" [126:11 - 126:22] NamespaceRef=outer_alias:10:11
+// CHECK: Punctuation: "::" [126:22 - 126:24] TypedefDecl=type:126:74 (Definition)
+// CHECK: Identifier: "inner" [126:24 - 126:29] NamespaceRef=inner:114:13
+// CHECK: Punctuation: "::" [126:29 - 126:31] TypedefDecl=type:126:74 (Definition)
+// CHECK: Identifier: "apply_meta" [126:31 - 126:41] TemplateRef=apply_meta:116:12
+// CHECK: Punctuation: "<" [126:41 - 126:42] TypedefDecl=type:126:74 (Definition)
+// CHECK: Identifier: "T_type" [126:42 - 126:48] TypeRef=T_type:124:13
+// CHECK: Punctuation: "," [126:48 - 126:49] TypedefDecl=type:126:74 (Definition)
+// CHECK: Identifier: "U_type" [126:50 - 126:56] TypeRef=U_type:125:13
+// CHECK: Punctuation: "::" [126:56 - 126:58] TypedefDecl=type:126:74 (Definition)
+// CHECK: Keyword: "template" [126:58 - 126:66] TypedefDecl=type:126:74 (Definition)
+// CHECK: Identifier: "apply" [126:67 - 126:72] TypedefDecl=type:126:74 (Definition)
+// CHECK: Punctuation: ">" [126:72 - 126:73] TypedefDecl=type:126:74 (Definition)
+// CHECK: Identifier: "type" [126:74 - 126:78] TypedefDecl=type:126:74 (Definition)
+
+// Member access expressions
+// CHECK: Identifier: "inherited" [136:5 - 136:14] TypeRef=inherited:134:14
+// CHECK: Punctuation: "::" [136:14 - 136:16] MemberRefExpr=f:130:8
+// CHECK: Identifier: "f" [136:16 - 136:17] MemberRefExpr=f:130:8
diff --git a/clang/test/Index/annotate-subscripting.m b/clang/test/Index/annotate-subscripting.m
new file mode 100644
index 0000000..cda1465
--- /dev/null
+++ b/clang/test/Index/annotate-subscripting.m
@@ -0,0 +1,92 @@
+@interface NSArray
+- (id)objectAtIndexedSubscript:(int)index;
++ (id)arrayWithObjects:(id *)objects count:(unsigned)count;
+@end
+
+@interface NSMutableArray : NSArray
+- (id)objectAtIndexedSubscript:(int)index;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary
+- (id)objectForKeyedSubscript:(id)key;
++ (id)dictionaryWithObjects:(id *)objects forKeys:(id *)keys count:(unsigned)count;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@class NSString;
+
+id testArray(int index, id p) {
+ NSMutableArray *array;
+ array[3] = 0;
+ NSArray *arr = @[ p, p ];
+ return array[index];
+}
+
+void testDict() {
+ NSMutableDictionary *dictionary;
+ NSString *key;
+ id newObject, oldObject;
+ oldObject = dictionary[key];
+ dictionary[key] = newObject;
+ NSDictionary *dict = @{ key: newObject, key: oldObject };
+}
+
+// RUN: c-index-test -test-annotate-tokens=%s:22:1:36:1 -target x86_64-apple-macosx10.7 %s | FileCheck %s
+// CHECK: Identifier: "array" [24:3 - 24:8] DeclRefExpr=array:23:19
+// CHECK: Punctuation: "[" [24:8 - 24:9] UnexposedExpr=
+// CHECK: Literal: "3" [24:9 - 24:10] IntegerLiteral=
+// CHECK: Punctuation: "]" [24:10 - 24:11] UnexposedExpr=
+// CHECK: Punctuation: "=" [24:12 - 24:13] BinaryOperator=
+// CHECK: Literal: "0" [24:14 - 24:15] IntegerLiteral=
+// CHECK: Punctuation: ";" [24:15 - 24:16] CompoundStmt=
+// CHECK: Identifier: "NSArray" [25:3 - 25:10] ObjCClassRef=NSArray:1:12
+// CHECK: Punctuation: "*" [25:11 - 25:12] VarDecl=arr:25:12 (Definition)
+// CHECK: Identifier: "arr" [25:12 - 25:15] VarDecl=arr:25:12 (Definition)
+// CHECK: Punctuation: "=" [25:16 - 25:17] VarDecl=arr:25:12 (Definition)
+// CHECK: Punctuation: "@" [25:18 - 25:19] UnexposedExpr=
+// CHECK: Punctuation: "[" [25:19 - 25:20] UnexposedExpr=
+// CHECK: Identifier: "p" [25:21 - 25:22] DeclRefExpr=p:22:28
+// CHECK: Punctuation: "," [25:22 - 25:23] UnexposedExpr=
+// CHECK: Identifier: "p" [25:24 - 25:25] DeclRefExpr=p:22:28
+// CHECK: Punctuation: "]" [25:26 - 25:27] UnexposedExpr=
+// CHECK: Punctuation: ";" [25:27 - 25:28] DeclStmt=
+// CHECK: Keyword: "return" [26:3 - 26:9] ReturnStmt=
+// CHECK: Identifier: "array" [26:10 - 26:15] DeclRefExpr=array:23:19
+// CHECK: Punctuation: "[" [26:15 - 26:16] UnexposedExpr=
+// CHECK: Identifier: "index" [26:16 - 26:21] DeclRefExpr=index:22:18
+// CHECK: Punctuation: "]" [26:21 - 26:22] UnexposedExpr=
+// CHECK: Punctuation: ";" [26:22 - 26:23] CompoundStmt=
+
+// CHECK: Identifier: "oldObject" [33:3 - 33:12] DeclRefExpr=oldObject:32:17
+// CHECK: Punctuation: "=" [33:13 - 33:14] BinaryOperator=
+// CHECK: Identifier: "dictionary" [33:15 - 33:25] DeclRefExpr=dictionary:30:24
+// CHECK: Punctuation: "[" [33:25 - 33:26] UnexposedExpr=
+// CHECK: Identifier: "key" [33:26 - 33:29] DeclRefExpr=key:31:13
+// CHECK: Punctuation: "]" [33:29 - 33:30] UnexposedExpr=
+// CHECK: Punctuation: ";" [33:30 - 33:31] CompoundStmt=
+// CHECK: Identifier: "dictionary" [34:3 - 34:13] DeclRefExpr=dictionary:30:24
+// CHECK: Punctuation: "[" [34:13 - 34:14] UnexposedExpr=
+// CHECK: Identifier: "key" [34:14 - 34:17] DeclRefExpr=key:31:13
+// CHECK: Punctuation: "]" [34:17 - 34:18] UnexposedExpr=
+// CHECK: Punctuation: "=" [34:19 - 34:20] BinaryOperator=
+// CHECK: Identifier: "newObject" [34:21 - 34:30] DeclRefExpr=newObject:32:6
+// CHECK: Punctuation: ";" [34:30 - 34:31] CompoundStmt=
+// CHECK: Identifier: "NSDictionary" [35:3 - 35:15] ObjCClassRef=NSDictionary:11:12
+// CHECK: Punctuation: "*" [35:16 - 35:17] VarDecl=dict:35:17 (Definition)
+// CHECK: Identifier: "dict" [35:17 - 35:21] VarDecl=dict:35:17 (Definition)
+// CHECK: Punctuation: "=" [35:22 - 35:23] VarDecl=dict:35:17 (Definition)
+// CHECK: Punctuation: "@" [35:24 - 35:25] UnexposedExpr=
+// CHECK: Punctuation: "{" [35:25 - 35:26] UnexposedExpr=
+// CHECK: Identifier: "key" [35:27 - 35:30] DeclRefExpr=key:31:13
+// CHECK: Punctuation: ":" [35:30 - 35:31] UnexposedExpr=
+// CHECK: Identifier: "newObject" [35:32 - 35:41] DeclRefExpr=newObject:32:6
+// CHECK: Punctuation: "," [35:41 - 35:42] UnexposedExpr=
+// CHECK: Identifier: "key" [35:43 - 35:46] DeclRefExpr=key:31:13
+// CHECK: Punctuation: ":" [35:46 - 35:47] UnexposedExpr=
+// CHECK: Identifier: "oldObject" [35:48 - 35:57] DeclRefExpr=oldObject:32:17
+// CHECK: Punctuation: "}" [35:58 - 35:59] UnexposedExpr=
+// CHECK: Punctuation: ";" [35:59 - 35:60] DeclStmt=
diff --git a/clang/test/Index/annotate-tokens-cxx0x.cpp b/clang/test/Index/annotate-tokens-cxx0x.cpp
new file mode 100644
index 0000000..a126b85
--- /dev/null
+++ b/clang/test/Index/annotate-tokens-cxx0x.cpp
@@ -0,0 +1,27 @@
+template<typename ...Args>
+int f(Args ...args) {
+ return sizeof...(args) + sizeof...(Args);
+}
+
+void test() {
+ int a;
+ decltype(a) b;
+
+ typedef int Integer;
+ typedef float Float;
+ typedef bool Bool;
+ bool b2 = __is_trivially_constructible(Integer, Float, Bool);
+}
+
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:5:1 -fno-delayed-template-parsing -std=c++11 %s | FileCheck %s
+// CHECK: Identifier: "args" [3:20 - 3:24] SizeOfPackExpr=args:2:15
+// CHECK: Identifier: "Args" [3:38 - 3:42] TypeRef=Args:1:22
+
+// RUN: c-index-test -test-annotate-tokens=%s:8:1:9:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-DECLTYPE %s
+// CHECK-DECLTYPE: Identifier: "a" [8:12 - 8:13] DeclRefExpr=a:7:7
+
+// RUN: c-index-test -test-annotate-tokens=%s:13:1:14:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-TRAIT %s
+// CHECK-TRAIT: Identifier: "Integer" [13:42 - 13:49] TypeRef=Integer:10:15
+// CHECK-TRAIT: Identifier: "Float" [13:51 - 13:56] TypeRef=Float:11:17
+// CHECK-TRAIT: Identifier: "Bool" [13:58 - 13:62] TypeRef=Bool:12:16
+
diff --git a/clang/test/Index/annotate-tokens-include.c b/clang/test/Index/annotate-tokens-include.c
new file mode 100644
index 0000000..2190125
--- /dev/null
+++ b/clang/test/Index/annotate-tokens-include.c
@@ -0,0 +1,7 @@
+#include "annotate-tokens-include.h"
+
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:2:1 %s | FileCheck %s
+// CHECK: Punctuation: "#" [1:1 - 1:2] inclusion directive=annotate-tokens-include.h
+// CHECK: Identifier: "include" [1:2 - 1:9] inclusion directive=annotate-tokens-include.h
+// CHECK: Literal: ""annotate-tokens-include.h"" [1:10 - 1:37] inclusion directive=annotate-tokens-include.h
+
diff --git a/clang/test/Index/annotate-tokens-include.h b/clang/test/Index/annotate-tokens-include.h
new file mode 100644
index 0000000..5d5f8f0
--- /dev/null
+++ b/clang/test/Index/annotate-tokens-include.h
@@ -0,0 +1 @@
+int foo();
diff --git a/clang/test/Index/annotate-tokens-pp.c b/clang/test/Index/annotate-tokens-pp.c
new file mode 100644
index 0000000..b37ab39
--- /dev/null
+++ b/clang/test/Index/annotate-tokens-pp.c
@@ -0,0 +1,198 @@
+#define NOTHING(X,Y)
+#define STILL_NOTHING NOTHING(honk,warble)
+#define BAR baz
+#define WIBBLE(X, Y) X##Y
+NOTHING(more,junk) float WIBBLE(int, float);
+int BAR STILL_NOTHING;
+#include "foo.h"
+#undef BAR
+
+#define REVERSE_MACRO(x,y) y + x
+#define TWICE_MACRO(y) y + y
+
+void test_macro_args() {
+ int z = 1;
+ int t = 2;
+ int k = REVERSE_MACRO(t,z);
+ int j = TWICE_MACRO(k + k);
+ int w = j + j;
+}
+
+#define fun_with_macro_bodies(x, y) do { if (x) y } while (0)
+
+void test() {
+ int x = 10;
+ fun_with_macro_bodies(x, { int z = x; ++z; });
+}
+
+#include "pragma-once.h"
+#include "guarded.h"
+
+const char *fname = __FILE__;
+
+// RUN: c-index-test -test-annotate-tokens=%s:2:1:32:1 -I%S/Inputs %s | FileCheck %s
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-annotate-tokens=%s:2:1:32:1 -I%S/Inputs %s | FileCheck %s
+// CHECK: Punctuation: "#" [2:1 - 2:2] preprocessing directive=
+// CHECK: Identifier: "define" [2:2 - 2:8] preprocessing directive=
+// CHECK: Identifier: "STILL_NOTHING" [2:9 - 2:22] macro definition=STILL_NOTHING
+// CHECK: Identifier: "NOTHING" [2:23 - 2:30] macro definition=STILL_NOTHING
+// CHECK: Punctuation: "(" [2:30 - 2:31] macro definition=STILL_NOTHING
+// CHECK: Identifier: "honk" [2:31 - 2:35] macro definition=STILL_NOTHING
+// CHECK: Punctuation: "," [2:35 - 2:36] macro definition=STILL_NOTHING
+// CHECK: Identifier: "warble" [2:36 - 2:42] macro definition=STILL_NOTHING
+// CHECK: Punctuation: ")" [2:42 - 2:43] macro definition=STILL_NOTHING
+// CHECK: Punctuation: "#" [3:1 - 3:2] preprocessing directive=
+// CHECK: Identifier: "define" [3:2 - 3:8] preprocessing directive=
+// CHECK: Identifier: "BAR" [3:9 - 3:12] macro definition=BAR
+// CHECK: Identifier: "baz" [3:13 - 3:16] macro definition=BAR
+// CHECK: Punctuation: "#" [4:1 - 4:2] preprocessing directive=
+// CHECK: Identifier: "define" [4:2 - 4:8] preprocessing directive=
+// CHECK: Identifier: "WIBBLE" [4:9 - 4:15] macro definition=WIBBLE
+// CHECK: Punctuation: "(" [4:15 - 4:16] macro definition=WIBBLE
+// CHECK: Identifier: "X" [4:16 - 4:17] macro definition=WIBBLE
+// CHECK: Punctuation: "," [4:17 - 4:18] macro definition=WIBBLE
+// CHECK: Identifier: "Y" [4:19 - 4:20] macro definition=WIBBLE
+// CHECK: Punctuation: ")" [4:20 - 4:21] macro definition=WIBBLE
+// CHECK: Identifier: "X" [4:22 - 4:23] macro definition=WIBBLE
+// CHECK: Punctuation: "##" [4:23 - 4:25] macro definition=WIBBLE
+// CHECK: Identifier: "Y" [4:25 - 4:26] macro definition=WIBBLE
+// CHECK: Identifier: "NOTHING" [5:1 - 5:8] macro expansion=NOTHING:1:9
+// CHECK: Punctuation: "(" [5:8 - 5:9]
+// CHECK: Identifier: "more" [5:9 - 5:13]
+// CHECK: Punctuation: "," [5:13 - 5:14]
+// CHECK: Identifier: "junk" [5:14 - 5:18]
+// CHECK: Punctuation: ")" [5:18 - 5:19]
+// CHECK: Keyword: "float" [5:20 - 5:25]
+// CHECK: Identifier: "WIBBLE" [5:26 - 5:32] macro expansion=WIBBLE:4:9
+// CHECK: Punctuation: "(" [5:32 - 5:33]
+// CHECK: Keyword: "int" [5:33 - 5:36]
+// CHECK: Punctuation: "," [5:36 - 5:37]
+// CHECK: Keyword: "float" [5:38 - 5:43]
+// CHECK: Punctuation: ")" [5:43 - 5:44]
+// CHECK: Punctuation: ";" [5:44 - 5:45]
+// CHECK: Keyword: "int" [6:1 - 6:4]
+// CHECK: Identifier: "BAR" [6:5 - 6:8] macro expansion=BAR:3:9
+// CHECK: Identifier: "STILL_NOTHING" [6:9 - 6:22] macro expansion=STILL_NOTHING:2:9
+// CHECK: Punctuation: ";" [6:22 - 6:23]
+// CHECK: Punctuation: "#" [7:1 - 7:2] inclusion directive=foo.h
+// CHECK: Identifier: "include" [7:2 - 7:9] inclusion directive=foo.h
+// CHECK: Literal: ""foo.h"" [7:10 - 7:17] inclusion directive=foo.h
+// CHECK: Punctuation: "#" [8:1 - 8:2] preprocessing directive=
+// CHECK: Identifier: "undef" [8:2 - 8:7] preprocessing directive=
+// CHECK: Identifier: "BAR" [8:8 - 8:11] preprocessing directive=
+// CHECK: Punctuation: "#" [10:1 - 10:2] preprocessing directive=
+// CHECK: Identifier: "define" [10:2 - 10:8] preprocessing directive=
+// CHECK: Identifier: "REVERSE_MACRO" [10:9 - 10:22] macro definition=REVERSE_MACRO
+// CHECK: Punctuation: "(" [10:22 - 10:23] macro definition=REVERSE_MACRO
+// CHECK: Identifier: "x" [10:23 - 10:24] macro definition=REVERSE_MACRO
+// CHECK: Punctuation: "," [10:24 - 10:25] macro definition=REVERSE_MACRO
+// CHECK: Identifier: "y" [10:25 - 10:26] macro definition=REVERSE_MACRO
+// CHECK: Punctuation: ")" [10:26 - 10:27] macro definition=REVERSE_MACRO
+// CHECK: Identifier: "y" [10:28 - 10:29] macro definition=REVERSE_MACRO
+// CHECK: Punctuation: "+" [10:30 - 10:31] macro definition=REVERSE_MACRO
+// CHECK: Identifier: "x" [10:32 - 10:33] macro definition=REVERSE_MACRO
+// CHECK: Punctuation: "#" [11:1 - 11:2] preprocessing directive=
+// CHECK: Identifier: "define" [11:2 - 11:8] preprocessing directive=
+// CHECK: Identifier: "TWICE_MACRO" [11:9 - 11:20] macro definition=TWICE_MACRO
+// CHECK: Punctuation: "(" [11:20 - 11:21] macro definition=TWICE_MACRO
+// CHECK: Identifier: "y" [11:21 - 11:22] macro definition=TWICE_MACRO
+// CHECK: Punctuation: ")" [11:22 - 11:23] macro definition=TWICE_MACRO
+// CHECK: Identifier: "y" [11:24 - 11:25] macro definition=TWICE_MACRO
+// CHECK: Punctuation: "+" [11:26 - 11:27] macro definition=TWICE_MACRO
+// CHECK: Identifier: "y" [11:28 - 11:29] macro definition=TWICE_MACRO
+// CHECK: Keyword: "void" [13:1 - 13:5] FunctionDecl=test_macro_args:13:6 (Definition)
+// CHECK: Identifier: "test_macro_args" [13:6 - 13:21] FunctionDecl=test_macro_args:13:6 (Definition)
+// CHECK: Punctuation: "(" [13:21 - 13:22] FunctionDecl=test_macro_args:13:6 (Definition)
+// CHECK: Punctuation: ")" [13:22 - 13:23] FunctionDecl=test_macro_args:13:6 (Definition)
+// CHECK: Punctuation: "{" [13:24 - 13:25] CompoundStmt=
+// CHECK: Keyword: "int" [14:3 - 14:6] VarDecl=z:14:7 (Definition)
+// CHECK: Identifier: "z" [14:7 - 14:8] VarDecl=z:14:7 (Definition)
+// CHECK: Punctuation: "=" [14:9 - 14:10] VarDecl=z:14:7 (Definition)
+// CHECK: Literal: "1" [14:11 - 14:12] IntegerLiteral=
+// CHECK: Punctuation: ";" [14:12 - 14:13] DeclStmt=
+// CHECK: Keyword: "int" [15:3 - 15:6] VarDecl=t:15:7 (Definition)
+// CHECK: Identifier: "t" [15:7 - 15:8] VarDecl=t:15:7 (Definition)
+// CHECK: Punctuation: "=" [15:9 - 15:10] VarDecl=t:15:7 (Definition)
+// CHECK: Literal: "2" [15:11 - 15:12] IntegerLiteral=
+// CHECK: Punctuation: ";" [15:12 - 15:13] DeclStmt=
+// CHECK: Keyword: "int" [16:3 - 16:6] VarDecl=k:16:7 (Definition)
+// CHECK: Identifier: "k" [16:7 - 16:8] VarDecl=k:16:7 (Definition)
+// CHECK: Punctuation: "=" [16:9 - 16:10] VarDecl=k:16:7 (Definition)
+// CHECK: Identifier: "REVERSE_MACRO" [16:11 - 16:24] macro expansion=REVERSE_MACRO:10:9
+// CHECK: Punctuation: "(" [16:24 - 16:25]
+// CHECK: Identifier: "t" [16:25 - 16:26] DeclRefExpr=t:15:7
+// CHECK: Punctuation: "," [16:26 - 16:27]
+// CHECK: Identifier: "z" [16:27 - 16:28] DeclRefExpr=z:14:7
+// FIXME: The token below should really be annotated as "macro expansion=REVERSE_MACRO:10:9"
+// CHECK: Punctuation: ")" [16:28 - 16:29] DeclStmt=
+// CHECK: Punctuation: ";" [16:29 - 16:30] DeclStmt=
+// CHECK: Keyword: "int" [17:3 - 17:6] VarDecl=j:17:7 (Definition)
+// CHECK: Identifier: "j" [17:7 - 17:8] VarDecl=j:17:7 (Definition)
+// CHECK: Punctuation: "=" [17:9 - 17:10] VarDecl=j:17:7 (Definition)
+// CHECK: Identifier: "TWICE_MACRO" [17:11 - 17:22] macro expansion=TWICE_MACRO:11:9
+// CHECK: Punctuation: "(" [17:22 - 17:23]
+// CHECK: Identifier: "k" [17:23 - 17:24] DeclRefExpr=k:16:7
+// CHECK: Punctuation: "+" [17:25 - 17:26] BinaryOperator=
+// CHECK: Identifier: "k" [17:27 - 17:28] DeclRefExpr=k:16:7
+// FIXME: The token below should really be annotated as "macro expansion=TWICE_MACRO:11:9"
+// CHECK: Punctuation: ")" [17:28 - 17:29] DeclStmt=
+// CHECK: Punctuation: ";" [17:29 - 17:30] DeclStmt=
+// CHECK: Keyword: "int" [18:3 - 18:6] VarDecl=w:18:7 (Definition)
+// CHECK: Identifier: "w" [18:7 - 18:8] VarDecl=w:18:7 (Definition)
+// CHECK: Punctuation: "=" [18:9 - 18:10] VarDecl=w:18:7 (Definition)
+// CHECK: Identifier: "j" [18:11 - 18:12] DeclRefExpr=j:17:7
+// CHECK: Punctuation: "+" [18:13 - 18:14] BinaryOperator=
+// CHECK: Identifier: "j" [18:15 - 18:16] DeclRefExpr=j:17:7
+// CHECK: Punctuation: ";" [18:16 - 18:17] DeclStmt=
+// CHECK: Punctuation: "}" [19:1 - 19:2] CompoundStmt=
+// CHECK: Punctuation: "#" [21:1 - 21:2] preprocessing directive=
+// CHECK: Identifier: "define" [21:2 - 21:8] preprocessing directive=
+// CHECK: Identifier: "fun_with_macro_bodies" [21:9 - 21:30] macro definition=fun_with_macro_bodies
+// CHECK: Punctuation: "(" [21:30 - 21:31] macro definition=fun_with_macro_bodies
+// CHECK: Identifier: "x" [21:31 - 21:32] macro definition=fun_with_macro_bodies
+// CHECK: Punctuation: "," [21:32 - 21:33] macro definition=fun_with_macro_bodies
+// CHECK: Identifier: "y" [21:34 - 21:35] macro definition=fun_with_macro_bodies
+// CHECK: Punctuation: ")" [21:35 - 21:36] macro definition=fun_with_macro_bodies
+// CHECK: Keyword: "do" [21:37 - 21:39] macro definition=fun_with_macro_bodies
+// CHECK: Punctuation: "{" [21:40 - 21:41] macro definition=fun_with_macro_bodies
+// CHECK: Keyword: "if" [21:42 - 21:44] macro definition=fun_with_macro_bodies
+// CHECK: Punctuation: "(" [21:45 - 21:46] macro definition=fun_with_macro_bodies
+// CHECK: Identifier: "x" [21:46 - 21:47] macro definition=fun_with_macro_bodies
+// CHECK: Punctuation: ")" [21:47 - 21:48] macro definition=fun_with_macro_bodies
+// CHECK: Identifier: "y" [21:49 - 21:50] macro definition=fun_with_macro_bodies
+// CHECK: Punctuation: "}" [21:51 - 21:52] macro definition=fun_with_macro_bodies
+// CHECK: Keyword: "while" [21:53 - 21:58] macro definition=fun_with_macro_bodies
+// CHECK: Punctuation: "(" [21:59 - 21:60] macro definition=fun_with_macro_bodies
+// CHECK: Literal: "0" [21:60 - 21:61] macro definition=fun_with_macro_bodies
+// CHECK: Punctuation: ")" [21:61 - 21:62] macro definition=fun_with_macro_bodies
+// CHECK: Keyword: "void" [23:1 - 23:5] FunctionDecl=test:23:6 (Definition)
+// CHECK: Identifier: "test" [23:6 - 23:10] FunctionDecl=test:23:6 (Definition)
+// CHECK: Punctuation: "(" [23:10 - 23:11] FunctionDecl=test:23:6 (Definition)
+// CHECK: Punctuation: ")" [23:11 - 23:12] FunctionDecl=test:23:6 (Definition)
+// CHECK: Punctuation: "{" [23:13 - 23:14] CompoundStmt=
+// CHECK: Keyword: "int" [24:3 - 24:6] VarDecl=x:24:7 (Definition)
+// CHECK: Identifier: "x" [24:7 - 24:8] VarDecl=x:24:7 (Definition)
+// CHECK: Punctuation: "=" [24:9 - 24:10] VarDecl=x:24:7 (Definition)
+// CHECK: Literal: "10" [24:11 - 24:13] IntegerLiteral=
+// CHECK: Punctuation: ";" [24:13 - 24:14] DeclStmt=
+// CHECK: Identifier: "fun_with_macro_bodies" [25:3 - 25:24] macro expansion=fun_with_macro_bodies:21:9
+// CHECK: Punctuation: "(" [25:24 - 25:25] CompoundStmt=
+// CHECK: Identifier: "x" [25:25 - 25:26] DeclRefExpr=x:24:7
+// CHECK: Punctuation: "," [25:26 - 25:27]
+// CHECK: Punctuation: "{" [25:28 - 25:29] CompoundStmt=
+// CHECK: Keyword: "int" [25:30 - 25:33] DeclStmt=
+// CHECK: Identifier: "z" [25:34 - 25:35] VarDecl=z:25:34 (Definition)
+// CHECK: Punctuation: "=" [25:36 - 25:37] VarDecl=z:25:34 (Definition)
+// CHECK: Identifier: "x" [25:38 - 25:39] DeclRefExpr=x:24:7
+// CHECK: Punctuation: ";" [25:39 - 25:40] DeclStmt=
+// CHECK: Punctuation: "++" [25:41 - 25:43] UnaryOperator=
+// CHECK: Identifier: "z" [25:43 - 25:44] DeclRefExpr=z:25:3
+// CHECK: Punctuation: ";" [25:44 - 25:45] CompoundStmt=
+// CHECK: Punctuation: "}" [25:46 - 25:47] CompoundStmt=
+// FIXME: The token below should really be annotated as "macro expansion=fun_with_macro_bodies:21:9"
+// CHECK: Punctuation: ")" [25:47 - 25:48] CompoundStmt=
+// CHECK: Punctuation: ";" [25:48 - 25:49] CompoundStmt=
+// CHECK: Punctuation: "}" [26:1 - 26:2] CompoundStmt=
+// CHECK: {{28:1.*inclusion directive=pragma-once.h.*multi-include guarded}}
+// CHECK: {{29:1.*inclusion directive=guarded.h.*multi-include guarded}}
+// CHECK: Identifier: "__FILE__" [31:21 - 31:29] macro expansion=__FILE__
diff --git a/clang/test/Index/annotate-tokens-preamble.c b/clang/test/Index/annotate-tokens-preamble.c
new file mode 100644
index 0000000..aa222bd
--- /dev/null
+++ b/clang/test/Index/annotate-tokens-preamble.c
@@ -0,0 +1,20 @@
+// A comment line.
+
+void f(void *ptr) {
+}
+
+
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:5:1 %s | FileCheck %s
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-annotate-tokens=%s:1:1:5:1 %s | FileCheck %s
+// CHECK: Comment: "// A comment line." [1:1 - 1:19]
+// CHECK: Keyword: "void" [3:1 - 3:5] FunctionDecl=f:3:6 (Definition)
+// CHECK: Identifier: "f" [3:6 - 3:7] FunctionDecl=f:3:6 (Definition)
+// CHECK: Punctuation: "(" [3:7 - 3:8] FunctionDecl=f:3:6 (Definition)
+// CHECK: Keyword: "void" [3:8 - 3:12] ParmDecl=ptr:3:14 (Definition)
+// CHECK: Punctuation: "*" [3:13 - 3:14] ParmDecl=ptr:3:14 (Definition)
+// CHECK: Identifier: "ptr" [3:14 - 3:17] ParmDecl=ptr:3:14 (Definition)
+// CHECK: Punctuation: ")" [3:17 - 3:18] FunctionDecl=f:3:6 (Definition)
+// CHECK: Punctuation: "{" [3:19 - 3:20] CompoundStmt=
+// CHECK: Punctuation: "}" [4:1 - 4:2] CompoundStmt=
+
+
diff --git a/clang/test/Index/annotate-tokens-with-default-args.cpp b/clang/test/Index/annotate-tokens-with-default-args.cpp
new file mode 100644
index 0000000..d5ca706
--- /dev/null
+++ b/clang/test/Index/annotate-tokens-with-default-args.cpp
@@ -0,0 +1,16 @@
+#include "annotate-tokens-with-default-args.h"
+
+void Foo::m(Foo *f) {}
+
+// RUN: c-index-test -test-annotate-tokens=%s:3:1:4:1 %s | FileCheck %s
+// CHECK: Keyword: "void" [3:1 - 3:5] CXXMethod=m:3:11 (Definition)
+// CHECK: Identifier: "Foo" [3:6 - 3:9] TypeRef=struct Foo:1:8
+// CHECK: Punctuation: "::" [3:9 - 3:11] CXXMethod=m:3:11 (Definition)
+// CHECK: Identifier: "m" [3:11 - 3:12] CXXMethod=m:3:11 (Definition)
+// CHECK: Punctuation: "(" [3:12 - 3:13] CXXMethod=m:3:11 (Definition)
+// CHECK: Identifier: "Foo" [3:13 - 3:16] TypeRef=struct Foo:1:8
+// CHECK: Punctuation: "*" [3:17 - 3:18] ParmDecl=f:3:18 (Definition)
+// CHECK: Identifier: "f" [3:18 - 3:19] ParmDecl=f:3:18 (Definition)
+// CHECK: Punctuation: ")" [3:19 - 3:20] CXXMethod=m:3:11 (Definition)
+// CHECK: Punctuation: "{" [3:21 - 3:22] CompoundStmt=
+// CHECK: Punctuation: "}" [3:22 - 3:23] CompoundStmt=
diff --git a/clang/test/Index/annotate-tokens-with-default-args.h b/clang/test/Index/annotate-tokens-with-default-args.h
new file mode 100644
index 0000000..323c519
--- /dev/null
+++ b/clang/test/Index/annotate-tokens-with-default-args.h
@@ -0,0 +1,3 @@
+struct Foo {
+ void m(Foo *f = 0);
+};
diff --git a/clang/test/Index/annotate-tokens.c b/clang/test/Index/annotate-tokens.c
new file mode 100644
index 0000000..0b5f3d4
--- /dev/null
+++ b/clang/test/Index/annotate-tokens.c
@@ -0,0 +1,136 @@
+typedef int T;
+struct X { int a, b; };
+void f(void *ptr) {
+ T* t_ptr = (T *)ptr;
+ (void)sizeof(T);
+ /* A comment */
+ struct X x = (struct X){1, 2};
+ void *xx = ptr ? : &x;
+ const char * hello = "Hello";
+}
+enum Color { Red, Green, Blue };
+typedef int Int;
+enum Color g(int i, ...) {
+ __builtin_va_list va;
+ (void)__builtin_va_arg(va, Int);
+ (void)__builtin_types_compatible_p(Int, Int);
+
+ struct X x = { 0, 0 };
+ do {
+ x.a++;
+ } while (x.a < 10);
+
+ enum Color c;
+ switch (c) {
+ case Red:
+ return Green;
+
+ case Green:
+ return Blue;
+
+ case Blue:
+ return Red;
+ }
+}
+
+// RUN: c-index-test -test-annotate-tokens=%s:4:1:34:1 %s | FileCheck %s
+// CHECK: Identifier: "T" [4:3 - 4:4] TypeRef=T:1:13
+// CHECK: Punctuation: "*" [4:4 - 4:5] VarDecl=t_ptr:4:6 (Definition)
+// CHECK: Identifier: "t_ptr" [4:6 - 4:11] VarDecl=t_ptr:4:6 (Definition)
+// CHECK: Punctuation: "=" [4:12 - 4:13] VarDecl=t_ptr:4:6 (Definition)
+// CHECK: Punctuation: "(" [4:14 - 4:15] CStyleCastExpr=
+// CHECK: Identifier: "T" [4:15 - 4:16] TypeRef=T:1:13
+// CHECK: Identifier: "ptr" [4:19 - 4:22] DeclRefExpr=ptr:3:14
+// CHECK: Punctuation: ";" [4:22 - 4:23] DeclStmt=
+// CHECK: Punctuation: "(" [5:3 - 5:4] CStyleCastExpr=
+// CHECK: Keyword: "void" [5:4 - 5:8] CStyleCastExpr=
+// CHECK: Punctuation: ")" [5:8 - 5:9] CStyleCastExpr=
+// CHECK: Keyword: "sizeof" [5:9 - 5:15] UnexposedExpr=
+// CHECK: Punctuation: "(" [5:15 - 5:16] UnexposedExpr=
+// CHECK: Identifier: "T" [5:16 - 5:17] TypeRef=T:1:13
+// CHECK: Punctuation: ")" [5:17 - 5:18] UnexposedExpr=
+// CHECK: Punctuation: ";" [5:18 - 5:19] CompoundStmt=
+// CHECK: Keyword: "struct" [7:3 - 7:9] VarDecl=x:7:12 (Definition)
+// CHECK: Identifier: "X" [7:10 - 7:11] TypeRef=struct X:2:8
+// CHECK: Identifier: "x" [7:12 - 7:13] VarDecl=x:7:12 (Definition)
+// CHECK: Punctuation: "=" [7:14 - 7:15] VarDecl=x:7:12 (Definition)
+// CHECK: Punctuation: "(" [7:16 - 7:17] CompoundLiteralExpr=
+// CHECK: Keyword: "struct" [7:17 - 7:23] CompoundLiteralExpr=
+// CHECK: Identifier: "X" [7:24 - 7:25] TypeRef=struct X:2:8
+// CHECK: Punctuation: ")" [7:25 - 7:26] CompoundLiteralExpr=
+// CHECK: Punctuation: "{" [7:26 - 7:27] InitListExpr=
+// CHECK: Literal: "1" [7:27 - 7:28] IntegerLiteral=
+// CHECK: Punctuation: "," [7:28 - 7:29] InitListExpr=
+// CHECK: Literal: "2" [7:30 - 7:31] IntegerLiteral=
+// CHECK: Punctuation: "}" [7:31 - 7:32] InitListExpr=
+// CHECK: Punctuation: ";" [7:32 - 7:33] DeclStmt=
+// CHECK: Keyword: "void" [8:3 - 8:7] VarDecl=xx:8:9 (Definition)
+// CHECK: Punctuation: "*" [8:8 - 8:9] VarDecl=xx:8:9 (Definition)
+// CHECK: Identifier: "xx" [8:9 - 8:11] VarDecl=xx:8:9 (Definition)
+// CHECK: Punctuation: "=" [8:12 - 8:13] VarDecl=xx:8:9 (Definition)
+// CHECK: Identifier: "ptr" [8:14 - 8:17] DeclRefExpr=ptr:3:14
+// CHECK: Punctuation: "?" [8:18 - 8:19] UnexposedExpr=
+// CHECK: Punctuation: ":" [8:20 - 8:21] UnexposedExpr=
+// CHECK: Punctuation: "&" [8:22 - 8:23] UnaryOperator=
+// CHECK: Identifier: "x" [8:23 - 8:24] DeclRefExpr=x:7:12
+// CHECK: Punctuation: ";" [8:24 - 8:25] DeclStmt=
+// CHECK: Keyword: "const" [9:3 - 9:8] DeclStmt=
+// CHECK: Keyword: "char" [9:9 - 9:13] VarDecl=hello:9:16 (Definition)
+// CHECK: Punctuation: "*" [9:14 - 9:15] VarDecl=hello:9:16 (Definition)
+// CHECK: Identifier: "hello" [9:16 - 9:21] VarDecl=hello:9:16 (Definition)
+// CHECK: Punctuation: "=" [9:22 - 9:23] VarDecl=hello:9:16 (Definition)
+// CHECK: Literal: ""Hello"" [9:24 - 9:31] StringLiteral=
+// CHECK: Punctuation: ";" [9:31 - 9:32] DeclStmt=
+// CHECK: Punctuation: "}" [10:1 - 10:2] CompoundStmt=
+// CHECK: Keyword: "__builtin_va_arg" [15:9 - 15:25] UnexposedExpr=
+// CHECK: Identifier: "Int" [15:30 - 15:33] TypeRef=Int:12:13
+// CHECK: Keyword: "__builtin_types_compatible_p" [16:9 - 16:37] UnexposedExpr=
+// CHECK: Identifier: "Int" [16:38 - 16:41] TypeRef=Int:12:13
+// CHECK: Punctuation: "," [16:41 - 16:42] UnexposedExpr=
+// CHECK: Identifier: "Int" [16:43 - 16:46] TypeRef=Int:12:13
+// CHECK: Keyword: "struct" [18:3 - 18:9] VarDecl=x:18:12 (Definition)
+// CHECK: Identifier: "X" [18:10 - 18:11] TypeRef=struct X:2:8
+// CHECK: Identifier: "x" [18:12 - 18:13] VarDecl=x:18:12 (Definition)
+// CHECK: Keyword: "do" [19:3 - 19:5] DoStmt=
+// CHECK: Identifier: "x" [20:5 - 20:6] DeclRefExpr=x:18:12
+// CHECK: Punctuation: "." [20:6 - 20:7] MemberRefExpr=a:2:16
+// CHECK: Identifier: "a" [20:7 - 20:8] MemberRefExpr=a:2:16
+// CHECK: Punctuation: "++" [20:8 - 20:10] UnaryOperator=
+// CHECK: Punctuation: ";" [20:10 - 20:11] CompoundStmt=
+// CHECK: Punctuation: "}" [21:3 - 21:4] CompoundStmt=
+// CHECK: Keyword: "while" [21:5 - 21:10] DoStmt=
+// CHECK: Punctuation: "(" [21:11 - 21:12] DoStmt=
+// CHECK: Identifier: "x" [21:12 - 21:13] DeclRefExpr=x:18:12
+// CHECK: Punctuation: "." [21:13 - 21:14] MemberRefExpr=a:2:16
+// CHECK: Identifier: "a" [21:14 - 21:15] MemberRefExpr=a:2:16
+
+// CHECK: Keyword: "enum" [23:3 - 23:7] VarDecl=c:23:14 (Definition)
+// CHECK: Identifier: "Color" [23:8 - 23:13] TypeRef=enum Color:11:6
+// CHECK: Identifier: "c" [23:14 - 23:15] VarDecl=c:23:14 (Definition)
+// CHECK: Punctuation: ";" [23:15 - 23:16] DeclStmt=
+// CHECK: Keyword: "switch" [24:3 - 24:9] SwitchStmt=
+// CHECK: Punctuation: "(" [24:10 - 24:11] SwitchStmt=
+// CHECK: Identifier: "c" [24:11 - 24:12] DeclRefExpr=c:23:14
+// CHECK: Punctuation: ")" [24:12 - 24:13] SwitchStmt=
+// CHECK: Punctuation: "{" [24:14 - 24:15] CompoundStmt=
+// CHECK: Keyword: "case" [25:3 - 25:7] CaseStmt=
+// CHECK: Identifier: "Red" [25:8 - 25:11] DeclRefExpr=Red:11:14
+// CHECK: Punctuation: ":" [25:11 - 25:12] CaseStmt=
+// CHECK: Keyword: "return" [26:5 - 26:11] ReturnStmt=
+// CHECK: Identifier: "Green" [26:12 - 26:17] DeclRefExpr=Green:11:19
+// CHECK: Punctuation: ";" [26:17 - 26:18] CompoundStmt=
+// CHECK: Keyword: "case" [28:3 - 28:7] CaseStmt=
+// CHECK: Identifier: "Green" [28:8 - 28:13] DeclRefExpr=Green:11:19
+// CHECK: Punctuation: ":" [28:13 - 28:14] CaseStmt=
+// CHECK: Keyword: "return" [29:5 - 29:11] ReturnStmt=
+// CHECK: Identifier: "Blue" [29:12 - 29:16] DeclRefExpr=Blue:11:26
+// CHECK: Punctuation: ";" [29:16 - 29:17] CompoundStmt=
+// CHECK: Keyword: "case" [31:3 - 31:7] CaseStmt=
+// CHECK: Identifier: "Blue" [31:8 - 31:12] DeclRefExpr=Blue:11:26
+// CHECK: Punctuation: ":" [31:12 - 31:13] CaseStmt=
+// CHECK: Keyword: "return" [32:5 - 32:11] ReturnStmt=
+// CHECK: Identifier: "Red" [32:12 - 32:15] DeclRefExpr=Red:11:14
+// CHECK: Punctuation: ";" [32:15 - 32:16] CompoundStmt=
+
+// RUN: c-index-test -test-annotate-tokens=%s:4:1:165:32 %s | FileCheck %s
+// RUN: c-index-test -test-annotate-tokens=%s:4:1:165:38 %s | FileCheck %s
diff --git a/clang/test/Index/annotate-tokens.cpp b/clang/test/Index/annotate-tokens.cpp
new file mode 100644
index 0000000..3062901
--- /dev/null
+++ b/clang/test/Index/annotate-tokens.cpp
@@ -0,0 +1,122 @@
+struct bonk { };
+void test(bonk X) {
+ X = X;
+ __is_base_of(bonk, bonk);
+}
+
+struct X {
+ X operator++();
+ X operator++(int);
+};
+void test2(X x) {
+ ++(x);
+ (x)++;
+}
+
+struct S1 { void f(); };
+struct S2 { S1 *operator->(); };
+void test3(S2 s2) {
+ s2->f();
+ X foo;
+}
+
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:21:1 %s | FileCheck %s
+// CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition)
+// CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition)
+// CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition)
+// CHECK: Punctuation: "}" [1:15 - 1:16] StructDecl=bonk:1:8 (Definition)
+// CHECK: Punctuation: ";" [1:16 - 1:17]
+// CHECK: Keyword: "void" [2:1 - 2:5] FunctionDecl=test:2:6 (Definition)
+// CHECK: Identifier: "test" [2:6 - 2:10] FunctionDecl=test:2:6 (Definition)
+// CHECK: Punctuation: "(" [2:10 - 2:11] FunctionDecl=test:2:6 (Definition)
+// CHECK: Identifier: "bonk" [2:11 - 2:15] TypeRef=struct bonk:1:8
+// CHECK: Identifier: "X" [2:16 - 2:17] ParmDecl=X:2:16 (Definition)
+// CHECK: Punctuation: ")" [2:17 - 2:18] FunctionDecl=test:2:6 (Definition)
+// CHECK: Punctuation: "{" [2:19 - 2:20] CompoundStmt=
+// CHECK: Identifier: "X" [3:5 - 3:6] DeclRefExpr=X:2:16
+// CHECK: Punctuation: "=" [3:7 - 3:8] DeclRefExpr=operator=:1:8
+// CHECK: Identifier: "X" [3:9 - 3:10] DeclRefExpr=X:2:16
+// CHECK: Punctuation: ";" [3:10 - 3:11] CompoundStmt=
+// CHECK: Keyword: "__is_base_of" [4:5 - 4:17] UnexposedExpr=
+// CHECK: Punctuation: "(" [4:17 - 4:18] UnexposedExpr=
+// CHECK: Identifier: "bonk" [4:18 - 4:22] TypeRef=struct bonk:1:8
+// CHECK: Punctuation: "," [4:22 - 4:23] UnexposedExpr=
+// CHECK: Identifier: "bonk" [4:24 - 4:28] TypeRef=struct bonk:1:8
+// CHECK: Punctuation: ")" [4:28 - 4:29] UnexposedExpr=
+// CHECK: Punctuation: ";" [4:29 - 4:30] CompoundStmt=
+// CHECK: Punctuation: "}" [5:1 - 5:2] CompoundStmt=
+// CHECK: Keyword: "struct" [7:1 - 7:7] StructDecl=X:7:8 (Definition)
+// CHECK: Identifier: "X" [7:8 - 7:9] StructDecl=X:7:8 (Definition)
+// CHECK: Punctuation: "{" [7:10 - 7:11] StructDecl=X:7:8 (Definition)
+// CHECK: Identifier: "X" [8:3 - 8:4] TypeRef=struct X:7:8
+// CHECK: Keyword: "operator" [8:5 - 8:13] CXXMethod=operator++:8:5
+// CHECK: Punctuation: "++" [8:13 - 8:15] CXXMethod=operator++:8:5
+// CHECK: Punctuation: "(" [8:15 - 8:16] CXXMethod=operator++:8:5
+// CHECK: Punctuation: ")" [8:16 - 8:17] CXXMethod=operator++:8:5
+// CHECK: Punctuation: ";" [8:17 - 8:18] StructDecl=X:7:8 (Definition)
+// CHECK: Identifier: "X" [9:3 - 9:4] TypeRef=struct X:7:8
+// CHECK: Keyword: "operator" [9:5 - 9:13] CXXMethod=operator++:9:5
+// CHECK: Punctuation: "++" [9:13 - 9:15] CXXMethod=operator++:9:5
+// CHECK: Punctuation: "(" [9:15 - 9:16] CXXMethod=operator++:9:5
+// CHECK: Keyword: "int" [9:16 - 9:19] ParmDecl=:9:19 (Definition)
+// CHECK: Punctuation: ")" [9:19 - 9:20] ParmDecl=:9:19 (Definition)
+// CHECK: Punctuation: ";" [9:20 - 9:21] StructDecl=X:7:8 (Definition)
+// CHECK: Punctuation: "}" [10:1 - 10:2] StructDecl=X:7:8 (Definition)
+// CHECK: Punctuation: ";" [10:2 - 10:3]
+// CHECK: Keyword: "void" [11:1 - 11:5] FunctionDecl=test2:11:6 (Definition)
+// CHECK: Identifier: "test2" [11:6 - 11:11] FunctionDecl=test2:11:6 (Definition)
+// CHECK: Punctuation: "(" [11:11 - 11:12] FunctionDecl=test2:11:6 (Definition)
+// CHECK: Identifier: "X" [11:12 - 11:13] TypeRef=struct X:7:8
+// CHECK: Identifier: "x" [11:14 - 11:15] ParmDecl=x:11:14 (Definition)
+// CHECK: Punctuation: ")" [11:15 - 11:16] FunctionDecl=test2:11:6 (Definition)
+// CHECK: Punctuation: "{" [11:17 - 11:18] CompoundStmt=
+// CHECK: Punctuation: "++" [12:3 - 12:5] CallExpr=operator++:8:5
+// CHECK: Punctuation: "(" [12:5 - 12:6] ParenExpr=
+// CHECK: Identifier: "x" [12:6 - 12:7] DeclRefExpr=x:11:14
+// CHECK: Punctuation: ")" [12:7 - 12:8] ParenExpr=
+// CHECK: Punctuation: ";" [12:8 - 12:9] CompoundStmt=
+// CHECK: Punctuation: "(" [13:3 - 13:4] ParenExpr=
+// CHECK: Identifier: "x" [13:4 - 13:5] DeclRefExpr=x:11:14
+// CHECK: Punctuation: ")" [13:5 - 13:6] ParenExpr=
+// CHECK: Punctuation: "++" [13:6 - 13:8] DeclRefExpr=operator++:9:5
+// CHECK: Punctuation: ";" [13:8 - 13:9] CompoundStmt=
+// CHECK: Punctuation: "}" [14:1 - 14:2] CompoundStmt=
+// CHECK: Keyword: "struct" [16:1 - 16:7] StructDecl=S1:16:8 (Definition)
+// CHECK: Identifier: "S1" [16:8 - 16:10] StructDecl=S1:16:8 (Definition)
+// CHECK: Punctuation: "{" [16:11 - 16:12] StructDecl=S1:16:8 (Definition)
+// CHECK: Keyword: "void" [16:13 - 16:17] CXXMethod=f:16:18
+// CHECK: Identifier: "f" [16:18 - 16:19] CXXMethod=f:16:18
+// CHECK: Punctuation: "(" [16:19 - 16:20] CXXMethod=f:16:18
+// CHECK: Punctuation: ")" [16:20 - 16:21] CXXMethod=f:16:18
+// CHECK: Punctuation: ";" [16:21 - 16:22] StructDecl=S1:16:8 (Definition)
+// CHECK: Punctuation: "}" [16:23 - 16:24] StructDecl=S1:16:8 (Definition)
+// CHECK: Punctuation: ";" [16:24 - 16:25]
+// CHECK: Keyword: "struct" [17:1 - 17:7] StructDecl=S2:17:8 (Definition)
+// CHECK: Identifier: "S2" [17:8 - 17:10] StructDecl=S2:17:8 (Definition)
+// CHECK: Punctuation: "{" [17:11 - 17:12] StructDecl=S2:17:8 (Definition)
+// CHECK: Identifier: "S1" [17:13 - 17:15] TypeRef=struct S1:16:8
+// CHECK: Punctuation: "*" [17:16 - 17:17] CXXMethod=operator->:17:17
+// CHECK: Keyword: "operator" [17:17 - 17:25] CXXMethod=operator->:17:17
+// CHECK: Punctuation: "->" [17:25 - 17:27] CXXMethod=operator->:17:17
+// CHECK: Punctuation: "(" [17:27 - 17:28] CXXMethod=operator->:17:17
+// CHECK: Punctuation: ")" [17:28 - 17:29] CXXMethod=operator->:17:17
+// CHECK: Punctuation: ";" [17:29 - 17:30] StructDecl=S2:17:8 (Definition)
+// CHECK: Punctuation: "}" [17:31 - 17:32] StructDecl=S2:17:8 (Definition)
+// CHECK: Punctuation: ";" [17:32 - 17:33]
+// CHECK: Keyword: "void" [18:1 - 18:5] FunctionDecl=test3:18:6 (Definition)
+// CHECK: Identifier: "test3" [18:6 - 18:11] FunctionDecl=test3:18:6 (Definition)
+// CHECK: Punctuation: "(" [18:11 - 18:12] FunctionDecl=test3:18:6 (Definition)
+// CHECK: Identifier: "S2" [18:12 - 18:14] TypeRef=struct S2:17:8
+// CHECK: Identifier: "s2" [18:15 - 18:17] ParmDecl=s2:18:15 (Definition)
+// CHECK: Punctuation: ")" [18:17 - 18:18] FunctionDecl=test3:18:6 (Definition)
+// CHECK: Punctuation: "{" [18:19 - 18:20] CompoundStmt=
+// CHECK: Identifier: "s2" [19:3 - 19:5] DeclRefExpr=s2:18:15
+// CHECK: Punctuation: "->" [19:5 - 19:7] DeclRefExpr=operator->:17:17
+// CHECK: Identifier: "f" [19:7 - 19:8] MemberRefExpr=f:16:18
+// CHECK: Punctuation: "(" [19:8 - 19:9] CallExpr=f:16:18
+// CHECK: Punctuation: ")" [19:9 - 19:10] CallExpr=f:16:18
+// CHECK: Punctuation: ";" [19:10 - 19:11] CompoundStmt=
+// CHECK: Identifier: "X" [20:3 - 20:4] TypeRef=struct X:7:8
+// CHECK: Identifier: "foo" [20:5 - 20:8] VarDecl=foo:20:5 (Definition)
+// CHECK: Punctuation: ";" [20:8 - 20:9] DeclStmt=
+// CHECK: Punctuation: "}" [21:1 - 21:2] CompoundStmt=
diff --git a/clang/test/Index/annotate-tokens.m b/clang/test/Index/annotate-tokens.m
new file mode 100644
index 0000000..1a48293
--- /dev/null
+++ b/clang/test/Index/annotate-tokens.m
@@ -0,0 +1,576 @@
+@interface Foo
+- (int)compare:(Foo*)other;
+@end
+
+@implementation Foo
+- (int)compare:(Foo*)other {
+ return 0;
+ (void)@encode(Foo);
+}
+@end
+
+// From <rdar://problem/7971430>, the 'barType' referenced in the ivar
+// declarations should be annotated as TypeRefs.
+typedef int * barType;
+@interface Bar
+{
+ barType iVar;
+ barType iVar1, iVar2;
+}
+@end
+@implementation Bar
+- (void) method
+{
+ barType local = iVar;
+}
+@end
+
+// From <rdar://problem/7967123>. The ranges for attributes are not
+// currently stored, causing most of the tokens to be falsely annotated.
+// Since there are no source ranges for attributes, we currently don't
+// annotate them.
+@interface IBActionTests
+- (IBAction) actionMethod:(in id)arg;
+- (void)foo:(int)x;
+@end
+extern int ibaction_test(void);
+@implementation IBActionTests
+- (IBAction) actionMethod:(in id)arg
+{
+ ibaction_test();
+ [self foo:0];
+}
+- (void) foo:(int)x
+{
+ (void) x;
+}
+@end
+
+// From <rdar://problem/7961995>. Essentially the same issue as 7967123,
+// but impacting code marked as IBOutlets.
+@interface IBOutletTests
+{
+ IBOutlet char * anOutlet;
+}
+- (IBAction) actionMethod:(id)arg;
+@property IBOutlet int * aPropOutlet;
+@end
+
+// From <rdar://problem/7974151>. The first 'foo:' wasn't being annotated as
+// being part of the Objective-C message expression since the argument
+// was expanded from a macro.
+
+#define VAL 0
+
+@interface R7974151
+- (int) foo:(int)arg;
+- (int) method;
+@end
+
+@implementation R7974151
+- (int) foo:(int)arg {
+ return arg;
+}
+- (int) method
+{
+ int local = [self foo:VAL];
+ int second = [self foo:0];
+ return local;
+}
+- (int)othermethod:(IBOutletTests *)ibt {
+ return *ibt.aPropOutlet;
+}
+@end
+
+@protocol Proto @end
+
+void f() {
+ (void)@protocol(Proto);
+}
+
+// <rdar://problem/8595462> - Properly annotate functions and variables
+// declared within an @implementation.
+@class Rdar8595462_A;
+@interface Rdar8595462_B
+@end
+
+@implementation Rdar8595462_B
+Rdar8595462_A * Rdar8595462_aFunction() {
+ Rdar8595462_A * localVar = 0;
+ return localVar;
+}
+static Rdar8595462_A * Rdar8595462_staticVar;
+@end
+
+// <rdar://problem/8595386> Issues doing syntax coloring of properties
+@interface Rdar8595386 {
+ Foo *_foo;
+}
+
+@property (readonly, copy) Foo *foo;
+@property (readonly) Foo *foo2;
+@end
+
+@implementation Rdar8595386
+@synthesize foo = _foo;
+@dynamic foo2;
+@end
+
+// <rdar://problem/8778404> Blocks don't get colored if annotation starts within the block itself
+@interface Rdar8778404
+@end
+
+@implementation Rdar8778404
+- (int)blah:(int)arg, ... { return arg; }
+- (int)blarg:(int)x {
+ (void)^ {
+ int result = [self blah:5, x];
+ Rdar8778404 *a = self;
+ return 0;
+ };
+}
+@end
+
+@interface Rdar8062781
++ (Foo*)getB;
+@property (readonly, nonatomic) Foo *blah;
+@property (readonly, atomic) Foo *abah;
+@end
+
+@interface rdar9535717 {
+ __weak Foo *foo;
+}
+@end
+
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:118:1 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' | FileCheck %s
+// CHECK: Punctuation: "@" [1:1 - 1:2] ObjCInterfaceDecl=Foo:1:12
+// CHECK: Keyword: "interface" [1:2 - 1:11] ObjCInterfaceDecl=Foo:1:12
+// CHECK: Identifier: "Foo" [1:12 - 1:15] ObjCInterfaceDecl=Foo:1:12
+// CHECK: Punctuation: "-" [2:1 - 2:2] ObjCInstanceMethodDecl=compare::2:8
+// CHECK: Punctuation: "(" [2:3 - 2:4] ObjCInstanceMethodDecl=compare::2:8
+// CHECK: Keyword: "int" [2:4 - 2:7] ObjCInstanceMethodDecl=compare::2:8
+// CHECK: Punctuation: ")" [2:7 - 2:8] ObjCInstanceMethodDecl=compare::2:8
+// CHECK: Identifier: "compare" [2:8 - 2:15] ObjCInstanceMethodDecl=compare::2:8
+// CHECK: Punctuation: ":" [2:15 - 2:16] ObjCInstanceMethodDecl=compare::2:8
+// CHECK: Punctuation: "(" [2:16 - 2:17] ObjCInstanceMethodDecl=compare::2:8
+// CHECK: Identifier: "Foo" [2:17 - 2:20] ObjCClassRef=Foo:1:12
+// CHECK: Punctuation: "*" [2:20 - 2:21] ParmDecl=other:2:22 (Definition)
+// CHECK: Punctuation: ")" [2:21 - 2:22] ParmDecl=other:2:22 (Definition)
+// CHECK: Identifier: "other" [2:22 - 2:27] ParmDecl=other:2:22 (Definition)
+// CHECK: Punctuation: ";" [2:27 - 2:28] ObjCInstanceMethodDecl=compare::2:8
+// CHECK: Punctuation: "@" [3:1 - 3:2] ObjCInterfaceDecl=Foo:1:12
+// CHECK: Keyword: "end" [3:2 - 3:5] ObjCInterfaceDecl=Foo:1:12
+// CHECK: Punctuation: "@" [5:1 - 5:2] ObjCImplementationDecl=Foo:5:17 (Definition)
+// CHECK: Keyword: "implementation" [5:2 - 5:16] ObjCImplementationDecl=Foo:5:17 (Definition)
+// CHECK: Identifier: "Foo" [5:17 - 5:20] ObjCImplementationDecl=Foo:5:17 (Definition)
+// CHECK: Punctuation: "-" [6:1 - 6:2] ObjCInstanceMethodDecl=compare::6:8 (Definition)
+// CHECK: Punctuation: "(" [6:3 - 6:4] ObjCInstanceMethodDecl=compare::6:8 (Definition)
+// CHECK: Keyword: "int" [6:4 - 6:7] ObjCInstanceMethodDecl=compare::6:8 (Definition)
+// CHECK: Punctuation: ")" [6:7 - 6:8] ObjCInstanceMethodDecl=compare::6:8 (Definition)
+// CHECK: Identifier: "compare" [6:8 - 6:15] ObjCInstanceMethodDecl=compare::6:8 (Definition)
+// CHECK: Punctuation: ":" [6:15 - 6:16] ObjCInstanceMethodDecl=compare::6:8 (Definition)
+// CHECK: Punctuation: "(" [6:16 - 6:17] ObjCInstanceMethodDecl=compare::6:8 (Definition)
+// CHECK: Identifier: "Foo" [6:17 - 6:20] ObjCClassRef=Foo:1:12
+// CHECK: Punctuation: "*" [6:20 - 6:21] ParmDecl=other:6:22 (Definition)
+// CHECK: Punctuation: ")" [6:21 - 6:22] ParmDecl=other:6:22 (Definition)
+// CHECK: Identifier: "other" [6:22 - 6:27] ParmDecl=other:6:22 (Definition)
+// CHECK: Punctuation: "{" [6:28 - 6:29] CompoundStmt=
+// CHECK: Keyword: "return" [7:3 - 7:9] ReturnStmt=
+// CHECK: Literal: "0" [7:10 - 7:11] IntegerLiteral=
+// CHECK: Punctuation: ";" [7:11 - 7:12] CompoundStmt=
+// CHECK: Punctuation: "(" [8:3 - 8:4] CStyleCastExpr=
+// CHECK: Keyword: "void" [8:4 - 8:8] CStyleCastExpr=
+// CHECK: Punctuation: ")" [8:8 - 8:9] CStyleCastExpr=
+// CHECK: Punctuation: "@" [8:9 - 8:10] ObjCEncodeExpr=
+// CHECK: Keyword: "encode" [8:10 - 8:16] ObjCEncodeExpr=
+// CHECK: Punctuation: "(" [8:16 - 8:17] ObjCEncodeExpr=
+// CHECK: Identifier: "Foo" [8:17 - 8:20] ObjCClassRef=Foo:1:12
+// CHECK: Punctuation: ")" [8:20 - 8:21] ObjCEncodeExpr=
+// CHECK: Punctuation: ";" [8:21 - 8:22] CompoundStmt=
+// CHECK: Punctuation: "}" [9:1 - 9:2] CompoundStmt=
+// CHECK: Punctuation: "@" [10:1 - 10:2] ObjCImplementationDecl=Foo:5:17 (Definition)
+// CHECK: Keyword: "end" [10:2 - 10:5]
+// CHECK: Keyword: "typedef" [14:1 - 14:8]
+// CHECK: Keyword: "int" [14:9 - 14:12]
+// CHECK: Punctuation: "*" [14:13 - 14:14]
+// CHECK: Identifier: "barType" [14:15 - 14:22] TypedefDecl=barType:14:15 (Definition)
+// CHECK: Punctuation: ";" [14:22 - 14:23]
+// CHECK: Punctuation: "@" [15:1 - 15:2] ObjCInterfaceDecl=Bar:15:12
+// CHECK: Keyword: "interface" [15:2 - 15:11] ObjCInterfaceDecl=Bar:15:12
+// CHECK: Identifier: "Bar" [15:12 - 15:15] ObjCInterfaceDecl=Bar:15:12
+// CHECK: Punctuation: "{" [16:1 - 16:2] ObjCInterfaceDecl=Bar:15:12
+// CHECK: Identifier: "barType" [17:5 - 17:12] TypeRef=barType:14:15
+// CHECK: Identifier: "iVar" [17:13 - 17:17] ObjCIvarDecl=iVar:17:13 (Definition)
+// CHECK: Punctuation: ";" [17:17 - 17:18] ObjCInterfaceDecl=Bar:15:12
+// CHECK: Identifier: "barType" [18:5 - 18:12] TypeRef=barType:14:15
+// CHECK: Identifier: "iVar1" [18:13 - 18:18] ObjCIvarDecl=iVar1:18:13 (Definition)
+// CHECK: Punctuation: "," [18:18 - 18:19] ObjCIvarDecl=iVar2:18:20 (Definition)
+// CHECK: Identifier: "iVar2" [18:20 - 18:25] ObjCIvarDecl=iVar2:18:20 (Definition)
+// CHECK: Punctuation: ";" [18:25 - 18:26] ObjCInterfaceDecl=Bar:15:12
+// CHECK: Punctuation: "}" [19:1 - 19:2] ObjCInterfaceDecl=Bar:15:12
+// CHECK: Punctuation: "@" [20:1 - 20:2] ObjCInterfaceDecl=Bar:15:12
+// CHECK: Keyword: "end" [20:2 - 20:5] ObjCInterfaceDecl=Bar:15:12
+// CHECK: Punctuation: "@" [21:1 - 21:2] ObjCImplementationDecl=Bar:21:17 (Definition)
+// CHECK: Keyword: "implementation" [21:2 - 21:16] ObjCImplementationDecl=Bar:21:17 (Definition)
+// CHECK: Identifier: "Bar" [21:17 - 21:20] ObjCImplementationDecl=Bar:21:17 (Definition)
+// CHECK: Punctuation: "-" [22:1 - 22:2] ObjCInstanceMethodDecl=method:22:10 (Definition)
+// CHECK: Punctuation: "(" [22:3 - 22:4] ObjCInstanceMethodDecl=method:22:10 (Definition)
+// CHECK: Keyword: "void" [22:4 - 22:8] ObjCInstanceMethodDecl=method:22:10 (Definition)
+// CHECK: Punctuation: ")" [22:8 - 22:9] ObjCInstanceMethodDecl=method:22:10 (Definition)
+// CHECK: Identifier: "method" [22:10 - 22:16] ObjCInstanceMethodDecl=method:22:10 (Definition)
+// CHECK: Punctuation: "{" [23:1 - 23:2] CompoundStmt=
+// CHECK: Identifier: "barType" [24:5 - 24:12] TypeRef=barType:14:15
+// CHECK: Identifier: "local" [24:13 - 24:18] VarDecl=local:24:13 (Definition)
+// CHECK: Punctuation: "=" [24:19 - 24:20] VarDecl=local:24:13 (Definition)
+// CHECK: Identifier: "iVar" [24:21 - 24:25] MemberRefExpr=iVar:17:13
+// CHECK: Punctuation: ";" [24:25 - 24:26] DeclStmt=
+// CHECK: Punctuation: "}" [25:1 - 25:2] CompoundStmt=
+// CHECK: Punctuation: "@" [26:1 - 26:2] ObjCImplementationDecl=Bar:21:17 (Definition)
+// CHECK: Keyword: "end" [26:2 - 26:5]
+// CHECK: Punctuation: "@" [32:1 - 32:2] ObjCInterfaceDecl=IBActionTests:32:12
+// CHECK: Keyword: "interface" [32:2 - 32:11] ObjCInterfaceDecl=IBActionTests:32:12
+// CHECK: Identifier: "IBActionTests" [32:12 - 32:25] ObjCInterfaceDecl=IBActionTests:32:12
+// CHECK: Punctuation: "-" [33:1 - 33:2] ObjCInstanceMethodDecl=actionMethod::33:1
+// CHECK: Punctuation: "(" [33:3 - 33:4] ObjCInstanceMethodDecl=actionMethod::33:1
+// CHECK: Identifier: "IBAction" [33:4 - 33:12] macro expansion=IBAction
+// CHECK: Punctuation: ")" [33:12 - 33:13] ObjCInstanceMethodDecl=actionMethod::33:1
+// CHECK: Identifier: "actionMethod" [33:14 - 33:26] ObjCInstanceMethodDecl=actionMethod::33:1
+// CHECK: Punctuation: ":" [33:26 - 33:27] ObjCInstanceMethodDecl=actionMethod::33:1
+// CHECK: Punctuation: "(" [33:27 - 33:28] ObjCInstanceMethodDecl=actionMethod::33:1
+// CHECK: Keyword: "in" [33:28 - 33:30] ObjCInstanceMethodDecl=actionMethod::33:1
+// CHECK: Identifier: "id" [33:31 - 33:33] TypeRef=id:0:0
+// CHECK: Punctuation: ")" [33:33 - 33:34] ParmDecl=arg:33:34 (Definition)
+// CHECK: Identifier: "arg" [33:34 - 33:37] ParmDecl=arg:33:34 (Definition)
+// CHECK: Punctuation: ";" [33:37 - 33:38] ObjCInstanceMethodDecl=actionMethod::33:1
+// CHECK: Punctuation: "-" [34:1 - 34:2] ObjCInstanceMethodDecl=foo::34:9
+// CHECK: Punctuation: "(" [34:3 - 34:4] ObjCInstanceMethodDecl=foo::34:9
+// CHECK: Keyword: "void" [34:4 - 34:8] ObjCInstanceMethodDecl=foo::34:9
+// CHECK: Punctuation: ")" [34:8 - 34:9] ObjCInstanceMethodDecl=foo::34:9
+// CHECK: Identifier: "foo" [34:9 - 34:12] ObjCInstanceMethodDecl=foo::34:9
+// CHECK: Punctuation: ":" [34:12 - 34:13] ObjCInstanceMethodDecl=foo::34:9
+// CHECK: Punctuation: "(" [34:13 - 34:14] ObjCInstanceMethodDecl=foo::34:9
+// CHECK: Keyword: "int" [34:14 - 34:17] ParmDecl=x:34:18 (Definition)
+// CHECK: Punctuation: ")" [34:17 - 34:18] ParmDecl=x:34:18 (Definition)
+// CHECK: Identifier: "x" [34:18 - 34:19] ParmDecl=x:34:18 (Definition)
+// CHECK: Punctuation: ";" [34:19 - 34:20] ObjCInstanceMethodDecl=foo::34:9
+// CHECK: Punctuation: "@" [35:1 - 35:2] ObjCInterfaceDecl=IBActionTests:32:12
+// CHECK: Keyword: "end" [35:2 - 35:5] ObjCInterfaceDecl=IBActionTests:32:12
+// CHECK: Keyword: "extern" [36:1 - 36:7]
+// CHECK: Keyword: "int" [36:8 - 36:11] FunctionDecl=ibaction_test:36:12
+// CHECK: Identifier: "ibaction_test" [36:12 - 36:25] FunctionDecl=ibaction_test:36:12
+// CHECK: Punctuation: "(" [36:25 - 36:26] FunctionDecl=ibaction_test:36:12
+// CHECK: Keyword: "void" [36:26 - 36:30] FunctionDecl=ibaction_test:36:12
+// CHECK: Punctuation: ")" [36:30 - 36:31] FunctionDecl=ibaction_test:36:12
+// CHECK: Punctuation: ";" [36:31 - 36:32]
+// CHECK: Punctuation: "@" [37:1 - 37:2] ObjCImplementationDecl=IBActionTests:37:17 (Definition)
+// CHECK: Keyword: "implementation" [37:2 - 37:16] ObjCImplementationDecl=IBActionTests:37:17 (Definition)
+// CHECK: Identifier: "IBActionTests" [37:17 - 37:30] ObjCImplementationDecl=IBActionTests:37:17 (Definition)
+// CHECK: Punctuation: "-" [38:1 - 38:2] ObjCInstanceMethodDecl=actionMethod::38:14 (Definition)
+// CHECK: Punctuation: "(" [38:3 - 38:4] ObjCInstanceMethodDecl=actionMethod::38:14 (Definition)
+// CHECK: Identifier: "IBAction" [38:4 - 38:12] macro expansion=IBAction
+// CHECK: Punctuation: ")" [38:12 - 38:13] ObjCInstanceMethodDecl=actionMethod::38:14 (Definition)
+// CHECK: Identifier: "actionMethod" [38:14 - 38:26] ObjCInstanceMethodDecl=actionMethod::38:14 (Definition)
+// CHECK: Punctuation: ":" [38:26 - 38:27] ObjCInstanceMethodDecl=actionMethod::38:14 (Definition)
+// CHECK: Keyword: "in" [38:28 - 38:30] ObjCInstanceMethodDecl=actionMethod::38:14 (Definition)
+// CHECK: Identifier: "id" [38:31 - 38:33] TypeRef=id:0:0
+// CHECK: Punctuation: ")" [38:33 - 38:34] ParmDecl=arg:38:34 (Definition)
+// CHECK: Identifier: "arg" [38:34 - 38:37] ParmDecl=arg:38:34 (Definition)
+// CHECK: Punctuation: "{" [39:1 - 39:2] CompoundStmt=
+// CHECK: Identifier: "ibaction_test" [40:5 - 40:18] DeclRefExpr=ibaction_test:36:12
+// CHECK: Punctuation: "(" [40:18 - 40:19] CallExpr=ibaction_test:36:12
+// CHECK: Punctuation: ")" [40:19 - 40:20] CallExpr=ibaction_test:36:12
+// CHECK: Punctuation: ";" [40:20 - 40:21] CompoundStmt=
+// CHECK: Punctuation: "[" [41:5 - 41:6] ObjCMessageExpr=foo::34:9
+// CHECK: Identifier: "self" [41:6 - 41:10] DeclRefExpr=self:0:0
+// CHECK: Identifier: "foo" [41:11 - 41:14] ObjCMessageExpr=foo::34:9
+// CHECK: Punctuation: ":" [41:14 - 41:15] ObjCMessageExpr=foo::34:9
+// CHECK: Literal: "0" [41:15 - 41:16] IntegerLiteral=
+// CHECK: Punctuation: "]" [41:16 - 41:17] ObjCMessageExpr=foo::34:9
+// CHECK: Punctuation: ";" [41:17 - 41:18] CompoundStmt=
+// CHECK: Punctuation: "}" [42:1 - 42:2] CompoundStmt=
+// CHECK: Punctuation: "-" [43:1 - 43:2] ObjCInstanceMethodDecl=foo::43:10 (Definition)
+// CHECK: Punctuation: "(" [43:3 - 43:4] ObjCInstanceMethodDecl=foo::43:10 (Definition)
+// CHECK: Keyword: "void" [43:4 - 43:8] ObjCInstanceMethodDecl=foo::43:10 (Definition)
+// CHECK: Punctuation: ")" [43:8 - 43:9] ObjCInstanceMethodDecl=foo::43:10 (Definition)
+// CHECK: Identifier: "foo" [43:10 - 43:13] ObjCInstanceMethodDecl=foo::43:10 (Definition)
+// CHECK: Punctuation: ":" [43:13 - 43:14] ObjCInstanceMethodDecl=foo::43:10 (Definition)
+// CHECK: Punctuation: "(" [43:14 - 43:15] ObjCInstanceMethodDecl=foo::43:10 (Definition)
+// CHECK: Keyword: "int" [43:15 - 43:18] ParmDecl=x:43:19 (Definition)
+// CHECK: Punctuation: ")" [43:18 - 43:19] ParmDecl=x:43:19 (Definition)
+// CHECK: Identifier: "x" [43:19 - 43:20] ParmDecl=x:43:19 (Definition)
+// CHECK: Punctuation: "{" [44:1 - 44:2] CompoundStmt=
+// CHECK: Punctuation: "(" [45:3 - 45:4] CStyleCastExpr=
+// CHECK: Keyword: "void" [45:4 - 45:8] CStyleCastExpr=
+// CHECK: Punctuation: ")" [45:8 - 45:9] CStyleCastExpr=
+// CHECK: Identifier: "x" [45:10 - 45:11] DeclRefExpr=x:43:19
+// CHECK: Punctuation: ";" [45:11 - 45:12] CompoundStmt=
+// CHECK: Punctuation: "}" [46:1 - 46:2] CompoundStmt=
+// CHECK: Punctuation: "@" [47:1 - 47:2] ObjCImplementationDecl=IBActionTests:37:17 (Definition)
+// CHECK: Keyword: "end" [47:2 - 47:5]
+// CHECK: Punctuation: "@" [51:1 - 51:2] ObjCInterfaceDecl=IBOutletTests:51:12
+// CHECK: Keyword: "interface" [51:2 - 51:11] ObjCInterfaceDecl=IBOutletTests:51:12
+// CHECK: Identifier: "IBOutletTests" [51:12 - 51:25] ObjCInterfaceDecl=IBOutletTests:51:12
+// CHECK: Punctuation: "{" [52:1 - 52:2] ObjCInterfaceDecl=IBOutletTests:51:12
+// CHECK: Identifier: "IBOutlet" [53:5 - 53:13] macro expansion=IBOutlet
+// CHECK: Keyword: "char" [53:14 - 53:18] ObjCIvarDecl=anOutlet:53:21 (Definition)
+// CHECK: Punctuation: "*" [53:19 - 53:20] ObjCIvarDecl=anOutlet:53:21 (Definition)
+// CHECK: Identifier: "anOutlet" [53:21 - 53:29] ObjCIvarDecl=anOutlet:53:21 (Definition)
+// CHECK: Punctuation: ";" [53:29 - 53:30] ObjCInterfaceDecl=IBOutletTests:51:12
+// CHECK: Punctuation: "}" [54:1 - 54:2] ObjCInterfaceDecl=IBOutletTests:51:12
+// CHECK: Punctuation: "-" [55:1 - 55:2] ObjCInstanceMethodDecl=actionMethod::55:1
+// CHECK: Punctuation: "(" [55:3 - 55:4] ObjCInstanceMethodDecl=actionMethod::55:1
+// CHECK: Identifier: "IBAction" [55:4 - 55:12] macro expansion=IBAction
+// CHECK: Punctuation: ")" [55:12 - 55:13] ObjCInstanceMethodDecl=actionMethod::55:1
+// CHECK: Identifier: "actionMethod" [55:14 - 55:26] ObjCInstanceMethodDecl=actionMethod::55:1
+// CHECK: Punctuation: ":" [55:26 - 55:27] ObjCInstanceMethodDecl=actionMethod::55:1
+// CHECK: Punctuation: "(" [55:27 - 55:28] ObjCInstanceMethodDecl=actionMethod::55:1
+// CHECK: Identifier: "id" [55:28 - 55:30] TypeRef=id:0:0
+// CHECK: Punctuation: ")" [55:30 - 55:31] ParmDecl=arg:55:31 (Definition)
+// CHECK: Identifier: "arg" [55:31 - 55:34] ParmDecl=arg:55:31 (Definition)
+// CHECK: Punctuation: ";" [55:34 - 55:35] ObjCInstanceMethodDecl=actionMethod::55:1
+// CHECK: Punctuation: "@" [56:1 - 56:2] ObjCPropertyDecl=aPropOutlet:56:26
+// CHECK: Keyword: "property" [56:2 - 56:10] ObjCPropertyDecl=aPropOutlet:56:26
+// CHECK: Identifier: "IBOutlet" [56:11 - 56:19] macro expansion=IBOutlet
+// CHECK: Keyword: "int" [56:20 - 56:23] ObjCPropertyDecl=aPropOutlet:56:26
+// CHECK: Punctuation: "*" [56:24 - 56:25] ObjCPropertyDecl=aPropOutlet:56:26
+// CHECK: Identifier: "aPropOutlet" [56:26 - 56:37] ObjCPropertyDecl=aPropOutlet:56:26
+// CHECK: Punctuation: ";" [56:37 - 56:38] ObjCInterfaceDecl=IBOutletTests:51:12
+// CHECK: Punctuation: "@" [57:1 - 57:2] ObjCInterfaceDecl=IBOutletTests:51:12
+// CHECK: Keyword: "end" [57:2 - 57:5] ObjCInterfaceDecl=IBOutletTests:51:12
+// CHECK: Punctuation: "#" [63:1 - 63:2] preprocessing directive=
+// CHECK: Identifier: "define" [63:2 - 63:8] preprocessing directive=
+// CHECK: Identifier: "VAL" [63:9 - 63:12] macro definition=VAL
+// CHECK: Literal: "0" [63:13 - 63:14] macro definition=VAL
+// CHECK: Punctuation: "@" [65:1 - 65:2] ObjCInterfaceDecl=R7974151:65:12
+// CHECK: Keyword: "interface" [65:2 - 65:11] ObjCInterfaceDecl=R7974151:65:12
+// CHECK: Identifier: "R7974151" [65:12 - 65:20] ObjCInterfaceDecl=R7974151:65:12
+// CHECK: Punctuation: "-" [66:1 - 66:2] ObjCInstanceMethodDecl=foo::66:9
+// CHECK: Punctuation: "(" [66:3 - 66:4] ObjCInstanceMethodDecl=foo::66:9
+// CHECK: Keyword: "int" [66:4 - 66:7] ObjCInstanceMethodDecl=foo::66:9
+// CHECK: Punctuation: ")" [66:7 - 66:8] ObjCInstanceMethodDecl=foo::66:9
+// CHECK: Identifier: "foo" [66:9 - 66:12] ObjCInstanceMethodDecl=foo::66:9
+// CHECK: Punctuation: ":" [66:12 - 66:13] ObjCInstanceMethodDecl=foo::66:9
+// CHECK: Punctuation: "(" [66:13 - 66:14] ObjCInstanceMethodDecl=foo::66:9
+// CHECK: Keyword: "int" [66:14 - 66:17] ParmDecl=arg:66:18 (Definition)
+// CHECK: Punctuation: ")" [66:17 - 66:18] ParmDecl=arg:66:18 (Definition)
+// CHECK: Identifier: "arg" [66:18 - 66:21] ParmDecl=arg:66:18 (Definition)
+// CHECK: Punctuation: ";" [66:21 - 66:22] ObjCInstanceMethodDecl=foo::66:9
+// CHECK: Punctuation: "-" [67:1 - 67:2] ObjCInstanceMethodDecl=method:67:9
+// CHECK: Punctuation: "(" [67:3 - 67:4] ObjCInstanceMethodDecl=method:67:9
+// CHECK: Keyword: "int" [67:4 - 67:7] ObjCInstanceMethodDecl=method:67:9
+// CHECK: Punctuation: ")" [67:7 - 67:8] ObjCInstanceMethodDecl=method:67:9
+// CHECK: Identifier: "method" [67:9 - 67:15] ObjCInstanceMethodDecl=method:67:9
+// CHECK: Punctuation: ";" [67:15 - 67:16] ObjCInstanceMethodDecl=method:67:9
+// CHECK: Punctuation: "@" [68:1 - 68:2] ObjCInterfaceDecl=R7974151:65:12
+// CHECK: Keyword: "end" [68:2 - 68:5] ObjCInterfaceDecl=R7974151:65:12
+// CHECK: Punctuation: "@" [70:1 - 70:2] ObjCImplementationDecl=R7974151:70:17 (Definition)
+// CHECK: Keyword: "implementation" [70:2 - 70:16] ObjCImplementationDecl=R7974151:70:17 (Definition)
+// CHECK: Identifier: "R7974151" [70:17 - 70:25] ObjCImplementationDecl=R7974151:70:17 (Definition)
+// CHECK: Punctuation: "-" [71:1 - 71:2] ObjCInstanceMethodDecl=foo::71:9 (Definition)
+// CHECK: Punctuation: "(" [71:3 - 71:4] ObjCInstanceMethodDecl=foo::71:9 (Definition)
+// CHECK: Keyword: "int" [71:4 - 71:7] ObjCInstanceMethodDecl=foo::71:9 (Definition)
+// CHECK: Punctuation: ")" [71:7 - 71:8] ObjCInstanceMethodDecl=foo::71:9 (Definition)
+// CHECK: Identifier: "foo" [71:9 - 71:12] ObjCInstanceMethodDecl=foo::71:9 (Definition)
+// CHECK: Punctuation: ":" [71:12 - 71:13] ObjCInstanceMethodDecl=foo::71:9 (Definition)
+// CHECK: Punctuation: "(" [71:13 - 71:14] ObjCInstanceMethodDecl=foo::71:9 (Definition)
+// CHECK: Keyword: "int" [71:14 - 71:17] ParmDecl=arg:71:18 (Definition)
+// CHECK: Punctuation: ")" [71:17 - 71:18] ParmDecl=arg:71:18 (Definition)
+// CHECK: Identifier: "arg" [71:18 - 71:21] ParmDecl=arg:71:18 (Definition)
+// CHECK: Punctuation: "{" [71:22 - 71:23] CompoundStmt=
+// CHECK: Keyword: "return" [72:3 - 72:9] ReturnStmt=
+// CHECK: Identifier: "arg" [72:10 - 72:13] DeclRefExpr=arg:71:18
+// CHECK: Punctuation: ";" [72:13 - 72:14] CompoundStmt=
+// CHECK: Punctuation: "}" [73:1 - 73:2] CompoundStmt=
+// CHECK: Punctuation: "-" [74:1 - 74:2] ObjCInstanceMethodDecl=method:74:9 (Definition)
+// CHECK: Punctuation: "(" [74:3 - 74:4] ObjCInstanceMethodDecl=method:74:9 (Definition)
+// CHECK: Keyword: "int" [74:4 - 74:7] ObjCInstanceMethodDecl=method:74:9 (Definition)
+// CHECK: Punctuation: ")" [74:7 - 74:8] ObjCInstanceMethodDecl=method:74:9 (Definition)
+// CHECK: Identifier: "method" [74:9 - 74:15] ObjCInstanceMethodDecl=method:74:9 (Definition)
+// CHECK: Punctuation: "{" [75:1 - 75:2] CompoundStmt=
+// CHECK: Keyword: "int" [76:5 - 76:8] VarDecl=local:76:9 (Definition)
+// CHECK: Identifier: "local" [76:9 - 76:14] VarDecl=local:76:9 (Definition)
+// CHECK: Punctuation: "=" [76:15 - 76:16] VarDecl=local:76:9 (Definition)
+// CHECK: Punctuation: "[" [76:17 - 76:18] ObjCMessageExpr=foo::66:9
+// CHECK: Identifier: "self" [76:18 - 76:22] DeclRefExpr=self:0:0
+// CHECK: Identifier: "foo" [76:23 - 76:26] ObjCMessageExpr=foo::66:9
+// CHECK: Punctuation: ":" [76:26 - 76:27] ObjCMessageExpr=foo::66:9
+// CHECK: Identifier: "VAL" [76:27 - 76:30] macro expansion=VAL:63:9
+// CHECK: Punctuation: "]" [76:30 - 76:31] ObjCMessageExpr=foo::66:9
+// CHECK: Punctuation: ";" [76:31 - 76:32] DeclStmt=
+// CHECK: Keyword: "int" [77:5 - 77:8] VarDecl=second:77:9 (Definition)
+// CHECK: Identifier: "second" [77:9 - 77:15] VarDecl=second:77:9 (Definition)
+// CHECK: Punctuation: "=" [77:16 - 77:17] VarDecl=second:77:9 (Definition)
+// CHECK: Punctuation: "[" [77:18 - 77:19] ObjCMessageExpr=foo::66:9
+// CHECK: Identifier: "self" [77:19 - 77:23] DeclRefExpr=self:0:0
+// CHECK: Identifier: "foo" [77:24 - 77:27] ObjCMessageExpr=foo::66:9
+// CHECK: Punctuation: ":" [77:27 - 77:28] ObjCMessageExpr=foo::66:9
+// CHECK: Literal: "0" [77:28 - 77:29] IntegerLiteral=
+// CHECK: Punctuation: "]" [77:29 - 77:30] ObjCMessageExpr=foo::66:9
+// CHECK: Punctuation: ";" [77:30 - 77:31] DeclStmt=
+// CHECK: Keyword: "return" [78:5 - 78:11] ReturnStmt=
+// CHECK: Identifier: "local" [78:12 - 78:17] DeclRefExpr=local:76:9
+// CHECK: Punctuation: ";" [78:17 - 78:18] CompoundStmt=
+// CHECK: Punctuation: "}" [79:1 - 79:2] CompoundStmt=
+// CHECK: Punctuation: "-" [80:1 - 80:2] ObjCInstanceMethodDecl=othermethod::80:8 (Definition)
+// CHECK: Punctuation: "(" [80:3 - 80:4] ObjCInstanceMethodDecl=othermethod::80:8 (Definition)
+// CHECK: Keyword: "int" [80:4 - 80:7] ObjCInstanceMethodDecl=othermethod::80:8 (Definition)
+// CHECK: Punctuation: ")" [80:7 - 80:8] ObjCInstanceMethodDecl=othermethod::80:8 (Definition)
+// CHECK: Identifier: "othermethod" [80:8 - 80:19] ObjCInstanceMethodDecl=othermethod::80:8 (Definition)
+// CHECK: Punctuation: ":" [80:19 - 80:20] ObjCInstanceMethodDecl=othermethod::80:8 (Definition)
+// CHECK: Punctuation: "(" [80:20 - 80:21] ObjCInstanceMethodDecl=othermethod::80:8 (Definition)
+// CHECK: Identifier: "IBOutletTests" [80:21 - 80:34] ObjCClassRef=IBOutletTests:51:12
+// CHECK: Punctuation: "*" [80:35 - 80:36] ParmDecl=ibt:80:37 (Definition)
+// CHECK: Punctuation: ")" [80:36 - 80:37] ParmDecl=ibt:80:37 (Definition)
+// CHECK: Identifier: "ibt" [80:37 - 80:40] ParmDecl=ibt:80:37 (Definition)
+// CHECK: Punctuation: "{" [80:41 - 80:42] CompoundStmt=
+// CHECK: Keyword: "return" [81:3 - 81:9] ReturnStmt=
+// CHECK: Punctuation: "*" [81:10 - 81:11] UnaryOperator=
+// CHECK: Identifier: "ibt" [81:11 - 81:14] DeclRefExpr=ibt:80:37
+// CHECK: Punctuation: "." [81:14 - 81:15] MemberRefExpr=aPropOutlet:56:26
+// CHECK: Identifier: "aPropOutlet" [81:15 - 81:26] MemberRefExpr=aPropOutlet:56:26
+// CHECK: Punctuation: ";" [81:26 - 81:27] CompoundStmt=
+// CHECK: Punctuation: "}" [82:1 - 82:2] CompoundStmt=
+// CHECK: Punctuation: "@" [83:1 - 83:2] ObjCImplementationDecl=R7974151:70:17 (Definition)
+// CHECK: Keyword: "end" [83:2 - 83:5]
+// CHECK: Punctuation: "@" [85:1 - 85:2] ObjCProtocolDecl=Proto:85:11 (Definition)
+// CHECK: Keyword: "protocol" [85:2 - 85:10] ObjCProtocolDecl=Proto:85:11 (Definition)
+// CHECK: Identifier: "Proto" [85:11 - 85:16] ObjCProtocolDecl=Proto:85:11 (Definition)
+// CHECK: Punctuation: "@" [85:17 - 85:18] ObjCProtocolDecl=Proto:85:11 (Definition)
+// CHECK: Keyword: "end" [85:18 - 85:21] ObjCProtocolDecl=Proto:85:11 (Definition)
+// CHECK: Keyword: "void" [87:1 - 87:5] FunctionDecl=f:87:6 (Definition)
+// CHECK: Identifier: "f" [87:6 - 87:7] FunctionDecl=f:87:6 (Definition)
+// CHECK: Punctuation: "(" [87:7 - 87:8] FunctionDecl=f:87:6 (Definition)
+// CHECK: Punctuation: ")" [87:8 - 87:9] FunctionDecl=f:87:6 (Definition)
+// CHECK: Punctuation: "{" [87:10 - 87:11] CompoundStmt=
+// CHECK: Punctuation: "(" [88:3 - 88:4] CStyleCastExpr=
+// CHECK: Keyword: "void" [88:4 - 88:8] CStyleCastExpr=
+// CHECK: Punctuation: ")" [88:8 - 88:9] CStyleCastExpr=
+// CHECK: Punctuation: "@" [88:9 - 88:10] ObjCProtocolExpr=Proto:85:1
+// CHECK: Keyword: "protocol" [88:10 - 88:18] ObjCProtocolExpr=Proto:85:1
+// CHECK: Punctuation: "(" [88:18 - 88:19] ObjCProtocolExpr=Proto:85:1
+// CHECK: Identifier: "Proto" [88:19 - 88:24] ObjCProtocolExpr=Proto:85:1
+// CHECK: Punctuation: ")" [88:24 - 88:25] ObjCProtocolExpr=Proto:85:1
+// CHECK: Punctuation: ";" [88:25 - 88:26] CompoundStmt=
+// CHECK: Punctuation: "}" [89:1 - 89:2] CompoundStmt=
+// CHECK: Punctuation: "@" [93:1 - 93:2] ObjCInterfaceDecl=Rdar8595462_A:93:8
+// CHECK: Keyword: "class" [93:2 - 93:7] ObjCInterfaceDecl=Rdar8595462_A:93:8
+// CHECK: Identifier: "Rdar8595462_A" [93:8 - 93:21] ObjCClassRef=Rdar8595462_A:93:8
+// CHECK: Punctuation: ";" [93:21 - 93:22]
+// CHECK: Punctuation: "@" [94:1 - 94:2] ObjCInterfaceDecl=Rdar8595462_B:94:12
+// CHECK: Keyword: "interface" [94:2 - 94:11] ObjCInterfaceDecl=Rdar8595462_B:94:12
+// CHECK: Identifier: "Rdar8595462_B" [94:12 - 94:25] ObjCInterfaceDecl=Rdar8595462_B:94:12
+// CHECK: Punctuation: "@" [95:1 - 95:2] ObjCInterfaceDecl=Rdar8595462_B:94:12
+// CHECK: Keyword: "end" [95:2 - 95:5] ObjCInterfaceDecl=Rdar8595462_B:94:12
+// CHECK: Punctuation: "@" [97:1 - 97:2] ObjCImplementationDecl=Rdar8595462_B:97:17 (Definition)
+// CHECK: Keyword: "implementation" [97:2 - 97:16] ObjCImplementationDecl=Rdar8595462_B:97:17 (Definition)
+// CHECK: Identifier: "Rdar8595462_B" [97:17 - 97:30] ObjCImplementationDecl=Rdar8595462_B:97:17 (Definition)
+// CHECK: Identifier: "Rdar8595462_A" [98:1 - 98:14] ObjCClassRef=Rdar8595462_A:93:8
+// CHECK: Punctuation: "*" [98:15 - 98:16] FunctionDecl=Rdar8595462_aFunction:98:17 (Definition)
+// CHECK: Identifier: "Rdar8595462_aFunction" [98:17 - 98:38] FunctionDecl=Rdar8595462_aFunction:98:17 (Definition)
+// CHECK: Punctuation: "(" [98:38 - 98:39] FunctionDecl=Rdar8595462_aFunction:98:17 (Definition)
+// CHECK: Punctuation: ")" [98:39 - 98:40] FunctionDecl=Rdar8595462_aFunction:98:17 (Definition)
+// CHECK: Punctuation: "{" [98:41 - 98:42] CompoundStmt=
+// CHECK: Identifier: "Rdar8595462_A" [99:3 - 99:16] ObjCClassRef=Rdar8595462_A:93:8
+// CHECK: Punctuation: "*" [99:17 - 99:18] VarDecl=localVar:99:19 (Definition)
+// CHECK: Identifier: "localVar" [99:19 - 99:27] VarDecl=localVar:99:19 (Definition)
+// CHECK: Punctuation: "=" [99:28 - 99:29] VarDecl=localVar:99:19 (Definition)
+// CHECK: Literal: "0" [99:30 - 99:31] IntegerLiteral=
+// CHECK: Punctuation: ";" [99:31 - 99:32] DeclStmt=
+// CHECK: Keyword: "return" [100:3 - 100:9] ReturnStmt=
+// CHECK: Identifier: "localVar" [100:10 - 100:18] DeclRefExpr=localVar:99:19
+// CHECK: Punctuation: ";" [100:18 - 100:19] CompoundStmt=
+// CHECK: Punctuation: "}" [101:1 - 101:2] CompoundStmt=
+// CHECK: Keyword: "static" [102:1 - 102:7] ObjCImplementationDecl=Rdar8595462_B:97:17 (Definition)
+// CHECK: Identifier: "Rdar8595462_A" [102:8 - 102:21] ObjCClassRef=Rdar8595462_A:93:8
+// CHECK: Punctuation: "*" [102:22 - 102:23] VarDecl=Rdar8595462_staticVar:102:24
+// CHECK: Identifier: "Rdar8595462_staticVar" [102:24 - 102:45] VarDecl=Rdar8595462_staticVar:102:24
+// CHECK: Punctuation: ";" [102:45 - 102:46] ObjCImplementationDecl=Rdar8595462_B:97:17 (Definition)
+// CHECK: Punctuation: "@" [103:1 - 103:2] ObjCImplementationDecl=Rdar8595462_B:97:17 (Definition)
+// CHECK: Keyword: "end" [103:2 - 103:5]
+
+// CHECK: Punctuation: "@" [110:1 - 110:2] ObjCPropertyDecl=foo:110:33
+// CHECK: Keyword: "property" [110:2 - 110:10] ObjCPropertyDecl=foo:110:33
+// CHECK: Punctuation: "(" [110:11 - 110:12] ObjCPropertyDecl=foo:110:33
+// CHECK: Keyword: "readonly" [110:12 - 110:20] ObjCPropertyDecl=foo:110:33
+// CHECK: Punctuation: "," [110:20 - 110:21] ObjCPropertyDecl=foo:110:33
+// CHECK: Keyword: "copy" [110:22 - 110:26] ObjCPropertyDecl=foo:110:33
+// CHECK: Punctuation: ")" [110:26 - 110:27] ObjCPropertyDecl=foo:110:33
+// CHECK: Identifier: "Foo" [110:28 - 110:31] ObjCClassRef=Foo:1:12
+// CHECK: Punctuation: "*" [110:32 - 110:33] ObjCPropertyDecl=foo:110:33
+// CHECK: Identifier: "foo" [110:33 - 110:36] ObjCPropertyDecl=foo:110:33
+// CHECK: Keyword: "property" [111:2 - 111:10] ObjCPropertyDecl=foo2:111:27
+// CHECK: Punctuation: "(" [111:11 - 111:12] ObjCPropertyDecl=foo2:111:27
+// CHECK: Keyword: "readonly" [111:12 - 111:20] ObjCPropertyDecl=foo2:111:27
+// CHECK: Punctuation: ")" [111:20 - 111:21] ObjCPropertyDecl=foo2:111:27
+// CHECK: Identifier: "Foo" [111:22 - 111:25] ObjCClassRef=Foo:1:12
+// CHECK: Punctuation: "*" [111:26 - 111:27] ObjCPropertyDecl=foo2:111:27
+// CHECK: Identifier: "foo2" [111:27 - 111:31] ObjCPropertyDecl=foo2:111:27
+
+// CHECK: Punctuation: "@" [115:1 - 115:2] ObjCSynthesizeDecl=foo:110:33 (Definition)
+// CHECK: Keyword: "synthesize" [115:2 - 115:12] ObjCSynthesizeDecl=foo:110:33 (Definition)
+// CHECK: Identifier: "foo" [115:13 - 115:16] ObjCSynthesizeDecl=foo:110:33 (Definition)
+// CHECK: Punctuation: "=" [115:17 - 115:18] ObjCSynthesizeDecl=foo:110:33 (Definition)
+// CHECK: Identifier: "_foo" [115:19 - 115:23] MemberRef=_foo:107:8
+// CHECK: Punctuation: ";" [115:23 - 115:24] ObjCImplementationDecl=Rdar8595386:114:17 (Definition)
+
+// RUN: c-index-test -test-annotate-tokens=%s:127:1:130:1 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' | FileCheck -check-prefix=CHECK-INSIDE_BLOCK %s
+// CHECK-INSIDE_BLOCK: Keyword: "int" [127:5 - 127:8] VarDecl=result:127:9 (Definition)
+// CHECK-INSIDE_BLOCK: Identifier: "result" [127:9 - 127:15] VarDecl=result:127:9 (Definition)
+// CHECK-INSIDE_BLOCK: Punctuation: "=" [127:16 - 127:17] VarDecl=result:127:9 (Definition)
+// CHECK-INSIDE_BLOCK: Punctuation: "[" [127:18 - 127:19] ObjCMessageExpr=blah::124:8
+// CHECK-INSIDE_BLOCK: Identifier: "self" [127:19 - 127:23] DeclRefExpr=self:0:0
+// CHECK-INSIDE_BLOCK: Identifier: "blah" [127:24 - 127:28] ObjCMessageExpr=blah::124:8
+// CHECK-INSIDE_BLOCK: Punctuation: ":" [127:28 - 127:29] ObjCMessageExpr=blah::124:8
+// CHECK-INSIDE_BLOCK: Literal: "5" [127:29 - 127:30] IntegerLiteral=
+// CHECK-INSIDE_BLOCK: Punctuation: "," [127:30 - 127:31] ObjCMessageExpr=blah::124:8
+// CHECK-INSIDE_BLOCK: Identifier: "x" [127:32 - 127:33] DeclRefExpr=x:125:19
+// CHECK-INSIDE_BLOCK: Punctuation: "]" [127:33 - 127:34] ObjCMessageExpr=blah::124:8
+// CHECK-INSIDE_BLOCK: Punctuation: ";" [127:34 - 127:35] DeclStmt=
+// CHECK-INSIDE_BLOCK: Identifier: "Rdar8778404" [128:5 - 128:16] ObjCClassRef=Rdar8778404:120:12
+// CHECK-INSIDE_BLOCK: Punctuation: "*" [128:17 - 128:18] VarDecl=a:128:18 (Definition)
+// CHECK-INSIDE_BLOCK: Identifier: "a" [128:18 - 128:19] VarDecl=a:128:18 (Definition)
+// CHECK-INSIDE_BLOCK: Punctuation: "=" [128:20 - 128:21] VarDecl=a:128:18 (Definition)
+// CHECK-INSIDE_BLOCK: Identifier: "self" [128:22 - 128:26] DeclRefExpr=self:0:0
+
+// RUN: c-index-test -test-annotate-tokens=%s:134:1:138:1 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' | FileCheck -check-prefix=CHECK-PROP-AFTER-METHOD %s
+// CHECK-PROP-AFTER-METHOD: Punctuation: "@" [134:1 - 134:2] ObjCInterfaceDecl=Rdar8062781:134:12
+// CHECK-PROP-AFTER-METHOD: Keyword: "interface" [134:2 - 134:11] ObjCInterfaceDecl=Rdar8062781:134:12
+// CHECK-PROP-AFTER-METHOD: Identifier: "Rdar8062781" [134:12 - 134:23] ObjCInterfaceDecl=Rdar8062781:134:12
+// CHECK-PROP-AFTER-METHOD: Punctuation: "+" [135:1 - 135:2] ObjCClassMethodDecl=getB:135:9
+// CHECK-PROP-AFTER-METHOD: Punctuation: "(" [135:3 - 135:4] ObjCClassMethodDecl=getB:135:9
+// CHECK-PROP-AFTER-METHOD: Identifier: "Foo" [135:4 - 135:7] ObjCClassRef=Foo:1:12
+// CHECK-PROP-AFTER-METHOD: Punctuation: "*" [135:7 - 135:8] ObjCClassMethodDecl=getB:135:9
+// CHECK-PROP-AFTER-METHOD: Punctuation: ")" [135:8 - 135:9] ObjCClassMethodDecl=getB:135:9
+// CHECK-PROP-AFTER-METHOD: Identifier: "getB" [135:9 - 135:13] ObjCClassMethodDecl=getB:135:9
+// CHECK-PROP-AFTER-METHOD: Punctuation: ";" [135:13 - 135:14] ObjCClassMethodDecl=getB:135:9
+// CHECK-PROP-AFTER-METHOD: Punctuation: "@" [136:1 - 136:2] ObjCPropertyDecl=blah:136:38
+// CHECK-PROP-AFTER-METHOD: Keyword: "property" [136:2 - 136:10] ObjCPropertyDecl=blah:136:38
+// CHECK-PROP-AFTER-METHOD: Punctuation: "(" [136:11 - 136:12] ObjCPropertyDecl=blah:136:38
+// CHECK-PROP-AFTER-METHOD: Keyword: "readonly" [136:12 - 136:20] ObjCPropertyDecl=blah:136:38
+// CHECK-PROP-AFTER-METHOD: Punctuation: "," [136:20 - 136:21] ObjCPropertyDecl=blah:136:38
+// CHECK-PROP-AFTER-METHOD: Keyword: "nonatomic" [136:22 - 136:31] ObjCPropertyDecl=blah:136:38
+// CHECK-PROP-AFTER-METHOD: Punctuation: ")" [136:31 - 136:32] ObjCPropertyDecl=blah:136:38
+// CHECK-PROP-AFTER-METHOD: Identifier: "Foo" [136:33 - 136:36] ObjCClassRef=Foo:1:12
+// CHECK-PROP-AFTER-METHOD: Punctuation: "*" [136:37 - 136:38] ObjCPropertyDecl=blah:136:38
+// CHECK-PROP-AFTER-METHOD: Identifier: "blah" [136:38 - 136:42] ObjCPropertyDecl=blah:136:38
+// CHECK-PROP-AFTER-METHOD: Punctuation: ";" [136:42 - 136:43] ObjCInterfaceDecl=Rdar8062781:134:12
+// CHECK-PROP-AFTER-METHOD: Punctuation: "@" [137:1 - 137:2] ObjCPropertyDecl=abah:137:35
+// CHECK-PROP-AFTER-METHOD: Keyword: "property" [137:2 - 137:10] ObjCPropertyDecl=abah:137:35
+// CHECK-PROP-AFTER-METHOD: Punctuation: "(" [137:11 - 137:12] ObjCPropertyDecl=abah:137:35
+// CHECK-PROP-AFTER-METHOD: Keyword: "readonly" [137:12 - 137:20] ObjCPropertyDecl=abah:137:35
+// CHECK-PROP-AFTER-METHOD: Punctuation: "," [137:20 - 137:21] ObjCPropertyDecl=abah:137:35
+// CHECK-PROP-AFTER-METHOD: Keyword: "atomic" [137:22 - 137:28] ObjCPropertyDecl=abah:137:35
+// CHECK-PROP-AFTER-METHOD: Punctuation: ")" [137:28 - 137:29] ObjCPropertyDecl=abah:137:35
+// CHECK-PROP-AFTER-METHOD: Identifier: "Foo" [137:30 - 137:33] ObjCClassRef=Foo:1:12
+// CHECK-PROP-AFTER-METHOD: Punctuation: "*" [137:34 - 137:35] ObjCPropertyDecl=abah:137:35
+// CHECK-PROP-AFTER-METHOD: Identifier: "abah" [137:35 - 137:39] ObjCPropertyDecl=abah:137:35
+// CHECK-PROP-AFTER-METHOD: Punctuation: ";" [137:39 - 137:40] ObjCInterfaceDecl=Rdar8062781:134:12
+// CHECK-PROP-AFTER-METHOD: Punctuation: "@" [138:1 - 138:2] ObjCInterfaceDecl=Rdar8062781:134:12
+
+// RUN: c-index-test -test-annotate-tokens=%s:141:1:142:1 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' -target x86_64-apple-macosx10.7.0 | FileCheck -check-prefix=CHECK-WITH-WEAK %s
+// CHECK-WITH-WEAK: Identifier: "__weak" [141:3 - 141:9] macro expansion
+// CHECK-WITH-WEAK: Identifier: "Foo" [141:10 - 141:13] ObjCClassRef=Foo:1:12
+// CHECK-WITH-WEAK: Punctuation: "*" [141:14 - 141:15] ObjCIvarDecl=foo:141:15 (Definition)
+// CHECK-WITH-WEAK: Identifier: "foo" [141:15 - 141:18] ObjCIvarDecl=foo:141:15 (Definition)
+// CHECK-WITH-WEAK: Punctuation: ";" [141:18 - 141:19] ObjCInterfaceDecl=rdar9535717:140:12
+// CHECK-WITH-WEAK: Punctuation: "}" [142:1 - 142:2] ObjCInterfaceDecl=rdar9535717:140:12
diff --git a/clang/test/Index/annotate-toplevel-in-objccontainer.m b/clang/test/Index/annotate-toplevel-in-objccontainer.m
new file mode 100644
index 0000000..56b7871
--- /dev/null
+++ b/clang/test/Index/annotate-toplevel-in-objccontainer.m
@@ -0,0 +1,33 @@
+@interface Foo
+void func1(int);
+void func2(int);
+
+-(void)meth1;
+-(void)meth2;
+@end
+
+@implementation Foo
+void func(int);
+static int glob1;
+static int glob2;
+
+-(void)meth1 {}
+-(void)meth2 {}
+@end
+
+// RUN: c-index-test -write-pch %t.h.pch -x objective-c-header %s.h
+
+// RUN: c-index-test -test-annotate-tokens=%s:5:1:7:1 %s -include %t.h \
+// RUN: | FileCheck -check-prefix=INTER %s
+// CHECK-INTER: Identifier: "meth1" [5:8 - 5:13] ObjCInstanceMethodDecl=meth1:5:8
+// CHECK-INTER: Identifier: "meth2" [6:8 - 6:13] ObjCInstanceMethodDecl=meth2:6:8
+
+// RUN: c-index-test -test-annotate-tokens=%s:14:1:16:1 %s -include %t.h \
+// RUN: | FileCheck -check-prefix=IMPL %s
+// CHECK-IMPL: Identifier: "meth1" [14:8 - 14:13] ObjCInstanceMethodDecl=meth1:14:8 (Definition)
+// CHECK-IMPL: Identifier: "meth2" [15:8 - 15:13] ObjCInstanceMethodDecl=meth2:15:8 (Definition)
+
+// RUN: c-index-test -test-annotate-tokens=%s.h:7:1:9:1 %s -include %t.h \
+// RUN: | FileCheck -check-prefix=PCH %s
+// CHECK-PCH: Identifier: "meth1" [7:8 - 7:13] ObjCInstanceMethodDecl=meth1:7:8
+// CHECK-PCH: Identifier: "meth2" [8:8 - 8:13] ObjCInstanceMethodDecl=meth2:8:8
diff --git a/clang/test/Index/annotate-toplevel-in-objccontainer.m.h b/clang/test/Index/annotate-toplevel-in-objccontainer.m.h
new file mode 100644
index 0000000..fe507fc
--- /dev/null
+++ b/clang/test/Index/annotate-toplevel-in-objccontainer.m.h
@@ -0,0 +1,9 @@
+@interface FooPCH
+void funcPCH1(int);
+void funcPCH2(int);
+
+enum E { Cake };
+
+-(void)meth1;
+-(void)meth2;
+@end
diff --git a/clang/test/Index/arc-annotate.m b/clang/test/Index/arc-annotate.m
new file mode 100644
index 0000000..b836bc8
--- /dev/null
+++ b/clang/test/Index/arc-annotate.m
@@ -0,0 +1,38 @@
+@interface A
+@property (strong, nonatomic) id property;
+@property (nonatomic, weak) id second_property;
+@property (unsafe_unretained, nonatomic) id third_property;
+@end
+
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:5:1 %s -fobjc-arc -fobjc-nonfragile-abi | FileCheck %s
+// CHECK: Punctuation: "@" [1:1 - 1:2] ObjCInterfaceDecl=A:1:12
+// CHECK: Keyword: "interface" [1:2 - 1:11] ObjCInterfaceDecl=A:1:12
+// CHECK: Identifier: "A" [1:12 - 1:13] ObjCInterfaceDecl=A:1:12
+// CHECK: Punctuation: "@" [2:1 - 2:2] ObjCPropertyDecl=property:2:34
+// CHECK: Keyword: "property" [2:2 - 2:10] ObjCPropertyDecl=property:2:34
+// CHECK: Punctuation: "(" [2:11 - 2:12] ObjCPropertyDecl=property:2:34
+// CHECK: Keyword: "strong" [2:12 - 2:18] ObjCPropertyDecl=property:2:34
+// CHECK: Punctuation: "," [2:18 - 2:19] ObjCPropertyDecl=property:2:34
+// CHECK: Keyword: "nonatomic" [2:20 - 2:29] ObjCPropertyDecl=property:2:34
+// CHECK: Punctuation: ")" [2:29 - 2:30] ObjCPropertyDecl=property:2:34
+// CHECK: Identifier: "id" [2:31 - 2:33] TypeRef=id:0:0
+// CHECK: Identifier: "property" [2:34 - 2:42] ObjCPropertyDecl=property:2:34
+// CHECK: Punctuation: ";" [2:42 - 2:43] ObjCInterfaceDecl=A:1:12
+// CHECK: Punctuation: "@" [3:1 - 3:2] ObjCPropertyDecl=second_property:3:32
+// CHECK: Keyword: "property" [3:2 - 3:10] ObjCPropertyDecl=second_property:3:32
+// CHECK: Punctuation: "(" [3:11 - 3:12] ObjCPropertyDecl=second_property:3:32
+// CHECK: Keyword: "nonatomic" [3:12 - 3:21] ObjCPropertyDecl=second_property:3:32
+// CHECK: Punctuation: "," [3:21 - 3:22] ObjCPropertyDecl=second_property:3:32
+// CHECK: Keyword: "weak" [3:23 - 3:27] ObjCPropertyDecl=second_property:3:32
+// CHECK: Punctuation: ")" [3:27 - 3:28] ObjCPropertyDecl=second_property:3:32
+// CHECK: Identifier: "id" [3:29 - 3:31] TypeRef=id:0:0
+// CHECK: Identifier: "second_property" [3:32 - 3:47] ObjCPropertyDecl=second_property:3:32
+// CHECK: Punctuation: "@" [4:1 - 4:2] ObjCPropertyDecl=third_property:4:45
+// CHECK: Keyword: "property" [4:2 - 4:10] ObjCPropertyDecl=third_property:4:45
+// CHECK: Punctuation: "(" [4:11 - 4:12] ObjCPropertyDecl=third_property:4:45
+// CHECK: Keyword: "unsafe_unretained" [4:12 - 4:29] ObjCPropertyDecl=third_property:4:45
+// CHECK: Punctuation: "," [4:29 - 4:30] ObjCPropertyDecl=third_property:4:45
+// CHECK: Keyword: "nonatomic" [4:31 - 4:40] ObjCPropertyDecl=third_property:4:45
+// CHECK: Punctuation: ")" [4:40 - 4:41] ObjCPropertyDecl=third_property:4:45
+// CHECK: Identifier: "id" [4:42 - 4:44] TypeRef=id:0:0
+// CHECK: Identifier: "third_property" [4:45 - 4:59] ObjCPropertyDecl=third_property:4:45
diff --git a/clang/test/Index/arc-complete.m b/clang/test/Index/arc-complete.m
new file mode 100644
index 0000000..328983c
--- /dev/null
+++ b/clang/test/Index/arc-complete.m
@@ -0,0 +1,16 @@
+typedef const void *CFTypeRef;
+
+void test(id x) {
+ (__bridge CFTypeRef)x;
+}
+
+
+
+// RUN: c-index-test -code-completion-at=%s:4:4 %s -fobjc-arc -fobjc-nonfragile-abi | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: macro definition:{TypedText __autoreleasing} (70)
+// CHECK-CC1: NotImplemented:{TypedText __bridge}{HorizontalSpace }{Placeholder type}{RightParen )}{Placeholder expression} (40)
+// CHECK-CC1: NotImplemented:{TypedText __bridge_retained}{HorizontalSpace }{Placeholder CF type}{RightParen )}{Placeholder expression} (40)
+// CHECK-CC1: NotImplemented:{TypedText __bridge_transfer}{HorizontalSpace }{Placeholder Objective-C type}{RightParen )}{Placeholder expression} (40)
+// CHECK-CC1: macro definition:{TypedText __strong} (70)
+// CHECK-CC1: macro definition:{TypedText __unsafe_unretained} (70)
+// CHECK-CC1: macro definition:{TypedText __weak} (70)
diff --git a/clang/test/Index/asm-attribute.c b/clang/test/Index/asm-attribute.c
new file mode 100644
index 0000000..f952459
--- /dev/null
+++ b/clang/test/Index/asm-attribute.c
@@ -0,0 +1,6 @@
+int foo(int x) __asm__("_foo_");
+
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+// CHECK: asm-attribute.c:1:5: FunctionDecl=foo:1:5 Extent=[1:1 - 1:32]
+// FIXME: Location below.
+// CHECK: <invalid loc>:0:0: asm label=_foo_ Extent=[1:24 - 1:31]
diff --git a/clang/test/Index/blocks.c b/clang/test/Index/blocks.c
new file mode 100644
index 0000000..3f33e48
--- /dev/null
+++ b/clang/test/Index/blocks.c
@@ -0,0 +1,34 @@
+// RUN: c-index-test -test-load-source local -fblocks %s | FileCheck %s
+
+typedef int int_t;
+struct foo { long x; };
+
+void test() {
+ static struct foo _foo;
+ __block i = 0;
+ ^ int_t(struct foo *foo) { return (int_t) foo->x + i; }(&_foo);
+}
+
+// CHECK: blocks.c:6:6: FunctionDecl=test:6:6 (Definition) Extent=[6:1 - 10:2]
+// CHECK: blocks.c:6:13: CompoundStmt= Extent=[6:13 - 10:2]
+// CHECK: blocks.c:7:3: DeclStmt= Extent=[7:3 - 7:26]
+// CHECK: blocks.c:7:21: VarDecl=_foo:7:21 (Definition) Extent=[7:3 - 7:25]
+// CHECK: blocks.c:7:17: TypeRef=struct foo:4:8 Extent=[7:17 - 7:20]
+// CHECK: blocks.c:8:11: VarDecl=i:8:11 (Definition) Extent=[8:3 - 8:16]
+// CHECK: blocks.c:8:15: IntegerLiteral= Extent=[8:15 - 8:16]
+// CHECK: blocks.c:9:3: CallExpr= Extent=[9:3 - 9:65]
+// CHECK: blocks.c:9:3: BlockExpr= Extent=[9:3 - 9:58]
+// CHECK: blocks.c:9:5: TypeRef=int_t:3:13 Extent=[9:5 - 9:10]
+// CHECK: blocks.c:9:23: ParmDecl=foo:9:23 (Definition) Extent=[9:11 - 9:26]
+// CHECK: blocks.c:9:18: TypeRef=struct foo:4:8 Extent=[9:18 - 9:21]
+// CHECK: blocks.c:9:28: CompoundStmt= Extent=[9:28 - 9:58]
+// CHECK: blocks.c:9:30: ReturnStmt= Extent=[9:30 - 9:55]
+// CHECK: blocks.c:9:37: BinaryOperator= Extent=[9:37 - 9:55]
+// CHECK: blocks.c:9:37: CStyleCastExpr= Extent=[9:37 - 9:51]
+// CHECK: blocks.c:9:38: TypeRef=int_t:3:13 Extent=[9:38 - 9:43]
+// CHECK: blocks.c:9:50: MemberRefExpr=x:4:19 SingleRefName=[9:50 - 9:51] RefName=[9:50 - 9:51] Extent=[9:45 - 9:51]
+// CHECK: blocks.c:9:45: DeclRefExpr=foo:9:23 Extent=[9:45 - 9:48]
+// CHECK: blocks.c:9:54: DeclRefExpr=i:8:11 Extent=[9:54 - 9:55]
+// CHECK: blocks.c:9:59: UnaryOperator= Extent=[9:59 - 9:64]
+// CHECK: blocks.c:9:60: DeclRefExpr=_foo:7:21 Extent=[9:60 - 9:64]
+
diff --git a/clang/test/Index/c-index-api-loadTU-test.m b/clang/test/Index/c-index-api-loadTU-test.m
new file mode 100644
index 0000000..251d73b
--- /dev/null
+++ b/clang/test/Index/c-index-api-loadTU-test.m
@@ -0,0 +1,163 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -emit-pch -x objective-c %s -o %t.ast
+// RUN: c-index-test -test-load-tu %t.ast all | FileCheck %s
+
+@interface Foo
+{
+ __attribute__((iboutlet)) id myoutlet;
+}
+- (void) __attribute__((ibaction)) myMessage:(id)msg;
+- foo __attribute__((deprecated));
++ fooC;
+
+@end
+
+@interface Bar : Foo
+{
+}
+
+@end
+
+@interface Foo (FooCat)
+- (int) catMethodWithFloat:(float) fArg;
+- (float) floatMethod;
+@end
+
+@protocol Proto
+- pMethod;
+@end
+
+@protocol SubP <Proto>
+- spMethod;
+@end
+
+@interface Baz : Bar <SubP>
+{
+ int _anIVar;
+}
+
+- (Foo *) bazMethod;
+
+@end
+
+enum {
+ someEnum
+};
+
+int main (int argc, const char * argv[]) {
+ Baz * bee;
+ id a = [bee foo];
+ id <SubP> c = [Foo fooC];
+ id <Proto> d;
+ d = c;
+ [d pMethod];
+ [bee catMethodWithFloat:[bee floatMethod]];
+ main(someEnum, (const char **)bee);
+}
+
+// Test attribute traversal.
+#define IBOutlet __attribute__((iboutlet))
+#define IBOutletCollection(ClassName) __attribute__((iboutletcollection(ClassName)))
+#define IBAction void)__attribute__((ibaction)
+
+@interface TestAttributes {
+ IBOutlet id anOutlet;
+ IBOutletCollection(id) id anOutletCollection;
+}
+- (IBAction) actionMethod:(id)arg;
+@end
+
+typedef struct X0 X1;
+struct X0;
+struct X0 {};
+
+@interface TestAttributes()
+// <rdar://problem/9561076>
+@property (retain) IBOutlet id anotherOutlet;
+@end
+
+// CHECK: c-index-api-loadTU-test.m:4:12: ObjCInterfaceDecl=Foo:4:12 Extent=[4:1 - 12:5]
+// CHECK: c-index-api-loadTU-test.m:6:32: ObjCIvarDecl=myoutlet:6:32 (Definition) Extent=[6:3 - 6:40]
+// CHECK: <invalid loc>:0:0: attribute(iboutlet)=
+// CHECK: c-index-api-loadTU-test.m:6:29: TypeRef=id:0:0 Extent=[6:29 - 6:31]
+// CHECK: c-index-api-loadTU-test.m:8:36: ObjCInstanceMethodDecl=myMessage::8:36 Extent=[8:1 - 8:54]
+// CHECK: <invalid loc>:0:0: attribute(ibaction)=
+// CHECK: c-index-api-loadTU-test.m:8:50: ParmDecl=msg:8:50 (Definition) Extent=[8:47 - 8:53]
+// CHECK: c-index-api-loadTU-test.m:8:47: TypeRef=id:0:0 Extent=[8:47 - 8:49]
+// CHECK: c-index-api-loadTU-test.m:9:3: ObjCInstanceMethodDecl=foo:9:3 (deprecated) Extent=[9:1 - 9:35]
+// CHECK: c-index-api-loadTU-test.m:10:3: ObjCClassMethodDecl=fooC:10:3 Extent=[10:1 - 10:8]
+// CHECK: c-index-api-loadTU-test.m:14:12: ObjCInterfaceDecl=Bar:14:12 Extent=[14:1 - 18:5]
+// CHECK: c-index-api-loadTU-test.m:14:18: ObjCSuperClassRef=Foo:4:12 Extent=[14:18 - 14:21]
+// CHECK: c-index-api-loadTU-test.m:20:12: ObjCCategoryDecl=FooCat:20:12 Extent=[20:1 - 23:5]
+// CHECK: c-index-api-loadTU-test.m:20:12: ObjCClassRef=Foo:4:12 Extent=[20:12 - 20:15]
+// CHECK: c-index-api-loadTU-test.m:21:9: ObjCInstanceMethodDecl=catMethodWithFloat::21:9 Extent=[21:1 - 21:41]
+// CHECK: c-index-api-loadTU-test.m:21:36: ParmDecl=fArg:21:36 (Definition) Extent=[21:29 - 21:40]
+// CHECK: c-index-api-loadTU-test.m:22:11: ObjCInstanceMethodDecl=floatMethod:22:11 Extent=[22:1 - 22:23]
+// CHECK: c-index-api-loadTU-test.m:25:11: ObjCProtocolDecl=Proto:25:11 (Definition) Extent=[25:1 - 27:5]
+// CHECK: c-index-api-loadTU-test.m:26:3: ObjCInstanceMethodDecl=pMethod:26:3 Extent=[26:1 - 26:11]
+// CHECK: c-index-api-loadTU-test.m:29:11: ObjCProtocolDecl=SubP:29:11 (Definition) Extent=[29:1 - 31:5]
+// CHECK: c-index-api-loadTU-test.m:29:17: ObjCProtocolRef=Proto:25:11 Extent=[29:17 - 29:22]
+// CHECK: c-index-api-loadTU-test.m:30:3: ObjCInstanceMethodDecl=spMethod:30:3 Extent=[30:1 - 30:12]
+// CHECK: c-index-api-loadTU-test.m:33:12: ObjCInterfaceDecl=Baz:33:12 Extent=[33:1 - 40:5]
+// CHECK: c-index-api-loadTU-test.m:33:18: ObjCSuperClassRef=Bar:14:12 Extent=[33:18 - 33:21]
+// CHECK: c-index-api-loadTU-test.m:33:23: ObjCProtocolRef=SubP:29:11 Extent=[33:23 - 33:27]
+// CHECK: c-index-api-loadTU-test.m:35:9: ObjCIvarDecl=_anIVar:35:9 (Definition) Extent=[35:5 - 35:16]
+// CHECK: c-index-api-loadTU-test.m:38:11: ObjCInstanceMethodDecl=bazMethod:38:11 Extent=[38:1 - 38:21]
+// CHECK: c-index-api-loadTU-test.m:38:4: ObjCClassRef=Foo:4:12 Extent=[38:4 - 38:7]
+// CHECK: c-index-api-loadTU-test.m:42:1: EnumDecl=:42:1 (Definition) Extent=[42:1 - 44:2]
+// CHECK: c-index-api-loadTU-test.m:43:3: EnumConstantDecl=someEnum:43:3 (Definition) Extent=[43:3 - 43:11]
+// CHECK: c-index-api-loadTU-test.m:46:5: FunctionDecl=main:46:5 (Definition) Extent=[46:1 - 55:2]
+// CHECK: c-index-api-loadTU-test.m:46:15: ParmDecl=argc:46:15 (Definition) Extent=[46:11 - 46:19]
+// CHECK: c-index-api-loadTU-test.m:46:34: ParmDecl=argv:46:34 (Definition) Extent=[46:21 - 46:40]
+// CHECK: c-index-api-loadTU-test.m:47:8: VarDecl=bee:47:8 (Definition) Extent=[47:2 - 47:11]
+// CHECK: c-index-api-loadTU-test.m:47:2: ObjCClassRef=Baz:33:12 Extent=[47:2 - 47:5]
+// CHECK: c-index-api-loadTU-test.m:48:5: VarDecl=a:48:5 (Definition) Extent=[48:2 - 48:18]
+// CHECK: c-index-api-loadTU-test.m:48:2: TypeRef=id:0:0 Extent=[48:2 - 48:4]
+// CHECK: c-index-api-loadTU-test.m:48:9: ObjCMessageExpr=foo:9:3 Extent=[48:9 - 48:18]
+// CHECK: c-index-api-loadTU-test.m:48:10: DeclRefExpr=bee:47:8 Extent=[48:10 - 48:13]
+// CHECK: c-index-api-loadTU-test.m:49:12: VarDecl=c:49:12 (Definition) Extent=[49:2 - 49:26]
+// CHECK: c-index-api-loadTU-test.m:49:2: TypeRef=id:0:0 Extent=[49:2 - 49:4]
+// CHECK: c-index-api-loadTU-test.m:49:6: ObjCProtocolRef=SubP:29:11 Extent=[49:6 - 49:10]
+// CHECK: c-index-api-loadTU-test.m:49:16: UnexposedExpr=fooC:10:3 Extent=[49:16 - 49:26]
+// CHECK: c-index-api-loadTU-test.m:49:16: ObjCMessageExpr=fooC:10:3 Extent=[49:16 - 49:26]
+// CHECK: c-index-api-loadTU-test.m:49:17: ObjCClassRef=Foo:4:12 Extent=[49:17 - 49:20]
+// CHECK: c-index-api-loadTU-test.m:50:13: VarDecl=d:50:13 (Definition) Extent=[50:2 - 50:14]
+// CHECK: c-index-api-loadTU-test.m:50:2: TypeRef=id:0:0 Extent=[50:2 - 50:4]
+// CHECK: c-index-api-loadTU-test.m:50:6: ObjCProtocolRef=Proto:25:11 Extent=[50:6 - 50:11]
+// CHECK: c-index-api-loadTU-test.m:51:2: BinaryOperator= Extent=[51:2 - 51:7]
+// CHECK: c-index-api-loadTU-test.m:51:2: DeclRefExpr=d:50:13 Extent=[51:2 - 51:3]
+// CHECK: c-index-api-loadTU-test.m:51:6: UnexposedExpr=c:49:12 Extent=[51:6 - 51:7]
+// CHECK: c-index-api-loadTU-test.m:51:6: DeclRefExpr=c:49:12 Extent=[51:6 - 51:7]
+// CHECK: c-index-api-loadTU-test.m:52:2: ObjCMessageExpr=pMethod:26:3 Extent=[52:2 - 52:13]
+// CHECK: c-index-api-loadTU-test.m:52:3: DeclRefExpr=d:50:13 Extent=[52:3 - 52:4]
+// CHECK: c-index-api-loadTU-test.m:53:2: ObjCMessageExpr=catMethodWithFloat::21:9 Extent=[53:2 - 53:44]
+// CHECK: c-index-api-loadTU-test.m:53:3: DeclRefExpr=bee:47:8 Extent=[53:3 - 53:6]
+// CHECK: c-index-api-loadTU-test.m:53:26: ObjCMessageExpr=floatMethod:22:11 Extent=[53:26 - 53:43]
+// CHECK: c-index-api-loadTU-test.m:53:27: DeclRefExpr=bee:47:8 Extent=[53:27 - 53:30]
+// CHECK: c-index-api-loadTU-test.m:54:3: CallExpr=main:46:5 Extent=[54:3 - 54:37]
+// CHECK: c-index-api-loadTU-test.m:54:3: UnexposedExpr=main:46:5 Extent=[54:3 - 54:7]
+// CHECK: c-index-api-loadTU-test.m:54:3: DeclRefExpr=main:46:5 Extent=[54:3 - 54:7]
+// CHECK: c-index-api-loadTU-test.m:54:8: DeclRefExpr=someEnum:43:3 Extent=[54:8 - 54:16]
+// CHECK: c-index-api-loadTU-test.m:54:18: CStyleCastExpr= Extent=[54:18 - 54:36]
+// CHECK: c-index-api-loadTU-test.m:54:33: DeclRefExpr=bee:47:8 Extent=[54:33 - 54:36]
+// CHECK: c-index-api-loadTU-test.m:62:12: ObjCInterfaceDecl=TestAttributes:62:12 Extent=[62:1 - 67:5]
+// CHECK: c-index-api-loadTU-test.m:63:15: ObjCIvarDecl=anOutlet:63:15 (Definition) Extent=[58:18 - 63:23]
+// CHECK: <invalid loc>:0:0: attribute(iboutlet)=
+// CHECK: c-index-api-loadTU-test.m:64:29: ObjCIvarDecl=anOutletCollection:64:29 (Definition) Extent=[59:39 - 64:47]
+// CHECK: <invalid loc>:0:0: attribute(iboutletcollection)= [IBOutletCollection=ObjCObjectPointer]
+// CHECK: c-index-api-loadTU-test.m:64:26: TypeRef=id:0:0 Extent=[64:26 - 64:28]
+// CHECK: c-index-api-loadTU-test.m:66:14: ObjCInstanceMethodDecl=actionMethod::66:14 Extent=[66:1 - 66:35]
+// CHECK: <invalid loc>:0:0: attribute(ibaction)=
+// CHECK: c-index-api-loadTU-test.m:66:31: ParmDecl=arg:66:31 (Definition) Extent=[66:28 - 66:34]
+// CHECK: c-index-api-loadTU-test.m:66:28: TypeRef=id:0:0 Extent=[66:28 - 66:30]
+// CHECK: c-index-api-loadTU-test.m:69:16: StructDecl=X0:69:16 Extent=[69:9 - 69:18]
+// CHECK: c-index-api-loadTU-test.m:69:19: TypedefDecl=X1:69:19 (Definition) Extent=[69:1 - 69:21]
+// CHECK: c-index-api-loadTU-test.m:69:16: TypeRef=struct X0:71:8 Extent=[69:16 - 69:18]
+// CHECK: c-index-api-loadTU-test.m:70:8: StructDecl=X0:70:8 Extent=[70:1 - 70:10]
+// CHECK: c-index-api-loadTU-test.m:71:8: StructDecl=X0:71:8 (Definition) Extent=[71:1 - 71:14]
+
+// CHECK: <invalid loc>:0:0: attribute(iboutlet)=
+// CHECK: c-index-api-loadTU-test.m:75:29: TypeRef=id:0:0 Extent=[75:29 - 75:31]
+// CHECK: c-index-api-loadTU-test.m:75:32: ObjCInstanceMethodDecl=anotherOutlet:75:32 Extent=[75:32 - 75:45]
+// CHECK: c-index-api-loadTU-test.m:75:32: ObjCInstanceMethodDecl=setAnotherOutlet::75:32 Extent=[75:32 - 75:45]
+// CHECK: c-index-api-loadTU-test.m:75:32: ParmDecl=anotherOutlet:75:32 (Definition) Extent=[75:32 - 75:45]
+
diff --git a/clang/test/Index/c-index-getCursor-pp.c b/clang/test/Index/c-index-getCursor-pp.c
new file mode 100644
index 0000000..0a10450
--- /dev/null
+++ b/clang/test/Index/c-index-getCursor-pp.c
@@ -0,0 +1,39 @@
+#define OBSCURE(X) X
+#define DECORATION
+
+typedef int T;
+void OBSCURE(func)(int x) {
+ OBSCURE(T) DECORATION value;
+}
+
+#include "a.h"
+
+#define A(X) X
+#define B(X) A(X)
+
+B(int x);
+
+const char *fname = __FILE__;
+
+// RUN: c-index-test -cursor-at=%s:1:11 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-1 %s
+// CHECK-1: macro definition=OBSCURE
+// RUN: c-index-test -cursor-at=%s:2:14 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-2 %s
+// CHECK-2: macro definition=DECORATION
+// RUN: c-index-test -cursor-at=%s:5:7 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-3 %s
+// CHECK-3: macro expansion=OBSCURE:1:9
+// RUN: c-index-test -cursor-at=%s:6:6 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-4 %s
+// CHECK-4: macro expansion=OBSCURE:1:9
+// RUN: c-index-test -cursor-at=%s:6:19 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-5 %s
+// CHECK-5: macro expansion=DECORATION:2:9
+// RUN: c-index-test -cursor-at=%s:9:10 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-6 %s
+// CHECK-6: inclusion directive=a.h
+// RUN: c-index-test -cursor-at=%s:14:1 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-7 %s
+// CHECK-7: macro expansion=B:12:9
+// RUN: c-index-test -cursor-at=%s:16:25 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-8 %s
+// CHECK-8: macro expansion=__FILE__
+
+// Same tests, but with "editing" optimizations
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:1:11 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-1 %s
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:2:14 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-2 %s
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:5:7 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-3 %s
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:9:10 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-6 %s
diff --git a/clang/test/Index/c-index-getCursor-test.m b/clang/test/Index/c-index-getCursor-test.m
new file mode 100644
index 0000000..bae5979
--- /dev/null
+++ b/clang/test/Index/c-index-getCursor-test.m
@@ -0,0 +1,168 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -emit-pch -x objective-c %s -detailed-preprocessing-record -o %t.ast
+// RUN: c-index-test -test-file-scan %t.ast %s | FileCheck %s
+@interface Foo
+{
+}
+
+- foo;
++ fooC;
+
+@end
+
+@interface Bar : Foo
+{
+}
+
+@end
+
+@interface Foo (FooCat)
+- (int) catMethodWithFloat:(float) fArg;
+- (float) floatMethod;
+@end
+
+@protocol Proto
+- pMethod;
+@end
+
+@protocol SubP <Proto>
+- spMethod;
+@end
+
+@interface Baz : Bar <SubP>
+{
+ int _anIVar;
+}
+
+- (Foo *) bazMethod;
+
+@end
+
+enum {
+ someEnum
+};
+
+int main (int argc, const char * argv[]) {
+ Baz * bee;
+ id a = [bee foo];
+ id <SubP> c = [Foo fooC];
+ id <Proto> d;
+ d = c;
+ [d pMethod];
+ [bee catMethodWithFloat:[bee floatMethod]];
+ main(someEnum, (const char **)bee);
+}
+
+#define CONCAT(X, Y) X##Y
+
+void f() {
+ int CONCAT(my,_var);
+}
+#undef CONCAT
+
+// CHECK: [1:1 - 3:1] Invalid Cursor => NoDeclFound
+// CHECK: [3:1 - 7:1] ObjCInterfaceDecl=Foo:3:12
+// CHECK: [7:1 - 7:7] ObjCInstanceMethodDecl=foo:7:3
+// CHECK: [7:7 - 8:1] ObjCInterfaceDecl=Foo:3:12
+// CHECK: [8:1 - 8:8] ObjCClassMethodDecl=fooC:8:3
+// CHECK: [8:8 - 10:5] ObjCInterfaceDecl=Foo:3:12
+// CHECK: [10:5 - 12:1] Invalid Cursor => NoDeclFound
+// CHECK: [12:1 - 12:18] ObjCInterfaceDecl=Bar:12:12
+// CHECK: [12:18 - 12:21] ObjCSuperClassRef=Foo:3:12
+// CHECK: [12:21 - 16:5] ObjCInterfaceDecl=Bar:12:12
+// CHECK: [16:5 - 18:1] Invalid Cursor => NoDeclFound
+// CHECK: [18:1 - 18:12] ObjCCategoryDecl=FooCat:18:12
+// CHECK: [18:12 - 18:15] ObjCClassRef=Foo:3:12
+// CHECK: [18:15 - 19:1] ObjCCategoryDecl=FooCat:18:12
+// CHECK: [19:1 - 19:29] ObjCInstanceMethodDecl=catMethodWithFloat::19:9
+// CHECK: [19:29 - 19:40] ParmDecl=fArg:19:36 (Definition)
+// CHECK: [19:40 - 19:41] ObjCInstanceMethodDecl=catMethodWithFloat::19:9
+// CHECK: [19:41 - 20:1] ObjCCategoryDecl=FooCat:18:12
+// CHECK: [20:1 - 20:23] ObjCInstanceMethodDecl=floatMethod:20:11
+// CHECK: [20:23 - 21:5] ObjCCategoryDecl=FooCat:18:12
+// CHECK: [21:5 - 23:1] Invalid Cursor => NoDeclFound
+// CHECK: [23:1 - 24:1] ObjCProtocolDecl=Proto:23:11 (Definition)
+// CHECK: [24:1 - 24:11] ObjCInstanceMethodDecl=pMethod:24:3
+// CHECK: [24:11 - 25:5] ObjCProtocolDecl=Proto:23:11 (Definition)
+// CHECK: [25:5 - 27:1] Invalid Cursor => NoDeclFound
+// CHECK: [27:1 - 27:17] ObjCProtocolDecl=SubP:27:11 (Definition)
+// CHECK: [27:17 - 27:22] ObjCProtocolRef=Proto:23:1
+// CHECK: [27:22 - 28:1] ObjCProtocolDecl=SubP:27:11 (Definition)
+// CHECK: [28:1 - 28:12] ObjCInstanceMethodDecl=spMethod:28:3
+// CHECK: [28:12 - 29:5] ObjCProtocolDecl=SubP:27:11 (Definition)
+// CHECK: [29:5 - 31:1] Invalid Cursor => NoDeclFound
+// CHECK: [31:1 - 31:18] ObjCInterfaceDecl=Baz:31:12
+// CHECK: [31:18 - 31:21] ObjCSuperClassRef=Bar:12:12
+// CHECK: [31:21 - 31:23] ObjCInterfaceDecl=Baz:31:12
+// CHECK: [31:23 - 31:27] ObjCProtocolRef=SubP:27:1
+// CHECK: [31:27 - 33:5] ObjCInterfaceDecl=Baz:31:12
+// CHECK: [33:5 - 33:16] ObjCIvarDecl=_anIVar:33:9 (Definition)
+// CHECK: [33:16 - 36:1] ObjCInterfaceDecl=Baz:31:12
+// CHECK: [36:1 - 36:4] ObjCInstanceMethodDecl=bazMethod:36:1
+// CHECK: [36:4 - 36:7] ObjCClassRef=Foo:3:12
+// CHECK: [36:7 - 36:21] ObjCInstanceMethodDecl=bazMethod:36:1
+// CHECK: [36:21 - 38:5] ObjCInterfaceDecl=Baz:31:12
+// CHECK: [38:5 - 40:1] Invalid Cursor => NoDeclFound
+// CHECK: [40:1 - 41:3] EnumDecl=:40:1 (Definition)
+// CHECK: [41:3 - 41:11] EnumConstantDecl=someEnum:41:3 (Definition)
+// CHECK: [41:11 - 42:2] EnumDecl=:40:1 (Definition)
+// CHECK: [42:2 - 44:1] Invalid Cursor => NoDeclFound
+// CHECK: [44:1 - 44:11] FunctionDecl=main:44:5 (Definition)
+// CHECK: [44:11 - 44:19] ParmDecl=argc:44:15 (Definition)
+// CHECK: [44:19 - 44:21] FunctionDecl=main:44:5 (Definition)
+// CHECK: [44:21 - 44:40] ParmDecl=argv:44:34 (Definition)
+// CHECK: [44:40 - 44:42] FunctionDecl=main:44:5 (Definition)
+// CHECK: [44:42 - 45:2] CompoundStmt=
+// CHECK: [45:2 - 45:5] ObjCClassRef=Baz:31:12
+// CHECK: [45:5 - 45:11] VarDecl=bee:45:8 (Definition)
+// CHECK: [45:11 - 45:12] DeclStmt=
+// CHECK: [45:12 - 46:2] CompoundStmt=
+// CHECK: [46:2 - 46:4] TypeRef=id:0:0
+// CHECK: [46:4 - 46:9] VarDecl=a:46:5 (Definition)
+// CHECK: [46:9 - 46:10] ObjCMessageExpr=foo:7:3
+// CHECK: [46:10 - 46:13] DeclRefExpr=bee:45:8
+// CHECK: [46:13 - 46:18] ObjCMessageExpr=foo:7:3
+// CHECK: [46:18 - 46:19] DeclStmt=
+// CHECK: [46:19 - 47:2] CompoundStmt=
+// CHECK: [47:2 - 47:4] TypeRef=id:0:0
+// CHECK: [47:4 - 47:6] VarDecl=c:47:12 (Definition)
+// CHECK: [47:6 - 47:10] ObjCProtocolRef=SubP:27:1
+// CHECK: [47:10 - 47:16] VarDecl=c:47:12 (Definition)
+// CHECK: [47:16 - 47:17] ObjCMessageExpr=fooC:8:3
+// CHECK: [47:17 - 47:20] ObjCClassRef=Foo:3:12
+// CHECK: [47:20 - 47:26] ObjCMessageExpr=fooC:8:3
+// CHECK: [47:26 - 47:27] DeclStmt=
+// CHECK: [47:27 - 48:2] CompoundStmt=
+// CHECK: [48:2 - 48:4] TypeRef=id:0:0
+// CHECK: [48:4 - 48:6] VarDecl=d:48:13 (Definition)
+// CHECK: [48:6 - 48:11] ObjCProtocolRef=Proto:23:1
+// CHECK: [48:11 - 48:14] VarDecl=d:48:13 (Definition)
+// CHECK: [48:14 - 48:15] DeclStmt=
+// CHECK: [48:15 - 49:2] CompoundStmt=
+// CHECK: [49:2 - 49:3] DeclRefExpr=d:48:13
+// CHECK: [49:3 - 49:6] BinaryOperator=
+// CHECK: [49:6 - 49:7] DeclRefExpr=c:47:12
+// CHECK: [49:7 - 50:2] CompoundStmt=
+// CHECK: [50:2 - 50:3] ObjCMessageExpr=pMethod:24:3
+// CHECK: [50:3 - 50:4] DeclRefExpr=d:48:13
+// CHECK: [50:4 - 50:13] ObjCMessageExpr=pMethod:24:3
+// CHECK: [50:13 - 51:2] CompoundStmt=
+// CHECK: [51:2 - 51:3] ObjCMessageExpr=catMethodWithFloat::19:9
+// CHECK: [51:3 - 51:6] DeclRefExpr=bee:45:8
+// CHECK: [51:6 - 51:26] ObjCMessageExpr=catMethodWithFloat::19:9
+// CHECK: [51:26 - 51:27] ObjCMessageExpr=floatMethod:20:1
+// CHECK: [51:27 - 51:30] DeclRefExpr=bee:45:8
+// CHECK: [51:30 - 51:43] ObjCMessageExpr=floatMethod:20:1
+// CHECK: [51:43 - 51:44] ObjCMessageExpr=catMethodWithFloat::19:9
+// CHECK: [51:44 - 52:3] CompoundStmt=
+// CHECK: [52:3 - 52:7] DeclRefExpr=main:44:5
+// CHECK: [52:7 - 52:8] CallExpr=main:44:5
+// CHECK: [52:8 - 52:16] DeclRefExpr=someEnum:41:3
+// CHECK: [52:16 - 52:18] CallExpr=main:44:5
+// CHECK: [52:18 - 52:33] CStyleCastExpr=
+// CHECK: [52:33 - 52:36] DeclRefExpr=bee:45:8
+// CHECK: [52:36 - 52:37] CallExpr=main:44:5
+// CHECK: [52:37 - 53:2] CompoundStmt=
+// CHECK: [55:9 - 55:26] macro definition=CONCAT
+// CHECK: [57:1 - 57:10] FunctionDecl=f:57:6 (Definition)
+// CHECK: [58:4 - 58:8] VarDecl=my_var:58:8 (Definition)
+// CHECK: [58:8 - 58:15] macro expansion=CONCAT:55:9
diff --git a/clang/test/Index/c-index-pch.c b/clang/test/Index/c-index-pch.c
new file mode 100644
index 0000000..313fae8
--- /dev/null
+++ b/clang/test/Index/c-index-pch.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -x c -o %t.pch %S/Inputs/c-index-pch.h
+// RUN: %clang_cc1 -include-pch %t.pch -x c -emit-pch -o %t.ast %s
+// RUN: c-index-test -test-load-tu %t.ast all | FileCheck -check-prefix=ALL %s
+// ALL: FunctionDecl=foo
+// ALL: VarDecl=bar
+// ALL: FunctionDecl=wibble
+// ALL: FunctionDecl=wonka
+void wibble(int i);
+void wonka(float);
diff --git a/clang/test/Index/c-index-redecls.c b/clang/test/Index/c-index-redecls.c
new file mode 100644
index 0000000..0cf2f03
--- /dev/null
+++ b/clang/test/Index/c-index-redecls.c
@@ -0,0 +1,107 @@
+// RUN: %clang_cc1 -emit-pch -o %t.ast %s
+// RUN: c-index-test -test-load-tu %t.ast all
+
+// rdar://8956193 - We would blow the thread stack because of nested calls due
+// to redeclarations.
+
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
+void socrates(void);
diff --git a/clang/test/Index/cindex-from-source.m b/clang/test/Index/cindex-from-source.m
new file mode 100644
index 0000000..f226e45
--- /dev/null
+++ b/clang/test/Index/cindex-from-source.m
@@ -0,0 +1,12 @@
+
+// RUN: %clang -x objective-c-header %S/Inputs/cindex-from-source.h -o %t.pfx.h.gch
+// RUN: c-index-test -test-load-source local %s -include %t.pfx.h > %t
+// RUN: FileCheck %s < %t
+// CHECK: cindex-from-source.m:{{.*}}:{{.*}}: StructDecl=s0:{{.*}}:{{.*}}
+// CHECK: cindex-from-source.m:{{.*}}:{{.*}}: VarDecl=g0:{{.*}}:{{.*}}
+// CHECK: cindex-from-source.m:9:1: TypeRef=t0:1:13 Extent=[9:1 - 9:3]
+struct s0 {};
+t0 g0;
+
+// RUN: c-index-test -test-load-source-reparse 5 local %s -include %t.pfx.h > %t
+// RUN: FileCheck %s < %t
diff --git a/clang/test/Index/cindex-on-invalid-usrs.m b/clang/test/Index/cindex-on-invalid-usrs.m
new file mode 100644
index 0000000..6414761
--- /dev/null
+++ b/clang/test/Index/cindex-on-invalid-usrs.m
@@ -0,0 +1,7 @@
+// RUN: c-index-test -test-load-source-usrs local %s 2>&1 | FileCheck %s
+
+// <rdar://problem/8452791> - Crash when generating USRs.
+@interface Rdar8452791 () - (void)rdar8452791;
+
+// CHECK: error: cannot find interface declaration for 'Rdar8452791'
+// CHECK: missing '@end'
diff --git a/clang/test/Index/cindex-on-invalid.m b/clang/test/Index/cindex-on-invalid.m
new file mode 100644
index 0000000..6eff24b
--- /dev/null
+++ b/clang/test/Index/cindex-on-invalid.m
@@ -0,0 +1,21 @@
+// RUN: c-index-test -test-load-source local %s 2>&1 | FileCheck %s
+
+// <rdar://problem/9123493>
+void test() {
+ goto exit;
+}
+
+int foo;
+
+#define NO 0
+
+void f(int y) {
+ if (y = NO);
+}
+
+int
+
+// CHECK: cindex-on-invalid.m:5:8: error: use of undeclared label 'exit'
+// CHECK: cindex-on-invalid.m:13:9:{13:7-13:13}
+// CHECK: cindex-on-invalid.m:21:1: error: expected identifier or '('
+
diff --git a/clang/test/Index/cindex-test-inclusions.c b/clang/test/Index/cindex-test-inclusions.c
new file mode 100644
index 0000000..9c7de2e
--- /dev/null
+++ b/clang/test/Index/cindex-test-inclusions.c
@@ -0,0 +1,13 @@
+// RUN: c-index-test -test-inclusion-stack-source %s 2>&1 | FileCheck %s
+
+#include "include_test.h"
+
+// CHECK: cindex-test-inclusions.c
+// CHECK: included by:
+// CHECK: include_test.h
+// CHECK: included by:
+// CHECK: cindex-test-inclusions.c:3:10
+// CHECK: include_test_2.h
+// CHECK: included by:
+// CHECK: include_test.h:1:10
+// CHECK: cindex-test-inclusions.c:3:10
diff --git a/clang/test/Index/code-completion.cpp b/clang/test/Index/code-completion.cpp
new file mode 100644
index 0000000..5789d3b
--- /dev/null
+++ b/clang/test/Index/code-completion.cpp
@@ -0,0 +1,90 @@
+// Code-completion through the C interface
+#include "nonexistent_header.h"
+struct X {
+ int member;
+
+ enum E { Val1 };
+};
+
+struct Y {
+ float member;
+ void memfunc(int i = 17);
+};
+
+struct Z : X, Y {
+ double member;
+ operator int() const;
+};
+struct W { };
+struct Z get_Z();
+namespace N { }
+void test_Z() {
+ // RUN: c-index-test -code-completion-at=%s:23:11 %s | FileCheck -check-prefix=CHECK-MEMBER %s
+ get_Z().member = 17;
+}
+
+
+float& overloaded(int i, long second);
+double& overloaded(float f, int second);
+int& overloaded(Z z, int second);
+
+void test_overloaded() {
+ // RUN: c-index-test -code-completion-at=%s:33:18 %s | FileCheck -check-prefix=CHECK-OVERLOAD %s
+ overloaded(Z(), 0);
+}
+
+Z::operator int() const {
+ return 0;
+}
+
+// CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member}
+// CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member}
+// CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member}
+// CHECK-MEMBER: CXXMethod:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )}
+// CHECK-MEMBER: CXXConversion:{TypedText operator int}{LeftParen (}{RightParen )}{Informative const}
+// CHECK-MEMBER: CXXMethod:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder const Z &}{RightParen )}
+// CHECK-MEMBER: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )}
+// CHECK-MEMBER: CXXMethod:{ResultType Y &}{Text Y::}{TypedText operator=}{LeftParen (}{Placeholder const Y &}{RightParen )}
+// CHECK-MEMBER: EnumConstantDecl:{ResultType X::E}{Informative E::}{TypedText Val1}
+// CHECK-MEMBER: StructDecl:{TypedText X}{Text ::}
+// CHECK-MEMBER: StructDecl:{TypedText Y}{Text ::}
+// CHECK-MEMBER: StructDecl:{TypedText Z}{Text ::}
+// CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )}
+// CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative Y::}{TypedText ~Y}{LeftParen (}{RightParen )}
+// CHECK-MEMBER: CXXDestructor:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )}
+// CHECK-MEMBER: Completion contexts:
+// CHECK-MEMBER-NEXT: Dot member access
+// CHECK-MEMBER-NEXT: Container Kind: StructDecl
+// CHECK-MEMBER-NEXT: Container is complete
+// CHECK-MEMBER-NEXT: Container USR: c:@S@Z
+
+// CHECK-OVERLOAD: NotImplemented:{ResultType int &}{Text overloaded}{LeftParen (}{Text Z z}{Comma , }{CurrentParameter int second}{RightParen )}
+// CHECK-OVERLOAD: NotImplemented:{ResultType float &}{Text overloaded}{LeftParen (}{Text int i}{Comma , }{CurrentParameter long second}{RightParen )}
+// CHECK-OVERLOAD: NotImplemented:{ResultType double &}{Text overloaded}{LeftParen (}{Text float f}{Comma , }{CurrentParameter int second}{RightParen )}
+// CHECK-OVERLOAD: Completion contexts:
+// CHECK-OVERLOAD-NEXT: Any type
+// CHECK-OVERLOAD-NEXT: Any value
+// CHECK-OVERLOAD-NEXT: Enum tag
+// CHECK-OVERLOAD-NEXT: Union tag
+// CHECK-OVERLOAD-NEXT: Struct tag
+// CHECK-OVERLOAD-NEXT: Class name
+// CHECK-OVERLOAD-NEXT: Nested name specifier
+// CHECK-OVERLOAD-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:37:10 %s | FileCheck -check-prefix=CHECK-EXPR %s
+// CHECK-EXPR: NotImplemented:{TypedText int} (50)
+// CHECK-EXPR: NotImplemented:{TypedText long} (50)
+// CHECK-EXPR: FieldDecl:{ResultType double}{TypedText member} (17)
+// CHECK-EXPR: FieldDecl:{ResultType int}{Text X::}{TypedText member} (9)
+// CHECK-EXPR: FieldDecl:{ResultType float}{Text Y::}{TypedText member} (18)
+// CHECK-EXPR: CXXMethod:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} (37)
+// CHECK-EXPR: Namespace:{TypedText N}{Text ::} (75)
+// CHECK-EXPR: Completion contexts:
+// CHECK-EXPR-NEXT: Any type
+// CHECK-EXPR-NEXT: Any value
+// CHECK-EXPR-NEXT: Enum tag
+// CHECK-EXPR-NEXT: Union tag
+// CHECK-EXPR-NEXT: Struct tag
+// CHECK-EXPR-NEXT: Class name
+// CHECK-EXPR-NEXT: Nested name specifier
+// CHECK-EXPR-NEXT: Objective-C interface
diff --git a/clang/test/Index/complete-access-checks.cpp b/clang/test/Index/complete-access-checks.cpp
new file mode 100644
index 0000000..c77a5d6
--- /dev/null
+++ b/clang/test/Index/complete-access-checks.cpp
@@ -0,0 +1,89 @@
+struct X {
+ int member1;
+ void func1();
+protected:
+ int member2;
+ void func2();
+private:
+ int member3;
+ void func3();
+};
+
+struct Y: protected X {
+ void doSomething();
+};
+
+class Z {
+public:
+ int member1;
+ void func1();
+protected:
+ int member2;
+ void func2();
+private:
+ int member3;
+ void func3();
+};
+
+void Y::doSomething() {
+ // RUN: c-index-test -code-completion-at=%s:30:9 %s | FileCheck -check-prefix=CHECK-SUPER-ACCESS %s
+ this->;
+
+ Z that;
+ // RUN: c-index-test -code-completion-at=%s:34:8 %s | FileCheck -check-prefix=CHECK-ACCESS %s
+ that.
+}
+
+// CHECK-SUPER-ACCESS: CXXMethod:{ResultType void}{TypedText doSomething}{LeftParen (}{RightParen )} (34)
+// CHECK-SUPER-ACCESS: CXXMethod:{ResultType void}{Informative X::}{TypedText func1}{LeftParen (}{RightParen )} (36)
+// CHECK-SUPER-ACCESS: CXXMethod:{ResultType void}{Informative X::}{TypedText func2}{LeftParen (}{RightParen )} (36) (inaccessible)
+// CHECK-SUPER-ACCESS: CXXMethod:{ResultType void}{Informative X::}{TypedText func3}{LeftParen (}{RightParen )} (36) (inaccessible)
+// CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member1} (37)
+// CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member2} (37) (inaccessible)
+// CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member3} (37) (inaccessible)
+// CHECK-SUPER-ACCESS: CXXMethod:{ResultType Y &}{TypedText operator=}{LeftParen (}{Placeholder const Y &}{RightParen )} (34)
+// CHECK-SUPER-ACCESS: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (36)
+// CHECK-SUPER-ACCESS: StructDecl:{TypedText X}{Text ::} (77)
+// CHECK-SUPER-ACCESS: StructDecl:{TypedText Y}{Text ::} (75)
+// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )} (36)
+// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{TypedText ~Y}{LeftParen (}{RightParen )} (34)
+
+// CHECK-ACCESS: CXXMethod:{ResultType void}{TypedText func1}{LeftParen (}{RightParen )} (34)
+// CHECK-ACCESS: CXXMethod:{ResultType void}{TypedText func2}{LeftParen (}{RightParen )} (34) (inaccessible)
+// CHECK-ACCESS: CXXMethod:{ResultType void}{TypedText func3}{LeftParen (}{RightParen )} (34) (inaccessible)
+// CHECK-ACCESS: FieldDecl:{ResultType int}{TypedText member1} (35)
+// CHECK-ACCESS: FieldDecl:{ResultType int}{TypedText member2} (35) (inaccessible)
+// CHECK-ACCESS: FieldDecl:{ResultType int}{TypedText member3} (35) (inaccessible)
+// CHECK-ACCESS: CXXMethod:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder const Z &}{RightParen )} (34)
+// CHECK-ACCESS: ClassDecl:{TypedText Z}{Text ::} (75)
+// CHECK-ACCESS: CXXDestructor:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )} (34)
+
+class P {
+protected:
+ int member;
+};
+
+class Q : public P {
+public:
+ using P::member;
+};
+
+void f(P x, Q y) {
+ // RUN: c-index-test -code-completion-at=%s:73:5 %s | FileCheck -check-prefix=CHECK-USING-INACCESSIBLE %s
+ x.; // member is inaccessible
+ // RUN: c-index-test -code-completion-at=%s:75:5 %s | FileCheck -check-prefix=CHECK-USING-ACCESSIBLE %s
+ y.; // member is accessible
+}
+
+// CHECK-USING-INACCESSIBLE: FieldDecl:{ResultType int}{TypedText member} (35) (inaccessible)
+// CHECK-USING-INACCESSIBLE: CXXMethod:{ResultType P &}{TypedText operator=}{LeftParen (}{Placeholder const P &}{RightParen )} (34)
+// CHECK-USING-INACCESSIBLE: ClassDecl:{TypedText P}{Text ::} (75)
+// CHECK-USING-INACCESSIBLE: CXXDestructor:{ResultType void}{TypedText ~P}{LeftParen (}{RightParen )} (34)
+
+// CHECK-USING-ACCESSIBLE: FieldDecl:{ResultType int}{TypedText member} (35)
+// CHECK-USING-ACCESSIBLE: CXXMethod:{ResultType Q &}{TypedText operator=}{LeftParen (}{Placeholder const Q &}{RightParen )} (34)
+// CHECK-USING-ACCESSIBLE: CXXMethod:{ResultType P &}{Text P::}{TypedText operator=}{LeftParen (}{Placeholder const P &}{RightParen )} (36)
+// CHECK-USING-ACCESSIBLE: ClassDecl:{TypedText P}{Text ::} (77)
+// CHECK-USING-ACCESSIBLE: ClassDecl:{TypedText Q}{Text ::} (75)
+// CHECK-USING-ACCESSIBLE: CXXDestructor:{ResultType void}{Informative P::}{TypedText ~P}{LeftParen (}{RightParen )} (36)
+// CHECK-USING-ACCESSIBLE: CXXDestructor:{ResultType void}{TypedText ~Q}{LeftParen (}{RightParen )} (34)
diff --git a/clang/test/Index/complete-at-directives.m b/clang/test/Index/complete-at-directives.m
new file mode 100644
index 0000000..1e97d45
--- /dev/null
+++ b/clang/test/Index/complete-at-directives.m
@@ -0,0 +1,54 @@
+/* Run lines are at the end, since line/column matter in this test. */
+@interface MyClass { @public }
+@end
+
+@implementation MyClass
+@end
+
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:2:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: {TypedText class}{HorizontalSpace }{Placeholder name}
+// CHECK-CC1: {TypedText compatibility_alias}{HorizontalSpace }{Placeholder alias}{HorizontalSpace }{Placeholder class}
+// CHECK-CC1: {TypedText implementation}{HorizontalSpace }{Placeholder class}
+// CHECK-CC1: {TypedText interface}{HorizontalSpace }{Placeholder class}
+// CHECK-CC1: {TypedText protocol}{HorizontalSpace }{Placeholder protocol}
+
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:3:2 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: {TypedText end}
+// CHECK-CC2: {TypedText optional}
+// CHECK-CC2: {TypedText property}
+// CHECK-CC2: {TypedText required}
+
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:6:2 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: {TypedText dynamic}{HorizontalSpace }{Placeholder property}
+// CHECK-CC3: {TypedText end}
+// CHECK-CC3: {TypedText synthesize}{HorizontalSpace }{Placeholder property}
+
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:2:1 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: NotImplemented:{TypedText @class}{HorizontalSpace }{Placeholder name}
+// CHECK-CC4: NotImplemented:{TypedText @compatibility_alias}{HorizontalSpace }{Placeholder alias}{HorizontalSpace }{Placeholder class}
+// CHECK-CC4: NotImplemented:{TypedText @implementation}{HorizontalSpace }{Placeholder class}
+// CHECK-CC4: NotImplemented:{TypedText @interface}{HorizontalSpace }{Placeholder class}
+// CHECK-CC4: NotImplemented:{TypedText @protocol}{HorizontalSpace }{Placeholder protocol}
+// CHECK-CC4: NotImplemented:{TypedText _Bool}
+// CHECK-CC4: TypedefDecl:{TypedText Class}
+// CHECK-CC4: TypedefDecl:{TypedText id}
+// CHECK-CC4: TypedefDecl:{TypedText SEL}
+
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:3:1 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: {TypedText @end}
+// CHECK-CC5: {TypedText @optional}
+// CHECK-CC5: {TypedText @property}
+// CHECK-CC5: {TypedText @required}
+
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:2:23 %s | FileCheck -check-prefix=CHECK-CC6 %s
+// CHECK-CC6: NotImplemented:{TypedText package}
+// CHECK-CC6: NotImplemented:{TypedText private}
+// CHECK-CC6: NotImplemented:{TypedText protected}
+// CHECK-CC6: NotImplemented:{TypedText public}
+
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:2:22 %s | FileCheck -check-prefix=CHECK-CC7 %s
+// CHECK-CC7: NotImplemented:{TypedText @package}
+// CHECK-CC7: NotImplemented:{TypedText @private}
+// CHECK-CC7: NotImplemented:{TypedText @protected}
+// CHECK-CC7: NotImplemented:{TypedText @public}
+// CHECK-CC7: NotImplemented:{TypedText _Bool}
diff --git a/clang/test/Index/complete-at-exprstmt.m b/clang/test/Index/complete-at-exprstmt.m
new file mode 100644
index 0000000..a6d7675
--- /dev/null
+++ b/clang/test/Index/complete-at-exprstmt.m
@@ -0,0 +1,55 @@
+/* The run lines are below, because this test is line- and
+ column-number sensitive. */
+@interface MyClass { int ivar; }
+- (int)myMethod:(int)arg;
+@end
+
+@implementation MyClass
+- (int)myMethod:(int)arg {
+ @synchronized (@encode(MyClass)) { }
+}
+@end
+
+@interface A
++ (int)add:(int)x to:(int)y;
++ (int)add:(int)x to:(int)y plus:(int)z;
+@end
+
+void f() {
+ @selector(add:to:);
+}
+
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:9:4 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: {TypedText encode}{LeftParen (}{Placeholder type-name}{RightParen )}
+// CHECK-CC1: {TypedText protocol}{LeftParen (}{Placeholder protocol-name}{RightParen )}
+// CHECK-CC1: {TypedText selector}{LeftParen (}{Placeholder selector}{RightParen )}
+// CHECK-CC1: {TypedText synchronized}{HorizontalSpace }{LeftParen (}{Placeholder expression}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }}
+// CHECK-CC1: {TypedText throw}{HorizontalSpace }{Placeholder expression}
+// CHECK-CC1: {TypedText try}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @catch}{LeftParen (}{Placeholder parameter}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @finally}{LeftBrace {}{Placeholder statements}{RightBrace }}
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:9:19 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: {TypedText encode}{LeftParen (}{Placeholder type-name}{RightParen )}
+// CHECK-CC2: {TypedText protocol}{LeftParen (}{Placeholder protocol-name}{RightParen )}
+// CHECK-CC2: {TypedText selector}{LeftParen (}{Placeholder selector}{RightParen )}
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:9:3 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: NotImplemented:{ResultType char[]}{TypedText @encode}{LeftParen (}{Placeholder type-name}{RightParen )}
+// CHECK-CC3: NotImplemented:{ResultType Protocol *}{TypedText @protocol}{LeftParen (}{Placeholder protocol-name}{RightParen )}
+// CHECK-CC3: NotImplemented:{ResultType SEL}{TypedText @selector}{LeftParen (}{Placeholder selector}{RightParen )}
+// CHECK-CC3: NotImplemented:{TypedText @synchronized}{HorizontalSpace }{LeftParen (}{Placeholder expression}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }}
+// CHECK-CC3: NotImplemented:{TypedText @throw}{HorizontalSpace }{Placeholder expression}
+// CHECK-CC3: NotImplemented:{TypedText @try}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @catch}{LeftParen (}{Placeholder parameter}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @finally}{LeftBrace {}{Placeholder statements}{RightBrace }}
+// CHECK-CC3: NotImplemented:{ResultType SEL}{TypedText _cmd}
+// CHECK-CC3: ParmDecl:{ResultType int}{TypedText arg}
+// CHECK-CC3: TypedefDecl:{TypedText Class}
+// CHECK-CC3: TypedefDecl:{TypedText id}
+// CHECK-CC3: ObjCIvarDecl:{ResultType int}{TypedText ivar}
+// CHECK-CC3: ObjCInterfaceDecl:{TypedText MyClass}
+// CHECK-CC3: TypedefDecl:{TypedText SEL}
+// CHECK-CC3: NotImplemented:{ResultType MyClass *}{TypedText self}
+// RUN: c-index-test -code-completion-at=%s:19:13 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: NotImplemented:{TypedText add:to:} (40)
+// CHECK-CC4: NotImplemented:{TypedText add:to:plus:} (40)
+// CHECK-CC4: NotImplemented:{TypedText myMethod:} (40)
+// RUN: c-index-test -code-completion-at=%s:19:17 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: NotImplemented:{Informative add:}{TypedText to:} (40)
+// CHECK-CC5: NotImplemented:{Informative add:}{TypedText to:plus:} (40)
+
diff --git a/clang/test/Index/complete-blocks.m b/clang/test/Index/complete-blocks.m
new file mode 100644
index 0000000..cb507e2
--- /dev/null
+++ b/clang/test/Index/complete-blocks.m
@@ -0,0 +1,64 @@
+// The line and column layout of this test is significant. Run lines
+// are at the end.
+typedef void (^block_t)(float f, double d);
+void f(int (^block)(int x, int y));
+void g(block_t b);
+
+void test_f() {
+
+}
+
+@interface A
+- method:(int (^)(int x, int y))b;
+- method2:(block_t)b;
+@end
+
+void test_A(A *a) {
+ [a method:0];
+}
+
+@interface B
+- method3:(int (^)(void))b;
+@end
+
+void test_B(B *b) {
+ [b method3:^int(void){ return 0; }];
+}
+
+@interface C
+- method4:(void(^)(void))arg;
+- method5:(void(^)())arg5;
+@end
+
+void test_C(C *c) {
+ [c method4:^{}];
+}
+
+@interface D
+- method6:(void(^)(block_t block))arg;
+@end
+
+void test_D(D *d) {
+ [d method6:0];
+}
+
+// RUN: c-index-test -code-completion-at=%s:8:1 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder ^int(int x, int y)block}{RightParen )} (50)
+// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText g}{LeftParen (}{Placeholder ^(float f, double d)b}{RightParen )} (50)
+// RUN: c-index-test -code-completion-at=%s:17:6 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText method2:}{Placeholder ^(float f, double d)b} (35)
+// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText method:}{Placeholder ^int(int x, int y)b} (35)
+// RUN: c-index-test -code-completion-at=%s:25:6 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: ObjCInstanceMethodDecl:{ResultType id}{TypedText method3:}{Placeholder ^int(void)b} (35)
+// RUN: c-index-test -code-completion-at=%s:34:6 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType id}{TypedText method4:}{Placeholder ^(void)arg} (35)
+// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType id}{TypedText method5:}{Placeholder ^(void)arg5} (35)
+// RUN: c-index-test -code-completion-at=%s:25:15 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: TypedefDecl:{TypedText block_t} (50)
+// CHECK-CC5: TypedefDecl:{TypedText Class} (50)
+// CHECK-CC5-NOT: test_A
+// CHECK-CC5: {TypedText union} (50)
+
+// RUN: c-index-test -code-completion-at=%s:42:6 %s | FileCheck -check-prefix=CHECK-CC6 %s
+// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType id}{TypedText method6:}{Placeholder ^(block_t block)arg} (35)
+
diff --git a/clang/test/Index/complete-categories.m b/clang/test/Index/complete-categories.m
new file mode 100644
index 0000000..92b14db
--- /dev/null
+++ b/clang/test/Index/complete-categories.m
@@ -0,0 +1,39 @@
+/* Note: the RUN lines are near the end of the file, since line/column
+ matter for this test. */
+
+@interface I1 @end
+@interface I2 @end
+@interface I3 : I2 @end
+
+@interface I1(Cat1) @end
+@interface I1(Cat2) @end
+@interface I1(Cat3) @end
+
+@interface I2 (Cat2) @end
+@interface I2 (Cat3) @end
+@interface I2 (Cat2) @end
+@interface I3 (Cat1) @end
+@interface I3 (Cat2) @end
+
+@implementation I1(Cat2) @end
+@implementation I1(Cat3) @end
+@implementation I3(Cat2) @end
+
+// RUN: c-index-test -code-completion-at=%s:12:16 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: ObjCCategoryDecl:{TypedText Cat1}
+// CHECK-CC1: ObjCCategoryDecl:{TypedText Cat2}
+// CHECK-CC1: ObjCCategoryDecl:{TypedText Cat3}
+// RUN: c-index-test -code-completion-at=%s:13:16 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: ObjCCategoryDecl:{TypedText Cat1}
+// CHECK-CC2-NEXT: ObjCCategoryDecl:{TypedText Cat3}
+// RUN: c-index-test -code-completion-at=%s:18:20 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: ObjCCategoryDecl:{TypedText Cat1}
+// CHECK-CC3: ObjCCategoryDecl:{TypedText Cat2}
+// CHECK-CC3: ObjCCategoryDecl:{TypedText Cat3}
+// RUN: c-index-test -code-completion-at=%s:19:20 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: ObjCCategoryDecl:{TypedText Cat1}
+// CHECK-CC4-NEXT: ObjCCategoryDecl:{TypedText Cat3}
+// RUN: c-index-test -code-completion-at=%s:20:20 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: ObjCCategoryDecl:{TypedText Cat1}
+// CHECK-CC5-NEXT: ObjCCategoryDecl:{TypedText Cat2}
+// CHECK-CC5-NEXT: ObjCCategoryDecl:{TypedText Cat3}
diff --git a/clang/test/Index/complete-ctor-inits.cpp b/clang/test/Index/complete-ctor-inits.cpp
new file mode 100644
index 0000000..f506214
--- /dev/null
+++ b/clang/test/Index/complete-ctor-inits.cpp
@@ -0,0 +1,40 @@
+// The run lines are below, because this test is line- and
+// column-number sensitive.
+
+template<typename T>
+struct X {
+ X(T);
+};
+
+struct Virt { };
+struct Y : virtual Virt { };
+
+struct Z : public X<int>, public Y {
+ Z();
+
+ int a, b, c;
+};
+
+Z::Z() : ::X<int>(0), Virt(), b(), c() { }
+
+// RUN: c-index-test -code-completion-at=%s:18:10 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: MemberRef:{TypedText a}{LeftParen (}{Placeholder args}{RightParen )} (35)
+// CHECK-CC1: MemberRef:{TypedText b}{LeftParen (}{Placeholder args}{RightParen )} (35)
+// CHECK-CC1: MemberRef:{TypedText c}{LeftParen (}{Placeholder args}{RightParen )} (35)
+// CHECK-CC1: NotImplemented:{TypedText Virt}{LeftParen (}{Placeholder args}{RightParen )} (35)
+// CHECK-CC1: NotImplemented:{TypedText X<int>}{LeftParen (}{Placeholder args}{RightParen )} (7)
+// CHECK-CC1: NotImplemented:{TypedText Y}{LeftParen (}{Placeholder args}{RightParen )} (35)
+
+// RUN: c-index-test -code-completion-at=%s:18:23 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: MemberRef:{TypedText a}{LeftParen (}{Placeholder args}{RightParen )} (35)
+// CHECK-CC2: MemberRef:{TypedText b}{LeftParen (}{Placeholder args}{RightParen )} (35)
+// CHECK-CC2: MemberRef:{TypedText c}{LeftParen (}{Placeholder args}{RightParen )} (35)
+// CHECK-CC2: NotImplemented:{TypedText Virt}{LeftParen (}{Placeholder args}{RightParen )} (35)
+// CHECK-CC2: NotImplemented:{TypedText Y}{LeftParen (}{Placeholder args}{RightParen )} (7)
+
+// RUN: c-index-test -code-completion-at=%s:18:36 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: MemberRef:{TypedText a}{LeftParen (}{Placeholder args}{RightParen )} (35)
+// CHECK-CC3-NOT: MemberRef:{TypedText b}{LeftParen (}{Placeholder args}{RightParen )}
+// CHECK-CC3: MemberRef:{TypedText c}{LeftParen (}{Placeholder args}{RightParen )} (7)
+// CHECK-CC3-NOT: NotImplemented:{TypedText Virt}{LeftParen (}{Placeholder args}{RightParen )}
+// CHECK-CC3: NotImplemented:{TypedText Y}{LeftParen (}{Placeholder args}{RightParen )} (35)
diff --git a/clang/test/Index/complete-cxx-inline-methods.cpp b/clang/test/Index/complete-cxx-inline-methods.cpp
new file mode 100644
index 0000000..d441972
--- /dev/null
+++ b/clang/test/Index/complete-cxx-inline-methods.cpp
@@ -0,0 +1,44 @@
+namespace {
+class MyCls {
+ void in_foo() {
+ vec.x = 0;
+ }
+ void out_foo();
+
+ struct Vec { int x, y; };
+ Vec vec;
+};
+
+void MyCls::out_foo() {
+ vec.x = 0;
+}
+
+class OtherClass : public MyCls {
+public:
+ OtherClass(const OtherClass &other) : MyCls(other), value(value) { }
+
+private:
+ int value;
+ MyCls *object;
+};
+}
+
+// RUN: c-index-test -code-completion-at=%s:4:9 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:13:7 %s | FileCheck %s
+// CHECK: CXXMethod:{ResultType MyCls::Vec &}{TypedText operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (34)
+// CHECK-NEXT: StructDecl:{TypedText Vec}{Text ::} (75)
+// CHECK-NEXT: FieldDecl:{ResultType int}{TypedText x} (35)
+// CHECK-NEXT: FieldDecl:{ResultType int}{TypedText y} (35)
+// CHECK-NEXT: CXXDestructor:{ResultType void}{TypedText ~Vec}{LeftParen (}{RightParen )} (34)
+// CHECK-NEXT: Completion contexts:
+// CHECK-NEXT: Dot member access
+// CHECK-NEXT: Container Kind: StructDecl
+
+// RUN: c-index-test -code-completion-at=%s:18:41 %s | FileCheck -check-prefix=CHECK-CTOR-INIT %s
+// CHECK-CTOR-INIT: NotImplemented:{TypedText MyCls}{LeftParen (}{Placeholder args}{RightParen )} (7)
+// CHECK-CTOR-INIT: MemberRef:{TypedText object}{LeftParen (}{Placeholder args}{RightParen )} (35)
+// CHECK-CTOR-INIT: MemberRef:{TypedText value}{LeftParen (}{Placeholder args}{RightParen )} (35)
+// RUN: c-index-test -code-completion-at=%s:18:55 %s | FileCheck -check-prefix=CHECK-CTOR-INIT-2 %s
+// CHECK-CTOR-INIT-2-NOT: NotImplemented:{TypedText MyCls}{LeftParen (}{Placeholder args}{RightParen )}
+// CHECK-CTOR-INIT-2: MemberRef:{TypedText object}{LeftParen (}{Placeholder args}{RightParen )} (35)
+// CHECK-CTOR-INIT-2: MemberRef:{TypedText value}{LeftParen (}{Placeholder args}{RightParen )} (7)
diff --git a/clang/test/Index/complete-declarators.cpp b/clang/test/Index/complete-declarators.cpp
new file mode 100644
index 0000000..ccbfde1
--- /dev/null
+++ b/clang/test/Index/complete-declarators.cpp
@@ -0,0 +1,43 @@
+// This test is line- and column-sensitive, so test commands are at the bottom.
+namespace N {
+ struct X {
+ int f(X);
+ };
+}
+
+int g(int a);
+
+struct Y { };
+
+struct Z {
+ int member;
+ friend int N::X::f(N::X);
+};
+
+// RUN: c-index-test -code-completion-at=%s:8:5 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:8:5 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: NotImplemented:{TypedText const} (40)
+// CHECK-CC1: Namespace:{TypedText N}{Text ::} (75)
+// CHECK-CC1: NotImplemented:{TypedText operator} (40)
+// CHECK-CC1: NotImplemented:{TypedText volatile} (40)
+// RUN: c-index-test -code-completion-at=%s:8:11 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:8:11 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: NotImplemented:{TypedText const} (40)
+// CHECK-CC2-NOT: Namespace:{TypedText N}{Text ::} (75)
+// CHECK-CC2-NOT: NotImplemented:{TypedText operator} (40)
+// CHECK-CC2: NotImplemented:{TypedText volatile} (40)
+// RUN: c-index-test -code-completion-at=%s:13:7 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:13:7 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: NotImplemented:{TypedText const} (40)
+// CHECK-CC3-NOT: Namespace:{TypedText N}{Text ::} (75)
+// CHECK-CC3: NotImplemented:{TypedText operator} (40)
+// CHECK-CC3: NotImplemented:{TypedText volatile} (40)
+// RUN: c-index-test -code-completion-at=%s:14:14 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:14 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: NotImplemented:{TypedText const} (40)
+// CHECK-CC4: Namespace:{TypedText N}{Text ::} (75)
+// CHECK-CC4: NotImplemented:{TypedText operator} (40)
+// CHECK-CC4: NotImplemented:{TypedText volatile} (40)
+// CHECK-CC4: StructDecl:{TypedText Y}{Text ::} (75)
+// CHECK-CC4: StructDecl:{TypedText Z}{Text ::} (75)
+
diff --git a/clang/test/Index/complete-declarators.m b/clang/test/Index/complete-declarators.m
new file mode 100644
index 0000000..071df60
--- /dev/null
+++ b/clang/test/Index/complete-declarators.m
@@ -0,0 +1,72 @@
+// This test is line- and column-sensitive, so test commands are at the bottom.
+@protocol P
+- (int)method:(id)param1;
+@end
+
+@interface A <P>
+- (int)method:(id)param1;
+
+@property int prop1;
+@end
+
+@implementation A
+- (int)method:(id)param1 {
+ int q2;
+ for(id q in param1) {
+ int y;
+ }
+ id q;
+ for(q in param1) {
+ int y;
+ }
+
+ static P *p = 0;
+}
+@end
+
+// RUN: c-index-test -code-completion-at=%s:7:19 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1-NOT: NotImplemented:{TypedText extern} (40)
+// CHECK-CC1: NotImplemented:{TypedText param1} (40)
+// RUN: c-index-test -code-completion-at=%s:9:15 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: c-index-test -code-completion-at=%s:15:10 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: c-index-test -code-completion-at=%s:16:9 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: NotImplemented:{TypedText const} (40)
+// CHECK-CC2-NOT: int
+// CHECK-CC2: NotImplemented:{TypedText restrict} (40)
+// CHECK-CC2: NotImplemented:{TypedText volatile} (40)
+// RUN: c-index-test -code-completion-at=%s:15:15 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: ParmDecl:{ResultType id}{TypedText param1} (34)
+// CHECK-CC3-NOT: VarDecl:{ResultType int}{TypedText q2}
+// CHECK-CC3-NOT: VarDecl:{ResultType id}{TypedText q}
+// CHECK-CC3: NotImplemented:{ResultType A *}{TypedText self} (34)
+// CHECK-CC3: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// RUN: c-index-test -code-completion-at=%s:15:15 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: ParmDecl:{ResultType id}{TypedText param1} (34)
+// CHECK-CC4-NOT: VarDecl:{ResultType int}{TypedText q2}
+// CHECK-CC4: NotImplemented:{ResultType A *}{TypedText self} (34)
+// CHECK-CC4: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// RUN: c-index-test -code-completion-at=%s:23:10 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: NotImplemented:{TypedText _Bool} (50)
+// CHECK-CC5: NotImplemented:{TypedText _Complex} (50)
+// CHECK-CC5: NotImplemented:{TypedText _Imaginary} (50)
+// CHECK-CC5: ObjCInterfaceDecl:{TypedText A} (50)
+// CHECK-CC5: NotImplemented:{TypedText char} (50)
+// CHECK-CC5: TypedefDecl:{TypedText Class} (50)
+// CHECK-CC5: NotImplemented:{TypedText const} (50)
+// CHECK-CC5: NotImplemented:{TypedText double} (50)
+// CHECK-CC5: NotImplemented:{TypedText enum} (50)
+// CHECK-CC5: NotImplemented:{TypedText float} (50)
+// CHECK-CC5: TypedefDecl:{TypedText id} (50)
+// CHECK-CC5: NotImplemented:{TypedText int} (50)
+// CHECK-CC5: NotImplemented:{TypedText long} (50)
+// CHECK-CC5: NotImplemented:{TypedText restrict} (50)
+// CHECK-CC5: TypedefDecl:{TypedText SEL} (50)
+// CHECK-CC5: NotImplemented:{TypedText short} (50)
+// CHECK-CC5: NotImplemented:{TypedText signed} (50)
+// CHECK-CC5: NotImplemented:{TypedText struct} (50)
+// CHECK-CC5: NotImplemented:{TypedText typeof}{HorizontalSpace }{Placeholder expression} (40)
+// CHECK-CC5: NotImplemented:{TypedText typeof}{LeftParen (}{Placeholder type}{RightParen )} (40)
+// CHECK-CC5: NotImplemented:{TypedText union} (50)
+// CHECK-CC5: NotImplemented:{TypedText unsigned} (50)
+// CHECK-CC5: NotImplemented:{TypedText void} (50)
+// CHECK-CC5: NotImplemented:{TypedText volatile} (50)
diff --git a/clang/test/Index/complete-driver-errors.c b/clang/test/Index/complete-driver-errors.c
new file mode 100644
index 0000000..566090c
--- /dev/null
+++ b/clang/test/Index/complete-driver-errors.c
@@ -0,0 +1,24 @@
+int *blah = 1;
+
+int
+
+// CHECK-RESULTS: NotImplemented:{TypedText const} (40)
+// CHECK-RESULTS: NotImplemented:{TypedText restrict} (40)
+// CHECK-RESULTS: NotImplemented:{TypedText volatile} (40)
+// CHECK-DIAGS: error: invalid value '' in '-std='
+// CHECK-DIAGS: complete-driver-errors.c:1:6:{1:13-1:14}: warning: incompatible integer to pointer conversion initializing 'int *' with an expression of type 'int'
+
+// Test driver errors with code completion
+// RUN: c-index-test -code-completion-at=%s:4:1 -std= %s 2> %t | FileCheck -check-prefix=CHECK-RESULTS %s
+// RUN: FileCheck -check-prefix=CHECK-DIAGS %s < %t
+
+// Test driver errors with parsing
+// RUN: c-index-test -test-load-source all -std= %s 2> %t | FileCheck -check-prefix=CHECK-LOAD %s
+// RUN: FileCheck -check-prefix=CHECK-DIAGS %s < %t
+// CHECK-LOAD: complete-driver-errors.c:1:6: VarDecl=blah:1:6
+
+// Test driver errors with code completion and precompiled preamble
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:4:1 -std= %s 2> %t | FileCheck -check-prefix=CHECK-RESULTS %s
+// RUN: FileCheck -check-prefix=CHECK-DIAGS %s < %t
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source all -std= %s 2> %t | FileCheck -check-prefix=CHECK-LOAD %s
+// RUN: FileCheck -check-prefix=CHECK-DIAGS %s < %t
diff --git a/clang/test/Index/complete-enums.c b/clang/test/Index/complete-enums.c
new file mode 100644
index 0000000..713e24f
--- /dev/null
+++ b/clang/test/Index/complete-enums.c
@@ -0,0 +1,22 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+enum __attribute__((deprecated)) Color {
+ Color_Red = 17,
+ Color_Green,
+ Color_Blue
+};
+int Greeby();
+void f(enum Color color) {
+ switch (color) {
+ case Red:
+ }
+}
+
+// RUN: c-index-test -code-completion-at=%s:11:1 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: EnumConstantDecl:{ResultType enum Color}{TypedText Color_Red} (65) (deprecated)
+
+// RUN: c-index-test -code-completion-at=%s:12:8 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: EnumConstantDecl:{ResultType enum Color}{TypedText Color_Blue} (7) (deprecated)
+// CHECK-CC2-NEXT: EnumConstantDecl:{ResultType enum Color}{TypedText Color_Green} (7) (deprecated)
+// CHECK-CC2-NEXT: EnumConstantDecl:{ResultType enum Color}{TypedText Color_Red} (7) (deprecated)
diff --git a/clang/test/Index/complete-enums.cpp b/clang/test/Index/complete-enums.cpp
new file mode 100644
index 0000000..49a8932
--- /dev/null
+++ b/clang/test/Index/complete-enums.cpp
@@ -0,0 +1,25 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+enum class Color {
+ Red = 17,
+ Green,
+ Blue
+};
+int Greeby();
+void f(Color color) {
+ switch (color) {
+ case Color::Green:
+ case Color::Red;
+ }
+}
+
+// RUN: c-index-test -code-completion-at=%s:12:8 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: EnumConstantDecl:{ResultType Color}{Text Color::}{TypedText Blue} (7)
+// CHECK-CC1: EnumConstantDecl:{ResultType Color}{Text Color::}{TypedText Green} (7)
+// CHECK-CC1: EnumConstantDecl:{ResultType Color}{Text Color::}{TypedText Red} (7)
+
+// RUN: c-index-test -code-completion-at=%s:13:8 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: EnumConstantDecl:{ResultType Color}{Text Color::}{TypedText Blue} (7)
+// CHECK-CC2-NOT: Green
+// CHECK-CC2: EnumConstantDecl:{ResultType Color}{Text Color::}{TypedText Red} (7)
diff --git a/clang/test/Index/complete-exprs.c b/clang/test/Index/complete-exprs.c
new file mode 100644
index 0000000..afb6219
--- /dev/null
+++ b/clang/test/Index/complete-exprs.c
@@ -0,0 +1,69 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+int f(int) __attribute__((unavailable));
+
+int test(int i, int j, int k, int l) {
+ return i | j | k & l;
+}
+
+struct X __attribute__((deprecated)) f1 = { 17 };
+void f2() { f1(17); }
+
+const char *str = "Hello, \nWorld";
+
+void f3(const char*, ...) __attribute__((sentinel(0)));
+
+#define NULL __null
+void f4(const char* str) {
+ f3(str, NULL);
+}
+
+typedef int type;
+void f5(float f) {
+ (type)f;
+}
+
+// RUN: c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: NotImplemented:{TypedText __PRETTY_FUNCTION__} (65)
+// CHECK-CC1: macro definition:{TypedText __VERSION__} (70)
+// CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (12) (unavailable)
+// CHECK-CC1-NOT: NotImplemented:{TypedText float} (65)
+// CHECK-CC1: ParmDecl:{ResultType int}{TypedText j} (8)
+// CHECK-CC1: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: c-index-test -code-completion-at=%s:7:14 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:14 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: macro definition:{TypedText __VERSION__} (70)
+// CHECK-CC3: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50)
+// CHECK-CC3-NOT: NotImplemented:{TypedText float}
+// CHECK-CC3: ParmDecl:{ResultType int}{TypedText j} (34)
+// CHECK-CC3: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expressio
+
+// RUN: c-index-test -code-completion-at=%s:7:18 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: c-index-test -code-completion-at=%s:7:22 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: c-index-test -code-completion-at=%s:7:2 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: macro definition:{TypedText __VERSION__} (70)
+// CHECK-CC2: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50)
+// CHECK-CC2: NotImplemented:{TypedText float} (50)
+// CHECK-CC2: ParmDecl:{ResultType int}{TypedText j} (34)
+// CHECK-CC2: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// RUN: c-index-test -code-completion-at=%s:11:16 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50)
+// CHECK-CC4: VarDecl:{ResultType struct X}{TypedText f1} (50) (deprecated)
+
+// RUN: c-index-test -code-completion-at=%s:19:3 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC6 %s
+// CHECK-CC6: FunctionDecl:{ResultType void}{TypedText f3}{LeftParen (}{Placeholder const char *, ...}{Text , NULL}{RightParen )} (50)
+// CHECK-CC6: NotImplemented:{TypedText void} (50)
+// CHECK-CC6: NotImplemented:{TypedText volatile} (50)
+
+// RUN: c-index-test -code-completion-at=%s:24:4 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC7 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:24:4 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC7 %s
+// CHECK-CC7: ParmDecl:{ResultType float}{TypedText f} (34)
+// CHECK-CC7: VarDecl:{ResultType struct X}{TypedText f1} (50) (deprecated)
+// CHECK-CC7: FunctionDecl:{ResultType void}{TypedText f2}{LeftParen (}{RightParen )} (50)
+// CHECK-CC7: FunctionDecl:{ResultType void}{TypedText f3}{LeftParen (}{Placeholder const char *, ...}{Text , NULL}{RightParen )} (50)
+// CHECK-CC7: FunctionDecl:{ResultType void}{TypedText f4}{LeftParen (}{Placeholder const char *str}{RightParen )} (50)
+// CHECK-CC7: FunctionDecl:{ResultType void}{TypedText f5}{LeftParen (}{Placeholder float f}{RightParen )} (50)
+// CHECK-CC7: TypedefDecl:{TypedText type}
diff --git a/clang/test/Index/complete-exprs.cpp b/clang/test/Index/complete-exprs.cpp
new file mode 100644
index 0000000..de3aac5
--- /dev/null
+++ b/clang/test/Index/complete-exprs.cpp
@@ -0,0 +1,84 @@
+// Line- and column-sensitive test; run lines follow.
+
+class string {
+ public:
+ string();
+ string(const char *);
+ string(const char *, int n);
+};
+
+template<typename T>
+class vector {
+public:
+ vector(const T &, unsigned n);
+ template<typename InputIterator>
+ vector(InputIterator first, InputIterator last);
+ void push_back(const T&);
+};
+template<typename T> void vector<T>::push_back(const T&) { }
+void f() {
+
+}
+
+int foo();
+
+void g() {
+ vector<int>(foo(), foo());
+}
+
+struct X {
+ void f() const;
+};
+
+void X::f() const {
+
+}
+
+namespace N {
+ int x;
+ class C {
+ int member;
+
+ int f(int param) {
+ return member;
+ }
+ };
+}
+
+// RUN: c-index-test -code-completion-at=%s:20:2 %s -std=c++0x | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:20:2 -std=c++0x %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: NotImplemented:{ResultType size_t}{TypedText alignof}{LeftParen (}{Placeholder type}{RightParen )} (40)
+// CHECK-CC1: NotImplemented:{ResultType bool}{TypedText noexcept}{LeftParen (}{Placeholder expression}{RightParen )} (40)
+// CHECK-CC1: NotImplemented:{ResultType std::nullptr_t}{TypedText nullptr} (40)
+// CHECK-CC1: NotImplemented:{TypedText operator} (40)
+// CHECK-CC1-NOT: push_back
+// CHECK-CC1: ClassDecl:{TypedText string} (50)
+// CHECK-CC1: CXXConstructor:{TypedText string}{LeftParen (}{RightParen )} (50)
+// CHECK-CC1: CXXConstructor:{TypedText string}{LeftParen (}{Placeholder const char *}{RightParen )} (50)
+// CHECK-CC1: CXXConstructor:{TypedText string}{LeftParen (}{Placeholder const char *}{Comma , }{Placeholder int n}{RightParen )} (50)
+// CHECK-CC1: ClassTemplate:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
+// CHECK-CC1: CXXConstructor:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder const T &}{Comma , }{Placeholder unsigned int n}{RightParen )} (50)
+// CHECK-CC1: FunctionTemplate:{ResultType void}{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder InputIterator first}{Comma , }{Placeholder InputIterator last}{RightParen )} (50)
+
+// RUN: c-index-test -code-completion-at=%s:19:1 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:19:1 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: ClassDecl:{TypedText string} (50)
+// CHECK-CC2-NOT: CXXConstructor
+// CHECK-CC2: ClassTemplate:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
+
+// RUN: c-index-test -code-completion-at=%s:26:15 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: NotImplemented:{TypedText float} (50)
+// CHECK-CC3: FunctionDecl:{ResultType int}{TypedText foo}{LeftParen (}{RightParen )} (50)
+// CHECK-CC3: FunctionDecl:{ResultType void}{TypedText g}{LeftParen (}{RightParen )} (50)
+// CHECK-CC3: ClassTemplate:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
+// CHECK-CC3: CXXConstructor:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder const T &}{Comma , }{Placeholder unsigned int n}{RightParen )} (50)
+// CHECK-CC3: FunctionTemplate:{ResultType void}{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder InputIterator first}{Comma , }{Placeholder InputIterator last}{RightParen )} (50)
+
+// RUN: c-index-test -code-completion-at=%s:34:1 %s -std=c++0x | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: NotImplemented:{ResultType const X *}{TypedText this} (40)
+
+// RUN: c-index-test -code-completion-at=%s:43:14 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: FieldDecl:{ResultType int}{TypedText member} (8) (parent: ClassDecl 'N::C')
+// CHECK-CC5: ParmDecl:{ResultType int}{TypedText param} (8)
+// CHECK-CC5: StructDecl:{TypedText X} (50) (parent: TranslationUnit '(null)')
+// CHECK-CC5: VarDecl:{ResultType int}{TypedText x} (12) (parent: Namespace 'N')
diff --git a/clang/test/Index/complete-exprs.m b/clang/test/Index/complete-exprs.m
new file mode 100644
index 0000000..c3ff63b
--- /dev/null
+++ b/clang/test/Index/complete-exprs.m
@@ -0,0 +1,49 @@
+typedef signed char BOOL;
+#define YES ((BOOL)1)
+#define NO ((BOOL)0)
+#define bool _Bool
+@interface NSArray + (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; @end
+@interface A
+- (int)method:(id)param1;
+@property int prop1;
+@end
+__strong id global;
+@implementation A
+- (int)method:(id)param1 {
+ void foo(bool (^block)(id x, A* y));
+ for(BOOL B = YES; ; ) { }
+ @[ global ];
+ @{ global : global };
+}
+@end
+
+// RUN: c-index-test -code-completion-at=%s:13:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: NotImplemented:{TypedText @[}{HorizontalSpace }{Placeholder objects, ...}{HorizontalSpace }{RightBracket ]} (40)
+// CHECK-CC1: NotImplemented:{TypedText @{}{HorizontalSpace }{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{HorizontalSpace }{RightBrace }} (40)
+// CHECK-CC1: NotImplemented:{ResultType SEL}{TypedText _cmd} (80)
+// CHECK-CC1: TypedefDecl:{TypedText BOOL} (50)
+// CHECK-CC1: macro definition:{TypedText bool} (51)
+// CHECK-CC1: macro definition:{TypedText NO} (65)
+// CHECK-CC1: NotImplemented:{ResultType A *}{TypedText self} (34)
+// CHECK-CC1: macro definition:{TypedText YES} (65)
+// RUN: c-index-test -code-completion-at=%s:14:7 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:7 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: TypedefDecl:{TypedText BOOL} (50)
+// CHECK-CC2: NotImplemented:{TypedText char} (50)
+// CHECK-CC2: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// RUN: c-index-test -code-completion-at=%s:15:1 -fobjc-arc -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:15:1 -fobjc-arc -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: FunctionDecl:{ResultType void}{TypedText foo}{LeftParen (}{Placeholder ^bool(id x, A *y)block}{RightParen )} (34)
+// CHECK-CC3: VarDecl:{ResultType id}{TypedText global} (50)
+// CHECK-CC3: ParmDecl:{ResultType id}{TypedText param1} (34)
+
+// RUN: c-index-test -code-completion-at=%s:15:5 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: c-index-test -code-completion-at=%s:16:5 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: c-index-test -code-completion-at=%s:16:14 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: NotImplemented:{TypedText @[}{HorizontalSpace }{Placeholder objects, ...}{HorizontalSpace }{RightBracket ]} (40)
+// CHECK-CC4: NotImplemented:{TypedText @{}{HorizontalSpace }{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{HorizontalSpace }{RightBrace }} (40)
+// CHECK-CC4: NotImplemented:{ResultType SEL}{TypedText _cmd} (80)
+// CHECK-CC4: macro definition:{TypedText bool} (51)
+// CHECK-CC4: macro definition:{TypedText NO} (65)
+// CHECK-CC4: NotImplemented:{ResultType A *}{TypedText self} (34)
+// CHECK-CC4: macro definition:{TypedText YES} (65)
diff --git a/clang/test/Index/complete-hiding.c b/clang/test/Index/complete-hiding.c
new file mode 100644
index 0000000..1da20e6
--- /dev/null
+++ b/clang/test/Index/complete-hiding.c
@@ -0,0 +1,32 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+struct StructA { };
+struct StructB { };
+struct StructC { };
+int ValueA;
+int ValueB;
+
+void f() {
+
+ int ValueA = 0;
+ int StructA = 0;
+ struct StructB { };
+
+ struct StructA sa = { };
+}
+
+// RUN: c-index-test -code-completion-at=%s:16:3 %s > %t
+// RUN: FileCheck -check-prefix=CHECK-CC1 -input-file=%t %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:16:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: VarDecl:{ResultType int}{TypedText StructA} (34)
+// CHECK-CC1: VarDecl:{ResultType int}{TypedText ValueA} (34)
+// CHECK-CC1-NOT: VarDecl:{ResultType int}{TypedText ValueA} (50)
+// CHECK-CC1: VarDecl:{ResultType int}{TypedText ValueB} (50)
+// RUN: c-index-test -code-completion-at=%s:16:10 %s > %t
+// RUN: FileCheck -check-prefix=CHECK-CC2 -input-file=%t %s
+// CHECK-CC2: StructDecl:{TypedText StructA} (50)
+// CHECK-CC2-NOT: StructDecl:{TypedText StructB} (50)
+// CHECK-CC2: StructDecl:{TypedText StructC} (50)
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:16:10 %s > %t
+// RUN: FileCheck -check-prefix=CHECK-CC2 -input-file=%t %s
diff --git a/clang/test/Index/complete-in-invalid-method.m b/clang/test/Index/complete-in-invalid-method.m
new file mode 100644
index 0000000..0e6c8e6
--- /dev/null
+++ b/clang/test/Index/complete-in-invalid-method.m
@@ -0,0 +1,19 @@
+@interface I
+-(void)foo;
+@end
+
+struct S {
+ int x,y;
+};
+
+@implementation I
+-(void) foo {
+ struct S s;
+ if (1) {
+ s.
+}
+@end
+
+// RUN: c-index-test -code-completion-at=%s:13:7 -fobjc-nonfragile-abi %s | FileCheck %s
+// CHECK: FieldDecl:{ResultType int}{TypedText x}
+// CHECK: FieldDecl:{ResultType int}{TypedText y}
diff --git a/clang/test/Index/complete-in-stringify.c b/clang/test/Index/complete-in-stringify.c
new file mode 100644
index 0000000..d518549
--- /dev/null
+++ b/clang/test/Index/complete-in-stringify.c
@@ -0,0 +1,17 @@
+const char *func(const char *);
+
+#define MORE __FILE__
+
+#define M(x) "1"#x
+#define N(x) func("2"#x MORE)
+
+void foo(const char *);
+
+int test() {
+ foo(M(x()));
+ foo(N(x()));
+}
+
+// RUN: c-index-test -code-completion-at=%s:11:11 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:12:11 %s | FileCheck %s
+// CHECK: Natural language
diff --git a/clang/test/Index/complete-interfaces.m b/clang/test/Index/complete-interfaces.m
new file mode 100644
index 0000000..2f86c3d
--- /dev/null
+++ b/clang/test/Index/complete-interfaces.m
@@ -0,0 +1,47 @@
+/* Note: the RUN lines are near the end of the file, since line/column
+ matter for this test. */
+
+@class Int1, Int2, Int3, Int4;
+
+@interface Int3
+{
+}
+@end
+
+@interface Int2 : Int3
+{
+}
+@end
+
+@implementation Int2
+@end
+
+@implementation Int3
+@end
+
+// RUN: c-index-test -code-completion-at=%s:6:12 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: ObjCInterfaceDecl:{TypedText Int1}
+// CHECK-CC1: ObjCInterfaceDecl:{TypedText Int2}
+// CHECK-CC1: ObjCInterfaceDecl:{TypedText Int3}
+// CHECK-CC1: ObjCInterfaceDecl:{TypedText Int4}
+// RUN: c-index-test -code-completion-at=%s:11:12 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: ObjCInterfaceDecl:{TypedText Int1}
+// CHECK-CC2-NEXT: ObjCInterfaceDecl:{TypedText Int2}
+// CHECK-CC2-NEXT: ObjCInterfaceDecl:{TypedText Int3}
+// CHECK-CC2-NEXT: ObjCInterfaceDecl:{TypedText Int4}
+// RUN: c-index-test -code-completion-at=%s:11:19 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: ObjCInterfaceDecl:{TypedText Int1}
+// CHECK-CC3-NEXT: ObjCInterfaceDecl:{TypedText Int3}
+// CHECK-CC3-NEXT: ObjCInterfaceDecl:{TypedText Int4}
+// RUN: c-index-test -code-completion-at=%s:16:17 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: ObjCInterfaceDecl:{TypedText Int1}
+// CHECK-CC4-NEXT: ObjCInterfaceDecl:{TypedText Int2}
+// CHECK-CC4-NEXT: ObjCInterfaceDecl:{TypedText Int3}
+// CHECK-CC4-NEXT: ObjCInterfaceDecl:{TypedText Int4}
+// RUN: c-index-test -code-completion-at=%s:19:17 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: ObjCInterfaceDecl:{TypedText Int1}
+// CHECK-CC5-NEXT: ObjCInterfaceDecl:{TypedText Int3}
+// CHECK-CC5-NEXT: ObjCInterfaceDecl:{TypedText Int4}
+
+
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:11:12 %s | FileCheck -check-prefix=CHECK-CC2 %s
diff --git a/clang/test/Index/complete-ivar-access.m b/clang/test/Index/complete-ivar-access.m
new file mode 100644
index 0000000..13b43d8
--- /dev/null
+++ b/clang/test/Index/complete-ivar-access.m
@@ -0,0 +1,69 @@
+@interface Other {
+@private
+ int other_private;
+@protected
+ int other_protected;
+@public
+ int other_public;
+}
+@end
+
+@interface Super {
+@private
+ int super_private;
+@protected
+ int super_protected;
+@public
+ int super_public;
+}
+@end
+
+@interface Super () {
+@private
+ int super_ext_private;
+@protected
+ int super_ext_protected;
+@public
+ int super_ext_public;
+}
+@end
+
+@interface Sub : Super {
+@private
+ int sub_private;
+@protected
+ int sub_protected;
+@public
+ int sub_public;
+}
+@end
+
+@implementation Sub
+- (void)method:(Sub *)sub with:(Other *)other {
+ sub->super_protected = 1;
+ other->other_public = 1;
+}
+
+void f(Sub *sub, Other *other) {
+ sub->super_protected = 1;
+ other->other_public = 1;
+}
+@end
+
+// RUN: c-index-test -code-completion-at=%s:43:8 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-SUB %s
+// RUN: c-index-test -code-completion-at=%s:48:8 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-SUB %s
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText sub_private} (35)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText sub_protected} (35)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText sub_public} (35)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText super_ext_private} (35) (inaccessible)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText super_ext_protected} (35)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText super_ext_public} (35)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText super_private} (37) (inaccessible)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText super_protected} (37)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText super_public} (37)
+
+// RUN: c-index-test -code-completion-at=%s:44:10 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-OTHER %s
+// RUN: c-index-test -code-completion-at=%s:49:10 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-OTHER %s
+// CHECK-OTHER: ObjCIvarDecl:{ResultType int}{TypedText other_private} (35) (inaccessible)
+// CHECK-OTHER: ObjCIvarDecl:{ResultType int}{TypedText other_protected} (35) (inaccessible)
+// CHECK-OTHER: ObjCIvarDecl:{ResultType int}{TypedText other_public} (35)
diff --git a/clang/test/Index/complete-kvc.m b/clang/test/Index/complete-kvc.m
new file mode 100644
index 0000000..62d98a9
--- /dev/null
+++ b/clang/test/Index/complete-kvc.m
@@ -0,0 +1,105 @@
+// Test for code completions related to Key-Value Coding and Key-Value Observing.
+// Since this test is line- and column-sensitive, the run lines are at the end.
+
+typedef signed char BOOL;
+
+@interface NSSet
+@end
+
+@interface NSMutableSet : NSSet
+@end
+
+@interface MySet : NSMutableSet
+@end
+
+@interface NSArray
+@end
+
+@interface NSMutableArray : NSArray
+@end
+
+@interface MyArray : NSMutableArray
+@end
+
+@interface MyClass
+@property int intProperty;
+@property BOOL boolProperty;
+@property int* intPointerProperty;
+
+@property NSSet *setProperty;
+@property NSMutableSet *mutableSetProperty;
+@property MySet *mySetProperty;
+
+@property NSArray *arrayProperty;
+@property NSMutableArray *mutableArrayProperty;
+@property MyArray *myArrayProperty;
+@end
+
+@implementation MyClass
+- (int)intProperty { return 0; }
+- (void)setIntProperty:(int)newValue { }
++ (NSSet *)keyPathsForValuesAffectingIntProperty { return 0; }
+@end
+
+@interface MySubClass : MyClass
+@end
+
+@interface MySubClass ()
+@property int intProperty;
+@end
+
+@implementation MySubClass
+- (int)intProperty { return 0; }
+@end
+
+// RUN: c-index-test -code-completion-at=%s:39:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText addMutableArrayPropertyObject:}{LeftParen (}{Placeholder object-type}{Text *}{RightParen )}{Text object} (55)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText addMutableSetProperty:}{LeftParen (}{Text NSSet *}{RightParen )}{Text objects} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text NSArray *}{RightParen )}{TypedText arrayProperty} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text NSArray *}{RightParen )}{TypedText arrayPropertyAtIndexes:}{LeftParen (}{Text NSIndexSet *}{RightParen )}{Text indexes} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text BOOL}{RightParen )}{TypedText boolProperty} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text NSArray *}{RightParen )}{TypedText boolPropertyAtIndexes:}{LeftParen (}{Text NSIndexSet *}{RightParen )}{Text indexes} (55)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text NSUInteger}{RightParen )}{TypedText countOfArrayProperty} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text NSUInteger}{RightParen )}{TypedText countOfBoolProperty} (55)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text NSUInteger}{RightParen )}{TypedText countOfSetProperty} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text NSEnumerator *}{RightParen )}{TypedText enumeratorOfMutableArrayProperty} (55)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text NSEnumerator *}{RightParen )}{TypedText enumeratorOfMutableSetProperty} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText getMyArrayProperty:}{LeftParen (}{Placeholder object-type}{Text **}{RightParen )}{Text buffer}{HorizontalSpace }{TypedText range:}{LeftParen (}{Text NSRange}{RightParen )}{Text inRange} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText getMySetProperty:}{LeftParen (}{Placeholder object-type}{Text **}{RightParen )}{Text buffer}{HorizontalSpace }{TypedText range:}{LeftParen (}{Text NSRange}{RightParen )}{Text inRange} (55)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText insertIntProperty:}{LeftParen (}{Text NSArray *}{RightParen )}{Text array}{HorizontalSpace }{TypedText atIndexes:}{LeftParen (}{Placeholder NSIndexSet *}{RightParen )}{Text indexes} (55)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText insertMutableArrayProperty:}{LeftParen (}{Text NSArray *}{RightParen )}{Text array}{HorizontalSpace }{TypedText atIndexes:}{LeftParen (}{Placeholder NSIndexSet *}{RightParen )}{Text indexes} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText insertObject:}{LeftParen (}{Placeholder object-type}{Text *}{RightParen )}{Text object}{HorizontalSpace }{TypedText inMyArrayPropertyAtIndex:}{LeftParen (}{Placeholder NSUInteger}{RightParen )}{Text index} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText insertObject:}{LeftParen (}{Placeholder object-type}{Text *}{RightParen )}{Text object}{HorizontalSpace }{TypedText inMySetPropertyAtIndex:}{LeftParen (}{Placeholder NSUInteger}{RightParen )}{Text index} (55)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText intersectMySetProperty:}{LeftParen (}{Text NSSet *}{RightParen )}{Text objects} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText intersectSetProperty:}{LeftParen (}{Text NSSet *}{RightParen )}{Text objects} (55)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text int *}{RightParen )}{TypedText intPointerProperty} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText intProperty} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text BOOL}{RightParen )}{TypedText isBoolProperty} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text BOOL}{RightParen )}{TypedText isIntProperty} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Placeholder object-type}{Text *}{RightParen )}{TypedText memberOfMyArrayProperty:}{LeftParen (}{Placeholder object-type}{Text *}{RightParen )}{Text object} (55)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Placeholder object-type}{Text *}{RightParen )}{TypedText memberOfMySetProperty:}{LeftParen (}{Placeholder object-type}{Text *}{RightParen )}{Text object} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text NSMutableArray *}{RightParen )}{TypedText mutableArrayProperty} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text NSMutableSet *}{RightParen )}{TypedText mutableSetProperty} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text NSArray *}{RightParen )}{TypedText mutableSetPropertyAtIndexes:}{LeftParen (}{Text NSIndexSet *}{RightParen )}{Text indexes} (55)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text MyArray *}{RightParen )}{TypedText myArrayProperty} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text NSArray *}{RightParen )}{TypedText myArrayPropertyAtIndexes:}{LeftParen (}{Text NSIndexSet *}{RightParen )}{Text indexes} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText objectInMutableSetPropertyAtIndex:}{LeftParen (}{Text NSUInteger}{RightParen )}{Text index} (55)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText objectInMyArrayPropertyAtIndex:}{LeftParen (}{Text NSUInteger}{RightParen )}{Text index} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText removeMyArrayPropertyAtIndexes:}{LeftParen (}{Text NSIndexSet *}{RightParen )}{Text indexes} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText removeMySetPropertyAtIndexes:}{LeftParen (}{Text NSIndexSet *}{RightParen )}{Text indexes} (55)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText removeObjectFromIntPropertyAtIndex:}{LeftParen (}{Text NSUInteger}{RightParen )}{Text index} (55)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText removeObjectFromMutableArrayPropertyAtIndex:}{LeftParen (}{Text NSUInteger}{RightParen )}{Text index} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText replaceMyArrayPropertyAtIndexes:}{LeftParen (}{Placeholder NSIndexSet *}{RightParen )}{Text indexes}{HorizontalSpace }{TypedText withMyArrayProperty:}{LeftParen (}{Text NSArray *}{RightParen )}{Text array} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText replaceMySetPropertyAtIndexes:}{LeftParen (}{Placeholder NSIndexSet *}{RightParen )}{Text indexes}{HorizontalSpace }{TypedText withMySetProperty:}{LeftParen (}{Text NSArray *}{RightParen )}{Text array} (55)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText replaceObjectInMyArrayPropertyAtIndex:}{LeftParen (}{Placeholder NSUInteger}{RightParen )}{Text index}{HorizontalSpace }{TypedText withObject:}{LeftParen (}{Text id}{RightParen )}{Text object} (40)
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText replaceObjectInMySetPropertyAtIndex:}{LeftParen (}{Placeholder NSUInteger}{RightParen )}{Text index}{HorizontalSpace }{TypedText withObject:}{LeftParen (}{Text id}{RightParen )}{Text object} (55)
+
+// RUN: c-index-test -code-completion-at=%s:41:3 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: ObjCClassMethodDecl:{LeftParen (}{Text BOOL}{RightParen )}{TypedText automaticallyNotifiesObserversOfArrayProperty} (40)
+// CHECK-CC2: ObjCClassMethodDecl:{LeftParen (}{Text BOOL}{RightParen )}{TypedText automaticallyNotifiesObserversOfMutableArrayProperty} (40)
+// CHECK-CC2: ObjCClassMethodDecl:{LeftParen (}{Text NSSet *}{RightParen )}{TypedText keyPathsForValuesAffectingMutableArrayProperty} (40)
+
+// RUN: c-index-test -code-completion-at=%s:52:8 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText countOfIntProperty} (55)
+// CHECK-CC3-NEXT: ObjCInstanceMethodDecl:{TypedText intProperty} (40)
+// CHECK-CC3-NEXT: ObjCInstanceMethodDecl:{TypedText isIntProperty} (40)
diff --git a/clang/test/Index/complete-lambdas.cpp b/clang/test/Index/complete-lambdas.cpp
new file mode 100644
index 0000000..ba337e4
--- /dev/null
+++ b/clang/test/Index/complete-lambdas.cpp
@@ -0,0 +1,43 @@
+// This test is line- and column-sensitive. See below for run lines.
+
+int global;
+
+struct X {
+ static int member;
+ void f(int zed) {
+ int local;
+ static int local_static;
+ [=] {
+ int inner_local;
+ [local, this, inner_local] {
+ }
+ }();
+ }
+};
+
+
+// RUN: c-index-test -code-completion-at=%s:12:8 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: VarDecl:{ResultType int}{TypedText inner_local} (34)
+// CHECK-CC1-NEXT: VarDecl:{ResultType int}{TypedText local} (34)
+// CHECK-CC1-NEXT: NotImplemented:{ResultType X *}{TypedText this} (40)
+// CHECK-CC1-NEXT: ParmDecl:{ResultType int}{TypedText zed} (34)
+
+// RUN: c-index-test -code-completion-at=%s:12:15 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: VarDecl:{ResultType int}{TypedText inner_local} (34)
+// CHECK-CC2-NEXT: NotImplemented:{ResultType X *}{TypedText this} (40)
+// CHECK-CC2-NEXT: ParmDecl:{ResultType int}{TypedText zed} (34)
+
+// RUN: c-index-test -code-completion-at=%s:12:21 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: VarDecl:{ResultType int}{TypedText inner_local} (34)
+// CHECK-CC3-NEXT: ParmDecl:{ResultType int}{TypedText zed} (34)
+
+// RUN: c-index-test -code-completion-at=%s:12:8 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: TypedefDecl:{TypedText Class} (50)
+// CHECK-CC4: TypedefDecl:{TypedText id} (50)
+// CHECK-CC4: VarDecl:{ResultType int}{TypedText inner_local} (34)
+// CHECK-CC4: VarDecl:{ResultType int}{TypedText local} (34)
+// CHECK-CC4: NotImplemented:{ResultType X *}{TypedText this} (40)
+// CHECK-CC4: ParmDecl:{ResultType int}{TypedText zed} (34)
+
+// RUN: c-index-test -code-completion-at=%s:12:15 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: c-index-test -code-completion-at=%s:12:21 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC3 %s
diff --git a/clang/test/Index/complete-macro-args.c b/clang/test/Index/complete-macro-args.c
new file mode 100644
index 0000000..ca36af1
--- /dev/null
+++ b/clang/test/Index/complete-macro-args.c
@@ -0,0 +1,22 @@
+struct Point {
+ float x;
+ float y;
+ float z;
+};
+
+#define MACRO2(x) x
+#define MACRO(x) MACRO2(x)
+
+void test(struct Point *p) {
+ p->x;
+ MACRO(p->x);
+}
+
+// RUN: c-index-test -code-completion-at=%s:11:12 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:12:12 %s | FileCheck %s
+// CHECK: FieldDecl:{ResultType float}{TypedText x} (35)
+// CHECK-NEXT: FieldDecl:{ResultType float}{TypedText y} (35)
+// CHECK-NEXT: FieldDecl:{ResultType float}{TypedText z} (35)
+// CHECK-NEXT: Completion contexts:
+// CHECK-NEXT: Arrow member access
+// CHECK-NEXT: Container Kind: StructDecl
diff --git a/clang/test/Index/complete-macros.c b/clang/test/Index/complete-macros.c
new file mode 100644
index 0000000..df798a8
--- /dev/null
+++ b/clang/test/Index/complete-macros.c
@@ -0,0 +1,43 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+#define FOO(Arg1,Arg2) foobar
+#define nil 0
+void f() {
+
+}
+
+void g(int);
+
+void f2() {
+ int *ip = nil;
+ ip = nil;
+ g(nil);
+}
+
+#define variadic1(...)
+#define variadic2(args...)
+#define variadic3(args, ...)
+#define variadic4(first, second, args, ...)
+#define variadic5(first, second, args ...)
+
+void test_variadic() {
+
+}
+
+// RUN: c-index-test -code-completion-at=%s:7:1 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:1 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: macro definition:{TypedText FOO}{LeftParen (}{Placeholder Arg1}{Comma , }{Placeholder Arg2}{RightParen )}
+// RUN: c-index-test -code-completion-at=%s:13:13 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: c-index-test -code-completion-at=%s:14:8 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:8 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: macro definition:{TypedText nil} (32)
+// RUN: c-index-test -code-completion-at=%s:15:5 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:15:5 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: macro definition:{TypedText nil} (65)
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:25:2 %s | FileCheck -check-prefix=CHECK-VARIADIC %s
+// CHECK-VARIADIC: macro definition:{TypedText variadic1}{LeftParen (}{Placeholder ...}{RightParen )} (70)
+// CHECK-VARIADIC: macro definition:{TypedText variadic2}{LeftParen (}{Placeholder args...}{RightParen )} (70)
+// CHECK-VARIADIC: macro definition:{TypedText variadic3}{LeftParen (}{Placeholder args, ...}{RightParen )} (70)
+// CHECK-VARIADIC: macro definition:{TypedText variadic4}{LeftParen (}{Placeholder first}{Comma , }{Placeholder second}{Comma , }{Placeholder args, ...}{RightParen )} (70)
+// CHECK-VARIADIC: macro definition:{TypedText variadic5}{LeftParen (}{Placeholder first}{Comma , }{Placeholder second}{Comma , }{Placeholder args...}{RightParen )} (70)
diff --git a/clang/test/Index/complete-member-access.m b/clang/test/Index/complete-member-access.m
new file mode 100644
index 0000000..5e40be1
--- /dev/null
+++ b/clang/test/Index/complete-member-access.m
@@ -0,0 +1,77 @@
+/* Note: the RUN lines are near the end of the file, since line/column
+ matter for this test. */
+
+@protocol MyProtocol
+@property float ProtoProp;
+@end
+
+@interface Super {
+ int SuperIVar;
+}
+@end
+@interface Int : Super<MyProtocol>
+{
+ int IVar;
+}
+
+@property int prop1;
+@end
+
+void test_props(Int* ptr) {
+ ptr.prop1 = 0;
+ ptr->IVar = 0;
+}
+
+@interface Sub : Int
+@property int myProp;
+
+- (int)myProp;
+- (int)myOtherPropLikeThing;
+- (int)myOtherNonPropThing:(int)value;
+@end
+
+int test_more_props(Sub *s) {
+ return s.myOtherPropLikeThing;
+}
+
+@interface Other
+@property Sub *sub;
+@end
+
+int test_two_levels(Other *other) {
+ return other.sub.myProp;
+}
+
+// RUN: c-index-test -code-completion-at=%s:21:7 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: ObjCPropertyDecl:{ResultType int}{TypedText prop1}
+// CHECK-CC1: ObjCPropertyDecl:{ResultType float}{TypedText ProtoProp}
+// CHECK-CC1: Completion contexts:
+// CHECK-CC1-NEXT: Objective-C property access
+// CHECK-CC1-NEXT: Container Kind: ObjCInterfaceDecl
+// CHECK-CC1-NEXT: Container is complete
+// CHECK-CC1-NEXT: Container USR: c:objc(cs)Int
+// RUN: c-index-test -code-completion-at=%s:22:8 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: ObjCIvarDecl:{ResultType int}{TypedText IVar} (35)
+// CHECK-CC2: ObjCIvarDecl:{ResultType int}{TypedText SuperIVar} (37)
+// CHECK-CC2: Completion contexts:
+// CHECK-CC2-NEXT: Arrow member access
+// CHECK-CC2-NEXT: Container Kind: ObjCInterfaceDecl
+// CHECK-CC2-NEXT: Container is complete
+// CHECK-CC2-NEXT: Container USR: c:objc(cs)Int
+// RUN: c-index-test -code-completion-at=%s:34:12 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: ObjCInstanceMethodDecl:{ResultType int}{TypedText myOtherPropLikeThing} (37)
+// CHECK-CC3: ObjCPropertyDecl:{ResultType int}{TypedText myProp} (35)
+// CHECK-CC3: ObjCPropertyDecl:{ResultType int}{TypedText prop1} (35)
+// CHECK-CC3: ObjCPropertyDecl:{ResultType float}{TypedText ProtoProp} (35)
+// CHECK-CC3: Completion contexts:
+// CHECK-CC3-NEXT: Objective-C property access
+// CHECK-CC3-NEXT: Container Kind: ObjCInterfaceDecl
+// CHECK-CC3-NEXT: Container is complete
+// CHECK-CC3-NEXT: Container USR: c:objc(cs)Sub
+
+// RUN: c-index-test -code-completion-at=%s:42:20 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText myOtherPropLikeThing} (37)
+// CHECK-CC4-NEXT: ObjCPropertyDecl:{ResultType int}{TypedText myProp} (35)
+// CHECK-CC4-NEXT: ObjCPropertyDecl:{ResultType int}{TypedText prop1} (35)
+// CHECK-CC4-NEXT: ObjCPropertyDecl:{ResultType float}{TypedText ProtoProp} (35)
+
diff --git a/clang/test/Index/complete-memfunc-cvquals.cpp b/clang/test/Index/complete-memfunc-cvquals.cpp
new file mode 100644
index 0000000..9068ef8
--- /dev/null
+++ b/clang/test/Index/complete-memfunc-cvquals.cpp
@@ -0,0 +1,86 @@
+// The run lines are below, because this test is line- and
+// column-number sensitive.
+struct Foo {
+ void babble() const volatile;
+ void bar();
+ void baz() const;
+ void bingo() volatile;
+ void theend() const volatile;
+};
+
+template<typename T>
+struct smart_ptr {
+ T *operator->();
+ const T* operator->() const;
+};
+
+void text(Foo f, Foo *fp, const Foo &fc, const Foo *fcp,
+ smart_ptr<Foo> sf, const smart_ptr<Foo> &sfc, Foo volatile *fvp) {
+ f.bar();
+ fp->bar();
+ fc.baz();
+ fcp->baz();
+ sf->bar();
+ sfc->baz();
+ fvp->babble();
+}
+
+void Foo::bar() {
+
+}
+
+void Foo::baz() const {
+
+}
+
+void Foo::bingo() volatile {
+
+}
+
+// Check member access expressions.
+// RUN: c-index-test -code-completion-at=%s:19:5 %s | FileCheck -check-prefix=CHECK-NOQUALS %s
+// RUN: c-index-test -code-completion-at=%s:20:7 %s | FileCheck -check-prefix=CHECK-NOQUALS %s
+// RUN: c-index-test -code-completion-at=%s:23:7 %s | FileCheck -check-prefix=CHECK-NOQUALS %s
+// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (35)
+// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{RightParen )} (34)
+// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (35)
+// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (35)
+// RUN: c-index-test -code-completion-at=%s:21:6 %s | FileCheck -check-prefix=CHECK-CONST %s
+// RUN: c-index-test -code-completion-at=%s:22:8 %s | FileCheck -check-prefix=CHECK-CONST %s
+// RUN: c-index-test -code-completion-at=%s:24:8 %s | FileCheck -check-prefix=CHECK-CONST %s
+// CHECK-CONST: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (35)
+// CHECK-CONST-NOT: bar
+// CHECK-CONST: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (34)
+// CHECK-CONST-NOT: bingo
+// CHECK-CONST: theend
+// RUN: c-index-test -code-completion-at=%s:25:8 %s | FileCheck -check-prefix=CHECK-VOLATILE %s
+// CHECK-VOLATILE: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (35)
+// CHECK-VOLATILE-NOT: baz
+// CHECK-VOLATILE: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (34)
+
+// Check implicit member access expressions.
+// RUN: c-index-test -code-completion-at=%s:29:2 %s | FileCheck -check-prefix=CHECK-IMPLICIT-NOQUALS %s
+// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (35)
+// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{RightParen )} (34)
+// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (35)
+// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (35)
+
+// RUN: c-index-test -code-completion-at=%s:33:1 %s | FileCheck -check-prefix=CHECK-IMPLICIT-CONST %s
+// CHECK-IMPLICIT-CONST: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (35)
+// CHECK-IMPLICIT-CONST-NOT: bar
+// CHECK-IMPLICIT-CONST: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (34)
+// CHECK-IMPLICIT-CONST-NOT: bingo
+// CHECK-IMPLICIT-CONST: theend
+
+// RUN: c-index-test -code-completion-at=%s:37:1 %s | FileCheck -check-prefix=CHECK-IMPLICIT-VOLATILE %s
+// CHECK-IMPLICIT-VOLATILE: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (35)
+// CHECK-IMPLICIT-VOLATILE-NOT: baz
+// CHECK-IMPLICIT-VOLATILE: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (34)
+
+// RUN: c-index-test -code-completion-at=%s:4:17 %s | FileCheck -check-prefix=CHECK-CVQUAL-AFTER %s
+// CHECK-CVQUAL-AFTER: NotImplemented:{TypedText const} (40)
+// CHECK-CVQUAL-AFTER: NotImplemented:{TypedText volatile} (40)
+
+// RUN: c-index-test -code-completion-at=%s:4:23 %s | FileCheck -check-prefix=CHECK-CVQUAL-AFTER2 %s
+// CHECK-CVQUAL-AFTER2-NOT: NotImplemented:{TypedText const} (40)
+// CHECK-CVQUAL-AFTER2: NotImplemented:{TypedText volatile} (40)
diff --git a/clang/test/Index/complete-method-decls.m b/clang/test/Index/complete-method-decls.m
new file mode 100644
index 0000000..becb7de
--- /dev/null
+++ b/clang/test/Index/complete-method-decls.m
@@ -0,0 +1,184 @@
+/* Note: the RUN lines are near the end of the file, since line/column
+ matter for this test. */
+#define IBAction void
+@protocol P1
+- (id)abc;
+- (id)initWithInt:(int)x;
+- (id)initWithTwoInts:(inout int)x second:(int)y;
+- (int)getInt;
+- (id)getSelf;
+@end
+
+@protocol P2<P1>
++ (id)alloc;
+@end
+
+@interface A <P1>
+- (id)init;
+- (int)getValue;
+@end
+
+@interface B : A<P2>
+- (id)initWithInt:(int)x;
+- (int)getSecondValue;
+- (id)getSelf;
+- (int)setValue:(int)x;
+@end
+
+@interface B (FooBar)
+- (id)categoryFunction:(int)x;
+@end
+
+@implementation B
+- (int)getSecondValue { return 0; }
+- (id)init { return self; }
+- (id)getSelf { return self; }
+- (void)setValue:(int)x { }
+- (id)initWithTwoInts:(int)x second:(int)y { return self; }
++ (id)alloc { return 0; }
+@end
+
+@implementation B (FooBar)
+- (id)categoryFunction:(int)x { return self; }
+@end
+
+@interface C
+- (int)first:(int)x second:(float)y third:(double)z;
+- (id)first:(int)xx second2:(float)y2 third:(double)z;
+- (void*)first:(int)xxx second3:(float)y3 third:(double)z;
+@end
+
+@interface D
+- (int)first:(int)x second2:(float)y third:(double)z;
+@end
+
+@implementation D
+- (int)first:(int)x second2:(float)y third:(double)z { }
+@end
+
+@interface Passing
+- (oneway void)method:(in id)x;
+@end
+
+@interface Gaps
+- (void)method:(int)x :(int)y;
+@end
+
+@implementation Gaps
+- (void)method:(int)x :(int)y {}
+@end
+
+@implementation Passing
+- (oneway void)method:(in id x) {}
+@end
+
+// RUN: c-index-test -code-completion-at=%s:17:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc} (40) (parent: ObjCProtocolDecl 'P1')
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt} (40) (parent: ObjCProtocolDecl 'P1')
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf} (40) (parent: ObjCProtocolDecl 'P1')
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x} (40) (parent: ObjCProtocolDecl 'P1')
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y} (40) (parent: ObjCProtocolDecl 'P1')
+// RUN: c-index-test -code-completion-at=%s:17:7 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText abc}
+// CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf}
+// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}
+// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
+// RUN: c-index-test -code-completion-at=%s:24:7 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText abc}
+// CHECK-CC3-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf}
+// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText init}
+// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}
+// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:33:3 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)
+// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace
+// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace
+// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (40)
+// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
+// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace
+// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText setValue}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:33:8 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42) (parent: ObjCProtocolDecl 'P1')
+// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (40) (parent: ObjCInterfaceDecl 'B')
+// CHECK-CC5-NOT: {TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace
+// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText setValue}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:37:7 %s | FileCheck -check-prefix=CHECK-CC6 %s
+// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace
+// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (40)
+// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
+// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:42:3 %s | FileCheck -check-prefix=CHECK-CC7 %s
+// CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)
+// CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText categoryFunction}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
+// CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:52:21 %s | FileCheck -check-prefix=CHECK-CC8 %s
+// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{TypedText second2:}{Text (float)y2}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)
+// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType void *}{Informative first:}{TypedText second3:}{Text (float)y3}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)
+// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second:}{Text (float)y}{HorizontalSpace }{TypedText third:}{Text (double)z} (8)
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:52:19 %s | FileCheck -check-prefix=CHECK-CC9 %s
+// CHECK-CC9: NotImplemented:{TypedText x} (40)
+// CHECK-CC9: NotImplemented:{TypedText xx} (40)
+// CHECK-CC9: NotImplemented:{TypedText xxx} (40)
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:52:36 %s | FileCheck -check-prefix=CHECK-CCA %s
+// CHECK-CCA: NotImplemented:{TypedText y2} (40)
+// RUN: c-index-test -code-completion-at=%s:56:3 %s | FileCheck -check-prefix=CHECK-CCB %s
+// CHECK-CCB: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText first}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second2:}{LeftParen (}{Text float}{RightParen )}{Text y}{HorizontalSpace }{TypedText third:}{LeftParen (}{Text double}{RightParen )}{Text z} (40)
+// RUN: c-index-test -code-completion-at=%s:56:8 %s | FileCheck -check-prefix=CHECK-CCC %s
+// CHECK-CCC: ObjCInstanceMethodDecl:{TypedText first}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second2:}{LeftParen (}{Text float}{RightParen )}{Text y}{HorizontalSpace }{TypedText third:}{LeftParen (}{Text double}{RightParen )}{Text z} (40)
+// RUN: c-index-test -code-completion-at=%s:56:21 %s | FileCheck -check-prefix=CHECK-CCD %s
+// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{TypedText second2:}{Text (float)y2}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)
+// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second2:}{Text (float)y}{HorizontalSpace }{TypedText third:}{Text (double)z} (8)
+// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType void *}{Informative first:}{TypedText second3:}{Text (float)y3}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)
+// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second:}{Text (float)y}{HorizontalSpace }{TypedText third:}{Text (double)z} (8)
+// RUN: c-index-test -code-completion-at=%s:56:38 %s | FileCheck -check-prefix=CHECK-CCE %s
+// CHECK-CCE: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{Informative second2:}{TypedText third:}{Text (double)z} (35)
+// CHECK-CCE: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{Informative second2:}{TypedText third:}{Text (double)z} (8)
+// RUN: c-index-test -code-completion-at=%s:60:4 %s | FileCheck -check-prefix=CHECK-CCF %s
+// CHECK-CCF: ObjCInterfaceDecl:{TypedText A} (50)
+// CHECK-CCF: ObjCInterfaceDecl:{TypedText B} (50)
+// CHECK-CCF: NotImplemented:{TypedText bycopy} (40)
+// CHECK-CCF: NotImplemented:{TypedText byref} (40)
+// CHECK-CCF: NotImplemented:{TypedText in} (40)
+// CHECK-CCF: NotImplemented:{TypedText inout} (40)
+// CHECK-CCF: NotImplemented:{TypedText oneway} (40)
+// CHECK-CCF: NotImplemented:{TypedText out} (40)
+// CHECK-CCF: NotImplemented:{TypedText unsigned} (50)
+// CHECK-CCF: NotImplemented:{TypedText void} (50)
+// CHECK-CCF: NotImplemented:{TypedText volatile} (50)
+// RUN: c-index-test -code-completion-at=%s:60:11 %s | FileCheck -check-prefix=CHECK-CCG %s
+// CHECK-CCG: ObjCInterfaceDecl:{TypedText A} (50)
+// CHECK-CCG: ObjCInterfaceDecl:{TypedText B} (50)
+// CHECK-CCG-NOT: NotImplemented:{TypedText bycopy} (40)
+// CHECK-CCG-NOT: NotImplemented:{TypedText byref} (40)
+// CHECK-CCG: NotImplemented:{TypedText in} (40)
+// CHECK-CCG: NotImplemented:{TypedText inout} (40)
+// CHECK-CCG-NOT: NotImplemented:{TypedText oneway} (40)
+// CHECK-CCG: NotImplemented:{TypedText out} (40)
+// CHECK-CCG: NotImplemented:{TypedText unsigned} (50)
+// CHECK-CCG: NotImplemented:{TypedText void} (50)
+// CHECK-CCG: NotImplemented:{TypedText volatile} (50)
+// RUN: c-index-test -code-completion-at=%s:60:24 %s | FileCheck -check-prefix=CHECK-CCF %s
+// RUN: c-index-test -code-completion-at=%s:60:26 %s | FileCheck -check-prefix=CHECK-CCH %s
+// CHECK-CCH: ObjCInterfaceDecl:{TypedText A} (50)
+// CHECK-CCH: ObjCInterfaceDecl:{TypedText B} (50)
+// CHECK-CCH: NotImplemented:{TypedText bycopy} (40)
+// CHECK-CCH: NotImplemented:{TypedText byref} (40)
+// CHECK-CCH-NOT: NotImplemented:{TypedText in} (40)
+// CHECK-CCH: NotImplemented:{TypedText inout} (40)
+// CHECK-CCH: NotImplemented:{TypedText oneway} (40)
+// CHECK-CCH: NotImplemented:{TypedText out} (40)
+// CHECK-CCH: NotImplemented:{TypedText unsigned} (50)
+// CHECK-CCH: NotImplemented:{TypedText void} (50)
+// CHECK-CCH: NotImplemented:{TypedText volatile} (50)
+
+// IBAction completion
+// RUN: c-index-test -code-completion-at=%s:5:4 %s | FileCheck -check-prefix=CHECK-IBACTION %s
+// CHECK-IBACTION: NotImplemented:{TypedText IBAction}{RightParen )}{Placeholder selector}{Colon :}{LeftParen (}{Text id}{RightParen )}{Text sender} (40)
+
+// <rdar://problem/8939352>
+// RUN: c-index-test -code-completion-at=%s:68:9 %s | FileCheck -check-prefix=CHECK-8939352 %s
+// CHECK-8939352: ObjCInstanceMethodDecl:{TypedText method}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text y} (40)
+
+
+// RUN: c-index-test -code-completion-at=%s:72:2 %s | FileCheck -check-prefix=CHECK-ONEWAY %s
+// CHECK-ONEWAY: ObjCInstanceMethodDecl:{LeftParen (}{Text oneway }{Text void}{RightParen )}{TypedText method}{TypedText :}{LeftParen (}{Text in }{Text id}{RightParen )}{Text x} (40) (parent: ObjCInterfaceDecl 'Passing')
diff --git a/clang/test/Index/complete-modules.m b/clang/test/Index/complete-modules.m
new file mode 100644
index 0000000..b82430d
--- /dev/null
+++ b/clang/test/Index/complete-modules.m
@@ -0,0 +1,14 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+@__experimental_modules_import LibA.Extensions;
+
+// RUN: rm -rf %t
+// RUN: c-index-test -code-completion-at=%s:4:32 -fmodule-cache-path %t -fmodules -F %S/Inputs/Frameworks -I %S/Inputs/Headers %s | FileCheck -check-prefix=CHECK-TOP-LEVEL %s
+// CHECK-TOP-LEVEL: NotImplemented:{TypedText Framework} (50)
+// CHECK-TOP-LEVEL: NotImplemented:{TypedText LibA} (50)
+// CHECK-TOP-LEVEL: NotImplemented:{TypedText nested} (50)
+
+// RUN: c-index-test -code-completion-at=%s:4:37 -fmodule-cache-path %t -fmodules -F %S/Inputs/Frameworks -I %S/Inputs/Headers %s | FileCheck -check-prefix=CHECK-LIBA %s
+// CHECK-LIBA: NotImplemented:{TypedText Extensions} (50)
+
diff --git a/clang/test/Index/complete-natural.m b/clang/test/Index/complete-natural.m
new file mode 100644
index 0000000..326b8a7
--- /dev/null
+++ b/clang/test/Index/complete-natural.m
@@ -0,0 +1,57 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+const char *in_string = "string";
+char in_char = 'a';
+// in comment
+/* in comment */
+#warning blarg
+#error blarg
+#pragma mark this is the spot
+// RUN: c-index-test -code-completion-at=%s:4:32 %s > %t
+// RUN: echo "DONE" >> %t
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t
+// CHECK-CC1: Completion contexts:
+// CHECK-CC1-NEXT: Natural language
+// CHECK-CC1-NEXT: DONE
+// RUN: c-index-test -code-completion-at=%s:5:18 %s > %t
+// RUN: echo "DONE" >> %t
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t
+// RUN: c-index-test -code-completion-at=%s:6:7 %s > %t
+// RUN: echo "DONE" >> %t
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t
+// RUN: c-index-test -code-completion-at=%s:7:7 %s > %t
+// RUN: echo "DONE" >> %t
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t
+// RUN: c-index-test -code-completion-at=%s:8:10 %s > %t
+// RUN: echo "DONE" >> %t
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t
+// RUN: c-index-test -code-completion-at=%s:9:9 %s > %t
+// RUN: echo "DONE" >> %t
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t
+// RUN: c-index-test -code-completion-at=%s:10:19 %s > %t
+// RUN: echo "DONE" >> %t
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t
+
+// Same tests as above, but with completion caching.
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:4:32 %s > %t
+// RUN: echo "DONE" >> %t
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:5:18 %s > %t
+// RUN: echo "DONE" >> %t
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:6:7 %s > %t
+// RUN: echo "DONE" >> %t
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:7 %s > %t
+// RUN: echo "DONE" >> %t
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:8:10 %s > %t
+// RUN: echo "DONE" >> %t
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:9:9 %s > %t
+// RUN: echo "DONE" >> %t
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:10:19 %s > %t
+// RUN: echo "DONE" >> %t
+// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t
diff --git a/clang/test/Index/complete-objc-message-id.m b/clang/test/Index/complete-objc-message-id.m
new file mode 100644
index 0000000..415e0ff
--- /dev/null
+++ b/clang/test/Index/complete-objc-message-id.m
@@ -0,0 +1,74 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+@interface A
++ (id)alloc;
++ (id)init;
++ (id)new;
++ (Class)class;
++ (Class)superclass;
+- (id)retain;
+- (id)autorelease;
+- (id)superclass;
+@end
+
+@interface B : A
+- (int)B_method;
+@end
+
+@interface Unrelated
++ (id)icky;
+@end
+
+void message_id(B *b) {
+ [[A alloc] init];
+ [[b retain] B_method];
+ [[b superclass] B_method];
+}
+
+@implementation Unrelated
++ (id)alloc {
+ return [A alloc];
+}
+@end
+
+@protocol P1
+- (int)P1_method1;
++ (int)P1_method2;
+@end
+
+@protocol P2 <P1>
+- (int)P2_method1;
++ (int)P2_method2;
+@end
+
+void message_qualified_id(id<P2> ip2) {
+ [ip2 P1_method];
+ ip2 P1_method];
+}
+
+// RUN: c-index-test -code-completion-at=%s:24:14 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: ObjCInstanceMethodDecl:{ResultType id}{TypedText autorelease}
+// CHECK-CC1-NOT: B_method
+// CHECK-CC1: ObjCInstanceMethodDecl:{ResultType id}{TypedText retain}
+// RUN: c-index-test -code-completion-at=%s:25:15 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText autorelease}
+// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText B_method}
+// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText retain}
+// RUN: c-index-test -code-completion-at=%s:26:19 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: ObjCInstanceMethodDecl:{ResultType id}{TypedText autorelease}
+// CHECK-CC3-NOT: B_method
+// CHECK-CC3: ObjCInstanceMethodDecl:{ResultType id}{TypedText retain}
+
+
+// RUN: c-index-test -code-completion-at=%s:31:13 %s | FileCheck -check-prefix=CHECK-SELECTOR-PREF %s
+// CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType id}{TypedText alloc} (32)
+// CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType Class}{TypedText class} (35)
+// CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType id}{TypedText init} (35)
+// CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType id}{TypedText new} (35)
+// CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType Class}{TypedText superclass} (35)
+
+// RUN: c-index-test -code-completion-at=%s:46:7 %s | FileCheck -check-prefix=CHECK-INSTANCE-QUAL-ID %s
+// RUN: c-index-test -code-completion-at=%s:47:7 %s | FileCheck -check-prefix=CHECK-INSTANCE-QUAL-ID %s
+// CHECK-INSTANCE-QUAL-ID: ObjCInstanceMethodDecl:{ResultType int}{TypedText P1_method1} (37)
+// CHECK-INSTANCE-QUAL-ID: ObjCInstanceMethodDecl:{ResultType int}{TypedText P2_method1} (35)
diff --git a/clang/test/Index/complete-objc-message.m b/clang/test/Index/complete-objc-message.m
new file mode 100644
index 0000000..1835c3e
--- /dev/null
+++ b/clang/test/Index/complete-objc-message.m
@@ -0,0 +1,336 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+#define nil (void*)0
+@protocol FooTestProtocol
++ protocolClassMethod;
+- protocolInstanceMethod : (int)value;
+@end
+@interface Foo <FooTestProtocol> {
+ void *isa;
+}
++ (int)classMethod1:a withKeyword:(int)b;
++ (void)classMethod2;
++ new;
+- instanceMethod1;
+@end
+
+@interface Foo (FooTestCategory)
++ categoryClassMethod;
+- categoryInstanceMethod;
+@end
+
+void func() {
+ Foo *obj = [Foo new];
+ [obj xx];
+}
+
+@interface MyClass { }
++ (int)MyClassMethod:(id)obj;
+- (int)MyInstMethod:(id)x second:(id)y;
+@end
+
+@interface MySubClass : MyClass { }
++ (int)MySubClassMethod;
+- (int)MySubInstMethod;
+@end
+
+@implementation MyClass
++ (int)MyClassMethod:(id)obj {
+ return 0;
+}
+
++ (int)MyPrivateMethod {
+ return 1;
+}
+
+- (int)MyInstMethod:(id)x second:(id)y {
+ return 2;
+}
+
+- (int)MyPrivateInstMethod {
+ return 3;
+}
+@end
+MyClass *getMyClass();
+@implementation MySubClass
++ (int)MySubClassMethod {
+ return 2;
+}
+
++ (int)MySubPrivateMethod {
+ return [super MyPrivateMethod];
+}
+
+- (int)MySubInstMethod:(id)obj {
+ return [super MyInstMethod: obj second:obj];
+}
+
+- (int)MyInstMethod:(id)x second:(id)y {
+ return 3;
+}
+@end
+
+void test_super_var(MySubClass *super) {
+ [super MyInstMethod: super second:super];
+}
+
+@protocol FooTestProtocol2
+- (int)secondProtocolInstanceMethod;
+@end
+
+void test_qual_id(id<FooTestProtocol,FooTestProtocol2> ptr) {
+ [ptr protocolInstanceMethod:1];
+}
+
+@interface Overload
+- (int)Method:(int)i;
+- (int)Method;
+- (int)Method:(float)f Arg1:(int)i1 Arg2:(int)i2;
+- (int)Method:(float)f Arg1:(int)i1 OtherArg:(id)obj;
+- (int)Method:(float)f SomeArg:(int)i1 OtherArg:(id)obj;
+- (int)OtherMethod:(float)f Arg1:(int)i1 Arg2:(int)i2;
+@end
+
+void test_overload(Overload *ovl) {
+ [ovl Method:1 Arg1:1 OtherArg:ovl];
+}
+
+@interface Ellipsis
+- (int)Method:(int)i, ...;
+- (int)SentinelMethod:(int)i, ... __attribute__((sentinel(0,1)));
+@end
+void f(Ellipsis *e) {
+ [e Method:1, 2, 3];
+}
+
+@interface Overload2
++ (int)Method:(int)i;
++ (int)Method;
++ (int)Method:(float)f Arg1:(int)i1 Arg2:(int)i2;
++ (int)Method:(float)f Arg1:(int)i1 OtherArg:(id)obj;
++ (int)Method:(float)f SomeArg:(int)i1 OtherArg:(id)obj;
++ (int)OtherMethod:(float)f Arg1:(int)i1 Arg2:(int)i2;
+@end
+
+void test_overload2(void) {
+ [Overload2 Method:1 Arg1:1 OtherArg:ovl];
+}
+
+void msg_id(id x) {
+ [x Method:1 Arg1:1 OtherArg:ovl];
+ [[x blarg] Method:1 Arg1:1 OtherArg:ovl];
+ [id Method:1 Arg1:1 OtherArg:ovl];
+}
+
+@interface A
+- (void)method1;
+@end
+
+@interface B : A
+- (void)method2;
+@end
+
+void test_ranking(B *b) {
+ [b method1];
+ b method1];
+}
+
+void test_overload3(Overload *ovl) {
+ ovl Method:1 Arg1:1 OtherArg:ovl];
+ Overload2 Method:1 Arg1:1 OtherArg:ovl];
+ (Overload2 Method:1 Arg1:1 OtherArg:ovl]);
+}
+
+@interface C : B
+- (void)method2;
+- (void)method3;
+@end
+
+void test_redundancy(C *c) {
+ [c method2];
+};
+
+@protocol P
+- (Class)class;
+@end
+
+@interface A () <P>
+@end
+
+@interface A ()
++ (void)class_method3;
+@end
+
+@interface A (Cat)
++ (void)class_method4;
+@end
+
+@implementation A
+- (void)method5:(A*)a {
+ [[self class] class_method4];
+}
+@end
+
+void test_missing_open_more() {
+ A *a = A class_method3];
+}
+
+void test_block_invoke(A *(^block1)(int),
+ int (^block2)(int),
+ id (^block3)(int)) {
+ [block1(5) init];
+}
+
+@interface DO
+- (void)method:(in bycopy A*)ain result:(out byref A**)aout;
+@end
+
+void test_DO(DO *d, A* a) {
+ [d method:a aout:&a];
+}
+
+// RUN: c-index-test -code-completion-at=%s:23:19 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: {TypedText categoryClassMethod} (35) (parent: ObjCCategoryDecl 'Foo(FooTestCategory)')
+// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)}{HorizontalSpace }{TypedText withKeyword:}{Placeholder (int)} (35) (parent: ObjCInterfaceDecl 'Foo')
+// CHECK-CC1: {TypedText classMethod2} (35) (parent: ObjCInterfaceDecl 'Foo')
+// CHECK-CC1: {TypedText new} (35) (parent: ObjCInterfaceDecl 'Foo')
+// CHECK-CC1: {TypedText protocolClassMethod} (37) (parent: ObjCProtocolDecl 'FooTestProtocol')
+// CHECK-CC1: Completion contexts:
+// CHECK-CC1-NEXT: Objective-C class method
+// CHECK-CC1-NEXT: Container Kind: ObjCInterfaceDecl
+// CHECK-CC1-NEXT: Container is complete
+// CHECK-CC1-NEXT: Container USR: c:objc(cs)Foo
+// RUN: c-index-test -code-completion-at=%s:24:8 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: {TypedText categoryInstanceMethod}
+// CHECK-CC2: {TypedText instanceMethod1}
+// CHECK-CC2: {TypedText protocolInstanceMethod:}{Placeholder (int)}
+// CHECK-CC2: Completion contexts:
+// CHECK-CC2-NEXT: Objective-C instance method
+// CHECK-CC2-NEXT: Container Kind: ObjCInterfaceDecl
+// CHECK-CC2-NEXT: Container is complete
+// CHECK-CC2-NEXT: Container USR: c:objc(cs)Foo
+// RUN: c-index-test -code-completion-at=%s:61:16 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)}
+// CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod}
+// RUN: c-index-test -code-completion-at=%s:65:16 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)}{HorizontalSpace }{TypedText second:}{Placeholder (id)}
+// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod}
+// RUN: c-index-test -code-completion-at=%s:74:9 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)}{HorizontalSpace }{TypedText second:}{Placeholder (id)}
+// CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod}
+// RUN: c-index-test -code-completion-at=%s:82:8 %s | FileCheck -check-prefix=CHECK-CC6 %s
+// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)}
+// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType int}{TypedText secondProtocolInstanceMethod}
+// RUN: c-index-test -code-completion-at=%s:95:8 %s | FileCheck -check-prefix=CHECK-CC7 %s
+// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method}
+// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)}
+// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{TypedText Arg2:}{Placeholder (int)}
+// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{TypedText OtherArg:}{Placeholder (id)}
+// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{TypedText SomeArg:}{Placeholder (int)}{HorizontalSpace }{TypedText OtherArg:}{Placeholder (id)}
+// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)}{HorizontalSpace }{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{TypedText Arg2:}{Placeholder (int)}
+// RUN: c-index-test -code-completion-at=%s:95:17 %s | FileCheck -check-prefix=CHECK-CC8 %s
+// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{TypedText Arg2:}{Placeholder (int)}
+// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{TypedText OtherArg:}{Placeholder (id)}
+// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)}{HorizontalSpace }{TypedText OtherArg:}{Placeholder (id)}
+// CHECK-CC8-NOT: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText }
+// RUN: c-index-test -code-completion-at=%s:95:24 %s | FileCheck -check-prefix=CHECK-CC9 %s
+// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)}
+// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)}
+// CHECK-CC9: Objective-C selector: Method:Arg1:
+// RUN: c-index-test -code-completion-at=%s:61:11 %s | FileCheck -check-prefix=CHECK-CCA %s
+// CHECK-CCA: TypedefDecl:{TypedText Class}
+// CHECK-CCA-NEXT: ObjCInterfaceDecl:{TypedText Foo}
+// CHECK-CCA-NOT: FunctionDecl:{ResultType void}{TypedText func}{LeftParen (}{RightParen )}
+// CHECK-CCA:FunctionDecl:{ResultType MyClass *}{TypedText getMyClass}{LeftParen (}{RightParen )}
+// CHECK-CCA: TypedefDecl:{TypedText id}
+// CHECK-CCA: ObjCInterfaceDecl:{TypedText MyClass}
+// CHECK-CCA: ObjCInterfaceDecl:{TypedText MySubClass}
+// CHECK-CCA: {ResultType Class}{TypedText self}
+// CHECK-CCA: {TypedText super}
+// RUN: c-index-test -code-completion-at=%s:103:6 %s | FileCheck -check-prefix=CHECK-CCB %s
+// CHECK-CCB: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int), ...}
+// CHECK-CCB: ObjCInstanceMethodDecl:{ResultType int}{TypedText SentinelMethod:}{Placeholder (int), ...}{Text , nil}
+// RUN: c-index-test -code-completion-at=%s:116:14 %s | FileCheck -check-prefix=CHECK-CCC %s
+// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method}
+// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)}
+// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{TypedText Arg2:}{Placeholder (int)}
+// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{TypedText OtherArg:}{Placeholder (id)}
+// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{TypedText SomeArg:}{Placeholder (int)}{HorizontalSpace }{TypedText OtherArg:}{Placeholder (id)}
+// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)}{HorizontalSpace }{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{TypedText Arg2:}{Placeholder (int)}
+// RUN: c-index-test -code-completion-at=%s:116:23 %s | FileCheck -check-prefix=CHECK-CCD %s
+// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{TypedText Arg2:}{Placeholder (int)}
+// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{TypedText OtherArg:}{Placeholder (id)}
+// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)}{HorizontalSpace }{TypedText OtherArg:}{Placeholder (id)}
+// CHECK-CCD-NOT: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText }
+// CHECK-CCD: Objective-C selector: Method:
+// RUN: c-index-test -code-completion-at=%s:116:30 %s | FileCheck -check-prefix=CHECK-CCE %s
+// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)}
+// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)}
+// RUN: c-index-test -code-completion-at=%s:61:11 %s | FileCheck -check-prefix=CHECK-CCF %s
+// CHECK-CCF: TypedefDecl:{TypedText Class}
+// CHECK-CCF: ObjCInterfaceDecl:{TypedText Foo}
+// CHECK-CCF-NOT: FunctionDecl:{ResultType void}{TypedText func}{LeftParen (}{RightParen )}
+// CHECK-CCF: TypedefDecl:{TypedText id}
+// CHECK-CCF: ObjCInterfaceDecl:{TypedText MyClass}
+// CHECK-CCF: ObjCInterfaceDecl:{TypedText MySubClass}
+// CHECK-CCF: {ResultType Class}{TypedText self}
+// CHECK-CCF: {TypedText super}
+// RUN: c-index-test -code-completion-at=%s:120:6 %s | FileCheck -check-prefix=CHECK-CCG %s
+// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText categoryInstanceMethod}
+// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText instanceMethod1}
+// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method}
+// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)}{HorizontalSpace }{TypedText second:}{Placeholder (id)}
+// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod}
+// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod}
+// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)}
+// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText secondProtocolInstanceMethod}
+// RUN: c-index-test -code-completion-at=%s:121:14 %s | FileCheck -check-prefix=CHECK-CCG %s
+// RUN: c-index-test -code-completion-at=%s:122:7 %s | FileCheck -check-prefix=CHECK-CCH %s
+// CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText categoryClassMethod}
+// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod1:}{Placeholder (id)}{HorizontalSpace }{TypedText withKeyword:}{Placeholder (int)}
+// CHECK-CCH: ObjCClassMethodDecl:{ResultType void}{TypedText classMethod2}
+// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method}
+// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)}
+// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)}
+// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod}
+// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MySubClassMethod}
+// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MySubPrivateMethod}
+// CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText new}
+// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)}{HorizontalSpace }{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{TypedText Arg2:}{Placeholder (int)}
+// CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText protocolClassMethod}
+// RUN: c-index-test -code-completion-at=%s:134:6 %s | FileCheck -check-prefix=CHECK-CCI %s
+// CHECK-CCI: ObjCInstanceMethodDecl:{ResultType void}{TypedText method1} (37)
+// CHECK-CCI: ObjCInstanceMethodDecl:{ResultType void}{TypedText method2} (35)
+
+// RUN: c-index-test -code-completion-at=%s:150:5 %s | FileCheck -check-prefix=CHECK-REDUNDANT %s
+// CHECK-REDUNDANT: ObjCInstanceMethodDecl:{ResultType void}{TypedText method2} (35)
+// CHECK-REDUNDANT-NOT: ObjCInstanceMethodDecl:{ResultType void}{TypedText method2}
+// CHECK-REDUNDANT: ObjCInstanceMethodDecl:{ResultType void}{TypedText method3} (35)
+
+// RUN: c-index-test -code-completion-at=%s:170:16 %s | FileCheck -check-prefix=CHECK-CLASS-RESULT %s
+// CHECK-CLASS-RESULT: ObjCClassMethodDecl:{ResultType void}{TypedText class_method3} (35)
+// CHECK-CLASS-RESULT: ObjCClassMethodDecl:{ResultType void}{TypedText class_method4} (35) (parent: ObjCCategoryDecl 'A(Cat)')
+
+// RUN: c-index-test -code-completion-at=%s:181:4 %s | FileCheck -check-prefix=CHECK-BLOCK-RECEIVER %s
+// CHECK-BLOCK-RECEIVER: ObjCInterfaceDecl:{TypedText A} (50)
+// CHECK-BLOCK-RECEIVER: ObjCInterfaceDecl:{TypedText B} (50)
+// CHECK-BLOCK-RECEIVER: ParmDecl:{ResultType A *(^)(int)}{TypedText block1} (34)
+// CHECK-BLOCK-RECEIVER-NEXT: ParmDecl:{ResultType id (^)(int)}{TypedText block3} (34)
+
+// Test code completion with a missing opening bracket:
+// RUN: c-index-test -code-completion-at=%s:135:5 %s | FileCheck -check-prefix=CHECK-CCI %s
+// RUN: c-index-test -code-completion-at=%s:139:7 %s | FileCheck -check-prefix=CHECK-CC7 %s
+// RUN: c-index-test -code-completion-at=%s:139:16 %s | FileCheck -check-prefix=CHECK-CC8 %s
+// RUN: c-index-test -code-completion-at=%s:139:23 %s | FileCheck -check-prefix=CHECK-CC9 %s
+
+// RUN: c-index-test -code-completion-at=%s:140:14 %s | FileCheck -check-prefix=CHECK-CCC %s
+// RUN: c-index-test -code-completion-at=%s:140:23 %s | FileCheck -check-prefix=CHECK-CCD %s
+// RUN: c-index-test -code-completion-at=%s:140:30 %s | FileCheck -check-prefix=CHECK-CCE %s
+// RUN: c-index-test -code-completion-at=%s:141:14 %s | FileCheck -check-prefix=CHECK-CCC %s
+// RUN: c-index-test -code-completion-at=%s:141:23 %s | FileCheck -check-prefix=CHECK-CCD %s
+// RUN: c-index-test -code-completion-at=%s:141:30 %s | FileCheck -check-prefix=CHECK-CCE %s
+
+// RUN: c-index-test -code-completion-at=%s:175:12 %s | FileCheck -check-prefix=CHECK-CLASS-RESULT %s
+
+// RUN: c-index-test -code-completion-at=%s:189:6 %s | FileCheck -check-prefix=CHECK-DISTRIB-OBJECTS %s
+// CHECK-DISTRIB-OBJECTS: ObjCInstanceMethodDecl:{ResultType void}{TypedText method:}{Placeholder (in bycopy A *)}{HorizontalSpace }{TypedText result:}{Placeholder (out byref A **)} (35)
diff --git a/clang/test/Index/complete-pch.m b/clang/test/Index/complete-pch.m
new file mode 100644
index 0000000..517d49c
--- /dev/null
+++ b/clang/test/Index/complete-pch.m
@@ -0,0 +1,26 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+@interface C
+- (int)instanceMethod3:(int)x;
++ (int)classMethod3:(float)f;
+@end
+
+void msg_id(id x) {
+ [id classMethod1:1.0];
+ [x instanceMethod1:5];
+}
+
+// Build the precompiled header
+// RUN: %clang -x objective-c-header -o %t.h.pch %S/Inputs/complete-pch.h
+
+// Run the actual tests
+// RUN: c-index-test -code-completion-at=%s:10:7 -include %t.h %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod1:}{Placeholder (double)}
+// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod2:}{Placeholder (float)}
+// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod3:}{Placeholder (float)}
+
+// RUN: c-index-test -code-completion-at=%s:11:6 -include %t.h %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod1:}{Placeholder (int)}
+// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod2:}{Placeholder (int)}
+// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod3:}{Placeholder (int)}
diff --git a/clang/test/Index/complete-preprocessor.m b/clang/test/Index/complete-preprocessor.m
new file mode 100644
index 0000000..bea9d32
--- /dev/null
+++ b/clang/test/Index/complete-preprocessor.m
@@ -0,0 +1,80 @@
+// The line and column layout of this test is significant. Run lines
+// are at the end.
+
+#if 1
+#endif
+
+#define FOO(a, b) a##b
+#define BAR
+#ifdef FOO
+#endif
+#if defined(FOO)
+#endif
+
+FOO(in,t) value;
+
+// RUN: c-index-test -code-completion-at=%s:4:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: NotImplemented:{TypedText define}{HorizontalSpace }{Placeholder macro} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText define}{HorizontalSpace }{Placeholder macro}{LeftParen (}{Placeholder args}{RightParen )} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText error}{HorizontalSpace }{Placeholder message} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText if}{HorizontalSpace }{Placeholder condition} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText ifdef}{HorizontalSpace }{Placeholder macro} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText ifndef}{HorizontalSpace }{Placeholder macro} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText import}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText import}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText include}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText include}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText include_next}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText include_next}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText line}{HorizontalSpace }{Placeholder number} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText line}{HorizontalSpace }{Placeholder number}{HorizontalSpace }{Text "}{Placeholder filename}{Text "} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText pragma}{HorizontalSpace }{Placeholder arguments} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText undef}{HorizontalSpace }{Placeholder macro} (40)
+// CHECK-CC1-NEXT: NotImplemented:{TypedText warning}{HorizontalSpace }{Placeholder message} (40)
+// RUN: c-index-test -code-completion-at=%s:5:2 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: NotImplemented:{TypedText define}{HorizontalSpace }{Placeholder macro} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText define}{HorizontalSpace }{Placeholder macro}{LeftParen (}{Placeholder args}{RightParen )} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText elif}{HorizontalSpace }{Placeholder condition} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText else} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText endif} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText error}{HorizontalSpace }{Placeholder message} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText if}{HorizontalSpace }{Placeholder condition} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText ifdef}{HorizontalSpace }{Placeholder macro} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText ifndef}{HorizontalSpace }{Placeholder macro} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText import}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText import}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText include}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText include}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText include_next}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText include_next}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText line}{HorizontalSpace }{Placeholder number} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText line}{HorizontalSpace }{Placeholder number}{HorizontalSpace }{Text "}{Placeholder filename}{Text "} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText pragma}{HorizontalSpace }{Placeholder arguments} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText undef}{HorizontalSpace }{Placeholder macro} (40)
+// CHECK-CC2-NEXT: NotImplemented:{TypedText warning}{HorizontalSpace }{Placeholder message} (40)
+// RUN: c-index-test -code-completion-at=%s:9:8 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: NotImplemented:{TypedText BAR} (40)
+// CHECK-CC3: NotImplemented:{TypedText FOO} (40)
+// RUN: c-index-test -code-completion-at=%s:11:12 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: c-index-test -code-completion-at=%s:11:13 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: c-index-test -code-completion-at=%s:11:5 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: macro definition:{TypedText BAR} (70)
+// CHECK-CC4: macro definition:{TypedText FOO}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (70)
+// RUN: c-index-test -code-completion-at=%s:14:5 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: NotImplemented:{TypedText const} (50)
+// CHECK-CC5: NotImplemented:{TypedText double} (50)
+// CHECK-CC5: NotImplemented:{TypedText enum} (50)
+// CHECK-CC5: NotImplemented:{TypedText extern} (40)
+// CHECK-CC5: NotImplemented:{TypedText float} (50)
+// CHECK-CC5: macro definition:{TypedText FOO}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (70)
+// CHECK-CC5: TypedefDecl:{TypedText id} (50)
+// CHECK-CC5: NotImplemented:{TypedText inline} (40)
+// CHECK-CC5: NotImplemented:{TypedText int} (50)
+// CHECK-CC5: NotImplemented:{TypedText long} (50)
+
+// Same tests as above, but with completion caching.
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:4:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:5:2 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:9:8 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:11:5 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:5 %s | FileCheck -check-prefix=CHECK-CC5 %s
diff --git a/clang/test/Index/complete-properties.m b/clang/test/Index/complete-properties.m
new file mode 100644
index 0000000..ce1870e
--- /dev/null
+++ b/clang/test/Index/complete-properties.m
@@ -0,0 +1,82 @@
+/* Note: the RUN lines are near the end of the file, since line/column
+ matter for this test. */
+@class MyClass;
+@interface I1
+{
+ id StoredProp3;
+ int RandomIVar;
+}
+@property int Prop0;
+@property int Prop1;
+@property float Prop2;
+@end
+
+@interface I2 : I1
+@property id Prop3;
+@property id Prop4;
+@end
+
+@implementation I2
+@synthesize Prop2, Prop1, Prop3 = StoredProp3;
+@dynamic Prop4;
+@end
+
+@interface I3 : I2
+@property id Prop3;
+@end
+
+id test(I3 *i3) {
+ return i3.Prop3;
+}
+
+@interface I4
+@property id Prop2;
+@end
+
+@interface I4 () {
+ I4 *Prop1;
+}
+@end
+
+@implementation I4 {
+ id Prop2_;
+}
+
+@synthesize Prop2 = Prop2_;
+@end
+
+// RUN: c-index-test -code-completion-at=%s:20:13 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: ObjCPropertyDecl:{ResultType int}{TypedText Prop0}
+// CHECK-CC1: ObjCPropertyDecl:{ResultType int}{TypedText Prop1}
+// CHECK-CC1: ObjCPropertyDecl:{ResultType float}{TypedText Prop2}
+// CHECK-CC1: ObjCPropertyDecl:{ResultType id}{TypedText Prop3}
+// CHECK-CC1: ObjCPropertyDecl:{ResultType id}{TypedText Prop4}
+// RUN: c-index-test -code-completion-at=%s:20:20 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: ObjCPropertyDecl:{ResultType int}{TypedText Prop0}
+// CHECK-CC2: ObjCPropertyDecl:{ResultType int}{TypedText Prop1}
+// CHECK-CC2-NEXT: ObjCPropertyDecl:{ResultType id}{TypedText Prop3}
+// CHECK-CC2: ObjCPropertyDecl:{ResultType id}{TypedText Prop4}
+// RUN: c-index-test -code-completion-at=%s:20:35 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: ObjCIvarDecl:{ResultType id}{TypedText _Prop3} (36)
+// CHECK-CC3: ObjCIvarDecl:{ResultType int}{TypedText RandomIVar} (35)
+// CHECK-CC3: ObjCIvarDecl:{ResultType id}{TypedText StoredProp3} (8)
+
+// RUN: c-index-test -code-completion-at=%s:21:10 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: ObjCPropertyDecl:{ResultType int}{TypedText Prop0}
+// CHECK-CC4-NEXT: ObjCPropertyDecl:{ResultType id}{TypedText Prop4}
+
+// RUN: c-index-test -code-completion-at=%s:29:13 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: ObjCPropertyDecl:{ResultType int}{TypedText Prop0} (35)
+// CHECK-CC5-NEXT: ObjCPropertyDecl:{ResultType int}{TypedText Prop1} (35)
+// CHECK-CC5-NEXT: ObjCPropertyDecl:{ResultType float}{TypedText Prop2} (35)
+// CHECK-CC5-NEXT: ObjCPropertyDecl:{ResultType id}{TypedText Prop3} (35)
+// CHECK-CC5-NEXT: ObjCPropertyDecl:{ResultType id}{TypedText Prop4} (35)
+
+// RUN: c-index-test -code-completion-at=%s:9:11 %s | FileCheck -check-prefix=CHECK-CC6 %s
+// CHECK-CC6: ObjCInterfaceDecl:{TypedText MyClass} (50)
+
+
+// RUN: c-index-test -code-completion-at=%s:45:21 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-CC7 %s
+// CHECK-CC7-NOT: ObjCIvarDecl:{ResultType id}{TypedText _Prop2}
+// CHECK-CC7: ObjCIvarDecl:{ResultType I4 *}{TypedText Prop1} (17)
+// CHECK-CC7: ObjCIvarDecl:{ResultType id}{TypedText Prop2_} (7)
diff --git a/clang/test/Index/complete-property-flags.m b/clang/test/Index/complete-property-flags.m
new file mode 100644
index 0000000..f2e08c3
--- /dev/null
+++ b/clang/test/Index/complete-property-flags.m
@@ -0,0 +1,26 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+@interface Foo {
+ void *isa;
+}
+@property(copy) Foo *myprop;
+@property(retain, nonatomic) id xx;
+// RUN: c-index-test -code-completion-at=%s:7:11 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: {TypedText assign}
+// CHECK-CC1-NEXT: {TypedText atomic}
+// CHECK-CC1-NEXT: {TypedText copy}
+// CHECK-CC1-NEXT: {TypedText getter}{Text = }{Placeholder method}
+// CHECK-CC1-NEXT: {TypedText nonatomic}
+// CHECK-CC1-NEXT: {TypedText readonly}
+// CHECK-CC1-NEXT: {TypedText readwrite}
+// CHECK-CC1-NEXT: {TypedText retain}
+// CHECK-CC1-NEXT: {TypedText setter}{Text = }{Placeholder method}
+// CHECK-CC1-NEXT: {TypedText strong}
+// CHECK-CC1-NEXT: {TypedText unsafe_unretained}
+// RUN: c-index-test -code-completion-at=%s:8:18 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: {TypedText getter}{Text = }{Placeholder method}
+// CHECK-CC2-NEXT: {TypedText nonatomic}
+// CHECK-CC2-NEXT: {TypedText readwrite}
+// CHECK-CC2-NEXT: {TypedText setter}{Text = }{Placeholder method}
+@end
diff --git a/clang/test/Index/complete-property-getset.m b/clang/test/Index/complete-property-getset.m
new file mode 100644
index 0000000..f4424ce
--- /dev/null
+++ b/clang/test/Index/complete-property-getset.m
@@ -0,0 +1,41 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+@interface Super { }
+- (int)getter1;
++ (int)getter2_not_instance;
+- (int)getter2_not:(int)x;
+- (int)getter3;
+- (void)setter1:(int)x;
++ (void)setter2_not_inst:(int)x;
++ (void)setter2_many_args:(int)x second:(int)y;
+- (void)setter3:(int)y;
+@property (getter = getter1, setter = setter1:) int blah;
+@end
+
+@interface Sub : Super { }
+- (int)getter4;
+- (void)setter4:(int)x;
+@property (getter = getter4, setter = setter1:) int blarg;
+@end
+
+// RUN: c-index-test -code-completion-at=%s:13:21 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: ObjCInstanceMethodDecl:{ResultType int}{TypedText getter1}
+// CHECK-CC1-NOT: getter2
+// CHECK-CC1: ObjCInstanceMethodDecl:{ResultType int}{TypedText getter3}
+// RUN: c-index-test -code-completion-at=%s:13:39 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText getter2_not:}
+// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType void}{TypedText setter1:}
+// CHECK-CC2-NOT: setter2
+// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType void}{TypedText setter3:}
+// RUN: c-index-test -code-completion-at=%s:19:21 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: ObjCInstanceMethodDecl:{ResultType int}{TypedText getter1}
+// CHECK-CC3-NOT: getter2
+// CHECK-CC3: ObjCInstanceMethodDecl:{ResultType int}{TypedText getter3}
+// CHECK-CC3: ObjCInstanceMethodDecl:{ResultType int}{TypedText getter4}
+// RUN: c-index-test -code-completion-at=%s:19:39 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText getter2_not:}{Informative (int)x}
+// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType void}{TypedText setter1:}{Informative (int)x}
+// CHECK-CC4-NOT: setter2
+// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType void}{TypedText setter3:}{Informative (int)y}
+// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType void}{TypedText setter4:}{Informative (int)x}
diff --git a/clang/test/Index/complete-protocols.m b/clang/test/Index/complete-protocols.m
new file mode 100644
index 0000000..6af0198
--- /dev/null
+++ b/clang/test/Index/complete-protocols.m
@@ -0,0 +1,27 @@
+/* Note: the RUN lines are near the end of the file, since line/column
+ matter for this test. */
+
+@protocol Protocol1
+@end
+
+@protocol Protocol2;
+
+void f(id<Protocol1,Protocol2>);
+
+@protocol Protocol0;
+@protocol NewProtocol
+{
+}
+@end
+
+// RUN: c-index-test -code-completion-at=%s:9:11 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: ObjCProtocolDecl:{TypedText Protocol1}
+// CHECK-CC1-NEXT: ObjCProtocolDecl:{TypedText Protocol2}
+// RUN: c-index-test -code-completion-at=%s:9:21 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2-NOT: ObjCProtocolDecl:{TypedText Protocol1}
+// CHECK-CC2: ObjCProtocolDecl:{TypedText Protocol2}
+// RUN: c-index-test -code-completion-at=%s:12:11 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: ObjCProtocolDecl:{TypedText Protocol0}
+// CHECK-CC3-NEXT: ObjCProtocolDecl:{TypedText Protocol2}
+
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:9:11 %s | FileCheck -check-prefix=CHECK-CC1 %s
diff --git a/clang/test/Index/complete-qualified.cpp b/clang/test/Index/complete-qualified.cpp
new file mode 100644
index 0000000..f5c032c
--- /dev/null
+++ b/clang/test/Index/complete-qualified.cpp
@@ -0,0 +1,20 @@
+template <typename X, typename Y>
+class C
+{
+};
+
+class Foo
+{
+public:
+ C<Foo, class Bar> c;
+};
+
+void foo()
+{
+ Foo::
+
+// RUN: c-index-test -code-completion-at=%s:14:8 %s -o - | FileCheck -check-prefix=CC1 %s
+// CHECK-CC1: FieldDecl:{ResultType C<Foo, class Bar>}{TypedText c} (35) (parent: ClassDecl 'Foo')
+// CHECK-CC1: ClassDecl:{TypedText Foo} (35) (parent: ClassDecl 'Foo')
+// CHECK-CC1: CXXMethod:{ResultType Foo &}{TypedText operator=}{LeftParen (}{Placeholder const Foo &}{RightParen )} (35) (parent: ClassDecl 'Foo')
+// CHECK-CC1: CXXDestructor:{ResultType void}{TypedText ~Foo}{LeftParen (}{RightParen )} (35) (parent: ClassDecl 'Foo')
diff --git a/clang/test/Index/complete-recovery.m b/clang/test/Index/complete-recovery.m
new file mode 100644
index 0000000..19de0fb
--- /dev/null
+++ b/clang/test/Index/complete-recovery.m
@@ -0,0 +1,38 @@
+/* Run lines are at the end, since line/column matter in this test. */
+
+@interface A
+- (void)method:(int)x;
+@end
+
+@implementation A
+- (void)method:(int)x {
+ A *a = [A method:1];
+ blarg * blah = wibble;
+ A *a2;
+ z = [a2 method:1];
+ blah ? blech : [a2 method:1];
+ (a * a2)([a2 method:1]);
+ B *a = [a2 method:1];
+}
+@end
+
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:9:20 %s 2>%t | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: not grep error %t
+// CHECK-CC1: NotImplemented:{ResultType char[]}{TypedText @encode}{LeftParen (}{Placeholder type-name}{RightParen )}
+// CHECK-CC1-NOT: NotImplemented:{TypedText _Bool}
+// CHECK-CC1: VarDecl:{ResultType A *}{TypedText a}
+// CHECK-CC1: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )}
+
+// Test case for fix comitted in r145441.
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:9:20 %s -fms-compatibility | FileCheck -check-prefix=CHECK-CC1 %s
+
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:10:24 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: NotImplemented:{ResultType char[]}{TypedText @encode}{LeftParen (}{Placeholder type-name}{RightParen )}
+// CHECK-CC2: NotImplemented:{TypedText _Bool}
+// CHECK-CC2: VarDecl:{ResultType A *}{TypedText a}
+// CHECK-CC2: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )}
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:12:11 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: ObjCInstanceMethodDecl:{ResultType void}{TypedText method:}{Placeholder (int)} (32)
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:13:22 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:14:16 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:15:14 %s | FileCheck -check-prefix=CHECK-CC3 %s
diff --git a/clang/test/Index/complete-stmt.c b/clang/test/Index/complete-stmt.c
new file mode 100644
index 0000000..e39431e
--- /dev/null
+++ b/clang/test/Index/complete-stmt.c
@@ -0,0 +1,16 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+
+void f(int x) {
+ if (x) {
+ }
+}
+
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:7:4 %s | FileCheck -check-prefix=CHECK-IF-ELSE %s
+// CHECK-IF-ELSE: NotImplemented:{TypedText else}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Placeholder statements}{VerticalSpace }{RightBrace }} (40)
+// CHECK-IF-ELSE: NotImplemented:{TypedText else}{HorizontalSpace }{Text if}{HorizontalSpace }{LeftParen (}{Placeholder expression}{RightParen )}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Placeholder statements}{VerticalSpace }{RightBrace }} (40)
+
+// RUN: c-index-test -code-completion-at=%s:7:4 %s | FileCheck -check-prefix=CHECK-IF-ELSE-SIMPLE %s
+// CHECK-IF-ELSE-SIMPLE: NotImplemented:{TypedText else} (40)
+// CHECK-IF-ELSE-SIMPLE: NotImplemented:{TypedText else}{HorizontalSpace }{Text if}{HorizontalSpace }{LeftParen (}{Placeholder expression}{RightParen )} (40)
diff --git a/clang/test/Index/complete-super.cpp b/clang/test/Index/complete-super.cpp
new file mode 100644
index 0000000..9ffa7c8
--- /dev/null
+++ b/clang/test/Index/complete-super.cpp
@@ -0,0 +1,42 @@
+// The run lines are below, because this test is line- and
+// column-number sensitive.
+
+struct A {
+ virtual void foo(int x, int y);
+ virtual void bar(double x);
+ virtual void bar(float x);
+};
+
+struct B : A {
+ void foo(int a, int b);
+ void bar(float real);
+};
+
+void B::foo(int a, int b) {
+ A::foo(a, b);
+}
+
+void B::bar(float real) {
+ A::bar(real);
+}
+
+// RUN: c-index-test -code-completion-at=%s:16:3 %s | FileCheck -check-prefix=CHECK-FOO-UNQUAL %s
+// CHECK-FOO-UNQUAL: CXXMethod:{Text A::}{TypedText foo}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (20)
+
+// RUN: c-index-test -code-completion-at=%s:20:3 %s | FileCheck -check-prefix=CHECK-BAR-UNQUAL %s
+// CHECK-BAR-UNQUAL: CXXMethod:{Text A::}{TypedText bar}{LeftParen (}{Placeholder real}{RightParen )} (20)
+// CHECK-BAR-UNQUAL: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{Placeholder float real}{RightParen )} (34)
+// CHECK-BAR-UNQUAL: CXXMethod:{ResultType void}{Text A::}{TypedText bar}{LeftParen (}{Placeholder double x}{RightParen )} (36)
+
+// RUN: c-index-test -code-completion-at=%s:16:6 %s | FileCheck -check-prefix=CHECK-FOO-QUAL %s
+// CHECK-FOO-QUAL: CXXMethod:{TypedText foo}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (20)
+
+// RUN: c-index-test -code-completion-at=%s:5:1 %s | FileCheck -check-prefix=CHECK-ACCESS %s
+// CHECK-ACCESS: NotImplemented:{TypedText private} (40)
+// CHECK-ACCESS: NotImplemented:{TypedText protected} (40)
+// CHECK-ACCESS: NotImplemented:{TypedText public} (40)
+
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:5:1 %s | FileCheck -check-prefix=CHECK-ACCESS-PATTERN %s
+// CHECK-ACCESS-PATTERN: NotImplemented:{TypedText private}{Colon :} (40)
+// CHECK-ACCESS-PATTERN: NotImplemented:{TypedText protected}{Colon :} (40)
+// CHECK-ACCESS-PATTERN: NotImplemented:{TypedText public}{Colon :} (40)
diff --git a/clang/test/Index/complete-super.m b/clang/test/Index/complete-super.m
new file mode 100644
index 0000000..6c2daa8
--- /dev/null
+++ b/clang/test/Index/complete-super.m
@@ -0,0 +1,81 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+typedef int Bool;
+
+@interface A
+- (void)add:(int)x to:(int)y;
++ (void)select:(Bool)condition first:(int)x second:(int)y;
+- (void)last;
++ (void)last;
+@end
+
+@interface B : A
+- (void)add:(int)x to:(int)y;
++ (void)select:(Bool)condition first:(int)x second:(int)y;
+@end
+
+@implementation B
+- (void)add:(int)a to:(int)b {
+ [super add:a to:b];
+}
+
++ (void)select:(Bool)condition first:(int)a second:(int)b {
+ [super selector:condition first:a second:b];
+ super selector:condition first:a second:b];
+}
+@end
+
+@interface A (Cat)
+- (void)multiply:(int)x by:(int)y;
+@end
+
+@interface C : A
+@end
+
+@implementation C
+- (void)multiply:(int)a by:(int)b {
+ [super multiply:a by:b];
+}
+@end
+
+// Check "super" completion as a message receiver.
+// RUN: c-index-test -code-completion-at=%s:20:4 %s | FileCheck -check-prefix=CHECK-ADD-RECEIVER %s
+// CHECK-ADD-RECEIVER: ObjCInstanceMethodDecl:{ResultType void}{TypedText super}{HorizontalSpace }{Text add:}{Placeholder a}{HorizontalSpace }{Text to:}{Placeholder b} (20)
+
+// RUN: c-index-test -code-completion-at=%s:24:4 %s | FileCheck -check-prefix=CHECK-SELECT-RECEIVER %s
+// CHECK-SELECT-RECEIVER: ObjCClassMethodDecl:{ResultType void}{TypedText super}{HorizontalSpace }{Text select:}{Placeholder condition}{HorizontalSpace }{Text first:}{Placeholder a}{HorizontalSpace }{Text second:}{Placeholder b} (20)
+
+// Check "super" completion at the first identifier
+// RUN: c-index-test -code-completion-at=%s:20:10 %s | FileCheck -check-prefix=CHECK-ADD-ADD %s
+// CHECK-ADD-ADD: ObjCInstanceMethodDecl:{ResultType void}{TypedText add:}{Placeholder a}{HorizontalSpace }{Text to:}{Placeholder b} (20)
+// CHECK-ADD-ADD-NOT: add
+// CHECK-ADD-ADD: ObjCInstanceMethodDecl:{ResultType void}{TypedText last} (35)
+
+// RUN: c-index-test -code-completion-at=%s:24:10 %s | FileCheck -check-prefix=CHECK-SELECTOR-SELECTOR %s
+// CHECK-SELECTOR-SELECTOR-NOT: x
+// CHECK-SELECTOR-SELECTOR: ObjCClassMethodDecl:{ResultType void}{TypedText last} (35)
+// CHECK-SELECTOR-SELECTOR: ObjCClassMethodDecl:{ResultType void}{TypedText select:}{Placeholder condition}{HorizontalSpace }{Text first:}{Placeholder a}{HorizontalSpace }{Text second:}{Placeholder b} (20)
+
+// Check "super" completion at the second identifier
+// RUN: c-index-test -code-completion-at=%s:20:16 %s | FileCheck -check-prefix=CHECK-ADD-TO %s
+// CHECK-ADD-TO: ObjCInstanceMethodDecl:{ResultType void}{Informative add:}{TypedText to:}{Placeholder b} (20)
+
+// RUN: c-index-test -code-completion-at=%s:24:28 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s
+// CHECK-SELECTOR-FIRST: ObjCClassMethodDecl:{ResultType void}{Informative select:}{TypedText first:}{Placeholder a}{HorizontalSpace }{Text second:}{Placeholder b} (20)
+
+// Check "super" completion at the third identifier
+// RUN: c-index-test -code-completion-at=%s:24:37 %s | FileCheck -check-prefix=CHECK-SELECTOR-SECOND %s
+// CHECK-SELECTOR-SECOND: ObjCClassMethodDecl:{ResultType void}{Informative select:}{Informative first:}{TypedText second:}{Placeholder b} (20)
+
+// Check "super" completion with missing '['.
+// RUN: c-index-test -code-completion-at=%s:25:10 %s | FileCheck -check-prefix=CHECK-SELECTOR-SELECTOR %s
+// RUN: c-index-test -code-completion-at=%s:25:28 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s
+// RUN: c-index-test -code-completion-at=%s:25:37 %s | FileCheck -check-prefix=CHECK-SELECTOR-SECOND %s
+
+// Check "super" completion for a method declared in a category.
+// RUN: c-index-test -code-completion-at=%s:38:10 %s | FileCheck -check-prefix=CHECK-IN-CATEGORY %s
+// CHECK-IN-CATEGORY: ObjCInstanceMethodDecl:{ResultType void}{TypedText add:}{Placeholder (int)}{HorizontalSpace }{TypedText to:}{Placeholder (int)} (35)
+// CHECK-IN-CATEGORY: ObjCInstanceMethodDecl:{ResultType void}{TypedText last} (35)
+// CHECK-IN-CATEGORY: ObjCInstanceMethodDecl:{ResultType void}{TypedText multiply:}{Placeholder a}{HorizontalSpace }{Text by:}{Placeholder b} (20)
+
diff --git a/clang/test/Index/complete-synthesized.m b/clang/test/Index/complete-synthesized.m
new file mode 100644
index 0000000..8c848fc
--- /dev/null
+++ b/clang/test/Index/complete-synthesized.m
@@ -0,0 +1,46 @@
+// Note: this test is line- and column-sensitive. Test commands are at
+// the end.
+
+
+@interface A
+@property int prop1;
+@end
+
+@interface B : A {
+ float _prop2;
+}
+@property float prop2;
+@property short prop3;
+@end
+
+@interface B ()
+@property double prop4;
+@end
+
+@implementation B
+@synthesize prop2 = _prop2;
+
+- (int)method {
+ return _prop2;
+}
+
+@dynamic prop3;
+
+- (short)method2 {
+ return _prop4;
+}
+
+- (short)method3 {
+ return prop3;
+}
+@end
+
+// RUN: c-index-test -code-completion-at=%s:24:1 -target x86_64-apple-macosx10.7 -fobjc-nonfragile-abi %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:30:2 -target x86_64-apple-macosx10.7 -fobjc-nonfragile-abi %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:34:2 -target x86_64-apple-macosx10.7 -fobjc-nonfragile-abi %s | FileCheck %s
+
+// CHECK: NotImplemented:{TypedText _Bool} (50)
+// CHECK: ObjCIvarDecl:{ResultType float}{TypedText _prop2} (35)
+// CHECK-NOT: prop2
+// CHECK-NOT: prop3
+// CHECK: ObjCIvarDecl:{ResultType double}{TypedText _prop4} (35)
diff --git a/clang/test/Index/complete-tabs.c b/clang/test/Index/complete-tabs.c
new file mode 100644
index 0000000..f3313bf
--- /dev/null
+++ b/clang/test/Index/complete-tabs.c
@@ -0,0 +1,9 @@
+// Test code-completion in the presence of tabs
+struct Point { int x, y; };
+
+void f(struct Point *p) {
+ p->
+
+// RUN: c-index-test -code-completion-at=%s:5:5 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: {TypedText x}
+// CHECK-CC1: {TypedText y}
diff --git a/clang/test/Index/complete-templates.cpp b/clang/test/Index/complete-templates.cpp
new file mode 100644
index 0000000..d2279b1
--- /dev/null
+++ b/clang/test/Index/complete-templates.cpp
@@ -0,0 +1,19 @@
+// Tests are line- and column-sensive, so run lines are below.
+
+template<typename T>
+class X {
+ X();
+ X(const X&);
+
+ template<typename U> X(U);
+};
+
+template<typename T> void f(T);
+
+void test() {
+
+}
+
+// RUN: c-index-test -code-completion-at=%s:14:2 %s | FileCheck %s
+// CHECK: FunctionTemplate:{ResultType void}{TypedText f}{LeftParen (}{Placeholder T}{RightParen )} (50)
+// CHECK: ClassTemplate:{TypedText X}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
diff --git a/clang/test/Index/complete-type-factors.m b/clang/test/Index/complete-type-factors.m
new file mode 100644
index 0000000..e5aa893
--- /dev/null
+++ b/clang/test/Index/complete-type-factors.m
@@ -0,0 +1,137 @@
+/* Run lines are at the end, since line/column matter in this test. */
+
+enum Color {
+ Red, Green, Blue
+};
+
+enum Priority {
+ Low,
+ High
+};
+
+int func1(enum Color);
+enum Priority func2(int);
+void func3(float);
+enum Priority test1(enum Priority priority, enum Color color, int integer) {
+ int i = integer;
+ enum Color c = color;
+ return priority;
+ func1(c);
+ void (^block)(enum Color, int);
+ block(c, 17);
+ c = color;
+}
+
+@interface A
++ (void)method:(enum Color)color priority:(enum Priority)priority;
+- (void)method:(enum Color)color priority:(enum Priority)priority;
+@end
+
+void test2(A *a) {
+ [a method:Red priority:High];
+ [A method:Red priority:Low];
+}
+
+// RUN: c-index-test -code-completion-at=%s:16:11 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: EnumConstantDecl:{ResultType enum Color}{TypedText Blue} (32)
+// CHECK-CC1: ParmDecl:{ResultType enum Color}{TypedText color} (17)
+// CHECK-CC1: FunctionDecl:{ResultType int}{TypedText func1}{LeftParen (}{Placeholder enum Color}{RightParen )} (12)
+// CHECK-CC1: FunctionDecl:{ResultType enum Priority}{TypedText func2}{LeftParen (}{Placeholder int}{RightParen )} (25)
+// CHECK-CC1: EnumConstantDecl:{ResultType enum Color}{TypedText Green} (32)
+// CHECK-CC1: EnumConstantDecl:{ResultType enum Priority}{TypedText High} (32)
+// CHECK-CC1: VarDecl:{ResultType int}{TypedText i} (8)
+// CHECK-CC1: ParmDecl:{ResultType int}{TypedText integer} (8)
+// CHECK-CC1: EnumConstantDecl:{ResultType enum Priority}{TypedText Low} (32)
+// CHECK-CC1: ParmDecl:{ResultType enum Priority}{TypedText priority} (17)
+// CHECK-CC1: EnumConstantDecl:{ResultType enum Color}{TypedText Red} (32)
+// CHECK-CC1: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// CHECK-CC1: FunctionDecl:{ResultType enum Priority}{TypedText test1}{LeftParen (}{Placeholder enum Priority priority}{Comma , }{Placeholder enum Color color}{Comma , }{Placeholder int integer}{RightParen )} (25)
+// RUN: c-index-test -code-completion-at=%s:17:18 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: EnumConstantDecl:{ResultType enum Color}{TypedText Blue} (16)
+// CHECK-CC2: VarDecl:{ResultType enum Color}{TypedText c} (8)
+// CHECK-CC2: ParmDecl:{ResultType enum Color}{TypedText color} (8)
+// CHECK-CC2: FunctionDecl:{ResultType int}{TypedText func1}{LeftParen (}{Placeholder enum Color}{RightParen )} (25)
+// CHECK-CC2: FunctionDecl:{ResultType enum Priority}{TypedText func2}{LeftParen (}{Placeholder int}{RightParen )} (50)
+// CHECK-CC2: EnumConstantDecl:{ResultType enum Color}{TypedText Green} (16)
+// CHECK-CC2: EnumConstantDecl:{ResultType enum Priority}{TypedText High} (65)
+// CHECK-CC2: VarDecl:{ResultType int}{TypedText i} (17)
+// CHECK-CC2: ParmDecl:{ResultType int}{TypedText integer} (17)
+// CHECK-CC2: EnumConstantDecl:{ResultType enum Priority}{TypedText Low} (65)
+// CHECK-CC2: ParmDecl:{ResultType enum Priority}{TypedText priority} (34)
+// CHECK-CC2: EnumConstantDecl:{ResultType enum Color}{TypedText Red} (16)
+// CHECK-CC2: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// CHECK-CC2: FunctionDecl:{ResultType enum Priority}{TypedText test1}{LeftParen (}{Placeholder enum Priority priority}{Comma , }{Placeholder enum Color color}{Comma , }{Placeholder int integer}{RightParen )} (50)
+// RUN: c-index-test -code-completion-at=%s:18:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: EnumConstantDecl:{ResultType enum Color}{TypedText Blue} (65)
+// CHECK-CC3: VarDecl:{ResultType enum Color}{TypedText c} (34)
+// CHECK-CC3: ParmDecl:{ResultType enum Color}{TypedText color} (34)
+// CHECK-CC3: FunctionDecl:{ResultType int}{TypedText func1}{LeftParen (}{Placeholder enum Color}{RightParen )} (25)
+// CHECK-CC3: FunctionDecl:{ResultType enum Priority}{TypedText func2}{LeftParen (}{Placeholder int}{RightParen )} (12)
+// CHECK-CC3: FunctionDecl:{ResultType void}{TypedText func3}{LeftParen (}{Placeholder float}{RightParen )} (50)
+// CHECK-CC3: EnumConstantDecl:{ResultType enum Color}{TypedText Green} (65)
+// CHECK-CC3: EnumConstantDecl:{ResultType enum Priority}{TypedText High} (16)
+// CHECK-CC3: VarDecl:{ResultType int}{TypedText i} (17)
+// CHECK-CC3: ParmDecl:{ResultType int}{TypedText integer} (17)
+// CHECK-CC3: EnumConstantDecl:{ResultType enum Priority}{TypedText Low} (16)
+// CHECK-CC3: ParmDecl:{ResultType enum Priority}{TypedText priority} (8)
+// CHECK-CC3: EnumConstantDecl:{ResultType enum Color}{TypedText Red} (65)
+// CHECK-CC3: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// CHECK-CC3: FunctionDecl:{ResultType enum Priority}{TypedText test1}{LeftParen (}{Placeholder enum Priority priority}{Comma , }{Placeholder enum Color color}{Comma , }{Placeholder int integer}{RightParen )} (12)
+// RUN: c-index-test -code-completion-at=%s:19:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: EnumConstantDecl:{ResultType enum Color}{TypedText Blue} (16)
+// CHECK-CC4: VarDecl:{ResultType enum Color}{TypedText c} (8)
+// CHECK-CC4: ParmDecl:{ResultType enum Color}{TypedText color} (8)
+// CHECK-CC4: FunctionDecl:{ResultType int}{TypedText func1}{LeftParen (}{Placeholder enum Color}{RightParen )} (25)
+// CHECK-CC4: FunctionDecl:{ResultType enum Priority}{TypedText func2}{LeftParen (}{Placeholder int}{RightParen )} (50)
+// CHECK-CC4: FunctionDecl:{ResultType void}{TypedText func3}{LeftParen (}{Placeholder float}{RightParen )} (50)
+// CHECK-CC4: EnumConstantDecl:{ResultType enum Color}{TypedText Green} (16)
+// CHECK-CC4: EnumConstantDecl:{ResultType enum Priority}{TypedText High} (65)
+// CHECK-CC4: VarDecl:{ResultType int}{TypedText i} (17)
+// CHECK-CC4: ParmDecl:{ResultType int}{TypedText integer} (17)
+// CHECK-CC4: EnumConstantDecl:{ResultType enum Priority}{TypedText Low} (65)
+// CHECK-CC4: ParmDecl:{ResultType enum Priority}{TypedText priority} (34)
+// CHECK-CC4: EnumConstantDecl:{ResultType enum Color}{TypedText Red} (16)
+// CHECK-CC4: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// CHECK-CC4: FunctionDecl:{ResultType enum Priority}{TypedText test1}{LeftParen (}{Placeholder enum Priority priority}{Comma , }{Placeholder enum Color color}{Comma , }{Placeholder int integer}{RightParen )} (50)
+// RUN: c-index-test -code-completion-at=%s:21:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: c-index-test -code-completion-at=%s:22:7 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC6 %s
+// CHECK-CC6: VarDecl:{ResultType void (^)(enum Color, int)}{TypedText block} (34)
+// CHECK-CC6: EnumConstantDecl:{ResultType enum Color}{TypedText Blue} (16)
+// CHECK-CC6: VarDecl:{ResultType enum Color}{TypedText c} (8)
+// CHECK-CC6: ParmDecl:{ResultType enum Color}{TypedText color} (8)
+// CHECK-CC6: FunctionDecl:{ResultType int}{TypedText func1}{LeftParen (}{Placeholder enum Color}{RightParen )} (25)
+// CHECK-CC6: FunctionDecl:{ResultType enum Priority}{TypedText func2}{LeftParen (}{Placeholder int}{RightParen )} (50)
+// CHECK-CC6: FunctionDecl:{ResultType void}{TypedText func3}{LeftParen (}{Placeholder float}{RightParen )} (50)
+// CHECK-CC6: EnumConstantDecl:{ResultType enum Color}{TypedText Green} (16)
+// CHECK-CC6: EnumConstantDecl:{ResultType enum Priority}{TypedText High} (65)
+// CHECK-CC6: VarDecl:{ResultType int}{TypedText i} (17)
+// CHECK-CC6: ParmDecl:{ResultType int}{TypedText integer} (17)
+// CHECK-CC6: EnumConstantDecl:{ResultType enum Priority}{TypedText Low} (65)
+// CHECK-CC6: ParmDecl:{ResultType enum Priority}{TypedText priority} (34)
+// CHECK-CC6: EnumConstantDecl:{ResultType enum Color}{TypedText Red} (16)
+// CHECK-CC6: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// CHECK-CC6: FunctionDecl:{ResultType enum Priority}{TypedText test1}{LeftParen (}{Placeholder enum Priority priority}{Comma , }{Placeholder enum Color color}{Comma , }{Placeholder int integer}{RightParen )} (50)
+// RUN: c-index-test -code-completion-at=%s:31:13 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC7 %s
+// RUN: c-index-test -code-completion-at=%s:32:13 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC7 %s
+// CHECK-CC7: ParmDecl:{ResultType A *}{TypedText a} (34)
+// CHECK-CC7: EnumConstantDecl:{ResultType enum Color}{TypedText Blue} (16)
+// CHECK-CC7: FunctionDecl:{ResultType int}{TypedText func1}{LeftParen (}{Placeholder enum Color}{RightParen )} (25)
+// CHECK-CC7: FunctionDecl:{ResultType enum Priority}{TypedText func2}{LeftParen (}{Placeholder int}{RightParen )} (50)
+// CHECK-CC7: FunctionDecl:{ResultType void}{TypedText func3}{LeftParen (}{Placeholder float}{RightParen )} (50)
+// CHECK-CC7: EnumConstantDecl:{ResultType enum Color}{TypedText Green} (16)
+// CHECK-CC7: EnumConstantDecl:{ResultType enum Priority}{TypedText High} (65)
+// CHECK-CC7: EnumConstantDecl:{ResultType enum Priority}{TypedText Low} (65)
+// CHECK-CC7: EnumConstantDecl:{ResultType enum Color}{TypedText Red} (16)
+// CHECK-CC7: FunctionDecl:{ResultType enum Priority}{TypedText test1}{LeftParen (}{Placeholder enum Priority priority}{Comma , }{Placeholder enum Color color}{Comma , }{Placeholder int integer}{RightParen )} (50)
+// RUN: c-index-test -code-completion-at=%s:31:26 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC8 %s
+// RUN: c-index-test -code-completion-at=%s:32:26 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC8 %s
+// CHECK-CC8: ParmDecl:{ResultType A *}{TypedText a} (34)
+// CHECK-CC8: EnumConstantDecl:{ResultType enum Color}{TypedText Blue} (65)
+// CHECK-CC8: FunctionDecl:{ResultType int}{TypedText func1}{LeftParen (}{Placeholder enum Color}{RightParen )} (25)
+// CHECK-CC8: FunctionDecl:{ResultType enum Priority}{TypedText func2}{LeftParen (}{Placeholder int}{RightParen )} (12)
+// CHECK-CC8: FunctionDecl:{ResultType void}{TypedText func3}{LeftParen (}{Placeholder float}{RightParen )} (50)
+// CHECK-CC8: EnumConstantDecl:{ResultType enum Color}{TypedText Green} (65)
+// CHECK-CC8: EnumConstantDecl:{ResultType enum Priority}{TypedText High} (16)
+// CHECK-CC8: EnumConstantDecl:{ResultType enum Priority}{TypedText Low} (16)
+// CHECK-CC8: EnumConstantDecl:{ResultType enum Color}{TypedText Red} (65)
+// CHECK-CC8: FunctionDecl:{ResultType enum Priority}{TypedText test1}{LeftParen (}{Placeholder enum Priority priority}{Comma , }{Placeholder enum Color color}{Comma , }{Placeholder int integer}{RightParen )} (12)
diff --git a/clang/test/Index/complete-unterminated.c b/clang/test/Index/complete-unterminated.c
new file mode 100644
index 0000000..56e6ae1
--- /dev/null
+++ b/clang/test/Index/complete-unterminated.c
@@ -0,0 +1,30 @@
+typedef int Integer;
+
+#if 0
+
+
+#endif
+
+/* blah */
+
+void f0(const char*);
+void f1(char);
+
+const char *hello = "Hello, world";
+const char a = 'a';
+
+#define FOO(a, b) a b
+
+FOO(int, x);
+
+// RUN: c-index-test -code-completion-at=%s:5:1 -pedantic %s 2> %t.err | FileCheck %s
+// RUN: not grep error %t.err
+// CHECK: {TypedText Integer}
+// RUN: c-index-test -code-completion-at=%s:8:6 -pedantic %s 2> %t.err
+// RUN: not grep error %t.err
+// RUN: c-index-test -code-completion-at=%s:10:28 -pedantic %s 2> %t.err
+// RUN: not grep unterminated %t.err
+// RUN: c-index-test -code-completion-at=%s:11:17 -pedantic %s 2> %t.err
+// RUN: not grep unterminated %t.err
+// RUN: c-index-test -code-completion-at=%s:18:10 -pedantic %s 2> %t.err
+// RUN: not grep unterminated %t.err
diff --git a/clang/test/Index/complete-with-annotations.cpp b/clang/test/Index/complete-with-annotations.cpp
new file mode 100644
index 0000000..afa8d9e
--- /dev/null
+++ b/clang/test/Index/complete-with-annotations.cpp
@@ -0,0 +1,23 @@
+class X {
+ void doSomething();
+
+ int field __attribute((annotate("one"), annotate("two"), annotate("three")));
+
+public __attribute__((annotate("some annotation"))):
+ void func2();
+ int member2 __attribute__((annotate("another annotation")));
+};
+
+void X::doSomething() {
+ // RUN: c-index-test -code-completion-at=%s:13:9 %s | FileCheck %s
+ this->;
+}
+
+// CHECK: CXXMethod:{ResultType void}{TypedText doSomething}{LeftParen (}{RightParen )} (34)
+// CHECK: FieldDecl:{ResultType int}{TypedText field} (35) ("three", "two", "one")
+// CHECK: CXXMethod:{ResultType void}{TypedText func2}{LeftParen (}{RightParen )} (34) ("some annotation")
+// CHECK: FieldDecl:{ResultType int}{TypedText member2} (35) ("another annotation", "some annotation")
+// CHECK: CXXMethod:{ResultType X &}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (34)
+// CHECK: ClassDecl:{TypedText X}{Text ::} (75)
+// CHECK: CXXDestructor:{ResultType void}{TypedText ~X}{LeftParen (}{RightParen )} (34)
+
diff --git a/clang/test/Index/crash-recovery-code-complete.c b/clang/test/Index/crash-recovery-code-complete.c
new file mode 100644
index 0000000..dde90bc
--- /dev/null
+++ b/clang/test/Index/crash-recovery-code-complete.c
@@ -0,0 +1,12 @@
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_PREAMBLE_FILE=%t-preamble.pch \
+// RUN: not c-index-test -code-completion-at=%s:20:1 \
+// RUN: "-remap-file=%s;%S/Inputs/crash-recovery-code-complete-remap.c" \
+// RUN: %s 2> %t.err
+// RUN: FileCheck < %t.err -check-prefix=CHECK-CODE-COMPLETE-CRASH %s
+// RUN: test ! -e %t-preamble.pch
+// CHECK-CODE-COMPLETE-CRASH: Unable to perform code completion!
+//
+// REQUIRES: crash-recovery
+// REQUIRES: shell
+
+#warning parsing original file
diff --git a/clang/test/Index/crash-recovery-modules.m b/clang/test/Index/crash-recovery-modules.m
new file mode 100644
index 0000000..212923f
--- /dev/null
+++ b/clang/test/Index/crash-recovery-modules.m
@@ -0,0 +1,20 @@
+// Clear out the module cache entirely, so we start from nothing.
+// RUN: rm -rf %t
+
+// Parse the file, such that building the module will cause Clang to crash.
+// RUN: not env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodule-cache-path %t -Xclang -fdisable-module-hash -I %S/Inputs/Headers -DCRASH %s 2> %t.err
+// RUN: FileCheck < %t.err -check-prefix=CHECK-CRASH %s
+// CHECK-CRASH: crash-recovery-modules.m:16:32:{16:2-16:37}: fatal error: could not build module 'Crash'
+
+// Parse the file again, without crashing, to make sure that
+// subsequent parses do the right thing.
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodule-cache-path %t -Xclang -fdisable-module-hash -I %S/Inputs/Headers %s
+
+// REQUIRES: crash-recovery
+// REQUIRES: shell
+
+@__experimental_modules_import Crash;
+
+void test() {
+ const char* error = getCrashString();
+}
diff --git a/clang/test/Index/crash-recovery-reparse.c b/clang/test/Index/crash-recovery-reparse.c
new file mode 100644
index 0000000..06bb76b
--- /dev/null
+++ b/clang/test/Index/crash-recovery-reparse.c
@@ -0,0 +1,12 @@
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_PREAMBLE_FILE=%t-preamble.pch \
+// RUN: not c-index-test -test-load-source-reparse 1 local \
+// RUN: -remap-file="%s;%S/Inputs/crash-recovery-reparse-remap.c" \
+// RUN: %s 2> %t.err
+// RUN: FileCheck < %t.err -check-prefix=CHECK-REPARSE-SOURCE-CRASH %s
+// RUN: test ! -e $t-preamble.pch
+// CHECK-REPARSE-SOURCE-CRASH: Unable to reparse translation unit
+//
+// REQUIRES: crash-recovery
+// REQUIRES: shell
+
+#warning parsing original file
diff --git a/clang/test/Index/crash-recovery.c b/clang/test/Index/crash-recovery.c
new file mode 100644
index 0000000..b7f6e0b
--- /dev/null
+++ b/clang/test/Index/crash-recovery.c
@@ -0,0 +1,7 @@
+// RUN: not c-index-test -test-load-source all %s 2> %t.err
+// RUN: FileCheck < %t.err -check-prefix=CHECK-LOAD-SOURCE-CRASH %s
+// CHECK-LOAD-SOURCE-CRASH: Unable to load translation unit
+//
+// REQUIRES: crash-recovery
+
+#pragma clang __debug crash
diff --git a/clang/test/Index/cursor-ref-names.cpp b/clang/test/Index/cursor-ref-names.cpp
new file mode 100644
index 0000000..26174bc
--- /dev/null
+++ b/clang/test/Index/cursor-ref-names.cpp
@@ -0,0 +1,47 @@
+template <typename T>
+struct Base {
+ void func();
+ int operator[](T);
+};
+
+struct Sub: public Base<int> {
+ void func();
+};
+
+template <typename T>
+inline T myMax(T a, T b)
+{ return (a > b) ? a : b; }
+
+int main()
+{
+ Sub inst;
+ inst.func();
+ inst[1];
+ inst.operator[](1);
+
+ inst.Base<int>::operator[](1);
+ myMax<int>(1, 2);
+
+ return 0;
+}
+
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+// CHECK: cursor-ref-names.cpp:17:5: DeclStmt= Extent=[17:5 - 17:14]
+// CHECK: cursor-ref-names.cpp:17:9: VarDecl=inst:17:9 (Definition) Extent=[17:5 - 17:13]
+// CHECK: cursor-ref-names.cpp:17:5: TypeRef=struct Sub:7:8 Extent=[17:5 - 17:8]
+// CHECK: cursor-ref-names.cpp:17:9: CallExpr=Sub:7:8 Extent=[17:9 - 17:13]
+// CHECK: cursor-ref-names.cpp:18:5: CallExpr=func:8:10 Extent=[18:5 - 18:16]
+// CHECK: cursor-ref-names.cpp:18:10: MemberRefExpr=func:8:10 SingleRefName=[18:10 - 18:14] RefName=[18:10 - 18:14] Extent=[18:5 - 18:14]
+// CHECK: cursor-ref-names.cpp:18:5: DeclRefExpr=inst:17:9 Extent=[18:5 - 18:9]
+// CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 SingleRefName=[19:9 - 19:12] RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:5 - 19:12]
+// CHECK: cursor-ref-names.cpp:19:5: DeclRefExpr=inst:17:9 Extent=[19:5 - 19:9]
+// CHECK: cursor-ref-names.cpp:19:9: DeclRefExpr=operator[]:4:9 RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:9 - 19:12]
+// CHECK: cursor-ref-names.cpp:20:5: CallExpr=operator[]:4:9 Extent=[20:5 - 20:23]
+// CHECK: cursor-ref-names.cpp:20:10: MemberRefExpr=operator[]:4:9 SingleRefName=[20:10 - 20:20] RefName=[20:10 - 20:18] RefName=[20:18 - 20:19] RefName=[20:19 - 20:20] Extent=[20:5 - 20:20]
+// CHECK: cursor-ref-names.cpp:20:5: DeclRefExpr=inst:17:9 Extent=[20:5 - 20:9]
+// CHECK: cursor-ref-names.cpp:22:5: CallExpr=operator[]:4:9 Extent=[22:5 - 22:34]
+// CHECK: cursor-ref-names.cpp:22:21: MemberRefExpr=operator[]:4:9 SingleRefName=[22:10 - 22:31] RefName=[22:10 - 22:21] RefName=[22:21 - 22:29] RefName=[22:29 - 22:30] RefName=[22:30 - 22:31] Extent=[22:5 - 22:31]
+// CHECK: cursor-ref-names.cpp:22:5: DeclRefExpr=inst:17:9 Extent=[22:5 - 22:9]
+// CHECK: cursor-ref-names.cpp:22:10: TemplateRef=Base:2:8 Extent=[22:10 - 22:14]
+// CHECK: cursor-ref-names.cpp:23:5: CallExpr=myMax:12:10 Extent=[23:5 - 23:21]
+// CHECK: cursor-ref-names.cpp:23:5: DeclRefExpr=myMax:12:10 RefName=[23:5 - 23:10] RefName=[23:10 - 23:15] Extent=[23:5 - 23:15]
diff --git a/clang/test/Index/cxx-operator-overload.cpp b/clang/test/Index/cxx-operator-overload.cpp
new file mode 100644
index 0000000..8647448
--- /dev/null
+++ b/clang/test/Index/cxx-operator-overload.cpp
@@ -0,0 +1,28 @@
+// Run lines are sensitive to line numbers and come below the code.
+// FIXME: re-enable this when we can serialize more C++ ASTs
+class Cls {
+public:
+ Cls operator +(const Cls &RHS);
+};
+
+static void bar() {
+ Cls x1, x2, x3;
+ Cls x4 = x1 + x2 + x3;
+}
+
+Cls Cls::operator +(const Cls &RHS) { while (1) {} }
+
+// RUN: %clang_cc1 -emit-pch %s -o %t.ast
+
+// RUNx: index-test %t.ast -point-at %s:10:17 -print-decls > %t &&
+// RUNx: cat %t | count 2 &&
+// RUNx: grep ':5:9,' %t &&
+// RUNx: grep ':13:10,' %t &&
+
+// Yep, we can show references of '+' plus signs that are overloaded, w00t!
+// RUNx: index-test %t.ast -point-at %s:5:15 -print-refs > %t &&
+// RUNx: cat %t | count 2 &&
+// RUNx: grep ':10:17,' %t &&
+// RUNx: grep ':10:22,' %t &&
+
+// RUNx: index-test %t.ast -point-at %s:10:14 | grep 'DeclRefExpr x1'
diff --git a/clang/test/Index/cxx11-lambdas.cpp b/clang/test/Index/cxx11-lambdas.cpp
new file mode 100644
index 0000000..93db022
--- /dev/null
+++ b/clang/test/Index/cxx11-lambdas.cpp
@@ -0,0 +1,33 @@
+// Test is line- and column-sensitive; see below.
+
+typedef int Integer;
+struct X {
+ void f() {
+ int localA, localB;
+ auto lambda = [&localA, localB] (Integer x) -> Integer {
+ return localA + localB + x;
+ };
+ }
+};
+
+// RUN: c-index-test -test-load-source all -std=c++11 %s | FileCheck -check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx11-lambdas.cpp:7:19: LambdaExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx11-lambdas.cpp:7:21: VariableRef=localA:6:9 Extent=[7:21 - 7:27]
+// CHECK-LOAD: cxx11-lambdas.cpp:7:29: VariableRef=localB:6:17 Extent=[7:29 - 7:35]
+// CHECK-LOAD: cxx11-lambdas.cpp:7:52: TypeRef=Integer:3:13 Extent=[7:52 - 7:59]
+// CHECK-LOAD: cxx11-lambdas.cpp:7:46: ParmDecl=x:7:46 (Definition) Extent=[7:38 - 7:47]
+// CHECK-LOAD: cxx11-lambdas.cpp:7:38: TypeRef=Integer:3:13 Extent=[7:38 - 7:45]
+// CHECK-LOAD: cxx11-lambdas.cpp:7:60: CompoundStmt= Extent=[7:60 - 9:6]
+// CHECK-LOAD: cxx11-lambdas.cpp:8:7: ReturnStmt= Extent=[8:7 - 8:33]
+// CHECK-LOAD: cxx11-lambdas.cpp:8:14: DeclRefExpr=localA:6:9 Extent=[8:14 - 8:20]
+// CHECK-LOAD: cxx11-lambdas.cpp:8:23: DeclRefExpr=localB:6:17 Extent=[8:23 - 8:29]
+// CHECK-LOAD: cxx11-lambdas.cpp:8:32: DeclRefExpr=x:7:46 Extent=[8:32 - 8:33]
+
+// RUN: env CINDEXTEST_INDEXLOCALSYMBOLS=1 c-index-test -index-file -std=c++11 %s | FileCheck -check-prefix=CHECK-INDEX %s
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localA | USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localA | lang: C | cursor: VariableRef=localA:6:9 | loc: 7:21
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localB | USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localB | lang: C | cursor: VariableRef=localB:6:17 | loc: 7:29
+// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: c:cxx11-lambdas.cpp@51@T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 7:52
+// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: c:cxx11-lambdas.cpp@51@T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 7:38
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localA | USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localA | lang: C | cursor: DeclRefExpr=localA:6:9 | loc: 8:14
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localB | USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localB | lang: C | cursor: DeclRefExpr=localB:6:17 | loc: 8:23
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: x | USR: c:cxx11-lambdas.cpp@157@S@X@F@f#@Ca@F@operator()#I#1@x | lang: C | cursor: DeclRefExpr=x:7:46 | loc: 8:32
diff --git a/clang/test/Index/error-on-deserialized.c b/clang/test/Index/error-on-deserialized.c
new file mode 100644
index 0000000..8ba8283
--- /dev/null
+++ b/clang/test/Index/error-on-deserialized.c
@@ -0,0 +1,13 @@
+
+#include "targeted-top.h"
+
+// This tests that we will correctly error out on the deserialized decl.
+
+// RUN: c-index-test -write-pch %t.h.pch %S/targeted-top.h
+// RUN: env CINDEXTEST_FAILONERROR=1 not c-index-test -cursor-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 2>&1 \
+// RUN: | FileCheck %s
+
+// CHECK: error: NestedVar1 was deserialized
diff --git a/clang/test/Index/file-macro-refs.c b/clang/test/Index/file-macro-refs.c
new file mode 100644
index 0000000..ed01cf5
--- /dev/null
+++ b/clang/test/Index/file-macro-refs.c
@@ -0,0 +1,12 @@
+#define FOO
+
+FOO
+FOO
+
+// RUN: c-index-test -file-refs-at=%s:3:2 %s | FileCheck %s
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -file-refs-at=%s:3:2 %s | FileCheck %s
+
+// CHECK: macro expansion=FOO:1:9
+// CHECK-NEXT: macro definition=FOO =[1:9 - 1:12]
+// CHECK-NEXT: macro expansion=FOO:1:9 =[3:1 - 3:4]
+// CHECK-NEXT: macro expansion=FOO:1:9 =[4:1 - 4:4]
diff --git a/clang/test/Index/file-refs-subscripting.m b/clang/test/Index/file-refs-subscripting.m
new file mode 100644
index 0000000..493d93d
--- /dev/null
+++ b/clang/test/Index/file-refs-subscripting.m
@@ -0,0 +1,65 @@
+@interface NSArray
+- (id)objectAtIndexedSubscript:(int)index;
++ (id)arrayWithObjects:(id *)objects count:(unsigned)count;
+@end
+
+@interface NSMutableArray : NSArray
+- (id)objectAtIndexedSubscript:(int)index;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary
+- (id)objectForKeyedSubscript:(id)key;
++ (id)dictionaryWithObjects:(id *)objects forKeys:(id *)keys count:(unsigned)count;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@class NSString;
+
+id testArray(int index, id p) {
+ NSMutableArray *array;
+ array[3] = 0;
+ NSArray *arr = @[ p, p ];
+ return array[index];
+}
+
+void testDict() {
+ NSMutableDictionary *dictionary;
+ NSString *key;
+ id newObject, oldObject;
+ oldObject = dictionary[key];
+ dictionary[key] = newObject;
+ NSDictionary *dict = @{ key: newObject, key: oldObject };
+}
+
+// RUN: c-index-test \
+
+// RUN: -file-refs-at=%s:22:21 \
+// CHECK: ParmDecl=index:22:18
+// CHECK-NEXT: ParmDecl=index:22:18 (Definition) =[22:18 - 22:23]
+// CHECK-NEXT: DeclRefExpr=index:22:18 =[26:16 - 26:21]
+
+// RUN: -file-refs-at=%s:22:28 \
+// CHECK-NEXT: ParmDecl=p:22:28
+// CHECK-NEXT: ParmDecl=p:22:28 (Definition) =[22:28 - 22:29]
+// CHECK-NEXT: DeclRefExpr=p:22:28 =[25:21 - 25:22]
+// CHECK-NEXT: DeclRefExpr=p:22:28 =[25:24 - 25:25]
+
+// RUN: -file-refs-at=%s:34:16 \
+// CHECK-NEXT: DeclRefExpr=key:31:13
+// CHECK-NEXT: VarDecl=key:31:13 (Definition) =[31:13 - 31:16]
+// CHECK-NEXT: DeclRefExpr=key:31:13 =[33:26 - 33:29]
+// CHECK-NEXT: DeclRefExpr=key:31:13 =[34:14 - 34:17]
+// CHECK-NEXT: DeclRefExpr=key:31:13 =[35:27 - 35:30]
+// CHECK-NEXT: DeclRefExpr=key:31:13 =[35:43 - 35:46]
+
+// RUN: -file-refs-at=%s:35:35 \
+// CHECK-NEXT: DeclRefExpr=newObject:32:6
+// CHECK-NEXT: VarDecl=newObject:32:6 (Definition) =[32:6 - 32:15]
+// CHECK-NEXT: DeclRefExpr=newObject:32:6 =[34:21 - 34:30]
+// CHECK-NEXT: DeclRefExpr=newObject:32:6 =[35:32 - 35:41]
+
+// RUN: -target x86_64-apple-macosx10.7 %s | FileCheck %s
diff --git a/clang/test/Index/file-refs.c b/clang/test/Index/file-refs.c
new file mode 100644
index 0000000..23042ea
--- /dev/null
+++ b/clang/test/Index/file-refs.c
@@ -0,0 +1,57 @@
+enum {
+ VALUE = 3
+};
+
+extern int glob_x;
+
+int f(int x) {
+ return x+glob_x+VALUE;
+}
+
+typedef struct {
+ int x;
+ int y;
+} Vector;
+
+int vector_get_x(Vector v) {
+ int x = v.x;
+ return x;
+}
+
+int f(int);
+int f(int);
+
+// RUN: c-index-test \
+
+// RUN: -file-refs-at=%s:2:5 \
+// CHECK: EnumConstantDecl=VALUE:2:3 (Definition)
+// CHECK-NEXT: EnumConstantDecl=VALUE:2:3 (Definition) =[2:3 - 2:8]
+// CHECK-NEXT: DeclRefExpr=VALUE:2:3 =[8:19 - 8:24]
+
+// RUN: -file-refs-at=%s:8:15 \
+// CHECK-NEXT: DeclRefExpr=glob_x:5:12
+// CHECK-NEXT: VarDecl=glob_x:5:12 =[5:12 - 5:18]
+// CHECK-NEXT: DeclRefExpr=glob_x:5:12 =[8:12 - 8:18]
+
+// RUN: -file-refs-at=%s:8:10 \
+// CHECK-NEXT: DeclRefExpr=x:7:11
+// CHECK-NEXT: ParmDecl=x:7:11 (Definition) =[7:11 - 7:12]
+// CHECK-NEXT: DeclRefExpr=x:7:11 =[8:10 - 8:11]
+
+// RUN: -file-refs-at=%s:12:7 \
+// CHECK-NEXT: FieldDecl=x:12:7 (Definition)
+// CHECK-NEXT: FieldDecl=x:12:7 (Definition) =[12:7 - 12:8]
+// CHECK-NEXT: MemberRefExpr=x:12:7 {{.*}} =[17:13 - 17:14]
+
+// RUN: -file-refs-at=%s:16:21 \
+// CHECK-NEXT: TypeRef=Vector:14:3
+// CHECK-NEXT: TypedefDecl=Vector:14:3 (Definition) =[14:3 - 14:9]
+// CHECK-NEXT: TypeRef=Vector:14:3 =[16:18 - 16:24]
+
+// RUN: -file-refs-at=%s:21:5 \
+// CHECK-NEXT: FunctionDecl=f:21:5
+// CHECK-NEXT: FunctionDecl=f:7:5 (Definition) =[7:5 - 7:6]
+// CHECK-NEXT: FunctionDecl=f:21:5 =[21:5 - 21:6]
+// CHECK-NEXT: FunctionDecl=f:22:5 =[22:5 - 22:6]
+
+// RUN: %s | FileCheck %s
diff --git a/clang/test/Index/file-refs.cpp b/clang/test/Index/file-refs.cpp
new file mode 100644
index 0000000..a96d27c
--- /dev/null
+++ b/clang/test/Index/file-refs.cpp
@@ -0,0 +1,104 @@
+namespace NS {
+ class C {
+ public:
+ C() { }
+ void m();
+ };
+}
+
+void NS::C::m() {
+ C c;
+ c.m();
+}
+
+void f() {
+ NS::C c1();
+ NS::C c2 = NS::C();
+}
+
+void over(int);
+void over(float);
+
+void test_over() {
+ over(0);
+ over(0.0f);
+}
+
+template <typename T>
+T tf(T t) {
+ return t;
+}
+
+namespace Test2 {
+
+struct S {
+ S(int x, int y);
+ S();
+};
+
+typedef S Cake;
+
+void f() {
+ Cake p;
+ p = Test2::S(0,2);
+ p = Test2::Cake(0,2);
+}
+
+}
+
+// RUN: c-index-test \
+
+// RUN: -file-refs-at=%s:9:7 \
+// CHECK: NamespaceRef=NS:1:11
+// CHECK-NEXT: Namespace=NS:1:11 (Definition) =[1:11 - 1:13]
+// CHECK-NEXT: NamespaceRef=NS:1:11 =[9:6 - 9:8]
+// CHECK-NEXT: NamespaceRef=NS:1:11 =[15:3 - 15:5]
+// CHECK-NEXT: NamespaceRef=NS:1:11 =[16:3 - 16:5]
+// CHECK-NEXT: NamespaceRef=NS:1:11 =[16:14 - 16:16]
+
+// RUN: -file-refs-at=%s:2:9 \
+// CHECK-NEXT: ClassDecl=C:2:9 (Definition)
+// CHECK-NEXT: ClassDecl=C:2:9 (Definition) =[2:9 - 2:10]
+// CHECK-NEXT: CXXConstructor=C:4:5 (Definition) =[4:5 - 4:6]
+// CHECK-NEXT: TypeRef=class NS::C:2:9 =[9:10 - 9:11]
+// CHECK-NEXT: TypeRef=class NS::C:2:9 =[10:3 - 10:4]
+// CHECK-NEXT: TypeRef=class NS::C:2:9 =[15:7 - 15:8]
+// CHECK-NEXT: TypeRef=class NS::C:2:9 =[16:7 - 16:8]
+// CHECK-NEXT: TypeRef=class NS::C:2:9 =[16:18 - 16:19]
+
+// RUN: -file-refs-at=%s:16:18 \
+// CHECK-NEXT: CallExpr=C:4:5
+// CHECK-NEXT: ClassDecl=C:2:9 (Definition) =[2:9 - 2:10]
+// CHECK-NEXT: CXXConstructor=C:4:5 (Definition) =[4:5 - 4:6]
+// CHECK-NEXT: TypeRef=class NS::C:2:9 =[9:10 - 9:11]
+// CHECK-NEXT: TypeRef=class NS::C:2:9 =[10:3 - 10:4]
+// CHECK-NEXT: TypeRef=class NS::C:2:9 =[15:7 - 15:8]
+// CHECK-NEXT: TypeRef=class NS::C:2:9 =[16:7 - 16:8]
+// CHECK-NEXT: TypeRef=class NS::C:2:9 =[16:18 - 16:19]
+
+// RUN: -file-refs-at=%s:20:8 \
+// CHECK-NEXT: FunctionDecl=over:20:6
+// CHECK-NEXT: FunctionDecl=over:20:6 =[20:6 - 20:10]
+// CHECK-NEXT: DeclRefExpr=over:20:6 =[24:3 - 24:7]
+
+// RUN: -file-refs-at=%s:28:1 \
+// CHECK-NEXT: TypeRef=T:27:20
+// FIXME: Missing TemplateTypeParameter=T:27:20 (Definition)
+// CHECK-NEXT: TypeRef=T:27:20 =[28:1 - 28:2]
+// CHECK-NEXT: TypeRef=T:27:20 =[28:6 - 28:7]
+
+// RUN: -file-refs-at=%s:43:14 \
+// CHECK-NEXT: CallExpr=S:35:3
+// CHECK-NEXT: StructDecl=S:34:8 (Definition) =[34:8 - 34:9]
+// CHECK-NEXT: CXXConstructor=S:35:3 =[35:3 - 35:4]
+// CHECK-NEXT: CXXConstructor=S:36:3 =[36:3 - 36:4]
+// CHECK-NEXT: TypeRef=struct Test2::S:34:8 =[39:9 - 39:10]
+// CHECK-NEXT: TypeRef=struct Test2::S:34:8 =[43:14 - 43:15]
+
+// RUN: -file-refs-at=%s:44:16 \
+// CHECK-NEXT: CallExpr=S:35:3
+// CHECK-NEXT: TypedefDecl=Cake:39:11 (Definition) =[39:11 - 39:15]
+// CHECK-NEXT: TypeRef=Cake:39:11 =[42:3 - 42:7]
+// CHECK-NEXT: TypeRef=Cake:39:11 =[44:14 - 44:18]
+
+// RUN: %s | FileCheck %s
diff --git a/clang/test/Index/file-refs.m b/clang/test/Index/file-refs.m
new file mode 100644
index 0000000..3f21c9e
--- /dev/null
+++ b/clang/test/Index/file-refs.m
@@ -0,0 +1,91 @@
+@class Foo;
+
+@interface Foo
+-(id)setWithInt:(int)i andFloat:(float)f;
+@end
+
+@implementation Foo
+-(id)setWithInt:(int)i andFloat:(float)f {
+ return self;
+}
+@end
+
+void test(Foo *foo) {
+ [foo setWithInt:0 andFloat:0];
+ [foo setWithInt: 2 andFloat: 3];
+}
+
+@protocol Prot1
+-(void)protMeth;
+@end
+
+@protocol Prot2<Prot1>
+@end
+
+@interface Base<Prot2>
+@end
+
+@interface Sub : Base
+-(void)protMeth;
+@end
+
+@implementation Sub
+-(void)protMeth {}
+@end
+
+void test2(Sub *s, id<Prot1> p) {
+ [s protMeth];
+ [p protMeth];
+}
+
+
+// RUN: c-index-test \
+
+// RUN: -file-refs-at=%s:7:18 \
+// CHECK: ObjCImplementationDecl=Foo:7:17 (Definition)
+
+// FIXME: There should not be 2 for the same range.
+// CHECK-NEXT: ObjCInterfaceDecl=Foo:1:8 =[1:8 - 1:11]
+// CHECK-NEXT: ObjCClassRef=Foo:3:12 =[1:8 - 1:11]
+
+// CHECK-NEXT: ObjCInterfaceDecl=Foo:3:12 =[3:12 - 3:15]
+// CHECK-NEXT: ObjCImplementationDecl=Foo:7:17 (Definition) =[7:17 - 7:20]
+// CHECK-NEXT: ObjCClassRef=Foo:3:12 =[13:11 - 13:14]
+
+// RUN: -file-refs-at=%s:4:10 \
+// CHECK-NEXT: ObjCInstanceMethodDecl=setWithInt:andFloat::4:6
+// CHECK-NEXT: ObjCInstanceMethodDecl=setWithInt:andFloat::4:6 =[4:6 - 4:16]
+// CHECK-NEXT: ObjCInstanceMethodDecl=setWithInt:andFloat::8:6 (Definition) =[8:6 - 8:16]
+// CHECK-NEXT: ObjCMessageExpr=setWithInt:andFloat::4:6 =[14:8 - 14:18]
+// CHECK-NEXT: ObjCMessageExpr=setWithInt:andFloat::4:6 =[15:8 - 15:18]
+
+// RUN: -file-refs-at=%s:15:27 \
+// CHECK-NEXT: ObjCMessageExpr=setWithInt:andFloat::4:6
+// CHECK-NEXT: ObjCInstanceMethodDecl=setWithInt:andFloat::4:6 =[4:24 - 4:32]
+// CHECK-NEXT: ObjCInstanceMethodDecl=setWithInt:andFloat::8:6 (Definition) =[8:24 - 8:32]
+// CHECK-NEXT: ObjCMessageExpr=setWithInt:andFloat::4:6 =[14:21 - 14:29]
+// CHECK-NEXT: ObjCMessageExpr=setWithInt:andFloat::4:6 =[15:22 - 15:30]
+
+// RUN: -file-refs-at=%s:18:13 \
+// CHECK-NEXT: ObjCProtocolDecl=Prot1:18:11 (Definition)
+// CHECK-NEXT: ObjCProtocolDecl=Prot1:18:11 (Definition) =[18:11 - 18:16]
+// CHECK-NEXT: ObjCProtocolRef=Prot1:18:11 =[22:17 - 22:22]
+// CHECK-NEXT: ObjCProtocolRef=Prot1:18:11 =[36:23 - 36:28]
+
+// RUN: -file-refs-at=%s:38:10 \
+// CHECK-NEXT: ObjCMessageExpr=protMeth:19:8
+// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:19:8 =[19:8 - 19:16]
+// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:29:8 [Overrides @19:8] =[29:8 - 29:16]
+// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:33:8 (Definition) [Overrides @19:8] =[33:8 - 33:16]
+// CHECK-NEXT: ObjCMessageExpr=protMeth:29:8 =[37:6 - 37:14]
+// CHECK-NEXT: ObjCMessageExpr=protMeth:19:8 =[38:6 - 38:14]
+
+// RUN: -file-refs-at=%s:33:12 \
+// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:33:8 (Definition) [Overrides @19:8]
+// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:19:8 =[19:8 - 19:16]
+// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:29:8 [Overrides @19:8] =[29:8 - 29:16]
+// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:33:8 (Definition) [Overrides @19:8] =[33:8 - 33:16]
+// CHECK-NEXT: ObjCMessageExpr=protMeth:29:8 =[37:6 - 37:14]
+// CHECK-NEXT: ObjCMessageExpr=protMeth:19:8 =[38:6 - 38:14]
+
+// RUN: %s | FileCheck %s
diff --git a/clang/test/Index/fix-its.c b/clang/test/Index/fix-its.c
new file mode 100644
index 0000000..d5cb1af
--- /dev/null
+++ b/clang/test/Index/fix-its.c
@@ -0,0 +1,27 @@
+// RUN: c-index-test -test-load-source all -fspell-checking %s 2> %t
+// RUN: FileCheck %s < %t
+struct X {
+ int wibble;
+};
+
+#define MACRO(X) X
+
+void f(struct X *x) {
+ // CHECK: error: no member named 'wobble' in 'struct X'; did you mean 'wibble'?
+ // CHECK: FIX-IT: Replace [13:12 - 13:18] with "wibble"
+ // CHECK: note: 'wibble' declared here
+ MACRO(x->wobble = 17);
+ // CHECK: error: no member named 'wabble' in 'struct X'; did you mean 'wibble'?
+ // CHECK: FIX-IT: Replace [17:6 - 17:12] with "wibble"
+ // CHECK: note: 'wibble' declared here
+ x->wabble = 17;
+}
+
+int printf(const char *restrict, ...);
+
+void f2() {
+ unsigned long index;
+ // CHECK: warning: format specifies type 'int' but the argument has type 'unsigned long'
+ // CHECK: FIX-IT: Replace [26:17 - 26:19] with "%ld"
+ MACRO(printf("%d", index));
+}
diff --git a/clang/test/Index/get-cursor-includes.c b/clang/test/Index/get-cursor-includes.c
new file mode 100644
index 0000000..68d64f1
--- /dev/null
+++ b/clang/test/Index/get-cursor-includes.c
@@ -0,0 +1,7 @@
+#include "get-cursor-includes-2.h"
+#include "get-cursor-includes-2.h"
+
+// RUN: c-index-test -write-pch %t.h.pch -I%S/Inputs -Xclang -detailed-preprocessing-record %S/Inputs/get-cursor-includes-2.h
+// RUN: c-index-test -cursor-at=%S/Inputs/get-cursor-includes-2.h:1:5 -I%S/Inputs -include %t.h %s | FileCheck %s
+
+// CHECK: inclusion directive=get-cursor-includes-1.h
diff --git a/clang/test/Index/get-cursor-macro-args.h b/clang/test/Index/get-cursor-macro-args.h
new file mode 100644
index 0000000..40ec8dc
--- /dev/null
+++ b/clang/test/Index/get-cursor-macro-args.h
@@ -0,0 +1,16 @@
+@interface MyClass
++(void)meth;
+@end
+
+#define MACRO2(x) x
+#define MACRO(x) MACRO2(x)
+
+void test() {
+ MACRO([MyClass meth]);
+}
+
+#define INVOKE(METHOD, CLASS) [CLASS METHOD]
+
+void test2() {
+ INVOKE(meth, MyClass);
+}
diff --git a/clang/test/Index/get-cursor-macro-args.m b/clang/test/Index/get-cursor-macro-args.m
new file mode 100644
index 0000000..4945fd3
--- /dev/null
+++ b/clang/test/Index/get-cursor-macro-args.m
@@ -0,0 +1,19 @@
+// Test without PCH
+// RUN: c-index-test -cursor-at=%S/get-cursor-macro-args.h:9:12 \
+// RUN: -cursor-at=%S/get-cursor-macro-args.h:9:21 \
+// RUN: -cursor-at=%S/get-cursor-macro-args.h:15:12 \
+// RUN: -cursor-at=%S/get-cursor-macro-args.h:15:20 \
+// RUN: %s -include get-cursor-macro-args.h | FileCheck %s
+
+// Test with PCH
+// RUN: c-index-test -write-pch %t.pch -x objective-c-header %S/get-cursor-macro-args.h
+// RUN: c-index-test -cursor-at=%S/get-cursor-macro-args.h:9:12 \
+// RUN: -cursor-at=%S/get-cursor-macro-args.h:9:21 \
+// RUN: -cursor-at=%S/get-cursor-macro-args.h:15:12 \
+// RUN: -cursor-at=%S/get-cursor-macro-args.h:15:20 \
+// RUN: %s -include-pch %t.pch | FileCheck %s
+
+// CHECK: ObjCClassRef=MyClass:1:12
+// CHECK-NEXT: ObjCMessageExpr=meth:2:8
+// CHECK-NEXT: ObjCMessageExpr=meth:2:8
+// CHECK-NEXT: ObjCClassRef=MyClass:1:12
diff --git a/clang/test/Index/get-cursor.c b/clang/test/Index/get-cursor.c
new file mode 100644
index 0000000..23a4b5c
--- /dev/null
+++ b/clang/test/Index/get-cursor.c
@@ -0,0 +1,14 @@
+struct _MyS {
+ int foo;
+} MyS;
+
+struct _MyS ww;
+
+// RUN: c-index-test -cursor-at=%s:1:9 \
+// RUN: -cursor-at=%s:2:9 \
+// RUN: -cursor-at=%s:5:9 \
+// RUN: %s | FileCheck %s
+
+// CHECK: StructDecl=_MyS:1:8 (Definition)
+// CHECK: FieldDecl=foo:2:7 (Definition)
+// CHECK: TypeRef=struct _MyS:1:8
diff --git a/clang/test/Index/get-cursor.cpp b/clang/test/Index/get-cursor.cpp
new file mode 100644
index 0000000..e1e6835
--- /dev/null
+++ b/clang/test/Index/get-cursor.cpp
@@ -0,0 +1,95 @@
+// Test is line- and column-sensitive. Run lines are below.
+
+struct X {
+ X();
+ X(int);
+ X(int, int);
+ X(const X&);
+};
+
+X getX(int value) {
+ switch (value) {
+ case 1: return X(value);
+ case 2: return X(value, value);
+ case 3: return (X)value;
+ default: break;
+ }
+ return X();
+}
+
+struct Y {
+ int member;
+
+ X getX();
+};
+
+X Y::getX() {
+ return member;
+}
+
+struct YDerived : Y {
+ X getAnotherX() { return member; }
+};
+
+void test() {
+ X foo;
+
+ try {
+ } catch (X e) {
+ X x;
+ }
+}
+
+// RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s
+// CHECK-COMPLETION-1: CXXConstructor=X:6:3
+// CHECK-COMPLETION-1-NEXT: Completion string: {TypedText X}{LeftParen (}{Placeholder int}{Comma , }{Placeholder int}{RightParen )}
+
+// RUN: c-index-test -cursor-at=%s:31:16 %s | FileCheck -check-prefix=CHECK-COMPLETION-2 %s
+// CHECK-COMPLETION-2: CXXMethod=getAnotherX:31:5 (Definition)
+// CHECK-COMPLETION-2-NEXT: Completion string: {ResultType X}{TypedText getAnotherX}{LeftParen (}{RightParen )}
+
+// RUN: c-index-test -cursor-at=%s:12:20 %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
+// RUN: c-index-test -cursor-at=%s:13:21 %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
+// RUN: c-index-test -cursor-at=%s:13:28 %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
+// RUN: c-index-test -cursor-at=%s:14:23 %s | FileCheck -check-prefix=CHECK-VALUE-REF %s
+// CHECK-VALUE-REF: DeclRefExpr=value:10:12
+
+// RUN: c-index-test -cursor-at=%s:12:18 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR1 %s
+// RUN: c-index-test -cursor-at=%s:13:18 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR2 %s
+// RUN: c-index-test -cursor-at=%s:14:19 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR1 %s
+// RUN: c-index-test -cursor-at=%s:17:10 %s | FileCheck -check-prefix=CHECK-CONSTRUCTOR3 %s
+// CHECK-TYPE-REF: TypeRef=struct X:3:8
+// CHECK-CONSTRUCTOR1: CallExpr=X:5:3
+// CHECK-CONSTRUCTOR2: CallExpr=X:6:3
+// CHECK-CONSTRUCTOR3: CallExpr=X:4:3
+
+// RUN: c-index-test -cursor-at=%s:23:3 %s | FileCheck -check-prefix=CHECK-RETTYPE %s
+// RUN: c-index-test -cursor-at=%s:26:1 %s | FileCheck -check-prefix=CHECK-RETTYPE %s
+// CHECK-RETTYPE: TypeRef=struct X:3:8
+
+// RUN: c-index-test -cursor-at=%s:23:7 %s | FileCheck -check-prefix=CHECK-MEMFUNC-DECL %s
+// CHECK-MEMFUNC-DECL: CXXMethod=getX:23:5
+// RUN: c-index-test -cursor-at=%s:26:7 %s | FileCheck -check-prefix=CHECK-MEMFUNC-DEF %s
+// CHECK-MEMFUNC-DEF: CXXMethod=getX:26:6
+
+// RUN: c-index-test -cursor-at=%s:26:3 %s | FileCheck -check-prefix=CHECK-TYPEREF-Y %s
+// CHECK-TYPEREF-Y: TypeRef=struct Y:20:8
+
+// RUN: c-index-test -cursor-at=%s:27:10 %s | FileCheck -check-prefix=CHECK-IMPLICIT-MEMREF %s
+// RUN: c-index-test -cursor-at=%s:31:28 %s | FileCheck -check-prefix=CHECK-IMPLICIT-MEMREF %s
+// CHECK-IMPLICIT-MEMREF: MemberRefExpr=member:21:7
+
+// RUN: c-index-test -cursor-at=%s:35:5 %s | FileCheck -check-prefix=CHECK-DECL %s
+// CHECK-DECL: VarDecl=foo:35:5
+
+// RUN: c-index-test -cursor-at=%s:21:3 %s | FileCheck -check-prefix=CHECK-MEMBER %s
+// CHECK-MEMBER: FieldDecl=member:21:7 (Definition)
+// CHECK-MEMBER-NEXT: Completion string: {ResultType int}{TypedText member}
+
+// RUN: c-index-test -cursor-at=%s:38:12 -cursor-at=%s:39:5 %s | FileCheck -check-prefix=CHECK-CXXCATCH %s
+// CHECK-CXXCATCH: TypeRef=struct X:3:8
+// CHECK-CXXCATCH-NEXT: TypeRef=struct X:3:8
+
+// RUN: c-index-test -test-load-source-usrs local %s | FileCheck -check-prefix=CHECK-USR %s
+// CHECK-USR: get-cursor.cpp c:get-cursor.cpp@472@F@test#@e Extent=[38:12 - 38:15]
+// CHECK-USR: get-cursor.cpp c:get-cursor.cpp@483@F@test#@x Extent=[39:5 - 39:8]
diff --git a/clang/test/Index/get-cursor.m b/clang/test/Index/get-cursor.m
new file mode 100644
index 0000000..5ac3375
--- /dev/null
+++ b/clang/test/Index/get-cursor.m
@@ -0,0 +1,104 @@
+// Test is line- and column-sensitive. Run lines are below.
+
+@interface rdar9771715
+@property (readonly) int foo1;
+@property (readwrite) int foo2;
+@end
+
+@class Foo;
+
+@interface rdar9535717 {
+ __weak Foo *foo;
+}
+@end
+
+@interface Test1 {
+ id _name;
+}
+@end
+@interface Test1 ()
+- (id)name;
+@end
+@interface Test1 ()
+@property (copy) id name;
+@end
+@implementation Test1
+@synthesize name = _name;
+@end
+
+@interface rdar10902015
+@end
+
+@implementation rdar10902015
+
+struct S { int x; };
+
+-(void)mm:(struct S*)s {
+ rdar10902015 *i = 0;
+ s->x = 0;
+ Test1 *test1;
+ test1.name = 0;
+}
+@end
+
+@interface Test2
+-(int)implicitProp;
+-(void)setImplicitProp:(int)x;
+@end
+
+void foo1(Test2 *test2) {
+ int x = test2.implicitProp;
+ test2.implicitProp = x;
+ ++test2.implicitProp;
+}
+
+@interface Test3
+-(void)setFoo:(int)x withBar:(int)y;
+@end
+
+void foo3(Test3 *test3) {
+ [test3 setFoo:2 withBar:4];
+}
+
+@interface Test4
+@end
+@interface Test4(Dido)
+@end
+@implementation Test4(Dido)
+@end
+
+@class Forw1, Forw2, Forw3;
+
+// RUN: c-index-test -cursor-at=%s:4:28 -cursor-at=%s:5:28 %s | FileCheck -check-prefix=CHECK-PROP %s
+// CHECK-PROP: ObjCPropertyDecl=foo1:4:26
+// CHECK-PROP: ObjCPropertyDecl=foo2:5:27
+
+// RUN: c-index-test -cursor-at=%s:11:11 %s -target x86_64-apple-macosx10.7.0 | FileCheck -check-prefix=CHECK-WITH-WEAK %s
+// CHECK-WITH-WEAK: ObjCClassRef=Foo:8:8
+
+// RUN: c-index-test -cursor-at=%s:20:10 %s | FileCheck -check-prefix=CHECK-METHOD %s
+// CHECK-METHOD: 20:7 ObjCInstanceMethodDecl=name:20:7 Extent=[20:1 - 20:12]
+
+// RUN: c-index-test -cursor-at=%s:37:17 %s | FileCheck -check-prefix=CHECK-IN-IMPL %s
+// CHECK-IN-IMPL: VarDecl=i:37:17
+
+// RUN: c-index-test -cursor-at=%s:38:6 -cursor-at=%s:40:11 \
+// RUN: -cursor-at=%s:50:20 -cursor-at=%s:51:15 -cursor-at=%s:52:20 %s | FileCheck -check-prefix=CHECK-MEMBERREF %s
+// CHECK-MEMBERREF: 38:6 MemberRefExpr=x:34:16 SingleRefName=[38:6 - 38:7] RefName=[38:6 - 38:7] Extent=[38:3 - 38:7]
+// CHECK-MEMBERREF: 40:9 MemberRefExpr=name:23:21 Extent=[40:3 - 40:13] Spelling=name ([40:9 - 40:13])
+// CHECK-MEMBERREF: 50:17 MemberRefExpr=implicitProp:45:7 Extent=[50:11 - 50:29] Spelling=implicitProp ([50:17 - 50:29])
+// CHECK-MEMBERREF: 51:9 MemberRefExpr=setImplicitProp::46:8 Extent=[51:3 - 51:21] Spelling=setImplicitProp: ([51:9 - 51:21])
+// CHECK-MEMBERREF: 52:11 MemberRefExpr=setImplicitProp::46:8 Extent=[52:5 - 52:23] Spelling=setImplicitProp: ([52:11 - 52:23])
+
+// RUN: c-index-test -cursor-at=%s:56:24 -cursor-at=%s:60:14 \
+// RUN: -cursor-at=%s:65:20 -cursor-at=%s:67:25 \
+// RUN: -cursor-at=%s:70:10 -cursor-at=%s:70:16 -cursor-at=%s:70:25 \
+// RUN: %s | FileCheck -check-prefix=CHECK-SPELLRANGE %s
+// CHECK-SPELLRANGE: 56:8 ObjCInstanceMethodDecl=setFoo:withBar::56:8 Extent=[56:1 - 56:37] Spelling=setFoo:withBar: ([56:8 - 56:14][56:22 - 56:29]) Selector index=1
+// CHECK-SPELLRANGE: 60:3 ObjCMessageExpr=setFoo:withBar::56:8 Extent=[60:3 - 60:29] Spelling=setFoo:withBar: ([60:10 - 60:16][60:19 - 60:26]) Selector index=0
+// CHECK-SPELLRANGE: 65:12 ObjCCategoryDecl=Dido:65:12 Extent=[65:1 - 66:5] Spelling=Dido ([65:18 - 65:22])
+// CHECK-SPELLRANGE: 67:17 ObjCCategoryImplDecl=Dido:67:17 (Definition) Extent=[67:1 - 68:2] Spelling=Dido ([67:23 - 67:27])
+
+// CHECK-SPELLRANGE: 70:8 ObjCClassRef=Forw1:70:8 Extent=[70:8 - 70:13] Spelling=Forw1 ([70:8 - 70:13])
+// CHECK-SPELLRANGE: 70:15 ObjCClassRef=Forw2:70:15 Extent=[70:15 - 70:20] Spelling=Forw2 ([70:15 - 70:20])
+// CHECK-SPELLRANGE: 70:22 ObjCClassRef=Forw3:70:22 Extent=[70:22 - 70:27] Spelling=Forw3 ([70:22 - 70:27])
diff --git a/clang/test/Index/getcursor-pp-pch.c b/clang/test/Index/getcursor-pp-pch.c
new file mode 100644
index 0000000..d68384c
--- /dev/null
+++ b/clang/test/Index/getcursor-pp-pch.c
@@ -0,0 +1,43 @@
+
+
+
+typedef int T;
+void OBSCURE(func)(int x) {
+ OBSCURE(T) DECORATION value;
+}
+
+
+// Without PCH
+// RUN: c-index-test -cursor-at=%s.h:1:11 \
+// RUN: -cursor-at=%s.h:2:14 \
+// RUN: -cursor-at=%s.h:4:5 \
+// RUN: -cursor-at=%s.h:5:5 \
+// RUN: -cursor-at=%s.h:5:14 \
+// RUN: -cursor-at=%s:5:7 \
+// RUN: -cursor-at=%s:6:6 \
+// RUN: -cursor-at=%s:6:19 \
+// RUN: -include %s.h %s | FileCheck %s
+
+// With PCH
+// RUN: c-index-test -write-pch %t.h.pch %s.h -Xclang -detailed-preprocessing-record
+// RUN: c-index-test -cursor-at=%s.h:1:11 \
+// RUN: -cursor-at=%s.h:2:14 \
+// RUN: -cursor-at=%s.h:4:5 \
+// RUN: -cursor-at=%s.h:5:5 \
+// RUN: -cursor-at=%s.h:5:14 \
+// RUN: -cursor-at=%s:5:7 \
+// RUN: -cursor-at=%s:6:6 \
+// RUN: -cursor-at=%s:6:19 \
+// RUN: -include %t.h %s | FileCheck %s
+
+// From header
+// CHECK: macro definition=OBSCURE
+// CHECK: macro definition=DECORATION
+// CHECK: macro expansion=DECORATION:2:9
+// CHECK: macro expansion=OBSCURE:1:9
+// CHECK: macro expansion=DECORATION:2:9
+
+// From main file
+// CHECK: macro expansion=OBSCURE:1:9
+// CHECK: macro expansion=OBSCURE:1:9
+// CHECK: macro expansion=DECORATION:2:9
diff --git a/clang/test/Index/getcursor-pp-pch.c.h b/clang/test/Index/getcursor-pp-pch.c.h
new file mode 100644
index 0000000..c24a39c
--- /dev/null
+++ b/clang/test/Index/getcursor-pp-pch.c.h
@@ -0,0 +1,5 @@
+#define OBSCURE(X) X
+#define DECORATION
+
+DECORATION
+OBSCURE(DECORATION)
diff --git a/clang/test/Index/in-class-init.cpp b/clang/test/Index/in-class-init.cpp
new file mode 100644
index 0000000..61431ca
--- /dev/null
+++ b/clang/test/Index/in-class-init.cpp
@@ -0,0 +1,6 @@
+struct S {
+ int field = 2;
+};
+
+// RUN: c-index-test -test-load-source all -std=c++11 %s | FileCheck %s
+// CHECK: 2:7: FieldDecl=field:2:7 (Definition) Extent=[2:3 - 2:16]
diff --git a/clang/test/Index/include_test.h b/clang/test/Index/include_test.h
new file mode 100644
index 0000000..3c40c8d
--- /dev/null
+++ b/clang/test/Index/include_test.h
@@ -0,0 +1 @@
+#include "include_test_2.h"
diff --git a/clang/test/Index/include_test_2.h b/clang/test/Index/include_test_2.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Index/include_test_2.h
diff --git a/clang/test/Index/index-attrs.m b/clang/test/Index/index-attrs.m
new file mode 100644
index 0000000..09c52ba
--- /dev/null
+++ b/clang/test/Index/index-attrs.m
@@ -0,0 +1,17 @@
+@class Foo;
+@interface Bar
+@property (retain) __attribute__((iboutletcollection(Foo))) Foo *prop;
+@end
+
+@interface I
+-(id)prop __attribute__((annotate("anno")));
+-(void)setProp:(id)p __attribute__((annotate("anno")));
+@property (assign) id prop __attribute__((annotate("anno")));
+@end
+
+// RUN: c-index-test -index-file %s | FileCheck %s
+// CHECK: <attribute>: attribute(iboutletcollection)= [IBOutletCollection=ObjCInterface]
+
+// CHECK: <attribute>: attribute(annotate)=anno
+// CHECK: <getter>: kind: objc-instance-method | name: prop | {{.*}} <attribute>: attribute(annotate)=anno
+// CHECK: <setter>: kind: objc-instance-method | name: setProp: | {{.*}} <attribute>: attribute(annotate)=anno
diff --git a/clang/test/Index/index-decls.m b/clang/test/Index/index-decls.m
new file mode 100644
index 0000000..9e4e620
--- /dev/null
+++ b/clang/test/Index/index-decls.m
@@ -0,0 +1,30 @@
+@interface I
+@property (readonly) id prop;
+ -(id)prop;
+@end
+
+@interface I()
+@property (assign,readwrite) id prop;
+@end
+
+@implementation I
+@synthesize prop = _prop;
+@end
+
+rdar://11015325
+@interface I1
+__attribute__((something)) @interface I2 @end
+@end
+
+// RUN: c-index-test -index-file %s > %t
+// RUN: FileCheck %s -input-file=%t
+// CHECK: [indexDeclaration]: kind: objc-class | name: I | {{.*}} | loc: 1:12
+// CHECK: [indexDeclaration]: kind: objc-instance-method | name: prop | {{.*}} | loc: 3:2
+// CHECK: [indexDeclaration]: kind: objc-property | name: prop | {{.*}} | loc: 2:25
+// CHECK: [indexDeclaration]: kind: objc-category | name: | {{.*}} | loc: 6:12
+// CHECK: [indexDeclaration]: kind: objc-instance-method | name: setProp: | {{.*}} | loc: 7:33
+// CHECK: [indexDeclaration]: kind: objc-property | name: prop | {{.*}} | loc: 7:33
+
+// CHECK: [indexDeclaration]: kind: objc-ivar | name: _prop | {{.*}} | loc: 11:20
+// CHECK: [indexDeclaration]: kind: objc-instance-method | name: prop | {{.*}} | loc: 11:13 | {{.*}} | lexical-container: [I:10:17]
+// CHECK: [indexDeclaration]: kind: objc-instance-method | name: setProp: | {{.*}} | loc: 11:13 | {{.*}} | lexical-container: [I:10:17]
diff --git a/clang/test/Index/index-invalid-code.m b/clang/test/Index/index-invalid-code.m
new file mode 100644
index 0000000..9084533
--- /dev/null
+++ b/clang/test/Index/index-invalid-code.m
@@ -0,0 +1,8 @@
+struct S {
+ int {
+};
+typedef struct S S;
+
+// RUN: c-index-test -index-file %s | FileCheck %s
+// CHECK: [indexDeclaration]: kind: struct | name: S |
+// CHECK-NOT: [indexDeclaration]: kind: struct | name: S |
diff --git a/clang/test/Index/index-many-logical-ops.c b/clang/test/Index/index-many-logical-ops.c
new file mode 100644
index 0000000..67017de
--- /dev/null
+++ b/clang/test/Index/index-many-logical-ops.c
@@ -0,0 +1,2011 @@
+// RUN: c-index-test -index-file %s | FileCheck %s
+
+// rdar://10941790
+// Check that we don't get stack overflow trying to index a huge number of
+// logical operators.
+
+// CHECK: [indexDeclaration]: kind: function | name: foo
+int foo(int x) {
+ return
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x;
+}
diff --git a/clang/test/Index/index-refs.cpp b/clang/test/Index/index-refs.cpp
new file mode 100644
index 0000000..77e2af7
--- /dev/null
+++ b/clang/test/Index/index-refs.cpp
@@ -0,0 +1,121 @@
+
+namespace NS {
+ extern int gx;
+ typedef int MyInt;
+}
+
+enum {
+ EnumVal = 1
+};
+
+NS::MyInt NS::gx = EnumVal;
+
+void foo() {
+ NS::MyInt x;
+}
+
+enum {
+ SecondVal = EnumVal
+};
+
+struct S {
+ S& operator++();
+ int operator*();
+ S& operator=(int x);
+ S& operator!=(int x);
+ S& operator()(int x);
+};
+
+void foo2(S &s) {
+ (void)++s;
+ (void)*s;
+ s = 3;
+ (void)(s != 3);
+ s(3);
+}
+
+namespace NS {
+ namespace Inn {}
+ typedef int Foo;
+}
+
+using namespace NS;
+using namespace NS::Inn;
+using NS::Foo;
+
+template <typename T1, typename T2>
+struct TS { };
+
+template <typename T>
+struct TS<T, int> {
+ typedef int MyInt;
+};
+
+void foo3() {
+ TS<int, int> s;
+}
+
+const int array_size = 3;
+typedef int some_arr[array_size];
+
+const int default_param = 3;
+void foo4(int p = default_param);
+
+struct S2 {
+ int x,y;
+};
+
+void foo5() {
+ struct S2 s = { .y = 1, .x = 4};
+}
+
+// RUN: c-index-test -index-file %s | FileCheck %s
+// CHECK: [indexDeclaration]: kind: namespace | name: NS
+// CHECK-NEXT: [indexDeclaration]: kind: variable | name: gx
+// CHECK-NEXT: [indexDeclaration]: kind: typedef | name: MyInt
+// CHECK-NEXT: [indexDeclaration]: kind: enum
+// CHECK-NEXT: [indexDeclaration]: kind: enumerator | name: EnumVal
+// CHECK-NEXT: [indexDeclaration]: kind: variable | name: gx
+// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS
+// CHECK-NEXT: [indexEntityReference]: kind: typedef | name: MyInt
+// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS
+// CHECK-NEXT: [indexEntityReference]: kind: enumerator | name: EnumVal
+// CHECK-NEXT: [indexDeclaration]: kind: function | name: foo
+// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS
+// CHECK-NEXT: [indexEntityReference]: kind: typedef | name: MyInt
+// CHECK-NEXT: [indexDeclaration]: kind: enum
+// CHECK-NEXT: [indexDeclaration]: kind: enumerator | name: SecondVal
+// CHECK-NEXT: [indexEntityReference]: kind: enumerator | name: EnumVal
+
+// CHECK: [indexDeclaration]: kind: function | name: foo2
+// CHECK: [indexEntityReference]: kind: c++-instance-method | name: operator++
+// CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: operator*
+// CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: operator=
+// CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: operator!=
+// CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: operator()
+
+// CHECK: [indexEntityReference]: kind: namespace | name: NS | {{.*}} | loc: 42:17
+// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS | {{.*}} | loc: 43:17
+// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: Inn | {{.*}} | loc: 43:21
+// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS | {{.*}} | loc: 44:7
+// CHECK-NEXT: [indexEntityReference]: kind: typedef | name: Foo | {{.*}} | loc: 44:11
+
+// CHECK: [indexDeclaration]: kind: c++-class-template | name: TS | {{.*}} | loc: 47:8
+// CHECK-NEXT: [indexDeclaration]: kind: struct-template-partial-spec | name: TS | USR: c:@SP>1#T@TS>#t0.0#I | {{.*}} | loc: 50:8
+// CHECK-NEXT: [indexDeclaration]: kind: typedef | name: MyInt | USR: c:index-refs.cpp@593@SP>1#T@TS>#t0.0#I@T@MyInt | {{.*}} | loc: 51:15 | semantic-container: [TS:50:8] | lexical-container: [TS:50:8]
+/* when indexing implicit instantiations
+ [indexDeclaration]: kind: struct-template-spec | name: TS | USR: c:@S@TS>#I | {{.*}} | loc: 50:8
+ [indexDeclaration]: kind: typedef | name: MyInt | USR: c:index-refs.cpp@593@S@TS>#I@T@MyInt | {{.*}} | loc: 51:15 | semantic-container: [TS:50:8] | lexical-container: [TS:50:8]
+ */
+// CHECK-NEXT: [indexDeclaration]: kind: function | name: foo3
+/* when indexing implicit instantiations
+ [indexEntityReference]: kind: struct-template-spec | name: TS | USR: c:@S@TS>#I | {{.*}} | loc: 55:3
+*/
+// CHECK-NEXT: [indexEntityReference]: kind: c++-class-template | name: TS | USR: c:@ST>2#T#T@TS | {{.*}} | loc: 55:3
+
+// CHECK: [indexEntityReference]: kind: variable | name: array_size | {{.*}} | loc: 59:22
+// CHECK: [indexEntityReference]: kind: variable | name: default_param | {{.*}} | loc: 62:19
+// CHECK-NOT: [indexEntityReference]: kind: variable | name: default_param | {{.*}} | loc: 62:19
+
+// CHECK: [indexEntityReference]: kind: field | name: y | {{.*}} | loc: 69:20
+// CHECK-NEXT: [indexEntityReference]: kind: field | name: x | {{.*}} | loc: 69:28
diff --git a/clang/test/Index/index-subscripting-literals.m b/clang/test/Index/index-subscripting-literals.m
new file mode 100644
index 0000000..4ecad0b
--- /dev/null
+++ b/clang/test/Index/index-subscripting-literals.m
@@ -0,0 +1,66 @@
+@interface NSArray
+- (id)objectAtIndexedSubscript:(int)index;
++ (id)arrayWithObjects:(id *)objects count:(unsigned)count;
+@end
+
+@interface NSMutableArray : NSArray
+- (id)objectAtIndexedSubscript:(int)index;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary
+- (id)objectForKeyedSubscript:(id)key;
++ (id)dictionaryWithObjects:(id *)objects forKeys:(id *)keys count:(unsigned)count;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@class NSString;
+
+int idx;
+id p;
+
+id testArray() {
+ NSMutableArray *array;
+ array[idx] = p;
+ NSArray *arr = @[ p, p ];
+ return array[idx];
+}
+
+NSString *key;
+id newObject, oldObject;
+
+void testDict() {
+ NSMutableDictionary *dictionary;
+ oldObject = dictionary[key];
+ dictionary[key] = newObject;
+ NSDictionary *dict = @{ key: newObject, key: oldObject };
+}
+
+// RUN: c-index-test -index-file -target x86_64-apple-macosx10.7 %s | FileCheck %s
+
+// CHECK: [indexEntityReference]: kind: variable | name: idx | USR: c:@idx | lang: C | cursor: DeclRefExpr=idx:22:5 | loc: 27:9
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: p | USR: c:@p | lang: C | cursor: DeclRefExpr=p:23:4 | loc: 27:16 | <parent>:: kind: function | name: testArray | USR: c:@F@testArray | lang: C | container: [testArray:25:4] | refkind: direct
+// CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: setObject:atIndexedSubscript:
+// CHECK-NEXT: [indexEntityReference]: kind: objc-class | name: NSArray
+// CHECK-NEXT: [indexEntityReference]: kind: objc-class-method | name: arrayWithObjects:count:
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: p | USR: c:@p | lang: C | cursor: DeclRefExpr=p:23:4 | loc: 28:21
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: p | USR: c:@p | lang: C | cursor: DeclRefExpr=p:23:4 | loc: 28:24
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: idx | USR: c:@idx | lang: C | cursor: DeclRefExpr=idx:22:5 | loc: 29:16
+// CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: objectAtIndexedSubscript:
+// CHECK-NEXT: [indexDeclaration]: kind: variable | name: key
+
+// CHECK: [indexEntityReference]: kind: variable | name: oldObject
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 37:26
+// CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: objectForKeyedSubscript:
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 38:14
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: newObject | USR: c:@newObject | lang: C | cursor: DeclRefExpr=newObject:33:4 | loc: 38:21
+// CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: setObject:forKeyedSubscript:
+// CHECK-NEXT: [indexEntityReference]: kind: objc-class | name: NSDictionary
+// CHECK-NEXT: [indexEntityReference]: kind: objc-class-method | name: dictionaryWithObjects:forKeys:count:
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 39:27
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: newObject | USR: c:@newObject | lang: C | cursor: DeclRefExpr=newObject:33:4 | loc: 39:32
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 39:43
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: oldObject | USR: c:@oldObject | lang: C | cursor: DeclRefExpr=oldObject:33:15 | loc: 39:48
diff --git a/clang/test/Index/index-suppress-refs.cpp b/clang/test/Index/index-suppress-refs.cpp
new file mode 100644
index 0000000..113dd40
--- /dev/null
+++ b/clang/test/Index/index-suppress-refs.cpp
@@ -0,0 +1,12 @@
+
+#include "index-suppress-refs.hpp"
+
+class Sub : B1, B2 {
+ typedef B1 Base1;
+ typedef B2 Base2;
+};
+
+// RUN: env CINDEXTEST_SUPPRESSREFS=1 c-index-test -index-file %s | FileCheck %s
+// CHECK: [indexDeclaration]: kind: c++-class | name: Sub
+// CHECK-NOT: [indexEntityReference]: kind: c++-class | name: B1
+// CHECK-NOT: [indexEntityReference]: kind: c++-class | name: B2
diff --git a/clang/test/Index/index-suppress-refs.h b/clang/test/Index/index-suppress-refs.h
new file mode 100644
index 0000000..03c5624
--- /dev/null
+++ b/clang/test/Index/index-suppress-refs.h
@@ -0,0 +1,9 @@
+
+@interface I
+@end
+
+@interface B
+@end
+
+@protocol P
+@end
diff --git a/clang/test/Index/index-suppress-refs.hpp b/clang/test/Index/index-suppress-refs.hpp
new file mode 100644
index 0000000..4aab08b
--- /dev/null
+++ b/clang/test/Index/index-suppress-refs.hpp
@@ -0,0 +1,3 @@
+
+class B1 {};
+class B2 {};
diff --git a/clang/test/Index/index-suppress-refs.m b/clang/test/Index/index-suppress-refs.m
new file mode 100644
index 0000000..46420ee
--- /dev/null
+++ b/clang/test/Index/index-suppress-refs.m
@@ -0,0 +1,44 @@
+
+#include "index-suppress-refs.h"
+
+#define TYPEDEF(x) typedef int x
+TYPEDEF(MyInt);
+
+MyInt gx;
+
+@class I;
+
+@interface I(cat)
+-(I*)meth;
+@end
+
+@class I;
+
+@interface S : B<P>
+-(void)meth:(B*)b :(id<P>)p;
+@end
+
+// RUN: env CINDEXTEST_SUPPRESSREFS=1 c-index-test -index-file %s | FileCheck %s
+// CHECK: [indexDeclaration]: kind: objc-class | name: I
+// CHECK-NEXT: <ObjCContainerInfo>: kind: interface
+// CHECK-NEXT: [indexDeclaration]: kind: objc-class | name: B
+// CHECK-NEXT: <ObjCContainerInfo>: kind: interface
+// CHECK-NEXT: [indexDeclaration]: kind: objc-protocol | name: P
+// CHECK-NEXT: <ObjCContainerInfo>: kind: interface
+// CHECK-NEXT: [indexDeclaration]: kind: typedef | name: MyInt
+// CHECK-NEXT: [indexDeclaration]: kind: variable | name: gx
+// CHECK-NEXT: [indexDeclaration]: kind: objc-class | name: I
+// CHECK-NEXT: <ObjCContainerInfo>: kind: forward-ref
+// CHECK-NEXT: [indexDeclaration]: kind: objc-category | name: cat
+// CHECK-NEXT: <ObjCContainerInfo>: kind: interface
+// CHECK-NEXT: <ObjCCategoryInfo>: class: kind: objc-class | name: I
+// CHECK-NEXT: [indexDeclaration]: kind: objc-instance-method | name: meth
+// CHECK-NOT: [indexEntityReference]: kind: objc-class | name: I
+// CHECK-NOT: [indexDeclaration]: kind: objc-class | name: I
+// CHECK-NEXT: [indexDeclaration]: kind: objc-class | name: S
+// CHECK-NEXT: <ObjCContainerInfo>: kind: interface
+// CHECK-NEXT: <base>: kind: objc-class | name: B
+// CHECK-NEXT: <protocol>: kind: objc-protocol | name: P
+// CHECK-NEXT: [indexDeclaration]: kind: objc-instance-method | name: meth::
+// CHECK-NOT: [indexEntityReference]: kind: objc-class | name: B
+// CHECK-NOT: [indexEntityReference]: kind: objc-protocol | name: P \ No newline at end of file
diff --git a/clang/test/Index/index-templates.cpp b/clang/test/Index/index-templates.cpp
new file mode 100644
index 0000000..05068df
--- /dev/null
+++ b/clang/test/Index/index-templates.cpp
@@ -0,0 +1,207 @@
+// Test is line- and column-sensitive. See run lines below.
+
+template<typename T, T Value, template<typename U, U ValU> class X>
+void f(X<T, Value> x);
+
+template<typename T> class allocator;
+
+template<typename T, typename Alloc = allocator<T> >
+class vector {
+ void clear();
+};
+
+template<typename T>
+class vector<T*> { };
+
+struct Z1 { };
+
+template class vector<Z1>;
+
+struct Z2 { };
+
+template<>
+class vector<Z2> {
+ void clear();
+};
+
+template<typename T, typename U>
+struct Y {
+ using typename T::type;
+ using U::operator Z2;
+};
+
+struct Z3 { };
+
+const unsigned OneDimension = 1;
+template<typename T, unsigned Dimensions = OneDimension>
+struct array { };
+
+template<template<typename, unsigned> class DataStructure = array>
+struct storage { };
+
+typedef unsigned Unsigned;
+
+template<typename T, Unsigned Value>
+struct value_c;
+
+template class vector<int*>;
+
+struct Z4 {
+ template<typename T> T getAs();
+};
+
+void template_exprs() {
+ f<Unsigned, OneDimension, array>(array<Unsigned, OneDimension>());
+ Z4().getAs<Unsigned>();
+}
+
+template<typename T> void swap(T&, T&);
+template<typename T, typename U> void swap(Y<T, U>&, Y<T, U>&);
+void swap(Z4&, Z4&);
+
+struct Z5 {
+ int f(int);
+ float f(float);
+};
+
+template<typename T>
+void unresolved_exprs(T &x) {
+ swap(x, x);
+ Z5 z5;
+ z5.f(x);
+ swap<T>(x, x);
+}
+
+template<typename T, typename U>
+struct Pair {
+ T first;
+ U second;
+};
+
+template<typename T, typename U>
+void init_list(T t, U u) {
+ typedef U second_type;
+
+ Pair<T, U> p = { t, second_type(u) };
+}
+
+template<typename T>
+struct compare { };
+
+template<typename Key, typename Value,
+ typename Comparison = compare<Pair<Key, Value> >,
+ typename Allocator = allocator<Pair<Key, Value> > >
+struct map;
+
+void f(map<Z4, Pair<int, Z4> >);
+
+template class Pair<int, int>;
+
+template<typename T, typename U>
+struct SuperPair : Pair<int, int>, Pair<T, U> { };
+
+// RUN: c-index-test -test-load-source all -fno-delayed-template-parsing %s | FileCheck -check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: index-templates.cpp:4:6: FunctionTemplate=f:4:6 Extent=[3:1 - 4:22]
+// CHECK-LOAD: index-templates.cpp:3:19: TemplateTypeParameter=T:3:19 (Definition) Extent=[3:10 - 3:20]
+// CHECK-LOAD: index-templates.cpp:3:24: NonTypeTemplateParameter=Value:3:24 (Definition) Extent=[3:22 - 3:29]
+// FIXME: Need the template type parameter here
+// CHECK-LOAD: index-templates.cpp:3:66: TemplateTemplateParameter=X:3:66 (Definition) Extent=[3:31 - 3:67]
+// CHECK-LOAD: index-templates.cpp:4:20: ParmDecl=x:4:20 (Definition) Extent=[4:8 - 4:21]
+// CHECK-LOAD: index-templates.cpp:4:8: TemplateRef=X:3:66 Extent=[4:8 - 4:9]
+// FIXME: Need the template type parameter here
+// CHECK-LOAD: index-templates.cpp:4:13: DeclRefExpr=Value:3:24 Extent=[4:13 - 4:18]
+// CHECK-LOAD: index-templates.cpp:6:28: ClassTemplate=allocator:6:28 Extent=[6:1 - 6:37]
+// CHECK-LOAD: index-templates.cpp:6:19: TemplateTypeParameter=T:6:19 (Definition) Extent=[6:10 - 6:20]
+// CHECK-LOAD: index-templates.cpp:9:7: ClassTemplate=vector:9:7 (Definition) Extent=[8:1 - 11:2]
+// CHECK-LOAD: index-templates.cpp:8:19: TemplateTypeParameter=T:8:19 (Definition) Extent=[8:10 - 8:20]
+// CHECK-LOAD: index-templates.cpp:8:31: TemplateTypeParameter=Alloc:8:31 (Definition) Extent=[8:22 - 8:51]
+// CHECK-LOAD: index-templates.cpp:8:39: TemplateRef=allocator:6:28 Extent=[8:39 - 8:48]
+// CHECK-LOAD: index-templates.cpp:10:8: CXXMethod=clear:10:8 Extent=[10:3 - 10:15]
+// CHECK-LOAD: index-templates.cpp:14:7: ClassTemplatePartialSpecialization=vector:14:7 (Definition) [Specialization of vector:9:7] Extent=[13:1 - 14:21]
+// CHECK-LOAD: index-templates.cpp:13:19: TemplateTypeParameter=T:13:19 (Definition) Extent=[13:10 - 13:20]
+// CHECK-LOAD: index-templates.cpp:16:8: StructDecl=Z1:16:8 (Definition) Extent=[16:1 - 16:14]
+// CHECK-LOAD: index-templates.cpp:18:16: ClassDecl=vector:18:16 (Definition) [Specialization of vector:9:7] Extent=[18:1 - 18:26]
+// CHECK-LOAD: index-templates.cpp:18:23: TypeRef=struct Z1:16:8 Extent=[18:23 - 18:25]
+// CHECK-LOAD-NOT: CXXMethod=clear
+// CHECK-LOAD: index-templates.cpp:20:8: StructDecl=Z2:20:8 (Definition) Extent=[20:1 - 20:14]
+// CHECK-LOAD: index-templates.cpp:23:7: ClassDecl=vector:23:7 (Definition) [Specialization of vector:9:7] Extent=[22:1 - 25:2]
+// CHECK-LOAD: index-templates.cpp:23:14: TypeRef=struct Z2:20:8 Extent=[23:14 - 23:16]
+// CHECK-LOAD: index-templates.cpp:24:8: CXXMethod=clear:24:8 Extent=[24:3 - 24:15]
+// CHECK-LOAD: index-templates.cpp:28:8: ClassTemplate=Y:28:8 (Definition) Extent=[27:1 - 31:2]
+// CHECK-LOAD: index-templates.cpp:27:19: TemplateTypeParameter=T:27:19 (Definition) Extent=[27:10 - 27:20]
+// CHECK-LOAD: index-templates.cpp:27:31: TemplateTypeParameter=U:27:31 (Definition) Extent=[27:22 - 27:32]
+// CHECK-LOAD: index-templates.cpp:29:21: UsingDeclaration=type:29:21 Extent=[29:3 - 29:25]
+// CHECK-LOAD: index-templates.cpp:30:12: UsingDeclaration=operator Z2:30:12 Extent=[30:3 - 30:23]
+// CHECK-LOAD: index-templates.cpp:30:21: TypeRef=struct Z2:20:8 Extent=[30:21 - 30:23]
+// CHECK-LOAD: index-templates.cpp:35:16: VarDecl=OneDimension:35:16 (Definition) Extent=[35:1 - 35:32]
+// CHECK-LOAD: index-templates.cpp:35:31: UnexposedExpr= Extent=[35:31 - 35:32]
+// CHECK-LOAD: index-templates.cpp:35:31: IntegerLiteral= Extent=[35:31 - 35:32]
+// CHECK-LOAD: index-templates.cpp:37:8: ClassTemplate=array:37:8 (Definition) Extent=[36:1 - 37:17]
+// CHECK-LOAD: index-templates.cpp:36:19: TemplateTypeParameter=T:36:19 (Definition) Extent=[36:10 - 36:20]
+// CHECK-LOAD: index-templates.cpp:36:31: NonTypeTemplateParameter=Dimensions:36:31 (Definition) Extent=[36:22 - 36:56]
+// CHECK-LOAD: index-templates.cpp:36:44: DeclRefExpr=OneDimension:35:16 Extent=[36:44 - 36:56]
+// CHECK-LOAD: index-templates.cpp:40:8: ClassTemplate=storage:40:8 (Definition) Extent=[39:1 - 40:19]
+// CHECK-LOAD: index-templates.cpp:39:45: TemplateTemplateParameter=DataStructure:39:45 (Definition) Extent=[39:10 - 39:66]
+// CHECK-LOAD: index-templates.cpp:39:19: TemplateTypeParameter=:39:19 (Definition) Extent=[39:19 - 39:27]
+// CHECK-LOAD: index-templates.cpp:39:37: NonTypeTemplateParameter=:39:37 (Definition) Extent=[39:29 - 39:38]
+// CHECK-LOAD: index-templates.cpp:39:61: TemplateRef=array:37:8 Extent=[39:61 - 39:66]
+// CHECK-LOAD: index-templates.cpp:42:18: TypedefDecl=Unsigned:42:18 (Definition) Extent=[42:1 - 42:26]
+// CHECK-LOAD: index-templates.cpp:45:8: ClassTemplate=value_c:45:8 Extent=[44:1 - 45:15]
+// CHECK-LOAD: index-templates.cpp:44:19: TemplateTypeParameter=T:44:19 (Definition) Extent=[44:10 - 44:20]
+// CHECK-LOAD: index-templates.cpp:44:31: NonTypeTemplateParameter=Value:44:31 (Definition) Extent=[44:22 - 44:36]
+// CHECK-LOAD: index-templates.cpp:44:22: TypeRef=Unsigned:42:18 Extent=[44:22 - 44:30]
+// CHECK-LOAD: index-templates.cpp:47:16: ClassDecl=vector:47:16 (Definition) [Specialization of vector:14:7] Extent=[47:1 - 47:28]
+// CHECK-LOAD: index-templates.cpp:49:8: StructDecl=Z4:49:8 (Definition) Extent=[49:1 - 51:2]
+// CHECK-LOAD: index-templates.cpp:50:26: FunctionTemplate=getAs:50:26 Extent=[50:3 - 50:33]
+// CHECK-LOAD: index-templates.cpp:50:21: TemplateTypeParameter=T:50:21 (Definition) Extent=[50:12 - 50:22]
+// CHECK-LOAD: index-templates.cpp:53:6: FunctionDecl=template_exprs:53:6 (Definition)
+// CHECK-LOAD: index-templates.cpp:54:3: CallExpr=f:4:6 Extent=[54:3 - 54:68]
+// CHECK-LOAD: index-templates.cpp:54:3: UnexposedExpr=f:4:6 Extent=[54:3 - 54:35]
+// CHECK-LOAD: index-templates.cpp:54:3: DeclRefExpr=f:4:6 RefName=[54:3 - 54:4] RefName=[54:4 - 54:35] Extent=[54:3 - 54:35]
+// CHECK-LOAD: index-templates.cpp:54:5: TypeRef=Unsigned:42:18 Extent=[54:5 - 54:13]
+// CHECK-LOAD: index-templates.cpp:54:15: DeclRefExpr=OneDimension:35:16 Extent=[54:15 - 54:27]
+// CHECK-LOAD: index-templates.cpp:54:29: TemplateRef=array:37:8 Extent=[54:29 - 54:34]
+// CHECK-LOAD: index-templates.cpp:55:8: MemberRefExpr=getAs:50:26 SingleRefName=[55:8 - 55:13] RefName=[55:8 - 55:13] Extent=[55:3 - 55:23]
+// CHECK-LOAD: index-templates.cpp:55:3: CallExpr=Z4:49:8 Extent=[55:3 - 55:7]
+// CHECK-LOAD: index-templates.cpp:55:14: TypeRef=Unsigned:42:18 Extent=[55:14 - 55:22]
+// CHECK-LOAD: index-templates.cpp:68:6: FunctionTemplate=unresolved_exprs:68:6 (Definition)
+// CHECK-LOAD: index-templates.cpp:69:3: OverloadedDeclRef=swap[60:6, 59:39, 58:27]
+// CHECK-LOAD: index-templates.cpp:71:6: OverloadedDeclRef=f[63:7, 64:9]
+// CHECK-LOAD: index-templates.cpp:72:3: OverloadedDeclRef=swap[58:27, 59:39]
+// CHECK-LOAD: index-templates.cpp:82:6: FunctionTemplate=init_list:82:6 (Definition)
+// CHECK-LOAD: index-templates.cpp:85:14: VarDecl=p:85:14 (Definition)
+// CHECK-LOAD: index-templates.cpp:85:20: DeclRefExpr=t:82:18 Extent=[85:20 - 85:21]
+// CHECK-LOAD: index-templates.cpp:85:23: TypeRef=second_type:83:13 Extent=[85:23 - 85:34]
+// CHECK-LOAD: index-templates.cpp:85:35: DeclRefExpr=u:82:23 Extent=[85:35 - 85:36]
+// CHECK-LOAD: index-templates.cpp:101:8: ClassTemplate=SuperPair:101:8 (Definition) Extent=[100:1 - 101:50]
+// CHECK-LOAD: index-templates.cpp:100:19: TemplateTypeParameter=T:100:19 (Definition) Extent=[100:10 - 100:20]
+// CHECK-LOAD: index-templates.cpp:100:31: TemplateTypeParameter=U:100:31 (Definition) Extent=[100:22 - 100:32]
+// CHECK-LOAD: index-templates.cpp:101:20: C++ base class specifier=Pair<int, int>:98:16 [access=public isVirtual=false] Extent=[101:20 - 101:34]
+// CHECK-LOAD: index-templates.cpp:101:36: C++ base class specifier=Pair<T, U>:76:8 [access=public isVirtual=false] Extent=[101:36 - 101:46]
+
+
+// RUN: c-index-test -test-load-source-usrs all -fno-delayed-template-parsing %s | FileCheck -check-prefix=CHECK-USRS %s
+// CHECK-USRS: index-templates.cpp c:@FT@>3#T#Nt0.0#t>2#T#Nt1.0f#>t0.22S0_# Extent=[3:1 - 4:22]
+// CHECK-USRS: index-templates.cpp c:index-templates.cpp@70 Extent=[3:10 - 3:20]
+// CHECK-USRS: index-templates.cpp c:index-templates.cpp@82 Extent=[3:22 - 3:29]
+// CHECK-USRS: index-templates.cpp c:index-templates.cpp@91 Extent=[3:31 - 3:67]
+// CHECK-USRS: index-templates.cpp c:index-templates.cpp@136@FT@>3#T#Nt0.0#t>2#T#Nt1.0f#>t0.22S0_#@x Extent=[4:8 - 4:21]
+// CHECK-USRS: index-templates.cpp c:@CT>1#T@allocator Extent=[6:1 - 6:37]
+// CHECK-USRS: index-templates.cpp c:index-templates.cpp@162 Extent=[6:10 - 6:20]
+// CHECK-USRS: index-templates.cpp c:@CT>2#T#T@vector Extent=[8:1 - 11:2]
+// CHECK-USRS: index-templates.cpp c:index-templates.cpp@201 Extent=[8:10 - 8:20]
+// CHECK-USRS: index-templates.cpp c:index-templates.cpp@213 Extent=[8:22 - 8:51]
+// CHECK-USRS: index-templates.cpp c:@CT>2#T#T@vector@F@clear# Extent=[10:3 - 10:15]
+// CHECK-USRS: index-templates.cpp c:@CP>1#T@vector>#*t0.0#>@CT>1#T@allocator1S0_ Extent=[13:1 - 14:21]
+// CHECK-USRS: index-templates.cpp c:index-templates.cpp@289 Extent=[13:10 - 13:20]
+// CHECK-USRS: index-templates.cpp c:@S@Z1 Extent=[16:1 - 16:14]
+// CHECK-USRS: index-templates.cpp c:@C@vector>#$@S@Z1#$@C@allocator>#S0_ Extent=[18:1 - 18:26]
+// CHECK-USRS: index-templates.cpp c:@S@Z2 Extent=[20:1 - 20:14]
+// CHECK-USRS: index-templates.cpp c:@C@vector>#$@S@Z2#$@C@allocator>#S0_ Extent=[22:1 - 25:2]
+// CHECK-USRS: index-templates.cpp c:@C@vector>#$@S@Z2#$@C@allocator>#S0_@F@clear# Extent=[24:3 - 24:15]
+// CHECK-USRS: index-templates.cpp c:@ST>2#T#T@Y Extent=[27:1 - 31:2]
+// CHECK-USRS: index-templates.cpp c:index-templates.cpp@443 Extent=[27:10 - 27:20]
+// CHECK-USRS: index-templates.cpp c:index-templates.cpp@455 Extent=[27:22 - 27:32]
+// CHECK-USRS-NOT: type
+// CHECK-USRS: index-templates.cpp c:@S@Z3 Extent=[33:1 - 33:14]
+// CHECK-USRS: index-templates.cpp c:@F@f#$@S@map>#$@S@Z4#$@S@Pair>#I#S1_#$@S@compare>#$@S@Pair>#S1_#S2_#$@C@allocator>#S4_#
diff --git a/clang/test/Index/initializer-memory.cpp b/clang/test/Index/initializer-memory.cpp
new file mode 100644
index 0000000..f085c35
--- /dev/null
+++ b/clang/test/Index/initializer-memory.cpp
@@ -0,0 +1,16 @@
+// RUN: c-index-test -test-load-source-memory-usage none %s 2>&1 | FileCheck %s
+
+// rdar://9275920 - We would create millions of Exprs to fill out the initializer.
+
+double data[1000000] = {0};
+double data_empty_init[1000000] = {};
+
+struct S {
+ S(int);
+ S();
+};
+
+S data2[1000000] = {0};
+S data_empty_init2[1000000] = {};
+
+// CHECK: TOTAL = {{.*}} (0.{{.*}} MBytes)
diff --git a/clang/test/Index/invalid-code-rdar10451854.m b/clang/test/Index/invalid-code-rdar10451854.m
new file mode 100644
index 0000000..1562671
--- /dev/null
+++ b/clang/test/Index/invalid-code-rdar10451854.m
@@ -0,0 +1,15 @@
+struct {
+
+@implementation Foo
+
+- (void)finalize {
+ NSLog(@"bar");
+}
+
+- (NSArray *)graphics {
+}
+
+@end
+
+// Test that we don't crash
+// RUN: c-index-test -test-load-source-reparse 3 local %s
diff --git a/clang/test/Index/invalid-code-rdar_7833619.m b/clang/test/Index/invalid-code-rdar_7833619.m
new file mode 100644
index 0000000..0034539
--- /dev/null
+++ b/clang/test/Index/invalid-code-rdar_7833619.m
@@ -0,0 +1,4 @@
+// RUN: c-index-test -test-load-source all %s
+// All we care about in this test is that it doesn't crash.
+typedef r7833619_a (*r7833619_b)(r7833619_c *r7833619_d, r7833619_c *r7833619_e);
+
diff --git a/clang/test/Index/invalid-rdar-8236270.cpp b/clang/test/Index/invalid-rdar-8236270.cpp
new file mode 100644
index 0000000..85a0eaa
--- /dev/null
+++ b/clang/test/Index/invalid-rdar-8236270.cpp
@@ -0,0 +1,11 @@
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+
+// This test case previously just crashed the frontend.
+
+struct abc *P;
+int main(
+
+// CHECK: StructDecl=abc:5:8 Extent=[5:1 - 5:11]
+// CHECK: VarDecl=P:5:13 (Definition) Extent=[5:1 - 5:14]
+// CHECK: VarDecl=main:6:5 (Definition) Extent=[6:1 - 6:9]
+
diff --git a/clang/test/Index/linkage.c b/clang/test/Index/linkage.c
new file mode 100644
index 0000000..41a1fbd
--- /dev/null
+++ b/clang/test/Index/linkage.c
@@ -0,0 +1,30 @@
+// RUN: c-index-test -test-print-linkage-source %s | FileCheck %s
+
+enum Baz { Qux = 0 };
+int x;
+void foo();
+static int w;
+void bar(int y) {
+ static int z;
+ int k;
+}
+extern int n;
+static int wibble(int);
+
+void ena(int (*dio)(int tria));
+
+// CHECK: EnumDecl=Baz:3:6 (Definition)linkage=External
+// CHECK: EnumConstantDecl=Qux:3:12 (Definition)linkage=External
+// CHECK: VarDecl=x:4:5linkage=External
+// CHECK: FunctionDecl=foo:5:6linkage=External
+// CHECK: VarDecl=w:6:12linkage=Internal
+// CHECK: FunctionDecl=bar:7:6 (Definition)linkage=External
+// CHECK: ParmDecl=y:7:14 (Definition)linkage=NoLinkage
+// CHECK: VarDecl=z:8:14 (Definition)linkage=NoLinkage
+// CHECK: VarDecl=k:9:7 (Definition)linkage=NoLinkage
+// CHECK: VarDecl=n:11:12linkage=External
+// CHECK: FunctionDecl=wibble:12:12linkage=Internal
+// CHECK: ParmDecl=:12:22 (Definition)linkage=NoLinkage
+// CHECK: FunctionDecl=ena:14:6linkage=External
+// CHECK: ParmDecl=dio:14:16 (Definition)linkage=NoLinkage
+// CHECK: ParmDecl=tria:14:25 (Definition)linkage=NoLinkage
diff --git a/clang/test/Index/load-classes.cpp b/clang/test/Index/load-classes.cpp
new file mode 100644
index 0000000..5877019
--- /dev/null
+++ b/clang/test/Index/load-classes.cpp
@@ -0,0 +1,28 @@
+// Test is line- and column-sensitive; see below.
+
+struct X {
+ X(int value);
+ X(const X& x);
+ ~X();
+ operator X*();
+};
+
+X::X(int value) {
+}
+
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+// CHECK: load-classes.cpp:3:8: StructDecl=X:3:8 (Definition) Extent=[3:1 - 8:2]
+// CHECK: load-classes.cpp:4:3: CXXConstructor=X:4:3 Extent=[4:3 - 4:15]
+// FIXME: missing TypeRef in the constructor name
+// CHECK: load-classes.cpp:4:9: ParmDecl=value:4:9 (Definition) Extent=[4:5 - 4:14]
+// CHECK: load-classes.cpp:5:3: CXXConstructor=X:5:3 Extent=[5:3 - 5:16]
+// FIXME: missing TypeRef in the constructor name
+// CHECK: load-classes.cpp:5:14: ParmDecl=x:5:14 (Definition) Extent=[5:5 - 5:15]
+// CHECK: load-classes.cpp:5:11: TypeRef=struct X:3:8 Extent=[5:11 - 5:12]
+// CHECK: load-classes.cpp:6:3: CXXDestructor=~X:6:3 Extent=[6:3 - 6:7]
+// FIXME: missing TypeRef in the destructor name
+// CHECK: load-classes.cpp:7:3: CXXConversion=operator struct X *:7:3 Extent=[7:3 - 7:16]
+// CHECK: load-classes.cpp:7:12: TypeRef=struct X:3:8 Extent=[7:12 - 7:13]
+// CHECK: load-classes.cpp:10:4: CXXConstructor=X:10:4 (Definition) Extent=[10:1 - 11:2]
+// CHECK: load-classes.cpp:10:1: TypeRef=struct X:3:8 Extent=[10:1 - 10:2]
+// CHECK: load-classes.cpp:10:10: ParmDecl=value:10:10 (Definition) Extent=[10:6 - 10:15]
diff --git a/clang/test/Index/load-decls.c b/clang/test/Index/load-decls.c
new file mode 100644
index 0000000..e0617c0
--- /dev/null
+++ b/clang/test/Index/load-decls.c
@@ -0,0 +1,15 @@
+enum Color {
+ Red,
+ Green,
+ Blue,
+
+ Rouge = Red
+};
+
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+// CHECK: load-decls.c:1:6: EnumDecl=Color:1:6 (Definition) Extent=[1:1 - 7:2]
+// CHECK: load-decls.c:2:3: EnumConstantDecl=Red:2:3 (Definition) Extent=[2:3 - 2:6]
+// CHECK: load-decls.c:3:3: EnumConstantDecl=Green:3:3 (Definition) Extent=[3:3 - 3:8]
+// CHECK: load-decls.c:4:3: EnumConstantDecl=Blue:4:3 (Definition) Extent=[4:3 - 4:7]
+// CHECK: load-decls.c:6:3: EnumConstantDecl=Rouge:6:3 (Definition) Extent=[6:3 - 6:14]
+// CHECK: load-decls.c:6:11: DeclRefExpr=Red:2:3 Extent=[6:11 - 6:14]
diff --git a/clang/test/Index/load-exprs.c b/clang/test/Index/load-exprs.c
new file mode 100644
index 0000000..a4723d8
--- /dev/null
+++ b/clang/test/Index/load-exprs.c
@@ -0,0 +1,81 @@
+typedef int T;
+struct X { int a, b; };
+void f(void *ptr) {
+ T* t_ptr = (T *)ptr;
+ (void)sizeof(T);
+ struct X x = (struct X){1, 2};
+ void *xx = ptr ? : &x;
+}
+
+int test_blocks(int x) {
+ __block int y = x;
+ ^{
+ static int z = 0;
+ y = (++z) + x;
+ ^{
+ ++z;
+ ++y;
+ }();
+ }();
+ return y;
+}
+
+struct Y {
+ struct X array[3];
+};
+
+enum { StartIndex = 1 };
+
+void test_members(int aval, int bval) {
+ struct Y y0 = { .array[StartIndex].b = bval, .array[StartIndex].a = aval };
+ __builtin_offsetof(struct Y, array[StartIndex].b);
+}
+
+// RUN: c-index-test -test-load-source all %s -fblocks | FileCheck %s
+// CHECK: macro definition=__clang__
+// CHECK: load-exprs.c:1:13: TypedefDecl=T:1:13 (Definition) Extent=[1:1 - 1:14]
+// CHECK: load-exprs.c:2:8: StructDecl=X:2:8 (Definition) Extent=[2:1 - 2:23]
+// CHECK: load-exprs.c:2:16: FieldDecl=a:2:16 (Definition) Extent=[2:12 - 2:17]
+// CHECK: load-exprs.c:2:19: FieldDecl=b:2:19 (Definition) Extent=[2:12 - 2:20]
+// CHECK: load-exprs.c:3:6: FunctionDecl=f:3:6 (Definition) Extent=[3:1 - 8:2]
+// CHECK: load-exprs.c:3:14: ParmDecl=ptr:3:14 (Definition) Extent=[3:8 - 3:17]
+// CHECK: load-exprs.c:4:6: VarDecl=t_ptr:4:6 (Definition) Extent=[4:3 - 4:22]
+// CHECK: load-exprs.c:4:3: TypeRef=T:1:13 Extent=[4:3 - 4:4]
+// CHECK: load-exprs.c:4:15: TypeRef=T:1:13 Extent=[4:15 - 4:16]
+// CHECK: load-exprs.c:4:19: DeclRefExpr=ptr:3:14 Extent=[4:19 - 4:22]
+// CHECK: load-exprs.c:5:16: TypeRef=T:1:13 Extent=[5:16 - 5:17]
+// CHECK: load-exprs.c:6:12: VarDecl=x:6:12 (Definition) Extent=[6:3 - 6:32]
+// CHECK: load-exprs.c:6:10: TypeRef=struct X:2:8 Extent=[6:10 - 6:11]
+// CHECK: load-exprs.c:6:24: TypeRef=struct X:2:8 Extent=[6:24 - 6:25]
+// CHECK: load-exprs.c:7:9: VarDecl=xx:7:9 (Definition) Extent=[7:3 - 7:24]
+// CHECK: load-exprs.c:7:14: DeclRefExpr=ptr:3:14 Extent=[7:14 - 7:17]
+// CHECK: load-exprs.c:7:23: DeclRefExpr=x:6:12 Extent=[7:23 - 7:24]
+// CHECK: load-exprs.c:10:5: FunctionDecl=test_blocks:10:5 (Definition) Extent=[10:1 - 21:2]
+// CHECK: load-exprs.c:10:21: ParmDecl=x:10:21 (Definition) Extent=[10:17 - 10:22]
+// CHECK: load-exprs.c:11:15: VarDecl=y:11:15 (Definition) Extent=[11:3 - 11:20]
+// CHECK: load-exprs.c:11:19: DeclRefExpr=x:10:21 Extent=[11:19 - 11:20]
+// CHECK: load-exprs.c:12:3: CallExpr= Extent=[12:3 - 19:7]
+// CHECK: load-exprs.c:13:17: VarDecl=z:13:17 (Definition) Extent=[13:6 - 13:22]
+// CHECK: load-exprs.c:14:6: DeclRefExpr=y:11:15 Extent=[14:6 - 14:7]
+// CHECK: load-exprs.c:14:13: DeclRefExpr=z:13:17 Extent=[14:13 - 14:14]
+// CHECK: load-exprs.c:14:18: DeclRefExpr=x:10:21 Extent=[14:18 - 14:19]
+// CHECK: load-exprs.c:15:6: CallExpr= Extent=[15:6 - 18:9]
+// CHECK: load-exprs.c:16:10: DeclRefExpr=z:13:17 Extent=[16:10 - 16:11]
+// CHECK: load-exprs.c:17:10: DeclRefExpr=y:11:15 Extent=[17:10 - 17:11]
+// CHECK: load-exprs.c:20:10: DeclRefExpr=y:11:15 Extent=[20:10 - 20:11]
+// CHECK: load-exprs.c:29:6: FunctionDecl=test_members:29:6 (Definition)
+// CHECK: load-exprs.c:30:12: VarDecl=y0:30:12 (Definition) Extent=[30:3 - 30:77]
+// CHECK: load-exprs.c:30:10: TypeRef=struct Y:23:8 Extent=[30:10 - 30:11]
+// CHECK: load-exprs.c:30:20: MemberRef=array:24:12 Extent=[30:20 - 30:25]
+// CHECK: load-exprs.c:30:26: DeclRefExpr=StartIndex:27:8 Extent=[30:26 - 30:36]
+// CHECK: load-exprs.c:30:38: MemberRef=b:2:19 Extent=[30:38 - 30:39]
+// CHECK: load-exprs.c:30:42: DeclRefExpr=bval:29:33 Extent=[30:42 - 30:46]
+// CHECK: load-exprs.c:30:49: MemberRef=array:24:12 Extent=[30:49 - 30:54]
+// CHECK: load-exprs.c:30:55: DeclRefExpr=StartIndex:27:8 Extent=[30:55 - 30:65]
+// CHECK: load-exprs.c:30:67: MemberRef=a:2:16 Extent=[30:67 - 30:68]
+// CHECK: load-exprs.c:30:71: DeclRefExpr=aval:29:23 Extent=[30:71 - 30:75]
+// CHECK: load-exprs.c:31:29: TypeRef=struct Y:23:8 Extent=[31:29 - 31:30]
+// CHECK: load-exprs.c:31:32: MemberRef=array:24:12 Extent=[31:32 - 31:37]
+// CHECK: load-exprs.c:31:38: DeclRefExpr=StartIndex:27:8 Extent=[31:38 - 31:48]
+// CHECK: load-exprs.c:31:50: MemberRef=b:2:19 Extent=[31:50 - 31:51]
+
diff --git a/clang/test/Index/load-namespaces.cpp b/clang/test/Index/load-namespaces.cpp
new file mode 100644
index 0000000..49de66a
--- /dev/null
+++ b/clang/test/Index/load-namespaces.cpp
@@ -0,0 +1,50 @@
+// Test is line- and column-sensitive; see below.
+
+namespace std {
+ namespace rel_ops {
+ void f();
+ }
+}
+
+namespace std {
+ void g();
+}
+
+namespace std98 = std;
+namespace std0x = std98;
+
+using namespace std0x;
+
+namespace std {
+ int g(int);
+}
+
+using std::g;
+
+void std::g() {
+}
+
+namespace my_rel_ops = std::rel_ops;
+
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+// CHECK: load-namespaces.cpp:3:11: Namespace=std:3:11 (Definition) Extent=[3:1 - 7:2]
+// CHECK: load-namespaces.cpp:4:13: Namespace=rel_ops:4:13 (Definition) Extent=[4:3 - 6:4]
+// CHECK: load-namespaces.cpp:5:10: FunctionDecl=f:5:10 Extent=[5:5 - 5:13]
+// CHECK: load-namespaces.cpp:9:11: Namespace=std:9:11 (Definition) Extent=[9:1 - 11:2]
+// CHECK: load-namespaces.cpp:10:8: FunctionDecl=g:10:8 Extent=[10:3 - 10:11]
+// CHECK: load-namespaces.cpp:13:11: NamespaceAlias=std98:13:11 Extent=[13:1 - 13:22]
+// CHECK: load-namespaces.cpp:13:19: NamespaceRef=std:3:11 Extent=[13:19 - 13:22]
+// CHECK: load-namespaces.cpp:14:11: NamespaceAlias=std0x:14:11 Extent=[14:1 - 14:24]
+// CHECK: load-namespaces.cpp:14:19: NamespaceRef=std98:13:11 Extent=[14:19 - 14:24]
+// CHECK: load-namespaces.cpp:16:17: UsingDirective=:16:17 Extent=[16:1 - 16:22]
+// CHECK: load-namespaces.cpp:16:17: NamespaceRef=std0x:14:11 Extent=[16:17 - 16:22]
+// CHECK: load-namespaces.cpp:18:11: Namespace=std:18:11 (Definition) Extent=[18:1 - 20:2]
+// CHECK: load-namespaces.cpp:19:7: FunctionDecl=g:19:7 Extent=[19:3 - 19:13]
+// CHECK: load-namespaces.cpp:19:12: ParmDecl=:19:12 (Definition) Extent=[19:9 - 19:13]
+// CHECK: load-namespaces.cpp:22:12: UsingDeclaration=g[19:7, 10:8] Extent=[22:1 - 22:13]
+// CHECK: load-namespaces.cpp:22:7: NamespaceRef=std:18:11 Extent=[22:7 - 22:10]
+// CHECK: load-namespaces.cpp:24:11: FunctionDecl=g:24:11 (Definition) Extent=[24:1 - 25:2]
+// CHECK: load-namespaces.cpp:24:6: NamespaceRef=std:18:11 Extent=[24:6 - 24:9]
+// CHECK: load-namespaces.cpp:27:11: NamespaceAlias=my_rel_ops:27:11 Extent=[27:1 - 27:36]
+// CHECK: load-namespaces.cpp:27:24: NamespaceRef=std:18:11 Extent=[27:24 - 27:27]
+// CHECK: load-namespaces.cpp:27:29: NamespaceRef=rel_ops:4:13 Extent=[27:29 - 27:36]
diff --git a/clang/test/Index/load-stmts.cpp b/clang/test/Index/load-stmts.cpp
new file mode 100644
index 0000000..ed0debd
--- /dev/null
+++ b/clang/test/Index/load-stmts.cpp
@@ -0,0 +1,231 @@
+typedef int T;
+struct X { int a, b; };
+void f(int x) {
+ for (T y = x; T z = x; ++x) {
+ }
+ if (T *z2 = &x) { }
+ while (T *z3 = &x) { }
+ switch (T z4 = x) {
+ case 17: break;
+ }
+}
+
+// Test handling of C++ base specifiers.
+class A {
+ void doA();
+};
+
+class B {
+ void doB();
+};
+
+class C : public A, private B {
+ void doC();
+};
+
+class D : virtual public C, virtual private A {};
+
+namespace std {
+ class type_info { };
+}
+
+void test_exprs(C *c) {
+ int typeid_marker;
+ typeid(C);
+ typeid(c);
+ typedef int Integer;
+ Integer *int_ptr;
+ int_ptr->Integer::~Integer();
+}
+
+namespace N {
+ int f(int);
+ float f(float);
+
+ template<typename T> T g(T);
+ template<typename T> T g(T*);
+}
+
+template<typename T>
+void test_dependent_exprs(T t) {
+ N::f(t);
+ typedef T type;
+ N::g<type>(t);
+ type::template f<type*>(t);
+ t->type::template f<type*>();
+}
+
+struct Y {
+ int f(int);
+ float f(float);
+
+ template<typename T> T g(T);
+ template<typename T> T g(T*);
+};
+
+template<typename T>
+void test_more_dependent_exprs(T t, Y y) {
+ y.Y::f(t);
+ typedef T type;
+ y.g<type>(t);
+}
+
+struct Pair {
+ Pair(int, int);
+};
+
+void *operator new(__SIZE_TYPE__, void*) throw();
+
+void test_more_exprs(void *mem, int i, int j) {
+ new (mem) Pair(i, j);
+ typedef int Integer;
+ (void)Integer(i);
+ (Integer)i;
+ Integer();
+}
+
+template<typename T>
+void test_even_more_dependent_exprs(T t, Y y) {
+ typedef T type;
+ (void)type(t, y);
+ (void)__has_nothrow_assign(type);
+}
+
+struct Base {
+ Base(int);
+};
+
+struct Derived : public Base {
+ Derived(int x);
+ int member;
+};
+
+Derived::Derived(int x)
+ : member(x), Base(x) {
+}
+
+void considered_harmful(int x) {
+ start_over:
+ void *ptr = &&start_over;
+ if (x > 17)
+ goto *ptr;
+ else
+ goto start_over;
+}
+
+void casts(int *ip) {
+ (void)reinterpret_cast<float *>(ip);
+}
+
+// RUN: c-index-test -test-load-source all -fno-delayed-template-parsing %s | FileCheck %s
+// CHECK: load-stmts.cpp:1:13: TypedefDecl=T:1:13 (Definition) Extent=[1:1 - 1:14]
+// CHECK: load-stmts.cpp:2:8: StructDecl=X:2:8 (Definition) Extent=[2:1 - 2:23]
+// CHECK: load-stmts.cpp:2:16: FieldDecl=a:2:16 (Definition) Extent=[2:12 - 2:17]
+// CHECK: load-stmts.cpp:2:19: FieldDecl=b:2:19 (Definition) Extent=[2:12 - 2:20]
+// CHECK: load-stmts.cpp:3:6: FunctionDecl=f:3:6 (Definition) Extent=[3:1 - 11:2]
+// CHECK: load-stmts.cpp:3:12: ParmDecl=x:3:12 (Definition) Extent=[3:8 - 3:13]
+// CHECK: load-stmts.cpp:4:10: VarDecl=y:4:10 (Definition) Extent=[4:8 - 4:15]
+// CHECK: load-stmts.cpp:4:8: TypeRef=T:1:13 Extent=[4:8 - 4:9]
+// CHECK: load-stmts.cpp:4:14: DeclRefExpr=x:3:12 Extent=[4:14 - 4:15]
+// CHECK: load-stmts.cpp:4:19: VarDecl=z:4:19 (Definition) Extent=[4:17 - 4:24]
+// CHECK: load-stmts.cpp:4:17: TypeRef=T:1:13 Extent=[4:17 - 4:18]
+// CHECK: load-stmts.cpp:4:23: DeclRefExpr=x:3:12 Extent=[4:23 - 4:24]
+// CHECK: load-stmts.cpp:4:19: UnexposedExpr=z:4:19 Extent=[4:19 - 4:20]
+// CHECK: load-stmts.cpp:4:19: DeclRefExpr=z:4:19 Extent=[4:19 - 4:20]
+// CHECK: load-stmts.cpp:4:26: UnaryOperator= Extent=[4:26 - 4:29]
+// CHECK: load-stmts.cpp:4:28: DeclRefExpr=x:3:12 Extent=[4:28 - 4:29]
+// CHECK: load-stmts.cpp:6:10: VarDecl=z2:6:10 (Definition) Extent=[6:7 - 6:17]
+// CHECK: load-stmts.cpp:6:7: TypeRef=T:1:13 Extent=[6:7 - 6:8]
+// CHECK: load-stmts.cpp:6:15: UnaryOperator= Extent=[6:15 - 6:17]
+// CHECK: load-stmts.cpp:6:16: DeclRefExpr=x:3:12 Extent=[6:16 - 6:17]
+// CHECK: load-stmts.cpp:6:10: UnexposedExpr=z2:6:10 Extent=[6:10 - 6:12]
+// CHECK: load-stmts.cpp:6:10: DeclRefExpr=z2:6:10 Extent=[6:10 - 6:12]
+// CHECK: load-stmts.cpp:7:13: VarDecl=z3:7:13 (Definition) Extent=[7:10 - 7:20]
+// CHECK: load-stmts.cpp:7:10: TypeRef=T:1:13 Extent=[7:10 - 7:11]
+// CHECK: load-stmts.cpp:7:18: UnaryOperator= Extent=[7:18 - 7:20]
+// CHECK: load-stmts.cpp:7:19: DeclRefExpr=x:3:12 Extent=[7:19 - 7:20]
+// CHECK: load-stmts.cpp:7:13: UnexposedExpr=z3:7:13 Extent=[7:13 - 7:15]
+// CHECK: load-stmts.cpp:7:13: DeclRefExpr=z3:7:13 Extent=[7:13 - 7:15]
+// CHECK: load-stmts.cpp:8:13: VarDecl=z4:8:13 (Definition) Extent=[8:11 - 8:19]
+// CHECK: load-stmts.cpp:8:11: TypeRef=T:1:13 Extent=[8:11 - 8:12]
+// CHECK: load-stmts.cpp:8:18: DeclRefExpr=x:3:12 Extent=[8:18 - 8:19]
+// CHECK: load-stmts.cpp:8:13: DeclRefExpr=z4:8:13 Extent=[8:13 - 8:15]
+// CHECK: load-stmts.cpp:9:8: IntegerLiteral= Extent=[9:8 - 9:10]
+// CHECK: load-stmts.cpp:14:7: ClassDecl=A:14:7 (Definition) Extent=[14:1 - 16:2]
+// CHECK: load-stmts.cpp:15:8: CXXMethod=doA:15:8 Extent=[15:3 - 15:13]
+// CHECK: load-stmts.cpp:18:7: ClassDecl=B:18:7 (Definition) Extent=[18:1 - 20:2]
+// CHECK: load-stmts.cpp:19:8: CXXMethod=doB:19:8 Extent=[19:3 - 19:13]
+// CHECK: load-stmts.cpp:22:7: ClassDecl=C:22:7 (Definition) Extent=[22:1 - 24:2]
+// CHECK: load-stmts.cpp:22:18: C++ base class specifier=class A:14:7 [access=public isVirtual=false]
+// CHECK: load-stmts.cpp:22:29: C++ base class specifier=class B:18:7 [access=private isVirtual=false]
+// CHECK: load-stmts.cpp:23:8: CXXMethod=doC:23:8 Extent=[23:3 - 23:13]
+// CHECK: load-stmts.cpp:26:7: ClassDecl=D:26:7 (Definition) Extent=[26:1 - 26:49]
+// CHECK: load-stmts.cpp:26:26: C++ base class specifier=class C:22:7 [access=public isVirtual=true]
+// CHECK: load-stmts.cpp:26:45: C++ base class specifier=class A:14:7 [access=private isVirtual=true]
+// CHECK: load-stmts.cpp:33:7: VarDecl=typeid_marker:33:7 (Definition)
+// CHECK: load-stmts.cpp:34:10: TypeRef=class C:22:7 Extent=[34:10 - 34:11]
+// CHECK: load-stmts.cpp:35:10: DeclRefExpr=c:32:20 Extent=[35:10 - 35:11]
+// CHECK: load-stmts.cpp:37:12: VarDecl=int_ptr:37:12 (Definition) Extent=[37:3 - 37:19]
+// CHECK: load-stmts.cpp:37:3: TypeRef=Integer:36:15 Extent=[37:3 - 37:10]
+// CHECK: load-stmts.cpp:38:3: DeclRefExpr=int_ptr:37:12 Extent=[38:3 - 38:10]
+// CHECK: load-stmts.cpp:38:12: TypeRef=Integer:36:15 Extent=[38:12 - 38:19]
+// CHECK: load-stmts.cpp:38:22: TypeRef=Integer:36:15 Extent=[38:22 - 38:29]
+// CHECK: load-stmts.cpp:50:6: FunctionTemplate=test_dependent_exprs:50:6 (Definition)
+// CHECK: load-stmts.cpp:51:3: CallExpr= Extent=[51:3 - 51:10]
+// CHECK: load-stmts.cpp:51:3: NamespaceRef=N:41:11 Extent=[51:3 - 51:4]
+// CHECK: load-stmts.cpp:51:8: DeclRefExpr=t:50:29 Extent=[51:8 - 51:9]
+// CHECK: load-stmts.cpp:52:13: TypedefDecl=type:52:13 (Definition) Extent=[52:3 - 52:17]
+// CHECK: load-stmts.cpp:53:3: CallExpr= Extent=[53:3 - 53:16]
+// CHECK: load-stmts.cpp:53:3: NamespaceRef=N:41:11 Extent=[53:3 - 53:4]
+// CHECK: load-stmts.cpp:53:8: TypeRef=type:52:13 Extent=[53:8 - 53:12]
+// CHECK: load-stmts.cpp:53:14: DeclRefExpr=t:50:29 Extent=[53:14 - 53:15]
+// CHECK: load-stmts.cpp:54:3: CallExpr= Extent=[54:3 - 54:29]
+// CHECK: load-stmts.cpp:54:3: TypeRef=type:52:13 Extent=[54:3 - 54:7]
+// CHECK: load-stmts.cpp:54:20: TypeRef=type:52:13 Extent=[54:20 - 54:24]
+// CHECK: load-stmts.cpp:54:27: DeclRefExpr=t:50:29 Extent=[54:27 - 54:28]
+// CHECK: load-stmts.cpp:55:3: CallExpr= Extent=[55:3 - 55:31]
+// CHECK: load-stmts.cpp:55:3: DeclRefExpr=t:50:29 Extent=[55:3 - 55:4]
+// CHECK: load-stmts.cpp:55:23: TypeRef=type:52:13 Extent=[55:23 - 55:27]
+// CHECK: load-stmts.cpp:67:6: FunctionTemplate=test_more_dependent_exprs:67:6 (Definition)
+// CHECK: load-stmts.cpp:68:3: CallExpr= Extent=[68:3 - 68:12]
+// CHECK: load-stmts.cpp:68:3: DeclRefExpr=y:67:39 Extent=[68:3 - 68:4]
+// CHECK: load-stmts.cpp:68:5: TypeRef=struct Y:58:8 Extent=[68:5 - 68:6]
+// CHECK: load-stmts.cpp:68:10: DeclRefExpr=t:67:34 Extent=[68:10 - 68:11]
+// CHECK: load-stmts.cpp:70:3: CallExpr= Extent=[70:3 - 70:15]
+// CHECK: load-stmts.cpp:70:3: DeclRefExpr=y:67:39 Extent=[70:3 - 70:4]
+// CHECK: load-stmts.cpp:70:7: TypeRef=type:69:13 Extent=[70:7 - 70:11]
+// CHECK: load-stmts.cpp:70:13: DeclRefExpr=t:67:34 Extent=[70:13 - 70:14]
+// CHECK: load-stmts.cpp:79:6: FunctionDecl=test_more_exprs:79:6 (Definition)
+// CHECK: load-stmts.cpp:80:8: DeclRefExpr=mem:79:28 Extent=[80:8 - 80:11]
+// CHECK: load-stmts.cpp:80:13: TypeRef=struct Pair:73:8 Extent=[80:13 - 80:17]
+// CHECK: load-stmts.cpp:80:18: DeclRefExpr=i:79:37 Extent=[80:18 - 80:19]
+// CHECK: load-stmts.cpp:80:21: DeclRefExpr=j:79:44 Extent=[80:21 - 80:22]
+// CHECK: load-stmts.cpp:82:9: TypeRef=Integer:81:15 Extent=[82:9 - 82:16]
+// CHECK: load-stmts.cpp:82:17: DeclRefExpr=i:79:37 Extent=[82:17 - 82:18]
+// CHECK: load-stmts.cpp:83:3: CStyleCastExpr= Extent=[83:3 - 83:13]
+// CHECK: load-stmts.cpp:83:4: TypeRef=Integer:81:15 Extent=[83:4 - 83:11]
+// CHECK: load-stmts.cpp:83:12: UnexposedExpr=i:79:37 Extent=[83:12 - 83:13]
+// CHECK: load-stmts.cpp:83:12: DeclRefExpr=i:79:37 Extent=[83:12 - 83:13]
+// CHECK: load-stmts.cpp:84:3: UnexposedExpr= Extent=[84:3 - 84:12]
+// CHECK: load-stmts.cpp:84:3: TypeRef=Integer:81:15 Extent=[84:3 - 84:10]
+// CHECK: load-stmts.cpp:90:9: TypeRef=type:89:13 Extent=[90:9 - 90:13]
+// CHECK: load-stmts.cpp:90:14: DeclRefExpr=t:88:39 Extent=[90:14 - 90:15]
+// CHECK: load-stmts.cpp:90:17: DeclRefExpr=y:88:44 Extent=[90:17 - 90:18]
+// CHECK: load-stmts.cpp:91:9: UnexposedExpr= Extent=[91:9 - 91:35]
+// CHECK: load-stmts.cpp:91:30: TypeRef=type:89:13 Extent=[91:30 - 91:34]
+// CHECK: load-stmts.cpp:103:10: CXXConstructor=Derived:103:10 (Definition)
+// CHECK: load-stmts.cpp:103:1: TypeRef=struct Derived:98:8 Extent=[103:1 - 103:
+// FIXME: Missing TypeRef for constructor name.
+// CHECK: load-stmts.cpp:103:22: ParmDecl=x:103:22 (Definition)
+// CHECK: load-stmts.cpp:104:5: MemberRef=member:100:7 Extent=[104:5 - 104:11]
+// CHECK: load-stmts.cpp:104:12: DeclRefExpr=x:103:22 Extent=[104:12 - 104:13]
+// CHECK: load-stmts.cpp:104:16: TypeRef=struct Base:94:8 Extent=[104:16 - 104:2
+// CHECK: load-stmts.cpp:104:16: CallExpr=Base:95:3 Extent=[104:16 - 104:23]
+// CHECK: load-stmts.cpp:104:21: DeclRefExpr=x:103:22 Extent=[104:21 - 104:22]
+// CHECK: load-stmts.cpp:107:6: FunctionDecl=considered_harmful:107:6 (Definition)
+// CHECK: load-stmts.cpp:108:2: LabelStmt=start_over Extent=[108:2 - 109:28]
+// CHECK: load-stmts.cpp:109:17: LabelRef=start_over:108:2 Extent=[109:17 - 109:27]
+// CHECK: load-stmts.cpp:113:10: LabelRef=start_over:108:2 Extent=[113:10 - 113:20]
+// CHECK: load-stmts.cpp:117:35: UnexposedExpr=ip:116:17 Extent=[117:35 - 117:37]
+// CHECK: load-stmts.cpp:117:35: DeclRefExpr=ip:116:17 Extent=[117:35 - 117:37]
+
diff --git a/clang/test/Index/local-symbols.m b/clang/test/Index/local-symbols.m
new file mode 100644
index 0000000..b4eb262
--- /dev/null
+++ b/clang/test/Index/local-symbols.m
@@ -0,0 +1,44 @@
+// RUN: c-index-test -test-load-source local %s | FileCheck %s
+
+// From: <rdar://problem/7568881>
+// The method 'bar' was also being reported outside the @implementation
+
+@interface Foo {
+ id x;
+}
+- (id) bar;
+@end
+
+@implementation Foo
+- (id) bar {
+ return 0;
+}
+@end
+
+// From: <rdar://problem/8380046>
+
+@protocol Prot8380046
+@end
+
+@interface R8380046
+@end
+
+@interface R8380046 () <Prot8380046>
+@end
+
+// CHECK: local-symbols.m:6:12: ObjCInterfaceDecl=Foo:6:12 Extent=[6:1 - 10:5]
+// CHECK: local-symbols.m:7:6: ObjCIvarDecl=x:7:6 (Definition) Extent=[7:3 - 7:7]
+// CHECK: local-symbols.m:7:3: TypeRef=id:0:0 Extent=[7:3 - 7:5]
+// CHECK: local-symbols.m:9:8: ObjCInstanceMethodDecl=bar:9:8 Extent=[9:1 - 9:12]
+// CHECK: local-symbols.m:9:4: TypeRef=id:0:0 Extent=[9:4 - 9:6]
+// CHECK: local-symbols.m:12:17: ObjCImplementationDecl=Foo:12:17 (Definition) Extent=[12:1 - 16:2]
+// CHECK: local-symbols.m:13:8: ObjCInstanceMethodDecl=bar:13:8 (Definition) Extent=[13:1 - 15:2]
+// CHECK: local-symbols.m:13:4: TypeRef=id:0:0 Extent=[13:4 - 13:6]
+// CHECK: local-symbols.m:14:10: UnexposedExpr= Extent=[14:10 - 14:11]
+// CHECK: local-symbols.m:14:10: IntegerLiteral= Extent=[14:10 - 14:11]
+// CHECK: local-symbols.m:20:11: ObjCProtocolDecl=Prot8380046:20:11 (Definition) Extent=[20:1 - 21:5]
+// CHECK: local-symbols.m:23:12: ObjCInterfaceDecl=R8380046:23:12 Extent=[23:1 - 24:5]
+// CHECK: local-symbols.m:26:12: ObjCCategoryDecl=:26:12 Extent=[26:1 - 27:5]
+// CHECK: local-symbols.m:26:12: ObjCClassRef=R8380046:23:12 Extent=[26:12 - 26:20]
+// CHECK: local-symbols.m:26:25: ObjCProtocolRef=Prot8380046:20:11 Extent=[26:25 - 26:36]
+
diff --git a/clang/test/Index/ms-if-exists.cpp b/clang/test/Index/ms-if-exists.cpp
new file mode 100644
index 0000000..0815a03
--- /dev/null
+++ b/clang/test/Index/ms-if-exists.cpp
@@ -0,0 +1,24 @@
+template<typename T>
+void f(T t) {
+ __if_exists(T::foo) {
+ { }
+ t.foo();
+ }
+
+ __if_not_exists(T::bar) {
+ int *i = t; // expected-error{{no viable conversion from 'HasFoo' to 'int *'}}
+ { }
+ }
+}
+
+// RUN: c-index-test -test-annotate-tokens=%s:3:1:11:3 -fms-extensions -fno-ms-compatibility -fno-delayed-template-parsing %s | FileCheck %s
+
+// CHECK: Identifier: "T" [3:15 - 3:16] TypeRef=T:1:19
+// CHECK: Punctuation: "}" [4:7 - 4:8] CompoundStmt=
+// CHECK: Identifier: "t" [5:5 - 5:6] DeclRefExpr=t:2:10
+// CHECK: Punctuation: "." [5:6 - 5:7] MemberRefExpr=
+// CHECK: Identifier: "foo" [5:7 - 5:10] MemberRefExpr=
+// CHECK: Keyword: "int" [9:5 - 9:8] VarDecl=i:9:10 (Definition)
+// CHECK: Punctuation: "*" [9:9 - 9:10] VarDecl=i:9:10 (Definition)
+// CHECK: Identifier: "i" [9:10 - 9:11] VarDecl=i:9:10 (Definition)
+// CHECK: Punctuation: "=" [9:12 - 9:13] VarDecl=i:9:10 (Definition)
diff --git a/clang/test/Index/nested-binaryoperators.cpp b/clang/test/Index/nested-binaryoperators.cpp
new file mode 100644
index 0000000..57adc6b
--- /dev/null
+++ b/clang/test/Index/nested-binaryoperators.cpp
@@ -0,0 +1,1983 @@
+typedef unsigned int uint;
+int foo(uint c) {
+ return ((c >= 0x41 && c <= 0x5a)
+ || (c >= 0x61 && c <= 0x7a)
+ || (c >= 0xc0 && c <= 0xd6)
+ || (c >= 0xd8 && c <= 0xf6)
+ || (c >= 0xf8 && c <= 0xff)
+ || (c >= 0x100 && c <= 0x131)
+ || (c >= 0x134 && c <= 0x13e)
+ || (c >= 0x141 && c <= 0x148)
+ || (c >= 0x14a && c <= 0x17e)
+ || (c >= 0x180 && c <= 0x1c3)
+ || (c >= 0x1cd && c <= 0x1f0)
+ || (c >= 0x1f4 && c <= 0x1f5)
+ || (c >= 0x1fa && c <= 0x217)
+ || (c >= 0x250 && c <= 0x2a8)
+ || (c >= 0x2bb && c <= 0x2c1)
+ || c == 0x386 || (c >= 0x388 && c <= 0x38a)
+ || c == 0x38c || (c >= 0x38e && c <= 0x3a1)
+ || (c >= 0x3a3 && c <= 0x3ce)
+ || (c >= 0x3d0 && c <= 0x3d6)
+ || c == 0x3da || c == 0x3dc || c == 0x3de ||
+ c == 0x3e0 || (c >= 0x3e2 && c <= 0x3f3)
+ || (c >= 0x401 && c <= 0x40c)
+ || (c >= 0x40e && c <= 0x44f)
+ || (c >= 0x451 && c <= 0x45c)
+ || (c >= 0x45e && c <= 0x481)
+ || (c >= 0x490 && c <= 0x4c4)
+ || (c >= 0x4c7 && c <= 0x4c8)
+ || (c >= 0x4cb && c <= 0x4cc)
+ || (c >= 0x4d0 && c <= 0x4eb)
+ || (c >= 0x4ee && c <= 0x4f5)
+ || (c >= 0x4f8 && c <= 0x4f9)
+ || (c >= 0x531 && c <= 0x556)
+ || c == 0x559 || (c >= 0x561 && c <= 0x586)
+ || (c >= 0x5d0 && c <= 0x5ea)
+ || (c >= 0x5f0 && c <= 0x5f2)
+ || (c >= 0x621 && c <= 0x63a)
+ || (c >= 0x641 && c <= 0x64a)
+ || (c >= 0x671 && c <= 0x6b7)
+ || (c >= 0x6ba && c <= 0x6be)
+ || (c >= 0x6c0 && c <= 0x6ce)
+ || (c >= 0x6d0 && c <= 0x6d3)
+ || c == 0x6d5 || (c >= 0x6e5 && c <= 0x6e6)
+ || (c >= 0x905 && c <= 0x939)
+ || c == 0x93d || (c >= 0x958 && c <= 0x961)
+ || (c >= 0x985 && c <= 0x98c)
+ || (c >= 0x98f && c <= 0x990)
+ || (c >= 0x993 && c <= 0x9a8)
+ || (c >= 0x9aa && c <= 0x9b0)
+ || c == 0x9b2 || (c >= 0x9b6 && c <= 0x9b9)
+ || (c >= 0x9dc && c <= 0x9dd)
+ || (c >= 0x9df && c <= 0x9e1)
+ || (c >= 0x9f0 && c <= 0x9f1)
+ || (c >= 0xa05 && c <= 0xa0a)
+ || (c >= 0xa0f && c <= 0xa10)
+ || (c >= 0xa13 && c <= 0xa28)
+ || (c >= 0xa2a && c <= 0xa30)
+ || (c >= 0xa32 && c <= 0xa33)
+ || (c >= 0xa35 && c <= 0xa36)
+ || (c >= 0xa38 && c <= 0xa39)
+ || (c >= 0xa59 && c <= 0xa5c)
+ || c == 0xa5e || (c >= 0xa72 && c <= 0xa74)
+ || (c >= 0xa85 && c <= 0xa8b)
+ || c == 0xa8d || (c >= 0xa8f && c <= 0xa91)
+ || (c >= 0xa93 && c <= 0xaa8)
+ || (c >= 0xaaa && c <= 0xab0)
+ || (c >= 0xab2 && c <= 0xab3)
+ || (c >= 0xab5 && c <= 0xab9)
+ || c == 0xabd || c == 0xae0 || (c >= 0xb05 && c <= 0xb0c)
+ || (c >= 0xb0f && c <= 0xb10)
+ || (c >= 0xb13 && c <= 0xb28)
+ || (c >= 0xb2a && c <= 0xb30)
+ || (c >= 0xb32 && c <= 0xb33)
+ || (c >= 0xb36 && c <= 0xb39)
+ || c == 0xb3d || (c >= 0xb5c && c <= 0xb5d)
+ || (c >= 0xb5f && c <= 0xb61)
+ || (c >= 0xb85 && c <= 0xb8a)
+ || (c >= 0xb8e && c <= 0xb90)
+ || (c >= 0xb92 && c <= 0xb95)
+ || (c >= 0xb99 && c <= 0xb9a)
+ || c == 0xb9c || (c >= 0xb9e && c <= 0xb9f)
+ || (c >= 0xba3 && c <= 0xba4)
+ || (c >= 0xba8 && c <= 0xbaa)
+ || (c >= 0xbae && c <= 0xbb5)
+ || (c >= 0xbb7 && c <= 0xbb9)
+ || (c >= 0xc05 && c <= 0xc0c)
+ || (c >= 0xc0e && c <= 0xc10)
+ || (c >= 0xc12 && c <= 0xc28)
+ || (c >= 0xc2a && c <= 0xc33)
+ || (c >= 0xc35 && c <= 0xc39)
+ || (c >= 0xc60 && c <= 0xc61)
+ || (c >= 0xc85 && c <= 0xc8c)
+ || (c >= 0xc8e && c <= 0xc90)
+ || (c >= 0xc92 && c <= 0xca8)
+ || (c >= 0xcaa && c <= 0xcb3)
+ || (c >= 0xcb5 && c <= 0xcb9)
+ || c == 0xcde || (c >= 0xce0 && c <= 0xce1)
+ || (c >= 0xd05 && c <= 0xd0c)
+ || (c >= 0xd0e && c <= 0xd10)
+ || (c >= 0xd12 && c <= 0xd28)
+ || (c >= 0xd2a && c <= 0xd39)
+ || (c >= 0xd60 && c <= 0xd61)
+ || (c >= 0xe01 && c <= 0xe2e)
+ || c == 0xe30 || (c >= 0xe32 && c <= 0xe33)
+ || (c >= 0xe40 && c <= 0xe45)
+ || (c >= 0xe81 && c <= 0xe82)
+ || c == 0xe84 || (c >= 0xe87 && c <= 0xe88)
+ || c == 0xe8a || c == 0xe8d || (c >= 0xe94 && c <= 0xe97)
+ || (c >= 0xe99 && c <= 0xe9f)
+ || (c >= 0xea1 && c <= 0xea3)
+ || c == 0xea5 || c == 0xea7 || (c >= 0xeaa && c <= 0xeab)
+ || (c >= 0xead && c <= 0xeae)
+ || c == 0xeb0 || (c >= 0xeb2 && c <= 0xeb3)
+ || c == 0xebd || (c >= 0xec0 && c <= 0xec4)
+ || (c >= 0xf40 && c <= 0xf47)
+ || (c >= 0xf49 && c <= 0xf69)
+ || (c >= 0x10a0 && c <= 0x10c5)
+ || (c >= 0x10d0 && c <= 0x10f6)
+ || c == 0x1100 || (c >= 0x1102 && c <= 0x1103)
+ || (c >= 0x1105 && c <= 0x1107)
+ || c == 0x1109 || (c >= 0x110b && c <= 0x110c)
+ || (c >= 0x110e && c <= 0x1112)
+ || c == 0x113c || c == 0x113e || c == 0x1140 || c == 0x114c ||
+ c == 0x114e || c == 0x1150 || (c >= 0x1154 && c <= 0x1155)
+ || c == 0x1159 || (c >= 0x115f && c <= 0x1161)
+ || c == 0x1163 || c == 0x1165 || c == 0x1167 || c == 0x1169 ||
+ (c >= 0x116d && c <= 0x116e)
+ || (c >= 0x1172 && c <= 0x1173)
+ || c == 0x1175 || c == 0x119e || c == 0x11a8 || c == 0x11ab ||
+ (c >= 0x11ae && c <= 0x11af)
+ || (c >= 0x11b7 && c <= 0x11b8)
+ || c == 0x11ba || (c >= 0x11bc && c <= 0x11c2)
+ || c == 0x11eb || c == 0x11f0 || c == 0x11f9 || (c >= 0x1e00 && c <= 0x1e9b)
+ || (c >= 0x1ea0 && c <= 0x1ef9)
+ || (c >= 0x1f00 && c <= 0x1f15)
+ || (c >= 0x1f18 && c <= 0x1f1d)
+ || (c >= 0x1f20 && c <= 0x1f45)
+ || (c >= 0x1f48 && c <= 0x1f4d)
+ || (c >= 0x1f50 && c <= 0x1f57)
+ || c == 0x1f59 || c == 0x1f5b || c == 0x1f5d || (c >= 0x1f5f && c <= 0x1f7d)
+ || (c >= 0x1f80 && c <= 0x1fb4)
+ || (c >= 0x1fb6 && c <= 0x1fbc)
+ || c == 0x1fbe || (c >= 0x1fc2 && c <= 0x1fc4)
+ || (c >= 0x1fc6 && c <= 0x1fcc)
+ || (c >= 0x1fd0 && c <= 0x1fd3)
+ || (c >= 0x1fd6 && c <= 0x1fdb)
+ || (c >= 0x1fe0 && c <= 0x1fec)
+ || (c >= 0x1ff2 && c <= 0x1ff4)
+ || (c >= 0x1ff6 && c <= 0x1ffc)
+ || c == 0x2126 || (c >= 0x212a && c <= 0x212b)
+ || c == 0x212e || (c >= 0x2180 && c <= 0x2182)
+ || (c >= 0x3041 && c <= 0x3094)
+ || (c >= 0x30a1 && c <= 0x30fa)
+ || (c >= 0x3105 && c <= 0x312c)
+ || (c >= 0xac00 && c <= 0xd7a3)
+ || (c >= 0x4e00 && c <= 0x9fa5)
+ || c == 0x3007 || (c >= 0x3021 && c <= 0x3029)
+ || (c >= 0x4e00 && c <= 0x9fa5)
+ || c == 0x3007 || (c >= 0x3021 && c <= 0x3029));
+}
+
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+// CHECK: 1:22: TypedefDecl=uint:1:22 (Definition) Extent=[1:1 - 1:26]
+// CHECK: 2:5: FunctionDecl=foo:2:5 (Definition) Extent=[2:1 - 161:2]
+// CHECK: 2:14: ParmDecl=c:2:14 (Definition) Extent=[2:9 - 2:15]
+// CHECK: 2:9: TypeRef=uint:1:22 Extent=[2:9 - 2:13]
+// CHECK: 2:17: CompoundStmt= Extent=[2:17 - 161:2]
+// CHECK: 3:3: ReturnStmt= Extent=[3:3 - 160:52]
+// CHECK: 3:10: UnexposedExpr= Extent=[3:10 - 160:52]
+// CHECK: 3:10: ParenExpr= Extent=[3:10 - 160:52]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 160:51]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 160:19]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 159:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 158:51]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 158:19]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 157:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 156:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 155:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 154:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 153:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 152:51]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 152:19]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 151:51]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 151:19]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 150:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 149:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 148:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 147:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 146:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 145:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 144:51]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 144:19]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 143:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 142:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 141:81]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 141:49]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 141:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 141:19]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 140:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 139:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 138:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 137:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 136:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 135:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 134:81]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 134:49]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 134:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 134:19]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 133:51]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 133:19]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 132:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 131:33]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 130:64]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 130:49]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 130:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 130:19]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 129:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 128:33]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 127:64]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 127:49]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 127:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 127:19]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 126:51]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 126:19]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 125:63]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 125:31]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 125:16]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 124:64]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 124:49]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 124:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 124:19]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 123:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 122:51]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 122:19]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 121:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 120:51]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 120:19]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 119:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 118:36]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 117:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 116:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 115:48]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 115:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 114:48]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 114:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 113:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 112:62]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 112:32]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 112:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 111:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 110:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 109:62]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 109:32]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 109:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 108:48]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 108:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 107:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 106:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 105:48]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 105:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 104:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 103:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 102:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 101:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 100:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 99:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 98:48]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 98:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 97:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 96:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 95:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 94:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 93:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 92:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 91:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 90:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 89:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 88:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 87:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 86:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 85:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 84:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 83:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 82:48]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 82:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 81:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 80:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 79:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 78:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 77:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 76:48]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 76:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 75:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 74:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 73:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 72:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 71:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 70:62]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 70:32]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 70:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 69:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 68:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 67:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 66:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 65:48]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 65:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 64:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 63:48]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 63:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 62:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 61:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 60:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 59:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 58:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 57:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 56:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 55:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 54:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 53:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 52:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 51:48]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 51:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 50:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 49:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 48:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 47:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 46:48]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 46:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 45:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 44:48]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 44:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 43:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 42:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 41:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 40:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 39:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 38:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 37:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 36:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 35:48]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 35:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 34:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 33:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 32:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 31:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 30:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 29:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 28:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 27:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 26:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 25:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 24:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 23:45]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 23:15]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 22:46]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 22:32]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 22:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 21:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 20:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 19:48]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 19:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 18:48]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 18:18]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 17:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 16:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 15:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 14:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 13:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 12:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 11:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 10:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 9:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 8:34]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 7:32]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 6:32]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 5:32]
+// CHECK: 3:11: BinaryOperator= Extent=[3:11 - 4:32]
+// CHECK: 3:12: BinaryOperator= Extent=[3:12 - 3:34]
+// CHECK: 3:12: BinaryOperator= Extent=[3:12 - 3:21]
+// CHECK: 3:12: DeclRefExpr=c:2:14 Extent=[3:12 - 3:13]
+// CHECK: 3:17: UnexposedExpr= Extent=[3:17 - 3:21]
+// CHECK: 3:17: IntegerLiteral= Extent=[3:17 - 3:21]
+// CHECK: 3:25: BinaryOperator= Extent=[3:25 - 3:34]
+// CHECK: 3:25: DeclRefExpr=c:2:14 Extent=[3:25 - 3:26]
+// CHECK: 3:30: UnexposedExpr= Extent=[3:30 - 3:34]
+// CHECK: 3:30: IntegerLiteral= Extent=[3:30 - 3:34]
+// CHECK: 4:9: BinaryOperator= Extent=[4:9 - 4:31]
+// CHECK: 4:9: BinaryOperator= Extent=[4:9 - 4:18]
+// CHECK: 4:9: DeclRefExpr=c:2:14 Extent=[4:9 - 4:10]
+// CHECK: 4:14: UnexposedExpr= Extent=[4:14 - 4:18]
+// CHECK: 4:14: IntegerLiteral= Extent=[4:14 - 4:18]
+// CHECK: 4:22: BinaryOperator= Extent=[4:22 - 4:31]
+// CHECK: 4:22: DeclRefExpr=c:2:14 Extent=[4:22 - 4:23]
+// CHECK: 4:27: UnexposedExpr= Extent=[4:27 - 4:31]
+// CHECK: 4:27: IntegerLiteral= Extent=[4:27 - 4:31]
+// CHECK: 5:8: ParenExpr= Extent=[5:8 - 5:32]
+// CHECK: 5:9: BinaryOperator= Extent=[5:9 - 5:31]
+// CHECK: 5:9: BinaryOperator= Extent=[5:9 - 5:18]
+// CHECK: 5:9: DeclRefExpr=c:2:14 Extent=[5:9 - 5:10]
+// CHECK: 5:14: UnexposedExpr= Extent=[5:14 - 5:18]
+// CHECK: 5:14: IntegerLiteral= Extent=[5:14 - 5:18]
+// CHECK: 5:22: BinaryOperator= Extent=[5:22 - 5:31]
+// CHECK: 5:22: DeclRefExpr=c:2:14 Extent=[5:22 - 5:23]
+// CHECK: 5:27: UnexposedExpr= Extent=[5:27 - 5:31]
+// CHECK: 5:27: IntegerLiteral= Extent=[5:27 - 5:31]
+// CHECK: 6:9: BinaryOperator= Extent=[6:9 - 6:31]
+// CHECK: 6:9: BinaryOperator= Extent=[6:9 - 6:18]
+// CHECK: 6:9: DeclRefExpr=c:2:14 Extent=[6:9 - 6:10]
+// CHECK: 6:14: UnexposedExpr= Extent=[6:14 - 6:18]
+// CHECK: 6:14: IntegerLiteral= Extent=[6:14 - 6:18]
+// CHECK: 6:22: BinaryOperator= Extent=[6:22 - 6:31]
+// CHECK: 6:22: DeclRefExpr=c:2:14 Extent=[6:22 - 6:23]
+// CHECK: 6:27: UnexposedExpr= Extent=[6:27 - 6:31]
+// CHECK: 6:27: IntegerLiteral= Extent=[6:27 - 6:31]
+// CHECK: 7:9: BinaryOperator= Extent=[7:9 - 7:31]
+// CHECK: 7:9: BinaryOperator= Extent=[7:9 - 7:18]
+// CHECK: 7:9: DeclRefExpr=c:2:14 Extent=[7:9 - 7:10]
+// CHECK: 7:14: UnexposedExpr= Extent=[7:14 - 7:18]
+// CHECK: 7:14: IntegerLiteral= Extent=[7:14 - 7:18]
+// CHECK: 7:22: BinaryOperator= Extent=[7:22 - 7:31]
+// CHECK: 7:22: DeclRefExpr=c:2:14 Extent=[7:22 - 7:23]
+// CHECK: 7:27: UnexposedExpr= Extent=[7:27 - 7:31]
+// CHECK: 7:27: IntegerLiteral= Extent=[7:27 - 7:31]
+// CHECK: 8:9: BinaryOperator= Extent=[8:9 - 8:33]
+// CHECK: 8:9: BinaryOperator= Extent=[8:9 - 8:19]
+// CHECK: 8:9: DeclRefExpr=c:2:14 Extent=[8:9 - 8:10]
+// CHECK: 8:14: UnexposedExpr= Extent=[8:14 - 8:19]
+// CHECK: 8:14: IntegerLiteral= Extent=[8:14 - 8:19]
+// CHECK: 8:23: BinaryOperator= Extent=[8:23 - 8:33]
+// CHECK: 8:23: DeclRefExpr=c:2:14 Extent=[8:23 - 8:24]
+// CHECK: 8:28: UnexposedExpr= Extent=[8:28 - 8:33]
+// CHECK: 8:28: IntegerLiteral= Extent=[8:28 - 8:33]
+// CHECK: 9:9: BinaryOperator= Extent=[9:9 - 9:33]
+// CHECK: 9:9: BinaryOperator= Extent=[9:9 - 9:19]
+// CHECK: 9:9: DeclRefExpr=c:2:14 Extent=[9:9 - 9:10]
+// CHECK: 9:14: UnexposedExpr= Extent=[9:14 - 9:19]
+// CHECK: 9:14: IntegerLiteral= Extent=[9:14 - 9:19]
+// CHECK: 9:23: BinaryOperator= Extent=[9:23 - 9:33]
+// CHECK: 9:23: DeclRefExpr=c:2:14 Extent=[9:23 - 9:24]
+// CHECK: 9:28: UnexposedExpr= Extent=[9:28 - 9:33]
+// CHECK: 9:28: IntegerLiteral= Extent=[9:28 - 9:33]
+// CHECK: 10:9: BinaryOperator= Extent=[10:9 - 10:33]
+// CHECK: 10:9: BinaryOperator= Extent=[10:9 - 10:19]
+// CHECK: 10:9: DeclRefExpr=c:2:14 Extent=[10:9 - 10:10]
+// CHECK: 10:14: UnexposedExpr= Extent=[10:14 - 10:19]
+// CHECK: 10:14: IntegerLiteral= Extent=[10:14 - 10:19]
+// CHECK: 10:23: BinaryOperator= Extent=[10:23 - 10:33]
+// CHECK: 10:23: DeclRefExpr=c:2:14 Extent=[10:23 - 10:24]
+// CHECK: 10:28: UnexposedExpr= Extent=[10:28 - 10:33]
+// CHECK: 10:28: IntegerLiteral= Extent=[10:28 - 10:33]
+// CHECK: 11:9: BinaryOperator= Extent=[11:9 - 11:33]
+// CHECK: 11:9: BinaryOperator= Extent=[11:9 - 11:19]
+// CHECK: 11:9: DeclRefExpr=c:2:14 Extent=[11:9 - 11:10]
+// CHECK: 11:14: UnexposedExpr= Extent=[11:14 - 11:19]
+// CHECK: 11:14: IntegerLiteral= Extent=[11:14 - 11:19]
+// CHECK: 11:23: BinaryOperator= Extent=[11:23 - 11:33]
+// CHECK: 11:23: DeclRefExpr=c:2:14 Extent=[11:23 - 11:24]
+// CHECK: 11:28: UnexposedExpr= Extent=[11:28 - 11:33]
+// CHECK: 11:28: IntegerLiteral= Extent=[11:28 - 11:33]
+// CHECK: 12:9: BinaryOperator= Extent=[12:9 - 12:33]
+// CHECK: 12:9: BinaryOperator= Extent=[12:9 - 12:19]
+// CHECK: 12:9: DeclRefExpr=c:2:14 Extent=[12:9 - 12:10]
+// CHECK: 12:14: UnexposedExpr= Extent=[12:14 - 12:19]
+// CHECK: 12:14: IntegerLiteral= Extent=[12:14 - 12:19]
+// CHECK: 12:23: BinaryOperator= Extent=[12:23 - 12:33]
+// CHECK: 12:23: DeclRefExpr=c:2:14 Extent=[12:23 - 12:24]
+// CHECK: 12:28: UnexposedExpr= Extent=[12:28 - 12:33]
+// CHECK: 12:28: IntegerLiteral= Extent=[12:28 - 12:33]
+// CHECK: 13:9: BinaryOperator= Extent=[13:9 - 13:33]
+// CHECK: 13:9: BinaryOperator= Extent=[13:9 - 13:19]
+// CHECK: 13:9: DeclRefExpr=c:2:14 Extent=[13:9 - 13:10]
+// CHECK: 13:14: UnexposedExpr= Extent=[13:14 - 13:19]
+// CHECK: 13:14: IntegerLiteral= Extent=[13:14 - 13:19]
+// CHECK: 13:23: BinaryOperator= Extent=[13:23 - 13:33]
+// CHECK: 13:23: DeclRefExpr=c:2:14 Extent=[13:23 - 13:24]
+// CHECK: 13:28: UnexposedExpr= Extent=[13:28 - 13:33]
+// CHECK: 13:28: IntegerLiteral= Extent=[13:28 - 13:33]
+// CHECK: 14:9: BinaryOperator= Extent=[14:9 - 14:33]
+// CHECK: 14:9: BinaryOperator= Extent=[14:9 - 14:19]
+// CHECK: 14:9: DeclRefExpr=c:2:14 Extent=[14:9 - 14:10]
+// CHECK: 14:14: UnexposedExpr= Extent=[14:14 - 14:19]
+// CHECK: 14:14: IntegerLiteral= Extent=[14:14 - 14:19]
+// CHECK: 14:23: BinaryOperator= Extent=[14:23 - 14:33]
+// CHECK: 14:23: DeclRefExpr=c:2:14 Extent=[14:23 - 14:24]
+// CHECK: 14:28: UnexposedExpr= Extent=[14:28 - 14:33]
+// CHECK: 14:28: IntegerLiteral= Extent=[14:28 - 14:33]
+// CHECK: 15:9: BinaryOperator= Extent=[15:9 - 15:33]
+// CHECK: 15:9: BinaryOperator= Extent=[15:9 - 15:19]
+// CHECK: 15:9: DeclRefExpr=c:2:14 Extent=[15:9 - 15:10]
+// CHECK: 15:14: UnexposedExpr= Extent=[15:14 - 15:19]
+// CHECK: 15:14: IntegerLiteral= Extent=[15:14 - 15:19]
+// CHECK: 15:23: BinaryOperator= Extent=[15:23 - 15:33]
+// CHECK: 15:23: DeclRefExpr=c:2:14 Extent=[15:23 - 15:24]
+// CHECK: 15:28: UnexposedExpr= Extent=[15:28 - 15:33]
+// CHECK: 15:28: IntegerLiteral= Extent=[15:28 - 15:33]
+// CHECK: 16:9: BinaryOperator= Extent=[16:9 - 16:33]
+// CHECK: 16:9: BinaryOperator= Extent=[16:9 - 16:19]
+// CHECK: 16:9: DeclRefExpr=c:2:14 Extent=[16:9 - 16:10]
+// CHECK: 16:14: UnexposedExpr= Extent=[16:14 - 16:19]
+// CHECK: 16:14: IntegerLiteral= Extent=[16:14 - 16:19]
+// CHECK: 16:23: BinaryOperator= Extent=[16:23 - 16:33]
+// CHECK: 16:23: DeclRefExpr=c:2:14 Extent=[16:23 - 16:24]
+// CHECK: 16:28: UnexposedExpr= Extent=[16:28 - 16:33]
+// CHECK: 16:28: IntegerLiteral= Extent=[16:28 - 16:33]
+// CHECK: 17:9: BinaryOperator= Extent=[17:9 - 17:33]
+// CHECK: 17:9: BinaryOperator= Extent=[17:9 - 17:19]
+// CHECK: 17:9: DeclRefExpr=c:2:14 Extent=[17:9 - 17:10]
+// CHECK: 17:14: UnexposedExpr= Extent=[17:14 - 17:19]
+// CHECK: 17:14: IntegerLiteral= Extent=[17:14 - 17:19]
+// CHECK: 17:23: BinaryOperator= Extent=[17:23 - 17:33]
+// CHECK: 17:23: DeclRefExpr=c:2:14 Extent=[17:23 - 17:24]
+// CHECK: 17:28: UnexposedExpr= Extent=[17:28 - 17:33]
+// CHECK: 17:28: IntegerLiteral= Extent=[17:28 - 17:33]
+// CHECK: 18:8: BinaryOperator= Extent=[18:8 - 18:18]
+// CHECK: 18:8: DeclRefExpr=c:2:14 Extent=[18:8 - 18:9]
+// CHECK: 18:13: UnexposedExpr= Extent=[18:13 - 18:18]
+// CHECK: 18:13: IntegerLiteral= Extent=[18:13 - 18:18]
+// CHECK: 18:23: BinaryOperator= Extent=[18:23 - 18:47]
+// CHECK: 18:23: BinaryOperator= Extent=[18:23 - 18:33]
+// CHECK: 18:23: DeclRefExpr=c:2:14 Extent=[18:23 - 18:24]
+// CHECK: 18:28: UnexposedExpr= Extent=[18:28 - 18:33]
+// CHECK: 18:28: IntegerLiteral= Extent=[18:28 - 18:33]
+// CHECK: 18:37: BinaryOperator= Extent=[18:37 - 18:47]
+// CHECK: 18:37: DeclRefExpr=c:2:14 Extent=[18:37 - 18:38]
+// CHECK: 18:42: UnexposedExpr= Extent=[18:42 - 18:47]
+// CHECK: 18:42: IntegerLiteral= Extent=[18:42 - 18:47]
+// CHECK: 19:8: BinaryOperator= Extent=[19:8 - 19:18]
+// CHECK: 19:8: DeclRefExpr=c:2:14 Extent=[19:8 - 19:9]
+// CHECK: 19:13: UnexposedExpr= Extent=[19:13 - 19:18]
+// CHECK: 19:13: IntegerLiteral= Extent=[19:13 - 19:18]
+// CHECK: 19:23: BinaryOperator= Extent=[19:23 - 19:47]
+// CHECK: 19:23: BinaryOperator= Extent=[19:23 - 19:33]
+// CHECK: 19:23: DeclRefExpr=c:2:14 Extent=[19:23 - 19:24]
+// CHECK: 19:28: UnexposedExpr= Extent=[19:28 - 19:33]
+// CHECK: 19:28: IntegerLiteral= Extent=[19:28 - 19:33]
+// CHECK: 19:37: BinaryOperator= Extent=[19:37 - 19:47]
+// CHECK: 19:37: DeclRefExpr=c:2:14 Extent=[19:37 - 19:38]
+// CHECK: 19:42: UnexposedExpr= Extent=[19:42 - 19:47]
+// CHECK: 19:42: IntegerLiteral= Extent=[19:42 - 19:47]
+// CHECK: 20:9: BinaryOperator= Extent=[20:9 - 20:33]
+// CHECK: 20:9: BinaryOperator= Extent=[20:9 - 20:19]
+// CHECK: 20:9: DeclRefExpr=c:2:14 Extent=[20:9 - 20:10]
+// CHECK: 20:14: UnexposedExpr= Extent=[20:14 - 20:19]
+// CHECK: 20:14: IntegerLiteral= Extent=[20:14 - 20:19]
+// CHECK: 20:23: BinaryOperator= Extent=[20:23 - 20:33]
+// CHECK: 20:23: DeclRefExpr=c:2:14 Extent=[20:23 - 20:24]
+// CHECK: 20:28: UnexposedExpr= Extent=[20:28 - 20:33]
+// CHECK: 20:28: IntegerLiteral= Extent=[20:28 - 20:33]
+// CHECK: 21:9: BinaryOperator= Extent=[21:9 - 21:33]
+// CHECK: 21:9: BinaryOperator= Extent=[21:9 - 21:19]
+// CHECK: 21:9: DeclRefExpr=c:2:14 Extent=[21:9 - 21:10]
+// CHECK: 21:14: UnexposedExpr= Extent=[21:14 - 21:19]
+// CHECK: 21:14: IntegerLiteral= Extent=[21:14 - 21:19]
+// CHECK: 21:23: BinaryOperator= Extent=[21:23 - 21:33]
+// CHECK: 21:23: DeclRefExpr=c:2:14 Extent=[21:23 - 21:24]
+// CHECK: 21:28: UnexposedExpr= Extent=[21:28 - 21:33]
+// CHECK: 21:28: IntegerLiteral= Extent=[21:28 - 21:33]
+// CHECK: 22:8: BinaryOperator= Extent=[22:8 - 22:18]
+// CHECK: 22:8: DeclRefExpr=c:2:14 Extent=[22:8 - 22:9]
+// CHECK: 22:13: UnexposedExpr= Extent=[22:13 - 22:18]
+// CHECK: 22:13: IntegerLiteral= Extent=[22:13 - 22:18]
+// CHECK: 22:22: BinaryOperator= Extent=[22:22 - 22:32]
+// CHECK: 22:22: DeclRefExpr=c:2:14 Extent=[22:22 - 22:23]
+// CHECK: 22:27: UnexposedExpr= Extent=[22:27 - 22:32]
+// CHECK: 22:27: IntegerLiteral= Extent=[22:27 - 22:32]
+// CHECK: 22:36: BinaryOperator= Extent=[22:36 - 22:46]
+// CHECK: 22:36: DeclRefExpr=c:2:14 Extent=[22:36 - 22:37]
+// CHECK: 22:41: UnexposedExpr= Extent=[22:41 - 22:46]
+// CHECK: 22:41: IntegerLiteral= Extent=[22:41 - 22:46]
+// CHECK: 23:5: BinaryOperator= Extent=[23:5 - 23:15]
+// CHECK: 23:5: DeclRefExpr=c:2:14 Extent=[23:5 - 23:6]
+// CHECK: 23:10: UnexposedExpr= Extent=[23:10 - 23:15]
+// CHECK: 23:10: IntegerLiteral= Extent=[23:10 - 23:15]
+// CHECK: 23:20: BinaryOperator= Extent=[23:20 - 23:44]
+// CHECK: 23:20: BinaryOperator= Extent=[23:20 - 23:30]
+// CHECK: 23:20: DeclRefExpr=c:2:14 Extent=[23:20 - 23:21]
+// CHECK: 23:25: UnexposedExpr= Extent=[23:25 - 23:30]
+// CHECK: 23:25: IntegerLiteral= Extent=[23:25 - 23:30]
+// CHECK: 23:34: BinaryOperator= Extent=[23:34 - 23:44]
+// CHECK: 23:34: DeclRefExpr=c:2:14 Extent=[23:34 - 23:35]
+// CHECK: 23:39: UnexposedExpr= Extent=[23:39 - 23:44]
+// CHECK: 23:39: IntegerLiteral= Extent=[23:39 - 23:44]
+// CHECK: 24:9: BinaryOperator= Extent=[24:9 - 24:33]
+// CHECK: 24:9: BinaryOperator= Extent=[24:9 - 24:19]
+// CHECK: 24:9: DeclRefExpr=c:2:14 Extent=[24:9 - 24:10]
+// CHECK: 24:14: UnexposedExpr= Extent=[24:14 - 24:19]
+// CHECK: 24:14: IntegerLiteral= Extent=[24:14 - 24:19]
+// CHECK: 24:23: BinaryOperator= Extent=[24:23 - 24:33]
+// CHECK: 24:23: DeclRefExpr=c:2:14 Extent=[24:23 - 24:24]
+// CHECK: 24:28: UnexposedExpr= Extent=[24:28 - 24:33]
+// CHECK: 24:28: IntegerLiteral= Extent=[24:28 - 24:33]
+// CHECK: 25:9: BinaryOperator= Extent=[25:9 - 25:33]
+// CHECK: 25:9: BinaryOperator= Extent=[25:9 - 25:19]
+// CHECK: 25:9: DeclRefExpr=c:2:14 Extent=[25:9 - 25:10]
+// CHECK: 25:14: UnexposedExpr= Extent=[25:14 - 25:19]
+// CHECK: 25:14: IntegerLiteral= Extent=[25:14 - 25:19]
+// CHECK: 25:23: BinaryOperator= Extent=[25:23 - 25:33]
+// CHECK: 25:23: DeclRefExpr=c:2:14 Extent=[25:23 - 25:24]
+// CHECK: 25:28: UnexposedExpr= Extent=[25:28 - 25:33]
+// CHECK: 25:28: IntegerLiteral= Extent=[25:28 - 25:33]
+// CHECK: 26:9: BinaryOperator= Extent=[26:9 - 26:33]
+// CHECK: 26:9: BinaryOperator= Extent=[26:9 - 26:19]
+// CHECK: 26:9: DeclRefExpr=c:2:14 Extent=[26:9 - 26:10]
+// CHECK: 26:14: UnexposedExpr= Extent=[26:14 - 26:19]
+// CHECK: 26:14: IntegerLiteral= Extent=[26:14 - 26:19]
+// CHECK: 26:23: BinaryOperator= Extent=[26:23 - 26:33]
+// CHECK: 26:23: DeclRefExpr=c:2:14 Extent=[26:23 - 26:24]
+// CHECK: 26:28: UnexposedExpr= Extent=[26:28 - 26:33]
+// CHECK: 26:28: IntegerLiteral= Extent=[26:28 - 26:33]
+// CHECK: 27:9: BinaryOperator= Extent=[27:9 - 27:33]
+// CHECK: 27:9: BinaryOperator= Extent=[27:9 - 27:19]
+// CHECK: 27:9: DeclRefExpr=c:2:14 Extent=[27:9 - 27:10]
+// CHECK: 27:14: UnexposedExpr= Extent=[27:14 - 27:19]
+// CHECK: 27:14: IntegerLiteral= Extent=[27:14 - 27:19]
+// CHECK: 27:23: BinaryOperator= Extent=[27:23 - 27:33]
+// CHECK: 27:23: DeclRefExpr=c:2:14 Extent=[27:23 - 27:24]
+// CHECK: 27:28: UnexposedExpr= Extent=[27:28 - 27:33]
+// CHECK: 27:28: IntegerLiteral= Extent=[27:28 - 27:33]
+// CHECK: 28:9: BinaryOperator= Extent=[28:9 - 28:33]
+// CHECK: 28:9: BinaryOperator= Extent=[28:9 - 28:19]
+// CHECK: 28:9: DeclRefExpr=c:2:14 Extent=[28:9 - 28:10]
+// CHECK: 28:14: UnexposedExpr= Extent=[28:14 - 28:19]
+// CHECK: 28:14: IntegerLiteral= Extent=[28:14 - 28:19]
+// CHECK: 28:23: BinaryOperator= Extent=[28:23 - 28:33]
+// CHECK: 28:23: DeclRefExpr=c:2:14 Extent=[28:23 - 28:24]
+// CHECK: 28:28: UnexposedExpr= Extent=[28:28 - 28:33]
+// CHECK: 28:28: IntegerLiteral= Extent=[28:28 - 28:33]
+// CHECK: 29:9: BinaryOperator= Extent=[29:9 - 29:33]
+// CHECK: 29:9: BinaryOperator= Extent=[29:9 - 29:19]
+// CHECK: 29:9: DeclRefExpr=c:2:14 Extent=[29:9 - 29:10]
+// CHECK: 29:14: UnexposedExpr= Extent=[29:14 - 29:19]
+// CHECK: 29:14: IntegerLiteral= Extent=[29:14 - 29:19]
+// CHECK: 29:23: BinaryOperator= Extent=[29:23 - 29:33]
+// CHECK: 29:23: DeclRefExpr=c:2:14 Extent=[29:23 - 29:24]
+// CHECK: 29:28: UnexposedExpr= Extent=[29:28 - 29:33]
+// CHECK: 29:28: IntegerLiteral= Extent=[29:28 - 29:33]
+// CHECK: 30:9: BinaryOperator= Extent=[30:9 - 30:33]
+// CHECK: 30:9: BinaryOperator= Extent=[30:9 - 30:19]
+// CHECK: 30:9: DeclRefExpr=c:2:14 Extent=[30:9 - 30:10]
+// CHECK: 30:14: UnexposedExpr= Extent=[30:14 - 30:19]
+// CHECK: 30:14: IntegerLiteral= Extent=[30:14 - 30:19]
+// CHECK: 30:23: BinaryOperator= Extent=[30:23 - 30:33]
+// CHECK: 30:23: DeclRefExpr=c:2:14 Extent=[30:23 - 30:24]
+// CHECK: 30:28: UnexposedExpr= Extent=[30:28 - 30:33]
+// CHECK: 30:28: IntegerLiteral= Extent=[30:28 - 30:33]
+// CHECK: 31:9: BinaryOperator= Extent=[31:9 - 31:33]
+// CHECK: 31:9: BinaryOperator= Extent=[31:9 - 31:19]
+// CHECK: 31:9: DeclRefExpr=c:2:14 Extent=[31:9 - 31:10]
+// CHECK: 31:14: UnexposedExpr= Extent=[31:14 - 31:19]
+// CHECK: 31:14: IntegerLiteral= Extent=[31:14 - 31:19]
+// CHECK: 31:23: BinaryOperator= Extent=[31:23 - 31:33]
+// CHECK: 31:23: DeclRefExpr=c:2:14 Extent=[31:23 - 31:24]
+// CHECK: 31:28: UnexposedExpr= Extent=[31:28 - 31:33]
+// CHECK: 31:28: IntegerLiteral= Extent=[31:28 - 31:33]
+// CHECK: 32:9: BinaryOperator= Extent=[32:9 - 32:33]
+// CHECK: 32:9: BinaryOperator= Extent=[32:9 - 32:19]
+// CHECK: 32:9: DeclRefExpr=c:2:14 Extent=[32:9 - 32:10]
+// CHECK: 32:14: UnexposedExpr= Extent=[32:14 - 32:19]
+// CHECK: 32:14: IntegerLiteral= Extent=[32:14 - 32:19]
+// CHECK: 32:23: BinaryOperator= Extent=[32:23 - 32:33]
+// CHECK: 32:23: DeclRefExpr=c:2:14 Extent=[32:23 - 32:24]
+// CHECK: 32:28: UnexposedExpr= Extent=[32:28 - 32:33]
+// CHECK: 32:28: IntegerLiteral= Extent=[32:28 - 32:33]
+// CHECK: 33:9: BinaryOperator= Extent=[33:9 - 33:33]
+// CHECK: 33:9: BinaryOperator= Extent=[33:9 - 33:19]
+// CHECK: 33:9: DeclRefExpr=c:2:14 Extent=[33:9 - 33:10]
+// CHECK: 33:14: UnexposedExpr= Extent=[33:14 - 33:19]
+// CHECK: 33:14: IntegerLiteral= Extent=[33:14 - 33:19]
+// CHECK: 33:23: BinaryOperator= Extent=[33:23 - 33:33]
+// CHECK: 33:23: DeclRefExpr=c:2:14 Extent=[33:23 - 33:24]
+// CHECK: 33:28: UnexposedExpr= Extent=[33:28 - 33:33]
+// CHECK: 33:28: IntegerLiteral= Extent=[33:28 - 33:33]
+// CHECK: 34:9: BinaryOperator= Extent=[34:9 - 34:33]
+// CHECK: 34:9: BinaryOperator= Extent=[34:9 - 34:19]
+// CHECK: 34:9: DeclRefExpr=c:2:14 Extent=[34:9 - 34:10]
+// CHECK: 34:14: UnexposedExpr= Extent=[34:14 - 34:19]
+// CHECK: 34:14: IntegerLiteral= Extent=[34:14 - 34:19]
+// CHECK: 34:23: BinaryOperator= Extent=[34:23 - 34:33]
+// CHECK: 34:23: DeclRefExpr=c:2:14 Extent=[34:23 - 34:24]
+// CHECK: 34:28: UnexposedExpr= Extent=[34:28 - 34:33]
+// CHECK: 34:28: IntegerLiteral= Extent=[34:28 - 34:33]
+// CHECK: 35:8: BinaryOperator= Extent=[35:8 - 35:18]
+// CHECK: 35:8: DeclRefExpr=c:2:14 Extent=[35:8 - 35:9]
+// CHECK: 35:13: UnexposedExpr= Extent=[35:13 - 35:18]
+// CHECK: 35:13: IntegerLiteral= Extent=[35:13 - 35:18]
+// CHECK: 35:23: BinaryOperator= Extent=[35:23 - 35:47]
+// CHECK: 35:23: BinaryOperator= Extent=[35:23 - 35:33]
+// CHECK: 35:23: DeclRefExpr=c:2:14 Extent=[35:23 - 35:24]
+// CHECK: 35:28: UnexposedExpr= Extent=[35:28 - 35:33]
+// CHECK: 35:28: IntegerLiteral= Extent=[35:28 - 35:33]
+// CHECK: 35:37: BinaryOperator= Extent=[35:37 - 35:47]
+// CHECK: 35:37: DeclRefExpr=c:2:14 Extent=[35:37 - 35:38]
+// CHECK: 35:42: UnexposedExpr= Extent=[35:42 - 35:47]
+// CHECK: 35:42: IntegerLiteral= Extent=[35:42 - 35:47]
+// CHECK: 36:9: BinaryOperator= Extent=[36:9 - 36:33]
+// CHECK: 36:9: BinaryOperator= Extent=[36:9 - 36:19]
+// CHECK: 36:9: DeclRefExpr=c:2:14 Extent=[36:9 - 36:10]
+// CHECK: 36:14: UnexposedExpr= Extent=[36:14 - 36:19]
+// CHECK: 36:14: IntegerLiteral= Extent=[36:14 - 36:19]
+// CHECK: 36:23: BinaryOperator= Extent=[36:23 - 36:33]
+// CHECK: 36:23: DeclRefExpr=c:2:14 Extent=[36:23 - 36:24]
+// CHECK: 36:28: UnexposedExpr= Extent=[36:28 - 36:33]
+// CHECK: 36:28: IntegerLiteral= Extent=[36:28 - 36:33]
+// CHECK: 37:9: BinaryOperator= Extent=[37:9 - 37:33]
+// CHECK: 37:9: BinaryOperator= Extent=[37:9 - 37:19]
+// CHECK: 37:9: DeclRefExpr=c:2:14 Extent=[37:9 - 37:10]
+// CHECK: 37:14: UnexposedExpr= Extent=[37:14 - 37:19]
+// CHECK: 37:14: IntegerLiteral= Extent=[37:14 - 37:19]
+// CHECK: 37:23: BinaryOperator= Extent=[37:23 - 37:33]
+// CHECK: 37:23: DeclRefExpr=c:2:14 Extent=[37:23 - 37:24]
+// CHECK: 37:28: UnexposedExpr= Extent=[37:28 - 37:33]
+// CHECK: 37:28: IntegerLiteral= Extent=[37:28 - 37:33]
+// CHECK: 38:9: BinaryOperator= Extent=[38:9 - 38:33]
+// CHECK: 38:9: BinaryOperator= Extent=[38:9 - 38:19]
+// CHECK: 38:9: DeclRefExpr=c:2:14 Extent=[38:9 - 38:10]
+// CHECK: 38:14: UnexposedExpr= Extent=[38:14 - 38:19]
+// CHECK: 38:14: IntegerLiteral= Extent=[38:14 - 38:19]
+// CHECK: 38:23: BinaryOperator= Extent=[38:23 - 38:33]
+// CHECK: 38:23: DeclRefExpr=c:2:14 Extent=[38:23 - 38:24]
+// CHECK: 38:28: UnexposedExpr= Extent=[38:28 - 38:33]
+// CHECK: 38:28: IntegerLiteral= Extent=[38:28 - 38:33]
+// CHECK: 39:9: BinaryOperator= Extent=[39:9 - 39:33]
+// CHECK: 39:9: BinaryOperator= Extent=[39:9 - 39:19]
+// CHECK: 39:9: DeclRefExpr=c:2:14 Extent=[39:9 - 39:10]
+// CHECK: 39:14: UnexposedExpr= Extent=[39:14 - 39:19]
+// CHECK: 39:14: IntegerLiteral= Extent=[39:14 - 39:19]
+// CHECK: 39:23: BinaryOperator= Extent=[39:23 - 39:33]
+// CHECK: 39:23: DeclRefExpr=c:2:14 Extent=[39:23 - 39:24]
+// CHECK: 39:28: UnexposedExpr= Extent=[39:28 - 39:33]
+// CHECK: 39:28: IntegerLiteral= Extent=[39:28 - 39:33]
+// CHECK: 40:9: BinaryOperator= Extent=[40:9 - 40:33]
+// CHECK: 40:9: BinaryOperator= Extent=[40:9 - 40:19]
+// CHECK: 40:9: DeclRefExpr=c:2:14 Extent=[40:9 - 40:10]
+// CHECK: 40:14: UnexposedExpr= Extent=[40:14 - 40:19]
+// CHECK: 40:14: IntegerLiteral= Extent=[40:14 - 40:19]
+// CHECK: 40:23: BinaryOperator= Extent=[40:23 - 40:33]
+// CHECK: 40:23: DeclRefExpr=c:2:14 Extent=[40:23 - 40:24]
+// CHECK: 40:28: UnexposedExpr= Extent=[40:28 - 40:33]
+// CHECK: 40:28: IntegerLiteral= Extent=[40:28 - 40:33]
+// CHECK: 41:9: BinaryOperator= Extent=[41:9 - 41:33]
+// CHECK: 41:9: BinaryOperator= Extent=[41:9 - 41:19]
+// CHECK: 41:9: DeclRefExpr=c:2:14 Extent=[41:9 - 41:10]
+// CHECK: 41:14: UnexposedExpr= Extent=[41:14 - 41:19]
+// CHECK: 41:14: IntegerLiteral= Extent=[41:14 - 41:19]
+// CHECK: 41:23: BinaryOperator= Extent=[41:23 - 41:33]
+// CHECK: 41:23: DeclRefExpr=c:2:14 Extent=[41:23 - 41:24]
+// CHECK: 41:28: UnexposedExpr= Extent=[41:28 - 41:33]
+// CHECK: 41:28: IntegerLiteral= Extent=[41:28 - 41:33]
+// CHECK: 42:9: BinaryOperator= Extent=[42:9 - 42:33]
+// CHECK: 42:9: BinaryOperator= Extent=[42:9 - 42:19]
+// CHECK: 42:9: DeclRefExpr=c:2:14 Extent=[42:9 - 42:10]
+// CHECK: 42:14: UnexposedExpr= Extent=[42:14 - 42:19]
+// CHECK: 42:14: IntegerLiteral= Extent=[42:14 - 42:19]
+// CHECK: 42:23: BinaryOperator= Extent=[42:23 - 42:33]
+// CHECK: 42:23: DeclRefExpr=c:2:14 Extent=[42:23 - 42:24]
+// CHECK: 42:28: UnexposedExpr= Extent=[42:28 - 42:33]
+// CHECK: 42:28: IntegerLiteral= Extent=[42:28 - 42:33]
+// CHECK: 43:9: BinaryOperator= Extent=[43:9 - 43:33]
+// CHECK: 43:9: BinaryOperator= Extent=[43:9 - 43:19]
+// CHECK: 43:9: DeclRefExpr=c:2:14 Extent=[43:9 - 43:10]
+// CHECK: 43:14: UnexposedExpr= Extent=[43:14 - 43:19]
+// CHECK: 43:14: IntegerLiteral= Extent=[43:14 - 43:19]
+// CHECK: 43:23: BinaryOperator= Extent=[43:23 - 43:33]
+// CHECK: 43:23: DeclRefExpr=c:2:14 Extent=[43:23 - 43:24]
+// CHECK: 43:28: UnexposedExpr= Extent=[43:28 - 43:33]
+// CHECK: 43:28: IntegerLiteral= Extent=[43:28 - 43:33]
+// CHECK: 44:8: BinaryOperator= Extent=[44:8 - 44:18]
+// CHECK: 44:8: DeclRefExpr=c:2:14 Extent=[44:8 - 44:9]
+// CHECK: 44:13: UnexposedExpr= Extent=[44:13 - 44:18]
+// CHECK: 44:13: IntegerLiteral= Extent=[44:13 - 44:18]
+// CHECK: 44:23: BinaryOperator= Extent=[44:23 - 44:47]
+// CHECK: 44:23: BinaryOperator= Extent=[44:23 - 44:33]
+// CHECK: 44:23: DeclRefExpr=c:2:14 Extent=[44:23 - 44:24]
+// CHECK: 44:28: UnexposedExpr= Extent=[44:28 - 44:33]
+// CHECK: 44:28: IntegerLiteral= Extent=[44:28 - 44:33]
+// CHECK: 44:37: BinaryOperator= Extent=[44:37 - 44:47]
+// CHECK: 44:37: DeclRefExpr=c:2:14 Extent=[44:37 - 44:38]
+// CHECK: 44:42: UnexposedExpr= Extent=[44:42 - 44:47]
+// CHECK: 44:42: IntegerLiteral= Extent=[44:42 - 44:47]
+// CHECK: 45:9: BinaryOperator= Extent=[45:9 - 45:33]
+// CHECK: 45:9: BinaryOperator= Extent=[45:9 - 45:19]
+// CHECK: 45:9: DeclRefExpr=c:2:14 Extent=[45:9 - 45:10]
+// CHECK: 45:14: UnexposedExpr= Extent=[45:14 - 45:19]
+// CHECK: 45:14: IntegerLiteral= Extent=[45:14 - 45:19]
+// CHECK: 45:23: BinaryOperator= Extent=[45:23 - 45:33]
+// CHECK: 45:23: DeclRefExpr=c:2:14 Extent=[45:23 - 45:24]
+// CHECK: 45:28: UnexposedExpr= Extent=[45:28 - 45:33]
+// CHECK: 45:28: IntegerLiteral= Extent=[45:28 - 45:33]
+// CHECK: 46:8: BinaryOperator= Extent=[46:8 - 46:18]
+// CHECK: 46:8: DeclRefExpr=c:2:14 Extent=[46:8 - 46:9]
+// CHECK: 46:13: UnexposedExpr= Extent=[46:13 - 46:18]
+// CHECK: 46:13: IntegerLiteral= Extent=[46:13 - 46:18]
+// CHECK: 46:23: BinaryOperator= Extent=[46:23 - 46:47]
+// CHECK: 46:23: BinaryOperator= Extent=[46:23 - 46:33]
+// CHECK: 46:23: DeclRefExpr=c:2:14 Extent=[46:23 - 46:24]
+// CHECK: 46:28: UnexposedExpr= Extent=[46:28 - 46:33]
+// CHECK: 46:28: IntegerLiteral= Extent=[46:28 - 46:33]
+// CHECK: 46:37: BinaryOperator= Extent=[46:37 - 46:47]
+// CHECK: 46:37: DeclRefExpr=c:2:14 Extent=[46:37 - 46:38]
+// CHECK: 46:42: UnexposedExpr= Extent=[46:42 - 46:47]
+// CHECK: 46:42: IntegerLiteral= Extent=[46:42 - 46:47]
+// CHECK: 47:9: BinaryOperator= Extent=[47:9 - 47:33]
+// CHECK: 47:9: BinaryOperator= Extent=[47:9 - 47:19]
+// CHECK: 47:9: DeclRefExpr=c:2:14 Extent=[47:9 - 47:10]
+// CHECK: 47:14: UnexposedExpr= Extent=[47:14 - 47:19]
+// CHECK: 47:14: IntegerLiteral= Extent=[47:14 - 47:19]
+// CHECK: 47:23: BinaryOperator= Extent=[47:23 - 47:33]
+// CHECK: 47:23: DeclRefExpr=c:2:14 Extent=[47:23 - 47:24]
+// CHECK: 47:28: UnexposedExpr= Extent=[47:28 - 47:33]
+// CHECK: 47:28: IntegerLiteral= Extent=[47:28 - 47:33]
+// CHECK: 48:9: BinaryOperator= Extent=[48:9 - 48:33]
+// CHECK: 48:9: BinaryOperator= Extent=[48:9 - 48:19]
+// CHECK: 48:9: DeclRefExpr=c:2:14 Extent=[48:9 - 48:10]
+// CHECK: 48:14: UnexposedExpr= Extent=[48:14 - 48:19]
+// CHECK: 48:14: IntegerLiteral= Extent=[48:14 - 48:19]
+// CHECK: 48:23: BinaryOperator= Extent=[48:23 - 48:33]
+// CHECK: 48:23: DeclRefExpr=c:2:14 Extent=[48:23 - 48:24]
+// CHECK: 48:28: UnexposedExpr= Extent=[48:28 - 48:33]
+// CHECK: 48:28: IntegerLiteral= Extent=[48:28 - 48:33]
+// CHECK: 49:9: BinaryOperator= Extent=[49:9 - 49:33]
+// CHECK: 49:9: BinaryOperator= Extent=[49:9 - 49:19]
+// CHECK: 49:9: DeclRefExpr=c:2:14 Extent=[49:9 - 49:10]
+// CHECK: 49:14: UnexposedExpr= Extent=[49:14 - 49:19]
+// CHECK: 49:14: IntegerLiteral= Extent=[49:14 - 49:19]
+// CHECK: 49:23: BinaryOperator= Extent=[49:23 - 49:33]
+// CHECK: 49:23: DeclRefExpr=c:2:14 Extent=[49:23 - 49:24]
+// CHECK: 49:28: UnexposedExpr= Extent=[49:28 - 49:33]
+// CHECK: 49:28: IntegerLiteral= Extent=[49:28 - 49:33]
+// CHECK: 50:9: BinaryOperator= Extent=[50:9 - 50:33]
+// CHECK: 50:9: BinaryOperator= Extent=[50:9 - 50:19]
+// CHECK: 50:9: DeclRefExpr=c:2:14 Extent=[50:9 - 50:10]
+// CHECK: 50:14: UnexposedExpr= Extent=[50:14 - 50:19]
+// CHECK: 50:14: IntegerLiteral= Extent=[50:14 - 50:19]
+// CHECK: 50:23: BinaryOperator= Extent=[50:23 - 50:33]
+// CHECK: 50:23: DeclRefExpr=c:2:14 Extent=[50:23 - 50:24]
+// CHECK: 50:28: UnexposedExpr= Extent=[50:28 - 50:33]
+// CHECK: 50:28: IntegerLiteral= Extent=[50:28 - 50:33]
+// CHECK: 51:8: BinaryOperator= Extent=[51:8 - 51:18]
+// CHECK: 51:8: DeclRefExpr=c:2:14 Extent=[51:8 - 51:9]
+// CHECK: 51:13: UnexposedExpr= Extent=[51:13 - 51:18]
+// CHECK: 51:13: IntegerLiteral= Extent=[51:13 - 51:18]
+// CHECK: 51:23: BinaryOperator= Extent=[51:23 - 51:47]
+// CHECK: 51:23: BinaryOperator= Extent=[51:23 - 51:33]
+// CHECK: 51:23: DeclRefExpr=c:2:14 Extent=[51:23 - 51:24]
+// CHECK: 51:28: UnexposedExpr= Extent=[51:28 - 51:33]
+// CHECK: 51:28: IntegerLiteral= Extent=[51:28 - 51:33]
+// CHECK: 51:37: BinaryOperator= Extent=[51:37 - 51:47]
+// CHECK: 51:37: DeclRefExpr=c:2:14 Extent=[51:37 - 51:38]
+// CHECK: 51:42: UnexposedExpr= Extent=[51:42 - 51:47]
+// CHECK: 51:42: IntegerLiteral= Extent=[51:42 - 51:47]
+// CHECK: 52:9: BinaryOperator= Extent=[52:9 - 52:33]
+// CHECK: 52:9: BinaryOperator= Extent=[52:9 - 52:19]
+// CHECK: 52:9: DeclRefExpr=c:2:14 Extent=[52:9 - 52:10]
+// CHECK: 52:14: UnexposedExpr= Extent=[52:14 - 52:19]
+// CHECK: 52:14: IntegerLiteral= Extent=[52:14 - 52:19]
+// CHECK: 52:23: BinaryOperator= Extent=[52:23 - 52:33]
+// CHECK: 52:23: DeclRefExpr=c:2:14 Extent=[52:23 - 52:24]
+// CHECK: 52:28: UnexposedExpr= Extent=[52:28 - 52:33]
+// CHECK: 52:28: IntegerLiteral= Extent=[52:28 - 52:33]
+// CHECK: 53:9: BinaryOperator= Extent=[53:9 - 53:33]
+// CHECK: 53:9: BinaryOperator= Extent=[53:9 - 53:19]
+// CHECK: 53:9: DeclRefExpr=c:2:14 Extent=[53:9 - 53:10]
+// CHECK: 53:14: UnexposedExpr= Extent=[53:14 - 53:19]
+// CHECK: 53:14: IntegerLiteral= Extent=[53:14 - 53:19]
+// CHECK: 53:23: BinaryOperator= Extent=[53:23 - 53:33]
+// CHECK: 53:23: DeclRefExpr=c:2:14 Extent=[53:23 - 53:24]
+// CHECK: 53:28: UnexposedExpr= Extent=[53:28 - 53:33]
+// CHECK: 53:28: IntegerLiteral= Extent=[53:28 - 53:33]
+// CHECK: 54:9: BinaryOperator= Extent=[54:9 - 54:33]
+// CHECK: 54:9: BinaryOperator= Extent=[54:9 - 54:19]
+// CHECK: 54:9: DeclRefExpr=c:2:14 Extent=[54:9 - 54:10]
+// CHECK: 54:14: UnexposedExpr= Extent=[54:14 - 54:19]
+// CHECK: 54:14: IntegerLiteral= Extent=[54:14 - 54:19]
+// CHECK: 54:23: BinaryOperator= Extent=[54:23 - 54:33]
+// CHECK: 54:23: DeclRefExpr=c:2:14 Extent=[54:23 - 54:24]
+// CHECK: 54:28: UnexposedExpr= Extent=[54:28 - 54:33]
+// CHECK: 54:28: IntegerLiteral= Extent=[54:28 - 54:33]
+// CHECK: 55:9: BinaryOperator= Extent=[55:9 - 55:33]
+// CHECK: 55:9: BinaryOperator= Extent=[55:9 - 55:19]
+// CHECK: 55:9: DeclRefExpr=c:2:14 Extent=[55:9 - 55:10]
+// CHECK: 55:14: UnexposedExpr= Extent=[55:14 - 55:19]
+// CHECK: 55:14: IntegerLiteral= Extent=[55:14 - 55:19]
+// CHECK: 55:23: BinaryOperator= Extent=[55:23 - 55:33]
+// CHECK: 55:23: DeclRefExpr=c:2:14 Extent=[55:23 - 55:24]
+// CHECK: 55:28: UnexposedExpr= Extent=[55:28 - 55:33]
+// CHECK: 55:28: IntegerLiteral= Extent=[55:28 - 55:33]
+// CHECK: 56:9: BinaryOperator= Extent=[56:9 - 56:33]
+// CHECK: 56:9: BinaryOperator= Extent=[56:9 - 56:19]
+// CHECK: 56:9: DeclRefExpr=c:2:14 Extent=[56:9 - 56:10]
+// CHECK: 56:14: UnexposedExpr= Extent=[56:14 - 56:19]
+// CHECK: 56:14: IntegerLiteral= Extent=[56:14 - 56:19]
+// CHECK: 56:23: BinaryOperator= Extent=[56:23 - 56:33]
+// CHECK: 56:23: DeclRefExpr=c:2:14 Extent=[56:23 - 56:24]
+// CHECK: 56:28: UnexposedExpr= Extent=[56:28 - 56:33]
+// CHECK: 56:28: IntegerLiteral= Extent=[56:28 - 56:33]
+// CHECK: 57:9: BinaryOperator= Extent=[57:9 - 57:33]
+// CHECK: 57:9: BinaryOperator= Extent=[57:9 - 57:19]
+// CHECK: 57:9: DeclRefExpr=c:2:14 Extent=[57:9 - 57:10]
+// CHECK: 57:14: UnexposedExpr= Extent=[57:14 - 57:19]
+// CHECK: 57:14: IntegerLiteral= Extent=[57:14 - 57:19]
+// CHECK: 57:23: BinaryOperator= Extent=[57:23 - 57:33]
+// CHECK: 57:23: DeclRefExpr=c:2:14 Extent=[57:23 - 57:24]
+// CHECK: 57:28: UnexposedExpr= Extent=[57:28 - 57:33]
+// CHECK: 57:28: IntegerLiteral= Extent=[57:28 - 57:33]
+// CHECK: 58:9: BinaryOperator= Extent=[58:9 - 58:33]
+// CHECK: 58:9: BinaryOperator= Extent=[58:9 - 58:19]
+// CHECK: 58:9: DeclRefExpr=c:2:14 Extent=[58:9 - 58:10]
+// CHECK: 58:14: UnexposedExpr= Extent=[58:14 - 58:19]
+// CHECK: 58:14: IntegerLiteral= Extent=[58:14 - 58:19]
+// CHECK: 58:23: BinaryOperator= Extent=[58:23 - 58:33]
+// CHECK: 58:23: DeclRefExpr=c:2:14 Extent=[58:23 - 58:24]
+// CHECK: 58:28: UnexposedExpr= Extent=[58:28 - 58:33]
+// CHECK: 58:28: IntegerLiteral= Extent=[58:28 - 58:33]
+// CHECK: 59:9: BinaryOperator= Extent=[59:9 - 59:33]
+// CHECK: 59:9: BinaryOperator= Extent=[59:9 - 59:19]
+// CHECK: 59:9: DeclRefExpr=c:2:14 Extent=[59:9 - 59:10]
+// CHECK: 59:14: UnexposedExpr= Extent=[59:14 - 59:19]
+// CHECK: 59:14: IntegerLiteral= Extent=[59:14 - 59:19]
+// CHECK: 59:23: BinaryOperator= Extent=[59:23 - 59:33]
+// CHECK: 59:23: DeclRefExpr=c:2:14 Extent=[59:23 - 59:24]
+// CHECK: 59:28: UnexposedExpr= Extent=[59:28 - 59:33]
+// CHECK: 59:28: IntegerLiteral= Extent=[59:28 - 59:33]
+// CHECK: 60:9: BinaryOperator= Extent=[60:9 - 60:33]
+// CHECK: 60:9: BinaryOperator= Extent=[60:9 - 60:19]
+// CHECK: 60:9: DeclRefExpr=c:2:14 Extent=[60:9 - 60:10]
+// CHECK: 60:14: UnexposedExpr= Extent=[60:14 - 60:19]
+// CHECK: 60:14: IntegerLiteral= Extent=[60:14 - 60:19]
+// CHECK: 60:23: BinaryOperator= Extent=[60:23 - 60:33]
+// CHECK: 60:23: DeclRefExpr=c:2:14 Extent=[60:23 - 60:24]
+// CHECK: 60:28: UnexposedExpr= Extent=[60:28 - 60:33]
+// CHECK: 60:28: IntegerLiteral= Extent=[60:28 - 60:33]
+// CHECK: 61:9: BinaryOperator= Extent=[61:9 - 61:33]
+// CHECK: 61:9: BinaryOperator= Extent=[61:9 - 61:19]
+// CHECK: 61:9: DeclRefExpr=c:2:14 Extent=[61:9 - 61:10]
+// CHECK: 61:14: UnexposedExpr= Extent=[61:14 - 61:19]
+// CHECK: 61:14: IntegerLiteral= Extent=[61:14 - 61:19]
+// CHECK: 61:23: BinaryOperator= Extent=[61:23 - 61:33]
+// CHECK: 61:23: DeclRefExpr=c:2:14 Extent=[61:23 - 61:24]
+// CHECK: 61:28: UnexposedExpr= Extent=[61:28 - 61:33]
+// CHECK: 61:28: IntegerLiteral= Extent=[61:28 - 61:33]
+// CHECK: 62:9: BinaryOperator= Extent=[62:9 - 62:33]
+// CHECK: 62:9: BinaryOperator= Extent=[62:9 - 62:19]
+// CHECK: 62:9: DeclRefExpr=c:2:14 Extent=[62:9 - 62:10]
+// CHECK: 62:14: UnexposedExpr= Extent=[62:14 - 62:19]
+// CHECK: 62:14: IntegerLiteral= Extent=[62:14 - 62:19]
+// CHECK: 62:23: BinaryOperator= Extent=[62:23 - 62:33]
+// CHECK: 62:23: DeclRefExpr=c:2:14 Extent=[62:23 - 62:24]
+// CHECK: 62:28: UnexposedExpr= Extent=[62:28 - 62:33]
+// CHECK: 62:28: IntegerLiteral= Extent=[62:28 - 62:33]
+// CHECK: 63:8: BinaryOperator= Extent=[63:8 - 63:18]
+// CHECK: 63:8: DeclRefExpr=c:2:14 Extent=[63:8 - 63:9]
+// CHECK: 63:13: UnexposedExpr= Extent=[63:13 - 63:18]
+// CHECK: 63:13: IntegerLiteral= Extent=[63:13 - 63:18]
+// CHECK: 63:23: BinaryOperator= Extent=[63:23 - 63:47]
+// CHECK: 63:23: BinaryOperator= Extent=[63:23 - 63:33]
+// CHECK: 63:23: DeclRefExpr=c:2:14 Extent=[63:23 - 63:24]
+// CHECK: 63:28: UnexposedExpr= Extent=[63:28 - 63:33]
+// CHECK: 63:28: IntegerLiteral= Extent=[63:28 - 63:33]
+// CHECK: 63:37: BinaryOperator= Extent=[63:37 - 63:47]
+// CHECK: 63:37: DeclRefExpr=c:2:14 Extent=[63:37 - 63:38]
+// CHECK: 63:42: UnexposedExpr= Extent=[63:42 - 63:47]
+// CHECK: 63:42: IntegerLiteral= Extent=[63:42 - 63:47]
+// CHECK: 64:9: BinaryOperator= Extent=[64:9 - 64:33]
+// CHECK: 64:9: BinaryOperator= Extent=[64:9 - 64:19]
+// CHECK: 64:9: DeclRefExpr=c:2:14 Extent=[64:9 - 64:10]
+// CHECK: 64:14: UnexposedExpr= Extent=[64:14 - 64:19]
+// CHECK: 64:14: IntegerLiteral= Extent=[64:14 - 64:19]
+// CHECK: 64:23: BinaryOperator= Extent=[64:23 - 64:33]
+// CHECK: 64:23: DeclRefExpr=c:2:14 Extent=[64:23 - 64:24]
+// CHECK: 64:28: UnexposedExpr= Extent=[64:28 - 64:33]
+// CHECK: 64:28: IntegerLiteral= Extent=[64:28 - 64:33]
+// CHECK: 65:8: BinaryOperator= Extent=[65:8 - 65:18]
+// CHECK: 65:8: DeclRefExpr=c:2:14 Extent=[65:8 - 65:9]
+// CHECK: 65:13: UnexposedExpr= Extent=[65:13 - 65:18]
+// CHECK: 65:13: IntegerLiteral= Extent=[65:13 - 65:18]
+// CHECK: 65:23: BinaryOperator= Extent=[65:23 - 65:47]
+// CHECK: 65:23: BinaryOperator= Extent=[65:23 - 65:33]
+// CHECK: 65:23: DeclRefExpr=c:2:14 Extent=[65:23 - 65:24]
+// CHECK: 65:28: UnexposedExpr= Extent=[65:28 - 65:33]
+// CHECK: 65:28: IntegerLiteral= Extent=[65:28 - 65:33]
+// CHECK: 65:37: BinaryOperator= Extent=[65:37 - 65:47]
+// CHECK: 65:37: DeclRefExpr=c:2:14 Extent=[65:37 - 65:38]
+// CHECK: 65:42: UnexposedExpr= Extent=[65:42 - 65:47]
+// CHECK: 65:42: IntegerLiteral= Extent=[65:42 - 65:47]
+// CHECK: 66:9: BinaryOperator= Extent=[66:9 - 66:33]
+// CHECK: 66:9: BinaryOperator= Extent=[66:9 - 66:19]
+// CHECK: 66:9: DeclRefExpr=c:2:14 Extent=[66:9 - 66:10]
+// CHECK: 66:14: UnexposedExpr= Extent=[66:14 - 66:19]
+// CHECK: 66:14: IntegerLiteral= Extent=[66:14 - 66:19]
+// CHECK: 66:23: BinaryOperator= Extent=[66:23 - 66:33]
+// CHECK: 66:23: DeclRefExpr=c:2:14 Extent=[66:23 - 66:24]
+// CHECK: 66:28: UnexposedExpr= Extent=[66:28 - 66:33]
+// CHECK: 66:28: IntegerLiteral= Extent=[66:28 - 66:33]
+// CHECK: 67:9: BinaryOperator= Extent=[67:9 - 67:33]
+// CHECK: 67:9: BinaryOperator= Extent=[67:9 - 67:19]
+// CHECK: 67:9: DeclRefExpr=c:2:14 Extent=[67:9 - 67:10]
+// CHECK: 67:14: UnexposedExpr= Extent=[67:14 - 67:19]
+// CHECK: 67:14: IntegerLiteral= Extent=[67:14 - 67:19]
+// CHECK: 67:23: BinaryOperator= Extent=[67:23 - 67:33]
+// CHECK: 67:23: DeclRefExpr=c:2:14 Extent=[67:23 - 67:24]
+// CHECK: 67:28: UnexposedExpr= Extent=[67:28 - 67:33]
+// CHECK: 67:28: IntegerLiteral= Extent=[67:28 - 67:33]
+// CHECK: 68:9: BinaryOperator= Extent=[68:9 - 68:33]
+// CHECK: 68:9: BinaryOperator= Extent=[68:9 - 68:19]
+// CHECK: 68:9: DeclRefExpr=c:2:14 Extent=[68:9 - 68:10]
+// CHECK: 68:14: UnexposedExpr= Extent=[68:14 - 68:19]
+// CHECK: 68:14: IntegerLiteral= Extent=[68:14 - 68:19]
+// CHECK: 68:23: BinaryOperator= Extent=[68:23 - 68:33]
+// CHECK: 68:23: DeclRefExpr=c:2:14 Extent=[68:23 - 68:24]
+// CHECK: 68:28: UnexposedExpr= Extent=[68:28 - 68:33]
+// CHECK: 68:28: IntegerLiteral= Extent=[68:28 - 68:33]
+// CHECK: 69:9: BinaryOperator= Extent=[69:9 - 69:33]
+// CHECK: 69:9: BinaryOperator= Extent=[69:9 - 69:19]
+// CHECK: 69:9: DeclRefExpr=c:2:14 Extent=[69:9 - 69:10]
+// CHECK: 69:14: UnexposedExpr= Extent=[69:14 - 69:19]
+// CHECK: 69:14: IntegerLiteral= Extent=[69:14 - 69:19]
+// CHECK: 69:23: BinaryOperator= Extent=[69:23 - 69:33]
+// CHECK: 69:23: DeclRefExpr=c:2:14 Extent=[69:23 - 69:24]
+// CHECK: 69:28: UnexposedExpr= Extent=[69:28 - 69:33]
+// CHECK: 69:28: IntegerLiteral= Extent=[69:28 - 69:33]
+// CHECK: 70:8: BinaryOperator= Extent=[70:8 - 70:18]
+// CHECK: 70:8: DeclRefExpr=c:2:14 Extent=[70:8 - 70:9]
+// CHECK: 70:13: UnexposedExpr= Extent=[70:13 - 70:18]
+// CHECK: 70:13: IntegerLiteral= Extent=[70:13 - 70:18]
+// CHECK: 70:22: BinaryOperator= Extent=[70:22 - 70:32]
+// CHECK: 70:22: DeclRefExpr=c:2:14 Extent=[70:22 - 70:23]
+// CHECK: 70:27: UnexposedExpr= Extent=[70:27 - 70:32]
+// CHECK: 70:27: IntegerLiteral= Extent=[70:27 - 70:32]
+// CHECK: 70:37: BinaryOperator= Extent=[70:37 - 70:61]
+// CHECK: 70:37: BinaryOperator= Extent=[70:37 - 70:47]
+// CHECK: 70:37: DeclRefExpr=c:2:14 Extent=[70:37 - 70:38]
+// CHECK: 70:42: UnexposedExpr= Extent=[70:42 - 70:47]
+// CHECK: 70:42: IntegerLiteral= Extent=[70:42 - 70:47]
+// CHECK: 70:51: BinaryOperator= Extent=[70:51 - 70:61]
+// CHECK: 70:51: DeclRefExpr=c:2:14 Extent=[70:51 - 70:52]
+// CHECK: 70:56: UnexposedExpr= Extent=[70:56 - 70:61]
+// CHECK: 70:56: IntegerLiteral= Extent=[70:56 - 70:61]
+// CHECK: 71:9: BinaryOperator= Extent=[71:9 - 71:33]
+// CHECK: 71:9: BinaryOperator= Extent=[71:9 - 71:19]
+// CHECK: 71:9: DeclRefExpr=c:2:14 Extent=[71:9 - 71:10]
+// CHECK: 71:14: UnexposedExpr= Extent=[71:14 - 71:19]
+// CHECK: 71:14: IntegerLiteral= Extent=[71:14 - 71:19]
+// CHECK: 71:23: BinaryOperator= Extent=[71:23 - 71:33]
+// CHECK: 71:23: DeclRefExpr=c:2:14 Extent=[71:23 - 71:24]
+// CHECK: 71:28: UnexposedExpr= Extent=[71:28 - 71:33]
+// CHECK: 71:28: IntegerLiteral= Extent=[71:28 - 71:33]
+// CHECK: 72:9: BinaryOperator= Extent=[72:9 - 72:33]
+// CHECK: 72:9: BinaryOperator= Extent=[72:9 - 72:19]
+// CHECK: 72:9: DeclRefExpr=c:2:14 Extent=[72:9 - 72:10]
+// CHECK: 72:14: UnexposedExpr= Extent=[72:14 - 72:19]
+// CHECK: 72:14: IntegerLiteral= Extent=[72:14 - 72:19]
+// CHECK: 72:23: BinaryOperator= Extent=[72:23 - 72:33]
+// CHECK: 72:23: DeclRefExpr=c:2:14 Extent=[72:23 - 72:24]
+// CHECK: 72:28: UnexposedExpr= Extent=[72:28 - 72:33]
+// CHECK: 72:28: IntegerLiteral= Extent=[72:28 - 72:33]
+// CHECK: 73:9: BinaryOperator= Extent=[73:9 - 73:33]
+// CHECK: 73:9: BinaryOperator= Extent=[73:9 - 73:19]
+// CHECK: 73:9: DeclRefExpr=c:2:14 Extent=[73:9 - 73:10]
+// CHECK: 73:14: UnexposedExpr= Extent=[73:14 - 73:19]
+// CHECK: 73:14: IntegerLiteral= Extent=[73:14 - 73:19]
+// CHECK: 73:23: BinaryOperator= Extent=[73:23 - 73:33]
+// CHECK: 73:23: DeclRefExpr=c:2:14 Extent=[73:23 - 73:24]
+// CHECK: 73:28: UnexposedExpr= Extent=[73:28 - 73:33]
+// CHECK: 73:28: IntegerLiteral= Extent=[73:28 - 73:33]
+// CHECK: 74:9: BinaryOperator= Extent=[74:9 - 74:33]
+// CHECK: 74:9: BinaryOperator= Extent=[74:9 - 74:19]
+// CHECK: 74:9: DeclRefExpr=c:2:14 Extent=[74:9 - 74:10]
+// CHECK: 74:14: UnexposedExpr= Extent=[74:14 - 74:19]
+// CHECK: 74:14: IntegerLiteral= Extent=[74:14 - 74:19]
+// CHECK: 74:23: BinaryOperator= Extent=[74:23 - 74:33]
+// CHECK: 74:23: DeclRefExpr=c:2:14 Extent=[74:23 - 74:24]
+// CHECK: 74:28: UnexposedExpr= Extent=[74:28 - 74:33]
+// CHECK: 74:28: IntegerLiteral= Extent=[74:28 - 74:33]
+// CHECK: 75:9: BinaryOperator= Extent=[75:9 - 75:33]
+// CHECK: 75:9: BinaryOperator= Extent=[75:9 - 75:19]
+// CHECK: 75:9: DeclRefExpr=c:2:14 Extent=[75:9 - 75:10]
+// CHECK: 75:14: UnexposedExpr= Extent=[75:14 - 75:19]
+// CHECK: 75:14: IntegerLiteral= Extent=[75:14 - 75:19]
+// CHECK: 75:23: BinaryOperator= Extent=[75:23 - 75:33]
+// CHECK: 75:23: DeclRefExpr=c:2:14 Extent=[75:23 - 75:24]
+// CHECK: 75:28: UnexposedExpr= Extent=[75:28 - 75:33]
+// CHECK: 75:28: IntegerLiteral= Extent=[75:28 - 75:33]
+// CHECK: 76:8: BinaryOperator= Extent=[76:8 - 76:18]
+// CHECK: 76:8: DeclRefExpr=c:2:14 Extent=[76:8 - 76:9]
+// CHECK: 76:13: UnexposedExpr= Extent=[76:13 - 76:18]
+// CHECK: 76:13: IntegerLiteral= Extent=[76:13 - 76:18]
+// CHECK: 76:23: BinaryOperator= Extent=[76:23 - 76:47]
+// CHECK: 76:23: BinaryOperator= Extent=[76:23 - 76:33]
+// CHECK: 76:23: DeclRefExpr=c:2:14 Extent=[76:23 - 76:24]
+// CHECK: 76:28: UnexposedExpr= Extent=[76:28 - 76:33]
+// CHECK: 76:28: IntegerLiteral= Extent=[76:28 - 76:33]
+// CHECK: 76:37: BinaryOperator= Extent=[76:37 - 76:47]
+// CHECK: 76:37: DeclRefExpr=c:2:14 Extent=[76:37 - 76:38]
+// CHECK: 76:42: UnexposedExpr= Extent=[76:42 - 76:47]
+// CHECK: 76:42: IntegerLiteral= Extent=[76:42 - 76:47]
+// CHECK: 77:9: BinaryOperator= Extent=[77:9 - 77:33]
+// CHECK: 77:9: BinaryOperator= Extent=[77:9 - 77:19]
+// CHECK: 77:9: DeclRefExpr=c:2:14 Extent=[77:9 - 77:10]
+// CHECK: 77:14: UnexposedExpr= Extent=[77:14 - 77:19]
+// CHECK: 77:14: IntegerLiteral= Extent=[77:14 - 77:19]
+// CHECK: 77:23: BinaryOperator= Extent=[77:23 - 77:33]
+// CHECK: 77:23: DeclRefExpr=c:2:14 Extent=[77:23 - 77:24]
+// CHECK: 77:28: UnexposedExpr= Extent=[77:28 - 77:33]
+// CHECK: 77:28: IntegerLiteral= Extent=[77:28 - 77:33]
+// CHECK: 78:9: BinaryOperator= Extent=[78:9 - 78:33]
+// CHECK: 78:9: BinaryOperator= Extent=[78:9 - 78:19]
+// CHECK: 78:9: DeclRefExpr=c:2:14 Extent=[78:9 - 78:10]
+// CHECK: 78:14: UnexposedExpr= Extent=[78:14 - 78:19]
+// CHECK: 78:14: IntegerLiteral= Extent=[78:14 - 78:19]
+// CHECK: 78:23: BinaryOperator= Extent=[78:23 - 78:33]
+// CHECK: 78:23: DeclRefExpr=c:2:14 Extent=[78:23 - 78:24]
+// CHECK: 78:28: UnexposedExpr= Extent=[78:28 - 78:33]
+// CHECK: 78:28: IntegerLiteral= Extent=[78:28 - 78:33]
+// CHECK: 79:9: BinaryOperator= Extent=[79:9 - 79:33]
+// CHECK: 79:9: BinaryOperator= Extent=[79:9 - 79:19]
+// CHECK: 79:9: DeclRefExpr=c:2:14 Extent=[79:9 - 79:10]
+// CHECK: 79:14: UnexposedExpr= Extent=[79:14 - 79:19]
+// CHECK: 79:14: IntegerLiteral= Extent=[79:14 - 79:19]
+// CHECK: 79:23: BinaryOperator= Extent=[79:23 - 79:33]
+// CHECK: 79:23: DeclRefExpr=c:2:14 Extent=[79:23 - 79:24]
+// CHECK: 79:28: UnexposedExpr= Extent=[79:28 - 79:33]
+// CHECK: 79:28: IntegerLiteral= Extent=[79:28 - 79:33]
+// CHECK: 80:9: BinaryOperator= Extent=[80:9 - 80:33]
+// CHECK: 80:9: BinaryOperator= Extent=[80:9 - 80:19]
+// CHECK: 80:9: DeclRefExpr=c:2:14 Extent=[80:9 - 80:10]
+// CHECK: 80:14: UnexposedExpr= Extent=[80:14 - 80:19]
+// CHECK: 80:14: IntegerLiteral= Extent=[80:14 - 80:19]
+// CHECK: 80:23: BinaryOperator= Extent=[80:23 - 80:33]
+// CHECK: 80:23: DeclRefExpr=c:2:14 Extent=[80:23 - 80:24]
+// CHECK: 80:28: UnexposedExpr= Extent=[80:28 - 80:33]
+// CHECK: 80:28: IntegerLiteral= Extent=[80:28 - 80:33]
+// CHECK: 81:9: BinaryOperator= Extent=[81:9 - 81:33]
+// CHECK: 81:9: BinaryOperator= Extent=[81:9 - 81:19]
+// CHECK: 81:9: DeclRefExpr=c:2:14 Extent=[81:9 - 81:10]
+// CHECK: 81:14: UnexposedExpr= Extent=[81:14 - 81:19]
+// CHECK: 81:14: IntegerLiteral= Extent=[81:14 - 81:19]
+// CHECK: 81:23: BinaryOperator= Extent=[81:23 - 81:33]
+// CHECK: 81:23: DeclRefExpr=c:2:14 Extent=[81:23 - 81:24]
+// CHECK: 81:28: UnexposedExpr= Extent=[81:28 - 81:33]
+// CHECK: 81:28: IntegerLiteral= Extent=[81:28 - 81:33]
+// CHECK: 82:8: BinaryOperator= Extent=[82:8 - 82:18]
+// CHECK: 82:8: DeclRefExpr=c:2:14 Extent=[82:8 - 82:9]
+// CHECK: 82:13: UnexposedExpr= Extent=[82:13 - 82:18]
+// CHECK: 82:13: IntegerLiteral= Extent=[82:13 - 82:18]
+// CHECK: 82:23: BinaryOperator= Extent=[82:23 - 82:47]
+// CHECK: 82:23: BinaryOperator= Extent=[82:23 - 82:33]
+// CHECK: 82:23: DeclRefExpr=c:2:14 Extent=[82:23 - 82:24]
+// CHECK: 82:28: UnexposedExpr= Extent=[82:28 - 82:33]
+// CHECK: 82:28: IntegerLiteral= Extent=[82:28 - 82:33]
+// CHECK: 82:37: BinaryOperator= Extent=[82:37 - 82:47]
+// CHECK: 82:37: DeclRefExpr=c:2:14 Extent=[82:37 - 82:38]
+// CHECK: 82:42: UnexposedExpr= Extent=[82:42 - 82:47]
+// CHECK: 82:42: IntegerLiteral= Extent=[82:42 - 82:47]
+// CHECK: 83:9: BinaryOperator= Extent=[83:9 - 83:33]
+// CHECK: 83:9: BinaryOperator= Extent=[83:9 - 83:19]
+// CHECK: 83:9: DeclRefExpr=c:2:14 Extent=[83:9 - 83:10]
+// CHECK: 83:14: UnexposedExpr= Extent=[83:14 - 83:19]
+// CHECK: 83:14: IntegerLiteral= Extent=[83:14 - 83:19]
+// CHECK: 83:23: BinaryOperator= Extent=[83:23 - 83:33]
+// CHECK: 83:23: DeclRefExpr=c:2:14 Extent=[83:23 - 83:24]
+// CHECK: 83:28: UnexposedExpr= Extent=[83:28 - 83:33]
+// CHECK: 83:28: IntegerLiteral= Extent=[83:28 - 83:33]
+// CHECK: 84:9: BinaryOperator= Extent=[84:9 - 84:33]
+// CHECK: 84:9: BinaryOperator= Extent=[84:9 - 84:19]
+// CHECK: 84:9: DeclRefExpr=c:2:14 Extent=[84:9 - 84:10]
+// CHECK: 84:14: UnexposedExpr= Extent=[84:14 - 84:19]
+// CHECK: 84:14: IntegerLiteral= Extent=[84:14 - 84:19]
+// CHECK: 84:23: BinaryOperator= Extent=[84:23 - 84:33]
+// CHECK: 84:23: DeclRefExpr=c:2:14 Extent=[84:23 - 84:24]
+// CHECK: 84:28: UnexposedExpr= Extent=[84:28 - 84:33]
+// CHECK: 84:28: IntegerLiteral= Extent=[84:28 - 84:33]
+// CHECK: 85:9: BinaryOperator= Extent=[85:9 - 85:33]
+// CHECK: 85:9: BinaryOperator= Extent=[85:9 - 85:19]
+// CHECK: 85:9: DeclRefExpr=c:2:14 Extent=[85:9 - 85:10]
+// CHECK: 85:14: UnexposedExpr= Extent=[85:14 - 85:19]
+// CHECK: 85:14: IntegerLiteral= Extent=[85:14 - 85:19]
+// CHECK: 85:23: BinaryOperator= Extent=[85:23 - 85:33]
+// CHECK: 85:23: DeclRefExpr=c:2:14 Extent=[85:23 - 85:24]
+// CHECK: 85:28: UnexposedExpr= Extent=[85:28 - 85:33]
+// CHECK: 85:28: IntegerLiteral= Extent=[85:28 - 85:33]
+// CHECK: 86:9: BinaryOperator= Extent=[86:9 - 86:33]
+// CHECK: 86:9: BinaryOperator= Extent=[86:9 - 86:19]
+// CHECK: 86:9: DeclRefExpr=c:2:14 Extent=[86:9 - 86:10]
+// CHECK: 86:14: UnexposedExpr= Extent=[86:14 - 86:19]
+// CHECK: 86:14: IntegerLiteral= Extent=[86:14 - 86:19]
+// CHECK: 86:23: BinaryOperator= Extent=[86:23 - 86:33]
+// CHECK: 86:23: DeclRefExpr=c:2:14 Extent=[86:23 - 86:24]
+// CHECK: 86:28: UnexposedExpr= Extent=[86:28 - 86:33]
+// CHECK: 86:28: IntegerLiteral= Extent=[86:28 - 86:33]
+// CHECK: 87:9: BinaryOperator= Extent=[87:9 - 87:33]
+// CHECK: 87:9: BinaryOperator= Extent=[87:9 - 87:19]
+// CHECK: 87:9: DeclRefExpr=c:2:14 Extent=[87:9 - 87:10]
+// CHECK: 87:14: UnexposedExpr= Extent=[87:14 - 87:19]
+// CHECK: 87:14: IntegerLiteral= Extent=[87:14 - 87:19]
+// CHECK: 87:23: BinaryOperator= Extent=[87:23 - 87:33]
+// CHECK: 87:23: DeclRefExpr=c:2:14 Extent=[87:23 - 87:24]
+// CHECK: 87:28: UnexposedExpr= Extent=[87:28 - 87:33]
+// CHECK: 87:28: IntegerLiteral= Extent=[87:28 - 87:33]
+// CHECK: 88:9: BinaryOperator= Extent=[88:9 - 88:33]
+// CHECK: 88:9: BinaryOperator= Extent=[88:9 - 88:19]
+// CHECK: 88:9: DeclRefExpr=c:2:14 Extent=[88:9 - 88:10]
+// CHECK: 88:14: UnexposedExpr= Extent=[88:14 - 88:19]
+// CHECK: 88:14: IntegerLiteral= Extent=[88:14 - 88:19]
+// CHECK: 88:23: BinaryOperator= Extent=[88:23 - 88:33]
+// CHECK: 88:23: DeclRefExpr=c:2:14 Extent=[88:23 - 88:24]
+// CHECK: 88:28: UnexposedExpr= Extent=[88:28 - 88:33]
+// CHECK: 88:28: IntegerLiteral= Extent=[88:28 - 88:33]
+// CHECK: 89:9: BinaryOperator= Extent=[89:9 - 89:33]
+// CHECK: 89:9: BinaryOperator= Extent=[89:9 - 89:19]
+// CHECK: 89:9: DeclRefExpr=c:2:14 Extent=[89:9 - 89:10]
+// CHECK: 89:14: UnexposedExpr= Extent=[89:14 - 89:19]
+// CHECK: 89:14: IntegerLiteral= Extent=[89:14 - 89:19]
+// CHECK: 89:23: BinaryOperator= Extent=[89:23 - 89:33]
+// CHECK: 89:23: DeclRefExpr=c:2:14 Extent=[89:23 - 89:24]
+// CHECK: 89:28: UnexposedExpr= Extent=[89:28 - 89:33]
+// CHECK: 89:28: IntegerLiteral= Extent=[89:28 - 89:33]
+// CHECK: 90:9: BinaryOperator= Extent=[90:9 - 90:33]
+// CHECK: 90:9: BinaryOperator= Extent=[90:9 - 90:19]
+// CHECK: 90:9: DeclRefExpr=c:2:14 Extent=[90:9 - 90:10]
+// CHECK: 90:14: UnexposedExpr= Extent=[90:14 - 90:19]
+// CHECK: 90:14: IntegerLiteral= Extent=[90:14 - 90:19]
+// CHECK: 90:23: BinaryOperator= Extent=[90:23 - 90:33]
+// CHECK: 90:23: DeclRefExpr=c:2:14 Extent=[90:23 - 90:24]
+// CHECK: 90:28: UnexposedExpr= Extent=[90:28 - 90:33]
+// CHECK: 90:28: IntegerLiteral= Extent=[90:28 - 90:33]
+// CHECK: 91:9: BinaryOperator= Extent=[91:9 - 91:33]
+// CHECK: 91:9: BinaryOperator= Extent=[91:9 - 91:19]
+// CHECK: 91:9: DeclRefExpr=c:2:14 Extent=[91:9 - 91:10]
+// CHECK: 91:14: UnexposedExpr= Extent=[91:14 - 91:19]
+// CHECK: 91:14: IntegerLiteral= Extent=[91:14 - 91:19]
+// CHECK: 91:23: BinaryOperator= Extent=[91:23 - 91:33]
+// CHECK: 91:23: DeclRefExpr=c:2:14 Extent=[91:23 - 91:24]
+// CHECK: 91:28: UnexposedExpr= Extent=[91:28 - 91:33]
+// CHECK: 91:28: IntegerLiteral= Extent=[91:28 - 91:33]
+// CHECK: 92:9: BinaryOperator= Extent=[92:9 - 92:33]
+// CHECK: 92:9: BinaryOperator= Extent=[92:9 - 92:19]
+// CHECK: 92:9: DeclRefExpr=c:2:14 Extent=[92:9 - 92:10]
+// CHECK: 92:14: UnexposedExpr= Extent=[92:14 - 92:19]
+// CHECK: 92:14: IntegerLiteral= Extent=[92:14 - 92:19]
+// CHECK: 92:23: BinaryOperator= Extent=[92:23 - 92:33]
+// CHECK: 92:23: DeclRefExpr=c:2:14 Extent=[92:23 - 92:24]
+// CHECK: 92:28: UnexposedExpr= Extent=[92:28 - 92:33]
+// CHECK: 92:28: IntegerLiteral= Extent=[92:28 - 92:33]
+// CHECK: 93:9: BinaryOperator= Extent=[93:9 - 93:33]
+// CHECK: 93:9: BinaryOperator= Extent=[93:9 - 93:19]
+// CHECK: 93:9: DeclRefExpr=c:2:14 Extent=[93:9 - 93:10]
+// CHECK: 93:14: UnexposedExpr= Extent=[93:14 - 93:19]
+// CHECK: 93:14: IntegerLiteral= Extent=[93:14 - 93:19]
+// CHECK: 93:23: BinaryOperator= Extent=[93:23 - 93:33]
+// CHECK: 93:23: DeclRefExpr=c:2:14 Extent=[93:23 - 93:24]
+// CHECK: 93:28: UnexposedExpr= Extent=[93:28 - 93:33]
+// CHECK: 93:28: IntegerLiteral= Extent=[93:28 - 93:33]
+// CHECK: 94:9: BinaryOperator= Extent=[94:9 - 94:33]
+// CHECK: 94:9: BinaryOperator= Extent=[94:9 - 94:19]
+// CHECK: 94:9: DeclRefExpr=c:2:14 Extent=[94:9 - 94:10]
+// CHECK: 94:14: UnexposedExpr= Extent=[94:14 - 94:19]
+// CHECK: 94:14: IntegerLiteral= Extent=[94:14 - 94:19]
+// CHECK: 94:23: BinaryOperator= Extent=[94:23 - 94:33]
+// CHECK: 94:23: DeclRefExpr=c:2:14 Extent=[94:23 - 94:24]
+// CHECK: 94:28: UnexposedExpr= Extent=[94:28 - 94:33]
+// CHECK: 94:28: IntegerLiteral= Extent=[94:28 - 94:33]
+// CHECK: 95:9: BinaryOperator= Extent=[95:9 - 95:33]
+// CHECK: 95:9: BinaryOperator= Extent=[95:9 - 95:19]
+// CHECK: 95:9: DeclRefExpr=c:2:14 Extent=[95:9 - 95:10]
+// CHECK: 95:14: UnexposedExpr= Extent=[95:14 - 95:19]
+// CHECK: 95:14: IntegerLiteral= Extent=[95:14 - 95:19]
+// CHECK: 95:23: BinaryOperator= Extent=[95:23 - 95:33]
+// CHECK: 95:23: DeclRefExpr=c:2:14 Extent=[95:23 - 95:24]
+// CHECK: 95:28: UnexposedExpr= Extent=[95:28 - 95:33]
+// CHECK: 95:28: IntegerLiteral= Extent=[95:28 - 95:33]
+// CHECK: 96:9: BinaryOperator= Extent=[96:9 - 96:33]
+// CHECK: 96:9: BinaryOperator= Extent=[96:9 - 96:19]
+// CHECK: 96:9: DeclRefExpr=c:2:14 Extent=[96:9 - 96:10]
+// CHECK: 96:14: UnexposedExpr= Extent=[96:14 - 96:19]
+// CHECK: 96:14: IntegerLiteral= Extent=[96:14 - 96:19]
+// CHECK: 96:23: BinaryOperator= Extent=[96:23 - 96:33]
+// CHECK: 96:23: DeclRefExpr=c:2:14 Extent=[96:23 - 96:24]
+// CHECK: 96:28: UnexposedExpr= Extent=[96:28 - 96:33]
+// CHECK: 96:28: IntegerLiteral= Extent=[96:28 - 96:33]
+// CHECK: 97:9: BinaryOperator= Extent=[97:9 - 97:33]
+// CHECK: 97:9: BinaryOperator= Extent=[97:9 - 97:19]
+// CHECK: 97:9: DeclRefExpr=c:2:14 Extent=[97:9 - 97:10]
+// CHECK: 97:14: UnexposedExpr= Extent=[97:14 - 97:19]
+// CHECK: 97:14: IntegerLiteral= Extent=[97:14 - 97:19]
+// CHECK: 97:23: BinaryOperator= Extent=[97:23 - 97:33]
+// CHECK: 97:23: DeclRefExpr=c:2:14 Extent=[97:23 - 97:24]
+// CHECK: 97:28: UnexposedExpr= Extent=[97:28 - 97:33]
+// CHECK: 97:28: IntegerLiteral= Extent=[97:28 - 97:33]
+// CHECK: 98:8: BinaryOperator= Extent=[98:8 - 98:18]
+// CHECK: 98:8: DeclRefExpr=c:2:14 Extent=[98:8 - 98:9]
+// CHECK: 98:13: UnexposedExpr= Extent=[98:13 - 98:18]
+// CHECK: 98:13: IntegerLiteral= Extent=[98:13 - 98:18]
+// CHECK: 98:23: BinaryOperator= Extent=[98:23 - 98:47]
+// CHECK: 98:23: BinaryOperator= Extent=[98:23 - 98:33]
+// CHECK: 98:23: DeclRefExpr=c:2:14 Extent=[98:23 - 98:24]
+// CHECK: 98:28: UnexposedExpr= Extent=[98:28 - 98:33]
+// CHECK: 98:28: IntegerLiteral= Extent=[98:28 - 98:33]
+// CHECK: 98:37: BinaryOperator= Extent=[98:37 - 98:47]
+// CHECK: 98:37: DeclRefExpr=c:2:14 Extent=[98:37 - 98:38]
+// CHECK: 98:42: UnexposedExpr= Extent=[98:42 - 98:47]
+// CHECK: 98:42: IntegerLiteral= Extent=[98:42 - 98:47]
+// CHECK: 99:9: BinaryOperator= Extent=[99:9 - 99:33]
+// CHECK: 99:9: BinaryOperator= Extent=[99:9 - 99:19]
+// CHECK: 99:9: DeclRefExpr=c:2:14 Extent=[99:9 - 99:10]
+// CHECK: 99:14: UnexposedExpr= Extent=[99:14 - 99:19]
+// CHECK: 99:14: IntegerLiteral= Extent=[99:14 - 99:19]
+// CHECK: 99:23: BinaryOperator= Extent=[99:23 - 99:33]
+// CHECK: 99:23: DeclRefExpr=c:2:14 Extent=[99:23 - 99:24]
+// CHECK: 99:28: UnexposedExpr= Extent=[99:28 - 99:33]
+// CHECK: 99:28: IntegerLiteral= Extent=[99:28 - 99:33]
+// CHECK: 100:9: BinaryOperator= Extent=[100:9 - 100:33]
+// CHECK: 100:9: BinaryOperator= Extent=[100:9 - 100:19]
+// CHECK: 100:9: DeclRefExpr=c:2:14 Extent=[100:9 - 100:10]
+// CHECK: 100:14: UnexposedExpr= Extent=[100:14 - 100:19]
+// CHECK: 100:14: IntegerLiteral= Extent=[100:14 - 100:19]
+// CHECK: 100:23: BinaryOperator= Extent=[100:23 - 100:33]
+// CHECK: 100:23: DeclRefExpr=c:2:14 Extent=[100:23 - 100:24]
+// CHECK: 100:28: UnexposedExpr= Extent=[100:28 - 100:33]
+// CHECK: 100:28: IntegerLiteral= Extent=[100:28 - 100:33]
+// CHECK: 101:9: BinaryOperator= Extent=[101:9 - 101:33]
+// CHECK: 101:9: BinaryOperator= Extent=[101:9 - 101:19]
+// CHECK: 101:9: DeclRefExpr=c:2:14 Extent=[101:9 - 101:10]
+// CHECK: 101:14: UnexposedExpr= Extent=[101:14 - 101:19]
+// CHECK: 101:14: IntegerLiteral= Extent=[101:14 - 101:19]
+// CHECK: 101:23: BinaryOperator= Extent=[101:23 - 101:33]
+// CHECK: 101:23: DeclRefExpr=c:2:14 Extent=[101:23 - 101:24]
+// CHECK: 101:28: UnexposedExpr= Extent=[101:28 - 101:33]
+// CHECK: 101:28: IntegerLiteral= Extent=[101:28 - 101:33]
+// CHECK: 102:9: BinaryOperator= Extent=[102:9 - 102:33]
+// CHECK: 102:9: BinaryOperator= Extent=[102:9 - 102:19]
+// CHECK: 102:9: DeclRefExpr=c:2:14 Extent=[102:9 - 102:10]
+// CHECK: 102:14: UnexposedExpr= Extent=[102:14 - 102:19]
+// CHECK: 102:14: IntegerLiteral= Extent=[102:14 - 102:19]
+// CHECK: 102:23: BinaryOperator= Extent=[102:23 - 102:33]
+// CHECK: 102:23: DeclRefExpr=c:2:14 Extent=[102:23 - 102:24]
+// CHECK: 102:28: UnexposedExpr= Extent=[102:28 - 102:33]
+// CHECK: 102:28: IntegerLiteral= Extent=[102:28 - 102:33]
+// CHECK: 103:9: BinaryOperator= Extent=[103:9 - 103:33]
+// CHECK: 103:9: BinaryOperator= Extent=[103:9 - 103:19]
+// CHECK: 103:9: DeclRefExpr=c:2:14 Extent=[103:9 - 103:10]
+// CHECK: 103:14: UnexposedExpr= Extent=[103:14 - 103:19]
+// CHECK: 103:14: IntegerLiteral= Extent=[103:14 - 103:19]
+// CHECK: 103:23: BinaryOperator= Extent=[103:23 - 103:33]
+// CHECK: 103:23: DeclRefExpr=c:2:14 Extent=[103:23 - 103:24]
+// CHECK: 103:28: UnexposedExpr= Extent=[103:28 - 103:33]
+// CHECK: 103:28: IntegerLiteral= Extent=[103:28 - 103:33]
+// CHECK: 104:9: BinaryOperator= Extent=[104:9 - 104:33]
+// CHECK: 104:9: BinaryOperator= Extent=[104:9 - 104:19]
+// CHECK: 104:9: DeclRefExpr=c:2:14 Extent=[104:9 - 104:10]
+// CHECK: 104:14: UnexposedExpr= Extent=[104:14 - 104:19]
+// CHECK: 104:14: IntegerLiteral= Extent=[104:14 - 104:19]
+// CHECK: 104:23: BinaryOperator= Extent=[104:23 - 104:33]
+// CHECK: 104:23: DeclRefExpr=c:2:14 Extent=[104:23 - 104:24]
+// CHECK: 104:28: UnexposedExpr= Extent=[104:28 - 104:33]
+// CHECK: 104:28: IntegerLiteral= Extent=[104:28 - 104:33]
+// CHECK: 105:8: BinaryOperator= Extent=[105:8 - 105:18]
+// CHECK: 105:8: DeclRefExpr=c:2:14 Extent=[105:8 - 105:9]
+// CHECK: 105:13: UnexposedExpr= Extent=[105:13 - 105:18]
+// CHECK: 105:13: IntegerLiteral= Extent=[105:13 - 105:18]
+// CHECK: 105:23: BinaryOperator= Extent=[105:23 - 105:47]
+// CHECK: 105:23: BinaryOperator= Extent=[105:23 - 105:33]
+// CHECK: 105:23: DeclRefExpr=c:2:14 Extent=[105:23 - 105:24]
+// CHECK: 105:28: UnexposedExpr= Extent=[105:28 - 105:33]
+// CHECK: 105:28: IntegerLiteral= Extent=[105:28 - 105:33]
+// CHECK: 105:37: BinaryOperator= Extent=[105:37 - 105:47]
+// CHECK: 105:37: DeclRefExpr=c:2:14 Extent=[105:37 - 105:38]
+// CHECK: 105:42: UnexposedExpr= Extent=[105:42 - 105:47]
+// CHECK: 105:42: IntegerLiteral= Extent=[105:42 - 105:47]
+// CHECK: 106:9: BinaryOperator= Extent=[106:9 - 106:33]
+// CHECK: 106:9: BinaryOperator= Extent=[106:9 - 106:19]
+// CHECK: 106:9: DeclRefExpr=c:2:14 Extent=[106:9 - 106:10]
+// CHECK: 106:14: UnexposedExpr= Extent=[106:14 - 106:19]
+// CHECK: 106:14: IntegerLiteral= Extent=[106:14 - 106:19]
+// CHECK: 106:23: BinaryOperator= Extent=[106:23 - 106:33]
+// CHECK: 106:23: DeclRefExpr=c:2:14 Extent=[106:23 - 106:24]
+// CHECK: 106:28: UnexposedExpr= Extent=[106:28 - 106:33]
+// CHECK: 106:28: IntegerLiteral= Extent=[106:28 - 106:33]
+// CHECK: 107:9: BinaryOperator= Extent=[107:9 - 107:33]
+// CHECK: 107:9: BinaryOperator= Extent=[107:9 - 107:19]
+// CHECK: 107:9: DeclRefExpr=c:2:14 Extent=[107:9 - 107:10]
+// CHECK: 107:14: UnexposedExpr= Extent=[107:14 - 107:19]
+// CHECK: 107:14: IntegerLiteral= Extent=[107:14 - 107:19]
+// CHECK: 107:23: BinaryOperator= Extent=[107:23 - 107:33]
+// CHECK: 107:23: DeclRefExpr=c:2:14 Extent=[107:23 - 107:24]
+// CHECK: 107:28: UnexposedExpr= Extent=[107:28 - 107:33]
+// CHECK: 107:28: IntegerLiteral= Extent=[107:28 - 107:33]
+// CHECK: 108:8: BinaryOperator= Extent=[108:8 - 108:18]
+// CHECK: 108:8: DeclRefExpr=c:2:14 Extent=[108:8 - 108:9]
+// CHECK: 108:13: UnexposedExpr= Extent=[108:13 - 108:18]
+// CHECK: 108:13: IntegerLiteral= Extent=[108:13 - 108:18]
+// CHECK: 108:23: BinaryOperator= Extent=[108:23 - 108:47]
+// CHECK: 108:23: BinaryOperator= Extent=[108:23 - 108:33]
+// CHECK: 108:23: DeclRefExpr=c:2:14 Extent=[108:23 - 108:24]
+// CHECK: 108:28: UnexposedExpr= Extent=[108:28 - 108:33]
+// CHECK: 108:28: IntegerLiteral= Extent=[108:28 - 108:33]
+// CHECK: 108:37: BinaryOperator= Extent=[108:37 - 108:47]
+// CHECK: 108:37: DeclRefExpr=c:2:14 Extent=[108:37 - 108:38]
+// CHECK: 108:42: UnexposedExpr= Extent=[108:42 - 108:47]
+// CHECK: 108:42: IntegerLiteral= Extent=[108:42 - 108:47]
+// CHECK: 109:8: BinaryOperator= Extent=[109:8 - 109:18]
+// CHECK: 109:8: DeclRefExpr=c:2:14 Extent=[109:8 - 109:9]
+// CHECK: 109:13: UnexposedExpr= Extent=[109:13 - 109:18]
+// CHECK: 109:13: IntegerLiteral= Extent=[109:13 - 109:18]
+// CHECK: 109:22: BinaryOperator= Extent=[109:22 - 109:32]
+// CHECK: 109:22: DeclRefExpr=c:2:14 Extent=[109:22 - 109:23]
+// CHECK: 109:27: UnexposedExpr= Extent=[109:27 - 109:32]
+// CHECK: 109:27: IntegerLiteral= Extent=[109:27 - 109:32]
+// CHECK: 109:37: BinaryOperator= Extent=[109:37 - 109:61]
+// CHECK: 109:37: BinaryOperator= Extent=[109:37 - 109:47]
+// CHECK: 109:37: DeclRefExpr=c:2:14 Extent=[109:37 - 109:38]
+// CHECK: 109:42: UnexposedExpr= Extent=[109:42 - 109:47]
+// CHECK: 109:42: IntegerLiteral= Extent=[109:42 - 109:47]
+// CHECK: 109:51: BinaryOperator= Extent=[109:51 - 109:61]
+// CHECK: 109:51: DeclRefExpr=c:2:14 Extent=[109:51 - 109:52]
+// CHECK: 109:56: UnexposedExpr= Extent=[109:56 - 109:61]
+// CHECK: 109:56: IntegerLiteral= Extent=[109:56 - 109:61]
+// CHECK: 110:9: BinaryOperator= Extent=[110:9 - 110:33]
+// CHECK: 110:9: BinaryOperator= Extent=[110:9 - 110:19]
+// CHECK: 110:9: DeclRefExpr=c:2:14 Extent=[110:9 - 110:10]
+// CHECK: 110:14: UnexposedExpr= Extent=[110:14 - 110:19]
+// CHECK: 110:14: IntegerLiteral= Extent=[110:14 - 110:19]
+// CHECK: 110:23: BinaryOperator= Extent=[110:23 - 110:33]
+// CHECK: 110:23: DeclRefExpr=c:2:14 Extent=[110:23 - 110:24]
+// CHECK: 110:28: UnexposedExpr= Extent=[110:28 - 110:33]
+// CHECK: 110:28: IntegerLiteral= Extent=[110:28 - 110:33]
+// CHECK: 111:9: BinaryOperator= Extent=[111:9 - 111:33]
+// CHECK: 111:9: BinaryOperator= Extent=[111:9 - 111:19]
+// CHECK: 111:9: DeclRefExpr=c:2:14 Extent=[111:9 - 111:10]
+// CHECK: 111:14: UnexposedExpr= Extent=[111:14 - 111:19]
+// CHECK: 111:14: IntegerLiteral= Extent=[111:14 - 111:19]
+// CHECK: 111:23: BinaryOperator= Extent=[111:23 - 111:33]
+// CHECK: 111:23: DeclRefExpr=c:2:14 Extent=[111:23 - 111:24]
+// CHECK: 111:28: UnexposedExpr= Extent=[111:28 - 111:33]
+// CHECK: 111:28: IntegerLiteral= Extent=[111:28 - 111:33]
+// CHECK: 112:8: BinaryOperator= Extent=[112:8 - 112:18]
+// CHECK: 112:8: DeclRefExpr=c:2:14 Extent=[112:8 - 112:9]
+// CHECK: 112:13: UnexposedExpr= Extent=[112:13 - 112:18]
+// CHECK: 112:13: IntegerLiteral= Extent=[112:13 - 112:18]
+// CHECK: 112:22: BinaryOperator= Extent=[112:22 - 112:32]
+// CHECK: 112:22: DeclRefExpr=c:2:14 Extent=[112:22 - 112:23]
+// CHECK: 112:27: UnexposedExpr= Extent=[112:27 - 112:32]
+// CHECK: 112:27: IntegerLiteral= Extent=[112:27 - 112:32]
+// CHECK: 112:37: BinaryOperator= Extent=[112:37 - 112:61]
+// CHECK: 112:37: BinaryOperator= Extent=[112:37 - 112:47]
+// CHECK: 112:37: DeclRefExpr=c:2:14 Extent=[112:37 - 112:38]
+// CHECK: 112:42: UnexposedExpr= Extent=[112:42 - 112:47]
+// CHECK: 112:42: IntegerLiteral= Extent=[112:42 - 112:47]
+// CHECK: 112:51: BinaryOperator= Extent=[112:51 - 112:61]
+// CHECK: 112:51: DeclRefExpr=c:2:14 Extent=[112:51 - 112:52]
+// CHECK: 112:56: UnexposedExpr= Extent=[112:56 - 112:61]
+// CHECK: 112:56: IntegerLiteral= Extent=[112:56 - 112:61]
+// CHECK: 113:9: BinaryOperator= Extent=[113:9 - 113:33]
+// CHECK: 113:9: BinaryOperator= Extent=[113:9 - 113:19]
+// CHECK: 113:9: DeclRefExpr=c:2:14 Extent=[113:9 - 113:10]
+// CHECK: 113:14: UnexposedExpr= Extent=[113:14 - 113:19]
+// CHECK: 113:14: IntegerLiteral= Extent=[113:14 - 113:19]
+// CHECK: 113:23: BinaryOperator= Extent=[113:23 - 113:33]
+// CHECK: 113:23: DeclRefExpr=c:2:14 Extent=[113:23 - 113:24]
+// CHECK: 113:28: UnexposedExpr= Extent=[113:28 - 113:33]
+// CHECK: 113:28: IntegerLiteral= Extent=[113:28 - 113:33]
+// CHECK: 114:8: BinaryOperator= Extent=[114:8 - 114:18]
+// CHECK: 114:8: DeclRefExpr=c:2:14 Extent=[114:8 - 114:9]
+// CHECK: 114:13: UnexposedExpr= Extent=[114:13 - 114:18]
+// CHECK: 114:13: IntegerLiteral= Extent=[114:13 - 114:18]
+// CHECK: 114:23: BinaryOperator= Extent=[114:23 - 114:47]
+// CHECK: 114:23: BinaryOperator= Extent=[114:23 - 114:33]
+// CHECK: 114:23: DeclRefExpr=c:2:14 Extent=[114:23 - 114:24]
+// CHECK: 114:28: UnexposedExpr= Extent=[114:28 - 114:33]
+// CHECK: 114:28: IntegerLiteral= Extent=[114:28 - 114:33]
+// CHECK: 114:37: BinaryOperator= Extent=[114:37 - 114:47]
+// CHECK: 114:37: DeclRefExpr=c:2:14 Extent=[114:37 - 114:38]
+// CHECK: 114:42: UnexposedExpr= Extent=[114:42 - 114:47]
+// CHECK: 114:42: IntegerLiteral= Extent=[114:42 - 114:47]
+// CHECK: 115:8: BinaryOperator= Extent=[115:8 - 115:18]
+// CHECK: 115:8: DeclRefExpr=c:2:14 Extent=[115:8 - 115:9]
+// CHECK: 115:13: UnexposedExpr= Extent=[115:13 - 115:18]
+// CHECK: 115:13: IntegerLiteral= Extent=[115:13 - 115:18]
+// CHECK: 115:23: BinaryOperator= Extent=[115:23 - 115:47]
+// CHECK: 115:23: BinaryOperator= Extent=[115:23 - 115:33]
+// CHECK: 115:23: DeclRefExpr=c:2:14 Extent=[115:23 - 115:24]
+// CHECK: 115:28: UnexposedExpr= Extent=[115:28 - 115:33]
+// CHECK: 115:28: IntegerLiteral= Extent=[115:28 - 115:33]
+// CHECK: 115:37: BinaryOperator= Extent=[115:37 - 115:47]
+// CHECK: 115:37: DeclRefExpr=c:2:14 Extent=[115:37 - 115:38]
+// CHECK: 115:42: UnexposedExpr= Extent=[115:42 - 115:47]
+// CHECK: 115:42: IntegerLiteral= Extent=[115:42 - 115:47]
+// CHECK: 116:9: BinaryOperator= Extent=[116:9 - 116:33]
+// CHECK: 116:9: BinaryOperator= Extent=[116:9 - 116:19]
+// CHECK: 116:9: DeclRefExpr=c:2:14 Extent=[116:9 - 116:10]
+// CHECK: 116:14: UnexposedExpr= Extent=[116:14 - 116:19]
+// CHECK: 116:14: IntegerLiteral= Extent=[116:14 - 116:19]
+// CHECK: 116:23: BinaryOperator= Extent=[116:23 - 116:33]
+// CHECK: 116:23: DeclRefExpr=c:2:14 Extent=[116:23 - 116:24]
+// CHECK: 116:28: UnexposedExpr= Extent=[116:28 - 116:33]
+// CHECK: 116:28: IntegerLiteral= Extent=[116:28 - 116:33]
+// CHECK: 117:9: BinaryOperator= Extent=[117:9 - 117:33]
+// CHECK: 117:9: BinaryOperator= Extent=[117:9 - 117:19]
+// CHECK: 117:9: DeclRefExpr=c:2:14 Extent=[117:9 - 117:10]
+// CHECK: 117:14: UnexposedExpr= Extent=[117:14 - 117:19]
+// CHECK: 117:14: IntegerLiteral= Extent=[117:14 - 117:19]
+// CHECK: 117:23: BinaryOperator= Extent=[117:23 - 117:33]
+// CHECK: 117:23: DeclRefExpr=c:2:14 Extent=[117:23 - 117:24]
+// CHECK: 117:28: UnexposedExpr= Extent=[117:28 - 117:33]
+// CHECK: 117:28: IntegerLiteral= Extent=[117:28 - 117:33]
+// CHECK: 118:9: BinaryOperator= Extent=[118:9 - 118:35]
+// CHECK: 118:9: BinaryOperator= Extent=[118:9 - 118:20]
+// CHECK: 118:9: DeclRefExpr=c:2:14 Extent=[118:9 - 118:10]
+// CHECK: 118:14: UnexposedExpr= Extent=[118:14 - 118:20]
+// CHECK: 118:14: IntegerLiteral= Extent=[118:14 - 118:20]
+// CHECK: 118:24: BinaryOperator= Extent=[118:24 - 118:35]
+// CHECK: 118:24: DeclRefExpr=c:2:14 Extent=[118:24 - 118:25]
+// CHECK: 118:29: UnexposedExpr= Extent=[118:29 - 118:35]
+// CHECK: 118:29: IntegerLiteral= Extent=[118:29 - 118:35]
+// CHECK: 119:9: BinaryOperator= Extent=[119:9 - 119:35]
+// CHECK: 119:9: BinaryOperator= Extent=[119:9 - 119:20]
+// CHECK: 119:9: DeclRefExpr=c:2:14 Extent=[119:9 - 119:10]
+// CHECK: 119:14: UnexposedExpr= Extent=[119:14 - 119:20]
+// CHECK: 119:14: IntegerLiteral= Extent=[119:14 - 119:20]
+// CHECK: 119:24: BinaryOperator= Extent=[119:24 - 119:35]
+// CHECK: 119:24: DeclRefExpr=c:2:14 Extent=[119:24 - 119:25]
+// CHECK: 119:29: UnexposedExpr= Extent=[119:29 - 119:35]
+// CHECK: 119:29: IntegerLiteral= Extent=[119:29 - 119:35]
+// CHECK: 120:8: BinaryOperator= Extent=[120:8 - 120:19]
+// CHECK: 120:8: DeclRefExpr=c:2:14 Extent=[120:8 - 120:9]
+// CHECK: 120:13: UnexposedExpr= Extent=[120:13 - 120:19]
+// CHECK: 120:13: IntegerLiteral= Extent=[120:13 - 120:19]
+// CHECK: 120:24: BinaryOperator= Extent=[120:24 - 120:50]
+// CHECK: 120:24: BinaryOperator= Extent=[120:24 - 120:35]
+// CHECK: 120:24: DeclRefExpr=c:2:14 Extent=[120:24 - 120:25]
+// CHECK: 120:29: UnexposedExpr= Extent=[120:29 - 120:35]
+// CHECK: 120:29: IntegerLiteral= Extent=[120:29 - 120:35]
+// CHECK: 120:39: BinaryOperator= Extent=[120:39 - 120:50]
+// CHECK: 120:39: DeclRefExpr=c:2:14 Extent=[120:39 - 120:40]
+// CHECK: 120:44: UnexposedExpr= Extent=[120:44 - 120:50]
+// CHECK: 120:44: IntegerLiteral= Extent=[120:44 - 120:50]
+// CHECK: 121:9: BinaryOperator= Extent=[121:9 - 121:35]
+// CHECK: 121:9: BinaryOperator= Extent=[121:9 - 121:20]
+// CHECK: 121:9: DeclRefExpr=c:2:14 Extent=[121:9 - 121:10]
+// CHECK: 121:14: UnexposedExpr= Extent=[121:14 - 121:20]
+// CHECK: 121:14: IntegerLiteral= Extent=[121:14 - 121:20]
+// CHECK: 121:24: BinaryOperator= Extent=[121:24 - 121:35]
+// CHECK: 121:24: DeclRefExpr=c:2:14 Extent=[121:24 - 121:25]
+// CHECK: 121:29: UnexposedExpr= Extent=[121:29 - 121:35]
+// CHECK: 121:29: IntegerLiteral= Extent=[121:29 - 121:35]
+// CHECK: 122:8: BinaryOperator= Extent=[122:8 - 122:19]
+// CHECK: 122:8: DeclRefExpr=c:2:14 Extent=[122:8 - 122:9]
+// CHECK: 122:13: UnexposedExpr= Extent=[122:13 - 122:19]
+// CHECK: 122:13: IntegerLiteral= Extent=[122:13 - 122:19]
+// CHECK: 122:24: BinaryOperator= Extent=[122:24 - 122:50]
+// CHECK: 122:24: BinaryOperator= Extent=[122:24 - 122:35]
+// CHECK: 122:24: DeclRefExpr=c:2:14 Extent=[122:24 - 122:25]
+// CHECK: 122:29: UnexposedExpr= Extent=[122:29 - 122:35]
+// CHECK: 122:29: IntegerLiteral= Extent=[122:29 - 122:35]
+// CHECK: 122:39: BinaryOperator= Extent=[122:39 - 122:50]
+// CHECK: 122:39: DeclRefExpr=c:2:14 Extent=[122:39 - 122:40]
+// CHECK: 122:44: UnexposedExpr= Extent=[122:44 - 122:50]
+// CHECK: 122:44: IntegerLiteral= Extent=[122:44 - 122:50]
+// CHECK: 123:9: BinaryOperator= Extent=[123:9 - 123:35]
+// CHECK: 123:9: BinaryOperator= Extent=[123:9 - 123:20]
+// CHECK: 123:9: DeclRefExpr=c:2:14 Extent=[123:9 - 123:10]
+// CHECK: 123:14: UnexposedExpr= Extent=[123:14 - 123:20]
+// CHECK: 123:14: IntegerLiteral= Extent=[123:14 - 123:20]
+// CHECK: 123:24: BinaryOperator= Extent=[123:24 - 123:35]
+// CHECK: 123:24: DeclRefExpr=c:2:14 Extent=[123:24 - 123:25]
+// CHECK: 123:29: UnexposedExpr= Extent=[123:29 - 123:35]
+// CHECK: 123:29: IntegerLiteral= Extent=[123:29 - 123:35]
+// CHECK: 124:8: BinaryOperator= Extent=[124:8 - 124:19]
+// CHECK: 124:8: DeclRefExpr=c:2:14 Extent=[124:8 - 124:9]
+// CHECK: 124:13: UnexposedExpr= Extent=[124:13 - 124:19]
+// CHECK: 124:13: IntegerLiteral= Extent=[124:13 - 124:19]
+// CHECK: 124:23: BinaryOperator= Extent=[124:23 - 124:34]
+// CHECK: 124:23: DeclRefExpr=c:2:14 Extent=[124:23 - 124:24]
+// CHECK: 124:28: UnexposedExpr= Extent=[124:28 - 124:34]
+// CHECK: 124:28: IntegerLiteral= Extent=[124:28 - 124:34]
+// CHECK: 124:38: BinaryOperator= Extent=[124:38 - 124:49]
+// CHECK: 124:38: DeclRefExpr=c:2:14 Extent=[124:38 - 124:39]
+// CHECK: 124:43: UnexposedExpr= Extent=[124:43 - 124:49]
+// CHECK: 124:43: IntegerLiteral= Extent=[124:43 - 124:49]
+// CHECK: 124:53: BinaryOperator= Extent=[124:53 - 124:64]
+// CHECK: 124:53: DeclRefExpr=c:2:14 Extent=[124:53 - 124:54]
+// CHECK: 124:58: UnexposedExpr= Extent=[124:58 - 124:64]
+// CHECK: 124:58: IntegerLiteral= Extent=[124:58 - 124:64]
+// CHECK: 125:5: BinaryOperator= Extent=[125:5 - 125:16]
+// CHECK: 125:5: DeclRefExpr=c:2:14 Extent=[125:5 - 125:6]
+// CHECK: 125:10: UnexposedExpr= Extent=[125:10 - 125:16]
+// CHECK: 125:10: IntegerLiteral= Extent=[125:10 - 125:16]
+// CHECK: 125:20: BinaryOperator= Extent=[125:20 - 125:31]
+// CHECK: 125:20: DeclRefExpr=c:2:14 Extent=[125:20 - 125:21]
+// CHECK: 125:25: UnexposedExpr= Extent=[125:25 - 125:31]
+// CHECK: 125:25: IntegerLiteral= Extent=[125:25 - 125:31]
+// CHECK: 125:36: BinaryOperator= Extent=[125:36 - 125:62]
+// CHECK: 125:36: BinaryOperator= Extent=[125:36 - 125:47]
+// CHECK: 125:36: DeclRefExpr=c:2:14 Extent=[125:36 - 125:37]
+// CHECK: 125:41: UnexposedExpr= Extent=[125:41 - 125:47]
+// CHECK: 125:41: IntegerLiteral= Extent=[125:41 - 125:47]
+// CHECK: 125:51: BinaryOperator= Extent=[125:51 - 125:62]
+// CHECK: 125:51: DeclRefExpr=c:2:14 Extent=[125:51 - 125:52]
+// CHECK: 125:56: UnexposedExpr= Extent=[125:56 - 125:62]
+// CHECK: 125:56: IntegerLiteral= Extent=[125:56 - 125:62]
+// CHECK: 126:8: BinaryOperator= Extent=[126:8 - 126:19]
+// CHECK: 126:8: DeclRefExpr=c:2:14 Extent=[126:8 - 126:9]
+// CHECK: 126:13: UnexposedExpr= Extent=[126:13 - 126:19]
+// CHECK: 126:13: IntegerLiteral= Extent=[126:13 - 126:19]
+// CHECK: 126:24: BinaryOperator= Extent=[126:24 - 126:50]
+// CHECK: 126:24: BinaryOperator= Extent=[126:24 - 126:35]
+// CHECK: 126:24: DeclRefExpr=c:2:14 Extent=[126:24 - 126:25]
+// CHECK: 126:29: UnexposedExpr= Extent=[126:29 - 126:35]
+// CHECK: 126:29: IntegerLiteral= Extent=[126:29 - 126:35]
+// CHECK: 126:39: BinaryOperator= Extent=[126:39 - 126:50]
+// CHECK: 126:39: DeclRefExpr=c:2:14 Extent=[126:39 - 126:40]
+// CHECK: 126:44: UnexposedExpr= Extent=[126:44 - 126:50]
+// CHECK: 126:44: IntegerLiteral= Extent=[126:44 - 126:50]
+// CHECK: 127:8: BinaryOperator= Extent=[127:8 - 127:19]
+// CHECK: 127:8: DeclRefExpr=c:2:14 Extent=[127:8 - 127:9]
+// CHECK: 127:13: UnexposedExpr= Extent=[127:13 - 127:19]
+// CHECK: 127:13: IntegerLiteral= Extent=[127:13 - 127:19]
+// CHECK: 127:23: BinaryOperator= Extent=[127:23 - 127:34]
+// CHECK: 127:23: DeclRefExpr=c:2:14 Extent=[127:23 - 127:24]
+// CHECK: 127:28: UnexposedExpr= Extent=[127:28 - 127:34]
+// CHECK: 127:28: IntegerLiteral= Extent=[127:28 - 127:34]
+// CHECK: 127:38: BinaryOperator= Extent=[127:38 - 127:49]
+// CHECK: 127:38: DeclRefExpr=c:2:14 Extent=[127:38 - 127:39]
+// CHECK: 127:43: UnexposedExpr= Extent=[127:43 - 127:49]
+// CHECK: 127:43: IntegerLiteral= Extent=[127:43 - 127:49]
+// CHECK: 127:53: BinaryOperator= Extent=[127:53 - 127:64]
+// CHECK: 127:53: DeclRefExpr=c:2:14 Extent=[127:53 - 127:54]
+// CHECK: 127:58: UnexposedExpr= Extent=[127:58 - 127:64]
+// CHECK: 127:58: IntegerLiteral= Extent=[127:58 - 127:64]
+// CHECK: 128:6: BinaryOperator= Extent=[128:6 - 128:32]
+// CHECK: 128:6: BinaryOperator= Extent=[128:6 - 128:17]
+// CHECK: 128:6: DeclRefExpr=c:2:14 Extent=[128:6 - 128:7]
+// CHECK: 128:11: UnexposedExpr= Extent=[128:11 - 128:17]
+// CHECK: 128:11: IntegerLiteral= Extent=[128:11 - 128:17]
+// CHECK: 128:21: BinaryOperator= Extent=[128:21 - 128:32]
+// CHECK: 128:21: DeclRefExpr=c:2:14 Extent=[128:21 - 128:22]
+// CHECK: 128:26: UnexposedExpr= Extent=[128:26 - 128:32]
+// CHECK: 128:26: IntegerLiteral= Extent=[128:26 - 128:32]
+// CHECK: 129:9: BinaryOperator= Extent=[129:9 - 129:35]
+// CHECK: 129:9: BinaryOperator= Extent=[129:9 - 129:20]
+// CHECK: 129:9: DeclRefExpr=c:2:14 Extent=[129:9 - 129:10]
+// CHECK: 129:14: UnexposedExpr= Extent=[129:14 - 129:20]
+// CHECK: 129:14: IntegerLiteral= Extent=[129:14 - 129:20]
+// CHECK: 129:24: BinaryOperator= Extent=[129:24 - 129:35]
+// CHECK: 129:24: DeclRefExpr=c:2:14 Extent=[129:24 - 129:25]
+// CHECK: 129:29: UnexposedExpr= Extent=[129:29 - 129:35]
+// CHECK: 129:29: IntegerLiteral= Extent=[129:29 - 129:35]
+// CHECK: 130:8: BinaryOperator= Extent=[130:8 - 130:19]
+// CHECK: 130:8: DeclRefExpr=c:2:14 Extent=[130:8 - 130:9]
+// CHECK: 130:13: UnexposedExpr= Extent=[130:13 - 130:19]
+// CHECK: 130:13: IntegerLiteral= Extent=[130:13 - 130:19]
+// CHECK: 130:23: BinaryOperator= Extent=[130:23 - 130:34]
+// CHECK: 130:23: DeclRefExpr=c:2:14 Extent=[130:23 - 130:24]
+// CHECK: 130:28: UnexposedExpr= Extent=[130:28 - 130:34]
+// CHECK: 130:28: IntegerLiteral= Extent=[130:28 - 130:34]
+// CHECK: 130:38: BinaryOperator= Extent=[130:38 - 130:49]
+// CHECK: 130:38: DeclRefExpr=c:2:14 Extent=[130:38 - 130:39]
+// CHECK: 130:43: UnexposedExpr= Extent=[130:43 - 130:49]
+// CHECK: 130:43: IntegerLiteral= Extent=[130:43 - 130:49]
+// CHECK: 130:53: BinaryOperator= Extent=[130:53 - 130:64]
+// CHECK: 130:53: DeclRefExpr=c:2:14 Extent=[130:53 - 130:54]
+// CHECK: 130:58: UnexposedExpr= Extent=[130:58 - 130:64]
+// CHECK: 130:58: IntegerLiteral= Extent=[130:58 - 130:64]
+// CHECK: 131:6: BinaryOperator= Extent=[131:6 - 131:32]
+// CHECK: 131:6: BinaryOperator= Extent=[131:6 - 131:17]
+// CHECK: 131:6: DeclRefExpr=c:2:14 Extent=[131:6 - 131:7]
+// CHECK: 131:11: UnexposedExpr= Extent=[131:11 - 131:17]
+// CHECK: 131:11: IntegerLiteral= Extent=[131:11 - 131:17]
+// CHECK: 131:21: BinaryOperator= Extent=[131:21 - 131:32]
+// CHECK: 131:21: DeclRefExpr=c:2:14 Extent=[131:21 - 131:22]
+// CHECK: 131:26: UnexposedExpr= Extent=[131:26 - 131:32]
+// CHECK: 131:26: IntegerLiteral= Extent=[131:26 - 131:32]
+// CHECK: 132:9: BinaryOperator= Extent=[132:9 - 132:35]
+// CHECK: 132:9: BinaryOperator= Extent=[132:9 - 132:20]
+// CHECK: 132:9: DeclRefExpr=c:2:14 Extent=[132:9 - 132:10]
+// CHECK: 132:14: UnexposedExpr= Extent=[132:14 - 132:20]
+// CHECK: 132:14: IntegerLiteral= Extent=[132:14 - 132:20]
+// CHECK: 132:24: BinaryOperator= Extent=[132:24 - 132:35]
+// CHECK: 132:24: DeclRefExpr=c:2:14 Extent=[132:24 - 132:25]
+// CHECK: 132:29: UnexposedExpr= Extent=[132:29 - 132:35]
+// CHECK: 132:29: IntegerLiteral= Extent=[132:29 - 132:35]
+// CHECK: 133:8: BinaryOperator= Extent=[133:8 - 133:19]
+// CHECK: 133:8: DeclRefExpr=c:2:14 Extent=[133:8 - 133:9]
+// CHECK: 133:13: UnexposedExpr= Extent=[133:13 - 133:19]
+// CHECK: 133:13: IntegerLiteral= Extent=[133:13 - 133:19]
+// CHECK: 133:24: BinaryOperator= Extent=[133:24 - 133:50]
+// CHECK: 133:24: BinaryOperator= Extent=[133:24 - 133:35]
+// CHECK: 133:24: DeclRefExpr=c:2:14 Extent=[133:24 - 133:25]
+// CHECK: 133:29: UnexposedExpr= Extent=[133:29 - 133:35]
+// CHECK: 133:29: IntegerLiteral= Extent=[133:29 - 133:35]
+// CHECK: 133:39: BinaryOperator= Extent=[133:39 - 133:50]
+// CHECK: 133:39: DeclRefExpr=c:2:14 Extent=[133:39 - 133:40]
+// CHECK: 133:44: UnexposedExpr= Extent=[133:44 - 133:50]
+// CHECK: 133:44: IntegerLiteral= Extent=[133:44 - 133:50]
+// CHECK: 134:8: BinaryOperator= Extent=[134:8 - 134:19]
+// CHECK: 134:8: DeclRefExpr=c:2:14 Extent=[134:8 - 134:9]
+// CHECK: 134:13: UnexposedExpr= Extent=[134:13 - 134:19]
+// CHECK: 134:13: IntegerLiteral= Extent=[134:13 - 134:19]
+// CHECK: 134:23: BinaryOperator= Extent=[134:23 - 134:34]
+// CHECK: 134:23: DeclRefExpr=c:2:14 Extent=[134:23 - 134:24]
+// CHECK: 134:28: UnexposedExpr= Extent=[134:28 - 134:34]
+// CHECK: 134:28: IntegerLiteral= Extent=[134:28 - 134:34]
+// CHECK: 134:38: BinaryOperator= Extent=[134:38 - 134:49]
+// CHECK: 134:38: DeclRefExpr=c:2:14 Extent=[134:38 - 134:39]
+// CHECK: 134:43: UnexposedExpr= Extent=[134:43 - 134:49]
+// CHECK: 134:43: IntegerLiteral= Extent=[134:43 - 134:49]
+// CHECK: 134:54: BinaryOperator= Extent=[134:54 - 134:80]
+// CHECK: 134:54: BinaryOperator= Extent=[134:54 - 134:65]
+// CHECK: 134:54: DeclRefExpr=c:2:14 Extent=[134:54 - 134:55]
+// CHECK: 134:59: UnexposedExpr= Extent=[134:59 - 134:65]
+// CHECK: 134:59: IntegerLiteral= Extent=[134:59 - 134:65]
+// CHECK: 134:69: BinaryOperator= Extent=[134:69 - 134:80]
+// CHECK: 134:69: DeclRefExpr=c:2:14 Extent=[134:69 - 134:70]
+// CHECK: 134:74: UnexposedExpr= Extent=[134:74 - 134:80]
+// CHECK: 134:74: IntegerLiteral= Extent=[134:74 - 134:80]
+// CHECK: 135:9: BinaryOperator= Extent=[135:9 - 135:35]
+// CHECK: 135:9: BinaryOperator= Extent=[135:9 - 135:20]
+// CHECK: 135:9: DeclRefExpr=c:2:14 Extent=[135:9 - 135:10]
+// CHECK: 135:14: UnexposedExpr= Extent=[135:14 - 135:20]
+// CHECK: 135:14: IntegerLiteral= Extent=[135:14 - 135:20]
+// CHECK: 135:24: BinaryOperator= Extent=[135:24 - 135:35]
+// CHECK: 135:24: DeclRefExpr=c:2:14 Extent=[135:24 - 135:25]
+// CHECK: 135:29: UnexposedExpr= Extent=[135:29 - 135:35]
+// CHECK: 135:29: IntegerLiteral= Extent=[135:29 - 135:35]
+// CHECK: 136:9: BinaryOperator= Extent=[136:9 - 136:35]
+// CHECK: 136:9: BinaryOperator= Extent=[136:9 - 136:20]
+// CHECK: 136:9: DeclRefExpr=c:2:14 Extent=[136:9 - 136:10]
+// CHECK: 136:14: UnexposedExpr= Extent=[136:14 - 136:20]
+// CHECK: 136:14: IntegerLiteral= Extent=[136:14 - 136:20]
+// CHECK: 136:24: BinaryOperator= Extent=[136:24 - 136:35]
+// CHECK: 136:24: DeclRefExpr=c:2:14 Extent=[136:24 - 136:25]
+// CHECK: 136:29: UnexposedExpr= Extent=[136:29 - 136:35]
+// CHECK: 136:29: IntegerLiteral= Extent=[136:29 - 136:35]
+// CHECK: 137:9: BinaryOperator= Extent=[137:9 - 137:35]
+// CHECK: 137:9: BinaryOperator= Extent=[137:9 - 137:20]
+// CHECK: 137:9: DeclRefExpr=c:2:14 Extent=[137:9 - 137:10]
+// CHECK: 137:14: UnexposedExpr= Extent=[137:14 - 137:20]
+// CHECK: 137:14: IntegerLiteral= Extent=[137:14 - 137:20]
+// CHECK: 137:24: BinaryOperator= Extent=[137:24 - 137:35]
+// CHECK: 137:24: DeclRefExpr=c:2:14 Extent=[137:24 - 137:25]
+// CHECK: 137:29: UnexposedExpr= Extent=[137:29 - 137:35]
+// CHECK: 137:29: IntegerLiteral= Extent=[137:29 - 137:35]
+// CHECK: 138:9: BinaryOperator= Extent=[138:9 - 138:35]
+// CHECK: 138:9: BinaryOperator= Extent=[138:9 - 138:20]
+// CHECK: 138:9: DeclRefExpr=c:2:14 Extent=[138:9 - 138:10]
+// CHECK: 138:14: UnexposedExpr= Extent=[138:14 - 138:20]
+// CHECK: 138:14: IntegerLiteral= Extent=[138:14 - 138:20]
+// CHECK: 138:24: BinaryOperator= Extent=[138:24 - 138:35]
+// CHECK: 138:24: DeclRefExpr=c:2:14 Extent=[138:24 - 138:25]
+// CHECK: 138:29: UnexposedExpr= Extent=[138:29 - 138:35]
+// CHECK: 138:29: IntegerLiteral= Extent=[138:29 - 138:35]
+// CHECK: 139:9: BinaryOperator= Extent=[139:9 - 139:35]
+// CHECK: 139:9: BinaryOperator= Extent=[139:9 - 139:20]
+// CHECK: 139:9: DeclRefExpr=c:2:14 Extent=[139:9 - 139:10]
+// CHECK: 139:14: UnexposedExpr= Extent=[139:14 - 139:20]
+// CHECK: 139:14: IntegerLiteral= Extent=[139:14 - 139:20]
+// CHECK: 139:24: BinaryOperator= Extent=[139:24 - 139:35]
+// CHECK: 139:24: DeclRefExpr=c:2:14 Extent=[139:24 - 139:25]
+// CHECK: 139:29: UnexposedExpr= Extent=[139:29 - 139:35]
+// CHECK: 139:29: IntegerLiteral= Extent=[139:29 - 139:35]
+// CHECK: 140:9: BinaryOperator= Extent=[140:9 - 140:35]
+// CHECK: 140:9: BinaryOperator= Extent=[140:9 - 140:20]
+// CHECK: 140:9: DeclRefExpr=c:2:14 Extent=[140:9 - 140:10]
+// CHECK: 140:14: UnexposedExpr= Extent=[140:14 - 140:20]
+// CHECK: 140:14: IntegerLiteral= Extent=[140:14 - 140:20]
+// CHECK: 140:24: BinaryOperator= Extent=[140:24 - 140:35]
+// CHECK: 140:24: DeclRefExpr=c:2:14 Extent=[140:24 - 140:25]
+// CHECK: 140:29: UnexposedExpr= Extent=[140:29 - 140:35]
+// CHECK: 140:29: IntegerLiteral= Extent=[140:29 - 140:35]
+// CHECK: 141:8: BinaryOperator= Extent=[141:8 - 141:19]
+// CHECK: 141:8: DeclRefExpr=c:2:14 Extent=[141:8 - 141:9]
+// CHECK: 141:13: UnexposedExpr= Extent=[141:13 - 141:19]
+// CHECK: 141:13: IntegerLiteral= Extent=[141:13 - 141:19]
+// CHECK: 141:23: BinaryOperator= Extent=[141:23 - 141:34]
+// CHECK: 141:23: DeclRefExpr=c:2:14 Extent=[141:23 - 141:24]
+// CHECK: 141:28: UnexposedExpr= Extent=[141:28 - 141:34]
+// CHECK: 141:28: IntegerLiteral= Extent=[141:28 - 141:34]
+// CHECK: 141:38: BinaryOperator= Extent=[141:38 - 141:49]
+// CHECK: 141:38: DeclRefExpr=c:2:14 Extent=[141:38 - 141:39]
+// CHECK: 141:43: UnexposedExpr= Extent=[141:43 - 141:49]
+// CHECK: 141:43: IntegerLiteral= Extent=[141:43 - 141:49]
+// CHECK: 141:54: BinaryOperator= Extent=[141:54 - 141:80]
+// CHECK: 141:54: BinaryOperator= Extent=[141:54 - 141:65]
+// CHECK: 141:54: DeclRefExpr=c:2:14 Extent=[141:54 - 141:55]
+// CHECK: 141:59: UnexposedExpr= Extent=[141:59 - 141:65]
+// CHECK: 141:59: IntegerLiteral= Extent=[141:59 - 141:65]
+// CHECK: 141:69: BinaryOperator= Extent=[141:69 - 141:80]
+// CHECK: 141:69: DeclRefExpr=c:2:14 Extent=[141:69 - 141:70]
+// CHECK: 141:74: UnexposedExpr= Extent=[141:74 - 141:80]
+// CHECK: 141:74: IntegerLiteral= Extent=[141:74 - 141:80]
+// CHECK: 142:9: BinaryOperator= Extent=[142:9 - 142:35]
+// CHECK: 142:9: BinaryOperator= Extent=[142:9 - 142:20]
+// CHECK: 142:9: DeclRefExpr=c:2:14 Extent=[142:9 - 142:10]
+// CHECK: 142:14: UnexposedExpr= Extent=[142:14 - 142:20]
+// CHECK: 142:14: IntegerLiteral= Extent=[142:14 - 142:20]
+// CHECK: 142:24: BinaryOperator= Extent=[142:24 - 142:35]
+// CHECK: 142:24: DeclRefExpr=c:2:14 Extent=[142:24 - 142:25]
+// CHECK: 142:29: UnexposedExpr= Extent=[142:29 - 142:35]
+// CHECK: 142:29: IntegerLiteral= Extent=[142:29 - 142:35]
+// CHECK: 143:9: BinaryOperator= Extent=[143:9 - 143:35]
+// CHECK: 143:9: BinaryOperator= Extent=[143:9 - 143:20]
+// CHECK: 143:9: DeclRefExpr=c:2:14 Extent=[143:9 - 143:10]
+// CHECK: 143:14: UnexposedExpr= Extent=[143:14 - 143:20]
+// CHECK: 143:14: IntegerLiteral= Extent=[143:14 - 143:20]
+// CHECK: 143:24: BinaryOperator= Extent=[143:24 - 143:35]
+// CHECK: 143:24: DeclRefExpr=c:2:14 Extent=[143:24 - 143:25]
+// CHECK: 143:29: UnexposedExpr= Extent=[143:29 - 143:35]
+// CHECK: 143:29: IntegerLiteral= Extent=[143:29 - 143:35]
+// CHECK: 144:8: BinaryOperator= Extent=[144:8 - 144:19]
+// CHECK: 144:8: DeclRefExpr=c:2:14 Extent=[144:8 - 144:9]
+// CHECK: 144:13: UnexposedExpr= Extent=[144:13 - 144:19]
+// CHECK: 144:13: IntegerLiteral= Extent=[144:13 - 144:19]
+// CHECK: 144:24: BinaryOperator= Extent=[144:24 - 144:50]
+// CHECK: 144:24: BinaryOperator= Extent=[144:24 - 144:35]
+// CHECK: 144:24: DeclRefExpr=c:2:14 Extent=[144:24 - 144:25]
+// CHECK: 144:29: UnexposedExpr= Extent=[144:29 - 144:35]
+// CHECK: 144:29: IntegerLiteral= Extent=[144:29 - 144:35]
+// CHECK: 144:39: BinaryOperator= Extent=[144:39 - 144:50]
+// CHECK: 144:39: DeclRefExpr=c:2:14 Extent=[144:39 - 144:40]
+// CHECK: 144:44: UnexposedExpr= Extent=[144:44 - 144:50]
+// CHECK: 144:44: IntegerLiteral= Extent=[144:44 - 144:50]
+// CHECK: 145:9: BinaryOperator= Extent=[145:9 - 145:35]
+// CHECK: 145:9: BinaryOperator= Extent=[145:9 - 145:20]
+// CHECK: 145:9: DeclRefExpr=c:2:14 Extent=[145:9 - 145:10]
+// CHECK: 145:14: UnexposedExpr= Extent=[145:14 - 145:20]
+// CHECK: 145:14: IntegerLiteral= Extent=[145:14 - 145:20]
+// CHECK: 145:24: BinaryOperator= Extent=[145:24 - 145:35]
+// CHECK: 145:24: DeclRefExpr=c:2:14 Extent=[145:24 - 145:25]
+// CHECK: 145:29: UnexposedExpr= Extent=[145:29 - 145:35]
+// CHECK: 145:29: IntegerLiteral= Extent=[145:29 - 145:35]
+// CHECK: 146:9: BinaryOperator= Extent=[146:9 - 146:35]
+// CHECK: 146:9: BinaryOperator= Extent=[146:9 - 146:20]
+// CHECK: 146:9: DeclRefExpr=c:2:14 Extent=[146:9 - 146:10]
+// CHECK: 146:14: UnexposedExpr= Extent=[146:14 - 146:20]
+// CHECK: 146:14: IntegerLiteral= Extent=[146:14 - 146:20]
+// CHECK: 146:24: BinaryOperator= Extent=[146:24 - 146:35]
+// CHECK: 146:24: DeclRefExpr=c:2:14 Extent=[146:24 - 146:25]
+// CHECK: 146:29: UnexposedExpr= Extent=[146:29 - 146:35]
+// CHECK: 146:29: IntegerLiteral= Extent=[146:29 - 146:35]
+// CHECK: 147:9: BinaryOperator= Extent=[147:9 - 147:35]
+// CHECK: 147:9: BinaryOperator= Extent=[147:9 - 147:20]
+// CHECK: 147:9: DeclRefExpr=c:2:14 Extent=[147:9 - 147:10]
+// CHECK: 147:14: UnexposedExpr= Extent=[147:14 - 147:20]
+// CHECK: 147:14: IntegerLiteral= Extent=[147:14 - 147:20]
+// CHECK: 147:24: BinaryOperator= Extent=[147:24 - 147:35]
+// CHECK: 147:24: DeclRefExpr=c:2:14 Extent=[147:24 - 147:25]
+// CHECK: 147:29: UnexposedExpr= Extent=[147:29 - 147:35]
+// CHECK: 147:29: IntegerLiteral= Extent=[147:29 - 147:35]
+// CHECK: 148:9: BinaryOperator= Extent=[148:9 - 148:35]
+// CHECK: 148:9: BinaryOperator= Extent=[148:9 - 148:20]
+// CHECK: 148:9: DeclRefExpr=c:2:14 Extent=[148:9 - 148:10]
+// CHECK: 148:14: UnexposedExpr= Extent=[148:14 - 148:20]
+// CHECK: 148:14: IntegerLiteral= Extent=[148:14 - 148:20]
+// CHECK: 148:24: BinaryOperator= Extent=[148:24 - 148:35]
+// CHECK: 148:24: DeclRefExpr=c:2:14 Extent=[148:24 - 148:25]
+// CHECK: 148:29: UnexposedExpr= Extent=[148:29 - 148:35]
+// CHECK: 148:29: IntegerLiteral= Extent=[148:29 - 148:35]
+// CHECK: 149:9: BinaryOperator= Extent=[149:9 - 149:35]
+// CHECK: 149:9: BinaryOperator= Extent=[149:9 - 149:20]
+// CHECK: 149:9: DeclRefExpr=c:2:14 Extent=[149:9 - 149:10]
+// CHECK: 149:14: UnexposedExpr= Extent=[149:14 - 149:20]
+// CHECK: 149:14: IntegerLiteral= Extent=[149:14 - 149:20]
+// CHECK: 149:24: BinaryOperator= Extent=[149:24 - 149:35]
+// CHECK: 149:24: DeclRefExpr=c:2:14 Extent=[149:24 - 149:25]
+// CHECK: 149:29: UnexposedExpr= Extent=[149:29 - 149:35]
+// CHECK: 149:29: IntegerLiteral= Extent=[149:29 - 149:35]
+// CHECK: 150:9: BinaryOperator= Extent=[150:9 - 150:35]
+// CHECK: 150:9: BinaryOperator= Extent=[150:9 - 150:20]
+// CHECK: 150:9: DeclRefExpr=c:2:14 Extent=[150:9 - 150:10]
+// CHECK: 150:14: UnexposedExpr= Extent=[150:14 - 150:20]
+// CHECK: 150:14: IntegerLiteral= Extent=[150:14 - 150:20]
+// CHECK: 150:24: BinaryOperator= Extent=[150:24 - 150:35]
+// CHECK: 150:24: DeclRefExpr=c:2:14 Extent=[150:24 - 150:25]
+// CHECK: 150:29: UnexposedExpr= Extent=[150:29 - 150:35]
+// CHECK: 150:29: IntegerLiteral= Extent=[150:29 - 150:35]
+// CHECK: 151:8: BinaryOperator= Extent=[151:8 - 151:19]
+// CHECK: 151:8: DeclRefExpr=c:2:14 Extent=[151:8 - 151:9]
+// CHECK: 151:13: UnexposedExpr= Extent=[151:13 - 151:19]
+// CHECK: 151:13: IntegerLiteral= Extent=[151:13 - 151:19]
+// CHECK: 151:24: BinaryOperator= Extent=[151:24 - 151:50]
+// CHECK: 151:24: BinaryOperator= Extent=[151:24 - 151:35]
+// CHECK: 151:24: DeclRefExpr=c:2:14 Extent=[151:24 - 151:25]
+// CHECK: 151:29: UnexposedExpr= Extent=[151:29 - 151:35]
+// CHECK: 151:29: IntegerLiteral= Extent=[151:29 - 151:35]
+// CHECK: 151:39: BinaryOperator= Extent=[151:39 - 151:50]
+// CHECK: 151:39: DeclRefExpr=c:2:14 Extent=[151:39 - 151:40]
+// CHECK: 151:44: UnexposedExpr= Extent=[151:44 - 151:50]
+// CHECK: 151:44: IntegerLiteral= Extent=[151:44 - 151:50]
+// CHECK: 152:8: BinaryOperator= Extent=[152:8 - 152:19]
+// CHECK: 152:8: DeclRefExpr=c:2:14 Extent=[152:8 - 152:9]
+// CHECK: 152:13: UnexposedExpr= Extent=[152:13 - 152:19]
+// CHECK: 152:13: IntegerLiteral= Extent=[152:13 - 152:19]
+// CHECK: 152:24: BinaryOperator= Extent=[152:24 - 152:50]
+// CHECK: 152:24: BinaryOperator= Extent=[152:24 - 152:35]
+// CHECK: 152:24: DeclRefExpr=c:2:14 Extent=[152:24 - 152:25]
+// CHECK: 152:29: UnexposedExpr= Extent=[152:29 - 152:35]
+// CHECK: 152:29: IntegerLiteral= Extent=[152:29 - 152:35]
+// CHECK: 152:39: BinaryOperator= Extent=[152:39 - 152:50]
+// CHECK: 152:39: DeclRefExpr=c:2:14 Extent=[152:39 - 152:40]
+// CHECK: 152:44: UnexposedExpr= Extent=[152:44 - 152:50]
+// CHECK: 152:44: IntegerLiteral= Extent=[152:44 - 152:50]
+// CHECK: 153:9: BinaryOperator= Extent=[153:9 - 153:35]
+// CHECK: 153:9: BinaryOperator= Extent=[153:9 - 153:20]
+// CHECK: 153:9: DeclRefExpr=c:2:14 Extent=[153:9 - 153:10]
+// CHECK: 153:14: UnexposedExpr= Extent=[153:14 - 153:20]
+// CHECK: 153:14: IntegerLiteral= Extent=[153:14 - 153:20]
+// CHECK: 153:24: BinaryOperator= Extent=[153:24 - 153:35]
+// CHECK: 153:24: DeclRefExpr=c:2:14 Extent=[153:24 - 153:25]
+// CHECK: 153:29: UnexposedExpr= Extent=[153:29 - 153:35]
+// CHECK: 153:29: IntegerLiteral= Extent=[153:29 - 153:35]
+// CHECK: 154:9: BinaryOperator= Extent=[154:9 - 154:35]
+// CHECK: 154:9: BinaryOperator= Extent=[154:9 - 154:20]
+// CHECK: 154:9: DeclRefExpr=c:2:14 Extent=[154:9 - 154:10]
+// CHECK: 154:14: UnexposedExpr= Extent=[154:14 - 154:20]
+// CHECK: 154:14: IntegerLiteral= Extent=[154:14 - 154:20]
+// CHECK: 154:24: BinaryOperator= Extent=[154:24 - 154:35]
+// CHECK: 154:24: DeclRefExpr=c:2:14 Extent=[154:24 - 154:25]
+// CHECK: 154:29: UnexposedExpr= Extent=[154:29 - 154:35]
+// CHECK: 154:29: IntegerLiteral= Extent=[154:29 - 154:35]
+// CHECK: 155:9: BinaryOperator= Extent=[155:9 - 155:35]
+// CHECK: 155:9: BinaryOperator= Extent=[155:9 - 155:20]
+// CHECK: 155:9: DeclRefExpr=c:2:14 Extent=[155:9 - 155:10]
+// CHECK: 155:14: UnexposedExpr= Extent=[155:14 - 155:20]
+// CHECK: 155:14: IntegerLiteral= Extent=[155:14 - 155:20]
+// CHECK: 155:24: BinaryOperator= Extent=[155:24 - 155:35]
+// CHECK: 155:24: DeclRefExpr=c:2:14 Extent=[155:24 - 155:25]
+// CHECK: 155:29: UnexposedExpr= Extent=[155:29 - 155:35]
+// CHECK: 155:29: IntegerLiteral= Extent=[155:29 - 155:35]
+// CHECK: 156:9: BinaryOperator= Extent=[156:9 - 156:35]
+// CHECK: 156:9: BinaryOperator= Extent=[156:9 - 156:20]
+// CHECK: 156:9: DeclRefExpr=c:2:14 Extent=[156:9 - 156:10]
+// CHECK: 156:14: UnexposedExpr= Extent=[156:14 - 156:20]
+// CHECK: 156:14: IntegerLiteral= Extent=[156:14 - 156:20]
+// CHECK: 156:24: BinaryOperator= Extent=[156:24 - 156:35]
+// CHECK: 156:24: DeclRefExpr=c:2:14 Extent=[156:24 - 156:25]
+// CHECK: 156:29: UnexposedExpr= Extent=[156:29 - 156:35]
+// CHECK: 156:29: IntegerLiteral= Extent=[156:29 - 156:35]
+// CHECK: 157:9: BinaryOperator= Extent=[157:9 - 157:35]
+// CHECK: 157:9: BinaryOperator= Extent=[157:9 - 157:20]
+// CHECK: 157:9: DeclRefExpr=c:2:14 Extent=[157:9 - 157:10]
+// CHECK: 157:14: UnexposedExpr= Extent=[157:14 - 157:20]
+// CHECK: 157:14: IntegerLiteral= Extent=[157:14 - 157:20]
+// CHECK: 157:24: BinaryOperator= Extent=[157:24 - 157:35]
+// CHECK: 157:24: DeclRefExpr=c:2:14 Extent=[157:24 - 157:25]
+// CHECK: 157:29: UnexposedExpr= Extent=[157:29 - 157:35]
+// CHECK: 157:29: IntegerLiteral= Extent=[157:29 - 157:35]
+// CHECK: 158:8: BinaryOperator= Extent=[158:8 - 158:19]
+// CHECK: 158:8: DeclRefExpr=c:2:14 Extent=[158:8 - 158:9]
+// CHECK: 158:13: UnexposedExpr= Extent=[158:13 - 158:19]
+// CHECK: 158:13: IntegerLiteral= Extent=[158:13 - 158:19]
+// CHECK: 158:24: BinaryOperator= Extent=[158:24 - 158:50]
+// CHECK: 158:24: BinaryOperator= Extent=[158:24 - 158:35]
+// CHECK: 158:24: DeclRefExpr=c:2:14 Extent=[158:24 - 158:25]
+// CHECK: 158:29: UnexposedExpr= Extent=[158:29 - 158:35]
+// CHECK: 158:29: IntegerLiteral= Extent=[158:29 - 158:35]
+// CHECK: 158:39: BinaryOperator= Extent=[158:39 - 158:50]
+// CHECK: 158:39: DeclRefExpr=c:2:14 Extent=[158:39 - 158:40]
+// CHECK: 158:44: UnexposedExpr= Extent=[158:44 - 158:50]
+// CHECK: 158:44: IntegerLiteral= Extent=[158:44 - 158:50]
+// CHECK: 159:9: BinaryOperator= Extent=[159:9 - 159:35]
+// CHECK: 159:9: BinaryOperator= Extent=[159:9 - 159:20]
+// CHECK: 159:9: DeclRefExpr=c:2:14 Extent=[159:9 - 159:10]
+// CHECK: 159:14: UnexposedExpr= Extent=[159:14 - 159:20]
+// CHECK: 159:14: IntegerLiteral= Extent=[159:14 - 159:20]
+// CHECK: 159:24: BinaryOperator= Extent=[159:24 - 159:35]
+// CHECK: 159:24: DeclRefExpr=c:2:14 Extent=[159:24 - 159:25]
+// CHECK: 159:29: UnexposedExpr= Extent=[159:29 - 159:35]
+// CHECK: 159:29: IntegerLiteral= Extent=[159:29 - 159:35]
+// CHECK: 160:8: BinaryOperator= Extent=[160:8 - 160:19]
+// CHECK: 160:8: DeclRefExpr=c:2:14 Extent=[160:8 - 160:9]
+// CHECK: 160:13: UnexposedExpr= Extent=[160:13 - 160:19]
+// CHECK: 160:13: IntegerLiteral= Extent=[160:13 - 160:19]
+// CHECK: 160:23: ParenExpr= Extent=[160:23 - 160:51]
+// CHECK: 160:24: BinaryOperator= Extent=[160:24 - 160:50]
+// CHECK: 160:24: BinaryOperator= Extent=[160:24 - 160:35]
+// CHECK: 160:24: DeclRefExpr=c:2:14 Extent=[160:24 - 160:25]
+// CHECK: 160:29: UnexposedExpr= Extent=[160:29 - 160:35]
+// CHECK: 160:29: IntegerLiteral= Extent=[160:29 - 160:35]
+// CHECK: 160:39: BinaryOperator= Extent=[160:39 - 160:50]
+// CHECK: 160:39: DeclRefExpr=c:2:14 Extent=[160:39 - 160:40]
+// CHECK: 160:44: UnexposedExpr= Extent=[160:44 - 160:50]
+// CHECK: 160:44: IntegerLiteral= Extent=[160:44 - 160:50]
+
diff --git a/clang/test/Index/overrides.cpp b/clang/test/Index/overrides.cpp
new file mode 100644
index 0000000..698b256
--- /dev/null
+++ b/clang/test/Index/overrides.cpp
@@ -0,0 +1,20 @@
+struct A {
+ virtual void f(int);
+};
+
+struct B {
+ virtual void f(int);
+ virtual void g();
+};
+
+struct C : B, A {
+ virtual void g();
+};
+
+struct D : C {
+ virtual void f(int);
+};
+
+// RUN: c-index-test -test-load-source local %s | FileCheck %s
+// CHECK: overrides.cpp:11:16: CXXMethod=g:11:16 (virtual) [Overrides @7:16] Extent=[11:3 - 11:19]
+// CHECK: overrides.cpp:15:16: CXXMethod=f:15:16 (virtual) [Overrides @2:16, @6:16] Extent=[15:3 - 15:22]
diff --git a/clang/test/Index/overrides.m b/clang/test/Index/overrides.m
new file mode 100644
index 0000000..6908754
--- /dev/null
+++ b/clang/test/Index/overrides.m
@@ -0,0 +1,61 @@
+
+@protocol P1
+- (void)protoMethod;
+- (void)protoMethodWithParam:(int)param;
+@end
+
+@protocol P3
+- (void)protoMethod;
+@end
+
+@protocol P2 <P1>
+- (void)protoMethod;
+@end
+
+@interface A
+- (void)method;
+- (void)protoMethod;
++ (void)methodWithParam:(int)param;
+@end
+
+@interface B : A <P2, P3>
+- (void)method;
+- (void)protoMethod;
+@end
+
+@implementation B
+- (void)method { }
++ (void)methodWithParam:(int)param { }
+@end
+
+@protocol P4 <P3>
+- (void)protoMethod;
+@end
+
+@interface B(cat) <P4>
+- (void)protoMethod;
+@end
+
+@interface B2
+@end
+
+@interface B2(cat)
+-(void)meth;
+@end
+
+@interface I2 : B2
+@end
+
+@implementation I2
+-(void)meth { }
+@end
+
+// RUN: c-index-test -test-load-source local %s | FileCheck %s
+// CHECK: overrides.m:12:9: ObjCInstanceMethodDecl=protoMethod:12:9 [Overrides @3:9]
+// CHECK: overrides.m:22:9: ObjCInstanceMethodDecl=method:22:9 [Overrides @16:9]
+// CHECK: overrides.m:23:9: ObjCInstanceMethodDecl=protoMethod:23:9 [Overrides @12:9, @8:9, @32:9, @17:9]
+// CHECK: overrides.m:27:9: ObjCInstanceMethodDecl=method:27:9 (Definition) [Overrides @16:9]
+// CHECK: overrides.m:28:9: ObjCClassMethodDecl=methodWithParam::28:9 (Definition) [Overrides @18:9]
+// CHECK: overrides.m:32:9: ObjCInstanceMethodDecl=protoMethod:32:9 [Overrides @8:9]
+// CHECK: overrides.m:36:9: ObjCInstanceMethodDecl=protoMethod:36:9 [Overrides @12:9, @8:9, @32:9, @17:9]
+// CHECK: overrides.m:50:8: ObjCInstanceMethodDecl=meth:50:8 (Definition) [Overrides @43:8]
diff --git a/clang/test/Index/pch-opaque-value.cpp b/clang/test/Index/pch-opaque-value.cpp
new file mode 100644
index 0000000..ae6b6dc
--- /dev/null
+++ b/clang/test/Index/pch-opaque-value.cpp
@@ -0,0 +1,16 @@
+struct S {
+ S();
+ S(int);
+ S(const S &);
+ ~S();
+};
+
+void f() {
+ try {
+ } catch (S e) {
+ }
+}
+
+// RUN: c-index-test -write-pch %t.pch %s
+// RUN: c-index-test -test-load-tu-usrs %t.pch local | FileCheck %s
+// CHECK: pch-opaque-value.cpp c:pch-opaque-value.cpp@86@F@f#@e Extent=[10:12 - 10:15]
diff --git a/clang/test/Index/pch-with-errors.c b/clang/test/Index/pch-with-errors.c
new file mode 100644
index 0000000..be8728e
--- /dev/null
+++ b/clang/test/Index/pch-with-errors.c
@@ -0,0 +1,42 @@
+#ifndef HEADER
+#define HEADER
+
+#include "blahblah.h"
+void erroneous(int);
+void erroneous(float);
+
+struct bar;
+struct zed {
+ bar g;
+};
+struct baz {
+ zed h;
+};
+
+void errparm(zed e);
+
+struct S {
+ {
+;
+
+#else
+
+void foo(void) {
+ erroneous(0);
+}
+
+#endif
+
+// RUN: c-index-test -write-pch %t.h.pch %s -Xclang -detailed-preprocessing-record
+// RUN: c-index-test -test-load-source local %s -include %t.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-PARSE %s
+// RUN: c-index-test -index-file %s -include %t.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-INDEX %s
+
+// CHECK-PARSE: pch-with-errors.c:{{.*}}:6: FunctionDecl=foo
+// CHECK-PARSE: pch-with-errors.c:{{.*}}:3: CallExpr=erroneous
+
+// CHECK-INDEX: [indexDeclaration]: kind: function | name: foo
+// CHECK-INDEX: [indexEntityReference]: kind: function | name: erroneous
+
+// RUN: %clang -fsyntax-only %s -include %t.h 2>&1 | FileCheck -check-prefix=PCH-ERR %s
+
+// PCH-ERR: error: PCH file contains compiler errors
diff --git a/clang/test/Index/pch-with-errors.m b/clang/test/Index/pch-with-errors.m
new file mode 100644
index 0000000..cc42cd3
--- /dev/null
+++ b/clang/test/Index/pch-with-errors.m
@@ -0,0 +1,28 @@
+#ifndef HEADER
+#define HEADER
+
+@interface I(cat)
+-(void)meth;
+@end
+
+@interface I2
+-(void)meth;
+@end
+
+#else
+
+void foo(I2 *i) {
+ [i meth];
+}
+
+#endif
+
+// RUN: c-index-test -write-pch %t.h.pch %s -Xclang -detailed-preprocessing-record
+// RUN: c-index-test -test-load-source local %s -include %t.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-PARSE %s
+// RUN: c-index-test -index-file %s -include %t.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-INDEX %s
+
+// CHECK-PARSE: pch-with-errors.m:{{.*}} FunctionDecl=foo
+// CHECK-PARSE: pch-with-errors.m:{{.*}} ObjCMessageExpr=meth
+
+// CHECK-INDEX: [indexDeclaration]: kind: function | name: foo
+// CHECK-INDEX: [indexEntityReference]: kind: objc-instance-method | name: meth
diff --git a/clang/test/Index/pragma-diag-reparse.c b/clang/test/Index/pragma-diag-reparse.c
new file mode 100644
index 0000000..71d0618
--- /dev/null
+++ b/clang/test/Index/pragma-diag-reparse.c
@@ -0,0 +1,20 @@
+#pragma clang diagnostic ignored "-Wtautological-compare"
+#include "pragma_disable_warning.h"
+
+int main (int argc, const char * argv[])
+{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ int x=0;
+#pragma clang diagnostic pop
+
+ return x;
+}
+
+void foo() { int b=0; while (b==b); }
+
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source-reparse 5 local \
+// RUN: -I%S/Inputs \
+// RUN: %s -Wall -Werror | FileCheck %s
+
+// CHECK: pragma-diag-reparse.c:8:7: VarDecl=x:8:7 (Definition) Extent=[8:3 - 8:10]
diff --git a/clang/test/Index/preamble-reparse-chained.c b/clang/test/Index/preamble-reparse-chained.c
new file mode 100644
index 0000000..5cc28f7
--- /dev/null
+++ b/clang/test/Index/preamble-reparse-chained.c
@@ -0,0 +1,10 @@
+// RUN: c-index-test -write-pch %t.h.pch -x c-header %S/Inputs/a.h
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 all -I%S/Inputs -include %t.h %s | FileCheck %s
+#include "a.h"
+#include "b.h"
+
+A a;
+B b;
+
+// CHECK: a.h:3:13: TypedefDecl=A:3:13 (Definition) Extent=[3:1 - 3:14]
+// CHECK: b.h:1:15: TypedefDecl=B:1:15 (Definition) Extent=[1:1 - 1:16]
diff --git a/clang/test/Index/preamble-reparse-cmd-define.c b/clang/test/Index/preamble-reparse-cmd-define.c
new file mode 100644
index 0000000..67ffde1
--- /dev/null
+++ b/clang/test/Index/preamble-reparse-cmd-define.c
@@ -0,0 +1,9 @@
+// RUN: c-index-test -write-pch %t.h.pch %s.h
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_REMAP_AFTER_TRIAL=1 c-index-test -test-load-source-reparse 3 local \
+// RUN: "-remap-file=%s;%s.remap" %s -include %t.h -D CMD_MACRO=1 2>&1 | FileCheck %s
+
+// CHECK-NOT: error:
+
+int foo() {
+ return x;
+}
diff --git a/clang/test/Index/preamble-reparse-cmd-define.c.h b/clang/test/Index/preamble-reparse-cmd-define.c.h
new file mode 100644
index 0000000..2497af6
--- /dev/null
+++ b/clang/test/Index/preamble-reparse-cmd-define.c.h
@@ -0,0 +1 @@
+extern int x;
diff --git a/clang/test/Index/preamble-reparse-cmd-define.c.remap b/clang/test/Index/preamble-reparse-cmd-define.c.remap
new file mode 100644
index 0000000..35c140d
--- /dev/null
+++ b/clang/test/Index/preamble-reparse-cmd-define.c.remap
@@ -0,0 +1,8 @@
+
+#ifndef CMD_MACRO
+#error CMD_MACRO undefined
+#endif
+
+int foo() {
+ return x;
+}
diff --git a/clang/test/Index/preamble-reparse-import.m b/clang/test/Index/preamble-reparse-import.m
new file mode 100644
index 0000000..9bdb89a
--- /dev/null
+++ b/clang/test/Index/preamble-reparse-import.m
@@ -0,0 +1,12 @@
+// RUN: c-index-test -write-pch %t.h.pch -x objective-c %s-2.h
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_FAILONERROR=1 \
+// RUN: c-index-test -test-load-source-reparse 3 local %s -include %t.h
+// RUN: c-index-test -write-pch %t.h.pch -x objective-c %s-3.h
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_FAILONERROR=1 \
+// RUN: c-index-test -test-load-source-reparse 3 local %s -include %t.h
+
+#import "preamble-reparse-import.m-1.h"
+
+void foo();
+#import "preamble-reparse-import.m-2.h"
+#import "preamble-reparse-import.m-1.h"
diff --git a/clang/test/Index/preamble-reparse-import.m-1.h b/clang/test/Index/preamble-reparse-import.m-1.h
new file mode 100644
index 0000000..0d15823
--- /dev/null
+++ b/clang/test/Index/preamble-reparse-import.m-1.h
@@ -0,0 +1,5 @@
+#ifdef PARSED2
+#error parsed twice
+#endif
+
+#define PARSED2 1
diff --git a/clang/test/Index/preamble-reparse-import.m-2.h b/clang/test/Index/preamble-reparse-import.m-2.h
new file mode 100644
index 0000000..8acc5c3
--- /dev/null
+++ b/clang/test/Index/preamble-reparse-import.m-2.h
@@ -0,0 +1,5 @@
+#ifdef PARSED
+#error parsed twice
+#endif
+
+#define PARSED 1
diff --git a/clang/test/Index/preamble-reparse-import.m-3.h b/clang/test/Index/preamble-reparse-import.m-3.h
new file mode 100644
index 0000000..5369c1b
--- /dev/null
+++ b/clang/test/Index/preamble-reparse-import.m-3.h
@@ -0,0 +1 @@
+#import "preamble-reparse-import.m-2.h"
diff --git a/clang/test/Index/preamble-reparse.c b/clang/test/Index/preamble-reparse.c
new file mode 100644
index 0000000..5bd03b3
--- /dev/null
+++ b/clang/test/Index/preamble-reparse.c
@@ -0,0 +1,2 @@
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local "-remap-file=%S/Inputs/preamble-reparse-1.c;%S/Inputs/preamble-reparse-2.c" %S/Inputs/preamble-reparse-1.c | FileCheck %s
+// CHECK: preamble-reparse-1.c:1:5: VarDecl=x:1:5 Extent=[1:1 - 1:6]
diff --git a/clang/test/Index/preamble.c b/clang/test/Index/preamble.c
new file mode 100644
index 0000000..8a158e9
--- /dev/null
+++ b/clang/test/Index/preamble.c
@@ -0,0 +1,24 @@
+#include "prefix.h"
+#include "preamble.h"
+int wibble(int);
+
+void f(int x) {
+
+}
+// RUN: c-index-test -write-pch %t.pch -x c-header %S/Inputs/prefix.h
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local -I %S/Inputs -include %t %s 2> %t.stderr.txt | FileCheck %s
+// RUN: FileCheck -check-prefix CHECK-DIAG %s < %t.stderr.txt
+// CHECK: preamble.h:1:12: FunctionDecl=bar:1:12 (Definition) Extent=[1:1 - 6:2]
+// CHECK: preamble.h:4:3: BinaryOperator= Extent=[4:3 - 4:13]
+// CHECK: preamble.h:4:3: DeclRefExpr=ptr:2:8 Extent=[4:3 - 4:6]
+// CHECK: preamble.h:4:9: UnexposedExpr=ptr1:3:10 Extent=[4:9 - 4:13]
+// CHECK: preamble.h:4:9: DeclRefExpr=ptr1:3:10 Extent=[4:9 - 4:13]
+// CHECK: preamble.h:5:10: IntegerLiteral= Extent=[5:10 - 5:11]
+// CHECK: preamble.c:3:5: FunctionDecl=wibble:3:5 Extent=[3:1 - 3:16]
+// CHECK: preamble.c:3:15: ParmDecl=:3:15 (Definition) Extent=[3:12 - 3:16]
+// CHECK-DIAG: preamble.h:4:7:{4:9-4:13}: warning: incompatible pointer types assigning to 'int *' from 'float *'
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:6:1 -I %S/Inputs -include %t %s 2> %t.stderr.txt | FileCheck -check-prefix CHECK-CC %s
+// CHECK-CC: FunctionDecl:{ResultType int}{TypedText bar}{LeftParen (}{Placeholder int i}{RightParen )} (50)
+// CHECK-CC: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder int x}{RightParen )} (50)
+// CHECK-CC: FunctionDecl:{ResultType int}{TypedText foo}{LeftParen (}{Placeholder int}{RightParen )} (50)
+// CHECK-CC: FunctionDecl:{ResultType int}{TypedText wibble}{LeftParen (}{Placeholder int}{RightParen )} (50)
diff --git a/clang/test/Index/preamble_macro_template.cpp b/clang/test/Index/preamble_macro_template.cpp
new file mode 100644
index 0000000..ee1b413
--- /dev/null
+++ b/clang/test/Index/preamble_macro_template.cpp
@@ -0,0 +1,15 @@
+template void foo(int *);
+
+int main() { }
+
+// RUN: c-index-test -write-pch %t.pch -fno-delayed-template-parsing -x c++-header %S/Inputs/preamble_macro_template.h
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local -fno-delayed-template-parsing -I %S/Inputs -include %t %s | FileCheck %s
+// CHECK: preamble_macro_template.h:4:6: FunctionDecl=foo:4:6 (Definition) [Specialization of foo:4:6] Extent=[4:1 - 6:2]
+// CHECK: preamble_macro_template.h:4:13: ParmDecl=p:4:13 (Definition) Extent=[4:10 - 4:14]
+// CHECK: preamble_macro_template.h:4:16: CompoundStmt= Extent=[4:16 - 6:2]
+// CHECK: preamble_macro_template.h:5:3: CStyleCastExpr= Extent=[5:3 - 5:27]
+// CHECK: preamble_macro_template.h:1:21: CXXStaticCastExpr= Extent=[1:21 - 5:27]
+// CHECK: preamble_macro_template.h:5:25: UnexposedExpr= Extent=[5:25 - 5:26]
+// CHECK: preamble_macro_template.h:5:25: IntegerLiteral= Extent=[5:25 - 5:26]
+// CHECK: preamble_macro_template.cpp:3:5: FunctionDecl=main:3:5 (Definition) Extent=[3:1 - 3:15]
+// CHECK: preamble_macro_template.cpp:3:12: CompoundStmt= Extent=[3:12 - 3:15]
diff --git a/clang/test/Index/print-display-names.cpp b/clang/test/Index/print-display-names.cpp
new file mode 100644
index 0000000..94fe466
--- /dev/null
+++ b/clang/test/Index/print-display-names.cpp
@@ -0,0 +1,20 @@
+template<typename T, typename>
+class ClassTmpl { };
+
+typedef int Integer;
+
+template class ClassTmpl<Integer, Integer>;
+
+void f(ClassTmpl<float, Integer> p);
+
+template<typename T>
+void g(ClassTmpl<T, T>);
+
+template<> void g<int>(ClassTmpl<int, int>);
+
+// RUN: c-index-test -test-load-source all-display %s | FileCheck %s
+// CHECK: print-display-names.cpp:2:7: ClassTemplate=ClassTmpl<T, typename>:2:7
+// CHECK: print-display-names.cpp:6:16: ClassDecl=ClassTmpl<Integer, Integer>:6:16 (Definition)
+// CHECK: print-display-names.cpp:8:6: FunctionDecl=f(ClassTmpl<float, Integer>):8:6
+// CHECK: print-display-names.cpp:11:6: FunctionTemplate=g(ClassTmpl<T, T>):11:6
+// CHECK: print-display-names.cpp:13:17: FunctionDecl=g<>(ClassTmpl<int, int>):13:17 [Specialization of g:11:6]
diff --git a/clang/test/Index/print-typekind.c b/clang/test/Index/print-typekind.c
new file mode 100644
index 0000000..294aea7
--- /dev/null
+++ b/clang/test/Index/print-typekind.c
@@ -0,0 +1,28 @@
+typedef int FooType;
+int *p;
+int *f(int *p, char *x, FooType z) {
+ const FooType w = z;
+ return p + z;
+}
+typedef double OtherType;
+typedef int ArrayType[5];
+
+// RUN: c-index-test -test-print-typekind %s | FileCheck %s
+// CHECK: TypedefDecl=FooType:1:13 (Definition) typekind=Typedef [canonical=Int] [isPOD=1]
+// CHECK: VarDecl=p:2:6 typekind=Pointer [isPOD=1]
+// CHECK: FunctionDecl=f:3:6 (Definition) typekind=FunctionProto [canonical=FunctionProto] [result=Pointer] [args= Pointer Pointer Typedef] [isPOD=0]
+// CHECK: ParmDecl=p:3:13 (Definition) typekind=Pointer [isPOD=1]
+// CHECK: ParmDecl=x:3:22 (Definition) typekind=Pointer [isPOD=1]
+// CHECK: ParmDecl=z:3:33 (Definition) typekind=Typedef [canonical=Int] [isPOD=1]
+// CHECK: TypeRef=FooType:1:13 typekind=Typedef [canonical=Int] [isPOD=1]
+// CHECK: CompoundStmt= typekind=Invalid [isPOD=0]
+// CHECK: DeclStmt= typekind=Invalid [isPOD=0]
+// CHECK: VarDecl=w:4:17 (Definition) typekind=Typedef const [canonical=Int] [isPOD=1]
+// CHECK: TypeRef=FooType:1:13 typekind=Typedef [canonical=Int] [isPOD=1]
+// CHECK: DeclRefExpr=z:3:33 typekind=Typedef [canonical=Int] [isPOD=1]
+// CHECK: ReturnStmt= typekind=Invalid [isPOD=0]
+// CHECK: BinaryOperator= typekind=Pointer [isPOD=1]
+// CHECK: DeclRefExpr=p:3:13 typekind=Pointer [isPOD=1]
+// CHECK: DeclRefExpr=z:3:33 typekind=Typedef [canonical=Int] [isPOD=1]
+// CHECK: TypedefDecl=OtherType:7:16 (Definition) typekind=Typedef [canonical=Double] [isPOD=1]
+// CHECK: TypedefDecl=ArrayType:8:13 (Definition) typekind=Typedef [canonical=ConstantArray] [isPOD=1]
diff --git a/clang/test/Index/print-typekind.m b/clang/test/Index/print-typekind.m
new file mode 100644
index 0000000..9db1929
--- /dev/null
+++ b/clang/test/Index/print-typekind.m
@@ -0,0 +1,10 @@
+@interface Foo
+@property (readonly) id x;
+-(int) mymethod;
+-(int) mymethod2:(int)x blah:(float)y;
+@end
+
+// RUN: c-index-test -test-print-typekind %s | FileCheck %s
+// CHECK: ObjCPropertyDecl=x:2:25 typekind=Typedef [canonical=ObjCObjectPointer]
+// CHECK: ObjCInstanceMethodDecl=mymethod:3:8 typekind=Invalid [result=Int]
+// CHECK: ObjCInstanceMethodDecl=mymethod2:blah::4:8 typekind=Invalid [result=Int] [args= Int Float]
diff --git a/clang/test/Index/print-usrs.c b/clang/test/Index/print-usrs.c
new file mode 100644
index 0000000..898778b
--- /dev/null
+++ b/clang/test/Index/print-usrs.c
@@ -0,0 +1,17 @@
+// RUN: c-index-test -print-usr-file %s | FileCheck %s
+// This isn't really C code; it has a .c extension to get picked up by lit.
+ObjCClass NSObject
+ObjCCategory NSObject foo
+ObjCIvar x c:objc(cs)NSObject
+ObjCMethod foo: 0 c:objc(cs)NSObject
+ObjCMethod baz:with 1 c:objc(cs)NSObject
+ObjCProperty gimme c:objc(cs)NSObject
+ObjCProtocol blah
+// CHECK: c:objc(cs)NSObject
+// CHECK: c:objc(cy)NSObject@foo
+// CHECK: c:objc(cs)NSObject@x
+// CHECK: c:objc(cs)NSObject(cm)foo:
+// CHECK: c:objc(cs)NSObject(im)baz:with
+// CHECK: c:objc(cs)NSObject(py)gimme
+// CHECK: c:objc(pl)blah
+
diff --git a/clang/test/Index/properties-class-extensions.m b/clang/test/Index/properties-class-extensions.m
new file mode 100644
index 0000000..aa99207
--- /dev/null
+++ b/clang/test/Index/properties-class-extensions.m
@@ -0,0 +1,99 @@
+// Test that @properties within class extensions are visited by
+// clang_visitChildren only in the class extension, not the original
+// @interface (where we have a duplicate declaration - to be removed).
+@interface Foo {} @end
+@interface Foo (Cat)
+@property int a;
+@end
+@interface Foo ()
+@property int b;
+- (void) bar;
+@end
+
+// Test that 'setter' methods defined by @property in the class extension
+// but not the in @interface are only presented in the class extension.
+@interface Bar
+@property (readonly) id bar;
+@end
+@interface Bar ()
+@property (readwrite) id bar;
+@end
+
+// Another test, this one involving protocols, where the @property should
+// not appear in the @interface.
+@class Rdar8467189_Bar;
+@protocol Rdar8467189_FooProtocol
+@property (readonly) Rdar8467189_Bar *Rdar8467189_Bar;
+@end
+@interface Rdar8467189_Foo <Rdar8467189_FooProtocol>
+@end
+@interface Rdar8467189_Foo ()
+@property (readwrite) Rdar8467189_Bar *Rdar8467189_Bar;
+@end
+
+// Test if the @property added in an extension is not reported in the @interface.
+@interface Qux
+@end
+@interface Qux ()
+@property (assign, readwrite) id qux;
+@end
+
+@implementation Qux
+@dynamic qux;
+@end
+
+// RUN: c-index-test -test-load-source local %s | FileCheck %s
+// CHECK: properties-class-extensions.m:4:12: ObjCInterfaceDecl=Foo:4:12 Extent=[4:1 - 4:23]
+// CHECK-NOT: properties-class-extensions.m:9:15: ObjCInstanceMethodDecl=setB::9:15 Extent=[9:15 - 9:16]
+// CHECK-NOT: properties-class-extensions.m:9:15: ParmDecl=b:9:15 (Definition) Extent=[9:15 - 9:16]
+// CHECK: properties-class-extensions.m:5:12: ObjCCategoryDecl=Cat:5:12 Extent=[5:1 - 7:5]
+// CHECK: properties-class-extensions.m:5:12: ObjCClassRef=Foo:4:12 Extent=[5:12 - 5:15]
+// CHECK: properties-class-extensions.m:6:15: ObjCPropertyDecl=a:6:15 Extent=[6:1 - 6:16]
+// CHECK: properties-class-extensions.m:6:15: ObjCInstanceMethodDecl=a:6:15 Extent=[6:15 - 6:16]
+// CHECK: properties-class-extensions.m:6:15: ObjCInstanceMethodDecl=setA::6:15 Extent=[6:15 - 6:16]
+// CHECK: properties-class-extensions.m:6:15: ParmDecl=a:6:15 (Definition) Extent=[6:15 - 6:16]
+// CHECK: properties-class-extensions.m:8:12: ObjCCategoryDecl=:8:12 Extent=[8:1 - 11:5]
+// CHECK: properties-class-extensions.m:8:12: ObjCClassRef=Foo:4:12 Extent=[8:12 - 8:15]
+// CHECK: properties-class-extensions.m:9:15: ObjCPropertyDecl=b:9:15 Extent=[9:1 - 9:16]
+// CHECK: properties-class-extensions.m:9:15: ObjCInstanceMethodDecl=b:9:15 Extent=[9:15 - 9:16]
+// CHECK: properties-class-extensions.m:9:15: ObjCInstanceMethodDecl=setB::9:15 Extent=[9:15 - 9:16]
+// CHECK: properties-class-extensions.m:9:15: ParmDecl=b:9:15 (Definition) Extent=[9:15 - 9:16]
+// CHECK: properties-class-extensions.m:10:10: ObjCInstanceMethodDecl=bar:10:10 Extent=[10:1 - 10:14]
+// CHECK: properties-class-extensions.m:15:12: ObjCInterfaceDecl=Bar:15:12 Extent=[15:1 - 17:5]
+// CHECK: properties-class-extensions.m:16:25: ObjCPropertyDecl=bar:16:25 Extent=[16:1 - 16:28]
+// CHECK: properties-class-extensions.m:16:22: TypeRef=id:0:0 Extent=[16:22 - 16:24]
+// CHECK: properties-class-extensions.m:16:25: ObjCInstanceMethodDecl=bar:16:25 Extent=[16:25 - 16:28]
+// CHECK: properties-class-extensions.m:18:12: ObjCCategoryDecl=:18:12 Extent=[18:1 - 20:5]
+// CHECK: properties-class-extensions.m:18:12: ObjCClassRef=Bar:15:12 Extent=[18:12 - 18:15]
+// CHECK: properties-class-extensions.m:19:26: ObjCPropertyDecl=bar:19:26 Extent=[19:1 - 19:29]
+// CHECK: properties-class-extensions.m:19:23: TypeRef=id:0:0 Extent=[19:23 - 19:25]
+// CHECK-NOT: properties-class-extensions.m:16:25: ObjCInstanceMethodDecl=bar:16:25 Extent=[16:25 - 16:28]
+// CHECK: properties-class-extensions.m:19:26: ObjCInstanceMethodDecl=setBar::19:26 Extent=[19:26 - 19:29]
+// CHECK: properties-class-extensions.m:19:26: ParmDecl=bar:19:26 (Definition) Extent=[19:26 - 19:29]
+// CHECK: properties-class-extensions.m:24:8: ObjCInterfaceDecl=Rdar8467189_Bar:24:8 Extent=[24:1 - 24:23]
+// CHECK: properties-class-extensions.m:24:8: ObjCClassRef=Rdar8467189_Bar:24:8 Extent=[24:8 - 24:23]
+// CHECK: properties-class-extensions.m:25:11: ObjCProtocolDecl=Rdar8467189_FooProtocol:25:11 (Definition) Extent=[25:1 - 27:5]
+// CHECK: properties-class-extensions.m:26:39: ObjCPropertyDecl=Rdar8467189_Bar:26:39 Extent=[26:1 - 26:54]
+// CHECK: properties-class-extensions.m:26:22: ObjCClassRef=Rdar8467189_Bar:24:8 Extent=[26:22 - 26:37]
+// CHECK: properties-class-extensions.m:26:39: ObjCInstanceMethodDecl=Rdar8467189_Bar:26:39 Extent=[26:39 - 26:54]
+// CHECK: properties-class-extensions.m:28:12: ObjCInterfaceDecl=Rdar8467189_Foo:28:12 Extent=[28:1 - 29:5]
+// CHECK: properties-class-extensions.m:28:29: ObjCProtocolRef=Rdar8467189_FooProtocol:25:11 Extent=[28:29 - 28:52]
+// CHECK-NOT: properties-class-extensions.m:31:40: ObjCPropertyDecl=Rdar8467189_Bar:31:40 Extent=[31:40 - 31:55]
+// CHECK-NOT: properties-class-extensions.m:31:23: ObjCClassRef=Rdar8467189_Bar:24:8 Extent=[31:23 - 31:38]
+// CHECK: properties-class-extensions.m:30:12: ObjCCategoryDecl=:30:12 Extent=[30:1 - 32:5]
+// CHECK: properties-class-extensions.m:30:12: ObjCClassRef=Rdar8467189_Foo:28:12 Extent=[30:12 - 30:27]
+// CHECK: properties-class-extensions.m:31:40: ObjCPropertyDecl=Rdar8467189_Bar:31:40 Extent=[31:1 - 31:55]
+// CHECK: properties-class-extensions.m:31:23: ObjCClassRef=Rdar8467189_Bar:24:8 Extent=[31:23 - 31:38]
+// CHECK: properties-class-extensions.m:31:40: ObjCInstanceMethodDecl=Rdar8467189_Bar:31:40 [Overrides @26:39] Extent=[31:40 - 31:55]
+// CHECK: properties-class-extensions.m:31:40: ObjCInstanceMethodDecl=setRdar8467189_Bar::31:40 Extent=[31:40 - 31:55]
+// CHECK: properties-class-extensions.m:31:40: ParmDecl=Rdar8467189_Bar:31:40 (Definition) Extent=[31:40 - 31:55]
+// CHECK: properties-class-extensions.m:35:12: ObjCInterfaceDecl=Qux:35:12 Extent=[35:1 - 36:5]
+// CHECK: properties-class-extensions.m:37:12: ObjCCategoryDecl=:37:12 Extent=[37:1 - 39:5]
+// CHECK: properties-class-extensions.m:37:12: ObjCClassRef=Qux:35:12 Extent=[37:12 - 37:15]
+// CHECK: properties-class-extensions.m:38:34: ObjCPropertyDecl=qux:38:34 Extent=[38:1 - 38:37]
+// CHECK: properties-class-extensions.m:38:31: TypeRef=id:0:0 Extent=[38:31 - 38:33]
+// CHECK: properties-class-extensions.m:38:34: ObjCInstanceMethodDecl=qux:38:34 Extent=[38:34 - 38:37]
+// CHECK: properties-class-extensions.m:38:34: ObjCInstanceMethodDecl=setQux::38:34 Extent=[38:34 - 38:37]
+// CHECK: properties-class-extensions.m:38:34: ParmDecl=qux:38:34 (Definition) Extent=[38:34 - 38:37]
+// CHECK: properties-class-extensions.m:42:10: ObjCDynamicDecl=qux:38:34 (Definition) Extent=[42:1 - 42:13]
+
diff --git a/clang/test/Index/rdar-8288645-invalid-code.mm b/clang/test/Index/rdar-8288645-invalid-code.mm
new file mode 100644
index 0000000..ec45641
--- /dev/null
+++ b/clang/test/Index/rdar-8288645-invalid-code.mm
@@ -0,0 +1,7 @@
+// RUN: c-index-test -test-load-source all %s 2>&1 | FileCheck %s
+
+// This test case previously crashed Sema.
+
+extern "C" { @implementation Foo - (id)initWithBar:(Baz<WozBar>)pepper {
+
+// CHECK: warning: cannot find interface declaration for 'Foo'
diff --git a/clang/test/Index/recover-bad-code-rdar_7487294.c b/clang/test/Index/recover-bad-code-rdar_7487294.c
new file mode 100644
index 0000000..e060672
--- /dev/null
+++ b/clang/test/Index/recover-bad-code-rdar_7487294.c
@@ -0,0 +1,13 @@
+// RUN: %clang-cc1 -fsyntax-only %s 2>&1 | FileCheck %s
+
+// IMPORTANT: This test case intentionally DOES NOT use --disable-free. It
+// tests that we are properly reclaiming the ASTs and we do not have a double free.
+// Previously we tried to free the size expression of the VLA twice.
+
+int foo(int x) {
+ int y[x * 3];
+ help
+};
+
+// CHECK: 9:3: error: use of undeclared identifier 'help'
+// CHECK: help
diff --git a/clang/test/Index/recursive-cxx-member-calls.cpp b/clang/test/Index/recursive-cxx-member-calls.cpp
new file mode 100644
index 0000000..b80cbf4
--- /dev/null
+++ b/clang/test/Index/recursive-cxx-member-calls.cpp
@@ -0,0 +1,2243 @@
+typedef long unsigned int __darwin_size_t;
+typedef __darwin_size_t size_t;
+namespace std {
+ template < class _T1, class _T2 > struct pair { _T2 second; };
+}
+extern "C" {
+ int memcmp(const void *, const void *, size_t);
+ size_t strlen(const char *);
+}
+namespace clang {
+ class IdentifierInfo;
+ class AttributeList {
+ enum Kind {
+ AT_IBAction, AT_IBOutlet, AT_IBOutletCollection,
+ AT_address_space, AT_alias, AT_aligned, AT_always_inline,
+ AT_analyzer_noreturn, AT_annotate, AT_base_check, AT_blocks,
+ AT_carries_dependency, AT_cdecl, AT_cleanup, AT_const, AT_constructor,
+ AT_deprecated, AT_destructor, AT_dllexport, AT_dllimport,
+ AT_ext_vector_type, AT_fastcall, AT_final, AT_format, AT_format_arg,
+ AT_gnu_inline, AT_hiding, AT_malloc, AT_mode, AT_naked, AT_nodebug,
+ AT_noinline, AT_no_instrument_function, AT_nonnull, AT_noreturn,
+ AT_nothrow, AT_nsobject, AT_objc_exception, AT_override,
+ AT_cf_returns_not_retained, AT_cf_returns_retained,
+ AT_ns_returns_not_retained, AT_ns_returns_retained, AT_objc_gc,
+ AT_overloadable, AT_ownership_holds, AT_ownership_returns,
+ AT_ownership_takes, AT_packed, AT_pascal, AT_pure, AT_regparm,
+ AT_section, AT_sentinel, AT_stdcall, AT_thiscall, AT_transparent_union,
+ AT_unavailable, AT_unused, AT_used, AT_vecreturn, AT_vector_size,
+ AT_visibility, AT_warn_unused_result, AT_weak, AT_weakref,
+ AT_weak_import, AT_reqd_wg_size, AT_init_priority,
+ AT_returns_twice, IgnoredAttribute, UnknownAttribute
+ };
+ static Kind getKind(const IdentifierInfo * Name);
+ };
+}
+size_t magic_length(const char *s);
+namespace llvm {
+class StringRef {
+public:
+ typedef const char *iterator;
+ static const size_t npos = ~size_t(0);
+private:
+ const char *Data;
+ size_t Length;
+ static size_t min(size_t a, size_t b) { return a < b ? a : b; }
+public:
+ StringRef(): Data(0), Length(0) {}
+ StringRef(const char *Str) : Data(Str), Length(magic_length(Str)) {}
+ StringRef(const char *data, size_t length) : Data(data), Length(length) {}
+ iterator end() const { return Data; }
+ size_t size() const { return Length; }
+ bool startswith(StringRef Prefix) const {
+ return Length >= Prefix.Length &&
+ memcmp(Data, Prefix.Data, Prefix.Length) == 0;
+ }
+ bool endswith(StringRef Suffix) const {
+ return Length >= Suffix.Length &&
+ memcmp(end() - Suffix.Length, Suffix.Data, Suffix.Length) == 0;
+ }
+ StringRef substr(size_t Start, size_t N = npos) const {
+ return StringRef(Data + Start, min(N, Length - Start));
+ }
+};
+}
+namespace clang {
+class IdentifierInfo {
+public:IdentifierInfo();
+ const char *getNameStart() const {
+ typedef std::pair < IdentifierInfo, const char *>actualtype;
+ return ((const actualtype *) this)->second;
+ }
+ unsigned getLength() const {
+ typedef std::pair < IdentifierInfo, const char *>actualtype;
+ const char *p = ((const actualtype *) this)->second - 2;
+ return (((unsigned) p[0]) | (((unsigned) p[1]) << 8)) - 1;
+ }
+ llvm::StringRef getName() const {
+ return llvm::StringRef(getNameStart(), getLength());
+ }
+};
+}
+namespace llvm {
+template < typename T, typename R = T > class StringSwitch {
+ StringRef Str;
+ const T *Result;
+public:
+ explicit StringSwitch(StringRef Str) : Str(Str), Result(0) {}
+ template < unsigned N > StringSwitch & Case(const char (&S)[N],
+ const T & Value) {
+ return *this;
+ }
+ R Default(const T & Value) const {
+ return Value;
+ }
+};
+}
+
+using namespace clang;
+
+AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
+ llvm::StringRef AttrName = Name->getName();
+ if (AttrName.startswith("__") && AttrName.endswith("__"))
+ AttrName = AttrName.substr(2, AttrName.size() - 4);
+
+ return llvm::StringSwitch < AttributeList::Kind > (AttrName)
+ .Case("weak", AT_weak)
+ .Case("weakref", AT_weakref)
+ .Case("pure", AT_pure)
+ .Case("mode", AT_mode)
+ .Case("used", AT_used)
+ .Case("alias", AT_alias)
+ .Case("align", AT_aligned)
+ .Case("final", AT_final)
+ .Case("cdecl", AT_cdecl)
+ .Case("const", AT_const)
+ .Case("__const", AT_const)
+ .Case("blocks", AT_blocks)
+ .Case("format", AT_format)
+ .Case("hiding", AT_hiding)
+ .Case("malloc", AT_malloc)
+ .Case("packed", AT_packed)
+ .Case("unused", AT_unused)
+ .Case("aligned", AT_aligned)
+ .Case("cleanup", AT_cleanup)
+ .Case("naked", AT_naked)
+ .Case("nodebug", AT_nodebug)
+ .Case("nonnull", AT_nonnull)
+ .Case("nothrow", AT_nothrow)
+ .Case("objc_gc", AT_objc_gc)
+ .Case("regparm", AT_regparm)
+ .Case("section", AT_section)
+ .Case("stdcall", AT_stdcall)
+ .Case("annotate", AT_annotate)
+ .Case("fastcall", AT_fastcall)
+ .Case("ibaction", AT_IBAction)
+ .Case("iboutlet", AT_IBOutlet)
+ .Case("iboutletcollection", AT_IBOutletCollection)
+ .Case("noreturn", AT_noreturn)
+ .Case("noinline", AT_noinline)
+ .Case("override", AT_override)
+ .Case("sentinel", AT_sentinel)
+ .Case("NSObject", AT_nsobject)
+ .Case("dllimport", AT_dllimport)
+ .Case("dllexport", AT_dllexport)
+ .Case("may_alias", IgnoredAttribute)
+ .Case("base_check", AT_base_check)
+ .Case("deprecated", AT_deprecated)
+ .Case("visibility", AT_visibility)
+ .Case("destructor", AT_destructor)
+ .Case("format_arg", AT_format_arg)
+ .Case("gnu_inline", AT_gnu_inline)
+ .Case("weak_import", AT_weak_import)
+ .Case("vecreturn", AT_vecreturn)
+ .Case("vector_size", AT_vector_size)
+ .Case("constructor", AT_constructor)
+ .Case("unavailable", AT_unavailable)
+ .Case("overloadable", AT_overloadable)
+ .Case("address_space", AT_address_space)
+ .Case("always_inline", AT_always_inline)
+ .Case("returns_twice", AT_returns_twice)
+ .Case("vec_type_hint", IgnoredAttribute)
+ .Case("objc_exception", AT_objc_exception)
+ .Case("ext_vector_type", AT_ext_vector_type)
+ .Case("transparent_union", AT_transparent_union)
+ .Case("analyzer_noreturn", AT_analyzer_noreturn)
+ .Case("warn_unused_result", AT_warn_unused_result)
+ .Case("carries_dependency", AT_carries_dependency)
+ .Case("ns_returns_not_retained", AT_ns_returns_not_retained)
+ .Case("ns_returns_retained", AT_ns_returns_retained)
+ .Case("cf_returns_not_retained", AT_cf_returns_not_retained)
+ .Case("cf_returns_retained", AT_cf_returns_retained)
+ .Case("ownership_returns", AT_ownership_returns)
+ .Case("ownership_holds", AT_ownership_holds)
+ .Case("ownership_takes", AT_ownership_takes)
+ .Case("reqd_work_group_size", AT_reqd_wg_size)
+ .Case("init_priority", AT_init_priority)
+ .Case("no_instrument_function", AT_no_instrument_function)
+ .Case("thiscall", AT_thiscall)
+ .Case("pascal", AT_pascal)
+ .Case("__cdecl", AT_cdecl)
+ .Case("__stdcall", AT_stdcall)
+ .Case("__fastcall", AT_fastcall)
+ .Case("__thiscall", AT_thiscall)
+ .Case("__pascal", AT_pascal)
+ .Default(UnknownAttribute);
+}
+
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:186:1 %s 2>&1 | FileCheck -check-prefix=CHECK-tokens %s
+// CHECK-tokens: Keyword: "typedef" [1:1 - 1:8]
+// CHECK-tokens: Keyword: "long" [1:9 - 1:13]
+// CHECK-tokens: Keyword: "unsigned" [1:14 - 1:22]
+// CHECK-tokens: Keyword: "int" [1:23 - 1:26]
+// CHECK-tokens: Identifier: "__darwin_size_t" [1:27 - 1:42] TypedefDecl=__darwin_size_t:1:27 (Definition)
+// CHECK-tokens: Punctuation: ";" [1:42 - 1:43]
+// CHECK-tokens: Keyword: "typedef" [2:1 - 2:8]
+// CHECK-tokens: Identifier: "__darwin_size_t" [2:9 - 2:24]
+// CHECK-tokens: Identifier: "size_t" [2:25 - 2:31] TypedefDecl=size_t:2:25 (Definition)
+// CHECK-tokens: Punctuation: ";" [2:31 - 2:32]
+// CHECK-tokens: Keyword: "namespace" [3:1 - 3:10]
+// CHECK-tokens: Identifier: "std" [3:11 - 3:14] Namespace=std:3:11 (Definition)
+// CHECK-tokens: Punctuation: "{" [3:15 - 3:16] Namespace=std:3:11 (Definition)
+// CHECK-tokens: Keyword: "template" [4:3 - 4:11] ClassTemplate=pair:4:44 (Definition)
+// CHECK-tokens: Punctuation: "<" [4:12 - 4:13] ClassTemplate=pair:4:44 (Definition)
+// CHECK-tokens: Keyword: "class" [4:14 - 4:19] TemplateTypeParameter=_T1:4:20 (Definition)
+// CHECK-tokens: Identifier: "_T1" [4:20 - 4:23] TemplateTypeParameter=_T1:4:20 (Definition)
+// CHECK-tokens: Punctuation: "," [4:23 - 4:24] ClassTemplate=pair:4:44 (Definition)
+// CHECK-tokens: Keyword: "class" [4:25 - 4:30] TemplateTypeParameter=_T2:4:31 (Definition)
+// CHECK-tokens: Identifier: "_T2" [4:31 - 4:34] TemplateTypeParameter=_T2:4:31 (Definition)
+// CHECK-tokens: Punctuation: ">" [4:35 - 4:36] ClassTemplate=pair:4:44 (Definition)
+// CHECK-tokens: Keyword: "struct" [4:37 - 4:43] ClassTemplate=pair:4:44 (Definition)
+// CHECK-tokens: Identifier: "pair" [4:44 - 4:48] ClassTemplate=pair:4:44 (Definition)
+// CHECK-tokens: Punctuation: "{" [4:49 - 4:50] ClassTemplate=pair:4:44 (Definition)
+// CHECK-tokens: Identifier: "_T2" [4:51 - 4:54] TypeRef=_T2:4:31
+// CHECK-tokens: Identifier: "second" [4:55 - 4:61] FieldDecl=second:4:55 (Definition)
+// CHECK-tokens: Punctuation: ";" [4:61 - 4:62] ClassTemplate=pair:4:44 (Definition)
+// CHECK-tokens: Punctuation: "}" [4:63 - 4:64] ClassTemplate=pair:4:44 (Definition)
+// CHECK-tokens: Punctuation: ";" [4:64 - 4:65] Namespace=std:3:11 (Definition)
+// CHECK-tokens: Punctuation: "}" [5:1 - 5:2] Namespace=std:3:11 (Definition)
+// CHECK-tokens: Keyword: "extern" [6:1 - 6:7]
+// CHECK-tokens: Literal: ""C"" [6:8 - 6:11] UnexposedDecl=:6:8 (Definition)
+// CHECK-tokens: Punctuation: "{" [6:12 - 6:13] UnexposedDecl=:6:8 (Definition)
+// CHECK-tokens: Keyword: "int" [7:3 - 7:6] FunctionDecl=memcmp:7:7
+// CHECK-tokens: Identifier: "memcmp" [7:7 - 7:13] FunctionDecl=memcmp:7:7
+// CHECK-tokens: Punctuation: "(" [7:13 - 7:14] FunctionDecl=memcmp:7:7
+// CHECK-tokens: Keyword: "const" [7:14 - 7:19] FunctionDecl=memcmp:7:7
+// CHECK-tokens: Keyword: "void" [7:20 - 7:24] ParmDecl=:7:26 (Definition)
+// CHECK-tokens: Punctuation: "*" [7:25 - 7:26] ParmDecl=:7:26 (Definition)
+// CHECK-tokens: Punctuation: "," [7:26 - 7:27] ParmDecl=:7:26 (Definition)
+// CHECK-tokens: Keyword: "const" [7:28 - 7:33] FunctionDecl=memcmp:7:7
+// CHECK-tokens: Keyword: "void" [7:34 - 7:38] ParmDecl=:7:40 (Definition)
+// CHECK-tokens: Punctuation: "*" [7:39 - 7:40] ParmDecl=:7:40 (Definition)
+// CHECK-tokens: Punctuation: "," [7:40 - 7:41] ParmDecl=:7:40 (Definition)
+// CHECK-tokens: Identifier: "size_t" [7:42 - 7:48] TypeRef=size_t:2:25
+// CHECK-tokens: Punctuation: ")" [7:48 - 7:49] ParmDecl=:7:48 (Definition)
+// CHECK-tokens: Punctuation: ";" [7:49 - 7:50] UnexposedDecl=:6:8 (Definition)
+// CHECK-tokens: Identifier: "size_t" [8:3 - 8:9] TypeRef=size_t:2:25
+// CHECK-tokens: Identifier: "strlen" [8:10 - 8:16] FunctionDecl=strlen:8:10
+// CHECK-tokens: Punctuation: "(" [8:16 - 8:17] FunctionDecl=strlen:8:10
+// CHECK-tokens: Keyword: "const" [8:17 - 8:22] FunctionDecl=strlen:8:10
+// CHECK-tokens: Keyword: "char" [8:23 - 8:27] ParmDecl=:8:29 (Definition)
+// CHECK-tokens: Punctuation: "*" [8:28 - 8:29] ParmDecl=:8:29 (Definition)
+// CHECK-tokens: Punctuation: ")" [8:29 - 8:30] ParmDecl=:8:29 (Definition)
+// CHECK-tokens: Punctuation: ";" [8:30 - 8:31]
+// CHECK-tokens: Punctuation: "}" [9:1 - 9:2]
+// CHECK-tokens: Keyword: "namespace" [10:1 - 10:10]
+// CHECK-tokens: Identifier: "clang" [10:17 - 10:22] Namespace=clang:10:17 (Definition)
+// CHECK-tokens: Punctuation: "{" [10:23 - 10:24] Namespace=clang:10:17 (Definition)
+// CHECK-tokens: Keyword: "class" [11:3 - 11:8] ClassDecl=IdentifierInfo:11:9
+// CHECK-tokens: Identifier: "IdentifierInfo" [11:9 - 11:23] ClassDecl=IdentifierInfo:11:9
+// CHECK-tokens: Punctuation: ";" [11:23 - 11:24] Namespace=clang:10:17 (Definition)
+// CHECK-tokens: Keyword: "class" [12:3 - 12:8] ClassDecl=AttributeList:12:9 (Definition)
+// CHECK-tokens: Identifier: "AttributeList" [12:9 - 12:22] ClassDecl=AttributeList:12:9 (Definition)
+// CHECK-tokens: Punctuation: "{" [12:23 - 12:24] ClassDecl=AttributeList:12:9 (Definition)
+// CHECK-tokens: Keyword: "enum" [13:5 - 13:9] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "Kind" [13:10 - 13:14] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Punctuation: "{" [13:15 - 13:16] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_IBAction" [14:7 - 14:18] EnumConstantDecl=AT_IBAction:14:7 (Definition)
+// CHECK-tokens: Punctuation: "," [14:18 - 14:19] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_IBOutlet" [14:20 - 14:31] EnumConstantDecl=AT_IBOutlet:14:20 (Definition)
+// CHECK-tokens: Punctuation: "," [14:31 - 14:32] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_IBOutletCollection" [14:33 - 14:54] EnumConstantDecl=AT_IBOutletCollection:14:33 (Definition)
+// CHECK-tokens: Punctuation: "," [14:54 - 14:55] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_address_space" [15:7 - 15:23] EnumConstantDecl=AT_address_space:15:7 (Definition)
+// CHECK-tokens: Punctuation: "," [15:23 - 15:24] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_alias" [15:25 - 15:33] EnumConstantDecl=AT_alias:15:25 (Definition)
+// CHECK-tokens: Punctuation: "," [15:33 - 15:34] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_aligned" [15:35 - 15:45] EnumConstantDecl=AT_aligned:15:35 (Definition)
+// CHECK-tokens: Punctuation: "," [15:45 - 15:46] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_always_inline" [15:47 - 15:63] EnumConstantDecl=AT_always_inline:15:47 (Definition)
+// CHECK-tokens: Punctuation: "," [15:63 - 15:64] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_analyzer_noreturn" [16:7 - 16:27] EnumConstantDecl=AT_analyzer_noreturn:16:7 (Definition)
+// CHECK-tokens: Punctuation: "," [16:27 - 16:28] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_annotate" [16:29 - 16:40] EnumConstantDecl=AT_annotate:16:29 (Definition)
+// CHECK-tokens: Punctuation: "," [16:40 - 16:41] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_base_check" [16:42 - 16:55] EnumConstantDecl=AT_base_check:16:42 (Definition)
+// CHECK-tokens: Punctuation: "," [16:55 - 16:56] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_blocks" [16:57 - 16:66] EnumConstantDecl=AT_blocks:16:57 (Definition)
+// CHECK-tokens: Punctuation: "," [16:66 - 16:67] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_carries_dependency" [17:7 - 17:28] EnumConstantDecl=AT_carries_dependency:17:7 (Definition)
+// CHECK-tokens: Punctuation: "," [17:28 - 17:29] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_cdecl" [17:30 - 17:38] EnumConstantDecl=AT_cdecl:17:30 (Definition)
+// CHECK-tokens: Punctuation: "," [17:38 - 17:39] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_cleanup" [17:40 - 17:50] EnumConstantDecl=AT_cleanup:17:40 (Definition)
+// CHECK-tokens: Punctuation: "," [17:50 - 17:51] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_const" [17:52 - 17:60] EnumConstantDecl=AT_const:17:52 (Definition)
+// CHECK-tokens: Punctuation: "," [17:60 - 17:61] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_constructor" [17:62 - 17:76] EnumConstantDecl=AT_constructor:17:62 (Definition)
+// CHECK-tokens: Punctuation: "," [17:76 - 17:77] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_deprecated" [18:7 - 18:20] EnumConstantDecl=AT_deprecated:18:7 (Definition)
+// CHECK-tokens: Punctuation: "," [18:20 - 18:21] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_destructor" [18:22 - 18:35] EnumConstantDecl=AT_destructor:18:22 (Definition)
+// CHECK-tokens: Punctuation: "," [18:35 - 18:36] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_dllexport" [18:37 - 18:49] EnumConstantDecl=AT_dllexport:18:37 (Definition)
+// CHECK-tokens: Punctuation: "," [18:49 - 18:50] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_dllimport" [18:51 - 18:63] EnumConstantDecl=AT_dllimport:18:51 (Definition)
+// CHECK-tokens: Punctuation: "," [18:63 - 18:64] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_ext_vector_type" [19:7 - 19:25] EnumConstantDecl=AT_ext_vector_type:19:7 (Definition)
+// CHECK-tokens: Punctuation: "," [19:25 - 19:26] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_fastcall" [19:27 - 19:38] EnumConstantDecl=AT_fastcall:19:27 (Definition)
+// CHECK-tokens: Punctuation: "," [19:38 - 19:39] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_final" [19:40 - 19:48] EnumConstantDecl=AT_final:19:40 (Definition)
+// CHECK-tokens: Punctuation: "," [19:48 - 19:49] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_format" [19:50 - 19:59] EnumConstantDecl=AT_format:19:50 (Definition)
+// CHECK-tokens: Punctuation: "," [19:59 - 19:60] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_format_arg" [19:61 - 19:74] EnumConstantDecl=AT_format_arg:19:61 (Definition)
+// CHECK-tokens: Punctuation: "," [19:74 - 19:75] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_gnu_inline" [20:7 - 20:20] EnumConstantDecl=AT_gnu_inline:20:7 (Definition)
+// CHECK-tokens: Punctuation: "," [20:20 - 20:21] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_hiding" [20:22 - 20:31] EnumConstantDecl=AT_hiding:20:22 (Definition)
+// CHECK-tokens: Punctuation: "," [20:31 - 20:32] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_malloc" [20:33 - 20:42] EnumConstantDecl=AT_malloc:20:33 (Definition)
+// CHECK-tokens: Punctuation: "," [20:42 - 20:43] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_mode" [20:44 - 20:51] EnumConstantDecl=AT_mode:20:44 (Definition)
+// CHECK-tokens: Punctuation: "," [20:51 - 20:52] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_naked" [20:53 - 20:61] EnumConstantDecl=AT_naked:20:53 (Definition)
+// CHECK-tokens: Punctuation: "," [20:61 - 20:62] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_nodebug" [20:63 - 20:73] EnumConstantDecl=AT_nodebug:20:63 (Definition)
+// CHECK-tokens: Punctuation: "," [20:73 - 20:74] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_noinline" [21:7 - 21:18] EnumConstantDecl=AT_noinline:21:7 (Definition)
+// CHECK-tokens: Punctuation: "," [21:18 - 21:19] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_no_instrument_function" [21:20 - 21:45] EnumConstantDecl=AT_no_instrument_function:21:20 (Definition)
+// CHECK-tokens: Punctuation: "," [21:45 - 21:46] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_nonnull" [21:47 - 21:57] EnumConstantDecl=AT_nonnull:21:47 (Definition)
+// CHECK-tokens: Punctuation: "," [21:57 - 21:58] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_noreturn" [21:59 - 21:70] EnumConstantDecl=AT_noreturn:21:59 (Definition)
+// CHECK-tokens: Punctuation: "," [21:70 - 21:71] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_nothrow" [22:7 - 22:17] EnumConstantDecl=AT_nothrow:22:7 (Definition)
+// CHECK-tokens: Punctuation: "," [22:17 - 22:18] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_nsobject" [22:19 - 22:30] EnumConstantDecl=AT_nsobject:22:19 (Definition)
+// CHECK-tokens: Punctuation: "," [22:30 - 22:31] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_objc_exception" [22:32 - 22:49] EnumConstantDecl=AT_objc_exception:22:32 (Definition)
+// CHECK-tokens: Punctuation: "," [22:49 - 22:50] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_override" [22:51 - 22:62] EnumConstantDecl=AT_override:22:51 (Definition)
+// CHECK-tokens: Punctuation: "," [22:62 - 22:63] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_cf_returns_not_retained" [23:7 - 23:33] EnumConstantDecl=AT_cf_returns_not_retained:23:7 (Definition)
+// CHECK-tokens: Punctuation: "," [23:33 - 23:34] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_cf_returns_retained" [23:35 - 23:57] EnumConstantDecl=AT_cf_returns_retained:23:35 (Definition)
+// CHECK-tokens: Punctuation: "," [23:57 - 23:58] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_ns_returns_not_retained" [24:7 - 24:33] EnumConstantDecl=AT_ns_returns_not_retained:24:7 (Definition)
+// CHECK-tokens: Punctuation: "," [24:33 - 24:34] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_ns_returns_retained" [24:35 - 24:57] EnumConstantDecl=AT_ns_returns_retained:24:35 (Definition)
+// CHECK-tokens: Punctuation: "," [24:57 - 24:58] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_objc_gc" [24:59 - 24:69] EnumConstantDecl=AT_objc_gc:24:59 (Definition)
+// CHECK-tokens: Punctuation: "," [24:69 - 24:70] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_overloadable" [25:7 - 25:22] EnumConstantDecl=AT_overloadable:25:7 (Definition)
+// CHECK-tokens: Punctuation: "," [25:22 - 25:23] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_ownership_holds" [25:24 - 25:42] EnumConstantDecl=AT_ownership_holds:25:24 (Definition)
+// CHECK-tokens: Punctuation: "," [25:42 - 25:43] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_ownership_returns" [25:44 - 25:64] EnumConstantDecl=AT_ownership_returns:25:44 (Definition)
+// CHECK-tokens: Punctuation: "," [25:64 - 25:65] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_ownership_takes" [26:7 - 26:25] EnumConstantDecl=AT_ownership_takes:26:7 (Definition)
+// CHECK-tokens: Punctuation: "," [26:25 - 26:26] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_packed" [26:27 - 26:36] EnumConstantDecl=AT_packed:26:27 (Definition)
+// CHECK-tokens: Punctuation: "," [26:36 - 26:37] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_pascal" [26:38 - 26:47] EnumConstantDecl=AT_pascal:26:38 (Definition)
+// CHECK-tokens: Punctuation: "," [26:47 - 26:48] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_pure" [26:49 - 26:56] EnumConstantDecl=AT_pure:26:49 (Definition)
+// CHECK-tokens: Punctuation: "," [26:56 - 26:57] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_regparm" [26:58 - 26:68] EnumConstantDecl=AT_regparm:26:58 (Definition)
+// CHECK-tokens: Punctuation: "," [26:68 - 26:69] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_section" [27:7 - 27:17] EnumConstantDecl=AT_section:27:7 (Definition)
+// CHECK-tokens: Punctuation: "," [27:17 - 27:18] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_sentinel" [27:19 - 27:30] EnumConstantDecl=AT_sentinel:27:19 (Definition)
+// CHECK-tokens: Punctuation: "," [27:30 - 27:31] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_stdcall" [27:32 - 27:42] EnumConstantDecl=AT_stdcall:27:32 (Definition)
+// CHECK-tokens: Punctuation: "," [27:42 - 27:43] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_thiscall" [27:44 - 27:55] EnumConstantDecl=AT_thiscall:27:44 (Definition)
+// CHECK-tokens: Punctuation: "," [27:55 - 27:56] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_transparent_union" [27:57 - 27:77] EnumConstantDecl=AT_transparent_union:27:57 (Definition)
+// CHECK-tokens: Punctuation: "," [27:77 - 27:78] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_unavailable" [28:7 - 28:21] EnumConstantDecl=AT_unavailable:28:7 (Definition)
+// CHECK-tokens: Punctuation: "," [28:21 - 28:22] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_unused" [28:23 - 28:32] EnumConstantDecl=AT_unused:28:23 (Definition)
+// CHECK-tokens: Punctuation: "," [28:32 - 28:33] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_used" [28:34 - 28:41] EnumConstantDecl=AT_used:28:34 (Definition)
+// CHECK-tokens: Punctuation: "," [28:41 - 28:42] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_vecreturn" [28:43 - 28:55] EnumConstantDecl=AT_vecreturn:28:43 (Definition)
+// CHECK-tokens: Punctuation: "," [28:55 - 28:56] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_vector_size" [28:57 - 28:71] EnumConstantDecl=AT_vector_size:28:57 (Definition)
+// CHECK-tokens: Punctuation: "," [28:71 - 28:72] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_visibility" [29:7 - 29:20] EnumConstantDecl=AT_visibility:29:7 (Definition)
+// CHECK-tokens: Punctuation: "," [29:20 - 29:21] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_warn_unused_result" [29:22 - 29:43] EnumConstantDecl=AT_warn_unused_result:29:22 (Definition)
+// CHECK-tokens: Punctuation: "," [29:43 - 29:44] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_weak" [29:45 - 29:52] EnumConstantDecl=AT_weak:29:45 (Definition)
+// CHECK-tokens: Punctuation: "," [29:52 - 29:53] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_weakref" [29:54 - 29:64] EnumConstantDecl=AT_weakref:29:54 (Definition)
+// CHECK-tokens: Punctuation: "," [29:64 - 29:65] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_weak_import" [30:7 - 30:21] EnumConstantDecl=AT_weak_import:30:7 (Definition)
+// CHECK-tokens: Punctuation: "," [30:21 - 30:22] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_reqd_wg_size" [30:23 - 30:38] EnumConstantDecl=AT_reqd_wg_size:30:23 (Definition)
+// CHECK-tokens: Punctuation: "," [30:38 - 30:39] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_init_priority" [30:40 - 30:56] EnumConstantDecl=AT_init_priority:30:40 (Definition)
+// CHECK-tokens: Punctuation: "," [30:56 - 30:57] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "AT_returns_twice" [31:7 - 31:23] EnumConstantDecl=AT_returns_twice:31:7 (Definition)
+// CHECK-tokens: Punctuation: "," [31:23 - 31:24] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Identifier: "IgnoredAttribute" [31:25 - 31:41] EnumConstantDecl=IgnoredAttribute:31:25 (Definition)
+// CHECK-tokens: Punctuation: "}" [32:5 - 32:6] EnumDecl=Kind:13:10 (Definition)
+// CHECK-tokens: Punctuation: ";" [32:6 - 32:7] ClassDecl=AttributeList:12:9 (Definition)
+// CHECK-tokens: Keyword: "static" [33:5 - 33:11] ClassDecl=AttributeList:12:9 (Definition)
+// CHECK-tokens: Identifier: "Kind" [33:12 - 33:16] TypeRef=enum clang::AttributeList::Kind:13:10
+// CHECK-tokens: Identifier: "getKind" [33:17 - 33:24] CXXMethod=getKind:33:17 (static)
+// CHECK-tokens: Punctuation: "(" [33:24 - 33:25] CXXMethod=getKind:33:17 (static)
+// CHECK-tokens: Keyword: "const" [33:25 - 33:30] CXXMethod=getKind:33:17 (static)
+// CHECK-tokens: Identifier: "IdentifierInfo" [33:31 - 33:45] TypeRef=class clang::IdentifierInfo:66:7
+// CHECK-tokens: Punctuation: "*" [33:46 - 33:47] ParmDecl=Name:33:48 (Definition)
+// CHECK-tokens: Identifier: "Name" [33:48 - 33:52] ParmDecl=Name:33:48 (Definition)
+// CHECK-tokens: Punctuation: ")" [33:52 - 33:53] CXXMethod=getKind:33:17 (static)
+// CHECK-tokens: Punctuation: ";" [33:53 - 33:54] ClassDecl=AttributeList:12:9 (Definition)
+// CHECK-tokens: Punctuation: "}" [34:3 - 34:4] ClassDecl=AttributeList:12:9 (Definition)
+// CHECK-tokens: Punctuation: ";" [34:4 - 34:5] Namespace=clang:10:17 (Definition)
+// CHECK-tokens: Punctuation: "}" [35:1 - 35:2] Namespace=clang:10:17 (Definition)
+// CHECK-tokens: Identifier: "size_t" [36:1 - 36:7] TypeRef=size_t:2:25
+// CHECK-tokens: Identifier: "magic_length" [36:8 - 36:20] FunctionDecl=magic_length:36:8
+// CHECK-tokens: Punctuation: "(" [36:20 - 36:21] FunctionDecl=magic_length:36:8
+// CHECK-tokens: Keyword: "const" [36:21 - 36:26] FunctionDecl=magic_length:36:8
+// CHECK-tokens: Keyword: "char" [36:27 - 36:31] ParmDecl=s:36:33 (Definition)
+// CHECK-tokens: Punctuation: "*" [36:32 - 36:33] ParmDecl=s:36:33 (Definition)
+// CHECK-tokens: Identifier: "s" [36:33 - 36:34] ParmDecl=s:36:33 (Definition)
+// CHECK-tokens: Punctuation: ")" [36:34 - 36:35] FunctionDecl=magic_length:36:8
+// CHECK-tokens: Punctuation: ";" [36:35 - 36:36]
+// CHECK-tokens: Keyword: "namespace" [37:1 - 37:10]
+// CHECK-tokens: Identifier: "llvm" [37:11 - 37:15] Namespace=llvm:37:11 (Definition)
+// CHECK-tokens: Punctuation: "{" [37:16 - 37:17] Namespace=llvm:37:11 (Definition)
+// CHECK-tokens: Keyword: "class" [38:1 - 38:6] ClassDecl=StringRef:38:7 (Definition)
+// CHECK-tokens: Identifier: "StringRef" [38:7 - 38:16] ClassDecl=StringRef:38:7 (Definition)
+// CHECK-tokens: Punctuation: "{" [38:17 - 38:18] ClassDecl=StringRef:38:7 (Definition)
+// CHECK-tokens: Keyword: "public" [39:1 - 39:7] CXXAccessSpecifier=:39:1 (Definition)
+// CHECK-tokens: Punctuation: ":" [39:7 - 39:8] CXXAccessSpecifier=:39:1 (Definition)
+// CHECK-tokens: Keyword: "typedef" [40:3 - 40:10] ClassDecl=StringRef:38:7 (Definition)
+// CHECK-tokens: Keyword: "const" [40:11 - 40:16] ClassDecl=StringRef:38:7 (Definition)
+// CHECK-tokens: Keyword: "char" [40:17 - 40:21] TypedefDecl=iterator:40:23 (Definition)
+// CHECK-tokens: Punctuation: "*" [40:22 - 40:23] TypedefDecl=iterator:40:23 (Definition)
+// CHECK-tokens: Identifier: "iterator" [40:23 - 40:31] TypedefDecl=iterator:40:23 (Definition)
+// CHECK-tokens: Punctuation: ";" [40:31 - 40:32] ClassDecl=StringRef:38:7 (Definition)
+// CHECK-tokens: Keyword: "static" [41:3 - 41:9] ClassDecl=StringRef:38:7 (Definition)
+// CHECK-tokens: Keyword: "const" [41:10 - 41:15] ClassDecl=StringRef:38:7 (Definition)
+// CHECK-tokens: Identifier: "size_t" [41:16 - 41:22] TypeRef=size_t:2:25
+// CHECK-tokens: Identifier: "npos" [41:23 - 41:27] VarDecl=npos:41:23
+// CHECK-tokens: Punctuation: "=" [41:28 - 41:29] VarDecl=npos:41:23
+// CHECK-tokens: Punctuation: "~" [41:30 - 41:31] UnaryOperator=
+// CHECK-tokens: Identifier: "size_t" [41:31 - 41:37] TypeRef=size_t:2:25
+// CHECK-tokens: Punctuation: "(" [41:37 - 41:38] CXXFunctionalCastExpr=
+// CHECK-tokens: Literal: "0" [41:38 - 41:39] IntegerLiteral=
+// CHECK-tokens: Punctuation: ")" [41:39 - 41:40] CXXFunctionalCastExpr
+// CHECK-tokens: Punctuation: ";" [41:40 - 41:41] ClassDecl=StringRef:38:7 (Definition)
+// CHECK-tokens: Keyword: "private" [42:1 - 42:8] CXXAccessSpecifier=:42:1 (Definition)
+// CHECK-tokens: Punctuation: ":" [42:8 - 42:9] CXXAccessSpecifier=:42:1 (Definition)
+// CHECK-tokens: Keyword: "const" [43:3 - 43:8] ClassDecl=StringRef:38:7 (Definition)
+// CHECK-tokens: Keyword: "char" [43:9 - 43:13] FieldDecl=Data:43:15 (Definition)
+// CHECK-tokens: Punctuation: "*" [43:14 - 43:15] FieldDecl=Data:43:15 (Definition)
+// CHECK-tokens: Identifier: "Data" [43:15 - 43:19] FieldDecl=Data:43:15 (Definition)
+// CHECK-tokens: Punctuation: ";" [43:19 - 43:20] ClassDecl=StringRef:38:7 (Definition)
+// CHECK-tokens: Identifier: "size_t" [44:3 - 44:9] TypeRef=size_t:2:25
+// CHECK-tokens: Identifier: "Length" [44:10 - 44:16] FieldDecl=Length:44:10 (Definition)
+// CHECK-tokens: Punctuation: ";" [44:16 - 44:17] ClassDecl=StringRef:38:7 (Definition)
+// CHECK-tokens: Keyword: "static" [45:3 - 45:9] ClassDecl=StringRef:38:7 (Definition)
+// CHECK-tokens: Identifier: "size_t" [45:10 - 45:16] TypeRef=size_t:2:25
+// CHECK-tokens: Identifier: "min" [45:17 - 45:20] CXXMethod=min:45:17 (Definition) (static)
+// CHECK-tokens: Punctuation: "(" [45:20 - 45:21] CXXMethod=min:45:17 (Definition) (static)
+// CHECK-tokens: Identifier: "size_t" [45:21 - 45:27] TypeRef=size_t:2:25
+// CHECK-tokens: Identifier: "a" [45:28 - 45:29] ParmDecl=a:45:28 (Definition)
+// CHECK-tokens: Punctuation: "," [45:29 - 45:30] CXXMethod=min:45:17 (Definition) (static)
+// CHECK-tokens: Identifier: "size_t" [45:31 - 45:37] TypeRef=size_t:2:25
+// CHECK-tokens: Identifier: "b" [45:38 - 45:39] ParmDecl=b:45:38 (Definition)
+// CHECK-tokens: Punctuation: ")" [45:39 - 45:40] CXXMethod=min:45:17 (Definition) (static)
+// CHECK-tokens: Punctuation: "{" [45:41 - 45:42] CompoundStmt=
+// CHECK-tokens: Keyword: "return" [45:43 - 45:49] ReturnStmt=
+// CHECK-tokens: Identifier: "a" [45:50 - 45:51] DeclRefExpr=a:45:28
+// CHECK-tokens: Punctuation: "<" [45:52 - 45:53] BinaryOperator=
+// CHECK-tokens: Identifier: "b" [45:54 - 45:55] DeclRefExpr=b:45:38
+// CHECK-tokens: Punctuation: "?" [45:56 - 45:57] ConditionalOperator=
+// CHECK-tokens: Identifier: "a" [45:58 - 45:59] DeclRefExpr=a:45:28
+// CHECK-tokens: Punctuation: ":" [45:60 - 45:61] ConditionalOperator
+// CHECK-tokens: Identifier: "b" [45:62 - 45:63] DeclRefExpr=b:45:38
+// CHECK-tokens: Punctuation: ";" [45:63 - 45:64] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [45:65 - 45:66] CompoundStmt=
+// CHECK-tokens: Keyword: "public" [46:1 - 46:7] CXXAccessSpecifier=:46:1 (Definition)
+// CHECK-tokens: Punctuation: ":" [46:7 - 46:8] CXXAccessSpecifier=:46:1 (Definition)
+// CHECK-tokens: Identifier: "StringRef" [47:3 - 47:12] CXXConstructor=StringRef:47:3 (Definition)
+// CHECK-tokens: Punctuation: "(" [47:12 - 47:13] CXXConstructor=StringRef:47:3 (Definition)
+// CHECK-tokens: Punctuation: ")" [47:13 - 47:14] CXXConstructor=StringRef:47:3 (Definition)
+// CHECK-tokens: Punctuation: ":" [47:14 - 47:15] CXXConstructor=StringRef:47:3 (Definition)
+// CHECK-tokens: Identifier: "Data" [47:16 - 47:20] MemberRef=Data:43:15
+// CHECK-tokens: Punctuation: "(" [47:20 - 47:21] CXXConstructor=StringRef:47:3 (Definition)
+// CHECK-tokens: Literal: "0" [47:21 - 47:22] IntegerLiteral=
+// CHECK-tokens: Punctuation: ")" [47:22 - 47:23] CXXConstructor=StringRef:47:3 (Definition)
+// CHECK-tokens: Punctuation: "," [47:23 - 47:24] CXXConstructor=StringRef:47:3 (Definition)
+// CHECK-tokens: Identifier: "Length" [47:25 - 47:31] MemberRef=Length:44:10
+// CHECK-tokens: Punctuation: "(" [47:31 - 47:32] CXXConstructor=StringRef:47:3 (Definition)
+// CHECK-tokens: Literal: "0" [47:32 - 47:33] IntegerLiteral=
+// CHECK-tokens: Punctuation: ")" [47:33 - 47:34] CXXConstructor=StringRef:47:3 (Definition)
+// CHECK-tokens: Punctuation: "{" [47:35 - 47:36] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [47:36 - 47:37] CompoundStmt=
+// CHECK-tokens: Identifier: "StringRef" [48:3 - 48:12] CXXConstructor=StringRef:48:3 (Definition)
+// CHECK-tokens: Punctuation: "(" [48:12 - 48:13] CXXConstructor=StringRef:48:3 (Definition)
+// CHECK-tokens: Keyword: "const" [48:13 - 48:18] CXXConstructor=StringRef:48:3 (Definition)
+// CHECK-tokens: Keyword: "char" [48:19 - 48:23] ParmDecl=Str:48:25 (Definition)
+// CHECK-tokens: Punctuation: "*" [48:24 - 48:25] ParmDecl=Str:48:25 (Definition)
+// CHECK-tokens: Identifier: "Str" [48:25 - 48:28] ParmDecl=Str:48:25 (Definition)
+// CHECK-tokens: Punctuation: ")" [48:28 - 48:29] CXXConstructor=StringRef:48:3 (Definition)
+// CHECK-tokens: Punctuation: ":" [48:30 - 48:31] CXXConstructor=StringRef:48:3 (Definition)
+// CHECK-tokens: Identifier: "Data" [48:32 - 48:36] MemberRef=Data:43:15
+// CHECK-tokens: Punctuation: "(" [48:36 - 48:37] CXXConstructor=StringRef:48:3 (Definition)
+// CHECK-tokens: Identifier: "Str" [48:37 - 48:40] DeclRefExpr=Str:48:25
+// CHECK-tokens: Punctuation: ")" [48:40 - 48:41] CXXConstructor=StringRef:48:3 (Definition)
+// CHECK-tokens: Punctuation: "," [48:41 - 48:42] CXXConstructor=StringRef:48:3 (Definition)
+// CHECK-tokens: Identifier: "Length" [48:43 - 48:49] MemberRef=Length:44:10
+// CHECK-tokens: Punctuation: "(" [48:49 - 48:50] CXXConstructor=StringRef:48:3 (Definition)
+// CHECK-tokens: Identifier: "magic_length" [48:50 - 48:62] DeclRefExpr=magic_length:36:8
+// CHECK-tokens: Punctuation: "(" [48:62 - 48:63] CallExpr=magic_length:36:8
+// CHECK-tokens: Identifier: "Str" [48:63 - 48:66] DeclRefExpr=Str:48:25
+// CHECK-tokens: Punctuation: ")" [48:66 - 48:67] CallExpr=magic_length:36:8
+// CHECK-tokens: Punctuation: ")" [48:67 - 48:68] CXXConstructor=StringRef:48:3 (Definition)
+// CHECK-tokens: Punctuation: "{" [48:69 - 48:70] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [48:70 - 48:71] CompoundStmt=
+// CHECK-tokens: Identifier: "StringRef" [49:3 - 49:12] CXXConstructor=StringRef:49:3 (Definition)
+// CHECK-tokens: Punctuation: "(" [49:12 - 49:13] CXXConstructor=StringRef:49:3 (Definition)
+// CHECK-tokens: Keyword: "const" [49:13 - 49:18] CXXConstructor=StringRef:49:3 (Definition)
+// CHECK-tokens: Keyword: "char" [49:19 - 49:23] ParmDecl=data:49:25 (Definition)
+// CHECK-tokens: Punctuation: "*" [49:24 - 49:25] ParmDecl=data:49:25 (Definition)
+// CHECK-tokens: Identifier: "data" [49:25 - 49:29] ParmDecl=data:49:25 (Definition)
+// CHECK-tokens: Punctuation: "," [49:29 - 49:30] CXXConstructor=StringRef:49:3 (Definition)
+// CHECK-tokens: Identifier: "size_t" [49:31 - 49:37] TypeRef=size_t:2:25
+// CHECK-tokens: Identifier: "length" [49:38 - 49:44] ParmDecl=length:49:38 (Definition)
+// CHECK-tokens: Punctuation: ")" [49:44 - 49:45] CXXConstructor=StringRef:49:3 (Definition)
+// CHECK-tokens: Punctuation: ":" [49:46 - 49:47] CXXConstructor=StringRef:49:3 (Definition)
+// CHECK-tokens: Identifier: "Data" [49:48 - 49:52] MemberRef=Data:43:15
+// CHECK-tokens: Punctuation: "(" [49:52 - 49:53] CXXConstructor=StringRef:49:3 (Definition)
+// CHECK-tokens: Identifier: "data" [49:53 - 49:57] DeclRefExpr=data:49:25
+// CHECK-tokens: Punctuation: ")" [49:57 - 49:58] CXXConstructor=StringRef:49:3 (Definition)
+// CHECK-tokens: Punctuation: "," [49:58 - 49:59] CXXConstructor=StringRef:49:3 (Definition)
+// CHECK-tokens: Identifier: "Length" [49:60 - 49:66] MemberRef=Length:44:10
+// CHECK-tokens: Punctuation: "(" [49:66 - 49:67] CXXConstructor=StringRef:49:3 (Definition)
+// CHECK-tokens: Identifier: "length" [49:67 - 49:73] DeclRefExpr=length:49:38
+// CHECK-tokens: Punctuation: ")" [49:73 - 49:74] CXXConstructor=StringRef:49:3 (Definition)
+// CHECK-tokens: Punctuation: "{" [49:75 - 49:76] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [49:76 - 49:77] CompoundStmt=
+// CHECK-tokens: Identifier: "iterator" [50:3 - 50:11] TypeRef=iterator:40:23
+// CHECK-tokens: Identifier: "end" [50:12 - 50:15] CXXMethod=end:50:12 (Definition)
+// CHECK-tokens: Punctuation: "(" [50:15 - 50:16] CXXMethod=end:50:12 (Definition)
+// CHECK-tokens: Punctuation: ")" [50:16 - 50:17] CXXMethod=end:50:12 (Definition)
+// CHECK-tokens: Keyword: "const" [50:18 - 50:23] CXXMethod=end:50:12 (Definition)
+// CHECK-tokens: Punctuation: "{" [50:24 - 50:25] CompoundStmt=
+// CHECK-tokens: Keyword: "return" [50:26 - 50:32] ReturnStmt=
+// CHECK-tokens: Identifier: "Data" [50:33 - 50:37] MemberRefExpr=Data:43:15
+// CHECK-tokens: Punctuation: ";" [50:37 - 50:38] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [50:39 - 50:40] CompoundStmt=
+// CHECK-tokens: Identifier: "size_t" [51:3 - 51:9] TypeRef=size_t:2:25
+// CHECK-tokens: Identifier: "size" [51:10 - 51:14] CXXMethod=size:51:10 (Definition)
+// CHECK-tokens: Punctuation: "(" [51:14 - 51:15] CXXMethod=size:51:10 (Definition)
+// CHECK-tokens: Punctuation: ")" [51:15 - 51:16] CXXMethod=size:51:10 (Definition)
+// CHECK-tokens: Keyword: "const" [51:17 - 51:22] CXXMethod=size:51:10 (Definition)
+// CHECK-tokens: Punctuation: "{" [51:23 - 51:24] CompoundStmt=
+// CHECK-tokens: Keyword: "return" [51:25 - 51:31] ReturnStmt=
+// CHECK-tokens: Identifier: "Length" [51:32 - 51:38] MemberRefExpr=Length:44:10
+// CHECK-tokens: Punctuation: ";" [51:38 - 51:39] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [51:40 - 51:41] CompoundStmt=
+// CHECK-tokens: Keyword: "bool" [52:3 - 52:7] CXXMethod=startswith:52:8 (Definition)
+// CHECK-tokens: Identifier: "startswith" [52:8 - 52:18] CXXMethod=startswith:52:8 (Definition)
+// CHECK-tokens: Punctuation: "(" [52:18 - 52:19] CXXMethod=startswith:52:8 (Definition)
+// CHECK-tokens: Identifier: "StringRef" [52:19 - 52:28] TypeRef=class llvm::StringRef:38:7
+// CHECK-tokens: Identifier: "Prefix" [52:29 - 52:35] ParmDecl=Prefix:52:29 (Definition)
+// CHECK-tokens: Punctuation: ")" [52:35 - 52:36] CXXMethod=startswith:52:8 (Definition)
+// CHECK-tokens: Keyword: "const" [52:37 - 52:42] CXXMethod=startswith:52:8 (Definition)
+// CHECK-tokens: Punctuation: "{" [52:43 - 52:44] CompoundStmt=
+// CHECK-tokens: Keyword: "return" [53:5 - 53:11] ReturnStmt=
+// CHECK-tokens: Identifier: "Length" [53:12 - 53:18] MemberRefExpr=Length:44:10
+// CHECK-tokens: Punctuation: ">=" [53:19 - 53:21] BinaryOperator=
+// CHECK-tokens: Identifier: "Prefix" [53:22 - 53:28] DeclRefExpr=Prefix:52:29
+// CHECK-tokens: Punctuation: "." [53:28 - 53:29] MemberRefExpr=Length:44:10
+// CHECK-tokens: Identifier: "Length" [53:29 - 53:35] MemberRefExpr=Length:44:10
+// CHECK-tokens: Punctuation: "&&" [53:36 - 53:38] BinaryOperator=
+// CHECK-tokens: Identifier: "memcmp" [54:11 - 54:17] DeclRefExpr=memcmp:7:7
+// CHECK-tokens: Punctuation: "(" [54:17 - 54:18] CallExpr=memcmp:7:7
+// CHECK-tokens: Identifier: "Data" [54:18 - 54:22] MemberRefExpr=Data:43:15
+// CHECK-tokens: Punctuation: "," [54:22 - 54:23] CallExpr=memcmp:7:7
+// CHECK-tokens: Identifier: "Prefix" [54:24 - 54:30] DeclRefExpr=Prefix:52:29
+// CHECK-tokens: Punctuation: "." [54:30 - 54:31] MemberRefExpr=Data:43:15
+// CHECK-tokens: Identifier: "Data" [54:31 - 54:35] MemberRefExpr=Data:43:15
+// CHECK-tokens: Punctuation: "," [54:35 - 54:36] CallExpr=memcmp:7:7
+// CHECK-tokens: Identifier: "Prefix" [54:37 - 54:43] DeclRefExpr=Prefix:52:29
+// CHECK-tokens: Punctuation: "." [54:43 - 54:44] MemberRefExpr=Length:44:10
+// CHECK-tokens: Identifier: "Length" [54:44 - 54:50] MemberRefExpr=Length:44:10
+// CHECK-tokens: Punctuation: ")" [54:50 - 54:51] CallExpr=memcmp:7:7
+// CHECK-tokens: Punctuation: "==" [54:52 - 54:54] BinaryOperator=
+// CHECK-tokens: Literal: "0" [54:55 - 54:56] IntegerLiteral=
+// CHECK-tokens: Punctuation: ";" [54:56 - 54:57] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [55:3 - 55:4] CompoundStmt=
+// CHECK-tokens: Keyword: "bool" [56:3 - 56:7] CXXMethod=endswith:56:8 (Definition)
+// CHECK-tokens: Identifier: "endswith" [56:8 - 56:16] CXXMethod=endswith:56:8 (Definition)
+// CHECK-tokens: Punctuation: "(" [56:16 - 56:17] CXXMethod=endswith:56:8 (Definition)
+// CHECK-tokens: Identifier: "StringRef" [56:17 - 56:26] TypeRef=class llvm::StringRef:38:7
+// CHECK-tokens: Identifier: "Suffix" [56:27 - 56:33] ParmDecl=Suffix:56:27 (Definition)
+// CHECK-tokens: Punctuation: ")" [56:33 - 56:34] CXXMethod=endswith:56:8 (Definition)
+// CHECK-tokens: Keyword: "const" [56:35 - 56:40] CXXMethod=endswith:56:8 (Definition)
+// CHECK-tokens: Punctuation: "{" [56:41 - 56:42] CompoundStmt=
+// CHECK-tokens: Keyword: "return" [57:5 - 57:11] ReturnStmt=
+// CHECK-tokens: Identifier: "Length" [57:12 - 57:18] MemberRefExpr=Length:44:10
+// CHECK-tokens: Punctuation: ">=" [57:19 - 57:21] BinaryOperator=
+// CHECK-tokens: Identifier: "Suffix" [57:22 - 57:28] DeclRefExpr=Suffix:56:27
+// CHECK-tokens: Punctuation: "." [57:28 - 57:29] MemberRefExpr=Length:44:10
+// CHECK-tokens: Identifier: "Length" [57:29 - 57:35] MemberRefExpr=Length:44:10
+// CHECK-tokens: Punctuation: "&&" [57:36 - 57:38] BinaryOperator=
+// CHECK-tokens: Identifier: "memcmp" [58:7 - 58:13] DeclRefExpr=memcmp:7:7
+// CHECK-tokens: Punctuation: "(" [58:13 - 58:14] CallExpr=memcmp:7:7
+// CHECK-tokens: Identifier: "end" [58:14 - 58:17] MemberRefExpr=end:50:12
+// CHECK-tokens: Punctuation: "(" [58:17 - 58:18] CallExpr=end:50:12
+// CHECK-tokens: Punctuation: ")" [58:18 - 58:19] CallExpr=end:50:12
+// CHECK-tokens: Punctuation: "-" [58:20 - 58:21] BinaryOperator=
+// CHECK-tokens: Identifier: "Suffix" [58:22 - 58:28] DeclRefExpr=Suffix:56:27
+// CHECK-tokens: Punctuation: "." [58:28 - 58:29] MemberRefExpr=Length:44:10
+// CHECK-tokens: Identifier: "Length" [58:29 - 58:35] MemberRefExpr=Length:44:10
+// CHECK-tokens: Punctuation: "," [58:35 - 58:36] CallExpr=memcmp:7:7
+// CHECK-tokens: Identifier: "Suffix" [58:37 - 58:43] DeclRefExpr=Suffix:56:27
+// CHECK-tokens: Punctuation: "." [58:43 - 58:44] MemberRefExpr=Data:43:15
+// CHECK-tokens: Identifier: "Data" [58:44 - 58:48] MemberRefExpr=Data:43:15
+// CHECK-tokens: Punctuation: "," [58:48 - 58:49] CallExpr=memcmp:7:7
+// CHECK-tokens: Identifier: "Suffix" [58:50 - 58:56] DeclRefExpr=Suffix:56:27
+// CHECK-tokens: Punctuation: "." [58:56 - 58:57] MemberRefExpr=Length:44:10
+// CHECK-tokens: Identifier: "Length" [58:57 - 58:63] MemberRefExpr=Length:44:10
+// CHECK-tokens: Punctuation: ")" [58:63 - 58:64] CallExpr=memcmp:7:7
+// CHECK-tokens: Punctuation: "==" [58:65 - 58:67] BinaryOperator=
+// CHECK-tokens: Literal: "0" [58:68 - 58:69] IntegerLiteral=
+// CHECK-tokens: Punctuation: ";" [58:69 - 58:70] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [59:3 - 59:4] CompoundStmt=
+// CHECK-tokens: Identifier: "StringRef" [60:3 - 60:12] TypeRef=class llvm::StringRef:38:7
+// CHECK-tokens: Identifier: "substr" [60:13 - 60:19] CXXMethod=substr:60:13 (Definition)
+// CHECK-tokens: Punctuation: "(" [60:19 - 60:20] CXXMethod=substr:60:13 (Definition)
+// CHECK-tokens: Identifier: "size_t" [60:20 - 60:26] TypeRef=size_t:2:25
+// CHECK-tokens: Identifier: "Start" [60:27 - 60:32] ParmDecl=Start:60:27 (Definition)
+// CHECK-tokens: Punctuation: "," [60:32 - 60:33] CXXMethod=substr:60:13 (Definition)
+// CHECK-tokens: Identifier: "size_t" [60:34 - 60:40] TypeRef=size_t:2:25
+// CHECK-tokens: Identifier: "N" [60:41 - 60:42] ParmDecl=N:60:41 (Definition)
+// CHECK-tokens: Punctuation: "=" [60:43 - 60:44] ParmDecl=N:60:41 (Definition)
+// CHECK-tokens: Identifier: "npos" [60:45 - 60:49] DeclRefExpr=npos:41:23
+// CHECK-tokens: Punctuation: ")" [60:49 - 60:50] CXXMethod=substr:60:13 (Definition)
+// CHECK-tokens: Keyword: "const" [60:51 - 60:56] CXXMethod=substr:60:13 (Definition)
+// CHECK-tokens: Punctuation: "{" [60:57 - 60:58] CompoundStmt=
+// CHECK-tokens: Keyword: "return" [61:5 - 61:11] ReturnStmt=
+// CHECK-tokens: Identifier: "StringRef" [61:12 - 61:21] TypeRef=class llvm::StringRef:38:7
+// CHECK-tokens: Punctuation: "(" [61:21 - 61:22] CallExpr=StringRef:49:3
+// CHECK-tokens: Identifier: "Data" [61:22 - 61:26] MemberRefExpr=Data:43:15
+// CHECK-tokens: Punctuation: "+" [61:27 - 61:28] BinaryOperator=
+// CHECK-tokens: Identifier: "Start" [61:29 - 61:34] DeclRefExpr=Start:60:27
+// CHECK-tokens: Punctuation: "," [61:34 - 61:35] CallExpr=StringRef:49:3
+// CHECK-tokens: Identifier: "min" [61:36 - 61:39] DeclRefExpr=min:45:17
+// CHECK-tokens: Punctuation: "(" [61:39 - 61:40] CallExpr=min:45:17
+// CHECK-tokens: Identifier: "N" [61:40 - 61:41] DeclRefExpr=N:60:41
+// CHECK-tokens: Punctuation: "," [61:41 - 61:42] CallExpr=min:45:17
+// CHECK-tokens: Identifier: "Length" [61:43 - 61:49] MemberRefExpr=Length:44:10
+// CHECK-tokens: Punctuation: "-" [61:50 - 61:51] BinaryOperator=
+// CHECK-tokens: Identifier: "Start" [61:52 - 61:57] DeclRefExpr=Start:60:27
+// CHECK-tokens: Punctuation: ")" [61:57 - 61:58] CallExpr=min:45:17
+// CHECK-tokens: Punctuation: ")" [61:58 - 61:59] CallExpr=StringRef:49:3
+// CHECK-tokens: Punctuation: ";" [61:59 - 61:60] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [62:3 - 62:4] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [63:1 - 63:2] ClassDecl=StringRef:38:7 (Definition)
+// CHECK-tokens: Punctuation: ";" [63:2 - 63:3] Namespace=llvm:37:11 (Definition)
+// CHECK-tokens: Punctuation: "}" [64:1 - 64:2] Namespace=llvm:37:11 (Definition)
+// CHECK-tokens: Keyword: "namespace" [65:1 - 65:10]
+// CHECK-tokens: Identifier: "clang" [65:11 - 65:16] Namespace=clang:65:11 (Definition)
+// CHECK-tokens: Punctuation: "{" [65:17 - 65:18] Namespace=clang:65:11 (Definition)
+// CHECK-tokens: Keyword: "class" [66:1 - 66:6] ClassDecl=IdentifierInfo:66:7 (Definition)
+// CHECK-tokens: Identifier: "IdentifierInfo" [66:7 - 66:21] ClassDecl=IdentifierInfo:66:7 (Definition)
+// CHECK-tokens: Punctuation: "{" [66:22 - 66:23] ClassDecl=IdentifierInfo:66:7 (Definition)
+// CHECK-tokens: Keyword: "public" [67:1 - 67:7] CXXAccessSpecifier=:67:1 (Definition)
+// CHECK-tokens: Punctuation: ":" [67:7 - 67:8] CXXAccessSpecifier=:67:1 (Definition)
+// CHECK-tokens: Identifier: "IdentifierInfo" [67:8 - 67:22] CXXConstructor=IdentifierInfo:67:8
+// CHECK-tokens: Punctuation: "(" [67:22 - 67:23] CXXConstructor=IdentifierInfo:67:8
+// CHECK-tokens: Punctuation: ")" [67:23 - 67:24] CXXConstructor=IdentifierInfo:67:8
+// CHECK-tokens: Punctuation: ";" [67:24 - 67:25] ClassDecl=IdentifierInfo:66:7 (Definition)
+// CHECK-tokens: Keyword: "const" [68:3 - 68:8] ClassDecl=IdentifierInfo:66:7 (Definition)
+// CHECK-tokens: Keyword: "char" [68:9 - 68:13] CXXMethod=getNameStart:68:15 (Definition)
+// CHECK-tokens: Punctuation: "*" [68:14 - 68:15] CXXMethod=getNameStart:68:15 (Definition)
+// CHECK-tokens: Identifier: "getNameStart" [68:15 - 68:27] CXXMethod=getNameStart:68:15 (Definition)
+// CHECK-tokens: Punctuation: "(" [68:27 - 68:28] CXXMethod=getNameStart:68:15 (Definition)
+// CHECK-tokens: Punctuation: ")" [68:28 - 68:29] CXXMethod=getNameStart:68:15 (Definition)
+// CHECK-tokens: Keyword: "const" [68:30 - 68:35] CXXMethod=getNameStart:68:15 (Definition)
+// CHECK-tokens: Punctuation: "{" [68:36 - 68:37] CompoundStmt=
+// CHECK-tokens: Keyword: "typedef" [69:5 - 69:12] DeclStmt=
+// CHECK-tokens: Identifier: "std" [69:13 - 69:16] NamespaceRef=std:3:11
+// CHECK-tokens: Punctuation: "::" [69:16 - 69:18] TypedefDecl=actualtype:69:54 (Definition)
+// CHECK-tokens: Identifier: "pair" [69:18 - 69:22] TemplateRef=pair:4:44
+// CHECK-tokens: Punctuation: "<" [69:23 - 69:24] TypedefDecl=actualtype:69:54 (Definition)
+// CHECK-tokens: Identifier: "IdentifierInfo" [69:25 - 69:39] TypeRef=class clang::IdentifierInfo:66:7
+// CHECK-tokens: Punctuation: "," [69:39 - 69:40] TypedefDecl=actualtype:69:54 (Definition)
+// CHECK-tokens: Keyword: "const" [69:41 - 69:46] TypedefDecl=actualtype:69:54 (Definition)
+// CHECK-tokens: Keyword: "char" [69:47 - 69:51] TypedefDecl=actualtype:69:54 (Definition)
+// CHECK-tokens: Punctuation: "*" [69:52 - 69:53] TypedefDecl=actualtype:69:54 (Definition)
+// CHECK-tokens: Punctuation: ">" [69:53 - 69:54] TypedefDecl=actualtype:69:54 (Definition)
+// CHECK-tokens: Identifier: "actualtype" [69:54 - 69:64] TypedefDecl=actualtype:69:54 (Definition)
+// CHECK-tokens: Punctuation: ";" [69:64 - 69:65] DeclStmt=
+// CHECK-tokens: Keyword: "return" [70:5 - 70:11] ReturnStmt=
+// CHECK-tokens: Punctuation: "(" [70:12 - 70:13] ParenExpr=
+// CHECK-tokens: Punctuation: "(" [70:13 - 70:14] CStyleCastExpr=
+// CHECK-tokens: Keyword: "const" [70:14 - 70:19] CStyleCastExpr=
+// CHECK-tokens: Identifier: "actualtype" [70:20 - 70:30] TypeRef=actualtype:69:54
+// CHECK-tokens: Punctuation: "*" [70:31 - 70:32] CStyleCastExpr=
+// CHECK-tokens: Punctuation: ")" [70:32 - 70:33] CStyleCastExpr=
+// CHECK-tokens: Keyword: "this" [70:34 - 70:38] CXXThisExpr=
+// CHECK-tokens: Punctuation: ")" [70:38 - 70:39] ParenExpr=
+// CHECK-tokens: Punctuation: "->" [70:39 - 70:41] MemberRefExpr=second:4:55
+// CHECK-tokens: Identifier: "second" [70:41 - 70:47] MemberRefExpr=second:4:55
+// CHECK-tokens: Punctuation: ";" [70:47 - 70:48] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [71:3 - 71:4] CompoundStmt=
+// CHECK-tokens: Keyword: "unsigned" [72:3 - 72:11] CXXMethod=getLength:72:12 (Definition)
+// CHECK-tokens: Identifier: "getLength" [72:12 - 72:21] CXXMethod=getLength:72:12 (Definition)
+// CHECK-tokens: Punctuation: "(" [72:21 - 72:22] CXXMethod=getLength:72:12 (Definition)
+// CHECK-tokens: Punctuation: ")" [72:22 - 72:23] CXXMethod=getLength:72:12 (Definition)
+// CHECK-tokens: Keyword: "const" [72:24 - 72:29] CXXMethod=getLength:72:12 (Definition)
+// CHECK-tokens: Punctuation: "{" [72:30 - 72:31] CompoundStmt=
+// CHECK-tokens: Keyword: "typedef" [73:5 - 73:12] DeclStmt=
+// CHECK-tokens: Identifier: "std" [73:13 - 73:16] NamespaceRef=std:3:11
+// CHECK-tokens: Punctuation: "::" [73:16 - 73:18] TypedefDecl=actualtype:73:54 (Definition)
+// CHECK-tokens: Identifier: "pair" [73:18 - 73:22] TemplateRef=pair:4:44
+// CHECK-tokens: Punctuation: "<" [73:23 - 73:24] TypedefDecl=actualtype:73:54 (Definition)
+// CHECK-tokens: Identifier: "IdentifierInfo" [73:25 - 73:39] TypeRef=class clang::IdentifierInfo:66:7
+// CHECK-tokens: Punctuation: "," [73:39 - 73:40] TypedefDecl=actualtype:73:54 (Definition)
+// CHECK-tokens: Keyword: "const" [73:41 - 73:46] TypedefDecl=actualtype:73:54 (Definition)
+// CHECK-tokens: Keyword: "char" [73:47 - 73:51] TypedefDecl=actualtype:73:54 (Definition)
+// CHECK-tokens: Punctuation: "*" [73:52 - 73:53] TypedefDecl=actualtype:73:54 (Definition)
+// CHECK-tokens: Punctuation: ">" [73:53 - 73:54] TypedefDecl=actualtype:73:54 (Definition)
+// CHECK-tokens: Identifier: "actualtype" [73:54 - 73:64] TypedefDecl=actualtype:73:54 (Definition)
+// CHECK-tokens: Punctuation: ";" [73:64 - 73:65] DeclStmt=
+// CHECK-tokens: Keyword: "const" [74:5 - 74:10] DeclStmt=
+// CHECK-tokens: Keyword: "char" [74:11 - 74:15] VarDecl=p:74:17 (Definition)
+// CHECK-tokens: Punctuation: "*" [74:16 - 74:17] VarDecl=p:74:17 (Definition)
+// CHECK-tokens: Identifier: "p" [74:17 - 74:18] VarDecl=p:74:17 (Definition)
+// CHECK-tokens: Punctuation: "=" [74:19 - 74:20] VarDecl=p:74:17 (Definition)
+// CHECK-tokens: Punctuation: "(" [74:21 - 74:22] ParenExpr=
+// CHECK-tokens: Punctuation: "(" [74:22 - 74:23] CStyleCastExpr=
+// CHECK-tokens: Keyword: "const" [74:23 - 74:28] CStyleCastExpr=
+// CHECK-tokens: Identifier: "actualtype" [74:29 - 74:39] TypeRef=actualtype:73:54
+// CHECK-tokens: Punctuation: "*" [74:40 - 74:41] CStyleCastExpr=
+// CHECK-tokens: Punctuation: ")" [74:41 - 74:42] CStyleCastExpr=
+// CHECK-tokens: Keyword: "this" [74:43 - 74:47] CXXThisExpr=
+// CHECK-tokens: Punctuation: ")" [74:47 - 74:48] ParenExpr=
+// CHECK-tokens: Punctuation: "->" [74:48 - 74:50] MemberRefExpr=second:4:55
+// CHECK-tokens: Identifier: "second" [74:50 - 74:56] MemberRefExpr=second:4:55
+// CHECK-tokens: Punctuation: "-" [74:57 - 74:58] BinaryOperator=
+// CHECK-tokens: Literal: "2" [74:59 - 74:60] IntegerLiteral=
+// CHECK-tokens: Punctuation: ";" [74:60 - 74:61] DeclStmt=
+// CHECK-tokens: Keyword: "return" [75:5 - 75:11] ReturnStmt=
+// CHECK-tokens: Punctuation: "(" [75:12 - 75:13] ParenExpr=
+// CHECK-tokens: Punctuation: "(" [75:13 - 75:14] ParenExpr=
+// CHECK-tokens: Punctuation: "(" [75:14 - 75:15] CStyleCastExpr=
+// CHECK-tokens: Keyword: "unsigned" [75:15 - 75:23] CStyleCastExpr=
+// CHECK-tokens: Punctuation: ")" [75:23 - 75:24] CStyleCastExpr=
+// CHECK-tokens: Identifier: "p" [75:25 - 75:26] DeclRefExpr=p:74:17
+// CHECK-tokens: Punctuation: "[" [75:26 - 75:27] ArraySubscriptExpr=
+// CHECK-tokens: Literal: "0" [75:27 - 75:28] IntegerLiteral=
+// CHECK-tokens: Punctuation: "]" [75:28 - 75:29] ArraySubscriptExpr=
+// CHECK-tokens: Punctuation: ")" [75:29 - 75:30] ParenExpr=
+// CHECK-tokens: Punctuation: "|" [75:31 - 75:32] BinaryOperator=
+// CHECK-tokens: Punctuation: "(" [75:33 - 75:34] ParenExpr=
+// CHECK-tokens: Punctuation: "(" [75:34 - 75:35] ParenExpr=
+// CHECK-tokens: Punctuation: "(" [75:35 - 75:36] CStyleCastExpr=
+// CHECK-tokens: Keyword: "unsigned" [75:36 - 75:44] CStyleCastExpr=
+// CHECK-tokens: Punctuation: ")" [75:44 - 75:45] CStyleCastExpr=
+// CHECK-tokens: Identifier: "p" [75:46 - 75:47] DeclRefExpr=p:74:17
+// CHECK-tokens: Punctuation: "[" [75:47 - 75:48] ArraySubscriptExpr=
+// CHECK-tokens: Literal: "1" [75:48 - 75:49] IntegerLiteral=
+// CHECK-tokens: Punctuation: "]" [75:49 - 75:50] ArraySubscriptExpr=
+// CHECK-tokens: Punctuation: ")" [75:50 - 75:51] ParenExpr=
+// CHECK-tokens: Punctuation: "<<" [75:52 - 75:54] BinaryOperator=
+// CHECK-tokens: Literal: "8" [75:55 - 75:56] IntegerLiteral=
+// CHECK-tokens: Punctuation: ")" [75:56 - 75:57] ParenExpr=
+// CHECK-tokens: Punctuation: ")" [75:57 - 75:58] ParenExpr=
+// CHECK-tokens: Punctuation: "-" [75:59 - 75:60] BinaryOperator=
+// CHECK-tokens: Literal: "1" [75:61 - 75:62] IntegerLiteral=
+// CHECK-tokens: Punctuation: ";" [75:62 - 75:63] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [76:3 - 76:4] CompoundStmt=
+// CHECK-tokens: Identifier: "llvm" [77:3 - 77:7] NamespaceRef=llvm:37:11
+// CHECK-tokens: Punctuation: "::" [77:7 - 77:9] CXXMethod=getName:77:19 (Definition)
+// CHECK-tokens: Identifier: "StringRef" [77:9 - 77:18] TypeRef=class llvm::StringRef:38:7
+// CHECK-tokens: Identifier: "getName" [77:19 - 77:26] CXXMethod=getName:77:19 (Definition)
+// CHECK-tokens: Punctuation: "(" [77:26 - 77:27] CXXMethod=getName:77:19 (Definition)
+// CHECK-tokens: Punctuation: ")" [77:27 - 77:28] CXXMethod=getName:77:19 (Definition)
+// CHECK-tokens: Keyword: "const" [77:29 - 77:34] CXXMethod=getName:77:19 (Definition)
+// CHECK-tokens: Punctuation: "{" [77:35 - 77:36] CompoundStmt=
+// CHECK-tokens: Keyword: "return" [78:5 - 78:11] ReturnStmt=
+// CHECK-tokens: Identifier: "llvm" [78:12 - 78:16] NamespaceRef=llvm:37:11
+// CHECK-tokens: Punctuation: "::" [78:16 - 78:18] CallExpr=StringRef:49:3
+// CHECK-tokens: Identifier: "StringRef" [78:18 - 78:27] TypeRef=class llvm::StringRef:38:7
+// CHECK-tokens: Punctuation: "(" [78:27 - 78:28] CallExpr=StringRef:49:3
+// CHECK-tokens: Identifier: "getNameStart" [78:28 - 78:40] MemberRefExpr=getNameStart:68:15
+// CHECK-tokens: Punctuation: "(" [78:40 - 78:41] CallExpr=getNameStart:68:15
+// CHECK-tokens: Punctuation: ")" [78:41 - 78:42] CallExpr=getNameStart:68:15
+// CHECK-tokens: Punctuation: "," [78:42 - 78:43] CallExpr=StringRef:49:3
+// CHECK-tokens: Identifier: "getLength" [78:44 - 78:53] MemberRefExpr=getLength:72:12
+// CHECK-tokens: Punctuation: "(" [78:53 - 78:54] CallExpr=getLength:72:12
+// CHECK-tokens: Punctuation: ")" [78:54 - 78:55] CallExpr=getLength:72:12
+// CHECK-tokens: Punctuation: ")" [78:55 - 78:56] CallExpr=StringRef:49:3
+// CHECK-tokens: Punctuation: ";" [78:56 - 78:57] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [79:3 - 79:4] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [80:1 - 80:2] ClassDecl=IdentifierInfo:66:7 (Definition)
+// CHECK-tokens: Punctuation: ";" [80:2 - 80:3] Namespace=clang:65:11 (Definition)
+// CHECK-tokens: Punctuation: "}" [81:1 - 81:2] Namespace=clang:65:11 (Definition)
+// CHECK-tokens: Keyword: "namespace" [82:1 - 82:10]
+// CHECK-tokens: Identifier: "llvm" [82:11 - 82:15] Namespace=llvm:82:11 (Definition)
+// CHECK-tokens: Punctuation: "{" [82:16 - 82:17] Namespace=llvm:82:11 (Definition)
+// CHECK-tokens: Keyword: "template" [83:1 - 83:9] ClassTemplate=StringSwitch:83:47 (Definition)
+// CHECK-tokens: Punctuation: "<" [83:10 - 83:11] ClassTemplate=StringSwitch:83:47 (Definition)
+// CHECK-tokens: Keyword: "typename" [83:12 - 83:20] TemplateTypeParameter=T:83:21 (Definition)
+// CHECK-tokens: Identifier: "T" [83:21 - 83:22] TemplateTypeParameter=T:83:21 (Definition)
+// CHECK-tokens: Punctuation: "," [83:22 - 83:23] ClassTemplate=StringSwitch:83:47 (Definition)
+// CHECK-tokens: Keyword: "typename" [83:24 - 83:32] TemplateTypeParameter=R:83:33 (Definition)
+// CHECK-tokens: Identifier: "R" [83:33 - 83:34] TemplateTypeParameter=R:83:33 (Definition)
+// CHECK-tokens: Punctuation: "=" [83:35 - 83:36] TemplateTypeParameter=R:83:33 (Definition)
+// CHECK-tokens: Identifier: "T" [83:37 - 83:38] TypeRef=T:83:21
+// CHECK-tokens: Punctuation: ">" [83:39 - 83:40] ClassTemplate=StringSwitch:83:47 (Definition)
+// CHECK-tokens: Keyword: "class" [83:41 - 83:46] ClassTemplate=StringSwitch:83:47 (Definition)
+// CHECK-tokens: Identifier: "StringSwitch" [83:47 - 83:59] ClassTemplate=StringSwitch:83:47 (Definition)
+// CHECK-tokens: Punctuation: "{" [83:60 - 83:61] ClassTemplate=StringSwitch:83:47 (Definition)
+// CHECK-tokens: Identifier: "StringRef" [84:3 - 84:12] TypeRef=class llvm::StringRef:38:7
+// CHECK-tokens: Identifier: "Str" [84:13 - 84:16] FieldDecl=Str:84:13 (Definition)
+// CHECK-tokens: Punctuation: ";" [84:16 - 84:17] ClassTemplate=StringSwitch:83:47 (Definition)
+// CHECK-tokens: Keyword: "const" [85:3 - 85:8] ClassTemplate=StringSwitch:83:47 (Definition)
+// CHECK-tokens: Identifier: "T" [85:9 - 85:10] TypeRef=T:83:21
+// CHECK-tokens: Punctuation: "*" [85:11 - 85:12] FieldDecl=Result:85:12 (Definition)
+// CHECK-tokens: Identifier: "Result" [85:12 - 85:18] FieldDecl=Result:85:12 (Definition)
+// CHECK-tokens: Punctuation: ";" [85:18 - 85:19] ClassTemplate=StringSwitch:83:47 (Definition)
+// CHECK-tokens: Keyword: "public" [86:1 - 86:7] CXXAccessSpecifier=:86:1 (Definition)
+// CHECK-tokens: Punctuation: ":" [86:7 - 86:8] CXXAccessSpecifier=:86:1 (Definition)
+// CHECK-tokens: Keyword: "explicit" [87:3 - 87:11] CXXConstructor=StringSwitch<T, R>:87:12 (Definition)
+// CHECK-tokens: Identifier: "StringSwitch" [87:12 - 87:24] CXXConstructor=StringSwitch<T, R>:87:12 (Definition)
+// CHECK-tokens: Punctuation: "(" [87:24 - 87:25] CXXConstructor=StringSwitch<T, R>:87:12 (Definition)
+// CHECK-tokens: Identifier: "StringRef" [87:25 - 87:34] TypeRef=class llvm::StringRef:38:7
+// CHECK-tokens: Identifier: "Str" [87:35 - 87:38] ParmDecl=Str:87:35 (Definition)
+// CHECK-tokens: Punctuation: ")" [87:38 - 87:39] CXXConstructor=StringSwitch<T, R>:87:12 (Definition)
+// CHECK-tokens: Punctuation: ":" [87:40 - 87:41] CXXConstructor=StringSwitch<T, R>:87:12 (Definition)
+// CHECK-tokens: Identifier: "Str" [87:42 - 87:45] MemberRef=Str:84:13
+// CHECK-tokens: Punctuation: "(" [87:45 - 87:46] UnexposedExpr=
+// CHECK-tokens: Identifier: "Str" [87:46 - 87:49] DeclRefExpr=Str:87:35
+// CHECK-tokens: Punctuation: ")" [87:49 - 87:50] UnexposedExpr=
+// CHECK-tokens: Punctuation: "," [87:50 - 87:51] CXXConstructor=StringSwitch<T, R>:87:12 (Definition)
+// CHECK-tokens: Identifier: "Result" [87:52 - 87:58] MemberRef=Result:85:12
+// CHECK-tokens: Punctuation: "(" [87:58 - 87:59] UnexposedExpr=
+// CHECK-tokens: Literal: "0" [87:59 - 87:60] IntegerLiteral=
+// CHECK-tokens: Punctuation: ")" [87:60 - 87:61] UnexposedExpr=
+// CHECK-tokens: Punctuation: "{" [87:62 - 87:63] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [87:63 - 87:64] CompoundStmt=
+// CHECK-tokens: Keyword: "template" [88:3 - 88:11] FunctionTemplate=Case:88:42 (Definition)
+// CHECK-tokens: Punctuation: "<" [88:12 - 88:13] FunctionTemplate=Case:88:42 (Definition)
+// CHECK-tokens: Keyword: "unsigned" [88:14 - 88:22] NonTypeTemplateParameter=N:88:23 (Definition)
+// CHECK-tokens: Identifier: "N" [88:23 - 88:24] NonTypeTemplateParameter=N:88:23 (Definition)
+// CHECK-tokens: Punctuation: ">" [88:25 - 88:26] FunctionTemplate=Case:88:42 (Definition)
+// CHECK-tokens: Identifier: "StringSwitch" [88:27 - 88:39] TypeRef=StringSwitch<T, R>:83:47
+// CHECK-tokens: Punctuation: "&" [88:40 - 88:41] FunctionTemplate=Case:88:42 (Definition)
+// CHECK-tokens: Identifier: "Case" [88:42 - 88:46] FunctionTemplate=Case:88:42 (Definition)
+// CHECK-tokens: Punctuation: "(" [88:46 - 88:47] FunctionTemplate=Case:88:42 (Definition)
+// CHECK-tokens: Keyword: "const" [88:47 - 88:52] FunctionTemplate=Case:88:42 (Definition)
+// CHECK-tokens: Keyword: "char" [88:53 - 88:57] ParmDecl=S:88:60 (Definition)
+// CHECK-tokens: Punctuation: "(" [88:58 - 88:59] ParmDecl=S:88:60 (Definition)
+// CHECK-tokens: Punctuation: "&" [88:59 - 88:60] ParmDecl=S:88:60 (Definition)
+// CHECK-tokens: Identifier: "S" [88:60 - 88:61] ParmDecl=S:88:60 (Definition)
+// CHECK-tokens: Punctuation: ")" [88:61 - 88:62] ParmDecl=S:88:60 (Definition)
+// CHECK-tokens: Punctuation: "[" [88:62 - 88:63] ParmDecl=S:88:60 (Definition)
+// CHECK-tokens: Identifier: "N" [88:63 - 88:64] DeclRefExpr=N:88:23
+// CHECK-tokens: Punctuation: "]" [88:64 - 88:65] ParmDecl=S:88:60 (Definition)
+// CHECK-tokens: Punctuation: "," [88:65 - 88:66] FunctionTemplate=Case:88:42 (Definition)
+// CHECK-tokens: Keyword: "const" [89:47 - 89:52] FunctionTemplate=Case:88:42 (Definition)
+// CHECK-tokens: Identifier: "T" [89:53 - 89:54] TypeRef=T:83:21
+// CHECK-tokens: Punctuation: "&" [89:55 - 89:56] ParmDecl=Value:89:57 (Definition)
+// CHECK-tokens: Identifier: "Value" [89:57 - 89:62] ParmDecl=Value:89:57 (Definition)
+// CHECK-tokens: Punctuation: ")" [89:62 - 89:63] FunctionTemplate=Case:88:42 (Definition)
+// CHECK-tokens: Punctuation: "{" [89:64 - 89:65] CompoundStmt=
+// CHECK-tokens: Keyword: "return" [90:5 - 90:11] ReturnStmt=
+// CHECK-tokens: Punctuation: "*" [90:12 - 90:13] UnaryOperator=
+// CHECK-tokens: Keyword: "this" [90:13 - 90:17] CXXThisExpr=
+// CHECK-tokens: Punctuation: ";" [90:17 - 90:18] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [91:3 - 91:4] CompoundStmt=
+// CHECK-tokens: Identifier: "R" [92:3 - 92:4] TypeRef=R:83:33
+// CHECK-tokens: Identifier: "Default" [92:5 - 92:12] CXXMethod=Default:92:5 (Definition)
+// CHECK-tokens: Punctuation: "(" [92:12 - 92:13] CXXMethod=Default:92:5 (Definition)
+// CHECK-tokens: Keyword: "const" [92:13 - 92:18] CXXMethod=Default:92:5 (Definition)
+// CHECK-tokens: Identifier: "T" [92:19 - 92:20] TypeRef=T:83:21
+// CHECK-tokens: Punctuation: "&" [92:21 - 92:22] ParmDecl=Value:92:23 (Definition)
+// CHECK-tokens: Identifier: "Value" [92:23 - 92:28] ParmDecl=Value:92:23 (Definition)
+// CHECK-tokens: Punctuation: ")" [92:28 - 92:29] CXXMethod=Default:92:5 (Definition)
+// CHECK-tokens: Keyword: "const" [92:30 - 92:35] CXXMethod=Default:92:5 (Definition)
+// CHECK-tokens: Punctuation: "{" [92:36 - 92:37] CompoundStmt=
+// CHECK-tokens: Keyword: "return" [93:5 - 93:11] ReturnStmt=
+// CHECK-tokens: Identifier: "Value" [93:12 - 93:17] DeclRefExpr=Value:92:23
+// CHECK-tokens: Punctuation: ";" [93:17 - 93:18] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [94:3 - 94:4] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [95:1 - 95:2] ClassTemplate=StringSwitch:83:47 (Definition)
+// CHECK-tokens: Punctuation: ";" [95:2 - 95:3] Namespace=llvm:82:11 (Definition)
+// CHECK-tokens: Punctuation: "}" [96:1 - 96:2] Namespace=llvm:82:11 (Definition)
+// CHECK-tokens: Keyword: "using" [98:1 - 98:6] UsingDirective=:98:17
+// CHECK-tokens: Keyword: "namespace" [98:7 - 98:16] UsingDirective=:98:17
+// CHECK-tokens: Identifier: "clang" [98:17 - 98:22] NamespaceRef=clang:10:17
+// CHECK-tokens: Punctuation: ";" [98:22 - 98:23]
+// CHECK-tokens: Identifier: "AttributeList" [100:1 - 100:14] TypeRef=class clang::AttributeList:12:9
+// CHECK-tokens: Punctuation: "::" [100:14 - 100:16] CXXMethod=getKind:100:36 (Definition) (static)
+// CHECK-tokens: Identifier: "Kind" [100:16 - 100:20] TypeRef=enum clang::AttributeList::Kind:13:10
+// CHECK-tokens: Identifier: "AttributeList" [100:21 - 100:34] TypeRef=class clang::AttributeList:12:9
+// CHECK-tokens: Punctuation: "::" [100:34 - 100:36] CXXMethod=getKind:100:36 (Definition) (static)
+// CHECK-tokens: Identifier: "getKind" [100:36 - 100:43] CXXMethod=getKind:100:36 (Definition) (static)
+// CHECK-tokens: Punctuation: "(" [100:43 - 100:44] CXXMethod=getKind:100:36 (Definition) (static)
+// CHECK-tokens: Keyword: "const" [100:44 - 100:49] CXXMethod=getKind:100:36 (Definition) (static)
+// CHECK-tokens: Identifier: "IdentifierInfo" [100:50 - 100:64] TypeRef=class clang::IdentifierInfo:66:7
+// CHECK-tokens: Punctuation: "*" [100:65 - 100:66] ParmDecl=Name:100:67 (Definition)
+// CHECK-tokens: Identifier: "Name" [100:67 - 100:71] ParmDecl=Name:100:67 (Definition)
+// CHECK-tokens: Punctuation: ")" [100:71 - 100:72] CXXMethod=getKind:100:36 (Definition) (static)
+// CHECK-tokens: Punctuation: "{" [100:73 - 100:74] CompoundStmt=
+// CHECK-tokens: Identifier: "llvm" [101:3 - 101:7] NamespaceRef=llvm:82:11
+// CHECK-tokens: Punctuation: "::" [101:7 - 101:9] VarDecl=AttrName:101:19 (Definition)
+// CHECK-tokens: Identifier: "StringRef" [101:9 - 101:18] TypeRef=class llvm::StringRef:38:7
+// CHECK-tokens: Identifier: "AttrName" [101:19 - 101:27] VarDecl=AttrName:101:19 (Definition)
+// CHECK-tokens: Punctuation: "=" [101:28 - 101:29] VarDecl=AttrName:101:19 (Definition)
+// CHECK-tokens: Identifier: "Name" [101:30 - 101:34] DeclRefExpr=Name:100:67
+// CHECK-tokens: Punctuation: "->" [101:34 - 101:36] MemberRefExpr=getName:77:19
+// CHECK-tokens: Identifier: "getName" [101:36 - 101:43] MemberRefExpr=getName:77:19
+// CHECK-tokens: Punctuation: "(" [101:43 - 101:44] CallExpr=getName:77:19
+// CHECK-tokens: Punctuation: ")" [101:44 - 101:45] CallExpr=getName:77:19
+// CHECK-tokens: Punctuation: ";" [101:45 - 101:46] DeclStmt=
+// CHECK-tokens: Keyword: "if" [102:3 - 102:5] IfStmt=
+// CHECK-tokens: Punctuation: "(" [102:6 - 102:7] IfStmt=
+// CHECK-tokens: Identifier: "AttrName" [102:7 - 102:15] DeclRefExpr=AttrName:101:19
+// CHECK-tokens: Punctuation: "." [102:15 - 102:16] MemberRefExpr=startswith:52:8
+// CHECK-tokens: Identifier: "startswith" [102:16 - 102:26] MemberRefExpr=startswith:52:8
+// CHECK-tokens: Punctuation: "(" [102:26 - 102:27] CallExpr=startswith:52:8
+// CHECK-tokens: Literal: ""__"" [102:27 - 102:31] StringLiteral=
+// CHECK-tokens: Punctuation: ")" [102:31 - 102:32] CallExpr=startswith:52:8
+// CHECK-tokens: Punctuation: "&&" [102:33 - 102:35] BinaryOperator=
+// CHECK-tokens: Identifier: "AttrName" [102:36 - 102:44] DeclRefExpr=AttrName:101:19
+// CHECK-tokens: Punctuation: "." [102:44 - 102:45] MemberRefExpr=endswith:56:8
+// CHECK-tokens: Identifier: "endswith" [102:45 - 102:53] MemberRefExpr=endswith:56:8
+// CHECK-tokens: Punctuation: "(" [102:53 - 102:54] CallExpr=endswith:56:8
+// CHECK-tokens: Literal: ""__"" [102:54 - 102:58] StringLiteral=
+// CHECK-tokens: Punctuation: ")" [102:58 - 102:59] CallExpr=endswith:56:8
+// CHECK-tokens: Punctuation: ")" [102:59 - 102:60] IfStmt=
+// CHECK-tokens: Identifier: "AttrName" [103:5 - 103:13] DeclRefExpr=AttrName:101:19
+// CHECK-tokens: Punctuation: "=" [103:14 - 103:15] DeclRefExpr=operator=:38:7
+// CHECK-tokens: Identifier: "AttrName" [103:16 - 103:24] DeclRefExpr=AttrName:101:19
+// CHECK-tokens: Punctuation: "." [103:24 - 103:25] MemberRefExpr=substr:60:13
+// CHECK-tokens: Identifier: "substr" [103:25 - 103:31] MemberRefExpr=substr:60:13
+// CHECK-tokens: Punctuation: "(" [103:31 - 103:32] CallExpr=substr:60:13
+// CHECK-tokens: Literal: "2" [103:32 - 103:33] IntegerLiteral=
+// CHECK-tokens: Punctuation: "," [103:33 - 103:34] CallExpr=substr:60:13
+// CHECK-tokens: Identifier: "AttrName" [103:35 - 103:43] DeclRefExpr=AttrName:101:19
+// CHECK-tokens: Punctuation: "." [103:43 - 103:44] MemberRefExpr=size:51:10
+// CHECK-tokens: Identifier: "size" [103:44 - 103:48] MemberRefExpr=size:51:10
+// CHECK-tokens: Punctuation: "(" [103:48 - 103:49] CallExpr=size:51:10
+// CHECK-tokens: Punctuation: ")" [103:49 - 103:50] CallExpr=size:51:10
+// CHECK-tokens: Punctuation: "-" [103:51 - 103:52] BinaryOperator=
+// CHECK-tokens: Literal: "4" [103:53 - 103:54] IntegerLiteral=
+// CHECK-tokens: Punctuation: ")" [103:54 - 103:55] CallExpr=substr:60:13
+// CHECK-tokens: Punctuation: ";" [103:55 - 103:56] CompoundStmt=
+// CHECK-tokens: Keyword: "return" [105:3 - 105:9] ReturnStmt=
+// FIXME: Missing "llvm" namespace reference below
+// CHECK-tokens: Identifier: "llvm" [105:10 - 105:14] NamespaceRef=llvm:82:11
+// CHECK-tokens: Punctuation: "::" [105:14 - 105:16] CXXFunctionalCastExpr=
+// CHECK-tokens: Identifier: "StringSwitch" [105:16 - 105:28] TemplateRef=StringSwitch:83:47
+// CHECK-tokens: Punctuation: "<" [105:29 - 105:30] CXXFunctionalCastExpr=
+// CHECK-tokens: Identifier: "AttributeList" [105:31 - 105:44] TypeRef=class clang::AttributeList:12:9
+// CHECK-tokens: Punctuation: "::" [105:44 - 105:46] CXXFunctionalCastExpr=
+// CHECK-tokens: Identifier: "Kind" [105:46 - 105:50] TypeRef=enum clang::AttributeList::Kind:13:10
+// CHECK-tokens: Punctuation: ">" [105:51 - 105:52] CallExpr=StringSwitch:87:12
+// CHECK-tokens: Punctuation: "(" [105:53 - 105:54] CallExpr=StringSwitch:87:12
+// CHECK-tokens: Identifier: "AttrName" [105:54 - 105:62] DeclRefExpr=AttrName:101:19
+// CHECK-tokens: Punctuation: ")" [105:62 - 105:63] CXXFunctionalCastExpr=
+// CHECK-tokens: Punctuation: "." [106:5 - 106:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [106:6 - 106:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [106:10 - 106:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""weak"" [106:11 - 106:17] StringLiteral=
+// CHECK-tokens: Punctuation: "," [106:17 - 106:18] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_weak" [106:19 - 106:26] DeclRefExpr=AT_weak:29:45
+// CHECK-tokens: Punctuation: ")" [106:26 - 106:27] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [107:5 - 107:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [107:6 - 107:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [107:10 - 107:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""weakref"" [107:11 - 107:20] StringLiteral=
+// CHECK-tokens: Punctuation: "," [107:20 - 107:21] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_weakref" [107:22 - 107:32] DeclRefExpr=AT_weakref:29:54
+// CHECK-tokens: Punctuation: ")" [107:32 - 107:33] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [108:5 - 108:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [108:6 - 108:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [108:10 - 108:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""pure"" [108:11 - 108:17] StringLiteral=
+// CHECK-tokens: Punctuation: "," [108:17 - 108:18] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_pure" [108:19 - 108:26] DeclRefExpr=AT_pure:26:49
+// CHECK-tokens: Punctuation: ")" [108:26 - 108:27] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [109:5 - 109:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [109:6 - 109:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [109:10 - 109:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""mode"" [109:11 - 109:17] StringLiteral=
+// CHECK-tokens: Punctuation: "," [109:17 - 109:18] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_mode" [109:19 - 109:26] DeclRefExpr=AT_mode:20:44
+// CHECK-tokens: Punctuation: ")" [109:26 - 109:27] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [110:5 - 110:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [110:6 - 110:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [110:10 - 110:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""used"" [110:11 - 110:17] StringLiteral=
+// CHECK-tokens: Punctuation: "," [110:17 - 110:18] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_used" [110:19 - 110:26] DeclRefExpr=AT_used:28:34
+// CHECK-tokens: Punctuation: ")" [110:26 - 110:27] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [111:5 - 111:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [111:6 - 111:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [111:10 - 111:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""alias"" [111:11 - 111:18] StringLiteral=
+// CHECK-tokens: Punctuation: "," [111:18 - 111:19] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_alias" [111:20 - 111:28] DeclRefExpr=AT_alias:15:25
+// CHECK-tokens: Punctuation: ")" [111:28 - 111:29] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [112:5 - 112:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [112:6 - 112:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [112:10 - 112:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""align"" [112:11 - 112:18] StringLiteral=
+// CHECK-tokens: Punctuation: "," [112:18 - 112:19] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_aligned" [112:20 - 112:30] DeclRefExpr=AT_aligned:15:35
+// CHECK-tokens: Punctuation: ")" [112:30 - 112:31] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [113:5 - 113:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [113:6 - 113:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [113:10 - 113:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""final"" [113:11 - 113:18] StringLiteral=
+// CHECK-tokens: Punctuation: "," [113:18 - 113:19] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_final" [113:20 - 113:28] DeclRefExpr=AT_final:19:40
+// CHECK-tokens: Punctuation: ")" [113:28 - 113:29] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [114:5 - 114:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [114:6 - 114:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [114:10 - 114:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""cdecl"" [114:11 - 114:18] StringLiteral=
+// CHECK-tokens: Punctuation: "," [114:18 - 114:19] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_cdecl" [114:20 - 114:28] DeclRefExpr=AT_cdecl:17:30
+// CHECK-tokens: Punctuation: ")" [114:28 - 114:29] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [115:5 - 115:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [115:6 - 115:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [115:10 - 115:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""const"" [115:11 - 115:18] StringLiteral=
+// CHECK-tokens: Punctuation: "," [115:18 - 115:19] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_const" [115:20 - 115:28] DeclRefExpr=AT_const:17:52
+// CHECK-tokens: Punctuation: ")" [115:28 - 115:29] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [116:5 - 116:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [116:6 - 116:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [116:10 - 116:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""__const"" [116:11 - 116:20] StringLiteral=
+// CHECK-tokens: Punctuation: "," [116:20 - 116:21] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_const" [116:22 - 116:30] DeclRefExpr=AT_const:17:52
+// CHECK-tokens: Punctuation: ")" [116:30 - 116:31] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [117:5 - 117:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [117:6 - 117:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [117:10 - 117:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""blocks"" [117:11 - 117:19] StringLiteral=
+// CHECK-tokens: Punctuation: "," [117:19 - 117:20] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_blocks" [117:21 - 117:30] DeclRefExpr=AT_blocks:16:57
+// CHECK-tokens: Punctuation: ")" [117:30 - 117:31] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [118:5 - 118:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [118:6 - 118:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [118:10 - 118:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""format"" [118:11 - 118:19] StringLiteral=
+// CHECK-tokens: Punctuation: "," [118:19 - 118:20] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_format" [118:21 - 118:30] DeclRefExpr=AT_format:19:50
+// CHECK-tokens: Punctuation: ")" [118:30 - 118:31] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [119:5 - 119:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [119:6 - 119:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [119:10 - 119:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""hiding"" [119:11 - 119:19] StringLiteral=
+// CHECK-tokens: Punctuation: "," [119:19 - 119:20] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_hiding" [119:21 - 119:30] DeclRefExpr=AT_hiding:20:22
+// CHECK-tokens: Punctuation: ")" [119:30 - 119:31] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [120:5 - 120:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [120:6 - 120:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [120:10 - 120:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""malloc"" [120:11 - 120:19] StringLiteral=
+// CHECK-tokens: Punctuation: "," [120:19 - 120:20] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_malloc" [120:21 - 120:30] DeclRefExpr=AT_malloc:20:33
+// CHECK-tokens: Punctuation: ")" [120:30 - 120:31] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [121:5 - 121:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [121:6 - 121:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [121:10 - 121:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""packed"" [121:11 - 121:19] StringLiteral=
+// CHECK-tokens: Punctuation: "," [121:19 - 121:20] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_packed" [121:21 - 121:30] DeclRefExpr=AT_packed:26:27
+// CHECK-tokens: Punctuation: ")" [121:30 - 121:31] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [122:5 - 122:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [122:6 - 122:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [122:10 - 122:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""unused"" [122:11 - 122:19] StringLiteral=
+// CHECK-tokens: Punctuation: "," [122:19 - 122:20] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_unused" [122:21 - 122:30] DeclRefExpr=AT_unused:28:23
+// CHECK-tokens: Punctuation: ")" [122:30 - 122:31] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [123:5 - 123:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [123:6 - 123:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [123:10 - 123:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""aligned"" [123:11 - 123:20] StringLiteral=
+// CHECK-tokens: Punctuation: "," [123:20 - 123:21] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_aligned" [123:22 - 123:32] DeclRefExpr=AT_aligned:15:35
+// CHECK-tokens: Punctuation: ")" [123:32 - 123:33] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [124:5 - 124:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [124:6 - 124:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [124:10 - 124:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""cleanup"" [124:11 - 124:20] StringLiteral=
+// CHECK-tokens: Punctuation: "," [124:20 - 124:21] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_cleanup" [124:22 - 124:32] DeclRefExpr=AT_cleanup:17:40
+// CHECK-tokens: Punctuation: ")" [124:32 - 124:33] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [125:5 - 125:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [125:6 - 125:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [125:10 - 125:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""naked"" [125:11 - 125:18] StringLiteral=
+// CHECK-tokens: Punctuation: "," [125:18 - 125:19] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_naked" [125:20 - 125:28] DeclRefExpr=AT_naked:20:53
+// CHECK-tokens: Punctuation: ")" [125:28 - 125:29] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [126:5 - 126:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [126:6 - 126:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [126:10 - 126:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""nodebug"" [126:11 - 126:20] StringLiteral=
+// CHECK-tokens: Punctuation: "," [126:20 - 126:21] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_nodebug" [126:22 - 126:32] DeclRefExpr=AT_nodebug:20:63
+// CHECK-tokens: Punctuation: ")" [126:32 - 126:33] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [127:5 - 127:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [127:6 - 127:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [127:10 - 127:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""nonnull"" [127:11 - 127:20] StringLiteral=
+// CHECK-tokens: Punctuation: "," [127:20 - 127:21] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_nonnull" [127:22 - 127:32] DeclRefExpr=AT_nonnull:21:47
+// CHECK-tokens: Punctuation: ")" [127:32 - 127:33] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [128:5 - 128:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [128:6 - 128:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [128:10 - 128:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""nothrow"" [128:11 - 128:20] StringLiteral=
+// CHECK-tokens: Punctuation: "," [128:20 - 128:21] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_nothrow" [128:22 - 128:32] DeclRefExpr=AT_nothrow:22:7
+// CHECK-tokens: Punctuation: ")" [128:32 - 128:33] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [129:5 - 129:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [129:6 - 129:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [129:10 - 129:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""objc_gc"" [129:11 - 129:20] StringLiteral=
+// CHECK-tokens: Punctuation: "," [129:20 - 129:21] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_objc_gc" [129:22 - 129:32] DeclRefExpr=AT_objc_gc:24:59
+// CHECK-tokens: Punctuation: ")" [129:32 - 129:33] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [130:5 - 130:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [130:6 - 130:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [130:10 - 130:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""regparm"" [130:11 - 130:20] StringLiteral=
+// CHECK-tokens: Punctuation: "," [130:20 - 130:21] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_regparm" [130:22 - 130:32] DeclRefExpr=AT_regparm:26:58
+// CHECK-tokens: Punctuation: ")" [130:32 - 130:33] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [131:5 - 131:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [131:6 - 131:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [131:10 - 131:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""section"" [131:11 - 131:20] StringLiteral=
+// CHECK-tokens: Punctuation: "," [131:20 - 131:21] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_section" [131:22 - 131:32] DeclRefExpr=AT_section:27:7
+// CHECK-tokens: Punctuation: ")" [131:32 - 131:33] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [132:5 - 132:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [132:6 - 132:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [132:10 - 132:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""stdcall"" [132:11 - 132:20] StringLiteral=
+// CHECK-tokens: Punctuation: "," [132:20 - 132:21] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_stdcall" [132:22 - 132:32] DeclRefExpr=AT_stdcall:27:32
+// CHECK-tokens: Punctuation: ")" [132:32 - 132:33] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [133:5 - 133:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [133:6 - 133:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [133:10 - 133:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""annotate"" [133:11 - 133:21] StringLiteral=
+// CHECK-tokens: Punctuation: "," [133:21 - 133:22] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_annotate" [133:23 - 133:34] DeclRefExpr=AT_annotate:16:29
+// CHECK-tokens: Punctuation: ")" [133:34 - 133:35] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [134:5 - 134:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [134:6 - 134:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [134:10 - 134:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""fastcall"" [134:11 - 134:21] StringLiteral=
+// CHECK-tokens: Punctuation: "," [134:21 - 134:22] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_fastcall" [134:23 - 134:34] DeclRefExpr=AT_fastcall:19:27
+// CHECK-tokens: Punctuation: ")" [134:34 - 134:35] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [135:5 - 135:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [135:6 - 135:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [135:10 - 135:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""ibaction"" [135:11 - 135:21] StringLiteral=
+// CHECK-tokens: Punctuation: "," [135:21 - 135:22] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_IBAction" [135:23 - 135:34] DeclRefExpr=AT_IBAction:14:7
+// CHECK-tokens: Punctuation: ")" [135:34 - 135:35] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [136:5 - 136:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [136:6 - 136:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [136:10 - 136:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""iboutlet"" [136:11 - 136:21] StringLiteral=
+// CHECK-tokens: Punctuation: "," [136:21 - 136:22] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_IBOutlet" [136:23 - 136:34] DeclRefExpr=AT_IBOutlet:14:20
+// CHECK-tokens: Punctuation: ")" [136:34 - 136:35] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [137:5 - 137:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [137:6 - 137:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [137:10 - 137:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""iboutletcollection"" [137:11 - 137:31] StringLiteral=
+// CHECK-tokens: Punctuation: "," [137:31 - 137:32] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_IBOutletCollection" [137:33 - 137:54] DeclRefExpr=AT_IBOutletCollection:14:33
+// CHECK-tokens: Punctuation: ")" [137:54 - 137:55] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [138:5 - 138:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [138:6 - 138:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [138:10 - 138:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""noreturn"" [138:11 - 138:21] StringLiteral=
+// CHECK-tokens: Punctuation: "," [138:21 - 138:22] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_noreturn" [138:23 - 138:34] DeclRefExpr=AT_noreturn:21:59
+// CHECK-tokens: Punctuation: ")" [138:34 - 138:35] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [139:5 - 139:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [139:6 - 139:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [139:10 - 139:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""noinline"" [139:11 - 139:21] StringLiteral=
+// CHECK-tokens: Punctuation: "," [139:21 - 139:22] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_noinline" [139:23 - 139:34] DeclRefExpr=AT_noinline:21:7
+// CHECK-tokens: Punctuation: ")" [139:34 - 139:35] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [140:5 - 140:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [140:6 - 140:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [140:10 - 140:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""override"" [140:11 - 140:21] StringLiteral=
+// CHECK-tokens: Punctuation: "," [140:21 - 140:22] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_override" [140:23 - 140:34] DeclRefExpr=AT_override:22:51
+// CHECK-tokens: Punctuation: ")" [140:34 - 140:35] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [141:5 - 141:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [141:6 - 141:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [141:10 - 141:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""sentinel"" [141:11 - 141:21] StringLiteral=
+// CHECK-tokens: Punctuation: "," [141:21 - 141:22] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_sentinel" [141:23 - 141:34] DeclRefExpr=AT_sentinel:27:19
+// CHECK-tokens: Punctuation: ")" [141:34 - 141:35] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [142:5 - 142:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [142:6 - 142:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [142:10 - 142:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""NSObject"" [142:11 - 142:21] StringLiteral=
+// CHECK-tokens: Punctuation: "," [142:21 - 142:22] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_nsobject" [142:23 - 142:34] DeclRefExpr=AT_nsobject:22:19
+// CHECK-tokens: Punctuation: ")" [142:34 - 142:35] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [143:5 - 143:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [143:6 - 143:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [143:10 - 143:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""dllimport"" [143:11 - 143:22] StringLiteral=
+// CHECK-tokens: Punctuation: "," [143:22 - 143:23] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_dllimport" [143:24 - 143:36] DeclRefExpr=AT_dllimport:18:51
+// CHECK-tokens: Punctuation: ")" [143:36 - 143:37] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [144:5 - 144:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [144:6 - 144:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [144:10 - 144:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""dllexport"" [144:11 - 144:22] StringLiteral=
+// CHECK-tokens: Punctuation: "," [144:22 - 144:23] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_dllexport" [144:24 - 144:36] DeclRefExpr=AT_dllexport:18:37
+// CHECK-tokens: Punctuation: ")" [144:36 - 144:37] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [145:5 - 145:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [145:6 - 145:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [145:10 - 145:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""may_alias"" [145:11 - 145:22] StringLiteral=
+// CHECK-tokens: Punctuation: "," [145:22 - 145:23] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "IgnoredAttribute" [145:24 - 145:40] DeclRefExpr=IgnoredAttribute:31:25
+// CHECK-tokens: Punctuation: ")" [145:40 - 145:41] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [146:5 - 146:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [146:6 - 146:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [146:10 - 146:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""base_check"" [146:11 - 146:23] StringLiteral=
+// CHECK-tokens: Punctuation: "," [146:23 - 146:24] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_base_check" [146:25 - 146:38] DeclRefExpr=AT_base_check:16:42
+// CHECK-tokens: Punctuation: ")" [146:38 - 146:39] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [147:5 - 147:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [147:6 - 147:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [147:10 - 147:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""deprecated"" [147:11 - 147:23] StringLiteral=
+// CHECK-tokens: Punctuation: "," [147:23 - 147:24] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_deprecated" [147:25 - 147:38] DeclRefExpr=AT_deprecated:18:7
+// CHECK-tokens: Punctuation: ")" [147:38 - 147:39] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [148:5 - 148:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [148:6 - 148:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [148:10 - 148:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""visibility"" [148:11 - 148:23] StringLiteral=
+// CHECK-tokens: Punctuation: "," [148:23 - 148:24] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_visibility" [148:25 - 148:38] DeclRefExpr=AT_visibility:29:7
+// CHECK-tokens: Punctuation: ")" [148:38 - 148:39] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [149:5 - 149:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [149:6 - 149:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [149:10 - 149:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""destructor"" [149:11 - 149:23] StringLiteral=
+// CHECK-tokens: Punctuation: "," [149:23 - 149:24] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_destructor" [149:25 - 149:38] DeclRefExpr=AT_destructor:18:22
+// CHECK-tokens: Punctuation: ")" [149:38 - 149:39] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [150:5 - 150:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [150:6 - 150:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [150:10 - 150:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""format_arg"" [150:11 - 150:23] StringLiteral=
+// CHECK-tokens: Punctuation: "," [150:23 - 150:24] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_format_arg" [150:25 - 150:38] DeclRefExpr=AT_format_arg:19:61
+// CHECK-tokens: Punctuation: ")" [150:38 - 150:39] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [151:5 - 151:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [151:6 - 151:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [151:10 - 151:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""gnu_inline"" [151:11 - 151:23] StringLiteral=
+// CHECK-tokens: Punctuation: "," [151:23 - 151:24] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_gnu_inline" [151:25 - 151:38] DeclRefExpr=AT_gnu_inline:20:7
+// CHECK-tokens: Punctuation: ")" [151:38 - 151:39] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [152:5 - 152:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [152:6 - 152:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [152:10 - 152:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""weak_import"" [152:11 - 152:24] StringLiteral=
+// CHECK-tokens: Punctuation: "," [152:24 - 152:25] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_weak_import" [152:26 - 152:40] DeclRefExpr=AT_weak_import:30:7
+// CHECK-tokens: Punctuation: ")" [152:40 - 152:41] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [153:5 - 153:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [153:6 - 153:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [153:10 - 153:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""vecreturn"" [153:11 - 153:22] StringLiteral=
+// CHECK-tokens: Punctuation: "," [153:22 - 153:23] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_vecreturn" [153:24 - 153:36] DeclRefExpr=AT_vecreturn:28:43
+// CHECK-tokens: Punctuation: ")" [153:36 - 153:37] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [154:5 - 154:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [154:6 - 154:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [154:10 - 154:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""vector_size"" [154:11 - 154:24] StringLiteral=
+// CHECK-tokens: Punctuation: "," [154:24 - 154:25] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_vector_size" [154:26 - 154:40] DeclRefExpr=AT_vector_size:28:57
+// CHECK-tokens: Punctuation: ")" [154:40 - 154:41] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [155:5 - 155:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [155:6 - 155:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [155:10 - 155:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""constructor"" [155:11 - 155:24] StringLiteral=
+// CHECK-tokens: Punctuation: "," [155:24 - 155:25] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_constructor" [155:26 - 155:40] DeclRefExpr=AT_constructor:17:62
+// CHECK-tokens: Punctuation: ")" [155:40 - 155:41] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [156:5 - 156:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [156:6 - 156:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [156:10 - 156:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""unavailable"" [156:11 - 156:24] StringLiteral=
+// CHECK-tokens: Punctuation: "," [156:24 - 156:25] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_unavailable" [156:26 - 156:40] DeclRefExpr=AT_unavailable:28:7
+// CHECK-tokens: Punctuation: ")" [156:40 - 156:41] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [157:5 - 157:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [157:6 - 157:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [157:10 - 157:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""overloadable"" [157:11 - 157:25] StringLiteral=
+// CHECK-tokens: Punctuation: "," [157:25 - 157:26] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_overloadable" [157:27 - 157:42] DeclRefExpr=AT_overloadable:25:7
+// CHECK-tokens: Punctuation: ")" [157:42 - 157:43] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [158:5 - 158:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [158:6 - 158:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [158:10 - 158:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""address_space"" [158:11 - 158:26] StringLiteral=
+// CHECK-tokens: Punctuation: "," [158:26 - 158:27] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_address_space" [158:28 - 158:44] DeclRefExpr=AT_address_space:15:7
+// CHECK-tokens: Punctuation: ")" [158:44 - 158:45] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [159:5 - 159:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [159:6 - 159:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [159:10 - 159:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""always_inline"" [159:11 - 159:26] StringLiteral=
+// CHECK-tokens: Punctuation: "," [159:26 - 159:27] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_always_inline" [159:28 - 159:44] DeclRefExpr=AT_always_inline:15:47
+// CHECK-tokens: Punctuation: ")" [159:44 - 159:45] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [160:5 - 160:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [160:6 - 160:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [160:10 - 160:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""returns_twice"" [160:11 - 160:26] StringLiteral=
+// CHECK-tokens: Punctuation: "," [160:26 - 160:27] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_returns_twice" [160:28 - 160:44] DeclRefExpr=AT_returns_twice:31:7
+// CHECK-tokens: Punctuation: ")" [160:44 - 160:45] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [161:5 - 161:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [161:6 - 161:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [161:10 - 161:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""vec_type_hint"" [161:11 - 161:26] StringLiteral=
+// CHECK-tokens: Punctuation: "," [161:26 - 161:27] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "IgnoredAttribute" [161:28 - 161:44] DeclRefExpr=IgnoredAttribute:31:25
+// CHECK-tokens: Punctuation: ")" [161:44 - 161:45] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [162:5 - 162:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [162:6 - 162:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [162:10 - 162:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""objc_exception"" [162:11 - 162:27] StringLiteral=
+// CHECK-tokens: Punctuation: "," [162:27 - 162:28] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_objc_exception" [162:29 - 162:46] DeclRefExpr=AT_objc_exception:22:32
+// CHECK-tokens: Punctuation: ")" [162:46 - 162:47] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [163:5 - 163:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [163:6 - 163:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [163:10 - 163:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""ext_vector_type"" [163:11 - 163:28] StringLiteral=
+// CHECK-tokens: Punctuation: "," [163:28 - 163:29] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_ext_vector_type" [163:30 - 163:48] DeclRefExpr=AT_ext_vector_type:19:7
+// CHECK-tokens: Punctuation: ")" [163:48 - 163:49] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [164:5 - 164:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [164:6 - 164:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [164:10 - 164:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""transparent_union"" [164:11 - 164:30] StringLiteral=
+// CHECK-tokens: Punctuation: "," [164:30 - 164:31] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_transparent_union" [164:32 - 164:52] DeclRefExpr=AT_transparent_union:27:57
+// CHECK-tokens: Punctuation: ")" [164:52 - 164:53] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [165:5 - 165:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [165:6 - 165:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [165:10 - 165:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""analyzer_noreturn"" [165:11 - 165:30] StringLiteral=
+// CHECK-tokens: Punctuation: "," [165:30 - 165:31] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_analyzer_noreturn" [165:32 - 165:52] DeclRefExpr=AT_analyzer_noreturn:16:7
+// CHECK-tokens: Punctuation: ")" [165:52 - 165:53] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [166:5 - 166:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [166:6 - 166:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [166:10 - 166:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""warn_unused_result"" [166:11 - 166:31] StringLiteral=
+// CHECK-tokens: Punctuation: "," [166:31 - 166:32] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_warn_unused_result" [166:33 - 166:54] DeclRefExpr=AT_warn_unused_result:29:22
+// CHECK-tokens: Punctuation: ")" [166:54 - 166:55] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [167:5 - 167:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [167:6 - 167:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [167:10 - 167:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""carries_dependency"" [167:11 - 167:31] StringLiteral=
+// CHECK-tokens: Punctuation: "," [167:31 - 167:32] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_carries_dependency" [167:33 - 167:54] DeclRefExpr=AT_carries_dependency:17:7
+// CHECK-tokens: Punctuation: ")" [167:54 - 167:55] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [168:5 - 168:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [168:6 - 168:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [168:10 - 168:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""ns_returns_not_retained"" [168:11 - 168:36] StringLiteral=
+// CHECK-tokens: Punctuation: "," [168:36 - 168:37] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_ns_returns_not_retained" [168:38 - 168:64] DeclRefExpr=AT_ns_returns_not_retained:24:7
+// CHECK-tokens: Punctuation: ")" [168:64 - 168:65] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [169:5 - 169:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [169:6 - 169:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [169:10 - 169:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""ns_returns_retained"" [169:11 - 169:32] StringLiteral=
+// CHECK-tokens: Punctuation: "," [169:32 - 169:33] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_ns_returns_retained" [169:34 - 169:56] DeclRefExpr=AT_ns_returns_retained:24:35
+// CHECK-tokens: Punctuation: ")" [169:56 - 169:57] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [170:5 - 170:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [170:6 - 170:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [170:10 - 170:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""cf_returns_not_retained"" [170:11 - 170:36] StringLiteral=
+// CHECK-tokens: Punctuation: "," [170:36 - 170:37] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_cf_returns_not_retained" [170:38 - 170:64] DeclRefExpr=AT_cf_returns_not_retained:23:7
+// CHECK-tokens: Punctuation: ")" [170:64 - 170:65] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [171:5 - 171:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [171:6 - 171:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [171:10 - 171:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""cf_returns_retained"" [171:11 - 171:32] StringLiteral=
+// CHECK-tokens: Punctuation: "," [171:32 - 171:33] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_cf_returns_retained" [171:34 - 171:56] DeclRefExpr=AT_cf_returns_retained:23:35
+// CHECK-tokens: Punctuation: ")" [171:56 - 171:57] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [172:5 - 172:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [172:6 - 172:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [172:10 - 172:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""ownership_returns"" [172:11 - 172:30] StringLiteral=
+// CHECK-tokens: Punctuation: "," [172:30 - 172:31] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_ownership_returns" [172:32 - 172:52] DeclRefExpr=AT_ownership_returns:25:44
+// CHECK-tokens: Punctuation: ")" [172:52 - 172:53] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [173:5 - 173:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [173:6 - 173:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [173:10 - 173:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""ownership_holds"" [173:11 - 173:28] StringLiteral=
+// CHECK-tokens: Punctuation: "," [173:28 - 173:29] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_ownership_holds" [173:30 - 173:48] DeclRefExpr=AT_ownership_holds:25:24
+// CHECK-tokens: Punctuation: ")" [173:48 - 173:49] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [174:5 - 174:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [174:6 - 174:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [174:10 - 174:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""ownership_takes"" [174:11 - 174:28] StringLiteral=
+// CHECK-tokens: Punctuation: "," [174:28 - 174:29] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_ownership_takes" [174:30 - 174:48] DeclRefExpr=AT_ownership_takes:26:7
+// CHECK-tokens: Punctuation: ")" [174:48 - 174:49] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [175:5 - 175:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [175:6 - 175:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [175:10 - 175:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""reqd_work_group_size"" [175:11 - 175:33] StringLiteral=
+// CHECK-tokens: Punctuation: "," [175:33 - 175:34] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_reqd_wg_size" [175:35 - 175:50] DeclRefExpr=AT_reqd_wg_size:30:23
+// CHECK-tokens: Punctuation: ")" [175:50 - 175:51] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [176:5 - 176:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [176:6 - 176:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [176:10 - 176:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""init_priority"" [176:11 - 176:26] StringLiteral=
+// CHECK-tokens: Punctuation: "," [176:26 - 176:27] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_init_priority" [176:28 - 176:44] DeclRefExpr=AT_init_priority:30:40
+// CHECK-tokens: Punctuation: ")" [176:44 - 176:45] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [177:5 - 177:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [177:6 - 177:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [177:10 - 177:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""no_instrument_function"" [177:11 - 177:35] StringLiteral=
+// CHECK-tokens: Punctuation: "," [177:35 - 177:36] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_no_instrument_function" [177:37 - 177:62] DeclRefExpr=AT_no_instrument_function:21:20
+// CHECK-tokens: Punctuation: ")" [177:62 - 177:63] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [178:5 - 178:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [178:6 - 178:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [178:10 - 178:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""thiscall"" [178:11 - 178:21] StringLiteral=
+// CHECK-tokens: Punctuation: "," [178:21 - 178:22] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_thiscall" [178:23 - 178:34] DeclRefExpr=AT_thiscall:27:44
+// CHECK-tokens: Punctuation: ")" [178:34 - 178:35] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [179:5 - 179:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [179:6 - 179:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [179:10 - 179:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""pascal"" [179:11 - 179:19] StringLiteral=
+// CHECK-tokens: Punctuation: "," [179:19 - 179:20] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_pascal" [179:21 - 179:30] DeclRefExpr=AT_pascal:26:38
+// CHECK-tokens: Punctuation: ")" [179:30 - 179:31] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [180:5 - 180:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [180:6 - 180:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [180:10 - 180:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""__cdecl"" [180:11 - 180:20] StringLiteral=
+// CHECK-tokens: Punctuation: "," [180:20 - 180:21] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_cdecl" [180:22 - 180:30] DeclRefExpr=AT_cdecl:17:30
+// CHECK-tokens: Punctuation: ")" [180:30 - 180:31] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [181:5 - 181:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [181:6 - 181:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [181:10 - 181:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""__stdcall"" [181:11 - 181:22] StringLiteral=
+// CHECK-tokens: Punctuation: "," [181:22 - 181:23] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_stdcall" [181:24 - 181:34] DeclRefExpr=AT_stdcall:27:32
+// CHECK-tokens: Punctuation: ")" [181:34 - 181:35] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [182:5 - 182:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [182:6 - 182:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [182:10 - 182:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""__fastcall"" [182:11 - 182:23] StringLiteral=
+// CHECK-tokens: Punctuation: "," [182:23 - 182:24] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_fastcall" [182:25 - 182:36] DeclRefExpr=AT_fastcall:19:27
+// CHECK-tokens: Punctuation: ")" [182:36 - 182:37] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [183:5 - 183:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [183:6 - 183:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [183:10 - 183:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""__thiscall"" [183:11 - 183:23] StringLiteral=
+// CHECK-tokens: Punctuation: "," [183:23 - 183:24] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_thiscall" [183:25 - 183:36] DeclRefExpr=AT_thiscall:27:44
+// CHECK-tokens: Punctuation: ")" [183:36 - 183:37] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [184:5 - 184:6] MemberRefExpr=Case:88:42
+// CHECK-tokens: Identifier: "Case" [184:6 - 184:10] MemberRefExpr=Case:88:42
+// CHECK-tokens: Punctuation: "(" [184:10 - 184:11] CallExpr=Case:88:42
+// CHECK-tokens: Literal: ""__pascal"" [184:11 - 184:21] StringLiteral=
+// CHECK-tokens: Punctuation: "," [184:21 - 184:22] CallExpr=Case:88:42
+// CHECK-tokens: Identifier: "AT_pascal" [184:23 - 184:32] DeclRefExpr=AT_pascal:26:38
+// CHECK-tokens: Punctuation: ")" [184:32 - 184:33] CallExpr=Case:88:42
+// CHECK-tokens: Punctuation: "." [185:5 - 185:6] MemberRefExpr=Default:92:5
+// CHECK-tokens: Identifier: "Default" [185:6 - 185:13] MemberRefExpr=Default:92:5
+// CHECK-tokens: Punctuation: "(" [185:13 - 185:14] CallExpr=Default:92:5
+// CHECK-tokens: Identifier: "UnknownAttribute" [185:14 - 185:30] DeclRefExpr=UnknownAttribute:31:43
+// CHECK-tokens: Punctuation: ")" [185:30 - 185:31] CallExpr=Default:92:5
+// CHECK-tokens: Punctuation: ";" [185:31 - 185:32] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [186:1 - 186:2] CompoundStmt=
+
+// RUN: c-index-test -test-load-source all %s 2>&1 | FileCheck %s
+// CHECK: 1:27: TypedefDecl=__darwin_size_t:1:27 (Definition) Extent=[1:1 - 1:42]
+// CHECK: 2:25: TypedefDecl=size_t:2:25 (Definition) Extent=[2:1 - 2:31]
+// CHECK: 2:9: TypeRef=__darwin_size_t:1:27 Extent=[2:9 - 2:24]
+// CHECK: 3:11: Namespace=std:3:11 (Definition) Extent=[3:1 - 5:2]
+// CHECK: 4:44: ClassTemplate=pair:4:44 (Definition) Extent=[4:3 - 4:64]
+// CHECK: 4:20: TemplateTypeParameter=_T1:4:20 (Definition) Extent=[4:14 - 4:23]
+// CHECK: 4:31: TemplateTypeParameter=_T2:4:31 (Definition) Extent=[4:25 - 4:34]
+// CHECK: 4:55: FieldDecl=second:4:55 (Definition) Extent=[4:51 - 4:61]
+// CHECK: 6:8: UnexposedDecl=:6:8 (Definition) Extent=[6:1 - 9:2]
+// CHECK: 7:7: FunctionDecl=memcmp:7:7 Extent=[7:3 - 7:49]
+// CHECK: 7:26: ParmDecl=:7:26 (Definition) Extent=[7:14 - 7:27]
+// CHECK: 7:40: ParmDecl=:7:40 (Definition) Extent=[7:28 - 7:41]
+// CHECK: 7:48: ParmDecl=:7:48 (Definition) Extent=[7:42 - 7:49]
+// CHECK: 7:42: TypeRef=size_t:2:25 Extent=[7:42 - 7:48]
+// CHECK: 8:10: FunctionDecl=strlen:8:10 Extent=[8:3 - 8:30]
+// CHECK: 8:3: TypeRef=size_t:2:25 Extent=[8:3 - 8:9]
+// CHECK: 8:29: ParmDecl=:8:29 (Definition) Extent=[8:17 - 8:30]
+// CHECK: 10:17: Namespace=clang:10:17 (Definition) Extent=[10:1 - 35:2]
+// CHECK: 11:9: ClassDecl=IdentifierInfo:11:9 Extent=[11:3 - 11:23]
+// CHECK: 12:9: ClassDecl=AttributeList:12:9 (Definition) Extent=[12:3 - 34:4]
+// CHECK: 13:10: EnumDecl=Kind:13:10 (Definition) Extent=[13:5 - 32:6]
+// CHECK: 14:7: EnumConstantDecl=AT_IBAction:14:7 (Definition) Extent=[14:7 - 14:18]
+// CHECK: 14:20: EnumConstantDecl=AT_IBOutlet:14:20 (Definition) Extent=[14:20 - 14:31]
+// CHECK: 14:33: EnumConstantDecl=AT_IBOutletCollection:14:33 (Definition) Extent=[14:33 - 14:54]
+// CHECK: 15:7: EnumConstantDecl=AT_address_space:15:7 (Definition) Extent=[15:7 - 15:23]
+// CHECK: 15:25: EnumConstantDecl=AT_alias:15:25 (Definition) Extent=[15:25 - 15:33]
+// CHECK: 15:35: EnumConstantDecl=AT_aligned:15:35 (Definition) Extent=[15:35 - 15:45]
+// CHECK: 15:47: EnumConstantDecl=AT_always_inline:15:47 (Definition) Extent=[15:47 - 15:63]
+// CHECK: 16:7: EnumConstantDecl=AT_analyzer_noreturn:16:7 (Definition) Extent=[16:7 - 16:27]
+// CHECK: 16:29: EnumConstantDecl=AT_annotate:16:29 (Definition) Extent=[16:29 - 16:40]
+// CHECK: 16:42: EnumConstantDecl=AT_base_check:16:42 (Definition) Extent=[16:42 - 16:55]
+// CHECK: 16:57: EnumConstantDecl=AT_blocks:16:57 (Definition) Extent=[16:57 - 16:66]
+// CHECK: 17:7: EnumConstantDecl=AT_carries_dependency:17:7 (Definition) Extent=[17:7 - 17:28]
+// CHECK: 17:30: EnumConstantDecl=AT_cdecl:17:30 (Definition) Extent=[17:30 - 17:38]
+// CHECK: 17:40: EnumConstantDecl=AT_cleanup:17:40 (Definition) Extent=[17:40 - 17:50]
+// CHECK: 17:52: EnumConstantDecl=AT_const:17:52 (Definition) Extent=[17:52 - 17:60]
+// CHECK: 17:62: EnumConstantDecl=AT_constructor:17:62 (Definition) Extent=[17:62 - 17:76]
+// CHECK: 18:7: EnumConstantDecl=AT_deprecated:18:7 (Definition) Extent=[18:7 - 18:20]
+// CHECK: 18:22: EnumConstantDecl=AT_destructor:18:22 (Definition) Extent=[18:22 - 18:35]
+// CHECK: 18:37: EnumConstantDecl=AT_dllexport:18:37 (Definition) Extent=[18:37 - 18:49]
+// CHECK: 18:51: EnumConstantDecl=AT_dllimport:18:51 (Definition) Extent=[18:51 - 18:63]
+// CHECK: 19:7: EnumConstantDecl=AT_ext_vector_type:19:7 (Definition) Extent=[19:7 - 19:25]
+// CHECK: 19:27: EnumConstantDecl=AT_fastcall:19:27 (Definition) Extent=[19:27 - 19:38]
+// CHECK: 19:40: EnumConstantDecl=AT_final:19:40 (Definition) Extent=[19:40 - 19:48]
+// CHECK: 19:50: EnumConstantDecl=AT_format:19:50 (Definition) Extent=[19:50 - 19:59]
+// CHECK: 19:61: EnumConstantDecl=AT_format_arg:19:61 (Definition) Extent=[19:61 - 19:74]
+// CHECK: 20:7: EnumConstantDecl=AT_gnu_inline:20:7 (Definition) Extent=[20:7 - 20:20]
+// CHECK: 20:22: EnumConstantDecl=AT_hiding:20:22 (Definition) Extent=[20:22 - 20:31]
+// CHECK: 20:33: EnumConstantDecl=AT_malloc:20:33 (Definition) Extent=[20:33 - 20:42]
+// CHECK: 20:44: EnumConstantDecl=AT_mode:20:44 (Definition) Extent=[20:44 - 20:51]
+// CHECK: 20:53: EnumConstantDecl=AT_naked:20:53 (Definition) Extent=[20:53 - 20:61]
+// CHECK: 20:63: EnumConstantDecl=AT_nodebug:20:63 (Definition) Extent=[20:63 - 20:73]
+// CHECK: 21:7: EnumConstantDecl=AT_noinline:21:7 (Definition) Extent=[21:7 - 21:18]
+// CHECK: 21:20: EnumConstantDecl=AT_no_instrument_function:21:20 (Definition) Extent=[21:20 - 21:45]
+// CHECK: 21:47: EnumConstantDecl=AT_nonnull:21:47 (Definition) Extent=[21:47 - 21:57]
+// CHECK: 21:59: EnumConstantDecl=AT_noreturn:21:59 (Definition) Extent=[21:59 - 21:70]
+// CHECK: 22:7: EnumConstantDecl=AT_nothrow:22:7 (Definition) Extent=[22:7 - 22:17]
+// CHECK: 22:19: EnumConstantDecl=AT_nsobject:22:19 (Definition) Extent=[22:19 - 22:30]
+// CHECK: 22:32: EnumConstantDecl=AT_objc_exception:22:32 (Definition) Extent=[22:32 - 22:49]
+// CHECK: 22:51: EnumConstantDecl=AT_override:22:51 (Definition) Extent=[22:51 - 22:62]
+// CHECK: 23:7: EnumConstantDecl=AT_cf_returns_not_retained:23:7 (Definition) Extent=[23:7 - 23:33]
+// CHECK: 23:35: EnumConstantDecl=AT_cf_returns_retained:23:35 (Definition) Extent=[23:35 - 23:57]
+// CHECK: 24:7: EnumConstantDecl=AT_ns_returns_not_retained:24:7 (Definition) Extent=[24:7 - 24:33]
+// CHECK: 24:35: EnumConstantDecl=AT_ns_returns_retained:24:35 (Definition) Extent=[24:35 - 24:57]
+// CHECK: 24:59: EnumConstantDecl=AT_objc_gc:24:59 (Definition) Extent=[24:59 - 24:69]
+// CHECK: 25:7: EnumConstantDecl=AT_overloadable:25:7 (Definition) Extent=[25:7 - 25:22]
+// CHECK: 25:24: EnumConstantDecl=AT_ownership_holds:25:24 (Definition) Extent=[25:24 - 25:42]
+// CHECK: 25:44: EnumConstantDecl=AT_ownership_returns:25:44 (Definition) Extent=[25:44 - 25:64]
+// CHECK: 26:7: EnumConstantDecl=AT_ownership_takes:26:7 (Definition) Extent=[26:7 - 26:25]
+// CHECK: 26:27: EnumConstantDecl=AT_packed:26:27 (Definition) Extent=[26:27 - 26:36]
+// CHECK: 26:38: EnumConstantDecl=AT_pascal:26:38 (Definition) Extent=[26:38 - 26:47]
+// CHECK: 26:49: EnumConstantDecl=AT_pure:26:49 (Definition) Extent=[26:49 - 26:56]
+// CHECK: 26:58: EnumConstantDecl=AT_regparm:26:58 (Definition) Extent=[26:58 - 26:68]
+// CHECK: 27:7: EnumConstantDecl=AT_section:27:7 (Definition) Extent=[27:7 - 27:17]
+// CHECK: 27:19: EnumConstantDecl=AT_sentinel:27:19 (Definition) Extent=[27:19 - 27:30]
+// CHECK: 27:32: EnumConstantDecl=AT_stdcall:27:32 (Definition) Extent=[27:32 - 27:42]
+// CHECK: 27:44: EnumConstantDecl=AT_thiscall:27:44 (Definition) Extent=[27:44 - 27:55]
+// CHECK: 27:57: EnumConstantDecl=AT_transparent_union:27:57 (Definition) Extent=[27:57 - 27:77]
+// CHECK: 28:7: EnumConstantDecl=AT_unavailable:28:7 (Definition) Extent=[28:7 - 28:21]
+// CHECK: 28:23: EnumConstantDecl=AT_unused:28:23 (Definition) Extent=[28:23 - 28:32]
+// CHECK: 28:34: EnumConstantDecl=AT_used:28:34 (Definition) Extent=[28:34 - 28:41]
+// CHECK: 28:43: EnumConstantDecl=AT_vecreturn:28:43 (Definition) Extent=[28:43 - 28:55]
+// CHECK: 28:57: EnumConstantDecl=AT_vector_size:28:57 (Definition) Extent=[28:57 - 28:71]
+// CHECK: 29:7: EnumConstantDecl=AT_visibility:29:7 (Definition) Extent=[29:7 - 29:20]
+// CHECK: 29:22: EnumConstantDecl=AT_warn_unused_result:29:22 (Definition) Extent=[29:22 - 29:43]
+// CHECK: 29:45: EnumConstantDecl=AT_weak:29:45 (Definition) Extent=[29:45 - 29:52]
+// CHECK: 29:54: EnumConstantDecl=AT_weakref:29:54 (Definition) Extent=[29:54 - 29:64]
+// CHECK: 30:7: EnumConstantDecl=AT_weak_import:30:7 (Definition) Extent=[30:7 - 30:21]
+// CHECK: 30:23: EnumConstantDecl=AT_reqd_wg_size:30:23 (Definition) Extent=[30:23 - 30:38]
+// CHECK: 30:40: EnumConstantDecl=AT_init_priority:30:40 (Definition) Extent=[30:40 - 30:56]
+// CHECK: 31:7: EnumConstantDecl=AT_returns_twice:31:7 (Definition) Extent=[31:7 - 31:23]
+// CHECK: 31:25: EnumConstantDecl=IgnoredAttribute:31:25 (Definition) Extent=[31:25 - 31:41]
+// CHECK: 33:17: CXXMethod=getKind:33:17 (static) Extent=[33:5 - 33:53]
+// CHECK: 33:12: TypeRef=enum clang::AttributeList::Kind:13:10 Extent=[33:12 - 33:16]
+// CHECK: 33:48: ParmDecl=Name:33:48 (Definition) Extent=[33:25 - 33:52]
+// CHECK: 33:31: TypeRef=class clang::IdentifierInfo:66:7 Extent=[33:31 - 33:45]
+// CHECK: 36:8: FunctionDecl=magic_length:36:8 Extent=[36:1 - 36:35]
+// CHECK: 36:1: TypeRef=size_t:2:25 Extent=[36:1 - 36:7]
+// CHECK: 36:33: ParmDecl=s:36:33 (Definition) Extent=[36:21 - 36:34]
+// CHECK: 37:11: Namespace=llvm:37:11 (Definition) Extent=[37:1 - 64:2]
+// CHECK: 38:7: ClassDecl=StringRef:38:7 (Definition) Extent=[38:1 - 63:2]
+// CHECK: 39:1: CXXAccessSpecifier=:39:1 (Definition) Extent=[39:1 - 39:8]
+// CHECK: 40:23: TypedefDecl=iterator:40:23 (Definition) Extent=[40:3 - 40:31]
+// CHECK: 41:23: VarDecl=npos:41:23 Extent=[41:3 - 41:40]
+// CHECK: 41:16: TypeRef=size_t:2:25 Extent=[41:16 - 41:22]
+// CHECK: 41:30: UnaryOperator= Extent=[41:30 - 41:40]
+// CHECK: 41:31: CXXFunctionalCastExpr= Extent=[41:31 - 41:40]
+// CHECK: 41:31: TypeRef=size_t:2:25 Extent=[41:31 - 41:37]
+// CHECK: 41:38: UnexposedExpr= Extent=[41:38 - 41:39]
+// CHECK: 41:38: IntegerLiteral= Extent=[41:38 - 41:39]
+// CHECK: 42:1: CXXAccessSpecifier=:42:1 (Definition) Extent=[42:1 - 42:9]
+// CHECK: 43:15: FieldDecl=Data:43:15 (Definition) Extent=[43:3 - 43:19]
+// CHECK: 44:10: FieldDecl=Length:44:10 (Definition) Extent=[44:3 - 44:16]
+// CHECK: 44:3: TypeRef=size_t:2:25 Extent=[44:3 - 44:9]
+// CHECK: 45:17: CXXMethod=min:45:17 (Definition) (static) Extent=[45:3 - 45:66]
+// CHECK: 45:10: TypeRef=size_t:2:25 Extent=[45:10 - 45:16]
+// CHECK: 45:28: ParmDecl=a:45:28 (Definition) Extent=[45:21 - 45:29]
+// CHECK: 45:21: TypeRef=size_t:2:25 Extent=[45:21 - 45:27]
+// CHECK: 45:38: ParmDecl=b:45:38 (Definition) Extent=[45:31 - 45:39]
+// CHECK: 45:31: TypeRef=size_t:2:25 Extent=[45:31 - 45:37]
+// CHECK: 45:41: CompoundStmt= Extent=[45:41 - 45:66]
+// CHECK: 45:43: ReturnStmt= Extent=[45:43 - 45:63]
+// CHECK: 45:50: ConditionalOperator= Extent=[45:50 - 45:63]
+// CHECK: 45:50: BinaryOperator= Extent=[45:50 - 45:55]
+// CHECK: 45:50: DeclRefExpr=a:45:28 Extent=[45:50 - 45:51]
+// CHECK: 45:54: DeclRefExpr=b:45:38 Extent=[45:54 - 45:55]
+// CHECK: 45:58: DeclRefExpr=a:45:28 Extent=[45:58 - 45:59]
+// CHECK: 45:62: DeclRefExpr=b:45:38 Extent=[45:62 - 45:63]
+// CHECK: 46:1: CXXAccessSpecifier=:46:1 (Definition) Extent=[46:1 - 46:8]
+// CHECK: 47:3: CXXConstructor=StringRef:47:3 (Definition) Extent=[47:3 - 47:37]
+// CHECK: 47:16: MemberRef=Data:43:15 Extent=[47:16 - 47:20]
+// CHECK: 47:21: UnexposedExpr= Extent=[47:21 - 47:22]
+// CHECK: 47:21: IntegerLiteral= Extent=[47:21 - 47:22]
+// CHECK: 47:25: MemberRef=Length:44:10 Extent=[47:25 - 47:31]
+// CHECK: 47:32: UnexposedExpr= Extent=[47:32 - 47:33]
+// CHECK: 47:32: IntegerLiteral= Extent=[47:32 - 47:33]
+// CHECK: 47:35: CompoundStmt= Extent=[47:35 - 47:37]
+// CHECK: 48:3: CXXConstructor=StringRef:48:3 (Definition) Extent=[48:3 - 48:71]
+// CHECK: 48:25: ParmDecl=Str:48:25 (Definition) Extent=[48:13 - 48:28]
+// CHECK: 48:32: MemberRef=Data:43:15 Extent=[48:32 - 48:36]
+// CHECK: 48:37: DeclRefExpr=Str:48:25 Extent=[48:37 - 48:40]
+// CHECK: 48:43: MemberRef=Length:44:10 Extent=[48:43 - 48:49]
+// CHECK: 48:50: CallExpr=magic_length:36:8 Extent=[48:50 - 48:67]
+// CHECK: 48:50: UnexposedExpr=magic_length:36:8 Extent=[48:50 - 48:62]
+// CHECK: 48:50: DeclRefExpr=magic_length:36:8 Extent=[48:50 - 48:62]
+// CHECK: 48:63: DeclRefExpr=Str:48:25 Extent=[48:63 - 48:66]
+// CHECK: 48:69: CompoundStmt= Extent=[48:69 - 48:71]
+// CHECK: 49:3: CXXConstructor=StringRef:49:3 (Definition) Extent=[49:3 - 49:77]
+// CHECK: 49:25: ParmDecl=data:49:25 (Definition) Extent=[49:13 - 49:29]
+// CHECK: 49:38: ParmDecl=length:49:38 (Definition) Extent=[49:31 - 49:44]
+// CHECK: 49:31: TypeRef=size_t:2:25 Extent=[49:31 - 49:37]
+// CHECK: 49:48: MemberRef=Data:43:15 Extent=[49:48 - 49:52]
+// CHECK: 49:53: DeclRefExpr=data:49:25 Extent=[49:53 - 49:57]
+// CHECK: 49:60: MemberRef=Length:44:10 Extent=[49:60 - 49:66]
+// CHECK: 49:67: DeclRefExpr=length:49:38 Extent=[49:67 - 49:73]
+// CHECK: 49:75: CompoundStmt= Extent=[49:75 - 49:77]
+// CHECK: 50:12: CXXMethod=end:50:12 (Definition) Extent=[50:3 - 50:40]
+// CHECK: 50:3: TypeRef=iterator:40:23 Extent=[50:3 - 50:11]
+// CHECK: 50:24: CompoundStmt= Extent=[50:24 - 50:40]
+// CHECK: 50:26: ReturnStmt= Extent=[50:26 - 50:37]
+// CHECK: 50:33: MemberRefExpr=Data:43:15 Extent=[50:33 - 50:37]
+// CHECK: 51:10: CXXMethod=size:51:10 (Definition) Extent=[51:3 - 51:41]
+// CHECK: 51:3: TypeRef=size_t:2:25 Extent=[51:3 - 51:9]
+// CHECK: 51:23: CompoundStmt= Extent=[51:23 - 51:41]
+// CHECK: 51:25: ReturnStmt= Extent=[51:25 - 51:38]
+// CHECK: 51:32: MemberRefExpr=Length:44:10 Extent=[51:32 - 51:38]
+// CHECK: 52:8: CXXMethod=startswith:52:8 (Definition) Extent=[52:3 - 55:4]
+// CHECK: 52:29: ParmDecl=Prefix:52:29 (Definition) Extent=[52:19 - 52:35]
+// CHECK: 52:19: TypeRef=class llvm::StringRef:38:7 Extent=[52:19 - 52:28]
+// CHECK: 52:43: CompoundStmt= Extent=[52:43 - 55:4]
+// CHECK: 53:5: ReturnStmt= Extent=[53:5 - 54:56]
+// CHECK: 53:12: BinaryOperator= Extent=[53:12 - 54:56]
+// CHECK: 53:12: BinaryOperator= Extent=[53:12 - 53:35]
+// CHECK: 53:12: UnexposedExpr=Length:44:10 Extent=[53:12 - 53:18]
+// CHECK: 53:12: MemberRefExpr=Length:44:10 Extent=[53:12 - 53:18]
+// CHECK: 53:29: MemberRefExpr=Length:44:10 SingleRefName=[53:29 - 53:35] RefName=[53:29 - 53:35] Extent=[53:22 - 53:35]
+// CHECK: 53:22: DeclRefExpr=Prefix:52:29 Extent=[53:22 - 53:28]
+// CHECK: 54:11: BinaryOperator= Extent=[54:11 - 54:56]
+// CHECK: 54:11: CallExpr=memcmp:7:7 Extent=[54:11 - 54:51]
+// CHECK: 54:11: UnexposedExpr=memcmp:7:7 Extent=[54:11 - 54:17]
+// CHECK: 54:11: DeclRefExpr=memcmp:7:7 Extent=[54:11 - 54:17]
+// CHECK: 54:18: UnexposedExpr=Data:43:15 Extent=[54:18 - 54:22]
+// CHECK: 54:18: MemberRefExpr=Data:43:15 Extent=[54:18 - 54:22]
+// CHECK: 54:31: UnexposedExpr=Data:43:15 Extent=[54:24 - 54:35]
+// CHECK: 54:31: MemberRefExpr=Data:43:15 SingleRefName=[54:31 - 54:35] RefName=[54:31 - 54:35] Extent=[54:24 - 54:35]
+// CHECK: 54:24: DeclRefExpr=Prefix:52:29 Extent=[54:24 - 54:30]
+// CHECK: 54:44: MemberRefExpr=Length:44:10 SingleRefName=[54:44 - 54:50] RefName=[54:44 - 54:50] Extent=[54:37 - 54:50]
+// CHECK: 54:37: DeclRefExpr=Prefix:52:29 Extent=[54:37 - 54:43]
+// CHECK: 54:55: IntegerLiteral= Extent=[54:55 - 54:56]
+// CHECK: 56:8: CXXMethod=endswith:56:8 (Definition) Extent=[56:3 - 59:4]
+// CHECK: 56:27: ParmDecl=Suffix:56:27 (Definition) Extent=[56:17 - 56:33]
+// CHECK: 56:17: TypeRef=class llvm::StringRef:38:7 Extent=[56:17 - 56:26]
+// CHECK: 56:41: CompoundStmt= Extent=[56:41 - 59:4]
+// CHECK: 57:5: ReturnStmt= Extent=[57:5 - 58:69]
+// CHECK: 57:12: BinaryOperator= Extent=[57:12 - 58:69]
+// CHECK: 57:12: BinaryOperator= Extent=[57:12 - 57:35]
+// CHECK: 57:12: UnexposedExpr=Length:44:10 Extent=[57:12 - 57:18]
+// CHECK: 57:12: MemberRefExpr=Length:44:10 Extent=[57:12 - 57:18]
+// CHECK: 57:29: MemberRefExpr=Length:44:10 SingleRefName=[57:29 - 57:35] RefName=[57:29 - 57:35] Extent=[57:22 - 57:35]
+// CHECK: 57:22: DeclRefExpr=Suffix:56:27 Extent=[57:22 - 57:28]
+// CHECK: 58:7: BinaryOperator= Extent=[58:7 - 58:69]
+// CHECK: 58:7: CallExpr=memcmp:7:7 Extent=[58:7 - 58:64]
+// CHECK: 58:7: UnexposedExpr=memcmp:7:7 Extent=[58:7 - 58:13]
+// CHECK: 58:7: DeclRefExpr=memcmp:7:7 Extent=[58:7 - 58:13]
+// CHECK: 58:14: UnexposedExpr= Extent=[58:14 - 58:35]
+// CHECK: 58:14: BinaryOperator= Extent=[58:14 - 58:35]
+// CHECK: 58:14: CallExpr=end:50:12 Extent=[58:14 - 58:19]
+// CHECK: 58:14: MemberRefExpr=end:50:12 Extent=[58:14 - 58:17]
+// CHECK: 58:29: MemberRefExpr=Length:44:10 SingleRefName=[58:29 - 58:35] RefName=[58:29 - 58:35] Extent=[58:22 - 58:35]
+// CHECK: 58:22: DeclRefExpr=Suffix:56:27 Extent=[58:22 - 58:28]
+// CHECK: 58:44: UnexposedExpr=Data:43:15 Extent=[58:37 - 58:48]
+// CHECK: 58:44: MemberRefExpr=Data:43:15 SingleRefName=[58:44 - 58:48] RefName=[58:44 - 58:48] Extent=[58:37 - 58:48]
+// CHECK: 58:37: DeclRefExpr=Suffix:56:27 Extent=[58:37 - 58:43]
+// CHECK: 58:57: MemberRefExpr=Length:44:10 SingleRefName=[58:57 - 58:63] RefName=[58:57 - 58:63] Extent=[58:50 - 58:63]
+// CHECK: 58:50: DeclRefExpr=Suffix:56:27 Extent=[58:50 - 58:56]
+// CHECK: 58:68: IntegerLiteral= Extent=[58:68 - 58:69]
+// CHECK: 60:13: CXXMethod=substr:60:13 (Definition) Extent=[60:3 - 62:4]
+// CHECK: 60:3: TypeRef=class llvm::StringRef:38:7 Extent=[60:3 - 60:12]
+// CHECK: 60:27: ParmDecl=Start:60:27 (Definition) Extent=[60:20 - 60:32]
+// CHECK: 60:20: TypeRef=size_t:2:25 Extent=[60:20 - 60:26]
+// CHECK: 60:41: ParmDecl=N:60:41 (Definition) Extent=[60:34 - 60:49]
+// CHECK: 60:34: TypeRef=size_t:2:25 Extent=[60:34 - 60:40]
+// CHECK: 60:45: DeclRefExpr=npos:41:23 Extent=[60:45 - 60:49]
+// CHECK: 60:57: CompoundStmt= Extent=[60:57 - 62:4]
+// CHECK: 61:5: ReturnStmt= Extent=[61:5 - 61:59]
+// CHECK: 61:12: CallExpr= Extent=[61:12 - 61:59]
+// CHECK: 61:12: UnexposedExpr=StringRef:49:3 Extent=[61:12 - 61:59]
+// CHECK: 61:12: CallExpr=StringRef:49:3 Extent=[61:12 - 61:59]
+// CHECK: 61:12: TypeRef=class llvm::StringRef:38:7 Extent=[61:12 - 61:21]
+// CHECK: 61:22: BinaryOperator= Extent=[61:22 - 61:34]
+// CHECK: 61:22: UnexposedExpr=Data:43:15 Extent=[61:22 - 61:26]
+// CHECK: 61:22: MemberRefExpr=Data:43:15 Extent=[61:22 - 61:26]
+// CHECK: 61:29: DeclRefExpr=Start:60:27 Extent=[61:29 - 61:34]
+// CHECK: 61:36: CallExpr=min:45:17 Extent=[61:36 - 61:58]
+// CHECK: 61:36: UnexposedExpr=min:45:17 Extent=[61:36 - 61:39]
+// CHECK: 61:36: DeclRefExpr=min:45:17 Extent=[61:36 - 61:39]
+// CHECK: 61:40: DeclRefExpr=N:60:41 Extent=[61:40 - 61:41]
+// CHECK: 61:43: BinaryOperator= Extent=[61:43 - 61:57]
+// CHECK: 61:43: UnexposedExpr=Length:44:10 Extent=[61:43 - 61:49]
+// CHECK: 61:43: MemberRefExpr=Length:44:10 Extent=[61:43 - 61:49]
+// CHECK: 61:52: DeclRefExpr=Start:60:27 Extent=[61:52 - 61:57]
+// CHECK: 65:11: Namespace=clang:65:11 (Definition) Extent=[65:1 - 81:2]
+// CHECK: 66:7: ClassDecl=IdentifierInfo:66:7 (Definition) Extent=[66:1 - 80:2]
+// CHECK: 67:1: CXXAccessSpecifier=:67:1 (Definition) Extent=[67:1 - 67:8]
+// CHECK: 67:8: CXXConstructor=IdentifierInfo:67:8 Extent=[67:8 - 67:24]
+// CHECK: 68:15: CXXMethod=getNameStart:68:15 (Definition) Extent=[68:3 - 71:4]
+// CHECK: 68:36: CompoundStmt= Extent=[68:36 - 71:4]
+// CHECK: 69:5: DeclStmt= Extent=[69:5 - 69:65]
+// CHECK: 69:54: TypedefDecl=actualtype:69:54 (Definition) Extent=[69:5 - 69:64]
+// CHECK: 69:18: TemplateRef=pair:4:44 Extent=[69:18 - 69:22]
+// CHECK: 69:25: TypeRef=class clang::IdentifierInfo:66:7 Extent=[69:25 - 69:39]
+// CHECK: 70:5: ReturnStmt= Extent=[70:5 - 70:47]
+// CHECK: 70:41: MemberRefExpr=second:4:55 SingleRefName=[70:41 - 70:47] RefName=[70:41 - 70:47] Extent=[70:12 - 70:47]
+// CHECK: 70:12: ParenExpr= Extent=[70:12 - 70:39]
+// CHECK: 70:13: CStyleCastExpr= Extent=[70:13 - 70:38]
+// CHECK: 70:20: TypeRef=actualtype:69:54 Extent=[70:20 - 70:30]
+// CHECK: 70:34: CXXThisExpr= Extent=[70:34 - 70:38]
+// CHECK: 72:12: CXXMethod=getLength:72:12 (Definition) Extent=[72:3 - 76:4]
+// CHECK: 72:30: CompoundStmt= Extent=[72:30 - 76:4]
+// CHECK: 73:5: DeclStmt= Extent=[73:5 - 73:65]
+// CHECK: 73:54: TypedefDecl=actualtype:73:54 (Definition) Extent=[73:5 - 73:64]
+// CHECK: 73:18: TemplateRef=pair:4:44 Extent=[73:18 - 73:22]
+// CHECK: 73:25: TypeRef=class clang::IdentifierInfo:66:7 Extent=[73:25 - 73:39]
+// CHECK: 74:5: DeclStmt= Extent=[74:5 - 74:61]
+// CHECK: 74:17: VarDecl=p:74:17 (Definition) Extent=[74:5 - 74:60]
+// CHECK: 74:21: BinaryOperator= Extent=[74:21 - 74:60]
+// CHECK: 74:50: UnexposedExpr=second:4:55 Extent=[74:21 - 74:56]
+// CHECK: 74:50: MemberRefExpr=second:4:55 SingleRefName=[74:50 - 74:56] RefName=[74:50 - 74:56] Extent=[74:21 - 74:56]
+// CHECK: 74:21: ParenExpr= Extent=[74:21 - 74:48]
+// CHECK: 74:22: CStyleCastExpr= Extent=[74:22 - 74:47]
+// CHECK: 74:29: TypeRef=actualtype:73:54 Extent=[74:29 - 74:39]
+// CHECK: 74:43: CXXThisExpr= Extent=[74:43 - 74:47]
+// CHECK: 74:59: IntegerLiteral= Extent=[74:59 - 74:60]
+// CHECK: 75:5: ReturnStmt= Extent=[75:5 - 75:62]
+// CHECK: 75:12: BinaryOperator= Extent=[75:12 - 75:62]
+// CHECK: 75:12: ParenExpr= Extent=[75:12 - 75:58]
+// CHECK: 75:13: BinaryOperator= Extent=[75:13 - 75:57]
+// CHECK: 75:13: ParenExpr= Extent=[75:13 - 75:30]
+// CHECK: 75:14: CStyleCastExpr= Extent=[75:14 - 75:29]
+// CHECK: 75:25: UnexposedExpr= Extent=[75:25 - 75:29]
+// CHECK: 75:25: UnexposedExpr= Extent=[75:25 - 75:29]
+// CHECK: 75:25: ArraySubscriptExpr= Extent=[75:25 - 75:29]
+// CHECK: 75:25: DeclRefExpr=p:74:17 Extent=[75:25 - 75:26]
+// CHECK: 75:27: IntegerLiteral= Extent=[75:27 - 75:28]
+// CHECK: 75:33: ParenExpr= Extent=[75:33 - 75:57]
+// CHECK: 75:34: BinaryOperator= Extent=[75:34 - 75:56]
+// CHECK: 75:34: ParenExpr= Extent=[75:34 - 75:51]
+// CHECK: 75:35: CStyleCastExpr= Extent=[75:35 - 75:50]
+// CHECK: 75:46: UnexposedExpr= Extent=[75:46 - 75:50]
+// CHECK: 75:46: UnexposedExpr= Extent=[75:46 - 75:50]
+// CHECK: 75:46: ArraySubscriptExpr= Extent=[75:46 - 75:50]
+// CHECK: 75:46: DeclRefExpr=p:74:17 Extent=[75:46 - 75:47]
+// CHECK: 75:48: IntegerLiteral= Extent=[75:48 - 75:49]
+// CHECK: 75:55: IntegerLiteral= Extent=[75:55 - 75:56]
+// CHECK: 75:61: UnexposedExpr= Extent=[75:61 - 75:62]
+// CHECK: 75:61: IntegerLiteral= Extent=[75:61 - 75:62]
+// CHECK: 77:19: CXXMethod=getName:77:19 (Definition) Extent=[77:3 - 79:4]
+// CHECK: 77:35: CompoundStmt= Extent=[77:35 - 79:4]
+// CHECK: 78:5: ReturnStmt= Extent=[78:5 - 78:56]
+// CHECK: 78:12: CallExpr= Extent=[78:12 - 78:56]
+// CHECK: 78:12: UnexposedExpr=StringRef:49:3 Extent=[78:12 - 78:56]
+// CHECK: 78:12: CallExpr=StringRef:49:3 Extent=[78:12 - 78:56]
+// CHECK: 78:28: CallExpr=getNameStart:68:15 Extent=[78:28 - 78:42]
+// CHECK: 78:28: MemberRefExpr=getNameStart:68:15 Extent=[78:28 - 78:40]
+// CHECK: 78:44: UnexposedExpr=getLength:72:12 Extent=[78:44 - 78:55]
+// CHECK: 78:44: CallExpr=getLength:72:12 Extent=[78:44 - 78:55]
+// CHECK: 78:44: MemberRefExpr=getLength:72:12 Extent=[78:44 - 78:53]
+// CHECK: 82:11: Namespace=llvm:82:11 (Definition) Extent=[82:1 - 96:2]
+// CHECK: 83:47: ClassTemplate=StringSwitch:83:47 (Definition) Extent=[83:1 - 95:2]
+// CHECK: 83:21: TemplateTypeParameter=T:83:21 (Definition) Extent=[83:12 - 83:22]
+// CHECK: 83:33: TemplateTypeParameter=R:83:33 (Definition) Extent=[83:24 - 83:38]
+// CHECK: 84:13: FieldDecl=Str:84:13 (Definition) Extent=[84:3 - 84:16]
+// CHECK: 84:3: TypeRef=class llvm::StringRef:38:7 Extent=[84:3 - 84:12]
+// CHECK: 85:12: FieldDecl=Result:85:12 (Definition) Extent=[85:3 - 85:18]
+// CHECK: 86:1: CXXAccessSpecifier=:86:1 (Definition) Extent=[86:1 - 86:8]
+// CHECK: 87:12: CXXConstructor=StringSwitch<T, R>:87:12 (Definition) Extent=[87:3 - 87:64]
+// CHECK: 87:35: ParmDecl=Str:87:35 (Definition) Extent=[87:25 - 87:38]
+// CHECK: 87:25: TypeRef=class llvm::StringRef:38:7 Extent=[87:25 - 87:34]
+// CHECK: 87:42: MemberRef=Str:84:13 Extent=[87:42 - 87:45]
+// CHECK: 87:45: UnexposedExpr= Extent=[87:45 - 87:50]
+// CHECK: 87:46: DeclRefExpr=Str:87:35 Extent=[87:46 - 87:49]
+// CHECK: 87:52: MemberRef=Result:85:12 Extent=[87:52 - 87:58]
+// CHECK: 87:58: UnexposedExpr= Extent=[87:58 - 87:61]
+// CHECK: 87:59: IntegerLiteral= Extent=[87:59 - 87:60]
+// CHECK: 87:62: CompoundStmt= Extent=[87:62 - 87:64]
+// CHECK: 88:42: FunctionTemplate=Case:88:42 (Definition) Extent=[88:3 - 91:4]
+// CHECK: 88:23: NonTypeTemplateParameter=N:88:23 (Definition) Extent=[88:14 - 88:24]
+// CHECK: 88:60: ParmDecl=S:88:60 (Definition) Extent=[88:47 - 88:65]
+// CHECK: 88:63: DeclRefExpr=N:88:23 Extent=[88:63 - 88:64]
+// CHECK: 89:57: ParmDecl=Value:89:57 (Definition) Extent=[89:47 - 89:62]
+// CHECK: 89:64: CompoundStmt= Extent=[89:64 - 91:4]
+// CHECK: 90:5: ReturnStmt= Extent=[90:5 - 90:17]
+// CHECK: 90:12: UnaryOperator= Extent=[90:12 - 90:17]
+// CHECK: 90:13: CXXThisExpr= Extent=[90:13 - 90:17]
+// CHECK: 92:5: CXXMethod=Default:92:5 (Definition) Extent=[92:3 - 94:4]
+// CHECK: 92:23: ParmDecl=Value:92:23 (Definition) Extent=[92:13 - 92:28]
+// CHECK: 92:36: CompoundStmt= Extent=[92:36 - 94:4]
+// CHECK: 93:5: ReturnStmt= Extent=[93:5 - 93:17]
+// CHECK: 93:12: DeclRefExpr=Value:92:23 Extent=[93:12 - 93:17]
+// CHECK: 98:17: UsingDirective=:98:17 Extent=[98:1 - 98:22]
+// CHECK: 98:17: NamespaceRef=clang:10:17 Extent=[98:17 - 98:22]
+// CHECK: 100:36: CXXMethod=getKind:100:36 (Definition) (static) Extent=[100:1 - 186:2]
+// CHECK: 100:21: TypeRef=class clang::AttributeList:12:9 Extent=[100:21 - 100:34]
+// CHECK: 100:67: ParmDecl=Name:100:67 (Definition) Extent=[100:44 - 100:71]
+// CHECK: 100:50: TypeRef=class clang::IdentifierInfo:66:7 Extent=[100:50 - 100:64]
+// CHECK: 100:73: CompoundStmt= Extent=[100:73 - 186:2]
+// CHECK: 101:3: DeclStmt= Extent=[101:3 - 101:46]
+// CHECK: 101:19: VarDecl=AttrName:101:19 (Definition) Extent=[101:3 - 101:45]
+// CHECK: 101:30: CallExpr= Extent=[101:30 - 101:45]
+// CHECK: 101:30: UnexposedExpr=getName:77:19 Extent=[101:30 - 101:45]
+// CHECK: 101:30: CallExpr=getName:77:19 Extent=[101:30 - 101:45]
+// CHECK: 101:36: MemberRefExpr=getName:77:19 SingleRefName=[101:36 - 101:43] RefName=[101:36 - 101:43] Extent=[101:30 - 101:43]
+// CHECK: 101:30: DeclRefExpr=Name:100:67 Extent=[101:30 - 101:34]
+// CHECK: 102:3: IfStmt= Extent=[102:3 - 103:55]
+// CHECK: 102:7: BinaryOperator= Extent=[102:7 - 102:59]
+// CHECK: 102:7: CallExpr=startswith:52:8 Extent=[102:7 - 102:32]
+// CHECK: 102:16: MemberRefExpr=startswith:52:8 SingleRefName=[102:16 - 102:26] RefName=[102:16 - 102:26] Extent=[102:7 - 102:26]
+// CHECK: 102:7: UnexposedExpr=AttrName:101:19 Extent=[102:7 - 102:15]
+// CHECK: 102:7: DeclRefExpr=AttrName:101:19 Extent=[102:7 - 102:15]
+// CHECK: 102:27: CallExpr= Extent=[102:27 - 102:31]
+// CHECK: 102:27: UnexposedExpr=StringRef:48:3 Extent=[102:27 - 102:31]
+// CHECK: 102:27: UnexposedExpr=StringRef:48:3 Extent=[102:27 - 102:31]
+// CHECK: 102:27: CallExpr=StringRef:48:3 Extent=[102:27 - 102:31]
+// CHECK: 102:27: UnexposedExpr= Extent=[102:27 - 102:31]
+// CHECK: 102:27: StringLiteral= Extent=[102:27 - 102:31]
+// CHECK: 102:36: CallExpr=endswith:56:8 Extent=[102:36 - 102:59]
+// CHECK: 102:45: MemberRefExpr=endswith:56:8 SingleRefName=[102:45 - 102:53] RefName=[102:45 - 102:53] Extent=[102:36 - 102:53]
+// CHECK: 102:36: UnexposedExpr=AttrName:101:19 Extent=[102:36 - 102:44]
+// CHECK: 102:36: DeclRefExpr=AttrName:101:19 Extent=[102:36 - 102:44]
+// CHECK: 102:54: CallExpr= Extent=[102:54 - 102:58]
+// CHECK: 102:54: UnexposedExpr=StringRef:48:3 Extent=[102:54 - 102:58]
+// CHECK: 102:54: UnexposedExpr=StringRef:48:3 Extent=[102:54 - 102:58]
+// CHECK: 102:54: CallExpr=StringRef:48:3 Extent=[102:54 - 102:58]
+// CHECK: 102:54: UnexposedExpr= Extent=[102:54 - 102:58]
+// CHECK: 102:54: StringLiteral= Extent=[102:54 - 102:58]
+// CHECK: 103:5: CallExpr=operator=:38:7 Extent=[103:5 - 103:55]
+// CHECK: 103:5: DeclRefExpr=AttrName:101:19 Extent=[103:5 - 103:13]
+// CHECK: 103:14: UnexposedExpr=operator=:38:7
+// CHECK: 103:14: DeclRefExpr=operator=:38:7
+// CHECK: 103:16: UnexposedExpr=substr:60:13 Extent=[103:16 - 103:55]
+// CHECK: 103:16: CallExpr=substr:60:13 Extent=[103:16 - 103:55]
+// CHECK: 103:25: MemberRefExpr=substr:60:13 SingleRefName=[103:25 - 103:31] RefName=[103:25 - 103:31] Extent=[103:16 - 103:31]
+// CHECK: 103:16: UnexposedExpr=AttrName:101:19 Extent=[103:16 - 103:24]
+// CHECK: 103:16: DeclRefExpr=AttrName:101:19 Extent=[103:16 - 103:24]
+// CHECK: 103:32: UnexposedExpr= Extent=[103:32 - 103:33]
+// CHECK: 103:32: IntegerLiteral= Extent=[103:32 - 103:33]
+// CHECK: 103:35: BinaryOperator= Extent=[103:35 - 103:54]
+// CHECK: 103:35: CallExpr=size:51:10 Extent=[103:35 - 103:50]
+// CHECK: 103:44: MemberRefExpr=size:51:10 SingleRefName=[103:44 - 103:48] RefName=[103:44 - 103:48] Extent=[103:35 - 103:48]
+// CHECK: 103:35: UnexposedExpr=AttrName:101:19 Extent=[103:35 - 103:43]
+// CHECK: 103:35: DeclRefExpr=AttrName:101:19 Extent=[103:35 - 103:43]
+// CHECK: 103:53: UnexposedExpr= Extent=[103:53 - 103:54]
+// CHECK: 103:53: IntegerLiteral= Extent=[103:53 - 103:54]
+// CHECK: 105:3: ReturnStmt= Extent=[105:3 - 185:31]
+// CHECK: 105:10: CallExpr=Default:92:5 Extent=[105:10 - 185:31]
+// CHECK: 185:6: MemberRefExpr=Default:92:5 SingleRefName=[185:6 - 185:13] RefName=[185:6 - 185:13] Extent=[105:10 - 185:13]
+// CHECK: 105:10: UnexposedExpr=Case:88:42 Extent=[105:10 - 184:33]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 184:33]
+// CHECK: 184:6: MemberRefExpr=Case:88:42 SingleRefName=[184:6 - 184:10] RefName=[184:6 - 184:10] Extent=[105:10 - 184:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 183:37]
+// CHECK: 183:6: MemberRefExpr=Case:88:42 SingleRefName=[183:6 - 183:10] RefName=[183:6 - 183:10] Extent=[105:10 - 183:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 182:37]
+// CHECK: 182:6: MemberRefExpr=Case:88:42 SingleRefName=[182:6 - 182:10] RefName=[182:6 - 182:10] Extent=[105:10 - 182:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 181:35]
+// CHECK: 181:6: MemberRefExpr=Case:88:42 SingleRefName=[181:6 - 181:10] RefName=[181:6 - 181:10] Extent=[105:10 - 181:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 180:31]
+// CHECK: 180:6: MemberRefExpr=Case:88:42 SingleRefName=[180:6 - 180:10] RefName=[180:6 - 180:10] Extent=[105:10 - 180:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 179:31]
+// CHECK: 179:6: MemberRefExpr=Case:88:42 SingleRefName=[179:6 - 179:10] RefName=[179:6 - 179:10] Extent=[105:10 - 179:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 178:35]
+// CHECK: 178:6: MemberRefExpr=Case:88:42 SingleRefName=[178:6 - 178:10] RefName=[178:6 - 178:10] Extent=[105:10 - 178:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 177:63]
+// CHECK: 177:6: MemberRefExpr=Case:88:42 SingleRefName=[177:6 - 177:10] RefName=[177:6 - 177:10] Extent=[105:10 - 177:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 176:45]
+// CHECK: 176:6: MemberRefExpr=Case:88:42 SingleRefName=[176:6 - 176:10] RefName=[176:6 - 176:10] Extent=[105:10 - 176:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 175:51]
+// CHECK: 175:6: MemberRefExpr=Case:88:42 SingleRefName=[175:6 - 175:10] RefName=[175:6 - 175:10] Extent=[105:10 - 175:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 174:49]
+// CHECK: 174:6: MemberRefExpr=Case:88:42 SingleRefName=[174:6 - 174:10] RefName=[174:6 - 174:10] Extent=[105:10 - 174:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 173:49]
+// CHECK: 173:6: MemberRefExpr=Case:88:42 SingleRefName=[173:6 - 173:10] RefName=[173:6 - 173:10] Extent=[105:10 - 173:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 172:53]
+// CHECK: 172:6: MemberRefExpr=Case:88:42 SingleRefName=[172:6 - 172:10] RefName=[172:6 - 172:10] Extent=[105:10 - 172:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 171:57]
+// CHECK: 171:6: MemberRefExpr=Case:88:42 SingleRefName=[171:6 - 171:10] RefName=[171:6 - 171:10] Extent=[105:10 - 171:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 170:65]
+// CHECK: 170:6: MemberRefExpr=Case:88:42 SingleRefName=[170:6 - 170:10] RefName=[170:6 - 170:10] Extent=[105:10 - 170:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 169:57]
+// CHECK: 169:6: MemberRefExpr=Case:88:42 SingleRefName=[169:6 - 169:10] RefName=[169:6 - 169:10] Extent=[105:10 - 169:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 168:65]
+// CHECK: 168:6: MemberRefExpr=Case:88:42 SingleRefName=[168:6 - 168:10] RefName=[168:6 - 168:10] Extent=[105:10 - 168:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 167:55]
+// CHECK: 167:6: MemberRefExpr=Case:88:42 SingleRefName=[167:6 - 167:10] RefName=[167:6 - 167:10] Extent=[105:10 - 167:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 166:55]
+// CHECK: 166:6: MemberRefExpr=Case:88:42 SingleRefName=[166:6 - 166:10] RefName=[166:6 - 166:10] Extent=[105:10 - 166:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 165:53]
+// CHECK: 165:6: MemberRefExpr=Case:88:42 SingleRefName=[165:6 - 165:10] RefName=[165:6 - 165:10] Extent=[105:10 - 165:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 164:53]
+// CHECK: 164:6: MemberRefExpr=Case:88:42 SingleRefName=[164:6 - 164:10] RefName=[164:6 - 164:10] Extent=[105:10 - 164:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 163:49]
+// CHECK: 163:6: MemberRefExpr=Case:88:42 SingleRefName=[163:6 - 163:10] RefName=[163:6 - 163:10] Extent=[105:10 - 163:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 162:47]
+// CHECK: 162:6: MemberRefExpr=Case:88:42 SingleRefName=[162:6 - 162:10] RefName=[162:6 - 162:10] Extent=[105:10 - 162:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 161:45]
+// CHECK: 161:6: MemberRefExpr=Case:88:42 SingleRefName=[161:6 - 161:10] RefName=[161:6 - 161:10] Extent=[105:10 - 161:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 160:45]
+// CHECK: 160:6: MemberRefExpr=Case:88:42 SingleRefName=[160:6 - 160:10] RefName=[160:6 - 160:10] Extent=[105:10 - 160:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 159:45]
+// CHECK: 159:6: MemberRefExpr=Case:88:42 SingleRefName=[159:6 - 159:10] RefName=[159:6 - 159:10] Extent=[105:10 - 159:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 158:45]
+// CHECK: 158:6: MemberRefExpr=Case:88:42 SingleRefName=[158:6 - 158:10] RefName=[158:6 - 158:10] Extent=[105:10 - 158:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 157:43]
+// CHECK: 157:6: MemberRefExpr=Case:88:42 SingleRefName=[157:6 - 157:10] RefName=[157:6 - 157:10] Extent=[105:10 - 157:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 156:41]
+// CHECK: 156:6: MemberRefExpr=Case:88:42 SingleRefName=[156:6 - 156:10] RefName=[156:6 - 156:10] Extent=[105:10 - 156:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 155:41]
+// CHECK: 155:6: MemberRefExpr=Case:88:42 SingleRefName=[155:6 - 155:10] RefName=[155:6 - 155:10] Extent=[105:10 - 155:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 154:41]
+// CHECK: 154:6: MemberRefExpr=Case:88:42 SingleRefName=[154:6 - 154:10] RefName=[154:6 - 154:10] Extent=[105:10 - 154:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 153:37]
+// CHECK: 153:6: MemberRefExpr=Case:88:42 SingleRefName=[153:6 - 153:10] RefName=[153:6 - 153:10] Extent=[105:10 - 153:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 152:41]
+// CHECK: 152:6: MemberRefExpr=Case:88:42 SingleRefName=[152:6 - 152:10] RefName=[152:6 - 152:10] Extent=[105:10 - 152:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 151:39]
+// CHECK: 151:6: MemberRefExpr=Case:88:42 SingleRefName=[151:6 - 151:10] RefName=[151:6 - 151:10] Extent=[105:10 - 151:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 150:39]
+// CHECK: 150:6: MemberRefExpr=Case:88:42 SingleRefName=[150:6 - 150:10] RefName=[150:6 - 150:10] Extent=[105:10 - 150:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 149:39]
+// CHECK: 149:6: MemberRefExpr=Case:88:42 SingleRefName=[149:6 - 149:10] RefName=[149:6 - 149:10] Extent=[105:10 - 149:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 148:39]
+// CHECK: 148:6: MemberRefExpr=Case:88:42 SingleRefName=[148:6 - 148:10] RefName=[148:6 - 148:10] Extent=[105:10 - 148:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 147:39]
+// CHECK: 147:6: MemberRefExpr=Case:88:42 SingleRefName=[147:6 - 147:10] RefName=[147:6 - 147:10] Extent=[105:10 - 147:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 146:39]
+// CHECK: 146:6: MemberRefExpr=Case:88:42 SingleRefName=[146:6 - 146:10] RefName=[146:6 - 146:10] Extent=[105:10 - 146:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 145:41]
+// CHECK: 145:6: MemberRefExpr=Case:88:42 SingleRefName=[145:6 - 145:10] RefName=[145:6 - 145:10] Extent=[105:10 - 145:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 144:37]
+// CHECK: 144:6: MemberRefExpr=Case:88:42 SingleRefName=[144:6 - 144:10] RefName=[144:6 - 144:10] Extent=[105:10 - 144:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 143:37]
+// CHECK: 143:6: MemberRefExpr=Case:88:42 SingleRefName=[143:6 - 143:10] RefName=[143:6 - 143:10] Extent=[105:10 - 143:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 142:35]
+// CHECK: 142:6: MemberRefExpr=Case:88:42 SingleRefName=[142:6 - 142:10] RefName=[142:6 - 142:10] Extent=[105:10 - 142:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 141:35]
+// CHECK: 141:6: MemberRefExpr=Case:88:42 SingleRefName=[141:6 - 141:10] RefName=[141:6 - 141:10] Extent=[105:10 - 141:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 140:35]
+// CHECK: 140:6: MemberRefExpr=Case:88:42 SingleRefName=[140:6 - 140:10] RefName=[140:6 - 140:10] Extent=[105:10 - 140:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 139:35]
+// CHECK: 139:6: MemberRefExpr=Case:88:42 SingleRefName=[139:6 - 139:10] RefName=[139:6 - 139:10] Extent=[105:10 - 139:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 138:35]
+// CHECK: 138:6: MemberRefExpr=Case:88:42 SingleRefName=[138:6 - 138:10] RefName=[138:6 - 138:10] Extent=[105:10 - 138:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 137:55]
+// CHECK: 137:6: MemberRefExpr=Case:88:42 SingleRefName=[137:6 - 137:10] RefName=[137:6 - 137:10] Extent=[105:10 - 137:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 136:35]
+// CHECK: 136:6: MemberRefExpr=Case:88:42 SingleRefName=[136:6 - 136:10] RefName=[136:6 - 136:10] Extent=[105:10 - 136:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 135:35]
+// CHECK: 135:6: MemberRefExpr=Case:88:42 SingleRefName=[135:6 - 135:10] RefName=[135:6 - 135:10] Extent=[105:10 - 135:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 134:35]
+// CHECK: 134:6: MemberRefExpr=Case:88:42 SingleRefName=[134:6 - 134:10] RefName=[134:6 - 134:10] Extent=[105:10 - 134:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 133:35]
+// CHECK: 133:6: MemberRefExpr=Case:88:42 SingleRefName=[133:6 - 133:10] RefName=[133:6 - 133:10] Extent=[105:10 - 133:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 132:33]
+// CHECK: 132:6: MemberRefExpr=Case:88:42 SingleRefName=[132:6 - 132:10] RefName=[132:6 - 132:10] Extent=[105:10 - 132:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 131:33]
+// CHECK: 131:6: MemberRefExpr=Case:88:42 SingleRefName=[131:6 - 131:10] RefName=[131:6 - 131:10] Extent=[105:10 - 131:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 130:33]
+// CHECK: 130:6: MemberRefExpr=Case:88:42 SingleRefName=[130:6 - 130:10] RefName=[130:6 - 130:10] Extent=[105:10 - 130:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 129:33]
+// CHECK: 129:6: MemberRefExpr=Case:88:42 SingleRefName=[129:6 - 129:10] RefName=[129:6 - 129:10] Extent=[105:10 - 129:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 128:33]
+// CHECK: 128:6: MemberRefExpr=Case:88:42 SingleRefName=[128:6 - 128:10] RefName=[128:6 - 128:10] Extent=[105:10 - 128:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 127:33]
+// CHECK: 127:6: MemberRefExpr=Case:88:42 SingleRefName=[127:6 - 127:10] RefName=[127:6 - 127:10] Extent=[105:10 - 127:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 126:33]
+// CHECK: 126:6: MemberRefExpr=Case:88:42 SingleRefName=[126:6 - 126:10] RefName=[126:6 - 126:10] Extent=[105:10 - 126:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 125:29]
+// CHECK: 125:6: MemberRefExpr=Case:88:42 SingleRefName=[125:6 - 125:10] RefName=[125:6 - 125:10] Extent=[105:10 - 125:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 124:33]
+// CHECK: 124:6: MemberRefExpr=Case:88:42 SingleRefName=[124:6 - 124:10] RefName=[124:6 - 124:10] Extent=[105:10 - 124:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 123:33]
+// CHECK: 123:6: MemberRefExpr=Case:88:42 SingleRefName=[123:6 - 123:10] RefName=[123:6 - 123:10] Extent=[105:10 - 123:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 122:31]
+// CHECK: 122:6: MemberRefExpr=Case:88:42 SingleRefName=[122:6 - 122:10] RefName=[122:6 - 122:10] Extent=[105:10 - 122:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 121:31]
+// CHECK: 121:6: MemberRefExpr=Case:88:42 SingleRefName=[121:6 - 121:10] RefName=[121:6 - 121:10] Extent=[105:10 - 121:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 120:31]
+// CHECK: 120:6: MemberRefExpr=Case:88:42 SingleRefName=[120:6 - 120:10] RefName=[120:6 - 120:10] Extent=[105:10 - 120:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 119:31]
+// CHECK: 119:6: MemberRefExpr=Case:88:42 SingleRefName=[119:6 - 119:10] RefName=[119:6 - 119:10] Extent=[105:10 - 119:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 118:31]
+// CHECK: 118:6: MemberRefExpr=Case:88:42 SingleRefName=[118:6 - 118:10] RefName=[118:6 - 118:10] Extent=[105:10 - 118:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 117:31]
+// CHECK: 117:6: MemberRefExpr=Case:88:42 SingleRefName=[117:6 - 117:10] RefName=[117:6 - 117:10] Extent=[105:10 - 117:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 116:31]
+// CHECK: 116:6: MemberRefExpr=Case:88:42 SingleRefName=[116:6 - 116:10] RefName=[116:6 - 116:10] Extent=[105:10 - 116:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 115:29]
+// CHECK: 115:6: MemberRefExpr=Case:88:42 SingleRefName=[115:6 - 115:10] RefName=[115:6 - 115:10] Extent=[105:10 - 115:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 114:29]
+// CHECK: 114:6: MemberRefExpr=Case:88:42 SingleRefName=[114:6 - 114:10] RefName=[114:6 - 114:10] Extent=[105:10 - 114:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 113:29]
+// CHECK: 113:6: MemberRefExpr=Case:88:42 SingleRefName=[113:6 - 113:10] RefName=[113:6 - 113:10] Extent=[105:10 - 113:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 112:31]
+// CHECK: 112:6: MemberRefExpr=Case:88:42 SingleRefName=[112:6 - 112:10] RefName=[112:6 - 112:10] Extent=[105:10 - 112:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 111:29]
+// CHECK: 111:6: MemberRefExpr=Case:88:42 SingleRefName=[111:6 - 111:10] RefName=[111:6 - 111:10] Extent=[105:10 - 111:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 110:27]
+// CHECK: 110:6: MemberRefExpr=Case:88:42 SingleRefName=[110:6 - 110:10] RefName=[110:6 - 110:10] Extent=[105:10 - 110:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 109:27]
+// CHECK: 109:6: MemberRefExpr=Case:88:42 SingleRefName=[109:6 - 109:10] RefName=[109:6 - 109:10] Extent=[105:10 - 109:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 108:27]
+// CHECK: 108:6: MemberRefExpr=Case:88:42 SingleRefName=[108:6 - 108:10] RefName=[108:6 - 108:10] Extent=[105:10 - 108:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 107:33]
+// CHECK: 107:6: MemberRefExpr=Case:88:42 SingleRefName=[107:6 - 107:10] RefName=[107:6 - 107:10] Extent=[105:10 - 107:10]
+// CHECK: 105:10: CallExpr=Case:88:42 Extent=[105:10 - 106:27]
+// CHECK: 106:6: MemberRefExpr=Case:88:42 SingleRefName=[106:6 - 106:10] RefName=[106:6 - 106:10] Extent=[105:10 - 106:10]
+// CHECK: 105:10: CXXFunctionalCastExpr= Extent=[105:10 - 105:63]
+// CHECK: 105:16: TemplateRef=StringSwitch:83:47 Extent=[105:16 - 105:28]
+// CHECK: 105:10: CallExpr=StringSwitch:87:12 Extent=[105:10 - 105:62]
+// CHECK: 105:54: CallExpr=StringRef:38:7 Extent=[105:54 - 105:62]
+// CHECK: 105:54: UnexposedExpr=AttrName:101:19 Extent=[105:54 - 105:62]
+// CHECK: 105:54: DeclRefExpr=AttrName:101:19 Extent=[105:54 - 105:62]
+// CHECK: 106:11: StringLiteral= Extent=[106:11 - 106:17]
+// CHECK: 106:19: DeclRefExpr=AT_weak:29:45 Extent=[106:19 - 106:26]
+// CHECK: 107:11: StringLiteral= Extent=[107:11 - 107:20]
+// CHECK: 107:22: DeclRefExpr=AT_weakref:29:54 Extent=[107:22 - 107:32]
+// CHECK: 108:11: StringLiteral= Extent=[108:11 - 108:17]
+// CHECK: 108:19: DeclRefExpr=AT_pure:26:49 Extent=[108:19 - 108:26]
+// CHECK: 109:11: StringLiteral= Extent=[109:11 - 109:17]
+// CHECK: 109:19: DeclRefExpr=AT_mode:20:44 Extent=[109:19 - 109:26]
+// CHECK: 110:11: StringLiteral= Extent=[110:11 - 110:17]
+// CHECK: 110:19: DeclRefExpr=AT_used:28:34 Extent=[110:19 - 110:26]
+// CHECK: 111:11: StringLiteral= Extent=[111:11 - 111:18]
+// CHECK: 111:20: DeclRefExpr=AT_alias:15:25 Extent=[111:20 - 111:28]
+// CHECK: 112:11: StringLiteral= Extent=[112:11 - 112:18]
+// CHECK: 112:20: DeclRefExpr=AT_aligned:15:35 Extent=[112:20 - 112:30]
+// CHECK: 113:11: StringLiteral= Extent=[113:11 - 113:18]
+// CHECK: 113:20: DeclRefExpr=AT_final:19:40 Extent=[113:20 - 113:28]
+// CHECK: 114:11: StringLiteral= Extent=[114:11 - 114:18]
+// CHECK: 114:20: DeclRefExpr=AT_cdecl:17:30 Extent=[114:20 - 114:28]
+// CHECK: 115:11: StringLiteral= Extent=[115:11 - 115:18]
+// CHECK: 115:20: DeclRefExpr=AT_const:17:52 Extent=[115:20 - 115:28]
+// CHECK: 116:11: StringLiteral= Extent=[116:11 - 116:20]
+// CHECK: 116:22: DeclRefExpr=AT_const:17:52 Extent=[116:22 - 116:30]
+// CHECK: 117:11: StringLiteral= Extent=[117:11 - 117:19]
+// CHECK: 117:21: DeclRefExpr=AT_blocks:16:57 Extent=[117:21 - 117:30]
+// CHECK: 118:11: StringLiteral= Extent=[118:11 - 118:19]
+// CHECK: 118:21: DeclRefExpr=AT_format:19:50 Extent=[118:21 - 118:30]
+// CHECK: 119:11: StringLiteral= Extent=[119:11 - 119:19]
+// CHECK: 119:21: DeclRefExpr=AT_hiding:20:22 Extent=[119:21 - 119:30]
+// CHECK: 120:11: StringLiteral= Extent=[120:11 - 120:19]
+// CHECK: 120:21: DeclRefExpr=AT_malloc:20:33 Extent=[120:21 - 120:30]
+// CHECK: 121:11: StringLiteral= Extent=[121:11 - 121:19]
+// CHECK: 121:21: DeclRefExpr=AT_packed:26:27 Extent=[121:21 - 121:30]
+// CHECK: 122:11: StringLiteral= Extent=[122:11 - 122:19]
+// CHECK: 122:21: DeclRefExpr=AT_unused:28:23 Extent=[122:21 - 122:30]
+// CHECK: 123:11: StringLiteral= Extent=[123:11 - 123:20]
+// CHECK: 123:22: DeclRefExpr=AT_aligned:15:35 Extent=[123:22 - 123:32]
+// CHECK: 124:11: StringLiteral= Extent=[124:11 - 124:20]
+// CHECK: 124:22: DeclRefExpr=AT_cleanup:17:40 Extent=[124:22 - 124:32]
+// CHECK: 125:11: StringLiteral= Extent=[125:11 - 125:18]
+// CHECK: 125:20: DeclRefExpr=AT_naked:20:53 Extent=[125:20 - 125:28]
+// CHECK: 126:11: StringLiteral= Extent=[126:11 - 126:20]
+// CHECK: 126:22: DeclRefExpr=AT_nodebug:20:63 Extent=[126:22 - 126:32]
+// CHECK: 127:11: StringLiteral= Extent=[127:11 - 127:20]
+// CHECK: 127:22: DeclRefExpr=AT_nonnull:21:47 Extent=[127:22 - 127:32]
+// CHECK: 128:11: StringLiteral= Extent=[128:11 - 128:20]
+// CHECK: 128:22: DeclRefExpr=AT_nothrow:22:7 Extent=[128:22 - 128:32]
+// CHECK: 129:11: StringLiteral= Extent=[129:11 - 129:20]
+// CHECK: 129:22: DeclRefExpr=AT_objc_gc:24:59 Extent=[129:22 - 129:32]
+// CHECK: 130:11: StringLiteral= Extent=[130:11 - 130:20]
+// CHECK: 130:22: DeclRefExpr=AT_regparm:26:58 Extent=[130:22 - 130:32]
+// CHECK: 131:11: StringLiteral= Extent=[131:11 - 131:20]
+// CHECK: 131:22: DeclRefExpr=AT_section:27:7 Extent=[131:22 - 131:32]
+// CHECK: 132:11: StringLiteral= Extent=[132:11 - 132:20]
+// CHECK: 132:22: DeclRefExpr=AT_stdcall:27:32 Extent=[132:22 - 132:32]
+// CHECK: 133:11: StringLiteral= Extent=[133:11 - 133:21]
+// CHECK: 133:23: DeclRefExpr=AT_annotate:16:29 Extent=[133:23 - 133:34]
+// CHECK: 134:11: StringLiteral= Extent=[134:11 - 134:21]
+// CHECK: 134:23: DeclRefExpr=AT_fastcall:19:27 Extent=[134:23 - 134:34]
+// CHECK: 135:11: StringLiteral= Extent=[135:11 - 135:21]
+// CHECK: 135:23: DeclRefExpr=AT_IBAction:14:7 Extent=[135:23 - 135:34]
+// CHECK: 136:11: StringLiteral= Extent=[136:11 - 136:21]
+// CHECK: 136:23: DeclRefExpr=AT_IBOutlet:14:20 Extent=[136:23 - 136:34]
+// CHECK: 137:11: StringLiteral= Extent=[137:11 - 137:31]
+// CHECK: 137:33: DeclRefExpr=AT_IBOutletCollection:14:33 Extent=[137:33 - 137:54]
+// CHECK: 138:11: StringLiteral= Extent=[138:11 - 138:21]
+// CHECK: 138:23: DeclRefExpr=AT_noreturn:21:59 Extent=[138:23 - 138:34]
+// CHECK: 139:11: StringLiteral= Extent=[139:11 - 139:21]
+// CHECK: 139:23: DeclRefExpr=AT_noinline:21:7 Extent=[139:23 - 139:34]
+// CHECK: 140:11: StringLiteral= Extent=[140:11 - 140:21]
+// CHECK: 140:23: DeclRefExpr=AT_override:22:51 Extent=[140:23 - 140:34]
+// CHECK: 141:11: StringLiteral= Extent=[141:11 - 141:21]
+// CHECK: 141:23: DeclRefExpr=AT_sentinel:27:19 Extent=[141:23 - 141:34]
+// CHECK: 142:11: StringLiteral= Extent=[142:11 - 142:21]
+// CHECK: 142:23: DeclRefExpr=AT_nsobject:22:19 Extent=[142:23 - 142:34]
+// CHECK: 143:11: StringLiteral= Extent=[143:11 - 143:22]
+// CHECK: 143:24: DeclRefExpr=AT_dllimport:18:51 Extent=[143:24 - 143:36]
+// CHECK: 144:11: StringLiteral= Extent=[144:11 - 144:22]
+// CHECK: 144:24: DeclRefExpr=AT_dllexport:18:37 Extent=[144:24 - 144:36]
+// CHECK: 145:11: StringLiteral= Extent=[145:11 - 145:22]
+// CHECK: 146:11: StringLiteral= Extent=[146:11 - 146:23]
+// CHECK: 146:25: DeclRefExpr=AT_base_check:16:42 Extent=[146:25 - 146:38]
+// CHECK: 147:11: StringLiteral= Extent=[147:11 - 147:23]
+// CHECK: 147:25: DeclRefExpr=AT_deprecated:18:7 Extent=[147:25 - 147:38]
+// CHECK: 148:11: StringLiteral= Extent=[148:11 - 148:23]
+// CHECK: 148:25: DeclRefExpr=AT_visibility:29:7 Extent=[148:25 - 148:38]
+// CHECK: 149:11: StringLiteral= Extent=[149:11 - 149:23]
+// CHECK: 149:25: DeclRefExpr=AT_destructor:18:22 Extent=[149:25 - 149:38]
+// CHECK: 150:11: StringLiteral= Extent=[150:11 - 150:23]
+// CHECK: 150:25: DeclRefExpr=AT_format_arg:19:61 Extent=[150:25 - 150:38]
+// CHECK: 151:11: StringLiteral= Extent=[151:11 - 151:23]
+// CHECK: 151:25: DeclRefExpr=AT_gnu_inline:20:7 Extent=[151:25 - 151:38]
+// CHECK: 152:11: StringLiteral= Extent=[152:11 - 152:24]
+// CHECK: 152:26: DeclRefExpr=AT_weak_import:30:7 Extent=[152:26 - 152:40]
+// CHECK: 153:11: StringLiteral= Extent=[153:11 - 153:22]
+// CHECK: 153:24: DeclRefExpr=AT_vecreturn:28:43 Extent=[153:24 - 153:36]
+// CHECK: 154:11: StringLiteral= Extent=[154:11 - 154:24]
+// CHECK: 154:26: DeclRefExpr=AT_vector_size:28:57 Extent=[154:26 - 154:40]
+// CHECK: 155:11: StringLiteral= Extent=[155:11 - 155:24]
+// CHECK: 155:26: DeclRefExpr=AT_constructor:17:62 Extent=[155:26 - 155:40]
+// CHECK: 156:11: StringLiteral= Extent=[156:11 - 156:24]
+// CHECK: 156:26: DeclRefExpr=AT_unavailable:28:7 Extent=[156:26 - 156:40]
+// CHECK: 157:11: StringLiteral= Extent=[157:11 - 157:25]
+// CHECK: 157:27: DeclRefExpr=AT_overloadable:25:7 Extent=[157:27 - 157:42]
+// CHECK: 158:11: StringLiteral= Extent=[158:11 - 158:26]
+// CHECK: 158:28: DeclRefExpr=AT_address_space:15:7 Extent=[158:28 - 158:44]
+// CHECK: 159:11: StringLiteral= Extent=[159:11 - 159:26]
+// CHECK: 159:28: DeclRefExpr=AT_always_inline:15:47 Extent=[159:28 - 159:44]
+// CHECK: 160:11: StringLiteral= Extent=[160:11 - 160:26]
+// CHECK: 161:11: StringLiteral= Extent=[161:11 - 161:26]
+// CHECK: 162:11: StringLiteral= Extent=[162:11 - 162:27]
+// CHECK: 162:29: DeclRefExpr=AT_objc_exception:22:32 Extent=[162:29 - 162:46]
+// CHECK: 163:11: StringLiteral= Extent=[163:11 - 163:28]
+// CHECK: 163:30: DeclRefExpr=AT_ext_vector_type:19:7 Extent=[163:30 - 163:48]
+// CHECK: 164:11: StringLiteral= Extent=[164:11 - 164:30]
+// CHECK: 164:32: DeclRefExpr=AT_transparent_union:27:57 Extent=[164:32 - 164:52]
+// CHECK: 165:11: StringLiteral= Extent=[165:11 - 165:30]
+// CHECK: 165:32: DeclRefExpr=AT_analyzer_noreturn:16:7 Extent=[165:32 - 165:52]
+// CHECK: 166:11: StringLiteral= Extent=[166:11 - 166:31]
+// CHECK: 166:33: DeclRefExpr=AT_warn_unused_result:29:22 Extent=[166:33 - 166:54]
+// CHECK: 167:11: StringLiteral= Extent=[167:11 - 167:31]
+// CHECK: 167:33: DeclRefExpr=AT_carries_dependency:17:7 Extent=[167:33 - 167:54]
+// CHECK: 168:11: StringLiteral= Extent=[168:11 - 168:36]
+// CHECK: 168:38: DeclRefExpr=AT_ns_returns_not_retained:24:7 Extent=[168:38 - 168:64]
+// CHECK: 169:11: StringLiteral= Extent=[169:11 - 169:32]
+// CHECK: 169:34: DeclRefExpr=AT_ns_returns_retained:24:35 Extent=[169:34 - 169:56]
+// CHECK: 170:11: StringLiteral= Extent=[170:11 - 170:36]
+// CHECK: 170:38: DeclRefExpr=AT_cf_returns_not_retained:23:7 Extent=[170:38 - 170:64]
+// CHECK: 171:11: StringLiteral= Extent=[171:11 - 171:32]
+// CHECK: 171:34: DeclRefExpr=AT_cf_returns_retained:23:35 Extent=[171:34 - 171:56]
+// CHECK: 172:11: StringLiteral= Extent=[172:11 - 172:30]
+// CHECK: 172:32: DeclRefExpr=AT_ownership_returns:25:44 Extent=[172:32 - 172:52]
+// CHECK: 173:11: StringLiteral= Extent=[173:11 - 173:28]
+// CHECK: 173:30: DeclRefExpr=AT_ownership_holds:25:24 Extent=[173:30 - 173:48]
+// CHECK: 174:11: StringLiteral= Extent=[174:11 - 174:28]
+// CHECK: 174:30: DeclRefExpr=AT_ownership_takes:26:7 Extent=[174:30 - 174:48]
+// CHECK: 175:11: StringLiteral= Extent=[175:11 - 175:33]
+// CHECK: 175:35: DeclRefExpr=AT_reqd_wg_size:30:23 Extent=[175:35 - 175:50]
+// CHECK: 176:11: StringLiteral= Extent=[176:11 - 176:26]
+// CHECK: 176:28: DeclRefExpr=AT_init_priority:30:40 Extent=[176:28 - 176:44]
+// CHECK: 177:11: StringLiteral= Extent=[177:11 - 177:35]
+// CHECK: 177:37: DeclRefExpr=AT_no_instrument_function:21:20 Extent=[177:37 - 177:62]
+// CHECK: 178:11: StringLiteral= Extent=[178:11 - 178:21]
+// CHECK: 178:23: DeclRefExpr=AT_thiscall:27:44 Extent=[178:23 - 178:34]
+// CHECK: 179:11: StringLiteral= Extent=[179:11 - 179:19]
+// CHECK: 179:21: DeclRefExpr=AT_pascal:26:38 Extent=[179:21 - 179:30]
+// CHECK: 180:11: StringLiteral= Extent=[180:11 - 180:20]
+// CHECK: 180:22: DeclRefExpr=AT_cdecl:17:30 Extent=[180:22 - 180:30]
+// CHECK: 181:11: StringLiteral= Extent=[181:11 - 181:22]
+// CHECK: 181:24: DeclRefExpr=AT_stdcall:27:32 Extent=[181:24 - 181:34]
+// CHECK: 182:11: StringLiteral= Extent=[182:11 - 182:23]
+// CHECK: 182:25: DeclRefExpr=AT_fastcall:19:27 Extent=[182:25 - 182:36]
+// CHECK: 183:11: StringLiteral= Extent=[183:11 - 183:23]
+// CHECK: 183:25: DeclRefExpr=AT_thiscall:27:44 Extent=[183:25 - 183:36]
+// CHECK: 184:11: StringLiteral= Extent=[184:11 - 184:21]
+// CHECK: 184:23: DeclRefExpr=AT_pascal:26:38 Extent=[184:23 - 184:32]
+
diff --git a/clang/test/Index/recursive-member-access.c b/clang/test/Index/recursive-member-access.c
new file mode 100644
index 0000000..6a19f57
--- /dev/null
+++ b/clang/test/Index/recursive-member-access.c
@@ -0,0 +1,532 @@
+struct rdar8650865 {
+ struct rdar8650865 *first;
+ int x;
+};
+
+int test_rdar8650865(struct rdar8650865 *s) {
+ return ((((((s->first)->first)
+ ->first)
+ ->first)
+ ->first)
+ ->first)
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->first
+ ->x;
+}
+
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+// CHECK: 1:8: StructDecl=rdar8650865:1:8 (Definition) Extent=[1:1 - 4:2]
+// CHECK: 2:23: FieldDecl=first:2:23 (Definition) Extent=[2:3 - 2:28]
+// CHECK: 2:10: TypeRef=struct rdar8650865:1:8 Extent=[2:10 - 2:21]
+// CHECK: 3:7: FieldDecl=x:3:7 (Definition) Extent=[3:3 - 3:8]
+// CHECK: 6:5: FunctionDecl=test_rdar8650865:6:5 (Definition) Extent=[6:1 - 124:2]
+// CHECK: 6:42: ParmDecl=s:6:42 (Definition) Extent=[6:22 - 6:43]
+// CHECK: 6:29: TypeRef=struct rdar8650865:1:8 Extent=[6:29 - 6:40]
+// CHECK: 6:45: CompoundStmt= Extent=[6:45 - 124:2]
+// CHECK: 7:3: ReturnStmt= Extent=[7:3 - 123:8]
+// CHECK: 123:7: MemberRefExpr=x:3:7 SingleRefName=[123:7 - 123:8] RefName=[123:7 - 123:8] Extent=[7:10 - 123:8]
+// CHECK: 122:7: MemberRefExpr=first:2:23 SingleRefName=[122:7 - 122:12] RefName=[122:7 - 122:12] Extent=[7:10 - 122:12]
+// CHECK: 121:7: MemberRefExpr=first:2:23 SingleRefName=[121:7 - 121:12] RefName=[121:7 - 121:12] Extent=[7:10 - 121:12]
+// CHECK: 120:7: MemberRefExpr=first:2:23 SingleRefName=[120:7 - 120:12] RefName=[120:7 - 120:12] Extent=[7:10 - 120:12]
+// CHECK: 119:7: MemberRefExpr=first:2:23 SingleRefName=[119:7 - 119:12] RefName=[119:7 - 119:12] Extent=[7:10 - 119:12]
+// CHECK: 118:7: MemberRefExpr=first:2:23 SingleRefName=[118:7 - 118:12] RefName=[118:7 - 118:12] Extent=[7:10 - 118:12]
+// CHECK: 117:7: MemberRefExpr=first:2:23 SingleRefName=[117:7 - 117:12] RefName=[117:7 - 117:12] Extent=[7:10 - 117:12]
+// CHECK: 116:7: MemberRefExpr=first:2:23 SingleRefName=[116:7 - 116:12] RefName=[116:7 - 116:12] Extent=[7:10 - 116:12]
+// CHECK: 115:7: MemberRefExpr=first:2:23 SingleRefName=[115:7 - 115:12] RefName=[115:7 - 115:12] Extent=[7:10 - 115:12]
+// CHECK: 114:7: MemberRefExpr=first:2:23 SingleRefName=[114:7 - 114:12] RefName=[114:7 - 114:12] Extent=[7:10 - 114:12]
+// CHECK: 113:7: MemberRefExpr=first:2:23 SingleRefName=[113:7 - 113:12] RefName=[113:7 - 113:12] Extent=[7:10 - 113:12]
+// CHECK: 112:7: MemberRefExpr=first:2:23 SingleRefName=[112:7 - 112:12] RefName=[112:7 - 112:12] Extent=[7:10 - 112:12]
+// CHECK: 111:7: MemberRefExpr=first:2:23 SingleRefName=[111:7 - 111:12] RefName=[111:7 - 111:12] Extent=[7:10 - 111:12]
+// CHECK: 110:7: MemberRefExpr=first:2:23 SingleRefName=[110:7 - 110:12] RefName=[110:7 - 110:12] Extent=[7:10 - 110:12]
+// CHECK: 109:7: MemberRefExpr=first:2:23 SingleRefName=[109:7 - 109:12] RefName=[109:7 - 109:12] Extent=[7:10 - 109:12]
+// CHECK: 108:7: MemberRefExpr=first:2:23 SingleRefName=[108:7 - 108:12] RefName=[108:7 - 108:12] Extent=[7:10 - 108:12]
+// CHECK: 107:7: MemberRefExpr=first:2:23 SingleRefName=[107:7 - 107:12] RefName=[107:7 - 107:12] Extent=[7:10 - 107:12]
+// CHECK: 106:7: MemberRefExpr=first:2:23 SingleRefName=[106:7 - 106:12] RefName=[106:7 - 106:12] Extent=[7:10 - 106:12]
+// CHECK: 105:7: MemberRefExpr=first:2:23 SingleRefName=[105:7 - 105:12] RefName=[105:7 - 105:12] Extent=[7:10 - 105:12]
+// CHECK: 104:7: MemberRefExpr=first:2:23 SingleRefName=[104:7 - 104:12] RefName=[104:7 - 104:12] Extent=[7:10 - 104:12]
+// CHECK: 103:7: MemberRefExpr=first:2:23 SingleRefName=[103:7 - 103:12] RefName=[103:7 - 103:12] Extent=[7:10 - 103:12]
+// CHECK: 102:7: MemberRefExpr=first:2:23 SingleRefName=[102:7 - 102:12] RefName=[102:7 - 102:12] Extent=[7:10 - 102:12]
+// CHECK: 101:7: MemberRefExpr=first:2:23 SingleRefName=[101:7 - 101:12] RefName=[101:7 - 101:12] Extent=[7:10 - 101:12]
+// CHECK: 100:7: MemberRefExpr=first:2:23 SingleRefName=[100:7 - 100:12] RefName=[100:7 - 100:12] Extent=[7:10 - 100:12]
+// CHECK: 99:7: MemberRefExpr=first:2:23 SingleRefName=[99:7 - 99:12] RefName=[99:7 - 99:12] Extent=[7:10 - 99:12]
+// CHECK: 98:7: MemberRefExpr=first:2:23 SingleRefName=[98:7 - 98:12] RefName=[98:7 - 98:12] Extent=[7:10 - 98:12]
+// CHECK: 97:7: MemberRefExpr=first:2:23 SingleRefName=[97:7 - 97:12] RefName=[97:7 - 97:12] Extent=[7:10 - 97:12]
+// CHECK: 96:7: MemberRefExpr=first:2:23 SingleRefName=[96:7 - 96:12] RefName=[96:7 - 96:12] Extent=[7:10 - 96:12]
+// CHECK: 95:7: MemberRefExpr=first:2:23 SingleRefName=[95:7 - 95:12] RefName=[95:7 - 95:12] Extent=[7:10 - 95:12]
+// CHECK: 94:7: MemberRefExpr=first:2:23 SingleRefName=[94:7 - 94:12] RefName=[94:7 - 94:12] Extent=[7:10 - 94:12]
+// CHECK: 93:7: MemberRefExpr=first:2:23 SingleRefName=[93:7 - 93:12] RefName=[93:7 - 93:12] Extent=[7:10 - 93:12]
+// CHECK: 92:7: MemberRefExpr=first:2:23 SingleRefName=[92:7 - 92:12] RefName=[92:7 - 92:12] Extent=[7:10 - 92:12]
+// CHECK: 91:7: MemberRefExpr=first:2:23 SingleRefName=[91:7 - 91:12] RefName=[91:7 - 91:12] Extent=[7:10 - 91:12]
+// CHECK: 90:7: MemberRefExpr=first:2:23 SingleRefName=[90:7 - 90:12] RefName=[90:7 - 90:12] Extent=[7:10 - 90:12]
+// CHECK: 89:7: MemberRefExpr=first:2:23 SingleRefName=[89:7 - 89:12] RefName=[89:7 - 89:12] Extent=[7:10 - 89:12]
+// CHECK: 88:7: MemberRefExpr=first:2:23 SingleRefName=[88:7 - 88:12] RefName=[88:7 - 88:12] Extent=[7:10 - 88:12]
+// CHECK: 87:7: MemberRefExpr=first:2:23 SingleRefName=[87:7 - 87:12] RefName=[87:7 - 87:12] Extent=[7:10 - 87:12]
+// CHECK: 86:7: MemberRefExpr=first:2:23 SingleRefName=[86:7 - 86:12] RefName=[86:7 - 86:12] Extent=[7:10 - 86:12]
+// CHECK: 85:7: MemberRefExpr=first:2:23 SingleRefName=[85:7 - 85:12] RefName=[85:7 - 85:12] Extent=[7:10 - 85:12]
+// CHECK: 84:7: MemberRefExpr=first:2:23 SingleRefName=[84:7 - 84:12] RefName=[84:7 - 84:12] Extent=[7:10 - 84:12]
+// CHECK: 83:7: MemberRefExpr=first:2:23 SingleRefName=[83:7 - 83:12] RefName=[83:7 - 83:12] Extent=[7:10 - 83:12]
+// CHECK: 82:7: MemberRefExpr=first:2:23 SingleRefName=[82:7 - 82:12] RefName=[82:7 - 82:12] Extent=[7:10 - 82:12]
+// CHECK: 81:7: MemberRefExpr=first:2:23 SingleRefName=[81:7 - 81:12] RefName=[81:7 - 81:12] Extent=[7:10 - 81:12]
+// CHECK: 80:7: MemberRefExpr=first:2:23 SingleRefName=[80:7 - 80:12] RefName=[80:7 - 80:12] Extent=[7:10 - 80:12]
+// CHECK: 79:7: MemberRefExpr=first:2:23 SingleRefName=[79:7 - 79:12] RefName=[79:7 - 79:12] Extent=[7:10 - 79:12]
+// CHECK: 78:7: MemberRefExpr=first:2:23 SingleRefName=[78:7 - 78:12] RefName=[78:7 - 78:12] Extent=[7:10 - 78:12]
+// CHECK: 77:7: MemberRefExpr=first:2:23 SingleRefName=[77:7 - 77:12] RefName=[77:7 - 77:12] Extent=[7:10 - 77:12]
+// CHECK: 76:7: MemberRefExpr=first:2:23 SingleRefName=[76:7 - 76:12] RefName=[76:7 - 76:12] Extent=[7:10 - 76:12]
+// CHECK: 75:7: MemberRefExpr=first:2:23 SingleRefName=[75:7 - 75:12] RefName=[75:7 - 75:12] Extent=[7:10 - 75:12]
+// CHECK: 74:7: MemberRefExpr=first:2:23 SingleRefName=[74:7 - 74:12] RefName=[74:7 - 74:12] Extent=[7:10 - 74:12]
+// CHECK: 73:7: MemberRefExpr=first:2:23 SingleRefName=[73:7 - 73:12] RefName=[73:7 - 73:12] Extent=[7:10 - 73:12]
+// CHECK: 72:7: MemberRefExpr=first:2:23 SingleRefName=[72:7 - 72:12] RefName=[72:7 - 72:12] Extent=[7:10 - 72:12]
+// CHECK: 71:7: MemberRefExpr=first:2:23 SingleRefName=[71:7 - 71:12] RefName=[71:7 - 71:12] Extent=[7:10 - 71:12]
+// CHECK: 70:7: MemberRefExpr=first:2:23 SingleRefName=[70:7 - 70:12] RefName=[70:7 - 70:12] Extent=[7:10 - 70:12]
+// CHECK: 69:7: MemberRefExpr=first:2:23 SingleRefName=[69:7 - 69:12] RefName=[69:7 - 69:12] Extent=[7:10 - 69:12]
+// CHECK: 68:7: MemberRefExpr=first:2:23 SingleRefName=[68:7 - 68:12] RefName=[68:7 - 68:12] Extent=[7:10 - 68:12]
+// CHECK: 67:7: MemberRefExpr=first:2:23 SingleRefName=[67:7 - 67:12] RefName=[67:7 - 67:12] Extent=[7:10 - 67:12]
+// CHECK: 66:7: MemberRefExpr=first:2:23 SingleRefName=[66:7 - 66:12] RefName=[66:7 - 66:12] Extent=[7:10 - 66:12]
+// CHECK: 65:7: MemberRefExpr=first:2:23 SingleRefName=[65:7 - 65:12] RefName=[65:7 - 65:12] Extent=[7:10 - 65:12]
+// CHECK: 64:7: MemberRefExpr=first:2:23 SingleRefName=[64:7 - 64:12] RefName=[64:7 - 64:12] Extent=[7:10 - 64:12]
+// CHECK: 63:7: MemberRefExpr=first:2:23 SingleRefName=[63:7 - 63:12] RefName=[63:7 - 63:12] Extent=[7:10 - 63:12]
+// CHECK: 62:7: MemberRefExpr=first:2:23 SingleRefName=[62:7 - 62:12] RefName=[62:7 - 62:12] Extent=[7:10 - 62:12]
+// CHECK: 61:7: MemberRefExpr=first:2:23 SingleRefName=[61:7 - 61:12] RefName=[61:7 - 61:12] Extent=[7:10 - 61:12]
+// CHECK: 60:7: MemberRefExpr=first:2:23 SingleRefName=[60:7 - 60:12] RefName=[60:7 - 60:12] Extent=[7:10 - 60:12]
+// CHECK: 59:7: MemberRefExpr=first:2:23 SingleRefName=[59:7 - 59:12] RefName=[59:7 - 59:12] Extent=[7:10 - 59:12]
+// CHECK: 58:7: MemberRefExpr=first:2:23 SingleRefName=[58:7 - 58:12] RefName=[58:7 - 58:12] Extent=[7:10 - 58:12]
+// CHECK: 57:7: MemberRefExpr=first:2:23 SingleRefName=[57:7 - 57:12] RefName=[57:7 - 57:12] Extent=[7:10 - 57:12]
+// CHECK: 56:7: MemberRefExpr=first:2:23 SingleRefName=[56:7 - 56:12] RefName=[56:7 - 56:12] Extent=[7:10 - 56:12]
+// CHECK: 55:7: MemberRefExpr=first:2:23 SingleRefName=[55:7 - 55:12] RefName=[55:7 - 55:12] Extent=[7:10 - 55:12]
+// CHECK: 54:7: MemberRefExpr=first:2:23 SingleRefName=[54:7 - 54:12] RefName=[54:7 - 54:12] Extent=[7:10 - 54:12]
+// CHECK: 53:7: MemberRefExpr=first:2:23 SingleRefName=[53:7 - 53:12] RefName=[53:7 - 53:12] Extent=[7:10 - 53:12]
+// CHECK: 52:7: MemberRefExpr=first:2:23 SingleRefName=[52:7 - 52:12] RefName=[52:7 - 52:12] Extent=[7:10 - 52:12]
+// CHECK: 51:7: MemberRefExpr=first:2:23 SingleRefName=[51:7 - 51:12] RefName=[51:7 - 51:12] Extent=[7:10 - 51:12]
+// CHECK: 50:7: MemberRefExpr=first:2:23 SingleRefName=[50:7 - 50:12] RefName=[50:7 - 50:12] Extent=[7:10 - 50:12]
+// CHECK: 49:7: MemberRefExpr=first:2:23 SingleRefName=[49:7 - 49:12] RefName=[49:7 - 49:12] Extent=[7:10 - 49:12]
+// CHECK: 48:7: MemberRefExpr=first:2:23 SingleRefName=[48:7 - 48:12] RefName=[48:7 - 48:12] Extent=[7:10 - 48:12]
+// CHECK: 47:7: MemberRefExpr=first:2:23 SingleRefName=[47:7 - 47:12] RefName=[47:7 - 47:12] Extent=[7:10 - 47:12]
+// CHECK: 46:7: MemberRefExpr=first:2:23 SingleRefName=[46:7 - 46:12] RefName=[46:7 - 46:12] Extent=[7:10 - 46:12]
+// CHECK: 45:7: MemberRefExpr=first:2:23 SingleRefName=[45:7 - 45:12] RefName=[45:7 - 45:12] Extent=[7:10 - 45:12]
+// CHECK: 44:7: MemberRefExpr=first:2:23 SingleRefName=[44:7 - 44:12] RefName=[44:7 - 44:12] Extent=[7:10 - 44:12]
+// CHECK: 43:7: MemberRefExpr=first:2:23 SingleRefName=[43:7 - 43:12] RefName=[43:7 - 43:12] Extent=[7:10 - 43:12]
+// CHECK: 42:7: MemberRefExpr=first:2:23 SingleRefName=[42:7 - 42:12] RefName=[42:7 - 42:12] Extent=[7:10 - 42:12]
+// CHECK: 41:7: MemberRefExpr=first:2:23 SingleRefName=[41:7 - 41:12] RefName=[41:7 - 41:12] Extent=[7:10 - 41:12]
+// CHECK: 40:7: MemberRefExpr=first:2:23 SingleRefName=[40:7 - 40:12] RefName=[40:7 - 40:12] Extent=[7:10 - 40:12]
+// CHECK: 39:7: MemberRefExpr=first:2:23 SingleRefName=[39:7 - 39:12] RefName=[39:7 - 39:12] Extent=[7:10 - 39:12]
+// CHECK: 38:7: MemberRefExpr=first:2:23 SingleRefName=[38:7 - 38:12] RefName=[38:7 - 38:12] Extent=[7:10 - 38:12]
+// CHECK: 37:7: MemberRefExpr=first:2:23 SingleRefName=[37:7 - 37:12] RefName=[37:7 - 37:12] Extent=[7:10 - 37:12]
+// CHECK: 36:7: MemberRefExpr=first:2:23 SingleRefName=[36:7 - 36:12] RefName=[36:7 - 36:12] Extent=[7:10 - 36:12]
+// CHECK: 35:7: MemberRefExpr=first:2:23 SingleRefName=[35:7 - 35:12] RefName=[35:7 - 35:12] Extent=[7:10 - 35:12]
+// CHECK: 34:7: MemberRefExpr=first:2:23 SingleRefName=[34:7 - 34:12] RefName=[34:7 - 34:12] Extent=[7:10 - 34:12]
+// CHECK: 33:7: MemberRefExpr=first:2:23 SingleRefName=[33:7 - 33:12] RefName=[33:7 - 33:12] Extent=[7:10 - 33:12]
+// CHECK: 32:7: MemberRefExpr=first:2:23 SingleRefName=[32:7 - 32:12] RefName=[32:7 - 32:12] Extent=[7:10 - 32:12]
+// CHECK: 31:7: MemberRefExpr=first:2:23 SingleRefName=[31:7 - 31:12] RefName=[31:7 - 31:12] Extent=[7:10 - 31:12]
+// CHECK: 30:7: MemberRefExpr=first:2:23 SingleRefName=[30:7 - 30:12] RefName=[30:7 - 30:12] Extent=[7:10 - 30:12]
+// CHECK: 29:7: MemberRefExpr=first:2:23 SingleRefName=[29:7 - 29:12] RefName=[29:7 - 29:12] Extent=[7:10 - 29:12]
+// CHECK: 28:7: MemberRefExpr=first:2:23 SingleRefName=[28:7 - 28:12] RefName=[28:7 - 28:12] Extent=[7:10 - 28:12]
+// CHECK: 27:7: MemberRefExpr=first:2:23 SingleRefName=[27:7 - 27:12] RefName=[27:7 - 27:12] Extent=[7:10 - 27:12]
+// CHECK: 26:7: MemberRefExpr=first:2:23 SingleRefName=[26:7 - 26:12] RefName=[26:7 - 26:12] Extent=[7:10 - 26:12]
+// CHECK: 25:7: MemberRefExpr=first:2:23 SingleRefName=[25:7 - 25:12] RefName=[25:7 - 25:12] Extent=[7:10 - 25:12]
+// CHECK: 24:7: MemberRefExpr=first:2:23 SingleRefName=[24:7 - 24:12] RefName=[24:7 - 24:12] Extent=[7:10 - 24:12]
+// CHECK: 23:7: MemberRefExpr=first:2:23 SingleRefName=[23:7 - 23:12] RefName=[23:7 - 23:12] Extent=[7:10 - 23:12]
+// CHECK: 22:7: MemberRefExpr=first:2:23 SingleRefName=[22:7 - 22:12] RefName=[22:7 - 22:12] Extent=[7:10 - 22:12]
+// CHECK: 21:7: MemberRefExpr=first:2:23 SingleRefName=[21:7 - 21:12] RefName=[21:7 - 21:12] Extent=[7:10 - 21:12]
+// CHECK: 20:7: MemberRefExpr=first:2:23 SingleRefName=[20:7 - 20:12] RefName=[20:7 - 20:12] Extent=[7:10 - 20:12]
+// CHECK: 19:7: MemberRefExpr=first:2:23 SingleRefName=[19:7 - 19:12] RefName=[19:7 - 19:12] Extent=[7:10 - 19:12]
+// CHECK: 18:7: MemberRefExpr=first:2:23 SingleRefName=[18:7 - 18:12] RefName=[18:7 - 18:12] Extent=[7:10 - 18:12]
+// CHECK: 17:7: MemberRefExpr=first:2:23 SingleRefName=[17:7 - 17:12] RefName=[17:7 - 17:12] Extent=[7:10 - 17:12]
+// CHECK: 16:7: MemberRefExpr=first:2:23 SingleRefName=[16:7 - 16:12] RefName=[16:7 - 16:12] Extent=[7:10 - 16:12]
+// CHECK: 15:7: MemberRefExpr=first:2:23 SingleRefName=[15:7 - 15:12] RefName=[15:7 - 15:12] Extent=[7:10 - 15:12]
+// CHECK: 14:7: MemberRefExpr=first:2:23 SingleRefName=[14:7 - 14:12] RefName=[14:7 - 14:12] Extent=[7:10 - 14:12]
+// CHECK: 13:7: MemberRefExpr=first:2:23 SingleRefName=[13:7 - 13:12] RefName=[13:7 - 13:12] Extent=[7:10 - 13:12]
+// CHECK: 12:7: MemberRefExpr=first:2:23 SingleRefName=[12:7 - 12:12] RefName=[12:7 - 12:12] Extent=[7:10 - 12:12]
+// CHECK: 11:7: MemberRefExpr=first:2:23 SingleRefName=[11:7 - 11:12] RefName=[11:7 - 11:12] Extent=[7:11 - 11:12]
+// CHECK: 10:7: MemberRefExpr=first:2:23 SingleRefName=[10:7 - 10:12] RefName=[10:7 - 10:12] Extent=[7:12 - 10:12]
+// CHECK: 9:7: MemberRefExpr=first:2:23 SingleRefName=[9:7 - 9:12] RefName=[9:7 - 9:12] Extent=[7:13 - 9:12]
+// CHECK: 8:7: MemberRefExpr=first:2:23 SingleRefName=[8:7 - 8:12] RefName=[8:7 - 8:12] Extent=[7:14 - 8:12]
+// CHECK: 7:27: MemberRefExpr=first:2:23 SingleRefName=[7:27 - 7:32] RefName=[7:27 - 7:32] Extent=[7:15 - 7:32]
+// CHECK: 7:19: MemberRefExpr=first:2:23 SingleRefName=[7:19 - 7:24] RefName=[7:19 - 7:24] Extent=[7:16 - 7:24]
+// CHECK: 7:16: DeclRefExpr=s:6:42 Extent=[7:16 - 7:17]
+
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:124:1 %s | FileCheck -check-prefix=CHECK-tokens %s
+// CHECK-tokens: Keyword: "struct" [1:1 - 1:7] StructDecl=rdar8650865:1:8 (Definition)
+// CHECK-tokens: Identifier: "rdar8650865" [1:8 - 1:19] StructDecl=rdar8650865:1:8 (Definition)
+// CHECK-tokens: Punctuation: "{" [1:20 - 1:21] StructDecl=rdar8650865:1:8 (Definition)
+// CHECK-tokens: Keyword: "struct" [2:3 - 2:9] FieldDecl=first:2:23 (Definition)
+// CHECK-tokens: Identifier: "rdar8650865" [2:10 - 2:21] TypeRef=struct rdar8650865:1:8
+// CHECK-tokens: Punctuation: "*" [2:22 - 2:23] FieldDecl=first:2:23 (Definition)
+// CHECK-tokens: Identifier: "first" [2:23 - 2:28] FieldDecl=first:2:23 (Definition)
+// CHECK-tokens: Punctuation: ";" [2:28 - 2:29] StructDecl=rdar8650865:1:8 (Definition)
+// CHECK-tokens: Keyword: "int" [3:3 - 3:6] FieldDecl=x:3:7 (Definition)
+// CHECK-tokens: Identifier: "x" [3:7 - 3:8] FieldDecl=x:3:7 (Definition)
+// CHECK-tokens: Punctuation: ";" [3:8 - 3:9] StructDecl=rdar8650865:1:8 (Definition)
+// CHECK-tokens: Punctuation: "}" [4:1 - 4:2] StructDecl=rdar8650865:1:8 (Definition)
+// CHECK-tokens: Punctuation: ";" [4:2 - 4:3]
+// CHECK-tokens: Keyword: "int" [6:1 - 6:4] FunctionDecl=test_rdar8650865:6:5 (Definition)
+// CHECK-tokens: Identifier: "test_rdar8650865" [6:5 - 6:21] FunctionDecl=test_rdar8650865:6:5 (Definition)
+// CHECK-tokens: Punctuation: "(" [6:21 - 6:22] FunctionDecl=test_rdar8650865:6:5 (Definition)
+// CHECK-tokens: Keyword: "struct" [6:22 - 6:28] ParmDecl=s:6:42 (Definition)
+// CHECK-tokens: Identifier: "rdar8650865" [6:29 - 6:40] TypeRef=struct rdar8650865:1:8
+// CHECK-tokens: Punctuation: "*" [6:41 - 6:42] ParmDecl=s:6:42 (Definition)
+// CHECK-tokens: Identifier: "s" [6:42 - 6:43] ParmDecl=s:6:42 (Definition)
+// CHECK-tokens: Punctuation: ")" [6:43 - 6:44] FunctionDecl=test_rdar8650865:6:5 (Definition)
+// CHECK-tokens: Punctuation: "{" [6:45 - 6:46] CompoundStmt=
+// CHECK-tokens: Keyword: "return" [7:3 - 7:9] ReturnStmt=
+// CHECK-tokens: Punctuation: "(" [7:10 - 7:11] ParenExpr=
+// CHECK-tokens: Punctuation: "(" [7:11 - 7:12] ParenExpr=
+// CHECK-tokens: Punctuation: "(" [7:12 - 7:13] ParenExpr=
+// CHECK-tokens: Punctuation: "(" [7:13 - 7:14] ParenExpr=
+// CHECK-tokens: Punctuation: "(" [7:14 - 7:15] ParenExpr=
+// CHECK-tokens: Punctuation: "(" [7:15 - 7:16] ParenExpr=
+// CHECK-tokens: Identifier: "s" [7:16 - 7:17] DeclRefExpr=s:6:42
+// CHECK-tokens: Punctuation: "->" [7:17 - 7:19] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [7:19 - 7:24] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: ")" [7:24 - 7:25] ParenExpr=
+// CHECK-tokens: Punctuation: "->" [7:25 - 7:27] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [7:27 - 7:32] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: ")" [7:32 - 7:33] ParenExpr=
+// CHECK-tokens: Punctuation: "->" [8:5 - 8:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [8:7 - 8:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: ")" [8:12 - 8:13] ParenExpr=
+// CHECK-tokens: Punctuation: "->" [9:5 - 9:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [9:7 - 9:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: ")" [9:12 - 9:13] ParenExpr=
+// CHECK-tokens: Punctuation: "->" [10:5 - 10:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [10:7 - 10:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: ")" [10:12 - 10:13] ParenExpr=
+// CHECK-tokens: Punctuation: "->" [11:5 - 11:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [11:7 - 11:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: ")" [11:12 - 11:13] ParenExpr=
+// CHECK-tokens: Punctuation: "->" [12:5 - 12:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [12:7 - 12:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [13:5 - 13:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [13:7 - 13:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [14:5 - 14:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [14:7 - 14:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [15:5 - 15:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [15:7 - 15:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [16:5 - 16:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [16:7 - 16:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [17:5 - 17:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [17:7 - 17:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [18:5 - 18:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [18:7 - 18:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [19:5 - 19:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [19:7 - 19:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [20:5 - 20:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [20:7 - 20:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [21:5 - 21:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [21:7 - 21:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [22:5 - 22:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [22:7 - 22:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [23:5 - 23:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [23:7 - 23:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [24:5 - 24:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [24:7 - 24:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [25:5 - 25:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [25:7 - 25:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [26:5 - 26:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [26:7 - 26:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [27:5 - 27:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [27:7 - 27:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [28:5 - 28:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [28:7 - 28:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [29:5 - 29:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [29:7 - 29:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [30:5 - 30:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [30:7 - 30:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [31:5 - 31:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [31:7 - 31:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [32:5 - 32:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [32:7 - 32:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [33:5 - 33:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [33:7 - 33:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [34:5 - 34:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [34:7 - 34:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [35:5 - 35:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [35:7 - 35:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [36:5 - 36:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [36:7 - 36:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [37:5 - 37:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [37:7 - 37:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [38:5 - 38:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [38:7 - 38:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [39:5 - 39:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [39:7 - 39:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [40:5 - 40:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [40:7 - 40:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [41:5 - 41:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [41:7 - 41:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [42:5 - 42:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [42:7 - 42:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [43:5 - 43:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [43:7 - 43:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [44:5 - 44:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [44:7 - 44:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [45:5 - 45:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [45:7 - 45:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [46:5 - 46:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [46:7 - 46:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [47:5 - 47:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [47:7 - 47:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [48:5 - 48:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [48:7 - 48:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [49:5 - 49:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [49:7 - 49:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [50:5 - 50:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [50:7 - 50:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [51:5 - 51:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [51:7 - 51:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [52:5 - 52:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [52:7 - 52:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [53:5 - 53:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [53:7 - 53:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [54:5 - 54:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [54:7 - 54:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [55:5 - 55:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [55:7 - 55:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [56:5 - 56:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [56:7 - 56:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [57:5 - 57:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [57:7 - 57:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [58:5 - 58:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [58:7 - 58:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [59:5 - 59:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [59:7 - 59:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [60:5 - 60:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [60:7 - 60:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [61:5 - 61:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [61:7 - 61:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [62:5 - 62:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [62:7 - 62:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [63:5 - 63:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [63:7 - 63:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [64:5 - 64:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [64:7 - 64:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [65:5 - 65:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [65:7 - 65:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [66:5 - 66:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [66:7 - 66:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [67:5 - 67:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [67:7 - 67:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [68:5 - 68:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [68:7 - 68:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [69:5 - 69:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [69:7 - 69:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [70:5 - 70:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [70:7 - 70:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [71:5 - 71:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [71:7 - 71:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [72:5 - 72:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [72:7 - 72:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [73:5 - 73:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [73:7 - 73:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [74:5 - 74:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [74:7 - 74:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [75:5 - 75:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [75:7 - 75:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [76:5 - 76:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [76:7 - 76:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [77:5 - 77:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [77:7 - 77:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [78:5 - 78:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [78:7 - 78:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [79:5 - 79:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [79:7 - 79:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [80:5 - 80:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [80:7 - 80:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [81:5 - 81:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [81:7 - 81:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [82:5 - 82:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [82:7 - 82:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [83:5 - 83:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [83:7 - 83:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [84:5 - 84:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [84:7 - 84:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [85:5 - 85:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [85:7 - 85:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [86:5 - 86:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [86:7 - 86:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [87:5 - 87:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [87:7 - 87:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [88:5 - 88:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [88:7 - 88:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [89:5 - 89:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [89:7 - 89:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [90:5 - 90:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [90:7 - 90:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [91:5 - 91:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [91:7 - 91:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [92:5 - 92:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [92:7 - 92:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [93:5 - 93:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [93:7 - 93:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [94:5 - 94:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [94:7 - 94:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [95:5 - 95:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [95:7 - 95:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [96:5 - 96:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [96:7 - 96:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [97:5 - 97:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [97:7 - 97:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [98:5 - 98:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [98:7 - 98:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [99:5 - 99:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [99:7 - 99:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [100:5 - 100:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [100:7 - 100:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [101:5 - 101:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [101:7 - 101:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [102:5 - 102:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [102:7 - 102:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [103:5 - 103:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [103:7 - 103:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [104:5 - 104:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [104:7 - 104:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [105:5 - 105:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [105:7 - 105:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [106:5 - 106:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [106:7 - 106:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [107:5 - 107:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [107:7 - 107:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [108:5 - 108:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [108:7 - 108:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [109:5 - 109:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [109:7 - 109:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [110:5 - 110:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [110:7 - 110:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [111:5 - 111:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [111:7 - 111:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [112:5 - 112:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [112:7 - 112:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [113:5 - 113:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [113:7 - 113:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [114:5 - 114:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [114:7 - 114:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [115:5 - 115:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [115:7 - 115:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [116:5 - 116:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [116:7 - 116:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [117:5 - 117:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [117:7 - 117:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [118:5 - 118:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [118:7 - 118:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [119:5 - 119:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [119:7 - 119:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [120:5 - 120:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [120:7 - 120:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [121:5 - 121:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [121:7 - 121:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [122:5 - 122:7] MemberRefExpr=first:2:23
+// CHECK-tokens: Identifier: "first" [122:7 - 122:12] MemberRefExpr=first:2:23
+// CHECK-tokens: Punctuation: "->" [123:5 - 123:7] MemberRefExpr=x:3:7
+// CHECK-tokens: Identifier: "x" [123:7 - 123:8] MemberRefExpr=x:3:7
+// CHECK-tokens: Punctuation: ";" [123:8 - 123:9] CompoundStmt=
+// CHECK-tokens: Punctuation: "}" [124:1 - 124:2] CompoundStmt=
+
+
diff --git a/clang/test/Index/redeclarations.cpp b/clang/test/Index/redeclarations.cpp
new file mode 100644
index 0000000..11dc932
--- /dev/null
+++ b/clang/test/Index/redeclarations.cpp
@@ -0,0 +1,21 @@
+#include "redeclarations.h"
+
+class A
+{
+};
+
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 2 all -I%S/Inputs -fno-delayed-template-parsing -fno-ms-compatibility -fno-ms-extensions %s | FileCheck %s
+
+// CHECK: redeclarations.h:1:7: ClassDecl=X:1:7 (Definition) Extent=[1:1 - 4:2]
+// CHECK: redeclarations.h:8:7: ClassTemplate=B:8:7 (Definition) Extent=[7:1 - 10:2]
+// CHECK: redeclarations.h:7:20: TemplateTypeParameter=T1:7:20 (Definition) Extent=[7:11 - 7:22]
+// CHECK: redeclarations.h:7:33: TemplateTypeParameter=T2:7:33 (Definition) Extent=[7:24 - 7:35]
+// CHECK: redeclarations.h:13:8: ClassTemplate=C:13:8 (Definition) Extent=[12:1 - 15:2]
+// CHECK: redeclarations.h:12:17: TemplateTypeParameter=T:12:17 (Definition) Extent=[12:11 - 12:18]
+// CHECK: redeclarations.h:17:7: ClassDecl=D:17:7 (Definition) Extent=[17:1 - 21:2]
+// CHECK: redeclarations.h:19:16: ClassDecl=A:19:16 Extent=[19:10 - 19:17]
+// CHECK: redeclarations.h:19:19: FieldDecl=x:19:19 (Definition) Extent=[19:5 - 19:20]
+// CHECK: redeclarations.h:19:5: TemplateRef=B:8:7 Extent=[19:5 - 19:6]
+// CHECK: redeclarations.h:19:7: TypeRef=class D:17:7 Extent=[19:7 - 19:8]
+// CHECK: redeclarations.h:19:16: TypeRef=class A:3:7 Extent=[19:16 - 19:17]
+// CHECK: redeclarations.cpp:3:7: ClassDecl=A:3:7 (Definition) Extent=[3:1 - 5:2]
diff --git a/clang/test/Index/remap-complete.c b/clang/test/Index/remap-complete.c
new file mode 100644
index 0000000..93fb623
--- /dev/null
+++ b/clang/test/Index/remap-complete.c
@@ -0,0 +1,4 @@
+// RUN: c-index-test -code-completion-at=%s:6:2 -remap-file="%s;%S/Inputs/remap-complete-to.c" %s | FileCheck %s
+
+// CHECK: FunctionDecl:{ResultType int}{TypedText f0}{LeftParen (}
+void f() { }
diff --git a/clang/test/Index/remap-cursor-at.c b/clang/test/Index/remap-cursor-at.c
new file mode 100644
index 0000000..c2bed0e
--- /dev/null
+++ b/clang/test/Index/remap-cursor-at.c
@@ -0,0 +1,4 @@
+// RUN: c-index-test -cursor-at=%s:1:15 -cursor-at=%s:2:21 -remap-file="%s;%S/Inputs/remap-load-to.c" %s | FileCheck %s
+
+// CHECK: ParmDecl=parm1:1:13 (Definition)
+// CHECK: DeclRefExpr=parm2:1:26
diff --git a/clang/test/Index/remap-load.c b/clang/test/Index/remap-load.c
new file mode 100644
index 0000000..2608874
--- /dev/null
+++ b/clang/test/Index/remap-load.c
@@ -0,0 +1,10 @@
+// RUN: c-index-test -test-load-source all -remap-file="%s;%S/Inputs/remap-load-to.c" %s | FileCheck -check-prefix=CHECK %s
+
+// CHECK: remap-load.c:1:5: FunctionDecl=foo:1:5 (Definition) Extent=[1:1 - 3:2]
+// CHECK: remap-load.c:1:13: ParmDecl=parm1:1:13 (Definition) Extent=[1:9 - 1:18]
+// CHECK: remap-load.c:1:26: ParmDecl=parm2:1:26 (Definition) Extent=[1:20 - 1:31]
+// CHECK: remap-load.c:2:10: UnexposedExpr= Extent=[2:10 - 2:23]
+// CHECK: remap-load.c:2:10: BinaryOperator= Extent=[2:10 - 2:23]
+// CHECK: remap-load.c:2:10: UnexposedExpr=parm1:1:13 Extent=[2:10 - 2:15]
+// CHECK: remap-load.c:2:10: DeclRefExpr=parm1:1:13 Extent=[2:10 - 2:15]
+// CHECK: remap-load.c:2:18: DeclRefExpr=parm2:1:26 Extent=[2:18 - 2:23]
diff --git a/clang/test/Index/reparse-instantiate.cpp b/clang/test/Index/reparse-instantiate.cpp
new file mode 100644
index 0000000..84e5860
--- /dev/null
+++ b/clang/test/Index/reparse-instantiate.cpp
@@ -0,0 +1,7 @@
+int main()
+{
+ return 0;
+}
+
+// RUN: c-index-test -write-pch %t.pch -fno-delayed-template-parsing -x c++-header %S/Inputs/reparse-instantiate.h
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local -fno-delayed-template-parsing -I %S/Inputs -include %t %s
diff --git a/clang/test/Index/retain-target-options.c b/clang/test/Index/retain-target-options.c
new file mode 100644
index 0000000..2fba476
--- /dev/null
+++ b/clang/test/Index/retain-target-options.c
@@ -0,0 +1,8 @@
+// RUN: c-index-test -test-load-source all -target x86_64-apple-darwin10.0.0 -msse4.1 %s 2>&1 | FileCheck %s
+// RUN: c-index-test -test-load-source-reparse 1 all -target x86_64-apple-darwin10.0.0 -msse4.1 %s 2>&1 | FileCheck %s
+// RUN: c-index-test -test-load-source-reparse 5 all -target x86_64-apple-darwin10.0.0 -msse4.1 %s 2>&1 | FileCheck %s
+
+// CHECK: error: SSE4_1 used
+#if defined(__SSE4_1__)
+#error SSE4_1 used
+#endif
diff --git a/clang/test/Index/targeted-annotation.c b/clang/test/Index/targeted-annotation.c
new file mode 100644
index 0000000..cfa1046
--- /dev/null
+++ b/clang/test/Index/targeted-annotation.c
@@ -0,0 +1,99 @@
+
+#include "targeted-top.h"
+#include "targeted-preamble.h"
+
+int LocalVar1;
+int LocalVar2;
+
+// RUN: c-index-test -write-pch %t.h.pch %S/targeted-top.h
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-annotate-tokens=%s:1:1:7:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=LOCAL
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:7:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=LOCAL
+
+// LOCAL: Punctuation: "#" [2:1 - 2:2] inclusion directive=targeted-top.h
+// LOCAL: Identifier: "include" [2:2 - 2:9] inclusion directive=targeted-top.h
+// LOCAL: Literal: ""targeted-top.h"" [2:10 - 2:26] inclusion directive=targeted-top.h
+// LOCAL: Punctuation: "#" [3:1 - 3:2] inclusion directive=targeted-preamble.h
+// LOCAL: Identifier: "include" [3:2 - 3:9] inclusion directive=targeted-preamble.h
+// LOCAL: Literal: ""targeted-preamble.h"" [3:10 - 3:31] inclusion directive=targeted-preamble.h
+// LOCAL: Keyword: "int" [5:1 - 5:4] VarDecl=LocalVar1:5:5
+// LOCAL: Identifier: "LocalVar1" [5:5 - 5:14] VarDecl=LocalVar1:5:5
+// LOCAL: Punctuation: ";" [5:14 - 5:15]
+// LOCAL: Keyword: "int" [6:1 - 6:4] VarDecl=LocalVar2:6:5
+// LOCAL: Identifier: "LocalVar2" [6:5 - 6:14] VarDecl=LocalVar2:6:5
+// LOCAL: Punctuation: ";" [6:14 - 6:15]
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-annotate-tokens=%S/targeted-fields.h:1:1:4:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=FIELD
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -test-annotate-tokens=%S/targeted-fields.h:1:1:4:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=FIELD
+
+// FIELD: Keyword: "int" [2:3 - 2:6] FieldDecl=z:2:7 (Definition)
+// FIELD: Identifier: "z" [2:7 - 2:8] FieldDecl=z:2:7 (Definition)
+// FIELD: Punctuation: ";" [2:8 - 2:9] StructDecl=:13:9 (Definition)
+// FIELD: Keyword: "int" [3:3 - 3:6] FieldDecl=w:3:7 (Definition)
+// FIELD: Identifier: "w" [3:7 - 3:8] FieldDecl=w:3:7 (Definition)
+// FIELD: Punctuation: ";" [3:8 - 3:9] StructDecl=:13:9 (Definition)
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-annotate-tokens=%S/targeted-nested1.h:1:1:3:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=NESTED
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -test-annotate-tokens=%S/targeted-nested1.h:1:1:3:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=NESTED
+
+// NESTED: Keyword: "extern" [2:1 - 2:7]
+// NESTED: Keyword: "int" [2:8 - 2:11] VarDecl=NestedVar1:2:12
+// NESTED: Identifier: "NestedVar1" [2:12 - 2:22] VarDecl=NestedVar1:2:12
+// NESTED: Punctuation: ";" [2:22 - 2:23]
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-annotate-tokens=%S/targeted-top.h:1:1:12:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=vector_get_x \
+// RUN: | FileCheck %s -check-prefix=TOP
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -test-annotate-tokens=%S/targeted-top.h:1:1:12:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=vector_get_x \
+// RUN: | FileCheck %s -check-prefix=TOP
+
+// TOP: Punctuation: "#" [2:1 - 2:2] preprocessing directive=
+// TOP: Identifier: "ifndef" [2:2 - 2:8] preprocessing directive=
+// TOP: Identifier: "TARGETED_TOP_H" [2:9 - 2:23] preprocessing directive=
+// TOP: Punctuation: "#" [3:1 - 3:2] preprocessing directive=
+// TOP: Identifier: "define" [3:2 - 3:8] preprocessing directive=
+// TOP: Identifier: "TARGETED_TOP_H" [3:9 - 3:23] preprocessing directive=
+// TOP: Punctuation: "#" [5:1 - 5:2] preprocessing directive=
+// TOP: Identifier: "include" [5:2 - 5:9] preprocessing directive=
+// TOP: Literal: ""targeted-nested1.h"" [5:10 - 5:30] preprocessing directive=
+// TOP: Keyword: "enum" [7:1 - 7:5] EnumDecl=:7:1 (Definition)
+// TOP: Punctuation: "{" [7:6 - 7:7] EnumDecl=:7:1 (Definition)
+// TOP: Identifier: "VALUE" [8:3 - 8:8] EnumConstantDecl=VALUE:8:3 (Definition)
+// TOP: Punctuation: "=" [8:9 - 8:10] EnumConstantDecl=VALUE:8:3 (Definition)
+// TOP: Literal: "3" [8:11 - 8:12] IntegerLiteral=
+// TOP: Punctuation: "}" [9:1 - 9:2] EnumDecl=:7:1 (Definition)
+// TOP: Punctuation: ";" [9:2 - 9:3]
+// TOP: Keyword: "extern" [11:1 - 11:7]
+// TOP: Keyword: "int" [11:8 - 11:11] VarDecl=TopVar:11:12
+// TOP: Identifier: "TopVar" [11:12 - 11:18] VarDecl=TopVar:11:12
+// TOP: Punctuation: ";" [11:18 - 11:19]
diff --git a/clang/test/Index/targeted-cursor.c b/clang/test/Index/targeted-cursor.c
new file mode 100644
index 0000000..7efc07f
--- /dev/null
+++ b/clang/test/Index/targeted-cursor.c
@@ -0,0 +1,65 @@
+
+#include "targeted-top.h"
+#include "targeted-preamble.h"
+
+int LocalVar1;
+int LocalVar2;
+
+// RUN: c-index-test -write-pch %t.h.pch %S/targeted-top.h
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%s:5:10 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=LOCAL-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-top.h:11:15 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=vector_get_x \
+// RUN: | FileCheck %s -check-prefix=TOP-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=NESTED-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-fields.h:2:7 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=FIELD-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-fields.h:1:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=FIELD-CURSOR2
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -cursor-at=%s:5:10 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=LOCAL-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -cursor-at=%S/targeted-top.h:11:15 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=vector_get_x \
+// RUN: | FileCheck %s -check-prefix=TOP-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -cursor-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=NESTED-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -cursor-at=%S/targeted-preamble.h:2:15 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=PREAMBLE-CURSOR1
+
+// LOCAL-CURSOR1: VarDecl=LocalVar1:5:5
+// TOP-CURSOR1: VarDecl=TopVar:11:12
+// NESTED-CURSOR1: VarDecl=NestedVar1:2:12
+// PREAMBLE-CURSOR1: VarDecl=PreambleVar:2:12
+
+// FIELD-CURSOR1: FieldDecl=z:2:7 (Definition)
+// FIELD-CURSOR2: StructDecl=:13:9 (Definition)
diff --git a/clang/test/Index/targeted-cursor.m b/clang/test/Index/targeted-cursor.m
new file mode 100644
index 0000000..a53ebf6
--- /dev/null
+++ b/clang/test/Index/targeted-cursor.m
@@ -0,0 +1,6 @@
+
+// rdar://10920009
+// RUN: c-index-test -write-pch %t.h.pch -target x86_64-apple-macosx10.7 -x objective-c-header %S/targeted-cursor.m.h -Xclang -detailed-preprocessing-record
+// RUN: c-index-test -cursor-at=%S/targeted-cursor.m.h:5:13 %s -target x86_64-apple-macosx10.7 -include %t.h | FileCheck %s
+
+// CHECK: ObjCClassRef=I:2:12
diff --git a/clang/test/Index/targeted-cursor.m.h b/clang/test/Index/targeted-cursor.m.h
new file mode 100644
index 0000000..735c7bd
--- /dev/null
+++ b/clang/test/Index/targeted-cursor.m.h
@@ -0,0 +1,7 @@
+
+@interface I
+
+-(void)mm:(void (^)(I*))block;
+-(void)mm2:(I*)i;
+
+@end
diff --git a/clang/test/Index/targeted-fields.h b/clang/test/Index/targeted-fields.h
new file mode 100644
index 0000000..7da57f3
--- /dev/null
+++ b/clang/test/Index/targeted-fields.h
@@ -0,0 +1,3 @@
+
+ int z;
+ int w;
diff --git a/clang/test/Index/targeted-file-refs.c b/clang/test/Index/targeted-file-refs.c
new file mode 100644
index 0000000..195cd86
--- /dev/null
+++ b/clang/test/Index/targeted-file-refs.c
@@ -0,0 +1,59 @@
+
+#include "targeted-top.h"
+#include "targeted-preamble.h"
+
+extern int LocalVar;
+int LocalVar;
+
+// RUN: c-index-test -write-pch %t.h.pch %S/targeted-top.h -Xclang -detailed-preprocessing-record
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -file-refs-at=%s:5:17 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=LOCAL
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -file-refs-at=%s:5:17 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=LOCAL
+
+// LOCAL: VarDecl=LocalVar:5:12
+// LOCAL: VarDecl=LocalVar:5:12 =[5:12 - 5:20]
+// LOCAL: VarDecl=LocalVar:6:5 =[6:5 - 6:13]
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -file-refs-at=%S/targeted-top.h:14:7 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: | FileCheck %s -check-prefix=TOP
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -file-refs-at=%S/targeted-top.h:14:7 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: | FileCheck %s -check-prefix=TOP
+
+// TOP: FieldDecl=x:14:7 (Definition)
+// TOP: FieldDecl=x:14:7 (Definition) =[14:7 - 14:8]
+// TOP: MemberRefExpr=x:14:7 SingleRefName=[20:13 - 20:14] RefName=[20:13 - 20:14] =[20:13 - 20:14]
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -file-refs-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=NESTED
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -file-refs-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=NESTED
+
+// NESTED: VarDecl=NestedVar1:2:12
+// NESTED: VarDecl=NestedVar1:2:12 =[2:12 - 2:22]
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -file-refs-at=%S/targeted-preamble.h:2:15 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=PREAMBLE
+
+// PREAMBLE: VarDecl=PreambleVar:2:12
+// PREAMBLE: VarDecl=PreambleVar:2:12 =[2:12 - 2:23]
diff --git a/clang/test/Index/targeted-nested1.h b/clang/test/Index/targeted-nested1.h
new file mode 100644
index 0000000..d5a019b
--- /dev/null
+++ b/clang/test/Index/targeted-nested1.h
@@ -0,0 +1,2 @@
+
+extern int NestedVar1;
diff --git a/clang/test/Index/targeted-preamble.h b/clang/test/Index/targeted-preamble.h
new file mode 100644
index 0000000..19b9539
--- /dev/null
+++ b/clang/test/Index/targeted-preamble.h
@@ -0,0 +1,2 @@
+
+extern int PreambleVar;
diff --git a/clang/test/Index/targeted-top.h b/clang/test/Index/targeted-top.h
new file mode 100644
index 0000000..0f3c975
--- /dev/null
+++ b/clang/test/Index/targeted-top.h
@@ -0,0 +1,24 @@
+
+#ifndef TARGETED_TOP_H
+#define TARGETED_TOP_H
+
+#include "targeted-nested1.h"
+
+enum {
+ VALUE = 3
+};
+
+extern int TopVar;
+
+typedef struct {
+ int x;
+ int y;
+#include "targeted-fields.h"
+} Vector;
+
+static inline int vector_get_x(Vector v) {
+ int x = v.x;
+ return x;
+}
+
+#endif
diff --git a/clang/test/Index/unmatched-braces.c b/clang/test/Index/unmatched-braces.c
new file mode 100644
index 0000000..b994605
--- /dev/null
+++ b/clang/test/Index/unmatched-braces.c
@@ -0,0 +1,9 @@
+void foo() {
+ int x;
+ if (x) {
+}
+
+// RUN: c-index-test -cursor-at=%s:2:7 %s > %t
+// RUN: FileCheck %s -input-file %t
+
+// CHECK: VarDecl=x:2:7
diff --git a/clang/test/Index/unmatched-braces.m b/clang/test/Index/unmatched-braces.m
new file mode 100644
index 0000000..84fe82a
--- /dev/null
+++ b/clang/test/Index/unmatched-braces.m
@@ -0,0 +1,11 @@
+@implementation I
+-(void)meth {
+ int x;
+ if (x) {
+}
+@end
+
+// RUN: c-index-test -cursor-at=%s:3:7 %s > %t
+// RUN: FileCheck %s -input-file %t
+
+// CHECK: VarDecl=x:3:7
diff --git a/clang/test/Index/usrs-cxx0x.cpp b/clang/test/Index/usrs-cxx0x.cpp
new file mode 100644
index 0000000..a48b446
--- /dev/null
+++ b/clang/test/Index/usrs-cxx0x.cpp
@@ -0,0 +1,8 @@
+template<typename ...Types>
+struct tuple { };
+
+void f(tuple<int, float, double>);
+
+// RUN: c-index-test -test-load-source-usrs all -std=c++11 %s | FileCheck %s
+// CHECK: usrs-cxx0x.cpp c:@ST>1#pT@tuple Extent=[1:1 - 2:17]
+// CHECK: usrs-cxx0x.cpp c:@F@f#$@S@tuple>#p3Ifd# Extent=[4:1 - 4:34]
diff --git a/clang/test/Index/usrs.cpp b/clang/test/Index/usrs.cpp
new file mode 100644
index 0000000..023818c
--- /dev/null
+++ b/clang/test/Index/usrs.cpp
@@ -0,0 +1,146 @@
+namespace foo {
+ int x;
+ void bar(int z);
+}
+namespace bar {
+ typedef int QType;
+ void bar(QType z);
+}
+
+class ClsA {
+public:
+ int a, b;
+ ClsA(int A, int B) : a(A), b(B) {}
+};
+
+namespace foo {
+ class ClsB : public ClsA {
+ public:
+ ClsB() : ClsA(1, 2) {}
+ int result() const;
+ };
+}
+
+int foo::ClsB::result() const {
+ return a + b;
+}
+
+namespace {
+ class ClsC : public foo::ClsB {};
+ int w;
+}
+
+int z;
+
+namespace foo { namespace taz {
+ int x;
+ static inline int add(int a, int b) { return a + b; }
+ void sub(int a, int b);
+}
+}
+
+namespace foo { namespace taz {
+ class ClsD : public foo::ClsB {
+ public:
+ ClsD& operator=(int x) { a = x; return *this; }
+ ClsD& operator=(double x) { a = (int) x; return *this; }
+ ClsD& operator=(const ClsD &x) { a = x.a; return *this; }
+ static int qux();
+ static int uz(int z, ...);
+ bool operator==(const ClsD &x) const { return a == x.a; }
+ };
+}}
+
+extern "C" {
+ void rez(int a, int b);
+}
+
+namespace foo_alias = foo;
+
+using namespace foo;
+
+namespace foo_alias2 = foo;
+
+using foo::ClsB;
+
+namespace foo_alias3 = foo;
+
+namespace {
+class RDar9371763_Foo {
+public:
+ void bar();
+};
+}
+
+void RDar9371763_Foo::bar() {}
+
+void rdar9371763() {
+ RDar9371763_Foo foo;
+ foo.bar();
+}
+
+// RUN: c-index-test -test-load-source-usrs all %s | FileCheck %s
+// CHECK: usrs.cpp c:@N@foo Extent=[1:1 - 4:2]
+// CHECK: usrs.cpp c:@N@foo@x Extent=[2:3 - 2:8]
+// CHECK: usrs.cpp c:@N@foo@F@bar#I# Extent=[3:3 - 3:18]
+// CHECK: usrs.cpp c:usrs.cpp@36@N@foo@F@bar#I#@z Extent=[3:12 - 3:17]
+// CHECK: usrs.cpp c:@N@bar Extent=[5:1 - 8:2]
+// CHECK: usrs.cpp c:usrs.cpp@64@N@bar@T@QType Extent=[6:3 - 6:20]
+// CHECK: usrs.cpp c:@N@bar@F@bar#I# Extent=[7:3 - 7:20]
+// CHECK: usrs.cpp c:usrs.cpp@94@N@bar@F@bar#I#@z Extent=[7:12 - 7:19]
+// CHECK: usrs.cpp c:@C@ClsA Extent=[10:1 - 14:2]
+// CHECK: usrs.cpp c: Extent=[11:1 - 11:8]
+// CHECK: usrs.cpp c:@C@ClsA@FI@a Extent=[12:3 - 12:8]
+// CHECK: usrs.cpp c:@C@ClsA@FI@b Extent=[12:3 - 12:11]
+// CHECK: usrs.cpp c:@C@ClsA@F@ClsA#I#I# Extent=[13:3 - 13:37]
+// CHECK: usrs.cpp c:usrs.cpp@147@C@ClsA@F@ClsA#I#I#@A Extent=[13:8 - 13:13]
+// CHECK: usrs.cpp c:usrs.cpp@154@C@ClsA@F@ClsA#I#I#@B Extent=[13:15 - 13:20]
+// CHECK: usrs.cpp c:@N@foo Extent=[16:1 - 22:2]
+// CHECK: usrs.cpp c:@N@foo@C@ClsB Extent=[17:3 - 21:4]
+// CHECK: usrs.cpp c: Extent=[18:3 - 18:10]
+// CHECK: usrs.cpp c:@N@foo@C@ClsB@F@ClsB# Extent=[19:5 - 19:27]
+// CHECK: usrs.cpp c:@N@foo@C@ClsB@F@result#1 Extent=[20:5 - 20:23]
+// CHECK: usrs.cpp c:@N@foo@C@ClsB@F@result#1 Extent=[24:1 - 26:2]
+// CHECK: usrs.cpp c:@aN@C@ClsC Extent=[29:3 - 29:35]
+// CHECK: usrs.cpp c:@aN@w Extent=[30:3 - 30:8]
+// CHECK: usrs.cpp c:@z Extent=[33:1 - 33:6]
+// CHECK: usrs.cpp c:@N@foo Extent=[35:1 - 40:2]
+// CHECK: usrs.cpp c:@N@foo@N@taz Extent=[35:17 - 39:2]
+// CHECK: usrs.cpp c:@N@foo@N@taz@x Extent=[36:3 - 36:8]
+// CHECK: usrs.cpp c:usrs.cpp@457@N@foo@N@taz@F@add#I#I# Extent=[37:3 - 37:56]
+// CHECK: usrs.cpp c:usrs.cpp@479@N@foo@N@taz@F@add#I#I#@a Extent=[37:25 - 37:30]
+// CHECK: usrs.cpp c:usrs.cpp@486@N@foo@N@taz@F@add#I#I#@b Extent=[37:32 - 37:37]
+// CHECK: usrs.cpp c:@N@foo@N@taz@F@sub#I#I# Extent=[38:3 - 38:25]
+// CHECK: usrs.cpp c:usrs.cpp@522@N@foo@N@taz@F@sub#I#I#@a Extent=[38:12 - 38:17]
+// CHECK: usrs.cpp c:usrs.cpp@529@N@foo@N@taz@F@sub#I#I#@b Extent=[38:19 - 38:24]
+// CHECK: usrs.cpp c:@N@foo Extent=[42:1 - 52:3]
+// CHECK: usrs.cpp c:@N@foo@N@taz Extent=[42:17 - 52:2]
+// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD Extent=[43:3 - 51:4]
+// CHECK: usrs.cpp c: Extent=[44:3 - 44:10]
+// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator=#I# Extent=[45:5 - 45:52]
+// CHECK: usrs.cpp c:usrs.cpp@638@N@foo@N@taz@C@ClsD@F@operator=#I#@x Extent=[45:21 - 45:26]
+// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator=#d# Extent=[46:5 - 46:61]
+// CHECK: usrs.cpp c:usrs.cpp@690@N@foo@N@taz@C@ClsD@F@operator=#d#@x Extent=[46:21 - 46:29]
+// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator=#&1$@N@foo@N@taz@C@ClsD# Extent=[47:5 - 47:62]
+// CHECK: usrs.cpp c:usrs.cpp@751@N@foo@N@taz@C@ClsD@F@operator=#&1$@N@foo@N@taz@C@ClsD#@x Extent=[47:21 - 47:34]
+// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@qux#S Extent=[48:5 - 48:21]
+// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@uz#I.#S Extent=[49:5 - 49:30]
+// CHECK: usrs.cpp c:usrs.cpp@833@N@foo@N@taz@C@ClsD@F@uz#I.#S@z Extent=[49:19 - 49:24]
+// CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator==#&1$@N@foo@N@taz@C@ClsD#1 Extent=[50:5 - 50:62]
+// CHECK: usrs.cpp c:usrs.cpp@866@N@foo@N@taz@C@ClsD@F@operator==#&1$@N@foo@N@taz@C@ClsD#1@x Extent=[50:21 - 50:34]
+// CHECK: usrs.cpp c:@F@rez Extent=[55:3 - 55:25]
+// CHECK: usrs.cpp c:usrs.cpp@941@F@rez@a Extent=[55:12 - 55:17]
+// CHECK: usrs.cpp c:usrs.cpp@948@F@rez@b Extent=[55:19 - 55:24]
+// CHECK: usrs.cpp c:@NA@foo_alias
+// CHECK-NOT: foo
+// CHECK: usrs.cpp c:@NA@foo_alias2
+// CHECK-NOT: ClsB
+// CHECK: usrs.cpp c:@NA@foo_alias3
+// CHECK: usrs.cpp c:@aN Extent=[68:1 - 73:2]
+// CHECK: usrs.cpp c:@aN@C@RDar9371763_Foo Extent=[69:1 - 72:2]
+// CHECK: usrs.cpp c: Extent=[70:1 - 70:8]
+// CHECK: usrs.cpp c:usrs.cpp@1131@aN@C@RDar9371763_Foo@F@bar# Extent=[71:3 - 71:13]
+// CHECK: usrs.cpp c:usrs.cpp@1131@aN@C@RDar9371763_Foo@F@bar# Extent=[75:1 - 75:31]
+// CHECK: usrs.cpp c:@F@rdar9371763# Extent=[77:1 - 80:2]
+// CHECK: usrs.cpp c:usrs.cpp@1204@F@rdar9371763#@foo Extent=[78:3 - 78:22]
+
diff --git a/clang/test/Index/usrs.m b/clang/test/Index/usrs.m
new file mode 100644
index 0000000..95a5388
--- /dev/null
+++ b/clang/test/Index/usrs.m
@@ -0,0 +1,284 @@
+
+
+static inline int my_helper(int x, int y) { return x + y; }
+
+enum {
+ ABA,
+ CADABA
+};
+
+enum {
+ FOO,
+ BAR
+};
+
+typedef struct {
+ int wa;
+ int moo;
+} MyStruct;
+
+enum Pizza {
+ CHEESE,
+ MUSHROOMS
+};
+
+@interface Foo {
+ id x;
+ id y;
+}
+- (id) godzilla;
++ (id) kingkong;
+@property int d1;
+@end
+
+@implementation Foo
+- (id) godzilla {
+ static int a = 0;
+ extern int z;
+ return 0;
+}
++ (id) kingkong {
+ int local_var;
+ return 0;
+}
+@synthesize d1;
+@end
+
+int z;
+
+static int local_func(int x) { return x; }
+
+@interface CWithExt
+- (id) meth1;
+@end
+@interface CWithExt ()
+- (id) meth2;
+@end
+@interface CWithExt ()
+- (id) meth3;
+@end
+@interface CWithExt (Bar)
+- (id) meth4;
+@end
+@implementation CWithExt
+- (id) meth1 { return 0; }
+- (id) meth2 { return 0; }
+- (id) meth3 { return 0; }
+@end
+@implementation CWithExt (Bar)
+- (id) meth4 { return 0; }
+@end
+
+void aux_1(int, int, int);
+int test_multi_declaration(void) {
+ int foo = 1, bar = 2, baz = 3;
+ aux_1(foo, bar, baz);
+ return 0;
+}
+
+@protocol P1
+- (void)method;
+@end
+
+@interface CWithExt2
+@end
+@interface CWithExt2 () {
+ id var_ext;
+}
+@property (assign) id pro_ext;
+@end
+
+// RUN: c-index-test -test-load-source-usrs all -target x86_64-apple-macosx10.7 %s | FileCheck %s
+// CHECK: usrs.m c:usrs.m@67@F@my_helper Extent=[3:1 - 3:60]
+// CHECK: usrs.m c:usrs.m@95@F@my_helper@x Extent=[3:29 - 3:34]
+// CHECK: usrs.m c:usrs.m@102@F@my_helper@y Extent=[3:36 - 3:41]
+// CHECK: usrs.m c:usrs.m@128@Ea Extent=[5:1 - 8:2]
+// CHECK: usrs.m c:usrs.m@128@Ea@ABA Extent=[6:3 - 6:6]
+// CHECK: usrs.m c:usrs.m@128@Ea@CADABA Extent=[7:3 - 7:9]
+// CHECK: usrs.m c:usrs.m@155@Ea Extent=[10:1 - 13:2]
+// CHECK: usrs.m c:usrs.m@155@Ea@FOO Extent=[11:3 - 11:6]
+// CHECK: usrs.m c:usrs.m@155@Ea@BAR Extent=[12:3 - 12:6]
+// CHECK: usrs.m c:@SA@MyStruct Extent=[15:9 - 18:2]
+// CHECK: usrs.m c:@SA@MyStruct@FI@wa Extent=[16:3 - 16:9]
+// CHECK: usrs.m c:@SA@MyStruct@FI@moo Extent=[17:3 - 17:10]
+// CHECK: usrs.m c:usrs.m@179@T@MyStruct Extent=[15:1 - 18:11]
+// CHECK: usrs.m c:@E@Pizza Extent=[20:1 - 23:2]
+// CHECK: usrs.m c:@E@Pizza@CHEESE Extent=[21:3 - 21:9]
+// CHECK: usrs.m c:@E@Pizza@MUSHROOMS Extent=[22:3 - 22:12]
+// CHECK: usrs.m c:objc(cs)Foo Extent=[25:1 - 32:5]
+// CHECK: usrs.m c:objc(cs)Foo@x Extent=[26:3 - 26:7]
+// CHECK: usrs.m c:objc(cs)Foo@y Extent=[27:3 - 27:7]
+// CHECK: usrs.m c:objc(cs)Foo(im)godzilla Extent=[29:1 - 29:17]
+// CHECK: usrs.m c:objc(cs)Foo(cm)kingkong Extent=[30:1 - 30:17]
+// CHECK: usrs.m c:objc(cs)Foo(py)d1 Extent=[31:1 - 31:17]
+// CHECK: usrs.m c:objc(cs)Foo(im)d1 Extent=[31:15 - 31:17]
+// CHECK: usrs.m c:objc(cs)Foo(im)setD1: Extent=[31:15 - 31:17]
+// CHECK: usrs.m c:usrs.m@352objc(cs)Foo(im)setD1:@d1 Extent=[31:15 - 31:17]
+// CHECK: usrs.m c:objc(cs)Foo Extent=[34:1 - 45:2]
+// CHECK: usrs.m c:objc(cs)Foo(im)godzilla Extent=[35:1 - 39:2]
+// CHECK: usrs.m c:usrs.m@402objc(cs)Foo(im)godzilla@a Extent=[36:3 - 36:19]
+// CHECK: usrs.m c:objc(cs)Foo(im)godzilla@z Extent=[37:3 - 37:15]
+// CHECK: usrs.m c:objc(cs)Foo(cm)kingkong Extent=[40:1 - 43:2]
+// CHECK: usrs.m c:usrs.m@470objc(cs)Foo(cm)kingkong@local_var Extent=[41:3 - 41:16]
+// CHECK: usrs.m c:objc(cs)Foo@d1 Extent=[44:13 - 44:15]
+// CHECK: usrs.m c:objc(cs)Foo(py)d1 Extent=[44:1 - 44:15]
+// CHECK: usrs.m c:@z Extent=[47:1 - 47:6]
+// CHECK: usrs.m c:usrs.m@529@F@local_func Extent=[49:1 - 49:43]
+// CHECK: usrs.m c:usrs.m@551@F@local_func@x Extent=[49:23 - 49:28]
+// CHECK: usrs.m c:objc(cs)CWithExt Extent=[51:1 - 53:5]
+// CHECK: usrs.m c:objc(cs)CWithExt(im)meth1 Extent=[52:1 - 52:14]
+// CHECK: usrs.m c:objc(ext)CWithExt@usrs.m@612 Extent=[54:1 - 56:5]
+// CHECK: usrs.m c:objc(cs)CWithExt(im)meth2 Extent=[55:1 - 55:14]
+// CHECK: usrs.m c:objc(ext)CWithExt@usrs.m@654 Extent=[57:1 - 59:5]
+// CHECK: usrs.m c:objc(cs)CWithExt(im)meth3 Extent=[58:1 - 58:14]
+// CHECK: usrs.m c:objc(cy)CWithExt@Bar Extent=[60:1 - 62:5]
+// CHECK: usrs.m c:objc(cs)CWithExt(im)meth4 Extent=[61:1 - 61:14]
+// CHECK: usrs.m c:objc(cs)CWithExt Extent=[63:1 - 67:2]
+// CHECK: usrs.m c:objc(cs)CWithExt(im)meth1 Extent=[64:1 - 64:27]
+// CHECK: usrs.m c:objc(cs)CWithExt(im)meth2 Extent=[65:1 - 65:27]
+// CHECK: usrs.m c:objc(cs)CWithExt(im)meth3 Extent=[66:1 - 66:27]
+// CHECK: usrs.m c:objc(cy)CWithExt@Bar Extent=[68:1 - 70:2]
+// CHECK: usrs.m c:objc(cs)CWithExt(im)meth4 Extent=[69:1 - 69:27]
+// CHECK: usrs.m c:@F@aux_1 Extent=[72:1 - 72:26]
+// CHECK: usrs.m c:@F@test_multi_declaration Extent=[73:1 - 77:2]
+// CHECK: usrs.m c:usrs.m@980@F@test_multi_declaration@foo Extent=[74:3 - 74:14]
+// CHECK: usrs.m c:usrs.m@980@F@test_multi_declaration@bar Extent=[74:16 - 74:23]
+// CHECK: usrs.m c:usrs.m@980@F@test_multi_declaration@baz Extent=[74:25 - 74:32]
+// CHECK: usrs.m c:objc(pl)P1 Extent=[79:1 - 81:5]
+// CHECK: usrs.m c:objc(pl)P1(im)method Extent=[80:1 - 80:16]
+// CHECK: usrs.m c:objc(cs)CWithExt2 Extent=[83:1 - 84:5]
+// CHECK: usrs.m c:objc(ext)CWithExt2@usrs.m@1111 Extent=[85:1 - 89:5]
+// CHECK: usrs.m c:objc(cs)CWithExt2@var_ext Extent=[86:3 - 86:13]
+// CHECK: usrs.m c:objc(cs)CWithExt2(py)pro_ext Extent=[88:1 - 88:30]
+// CHECK: usrs.m c:objc(cs)CWithExt2(im)pro_ext Extent=[88:23 - 88:30]
+// CHECK: usrs.m c:objc(cs)CWithExt2(im)setPro_ext: Extent=[88:23 - 88:30]
+
+// RUN: c-index-test -test-load-source all %s | FileCheck -check-prefix=CHECK-source %s
+// CHECK-source: usrs.m:3:19: FunctionDecl=my_helper:3:19 (Definition) Extent=[3:1 - 3:60]
+// CHECK-source: usrs.m:3:33: ParmDecl=x:3:33 (Definition) Extent=[3:29 - 3:34]
+// CHECK-source: usrs.m:3:40: ParmDecl=y:3:40 (Definition) Extent=[3:36 - 3:41]
+// CHECK-source: usrs.m:3:43: CompoundStmt= Extent=[3:43 - 3:60]
+// CHECK-source: usrs.m:3:45: ReturnStmt= Extent=[3:45 - 3:57]
+// CHECK-source: usrs.m:3:52: BinaryOperator= Extent=[3:52 - 3:57]
+// CHECK-source: usrs.m:3:52: DeclRefExpr=x:3:33 Extent=[3:52 - 3:53]
+// CHECK-source: usrs.m:3:56: DeclRefExpr=y:3:40 Extent=[3:56 - 3:57]
+// CHECK-source: usrs.m:5:1: EnumDecl=:5:1 (Definition) Extent=[5:1 - 8:2]
+// CHECK-source: usrs.m:6:3: EnumConstantDecl=ABA:6:3 (Definition) Extent=[6:3 - 6:6]
+// CHECK-source: usrs.m:7:3: EnumConstantDecl=CADABA:7:3 (Definition) Extent=[7:3 - 7:9]
+// CHECK-source: usrs.m:10:1: EnumDecl=:10:1 (Definition) Extent=[10:1 - 13:2]
+// CHECK-source: usrs.m:11:3: EnumConstantDecl=FOO:11:3 (Definition) Extent=[11:3 - 11:6]
+// CHECK-source: usrs.m:12:3: EnumConstantDecl=BAR:12:3 (Definition) Extent=[12:3 - 12:6]
+// CHECK-source: usrs.m:18:3: TypedefDecl=MyStruct:18:3 (Definition) Extent=[15:1 - 18:11]
+// CHECK-source: usrs.m:15:9: StructDecl=:15:9 (Definition) Extent=[15:9 - 18:2]
+// CHECK-source: usrs.m:16:7: FieldDecl=wa:16:7 (Definition) Extent=[16:3 - 16:9]
+// CHECK-source: usrs.m:17:7: FieldDecl=moo:17:7 (Definition) Extent=[17:3 - 17:10]
+// CHECK-source: usrs.m:20:6: EnumDecl=Pizza:20:6 (Definition) Extent=[20:1 - 23:2]
+// CHECK-source: usrs.m:21:3: EnumConstantDecl=CHEESE:21:3 (Definition) Extent=[21:3 - 21:9]
+// CHECK-source: usrs.m:22:3: EnumConstantDecl=MUSHROOMS:22:3 (Definition) Extent=[22:3 - 22:12]
+// CHECK-source: usrs.m:25:12: ObjCInterfaceDecl=Foo:25:12 Extent=[25:1 - 32:5]
+// CHECK-source: usrs.m:26:6: ObjCIvarDecl=x:26:6 (Definition) Extent=[26:3 - 26:7]
+// CHECK-source: usrs.m:26:3: TypeRef=id:0:0 Extent=[26:3 - 26:5]
+// CHECK-source: usrs.m:27:6: ObjCIvarDecl=y:27:6 (Definition) Extent=[27:3 - 27:7]
+// CHECK-source: usrs.m:27:3: TypeRef=id:0:0 Extent=[27:3 - 27:5]
+// CHECK-source: usrs.m:29:8: ObjCInstanceMethodDecl=godzilla:29:8 Extent=[29:1 - 29:17]
+// CHECK-source: usrs.m:29:4: TypeRef=id:0:0 Extent=[29:4 - 29:6]
+// CHECK-source: usrs.m:30:8: ObjCClassMethodDecl=kingkong:30:8 Extent=[30:1 - 30:17]
+// CHECK-source: usrs.m:30:4: TypeRef=id:0:0 Extent=[30:4 - 30:6]
+// CHECK-source: usrs.m:31:15: ObjCPropertyDecl=d1:31:15 Extent=[31:1 - 31:17]
+// CHECK-source: usrs.m:31:15: ObjCInstanceMethodDecl=d1:31:15 Extent=[31:15 - 31:17]
+// CHECK-source: usrs.m:31:15: ObjCInstanceMethodDecl=setD1::31:15 Extent=[31:15 - 31:17]
+// CHECK-source: usrs.m:31:15: ParmDecl=d1:31:15 (Definition) Extent=[31:15 - 31:17]
+// CHECK-source: usrs.m:34:17: ObjCImplementationDecl=Foo:34:17 (Definition) Extent=[34:1 - 45:2]
+// CHECK-source: usrs.m:35:8: ObjCInstanceMethodDecl=godzilla:35:8 (Definition) Extent=[35:1 - 39:2]
+// CHECK-source: usrs.m:35:4: TypeRef=id:0:0 Extent=[35:4 - 35:6]
+// CHECK-source: usrs.m:35:17: CompoundStmt= Extent=[35:17 - 39:2]
+// CHECK-source: usrs.m:36:3: DeclStmt= Extent=[36:3 - 36:20]
+// CHECK-source: usrs.m:36:14: VarDecl=a:36:14 (Definition) Extent=[36:3 - 36:19]
+// CHECK-source: usrs.m:36:18: IntegerLiteral= Extent=[36:18 - 36:19]
+// CHECK-source: usrs.m:37:3: DeclStmt= Extent=[37:3 - 37:16]
+// CHECK-source: usrs.m:37:14: VarDecl=z:37:14 Extent=[37:3 - 37:15]
+// CHECK-source: usrs.m:38:3: ReturnStmt= Extent=[38:3 - 38:11]
+// CHECK-source: usrs.m:38:10: UnexposedExpr= Extent=[38:10 - 38:11]
+// CHECK-source: usrs.m:38:10: IntegerLiteral= Extent=[38:10 - 38:11]
+// CHECK-source: usrs.m:40:8: ObjCClassMethodDecl=kingkong:40:8 (Definition) Extent=[40:1 - 43:2]
+// CHECK-source: usrs.m:40:4: TypeRef=id:0:0 Extent=[40:4 - 40:6]
+// CHECK-source: usrs.m:40:17: CompoundStmt= Extent=[40:17 - 43:2]
+// CHECK-source: usrs.m:41:3: DeclStmt= Extent=[41:3 - 41:17]
+// CHECK-source: usrs.m:41:7: VarDecl=local_var:41:7 (Definition) Extent=[41:3 - 41:16]
+// CHECK-source: usrs.m:42:3: ReturnStmt= Extent=[42:3 - 42:11]
+// CHECK-source: usrs.m:42:10: UnexposedExpr= Extent=[42:10 - 42:11]
+// CHECK-source: usrs.m:42:10: IntegerLiteral= Extent=[42:10 - 42:11]
+// CHECK-source: usrs.m:44:13: ObjCIvarDecl=d1:44:13 (Definition) Extent=[44:13 - 44:15]
+// CHECK-source: usrs.m:44:13: ObjCSynthesizeDecl=d1:31:15 (Definition) Extent=[44:1 - 44:15]
+// CHECK-source: usrs.m:47:5: VarDecl=z:47:5 Extent=[47:1 - 47:6]
+// CHECK-source: usrs.m:49:12: FunctionDecl=local_func:49:12 (Definition) Extent=[49:1 - 49:43]
+// CHECK-source: usrs.m:49:27: ParmDecl=x:49:27 (Definition) Extent=[49:23 - 49:28]
+// CHECK-source: usrs.m:49:30: CompoundStmt= Extent=[49:30 - 49:43]
+// CHECK-source: usrs.m:49:32: ReturnStmt= Extent=[49:32 - 49:40]
+// CHECK-source: usrs.m:49:39: DeclRefExpr=x:49:27 Extent=[49:39 - 49:40]
+// CHECK-source: usrs.m:51:12: ObjCInterfaceDecl=CWithExt:51:12 Extent=[51:1 - 53:5]
+// CHECK-source: usrs.m:52:8: ObjCInstanceMethodDecl=meth1:52:8 Extent=[52:1 - 52:14]
+// CHECK-source: usrs.m:52:4: TypeRef=id:0:0 Extent=[52:4 - 52:6]
+// CHECK-source: usrs.m:54:12: ObjCCategoryDecl=:54:12 Extent=[54:1 - 56:5]
+// CHECK-source: usrs.m:54:12: ObjCClassRef=CWithExt:51:12 Extent=[54:12 - 54:20]
+// CHECK-source: usrs.m:55:8: ObjCInstanceMethodDecl=meth2:55:8 Extent=[55:1 - 55:14]
+// CHECK-source: usrs.m:55:4: TypeRef=id:0:0 Extent=[55:4 - 55:6]
+// CHECK-source: usrs.m:57:12: ObjCCategoryDecl=:57:12 Extent=[57:1 - 59:5]
+// CHECK-source: usrs.m:57:12: ObjCClassRef=CWithExt:51:12 Extent=[57:12 - 57:20]
+// CHECK-source: usrs.m:58:8: ObjCInstanceMethodDecl=meth3:58:8 Extent=[58:1 - 58:14]
+// CHECK-source: usrs.m:58:4: TypeRef=id:0:0 Extent=[58:4 - 58:6]
+// CHECK-source: usrs.m:60:12: ObjCCategoryDecl=Bar:60:12 Extent=[60:1 - 62:5]
+// CHECK-source: usrs.m:60:12: ObjCClassRef=CWithExt:51:12 Extent=[60:12 - 60:20]
+// CHECK-source: usrs.m:61:8: ObjCInstanceMethodDecl=meth4:61:8 Extent=[61:1 - 61:14]
+// CHECK-source: usrs.m:61:4: TypeRef=id:0:0 Extent=[61:4 - 61:6]
+// CHECK-source: usrs.m:63:17: ObjCImplementationDecl=CWithExt:63:17 (Definition) Extent=[63:1 - 67:2]
+// CHECK-source: usrs.m:64:8: ObjCInstanceMethodDecl=meth1:64:8 (Definition) Extent=[64:1 - 64:27]
+// CHECK-source: usrs.m:64:4: TypeRef=id:0:0 Extent=[64:4 - 64:6]
+// CHECK-source: usrs.m:64:14: CompoundStmt= Extent=[64:14 - 64:27]
+// CHECK-source: usrs.m:64:16: ReturnStmt= Extent=[64:16 - 64:24]
+// CHECK-source: usrs.m:64:23: UnexposedExpr= Extent=[64:23 - 64:24]
+// CHECK-source: usrs.m:64:23: IntegerLiteral= Extent=[64:23 - 64:24]
+// CHECK-source: usrs.m:65:8: ObjCInstanceMethodDecl=meth2:65:8 (Definition) Extent=[65:1 - 65:27]
+// CHECK-source: usrs.m:65:4: TypeRef=id:0:0 Extent=[65:4 - 65:6]
+// CHECK-source: usrs.m:65:14: CompoundStmt= Extent=[65:14 - 65:27]
+// CHECK-source: usrs.m:65:16: ReturnStmt= Extent=[65:16 - 65:24]
+// CHECK-source: usrs.m:65:23: UnexposedExpr= Extent=[65:23 - 65:24]
+// CHECK-source: usrs.m:65:23: IntegerLiteral= Extent=[65:23 - 65:24]
+// CHECK-source: usrs.m:66:8: ObjCInstanceMethodDecl=meth3:66:8 (Definition) Extent=[66:1 - 66:27]
+// CHECK-source: usrs.m:66:4: TypeRef=id:0:0 Extent=[66:4 - 66:6]
+// CHECK-source: usrs.m:66:14: CompoundStmt= Extent=[66:14 - 66:27]
+// CHECK-source: usrs.m:66:16: ReturnStmt= Extent=[66:16 - 66:24]
+// CHECK-source: usrs.m:66:23: UnexposedExpr= Extent=[66:23 - 66:24]
+// CHECK-source: usrs.m:66:23: IntegerLiteral= Extent=[66:23 - 66:24]
+// CHECK-source: usrs.m:68:17: ObjCCategoryImplDecl=Bar:68:17 (Definition) Extent=[68:1 - 70:2]
+// CHECK-source: usrs.m:68:17: ObjCClassRef=CWithExt:51:12 Extent=[68:17 - 68:25]
+// CHECK-source: usrs.m:69:8: ObjCInstanceMethodDecl=meth4:69:8 (Definition) Extent=[69:1 - 69:27]
+// CHECK-source: usrs.m:69:4: TypeRef=id:0:0 Extent=[69:4 - 69:6]
+// CHECK-source: usrs.m:69:14: CompoundStmt= Extent=[69:14 - 69:27]
+// CHECK-source: usrs.m:69:16: ReturnStmt= Extent=[69:16 - 69:24]
+// CHECK-source: usrs.m:69:23: UnexposedExpr= Extent=[69:23 - 69:24]
+// CHECK-source: usrs.m:69:23: IntegerLiteral= Extent=[69:23 - 69:24]
+// CHECK-source: usrs.m:72:6: FunctionDecl=aux_1:72:6 Extent=[72:1 - 72:26]
+// CHECK-source: usrs.m:72:15: ParmDecl=:72:15 (Definition) Extent=[72:12 - 72:16]
+// CHECK-source: usrs.m:72:20: ParmDecl=:72:20 (Definition) Extent=[72:17 - 72:21]
+// CHECK-source: usrs.m:72:25: ParmDecl=:72:25 (Definition) Extent=[72:22 - 72:26]
+// CHECK-source: usrs.m:73:5: FunctionDecl=test_multi_declaration:73:5 (Definition) Extent=[73:1 - 77:2]
+// CHECK-source: usrs.m:73:34: CompoundStmt= Extent=[73:34 - 77:2]
+// CHECK-source: usrs.m:74:3: DeclStmt= Extent=[74:3 - 74:33]
+// CHECK-source: usrs.m:74:7: VarDecl=foo:74:7 (Definition) Extent=[74:3 - 74:14]
+// CHECK-source: usrs.m:74:13: IntegerLiteral= Extent=[74:13 - 74:14]
+// CHECK-source: usrs.m:74:16: VarDecl=bar:74:16 Extent=[74:16 - 74:23]
+// CHECK-source: usrs.m:74:22: IntegerLiteral= Extent=[74:22 - 74:23]
+// CHECK-source: usrs.m:74:25: VarDecl=baz:74:25 Extent=[74:25 - 74:32]
+// CHECK-source: usrs.m:74:31: IntegerLiteral= Extent=[74:31 - 74:32]
+// CHECK-source: usrs.m:75:3: CallExpr=aux_1:72:6 Extent=[75:3 - 75:23]
+// CHECK-source: usrs.m:75:3: UnexposedExpr=aux_1:72:6 Extent=[75:3 - 75:8]
+// CHECK-source: usrs.m:75:3: DeclRefExpr=aux_1:72:6 Extent=[75:3 - 75:8]
+// CHECK-source: usrs.m:75:9: DeclRefExpr=foo:74:7 Extent=[75:9 - 75:12]
+// CHECK-source: usrs.m:75:14: DeclRefExpr=bar:74:16 Extent=[75:14 - 75:17]
+// CHECK-source: usrs.m:75:19: DeclRefExpr=baz:74:25 Extent=[75:19 - 75:22]
+// CHECK-source: usrs.m:76:3: ReturnStmt= Extent=[76:3 - 76:11]
+// CHECK-source: usrs.m:76:10: IntegerLiteral= Extent=[76:10 - 76:11]
+// CHECK-source: usrs.m:79:11: ObjCProtocolDecl=P1:79:11 (Definition) Extent=[79:1 - 81:5]
+// CHECK-source: usrs.m:80:9: ObjCInstanceMethodDecl=method:80:9 Extent=[80:1 - 80:16]
+
diff --git a/clang/test/Index/vector-types.c b/clang/test/Index/vector-types.c
new file mode 100644
index 0000000..404e4a5
--- /dev/null
+++ b/clang/test/Index/vector-types.c
@@ -0,0 +1,6 @@
+int __attribute__((vector_size(16))) x;
+typedef int __attribute__((vector_size(16))) int4_t;
+
+// RUN: c-index-test -test-print-typekind %s | FileCheck %s
+// CHECK: VarDecl=x:1:38 typekind=Vector [isPOD=1]
+// CHECK: TypedefDecl=int4_t:2:46 (Definition) typekind=Typedef [canonical=Vector] [isPOD=1]
diff --git a/clang/test/Index/warning-flags.c b/clang/test/Index/warning-flags.c
new file mode 100644
index 0000000..b76662e
--- /dev/null
+++ b/clang/test/Index/warning-flags.c
@@ -0,0 +1,16 @@
+int foo() { }
+int *bar(float *f) { return f; }
+
+// RUN: c-index-test -test-load-source all %s 2>&1|FileCheck -check-prefix=CHECK-BOTH-WARNINGS %s
+// RUN: c-index-test -test-load-source-reparse 5 all %s 2>&1|FileCheck -check-prefix=CHECK-BOTH-WARNINGS %s
+// RUN: c-index-test -test-load-source all -Wno-return-type %s 2>&1|FileCheck -check-prefix=CHECK-SECOND-WARNING %s
+// RUN: c-index-test -test-load-source-reparse 5 all -Wno-return-type %s 2>&1|FileCheck -check-prefix=CHECK-SECOND-WARNING %s
+// RUN: c-index-test -test-load-source all -w %s 2>&1|not grep warning:
+// RUN: c-index-test -test-load-source-reparse 5 all -w %s 2>&1|not grep warning:
+
+// CHECK-BOTH-WARNINGS: warning: control reaches end of non-void function
+// CHECK-BOTH-WARNINGS: warning: incompatible pointer types returning 'float *' from a function with result type 'int *'
+
+// CHECK-SECOND-WARNING-NOT:control reaches end of non-void
+// CHECK-SECOND-WARNING: warning: incompatible pointer types returning 'float *' from a function with result type 'int *'
+
diff --git a/clang/test/Index/werror.c b/clang/test/Index/werror.c
new file mode 100644
index 0000000..98b602a
--- /dev/null
+++ b/clang/test/Index/werror.c
@@ -0,0 +1,12 @@
+inline int *get_int_ptr(float *fp) {
+ return fp;
+}
+
+#ifdef FATAL
+void fatal(int);
+void fatal(float);
+#endif
+
+// RUN: c-index-test -write-pch %t.pch -Werror %s
+// RUN: c-index-test -write-pch %t.pch -DFATAL -Werror %s
+
diff --git a/clang/test/Lexer/11-27-2007-FloatLiterals.c b/clang/test/Lexer/11-27-2007-FloatLiterals.c
new file mode 100644
index 0000000..f3d978b
--- /dev/null
+++ b/clang/test/Lexer/11-27-2007-FloatLiterals.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: 0x3BFD83C940000000
+// CHECK: 2.000000e+{{[0]*}}32
+// CHECK: 0x3BFD83C940000000
+// CHECK: 2.000000e+{{[0]*}}32
+// CHECK: 0x7FF0000000000000
+
+float F = 1e-19f;
+double D = 2e32;
+float F2 = 01e-19f;
+double D2 = 02e32;
+float F3 = 0xFp100000000000000000000F;
diff --git a/clang/test/Lexer/badstring_in_if0.c b/clang/test/Lexer/badstring_in_if0.c
new file mode 100644
index 0000000..486dcf2
--- /dev/null
+++ b/clang/test/Lexer/badstring_in_if0.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -E %s 2>&1 | not grep error
+#if 0
+
+ "
+
+ '
+
+#endif
diff --git a/clang/test/Lexer/bcpl-escaped-newline.c b/clang/test/Lexer/bcpl-escaped-newline.c
new file mode 100644
index 0000000..4d4a7b5
--- /dev/null
+++ b/clang/test/Lexer/bcpl-escaped-newline.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -Eonly -trigraphs %s
+// RUN: %clang_cc1 -Eonly -verify %s
+
+//\
+#error bar
+
+//??/
+#error qux // expected-error {{qux}}
+
+// Trailing whitespace!
+//\
+#error quux
diff --git a/clang/test/Lexer/block_cmt_end.c b/clang/test/Lexer/block_cmt_end.c
new file mode 100644
index 0000000..f54b6a4
--- /dev/null
+++ b/clang/test/Lexer/block_cmt_end.c
@@ -0,0 +1,34 @@
+/*
+ RUN: %clang_cc1 -E -trigraphs %s | grep bar
+ RUN: %clang_cc1 -E -trigraphs %s | grep foo
+ RUN: %clang_cc1 -E -trigraphs %s | not grep qux
+ RUN: %clang_cc1 -E -trigraphs %s | not grep xyz
+ RUN: %clang_cc1 -fsyntax-only -trigraphs -verify %s
+*/
+
+// This is a simple comment, /*/ does not end a comment, the trailing */ does.
+int i = /*/ */ 1;
+
+/* qux
+
+next comment ends with normal escaped newline:
+*/
+
+/* expected-warning {{escaped newline}} expected-warning {{backslash and newline}} *\
+/
+
+int bar /* expected-error {{expected ';' after top level declarator}} */
+
+/* xyz
+
+next comment ends with a trigraph escaped newline: */
+
+/* expected-warning {{escaped newline between}} expected-warning {{backslash and newline separated by space}} expected-warning {{trigraph ends block comment}} *??/
+/
+
+foo
+
+
+// rdar://6060752 - We should not get warnings about trigraphs in comments:
+// '????'
+/* ???? */
diff --git a/clang/test/Lexer/c90.c b/clang/test/Lexer/c90.c
new file mode 100644
index 0000000..d910572
--- /dev/null
+++ b/clang/test/Lexer/c90.c
@@ -0,0 +1,34 @@
+/* RUN: %clang_cc1 -std=c90 -fsyntax-only %s -verify -pedantic-errors
+ */
+
+enum { cast_hex = (long) (
+ 0x0p-1 /* expected-error {{hexadecimal floating constants are a C99 feature}} */
+ ) };
+
+/* PR2477 */
+int test1(int a,int b) {return a//* This is a divide followed by block comment in c89 mode */
+b;}
+
+// comment accepted as extension /* expected-error {{// comments are not allowed in this language}}
+
+void test2() {
+ const char * str =
+ "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds" // expected-error{{string literal of length 845 exceeds maximum length 509 that C90 compilers are required to support}}
+ "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds"
+ "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds"
+ "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds"
+ "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds"
+ "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds"
+ "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds"
+ "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds"
+ "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds"
+ "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds"
+ "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds"
+ "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds"
+ "sdjflksdjf lksdjf skldfjsdkljflksdjf kldsjflkdsj fldks jflsdkjfds";
+}
+
+void test3() {
+ (void)L"\u1234"; // expected-error {{unicode escape sequences are only valid in C99 or C++}}
+ (void)L'\u1234'; // expected-error {{unicode escape sequences are only valid in C99 or C++}}
+}
diff --git a/clang/test/Lexer/char-escapes.c b/clang/test/Lexer/char-escapes.c
new file mode 100644
index 0000000..32a1c61
--- /dev/null
+++ b/clang/test/Lexer/char-escapes.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+
+int test['\\' == 92 ? 1 : -1];
+int test['\"' == 34 ? 1 : -1];
+int test['\'' == 39 ? 1 : -1];
+int test['\?' == 63 ? 1 : -1];
+int test['\a' == 7 ? 1 : -1];
+int test['\b' == 8 ? 1 : -1];
+int test['\e' == 27 ? 1 : -1]; // expected-warning {{non-standard escape}}
+int test['\E' == 27 ? 1 : -1]; // expected-warning {{non-standard escape}}
+int test['\f' == 12 ? 1 : -1];
+int test['\n' == 10 ? 1 : -1];
+int test['\r' == 13 ? 1 : -1];
+int test['\t' == 9 ? 1 : -1];
+int test['\v' == 11 ? 1 : -1];
+int test['\xa' == 10 ? 1 : -1];
+int test['\1' == 1 ? 1 : -1];
+int test['\(' == 40 ? 1 : -1]; // expected-warning {{non-standard escape}}
+int test['\{' == 123 ? 1 : -1]; // expected-warning {{non-standard escape}}
+int test['\[' == 91 ? 1 : -1]; // expected-warning {{non-standard escape}}
+int test['\%' == 37 ? 1 : -1]; // expected-warning {{non-standard escape}}
+const char *format = "abc \m def"; // expected-warning{{unknown escape sequence '\m'}}
diff --git a/clang/test/Lexer/char-literal-encoding-error.c b/clang/test/Lexer/char-literal-encoding-error.c
new file mode 100644
index 0000000..e752de2
--- /dev/null
+++ b/clang/test/Lexer/char-literal-encoding-error.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -x c++ %s
+
+// This file is encoded using ISO-8859-1
+
+int main() {
+ (void)''; // expected-warning {{illegal character encoding in character literal}}
+ (void)u''; // expected-error {{illegal character encoding in character literal}}
+ (void)U''; // expected-error {{illegal character encoding in character literal}}
+ (void)L''; // expected-error {{illegal character encoding in character literal}}
+
+ // For narrow character literals, since there is no error, make sure the
+ // encoding is correct
+ static_assert((unsigned char)'' == 0xE9, ""); // expected-warning {{illegal character encoding in character literal}}
+ static_assert('' == 0xE9E9, ""); // expected-warning {{illegal character encoding in character literal}} expected-warning {{multi-character character constant}}
+}
diff --git a/clang/test/Lexer/char-literal.cpp b/clang/test/Lexer/char-literal.cpp
new file mode 100644
index 0000000..5dc5360
--- /dev/null
+++ b/clang/test/Lexer/char-literal.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -Wfour-char-constants -fsyntax-only -verify %s
+
+int a = 'ab'; // expected-warning {{multi-character character constant}}
+int b = '\xFF\xFF'; // expected-warning {{multi-character character constant}}
+int c = 'APPS'; // expected-warning {{multi-character character constant}}
+
+char d = '⌘'; // expected-error {{character too large for enclosing character literal type}}
+char e = '\u2318'; // expected-error {{character too large for enclosing character literal type}}
+
+auto f = '\xE2\x8C\x98'; // expected-warning {{multi-character character constant}}
+
+char16_t g = u'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
+char16_t h = u'\U0010FFFD'; // expected-error {{character too large for enclosing character literal type}}
+
+wchar_t i = L'ab'; // expected-warning {{extraneous characters in character constant ignored}}
+wchar_t j = L'\U0010FFFD';
+
+char32_t k = U'\U0010FFFD';
+
+char l = 'Ø'; // expected-error {{character too large for enclosing character literal type}}
+char m = '👿'; // expected-error {{character too large for enclosing character literal type}}
+
+char32_t n = U'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
+char16_t o = '👽'; // expected-error {{character too large for enclosing character literal type}}
diff --git a/clang/test/Lexer/clang-keywords.cpp b/clang/test/Lexer/clang-keywords.cpp
new file mode 100644
index 0000000..a349b44
--- /dev/null
+++ b/clang/test/Lexer/clang-keywords.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+__char16_t c16;
+void f(__char32_t) { }
diff --git a/clang/test/Lexer/comment-escape.c b/clang/test/Lexer/comment-escape.c
new file mode 100644
index 0000000..191e654
--- /dev/null
+++ b/clang/test/Lexer/comment-escape.c
@@ -0,0 +1,6 @@
+// RUN: %clang -fsyntax-only %s
+// rdar://6757323
+// foo \
+
+#define blork 32
+
diff --git a/clang/test/Lexer/conflict-marker.c b/clang/test/Lexer/conflict-marker.c
new file mode 100644
index 0000000..2a8e43b
--- /dev/null
+++ b/clang/test/Lexer/conflict-marker.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+// Test that we recover gracefully from conflict markers left in input files.
+// PR5238
+
+// diff3 style
+<<<<<<< .mine // expected-error {{version control conflict marker in file}}
+int x = 4;
+|||||||
+int x = 123;
+=======
+float x = 17;
+>>>>>>> .r91107
+
+// normal style.
+<<<<<<< .mine // expected-error {{version control conflict marker in file}}
+typedef int y;
+=======
+typedef struct foo *y;
+>>>>>>> .r91107
+
+// Perforce style.
+>>>> ORIGINAL conflict-marker.c#6 // expected-error {{version control conflict marker in file}}
+int z = 1;
+==== THEIRS conflict-marker.c#7
+int z = 0;
+==== YOURS conflict-marker.c
+int z = 2;
+<<<<
+
+;
+y b;
+
+
+int foo() {
+ y a = x;
+ return x + a - z;
+}
diff --git a/clang/test/Lexer/constants.c b/clang/test/Lexer/constants.c
new file mode 100644
index 0000000..2903885
--- /dev/null
+++ b/clang/test/Lexer/constants.c
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -trigraphs %s
+
+int x = 000000080; // expected-error {{invalid digit}}
+
+int y = 0000\
+00080; // expected-error {{invalid digit}}
+
+
+
+float X = 1.17549435e-38F;
+float Y = 08.123456;
+
+// PR2252
+#if -0x8000000000000000 // should not warn.
+#endif
+
+
+int c[] = {
+ 'df', // expected-warning {{multi-character character constant}}
+ '\t',
+ '\\
+t',
+ '??!', // expected-warning {{trigraph converted to '|' character}}
+ 'abcd' // expected-warning {{multi-character character constant}}
+};
+
+// PR4499
+int m0 = '0';
+int m1 = '\\\''; // expected-warning {{multi-character character constant}}
+int m2 = '\\\\'; // expected-warning {{multi-character character constant}}
+int m3 = '\\\
+';
+
+
+#pragma clang diagnostic ignored "-Wmultichar"
+
+int d = 'df'; // no warning.
+int e = 'abcd'; // still warn: expected-warning {{multi-character character constant}}
+
+#pragma clang diagnostic ignored "-Wfour-char-constants"
+
+int f = 'abcd'; // ignored.
+
+// rdar://problem/6974641
+float t0[] = {
+ 1.9e20f,
+ 1.9e-20f,
+ 1.9e50f, // expected-warning {{too large}}
+ 1.9e-50f, // expected-warning {{too small}}
+ -1.9e20f,
+ -1.9e-20f,
+ -1.9e50f, // expected-warning {{too large}}
+ -1.9e-50f // expected-warning {{too small}}
+};
+double t1[] = {
+ 1.9e50,
+ 1.9e-50,
+ 1.9e500, // expected-warning {{too large}}
+ 1.9e-500, // expected-warning {{too small}}
+ -1.9e50,
+ -1.9e-50,
+ -1.9e500, // expected-warning {{too large}}
+ -1.9e-500 // expected-warning {{too small}}
+};
+
+// PR7888
+double g = 1e100000000; // expected-warning {{too large}}
+
+char h = '\u1234'; // expected-error {{character too large for enclosing character literal type}}
diff --git a/clang/test/Lexer/counter.c b/clang/test/Lexer/counter.c
new file mode 100644
index 0000000..2173730
--- /dev/null
+++ b/clang/test/Lexer/counter.c
@@ -0,0 +1,16 @@
+// __COUNTER__ support: rdar://4329310
+// RUN: %clang -E %s > %t
+
+#define PASTE2(x,y) x##y
+#define PASTE1(x,y) PASTE2(x,y)
+#define UNIQUE(x) PASTE1(x,__COUNTER__)
+
+// RUN: grep "A: 0" %t
+A: __COUNTER__
+
+// RUN: grep "B: foo1" %t
+B: UNIQUE(foo);
+// RUN: grep "C: foo2" %t
+C: UNIQUE(foo);
+// RUN: grep "D: 3" %t
+D: __COUNTER__
diff --git a/clang/test/Lexer/cxx0x_keyword.cpp b/clang/test/Lexer/cxx0x_keyword.cpp
new file mode 100644
index 0000000..e6841ef
--- /dev/null
+++ b/clang/test/Lexer/cxx0x_keyword.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 2>&1
+int static_assert; /* expected-error {{expected unqualified-id}} */
diff --git a/clang/test/Lexer/cxx0x_keyword_as_cxx98.cpp b/clang/test/Lexer/cxx0x_keyword_as_cxx98.cpp
new file mode 100644
index 0000000..5d16810
--- /dev/null
+++ b/clang/test/Lexer/cxx0x_keyword_as_cxx98.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Wc++11-compat
+
+#define constexpr const
+constexpr int x = 0;
+#undef constexpr
+
+namespace lib {
+ struct nullptr_t;
+ typedef nullptr_t nullptr; // expected-warning {{'nullptr' is a keyword in C++11}}
+}
+
+#define CONCAT(X,Y) CONCAT2(X,Y)
+#define CONCAT2(X,Y) X ## Y
+int CONCAT(constexpr,ession);
+
+#define ID(X) X
+extern int ID(decltype); // expected-warning {{'decltype' is a keyword in C++11}}
+
+extern int CONCAT(align,of); // expected-warning {{'alignof' is a keyword in C++11}}
+
+#define static_assert(b, s) int CONCAT(check, __LINE__)[(b) ? 1 : 0];
+static_assert(1 > 0, "hello"); // ok
+
+#define IF_CXX11(CXX11, CXX03) CXX03
+typedef IF_CXX11(char16_t, wchar_t) my_wide_char_t; // ok
+
+int alignas; // expected-warning {{'alignas' is a keyword in C++11}}
+int alignof; // already diagnosed in this TU
+int char16_t; // expected-warning {{'char16_t' is a keyword in C++11}}
+int char32_t; // expected-warning {{'char32_t' is a keyword in C++11}}
+int constexpr; // expected-warning {{'constexpr' is a keyword in C++11}}
+int decltype; // already diagnosed in this TU
+int noexcept; // expected-warning {{'noexcept' is a keyword in C++11}}
+int nullptr; // already diagnosed in this TU
+int static_assert; // expected-warning {{'static_assert' is a keyword in C++11}}
+int thread_local; // expected-warning {{'thread_local' is a keyword in C++11}}
diff --git a/clang/test/Lexer/cxx0x_raw_string_delim_length.cpp b/clang/test/Lexer/cxx0x_raw_string_delim_length.cpp
new file mode 100644
index 0000000..b9f6d13
--- /dev/null
+++ b/clang/test/Lexer/cxx0x_raw_string_delim_length.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+const char *str1 = R"(abcdef)"; // ok
+const char *str2 = R"foo()foo"; // ok
+const char *str3 = R"()"; // ok
+// FIXME: recover better than this.
+const char *str4 = R"abcdefghijkmnopqrstuvwxyz(abcdef)abcdefghijkmnopqrstuvwxyz"; // expected-error {{raw string delimiter longer than 16 characters}} expected-error {{expected expression}}
diff --git a/clang/test/Lexer/cxx0x_raw_string_unterminated.cpp b/clang/test/Lexer/cxx0x_raw_string_unterminated.cpp
new file mode 100644
index 0000000..dfbaaee
--- /dev/null
+++ b/clang/test/Lexer/cxx0x_raw_string_unterminated.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -std=c++11 -E %s 2>&1 | grep 'error: raw string missing terminating delimiter )foo"'
+
+const char *str = R"foo(abc
+def)bar";
diff --git a/clang/test/Lexer/digraph.c b/clang/test/Lexer/digraph.c
new file mode 100644
index 0000000..cf6e478
--- /dev/null
+++ b/clang/test/Lexer/digraph.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -ffreestanding %s
+
+%:include <stdint.h>
+
+ %:ifndef BUFSIZE
+ %:define BUFSIZE 512
+ %:endif
+
+ void copy(char d<::>, const char s<::>, int len)
+ <%
+ while (len-- >= 0)
+ <%
+ d<:len:> = s<:len:>;
+ %>
+ %>
diff --git a/clang/test/Lexer/dollar-idents.c b/clang/test/Lexer/dollar-idents.c
new file mode 100644
index 0000000..cbf25b0
--- /dev/null
+++ b/clang/test/Lexer/dollar-idents.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -dump-tokens %s 2> %t
+// RUN: grep "identifier '\$A'" %t
+// RUN: %clang_cc1 -dump-tokens -x assembler-with-cpp %s 2> %t
+// RUN: grep "identifier 'A'" %t
+// PR3808
+
+$A
diff --git a/clang/test/Lexer/escape_newline.c b/clang/test/Lexer/escape_newline.c
new file mode 100644
index 0000000..d0f27df
--- /dev/null
+++ b/clang/test/Lexer/escape_newline.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -trigraphs %s | grep -- ' ->'
+// RUN: %clang_cc1 -E -trigraphs %s 2>&1 | grep 'backslash and newline separated by space'
+// RUN: %clang_cc1 -E -trigraphs %s 2>&1 | grep 'trigraph converted'
+// RUN: %clang_cc1 -E -CC -trigraphs %s
+
+// This is an ugly way to spell a -> token.
+ -??/
+>
+
+// \
+
diff --git a/clang/test/Lexer/gnu_keywords.c b/clang/test/Lexer/gnu_keywords.c
new file mode 100644
index 0000000..c4bd9b3
--- /dev/null
+++ b/clang/test/Lexer/gnu_keywords.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -DGNU_KEYWORDS -std=gnu89 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DGNU_KEYWORDS -std=c99 -fgnu-keywords -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=gnu89 -fno-gnu-keywords -fsyntax-only -verify %s
+
+void f() {
+#ifdef GNU_KEYWORDS
+ asm ("ret" : :);
+#else
+ int asm;
+#endif
+}
diff --git a/clang/test/Lexer/has_extension.c b/clang/test/Lexer/has_extension.c
new file mode 100644
index 0000000..3b08510
--- /dev/null
+++ b/clang/test/Lexer/has_extension.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-PED-NONE %s
+// RUN: %clang_cc1 -pedantic-errors -E %s -o - | FileCheck --check-prefix=CHECK-PED-ERR %s
+
+// CHECK-PED-NONE: no_dummy_extension
+#if !__has_extension(dummy_extension)
+int no_dummy_extension();
+#endif
+
+// Arbitrary feature to test that has_extension is a superset of has_feature
+// CHECK-PED-NONE: attribute_overloadable
+#if __has_extension(attribute_overloadable)
+int attribute_overloadable();
+#endif
+
+// CHECK-PED-NONE: has_c_static_assert
+// CHECK-PED-ERR: no_c_static_assert
+#if __has_extension(c_static_assert)
+int has_c_static_assert();
+#else
+int no_c_static_assert();
+#endif
+
+// CHECK-PED-NONE: has_c_generic_selections
+// CHECK-PED-ERR: no_c_generic_selections
+#if __has_extension(c_generic_selections)
+int has_c_generic_selections();
+#else
+int no_c_generic_selections();
+#endif
+
+// CHECK-PED-NONE: has_c_alignas
+// CHECK-PED-ERR: no_c_alignas
+#if __has_extension(c_alignas)
+int has_c_alignas();
+#else
+int no_c_alignas();
+#endif
+
+// Arbitrary feature to test that the extension name can be surrounded with
+// double underscores.
+// CHECK-PED-NONE: has_double_underscores
+#if __has_extension(__c_alignas__)
+int has_double_underscores();
+#endif
diff --git a/clang/test/Lexer/has_extension_cxx.cpp b/clang/test/Lexer/has_extension_cxx.cpp
new file mode 100644
index 0000000..6ffeebd
--- /dev/null
+++ b/clang/test/Lexer/has_extension_cxx.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -E %s -o - | FileCheck %s
+
+// CHECK: c_static_assert
+#if __has_extension(c_static_assert)
+int c_static_assert();
+#endif
+
+// CHECK: c_generic_selections
+#if __has_extension(c_generic_selections)
+int c_generic_selections();
+#endif
+
+// CHECK: has_deleted_functions
+#if __has_extension(cxx_deleted_functions)
+int has_deleted_functions();
+#endif
+
+// CHECK: has_inline_namespaces
+#if __has_extension(cxx_inline_namespaces)
+int has_inline_namespaces();
+#endif
+
+// CHECK: has_override_control
+#if __has_extension(cxx_override_control)
+int has_override_control();
+#endif
+
+// CHECK: has_range_for
+#if __has_extension(cxx_range_for)
+int has_range_for();
+#endif
+
+// CHECK: has_reference_qualified_functions
+#if __has_extension(cxx_reference_qualified_functions)
+int has_reference_qualified_functions();
+#endif
+
+// CHECK: has_rvalue_references
+#if __has_extension(cxx_rvalue_references)
+int has_rvalue_references();
+#endif
+
+#if __has_extension(cxx_local_type_template_args)
+int has_local_type_template_args();
+#else
+int no_local_type_template_args();
+#endif
+
+// CHECK: has_local_type_template_args
diff --git a/clang/test/Lexer/has_feature_address_sanitizer.cpp b/clang/test/Lexer/has_feature_address_sanitizer.cpp
new file mode 100644
index 0000000..69acc39
--- /dev/null
+++ b/clang/test/Lexer/has_feature_address_sanitizer.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -faddress-sanitizer %s -o - | FileCheck --check-prefix=CHECK-ASAN %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-ASAN %s
+
+#if __has_feature(address_sanitizer)
+int AddressSanitizerEnabled();
+#else
+int AddressSanitizerDisabled();
+#endif
+
+// CHECK-ASAN: AddressSanitizerEnabled
+// CHECK-NO-ASAN: AddressSanitizerDisabled
diff --git a/clang/test/Lexer/has_feature_c1x.c b/clang/test/Lexer/has_feature_c1x.c
new file mode 100644
index 0000000..c9a5f56
--- /dev/null
+++ b/clang/test/Lexer/has_feature_c1x.c
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -E -std=c1x %s -o - | FileCheck --check-prefix=CHECK-1X %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-1X %s
+
+#if __has_feature(c_atomic)
+int has_atomic();
+#else
+int no_atomic();
+#endif
+
+// CHECK-1X: has_atomic
+// CHECK-NO-1X: no_atomic
+
+#if __has_feature(c_static_assert)
+int has_static_assert();
+#else
+int no_static_assert();
+#endif
+
+// CHECK-1X: has_static_assert
+// CHECK-NO-1X: no_static_assert
+
+#if __has_feature(c_generic_selections)
+int has_generic_selections();
+#else
+int no_generic_selections();
+#endif
+
+// CHECK-1X: has_generic_selections
+// CHECK-NO-1X: no_generic_selections
+
+#if __has_feature(c_alignas)
+int has_alignas();
+#else
+int no_alignas();
+#endif
+
+// CHECK-1X: has_alignas
+// CHECK-NO-1X: no_alignas
+
+#if __STDC_VERSION__ > 199901L
+int is_c1x();
+#else
+int is_not_c1x();
+#endif
+
+// CHECK-1X: is_c1x
+// CHECK-NO-1X: is_not_c1x
diff --git a/clang/test/Lexer/has_feature_cxx0x.cpp b/clang/test/Lexer/has_feature_cxx0x.cpp
new file mode 100644
index 0000000..8e0222d
--- /dev/null
+++ b/clang/test/Lexer/has_feature_cxx0x.cpp
@@ -0,0 +1,274 @@
+// RUN: %clang_cc1 -E -std=c++11 %s -o - | FileCheck --check-prefix=CHECK-0X %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-0X %s
+
+#if __has_feature(cxx_atomic)
+int has_atomic();
+#else
+int no_atomic();
+#endif
+
+// CHECK-0X: has_atomic
+// CHECK-NO-0X: no_atomic
+
+#if __has_feature(cxx_lambdas)
+int has_lambdas();
+#else
+int no_lambdas();
+#endif
+
+// CHECK-0X: has_lambdas
+// CHECK-NO-0X: no_lambdas
+
+
+#if __has_feature(cxx_nullptr)
+int has_nullptr();
+#else
+int no_nullptr();
+#endif
+
+// CHECK-0X: has_nullptr
+// CHECK-NO-0X: no_nullptr
+
+
+#if __has_feature(cxx_decltype)
+int has_decltype();
+#else
+int no_decltype();
+#endif
+
+// CHECK-0X: has_decltype
+// CHECK-NO-0X: no_decltype
+
+
+#if __has_feature(cxx_decltype_incomplete_return_types)
+int has_decltype_incomplete_return_types();
+#else
+int no_decltype_incomplete_return_types();
+#endif
+
+// CHECK-0X: has_decltype_incomplete_return_types
+// CHECK-NO-0X: no_decltype_incomplete_return_types
+
+
+#if __has_feature(cxx_auto_type)
+int has_auto_type();
+#else
+int no_auto_type();
+#endif
+
+// CHECK-0X: has_auto_type
+// CHECK-NO-0X: no_auto_type
+
+
+#if __has_feature(cxx_trailing_return)
+int has_trailing_return();
+#else
+int no_trailing_return();
+#endif
+
+// CHECK-0X: has_trailing_return
+// CHECK-NO-0X: no_trailing_return
+
+
+#if __has_feature(cxx_attributes)
+int has_attributes();
+#else
+int no_attributes();
+#endif
+
+// CHECK-0X: has_attributes
+// CHECK-NO-0X: no_attributes
+
+
+#if __has_feature(cxx_static_assert)
+int has_static_assert();
+#else
+int no_static_assert();
+#endif
+
+// CHECK-0X: has_static_assert
+// CHECK-NO-0X: no_static_assert
+
+#if __has_feature(cxx_deleted_functions)
+int has_deleted_functions();
+#else
+int no_deleted_functions();
+#endif
+
+// CHECK-0X: has_deleted_functions
+// CHECK-NO-0X: no_deleted_functions
+
+#if __has_feature(cxx_defaulted_functions)
+int has_defaulted_functions();
+#else
+int no_defaulted_functions();
+#endif
+
+// CHECK-0X: has_defaulted_functions
+// CHECK-NO-0X: no_defaulted_functions
+
+#if __has_feature(cxx_rvalue_references)
+int has_rvalue_references();
+#else
+int no_rvalue_references();
+#endif
+
+// CHECK-0X: has_rvalue_references
+// CHECK-NO-0X: no_rvalue_references
+
+
+#if __has_feature(cxx_variadic_templates)
+int has_variadic_templates();
+#else
+int no_variadic_templates();
+#endif
+
+// CHECK-0X: has_variadic_templates
+// CHECK-NO-0X: no_variadic_templates
+
+
+#if __has_feature(cxx_inline_namespaces)
+int has_inline_namespaces();
+#else
+int no_inline_namespaces();
+#endif
+
+// CHECK-0X: has_inline_namespaces
+// CHECK-NO-0X: no_inline_namespaces
+
+
+#if __has_feature(cxx_range_for)
+int has_range_for();
+#else
+int no_range_for();
+#endif
+
+// CHECK-0X: has_range_for
+// CHECK-NO-0X: no_range_for
+
+
+#if __has_feature(cxx_reference_qualified_functions)
+int has_reference_qualified_functions();
+#else
+int no_reference_qualified_functions();
+#endif
+
+// CHECK-0X: has_reference_qualified_functions
+// CHECK-NO-0X: no_reference_qualified_functions
+
+#if __has_feature(cxx_default_function_template_args)
+int has_default_function_template_args();
+#else
+int no_default_function_template_args();
+#endif
+
+// CHECK-0X: has_default_function_template_args
+// CHECK-NO-0X: no_default_function_template_args
+
+#if __has_feature(cxx_noexcept)
+int has_noexcept();
+#else
+int no_noexcept();
+#endif
+
+// CHECK-0X: has_noexcept
+// CHECK-NO-0X: no_noexcept
+
+#if __has_feature(cxx_override_control)
+int has_override_control();
+#else
+int no_override_control();
+#endif
+
+// CHECK-0X: has_override_control
+// CHECK-NO-0X: no_override_control
+
+#if __has_feature(cxx_alias_templates)
+int has_alias_templates();
+#else
+int no_alias_templates();
+#endif
+
+// CHECK-0X: has_alias_templates
+// CHECK-NO-0X: no_alias_templates
+
+#if __has_feature(cxx_implicit_moves)
+int has_implicit_moves();
+#else
+int no_implicit_moves();
+#endif
+
+// CHECK-0X: has_implicit_moves
+// CHECK-NO-0X: no_implicit_moves
+
+#if __has_feature(cxx_alignas)
+int has_alignas();
+#else
+int no_alignas();
+#endif
+
+// CHECK-0X: has_alignas
+// CHECK-NO-0X: no_alignas
+
+#if __has_feature(cxx_raw_string_literals)
+int has_raw_string_literals();
+#else
+int no_raw_string_literals();
+#endif
+
+// CHECK-0X: has_raw_string_literals
+// CHECK-NO-0X: no_raw_string_literals
+
+#if __has_feature(cxx_unicode_literals)
+int has_unicode_literals();
+#else
+int no_unicode_literals();
+#endif
+
+// CHECK-0X: has_unicode_literals
+// CHECK-NO-0X: no_unicode_literals
+
+#if __has_feature(cxx_constexpr)
+int has_constexpr();
+#else
+int no_constexpr();
+#endif
+
+// CHECK-0X: has_constexpr
+// CHECK-NO-0X: no_constexpr
+
+#if __has_feature(cxx_generalized_initializers)
+int has_generalized_initializers();
+#else
+int no_generalized_initializers();
+#endif
+
+// CHECK-0X: has_generalized_initializers
+// CHECK-NO-0X: no_generalized_initializers
+
+#if __has_feature(cxx_unrestricted_unions)
+int has_unrestricted_unions();
+#else
+int no_unrestricted_unions();
+#endif
+
+// CHECK-0X: has_unrestricted_unions
+// CHECK-NO-0X: no_unrestricted_unions
+
+#if __has_feature(cxx_user_literals)
+int has_user_literals();
+#else
+int no_user_literals();
+#endif
+
+// CHECK-0X: has_user_literals
+// CHECK-NO-0X: no_user_literals
+
+#if __has_feature(cxx_local_type_template_args)
+int has_local_type_template_args();
+#else
+int no_local_type_template_args();
+#endif
+
+// CHECK-0X: has_local_type_template_args
+// CHECK-NO-0X: no_local_type_template_args
diff --git a/clang/test/Lexer/has_feature_exceptions.cpp b/clang/test/Lexer/has_feature_exceptions.cpp
new file mode 100644
index 0000000..bb5dc0c
--- /dev/null
+++ b/clang/test/Lexer/has_feature_exceptions.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -fexceptions %s -o - | FileCheck --check-prefix=CHECK-EXCEPTIONS %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-EXCEPTIONS %s
+
+#if __has_feature(cxx_exceptions)
+int foo();
+#else
+int bar();
+#endif
+
+// CHECK-EXCEPTIONS: foo
+// CHECK-NO-EXCEPTIONS: bar
diff --git a/clang/test/Lexer/has_feature_modules.m b/clang/test/Lexer/has_feature_modules.m
new file mode 100644
index 0000000..6cea324
--- /dev/null
+++ b/clang/test/Lexer/has_feature_modules.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -E -fmodules %s -o - | FileCheck --check-prefix=CHECK-HAS-OBJC-MODULES %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-OBJC-MODULES %s
+// RUN: %clang_cc1 -E -x c -fmodules %s -o - | FileCheck --check-prefix=CHECK-NO-OBJC-MODULES %s
+
+// RUN: %clang_cc1 -E -fmodules %s -o - | FileCheck --check-prefix=CHECK-HAS-MODULES %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-MODULES %s
+// RUN: %clang_cc1 -E -x c -fmodules %s -o - | FileCheck --check-prefix=CHECK-HAS-MODULES %s
+
+#if __has_feature(modules)
+int has_modules();
+#else
+int no_modules();
+#endif
+
+// CHECK-HAS-MODULES: has_modules
+// CHECK-NO-MODULES: no_modules
+
+#if __has_feature(objc_modules)
+int has_objc_modules();
+#else
+int no_objc_modules();
+#endif
+
+// CHECK-HAS-OBJC-MODULES: has_objc_modules
+// CHECK-NO-OBJC-MODULES: no_objc_modules
diff --git a/clang/test/Lexer/has_feature_objc_arc.m b/clang/test/Lexer/has_feature_objc_arc.m
new file mode 100644
index 0000000..279b91a
--- /dev/null
+++ b/clang/test/Lexer/has_feature_objc_arc.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -E %s -fobjc-arc "-triple" "x86_64-apple-macosx10.7.0" -fobjc-runtime-has-weak | FileCheck --check-prefix=CHECK-ARC %s
+// RUN: %clang_cc1 -E %s -fobjc-arc "-triple" "x86_64-apple-macosx10.6.0" | FileCheck --check-prefix=CHECK-ARCLITE %s
+
+#if __has_feature(objc_arc)
+void has_objc_arc_feature();
+#else
+void no_objc_arc_feature();
+#endif
+
+#if __has_feature(objc_arc_weak)
+void has_objc_arc_weak_feature();
+#else
+void no_objc_arc_weak_feature();
+#endif
+
+// CHECK-ARC: void has_objc_arc_feature();
+// CHECK-ARC: void has_objc_arc_weak_feature();
+
+// CHECK-ARCLITE: void has_objc_arc_feature();
+// CHECK-ARCLITE: void no_objc_arc_weak_feature();
diff --git a/clang/test/Lexer/has_feature_rtti.cpp b/clang/test/Lexer/has_feature_rtti.cpp
new file mode 100644
index 0000000..4bfeead
--- /dev/null
+++ b/clang/test/Lexer/has_feature_rtti.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-RTTI %s
+// RUN: %clang_cc1 -E -fno-rtti %s -o - | FileCheck --check-prefix=CHECK-NO-RTTI %s
+
+#if __has_feature(cxx_rtti)
+int foo();
+#else
+int bar();
+#endif
+
+// CHECK-RTTI: foo
+// CHECK-NO-RTTI: bar
diff --git a/clang/test/Lexer/has_feature_type_traits.cpp b/clang/test/Lexer/has_feature_type_traits.cpp
new file mode 100644
index 0000000..0c2cfa5
--- /dev/null
+++ b/clang/test/Lexer/has_feature_type_traits.cpp
@@ -0,0 +1,111 @@
+// RUN: %clang_cc1 -E %s -o - | FileCheck %s
+
+#if __has_feature(has_nothrow_assign)
+int has_nothrow_assign();
+#endif
+// CHECK: int has_nothrow_assign();
+
+#if __has_feature(has_nothrow_copy)
+int has_nothrow_copy();
+#endif
+// CHECK: int has_nothrow_copy();
+
+#if __has_feature(has_nothrow_constructor)
+int has_nothrow_constructor();
+#endif
+// CHECK: int has_nothrow_constructor();
+
+#if __has_feature(has_trivial_assign)
+int has_trivial_assign();
+#endif
+// CHECK: int has_trivial_assign();
+
+#if __has_feature(has_trivial_copy)
+int has_trivial_copy();
+#endif
+// CHECK: int has_trivial_copy();
+
+#if __has_feature(has_trivial_constructor)
+int has_trivial_constructor();
+#endif
+// CHECK: int has_trivial_constructor();
+
+#if __has_feature(has_trivial_destructor)
+int has_trivial_destructor();
+#endif
+// CHECK: int has_trivial_destructor();
+
+#if __has_feature(has_virtual_destructor)
+int has_virtual_destructor();
+#endif
+// CHECK: int has_virtual_destructor();
+
+#if __has_feature(is_abstract)
+int is_abstract();
+#endif
+// CHECK: int is_abstract();
+
+#if __has_feature(is_base_of)
+int is_base_of();
+#endif
+// CHECK: int is_base_of();
+
+#if __has_feature(is_class)
+int is_class();
+#endif
+// CHECK: int is_class();
+
+#if __has_feature(is_convertible_to)
+int is_convertible_to();
+#endif
+// CHECK: int is_convertible_to();
+
+#if __has_feature(is_empty)
+int is_empty();
+#endif
+// CHECK: int is_empty();
+
+#if __has_feature(is_enum)
+int is_enum();
+#endif
+// CHECK: int is_enum();
+
+#if __has_feature(is_final)
+int is_final();
+#endif
+// CHECK: int is_final();
+
+#if __has_feature(is_pod)
+int is_pod();
+#endif
+// CHECK: int is_pod();
+
+#if __has_feature(is_polymorphic)
+int is_polymorphic();
+#endif
+// CHECK: int is_polymorphic();
+
+#if __has_feature(is_union)
+int is_union();
+#endif
+// CHECK: int is_union();
+
+#if __has_feature(is_literal)
+int is_literal();
+#endif
+// CHECK: int is_literal();
+
+#if __has_feature(is_standard_layout)
+int is_standard_layout();
+#endif
+// CHECK: int is_standard_layout();
+
+#if __has_feature(is_trivially_copyable)
+int is_trivially_copyable();
+#endif
+// CHECK: int is_trivially_copyable();
+
+#if __has_feature(underlying_type)
+int underlying_type();
+#endif
+// CHECK: int underlying_type();
diff --git a/clang/test/Lexer/hexfloat.cpp b/clang/test/Lexer/hexfloat.cpp
new file mode 100644
index 0000000..6566933
--- /dev/null
+++ b/clang/test/Lexer/hexfloat.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -pedantic %s
+float f = 0x1p+1; // expected-warning{{hexadecimal floating constants are a C99 feature}}
+double e = 0x.p0; //expected-error{{hexadecimal floating constants require a significand}}
+double d = 0x.2p2; // expected-warning{{hexadecimal floating constants are a C99 feature}}
+float g = 0x1.2p2; // expected-warning{{hexadecimal floating constants are a C99 feature}}
+double h = 0x1.p2; // expected-warning{{hexadecimal floating constants are a C99 feature}}
diff --git a/clang/test/Lexer/ms-extensions.c b/clang/test/Lexer/ms-extensions.c
new file mode 100644
index 0000000..377d2d5
--- /dev/null
+++ b/clang/test/Lexer/ms-extensions.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility %s
+
+__int8 x1 = 3i8;
+__int16 x2 = 4i16;
+__int32 x3 = 5i32;
+__int64 x5 = 0x42i64;
+__int64 x6 = 0x42I64;
+__int64 x4 = 70000000i128;
+
+__int64 y = 0x42i64u; // expected-error {{invalid suffix}}
+__int64 w = 0x43ui64;
+__int64 z = 9Li64; // expected-error {{invalid suffix}}
+__int64 q = 10lli64; // expected-error {{invalid suffix}}
+
+// radar 7562363
+#define ULLONG_MAX 0xffffffffffffffffui64
+#define UINT 0xffffffffui32
+#define USHORT 0xffffui16
+#define UCHAR 0xffui8
+
+void a() {
+ unsigned long long m = ULLONG_MAX;
+ unsigned int n = UINT;
+ unsigned short s = USHORT;
+ unsigned char c = UCHAR;
+}
+
+void pr_7968()
+{
+ int var1 = 0x1111111e+1;
+ int var2 = 0X1111111e+1;
+ int var3 = 0xe+1;
+ int var4 = 0XE+1;
+
+ int var5= 0\
+x1234e+1;
+
+ int var6=
+ /*expected-warning {{backslash and newline separated by space}} */ 0\
+x1234e+1;
+}
+
diff --git a/clang/test/Lexer/ms-extensions.cpp b/clang/test/Lexer/ms-extensions.cpp
new file mode 100644
index 0000000..7e18a6c
--- /dev/null
+++ b/clang/test/Lexer/ms-extensions.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wreserved-user-defined-literal -fms-extensions -fms-compatibility %s
+
+#define bar(x) #x
+const char * f() {
+ return "foo"bar("bar")"baz"; /*expected-warning {{identifier after literal will be treated as a reserved user-defined literal suffix in C++11}} */
+}
diff --git a/clang/test/Lexer/msdos-cpm-eof.c b/clang/test/Lexer/msdos-cpm-eof.c
new file mode 100644
index 0000000..9ef6e32
--- /dev/null
+++ b/clang/test/Lexer/msdos-cpm-eof.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
+
+int x;
+
+
+
+I am random garbage after ^Z
diff --git a/clang/test/Lexer/multiple-include.c b/clang/test/Lexer/multiple-include.c
new file mode 100644
index 0000000..d737f95
--- /dev/null
+++ b/clang/test/Lexer/multiple-include.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -fsyntax-only
+
+#ifndef XVID_AUTO_INCLUDE
+
+#define XVID_AUTO_INCLUDE
+#define FUNC_H H_Pass_16_C
+#include "multiple-include.c"
+
+#define FUNC_H H_Pass_8_C
+
+#include "multiple-include.c"
+#undef XVID_AUTO_INCLUDE
+
+typedef void ff();
+typedef struct { ff *a;} S;
+
+S s = { H_Pass_8_C };
+
+#endif
+
+#if defined(XVID_AUTO_INCLUDE) && defined(REFERENCE_CODE)
+#elif defined(XVID_AUTO_INCLUDE) && !defined(REFERENCE_CODE)
+
+static void FUNC_H(){};
+#undef FUNC_H
+
+#endif
diff --git a/clang/test/Lexer/newline-eof-c++11.cpp b/clang/test/Lexer/newline-eof-c++11.cpp
new file mode 100644
index 0000000..3c45f28
--- /dev/null
+++ b/clang/test/Lexer/newline-eof-c++11.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wnewline-eof -verify %s
+
+// The following line isn't terminated, don't fix it.
+void foo() {} \ No newline at end of file
diff --git a/clang/test/Lexer/newline-eof-c++98-compat.cpp b/clang/test/Lexer/newline-eof-c++98-compat.cpp
new file mode 100644
index 0000000..3e5c8e2
--- /dev/null
+++ b/clang/test/Lexer/newline-eof-c++98-compat.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -Wc++98-compat-pedantic -std=c++11 -verify %s
+
+// The following line isn't terminated, don't fix it.
+void foo() {} // expected-warning{{C++98 requires newline at end of file}} \ No newline at end of file
diff --git a/clang/test/Lexer/newline-eof.c b/clang/test/Lexer/newline-eof.c
new file mode 100644
index 0000000..825a266
--- /dev/null
+++ b/clang/test/Lexer/newline-eof.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -Wnewline-eof -verify %s
+// rdar://9133072
+
+// The following line isn't terminated, don't fix it.
+void foo() {} // expected-warning{{no newline at end of file}} \ No newline at end of file
diff --git a/clang/test/Lexer/numeric-literal-trash.c b/clang/test/Lexer/numeric-literal-trash.c
new file mode 100644
index 0000000..5407ba9
--- /dev/null
+++ b/clang/test/Lexer/numeric-literal-trash.c
@@ -0,0 +1,13 @@
+/* RUN: %clang_cc1 -fsyntax-only -verify %s
+ */
+# define XRECORD(x, c_name) e##c (x, __LINE__)
+
+
+
+int ec(int, int);
+
+
+ void x() {
+
+XRECORD (XRECORD (1, 1), 1);
+ }
diff --git a/clang/test/Lexer/pragma-mark.c b/clang/test/Lexer/pragma-mark.c
new file mode 100644
index 0000000..96e8485
--- /dev/null
+++ b/clang/test/Lexer/pragma-mark.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+// Lexer diagnostics shouldn't be included in #pragma mark.
+#pragma mark Mike's world
+_Pragma("mark foo ' bar")
+
+#define X(S) _Pragma(S)
+X("mark foo ' bar")
+
+int i;
+
diff --git a/clang/test/Lexer/pragma-message.c b/clang/test/Lexer/pragma-message.c
new file mode 100644
index 0000000..807edda
--- /dev/null
+++ b/clang/test/Lexer/pragma-message.c
@@ -0,0 +1,14 @@
+/* Test pragma message directive from
+ http://msdn.microsoft.com/en-us/library/x7dkzch2.aspx */
+
+// message: Sends a string literal to the standard output without terminating
+// the compilation.
+// #pragma message(messagestring)
+// OR
+// #pragma message messagestring
+//
+// RUN: %clang_cc1 -fsyntax-only -verify -Werror %s
+#define STRING2(x) #x
+#define STRING(x) STRING2(x)
+#pragma message(":O I'm a message! " STRING(__LINE__)) // expected-warning {{:O I'm a message! 13}}
+#pragma message ":O gcc accepts this! " STRING(__LINE__) // expected-warning {{:O gcc accepts this! 14}}
diff --git a/clang/test/Lexer/pragma-operators.cpp b/clang/test/Lexer/pragma-operators.cpp
new file mode 100644
index 0000000..d1645ad
--- /dev/null
+++ b/clang/test/Lexer/pragma-operators.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fms-extensions -E %s | FileCheck %s
+
+// Test that we properly expand the C99 _Pragma and Microsoft __pragma
+// into #pragma directives, with newlines where needed. <rdar://problem/8412013>
+
+// CHECK: #line
+// CHECK: #pragma warning(push)
+// CHECK: extern "C" {
+// CHECK: #line
+// CHECK: #pragma warning(push)
+// CHECK: int foo() { return 0; } }
+// CHECK: #line
+// CHECK: #pragma warning(pop)
+#define A(X) extern "C" { __pragma(warning(push)) \
+ int X() { return 0; } \
+}
+#define B(X) A(X)
+#pragma warning(push)
+B(foo)
+#pragma warning(pop)
diff --git a/clang/test/Lexer/preamble.c b/clang/test/Lexer/preamble.c
new file mode 100644
index 0000000..5b2739a
--- /dev/null
+++ b/clang/test/Lexer/preamble.c
@@ -0,0 +1,36 @@
+// Preamble detection test: see below for comments and test commands.
+//* A BCPL comment that includes '/*'
+#include <blah>
+#ifndef FOO
+#else
+#ifdef BAR
+#elif WIBBLE
+#endif
+#pragma unknown
+#endif
+#ifdef WIBBLE
+#include "honk"
+#else
+int foo();
+#endif
+
+// This test checks for detection of the preamble of a file, which
+// includes all of the starting comments and #includes. Note that any
+// changes to the preamble part of this file must be mirrored in
+// Inputs/preamble.txt, since we diff against it.
+
+// RUN: %clang_cc1 -print-preamble %s > %t
+// RUN: echo END. >> %t
+// RUN: FileCheck < %t %s
+
+// CHECK: // Preamble detection test: see below for comments and test commands.
+// CHECK-NEXT: //* A BCPL comment that includes '/*'
+// CHECK-NEXT: #include <blah>
+// CHECK-NEXT: #ifndef FOO
+// CHECK-NEXT: #else
+// CHECK-NEXT: #ifdef BAR
+// CHECK-NEXT: #elif WIBBLE
+// CHECK-NEXT: #endif
+// CHECK-NEXT: #pragma unknown
+// CHECK-NEXT: #endif
+// CHECK-NEXT: END.
diff --git a/clang/test/Lexer/rdar-8914293.c b/clang/test/Lexer/rdar-8914293.c
new file mode 100644
index 0000000..e39e4f1
--- /dev/null
+++ b/clang/test/Lexer/rdar-8914293.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// rdar://8914293
+// We want be compatible with gcc and warn, not error.
+
+/* expected-warning {{missing terminating}} */ #define FOO "foo
+/* expected-warning {{missing terminating}} */ #define KOO 'k
diff --git a/clang/test/Lexer/rdr-6096838-2.c b/clang/test/Lexer/rdr-6096838-2.c
new file mode 100644
index 0000000..e64acc9
--- /dev/null
+++ b/clang/test/Lexer/rdr-6096838-2.c
@@ -0,0 +1,5 @@
+/* RUN: %clang_cc1 -triple x86_64-unknown-unknown -pedantic -std=gnu89 -fsyntax-only -verify %s
+ rdar://6096838
+ */
+
+long double d = 0x0.0000003ffffffff00000p-16357L; /* expected-warning {{hexadecimal floating constants are a C99 feature}} */
diff --git a/clang/test/Lexer/rdr-6096838.c b/clang/test/Lexer/rdr-6096838.c
new file mode 100644
index 0000000..d1426cc
--- /dev/null
+++ b/clang/test/Lexer/rdr-6096838.c
@@ -0,0 +1,6 @@
+/* RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only -verify %s
+ * RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=gnu89 -fsyntax-only -verify %s
+ rdar://6096838
+ */
+
+long double d = 0x0.0000003ffffffff00000p-16357L;
diff --git a/clang/test/Lexer/string-literal-encoding.c b/clang/test/Lexer/string-literal-encoding.c
new file mode 100644
index 0000000..57097dc
--- /dev/null
+++ b/clang/test/Lexer/string-literal-encoding.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -x c++ -std=c++0x -fsyntax-only -verify %s
+
+// This file should be encoded using ISO-8859-1, the string literals should
+// contain the ISO-8859-1 encoding for the code points U+00C0 U+00E9 U+00EE
+// U+00F5 U+00FC
+
+void f() {
+ wchar_t const *a = L""; // expected-error {{illegal character encoding in string literal}}
+
+ char16_t const *b = u""; // expected-error {{illegal character encoding in string literal}}
+ char32_t const *c = U""; // expected-error {{illegal character encoding in string literal}}
+ wchar_t const *d = LR"()"; // expected-error {{illegal character encoding in string literal}}
+ char16_t const *e = uR"()"; // expected-error {{illegal character encoding in string literal}}
+ char32_t const *f = UR"()"; // expected-error {{illegal character encoding in string literal}}
+
+ char const *g = ""; // expected-warning {{illegal character encoding in string literal}}
+ char const *h = u8""; // expected-error {{illegal character encoding in string literal}}
+ char const *i = R"()"; // expected-warning {{illegal character encoding in string literal}}
+}
+
+void g() {
+ wchar_t const *a = L"foo "; // expected-error {{illegal character encoding in string literal}}
+
+ char16_t const *b = u"foo "; // expected-error {{illegal character encoding in string literal}}
+ char32_t const *c = U"foo "; // expected-error {{illegal character encoding in string literal}}
+ wchar_t const *d = LR"(foo )"; // expected-error {{illegal character encoding in string literal}}
+ char16_t const *e = uR"(foo )"; // expected-error {{illegal character encoding in string literal}}
+ char32_t const *f = UR"(foo )"; // expected-error {{illegal character encoding in string literal}}
+
+ char const *g = "foo "; // expected-warning {{illegal character encoding in string literal}}
+ char const *h = u8"foo "; // expected-error {{illegal character encoding in string literal}}
+ char const *i = R"(foo )"; // expected-warning {{illegal character encoding in string literal}}
+}
diff --git a/clang/test/Lexer/string_concat.cpp b/clang/test/Lexer/string_concat.cpp
new file mode 100644
index 0000000..7e78a63
--- /dev/null
+++ b/clang/test/Lexer/string_concat.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+void f() {
+
+ const char* a = u8"abc" u"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char* b = u8"abc" U"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char* c = u8"abc" L"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char* d = u8"abc" uR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char* e = u8"abc" UR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char* f = u8"abc" LR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+
+ const char16_t* g = u"abc" u8"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char16_t* h = u"abc" U"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char16_t* i = u"abc" L"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char16_t* j = u"abc" u8R"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char16_t* k = u"abc" UR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char16_t* l = u"abc" LR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+
+ const char32_t* m = U"abc" u8"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char32_t* n = U"abc" u"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char32_t* o = U"abc" L"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char32_t* p = U"abc" u8R"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char32_t* q = U"abc" uR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char32_t* r = U"abc" LR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+
+ const wchar_t* s = L"abc" u8"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const wchar_t* t = L"abc" u"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const wchar_t* u = L"abc" U"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const wchar_t* v = L"abc" u8R"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const wchar_t* w = L"abc" uR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const wchar_t* x = L"abc" UR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+}
+
diff --git a/clang/test/Lexer/token-concat-2.c b/clang/test/Lexer/token-concat-2.c
new file mode 100644
index 0000000..7d3cd64
--- /dev/null
+++ b/clang/test/Lexer/token-concat-2.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -E -x c -o - %s | grep '[.][*]'
+// PR4395
+#define X .*
+X
diff --git a/clang/test/Lexer/token-concat.c b/clang/test/Lexer/token-concat.c
new file mode 100644
index 0000000..551af95
--- /dev/null
+++ b/clang/test/Lexer/token-concat.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -E -x c -o %t %s
+// RUN: grep 'IDENT.2' %t
+
+IDENT.2
diff --git a/clang/test/Lexer/token-concat.cpp b/clang/test/Lexer/token-concat.cpp
new file mode 100644
index 0000000..57dbae0
--- /dev/null
+++ b/clang/test/Lexer/token-concat.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -E -std=c++11 -o - %s | FileCheck %s
+
+#define id(x) x
+id("s")_x // CHECK: "s" _x
+id(L"s")_x // CHECK: L"s" _x
+id(u8"s")_x // CHECK: u8"s" _x
+id(u"s")_x // CHECK: u"s" _x
+id(U"s")_x // CHECK: U"s" _x
+id('s')_x // CHECK: 's' _x
+id(L's')_x // CHECK: L's' _x
+id(u's')_x // CHECK: u's' _x
+id(U's')_x // CHECK: U's' _x
+id("s"_x)_y // CHECK: "s"_x _y
+id(1.0_)f // CHECK: 1.0_ f
+id(1.0)_f // CHECK: 1.0 _f
+id(0xface+)b_count // CHECK: 0xface+ b_count
+id("s")1 // CHECK: "s"1
+id("s"_x)1 // CHECK: "s"_x 1
+id(1)_2_x // CHECK: 1 _2_x
diff --git a/clang/test/Lexer/unknown-char.c b/clang/test/Lexer/unknown-char.c
new file mode 100644
index 0000000..334df37
--- /dev/null
+++ b/clang/test/Lexer/unknown-char.c
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -E %s 2>&1 | not grep error
+ ` ` ` `
diff --git a/clang/test/Lexer/utf-16.c b/clang/test/Lexer/utf-16.c
new file mode 100644
index 0000000..169ee43
--- /dev/null
+++ b/clang/test/Lexer/utf-16.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// rdar://7876588
+
+// This test verifies that clang gives a decent error for UTF-16 source files.
+
+#include "utf-16.c.txt" // expected-error {{UTF-16 (LE) byte order mark detected}}
diff --git a/clang/test/Lexer/utf-16.c.txt b/clang/test/Lexer/utf-16.c.txt
new file mode 100644
index 0000000..4f3d169
--- /dev/null
+++ b/clang/test/Lexer/utf-16.c.txt
Binary files differ
diff --git a/clang/test/Lexer/utf8-char-literal.cpp b/clang/test/Lexer/utf8-char-literal.cpp
new file mode 100644
index 0000000..12b001e
--- /dev/null
+++ b/clang/test/Lexer/utf8-char-literal.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -fsyntax-only -verify %s
+
+int array0[u'ñ' == u'\xf1'? 1 : -1];
+int array1['\xF1' != u'\xf1'? 1 : -1];
+int array1['ñ' != u'\xf1'? 1 : -1]; // expected-error {{character too large for enclosing character literal type}}
diff --git a/clang/test/Lexer/wchar.c b/clang/test/Lexer/wchar.c
new file mode 100644
index 0000000..de00c02
--- /dev/null
+++ b/clang/test/Lexer/wchar.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -fshort-wchar -verify %s
+
+void f() {
+ (void)L"\U00010000"; // unicode escape produces UTF-16 sequence, so no warning
+
+ (void)L'\U00010000'; // expected-error {{character too large for enclosing character literal type}}
+
+ (void)L'ab'; // expected-warning {{extraneous characters in character constant ignored}}
+
+ (void)L'a\u1000'; // expected-warning {{extraneous characters in character constant ignored}}
+}
+
diff --git a/clang/test/Makefile b/clang/test/Makefile
new file mode 100644
index 0000000..4fdafe1
--- /dev/null
+++ b/clang/test/Makefile
@@ -0,0 +1,71 @@
+CLANG_LEVEL := ..
+include $(CLANG_LEVEL)/Makefile
+
+# Test in all immediate subdirectories if unset.
+ifdef TESTSUITE
+TESTDIRS := $(TESTSUITE:%=$(PROJ_SRC_DIR)/%)
+else
+TESTDIRS ?= $(PROJ_SRC_DIR)
+endif
+
+# 'lit' wants objdir paths, so it will pick up the lit.site.cfg.
+TESTDIRS := $(TESTDIRS:$(PROJ_SRC_DIR)%=$(PROJ_OBJ_DIR)%)
+
+# Allow EXTRA_TESTDIRS to provide additional test directories.
+TESTDIRS += $(EXTRA_TESTDIRS)
+
+ifndef TESTARGS
+ifdef VERBOSE
+TESTARGS = -v
+else
+TESTARGS = -s -v
+endif
+endif
+
+# Make sure any extra test suites can find the main site config.
+LIT_ARGS := --param clang_site_config=$(PROJ_OBJ_DIR)/lit.site.cfg
+
+ifdef VG
+ LIT_ARGS += "--vg"
+endif
+
+all:: lit.site.cfg Unit/lit.site.cfg
+ @ echo '--- Running clang tests for $(TARGET_TRIPLE) ---'
+ @ $(PYTHON) $(LLVM_SRC_ROOT)/utils/lit/lit.py \
+ $(LIT_ARGS) $(TESTARGS) $(TESTDIRS)
+
+FORCE:
+
+lit.site.cfg: FORCE
+ @echo "Making Clang 'lit.site.cfg' file..."
+ @$(ECHOPATH) s=@LLVM_SOURCE_DIR@=$(LLVM_SRC_ROOT)=g > lit.tmp
+ @$(ECHOPATH) s=@LLVM_BINARY_DIR@=$(LLVM_OBJ_ROOT)=g >> lit.tmp
+ @$(ECHOPATH) s=@LLVM_TOOLS_DIR@=$(ToolDir)=g >> lit.tmp
+ @$(ECHOPATH) s=@LLVM_LIBS_DIR@=$(LibDir)=g >> lit.tmp
+ @$(ECHOPATH) s=@CLANG_SOURCE_DIR@=$(PROJ_SRC_DIR)/..=g >> lit.tmp
+ @$(ECHOPATH) s=@CLANG_BINARY_DIR@=$(PROJ_OBJ_DIR)/..=g >> lit.tmp
+ @$(ECHOPATH) s=@TARGET_TRIPLE@=$(TARGET_TRIPLE)=g >> lit.tmp
+ @sed -f lit.tmp $(PROJ_SRC_DIR)/lit.site.cfg.in > $@
+ @-rm -f lit.tmp
+
+Unit/lit.site.cfg: FORCE
+ @echo "Making Clang 'Unit/lit.site.cfg' file..."
+ @$(MKDIR) $(dir $@)
+ @$(ECHOPATH) s=@LLVM_SOURCE_DIR@=$(LLVM_SRC_ROOT)=g > unit.tmp
+ @$(ECHOPATH) s=@LLVM_BINARY_DIR@=$(LLVM_OBJ_ROOT)=g >> unit.tmp
+ @$(ECHOPATH) s=@LLVM_TOOLS_DIR@=$(ToolDir)=g >> unit.tmp
+ @$(ECHOPATH) s=@LLVM_LIBS_DIR@=$(LibDir)=g >> unit.tmp
+ @$(ECHOPATH) s=@CLANG_SOURCE_DIR@=$(PROJ_SRC_DIR)/..=g >> unit.tmp
+ @$(ECHOPATH) s=@CLANG_BINARY_DIR@=$(PROJ_OBJ_DIR)/..=g >> unit.tmp
+ @$(ECHOPATH) s=@TARGET_TRIPLE@=$(TARGET_TRIPLE)=g >> unit.tmp
+ @$(ECHOPATH) s=@LLVM_BUILD_MODE@=$(BuildMode)=g >> unit.tmp
+ @$(ECHOPATH) s=@ENABLE_SHARED@=$(ENABLE_SHARED)=g >> unit.tmp
+ @$(ECHOPATH) s=@SHLIBDIR@=$(SharedLibDir)=g >> unit.tmp
+ @$(ECHOPATH) s=@SHLIBPATH_VAR@=$(SHLIBPATH_VAR)=g >> unit.tmp
+ @sed -f unit.tmp $(PROJ_SRC_DIR)/Unit/lit.site.cfg.in > $@
+ @-rm -f unit.tmp
+
+clean::
+ @ find . -name Output | xargs rm -fr
+
+.PHONY: all report clean
diff --git a/clang/test/Misc/Inputs/include.h b/clang/test/Misc/Inputs/include.h
new file mode 100644
index 0000000..72835e9
--- /dev/null
+++ b/clang/test/Misc/Inputs/include.h
@@ -0,0 +1,3 @@
+#define EQUALS(a,b) a == b
+
+int foo(int x) { return x; }
diff --git a/clang/test/Misc/Inputs/remapped-file b/clang/test/Misc/Inputs/remapped-file
new file mode 100644
index 0000000..657613e
--- /dev/null
+++ b/clang/test/Misc/Inputs/remapped-file
@@ -0,0 +1 @@
+int *f(float *fp) { return fp; }
diff --git a/clang/test/Misc/Inputs/remapped-file-2 b/clang/test/Misc/Inputs/remapped-file-2
new file mode 100644
index 0000000..9ac034a
--- /dev/null
+++ b/clang/test/Misc/Inputs/remapped-file-2
@@ -0,0 +1,3 @@
+#include "nonexistent.h"
+
+int *f() { return fp; }
diff --git a/clang/test/Misc/Inputs/remapped-file-3 b/clang/test/Misc/Inputs/remapped-file-3
new file mode 100644
index 0000000..b7ab613
--- /dev/null
+++ b/clang/test/Misc/Inputs/remapped-file-3
@@ -0,0 +1,2 @@
+extern float *fp;
+
diff --git a/clang/test/Misc/Inputs/working-directory.h b/clang/test/Misc/Inputs/working-directory.h
new file mode 100644
index 0000000..061df62
--- /dev/null
+++ b/clang/test/Misc/Inputs/working-directory.h
@@ -0,0 +1 @@
+typedef int Foo;
diff --git a/clang/test/Misc/ast-dump-templates.cpp b/clang/test/Misc/ast-dump-templates.cpp
new file mode 100644
index 0000000..7d56e7b
--- /dev/null
+++ b/clang/test/Misc/ast-dump-templates.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -ast-dump %s > %t
+// RUN: FileCheck < %t %s -check-prefix=CHECK1
+// RUN: FileCheck < %t %s -check-prefix=CHECK2
+
+template <int X, typename Y, int Z = 5>
+struct foo {
+ int constant;
+ foo() {}
+ Y getSum() { return Y(X + Z); }
+};
+
+template <int A, typename B>
+B bar() {
+ return B(A);
+}
+
+void baz() {
+ int x = bar<5, int>();
+ int y = foo<5, int>().getSum();
+ double z = foo<2, double, 3>().getSum();
+}
+
+// Template instantiation - foo
+// Since the order of instantiation may vary during runs, run FileCheck twice
+// to make sure each instantiation is in the correct spot.
+// CHECK1: template <int X = 5, typename Y = int, int Z = 5> struct foo {
+// CHECK2: template <int X = 2, typename Y = double, int Z = 3> struct foo {
+
+// Template definition - foo
+// CHECK1: template <int X, typename Y, int Z = (IntegerLiteral {{.*}} 'int' 5)
+// CHECK2: template <int X, typename Y, int Z = (IntegerLiteral {{.*}} 'int' 5)
+
+// Template instantiation - bar
+// CHECK1: template <int A = 5, typename B = int> int bar()
+// CHECK2: template <int A = 5, typename B = int> int bar()
+
+// Template definition - bar
+// CHECK1: template <int A, typename B> B bar()
+// CHECK2: template <int A, typename B> B bar()
diff --git a/clang/test/Misc/caret-diags-macros.c b/clang/test/Misc/caret-diags-macros.c
new file mode 100644
index 0000000..de1ee76
--- /dev/null
+++ b/clang/test/Misc/caret-diags-macros.c
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
+
+#define M1(x) x
+#define M2 1;
+void foo() {
+ M1(
+ M2);
+ // CHECK: :7:{{[0-9]+}}: warning: expression result unused
+ // CHECK: :4:{{[0-9]+}}: note: expanded from macro 'M2'
+ // CHECK: :3:{{[0-9]+}}: note: expanded from macro 'M1'
+}
+
+#define A 1
+#define B A
+#define C B
+void bar() {
+ C;
+ // CHECK: :17:3: warning: expression result unused
+ // CHECK: :15:11: note: expanded from macro 'C'
+ // CHECK: :14:11: note: expanded from macro 'B'
+ // CHECK: :13:11: note: expanded from macro 'A'
+}
+
+// rdar://7597492
+#define sprintf(str, A, B) \
+__builtin___sprintf_chk (str, 0, 42, A, B)
+
+void baz(char *Msg) {
+ sprintf(Msg, " sizeof FoooLib : =%3u\n", 12LL);
+}
+
+
+// PR9279: comprehensive tests for multi-level macro back traces
+#define macro_args1(x) x
+#define macro_args2(x) macro_args1(x)
+#define macro_args3(x) macro_args2(x)
+
+#define macro_many_args1(x, y, z) y
+#define macro_many_args2(x, y, z) macro_many_args1(x, y, z)
+#define macro_many_args3(x, y, z) macro_many_args2(x, y, z)
+
+void test() {
+ macro_args3(1);
+ // CHECK: {{.*}}:43:15: warning: expression result unused
+ // Also check that the 'caret' printing agrees with the location here where
+ // its easy to FileCheck.
+ // CHECK-NEXT: macro_args3(1);
+ // CHECK-NEXT: ~~~~~~~~~~~~^~
+ // CHECK: {{.*}}:36:36: note: expanded from macro 'macro_args3'
+ // CHECK: {{.*}}:35:36: note: expanded from macro 'macro_args2'
+ // CHECK: {{.*}}:34:24: note: expanded from macro 'macro_args1'
+
+ macro_many_args3(
+ 1,
+ 2,
+ 3);
+ // CHECK: {{.*}}:55:5: warning: expression result unused
+ // CHECK: {{.*}}:40:55: note: expanded from macro 'macro_many_args3'
+ // CHECK: {{.*}}:39:55: note: expanded from macro 'macro_many_args2'
+ // CHECK: {{.*}}:38:35: note: expanded from macro 'macro_many_args1'
+
+ macro_many_args3(
+ 1,
+ M2,
+ 3);
+ // CHECK: {{.*}}:64:5: warning: expression result unused
+ // CHECK: {{.*}}:4:12: note: expanded from macro 'M2'
+ // CHECK: {{.*}}:40:55: note: expanded from macro 'macro_many_args3'
+ // CHECK: {{.*}}:39:55: note: expanded from macro 'macro_many_args2'
+ // CHECK: {{.*}}:38:35: note: expanded from macro 'macro_many_args1'
+
+ macro_many_args3(
+ 1,
+ macro_args2(2),
+ 3);
+ // CHECK: {{.*}}:74:17: warning: expression result unused
+ // This caret location needs to be printed *inside* a different macro's
+ // arguments.
+ // CHECK-NEXT: macro_args2(2),
+ // CHECK-NEXT: ~~~~~~~~~~~~^~~
+ // CHECK: {{.*}}:35:36: note: expanded from macro 'macro_args2'
+ // CHECK: {{.*}}:34:24: note: expanded from macro 'macro_args1'
+ // CHECK: {{.*}}:40:55: note: expanded from macro 'macro_many_args3'
+ // CHECK: {{.*}}:39:55: note: expanded from macro 'macro_many_args2'
+ // CHECK: {{.*}}:38:35: note: expanded from macro 'macro_many_args1'
+}
+
+#define variadic_args1(x, y, ...) y
+#define variadic_args2(x, ...) variadic_args1(x, __VA_ARGS__)
+#define variadic_args3(x, y, ...) variadic_args2(x, y, __VA_ARGS__)
+
+void test2() {
+ variadic_args3(1, 2, 3, 4);
+ // CHECK: {{.*}}:93:21: warning: expression result unused
+ // CHECK-NEXT: variadic_args3(1, 2, 3, 4);
+ // CHECK-NEXT: ~~~~~~~~~~~~~~~~~~^~~~~~~~
+ // CHECK: {{.*}}:90:53: note: expanded from macro 'variadic_args3'
+ // CHECK: {{.*}}:89:50: note: expanded from macro 'variadic_args2'
+ // CHECK: {{.*}}:88:35: note: expanded from macro 'variadic_args1'
+}
+
+#define variadic_pasting_args1(x, y, z) y
+#define variadic_pasting_args2(x, ...) variadic_pasting_args1(x ## __VA_ARGS__)
+#define variadic_pasting_args2a(x, y, ...) variadic_pasting_args1(x, y ## __VA_ARGS__)
+#define variadic_pasting_args3(x, y, ...) variadic_pasting_args2(x, y, __VA_ARGS__)
+#define variadic_pasting_args3a(x, y, ...) variadic_pasting_args2a(x, y, __VA_ARGS__)
+
+void test3() {
+ variadic_pasting_args3(1, 2, 3, 4);
+ // CHECK: {{.*}}:109:32: warning: expression result unused
+ // CHECK: {{.*}}:105:72: note: expanded from macro 'variadic_pasting_args3'
+ // CHECK: {{.*}}:103:68: note: expanded from macro 'variadic_pasting_args2'
+ // CHECK: {{.*}}:102:41: note: expanded from macro 'variadic_pasting_args1'
+
+ variadic_pasting_args3a(1, 2, 3, 4);
+ // CHECK: {{.*}}:115:30: warning: expression result unused
+ // CHECK: {{.*}}:106:71: note: expanded from macro 'variadic_pasting_args3a'
+ // CHECK: {{.*}}:104:70: note: expanded from macro 'variadic_pasting_args2a'
+ // CHECK: {{.*}}:102:41: note: expanded from macro 'variadic_pasting_args1'
+}
diff --git a/clang/test/Misc/caret-diags-scratch-buffer.c b/clang/test/Misc/caret-diags-scratch-buffer.c
new file mode 100644
index 0000000..883c68e
--- /dev/null
+++ b/clang/test/Misc/caret-diags-scratch-buffer.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | not grep keyXXXX
+// This should not show keyXXXX in the caret diag output. This once
+// happened because the two tokens ended up in the scratch buffer and
+// the caret diag from the scratch buffer included the previous token.
+#define M(name) \
+ if (name ## XXXX != name ## _sb);
+
+void foo() {
+ int keyXXXX;
+ M(key);
+}
+
diff --git a/clang/test/Misc/diag-aka-types.cpp b/clang/test/Misc/diag-aka-types.cpp
new file mode 100644
index 0000000..4c9a731
--- /dev/null
+++ b/clang/test/Misc/diag-aka-types.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11
+
+struct X {};
+typedef X foo_t;
+
+foo_t *ptr;
+char c1 = ptr; // expected-error{{'foo_t *' (aka 'X *')}}
+
+const foo_t &ref = foo_t();
+char c2 = ref; // expected-error{{'const foo_t' (aka 'const X')}}
+
+// deduced auto should not produce an aka.
+auto aut = X();
+char c3 = aut; // expected-error{{from 'X' to 'char'}}
+
+// There are two classes named Foo::foo here. Make sure the message gives
+// a way to them apart.
+namespace Foo {
+ class foo {};
+}
+
+namespace bar {
+ namespace Foo {
+ class foo;
+ }
+ void f(Foo::foo* x); // expected-note{{passing argument to parameter 'x' here}}
+}
+
+void test(Foo::foo* x) {
+ bar::f(x); // expected-error{{cannot initialize a parameter of type 'Foo::foo *' (aka 'bar::Foo::foo *') with an lvalue of type 'Foo::foo *'}}
+}
+
+// PR9548 - "no known conversion from 'vector<string>' to 'vector<string>'"
+// vector<string> refers to two different types here. Make sure the message
+// gives a way to tell them apart.
+class versa_string;
+typedef versa_string string;
+
+namespace std {template <typename T> class vector;}
+using std::vector;
+
+void f(vector<string> v); // expected-note {{candidate function not viable: no known conversion from 'vector<string>' (aka 'std::vector<std::basic_string>') to 'vector<string>' (aka 'std::vector<versa_string>') for 1st argument}}
+
+namespace std {
+ class basic_string;
+ typedef basic_string string;
+ template <typename T> class vector {};
+ void g() {
+ vector<string> v;
+ f(v); // expected-error{{no matching function for call to 'f'}}
+ }
+}
+
+namespace ns {
+ struct str {
+ static void method(struct data *) {}
+ };
+}
+
+struct data { int i; };
+
+typedef void (*callback)(struct data *);
+
+void helper(callback cb) {} // expected-note{{candidate function not viable: no known conversion from 'void (*)(struct data *)' (aka 'void (*)(ns::data *)') to 'callback' (aka 'void (*)(struct data *)') for 1st argument;}}
+
+void test() {
+ helper(&ns::str::method); // expected-error{{no matching function for call to 'helper'}}
+}
diff --git a/clang/test/Misc/diag-format.c b/clang/test/Misc/diag-format.c
new file mode 100644
index 0000000..959177b
--- /dev/null
+++ b/clang/test/Misc/diag-format.c
@@ -0,0 +1,34 @@
+// RUN: %clang -fsyntax-only %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
+// RUN: %clang -fsyntax-only -fdiagnostics-format=clang %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
+// RUN: %clang -fsyntax-only -fdiagnostics-format=clang -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
+//
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc %s 2>&1 | FileCheck %s -check-prefix=MSVC
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC
+//
+// RUN: %clang -fsyntax-only -fdiagnostics-format=vi %s 2>&1 | FileCheck %s -check-prefix=VI
+//
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fno-show-column %s 2>&1 | FileCheck %s -check-prefix=MSVC_ORIG
+//
+// RUN: %clang -fsyntax-only -fno-show-column %s 2>&1 | FileCheck %s -check-prefix=NO_COLUMN
+//
+
+
+
+
+
+
+
+
+
+
+
+
+#ifdef foo
+#endif bad // extension!
+// DEFAULT: {{.*}}:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+// MSVC: {{.*}}(28,7) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
+// VI: {{.*}} +28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+// MSVC_ORIG: {{.*}}(28) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
+// NO_COLUMN: {{.*}}:28: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+int x;
diff --git a/clang/test/Misc/diag-line-wrapping.cpp b/clang/test/Misc/diag-line-wrapping.cpp
new file mode 100644
index 0000000..830aa13
--- /dev/null
+++ b/clang/test/Misc/diag-line-wrapping.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -fmessage-length 60 %s 2>&1 | FileCheck %s
+
+struct B { void f(); };
+struct D1 : B {};
+struct D2 : B {};
+struct DD : D1, D2 {
+ void g() { f(); }
+ // Ensure that after line-wrapping takes place, we preserve artificial
+ // newlines introduced to manually format a section of the diagnostic text.
+ // CHECK: {{.*}}: error:
+ // CHECK: struct DD -> struct D1 -> struct B
+ // CHECK: struct DD -> struct D2 -> struct B
+}
diff --git a/clang/test/Misc/diag-macro-backtrace.c b/clang/test/Misc/diag-macro-backtrace.c
new file mode 100644
index 0000000..ea40cbe
--- /dev/null
+++ b/clang/test/Misc/diag-macro-backtrace.c
@@ -0,0 +1,53 @@
+// RUN: %clang -fsyntax-only -fmacro-backtrace-limit=0 %s 2>&1 | FileCheck %s
+
+#define FOO 1+"hi"
+#define BAR FOO
+#define BAZ BAR
+#define QUZ BAZ
+#define TAZ QUZ
+#define ABA TAZ
+#define BAB ABA
+#define ZAZ BAB
+#define WAZ ZAZ
+#define DROOL WAZ
+#define FOOL DROOL
+
+FOOL
+
+// CHECK: :15:1: error: expected identifier or '('
+// CHECK: FOOL
+// CHECK: ^
+// CHECK: :13:14: note: expanded from macro 'FOOL'
+// CHECK: #define FOOL DROOL
+// CHECK: ^
+// CHECK: :12:15: note: expanded from macro 'DROOL'
+// CHECK: #define DROOL WAZ
+// CHECK: ^
+// CHECK: :11:13: note: expanded from macro 'WAZ'
+// CHECK: #define WAZ ZAZ
+// CHECK: ^
+// CHECK: :10:13: note: expanded from macro 'ZAZ'
+// CHECK: #define ZAZ BAB
+// CHECK: ^
+// CHECK: :9:13: note: expanded from macro 'BAB'
+// CHECK: #define BAB ABA
+// CHECK: ^
+// CHECK: :8:13: note: expanded from macro 'ABA'
+// CHECK: #define ABA TAZ
+// CHECK: ^
+// CHECK: :7:13: note: expanded from macro 'TAZ'
+// CHECK: #define TAZ QUZ
+// CHECK: ^
+// CHECK: :6:13: note: expanded from macro 'QUZ'
+// CHECK: #define QUZ BAZ
+// CHECK: ^
+// CHECK: :5:13: note: expanded from macro 'BAZ'
+// CHECK: #define BAZ BAR
+// CHECK: ^
+// CHECK: :4:13: note: expanded from macro 'BAR'
+// CHECK: #define BAR FOO
+// CHECK: ^
+// CHECK: :3:13: note: expanded from macro 'FOO'
+// CHECK: #define FOO 1+"hi"
+// CHECK: ^
+// CHECK: 1 error generated.
diff --git a/clang/test/Misc/diag-mapping.c b/clang/test/Misc/diag-mapping.c
new file mode 100644
index 0000000..75b49ef
--- /dev/null
+++ b/clang/test/Misc/diag-mapping.c
@@ -0,0 +1,30 @@
+// This should warn by default.
+// RUN: %clang_cc1 %s 2>&1 | grep "warning:"
+// This should not emit anything.
+// RUN: %clang_cc1 %s -Wno-extra-tokens 2>&1 | not grep diagnostic
+
+// -Werror can map all warnings to error.
+// RUN: %clang_cc1 %s -Werror 2>&1 | grep "error:"
+
+// -Werror can map this one warning to error.
+// RUN: %clang_cc1 %s -Werror=extra-tokens 2>&1 | grep "error:"
+
+// Mapping unrelated diags to errors doesn't affect this one.
+// RUN: %clang_cc1 %s -Werror=trigraphs 2>&1 | grep "warning:"
+
+// This should stay a warning with -pedantic.
+// RUN: %clang_cc1 %s -pedantic 2>&1 | grep "warning:"
+
+// This should emit an error with -pedantic-errors.
+// RUN: %clang_cc1 %s -pedantic-errors 2>&1 | grep "error:"
+
+// This should emit a warning, because -Wfoo overrides -pedantic*.
+// RUN: %clang_cc1 %s -pedantic-errors -Wextra-tokens 2>&1 | grep "warning:"
+
+// This should emit nothing, because -Wno-extra-tokens overrides -pedantic*
+// RUN: %clang_cc1 %s -pedantic-errors -Wno-extra-tokens 2>&1 | not grep diagnostic
+
+#ifdef foo
+#endif bad // extension!
+
+int x;
diff --git a/clang/test/Misc/diag-mapping2.c b/clang/test/Misc/diag-mapping2.c
new file mode 100644
index 0000000..bc5a087
--- /dev/null
+++ b/clang/test/Misc/diag-mapping2.c
@@ -0,0 +1,22 @@
+// This should warn by default.
+// RUN: %clang_cc1 %s 2>&1 | grep "warning:"
+
+// This should not emit anything.
+// RUN: %clang_cc1 %s -w 2>&1 | not grep diagnostic
+// RUN: %clang_cc1 %s -Wno-#warnings 2>&1 | not grep diagnostic
+
+// -Werror can map all warnings to error.
+// RUN: %clang_cc1 %s -Werror 2>&1 | grep "error:"
+
+// -Werror can map this one warning to error.
+// RUN: %clang_cc1 %s -Werror=#warnings 2>&1 | grep "error:"
+
+// -Wno-error= overrides -Werror. rdar://3158301
+// RUN: %clang_cc1 %s -Werror -Wno-error=#warnings 2>&1 | grep "warning:"
+
+// -Wno-error overrides -Werror. PR4715
+// RUN: %clang_cc1 %s -Werror -Wno-error 2>&1 | grep "warning:"
+
+#warning foo
+
+
diff --git a/clang/test/Misc/diag-verify.cpp b/clang/test/Misc/diag-verify.cpp
new file mode 100644
index 0000000..895bc3f
--- /dev/null
+++ b/clang/test/Misc/diag-verify.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s 2>&1 | FileCheck %s
+
+// Test the -verify flag. Each of the "x = y;" lines will produce a
+// "use of undeclared identifier 'y'" error message.
+
+void test() {
+ int x;
+ // Proper matches here.
+ x = y; // expected-error{{use of undeclared identifier 'y'}}
+ x = y; // expected-error{{use of undeclared identifier}}
+ x = y; // expected-error{{undeclared identifier 'y'}}
+ x = y; // expected-error{{use of}}
+ x = y; // expected-error{{undeclared identifier}}
+ x = y; // expected-error{{'y'}}
+
+ // Bad matches here.
+ x = y; // expected-error{{use of undeclared identifier 'y' is fine}}
+ x = y; // expected-error{{abuse of undeclared identifier 'y'}}
+ x = y; // expected-error{{good use of undeclared identifier 'y' in code}}
+ x = y; // expected-error{{ use of undeclared identifier 'y' }}
+ x = y; // expected-error{{use of undeclared identifier 'y' is disallowed}}
+ x = y; // expected-error{{please don't use of undeclared identifier 'y'}}
+ x = y; // expected-error{{use of undeclared identifier 'y'; please declare y before use}}
+ x = y; // expected-error{{use of use of undeclared identifier 'y'}}
+ x = y; // expected-error{{use of undeclared identifier 'y' identifier 'y'}}
+}
+
+//CHECK: error: 'error' diagnostics expected but not seen:
+//CHECK: Line 17: use of undeclared identifier 'y' is fine
+//CHECK: Line 18: abuse of undeclared identifier 'y'
+//CHECK: Line 19: good use of undeclared identifier 'y' in code
+//CHECK: Line 20: use of undeclared identifier 'y'
+//CHECK: Line 21: use of undeclared identifier 'y' is disallowed
+//CHECK: Line 22: please don't use of undeclared identifier 'y'
+//CHECK: Line 23: use of undeclared identifier 'y'; please declare y before use
+//CHECK: Line 24: use of use of undeclared identifier 'y'
+//CHECK: Line 25: use of undeclared identifier 'y' identifier 'y'
+//CHECK: error: 'error' diagnostics seen but not expected:
+//CHECK: Line 17: use of undeclared identifier 'y'
+//CHECK: Line 18: use of undeclared identifier 'y'
+//CHECK: Line 19: use of undeclared identifier 'y'
+//CHECK: Line 20: use of undeclared identifier 'y'
+//CHECK: Line 21: use of undeclared identifier 'y'
+//CHECK: Line 22: use of undeclared identifier 'y'
+//CHECK: Line 23: use of undeclared identifier 'y'
+//CHECK: Line 24: use of undeclared identifier 'y'
+//CHECK: Line 25: use of undeclared identifier 'y'
+//CHECK: 18 errors generated.
diff --git a/clang/test/Misc/emit-html-insert.c b/clang/test/Misc/emit-html-insert.c
new file mode 100644
index 0000000..289c28a
--- /dev/null
+++ b/clang/test/Misc/emit-html-insert.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -emit-html -o - | grep ">&lt; 10; }"
+
+int a(int x) { return x
+< 10; }
diff --git a/clang/test/Misc/emit-html.c b/clang/test/Misc/emit-html.c
new file mode 100644
index 0000000..48c8b61
--- /dev/null
+++ b/clang/test/Misc/emit-html.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -emit-html -o -
+
+// rdar://6562329
+#line 42 "foo.c"
+
+// PR3635
+#define F(fmt, ...) fmt, ## __VA_ARGS__
+int main(int argc, char **argv) {
+ return F(argc, 1);
+}
+
+// PR3798
+#define FOR_ALL_FILES(f,i) i
+
+#if 0
+ FOR_ALL_FILES(f) { }
+#endif
+
diff --git a/clang/test/Misc/error-limit-multiple-notes.cpp b/clang/test/Misc/error-limit-multiple-notes.cpp
new file mode 100644
index 0000000..019b4dd
--- /dev/null
+++ b/clang/test/Misc/error-limit-multiple-notes.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -ferror-limit 1 -fsyntax-only %s 2>&1 | FileCheck %s
+
+// error and three notes emitted
+void foo(int);
+void foo(double);
+void foo(int, int);
+
+int main()
+{
+ foo();
+}
+
+// error and note suppressed by error-limit
+struct s1{};
+struct s1{};
+
+// CHECK: 10:5: error: no matching function for call to 'foo'
+// CHECK: 6:6: note: candidate function not viable: requires 2 arguments, but 0 were provided
+// CHECK: 5:6: note: candidate function not viable: requires 1 argument, but 0 were provided
+// CHECK: 4:6: note: candidate function not viable: requires 1 argument, but 0 were provided
+// CHECK: fatal error: too many errors emitted, stopping now
+// CHECK-NOT: 15:8: error: redefinition of 's1'
+// CHECK-NOT: 14:8: note: previous definition is here
diff --git a/clang/test/Misc/error-limit.c b/clang/test/Misc/error-limit.c
new file mode 100644
index 0000000..26f4ac1
--- /dev/null
+++ b/clang/test/Misc/error-limit.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -ferror-limit 1 -fsyntax-only %s 2>&1 | FileCheck %s
+
+// error and note emitted
+struct s1{};
+struct s1{};
+
+// error and note suppressed by error-limit
+struct s2{};
+struct s2{};
+
+// CHECK: 5:8: error: redefinition of 's1'
+// CHECK: 4:8: note: previous definition is here
+// CHECK: fatal error: too many errors emitted, stopping now
+// CHECK-NOT: 9:8: error: redefinition of 's2'
+// CHECK-NOT: 8:8: note: previous definition is here
diff --git a/clang/test/Misc/include-stack-for-note-flag.cpp b/clang/test/Misc/include-stack-for-note-flag.cpp
new file mode 100644
index 0000000..b41284f
--- /dev/null
+++ b/clang/test/Misc/include-stack-for-note-flag.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-note-include-stack %s 2>&1 | FileCheck %s -check-prefix=STACK
+// RUN: %clang_cc1 -fsyntax-only -fno-diagnostics-show-note-include-stack %s 2>&1 | FileCheck %s -check-prefix=STACKLESS
+// RUN: %clang_cc1 -fsyntax-only -fno-diagnostics-show-note-include-stack -fdiagnostics-show-note-include-stack %s 2>&1 | FileCheck %s -check-prefix=STACK
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-note-include-stack -fno-diagnostics-show-note-include-stack %s 2>&1 | FileCheck %s -check-prefix=STACKLESS
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s -check-prefix=STACKLESS
+
+#include "Inputs/include.h"
+int test() {
+ return foo(1, 1);
+}
+
+bool macro(int x, int y) {
+ return EQUALS(&x, y);
+}
+
+// STACK: error: no matching function for call to 'foo'
+// STACK: In file included from
+// STACK: note: candidate function not viable
+// STACK: error: comparison between pointer and integer
+// STACK: In file included from
+// STACK: note: expanded from macro
+
+// STACKLESS: error: no matching function for call to 'foo'
+// STACKLESS-NOT: In file included from
+// STACKLESS: note: candidate function not viable
+// STACKLESS: error: comparison between pointer and integer
+// STACKLESS-NOT: In file included from
+// STACKLESS: note: expanded from macro
diff --git a/clang/test/Misc/integer-literal-printing.cpp b/clang/test/Misc/integer-literal-printing.cpp
new file mode 100644
index 0000000..d751730
--- /dev/null
+++ b/clang/test/Misc/integer-literal-printing.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+// PR11179
+template <short T> class Type1 {};
+template <short T> void Function1(Type1<T>& x) {} // expected-note{{candidate function [with T = -42] not viable: no known conversion from 'Type1<-42>' to 'Type1<-42> &' for 1st argument;}}
+
+template <unsigned short T> class Type2 {};
+template <unsigned short T> void Function2(Type2<T>& x) {} // expected-note{{candidate function [with T = 42] not viable: no known conversion from 'Type2<42>' to 'Type2<42> &' for 1st argument;}}
+
+void Function() {
+ Function1(Type1<-42>()); // expected-error{{no matching function for call to 'Function1'}}
+ Function2(Type2<42>()); // expected-error{{no matching function for call to 'Function2'}}
+}
diff --git a/clang/test/Misc/macro-backtrace.c b/clang/test/Misc/macro-backtrace.c
new file mode 100644
index 0000000..7aeaf21
--- /dev/null
+++ b/clang/test/Misc/macro-backtrace.c
@@ -0,0 +1,57 @@
+// Tests for macro expansion backtraces. The RUN and CHECK lines are grouped
+// below the test code to reduce noise when updating them.
+
+#define M1(A, B) ((A) < (B))
+#define M2(A, B) M1(A, B)
+#define M3(A, B) M2(A, B)
+#define M4(A, B) M3(A, B)
+#define M5(A, B) M4(A, B)
+#define M6(A, B) M5(A, B)
+#define M7(A, B) M6(A, B)
+#define M8(A, B) M7(A, B)
+#define M9(A, B) M8(A, B)
+#define M10(A, B) M9(A, B)
+#define M11(A, B) M10(A, B)
+#define M12(A, B) M11(A, B)
+
+void f(int *ip, float *fp) {
+ if (M12(ip, fp)) { }
+ // RUN: %clang_cc1 -fsyntax-only -fmacro-backtrace-limit 5 %s 2>&1 \
+ // RUN: | FileCheck %s -check-prefix=CHECK-LIMIT
+ // CHECK-LIMIT: macro-backtrace.c:18:7: warning: comparison of distinct pointer types ('int *' and 'float *')
+ // CHECK-LIMIT: if (M12(ip, fp)) { }
+ // CHECK-LIMIT: macro-backtrace.c:15:19: note: expanded from macro 'M12'
+ // CHECK-LIMIT: #define M12(A, B) M11(A, B)
+ // CHECK-LIMIT: macro-backtrace.c:14:19: note: expanded from macro 'M11'
+ // CHECK-LIMIT: #define M11(A, B) M10(A, B)
+ // CHECK-LIMIT: note: (skipping 7 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
+ // CHECK-LIMIT: macro-backtrace.c:6:18: note: expanded from macro 'M3'
+ // CHECK-LIMIT: #define M3(A, B) M2(A, B)
+ // CHECK-LIMIT: macro-backtrace.c:5:18: note: expanded from macro 'M2'
+ // CHECK-LIMIT: #define M2(A, B) M1(A, B)
+ // CHECK-LIMIT: macro-backtrace.c:4:23: note: expanded from macro 'M1'
+ // CHECK-LIMIT: #define M1(A, B) ((A) < (B))
+
+ // RUN: %clang_cc1 -fsyntax-only -fno-caret-diagnostics %s 2>&1 \
+ // RUN: | FileCheck %s -check-prefix=CHECK-NO-CARETS
+ // CHECK-NO-CARETS: macro-backtrace.c:18:7: warning: comparison of distinct pointer types ('int *' and 'float *')
+ // CHECK-NO-CARETS-NEXT: macro-backtrace.c:15:19: note: expanded from macro 'M12'
+ // CHECK-NO-CARETS-NEXT: macro-backtrace.c:14:19: note: expanded from macro 'M11'
+ // CHECK-NO-CARETS-NEXT: macro-backtrace.c:13:19: note: expanded from macro 'M10'
+ // CHECK-NO-CARETS-NEXT: note: (skipping 6 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
+ // CHECK-NO-CARETS-NEXT: macro-backtrace.c:6:18: note: expanded from macro 'M3'
+ // CHECK-NO-CARETS-NEXT: macro-backtrace.c:5:18: note: expanded from macro 'M2'
+ // CHECK-NO-CARETS-NEXT: macro-backtrace.c:4:23: note: expanded from macro 'M1'
+
+ // Check that the expansion notes respect the same formatting options as
+ // other diagnostics.
+ // RUN: %clang_cc1 -fsyntax-only -fdiagnostics-format vi %s 2>&1 \
+ // RUN: | FileCheck %s -check-prefix=CHECK-NOTE-FORMAT
+ // CHECK-NOTE-FORMAT: macro-backtrace.c +18:7: warning:
+ // CHECK-NOTE-FORMAT: macro-backtrace.c +15:19: note:
+ // CHECK-NOTE-FORMAT: macro-backtrace.c +14:19: note:
+ // CHECK-NOTE-FORMAT: note:
+ // CHECK-NOTE-FORMAT: macro-backtrace.c +6:18: note:
+ // CHECK-NOTE-FORMAT: macro-backtrace.c +5:18: note:
+ // CHECK-NOTE-FORMAT: macro-backtrace.c +4:23: note:
+}
diff --git a/clang/test/Misc/message-length.c b/clang/test/Misc/message-length.c
new file mode 100644
index 0000000..a6f4f44
--- /dev/null
+++ b/clang/test/Misc/message-length.c
@@ -0,0 +1,41 @@
+// RUN: not %clang_cc1 -fmessage-length 72 %s 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not %clang_cc1 -fmessage-length 1 %s
+// RUN: not %clang_cc1 -fmessage-length 8 %s 2>&1 | FileCheck -check-prefix=CHECK-DOT %s
+// Hack so we can check things better, force the file name and line.
+# 1 "FILE" 1
+
+/* It's tough to verify the results of this test mechanically, since
+ the length of the filename (and, therefore, how the word-wrapping
+ behaves) changes depending on where the test-suite resides in the
+ file system. */
+void f(int, float, char, float);
+
+void g() {
+ int (*fp1)(int, float, short, float) = f;
+
+ int (*fp2)(int, float, short, float) = f;
+}
+
+void a_func_to_call(int, int, int);
+
+void a_very_long_line(int *ip, float *FloatPointer) {
+ for (int ALongIndexName = 0; ALongIndexName < 100; ALongIndexName++) if (ip[ALongIndexName] == 17) a_func_to_call(ip == FloatPointer, ip[ALongIndexName], FloatPointer[ALongIndexName]);
+
+
+ int array0[] = { [3] 3, 5, 7, 4, 2, 7, 6, 3, 4, 5, 6, 7, 8, 9, 12, 345, 14, 345, 789, 234, 678, 345, 123, 765, 234 };
+}
+
+#pragma STDC CX_LIMITED_RANGE // some long comment text and a brace, eh {}
+
+// CHECK: FILE:23:78
+// CHECK: {{^ ...// some long comment text and a brace, eh {}}}
+
+struct A { int x; };
+void h(struct A *a) {
+ // CHECK-DOT: member
+ // CHECK-DOT: reference
+ // CHECK-DOT: type
+ (void)a
+ .
+ x;
+}
diff --git a/clang/test/Misc/predefines.c b/clang/test/Misc/predefines.c
new file mode 100644
index 0000000..87f676e
--- /dev/null
+++ b/clang/test/Misc/predefines.c
@@ -0,0 +1,5 @@
+/* RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -ffreestanding -pedantic-errors %s
+ * rdar://6814950
+ */
+#include <stdint.h>
+
diff --git a/clang/test/Misc/remap-file.c b/clang/test/Misc/remap-file.c
new file mode 100644
index 0000000..003cd2e
--- /dev/null
+++ b/clang/test/Misc/remap-file.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -remap-file "%s;%S/Inputs/remapped-file" -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-EXIST %s
+// RUN: %clang_cc1 -remap-file "%S/nonexistent.c;%S/Inputs/remapped-file" -fsyntax-only %S/nonexistent.c 2>&1 | FileCheck -check-prefix=CHECK-NONEXIST %s
+// RUN: %clang_cc1 -remap-file "%S/nonexistent.c;%S/Inputs/remapped-file-2" -remap-file "%S/nonexistent.h;%S/Inputs/remapped-file-3" -fsyntax-only %S/nonexistent.c 2>&1 | FileCheck -check-prefix=CHECK-HEADER %s
+
+// CHECK-EXIST: remap-file.c:1:28: warning: incompatible pointer types
+// CHECK-NONEXIST: nonexistent.c:1:28: warning: incompatible pointer types
+// CHECK-HEADER: nonexistent.c:3:19: warning: incompatible pointer types
+int
diff --git a/clang/test/Misc/serialized-diags-no-category.c b/clang/test/Misc/serialized-diags-no-category.c
new file mode 100644
index 0000000..3074892
--- /dev/null
+++ b/clang/test/Misc/serialized-diags-no-category.c
@@ -0,0 +1,12 @@
+#error foo
+#error bar
+
+// RUN: rm -f %t
+// RUN: %clang -ferror-limit=1 -fsyntax-only %s --serialize-diagnostics %t > /dev/null 2>&1 || true
+// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s
+
+// This test case tests that we can handle both fatal errors and errors without categories.
+
+// CHECK: {{.*[/\\]}}serialized-diags-no-category.c:1:2: error: foo []
+// CHECK: Number of diagnostics: 2
+
diff --git a/clang/test/Misc/serialized-diags-no-issue.c b/clang/test/Misc/serialized-diags-no-issue.c
new file mode 100644
index 0000000..5c7da82
--- /dev/null
+++ b/clang/test/Misc/serialized-diags-no-issue.c
@@ -0,0 +1,10 @@
+void foo();
+
+// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t
+// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s
+// RUN: rm -f %t
+
+// NOTE: it is important that this test case contains no issues. It tests
+// that serialize diagnostics work in the absence of any issues.
+
+// CHECK: Number of diagnostics: 0
diff --git a/clang/test/Misc/serialized-diags-single-issue.c b/clang/test/Misc/serialized-diags-single-issue.c
new file mode 100644
index 0000000..938dda3
--- /dev/null
+++ b/clang/test/Misc/serialized-diags-single-issue.c
@@ -0,0 +1,36 @@
+void foo() {
+ int voodoo;
+ voodoo = voodoo + 1;
+}
+
+// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t
+// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s
+// RUN: rm -f %t
+
+// NOTE: it is important that this test case only contain a single issue. This test case checks
+// if we can handle serialized diagnostics that contain only one diagnostic.
+
+// CHECK: {{.*}}serialized-diags-single-issue.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized] [Semantic Issue]
+// CHECK: Range: {{.*}}serialized-diags-single-issue.c:3:12 {{.*}}serialized-diags-single-issue.c:3:18
+// CHECK: +-{{.*}}serialized-diags-single-issue.c:2:13: note: initialize the variable 'voodoo' to silence this warning []
+// CHECK: +-Range: {{.*}}serialized-diags-single-issue.c:2:13 {{.*}}serialized-diags-single-issue.c:2:13
+// CHECK: +-FIXIT: ({{.*}}serialized-diags-single-issue.c:2:13 - {{.*}}serialized-diags-single-issue.c:2:13): " = 0"
+
+// Test that we handle serializing diagnostics for multiple source files
+// RUN: %clang_cc1 -Wall -fsyntax-only %s %s -serialize-diagnostic-file %t
+// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck -check-prefix=CHECK-MULT %s
+// RUN: rm -f %t
+
+// CHECK-MULT: {{.*}}serialized-diags-single-issue.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized]
+// CHECK-MULT: Range: {{.*}}serialized-diags-single-issue.c:3:12 {{.*}}serialized-diags-single-issue.c:3:18
+// CHECK-MULT: +-{{.*}}serialized-diags-single-issue.c:2:13: note: initialize the variable 'voodoo' to silence this warning []
+// CHECK-MULT: +-Range: {{.*}}serialized-diags-single-issue.c:2:13 {{.*}}serialized-diags-single-issue.c:2:13
+// CHECK-MULT: +-FIXIT: ({{.*}}serialized-diags-single-issue.c:2:13 - {{.*}}serialized-diags-single-issue.c:2:13): " = 0"
+
+// CHECK-MULT: {{.*}}serialized-diags-single-issue.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized]
+// CHECK-MULT: Range: {{.*}}serialized-diags-single-issue.c:3:12 {{.*}}serialized-diags-single-issue.c:3:18
+// CHECK-MULT: +-{{.*}}serialized-diags-single-issue.c:2:13: note: initialize the variable 'voodoo' to silence this warning []
+// CHECK-MULT: +-Range: {{.*}}serialized-diags-single-issue.c:2:13 {{.*}}serialized-diags-single-issue.c:2:13
+// CHECK-MULT: +-FIXIT: ({{.*}}serialized-diags-single-issue.c:2:13 - {{.*}}serialized-diags-single-issue.c:2:13): " = 0"
+
+// CHECK-MULT: Number of diagnostics: 2
diff --git a/clang/test/Misc/serialized-diags.c b/clang/test/Misc/serialized-diags.c
new file mode 100644
index 0000000..ae4611b
--- /dev/null
+++ b/clang/test/Misc/serialized-diags.c
@@ -0,0 +1,67 @@
+void foo() {
+ int voodoo;
+ voodoo = voodoo + 1;
+}
+
+void bar() {
+ int dragon;
+ dragon = dragon + 1
+}
+
+// Test handling of FixIts that only remove text.
+int baz();
+void qux(int x) {
+ if ((x == baz()))
+ return;
+}
+
+// Test handling of macros.
+void taz(int x, int y);
+#define false 0
+void testMacro() {
+ taz(0, 0, false);
+}
+
+// Test handling of issues from #includes.
+#include "serialized-diags.h"
+
+// Test handling of warnings that have empty fixits.
+void rdar11040133() {
+ unsigned x;
+}
+
+// RUN: rm -f %t
+// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t.diag > /dev/null 2>&1 || true
+// RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+// This test case tests that we can handle multiple diagnostics which contain
+// FIXITs at different levels (one at the note, another at the main diagnostic).
+
+// CHECK: {{.*[/\\]}}serialized-diags.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized]
+// CHECK: Range: {{.*[/\\]}}serialized-diags.c:3:12 {{.*[/\\]}}serialized-diags.c:3:18
+// CHECK: +-{{.*[/\\]}}serialized-diags.c:2:13: note: initialize the variable 'voodoo' to silence this warning []
+// CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:2:13 - {{.*[/\\]}}serialized-diags.c:2:13): " = 0"
+// CHECK: {{.*[/\\]}}serialized-diags.c:8:22: error: expected ';' after expression []
+// CHECK: FIXIT: ({{.*[/\\]}}serialized-diags.c:8:22 - {{.*[/\\]}}serialized-diags.c:8:22): ";"
+// CHECK: {{.*[/\\]}}serialized-diags.c:14:10: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
+// CHECK: Range: {{.*[/\\]}}serialized-diags.c:14:8 {{.*[/\\]}}serialized-diags.c:14:18
+// CHECK: +-{{.*[/\\]}}serialized-diags.c:14:10: note: remove extraneous parentheses around the comparison to silence this warning []
+// CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:14:7 - {{.*[/\\]}}serialized-diags.c:14:8): ""
+// CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:14:18 - {{.*[/\\]}}serialized-diags.c:14:19): ""
+// CHECK: +-{{.*[/\\]}}serialized-diags.c:14:10: note: use '=' to turn this equality comparison into an assignment []
+// CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:14:10 - {{.*[/\\]}}serialized-diags.c:14:12): "="
+// CHECK: {{.*[/\\]}}serialized-diags.c:22:13: error: too many arguments to function call, expected 2, have 3 []
+// CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:3 {{.*[/\\]}}serialized-diags.c:22:6
+// CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:13 {{.*[/\\]}}serialized-diags.c:22:18
+// CHECK: +-{{.*[/\\]}}serialized-diags.c:20:15: note: expanded from macro 'false' []
+// CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:22:3 {{.*[/\\]}}serialized-diags.c:22:6
+// CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:20:15 {{.*[/\\]}}serialized-diags.c:20:16
+// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:1: note: 'taz' declared here []
+// CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion]
+// CHECK: Range: {{.*[/\\]}}serialized-diags.h:5:16 {{.*[/\\]}}serialized-diags.h:5:17
+// CHECK: +-{{.*[/\\]}}serialized-diags.c:26:10: note: in file included from {{.*[/\\]}}serialized-diags.c:26: []
+// CHECK: Number FIXITs = 0
+// CHECK: {{.*[/\\]}}serialized-diags.c:30:12: warning: unused variable 'x'
+// CHECK: Number FIXITs = 0
+// CHECK: Number of diagnostics: 6
diff --git a/clang/test/Misc/serialized-diags.h b/clang/test/Misc/serialized-diags.h
new file mode 100644
index 0000000..d38a352
--- /dev/null
+++ b/clang/test/Misc/serialized-diags.h
@@ -0,0 +1,5 @@
+// This file intentionally has a bug. It is intended
+// to be used with serialized-diagnostics.c to show
+// how errors are handled with #includes in serialized
+// diagnostics.
+char *badStr = 1;
diff --git a/clang/test/Misc/show-diag-options.c b/clang/test/Misc/show-diag-options.c
new file mode 100644
index 0000000..f0404a8
--- /dev/null
+++ b/clang/test/Misc/show-diag-options.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix=BASE
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix=OPTION
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -Werror %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix=OPTION_ERROR
+// RUN: %clang_cc1 -fsyntax-only -std=c89 -pedantic -fdiagnostics-show-option %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix=OPTION_PEDANTIC
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-category id %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CATEGORY_ID
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-category name %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CATEGORY_NAME
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -fdiagnostics-show-category name -Werror %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix=OPTION_ERROR_CATEGORY
+
+void test(int x, int y) {
+ if (x = y) ++x;
+ // BASE: {{.*}}: warning: {{[a-z ]+$}}
+ // OPTION: {{.*}}: warning: {{[a-z ]+}} [-Wparentheses]
+ // OPTION_ERROR: {{.*}}: error: {{[a-z ]+}} [-Werror,-Wparentheses]
+ // CATEGORY_ID: {{.*}}: warning: {{[a-z ]+}} [2]
+ // CATEGORY_NAME: {{.*}}: warning: {{[a-z ]+}} [Semantic Issue]
+ // OPTION_ERROR_CATEGORY: {{.*}}: error: {{[a-z ]+}} [-Werror,-Wparentheses,Semantic Issue]
+
+ // Leverage the fact that all these '//'s get warned about in C89 pedantic.
+ // OPTION_PEDANTIC: {{.*}}: warning: {{[/a-z ]+}} [-pedantic,-Wcomment]
+}
diff --git a/clang/test/Misc/tabstop.c b/clang/test/Misc/tabstop.c
new file mode 100644
index 0000000..49c4d7b
--- /dev/null
+++ b/clang/test/Misc/tabstop.c
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -ftabstop 3 -fsyntax-only %s 2>&1 | FileCheck -check-prefix=3 -strict-whitespace %s
+// RUN: %clang_cc1 -ftabstop 4 -fsyntax-only %s 2>&1 | FileCheck -check-prefix=4 -strict-whitespace %s
+// RUN: %clang_cc1 -ftabstop 5 -fsyntax-only %s 2>&1 | FileCheck -check-prefix=5 -strict-whitespace %s
+
+// tab
+ void* a = 1;
+
+// tab tab
+ void* b = 1;
+
+// 3x space tab
+ void* c = 1;
+
+// tab at column 10
+void* d = 1;
+
+//CHECK-3: {{^ void\* a = 1;}}
+//CHECK-3: {{^ void\* b = 1;}}
+//CHECK-3: {{^ void\* c = 1;}}
+//CHECK-3: {{^void\* d = 1;}}
+
+//CHECK-4: {{^ void\* a = 1;}}
+//CHECK-4: {{^ void\* b = 1;}}
+//CHECK-4: {{^ void\* c = 1;}}
+//CHECK-4: {{^void\* d = 1;}}
+
+//CHECK-5: {{^ void\* a = 1;}}
+//CHECK-5: {{^ void\* b = 1;}}
+//CHECK-5: {{^ void\* c = 1;}}
+//CHECK-5: {{^void\* d = 1;}}
+
+// Test code modification hints
+
+void f(void)
+{
+ if (0 & 1 == 1)
+ {}
+}
+
+// CHECK-3: {{^ }}if (0 & 1 == 1)
+// CHECK-3: {{^ }} ( )
+
+// CHECK-4: {{^ }}if (0 & 1 == 1)
+// CHECK-4: {{^ }} ( )
+
+// CHECK-5: {{^ }}if (0 & 1 == 1)
+// CHECK-5: {{^ }} ( )
diff --git a/clang/test/Misc/unprintable.c b/clang/test/Misc/unprintable.c
new file mode 100644
index 0000000..860503e
--- /dev/null
+++ b/clang/test/Misc/unprintable.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s 2>&1 | FileCheck -strict-whitespace %s
+
+int main() {
+ int i;
+ if((i==/*👿*/1));
+
+// CHECK: {{^ if\(\(i==/\*<U\+1F47F>\*/1\)\);}}
+
+// CHECK: {{^ ~\^~~~~~~~~~~~~~~~}}
+// CHECK: {{^ ~ \^ ~}}
+
+ /* 👿 */ "👿berhund";
+
+// CHECK: {{^ /\* <U\+1F47F> \*/ "<U\+1F47F>berhund";}}
+// CHECK: {{^ \^~~~~~~~~~~~~~~~~~}}
+} \ No newline at end of file
diff --git a/clang/test/Misc/verify.c b/clang/test/Misc/verify.c
new file mode 100644
index 0000000..85b034e
--- /dev/null
+++ b/clang/test/Misc/verify.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct s; // expected-note 7 {{forward declaration of 'struct s'}}
+
+// standard string matching
+struct s s1; // expected-error {{tentative definition has type 'struct s' that is never completed}}
+struct s s2; // expected-error {{tentative definition has type}}
+
+// regex matching
+struct s r1; // expected-error-re {{tentative definition has type 'struct s' that is never completed}}
+struct s r2; // expected-error-re {{tentative definition has type '.*[[:space:]]*.*' that is never completed}}
+struct s r3; // expected-error-re {{tentative definition has type '(.*)[[:space:]]*(.*)' that is never completed}}
+struct s r4; // expected-error-re {{^tentative}}
+struct s r5; // expected-error-re {{completed$}}
diff --git a/clang/test/Misc/warn-in-system-header.c b/clang/test/Misc/warn-in-system-header.c
new file mode 100644
index 0000000..6e0237d
--- /dev/null
+++ b/clang/test/Misc/warn-in-system-header.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -isystem %S %s -fsyntax-only -verify
+
+#include <warn-in-system-header.h>
+// expected-warning {{the cake is a lie}}
diff --git a/clang/test/Misc/warn-in-system-header.h b/clang/test/Misc/warn-in-system-header.h
new file mode 100644
index 0000000..5e127b9
--- /dev/null
+++ b/clang/test/Misc/warn-in-system-header.h
@@ -0,0 +1,4 @@
+
+
+
+#warning the cake is a lie
diff --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c
new file mode 100644
index 0000000..bc0c941
--- /dev/null
+++ b/clang/test/Misc/warning-flags.c
@@ -0,0 +1,273 @@
+RUN: diagtool list-warnings 2>&1 | FileCheck %s
+
+This test serves two purposes:
+
+(1) It documents all existing warnings that currently have no associated -W flag,
+ and ensures that the list never grows.
+
+ If take an existing warning and add a flag, this test will fail. To
+ fix this test, simply remove that warning from the list below.
+
+(2) It prevents us adding new warnings to Clang that have no -W flag. All
+ new warnings should have -W flags.
+
+ If you add a new warning without a flag, this test will fail. To fix
+ this test, simply add a warning group to that warning.
+
+
+The list of warnings below should NEVER grow. It should gradually shrink to 0.
+
+CHECK: Warnings without flags (253):
+CHECK-NEXT: ext_anonymous_struct_union_qualified
+CHECK-NEXT: ext_binary_literal
+CHECK-NEXT: ext_cast_fn_obj
+CHECK-NEXT: ext_delete_void_ptr_operand
+CHECK-NEXT: ext_designated_init
+CHECK-NEXT: ext_duplicate_declspec
+CHECK-NEXT: ext_ellipsis_exception_spec
+CHECK-NEXT: ext_empty_fnmacro_arg
+CHECK-NEXT: ext_empty_source_file
+CHECK-NEXT: ext_enum_friend
+CHECK-NEXT: ext_enum_value_not_int
+CHECK-NEXT: ext_enumerator_list_comma
+CHECK-NEXT: ext_expected_semi_decl_list
+CHECK-NEXT: ext_explicit_instantiation_without_qualified_id
+CHECK-NEXT: ext_explicit_specialization_storage_class
+CHECK-NEXT: ext_extra_ivar_semi
+CHECK-NEXT: ext_extra_struct_semi
+CHECK-NEXT: ext_forward_ref_enum
+CHECK-NEXT: ext_freestanding_complex
+CHECK-NEXT: ext_hexconstant_invalid
+CHECK-NEXT: ext_ident_list_in_param
+CHECK-NEXT: ext_imaginary_constant
+CHECK-NEXT: ext_implicit_lib_function_decl
+CHECK-NEXT: ext_in_class_initializer_non_constant
+CHECK-NEXT: ext_integer_complement_complex
+CHECK-NEXT: ext_integer_complex
+CHECK-NEXT: ext_integer_increment_complex
+CHECK-NEXT: ext_invalid_sign_spec
+CHECK-NEXT: ext_missing_declspec
+CHECK-NEXT: ext_missing_varargs_arg
+CHECK-NEXT: ext_missing_whitespace_after_macro_name
+CHECK-NEXT: ext_new_paren_array_nonconst
+CHECK-NEXT: ext_nonstandard_escape
+CHECK-NEXT: ext_param_not_declared
+CHECK-NEXT: ext_paste_comma
+CHECK-NEXT: ext_plain_complex
+CHECK-NEXT: ext_pp_bad_vaargs_use
+CHECK-NEXT: ext_pp_comma_expr
+CHECK-NEXT: ext_pp_ident_directive
+CHECK-NEXT: ext_pp_include_next_directive
+CHECK-NEXT: ext_pp_line_too_big
+CHECK-NEXT: ext_pp_macro_redef
+CHECK-NEXT: ext_pp_warning_directive
+CHECK-NEXT: ext_return_has_void_expr
+CHECK-NEXT: ext_subscript_non_lvalue
+CHECK-NEXT: ext_template_arg_extra_parens
+CHECK-NEXT: ext_thread_before
+CHECK-NEXT: ext_top_level_semi
+CHECK-NEXT: ext_typecheck_addrof_void
+CHECK-NEXT: ext_typecheck_cast_nonscalar
+CHECK-NEXT: ext_typecheck_cast_to_union
+CHECK-NEXT: ext_typecheck_comparison_of_distinct_pointers
+CHECK-NEXT: ext_typecheck_comparison_of_distinct_pointers_nonstandard
+CHECK-NEXT: ext_typecheck_comparison_of_fptr_to_void
+CHECK-NEXT: ext_typecheck_comparison_of_pointer_integer
+CHECK-NEXT: ext_typecheck_cond_incompatible_operands
+CHECK-NEXT: ext_typecheck_cond_incompatible_operands_nonstandard
+CHECK-NEXT: ext_typecheck_cond_one_void
+CHECK-NEXT: ext_typecheck_convert_pointer_void_func
+CHECK-NEXT: ext_typecheck_ordered_comparison_of_function_pointers
+CHECK-NEXT: ext_typecheck_ordered_comparison_of_pointer_and_zero
+CHECK-NEXT: ext_typecheck_ordered_comparison_of_pointer_integer
+CHECK-NEXT: ext_typecheck_zero_array_size
+CHECK-NEXT: ext_unknown_escape
+CHECK-NEXT: ext_using_undefined_std
+CHECK-NEXT: ext_vla_folded_to_constant
+CHECK-NEXT: pp_include_next_absolute_path
+CHECK-NEXT: pp_include_next_in_primary
+CHECK-NEXT: pp_invalid_string_literal
+CHECK-NEXT: pp_out_of_date_dependency
+CHECK-NEXT: pp_poisoning_existing_macro
+CHECK-NEXT: pp_pragma_once_in_main_file
+CHECK-NEXT: pp_pragma_sysheader_in_main_file
+CHECK-NEXT: pp_undef_builtin_macro
+CHECK-NEXT: w_asm_qualifier_ignored
+CHECK-NEXT: warn_accessor_property_type_mismatch
+CHECK-NEXT: warn_anon_bitfield_width_exceeds_type_size
+CHECK-NEXT: warn_asm_label_on_auto_decl
+CHECK-NEXT: warn_attribute_ibaction
+CHECK-NEXT: warn_attribute_iboutlet
+CHECK-NEXT: warn_attribute_ignored
+CHECK-NEXT: warn_attribute_ignored_for_field_of_type
+CHECK-NEXT: warn_attribute_malloc_pointer_only
+CHECK-NEXT: warn_attribute_nonnull_no_pointers
+CHECK-NEXT: warn_attribute_precede_definition
+CHECK-NEXT: warn_attribute_sentinel_named_arguments
+CHECK-NEXT: warn_attribute_sentinel_not_variadic
+CHECK-NEXT: warn_attribute_type_not_supported
+CHECK-NEXT: warn_attribute_unknown_visibility
+CHECK-NEXT: warn_attribute_void_function_method
+CHECK-NEXT: warn_attribute_weak_import_invalid_on_definition
+CHECK-NEXT: warn_attribute_weak_on_field
+CHECK-NEXT: warn_attribute_weak_on_local
+CHECK-NEXT: warn_attribute_wrong_decl_type
+CHECK-NEXT: warn_availability_and_unavailable
+CHECK-NEXT: warn_availability_unknown_platform
+CHECK-NEXT: warn_availability_version_ordering
+CHECK-NEXT: warn_bad_receiver_type
+CHECK-NEXT: warn_bitfield_width_exceeds_type_size
+CHECK-NEXT: warn_bool_switch_condition
+CHECK-NEXT: warn_braces_around_scalar_init
+CHECK-NEXT: warn_c_kext
+CHECK-NEXT: warn_call_to_pure_virtual_member_function_from_ctor_dtor
+CHECK-NEXT: warn_call_wrong_number_of_arguments
+CHECK-NEXT: warn_case_empty_range
+CHECK-NEXT: warn_char_constant_too_large
+CHECK-NEXT: warn_class_method_not_found
+CHECK-NEXT: warn_cmdline_missing_macro_defs
+CHECK-NEXT: warn_collection_expr_type
+CHECK-NEXT: warn_conflicting_param_types
+CHECK-NEXT: warn_conflicting_ret_types
+CHECK-NEXT: warn_conflicting_variadic
+CHECK-NEXT: warn_conv_to_base_not_used
+CHECK-NEXT: warn_conv_to_self_not_used
+CHECK-NEXT: warn_conv_to_void_not_used
+CHECK-NEXT: warn_cxx0x_right_shift_in_template_arg
+CHECK-NEXT: warn_delete_array_type
+CHECK-NEXT: warn_division_by_zero
+CHECK-NEXT: warn_double_const_requires_fp64
+CHECK-NEXT: warn_drv_assuming_mfloat_abi_is
+CHECK-NEXT: warn_drv_clang_unsupported
+CHECK-NEXT: warn_drv_input_file_unused
+CHECK-NEXT: warn_drv_not_using_clang_arch
+CHECK-NEXT: warn_drv_not_using_clang_cpp
+CHECK-NEXT: warn_drv_not_using_clang_cxx
+CHECK-NEXT: warn_drv_objc_gc_unsupported
+CHECK-NEXT: warn_drv_pch_not_first_include
+CHECK-NEXT: warn_drv_preprocessed_input_file_unused
+CHECK-NEXT: warn_dup_category_def
+CHECK-NEXT: warn_duplicate_protocol_def
+CHECK-NEXT: warn_enum_too_large
+CHECK-NEXT: warn_enum_value_overflow
+CHECK-NEXT: warn_enumerator_too_large
+CHECK-NEXT: warn_exception_caught_by_earlier_handler
+CHECK-NEXT: warn_excess_initializers
+CHECK-NEXT: warn_excess_initializers_in_char_array_initializer
+CHECK-NEXT: warn_expected_qualified_after_typename
+CHECK-NEXT: warn_extern_init
+CHECK-NEXT: warn_extraneous_char_constant
+CHECK-NEXT: warn_fe_cc_log_diagnostics_failure
+CHECK-NEXT: warn_fe_cc_print_header_failure
+CHECK-NEXT: warn_fe_macro_contains_embedded_newline
+CHECK-NEXT: warn_file_asm_volatile
+CHECK-NEXT: warn_function_attribute_wrong_type
+CHECK-NEXT: warn_gc_attribute_weak_on_local
+CHECK-NEXT: warn_gnu_inline_attribute_requires_inline
+CHECK-NEXT: warn_hex_escape_too_large
+CHECK-NEXT: warn_ignoring_ftabstop_value
+CHECK-NEXT: warn_illegal_constant_array_size
+CHECK-NEXT: warn_implements_nscopying
+CHECK-NEXT: warn_incompatible_qualified_id
+CHECK-NEXT: warn_initializer_string_for_char_array_too_long
+CHECK-NEXT: warn_inline_namespace_reopened_noninline
+CHECK-NEXT: warn_inst_method_not_found
+CHECK-NEXT: warn_instance_method_on_class_found
+CHECK-NEXT: warn_integer_too_large
+CHECK-NEXT: warn_integer_too_large_for_signed
+CHECK-NEXT: warn_invalid_asm_cast_lvalue
+CHECK-NEXT: warn_many_braces_around_scalar_init
+CHECK-NEXT: warn_maynot_respond
+CHECK-NEXT: warn_member_extra_qualification
+CHECK-NEXT: warn_method_param_redefinition
+CHECK-NEXT: warn_mismatched_exception_spec
+CHECK-NEXT: warn_missing_case_for_condition
+CHECK-NEXT: warn_missing_dependent_template_keyword
+CHECK-NEXT: warn_missing_exception_specification
+CHECK-NEXT: warn_missing_whitespace_after_macro_name
+CHECK-NEXT: warn_multiple_method_decl
+CHECK-NEXT: warn_no_constructor_for_refconst
+CHECK-NEXT: warn_nonnull_pointers_only
+CHECK-NEXT: warn_not_compound_assign
+CHECK-NEXT: warn_ns_attribute_wrong_parameter_type
+CHECK-NEXT: warn_ns_attribute_wrong_return_type
+CHECK-NEXT: warn_objc_object_attribute_wrong_type
+CHECK-NEXT: warn_objc_property_copy_missing_on_block
+CHECK-NEXT: warn_objc_property_default_assign_on_object
+CHECK-NEXT: warn_objc_property_no_assignment_attribute
+CHECK-NEXT: warn_objc_protocol_qualifier_missing_id
+CHECK-NEXT: warn_octal_escape_too_large
+CHECK-NEXT: warn_odr_tag_type_inconsistent
+CHECK-NEXT: warn_on_superclass_use
+CHECK-NEXT: warn_param_default_argument_redefinition
+CHECK-NEXT: warn_partial_specs_not_deducible
+CHECK-NEXT: warn_pointer_attribute_wrong_type
+CHECK-NEXT: warn_pp_convert_lhs_to_positive
+CHECK-NEXT: warn_pp_convert_rhs_to_positive
+CHECK-NEXT: warn_pp_expr_overflow
+CHECK-NEXT: warn_pp_line_decimal
+CHECK-NEXT: warn_pragma_align_expected_equal
+CHECK-NEXT: warn_pragma_align_invalid_option
+CHECK-NEXT: warn_pragma_debug_unexpected_command
+CHECK-NEXT: warn_pragma_expected_colon
+CHECK-NEXT: warn_pragma_expected_enable_disable
+CHECK-NEXT: warn_pragma_expected_identifier
+CHECK-NEXT: warn_pragma_expected_lparen
+CHECK-NEXT: warn_pragma_expected_rparen
+CHECK-NEXT: warn_pragma_extra_tokens_at_eol
+CHECK-NEXT: warn_pragma_ms_struct
+CHECK-NEXT: warn_pragma_options_align_reset_failed
+CHECK-NEXT: warn_pragma_options_align_unsupported_option
+CHECK-NEXT: warn_pragma_options_expected_align
+CHECK-NEXT: warn_pragma_pack_invalid_action
+CHECK-NEXT: warn_pragma_pack_invalid_alignment
+CHECK-NEXT: warn_pragma_pack_malformed
+CHECK-NEXT: warn_pragma_pack_pop_failed
+CHECK-NEXT: warn_pragma_pack_pop_identifer_and_alignment
+CHECK-NEXT: warn_pragma_pack_show
+CHECK-NEXT: warn_pragma_pop_macro_no_push
+CHECK-NEXT: warn_pragma_unknown_extension
+CHECK-NEXT: warn_pragma_unused_expected_punc
+CHECK-NEXT: warn_pragma_unused_expected_var
+CHECK-NEXT: warn_pragma_unused_expected_var_arg
+CHECK-NEXT: warn_pragma_unused_undeclared_var
+CHECK-NEXT: warn_previous_alias_decl
+CHECK-NEXT: warn_printf_asterisk_missing_arg
+CHECK-NEXT: warn_property_attr_mismatch
+CHECK-NEXT: warn_property_attribute
+CHECK-NEXT: warn_property_getter_owning_mismatch
+CHECK-NEXT: warn_property_types_are_incompatible
+CHECK-NEXT: warn_readonly_property
+CHECK-NEXT: warn_receiver_forward_class
+CHECK-NEXT: warn_redecl_library_builtin
+CHECK-NEXT: warn_redeclaration_without_attribute_prev_attribute_ignored
+CHECK-NEXT: warn_register_objc_catch_parm
+CHECK-NEXT: warn_related_result_type_compatibility_class
+CHECK-NEXT: warn_related_result_type_compatibility_protocol
+CHECK-NEXT: warn_remainder_by_zero
+CHECK-NEXT: warn_root_inst_method_not_found
+CHECK-NEXT: warn_second_parameter_of_va_start_not_last_named_argument
+CHECK-NEXT: warn_second_parameter_to_va_arg_never_compatible
+CHECK-NEXT: warn_standalone_specifier
+CHECK-NEXT: warn_static_inline_explicit_inst_ignored
+CHECK-NEXT: warn_static_non_static
+CHECK-NEXT: warn_template_export_unsupported
+CHECK-NEXT: warn_template_spec_extra_headers
+CHECK-NEXT: warn_tentative_incomplete_array
+CHECK-NEXT: warn_transparent_union_attribute_field_size_align
+CHECK-NEXT: warn_transparent_union_attribute_floating
+CHECK-NEXT: warn_transparent_union_attribute_not_definition
+CHECK-NEXT: warn_transparent_union_attribute_zero_fields
+CHECK-NEXT: warn_typecheck_function_qualifiers
+CHECK-NEXT: warn_unavailable_fwdclass_message
+CHECK-NEXT: warn_undef_interface
+CHECK-NEXT: warn_undef_interface_suggest
+CHECK-NEXT: warn_undef_protocolref
+CHECK-NEXT: warn_undefined_internal
+CHECK-NEXT: warn_unknown_analyzer_checker
+CHECK-NEXT: warn_unknown_method_family
+CHECK-NEXT: warn_unterminated_char
+CHECK-NEXT: warn_unterminated_string
+CHECK-NEXT: warn_use_out_of_scope_declaration
+CHECK-NEXT: warn_weak_identifier_undeclared
+CHECK-NEXT: warn_weak_import
diff --git a/clang/test/Misc/wnull-character.cpp b/clang/test/Misc/wnull-character.cpp
new file mode 100644
index 0000000..a618da2
--- /dev/null
+++ b/clang/test/Misc/wnull-character.cpp
Binary files differ
diff --git a/clang/test/Misc/working-directory.c b/clang/test/Misc/working-directory.c
new file mode 100644
index 0000000..5c71d9f
--- /dev/null
+++ b/clang/test/Misc/working-directory.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -working-directory %S working-directory.c -IInputs -fsyntax-only
+
+#include "working-directory.h"
+
+Foo bar;
diff --git a/clang/test/Misc/wrong-encoding.c b/clang/test/Misc/wrong-encoding.c
new file mode 100644
index 0000000..bd1cf3d
--- /dev/null
+++ b/clang/test/Misc/wrong-encoding.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s
+
+void foo() {
+
+ ""; //
+// CHECK: {{^ "<A7><C3>"; // <F8>}}
+// CHECK: {{^ \^}}
+
+ /* */ const char *d = "";
+
+// CHECK: {{^ /\* <FE><AB> \*/ const char \*d = "<A5>";}}
+// CHECK: {{^ \^}}
+
+// CHECK: {{^ "<A7><C3>"; // <F8>}}
+// CHECK: {{^ \^~~~~~~~~~}}
+}
diff --git a/clang/test/Modules/Inputs/AlsoDependsOnModule.framework/Headers/AlsoDependsOnModule.h b/clang/test/Modules/Inputs/AlsoDependsOnModule.framework/Headers/AlsoDependsOnModule.h
new file mode 100644
index 0000000..1417e0c
--- /dev/null
+++ b/clang/test/Modules/Inputs/AlsoDependsOnModule.framework/Headers/AlsoDependsOnModule.h
@@ -0,0 +1,2 @@
+#import <Module/Module.h> // expected-warning{{treating #import as an import of module 'Module'}}
+
diff --git a/clang/test/Modules/Inputs/CmdLine.framework/Headers/CmdLine.h b/clang/test/Modules/Inputs/CmdLine.framework/Headers/CmdLine.h
new file mode 100644
index 0000000..46b8fc0
--- /dev/null
+++ b/clang/test/Modules/Inputs/CmdLine.framework/Headers/CmdLine.h
@@ -0,0 +1,6 @@
+#ifdef FOO_RETURNS_INT_PTR
+int *foo(void);
+#else
+float *foo(void);
+#endif
+
diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h b/clang/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h
new file mode 100644
index 0000000..69f9e8e
--- /dev/null
+++ b/clang/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h
@@ -0,0 +1 @@
+double *sub_framework_other;
diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h b/clang/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
new file mode 100644
index 0000000..e6e835e
--- /dev/null
+++ b/clang/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
@@ -0,0 +1,2 @@
+#include "SubFramework/Other.h"
+float *sub_framework;
diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h
new file mode 100644
index 0000000..9425f48
--- /dev/null
+++ b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h
@@ -0,0 +1,5 @@
+#include <Module/Module.h> //expected-warning{{treating #include as an import of module 'Module'}}
+
+#define DEPENDS_ON_MODULE 1
+#__private_macro DEPENDS_ON_MODULE
+
diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h
new file mode 100644
index 0000000..724d798
--- /dev/null
+++ b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h
@@ -0,0 +1,5 @@
+class CXXOnly {
+ public:
+ CXXOnly();
+ ~CXXOnly();
+};
diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/other.h b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/other.h
new file mode 100644
index 0000000..5ee3f92
--- /dev/null
+++ b/clang/test/Modules/Inputs/DependsOnModule.framework/Headers/other.h
@@ -0,0 +1 @@
+int depends_on_module_other;
diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h b/clang/test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h
new file mode 100644
index 0000000..4b3c30c
--- /dev/null
+++ b/clang/test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h
@@ -0,0 +1,2 @@
+int depends_on_module_private;
+
diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/module.map b/clang/test/Modules/Inputs/DependsOnModule.framework/module.map
new file mode 100644
index 0000000..2a3dd80
--- /dev/null
+++ b/clang/test/Modules/Inputs/DependsOnModule.framework/module.map
@@ -0,0 +1,19 @@
+framework module DependsOnModule {
+ umbrella header "DependsOnModule.h"
+ header "other.h"
+ module * {
+ export *
+ }
+ explicit module CXX {
+ requires cplusplus
+ header "cxx_other.h"
+ }
+
+ explicit framework module SubFramework {
+ umbrella header "SubFramework.h"
+
+ module * {
+ export *
+ }
+ }
+}
diff --git a/clang/test/Modules/Inputs/DependsOnModule.framework/module_private.map b/clang/test/Modules/Inputs/DependsOnModule.framework/module_private.map
new file mode 100644
index 0000000..5ed0029
--- /dev/null
+++ b/clang/test/Modules/Inputs/DependsOnModule.framework/module_private.map
@@ -0,0 +1,6 @@
+explicit module DependsOnModule.Private {
+ explicit module DependsOnModule {
+ header "DependsOnModulePrivate.h"
+ }
+}
+
diff --git a/clang/test/Modules/Inputs/MethodPoolA.h b/clang/test/Modules/Inputs/MethodPoolA.h
new file mode 100644
index 0000000..6af24a9
--- /dev/null
+++ b/clang/test/Modules/Inputs/MethodPoolA.h
@@ -0,0 +1,8 @@
+
+
+
+
+@interface A
++ (int)method1;
+- (int)method2:(int)param;
+@end
diff --git a/clang/test/Modules/Inputs/MethodPoolB.h b/clang/test/Modules/Inputs/MethodPoolB.h
new file mode 100644
index 0000000..e1e86ed
--- /dev/null
+++ b/clang/test/Modules/Inputs/MethodPoolB.h
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+@interface B
+- (int)method1;
+- (int)method2:(float)param;
+@end
diff --git a/clang/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h b/clang/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
new file mode 100644
index 0000000..f7f9fb6
--- /dev/null
+++ b/clang/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
@@ -0,0 +1,5 @@
+#ifndef MODULE_SUBFRAMEWORK_H
+#define MODULE_SUBFRAMEWORK_H
+#__private_macro MODULE_SUBFRAMEWORK_H
+char *module_subframework;
+#endif
diff --git a/clang/test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h b/clang/test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h
new file mode 100644
index 0000000..6e81adc
--- /dev/null
+++ b/clang/test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h
@@ -0,0 +1 @@
+unsigned *Buried_Treasure;
diff --git a/clang/test/Modules/Inputs/Module.framework/Headers/Module.h b/clang/test/Modules/Inputs/Module.framework/Headers/Module.h
new file mode 100644
index 0000000..738b222
--- /dev/null
+++ b/clang/test/Modules/Inputs/Module.framework/Headers/Module.h
@@ -0,0 +1,22 @@
+// expected-warning{{umbrella header}}
+
+#ifndef MODULE_H
+#define MODULE_H
+const char *getModuleVersion(void);
+
+#ifdef FOO
+# error Module should have been built without -DFOO
+#endif
+
+@interface Module
++(const char *)version; // retrieve module version
++alloc;
+@end
+
+#define MODULE_H_MACRO 1
+#__private_macro MODULE_H_MACRO
+
+#include <Module/Sub.h>
+#include <Module/Buried/Treasure.h>
+
+#endif // MODULE_H
diff --git a/clang/test/Modules/Inputs/Module.framework/Headers/NotInModule.h b/clang/test/Modules/Inputs/Module.framework/Headers/NotInModule.h
new file mode 100644
index 0000000..6b15791
--- /dev/null
+++ b/clang/test/Modules/Inputs/Module.framework/Headers/NotInModule.h
@@ -0,0 +1 @@
+int not_in_module;
diff --git a/clang/test/Modules/Inputs/Module.framework/Headers/Sub.h b/clang/test/Modules/Inputs/Module.framework/Headers/Sub.h
new file mode 100644
index 0000000..dea76e7
--- /dev/null
+++ b/clang/test/Modules/Inputs/Module.framework/Headers/Sub.h
@@ -0,0 +1,3 @@
+#include <Module/Sub2.h>
+int *Module_Sub;
+
diff --git a/clang/test/Modules/Inputs/Module.framework/Headers/Sub2.h b/clang/test/Modules/Inputs/Module.framework/Headers/Sub2.h
new file mode 100644
index 0000000..beed4a8
--- /dev/null
+++ b/clang/test/Modules/Inputs/Module.framework/Headers/Sub2.h
@@ -0,0 +1 @@
+int *Module_Sub2;
diff --git a/clang/test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h b/clang/test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h
new file mode 100644
index 0000000..0782336
--- /dev/null
+++ b/clang/test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h
@@ -0,0 +1 @@
+int module_private;
diff --git a/clang/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h b/clang/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h
new file mode 100644
index 0000000..5142f56
--- /dev/null
+++ b/clang/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h
@@ -0,0 +1,3 @@
+
+@__experimental_modules_import MutuallyRecursive2;
+
diff --git a/clang/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h b/clang/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h
new file mode 100644
index 0000000..8a3cc33
--- /dev/null
+++ b/clang/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h
@@ -0,0 +1,6 @@
+
+
+@__experimental_modules_import MutuallyRecursive1;
+
+
+
diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/A.h b/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/A.h
new file mode 100644
index 0000000..73f32bf
--- /dev/null
+++ b/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/A.h
@@ -0,0 +1,8 @@
+int no_umbrella_A;
+
+inline int has_warning(int x) {
+ if (x > 0)
+ return x;
+ // Note: warning here is suppressed because this module is considered a
+ // "system" module.
+}
diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/B.h b/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/B.h
new file mode 100644
index 0000000..dc6770f
--- /dev/null
+++ b/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/B.h
@@ -0,0 +1 @@
+int no_umbrella_B;
diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h b/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h
new file mode 100644
index 0000000..ac4a14a
--- /dev/null
+++ b/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h
@@ -0,0 +1 @@
+this is gibberish
diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h b/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h
new file mode 100644
index 0000000..4a9351a
--- /dev/null
+++ b/clang/test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h
@@ -0,0 +1 @@
+int no_umbrella_C;
diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h b/clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h
new file mode 100644
index 0000000..bd606d2
--- /dev/null
+++ b/clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h
@@ -0,0 +1 @@
+int no_umbrella_A_private;
diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h b/clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h
new file mode 100644
index 0000000..442be2d
--- /dev/null
+++ b/clang/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h
@@ -0,0 +1 @@
+int no_umbrella_B_private;
diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/module.map b/clang/test/Modules/Inputs/NoUmbrella.framework/module.map
new file mode 100644
index 0000000..4a4d970
--- /dev/null
+++ b/clang/test/Modules/Inputs/NoUmbrella.framework/module.map
@@ -0,0 +1,9 @@
+framework module NoUmbrella [system] {
+ umbrella "Headers"
+ module * { }
+
+ module unavailable {
+ requires unavailable
+ header "Boom.h"
+ }
+}
diff --git a/clang/test/Modules/Inputs/NoUmbrella.framework/module_private.map b/clang/test/Modules/Inputs/NoUmbrella.framework/module_private.map
new file mode 100644
index 0000000..0507ba0
--- /dev/null
+++ b/clang/test/Modules/Inputs/NoUmbrella.framework/module_private.map
@@ -0,0 +1,4 @@
+explicit module NoUmbrella.Private {
+ umbrella "PrivateHeaders"
+ explicit module * { }
+}
diff --git a/clang/test/Modules/Inputs/System/usr/include/module.map b/clang/test/Modules/Inputs/System/usr/include/module.map
new file mode 100644
index 0000000..884b59c
--- /dev/null
+++ b/clang/test/Modules/Inputs/System/usr/include/module.map
@@ -0,0 +1,21 @@
+module cstd [system] {
+ // Only in compiler support directory
+ module float_constants {
+ header "float.h"
+ }
+
+ // Only in system headers directory
+ module stdio {
+ header "stdio.h"
+ }
+
+ // In both directories (compiler support version wins, does not forward)
+ module stdbool {
+ header "stdbool.h"
+ }
+
+ // In both directories (compiler support version wins, forwards)
+ module stdint {
+ header "stdint.h"
+ }
+}
diff --git a/clang/test/Modules/Inputs/System/usr/include/stdbool.h b/clang/test/Modules/Inputs/System/usr/include/stdbool.h
new file mode 100644
index 0000000..760d7dc
--- /dev/null
+++ b/clang/test/Modules/Inputs/System/usr/include/stdbool.h
@@ -0,0 +1 @@
+// Testing hack: does not define bool/true/false.
diff --git a/clang/test/Modules/Inputs/System/usr/include/stdint.h b/clang/test/Modules/Inputs/System/usr/include/stdint.h
new file mode 100644
index 0000000..e8e50f9
--- /dev/null
+++ b/clang/test/Modules/Inputs/System/usr/include/stdint.h
@@ -0,0 +1 @@
+typedef int my_awesome_nonstandard_integer_type;
diff --git a/clang/test/Modules/Inputs/System/usr/include/stdio.h b/clang/test/Modules/Inputs/System/usr/include/stdio.h
new file mode 100644
index 0000000..9a7b106
--- /dev/null
+++ b/clang/test/Modules/Inputs/System/usr/include/stdio.h
@@ -0,0 +1,3 @@
+typedef struct { int id; } FILE;
+int fprintf(FILE*restrict, const char* restrict format, ...);
+
diff --git a/clang/test/Modules/Inputs/category_bottom.h b/clang/test/Modules/Inputs/category_bottom.h
new file mode 100644
index 0000000..b53d9c3
--- /dev/null
+++ b/clang/test/Modules/Inputs/category_bottom.h
@@ -0,0 +1,11 @@
+@__experimental_modules_import category_left;
+
+@interface Foo(Bottom)
+-(void)bottom;
+@end
+
+@__experimental_modules_import category_right;
+
+@interface LeftFoo(Bottom)
+-(void)bottom;
+@end
diff --git a/clang/test/Modules/Inputs/category_left.h b/clang/test/Modules/Inputs/category_left.h
new file mode 100644
index 0000000..736fa43
--- /dev/null
+++ b/clang/test/Modules/Inputs/category_left.h
@@ -0,0 +1,15 @@
+@__experimental_modules_import category_top;
+
+@interface Foo(Left)
+-(void)left;
+@end
+
+@interface LeftFoo
+-(void)left;
+@end
+
+@interface Foo(Duplicate)
+@end
+
+@interface Foo(Duplicate)
+@end
diff --git a/clang/test/Modules/Inputs/category_other.h b/clang/test/Modules/Inputs/category_other.h
new file mode 100644
index 0000000..1bb5a91
--- /dev/null
+++ b/clang/test/Modules/Inputs/category_other.h
@@ -0,0 +1,6 @@
+@__experimental_modules_import category_top;
+
+@interface Foo(Other)
+-(void)other;
+@end
+
diff --git a/clang/test/Modules/Inputs/category_right.h b/clang/test/Modules/Inputs/category_right.h
new file mode 100644
index 0000000..d993b50
--- /dev/null
+++ b/clang/test/Modules/Inputs/category_right.h
@@ -0,0 +1,12 @@
+@__experimental_modules_import category_top;
+
+@interface Foo(Right1)
+-(void)right1;
+@end
+
+@interface Foo(Right2)
+-(void)right2;
+@end
+
+@interface Foo(Duplicate) // expected-warning {{duplicate definition of category}}
+@end
diff --git a/clang/test/Modules/Inputs/category_top.h b/clang/test/Modules/Inputs/category_top.h
new file mode 100644
index 0000000..c9558b6
--- /dev/null
+++ b/clang/test/Modules/Inputs/category_top.h
@@ -0,0 +1,14 @@
+@interface Foo
+@end
+
+@interface Foo(Top)
+-(void)top;
+@end
+
+@interface Foo(Top2)
+-(void)top2;
+@end
+
+@interface Foo(Top3)
+-(void)top3;
+@end
diff --git a/clang/test/Modules/Inputs/decl.h b/clang/test/Modules/Inputs/decl.h
new file mode 100644
index 0000000..8dbe11e
--- /dev/null
+++ b/clang/test/Modules/Inputs/decl.h
@@ -0,0 +1,2 @@
+@class A;
+typedef struct B B;
diff --git a/clang/test/Modules/Inputs/decl2.h b/clang/test/Modules/Inputs/decl2.h
new file mode 100644
index 0000000..decf6e0
--- /dev/null
+++ b/clang/test/Modules/Inputs/decl2.h
@@ -0,0 +1 @@
+@class A;
diff --git a/clang/test/Modules/Inputs/def-include.h b/clang/test/Modules/Inputs/def-include.h
new file mode 100644
index 0000000..9e0e575
--- /dev/null
+++ b/clang/test/Modules/Inputs/def-include.h
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+struct B {
+ int b1;
+};
diff --git a/clang/test/Modules/Inputs/def.h b/clang/test/Modules/Inputs/def.h
new file mode 100644
index 0000000..6d06b08
--- /dev/null
+++ b/clang/test/Modules/Inputs/def.h
@@ -0,0 +1,11 @@
+#include "def-include.h"
+
+
+
+@interface A {
+@public
+ int ivar;
+}
+@end
+
+
diff --git a/clang/test/Modules/Inputs/diamond.h b/clang/test/Modules/Inputs/diamond.h
new file mode 100644
index 0000000..15b5290
--- /dev/null
+++ b/clang/test/Modules/Inputs/diamond.h
@@ -0,0 +1 @@
+@__experimental_modules_import diamond_bottom;
diff --git a/clang/test/Modules/Inputs/diamond_bottom.h b/clang/test/Modules/Inputs/diamond_bottom.h
new file mode 100644
index 0000000..b45fa93
--- /dev/null
+++ b/clang/test/Modules/Inputs/diamond_bottom.h
@@ -0,0 +1,4 @@
+@__experimental_modules_import diamond_left;
+@__experimental_modules_import diamond_right;
+
+char bottom(char *x);
diff --git a/clang/test/Modules/Inputs/diamond_left.h b/clang/test/Modules/Inputs/diamond_left.h
new file mode 100644
index 0000000..cc406ab
--- /dev/null
+++ b/clang/test/Modules/Inputs/diamond_left.h
@@ -0,0 +1,9 @@
+@__experimental_modules_import diamond_top;
+
+float left(float *);
+
+int top_left(char *c);
+
+int left_and_right(int*);
+
+
diff --git a/clang/test/Modules/Inputs/diamond_right.h b/clang/test/Modules/Inputs/diamond_right.h
new file mode 100644
index 0000000..2ba1d77
--- /dev/null
+++ b/clang/test/Modules/Inputs/diamond_right.h
@@ -0,0 +1,7 @@
+@__experimental_modules_import diamond_top;
+
+double right(double *);
+
+struct left_and_right {
+ int left, right;
+};
diff --git a/clang/test/Modules/Inputs/diamond_top.h b/clang/test/Modules/Inputs/diamond_top.h
new file mode 100644
index 0000000..34998cd
--- /dev/null
+++ b/clang/test/Modules/Inputs/diamond_top.h
@@ -0,0 +1,4 @@
+int top(int *);
+
+int top_left(char *c);
+
diff --git a/clang/test/Modules/Inputs/irgen.h b/clang/test/Modules/Inputs/irgen.h
new file mode 100644
index 0000000..9936bf6
--- /dev/null
+++ b/clang/test/Modules/Inputs/irgen.h
@@ -0,0 +1 @@
+static inline int triple(int x) { return x * 3; }
diff --git a/clang/test/Modules/Inputs/load_failure.h b/clang/test/Modules/Inputs/load_failure.h
new file mode 100644
index 0000000..5bcb44d
--- /dev/null
+++ b/clang/test/Modules/Inputs/load_failure.h
@@ -0,0 +1 @@
+int fail(int);
diff --git a/clang/test/Modules/Inputs/lookup_left.h b/clang/test/Modules/Inputs/lookup_left.h
new file mode 100644
index 0000000..01723d4
--- /dev/null
+++ b/clang/test/Modules/Inputs/lookup_left.h
@@ -0,0 +1,3 @@
+@interface A
+- (int)method;
+@end
diff --git a/clang/test/Modules/Inputs/lookup_left.hpp b/clang/test/Modules/Inputs/lookup_left.hpp
new file mode 100644
index 0000000..66d6206
--- /dev/null
+++ b/clang/test/Modules/Inputs/lookup_left.hpp
@@ -0,0 +1,5 @@
+int *f0(int*);
+
+#pragma weak weak_identifier // expected-warning{{weak identifier 'weak_identifier' never declared}}
+
+
diff --git a/clang/test/Modules/Inputs/lookup_right.h b/clang/test/Modules/Inputs/lookup_right.h
new file mode 100644
index 0000000..f8f0c97
--- /dev/null
+++ b/clang/test/Modules/Inputs/lookup_right.h
@@ -0,0 +1,5 @@
+
+@interface B
+- (double)method;
+@end
+
diff --git a/clang/test/Modules/Inputs/lookup_right.hpp b/clang/test/Modules/Inputs/lookup_right.hpp
new file mode 100644
index 0000000..8845347
--- /dev/null
+++ b/clang/test/Modules/Inputs/lookup_right.hpp
@@ -0,0 +1 @@
+float *f0(float*);
diff --git a/clang/test/Modules/Inputs/macros.h b/clang/test/Modules/Inputs/macros.h
new file mode 100644
index 0000000..4f53556
--- /dev/null
+++ b/clang/test/Modules/Inputs/macros.h
@@ -0,0 +1,10 @@
+#define MODULE
+#define INTEGER(X) int
+#define FLOAT float
+#define DOUBLE double
+
+#__public_macro INTEGER
+#__private_macro FLOAT
+#__private_macro MODULE
+
+int (INTEGER);
diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map
new file mode 100644
index 0000000..e8d1f2c
--- /dev/null
+++ b/clang/test/Modules/Inputs/module.map
@@ -0,0 +1,86 @@
+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 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 { header "macros.h" }
+module category_top { header "category_top.h" }
+module category_left {
+ header "category_left.h"
+ export category_top
+}
+module category_right {
+ header "category_right.h"
+ export category_top
+}
+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 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" }
+}
+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 {
+ 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 MethodPoolA {
+ header "MethodPoolA.h"
+}
+module MethodPoolB {
+ header "MethodPoolB.h"
+}
diff --git a/clang/test/Modules/Inputs/module_private_left.h b/clang/test/Modules/Inputs/module_private_left.h
new file mode 100644
index 0000000..ff33999
--- /dev/null
+++ b/clang/test/Modules/Inputs/module_private_left.h
@@ -0,0 +1,26 @@
+__module_private__ struct HiddenStruct;
+
+__module_private__ struct HiddenStruct {
+};
+
+
+int &f0(int);
+
+template<typename T>
+__module_private__ void f1(T*);
+
+template<typename T>
+__module_private__ void f1(T*);
+
+template<typename T>
+__module_private__ class vector;
+
+template<typename T>
+__module_private__ class vector {
+};
+
+vector<float> vec_float;
+
+typedef __module_private__ int Integer;
+typedef __module_private__ int Integer;
+
diff --git a/clang/test/Modules/Inputs/module_private_right.h b/clang/test/Modules/Inputs/module_private_right.h
new file mode 100644
index 0000000..53efe25
--- /dev/null
+++ b/clang/test/Modules/Inputs/module_private_right.h
@@ -0,0 +1,13 @@
+__module_private__ double &f0(double);
+__module_private__ double &f0(double);
+
+__module_private__ int hidden_var;
+
+inline void test_f0_in_right() {
+ double &dr = f0(hidden_var);
+}
+
+struct VisibleStruct {
+ __module_private__ int field;
+ __module_private__ virtual void setField(int f);
+};
diff --git a/clang/test/Modules/Inputs/namespaces-left.h b/clang/test/Modules/Inputs/namespaces-left.h
new file mode 100644
index 0000000..d253fed
--- /dev/null
+++ b/clang/test/Modules/Inputs/namespaces-left.h
@@ -0,0 +1,53 @@
+@__experimental_modules_import namespaces_top;
+
+namespace N1 { }
+
+namespace N1 {
+ float& f(float);
+}
+
+namespace N2 {
+ float& f(float);
+}
+
+
+
+
+
+namespace N5 {
+ int &f(int);
+}
+
+namespace N6 {
+ int &f(int);
+}
+
+namespace N7 {
+ int &f(int);
+}
+
+namespace N8 {
+ int &f(int);
+}
+
+namespace N9 {
+ int &f(int);
+}
+
+namespace N10 {
+ int &f(int);
+}
+
+namespace N11 {
+ namespace {
+ class Foo;
+ }
+ Foo *getFoo();
+}
+
+namespace N12 {
+ namespace {
+ class Foo;
+ }
+ Foo *getFoo();
+}
diff --git a/clang/test/Modules/Inputs/namespaces-right.h b/clang/test/Modules/Inputs/namespaces-right.h
new file mode 100644
index 0000000..7e7286e
--- /dev/null
+++ b/clang/test/Modules/Inputs/namespaces-right.h
@@ -0,0 +1,61 @@
+@__experimental_modules_import namespaces_top;
+
+namespace N2 { }
+
+namespace N2 { }
+
+namespace N2 { }
+
+namespace N2 { }
+
+namespace N2 {
+ double& f(double);
+}
+
+namespace N3 {
+ double& f(double);
+}
+
+namespace N5 {
+ double &f(double);
+}
+
+namespace N6 {
+ double &f(double);
+}
+
+namespace N7 {
+ double &f(double);
+}
+
+namespace N8 {
+ int &f(int);
+}
+
+namespace N9 {
+ int &f(int);
+}
+
+namespace N10 {
+ int &f(int);
+}
+
+
+
+
+
+
+
+namespace N11 {
+ namespace {
+ class Foo;
+ }
+ void consumeFoo(Foo*);
+}
+
+namespace N12 {
+ namespace {
+ class Foo;
+ }
+ void consumeFoo(Foo*);
+}
diff --git a/clang/test/Modules/Inputs/namespaces-top.h b/clang/test/Modules/Inputs/namespaces-top.h
new file mode 100644
index 0000000..0c607f5
--- /dev/null
+++ b/clang/test/Modules/Inputs/namespaces-top.h
@@ -0,0 +1,14 @@
+namespace N1 {
+ int& f(int);
+}
+
+namespace N2 {
+ int& f(int);
+}
+
+namespace N3 {
+ int& f(int);
+}
+
+namespace N12 { }
+
diff --git a/clang/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h b/clang/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h
new file mode 100644
index 0000000..7462376
--- /dev/null
+++ b/clang/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h
@@ -0,0 +1,4 @@
+int umbrella;
+
+#include "umbrella_sub.h"
+
diff --git a/clang/test/Modules/Inputs/normal-module-map/Umbrella/module.map b/clang/test/Modules/Inputs/normal-module-map/Umbrella/module.map
new file mode 100644
index 0000000..611cf9f
--- /dev/null
+++ b/clang/test/Modules/Inputs/normal-module-map/Umbrella/module.map
@@ -0,0 +1,3 @@
+module Umbrella {
+ umbrella header "Umbrella.h"
+} \ No newline at end of file
diff --git a/clang/test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h b/clang/test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h
new file mode 100644
index 0000000..9fdccd1
--- /dev/null
+++ b/clang/test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h
@@ -0,0 +1,2 @@
+int umbrella_sub;
+
diff --git a/clang/test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h b/clang/test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h
new file mode 100644
index 0000000..36110d8
--- /dev/null
+++ b/clang/test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h
@@ -0,0 +1 @@
+int umbrella2;
diff --git a/clang/test/Modules/Inputs/normal-module-map/Umbrella2/module.map b/clang/test/Modules/Inputs/normal-module-map/Umbrella2/module.map
new file mode 100644
index 0000000..1e57704
--- /dev/null
+++ b/clang/test/Modules/Inputs/normal-module-map/Umbrella2/module.map
@@ -0,0 +1,3 @@
+module Umbrella2 {
+ umbrella header "Umbrella2.h"
+}
diff --git a/clang/test/Modules/Inputs/normal-module-map/a1.h b/clang/test/Modules/Inputs/normal-module-map/a1.h
new file mode 100644
index 0000000..f2d5a49
--- /dev/null
+++ b/clang/test/Modules/Inputs/normal-module-map/a1.h
@@ -0,0 +1 @@
+int a1;
diff --git a/clang/test/Modules/Inputs/normal-module-map/a2.h b/clang/test/Modules/Inputs/normal-module-map/a2.h
new file mode 100644
index 0000000..5c4e7ff
--- /dev/null
+++ b/clang/test/Modules/Inputs/normal-module-map/a2.h
@@ -0,0 +1 @@
+int a2;
diff --git a/clang/test/Modules/Inputs/normal-module-map/b1.h b/clang/test/Modules/Inputs/normal-module-map/b1.h
new file mode 100644
index 0000000..2ed1112
--- /dev/null
+++ b/clang/test/Modules/Inputs/normal-module-map/b1.h
@@ -0,0 +1,2 @@
+int b1;
+
diff --git a/clang/test/Modules/Inputs/normal-module-map/module.map b/clang/test/Modules/Inputs/normal-module-map/module.map
new file mode 100644
index 0000000..e17f44a
--- /dev/null
+++ b/clang/test/Modules/Inputs/normal-module-map/module.map
@@ -0,0 +1,13 @@
+module libA {
+ module a1 { header "a1.h" }
+ header "a2.h"
+}
+
+module libB {
+ header "b1.h"
+}
+
+module nested_umbrella {
+ umbrella "nested_umbrella"
+ module * { }
+}
diff --git a/clang/test/Modules/Inputs/normal-module-map/nested/module.map b/clang/test/Modules/Inputs/normal-module-map/nested/module.map
new file mode 100644
index 0000000..fd463c2
--- /dev/null
+++ b/clang/test/Modules/Inputs/normal-module-map/nested/module.map
@@ -0,0 +1,4 @@
+module libNested {
+ header "nested1.h"
+ header "nested2.h"
+} \ No newline at end of file
diff --git a/clang/test/Modules/Inputs/normal-module-map/nested/nested1.h b/clang/test/Modules/Inputs/normal-module-map/nested/nested1.h
new file mode 100644
index 0000000..3790d1a
--- /dev/null
+++ b/clang/test/Modules/Inputs/normal-module-map/nested/nested1.h
@@ -0,0 +1 @@
+int nested1;
diff --git a/clang/test/Modules/Inputs/normal-module-map/nested/nested2.h b/clang/test/Modules/Inputs/normal-module-map/nested/nested2.h
new file mode 100644
index 0000000..d56d601
--- /dev/null
+++ b/clang/test/Modules/Inputs/normal-module-map/nested/nested2.h
@@ -0,0 +1 @@
+int nested2;
diff --git a/clang/test/Modules/Inputs/normal-module-map/nested_umbrella/a.h b/clang/test/Modules/Inputs/normal-module-map/nested_umbrella/a.h
new file mode 100644
index 0000000..ab180fe
--- /dev/null
+++ b/clang/test/Modules/Inputs/normal-module-map/nested_umbrella/a.h
@@ -0,0 +1,2 @@
+int nested_umbrella_a;
+
diff --git a/clang/test/Modules/Inputs/normal-module-map/nested_umbrella/b.h b/clang/test/Modules/Inputs/normal-module-map/nested_umbrella/b.h
new file mode 100644
index 0000000..a903f5d
--- /dev/null
+++ b/clang/test/Modules/Inputs/normal-module-map/nested_umbrella/b.h
@@ -0,0 +1,2 @@
+int nested_umbrella_b;
+
diff --git a/clang/test/Modules/Inputs/point.h b/clang/test/Modules/Inputs/point.h
new file mode 100644
index 0000000..eab23d5
--- /dev/null
+++ b/clang/test/Modules/Inputs/point.h
@@ -0,0 +1,2 @@
+struct Point { int x, y; };
+
diff --git a/clang/test/Modules/Inputs/redecl-merge-bottom.h b/clang/test/Modules/Inputs/redecl-merge-bottom.h
new file mode 100644
index 0000000..40a9404
--- /dev/null
+++ b/clang/test/Modules/Inputs/redecl-merge-bottom.h
@@ -0,0 +1,28 @@
+@__experimental_modules_import redecl_merge_left;
+
+@class C4;
+@class C4;
+@protocol P4;
+@protocol P4;
+@protocol P4;
+@__experimental_modules_import redecl_merge_right;
+
+@class B;
+
+@class A;
+
+@protocol P1;
+
+struct S1;
+struct S3;
+
+void refers_to_C4(C4*);
+
+#ifdef __cplusplus
+template<typename T> class Vector;
+
+template<typename T> class Vector;
+
+template<typename T> class Vector;
+#endif
+
diff --git a/clang/test/Modules/Inputs/redecl-merge-left-left.h b/clang/test/Modules/Inputs/redecl-merge-left-left.h
new file mode 100644
index 0000000..5f48883
--- /dev/null
+++ b/clang/test/Modules/Inputs/redecl-merge-left-left.h
@@ -0,0 +1,7 @@
+@__experimental_modules_import redecl_merge_left;
+
+@class C4;
+void accept_a_C4(C4*);
+
+@class ClassWithDef;
+
diff --git a/clang/test/Modules/Inputs/redecl-merge-left.h b/clang/test/Modules/Inputs/redecl-merge-left.h
new file mode 100644
index 0000000..b3a7ba8
--- /dev/null
+++ b/clang/test/Modules/Inputs/redecl-merge-left.h
@@ -0,0 +1,90 @@
+@__experimental_modules_import redecl_merge_top;
+
+@class A;
+
+@class A;
+
+@interface B
++ (B*) create_a_B;
+@end
+
+@class A;
+
+@protocol P1;
+@protocol P2
+- (void)protoMethod2;
+@end
+
+struct S1;
+struct S2 {
+ int field;
+};
+
+struct S1 *produce_S1(void);
+void consume_S2(struct S2*);
+
+// Test declarations in different modules with no common initial
+// declaration.
+@class C;
+void accept_a_C(C*);
+
+@class C2;
+void accept_a_C2(C2*);
+
+@class C3;
+void accept_a_C3(C3*);
+@class C3;
+
+@class C4;
+
+@class Explicit;
+
+int *explicit_func(void);
+
+struct explicit_struct;
+
+@protocol P3, P4;
+
+@protocol P3;
+
+struct S3;
+struct S3;
+struct S4 {
+ int field;
+};
+
+struct S3 *produce_S3(void);
+void consume_S4(struct S4*);
+
+typedef int T1;
+typedef float T2;
+
+int func0(int);
+int func1(int);
+int func2(int);
+
+
+
+
+
+
+
+
+
+
+// Spacing matters!
+extern int var1;
+extern float var2;
+
+extern double var3;
+
+#ifdef __cplusplus
+template<typename T> class Vector;
+
+template<typename T> class Vector;
+#endif
+
+// Make sure this doesn't introduce an ambiguity-creating 'id' at the
+// top level.
+typedef void funcptr_with_id(int id);
+
diff --git a/clang/test/Modules/Inputs/redecl-merge-right.h b/clang/test/Modules/Inputs/redecl-merge-right.h
new file mode 100644
index 0000000..de7aa08
--- /dev/null
+++ b/clang/test/Modules/Inputs/redecl-merge-right.h
@@ -0,0 +1,94 @@
+@__experimental_modules_import redecl_merge_top;
+
+@interface Super
+@end
+
+@interface A : Super
+- (Super*)init;
+@end
+
+@class B;
+
+@protocol P1
+- (void)protoMethod1;
+@end
+
+@protocol P1;
+
+@protocol P2;
+
+@protocol P2;
+
+@protocol P2;
+
+struct S1;
+struct S2;
+
+void consume_S1(struct S1*);
+struct S2 *produce_S2(void);
+
+// Test declarations in different modules with no common initial
+// declaration.
+@class C;
+C *get_a_C(void);
+@class C2;
+C2 *get_a_C2(void);
+@class C3;
+C3 *get_a_C3(void);
+
+@class C4;
+@class C4;
+@class C4;
+@class C4;
+C4 *get_a_C4(void);
+
+@class Explicit;
+
+int *explicit_func(void);
+
+struct explicit_struct;
+
+@protocol P4, P3;
+@protocol P3;
+@protocol P3;
+@protocol P3;
+
+struct S3;
+struct S4;
+
+void consume_S3(struct S3*);
+struct S4 *produce_S4(void);
+
+typedef int T1;
+typedef double T2;
+
+int func0(int);
+int func1(int);
+int func1(int);
+int func1(int);
+int func1(int);
+static int func2(int);
+
+
+
+
+// Spacing matters!
+extern int var1;
+extern int var2;
+
+static double var3;
+
+#ifdef __cplusplus
+template<typename T> class Vector {
+public:
+ void push_back(const T&);
+};
+#endif
+
+int ONE;
+@__experimental_modules_import redecl_merge_top.Explicit;
+const int one = ONE;
+
+@interface ClassWithDef
+- (void)method;
+@end
diff --git a/clang/test/Modules/Inputs/redecl-merge-top-explicit.h b/clang/test/Modules/Inputs/redecl-merge-top-explicit.h
new file mode 100644
index 0000000..e06ff7a
--- /dev/null
+++ b/clang/test/Modules/Inputs/redecl-merge-top-explicit.h
@@ -0,0 +1,9 @@
+@class Explicit;
+
+int *explicit_func(void);
+
+struct explicit_struct { int member; };
+
+#define ONE 1
+
+typedef struct my_struct_type *my_struct_ref;
diff --git a/clang/test/Modules/Inputs/redecl-merge-top.h b/clang/test/Modules/Inputs/redecl-merge-top.h
new file mode 100644
index 0000000..519254c
--- /dev/null
+++ b/clang/test/Modules/Inputs/redecl-merge-top.h
@@ -0,0 +1,20 @@
+@class A;
+
+@class A;
+
+@class A;
+
+@class B;
+
+@protocol P1;
+
+@protocol P2;
+@protocol P2;
+
+struct S1;
+struct S2;
+struct S2;
+
+#ifdef __cplusplus
+template<typename T> class Vector;
+#endif
diff --git a/clang/test/Modules/Inputs/redecl_namespaces_left.h b/clang/test/Modules/Inputs/redecl_namespaces_left.h
new file mode 100644
index 0000000..49595ea
--- /dev/null
+++ b/clang/test/Modules/Inputs/redecl_namespaces_left.h
@@ -0,0 +1,3 @@
+namespace A {
+ int i;
+}
diff --git a/clang/test/Modules/Inputs/redecl_namespaces_right.h b/clang/test/Modules/Inputs/redecl_namespaces_right.h
new file mode 100644
index 0000000..fdf65ba
--- /dev/null
+++ b/clang/test/Modules/Inputs/redecl_namespaces_right.h
@@ -0,0 +1,3 @@
+namespace A {
+ int j;
+}
diff --git a/clang/test/Modules/Inputs/redeclarations_left.h b/clang/test/Modules/Inputs/redeclarations_left.h
new file mode 100644
index 0000000..4dfbf1d
--- /dev/null
+++ b/clang/test/Modules/Inputs/redeclarations_left.h
@@ -0,0 +1,2 @@
+@class NSObject;
+
diff --git a/clang/test/Modules/Inputs/redeclarations_right.h b/clang/test/Modules/Inputs/redeclarations_right.h
new file mode 100644
index 0000000..d3861fe
--- /dev/null
+++ b/clang/test/Modules/Inputs/redeclarations_right.h
@@ -0,0 +1,2 @@
+@interface NSObject
+@end
diff --git a/clang/test/Modules/Inputs/subdir/module.map b/clang/test/Modules/Inputs/subdir/module.map
new file mode 100644
index 0000000..4cd0215
--- /dev/null
+++ b/clang/test/Modules/Inputs/subdir/module.map
@@ -0,0 +1,3 @@
+module subdir {
+ header "subdir.h"
+}
diff --git a/clang/test/Modules/Inputs/subdir/subdir.h b/clang/test/Modules/Inputs/subdir/subdir.h
new file mode 100644
index 0000000..0fb3d21
--- /dev/null
+++ b/clang/test/Modules/Inputs/subdir/subdir.h
@@ -0,0 +1 @@
+const char *getSubdir();
diff --git a/clang/test/Modules/Inputs/submodules/hash_map.h b/clang/test/Modules/Inputs/submodules/hash_map.h
new file mode 100644
index 0000000..ce85984
--- /dev/null
+++ b/clang/test/Modules/Inputs/submodules/hash_map.h
@@ -0,0 +1,4 @@
+template<typename Key, typename Data> class hash_map { };
+
+#define HAVE_HASH_MAP
+
diff --git a/clang/test/Modules/Inputs/submodules/module.map b/clang/test/Modules/Inputs/submodules/module.map
new file mode 100644
index 0000000..16cedac
--- /dev/null
+++ b/clang/test/Modules/Inputs/submodules/module.map
@@ -0,0 +1,5 @@
+module std {
+ module vector { header "vector.h" }
+ module type_traits { header "type_traits.h" }
+ explicit module hash_map { header "hash_map.h" }
+}
diff --git a/clang/test/Modules/Inputs/submodules/type_traits.h b/clang/test/Modules/Inputs/submodules/type_traits.h
new file mode 100644
index 0000000..4dad090
--- /dev/null
+++ b/clang/test/Modules/Inputs/submodules/type_traits.h
@@ -0,0 +1,12 @@
+template<typename T>
+struct remove_reference {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_reference<T&> {
+ typedef T type;
+};
+
+#define HAVE_TYPE_TRAITS
+
diff --git a/clang/test/Modules/Inputs/submodules/vector.h b/clang/test/Modules/Inputs/submodules/vector.h
new file mode 100644
index 0000000..8e1cdc8
--- /dev/null
+++ b/clang/test/Modules/Inputs/submodules/vector.h
@@ -0,0 +1,3 @@
+template<typename T> class vector { };
+
+#define HAVE_VECTOR
diff --git a/clang/test/Modules/Inputs/wildcard-submodule-exports/A_one.h b/clang/test/Modules/Inputs/wildcard-submodule-exports/A_one.h
new file mode 100644
index 0000000..4a2c239
--- /dev/null
+++ b/clang/test/Modules/Inputs/wildcard-submodule-exports/A_one.h
@@ -0,0 +1 @@
+int *A1;
diff --git a/clang/test/Modules/Inputs/wildcard-submodule-exports/A_two.h b/clang/test/Modules/Inputs/wildcard-submodule-exports/A_two.h
new file mode 100644
index 0000000..1b08599
--- /dev/null
+++ b/clang/test/Modules/Inputs/wildcard-submodule-exports/A_two.h
@@ -0,0 +1 @@
+unsigned int *A2;
diff --git a/clang/test/Modules/Inputs/wildcard-submodule-exports/B_one.h b/clang/test/Modules/Inputs/wildcard-submodule-exports/B_one.h
new file mode 100644
index 0000000..0f44a56
--- /dev/null
+++ b/clang/test/Modules/Inputs/wildcard-submodule-exports/B_one.h
@@ -0,0 +1 @@
+short *B1;
diff --git a/clang/test/Modules/Inputs/wildcard-submodule-exports/B_two.h b/clang/test/Modules/Inputs/wildcard-submodule-exports/B_two.h
new file mode 100644
index 0000000..0e51242
--- /dev/null
+++ b/clang/test/Modules/Inputs/wildcard-submodule-exports/B_two.h
@@ -0,0 +1 @@
+unsigned short *B2;
diff --git a/clang/test/Modules/Inputs/wildcard-submodule-exports/C_one.h b/clang/test/Modules/Inputs/wildcard-submodule-exports/C_one.h
new file mode 100644
index 0000000..fb1c7de
--- /dev/null
+++ b/clang/test/Modules/Inputs/wildcard-submodule-exports/C_one.h
@@ -0,0 +1,4 @@
+@__experimental_modules_import A.One;
+@__experimental_modules_import B.One;
+
+long *C1;
diff --git a/clang/test/Modules/Inputs/wildcard-submodule-exports/C_two.h b/clang/test/Modules/Inputs/wildcard-submodule-exports/C_two.h
new file mode 100644
index 0000000..050a8f3
--- /dev/null
+++ b/clang/test/Modules/Inputs/wildcard-submodule-exports/C_two.h
@@ -0,0 +1,4 @@
+@__experimental_modules_import A.Two;
+@__experimental_modules_import B.Two;
+
+unsigned long *C2;
diff --git a/clang/test/Modules/Inputs/wildcard-submodule-exports/module.map b/clang/test/Modules/Inputs/wildcard-submodule-exports/module.map
new file mode 100644
index 0000000..64b0d89
--- /dev/null
+++ b/clang/test/Modules/Inputs/wildcard-submodule-exports/module.map
@@ -0,0 +1,20 @@
+module A {
+ module One { header "A_one.h" }
+ module Two { header "A_two.h" }
+}
+
+module B {
+ module One { header "B_one.h" }
+ module Two { header "B_two.h" }
+}
+
+module C {
+ module One {
+ header "C_one.h"
+ export A.*
+ }
+ module Two {
+ header "C_two.h"
+ export *
+ }
+}
diff --git a/clang/test/Modules/auto-module-import.m b/clang/test/Modules/auto-module-import.m
new file mode 100644
index 0000000..fbd0a54
--- /dev/null
+++ b/clang/test/Modules/auto-module-import.m
@@ -0,0 +1,73 @@
+// other file: expected-note{{'no_umbrella_A_private' declared here}}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs %s -verify
+
+#include <DependsOnModule/DependsOnModule.h> // expected-warning{{treating #include as an import of module 'DependsOnModule'}}
+
+#ifdef MODULE_H_MACRO
+# error MODULE_H_MACRO should have been hidden
+#endif
+
+#ifdef DEPENDS_ON_MODULE
+# error DEPENDS_ON_MODULE should have been hidden
+#endif
+
+Module *mod; // expected-error{{unknown type name 'Module'}}
+
+#import <AlsoDependsOnModule/AlsoDependsOnModule.h> // expected-warning{{treating #import as an import of module 'AlsoDependsOnModule'}}
+Module *mod2;
+
+int getDependsOther() { return depends_on_module_other; }
+
+void testSubframeworkOther() {
+ double *sfo1 = sub_framework_other; // expected-error{{use of undeclared identifier 'sub_framework_other'}}
+}
+
+// Test umbrella-less submodule includes
+#include <NoUmbrella/A.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.A'}}
+int getNoUmbrellaA() { return no_umbrella_A; }
+
+// Test umbrella-less submodule includes
+#include <NoUmbrella/SubDir/C.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.SubDir.C'}}
+int getNoUmbrellaC() { return no_umbrella_C; }
+
+// Test header cross-subframework include pattern.
+#include <DependsOnModule/../Frameworks/SubFramework.framework/Headers/Other.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.SubFramework.Other'}}
+
+void testSubframeworkOtherAgain() {
+ double *sfo1 = sub_framework_other;
+}
+
+void testModuleSubFramework() {
+ char *msf = module_subframework;
+}
+
+#include <Module/../Frameworks/SubFramework.framework/Headers/SubFramework.h> // expected-warning{{treating #include as an import of module 'Module.SubFramework'}}
+
+void testModuleSubFrameworkAgain() {
+ char *msf = module_subframework;
+}
+
+// Test inclusion of private headers.
+#include <DependsOnModule/DependsOnModulePrivate.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.Private.DependsOnModule'}}
+
+int getDependsOnModulePrivate() { return depends_on_module_private; }
+
+#include <Module/ModulePrivate.h> // includes the header
+
+int getModulePrivate() { return module_private; }
+
+#include <NoUmbrella/A_Private.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.Private.A_Private'}}
+int getNoUmbrellaAPrivate() { return no_umbrella_A_private; }
+
+int getNoUmbrellaBPrivateFail() { return no_umbrella_B_private; } // expected-error{{use of undeclared identifier 'no_umbrella_B_private'; did you mean 'no_umbrella_A_private'?}}
+
+// Test inclusion of headers that are under an umbrella directory but
+// not actually part of the module.
+#include <Module/NotInModule.h> // expected-warning{{treating #include as an import of module 'Module.NotInModule'}} \
+ // expected-warning{{missing submodule 'Module.NotInModule'}}
+
+int getNotInModule() {
+ return not_in_module;
+}
diff --git a/clang/test/Modules/compiler_builtins.m b/clang/test/Modules/compiler_builtins.m
new file mode 100644
index 0000000..de6f57b
--- /dev/null
+++ b/clang/test/Modules/compiler_builtins.m
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+// RUN: %clang -fsyntax-only -fmodules -fmodule-cache-path %t -D__need_wint_t %s -Xclang -verify
+
+#ifdef __SSE__
+@__experimental_modules_import _Builtin_intrinsics.intel.sse;
+#endif
+
+#ifdef __AVX2__
+@__experimental_modules_import _Builtin_intrinsics.intel.avx2;
+#endif
diff --git a/clang/test/Modules/cstd.m b/clang/test/Modules/cstd.m
new file mode 100644
index 0000000..1752cd3
--- /dev/null
+++ b/clang/test/Modules/cstd.m
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: %clang -fsyntax-only -isystem %S/Inputs/System/usr/include -fmodules -fmodule-cache-path %t -D__need_wint_t -Werror=implicit-function-declaration %s
+
+// Supplied by compiler, but referenced from the "/usr/include" module map.
+@__experimental_modules_import cstd.float_constants;
+
+float getFltMax() { return FLT_MAX; }
+
+// Supplied by the "/usr/include" module map.
+@__experimental_modules_import cstd.stdio;
+
+void test_fprintf(FILE *file) {
+ fprintf(file, "Hello, modules\n");
+}
+
+// Supplied by compiler, which forwards to the the "/usr/include" version.
+@__experimental_modules_import cstd.stdint;
+
+my_awesome_nonstandard_integer_type value;
+
+// Supplied by the compiler; that version wins.
+@__experimental_modules_import cstd.stdbool;
+
+#ifndef bool
+# error "bool was not defined!"
+#endif
+
+
+
diff --git a/clang/test/Modules/cycles.c b/clang/test/Modules/cycles.c
new file mode 100644
index 0000000..256f118
--- /dev/null
+++ b/clang/test/Modules/cycles.c
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -F %S/Inputs %s 2>&1 | FileCheck %s
+// FIXME: When we have a syntax for modules in C, use that.
+@__experimental_modules_import MutuallyRecursive1;
+
+// FIXME: Lots of redundant diagnostics here, because the preprocessor
+// can't currently tell the parser not to try to load the module again.
+
+// CHECK: MutuallyRecursive2.h:3:32: fatal error: cyclic dependency in module 'MutuallyRecursive1': MutuallyRecursive1 -> MutuallyRecursive2 -> MutuallyRecursive1
+// CHECK: MutuallyRecursive1.h:2:32: fatal error: could not build module 'MutuallyRecursive2'
+// CHECK: cycles.c:4:32: fatal error: could not build module 'MutuallyRecursive1'
+
diff --git a/clang/test/Modules/decldef.mm b/clang/test/Modules/decldef.mm
new file mode 100644
index 0000000..64a66d5
--- /dev/null
+++ b/clang/test/Modules/decldef.mm
@@ -0,0 +1,28 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -I %S/Inputs -fmodule-cache-path %t %s -verify
+
+
+// in other file: expected-note{{previous definition is here}}
+
+
+
+
+
+// in other file: expected-note{{previous definition is here}}
+
+@__experimental_modules_import decldef;
+A *a1; // expected-error{{unknown type name 'A'}}
+B *b1; // expected-error{{unknown type name 'B'}}
+@__experimental_modules_import decldef.Decl;
+
+A *a2;
+B *b;
+
+void testA(A *a) {
+ a->ivar = 17; // expected-error{{definition of 'A' must be imported before it is required}}
+}
+
+void testB() {
+ B b; // expected-error{{definition of 'B' must be imported before it is required}}
+ B b2; // Note: the reundant error was silenced.
+}
diff --git a/clang/test/Modules/diamond-pch.c b/clang/test/Modules/diamond-pch.c
new file mode 100644
index 0000000..4397c19
--- /dev/null
+++ b/clang/test/Modules/diamond-pch.c
@@ -0,0 +1,28 @@
+
+
+
+// in diamond-bottom.h: expected-note{{passing argument to parameter 'x' here}}
+
+void test_diamond(int i, float f, double d, char c) {
+ top(&i);
+ left(&f);
+ right(&d);
+ bottom(&c);
+ bottom(&d); // expected-warning{{incompatible pointer types passing 'double *' to parameter of type 'char *'}}
+
+ // Names in multiple places in the diamond.
+ top_left(&c);
+
+ left_and_right(&i);
+ struct left_and_right lr;
+ lr.left = 17;
+}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_top %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_bottom %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-pch -fmodule-cache-path %t -o %t.pch %S/Inputs/diamond.h
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -include-pch %t.pch %s -verify
+// FIXME: When we have a syntax for modules in C, use that.
diff --git a/clang/test/Modules/diamond.c b/clang/test/Modules/diamond.c
new file mode 100644
index 0000000..076eec4
--- /dev/null
+++ b/clang/test/Modules/diamond.c
@@ -0,0 +1,29 @@
+
+
+
+// in diamond-bottom.h: expected-note{{passing argument to parameter 'x' here}}
+
+@__experimental_modules_import diamond_bottom;
+
+void test_diamond(int i, float f, double d, char c) {
+ top(&i);
+ left(&f);
+ right(&d);
+ bottom(&c);
+ bottom(&d); // expected-warning{{incompatible pointer types passing 'double *' to parameter of type 'char *'}}
+
+ // Names in multiple places in the diamond.
+ top_left(&c);
+
+ left_and_right(&i);
+ struct left_and_right lr;
+ lr.left = 17;
+}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_top %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_bottom %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t %s -verify
+// FIXME: When we have a syntax for modules in C, use that.
diff --git a/clang/test/Modules/driver.c b/clang/test/Modules/driver.c
new file mode 100644
index 0000000..de10cd0
--- /dev/null
+++ b/clang/test/Modules/driver.c
@@ -0,0 +1,6 @@
+// RUN: %clang %s -### 2>&1 | FileCheck -check-prefix NO_MODULE_CACHE %s
+// RUN: %clang -fmodule-cache-path blarg %s -### 2>&1 | FileCheck -check-prefix WITH_MODULE_CACHE %s
+
+// CHECK-NO_MODULE_CACHE: {{clang.*"-fmodule-cache-path"}}
+
+// CHECK-WITH_MODULE_CACHE: {{clang.*"-fmodule-cache-path" "blarg"}}
diff --git a/clang/test/Modules/header-import.m b/clang/test/Modules/header-import.m
new file mode 100644
index 0000000..5444854
--- /dev/null
+++ b/clang/test/Modules/header-import.m
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
+
+#import "point.h"
+@__experimental_modules_import Module;
+#import "point.h"
+
diff --git a/clang/test/Modules/inferred-submodules.m b/clang/test/Modules/inferred-submodules.m
new file mode 100644
index 0000000..bee1cec
--- /dev/null
+++ b/clang/test/Modules/inferred-submodules.m
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs %s -verify
+
+@__experimental_modules_import Module.Sub;
+
+void test_Module_Sub() {
+ int *ip = Module_Sub;
+}
+
+@__experimental_modules_import Module.Buried.Treasure;
+
+void dig() {
+ unsigned *up = Buried_Treasure;
+}
+
diff --git a/clang/test/Modules/irgen.c b/clang/test/Modules/irgen.c
new file mode 100644
index 0000000..4a080db
--- /dev/null
+++ b/clang/test/Modules/irgen.c
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=irgen -triple x86_64-apple-darwin10 %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// FIXME: When we have a syntax for modules in C, use that.
+
+@__experimental_modules_import irgen;
+
+// CHECK: define void @triple_value
+void triple_value(int *px) {
+ *px = triple(*px);
+}
+
+// CHECK: define internal i32 @triple(i32
diff --git a/clang/test/Modules/load_failure.c b/clang/test/Modules/load_failure.c
new file mode 100644
index 0000000..3a96301
--- /dev/null
+++ b/clang/test/Modules/load_failure.c
@@ -0,0 +1,21 @@
+#ifdef NONEXISTENT
+@__experimental_modules_import load_nonexistent;
+#endif
+
+#ifdef FAILURE
+@__experimental_modules_import load_failure;
+#endif
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -fdisable-module-hash -emit-module -fmodule-name=load_failure %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -fdisable-module-hash %s -DNONEXISTENT 2>&1 | FileCheck -check-prefix=CHECK-NONEXISTENT %s
+// CHECK-NONEXISTENT: load_failure.c:2:32: fatal error: module 'load_nonexistent' not found
+
+// RUN: not %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -fdisable-module-hash %s -DFAILURE 2> %t.out
+// RUN: FileCheck -check-prefix=CHECK-FAILURE %s < %t.out
+
+// FIXME: Clean up diagnostic text below and give it a location
+// CHECK-FAILURE: error: C99 was disabled in PCH file but is currently enabled
+// FIXME: When we have a syntax for modules in C, use that.
+
+
diff --git a/clang/test/Modules/lookup.cpp b/clang/test/Modules/lookup.cpp
new file mode 100644
index 0000000..9839035
--- /dev/null
+++ b/clang/test/Modules/lookup.cpp
@@ -0,0 +1,34 @@
+
+#define import @__experimental_modules_import
+import lookup_left_cxx;
+#undef import
+#define IMPORT(X) @__experimental_modules_import X
+IMPORT(lookup_right_cxx);
+
+void test(int i, float f) {
+ // unqualified lookup
+ f0(&i);
+ f0(&f);
+
+ // qualified lookup into the translation unit
+ ::f0(&i);
+ ::f0(&f);
+}
+
+int import;
+
+void f() {
+ int import;
+}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -emit-module -fmodule-cache-path %t -fmodule-name=lookup_left_cxx %S/Inputs/module.map -verify
+// RUN: %clang_cc1 -fmodules -x objective-c++ -emit-module -fmodule-cache-path %t -fmodule-name=lookup_right_cxx %S/Inputs/module.map -verify
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t %s -verify
+// RUN: %clang_cc1 -fmodules -ast-print -x objective-c++ -fmodule-cache-path %t %s | FileCheck -check-prefix=CHECK-PRINT %s
+// FIXME: When we have a syntax for modules in C++, use that.
+
+// CHECK-PRINT: int *f0(int *);
+// CHECK-PRINT: float *f0(float *);
+// CHECK-PRINT: void test(int i, float f)
+
diff --git a/clang/test/Modules/lookup.m b/clang/test/Modules/lookup.m
new file mode 100644
index 0000000..c82503f
--- /dev/null
+++ b/clang/test/Modules/lookup.m
@@ -0,0 +1,20 @@
+
+// lookup_left.h: expected-note{{using}}
+// lookup_right.h: expected-note{{also found}}
+@__experimental_modules_import lookup_left_objc;
+@__experimental_modules_import lookup_right_objc;
+
+void test(id x) {
+ [x method]; // expected-warning{{multiple methods named 'method' found}}
+}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -emit-module -x objective-c -fmodule-name=lookup_left_objc %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -emit-module -x objective-c -fmodule-name=lookup_right_objc %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -verify %s
+// RUN: %clang_cc1 -fmodules -ast-print -x objective-c -fmodule-cache-path %t %s | FileCheck -check-prefix=CHECK-PRINT %s
+
+// CHECK-PRINT: - (int) method;
+// CHECK-PRINT: - (double) method
+// CHECK-PRINT: void test(id x)
+
diff --git a/clang/test/Modules/macros.c b/clang/test/Modules/macros.c
new file mode 100644
index 0000000..83e1c66
--- /dev/null
+++ b/clang/test/Modules/macros.c
@@ -0,0 +1,30 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=macros %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodule-cache-path %t %s
+// RUN: %clang_cc1 -E -fmodules -x objective-c -fmodule-cache-path %t %s | FileCheck -check-prefix CHECK-PREPROCESSED %s
+// FIXME: When we have a syntax for modules in C, use that.
+
+@__experimental_modules_import macros;
+
+#ifndef INTEGER
+# error INTEGER macro should be visible
+#endif
+
+#ifdef FLOAT
+# error FLOAT macro should not be visible
+#endif
+
+#ifdef MODULE
+# error MODULE macro should not be visible
+#endif
+
+// CHECK-PREPROCESSED: double d
+double d;
+DOUBLE *dp = &d;
+
+#__public_macro WIBBLE // expected-error{{no macro named 'WIBBLE'}}
+
+void f() {
+ // CHECK-PREPROCESSED: int i = INTEGER;
+ int i = INTEGER; // the value was exported, the macro was not.
+}
diff --git a/clang/test/Modules/method_pool.m b/clang/test/Modules/method_pool.m
new file mode 100644
index 0000000..25582ca
--- /dev/null
+++ b/clang/test/Modules/method_pool.m
@@ -0,0 +1,30 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodule-cache-path %t -fmodules -I %S/Inputs %s -verify
+
+@__experimental_modules_import MethodPoolA;
+
+
+// in other file: // expected-note{{using}}
+
+
+
+
+// in other file: expected-note{{also found}}
+
+void testMethod1(id object) {
+ [object method1];
+}
+
+void testMethod2(id object) {
+ [object method2:1];
+}
+
+@__experimental_modules_import MethodPoolB;
+
+void testMethod1Again(id object) {
+ [object method1];
+}
+
+void testMethod2Again(id object) {
+ [object method2:1]; // expected-warning{{multiple methods named 'method2:' found}}
+}
diff --git a/clang/test/Modules/module-private.cpp b/clang/test/Modules/module-private.cpp
new file mode 100644
index 0000000..246dcaf
--- /dev/null
+++ b/clang/test/Modules/module-private.cpp
@@ -0,0 +1,96 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -fmodule-name=module_private_left -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -fmodule-name=module_private_right -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
+
+@__experimental_modules_import module_private_left;
+@__experimental_modules_import module_private_right;
+
+void test() {
+ int &ir = f0(1.0); // okay: f0() from 'right' is not visible
+}
+
+int test_broken() {
+ HiddenStruct hidden; // expected-error{{use of undeclared identifier 'HiddenStruct'}}
+
+ Integer i; // expected-error{{use of undeclared identifier 'Integer'}}
+
+ int *ip = 0;
+ f1(ip); // expected-error{{use of undeclared identifier 'f1'}}
+
+ vector<int> vec; // expected-error{{use of undeclared identifier 'vector'}} \
+ // expected-error{{expected '(' for function-style cast or type construction}} \
+ // expected-error{{use of undeclared identifier 'vec'}}
+
+ VisibleStruct vs;
+ vs.field = 0; // expected-error{{no member named 'field' in 'VisibleStruct'}}
+ vs.setField(1); // expected-error{{no member named 'setField' in 'VisibleStruct'}}
+
+ return hidden_var; // expected-error{{use of undeclared identifier 'hidden_var'}}
+}
+
+// Check for private redeclarations of public entities.
+template<typename T>
+class public_class_template;
+
+template<typename T>
+__module_private__ class public_class_template;
+
+
+typedef int public_typedef;
+typedef __module_private__ int public_typedef;
+
+extern int public_var;
+extern __module_private__ int public_var;
+
+void public_func();
+__module_private__ void public_func();
+
+template<typename T>
+void public_func_template();
+template<typename T>
+__module_private__ void public_func_template();
+
+struct public_struct;
+__module_private__ struct public_struct;
+
+// Check for attempts to make specializations private
+template<> __module_private__ void public_func_template<int>(); // expected-error{{template specialization cannot be declared __module_private__}}
+
+template<typename T>
+struct public_class {
+ struct inner_struct;
+ static int static_var;
+
+ friend __module_private__ void public_func_friend();
+ friend __module_private__ struct public_struct_friend;
+};
+
+template<> __module_private__ struct public_class<int>::inner_struct { }; // expected-error{{member specialization cannot be declared __module_private__}}
+template<> __module_private__ int public_class<int>::static_var = 17; // expected-error{{member specialization cannot be declared __module_private__}}
+
+template<>
+__module_private__ struct public_class<float> { }; // expected-error{{template specialization cannot be declared __module_private__}}
+
+template<typename T>
+__module_private__ struct public_class<T *> { }; // expected-error{{partial specialization cannot be declared __module_private__}}
+
+// Check for attempts to make parameters and variables with automatic
+// storage module-private.
+
+void local_var_private(__module_private__ int param) { // expected-error{{parameter 'param' cannot be declared __module_private__}}
+ __module_private__ struct Local { int x, y; } local; //expected-error{{local variable 'local' cannot be declared __module_private__}}
+
+ __module_private__ struct OtherLocal { int x; }; // expected-error{{local struct cannot be declared __module_private__}}
+
+ typedef __module_private__ int local_typedef; // expected-error{{typedef 'local_typedef' cannot be declared __module_private__}}
+}
+
+// Check struct size
+struct LikeVisibleStruct {
+ int field;
+ virtual void setField(int f);
+};
+
+int check_struct_size[sizeof(VisibleStruct) == sizeof(LikeVisibleStruct)? 1 : -1];
diff --git a/clang/test/Modules/namespaces.cpp b/clang/test/Modules/namespaces.cpp
new file mode 100644
index 0000000..19e0c5a
--- /dev/null
+++ b/clang/test/Modules/namespaces.cpp
@@ -0,0 +1,64 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify
+
+// Importing modules which add declarations to a pre-existing non-imported
+// overload set does not currently work.
+// XFAIL: *
+
+namespace N6 {
+ char &f(char);
+}
+
+namespace N8 { }
+
+@__experimental_modules_import namespaces_left;
+@__experimental_modules_import namespaces_right;
+
+void test() {
+ int &ir1 = N1::f(1);
+ int &ir2 = N2::f(1);
+ int &ir3 = N3::f(1);
+ float &fr1 = N1::f(1.0f);
+ float &fr2 = N2::f(1.0f);
+ double &dr1 = N2::f(1.0);
+ double &dr2 = N3::f(1.0);
+}
+
+// Test namespaces merged without a common first declaration.
+namespace N5 {
+ char &f(char);
+}
+
+namespace N10 {
+ int &f(int);
+}
+
+void testMerged() {
+ int &ir1 = N5::f(17);
+ int &ir2 = N6::f(17);
+ int &ir3 = N7::f(17);
+ double &fr1 = N5::f(1.0);
+ double &fr2 = N6::f(1.0);
+ double &fr3 = N7::f(1.0);
+ char &cr1 = N5::f('a');
+ char &cr2 = N6::f('b');
+}
+
+// Test merging of declarations within namespaces that themselves were
+// merged without a common first declaration.
+void testMergedMerged() {
+ int &ir1 = N8::f(17);
+ int &ir2 = N9::f(17);
+ int &ir3 = N10::f(17);
+}
+
+// Test merging when using anonymous namespaces, which does not
+// actually perform any merging.
+// other file: expected-note{{passing argument to parameter here}}
+void testAnonymousNotMerged() {
+ N11::consumeFoo(N11::getFoo()); // expected-error{{cannot initialize a parameter of type 'N11::<anonymous>::Foo *' with an rvalue of type 'N11::<anonymous>::Foo *'}}
+ N12::consumeFoo(N12::getFoo()); // expected-error{{cannot initialize a parameter of type 'N12::<anonymous>::Foo *' with an rvalue of type 'N12::<anonymous>::Foo *'}}
+}
+
+
+// other file: expected-note{{passing argument to parameter here}}
diff --git a/clang/test/Modules/normal-module-map.cpp b/clang/test/Modules/normal-module-map.cpp
new file mode 100644
index 0000000..7cd4482
--- /dev/null
+++ b/clang/test/Modules/normal-module-map.cpp
@@ -0,0 +1,35 @@
+// Note: inside the module. expected-note{{'nested_umbrella_a' declared here}}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c -fmodule-cache-path %t -fmodules -I %S/Inputs/normal-module-map %s -verify
+#include "Umbrella/umbrella_sub.h"
+
+int getUmbrella() {
+ return umbrella + umbrella_sub;
+}
+
+@__experimental_modules_import Umbrella2;
+
+#include "a1.h"
+#include "b1.h"
+#include "nested/nested2.h"
+
+int test() {
+ return a1 + b1 + nested2;
+}
+
+@__experimental_modules_import nested_umbrella.a;
+
+int testNestedUmbrellaA() {
+ return nested_umbrella_a;
+}
+
+int testNestedUmbrellaBFail() {
+ return nested_umbrella_b; // expected-error{{use of undeclared identifier 'nested_umbrella_b'; did you mean 'nested_umbrella_a'?}}
+}
+
+@__experimental_modules_import nested_umbrella.b;
+
+int testNestedUmbrellaB() {
+ return nested_umbrella_b;
+}
diff --git a/clang/test/Modules/objc-categories.m b/clang/test/Modules/objc-categories.m
new file mode 100644
index 0000000..340f279
--- /dev/null
+++ b/clang/test/Modules/objc-categories.m
@@ -0,0 +1,40 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_top -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_left -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_right -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_bottom -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_other -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t %s -verify
+
+@__experimental_modules_import category_bottom;
+
+
+
+
+// in category_left.h: expected-note {{previous definition}}
+
+@interface Foo(Source)
+-(void)source;
+@end
+
+void test(Foo *foo, LeftFoo *leftFoo) {
+ [foo source];
+ [foo bottom];
+ [foo left];
+ [foo right1];
+ [foo right2];
+ [foo top];
+ [foo top2];
+ [foo top3];
+
+ [leftFoo left];
+ [leftFoo bottom];
+}
+
+// Load another module that also adds categories to Foo, verify that
+// we see those categories.
+@__experimental_modules_import category_other;
+
+void test_other(Foo *foo) {
+ [foo other];
+}
diff --git a/clang/test/Modules/on-demand-build-warnings.m b/clang/test/Modules/on-demand-build-warnings.m
new file mode 100644
index 0000000..24975c0
--- /dev/null
+++ b/clang/test/Modules/on-demand-build-warnings.m
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Wmodule-build -fmodule-cache-path %t -F %S/Inputs -verify %s
+
+@__experimental_modules_import Module; // expected-warning{{building module 'Module' from source}}
+
diff --git a/clang/test/Modules/on-demand-build.m b/clang/test/Modules/on-demand-build.m
new file mode 100644
index 0000000..cf1ae99
--- /dev/null
+++ b/clang/test/Modules/on-demand-build.m
@@ -0,0 +1,27 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Werror -Wno-error=incomplete-umbrella -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Werror -Wno-error=incomplete-umbrella -x objective-c++ -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Werror -Wno-error=incomplete-umbrella -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
+#define FOO
+@__experimental_modules_import Module;
+@interface OtherClass
+@end
+
+
+
+
+// in module: expected-note{{class method 'alloc' is assumed to return an instance of its receiver type ('Module *')}}
+void test_getModuleVersion() {
+ const char *version = getModuleVersion();
+ const char *version2 = [Module version];
+
+ OtherClass *other = [Module alloc]; // expected-error{{init}}
+}
+
+#ifdef MODULE_SUBFRAMEWORK_H
+# error MODULE_SUBFRAMEWORK_H should be hidden
+#endif
+
+@__experimental_modules_import subdir;
+
+const char *getSubdirTest() { return getSubdir(); }
diff --git a/clang/test/Modules/on-demand-macros.m b/clang/test/Modules/on-demand-macros.m
new file mode 100644
index 0000000..2b8c545
--- /dev/null
+++ b/clang/test/Modules/on-demand-macros.m
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -F %S/Inputs -DFOO_RETURNS_INT_PTR -verify %s
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -F %S/Inputs -verify %s
+
+@__experimental_modules_import CmdLine;
+
+void test() {
+#ifdef FOO_RETURNS_INT_PTR
+ int *ip = foo();
+#else
+ float *fp = foo();
+#endif
+}
diff --git a/clang/test/Modules/redecl-merge.m b/clang/test/Modules/redecl-merge.m
new file mode 100644
index 0000000..d7930ac
--- /dev/null
+++ b/clang/test/Modules/redecl-merge.m
@@ -0,0 +1,158 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify -Wno-objc-root-class
+// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify -Wno-objc-root-class
+@class C2;
+@class C3;
+@class C3;
+@__experimental_modules_import redecl_merge_left;
+typedef struct my_struct_type *my_struct_ref;
+@protocol P4;
+@class C3;
+@class C3;
+@__experimental_modules_import redecl_merge_right;
+
+@implementation A
+- (Super*)init { return self; }
+@end
+
+void f(A *a) {
+ [a init];
+}
+
+@class A;
+
+B *f1() {
+ return [B create_a_B];
+}
+
+@class B;
+
+void testProtoMerge(id<P1> p1, id<P2> p2) {
+ [p1 protoMethod1];
+ [p2 protoMethod2];
+}
+
+struct S1 {
+ int s1_field;
+};
+
+struct S3 {
+ int s3_field;
+};
+
+void testTagMerge() {
+ consume_S1(produce_S1());
+ struct S2 s2;
+ s2.field = 0;
+ consume_S2(produce_S2());
+ struct S1 s1;
+ s1.s1_field = 0;
+ consume_S3(produce_S3());
+ struct S4 s4;
+ s4.field = 0;
+ consume_S4(produce_S4());
+ struct S3 s3;
+ s3.s3_field = 0;
+}
+
+void testTypedefMerge(int i, double d) {
+ T1 *ip = &i;
+ // in other file: expected-note{{candidate found by name lookup is 'T2'}}
+ // FIXME: Typedefs aren't actually merged in the sense of other merges, because
+ // we should only merge them when the types are identical.
+ // in other file: expected-note{{candidate found by name lookup is 'T2'}}
+ // in other file: expected-note{{candidate function}}
+ T2 *dp = &d; // expected-error{{reference to 'T2' is ambiguous}}
+}
+
+void testFuncMerge(int i) {
+ func0(i);
+ // in other file: expected-note{{candidate function}}
+ func1(i);
+ func2(i); // expected-error{{call to 'func2' is ambiguous}}
+}
+
+void testVarMerge(int i) {
+ var1 = i;
+ // in other files: expected-note 2{{candidate found by name lookup is 'var2'}}
+ var2 = i; // expected-error{{reference to 'var2' is ambiguous}}
+ // in other files: expected-note 2{{candidate found by name lookup is 'var3'}}
+ var3 = i; // expected-error{{reference to 'var3' is ambiguous}}
+}
+
+// Test redeclarations of entities in explicit submodules, to make
+// sure we're maintaining the declaration chains even when normal name
+// lookup can't see what we're looking for.
+void testExplicit() {
+ Explicit *e;
+ int *(*fp)(void) = &explicit_func;
+ int *ip = explicit_func();
+
+ // FIXME: Should complain about definition not having been imported.
+ struct explicit_struct es = { 0 };
+}
+
+// Test resolution of declarations from multiple modules with no
+// common original declaration.
+void test_C(C *c) {
+ c = get_a_C();
+ accept_a_C(c);
+}
+
+void test_C2(C2 *c2) {
+ c2 = get_a_C2();
+ accept_a_C2(c2);
+}
+
+void test_C3(C3 *c3) {
+ c3 = get_a_C3();
+ accept_a_C3(c3);
+}
+
+C4 *global_C4;
+
+ClassWithDef *cwd1;
+
+@__experimental_modules_import redecl_merge_left_left;
+
+void test_C4a(C4 *c4) {
+ global_C4 = c4 = get_a_C4();
+ accept_a_C4(c4);
+}
+
+void test_ClassWithDef(ClassWithDef *cwd) {
+ [cwd method];
+}
+
+@__experimental_modules_import redecl_merge_bottom;
+
+void test_C4b() {
+ if (&refers_to_C4) {
+ }
+}
+
+@implementation B
++ (B*)create_a_B { return 0; }
+@end
+
+void g(A *a) {
+ [a init];
+}
+
+@protocol P3
+- (void)p3_method;
+@end
+
+id<P4> p4;
+id<P3> p3;
+
+#ifdef __cplusplus
+void testVector() {
+ Vector<int> vec_int;
+ vec_int.push_back(0);
+}
+#endif
+
+// Make sure we don't get conflicts with 'id'.
+funcptr_with_id fid;
+id id_global;
diff --git a/clang/test/Modules/redecl-namespaces.mm b/clang/test/Modules/redecl-namespaces.mm
new file mode 100644
index 0000000..e338821
--- /dev/null
+++ b/clang/test/Modules/redecl-namespaces.mm
@@ -0,0 +1,13 @@
+@__experimental_modules_import redecl_namespaces_left;
+@__experimental_modules_import redecl_namespaces_right;
+
+void test() {
+ A::i;
+ A::j;
+ A::k; // expected-error {{no member named 'k' in namespace 'A'}}
+}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -emit-module -fmodule-name=redecl_namespaces_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -emit-module -fmodule-name=redecl_namespaces_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -w %s -verify
diff --git a/clang/test/Modules/redeclarations.m b/clang/test/Modules/redeclarations.m
new file mode 100644
index 0000000..3f3e695
--- /dev/null
+++ b/clang/test/Modules/redeclarations.m
@@ -0,0 +1,11 @@
+@__experimental_modules_import redeclarations_left;
+@__experimental_modules_import redeclarations_right;
+
+@interface MyObject : NSObject
+@end
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=redeclarations_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=redeclarations_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t %s -verify
+
diff --git a/clang/test/Modules/requires.m b/clang/test/Modules/requires.m
new file mode 100644
index 0000000..ce2537c
--- /dev/null
+++ b/clang/test/Modules/requires.m
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs %s -verify
+
+@__experimental_modules_import DependsOnModule.CXX; // expected-error{{module 'DependsOnModule.CXX' requires feature 'cplusplus'}}
+
diff --git a/clang/test/Modules/subframeworks.m b/clang/test/Modules/subframeworks.m
new file mode 100644
index 0000000..09298c4
--- /dev/null
+++ b/clang/test/Modules/subframeworks.m
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs -F %S/Inputs/DependsOnModule.framework/Frameworks %s -verify
+// RUN: %clang_cc1 -x objective-c++ -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs -F %S/Inputs/DependsOnModule.framework/Frameworks %s -verify
+
+@__experimental_modules_import DependsOnModule;
+
+void testSubFramework() {
+ float *sf1 = sub_framework; // expected-error{{use of undeclared identifier 'sub_framework'}}
+}
+
+@__experimental_modules_import DependsOnModule.SubFramework;
+
+void testSubFrameworkAgain() {
+ float *sf2 = sub_framework;
+ double *sfo1 = sub_framework_other;
+}
+
+#ifdef __cplusplus
+@__experimental_modules_import DependsOnModule.CXX;
+
+CXXOnly cxxonly;
+#endif
diff --git a/clang/test/Modules/submodules-preprocess.cpp b/clang/test/Modules/submodules-preprocess.cpp
new file mode 100644
index 0000000..8d6c2cd
--- /dev/null
+++ b/clang/test/Modules/submodules-preprocess.cpp
@@ -0,0 +1,61 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -Eonly -fmodule-cache-path %t -I %S/Inputs/submodules %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
+
+@__experimental_modules_import std.vector;
+
+#ifndef HAVE_VECTOR
+# error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifdef HAVE_TYPE_TRAITS
+# error HAVE_TYPE_TRAITS_MAP macro is available (but shouldn't be)
+#endif
+
+#ifdef HAVE_HASH_MAP
+# error HAVE_HASH_MAP macro is available (but shouldn't be)
+#endif
+
+@__experimental_modules_import std.typetraits; // expected-error{{no submodule named 'typetraits' in module 'std'; did you mean 'type_traits'?}}
+
+#ifndef HAVE_VECTOR
+# error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifndef HAVE_TYPE_TRAITS
+# error HAVE_TYPE_TRAITS_MAP macro is not available (but should be)
+#endif
+
+#ifdef HAVE_HASH_MAP
+# error HAVE_HASH_MAP macro is available (but shouldn't be)
+#endif
+
+@__experimental_modules_import std.vector.compare; // expected-error{{no submodule named 'compare' in module 'std.vector'}}
+
+@__experimental_modules_import std; // import everything in 'std'
+
+#ifndef HAVE_VECTOR
+# error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifndef HAVE_TYPE_TRAITS
+# error HAVE_TYPE_TRAITS_MAP macro is not available (but should be)
+#endif
+
+#ifdef HAVE_HASH_MAP
+# error HAVE_HASH_MAP macro is available (but shouldn't be)
+#endif
+
+@__experimental_modules_import std.hash_map;
+
+#ifndef HAVE_VECTOR
+# error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifndef HAVE_TYPE_TRAITS
+# error HAVE_TYPE_TRAITS_MAP macro is not available (but should be)
+#endif
+
+#ifndef HAVE_HASH_MAP
+# error HAVE_HASH_MAP macro is not available (but should be)
+#endif
diff --git a/clang/test/Modules/submodules.cpp b/clang/test/Modules/submodules.cpp
new file mode 100644
index 0000000..60d5ae0
--- /dev/null
+++ b/clang/test/Modules/submodules.cpp
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c++ -fmodule-cache-path %t -fmodules -I %S/Inputs/submodules %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
+
+@__experimental_modules_import std.vector;
+
+vector<int> vi;
+
+// Note: remove_reference is not visible yet.
+remove_reference<int&>::type *int_ptr = 0; // expected-error{{unknown type name 'remove_reference'}} \
+// expected-error{{expected unqualified-id}}
+
+@__experimental_modules_import std.typetraits; // expected-error{{no submodule named 'typetraits' in module 'std'; did you mean 'type_traits'?}}
+
+vector<float> vf;
+remove_reference<int&>::type *int_ptr2 = 0;
+
+@__experimental_modules_import std.vector.compare; // expected-error{{no submodule named 'compare' in module 'std.vector'}}
+
+@__experimental_modules_import std; // import everything in 'std'
+
+// hash_map still isn't available.
+hash_map<int, float> ints_to_floats; // expected-error{{unknown type name 'hash_map'}} \
+// expected-error{{expected unqualified-id}}
+
+@__experimental_modules_import std.hash_map;
+
+hash_map<int, float> ints_to_floats2;
+
diff --git a/clang/test/Modules/submodules.m b/clang/test/Modules/submodules.m
new file mode 100644
index 0000000..e014bea
--- /dev/null
+++ b/clang/test/Modules/submodules.m
@@ -0,0 +1,11 @@
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs %s -verify
+
+// Note: transitively imports Module.Sub2.
+@__experimental_modules_import Module.Sub;
+
+int getValue() {
+ return *Module_Sub + *Module_Sub2;
+}
+
diff --git a/clang/test/Modules/wildcard-submodule-exports.cpp b/clang/test/Modules/wildcard-submodule-exports.cpp
new file mode 100644
index 0000000..6b4f02c
--- /dev/null
+++ b/clang/test/Modules/wildcard-submodule-exports.cpp
@@ -0,0 +1,26 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c++ -fmodule-cache-path %t -fmodules -I %S/Inputs/wildcard-submodule-exports %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
+
+@__experimental_modules_import C.One;
+
+void test_C_One() {
+ int *A1_ptr = A1;
+ long *C1_ptr = C1;
+ (void)B1; // expected-error{{use of undeclared identifier 'B1'}}
+}
+
+@__experimental_modules_import C.Two;
+
+void test_C_Two() {
+ unsigned int *A2_ptr = A2;
+ unsigned short *B2_ptr = B2;
+ unsigned long *C2_ptr = C2;
+}
+
+@__experimental_modules_import B.One;
+
+void test_B_One() {
+ short *B1_ptr = B1;
+}
+
diff --git a/clang/test/PCH/Inputs/arc.h b/clang/test/PCH/Inputs/arc.h
new file mode 100644
index 0000000..304e612
--- /dev/null
+++ b/clang/test/PCH/Inputs/arc.h
@@ -0,0 +1,26 @@
+// Header for Objective-C ARC-related PCH tests
+
+typedef const void *CFTypeRef;
+typedef const struct __CFString *CFStringRef;
+
+CFTypeRef CFCreateSomething();
+CFStringRef CFCreateString();
+CFTypeRef CFGetSomething();
+CFStringRef CFGetString();
+
+@interface NSString
+@end
+
+id CreateSomething();
+NSString *CreateNSString();
+
+#if __has_feature(objc_arc)
+#define BRIDGE __bridge
+#else
+#define BRIDGE
+#endif
+
+typedef int array0[sizeof((BRIDGE id)CFCreateSomething())];
+typedef int array1[sizeof((BRIDGE CFTypeRef)CreateSomething())];
+
+
diff --git a/clang/test/PCH/Inputs/chain-decls1.h b/clang/test/PCH/Inputs/chain-decls1.h
new file mode 100644
index 0000000..9de4461
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-decls1.h
@@ -0,0 +1,11 @@
+void f();
+
+struct one {};
+void two();
+
+void many(int i);
+struct many;
+void many(int j);
+struct many;
+
+void noret();
diff --git a/clang/test/PCH/Inputs/chain-decls2.h b/clang/test/PCH/Inputs/chain-decls2.h
new file mode 100644
index 0000000..b8b7d04
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-decls2.h
@@ -0,0 +1,12 @@
+void g();
+
+struct two {};
+void one();
+struct three {}; // for verification
+
+void many(int k);
+struct many;
+void many(int l);
+struct many {};
+
+void noret() __attribute__((noreturn));
diff --git a/clang/test/PCH/Inputs/chain-ext_vector1.h b/clang/test/PCH/Inputs/chain-ext_vector1.h
new file mode 100644
index 0000000..5109336
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-ext_vector1.h
@@ -0,0 +1,3 @@
+// First header file for chain-ext_vector.c PCH test
+
+typedef __attribute__((ext_vector_type(2))) float float2;
diff --git a/clang/test/PCH/Inputs/chain-ext_vector2.h b/clang/test/PCH/Inputs/chain-ext_vector2.h
new file mode 100644
index 0000000..bdaeccc
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-ext_vector2.h
@@ -0,0 +1,3 @@
+// Second header file for chain-ext_vector.c PCH test
+
+typedef __attribute__((ext_vector_type(4))) float float4;
diff --git a/clang/test/PCH/Inputs/chain-external-defs1.h b/clang/test/PCH/Inputs/chain-external-defs1.h
new file mode 100644
index 0000000..36a2653
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-external-defs1.h
@@ -0,0 +1,13 @@
+// Helper 1 for chain-external-defs.c test
+
+// Tentative definitions
+int x;
+int x2;
+
+// Should not show up
+static int z;
+
+int incomplete_array[];
+int incomplete_array2[];
+
+struct S s;
diff --git a/clang/test/PCH/Inputs/chain-external-defs2.h b/clang/test/PCH/Inputs/chain-external-defs2.h
new file mode 100644
index 0000000..72af92f
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-external-defs2.h
@@ -0,0 +1,11 @@
+// Helper 2 for chain-external-defs.c test
+
+// Tentative definitions
+int y;
+int y2;
+
+// Should still not show up
+static int z;
+
+int incomplete_array[];
+int incomplete_array3[];
diff --git a/clang/test/PCH/Inputs/chain-macro-override1.h b/clang/test/PCH/Inputs/chain-macro-override1.h
new file mode 100644
index 0000000..d956396
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-macro-override1.h
@@ -0,0 +1,5 @@
+void f() __attribute__((unavailable));
+void g();
+#define g() f()
+#define h() f()
+#define x x
diff --git a/clang/test/PCH/Inputs/chain-macro-override2.h b/clang/test/PCH/Inputs/chain-macro-override2.h
new file mode 100644
index 0000000..e4bff77
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-macro-override2.h
@@ -0,0 +1,5 @@
+#define f() g()
+#undef g
+#undef h
+#define h() g()
+int x;
diff --git a/clang/test/PCH/Inputs/chain-macro1.h b/clang/test/PCH/Inputs/chain-macro1.h
new file mode 100644
index 0000000..2e80e47
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-macro1.h
@@ -0,0 +1 @@
+#define FOOBAR void f();
diff --git a/clang/test/PCH/Inputs/chain-macro2.h b/clang/test/PCH/Inputs/chain-macro2.h
new file mode 100644
index 0000000..e888228
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-macro2.h
@@ -0,0 +1 @@
+#define BARFOO void g();
diff --git a/clang/test/PCH/Inputs/chain-remap-types1.h b/clang/test/PCH/Inputs/chain-remap-types1.h
new file mode 100644
index 0000000..d105489
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-remap-types1.h
@@ -0,0 +1,10 @@
+@class X;
+
+struct Y {
+ X *my_X;
+};
+
+@interface X {
+}
+@property X *prop;
+@end
diff --git a/clang/test/PCH/Inputs/chain-remap-types2.h b/clang/test/PCH/Inputs/chain-remap-types2.h
new file mode 100644
index 0000000..55ca8a9
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-remap-types2.h
@@ -0,0 +1,8 @@
+void h(X*);
+
+@interface X (Blah) {
+}
+@end
+
+void g(X*);
+
diff --git a/clang/test/PCH/Inputs/chain-selectors1.h b/clang/test/PCH/Inputs/chain-selectors1.h
new file mode 100644
index 0000000..b0b68f8
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-selectors1.h
@@ -0,0 +1,16 @@
+@interface X
+ -(void)f;
+ -(void)f2;
+ -(void)g:(int)p;
+ -(void)h:(int)p1 foo:(int)p2;
+@end
+
+void foo1() {
+ // FIXME: Can't verify warnings in headers
+ //(void)@selector(x);
+ (void)@selector(f);
+}
+
+@interface X (Blah)
+- (void)blah_method;
+@end
diff --git a/clang/test/PCH/Inputs/chain-selectors2.h b/clang/test/PCH/Inputs/chain-selectors2.h
new file mode 100644
index 0000000..973fc10
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-selectors2.h
@@ -0,0 +1,15 @@
+@interface Y
+ -(void)f;
+ -(double)f2;
+ -(void)e;
+@end
+
+void foo2() {
+ // FIXME: Can't verify warnings in headers
+ //(void)@selector(y);
+ //(void)@selector(e);
+}
+
+@interface X (Blarg)
+- (void)blarg_method;
+@end
diff --git a/clang/test/PCH/Inputs/chain-trivial1.h b/clang/test/PCH/Inputs/chain-trivial1.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-trivial1.h
diff --git a/clang/test/PCH/Inputs/chain-trivial2.h b/clang/test/PCH/Inputs/chain-trivial2.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/PCH/Inputs/chain-trivial2.h
diff --git a/clang/test/PCH/Inputs/cxx-method.h b/clang/test/PCH/Inputs/cxx-method.h
new file mode 100644
index 0000000..6adb859
--- /dev/null
+++ b/clang/test/PCH/Inputs/cxx-method.h
@@ -0,0 +1,6 @@
+struct S {
+ void m(int x);
+
+ operator const char*();
+ operator char*();
+};
diff --git a/clang/test/PCH/Inputs/namespaces.h b/clang/test/PCH/Inputs/namespaces.h
new file mode 100644
index 0000000..bd2c3ee
--- /dev/null
+++ b/clang/test/PCH/Inputs/namespaces.h
@@ -0,0 +1,44 @@
+// Header for PCH test namespaces.cpp
+
+namespace N1 {
+ typedef int t1;
+}
+
+namespace N1 {
+ typedef int t2;
+
+ void used_func();
+
+ struct used_cls { };
+}
+
+namespace N2 {
+ typedef float t1;
+
+ namespace Inner {
+ typedef int t3;
+ };
+}
+
+namespace {
+ void anon() { }
+ class C;
+}
+
+namespace N3 {
+ namespace {
+ class C;
+ }
+}
+
+namespace Alias1 = N2::Inner;
+
+using namespace N2::Inner;
+
+extern "C" {
+ void ext();
+}
+
+inline namespace N4 {
+ struct MemberOfN4;
+}
diff --git a/clang/test/PCH/Inputs/preamble.h b/clang/test/PCH/Inputs/preamble.h
new file mode 100644
index 0000000..aee330a
--- /dev/null
+++ b/clang/test/PCH/Inputs/preamble.h
@@ -0,0 +1 @@
+int f(int);
diff --git a/clang/test/PCH/Inputs/typo.h b/clang/test/PCH/Inputs/typo.h
new file mode 100644
index 0000000..63b553b
--- /dev/null
+++ b/clang/test/PCH/Inputs/typo.h
@@ -0,0 +1,6 @@
+
+
+@interface NSString
++ (id)alloc;
+@end
+
diff --git a/clang/test/PCH/Inputs/typo.hpp b/clang/test/PCH/Inputs/typo.hpp
new file mode 100644
index 0000000..c811595
--- /dev/null
+++ b/clang/test/PCH/Inputs/typo.hpp
@@ -0,0 +1,8 @@
+namespace boost {
+ template<typename F> class function {};
+
+ namespace graph {
+ template<typename V, typename E> class adjacency_list { };
+ };
+}
+
diff --git a/clang/test/PCH/Inputs/va_arg.h b/clang/test/PCH/Inputs/va_arg.h
new file mode 100644
index 0000000..1244e9f
--- /dev/null
+++ b/clang/test/PCH/Inputs/va_arg.h
@@ -0,0 +1,2 @@
+#include <stdarg.h>
+
diff --git a/clang/test/PCH/Inputs/working-directory-1.h b/clang/test/PCH/Inputs/working-directory-1.h
new file mode 100644
index 0000000..e42eda4
--- /dev/null
+++ b/clang/test/PCH/Inputs/working-directory-1.h
@@ -0,0 +1,5 @@
+template<typename T> struct A {
+ A() {
+ int a;
+ }
+};
diff --git a/clang/test/PCH/arc.m b/clang/test/PCH/arc.m
new file mode 100644
index 0000000..64b390c
--- /dev/null
+++ b/clang/test/PCH/arc.m
@@ -0,0 +1,17 @@
+// Test this without pch.
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -fobjc-arc -include %S/Inputs/arc.h -fsyntax-only -emit-llvm-only %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -fblocks -triple x86_64-apple-darwin11 -fobjc-arc -x objective-c-header -o %t %S/Inputs/arc.h
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -fobjc-arc -include-pch %t -fsyntax-only -emit-llvm-only %s
+
+// Test error when pch's -fobjc-arc state is different.
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -include-pch %t -fsyntax-only -emit-llvm-only %s 2>&1 | FileCheck -check-prefix=ERR1 %s
+// RUN: %clang_cc1 -emit-pch -fblocks -triple x86_64-apple-darwin11 -x objective-c-header -o %t %S/Inputs/arc.h
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -fobjc-arc -include-pch %t -fsyntax-only -emit-llvm-only %s 2>&1 | FileCheck -check-prefix=ERR2 %s
+
+array0 a0;
+array1 a1;
+
+// CHECK-ERR1: Objective-C automated reference counting was enabled in PCH file but is currently disabled
+// CHECK-ERR2: Objective-C automated reference counting was disabled in PCH file but is currently enabled
diff --git a/clang/test/PCH/asm.c b/clang/test/PCH/asm.c
new file mode 100644
index 0000000..99bc14d
--- /dev/null
+++ b/clang/test/PCH/asm.c
@@ -0,0 +1,11 @@
+// Test this without pch.
+// RUN: %clang_cc1 -triple i386-unknown-unknown -include %S/asm.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-pch -o %t %S/asm.h
+// RUN: %clang_cc1 -triple i386-unknown-unknown -include-pch %t -fsyntax-only -verify %s
+
+
+void call_f(void) { f(); }
+
+void call_clobbers(void) { clobbers(); }
diff --git a/clang/test/PCH/asm.h b/clang/test/PCH/asm.h
new file mode 100644
index 0000000..a568058
--- /dev/null
+++ b/clang/test/PCH/asm.h
@@ -0,0 +1,14 @@
+// Header for the PCH test asm.c
+
+void f() {
+ int i;
+
+ asm ("foo\n" : : "a" (i + 2));
+ asm ("foo\n" : [symbolic_name] "=a" (i) : "[symbolic_name]" (i));
+}
+
+void clobbers() {
+ asm ("nop" : : : "ax", "#ax", "%ax");
+ asm ("nop" : : : "eax", "rax", "ah", "al");
+ asm ("nop" : : : "0", "%0", "#0");
+}
diff --git a/clang/test/PCH/attrs-PR8406.c b/clang/test/PCH/attrs-PR8406.c
new file mode 100644
index 0000000..85225f5
--- /dev/null
+++ b/clang/test/PCH/attrs-PR8406.c
@@ -0,0 +1,23 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -emit-llvm -o - %s | FileCheck %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -emit-llvm -o - %s | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+struct Bar
+{
+ // CHECK: align 512
+ int buffer[123] __attribute__((__aligned__(512)));
+};
+
+#else
+
+void foo() {
+ struct Bar bar;
+}
+
+#endif
diff --git a/clang/test/PCH/attrs.c b/clang/test/PCH/attrs.c
new file mode 100644
index 0000000..2f868ac
--- /dev/null
+++ b/clang/test/PCH/attrs.c
@@ -0,0 +1,17 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+#ifndef HEADER
+#define HEADER
+
+int f(int) __attribute__((visibility("default"), overloadable)); // expected-note{{previous overload}}
+
+#else
+
+double f(double); // expected-error{{overloadable}}
+
+#endif
diff --git a/clang/test/PCH/blocks.c b/clang/test/PCH/blocks.c
new file mode 100644
index 0000000..e749886
--- /dev/null
+++ b/clang/test/PCH/blocks.c
@@ -0,0 +1,12 @@
+// Test this without pch.
+// RUN: %clang_cc1 -fblocks -include %S/blocks.h -fsyntax-only -emit-llvm -o - %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -fblocks -o %t %S/blocks.h
+// RUN: %clang_cc1 -fblocks -include-pch %t -fsyntax-only -emit-llvm -o - %s
+
+int do_add(int x, int y) { return add(x, y); }
+
+int do_scaled_add(int a, int b, int s) {
+ return scaled_add(a, b, s);
+}
diff --git a/clang/test/PCH/blocks.h b/clang/test/PCH/blocks.h
new file mode 100644
index 0000000..af7bb6f
--- /dev/null
+++ b/clang/test/PCH/blocks.h
@@ -0,0 +1,14 @@
+// Header for PCH test blocks.c
+
+int call_block(int (^bl)(int x, int y), int a, int b) {
+ return bl(a, b);
+}
+
+int add(int a, int b) {
+ return call_block(^(int x, int y) { return x + y; }, a, b);
+}
+
+int scaled_add(int a, int b, int s) {
+ __block int scale = s;
+ return call_block(^(int x, int y) { return x*scale + y; }, a, b);
+}
diff --git a/clang/test/PCH/builtins.c b/clang/test/PCH/builtins.c
new file mode 100644
index 0000000..eed2224
--- /dev/null
+++ b/clang/test/PCH/builtins.c
@@ -0,0 +1,10 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/builtins.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %S/builtins.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+void hello() {
+ printf("Hello, World!");
+}
diff --git a/clang/test/PCH/builtins.h b/clang/test/PCH/builtins.h
new file mode 100644
index 0000000..56e4a53
--- /dev/null
+++ b/clang/test/PCH/builtins.h
@@ -0,0 +1,2 @@
+// Header for PCH test builtins.c
+int printf(char const *, ...);
diff --git a/clang/test/PCH/chain-categories.m b/clang/test/PCH/chain-categories.m
new file mode 100644
index 0000000..1b91c73
--- /dev/null
+++ b/clang/test/PCH/chain-categories.m
@@ -0,0 +1,51 @@
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -include %s -include %s %s
+
+// With PCH
+// RUN: %clang_cc1 -fsyntax-only -verify %s -chain-include %s -chain-include %s
+
+#ifndef HEADER1
+#define HEADER1
+//===----------------------------------------------------------------------===//
+// Primary header
+
+@interface NSObject
+- (id)init;
+- (void)finalize;
+@end
+
+//===----------------------------------------------------------------------===//
+#elif !defined(HEADER2)
+#define HEADER2
+#if !defined(HEADER1)
+#error Header inclusion order messed up
+#endif
+
+//===----------------------------------------------------------------------===//
+// Dependent header
+
+@interface MyClass : NSObject
++(void)meth;
+@end
+
+@interface NSObject(ObjExt)
+-(void)extMeth;
+@end
+
+//===----------------------------------------------------------------------===//
+#else
+//===----------------------------------------------------------------------===//
+
+@implementation MyClass
++(void)meth {}
+-(void)finalize {
+ [super finalize];
+}
+@end
+
+void test(NSObject *o) {
+ [o extMeth];
+}
+
+//===----------------------------------------------------------------------===//
+#endif
diff --git a/clang/test/PCH/chain-categories2.m b/clang/test/PCH/chain-categories2.m
new file mode 100644
index 0000000..f230bf9
--- /dev/null
+++ b/clang/test/PCH/chain-categories2.m
@@ -0,0 +1,57 @@
+// Test that infinite loop in rdar://10418538 was fixed.
+
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class -include %s -include %s %s
+
+// With PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s -chain-include %s -chain-include %s
+
+#ifndef HEADER1
+#define HEADER1
+//===----------------------------------------------------------------------===//
+// Primary header
+
+@class I;
+
+@interface I2
+@property (readonly) id prop1;
+@end
+
+//===----------------------------------------------------------------------===//
+#elif !defined(HEADER2)
+#define HEADER2
+#if !defined(HEADER1)
+#error Header inclusion order messed up
+#endif
+
+//===----------------------------------------------------------------------===//
+// Dependent header
+
+@interface I
+@end
+
+@interface I(Cat1)
+@end
+
+@interface I(Cat2)
+@end
+
+@interface I2()
+@property (readwrite,assign) id prop1;
+@property (copy) id prop2;
+@end
+
+//===----------------------------------------------------------------------===//
+#else
+//===----------------------------------------------------------------------===//
+
+void f(I* i) {
+ [i meth]; // expected-warning {{not found}}
+}
+
+@implementation I2
+@synthesize prop1, prop2;
+@end
+
+//===----------------------------------------------------------------------===//
+#endif
diff --git a/clang/test/PCH/chain-class-extension.m b/clang/test/PCH/chain-class-extension.m
new file mode 100644
index 0000000..c99d6d4
--- /dev/null
+++ b/clang/test/PCH/chain-class-extension.m
@@ -0,0 +1,42 @@
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin10 -fobjc-arc %s -include %s -include %s
+
+// With PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin10 -fobjc-arc %s -chain-include %s -chain-include %s
+
+#ifndef HEADER1
+#define HEADER1
+//===----------------------------------------------------------------------===//
+// Primary header
+
+@interface I
++(void)meth;
+@end
+
+//===----------------------------------------------------------------------===//
+#elif !defined(HEADER2)
+#define HEADER2
+#if !defined(HEADER1)
+#error Header inclusion order messed up
+#endif
+
+//===----------------------------------------------------------------------===//
+// Dependent header
+
+@interface I()
+@property (assign) id prop;
++(void)meth2;
+@end
+
+//===----------------------------------------------------------------------===//
+#else
+//===----------------------------------------------------------------------===//
+
+void foo(I *i) {
+ [I meth];
+ [I meth2];
+ i.prop = 0;
+}
+
+//===----------------------------------------------------------------------===//
+#endif
diff --git a/clang/test/PCH/chain-conversion-lookup.cpp b/clang/test/PCH/chain-conversion-lookup.cpp
new file mode 100644
index 0000000..db9d8fc
--- /dev/null
+++ b/clang/test/PCH/chain-conversion-lookup.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -chain-include %s -chain-include %s
+
+#if !defined(PASS1)
+#define PASS1
+struct X {
+ operator int*();
+};
+
+struct Z {
+ operator int*();
+};
+#elif !defined(PASS2)
+#define PASS2
+struct Y {
+ operator int *();
+};
+#else
+int main() {
+ X x;
+ int *ip = x.operator int*();
+ Y y;
+ int *ip2 = y.operator int*();
+ Z z;
+ int *ip3 = z.operator int*();
+}
+#endif
diff --git a/clang/test/PCH/chain-cxx.cpp b/clang/test/PCH/chain-cxx.cpp
new file mode 100644
index 0000000..0d50e61
--- /dev/null
+++ b/clang/test/PCH/chain-cxx.cpp
@@ -0,0 +1,142 @@
+// Test C++ chained PCH functionality
+
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -include %s -include %s %s
+
+// With PCH
+// RUN: %clang_cc1 -fsyntax-only -verify %s -chain-include %s -chain-include %s
+
+#ifndef HEADER1
+#define HEADER1
+//===----------------------------------------------------------------------===//
+// Primary header for C++ chained PCH test
+
+void f();
+
+// Name not appearing in dependent
+void pf();
+
+namespace ns {
+ void g();
+
+ void pg();
+}
+
+template <typename T>
+struct S { typedef int G; };
+
+// Partially specialize
+template <typename T>
+struct S<T *> { typedef int H; };
+
+template <typename T> struct TS2;
+typedef TS2<int> TS2int;
+
+template <typename T> struct TestBaseSpecifiers { };
+template<typename T> struct TestBaseSpecifiers2 : TestBaseSpecifiers<T> { };
+
+template <typename T>
+struct TS3 {
+ static const int value = 0;
+ static const int value2;
+};
+template <typename T>
+const int TS3<T>::value;
+template <typename T>
+const int TS3<T>::value2 = 1;
+// Instantiate struct, but not value.
+struct instantiate : TS3<int> {};
+
+// Typedef
+typedef int Integer;
+
+//===----------------------------------------------------------------------===//
+#elif not defined(HEADER2)
+#define HEADER2
+#if !defined(HEADER1)
+#error Header inclusion order messed up
+#endif
+
+//===----------------------------------------------------------------------===//
+// Dependent header for C++ chained PCH test
+
+// Overload function from primary
+void f(int);
+
+// Add function with different name
+void f2();
+
+// Reopen namespace
+namespace ns {
+ // Overload function from primary
+ void g(int);
+
+ // Add different name
+ void g2();
+}
+
+// Specialize template from primary
+template <>
+struct S<int> { typedef int I; };
+
+// Partially specialize
+template <typename T>
+struct S<T &> { typedef int J; };
+
+// Specialize previous partial specialization
+template <>
+struct S<int *> { typedef int K; };
+
+// Specialize the partial specialization from this file
+template <>
+struct S<int &> { typedef int L; };
+
+template <typename T> struct TS2 { };
+
+struct TestBaseSpecifiers3 { };
+struct TestBaseSpecifiers4 : TestBaseSpecifiers3 { };
+
+struct A { };
+struct B : A { };
+
+// Instantiate TS3's members.
+static const int ts3m1 = TS3<int>::value;
+extern int arr[TS3<int>::value2];
+
+// Redefinition of typedef
+typedef int Integer;
+
+//===----------------------------------------------------------------------===//
+#else
+//===----------------------------------------------------------------------===//
+
+void test() {
+ f();
+ f(1);
+ pf();
+ f2();
+
+ ns::g();
+ ns::g(1);
+ ns::pg();
+ ns::g2();
+
+ typedef S<double>::G T1;
+ typedef S<double *>::H T2;
+ typedef S<int>::I T3;
+ typedef S<double &>::J T4;
+ typedef S<int *>::K T5;
+ typedef S<int &>::L T6;
+
+ TS2int ts2;
+
+ B b;
+ Integer i = 17;
+}
+
+// Should have remembered that there is a definition.
+static const int ts3m2 = TS3<int>::value;
+int arr[TS3<int>::value2];
+
+//===----------------------------------------------------------------------===//
+#endif
diff --git a/clang/test/PCH/chain-decls.c b/clang/test/PCH/chain-decls.c
new file mode 100644
index 0000000..f5724c4
--- /dev/null
+++ b/clang/test/PCH/chain-decls.c
@@ -0,0 +1,27 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/chain-decls1.h -include %S/Inputs/chain-decls2.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-decls1.h
+// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-decls2.h -include-pch %t1
+// RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -ast-print -include-pch %t2 %s | FileCheck %s
+
+// CHECK: void f();
+// CHECK: void g();
+
+int h() {
+ f();
+ g();
+
+ struct one x;
+ one();
+ struct two y;
+ two();
+ struct three z;
+
+ many(0);
+ struct many m;
+
+ noret();
+}
diff --git a/clang/test/PCH/chain-empty-initial-namespace.cpp b/clang/test/PCH/chain-empty-initial-namespace.cpp
new file mode 100644
index 0000000..bf15caa
--- /dev/null
+++ b/clang/test/PCH/chain-empty-initial-namespace.cpp
@@ -0,0 +1,24 @@
+// no PCH
+// RUN: %clang_cc1 -include %s -include %s -fsyntax-only %s
+// full PCH
+// RUN: %clang_cc1 -chain-include %s -chain-include %s -fsyntax-only %s
+#if !defined(PASS1)
+#define PASS1
+
+namespace foo {} // no external storage
+
+#elif !defined(PASS2)
+#define PASS2
+
+namespace foo {
+ void bar();
+}
+
+#else
+// PASS3
+
+void test() {
+ foo::bar(); // no-error
+}
+
+#endif
diff --git a/clang/test/PCH/chain-ext_vector.c b/clang/test/PCH/chain-ext_vector.c
new file mode 100644
index 0000000..d99a732
--- /dev/null
+++ b/clang/test/PCH/chain-ext_vector.c
@@ -0,0 +1,11 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/chain-ext_vector1.h -include %S/Inputs/chain-ext_vector2.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-ext_vector1.h
+// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-ext_vector2.h -include-pch %t1
+// RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
+
+int test(float4 f4) {
+ return f4.xy; // expected-error{{float2}}
+}
diff --git a/clang/test/PCH/chain-external-defs.c b/clang/test/PCH/chain-external-defs.c
new file mode 100644
index 0000000..7422294
--- /dev/null
+++ b/clang/test/PCH/chain-external-defs.c
@@ -0,0 +1,54 @@
+// Test with pch.
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t1.pch %S/Inputs/chain-external-defs1.h
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t2.pch %S/Inputs/chain-external-defs2.h -include-pch %t1.pch
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t2.pch -emit-llvm -o %t %s
+// RUN: echo FINI >> %t
+// RUN: FileCheck -input-file=%t -check-prefix=Z %s
+// RUN: FileCheck -input-file=%t -check-prefix=XA %s
+// RUN: FileCheck -input-file=%t -check-prefix=YA %s
+// RUN: FileCheck -input-file=%t -check-prefix=XB %s
+// RUN: FileCheck -input-file=%t -check-prefix=YB %s
+// RUN: FileCheck -input-file=%t -check-prefix=AA %s
+// RUN: FileCheck -input-file=%t -check-prefix=AB %s
+// RUN: FileCheck -input-file=%t -check-prefix=AC %s
+// RUN: FileCheck -input-file=%t -check-prefix=S %s
+
+// Z-NOT: @z
+
+// XA: @x = common global i32 0
+// XA-NOT: @x = common global i32 0
+
+// YA: @y = common global i32 0
+// YA-NOT: @y = common global i32 0
+
+// XB: @x2 = global i32 19
+// XB-NOT: @x2 = global i32 19
+int x2 = 19;
+// YB: @y2 = global i32 18
+// YB-NOT: @y2 = global i32 18
+int y2 = 18;
+
+// AA: @incomplete_array = common global [1 x i32]
+// AA-NOT: @incomplete_array = common global [1 x i32]
+// AB: @incomplete_array2 = common global [17 x i32]
+// AB-NOT: @incomplete_array2 = common global [17 x i32]
+int incomplete_array2[17];
+// AC: @incomplete_array3 = common global [1 x i32]
+// AC-NOT: @incomplete_array3 = common global [1 x i32]
+int incomplete_array3[];
+
+// S: @s = common global %struct.S
+// S-NOT: @s = common global %struct.S
+struct S {
+ int x, y;
+};
+
+// Z: FINI
+// XA: FINI
+// YA: FINI
+// XB: FINI
+// YB: FINI
+// AA: FINI
+// AB: FINI
+// AC: FINI
+// S: FINI
diff --git a/clang/test/PCH/chain-friend-instantiation.cpp b/clang/test/PCH/chain-friend-instantiation.cpp
new file mode 100644
index 0000000..294d979
--- /dev/null
+++ b/clang/test/PCH/chain-friend-instantiation.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 %s -ast-print -o - -chain-include %s -chain-include %s
+
+#if !defined(PASS1)
+#define PASS1
+
+template <class T> class TClass;
+
+namespace NS {
+ template <class X, class Y> TClass<X> problematic(X * ptr, const TClass<Y> &src);
+
+ template <class T>
+ class TBaseClass
+ {
+ protected:
+ template <class X, class Y> friend TClass<X> problematic(X * ptr, const TClass<Y> &src);
+ };
+}
+
+template <class T>
+class TClass: public NS::TBaseClass<T>
+{
+public:
+ inline TClass() { }
+};
+
+
+namespace NS {
+ template <class X, class T>
+ TClass<X> problematic(X *ptr, const TClass<T> &src);
+}
+
+template <class X, class T>
+TClass<X> unconst(const TClass<T> &src);
+
+#elif !defined(PASS2)
+#define PASS2
+
+namespace std {
+class s {};
+}
+
+
+typedef TClass<std::s> TStr;
+
+struct crash {
+ TStr str;
+
+ crash(const TClass<std::s> p)
+ {
+ unconst<TStr>(p);
+ }
+};
+
+#else
+
+void f() {
+ const TStr p;
+ crash c(p);
+}
+
+#endif
diff --git a/clang/test/PCH/chain-implicit-definition.cpp b/clang/test/PCH/chain-implicit-definition.cpp
new file mode 100644
index 0000000..245e8f9
--- /dev/null
+++ b/clang/test/PCH/chain-implicit-definition.cpp
@@ -0,0 +1,39 @@
+// no PCH
+// RUN: %clang_cc1 -emit-llvm-only -include %s -include %s %s
+// with PCH
+// RUN: %clang_cc1 -emit-llvm-only -chain-include %s -chain-include %s %s
+#if !defined(PASS1)
+#define PASS1
+
+// A base with a virtual dtor.
+struct A {
+ virtual ~A();
+};
+
+// A derived class with an implicit virtual dtor.
+struct B : A {
+ // Key function to suppress vtable definition.
+ virtual void virt();
+};
+
+#elif !defined(PASS2)
+#define PASS2
+
+// Further derived class that requires ~B().
+// Causes definition of ~B(), but it was lost when saving PCH.
+struct C : B {
+ C();
+ ~C() {}
+};
+
+#else
+
+void foo() {
+ // Variable that requires ~C().
+ C c;
+}
+
+// VTable placement would again cause definition of ~B(), hiding the bug,
+// if not for B::virt(), which suppresses the placement.
+
+#endif
diff --git a/clang/test/PCH/chain-late-anonymous-namespace.cpp b/clang/test/PCH/chain-late-anonymous-namespace.cpp
new file mode 100644
index 0000000..87205c6
--- /dev/null
+++ b/clang/test/PCH/chain-late-anonymous-namespace.cpp
@@ -0,0 +1,61 @@
+// no PCH
+// RUN: %clang_cc1 -include %s -include %s -fsyntax-only %s
+// with PCH
+// RUN: %clang_cc1 -chain-include %s -chain-include %s -fsyntax-only %s
+#if !defined(PASS1)
+#define PASS1
+
+namespace ns {}
+namespace os {}
+
+#elif !defined(PASS2)
+#define PASS2
+
+namespace ns {
+ namespace {
+ extern int x;
+ }
+}
+
+namespace {
+ extern int y;
+}
+namespace {
+}
+
+namespace os {
+ extern "C" {
+ namespace {
+ extern int z;
+ }
+ }
+}
+
+#else
+
+namespace ns {
+ namespace {
+ int x;
+ }
+ void test() {
+ (void)x;
+ }
+}
+
+namespace {
+ int y;
+}
+void test() {
+ (void)y;
+}
+
+namespace os {
+ namespace {
+ int z;
+ }
+ void test() {
+ (void)z;
+ }
+}
+
+#endif
diff --git a/clang/test/PCH/chain-macro-override.c b/clang/test/PCH/chain-macro-override.c
new file mode 100644
index 0000000..2713e70
--- /dev/null
+++ b/clang/test/PCH/chain-macro-override.c
@@ -0,0 +1,14 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/chain-macro-override1.h -include %S/Inputs/chain-macro-override2.h -fsyntax-only -verify -detailed-preprocessing-record %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-macro-override1.h -detailed-preprocessing-record
+// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-macro-override2.h -include-pch %t1 -detailed-preprocessing-record
+// RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
+
+int foo() {
+ f();
+ g();
+ h();
+ return x;
+}
diff --git a/clang/test/PCH/chain-macro.c b/clang/test/PCH/chain-macro.c
new file mode 100644
index 0000000..18356f7
--- /dev/null
+++ b/clang/test/PCH/chain-macro.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -o %t1 -detailed-preprocessing-record %S/Inputs/chain-macro1.h
+// RUN: %clang_cc1 -emit-pch -o %t2 -detailed-preprocessing-record %S/Inputs/chain-macro2.h -include-pch %t1
+// RUN: %clang_cc1 -fsyntax-only -verify -include-pch %t2 %s
+// RUN: %clang_cc1 -ast-print -include-pch %t2 %s | FileCheck %s
+
+// CHECK: void f();
+FOOBAR
+// CHECK: void g();
+BARFOO
diff --git a/clang/test/PCH/chain-pending-instantiations.cpp b/clang/test/PCH/chain-pending-instantiations.cpp
new file mode 100644
index 0000000..e49abcd
--- /dev/null
+++ b/clang/test/PCH/chain-pending-instantiations.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -chain-include %s -chain-include %s | FileCheck %s
+// CHECK: define linkonce_odr %{{[^ ]+}} @_ZN1AI1BE3getEv
+#if !defined(PASS1)
+#define PASS1
+
+template <typename Derived>
+struct A {
+ Derived* get() { return 0; }
+};
+
+struct B : A<B> {
+};
+
+#elif !defined(PASS2)
+#define PASS2
+
+struct C : B {
+};
+
+struct D : C {
+ void run() {
+ (void)get();
+ }
+};
+
+#else
+
+int main() {
+ D d;
+ d.run();
+}
+
+#endif
diff --git a/clang/test/PCH/chain-predecl.h b/clang/test/PCH/chain-predecl.h
new file mode 100644
index 0000000..bd332ff
--- /dev/null
+++ b/clang/test/PCH/chain-predecl.h
@@ -0,0 +1,3 @@
+// First header for chain-predecl.m
+@class Foo;
+@protocol Pro;
diff --git a/clang/test/PCH/chain-predecl.m b/clang/test/PCH/chain-predecl.m
new file mode 100644
index 0000000..6723b6f
--- /dev/null
+++ b/clang/test/PCH/chain-predecl.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-pch -o %t1 %S/chain-predecl.h -x objective-c
+// RUN: %clang_cc1 -emit-pch -o %t2 %s -x objective-c -include-pch %t1
+
+// Test predeclarations across chained PCH.
+@interface Foo
+-(void)bar;
+@end
+@interface Boom
+-(void)bar;
+@end
+@protocol Pro
+-(void)baz;
+@end
+@protocol Kaboom
+-(void)baz;
+@end
diff --git a/clang/test/PCH/chain-remap-types.m b/clang/test/PCH/chain-remap-types.m
new file mode 100644
index 0000000..585da44
--- /dev/null
+++ b/clang/test/PCH/chain-remap-types.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-pch -x objective-c-header -o %t1 %S/Inputs/chain-remap-types1.h
+// RUN: %clang_cc1 -emit-pch -x objective-c-header -o %t2 %S/Inputs/chain-remap-types2.h -include-pch %t1
+// RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -ast-print -include-pch %t2 %s | FileCheck %s
+
+// CHECK: @class X;
+// CHECK: struct Y
+// CHECK: @property ( assign,readwrite,atomic ) X * prop
+// CHECK: void h(X *);
+// CHECK: @interface X(Blah)
+// CHECK: void g(X *);
+
diff --git a/clang/test/PCH/chain-selectors.m b/clang/test/PCH/chain-selectors.m
new file mode 100644
index 0000000..7eae094
--- /dev/null
+++ b/clang/test/PCH/chain-selectors.m
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s -Wselector -include %S/Inputs/chain-selectors1.h -include %S/Inputs/chain-selectors2.h
+
+// RUN: %clang_cc1 -x objective-c -Wno-objc-root-class -emit-pch -o %t1 %S/Inputs/chain-selectors1.h
+// RUN: %clang_cc1 -x objective-c -Wno-objc-root-class -emit-pch -o %t2 %S/Inputs/chain-selectors2.h -include-pch %t1
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s -Wselector -include-pch %t2
+
+@implementation X
+-(void)f {}
+-(void)f2 {}
+-(void)g: (int)p {}
+-(void)h: (int)p1 foo: (int)p2 {}
+@end
+
+void bar() {
+ id a = 0;
+ [a nothing]; // expected-warning {{method '-nothing' not found}}
+ [a f];
+ // FIXME: Can't verify notes in headers
+ //[a f2];
+
+ (void)@selector(x); // expected-warning {{unimplemented selector}}
+ (void)@selector(y); // expected-warning {{unimplemented selector}}
+ (void)@selector(e); // expected-warning {{unimplemented selector}}
+}
+
+@implementation X (Blah)
+- (void)test_Blah {
+ [self blah_method];
+}
+
+- (void)blah_method { }
+@end
+
+@implementation X (Blarg)
+- (void)test_Blarg {
+ [self blarg_method];
+}
+
+- (void)blarg_method { }
+@end
diff --git a/clang/test/PCH/chain-trivial.c b/clang/test/PCH/chain-trivial.c
new file mode 100644
index 0000000..85b1eab
--- /dev/null
+++ b/clang/test/PCH/chain-trivial.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-pch -o %t1 %S/Inputs/chain-trivial1.h
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-pch -o %t2 -include-pch %t1 %S/Inputs/chain-trivial2.h
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-print -include-pch %t2 %s | FileCheck %s
+// CHECK: struct __va_list_tag {
diff --git a/clang/test/PCH/changed-files.c b/clang/test/PCH/changed-files.c
new file mode 100644
index 0000000..d1b603b
--- /dev/null
+++ b/clang/test/PCH/changed-files.c
@@ -0,0 +1,28 @@
+const char *s0 = m0;
+int s1 = m1;
+const char *s2 = m0;
+
+// FIXME: This test fails inexplicably on Windows in a manner that makes it
+// look like standard error isn't getting flushed properly.
+
+// RUN: false
+// XFAIL: *
+
+// RUN: echo '#define m0 ""' > %t.h
+// RUN: %clang_cc1 -emit-pch -o %t.h.pch %t.h
+// RUN: echo '' > %t.h
+// RUN: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr
+// RUN: grep "modified" %t.stderr
+
+// RUN: echo '#define m0 000' > %t.h
+// RUN: %clang_cc1 -emit-pch -o %t.h.pch %t.h
+// RUN: echo '' > %t.h
+// RUN: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr
+// RUN: grep "modified" %t.stderr
+
+// RUN: echo '#define m0 000' > %t.h
+// RUN: echo "#define m1 'abcd'" >> %t.h
+// RUN: %clang_cc1 -emit-pch -o %t.h.pch %t.h
+// RUN: echo '' > %t.h
+// RUN: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr
+// RUN: grep "modified" %t.stderr
diff --git a/clang/test/PCH/check-deserializations.cpp b/clang/test/PCH/check-deserializations.cpp
new file mode 100644
index 0000000..9f73c95
--- /dev/null
+++ b/clang/test/PCH/check-deserializations.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -error-on-deserialized-decl S1_method -include-pch %t -emit-llvm-only %s
+
+#ifndef HEADER
+#define HEADER
+// Header.
+
+struct S1 {
+ void S1_method(); // This should not be deserialized.
+ virtual void S1_keyfunc();
+};
+
+
+#else
+// Using the header.
+
+void test(S1*) {
+}
+
+#endif
diff --git a/clang/test/PCH/cmdline-include.c b/clang/test/PCH/cmdline-include.c
new file mode 100644
index 0000000..ad45192
--- /dev/null
+++ b/clang/test/PCH/cmdline-include.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -include %S/cmdline-include1.h -x c-header %S/cmdline-include2.h -emit-pch -o %t
+// RUN: %clang_cc1 %s -include-pch %t -fsyntax-only -verify
+// RUN: %clang_cc1 -x c-header %S/cmdline-include1.h -emit-pch -o %t
+// RUN: %clang_cc1 %s -include-pch %t -include %S/cmdline-include2.h -fsyntax-only -verify
+
+int g = x1 + x2;
diff --git a/clang/test/PCH/cmdline-include1.h b/clang/test/PCH/cmdline-include1.h
new file mode 100644
index 0000000..4f7c661
--- /dev/null
+++ b/clang/test/PCH/cmdline-include1.h
@@ -0,0 +1 @@
+enum { x1 };
diff --git a/clang/test/PCH/cmdline-include2.h b/clang/test/PCH/cmdline-include2.h
new file mode 100644
index 0000000..cf8e37b
--- /dev/null
+++ b/clang/test/PCH/cmdline-include2.h
@@ -0,0 +1 @@
+enum { x2 };
diff --git a/clang/test/PCH/cocoa.m b/clang/test/PCH/cocoa.m
new file mode 100644
index 0000000..0159b32
--- /dev/null
+++ b/clang/test/PCH/cocoa.m
@@ -0,0 +1,7 @@
+// RUN: %clang -arch x86_64 -x objective-c-header %s -o %t.h.pch
+// RUN: touch %t.empty.m
+// RUN: %clang -arch x86_64 -fsyntax-only %t.empty.m -include %t.h -Xclang -ast-dump 2>&1 > /dev/null
+#ifdef __APPLE__
+#include <Cocoa/Cocoa.h>
+#endif
+
diff --git a/clang/test/PCH/cuda-kernel-call.cu b/clang/test/PCH/cuda-kernel-call.cu
new file mode 100644
index 0000000..ef12c59
--- /dev/null
+++ b/clang/test/PCH/cuda-kernel-call.cu
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only %s
+
+#ifndef HEADER
+#define HEADER
+// Header.
+
+#include "../SemaCUDA/cuda.h"
+
+void kcall(void (*kp)()) {
+ kp<<<1, 1>>>();
+}
+
+__global__ void kern() {
+}
+
+#else
+// Using the header.
+
+void test() {
+ kcall(kern);
+ kern<<<1, 1>>>();
+}
+
+#endif
diff --git a/clang/test/PCH/cxx-alias-decl.cpp b/clang/test/PCH/cxx-alias-decl.cpp
new file mode 100644
index 0000000..872658f
--- /dev/null
+++ b/clang/test/PCH/cxx-alias-decl.cpp
@@ -0,0 +1,20 @@
+// Test this without pch.
+// RUN: %clang_cc1 -x c++ -std=c++11 -include %S/cxx-alias-decl.h -fsyntax-only -emit-llvm -o - %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++ -std=c++11 -emit-pch -o %t %S/cxx-alias-decl.h
+// RUN: %clang_cc1 -x c++ -std=c++11 -include-pch %t -fsyntax-only -emit-llvm -o - %s
+
+template struct T<S>;
+C<A>::A<char> a;
+
+using T1 = decltype(a);
+using T1 = D<int, char>;
+
+using T2 = B<A>;
+using T2 = S;
+
+using A = int;
+template<typename U> using B = S;
+template<typename U> using C = T<U>;
+template<typename U, typename V> using D = typename T<U>::template A<V>;
diff --git a/clang/test/PCH/cxx-alias-decl.h b/clang/test/PCH/cxx-alias-decl.h
new file mode 100644
index 0000000..26bc716
--- /dev/null
+++ b/clang/test/PCH/cxx-alias-decl.h
@@ -0,0 +1,11 @@
+// Header for PCH test cxx-alias-decl.cpp
+
+struct S {};
+template<typename U> struct T {
+ template<typename V> using A = T<V>;
+};
+
+using A = int;
+template<typename U> using B = S;
+template<typename U> using C = T<U>;
+template<typename U, typename V> using D = typename T<U>::template A<V>;
diff --git a/clang/test/PCH/cxx-chain-function-template.cpp b/clang/test/PCH/cxx-chain-function-template.cpp
new file mode 100644
index 0000000..494e190
--- /dev/null
+++ b/clang/test/PCH/cxx-chain-function-template.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -chain-include %s -chain-include %s -fsyntax-only %s
+// Just don't crash.
+#if !defined(RUN1)
+#define RUN1
+
+struct CXXRecordDecl { CXXRecordDecl(int); };
+
+template <typename T, typename U>
+T cast(U u) {
+ return reinterpret_cast<T&>(u);
+}
+
+void test1() {
+ cast<float>(1);
+}
+
+#elif !defined(RUN2)
+#define RUN2
+
+template <typename T>
+void test2(T) {
+ cast<CXXRecordDecl>(1.0f);
+}
+
+#else
+
+void test3() {
+ cast<CXXRecordDecl>(1.0f);
+ test2(1);
+}
+
+#endif
diff --git a/clang/test/PCH/cxx-constexpr.cpp b/clang/test/PCH/cxx-constexpr.cpp
new file mode 100644
index 0000000..8fe48f7
--- /dev/null
+++ b/clang/test/PCH/cxx-constexpr.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -pedantic-errors -std=c++98 -emit-pch %s -o %t
+// RUN: %clang_cc1 -pedantic-errors -std=c++98 -include-pch %t -verify %s
+
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t-cxx11
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t-cxx11 -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+extern const int a;
+const int b = a;
+
+#else
+
+const int a = 5;
+typedef int T[b]; // expected-error {{variable length array}} expected-error {{must be an integer constant expression}}
+typedef int T[5];
+
+#endif
diff --git a/clang/test/PCH/cxx-exprs.cpp b/clang/test/PCH/cxx-exprs.cpp
new file mode 100644
index 0000000..9cd3194
--- /dev/null
+++ b/clang/test/PCH/cxx-exprs.cpp
@@ -0,0 +1,27 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -verify -std=c++11 %s
+
+// Test with pch.
+// RUN: %clang_cc1 -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -verify -std=c++11 %s
+
+#ifndef HEADER
+#define HEADER
+
+template<typename T>
+class New {
+ New(const New&);
+
+public:
+ New *clone() {
+ return new New(*this);
+ }
+};
+
+#else
+
+New<int> *clone_new(New<int> *n) {
+ return n->clone();
+}
+
+#endif
diff --git a/clang/test/PCH/cxx-for-range.cpp b/clang/test/PCH/cxx-for-range.cpp
new file mode 100644
index 0000000..48310db
--- /dev/null
+++ b/clang/test/PCH/cxx-for-range.cpp
@@ -0,0 +1,19 @@
+// Test this without pch.
+// RUN: %clang_cc1 -x c++ -std=c++11 -include %S/cxx-for-range.h -fsyntax-only -emit-llvm -o - %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++ -std=c++11 -emit-pch -o %t %S/cxx-for-range.h
+// RUN: %clang_cc1 -x c++ -std=c++11 -include-pch %t -fsyntax-only -emit-llvm -o - %s
+
+void h() {
+ f();
+
+ g<int>();
+
+ char a[3] = { 0, 1, 2 };
+ for (auto w : a)
+ for (auto x : S())
+ for (auto y : T())
+ for (auto z : U())
+ ;
+}
diff --git a/clang/test/PCH/cxx-for-range.h b/clang/test/PCH/cxx-for-range.h
new file mode 100644
index 0000000..f15c7e7
--- /dev/null
+++ b/clang/test/PCH/cxx-for-range.h
@@ -0,0 +1,35 @@
+// Header for PCH test cxx-for-range.cpp
+
+struct S {
+ int *begin();
+ int *end();
+};
+
+struct T { };
+char *begin(T);
+char *end(T);
+
+struct U { };
+namespace std {
+ char *begin(U);
+ char *end(U);
+}
+
+void f() {
+ char a[3] = { 0, 1, 2 };
+ for (auto w : a)
+ for (auto x : S())
+ for (auto y : T())
+ for (auto z : U())
+ ;
+}
+
+template<typename A>
+void g() {
+ A a[3] = { 0, 1, 2 };
+ for (auto &v : a)
+ for (auto x : S())
+ for (auto y : T())
+ for (auto z : U())
+ ;
+}
diff --git a/clang/test/PCH/cxx-friends.cpp b/clang/test/PCH/cxx-friends.cpp
new file mode 100644
index 0000000..a8d7558
--- /dev/null
+++ b/clang/test/PCH/cxx-friends.cpp
@@ -0,0 +1,13 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/cxx-friends.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-friends.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+class F {
+ void m() {
+ A* a;
+ a->x = 0;
+ }
+};
diff --git a/clang/test/PCH/cxx-friends.h b/clang/test/PCH/cxx-friends.h
new file mode 100644
index 0000000..2a33f15
--- /dev/null
+++ b/clang/test/PCH/cxx-friends.h
@@ -0,0 +1,6 @@
+// Header for PCH test cxx-friends.cpp
+
+class A {
+ int x;
+ friend class F;
+};
diff --git a/clang/test/PCH/cxx-functions.cpp b/clang/test/PCH/cxx-functions.cpp
new file mode 100644
index 0000000..74df01a
--- /dev/null
+++ b/clang/test/PCH/cxx-functions.cpp
@@ -0,0 +1,10 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/cxx-functions.h -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-functions.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+
+void test_foo() {
+ foo();
+}
diff --git a/clang/test/PCH/cxx-functions.h b/clang/test/PCH/cxx-functions.h
new file mode 100644
index 0000000..8aa4986
--- /dev/null
+++ b/clang/test/PCH/cxx-functions.h
@@ -0,0 +1 @@
+void foo() throw( int, short, char, float, double );
diff --git a/clang/test/PCH/cxx-implicit-moves.cpp b/clang/test/PCH/cxx-implicit-moves.cpp
new file mode 100644
index 0000000..ccdc874
--- /dev/null
+++ b/clang/test/PCH/cxx-implicit-moves.cpp
@@ -0,0 +1,23 @@
+// Test with PCH
+// RUN: %clang_cc1 -std=c++11 -x c++-header -emit-pch -o %t %s
+// RUN: %clang_cc1 -std=c++11 -include-pch %t -verify %s
+
+// PR10847
+#ifndef HEADER
+#define HEADER
+struct NSSize {
+ double width;
+ double height;
+};
+typedef struct NSSize NSSize;
+
+static inline NSSize NSMakeSize(double w, double h) {
+ NSSize s = { w, h };
+ return s;
+}
+#else
+float test(float v1, float v2) {
+ NSSize s = NSMakeSize(v1, v2);
+ return s.width;
+}
+#endif
diff --git a/clang/test/PCH/cxx-member-init.cpp b/clang/test/PCH/cxx-member-init.cpp
new file mode 100644
index 0000000..2820665
--- /dev/null
+++ b/clang/test/PCH/cxx-member-init.cpp
@@ -0,0 +1,22 @@
+// Test this without pch.
+// RUN: %clang_cc1 -x c++ -std=c++11 -DHEADER -DSOURCE -fsyntax-only -emit-llvm -o - %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++ -std=c++11 -DHEADER -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -std=c++11 -DHEADER -include-pch %t -fsyntax-only -emit-llvm -o - %s
+
+#ifdef HEADER
+int n;
+struct S {
+ int *p = &m;
+ int &m = n;
+ S *that = this;
+};
+#endif
+
+#ifdef SOURCE
+S s;
+#elif HEADER
+#undef HEADER
+#define SOURCE
+#endif
diff --git a/clang/test/PCH/cxx-method.cpp b/clang/test/PCH/cxx-method.cpp
new file mode 100644
index 0000000..6ec65b2
--- /dev/null
+++ b/clang/test/PCH/cxx-method.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -x c++ -emit-pch %S/Inputs/cxx-method.h -o %t
+// RUN: %clang_cc1 -include-pch %t -verify %s
+
+void S::m(int x) { }
+
+S::operator char *() { return 0; }
+
+S::operator const char *() { return 0; }
diff --git a/clang/test/PCH/cxx-ms-function-specialization-class-scope.cpp b/clang/test/PCH/cxx-ms-function-specialization-class-scope.cpp
new file mode 100644
index 0000000..1803a11
--- /dev/null
+++ b/clang/test/PCH/cxx-ms-function-specialization-class-scope.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fms-extensions -triple i386-unknown-unknown -x c++-header -emit-pch -o %t %S/cxx-ms-function-specialization-class-scope.h
+// RUN: %clang_cc1 -fms-extensions -triple i386-unknown-unknown -include-pch %t -fsyntax-only -verify %s
+
+
+void test2()
+{
+ B<char> b(3);
+ char* ptr;
+ b.f(ptr);
+ b.f<int>(99);
+ b.f(100);
+}
+
diff --git a/clang/test/PCH/cxx-ms-function-specialization-class-scope.h b/clang/test/PCH/cxx-ms-function-specialization-class-scope.h
new file mode 100644
index 0000000..7668e73
--- /dev/null
+++ b/clang/test/PCH/cxx-ms-function-specialization-class-scope.h
@@ -0,0 +1,29 @@
+
+
+
+template <class T>
+class B {
+public:
+ template <class U>
+ B(U p) {
+ }
+ template <>
+ B(int p) { // expected-warning{{explicit specialization of 'B<T>' within class scope is a Microsoft extension}}
+ }
+
+ template <class U>
+ void f(U p) {
+ T y = 9;
+ }
+
+
+ template <>
+ void f(int p) { // expected-warning{{explicit specialization of 'f' within class scope is a Microsoft extension}}
+ T a = 3;
+ }
+
+ void f(int p) {
+ T a = 3;
+ }
+};
+
diff --git a/clang/test/PCH/cxx-namespaces.cpp b/clang/test/PCH/cxx-namespaces.cpp
new file mode 100644
index 0000000..0fd3de7
--- /dev/null
+++ b/clang/test/PCH/cxx-namespaces.cpp
@@ -0,0 +1,10 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/cxx-namespaces.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-namespaces.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+void m() {
+ N::x = 0;
+}
diff --git a/clang/test/PCH/cxx-namespaces.h b/clang/test/PCH/cxx-namespaces.h
new file mode 100644
index 0000000..f338953
--- /dev/null
+++ b/clang/test/PCH/cxx-namespaces.h
@@ -0,0 +1,7 @@
+// Header for PCH test cxx-namespaces.cpp
+
+namespace N {
+ namespace {
+ int x;
+ }
+}
diff --git a/clang/test/PCH/cxx-offsetof-base.cpp b/clang/test/PCH/cxx-offsetof-base.cpp
new file mode 100644
index 0000000..18265de
--- /dev/null
+++ b/clang/test/PCH/cxx-offsetof-base.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-offsetof-base.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only %s
diff --git a/clang/test/PCH/cxx-offsetof-base.h b/clang/test/PCH/cxx-offsetof-base.h
new file mode 100644
index 0000000..7c78101
--- /dev/null
+++ b/clang/test/PCH/cxx-offsetof-base.h
@@ -0,0 +1,5 @@
+// Header for PCH test cxx-offsetof-base.cpp
+
+struct Base { int x; };
+struct Derived : Base { int y; };
+int o = __builtin_offsetof(Derived, x);
diff --git a/clang/test/PCH/cxx-reference.cpp b/clang/test/PCH/cxx-reference.cpp
new file mode 100644
index 0000000..a1a44e6
--- /dev/null
+++ b/clang/test/PCH/cxx-reference.cpp
@@ -0,0 +1,6 @@
+// Test this without pch.
+// RUN: %clang_cc1 -x c++ -std=c++11 -include %S/cxx-reference.h -fsyntax-only -emit-llvm -o - %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++ -std=c++11 -emit-pch -o %t %S/cxx-reference.h
+// RUN: %clang_cc1 -x c++ -std=c++11 -include-pch %t -fsyntax-only -emit-llvm -o - %s
diff --git a/clang/test/PCH/cxx-reference.h b/clang/test/PCH/cxx-reference.h
new file mode 100644
index 0000000..b46a367
--- /dev/null
+++ b/clang/test/PCH/cxx-reference.h
@@ -0,0 +1,13 @@
+// Header for PCH test cxx-reference.cpp
+
+typedef char (&LR);
+typedef char (&&RR);
+
+char c;
+
+char &lr = c;
+char &&rr = 'c';
+LR &lrlr = c;
+LR &&rrlr = c;
+RR &lrrr = c;
+RR &&rrrr = 'c';
diff --git a/clang/test/PCH/cxx-required-decls.cpp b/clang/test/PCH/cxx-required-decls.cpp
new file mode 100644
index 0000000..8c4b11c
--- /dev/null
+++ b/clang/test/PCH/cxx-required-decls.cpp
@@ -0,0 +1,10 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/cxx-required-decls.h %s -emit-llvm -o - | FileCheck %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-required-decls.h
+// RUN: %clang_cc1 -include-pch %t %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: @_ZL5globS = internal global %struct.S zeroinitializer
+// CHECK: @_ZL3bar = internal global i32 0, align 4
+// CHECK: @glob_var = global i32 0
diff --git a/clang/test/PCH/cxx-required-decls.h b/clang/test/PCH/cxx-required-decls.h
new file mode 100644
index 0000000..099d2da
--- /dev/null
+++ b/clang/test/PCH/cxx-required-decls.h
@@ -0,0 +1,12 @@
+// Header for PCH test cxx-required-decls.cpp
+
+struct S {
+ S();
+};
+
+static S globS;
+
+extern int ext_foo;
+static int bar = ++ext_foo;
+
+int glob_var;
diff --git a/clang/test/PCH/cxx-static_assert.cpp b/clang/test/PCH/cxx-static_assert.cpp
new file mode 100644
index 0000000..ace12e0
--- /dev/null
+++ b/clang/test/PCH/cxx-static_assert.cpp
@@ -0,0 +1,20 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -verify -std=c++11 %s
+
+// Test with pch.
+// RUN: %clang_cc1 -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -verify -std=c++11 %s
+
+#ifndef HEADER
+#define HEADER
+
+template<int N> struct T {
+ static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed "N is not 2!"}}
+};
+
+#else
+
+T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}}
+T<2> t2;
+
+#endif
diff --git a/clang/test/PCH/cxx-templates.cpp b/clang/test/PCH/cxx-templates.cpp
new file mode 100644
index 0000000..7ce2477
--- /dev/null
+++ b/clang/test/PCH/cxx-templates.cpp
@@ -0,0 +1,70 @@
+// Test this without pch.
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h -verify %s -ast-dump -o -
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h %s -emit-llvm -o - | FileCheck %s
+
+// Test with pch.
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -x c++-header -emit-pch -o %t %S/cxx-templates.h
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include-pch %t -verify %s -ast-dump -o -
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include-pch %t %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: define weak_odr void @_ZN2S4IiE1mEv
+// CHECK: define linkonce_odr void @_ZN2S3IiE1mEv
+
+struct A {
+ typedef int type;
+ static void my_f();
+ template <typename T>
+ static T my_templf(T x) { return x; }
+};
+
+void test(const int (&a6)[17]) {
+ int x = templ_f<int, 5>(3);
+
+ S<char, float>::templ();
+ S<int, char>::partial();
+ S<int, float>::explicit_special();
+
+ Dep<A>::Ty ty;
+ Dep<A> a;
+ a.f();
+
+ S3<int> s3;
+ s3.m();
+
+ TS5 ts(0);
+
+ S6<const int[17]>::t2 b6 = a6;
+}
+
+template struct S4<int>;
+
+S7<int[5]> s7_5;
+
+namespace ZeroLengthExplicitTemplateArgs {
+ template void f<X>(X*);
+}
+
+// This used to overwrite memory and crash.
+namespace Test1 {
+ struct StringHasher {
+ template<typename T, char Converter(T)> static inline unsigned createHash(const T*, unsigned) {
+ return 0;
+ }
+ };
+
+ struct CaseFoldingHash {
+ static inline char foldCase(char) {
+ return 0;
+ }
+
+ static unsigned hash(const char* data, unsigned length) {
+ return StringHasher::createHash<char, foldCase>(data, length);
+ }
+ };
+}
+
+template< typename D >
+Foo< D >& Foo< D >::operator=( const Foo& other )
+{
+ return *this;
+}
diff --git a/clang/test/PCH/cxx-templates.h b/clang/test/PCH/cxx-templates.h
new file mode 100644
index 0000000..152e8ce
--- /dev/null
+++ b/clang/test/PCH/cxx-templates.h
@@ -0,0 +1,217 @@
+// Header for PCH test cxx-templates.cpp
+
+template <typename T1, typename T2>
+struct S;
+
+template <typename T1, typename T2>
+struct S {
+ S() { }
+ static void templ();
+};
+
+template <typename T>
+struct S<int, T> {
+ static void partial();
+};
+
+template <>
+struct S<int, float> {
+ static void explicit_special();
+};
+
+template <int x>
+int tmpl_f2() { return x; }
+
+template <typename T, int y>
+T templ_f(T x) {
+ int z = templ_f<int, 5>(3);
+ z = tmpl_f2<y+2>();
+ T data[y];
+ return x+y;
+}
+
+void govl(int);
+void govl(char);
+
+template <typename T>
+struct Unresolv {
+ void f() {
+ govl(T());
+ }
+};
+
+template <typename T>
+struct Dep {
+ typedef typename T::type Ty;
+ void f() {
+ Ty x = Ty();
+ T::my_f();
+ int y = T::template my_templf<int>(0);
+ ovl(y);
+ }
+
+ void ovl(int);
+ void ovl(float);
+};
+
+template<typename T, typename A1>
+inline T make_a(const A1& a1) {
+ T::depend_declref();
+ return T(a1);
+}
+
+template <class T> class UseBase {
+ void foo();
+ typedef int bar;
+};
+
+template <class T> class UseA : public UseBase<T> {
+ using UseBase<T>::foo;
+ using typename UseBase<T>::bar;
+};
+
+template <class T> class Sub : public UseBase<int> { };
+
+template <class _Ret, class _Tp>
+ class mem_fun_t
+ {
+ public:
+ explicit
+ mem_fun_t(_Ret (_Tp::*__pf)())
+ {}
+
+ private:
+ _Ret (_Tp::*_M_f)();
+ };
+
+template<unsigned N>
+bool isInt(int x);
+
+template<> bool isInt<8>(int x) {
+ try { ++x; } catch(...) { --x; }
+ return true;
+}
+
+template<typename _CharT>
+int __copy_streambufs_eof(_CharT);
+
+class basic_streambuf
+{
+ void m() { }
+ friend int __copy_streambufs_eof<>(int);
+};
+
+// PR 7660
+template<typename T> struct S_PR7660 { void g(void (*)(T)); };
+ template<> void S_PR7660<int>::g(void(*)(int)) {}
+
+// PR 7670
+template<typename> class C_PR7670;
+template<> class C_PR7670<int>;
+template<> class C_PR7670<int>;
+
+template <bool B>
+struct S2 {
+ static bool V;
+};
+
+extern template class S2<true>;
+
+template <typename T>
+struct S3 {
+ void m();
+};
+
+template <typename T>
+inline void S3<T>::m() { }
+
+template <typename T>
+struct S4 {
+ void m() { }
+};
+extern template struct S4<int>;
+
+void S4ImplicitInst() {
+ S4<int> s;
+ s.m();
+}
+
+struct S5 {
+ S5(int x);
+};
+
+struct TS5 {
+ S5 s;
+ template <typename T>
+ TS5(T y) : s(y) {}
+};
+
+// PR 8134
+template<class T> void f_PR8134(T);
+template<class T> void f_PR8134(T);
+void g_PR8134() { f_PR8134(0); f_PR8134('x'); }
+
+// rdar8580149
+template <typename T>
+struct S6;
+
+template <typename T, unsigned N>
+struct S6<const T [N]>
+{
+private:
+ typedef const T t1[N];
+public:
+ typedef t1& t2;
+};
+
+template<typename T>
+ struct S7;
+
+template<unsigned N>
+struct S7<int[N]> : S6<const int[N]> { };
+
+// Zero-length template argument lists
+namespace ZeroLengthExplicitTemplateArgs {
+ template<typename T> void h();
+
+ struct Y {
+ template<typename T> void f();
+ };
+
+ template<typename T>
+ void f(T *ptr) {
+ T::template g<>(17);
+ ptr->template g2<>(17);
+ h<T>();
+ h<int>();
+ Y y;
+ y.f<int>();
+ }
+
+ struct X {
+ template<typename T> static void g(T);
+ template<typename T> void g2(T);
+ };
+}
+
+namespace NonTypeTemplateParmContext {
+ template<typename T, int inlineCapacity = 0> class Vector { };
+
+ struct String {
+ template<int inlineCapacity>
+ static String adopt(Vector<char, inlineCapacity>&);
+ };
+
+ template<int inlineCapacity>
+ inline bool equalIgnoringNullity(const Vector<char, inlineCapacity>& a, const String& b) { return false; }
+}
+
+// <rdar://problem/11112464>
+template< typename > class Foo;
+
+template< typename T >
+class Foo : protected T
+{
+ public:
+ Foo& operator=( const Foo& other );
+};
diff --git a/clang/test/PCH/cxx-trailing-return.cpp b/clang/test/PCH/cxx-trailing-return.cpp
new file mode 100644
index 0000000..ff85f6d
--- /dev/null
+++ b/clang/test/PCH/cxx-trailing-return.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t-cxx11
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t-cxx11 -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+typedef auto f() -> int; // expected-note {{here}}
+typedef int g(); // expected-note {{here}}
+
+#else
+
+typedef void f; // expected-error {{typedef redefinition with different types ('void' vs 'auto () -> int')}}
+typedef void g; // expected-error {{typedef redefinition with different types ('void' vs 'int ()')}}
+
+#endif
diff --git a/clang/test/PCH/cxx-traits.cpp b/clang/test/PCH/cxx-traits.cpp
new file mode 100644
index 0000000..3df3479
--- /dev/null
+++ b/clang/test/PCH/cxx-traits.cpp
@@ -0,0 +1,11 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/cxx-traits.h -std=c++11 -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -x c++-header -std=c++11 -emit-pch -o %t %S/cxx-traits.h
+// RUN: %clang_cc1 -std=c++11 -include-pch %t -fsyntax-only -verify %s
+
+bool _Is_pod_comparator = __is_pod<int>::__value;
+bool _Is_empty_check = __is_empty<int>::__value;
+
+bool default_construct_int = is_trivially_constructible<int>::value;
+bool copy_construct_int = is_trivially_constructible<int, const int&>::value;
diff --git a/clang/test/PCH/cxx-traits.h b/clang/test/PCH/cxx-traits.h
new file mode 100644
index 0000000..8b62002
--- /dev/null
+++ b/clang/test/PCH/cxx-traits.h
@@ -0,0 +1,16 @@
+// Header for PCH test cxx-traits.cpp
+
+template<typename _Tp>
+struct __is_pod {
+ enum { __value };
+};
+
+template<typename _Tp>
+struct __is_empty {
+ enum { __value };
+};
+
+template<typename T, typename ...Args>
+struct is_trivially_constructible {
+ static const bool value = __is_trivially_constructible(T, Args...);
+};
diff --git a/clang/test/PCH/cxx-typeid.cpp b/clang/test/PCH/cxx-typeid.cpp
new file mode 100644
index 0000000..41dd544
--- /dev/null
+++ b/clang/test/PCH/cxx-typeid.cpp
@@ -0,0 +1,9 @@
+// Test this without pch.
+// RUN: %clang -include %S/cxx-typeid.h -fsyntax-only -Xclang -verify %s
+
+// RUN: %clang -ccc-pch-is-pch -x c++-header -o %t.gch %S/cxx-typeid.h
+// RUN: %clang -ccc-pch-is-pch -include %t -fsyntax-only -Xclang -verify %s
+
+void f() {
+ (void)typeid(int);
+}
diff --git a/clang/test/PCH/cxx-typeid.h b/clang/test/PCH/cxx-typeid.h
new file mode 100644
index 0000000..aa3b16a
--- /dev/null
+++ b/clang/test/PCH/cxx-typeid.h
@@ -0,0 +1,3 @@
+// Header for PCH test cxx-typeid.cpp
+
+#include <typeinfo>
diff --git a/clang/test/PCH/cxx-using.cpp b/clang/test/PCH/cxx-using.cpp
new file mode 100644
index 0000000..2ca7dad
--- /dev/null
+++ b/clang/test/PCH/cxx-using.cpp
@@ -0,0 +1,15 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/cxx-using.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-using.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+void m() {
+ D s; // expected-note {{candidate function}}
+ s.f(); // expected-error {{no matching member}}
+}
+
+
+
+// expected-note {{candidate function}}
diff --git a/clang/test/PCH/cxx-using.h b/clang/test/PCH/cxx-using.h
new file mode 100644
index 0000000..572cea2
--- /dev/null
+++ b/clang/test/PCH/cxx-using.h
@@ -0,0 +1,16 @@
+// Header for PCH test cxx-using.cpp
+
+
+
+
+
+
+struct B {
+ void f(char c);
+};
+
+struct D : B
+{
+ using B::f;
+ void f(int);
+};
diff --git a/clang/test/PCH/cxx-variadic-templates.cpp b/clang/test/PCH/cxx-variadic-templates.cpp
new file mode 100644
index 0000000..5b58693
--- /dev/null
+++ b/clang/test/PCH/cxx-variadic-templates.cpp
@@ -0,0 +1,11 @@
+// Test this without pch.
+// RUN: %clang_cc1 -std=c++11 -include %S/cxx-variadic-templates.h -verify %s -ast-dump -o -
+// RUN: %clang_cc1 -std=c++11 -include %S/cxx-variadic-templates.h %s -emit-llvm -o - | FileCheck %s
+
+// Test with pch.
+// RUN: %clang_cc1 -std=c++11 -x c++-header -emit-pch -o %t %S/cxx-variadic-templates.h
+// RUN: %clang_cc1 -std=c++11 -include-pch %t -verify %s -ast-dump -o -
+// RUN: %clang_cc1 -std=c++11 -include-pch %t %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: allocate_shared
+shared_ptr<int> spi = shared_ptr<int>::allocate_shared(1, 2);
diff --git a/clang/test/PCH/cxx-variadic-templates.h b/clang/test/PCH/cxx-variadic-templates.h
new file mode 100644
index 0000000..f6ee787
--- /dev/null
+++ b/clang/test/PCH/cxx-variadic-templates.h
@@ -0,0 +1,18 @@
+// PR9073
+template<typename _Tp>
+class shared_ptr{
+public:
+ template<class _Alloc, class ..._Args>
+ static
+ shared_ptr<_Tp>
+ allocate_shared(const _Alloc& __a, _Args&& ...__args);
+};
+
+template<class _Tp>
+template<class _Alloc, class ..._Args>
+shared_ptr<_Tp>
+shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args)
+{
+ shared_ptr<_Tp> __r;
+ return __r;
+}
diff --git a/clang/test/PCH/cxx0x-default-delete.cpp b/clang/test/PCH/cxx0x-default-delete.cpp
new file mode 100644
index 0000000..6eb65d6
--- /dev/null
+++ b/clang/test/PCH/cxx0x-default-delete.cpp
@@ -0,0 +1,34 @@
+// Without PCH
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -include %s %s
+// With PCH
+// RUN: %clang_cc1 -x c++-header -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -include-pch %t %s
+
+#ifndef PASS1
+#define PASS1
+
+struct foo {
+ foo() = default;
+ void bar() = delete; // expected-note{{deleted here}}
+};
+
+struct baz {
+ ~baz() = delete; // expected-note{{deleted here}}
+};
+
+class quux {
+ ~quux() = default; // expected-note{{private here}}
+};
+
+#else
+
+foo::foo() { } // expected-error{{definition of explicitly defaulted default constructor}}
+foo f;
+void fn() {
+ f.bar(); // expected-error{{deleted function}}
+}
+
+baz bz; // expected-error{{deleted function}}
+quux qx; // expected-error{{private destructor}}
+
+#endif
diff --git a/clang/test/PCH/cxx0x-delegating-ctors.cpp b/clang/test/PCH/cxx0x-delegating-ctors.cpp
new file mode 100644
index 0000000..f2b7e90
--- /dev/null
+++ b/clang/test/PCH/cxx0x-delegating-ctors.cpp
@@ -0,0 +1,20 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -std=c++11 -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++-header -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -std=c++11 -include-pch %t -fsyntax-only -verify %s
+
+#ifndef PASS1
+#define PASS1
+struct foo {
+ foo(int) : foo() { } // expected-note{{it delegates to}}
+ foo();
+ foo(bool) : foo('c') { } // expected-note{{it delegates to}}
+ foo(char) : foo(true) { } // expected-error{{creates a delegation cycle}} \
+ // expected-note{{which delegates to}}
+};
+#else
+foo::foo() : foo(1) { } // expected-error{{creates a delegation cycle}} \
+ // expected-note{{which delegates to}}
+#endif
diff --git a/clang/test/PCH/cxx11-constexpr.cpp b/clang/test/PCH/cxx11-constexpr.cpp
new file mode 100644
index 0000000..338543e
--- /dev/null
+++ b/clang/test/PCH/cxx11-constexpr.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+
+struct B {
+ B(); // expected-note {{here}}
+ constexpr B(char) {}
+};
+
+struct C { // expected-note {{not an aggregate and has no constexpr constructors}}
+ B b;
+ double d = 0.0;
+};
+
+struct D : B {
+ constexpr D(int n) : B('x'), k(2*n+1) {}
+ int k;
+};
+
+#else
+
+static_assert(D(4).k == 9, "");
+constexpr int f(C c) { return 0; } // expected-error {{not a literal type}}
+constexpr B b; // expected-error {{constant expression}} expected-note {{non-constexpr}}
+
+#endif
diff --git a/clang/test/PCH/cxx11-enum-template.cpp b/clang/test/PCH/cxx11-enum-template.cpp
new file mode 100644
index 0000000..70b0ff9
--- /dev/null
+++ b/clang/test/PCH/cxx11-enum-template.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+
+template<typename T> struct S {
+ enum class E {
+ e = T() // expected-error {{conversion from 'double' to 'int'}}
+ };
+};
+
+S<int> a;
+S<long>::E b;
+S<double>::E c;
+template struct S<char>;
+
+#else
+
+int k1 = (int)S<int>::E::e;
+int k2 = (int)decltype(b)::e;
+int k3 = (int)decltype(c)::e; // expected-note {{here}}
+int k4 = (int)S<char>::E::e;
+
+#endif
diff --git a/clang/test/PCH/cxx11-exception-spec.cpp b/clang/test/PCH/cxx11-exception-spec.cpp
new file mode 100644
index 0000000..3fca4e4
--- /dev/null
+++ b/clang/test/PCH/cxx11-exception-spec.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+
+template<bool b> int f() noexcept(b) {}
+decltype(f<false>()) a;
+decltype(f<true>()) b;
+
+#else
+
+static_assert(!noexcept(f<false>()), "");
+static_assert(noexcept(f<true>()), "");
+
+#endif
diff --git a/clang/test/PCH/cxx11-lambdas.mm b/clang/test/PCH/cxx11-lambdas.mm
new file mode 100644
index 0000000..c00ec63
--- /dev/null
+++ b/clang/test/PCH/cxx11-lambdas.mm
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -pedantic-errors -fblocks -std=c++11 -emit-pch %s -o %t-cxx11
+// RUN: %clang_cc1 -ast-print -pedantic-errors -fblocks -std=c++11 -include-pch %t-cxx11 %s | FileCheck -check-prefix=CHECK-PRINT %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+template<typename T>
+T add_slowly(const T& x, const T &y) {
+ return [=, &y] { return x + y; }();
+};
+
+inline int add_int_slowly_twice(int x, int y) {
+ int i = add_slowly(x, y);
+ auto lambda = [&](int z) { return x + z; };
+ return i + lambda(y);
+}
+
+inline int sum_array(int n) {
+ int array[5] = { 1, 2, 3, 4, 5};
+ auto lambda = [=](int N) -> int {
+ int sum = 0;
+ for (unsigned I = 0; I < N; ++I)
+ sum += array[N];
+ return sum;
+ };
+
+ return lambda(n);
+}
+
+inline int to_block_pointer(int n) {
+ auto lambda = [=](int m) { return n + m; };
+ int (^block)(int) = lambda;
+ return block(17);
+}
+
+#else
+
+// CHECK-PRINT: T add_slowly
+// CHECK-PRINT: return [=, &y]
+template float add_slowly(const float&, const float&);
+
+int add(int x, int y) {
+ return add_int_slowly_twice(x, y) + sum_array(4) + to_block_pointer(5);
+}
+
+// CHECK-PRINT: inline int add_int_slowly_twice
+// CHECK-PRINT: lambda = [&] (int z)
+#endif
diff --git a/clang/test/PCH/cxx11-user-defined-literals.cpp b/clang/test/PCH/cxx11-user-defined-literals.cpp
new file mode 100644
index 0000000..4a7c24b
--- /dev/null
+++ b/clang/test/PCH/cxx11-user-defined-literals.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+
+using size_t = decltype(sizeof(int));
+int operator"" _foo(const char *p, size_t);
+
+template<typename T> auto f(T t) -> decltype(t + ""_foo) { return 0; } // expected-note {{substitution failure}}
+
+#else
+
+int j = ""_foo;
+int k = f(0);
+int *l = f(&k);
+struct S {};
+int m = f(S()); // expected-error {{no matching}}
+
+#endif
diff --git a/clang/test/PCH/cxx_exprs.cpp b/clang/test/PCH/cxx_exprs.cpp
new file mode 100644
index 0000000..4cd9bae
--- /dev/null
+++ b/clang/test/PCH/cxx_exprs.cpp
@@ -0,0 +1,39 @@
+// Test this without pch.
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx_exprs.h -std=c++11 -fsyntax-only -verify %s -ast-dump
+
+// Test with pch. Use '-ast-dump' to force deserialization of function bodies.
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -x c++-header -std=c++11 -emit-pch -o %t %S/cxx_exprs.h
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-dump
+
+int integer;
+double floating;
+char character;
+bool boolean;
+
+// CXXStaticCastExpr
+static_cast_result void_ptr = &integer;
+
+// CXXDynamicCastExpr
+Derived *d;
+dynamic_cast_result derived_ptr = d;
+
+// CXXReinterpretCastExpr
+reinterpret_cast_result void_ptr2 = &integer;
+
+// CXXConstCastExpr
+const_cast_result char_ptr = &character;
+
+// CXXFunctionalCastExpr
+functional_cast_result *double_ptr = &floating;
+
+// CXXBoolLiteralExpr
+bool_literal_result *bool_ptr = &boolean;
+static_assert(true_value, "true_value is true");
+static_assert(!false_value, "false_value is false");
+
+// CXXNullPtrLiteralExpr
+cxx_null_ptr_result null_ptr = nullptr;
+
+// CXXTypeidExpr
+typeid_result1 typeid_1 = 0;
+typeid_result2 typeid_2 = 0;
diff --git a/clang/test/PCH/cxx_exprs.h b/clang/test/PCH/cxx_exprs.h
new file mode 100644
index 0000000..67ab4a6
--- /dev/null
+++ b/clang/test/PCH/cxx_exprs.h
@@ -0,0 +1,83 @@
+// Header for PCH test cxx_exprs.cpp
+
+
+// CXXStaticCastExpr
+typedef __typeof__(static_cast<void *>(0)) static_cast_result;
+
+// CXXDynamicCastExpr
+struct Base { Base(int); virtual void f(int x = 492); ~Base(); };
+struct Derived : Base { Derived(); void g(); };
+Base *base_ptr;
+typedef __typeof__(dynamic_cast<Derived *>(base_ptr)) dynamic_cast_result;
+
+// CXXReinterpretCastExpr
+typedef __typeof__(reinterpret_cast<void *>(0)) reinterpret_cast_result;
+
+// CXXConstCastExpr
+const char *const_char_ptr_value;
+typedef __typeof__(const_cast<char *>(const_char_ptr_value)) const_cast_result;
+
+// CXXFunctionalCastExpr
+int int_value;
+typedef __typeof__(double(int_value)) functional_cast_result;
+
+// CXXBoolLiteralExpr
+typedef __typeof__(true) bool_literal_result;
+const bool true_value = true;
+const bool false_value = false;
+
+// CXXNullPtrLiteralExpr
+typedef __typeof__(nullptr) cxx_null_ptr_result;
+
+void foo(Derived *P) {
+ // CXXMemberCallExpr
+ P->f(12);
+}
+
+
+// FIXME: This is a hack until <typeinfo> works completely.
+namespace std {
+ class type_info {};
+}
+
+// CXXTypeidExpr - Both expr and type forms.
+typedef __typeof__(typeid(int))* typeid_result1;
+typedef __typeof__(typeid(2))* typeid_result2;
+
+Derived foo();
+
+Derived::Derived() : Base(4) {
+}
+
+void Derived::g() {
+ // CXXThisExpr
+ f(2); // Implicit
+ this->f(1); // Explicit
+
+ // CXXThrowExpr
+ throw;
+ throw 42;
+
+ // CXXDefaultArgExpr
+ f();
+
+ const Derived &X = foo();
+
+ // FIXME: How do I make a CXXBindReferenceExpr, CXXConstructExpr?
+
+ int A = int(0.5); // CXXFunctionalCastExpr
+ A = int(); // CXXZeroInitValueExpr
+
+ Base *b = new Base(4); // CXXNewExpr
+ delete b; // CXXDeleteExpr
+}
+
+
+// FIXME: The comment on CXXTemporaryObjectExpr is broken, this doesn't make
+// one.
+struct CtorStruct { CtorStruct(int, float); };
+
+CtorStruct create_CtorStruct() {
+ return CtorStruct(1, 3.14f); // CXXTemporaryObjectExpr
+};
+
diff --git a/clang/test/PCH/designated-init.c b/clang/test/PCH/designated-init.c
new file mode 100644
index 0000000..beb4dff
--- /dev/null
+++ b/clang/test/PCH/designated-init.c
@@ -0,0 +1,7 @@
+// Test this without pch.
+// RUN: %clang_cc1 %s -include %s.h -emit-llvm -o %t.withoutpch.ll
+
+// Test with pch.
+// RUN: %clang_cc1 %s.h -emit-pch -o %t.pch
+// RUN: %clang_cc1 %s -include-pch %t.pch -emit-llvm -o %t.withpch.ll
+// RUN: diff %t.withoutpch.ll %t.withpch.ll
diff --git a/clang/test/PCH/designated-init.c.h b/clang/test/PCH/designated-init.c.h
new file mode 100644
index 0000000..63b1f79
--- /dev/null
+++ b/clang/test/PCH/designated-init.c.h
@@ -0,0 +1,42 @@
+static void *FooToken = &FooToken;
+static void *FooTable[256] = {
+ [0x3] = (void *[256]) { // 1
+ [0x5b] = (void *[256]) { // 2
+ [0x81] = (void *[256]) { // 3
+ [0x42] = (void *[256]) { // 4
+ [0xa2] = (void *[256]) { // 5
+ [0xe] = (void *[256]) { // 6
+ [0x20] = (void *[256]) { // 7
+ [0xd7] = (void *[256]) { // 8
+ [0x39] = (void *[256]) { // 9
+ [0xf1] = (void *[256]) { // 10
+ [0xa4] = (void *[256]) { // 11
+ [0xa8] = (void *[256]) { // 12
+ [0x21] = (void *[256]) { // 13
+ [0x86] = (void *[256]) { // 14
+ [0x1d] = (void *[256]) { // 15
+ [0xdc] = (void *[256]) { // 16
+ [0xa5] = (void *[256]) { // 17
+ [0xef] = (void *[256]) { // 18
+ [0x9] = (void *[256]) { // 19
+ [0x34] = &FooToken,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+};
diff --git a/clang/test/PCH/enum.c b/clang/test/PCH/enum.c
new file mode 100644
index 0000000..10ceb7c
--- /dev/null
+++ b/clang/test/PCH/enum.c
@@ -0,0 +1,15 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/enum.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %S/enum.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+int i = Red;
+
+int return_enum_constant() {
+ int result = aRoundShape;
+ return result;
+}
+
+enum Shape s = Triangle;
diff --git a/clang/test/PCH/enum.h b/clang/test/PCH/enum.h
new file mode 100644
index 0000000..7dc4e63
--- /dev/null
+++ b/clang/test/PCH/enum.h
@@ -0,0 +1,16 @@
+/* Used in enum.c test */
+
+enum Color {
+ Red,
+ Green,
+ Blue
+};
+
+enum Shape {
+ Square,
+ Triangle = 17,
+ Rhombus,
+ Circle
+};
+
+enum Shape aRoundShape = Circle;
diff --git a/clang/test/PCH/exprs.c b/clang/test/PCH/exprs.c
new file mode 100644
index 0000000..5928abd
--- /dev/null
+++ b/clang/test/PCH/exprs.c
@@ -0,0 +1,98 @@
+// Test this without pch.
+// RUN: %clang_cc1 -fblocks -include %S/exprs.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -fblocks -o %t %S/exprs.h
+// RUN: %clang_cc1 -fblocks -include-pch %t -fsyntax-only -verify %s
+
+__SIZE_TYPE__ size_type_value;
+int integer;
+long long_integer;
+double floating;
+_Complex double floating_complex;
+
+// DeclRefExpr
+int_decl_ref *int_ptr1 = &integer;
+enum_decl_ref *enum_ptr1 = &integer;
+
+// IntegerLiteral
+integer_literal *int_ptr2 = &integer;
+long_literal *long_ptr1 = &long_integer;
+
+// FloatingLiteral + ParenExpr
+floating_literal *double_ptr = &floating;
+
+// ImaginaryLiteral
+imaginary_literal *cdouble_ptr = &floating_complex;
+
+// StringLiteral
+const char* printHello() {
+ return hello;
+}
+
+// CharacterLiteral
+char_literal *int_ptr3 = &integer;
+
+// UnaryOperator
+negate_enum *int_ptr4 = &integer;
+
+// OffsetOfExpr
+offsetof_type *offsetof_ptr = &size_type_value;
+
+// UnaryExprOrTypeTraitExpr
+typeof(sizeof(float)) size_t_value;
+typeof_sizeof *size_t_ptr = &size_t_value;
+typeof_sizeof2 *size_t_ptr2 = &size_t_value;
+
+// ArraySubscriptExpr
+array_subscript *double_ptr1_5 = &floating;
+
+// CallExpr
+call_returning_double *double_ptr2 = &floating;
+
+// MemberExpr
+member_ref_double *double_ptr3 = &floating;
+
+// BinaryOperator
+add_result *int_ptr5 = &integer;
+
+// CompoundAssignOperator
+addeq_result *int_ptr6 = &integer;
+
+add_result_with_typeinfo *int_typeinfo_ptr6;
+
+// ConditionalOperator
+conditional_operator *double_ptr4 = &floating;
+
+// CStyleCastExpr
+void_ptr vp1 = &integer;
+
+// CompoundLiteral
+struct S s;
+compound_literal *sptr = &s;
+
+// ExtVectorElementExpr
+ext_vector_element *double_ptr5 = &floating;
+
+// InitListExpr
+double get_from_double_array(unsigned Idx) { return double_array[Idx]; }
+
+/// DesignatedInitExpr
+float get_from_designated(unsigned Idx) {
+ return designated_inits[2].y;
+}
+
+// TypesCompatibleExpr
+types_compatible *int_ptr7 = &integer;
+
+// ChooseExpr
+choose_expr *int_ptr8 = &integer;
+
+// GNUNullExpr FIXME: needs C++
+//null_type null = __null;
+
+// ShuffleVectorExpr
+shuffle_expr *vec_ptr = &vec2;
+
+// GenericSelectionExpr
+generic_selection_expr *double_ptr6 = &floating;
diff --git a/clang/test/PCH/exprs.h b/clang/test/PCH/exprs.h
new file mode 100644
index 0000000..09a5013
--- /dev/null
+++ b/clang/test/PCH/exprs.h
@@ -0,0 +1,107 @@
+// Header for PCH test exprs.c
+
+// DeclRefExpr
+int i = 17;
+enum Enum { Enumerator = 18 };
+typedef typeof(i) int_decl_ref;
+typedef typeof(Enumerator) enum_decl_ref;
+
+// IntegerLiteral
+typedef typeof(17) integer_literal;
+typedef typeof(17l) long_literal;
+
+// FloatingLiteral and ParenExpr
+typedef typeof((42.5)) floating_literal;
+
+// ImaginaryLiteral
+typedef typeof(17.0i) imaginary_literal;
+
+// StringLiteral
+const char *hello = "Hello" "PCH" "World";
+
+// CharacterLiteral
+typedef typeof('a') char_literal;
+
+// UnaryOperator
+typedef typeof(-Enumerator) negate_enum;
+
+// OffsetOfExpr
+struct X {
+ int member;
+};
+struct Y {
+ struct X array[5];
+};
+struct Z {
+ struct Y y;
+};
+typedef typeof(__builtin_offsetof(struct Z, y.array[1 + 2].member))
+ offsetof_type;
+
+// UnaryExprOrTypeTraitExpr
+typedef typeof(sizeof(int)) typeof_sizeof;
+typedef typeof(sizeof(Enumerator)) typeof_sizeof2;
+
+// ArraySubscriptExpr
+extern double values[];
+typedef typeof(values[2]) array_subscript;
+
+// CallExpr
+double dplus(double x, double y);
+double d0, d1;
+typedef typeof((&dplus)(d0, d1)) call_returning_double;
+
+// MemberExpr
+struct S {
+ double x;
+};
+typedef typeof(((struct S*)0)->x) member_ref_double;
+
+// BinaryOperator
+typedef typeof(i + Enumerator) add_result;
+
+// CompoundAssignOperator
+typedef typeof(i += Enumerator) addeq_result;
+
+// ConditionalOperator
+typedef typeof(i? : d0) conditional_operator;
+
+// CStyleCastExpr
+typedef typeof((void *)0) void_ptr;
+
+// CompoundLiteral
+typedef typeof((struct S){.x = 3.5}) compound_literal;
+
+typedef typeof(i + sizeof(int[i + Enumerator])) add_result_with_typeinfo;
+
+// ExtVectorElementExpr
+typedef __attribute__(( ext_vector_type(2) )) double double2;
+extern double2 vec2, vec2b;
+typedef typeof(vec2.x) ext_vector_element;
+
+// InitListExpr
+double double_array[3] = { 1.0, 2.0 };
+
+// DesignatedInitExpr
+struct {
+ int x;
+ float y;
+} designated_inits[3] = { [0].y = 17,
+ [2].x = 12.3, // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+ 3.5 };
+
+// TypesCompatibleExpr
+typedef typeof(__builtin_types_compatible_p(float, double)) types_compatible;
+
+// ChooseExpr
+typedef typeof(__builtin_choose_expr(17 > 19, d0, 1)) choose_expr;
+
+// GNUNullExpr FIXME: needs C++
+// typedef typeof(__null) null_type;
+
+// ShuffleVectorExpr
+typedef typeof(__builtin_shufflevector(vec2, vec2b, 2, 1)) shuffle_expr;
+
+// GenericSelectionExpr
+typedef typeof(_Generic(i, char*: 0, int: 0., default: hello))
+ generic_selection_expr;
diff --git a/clang/test/PCH/ext_vector.c b/clang/test/PCH/ext_vector.c
new file mode 100644
index 0000000..bd129ea
--- /dev/null
+++ b/clang/test/PCH/ext_vector.c
@@ -0,0 +1,10 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/ext_vector.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %S/ext_vector.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+int test(float4 f4) {
+ return f4.xy; // expected-error{{float2}}
+}
diff --git a/clang/test/PCH/ext_vector.h b/clang/test/PCH/ext_vector.h
new file mode 100644
index 0000000..39ab923
--- /dev/null
+++ b/clang/test/PCH/ext_vector.h
@@ -0,0 +1,4 @@
+// Header file for ext_vector.c PCH test
+
+typedef __attribute__((ext_vector_type(2))) float float2;
+typedef __attribute__((ext_vector_type(4))) float float4;
diff --git a/clang/test/PCH/external-defs.c b/clang/test/PCH/external-defs.c
new file mode 100644
index 0000000..5097859
--- /dev/null
+++ b/clang/test/PCH/external-defs.c
@@ -0,0 +1,19 @@
+// Test with pch.
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t.pch %S/external-defs.h
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t.pch -emit-llvm -o %t %s
+
+// RUN: grep "@x = common global i32 0" %t | count 1
+// RUN: grep "@z" %t | count 0
+
+// RUN: grep "@x2 = global i32 19" %t | count 1
+int x2 = 19;
+
+// RUN: grep "@incomplete_array = common global .*1 x i32" %t | count 1
+// RUN: grep "@incomplete_array2 = common global .*17 x i32" %t | count 1
+int incomplete_array2[17];
+// RUN: grep "@incomplete_array3 = common global .*1 x i32" %t | count 1
+int incomplete_array3[];
+
+struct S {
+ int x, y;
+};
diff --git a/clang/test/PCH/external-defs.h b/clang/test/PCH/external-defs.h
new file mode 100644
index 0000000..657b47b
--- /dev/null
+++ b/clang/test/PCH/external-defs.h
@@ -0,0 +1,13 @@
+// Helper for external-defs.c test
+
+// Tentative definitions
+int x;
+int x2;
+
+// Should not show up
+static int z;
+
+int incomplete_array[];
+int incomplete_array2[];
+
+struct S s;
diff --git a/clang/test/PCH/functions.c b/clang/test/PCH/functions.c
new file mode 100644
index 0000000..35e3921
--- /dev/null
+++ b/clang/test/PCH/functions.c
@@ -0,0 +1,25 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/functions.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %S/functions.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+// expected-note{{'f1' declared here}}
+int f0(int x0, int y0, ...) { return x0 + y0; }
+// expected-note{{passing argument to parameter here}}
+float *test_f1(int val, double x, double y) {
+ if (val > 5)
+ return f1(x, y);
+ else
+ return f1(x); // expected-error{{too few arguments to function call}}
+}
+
+void test_g0(int *x, float * y) {
+ g0(y); // expected-warning{{incompatible pointer types passing 'float *' to parameter of type 'int *'}}
+ g0(x);
+}
+
+void __attribute__((noreturn)) test_abort(int code) {
+ do_abort(code);
+}
+
diff --git a/clang/test/PCH/functions.h b/clang/test/PCH/functions.h
new file mode 100644
index 0000000..f57400f
--- /dev/null
+++ b/clang/test/PCH/functions.h
@@ -0,0 +1,11 @@
+/* For use with the functions.c test */
+
+
+
+
+int f0(int x, int y, ...);
+float *f1(float x, float y);
+
+void g0(int *);
+
+void do_abort(int) __attribute__((noreturn));
diff --git a/clang/test/PCH/fuzzy-pch.c b/clang/test/PCH/fuzzy-pch.c
new file mode 100644
index 0000000..5675753
--- /dev/null
+++ b/clang/test/PCH/fuzzy-pch.c
@@ -0,0 +1,19 @@
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -DFOO -o %t %S/variables.h
+// RUN: %clang_cc1 -DBAR=int -include-pch %t -fsyntax-only -pedantic %s
+// RUN: %clang_cc1 -DFOO -DBAR=int -include-pch %t -Werror %s
+// RUN: not %clang_cc1 -DFOO -DBAR=int -DX=5 -include-pch %t -Werror %s
+
+BAR bar = 17;
+
+#ifndef FOO
+# error FOO was not defined
+#endif
+
+#if FOO != 1
+# error FOO has the wrong definition
+#endif
+
+#ifndef BAR
+# error BAR was not defined
+#endif
diff --git a/clang/test/PCH/fuzzy-pch.h b/clang/test/PCH/fuzzy-pch.h
new file mode 100644
index 0000000..9eb1005
--- /dev/null
+++ b/clang/test/PCH/fuzzy-pch.h
@@ -0,0 +1,2 @@
+// Header for PCH test fuzzy-pch.c
+void f(int X);
diff --git a/clang/test/PCH/headermap.h b/clang/test/PCH/headermap.h
new file mode 100644
index 0000000..efab2d8
--- /dev/null
+++ b/clang/test/PCH/headermap.h
@@ -0,0 +1,3 @@
+/* Helper for the headermap.m test */
+int x = 17;
+
diff --git a/clang/test/PCH/headermap.m b/clang/test/PCH/headermap.m
new file mode 100644
index 0000000..6ba83d7
--- /dev/null
+++ b/clang/test/PCH/headermap.m
@@ -0,0 +1,15 @@
+// RUN: touch %t.hmap
+
+// RUN: %clang_cc1 -x objective-c -emit-pch -o %t.h.pch %S/headermap.h
+// RUN: %clang_cc1 -include-pch %t.h.pch %s
+
+// RUN: %clang_cc1 -x objective-c -emit-pch -o %t.h.pch %S/headermap.h
+// RUN: %clang_cc1 -include-pch %t.h.pch -I%t.hmap %s
+
+// RUN: %clang_cc1 -x objective-c -I%t.hmap -emit-pch -o %t.h.pch %S/headermap.h
+// RUN: %clang_cc1 -include-pch %t.h.pch %s
+
+// RUN: %clang_cc1 -x objective-c -I%t.hmap -emit-pch -o %t.h.pch %S/headermap.h
+// RUN: %clang_cc1 -include-pch %t.h.pch -I%t.hmap %s
+#import "headermap.h"
+
diff --git a/clang/test/PCH/headersearch.cpp b/clang/test/PCH/headersearch.cpp
new file mode 100644
index 0000000..8ca0c36
--- /dev/null
+++ b/clang/test/PCH/headersearch.cpp
@@ -0,0 +1,44 @@
+// Test reading of PCH with changed location of original input files,
+// i.e. invoking header search.
+// REQUIRES: shell
+
+// Generate the original files:
+// RUN: rm -rf %t_orig %t_moved
+// RUN: mkdir -p %t_orig/sub %t_orig/sub2
+// RUN: echo 'struct orig_sub{char c; int i; };' > %t_orig/sub/orig_sub.h
+// RUN: echo 'void orig_sub2_1();' > %t_orig/sub2/orig_sub2_1.h
+// RUN: echo '#include "orig_sub2_1.h"' > %t_orig/sub2/orig_sub2.h
+// RUN: echo 'template <typename T> void tf() { orig_sub2_1(); T::foo(); }' >> %t_orig/sub2/orig_sub2.h
+// RUN: echo 'void foo() {}' > %t_orig/tmp2.h
+// RUN: echo '#include "tmp2.h"' > %t_orig/all.h
+// RUN: echo '#include "sub/orig_sub.h"' >> %t_orig/all.h
+// RUN: echo '#include "orig_sub2.h"' >> %t_orig/all.h
+// RUN: echo 'int all();' >> %t_orig/all.h
+
+// Generate the PCH:
+// RUN: cd %t_orig && %clang_cc1 -x c++ -emit-pch -o all.h.pch -Isub2 all.h
+// RUN: cp -pR %t_orig %t_moved
+
+// Check diagnostic with location in original source:
+// RUN: %clang_cc1 -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -Wpadded -emit-obj -o %t.o %s 2> %t.stderr
+// RUN: grep 'struct orig_sub' %t.stderr
+
+// Check diagnostic with 2nd location in original source:
+// RUN: not %clang_cc1 -DREDECL -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -emit-obj -o %t.o %s 2> %t.stderr
+// RUN: grep 'void foo' %t.stderr
+
+// Check diagnostic with instantiation location in original source:
+// RUN: not %clang_cc1 -DINSTANTIATION -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -emit-obj -o %t.o %s 2> %t.stderr
+// RUN: grep 'orig_sub2_1' %t.stderr
+
+void qq(orig_sub*) {all();}
+
+#ifdef REDECL
+float foo() {return 0;}
+#endif
+
+#ifdef INSTANTIATION
+void f() {
+ tf<int>();
+}
+#endif
diff --git a/clang/test/PCH/libroot/usr/include/reloc.h b/clang/test/PCH/libroot/usr/include/reloc.h
new file mode 100644
index 0000000..04eeacb
--- /dev/null
+++ b/clang/test/PCH/libroot/usr/include/reloc.h
@@ -0,0 +1,15 @@
+#ifndef RELOC_H
+#define RELOC_H
+
+#include <reloc2.h>
+
+
+
+
+
+
+
+// Line number 13 below is important
+int x = 2;
+
+#endif // RELOC_H
diff --git a/clang/test/PCH/libroot/usr/include/reloc2.h b/clang/test/PCH/libroot/usr/include/reloc2.h
new file mode 100644
index 0000000..995415c
--- /dev/null
+++ b/clang/test/PCH/libroot/usr/include/reloc2.h
@@ -0,0 +1,15 @@
+#ifndef RELOC2_H
+#define RELOC2_H
+#include <stddef.h>
+
+
+
+
+
+
+
+
+
+// Line number below is important!
+int y = 2;
+#endif // RELOC2_H
diff --git a/clang/test/PCH/line-directive.c b/clang/test/PCH/line-directive.c
new file mode 100644
index 0000000..4710c40
--- /dev/null
+++ b/clang/test/PCH/line-directive.c
@@ -0,0 +1,25 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/line-directive.h -fsyntax-only %s 2>&1|grep "25:5"
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %S/line-directive.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only %s 2>&1|grep "25:5"
+
+double x; // expected-error{{redefinition of 'x' with a different type}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+// expected-note{{previous definition is here}}
diff --git a/clang/test/PCH/line-directive.h b/clang/test/PCH/line-directive.h
new file mode 100644
index 0000000..c5594b4
--- /dev/null
+++ b/clang/test/PCH/line-directive.h
@@ -0,0 +1,2 @@
+#line 25 "line-directive.c"
+int x;
diff --git a/clang/test/PCH/method-redecls.m b/clang/test/PCH/method-redecls.m
new file mode 100644
index 0000000..9d02b6a
--- /dev/null
+++ b/clang/test/PCH/method-redecls.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -x objective-c %s -emit-pch -o %t
+// RUN: %clang_cc1 -x objective-c %s -emit-pch -o %t -D IMPL
+
+// Avoid infinite loop because of method redeclarations.
+
+@interface Foo
+-(void)meth;
+-(void)meth;
+-(void)meth;
+@end
+
+#ifdef IMPL
+
+@implementation Foo
+-(void)meth { }
+@end
+
+#endif
diff --git a/clang/test/PCH/method_pool.h b/clang/test/PCH/method_pool.h
new file mode 100644
index 0000000..8085836
--- /dev/null
+++ b/clang/test/PCH/method_pool.h
@@ -0,0 +1,36 @@
+/* For use with the method_pool.m test */
+
+/* Whitespace below is significant */
+
+
+
+
+
+
+
+
+
+
+
+@interface TestMethodPool1
++ alloc;
+- (double)instMethod:(int)foo;
+@end
+
+@interface TestMethodPool2
+- (char)instMethod:(int)foo;
+@end
+
+@implementation TestMethodPool1
++ alloc { return 0; }
+
+- (double)instMethod:(int)foo {
+ return foo;
+}
+@end
+
+@implementation TestMethodPool2
+- (char)instMethod:(int)foo {
+ return foo;
+}
+@end
diff --git a/clang/test/PCH/method_pool.m b/clang/test/PCH/method_pool.m
new file mode 100644
index 0000000..20010fb
--- /dev/null
+++ b/clang/test/PCH/method_pool.m
@@ -0,0 +1,21 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/method_pool.h -fsyntax-only -verify -Wno-objc-root-class %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x objective-c -Wno-objc-root-class -emit-pch -o %t %S/method_pool.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify -Wno-objc-root-class %s
+
+int message_id(id x) {
+ return [x instMethod:17]; // expected-warning{{multiple methods}}
+}
+
+
+
+
+
+/* Whitespace below is significant */
+/* expected-note{{using}} */
+
+
+
+/* expected-note{{also}} */
diff --git a/clang/test/PCH/missing-file.cpp b/clang/test/PCH/missing-file.cpp
new file mode 100644
index 0000000..7d5cd11
--- /dev/null
+++ b/clang/test/PCH/missing-file.cpp
@@ -0,0 +1,31 @@
+// Test reading of PCH without original input files.
+
+// Generate the PCH, removing the original file:
+// RUN: echo 'struct S{char c; int i; }; void foo() {}' > %t.h
+// RUN: echo 'template <typename T> void tf() { T::foo(); }' >> %t.h
+// RUN: %clang_cc1 -x c++ -emit-pch -o %t.h.pch %t.h
+// RUN: rm %t.h
+
+// Check diagnostic with location in original source:
+// RUN: %clang_cc1 -include-pch %t.h.pch -Wpadded -emit-obj -o %t.o %s 2> %t.stderr
+// RUN: grep 'bytes to align' %t.stderr
+
+// Check diagnostic with 2nd location in original source:
+// RUN: not %clang_cc1 -DREDECL -include-pch %t.h.pch -emit-obj -o %t.o %s 2> %t.stderr
+// RUN: grep 'previous definition is here' %t.stderr
+
+// Check diagnostic with instantiation location in original source:
+// RUN: not %clang_cc1 -DINSTANTIATION -include-pch %t.h.pch -emit-obj -o %t.o %s 2> %t.stderr
+// RUN: grep 'cannot be used prior to' %t.stderr
+
+void qq(S*) {}
+
+#ifdef REDECL
+float foo() {return 0f;}
+#endif
+
+#ifdef INSTANTIATION
+void f() {
+ tf<int>();
+}
+#endif
diff --git a/clang/test/PCH/modified-header-crash.c b/clang/test/PCH/modified-header-crash.c
new file mode 100644
index 0000000..c74ce22
--- /dev/null
+++ b/clang/test/PCH/modified-header-crash.c
@@ -0,0 +1,10 @@
+// Don't crash.
+
+// RUN: cp %S/modified-header-crash.h %t.h
+// RUN: %clang_cc1 -DCAKE -x c-header %t.h -emit-pch -o %t
+// RUN: echo >> %t.h
+// RUN: not %clang_cc1 %s -include-pch %t -fsyntax-only
+
+void f(void) {
+ foo = 3;
+}
diff --git a/clang/test/PCH/modified-header-crash.h b/clang/test/PCH/modified-header-crash.h
new file mode 100644
index 0000000..971746e
--- /dev/null
+++ b/clang/test/PCH/modified-header-crash.h
@@ -0,0 +1 @@
+int foo;
diff --git a/clang/test/PCH/modified-header-error.c b/clang/test/PCH/modified-header-error.c
new file mode 100644
index 0000000..ef92494
--- /dev/null
+++ b/clang/test/PCH/modified-header-error.c
@@ -0,0 +1,12 @@
+// RUN: mkdir -p %t.dir
+// RUN: echo '#include "header2.h"' > %t.dir/header1.h
+// RUN: echo > %t.dir/header2.h
+// RUN: cp %s %t.dir/t.c
+// RUN: %clang_cc1 -x c-header %t.dir/header1.h -emit-pch -o %t.pch
+// RUN: echo >> %t.dir/header2.h
+// RUN: %clang_cc1 %t.dir/t.c -include-pch %t.pch -fsyntax-only 2>&1 | FileCheck %s
+
+#include "header2.h"
+
+// CHECK: fatal error: file {{.*}} has been modified since the precompiled header was built
+// REQUIRES: shell
diff --git a/clang/test/PCH/ms-if-exists.cpp b/clang/test/PCH/ms-if-exists.cpp
new file mode 100644
index 0000000..4bea198
--- /dev/null
+++ b/clang/test/PCH/ms-if-exists.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -x c++ -fms-extensions -fsyntax-only -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -fms-extensions -fsyntax-only -include-pch %t %s -verify
+
+#ifndef HEADER
+#define HEADER
+template<typename T>
+void f(T t) {
+ __if_exists(T::foo) {
+ { }
+ t.foo();
+ }
+
+ __if_not_exists(T::bar) {
+ int *i = t; // expected-error{{no viable conversion from 'HasFoo' to 'int *'}}
+ { }
+ }
+}
+#else
+struct HasFoo {
+ void foo();
+};
+struct HasBar {
+ void bar(int);
+ void bar(float);
+};
+
+template void f(HasFoo); // expected-note{{in instantiation of function template specialization 'f<HasFoo>' requested here}}
+template void f(HasBar);
+#endif
diff --git a/clang/test/PCH/multiple_decls.c b/clang/test/PCH/multiple_decls.c
new file mode 100644
index 0000000..e2cc552
--- /dev/null
+++ b/clang/test/PCH/multiple_decls.c
@@ -0,0 +1,17 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/multiple_decls.h -fsyntax-only -ast-print -o - %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %S/multiple_decls.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -ast-print -o - %s
+
+void f0(char c) {
+ wide(c);
+}
+
+struct wide w;
+struct narrow n;
+
+void f1(int i) {
+ narrow(i);
+}
diff --git a/clang/test/PCH/multiple_decls.h b/clang/test/PCH/multiple_decls.h
new file mode 100644
index 0000000..23696b0
--- /dev/null
+++ b/clang/test/PCH/multiple_decls.h
@@ -0,0 +1,7 @@
+// Header for PCH test multiple_decls.c
+
+struct wide { int value; };
+int wide(char);
+
+struct narrow { char narrow; };
+char narrow(int);
diff --git a/clang/test/PCH/namespaces.cpp b/clang/test/PCH/namespaces.cpp
new file mode 100644
index 0000000..6dd4473
--- /dev/null
+++ b/clang/test/PCH/namespaces.cpp
@@ -0,0 +1,45 @@
+// Test this without pch.
+// RUN: %clang_cc1 -x c++ -include %S/Inputs/namespaces.h -fsyntax-only %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++ -emit-pch -o %t %S/Inputs/namespaces.h
+// RUN: %clang_cc1 -x c++ -include-pch %t -fsyntax-only %s
+
+int int_val;
+N1::t1 *ip1 = &int_val;
+N1::t2 *ip2 = &int_val;
+N2::Inner::t3 *ip3 = &int_val;
+
+float float_val;
+namespace N2 { }
+N2::t1 *fp1 = &float_val;
+
+Alias1::t3 *ip4 = &int_val;
+t3 *ip5 = &int_val;
+
+void(*funp1)() = anon;
+
+namespace {
+ class C;
+}
+C* cp1;
+
+namespace N3 {
+ namespace {
+ class C;
+ }
+}
+
+N3::C *cp2;
+
+void(*funp2)() = ext;
+
+using N1::used_func;
+void (*pused)() = used_func;
+
+using N1::used_cls;
+used_cls s1;
+used_cls* ps1 = &s1;
+
+inline namespace N4 { }
+struct MemberOfN4 *mn4;
diff --git a/clang/test/PCH/nonvisible-external-defs.c b/clang/test/PCH/nonvisible-external-defs.c
new file mode 100644
index 0000000..49392ca
--- /dev/null
+++ b/clang/test/PCH/nonvisible-external-defs.c
@@ -0,0 +1,10 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/nonvisible-external-defs.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %S/nonvisible-external-defs.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+int g(int, float); // expected-error{{conflicting types}}
+
+// expected-note{{previous declaration}}
diff --git a/clang/test/PCH/nonvisible-external-defs.h b/clang/test/PCH/nonvisible-external-defs.h
new file mode 100644
index 0000000..a36fc2e
--- /dev/null
+++ b/clang/test/PCH/nonvisible-external-defs.h
@@ -0,0 +1,11 @@
+// Helper for PCH test nonvisible-external-defs.h
+
+
+
+
+
+
+
+void f() {
+ extern int g(int, int);
+}
diff --git a/clang/test/PCH/objc_container.h b/clang/test/PCH/objc_container.h
new file mode 100644
index 0000000..c83f902
--- /dev/null
+++ b/clang/test/PCH/objc_container.h
@@ -0,0 +1,26 @@
+@protocol P @end
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(unsigned int)index;
+- (void)setObject:(id)object atIndexedSubscript:(unsigned int)index;
+@end
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id)key;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+void all() {
+ NSMutableArray *array;
+ id oldObject = array[10];
+
+ array[10] = oldObject;
+
+ NSMutableDictionary *dictionary;
+ id key;
+ id newObject;
+ oldObject = dictionary[key];
+
+ dictionary[key] = newObject;
+}
+
diff --git a/clang/test/PCH/objc_container.m b/clang/test/PCH/objc_container.m
new file mode 100644
index 0000000..1e59054
--- /dev/null
+++ b/clang/test/PCH/objc_container.m
@@ -0,0 +1,20 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/objc_container.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x objective-c -emit-pch -o %t %S/objc_container.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+// RUN: %clang -cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=PRINT %s
+// RUN: %clang -cc1 -include-pch %t -emit-llvm -o - %s | FileCheck -check-prefix=IR %s
+
+// CHECK-PRINT: id oldObject = array[10];
+// CHECK-PRINT: array[10] = oldObject;
+// CHECK-PRINT: oldObject = dictionary[key];
+// CHECK-PRINT: dictionary[key] = newObject;
+
+// CHECK-IR: define void @all() nounwind
+// CHECK-IR: {{call.*objc_msgSend}}
+// CHECK-IR: {{call.*objc_msgSend}}
+// CHECK-IR: {{call.*objc_msgSend}}
+// CHECK-IR: {{call.*objc_msgSend}}
+// CHECK-IR: ret void
diff --git a/clang/test/PCH/objc_exprs.h b/clang/test/PCH/objc_exprs.h
new file mode 100644
index 0000000..807304c
--- /dev/null
+++ b/clang/test/PCH/objc_exprs.h
@@ -0,0 +1,26 @@
+
+@protocol foo;
+@class itf;
+
+// Expressions
+typedef typeof(@"foo" "bar") objc_string;
+typedef typeof(@encode(int)) objc_encode;
+typedef typeof(@protocol(foo)) objc_protocol;
+typedef typeof(@selector(noArgs)) objc_selector_noArgs;
+typedef typeof(@selector(oneArg:)) objc_selector_oneArg;
+typedef typeof(@selector(foo:bar:)) objc_selector_twoArg;
+
+
+// Types.
+typedef typeof(id<foo>) objc_id_protocol_ty;
+
+typedef typeof(itf*) objc_interface_ty;
+typedef typeof(itf<foo>*) objc_qual_interface_ty;
+
+@interface PP
+@property (assign) id prop;
+@end
+
+static inline id getPseudoObject(PP *p) {
+ return p.prop;
+}
diff --git a/clang/test/PCH/objc_exprs.m b/clang/test/PCH/objc_exprs.m
new file mode 100644
index 0000000..1f971e7
--- /dev/null
+++ b/clang/test/PCH/objc_exprs.m
@@ -0,0 +1,27 @@
+// Test this without pch.
+// RUN: %clang_cc1 -fblocks -include %S/objc_exprs.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x objective-c-header -emit-pch -fblocks -o %t %S/objc_exprs.h
+// RUN: %clang_cc1 -fblocks -include-pch %t -fsyntax-only -verify %s
+
+// Expressions
+int *A1 = (objc_string)0; // expected-warning {{aka 'NSString *'}}
+
+char A2 = (objc_encode){}; // expected-error {{not a compile-time constant}} \
+ expected-warning {{char [2]}}
+
+int *A3 = (objc_protocol)0; // expected-warning {{aka 'Protocol *'}}
+
+
+// Types.
+int *T0 = (objc_id_protocol_ty)0; // expected-warning {{aka 'id<foo>'}}
+
+int *T1 = (objc_interface_ty)0; // expected-warning {{aka 'itf *'}}
+int *T2 = (objc_qual_interface_ty)0; // expected-warning {{aka 'itf<foo> *'}}
+
+objc_selector_noArgs s1;
+objc_selector_oneArg s2;
+objc_selector_twoArg s3;
+
+
diff --git a/clang/test/PCH/objc_import.h b/clang/test/PCH/objc_import.h
new file mode 100644
index 0000000..8af87ab
--- /dev/null
+++ b/clang/test/PCH/objc_import.h
@@ -0,0 +1,7 @@
+/* For use with the objc_import.m test */
+
+@interface TestPCH
++ alloc;
+- (void)instMethod;
+@end
+
diff --git a/clang/test/PCH/objc_import.m b/clang/test/PCH/objc_import.m
new file mode 100644
index 0000000..277c6dd
--- /dev/null
+++ b/clang/test/PCH/objc_import.m
@@ -0,0 +1,15 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/objc_import.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x objective-c -emit-pch -o %t %S/objc_import.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+#import "objc_import.h"
+
+void func() {
+ TestPCH *xx;
+
+ xx = [TestPCH alloc];
+ [xx instMethod];
+}
diff --git a/clang/test/PCH/objc_literals.m b/clang/test/PCH/objc_literals.m
new file mode 100644
index 0000000..cce3173
--- /dev/null
+++ b/clang/test/PCH/objc_literals.m
@@ -0,0 +1,66 @@
+// RUN: %clang -cc1 -emit-pch -o %t %s
+// RUN: %clang -cc1 -include-pch %t -verify %s
+// RUN: %clang -cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=PRINT %s
+// RUN: %clang -cc1 -include-pch %t -emit-llvm -o - %s | FileCheck -check-prefix=IR %s
+
+#ifndef HEADER
+#define HEADER
+
+typedef unsigned char BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
++ (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;
+@end
+
+@interface NSArray
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+// CHECK-IR: define internal void @test_numeric_literals()
+static inline void test_numeric_literals() {
+ // CHECK-PRINT: id intlit = @17
+ // CHECK-IR: {{call.*17}}
+ id intlit = @17;
+ // CHECK-PRINT: id floatlit = @17.45
+ // CHECK-IR: {{call.*1.745}}
+ id floatlit = @17.45;
+}
+
+static inline void test_array_literals() {
+ // CHECK-PRINT: id arraylit = @[ @17, @17.45
+ id arraylit = @[@17, @17.45];
+}
+
+static inline void test_dictionary_literals() {
+ // CHECK-PRINT: id dictlit = @{ @17 : {{@17.45[^,]*}}, @"hello" : @"world" };
+ id dictlit = @{@17 : @17.45, @"hello" : @"world" };
+}
+
+#else
+void test_all() {
+ test_numeric_literals();
+ test_array_literals();
+ test_dictionary_literals();
+}
+#endif
diff --git a/clang/test/PCH/objc_literals.mm b/clang/test/PCH/objc_literals.mm
new file mode 100644
index 0000000..8ef3351
--- /dev/null
+++ b/clang/test/PCH/objc_literals.mm
@@ -0,0 +1,65 @@
+// RUN: %clang -cc1 -emit-pch -x objective-c++ -std=c++0x -o %t %s
+// RUN: %clang -cc1 -include-pch %t -x objective-c++ -std=c++0x -verify %s
+// RUN: %clang -cc1 -include-pch %t -x objective-c++ -std=c++0x -ast-print %s | FileCheck -check-prefix=PRINT %s
+// RUN: %clang -cc1 -include-pch %t -x objective-c++ -std=c++0x -emit-llvm -o - %s | FileCheck -check-prefix=IR %s
+
+#ifndef HEADER
+#define HEADER
+
+typedef unsigned char BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
++ (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;
+@end
+
+@interface NSArray
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+template<typename T, typename U>
+struct pair {
+ T first;
+ U second;
+};
+
+template<typename T, typename U>
+pair<T, U> make_pair(const T& first, const U& second) {
+ return { first, second };
+}
+
+// CHECK-IR: define linkonce_odr void @_Z29variadic_dictionary_expansionIJP8NSStringS1_EJP8NSNumberS3_EEvDp4pairIT_T0_E
+template<typename ...Ts, typename ... Us>
+void variadic_dictionary_expansion(pair<Ts, Us>... key_values) {
+ // CHECK-PRINT: id dict = @{ key_values.first : key_values.second... };
+ // CHECK-IR: {{call.*objc_msgSend}}
+ // CHECK-IR: ret void
+ id dict = @{ key_values.first : key_values.second ... };
+}
+
+#else
+void test_all() {
+ variadic_dictionary_expansion(make_pair(@"Seventeen", @17),
+ make_pair(@"YES", @true));
+}
+#endif
diff --git a/clang/test/PCH/objc_methods.h b/clang/test/PCH/objc_methods.h
new file mode 100644
index 0000000..c9b1ad4
--- /dev/null
+++ b/clang/test/PCH/objc_methods.h
@@ -0,0 +1,11 @@
+/* For use with the methods.m test */
+
+@interface TestPCH
++ alloc;
+- (instancetype)instMethod;
+@end
+
+@class TestForwardClassDecl;
+
+// FIXME: @compatibility_alias AliasForTestPCH TestPCH;
+
diff --git a/clang/test/PCH/objc_methods.m b/clang/test/PCH/objc_methods.m
new file mode 100644
index 0000000..e90a463
--- /dev/null
+++ b/clang/test/PCH/objc_methods.m
@@ -0,0 +1,16 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/objc_methods.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x objective-c -emit-pch -o %t %S/objc_methods.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+void func() {
+ TestPCH *xx;
+ TestForwardClassDecl *yy;
+// FIXME:
+// AliasForTestPCH *zz;
+
+ xx = [TestPCH alloc];
+ [xx instMethod];
+}
diff --git a/clang/test/PCH/objc_property.h b/clang/test/PCH/objc_property.h
new file mode 100644
index 0000000..2432370
--- /dev/null
+++ b/clang/test/PCH/objc_property.h
@@ -0,0 +1,12 @@
+/* For use with the objc_property.m PCH test */
+@interface TestProperties
+{
+ int value;
+ float percentage;
+}
+
++ alloc;
+
+@property int value;
+@property float percentage;
+@end
diff --git a/clang/test/PCH/objc_property.m b/clang/test/PCH/objc_property.m
new file mode 100644
index 0000000..b51cd90
--- /dev/null
+++ b/clang/test/PCH/objc_property.m
@@ -0,0 +1,11 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/objc_property.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x objective-c -emit-pch -o %t %S/objc_property.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+void func() {
+ TestProperties *xx = [TestProperties alloc];
+ xx.value = 5;
+}
diff --git a/clang/test/PCH/objc_stmts.h b/clang/test/PCH/objc_stmts.h
new file mode 100644
index 0000000..5f705df
--- /dev/null
+++ b/clang/test/PCH/objc_stmts.h
@@ -0,0 +1,22 @@
+/* For use with the methods.m test */
+
+@interface A
+@end
+
+@interface B
+@end
+
+@interface TestPCH
+- (void)instMethod;
+@end
+
+@implementation TestPCH
+- (void)instMethod {
+ @try {
+ } @catch(A *a) {
+ } @catch(B *b) {
+ } @catch(...) {
+ } @finally {
+ }
+}
+@end
diff --git a/clang/test/PCH/objc_stmts.m b/clang/test/PCH/objc_stmts.m
new file mode 100644
index 0000000..3bc728c
--- /dev/null
+++ b/clang/test/PCH/objc_stmts.m
@@ -0,0 +1,12 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/objc_stmts.h -emit-llvm -fobjc-exceptions -o - %s
+// RUN: %clang_cc1 -include %S/objc_stmts.h -ast-dump -fobjc-exceptions -o - %s 2>&1 | FileCheck %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x objective-c -emit-pch -fobjc-exceptions -o %t %S/objc_stmts.h
+// RUN: %clang_cc1 -include-pch %t -emit-llvm -fobjc-exceptions -o - %s
+// RUN: %clang_cc1 -include-pch %t -ast-dump -fobjc-exceptions -o - %s 2>&1 | FileCheck %s
+
+// CHECK: catch parm = "A *a"
+// CHECK: catch parm = "B *b"
+// CHECK: catch all
diff --git a/clang/test/PCH/objcxx-ivar-class.h b/clang/test/PCH/objcxx-ivar-class.h
new file mode 100644
index 0000000..5e55658
--- /dev/null
+++ b/clang/test/PCH/objcxx-ivar-class.h
@@ -0,0 +1,16 @@
+struct S {
+ S();
+ S(const S&);
+ ~S();
+ S& operator= (const S&);
+};
+
+@interface C {
+ S position;
+}
+@property(assign, nonatomic) S position;
+@end
+
+@implementation C
+ @synthesize position;
+@end
diff --git a/clang/test/PCH/objcxx-ivar-class.mm b/clang/test/PCH/objcxx-ivar-class.mm
new file mode 100644
index 0000000..8214957
--- /dev/null
+++ b/clang/test/PCH/objcxx-ivar-class.mm
@@ -0,0 +1,15 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/objcxx-ivar-class.h -verify %s -emit-llvm -o - | FileCheck %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x objective-c++-header -emit-pch -o %t %S/objcxx-ivar-class.h
+// RUN: %clang_cc1 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: [C position]
+// CHECK: call {{.*}} @_ZN1SC1ERKS_
+
+// CHECK: [C setPosition:]
+// CHECK: call %struct.S* @_ZN1SaSERKS_
+
+// CHECK: [C .cxx_destruct]
+// CHECK: [C .cxx_construct]
diff --git a/clang/test/PCH/opencl-extensions.cl b/clang/test/PCH/opencl-extensions.cl
new file mode 100644
index 0000000..a22b007
--- /dev/null
+++ b/clang/test/PCH/opencl-extensions.cl
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only %s
+
+#ifndef HEADER
+#define HEADER
+// Header.
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+#else
+// Using the header.
+
+void test(void) {
+ double d;
+}
+
+#endif
diff --git a/clang/test/PCH/pchpch.c b/clang/test/PCH/pchpch.c
new file mode 100644
index 0000000..d68a6ad
--- /dev/null
+++ b/clang/test/PCH/pchpch.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-pch -o %t1 %S/pchpch1.h
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-pch -o %t2 %S/pchpch2.h -include-pch %t1
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fsyntax-only %s -include-pch %t2
+
+// The purpose of this test is to make sure that a PCH created while including
+// an existing PCH can be loaded.
diff --git a/clang/test/PCH/pchpch1.h b/clang/test/PCH/pchpch1.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/PCH/pchpch1.h
diff --git a/clang/test/PCH/pchpch2.h b/clang/test/PCH/pchpch2.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/PCH/pchpch2.h
diff --git a/clang/test/PCH/pending-ids.m b/clang/test/PCH/pending-ids.m
new file mode 100644
index 0000000..b612d89
--- /dev/null
+++ b/clang/test/PCH/pending-ids.m
@@ -0,0 +1,33 @@
+// Test for rdar://10278815
+
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -include %s %s
+
+// With PCH
+// RUN: %clang_cc1 %s -emit-pch -o %t
+// RUN: %clang_cc1 -emit-llvm-only -verify %s -include-pch %t -g
+
+#ifndef HEADER
+#define HEADER
+//===----------------------------------------------------------------------===//
+// Header
+
+typedef char BOOL;
+
+@interface NSString
++ (BOOL)meth;
+@end
+
+static NSString * const cake = @"cake";
+
+//===----------------------------------------------------------------------===//
+#else
+//===----------------------------------------------------------------------===//
+
+@interface Foo {
+ BOOL ivar;
+}
+@end
+
+//===----------------------------------------------------------------------===//
+#endif
diff --git a/clang/test/PCH/pr4489.c b/clang/test/PCH/pr4489.c
new file mode 100644
index 0000000..033e55b
--- /dev/null
+++ b/clang/test/PCH/pr4489.c
@@ -0,0 +1,48 @@
+// RUN: %clang -x c-header -o %t.pch %s
+// RUN: echo > %t.empty.c
+// RUN: %clang -include %t -x c %t.empty.c -emit-llvm -S -o -
+
+// FIXME: This test is forcibly disabled, it is flaky on the clang-i686-xp-msvc9
+// buildbot.
+//
+// RUN: false
+// XFAIL: *
+
+// PR 4489: Crash with PCH
+// PR 4492: Crash with PCH (round two)
+// PR 4509: Crash with PCH (round three)
+typedef struct _IO_FILE FILE;
+extern int fprintf (struct _IO_FILE *__restrict __stream,
+ __const char *__restrict __format, ...);
+
+int x(void)
+{
+ switch (1) {
+ case 2: ;
+ int y = 0;
+ }
+}
+
+void y(void) {
+ extern char z;
+ fprintf (0, "a");
+}
+
+struct y0 { int i; } y0[1] = {};
+
+void x0(void)
+{
+ extern char z0;
+ fprintf (0, "a");
+}
+
+void x1(void)
+{
+ fprintf (0, "asdf");
+}
+
+void y1(void)
+{
+ extern char e;
+ fprintf (0, "asdf");
+}
diff --git a/clang/test/PCH/pragma-diag-section.cpp b/clang/test/PCH/pragma-diag-section.cpp
new file mode 100644
index 0000000..5b996bb
--- /dev/null
+++ b/clang/test/PCH/pragma-diag-section.cpp
@@ -0,0 +1,29 @@
+// Test this without pch.
+// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only
+
+// Test with pch.
+// RUN: %clang_cc1 %s -emit-pch -o %t
+// RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only
+
+#ifndef HEADER
+#define HEADER
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-compare"
+template <typename T>
+struct TS {
+ void m() {
+ T a = 0;
+ T b = a==a;
+ }
+};
+#pragma clang diagnostic pop
+
+#else
+
+void f() {
+ TS<int> ts;
+ ts.m();
+}
+
+#endif
diff --git a/clang/test/PCH/pragma-diag.c b/clang/test/PCH/pragma-diag.c
new file mode 100644
index 0000000..b304c4b
--- /dev/null
+++ b/clang/test/PCH/pragma-diag.c
@@ -0,0 +1,20 @@
+// Test this without pch.
+// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only
+
+// Test with pch.
+// RUN: %clang_cc1 %s -emit-pch -o %t
+// RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only
+
+#ifndef HEADER
+#define HEADER
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+#else
+
+void f() {
+ int a = 0;
+ int b = a==a;
+}
+
+#endif
diff --git a/clang/test/PCH/pragma-weak.c b/clang/test/PCH/pragma-weak.c
new file mode 100644
index 0000000..18b45c8
--- /dev/null
+++ b/clang/test/PCH/pragma-weak.c
@@ -0,0 +1,10 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/pragma-weak.h %s -verify -emit-llvm -o - | FileCheck %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c-header -emit-pch -o %t %S/pragma-weak.h
+// RUN: %clang_cc1 -include-pch %t %s -verify -emit-llvm -o - | FileCheck %s
+
+// CHECK: @weakvar = weak global i32 0
+int weakvar;
+// expected-warning {{weak identifier 'undeclaredvar' never declared}}
diff --git a/clang/test/PCH/pragma-weak.h b/clang/test/PCH/pragma-weak.h
new file mode 100644
index 0000000..42ecd50
--- /dev/null
+++ b/clang/test/PCH/pragma-weak.h
@@ -0,0 +1,10 @@
+// Header for PCH test pragma-weak.c
+
+#pragma weak weakvar
+
+
+
+
+
+
+#pragma weak undeclaredvar
diff --git a/clang/test/PCH/preamble.c b/clang/test/PCH/preamble.c
new file mode 100644
index 0000000..6a61fa1
--- /dev/null
+++ b/clang/test/PCH/preamble.c
@@ -0,0 +1,23 @@
+// Check that using the preamble option actually skips the preamble.
+
+// RUN: %clang_cc1 -emit-pch -o %t %S/Inputs/preamble.h -DFOO=f
+// RUN: %clang_cc1 -include-pch %t -preamble-bytes=317,1 -DFOO=f -verify %s -emit-llvm -o - | FileCheck %s
+
+float f(int); // Not an error, because we skip this via the preamble!
+
+
+
+
+
+
+
+
+
+
+
+
+int g(int x) {
+ return FOO(x);
+}
+
+// CHECK: call {{.*}} @f(
diff --git a/clang/test/PCH/preprocess.c b/clang/test/PCH/preprocess.c
new file mode 100644
index 0000000..8bf841f
--- /dev/null
+++ b/clang/test/PCH/preprocess.c
@@ -0,0 +1,8 @@
+// Check that -E mode is invariant when using an implicit PCH.
+
+// RUN: %clang_cc1 -include %S/preprocess.h -E -o %t.orig %s
+// RUN: %clang_cc1 -emit-pch -o %t %S/preprocess.h
+// RUN: %clang_cc1 -include-pch %t -E -o %t.from_pch %s
+// RUN: diff %t.orig %t.from_pch
+
+a_typedef a_value;
diff --git a/clang/test/PCH/preprocess.h b/clang/test/PCH/preprocess.h
new file mode 100644
index 0000000..39fa006
--- /dev/null
+++ b/clang/test/PCH/preprocess.h
@@ -0,0 +1,7 @@
+// Helper header for preprocess.c PCH test
+#ifndef PREPROCESS_H
+#define PREPROCESS_H
+
+typedef int a_typedef;
+
+#endif // PREPROCESS_H
diff --git a/clang/test/PCH/pth.c b/clang/test/PCH/pth.c
new file mode 100644
index 0000000..1262f8a
--- /dev/null
+++ b/clang/test/PCH/pth.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-pth -o %t %S/pth.h
+// RUN: %clang_cc1 -triple i386-unknown-unknown -include-pth %t -fsyntax-only %s 2>&1 | FileCheck %s
+
+#error This is the only diagnostic
+
+// CHECK: This is the only diagnostic
+// CHECK: 1 error generated. \ No newline at end of file
diff --git a/clang/test/PCH/pth.h b/clang/test/PCH/pth.h
new file mode 100644
index 0000000..9ae7021
--- /dev/null
+++ b/clang/test/PCH/pth.h
@@ -0,0 +1,12 @@
+// This case came up when using PTH with Boost (<rdar://problem/8227989>).
+
+# ifndef R8227989_PREPROCESSOR_CONFIG_CONFIG_HPP
+# ifndef R8227989_PP_CONFIG_FLAGS
+# endif
+#
+# ifndef R8227989_PP_CONFIG_ERRORS
+# ifdef NDEBUG
+# endif
+# endif
+# endif
+
diff --git a/clang/test/PCH/rdar10830559.cpp b/clang/test/PCH/rdar10830559.cpp
new file mode 100644
index 0000000..b9b6437
--- /dev/null
+++ b/clang/test/PCH/rdar10830559.cpp
@@ -0,0 +1,35 @@
+// Test this without pch.
+// RUN: %clang_cc1 -fsyntax-only -emit-llvm-only %s
+
+// Test with pch.
+// RUN: touch %t.empty.cpp
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -emit-llvm-only %t.empty.cpp
+
+// rdar://10830559
+
+#pragma ms_struct on
+
+template< typename T >
+class Templated
+{
+public:
+ struct s;
+};
+
+
+class Foo
+{
+private:
+
+ class Bar
+ {
+ private:
+ class BarTypes { public: virtual void Func(); };
+ class BarImpl {};
+ friend class Foo;
+ };
+
+
+ friend class Templated< Bar::BarImpl >::s;
+};
diff --git a/clang/test/PCH/rdar8852495.c b/clang/test/PCH/rdar8852495.c
new file mode 100644
index 0000000..fb465a3
--- /dev/null
+++ b/clang/test/PCH/rdar8852495.c
@@ -0,0 +1,26 @@
+// Test this without pch.
+// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only -Wno-sign-compare -Wtautological-compare
+
+// Test with pch.
+// RUN: %clang_cc1 %s -emit-pch -o %t -Wsign-compare -Wtautological-compare
+// RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only -Wno-sign-compare -Wtautological-compare
+
+// This tests that diagnostic mappings from PCH are propagated for #pragma
+// diagnostics but not for command-line flags.
+
+#ifndef HEADER
+#define HEADER
+
+#pragma clang diagnostic ignored "-Wtautological-compare"
+
+#else
+
+int f() {
+ int a;
+ int b = a==a;
+ unsigned x;
+ signed y;
+ return x == y;
+}
+
+#endif
diff --git a/clang/test/PCH/reinclude.cpp b/clang/test/PCH/reinclude.cpp
new file mode 100644
index 0000000..97e22cf
--- /dev/null
+++ b/clang/test/PCH/reinclude.cpp
@@ -0,0 +1,10 @@
+// Test without PCH
+// RUN: %clang_cc1 %s -include %S/reinclude1.h -include %S/reinclude2.h -fsyntax-only -verify
+
+// RUN: %clang_cc1 -x c++-header %S/reinclude1.h -emit-pch -o %t1
+// RUN: %clang_cc1 -x c++-header %S/reinclude2.h -include-pch %t1 -emit-pch -o %t2
+// RUN: %clang_cc1 %s -include-pch %t2 -fsyntax-only -verify
+// RUN: %clang_cc1 -x c++-header %S/reinclude2.h -include-pch %t1 -emit-pch -o %t2
+// RUN: %clang_cc1 %s -include-pch %t2 -fsyntax-only -verify
+
+int q2 = A::y;
diff --git a/clang/test/PCH/reinclude1.h b/clang/test/PCH/reinclude1.h
new file mode 100644
index 0000000..baeb677
--- /dev/null
+++ b/clang/test/PCH/reinclude1.h
@@ -0,0 +1,7 @@
+namespace A {
+ int x;
+ int y;
+}
+
+int foo;
+#define foo foo
diff --git a/clang/test/PCH/reinclude2.h b/clang/test/PCH/reinclude2.h
new file mode 100644
index 0000000..2aa6d31
--- /dev/null
+++ b/clang/test/PCH/reinclude2.h
@@ -0,0 +1 @@
+int q1 = A::x;
diff --git a/clang/test/PCH/reloc.c b/clang/test/PCH/reloc.c
new file mode 100644
index 0000000..4c426e4
--- /dev/null
+++ b/clang/test/PCH/reloc.c
@@ -0,0 +1,14 @@
+// RUN: %clang -target x86_64-apple-darwin10 --relocatable-pch -o %t \
+// RUN: -isysroot %S/libroot %S/libroot/usr/include/reloc.h
+// RUN: %clang -target x86_64-apple-darwin10 -fsyntax-only \
+// RUN: -include-pch %t -isysroot %S/libroot %s -Xclang -verify
+// RUN: not %clang -target x86_64-apple-darwin10 -include-pch %t %s
+
+#include <reloc.h>
+
+int x = 2; // expected-error{{redefinition}}
+int y = 5; // expected-error{{redefinition}}
+
+
+// expected-note{{previous definition}}
+// expected-note{{previous definition}}
diff --git a/clang/test/PCH/replaced-decl.m b/clang/test/PCH/replaced-decl.m
new file mode 100644
index 0000000..b9fee95
--- /dev/null
+++ b/clang/test/PCH/replaced-decl.m
@@ -0,0 +1,22 @@
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify %s -include %s -include %s
+
+// With PCH
+// RUN: %clang_cc1 -fsyntax-only -verify %s -chain-include %s -chain-include %s
+
+#ifndef HEADER1
+#define HEADER1
+
+@class I;
+
+#elif !defined(HEADER2)
+#define HEADER2
+
+@interface I // expected-note {{previous}}
+@end
+
+#else
+
+typedef int I; // expected-error {{redefinition}}
+
+#endif
diff --git a/clang/test/PCH/selector-warning.h b/clang/test/PCH/selector-warning.h
new file mode 100644
index 0000000..bd41929
--- /dev/null
+++ b/clang/test/PCH/selector-warning.h
@@ -0,0 +1,24 @@
+typedef struct objc_selector *SEL;
+
+@interface Foo
+- (void) NotOK;
+@end
+
+@implementation Foo
+- (void) foo
+{
+ SEL a = @selector(b1ar);
+ a = @selector(b1ar);
+ a = @selector(bar);
+ a = @selector(ok); // expected-warning {{unimplemented selector 'ok'}}
+ a = @selector(ok);
+ a = @selector(NotOK); // expected-warning {{unimplemented selector 'NotOK'}}
+ a = @selector(NotOK);
+
+ a = @selector(clNotOk); // expected-warning {{unimplemented selector 'clNotOk'}}
+
+ a = @selector (cl1);
+ a = @selector (cl2);
+ a = @selector (instNotOk); // expected-warning {{unimplemented selector 'instNotOk'}}
+}
+@end
diff --git a/clang/test/PCH/selector-warning.m b/clang/test/PCH/selector-warning.m
new file mode 100644
index 0000000..413f64f
--- /dev/null
+++ b/clang/test/PCH/selector-warning.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -x objective-c -emit-pch -o %t.h.pch %S/selector-warning.h
+// RUN: %clang_cc1 -include-pch %t.h.pch %s
+
+@interface Bar
++ (void) clNotOk;
+- (void) instNotOk;
++ (void) cl1;
+@end
+
+@implementation Bar
+- (void) bar {}
++ (void) cl1 {}
++ (void) cl2 {}
+@end
+
+@implementation Bar(CAT)
+- (void) b1ar {}
+@end
+
diff --git a/clang/test/PCH/single-token-macro.c b/clang/test/PCH/single-token-macro.c
new file mode 100644
index 0000000..29edb75
--- /dev/null
+++ b/clang/test/PCH/single-token-macro.c
@@ -0,0 +1,24 @@
+// rdar://10588825
+
+// Test this without pch.
+// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only
+
+// Test with pch.
+// RUN: %clang_cc1 %s -emit-pch -o %t
+// RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only
+
+#ifndef HEADER
+#define HEADER
+
+#define __stdcall
+#define STDCALL __stdcall
+
+void STDCALL Foo(void);
+
+#else
+
+void STDCALL Foo(void)
+{
+}
+
+#endif
diff --git a/clang/test/PCH/source-manager-stack.c b/clang/test/PCH/source-manager-stack.c
new file mode 100644
index 0000000..8f5da2f
--- /dev/null
+++ b/clang/test/PCH/source-manager-stack.c
@@ -0,0 +1,12 @@
+// Test that the source manager has the "proper" idea about the include stack
+// when using PCH.
+
+// RUN: echo 'int x;' > %t.prefix.h
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-show-note-include-stack -include %t.prefix.h %s 2> %t.diags.no_pch.txt
+// RUN: %clang_cc1 -emit-pch -o %t.prefix.pch %t.prefix.h
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-show-note-include-stack -include-pch %t.prefix.pch %s 2> %t.diags.pch.txt
+// RUN: diff %t.diags.no_pch.txt %t.diags.pch.txt
+// XFAIL: *
+// PR5662
+
+float x;
diff --git a/clang/test/PCH/stmts.c b/clang/test/PCH/stmts.c
new file mode 100644
index 0000000..6def453
--- /dev/null
+++ b/clang/test/PCH/stmts.c
@@ -0,0 +1,14 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/stmts.h -fsyntax-only -emit-llvm -o - %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %S/stmts.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -emit-llvm -o - %s
+
+void g0(void) { f0(5); }
+int g1(int x) { return f1(x); }
+const char* query_name(void) { return what_is_my_name(); }
+
+int use_computed_goto(int x) { return computed_goto(x); }
+
+int get_weird_max(int x, int y) { return weird_max(x, y); }
diff --git a/clang/test/PCH/stmts.h b/clang/test/PCH/stmts.h
new file mode 100644
index 0000000..4267e2c
--- /dev/null
+++ b/clang/test/PCH/stmts.h
@@ -0,0 +1,96 @@
+// Header for PCH test stmts.c
+
+void f0(int x) {
+ // NullStmt
+ ;
+ // IfStmt
+ if (x) {
+ } else if (x + 1) {
+ }
+
+ switch (x) {
+ case 0:
+ x = 17;
+ break;
+
+ case 1:
+ break;
+
+ default:
+ switch (x >> 1) {
+ case 7:
+ // fall through
+ case 9:
+ break;
+ }
+ x += 2;
+ break;
+ }
+
+ while (x > 20) {
+ if (x > 30) {
+ --x;
+ continue;
+ } else if (x < 5)
+ break;
+ else
+ goto done;
+ }
+
+ do {
+ x++;
+ } while (x < 10);
+
+ almost_done:
+ for (int y = x; y < 20; ++y) {
+ if (x + y == 12)
+ return;
+ else if (x - y == 7)
+ goto almost_done;
+ }
+
+ done:
+ x = x + 2;
+
+ int z = x, *y, j = 5;
+}
+
+int f1(int x) {
+ switch (x) {
+ case 17:
+ return 12;
+
+ default:
+ break;
+ }
+
+ // variable-length array
+ int array[x * 17 + 3];
+
+ return x*2;
+}
+
+const char* what_is_my_name(void) { return __func__; }
+
+int computed_goto(int x) {
+ start:
+ x = x << 1;
+ void *location = &&start;
+
+ if (x > 17)
+ location = &&done;
+
+ while (x > 12) {
+ --x;
+ if (x == 15)
+ goto *location;
+ }
+
+ done:
+ return 5;
+}
+
+#define maxint(a,b) ({int _a = (a), _b = (b); _a > _b ? _a : _b; })
+int weird_max(int x, int y) {
+ return maxint(++x, --y);
+}
diff --git a/clang/test/PCH/struct.c b/clang/test/PCH/struct.c
new file mode 100644
index 0000000..3e9d188
--- /dev/null
+++ b/clang/test/PCH/struct.c
@@ -0,0 +1,28 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/struct.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %S/struct.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+struct Point *p1;
+
+float getX(struct Point *p1) {
+ return p1->x;
+}
+
+void *get_fun_ptr() {
+ return fun->is_ptr? fun->ptr : 0;
+}
+
+struct Fun2 {
+ int very_fun;
+};
+
+int get_very_fun() {
+ return fun2->very_fun;
+}
+
+int *int_ptr_fail = &fun->is_ptr; // expected-error{{address of bit-field requested}}
+
+struct Nested nested = { 1, 2 };
diff --git a/clang/test/PCH/struct.h b/clang/test/PCH/struct.h
new file mode 100644
index 0000000..2ffdd4a
--- /dev/null
+++ b/clang/test/PCH/struct.h
@@ -0,0 +1,29 @@
+// Used with the struct.c test
+
+struct Point {
+ float x, y, z;
+};
+
+struct Point2 {
+ float xValue, yValue, zValue;
+};
+
+struct Fun;
+
+struct Fun *fun;
+
+struct Fun {
+ int is_ptr : 1;
+
+ union {
+ void *ptr;
+ int *integer;
+ };
+};
+
+struct Fun2;
+struct Fun2 *fun2;
+
+struct S {
+ struct Nested { int x, y; } nest;
+};
diff --git a/clang/test/PCH/subscripting-literals.m b/clang/test/PCH/subscripting-literals.m
new file mode 100644
index 0000000..1675373
--- /dev/null
+++ b/clang/test/PCH/subscripting-literals.m
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o %t.nopch.ll %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-pch -o %t.pch %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o %t.pch.ll %s -include-pch %t.pch
+// RUN: diff %t.nopch.ll %t.pch.ll
+
+#ifndef HEADER
+#define HEADER
+
+@interface NSArray
+- (id)objectAtIndexedSubscript:(int)index;
++ (id)arrayWithObjects:(id *)objects count:(unsigned)count;
+@end
+
+@interface NSMutableArray : NSArray
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary
+- (id)objectForKeyedSubscript:(id)key;
++ (id)dictionaryWithObjects:(id *)objects forKeys:(id *)keys count:(unsigned)count;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@interface NSNumber
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+@class NSString;
+
+id testArray(int idx, id p) {
+ NSMutableArray *array;
+ array[idx] = p;
+ NSArray *arr = @[ p, @7 ];
+ return array[idx];
+}
+
+void testDict(NSString *key, id newObject, id oldObject) {
+ NSMutableDictionary *dictionary;
+ oldObject = dictionary[key];
+ dictionary[key] = newObject;
+ NSDictionary *dict = @{ key: newObject, key: oldObject };
+}
+
+#endif
diff --git a/clang/test/PCH/tentative-defs.c b/clang/test/PCH/tentative-defs.c
new file mode 100644
index 0000000..0072818
--- /dev/null
+++ b/clang/test/PCH/tentative-defs.c
@@ -0,0 +1,9 @@
+// Test with pch.
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t.pch %S/tentative-defs.h
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t.pch -verify -emit-llvm -o %t %s
+
+// RUN: grep "@variable = common global i32 0" %t | count 1
+// RUN: grep "@incomplete_array = common global .*1 x i32" %t | count 1
+
+
+// FIXME: tentative-defs.h expected-warning{{tentative}}
diff --git a/clang/test/PCH/tentative-defs.h b/clang/test/PCH/tentative-defs.h
new file mode 100644
index 0000000..4675d9a
--- /dev/null
+++ b/clang/test/PCH/tentative-defs.h
@@ -0,0 +1,9 @@
+// Header for PCH test tentative-defs.c
+int variable;
+
+
+
+
+
+
+int incomplete_array[];
diff --git a/clang/test/PCH/types.c b/clang/test/PCH/types.c
new file mode 100644
index 0000000..fc37a9c
--- /dev/null
+++ b/clang/test/PCH/types.c
@@ -0,0 +1,73 @@
+// Test this without pch.
+// RUN: %clang_cc1 -fblocks -include %S/types.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -fblocks -o %t %S/types.h
+// RUN: %clang_cc1 -fblocks -include-pch %t -fsyntax-only -verify %s -ast-print
+
+typedef int INT;
+INT int_value;
+
+__attribute__((address_space(1))) int int_as_one;
+
+// TYPE_EXT_QUAL
+ASInt *as_int_ptr1 = &int_value; // expected-error{{changes address space of pointer}}
+ASInt *as_int_ptr2 = &int_as_one;
+
+// TYPE_COMPLEX
+_Complex float Cfloat_val;
+Cfloat *Cfloat_ptr = &Cfloat_val;
+
+// TYPE_ATOMIC
+_Atomic(int) AtomicInt_val;
+AtomicInt *AtomicInt_ptr = &AtomicInt_val;
+
+// TYPE_POINTER
+int_ptr int_value_ptr = &int_value;
+
+// TYPE_BLOCK_POINTER
+void test_block_ptr(Block *bl) {
+ *bl = ^(int x, float f) { return x; };
+}
+
+// TYPE_CONSTANT_ARRAY
+five_ints fvi = { 1, 2, 3, 4, 5 };
+
+// TYPE_INCOMPLETE_ARRAY
+float_array fa1 = { 1, 2, 3 };
+float_array fa2 = { 1, 2, 3, 4, 5, 6, 7, 8 };
+
+// TYPE_VARIABLE_ARRAY in stmts.[ch]
+
+// TYPE_VECTOR
+float4 f4 = { 1.0, 2.0, 3.0, 4.0 };
+
+// TYPE_EXT_VECTOR
+ext_float4 ef4 = { 1.0, 2.0, 3.0, 4.0 };
+
+// TYPE_FUNCTION_NO_PROTO
+noproto np1;
+int np1(x, y)
+ int x;
+ float y;
+{
+ return x;
+}
+
+// TYPE_FUNCTION_PROTO
+proto p1;
+float p1(float x, float y, ...) {
+ return x + y;
+}
+proto *p2 = p1;
+
+// TYPE_TYPEDEF
+int_ptr_ptr ipp = &int_value_ptr;
+
+// TYPE_TYPEOF_EXPR
+typeof_17 *t17 = &int_value;
+struct S { int x, y; };
+typeof_17 t17_2 = (struct S){1, 2}; // expected-error{{initializing 'typeof_17' (aka 'int') with an expression of incompatible type 'struct S'}}
+
+// TYPE_TYPEOF
+int_ptr_ptr2 ipp2 = &int_value_ptr;
diff --git a/clang/test/PCH/types.h b/clang/test/PCH/types.h
new file mode 100644
index 0000000..7df3f99
--- /dev/null
+++ b/clang/test/PCH/types.h
@@ -0,0 +1,50 @@
+/* Used with the types.c test */
+
+// TYPE_EXT_QUAL
+typedef __attribute__((address_space(1))) int ASInt;
+
+// TYPE_COMPLEX
+typedef _Complex float Cfloat;
+
+// TYPE_ATOMIC
+typedef _Atomic(int) AtomicInt;
+
+// TYPE_POINTER
+typedef int * int_ptr;
+
+// TYPE_BLOCK_POINTER
+typedef int (^Block)(int, float);
+
+// TYPE_CONSTANT_ARRAY
+typedef int five_ints[5];
+
+// TYPE_INCOMPLETE_ARRAY
+typedef float float_array[];
+
+// TYPE_VARIABLE_ARRAY in stmts.[ch]
+
+// TYPE_VECTOR
+typedef float float4 __attribute__((vector_size(16)));
+
+// TYPE_EXT_VECTOR
+typedef float ext_float4 __attribute__((ext_vector_type(4)));
+
+// TYPE_FUNCTION_NO_PROTO
+typedef int noproto();
+
+// TYPE_FUNCTION_PROTO
+typedef float proto(float, float, ...);
+
+// TYPE_TYPEDEF
+typedef int_ptr * int_ptr_ptr;
+
+// TYPE_TYPEOF_EXPR
+typedef typeof(17) typeof_17;
+
+// TYPE_TYPEOF
+typedef typeof(int_ptr *) int_ptr_ptr2;
+
+struct S2;
+struct S2 {};
+enum E;
+enum E { myenum };
diff --git a/clang/test/PCH/typo.cpp b/clang/test/PCH/typo.cpp
new file mode 100644
index 0000000..f8161d1
--- /dev/null
+++ b/clang/test/PCH/typo.cpp
@@ -0,0 +1,17 @@
+
+// In header: expected-note{{'boost::function' declared here}}
+
+
+// In header: expected-note{{'boost::graph::adjacency_list' declared here}}
+
+
+
+adjacent_list<int, int> g; // expected-error{{no template named 'adjacent_list'; did you mean 'boost::graph::adjacency_list'?}}
+Function<int(int)> f; // expected-error{{no template named 'Function'; did you mean 'boost::function'?}}
+
+// Without PCH
+// RUN: %clang_cc1 -include %S/Inputs/typo.hpp -verify %s
+
+// With PCH
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/Inputs/typo.hpp
+// RUN: %clang_cc1 -include-pch %t -verify %s
diff --git a/clang/test/PCH/typo.m b/clang/test/PCH/typo.m
new file mode 100644
index 0000000..c6f0275
--- /dev/null
+++ b/clang/test/PCH/typo.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -x objective-c-header -emit-pch -o %t %S/Inputs/typo.h
+// RUN: %clang_cc1 -include-pch %t -verify %s
+// In header: expected-note{{declared here}}
+void f() {
+ [NSstring alloc]; // expected-error{{unknown receiver 'NSstring'; did you mean 'NSString'?}}
+}
diff --git a/clang/test/PCH/typo2.cpp b/clang/test/PCH/typo2.cpp
new file mode 100644
index 0000000..f9b4c83
--- /dev/null
+++ b/clang/test/PCH/typo2.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-pch %s -o %t.pch
+// RUN: %clang_cc1 -include-pch %t.pch %s -verify
+
+#ifndef HEADER_INCLUDED
+#define HEADER_INCLUDED
+
+void func(struct Test); // expected-note{{'Test' declared here}}
+
+#else
+
+::Yest *T; // expected-error{{did you mean 'Test'}}
+
+#endif
diff --git a/clang/test/PCH/va_arg.c b/clang/test/PCH/va_arg.c
new file mode 100644
index 0000000..1fb2a83
--- /dev/null
+++ b/clang/test/PCH/va_arg.c
@@ -0,0 +1,12 @@
+// Test this without pch.
+// RUN: %clang_cc1 -triple=x86_64-unknown-freebsd7.0 -include %S/va_arg.h %s -emit-llvm -o -
+
+// Test with pch.
+// RUN: %clang_cc1 -triple=x86_64-unknown-freebsd7.0 -emit-pch -o %t %S/va_arg.h
+// RUN: %clang_cc1 -triple=x86_64-unknown-freebsd7.0 -include-pch %t %s -emit-llvm -o -
+
+char *g0(char** argv, int argc) { return argv[argc]; }
+
+char *g(char **argv) {
+ f(g0, argv, 1, 2, 3);
+}
diff --git a/clang/test/PCH/va_arg.cpp b/clang/test/PCH/va_arg.cpp
new file mode 100644
index 0000000..7c8dc6b
--- /dev/null
+++ b/clang/test/PCH/va_arg.cpp
@@ -0,0 +1,16 @@
+// Test this without pch.
+// RUN: %clang_cc1 -triple=x86_64-unknown-freebsd7.0 -include %S/Inputs/va_arg.h %s -emit-llvm -o -
+
+// Test with pch.
+// RUN: %clang_cc1 -triple=x86_64-unknown-freebsd7.0 -emit-pch -x c++-header -o %t %S/Inputs/va_arg.h
+// RUN: %clang_cc1 -triple=x86_64-unknown-freebsd7.0 -include-pch %t %s -emit-llvm -o -
+
+typedef __SIZE_TYPE__ size_t;
+
+extern "C" {
+int vsnprintf(char * , size_t, const char * , va_list) ;
+}
+
+void f(char *buffer, unsigned count, const char* format, va_list argptr) {
+ vsnprintf(buffer, count, format, argptr);
+}
diff --git a/clang/test/PCH/va_arg.h b/clang/test/PCH/va_arg.h
new file mode 100644
index 0000000..4a8e510
--- /dev/null
+++ b/clang/test/PCH/va_arg.h
@@ -0,0 +1,8 @@
+// Header for PCH test va_arg.c
+
+typedef __builtin_va_list va_list;
+char *f (char * (*g) (char **, int), char **p, ...) {
+ char *s;
+ va_list v;
+ s = g (p, __builtin_va_arg(v, int));
+}
diff --git a/clang/test/PCH/variables.c b/clang/test/PCH/variables.c
new file mode 100644
index 0000000..9f90b37
--- /dev/null
+++ b/clang/test/PCH/variables.c
@@ -0,0 +1,47 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+#ifndef HEADER
+#define HEADER
+
+extern float y;
+extern int *ip, x;
+
+float z; // expected-note{{previous}}
+
+int z2 = 17; // expected-note{{previous}}
+
+#define MAKE_HAPPY(X) X##Happy
+int MAKE_HAPPY(Very); // expected-note{{previous definition is here}}
+
+#define A_MACRO_IN_THE_PCH 492
+#define FUNCLIKE_MACRO(X, Y) X ## Y
+
+#define PASTE2(x,y) x##y
+#define PASTE1(x,y) PASTE2(x,y)
+#define UNIQUE(x) PASTE1(x,__COUNTER__)
+
+int UNIQUE(a); // a0
+int UNIQUE(a); // a1
+
+#else
+
+int *ip2 = &x;
+float *fp = &ip; // expected-warning{{incompatible pointer types}}
+double z; // expected-error{{redefinition}}
+int z2 = 18; // expected-error{{redefinition}}
+double VeryHappy; // expected-error{{redefinition}}
+
+int Q = A_MACRO_IN_THE_PCH;
+
+int R = FUNCLIKE_MACRO(A_MACRO_, IN_THE_PCH);
+
+
+int UNIQUE(a); // a2
+int *Arr[] = { &a0, &a1, &a2 };
+
+#endif
diff --git a/clang/test/PCH/variables.h b/clang/test/PCH/variables.h
new file mode 100644
index 0000000..23d2cd3
--- /dev/null
+++ b/clang/test/PCH/variables.h
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-pch -o variables.h.pch variables.h
+// Do not mess with the whitespace in this file. It's important.
+
+
+
+
+extern float y;
+extern int *ip, x;
+
+float z;
+
+int z2 = 17;
+
+#define MAKE_HAPPY(X) X##Happy
+int MAKE_HAPPY(Very);
+
+#define A_MACRO_IN_THE_PCH 492
+#define FUNCLIKE_MACRO(X, Y) X ## Y
+
+#define PASTE2(x,y) x##y
+#define PASTE1(x,y) PASTE2(x,y)
+#define UNIQUE(x) PASTE1(x,__COUNTER__)
+
+int UNIQUE(a); // a0
+int UNIQUE(a); // a1
diff --git a/clang/test/PCH/working-directory.cpp b/clang/test/PCH/working-directory.cpp
new file mode 100644
index 0000000..e77d31b
--- /dev/null
+++ b/clang/test/PCH/working-directory.cpp
@@ -0,0 +1,12 @@
+// Test this without pch.
+// RUN: %clang_cc1 -working-directory %S -I. -include working-directory.h %s -Wunused
+
+// Test with pch.
+// RUN: %clang_cc1 -working-directory %S -x c++-header -emit-pch -o %t.pch -I. working-directory.h
+// RUN: %clang_cc1 -include-pch %t.pch -fsyntax-only %s -Wunused
+
+void f() {
+ // Instantiating A<char> will trigger a warning, which will end up trying to get the path to
+ // the header that contains A.
+ A<char> b;
+}
diff --git a/clang/test/PCH/working-directory.h b/clang/test/PCH/working-directory.h
new file mode 100644
index 0000000..02a60e3
--- /dev/null
+++ b/clang/test/PCH/working-directory.h
@@ -0,0 +1 @@
+#include <Inputs/working-directory-1.h>
diff --git a/clang/test/Parser/CompoundStmtScope.c b/clang/test/Parser/CompoundStmtScope.c
new file mode 100644
index 0000000..4f99103
--- /dev/null
+++ b/clang/test/Parser/CompoundStmtScope.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void foo() {
+ {
+ typedef float X;
+ }
+ X Y; // expected-error {{use of undeclared identifier}}
+}
diff --git a/clang/test/Parser/DelayedTemplateParsing.cpp b/clang/test/Parser/DelayedTemplateParsing.cpp
new file mode 100644
index 0000000..9737c73
--- /dev/null
+++ b/clang/test/Parser/DelayedTemplateParsing.cpp
@@ -0,0 +1,92 @@
+// RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify %s
+
+template <class T>
+class A {
+ void foo() {
+ undeclared();
+ }
+ void foo2();
+};
+
+template <class T>
+class B {
+ void foo4() { } // expected-note {{previous definition is here}} expected-note {{previous definition is here}}
+ void foo4() { } // expected-error {{class member cannot be redeclared}} expected-error {{redefinition of 'foo4'}} expected-note {{previous definition is here}}
+
+ friend void foo3() {
+ undeclared();
+ }
+};
+
+
+template <class T>
+void B<T>::foo4() {// expected-error {{redefinition of 'foo4'}}
+}
+
+template <class T>
+void A<T>::foo2() {
+ undeclared();
+}
+
+
+template <class T>
+void foo3() {
+ undeclared();
+}
+
+template void A<int>::foo2();
+
+
+void undeclared()
+{
+
+}
+
+template <class T> void foo5() {} //expected-note {{previous definition is here}}
+template <class T> void foo5() {} // expected-error {{redefinition of 'foo5'}}
+
+
+
+namespace Inner_Outer_same_template_param_name {
+
+template <class T>
+class Outmost {
+public:
+ template <class T>
+ class Inner {
+ public:
+ void f() {
+ T* var;
+ }
+ };
+};
+
+}
+
+
+namespace PR11931 {
+
+template <typename RunType>
+struct BindState;
+
+ template<>
+struct BindState<void(void*)> {
+ static void Run() { }
+};
+
+class Callback {
+public:
+ typedef void RunType();
+
+ template <typename RunType>
+ Callback(BindState<RunType> bind_state) {
+ BindState<RunType>::Run();
+ }
+};
+
+
+Callback Bind() {
+ return Callback(BindState<void(void*)>());
+}
+
+}
diff --git a/clang/test/Parser/MicrosoftExtensions.c b/clang/test/Parser/MicrosoftExtensions.c
new file mode 100644
index 0000000..1ef326a
--- /dev/null
+++ b/clang/test/Parser/MicrosoftExtensions.c
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -verify -fms-extensions -Wno-missing-declarations -x objective-c++ %s
+__stdcall int func0();
+int __stdcall func();
+typedef int (__cdecl *tptr)();
+void (*__fastcall fastpfunc)();
+struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable) IUnknown {};
+extern __declspec(dllimport) void __stdcall VarR4FromDec();
+__declspec(deprecated) __declspec(deprecated) char * __cdecl ltoa( long _Val, char * _DstBuf, int _Radix);
+__declspec(noalias) __declspec(restrict) void * __cdecl xxx( void * _Memory );
+typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR;
+
+void * __ptr64 PtrToPtr64(const void *p)
+{
+ return((void * __ptr64) (unsigned __int64) (ULONG_PTR)p ); // expected-warning {{unknown attribute '__ptr64' ignored}}
+}
+void * __ptr32 PtrToPtr32(const void *p)
+{
+ return((void * __ptr32) (unsigned __int32) (ULONG_PTR)p ); // expected-warning {{unknown attribute '__ptr32' ignored}}
+}
+
+void __forceinline InterlockedBitTestAndSet (long *Base, long Bit)
+{
+ __asm {
+ mov eax, Bit
+ mov ecx, Base
+ lock bts [ecx], eax
+ setc al
+ };
+}
+_inline int foo99() { return 99; }
+
+void *_alloca(int);
+
+void foo() {
+ __declspec(align(16)) int *buffer = (int *)_alloca(9);
+}
+
+typedef bool (__stdcall __stdcall *blarg)(int);
+
+void local_callconv()
+{
+ bool (__stdcall *p)(int);
+}
+
+// Charify extension.
+#define FOO(x) #@x
+char x = FOO(a);
+
+typedef enum E { e1 };
+
+
+enum __declspec(deprecated) E2 { i, j, k };
+__declspec(deprecated) enum E3 { a, b, c } e;
+
+void deprecated_enum_test(void)
+{
+ // Test to make sure the deprecated warning follows the right thing
+ enum E2 e1; // expected-warning {{'E2' is deprecated}}
+ enum E3 e2; // No warning expected, the deprecation follows the variable
+ enum E3 e3 = e; // expected-warning {{'e' is deprecated}}
+}
+
+/* Microsoft attribute tests */
+[repeatable][source_annotation_attribute( Parameter|ReturnValue )]
+struct SA_Post{ SA_Post(); int attr; };
+
+[returnvalue:SA_Post( attr=1)]
+int foo1([SA_Post(attr=1)] void *param);
+
+
+
+void ms_intrinsics(int a)
+{
+ __noop();
+ __assume(a);
+ __debugbreak();
+}
diff --git a/clang/test/Parser/MicrosoftExtensions.cpp b/clang/test/Parser/MicrosoftExtensions.cpp
new file mode 100644
index 0000000..3a1ffea
--- /dev/null
+++ b/clang/test/Parser/MicrosoftExtensions.cpp
@@ -0,0 +1,311 @@
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing
+
+/* Microsoft attribute tests */
+[repeatable][source_annotation_attribute( Parameter|ReturnValue )]
+struct SA_Post{ SA_Post(); int attr; };
+
+[returnvalue:SA_Post( attr=1)]
+int foo1([SA_Post(attr=1)] void *param);
+
+namespace {
+ [returnvalue:SA_Post(attr=1)]
+ int foo2([SA_Post(attr=1)] void *param);
+}
+
+class T {
+ [returnvalue:SA_Post(attr=1)]
+ int foo3([SA_Post(attr=1)] void *param);
+};
+
+extern "C" {
+ [returnvalue:SA_Post(attr=1)]
+ int foo5([SA_Post(attr=1)] void *param);
+}
+
+class class_attr {
+public:
+ class_attr([SA_Pre(Null=SA_No,NullTerminated=SA_Yes)] int a)
+ {
+ }
+};
+
+
+
+void uuidof_test1()
+{
+ __uuidof(0); // expected-error {{you need to include <guiddef.h> before using the '__uuidof' operator}}
+}
+
+typedef struct _GUID
+{
+ unsigned long Data1;
+ unsigned short Data2;
+ unsigned short Data3;
+ unsigned char Data4[8];
+} GUID;
+
+struct __declspec(uuid(L"00000000-0000-0000-1234-000000000047")) uuid_attr_bad1 { };// expected-error {{'uuid' attribute requires parameter 1 to be a string}}
+struct __declspec(uuid(3)) uuid_attr_bad2 { };// expected-error {{'uuid' attribute requires parameter 1 to be a string}}
+struct __declspec(uuid("0000000-0000-0000-1234-0000500000047")) uuid_attr_bad3 { };// expected-error {{uuid attribute contains a malformed GUID}}
+struct __declspec(uuid("0000000-0000-0000-Z234-000000000047")) uuid_attr_bad4 { };// expected-error {{uuid attribute contains a malformed GUID}}
+struct __declspec(uuid("000000000000-0000-1234-000000000047")) uuid_attr_bad5 { };// expected-error {{uuid attribute contains a malformed GUID}}
+
+
+
+struct __declspec(uuid("000000A0-0000-0000-C000-000000000046"))
+struct_with_uuid { };
+struct struct_without_uuid { };
+
+struct __declspec(uuid("000000A0-0000-0000-C000-000000000049"))
+struct_with_uuid2;
+
+struct
+struct_with_uuid2 {} ;
+
+int uuid_sema_test()
+{
+ struct_with_uuid var_with_uuid[1];
+ struct_without_uuid var_without_uuid[1];
+
+ __uuidof(struct_with_uuid);
+ __uuidof(struct_with_uuid2);
+ __uuidof(struct_without_uuid); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
+ __uuidof(struct_with_uuid*);
+ __uuidof(struct_without_uuid*); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
+
+ __uuidof(var_with_uuid);
+ __uuidof(var_without_uuid);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
+ __uuidof(var_with_uuid[1]);
+ __uuidof(var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
+ __uuidof(&var_with_uuid[1]);
+ __uuidof(&var_without_uuid[1]);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
+
+ __uuidof(0);
+ __uuidof(1);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
+}
+
+
+template <class T>
+void template_uuid()
+{
+ T expr;
+
+ __uuidof(T);
+ __uuidof(expr);
+}
+
+
+template <class T, const GUID* g = &__uuidof(T)>
+class COM_CLASS_TEMPLATE { };
+
+typedef COM_CLASS_TEMPLATE<struct_with_uuid, &__uuidof(struct_with_uuid)> COM_TYPE_1;
+typedef COM_CLASS_TEMPLATE<struct_with_uuid> COM_TYPE_2;
+
+template <class T, const GUID& g>
+class COM_CLASS_TEMPLATE_REF { };
+typedef COM_CLASS_TEMPLATE_REF<struct_with_uuid, __uuidof(struct_with_uuid)> COM_TYPE_REF;
+
+ struct late_defined_uuid;
+ template<typename T>
+ void test_late_defined_uuid() {
+ __uuidof(late_defined_uuid);
+ }
+ struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) late_defined_uuid;
+
+
+class CtorCall {
+public:
+ CtorCall& operator=(const CtorCall& that);
+
+ int a;
+};
+
+CtorCall& CtorCall::operator=(const CtorCall& that)
+{
+ if (this != &that) {
+ this->CtorCall::~CtorCall();
+ this->CtorCall::CtorCall(that); // expected-warning {{explicit constructor calls are a Microsoft extension}}
+ }
+ return *this;
+}
+
+template <class A>
+class C1 {
+public:
+ template <int B>
+ class Iterator {
+ };
+};
+
+template<class T>
+class C2 {
+ typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
+};
+
+template <class T>
+void missing_template_keyword(){
+ typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
+}
+
+
+
+class AAAA { };
+
+template <class T>
+void redundant_typename() {
+ typename T t;// expected-warning {{expected a qualified name after 'typename'}}
+ typename AAAA a;// expected-warning {{expected a qualified name after 'typename'}}
+ t = 3;
+}
+
+
+__interface MicrosoftInterface;
+__interface MicrosoftInterface {
+ virtual void foo1() = 0;
+ virtual void foo2() = 0;
+};
+
+void interface_test() {
+ MicrosoftInterface* a;
+ a->foo1();
+}
+
+__int64 x7 = __int64(0);
+
+
+namespace If_exists_test {
+
+class IF_EXISTS {
+private:
+ typedef int Type;
+};
+
+int __if_exists_test() {
+ int b=0;
+ __if_exists(IF_EXISTS::Type) {
+ b++;
+ b++;
+ }
+ __if_exists(IF_EXISTS::Type_not) {
+ this wont compile.
+ }
+ __if_not_exists(IF_EXISTS::Type) {
+ this wont compile.
+ }
+ __if_not_exists(IF_EXISTS::Type_not) {
+ b++;
+ b++;
+ }
+}
+
+
+__if_exists(IF_EXISTS::Type) {
+ int var23;
+}
+
+__if_exists(IF_EXISTS::Type_not) {
+ this wont compile.
+}
+
+__if_not_exists(IF_EXISTS::Type) {
+ this wont compile.
+}
+
+__if_not_exists(IF_EXISTS::Type_not) {
+ int var244;
+}
+
+int __if_exists_init_list() {
+
+ int array1[] = {
+ 0,
+ __if_exists(IF_EXISTS::Type) {2, }
+ 3
+ };
+
+ int array2[] = {
+ 0,
+ __if_exists(IF_EXISTS::Type_not) { this wont compile }
+ 3
+ };
+
+ int array3[] = {
+ 0,
+ __if_not_exists(IF_EXISTS::Type_not) {2, }
+ 3
+ };
+
+ int array4[] = {
+ 0,
+ __if_not_exists(IF_EXISTS::Type) { this wont compile }
+ 3
+ };
+
+}
+
+
+class IF_EXISTS_CLASS_TEST {
+ __if_exists(IF_EXISTS::Type) {
+ // __if_exists, __if_not_exists can nest
+ __if_not_exists(IF_EXISTS::Type_not) {
+ int var123;
+ }
+ int var23;
+ }
+
+ __if_exists(IF_EXISTS::Type_not) {
+ this wont compile.
+ }
+
+ __if_not_exists(IF_EXISTS::Type) {
+ this wont compile.
+ }
+
+ __if_not_exists(IF_EXISTS::Type_not) {
+ int var244;
+ }
+};
+
+}
+
+
+int __identifier(generic) = 3;
+
+class inline_definition_pure_spec {
+ virtual int f() = 0 { return 0; }// expected-warning {{function definition with pure-specifier is a Microsoft extension}}
+ virtual int f2() = 0;
+};
+
+
+int main () {
+ // Necessary to force instantiation in -fdelayed-template-parsing mode.
+ test_late_defined_uuid<int>();
+ redundant_typename<int>();
+ missing_template_keyword<int>();
+}
+
+
+
+
+namespace access_protected_PTM {
+
+class A {
+protected:
+ void f(); // expected-note {{must name member using the type of the current context 'access_protected_PTM::B'}}
+};
+
+class B : public A{
+public:
+ void test_access();
+ static void test_access_static();
+};
+
+void B::test_access() {
+ &A::f; // expected-error {{'f' is a protected member of 'access_protected_PTM::A'}}
+}
+
+void B::test_access_static() {
+ &A::f;
+}
+
+} \ No newline at end of file
diff --git a/clang/test/Parser/PR11000.cpp b/clang/test/Parser/PR11000.cpp
new file mode 100644
index 0000000..7dae996
--- /dev/null
+++ b/clang/test/Parser/PR11000.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++11 %s 2>&1 | FileCheck %s
+
+// PR11000: Don't crash.
+class tuple<>
+{
+ template <class _Alloc>
+ tuple(allocator_arg_t, const _Alloc&) {}
+
+// CHECK: 6 errors generated.
diff --git a/clang/test/Parser/access-spec-attrs.cpp b/clang/test/Parser/access-spec-attrs.cpp
new file mode 100644
index 0000000..4fa5975
--- /dev/null
+++ b/clang/test/Parser/access-spec-attrs.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+struct X {
+public __attribute__((unavailable)): // expected-error {{access specifier can only have annotation attributes}}
+ void foo();
+private __attribute__((annotate("foobar"))):
+ void bar();
+};
+
+void f(X x) {
+ x.foo();
+}
diff --git a/clang/test/Parser/altivec.c b/clang/test/Parser/altivec.c
new file mode 100644
index 0000000..d1e6552
--- /dev/null
+++ b/clang/test/Parser/altivec.c
@@ -0,0 +1,121 @@
+// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -faltivec -fsyntax-only -verify %s
+
+__vector char vv_c;
+__vector signed char vv_sc;
+__vector unsigned char vv_uc;
+__vector short vv_s;
+__vector signed short vv_ss;
+__vector unsigned short vv_us;
+__vector short int vv_si;
+__vector signed short int vv_ssi;
+__vector unsigned short int vv_usi;
+__vector int vv_i;
+__vector signed int vv_sint;
+__vector unsigned int vv_ui;
+__vector float vv_f;
+__vector bool char vv_bc;
+__vector bool short vv_bs;
+__vector bool int vv_bi;
+__vector __pixel vv_p;
+__vector pixel vv__p;
+__vector int vf__r();
+void vf__a(__vector int a);
+void vf__a2(int b, __vector int a);
+
+vector char v_c;
+vector signed char v_sc;
+vector unsigned char v_uc;
+vector short v_s;
+vector signed short v_ss;
+vector unsigned short v_us;
+vector short int v_si;
+vector signed short int v_ssi;
+vector unsigned short int v_usi;
+vector int v_i;
+vector signed int v_sint;
+vector unsigned int v_ui;
+vector float v_f;
+vector bool char v_bc;
+vector bool short v_bs;
+vector bool int v_bi;
+vector __pixel v_p;
+vector pixel v__p;
+vector int f__r();
+void f_a(vector int a);
+void f_a2(int b, vector int a);
+
+vector int v = (vector int)(-1);
+
+// These should have warnings.
+__vector long vv_l; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+__vector signed long vv_sl; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+__vector unsigned long vv_ul; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+__vector long int vv_li; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+__vector signed long int vv_sli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+__vector unsigned long int vv_uli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+vector long v_l; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+vector signed long v_sl; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+vector unsigned long v_ul; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+vector long int v_li; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+vector signed long int v_sli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+vector unsigned long int v_uli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+__vector long double vv_ld; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+vector long double v_ld; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+vector bool v_b; // expected-warning {{type specifier missing, defaults to 'int'}}
+
+// These should have errors.
+__vector double vv_d1; // expected-error {{cannot use 'double' with '__vector'}}
+vector double v_d2; // expected-error {{cannot use 'double' with '__vector'}}
+__vector long double vv_ld3; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+vector long double v_ld4; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+vector bool float v_bf; // expected-error {{cannot use 'float' with '__vector bool'}}
+vector bool double v_bd; // expected-error {{cannot use 'double' with '__vector bool'}}
+vector bool pixel v_bp; // expected-error {{cannot use '__pixel' with '__vector bool'}}
+vector bool signed char v_bsc; // expected-error {{cannot use 'signed' with '__vector bool'}}
+vector bool unsigned int v_bsc2; // expected-error {{cannot use 'unsigned' with '__vector bool'}}
+vector bool long v_bl; // expected-error {{cannot use 'long' with '__vector bool'}}
+vector bool long long v_bll; // expected-error {{cannot use 'long long' with '__vector bool'}}
+
+void f() {
+ __vector unsigned int v = {0,0,0,0};
+ __vector int v__cast = (__vector int)v;
+ __vector int v_cast = (vector int)v;
+ __vector char vb_cast = (vector char)v;
+
+ // Check some casting between gcc and altivec vectors.
+ #define gccvector __attribute__((vector_size(16)))
+ gccvector unsigned int gccv = {0,0,0,0};
+ gccvector unsigned int gccv1 = gccv;
+ gccvector int gccv2 = (gccvector int)gccv;
+ gccvector unsigned int gccv3 = v;
+ __vector unsigned int av = gccv;
+ __vector int avi = (__vector int)gccv;
+ gccvector unsigned int gv = v;
+ gccvector int gvi = (gccvector int)v;
+ __attribute__((vector_size(8))) unsigned int gv8;
+ gv8 = gccv; // expected-error {{assigning to '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int' from incompatible type '__attribute__((__vector_size__(4 * sizeof(unsigned int)))) unsigned int'}}
+ av = gv8; // expected-error {{assigning to '__vector unsigned int' from incompatible type '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int'}}
+
+ v = gccv;
+ __vector unsigned int tv = gccv;
+ gccv = v;
+ gccvector unsigned int tgv = v;
+
+ int res_i;
+ // bug 7553 - Problem with '==' and vectors
+ res_i = (vv_sc == vv_sc);
+ res_i = (vv_uc != vv_uc);
+ res_i = (vv_s > vv_s);
+ res_i = (vv_us >= vv_us);
+ res_i = (vv_i < vv_i);
+ res_i = (vv_ui <= vv_ui);
+ res_i = (vv_f <= vv_f);
+}
+
+// bug 6895 - Vectorl literal casting confusion.
+vector char v1 = (vector char)((vector int)(1, 2, 3, 4));
+vector char v2 = (vector char)((vector float)(1.0f, 2.0f, 3.0f, 4.0f));
+vector char v3 = (vector char)((vector int)('a', 'b', 'c', 'd'));
+vector int v4 = (vector int)(1, 2, 3, 4);
+vector float v5 = (vector float)(1.0f, 2.0f, 3.0f, 4.0f);
+vector char v6 = (vector char)((vector int)(1+2, -2, (int)(2.0 * 3), -(5-3)));
diff --git a/clang/test/Parser/argument_qualified.c b/clang/test/Parser/argument_qualified.c
new file mode 100644
index 0000000..7d1b9fd
--- /dev/null
+++ b/clang/test/Parser/argument_qualified.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s
+int abc (const float x) {
+ return 1;
+}
+
diff --git a/clang/test/Parser/argument_redef.c b/clang/test/Parser/argument_redef.c
new file mode 100644
index 0000000..519e8fd
--- /dev/null
+++ b/clang/test/Parser/argument_redef.c
@@ -0,0 +1,6 @@
+/* RUN: %clang_cc1 -fsyntax-only -verify %s
+*/
+
+void foo(int A) { /* expected-note {{previous definition is here}} */
+ int A; /* expected-error {{redefinition of 'A'}} */
+}
diff --git a/clang/test/Parser/argument_scope.c b/clang/test/Parser/argument_scope.c
new file mode 100644
index 0000000..d2d10c2
--- /dev/null
+++ b/clang/test/Parser/argument_scope.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+typedef struct foo foo;
+
+void blah(int foo) {
+ foo = 1;
+}
diff --git a/clang/test/Parser/asm-constraints-pr7869.c b/clang/test/Parser/asm-constraints-pr7869.c
new file mode 100644
index 0000000..db36991
--- /dev/null
+++ b/clang/test/Parser/asm-constraints-pr7869.c
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s
+
+int a, b, c, d, e, f, g, h, i, j, k, l;
+
+void
+f1 (void)
+{
+ __asm__ volatile (""
+ : [a] "+r" (a), [b] "+r" (b), [c] "+r" (c), [d] "+r" (d),
+ [e] "+r" (e), [f] "+r" (f), [g] "+r" (g), [h] "+r" (h),
+ [i] "+r" (i), [j] "+r" (j), [k] "+r" (k), [l] "+r" (l));
+}
+
+void
+f2 (void)
+{
+ __asm__ volatile (""
+ : [a] "+r,m" (a), [b] "+r,m" (b), [c] "+r,m" (c), [d] "+r,m" (d),
+ [e] "+r,m" (e), [f] "+r,m" (f), [g] "+r,m" (g), [h] "+r,m" (h),
+ [i] "+r,m" (i), [j] "+r,m" (j), [k] "+r,m" (k), [l] "+r,m" (l));
+}
+
+void
+f3 (void)
+{
+ __asm__ volatile (""
+ : [a] "=r" (a), [b] "=r" (b), [c] "=r" (c), [d] "=r" (d),
+ [e] "=r" (e), [f] "=r" (f), [g] "=r" (g), [h] "=r" (h),
+ [i] "=r" (i), [j] "=r" (j), [k] "=r" (k), [l] "=r" (l)
+ : "[a]" (a), "[b]" (b), "[c]" (c), "[d]" (d),
+ "[e]" (e), "[f]" (f), "[g]" (g), "[h]" (h),
+ "[i]" (i), "[j]" (j), "[k]" (k), "[l]" (l));
+}
+
+void
+f4 (void)
+{
+ __asm__ volatile (""
+ : [a] "=r,m" (a), [b] "=r,m" (b), [c] "=r,m" (c), [d] "=r,m" (d),
+ [e] "=r,m" (e), [f] "=r,m" (f), [g] "=r,m" (g), [h] "=r,m" (h),
+ [i] "=r,m" (i), [j] "=r,m" (j), [k] "=r,m" (k), [l] "=r,m" (l)
+ : "[a],m" (a), "[b],m" (b), "[c],m" (c), "[d],m" (d),
+ "[e],m" (e), "[f],m" (f), "[g],m" (g), "[h],m" (h),
+ "[i],m" (i), "[j],m" (j), "[k],m" (k), "[l],m" (l));
+}
diff --git a/clang/test/Parser/asm.c b/clang/test/Parser/asm.c
new file mode 100644
index 0000000..23052c3
--- /dev/null
+++ b/clang/test/Parser/asm.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f1() {
+ // PR7673: Some versions of GCC support an empty clobbers section.
+ asm ("ret" : : :);
+}
+
+void f2() {
+ asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
+ asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}}
+}
+
+
+// rdar://5952468
+__asm ; // expected-error {{expected '(' after 'asm'}}
+
+// <rdar://problem/10465079> - Don't crash on wide string literals in 'asm'.
+int foo asm (L"bar"); // expected-error {{cannot use wide string literal in 'asm'}}
+
diff --git a/clang/test/Parser/asm.cpp b/clang/test/Parser/asm.cpp
new file mode 100644
index 0000000..35a497c
--- /dev/null
+++ b/clang/test/Parser/asm.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+int foo1 asm ("bar1");
+int foo2 asm (L"bar2"); // expected-error {{cannot use wide string literal in 'asm'}}
+int foo3 asm (u8"bar3"); // expected-error {{cannot use unicode string literal in 'asm'}}
+int foo4 asm (u"bar4"); // expected-error {{cannot use unicode string literal in 'asm'}}
+int foo5 asm (U"bar5"); // expected-error {{cannot use unicode string literal in 'asm'}}
+int foo6 asm ("bar6"_x); // expected-error {{string literal with user-defined suffix cannot be used here}}
diff --git a/clang/test/Parser/attr-availability.c b/clang/test/Parser/attr-availability.c
new file mode 100644
index 0000000..b9ff31c
--- /dev/null
+++ b/clang/test/Parser/attr-availability.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#if !__has_feature(attribute_availability)
+# error 'availability' attribute is not available
+#endif
+
+void f0() __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6)));
+
+void f1() __attribute__((availability(macosx,deprecated=10.4,introduced=10.2,obsoleted=10.6)));
+
+void f2() __attribute__((availability(ios,deprecated=10.4.7,introduced=10,obsoleted=10.6)));
+
+void f3() __attribute__((availability(ios,deprecated=10.4.7,introduced=10,obsoleted=10.6,introduced=10.2))); // expected-error{{redundant 'introduced' availability change; only the last specified change will be used}}
+
+void f4() __attribute__((availability(macosx,introduced=10.5), availability(ios,unavailable)));
+
+void f5() __attribute__((availability(macosx,introduced=10.5), availability(ios,unavailable, unavailable))); // expected-error{{redundant 'unavailable' availability change; only the last specified change will be used}}
+
+void f6() __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{'unavailable' availability overrides all other availability information}}
+
+// rdar://10095131
+enum E{
+ gorf __attribute__((availability(macosx,introduced=8.5, message = 10.0))), // expected-error {{expected string literal}}
+ garf __attribute__((availability(macosx,introduced=8.5, message))), // expected-error {{expected '=' after 'message'}}
+
+ foo __attribute__((availability(macosx,introduced=8.5,deprecated=9.0, message="Use CTFontCopyPostScriptName()", deprecated=10.0))) // expected-error {{expected ')'}} \
+ // expected-note {{to match this '('}}
+};
diff --git a/clang/test/Parser/attributes.c b/clang/test/Parser/attributes.c
new file mode 100644
index 0000000..347cb9c
--- /dev/null
+++ b/clang/test/Parser/attributes.c
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -pedantic -std=c99
+
+int __attribute__(()) x;
+
+__inline void __attribute__((__always_inline__, __nodebug__))
+foo(void) {
+}
+
+
+__attribute__(()) y; // expected-warning {{defaults to 'int'}}
+
+// PR2796
+int (__attribute__(()) *z)(long y);
+
+
+void f1(__attribute__(()) int x);
+
+int f2(y, __attribute__(()) x); // expected-error {{expected identifier}}
+
+// This is parsed as a normal argument list (with two args that are implicit
+// int) because the __attribute__ is a declspec.
+void f3(__attribute__(()) x, // expected-warning {{defaults to 'int'}}
+ y); // expected-warning {{defaults to 'int'}}
+
+void f4(__attribute__(())); // expected-error {{expected parameter declarator}}
+
+
+// This is ok, the __attribute__ applies to the pointer.
+int baz(int (__attribute__(()) *x)(long y));
+
+void g1(void (*f1)(__attribute__(()) int x));
+void g2(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}}
+void g3(void (*f3)(__attribute__(()) x, int y)); // expected-warning {{defaults to 'int'}}
+void g4(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}}
+
+
+void (*h1)(void (*f1)(__attribute__(()) int x));
+void (*h2)(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}}
+
+void (*h3)(void (*f3)(__attribute__(()) x)); // expected-warning {{defaults to 'int'}}
+void (*h4)(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}}
+
+
+
+// rdar://6131260
+int foo42(void) {
+ int x, __attribute__((unused)) y, z;
+ return 0;
+}
+
+// rdar://6096491
+void __attribute__((noreturn)) d0(void), __attribute__((noreturn)) d1(void);
+
+void d2(void) __attribute__((noreturn)), d3(void) __attribute__((noreturn));
+
+
+// PR6287
+void __attribute__((returns_twice)) returns_twice_test();
+
+int aligned(int);
+int __attribute__((vec_type_hint(char, aligned(16) )) missing_rparen_1; // expected-error {{expected ')'}}
+int __attribute__((mode(x aligned(16) )) missing_rparen_2; // expected-error {{expected ')'}}
+int __attribute__((format(printf, 0 aligned(16) )) missing_rparen_3; // expected-error {{expected ')'}}
+
+
+
+int testFundef1(int *a) __attribute__((nonnull(1))) { // \
+ // expected-warning {{GCC does not allow nonnull attribute in this position on a function definition}}
+ return *a;
+}
+
+// noreturn is lifted to type qualifier
+void testFundef2() __attribute__((noreturn)) { // \
+ // expected-warning {{GCC does not allow noreturn attribute in this position on a function definition}}
+ testFundef2();
+}
+
+int testFundef3(int *a) __attribute__((nonnull(1), // \
+ // expected-warning {{GCC does not allow nonnull attribute in this position on a function definition}}
+ pure)) { // \
+ // expected-warning {{GCC does not allow pure attribute in this position on a function definition}}
+ return *a;
+}
+
+int testFundef4(int *a) __attribute__((nonnull(1))) // \
+ // expected-warning {{GCC does not allow nonnull attribute in this position on a function definition}}
+ __attribute((pure)) { // \
+ // expected-warning {{GCC does not allow pure attribute in this position on a function definition}}
+ return *a;
+}
+
+// GCC allows these
+void testFundef5() __attribute__(()) { }
+
+__attribute__((pure)) int testFundef6(int a) { return a; }
+
+
+
diff --git a/clang/test/Parser/backtrack-crash.cpp b/clang/test/Parser/backtrack-crash.cpp
new file mode 100644
index 0000000..cc26873
--- /dev/null
+++ b/clang/test/Parser/backtrack-crash.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
+// PR7072
+()( // expected-error {{expected unqualified-id}}
+
diff --git a/clang/test/Parser/bad-control.c b/clang/test/Parser/bad-control.c
new file mode 100644
index 0000000..480d81b
--- /dev/null
+++ b/clang/test/Parser/bad-control.c
@@ -0,0 +1,9 @@
+/* RUN: %clang_cc1 -fsyntax-only -verify %s
+*/
+void foo() {
+ break; /* expected-error {{'break' statement not in loop or switch statement}} */
+}
+
+void foo2() {
+ continue; /* expected-error {{'continue' statement not in loop statement}} */
+}
diff --git a/clang/test/Parser/block-block-storageclass.c b/clang/test/Parser/block-block-storageclass.c
new file mode 100644
index 0000000..97ba113
--- /dev/null
+++ b/clang/test/Parser/block-block-storageclass.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+int printf(const char *, ...);
+void _Block_byref_release(void*src){}
+
+int main() {
+ __block int X = 1234;
+ __block const char * message = "HELLO";
+
+ X = X - 1234;
+
+ X += 1;
+
+ printf ("%s(%d)\n", message, X);
+ X -= 1;
+
+ return X;
+}
diff --git a/clang/test/Parser/block-pointer-decl.c b/clang/test/Parser/block-pointer-decl.c
new file mode 100644
index 0000000..a8cc258
--- /dev/null
+++ b/clang/test/Parser/block-pointer-decl.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
+
+int printf(char const *, ...);
+
+struct blockStruct {
+ int (^a)(float, int);
+ int b;
+};
+
+int blockTaker (int (^myBlock)(int), int other_input)
+{
+ return 5 * myBlock (other_input);
+}
+
+int main (int argc, char **argv)
+{
+ int (^blockptr) (int) = ^(int inval) {
+ printf ("Inputs: %d, %d.\n", argc, inval);
+ return argc * inval;
+ };
+
+
+ argc = 10;
+ printf ("I got: %d.\n",
+ blockTaker (blockptr, 6));
+ return 0;
+}
+
diff --git a/clang/test/Parser/bracket-crash.cpp b/clang/test/Parser/bracket-crash.cpp
new file mode 100644
index 0000000..bcc6eab
--- /dev/null
+++ b/clang/test/Parser/bracket-crash.cpp
@@ -0,0 +1,6 @@
+// RUN: not %clang_cc1 -fsyntax-only -std=c++11 %s
+// PR7481
+decltype(;
+struct{
+ a
+}
diff --git a/clang/test/Parser/builtin_classify_type.c b/clang/test/Parser/builtin_classify_type.c
new file mode 100644
index 0000000..a7c0855
--- /dev/null
+++ b/clang/test/Parser/builtin_classify_type.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct foo { int a; };
+
+int main() {
+ int a;
+ float b;
+ double d;
+ struct foo s;
+
+ static int ary[__builtin_classify_type(a)];
+ static int ary2[(__builtin_classify_type)(a)]; // expected-error{{variable length array declaration can not have 'static' storage duration}}
+ static int ary3[(*__builtin_classify_type)(a)]; // expected-error{{variable length array declaration can not have 'static' storage duration}}
+
+ int result;
+
+ result = __builtin_classify_type(a);
+ result = __builtin_classify_type(b);
+ result = __builtin_classify_type(d);
+ result = __builtin_classify_type(s);
+}
diff --git a/clang/test/Parser/builtin_types_compatible.c b/clang/test/Parser/builtin_types_compatible.c
new file mode 100644
index 0000000..ac81e7b
--- /dev/null
+++ b/clang/test/Parser/builtin_types_compatible.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+extern int funcInt(int);
+extern float funcFloat(float);
+extern double funcDouble(double);
+// figure out why "char *" doesn't work (with gcc, nothing to do with clang)
+//extern void funcCharPtr(char *);
+
+#define func(expr) \
+ do { \
+ typeof(expr) tmp; \
+ if (__builtin_types_compatible_p(typeof(expr), int)) funcInt(tmp); \
+ else if (__builtin_types_compatible_p(typeof(expr), float)) funcFloat(tmp); \
+ else if (__builtin_types_compatible_p(typeof(expr), double)) funcDouble(tmp); \
+ } while (0)
+#define func_choose(expr) \
+ __builtin_choose_expr(__builtin_types_compatible_p(typeof(expr), int), funcInt(expr), \
+ __builtin_choose_expr(__builtin_types_compatible_p(typeof(expr), float), funcFloat(expr), \
+ __builtin_choose_expr(__builtin_types_compatible_p(typeof(expr), double), funcDouble(expr), (void)0)))
+
+static void test()
+{
+ int a;
+ float b;
+ double d;
+
+ func(a);
+ func(b);
+ func(d);
+ a = func_choose(a);
+ b = func_choose(b);
+ d = func_choose(d);
+
+ int c;
+ struct xx { int a; } x, y;
+
+ c = __builtin_choose_expr(a+3-7, b, x); // expected-error{{'__builtin_choose_expr' requires a constant expression}}
+ c = __builtin_choose_expr(0, b, x); // expected-error{{assigning to 'int' from incompatible type 'struct xx'}}
+ c = __builtin_choose_expr(5+3-7, b, x);
+ y = __builtin_choose_expr(4+3-7, b, x);
+
+}
+
diff --git a/clang/test/Parser/c-namespace.c b/clang/test/Parser/c-namespace.c
new file mode 100644
index 0000000..fbef09e
--- /dev/null
+++ b/clang/test/Parser/c-namespace.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+void bla1() {
+ struct XXX;
+ int XXX;
+}
+
diff --git a/clang/test/Parser/c1x-alignas.c b/clang/test/Parser/c1x-alignas.c
new file mode 100644
index 0000000..5dccc99
--- /dev/null
+++ b/clang/test/Parser/c1x-alignas.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c1x -fsyntax-only -verify %s
+
+_Alignas(4) char c1;
+unsigned _Alignas(long) char c2;
+char _Alignas(16) c3;
+
+char c4 _Alignas(32); // expected-error {{expected ';' after top level declarator}}
diff --git a/clang/test/Parser/c1x-generic-selection.c b/clang/test/Parser/c1x-generic-selection.c
new file mode 100644
index 0000000..ee23059
--- /dev/null
+++ b/clang/test/Parser/c1x-generic-selection.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c1x -fsyntax-only -verify %s
+
+void foo(void) {
+ _Generic; // expected-error {{expected '('}}
+ (void) _Generic(0); // expected-error {{expected ','}}
+ (void) _Generic(0, void); // expected-error {{expected ':'}}
+ (void) _Generic(0,
+ default: 0, // expected-note {{previous default generic association is here}}
+ default: 0); // expected-error {{duplicate default generic association}}
+}
diff --git a/clang/test/Parser/char-literal-printing.c b/clang/test/Parser/char-literal-printing.c
new file mode 100644
index 0000000..27dd63a
--- /dev/null
+++ b/clang/test/Parser/char-literal-printing.c
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -ast-print %s
+// RUN: %clang_cc1 -x c++ -ast-print %s
+// RUN: %clang_cc1 -x c++ -std=c++11 -ast-print %s
+
+#include <stddef.h>
+
+char test1(void) { return '\\'; }
+wchar_t test2(void) { return L'\\'; }
+char test3(void) { return '\''; }
+wchar_t test4(void) { return L'\''; }
+char test5(void) { return '\a'; }
+wchar_t test6(void) { return L'\a'; }
+char test7(void) { return '\b'; }
+wchar_t test8(void) { return L'\b'; }
+char test9(void) { return '\e'; }
+wchar_t test10(void) { return L'\e'; }
+char test11(void) { return '\f'; }
+wchar_t test12(void) { return L'\f'; }
+char test13(void) { return '\n'; }
+wchar_t test14(void) { return L'\n'; }
+char test15(void) { return '\r'; }
+wchar_t test16(void) { return L'\r'; }
+char test17(void) { return '\t'; }
+wchar_t test18(void) { return L'\t'; }
+char test19(void) { return '\v'; }
+wchar_t test20(void) { return L'\v'; }
+
+char test21(void) { return 'c'; }
+wchar_t test22(void) { return L'c'; }
+char test23(void) { return '\x3'; }
+wchar_t test24(void) { return L'\x3'; }
+
+wchar_t test25(void) { return L'\x333'; }
+
+#if __cplusplus >= 201103L
+char16_t test26(void) { return u'\\'; }
+char16_t test27(void) { return u'\''; }
+char16_t test28(void) { return u'\a'; }
+char16_t test29(void) { return u'\b'; }
+char16_t test30(void) { return u'\e'; }
+char16_t test31(void) { return u'\f'; }
+char16_t test32(void) { return u'\n'; }
+char16_t test33(void) { return u'\r'; }
+char16_t test34(void) { return u'\t'; }
+char16_t test35(void) { return u'\v'; }
+
+char16_t test36(void) { return u'c'; }
+char16_t test37(void) { return u'\x3'; }
+
+char16_t test38(void) { return u'\x333'; }
+
+char32_t test39(void) { return U'\\'; }
+char32_t test40(void) { return U'\''; }
+char32_t test41(void) { return U'\a'; }
+char32_t test42(void) { return U'\b'; }
+char32_t test43(void) { return U'\e'; }
+char32_t test44(void) { return U'\f'; }
+char32_t test45(void) { return U'\n'; }
+char32_t test46(void) { return U'\r'; }
+char32_t test47(void) { return U'\t'; }
+char32_t test48(void) { return U'\v'; }
+
+char32_t test49(void) { return U'c'; }
+char32_t test50(void) { return U'\x3'; }
+
+char32_t test51(void) { return U'\x333'; }
+#endif
diff --git a/clang/test/Parser/check-objc2-syntax-1.m b/clang/test/Parser/check-objc2-syntax-1.m
new file mode 100644
index 0000000..3cdf2b0
--- /dev/null
+++ b/clang/test/Parser/check-objc2-syntax-1.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface Subclass
++ (int)magicNumber;
+@end
+
+int main (void) {
+ return Subclass.magicNumber;
+}
+
diff --git a/clang/test/Parser/check-syntax-1.m b/clang/test/Parser/check-syntax-1.m
new file mode 100644
index 0000000..0ae0c5d
--- /dev/null
+++ b/clang/test/Parser/check-syntax-1.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int @interface bla ; // expected-error {{cannot combine with previous 'int' declaration specifier}}
+@end
+
+typedef float CGFloat;
+@interface XNSNumber
++ (XNSNumber *) numberWithCGFloat : (CGFloat) float; // expected-error {{expected identifier}} \
+ // expected-error {{expected ';' after method prototype}}
+@end
+
+// rdar: // 7822196
+@interface A
+(void) x; // expected-error {{method type specifier must start with '-' or '+'}}
+(int)im; // expected-error {{method type specifier must start with '-' or '+'}} \
+- ok;
+@end
+
+
diff --git a/clang/test/Parser/check_cast.c b/clang/test/Parser/check_cast.c
new file mode 100644
index 0000000..790ee40
--- /dev/null
+++ b/clang/test/Parser/check_cast.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct foo {
+ int a;
+};
+
+int main() {
+ struct foo xxx;
+ int i;
+
+ xxx = (struct foo)1; // expected-error {{used type 'struct foo' where arithmetic or pointer type is required}}
+ i = (int)xxx; // expected-error {{operand of type 'struct foo' where arithmetic or pointer type is required}}
+}
diff --git a/clang/test/Parser/compound_literal.c b/clang/test/Parser/compound_literal.c
new file mode 100644
index 0000000..4f3609d
--- /dev/null
+++ b/clang/test/Parser/compound_literal.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+int main() {
+ char *s;
+ s = (char []){"whatever"};
+}
diff --git a/clang/test/Parser/control-scope.c b/clang/test/Parser/control-scope.c
new file mode 100644
index 0000000..5314980
--- /dev/null
+++ b/clang/test/Parser/control-scope.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -std=c90 -verify
+// RUN: %clang_cc1 %s -std=c99
+
+int f (int z) {
+ if (z + sizeof (enum {a})) // expected-note {{previous definition is here}}
+ return 1 + sizeof (enum {a}); // expected-error {{redefinition of enumerator 'a'}}
+ return 0;
+}
diff --git a/clang/test/Parser/cuda-kernel-call.cu b/clang/test/Parser/cuda-kernel-call.cu
new file mode 100644
index 0000000..f95ae9e
--- /dev/null
+++ b/clang/test/Parser/cuda-kernel-call.cu
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void foo(void) {
+ foo<<<1; // expected-error {{expected '>>>'}} expected-note {{to match this '<<<'}}
+
+ foo<<<1,1>>>; // expected-error {{expected '('}}
+
+ foo<<<>>>(); // expected-error {{expected expression}}
+}
diff --git a/clang/test/Parser/cxx-altivec.cpp b/clang/test/Parser/cxx-altivec.cpp
new file mode 100644
index 0000000..9b2b1af
--- /dev/null
+++ b/clang/test/Parser/cxx-altivec.cpp
@@ -0,0 +1,170 @@
+// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -faltivec -fsyntax-only -verify %s
+
+__vector char vv_c;
+__vector signed char vv_sc;
+__vector unsigned char vv_uc;
+__vector short vv_s;
+__vector signed short vv_ss;
+__vector unsigned short vv_us;
+__vector short int vv_si;
+__vector signed short int vv_ssi;
+__vector unsigned short int vv_usi;
+__vector int vv_i;
+__vector signed int vv_sint;
+__vector unsigned int vv_ui;
+__vector float vv_f;
+__vector bool char vv_bc;
+__vector bool short vv_bs;
+__vector bool int vv_bi;
+__vector __pixel vv_p;
+__vector pixel vv__p;
+__vector int vf__r();
+void vf__a(__vector int a);
+void vf__a2(int b, __vector int a);
+
+vector char v_c;
+vector signed char v_sc;
+vector unsigned char v_uc;
+vector short v_s;
+vector signed short v_ss;
+vector unsigned short v_us;
+vector short int v_si;
+vector signed short int v_ssi;
+vector unsigned short int v_usi;
+vector int v_i;
+vector signed int v_sint;
+vector unsigned int v_ui;
+vector float v_f;
+vector bool char v_bc;
+vector bool short v_bs;
+vector bool int v_bi;
+vector __pixel v_p;
+vector pixel v__p;
+vector int f__r();
+void f_a(vector int a);
+void f_a2(int b, vector int a);
+
+vector int v = (vector int)(-1);
+
+// These should have warnings.
+__vector long vv_l; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+__vector signed long vv_sl; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+__vector unsigned long vv_ul; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+__vector long int vv_li; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+__vector signed long int vv_sli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+__vector unsigned long int vv_uli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+vector long v_l; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+vector signed long v_sl; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+vector unsigned long v_ul; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+vector long int v_li; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+vector signed long int v_sli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+vector unsigned long int v_uli; // expected-warning {{Use of 'long' with '__vector' is deprecated}}
+__vector long double vv_ld; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+vector long double v_ld; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+
+// These should have errors.
+__vector double vv_d1; // expected-error {{cannot use 'double' with '__vector'}}
+vector double v_d2; // expected-error {{cannot use 'double' with '__vector'}}
+__vector long double vv_ld3; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+vector long double v_ld4; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
+vector bool v_b; // expected-error {{C++ requires a type specifier for all declarations}}
+vector bool float v_bf; // expected-error {{cannot use 'float' with '__vector bool'}}
+vector bool double v_bd; // expected-error {{cannot use 'double' with '__vector bool'}}
+vector bool pixel v_bp; // expected-error {{cannot use '__pixel' with '__vector bool'}}
+vector bool signed char v_bsc; // expected-error {{cannot use 'signed' with '__vector bool'}}
+vector bool unsigned int v_bsc2; // expected-error {{cannot use 'unsigned' with '__vector bool'}}
+vector bool long v_bl; // expected-error {{cannot use 'long' with '__vector bool'}}
+vector bool long long v_bll; // expected-error {{cannot use 'long long' with '__vector bool'}}
+
+void f() {
+ __vector unsigned int v = {0,0,0,0};
+ __vector int v__cast = (__vector int)v;
+ __vector int v_cast = (vector int)v;
+ __vector char vb_cast = (vector char)v;
+
+ // Check some casting between gcc and altivec vectors.
+ #define gccvector __attribute__((vector_size(16)))
+ gccvector unsigned int gccv = {0,0,0,0};
+ gccvector unsigned int gccv1 = gccv;
+ gccvector int gccv2 = (gccvector int)gccv;
+ gccvector unsigned int gccv3 = v;
+ __vector unsigned int av = gccv;
+ __vector int avi = (__vector int)gccv;
+ gccvector unsigned int gv = v;
+ gccvector int gvi = (gccvector int)v;
+ __attribute__((vector_size(8))) unsigned int gv8;
+ gv8 = gccv; // expected-error {{assigning to '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int' from incompatible type '__attribute__((__vector_size__(4 * sizeof(unsigned int)))) unsigned int'}}
+ av = gv8; // expected-error {{assigning to '__vector unsigned int' from incompatible type '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int'}}
+
+ v = gccv;
+ __vector unsigned int tv = gccv;
+ gccv = v;
+ gccvector unsigned int tgv = v;
+}
+
+// Now for the C++ version:
+
+class vc__v {
+ __vector int v;
+ __vector int f__r();
+ void f__a(__vector int a);
+ void f__a2(int b, __vector int a);
+};
+
+class c_v {
+ vector int v;
+ vector int f__r();
+ void f__a(vector int a);
+ void f__a2(int b, vector int a);
+};
+
+
+// bug 6895 - Vectorl literal casting confusion.
+vector char v1 = (vector char)((vector int)(1, 2, 3, 4));
+vector char v2 = (vector char)((vector float)(1.0f, 2.0f, 3.0f, 4.0f));
+vector char v3 = (vector char)((vector int)('a', 'b', 'c', 'd'));
+vector int v4 = (vector int)(1, 2, 3, 4);
+vector float v5 = (vector float)(1.0f, 2.0f, 3.0f, 4.0f);
+vector char v6 = (vector char)((vector int)(1+2, -2, (int)(2.0 * 3), -(5-3)));
+
+// bug 7553 - Problem with '==' and vectors
+void func() {
+ bool res_b;
+ res_b = (vv_sc == vv_sc);
+ res_b = (vv_uc != vv_uc);
+ res_b = (vv_s > vv_s);
+ res_b = (vv_us >= vv_us);
+ res_b = (vv_i < vv_i);
+ res_b = (vv_ui <= vv_ui);
+ res_b = (vv_f <= vv_f);
+}
+
+// vecreturn attribute test
+struct Vector
+{
+ __vector float xyzw;
+} __attribute__((vecreturn));
+
+Vector Add(Vector lhs, Vector rhs)
+{
+ Vector result;
+ result.xyzw = vec_add(lhs.xyzw, rhs.xyzw);
+ return result; // This will (eventually) be returned in a register
+}
+
+// vecreturn attribute test - should error because of virtual function.
+class VectorClassNonPod
+{
+ __vector float xyzw;
+public:
+ VectorClassNonPod() {}
+ virtual ~VectorClassNonPod() {}
+} __attribute__((vecreturn)); // expected-error {{the vecreturn attribute can only be used on a POD (plain old data) class or structure (i.e. no virtual functions)}}
+
+// vecreturn attribute test - should error because of virtual function.
+class VectorClassMultipleMembers
+{
+public:
+ __vector float xyzw;
+ __vector float abcd;
+} __attribute__((vecreturn)); // expected-error {{the vecreturn attribute can only be used on a class or structure with one member, which must be a vector}}
diff --git a/clang/test/Parser/cxx-ambig-decl-expr-xfail.cpp b/clang/test/Parser/cxx-ambig-decl-expr-xfail.cpp
new file mode 100644
index 0000000..ac4accb
--- /dev/null
+++ b/clang/test/Parser/cxx-ambig-decl-expr-xfail.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// XFAIL: *
+struct X {
+ template<typename T> X(T);
+ X(int, int);
+
+ X operator()(int, int) const;
+};
+
+template<typename T, typename U> struct Y { };
+
+X *x;
+void f() {
+ int y = 0;
+ X (*x)(int(y), int(y)) = Y<int, float>(), ++y;
+}
diff --git a/clang/test/Parser/cxx-ambig-decl-expr.cpp b/clang/test/Parser/cxx-ambig-decl-expr.cpp
new file mode 100644
index 0000000..b5ff728
--- /dev/null
+++ b/clang/test/Parser/cxx-ambig-decl-expr.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct X {
+ template<typename T, typename U>
+ static void f(int, int);
+};
+
+void f() {
+ void (*ptr)(int, int) = &X::f<int, int>;
+}
diff --git a/clang/test/Parser/cxx-ambig-paren-expr.cpp b/clang/test/Parser/cxx-ambig-paren-expr.cpp
new file mode 100644
index 0000000..3988205
--- /dev/null
+++ b/clang/test/Parser/cxx-ambig-paren-expr.cpp
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+
+void f() {
+ typedef int T;
+ int x, *px;
+
+ // Type id.
+ (T())x; // expected-error {{cast from 'int' to 'T ()'}}
+ (T())+x; // expected-error {{cast from 'int' to 'T ()'}}
+ (T())*px; // expected-error {{cast from 'int' to 'T ()'}}
+
+ // Expression.
+ x = (T());
+ x = (T())/x;
+
+ typedef int *PT;
+ // Make sure stuff inside the parens are parsed only once (only one warning).
+ x = (PT()[(int){1}]); // expected-warning {{compound literals}}
+
+ // Special case: empty parens is a call, not an expression
+ struct S{int operator()();};
+ (S())();
+
+ // FIXME: Special case: "++" is postfix here, not prefix
+ // (S())++;
+}
+
+// Make sure we do tentative parsing correctly in conditions.
+typedef int type;
+struct rec { rec(int); };
+
+namespace ns {
+ typedef int type;
+ struct rec { rec(int); };
+}
+
+struct cls {
+ typedef int type;
+ struct rec { rec(int); };
+};
+
+struct result {
+ template <class T> result(T);
+ bool check();
+};
+
+void test(int i) {
+ if (result((cls::type) i).check())
+ return;
+
+ if (result((ns::type) i).check())
+ return;
+
+ if (result((::type) i).check())
+ return;
+
+ if (result((cls::rec) i).check())
+ return;
+
+ if (result((ns::rec) i).check())
+ return;
+
+ if (result((::rec) i).check())
+ return;
+}
+
diff --git a/clang/test/Parser/cxx-attributes.cpp b/clang/test/Parser/cxx-attributes.cpp
new file mode 100644
index 0000000..8603b30
--- /dev/null
+++ b/clang/test/Parser/cxx-attributes.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class c {
+ virtual void f1(const char* a, ...)
+ __attribute__ (( __format__(__printf__,2,3) )) = 0;
+ virtual void f2(const char* a, ...)
+ __attribute__ (( __format__(__printf__,2,3) )) {}
+};
+
diff --git a/clang/test/Parser/cxx-bool.cpp b/clang/test/Parser/cxx-bool.cpp
new file mode 100644
index 0000000..a8a161e
--- /dev/null
+++ b/clang/test/Parser/cxx-bool.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+bool a = true;
+bool b = false;
diff --git a/clang/test/Parser/cxx-casting.cpp b/clang/test/Parser/cxx-casting.cpp
new file mode 100644
index 0000000..42ad12e
--- /dev/null
+++ b/clang/test/Parser/cxx-casting.cpp
@@ -0,0 +1,92 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+char *const_cast_test(const char *var)
+{
+ return const_cast<char*>(var);
+}
+
+struct A {
+ virtual ~A() {}
+};
+
+struct B : public A {
+};
+
+struct B *dynamic_cast_test(struct A *a)
+{
+ return dynamic_cast<struct B*>(a);
+}
+
+char *reinterpret_cast_test()
+{
+ return reinterpret_cast<char*>(0xdeadbeef);
+}
+
+double static_cast_test(int i)
+{
+ return static_cast<double>(i);
+}
+
+char postfix_expr_test()
+{
+ return reinterpret_cast<char*>(0xdeadbeef)[0];
+}
+
+// This was being incorrectly tentatively parsed.
+namespace test1 {
+ template <class T> class A {}; // expected-note 2{{here}}
+ void foo() { A<int>(*(A<int>*)0); }
+}
+
+typedef char* c;
+typedef A* a;
+void test2(char x, struct B * b) {
+ (void)const_cast<::c>(&x); // expected-error{{found '<::' after a const_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}}
+ (void)dynamic_cast<::a>(b); // expected-error{{found '<::' after a dynamic_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}}
+ (void)reinterpret_cast<::c>(x); // expected-error{{found '<::' after a reinterpret_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}}
+ (void)static_cast<::c>(&x); // expected-error{{found '<::' after a static_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}}
+
+ // Do not do digraph correction.
+ (void)static_cast<: :c>(&x); //\
+ expected-error {{expected '<' after 'static_cast'}} \
+ expected-error {{expected expression}}\
+ expected-error {{expected ']'}}\
+ expected-note {{to match this '['}}
+ (void)static_cast<: // expected-error {{expected '<' after 'static_cast'}} \
+ expected-note {{to match this '['}}
+ :c>(&x); // expected-error {{expected expression}} \
+ expected-error {{expected ']'}}
+#define LC <:
+#define C :
+ test1::A LC:B> c; // expected-error {{cannot refer to class template 'A' without a template argument list}} expected-error 2{{}} expected-note{{}}
+ (void)static_cast LC:c>(&x); // expected-error {{expected '<' after 'static_cast'}} expected-error 2{{}} expected-note{{}}
+ test1::A<:C B> d; // expected-error {{cannot refer to class template 'A' without a template argument list}} expected-error 2{{}} expected-note{{}}
+ (void)static_cast<:C c>(&x); // expected-error {{expected '<' after 'static_cast'}} expected-error 2{{}} expected-note{{}}
+
+#define LCC <::
+ test1::A LCC B> e; // expected-error{{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}}
+ (void)static_cast LCC c>(&x); // expected-error{{found '<::' after a static_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}}
+}
+
+ // This note comes from "::D[:F> A5;"
+template <class T> class D {}; // expected-note{{template is declared here}}
+template <class T> void E() {};
+class F {};
+
+void test3() {
+ ::D<::F> A1; // expected-error{{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}}
+ D<::F> A2; // expected-error{{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}}
+ ::E<::F>(); // expected-error{{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}}
+ E<::F>(); // expected-error{{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}}
+
+ ::D< ::F> A3;
+ D< ::F> A4;
+ ::E< ::F>();
+ E< ::F>();
+
+ // Make sure that parser doesn't expand '[:' to '< ::'
+ ::D[:F> A5; // expected-error {{cannot refer to class template 'D' without a template argument list}} \
+ // expected-error {{expected expression}} \
+ // expected-error {{expected ']'}} \
+ // expected-note {{to match this '['}}
+}
diff --git a/clang/test/Parser/cxx-class.cpp b/clang/test/Parser/cxx-class.cpp
new file mode 100644
index 0000000..1b3dd41
--- /dev/null
+++ b/clang/test/Parser/cxx-class.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+class C;
+class C {
+public:
+protected:
+ typedef int A,B;
+ static int sf(), u;
+
+ struct S {};
+ enum {}; // expected-warning{{declaration does not declare anything}}
+ int; // expected-warning {{declaration does not declare anything}}
+ int : 1, : 2;
+
+public:
+ void m() {
+ int l = 2;
+ };
+
+ template<typename T> void mt(T) { };
+ ; // expected-warning{{extra ';' inside a class}}
+
+ virtual int vf() const volatile = 0;
+
+private:
+ int x,f(),y,g();
+ inline int h();
+ static const int sci = 10;
+ mutable int mi;
+};
+void glo()
+{
+ struct local {};
+}
+
+// PR3177
+typedef union {
+ __extension__ union {
+ int a;
+ float b;
+ } y;
+} bug3177;
+
+// check that we don't consume the token after the access specifier
+// when it's not a colon
+class D {
+public // expected-error{{expected ':'}}
+ int i;
+};
+
+// consume the token after the access specifier if it's a semicolon
+// that was meant to be a colon
+class E {
+public; // expected-error{{expected ':'}}
+ int i;
+};
+
+class F {
+ int F1 { return 1; } // expected-error{{function definition does not declare parameters}}
+ void F2 {} // expected-error{{function definition does not declare parameters}}
+ typedef int F3() { return 0; } // expected-error{{function definition declared 'typedef'}}
+ typedef void F4() {} // expected-error{{function definition declared 'typedef'}}
+};
+
+namespace ctor_error {
+ class Foo {};
+ // By [class.qual]p2, this is a constructor declaration.
+ Foo::Foo (F) = F(); // expected-error{{does not match any declaration in 'ctor_error::Foo'}}
+
+ class Ctor { // expected-note{{not complete until the closing '}'}}
+ Ctor(f)(int); // ok
+ Ctor(g(int)); // ok
+ Ctor(x[5]); // expected-error{{incomplete type}}
+
+ Ctor(UnknownType *); // expected-error{{unknown type name 'UnknownType'}}
+ void operator+(UnknownType*); // expected-error{{unknown type name 'UnknownType'}}
+ };
+
+ Ctor::Ctor (x) = { 0 }; // \
+ // expected-error{{qualified reference to 'Ctor' is a constructor name}}
+
+ Ctor::Ctor(UnknownType *) {} // \
+ // expected-error{{unknown type name 'UnknownType'}}
+ void Ctor::operator+(UnknownType*) {} // \
+ // expected-error{{unknown type name 'UnknownType'}}
+}
+
+// PR11109 must appear at the end of the source file
+class pr11109r3 { // expected-note{{to match this '{'}}
+ public // expected-error{{expected ':'}} expected-error{{expected '}'}} expected-error{{expected ';' after class}}
diff --git a/clang/test/Parser/cxx-condition.cpp b/clang/test/Parser/cxx-condition.cpp
new file mode 100644
index 0000000..5672eea
--- /dev/null
+++ b/clang/test/Parser/cxx-condition.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct S { S(int); operator bool(); };
+
+void f() {
+ int a;
+ while (a) ;
+ while (int x) ; // expected-error {{variable declaration in condition must have an initializer}}
+ while (float x = 0) ;
+ if (const int x = a) ; // expected-warning{{empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ switch (int x = a+10) {}
+ for (; int x = ++a; ) ;
+
+ if (S a(42)) {} // expected-error {{variable declaration in condition cannot have a parenthesized initializer}}
+}
diff --git a/clang/test/Parser/cxx-decl.cpp b/clang/test/Parser/cxx-decl.cpp
new file mode 100644
index 0000000..57f33d8
--- /dev/null
+++ b/clang/test/Parser/cxx-decl.cpp
@@ -0,0 +1,129 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux %s
+
+int x(*g); // expected-error {{use of undeclared identifier 'g'}}
+
+struct Type {
+ int Type;
+};
+
+// rdar://8365458
+// rdar://9132143
+typedef char bool; // expected-error {{redeclaration of C++ built-in type 'bool'}}
+
+// PR4451 - We should recover well from the typo of '::' as ':' in a2.
+namespace y {
+ struct a { };
+ typedef int b;
+}
+
+y::a a1;
+y:a a2; // expected-error {{unexpected ':' in nested name specifier}}
+y::a a3 = a2;
+
+// Some valid colons:
+void foo() {
+y: // label
+ y::a s;
+
+ int a = 4;
+ a = a ? a : a+1;
+}
+
+struct b : y::a {};
+
+template <typename T>
+class someclass {
+
+ int bar() {
+ T *P;
+ return 1 ? P->x : P->y;
+ }
+};
+
+class asm_class_test {
+ void foo() __asm__("baz");
+};
+
+enum { fooenum = 1 };
+
+struct a {
+ int Type : fooenum;
+};
+
+void test(struct Type *P) {
+ int Type;
+ Type = 1 ? P->Type : Type;
+
+ Type = (y:b) 4; // expected-error {{unexpected ':' in nested name specifier}}
+ Type = 1 ? (
+ (y:b) // expected-error {{unexpected ':' in nested name specifier}}
+ 4) : 5;
+}
+
+struct test4 {
+ int x // expected-error {{expected ';' at end of declaration list}}
+ int y;
+ int z // expected-error {{expected ';' at end of declaration list}}
+};
+
+// Make sure we know these are legitimate commas and not typos for ';'.
+namespace Commas {
+ struct S {
+ static int a;
+ int c,
+ operator()();
+ };
+
+ int global1,
+ __attribute__(()) global2,
+ (global5),
+ *global6,
+ &global7 = global1,
+ &&global8 = static_cast<int&&>(global1), // expected-warning 2{{rvalue reference}}
+ S::a,
+ global9,
+ global10 = 0,
+ global11 == 0, // expected-error {{did you mean '='}}
+ global12 __attribute__(()),
+ global13(0),
+ global14[2],
+ global15;
+
+ void g() {
+ static int a,
+ b __asm__("ebx"), // expected-error {{expected ';' at end of declaration}}
+ Statics:return;
+ }
+}
+
+// PR5825
+struct test5 {};
+::new(static_cast<void*>(0)) test5; // expected-error {{expected unqualified-id}}
+
+
+// PR6782
+template<class T>
+class Class1;
+
+class Class2 {
+} // no ;
+
+typedef Class1<Class2> Type1; // expected-error {{cannot combine with previous 'class' declaration specifier}}
+
+// rdar : // 8307865
+struct CodeCompleteConsumer {
+};
+
+void CodeCompleteConsumer::() { // expected-error {{xpected unqualified-id}}
+}
+
+;
+
+// PR8380
+extern "" // expected-error {{unknown linkage language}}
+test6a { ;// expected-error {{C++ requires a type specifier for all declarations}} \
+ // expected-error {{expected ';' after top level declarator}}
+
+ int test6b;
+
+
diff --git a/clang/test/Parser/cxx-default-args.cpp b/clang/test/Parser/cxx-default-args.cpp
new file mode 100644
index 0000000..7fe8474
--- /dev/null
+++ b/clang/test/Parser/cxx-default-args.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR6647
+class C {
+ // After the error, the rest of the tokens inside the default arg should be
+ // skipped, avoiding a "expected ';' after class" after 'undecl'.
+ void m(int x = undecl + 0); // expected-error {{use of undeclared identifier 'undecl'}}
+};
+
+typedef struct Inst {
+ void m(int x=0);
+} *InstPtr;
+
+struct X {
+ void f(int x = 1:); // expected-error {{unexpected end of default argument expression}}
+};
diff --git a/clang/test/Parser/cxx-default-delete.cpp b/clang/test/Parser/cxx-default-delete.cpp
new file mode 100644
index 0000000..df24b3d
--- /dev/null
+++ b/clang/test/Parser/cxx-default-delete.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+int i = delete; // expected-error{{only functions}}
+int j = default; // expected-error{{special member functions}}
+
+int f() = delete, g; // expected-error{{'= delete' is a function definition}}
+int o, p() = delete; // expected-error{{'= delete' is a function definition}}
+
+int q() = default, r; // expected-error{{only special member functions}} \
+ // expected-error{{'= default' is a function definition}}
+int s, t() = default; // expected-error{{'= default' is a function definition}}
+
+struct foo {
+ foo() = default;
+ ~foo() = delete;
+ void bar() = delete;
+};
+
+void baz() = delete;
+
+struct quux {
+ int quux() = default; // expected-error{{constructor cannot have a return type}} expected-error {{member 'quux' has the same name as its class}}
+};
diff --git a/clang/test/Parser/cxx-ext-delete-default.cpp b/clang/test/Parser/cxx-ext-delete-default.cpp
new file mode 100644
index 0000000..af8b6d6
--- /dev/null
+++ b/clang/test/Parser/cxx-ext-delete-default.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+
+struct A {
+ A(const A&) = delete; // expected-warning {{C++11 extension}}
+ A& operator=(const A&) = delete; // expected-warning {{C++11 extension}}
+ A() = default; // expected-warning {{C++11 extension}}
+ ~A();
+};
+
+void f() = delete; // expected-warning {{C++11 extension}}
+A::~A() = default; //expected-warning {{C++11 extension}}
diff --git a/clang/test/Parser/cxx-extern-c-array.cpp b/clang/test/Parser/cxx-extern-c-array.cpp
new file mode 100644
index 0000000..14912fd
--- /dev/null
+++ b/clang/test/Parser/cxx-extern-c-array.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+extern "C" int myarray[];
+int myarray[12] = {0};
+
+extern "C" int anotherarray[][3];
+int anotherarray[2][3] = {1,2,3,4,5,6};
diff --git a/clang/test/Parser/cxx-friend.cpp b/clang/test/Parser/cxx-friend.cpp
new file mode 100644
index 0000000..a13e7ba
--- /dev/null
+++ b/clang/test/Parser/cxx-friend.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class C {
+ friend class D;
+};
+
+class A {
+public:
+ void f();
+};
+
+friend int x; // expected-error {{'friend' used outside of class}}
+
+friend class D {}; // expected-error {{'friend' used outside of class}}
+
+union U {
+ int u1;
+};
+
+class B {
+ // 'A' here should refer to the declaration above.
+ friend class A;
+
+ friend C; // expected-warning {{specify 'class' to befriend}}
+ friend U; // expected-warning {{specify 'union' to befriend}}
+ friend int; // expected-warning {{non-class friend type 'int'}}
+
+ friend void myfunc();
+
+ void f(A *a) { a->f(); }
+};
+
+
+
+
+
+template <typename t1, typename t2> class some_template;
+friend // expected-error {{'friend' used outside of class}}
+some_template<foo, bar>& // expected-error {{use of undeclared identifier 'foo'}}
+ ; // expected-error {{expected unqualified-id}}
diff --git a/clang/test/Parser/cxx-in-c.c b/clang/test/Parser/cxx-in-c.c
new file mode 100644
index 0000000..f5fa39b
--- /dev/null
+++ b/clang/test/Parser/cxx-in-c.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR9137
+void f0(int x) : {}; // expected-error{{expected function body after function declarator}}
+void f1(int x) try {}; // expected-error{{expected function body after function declarator}}
diff --git a/clang/test/Parser/cxx-member-crash.cpp b/clang/test/Parser/cxx-member-crash.cpp
new file mode 100644
index 0000000..2b31a60
--- /dev/null
+++ b/clang/test/Parser/cxx-member-crash.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1|FileCheck %s
+
+// <rdar://problem/9221993>
+
+// We only care to chek whether the compiler crashes; the actual
+// diagnostics are uninteresting.
+// CHECK: 8 errors generated.
+template<class _CharT> struct char_traits;
+template<typename _CharT, typename _Traits = char_traits<_CharT> > class basic_ios;
+template<typename _CharT, typename _Traits = char_traits<_CharT> > class ostreambuf_iterator;
+template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> > class num_get;
+template<typename _CharT, typename _Traits> class basic_ostream : virtual public basic_ios<_CharT, _Traits> {
+ template<typename _CharT, typename _InIter> _InIter num_get<_CharT, _InIter>:: _M_extract_float(_InIter __beg, _InIter __end, ios_base& __io, ios_base::iostate& __err, string& __xtrc) const {
+ const bool __plus = __c == __lit[__num_base::_S_iplus];
+ if ((__plus || __c == __lit[__num_base::_S_iminus]) && !(__lc->_M_use_grouping && __c == __lc->_M_thousands_sep) && !(__c == __lc->_M_decimal_point)) {
diff --git a/clang/test/Parser/cxx-member-init-missing-paren-crash.cpp b/clang/test/Parser/cxx-member-init-missing-paren-crash.cpp
new file mode 100644
index 0000000..5485e7d
--- /dev/null
+++ b/clang/test/Parser/cxx-member-init-missing-paren-crash.cpp
@@ -0,0 +1,12 @@
+// RUN: not %clang_cc1 -fsyntax-only %s
+// Note: The important part here is that we don't crash, not any specific errors
+class Test {
+ public:
+ Test() : ab_(false {};
+
+ bool ab() {
+ return ab_;
+ }
+ private:
+ bool ab_;
+}
diff --git a/clang/test/Parser/cxx-member-initializers.cpp b/clang/test/Parser/cxx-member-initializers.cpp
new file mode 100644
index 0000000..5c39068
--- /dev/null
+++ b/clang/test/Parser/cxx-member-initializers.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct x {
+ x() : a(4) ; // expected-error {{expected '{'}}
+};
+
+struct y {
+ int a;
+ y() : a(4) ; // expected-error {{expected '{'}}
+};
+
+struct z {
+ int a;
+ z() : a {} // expected-error {{expected '('}}
+};
diff --git a/clang/test/Parser/cxx-namespace-alias.cpp b/clang/test/Parser/cxx-namespace-alias.cpp
new file mode 100644
index 0000000..9b90aab
--- /dev/null
+++ b/clang/test/Parser/cxx-namespace-alias.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace A = B; // expected-error{{namespace name}}
+
+namespace A = !; // expected-error {{expected namespace name}}
+namespace A = A::!; // expected-error {{expected namespace name}} \
+ // expected-error{{use of undeclared identifier 'A'}}
+
+
diff --git a/clang/test/Parser/cxx-reference.cpp b/clang/test/Parser/cxx-reference.cpp
new file mode 100644
index 0000000..d21412c
--- /dev/null
+++ b/clang/test/Parser/cxx-reference.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+extern char *bork;
+char *& bar = bork;
+
+int val;
+
+void foo(int &a) {
+}
+
+typedef int & A;
+
+void g(const A aref) {
+}
+
+int & const X = val; // expected-error {{'const' qualifier may not be applied to a reference}}
+int & volatile Y = val; // expected-error {{'volatile' qualifier may not be applied to a reference}}
+int & const volatile Z = val; /* expected-error {{'const' qualifier may not be applied}} \
+ expected-error {{'volatile' qualifier may not be applied}} */
+
+typedef int && RV; // expected-warning {{rvalue references are a C++11 extension}}
diff --git a/clang/test/Parser/cxx-stmt.cpp b/clang/test/Parser/cxx-stmt.cpp
new file mode 100644
index 0000000..7677ca8
--- /dev/null
+++ b/clang/test/Parser/cxx-stmt.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
+
+void f1()
+{
+ try {
+ ;
+ } catch(int i) {
+ ;
+ } catch(...) {
+ }
+}
+
+void f2()
+{
+ try; // expected-error {{expected '{'}}
+
+ try {}
+ catch; // expected-error {{expected '('}}
+
+ try {}
+ catch (...); // expected-error {{expected '{'}}
+
+ try {}
+ catch {} // expected-error {{expected '('}}
+}
+
+void f3() try {
+} catch(...) {
+}
+
+struct A {
+ int i;
+ A(int);
+ A(char);
+ A() try : i(0) {} catch(...) {}
+ void f() try {} catch(...) {}
+ A(float) : i(0) try {} // expected-error {{expected '{' or ','}}
+};
+
+A::A(char) : i(0) try {} // expected-error {{expected '{' or ','}}
+A::A(int j) try : i(j) {} catch(...) {}
+
+
+
+// PR5740
+struct Type { };
+
+enum { Type } Kind;
+void f4() {
+ int i = 0;
+ switch (Kind) {
+ case Type: i = 7; break; // no error.
+ }
+}
+
+// PR5500
+void f5() {
+ asm volatile ("":: :"memory");
+ asm volatile ("": ::"memory");
+}
diff --git a/clang/test/Parser/cxx-template-argument.cpp b/clang/test/Parser/cxx-template-argument.cpp
new file mode 100644
index 0000000..c85b1c9
--- /dev/null
+++ b/clang/test/Parser/cxx-template-argument.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> struct A {};
+
+// Check for template argument lists followed by junk
+// FIXME: The diagnostics here aren't great...
+A<int+> int x; // expected-error {{expected '>'}} expected-error {{expected unqualified-id}}
+A<int x; // expected-error {{expected '>'}}
+
+// PR8912
+template <bool> struct S {};
+S<bool(2 > 1)> s;
diff --git a/clang/test/Parser/cxx-template-decl.cpp b/clang/test/Parser/cxx-template-decl.cpp
new file mode 100644
index 0000000..7e931a3
--- /dev/null
+++ b/clang/test/Parser/cxx-template-decl.cpp
@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Errors
+export class foo { }; // expected-error {{expected template}}
+template x; // expected-error {{C++ requires a type specifier for all declarations}} \
+ // expected-error {{does not refer}}
+export template x; // expected-error {{expected '<' after 'template'}}
+export template<class T> class x0; // expected-warning {{exported templates are unsupported}}
+template < ; // expected-error {{expected template parameter}} \
+// expected-error{{expected ',' or '>' in template-parameter-list}} \
+// expected-warning {{declaration does not declare anything}}
+template <int +> struct x1; // expected-error {{expected ',' or '>' in template-parameter-list}}
+
+// verifies that we only walk to the ',' & still produce errors on the rest of the template parameters
+template <int +, T> struct x2; // expected-error {{expected ',' or '>' in template-parameter-list}} \
+ expected-error {{expected unqualified-id}}
+template<template<int+>> struct x3; // expected-error {{expected ',' or '>' in template-parameter-list}} \
+ expected-error {{template template parameter requires 'class' after the parameter list}}
+template <template X> struct Err1; // expected-error {{expected '<' after 'template'}} \
+// expected-error{{extraneous}}
+template <template <typename> > struct Err2; // expected-error {{template template parameter requires 'class' after the parameter list}}
+template <template <typename> Foo> struct Err3; // expected-error {{template template parameter requires 'class' after the parameter list}}
+
+// Template function declarations
+template <typename T> void foo();
+template <typename T, typename U> void foo();
+
+// Template function definitions.
+template <typename T> void foo() { }
+
+// Template class (forward) declarations
+template <typename T> struct A;
+template <typename T, typename U> struct b;
+template <typename> struct C;
+template <typename, typename> struct D;
+
+// Forward declarations with default parameters?
+template <typename T = int> class X1;
+template <typename = int> class X2;
+
+// Forward declarations w/template template parameters
+template <template <typename> class T> class TTP1;
+template <template <typename> class> class TTP2;
+template <template <typename> class T = foo> class TTP3; // expected-error{{must be a class template}}
+template <template <typename> class = foo> class TTP3; // expected-error{{must be a class template}}
+template <template <typename X, typename Y> class T> class TTP5;
+
+// Forward declarations with non-type params
+template <int> class NTP0;
+template <int N> class NTP1;
+template <int N = 5> class NTP2;
+template <int = 10> class NTP3;
+template <unsigned int N = 12u> class NTP4;
+template <unsigned int = 12u> class NTP5;
+template <unsigned = 15u> class NTP6;
+template <typename T, T Obj> class NTP7;
+
+// Template class declarations
+template <typename T> struct A { };
+template <typename T, typename U> struct B { };
+
+// Template parameter shadowing
+template<typename T, // expected-note{{template parameter is declared here}}
+ typename T> // expected-error{{declaration of 'T' shadows template parameter}}
+ void shadow1();
+
+template<typename T> // expected-note{{template parameter is declared here}}
+void shadow2(int T); // expected-error{{declaration of 'T' shadows template parameter}}
+
+template<typename T> // expected-note{{template parameter is declared here}}
+class T { // expected-error{{declaration of 'T' shadows template parameter}}
+};
+
+template<int Size> // expected-note{{template parameter is declared here}}
+void shadow3(int Size); // expected-error{{declaration of 'Size' shadows template parameter}}
+
+// <rdar://problem/6952203>
+template<typename T> // expected-note{{here}}
+struct shadow4 {
+ int T; // expected-error{{shadows}}
+};
+
+template<typename T> // expected-note{{here}}
+struct shadow5 {
+ int T(int, float); // expected-error{{shadows}}
+};
+
+// Non-type template parameters in scope
+template<int Size>
+void f(int& i) {
+ i = Size;
+ Size = i; // expected-error{{expression is not assignable}}
+}
+
+template<typename T>
+const T& min(const T&, const T&);
+
+void f2() {
+ int x;
+ A< typeof(x>1) > a;
+}
+
+
+// PR3844
+template <> struct S<int> { }; // expected-error{{explicit specialization of non-template struct 'S'}}
+
+namespace PR6184 {
+ namespace N {
+ template <typename T>
+ void bar(typename T::x);
+ }
+
+ template <typename T>
+ void N::bar(typename T::x) { }
+}
diff --git a/clang/test/Parser/cxx-throw.cpp b/clang/test/Parser/cxx-throw.cpp
new file mode 100644
index 0000000..d63b6d4
--- /dev/null
+++ b/clang/test/Parser/cxx-throw.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
+
+int i;
+
+void foo() {
+ (throw,throw);
+ (1 ? throw 1 : throw 2);
+ throw int(1);
+ throw;
+ throw 1;
+ throw;
+ 1 ? throw : (void)42;
+ __extension__ throw 1; // expected-error {{expected expression}}
+ (void)throw; // expected-error {{expected expression}}
+}
diff --git a/clang/test/Parser/cxx-typeid.cpp b/clang/test/Parser/cxx-typeid.cpp
new file mode 100644
index 0000000..e726665
--- /dev/null
+++ b/clang/test/Parser/cxx-typeid.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// FIXME: This should really include <typeinfo>, but we don't have that yet.
+namespace std {
+ class type_info;
+}
+
+void f()
+{
+ (void)typeid(int);
+ (void)typeid(0);
+ (void)typeid 1; // expected-error {{expected '(' after 'typeid'}}
+}
diff --git a/clang/test/Parser/cxx-typeof.cpp b/clang/test/Parser/cxx-typeof.cpp
new file mode 100644
index 0000000..1ec6e29
--- /dev/null
+++ b/clang/test/Parser/cxx-typeof.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+static void test() {
+ int *pi;
+ int x;
+ typeof pi[x] y;
+}
+
+// Part of rdar://problem/8347416; from the gcc test suite.
+struct S {
+ int i;
+ __typeof(S::i) foo(); // expected-error {{invalid use of non-static data member 'i'}}
+};
diff --git a/clang/test/Parser/cxx-undeclared-identifier.cpp b/clang/test/Parser/cxx-undeclared-identifier.cpp
new file mode 100644
index 0000000..f15deab
--- /dev/null
+++ b/clang/test/Parser/cxx-undeclared-identifier.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+
+// PR7180
+int f(a::b::c); // expected-error {{use of undeclared identifier 'a'}}
+
+class Foo::Bar { // expected-error {{use of undeclared identifier 'Foo'}} \
+ // expected-note {{to match this '{'}} \
+ // expected-error {{expected ';' after class}}
+ // expected-error {{expected '}'}}
diff --git a/clang/test/Parser/cxx-using-declaration.cpp b/clang/test/Parser/cxx-using-declaration.cpp
new file mode 100644
index 0000000..2b2a69d
--- /dev/null
+++ b/clang/test/Parser/cxx-using-declaration.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace A {
+ int VA;
+ void FA() {}
+ struct SA { int V; };
+}
+
+using A::VA;
+using A::FA;
+using typename A::SA;
+
+int main()
+{
+ VA = 1;
+ FA();
+ SA x; //Still needs handling.
+}
+
+struct B {
+ void f(char){};
+ void g(char){};
+};
+struct D : B {
+ using B::f;
+ void f(int);
+ void g(int);
+};
+void D::f(int) { f('c'); } // calls B::f(char)
+void D::g(int) { g('c'); } // recursively calls D::g(int)
+
+namespace E {
+ template <typename TYPE> int funcE(TYPE arg) { return(arg); }
+}
+
+using E::funcE<int>; // expected-error{{using declaration can not refer to a template specialization}}
+
+namespace F {
+ struct X;
+}
+
+using F::X;
+// Should have some errors here. Waiting for implementation.
+void X(int);
+struct X *x;
diff --git a/clang/test/Parser/cxx-using-directive.cpp b/clang/test/Parser/cxx-using-directive.cpp
new file mode 100644
index 0000000..1d781fb
--- /dev/null
+++ b/clang/test/Parser/cxx-using-directive.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class A {};
+
+namespace B {
+ namespace A {} // expected-note{{namespace '::B::A' defined here}}
+ using namespace A ;
+}
+
+namespace C {}
+
+namespace D {
+
+ class C {
+
+ using namespace B ; // expected-error{{not allowed}}
+ };
+
+ namespace B {}
+
+ using namespace C ;
+ using namespace B::A ; // expected-error{{no namespace named 'A' in namespace 'D::B'; did you mean '::B::A'?}}
+ using namespace ::B::A ;
+ using namespace ::D::C ; // expected-error{{expected namespace name}}
+}
+
+using namespace ! ; // expected-error{{expected namespace name}}
+using namespace A ; // expected-error{{expected namespace name}}
+using namespace ::A // expected-error{{expected namespace name}} \
+ // expected-error{{expected ';' after namespace name}}
+ B ;
+
+void test_nslookup() {
+ int B;
+ class C;
+ using namespace B;
+ using namespace C;
+}
diff --git a/clang/test/Parser/cxx-variadic-func.cpp b/clang/test/Parser/cxx-variadic-func.cpp
new file mode 100644
index 0000000..b9360d6
--- /dev/null
+++ b/clang/test/Parser/cxx-variadic-func.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+void f(...) {
+ int g(int(...));
+}
diff --git a/clang/test/Parser/cxx0x-ambig.cpp b/clang/test/Parser/cxx0x-ambig.cpp
new file mode 100644
index 0000000..98757b4
--- /dev/null
+++ b/clang/test/Parser/cxx0x-ambig.cpp
@@ -0,0 +1,127 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// New exciting ambiguities in C++11
+
+// final 'context sensitive' mess.
+namespace final {
+ struct S { int n; };
+ struct T { int n; };
+ namespace N {
+ int n;
+ // These declare variables named final..
+ extern struct S final;
+ extern struct S final [[]];
+ extern struct S final, foo;
+ struct S final = S();
+
+ // This defines a class, not a variable, even though it would successfully
+ // parse as a variable but not as a class. DR1318's wording suggests that
+ // this disambiguation is only performed on an ambiguity, but that was not
+ // the intent.
+ struct S final { // expected-note {{here}}
+ int(n) // expected-error {{expected ';'}}
+ };
+ // This too.
+ struct T final : S {}; // expected-error {{base 'S' is marked 'final'}}
+ struct T bar : S {}; // expected-error {{expected ';' after top level declarator}} expected-error {{expected unqualified-id}}
+ }
+}
+
+// enum versus bitfield mess.
+namespace bitfield {
+ enum E {};
+
+ struct T {
+ constexpr T() {}
+ constexpr T(int) {}
+ constexpr T(T, T, T, T) {}
+ constexpr T operator=(T) { return *this; }
+ constexpr operator int() { return 4; }
+ };
+ constexpr T a, b, c, d;
+
+ struct S1 {
+ enum E : T ( a = 1, b = 2, c = 3, 4 ); // ok, declares a bitfield
+ };
+ // This could be a bit-field.
+ struct S2 {
+ enum E : T { a = 1, b = 2, c = 3, 4 }; // expected-error {{non-integral type}} expected-error {{expected '}'}} expected-note {{to match}}
+ };
+ struct S3 {
+ enum E : int { a = 1, b = 2, c = 3, d }; // ok, defines an enum
+ };
+ // Ambiguous.
+ struct S4 {
+ enum E : int { a = 1 }; // ok, defines an enum
+ };
+ // This could be a bit-field, but would be ill-formed due to the anonymous
+ // member being initialized.
+ struct S5 {
+ enum E : int { a = 1 } { b = 2 }; // expected-error {{expected member name}}
+ };
+ // This could be a bit-field.
+ struct S6 {
+ enum E : int { 1 }; // expected-error {{expected '}'}} expected-note {{to match}}
+ };
+
+ struct U {
+ constexpr operator T() { return T(); } // expected-note 2{{candidate}}
+ };
+ // This could be a bit-field.
+ struct S7 {
+ enum E : int { a = U() }; // expected-error {{no viable conversion}}
+ };
+ // This could be a bit-field, and does not conform to the grammar of an
+ // enum definition, because 'id(U())' is not a constant-expression.
+ constexpr const U &id(const U &u) { return u; }
+ struct S8 {
+ enum E : int { a = id(U()) }; // expected-error {{no viable conversion}}
+ };
+}
+
+namespace trailing_return {
+ typedef int n;
+ int a;
+
+ struct S {
+ S(int);
+ S *operator()() const;
+ int n;
+ };
+
+ namespace N {
+ void f() {
+ // This parses as a function declaration, but DR1223 makes the presence of
+ // 'auto' be used for disambiguation.
+ S(a)()->n; // ok, expression; expected-warning{{expression result unused}}
+ auto(a)()->n; // ok, function declaration
+ using T = decltype(a);
+ using T = auto() -> n;
+ }
+ }
+}
+
+namespace ellipsis {
+ template<typename...T>
+ struct S {
+ void e(S::S());
+ void f(S(...args[sizeof(T)])); // expected-note {{here}}
+ void f(S(...args)[sizeof(T)]); // expected-error {{redeclared}} expected-note {{here}}
+ void f(S ...args[sizeof(T)]); // expected-error {{redeclared}}
+ void g(S(...[sizeof(T)])); // expected-note {{here}}
+ void g(S(...)[sizeof(T)]); // expected-error {{function cannot return array type}}
+ void g(S ...[sizeof(T)]); // expected-error {{redeclared}}
+ void h(T(...)); // function type, expected-error {{unexpanded parameter pack}}
+ void h(T...); // pack expansion, ok
+ void i(int(T...)); // expected-note {{here}}
+ void i(int(T...a)); // expected-error {{redeclared}}
+ void i(int(T, ...)); // function type, expected-error {{unexpanded parameter pack}}
+ void i(int(T, ...a)); // expected-error {{expected ')'}} expected-note {{to match}} expected-error {{unexpanded parameter pack}}
+ void j(int(int...)); // function type, ok
+ void j(int(int...a)); // expected-error {{does not contain any unexpanded parameter packs}}
+ void j(T(int...)); // expected-error {{unexpanded parameter pack}}
+ void j(T(T...)); // expected-error {{unexpanded parameter pack}}
+ void k(int(...)(T)); // expected-error {{cannot return function type}}
+ void k(int ...(T));
+ };
+}
diff --git a/clang/test/Parser/cxx0x-attributes.cpp b/clang/test/Parser/cxx0x-attributes.cpp
new file mode 100644
index 0000000..f97995e
--- /dev/null
+++ b/clang/test/Parser/cxx0x-attributes.cpp
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s
+
+// Declaration syntax checks
+[[]] int before_attr;
+int [[]] between_attr;
+int after_attr [[]];
+int * [[]] ptr_attr;
+int & [[]] ref_attr = after_attr;
+int && [[]] rref_attr = 0;
+int array_attr [1] [[]];
+alignas(8) int aligned_attr;
+[[test::valid(for 42 [very] **** '+' symbols went on a trip; the end.)]]
+ int garbage_attr;
+[[,,,static, class, namespace,, inline, constexpr, mutable,, bi\
+tand, bitor::compl(!.*_ Cx.!U^*R),,,]] int more_garbage_attr;
+[[u8"invalid!"]] int invalid_string_attr; // expected-error {{expected ']'}}
+void fn_attr () [[]];
+void noexcept_fn_attr () noexcept [[]];
+struct MemberFnOrder {
+ virtual void f() const volatile && noexcept [[]] final = 0;
+};
+class [[]] class_attr {};
+extern "C++" [[]] int extern_attr;
+template <typename T> [[]] void template_attr ();
+[[]] [[]] int [[]] [[]] multi_attr [[]] [[]];
+
+int comma_attr [[,]];
+int scope_attr [[foo::]]; // expected-error {{expected identifier}}
+int (paren_attr) [[]]; // expected-error {{an attribute list cannot appear here}}
+unsigned [[]] int attr_in_decl_spec; // expected-error {{expected unqualified-id}}
+class foo {
+ void const_after_attr () [[]] const; // expected-error {{expected ';'}}
+};
+extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}}
+[[]] template <typename T> void before_template_attr (); // expected-error {{an attribute list cannot appear here}}
+[[]] namespace ns { int i; } // expected-error {{an attribute list cannot appear here}} expected-note {{declared here}}
+[[]] static_assert(true, ""); //expected-error {{an attribute list cannot appear here}}
+[[]] asm(""); // expected-error {{an attribute list cannot appear here}}
+
+[[]] using ns::i; // expected-error {{an attribute list cannot appear here}}
+[[]] using namespace ns;
+
+// Argument tests
+alignas int aligned_no_params; // expected-error {{expected '('}}
+alignas(i) int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}} expected-note {{read of non-const variable 'i'}}
+
+// Statement tests
+void foo () {
+ [[]] ;
+ [[]] { }
+ [[]] if (0) { }
+ [[]] for (;;);
+ [[]] do {
+ [[]] continue;
+ } while (0);
+ [[]] while (0);
+
+ [[]] switch (i) {
+ [[]] case 0:
+ [[]] default:
+ [[]] break;
+ }
+
+ [[]] goto there;
+ [[]] there:
+
+ [[]] try {
+ } [[]] catch (...) { // expected-error {{an attribute list cannot appear here}}
+ }
+ struct S { int arr[2]; } s;
+ (void)s.arr[ [] { return 0; }() ]; // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}}
+ int n = __builtin_offsetof(S, arr[ [] { return 0; }() ]); // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}}
+
+ void bar [[noreturn]] ([[]] int i, [[]] int j);
+ using FuncType = void ([[]] int);
+ void baz([[]]...); // expected-error {{expected parameter declarator}}
+
+ [[]] return;
+}
+
+template<typename...Ts> void variadic() {
+ void bar [[noreturn...]] (); // expected-error {{attribute 'noreturn' cannot be used as an attribute pack}}
+}
diff --git a/clang/test/Parser/cxx0x-condition.cpp b/clang/test/Parser/cxx0x-condition.cpp
new file mode 100644
index 0000000..e45cd86
--- /dev/null
+++ b/clang/test/Parser/cxx0x-condition.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct S { S(int); operator bool(); };
+
+void f() {
+ int a;
+ typedef int n;
+
+ while (a) ;
+ while (int x) ; // expected-error {{variable declaration in condition must have an initializer}}
+ while (float x = 0) ;
+ if (const int x = a) ; // expected-warning{{empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ switch (int x = a+10) {}
+ for (; int x = ++a; ) ;
+
+ if (S(a)) {} // ok
+ if (S(a) = 0) {} // ok
+ if (S(a) == 0) {} // ok
+
+ if (S(n)) {} // expected-error {{unexpected type name 'n': expected expression}}
+ if (S(n) = 0) {} // ok
+ if (S(n) == 0) {} // expected-error {{unexpected type name 'n': expected expression}}
+
+ if (S b(a)) {} // expected-error {{variable declaration in condition cannot have a parenthesized initializer}}
+
+ if (S b(n)) {} // expected-error {{a function type is not allowed here}} expected-error {{must have an initializer}}
+ if (S b(n) = 0) {} // expected-error {{a function type is not allowed here}}
+ if (S b(n) == 0) {} // expected-error {{a function type is not allowed here}} expected-error {{did you mean '='?}}
+
+ if (S{a}) {} // ok
+ if (S a{a}) {} // ok
+ if (S a = {a}) {} // ok
+ if (S a == {a}) {} // expected-error {{did you mean '='?}}
+
+ if (S(b){a}) {} // ok
+ if (S(b) = {a}) {} // ok
+}
diff --git a/clang/test/Parser/cxx0x-decl.cpp b/clang/test/Parser/cxx0x-decl.cpp
new file mode 100644
index 0000000..b9f5141
--- /dev/null
+++ b/clang/test/Parser/cxx0x-decl.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++0x %s
+
+// Make sure we know these are legitimate commas and not typos for ';'.
+namespace Commas {
+ int a,
+ b [[ ]],
+ c alignas(double);
+}
+
+struct S {};
+enum E { e };
+
+auto f() -> struct S {
+ return S();
+}
+auto g() -> enum E {
+ return E();
+}
diff --git a/clang/test/Parser/cxx0x-for-range.cpp b/clang/test/Parser/cxx0x-for-range.cpp
new file mode 100644
index 0000000..f920ef9
--- /dev/null
+++ b/clang/test/Parser/cxx0x-for-range.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template<typename T, typename U>
+struct pair {};
+
+template<typename T, typename U>
+struct map {
+ typedef pair<T,U> *iterator;
+ iterator begin();
+ iterator end();
+};
+
+template<typename T, typename U>
+pair<T,U> &tie(T &, U &);
+
+int foo(map<char*,int> &m) {
+ char *p;
+ int n;
+
+ for (pair<char*,int> x : m) {
+ (void)x;
+ }
+
+ for (tie(p, n) : m) { // expected-error {{for range declaration must declare a variable}}
+ (void)p;
+ (void)n;
+ }
+
+ return n;
+}
diff --git a/clang/test/Parser/cxx0x-in-cxx98.cpp b/clang/test/Parser/cxx0x-in-cxx98.cpp
new file mode 100644
index 0000000..b4bda89
--- /dev/null
+++ b/clang/test/Parser/cxx0x-in-cxx98.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s
+
+inline namespace N { // expected-warning{{inline namespaces are a C++11 feature}}
+struct X {
+ template<typename ...Args> // expected-warning{{variadic templates are a C++11 extension}}
+ void f(Args &&...) &; // expected-warning{{rvalue references are a C++11 extension}} \
+ // expected-warning{{reference qualifiers on functions are a C++11 extension}}
+};
+}
+
+struct B {
+ virtual void f();
+ virtual void g();
+};
+struct D final : B { // expected-warning {{'final' keyword is a C++11 extension}}
+ virtual void f() override; // expected-warning {{'override' keyword is a C++11 extension}}
+ virtual void g() final; // expected-warning {{'final' keyword is a C++11 extension}}
+};
+
+void NewBracedInitList() {
+ // A warning on this would be sufficient once we can handle it correctly.
+ new int {}; // expected-error {{}}
+}
diff --git a/clang/test/Parser/cxx0x-lambda-expressions.cpp b/clang/test/Parser/cxx0x-lambda-expressions.cpp
new file mode 100644
index 0000000..9c71941
--- /dev/null
+++ b/clang/test/Parser/cxx0x-lambda-expressions.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=c++11 %s
+
+enum E { e };
+
+class C {
+
+ int f() {
+ int foo, bar;
+
+ []; // expected-error {{expected body of lambda expression}}
+ [+] {}; // expected-error {{expected variable name or 'this' in lambda capture list}}
+ [foo+] {}; // expected-error {{expected ',' or ']' in lambda capture list}}
+ [foo,&this] {}; // expected-error {{'this' cannot be captured by reference}}
+ [&this] {}; // expected-error {{'this' cannot be captured by reference}}
+ [&,] {}; // expected-error {{expected variable name or 'this' in lambda capture list}}
+ [=,] {}; // expected-error {{expected variable name or 'this' in lambda capture list}}
+ [] {};
+ [=] (int i) {};
+ [&] (int) mutable -> void {};
+ [foo,bar] () { return 3; };
+ [=,&foo] () {};
+ [&,foo] () {};
+ [this] () {};
+ [] () -> class C { return C(); };
+ [] () -> enum E { return e; };
+
+ [] -> int { return 0; }; // expected-error{{lambda requires '()' before return type}}
+ [] mutable -> int { return 0; }; // expected-error{{lambda requires '()' before 'mutable'}}
+ return 1;
+ }
+
+ void designator_or_lambda() {
+ typedef int T;
+ const int b = 0;
+ const int c = 1;
+ int a1[1] = {[b] (T()) {}}; // expected-error{{no viable conversion from 'C::<lambda}}
+ int a2[1] = {[b] = 1 };
+ int a3[1] = {[b,c] = 1 }; // expected-error{{expected body of lambda expression}}
+ int a4[1] = {[&b] = 1 }; // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'const int *'}}
+ int a5[3] = { []{return 0;}() };
+ int a6[1] = {[this] = 1 }; // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'C *'}}
+ }
+};
diff --git a/clang/test/Parser/cxx0x-literal-operators.cpp b/clang/test/Parser/cxx0x-literal-operators.cpp
new file mode 100644
index 0000000..1881fcb
--- /dev/null
+++ b/clang/test/Parser/cxx0x-literal-operators.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+void operator "" (const char *); // expected-error {{expected identifier}}
+void operator "k" foo(const char *); // \
+ expected-error {{string literal after 'operator' must be '""'}} \
+ expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+void operator "" tester (const char *); // \
+ expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
diff --git a/clang/test/Parser/cxx0x-member-initializers.cpp b/clang/test/Parser/cxx0x-member-initializers.cpp
new file mode 100644
index 0000000..a324f97
--- /dev/null
+++ b/clang/test/Parser/cxx0x-member-initializers.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// Make sure we don't run off the end of the stream when parsing a deferred
+// initializer.
+int a; // expected-note {{previous}}
+struct S {
+ int n = 4 + ; // expected-error {{expected expression}}
+} a; // expected-error {{redefinition}}
+
+// Make sure we use all of the tokens.
+struct T {
+ int a = 1 // expected-error {{expected ';' at end of declaration list}}
+ int b = 2;
+ int c = b; // expected-error {{undeclared identifier}}
+};
+
+// Test recovery for bad constructor initializers
+
+struct R1 {
+ int a;
+ R1() : a {}
+}; // expected-error {{expected '{' or ','}}
+
+// Test correct parsing.
+
+struct V1 {
+ int a, b;
+ V1() : a(), b{} {}
+};
diff --git a/clang/test/Parser/cxx0x-override-control-keywords.cpp b/clang/test/Parser/cxx0x-override-control-keywords.cpp
new file mode 100644
index 0000000..444862a
--- /dev/null
+++ b/clang/test/Parser/cxx0x-override-control-keywords.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct Base {
+ virtual void override();
+};
+
+struct S : Base {
+ virtual void final() final;
+ virtual void override() override;
+};
+
+struct T {
+ // virt-specifier-seq is only valid in member-declarators, and a function definition is not a member-declarator.
+ // FIXME: This currently doesn't work.
+ // virtual void f() const override { }
+};
+
+struct override;
+struct Base2 {
+ virtual override override(int override);
+};
+
+struct A : Base2 {
+ virtual struct override override(int override) override;
+};
diff --git a/clang/test/Parser/cxx0x-rvalue-reference.cpp b/clang/test/Parser/cxx0x-rvalue-reference.cpp
new file mode 100644
index 0000000..e57e601
--- /dev/null
+++ b/clang/test/Parser/cxx0x-rvalue-reference.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+int && r1(int &&a);
+
+typedef int && R;
+void r2(const R a) {
+ int & &&ar = a; // expected-error{{'ar' declared as a reference to a reference}}
+}
+
diff --git a/clang/test/Parser/cxx11-stmt-attributes.cpp b/clang/test/Parser/cxx11-stmt-attributes.cpp
new file mode 100644
index 0000000..fab5621
--- /dev/null
+++ b/clang/test/Parser/cxx11-stmt-attributes.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s
+
+void foo(int i) {
+
+ [[unknown_attribute]] ;
+ [[unknown_attribute]] { }
+ [[unknown_attribute]] if (0) { }
+ [[unknown_attribute]] for (;;);
+ [[unknown_attribute]] do {
+ [[unknown_attribute]] continue;
+ } while (0);
+ [[unknown_attribute]] while (0);
+
+ [[unknown_attribute]] switch (i) {
+ [[unknown_attribute]] case 0:
+ [[unknown_attribute]] default:
+ [[unknown_attribute]] break;
+ }
+
+ [[unknown_attribute]] goto here;
+ [[unknown_attribute]] here:
+
+ [[unknown_attribute]] try {
+ } catch (...) {
+ }
+
+ [[unknown_attribute]] return;
+
+
+ alignas(8) ; // expected-warning {{attribute aligned cannot be specified on a statement}}
+ [[noreturn]] { } // expected-warning {{attribute noreturn cannot be specified on a statement}}
+ [[noreturn]] if (0) { } // expected-warning {{attribute noreturn cannot be specified on a statement}}
+ [[noreturn]] for (;;); // expected-warning {{attribute noreturn cannot be specified on a statement}}
+ [[noreturn]] do { // expected-warning {{attribute noreturn cannot be specified on a statement}}
+ [[unavailable]] continue; // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+ } while (0);
+ [[unknown_attributqqq]] while (0); // TODO: remove 'qqq' part and enjoy 'empty loop body' warning here (DiagnoseEmptyLoopBody)
+ [[unknown_attribute]] while (0); // no warning here yet, just an unknown attribute
+
+ [[unused]] switch (i) { // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+ [[uuid]] case 0: // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+ [[visibility]] default: // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+ [[carries_dependency]] break; // expected-warning {{attribute carries_dependency cannot be specified on a statement}}
+ }
+
+ [[fastcall]] goto there; // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+ [[noinline]] there: // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+
+ [[lock_returned]] try { // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+ } catch (...) {
+ }
+
+ [[weakref]] return; // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+}
diff --git a/clang/test/Parser/cxx11-type-specifier.cpp b/clang/test/Parser/cxx11-type-specifier.cpp
new file mode 100644
index 0000000..2e629f3
--- /dev/null
+++ b/clang/test/Parser/cxx11-type-specifier.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify %s -std=c++11 -fcxx-exceptions
+
+// Tests for parsing of type-specifier-seq
+
+struct S {
+ operator constexpr int(); // expected-error{{type name does not allow constexpr}}
+};
+enum E { e };
+
+void f() {
+ try {
+ (void) new constexpr int; // expected-error{{type name does not allow constexpr}}
+ } catch (constexpr int) { // expected-error{{type name does not allow constexpr}}
+ }
+
+ // These parse as type definitions, not as type references with braced
+ // initializers. Sad but true...
+ (void) new struct S {}; // expected-error{{'S' can not be defined in a type specifier}}
+ (void) new enum E { e }; // expected-error{{'E' can not be defined in a type specifier}}
+}
diff --git a/clang/test/Parser/cxx11-user-defined-literals.cpp b/clang/test/Parser/cxx11-user-defined-literals.cpp
new file mode 100644
index 0000000..49fea01
--- /dev/null
+++ b/clang/test/Parser/cxx11-user-defined-literals.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -fms-extensions -triple x86_64-apple-darwin9.0.0
+
+// A ud-suffix cannot be used on string literals in a whole bunch of contexts:
+
+#include "foo"_bar // expected-error {{expected "FILENAME" or <FILENAME>}}
+#line 1 "foo"_bar // expected-error {{user-defined suffix cannot be used here}}
+# 1 "foo"_bar 1 // expected-error {{user-defined suffix cannot be used here}}
+#ident "foo"_bar // expected-error {{user-defined suffix cannot be used here}}
+_Pragma("foo"_bar) // expected-error {{user-defined suffix cannot be used here}}
+#pragma comment(lib, "foo"_bar) // expected-error {{user-defined suffix cannot be used here}}
+_Pragma("comment(lib, \"foo\"_bar)") // expected-error {{user-defined suffix cannot be used here}}
+#pragma message "hi"_there // expected-error {{user-defined suffix cannot be used here}} expected-warning {{hi}}
+#pragma push_macro("foo"_bar) // expected-error {{user-defined suffix cannot be used here}}
+#if __has_warning("-Wan-island-to-discover"_bar) // expected-error {{user-defined suffix cannot be used here}}
+#elif __has_include("foo"_bar) // expected-error {{expected "FILENAME" or <FILENAME>}}
+#endif
+
+extern "C++"_x {} // expected-error {{user-defined suffix cannot be used here}} expected-error {{unknown linkage language}}
+
+int f() {
+ asm("mov %eax, %rdx"_foo); // expected-error {{user-defined suffix cannot be used here}}
+}
+
+static_assert(true, "foo"_bar); // expected-error {{user-defined suffix cannot be used here}}
+
+int cake() __attribute__((availability(macosx, unavailable, message = "is a lie"_x))); // expected-error {{user-defined suffix cannot be used here}}
+
+// A ud-suffix cannot be used on character literals in preprocessor constant
+// expressions:
+#if 'x'_y - u'x'_z // expected-error 2{{character literal with user-defined suffix cannot be used in preprocessor constant expression}}
+#error error
+#endif
+
+// A ud-suffix cannot be used on integer literals in preprocessor constant
+// expressions:
+#if 0_foo // expected-error {{integer literal with user-defined suffix cannot be used in preprocessor constant expression}}
+#error error
+#endif
+
+// But they can appear in expressions.
+constexpr char operator"" _id(char c) { return c; }
+constexpr wchar_t operator"" _id(wchar_t c) { return c; }
+constexpr char16_t operator"" _id(char16_t c) { return c; }
+constexpr char32_t operator"" _id(char32_t c) { return c; }
+
+using size_t = decltype(sizeof(int));
+constexpr const char operator"" _id(const char *p, size_t n) { return *p; }
+constexpr const wchar_t operator"" _id(const wchar_t *p, size_t n) { return *p; }
+constexpr const char16_t operator"" _id(const char16_t *p, size_t n) { return *p; }
+constexpr const char32_t operator"" _id(const char32_t *p, size_t n) { return *p; }
+
+constexpr unsigned long long operator"" _id(unsigned long long n) { return n; }
+constexpr long double operator"" _id(long double d) { return d; }
+
+template<int n> struct S {};
+S<"a"_id> sa;
+S<L"b"_id> sb;
+S<u8"c"_id> sc;
+S<u"d"_id> sd;
+S<U"e"_id> se;
+
+S<'w'_id> sw;
+S<L'x'_id> sx;
+S<u'y'_id> sy;
+S<U'z'_id> sz;
+
+S<100_id> sn;
+S<(int)1.3_id> sf;
+
+void h() {
+ (void)"test"_id "test" L"test";
+}
+
+// Test source location for suffix is known
+const char *p =
+ "foo\nbar" R"x(
+ erk
+ flux
+ )x" "eep\x1f"\
+_no_such_suffix // expected-error {{'operator "" _no_such_suffix'}}
+"and a bit more"
+"and another suffix"_no_such_suffix;
+
+char c =
+ '\x14'\
+_no_such_suffix; // expected-error {{'operator "" _no_such_suffix'}}
+
+int &r =
+1234567\
+_no_such_suffix; // expected-error {{'operator "" _no_such_suffix'}}
+
+int k =
+1234567.89\
+_no_such_suffix; // expected-error {{'operator "" _no_such_suffix'}}
+
+// Make sure we handle more interesting ways of writing a string literal which
+// is "" in translation phase 7.
+void operator "\
+" _foo(unsigned long long); // ok
+
+void operator R"xyzzy()xyzzy" _foo(long double); // ok
+
+void operator"" "" R"()" "" _foo(const char *); // ok
+
+// Ensure we diagnose the bad cases.
+void operator "\0" _non_empty(const char *); // expected-error {{must be '""'}}
+void operator ""_no_space(const char *); // expected-error {{C++11 requires a space}}
+void operator L"" _not_char(const char *); // expected-error {{cannot have an encoding prefix}}
+void operator "" ""
+U"" // expected-error {{cannot have an encoding prefix}}
+"" _also_not_char(const char *);
+void operator "" u8"" "\u0123" "hello"_all_of_the_things ""(const char*); // expected-error {{must be '""'}}
diff --git a/clang/test/Parser/declarators.c b/clang/test/Parser/declarators.c
new file mode 100644
index 0000000..a7a01d8
--- /dev/null
+++ b/clang/test/Parser/declarators.c
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
+
+extern int a1[];
+
+void f0();
+void f1(int [*]);
+void f2(int [const *]);
+void f3(int [volatile const*]);
+int f4(*XX)(void); /* expected-error {{cannot return}} expected-warning {{type specifier missing, defaults to 'int'}} */
+
+char ((((*X))));
+
+void (*signal(int, void (*)(int)))(int);
+
+int aaaa, ***C, * const D, B(int);
+
+int *A;
+
+struct str;
+
+void test2(int *P, int A) {
+ struct str;
+
+ // Hard case for array decl, not Array[*].
+ int Array[*(int*)P+A];
+}
+
+typedef int atype;
+void test3(x,
+ atype /* expected-error {{unexpected type name 'atype': expected identifier}} */
+ ) int x, atype; {}
+
+void test4(x, x) int x; {} /* expected-error {{redefinition of parameter 'x'}} */
+
+
+// PR3031
+int (test5), ; // expected-error {{expected identifier or '('}}
+
+
+
+// PR3963 & rdar://6759604 - test error recovery for mistyped "typenames".
+
+foo_t *d; // expected-error {{unknown type name 'foo_t'}}
+foo_t a; // expected-error {{unknown type name 'foo_t'}}
+int test6() { return a; } // a should be declared.
+
+// Use of tagged type without tag. rdar://6783347
+struct xyz { int y; };
+enum myenum { ASDFAS };
+xyz b; // expected-error {{must use 'struct' tag to refer to type 'xyz'}}
+myenum c; // expected-error {{must use 'enum' tag to refer to type 'myenum'}}
+
+float *test7() {
+ // We should recover 'b' by parsing it with a valid type of "struct xyz", which
+ // allows us to diagnose other bad things done with y, such as this.
+ return &b.y; // expected-warning {{incompatible pointer types returning 'int *' from a function with result type 'float *'}}
+}
+
+struct xyz test8() { return a; } // a should be be marked invalid, no diag.
+
+
+// Verify that implicit int still works.
+static f; // expected-warning {{type specifier missing, defaults to 'int'}}
+static g = 4; // expected-warning {{type specifier missing, defaults to 'int'}}
+static h // expected-warning {{type specifier missing, defaults to 'int'}}
+ __asm__("foo");
+
+
+struct test9 {
+ int x // expected-error {{expected ';' at end of declaration list}}
+ int y;
+ int z // expected-warning {{expected ';' at end of declaration list}}
+};
+
+// PR6208
+struct test10 { int a; } static test10x;
+struct test11 { int a; } const test11x;
+
+// PR6216
+void test12() {
+ (void)__builtin_offsetof(struct { char c; int i; }, i);
+}
+
+// rdar://7608537
+struct test13 { int a; } (test13x);
+
+// <rdar://problem/8044088>
+struct X<foo::int> { }; // expected-error{{expected identifier or '('}}
+
+
+// PR7617 - error recovery on missing ;.
+
+void test14() // expected-error {{expected ';' after top level declarator}}
+
+void test14a();
+void *test14b = (void*)test14a; // Make sure test14a didn't get skipped.
+
+// rdar://problem/8358508
+long struct X { int x; } test15(); // expected-error {{'long struct' is invalid}}
+
+void test16(i) int i j; { } // expected-error {{expected ';' at end of declaration}}
+void test17(i, j) int i, j k; { } // expected-error {{expected ';' at end of declaration}}
diff --git a/clang/test/Parser/designator.c b/clang/test/Parser/designator.c
new file mode 100644
index 0000000..6badab7
--- /dev/null
+++ b/clang/test/Parser/designator.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify -pedantic
+
+int X[] = {
+ [4]4, // expected-warning {{use of GNU 'missing =' extension in designator}}
+ [5] = 7
+};
+
+struct foo {
+ int arr[10];
+};
+
+struct foo Y[10] = {
+ [4] .arr [2] = 4,
+
+ // This is not the GNU array init designator extension.
+ [4] .arr [2] 4 // expected-error {{expected '=' or another designator}}
+};
diff --git a/clang/test/Parser/encode.m b/clang/test/Parser/encode.m
new file mode 100644
index 0000000..7b8022e
--- /dev/null
+++ b/clang/test/Parser/encode.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int main(void) {
+ const char ch = @encode(char *)[0];
+ char c = @encode(char *)[0] + 4;
+ return c;
+}
+
diff --git a/clang/test/Parser/enhanced-proto-1.m b/clang/test/Parser/enhanced-proto-1.m
new file mode 100644
index 0000000..fa6e413
--- /dev/null
+++ b/clang/test/Parser/enhanced-proto-1.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol MyProto1
+@optional
+- (void) FOO;
+@optional
+- (void) FOO1;
+@required
+- (void) REQ;
+@optional
+@end
+
+@protocol MyProto2 <MyProto1>
+- (void) FOO2;
+@optional
+- (void) FOO3;
+@end
diff --git a/clang/test/Parser/expressions.c b/clang/test/Parser/expressions.c
new file mode 100644
index 0000000..0d1b6c9
--- /dev/null
+++ b/clang/test/Parser/expressions.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void test1() {
+ if (sizeof (int){ 1}) {} // sizeof compound literal
+ if (sizeof (int)) {} // sizeof type
+
+ (void)(int)4; // cast.
+ (void)(int){4}; // compound literal.
+
+ int A = (struct{ int a;}){ 1}.a;
+}
+
+int test2(int a, int b) {
+ return a ? (void)a,b : a;
+}
+
+int test3(int a, int b, int c) {
+ return a = b = c;
+}
+
+int test4() {
+ test4();
+ return 0;
+}
+
+struct X0 { struct { struct { int c[10][9]; } b; } a; };
+
+int test_offsetof() {
+ (void)__builtin_offsetof(struct X0, a.b.c[4][5]);
+ return 0;
+}
+
+void test_sizeof(){
+ int arr[10];
+ (void)sizeof arr[0];
+ (void)sizeof(arr[0]);
+ (void)sizeof(arr)[0];
+}
+
+// PR3418
+int test_leading_extension() {
+ __extension__ (*(char*)0) = 1; // expected-warning {{indirection of non-volatile null pointer}} \
+ // expected-note {{consider using __builtin_trap}}
+ return 0;
+}
+
+// PR3972
+int test5(int);
+int test6(void) {
+ return test5( // expected-note {{to match}}
+ test5(1)
+ ; // expected-error {{expected ')'}}
+}
+
+// PR8394
+void test7() {
+ ({} // expected-note {{to match}}
+ ; // expected-error {{expected ')'}}
+}
diff --git a/clang/test/Parser/expressions.m b/clang/test/Parser/expressions.m
new file mode 100644
index 0000000..1f1005a
--- /dev/null
+++ b/clang/test/Parser/expressions.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void test1() {
+ @"s"; // expected-warning {{expression result unused}}
+}
+
diff --git a/clang/test/Parser/extension.c b/clang/test/Parser/extension.c
new file mode 100644
index 0000000..fd4cf80
--- /dev/null
+++ b/clang/test/Parser/extension.c
@@ -0,0 +1,20 @@
+/* RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify -std=c89
+ */
+
+/* Top level extension marker. */
+
+__extension__ typedef struct
+{
+ long long int quot;
+ long long int rem;
+} lldiv_t;
+
+
+/* Decl/expr __extension__ marker. */
+void bar() {
+ __extension__ int i;
+ int j;
+ __extension__ (j = 10LL);
+ __extension__ j = 10LL; /* expected-warning {{'long long' is an extension}} */
+}
+
diff --git a/clang/test/Parser/for.cpp b/clang/test/Parser/for.cpp
new file mode 100644
index 0000000..e413839
--- /dev/null
+++ b/clang/test/Parser/for.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f1() {
+ int n;
+
+ for (n = 0; n < 10; n++);
+
+ for (n = 0 n < 10; n++); // expected-error {{expected ';' in 'for'}}
+ for (n = 0; n < 10 n++); // expected-error {{expected ';' in 'for'}}
+
+ for (int n = 0 n < 10; n++); // expected-error {{expected ';' in 'for'}}
+ for (int n = 0; n < 10 n++); // expected-error {{expected ';' in 'for'}}
+
+ for (n = 0 bool b = n < 10; n++); // expected-error {{expected ';' in 'for'}}
+ for (n = 0; bool b = n < 10 n++); // expected-error {{expected ';' in 'for'}}
+
+ for (n = 0 n < 10 n++); // expected-error 2{{expected ';' in 'for'}}
+
+ for (;); // expected-error {{expected ';' in 'for'}}
+}
diff --git a/clang/test/Parser/function-decls.c b/clang/test/Parser/function-decls.c
new file mode 100644
index 0000000..db9a98b
--- /dev/null
+++ b/clang/test/Parser/function-decls.c
@@ -0,0 +1,10 @@
+/* RUN: %clang_cc1 %s -ast-print
+ */
+
+void foo() {
+ int X;
+ X = sizeof(void (*(*)())());
+ X = sizeof(int(*)(int, float, ...));
+ X = sizeof(void (*(int arga, void (*argb)(double Y)))(void* Z));
+}
+
diff --git a/clang/test/Parser/goto.c b/clang/test/Parser/goto.c
new file mode 100644
index 0000000..a3e0117
--- /dev/null
+++ b/clang/test/Parser/goto.c
@@ -0,0 +1,30 @@
+/* RUN: %clang_cc1 -fsyntax-only -verify %s
+*/
+
+void test1() {
+ goto ; /* expected-error {{expected identifier}} */
+}
+
+
+void test2() {
+ l: /* expected-note {{previous definition is here}} */
+
+ {
+ __label__ l;
+ l: goto l;
+ }
+
+ {
+ __label__ l;
+ __label__ h; /* expected-error {{use of undeclared label 'h'}} */
+ l: goto l;
+ }
+
+ /* PR3429 & rdar://8287027
+ */
+ {
+ l: /* expected-error {{redefinition of label 'l'}} */
+ ;
+ }
+
+}
diff --git a/clang/test/Parser/if-scope-c90.c b/clang/test/Parser/if-scope-c90.c
new file mode 100644
index 0000000..c368fab
--- /dev/null
+++ b/clang/test/Parser/if-scope-c90.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c90 %s
+
+int f (int z)
+{
+ if (z > (int) sizeof (enum {a, b}))
+ return a;
+ return b;
+}
diff --git a/clang/test/Parser/if-scope-c99.c b/clang/test/Parser/if-scope-c99.c
new file mode 100644
index 0000000..63f82e0
--- /dev/null
+++ b/clang/test/Parser/if-scope-c99.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 %s
+
+int f (int z)
+{
+ if (z > (int) sizeof (enum {a, b}))
+ return a;
+ return b; // expected-error{{use of undeclared identifier}}
+}
diff --git a/clang/test/Parser/implicit-casts.c b/clang/test/Parser/implicit-casts.c
new file mode 100644
index 0000000..a2b31f9
--- /dev/null
+++ b/clang/test/Parser/implicit-casts.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+_Complex double X;
+void test1(int c) {
+ X = 5;
+}
+void test2() {
+ int i;
+ double d = i;
+ double _Complex a = 5;
+
+ test1(a);
+ a = 5;
+ d = i;
+}
+int test3() {
+ int a[2];
+ a[0] = test3; // expected-warning{{incompatible pointer to integer conversion assigning to 'int' from 'int ()'}}
+ return 0;
+}
+short x; void test4(char c) { x += c; }
+int y; void test5(char c) { y += c; }
diff --git a/clang/test/Parser/knr_parameter_attributes.c b/clang/test/Parser/knr_parameter_attributes.c
new file mode 100644
index 0000000..fb975cb
--- /dev/null
+++ b/clang/test/Parser/knr_parameter_attributes.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -W -Wall -Werror -verify %s
+
+int f(int i __attribute__((__unused__)))
+{
+ return 0;
+}
+int g(i)
+ int i __attribute__((__unused__));
+{
+ return 0;
+}
diff --git a/clang/test/Parser/method-def-in-class.m b/clang/test/Parser/method-def-in-class.m
new file mode 100644
index 0000000..476ab9b
--- /dev/null
+++ b/clang/test/Parser/method-def-in-class.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://7029784
+
+@interface A
+-(id) f0 { // expected-error {{expected ';' after method prototype}}
+ assert(0);
+}
+@end
+
+@interface C
+- (id) f0 { // expected-error {{expected ';' after method prototype}}
+ assert(0);
+};
+@end
diff --git a/clang/test/Parser/method-prototype-1.m b/clang/test/Parser/method-prototype-1.m
new file mode 100644
index 0000000..a32bc2e
--- /dev/null
+++ b/clang/test/Parser/method-prototype-1.m
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 %s -fsyntax-only
+@interface MyObject
+- (void) bycopy : (int) woodo, ... ;
+- (void) break : (int) woodo, ... ;
+- (void) enum : (int) woodo, ... ;
+- (void) struct : (int) woodo, ... ;
+- (void) union : (int) woodo, ... ;
+- (void) if : (int) woodo, int i, char chh, ... ;
+- (void) else : (int) woodo, ... ;
+- (void) while : (int) woodo, ... ;
+- (void) do : (int) woodo, ... ;
+- (void) for : (int) woodo, ... ;
+- (void) switch : (int) woodo, ... ;
+- (void) case : (int) woodo, ... ;
+- (void) default : (int) woodo, ... ;
+- (void) break : (int) woodo, ... ;
+- (void) continue : (int) woodo, ... ;
+- (void) return : (int) woodo, ... ;
+- (void) goto : (int) woodo, ... ;
+- (void) sizeof : (int) woodo, ... ;
+- (void) typeof : (int) woodo, ... ;
+- (void) __alignof : (int) woodo, ... ;
+- (void) unsigned : (int) woodo, ... ;
+- (void) long : (int) woodo, ... ;
+- (void) const : (int) woodo, ... ;
+- (void) short : (int) woodo, ... ;
+- (void) volatile : (int) woodo, ... ;
+- (void) signed : (int) woodo, ... ;
+- (void) restrict : (int) woodo, ... ;
+- (void) _Complex : (int) woodo, ... ;
+- (void) in : (int) woodo, ... ;
+- (void) out : (int) woodo, ... ;
+- (void) inout : (int) woodo, ... ;
+- (void) bycopy : (int) woodo, ... ;
+- (void) byref : (int) woodo, ... ;
+- (void) oneway : (int) woodo, ... ;
+- (void) int : (int) woodo, ... ;
+- (void) char : (int) woodo, ... ;
+- (void) float : (int) woodo, ... ;
+- (void) double : (int) woodo, ... ;
+- (void) void : (int) woodo, ... ;
+- (void) _Bool : (int) woodo, ... ;
+@end
diff --git a/clang/test/Parser/missing-end-2.m b/clang/test/Parser/missing-end-2.m
new file mode 100644
index 0000000..e89f28e
--- /dev/null
+++ b/clang/test/Parser/missing-end-2.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar: //7824372
+
+@interface A // expected-note {{class started here}}
+-(void) im0;
+
+@implementation A // expected-error {{missing '@end'}}
+@end
+
+@interface B { // expected-note {{class started here}}
+}
+
+@implementation B // expected-error {{missing '@end'}}
+@end
+
+@interface C // expected-note 2 {{class started here}}
+@property int P;
+
+@implementation C // expected-error 2 {{missing '@end'}}
diff --git a/clang/test/Parser/missing-end-3.m b/clang/test/Parser/missing-end-3.m
new file mode 100644
index 0000000..4875ecd
--- /dev/null
+++ b/clang/test/Parser/missing-end-3.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://8283484
+@interface blah { // expected-note {{class started here}}
+ @private
+}
+// since I forgot the @end here it should say something
+
+@interface blah // expected-error {{missing '@end'}}
+@end // and Unknown type name 'end' here
+
diff --git a/clang/test/Parser/missing-end-4.m b/clang/test/Parser/missing-end-4.m
new file mode 100644
index 0000000..8a96e64
--- /dev/null
+++ b/clang/test/Parser/missing-end-4.m
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface X1
+@end
+@implementation X1 // expected-note {{implementation started here}}
+@interface Y1 // expected-error {{missing '@end'}}
+@end
+@end // expected-error {{'@end' must appear in an Objective-C context}}
+
+@interface X2
+@end
+@implementation X2 // expected-note {{implementation started here}}
+@protocol Y2 // expected-error {{missing '@end'}}
+@end
+@end // expected-error {{'@end' must appear in an Objective-C context}}
+
+@interface X6 // expected-note {{class started here}}
+@interface X7 // expected-error {{missing '@end'}}
+@end
+@end // expected-error {{'@end' must appear in an Objective-C context}}
+
+@protocol P1 // expected-note {{protocol started here}}
+@interface P2 // expected-error {{missing '@end'}}
+@end
+@end // expected-error {{'@end' must appear in an Objective-C context}}
+
+@interface X4 // expected-note {{class started here}}
+@implementation X4 // expected-error {{missing '@end'}}
+@end
+@end // expected-error {{'@end' must appear in an Objective-C context}}
+
+@interface I
+@end
+@implementation I
+@protocol P; // forward declarations of protocols in @implementations is allowed
+@class C; // forward declarations of classes in @implementations is allowed
+- (C<P>*) MyMeth {}
+@end
+
+@interface I2 {}
+@protocol P2; // expected-error {{illegal interface qualifier}}
+@class C2; // expected-error {{illegal interface qualifier}}
+@end
+
+@interface I3
+@end
+@implementation I3
+- Meth {}
++ Cls {}
+@protocol P3;
+@end
diff --git a/clang/test/Parser/missing-end.m b/clang/test/Parser/missing-end.m
new file mode 100644
index 0000000..d66ea64
--- /dev/null
+++ b/clang/test/Parser/missing-end.m
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface AAA // expected-note {{class started here}}
+{
+}
+@ x// expected-error{{expected an Objective-C directive after '@'}}
+// expected-error{{missing '@end'}}
diff --git a/clang/test/Parser/ms-inline-asm.c b/clang/test/Parser/ms-inline-asm.c
new file mode 100644
index 0000000..b1af23e
--- /dev/null
+++ b/clang/test/Parser/ms-inline-asm.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -verify -fms-extensions
+
+#define M __asm int 0x2c
+#define M2 int
+
+void t1(void) { M }
+void t2(void) { __asm int 0x2c }
+void t3(void) { __asm M2 0x2c }
+void* t4(void) { __asm mov eax, fs:[0x10] }
+void t5() {
+ __asm {
+ int 0x2c ; } asm comments are fun! }{
+ }
+ __asm {}
+}
+int t6() {
+ __asm int 3 ; } comments for single-line asm
+ __asm {}
+
+ __asm int 4
+ return 10;
+}
+int t7() { // expected-note {{to match this}}
+ __asm
+ __asm { // expected-error 3 {{expected}} expected-note {{to match this}}
diff --git a/clang/test/Parser/namelookup-bug-1.c b/clang/test/Parser/namelookup-bug-1.c
new file mode 100644
index 0000000..8667a71
--- /dev/null
+++ b/clang/test/Parser/namelookup-bug-1.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -verify %s
+
+typedef int Object;
+
+struct Object *pp;
+
+Object staticObject1;
diff --git a/clang/test/Parser/namelookup-bug-2.c b/clang/test/Parser/namelookup-bug-2.c
new file mode 100644
index 0000000..84850ff
--- /dev/null
+++ b/clang/test/Parser/namelookup-bug-2.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -verify %s
+
+typedef int Object;
+
+struct Object {int i1; } *P;
+
+void foo() {
+ struct Object { int i2; } *X;
+ Object:
+ {
+ Object a;
+ }
+}
+
diff --git a/clang/test/Parser/namespace-alias-attr.cpp b/clang/test/Parser/namespace-alias-attr.cpp
new file mode 100644
index 0000000..ba80922
--- /dev/null
+++ b/clang/test/Parser/namespace-alias-attr.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify %s
+
+namespace A
+{
+}
+
+namespace B __attribute__ (( static )) = A; // expected-error{{attributes can not be specified on namespace alias}}
+
diff --git a/clang/test/Parser/namespaces.cpp b/clang/test/Parser/namespaces.cpp
new file mode 100644
index 0000000..b8c7819
--- /dev/null
+++ b/clang/test/Parser/namespaces.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR6596
+namespace g { enum { o = 0 }; }
+
+void foo() {
+ namespace a { typedef g::o o; } // expected-error{{namespaces can only be defined in global or namespace scope}}
+}
diff --git a/clang/test/Parser/nested-namespaces-recovery.cpp b/clang/test/Parser/nested-namespaces-recovery.cpp
new file mode 100644
index 0000000..d45938b
--- /dev/null
+++ b/clang/test/Parser/nested-namespaces-recovery.cpp
@@ -0,0 +1,24 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: not %clang_cc1 -x c++ -fixit %t
+// RUN: %clang_cc1 -x c++ %t
+
+namespace foo1::foo2::foo3 { // expected-error {{nested namespace definition must define each namespace separately}}
+ int foo(int x) { return x; }
+}
+
+int foo(int x) {
+ return foo1::foo2::foo3::foo(x);
+}
+
+namespace bar1 {
+ namespace bar2 {
+ namespace bar3 {
+ int bar(int x) { return x; }
+ }
+ }
+}
+
+int bar(int x) {
+ return bar1::bar2::bar3::bar(x);
+}
diff --git a/clang/test/Parser/objc-alias-printing.m b/clang/test/Parser/objc-alias-printing.m
new file mode 100644
index 0000000..8b9cc6e
--- /dev/null
+++ b/clang/test/Parser/objc-alias-printing.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -ast-print %s
+
+@protocol P1 @end
+@protocol P2 @end
+
+@interface INTF @end
+
+@compatibility_alias alias INTF;
+
+
+int foo ()
+{
+ INTF *pi;
+ INTF<P2,P1> *pi2;
+ alias *p;
+ alias<P1,P2> *p2;
+ return pi2 == p2;
+}
diff --git a/clang/test/Parser/objc-category-neg-1.m b/clang/test/Parser/objc-category-neg-1.m
new file mode 100644
index 0000000..4aa8bae
--- /dev/null
+++ b/clang/test/Parser/objc-category-neg-1.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void __assert_rtn(const char *, const char *, int, const char *) __attribute__((__noreturn__));
+static __inline__ int __inline_isfinitef (float ) __attribute__ ((always_inline));
+
+@interface NSATSTypesetter (NSPantherCompatibility) // expected-error {{cannot find interface declaration for 'NSATSTypesetter'}}
+- (id)lineFragmentRectForProposedRect:(id)proposedRect remainingRect:(id)remainingRect __attribute__((deprecated));
+@end
diff --git a/clang/test/Parser/objc-forcollection-1.m b/clang/test/Parser/objc-forcollection-1.m
new file mode 100644
index 0000000..4850deb
--- /dev/null
+++ b/clang/test/Parser/objc-forcollection-1.m
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+
+@protocol P @end
+
+@interface MyList
+@end
+
+@implementation MyList
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount
+{
+ return 0;
+}
+@end
+
+@interface MyList (BasicTest)
+- (void)compilerTestAgainst;
+@end
+
+@implementation MyList (BasicTest)
+- (void)compilerTestAgainst {
+ int i;
+ for (id elem in self)
+ ++i;
+ for (MyList *elem in self)
+ ++i;
+ for (id<P> se in self)
+ ++i;
+
+ MyList<P> *p;
+ for (p in self)
+ ++i;
+
+ for (p in p)
+ ++i;
+}
+@end
+
diff --git a/clang/test/Parser/objc-forcollection-neg-2.m b/clang/test/Parser/objc-forcollection-neg-2.m
new file mode 100644
index 0000000..f95dd13
--- /dev/null
+++ b/clang/test/Parser/objc-forcollection-neg-2.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+typedef struct objc_class *Class;
+struct __objcFastEnumerationState;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+@protocol P @end
+
+@interface MyList
+@end
+
+@implementation MyList
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount
+{
+ return 0;
+}
+@end
+
+@interface MyList (BasicTest)
+- (void)compilerTestAgainst;
+@end
+
+@implementation MyList (BasicTest)
+- (void)compilerTestAgainst {
+ static i;// expected-warning {{type specifier missing, defaults to 'int'}}
+ for (id el, elem in self) // expected-error {{only one element declaration is allowed}}
+ ++i;
+ for (id el in self)
+ ++i;
+ MyList<P> ***p;
+ for (p in self) // expected-error {{selector element type 'MyList<P> ***' is not a valid object}}
+ ++i;
+
+}
+@end
+
diff --git a/clang/test/Parser/objc-forcollection-neg.m b/clang/test/Parser/objc-forcollection-neg.m
new file mode 100644
index 0000000..1a989a1
--- /dev/null
+++ b/clang/test/Parser/objc-forcollection-neg.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+struct __objcFastEnumerationState;
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+
+@interface MyList
+@end
+
+@implementation MyList
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount
+{
+ return 0;
+}
+@end
+
+@interface MyList (BasicTest)
+- (void)compilerTestAgainst;
+@end
+
+@implementation MyList (BasicTest)
+- (void)compilerTestAgainst {
+
+ int i=0;
+ for (int * elem in elem) // expected-error {{selector element type 'int *' is not a valid object}} \
+ expected-error {{collection expression type 'int *' is not a valid object}}
+ ++i;
+ for (i in elem) // expected-error {{use of undeclared identifier 'elem'}} \
+ expected-error {{selector element type 'int' is not a valid object}}
+ ++i;
+ for (id se in i) // expected-error {{collection expression type 'int' is not a valid object}}
+ ++i;
+}
+@end
+
diff --git a/clang/test/Parser/objc-foreach-syntax.m b/clang/test/Parser/objc-foreach-syntax.m
new file mode 100644
index 0000000..5d83dc6
--- /dev/null
+++ b/clang/test/Parser/objc-foreach-syntax.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+struct __objcFastEnumerationState;
+@implementation MyList // expected-warning {{cannot find interface declaration for 'MyList'}}
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount
+{
+ return 0;
+}
+@end
+
+
+int LOOP();
+
+@implementation MyList (BasicTest)
+- (void)compilerTestAgainst {
+MyList * el;
+ for (el in @"foo")
+ { LOOP(); }
+}
+@end
+
+
+static int test7(id keys) {
+ for (id key; in keys) ; // expected-error {{use of undeclared identifier 'in'}}
+}
diff --git a/clang/test/Parser/objc-init.m b/clang/test/Parser/objc-init.m
new file mode 100644
index 0000000..efa1266
--- /dev/null
+++ b/clang/test/Parser/objc-init.m
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify -pedantic -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify -x objective-c++ -Wno-objc-root-class %s
+// rdar://5707001
+
+@interface NSNumber;
+- () METH;
+- (unsigned) METH2;
+@end
+
+struct SomeStruct {
+ int x, y, z, q;
+};
+
+void test1() {
+ id objects[] = {[NSNumber METH]};
+}
+
+void test2(NSNumber x) { // expected-error {{interface type 'NSNumber' cannot be passed by value; did you forget * in 'NSNumber'}}
+ id objects[] = {[x METH]};
+}
+
+void test3(NSNumber *x) {
+ id objects[] = {[x METH]};
+}
+
+
+// rdar://5977581
+void test4() {
+ unsigned x[] = {[NSNumber METH2]+2};
+}
+
+void test5(NSNumber *x) {
+ unsigned y[] = {
+ [4][NSNumber METH2]+2, // expected-warning {{use of GNU 'missing =' extension in designator}}
+ [4][x METH2]+2 // expected-warning {{use of GNU 'missing =' extension in designator}}
+ };
+
+ struct SomeStruct z = {
+ .x = [x METH2], // ok.
+ .x [x METH2] // expected-error {{expected '=' or another designator}}
+ };
+}
+
+// rdar://7370882
+@interface SemicolonsAppDelegate
+{
+ id i;
+}
+@property (assign) id window;
+@end
+
+@implementation SemicolonsAppDelegate
+{
+ id i;
+}
+ @synthesize window=i;
+@end
+
+
+
diff --git a/clang/test/Parser/objc-interfaces.m b/clang/test/Parser/objc-interfaces.m
new file mode 100644
index 0000000..0ae17f1
--- /dev/null
+++ b/clang/test/Parser/objc-interfaces.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+// Test features and error recovery for objc interfaces.
+
+@interface INTF
+- (int*) foo2 __attribute__((deprecated)) : (int) x1 __attribute__((deprecated)); // expected-error {{expected ';' after method prototype}} expected-error {{method type specifier must start with '-' or '+'}}
+@end
+
diff --git a/clang/test/Parser/objc-messaging-1.m b/clang/test/Parser/objc-messaging-1.m
new file mode 100644
index 0000000..82450df
--- /dev/null
+++ b/clang/test/Parser/objc-messaging-1.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+int main ()
+{
+ int i,j;
+ struct S *p;
+ id a, b, c;
+ [a ii]; // expected-warning{{not found}}
+ [a if: 1 :2]; // expected-warning{{not found}}
+ [a inout: 1 :2 another:(2,3,4)]; // expected-warning{{not found}} \
+ // expected-warning 2{{expression result unused}}
+ [a inout: 1 :2 another:(2,3,4), 6,6,8]; // expected-warning{{not found}} \
+ // expected-warning 2{{expression result unused}}
+ [a inout: 1 :2 another:(2,3,4), (6,4,5),6,8]; // expected-warning{{not found}} \
+ // expected-warning 4{{expression result unused}}
+ [a inout: 1 :2 another:(i+10), (i,j-1,5),6,8]; // expected-warning{{not found}} \
+ // expected-warning 2{{expression result unused}}
+ [a long: 1 :2 another:(i+10), (i,j-1,5),6,8]; // expected-warning{{not found}} \
+ // expected-warning 2{{expression result unused}}
+ [a : "Hello\n" :2 another:(i+10), (i,j-1,5),6,8]; // expected-warning{{not found}} \
+ // expected-warning 2{{expression result unused}}
+
+ // Comma expression as receiver (rdar://6222856)
+ [a, b, c foo]; // expected-warning{{not found}} \
+ // expected-warning 2{{expression result unused}}
+
+}
diff --git a/clang/test/Parser/objc-messaging-neg-1.m b/clang/test/Parser/objc-messaging-neg-1.m
new file mode 100644
index 0000000..bb496e9
--- /dev/null
+++ b/clang/test/Parser/objc-messaging-neg-1.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface A
++(void) foo:(int) a;
+@end
+
+int main() {
+ id a;
+ [a bla:0 6:7]; // expected-error {{expected ']'}}
+ [A foo bar]; // expected-error {{expected ':'}}
+ [A foo bar bar1]; // expected-error {{expected ':'}}
+ [] {}; // expected-error {{expected expression}}
+}
diff --git a/clang/test/Parser/objc-missing-impl.m b/clang/test/Parser/objc-missing-impl.m
new file mode 100644
index 0000000..791b9f8
--- /dev/null
+++ b/clang/test/Parser/objc-missing-impl.m
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+@end // expected-error {{'@end' must appear in an Objective-C context}}
diff --git a/clang/test/Parser/objc-property-syntax.m b/clang/test/Parser/objc-property-syntax.m
new file mode 100644
index 0000000..38d12d5
--- /dev/null
+++ b/clang/test/Parser/objc-property-syntax.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface MyClass {
+ int prop;
+};
+@property unsigned char bufferedUTF8Bytes[4]; // expected-error {{property cannot have array or function type}}
+@property unsigned char bufferedUTFBytes:1; // expected-error {{property name cannot be a bitfield}}
+@property(nonatomic, retain, setter=ab_setDefaultToolbarItems) MyClass *ab_defaultToolbarItems; // expected-error {{method name referenced in property setter attribute must end with ':'}}
+
+@property int prop;
+@end
+
+@implementation MyClass
+@dynamic ab_defaultToolbarItems // expected-error{{expected ';' after @dynamic}}
+@synthesize prop // expected-error{{expected ';' after @synthesize}}
+@end
+
diff --git a/clang/test/Parser/objc-quirks.m b/clang/test/Parser/objc-quirks.m
new file mode 100644
index 0000000..0bdeb46
--- /dev/null
+++ b/clang/test/Parser/objc-quirks.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+// FIXME: This is a horrible error message here. Fix.
+int @"s" = 5; // expected-error {{prefix attribute must be}}
+
+
+// rdar://6480479
+@interface A // expected-note {{class started here}}
+}; // expected-error {{missing '@end'}} \
+// expected-error {{extraneous closing brace ('}')}} \
+// expected-warning{{extra ';' outside of a function}}
+
+
+
+
+// PR6811
+// 'super' isn't an expression, it is a magic context-sensitive keyword.
+@interface A2 {
+ id isa;
+}
+- (void)a;
+@end
+
+@interface B2 : A2 @end
+@implementation B2
+- (void)a
+{
+ [(super) a]; // expected-error {{use of undeclared identifier 'super'}}
+}
+@end
+
+@compatibility_alias A3 A2;
diff --git a/clang/test/Parser/objc-synthesized-recover.m b/clang/test/Parser/objc-synthesized-recover.m
new file mode 100644
index 0000000..c281c21
--- /dev/null
+++ b/clang/test/Parser/objc-synthesized-recover.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface I1
+{
+ int value;
+ int value2;
+}
+@property int value;
+@property int value2;
+@end
+
+@implementation I1
+@synthesize value, - value2; // expected-error{{expected a property name}}
+@synthesize value2;
+@end
diff --git a/clang/test/Parser/objc-try-catch-1.m b/clang/test/Parser/objc-try-catch-1.m
new file mode 100644
index 0000000..a3220eb
--- /dev/null
+++ b/clang/test/Parser/objc-try-catch-1.m
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -x objective-c++ %s
+void * proc();
+
+@interface NSConstantString
+@end
+
+@interface Frob
+@end
+
+@interface Frob1
+@end
+
+void * foo()
+{
+ @try {
+ return proc();
+ }
+ @catch (Frob* ex) {
+ @throw;
+ }
+ @catch (Frob1* ex) {
+ @throw proc();
+ }
+ @finally {
+ @try {
+ return proc();
+ }
+ @catch (Frob* ex) {
+ @throw 1,2; // expected-error {{@throw requires an Objective-C object type ('int' invalid)}} \
+ // expected-warning {{expression result unused}}
+ }
+ @catch (float x) { // expected-error {{@catch parameter is not a pointer to an interface type}}
+
+ }
+ @catch(...) {
+ @throw (4,3,proc()); // expected-warning {{expression result unused}} \
+ // expected-warning {{expression result unused}}
+ }
+ }
+
+ @try { // expected-error {{@try statement without a @catch and @finally clause}}
+ return proc();
+ }
+}
+
+
+void bar()
+{
+ @try {}// expected-error {{@try statement without a @catch and @finally clause}}
+ @"s"; // expected-warning {{result unused}}
+}
+
+void baz()
+{
+ @try {}// expected-error {{@try statement without a @catch and @finally clause}}
+ @try {}
+ @finally {}
+}
+
+void noTwoTokenLookAheadRequiresABitOfFancyFootworkInTheParser() {
+ @try {
+ // Do something
+ } @catch (...) {}
+ @try {
+ // Do something
+ } @catch (...) {}
+ return;
+}
+
diff --git a/clang/test/Parser/objc-type-printing.m b/clang/test/Parser/objc-type-printing.m
new file mode 100644
index 0000000..9bbdac9
--- /dev/null
+++ b/clang/test/Parser/objc-type-printing.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -ast-print %s
+
+@protocol P1 @end
+@protocol P2 @end
+@protocol P3 @end
+
+@interface INTF
+- (INTF<P1>*) METH;
+@end
+
+void foo()
+{
+ INTF *pintf;
+ INTF<P1>* p1;
+ INTF<P1, P1>* p2;
+ INTF<P1, P3>* p3;
+ INTF<P1, P3, P2>* p4;
+ INTF<P2,P2, P3, P1>* p5;
+}
diff --git a/clang/test/Parser/objcxx-at.mm b/clang/test/Parser/objcxx-at.mm
new file mode 100644
index 0000000..37aee4d
--- /dev/null
+++ b/clang/test/Parser/objcxx-at.mm
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface B {
+ int i;
+}
+@end
+
+struct Z {
+ @defs(B); // expected-error{{@defs is not supported in Objective-C++}}
+};
+
+struct Y { // expected-note{{to match this '{'}}
+ struct X { } // expected-error{{expected ';' after struct}}
+ @interface A // expected-error{{unexpected '@' in member specification}}
+} // expected-error{{expected '}'}} expected-error{{expected ';' after struct}}
diff --git a/clang/test/Parser/objcxx-lambda-expressions-neg.mm b/clang/test/Parser/objcxx-lambda-expressions-neg.mm
new file mode 100644
index 0000000..7cdb1a2
--- /dev/null
+++ b/clang/test/Parser/objcxx-lambda-expressions-neg.mm
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
+
+int main() {
+ []{}; // expected-error {{expected expression}}
+}
diff --git a/clang/test/Parser/objcxx0x-lambda-expressions.mm b/clang/test/Parser/objcxx0x-lambda-expressions.mm
new file mode 100644
index 0000000..1eab15b
--- /dev/null
+++ b/clang/test/Parser/objcxx0x-lambda-expressions.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value -std=c++11 %s
+
+class C {
+
+ void f() {
+ int foo, bar;
+
+ // fail to parse as a lambda introducer, so we get objc message parsing errors instead
+ [foo,+] {}; // expected-error {{expected expression}}
+
+ []; // expected-error {{expected body of lambda expression}}
+ [=,foo+] {}; // expected-error {{expected ',' or ']' in lambda capture list}}
+ [&this] {}; // expected-error {{address expression must be an lvalue}}
+ [] {};
+ [=] (int i) {};
+ [&] (int) mutable -> void {};
+ [foo,bar] () { return 3; };
+ [=,&foo] () {};
+ [this] () {};
+ }
+
+};
+
diff --git a/clang/test/Parser/objcxx11-attributes.mm b/clang/test/Parser/objcxx11-attributes.mm
new file mode 100644
index 0000000..0c91392
--- /dev/null
+++ b/clang/test/Parser/objcxx11-attributes.mm
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+@interface X {}
++ (X*) alloc;
+- (X*) init;
+- (int) getSize;
+- (void) setSize: (int) size;
+- (X*) getSelf;
+@end
+
+void f(X *noreturn) {
+ // An array size which is computed by a message send is OK.
+ int a[ [noreturn getSize] ];
+
+ // ... but is interpreted as an attribute where possible.
+ int b[ [noreturn] ]; // expected-warning {{'noreturn' only applies to function types}}
+
+ int c[ [noreturn getSize] + 1 ];
+
+ // An array size which is computed by a lambda is not OK.
+ int d[ [noreturn] { return 3; } () ]; // expected-error {{expected ']'}} expected-warning {{'noreturn' only applies}}
+
+ // A message send which contains a message send is OK.
+ [ [ X alloc ] init ];
+ [ [ int(), noreturn getSelf ] getSize ]; // expected-warning {{unused}}
+
+ // A message send which contains a lambda is OK.
+ [ [noreturn] { return noreturn; } () setSize: 4 ];
+ [ [bitand] { return noreturn; } () setSize: 5 ];
+ [[[[] { return [ X alloc ]; } () init] getSelf] getSize];
+
+ // An attribute is OK.
+ [[]];
+ [[int(), noreturn]]; // expected-warning {{attribute noreturn cannot be specified on a statement}}
+ [[class, test(foo 'x' bar),,,]];
+ [[bitand, noreturn]]; // expected-warning {{attribute noreturn cannot be specified on a statement}}
+
+ [[noreturn]]int(e)();
+ int e2(); // expected-warning {{interpreted as a function declaration}} expected-note{{}}
+
+ // A function taking a noreturn function.
+ int(f)([[noreturn]] int()); // expected-note {{here}}
+ f(e);
+ f(e2); // expected-error {{cannot initialize a parameter of type 'int (*)() __attribute__((noreturn))' with an lvalue of type 'int ()'}}
+
+ // Variables initialized by a message send.
+ int(g)([[noreturn getSelf] getSize]);
+ int(h)([[noreturn]{return noreturn;}() getSize]);
+
+ int i = g + h;
+}
+
+template<typename...Ts> void f(Ts ...x) {
+ [[test::foo(bar, baz)...]];
+ [[used(x)...]];
+ [[x...] { return [ X alloc ]; }() init];
+}
diff --git a/clang/test/Parser/objcxx11-user-defined-literal.mm b/clang/test/Parser/objcxx11-user-defined-literal.mm
new file mode 100644
index 0000000..a5f1397
--- /dev/null
+++ b/clang/test/Parser/objcxx11-user-defined-literal.mm
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+id x = @"foo"_bar; // expected-error{{user-defined suffix cannot be used here}}
diff --git a/clang/test/Parser/offsetof.c b/clang/test/Parser/offsetof.c
new file mode 100644
index 0000000..3a5b9f3
--- /dev/null
+++ b/clang/test/Parser/offsetof.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct a { struct { int b; } x[2]; };
+
+int a = __builtin_offsetof(struct a, x; // expected-error{{expected ')'}} expected-note{{to match this '('}}
+// FIXME: This actually shouldn't give an error
+int b = __builtin_offsetof(struct a, x->b); // expected-error{{expected ')'}} expected-note{{to match this '('}}
diff --git a/clang/test/Parser/opencl-astype.cl b/clang/test/Parser/opencl-astype.cl
new file mode 100644
index 0000000..d4c547e
--- /dev/null
+++ b/clang/test/Parser/opencl-astype.cl
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+void test_astype() {
+ float f = 1.0f;
+ unsigned int i = __builtin_astype(f, unsigned int);
+
+ typedef __attribute__(( ext_vector_type(4) )) int int4;
+ typedef __attribute__(( ext_vector_type(3) )) float float3;
+ typedef __attribute__(( ext_vector_type(4) )) float float4;
+ typedef __attribute__(( ext_vector_type(4) )) double double4;
+
+ float4 f4;
+ double4 d4 = __builtin_astype(f4, double4); // expected-error{{invalid reinterpretation: sizes of 'double4' and 'float4' must match}}
+
+ // Verify int4->float3, float3->int4 works.
+ int4 i4;
+ float3 f3 = __builtin_astype(i4, float3);
+ i4 = __builtin_astype(f3, int4);
+}
diff --git a/clang/test/Parser/opencl-image-access.cl b/clang/test/Parser/opencl-image-access.cl
new file mode 100644
index 0000000..313587c
--- /dev/null
+++ b/clang/test/Parser/opencl-image-access.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -fsyntax-only
+
+typedef void* image2d_t;
+
+__kernel void f__ro(__read_only image2d_t a) { }
+
+__kernel void f__wo(__write_only image2d_t a) { }
+
+__kernel void f__rw(__read_write image2d_t a) { }
+
+
+__kernel void fro(read_only image2d_t a) { }
+
+__kernel void fwo(write_only image2d_t a) { }
+
+__kernel void frw(read_write image2d_t a) { }
diff --git a/clang/test/Parser/opencl-kernel.cl b/clang/test/Parser/opencl-kernel.cl
new file mode 100644
index 0000000..3abb62b
--- /dev/null
+++ b/clang/test/Parser/opencl-kernel.cl
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+__kernel void test()
+{
+}
+
+kernel void test1()
+{
+}
diff --git a/clang/test/Parser/opencl-pragma.cl b/clang/test/Parser/opencl-pragma.cl
new file mode 100644
index 0000000..1946077
--- /dev/null
+++ b/clang/test/Parser/opencl-pragma.cl
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+#pragma OPENCL EXTENSION cl_no_such_extension : disable /* expected-warning {{unknown OpenCL extension 'cl_no_such_extension' - ignoring}} */
+
+#pragma OPENCL EXTENSION all : disable
+#pragma OPENCL EXTENSION all : enable /* expected-warning {{unknown OpenCL extension 'all' - ignoring}} */
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : on /* expected-warning {{expected 'enable' or 'disable' - ignoring}} */
+
+#pragma OPENCL FP_CONTRACT ON
+#pragma OPENCL FP_CONTRACT OFF
+#pragma OPENCL FP_CONTRACT DEFAULT
+#pragma OPENCL FP_CONTRACT FOO // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}}
diff --git a/clang/test/Parser/opencl-storage-class.cl b/clang/test/Parser/opencl-storage-class.cl
new file mode 100644
index 0000000..874329b
--- /dev/null
+++ b/clang/test/Parser/opencl-storage-class.cl
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+void test_storage_class_specs()
+{
+ static int a; // expected-error {{OpenCL does not support the 'static' storage class specifier}}
+ register int b; // expected-error {{OpenCL does not support the 'register' storage class specifier}}
+ extern int c; // expected-error {{OpenCL does not support the 'extern' storage class specifier}}
+ auto int d; // expected-error {{OpenCL does not support the 'auto' storage class specifier}}
+
+#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers : enable
+ static int e;
+ register int f;
+ extern int g;
+ auto int h;
+}
diff --git a/clang/test/Parser/parenthesis-balance.cpp b/clang/test/Parser/parenthesis-balance.cpp
new file mode 100644
index 0000000..5bfa639
--- /dev/null
+++ b/clang/test/Parser/parenthesis-balance.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int f(int x) {
+ if (int foo = f(bar)) {} // expected-error{{use of undeclared identifier 'bar'}}
+ while (int foo = f(bar)) {} // expected-error{{use of undeclared identifier 'bar'}}
+ for (int foo = f(bar);;) {} // expected-error{{use of undeclared identifier 'bar'}}
+
+ int bar;
+ if (int foo = f(bar)) {}
+ while (int foo = f(bar)) {}
+ for (int foo = f(bar);;) {}
+
+ return 0;
+}
+
diff --git a/clang/test/Parser/parmvardecl_conversion.c b/clang/test/Parser/parmvardecl_conversion.c
new file mode 100644
index 0000000..9fa8a68
--- /dev/null
+++ b/clang/test/Parser/parmvardecl_conversion.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f (int p[]) { p++; }
+
diff --git a/clang/test/Parser/parser_overflow.c b/clang/test/Parser/parser_overflow.c
new file mode 100644
index 0000000..d2006ea
--- /dev/null
+++ b/clang/test/Parser/parser_overflow.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -fsyntax-only 2>&1 | FileCheck %s
+
+void foo(void) {
+ {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
+}
+
+// CHECK: fatal error: parser recursion limit reached, program too complex
diff --git a/clang/test/Parser/placeholder-recovery.m b/clang/test/Parser/placeholder-recovery.m
new file mode 100644
index 0000000..1fc1549
--- /dev/null
+++ b/clang/test/Parser/placeholder-recovery.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// FIXME: We could do much better with this, if we recognized
+// placeholders somehow. However, we're content with not generating
+// bogus 'archaic' warnings with bad location info.
+@protocol <#protocol name#> <NSObject> // expected-error 2{{expected identifier}} \
+// expected-error{{cannot find protocol declaration for 'NSObject'}} \
+// expected-warning{{protocol qualifiers without 'id'}}
+
+<#methods#> // expected-error{{expected identifier}}
+
+@end // expected-error{{prefix attribute}}
diff --git a/clang/test/Parser/pointer-arithmetic.c b/clang/test/Parser/pointer-arithmetic.c
new file mode 100644
index 0000000..87eb1a2
--- /dev/null
+++ b/clang/test/Parser/pointer-arithmetic.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int *test1(int *a) { return a + 1; }
+int *test2(int *a) { return 1 + a; }
+int *test3(int *a) { return a - 1; }
+int test4(int *a, int *b) { return a - b; }
+
+int test5(int *a, int *b) { return a + b; } /* expected-error {{invalid operands}} */
+int *test6(int *a) { return 1 - a; } /* expected-error {{invalid operands}} */
diff --git a/clang/test/Parser/pointer_promotion.c b/clang/test/Parser/pointer_promotion.c
new file mode 100644
index 0000000..30589d0
--- /dev/null
+++ b/clang/test/Parser/pointer_promotion.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void test() {
+ void *vp;
+ int *ip;
+ char *cp;
+ struct foo *fp;
+ struct bar *bp;
+ short sint = 7;
+
+ if (ip < cp) {} // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
+ if (cp < fp) {} // expected-warning {{comparison of distinct pointer types ('char *' and 'struct foo *')}}
+ if (fp < bp) {} // expected-warning {{comparison of distinct pointer types ('struct foo *' and 'struct bar *')}}
+ if (ip < 7) {} // expected-warning {{comparison between pointer and integer ('int *' and 'int')}}
+ if (sint < ip) {} // expected-warning {{comparison between pointer and integer ('int' and 'int *')}}
+ if (ip == cp) {} // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
+}
diff --git a/clang/test/Parser/pragma-options.c b/clang/test/Parser/pragma-options.c
new file mode 100644
index 0000000..7844e71
--- /dev/null
+++ b/clang/test/Parser/pragma-options.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+
+/* expected-warning {{expected 'align' following '#pragma options'}} */ #pragma options
+/* expected-warning {{expected '=' following '#pragma options align'}} */ #pragma options align
+/* expected-warning {{expected identifier in '#pragma options'}} */ #pragma options align =
+/* expected-warning {{invalid alignment option in '#pragma options align'}} */ #pragma options align = foo
+/* expected-warning {{extra tokens at end of '#pragma options'}} */ #pragma options align = reset foo
+
+#pragma options align=natural
+#pragma options align=reset
+#pragma options align=mac68k
+#pragma options align=power
+
+/* expected-warning {{expected '=' following '#pragma align'}} */ #pragma align
+/* expected-warning {{expected identifier in '#pragma align'}} */ #pragma align =
+/* expected-warning {{invalid alignment option in '#pragma align'}} */ #pragma align = foo
+/* expected-warning {{extra tokens at end of '#pragma align'}} */ #pragma align = reset foo
+
+#pragma align=natural
+#pragma align=reset
+#pragma align=mac68k
+#pragma align=power
diff --git a/clang/test/Parser/pragma-pack.c b/clang/test/Parser/pragma-pack.c
new file mode 100644
index 0000000..84778cd
--- /dev/null
+++ b/clang/test/Parser/pragma-pack.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Note that this puts the expected lines before the directives to work around
+// limitations in the -verify mode.
+
+/* expected-warning {{missing '(' after '#pragma pack'}}*/ #pragma pack 10
+#pragma pack()
+#pragma pack(8)
+
+/*expected-warning {{unknown action for '#pragma pack'}}*/ #pragma pack(hello)
+#pragma pack(push)
+#pragma pack(pop)
+
+/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ #pragma pack(push,)
+/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ #pragma pack(push,)
+/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ #pragma pack(pop,)
+
+#pragma pack(push,i)
+/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ #pragma pack(push,i,
+/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ #pragma pack(push,i,)
+/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ #pragma pack(push,i,help)
+
+#pragma pack(push,8)
+/* expected-warning {{missing ')' after '#pragma pack'}}*/ #pragma pack(push,8,
+/* expected-warning {{missing ')' after '#pragma pack'}}*/ #pragma pack(push,8,)
+/* expected-warning {{missing ')' after '#pragma pack'}}*/ #pragma pack(push,i,8
+#pragma pack(push,i,8)
+
+/* expected-warning {{missing ')' after '#pragma pack'}}*/ #pragma pack(push
+
+_Pragma("pack(push)")
+/* expected-warning {{expected integer or identifier in '#pragma pack'}}*/ _Pragma("pack(push,)")
diff --git a/clang/test/Parser/pragma-visibility.c b/clang/test/Parser/pragma-visibility.c
new file mode 100644
index 0000000..cfc3d9e
--- /dev/null
+++ b/clang/test/Parser/pragma-visibility.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#pragma GCC visibility foo // expected-warning{{expected identifier in '#pragma visibility' - ignored}}
+#pragma GCC visibility pop foo // expected-warning{{extra tokens at end of '#pragma visibility' - ignored}}
+#pragma GCC visibility push // expected-warning{{missing '(' after '#pragma visibility'}}
+#pragma GCC visibility push( // expected-warning{{expected identifier in '#pragma visibility' - ignored}}
+#pragma GCC visibility push(hidden // expected-warning{{missing ')' after '#pragma visibility' - ignoring}}
+#pragma GCC visibility push(hidden)
+#pragma GCC visibility pop
diff --git a/clang/test/Parser/pragma-visibility2.c b/clang/test/Parser/pragma-visibility2.c
new file mode 100644
index 0000000..bcef09f
--- /dev/null
+++ b/clang/test/Parser/pragma-visibility2.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu -o %t %s
+// RUN: FileCheck --input-file=%t %s
+// PR10392
+
+#define push(foo) push(default)
+#pragma GCC visibility push(hidden)
+
+int v1;
+// CHECK: @v1 = common hidden global i32 0, align 4
+
+#pragma GCC visibility pop
+
+int v2;
+// CHECK: @v2 = common global i32 0, align 4
+
+_Pragma("GCC visibility push(hidden)");
+
+int v3;
+// CHECK: @v3 = common hidden global i32 0, align 4
diff --git a/clang/test/Parser/pragma-weak.c b/clang/test/Parser/pragma-weak.c
new file mode 100644
index 0000000..7e5740b
--- /dev/null
+++ b/clang/test/Parser/pragma-weak.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Note that this puts the expected lines before the directives to work around
+// limitations in the -verify mode.
+
+int x;
+/* expected-warning {{expected identifier in '#pragma weak'}}*/ #pragma weak
+#pragma weak x
+
+extern int z;
+/* expected-warning {{expected identifier in '#pragma weak'}}*/ #pragma weak z = =
+/* expected-warning {{expected identifier in '#pragma weak'}}*/ #pragma weak z =
+/* expected-warning {{weak identifier 'y' never declared}} */ #pragma weak z = y
+
+extern int a;
+/* expected-warning {{extra tokens at end of '#pragma weak'}}*/ #pragma weak a b
+/* expected-warning {{extra tokens at end of '#pragma weak'}}*/ #pragma weak a = x c
diff --git a/clang/test/Parser/prefix-attributes.m b/clang/test/Parser/prefix-attributes.m
new file mode 100644
index 0000000..399421f
--- /dev/null
+++ b/clang/test/Parser/prefix-attributes.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+__attribute__((deprecated)) @class B; // expected-error {{prefix attribute must be followed by an interface or protocol}}
+
+__attribute__((deprecated)) @interface A @end
+__attribute__((deprecated)) @protocol P0;
+__attribute__((deprecated)) @protocol P1
+@end
diff --git a/clang/test/Parser/promote_types_in_proto.c b/clang/test/Parser/promote_types_in_proto.c
new file mode 100644
index 0000000..969ba28
--- /dev/null
+++ b/clang/test/Parser/promote_types_in_proto.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s
+void functionPromotion(void f(char *const []));
+void arrayPromotion(char * const argv[]);
+
+int whatever(int argc, char *argv[])
+{
+ arrayPromotion(argv);
+ functionPromotion(arrayPromotion);
+}
diff --git a/clang/test/Parser/recovery.c b/clang/test/Parser/recovery.c
new file mode 100644
index 0000000..3916acf
--- /dev/null
+++ b/clang/test/Parser/recovery.c
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -fblocks %s
+
+// PR2241
+float test2241[2] = {
+ 1e, // expected-error {{exponent}}
+ 1ee0 // expected-error {{exponent}}
+};
+
+
+// Testcase derived from PR2692
+static void f (char * (*g) (char **, int), char **p, ...) {
+ char *s;
+ va_list v; // expected-error {{identifier}}
+ s = g (p, __builtin_va_arg(v, int)); // expected-error {{identifier}}
+}
+
+
+// PR3172
+} // expected-error {{extraneous closing brace ('}')}}
+
+
+// rdar://6094870
+void test(int a) {
+ struct { int i; } x;
+
+ if (x.hello) // expected-error {{no member named 'hello'}}
+ test(0);
+ else
+ ;
+
+ if (x.hello == 0) // expected-error {{no member named 'hello'}}
+ test(0);
+ else
+ ;
+
+ if ((x.hello == 0)) // expected-error {{no member named 'hello'}}
+ test(0);
+ else
+ ;
+
+ if (x.i == 0)) // expected-error {{expected expression}}
+ test(0);
+ else
+ ;
+}
+
+
+
+char (((( /* expected-note {{to match this '('}} */
+ *X x ] )))); /* expected-error {{expected ')'}} */
+
+; // expected-warning {{extra ';' outside of a function}}
+
+
+
+
+struct S { void *X, *Y; };
+
+struct S A = {
+&BADIDENT, 0 /* expected-error {{use of undeclared identifier}} */
+};
+
+// rdar://6248081
+void test6248081() {
+ [10] // expected-error {{expected expression}}
+}
+
+struct forward; // expected-note{{forward declaration of 'struct forward'}}
+void x(struct forward* x) {switch(x->a) {}} // expected-error {{incomplete definition of type}}
+
+// PR3410
+void foo() {
+ int X;
+ X = 4 // expected-error{{expected ';' after expression}}
+}
+
+// rdar://9045701
+void test9045701(int x) {
+#define VALUE 0
+ x = VALUE // expected-error{{expected ';' after expression}}
+}
+
+// rdar://7980651
+typedef int intptr_t; // expected-note {{'intptr_t' declared here}}
+void bar(intptr y); // expected-error {{unknown type name 'intptr'; did you mean 'intptr_t'?}}
+
+void test1(void) {
+ int x = 2: // expected-error {{expected ';' at end of declaration}}
+ int y = x;
+ int z = y;
+}
+
+void test2(int x) {
+#define VALUE2 VALUE+VALUE
+#define VALUE3 VALUE+0
+#define VALUE4(x) x+0
+ x = VALUE2 // expected-error{{expected ';' after expression}}
+ x = VALUE3 // expected-error{{expected ';' after expression}}
+ x = VALUE4(0) // expected-error{{expected ';' after expression}}
+}
diff --git a/clang/test/Parser/recovery.cpp b/clang/test/Parser/recovery.cpp
new file mode 100644
index 0000000..ffa1bab
--- /dev/null
+++ b/clang/test/Parser/recovery.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang -cc1 -verify -std=c++11 %s
+
+8gi///===--- recovery.cpp ---===// // expected-error {{unqualified-id}}
+namespace Std { // expected-note {{here}}
+ typedef int Important;
+}
+
+/ redeclare as an inline namespace // expected-error {{unqualified-id}}
+inline namespace Std { // expected-error {{cannot be reopened as inline}}
+ Important n;
+} / end namespace Std // expected-error {{unqualified-id}}
+int x;
+Std::Important y;
+
+// FIXME: Recover as if the typo correction were applied.
+extenr "C" { // expected-error {{did you mean 'extern'}} expected-error {{unqualified-id}}
+ void f();
+}
+void g() {
+ z = 1; // expected-error {{undeclared}}
+ f(); // expected-error {{undeclared}}
+}
+
+struct S {
+ int a, b, c;
+ S();
+};
+8S::S() : a{ 5 }, b{ 6 }, c{ 2 } { // expected-error {{unqualified-id}}
+ return;
+}
+int k;
+int l = k;
+
+5int m = { l }, n = m; // expected-error {{unqualified-id}}
+
+namespace N {
+ int
+} // expected-error {{unqualified-id}}
+
+// FIXME: Recover as if the typo correction were applied.
+strcut U { // expected-error {{did you mean 'struct'}}
+} *u[3]; // expected-error {{expected ';'}}
diff --git a/clang/test/Parser/recovery.m b/clang/test/Parser/recovery.m
new file mode 100644
index 0000000..e126526
--- /dev/null
+++ b/clang/test/Parser/recovery.m
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -fblocks %s
+
+@interface Test0
+@property (assign) id x // expected-error {{expected ';' at end of declaration list}}
+@end
diff --git a/clang/test/Parser/recursion-limits.cpp b/clang/test/Parser/recursion-limits.cpp
new file mode 100644
index 0000000..ea25dea
--- /dev/null
+++ b/clang/test/Parser/recursion-limits.cpp
@@ -0,0 +1,259 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+class outer {
+ class inner1 { inner1(); };
+ class inner2 { inner2(); };
+ class inner3 { inner3(); };
+ class inner4 { inner4(); };
+ class inner5 { inner5(); };
+ class inner6 { inner6(); };
+ class inner7 { inner7(); };
+ class inner8 { inner8(); };
+ class inner9 { inner9(); };
+ class inner10 { inner10(); };
+ class inner11 { inner11(); };
+ class inner12 { inner12(); };
+ class inner13 { inner13(); };
+ class inner14 { inner14(); };
+ class inner15 { inner15(); };
+ class inner16 { inner16(); };
+ class inner17 { inner17(); };
+ class inner18 { inner18(); };
+ class inner19 { inner19(); };
+ class inner20 { inner20(); };
+ class inner21 { inner21(); };
+ class inner22 { inner22(); };
+ class inner23 { inner23(); };
+ class inner24 { inner24(); };
+ class inner25 { inner25(); };
+ class inner26 { inner26(); };
+ class inner27 { inner27(); };
+ class inner28 { inner28(); };
+ class inner29 { inner29(); };
+ class inner30 { inner30(); };
+ class inner31 { inner31(); };
+ class inner32 { inner32(); };
+ class inner33 { inner33(); };
+ class inner34 { inner34(); };
+ class inner35 { inner35(); };
+ class inner36 { inner36(); };
+ class inner37 { inner37(); };
+ class inner38 { inner38(); };
+ class inner39 { inner39(); };
+ class inner40 { inner40(); };
+ class inner41 { inner41(); };
+ class inner42 { inner42(); };
+ class inner43 { inner43(); };
+ class inner44 { inner44(); };
+ class inner45 { inner45(); };
+ class inner46 { inner46(); };
+ class inner47 { inner47(); };
+ class inner48 { inner48(); };
+ class inner49 { inner49(); };
+ class inner50 { inner50(); };
+ class inner51 { inner51(); };
+ class inner52 { inner52(); };
+ class inner53 { inner53(); };
+ class inner54 { inner54(); };
+ class inner55 { inner55(); };
+ class inner56 { inner56(); };
+ class inner57 { inner57(); };
+ class inner58 { inner58(); };
+ class inner59 { inner59(); };
+ class inner60 { inner60(); };
+ class inner61 { inner61(); };
+ class inner62 { inner62(); };
+ class inner63 { inner63(); };
+ class inner64 { inner64(); };
+ class inner65 { inner65(); };
+ class inner66 { inner66(); };
+ class inner67 { inner67(); };
+ class inner68 { inner68(); };
+ class inner69 { inner69(); };
+ class inner70 { inner70(); };
+ class inner71 { inner71(); };
+ class inner72 { inner72(); };
+ class inner73 { inner73(); };
+ class inner74 { inner74(); };
+ class inner75 { inner75(); };
+ class inner76 { inner76(); };
+ class inner77 { inner77(); };
+ class inner78 { inner78(); };
+ class inner79 { inner79(); };
+ class inner80 { inner80(); };
+ class inner81 { inner81(); };
+ class inner82 { inner82(); };
+ class inner83 { inner83(); };
+ class inner84 { inner84(); };
+ class inner85 { inner85(); };
+ class inner86 { inner86(); };
+ class inner87 { inner87(); };
+ class inner88 { inner88(); };
+ class inner89 { inner89(); };
+ class inner90 { inner90(); };
+ class inner91 { inner91(); };
+ class inner92 { inner92(); };
+ class inner93 { inner93(); };
+ class inner94 { inner94(); };
+ class inner95 { inner95(); };
+ class inner96 { inner96(); };
+ class inner97 { inner97(); };
+ class inner98 { inner98(); };
+ class inner99 { inner99(); };
+ class inner100 { inner100(); };
+ class inner101 { inner101(); };
+ class inner102 { inner102(); };
+ class inner103 { inner103(); };
+ class inner104 { inner104(); };
+ class inner105 { inner105(); };
+ class inner106 { inner106(); };
+ class inner107 { inner107(); };
+ class inner108 { inner108(); };
+ class inner109 { inner109(); };
+ class inner110 { inner110(); };
+ class inner111 { inner111(); };
+ class inner112 { inner112(); };
+ class inner113 { inner113(); };
+ class inner114 { inner114(); };
+ class inner115 { inner115(); };
+ class inner116 { inner116(); };
+ class inner117 { inner117(); };
+ class inner118 { inner118(); };
+ class inner119 { inner119(); };
+ class inner120 { inner120(); };
+ class inner121 { inner121(); };
+ class inner122 { inner122(); };
+ class inner123 { inner123(); };
+ class inner124 { inner124(); };
+ class inner125 { inner125(); };
+ class inner126 { inner126(); };
+ class inner127 { inner127(); };
+ class inner128 { inner128(); };
+ class inner129 { inner129(); };
+ class inner130 { inner130(); };
+ class inner131 { inner131(); };
+ class inner132 { inner132(); };
+ class inner133 { inner133(); };
+ class inner134 { inner134(); };
+ class inner135 { inner135(); };
+ class inner136 { inner136(); };
+ class inner137 { inner137(); };
+ class inner138 { inner138(); };
+ class inner139 { inner139(); };
+ class inner140 { inner140(); };
+ class inner141 { inner141(); };
+ class inner142 { inner142(); };
+ class inner143 { inner143(); };
+ class inner144 { inner144(); };
+ class inner145 { inner145(); };
+ class inner146 { inner146(); };
+ class inner147 { inner147(); };
+ class inner148 { inner148(); };
+ class inner149 { inner149(); };
+ class inner150 { inner150(); };
+ class inner151 { inner151(); };
+ class inner152 { inner152(); };
+ class inner153 { inner153(); };
+ class inner154 { inner154(); };
+ class inner155 { inner155(); };
+ class inner156 { inner156(); };
+ class inner157 { inner157(); };
+ class inner158 { inner158(); };
+ class inner159 { inner159(); };
+ class inner160 { inner160(); };
+ class inner161 { inner161(); };
+ class inner162 { inner162(); };
+ class inner163 { inner163(); };
+ class inner164 { inner164(); };
+ class inner165 { inner165(); };
+ class inner166 { inner166(); };
+ class inner167 { inner167(); };
+ class inner168 { inner168(); };
+ class inner169 { inner169(); };
+ class inner170 { inner170(); };
+ class inner171 { inner171(); };
+ class inner172 { inner172(); };
+ class inner173 { inner173(); };
+ class inner174 { inner174(); };
+ class inner175 { inner175(); };
+ class inner176 { inner176(); };
+ class inner177 { inner177(); };
+ class inner178 { inner178(); };
+ class inner179 { inner179(); };
+ class inner180 { inner180(); };
+ class inner181 { inner181(); };
+ class inner182 { inner182(); };
+ class inner183 { inner183(); };
+ class inner184 { inner184(); };
+ class inner185 { inner185(); };
+ class inner186 { inner186(); };
+ class inner187 { inner187(); };
+ class inner188 { inner188(); };
+ class inner189 { inner189(); };
+ class inner190 { inner190(); };
+ class inner191 { inner191(); };
+ class inner192 { inner192(); };
+ class inner193 { inner193(); };
+ class inner194 { inner194(); };
+ class inner195 { inner195(); };
+ class inner196 { inner196(); };
+ class inner197 { inner197(); };
+ class inner198 { inner198(); };
+ class inner199 { inner199(); };
+ class inner200 { inner200(); };
+ class inner201 { inner201(); };
+ class inner202 { inner202(); };
+ class inner203 { inner203(); };
+ class inner204 { inner204(); };
+ class inner205 { inner205(); };
+ class inner206 { inner206(); };
+ class inner207 { inner207(); };
+ class inner208 { inner208(); };
+ class inner209 { inner209(); };
+ class inner210 { inner210(); };
+ class inner211 { inner211(); };
+ class inner212 { inner212(); };
+ class inner213 { inner213(); };
+ class inner214 { inner214(); };
+ class inner215 { inner215(); };
+ class inner216 { inner216(); };
+ class inner217 { inner217(); };
+ class inner218 { inner218(); };
+ class inner219 { inner219(); };
+ class inner220 { inner220(); };
+ class inner221 { inner221(); };
+ class inner222 { inner222(); };
+ class inner223 { inner223(); };
+ class inner224 { inner224(); };
+ class inner225 { inner225(); };
+ class inner226 { inner226(); };
+ class inner227 { inner227(); };
+ class inner228 { inner228(); };
+ class inner229 { inner229(); };
+ class inner230 { inner230(); };
+ class inner231 { inner231(); };
+ class inner232 { inner232(); };
+ class inner233 { inner233(); };
+ class inner234 { inner234(); };
+ class inner235 { inner235(); };
+ class inner236 { inner236(); };
+ class inner237 { inner237(); };
+ class inner238 { inner238(); };
+ class inner239 { inner239(); };
+ class inner240 { inner240(); };
+ class inner241 { inner241(); };
+ class inner242 { inner242(); };
+ class inner243 { inner243(); };
+ class inner244 { inner244(); };
+ class inner245 { inner245(); };
+ class inner246 { inner246(); };
+ class inner247 { inner247(); };
+ class inner248 { inner248(); };
+ class inner249 { inner249(); };
+ class inner250 { inner250(); };
+ class inner251 { inner251(); };
+ class inner252 { inner252(); };
+ class inner253 { inner253(); };
+ class inner254 { inner254(); };
+ class inner255 { inner255(); };
+ class inner256 { inner256(); };
+};
diff --git a/clang/test/Parser/selector-1.m b/clang/test/Parser/selector-1.m
new file mode 100644
index 0000000..5ba2da9
--- /dev/null
+++ b/clang/test/Parser/selector-1.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
+
+// rdar://8366474
+int main() {
+ SEL s = @selector(retain);
+ SEL s1 = @selector(meth1:);
+ SEL s2 = @selector(retainArgument::);
+ SEL s3 = @selector(retainArgument:::::);
+ SEL s4 = @selector(retainArgument:with:);
+ SEL s5 = @selector(meth1:with:with:);
+ SEL s6 = @selector(getEnum:enum:bool:);
+ SEL s7 = @selector(char:float:double:unsigned:short:long:);
+ SEL s9 = @selector(:enum:bool:);
+
+ (void) @selector(foo:);
+ (void) @selector(foo::);
+ (void) @selector(foo:::);
+ (void) @selector(foo::::);
+}
diff --git a/clang/test/Parser/skip-function-bodies.mm b/clang/test/Parser/skip-function-bodies.mm
new file mode 100644
index 0000000..8462f69
--- /dev/null
+++ b/clang/test/Parser/skip-function-bodies.mm
@@ -0,0 +1,45 @@
+// RUN: env CINDEXTEST_SKIP_FUNCTION_BODIES=1 c-index-test -test-load-source all %s | FileCheck %s
+
+class A {
+ class B {};
+
+public:
+ A() {
+ struct C {
+ void d() {}
+ };
+ }
+
+ typedef B E;
+};
+
+@interface F
+- (void) G;
+@end
+@implementation F
+- (void) G {
+ typedef A H;
+ class I {};
+}
+@end
+
+void J() {
+ class K {};
+}
+
+// CHECK: skip-function-bodies.mm:3:7: ClassDecl=A:3:7 (Definition) Extent=[3:1 - 14:2]
+// CHECK: skip-function-bodies.mm:4:9: ClassDecl=B:4:9 (Definition) Extent=[4:3 - 4:13]
+// CHECK: skip-function-bodies.mm:6:1: CXXAccessSpecifier=:6:1 (Definition) Extent=[6:1 - 6:8]
+// CHECK: skip-function-bodies.mm:7:3: CXXConstructor=A:7:3 Extent=[7:3 - 7:6]
+// CHECK-NOT: skip-function-bodies.mm:8:12: StructDecl=C:8:12 (Definition) Extent=[8:5 - 10:6]
+// CHECK-NOT: skip-function-bodies.mm:9:12: CXXMethod=d:9:12 (Definition) Extent=[9:7 - 9:18]
+// CHECK: skip-function-bodies.mm:13:13: TypedefDecl=E:13:13 (Definition) Extent=[13:3 - 13:14]
+// CHECK: skip-function-bodies.mm:13:11: TypeRef=class A::B:4:9 Extent=[13:11 - 13:12]
+// CHECK: skip-function-bodies.mm:16:12: ObjCInterfaceDecl=F:16:12 Extent=[16:1 - 18:5]
+// CHECK: skip-function-bodies.mm:17:10: ObjCInstanceMethodDecl=G:17:10 Extent=[17:1 - 17:12]
+// CHECK: skip-function-bodies.mm:19:17: ObjCImplementationDecl=F:19:17 (Definition) Extent=[19:1 - 24:2]
+// CHECK: skip-function-bodies.mm:20:10: ObjCInstanceMethodDecl=G:20:10 Extent=[20:1 - 20:13]
+// CHECK-NOT: skip-function-bodies.mm:21:13: TypedefDecl=H:21:13 (Definition) Extent=[21:3 - 21:14]
+// CHECK-NOT: skip-function-bodies.mm:21:11: TypeRef=class A:3:7 Extent=[21:11 - 21:12]
+// CHECK: skip-function-bodies.mm:26:6: FunctionDecl=J:26:6 Extent=[26:1 - 26:9]
+// CHECK-NOT: skip-function-bodies.mm:27:9: ClassDecl=K:27:9 (Definition) Extent=[27:3 - 27:13]
diff --git a/clang/test/Parser/statements.c b/clang/test/Parser/statements.c
new file mode 100644
index 0000000..3a123d6
--- /dev/null
+++ b/clang/test/Parser/statements.c
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unreachable-code
+
+void test1() {
+ { ; { ;;}} ;;
+}
+
+void test2() {
+ if (0) { if (1) {} } else { }
+
+ do { } while (0);
+
+ while (0) while(0) do ; while(0);
+
+ for ((void)0;0;(void)0)
+ for (;;)
+ for ((void)9;0;(void)2)
+ ;
+ for (int X = 0; 0; (void)0);
+}
+
+void test3() {
+ switch (0) {
+
+ case 4:
+ if (0) {
+ case 6: ;
+ }
+ default:
+ ;
+ }
+}
+
+void test4() {
+ if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
+
+ int X; // declaration in a block.
+
+foo: if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
+}
+
+typedef int t;
+void test5() {
+ if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
+
+ t x = 0;
+
+ if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
+}
+
+
+void test6(void) {
+ do
+ . // expected-error {{expected expression}}
+ while (0);
+}
+
+int test7() {
+ return 4 // expected-error {{expected ';' after return statement}}
+}
+
+void test8() {
+ // Should not skip '}' and produce a "expected '}'" error.
+ undecl // expected-error {{use of undeclared identifier 'undecl'}}
+}
diff --git a/clang/test/Parser/struct-recursion.c b/clang/test/Parser/struct-recursion.c
new file mode 100644
index 0000000..834c5d0
--- /dev/null
+++ b/clang/test/Parser/struct-recursion.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -fsyntax-only
+
+// C99 6.7.2.3p11
+
+// mutually recursive structs
+struct s1 { struct s2 *A; };
+struct s2 { struct s1 *B; };
+
+// both types are complete now.
+struct s1 a;
+struct s2 b;
diff --git a/clang/test/Parser/switch-recovery.cpp b/clang/test/Parser/switch-recovery.cpp
new file mode 100644
index 0000000..84ac0c8
--- /dev/null
+++ b/clang/test/Parser/switch-recovery.cpp
@@ -0,0 +1,172 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/7971948>
+struct A {};
+struct B {
+ void foo(int b) {
+ switch (a) { // expected-error{{use of undeclared identifier 'a'}}
+ default:
+ return;
+ }
+
+ switch (b) {
+ case 17 // expected-error{{expected ':' after 'case'}}
+ break;
+
+ default // expected-error{{expected ':' after 'default'}}
+ return;
+ }
+ }
+
+ void test2() {
+ enum X { Xa, Xb } x;
+
+ switch (x) { // expected-warning {{enumeration value 'Xb' not handled in switch}}
+ case Xa; // expected-error {{expected ':' after 'case'}}
+ break;
+ }
+
+ switch (x) {
+ default; // expected-error {{expected ':' after 'default'}}
+ break;
+ }
+ }
+
+ int test3(int i) {
+ switch (i) {
+ case 1: return 0;
+ 2: return 1; // expected-error {{expected 'case' keyword before expression}}
+ default: return 5;
+ }
+ }
+};
+
+int test4(int i) {
+ switch (i)
+ 1: return -1; // expected-error {{expected 'case' keyword before expression}}
+ return 0;
+}
+
+int test5(int i) {
+ switch (i) {
+ case 1: case 2: case 3: return 1;
+ {
+ 4:5:6:7: return 2; // expected-error 4{{expected 'case' keyword before expression}}
+ }
+ default: return -1;
+ }
+}
+
+int test6(int i) {
+ switch (i) {
+ case 1:
+ case 4:
+ // This class provides extra single colon tokens. Make sure no
+ // errors are seen here.
+ class foo{
+ public:
+ protected:
+ private:
+ };
+ case 2:
+ 5: // expected-error {{expected 'case' keyword before expression}}
+ default: return 1;
+ }
+}
+
+int test7(int i) {
+ switch (i) {
+ case false ? 1 : 2:
+ true ? 1 : 2: // expected-error {{expected 'case' keyword before expression}}
+ case 10:
+ 14 ? 3 : 4; // expected-warning {{expression result unused}}
+ default:
+ return 1;
+ }
+}
+
+enum foo { A, B, C};
+int test8( foo x ) {
+ switch (x) {
+ A: return 0; // FIXME: give a warning for unused labels that could also be
+ // a case expression.
+ default: return 1;
+ }
+}
+
+// Stress test to make sure Clang doesn't crash.
+void test9(int x) {
+ switch(x) {
+ case 1: return;
+ 2: case; // expected-error {{expected 'case' keyword before expression}} \
+ expected-error {{expected expression}}
+ 4:5:6: return; // expected-error 3{{expected 'case' keyword before expression}}
+ 7: :x; // expected-error {{expected 'case' keyword before expression}} \
+ expected-error {{expected expression}}
+ 8:: x; // expected-error {{expected ';' after expression}} \
+ expected-error {{no member named 'x' in the global namespace}} \
+ expected-warning {{expression result unused}}
+ 9:: :y; // expected-error {{expected ';' after expression}} \
+ expected-error {{expected unqualified-id}} \
+ expected-warning {{expression result unused}}
+ :; // expected-error {{expected expression}}
+ ::; // expected-error {{expected unqualified-id}}
+ }
+}
+
+void test10(int x) {
+ switch (x) {
+ case 1: {
+ struct Inner {
+ void g(int y) {
+ 2: y++; // expected-error {{expected ';' after expression}} \
+ // expected-warning {{expression result unused}}
+ }
+ };
+ break;
+ }
+ }
+}
+
+template<typename T>
+struct test11 {
+ enum { E };
+
+ void f(int x) {
+ switch (x) {
+ E: break; // FIXME: give a 'case' fix-it for unused labels that
+ // could also be an expression an a case label.
+ E+1: break; // expected-error {{expected 'case' keyword before expression}}
+ }
+ }
+};
+
+void test12(int x) {
+ switch (x) {
+ 0: // expected-error {{expected 'case' keyword before expression}}
+ while (x) {
+ 1: // expected-error {{expected 'case' keyword before expression}}
+ for (;x;) {
+ 2: // expected-error {{expected 'case' keyword before expression}}
+ if (x > 0) {
+ 3: // expected-error {{expected 'case' keyword before expression}}
+ --x;
+ }
+ }
+ }
+ }
+}
+
+void missing_statement_case(int x) {
+ switch (x) {
+ case 1:
+ case 0: // expected-error {{label at end of compound statement: expected statement}}
+ }
+}
+
+void missing_statement_default(int x) {
+ switch (x) {
+ case 0:
+ default: // expected-error {{label at end of compound statement: expected statement}}
+ }
+}
diff --git a/clang/test/Parser/top-level-semi-cxx0x.cpp b/clang/test/Parser/top-level-semi-cxx0x.cpp
new file mode 100644
index 0000000..be342a2
--- /dev/null
+++ b/clang/test/Parser/top-level-semi-cxx0x.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify %s
+
+void foo();
+
+void bar() { };
+
+void wibble();
+
+;
+
+namespace Blah {
+ void f() { };
+
+ void g();
+}
diff --git a/clang/test/Parser/traditional_arg_scope.c b/clang/test/Parser/traditional_arg_scope.c
new file mode 100644
index 0000000..3811d0d
--- /dev/null
+++ b/clang/test/Parser/traditional_arg_scope.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+int x(a) int a; {return a;}
+int y(b) int b; {return a;} // expected-error {{use of undeclared identifier}}
+
+// PR2332
+int a(a)int a;{a=10;return a;}
diff --git a/clang/test/Parser/typeof.c b/clang/test/Parser/typeof.c
new file mode 100644
index 0000000..7953a69
--- /dev/null
+++ b/clang/test/Parser/typeof.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int TInt;
+
+static void test() {
+ int *pi;
+
+ int typeof (int) aIntInt; // expected-error{{cannot combine with previous 'int' declaration specifier}}
+ short typeof (int) aShortInt; // expected-error{{'short typeof' is invalid}}
+ int int ttt; // expected-error{{cannot combine with previous 'int' declaration specifier}}
+ typeof(TInt) anInt;
+ short TInt eee; // expected-error{{expected ';' at end of declaration}}
+ void ary[7] fff; // expected-error{{array has incomplete element type 'void'}} expected-error{{expected ';' at end of declaration}}
+ typeof(void ary[7]) anIntError; // expected-error{{expected ')'}} expected-note {{to match this '('}} expected-error {{variable has incomplete type 'typeof(void)' (aka 'void')}}
+ typeof(const int) aci;
+ const typeof (*pi) aConstInt;
+ int xx;
+ int *i;
+}
+
+// <rdar://problem/8237491>
+void test2() {
+ int a;
+ short b;
+ __typeof__(a) (*f)(__typeof__(b));
+}
diff --git a/clang/test/Parser/types.c b/clang/test/Parser/types.c
new file mode 100644
index 0000000..53b9dd5
--- /dev/null
+++ b/clang/test/Parser/types.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+// Test the X can be overloaded inside the struct.
+typedef int X;
+struct Y { short X; };
+
+// Variable shadows type, PR3872
+
+typedef struct foo { int x; } foo;
+void test() {
+ foo *foo;
+ foo->x = 0;
+}
+
diff --git a/clang/test/Parser/warn-dangling-else.cpp b/clang/test/Parser/warn-dangling-else.cpp
new file mode 100644
index 0000000..e91af98
--- /dev/null
+++ b/clang/test/Parser/warn-dangling-else.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wdangling-else %s
+
+void f(int a, int b, int c, int d, int e) {
+
+ // should warn
+ { if (a) if (b) d++; else e++; } // expected-warning {{add explicit braces to avoid dangling else}}
+ { if (a) while (b) if (c) d++; else e++; } // expected-warning {{add explicit braces to avoid dangling else}}
+ { if (a) switch (b) if (c) d++; else e++; } // expected-warning {{add explicit braces to avoid dangling else}}
+ { if (a) for (;;) if (c) d++; else e++; } // expected-warning {{add explicit braces to avoid dangling else}}
+ { if (a) if (b) if (d) d++; else e++; else d--; } // expected-warning {{add explicit braces to avoid dangling else}}
+
+ if (a)
+ if (b) {
+ d++;
+ } else e++; // expected-warning {{add explicit braces to avoid dangling else}}
+
+ // shouldn't
+ { if (a) if (b) d++; }
+ { if (a) if (b) if (c) d++; }
+ { if (a) if (b) d++; else e++; else d--; }
+ { if (a) if (b) if (d) d++; else e++; else d--; else e--; }
+ { if (a) do if (b) d++; else e++; while (c); }
+
+ if (a) {
+ if (b) d++;
+ else e++;
+ }
+
+ if (a) {
+ if (b) d++;
+ } else e++;
+}
+
+// Somewhat more elaborate case that shouldn't warn.
+class A {
+ public:
+ void operator<<(const char* s) {}
+};
+
+void HandleDisabledThing() {}
+A GetThing() { return A(); }
+
+#define FOO(X) \
+ switch (0) default: \
+ if (!(X)) \
+ HandleDisabledThing(); \
+ else \
+ GetThing()
+
+void f(bool cond) {
+ int x = 0;
+ if (cond)
+ FOO(x) << "hello"; // no warning
+}
+
diff --git a/clang/test/Preprocessor/Inputs/TestFramework.framework/.system_framework b/clang/test/Preprocessor/Inputs/TestFramework.framework/.system_framework
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/clang/test/Preprocessor/Inputs/TestFramework.framework/.system_framework
diff --git a/clang/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/AnotherTestFramework.framework/Headers/AnotherTestFramework.h b/clang/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/AnotherTestFramework.framework/Headers/AnotherTestFramework.h
new file mode 100644
index 0000000..489f17a
--- /dev/null
+++ b/clang/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/AnotherTestFramework.framework/Headers/AnotherTestFramework.h
@@ -0,0 +1,3 @@
+static inline int another_test_framework_func(unsigned a) {
+ return a;
+}
diff --git a/clang/test/Preprocessor/Inputs/TestFramework.framework/Headers/TestFramework.h b/clang/test/Preprocessor/Inputs/TestFramework.framework/Headers/TestFramework.h
new file mode 100644
index 0000000..06f9ab5
--- /dev/null
+++ b/clang/test/Preprocessor/Inputs/TestFramework.framework/Headers/TestFramework.h
@@ -0,0 +1,6 @@
+// Include a subframework header.
+#include <AnotherTestFramework/AnotherTestFramework.h>
+
+static inline int test_framework_func(unsigned a) {
+ return a;
+}
diff --git a/clang/test/Preprocessor/_Pragma-dependency.c b/clang/test/Preprocessor/_Pragma-dependency.c
new file mode 100644
index 0000000..a2861c9
--- /dev/null
+++ b/clang/test/Preprocessor/_Pragma-dependency.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -E 2>&1 | grep 'DO_PRAGMA (STR'
+// RUN: %clang_cc1 %s -E 2>&1 | grep '7:3'
+
+#define DO_PRAGMA _Pragma
+#define STR "GCC dependency \"parse.y\"")
+ // Test that this line is printed by caret diagnostics.
+ DO_PRAGMA (STR
diff --git a/clang/test/Preprocessor/_Pragma-dependency2.c b/clang/test/Preprocessor/_Pragma-dependency2.c
new file mode 100644
index 0000000..c178764
--- /dev/null
+++ b/clang/test/Preprocessor/_Pragma-dependency2.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -E %s -verify
+
+#define DO_PRAGMA _Pragma
+DO_PRAGMA ("GCC dependency \"blahblabh\"") // expected-error {{file not found}}
+
diff --git a/clang/test/Preprocessor/_Pragma-in-macro-arg.c b/clang/test/Preprocessor/_Pragma-in-macro-arg.c
new file mode 100644
index 0000000..2877bcb
--- /dev/null
+++ b/clang/test/Preprocessor/_Pragma-in-macro-arg.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 %s -verify -Wconversion
+
+// Don't crash (rdar://11168596)
+#define A(desc) _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wparentheses\"") _Pragma("clang diagnostic pop")
+#define B(desc) A(desc)
+B(_Pragma("clang diagnostic ignored \"-Wparentheses\""))
+
+
+#define EMPTY(x)
+#define INACTIVE(x) EMPTY(x)
+
+#define ID(x) x
+#define ACTIVE(x) ID(x)
+
+// This should be ignored..
+INACTIVE(_Pragma("clang diagnostic ignored \"-Wconversion\""))
+
+#define IGNORE_CONV _Pragma("clang diagnostic ignored \"-Wconversion\"") _Pragma("clang diagnostic ignored \"-Wconversion\"")
+
+// ..as should this.
+INACTIVE(IGNORE_CONV)
+
+#define IGNORE_POPPUSH(Pop, Push, W, D) Push W D Pop
+IGNORE_POPPUSH(_Pragma("clang diagnostic pop"), _Pragma("clang diagnostic push"),
+ _Pragma("clang diagnostic ignored \"-Wconversion\""), int q = (double)1.0);
+
+int x1 = (double)1.0; // expected-warning {{implicit conversion}}
+
+ACTIVE(_Pragma) ("clang diagnostic ignored \"-Wconversion\"")) // expected-error {{_Pragma takes a parenthesized string literal}} \
+ expected-error {{expected identifier or '('}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+
+// This should disable the warning.
+ACTIVE(IGNORE_CONV)
+
+int x2 = (double)1.0;
diff --git a/clang/test/Preprocessor/_Pragma-location.c b/clang/test/Preprocessor/_Pragma-location.c
new file mode 100644
index 0000000..8b68d6c
--- /dev/null
+++ b/clang/test/Preprocessor/_Pragma-location.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -E | not grep 'scratch space'
+
+#define push _Pragma ("pack(push)")
+push
diff --git a/clang/test/Preprocessor/_Pragma-physloc.c b/clang/test/Preprocessor/_Pragma-physloc.c
new file mode 100644
index 0000000..a093af2
--- /dev/null
+++ b/clang/test/Preprocessor/_Pragma-physloc.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -E | grep '#pragma x y z'
+// RUN: %clang_cc1 %s -E | grep '#pragma a b c'
+
+_Pragma("x y z")
+_Pragma("a b c")
+
diff --git a/clang/test/Preprocessor/_Pragma.c b/clang/test/Preprocessor/_Pragma.c
new file mode 100644
index 0000000..0a83b14
--- /dev/null
+++ b/clang/test/Preprocessor/_Pragma.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -Wall
+
+_Pragma ("GCC system_header") // expected-warning {{system_header ignored in main file}}
+
+// rdar://6880630
+_Pragma("#define macro") // expected-warning {{unknown pragma ignored}}
+
+#ifdef macro
+#error #define invalid
+#endif
diff --git a/clang/test/Preprocessor/assembler-with-cpp.c b/clang/test/Preprocessor/assembler-with-cpp.c
new file mode 100644
index 0000000..a9c4294
--- /dev/null
+++ b/clang/test/Preprocessor/assembler-with-cpp.c
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 -x assembler-with-cpp -E %s -o - | FileCheck -strict-whitespace -check-prefix=CHECK-Identifiers-False %s
+
+#ifndef __ASSEMBLER__
+#error "__ASSEMBLER__ not defined"
+#endif
+
+
+// Invalid token pasting is ok.
+#define A X ## .
+1: A
+// CHECK-Identifiers-False: 1: X .
+
+// Line markers are not linemarkers in .S files, they are passed through.
+# 321
+// CHECK-Identifiers-False: # 321
+
+// Unknown directives are passed through.
+# B C
+// CHECK-Identifiers-False: # B C
+
+// Unknown directives are expanded.
+#define D(x) BAR ## x
+# D(42)
+// CHECK-Identifiers-False: # BAR42
+
+// Unmatched quotes are permitted.
+2: '
+3: "
+// CHECK-Identifiers-False: 2: '
+// CHECK-Identifiers-False: 3: "
+
+// (balance quotes to keep editors happy): "'
+
+// Empty char literals are ok.
+4: ''
+// CHECK-Identifiers-False: 4: ''
+
+
+// Portions of invalid pasting should still expand as macros.
+// rdar://6709206
+#define M4 expanded
+#define M5() M4 ## (
+
+5: M5()
+// CHECK-Identifiers-False: 5: expanded (
+
+// rdar://6804322
+#define FOO(name) name ## $foo
+6: FOO(blarg)
+// CHECK-Identifiers-False: 6: blarg $foo
+
+// RUN: %clang_cc1 -x assembler-with-cpp -fdollars-in-identifiers -E %s -o - | FileCheck -check-prefix=CHECK-Identifiers-True -strict-whitespace %s
+#define FOO(name) name ## $foo
+7: FOO(blarg)
+// CHECK-Identifiers-True: 7: blarg$foo
+
+//
+#define T6() T6 #nostring
+#define T7(x) T7 #x
+8: T6()
+9: T7(foo)
+// CHECK-Identifiers-True: 8: T6 #nostring
+// CHECK-Identifiers-True: 9: T7 "foo"
+
+// Concatenation with period doesn't leave a space
+#define T8(A,B) A ## B
+10: T8(.,T8)
+// CHECK-Identifiers-True: 10: .T8
+
+// This should not crash.
+#define T11(a) #0
+11: T11(b)
+// CHECK-Identifiers-True: 11: #0
+
+
+// This should not crash
+// rdar://8823139
+# ##
+// CHECK-Identifiers-False: # ##
diff --git a/clang/test/Preprocessor/builtin_line.c b/clang/test/Preprocessor/builtin_line.c
new file mode 100644
index 0000000..52228b5
--- /dev/null
+++ b/clang/test/Preprocessor/builtin_line.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -E | grep "^ 4"
+#define FOO __LINE__
+
+ FOO
+
+// PR3579 - This should expand to the __LINE__ of the ')' not of the X.
+// RUN: %clang_cc1 %s -E | grep "^A 13"
+
+#define X() __LINE__
+
+A X(
+
+)
diff --git a/clang/test/Preprocessor/c90.c b/clang/test/Preprocessor/c90.c
new file mode 100644
index 0000000..1d5010d
--- /dev/null
+++ b/clang/test/Preprocessor/c90.c
@@ -0,0 +1,10 @@
+/* RUN: %clang_cc1 %s -std=c89 -Eonly -verify -pedantic-errors
+ */
+
+/* PR3919 */
+
+#define foo`bar /* expected-error {{whitespace required after macro name}} */
+#define foo2!bar /* expected-warning {{whitespace recommended after macro name}} */
+
+#define foo3$bar /* expected-error {{'$' in identifier}} */
+
diff --git a/clang/test/Preprocessor/c99-6_10_3_3_p4.c b/clang/test/Preprocessor/c99-6_10_3_3_p4.c
new file mode 100644
index 0000000..320e6cf
--- /dev/null
+++ b/clang/test/Preprocessor/c99-6_10_3_3_p4.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -E %s | FileCheck -strict-whitespace %s
+
+#define hash_hash # ## #
+#define mkstr(a) # a
+#define in_between(a) mkstr(a)
+#define join(c, d) in_between(c hash_hash d)
+char p[] = join(x, y);
+
+// CHECK: char p[] = "x ## y";
+
diff --git a/clang/test/Preprocessor/c99-6_10_3_4_p5.c b/clang/test/Preprocessor/c99-6_10_3_4_p5.c
new file mode 100644
index 0000000..6dea09d
--- /dev/null
+++ b/clang/test/Preprocessor/c99-6_10_3_4_p5.c
@@ -0,0 +1,28 @@
+// Example from C99 6.10.3.4p5
+// RUN: %clang_cc1 -E %s | FileCheck -strict-whitespace %s
+
+#define x 3
+#define f(a) f(x * (a))
+#undef x
+#define x 2
+#define g f
+#define z z[0]
+#define h g(~
+#define m(a) a(w)
+#define w 0,1
+#define t(a) a
+#define p() int
+#define q(x) x
+#define r(x,y) x ## y
+#define str(x) # x
+ f(y+1) + f(f(z)) % t(t(g)(0) + t)(1);
+ g(x+(3,4)-w) | h 5) & m
+(f)^m(m);
+p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) };
+char c[2][6] = { str(hello), str() };
+
+// CHECK: f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1);
+// CHECK: f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1);
+// CHECK: int i[] = { 1, 23, 4, 5, };
+// CHECK: char c[2][6] = { "hello", "" };
+
diff --git a/clang/test/Preprocessor/c99-6_10_3_4_p6.c b/clang/test/Preprocessor/c99-6_10_3_4_p6.c
new file mode 100644
index 0000000..98bacb2
--- /dev/null
+++ b/clang/test/Preprocessor/c99-6_10_3_4_p6.c
@@ -0,0 +1,27 @@
+// Example from C99 6.10.3.4p6
+
+// RUN: %clang_cc1 -E %s | FileCheck -strict-whitespace %s
+
+#define str(s) # s
+#define xstr(s) str(s)
+#define debug(s, t) printf("x" # s "= %d, x" # t "= s" \
+ x ## s, x ## t)
+#define INCFILE(n) vers ## n
+#define glue(a, b) a ## b
+#define xglue(a, b) glue(a, b)
+#define HIGHLOW "hello"
+#define LOW LOW ", world"
+debug(1, 2);
+fputs(str(strncmp("abc\0d" "abc", '\4') // this goes away
+ == 0) str(: @\n), s);
+include xstr(INCFILE(2).h)
+glue(HIGH, LOW);
+xglue(HIGH, LOW)
+
+
+// CHECK: printf("x" "1" "= %d, x" "2" "= s" x1, x2);
+// CHECK: fputs("strncmp(\"abc\\0d\" \"abc\", '\\4') == 0" ": @\n", s);
+// CHECK: include "vers2.h"
+// CHECK: "hello";
+// CHECK: "hello" ", world"
+
diff --git a/clang/test/Preprocessor/c99-6_10_3_4_p7.c b/clang/test/Preprocessor/c99-6_10_3_4_p7.c
new file mode 100644
index 0000000..b63209b
--- /dev/null
+++ b/clang/test/Preprocessor/c99-6_10_3_4_p7.c
@@ -0,0 +1,10 @@
+// Example from C99 6.10.3.4p7
+
+// RUN: %clang_cc1 -E %s | FileCheck -strict-whitespace %s
+
+#define t(x,y,z) x ## y ## z
+int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),
+t(10,,), t(,11,), t(,,12), t(,,) };
+
+// CHECK: int j[] = { 123, 45, 67, 89,
+// CHECK: 10, 11, 12, };
diff --git a/clang/test/Preprocessor/c99-6_10_3_4_p9.c b/clang/test/Preprocessor/c99-6_10_3_4_p9.c
new file mode 100644
index 0000000..04c4b79
--- /dev/null
+++ b/clang/test/Preprocessor/c99-6_10_3_4_p9.c
@@ -0,0 +1,20 @@
+// Example from C99 6.10.3.4p9
+
+// RUN: %clang_cc1 -E %s | FileCheck -strict-whitespace %s
+
+#define debug(...) fprintf(stderr, __VA_ARGS__)
+#define showlist(...) puts(#__VA_ARGS__)
+#define report(test, ...) ((test)?puts(#test):\
+ printf(__VA_ARGS__))
+debug("Flag");
+// CHECK: fprintf(stderr, "Flag");
+
+debug("X = %d\n", x);
+// CHECK: fprintf(stderr, "X = %d\n", x);
+
+showlist(The first, second, and third items.);
+// CHECK: puts("The first, second, and third items.");
+
+report(x>y, "x is %d but y is %d", x, y);
+// CHECK: ((x>y)?puts("x>y"): printf("x is %d but y is %d", x, y));
+
diff --git a/clang/test/Preprocessor/clang_headers.c b/clang/test/Preprocessor/clang_headers.c
new file mode 100644
index 0000000..41bd754
--- /dev/null
+++ b/clang/test/Preprocessor/clang_headers.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -ffreestanding -E %s
+
+#include <limits.h>
diff --git a/clang/test/Preprocessor/comment_save.c b/clang/test/Preprocessor/comment_save.c
new file mode 100644
index 0000000..b860042
--- /dev/null
+++ b/clang/test/Preprocessor/comment_save.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -E -C %s | FileCheck -strict-whitespace %s
+
+// foo
+// CHECK: // foo
+
+/* bar */
+// CHECK: /* bar */
+
diff --git a/clang/test/Preprocessor/comment_save_if.c b/clang/test/Preprocessor/comment_save_if.c
new file mode 100644
index 0000000..4946122
--- /dev/null
+++ b/clang/test/Preprocessor/comment_save_if.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -E -CC -pedantic -verify
+
+#if 1 /*bar */
+
+#endif /*foo*/
+
+#if /*foo*/ defined /*foo*/ FOO /*foo*/
+#if /*foo*/ defined /*foo*/ ( /*foo*/ FOO /*foo*/ ) /*foo*/
+#endif
+#endif
+
diff --git a/clang/test/Preprocessor/comment_save_macro.c b/clang/test/Preprocessor/comment_save_macro.c
new file mode 100644
index 0000000..6ad759f
--- /dev/null
+++ b/clang/test/Preprocessor/comment_save_macro.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -E -C %s | FileCheck -check-prefix=CHECK-C -strict-whitespace %s
+// CHECK-C: boo bork bar // zot
+
+// RUN: %clang_cc1 -E -CC %s | FileCheck -check-prefix=CHECK-CC -strict-whitespace %s
+// CHECK-CC: boo bork /* blah*/ bar // zot
+
+// RUN: %clang_cc1 -E %s | FileCheck -check-prefix=CHECK -strict-whitespace %s
+// CHECK: boo bork bar
+
+
+#define FOO bork // blah
+boo FOO bar // zot
+
diff --git a/clang/test/Preprocessor/cxx_and.cpp b/clang/test/Preprocessor/cxx_and.cpp
new file mode 100644
index 0000000..a84ffe7
--- /dev/null
+++ b/clang/test/Preprocessor/cxx_and.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -DA -DB -E %s | grep 'int a = 37 == 37'
+// RUN: %clang_cc1 -DA -E %s | grep 'int a = 927 == 927'
+// RUN: %clang_cc1 -DB -E %s | grep 'int a = 927 == 927'
+// RUN: %clang_cc1 -E %s | grep 'int a = 927 == 927'
+#if defined(A) and defined(B)
+#define X 37
+#else
+#define X 927
+#endif
+
+#if defined(A) && defined(B)
+#define Y 37
+#else
+#define Y 927
+#endif
+
+int a = X == Y;
diff --git a/clang/test/Preprocessor/cxx_bitand.cpp b/clang/test/Preprocessor/cxx_bitand.cpp
new file mode 100644
index 0000000..01b4ff1
--- /dev/null
+++ b/clang/test/Preprocessor/cxx_bitand.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -DA=1 -DB=2 -E %s | grep 'int a = 927 == 927'
+// RUN: %clang_cc1 -DA=1 -DB=1 -E %s | grep 'int a = 37 == 37'
+// RUN: %clang_cc1 -E %s | grep 'int a = 927 == 927'
+#if A bitand B
+#define X 37
+#else
+#define X 927
+#endif
+
+#if A & B
+#define Y 37
+#else
+#define Y 927
+#endif
+
+int a = X == Y;
diff --git a/clang/test/Preprocessor/cxx_bitor.cpp b/clang/test/Preprocessor/cxx_bitor.cpp
new file mode 100644
index 0000000..c92596e
--- /dev/null
+++ b/clang/test/Preprocessor/cxx_bitor.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -DA=1 -DB=1 -E %s | grep 'int a = 37 == 37'
+// RUN: %clang_cc1 -DA=0 -DB=1 -E %s | grep 'int a = 37 == 37'
+// RUN: %clang_cc1 -DA=1 -DB=0 -E %s | grep 'int a = 37 == 37'
+// RUN: %clang_cc1 -DA=0 -DB=0 -E %s | grep 'int a = 927 == 927'
+// RUN: %clang_cc1 -E %s | grep 'int a = 927 == 927'
+#if A bitor B
+#define X 37
+#else
+#define X 927
+#endif
+
+#if A | B
+#define Y 37
+#else
+#define Y 927
+#endif
+
+int a = X == Y;
diff --git a/clang/test/Preprocessor/cxx_compl.cpp b/clang/test/Preprocessor/cxx_compl.cpp
new file mode 100644
index 0000000..824092c
--- /dev/null
+++ b/clang/test/Preprocessor/cxx_compl.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -DA=1 -E %s | grep 'int a = 37 == 37'
+// RUN: %clang_cc1 -DA=0 -E %s | grep 'int a = 927 == 927'
+// RUN: %clang_cc1 -E %s | grep 'int a = 927 == 927'
+#if compl 0 bitand A
+#define X 37
+#else
+#define X 927
+#endif
+
+#if ~0 & A
+#define Y 37
+#else
+#define Y 927
+#endif
+
+int a = X == Y;
diff --git a/clang/test/Preprocessor/cxx_not.cpp b/clang/test/Preprocessor/cxx_not.cpp
new file mode 100644
index 0000000..67e8775
--- /dev/null
+++ b/clang/test/Preprocessor/cxx_not.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -DA=1 -E %s | grep 'int a = 927 == 927'
+// RUN: %clang_cc1 -E %s | grep 'int a = 37 == 37'
+#if not defined(A)
+#define X 37
+#else
+#define X 927
+#endif
+
+#if ! defined(A)
+#define Y 37
+#else
+#define Y 927
+#endif
+
+int a = X == Y;
diff --git a/clang/test/Preprocessor/cxx_not_eq.cpp b/clang/test/Preprocessor/cxx_not_eq.cpp
new file mode 100644
index 0000000..f7670fa
--- /dev/null
+++ b/clang/test/Preprocessor/cxx_not_eq.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -DA=1 -DB=1 -E %s | grep 'int a = 927 == 927'
+// RUN: %clang_cc1 -E %s | grep 'int a = 927 == 927'
+// RUN: %clang_cc1 -DA=1 -DB=2 -E %s | grep 'int a = 37 == 37'
+#if A not_eq B
+#define X 37
+#else
+#define X 927
+#endif
+
+#if A != B
+#define Y 37
+#else
+#define Y 927
+#endif
+
+int a = X == Y;
diff --git a/clang/test/Preprocessor/cxx_oper_keyword.cpp b/clang/test/Preprocessor/cxx_oper_keyword.cpp
new file mode 100644
index 0000000..3fc246d
--- /dev/null
+++ b/clang/test/Preprocessor/cxx_oper_keyword.cpp
@@ -0,0 +1,7 @@
+// RUN: not %clang_cc1 %s -E
+// RUN: %clang_cc1 %s -E -fno-operator-names
+
+// Not valid in C++ unless -fno-operator-names is passed.
+#define and foo
+
+
diff --git a/clang/test/Preprocessor/cxx_oper_keyword_ms_compat.cpp b/clang/test/Preprocessor/cxx_oper_keyword_ms_compat.cpp
new file mode 100644
index 0000000..1c6ef90
--- /dev/null
+++ b/clang/test/Preprocessor/cxx_oper_keyword_ms_compat.cpp
@@ -0,0 +1,179 @@
+// RUN: %clang_cc1 %s -E -fms-compatibility
+
+bool f() {
+ // Check that operators still work before redefining them.
+#if compl 0 bitand 1
+ return true and false;
+#endif
+}
+
+// All c++ keywords should be #define-able in ms mode.
+// (operators like "and" aren't normally, the rest always is.)
+#define and
+#define and_eq
+#define alignas
+#define alignof
+#define asm
+#define auto
+#define bitand
+#define bitor
+#define bool
+#define break
+#define case
+#define catch
+#define char
+#define char16_t
+#define char32_t
+#define class
+#define compl
+#define const
+#define constexpr
+#define const_cast
+#define continue
+#define decltype
+#define default
+#define delete
+#define double
+#define dynamic_cast
+#define else
+#define enum
+#define explicit
+#define export
+#define extern
+#define false
+#define float
+#define for
+#define friend
+#define goto
+#define if
+#define inline
+#define int
+#define long
+#define mutable
+#define namespace
+#define new
+#define noexcept
+#define not
+#define not_eq
+#define nullptr
+#define operator
+#define or
+#define or_eq
+#define private
+#define protected
+#define public
+#define register
+#define reinterpret_cast
+#define return
+#define short
+#define signed
+#define sizeof
+#define static
+#define static_assert
+#define static_cast
+#define struct
+#define switch
+#define template
+#define this
+#define thread_local
+#define throw
+#define true
+#define try
+#define typedef
+#define typeid
+#define typename
+#define union
+#define unsigned
+#define using
+#define virtual
+#define void
+#define volatile
+#define wchar_t
+#define while
+#define xor
+#define xor_eq
+
+// Check this is all properly defined away.
+and
+and_eq
+alignas
+alignof
+asm
+auto
+bitand
+bitor
+bool
+break
+case
+catch
+char
+char16_t
+char32_t
+class
+compl
+const
+constexpr
+const_cast
+continue
+decltype
+default
+delete
+double
+dynamic_cast
+else
+enum
+explicit
+export
+extern
+false
+float
+for
+friend
+goto
+if
+inline
+int
+long
+mutable
+namespace
+new
+noexcept
+not
+not_eq
+nullptr
+operator
+or
+or_eq
+private
+protected
+public
+register
+reinterpret_cast
+return
+short
+signed
+sizeof
+static
+static_assert
+static_cast
+struct
+switch
+template
+this
+thread_local
+throw
+true
+try
+typedef
+typeid
+typename
+union
+unsigned
+using
+virtual
+void
+volatile
+wchar_t
+while
+xor
+xor_eq
diff --git a/clang/test/Preprocessor/cxx_oper_spelling.cpp b/clang/test/Preprocessor/cxx_oper_spelling.cpp
new file mode 100644
index 0000000..0ae9afd
--- /dev/null
+++ b/clang/test/Preprocessor/cxx_oper_spelling.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E %s | grep 'a: "and"'
+
+#define X(A) #A
+
+// C++'03 2.5p2: "In all respects of the language, each alternative
+// token behaves the same, respectively, as its primary token,
+// except for its spelling"
+//
+// This should be spelled as 'and', not '&&'
+a: X(and)
+
diff --git a/clang/test/Preprocessor/cxx_or.cpp b/clang/test/Preprocessor/cxx_or.cpp
new file mode 100644
index 0000000..e8ed92f
--- /dev/null
+++ b/clang/test/Preprocessor/cxx_or.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -DA -DB -E %s | grep 'int a = 37 == 37'
+// RUN: %clang_cc1 -DA -E %s | grep 'int a = 37 == 37'
+// RUN: %clang_cc1 -DB -E %s | grep 'int a = 37 == 37'
+// RUN: %clang_cc1 -E %s | grep 'int a = 927 == 927'
+#if defined(A) or defined(B)
+#define X 37
+#else
+#define X 927
+#endif
+
+#if defined(A) || defined(B)
+#define Y 37
+#else
+#define Y 927
+#endif
+
+int a = X == Y;
diff --git a/clang/test/Preprocessor/cxx_true.cpp b/clang/test/Preprocessor/cxx_true.cpp
new file mode 100644
index 0000000..b123e0c
--- /dev/null
+++ b/clang/test/Preprocessor/cxx_true.cpp
@@ -0,0 +1,13 @@
+/* RUN: %clang_cc1 -E %s -x c++ | grep block_1
+ RUN: %clang_cc1 -E %s -x c++ | not grep block_2
+ RUN: %clang_cc1 -E %s -x c | not grep block
+*/
+
+#if true
+block_1
+#endif
+
+#if false
+block_2
+#endif
+
diff --git a/clang/test/Preprocessor/cxx_xor.cpp b/clang/test/Preprocessor/cxx_xor.cpp
new file mode 100644
index 0000000..24a6ce4
--- /dev/null
+++ b/clang/test/Preprocessor/cxx_xor.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -DA=1 -DB=1 -E %s | grep 'int a = 927 == 927'
+// RUN: %clang_cc1 -DA=0 -DB=1 -E %s | grep 'int a = 37 == 37'
+// RUN: %clang_cc1 -DA=1 -DB=0 -E %s | grep 'int a = 37 == 37'
+// RUN: %clang_cc1 -DA=0 -DB=0 -E %s | grep 'int a = 927 == 927'
+// RUN: %clang_cc1 -E %s | grep 'int a = 927 == 927'
+#if A xor B
+#define X 37
+#else
+#define X 927
+#endif
+
+#if A ^ B
+#define Y 37
+#else
+#define Y 927
+#endif
+
+int a = X == Y;
diff --git a/clang/test/Preprocessor/dependencies-and-pp.c b/clang/test/Preprocessor/dependencies-and-pp.c
new file mode 100644
index 0000000..7877df3
--- /dev/null
+++ b/clang/test/Preprocessor/dependencies-and-pp.c
@@ -0,0 +1,31 @@
+// Test -MT and -E flags, PR4063
+
+// RUN: %clang -E -o %t.1 %s
+// RUN: %clang -E -MD -MF %t.d -MT foo -o %t.2 %s
+// RUN: diff %t.1 %t.2
+// RUN: grep "foo:" %t.d
+// RUN: grep "dependencies-and-pp.c" %t.d
+
+// Test -MQ flag without quoting
+
+// RUN: %clang -E -MD -MF %t.d -MQ foo -o %t %s
+// RUN: grep "foo:" %t.d
+
+// Test -MQ flag with quoting
+
+// RUN: %clang -E -MD -MF %t.d -MQ '$fo\ooo ooo\ ooo\\ ooo#oo' -o %t %s
+// RUN: fgrep '$$fo\ooo\ ooo\\\ ooo\\\\\ ooo\#oo:' %t.d
+
+// Test consecutive -MT flags
+
+// RUN: %clang -E -MD -MF %t.d -MT foo -MT bar -MT baz -o %t %s
+// RUN: diff %t.1 %t
+// RUN: fgrep "foo bar baz:" %t.d
+
+// Test consecutive -MT and -MQ flags
+
+// RUN: %clang -E -MD -MF %t.d -MT foo -MQ '$(bar)' -MT 'b az' -MQ 'qu ux' -MQ ' space' -o %t %s
+// RUN: fgrep 'foo $$(bar) b az qu\ ux \ space:' %t.d
+
+// TODO: Test default target without quoting
+// TODO: Test default target with quoting
diff --git a/clang/test/Preprocessor/directive-invalid.c b/clang/test/Preprocessor/directive-invalid.c
new file mode 100644
index 0000000..86cd253
--- /dev/null
+++ b/clang/test/Preprocessor/directive-invalid.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -E -verify %s
+// rdar://7683173
+
+#define r_paren )
+#if defined( x r_paren // expected-error {{missing ')' after 'defined'}} \
+ // expected-note {{to match this '('}}
+#endif
diff --git a/clang/test/Preprocessor/disabled-cond-diags.c b/clang/test/Preprocessor/disabled-cond-diags.c
new file mode 100644
index 0000000..531842a
--- /dev/null
+++ b/clang/test/Preprocessor/disabled-cond-diags.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -E %s 2>&1 | not grep "warning\|error"
+
+#if 0
+
+// Shouldn't get warnings here.
+??( ??)
+
+// Should not get an error here.
+` ` ` `
+#endif
diff --git a/clang/test/Preprocessor/dump-macros-spacing.c b/clang/test/Preprocessor/dump-macros-spacing.c
new file mode 100644
index 0000000..1392442
--- /dev/null
+++ b/clang/test/Preprocessor/dump-macros-spacing.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -E -dD < %s | grep stdin | grep -v define
+#define A A
+/* 1
+ * 2
+ * 3
+ * 4
+ * 5
+ * 6
+ * 7
+ * 8
+ */
+#define B B
+
diff --git a/clang/test/Preprocessor/dump-macros-undef.c b/clang/test/Preprocessor/dump-macros-undef.c
new file mode 100644
index 0000000..358fd17
--- /dev/null
+++ b/clang/test/Preprocessor/dump-macros-undef.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -E -dD %s | FileCheck %s
+// PR7818
+
+// CHECK: # 1 "{{.+}}.c"
+#define X 3
+// CHECK: #define X 3
+#undef X
+// CHECK: #undef X
diff --git a/clang/test/Preprocessor/dump-options.c b/clang/test/Preprocessor/dump-options.c
new file mode 100644
index 0000000..a329bd4
--- /dev/null
+++ b/clang/test/Preprocessor/dump-options.c
@@ -0,0 +1,3 @@
+// RUN: %clang %s -E -dD | grep __INTMAX_MAX__
+// RUN: %clang %s -E -dM | grep __INTMAX_MAX__
+
diff --git a/clang/test/Preprocessor/dump_macros.c b/clang/test/Preprocessor/dump_macros.c
new file mode 100644
index 0000000..d420eb4
--- /dev/null
+++ b/clang/test/Preprocessor/dump_macros.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -E -dM %s -o - | FileCheck %s -strict-whitespace
+
+// Space at end even without expansion tokens
+// CHECK: #define A(x)
+#define A(x)
+
+// Space before expansion list.
+// CHECK: #define B(x,y) x y
+#define B(x,y)x y
+
+// No space in argument list.
+// CHECK: #define C(x,y) x y
+#define C(x, y) x y
+
+// No paste avoidance.
+// CHECK: #define D() ..
+#define D() ..
+
+// Simple test.
+// CHECK: #define E .
+// CHECK: #define F X()Y
+#define E .
+#define F X()Y
+
+// gcc prints macros at end of translation unit, so last one wins.
+// CHECK: #define G 2
+#define G 1
+#undef G
+#define G 2
+
+// Variadic macros of various sorts. PR5699
+
+// CHECK: H(x,...) __VA_ARGS__
+#define H(x, ...) __VA_ARGS__
+// CHECK: I(...) __VA_ARGS__
+#define I(...) __VA_ARGS__
+// CHECK: J(x...) __VA_ARGS__
+#define J(x ...) __VA_ARGS__
diff --git a/clang/test/Preprocessor/dumptokens_phyloc.c b/clang/test/Preprocessor/dumptokens_phyloc.c
new file mode 100644
index 0000000..7321c0e
--- /dev/null
+++ b/clang/test/Preprocessor/dumptokens_phyloc.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -dump-tokens %s 2>&1 | grep "Spelling=.*dumptokens_phyloc.c:3:20"
+
+#define TESTPHYLOC 10
+
+TESTPHYLOC
diff --git a/clang/test/Preprocessor/expr_comma.c b/clang/test/Preprocessor/expr_comma.c
new file mode 100644
index 0000000..538727d
--- /dev/null
+++ b/clang/test/Preprocessor/expr_comma.c
@@ -0,0 +1,10 @@
+// Comma is not allowed in C89
+// RUN: not %clang_cc1 -E %s -std=c89 -pedantic-errors
+
+// Comma is allowed if unevaluated in C99
+// RUN: %clang_cc1 -E %s -std=c99 -pedantic-errors
+
+// PR2279
+
+#if 0? 1,2:3
+#endif
diff --git a/clang/test/Preprocessor/expr_define_expansion.c b/clang/test/Preprocessor/expr_define_expansion.c
new file mode 100644
index 0000000..38c0384
--- /dev/null
+++ b/clang/test/Preprocessor/expr_define_expansion.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -E -CC -pedantic -verify
+
+#define FOO && 1
+#if defined FOO FOO
+#endif
diff --git a/clang/test/Preprocessor/expr_invalid_tok.c b/clang/test/Preprocessor/expr_invalid_tok.c
new file mode 100644
index 0000000..5defcc5
--- /dev/null
+++ b/clang/test/Preprocessor/expr_invalid_tok.c
@@ -0,0 +1,15 @@
+// RUN: not %clang_cc1 -E %s 2>&1 | grep 'invalid token at start of a preprocessor expression'
+// RUN: not %clang_cc1 -E %s 2>&1 | grep 'token is not a valid binary operator in a preprocessor subexpression'
+// RUN: not %clang_cc1 -E %s 2>&1 | grep ':14: error: expected end of line in preprocessor expression'
+// PR2220
+
+#if 1 * * 2
+#endif
+
+#if 4 [ 2
+#endif
+
+
+// PR2284 - The constant-expr production does not including comma.
+#if 1 ? 2 : 0, 1
+#endif
diff --git a/clang/test/Preprocessor/expr_liveness.c b/clang/test/Preprocessor/expr_liveness.c
new file mode 100644
index 0000000..c3b6421
--- /dev/null
+++ b/clang/test/Preprocessor/expr_liveness.c
@@ -0,0 +1,52 @@
+/* RUN: %clang_cc1 -E %s -DNO_ERRORS -Werror -Wundef
+ RUN: not %clang_cc1 -E %s
+ */
+
+#ifdef NO_ERRORS
+/* None of these divisions by zero are in live parts of the expression, do not
+ emit any diagnostics. */
+
+#define MACRO_0 0
+#define MACRO_1 1
+
+#if MACRO_0 && 10 / MACRO_0
+foo
+#endif
+
+#if MACRO_1 || 10 / MACRO_0
+bar
+#endif
+
+#if 0 ? 124/0 : 42
+#endif
+
+// PR2279
+#if 0 ? 1/0: 2
+#else
+#error
+#endif
+
+// PR2279
+#if 1 ? 2 ? 3 : 4 : 5
+#endif
+
+// PR2284
+#if 1 ? 0: 1 ? 1/0: 1/0
+#endif
+
+#else
+
+
+/* The 1/0 is live, it should error out. */
+#if 0 && 1 ? 4 : 1 / 0
+baz
+#endif
+
+
+#endif
+
+// rdar://6505352
+// -Wundef should not warn about use of undefined identifier if not live.
+#if (!defined(XXX) || XXX > 42)
+#endif
+
diff --git a/clang/test/Preprocessor/expr_multichar.c b/clang/test/Preprocessor/expr_multichar.c
new file mode 100644
index 0000000..8ab12d9
--- /dev/null
+++ b/clang/test/Preprocessor/expr_multichar.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 < %s -E -verify -triple i686-pc-linux-gnu
+
+#if (('1234' >> 24) != '1')
+#error Bad multichar constant calculation!
+#endif
diff --git a/clang/test/Preprocessor/expr_usual_conversions.c b/clang/test/Preprocessor/expr_usual_conversions.c
new file mode 100644
index 0000000..5ca2cb8
--- /dev/null
+++ b/clang/test/Preprocessor/expr_usual_conversions.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -E -verify
+
+#define INTMAX_MIN (-9223372036854775807LL -1)
+
+#if (-42 + 0U) /* expected-warning {{left side of operator converted from negative value to unsigned: -42 to 18446744073709551574}} */ \
+ / -2 /* expected-warning {{right side of operator converted from negative value to unsigned: -2 to 18446744073709551614}} */
+foo
+#endif
+
+// Shifts don't want the usual conversions: PR2279
+#if (2 << 1U) - 30 >= 0
+#error
+#endif
+
diff --git a/clang/test/Preprocessor/extension-warning.c b/clang/test/Preprocessor/extension-warning.c
new file mode 100644
index 0000000..4ba57f7
--- /dev/null
+++ b/clang/test/Preprocessor/extension-warning.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+// The preprocessor shouldn't warn about extensions within macro bodies that
+// aren't expanded.
+#define TY typeof
+#define TY1 typeof(1)
+
+// But we should warn here
+TY1 x; // expected-warning {{extension}}
+TY(1) x; // FIXME: And we should warn here
+
+// Note: this warning intentionally doesn't trigger on keywords like
+// __attribute; the standard allows implementation-defined extensions
+// prefixed with "__".
+// Current list of keywords this can trigger on:
+// inline, restrict, asm, typeof, _asm
+
+void whatever() {}
diff --git a/clang/test/Preprocessor/feature_tests.c b/clang/test/Preprocessor/feature_tests.c
new file mode 100644
index 0000000..b78a251
--- /dev/null
+++ b/clang/test/Preprocessor/feature_tests.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 %s -triple=i686-apple-darwin9
+// RUN: %clang_cc1 %s -E -triple=i686-apple-darwin9
+#ifndef __has_feature
+#error Should have __has_feature
+#endif
+
+
+#if __has_feature(something_we_dont_have)
+#error Bad
+#endif
+
+#if !__has_builtin(__builtin_huge_val) || \
+ !__has_builtin(__builtin_shufflevector) || \
+ !__has_builtin(__builtin_trap) || \
+ !__has_builtin(__c11_atomic_init) || \
+ !__has_feature(attribute_analyzer_noreturn) || \
+ !__has_feature(attribute_overloadable)
+#error Clang should have these
+#endif
+
+#if __has_builtin(__builtin_insanity)
+#error Clang should not have this
+#endif
+
+#if !__has_feature(__attribute_deprecated_with_message__)
+#error Feature name in double underscores does not work
+#endif
+
+// Make sure we have x86 builtins only (forced with target triple).
+
+#if !__has_builtin(__builtin_ia32_emms) || \
+ __has_builtin(__builtin_altivec_abs_v4sf)
+#error Broken handling of target-specific builtins
+#endif
diff --git a/clang/test/Preprocessor/file_to_include.h b/clang/test/Preprocessor/file_to_include.h
new file mode 100644
index 0000000..97728ab
--- /dev/null
+++ b/clang/test/Preprocessor/file_to_include.h
@@ -0,0 +1,3 @@
+
+#warning file successfully included
+
diff --git a/clang/test/Preprocessor/function_macro_file.c b/clang/test/Preprocessor/function_macro_file.c
new file mode 100644
index 0000000..c97bb75
--- /dev/null
+++ b/clang/test/Preprocessor/function_macro_file.c
@@ -0,0 +1,5 @@
+/* RUN: %clang_cc1 -E -P %s | grep f
+ */
+
+#include "function_macro_file.h"
+()
diff --git a/clang/test/Preprocessor/function_macro_file.h b/clang/test/Preprocessor/function_macro_file.h
new file mode 100644
index 0000000..43d1199
--- /dev/null
+++ b/clang/test/Preprocessor/function_macro_file.h
@@ -0,0 +1,3 @@
+
+#define f() x
+f
diff --git a/clang/test/Preprocessor/has_attribute.c b/clang/test/Preprocessor/has_attribute.c
new file mode 100644
index 0000000..80f53a5
--- /dev/null
+++ b/clang/test/Preprocessor/has_attribute.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -E %s -o - | FileCheck %s
+
+// CHECK: always_inline
+#if __has_attribute(always_inline)
+int always_inline();
+#endif
+
+// CHECK: __always_inline__
+#if __has_attribute(__always_inline__)
+int __always_inline__();
+#endif
+
+// CHECK: no_dummy_attribute
+#if !__has_attribute(dummy_attribute)
+int no_dummy_attribute();
+#endif
+
+// CHECK: has_has_attribute
+#ifdef __has_attribute
+int has_has_attribute();
+#endif
+
+// CHECK: has_something_we_dont_have
+#if !__has_attribute(something_we_dont_have)
+int has_something_we_dont_have();
+#endif
diff --git a/clang/test/Preprocessor/has_include.c b/clang/test/Preprocessor/has_include.c
new file mode 100644
index 0000000..fdcae78
--- /dev/null
+++ b/clang/test/Preprocessor/has_include.c
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -ffreestanding -Eonly -verify %s
+
+// Try different path permutations of __has_include with existing file.
+#if __has_include("stdint.h")
+#else
+ #error "__has_include failed (1)."
+#endif
+
+#if __has_include(<stdint.h>)
+#else
+ #error "__has_include failed (2)."
+#endif
+
+// Try unary expression.
+#if !__has_include("stdint.h")
+ #error "__has_include failed (5)."
+#endif
+
+// Try binary expression.
+#if __has_include("stdint.h") && __has_include("stddef.h")
+#else
+ #error "__has_include failed (6)."
+#endif
+
+// Try non-existing file.
+#if __has_include("blahblah.h")
+ #error "__has_include failed (7)."
+#endif
+
+// Try defined.
+#if !defined(__has_include)
+ #error "defined(__has_include) failed (8)."
+#endif
+
+// Try different path permutations of __has_include_next with existing file.
+#if __has_include_next("stddef.h") // expected-warning {{#include_next in primary source file}}
+#else
+ #error "__has_include failed (1)."
+#endif
+
+#if __has_include_next(<stddef.h>) // expected-warning {{#include_next in primary source file}}
+#else
+ #error "__has_include failed (2)."
+#endif
+
+// Try unary expression.
+#if !__has_include_next("stdint.h") // expected-warning {{#include_next in primary source file}}
+ #error "__has_include_next failed (5)."
+#endif
+
+// Try binary expression.
+#if __has_include_next("stdint.h") && __has_include("stddef.h") // expected-warning {{#include_next in primary source file}}
+#else
+ #error "__has_include_next failed (6)."
+#endif
+
+// Try non-existing file.
+#if __has_include_next("blahblah.h") // expected-warning {{#include_next in primary source file}}
+ #error "__has_include_next failed (7)."
+#endif
+
+// Try defined.
+#if !defined(__has_include_next)
+ #error "defined(__has_include_next) failed (8)."
+#endif
+
+// Try badly formed expressions.
+// FIXME: I don't quite know how to avoid preprocessor side effects.
+// Use FileCheck?
+// It also assert due to unterminated #if's.
+//#if __has_include("stdint.h"
+//#if __has_include "stdint.h")
+//#if __has_include(stdint.h)
+//#if __has_include()
+//#if __has_include(
+//#if __has_include)
+//#if __has_include
+//#if __has_include(<stdint.h>
+//#if __has_include<stdint.h>)
+//#if __has_include("stdint.h)
+//#if __has_include(stdint.h")
+//#if __has_include(<stdint.h)
+//#if __has_include(stdint.h>)
diff --git a/clang/test/Preprocessor/hash_line.c b/clang/test/Preprocessor/hash_line.c
new file mode 100644
index 0000000..4f724df
--- /dev/null
+++ b/clang/test/Preprocessor/hash_line.c
@@ -0,0 +1,8 @@
+// The 1 and # should not go on the same line.
+// RUN: %clang_cc1 %s -E | not grep "1 #"
+// RUN: %clang_cc1 %s -E | grep '^1$'
+// RUN: %clang_cc1 %s -E | grep '^ #$'
+1
+#define EMPTY
+EMPTY #
+
diff --git a/clang/test/Preprocessor/hash_space.c b/clang/test/Preprocessor/hash_space.c
new file mode 100644
index 0000000..ac97556
--- /dev/null
+++ b/clang/test/Preprocessor/hash_space.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -E | grep " #"
+
+// Should put a space before the # so that -fpreprocessed mode doesn't
+// macro expand this again.
+#define HASH #
+HASH define foo bar
diff --git a/clang/test/Preprocessor/header_lookup1.c b/clang/test/Preprocessor/header_lookup1.c
new file mode 100644
index 0000000..d090936
--- /dev/null
+++ b/clang/test/Preprocessor/header_lookup1.c
@@ -0,0 +1,2 @@
+// RUN: %clang -fno-ms-extensions %s -E | grep 'stddef.h.*3'
+#include <stddef.h>
diff --git a/clang/test/Preprocessor/if_warning.c b/clang/test/Preprocessor/if_warning.c
new file mode 100644
index 0000000..641ec3b
--- /dev/null
+++ b/clang/test/Preprocessor/if_warning.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -Eonly -Werror=undef -verify
+// RUN: %clang_cc1 %s -Eonly -Werror-undef -verify
+
+extern int x;
+
+#if foo // expected-error {{'foo' is not defined, evaluates to 0}}
+#endif
+
+#ifdef foo
+#endif
+
+#if defined(foo)
+#endif
+
+
+// PR3938
+#if 0
+#ifdef D
+#else 1 // Should not warn due to C99 6.10p4
+#endif
+#endif
+
+// rdar://9475098
+#if 0
+#else 1 // expected-warning {{extra tokens}}
+#endif
+
+// PR6852
+#if 'somesillylongthing' // expected-warning {{character constant too long for its type}} \
+ // expected-warning {{multi-character character constant}}
+#endif
diff --git a/clang/test/Preprocessor/ifdef-recover.c b/clang/test/Preprocessor/ifdef-recover.c
new file mode 100644
index 0000000..51d06d1
--- /dev/null
+++ b/clang/test/Preprocessor/ifdef-recover.c
@@ -0,0 +1,15 @@
+/* RUN: %clang_cc1 -E %s 2>&1 >/dev/null | grep error: | count 3
+ */
+
+#ifdef
+
+#endif
+
+/* End of function-like macro invocation in #ifdef */
+/* PR1936 */
+#define f(x) x
+#if f(2
+#endif
+
+int x;
+
diff --git a/clang/test/Preprocessor/import_self.c b/clang/test/Preprocessor/import_self.c
new file mode 100644
index 0000000..8ba0b19
--- /dev/null
+++ b/clang/test/Preprocessor/import_self.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -E -I. %s | grep BODY_OF_FILE | wc -l | grep 1
+
+// This #import should have no effect, as we're importing the current file.
+#import <import_self.c>
+
+BODY_OF_FILE
+
diff --git a/clang/test/Preprocessor/include-directive1.c b/clang/test/Preprocessor/include-directive1.c
new file mode 100644
index 0000000..20f4582
--- /dev/null
+++ b/clang/test/Preprocessor/include-directive1.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -E %s -fno-caret-diagnostics 2>&1 >/dev/null | grep 'file successfully included' | count 3
+
+// XX expands to nothing.
+#define XX
+
+// expand macros to get to file to include
+#define FILE "file_to_include.h"
+#include XX FILE
+
+#include FILE
+
+// normal include
+#include "file_to_include.h"
+
diff --git a/clang/test/Preprocessor/include-directive2.c b/clang/test/Preprocessor/include-directive2.c
new file mode 100644
index 0000000..b1a9940
--- /dev/null
+++ b/clang/test/Preprocessor/include-directive2.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -ffreestanding -Eonly -verify %s
+# define HEADER <stdarg.h>
+
+# include HEADER
+
+#include <limits.h> NON_EMPTY // expected-warning {{extra tokens at end of #include directive}}
+
+// PR3916: these are ok.
+#define EMPTY
+#include <limits.h> EMPTY
+#include HEADER EMPTY
+
+// PR3916
+#define FN limits.h>
+#include <FN
+
+#include <> // expected-error {{empty filename}}
diff --git a/clang/test/Preprocessor/include-directive3.c b/clang/test/Preprocessor/include-directive3.c
new file mode 100644
index 0000000..c0e2ae1
--- /dev/null
+++ b/clang/test/Preprocessor/include-directive3.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -include %S/file_to_include.h -E %s -fno-caret-diagnostics 2>&1 >/dev/null | grep 'file successfully included' | count 1
+// PR3464
+
diff --git a/clang/test/Preprocessor/include-macros.c b/clang/test/Preprocessor/include-macros.c
new file mode 100644
index 0000000..b86cd0d
--- /dev/null
+++ b/clang/test/Preprocessor/include-macros.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -E -Dtest=FOO -imacros %S/pr2086.h %s | grep 'HERE: test'
+
+// This should not be expanded into FOO because pr2086.h undefs 'test'.
+HERE: test
diff --git a/clang/test/Preprocessor/include-pth.c b/clang/test/Preprocessor/include-pth.c
new file mode 100644
index 0000000..e1d6685
--- /dev/null
+++ b/clang/test/Preprocessor/include-pth.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-pth %s -o %t
+// RUN: %clang_cc1 -include-pth %t %s -E | grep 'file_to_include' | count 2
+#include "file_to_include.h"
diff --git a/clang/test/Preprocessor/indent_macro.c b/clang/test/Preprocessor/indent_macro.c
new file mode 100644
index 0000000..e695007
--- /dev/null
+++ b/clang/test/Preprocessor/indent_macro.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -E %s | grep '^ zzap$'
+
+// zzap is on a new line, should be indented.
+#define BLAH zzap
+ BLAH
+
diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
new file mode 100644
index 0000000..e0f45f1
--- /dev/null
+++ b/clang/test/Preprocessor/init.c
@@ -0,0 +1,1764 @@
+// RUN: %clang_cc1 -E -dM -x assembler-with-cpp < /dev/null | FileCheck -check-prefix ASM %s
+//
+// ASM:#define __ASSEMBLER__ 1
+//
+//
+// RUN: %clang_cc1 -fblocks -E -dM < /dev/null | FileCheck -check-prefix BLOCKS %s
+//
+// BLOCKS:#define __BLOCKS__ 1
+// BLOCKS:#define __block __attribute__((__blocks__(byref)))
+//
+//
+// RUN: %clang_cc1 -x c++ -std=c++11 -E -dM < /dev/null | FileCheck -check-prefix CXX0X %s
+//
+// CXX0X:#define __GNUG__
+// CXX0X:#define __GXX_EXPERIMENTAL_CXX0X__ 1
+// CXX0X:#define __GXX_RTTI 1
+// CXX0X:#define __GXX_WEAK__ 1
+// CXX0X:#define __cplusplus 201103L
+// CXX0X:#define __private_extern__ extern
+//
+//
+// RUN: %clang_cc1 -x c++ -std=c++98 -E -dM < /dev/null | FileCheck -check-prefix CXX98 %s
+//
+// CXX98:#define __GNUG__
+// CXX98:#define __GXX_RTTI 1
+// CXX98:#define __GXX_WEAK__ 1
+// CXX98:#define __cplusplus 199711L
+// CXX98:#define __private_extern__ extern
+//
+//
+// RUN: %clang_cc1 -fdeprecated-macro -E -dM < /dev/null | FileCheck -check-prefix DEPRECATED %s
+//
+// DEPRECATED:#define __DEPRECATED 1
+//
+//
+// RUN: %clang_cc1 -std=c99 -E -dM < /dev/null | FileCheck -check-prefix C99 %s
+//
+// C99:#define __STDC_VERSION__ 199901L
+// C99:#define __STRICT_ANSI__ 1
+//
+//
+// RUN: %clang_cc1 -E -dM < /dev/null | FileCheck -check-prefix COMMON %s
+//
+// COMMON:#define __CONSTANT_CFSTRINGS__ 1
+// COMMON:#define __FINITE_MATH_ONLY__ 0
+// COMMON:#define __GNUC_MINOR__
+// COMMON:#define __GNUC_PATCHLEVEL__
+// COMMON:#define __GNUC_STDC_INLINE__ 1
+// COMMON:#define __GNUC__
+// COMMON:#define __GXX_ABI_VERSION
+// COMMON:#define __STDC_HOSTED__ 1
+// COMMON:#define __STDC_VERSION__
+// COMMON:#define __STDC__ 1
+// COMMON:#define __VERSION__
+// COMMON:#define __clang__ 1
+// COMMON:#define __clang_major__ {{[0-9]+}}
+// COMMON:#define __clang_minor__ {{[0-9]+}}
+// COMMON:#define __clang_patchlevel__ {{[0-9]+}}
+// COMMON:#define __clang_version__
+// COMMON:#define __llvm__ 1
+//
+//
+// RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -check-prefix FREESTANDING %s
+// FREESTANDING:#define __STDC_HOSTED__ 0
+//
+// RUN: %clang_cc1 -x c++ -std=gnu++98 -E -dM < /dev/null | FileCheck -check-prefix GXX98 %s
+//
+// GXX98:#define __GNUG__
+// GXX98:#define __GXX_WEAK__ 1
+// GXX98:#define __cplusplus 1
+// GXX98:#define __private_extern__ extern
+//
+//
+// RUN: %clang_cc1 -std=iso9899:199409 -E -dM < /dev/null | FileCheck -check-prefix C94 %s
+//
+// C94:#define __STDC_VERSION__ 199409L
+//
+//
+// RUN: %clang_cc1 -fms-extensions -triple i686-pc-win32 -fobjc-fragile-abi -E -dM < /dev/null | FileCheck -check-prefix MSEXT %s
+//
+// MSEXT-NOT:#define __STDC__
+// MSEXT:#define _INTEGRAL_MAX_BITS 64
+//
+//
+// RUN: %clang_cc1 -x objective-c -E -dM < /dev/null | FileCheck -check-prefix OBJC %s
+//
+// OBJC:#define OBJC_NEW_PROPERTIES 1
+// OBJC:#define __NEXT_RUNTIME__ 1
+// OBJC:#define __OBJC__ 1
+//
+//
+// RUN: %clang_cc1 -x objective-c -fobjc-gc -E -dM < /dev/null | FileCheck -check-prefix OBJCGC %s
+//
+// OBJCGC:#define __OBJC_GC__ 1
+//
+//
+// RUN: %clang_cc1 -x objective-c -fobjc-exceptions -E -dM < /dev/null | FileCheck -check-prefix NONFRAGILE %s
+//
+// NONFRAGILE:#define OBJC_ZEROCOST_EXCEPTIONS 1
+// NONFRAGILE:#define __OBJC2__ 1
+//
+//
+// RUN: %clang_cc1 -O1 -E -dM < /dev/null | FileCheck -check-prefix O1 %s
+//
+// O1:#define __OPTIMIZE__ 1
+//
+//
+// RUN: %clang_cc1 -fpascal-strings -E -dM < /dev/null | FileCheck -check-prefix PASCAL %s
+//
+// PASCAL:#define __PASCAL_STRINGS__ 1
+//
+//
+// RUN: %clang_cc1 -E -dM < /dev/null | FileCheck -check-prefix SCHAR %s
+//
+// SCHAR:#define __STDC__ 1
+// SCHAR-NOT:#define __UNSIGNED_CHAR__
+// SCHAR:#define __clang__ 1
+//
+// RUN: %clang_cc1 -E -dM -fshort-wchar < /dev/null | FileCheck -check-prefix SHORTWCHAR %s
+//
+// SHORTWCHAR: #define __SIZEOF_WCHAR_T__ 2
+// SHORTWCHAR: #define __WCHAR_MAX__ 65535U
+// SHORTWCHAR: #define __WCHAR_TYPE__ unsigned short
+// SHORTWCHAR: #define __WCHAR_WIDTH__ 16
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-none < /dev/null | FileCheck -check-prefix ARM %s
+//
+// ARM:#define __APCS_32__ 1
+// ARM:#define __ARMEL__ 1
+// ARM:#define __ARM_ARCH_6J__ 1
+// ARM:#define __CHAR16_TYPE__ unsigned short
+// ARM:#define __CHAR32_TYPE__ unsigned int
+// ARM:#define __CHAR_BIT__ 8
+// ARM:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// ARM:#define __DBL_DIG__ 15
+// ARM:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// ARM:#define __DBL_HAS_DENORM__ 1
+// ARM:#define __DBL_HAS_INFINITY__ 1
+// ARM:#define __DBL_HAS_QUIET_NAN__ 1
+// ARM:#define __DBL_MANT_DIG__ 53
+// ARM:#define __DBL_MAX_10_EXP__ 308
+// ARM:#define __DBL_MAX_EXP__ 1024
+// ARM:#define __DBL_MAX__ 1.7976931348623157e+308
+// ARM:#define __DBL_MIN_10_EXP__ (-307)
+// ARM:#define __DBL_MIN_EXP__ (-1021)
+// ARM:#define __DBL_MIN__ 2.2250738585072014e-308
+// ARM:#define __DECIMAL_DIG__ 17
+// ARM:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// ARM:#define __FLT_DIG__ 6
+// ARM:#define __FLT_EPSILON__ 1.19209290e-7F
+// ARM:#define __FLT_EVAL_METHOD__ 0
+// ARM:#define __FLT_HAS_DENORM__ 1
+// ARM:#define __FLT_HAS_INFINITY__ 1
+// ARM:#define __FLT_HAS_QUIET_NAN__ 1
+// ARM:#define __FLT_MANT_DIG__ 24
+// ARM:#define __FLT_MAX_10_EXP__ 38
+// ARM:#define __FLT_MAX_EXP__ 128
+// ARM:#define __FLT_MAX__ 3.40282347e+38F
+// ARM:#define __FLT_MIN_10_EXP__ (-37)
+// ARM:#define __FLT_MIN_EXP__ (-125)
+// ARM:#define __FLT_MIN__ 1.17549435e-38F
+// ARM:#define __FLT_RADIX__ 2
+// ARM:#define __INT16_TYPE__ short
+// ARM:#define __INT32_TYPE__ int
+// ARM:#define __INT64_C_SUFFIX__ LL
+// ARM:#define __INT64_TYPE__ long long int
+// ARM:#define __INT8_TYPE__ char
+// ARM:#define __INTMAX_MAX__ 9223372036854775807LL
+// ARM:#define __INTMAX_TYPE__ long long int
+// ARM:#define __INTMAX_WIDTH__ 64
+// ARM:#define __INTPTR_TYPE__ long int
+// ARM:#define __INTPTR_WIDTH__ 32
+// ARM:#define __INT_MAX__ 2147483647
+// ARM:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324
+// ARM:#define __LDBL_DIG__ 15
+// ARM:#define __LDBL_EPSILON__ 2.2204460492503131e-16
+// ARM:#define __LDBL_HAS_DENORM__ 1
+// ARM:#define __LDBL_HAS_INFINITY__ 1
+// ARM:#define __LDBL_HAS_QUIET_NAN__ 1
+// ARM:#define __LDBL_MANT_DIG__ 53
+// ARM:#define __LDBL_MAX_10_EXP__ 308
+// ARM:#define __LDBL_MAX_EXP__ 1024
+// ARM:#define __LDBL_MAX__ 1.7976931348623157e+308
+// ARM:#define __LDBL_MIN_10_EXP__ (-307)
+// ARM:#define __LDBL_MIN_EXP__ (-1021)
+// ARM:#define __LDBL_MIN__ 2.2250738585072014e-308
+// ARM:#define __LITTLE_ENDIAN__ 1
+// ARM:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// ARM:#define __LONG_MAX__ 2147483647L
+// ARM:#define __NO_INLINE__ 1
+// ARM:#define __POINTER_WIDTH__ 32
+// ARM:#define __PTRDIFF_TYPE__ int
+// ARM:#define __PTRDIFF_WIDTH__ 32
+// ARM:#define __REGISTER_PREFIX__
+// ARM:#define __SCHAR_MAX__ 127
+// ARM:#define __SHRT_MAX__ 32767
+// ARM:#define __SIG_ATOMIC_WIDTH__ 32
+// ARM:#define __SIZEOF_DOUBLE__ 8
+// ARM:#define __SIZEOF_FLOAT__ 4
+// ARM:#define __SIZEOF_INT__ 4
+// ARM:#define __SIZEOF_LONG_DOUBLE__ 8
+// ARM:#define __SIZEOF_LONG_LONG__ 8
+// ARM:#define __SIZEOF_LONG__ 4
+// ARM:#define __SIZEOF_POINTER__ 4
+// ARM:#define __SIZEOF_PTRDIFF_T__ 4
+// ARM:#define __SIZEOF_SHORT__ 2
+// ARM:#define __SIZEOF_SIZE_T__ 4
+// ARM:#define __SIZEOF_WCHAR_T__ 4
+// ARM:#define __SIZEOF_WINT_T__ 4
+// ARM:#define __SIZE_TYPE__ unsigned int
+// ARM:#define __SIZE_WIDTH__ 32
+// ARM:#define __THUMB_INTERWORK__ 1
+// ARM:#define __UINTMAX_TYPE__ long long unsigned int
+// ARM:#define __USER_LABEL_PREFIX__ _
+// ARM:#define __WCHAR_MAX__ 4294967295U
+// ARM:#define __WCHAR_TYPE__ unsigned int
+// ARM:#define __WCHAR_WIDTH__ 32
+// ARM:#define __WINT_TYPE__ int
+// ARM:#define __WINT_WIDTH__ 32
+// ARM:#define __arm 1
+// ARM:#define __arm__ 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-none-none < /dev/null | FileCheck -check-prefix I386 %s
+//
+// I386:#define __CHAR16_TYPE__ unsigned short
+// I386:#define __CHAR32_TYPE__ unsigned int
+// I386:#define __CHAR_BIT__ 8
+// I386:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// I386:#define __DBL_DIG__ 15
+// I386:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// I386:#define __DBL_HAS_DENORM__ 1
+// I386:#define __DBL_HAS_INFINITY__ 1
+// I386:#define __DBL_HAS_QUIET_NAN__ 1
+// I386:#define __DBL_MANT_DIG__ 53
+// I386:#define __DBL_MAX_10_EXP__ 308
+// I386:#define __DBL_MAX_EXP__ 1024
+// I386:#define __DBL_MAX__ 1.7976931348623157e+308
+// I386:#define __DBL_MIN_10_EXP__ (-307)
+// I386:#define __DBL_MIN_EXP__ (-1021)
+// I386:#define __DBL_MIN__ 2.2250738585072014e-308
+// I386:#define __DECIMAL_DIG__ 21
+// I386:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// I386:#define __FLT_DIG__ 6
+// I386:#define __FLT_EPSILON__ 1.19209290e-7F
+// I386:#define __FLT_EVAL_METHOD__ 2
+// I386:#define __FLT_HAS_DENORM__ 1
+// I386:#define __FLT_HAS_INFINITY__ 1
+// I386:#define __FLT_HAS_QUIET_NAN__ 1
+// I386:#define __FLT_MANT_DIG__ 24
+// I386:#define __FLT_MAX_10_EXP__ 38
+// I386:#define __FLT_MAX_EXP__ 128
+// I386:#define __FLT_MAX__ 3.40282347e+38F
+// I386:#define __FLT_MIN_10_EXP__ (-37)
+// I386:#define __FLT_MIN_EXP__ (-125)
+// I386:#define __FLT_MIN__ 1.17549435e-38F
+// I386:#define __FLT_RADIX__ 2
+// I386:#define __INT16_TYPE__ short
+// I386:#define __INT32_TYPE__ int
+// I386:#define __INT64_C_SUFFIX__ LL
+// I386:#define __INT64_TYPE__ long long int
+// I386:#define __INT8_TYPE__ char
+// I386:#define __INTMAX_MAX__ 9223372036854775807LL
+// I386:#define __INTMAX_TYPE__ long long int
+// I386:#define __INTMAX_WIDTH__ 64
+// I386:#define __INTPTR_TYPE__ int
+// I386:#define __INTPTR_WIDTH__ 32
+// I386:#define __INT_MAX__ 2147483647
+// I386:#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
+// I386:#define __LDBL_DIG__ 18
+// I386:#define __LDBL_EPSILON__ 1.08420217248550443401e-19L
+// I386:#define __LDBL_HAS_DENORM__ 1
+// I386:#define __LDBL_HAS_INFINITY__ 1
+// I386:#define __LDBL_HAS_QUIET_NAN__ 1
+// I386:#define __LDBL_MANT_DIG__ 64
+// I386:#define __LDBL_MAX_10_EXP__ 4932
+// I386:#define __LDBL_MAX_EXP__ 16384
+// I386:#define __LDBL_MAX__ 1.18973149535723176502e+4932L
+// I386:#define __LDBL_MIN_10_EXP__ (-4931)
+// I386:#define __LDBL_MIN_EXP__ (-16381)
+// I386:#define __LDBL_MIN__ 3.36210314311209350626e-4932L
+// I386:#define __LITTLE_ENDIAN__ 1
+// I386:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// I386:#define __LONG_MAX__ 2147483647L
+// I386:#define __NO_INLINE__ 1
+// I386:#define __NO_MATH_INLINES 1
+// I386:#define __POINTER_WIDTH__ 32
+// I386:#define __PTRDIFF_TYPE__ int
+// I386:#define __PTRDIFF_WIDTH__ 32
+// I386:#define __REGISTER_PREFIX__
+// I386:#define __SCHAR_MAX__ 127
+// I386:#define __SHRT_MAX__ 32767
+// I386:#define __SIG_ATOMIC_WIDTH__ 32
+// I386:#define __SIZEOF_DOUBLE__ 8
+// I386:#define __SIZEOF_FLOAT__ 4
+// I386:#define __SIZEOF_INT__ 4
+// I386:#define __SIZEOF_LONG_DOUBLE__ 12
+// I386:#define __SIZEOF_LONG_LONG__ 8
+// I386:#define __SIZEOF_LONG__ 4
+// I386:#define __SIZEOF_POINTER__ 4
+// I386:#define __SIZEOF_PTRDIFF_T__ 4
+// I386:#define __SIZEOF_SHORT__ 2
+// I386:#define __SIZEOF_SIZE_T__ 4
+// I386:#define __SIZEOF_WCHAR_T__ 4
+// I386:#define __SIZEOF_WINT_T__ 4
+// I386:#define __SIZE_TYPE__ unsigned int
+// I386:#define __SIZE_WIDTH__ 32
+// I386:#define __UINTMAX_TYPE__ long long unsigned int
+// I386:#define __USER_LABEL_PREFIX__ _
+// I386:#define __WCHAR_MAX__ 2147483647
+// I386:#define __WCHAR_TYPE__ int
+// I386:#define __WCHAR_WIDTH__ 32
+// I386:#define __WINT_TYPE__ int
+// I386:#define __WINT_WIDTH__ 32
+// I386:#define __i386 1
+// I386:#define __i386__ 1
+// I386:#define i386 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-pc-linux-gnu -target-cpu pentium4 < /dev/null | FileCheck -check-prefix I386-LINUX %s
+//
+// I386-LINUX:#define __CHAR16_TYPE__ unsigned short
+// I386-LINUX:#define __CHAR32_TYPE__ unsigned int
+// I386-LINUX:#define __CHAR_BIT__ 8
+// I386-LINUX:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// I386-LINUX:#define __DBL_DIG__ 15
+// I386-LINUX:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// I386-LINUX:#define __DBL_HAS_DENORM__ 1
+// I386-LINUX:#define __DBL_HAS_INFINITY__ 1
+// I386-LINUX:#define __DBL_HAS_QUIET_NAN__ 1
+// I386-LINUX:#define __DBL_MANT_DIG__ 53
+// I386-LINUX:#define __DBL_MAX_10_EXP__ 308
+// I386-LINUX:#define __DBL_MAX_EXP__ 1024
+// I386-LINUX:#define __DBL_MAX__ 1.7976931348623157e+308
+// I386-LINUX:#define __DBL_MIN_10_EXP__ (-307)
+// I386-LINUX:#define __DBL_MIN_EXP__ (-1021)
+// I386-LINUX:#define __DBL_MIN__ 2.2250738585072014e-308
+// I386-LINUX:#define __DECIMAL_DIG__ 21
+// I386-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// I386-LINUX:#define __FLT_DIG__ 6
+// I386-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F
+// I386-LINUX:#define __FLT_EVAL_METHOD__ 0
+// I386-LINUX:#define __FLT_HAS_DENORM__ 1
+// I386-LINUX:#define __FLT_HAS_INFINITY__ 1
+// I386-LINUX:#define __FLT_HAS_QUIET_NAN__ 1
+// I386-LINUX:#define __FLT_MANT_DIG__ 24
+// I386-LINUX:#define __FLT_MAX_10_EXP__ 38
+// I386-LINUX:#define __FLT_MAX_EXP__ 128
+// I386-LINUX:#define __FLT_MAX__ 3.40282347e+38F
+// I386-LINUX:#define __FLT_MIN_10_EXP__ (-37)
+// I386-LINUX:#define __FLT_MIN_EXP__ (-125)
+// I386-LINUX:#define __FLT_MIN__ 1.17549435e-38F
+// I386-LINUX:#define __FLT_RADIX__ 2
+// I386-LINUX:#define __INT16_TYPE__ short
+// I386-LINUX:#define __INT32_TYPE__ int
+// I386-LINUX:#define __INT64_C_SUFFIX__ LL
+// I386-LINUX:#define __INT64_TYPE__ long long int
+// I386-LINUX:#define __INT8_TYPE__ char
+// I386-LINUX:#define __INTMAX_MAX__ 9223372036854775807LL
+// I386-LINUX:#define __INTMAX_TYPE__ long long int
+// I386-LINUX:#define __INTMAX_WIDTH__ 64
+// I386-LINUX:#define __INTPTR_TYPE__ int
+// I386-LINUX:#define __INTPTR_WIDTH__ 32
+// I386-LINUX:#define __INT_MAX__ 2147483647
+// I386-LINUX:#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
+// I386-LINUX:#define __LDBL_DIG__ 18
+// I386-LINUX:#define __LDBL_EPSILON__ 1.08420217248550443401e-19L
+// I386-LINUX:#define __LDBL_HAS_DENORM__ 1
+// I386-LINUX:#define __LDBL_HAS_INFINITY__ 1
+// I386-LINUX:#define __LDBL_HAS_QUIET_NAN__ 1
+// I386-LINUX:#define __LDBL_MANT_DIG__ 64
+// I386-LINUX:#define __LDBL_MAX_10_EXP__ 4932
+// I386-LINUX:#define __LDBL_MAX_EXP__ 16384
+// I386-LINUX:#define __LDBL_MAX__ 1.18973149535723176502e+4932L
+// I386-LINUX:#define __LDBL_MIN_10_EXP__ (-4931)
+// I386-LINUX:#define __LDBL_MIN_EXP__ (-16381)
+// I386-LINUX:#define __LDBL_MIN__ 3.36210314311209350626e-4932L
+// I386-LINUX:#define __LITTLE_ENDIAN__ 1
+// I386-LINUX:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// I386-LINUX:#define __LONG_MAX__ 2147483647L
+// I386-LINUX:#define __NO_INLINE__ 1
+// I386-LINUX:#define __NO_MATH_INLINES 1
+// I386-LINUX:#define __POINTER_WIDTH__ 32
+// I386-LINUX:#define __PTRDIFF_TYPE__ int
+// I386-LINUX:#define __PTRDIFF_WIDTH__ 32
+// I386-LINUX:#define __REGISTER_PREFIX__
+// I386-LINUX:#define __SCHAR_MAX__ 127
+// I386-LINUX:#define __SHRT_MAX__ 32767
+// I386-LINUX:#define __SIG_ATOMIC_WIDTH__ 32
+// I386-LINUX:#define __SIZEOF_DOUBLE__ 8
+// I386-LINUX:#define __SIZEOF_FLOAT__ 4
+// I386-LINUX:#define __SIZEOF_INT__ 4
+// I386-LINUX:#define __SIZEOF_LONG_DOUBLE__ 12
+// I386-LINUX:#define __SIZEOF_LONG_LONG__ 8
+// I386-LINUX:#define __SIZEOF_LONG__ 4
+// I386-LINUX:#define __SIZEOF_POINTER__ 4
+// I386-LINUX:#define __SIZEOF_PTRDIFF_T__ 4
+// I386-LINUX:#define __SIZEOF_SHORT__ 2
+// I386-LINUX:#define __SIZEOF_SIZE_T__ 4
+// I386-LINUX:#define __SIZEOF_WCHAR_T__ 4
+// I386-LINUX:#define __SIZEOF_WINT_T__ 4
+// I386-LINUX:#define __SIZE_TYPE__ unsigned int
+// I386-LINUX:#define __SIZE_WIDTH__ 32
+// I386-LINUX:#define __UINTMAX_TYPE__ long long unsigned int
+// I386-LINUX:#define __USER_LABEL_PREFIX__
+// I386-LINUX:#define __WCHAR_MAX__ 2147483647
+// I386-LINUX:#define __WCHAR_TYPE__ int
+// I386-LINUX:#define __WCHAR_WIDTH__ 32
+// I386-LINUX:#define __WINT_TYPE__ unsigned int
+// I386-LINUX:#define __WINT_WIDTH__ 32
+// I386-LINUX:#define __i386 1
+// I386-LINUX:#define __i386__ 1
+// I386-LINUX:#define i386 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips-none-none < /dev/null | FileCheck -check-prefix MIPS32BE %s
+//
+// MIPS32BE:#define MIPSEB 1
+// MIPS32BE:#define _ABIO32 1
+// MIPS32BE:#define _MIPSEB 1
+// MIPS32BE:#define _MIPS_SIM _ABIO32
+// MIPS32BE:#define _MIPS_SZINT 32
+// MIPS32BE:#define _MIPS_SZLONG 32
+// MIPS32BE:#define _MIPS_SZPTR 32
+// MIPS32BE:#define __CHAR16_TYPE__ unsigned short
+// MIPS32BE:#define __CHAR32_TYPE__ unsigned int
+// MIPS32BE:#define __CHAR_BIT__ 8
+// MIPS32BE:#define __CONSTANT_CFSTRINGS__ 1
+// MIPS32BE:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS32BE:#define __DBL_DIG__ 15
+// MIPS32BE:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// MIPS32BE:#define __DBL_HAS_DENORM__ 1
+// MIPS32BE:#define __DBL_HAS_INFINITY__ 1
+// MIPS32BE:#define __DBL_HAS_QUIET_NAN__ 1
+// MIPS32BE:#define __DBL_MANT_DIG__ 53
+// MIPS32BE:#define __DBL_MAX_10_EXP__ 308
+// MIPS32BE:#define __DBL_MAX_EXP__ 1024
+// MIPS32BE:#define __DBL_MAX__ 1.7976931348623157e+308
+// MIPS32BE:#define __DBL_MIN_10_EXP__ (-307)
+// MIPS32BE:#define __DBL_MIN_EXP__ (-1021)
+// MIPS32BE:#define __DBL_MIN__ 2.2250738585072014e-308
+// MIPS32BE:#define __DECIMAL_DIG__ 17
+// MIPS32BE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// MIPS32BE:#define __FLT_DIG__ 6
+// MIPS32BE:#define __FLT_EPSILON__ 1.19209290e-7F
+// MIPS32BE:#define __FLT_EVAL_METHOD__ 0
+// MIPS32BE:#define __FLT_HAS_DENORM__ 1
+// MIPS32BE:#define __FLT_HAS_INFINITY__ 1
+// MIPS32BE:#define __FLT_HAS_QUIET_NAN__ 1
+// MIPS32BE:#define __FLT_MANT_DIG__ 24
+// MIPS32BE:#define __FLT_MAX_10_EXP__ 38
+// MIPS32BE:#define __FLT_MAX_EXP__ 128
+// MIPS32BE:#define __FLT_MAX__ 3.40282347e+38F
+// MIPS32BE:#define __FLT_MIN_10_EXP__ (-37)
+// MIPS32BE:#define __FLT_MIN_EXP__ (-125)
+// MIPS32BE:#define __FLT_MIN__ 1.17549435e-38F
+// MIPS32BE:#define __FLT_RADIX__ 2
+// MIPS32BE:#define __INT16_TYPE__ short
+// MIPS32BE:#define __INT32_TYPE__ int
+// MIPS32BE:#define __INT64_C_SUFFIX__ LL
+// MIPS32BE:#define __INT64_TYPE__ long long int
+// MIPS32BE:#define __INT8_TYPE__ char
+// MIPS32BE:#define __INTMAX_MAX__ 9223372036854775807LL
+// MIPS32BE:#define __INTMAX_TYPE__ long long int
+// MIPS32BE:#define __INTMAX_WIDTH__ 64
+// MIPS32BE:#define __INTPTR_TYPE__ long int
+// MIPS32BE:#define __INTPTR_WIDTH__ 32
+// MIPS32BE:#define __INT_MAX__ 2147483647
+// MIPS32BE:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS32BE:#define __LDBL_DIG__ 15
+// MIPS32BE:#define __LDBL_EPSILON__ 2.2204460492503131e-16
+// MIPS32BE:#define __LDBL_HAS_DENORM__ 1
+// MIPS32BE:#define __LDBL_HAS_INFINITY__ 1
+// MIPS32BE:#define __LDBL_HAS_QUIET_NAN__ 1
+// MIPS32BE:#define __LDBL_MANT_DIG__ 53
+// MIPS32BE:#define __LDBL_MAX_10_EXP__ 308
+// MIPS32BE:#define __LDBL_MAX_EXP__ 1024
+// MIPS32BE:#define __LDBL_MAX__ 1.7976931348623157e+308
+// MIPS32BE:#define __LDBL_MIN_10_EXP__ (-307)
+// MIPS32BE:#define __LDBL_MIN_EXP__ (-1021)
+// MIPS32BE:#define __LDBL_MIN__ 2.2250738585072014e-308
+// MIPS32BE:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// MIPS32BE:#define __LONG_MAX__ 2147483647L
+// MIPS32BE:#define __MIPSEB 1
+// MIPS32BE:#define __MIPSEB__ 1
+// MIPS32BE:#define __NO_INLINE__ 1
+// MIPS32BE:#define __POINTER_WIDTH__ 32
+// MIPS32BE:#define __PRAGMA_REDEFINE_EXTNAME 1
+// MIPS32BE:#define __PTRDIFF_TYPE__ int
+// MIPS32BE:#define __PTRDIFF_WIDTH__ 32
+// MIPS32BE:#define __REGISTER_PREFIX__
+// MIPS32BE:#define __SCHAR_MAX__ 127
+// MIPS32BE:#define __SHRT_MAX__ 32767
+// MIPS32BE:#define __SIG_ATOMIC_WIDTH__ 32
+// MIPS32BE:#define __SIZEOF_DOUBLE__ 8
+// MIPS32BE:#define __SIZEOF_FLOAT__ 4
+// MIPS32BE:#define __SIZEOF_INT__ 4
+// MIPS32BE:#define __SIZEOF_LONG_DOUBLE__ 8
+// MIPS32BE:#define __SIZEOF_LONG_LONG__ 8
+// MIPS32BE:#define __SIZEOF_LONG__ 4
+// MIPS32BE:#define __SIZEOF_POINTER__ 4
+// MIPS32BE:#define __SIZEOF_PTRDIFF_T__ 4
+// MIPS32BE:#define __SIZEOF_SHORT__ 2
+// MIPS32BE:#define __SIZEOF_SIZE_T__ 4
+// MIPS32BE:#define __SIZEOF_WCHAR_T__ 4
+// MIPS32BE:#define __SIZEOF_WINT_T__ 4
+// MIPS32BE:#define __SIZE_TYPE__ unsigned int
+// MIPS32BE:#define __SIZE_WIDTH__ 32
+// MIPS32BE:#define __STDC_HOSTED__ 0
+// MIPS32BE:#define __STDC_VERSION__ 199901L
+// MIPS32BE:#define __STDC__ 1
+// MIPS32BE:#define __UINTMAX_TYPE__ long long unsigned int
+// MIPS32BE:#define __USER_LABEL_PREFIX__ _
+// MIPS32BE:#define __WCHAR_MAX__ 2147483647
+// MIPS32BE:#define __WCHAR_TYPE__ int
+// MIPS32BE:#define __WCHAR_WIDTH__ 32
+// MIPS32BE:#define __WINT_TYPE__ int
+// MIPS32BE:#define __WINT_WIDTH__ 32
+// MIPS32BE:#define __clang__ 1
+// MIPS32BE:#define __llvm__ 1
+// MIPS32BE:#define __mips 1
+// MIPS32BE:#define __mips__ 1
+// MIPS32BE:#define __mips_hard_float 1
+// MIPS32BE:#define __mips_o32 1
+// MIPS32BE:#define _mips 1
+// MIPS32BE:#define mips 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mipsel-none-none < /dev/null | FileCheck -check-prefix MIPS32EL %s
+//
+// MIPS32EL:#define MIPSEL 1
+// MIPS32EL:#define _ABIO32 1
+// MIPS32EL:#define _MIPSEL 1
+// MIPS32EL:#define _MIPS_SIM _ABIO32
+// MIPS32EL:#define _MIPS_SZINT 32
+// MIPS32EL:#define _MIPS_SZLONG 32
+// MIPS32EL:#define _MIPS_SZPTR 32
+// MIPS32EL:#define __CHAR16_TYPE__ unsigned short
+// MIPS32EL:#define __CHAR32_TYPE__ unsigned int
+// MIPS32EL:#define __CHAR_BIT__ 8
+// MIPS32EL:#define __CONSTANT_CFSTRINGS__ 1
+// MIPS32EL:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS32EL:#define __DBL_DIG__ 15
+// MIPS32EL:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// MIPS32EL:#define __DBL_HAS_DENORM__ 1
+// MIPS32EL:#define __DBL_HAS_INFINITY__ 1
+// MIPS32EL:#define __DBL_HAS_QUIET_NAN__ 1
+// MIPS32EL:#define __DBL_MANT_DIG__ 53
+// MIPS32EL:#define __DBL_MAX_10_EXP__ 308
+// MIPS32EL:#define __DBL_MAX_EXP__ 1024
+// MIPS32EL:#define __DBL_MAX__ 1.7976931348623157e+308
+// MIPS32EL:#define __DBL_MIN_10_EXP__ (-307)
+// MIPS32EL:#define __DBL_MIN_EXP__ (-1021)
+// MIPS32EL:#define __DBL_MIN__ 2.2250738585072014e-308
+// MIPS32EL:#define __DECIMAL_DIG__ 17
+// MIPS32EL:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// MIPS32EL:#define __FLT_DIG__ 6
+// MIPS32EL:#define __FLT_EPSILON__ 1.19209290e-7F
+// MIPS32EL:#define __FLT_EVAL_METHOD__ 0
+// MIPS32EL:#define __FLT_HAS_DENORM__ 1
+// MIPS32EL:#define __FLT_HAS_INFINITY__ 1
+// MIPS32EL:#define __FLT_HAS_QUIET_NAN__ 1
+// MIPS32EL:#define __FLT_MANT_DIG__ 24
+// MIPS32EL:#define __FLT_MAX_10_EXP__ 38
+// MIPS32EL:#define __FLT_MAX_EXP__ 128
+// MIPS32EL:#define __FLT_MAX__ 3.40282347e+38F
+// MIPS32EL:#define __FLT_MIN_10_EXP__ (-37)
+// MIPS32EL:#define __FLT_MIN_EXP__ (-125)
+// MIPS32EL:#define __FLT_MIN__ 1.17549435e-38F
+// MIPS32EL:#define __FLT_RADIX__ 2
+// MIPS32EL:#define __INT16_TYPE__ short
+// MIPS32EL:#define __INT32_TYPE__ int
+// MIPS32EL:#define __INT64_C_SUFFIX__ LL
+// MIPS32EL:#define __INT64_TYPE__ long long int
+// MIPS32EL:#define __INT8_TYPE__ char
+// MIPS32EL:#define __INTMAX_MAX__ 9223372036854775807LL
+// MIPS32EL:#define __INTMAX_TYPE__ long long int
+// MIPS32EL:#define __INTMAX_WIDTH__ 64
+// MIPS32EL:#define __INTPTR_TYPE__ long int
+// MIPS32EL:#define __INTPTR_WIDTH__ 32
+// MIPS32EL:#define __INT_MAX__ 2147483647
+// MIPS32EL:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS32EL:#define __LDBL_DIG__ 15
+// MIPS32EL:#define __LDBL_EPSILON__ 2.2204460492503131e-16
+// MIPS32EL:#define __LDBL_HAS_DENORM__ 1
+// MIPS32EL:#define __LDBL_HAS_INFINITY__ 1
+// MIPS32EL:#define __LDBL_HAS_QUIET_NAN__ 1
+// MIPS32EL:#define __LDBL_MANT_DIG__ 53
+// MIPS32EL:#define __LDBL_MAX_10_EXP__ 308
+// MIPS32EL:#define __LDBL_MAX_EXP__ 1024
+// MIPS32EL:#define __LDBL_MAX__ 1.7976931348623157e+308
+// MIPS32EL:#define __LDBL_MIN_10_EXP__ (-307)
+// MIPS32EL:#define __LDBL_MIN_EXP__ (-1021)
+// MIPS32EL:#define __LDBL_MIN__ 2.2250738585072014e-308
+// MIPS32EL:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// MIPS32EL:#define __LONG_MAX__ 2147483647L
+// MIPS32EL:#define __MIPSEL 1
+// MIPS32EL:#define __MIPSEL__ 1
+// MIPS32EL:#define __NO_INLINE__ 1
+// MIPS32EL:#define __POINTER_WIDTH__ 32
+// MIPS32EL:#define __PRAGMA_REDEFINE_EXTNAME 1
+// MIPS32EL:#define __PTRDIFF_TYPE__ int
+// MIPS32EL:#define __PTRDIFF_WIDTH__ 32
+// MIPS32EL:#define __REGISTER_PREFIX__
+// MIPS32EL:#define __SCHAR_MAX__ 127
+// MIPS32EL:#define __SHRT_MAX__ 32767
+// MIPS32EL:#define __SIG_ATOMIC_WIDTH__ 32
+// MIPS32EL:#define __SIZEOF_DOUBLE__ 8
+// MIPS32EL:#define __SIZEOF_FLOAT__ 4
+// MIPS32EL:#define __SIZEOF_INT__ 4
+// MIPS32EL:#define __SIZEOF_LONG_DOUBLE__ 8
+// MIPS32EL:#define __SIZEOF_LONG_LONG__ 8
+// MIPS32EL:#define __SIZEOF_LONG__ 4
+// MIPS32EL:#define __SIZEOF_POINTER__ 4
+// MIPS32EL:#define __SIZEOF_PTRDIFF_T__ 4
+// MIPS32EL:#define __SIZEOF_SHORT__ 2
+// MIPS32EL:#define __SIZEOF_SIZE_T__ 4
+// MIPS32EL:#define __SIZEOF_WCHAR_T__ 4
+// MIPS32EL:#define __SIZEOF_WINT_T__ 4
+// MIPS32EL:#define __SIZE_TYPE__ unsigned int
+// MIPS32EL:#define __SIZE_WIDTH__ 32
+// MIPS32EL:#define __UINTMAX_TYPE__ long long unsigned int
+// MIPS32EL:#define __USER_LABEL_PREFIX__ _
+// MIPS32EL:#define __WCHAR_MAX__ 2147483647
+// MIPS32EL:#define __WCHAR_TYPE__ int
+// MIPS32EL:#define __WCHAR_WIDTH__ 32
+// MIPS32EL:#define __WINT_TYPE__ int
+// MIPS32EL:#define __WINT_WIDTH__ 32
+// MIPS32EL:#define __clang__ 1
+// MIPS32EL:#define __llvm__ 1
+// MIPS32EL:#define __mips 1
+// MIPS32EL:#define __mips__ 1
+// MIPS32EL:#define __mips_hard_float 1
+// MIPS32EL:#define __mips_o32 1
+// MIPS32EL:#define _mips 1
+// MIPS32EL:#define mips 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-none-none < /dev/null | FileCheck -check-prefix MIPS64BE %s
+//
+// MIPS64BE:#define MIPSEB 1
+// MIPS64BE:#define _ABI64 3
+// MIPS64BE:#define _MIPSEB 1
+// MIPS64BE:#define _MIPS_SIM _ABI64
+// MIPS64BE:#define _MIPS_SZINT 32
+// MIPS64BE:#define _MIPS_SZLONG 64
+// MIPS64BE:#define _MIPS_SZPTR 64
+// MIPS64BE:#define __CHAR16_TYPE__ unsigned short
+// MIPS64BE:#define __CHAR32_TYPE__ unsigned int
+// MIPS64BE:#define __CHAR_BIT__ 8
+// MIPS64BE:#define __CONSTANT_CFSTRINGS__ 1
+// MIPS64BE:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS64BE:#define __DBL_DIG__ 15
+// MIPS64BE:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// MIPS64BE:#define __DBL_HAS_DENORM__ 1
+// MIPS64BE:#define __DBL_HAS_INFINITY__ 1
+// MIPS64BE:#define __DBL_HAS_QUIET_NAN__ 1
+// MIPS64BE:#define __DBL_MANT_DIG__ 53
+// MIPS64BE:#define __DBL_MAX_10_EXP__ 308
+// MIPS64BE:#define __DBL_MAX_EXP__ 1024
+// MIPS64BE:#define __DBL_MAX__ 1.7976931348623157e+308
+// MIPS64BE:#define __DBL_MIN_10_EXP__ (-307)
+// MIPS64BE:#define __DBL_MIN_EXP__ (-1021)
+// MIPS64BE:#define __DBL_MIN__ 2.2250738585072014e-308
+// MIPS64BE:#define __DECIMAL_DIG__ 36
+// MIPS64BE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// MIPS64BE:#define __FLT_DIG__ 6
+// MIPS64BE:#define __FLT_EPSILON__ 1.19209290e-7F
+// MIPS64BE:#define __FLT_EVAL_METHOD__ 0
+// MIPS64BE:#define __FLT_HAS_DENORM__ 1
+// MIPS64BE:#define __FLT_HAS_INFINITY__ 1
+// MIPS64BE:#define __FLT_HAS_QUIET_NAN__ 1
+// MIPS64BE:#define __FLT_MANT_DIG__ 24
+// MIPS64BE:#define __FLT_MAX_10_EXP__ 38
+// MIPS64BE:#define __FLT_MAX_EXP__ 128
+// MIPS64BE:#define __FLT_MAX__ 3.40282347e+38F
+// MIPS64BE:#define __FLT_MIN_10_EXP__ (-37)
+// MIPS64BE:#define __FLT_MIN_EXP__ (-125)
+// MIPS64BE:#define __FLT_MIN__ 1.17549435e-38F
+// MIPS64BE:#define __FLT_RADIX__ 2
+// MIPS64BE:#define __INT16_TYPE__ short
+// MIPS64BE:#define __INT32_TYPE__ int
+// MIPS64BE:#define __INT64_C_SUFFIX__ LL
+// MIPS64BE:#define __INT64_TYPE__ long long int
+// MIPS64BE:#define __INT8_TYPE__ char
+// MIPS64BE:#define __INTMAX_MAX__ 9223372036854775807LL
+// MIPS64BE:#define __INTMAX_TYPE__ long long int
+// MIPS64BE:#define __INTMAX_WIDTH__ 64
+// MIPS64BE:#define __INTPTR_TYPE__ long int
+// MIPS64BE:#define __INTPTR_WIDTH__ 64
+// MIPS64BE:#define __INT_MAX__ 2147483647
+// MIPS64BE:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
+// MIPS64BE:#define __LDBL_DIG__ 33
+// MIPS64BE:#define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L
+// MIPS64BE:#define __LDBL_HAS_DENORM__ 1
+// MIPS64BE:#define __LDBL_HAS_INFINITY__ 1
+// MIPS64BE:#define __LDBL_HAS_QUIET_NAN__ 1
+// MIPS64BE:#define __LDBL_MANT_DIG__ 113
+// MIPS64BE:#define __LDBL_MAX_10_EXP__ 4932
+// MIPS64BE:#define __LDBL_MAX_EXP__ 16384
+// MIPS64BE:#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L
+// MIPS64BE:#define __LDBL_MIN_10_EXP__ (-4931)
+// MIPS64BE:#define __LDBL_MIN_EXP__ (-16381)
+// MIPS64BE:#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
+// MIPS64BE:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// MIPS64BE:#define __LONG_MAX__ 9223372036854775807L
+// MIPS64BE:#define __MIPSEB 1
+// MIPS64BE:#define __MIPSEB__ 1
+// MIPS64BE:#define __NO_INLINE__ 1
+// MIPS64BE:#define __POINTER_WIDTH__ 64
+// MIPS64BE:#define __PRAGMA_REDEFINE_EXTNAME 1
+// MIPS64BE:#define __PTRDIFF_TYPE__ long int
+// MIPS64BE:#define __PTRDIFF_WIDTH__ 64
+// MIPS64BE:#define __REGISTER_PREFIX__
+// MIPS64BE:#define __SCHAR_MAX__ 127
+// MIPS64BE:#define __SHRT_MAX__ 32767
+// MIPS64BE:#define __SIG_ATOMIC_WIDTH__ 32
+// MIPS64BE:#define __SIZEOF_DOUBLE__ 8
+// MIPS64BE:#define __SIZEOF_FLOAT__ 4
+// MIPS64BE:#define __SIZEOF_INT__ 4
+// MIPS64BE:#define __SIZEOF_LONG_DOUBLE__ 16
+// MIPS64BE:#define __SIZEOF_LONG_LONG__ 8
+// MIPS64BE:#define __SIZEOF_LONG__ 8
+// MIPS64BE:#define __SIZEOF_POINTER__ 8
+// MIPS64BE:#define __SIZEOF_PTRDIFF_T__ 8
+// MIPS64BE:#define __SIZEOF_SHORT__ 2
+// MIPS64BE:#define __SIZEOF_SIZE_T__ 8
+// MIPS64BE:#define __SIZEOF_WCHAR_T__ 4
+// MIPS64BE:#define __SIZEOF_WINT_T__ 4
+// MIPS64BE:#define __SIZE_TYPE__ long unsigned int
+// MIPS64BE:#define __SIZE_WIDTH__ 64
+// MIPS64BE:#define __UINTMAX_TYPE__ long long unsigned int
+// MIPS64BE:#define __USER_LABEL_PREFIX__ _
+// MIPS64BE:#define __WCHAR_MAX__ 2147483647
+// MIPS64BE:#define __WCHAR_TYPE__ int
+// MIPS64BE:#define __WCHAR_WIDTH__ 32
+// MIPS64BE:#define __WINT_TYPE__ int
+// MIPS64BE:#define __WINT_WIDTH__ 32
+// MIPS64BE:#define __clang__ 1
+// MIPS64BE:#define __llvm__ 1
+// MIPS64BE:#define __mips 1
+// MIPS64BE:#define __mips__ 1
+// MIPS64BE:#define __mips_hard_float 1
+// MIPS64BE:#define __mips_n64 1
+// MIPS64BE:#define _mips 1
+// MIPS64BE:#define mips 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64el-none-none < /dev/null | FileCheck -check-prefix MIPS64EL %s
+//
+// MIPS64EL:#define MIPSEL 1
+// MIPS64EL:#define _ABI64 3
+// MIPS64EL:#define _MIPSEL 1
+// MIPS64EL:#define _MIPS_SIM _ABI64
+// MIPS64EL:#define _MIPS_SZINT 32
+// MIPS64EL:#define _MIPS_SZLONG 64
+// MIPS64EL:#define _MIPS_SZPTR 64
+// MIPS64EL:#define __CHAR16_TYPE__ unsigned short
+// MIPS64EL:#define __CHAR32_TYPE__ unsigned int
+// MIPS64EL:#define __CHAR_BIT__ 8
+// MIPS64EL:#define __CONSTANT_CFSTRINGS__ 1
+// MIPS64EL:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS64EL:#define __DBL_DIG__ 15
+// MIPS64EL:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// MIPS64EL:#define __DBL_HAS_DENORM__ 1
+// MIPS64EL:#define __DBL_HAS_INFINITY__ 1
+// MIPS64EL:#define __DBL_HAS_QUIET_NAN__ 1
+// MIPS64EL:#define __DBL_MANT_DIG__ 53
+// MIPS64EL:#define __DBL_MAX_10_EXP__ 308
+// MIPS64EL:#define __DBL_MAX_EXP__ 1024
+// MIPS64EL:#define __DBL_MAX__ 1.7976931348623157e+308
+// MIPS64EL:#define __DBL_MIN_10_EXP__ (-307)
+// MIPS64EL:#define __DBL_MIN_EXP__ (-1021)
+// MIPS64EL:#define __DBL_MIN__ 2.2250738585072014e-308
+// MIPS64EL:#define __DECIMAL_DIG__ 36
+// MIPS64EL:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// MIPS64EL:#define __FLT_DIG__ 6
+// MIPS64EL:#define __FLT_EPSILON__ 1.19209290e-7F
+// MIPS64EL:#define __FLT_EVAL_METHOD__ 0
+// MIPS64EL:#define __FLT_HAS_DENORM__ 1
+// MIPS64EL:#define __FLT_HAS_INFINITY__ 1
+// MIPS64EL:#define __FLT_HAS_QUIET_NAN__ 1
+// MIPS64EL:#define __FLT_MANT_DIG__ 24
+// MIPS64EL:#define __FLT_MAX_10_EXP__ 38
+// MIPS64EL:#define __FLT_MAX_EXP__ 128
+// MIPS64EL:#define __FLT_MAX__ 3.40282347e+38F
+// MIPS64EL:#define __FLT_MIN_10_EXP__ (-37)
+// MIPS64EL:#define __FLT_MIN_EXP__ (-125)
+// MIPS64EL:#define __FLT_MIN__ 1.17549435e-38F
+// MIPS64EL:#define __FLT_RADIX__ 2
+// MIPS64EL:#define __INT16_TYPE__ short
+// MIPS64EL:#define __INT32_TYPE__ int
+// MIPS64EL:#define __INT64_C_SUFFIX__ LL
+// MIPS64EL:#define __INT64_TYPE__ long long int
+// MIPS64EL:#define __INT8_TYPE__ char
+// MIPS64EL:#define __INTMAX_MAX__ 9223372036854775807LL
+// MIPS64EL:#define __INTMAX_TYPE__ long long int
+// MIPS64EL:#define __INTMAX_WIDTH__ 64
+// MIPS64EL:#define __INTPTR_TYPE__ long int
+// MIPS64EL:#define __INTPTR_WIDTH__ 64
+// MIPS64EL:#define __INT_MAX__ 2147483647
+// MIPS64EL:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
+// MIPS64EL:#define __LDBL_DIG__ 33
+// MIPS64EL:#define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L
+// MIPS64EL:#define __LDBL_HAS_DENORM__ 1
+// MIPS64EL:#define __LDBL_HAS_INFINITY__ 1
+// MIPS64EL:#define __LDBL_HAS_QUIET_NAN__ 1
+// MIPS64EL:#define __LDBL_MANT_DIG__ 113
+// MIPS64EL:#define __LDBL_MAX_10_EXP__ 4932
+// MIPS64EL:#define __LDBL_MAX_EXP__ 16384
+// MIPS64EL:#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L
+// MIPS64EL:#define __LDBL_MIN_10_EXP__ (-4931)
+// MIPS64EL:#define __LDBL_MIN_EXP__ (-16381)
+// MIPS64EL:#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
+// MIPS64EL:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// MIPS64EL:#define __LONG_MAX__ 9223372036854775807L
+// MIPS64EL:#define __MIPSEL 1
+// MIPS64EL:#define __MIPSEL__ 1
+// MIPS64EL:#define __NO_INLINE__ 1
+// MIPS64EL:#define __POINTER_WIDTH__ 64
+// MIPS64EL:#define __PRAGMA_REDEFINE_EXTNAME 1
+// MIPS64EL:#define __PTRDIFF_TYPE__ long int
+// MIPS64EL:#define __PTRDIFF_WIDTH__ 64
+// MIPS64EL:#define __REGISTER_PREFIX__
+// MIPS64EL:#define __SCHAR_MAX__ 127
+// MIPS64EL:#define __SHRT_MAX__ 32767
+// MIPS64EL:#define __SIG_ATOMIC_WIDTH__ 32
+// MIPS64EL:#define __SIZEOF_DOUBLE__ 8
+// MIPS64EL:#define __SIZEOF_FLOAT__ 4
+// MIPS64EL:#define __SIZEOF_INT__ 4
+// MIPS64EL:#define __SIZEOF_LONG_DOUBLE__ 16
+// MIPS64EL:#define __SIZEOF_LONG_LONG__ 8
+// MIPS64EL:#define __SIZEOF_LONG__ 8
+// MIPS64EL:#define __SIZEOF_POINTER__ 8
+// MIPS64EL:#define __SIZEOF_PTRDIFF_T__ 8
+// MIPS64EL:#define __SIZEOF_SHORT__ 2
+// MIPS64EL:#define __SIZEOF_SIZE_T__ 8
+// MIPS64EL:#define __SIZEOF_WCHAR_T__ 4
+// MIPS64EL:#define __SIZEOF_WINT_T__ 4
+// MIPS64EL:#define __SIZE_TYPE__ long unsigned int
+// MIPS64EL:#define __SIZE_WIDTH__ 64
+// MIPS64EL:#define __UINTMAX_TYPE__ long long unsigned int
+// MIPS64EL:#define __USER_LABEL_PREFIX__ _
+// MIPS64EL:#define __WCHAR_MAX__ 2147483647
+// MIPS64EL:#define __WCHAR_TYPE__ int
+// MIPS64EL:#define __WCHAR_WIDTH__ 32
+// MIPS64EL:#define __WINT_TYPE__ int
+// MIPS64EL:#define __WINT_WIDTH__ 32
+// MIPS64EL:#define __clang__ 1
+// MIPS64EL:#define __llvm__ 1
+// MIPS64EL:#define __mips 1
+// MIPS64EL:#define __mips__ 1
+// MIPS64EL:#define __mips_hard_float 1
+// MIPS64EL:#define __mips_n64 1
+// MIPS64EL:#define _mips 1
+// MIPS64EL:#define mips 1
+//
+// Check MIPS float ABI macros
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding \
+// RUN: -triple=mips-none-none < /dev/null \
+// RUN: | FileCheck -check-prefix MIPS-FABI-HARD %s
+// MIPS-FABI-HARD:#define __mips_hard_float 1
+//
+// RUN: %clang_cc1 -target-feature +soft-float -E -dM -ffreestanding \
+// RUN: -triple=mips-none-none < /dev/null \
+// RUN: | FileCheck -check-prefix MIPS-FABI-SOFT %s
+// MIPS-FABI-SOFT:#define __mips_soft_float 1
+//
+// RUN: %clang_cc1 -target-feature +single-float -E -dM -ffreestanding \
+// RUN: -triple=mips-none-none < /dev/null \
+// RUN: | FileCheck -check-prefix MIPS-FABI-SINGLE %s
+// MIPS-FABI-SINGLE:#define __mips_single_float 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=msp430-none-none < /dev/null | FileCheck -check-prefix MSP430 %s
+//
+// MSP430:#define MSP430 1
+// MSP430:#define __CHAR16_TYPE__ unsigned short
+// MSP430:#define __CHAR32_TYPE__ unsigned int
+// MSP430:#define __CHAR_BIT__ 8
+// MSP430:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// MSP430:#define __DBL_DIG__ 15
+// MSP430:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// MSP430:#define __DBL_HAS_DENORM__ 1
+// MSP430:#define __DBL_HAS_INFINITY__ 1
+// MSP430:#define __DBL_HAS_QUIET_NAN__ 1
+// MSP430:#define __DBL_MANT_DIG__ 53
+// MSP430:#define __DBL_MAX_10_EXP__ 308
+// MSP430:#define __DBL_MAX_EXP__ 1024
+// MSP430:#define __DBL_MAX__ 1.7976931348623157e+308
+// MSP430:#define __DBL_MIN_10_EXP__ (-307)
+// MSP430:#define __DBL_MIN_EXP__ (-1021)
+// MSP430:#define __DBL_MIN__ 2.2250738585072014e-308
+// MSP430:#define __DECIMAL_DIG__ 17
+// MSP430:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// MSP430:#define __FLT_DIG__ 6
+// MSP430:#define __FLT_EPSILON__ 1.19209290e-7F
+// MSP430:#define __FLT_EVAL_METHOD__ 0
+// MSP430:#define __FLT_HAS_DENORM__ 1
+// MSP430:#define __FLT_HAS_INFINITY__ 1
+// MSP430:#define __FLT_HAS_QUIET_NAN__ 1
+// MSP430:#define __FLT_MANT_DIG__ 24
+// MSP430:#define __FLT_MAX_10_EXP__ 38
+// MSP430:#define __FLT_MAX_EXP__ 128
+// MSP430:#define __FLT_MAX__ 3.40282347e+38F
+// MSP430:#define __FLT_MIN_10_EXP__ (-37)
+// MSP430:#define __FLT_MIN_EXP__ (-125)
+// MSP430:#define __FLT_MIN__ 1.17549435e-38F
+// MSP430:#define __FLT_RADIX__ 2
+// MSP430:#define __INT16_TYPE__ short
+// MSP430:#define __INT32_C_SUFFIX__ L
+// MSP430:#define __INT32_TYPE__ long int
+// MSP430:#define __INT8_TYPE__ char
+// MSP430:#define __INTMAX_MAX__ 2147483647L
+// MSP430:#define __INTMAX_TYPE__ long int
+// MSP430:#define __INTMAX_WIDTH__ 32
+// MSP430:#define __INTPTR_TYPE__ short
+// MSP430:#define __INTPTR_WIDTH__ 16
+// MSP430:#define __INT_MAX__ 32767
+// MSP430:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324
+// MSP430:#define __LDBL_DIG__ 15
+// MSP430:#define __LDBL_EPSILON__ 2.2204460492503131e-16
+// MSP430:#define __LDBL_HAS_DENORM__ 1
+// MSP430:#define __LDBL_HAS_INFINITY__ 1
+// MSP430:#define __LDBL_HAS_QUIET_NAN__ 1
+// MSP430:#define __LDBL_MANT_DIG__ 53
+// MSP430:#define __LDBL_MAX_10_EXP__ 308
+// MSP430:#define __LDBL_MAX_EXP__ 1024
+// MSP430:#define __LDBL_MAX__ 1.7976931348623157e+308
+// MSP430:#define __LDBL_MIN_10_EXP__ (-307)
+// MSP430:#define __LDBL_MIN_EXP__ (-1021)
+// MSP430:#define __LDBL_MIN__ 2.2250738585072014e-308
+// MSP430:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// MSP430:#define __LONG_MAX__ 2147483647L
+// MSP430:#define __MSP430__ 1
+// MSP430:#define __NO_INLINE__ 1
+// MSP430:#define __POINTER_WIDTH__ 16
+// MSP430:#define __PTRDIFF_TYPE__ int
+// MSP430:#define __PTRDIFF_WIDTH__ 16
+// MSP430:#define __SCHAR_MAX__ 127
+// MSP430:#define __SHRT_MAX__ 32767
+// MSP430:#define __SIG_ATOMIC_WIDTH__ 32
+// MSP430:#define __SIZEOF_DOUBLE__ 8
+// MSP430:#define __SIZEOF_FLOAT__ 4
+// MSP430:#define __SIZEOF_INT__ 2
+// MSP430:#define __SIZEOF_LONG_DOUBLE__ 8
+// MSP430:#define __SIZEOF_LONG_LONG__ 8
+// MSP430:#define __SIZEOF_LONG__ 4
+// MSP430:#define __SIZEOF_POINTER__ 2
+// MSP430:#define __SIZEOF_PTRDIFF_T__ 2
+// MSP430:#define __SIZEOF_SHORT__ 2
+// MSP430:#define __SIZEOF_SIZE_T__ 2
+// MSP430:#define __SIZEOF_WCHAR_T__ 2
+// MSP430:#define __SIZEOF_WINT_T__ 2
+// MSP430:#define __SIZE_TYPE__ unsigned int
+// MSP430:#define __SIZE_WIDTH__ 16
+// MSP430:#define __UINTMAX_TYPE__ long unsigned int
+// MSP430:#define __USER_LABEL_PREFIX__ _
+// MSP430:#define __WCHAR_MAX__ 32767
+// MSP430:#define __WCHAR_TYPE__ int
+// MSP430:#define __WCHAR_WIDTH__ 16
+// MSP430:#define __WINT_TYPE__ int
+// MSP430:#define __WINT_WIDTH__ 16
+// MSP430:#define __clang__ 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -fno-signed-char < /dev/null | FileCheck -check-prefix PPC64 %s
+//
+// PPC64:#define _ARCH_PPC 1
+// PPC64:#define _ARCH_PPC64 1
+// PPC64:#define _BIG_ENDIAN 1
+// PPC64:#define _LP64 1
+// PPC64:#define __BIG_ENDIAN__ 1
+// PPC64:#define __CHAR16_TYPE__ unsigned short
+// PPC64:#define __CHAR32_TYPE__ unsigned int
+// PPC64:#define __CHAR_BIT__ 8
+// PPC64:#define __CHAR_UNSIGNED__ 1
+// PPC64:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// PPC64:#define __DBL_DIG__ 15
+// PPC64:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// PPC64:#define __DBL_HAS_DENORM__ 1
+// PPC64:#define __DBL_HAS_INFINITY__ 1
+// PPC64:#define __DBL_HAS_QUIET_NAN__ 1
+// PPC64:#define __DBL_MANT_DIG__ 53
+// PPC64:#define __DBL_MAX_10_EXP__ 308
+// PPC64:#define __DBL_MAX_EXP__ 1024
+// PPC64:#define __DBL_MAX__ 1.7976931348623157e+308
+// PPC64:#define __DBL_MIN_10_EXP__ (-307)
+// PPC64:#define __DBL_MIN_EXP__ (-1021)
+// PPC64:#define __DBL_MIN__ 2.2250738585072014e-308
+// PPC64:#define __DECIMAL_DIG__ 33
+// PPC64:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// PPC64:#define __FLT_DIG__ 6
+// PPC64:#define __FLT_EPSILON__ 1.19209290e-7F
+// PPC64:#define __FLT_EVAL_METHOD__ 0
+// PPC64:#define __FLT_HAS_DENORM__ 1
+// PPC64:#define __FLT_HAS_INFINITY__ 1
+// PPC64:#define __FLT_HAS_QUIET_NAN__ 1
+// PPC64:#define __FLT_MANT_DIG__ 24
+// PPC64:#define __FLT_MAX_10_EXP__ 38
+// PPC64:#define __FLT_MAX_EXP__ 128
+// PPC64:#define __FLT_MAX__ 3.40282347e+38F
+// PPC64:#define __FLT_MIN_10_EXP__ (-37)
+// PPC64:#define __FLT_MIN_EXP__ (-125)
+// PPC64:#define __FLT_MIN__ 1.17549435e-38F
+// PPC64:#define __FLT_RADIX__ 2
+// PPC64:#define __INT16_TYPE__ short
+// PPC64:#define __INT32_TYPE__ int
+// PPC64:#define __INT64_C_SUFFIX__ L
+// PPC64:#define __INT64_TYPE__ long int
+// PPC64:#define __INT8_TYPE__ char
+// PPC64:#define __INTMAX_MAX__ 9223372036854775807L
+// PPC64:#define __INTMAX_TYPE__ long int
+// PPC64:#define __INTMAX_WIDTH__ 64
+// PPC64:#define __INTPTR_TYPE__ long int
+// PPC64:#define __INTPTR_WIDTH__ 64
+// PPC64:#define __INT_MAX__ 2147483647
+// PPC64:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+// PPC64:#define __LDBL_DIG__ 31
+// PPC64:#define __LDBL_EPSILON__ 4.94065645841246544176568792868221e-324L
+// PPC64:#define __LDBL_HAS_DENORM__ 1
+// PPC64:#define __LDBL_HAS_INFINITY__ 1
+// PPC64:#define __LDBL_HAS_QUIET_NAN__ 1
+// PPC64:#define __LDBL_MANT_DIG__ 106
+// PPC64:#define __LDBL_MAX_10_EXP__ 308
+// PPC64:#define __LDBL_MAX_EXP__ 1024
+// PPC64:#define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L
+// PPC64:#define __LDBL_MIN_10_EXP__ (-291)
+// PPC64:#define __LDBL_MIN_EXP__ (-968)
+// PPC64:#define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L
+// PPC64:#define __LONG_DOUBLE_128__ 1
+// PPC64:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// PPC64:#define __LONG_MAX__ 9223372036854775807L
+// PPC64:#define __LP64__ 1
+// PPC64:#define __NATURAL_ALIGNMENT__ 1
+// PPC64:#define __NO_INLINE__ 1
+// PPC64:#define __POINTER_WIDTH__ 64
+// PPC64:#define __POWERPC__ 1
+// PPC64:#define __PTRDIFF_TYPE__ long int
+// PPC64:#define __PTRDIFF_WIDTH__ 64
+// PPC64:#define __REGISTER_PREFIX__
+// PPC64:#define __SCHAR_MAX__ 127
+// PPC64:#define __SHRT_MAX__ 32767
+// PPC64:#define __SIG_ATOMIC_WIDTH__ 32
+// PPC64:#define __SIZEOF_DOUBLE__ 8
+// PPC64:#define __SIZEOF_FLOAT__ 4
+// PPC64:#define __SIZEOF_INT__ 4
+// PPC64:#define __SIZEOF_LONG_DOUBLE__ 16
+// PPC64:#define __SIZEOF_LONG_LONG__ 8
+// PPC64:#define __SIZEOF_LONG__ 8
+// PPC64:#define __SIZEOF_POINTER__ 8
+// PPC64:#define __SIZEOF_PTRDIFF_T__ 8
+// PPC64:#define __SIZEOF_SHORT__ 2
+// PPC64:#define __SIZEOF_SIZE_T__ 8
+// PPC64:#define __SIZEOF_WCHAR_T__ 4
+// PPC64:#define __SIZEOF_WINT_T__ 4
+// PPC64:#define __SIZE_TYPE__ long unsigned int
+// PPC64:#define __SIZE_WIDTH__ 64
+// PPC64:#define __UINTMAX_TYPE__ long unsigned int
+// PPC64:#define __USER_LABEL_PREFIX__ _
+// PPC64:#define __WCHAR_MAX__ 2147483647
+// PPC64:#define __WCHAR_TYPE__ int
+// PPC64:#define __WCHAR_WIDTH__ 32
+// PPC64:#define __WINT_TYPE__ int
+// PPC64:#define __WINT_WIDTH__ 32
+// PPC64:#define __ppc64__ 1
+// PPC64:#define __ppc__ 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-linux-gnu -fno-signed-char < /dev/null | FileCheck -check-prefix PPC64-LINUX %s
+//
+// PPC64-LINUX:#define _ARCH_PPC 1
+// PPC64-LINUX:#define _ARCH_PPC64 1
+// PPC64-LINUX:#define _BIG_ENDIAN 1
+// PPC64-LINUX:#define _LP64 1
+// PPC64-LINUX:#define __BIG_ENDIAN__ 1
+// PPC64-LINUX:#define __CHAR16_TYPE__ unsigned short
+// PPC64-LINUX:#define __CHAR32_TYPE__ unsigned int
+// PPC64-LINUX:#define __CHAR_BIT__ 8
+// PPC64-LINUX:#define __CHAR_UNSIGNED__ 1
+// PPC64-LINUX:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// PPC64-LINUX:#define __DBL_DIG__ 15
+// PPC64-LINUX:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// PPC64-LINUX:#define __DBL_HAS_DENORM__ 1
+// PPC64-LINUX:#define __DBL_HAS_INFINITY__ 1
+// PPC64-LINUX:#define __DBL_HAS_QUIET_NAN__ 1
+// PPC64-LINUX:#define __DBL_MANT_DIG__ 53
+// PPC64-LINUX:#define __DBL_MAX_10_EXP__ 308
+// PPC64-LINUX:#define __DBL_MAX_EXP__ 1024
+// PPC64-LINUX:#define __DBL_MAX__ 1.7976931348623157e+308
+// PPC64-LINUX:#define __DBL_MIN_10_EXP__ (-307)
+// PPC64-LINUX:#define __DBL_MIN_EXP__ (-1021)
+// PPC64-LINUX:#define __DBL_MIN__ 2.2250738585072014e-308
+// PPC64-LINUX:#define __DECIMAL_DIG__ 33
+// PPC64-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// PPC64-LINUX:#define __FLT_DIG__ 6
+// PPC64-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F
+// PPC64-LINUX:#define __FLT_EVAL_METHOD__ 0
+// PPC64-LINUX:#define __FLT_HAS_DENORM__ 1
+// PPC64-LINUX:#define __FLT_HAS_INFINITY__ 1
+// PPC64-LINUX:#define __FLT_HAS_QUIET_NAN__ 1
+// PPC64-LINUX:#define __FLT_MANT_DIG__ 24
+// PPC64-LINUX:#define __FLT_MAX_10_EXP__ 38
+// PPC64-LINUX:#define __FLT_MAX_EXP__ 128
+// PPC64-LINUX:#define __FLT_MAX__ 3.40282347e+38F
+// PPC64-LINUX:#define __FLT_MIN_10_EXP__ (-37)
+// PPC64-LINUX:#define __FLT_MIN_EXP__ (-125)
+// PPC64-LINUX:#define __FLT_MIN__ 1.17549435e-38F
+// PPC64-LINUX:#define __FLT_RADIX__ 2
+// PPC64-LINUX:#define __INT16_TYPE__ short
+// PPC64-LINUX:#define __INT32_TYPE__ int
+// PPC64-LINUX:#define __INT64_C_SUFFIX__ L
+// PPC64-LINUX:#define __INT64_TYPE__ long int
+// PPC64-LINUX:#define __INT8_TYPE__ char
+// PPC64-LINUX:#define __INTMAX_MAX__ 9223372036854775807L
+// PPC64-LINUX:#define __INTMAX_TYPE__ long int
+// PPC64-LINUX:#define __INTMAX_WIDTH__ 64
+// PPC64-LINUX:#define __INTPTR_TYPE__ long int
+// PPC64-LINUX:#define __INTPTR_WIDTH__ 64
+// PPC64-LINUX:#define __INT_MAX__ 2147483647
+// PPC64-LINUX:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+// PPC64-LINUX:#define __LDBL_DIG__ 31
+// PPC64-LINUX:#define __LDBL_EPSILON__ 4.94065645841246544176568792868221e-324L
+// PPC64-LINUX:#define __LDBL_HAS_DENORM__ 1
+// PPC64-LINUX:#define __LDBL_HAS_INFINITY__ 1
+// PPC64-LINUX:#define __LDBL_HAS_QUIET_NAN__ 1
+// PPC64-LINUX:#define __LDBL_MANT_DIG__ 106
+// PPC64-LINUX:#define __LDBL_MAX_10_EXP__ 308
+// PPC64-LINUX:#define __LDBL_MAX_EXP__ 1024
+// PPC64-LINUX:#define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L
+// PPC64-LINUX:#define __LDBL_MIN_10_EXP__ (-291)
+// PPC64-LINUX:#define __LDBL_MIN_EXP__ (-968)
+// PPC64-LINUX:#define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L
+// PPC64-LINUX:#define __LONG_DOUBLE_128__ 1
+// PPC64-LINUX:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// PPC64-LINUX:#define __LONG_MAX__ 9223372036854775807L
+// PPC64-LINUX:#define __LP64__ 1
+// PPC64-LINUX:#define __NATURAL_ALIGNMENT__ 1
+// PPC64-LINUX:#define __NO_INLINE__ 1
+// PPC64-LINUX:#define __POINTER_WIDTH__ 64
+// PPC64-LINUX:#define __POWERPC__ 1
+// PPC64-LINUX:#define __PTRDIFF_TYPE__ long int
+// PPC64-LINUX:#define __PTRDIFF_WIDTH__ 64
+// PPC64-LINUX:#define __REGISTER_PREFIX__
+// PPC64-LINUX:#define __SCHAR_MAX__ 127
+// PPC64-LINUX:#define __SHRT_MAX__ 32767
+// PPC64-LINUX:#define __SIG_ATOMIC_WIDTH__ 32
+// PPC64-LINUX:#define __SIZEOF_DOUBLE__ 8
+// PPC64-LINUX:#define __SIZEOF_FLOAT__ 4
+// PPC64-LINUX:#define __SIZEOF_INT__ 4
+// PPC64-LINUX:#define __SIZEOF_LONG_DOUBLE__ 16
+// PPC64-LINUX:#define __SIZEOF_LONG_LONG__ 8
+// PPC64-LINUX:#define __SIZEOF_LONG__ 8
+// PPC64-LINUX:#define __SIZEOF_POINTER__ 8
+// PPC64-LINUX:#define __SIZEOF_PTRDIFF_T__ 8
+// PPC64-LINUX:#define __SIZEOF_SHORT__ 2
+// PPC64-LINUX:#define __SIZEOF_SIZE_T__ 8
+// PPC64-LINUX:#define __SIZEOF_WCHAR_T__ 4
+// PPC64-LINUX:#define __SIZEOF_WINT_T__ 4
+// PPC64-LINUX:#define __SIZE_TYPE__ long unsigned int
+// PPC64-LINUX:#define __SIZE_WIDTH__ 64
+// PPC64-LINUX:#define __UINTMAX_TYPE__ long unsigned int
+// PPC64-LINUX:#define __USER_LABEL_PREFIX__
+// PPC64-LINUX:#define __WCHAR_MAX__ 2147483647
+// PPC64-LINUX:#define __WCHAR_TYPE__ int
+// PPC64-LINUX:#define __WCHAR_WIDTH__ 32
+// PPC64-LINUX:#define __WINT_TYPE__ unsigned int
+// PPC64-LINUX:#define __WINT_UNSIGNED__ 1
+// PPC64-LINUX:#define __WINT_WIDTH__ 32
+// PPC64-LINUX:#define __powerpc64__ 1
+// PPC64-LINUX:#define __powerpc__ 1
+// PPC64-LINUX:#define __ppc64__ 1
+// PPC64-LINUX:#define __ppc__ 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-none-none -fno-signed-char < /dev/null | FileCheck -check-prefix PPC %s
+//
+// PPC:#define _ARCH_PPC 1
+// PPC:#define _BIG_ENDIAN 1
+// PPC:#define __BIG_ENDIAN__ 1
+// PPC:#define __CHAR16_TYPE__ unsigned short
+// PPC:#define __CHAR32_TYPE__ unsigned int
+// PPC:#define __CHAR_BIT__ 8
+// PPC:#define __CHAR_UNSIGNED__ 1
+// PPC:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// PPC:#define __DBL_DIG__ 15
+// PPC:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// PPC:#define __DBL_HAS_DENORM__ 1
+// PPC:#define __DBL_HAS_INFINITY__ 1
+// PPC:#define __DBL_HAS_QUIET_NAN__ 1
+// PPC:#define __DBL_MANT_DIG__ 53
+// PPC:#define __DBL_MAX_10_EXP__ 308
+// PPC:#define __DBL_MAX_EXP__ 1024
+// PPC:#define __DBL_MAX__ 1.7976931348623157e+308
+// PPC:#define __DBL_MIN_10_EXP__ (-307)
+// PPC:#define __DBL_MIN_EXP__ (-1021)
+// PPC:#define __DBL_MIN__ 2.2250738585072014e-308
+// PPC:#define __DECIMAL_DIG__ 33
+// PPC:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// PPC:#define __FLT_DIG__ 6
+// PPC:#define __FLT_EPSILON__ 1.19209290e-7F
+// PPC:#define __FLT_EVAL_METHOD__ 0
+// PPC:#define __FLT_HAS_DENORM__ 1
+// PPC:#define __FLT_HAS_INFINITY__ 1
+// PPC:#define __FLT_HAS_QUIET_NAN__ 1
+// PPC:#define __FLT_MANT_DIG__ 24
+// PPC:#define __FLT_MAX_10_EXP__ 38
+// PPC:#define __FLT_MAX_EXP__ 128
+// PPC:#define __FLT_MAX__ 3.40282347e+38F
+// PPC:#define __FLT_MIN_10_EXP__ (-37)
+// PPC:#define __FLT_MIN_EXP__ (-125)
+// PPC:#define __FLT_MIN__ 1.17549435e-38F
+// PPC:#define __FLT_RADIX__ 2
+// PPC:#define __INT16_TYPE__ short
+// PPC:#define __INT32_TYPE__ int
+// PPC:#define __INT64_C_SUFFIX__ LL
+// PPC:#define __INT64_TYPE__ long long int
+// PPC:#define __INT8_TYPE__ char
+// PPC:#define __INTMAX_MAX__ 9223372036854775807LL
+// PPC:#define __INTMAX_TYPE__ long long int
+// PPC:#define __INTMAX_WIDTH__ 64
+// PPC:#define __INTPTR_TYPE__ long int
+// PPC:#define __INTPTR_WIDTH__ 32
+// PPC:#define __INT_MAX__ 2147483647
+// PPC:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+// PPC:#define __LDBL_DIG__ 31
+// PPC:#define __LDBL_EPSILON__ 4.94065645841246544176568792868221e-324L
+// PPC:#define __LDBL_HAS_DENORM__ 1
+// PPC:#define __LDBL_HAS_INFINITY__ 1
+// PPC:#define __LDBL_HAS_QUIET_NAN__ 1
+// PPC:#define __LDBL_MANT_DIG__ 106
+// PPC:#define __LDBL_MAX_10_EXP__ 308
+// PPC:#define __LDBL_MAX_EXP__ 1024
+// PPC:#define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L
+// PPC:#define __LDBL_MIN_10_EXP__ (-291)
+// PPC:#define __LDBL_MIN_EXP__ (-968)
+// PPC:#define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L
+// PPC:#define __LONG_DOUBLE_128__ 1
+// PPC:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// PPC:#define __LONG_MAX__ 2147483647L
+// PPC:#define __NATURAL_ALIGNMENT__ 1
+// PPC:#define __NO_INLINE__ 1
+// PPC:#define __POINTER_WIDTH__ 32
+// PPC:#define __POWERPC__ 1
+// PPC:#define __PTRDIFF_TYPE__ long int
+// PPC:#define __PTRDIFF_WIDTH__ 32
+// PPC:#define __REGISTER_PREFIX__
+// PPC:#define __SCHAR_MAX__ 127
+// PPC:#define __SHRT_MAX__ 32767
+// PPC:#define __SIG_ATOMIC_WIDTH__ 32
+// PPC:#define __SIZEOF_DOUBLE__ 8
+// PPC:#define __SIZEOF_FLOAT__ 4
+// PPC:#define __SIZEOF_INT__ 4
+// PPC:#define __SIZEOF_LONG_DOUBLE__ 16
+// PPC:#define __SIZEOF_LONG_LONG__ 8
+// PPC:#define __SIZEOF_LONG__ 4
+// PPC:#define __SIZEOF_POINTER__ 4
+// PPC:#define __SIZEOF_PTRDIFF_T__ 4
+// PPC:#define __SIZEOF_SHORT__ 2
+// PPC:#define __SIZEOF_SIZE_T__ 4
+// PPC:#define __SIZEOF_WCHAR_T__ 4
+// PPC:#define __SIZEOF_WINT_T__ 4
+// PPC:#define __SIZE_TYPE__ long unsigned int
+// PPC:#define __SIZE_WIDTH__ 32
+// PPC:#define __UINTMAX_TYPE__ long long unsigned int
+// PPC:#define __USER_LABEL_PREFIX__ _
+// PPC:#define __WCHAR_MAX__ 2147483647
+// PPC:#define __WCHAR_TYPE__ int
+// PPC:#define __WCHAR_WIDTH__ 32
+// PPC:#define __WINT_TYPE__ int
+// PPC:#define __WINT_WIDTH__ 32
+// PPC:#define __ppc__ 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-linux-gnu -fno-signed-char < /dev/null | FileCheck -check-prefix PPC-LINUX %s
+//
+// PPC-LINUX:#define _ARCH_PPC 1
+// PPC-LINUX:#define _BIG_ENDIAN 1
+// PPC-LINUX:#define __BIG_ENDIAN__ 1
+// PPC-LINUX:#define __CHAR16_TYPE__ unsigned short
+// PPC-LINUX:#define __CHAR32_TYPE__ unsigned int
+// PPC-LINUX:#define __CHAR_BIT__ 8
+// PPC-LINUX:#define __CHAR_UNSIGNED__ 1
+// PPC-LINUX:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// PPC-LINUX:#define __DBL_DIG__ 15
+// PPC-LINUX:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// PPC-LINUX:#define __DBL_HAS_DENORM__ 1
+// PPC-LINUX:#define __DBL_HAS_INFINITY__ 1
+// PPC-LINUX:#define __DBL_HAS_QUIET_NAN__ 1
+// PPC-LINUX:#define __DBL_MANT_DIG__ 53
+// PPC-LINUX:#define __DBL_MAX_10_EXP__ 308
+// PPC-LINUX:#define __DBL_MAX_EXP__ 1024
+// PPC-LINUX:#define __DBL_MAX__ 1.7976931348623157e+308
+// PPC-LINUX:#define __DBL_MIN_10_EXP__ (-307)
+// PPC-LINUX:#define __DBL_MIN_EXP__ (-1021)
+// PPC-LINUX:#define __DBL_MIN__ 2.2250738585072014e-308
+// PPC-LINUX:#define __DECIMAL_DIG__ 33
+// PPC-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// PPC-LINUX:#define __FLT_DIG__ 6
+// PPC-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F
+// PPC-LINUX:#define __FLT_EVAL_METHOD__ 0
+// PPC-LINUX:#define __FLT_HAS_DENORM__ 1
+// PPC-LINUX:#define __FLT_HAS_INFINITY__ 1
+// PPC-LINUX:#define __FLT_HAS_QUIET_NAN__ 1
+// PPC-LINUX:#define __FLT_MANT_DIG__ 24
+// PPC-LINUX:#define __FLT_MAX_10_EXP__ 38
+// PPC-LINUX:#define __FLT_MAX_EXP__ 128
+// PPC-LINUX:#define __FLT_MAX__ 3.40282347e+38F
+// PPC-LINUX:#define __FLT_MIN_10_EXP__ (-37)
+// PPC-LINUX:#define __FLT_MIN_EXP__ (-125)
+// PPC-LINUX:#define __FLT_MIN__ 1.17549435e-38F
+// PPC-LINUX:#define __FLT_RADIX__ 2
+// PPC-LINUX:#define __INT16_TYPE__ short
+// PPC-LINUX:#define __INT32_TYPE__ int
+// PPC-LINUX:#define __INT64_C_SUFFIX__ LL
+// PPC-LINUX:#define __INT64_TYPE__ long long int
+// PPC-LINUX:#define __INT8_TYPE__ char
+// PPC-LINUX:#define __INTMAX_MAX__ 9223372036854775807LL
+// PPC-LINUX:#define __INTMAX_TYPE__ long long int
+// PPC-LINUX:#define __INTMAX_WIDTH__ 64
+// PPC-LINUX:#define __INTPTR_TYPE__ int
+// PPC-LINUX:#define __INTPTR_WIDTH__ 32
+// PPC-LINUX:#define __INT_MAX__ 2147483647
+// PPC-LINUX:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+// PPC-LINUX:#define __LDBL_DIG__ 31
+// PPC-LINUX:#define __LDBL_EPSILON__ 4.94065645841246544176568792868221e-324L
+// PPC-LINUX:#define __LDBL_HAS_DENORM__ 1
+// PPC-LINUX:#define __LDBL_HAS_INFINITY__ 1
+// PPC-LINUX:#define __LDBL_HAS_QUIET_NAN__ 1
+// PPC-LINUX:#define __LDBL_MANT_DIG__ 106
+// PPC-LINUX:#define __LDBL_MAX_10_EXP__ 308
+// PPC-LINUX:#define __LDBL_MAX_EXP__ 1024
+// PPC-LINUX:#define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L
+// PPC-LINUX:#define __LDBL_MIN_10_EXP__ (-291)
+// PPC-LINUX:#define __LDBL_MIN_EXP__ (-968)
+// PPC-LINUX:#define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L
+// PPC-LINUX:#define __LONG_DOUBLE_128__ 1
+// PPC-LINUX:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// PPC-LINUX:#define __LONG_MAX__ 2147483647L
+// PPC-LINUX:#define __NATURAL_ALIGNMENT__ 1
+// PPC-LINUX:#define __NO_INLINE__ 1
+// PPC-LINUX:#define __POINTER_WIDTH__ 32
+// PPC-LINUX:#define __POWERPC__ 1
+// PPC-LINUX:#define __PTRDIFF_TYPE__ int
+// PPC-LINUX:#define __PTRDIFF_WIDTH__ 32
+// PPC-LINUX:#define __REGISTER_PREFIX__
+// PPC-LINUX:#define __SCHAR_MAX__ 127
+// PPC-LINUX:#define __SHRT_MAX__ 32767
+// PPC-LINUX:#define __SIG_ATOMIC_WIDTH__ 32
+// PPC-LINUX:#define __SIZEOF_DOUBLE__ 8
+// PPC-LINUX:#define __SIZEOF_FLOAT__ 4
+// PPC-LINUX:#define __SIZEOF_INT__ 4
+// PPC-LINUX:#define __SIZEOF_LONG_DOUBLE__ 16
+// PPC-LINUX:#define __SIZEOF_LONG_LONG__ 8
+// PPC-LINUX:#define __SIZEOF_LONG__ 4
+// PPC-LINUX:#define __SIZEOF_POINTER__ 4
+// PPC-LINUX:#define __SIZEOF_PTRDIFF_T__ 4
+// PPC-LINUX:#define __SIZEOF_SHORT__ 2
+// PPC-LINUX:#define __SIZEOF_SIZE_T__ 4
+// PPC-LINUX:#define __SIZEOF_WCHAR_T__ 4
+// PPC-LINUX:#define __SIZEOF_WINT_T__ 4
+// PPC-LINUX:#define __SIZE_TYPE__ unsigned int
+// PPC-LINUX:#define __SIZE_WIDTH__ 32
+// PPC-LINUX:#define __UINTMAX_TYPE__ long long unsigned int
+// PPC-LINUX:#define __USER_LABEL_PREFIX__
+// PPC-LINUX:#define __WCHAR_MAX__ 2147483647
+// PPC-LINUX:#define __WCHAR_TYPE__ int
+// PPC-LINUX:#define __WCHAR_WIDTH__ 32
+// PPC-LINUX:#define __WINT_TYPE__ unsigned int
+// PPC-LINUX:#define __WINT_UNSIGNED__ 1
+// PPC-LINUX:#define __WINT_WIDTH__ 32
+// PPC-LINUX:#define __powerpc__ 1
+// PPC-LINUX:#define __ppc__ 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-none-none < /dev/null | FileCheck -check-prefix SPARC %s
+//
+// SPARC:#define __CHAR16_TYPE__ unsigned short
+// SPARC:#define __CHAR32_TYPE__ unsigned int
+// SPARC:#define __CHAR_BIT__ 8
+// SPARC:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// SPARC:#define __DBL_DIG__ 15
+// SPARC:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// SPARC:#define __DBL_HAS_DENORM__ 1
+// SPARC:#define __DBL_HAS_INFINITY__ 1
+// SPARC:#define __DBL_HAS_QUIET_NAN__ 1
+// SPARC:#define __DBL_MANT_DIG__ 53
+// SPARC:#define __DBL_MAX_10_EXP__ 308
+// SPARC:#define __DBL_MAX_EXP__ 1024
+// SPARC:#define __DBL_MAX__ 1.7976931348623157e+308
+// SPARC:#define __DBL_MIN_10_EXP__ (-307)
+// SPARC:#define __DBL_MIN_EXP__ (-1021)
+// SPARC:#define __DBL_MIN__ 2.2250738585072014e-308
+// SPARC:#define __DECIMAL_DIG__ 17
+// SPARC:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// SPARC:#define __FLT_DIG__ 6
+// SPARC:#define __FLT_EPSILON__ 1.19209290e-7F
+// SPARC:#define __FLT_EVAL_METHOD__ 0
+// SPARC:#define __FLT_HAS_DENORM__ 1
+// SPARC:#define __FLT_HAS_INFINITY__ 1
+// SPARC:#define __FLT_HAS_QUIET_NAN__ 1
+// SPARC:#define __FLT_MANT_DIG__ 24
+// SPARC:#define __FLT_MAX_10_EXP__ 38
+// SPARC:#define __FLT_MAX_EXP__ 128
+// SPARC:#define __FLT_MAX__ 3.40282347e+38F
+// SPARC:#define __FLT_MIN_10_EXP__ (-37)
+// SPARC:#define __FLT_MIN_EXP__ (-125)
+// SPARC:#define __FLT_MIN__ 1.17549435e-38F
+// SPARC:#define __FLT_RADIX__ 2
+// SPARC:#define __INT16_TYPE__ short
+// SPARC:#define __INT32_TYPE__ int
+// SPARC:#define __INT64_C_SUFFIX__ LL
+// SPARC:#define __INT64_TYPE__ long long int
+// SPARC:#define __INT8_TYPE__ char
+// SPARC:#define __INTMAX_MAX__ 9223372036854775807LL
+// SPARC:#define __INTMAX_TYPE__ long long int
+// SPARC:#define __INTMAX_WIDTH__ 64
+// SPARC:#define __INTPTR_TYPE__ long int
+// SPARC:#define __INTPTR_WIDTH__ 32
+// SPARC:#define __INT_MAX__ 2147483647
+// SPARC:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324
+// SPARC:#define __LDBL_DIG__ 15
+// SPARC:#define __LDBL_EPSILON__ 2.2204460492503131e-16
+// SPARC:#define __LDBL_HAS_DENORM__ 1
+// SPARC:#define __LDBL_HAS_INFINITY__ 1
+// SPARC:#define __LDBL_HAS_QUIET_NAN__ 1
+// SPARC:#define __LDBL_MANT_DIG__ 53
+// SPARC:#define __LDBL_MAX_10_EXP__ 308
+// SPARC:#define __LDBL_MAX_EXP__ 1024
+// SPARC:#define __LDBL_MAX__ 1.7976931348623157e+308
+// SPARC:#define __LDBL_MIN_10_EXP__ (-307)
+// SPARC:#define __LDBL_MIN_EXP__ (-1021)
+// SPARC:#define __LDBL_MIN__ 2.2250738585072014e-308
+// SPARC:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// SPARC:#define __LONG_MAX__ 2147483647L
+// SPARC:#define __NO_INLINE__ 1
+// SPARC:#define __POINTER_WIDTH__ 32
+// SPARC:#define __PTRDIFF_TYPE__ long int
+// SPARC:#define __PTRDIFF_WIDTH__ 32
+// SPARC:#define __REGISTER_PREFIX__
+// SPARC:#define __SCHAR_MAX__ 127
+// SPARC:#define __SHRT_MAX__ 32767
+// SPARC:#define __SIG_ATOMIC_WIDTH__ 32
+// SPARC:#define __SIZEOF_DOUBLE__ 8
+// SPARC:#define __SIZEOF_FLOAT__ 4
+// SPARC:#define __SIZEOF_INT__ 4
+// SPARC:#define __SIZEOF_LONG_DOUBLE__ 8
+// SPARC:#define __SIZEOF_LONG_LONG__ 8
+// SPARC:#define __SIZEOF_LONG__ 4
+// SPARC:#define __SIZEOF_POINTER__ 4
+// SPARC:#define __SIZEOF_PTRDIFF_T__ 4
+// SPARC:#define __SIZEOF_SHORT__ 2
+// SPARC:#define __SIZEOF_SIZE_T__ 4
+// SPARC:#define __SIZEOF_WCHAR_T__ 4
+// SPARC:#define __SIZEOF_WINT_T__ 4
+// SPARC:#define __SIZE_TYPE__ long unsigned int
+// SPARC:#define __SIZE_WIDTH__ 32
+// SPARC:#define __UINTMAX_TYPE__ long long unsigned int
+// SPARC:#define __USER_LABEL_PREFIX__ _
+// SPARC:#define __VERSION__ "4.2.1 Compatible
+// SPARC:#define __WCHAR_MAX__ 2147483647
+// SPARC:#define __WCHAR_TYPE__ int
+// SPARC:#define __WCHAR_WIDTH__ 32
+// SPARC:#define __WINT_TYPE__ int
+// SPARC:#define __WINT_WIDTH__ 32
+// SPARC:#define __sparc 1
+// SPARC:#define __sparc__ 1
+// SPARC:#define __sparcv8 1
+// SPARC:#define sparc 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=tce-none-none < /dev/null | FileCheck -check-prefix TCE %s
+//
+// TCE:#define __CHAR16_TYPE__ unsigned short
+// TCE:#define __CHAR32_TYPE__ unsigned int
+// TCE:#define __CHAR_BIT__ 8
+// TCE:#define __DBL_DENORM_MIN__ 1.40129846e-45F
+// TCE:#define __DBL_DIG__ 6
+// TCE:#define __DBL_EPSILON__ 1.19209290e-7F
+// TCE:#define __DBL_HAS_DENORM__ 1
+// TCE:#define __DBL_HAS_INFINITY__ 1
+// TCE:#define __DBL_HAS_QUIET_NAN__ 1
+// TCE:#define __DBL_MANT_DIG__ 24
+// TCE:#define __DBL_MAX_10_EXP__ 38
+// TCE:#define __DBL_MAX_EXP__ 128
+// TCE:#define __DBL_MAX__ 3.40282347e+38F
+// TCE:#define __DBL_MIN_10_EXP__ (-37)
+// TCE:#define __DBL_MIN_EXP__ (-125)
+// TCE:#define __DBL_MIN__ 1.17549435e-38F
+// TCE:#define __DECIMAL_DIG__ -1
+// TCE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// TCE:#define __FLT_DIG__ 6
+// TCE:#define __FLT_EPSILON__ 1.19209290e-7F
+// TCE:#define __FLT_EVAL_METHOD__ 0
+// TCE:#define __FLT_HAS_DENORM__ 1
+// TCE:#define __FLT_HAS_INFINITY__ 1
+// TCE:#define __FLT_HAS_QUIET_NAN__ 1
+// TCE:#define __FLT_MANT_DIG__ 24
+// TCE:#define __FLT_MAX_10_EXP__ 38
+// TCE:#define __FLT_MAX_EXP__ 128
+// TCE:#define __FLT_MAX__ 3.40282347e+38F
+// TCE:#define __FLT_MIN_10_EXP__ (-37)
+// TCE:#define __FLT_MIN_EXP__ (-125)
+// TCE:#define __FLT_MIN__ 1.17549435e-38F
+// TCE:#define __FLT_RADIX__ 2
+// TCE:#define __INT16_TYPE__ short
+// TCE:#define __INT32_TYPE__ int
+// TCE:#define __INT8_TYPE__ char
+// TCE:#define __INTMAX_MAX__ 2147483647L
+// TCE:#define __INTMAX_TYPE__ long int
+// TCE:#define __INTMAX_WIDTH__ 32
+// TCE:#define __INTPTR_TYPE__ int
+// TCE:#define __INTPTR_WIDTH__ 32
+// TCE:#define __INT_MAX__ 2147483647
+// TCE:#define __LDBL_DENORM_MIN__ 1.40129846e-45F
+// TCE:#define __LDBL_DIG__ 6
+// TCE:#define __LDBL_EPSILON__ 1.19209290e-7F
+// TCE:#define __LDBL_HAS_DENORM__ 1
+// TCE:#define __LDBL_HAS_INFINITY__ 1
+// TCE:#define __LDBL_HAS_QUIET_NAN__ 1
+// TCE:#define __LDBL_MANT_DIG__ 24
+// TCE:#define __LDBL_MAX_10_EXP__ 38
+// TCE:#define __LDBL_MAX_EXP__ 128
+// TCE:#define __LDBL_MAX__ 3.40282347e+38F
+// TCE:#define __LDBL_MIN_10_EXP__ (-37)
+// TCE:#define __LDBL_MIN_EXP__ (-125)
+// TCE:#define __LDBL_MIN__ 1.17549435e-38F
+// TCE:#define __LONG_LONG_MAX__ 2147483647LL
+// TCE:#define __LONG_MAX__ 2147483647L
+// TCE:#define __NO_INLINE__ 1
+// TCE:#define __POINTER_WIDTH__ 32
+// TCE:#define __PTRDIFF_TYPE__ int
+// TCE:#define __PTRDIFF_WIDTH__ 32
+// TCE:#define __SCHAR_MAX__ 127
+// TCE:#define __SHRT_MAX__ 32767
+// TCE:#define __SIG_ATOMIC_WIDTH__ 32
+// TCE:#define __SIZEOF_DOUBLE__ 4
+// TCE:#define __SIZEOF_FLOAT__ 4
+// TCE:#define __SIZEOF_INT__ 4
+// TCE:#define __SIZEOF_LONG_DOUBLE__ 4
+// TCE:#define __SIZEOF_LONG_LONG__ 4
+// TCE:#define __SIZEOF_LONG__ 4
+// TCE:#define __SIZEOF_POINTER__ 4
+// TCE:#define __SIZEOF_PTRDIFF_T__ 4
+// TCE:#define __SIZEOF_SHORT__ 2
+// TCE:#define __SIZEOF_SIZE_T__ 4
+// TCE:#define __SIZEOF_WCHAR_T__ 4
+// TCE:#define __SIZEOF_WINT_T__ 4
+// TCE:#define __SIZE_TYPE__ unsigned int
+// TCE:#define __SIZE_WIDTH__ 32
+// TCE:#define __TCE_V1__ 1
+// TCE:#define __TCE__ 1
+// TCE:#define __UINTMAX_TYPE__ long unsigned int
+// TCE:#define __USER_LABEL_PREFIX__ _
+// TCE:#define __WCHAR_MAX__ 2147483647
+// TCE:#define __WCHAR_TYPE__ int
+// TCE:#define __WCHAR_WIDTH__ 32
+// TCE:#define __WINT_TYPE__ int
+// TCE:#define __WINT_WIDTH__ 32
+// TCE:#define __tce 1
+// TCE:#define __tce__ 1
+// TCE:#define tce 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-none-none < /dev/null | FileCheck -check-prefix X86_64 %s
+//
+// X86_64:#define _LP64 1
+// X86_64:#define __CHAR16_TYPE__ unsigned short
+// X86_64:#define __CHAR32_TYPE__ unsigned int
+// X86_64:#define __CHAR_BIT__ 8
+// X86_64:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// X86_64:#define __DBL_DIG__ 15
+// X86_64:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// X86_64:#define __DBL_HAS_DENORM__ 1
+// X86_64:#define __DBL_HAS_INFINITY__ 1
+// X86_64:#define __DBL_HAS_QUIET_NAN__ 1
+// X86_64:#define __DBL_MANT_DIG__ 53
+// X86_64:#define __DBL_MAX_10_EXP__ 308
+// X86_64:#define __DBL_MAX_EXP__ 1024
+// X86_64:#define __DBL_MAX__ 1.7976931348623157e+308
+// X86_64:#define __DBL_MIN_10_EXP__ (-307)
+// X86_64:#define __DBL_MIN_EXP__ (-1021)
+// X86_64:#define __DBL_MIN__ 2.2250738585072014e-308
+// X86_64:#define __DECIMAL_DIG__ 21
+// X86_64:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// X86_64:#define __FLT_DIG__ 6
+// X86_64:#define __FLT_EPSILON__ 1.19209290e-7F
+// X86_64:#define __FLT_EVAL_METHOD__ 0
+// X86_64:#define __FLT_HAS_DENORM__ 1
+// X86_64:#define __FLT_HAS_INFINITY__ 1
+// X86_64:#define __FLT_HAS_QUIET_NAN__ 1
+// X86_64:#define __FLT_MANT_DIG__ 24
+// X86_64:#define __FLT_MAX_10_EXP__ 38
+// X86_64:#define __FLT_MAX_EXP__ 128
+// X86_64:#define __FLT_MAX__ 3.40282347e+38F
+// X86_64:#define __FLT_MIN_10_EXP__ (-37)
+// X86_64:#define __FLT_MIN_EXP__ (-125)
+// X86_64:#define __FLT_MIN__ 1.17549435e-38F
+// X86_64:#define __FLT_RADIX__ 2
+// X86_64:#define __INT16_TYPE__ short
+// X86_64:#define __INT32_TYPE__ int
+// X86_64:#define __INT64_C_SUFFIX__ L
+// X86_64:#define __INT64_TYPE__ long int
+// X86_64:#define __INT8_TYPE__ char
+// X86_64:#define __INTMAX_MAX__ 9223372036854775807L
+// X86_64:#define __INTMAX_TYPE__ long int
+// X86_64:#define __INTMAX_WIDTH__ 64
+// X86_64:#define __INTPTR_TYPE__ long int
+// X86_64:#define __INTPTR_WIDTH__ 64
+// X86_64:#define __INT_MAX__ 2147483647
+// X86_64:#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
+// X86_64:#define __LDBL_DIG__ 18
+// X86_64:#define __LDBL_EPSILON__ 1.08420217248550443401e-19L
+// X86_64:#define __LDBL_HAS_DENORM__ 1
+// X86_64:#define __LDBL_HAS_INFINITY__ 1
+// X86_64:#define __LDBL_HAS_QUIET_NAN__ 1
+// X86_64:#define __LDBL_MANT_DIG__ 64
+// X86_64:#define __LDBL_MAX_10_EXP__ 4932
+// X86_64:#define __LDBL_MAX_EXP__ 16384
+// X86_64:#define __LDBL_MAX__ 1.18973149535723176502e+4932L
+// X86_64:#define __LDBL_MIN_10_EXP__ (-4931)
+// X86_64:#define __LDBL_MIN_EXP__ (-16381)
+// X86_64:#define __LDBL_MIN__ 3.36210314311209350626e-4932L
+// X86_64:#define __LITTLE_ENDIAN__ 1
+// X86_64:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// X86_64:#define __LONG_MAX__ 9223372036854775807L
+// X86_64:#define __LP64__ 1
+// X86_64:#define __MMX__ 1
+// X86_64:#define __NO_INLINE__ 1
+// X86_64:#define __NO_MATH_INLINES 1
+// X86_64:#define __POINTER_WIDTH__ 64
+// X86_64:#define __PTRDIFF_TYPE__ long int
+// X86_64:#define __PTRDIFF_WIDTH__ 64
+// X86_64:#define __REGISTER_PREFIX__
+// X86_64:#define __SCHAR_MAX__ 127
+// X86_64:#define __SHRT_MAX__ 32767
+// X86_64:#define __SIG_ATOMIC_WIDTH__ 32
+// X86_64:#define __SIZEOF_DOUBLE__ 8
+// X86_64:#define __SIZEOF_FLOAT__ 4
+// X86_64:#define __SIZEOF_INT__ 4
+// X86_64:#define __SIZEOF_LONG_DOUBLE__ 16
+// X86_64:#define __SIZEOF_LONG_LONG__ 8
+// X86_64:#define __SIZEOF_LONG__ 8
+// X86_64:#define __SIZEOF_POINTER__ 8
+// X86_64:#define __SIZEOF_PTRDIFF_T__ 8
+// X86_64:#define __SIZEOF_SHORT__ 2
+// X86_64:#define __SIZEOF_SIZE_T__ 8
+// X86_64:#define __SIZEOF_WCHAR_T__ 4
+// X86_64:#define __SIZEOF_WINT_T__ 4
+// X86_64:#define __SIZE_TYPE__ long unsigned int
+// X86_64:#define __SIZE_WIDTH__ 64
+// X86_64:#define __SSE2_MATH__ 1
+// X86_64:#define __SSE2__ 1
+// X86_64:#define __SSE_MATH__ 1
+// X86_64:#define __SSE__ 1
+// X86_64:#define __UINTMAX_TYPE__ long unsigned int
+// X86_64:#define __USER_LABEL_PREFIX__ _
+// X86_64:#define __WCHAR_MAX__ 2147483647
+// X86_64:#define __WCHAR_TYPE__ int
+// X86_64:#define __WCHAR_WIDTH__ 32
+// X86_64:#define __WINT_TYPE__ int
+// X86_64:#define __WINT_WIDTH__ 32
+// X86_64:#define __amd64 1
+// X86_64:#define __amd64__ 1
+// X86_64:#define __x86_64 1
+// X86_64:#define __x86_64__ 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-pc-linux-gnu < /dev/null | FileCheck -check-prefix X86_64-LINUX %s
+//
+// X86_64-LINUX:#define _LP64 1
+// X86_64-LINUX:#define __CHAR16_TYPE__ unsigned short
+// X86_64-LINUX:#define __CHAR32_TYPE__ unsigned int
+// X86_64-LINUX:#define __CHAR_BIT__ 8
+// X86_64-LINUX:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// X86_64-LINUX:#define __DBL_DIG__ 15
+// X86_64-LINUX:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// X86_64-LINUX:#define __DBL_HAS_DENORM__ 1
+// X86_64-LINUX:#define __DBL_HAS_INFINITY__ 1
+// X86_64-LINUX:#define __DBL_HAS_QUIET_NAN__ 1
+// X86_64-LINUX:#define __DBL_MANT_DIG__ 53
+// X86_64-LINUX:#define __DBL_MAX_10_EXP__ 308
+// X86_64-LINUX:#define __DBL_MAX_EXP__ 1024
+// X86_64-LINUX:#define __DBL_MAX__ 1.7976931348623157e+308
+// X86_64-LINUX:#define __DBL_MIN_10_EXP__ (-307)
+// X86_64-LINUX:#define __DBL_MIN_EXP__ (-1021)
+// X86_64-LINUX:#define __DBL_MIN__ 2.2250738585072014e-308
+// X86_64-LINUX:#define __DECIMAL_DIG__ 21
+// X86_64-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// X86_64-LINUX:#define __FLT_DIG__ 6
+// X86_64-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F
+// X86_64-LINUX:#define __FLT_EVAL_METHOD__ 0
+// X86_64-LINUX:#define __FLT_HAS_DENORM__ 1
+// X86_64-LINUX:#define __FLT_HAS_INFINITY__ 1
+// X86_64-LINUX:#define __FLT_HAS_QUIET_NAN__ 1
+// X86_64-LINUX:#define __FLT_MANT_DIG__ 24
+// X86_64-LINUX:#define __FLT_MAX_10_EXP__ 38
+// X86_64-LINUX:#define __FLT_MAX_EXP__ 128
+// X86_64-LINUX:#define __FLT_MAX__ 3.40282347e+38F
+// X86_64-LINUX:#define __FLT_MIN_10_EXP__ (-37)
+// X86_64-LINUX:#define __FLT_MIN_EXP__ (-125)
+// X86_64-LINUX:#define __FLT_MIN__ 1.17549435e-38F
+// X86_64-LINUX:#define __FLT_RADIX__ 2
+// X86_64-LINUX:#define __INT16_TYPE__ short
+// X86_64-LINUX:#define __INT32_TYPE__ int
+// X86_64-LINUX:#define __INT64_C_SUFFIX__ L
+// X86_64-LINUX:#define __INT64_TYPE__ long int
+// X86_64-LINUX:#define __INT8_TYPE__ char
+// X86_64-LINUX:#define __INTMAX_MAX__ 9223372036854775807L
+// X86_64-LINUX:#define __INTMAX_TYPE__ long int
+// X86_64-LINUX:#define __INTMAX_WIDTH__ 64
+// X86_64-LINUX:#define __INTPTR_TYPE__ long int
+// X86_64-LINUX:#define __INTPTR_WIDTH__ 64
+// X86_64-LINUX:#define __INT_MAX__ 2147483647
+// X86_64-LINUX:#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
+// X86_64-LINUX:#define __LDBL_DIG__ 18
+// X86_64-LINUX:#define __LDBL_EPSILON__ 1.08420217248550443401e-19L
+// X86_64-LINUX:#define __LDBL_HAS_DENORM__ 1
+// X86_64-LINUX:#define __LDBL_HAS_INFINITY__ 1
+// X86_64-LINUX:#define __LDBL_HAS_QUIET_NAN__ 1
+// X86_64-LINUX:#define __LDBL_MANT_DIG__ 64
+// X86_64-LINUX:#define __LDBL_MAX_10_EXP__ 4932
+// X86_64-LINUX:#define __LDBL_MAX_EXP__ 16384
+// X86_64-LINUX:#define __LDBL_MAX__ 1.18973149535723176502e+4932L
+// X86_64-LINUX:#define __LDBL_MIN_10_EXP__ (-4931)
+// X86_64-LINUX:#define __LDBL_MIN_EXP__ (-16381)
+// X86_64-LINUX:#define __LDBL_MIN__ 3.36210314311209350626e-4932L
+// X86_64-LINUX:#define __LITTLE_ENDIAN__ 1
+// X86_64-LINUX:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// X86_64-LINUX:#define __LONG_MAX__ 9223372036854775807L
+// X86_64-LINUX:#define __LP64__ 1
+// X86_64-LINUX:#define __MMX__ 1
+// X86_64-LINUX:#define __NO_INLINE__ 1
+// X86_64-LINUX:#define __NO_MATH_INLINES 1
+// X86_64-LINUX:#define __POINTER_WIDTH__ 64
+// X86_64-LINUX:#define __PTRDIFF_TYPE__ long int
+// X86_64-LINUX:#define __PTRDIFF_WIDTH__ 64
+// X86_64-LINUX:#define __REGISTER_PREFIX__
+// X86_64-LINUX:#define __SCHAR_MAX__ 127
+// X86_64-LINUX:#define __SHRT_MAX__ 32767
+// X86_64-LINUX:#define __SIG_ATOMIC_WIDTH__ 32
+// X86_64-LINUX:#define __SIZEOF_DOUBLE__ 8
+// X86_64-LINUX:#define __SIZEOF_FLOAT__ 4
+// X86_64-LINUX:#define __SIZEOF_INT__ 4
+// X86_64-LINUX:#define __SIZEOF_LONG_DOUBLE__ 16
+// X86_64-LINUX:#define __SIZEOF_LONG_LONG__ 8
+// X86_64-LINUX:#define __SIZEOF_LONG__ 8
+// X86_64-LINUX:#define __SIZEOF_POINTER__ 8
+// X86_64-LINUX:#define __SIZEOF_PTRDIFF_T__ 8
+// X86_64-LINUX:#define __SIZEOF_SHORT__ 2
+// X86_64-LINUX:#define __SIZEOF_SIZE_T__ 8
+// X86_64-LINUX:#define __SIZEOF_WCHAR_T__ 4
+// X86_64-LINUX:#define __SIZEOF_WINT_T__ 4
+// X86_64-LINUX:#define __SIZE_TYPE__ long unsigned int
+// X86_64-LINUX:#define __SIZE_WIDTH__ 64
+// X86_64-LINUX:#define __SSE2_MATH__ 1
+// X86_64-LINUX:#define __SSE2__ 1
+// X86_64-LINUX:#define __SSE_MATH__ 1
+// X86_64-LINUX:#define __SSE__ 1
+// X86_64-LINUX:#define __UINTMAX_TYPE__ long unsigned int
+// X86_64-LINUX:#define __USER_LABEL_PREFIX__
+// X86_64-LINUX:#define __WCHAR_MAX__ 2147483647
+// X86_64-LINUX:#define __WCHAR_TYPE__ int
+// X86_64-LINUX:#define __WCHAR_WIDTH__ 32
+// X86_64-LINUX:#define __WINT_TYPE__ unsigned int
+// X86_64-LINUX:#define __WINT_WIDTH__ 32
+// X86_64-LINUX:#define __amd64 1
+// X86_64-LINUX:#define __amd64__ 1
+// X86_64-LINUX:#define __x86_64 1
+// X86_64-LINUX:#define __x86_64__ 1
+//
+// RUN: %clang_cc1 -x c++ -triple i686-pc-linux-gnu -fobjc-fragile-abi -E -dM < /dev/null | FileCheck -check-prefix GNUSOURCE %s
+// GNUSOURCE:#define _GNU_SOURCE 1
+//
+// RUN: %clang_cc1 -x c++ -std=c++98 -fno-rtti -E -dM < /dev/null | FileCheck -check-prefix NORTTI %s
+// NORTTI: __GXX_ABI_VERSION
+// NORTTI-NOT:#define __GXX_RTTI
+// NORTTI: __STDC__
diff --git a/clang/test/Preprocessor/line-directive-output.c b/clang/test/Preprocessor/line-directive-output.c
new file mode 100644
index 0000000..290703a
--- /dev/null
+++ b/clang/test/Preprocessor/line-directive-output.c
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -E %s 2>&1 | FileCheck %s -strict-whitespace
+// PR6101
+int a;
+// CHECK: # 1 "{{.*}}line-directive-output.c"
+// CHECK: int a;
+
+// CHECK-NEXT: # 50 "{{.*}}line-directive-output.c"
+// CHECK-NEXT: int b;
+#line 50
+int b;
+
+// CHECK: # 13 "{{.*}}line-directive-output.c"
+// CHECK-NEXT: int c;
+# 13
+int c;
+
+
+// CHECK-NEXT: # 1 "A.c"
+#line 1 "A.c"
+// CHECK-NEXT: # 2 "A.c"
+#line 2
+
+// CHECK-NEXT: # 1 "B.c"
+#line 1 "B.c"
+
+// CHECK-NEXT: # 1000 "A.c"
+#line 1000 "A.c"
+
+int y;
+
+
+
+
+
+
+
+// CHECK: # 1010 "A.c"
+int z;
+
+extern int x;
+
+# 3 "temp2.h" 1
+extern int y;
+
+# 7 "A.c" 2
+extern int z;
+
+
+
+
+
+
+
+
+
+
+
+
+
+// CHECK: # 25 "A.c"
+
+
+// CHECK: # 50 "C.c" 1
+# 50 "C.c" 1
+
+
+// CHECK-NEXT: # 2000 "A.c" 2
+# 2000 "A.c" 2
+# 42 "A.c"
+# 44 "A.c"
+# 49 "A.c"
diff --git a/clang/test/Preprocessor/line-directive.c b/clang/test/Preprocessor/line-directive.c
new file mode 100644
index 0000000..28e9302
--- /dev/null
+++ b/clang/test/Preprocessor/line-directive.c
@@ -0,0 +1,92 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:92:2: error: ABC'
+// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:93:2: error: DEF'
+
+#line 'a' // expected-error {{#line directive requires a positive integer argument}}
+#line 0 // expected-error {{#line directive requires a positive integer argument}}
+#line 00 // expected-error {{#line directive requires a positive integer argument}}
+#line 2147483648 // expected-warning {{C requires #line number to be less than 2147483648, allowed as extension}}
+#line 42 // ok
+#line 42 'a' // expected-error {{invalid filename for #line directive}}
+#line 42 "foo/bar/baz.h" // ok
+
+
+// #line directives expand macros.
+#define A 42 "foo"
+#line A
+
+# 42
+# 42 "foo"
+# 42 "foo" 2 // expected-error {{invalid line marker flag '2': cannot pop empty include stack}}
+# 42 "foo" 1 3 // enter
+# 42 "foo" 2 3 // exit
+# 42 "foo" 2 3 4 // expected-error {{invalid line marker flag '2': cannot pop empty include stack}}
+# 42 "foo" 3 4
+
+# 'a' // expected-error {{invalid preprocessing directive}}
+# 42 'f' // expected-error {{invalid filename for line marker directive}}
+# 42 1 3 // expected-error {{invalid filename for line marker directive}}
+# 42 "foo" 3 1 // expected-error {{invalid flag line marker directive}}
+# 42 "foo" 42 // expected-error {{invalid flag line marker directive}}
+# 42 "foo" 1 2 // expected-error {{invalid flag line marker directive}}
+
+
+// These are checked by the RUN line.
+#line 92 "blonk.c"
+#error ABC // expected-error {{#error ABC}}
+#error DEF // expected-error {{#error DEF}}
+
+
+// Verify that linemarker diddling of the system header flag works.
+
+# 192 "glomp.h" // not a system header.
+typedef int x; // expected-note {{previous definition is here}}
+typedef int x; // expected-warning {{redefinition of typedef 'x' is a C11 feature}}
+
+# 192 "glomp.h" 3 // System header.
+typedef int y; // ok
+typedef int y; // ok
+
+typedef int q; // q is in system header.
+
+#line 42 "blonk.h" // doesn't change system headerness.
+
+typedef int z; // ok
+typedef int z; // ok
+
+# 97 // doesn't change system headerness.
+
+typedef int z1; // ok
+typedef int z1; // ok
+
+# 42 "blonk.h" // DOES change system headerness.
+
+typedef int w; // expected-note {{previous definition is here}}
+typedef int w; // expected-warning {{redefinition of typedef 'w' is a C11 feature}}
+
+typedef int q; // original definition in system header, should not diagnose.
+
+// This should not produce an "extra tokens at end of #line directive" warning,
+// because #line is allowed to contain expanded tokens.
+#define EMPTY()
+#line 2 "foo.c" EMPTY( )
+#line 2 "foo.c" NONEMPTY( ) // expected-warning{{extra tokens at end of #line directive}}
+
+// PR3940
+#line 0xf // expected-error {{#line directive requires a simple digit sequence}}
+#line 42U // expected-error {{#line directive requires a simple digit sequence}}
+
+
+// Line markers are digit strings interpreted as decimal numbers, this is
+// 10, not 8.
+#line 010 // expected-warning {{#line directive interprets number as decimal, not octal}}
+extern int array[__LINE__ == 10 ? 1:-1];
+
+/* PR3917 */
+#line 41
+extern char array2[\
+_\
+_LINE__ == 42 ? 1: -1]; /* line marker is location of first _ */
+
+
+
diff --git a/clang/test/Preprocessor/macro-multiline.c b/clang/test/Preprocessor/macro-multiline.c
new file mode 100644
index 0000000..df7c40a
--- /dev/null
+++ b/clang/test/Preprocessor/macro-multiline.c
@@ -0,0 +1,8 @@
+// RUN: %clang -E %s "-DX=A
+// RUN: THIS_SHOULD_NOT_EXIST_IN_THE_OUTPUT" > %t
+// RUN: grep "GOOD: A" %t
+// RUN: not grep THIS_SHOULD_NOT_EXIST_IN_THE_OUTPUT %t
+// rdar://6762183
+
+GOOD: X
+
diff --git a/clang/test/Preprocessor/macro_arg_directive.c b/clang/test/Preprocessor/macro_arg_directive.c
new file mode 100644
index 0000000..5c9943d
--- /dev/null
+++ b/clang/test/Preprocessor/macro_arg_directive.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+// header1.h
+void fail(const char *);
+#define MUNCH(...) \
+ ({ int result = 0; __VA_ARGS__; if (!result) { fail(#__VA_ARGS__); }; result })
+
+static inline int f(int k) {
+ return MUNCH( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{returning 'void'}}
+ if (k < 3)
+ result = 24;
+ else if (k > 4)
+ result = k - 4;
+}
+
+#include "macro_arg_directive.h" // expected-error {{embedding a #include directive within macro arguments is not supported}}
+
+int g(int k) {
+ return f(k) + f(k-1));
+}
diff --git a/clang/test/Preprocessor/macro_arg_directive.h b/clang/test/Preprocessor/macro_arg_directive.h
new file mode 100644
index 0000000..892dbf2
--- /dev/null
+++ b/clang/test/Preprocessor/macro_arg_directive.h
@@ -0,0 +1,9 @@
+// Support header for macro_arg_directive.c
+
+int n;
+
+struct S {
+ int k;
+};
+
+void g(int);
diff --git a/clang/test/Preprocessor/macro_arg_keyword.c b/clang/test/Preprocessor/macro_arg_keyword.c
new file mode 100644
index 0000000..b9bbbf3
--- /dev/null
+++ b/clang/test/Preprocessor/macro_arg_keyword.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -E %s | grep xxx-xxx
+
+#define foo(return) return-return
+
+foo(xxx)
+
diff --git a/clang/test/Preprocessor/macro_disable.c b/clang/test/Preprocessor/macro_disable.c
new file mode 100644
index 0000000..d7859dc
--- /dev/null
+++ b/clang/test/Preprocessor/macro_disable.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 %s -E | FileCheck -strict-whitespace %s
+// Check for C99 6.10.3.4p2.
+
+#define f(a) f(x * (a))
+#define x 2
+#define z z[0]
+f(f(z));
+// CHECK: f(2 * (f(2 * (z[0]))));
+
+
+
+#define A A B C
+#define B B C A
+#define C C A B
+A
+// CHECK: A B C A B A C A B C A
+
+
+// PR1820
+#define i(x) h(x
+#define h(x) x(void)
+extern int i(i));
+// CHECK: int i(void)
+
+
+#define M_0(x) M_ ## x
+#define M_1(x) x + M_0(0)
+#define M_2(x) x + M_1(1)
+#define M_3(x) x + M_2(2)
+#define M_4(x) x + M_3(3)
+#define M_5(x) x + M_4(4)
+
+a: M_0(1)(2)(3)(4)(5);
+b: M_0(5)(4)(3)(2)(1);
+
+// CHECK: a: 2 + M_0(3)(4)(5);
+// CHECK: b: 4 + 4 + 3 + 2 + 1 + M_0(3)(2)(1);
+
+#define n(v) v
+#define l m
+#define m l a
+c: n(m) X
+// CHECK: c: m a X
diff --git a/clang/test/Preprocessor/macro_expand.c b/clang/test/Preprocessor/macro_expand.c
new file mode 100644
index 0000000..4dc0357
--- /dev/null
+++ b/clang/test/Preprocessor/macro_expand.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -E %s | grep '^A: Y$'
+// RUN: %clang_cc1 -E %s | grep '^B: f()$'
+// RUN: %clang_cc1 -E %s | grep '^C: for()$'
+
+#define X() Y
+#define Y() X
+
+A: X()()()
+
+// PR3927
+#define f(x) h(x
+#define for(x) h(x
+#define h(x) x()
+B: f(f))
+C: for(for))
+
+// rdar://6880648
+#define f(x,y...) y
+f()
diff --git a/clang/test/Preprocessor/macro_expandloc.c b/clang/test/Preprocessor/macro_expandloc.c
new file mode 100644
index 0000000..f466013
--- /dev/null
+++ b/clang/test/Preprocessor/macro_expandloc.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -E 2>&1 | grep '#include'
+#define FOO 1
+
+// The error message should be on the #include line, not the 1.
+#include FOO
+
diff --git a/clang/test/Preprocessor/macro_expandloc2.c b/clang/test/Preprocessor/macro_expandloc2.c
new file mode 100644
index 0000000..4aa7dfe
--- /dev/null
+++ b/clang/test/Preprocessor/macro_expandloc2.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -E 2>&1 | grep '#include'
+#define FOO BAR
+
+// The error message should be on the #include line, not the 1.
+#include FOO
+
diff --git a/clang/test/Preprocessor/macro_fn.c b/clang/test/Preprocessor/macro_fn.c
new file mode 100644
index 0000000..85733b4
--- /dev/null
+++ b/clang/test/Preprocessor/macro_fn.c
@@ -0,0 +1,46 @@
+/* RUN: %clang_cc1 %s -Eonly -std=c89 -pedantic -verify
+*/
+/* PR3937 */
+#define zero() 0
+#define one(x) 0
+#define two(x, y) 0
+#define zero_dot(...) 0 /* expected-warning {{variadic macros were introduced in C99}} */
+#define one_dot(x, ...) 0 /* expected-warning {{variadic macros were introduced in C99}} */
+
+zero()
+zero(1); /* expected-error {{too many arguments provided to function-like macro invocation}} */
+zero(1, 2, 3); /* expected-error {{too many arguments provided to function-like macro invocation}} */
+
+one() /* ok */
+one(a)
+one(a,) /* expected-error {{too many arguments provided to function-like macro invocation}} */
+one(a, b) /* expected-error {{too many arguments provided to function-like macro invocation}} */
+
+two() /* expected-error {{too few arguments provided to function-like macro invocation}} */
+two(a) /* expected-error {{too few arguments provided to function-like macro invocation}} */
+two(a,b)
+two(a, ) /* expected-warning {{empty macro arguments were standardized in C99}} */
+two(a,b,c) /* expected-error {{too many arguments provided to function-like macro invocation}} */
+two(
+ , /* expected-warning {{empty macro arguments were standardized in C99}} */
+ , /* expected-warning {{empty macro arguments were standardized in C99}} \
+ expected-error {{too many arguments provided to function-like macro invocation}} */
+ )
+two(,) /* expected-warning 2 {{empty macro arguments were standardized in C99}} */
+
+
+
+/* PR4006 & rdar://6807000 */
+#define e(...) __VA_ARGS__ /* expected-warning {{variadic macros were introduced in C99}} */
+e(x)
+e()
+
+zero_dot()
+one_dot(x) /* empty ... argument: expected-warning {{varargs argument missing, but tolerated as an extension}} */
+one_dot() /* empty first argument, elided ...: expected-warning {{varargs argument missing, but tolerated as an extension}} */
+
+
+/* rdar://6816766 - Crash with function-like macro test at end of directive. */
+#define E() (i == 0)
+#if E
+#endif
diff --git a/clang/test/Preprocessor/macro_fn_comma_swallow.c b/clang/test/Preprocessor/macro_fn_comma_swallow.c
new file mode 100644
index 0000000..726a889
--- /dev/null
+++ b/clang/test/Preprocessor/macro_fn_comma_swallow.c
@@ -0,0 +1,28 @@
+// Test the GNU comma swallowing extension.
+// RUN: %clang_cc1 %s -E | FileCheck -strict-whitespace %s
+
+// CHECK: 1: foo{A, }
+#define X(Y) foo{A, Y}
+1: X()
+
+
+// CHECK: 2: fo2{A,}
+#define X2(Y) fo2{A,##Y}
+2: X2()
+
+// should eat the comma.
+// CHECK: 3: {foo}
+#define X3(b, ...) {b, ## __VA_ARGS__}
+3: X3(foo)
+
+
+
+// PR3880
+// CHECK: 4: AA BB
+#define X4(...) AA , ## __VA_ARGS__ BB
+4: X4()
+
+// PR7943
+// CHECK: 5: 1
+#define X5(x,...) x##,##__VA_ARGS__
+5: X5(1)
diff --git a/clang/test/Preprocessor/macro_fn_disable_expand.c b/clang/test/Preprocessor/macro_fn_disable_expand.c
new file mode 100644
index 0000000..16948dc
--- /dev/null
+++ b/clang/test/Preprocessor/macro_fn_disable_expand.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -E | FileCheck %s
+
+#define foo(x) bar x
+foo(foo) (2)
+// CHECK: bar foo (2)
+
+#define m(a) a(w)
+#define w ABCD
+m(m)
+// CHECK: m(ABCD)
+
+
+
+// rdar://7466570 PR4438, PR5163
+
+// We should get '42' in the argument list for gcc compatibility.
+#define A 1
+#define B 2
+#define C(x) (x + 1)
+
+X: C(
+#ifdef A
+#if A == 1
+#if B
+ 42
+#endif
+#endif
+#endif
+ )
+// CHECK: X: (42 + 1)
diff --git a/clang/test/Preprocessor/macro_fn_lparen_scan.c b/clang/test/Preprocessor/macro_fn_lparen_scan.c
new file mode 100644
index 0000000..0218469
--- /dev/null
+++ b/clang/test/Preprocessor/macro_fn_lparen_scan.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -E %s | grep 'noexp: foo y'
+// RUN: %clang_cc1 -E %s | grep 'expand: abc'
+// RUN: %clang_cc1 -E %s | grep 'noexp2: foo nonexp'
+// RUN: %clang_cc1 -E %s | grep 'expand2: abc'
+
+#define A foo
+#define foo() abc
+#define X A y
+
+// This should not expand to abc, because the foo macro isn't followed by (.
+noexp: X
+
+
+// This should expand to abc.
+#undef X
+#define X A ()
+expand: X
+
+
+// This should be 'foo nonexp'
+noexp2: A nonexp
+
+// This should expand
+expand2: A (
+)
+
+
diff --git a/clang/test/Preprocessor/macro_fn_lparen_scan2.c b/clang/test/Preprocessor/macro_fn_lparen_scan2.c
new file mode 100644
index 0000000..c23e741
--- /dev/null
+++ b/clang/test/Preprocessor/macro_fn_lparen_scan2.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -E %s | grep 'FUNC (3 +1);'
+
+#define F(a) a
+#define FUNC(a) (a+1)
+
+F(FUNC) FUNC (3); /* final token sequence is FUNC(3+1) */
+
diff --git a/clang/test/Preprocessor/macro_fn_placemarker.c b/clang/test/Preprocessor/macro_fn_placemarker.c
new file mode 100644
index 0000000..1791054
--- /dev/null
+++ b/clang/test/Preprocessor/macro_fn_placemarker.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -E | grep 'foo(A, )'
+
+#define X(Y) foo(A, Y)
+X()
+
diff --git a/clang/test/Preprocessor/macro_fn_preexpand.c b/clang/test/Preprocessor/macro_fn_preexpand.c
new file mode 100644
index 0000000..1b94c82
--- /dev/null
+++ b/clang/test/Preprocessor/macro_fn_preexpand.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -E | grep 'pre: 1 1 X'
+// RUN: %clang_cc1 %s -E | grep 'nopre: 1A(X)'
+
+/* Preexpansion of argument. */
+#define A(X) 1 X
+pre: A(A(X))
+
+/* The ## operator disables preexpansion. */
+#undef A
+#define A(X) 1 ## X
+nopre: A(A(X))
+
diff --git a/clang/test/Preprocessor/macro_fn_varargs_iso.c b/clang/test/Preprocessor/macro_fn_varargs_iso.c
new file mode 100644
index 0000000..a1aab26
--- /dev/null
+++ b/clang/test/Preprocessor/macro_fn_varargs_iso.c
@@ -0,0 +1,11 @@
+
+// RUN: %clang_cc1 -E %s | grep 'foo{a, b, c, d, e}'
+// RUN: %clang_cc1 -E %s | grep 'foo2{d, C, B}'
+// RUN: %clang_cc1 -E %s | grep 'foo2{d,e, C, B}'
+
+#define va1(...) foo{a, __VA_ARGS__, e}
+va1(b, c, d)
+#define va2(a, b, ...) foo2{__VA_ARGS__, b, a}
+va2(B, C, d)
+va2(B, C, d,e)
+
diff --git a/clang/test/Preprocessor/macro_fn_varargs_named.c b/clang/test/Preprocessor/macro_fn_varargs_named.c
new file mode 100644
index 0000000..b50d53d
--- /dev/null
+++ b/clang/test/Preprocessor/macro_fn_varargs_named.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -E %s | grep '^a: x$'
+// RUN: %clang_cc1 -E %s | grep '^b: x y, z,h$'
+// RUN: %clang_cc1 -E %s | grep '^c: foo(x)$'
+
+#define A(b, c...) b c
+a: A(x)
+b: A(x, y, z,h)
+
+#define B(b, c...) foo(b, ## c)
+c: B(x)
diff --git a/clang/test/Preprocessor/macro_misc.c b/clang/test/Preprocessor/macro_misc.c
new file mode 100644
index 0000000..53d9982
--- /dev/null
+++ b/clang/test/Preprocessor/macro_misc.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -Eonly -verify
+
+// This should not be rejected.
+#ifdef defined
+#endif
+
+
+
+// PR3764
+
+// This should not produce a redefinition warning.
+#define FUNC_LIKE(a) (a)
+#define FUNC_LIKE(a)(a)
+
+// This either.
+#define FUNC_LIKE2(a)\
+(a)
+#define FUNC_LIKE2(a) (a)
+
+// This should.
+#define FUNC_LIKE3(a) ( a) // expected-note {{previous definition is here}}
+#define FUNC_LIKE3(a) (a) // expected-warning {{'FUNC_LIKE3' macro redefined}}
+
diff --git a/clang/test/Preprocessor/macro_not_define.c b/clang/test/Preprocessor/macro_not_define.c
new file mode 100644
index 0000000..82648d4
--- /dev/null
+++ b/clang/test/Preprocessor/macro_not_define.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -E %s | grep '^ # define X 3$'
+
+#define H #
+ #define D define
+
+ #define DEFINE(a, b) H D a b
+
+ DEFINE(X, 3)
+
diff --git a/clang/test/Preprocessor/macro_paste_bad.c b/clang/test/Preprocessor/macro_paste_bad.c
new file mode 100644
index 0000000..0a028a4
--- /dev/null
+++ b/clang/test/Preprocessor/macro_paste_bad.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -Eonly -verify -pedantic %s
+// pasting ""x"" and ""+"" does not give a valid preprocessing token
+#define XYZ x ## +
+XYZ // expected-error {{pasting formed 'x+', an invalid preprocessing token}}
+#define XXYZ . ## test
+XXYZ // expected-error {{pasting formed '.test', an invalid preprocessing token}}
+
+// GCC PR 20077
+
+#define a a ## ## // expected-error {{'##' cannot appear at end of macro expansion}}
+#define b() b ## ## // expected-error {{'##' cannot appear at end of macro expansion}}
+#define c c ## // expected-error {{'##' cannot appear at end of macro expansion}}
+#define d() d ## // expected-error {{'##' cannot appear at end of macro expansion}}
+
+
+#define e ## ## e // expected-error {{'##' cannot appear at start of macro expansion}}
+#define f() ## ## f // expected-error {{'##' cannot appear at start of macro expansion}}
+#define g ## g // expected-error {{'##' cannot appear at start of macro expansion}}
+#define h() ## h // expected-error {{'##' cannot appear at start of macro expansion}}
+#define i ## // expected-error {{'##' cannot appear at start of macro expansion}}
+#define j() ## // expected-error {{'##' cannot appear at start of macro expansion}}
+
+// Invalid token pasting.
+// PR3918
+
+// When pasting creates poisoned identifiers, we error.
+#pragma GCC poison BLARG
+BLARG // expected-error {{attempt to use a poisoned identifier}}
+#define XX BL ## ARG
+XX // expected-error {{attempt to use a poisoned identifier}}
+
+#define VA __VA_ ## ARGS__
+int VA; // expected-warning {{__VA_ARGS__ can only appear in the expansion of a C99 variadic macro}}
+
diff --git a/clang/test/Preprocessor/macro_paste_bcpl_comment.c b/clang/test/Preprocessor/macro_paste_bcpl_comment.c
new file mode 100644
index 0000000..fd07b1f
--- /dev/null
+++ b/clang/test/Preprocessor/macro_paste_bcpl_comment.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -Eonly 2>&1 | grep error
+
+#define COMM1 / ## /
+COMM1
+
diff --git a/clang/test/Preprocessor/macro_paste_c_block_comment.c b/clang/test/Preprocessor/macro_paste_c_block_comment.c
new file mode 100644
index 0000000..c690a4c
--- /dev/null
+++ b/clang/test/Preprocessor/macro_paste_c_block_comment.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -Eonly -verify
+
+#define COMM / ## *
+COMM // expected-error {{pasting formed '/*', an invalid preprocessing token}}
+
diff --git a/clang/test/Preprocessor/macro_paste_commaext.c b/clang/test/Preprocessor/macro_paste_commaext.c
new file mode 100644
index 0000000..7cfe43d
--- /dev/null
+++ b/clang/test/Preprocessor/macro_paste_commaext.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -E | grep 'V);'
+// RUN: %clang_cc1 %s -E | grep 'W, 1, 2);'
+// RUN: %clang_cc1 %s -E | grep 'X, 1, 2);'
+// RUN: %clang_cc1 %s -E | grep 'Y, );'
+// RUN: %clang_cc1 %s -E | grep 'Z, );'
+
+#define debug(format, ...) format, ## __VA_ARGS__)
+debug(V);
+debug(W, 1, 2);
+debug(X, 1, 2 );
+debug(Y, );
+debug(Z,);
+
diff --git a/clang/test/Preprocessor/macro_paste_empty.c b/clang/test/Preprocessor/macro_paste_empty.c
new file mode 100644
index 0000000..2e26f14
--- /dev/null
+++ b/clang/test/Preprocessor/macro_paste_empty.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -E %s | grep 'a:Y'
+// RUN: %clang_cc1 -E %s | grep 'b:Y'
+// RUN: %clang_cc1 -E %s | grep 'c:YY'
+
+#define FOO(X) X ## Y
+a:FOO()
+
+#define FOO2(X) Y ## X
+b:FOO2()
+
+#define FOO3(X) X ## Y ## X ## Y ## X ## X
+c:FOO3()
+
diff --git a/clang/test/Preprocessor/macro_paste_hard.c b/clang/test/Preprocessor/macro_paste_hard.c
new file mode 100644
index 0000000..fad8426
--- /dev/null
+++ b/clang/test/Preprocessor/macro_paste_hard.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -E %s | grep '1: aaab 2'
+// RUN: %clang_cc1 -E %s | grep '2: 2 baaa'
+// RUN: %clang_cc1 -E %s | grep '3: 2 xx'
+
+#define a(n) aaa ## n
+#define b 2
+1: a(b b) // aaab 2 2 gets expanded, not b.
+
+#undef a
+#undef b
+#define a(n) n ## aaa
+#define b 2
+2: a(b b) // 2 baaa 2 gets expanded, not b.
+
+#define baaa xx
+3: a(b b) // 2 xx
+
diff --git a/clang/test/Preprocessor/macro_paste_hashhash.c b/clang/test/Preprocessor/macro_paste_hashhash.c
new file mode 100644
index 0000000..f4b03be
--- /dev/null
+++ b/clang/test/Preprocessor/macro_paste_hashhash.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E %s | FileCheck %s
+#define hash_hash # ## #
+#define mkstr(a) # a
+#define in_between(a) mkstr(a)
+#define join(c, d) in_between(c hash_hash d)
+// CHECK: "x ## y";
+join(x, y);
+
+#define FOO(x) A x B
+// CHECK: A ## B;
+FOO(##);
diff --git a/clang/test/Preprocessor/macro_paste_msextensions.c b/clang/test/Preprocessor/macro_paste_msextensions.c
new file mode 100644
index 0000000..c5b4213
--- /dev/null
+++ b/clang/test/Preprocessor/macro_paste_msextensions.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -P -E -fms-extensions %s | FileCheck -strict-whitespace %s
+
+// This horrible stuff should preprocess into (other than whitespace):
+// int foo;
+// int bar;
+// int baz;
+
+int foo;
+
+// CHECK: int foo;
+
+#define comment /##/ dead tokens live here
+comment This is stupidity
+
+int bar;
+
+// CHECK: int bar;
+
+#define nested(x) int x comment cute little dead tokens...
+
+nested(baz) rise of the dead tokens
+
+;
+
+// CHECK: int baz
+// CHECK: ;
+
+
+// rdar://8197149 - VC++ allows invalid token pastes: (##baz
+#define foo(x) abc(x)
+#define bar(y) foo(##baz(y))
+bar(q)
+
+// CHECK: abc(baz(q))
diff --git a/clang/test/Preprocessor/macro_paste_none.c b/clang/test/Preprocessor/macro_paste_none.c
new file mode 100644
index 0000000..97ccd7c
--- /dev/null
+++ b/clang/test/Preprocessor/macro_paste_none.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -E %s | grep '!!'
+
+#define A(B,C) B ## C
+
+!A(,)!
+
diff --git a/clang/test/Preprocessor/macro_paste_simple.c b/clang/test/Preprocessor/macro_paste_simple.c
new file mode 100644
index 0000000..0e62ba4
--- /dev/null
+++ b/clang/test/Preprocessor/macro_paste_simple.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -E | FileCheck %s
+
+#define FOO bar ## baz ## 123
+
+// CHECK: A: barbaz123
+A: FOO
+
+// PR9981
+#define M1(A) A
+#define M2(X) X
+B: M1(M2(##))
+
+// CHECK: B: ##
+
diff --git a/clang/test/Preprocessor/macro_paste_spacing.c b/clang/test/Preprocessor/macro_paste_spacing.c
new file mode 100644
index 0000000..6498ffc
--- /dev/null
+++ b/clang/test/Preprocessor/macro_paste_spacing.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -E | grep "^xy$"
+
+#define A x ## y
+blah
+
+A
+
diff --git a/clang/test/Preprocessor/macro_paste_spacing2.c b/clang/test/Preprocessor/macro_paste_spacing2.c
new file mode 100644
index 0000000..02cc12f
--- /dev/null
+++ b/clang/test/Preprocessor/macro_paste_spacing2.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -E | grep "movl %eax"
+// PR4132
+#define R1E %eax
+#define epilogue(r1) movl r1 ## E;
+epilogue(R1)
+
diff --git a/clang/test/Preprocessor/macro_rescan.c b/clang/test/Preprocessor/macro_rescan.c
new file mode 100644
index 0000000..3a38548
--- /dev/null
+++ b/clang/test/Preprocessor/macro_rescan.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -E %s | grep 'ei_1 = (17 +1);'
+// RUN: %clang_cc1 -E %s | grep 'ei_2 = (M1)(17);'
+
+#define M1(a) (a+1)
+#define M2(b) b
+
+int ei_1 = M2(M1)(17); /* becomes int ei_1 = (17+1); */
+int ei_2 = (M2(M1))(17); /* becomes int ei_2 = (M1)(17); */
+
diff --git a/clang/test/Preprocessor/macro_rescan2.c b/clang/test/Preprocessor/macro_rescan2.c
new file mode 100644
index 0000000..826f4ee
--- /dev/null
+++ b/clang/test/Preprocessor/macro_rescan2.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -E | grep 'a: 2\*f(9)'
+// RUN: %clang_cc1 %s -E | grep 'b: 2\*9\*g'
+
+#define f(a) a*g
+#define g f
+a: f(2)(9)
+
+#undef f
+#undef g
+
+#define f(a) a*g
+#define g(a) f(a)
+
+b: f(2)(9)
+
diff --git a/clang/test/Preprocessor/macro_rescan_varargs.c b/clang/test/Preprocessor/macro_rescan_varargs.c
new file mode 100644
index 0000000..6c6415a
--- /dev/null
+++ b/clang/test/Preprocessor/macro_rescan_varargs.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -E %s | FileCheck -strict-whitespace %s
+
+#define LPAREN (
+#define RPAREN )
+#define F(x, y) x + y
+#define ELLIP_FUNC(...) __VA_ARGS__
+
+1: ELLIP_FUNC(F, LPAREN, 'a', 'b', RPAREN); /* 1st invocation */
+2: ELLIP_FUNC(F LPAREN 'a', 'b' RPAREN); /* 2nd invocation */
+
+// CHECK: 1: F, (, 'a', 'b', );
+// CHECK: 2: 'a' + 'b';
+
diff --git a/clang/test/Preprocessor/macro_rparen_scan.c b/clang/test/Preprocessor/macro_rparen_scan.c
new file mode 100644
index 0000000..e4de5db
--- /dev/null
+++ b/clang/test/Preprocessor/macro_rparen_scan.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -E %s | grep '^3 ;$'
+
+/* Right paren scanning, hard case. Should expand to 3. */
+#define i(x) 3
+#define a i(yz
+#define b )
+a b ) ;
+
diff --git a/clang/test/Preprocessor/macro_rparen_scan2.c b/clang/test/Preprocessor/macro_rparen_scan2.c
new file mode 100644
index 0000000..42aa544
--- /dev/null
+++ b/clang/test/Preprocessor/macro_rparen_scan2.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -E %s | FileCheck -strict-whitespace %s
+
+#define R_PAREN )
+
+#define FUNC(a) a
+
+static int glob = (1 + FUNC(1 R_PAREN );
+
+// CHECK: static int glob = (1 + 1 );
+
diff --git a/clang/test/Preprocessor/macro_space.c b/clang/test/Preprocessor/macro_space.c
new file mode 100644
index 0000000..49a9a0f
--- /dev/null
+++ b/clang/test/Preprocessor/macro_space.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -E | grep '! ,'
+
+#define XX
+! XX,
+
diff --git a/clang/test/Preprocessor/macro_undef.c b/clang/test/Preprocessor/macro_undef.c
new file mode 100644
index 0000000..c842c85
--- /dev/null
+++ b/clang/test/Preprocessor/macro_undef.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -dM -undef -Dfoo=1 -E %s | FileCheck %s
+
+// CHECK-NOT: #define __clang__
+// CHECK: #define foo 1
diff --git a/clang/test/Preprocessor/mi_opt.c b/clang/test/Preprocessor/mi_opt.c
new file mode 100644
index 0000000..597ac07
--- /dev/null
+++ b/clang/test/Preprocessor/mi_opt.c
@@ -0,0 +1,11 @@
+// RUN: not %clang_cc1 -fsyntax-only %s
+// PR1900
+// This test should get a redefinition error from m_iopt.h: the MI opt
+// shouldn't apply.
+
+#define MACRO
+#include "mi_opt.h"
+#undef MACRO
+#define MACRO || 1
+#include "mi_opt.h"
+
diff --git a/clang/test/Preprocessor/mi_opt.h b/clang/test/Preprocessor/mi_opt.h
new file mode 100644
index 0000000..a82aa6a
--- /dev/null
+++ b/clang/test/Preprocessor/mi_opt.h
@@ -0,0 +1,4 @@
+#if !defined foo MACRO
+#define foo
+int x = 2;
+#endif
diff --git a/clang/test/Preprocessor/mi_opt2.c b/clang/test/Preprocessor/mi_opt2.c
new file mode 100644
index 0000000..198d19f
--- /dev/null
+++ b/clang/test/Preprocessor/mi_opt2.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -E %s | FileCheck %s
+// PR6282
+// This test should not trigger the include guard optimization since
+// the guard macro is defined on the first include.
+
+#define ITERATING 1
+#define X 1
+#include "mi_opt2.h"
+#undef X
+#define X 2
+#include "mi_opt2.h"
+
+// CHECK: b: 1
+// CHECK: b: 2
+
diff --git a/clang/test/Preprocessor/mi_opt2.h b/clang/test/Preprocessor/mi_opt2.h
new file mode 100644
index 0000000..df37eba
--- /dev/null
+++ b/clang/test/Preprocessor/mi_opt2.h
@@ -0,0 +1,5 @@
+#ifndef ITERATING
+a: X
+#else
+b: X
+#endif
diff --git a/clang/test/Preprocessor/microsoft-import.c b/clang/test/Preprocessor/microsoft-import.c
new file mode 100644
index 0000000..8835c7a
--- /dev/null
+++ b/clang/test/Preprocessor/microsoft-import.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -E -fms-compatibility %s 2>&1 | grep 'doh.c:100:2: error: #import of type library is an unsupported Microsoft feature'
+// RUN: %clang_cc1 -E -fms-compatibility %s 2>&1 | grep 'doh.c:200:2: error: #import of type library is an unsupported Microsoft feature'
+// RUN: %clang_cc1 -E -fms-compatibility %s 2>&1 | grep 'doh.c:300:2: error: #import of type library is an unsupported Microsoft feature'
+
+#line 100 "doh.c"
+#import "pp-record.h" // expected-error {{#import of type library is an unsupported Microsoft feature}}
+
+// Test attributes
+#line 200 "doh.c"
+#import "pp-record.h" no_namespace, auto_rename // expected-error {{#import of type library is an unsupported Microsoft feature}}
+
+// This will also fire the "#import of type library is an unsupported Microsoft feature"
+// error, but we can't use -verify because there's no way to put the comment on the proper line
+#line 300 "doh.c"
+#import "pp-record.h" no_namespace \
+ auto_rename \
+ auto_search
diff --git a/clang/test/Preprocessor/missing-system-header.c b/clang/test/Preprocessor/missing-system-header.c
new file mode 100644
index 0000000..69cb131
--- /dev/null
+++ b/clang/test/Preprocessor/missing-system-header.c
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+#include "missing-system-header.h"
diff --git a/clang/test/Preprocessor/missing-system-header.h b/clang/test/Preprocessor/missing-system-header.h
new file mode 100644
index 0000000..393ab2b
--- /dev/null
+++ b/clang/test/Preprocessor/missing-system-header.h
@@ -0,0 +1,2 @@
+#pragma clang system_header
+#include "not exist" // expected-error {{file not found}}
diff --git a/clang/test/Preprocessor/mmx.c b/clang/test/Preprocessor/mmx.c
new file mode 100644
index 0000000..2613cb6
--- /dev/null
+++ b/clang/test/Preprocessor/mmx.c
@@ -0,0 +1,13 @@
+// RUN: %clang -march=i386 -m32 -E -dM %s -msse -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=SSE_AND_MMX
+// RUN: %clang -march=i386 -m32 -E -dM %s -msse -mno-mmx -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=SSE_NO_MMX
+// RUN: %clang -march=i386 -m32 -E -dM %s -mno-mmx -msse -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=SSE_NO_MMX
+
+// SSE_AND_MMX: #define __MMX__
+// SSE_AND_MMX: #define __SSE__
+
+// SSE_NO_MMX-NOT: __MMX__
+// SSE_NO_MMX: __SSE__
+// SSE_NO_MMX-NOT: __MMX__
diff --git a/clang/test/Preprocessor/non_fragile_feature.m b/clang/test/Preprocessor/non_fragile_feature.m
new file mode 100644
index 0000000..cf64df2
--- /dev/null
+++ b/clang/test/Preprocessor/non_fragile_feature.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s
+#ifndef __has_feature
+#error Should have __has_feature
+#endif
+
+#if !__has_feature(objc_nonfragile_abi)
+#error Non-fragile ABI used for compilation but feature macro not set.
+#endif
+
+#if !__has_feature(objc_weak_class)
+#error objc_weak_class should be enabled with nonfragile abi
+#endif
diff --git a/clang/test/Preprocessor/non_fragile_feature1.m b/clang/test/Preprocessor/non_fragile_feature1.m
new file mode 100644
index 0000000..79cc488
--- /dev/null
+++ b/clang/test/Preprocessor/non_fragile_feature1.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-fragile-abi %s
+#ifndef __has_feature
+#error Should have __has_feature
+#endif
+
+#if __has_feature(objc_nonfragile_abi)
+#error Non-fragile ABI not used for compilation but feature macro set.
+#endif
diff --git a/clang/test/Preprocessor/objc-pp.m b/clang/test/Preprocessor/objc-pp.m
new file mode 100644
index 0000000..0ec288c
--- /dev/null
+++ b/clang/test/Preprocessor/objc-pp.m
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -ffreestanding
+
+#import <stdint.h> // no warning on #import in objc mode.
+
diff --git a/clang/test/Preprocessor/optimize.c b/clang/test/Preprocessor/optimize.c
new file mode 100644
index 0000000..97f841a
--- /dev/null
+++ b/clang/test/Preprocessor/optimize.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -Eonly %s -DOPT_O2 -O2 -verify
+#ifdef OPT_O2
+ #ifndef __OPTIMIZE__
+ #error "__OPTIMIZE__ not defined"
+ #endif
+ #ifdef __OPTIMIZE_SIZE__
+ #error "__OPTIMIZE_SIZE__ defined"
+ #endif
+#endif
+
+// RUN: %clang_cc1 -Eonly %s -DOPT_O0 -O0 -verify
+#ifdef OPT_O0
+ #ifdef __OPTIMIZE__
+ #error "__OPTIMIZE__ defined"
+ #endif
+ #ifdef __OPTIMIZE_SIZE__
+ #error "__OPTIMIZE_SIZE__ defined"
+ #endif
+#endif
+
+// RUN: %clang_cc1 -Eonly %s -DOPT_OS -Os -verify
+#ifdef OPT_OS
+ #ifndef __OPTIMIZE__
+ #error "__OPTIMIZE__ not defined"
+ #endif
+ #ifndef __OPTIMIZE_SIZE__
+ #error "__OPTIMIZE_SIZE__ not defined"
+ #endif
+#endif
diff --git a/clang/test/Preprocessor/output_paste_avoid.c b/clang/test/Preprocessor/output_paste_avoid.c
new file mode 100644
index 0000000..8e4f3a4
--- /dev/null
+++ b/clang/test/Preprocessor/output_paste_avoid.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -E %s -o - | FileCheck -strict-whitespace %s
+
+
+#define y(a) ..a
+A: y(.)
+// This should print as ".. ." to avoid turning into ...
+// CHECK: A: .. .
+
+#define X 0 .. 1
+B: X
+// CHECK: B: 0 .. 1
+
+#define DOT .
+C: ..DOT
+// CHECK: C: .. .
+
+
+#define PLUS +
+#define EMPTY
+#define f(x) =x=
+D: +PLUS -EMPTY- PLUS+ f(=)
+// CHECK: D: + + - - + + = = =
+
+
+#define test(x) L#x
+E: test(str)
+// Should expand to L "str" not L"str"
+// CHECK: E: L "str"
+
+// Should avoid producing >>=.
+#define equal =
+F: >>equal
+// CHECK: F: >> =
diff --git a/clang/test/Preprocessor/overflow.c b/clang/test/Preprocessor/overflow.c
new file mode 100644
index 0000000..a921441
--- /dev/null
+++ b/clang/test/Preprocessor/overflow.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -Eonly %s -verify -triple i686-pc-linux-gnu
+
+// Multiply signed overflow
+#if 0x7FFFFFFFFFFFFFFF*2 // expected-warning {{overflow}}
+#endif
+
+// Multiply unsigned overflow
+#if 0xFFFFFFFFFFFFFFFF*2
+#endif
+
+// Add signed overflow
+#if 0x7FFFFFFFFFFFFFFF+1 // expected-warning {{overflow}}
+#endif
+
+// Add unsigned overflow
+#if 0xFFFFFFFFFFFFFFFF+1
+#endif
+
+// Subtract signed overflow
+#if 0x7FFFFFFFFFFFFFFF- -1 // expected-warning {{overflow}}
+#endif
+
+// Subtract unsigned overflow
+#if 0xFFFFFFFFFFFFFFFF- -1 // expected-warning {{converted from negative value}}
+#endif
diff --git a/clang/test/Preprocessor/pic.c b/clang/test/Preprocessor/pic.c
new file mode 100644
index 0000000..3e649ee
--- /dev/null
+++ b/clang/test/Preprocessor/pic.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -dM -E -o - %s \
+// RUN: | FileCheck %s
+// CHECK-NOT: #define __PIC__
+// CHECK-NOT: #define __PIE__
+// CHECK-NOT: #define __pic__
+// CHECK-NOT: #define __pie__
+//
+// RUN: %clang_cc1 -pic-level 1 -dM -E -o - %s \
+// RUN: | FileCheck --check-prefix=CHECK-PIC1 %s
+// CHECK-PIC1: #define __PIC__ 1
+// CHECK-PIC1-NOT: #define __PIE__
+// CHECK-PIC1: #define __pic__ 1
+// CHECK-PIC1-NOT: #define __pie__
+//
+// RUN: %clang_cc1 -pic-level 2 -dM -E -o - %s \
+// RUN: | FileCheck --check-prefix=CHECK-PIC2 %s
+// CHECK-PIC2: #define __PIC__ 2
+// CHECK-PIC2-NOT: #define __PIE__
+// CHECK-PIC2: #define __pic__ 2
+// CHECK-PIC2-NOT: #define __pie__
+//
+// RUN: %clang_cc1 -pie-level 1 -dM -E -o - %s \
+// RUN: | FileCheck --check-prefix=CHECK-PIE1 %s
+// CHECK-PIE1-NOT: #define __PIC__
+// CHECK-PIE1: #define __PIE__ 1
+// CHECK-PIE1-NOT: #define __pic__
+// CHECK-PIE1: #define __pie__ 1
+//
+// RUN: %clang_cc1 -pie-level 2 -dM -E -o - %s \
+// RUN: | FileCheck --check-prefix=CHECK-PIE2 %s
+// CHECK-PIE2-NOT: #define __PIC__
+// CHECK-PIE2: #define __PIE__ 2
+// CHECK-PIE2-NOT: #define __pic__
+// CHECK-PIE2: #define __pie__ 2
diff --git a/clang/test/Preprocessor/pp-record.c b/clang/test/Preprocessor/pp-record.c
new file mode 100644
index 0000000..f098683
--- /dev/null
+++ b/clang/test/Preprocessor/pp-record.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -detailed-preprocessing-record %s
+
+// http://llvm.org/PR11120
+
+#define STRINGIZE(text) STRINGIZE_I(text)
+#define STRINGIZE_I(text) #text
+
+#define INC pp-record.h
+
+#include STRINGIZE(INC)
+
+CAKE;
diff --git a/clang/test/Preprocessor/pp-record.h b/clang/test/Preprocessor/pp-record.h
new file mode 100644
index 0000000..b39a174
--- /dev/null
+++ b/clang/test/Preprocessor/pp-record.h
@@ -0,0 +1,3 @@
+// Only useful for #inclusion.
+
+#define CAKE extern int is_a_lie
diff --git a/clang/test/Preprocessor/pr2086.c b/clang/test/Preprocessor/pr2086.c
new file mode 100644
index 0000000..d438e87
--- /dev/null
+++ b/clang/test/Preprocessor/pr2086.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E %s
+
+#define test
+#include "pr2086.h"
+#define test
+#include "pr2086.h"
+
+#ifdef test
+#error
+#endif
+
diff --git a/clang/test/Preprocessor/pr2086.h b/clang/test/Preprocessor/pr2086.h
new file mode 100644
index 0000000..b98b996
--- /dev/null
+++ b/clang/test/Preprocessor/pr2086.h
@@ -0,0 +1,6 @@
+#ifndef test
+#endif
+
+#ifdef test
+#undef test
+#endif
diff --git a/clang/test/Preprocessor/pragma-pushpop-macro.c b/clang/test/Preprocessor/pragma-pushpop-macro.c
new file mode 100644
index 0000000..08a6570
--- /dev/null
+++ b/clang/test/Preprocessor/pragma-pushpop-macro.c
@@ -0,0 +1,41 @@
+/* Test pragma pop_macro and push_macro directives from
+ http://msdn.microsoft.com/en-us/library/hsttss76.aspx */
+
+// pop_macro: Sets the value of the macro_name macro to the value on the top of
+// the stack for this macro.
+// #pragma pop_macro("macro_name")
+// push_macro: Saves the value of the macro_name macro on the top of the stack
+// for this macro.
+// #pragma push_macro("macro_name")
+//
+// RUN: %clang_cc1 -fms-extensions -E %s -o - | FileCheck %s
+
+#define X 1
+#define Y 2
+int pmx0 = X;
+int pmy0 = Y;
+#define Y 3
+#pragma push_macro("Y")
+#pragma push_macro("X")
+int pmx1 = X;
+#define X 2
+int pmx2 = X;
+#pragma pop_macro("X")
+int pmx3 = X;
+#pragma pop_macro("Y")
+int pmy1 = Y;
+
+// Have a stray 'push' to show we don't crash when having imbalanced
+// push/pop
+#pragma push_macro("Y")
+#define Y 4
+int pmy2 = Y;
+
+// CHECK: int pmx0 = 1
+// CHECK: int pmy0 = 2
+// CHECK: int pmx1 = 1
+// CHECK: int pmx2 = 2
+// CHECK: int pmx3 = 1
+// CHECK: int pmy1 = 3
+// CHECK: int pmy2 = 4
+
diff --git a/clang/test/Preprocessor/pragma_diagnostic.c b/clang/test/Preprocessor/pragma_diagnostic.c
new file mode 100644
index 0000000..818f02f
--- /dev/null
+++ b/clang/test/Preprocessor/pragma_diagnostic.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-undef %s
+// rdar://2362963
+
+#if FOO // ok.
+#endif
+
+#pragma GCC diagnostic warning "-Wundef"
+
+#if FOO // expected-warning {{'FOO' is not defined}}
+#endif
+
+#pragma GCC diagnostic ignored "-Wun" "def"
+
+#if FOO // ok.
+#endif
+
+#pragma GCC diagnostic error "-Wundef"
+
+#if FOO // expected-error {{'FOO' is not defined}}
+#endif
+
+
+#define foo error
+#pragma GCC diagnostic foo "-Wundef" // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'}}
+
+#pragma GCC diagnostic error 42 // expected-warning {{unexpected token in pragma diagnostic}}
+
+#pragma GCC diagnostic error "-Wundef" 42 // expected-warning {{unexpected token in pragma diagnostic}}
+#pragma GCC diagnostic error "invalid-name" // expected-warning {{pragma diagnostic expected option name (e.g. "-Wundef")}}
+
+#pragma GCC diagnostic error "-Winvalid-name" // expected-warning {{unknown warning group '-Winvalid-name', ignored}}
+
diff --git a/clang/test/Preprocessor/pragma_diagnostic_output.c b/clang/test/Preprocessor/pragma_diagnostic_output.c
new file mode 100644
index 0000000..e847107
--- /dev/null
+++ b/clang/test/Preprocessor/pragma_diagnostic_output.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -E %s | FileCheck %s
+// CHECK: #pragma GCC diagnostic warning "-Wall"
+#pragma GCC diagnostic warning "-Wall"
+// CHECK: #pragma GCC diagnostic ignored "-Wall"
+#pragma GCC diagnostic ignored "-Wall"
+// CHECK: #pragma GCC diagnostic error "-Wall"
+#pragma GCC diagnostic error "-Wall"
+// CHECK: #pragma GCC diagnostic fatal "-Wall"
+#pragma GCC diagnostic fatal "-Wall"
+// CHECK: #pragma GCC diagnostic push
+#pragma GCC diagnostic push
+// CHECK: #pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
+
+// CHECK: #pragma clang diagnostic warning "-Wall"
+#pragma clang diagnostic warning "-Wall"
+// CHECK: #pragma clang diagnostic ignored "-Wall"
+#pragma clang diagnostic ignored "-Wall"
+// CHECK: #pragma clang diagnostic error "-Wall"
+#pragma clang diagnostic error "-Wall"
+// CHECK: #pragma clang diagnostic fatal "-Wall"
+#pragma clang diagnostic fatal "-Wall"
+// CHECK: #pragma clang diagnostic push
+#pragma clang diagnostic push
+// CHECK: #pragma clang diagnostic pop
+#pragma clang diagnostic pop
diff --git a/clang/test/Preprocessor/pragma_diagnostic_sections.cpp b/clang/test/Preprocessor/pragma_diagnostic_sections.cpp
new file mode 100644
index 0000000..b680fae
--- /dev/null
+++ b/clang/test/Preprocessor/pragma_diagnostic_sections.cpp
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -fsyntax-only -Wall -Wunused-macros -Wunused-parameter -Wno-uninitialized -verify %s
+
+// rdar://8365684
+struct S {
+ void m1() { int b; while (b==b); } // expected-warning {{always evaluates to true}}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-compare"
+ void m2() { int b; while (b==b); }
+#pragma clang diagnostic pop
+
+ void m3() { int b; while (b==b); } // expected-warning {{always evaluates to true}}
+};
+
+//------------------------------------------------------------------------------
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-compare"
+template <typename T>
+struct TS {
+ void m() { T b; while (b==b); }
+};
+#pragma clang diagnostic pop
+
+void f() {
+ TS<int> ts;
+ ts.m();
+}
+
+//------------------------------------------------------------------------------
+
+#define UNUSED_MACRO1 // expected-warning {{macro is not used}}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-macros"
+#define UNUSED_MACRO2
+#pragma clang diagnostic pop
+
+//------------------------------------------------------------------------------
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wreturn-type"
+int g() { }
+#pragma clang diagnostic pop
+
+//------------------------------------------------------------------------------
+
+void ww(
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-parameter"
+ int x,
+#pragma clang diagnostic pop
+ int y) // expected-warning {{unused}}
+{
+}
+
+//------------------------------------------------------------------------------
+
+struct S2 {
+ int x, y;
+ S2() :
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wreorder"
+ y(),
+ x()
+#pragma clang diagnostic pop
+ {}
+};
+
+//------------------------------------------------------------------------------
+
+// rdar://8790245
+#define MYMACRO \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") \
+ _Pragma("clang diagnostic pop")
+MYMACRO
+#undef MYMACRO
+
+//------------------------------------------------------------------------------
diff --git a/clang/test/Preprocessor/pragma_microsoft.c b/clang/test/Preprocessor/pragma_microsoft.c
new file mode 100644
index 0000000..e461c70
--- /dev/null
+++ b/clang/test/Preprocessor/pragma_microsoft.c
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions
+
+// rdar://6495941
+
+#define FOO 1
+#define BAR "2"
+
+#pragma comment(linker,"foo=" FOO) // expected-error {{pragma comment requires parenthesized identifier and optional string}}
+#pragma comment(linker," bar=" BAR)
+
+#pragma comment( user, "Compiled on " __DATE__ " at " __TIME__ )
+
+#pragma comment(foo) // expected-error {{unknown kind of pragma comment}}
+#pragma comment(compiler,) // expected-error {{pragma comment requires}}
+#define foo compiler
+#pragma comment(foo) // macro expand kind.
+#pragma comment(foo) x // expected-error {{pragma comment requires}}
+
+#pragma comment(user, "foo\abar\nbaz\tsome thing")
+
+
+// __pragma
+
+__pragma(comment(linker," bar=" BAR))
+
+#define MACRO_WITH__PRAGMA { \
+ __pragma(warning(push)); \
+ __pragma(warning(disable: 10000)); \
+ 2+2; \
+ __pragma(warning(pop)); \
+}
+
+void f()
+{
+ __pragma()
+
+ // If we ever actually *support* __pragma(warning(disable: x)),
+ // this warning should go away.
+ MACRO_WITH__PRAGMA // expected-warning {{expression result unused}}
+}
+
+
+// This should include macro_arg_directive even though the include
+// is looking for test.h This allows us to assign to "n"
+#pragma include_alias("test.h", "macro_arg_directive.h" )
+#include "test.h"
+void test( void ) {
+ n = 12;
+}
+
+#pragma include_alias(<bar.h>, "bar.h") // expected-warning {{angle-bracketed include <bar.h> cannot be aliased to double-quoted include "bar.h"}}
+#pragma include_alias("foo.h", <bar.h>) // expected-warning {{double-quoted include "foo.h" cannot be aliased to angle-bracketed include <bar.h>}}
+#pragma include_alias("test.h") // expected-warning {{pragma include_alias expected ','}}
+
+// Make sure that the names match exactly for a replacement, including path information. If
+// this were to fail, we would get a file not found error
+#pragma include_alias(".\pp-record.h", "does_not_exist.h")
+#include "pp-record.h"
+
+#pragma include_alias(12) // expected-warning {{pragma include_alias expected include filename}}
+
+// It's expected that we can map "bar" and <bar> separately
+#define test
+// We can't actually look up stdio.h because we're using cc1 without header paths, but this will ensure
+// that we get the right bar.h, because the "bar.h" will undef test for us, where <bar.h> won't
+#pragma include_alias(<bar.h>, <stdio.h>)
+#pragma include_alias("bar.h", "pr2086.h") // This should #undef test
+
+#include "bar.h"
+#if defined(test)
+// This should not warn because test should not be defined
+#pragma include_alias("test.h")
+#endif
+
+// Test to make sure there are no use-after-free problems
+#define B "pp-record.h"
+#pragma include_alias("quux.h", B)
+void g() {}
+#include "quux.h"
+
+// Make sure that empty includes don't work
+#pragma include_alias("", "foo.h") // expected-error {{empty filename}}
+#pragma include_alias(<foo.h>, <>) // expected-error {{empty filename}}
diff --git a/clang/test/Preprocessor/pragma_poison.c b/clang/test/Preprocessor/pragma_poison.c
new file mode 100644
index 0000000..5b39183
--- /dev/null
+++ b/clang/test/Preprocessor/pragma_poison.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -Eonly -verify
+
+#pragma GCC poison rindex
+rindex(some_string, 'h'); // expected-error {{attempt to use a poisoned identifier}}
+
+#define BAR _Pragma ("GCC poison XYZW") XYZW /*NO ERROR*/
+ XYZW // ok
+BAR
+ XYZW // expected-error {{attempt to use a poisoned identifier}}
+
+// Pragma poison shouldn't warn from macro expansions defined before the token
+// is poisoned.
+
+#define strrchr rindex2
+#pragma GCC poison rindex2
+
+// Can poison multiple times.
+#pragma GCC poison rindex2
+
+strrchr(some_string, 'h'); // ok.
diff --git a/clang/test/Preprocessor/pragma_sysheader.c b/clang/test/Preprocessor/pragma_sysheader.c
new file mode 100644
index 0000000..17080fe
--- /dev/null
+++ b/clang/test/Preprocessor/pragma_sysheader.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -verify -pedantic %s -fsyntax-only
+// RUN: %clang_cc1 -E %s | FileCheck %s
+// rdar://6899937
+#include "pragma_sysheader.h"
+
+
+// PR9861: Verify that line markers are not messed up in -E mode.
+// CHECK: # 1 "{{.*}}pragma_sysheader.h" 1
+// CHECK-NEXT: # 1 "{{.*}}pragma_sysheader.h" 3
+// CHECK-NEXT: typedef int x;
+// CHECK-NEXT: typedef int x;
+// CHECK-NEXT: # 5 "{{.*}}pragma_sysheader.c" 2
diff --git a/clang/test/Preprocessor/pragma_sysheader.h b/clang/test/Preprocessor/pragma_sysheader.h
new file mode 100644
index 0000000..b79bde5
--- /dev/null
+++ b/clang/test/Preprocessor/pragma_sysheader.h
@@ -0,0 +1,4 @@
+#pragma GCC system_header
+typedef int x;
+typedef int x;
+
diff --git a/clang/test/Preprocessor/pragma_unknown.c b/clang/test/Preprocessor/pragma_unknown.c
new file mode 100644
index 0000000..2586754
--- /dev/null
+++ b/clang/test/Preprocessor/pragma_unknown.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -E %s | grep '#pragma foo bar'
+// RUN: %clang_cc1 -fsyntax-only -Wunknown-pragmas -verify %s
+
+// GCC doesn't expand macro args for unrecognized pragmas.
+#define bar xX
+#pragma foo bar // expected-warning {{unknown pragma ignored}}
+
+#pragma STDC FP_CONTRACT ON
+#pragma STDC FP_CONTRACT OFF
+#pragma STDC FP_CONTRACT DEFAULT
+#pragma STDC FP_CONTRACT IN_BETWEEN // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}}
+
+#pragma STDC FENV_ACCESS ON // expected-warning {{pragma STDC FENV_ACCESS ON is not supported, ignoring pragma}}
+#pragma STDC FENV_ACCESS OFF
+#pragma STDC FENV_ACCESS DEFAULT
+#pragma STDC FENV_ACCESS IN_BETWEEN // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}}
+
+#pragma STDC CX_LIMITED_RANGE ON
+#pragma STDC CX_LIMITED_RANGE OFF
+#pragma STDC CX_LIMITED_RANGE DEFAULT
+#pragma STDC CX_LIMITED_RANGE IN_BETWEEN // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}}
+
+#pragma STDC CX_LIMITED_RANGE // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}}
+#pragma STDC CX_LIMITED_RANGE ON FULL POWER // expected-warning {{expected end of directive in pragma}}
+
+#pragma STDC SO_GREAT // expected-warning {{unknown pragma in STDC namespace}}
+#pragma STDC // expected-warning {{unknown pragma in STDC namespace}}
+
diff --git a/clang/test/Preprocessor/predefined-arch-macros.c b/clang/test/Preprocessor/predefined-arch-macros.c
new file mode 100644
index 0000000..b063f7f
--- /dev/null
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -0,0 +1,866 @@
+// These tests are generated by running utils/generate_arch_predefine_tests.sh
+// to observe GCC's behavior (or some other system compiler's behavior).
+//
+// Begin X86/GCC/Linux tests ----------------
+//
+// RUN: %clang -march=i386 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_I386_M32
+// CHECK_I386_M32: #define __i386 1
+// CHECK_I386_M32: #define __i386__ 1
+// CHECK_I386_M32: #define __tune_i386__ 1
+// CHECK_I386_M32: #define i386 1
+// RUN: %clang -march=i386 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_I386_M64
+// CHECK_I386_M64: error:
+//
+// RUN: %clang -march=i486 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_I486_M32
+// CHECK_I486_M32: #define __i386 1
+// CHECK_I486_M32: #define __i386__ 1
+// CHECK_I486_M32: #define __i486 1
+// CHECK_I486_M32: #define __i486__ 1
+// CHECK_I486_M32: #define __tune_i486__ 1
+// CHECK_I486_M32: #define i386 1
+// RUN: %clang -march=i486 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_I486_M64
+// CHECK_I486_M64: error:
+//
+// RUN: %clang -march=i586 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_I586_M32
+// CHECK_I586_M32: #define __i386 1
+// CHECK_I586_M32: #define __i386__ 1
+// CHECK_I586_M32: #define __i586 1
+// CHECK_I586_M32: #define __i586__ 1
+// CHECK_I586_M32: #define __pentium 1
+// CHECK_I586_M32: #define __pentium__ 1
+// CHECK_I586_M32: #define __tune_i586__ 1
+// CHECK_I586_M32: #define __tune_pentium__ 1
+// CHECK_I586_M32: #define i386 1
+// RUN: %clang -march=i586 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_I586_M64
+// CHECK_I586_M64: error:
+//
+// RUN: %clang -march=pentium -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM_M32
+// CHECK_PENTIUM_M32: #define __i386 1
+// CHECK_PENTIUM_M32: #define __i386__ 1
+// CHECK_PENTIUM_M32: #define __i586 1
+// CHECK_PENTIUM_M32: #define __i586__ 1
+// CHECK_PENTIUM_M32: #define __pentium 1
+// CHECK_PENTIUM_M32: #define __pentium__ 1
+// CHECK_PENTIUM_M32: #define __tune_i586__ 1
+// CHECK_PENTIUM_M32: #define __tune_pentium__ 1
+// CHECK_PENTIUM_M32: #define i386 1
+// RUN: %clang -march=pentium -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM_M64
+// CHECK_PENTIUM_M64: error:
+//
+// RUN: %clang -march=pentium-mmx -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM_MMX_M32
+// CHECK_PENTIUM_MMX_M32: #define __MMX__ 1
+// CHECK_PENTIUM_MMX_M32: #define __i386 1
+// CHECK_PENTIUM_MMX_M32: #define __i386__ 1
+// CHECK_PENTIUM_MMX_M32: #define __i586 1
+// CHECK_PENTIUM_MMX_M32: #define __i586__ 1
+// CHECK_PENTIUM_MMX_M32: #define __pentium 1
+// CHECK_PENTIUM_MMX_M32: #define __pentium__ 1
+// CHECK_PENTIUM_MMX_M32: #define __pentium_mmx__ 1
+// CHECK_PENTIUM_MMX_M32: #define __tune_i586__ 1
+// CHECK_PENTIUM_MMX_M32: #define __tune_pentium__ 1
+// CHECK_PENTIUM_MMX_M32: #define __tune_pentium_mmx__ 1
+// CHECK_PENTIUM_MMX_M32: #define i386 1
+// RUN: %clang -march=pentium-mmx -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM_MMX_M64
+// CHECK_PENTIUM_MMX_M64: error:
+//
+// RUN: %clang -march=winchip-c6 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_WINCHIP_C6_M32
+// CHECK_WINCHIP_C6_M32: #define __MMX__ 1
+// CHECK_WINCHIP_C6_M32: #define __i386 1
+// CHECK_WINCHIP_C6_M32: #define __i386__ 1
+// CHECK_WINCHIP_C6_M32: #define __i486 1
+// CHECK_WINCHIP_C6_M32: #define __i486__ 1
+// CHECK_WINCHIP_C6_M32: #define __tune_i486__ 1
+// CHECK_WINCHIP_C6_M32: #define i386 1
+// RUN: %clang -march=winchip-c6 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_WINCHIP_C6_M64
+// CHECK_WINCHIP_C6_M64: error:
+//
+// RUN: %clang -march=winchip2 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_WINCHIP2_M32
+// CHECK_WINCHIP2_M32: #define __3dNOW__ 1
+// CHECK_WINCHIP2_M32: #define __MMX__ 1
+// CHECK_WINCHIP2_M32: #define __i386 1
+// CHECK_WINCHIP2_M32: #define __i386__ 1
+// CHECK_WINCHIP2_M32: #define __i486 1
+// CHECK_WINCHIP2_M32: #define __i486__ 1
+// CHECK_WINCHIP2_M32: #define __tune_i486__ 1
+// CHECK_WINCHIP2_M32: #define i386 1
+// RUN: %clang -march=winchip2 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_WINCHIP2_M64
+// CHECK_WINCHIP2_M64: error:
+//
+// RUN: %clang -march=c3 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_C3_M32
+// CHECK_C3_M32: #define __3dNOW__ 1
+// CHECK_C3_M32: #define __MMX__ 1
+// CHECK_C3_M32: #define __i386 1
+// CHECK_C3_M32: #define __i386__ 1
+// CHECK_C3_M32: #define __i486 1
+// CHECK_C3_M32: #define __i486__ 1
+// CHECK_C3_M32: #define __tune_i486__ 1
+// CHECK_C3_M32: #define i386 1
+// RUN: %clang -march=c3 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_C3_M64
+// CHECK_C3_M64: error:
+//
+// RUN: %clang -march=c3-2 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_C3_2_M32
+// CHECK_C3_2_M32: #define __MMX__ 1
+// CHECK_C3_2_M32: #define __SSE__ 1
+// CHECK_C3_2_M32: #define __i386 1
+// CHECK_C3_2_M32: #define __i386__ 1
+// CHECK_C3_2_M32: #define __i686 1
+// CHECK_C3_2_M32: #define __i686__ 1
+// CHECK_C3_2_M32: #define __pentiumpro 1
+// CHECK_C3_2_M32: #define __pentiumpro__ 1
+// CHECK_C3_2_M32: #define __tune_i686__ 1
+// CHECK_C3_2_M32: #define __tune_pentium2__ 1
+// CHECK_C3_2_M32: #define __tune_pentiumpro__ 1
+// CHECK_C3_2_M32: #define i386 1
+// RUN: %clang -march=c3-2 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_C3_2_M64
+// CHECK_C3_2_M64: error:
+//
+// RUN: %clang -march=i686 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_I686_M32
+// CHECK_I686_M32: #define __i386 1
+// CHECK_I686_M32: #define __i386__ 1
+// CHECK_I686_M32: #define __i686 1
+// CHECK_I686_M32: #define __i686__ 1
+// CHECK_I686_M32: #define __pentiumpro 1
+// CHECK_I686_M32: #define __pentiumpro__ 1
+// CHECK_I686_M32: #define i386 1
+// RUN: %clang -march=i686 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_I686_M64
+// CHECK_I686_M64: error:
+//
+// RUN: %clang -march=pentiumpro -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUMPRO_M32
+// CHECK_PENTIUMPRO_M32: #define __i386 1
+// CHECK_PENTIUMPRO_M32: #define __i386__ 1
+// CHECK_PENTIUMPRO_M32: #define __i686 1
+// CHECK_PENTIUMPRO_M32: #define __i686__ 1
+// CHECK_PENTIUMPRO_M32: #define __pentiumpro 1
+// CHECK_PENTIUMPRO_M32: #define __pentiumpro__ 1
+// CHECK_PENTIUMPRO_M32: #define __tune_i686__ 1
+// CHECK_PENTIUMPRO_M32: #define __tune_pentiumpro__ 1
+// CHECK_PENTIUMPRO_M32: #define i386 1
+// RUN: %clang -march=pentiumpro -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUMPRO_M64
+// CHECK_PENTIUMPRO_M64: error:
+//
+// RUN: %clang -march=pentium2 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM2_M32
+// CHECK_PENTIUM2_M32: #define __MMX__ 1
+// CHECK_PENTIUM2_M32: #define __i386 1
+// CHECK_PENTIUM2_M32: #define __i386__ 1
+// CHECK_PENTIUM2_M32: #define __i686 1
+// CHECK_PENTIUM2_M32: #define __i686__ 1
+// CHECK_PENTIUM2_M32: #define __pentiumpro 1
+// CHECK_PENTIUM2_M32: #define __pentiumpro__ 1
+// CHECK_PENTIUM2_M32: #define __tune_i686__ 1
+// CHECK_PENTIUM2_M32: #define __tune_pentium2__ 1
+// CHECK_PENTIUM2_M32: #define __tune_pentiumpro__ 1
+// CHECK_PENTIUM2_M32: #define i386 1
+// RUN: %clang -march=pentium2 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM2_M64
+// CHECK_PENTIUM2_M64: error:
+//
+// RUN: %clang -march=pentium3 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM3_M32
+// CHECK_PENTIUM3_M32: #define __MMX__ 1
+// CHECK_PENTIUM3_M32: #define __SSE__ 1
+// CHECK_PENTIUM3_M32: #define __i386 1
+// CHECK_PENTIUM3_M32: #define __i386__ 1
+// CHECK_PENTIUM3_M32: #define __i686 1
+// CHECK_PENTIUM3_M32: #define __i686__ 1
+// CHECK_PENTIUM3_M32: #define __pentiumpro 1
+// CHECK_PENTIUM3_M32: #define __pentiumpro__ 1
+// CHECK_PENTIUM3_M32: #define __tune_i686__ 1
+// CHECK_PENTIUM3_M32: #define __tune_pentium2__ 1
+// CHECK_PENTIUM3_M32: #define __tune_pentium3__ 1
+// CHECK_PENTIUM3_M32: #define __tune_pentiumpro__ 1
+// CHECK_PENTIUM3_M32: #define i386 1
+// RUN: %clang -march=pentium3 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM3_M64
+// CHECK_PENTIUM3_M64: error:
+//
+// RUN: %clang -march=pentium3m -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM3M_M32
+// CHECK_PENTIUM3M_M32: #define __MMX__ 1
+// CHECK_PENTIUM3M_M32: #define __SSE__ 1
+// CHECK_PENTIUM3M_M32: #define __i386 1
+// CHECK_PENTIUM3M_M32: #define __i386__ 1
+// CHECK_PENTIUM3M_M32: #define __i686 1
+// CHECK_PENTIUM3M_M32: #define __i686__ 1
+// CHECK_PENTIUM3M_M32: #define __pentiumpro 1
+// CHECK_PENTIUM3M_M32: #define __pentiumpro__ 1
+// CHECK_PENTIUM3M_M32: #define __tune_i686__ 1
+// CHECK_PENTIUM3M_M32: #define __tune_pentiumpro__ 1
+// CHECK_PENTIUM3M_M32: #define i386 1
+// RUN: %clang -march=pentium3m -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM3M_M64
+// CHECK_PENTIUM3M_M64: error:
+//
+// RUN: %clang -march=pentium-m -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM_M_M32
+// CHECK_PENTIUM_M_M32: #define __MMX__ 1
+// CHECK_PENTIUM_M_M32: #define __SSE2__ 1
+// CHECK_PENTIUM_M_M32: #define __SSE__ 1
+// CHECK_PENTIUM_M_M32: #define __i386 1
+// CHECK_PENTIUM_M_M32: #define __i386__ 1
+// CHECK_PENTIUM_M_M32: #define __i686 1
+// CHECK_PENTIUM_M_M32: #define __i686__ 1
+// CHECK_PENTIUM_M_M32: #define __pentiumpro 1
+// CHECK_PENTIUM_M_M32: #define __pentiumpro__ 1
+// CHECK_PENTIUM_M_M32: #define __tune_i686__ 1
+// CHECK_PENTIUM_M_M32: #define __tune_pentiumpro__ 1
+// CHECK_PENTIUM_M_M32: #define i386 1
+// RUN: %clang -march=pentium-m -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM_M_M64
+// CHECK_PENTIUM_M_M64: error:
+//
+// RUN: %clang -march=pentium4 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM4_M32
+// CHECK_PENTIUM4_M32: #define __MMX__ 1
+// CHECK_PENTIUM4_M32: #define __SSE2__ 1
+// CHECK_PENTIUM4_M32: #define __SSE__ 1
+// CHECK_PENTIUM4_M32: #define __i386 1
+// CHECK_PENTIUM4_M32: #define __i386__ 1
+// CHECK_PENTIUM4_M32: #define __pentium4 1
+// CHECK_PENTIUM4_M32: #define __pentium4__ 1
+// CHECK_PENTIUM4_M32: #define __tune_pentium4__ 1
+// CHECK_PENTIUM4_M32: #define i386 1
+// RUN: %clang -march=pentium4 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM4_M64
+// CHECK_PENTIUM4_M64: error:
+//
+// RUN: %clang -march=pentium4m -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM4M_M32
+// CHECK_PENTIUM4M_M32: #define __MMX__ 1
+// CHECK_PENTIUM4M_M32: #define __SSE2__ 1
+// CHECK_PENTIUM4M_M32: #define __SSE__ 1
+// CHECK_PENTIUM4M_M32: #define __i386 1
+// CHECK_PENTIUM4M_M32: #define __i386__ 1
+// CHECK_PENTIUM4M_M32: #define __pentium4 1
+// CHECK_PENTIUM4M_M32: #define __pentium4__ 1
+// CHECK_PENTIUM4M_M32: #define __tune_pentium4__ 1
+// CHECK_PENTIUM4M_M32: #define i386 1
+// RUN: %clang -march=pentium4m -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM4M_M64
+// CHECK_PENTIUM4M_M64: error:
+//
+// RUN: %clang -march=prescott -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PRESCOTT_M32
+// CHECK_PRESCOTT_M32: #define __MMX__ 1
+// CHECK_PRESCOTT_M32: #define __SSE2__ 1
+// CHECK_PRESCOTT_M32: #define __SSE3__ 1
+// CHECK_PRESCOTT_M32: #define __SSE__ 1
+// CHECK_PRESCOTT_M32: #define __i386 1
+// CHECK_PRESCOTT_M32: #define __i386__ 1
+// CHECK_PRESCOTT_M32: #define __nocona 1
+// CHECK_PRESCOTT_M32: #define __nocona__ 1
+// CHECK_PRESCOTT_M32: #define __tune_nocona__ 1
+// CHECK_PRESCOTT_M32: #define i386 1
+// RUN: %clang -march=prescott -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_PRESCOTT_M64
+// CHECK_PRESCOTT_M64: error:
+//
+// RUN: %clang -march=nocona -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_NOCONA_M32
+// CHECK_NOCONA_M32: #define __MMX__ 1
+// CHECK_NOCONA_M32: #define __SSE2__ 1
+// CHECK_NOCONA_M32: #define __SSE3__ 1
+// CHECK_NOCONA_M32: #define __SSE__ 1
+// CHECK_NOCONA_M32: #define __i386 1
+// CHECK_NOCONA_M32: #define __i386__ 1
+// CHECK_NOCONA_M32: #define __nocona 1
+// CHECK_NOCONA_M32: #define __nocona__ 1
+// CHECK_NOCONA_M32: #define __tune_nocona__ 1
+// CHECK_NOCONA_M32: #define i386 1
+// RUN: %clang -march=nocona -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_NOCONA_M64
+// CHECK_NOCONA_M64: #define __MMX__ 1
+// CHECK_NOCONA_M64: #define __SSE2_MATH__ 1
+// CHECK_NOCONA_M64: #define __SSE2__ 1
+// CHECK_NOCONA_M64: #define __SSE3__ 1
+// CHECK_NOCONA_M64: #define __SSE_MATH__ 1
+// CHECK_NOCONA_M64: #define __SSE__ 1
+// CHECK_NOCONA_M64: #define __amd64 1
+// CHECK_NOCONA_M64: #define __amd64__ 1
+// CHECK_NOCONA_M64: #define __nocona 1
+// CHECK_NOCONA_M64: #define __nocona__ 1
+// CHECK_NOCONA_M64: #define __tune_nocona__ 1
+// CHECK_NOCONA_M64: #define __x86_64 1
+// CHECK_NOCONA_M64: #define __x86_64__ 1
+//
+// RUN: %clang -march=core2 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_CORE2_M32
+// CHECK_CORE2_M32: #define __MMX__ 1
+// CHECK_CORE2_M32: #define __SSE2__ 1
+// CHECK_CORE2_M32: #define __SSE3__ 1
+// CHECK_CORE2_M32: #define __SSE__ 1
+// CHECK_CORE2_M32: #define __SSSE3__ 1
+// CHECK_CORE2_M32: #define __core2 1
+// CHECK_CORE2_M32: #define __core2__ 1
+// CHECK_CORE2_M32: #define __i386 1
+// CHECK_CORE2_M32: #define __i386__ 1
+// CHECK_CORE2_M32: #define __tune_core2__ 1
+// CHECK_CORE2_M32: #define i386 1
+// RUN: %clang -march=core2 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_CORE2_M64
+// CHECK_CORE2_M64: #define __MMX__ 1
+// CHECK_CORE2_M64: #define __SSE2_MATH__ 1
+// CHECK_CORE2_M64: #define __SSE2__ 1
+// CHECK_CORE2_M64: #define __SSE3__ 1
+// CHECK_CORE2_M64: #define __SSE_MATH__ 1
+// CHECK_CORE2_M64: #define __SSE__ 1
+// CHECK_CORE2_M64: #define __SSSE3__ 1
+// CHECK_CORE2_M64: #define __amd64 1
+// CHECK_CORE2_M64: #define __amd64__ 1
+// CHECK_CORE2_M64: #define __core2 1
+// CHECK_CORE2_M64: #define __core2__ 1
+// CHECK_CORE2_M64: #define __tune_core2__ 1
+// CHECK_CORE2_M64: #define __x86_64 1
+// CHECK_CORE2_M64: #define __x86_64__ 1
+//
+// RUN: %clang -march=corei7 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_COREI7_M32
+// CHECK_COREI7_M32: #define __MMX__ 1
+// CHECK_COREI7_M32: #define __SSE2__ 1
+// CHECK_COREI7_M32: #define __SSE3__ 1
+// CHECK_COREI7_M32: #define __SSE4_1__ 1
+// CHECK_COREI7_M32: #define __SSE4_2__ 1
+// CHECK_COREI7_M32: #define __SSE__ 1
+// CHECK_COREI7_M32: #define __SSSE3__ 1
+// CHECK_COREI7_M32: #define __corei7 1
+// CHECK_COREI7_M32: #define __corei7__ 1
+// CHECK_COREI7_M32: #define __i386 1
+// CHECK_COREI7_M32: #define __i386__ 1
+// CHECK_COREI7_M32: #define __tune_corei7__ 1
+// CHECK_COREI7_M32: #define i386 1
+// RUN: %clang -march=corei7 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_COREI7_M64
+// CHECK_COREI7_M64: #define __MMX__ 1
+// CHECK_COREI7_M64: #define __SSE2_MATH__ 1
+// CHECK_COREI7_M64: #define __SSE2__ 1
+// CHECK_COREI7_M64: #define __SSE3__ 1
+// CHECK_COREI7_M64: #define __SSE4_1__ 1
+// CHECK_COREI7_M64: #define __SSE4_2__ 1
+// CHECK_COREI7_M64: #define __SSE_MATH__ 1
+// CHECK_COREI7_M64: #define __SSE__ 1
+// CHECK_COREI7_M64: #define __SSSE3__ 1
+// CHECK_COREI7_M64: #define __amd64 1
+// CHECK_COREI7_M64: #define __amd64__ 1
+// CHECK_COREI7_M64: #define __corei7 1
+// CHECK_COREI7_M64: #define __corei7__ 1
+// CHECK_COREI7_M64: #define __tune_corei7__ 1
+// CHECK_COREI7_M64: #define __x86_64 1
+// CHECK_COREI7_M64: #define __x86_64__ 1
+//
+// RUN: %clang -march=corei7-avx -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_COREI7_AVX_M32
+// CHECK_COREI7_AVX_M32: #define __AES__ 1
+// FIXME: AVX is not yet enabled with Clang.
+// CHECK_COREI7_AVX_M32-NOT: #define __AVX__ 1
+// CHECK_COREI7_AVX_M32: #define __MMX__ 1
+// CHECK_COREI7_AVX_M32: #define __SSE2__ 1
+// CHECK_COREI7_AVX_M32: #define __SSE3__ 1
+// CHECK_COREI7_AVX_M32: #define __SSE4_1__ 1
+// CHECK_COREI7_AVX_M32: #define __SSE4_2__ 1
+// CHECK_COREI7_AVX_M32: #define __SSE__ 1
+// CHECK_COREI7_AVX_M32: #define __SSSE3__ 1
+// CHECK_COREI7_AVX_M32: #define __corei7 1
+// CHECK_COREI7_AVX_M32: #define __corei7__ 1
+// CHECK_COREI7_AVX_M32: #define __i386 1
+// CHECK_COREI7_AVX_M32: #define __i386__ 1
+// CHECK_COREI7_AVX_M32: #define __tune_corei7__ 1
+// CHECK_COREI7_AVX_M32: #define i386 1
+// RUN: %clang -march=corei7-avx -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_COREI7_AVX_M64
+// CHECK_COREI7_AVX_M64: #define __AES__ 1
+// FIXME: AVX is not yet enabled with Clang.
+// CHECK_COREI7_AVX_M64-NOT: #define __AVX__ 1
+// CHECK_COREI7_AVX_M64: #define __MMX__ 1
+// CHECK_COREI7_AVX_M64: #define __SSE2_MATH__ 1
+// CHECK_COREI7_AVX_M64: #define __SSE2__ 1
+// CHECK_COREI7_AVX_M64: #define __SSE3__ 1
+// CHECK_COREI7_AVX_M64: #define __SSE4_1__ 1
+// CHECK_COREI7_AVX_M64: #define __SSE4_2__ 1
+// CHECK_COREI7_AVX_M64: #define __SSE_MATH__ 1
+// CHECK_COREI7_AVX_M64: #define __SSE__ 1
+// CHECK_COREI7_AVX_M64: #define __SSSE3__ 1
+// CHECK_COREI7_AVX_M64: #define __amd64 1
+// CHECK_COREI7_AVX_M64: #define __amd64__ 1
+// CHECK_COREI7_AVX_M64: #define __corei7 1
+// CHECK_COREI7_AVX_M64: #define __corei7__ 1
+// CHECK_COREI7_AVX_M64: #define __tune_corei7__ 1
+// CHECK_COREI7_AVX_M64: #define __x86_64 1
+// CHECK_COREI7_AVX_M64: #define __x86_64__ 1
+//
+// RUN: %clang -march=core-avx-i -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_CORE_AVX_I_M32
+// CHECK_CORE_AVX_I_M32: #define __AES__ 1
+// FIXME: AVX is not yet enabled with Clang.
+// CHECK_CORE_AVX_I_M32-NOT: #define __AVX__ 1
+// CHECK_CORE_AVX_I_M32: #define __MMX__ 1
+// CHECK_CORE_AVX_I_M32: #define __SSE2__ 1
+// CHECK_CORE_AVX_I_M32: #define __SSE3__ 1
+// CHECK_CORE_AVX_I_M32: #define __SSE4_1__ 1
+// CHECK_CORE_AVX_I_M32: #define __SSE4_2__ 1
+// CHECK_CORE_AVX_I_M32: #define __SSE__ 1
+// CHECK_CORE_AVX_I_M32: #define __SSSE3__ 1
+// CHECK_CORE_AVX_I_M32: #define __corei7 1
+// CHECK_CORE_AVX_I_M32: #define __corei7__ 1
+// CHECK_CORE_AVX_I_M32: #define __i386 1
+// CHECK_CORE_AVX_I_M32: #define __i386__ 1
+// CHECK_CORE_AVX_I_M32: #define __tune_corei7__ 1
+// CHECK_CORE_AVX_I_M32: #define i386 1
+// RUN: %clang -march=core-avx-i -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_CORE_AVX_I_M64
+// CHECK_CORE_AVX_I_M64: #define __AES__ 1
+// FIXME: AVX is not yet enabled with Clang.
+// CHECK_CORE_AVX_I_M64-NOT: #define __AVX__ 1
+// CHECK_CORE_AVX_I_M64: #define __MMX__ 1
+// CHECK_CORE_AVX_I_M64: #define __SSE2_MATH__ 1
+// CHECK_CORE_AVX_I_M64: #define __SSE2__ 1
+// CHECK_CORE_AVX_I_M64: #define __SSE3__ 1
+// CHECK_CORE_AVX_I_M64: #define __SSE4_1__ 1
+// CHECK_CORE_AVX_I_M64: #define __SSE4_2__ 1
+// CHECK_CORE_AVX_I_M64: #define __SSE_MATH__ 1
+// CHECK_CORE_AVX_I_M64: #define __SSE__ 1
+// CHECK_CORE_AVX_I_M64: #define __SSSE3__ 1
+// CHECK_CORE_AVX_I_M64: #define __amd64 1
+// CHECK_CORE_AVX_I_M64: #define __amd64__ 1
+// CHECK_CORE_AVX_I_M64: #define __corei7 1
+// CHECK_CORE_AVX_I_M64: #define __corei7__ 1
+// CHECK_CORE_AVX_I_M64: #define __tune_corei7__ 1
+// CHECK_CORE_AVX_I_M64: #define __x86_64 1
+// CHECK_CORE_AVX_I_M64: #define __x86_64__ 1
+//
+// RUN: %clang -march=atom -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATOM_M32
+// CHECK_ATOM_M32: #define __MMX__ 1
+// CHECK_ATOM_M32: #define __SSE2__ 1
+// CHECK_ATOM_M32: #define __SSE3__ 1
+// CHECK_ATOM_M32: #define __SSE__ 1
+// CHECK_ATOM_M32: #define __SSSE3__ 1
+// CHECK_ATOM_M32: #define __atom 1
+// CHECK_ATOM_M32: #define __atom__ 1
+// CHECK_ATOM_M32: #define __i386 1
+// CHECK_ATOM_M32: #define __i386__ 1
+// CHECK_ATOM_M32: #define __tune_atom__ 1
+// CHECK_ATOM_M32: #define i386 1
+// RUN: %clang -march=atom -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATOM_M64
+// CHECK_ATOM_M64: #define __MMX__ 1
+// CHECK_ATOM_M64: #define __SSE2_MATH__ 1
+// CHECK_ATOM_M64: #define __SSE2__ 1
+// CHECK_ATOM_M64: #define __SSE3__ 1
+// CHECK_ATOM_M64: #define __SSE_MATH__ 1
+// CHECK_ATOM_M64: #define __SSE__ 1
+// CHECK_ATOM_M64: #define __SSSE3__ 1
+// CHECK_ATOM_M64: #define __amd64 1
+// CHECK_ATOM_M64: #define __amd64__ 1
+// CHECK_ATOM_M64: #define __atom 1
+// CHECK_ATOM_M64: #define __atom__ 1
+// CHECK_ATOM_M64: #define __tune_atom__ 1
+// CHECK_ATOM_M64: #define __x86_64 1
+// CHECK_ATOM_M64: #define __x86_64__ 1
+//
+// RUN: %clang -march=geode -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_GEODE_M32
+// CHECK_GEODE_M32: #define __3dNOW_A__ 1
+// CHECK_GEODE_M32: #define __3dNOW__ 1
+// CHECK_GEODE_M32: #define __MMX__ 1
+// CHECK_GEODE_M32: #define __geode 1
+// CHECK_GEODE_M32: #define __geode__ 1
+// CHECK_GEODE_M32: #define __i386 1
+// CHECK_GEODE_M32: #define __i386__ 1
+// CHECK_GEODE_M32: #define __tune_geode__ 1
+// CHECK_GEODE_M32: #define i386 1
+// RUN: %clang -march=geode -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_GEODE_M64
+// CHECK_GEODE_M64: error:
+//
+// RUN: %clang -march=k6 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_K6_M32
+// CHECK_K6_M32: #define __MMX__ 1
+// CHECK_K6_M32: #define __i386 1
+// CHECK_K6_M32: #define __i386__ 1
+// CHECK_K6_M32: #define __k6 1
+// CHECK_K6_M32: #define __k6__ 1
+// CHECK_K6_M32: #define __tune_k6__ 1
+// CHECK_K6_M32: #define i386 1
+// RUN: %clang -march=k6 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_K6_M64
+// CHECK_K6_M64: error:
+//
+// RUN: %clang -march=k6-2 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_K6_2_M32
+// CHECK_K6_2_M32: #define __3dNOW__ 1
+// CHECK_K6_2_M32: #define __MMX__ 1
+// CHECK_K6_2_M32: #define __i386 1
+// CHECK_K6_2_M32: #define __i386__ 1
+// CHECK_K6_2_M32: #define __k6 1
+// CHECK_K6_2_M32: #define __k6_2__ 1
+// CHECK_K6_2_M32: #define __k6__ 1
+// CHECK_K6_2_M32: #define __tune_k6_2__ 1
+// CHECK_K6_2_M32: #define __tune_k6__ 1
+// CHECK_K6_2_M32: #define i386 1
+// RUN: %clang -march=k6-2 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_K6_2_M64
+// CHECK_K6_2_M64: error:
+//
+// RUN: %clang -march=k6-3 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_K6_3_M32
+// CHECK_K6_3_M32: #define __3dNOW__ 1
+// CHECK_K6_3_M32: #define __MMX__ 1
+// CHECK_K6_3_M32: #define __i386 1
+// CHECK_K6_3_M32: #define __i386__ 1
+// CHECK_K6_3_M32: #define __k6 1
+// CHECK_K6_3_M32: #define __k6_3__ 1
+// CHECK_K6_3_M32: #define __k6__ 1
+// CHECK_K6_3_M32: #define __tune_k6_3__ 1
+// CHECK_K6_3_M32: #define __tune_k6__ 1
+// CHECK_K6_3_M32: #define i386 1
+// RUN: %clang -march=k6-3 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_K6_3_M64
+// CHECK_K6_3_M64: error:
+//
+// RUN: %clang -march=athlon -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_M32
+// CHECK_ATHLON_M32: #define __3dNOW_A__ 1
+// CHECK_ATHLON_M32: #define __3dNOW__ 1
+// CHECK_ATHLON_M32: #define __MMX__ 1
+// CHECK_ATHLON_M32: #define __athlon 1
+// CHECK_ATHLON_M32: #define __athlon__ 1
+// CHECK_ATHLON_M32: #define __i386 1
+// CHECK_ATHLON_M32: #define __i386__ 1
+// CHECK_ATHLON_M32: #define __tune_athlon__ 1
+// CHECK_ATHLON_M32: #define i386 1
+// RUN: %clang -march=athlon -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_M64
+// CHECK_ATHLON_M64: error:
+//
+// RUN: %clang -march=athlon-tbird -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_TBIRD_M32
+// CHECK_ATHLON_TBIRD_M32: #define __3dNOW_A__ 1
+// CHECK_ATHLON_TBIRD_M32: #define __3dNOW__ 1
+// CHECK_ATHLON_TBIRD_M32: #define __MMX__ 1
+// CHECK_ATHLON_TBIRD_M32: #define __athlon 1
+// CHECK_ATHLON_TBIRD_M32: #define __athlon__ 1
+// CHECK_ATHLON_TBIRD_M32: #define __i386 1
+// CHECK_ATHLON_TBIRD_M32: #define __i386__ 1
+// CHECK_ATHLON_TBIRD_M32: #define __tune_athlon__ 1
+// CHECK_ATHLON_TBIRD_M32: #define i386 1
+// RUN: %clang -march=athlon-tbird -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_TBIRD_M64
+// CHECK_ATHLON_TBIRD_M64: error:
+//
+// RUN: %clang -march=athlon-4 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_4_M32
+// CHECK_ATHLON_4_M32: #define __3dNOW_A__ 1
+// CHECK_ATHLON_4_M32: #define __3dNOW__ 1
+// CHECK_ATHLON_4_M32: #define __MMX__ 1
+// CHECK_ATHLON_4_M32: #define __SSE__ 1
+// CHECK_ATHLON_4_M32: #define __athlon 1
+// CHECK_ATHLON_4_M32: #define __athlon__ 1
+// CHECK_ATHLON_4_M32: #define __athlon_sse__ 1
+// CHECK_ATHLON_4_M32: #define __i386 1
+// CHECK_ATHLON_4_M32: #define __i386__ 1
+// CHECK_ATHLON_4_M32: #define __tune_athlon__ 1
+// CHECK_ATHLON_4_M32: #define __tune_athlon_sse__ 1
+// CHECK_ATHLON_4_M32: #define i386 1
+// RUN: %clang -march=athlon-4 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_4_M64
+// CHECK_ATHLON_4_M64: error:
+//
+// RUN: %clang -march=athlon-xp -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_XP_M32
+// CHECK_ATHLON_XP_M32: #define __3dNOW_A__ 1
+// CHECK_ATHLON_XP_M32: #define __3dNOW__ 1
+// CHECK_ATHLON_XP_M32: #define __MMX__ 1
+// CHECK_ATHLON_XP_M32: #define __SSE__ 1
+// CHECK_ATHLON_XP_M32: #define __athlon 1
+// CHECK_ATHLON_XP_M32: #define __athlon__ 1
+// CHECK_ATHLON_XP_M32: #define __athlon_sse__ 1
+// CHECK_ATHLON_XP_M32: #define __i386 1
+// CHECK_ATHLON_XP_M32: #define __i386__ 1
+// CHECK_ATHLON_XP_M32: #define __tune_athlon__ 1
+// CHECK_ATHLON_XP_M32: #define __tune_athlon_sse__ 1
+// CHECK_ATHLON_XP_M32: #define i386 1
+// RUN: %clang -march=athlon-xp -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_XP_M64
+// CHECK_ATHLON_XP_M64: error:
+//
+// RUN: %clang -march=athlon-mp -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_MP_M32
+// CHECK_ATHLON_MP_M32: #define __3dNOW_A__ 1
+// CHECK_ATHLON_MP_M32: #define __3dNOW__ 1
+// CHECK_ATHLON_MP_M32: #define __MMX__ 1
+// CHECK_ATHLON_MP_M32: #define __SSE__ 1
+// CHECK_ATHLON_MP_M32: #define __athlon 1
+// CHECK_ATHLON_MP_M32: #define __athlon__ 1
+// CHECK_ATHLON_MP_M32: #define __athlon_sse__ 1
+// CHECK_ATHLON_MP_M32: #define __i386 1
+// CHECK_ATHLON_MP_M32: #define __i386__ 1
+// CHECK_ATHLON_MP_M32: #define __tune_athlon__ 1
+// CHECK_ATHLON_MP_M32: #define __tune_athlon_sse__ 1
+// CHECK_ATHLON_MP_M32: #define i386 1
+// RUN: %clang -march=athlon-mp -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_MP_M64
+// CHECK_ATHLON_MP_M64: error:
+//
+// RUN: %clang -march=x86-64 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_X86_64_M32
+// CHECK_X86_64_M32: #define __MMX__ 1
+// CHECK_X86_64_M32: #define __SSE2__ 1
+// CHECK_X86_64_M32: #define __SSE__ 1
+// CHECK_X86_64_M32: #define __i386 1
+// CHECK_X86_64_M32: #define __i386__ 1
+// CHECK_X86_64_M32: #define __k8 1
+// CHECK_X86_64_M32: #define __k8__ 1
+// CHECK_X86_64_M32: #define i386 1
+// RUN: %clang -march=x86-64 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_X86_64_M64
+// CHECK_X86_64_M64: #define __MMX__ 1
+// CHECK_X86_64_M64: #define __SSE2_MATH__ 1
+// CHECK_X86_64_M64: #define __SSE2__ 1
+// CHECK_X86_64_M64: #define __SSE_MATH__ 1
+// CHECK_X86_64_M64: #define __SSE__ 1
+// CHECK_X86_64_M64: #define __amd64 1
+// CHECK_X86_64_M64: #define __amd64__ 1
+// CHECK_X86_64_M64: #define __k8 1
+// CHECK_X86_64_M64: #define __k8__ 1
+// CHECK_X86_64_M64: #define __x86_64 1
+// CHECK_X86_64_M64: #define __x86_64__ 1
+//
+// RUN: %clang -march=k8 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_K8_M32
+// CHECK_K8_M32: #define __3dNOW_A__ 1
+// CHECK_K8_M32: #define __3dNOW__ 1
+// CHECK_K8_M32: #define __MMX__ 1
+// CHECK_K8_M32: #define __SSE2__ 1
+// CHECK_K8_M32: #define __SSE__ 1
+// CHECK_K8_M32: #define __i386 1
+// CHECK_K8_M32: #define __i386__ 1
+// CHECK_K8_M32: #define __k8 1
+// CHECK_K8_M32: #define __k8__ 1
+// CHECK_K8_M32: #define __tune_k8__ 1
+// CHECK_K8_M32: #define i386 1
+// RUN: %clang -march=k8 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_K8_M64
+// CHECK_K8_M64: #define __3dNOW_A__ 1
+// CHECK_K8_M64: #define __3dNOW__ 1
+// CHECK_K8_M64: #define __MMX__ 1
+// CHECK_K8_M64: #define __SSE2_MATH__ 1
+// CHECK_K8_M64: #define __SSE2__ 1
+// CHECK_K8_M64: #define __SSE_MATH__ 1
+// CHECK_K8_M64: #define __SSE__ 1
+// CHECK_K8_M64: #define __amd64 1
+// CHECK_K8_M64: #define __amd64__ 1
+// CHECK_K8_M64: #define __k8 1
+// CHECK_K8_M64: #define __k8__ 1
+// CHECK_K8_M64: #define __tune_k8__ 1
+// CHECK_K8_M64: #define __x86_64 1
+// CHECK_K8_M64: #define __x86_64__ 1
+//
+// RUN: %clang -march=k8-sse3 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_K8_SSE3_M32
+// CHECK_K8_SSE3_M32: #define __3dNOW_A__ 1
+// CHECK_K8_SSE3_M32: #define __3dNOW__ 1
+// CHECK_K8_SSE3_M32: #define __MMX__ 1
+// CHECK_K8_SSE3_M32: #define __SSE2__ 1
+// CHECK_K8_SSE3_M32: #define __SSE3__ 1
+// CHECK_K8_SSE3_M32: #define __SSE__ 1
+// CHECK_K8_SSE3_M32: #define __i386 1
+// CHECK_K8_SSE3_M32: #define __i386__ 1
+// CHECK_K8_SSE3_M32: #define __k8 1
+// CHECK_K8_SSE3_M32: #define __k8__ 1
+// CHECK_K8_SSE3_M32: #define __tune_k8__ 1
+// CHECK_K8_SSE3_M32: #define i386 1
+// RUN: %clang -march=k8-sse3 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_K8_SSE3_M64
+// CHECK_K8_SSE3_M64: #define __3dNOW_A__ 1
+// CHECK_K8_SSE3_M64: #define __3dNOW__ 1
+// CHECK_K8_SSE3_M64: #define __MMX__ 1
+// CHECK_K8_SSE3_M64: #define __SSE2_MATH__ 1
+// CHECK_K8_SSE3_M64: #define __SSE2__ 1
+// CHECK_K8_SSE3_M64: #define __SSE3__ 1
+// CHECK_K8_SSE3_M64: #define __SSE_MATH__ 1
+// CHECK_K8_SSE3_M64: #define __SSE__ 1
+// CHECK_K8_SSE3_M64: #define __amd64 1
+// CHECK_K8_SSE3_M64: #define __amd64__ 1
+// CHECK_K8_SSE3_M64: #define __k8 1
+// CHECK_K8_SSE3_M64: #define __k8__ 1
+// CHECK_K8_SSE3_M64: #define __tune_k8__ 1
+// CHECK_K8_SSE3_M64: #define __x86_64 1
+// CHECK_K8_SSE3_M64: #define __x86_64__ 1
+//
+// RUN: %clang -march=opteron -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_OPTERON_M32
+// CHECK_OPTERON_M32: #define __3dNOW_A__ 1
+// CHECK_OPTERON_M32: #define __3dNOW__ 1
+// CHECK_OPTERON_M32: #define __MMX__ 1
+// CHECK_OPTERON_M32: #define __SSE2__ 1
+// CHECK_OPTERON_M32: #define __SSE__ 1
+// CHECK_OPTERON_M32: #define __i386 1
+// CHECK_OPTERON_M32: #define __i386__ 1
+// CHECK_OPTERON_M32: #define __k8 1
+// CHECK_OPTERON_M32: #define __k8__ 1
+// CHECK_OPTERON_M32: #define __tune_k8__ 1
+// CHECK_OPTERON_M32: #define i386 1
+// RUN: %clang -march=opteron -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_OPTERON_M64
+// CHECK_OPTERON_M64: #define __3dNOW_A__ 1
+// CHECK_OPTERON_M64: #define __3dNOW__ 1
+// CHECK_OPTERON_M64: #define __MMX__ 1
+// CHECK_OPTERON_M64: #define __SSE2_MATH__ 1
+// CHECK_OPTERON_M64: #define __SSE2__ 1
+// CHECK_OPTERON_M64: #define __SSE_MATH__ 1
+// CHECK_OPTERON_M64: #define __SSE__ 1
+// CHECK_OPTERON_M64: #define __amd64 1
+// CHECK_OPTERON_M64: #define __amd64__ 1
+// CHECK_OPTERON_M64: #define __k8 1
+// CHECK_OPTERON_M64: #define __k8__ 1
+// CHECK_OPTERON_M64: #define __tune_k8__ 1
+// CHECK_OPTERON_M64: #define __x86_64 1
+// CHECK_OPTERON_M64: #define __x86_64__ 1
+//
+// RUN: %clang -march=opteron-sse3 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_OPTERON_SSE3_M32
+// CHECK_OPTERON_SSE3_M32: #define __3dNOW_A__ 1
+// CHECK_OPTERON_SSE3_M32: #define __3dNOW__ 1
+// CHECK_OPTERON_SSE3_M32: #define __MMX__ 1
+// CHECK_OPTERON_SSE3_M32: #define __SSE2__ 1
+// CHECK_OPTERON_SSE3_M32: #define __SSE3__ 1
+// CHECK_OPTERON_SSE3_M32: #define __SSE__ 1
+// CHECK_OPTERON_SSE3_M32: #define __i386 1
+// CHECK_OPTERON_SSE3_M32: #define __i386__ 1
+// CHECK_OPTERON_SSE3_M32: #define __k8 1
+// CHECK_OPTERON_SSE3_M32: #define __k8__ 1
+// CHECK_OPTERON_SSE3_M32: #define __tune_k8__ 1
+// CHECK_OPTERON_SSE3_M32: #define i386 1
+// RUN: %clang -march=opteron-sse3 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_OPTERON_SSE3_M64
+// CHECK_OPTERON_SSE3_M64: #define __3dNOW_A__ 1
+// CHECK_OPTERON_SSE3_M64: #define __3dNOW__ 1
+// CHECK_OPTERON_SSE3_M64: #define __MMX__ 1
+// CHECK_OPTERON_SSE3_M64: #define __SSE2_MATH__ 1
+// CHECK_OPTERON_SSE3_M64: #define __SSE2__ 1
+// CHECK_OPTERON_SSE3_M64: #define __SSE3__ 1
+// CHECK_OPTERON_SSE3_M64: #define __SSE_MATH__ 1
+// CHECK_OPTERON_SSE3_M64: #define __SSE__ 1
+// CHECK_OPTERON_SSE3_M64: #define __amd64 1
+// CHECK_OPTERON_SSE3_M64: #define __amd64__ 1
+// CHECK_OPTERON_SSE3_M64: #define __k8 1
+// CHECK_OPTERON_SSE3_M64: #define __k8__ 1
+// CHECK_OPTERON_SSE3_M64: #define __tune_k8__ 1
+// CHECK_OPTERON_SSE3_M64: #define __x86_64 1
+// CHECK_OPTERON_SSE3_M64: #define __x86_64__ 1
+//
+// RUN: %clang -march=athlon64 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON64_M32
+// CHECK_ATHLON64_M32: #define __3dNOW_A__ 1
+// CHECK_ATHLON64_M32: #define __3dNOW__ 1
+// CHECK_ATHLON64_M32: #define __MMX__ 1
+// CHECK_ATHLON64_M32: #define __SSE2__ 1
+// CHECK_ATHLON64_M32: #define __SSE__ 1
+// CHECK_ATHLON64_M32: #define __i386 1
+// CHECK_ATHLON64_M32: #define __i386__ 1
+// CHECK_ATHLON64_M32: #define __k8 1
+// CHECK_ATHLON64_M32: #define __k8__ 1
+// CHECK_ATHLON64_M32: #define __tune_k8__ 1
+// CHECK_ATHLON64_M32: #define i386 1
+// RUN: %clang -march=athlon64 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON64_M64
+// CHECK_ATHLON64_M64: #define __3dNOW_A__ 1
+// CHECK_ATHLON64_M64: #define __3dNOW__ 1
+// CHECK_ATHLON64_M64: #define __MMX__ 1
+// CHECK_ATHLON64_M64: #define __SSE2_MATH__ 1
+// CHECK_ATHLON64_M64: #define __SSE2__ 1
+// CHECK_ATHLON64_M64: #define __SSE_MATH__ 1
+// CHECK_ATHLON64_M64: #define __SSE__ 1
+// CHECK_ATHLON64_M64: #define __amd64 1
+// CHECK_ATHLON64_M64: #define __amd64__ 1
+// CHECK_ATHLON64_M64: #define __k8 1
+// CHECK_ATHLON64_M64: #define __k8__ 1
+// CHECK_ATHLON64_M64: #define __tune_k8__ 1
+// CHECK_ATHLON64_M64: #define __x86_64 1
+// CHECK_ATHLON64_M64: #define __x86_64__ 1
+//
+// RUN: %clang -march=athlon64-sse3 -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON64_SSE3_M32
+// CHECK_ATHLON64_SSE3_M32: #define __3dNOW_A__ 1
+// CHECK_ATHLON64_SSE3_M32: #define __3dNOW__ 1
+// CHECK_ATHLON64_SSE3_M32: #define __MMX__ 1
+// CHECK_ATHLON64_SSE3_M32: #define __SSE2__ 1
+// CHECK_ATHLON64_SSE3_M32: #define __SSE3__ 1
+// CHECK_ATHLON64_SSE3_M32: #define __SSE__ 1
+// CHECK_ATHLON64_SSE3_M32: #define __i386 1
+// CHECK_ATHLON64_SSE3_M32: #define __i386__ 1
+// CHECK_ATHLON64_SSE3_M32: #define __k8 1
+// CHECK_ATHLON64_SSE3_M32: #define __k8__ 1
+// CHECK_ATHLON64_SSE3_M32: #define __tune_k8__ 1
+// CHECK_ATHLON64_SSE3_M32: #define i386 1
+// RUN: %clang -march=athlon64-sse3 -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON64_SSE3_M64
+// CHECK_ATHLON64_SSE3_M64: #define __3dNOW_A__ 1
+// CHECK_ATHLON64_SSE3_M64: #define __3dNOW__ 1
+// CHECK_ATHLON64_SSE3_M64: #define __MMX__ 1
+// CHECK_ATHLON64_SSE3_M64: #define __SSE2_MATH__ 1
+// CHECK_ATHLON64_SSE3_M64: #define __SSE2__ 1
+// CHECK_ATHLON64_SSE3_M64: #define __SSE3__ 1
+// CHECK_ATHLON64_SSE3_M64: #define __SSE_MATH__ 1
+// CHECK_ATHLON64_SSE3_M64: #define __SSE__ 1
+// CHECK_ATHLON64_SSE3_M64: #define __amd64 1
+// CHECK_ATHLON64_SSE3_M64: #define __amd64__ 1
+// CHECK_ATHLON64_SSE3_M64: #define __k8 1
+// CHECK_ATHLON64_SSE3_M64: #define __k8__ 1
+// CHECK_ATHLON64_SSE3_M64: #define __tune_k8__ 1
+// CHECK_ATHLON64_SSE3_M64: #define __x86_64 1
+// CHECK_ATHLON64_SSE3_M64: #define __x86_64__ 1
+//
+// RUN: %clang -march=athlon-fx -m32 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_FX_M32
+// CHECK_ATHLON_FX_M32: #define __3dNOW_A__ 1
+// CHECK_ATHLON_FX_M32: #define __3dNOW__ 1
+// CHECK_ATHLON_FX_M32: #define __MMX__ 1
+// CHECK_ATHLON_FX_M32: #define __SSE2__ 1
+// CHECK_ATHLON_FX_M32: #define __SSE__ 1
+// CHECK_ATHLON_FX_M32: #define __i386 1
+// CHECK_ATHLON_FX_M32: #define __i386__ 1
+// CHECK_ATHLON_FX_M32: #define __k8 1
+// CHECK_ATHLON_FX_M32: #define __k8__ 1
+// CHECK_ATHLON_FX_M32: #define __tune_k8__ 1
+// CHECK_ATHLON_FX_M32: #define i386 1
+// RUN: %clang -march=athlon-fx -m64 -E -dM %s -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_FX_M64
+// CHECK_ATHLON_FX_M64: #define __3dNOW_A__ 1
+// CHECK_ATHLON_FX_M64: #define __3dNOW__ 1
+// CHECK_ATHLON_FX_M64: #define __MMX__ 1
+// CHECK_ATHLON_FX_M64: #define __SSE2_MATH__ 1
+// CHECK_ATHLON_FX_M64: #define __SSE2__ 1
+// CHECK_ATHLON_FX_M64: #define __SSE_MATH__ 1
+// CHECK_ATHLON_FX_M64: #define __SSE__ 1
+// CHECK_ATHLON_FX_M64: #define __amd64 1
+// CHECK_ATHLON_FX_M64: #define __amd64__ 1
+// CHECK_ATHLON_FX_M64: #define __k8 1
+// CHECK_ATHLON_FX_M64: #define __k8__ 1
+// CHECK_ATHLON_FX_M64: #define __tune_k8__ 1
+// CHECK_ATHLON_FX_M64: #define __x86_64 1
+// CHECK_ATHLON_FX_M64: #define __x86_64__ 1
+//
+// End X86/GCC/Linux tests ------------------
diff --git a/clang/test/Preprocessor/predefined-exceptions.m b/clang/test/Preprocessor/predefined-exceptions.m
new file mode 100644
index 0000000..c13f429
--- /dev/null
+++ b/clang/test/Preprocessor/predefined-exceptions.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -x objective-c -fobjc-exceptions -fexceptions -E -dM %s | FileCheck -check-prefix=CHECK-OBJC-NOCXX %s
+// CHECK-OBJC-NOCXX: #define OBJC_ZEROCOST_EXCEPTIONS 1
+// CHECK-OBJC-NOCXX-NOT: #define __EXCEPTIONS 1
+
+// RUN: %clang_cc1 -x objective-c++ -fobjc-exceptions -fexceptions -fcxx-exceptions -E -dM %s | FileCheck -check-prefix=CHECK-OBJC-CXX %s
+// CHECK-OBJC-CXX: #define OBJC_ZEROCOST_EXCEPTIONS 1
+// CHECK-OBJC-CXX: #define __EXCEPTIONS 1
+
+// RUN: %clang_cc1 -x objective-c++ -fexceptions -fcxx-exceptions -E -dM %s | FileCheck -check-prefix=CHECK-NOOBJC-CXX %s
+// CHECK-NOOBJC-CXX-NOT: #define OBJC_ZEROCOST_EXCEPTIONS 1
+// CHECK-NOOBJC-CXX: #define __EXCEPTIONS 1
+
+// RUN: %clang_cc1 -x objective-c -E -dM %s | FileCheck -check-prefix=CHECK-NOOBJC-NOCXX %s
+// CHECK-NOOBJC-NOCXX-NOT: #define OBJC_ZEROCOST_EXCEPTIONS 1
+// CHECK-NOOBJC-NOCXX-NOT: #define __EXCEPTIONS 1
diff --git a/clang/test/Preprocessor/predefined-macros.c b/clang/test/Preprocessor/predefined-macros.c
new file mode 100644
index 0000000..5c11c3b
--- /dev/null
+++ b/clang/test/Preprocessor/predefined-macros.c
@@ -0,0 +1,15 @@
+// This test verifies that the correct macros are predefined.
+//
+// RUN: %clang_cc1 %s -E -dM -triple i686-pc-win32 -fms-extensions -fms-compatibility \
+// RUN: -fmsc-version=1300 -o - | FileCheck %s --check-prefix=CHECK-MS
+// CHECK-MS: #define _INTEGRAL_MAX_BITS 64
+// CHECK-MS: #define _MSC_EXTENSIONS 1
+// CHECK-MS: #define _MSC_VER 1300
+// CHECK-MS: #define _M_IX86 600
+// CHECK-MS: #define _M_IX86_FP
+// CHECK-MS: #define _WIN32 1
+// CHECK-MS-NOT: #define __GNUC__
+//
+// RUN: %clang_cc1 %s -E -dM -ffast-math -o - \
+// RUN: | FileCheck %s --check-prefix=CHECK-FAST-MATH
+// CHECK-FAST-MATH: #define __FAST_MATH__
diff --git a/clang/test/Preprocessor/print_line_count.c b/clang/test/Preprocessor/print_line_count.c
new file mode 100644
index 0000000..6a02b0e
--- /dev/null
+++ b/clang/test/Preprocessor/print_line_count.c
@@ -0,0 +1,4 @@
+/* RUN: %clang -E -C -P %s | wc -l | grep 4
+ PR2741
+ comment */
+y
diff --git a/clang/test/Preprocessor/print_line_empty_file.c b/clang/test/Preprocessor/print_line_empty_file.c
new file mode 100644
index 0000000..868d0b7
--- /dev/null
+++ b/clang/test/Preprocessor/print_line_empty_file.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -E %s | FileCheck %s
+
+#line 21 ""
+int foo() { return 42; }
+
+#line 4 "bug.c"
+int bar() { return 21; }
+
+// CHECK: # 21 ""
+// CHECK: int foo() { return 42; }
+// CHECK: # 4 "bug.c"
+// CHECK: int bar() { return 21; }
diff --git a/clang/test/Preprocessor/print_line_track.c b/clang/test/Preprocessor/print_line_track.c
new file mode 100644
index 0000000..fb2ccf2
--- /dev/null
+++ b/clang/test/Preprocessor/print_line_track.c
@@ -0,0 +1,17 @@
+/* RUN: %clang_cc1 -E %s | grep 'a 3'
+ * RUN: %clang_cc1 -E %s | grep 'b 16'
+ * RUN: %clang_cc1 -E -P %s | grep 'a 3'
+ * RUN: %clang_cc1 -E -P %s | grep 'b 16'
+ * RUN: %clang_cc1 -E %s | not grep '# 0 '
+ * RUN: %clang_cc1 -E -P %s | count 4
+ * PR1848 PR3437 PR7360
+*/
+
+#define t(x) x
+
+t(a
+3)
+
+t(b
+__LINE__)
+
diff --git a/clang/test/Preprocessor/pushable-diagnostics.c b/clang/test/Preprocessor/pushable-diagnostics.c
new file mode 100644
index 0000000..877eaaa
--- /dev/null
+++ b/clang/test/Preprocessor/pushable-diagnostics.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+#pragma clang diagnostic pop // expected-warning{{pragma diagnostic pop could not pop, no matching push}}
+
+#pragma clang diagnostic puhs // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'}}
+
+int a = 'df'; // expected-warning{{multi-character character constant}}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wmultichar"
+
+int b = 'df'; // no warning.
+#pragma clang diagnostic pop
+
+int c = 'df'; // expected-warning{{multi-character character constant}}
+
+#pragma clang diagnostic pop // expected-warning{{pragma diagnostic pop could not pop, no matching push}}
diff --git a/clang/test/Preprocessor/skipping_unclean.c b/clang/test/Preprocessor/skipping_unclean.c
new file mode 100644
index 0000000..52d1785
--- /dev/null
+++ b/clang/test/Preprocessor/skipping_unclean.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -E %s | grep bark
+
+#if 0
+blah
+#\
+else
+bark
+#endif
+
diff --git a/clang/test/Preprocessor/stdint.c b/clang/test/Preprocessor/stdint.c
new file mode 100644
index 0000000..70c106b
--- /dev/null
+++ b/clang/test/Preprocessor/stdint.c
@@ -0,0 +1,959 @@
+// RUN: %clang_cc1 -E -ffreestanding -triple=arm-none-none %s | FileCheck -check-prefix ARM %s
+//
+// ARM:typedef signed long long int int64_t;
+// ARM:typedef unsigned long long int uint64_t;
+// ARM:typedef int64_t int_least64_t;
+// ARM:typedef uint64_t uint_least64_t;
+// ARM:typedef int64_t int_fast64_t;
+// ARM:typedef uint64_t uint_fast64_t;
+//
+// ARM:typedef signed int int32_t;
+// ARM:typedef unsigned int uint32_t;
+// ARM:typedef int32_t int_least32_t;
+// ARM:typedef uint32_t uint_least32_t;
+// ARM:typedef int32_t int_fast32_t;
+// ARM:typedef uint32_t uint_fast32_t;
+//
+// ARM:typedef signed short int16_t;
+// ARM:typedef unsigned short uint16_t;
+// ARM:typedef int16_t int_least16_t;
+// ARM:typedef uint16_t uint_least16_t;
+// ARM:typedef int16_t int_fast16_t;
+// ARM:typedef uint16_t uint_fast16_t;
+//
+// ARM:typedef signed char int8_t;
+// ARM:typedef unsigned char uint8_t;
+// ARM:typedef int8_t int_least8_t;
+// ARM:typedef uint8_t uint_least8_t;
+// ARM:typedef int8_t int_fast8_t;
+// ARM:typedef uint8_t uint_fast8_t;
+//
+// ARM:typedef int32_t intptr_t;
+// ARM:typedef uint32_t uintptr_t;
+//
+// ARM:typedef long long int intmax_t;
+// ARM:typedef long long unsigned int uintmax_t;
+//
+// ARM:INT8_MAX_ 127
+// ARM:INT8_MIN_ (-127 -1)
+// ARM:UINT8_MAX_ 255
+// ARM:INT_LEAST8_MIN_ (-127 -1)
+// ARM:INT_LEAST8_MAX_ 127
+// ARM:UINT_LEAST8_MAX_ 255
+// ARM:INT_FAST8_MIN_ (-127 -1)
+// ARM:INT_FAST8_MAX_ 127
+// ARM:UINT_FAST8_MAX_ 255
+//
+// ARM:INT16_MAX_ 32767
+// ARM:INT16_MIN_ (-32767 -1)
+// ARM:UINT16_MAX_ 65535
+// ARM:INT_LEAST16_MIN_ (-32767 -1)
+// ARM:INT_LEAST16_MAX_ 32767
+// ARM:UINT_LEAST16_MAX_ 65535
+// ARM:INT_FAST16_MIN_ (-32767 -1)
+// ARM:INT_FAST16_MAX_ 32767
+// ARM:UINT_FAST16_MAX_ 65535
+//
+// ARM:INT32_MAX_ 2147483647
+// ARM:INT32_MIN_ (-2147483647 -1)
+// ARM:UINT32_MAX_ 4294967295U
+// ARM:INT_LEAST32_MIN_ (-2147483647 -1)
+// ARM:INT_LEAST32_MAX_ 2147483647
+// ARM:UINT_LEAST32_MAX_ 4294967295U
+// ARM:INT_FAST32_MIN_ (-2147483647 -1)
+// ARM:INT_FAST32_MAX_ 2147483647
+// ARM:UINT_FAST32_MAX_ 4294967295U
+//
+// ARM:INT64_MAX_ 9223372036854775807LL
+// ARM:INT64_MIN_ (-9223372036854775807LL -1)
+// ARM:UINT64_MAX_ 18446744073709551615ULL
+// ARM:INT_LEAST64_MIN_ (-9223372036854775807LL -1)
+// ARM:INT_LEAST64_MAX_ 9223372036854775807LL
+// ARM:UINT_LEAST64_MAX_ 18446744073709551615ULL
+// ARM:INT_FAST64_MIN_ (-9223372036854775807LL -1)
+// ARM:INT_FAST64_MAX_ 9223372036854775807LL
+// ARM:UINT_FAST64_MAX_ 18446744073709551615ULL
+//
+// ARM:INTPTR_MIN_ (-2147483647 -1)
+// ARM:INTPTR_MAX_ 2147483647
+// ARM:UINTPTR_MAX_ 4294967295U
+// ARM:PTRDIFF_MIN_ (-2147483647 -1)
+// ARM:PTRDIFF_MAX_ 2147483647
+// ARM:SIZE_MAX_ 4294967295U
+//
+// ARM:INTMAX_MIN_ (-9223372036854775807LL -1)
+// ARM:INTMAX_MAX_ 9223372036854775807LL
+// ARM:UINTMAX_MAX_ 18446744073709551615ULL
+//
+// ARM:SIG_ATOMIC_MIN_ (-2147483647 -1)
+// ARM:SIG_ATOMIC_MAX_ 2147483647
+// ARM:WINT_MIN_ (-2147483647 -1)
+// ARM:WINT_MAX_ 2147483647
+//
+// ARM:WCHAR_MAX_ 4294967295U
+// ARM:WCHAR_MIN_ 0U
+//
+// ARM:INT8_C_(0) 0
+// ARM:UINT8_C_(0) 0U
+// ARM:INT16_C_(0) 0
+// ARM:UINT16_C_(0) 0U
+// ARM:INT32_C_(0) 0
+// ARM:UINT32_C_(0) 0U
+// ARM:INT64_C_(0) 0LL
+// ARM:UINT64_C_(0) 0ULL
+//
+// ARM:INTMAX_C_(0) 0LL
+// ARM:UINTMAX_C_(0) 0ULL
+//
+//
+// RUN: %clang_cc1 -E -ffreestanding -triple=i386-none-none %s | FileCheck -check-prefix I386 %s
+//
+// I386:typedef signed long long int int64_t;
+// I386:typedef unsigned long long int uint64_t;
+// I386:typedef int64_t int_least64_t;
+// I386:typedef uint64_t uint_least64_t;
+// I386:typedef int64_t int_fast64_t;
+// I386:typedef uint64_t uint_fast64_t;
+//
+// I386:typedef signed int int32_t;
+// I386:typedef unsigned int uint32_t;
+// I386:typedef int32_t int_least32_t;
+// I386:typedef uint32_t uint_least32_t;
+// I386:typedef int32_t int_fast32_t;
+// I386:typedef uint32_t uint_fast32_t;
+//
+// I386:typedef signed short int16_t;
+// I386:typedef unsigned short uint16_t;
+// I386:typedef int16_t int_least16_t;
+// I386:typedef uint16_t uint_least16_t;
+// I386:typedef int16_t int_fast16_t;
+// I386:typedef uint16_t uint_fast16_t;
+//
+// I386:typedef signed char int8_t;
+// I386:typedef unsigned char uint8_t;
+// I386:typedef int8_t int_least8_t;
+// I386:typedef uint8_t uint_least8_t;
+// I386:typedef int8_t int_fast8_t;
+// I386:typedef uint8_t uint_fast8_t;
+//
+// I386:typedef int32_t intptr_t;
+// I386:typedef uint32_t uintptr_t;
+//
+// I386:typedef long long int intmax_t;
+// I386:typedef long long unsigned int uintmax_t;
+//
+// I386:INT8_MAX_ 127
+// I386:INT8_MIN_ (-127 -1)
+// I386:UINT8_MAX_ 255
+// I386:INT_LEAST8_MIN_ (-127 -1)
+// I386:INT_LEAST8_MAX_ 127
+// I386:UINT_LEAST8_MAX_ 255
+// I386:INT_FAST8_MIN_ (-127 -1)
+// I386:INT_FAST8_MAX_ 127
+// I386:UINT_FAST8_MAX_ 255
+//
+// I386:INT16_MAX_ 32767
+// I386:INT16_MIN_ (-32767 -1)
+// I386:UINT16_MAX_ 65535
+// I386:INT_LEAST16_MIN_ (-32767 -1)
+// I386:INT_LEAST16_MAX_ 32767
+// I386:UINT_LEAST16_MAX_ 65535
+// I386:INT_FAST16_MIN_ (-32767 -1)
+// I386:INT_FAST16_MAX_ 32767
+// I386:UINT_FAST16_MAX_ 65535
+//
+// I386:INT32_MAX_ 2147483647
+// I386:INT32_MIN_ (-2147483647 -1)
+// I386:UINT32_MAX_ 4294967295U
+// I386:INT_LEAST32_MIN_ (-2147483647 -1)
+// I386:INT_LEAST32_MAX_ 2147483647
+// I386:UINT_LEAST32_MAX_ 4294967295U
+// I386:INT_FAST32_MIN_ (-2147483647 -1)
+// I386:INT_FAST32_MAX_ 2147483647
+// I386:UINT_FAST32_MAX_ 4294967295U
+//
+// I386:INT64_MAX_ 9223372036854775807LL
+// I386:INT64_MIN_ (-9223372036854775807LL -1)
+// I386:UINT64_MAX_ 18446744073709551615ULL
+// I386:INT_LEAST64_MIN_ (-9223372036854775807LL -1)
+// I386:INT_LEAST64_MAX_ 9223372036854775807LL
+// I386:UINT_LEAST64_MAX_ 18446744073709551615ULL
+// I386:INT_FAST64_MIN_ (-9223372036854775807LL -1)
+// I386:INT_FAST64_MAX_ 9223372036854775807LL
+// I386:UINT_FAST64_MAX_ 18446744073709551615ULL
+//
+// I386:INTPTR_MIN_ (-2147483647 -1)
+// I386:INTPTR_MAX_ 2147483647
+// I386:UINTPTR_MAX_ 4294967295U
+// I386:PTRDIFF_MIN_ (-2147483647 -1)
+// I386:PTRDIFF_MAX_ 2147483647
+// I386:SIZE_MAX_ 4294967295U
+//
+// I386:INTMAX_MIN_ (-9223372036854775807LL -1)
+// I386:INTMAX_MAX_ 9223372036854775807LL
+// I386:UINTMAX_MAX_ 18446744073709551615ULL
+//
+// I386:SIG_ATOMIC_MIN_ (-2147483647 -1)
+// I386:SIG_ATOMIC_MAX_ 2147483647
+// I386:WINT_MIN_ (-2147483647 -1)
+// I386:WINT_MAX_ 2147483647
+//
+// I386:WCHAR_MAX_ 2147483647
+// I386:WCHAR_MIN_ (-2147483647 -1)
+//
+// I386:INT8_C_(0) 0
+// I386:UINT8_C_(0) 0U
+// I386:INT16_C_(0) 0
+// I386:UINT16_C_(0) 0U
+// I386:INT32_C_(0) 0
+// I386:UINT32_C_(0) 0U
+// I386:INT64_C_(0) 0LL
+// I386:UINT64_C_(0) 0ULL
+//
+// I386:INTMAX_C_(0) 0LL
+// I386:UINTMAX_C_(0) 0ULL
+//
+// RUN: %clang_cc1 -E -ffreestanding -triple=msp430-none-none %s | FileCheck -check-prefix MSP430 %s
+//
+// MSP430:typedef signed long int int32_t;
+// MSP430:typedef unsigned long int uint32_t;
+// MSP430:typedef int32_t int_least32_t;
+// MSP430:typedef uint32_t uint_least32_t;
+// MSP430:typedef int32_t int_fast32_t;
+// MSP430:typedef uint32_t uint_fast32_t;
+//
+// MSP430:typedef signed short int16_t;
+// MSP430:typedef unsigned short uint16_t;
+// MSP430:typedef int16_t int_least16_t;
+// MSP430:typedef uint16_t uint_least16_t;
+// MSP430:typedef int16_t int_fast16_t;
+// MSP430:typedef uint16_t uint_fast16_t;
+//
+// MSP430:typedef signed char int8_t;
+// MSP430:typedef unsigned char uint8_t;
+// MSP430:typedef int8_t int_least8_t;
+// MSP430:typedef uint8_t uint_least8_t;
+// MSP430:typedef int8_t int_fast8_t;
+// MSP430:typedef uint8_t uint_fast8_t;
+//
+// MSP430:typedef int16_t intptr_t;
+// MSP430:typedef uint16_t uintptr_t;
+//
+// MSP430:typedef long int intmax_t;
+// MSP430:typedef long unsigned int uintmax_t;
+//
+// MSP430:INT8_MAX_ 127
+// MSP430:INT8_MIN_ (-127 -1)
+// MSP430:UINT8_MAX_ 255
+// MSP430:INT_LEAST8_MIN_ (-127 -1)
+// MSP430:INT_LEAST8_MAX_ 127
+// MSP430:UINT_LEAST8_MAX_ 255
+// MSP430:INT_FAST8_MIN_ (-127 -1)
+// MSP430:INT_FAST8_MAX_ 127
+// MSP430:UINT_FAST8_MAX_ 255
+//
+// MSP430:INT16_MAX_ 32767
+// MSP430:INT16_MIN_ (-32767 -1)
+// MSP430:UINT16_MAX_ 65535
+// MSP430:INT_LEAST16_MIN_ (-32767 -1)
+// MSP430:INT_LEAST16_MAX_ 32767
+// MSP430:UINT_LEAST16_MAX_ 65535
+// MSP430:INT_FAST16_MIN_ (-32767 -1)
+// MSP430:INT_FAST16_MAX_ 32767
+// MSP430:UINT_FAST16_MAX_ 65535
+//
+// MSP430:INT32_MAX_ 2147483647L
+// MSP430:INT32_MIN_ (-2147483647L -1)
+// MSP430:UINT32_MAX_ 4294967295UL
+// MSP430:INT_LEAST32_MIN_ (-2147483647L -1)
+// MSP430:INT_LEAST32_MAX_ 2147483647L
+// MSP430:UINT_LEAST32_MAX_ 4294967295UL
+// MSP430:INT_FAST32_MIN_ (-2147483647L -1)
+// MSP430:INT_FAST32_MAX_ 2147483647L
+// MSP430:UINT_FAST32_MAX_ 4294967295UL
+//
+// MSP430:INT64_MAX_ 9223372036854775807LL
+// MSP430:INT64_MIN_ (-9223372036854775807LL -1)
+// MSP430:UINT64_MAX_ 18446744073709551615ULL
+// MSP430:INT_LEAST64_MIN_ (-9223372036854775807LL -1)
+// MSP430:INT_LEAST64_MAX_ 9223372036854775807LL
+// MSP430:UINT_LEAST64_MAX_ 18446744073709551615ULL
+// MSP430:INT_FAST64_MIN_ (-9223372036854775807LL -1)
+// MSP430:INT_FAST64_MAX_ 9223372036854775807LL
+// MSP430:UINT_FAST64_MAX_ 18446744073709551615ULL
+//
+// MSP430:INTPTR_MIN_ (-32767 -1)
+// MSP430:INTPTR_MAX_ 32767
+// MSP430:UINTPTR_MAX_ 65535
+// MSP430:PTRDIFF_MIN_ (-32767 -1)
+// MSP430:PTRDIFF_MAX_ 32767
+// MSP430:SIZE_MAX_ 65535
+//
+// MSP430:INTMAX_MIN_ (-2147483647L -1)
+// MSP430:INTMAX_MAX_ 2147483647L
+// MSP430:UINTMAX_MAX_ 4294967295UL
+//
+// MSP430:SIG_ATOMIC_MIN_ (-2147483647L -1)
+// MSP430:SIG_ATOMIC_MAX_ 2147483647L
+// MSP430:WINT_MIN_ (-32767 -1)
+// MSP430:WINT_MAX_ 32767
+//
+// MSP430:WCHAR_MAX_ 32767
+// MSP430:WCHAR_MIN_ (-32767 -1)
+//
+// MSP430:INT8_C_(0) 0
+// MSP430:UINT8_C_(0) 0U
+// MSP430:INT16_C_(0) 0
+// MSP430:UINT16_C_(0) 0U
+// MSP430:INT32_C_(0) 0L
+// MSP430:UINT32_C_(0) 0UL
+// MSP430:INT64_C_(0) 0LL
+// MSP430:UINT64_C_(0) 0ULL
+//
+// MSP430:INTMAX_C_(0) 0L
+// MSP430:UINTMAX_C_(0) 0UL
+//
+// RUN: %clang_cc1 -E -ffreestanding -triple=powerpc64-none-none %s | FileCheck -check-prefix PPC64 %s
+//
+// PPC64:typedef signed long int int64_t;
+// PPC64:typedef unsigned long int uint64_t;
+// PPC64:typedef int64_t int_least64_t;
+// PPC64:typedef uint64_t uint_least64_t;
+// PPC64:typedef int64_t int_fast64_t;
+// PPC64:typedef uint64_t uint_fast64_t;
+//
+// PPC64:typedef signed int int32_t;
+// PPC64:typedef unsigned int uint32_t;
+// PPC64:typedef int32_t int_least32_t;
+// PPC64:typedef uint32_t uint_least32_t;
+// PPC64:typedef int32_t int_fast32_t;
+// PPC64:typedef uint32_t uint_fast32_t;
+//
+// PPC64:typedef signed short int16_t;
+// PPC64:typedef unsigned short uint16_t;
+// PPC64:typedef int16_t int_least16_t;
+// PPC64:typedef uint16_t uint_least16_t;
+// PPC64:typedef int16_t int_fast16_t;
+// PPC64:typedef uint16_t uint_fast16_t;
+//
+// PPC64:typedef signed char int8_t;
+// PPC64:typedef unsigned char uint8_t;
+// PPC64:typedef int8_t int_least8_t;
+// PPC64:typedef uint8_t uint_least8_t;
+// PPC64:typedef int8_t int_fast8_t;
+// PPC64:typedef uint8_t uint_fast8_t;
+//
+// PPC64:typedef int64_t intptr_t;
+// PPC64:typedef uint64_t uintptr_t;
+//
+// PPC64:typedef long int intmax_t;
+// PPC64:typedef long unsigned int uintmax_t;
+//
+// PPC64:INT8_MAX_ 127
+// PPC64:INT8_MIN_ (-127 -1)
+// PPC64:UINT8_MAX_ 255
+// PPC64:INT_LEAST8_MIN_ (-127 -1)
+// PPC64:INT_LEAST8_MAX_ 127
+// PPC64:UINT_LEAST8_MAX_ 255
+// PPC64:INT_FAST8_MIN_ (-127 -1)
+// PPC64:INT_FAST8_MAX_ 127
+// PPC64:UINT_FAST8_MAX_ 255
+//
+// PPC64:INT16_MAX_ 32767
+// PPC64:INT16_MIN_ (-32767 -1)
+// PPC64:UINT16_MAX_ 65535
+// PPC64:INT_LEAST16_MIN_ (-32767 -1)
+// PPC64:INT_LEAST16_MAX_ 32767
+// PPC64:UINT_LEAST16_MAX_ 65535
+// PPC64:INT_FAST16_MIN_ (-32767 -1)
+// PPC64:INT_FAST16_MAX_ 32767
+// PPC64:UINT_FAST16_MAX_ 65535
+//
+// PPC64:INT32_MAX_ 2147483647
+// PPC64:INT32_MIN_ (-2147483647 -1)
+// PPC64:UINT32_MAX_ 4294967295U
+// PPC64:INT_LEAST32_MIN_ (-2147483647 -1)
+// PPC64:INT_LEAST32_MAX_ 2147483647
+// PPC64:UINT_LEAST32_MAX_ 4294967295U
+// PPC64:INT_FAST32_MIN_ (-2147483647 -1)
+// PPC64:INT_FAST32_MAX_ 2147483647
+// PPC64:UINT_FAST32_MAX_ 4294967295U
+//
+// PPC64:INT64_MAX_ 9223372036854775807L
+// PPC64:INT64_MIN_ (-9223372036854775807L -1)
+// PPC64:UINT64_MAX_ 18446744073709551615UL
+// PPC64:INT_LEAST64_MIN_ (-9223372036854775807L -1)
+// PPC64:INT_LEAST64_MAX_ 9223372036854775807L
+// PPC64:UINT_LEAST64_MAX_ 18446744073709551615UL
+// PPC64:INT_FAST64_MIN_ (-9223372036854775807L -1)
+// PPC64:INT_FAST64_MAX_ 9223372036854775807L
+// PPC64:UINT_FAST64_MAX_ 18446744073709551615UL
+//
+// PPC64:INTPTR_MIN_ (-9223372036854775807L -1)
+// PPC64:INTPTR_MAX_ 9223372036854775807L
+// PPC64:UINTPTR_MAX_ 18446744073709551615UL
+// PPC64:PTRDIFF_MIN_ (-9223372036854775807L -1)
+// PPC64:PTRDIFF_MAX_ 9223372036854775807L
+// PPC64:SIZE_MAX_ 18446744073709551615UL
+//
+// PPC64:INTMAX_MIN_ (-9223372036854775807L -1)
+// PPC64:INTMAX_MAX_ 9223372036854775807L
+// PPC64:UINTMAX_MAX_ 18446744073709551615UL
+//
+// PPC64:SIG_ATOMIC_MIN_ (-2147483647 -1)
+// PPC64:SIG_ATOMIC_MAX_ 2147483647
+// PPC64:WINT_MIN_ (-2147483647 -1)
+// PPC64:WINT_MAX_ 2147483647
+//
+// PPC64:WCHAR_MAX_ 2147483647
+// PPC64:WCHAR_MIN_ (-2147483647 -1)
+//
+// PPC64:INT8_C_(0) 0
+// PPC64:UINT8_C_(0) 0U
+// PPC64:INT16_C_(0) 0
+// PPC64:UINT16_C_(0) 0U
+// PPC64:INT32_C_(0) 0
+// PPC64:UINT32_C_(0) 0U
+// PPC64:INT64_C_(0) 0L
+// PPC64:UINT64_C_(0) 0UL
+//
+// PPC64:INTMAX_C_(0) 0L
+// PPC64:UINTMAX_C_(0) 0UL
+//
+// RUN: %clang_cc1 -E -ffreestanding -triple=powerpc-none-none %s | FileCheck -check-prefix PPC %s
+//
+//
+// PPC:typedef signed long long int int64_t;
+// PPC:typedef unsigned long long int uint64_t;
+// PPC:typedef int64_t int_least64_t;
+// PPC:typedef uint64_t uint_least64_t;
+// PPC:typedef int64_t int_fast64_t;
+// PPC:typedef uint64_t uint_fast64_t;
+//
+// PPC:typedef signed int int32_t;
+// PPC:typedef unsigned int uint32_t;
+// PPC:typedef int32_t int_least32_t;
+// PPC:typedef uint32_t uint_least32_t;
+// PPC:typedef int32_t int_fast32_t;
+// PPC:typedef uint32_t uint_fast32_t;
+//
+// PPC:typedef signed short int16_t;
+// PPC:typedef unsigned short uint16_t;
+// PPC:typedef int16_t int_least16_t;
+// PPC:typedef uint16_t uint_least16_t;
+// PPC:typedef int16_t int_fast16_t;
+// PPC:typedef uint16_t uint_fast16_t;
+//
+// PPC:typedef signed char int8_t;
+// PPC:typedef unsigned char uint8_t;
+// PPC:typedef int8_t int_least8_t;
+// PPC:typedef uint8_t uint_least8_t;
+// PPC:typedef int8_t int_fast8_t;
+// PPC:typedef uint8_t uint_fast8_t;
+//
+// PPC:typedef int32_t intptr_t;
+// PPC:typedef uint32_t uintptr_t;
+//
+// PPC:typedef long long int intmax_t;
+// PPC:typedef long long unsigned int uintmax_t;
+//
+// PPC:INT8_MAX_ 127
+// PPC:INT8_MIN_ (-127 -1)
+// PPC:UINT8_MAX_ 255
+// PPC:INT_LEAST8_MIN_ (-127 -1)
+// PPC:INT_LEAST8_MAX_ 127
+// PPC:UINT_LEAST8_MAX_ 255
+// PPC:INT_FAST8_MIN_ (-127 -1)
+// PPC:INT_FAST8_MAX_ 127
+// PPC:UINT_FAST8_MAX_ 255
+//
+// PPC:INT16_MAX_ 32767
+// PPC:INT16_MIN_ (-32767 -1)
+// PPC:UINT16_MAX_ 65535
+// PPC:INT_LEAST16_MIN_ (-32767 -1)
+// PPC:INT_LEAST16_MAX_ 32767
+// PPC:UINT_LEAST16_MAX_ 65535
+// PPC:INT_FAST16_MIN_ (-32767 -1)
+// PPC:INT_FAST16_MAX_ 32767
+// PPC:UINT_FAST16_MAX_ 65535
+//
+// PPC:INT32_MAX_ 2147483647
+// PPC:INT32_MIN_ (-2147483647 -1)
+// PPC:UINT32_MAX_ 4294967295U
+// PPC:INT_LEAST32_MIN_ (-2147483647 -1)
+// PPC:INT_LEAST32_MAX_ 2147483647
+// PPC:UINT_LEAST32_MAX_ 4294967295U
+// PPC:INT_FAST32_MIN_ (-2147483647 -1)
+// PPC:INT_FAST32_MAX_ 2147483647
+// PPC:UINT_FAST32_MAX_ 4294967295U
+//
+// PPC:INT64_MAX_ 9223372036854775807LL
+// PPC:INT64_MIN_ (-9223372036854775807LL -1)
+// PPC:UINT64_MAX_ 18446744073709551615ULL
+// PPC:INT_LEAST64_MIN_ (-9223372036854775807LL -1)
+// PPC:INT_LEAST64_MAX_ 9223372036854775807LL
+// PPC:UINT_LEAST64_MAX_ 18446744073709551615ULL
+// PPC:INT_FAST64_MIN_ (-9223372036854775807LL -1)
+// PPC:INT_FAST64_MAX_ 9223372036854775807LL
+// PPC:UINT_FAST64_MAX_ 18446744073709551615ULL
+//
+// PPC:INTPTR_MIN_ (-2147483647 -1)
+// PPC:INTPTR_MAX_ 2147483647
+// PPC:UINTPTR_MAX_ 4294967295U
+// PPC:PTRDIFF_MIN_ (-2147483647 -1)
+// PPC:PTRDIFF_MAX_ 2147483647
+// PPC:SIZE_MAX_ 4294967295U
+//
+// PPC:INTMAX_MIN_ (-9223372036854775807LL -1)
+// PPC:INTMAX_MAX_ 9223372036854775807LL
+// PPC:UINTMAX_MAX_ 18446744073709551615ULL
+//
+// PPC:SIG_ATOMIC_MIN_ (-2147483647 -1)
+// PPC:SIG_ATOMIC_MAX_ 2147483647
+// PPC:WINT_MIN_ (-2147483647 -1)
+// PPC:WINT_MAX_ 2147483647
+//
+// PPC:WCHAR_MAX_ 2147483647
+// PPC:WCHAR_MIN_ (-2147483647 -1)
+//
+// PPC:INT8_C_(0) 0
+// PPC:UINT8_C_(0) 0U
+// PPC:INT16_C_(0) 0
+// PPC:UINT16_C_(0) 0U
+// PPC:INT32_C_(0) 0
+// PPC:UINT32_C_(0) 0U
+// PPC:INT64_C_(0) 0LL
+// PPC:UINT64_C_(0) 0ULL
+//
+// PPC:INTMAX_C_(0) 0LL
+// PPC:UINTMAX_C_(0) 0ULL
+//
+// RUN: %clang_cc1 -E -ffreestanding -triple=sparc-none-none %s | FileCheck -check-prefix SPARC %s
+//
+// SPARC:typedef signed long long int int64_t;
+// SPARC:typedef unsigned long long int uint64_t;
+// SPARC:typedef int64_t int_least64_t;
+// SPARC:typedef uint64_t uint_least64_t;
+// SPARC:typedef int64_t int_fast64_t;
+// SPARC:typedef uint64_t uint_fast64_t;
+//
+// SPARC:typedef signed int int32_t;
+// SPARC:typedef unsigned int uint32_t;
+// SPARC:typedef int32_t int_least32_t;
+// SPARC:typedef uint32_t uint_least32_t;
+// SPARC:typedef int32_t int_fast32_t;
+// SPARC:typedef uint32_t uint_fast32_t;
+//
+// SPARC:typedef signed short int16_t;
+// SPARC:typedef unsigned short uint16_t;
+// SPARC:typedef int16_t int_least16_t;
+// SPARC:typedef uint16_t uint_least16_t;
+// SPARC:typedef int16_t int_fast16_t;
+// SPARC:typedef uint16_t uint_fast16_t;
+//
+// SPARC:typedef signed char int8_t;
+// SPARC:typedef unsigned char uint8_t;
+// SPARC:typedef int8_t int_least8_t;
+// SPARC:typedef uint8_t uint_least8_t;
+// SPARC:typedef int8_t int_fast8_t;
+// SPARC:typedef uint8_t uint_fast8_t;
+//
+// SPARC:typedef int32_t intptr_t;
+// SPARC:typedef uint32_t uintptr_t;
+//
+// SPARC:typedef long long int intmax_t;
+// SPARC:typedef long long unsigned int uintmax_t;
+//
+// SPARC:INT8_MAX_ 127
+// SPARC:INT8_MIN_ (-127 -1)
+// SPARC:UINT8_MAX_ 255
+// SPARC:INT_LEAST8_MIN_ (-127 -1)
+// SPARC:INT_LEAST8_MAX_ 127
+// SPARC:UINT_LEAST8_MAX_ 255
+// SPARC:INT_FAST8_MIN_ (-127 -1)
+// SPARC:INT_FAST8_MAX_ 127
+// SPARC:UINT_FAST8_MAX_ 255
+//
+// SPARC:INT16_MAX_ 32767
+// SPARC:INT16_MIN_ (-32767 -1)
+// SPARC:UINT16_MAX_ 65535
+// SPARC:INT_LEAST16_MIN_ (-32767 -1)
+// SPARC:INT_LEAST16_MAX_ 32767
+// SPARC:UINT_LEAST16_MAX_ 65535
+// SPARC:INT_FAST16_MIN_ (-32767 -1)
+// SPARC:INT_FAST16_MAX_ 32767
+// SPARC:UINT_FAST16_MAX_ 65535
+//
+// SPARC:INT32_MAX_ 2147483647
+// SPARC:INT32_MIN_ (-2147483647 -1)
+// SPARC:UINT32_MAX_ 4294967295U
+// SPARC:INT_LEAST32_MIN_ (-2147483647 -1)
+// SPARC:INT_LEAST32_MAX_ 2147483647
+// SPARC:UINT_LEAST32_MAX_ 4294967295U
+// SPARC:INT_FAST32_MIN_ (-2147483647 -1)
+// SPARC:INT_FAST32_MAX_ 2147483647
+// SPARC:UINT_FAST32_MAX_ 4294967295U
+//
+// SPARC:INT64_MAX_ 9223372036854775807LL
+// SPARC:INT64_MIN_ (-9223372036854775807LL -1)
+// SPARC:UINT64_MAX_ 18446744073709551615ULL
+// SPARC:INT_LEAST64_MIN_ (-9223372036854775807LL -1)
+// SPARC:INT_LEAST64_MAX_ 9223372036854775807LL
+// SPARC:UINT_LEAST64_MAX_ 18446744073709551615ULL
+// SPARC:INT_FAST64_MIN_ (-9223372036854775807LL -1)
+// SPARC:INT_FAST64_MAX_ 9223372036854775807LL
+// SPARC:UINT_FAST64_MAX_ 18446744073709551615ULL
+//
+// SPARC:INTPTR_MIN_ (-2147483647 -1)
+// SPARC:INTPTR_MAX_ 2147483647
+// SPARC:UINTPTR_MAX_ 4294967295U
+// SPARC:PTRDIFF_MIN_ (-2147483647 -1)
+// SPARC:PTRDIFF_MAX_ 2147483647
+// SPARC:SIZE_MAX_ 4294967295U
+//
+// SPARC:INTMAX_MIN_ (-9223372036854775807LL -1)
+// SPARC:INTMAX_MAX_ 9223372036854775807LL
+// SPARC:UINTMAX_MAX_ 18446744073709551615ULL
+//
+// SPARC:SIG_ATOMIC_MIN_ (-2147483647 -1)
+// SPARC:SIG_ATOMIC_MAX_ 2147483647
+// SPARC:WINT_MIN_ (-2147483647 -1)
+// SPARC:WINT_MAX_ 2147483647
+//
+// SPARC:WCHAR_MAX_ 2147483647
+// SPARC:WCHAR_MIN_ (-2147483647 -1)
+//
+// SPARC:INT8_C_(0) 0
+// SPARC:UINT8_C_(0) 0U
+// SPARC:INT16_C_(0) 0
+// SPARC:UINT16_C_(0) 0U
+// SPARC:INT32_C_(0) 0
+// SPARC:UINT32_C_(0) 0U
+// SPARC:INT64_C_(0) 0LL
+// SPARC:UINT64_C_(0) 0ULL
+//
+// SPARC:INTMAX_C_(0) 0LL
+// SPARC:UINTMAX_C_(0) 0ULL
+//
+// RUN: %clang_cc1 -E -ffreestanding -triple=tce-none-none %s | FileCheck -check-prefix TCE %s
+//
+// TCE:typedef signed int int32_t;
+// TCE:typedef unsigned int uint32_t;
+// TCE:typedef int32_t int_least32_t;
+// TCE:typedef uint32_t uint_least32_t;
+// TCE:typedef int32_t int_fast32_t;
+// TCE:typedef uint32_t uint_fast32_t;
+//
+// TCE:typedef signed short int16_t;
+// TCE:typedef unsigned short uint16_t;
+// TCE:typedef int16_t int_least16_t;
+// TCE:typedef uint16_t uint_least16_t;
+// TCE:typedef int16_t int_fast16_t;
+// TCE:typedef uint16_t uint_fast16_t;
+//
+// TCE:typedef signed char int8_t;
+// TCE:typedef unsigned char uint8_t;
+// TCE:typedef int8_t int_least8_t;
+// TCE:typedef uint8_t uint_least8_t;
+// TCE:typedef int8_t int_fast8_t;
+// TCE:typedef uint8_t uint_fast8_t;
+//
+// TCE:typedef int32_t intptr_t;
+// TCE:typedef uint32_t uintptr_t;
+//
+// TCE:typedef long int intmax_t;
+// TCE:typedef long unsigned int uintmax_t;
+//
+// TCE:INT8_MAX_ 127
+// TCE:INT8_MIN_ (-127 -1)
+// TCE:UINT8_MAX_ 255
+// TCE:INT_LEAST8_MIN_ (-127 -1)
+// TCE:INT_LEAST8_MAX_ 127
+// TCE:UINT_LEAST8_MAX_ 255
+// TCE:INT_FAST8_MIN_ (-127 -1)
+// TCE:INT_FAST8_MAX_ 127
+// TCE:UINT_FAST8_MAX_ 255
+//
+// TCE:INT16_MAX_ 32767
+// TCE:INT16_MIN_ (-32767 -1)
+// TCE:UINT16_MAX_ 65535
+// TCE:INT_LEAST16_MIN_ (-32767 -1)
+// TCE:INT_LEAST16_MAX_ 32767
+// TCE:UINT_LEAST16_MAX_ 65535
+// TCE:INT_FAST16_MIN_ (-32767 -1)
+// TCE:INT_FAST16_MAX_ 32767
+// TCE:UINT_FAST16_MAX_ 65535
+//
+// TCE:INT32_MAX_ 2147483647
+// TCE:INT32_MIN_ (-2147483647 -1)
+// TCE:UINT32_MAX_ 4294967295U
+// TCE:INT_LEAST32_MIN_ (-2147483647 -1)
+// TCE:INT_LEAST32_MAX_ 2147483647
+// TCE:UINT_LEAST32_MAX_ 4294967295U
+// TCE:INT_FAST32_MIN_ (-2147483647 -1)
+// TCE:INT_FAST32_MAX_ 2147483647
+// TCE:UINT_FAST32_MAX_ 4294967295U
+//
+// TCE:INT64_MAX_ INT64_MAX
+// TCE:INT64_MIN_ INT64_MIN
+// TCE:UINT64_MAX_ UINT64_MAX
+// TCE:INT_LEAST64_MIN_ INT_LEAST64_MIN
+// TCE:INT_LEAST64_MAX_ INT_LEAST64_MAX
+// TCE:UINT_LEAST64_MAX_ UINT_LEAST64_MAX
+// TCE:INT_FAST64_MIN_ INT_FAST64_MIN
+// TCE:INT_FAST64_MAX_ INT_FAST64_MAX
+// TCE:UINT_FAST64_MAX_ UINT_FAST64_MAX
+//
+// TCE:INTPTR_MIN_ (-2147483647 -1)
+// TCE:INTPTR_MAX_ 2147483647
+// TCE:UINTPTR_MAX_ 4294967295U
+// TCE:PTRDIFF_MIN_ (-2147483647 -1)
+// TCE:PTRDIFF_MAX_ 2147483647
+// TCE:SIZE_MAX_ 4294967295U
+//
+// TCE:INTMAX_MIN_ (-2147483647 -1)
+// TCE:INTMAX_MAX_ 2147483647
+// TCE:UINTMAX_MAX_ 4294967295U
+//
+// TCE:SIG_ATOMIC_MIN_ (-2147483647 -1)
+// TCE:SIG_ATOMIC_MAX_ 2147483647
+// TCE:WINT_MIN_ (-2147483647 -1)
+// TCE:WINT_MAX_ 2147483647
+//
+// TCE:WCHAR_MAX_ 2147483647
+// TCE:WCHAR_MIN_ (-2147483647 -1)
+//
+// TCE:INT8_C_(0) 0
+// TCE:UINT8_C_(0) 0U
+// TCE:INT16_C_(0) 0
+// TCE:UINT16_C_(0) 0U
+// TCE:INT32_C_(0) 0
+// TCE:UINT32_C_(0) 0U
+// TCE:INT64_C_(0) INT64_C(0)
+// TCE:UINT64_C_(0) UINT64_C(0)
+//
+// TCE:INTMAX_C_(0) 0
+// TCE:UINTMAX_C_(0) 0U
+//
+// RUN: %clang_cc1 -E -ffreestanding -triple=x86_64-none-none %s | FileCheck -check-prefix X86_64 %s
+//
+//
+// X86_64:typedef signed long int int64_t;
+// X86_64:typedef unsigned long int uint64_t;
+// X86_64:typedef int64_t int_least64_t;
+// X86_64:typedef uint64_t uint_least64_t;
+// X86_64:typedef int64_t int_fast64_t;
+// X86_64:typedef uint64_t uint_fast64_t;
+//
+// X86_64:typedef signed int int32_t;
+// X86_64:typedef unsigned int uint32_t;
+// X86_64:typedef int32_t int_least32_t;
+// X86_64:typedef uint32_t uint_least32_t;
+// X86_64:typedef int32_t int_fast32_t;
+// X86_64:typedef uint32_t uint_fast32_t;
+//
+// X86_64:typedef signed short int16_t;
+// X86_64:typedef unsigned short uint16_t;
+// X86_64:typedef int16_t int_least16_t;
+// X86_64:typedef uint16_t uint_least16_t;
+// X86_64:typedef int16_t int_fast16_t;
+// X86_64:typedef uint16_t uint_fast16_t;
+//
+// X86_64:typedef signed char int8_t;
+// X86_64:typedef unsigned char uint8_t;
+// X86_64:typedef int8_t int_least8_t;
+// X86_64:typedef uint8_t uint_least8_t;
+// X86_64:typedef int8_t int_fast8_t;
+// X86_64:typedef uint8_t uint_fast8_t;
+//
+// X86_64:typedef int64_t intptr_t;
+// X86_64:typedef uint64_t uintptr_t;
+//
+// X86_64:typedef long int intmax_t;
+// X86_64:typedef long unsigned int uintmax_t;
+//
+// X86_64:INT8_MAX_ 127
+// X86_64:INT8_MIN_ (-127 -1)
+// X86_64:UINT8_MAX_ 255
+// X86_64:INT_LEAST8_MIN_ (-127 -1)
+// X86_64:INT_LEAST8_MAX_ 127
+// X86_64:UINT_LEAST8_MAX_ 255
+// X86_64:INT_FAST8_MIN_ (-127 -1)
+// X86_64:INT_FAST8_MAX_ 127
+// X86_64:UINT_FAST8_MAX_ 255
+//
+// X86_64:INT16_MAX_ 32767
+// X86_64:INT16_MIN_ (-32767 -1)
+// X86_64:UINT16_MAX_ 65535
+// X86_64:INT_LEAST16_MIN_ (-32767 -1)
+// X86_64:INT_LEAST16_MAX_ 32767
+// X86_64:UINT_LEAST16_MAX_ 65535
+// X86_64:INT_FAST16_MIN_ (-32767 -1)
+// X86_64:INT_FAST16_MAX_ 32767
+// X86_64:UINT_FAST16_MAX_ 65535
+//
+// X86_64:INT32_MAX_ 2147483647
+// X86_64:INT32_MIN_ (-2147483647 -1)
+// X86_64:UINT32_MAX_ 4294967295U
+// X86_64:INT_LEAST32_MIN_ (-2147483647 -1)
+// X86_64:INT_LEAST32_MAX_ 2147483647
+// X86_64:UINT_LEAST32_MAX_ 4294967295U
+// X86_64:INT_FAST32_MIN_ (-2147483647 -1)
+// X86_64:INT_FAST32_MAX_ 2147483647
+// X86_64:UINT_FAST32_MAX_ 4294967295U
+//
+// X86_64:INT64_MAX_ 9223372036854775807L
+// X86_64:INT64_MIN_ (-9223372036854775807L -1)
+// X86_64:UINT64_MAX_ 18446744073709551615UL
+// X86_64:INT_LEAST64_MIN_ (-9223372036854775807L -1)
+// X86_64:INT_LEAST64_MAX_ 9223372036854775807L
+// X86_64:UINT_LEAST64_MAX_ 18446744073709551615UL
+// X86_64:INT_FAST64_MIN_ (-9223372036854775807L -1)
+// X86_64:INT_FAST64_MAX_ 9223372036854775807L
+// X86_64:UINT_FAST64_MAX_ 18446744073709551615UL
+//
+// X86_64:INTPTR_MIN_ (-9223372036854775807L -1)
+// X86_64:INTPTR_MAX_ 9223372036854775807L
+// X86_64:UINTPTR_MAX_ 18446744073709551615UL
+// X86_64:PTRDIFF_MIN_ (-9223372036854775807L -1)
+// X86_64:PTRDIFF_MAX_ 9223372036854775807L
+// X86_64:SIZE_MAX_ 18446744073709551615UL
+//
+// X86_64:INTMAX_MIN_ (-9223372036854775807L -1)
+// X86_64:INTMAX_MAX_ 9223372036854775807L
+// X86_64:UINTMAX_MAX_ 18446744073709551615UL
+//
+// X86_64:SIG_ATOMIC_MIN_ (-2147483647 -1)
+// X86_64:SIG_ATOMIC_MAX_ 2147483647
+// X86_64:WINT_MIN_ (-2147483647 -1)
+// X86_64:WINT_MAX_ 2147483647
+//
+// X86_64:WCHAR_MAX_ 2147483647
+// X86_64:WCHAR_MIN_ (-2147483647 -1)
+//
+// X86_64:INT8_C_(0) 0
+// X86_64:UINT8_C_(0) 0U
+// X86_64:INT16_C_(0) 0
+// X86_64:UINT16_C_(0) 0U
+// X86_64:INT32_C_(0) 0
+// X86_64:UINT32_C_(0) 0U
+// X86_64:INT64_C_(0) 0L
+// X86_64:UINT64_C_(0) 0UL
+//
+// X86_64:INTMAX_C_(0) 0L
+// X86_64:UINTMAX_C_(0) 0UL
+//
+//
+// RUN: %clang_cc1 -E -ffreestanding -triple=x86_64-pc-linux-gnu %s | FileCheck -check-prefix X86_64_LINUX %s
+//
+// X86_64_LINUX:WINT_MIN_ 0U
+// X86_64_LINUX:WINT_MAX_ 4294967295U
+//
+//
+// RUN: %clang_cc1 -E -ffreestanding -triple=i386-mingw32 %s | FileCheck -check-prefix I386_MINGW32 %s
+//
+// I386_MINGW32:WCHAR_MAX_ 65535U
+// I386_MINGW32:WCHAR_MIN_ 0U
+//
+//
+// stdint.h forms several macro definitions by pasting together identifiers
+// to form names (eg. int32_t is formed from int ## 32 ## _t). The following
+// case tests that these joining operations are performed correctly even if
+// the identifiers used in the operations (int, uint, _t, INT, UINT, _MIN,
+// _MAX, and _C(v)) are themselves macros.
+//
+// RUN: %clang_cc1 -E -ffreestanding -U__UINTMAX_TYPE__ -U__INTMAX_TYPE__ -Dint=a -Duint=b -D_t=c -DINT=d -DUINT=e -D_MIN=f -D_MAX=g '-D_C(v)=h' -triple=i386-none-none %s | FileCheck -check-prefix JOIN %s
+// JOIN:typedef int32_t intptr_t;
+// JOIN:typedef uint32_t uintptr_t;
+// JOIN:typedef __INTMAX_TYPE__ intmax_t;
+// JOIN:typedef __UINTMAX_TYPE__ uintmax_t;
+// JOIN:INTPTR_MIN_ (-2147483647 -1)
+// JOIN:INTPTR_MAX_ 2147483647
+// JOIN:UINTPTR_MAX_ 4294967295U
+// JOIN:PTRDIFF_MIN_ (-2147483647 -1)
+// JOIN:PTRDIFF_MAX_ 2147483647
+// JOIN:SIZE_MAX_ 4294967295U
+// JOIN:INTMAX_MIN_ (-9223372036854775807LL -1)
+// JOIN:INTMAX_MAX_ 9223372036854775807LL
+// JOIN:UINTMAX_MAX_ 18446744073709551615ULL
+// JOIN:SIG_ATOMIC_MIN_ (-2147483647 -1)
+// JOIN:SIG_ATOMIC_MAX_ 2147483647
+// JOIN:WINT_MIN_ (-2147483647 -1)
+// JOIN:WINT_MAX_ 2147483647
+// JOIN:WCHAR_MAX_ 2147483647
+// JOIN:WCHAR_MIN_ (-2147483647 -1)
+// JOIN:INTMAX_C_(0) 0LL
+// JOIN:UINTMAX_C_(0) 0ULL
+
+#include <stdint.h>
+
+INT8_MAX_ INT8_MAX
+INT8_MIN_ INT8_MIN
+UINT8_MAX_ UINT8_MAX
+INT_LEAST8_MIN_ INT_LEAST8_MIN
+INT_LEAST8_MAX_ INT_LEAST8_MAX
+UINT_LEAST8_MAX_ UINT_LEAST8_MAX
+INT_FAST8_MIN_ INT_FAST8_MIN
+INT_FAST8_MAX_ INT_FAST8_MAX
+UINT_FAST8_MAX_ UINT_FAST8_MAX
+
+INT16_MAX_ INT16_MAX
+INT16_MIN_ INT16_MIN
+UINT16_MAX_ UINT16_MAX
+INT_LEAST16_MIN_ INT_LEAST16_MIN
+INT_LEAST16_MAX_ INT_LEAST16_MAX
+UINT_LEAST16_MAX_ UINT_LEAST16_MAX
+INT_FAST16_MIN_ INT_FAST16_MIN
+INT_FAST16_MAX_ INT_FAST16_MAX
+UINT_FAST16_MAX_ UINT_FAST16_MAX
+
+INT32_MAX_ INT32_MAX
+INT32_MIN_ INT32_MIN
+UINT32_MAX_ UINT32_MAX
+INT_LEAST32_MIN_ INT_LEAST32_MIN
+INT_LEAST32_MAX_ INT_LEAST32_MAX
+UINT_LEAST32_MAX_ UINT_LEAST32_MAX
+INT_FAST32_MIN_ INT_FAST32_MIN
+INT_FAST32_MAX_ INT_FAST32_MAX
+UINT_FAST32_MAX_ UINT_FAST32_MAX
+
+INT64_MAX_ INT64_MAX
+INT64_MIN_ INT64_MIN
+UINT64_MAX_ UINT64_MAX
+INT_LEAST64_MIN_ INT_LEAST64_MIN
+INT_LEAST64_MAX_ INT_LEAST64_MAX
+UINT_LEAST64_MAX_ UINT_LEAST64_MAX
+INT_FAST64_MIN_ INT_FAST64_MIN
+INT_FAST64_MAX_ INT_FAST64_MAX
+UINT_FAST64_MAX_ UINT_FAST64_MAX
+
+INTPTR_MIN_ INTPTR_MIN
+INTPTR_MAX_ INTPTR_MAX
+UINTPTR_MAX_ UINTPTR_MAX
+PTRDIFF_MIN_ PTRDIFF_MIN
+PTRDIFF_MAX_ PTRDIFF_MAX
+SIZE_MAX_ SIZE_MAX
+
+INTMAX_MIN_ INTMAX_MIN
+INTMAX_MAX_ INTMAX_MAX
+UINTMAX_MAX_ UINTMAX_MAX
+
+SIG_ATOMIC_MIN_ SIG_ATOMIC_MIN
+SIG_ATOMIC_MAX_ SIG_ATOMIC_MAX
+WINT_MIN_ WINT_MIN
+WINT_MAX_ WINT_MAX
+
+WCHAR_MAX_ WCHAR_MAX
+WCHAR_MIN_ WCHAR_MIN
+
+INT8_C_(0) INT8_C(0)
+UINT8_C_(0) UINT8_C(0)
+INT16_C_(0) INT16_C(0)
+UINT16_C_(0) UINT16_C(0)
+INT32_C_(0) INT32_C(0)
+UINT32_C_(0) UINT32_C(0)
+INT64_C_(0) INT64_C(0)
+UINT64_C_(0) UINT64_C(0)
+
+INTMAX_C_(0) INTMAX_C(0)
+UINTMAX_C_(0) UINTMAX_C(0)
diff --git a/clang/test/Preprocessor/stringize_misc.c b/clang/test/Preprocessor/stringize_misc.c
new file mode 100644
index 0000000..6c2c78d
--- /dev/null
+++ b/clang/test/Preprocessor/stringize_misc.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -E %s | FileCheck -strict-whitespace %s
+
+#define M(x, y) #x #y
+
+M( f(1, 2), g((x=y++, y)))
+// CHECK: "f(1, 2)" "g((x=y++, y))"
+
+M( {a=1 , b=2;} ) /* A semicolon is not a comma */
+// CHECK: "{a=1" "b=2;}"
+
+M( <, [ ) /* Passes the arguments < and [ */
+// CHECK: "<" "["
+
+M( (,), (...) ) /* Passes the arguments (,) and (...) */
+// CHECK: "(,)" "(...)"
+
+#define START_END(start, end) start c=3; end
+
+START_END( {a=1 , b=2;} ) /* braces are not parentheses */
+// CHECK: {a=1 c=3; b=2;}
+
+/*
+ * To pass a comma token as an argument it is
+ * necessary to write:
+ */
+#define COMMA ,
+
+M(a COMMA b, (a, b))
+// CHECK: "a COMMA b" "(a, b)"
+
diff --git a/clang/test/Preprocessor/stringize_space.c b/clang/test/Preprocessor/stringize_space.c
new file mode 100644
index 0000000..263cff8
--- /dev/null
+++ b/clang/test/Preprocessor/stringize_space.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -E %s | grep -- '-"" , - "" , -"" , - ""'
+
+#define A(b) -#b , - #b , -# b , - # b
+A()
diff --git a/clang/test/Preprocessor/stringize_space2.c b/clang/test/Preprocessor/stringize_space2.c
new file mode 100644
index 0000000..a87d78e
--- /dev/null
+++ b/clang/test/Preprocessor/stringize_space2.c
@@ -0,0 +1,6 @@
+/* RUN: %clang_cc1 -E %s | grep 'a c'
+ */
+#define t(x) #x
+t(a
+c)
+
diff --git a/clang/test/Preprocessor/traditional-cpp.c b/clang/test/Preprocessor/traditional-cpp.c
new file mode 100644
index 0000000..5fc9ee3
--- /dev/null
+++ b/clang/test/Preprocessor/traditional-cpp.c
@@ -0,0 +1,12 @@
+/* Clang supports a very limited subset of -traditional-cpp, basically we only
+ * intend to add support for things that people actually rely on when doing
+ * things like using /usr/bin/cpp to preprocess non-source files. */
+
+/*
+ RUN: %clang_cc1 -traditional-cpp %s -E -o %t
+ RUN: FileCheck < %t %s
+*/
+
+/* CHECK: foo // bar
+ */
+foo // bar
diff --git a/clang/test/Preprocessor/undef-error.c b/clang/test/Preprocessor/undef-error.c
new file mode 100644
index 0000000..ad611de
--- /dev/null
+++ b/clang/test/Preprocessor/undef-error.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -pedantic-errors -verify
+// PR2045
+
+#define b
+/* expected-error {{extra tokens at end of #undef directive}} */ #undef a b
diff --git a/clang/test/Preprocessor/unterminated.c b/clang/test/Preprocessor/unterminated.c
new file mode 100644
index 0000000..9180653
--- /dev/null
+++ b/clang/test/Preprocessor/unterminated.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -E -verify %s
+// PR3096
+#ifdef FOO // expected-error {{unterminated conditional directive}}
+/* /* */
+
diff --git a/clang/test/Preprocessor/user_defined_system_framework.c b/clang/test/Preprocessor/user_defined_system_framework.c
new file mode 100644
index 0000000..8e3db56
--- /dev/null
+++ b/clang/test/Preprocessor/user_defined_system_framework.c
@@ -0,0 +1,8 @@
+// RUN: %clang -cc1 -fsyntax-only -F %S/Inputs -Wsign-conversion -verify %s
+
+// Check that TestFramework is treated as a system header.
+#include <TestFramework/TestFramework.h>
+
+int f1() {
+ return test_framework_func(1) + another_test_framework_func(2);
+}
diff --git a/clang/test/Preprocessor/warn-disabled-macro-expansion.c b/clang/test/Preprocessor/warn-disabled-macro-expansion.c
new file mode 100644
index 0000000..fe8e90c
--- /dev/null
+++ b/clang/test/Preprocessor/warn-disabled-macro-expansion.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -E -Wdisabled-macro-expansion -verify
+
+#define p p
+
+#define a b
+#define b a
+
+#define f(a) a
+
+#define g(b) a
+
+#define h(x) i(x)
+#define i(y) i(y)
+
+#define c(x) x(0)
+
+p // expected-warning {{recursive macro}}
+
+a // expected-warning {{recursive macro}}
+
+f(2)
+
+g(3) // expected-warning {{recursive macro}}
+
+h(0) // expected-warning {{recursive macro}}
+
+c(c) // expected-warning {{recursive macro}}
diff --git a/clang/test/Preprocessor/warn-macro-unused.c b/clang/test/Preprocessor/warn-macro-unused.c
new file mode 100644
index 0000000..c33aeb5
--- /dev/null
+++ b/clang/test/Preprocessor/warn-macro-unused.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -Wunused-macros -Dfoo -Dfoo -verify
+
+#include "warn-macro-unused.h"
+
+#define unused // expected-warning {{macro is not used}}
+#define unused
+unused
+
+// rdar://9745065
+#undef unused_from_header // no warning
diff --git a/clang/test/Preprocessor/warn-macro-unused.h b/clang/test/Preprocessor/warn-macro-unused.h
new file mode 100644
index 0000000..0c2c267
--- /dev/null
+++ b/clang/test/Preprocessor/warn-macro-unused.h
@@ -0,0 +1 @@
+#define unused_from_header
diff --git a/clang/test/Preprocessor/warning_tests.c b/clang/test/Preprocessor/warning_tests.c
new file mode 100644
index 0000000..96b96ef
--- /dev/null
+++ b/clang/test/Preprocessor/warning_tests.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+#ifndef __has_warning
+#error Should have __has_warning
+#endif
+
+#if __has_warning("not valid") // expected-warning {{__has_warning expected option name}}
+#endif
+
+#if __has_warning("-Wparentheses")
+#warning Should have -Wparentheses // expected-warning {{Should have -Wparentheses}}
+#endif
+
+#if __has_warning(-Wfoo) // expected-error {{builtin warning check macro requires a parenthesized string}}
+#endif
+
+#if __has_warning("-Wnot-a-valid-warning-flag-at-all")
+#else
+#warning Not a valid warning flag // expected-warning {{Not a valid warning flag}}
+#endif \ No newline at end of file
diff --git a/clang/test/Preprocessor/x86_target_features.c b/clang/test/Preprocessor/x86_target_features.c
new file mode 100644
index 0000000..ad7ee85
--- /dev/null
+++ b/clang/test/Preprocessor/x86_target_features.c
@@ -0,0 +1,32 @@
+// RUN: %clang -target i386-unknown-unknown -march=core2 -msse4 -x c -E -dM -o %t %s
+// RUN: grep '#define __SSE2_MATH__ 1' %t
+// RUN: grep '#define __SSE2__ 1' %t
+// RUN: grep '#define __SSE3__ 1' %t
+// RUN: grep '#define __SSE4_1__ 1' %t
+// RUN: grep '#define __SSE4_2__ 1' %t
+// RUN: grep '#define __SSE_MATH__ 1' %t
+// RUN: grep '#define __SSE__ 1' %t
+// RUN: grep '#define __SSSE3__ 1' %t
+
+// RUN: %clang -target i386-unknown-unknown -march=core2 -msse4 -mno-sse2 -x c -E -dM -o %t %s
+// RUN: grep '#define __SSE2_MATH__ 1' %t | count 0
+// RUN: grep '#define __SSE2__ 1' %t | count 0
+// RUN: grep '#define __SSE3__ 1' %t | count 0
+// RUN: grep '#define __SSE4_1__ 1' %t | count 0
+// RUN: grep '#define __SSE4_2__ 1' %t | count 0
+// RUN: grep '#define __SSE_MATH__ 1' %t
+// RUN: grep '#define __SSE__ 1' %t
+// RUN: grep '#define __SSSE3__ 1' %t | count 0
+
+// RUN: %clang -target i386-unknown-unknown -march=pentium-m -x c -E -dM -o %t %s
+// RUN: grep '#define __SSE2_MATH__ 1' %t
+// RUN: grep '#define __SSE2__ 1' %t
+// RUN: grep '#define __SSE3__ 1' %t | count 0
+// RUN: grep '#define __SSE4_1__ 1' %t | count 0
+// RUN: grep '#define __SSE4_2__ 1' %t | count 0
+// RUN: grep '#define __SSE_MATH__ 1' %t
+// RUN: grep '#define __SSE__ 1' %t
+// RUN: grep '#define __SSSE3__ 1' %t | count 0
+
+
+
diff --git a/clang/test/Rewriter/blockcast3.mm b/clang/test/Rewriter/blockcast3.mm
new file mode 100644
index 0000000..ceafcff
--- /dev/null
+++ b/clang/test/Rewriter/blockcast3.mm
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %t.mm -o %t-rw.cpp
+// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o %t-modern-rw.cpp
+// RUN: FileCheck -check-prefix LP --input-file=%t-modern-rw.cpp %s
+// radar 7607781
+
+typedef struct {
+ int a;
+ int b;
+} mystruct;
+
+void g(int (^block)(mystruct s)) {
+ mystruct x;
+ int v = block(x);
+}
+
+void f(const void **arg) {
+ __block const void **q = arg;
+ g(^(mystruct s){
+ *q++ = (void*)s.a;
+ return 314;
+ });
+}
+
+// CHECK-LP: (__Block_byref_q_0 *)&q
diff --git a/clang/test/Rewriter/blockstruct.m b/clang/test/Rewriter/blockstruct.m
new file mode 100644
index 0000000..ef85c58
--- /dev/null
+++ b/clang/test/Rewriter/blockstruct.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://8918702
+
+typedef void (^b_t)(void);
+void a(b_t work) { }
+struct _s {
+ int a;
+};
+struct _s *r();
+
+void f() {
+ __block struct _s *s = 0;
+ a(^{
+ s = (struct _s *)r();
+ });
+}
diff --git a/clang/test/Rewriter/crash.m b/clang/test/Rewriter/crash.m
new file mode 100644
index 0000000..c61100e
--- /dev/null
+++ b/clang/test/Rewriter/crash.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi -o - %s
+// rdar://5950938
+@interface NSArray {}
++ (id)arrayWithObjects:(id)firstObj, ...;
+@end
+
+@interface NSConstantString {}
+@end
+
+int main() {
+ id foo = [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", @"11", @"12", 0];
+ return 0;
+}
+
+// rdar://6291588
+@protocol A
+@end
+
+@interface Foo
+@end
+
+void func() {
+ id <A> obj = (id <A>)[Foo bar];
+}
+
diff --git a/clang/test/Rewriter/dllimport-typedef.c b/clang/test/Rewriter/dllimport-typedef.c
new file mode 100644
index 0000000..72cea70
--- /dev/null
+++ b/clang/test/Rewriter/dllimport-typedef.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-NEG %s
+// RUN: %clang_cc1 -triple i686-pc-win32 -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-POS %s
+
+// Do not report an error with including dllimport in the typedef when -fms-extensions is specified.
+// Addresses <rdar://problem/7653870>.
+typedef __declspec(dllimport) int CB(void);
+
+// This function is added just to trigger a diagnostic. This way we can test how many
+// diagnostics we expect.
+void bar() { return 1; }
+
+// CHECK-NEG: error: void function 'bar' should not return a value
+// CHECK-NEG: 1 error generated
+// CHECK-POS: warning: 'dllimport' attribute only applies to variables and functions
+// CHECK-POS: error: void function 'bar' should not return a value
+// CHECK-POS: 1 warning and 1 error generated
+
diff --git a/clang/test/Rewriter/finally.m b/clang/test/Rewriter/finally.m
new file mode 100644
index 0000000..8fd475c
--- /dev/null
+++ b/clang/test/Rewriter/finally.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi -fobjc-exceptions -verify %s -o -
+
+int main() {
+ @try {
+ printf("executing try"); // expected-warning{{implicitly declaring library function 'printf' with type 'int (const char *, ...)'}} \
+ // expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
+ return(0); // expected-warning{{rewriter doesn't support user-specified control flow semantics for @try/@finally (code may not execute properly)}}
+ } @finally {
+ printf("executing finally");
+ }
+ while (1) {
+ @try {
+ printf("executing try");
+ break;
+ } @finally {
+ printf("executing finally");
+ }
+ printf("executing after finally block");
+ }
+ @try {
+ printf("executing try");
+ } @finally {
+ printf("executing finally");
+ }
+ return 0;
+}
+
+void test_sync_with_implicit_finally() {
+ id foo;
+ @synchronized (foo) {
+ return; // The rewriter knows how to generate code for implicit finally
+ }
+}
+
+void test2_try_with_implicit_finally() {
+ @try {
+ return; // The rewriter knows how to generate code for implicit finally
+ } @catch (id e) {
+
+ }
+}
+
diff --git a/clang/test/Rewriter/func-in-impl.m b/clang/test/Rewriter/func-in-impl.m
new file mode 100644
index 0000000..350a726
--- /dev/null
+++ b/clang/test/Rewriter/func-in-impl.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -E %s -o %t.m
+// RUN: %clang_cc1 -fobjc-fragile-abi -rewrite-objc %t.m -o - | FileCheck %s
+
+@interface I {
+ id _delegate;
+}
+-(void)foo;
+@end
+
+@implementation I
+
+static void KKKK(int w);
+
+-(void) foo {
+ KKKK(0);
+}
+
+static void KKKK(int w) {
+ I *self = (I *)0;
+ if ([self->_delegate respondsToSelector:@selector(handlePortMessage:)]) {
+ }
+}
+
+-(void) foo2 {
+ KKKK(0);
+}
+
+@end
+
+// CHECK: if (((id (*)(id, SEL, ...))(void *)objc_msgSend)((id)((struct I_IMPL *)self)->_delegate, sel_registerName("respondsToSelector:"), sel_registerName("handlePortMessage:")))
diff --git a/clang/test/Rewriter/id-test-3.m b/clang/test/Rewriter/id-test-3.m
new file mode 100644
index 0000000..d7a7bf3
--- /dev/null
+++ b/clang/test/Rewriter/id-test-3.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@protocol P
+- (id<P>) Meth: (id<P>) Arg;
+@end
+
+@interface INTF<P>
+- (id<P>)IMeth;
+@end
+
+@implementation INTF
+- (id<P>)IMeth { return [(id<P>)self Meth: (id<P>)0]; }
+- (id<P>) Meth : (id<P>) Arg { return 0; }
+@end
diff --git a/clang/test/Rewriter/inner-block-helper-funcs.mm b/clang/test/Rewriter/inner-block-helper-funcs.mm
new file mode 100644
index 0000000..d30e1dc
--- /dev/null
+++ b/clang/test/Rewriter/inner-block-helper-funcs.mm
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
+// rdar://9846759
+
+typedef void (^dispatch_block_t)(void);
+
+extern int printf(const char*, ...);
+
+extern "C" dispatch_block_t Block_copy(dispatch_block_t aBlock);
+
+int main (int argc, char *argv[]) {
+
+ dispatch_block_t innerBlock = ^{printf("argc = %d\n", argc); };
+ id innerObject = 0;
+
+ printf("innerBlock is %x\n", innerBlock);
+
+ dispatch_block_t wrapperBlock = ^{
+ printf("innerBlock is %x %x\n", innerBlock, innerObject);
+ };
+
+ wrapperBlock();
+
+ dispatch_block_t copiedBlock = Block_copy(wrapperBlock);
+ copiedBlock();
+
+ return 0;
+}
+// CHECK-LP: _Block_object_assign((void*)&dst->innerBlock, (void*)src->innerBlock, 7
+// CHECK-LP: _Block_object_dispose((void*)src->innerBlock, 7
+// CHECK-LP: _Block_object_assign((void*)&dst->innerObject, (void*)src->innerObject, 3
+// CHECK-LP: _Block_object_dispose((void*)src->innerObject, 3
diff --git a/clang/test/Rewriter/instancetype-test.mm b/clang/test/Rewriter/instancetype-test.mm
new file mode 100644
index 0000000..7885055
--- /dev/null
+++ b/clang/test/Rewriter/instancetype-test.mm
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+
+void *sel_registerName(const char *);
+
+@interface Root
++ (instancetype)alloc;
+- (instancetype)init; // expected-note{{overridden method is part of the 'init' method family}}
+- (instancetype)self;
+- (Class)class;
+
+@property (assign) Root *selfProp;
+- (instancetype)selfProp;
+@end
+
+@protocol Proto1
+@optional
+- (instancetype)methodInProto1;
+@end
+
+@protocol Proto2
+@optional
+- (instancetype)methodInProto2; // expected-note{{overridden method returns an instance of its class type}}
+- (instancetype)otherMethodInProto2; // expected-note{{overridden method returns an instance of its class type}}
+@end
+
+@interface Subclass1 : Root
+- (instancetype)initSubclass1;
+- (void)methodOnSubclass1;
++ (instancetype)allocSubclass1;
+@end
+
+@interface Subclass2 : Root
+- (instancetype)initSubclass2;
+- (void)methodOnSubclass2;
+@end
+
+// Sanity check: the basic initialization pattern.
+void test_instancetype_alloc_init_simple() {
+ Root *r1 = [[Root alloc] init];
+ Subclass1 *sc1 = [[Subclass1 alloc] init];
+}
+
+// Test that message sends to instancetype methods have the right type.
+void test_instancetype_narrow_method_search() {
+ // instancetype on class methods
+ Subclass1 *sc1 = [[Subclass1 alloc] initSubclass2]; // expected-warning{{'Subclass1' may not respond to 'initSubclass2'}}
+ Subclass2 *sc2 = [[Subclass2 alloc] initSubclass2]; // okay
+
+ // instancetype on instance methods
+ [[[Subclass1 alloc] init] methodOnSubclass2]; // expected-warning{{'Subclass1' may not respond to 'methodOnSubclass2'}}
+ [[[Subclass2 alloc] init] methodOnSubclass2];
+
+ // instancetype on class methods using protocols
+ [[Subclass1<Proto1> alloc] methodInProto2]; // expected-warning{{method '-methodInProto2' not found (return type defaults to 'id')}}
+ [[Subclass1<Proto2> alloc] methodInProto2];
+
+ // instancetype on instance methods
+ Subclass1<Proto1> *sc1proto1 = 0;
+ [[sc1proto1 self] methodInProto2]; // expected-warning{{method '-methodInProto2' not found (return type defaults to 'id')}}
+ Subclass1<Proto2> *sc1proto2 = 0;
+ [[sc1proto2 self] methodInProto2];
+
+ // Exact type checks
+ // Message sends to Class.
+ // FIXME. This is not supported due to missing capability in rewriter and not due to instancetype issues
+ // Subclass1<Proto1> *sc1proto1_2 = [[[sc1proto1 class] alloc] init];
+
+ // Property access
+ [sc1proto1.self methodInProto2]; // expected-warning{{method '-methodInProto2' not found (return type defaults to 'id')}}
+ [sc1proto2.self methodInProto2];
+
+ [sc1proto1.selfProp methodInProto2]; // expected-warning{{method '-methodInProto2' not found (return type defaults to 'id')}}
+ [sc1proto2.selfProp methodInProto2];
+}
diff --git a/clang/test/Rewriter/ivar-encoding-1.m b/clang/test/Rewriter/ivar-encoding-1.m
new file mode 100644
index 0000000..d294943
--- /dev/null
+++ b/clang/test/Rewriter/ivar-encoding-1.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@interface Intf
+{
+ id ivar;
+ id ivar1[12];
+
+ id **ivar3;
+
+ id (*ivar4) (id, id);
+}
+@end
+
+@implementation Intf
+@end
diff --git a/clang/test/Rewriter/ivar-encoding-2.m b/clang/test/Rewriter/ivar-encoding-2.m
new file mode 100644
index 0000000..da60c79
--- /dev/null
+++ b/clang/test/Rewriter/ivar-encoding-2.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@implementation Intf
+{
+ id ivar;
+ id ivar1[12];
+
+ id **ivar3;
+
+ id (*ivar4) (id, id);
+}
+@end
diff --git a/clang/test/Rewriter/metadata-test-1.m b/clang/test/Rewriter/metadata-test-1.m
new file mode 100644
index 0000000..b2d6e8d
--- /dev/null
+++ b/clang/test/Rewriter/metadata-test-1.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@interface Intf
+@end
+
+@implementation Intf(Category)
+- (void) CatMeth {}
+@end
+
+@implementation Another
+- (void) CatMeth {}
+@end
diff --git a/clang/test/Rewriter/metadata-test-2.m b/clang/test/Rewriter/metadata-test-2.m
new file mode 100644
index 0000000..90399f7
--- /dev/null
+++ b/clang/test/Rewriter/metadata-test-2.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+typedef struct _NSPoint {
+ float x;
+ float y;
+} NSPoint;
+
+@interface Intf
+- (void) MyMeth : (NSPoint) Arg1;
+@end
+
+@implementation Intf
+- (void) MyMeth : (NSPoint) Arg1{}
+@end
+
diff --git a/clang/test/Rewriter/method-encoding-1.m b/clang/test/Rewriter/method-encoding-1.m
new file mode 100644
index 0000000..27abea5
--- /dev/null
+++ b/clang/test/Rewriter/method-encoding-1.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@protocol P1
+- (void) MyProtoMeth : (int **) arg1 : (void*) arg2;
++ (void) MyProtoMeth : (int **) arg1 : (void*) arg2;
+@end
+
+@interface Intf <P1>
+- (char *) MyMeth : (double) arg1 : (char *[12]) arg2;
+- (id) address:(void *)location with:(unsigned **)arg2;
+@end
+
+@implementation Intf
+- (char *) MyMeth : (double) arg1 : (char *[12]) arg2{ return 0; }
+- (void) MyProtoMeth : (int **) arg1 : (void*) arg2 {}
++ (void) MyProtoMeth : (int **) arg1 : (void*) arg2 {}
+- (id) address:(void *)location with:(unsigned **)arg2{ return 0; }
+@end
diff --git a/clang/test/Rewriter/missing-dllimport.c b/clang/test/Rewriter/missing-dllimport.c
new file mode 100644
index 0000000..1dfc04c
--- /dev/null
+++ b/clang/test/Rewriter/missing-dllimport.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-NEG %s
+// RUN: %clang_cc1 -triple i686-pc-win32 -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-POS %s
+
+// Do not report that 'foo()' is redeclared without dllimport attribute with -fms-extensions
+// specified. Addresses <rdar://problem/7653912>.
+
+__declspec(dllimport) int __cdecl foo(void);
+inline int __cdecl foo() { return 0; }
+
+// This function is added just to trigger a diagnostic. This way we can test how many
+// diagnostics we expect.
+void bar() { return 1; }
+
+// CHECK-NEG: error: void function 'bar' should not return a value
+// CHECK-NEG: 1 error generated
+// CHECK-POS: warning: 'foo' redeclared without dllimport attribute: previous dllimport ignored
+// CHECK-POS: error: void function 'bar' should not return a value
+// CHECK-POS: 1 warning and 1 error generated
+
diff --git a/clang/test/Rewriter/objc-bool-literal-check-modern.mm b/clang/test/Rewriter/objc-bool-literal-check-modern.mm
new file mode 100644
index 0000000..3386197
--- /dev/null
+++ b/clang/test/Rewriter/objc-bool-literal-check-modern.mm
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+// rdar://11124775
+
+typedef bool BOOL;
+
+BOOL yes() {
+ return __objc_yes;
+}
+
+BOOL no() {
+ return __objc_no;
+}
+
+BOOL which (int flag) {
+ return flag ? yes() : no();
+}
+
+int main() {
+ which (__objc_yes);
+ which (__objc_no);
+ return __objc_yes;
+}
+
+// CHECK: return ((bool)1);
+// CHECK: return ((bool)0);
+// CHECK: which (((bool)1));
+// CHECK: which (((bool)0));
+// CHECK: return ((bool)1);
diff --git a/clang/test/Rewriter/objc-bool-literal-modern-1.mm b/clang/test/Rewriter/objc-bool-literal-modern-1.mm
new file mode 100644
index 0000000..7825172
--- /dev/null
+++ b/clang/test/Rewriter/objc-bool-literal-modern-1.mm
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"__declspec(X)=" %t-rw.cpp
+// rdar://11231426
+
+typedef bool BOOL;
+
+BOOL yes() {
+ return __objc_yes;
+}
+
+BOOL no() {
+ return __objc_no;
+}
+
+BOOL which (int flag) {
+ return flag ? yes() : no();
+}
+
+int main() {
+ which (__objc_yes);
+ which (__objc_no);
+ return __objc_yes;
+}
+
+void y(BOOL (^foo)());
+
+void x() {
+ y(^{
+ return __objc_yes;
+ });
+}
diff --git a/clang/test/Rewriter/objc-bool-literal-modern.mm b/clang/test/Rewriter/objc-bool-literal-modern.mm
new file mode 100644
index 0000000..328ee6b
--- /dev/null
+++ b/clang/test/Rewriter/objc-bool-literal-modern.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -x objective-c++ -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -D"__declspec(X)=" %t-rw.cpp
+// rdar://11124775
+
+typedef bool BOOL;
+
+BOOL yes() {
+ return __objc_yes;
+}
+
+BOOL no() {
+ return __objc_no;
+}
+
+BOOL which (int flag) {
+ return flag ? yes() : no();
+}
+
+int main() {
+ which (__objc_yes);
+ which (__objc_no);
+ return __objc_yes;
+}
diff --git a/clang/test/Rewriter/objc-encoding-bug-1.m b/clang/test/Rewriter/objc-encoding-bug-1.m
new file mode 100644
index 0000000..083b570
--- /dev/null
+++ b/clang/test/Rewriter/objc-encoding-bug-1.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+typedef struct NSMethodFrameArgInfo {
+ struct NSMethodFrameArgInfo *subInfo;
+ struct NSMethodFrameArgInfo *an;
+} NSMethodFrameArgInfo;
+
+@interface NSMethodSignature
+- (NSMethodFrameArgInfo *)_argInfo;
+@end
+
+@implementation NSMethodSignature
+
+- (NSMethodFrameArgInfo *)_argInfo{
+ return 0;
+}
+
+@end
+
diff --git a/clang/test/Rewriter/objc-ivar-receiver-1.m b/clang/test/Rewriter/objc-ivar-receiver-1.m
new file mode 100644
index 0000000..5195042
--- /dev/null
+++ b/clang/test/Rewriter/objc-ivar-receiver-1.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - | grep 'newInv->_container'
+
+@interface NSMutableArray
+- (void)addObject:(id)addObject;
+@end
+
+@interface NSInvocation {
+@private
+ id _container;
+}
++ (NSInvocation *)invocationWithMethodSignature;
+
+@end
+
+@implementation NSInvocation
+
++ (NSInvocation *)invocationWithMethodSignature {
+ NSInvocation *newInv;
+ id obj = newInv->_container;
+ [newInv->_container addObject:0];
+ return 0;
+}
+@end
diff --git a/clang/test/Rewriter/objc-modern-class-init-hooks.mm b/clang/test/Rewriter/objc-modern-class-init-hooks.mm
new file mode 100644
index 0000000..c294c79
--- /dev/null
+++ b/clang/test/Rewriter/objc-modern-class-init-hooks.mm
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+// rdar:// 11124354
+
+@interface Root @end
+
+@interface Super : Root
+@end
+
+@interface Sub : Super
+@end
+
+@implementation Sub @end
+
+@implementation Root @end
+
+@interface Root(Cat) @end
+
+@interface Sub(Cat) @end
+
+@implementation Root(Cat) @end
+
+@implementation Sub(Cat) @end
+
+
+// CHECK: #pragma section(".objc_inithooks$B", long, read, write)
+// CHECK: __declspec(allocate(".objc_inithooks$B")) static void *OBJC_CLASS_SETUP[] = {
+// CHECK: (void *)&OBJC_CLASS_SETUP_$_Sub,
+// CHECK: (void *)&OBJC_CLASS_SETUP_$_Root,
+// CHECK: };
+
+// CHECK: #pragma section(".objc_inithooks$B", long, read, write)
+// CHECK: __declspec(allocate(".objc_inithooks$B")) static void *OBJC_CATEGORY_SETUP[] = {
+// CHECK: (void *)&OBJC_CATEGORY_SETUP_$_Root_$_Cat,
+// CHECK: (void *)&OBJC_CATEGORY_SETUP_$_Sub_$_Cat,
+// CHECK: };
diff --git a/clang/test/Rewriter/objc-modern-class-init.mm b/clang/test/Rewriter/objc-modern-class-init.mm
new file mode 100644
index 0000000..b0326a4
--- /dev/null
+++ b/clang/test/Rewriter/objc-modern-class-init.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar:// 11076938
+
+@interface Root @end
+
+@interface Super : Root
+@end
+
+@interface Sub : Super
+@end
+
+@implementation Sub @end
+
+@implementation Root @end
+
+@interface Root(Cat) @end
+
+@interface Sub(Cat) @end
+
+@implementation Root(Cat) @end
+
+@implementation Sub(Cat) @end
diff --git a/clang/test/Rewriter/objc-modern-container-subscript.mm b/clang/test/Rewriter/objc-modern-container-subscript.mm
new file mode 100644
index 0000000..d6bb9c2
--- /dev/null
+++ b/clang/test/Rewriter/objc-modern-container-subscript.mm
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://11203853
+
+void *sel_registerName(const char *);
+
+typedef unsigned int size_t;
+@protocol P @end
+
+@interface NSMutableArray
+#if __has_feature(objc_subscripting)
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+#endif
+@end
+
+#if __has_feature(objc_subscripting)
+@interface XNSMutableArray
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+#endif
+@end
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id)key;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@class NSString;
+
+int main() {
+ NSMutableArray<P> * array;
+ id oldObject = array[10];
+
+ array[10] = oldObject;
+
+ id unknown_array;
+ oldObject = unknown_array[1];
+
+ unknown_array[1] = oldObject;
+
+ NSMutableDictionary *dictionary;
+ NSString *key;
+ id newObject;
+ oldObject = dictionary[key];
+ dictionary[key] = newObject; // replace oldObject with newObject
+}
+
diff --git a/clang/test/Rewriter/objc-modern-implicit-cast.mm b/clang/test/Rewriter/objc-modern-implicit-cast.mm
new file mode 100644
index 0000000..e612199
--- /dev/null
+++ b/clang/test/Rewriter/objc-modern-implicit-cast.mm
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://11202764
+
+typedef void(^BL)(void);
+
+id return_id(void(^block)(void)) {
+ return block;
+}
+
+BL return_block(id obj) {
+ return obj;
+}
+
+int main()
+{
+ void(^block)(void);
+ id obj;
+ block = obj; // AnyPointerToBlockPointerCast
+ obj = block; // BlockPointerToObjCPointerCast
+
+ id obj1 = block;
+
+ void(^block1)(void) = obj1;
+
+ return_id(block1);
+
+ return_id(obj1);
+
+ return_block(block1);
+
+ return_block(obj1);
+}
diff --git a/clang/test/Rewriter/objc-modern-ivar-receiver-1.mm b/clang/test/Rewriter/objc-modern-ivar-receiver-1.mm
new file mode 100644
index 0000000..a5c17a6
--- /dev/null
+++ b/clang/test/Rewriter/objc-modern-ivar-receiver-1.mm
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+
+void *sel_registerName(const char *);
+
+@interface NSMutableArray
+- (void)addObject:(id)addObject;
+@end
+
+@interface NSInvocation {
+@private
+ id _container;
+}
++ (NSInvocation *)invocationWithMethodSignature;
+
+@end
+
+@implementation NSInvocation
+
++ (NSInvocation *)invocationWithMethodSignature {
+ NSInvocation *newInv;
+ id obj = newInv->_container;
+ [newInv->_container addObject:0];
+ return 0;
+}
+@end
+
+// CHECK: id obj = (*(id *)((char *)newInv + OBJC_IVAR_$_NSInvocation$_container));
+// rdar://11076938
+// CHECK: struct _class_t *superclass;
+// CHECK: extern "C" __declspec(dllimport) struct objc_cache _objc_empty_cache;
diff --git a/clang/test/Rewriter/objc-modern-linkage-spec.mm b/clang/test/Rewriter/objc-modern-linkage-spec.mm
new file mode 100644
index 0000000..028d787
--- /dev/null
+++ b/clang/test/Rewriter/objc-modern-linkage-spec.mm
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -x objective-c++ -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-attributes -D"__declspec(X)=" %t-rw.cpp
+// rdar://11169733
+
+extern "C" __declspec(dllexport)
+@interface Test @end
+
+@implementation Test @end
+
+extern "C" {
+__declspec(dllexport)
+@interface Test1 @end
+
+@implementation Test1 @end
+
+__declspec(dllexport)
+@interface Test2 @end
+
+@implementation Test2 @end
+};
+
diff --git a/clang/test/Rewriter/objc-modern-metadata-visibility.mm b/clang/test/Rewriter/objc-modern-metadata-visibility.mm
new file mode 100644
index 0000000..42adf86
--- /dev/null
+++ b/clang/test/Rewriter/objc-modern-metadata-visibility.mm
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+// rdar://11144048
+
+@class NSString;
+
+@interface NSObject {
+ Class isa;
+}
+@end
+
+@interface Sub : NSObject {
+ int subIvar;
+ NSString *nsstring;
+@private
+ id PrivateIvar;
+}
+@end
+
+@implementation Sub
+- (id) MyNSString { return subIvar ? PrivateIvar : nsstring; }
+@end
+
+@interface NSString @end
+@implementation NSString @end
+
+// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$subIvar;
+// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long OBJC_IVAR_$_Sub$PrivateIvar;
+// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$nsstring;
+// CHECK: #pragma warning(disable:4273)
+// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$subIvar
+// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$nsstring
+// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long int OBJC_IVAR_$_Sub$PrivateIvar
+// CHECK: extern "C" __declspec(dllimport) struct _class_t OBJC_METACLASS_$_NSObject;
+// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_METACLASS_$_Sub
+// CHECK: extern "C" __declspec(dllimport) struct _class_t OBJC_CLASS_$_NSObject;
+// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_Sub
+// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_NSString;
+// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_METACLASS_$_NSString
+// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_NSString
diff --git a/clang/test/Rewriter/objc-modern-numeric-literal.mm b/clang/test/Rewriter/objc-modern-numeric-literal.mm
new file mode 100644
index 0000000..5f0b1fc
--- /dev/null
+++ b/clang/test/Rewriter/objc-modern-numeric-literal.mm
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+// rdar://10803676
+
+extern "C" void *sel_registerName(const char *);
+
+typedef bool BOOL;
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+
+#if __has_feature(objc_bool)
+#define YES __objc_yes
+#define NO __objc_no
+#else
+#define YES ((BOOL)1)
+#define NO ((BOOL)0)
+#endif
+
+@interface NSNumber
++ (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 ;
+@end
+
+int main(int argc, const char *argv[]) {
+ // character literals.
+ NSNumber *theLetterZ = @'Z'; // equivalent to [NSNumber numberWithChar:'Z']
+
+ // integral literals.
+ NSNumber *fortyTwo = @42; // equivalent to [NSNumber numberWithInt:42]
+ NSNumber *fortyTwoUnsigned = @42U; // equivalent to [NSNumber numberWithUnsignedInt:42U]
+ NSNumber *fortyTwoLong = @42L; // equivalent to [NSNumber numberWithLong:42L]
+ NSNumber *fortyTwoLongLong = @42LL; // equivalent to [NSNumber numberWithLongLong:42LL]
+
+ // floating point literals.
+ NSNumber *piFloat = @3.141592654F; // equivalent to [NSNumber numberWithFloat:3.141592654F]
+ NSNumber *piDouble = @3.1415926535; // equivalent to [NSNumber numberWithDouble:3.1415926535]
+
+ // BOOL literals.
+ NSNumber *yesNumber = @YES; // equivalent to [NSNumber numberWithBool:YES]
+ NSNumber *noNumber = @NO; // equivalent to [NSNumber numberWithBool:NO]
+
+ NSNumber *trueNumber = @true; // equivalent to [NSNumber numberWithBool:(BOOL)true]
+ NSNumber *falseNumber = @false; // equivalent to [NSNumber numberWithBool:(BOOL)false]
+}
+
+// CHECK: NSNumber *theLetterZ = ((NSNumber *(*)(id, SEL, char))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithChar:"), 'Z');
+// CHECK: NSNumber *fortyTwo = ((NSNumber *(*)(id, SEL, int))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithInt:"), 42);
+// CHECK: NSNumber *fortyTwoUnsigned = ((NSNumber *(*)(id, SEL, unsigned int))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithUnsignedInt:"), 42U);
+// CHECK: NSNumber *fortyTwoLong = ((NSNumber *(*)(id, SEL, long))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithLong:"), 42L);
+// CHECK: NSNumber *fortyTwoLongLong = ((NSNumber *(*)(id, SEL, long long))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithLongLong:"), 42LL);
+// CHECK: NSNumber *piFloat = ((NSNumber *(*)(id, SEL, float))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithFloat:"), 3.1415927);
+// CHECK: NSNumber *piDouble = ((NSNumber *(*)(id, SEL, double))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithDouble:"), 3.1415926535);
+// CHECK: NSNumber *yesNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), true);
+// CHECK: NSNumber *noNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), false);
+// CHECK: NSNumber *trueNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), true);
+// CHECK: NSNumber *falseNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), false);
diff --git a/clang/test/Rewriter/objc-modern-property-attributes.mm b/clang/test/Rewriter/objc-modern-property-attributes.mm
new file mode 100644
index 0000000..7d74a95
--- /dev/null
+++ b/clang/test/Rewriter/objc-modern-property-attributes.mm
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+
+// rdar://11095151
+
+typedef void (^void_block_t)(void);
+
+@interface PropertyClass {
+ int q;
+ void_block_t __completion;
+ PropertyClass* YVAR;
+ id ID;
+}
+@property int q;
+@property int r;
+
+@property (copy) void_block_t completionBlock;
+@property (retain) PropertyClass* Yblock;
+@property (copy) id ID;
+
+@end
+
+@implementation PropertyClass
+@synthesize q; // attributes should be "Ti,Vq"
+@dynamic r; // attributes should be "Ti,D"
+@synthesize completionBlock=__completion; // "T@?,C,V__completion"
+@synthesize Yblock = YVAR; // "T@\"PropertyClass\",&,VYVAR"
+@synthesize ID; // "T@,C,VID"
+@end
+
+// CHECK: Ti,Vq
+// CHECK: Ti,D
+// CHECK: T@?,C,V__completion
+// CHECK: T@\"PropertyClass\",&,VYVAR
+
diff --git a/clang/test/Rewriter/objc-string-concat-1.m b/clang/test/Rewriter/objc-string-concat-1.m
new file mode 100644
index 0000000..80a9f04
--- /dev/null
+++ b/clang/test/Rewriter/objc-string-concat-1.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@class NSString;
+
+@interface NSConstantString;
+@end
+
+
+
+NSConstantString *t0 = @"123";
+NSConstantString *t = @"123" @"4567"; // concat
+NSConstantString *t1 = @"123" @"4567" /* COMMENT */ @"89"; // concat
+NSConstantString *t2 = @"123" @/* COMMENT */ "4567"; // concat
+
diff --git a/clang/test/Rewriter/objc-super-test.m b/clang/test/Rewriter/objc-super-test.m
new file mode 100644
index 0000000..fa95ad2
--- /dev/null
+++ b/clang/test/Rewriter/objc-super-test.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - | grep objc_msgSendSuper | grep MainMethod
+
+typedef struct objc_selector *SEL;
+typedef struct objc_object *id;
+
+@interface SUPER
+- (int) MainMethod;
+@end
+
+@interface MyDerived : SUPER
+- (int) instanceMethod;
+@end
+
+@implementation MyDerived
+- (int) instanceMethod {
+ return [super MainMethod];
+}
+@end
diff --git a/clang/test/Rewriter/objc-synchronized-1.m b/clang/test/Rewriter/objc-synchronized-1.m
new file mode 100644
index 0000000..df55536
--- /dev/null
+++ b/clang/test/Rewriter/objc-synchronized-1.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+id SYNCH_EXPR();
+void SYNCH_BODY();
+void SYNCH_BEFORE();
+void SYNC_AFTER();
+
+void foo(id sem)
+{
+ SYNCH_BEFORE();
+ @synchronized (SYNCH_EXPR()) {
+ SYNCH_BODY();
+ return;
+ }
+ SYNC_AFTER();
+ @synchronized ([sem self]) {
+ SYNCH_BODY();
+ return;
+ }
+}
diff --git a/clang/test/Rewriter/properties.m b/clang/test/Rewriter/properties.m
new file mode 100644
index 0000000..493fc3f
--- /dev/null
+++ b/clang/test/Rewriter/properties.m
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+void *sel_registerName(const char *);
+
+@interface Foo {
+ int i;
+ int rrrr;
+ Foo *o;
+}
+@property int i;
+@property(readonly) int rrrr;
+@property int d;
+@property(retain) Foo *o;
+
+- (void)foo;
+@end
+
+@implementation Foo
+@synthesize i;
+@synthesize rrrr;
+@synthesize o;
+
+@dynamic d;
+
+- (void)foo {
+ i = 99;
+}
+
+- (int)bar {
+ return i;
+}
+@end
+
+@interface Bar {
+}
+@end
+
+@implementation Bar
+
+static int func(int i) { return 0; }
+
+- (void)baz {
+ Foo *obj1, *obj2;
+ int i;
+ if (obj1.i == obj2.rrrr)
+ obj1.i = 33;
+ obj1.i = func(obj2.rrrr);
+ obj1.i = obj2.rrrr;
+ obj1.i = (obj2.rrrr);
+ [obj1 setI:[obj2 rrrr]];
+ obj1.i = [obj2 rrrr];
+ obj1.i = 3 + [obj2 rrrr];
+ i = obj1.o.i;
+ obj1.o.i = 77;
+}
+@end
diff --git a/clang/test/Rewriter/property-dot-syntax.mm b/clang/test/Rewriter/property-dot-syntax.mm
new file mode 100644
index 0000000..c8ee723
--- /dev/null
+++ b/clang/test/Rewriter/property-dot-syntax.mm
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar:// 8520727
+
+void *sel_registerName(const char *);
+
+@class NSString;
+
+@protocol CoreDAVAccountInfoProvider
+- (NSString *)userAgentHeader;
+@end
+
+@interface CoreDAVTask
+{
+ id<CoreDAVAccountInfoProvider> _accountInfoProvider;
+}
+- (void)METHOD;
+@end
+
+@implementation CoreDAVTask
+- (void)METHOD {
+ if ([_accountInfoProvider userAgentHeader]) {
+ }
+ if (_accountInfoProvider.userAgentHeader) {
+ }
+}
+@end
+
+//rdar: // 8541517
+@interface A { }
+@property (retain) NSString *scheme;
+@end
+
+@interface B : A {
+ NSString* _schemeName;
+}
+@end
+
+
+@implementation B
+-(void) test {
+ B *b;
+ b.scheme = _schemeName; // error because of this line
+}
+@end
+
diff --git a/clang/test/Rewriter/protocol-rewrite-1.m b/clang/test/Rewriter/protocol-rewrite-1.m
new file mode 100644
index 0000000..687a259
--- /dev/null
+++ b/clang/test/Rewriter/protocol-rewrite-1.m
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+typedef struct MyWidget {
+ int a;
+} MyWidget;
+
+MyWidget gWidget = { 17 };
+
+@protocol MyProto
+- (MyWidget *)widget;
+@end
+
+@interface Foo
+@end
+
+@interface Bar: Foo <MyProto>
+@end
+
+@interface Container
++ (MyWidget *)elementForView:(Foo *)view;
+@end
+
+@implementation Foo
+@end
+
+@implementation Bar
+- (MyWidget *)widget {
+ return &gWidget;
+}
+@end
+
+@implementation Container
++ (MyWidget *)elementForView:(Foo *)view
+{
+ MyWidget *widget = (void*)0;
+ if (@protocol(MyProto)) {
+ widget = [(id <MyProto>)view widget];
+ }
+ return widget;
+}
+@end
+
+int main(void) {
+ id view;
+ MyWidget *w = [Container elementForView: view];
+
+ return 0;
+}
diff --git a/clang/test/Rewriter/protocol-rewrite-2.m b/clang/test/Rewriter/protocol-rewrite-2.m
new file mode 100644
index 0000000..e0ec4f9
--- /dev/null
+++ b/clang/test/Rewriter/protocol-rewrite-2.m
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o %t.cpp
+// RUN: %clang_cc1 -fsyntax-only %t.cpp
+
+// rdar://10234024
+@protocol Foo;
+@protocol Foo
+@end
diff --git a/clang/test/Rewriter/rewrite-anonymous-union.m b/clang/test/Rewriter/rewrite-anonymous-union.m
new file mode 100644
index 0000000..339524f
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-anonymous-union.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi -o - %s
+// rdar://6948022
+
+typedef unsigned int uint32_t;
+
+typedef struct {
+ union {
+ uint32_t daysOfWeek;
+ uint32_t dayOfMonth;
+ };
+ uint32_t nthOccurrence;
+} OSPatternSpecificData;
+
+@interface NSNumber
++ (NSNumber *)numberWithLong:(long)value;
+@end
+
+@interface OSRecurrence {
+ OSPatternSpecificData _pts;
+}
+- (void)_setTypeSpecificInfoOnRecord;
+@end
+
+@implementation OSRecurrence
+- (void)_setTypeSpecificInfoOnRecord
+{
+ [NSNumber numberWithLong:(_pts.dayOfMonth >= 31 ? -1 : _pts.dayOfMonth)];
+}
+@end
+
diff --git a/clang/test/Rewriter/rewrite-api-bug.m b/clang/test/Rewriter/rewrite-api-bug.m
new file mode 100644
index 0000000..ebaa0be
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-api-bug.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@interface MyDerived
+- (void) instanceMethod;
+@end
+
+@implementation MyDerived
+- (void) instanceMethod {
+}
+@end
+
diff --git a/clang/test/Rewriter/rewrite-block-argument.m b/clang/test/Rewriter/rewrite-block-argument.m
new file mode 100644
index 0000000..898f983
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-block-argument.m
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" -emit-llvm -o %t %t-rw.cpp
+// radar 7987817
+
+void *sel_registerName(const char *);
+
+@interface Test {
+}
+@end
+
+@implementation Test
+
+- (void)enumerateProvidersWithBlock:(void (^)(void))block {
+ block();
+}
+
+- (void)providerEnumerator {
+ ^(void (^providerBlock)(void)) {
+ [self enumerateProvidersWithBlock:providerBlock];
+ };
+}
+
+- (void)testNilBlock {
+ [self enumerateProvidersWithBlock:0];
+}
+
+@end
+
+
+
+int main(int argc, char *argv[]) {
+ return 0;
+}
diff --git a/clang/test/Rewriter/rewrite-block-consts.mm b/clang/test/Rewriter/rewrite-block-consts.mm
new file mode 100644
index 0000000..1d6de8c
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-block-consts.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D__block="" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar:// 8243071
+
+void x(int y) {}
+void f() {
+ const int bar = 3;
+ int baz = 4;
+ __block int bab = 4;
+ __block const int bas = 5;
+ void (^b)() = ^{
+ x(bar);
+ x(baz);
+ x(bab);
+ x(bas);
+ b();
+ };
+ b();
+}
diff --git a/clang/test/Rewriter/rewrite-block-ivar-call.mm b/clang/test/Rewriter/rewrite-block-ivar-call.mm
new file mode 100644
index 0000000..2ec27b3
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-block-ivar-call.mm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -rewrite-objc -fobjc-fragile-abi -o - %s
+
+@interface Foo {
+ void (^_block)(void);
+}
+@end
+
+@implementation Foo
+- (void)bar {
+ _block();
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-block-literal-1.mm b/clang/test/Rewriter/rewrite-block-literal-1.mm
new file mode 100644
index 0000000..f152117
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-block-literal-1.mm
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// radar 9254348
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// rdar://11259664
+
+void *sel_registerName(const char *);
+typedef void (^BLOCK_TYPE)(void);
+
+@interface CoreDAVTaskGroup
+{
+ int IVAR;
+}
+@property int IVAR;
+- (void) setCompletionBlock : (BLOCK_TYPE) arg;
+@end
+
+@implementation CoreDAVTaskGroup
+- (void)_finishInitialSync {
+ CoreDAVTaskGroup *folderPost;
+ folderPost.completionBlock = ^{
+ self.IVAR = 0;
+ [self _finishInitialSync];
+ };
+
+ [folderPost setCompletionBlock : (^{
+ self.IVAR = 0;
+ })];
+}
+@dynamic IVAR;
+- (void) setCompletionBlock : (BLOCK_TYPE) arg {}
+@end
+
+
diff --git a/clang/test/Rewriter/rewrite-block-literal.mm b/clang/test/Rewriter/rewrite-block-literal.mm
new file mode 100644
index 0000000..083312e
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-block-literal.mm
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+
+// rdar: // 11006566
+
+void I( void (^)(void));
+void (^noop)(void);
+
+void nothing();
+int printf(const char*, ...);
+
+typedef void (^T) (void);
+
+void takeblock(T);
+int takeintint(int (^C)(int)) { return C(4); }
+
+T somefunction() {
+ if (^{ })
+ nothing();
+
+ noop = ^{};
+
+ noop = ^{printf("\nClosure\n"); };
+
+ I(^{ });
+
+ return ^{printf("\nClosure\n"); };
+}
+void test2() {
+ int x = 4;
+
+ takeblock(^{ printf("%d\n", x); });
+
+ while (1) {
+ takeblock(^{
+ while(1) break; // ok
+ });
+ break;
+ }
+}
+
+void test4() {
+ void (^noop)(void) = ^{};
+ void (*noop2)() = 0;
+}
+
+void myfunc(int (^block)(int)) {}
+
+void myfunc3(const int *x);
+
+void test5() {
+ int a;
+
+ myfunc(^(int abcd) {
+ myfunc3(&a);
+ return 1;
+ });
+}
+
+void *X;
+
+static int global_x = 10;
+void (^global_block)(void) = ^{ printf("global x is %d\n", global_x); };
+
+// CHECK: static __global_block_block_impl_0 __global_global_block_block_impl_0((void *)__global_block_block_func_0, &__global_block_block_desc_0_DATA);
+// CHECK: void (*global_block)(void) = (void (*)())&__global_global_block_block_impl_0;
+
+typedef void (^void_block_t)(void);
+
+static const void_block_t myBlock = ^{ };
+
+static const void_block_t myBlock2 = ^ void(void) { };
diff --git a/clang/test/Rewriter/rewrite-block-pointer.mm b/clang/test/Rewriter/rewrite-block-pointer.mm
new file mode 100644
index 0000000..58407a7
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-block-pointer.mm
@@ -0,0 +1,109 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// radar 7638400
+
+typedef void * id;
+void *sel_registerName(const char *);
+
+@interface X
+@end
+
+void foo(void (^block)(int));
+
+@implementation X
+static void enumerateIt(void (^block)(id, id, char *)) {
+ foo(^(int idx) { });
+}
+@end
+
+// radar 7651312
+void apply(void (^block)(int));
+
+static void x(int (^cmp)(int, int)) {
+ x(cmp);
+}
+
+static void y(int (^cmp)(int, int)) {
+ apply(^(int sect) {
+ x(cmp);
+ });
+}
+
+// radar 7659483
+void *_Block_copy(const void *aBlock);
+void x(void (^block)(void)) {
+ block = ((__typeof(block))_Block_copy((const void *)(block)));
+}
+
+// radar 7682763
+@interface Y {
+@private
+ id _private;
+}
+- (void (^)(void))f;
+@end
+
+typedef void (^void_block_t)(void);
+
+@interface YY {
+ void_block_t __completion;
+}
+@property (copy) void_block_t f;
+@end
+
+@implementation Y
+- (void (^)(void))f {
+ return [_private f];
+}
+
+@end
+
+// rdar: //8608902
+@protocol CoreDAVAccountInfoProvider;
+@protocol CodeProvider;
+typedef void (^BDVDiscoveryCompletionHandler)(int success, id<CoreDAVAccountInfoProvider> discoveredInfo);
+typedef void (^BDVDiscoveryCompletion)(id<CodeProvider> codeInfo, int success, id<CoreDAVAccountInfoProvider> discoveredInfo);
+typedef void (^BDVDiscovery)(int success);
+typedef void (^BDVDisc)(id<CoreDAVAccountInfoProvider> discoveredInfo, id<CodeProvider> codeInfo,
+ int success, id<CoreDAVAccountInfoProvider, CodeProvider> Info);
+typedef void (^BLOCK)(id, id<CoreDAVAccountInfoProvider>, id<CodeProvider> codeInfo);
+typedef void (^EMPTY_BLOCK)();
+typedef void (^ BDVDiscoveryCompletion1 )(id<CodeProvider> codeInfo, int success, id<CoreDAVAccountInfoProvider> discoveredInfo);
+
+void (^BL)(void(^arg1)(), int i1, void(^arg)(int));
+
+typedef void (^iscoveryCompletionHandler)(void(^arg1)(), id<CoreDAVAccountInfoProvider> discoveredInfo);
+
+typedef void (^DVDisc)(id<CoreDAVAccountInfoProvider> discoveredInfo, id<CodeProvider> codeInfo,
+ void(^arg1)(), int i1, void(^arg)(id<CoreDAVAccountInfoProvider>),
+ int success, id<CoreDAVAccountInfoProvider, CodeProvider> Info);
+
+
+@interface I @end
+@interface INTF @end
+void (^BLINT)(I<CoreDAVAccountInfoProvider>* ARG, INTF<CodeProvider, CoreDAVAccountInfoProvider>* ARG1);
+
+void test8608902() {
+ BDVDiscoveryCompletionHandler ppp;
+ ppp(1, 0);
+}
+
+void test9204669() {
+ __attribute__((__blocks__(byref))) char (^addChangeToData)();
+
+ addChangeToData = ^() {
+ return 'b';
+ };
+ addChangeToData();
+}
+
+void test9204669_1() {
+ __attribute__((__blocks__(byref))) void (^addChangeToData)();
+
+ addChangeToData = ^() {
+ addChangeToData();
+ };
+}
+
diff --git a/clang/test/Rewriter/rewrite-block-property.m b/clang/test/Rewriter/rewrite-block-property.m
new file mode 100644
index 0000000..5c44b7d
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-block-property.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+// rdar://9055596
+void *sel_registerName(const char *);
+
+typedef void (^FooBlock) (int foo, int bar, int baz);
+
+@interface Foo { }
+@property (readwrite, copy, nonatomic) FooBlock fooBlock;
+@end
+
+static void Bar (Foo * foo) {
+ foo.fooBlock (1,2,3);
+}
diff --git a/clang/test/Rewriter/rewrite-byref-in-nested-blocks.mm b/clang/test/Rewriter/rewrite-byref-in-nested-blocks.mm
new file mode 100644
index 0000000..a659383
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-byref-in-nested-blocks.mm
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// radar 7692350
+
+void f(void (^block)(void));
+
+@interface X {
+ int y;
+}
+- (void)foo;
+@end
+
+@implementation X
+- (void)foo {
+ __block int kerfluffle;
+ // radar 7692183
+ __block x;
+ f(^{
+ f(^{
+ y = 42;
+ kerfluffle = 1;
+ x = 2;
+ });
+ });
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-byref-vars.mm b/clang/test/Rewriter/rewrite-byref-vars.mm
new file mode 100644
index 0000000..14a182a
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-byref-vars.mm
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// radar 7540194
+
+extern "C" __declspec(dllexport) void BreakTheRewriter(int i) {
+ __block int aBlockVariable = 0;
+ void (^aBlock)(void) = ^ {
+ aBlockVariable = 42;
+ };
+ aBlockVariable++;
+ if (i) {
+ __block int bbBlockVariable = 0;
+ void (^aBlock)(void) = ^ {
+ bbBlockVariable = 42;
+ };
+ }
+}
+
+__declspec(dllexport) extern "C" __declspec(dllexport) void XXXXBreakTheRewriter(void) {
+
+ __block int aBlockVariable = 0;
+ void (^aBlock)(void) = ^ {
+ aBlockVariable = 42;
+ };
+ aBlockVariable++;
+ void (^bBlocks)(void) = ^ {
+ aBlockVariable = 43;
+ };
+ void (^c)(void) = ^ {
+ aBlockVariable = 44;
+ };
+
+}
+
+@interface I
+{
+ id list;
+}
+- (void) Meth;
+// radar 7589385 use before definition
+- (void) allObjects;
+@end
+
+@implementation I
+// radar 7589385 use before definition
+- (void) allObjects {
+ __attribute__((__blocks__(byref))) id *listp;
+
+ ^(void) {
+ *listp++ = 0;
+ };
+}
+- (void) Meth { __attribute__((__blocks__(byref))) void ** listp = (void **)list; }
+@end
+
+// $CLANG -cc1 -fms-extensions -rewrite-objc -fobjc-fragile-abi -x objective-c++ -fblocks bug.mm
+// g++ -c -D"__declspec(X)=" bug.cpp
diff --git a/clang/test/Rewriter/rewrite-captured-nested-bvar.c b/clang/test/Rewriter/rewrite-captured-nested-bvar.c
new file mode 100644
index 0000000..a48de4b
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-captured-nested-bvar.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -x c -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: FileCheck --input-file=%t-rw.cpp %s
+// rdar://9006279
+
+void q(void (^p)(void)) {
+ p();
+}
+
+void f() {
+ __block char BYREF_VAR_CHECK = 'a';
+ __block char d = 'd';
+ q(^{
+ q(^{
+ __block char e = 'e';
+ char l = 'l';
+ BYREF_VAR_CHECK = 'b';
+ d = 'd';
+ q(^{
+ e = '1';
+ BYREF_VAR_CHECK = '2';
+ d = '3';
+ }
+ );
+ });
+ });
+}
+
+int main() {
+ f();
+ return 0;
+}
+
+// CHECK 2: (__Block_byref_BYREF_VAR_CHECK_0 *)BYREF_VAR_CHECK
+// CHECK: (__Block_byref_BYREF_VAR_CHECK_0 *)&BYREF_VAR_CHECK
+// CHECK: (struct __Block_byref_BYREF_VAR_CHECK_0 *)&BYREF_VAR_CHECK, (struct __Block_byref_d_1 *)&d, 570425344));
diff --git a/clang/test/Rewriter/rewrite-cast-ivar-access.mm b/clang/test/Rewriter/rewrite-cast-ivar-access.mm
new file mode 100644
index 0000000..ccc1cde
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-cast-ivar-access.mm
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
+// radar 7575882
+
+@interface F {
+ int supervar;
+}
+@end
+
+@interface G : F {
+@public
+ int ivar;
+}
+@end
+
+@implementation G
+- (void)foo:(F *)arg {
+ int q = arg->supervar;
+ int v = ((G *)arg)->ivar;
+}
+@end
+
+void objc_assign_strongCast(id);
+void __CFAssignWithWriteBarrier(void **location, void *value) {
+ objc_assign_strongCast((id)value);
+}
+
+// radar 7607605
+@interface RealClass {
+ @public
+ int f;
+}
+@end
+
+@implementation RealClass
+@end
+
+@interface Foo {
+ id reserved;
+}
+@end
+
+@implementation Foo
+- (void)bar {
+ ((RealClass*)reserved)->f = 99;
+}
+@end
+
+// CHECK-LP: ((struct G_IMPL *)arg)->ivar
+
+// CHECK-LP: objc_assign_strongCast((id)value)
+
+// CHECK-LP: ((struct RealClass_IMPL *)((RealClass *)((struct Foo_IMPL *)self)->reserved))->f
diff --git a/clang/test/Rewriter/rewrite-cast-ivar-modern-access.mm b/clang/test/Rewriter/rewrite-cast-ivar-modern-access.mm
new file mode 100644
index 0000000..4a6cb32
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-cast-ivar-modern-access.mm
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@interface F {
+ int supervar;
+}
+@end
+
+@interface G : F {
+@public
+ int ivar;
+}
+@end
+
+@implementation G
+- (void)foo:(F *)arg {
+ int q = arg->supervar;
+ int v = ((G *)arg)->ivar;
+}
+@end
+
+void objc_assign_strongCast(id);
+void __CFAssignWithWriteBarrier(void **location, void *value) {
+ objc_assign_strongCast((id)value);
+}
+
+// radar 7607605
+@interface RealClass {
+ @public
+ int f;
+}
+@end
+
+@implementation RealClass
+@end
+
+@interface Foo {
+ id reserved;
+}
+@end
+
+@implementation Foo
+- (void)bar {
+ ((RealClass*)reserved)->f = 99;
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-cast-to-bool.mm b/clang/test/Rewriter/rewrite-cast-to-bool.mm
new file mode 100644
index 0000000..b3272b6
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-cast-to-bool.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// radar 9899834
+
+void *sel_registerName(const char *);
+
+@interface NSURLDownload
+-(void)setBool:(bool)Arg;
+@end
+
+@implementation NSURLDownload
+- (void) Meth
+{
+ [self setBool:(signed char)1];
+}
+@end
+
diff --git a/clang/test/Rewriter/rewrite-category-property.mm b/clang/test/Rewriter/rewrite-category-property.mm
new file mode 100644
index 0000000..b54bb67
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-category-property.mm
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -x objective-c++ -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
+// radar 7630636
+
+@class Y, Z;
+
+@interface A
+@property (readonly) Y *y;
+@end
+
+@interface A (cat)
+@property (readonly) Z *z;
+@end
+
+// CHECK-LP: // @property (readonly) Z *z;
diff --git a/clang/test/Rewriter/rewrite-constructor-init.mm b/clang/test/Rewriter/rewrite-constructor-init.mm
new file mode 100644
index 0000000..f12de1f
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-constructor-init.mm
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar : // 8213998
+
+typedef unsigned int NSUInteger;
+
+typedef struct _NSRange {
+ NSUInteger location;
+ NSUInteger length;
+} NSRange;
+
+static __inline NSRange NSMakeRange(NSUInteger loc, NSUInteger len) {
+ NSRange r;
+ r.location = loc;
+ r.length = len;
+ return r;
+}
+
+void bar() {
+ __block NSRange previousRange = NSMakeRange(0, 0);
+ void (^blk)() = ^{
+ previousRange = NSMakeRange(1, 0);
+ };
+}
diff --git a/clang/test/Rewriter/rewrite-eh.m b/clang/test/Rewriter/rewrite-eh.m
new file mode 100644
index 0000000..46d1930
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-eh.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi -fobjc-exceptions -o - %s
+// rdar://7522880
+
+@interface NSException
+@end
+
+@interface Foo
+@end
+
+@implementation Foo
+- (void)bar {
+ @try {
+ } @catch (NSException *e) {
+ }
+ @catch (Foo *f) {
+ }
+ @catch (...) {
+ }
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-elaborated-type.mm b/clang/test/Rewriter/rewrite-elaborated-type.mm
new file mode 100644
index 0000000..a0c7e43
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-elaborated-type.mm
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D_Bool=bool -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D_Bool=bool -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// radar 8143056
+
+typedef struct objc_class *Class;
+typedef unsigned NSPointerFunctionsOptions;
+extern "C" id NSClassFromObject(id object);
+void *sel_registerName(const char *);
+
+struct NSSlice {
+ int i1;
+};
+
+@interface NSConcretePointerFunctions {
+ @public
+ struct NSSlice slice;
+}
+- (bool)initializeSlice:(struct NSSlice *)slicep withOptions:(NSPointerFunctionsOptions)options;
+@end
+
+@implementation NSConcretePointerFunctions
+- (id)initWithOptions:(NSPointerFunctionsOptions)options {
+ if (![NSClassFromObject(self) initializeSlice:&slice withOptions:options])
+ return 0;
+ return self;
+ }
+- (bool)initializeSlice:(struct NSSlice *)slicep withOptions:(NSPointerFunctionsOptions)options {
+ return 0;
+ }
+@end
+
+@interface I1 @end
+
+@implementation I1
++ (struct s1 *) f0 {
+ return 0;
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-extern-c.mm b/clang/test/Rewriter/rewrite-extern-c.mm
new file mode 100644
index 0000000..c610493
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-extern-c.mm
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -rewrite-objc -fobjc-fragile-abi -o - %s
+// radar 7546096
+
+extern "C" {
+ short foo() { }
+}
+typedef unsigned char Boolean;
+
diff --git a/clang/test/Rewriter/rewrite-foreach-1.m b/clang/test/Rewriter/rewrite-foreach-1.m
new file mode 100644
index 0000000..f57e13c
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-foreach-1.m
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@protocol P @end
+
+@interface MyList
+@end
+
+@implementation MyList
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount
+{
+ return 0;
+}
+@end
+
+@interface MyList (BasicTest)
+- (void)compilerTestAgainst;
+@end
+
+int LOOP();
+@implementation MyList (BasicTest)
+- (void)compilerTestAgainst {
+ id el;
+ for (el in self)
+ { LOOP(); }
+ for (id el1 in self)
+ LOOP();
+
+ for (el in (self))
+ if (el)
+ LOOP();
+
+ for (el in ((self)))
+ if (el)
+ LOOP();
+}
+@end
+
diff --git a/clang/test/Rewriter/rewrite-foreach-2.m b/clang/test/Rewriter/rewrite-foreach-2.m
new file mode 100644
index 0000000..228612a
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-foreach-2.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@protocol P @end
+
+@interface MyList
+@end
+
+@implementation MyList
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount
+{
+ return 0;
+}
+@end
+
+@interface MyList (BasicTest)
+- (void)compilerTestAgainst;
+@end
+
+int LOOP();
+int INNERLOOP();
+void END_LOOP();
+@implementation MyList (BasicTest)
+- (void)compilerTestAgainst {
+ id el;
+ for (el in self)
+ { LOOP();
+ for (id el1 in self)
+ INNER_LOOP();
+
+ END_LOOP();
+ }
+}
+@end
+
diff --git a/clang/test/Rewriter/rewrite-foreach-3.m b/clang/test/Rewriter/rewrite-foreach-3.m
new file mode 100644
index 0000000..ef3803f
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-foreach-3.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@protocol P @end
+
+@interface MyList
+@end
+
+@implementation MyList
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount
+{
+ return 0;
+}
+@end
+
+@interface MyList (BasicTest)
+- (void)compilerTestAgainst;
+@end
+
+int LOOP();
+@implementation MyList (BasicTest)
+- (void)compilerTestAgainst {
+ MyList * el;
+ for (el in self)
+ { LOOP(); }
+ for (MyList * el1 in self)
+ LOOP();
+}
+@end
+
diff --git a/clang/test/Rewriter/rewrite-foreach-4.m b/clang/test/Rewriter/rewrite-foreach-4.m
new file mode 100644
index 0000000..42cb2fb
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-foreach-4.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@interface MyList
+- (id) allKeys;
+@end
+
+@implementation MyList
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount
+{
+ return 0;
+}
+- (id) allKeys { return 0; }
+@end
+
+@interface MyList (BasicTest)
+- (void)compilerTestAgainst;
+@end
+
+int LOOP();
+@implementation MyList (BasicTest)
+- (void)compilerTestAgainst {
+ MyList * el;
+ for (el in [el allKeys]) { LOOP();
+ }
+
+ for (id el1 in[el allKeys]) { LOOP();
+ }
+ for (el in([el allKeys])) { LOOP();
+ }
+}
+@end
+
diff --git a/clang/test/Rewriter/rewrite-foreach-5.m b/clang/test/Rewriter/rewrite-foreach-5.m
new file mode 100644
index 0000000..2940f45
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-foreach-5.m
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+void *sel_registerName(const char *);
+void objc_enumerationMutation(id);
+
+@interface MyList
+- (id) allKeys;
+@end
+
+@implementation MyList
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount
+{
+ return 0;
+}
+- (id) allKeys { return 0; }
+@end
+
+@interface MyList (BasicTest)
+- (void)compilerTestAgainst;
+@end
+
+int LOOP();
+@implementation MyList (BasicTest)
+- (void)compilerTestAgainst {
+ MyList * el;
+ int i;
+ for (el in [el allKeys]) {
+ for (i = 0; i < 10; i++)
+ if (i == 5)
+ break;
+
+ if (el == 0)
+ break;
+ if (el != self)
+ continue;
+ LOOP();
+ }
+
+ for (id el1 in[el allKeys]) {
+ LOOP();
+ for (el in self) {
+ if (el)
+ continue;
+ }
+ if (el1)
+ break;
+ }
+}
+@end
+
diff --git a/clang/test/Rewriter/rewrite-foreach-6.m b/clang/test/Rewriter/rewrite-foreach-6.m
new file mode 100644
index 0000000..968c6f4
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-foreach-6.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://5716356
+// FIXME: Should be able to pipe into clang, but code is not
+// yet correct for other reasons: rdar://5716940
+
+void *sel_registerName(const char *);
+void objc_enumerationMutation(id);
+
+@class NSNotification;
+@class NSMutableArray;
+
+void foo(NSMutableArray *notificationArray, id X) {
+ for (NSNotification *notification in notificationArray)
+ [X postNotification:notification];
+}
+
diff --git a/clang/test/Rewriter/rewrite-foreach-7.m b/clang/test/Rewriter/rewrite-foreach-7.m
new file mode 100644
index 0000000..8c9293f
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-foreach-7.m
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@class NSArray;
+int main() {
+ NSArray *foo;
+ for (Class c in foo) { }
+}
diff --git a/clang/test/Rewriter/rewrite-foreach-in-block.mm b/clang/test/Rewriter/rewrite-foreach-in-block.mm
new file mode 100644
index 0000000..fd34212
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-foreach-in-block.mm
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// rdar:// 9878420
+
+void objc_enumerationMutation(id);
+void *sel_registerName(const char *);
+typedef void (^CoreDAVCompletionBlock)(void);
+
+@interface I
+- (void)M;
+- (id) ARR;
+@property (readwrite, copy, nonatomic) CoreDAVCompletionBlock c;
+@end
+
+@implementation I
+- (void)M {
+ I* ace;
+ self.c = ^() {
+ // sanity test for the changes.
+ [ace ARR];
+ for (I *privilege in [ace ARR]) { }
+ };
+ self.c = ^() {
+ // sanity test for the changes.
+ [ace ARR];
+ };
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-foreach-protocol-id.m b/clang/test/Rewriter/rewrite-foreach-protocol-id.m
new file mode 100644
index 0000000..034fb7a
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-foreach-protocol-id.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar:// 9039342
+
+void *sel_registerName(const char *);
+void objc_enumerationMutation(id);
+
+@protocol CoreDAVLeafDataPayload @end
+
+@class NSString;
+
+@interface CoreDAVAction
+- (id) context;
+@end
+
+@interface I
+{
+ id uuidsToAddActions;
+}
+@end
+
+@implementation I
+- (void) Meth {
+ for (id<CoreDAVLeafDataPayload> uuid in uuidsToAddActions) {
+ CoreDAVAction *action = 0;
+ id <CoreDAVLeafDataPayload> payload = [action context];
+ }
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-forward-class.m b/clang/test/Rewriter/rewrite-forward-class.m
new file mode 100644
index 0000000..0ac620a
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-forward-class.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://6969189
+
+@class XX;
+@class YY, ZZ, QQ;
+@class ISyncClient, SMSession, ISyncManager, ISyncSession, SMDataclassInfo, SMClientInfo,
+ DMCConfiguration, DMCStatusEntry;
+
+@interface QQ
+
+@end
+
+@interface SMDataclassInfo : QQ
+- (XX*) Meth;
+- (DMCStatusEntry*)Meth2;
+@end
+
+@implementation SMDataclassInfo
+- (XX*) Meth { return 0; }
+- (DMCStatusEntry*)Meth2 { return 0; }
+@end
+
+@interface YY
+{
+ ISyncClient *p1;
+ ISyncSession *p2;
+}
+@property (copy) ISyncClient *p1;
+@end
+
+@implementation YY
+@synthesize p1;
+@end
+
diff --git a/clang/test/Rewriter/rewrite-forward-class.mm b/clang/test/Rewriter/rewrite-forward-class.mm
new file mode 100644
index 0000000..8e4eda6
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-forward-class.mm
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+extern "C" {
+@class XX;
+@class YY, ZZ, QQ;
+@class ISyncClient, SMSession, ISyncManager, ISyncSession, SMDataclassInfo, SMClientInfo,
+ DMCConfiguration, DMCStatusEntry;
+
+@interface QQ
+
+@end
+
+@interface SMDataclassInfo : QQ
+- (XX*) Meth;
+- (DMCStatusEntry*)Meth2;
+@end
+
+@implementation SMDataclassInfo
+- (XX*) Meth { return 0; }
+- (DMCStatusEntry*)Meth2 { return 0; }
+@end
+
+@interface YY
+{
+ ISyncClient *p1;
+ ISyncSession *p2;
+}
+@property (copy) ISyncClient *p1;
+@end
+
+@implementation YY
+@synthesize p1;
+@end
+
+extern "C" {
+@class CCC;
+@class Protocol, P , Q;
+int I,J,K;
+};
+
+};
+
+
diff --git a/clang/test/Rewriter/rewrite-function-decl.mm b/clang/test/Rewriter/rewrite-function-decl.mm
new file mode 100644
index 0000000..883d393
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-function-decl.mm
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fms-extensions -rewrite-objc -fobjc-fragile-abi -x objective-c++ -fblocks -o - %s
+
+extern "C" __declspec(dllexport) void BreakTheRewriter(void) {
+ __block int aBlockVariable = 0;
+ void (^aBlock)(void) = ^ {
+ aBlockVariable = 42;
+ };
+ aBlockVariable++;
+ void (^bBlocks)(void) = ^ {
+ aBlockVariable = 43;
+ };
+ void (^c)(void) = ^ {
+ aBlockVariable = 44;
+ };
+
+}
+__declspec(dllexport) extern "C" void AnotherBreakTheRewriter(int *p1, double d) {
+
+ __block int bBlockVariable = 0;
+ void (^aBlock)(void) = ^ {
+ bBlockVariable = 42;
+ };
+ bBlockVariable++;
+ void (^bBlocks)(void) = ^ {
+ bBlockVariable = 43;
+ };
+ void (^c)(void) = ^ {
+ bBlockVariable = 44;
+ };
+
+}
diff --git a/clang/test/Rewriter/rewrite-implementation.mm b/clang/test/Rewriter/rewrite-implementation.mm
new file mode 100644
index 0000000..2cc3387
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-implementation.mm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// radar 7649577
+
+@interface a
+@end
+
+@interface b : a
+@end
+
+@implementation b
+@end
+
+@interface NSArray @end
+@class NSArray;
+@implementation NSArray @end
diff --git a/clang/test/Rewriter/rewrite-ivar-use.m b/clang/test/Rewriter/rewrite-ivar-use.m
new file mode 100644
index 0000000..53b07c4
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-ivar-use.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// radar 7490331
+
+void *sel_registerName(const char *);
+
+@interface Foo {
+ int a;
+ id b;
+}
+- (void)bar;
+- (void)baz:(id)q;
+@end
+
+@implementation Foo
+// radar 7522803
+static void foo(id bar) {
+ int i = ((Foo *)bar)->a;
+}
+
+- (void)bar {
+ a = 42;
+ [self baz:b];
+}
+- (void)baz:(id)q {
+}
+@end
+
diff --git a/clang/test/Rewriter/rewrite-local-externs-in-block.mm b/clang/test/Rewriter/rewrite-local-externs-in-block.mm
new file mode 100644
index 0000000..35d282b
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-local-externs-in-block.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// radar 7735987
+
+extern "C" int printf(const char*, ...);
+
+void bar(void (^block)()) {
+ block();
+}
+
+int main() {
+ static int myArr[3] = {1, 2, 3};
+ printf ("%d %d %d\n", myArr[0], myArr[1], myArr[2]);
+
+ bar(^{
+ printf ("%d %d %d\n", myArr[0], myArr[1], myArr[2]);
+ myArr[0] = 42;
+ myArr[2] = 100;
+ printf ("%d %d %d\n", myArr[0], myArr[1], myArr[2]);
+ });
+
+ printf ("%d %d %d\n", myArr[0], myArr[1], myArr[2]);
+}
diff --git a/clang/test/Rewriter/rewrite-local-static-id.mm b/clang/test/Rewriter/rewrite-local-static-id.mm
new file mode 100644
index 0000000..b002b6e
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-local-static-id.mm
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" -emit-llvm -o %t %t-rw.cpp
+// radar 7946975
+
+void *sel_registerName(const char *);
+
+@interface foo
+@end
+
+@interface foo2 : foo
++ (id)x;
+@end
+
+typedef void (^b_t)(void);
+
+void bar(b_t block);
+
+void f() {
+ static id foo = 0;
+ bar(^{
+ foo = [foo2 x];
+ });
+}
+
diff --git a/clang/test/Rewriter/rewrite-message-expr.mm b/clang/test/Rewriter/rewrite-message-expr.mm
new file mode 100644
index 0000000..dafb31b
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-message-expr.mm
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
+// radar 7617047
+
+@interface Baz
+- (id)y;
++ (id)z;
+@end
+
+@interface Foo {
+@public
+ int bar;
+}
+@end
+
+extern Foo* x(id a);
+
+int f(Baz *baz) {
+ int i = x([Baz z])->bar;
+ int j = ((Foo*)[Baz z])->bar;
+ int k = x([baz y])->bar;
+ return i+j+k;
+}
+
+// CHECK-LP: ((struct Foo_IMPL *)x(((id (*)(id, SEL))(void *)objc_msgSend)(objc_getClass("Baz"), sel_registerName("z"))))->bar
diff --git a/clang/test/Rewriter/rewrite-modern-array-literal.mm b/clang/test/Rewriter/rewrite-modern-array-literal.mm
new file mode 100644
index 0000000..208e646
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-array-literal.mm
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -x objective-c++ -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://10803676
+
+extern "C" void *sel_registerName(const char *);
+@class NSString;
+
+@interface NSNumber
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+typedef unsigned long NSUInteger;
+
+@interface NSArray
++ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
+@end
+
+int i;
+int main() {
+ NSArray *array = @[ @"Hello", @1234 ];
+ if (i) {
+ NSArray *array = @[ @"Hello", @1234 ];
+ }
+ NSArray *array1 = @[ @"Hello", @1234, @[ @"Hello", @1234 ] ];
+}
+
diff --git a/clang/test/Rewriter/rewrite-modern-block-ivar-call.mm b/clang/test/Rewriter/rewrite-modern-block-ivar-call.mm
new file mode 100644
index 0000000..1bafbdd
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-block-ivar-call.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -E %s -o %t.m
+// RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %t.m -o %t-rw.cpp
+// RUN: FileCheck --input-file=%t-rw.cpp %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@interface Foo {
+ void (^_block)(void);
+}
+@end
+
+@implementation Foo
+- (void)bar {
+ _block();
+}
+@end
+
+// CHECK: ((void (*)(struct __block_impl *))((struct __block_impl *)(*(void (**)(void))((char *)self + OBJC_IVAR_$_Foo$_block)))->FuncPtr)((struct __block_impl *)(*(void (**)(void))((char *)self + OBJC_IVAR_$_Foo$_block)));
diff --git a/clang/test/Rewriter/rewrite-modern-block.mm b/clang/test/Rewriter/rewrite-modern-block.mm
new file mode 100644
index 0000000..8da723d
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-block.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://11230308
+
+typedef struct {
+ char byte0;
+ char byte1;
+} CFUUIDBytes;
+
+void x(void *);
+
+void y() {
+ __block CFUUIDBytes bytes;
+
+ void (^bar)() = ^{
+ x(&bytes);
+ };
+}
+
+// rdar://11236342
+int foo() {
+ __block int hello;
+}
diff --git a/clang/test/Rewriter/rewrite-modern-catch.m b/clang/test/Rewriter/rewrite-modern-catch.m
new file mode 100644
index 0000000..1900301
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-catch.m
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+void foo(id arg);
+
+@interface NSException
+@end
+
+@interface Foo
+@end
+
+@implementation Foo
+- (void)bar {
+ @try {
+ } @catch (NSException *e) {
+ foo(e);
+ }
+ @catch (Foo *f) {
+ }
+ @catch (...) {
+ @try {
+ }
+ @catch (Foo *f1) {
+ foo(f1);
+ }
+ @catch (id pid) {
+ foo(pid);
+ }
+ }
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-modern-class.mm b/clang/test/Rewriter/rewrite-modern-class.mm
new file mode 100644
index 0000000..b6be98a
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-class.mm
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@protocol PROTO @end
+
+@interface empty_root @end
+
+@interface root_with_ivars
+{
+ id ROOT_IVAR;
+ id ROOT1_IVAR;
+}
+@end
+
+@interface MAXIMAL : root_with_ivars<PROTO>
+{
+ double D_IVAR;
+ double D_PROPERTY;
+}
+- (void) V_METH;
+@end
+
+@implementation MAXIMAL
+- (void) V_METH {}
+@end
+//=========================================
+@interface empty_class @end
+
+@implementation empty_class @end
+//=========================================
+@interface class_empty_root : empty_root @end
+
+@implementation class_empty_root @end
+//=========================================
+@interface class_with_ivars : empty_root
+{
+ int class_with_ivars_IVAR;
+}
+@end
+
+@implementation class_with_ivars @end
+//=========================================
+@interface class_has_no_ivar : root_with_ivars @end
+
+@implementation class_has_no_ivar @end
+
+//============================class needs to be synthesized here=====================
+@interface SUPER {
+@public
+ double divar;
+ SUPER *p_super;
+}
+@end
+
+@interface INTF @end
+
+@implementation INTF
+- (SUPER *) Meth : (SUPER *)arg {
+ return arg->p_super;
+}
+@end
+
+@class FORM_CLASS;
+@interface INTF_DECL {
+}
+@end
+
+double Meth(INTF_DECL *p, FORM_CLASS *f) {
+ return 1.34;
+}
diff --git a/clang/test/Rewriter/rewrite-modern-container-literal.mm b/clang/test/Rewriter/rewrite-modern-container-literal.mm
new file mode 100644
index 0000000..2c2f61d
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-container-literal.mm
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -x objective-c++ -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://10803676
+
+void *sel_registerName(const char *);
+typedef unsigned long NSUInteger;
+typedef long NSInteger;
+typedef bool BOOL;
+
+@interface NSNumber
++ (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 ;
+@end
+
+@protocol NSCopying @end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
+@end
+
+@interface NSArray
++ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
+@end
+
+@interface NSString<NSCopying>
+@end
+
+id NSUserName();
+
+@interface NSDate
++ (id)date;
+@end
+
+int main() {
+NSArray *array = @[ @"Hello", NSUserName(), [NSDate date], [NSNumber numberWithInt:42]];
+
+NSDictionary *dictionary = @{ @"name" : NSUserName(), @"date" : [NSDate date], @"process" : @"processInfo"};
+
+NSDictionary *dict = @{ @"name":@666, @"man":@__objc_yes, @"date":@1.3 };
+
+}
+
diff --git a/clang/test/Rewriter/rewrite-modern-extern-c-func-decl.mm b/clang/test/Rewriter/rewrite-modern-extern-c-func-decl.mm
new file mode 100644
index 0000000..82d5a4d
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-extern-c-func-decl.mm
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -fms-extensions -U__declspec -rewrite-objc -x objective-c++ -fblocks -o %t-rw.cpp %s
+// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -Wno-attributes -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
+// rdar://11131490
+
+extern "C" __declspec(dllexport) void BreakTheRewriter(void) {
+ __block int aBlockVariable = 0;
+ void (^aBlock)(void) = ^ {
+ aBlockVariable = 42;
+ };
+ aBlockVariable++;
+ void (^bBlocks)(void) = ^ {
+ aBlockVariable = 43;
+ };
+ void (^c)(void) = ^ {
+ aBlockVariable = 44;
+ };
+
+}
+__declspec(dllexport) extern "C" void AnotherBreakTheRewriter(int *p1, double d) {
+
+ __block int bBlockVariable = 0;
+ void (^aBlock)(void) = ^ {
+ bBlockVariable = 42;
+ };
+ bBlockVariable++;
+ void (^bBlocks)(void) = ^ {
+ bBlockVariable = 43;
+ };
+ void (^c)(void) = ^ {
+ bBlockVariable = 44;
+ };
+
+}
+
+int
+
+__declspec (dllexport)
+
+main (int argc, char *argv[])
+{
+ __block int bBlockVariable = 0;
+ void (^aBlock)(void) = ^ {
+ bBlockVariable = 42;
+ };
+}
diff --git a/clang/test/Rewriter/rewrite-modern-ivar-use.mm b/clang/test/Rewriter/rewrite-modern-ivar-use.mm
new file mode 100644
index 0000000..ec8d2c7
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-ivar-use.mm
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw-modern.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw-modern.cpp
+
+void *sel_registerName(const char *);
+
+@interface Foo {
+ int a;
+ id b;
+}
+- (void)bar;
+- (void)baz:(id)q;
+@end
+
+@implementation Foo
+// radar 7522803
+static void foo(id bar) {
+ int i = ((Foo *)bar)->a;
+}
+
+- (void)bar {
+ a = 42;
+}
+- (void)baz:(id)q {
+}
+@end
+
diff --git a/clang/test/Rewriter/rewrite-modern-ivars-1.mm b/clang/test/Rewriter/rewrite-modern-ivars-1.mm
new file mode 100644
index 0000000..376d300
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-ivars-1.mm
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@interface NSCheapMutableString {
+@private
+ struct S s0;
+ union {
+ char *fat;
+ unsigned char *thin;
+ } contents;
+
+ struct {
+ unsigned int isFat:1;
+ unsigned int freeWhenDone:1;
+ unsigned int refs:30;
+ } flags;
+
+ struct S {
+ int iS1;
+ double dS1;
+ } others;
+
+ union U {
+ int iU1;
+ double dU1;
+ } u_others;
+
+ enum {
+ One, Two
+ } E1;
+
+ enum e {
+ Yes = 1,
+ No = 0
+ } BoOl;
+
+ struct S s1;
+
+ enum e E2;
+
+ union {
+ char *fat;
+ unsigned char *thin;
+ } Last_contents;
+
+ struct {
+ unsigned int isFat:1;
+ unsigned int freeWhenDone:1;
+ unsigned int refs:30;
+ } Last_flags;
+}
+@end
+
+@interface III {
+@private
+ struct S s0;
+
+ union {
+ char *fat;
+ unsigned char *thin;
+ } contents;
+
+ struct {
+ unsigned int isFat:1;
+ unsigned int freeWhenDone:1;
+ unsigned int refs:30;
+ } flags;
+
+ enum {
+ One1 = 1000, Two1, Three1
+ } E1;
+
+ struct S s1;
+
+ enum e E2;
+
+ union {
+ char *fat;
+ unsigned char *thin;
+ } Last_contents;
+
+ struct {
+ unsigned int isFat:1;
+ unsigned int freeWhenDone:1;
+ unsigned int refs:30;
+ } Last_flags;
+}
+@end
+
diff --git a/clang/test/Rewriter/rewrite-modern-ivars-2.mm b/clang/test/Rewriter/rewrite-modern-ivars-2.mm
new file mode 100644
index 0000000..0faed5c
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-ivars-2.mm
@@ -0,0 +1,101 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@interface B @end
+
+@interface A {
+ struct s0 {
+ int f0;
+ int f1;
+ } f0;
+ id f1;
+__weak B *f2;
+ int f3 : 5;
+ struct s1 {
+ int *f0;
+ int *f1;
+ } f4[2][1];
+}
+@end
+
+@interface C : A
+@property int p3;
+@end
+
+@implementation C
+@synthesize p3 = _p3;
+@end
+
+@interface A()
+@property int p0;
+@property (assign) __strong id p1;
+@property (assign) __weak id p2;
+@end
+
+// FIXME: Check layout for this class, once it is clear what the right
+// answer is.
+@implementation A
+@synthesize p0 = _p0;
+@synthesize p1 = _p1;
+@synthesize p2 = _p2;
+@end
+
+@interface D : A
+@property int p3;
+@end
+
+// FIXME: Check layout for this class, once it is clear what the right
+// answer is.
+@implementation D
+@synthesize p3 = _p3;
+@end
+
+typedef unsigned short UInt16;
+
+
+typedef signed char BOOL;
+typedef unsigned int FSCatalogInfoBitmap;
+
+@interface NSFileLocationComponent {
+ @private
+
+ id _specifierOrStandardizedPath;
+ BOOL _carbonCatalogInfoAndNameAreValid;
+ FSCatalogInfoBitmap _carbonCatalogInfoMask;
+ id _name;
+ id _containerComponent;
+ id _presentableName;
+ id _iconAsAttributedString;
+}
+@end
+
+@implementation NSFileLocationComponent @end
+
+// rdar://11229770
+
+@interface Foo {
+ int bar:26;
+}
+@end
+
+@implementation Foo
+@end
+
+@interface Foo1 {
+ int bar:26;
+ int bar2:4;
+}
+@end
+
+@implementation Foo1
+@end
+
+@interface Foo3 {
+ int foo;
+ int bar:26;
+}
+@end
+
+@implementation Foo3
+@end
+
diff --git a/clang/test/Rewriter/rewrite-modern-ivars.mm b/clang/test/Rewriter/rewrite-modern-ivars.mm
new file mode 100644
index 0000000..5e01a44
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-ivars.mm
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@protocol P @end
+@protocol P1 @end
+@interface INTF
+{
+ id CLASS_IVAR;
+ id<P, P1> Q_IVAR;
+
+ void (^_block)(id<P>);
+ void (*_fptr)(void (^_block)(id<P>));
+ char CLASS_EXT_IVAR;
+ id<P, P1> (^ext_block)(id<P>, INTF<P,P1>*, INTF*);
+ id IMPL_IVAR;
+ double D_IMPL_IVAR;
+ INTF<P> *(*imp_fptr)(void (^_block)(id<P>, INTF<P,P1>*));
+ id arr[100];
+}
+@end
+
+@implementation INTF @end
+
+@interface MISC_INTF
+{
+ id CLASS_IVAR;
+ id<P, P1> Q_IVAR;
+
+ void (^_block)(id<P>);
+ void (*_fptr)(void (^_block)(id<P>));
+ unsigned int BF : 8;
+}
+@end
+
+@interface MISC_INTF()
+{
+ char CLASS_EXT_IVAR;
+ id<P, P1> (^ext_block)(id<P>, MISC_INTF<P,P1>*, MISC_INTF*);
+}
+@end
+
+@interface MISC_INTF() {
+ int II1;
+ double DD1; }
+@end
+
+@interface MISC_INTF() { int II2; double DD2; }
+@end
+
+@interface MISC_INTF() { int II3;
+ double DD3; }
+@end
+
+@interface MISC_INTF() { int II4; double DD4;
+}
+@end
+
+@implementation MISC_INTF
+{
+ id IMPL_IVAR;
+ double D_IMPL_IVAR;
+ MISC_INTF<P> *(*imp_fptr)(void (^_block)(id<P>, MISC_INTF<P,P1>*));
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-modern-nested-ivar.mm b/clang/test/Rewriter/rewrite-modern-nested-ivar.mm
new file mode 100644
index 0000000..13e31cd
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-nested-ivar.mm
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -E %s -o %t.m
+// RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %t.m -o %t-rw.cpp
+// RUN: FileCheck --input-file=%t-rw.cpp %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@interface NSURLResponse {
+@public
+ NSURLResponse *InnerResponse;
+}
+@end
+
+@interface NSCachedURLResponseInternal
+{
+ @public
+ NSURLResponse *response;
+}
+@end
+
+@interface NSCachedURLResponse
+{
+ @private
+ NSCachedURLResponseInternal *_internal;
+}
+- (void) Meth;
+@end
+
+@implementation NSCachedURLResponse
+- (void) Meth {
+ _internal->response->InnerResponse = 0;
+ }
+@end
+
+// CHECK: (*(NSURLResponse **)((char *)(*(NSURLResponse **)((char *)(*(NSCachedURLResponseInternal **)((char *)self + OBJC_IVAR_$_NSCachedURLResponse$_internal)) + OBJC_IVAR_$_NSCachedURLResponseInternal$response)) + OBJC_IVAR_$_NSURLResponse$InnerResponse)) = 0;
diff --git a/clang/test/Rewriter/rewrite-modern-protocol-1.mm b/clang/test/Rewriter/rewrite-modern-protocol-1.mm
new file mode 100644
index 0000000..7b737fe
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-protocol-1.mm
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+// rdar://11248048
+
+@protocol NSCopying @end
+
+@interface INTF<NSCopying>
+@end
+
+@implementation INTF @end
+
+// CHECK: static struct _protocol_t _OBJC_PROTOCOL_NSCopying
+// CHECK: static struct _protocol_t *_OBJC_LABEL_PROTOCOL_$_NSCopying = &_OBJC_PROTOCOL_NSCopying;
+
diff --git a/clang/test/Rewriter/rewrite-modern-protocol.mm b/clang/test/Rewriter/rewrite-modern-protocol.mm
new file mode 100644
index 0000000..a4bd617
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-protocol.mm
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@protocol ROOT @end
+
+@protocol P1 @end
+
+@protocol P2<ROOT> @end
+
+@class NSObject;
+
+@protocol PROTO <P1, P2>
+- (id) INST_METHOD;
++ (id) CLASS_METHOD : (id)ARG;
+@property id Prop_in_PROTO;
+@optional
+- (id) opt_instance_method;
++ (id) opt_class_method;
+@property (readonly, retain) NSObject *AnotherProperty;
+@required
+- (id) req;
+@optional
+- (id) X_opt_instance_method;
++ (id) X_opt_class_method;
+@end
+
+@interface INTF <PROTO, ROOT>
+@end
+
+@implementation INTF
+@end
diff --git a/clang/test/Rewriter/rewrite-modern-struct-ivar.mm b/clang/test/Rewriter/rewrite-modern-struct-ivar.mm
new file mode 100644
index 0000000..09c02df
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-struct-ivar.mm
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %t.mm -o %t-rw.cpp
+// RUN: FileCheck --input-file=%t-rw.cpp %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+struct S {
+ int i1;
+ double d1;
+ void (^block1)();
+};
+
+@interface I
+{
+ struct S struct_ivar;
+
+ struct S *pstruct_ivar;
+}
+@end
+
+@implementation I
+- (struct S) dMeth{ return struct_ivar; }
+@end
+
+// CHECK: return (*(struct S *)((char *)self + OBJC_IVAR_$_I$struct_ivar));
diff --git a/clang/test/Rewriter/rewrite-modern-super.mm b/clang/test/Rewriter/rewrite-modern-super.mm
new file mode 100644
index 0000000..ee397b3
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-super.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=struct objc_object *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://11239894
+
+extern "C" void *sel_registerName(const char *);
+
+typedef struct objc_class * Class;
+
+@interface Sub
+- (void)dealloc;
+@end
+
+@interface I : Sub
+- (void)dealloc;
+@end
+
+@implementation I
+- (void)dealloc {
+ return;
+ [super dealloc];
+}
+@end
+
diff --git a/clang/test/Rewriter/rewrite-modern-synchronized.m b/clang/test/Rewriter/rewrite-modern-synchronized.m
new file mode 100644
index 0000000..e895339
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-synchronized.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+void *sel_registerName(const char *);
+
+id SYNCH_EXPR();
+void SYNCH_BODY();
+void SYNCH_BEFORE();
+void SYNC_AFTER();
+
+void foo(id sem)
+{
+ SYNCH_BEFORE();
+ @synchronized (SYNCH_EXPR()) {
+ SYNCH_BODY();
+ return;
+ }
+ SYNC_AFTER();
+ @synchronized ([sem self]) {
+ SYNCH_BODY();
+ return;
+ }
+}
+
+void test_sync_with_implicit_finally() {
+ id foo;
+ @synchronized (foo) {
+ return; // The rewriter knows how to generate code for implicit finally
+ }
+}
diff --git a/clang/test/Rewriter/rewrite-modern-throw.m b/clang/test/Rewriter/rewrite-modern-throw.m
new file mode 100644
index 0000000..1912384
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-throw.m
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+void *sel_registerName(const char *);
+
+@interface Foo @end
+void TRY();
+void SPLATCH();
+void MYTRY();
+void MYCATCH();
+
+void foo() {
+ @try { TRY(); }
+ @catch (...) { SPLATCH(); @throw; }
+}
+
+int main()
+{
+
+ @try {
+ MYTRY();
+ }
+
+ @catch (Foo* localException) {
+ MYCATCH();
+ @throw localException;
+ }
+
+ // no catch clause
+ @try { }
+ @finally { }
+}
+
+
+@interface INST
+{
+ INST* throw_val;
+}
+
+- (id) ThrowThis;
+
+- (void) MainMeth;
+
+@end
+
+
+@implementation INST
+- (id) ThrowThis { return 0; }
+
+- (void) MainMeth {
+ @try {
+ MYTRY();
+ }
+ @catch (Foo* localException) {
+ MYCATCH();
+ @throw [self ThrowThis];
+ }
+ @catch (...) {
+ @throw [throw_val ThrowThis];
+ }
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-modern-try-catch-finally.m b/clang/test/Rewriter/rewrite-modern-try-catch-finally.m
new file mode 100644
index 0000000..9beab7d
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-try-catch-finally.m
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+extern int printf(const char *, ...);
+
+int main() {
+ @try {
+ }
+ @finally {
+ }
+ while (1) {
+ @try {
+ printf("executing try");
+ break;
+ } @finally {
+ printf("executing finally");
+ }
+ printf("executing after finally block");
+ }
+ @try {
+ printf("executing try");
+ } @finally {
+ printf("executing finally");
+ }
+ return 0;
+}
+
+void test2_try_with_implicit_finally() {
+ @try {
+ return;
+ } @catch (id e) {
+
+ }
+}
+
+void FINALLY();
+void TRY();
+void CATCH();
+
+@interface NSException
+@end
+
+@interface Foo
+@end
+
+@implementation Foo
+- (void)bar {
+ @try {
+ TRY();
+ }
+ @catch (NSException *e) {
+ CATCH();
+ }
+ @finally {
+ FINALLY();
+ }
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-modern-try-finally.m b/clang/test/Rewriter/rewrite-modern-try-finally.m
new file mode 100644
index 0000000..500133b
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-try-finally.m
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+void FINALLY();
+void TRY();
+void INNER_FINALLY();
+void INNER_TRY();
+void CHECK();
+
+@interface Foo
+@end
+
+@implementation Foo
+- (void)bar {
+ @try {
+ TRY();
+ }
+ @finally {
+ FINALLY();
+ }
+ CHECK();
+ @try {
+ TRY();
+ }
+ @finally {
+ @try {
+ INNER_TRY();
+ }
+ @finally {
+ INNER_FINALLY();
+ }
+ FINALLY();
+ }
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-modern-typeof.mm b/clang/test/Rewriter/rewrite-modern-typeof.mm
new file mode 100644
index 0000000..4650ab7
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-modern-typeof.mm
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Wno-attributes -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+extern "C" {
+extern "C" void *_Block_copy(const void *aBlock);
+extern "C" void _Block_release(const void *aBlock);
+}
+
+int main() {
+ __attribute__((__blocks__(byref))) int a = 42;
+ int save_a = a;
+
+ void (^b)(void) = ^{
+ ((__typeof(^{ a = 2; }))_Block_copy((const void *)(^{ a = 2; })));
+ };
+
+ ((__typeof(b))_Block_copy((const void *)(b)));
+
+ return 0;
+}
+
+// CHECK-LP: ((void (^)(void))_Block_copy((const void *)(b)))
+
+// radar 7628153
+void f() {
+ int a;
+ __typeof__(a) aVal = a;
+ char *a1t = (char *)@encode(__typeof__(a));
+ __typeof__(aVal) bVal;
+ char *a2t = (char *)@encode(__typeof__(bVal));
+ __typeof__(bVal) cVal = bVal;
+ char *a3t = (char *)@encode(__typeof__(cVal));
+
+}
+
+// rdar://11239324
+void x() {
+ id y;
+ void (^z)() = ^{ };
+ y = (id)((__typeof(z))_Block_copy((const void *)(z)));
+}
+
+// CHECK-LP: int aVal = a;
+
+// CHECK-LP: int bVal;
diff --git a/clang/test/Rewriter/rewrite-nest.m b/clang/test/Rewriter/rewrite-nest.m
new file mode 100644
index 0000000..a08f947
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-nest.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@interface NSMapTable @end
+@interface NSEnumerator @end
+
+typedef unsigned int NSUInteger;
+
+@interface NSConcreteMapTable : NSMapTable {
+@public
+ NSUInteger capacity;
+}
+@end
+
+@interface NSConcreteMapTableValueEnumerator : NSEnumerator {
+ NSConcreteMapTable *mapTable;
+}
+@end
+
+@implementation NSConcreteMapTableValueEnumerator
+
+- nextObject {
+ while (mapTable->capacity) {
+ }
+ return 0;
+}
+@end
+
diff --git a/clang/test/Rewriter/rewrite-nested-blocks-1.mm b/clang/test/Rewriter/rewrite-nested-blocks-1.mm
new file mode 100644
index 0000000..25b17cf
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-nested-blocks-1.mm
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// radar 7696893
+
+void *sel_registerName(const char *);
+
+void f(void (^block)(void));
+void f2(id);
+void f3(int);
+char f4(id, id);
+
+@interface Baz
+- (void)b:(void (^)(void))block;
+@end
+
+@interface Bar
+@end
+
+@interface Foo {
+ int _x;
+}
+@end
+
+@implementation Foo
+- (void)method:(Bar *)up {
+ Baz *down;
+ int at;
+ id cq;
+ __block char didit = 'a';
+ __block char upIsFinished = 'b';
+ f(^{
+ id old_cq;
+ f2(cq);
+ [down b:^{
+ [down b:^{
+ f(^{
+ didit = f4(up, down);
+ upIsFinished = 'c';
+ self->_x++;
+ });
+ }];
+ }];
+ f2(old_cq);
+ f3(at);
+ });
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-nested-blocks-2.mm b/clang/test/Rewriter/rewrite-nested-blocks-2.mm
new file mode 100644
index 0000000..d1513f3
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-nested-blocks-2.mm
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// grep "static void __FUNC_block_copy_" %t-rw.cpp | count 2
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// grep "static void __FUNC_block_copy_" %t-modern-rw.cpp | count 2
+// rdar://8499592
+
+void Outer(void (^bk)());
+void Inner(void (^bk)());
+void INNER_FUNC(id d);
+
+void FUNC() {
+
+ id bar = (id)42;
+ Outer(^{
+ Inner(^{
+ INNER_FUNC(bar);
+ });
+ });
+}
diff --git a/clang/test/Rewriter/rewrite-nested-blocks.mm b/clang/test/Rewriter/rewrite-nested-blocks.mm
new file mode 100644
index 0000000..d492afa
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-nested-blocks.mm
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// radar 7682149
+
+
+void f(void (^block)(void));
+
+@interface X {
+ int y;
+}
+- (void)foo;
+@end
+
+@implementation X
+- (void)foo {
+ f(^{
+ f(^{
+ f(^{
+ y=42;
+ });
+ });
+});
+
+}
+@end
+
+struct S {
+ int y;
+};
+
+void foo () {
+ struct S *SELF;
+ f(^{
+ f(^{
+ SELF->y = 42;
+ });
+ });
+}
+
+// radar 7692419
+@interface Bar
+@end
+
+void f(Bar *);
+void q(void (^block)(void));
+
+void x() {
+ void (^myblock)(Bar *b) = ^(Bar *b) {
+ q(^{
+ f(b);
+ });
+ };
+
+ Bar *b = (Bar *)42;
+ myblock(b);
+}
diff --git a/clang/test/Rewriter/rewrite-nested-ivar.mm b/clang/test/Rewriter/rewrite-nested-ivar.mm
new file mode 100644
index 0000000..bab221d
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-nested-ivar.mm
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw-modern.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw-modern.cpp
+// radar 7583971
+
+
+@interface NSURLResponse {
+@public
+ NSURLResponse *InnerResponse;
+}
+@end
+
+@interface NSCachedURLResponseInternal
+{
+ @public
+ NSURLResponse *response;
+}
+@end
+
+@interface NSCachedURLResponse
+{
+ @private
+ NSCachedURLResponseInternal *_internal;
+}
+- (void) Meth;
+@end
+
+@implementation NSCachedURLResponse
+- (void) Meth {
+ _internal->response->InnerResponse = 0;
+ }
+@end
diff --git a/clang/test/Rewriter/rewrite-nested-property-in-blocks.mm b/clang/test/Rewriter/rewrite-nested-property-in-blocks.mm
new file mode 100755
index 0000000..7f9361e
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-nested-property-in-blocks.mm
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// radar 8608293
+
+void *sel_registerName(const char *);
+
+extern "C" void nowarn(id);
+
+extern "C" void noblockwarn(void (^)());
+
+@interface INTFOFPROP
+@property (readwrite, retain) INTFOFPROP *outer;
+@property (readwrite, retain) id inner;
+@end
+
+@interface NSSet
+- (NSSet *)objectsPassingTest:(char (^)(id obj, char *stop))predicate ;
+@end
+
+@interface INTF
+- (NSSet *)Meth;
+@end
+
+@implementation INTF
+
+- (NSSet *)Meth
+{
+ NSSet *aces;
+
+ noblockwarn(^() {
+ INTFOFPROP *ace;
+ nowarn(ace.outer.inner);
+ noblockwarn(^() {
+ INTFOFPROP *ace;
+ nowarn(ace.outer.inner);
+ });
+ });
+
+ noblockwarn(^() {
+ INTFOFPROP *ace;
+ nowarn(ace.outer.inner);
+ });
+
+return [aces objectsPassingTest:^(id obj, char *stop)
+ {
+ INTFOFPROP *ace = (INTFOFPROP *)obj;
+ nowarn(ace.outer.inner);
+ return (char)0;
+ }];
+
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-no-nextline.mm b/clang/test/Rewriter/rewrite-no-nextline.mm
new file mode 100644
index 0000000..4ef3715
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-no-nextline.mm
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// radar 7946975
+
+@interface RootObject {
+}
+@end void doStuff();
+int main(int argc, char *argv[]) {
+ return 0;
+}
diff --git a/clang/test/Rewriter/rewrite-property-attributes.mm b/clang/test/Rewriter/rewrite-property-attributes.mm
new file mode 100644
index 0000000..c707603
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-property-attributes.mm
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// radar 7214439
+
+typedef void (^void_block_t)(void);
+
+@interface Y {
+ void_block_t __completion;
+ Y* YVAR;
+ id ID;
+}
+@property (copy) void_block_t completionBlock;
+@property (retain) Y* Yblock;
+@property (copy) id ID;
+@end
+
+@implementation Y
+@synthesize completionBlock=__completion;
+@synthesize Yblock = YVAR;
+@synthesize ID;
+@end
+
diff --git a/clang/test/Rewriter/rewrite-property-set-cfstring.mm b/clang/test/Rewriter/rewrite-property-set-cfstring.mm
new file mode 100644
index 0000000..3ac9065
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-property-set-cfstring.mm
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar:// 8527018
+
+void *sel_registerName(const char *);
+
+@class NSString;
+@interface CoreDAVDiscoveryAccountInfo {
+ NSString *_scheme;
+}
+@property (retain) NSString *scheme;
+- (void) Meth ;
+@end
+
+@implementation CoreDAVDiscoveryAccountInfo
+@synthesize scheme=_scheme;
+- (void) Meth {
+ CoreDAVDiscoveryAccountInfo *discoveryInfo;
+ discoveryInfo.scheme = @"https";
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-protocol-property.mm b/clang/test/Rewriter/rewrite-protocol-property.mm
new file mode 100644
index 0000000..3a53f23
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-protocol-property.mm
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -Did="void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar:// 8558702
+
+@class NSString;
+@interface NSObject @end
+
+@protocol P
+@property (retain) NSString* test;
+@end
+
+
+@interface A : NSObject <P> {
+ NSString* _test;
+}
+@end
+
+
+@implementation A
+@synthesize test=_test;
+@end
+
diff --git a/clang/test/Rewriter/rewrite-protocol-qualified.mm b/clang/test/Rewriter/rewrite-protocol-qualified.mm
new file mode 100644
index 0000000..f828724
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-protocol-qualified.mm
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"id=void*" -D"__declspec(X)=" %t-rw.cpp
+// radar 7589414
+
+@protocol NSPortDelegate;
+@interface NSConnection @end
+
+@interface NSMessagePort
+- (void) clone;
+@end
+
+@implementation NSMessagePort
+- (void) clone {
+ NSConnection <NSPortDelegate> *conn = 0;
+ id <NSPortDelegate> *idc = 0;
+}
+@end
+
+// radar 7607413
+@protocol Proto1, Proto2;
+
+@protocol Proto
+@end
+
+unsigned char func(id<Proto1, Proto2> inProxy);
+
+id bar(id);
+
+void f() {
+ id a;
+ id b = bar((id <Proto>)a);
+}
+
+// rdar://8472487
+@protocol NSObject @end
+@class NSRunLoop;
+
+@protocol CoreDAVTaskManager <NSObject>
+ @property (retain) NSRunLoop *workRunLoop;
+@end
+
+
+// rdar://8475819
+@protocol some_protocol;
+
+void foo (int n)
+{
+ id<some_protocol> array[n];
+}
+
diff --git a/clang/test/Rewriter/rewrite-protocol-type-1.m b/clang/test/Rewriter/rewrite-protocol-type-1.m
new file mode 100644
index 0000000..5246df4
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-protocol-type-1.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@protocol MyProto1
+@end
+
+@protocol MyProto2
+@end
+
+@interface INTF @end
+
+INTF <MyProto1> *g1;
+
+INTF <MyProto1, MyProto2> *g2, *g3;
+
+INTF <MyProto1> * Func(INTF <MyProto1> *p2, INTF<MyProto1> *p3, INTF *p4, INTF<MyProto1> *p5)
+{
+ return p2;
+}
+
+INTF <MyProto1, MyProto2> * Func1(INTF *p2, INTF<MyProto1, MyProto2> *p3, INTF *p4, INTF<MyProto1> *p5)
+{
+ return p3;
+}
+
+@interface Foo
+@property int (*hashFunction)(const void *item, int (*size)(const void *item));
+@end
diff --git a/clang/test/Rewriter/rewrite-qualified-id.mm b/clang/test/Rewriter/rewrite-qualified-id.mm
new file mode 100644
index 0000000..f54bae9
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-qualified-id.mm
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// radar 7680953
+
+typedef void * id;
+
+@protocol foo
+@end
+
+@interface CL
+{
+ id <foo> changeSource;
+ CL <foo>* changeSource1;
+}
+@end
+
+typedef struct x
+{
+ id <foo> changeSource;
+} x;
+
diff --git a/clang/test/Rewriter/rewrite-rewritten-initializer.mm b/clang/test/Rewriter/rewrite-rewritten-initializer.mm
new file mode 100644
index 0000000..14734f9
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-rewritten-initializer.mm
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// radar 7669784
+
+typedef void * id;
+void *sel_registerName(const char *);
+
+@interface NSMutableString
+- (NSMutableString *)string;
+@end
+
+@interface Z
+@end
+
+@implementation Z
+
+- (void)x {
+ id numbers;
+ int i, numbersCount = 42;
+ __attribute__((__blocks__(byref))) int blockSum = 0;
+ void (^add)(id n, int idx, char *stop) = ^(id n, int idx, char *stop) { };
+ [numbers enumerateObjectsUsingBlock:add];
+ NSMutableString *forwardAppend = [NSMutableString string];
+ __attribute__((__blocks__(byref))) NSMutableString *blockAppend = [NSMutableString string];
+}
+
+@end
+
diff --git a/clang/test/Rewriter/rewrite-static-block.mm b/clang/test/Rewriter/rewrite-static-block.mm
new file mode 100644
index 0000000..4ee227e
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-static-block.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp -emit-llvm -o %t-rw.ll
+// RUN: FileCheck --input-file=%t-rw.ll %s
+
+typedef void (^void_block_t)(void);
+
+static const void_block_t myblock = ^{
+
+};
+
+// CHECK: myblock = internal global
diff --git a/clang/test/Rewriter/rewrite-super-message.mm b/clang/test/Rewriter/rewrite-super-message.mm
new file mode 100644
index 0000000..d770b33
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-super-message.mm
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -DKEEP_ATTRIBUTES -D"id=struct objc_object *" -D"Class=struct objc_class *" -D"SEL=void*" -D"__declspec(X)=" -emit-llvm -o - %t-rw.cpp | FileCheck %t-rw.cpp
+// radar 7738453
+
+void *sel_registerName(const char *);
+
+@interface __NSCFType
+@end
+
+@interface __NSCFString : __NSCFType
+- (const char *)UTF8String;
+@end
+
+@implementation __NSCFString
+- (const char *)UTF8String {
+ return (const char *)[super UTF8String];
+}
+@end
+
+// CHECK: call %struct.objc_class* @class_getSuperclass
+
+@class NSZone;
+
+@interface NSObject {
+}
+
++ (id)allocWithZone:(NSZone *)zone;
+@end
+
+
+@interface NSArray : NSObject
+@end
+
+@implementation NSArray
++ (id)allocWithZone:(NSZone *)zone {
+ return [super allocWithZone:zone];
+}
+@end
+
+@interface XNSArray
+{
+ Class isa;
+}
+@end
+
+@class XNSArray;
+
+@interface __NSArray0 : XNSArray
+@end
+
+@implementation __NSArray0 @end
diff --git a/clang/test/Rewriter/rewrite-trivial-constructor.mm b/clang/test/Rewriter/rewrite-trivial-constructor.mm
new file mode 100644
index 0000000..f14f4b1
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-trivial-constructor.mm
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fms-extensions -rewrite-objc -fobjc-fragile-abi -x objective-c++ -fblocks -o - %s
+// radar 7537770
+
+typedef struct {
+ int a;
+ int b;
+} s;
+
+extern void CFBasicHashApply(int (^block)(s)) {
+ int used, cnt;
+ for (int idx = 0; 0 < used && idx < cnt; idx++) {
+ s bkt;
+ if (0 < bkt.a) {
+ if (!block(bkt)) {
+ return;
+ }
+ used--;
+ }
+ }
+}
+
diff --git a/clang/test/Rewriter/rewrite-try-catch.m b/clang/test/Rewriter/rewrite-try-catch.m
new file mode 100644
index 0000000..b4d13b6
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-try-catch.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@interface Foo @end
+@interface GARF @end
+
+void foo() {
+ @try { TRY(); }
+ @catch (...) { SPLATCH(); @throw; }
+}
+
+int main()
+{
+
+ @try {
+ MYTRY();
+ }
+
+ @catch (Foo* localException) {
+ MYCATCH();
+ @throw;
+ }
+
+ // no catch clause
+ @try { }
+ @finally { }
+}
+
diff --git a/clang/test/Rewriter/rewrite-typeof.mm b/clang/test/Rewriter/rewrite-typeof.mm
new file mode 100644
index 0000000..24e3bcc
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-typeof.mm
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
+
+extern "C" {
+extern "C" void *_Block_copy(const void *aBlock);
+extern "C" void _Block_release(const void *aBlock);
+}
+
+int main() {
+ __attribute__((__blocks__(byref))) int a = 42;
+ int save_a = a;
+
+ void (^b)(void) = ^{
+ ((__typeof(^{ a = 2; }))_Block_copy((const void *)(^{ a = 2; })));
+ };
+
+ ((__typeof(b))_Block_copy((const void *)(b)));
+
+ return 0;
+}
+
+// CHECK-LP: ((void (^)(void))_Block_copy((const void *)(b)))
+
+// radar 7628153
+void f() {
+ int a;
+ __typeof__(a) aVal = a;
+ char *a1t = (char *)@encode(__typeof__(a));
+ __typeof__(aVal) bVal;
+ char *a2t = (char *)@encode(__typeof__(bVal));
+ __typeof__(bVal) cVal = bVal;
+ char *a3t = (char *)@encode(__typeof__(cVal));
+
+}
+
+
+// CHECK-LP: int aVal = a;
+
+// CHECK-LP: int bVal;
diff --git a/clang/test/Rewriter/rewrite-unique-block-api.mm b/clang/test/Rewriter/rewrite-unique-block-api.mm
new file mode 100644
index 0000000..1dcc1b6
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-unique-block-api.mm
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// radar 7630551
+
+void f(void (^b)(char c));
+
+@interface a
+- (void)processStuff;
+@end
+
+@implementation a
+- (void)processStuff {
+ f(^(char x) { });
+}
+@end
+
+@interface b
+- (void)processStuff;
+@end
+
+@implementation b
+- (void)processStuff {
+ f(^(char x) { });
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-user-defined-accessors.mm b/clang/test/Rewriter/rewrite-user-defined-accessors.mm
new file mode 100644
index 0000000..3c38e17
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-user-defined-accessors.mm
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -Did="void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar:// 8570020
+
+@interface Foo {
+ Foo *foo;
+}
+
+@property (retain, nonatomic) Foo *foo;
+
+@end
+
+@implementation Foo
+
+- (Foo *)foo {
+ if (!foo) {
+ foo = 0;
+ }
+ return foo;
+}
+
+
+- (void) setFoo : (Foo *) arg {
+ foo = arg;
+}
+
+@synthesize foo;
+
+@end
+
diff --git a/clang/test/Rewriter/rewrite-vararg.m b/clang/test/Rewriter/rewrite-vararg.m
new file mode 100644
index 0000000..bd58a6a
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-vararg.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+// rdar://9056351
+void *sel_registerName(const char *);
+
+@interface NSObject @end
+@class NSString;
+
+@protocol P
+ -(void)ParliamentFunkadelic;
+@end
+
+@interface Foo {
+ NSObject <P> *_dataSource;
+}
+@end
+
+@interface Bar { }
++(void)WhateverBar:(NSString*)format, ...;
+@end
+
+@implementation Foo
+-(void)WhateverFoo {
+ [Bar WhateverBar:@"ISyncSessionDriverDataSource %@ responded poorly", _dataSource];
+}
+@end
diff --git a/clang/test/Rewriter/rewrite-weak-attr.m b/clang/test/Rewriter/rewrite-weak-attr.m
new file mode 100644
index 0000000..60c6fc8
--- /dev/null
+++ b/clang/test/Rewriter/rewrite-weak-attr.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -fblocks -Dnil=0 -rewrite-objc -fobjc-fragile-abi -o - %s
+int main() {
+ __weak __block id foo = nil;
+ __block id foo2 = nil;
+ id foo3 = nil;
+
+ void (^myblock)() = ^{
+ foo = nil;
+ foo2 = nil;
+ [foo3 bar];
+ id foo4 = foo3;
+ };
+}
diff --git a/clang/test/Rewriter/static-type-protocol-1.m b/clang/test/Rewriter/static-type-protocol-1.m
new file mode 100644
index 0000000..bafe286
--- /dev/null
+++ b/clang/test/Rewriter/static-type-protocol-1.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@protocol Proto
+- (void) ProtoDidget;
+@end
+
+@protocol MyProto <Proto>
+- (void) widget;
+@end
+
+@interface Foo
+- (void)StillMode;
+@end
+
+@interface Container
++ (void)MyMeth;
+@end
+
+@implementation Container
++ (void)MyMeth
+{
+ Foo *view;
+ [(Foo <MyProto> *)view StillMode];
+ [(Foo <MyProto> *)view widget];
+ [(Foo <MyProto> *)view ProtoDidget];
+}
+@end
diff --git a/clang/test/Rewriter/undecl-objc-h.m b/clang/test/Rewriter/undecl-objc-h.m
new file mode 100644
index 0000000..5c3e693
--- /dev/null
+++ b/clang/test/Rewriter/undecl-objc-h.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+typedef struct S {
+ int * pint;
+ int size;
+}NSRec;
+
+@interface SUPER
+- (NSRec) MainMethod : (NSRec) Arg1 : (NSRec) Arg2;
+@end
+
+@interface MyDerived : SUPER
+{
+ NSRec d;
+}
+- (int) instanceMethod;
+- (int) another : (int) arg;
+- (NSRec) MainMethod : (NSRec) Arg1 : (NSRec) Arg2;
+@end
+
+@implementation MyDerived
+- (int) instanceMethod {
+ return [self another : [self MainMethod : d : d].size];
+}
+
+- (int) another : (int) arg { return arg; }
+- (NSRec) MainMethod : (NSRec) Arg1 : (NSRec) Arg2 { return Arg2; }
+@end
+
diff --git a/clang/test/Rewriter/undeclared-method-1.m b/clang/test/Rewriter/undeclared-method-1.m
new file mode 100644
index 0000000..9b4ca19
--- /dev/null
+++ b/clang/test/Rewriter/undeclared-method-1.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@interface Derived @end
+
+int main(void) {
+ Derived *v ;
+ [v free];
+ return 0;
+}
diff --git a/clang/test/Rewriter/undef-field-reference-1.m b/clang/test/Rewriter/undef-field-reference-1.m
new file mode 100644
index 0000000..9c067a8
--- /dev/null
+++ b/clang/test/Rewriter/undef-field-reference-1.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+@interface MyDerived
+{
+@public
+ int IVAR;
+}
+@end
+
+MyDerived *pd;
+int main() {
+ return pd->IVAR;
+}
+
+
diff --git a/clang/test/Rewriter/unnamed-bf-modern-write.mm b/clang/test/Rewriter/unnamed-bf-modern-write.mm
new file mode 100644
index 0000000..892382f
--- /dev/null
+++ b/clang/test/Rewriter/unnamed-bf-modern-write.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+
+@interface Foo {
+@private
+ int first;
+ int :1;
+ int third :1;
+ int :1;
+ int fifth :1;
+}
+@end
+@implementation Foo
+@end
+
+// CHECK: struct Foo_IMPL {
+// CHECK-NEXT: int first;
+// CHECK-NEXT: int : 1;
+// CHECK-NEXT: int third : 1;
+// CHECK-NEXT: int : 1;
+// CHECK-NEXT: int fifth : 1;
+// CHECK-NEXT: char : 0;
+// CHECK-NEXT: };
diff --git a/clang/test/Rewriter/va-method.m b/clang/test/Rewriter/va-method.m
new file mode 100644
index 0000000..c232d23
--- /dev/null
+++ b/clang/test/Rewriter/va-method.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+
+#include <stdarg.h>
+
+@interface NSObject @end
+@interface XX : NSObject @end
+
+@implementation XX
+- (void)encodeValuesOfObjCTypes:(const char *)types, ... {
+ va_list ap;
+ va_start(ap, types);
+ while (*types) ;
+ va_end(ap);
+}
+
+@end
+
diff --git a/clang/test/Rewriter/weak_byref_objects.m b/clang/test/Rewriter/weak_byref_objects.m
new file mode 100644
index 0000000..1b9efbe
--- /dev/null
+++ b/clang/test/Rewriter/weak_byref_objects.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fblocks -triple i386-apple-darwin9 -fobjc-gc -rewrite-objc -fobjc-fragile-abi %s -o -
+
+#define nil 0
+int main() {
+ __weak __block id foo = nil;
+ __block id foo2 = nil;
+ id foo3 = nil;
+
+ void (^myblock)() = ^{
+ foo = nil;
+ foo2 = nil;
+ [foo3 bar];
+ id foo4 = foo3;
+ };
+}
diff --git a/clang/test/Sema/128bitint.c b/clang/test/Sema/128bitint.c
new file mode 100644
index 0000000..89d3ee2
--- /dev/null
+++ b/clang/test/Sema/128bitint.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 %s
+typedef int i128 __attribute__((__mode__(TI)));
+typedef unsigned u128 __attribute__((__mode__(TI)));
+
+int a[((i128)-1 ^ (i128)-2) == 1 ? 1 : -1];
+int a[(u128)-1 > 1LL ? 1 : -1];
+
+// PR5435
+__uint128_t b = (__uint128_t)-1;
+
+// PR11916: Support for libstdc++ 4.7
+__int128 i = (__int128)0;
+unsigned __int128 u = (unsigned __int128)-1;
diff --git a/clang/test/Sema/2007-10-01-BuildArrayRef.c b/clang/test/Sema/2007-10-01-BuildArrayRef.c
new file mode 100644
index 0000000..4692731
--- /dev/null
+++ b/clang/test/Sema/2007-10-01-BuildArrayRef.c
@@ -0,0 +1,20 @@
+// RUN: not %clang_cc1_only -c %s -o - > /dev/null
+// PR 1603
+void func()
+{
+ const int *arr;
+ arr[0] = 1; // expected-error {{assignment of read-only location}}
+}
+
+struct foo {
+ int bar;
+};
+struct foo sfoo = { 0 };
+
+int func2()
+{
+ const struct foo *fp;
+ fp = &sfoo;
+ fp[0].bar = 1; // expected-error {{ assignment of read-only member}}
+ return sfoo.bar;
+}
diff --git a/clang/test/Sema/2009-03-09-WeakDeclarations-1.c b/clang/test/Sema/2009-03-09-WeakDeclarations-1.c
new file mode 100644
index 0000000..f219de6
--- /dev/null
+++ b/clang/test/Sema/2009-03-09-WeakDeclarations-1.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -triple i686-apple-darwin
+// Insist upon warnings for inappropriate weak attributes.
+
+// O.K.
+extern int ext_weak_import __attribute__ ((__weak_import__));
+
+// These are inappropriate, and should generate warnings:
+int decl_weak_import __attribute__ ((__weak_import__)); // expected-warning {'weak_import' attribute cannot be specified on a definition}
+int decl_initialized_weak_import __attribute__ ((__weak_import__)) = 13; // expected-warning {'weak_import' attribute cannot be specified on a definition}
+
+// O.K.
+extern int ext_f(void) __attribute__ ((__weak_import__));
+
+// These are inappropriate, and should generate warnings:
+int def_f(void) __attribute__ ((__weak_import__));
+int __attribute__ ((__weak_import__)) decl_f(void) {return 0;};
diff --git a/clang/test/Sema/2009-04-22-UnknownSize.c b/clang/test/Sema/2009-04-22-UnknownSize.c
new file mode 100644
index 0000000..9f71740
--- /dev/null
+++ b/clang/test/Sema/2009-04-22-UnknownSize.c
@@ -0,0 +1,4 @@
+// RUN: not %clang_cc1 %s -emit-llvm -o -
+// PR2958
+static struct foo s; // expected-error { tentative definition has type 'struct foo' that is never completed }
+struct foo *p = &s;
diff --git a/clang/test/Sema/2009-07-17-VoidParameter.c b/clang/test/Sema/2009-07-17-VoidParameter.c
new file mode 100644
index 0000000..68d1b1e
--- /dev/null
+++ b/clang/test/Sema/2009-07-17-VoidParameter.c
@@ -0,0 +1,4 @@
+// RUN: not %clang_cc1 -emit-llvm %s -o -
+// PR4214
+typedef void vt;
+void (*func_ptr)(vt my_vt); // expected-error {argument may not have 'void' type}
diff --git a/clang/test/Sema/2010-05-31-palignr.c b/clang/test/Sema/2010-05-31-palignr.c
new file mode 100644
index 0000000..12be29a
--- /dev/null
+++ b/clang/test/Sema/2010-05-31-palignr.c
@@ -0,0 +1,22 @@
+// RUN: not %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o /dev/null %s
+
+#include <tmmintrin.h>
+
+extern int i;
+
+int main ()
+{
+#if defined( __SSSE3__ )
+
+ typedef int16_t vSInt16 __attribute__ ((__vector_size__ (16)));
+
+ short dtbl[] = {1,2,3,4,5,6,7,8};
+ vSInt16 *vdtbl = (vSInt16*) dtbl;
+
+ vSInt16 v0;
+ v0 = *vdtbl;
+ v0 = _mm_alignr_epi8(v0, v0, i); // expected-error {{argument to '__builtin_ia32_palignr128' must be a constant integer}}
+
+ return 0;
+#endif
+}
diff --git a/clang/test/Sema/Inputs/conversion.h b/clang/test/Sema/Inputs/conversion.h
new file mode 100644
index 0000000..768190f
--- /dev/null
+++ b/clang/test/Sema/Inputs/conversion.h
@@ -0,0 +1,4 @@
+/* Fake system header for Sema/conversion.c */
+
+#define LONG_MAX __LONG_MAX__
+#define SETBIT(set,bit) do { int i = bit; set[i/(8*sizeof(set[0]))] |= (1 << (i%(8*sizeof(set)))); } while(0)
diff --git a/clang/test/Sema/Inputs/pragma-arc-cf-code-audited.h b/clang/test/Sema/Inputs/pragma-arc-cf-code-audited.h
new file mode 100644
index 0000000..6ea360c
--- /dev/null
+++ b/clang/test/Sema/Inputs/pragma-arc-cf-code-audited.h
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#pragma clang arc_cf_code_audited begin
diff --git a/clang/test/Sema/Inputs/unused-expr-system-header.h b/clang/test/Sema/Inputs/unused-expr-system-header.h
new file mode 100644
index 0000000..72b2d95
--- /dev/null
+++ b/clang/test/Sema/Inputs/unused-expr-system-header.h
@@ -0,0 +1,23 @@
+// "System header" for testing that -Wunused-value is properly suppressed in
+// certain cases.
+
+#define POSSIBLY_BAD_MACRO(x) \
+ { int i = x; \
+ i; }
+
+#define STATEMENT_EXPR_MACRO(x) \
+ (__extension__ \
+ ({int i = x; \
+ i;}))
+
+#define COMMA_MACRO_1(x, y) \
+ {x, y;}
+
+#define COMMA_MACRO_2(x, y) \
+ if (x) { 1 == 2, y; }
+
+#define COMMA_MACRO_3(x, y) \
+ (x, y)
+
+#define COMMA_MACRO_4(x, y) \
+ ( 1 == 2, y )
diff --git a/clang/test/Sema/MicrosoftCompatibility.c b/clang/test/Sema/MicrosoftCompatibility.c
new file mode 100644
index 0000000..f148e86
--- /dev/null
+++ b/clang/test/Sema/MicrosoftCompatibility.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-compatibility
+
+enum ENUM1; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
+enum ENUM1 var1 = 3;
+enum ENUM1* var2 = 0;
+
+
+enum ENUM2 {
+ ENUM2_a = (enum ENUM2) 4,
+ ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
+ ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
+};
+
+__declspec(noreturn) void f6( void ) {
+ return; // expected-warning {{function 'f6' declared 'noreturn' should not return}}
+}
diff --git a/clang/test/Sema/MicrosoftExtensions.c b/clang/test/Sema/MicrosoftExtensions.c
new file mode 100644
index 0000000..fb0c6bd
--- /dev/null
+++ b/clang/test/Sema/MicrosoftExtensions.c
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions
+
+
+struct A
+{
+ int a[]; /* expected-warning {{flexible array member 'a' in otherwise empty struct is a Microsoft extension}} */
+};
+
+struct C {
+ int l;
+ union {
+ int c1[]; /* expected-warning {{flexible array member 'c1' in a union is a Microsoft extension}} */
+ char c2[]; /* expected-warning {{flexible array member 'c2' in a union is a Microsoft extension}} */
+ };
+};
+
+
+struct D {
+ int l;
+ int D[];
+};
+
+
+
+
+
+
+typedef struct notnested {
+ long bad1;
+ long bad2;
+} NOTNESTED;
+
+
+typedef struct nested1 {
+ long a;
+ struct notnested var1;
+ NOTNESTED var2;
+} NESTED1;
+
+struct nested2 {
+ long b;
+ NESTED1; // expected-warning {{anonymous structs are a Microsoft extension}}
+};
+
+struct test {
+ int c;
+ struct nested2; // expected-warning {{anonymous structs are a Microsoft extension}}
+};
+
+void foo()
+{
+ struct test var;
+ var.a;
+ var.b;
+ var.c;
+ var.bad1; // expected-error {{no member named 'bad1' in 'struct test'}}
+ var.bad2; // expected-error {{no member named 'bad2' in 'struct test'}}
+}
+
+// Enumeration types with a fixed underlying type.
+const int seventeen = 17;
+typedef int Int;
+
+struct X0 {
+ enum E1 : Int { SomeOtherValue } field; // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
+ enum E1 : seventeen;
+};
+
+enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
+ SomeValue = 0x100000000
+};
+
+
+void pointer_to_integral_type_conv(char* ptr) {
+ char ch = (char)ptr;
+ short sh = (short)ptr;
+ ch = (char)ptr;
+ sh = (short)ptr;
+}
+
+
+typedef struct {
+ UNKNOWN u; // expected-error {{unknown type name 'UNKNOWN'}}
+} AA;
+
+typedef struct {
+ AA; // expected-warning {{anonymous structs are a Microsoft extension}}
+} BB;
+
+__declspec(deprecated("This is deprecated")) enum DE1 { one, two } e1;
+struct __declspec(deprecated) DS1 { int i; float f; };
+
+#define MY_TEXT "This is also deprecated"
+__declspec(deprecated(MY_TEXT)) void Dfunc1( void ) {}
+
+void test( void ) {
+ e1 = one; // expected-warning {{'e1' is deprecated: This is deprecated}}
+ struct DS1 s = { 0 }; // expected-warning {{'DS1' is deprecated}}
+ Dfunc1(); // expected-warning {{'Dfunc1' is deprecated: This is also deprecated}}
+
+ enum DE1 no; // no warning because E1 is not deprecated
+}
diff --git a/clang/test/Sema/PR2727.c b/clang/test/Sema/PR2727.c
new file mode 100644
index 0000000..332b0df
--- /dev/null
+++ b/clang/test/Sema/PR2727.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c90 %s
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c99 %s
+
+int f (int x)
+{
+ // sizeof applied to a type should not delete the type.
+ return sizeof (int[x]);
+}
diff --git a/clang/test/Sema/PR2728.c b/clang/test/Sema/PR2728.c
new file mode 100644
index 0000000..e9f1dea
--- /dev/null
+++ b/clang/test/Sema/PR2728.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c90 %s
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c99 %s
+
+struct s
+{
+ int a;
+};
+
+int a[__builtin_offsetof(struct s, a) == 0];
diff --git a/clang/test/Sema/PR2919-builtin-types-compat-strips-crv.c b/clang/test/Sema/PR2919-builtin-types-compat-strips-crv.c
new file mode 100644
index 0000000..9c13357
--- /dev/null
+++ b/clang/test/Sema/PR2919-builtin-types-compat-strips-crv.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+typedef struct foo T0;
+typedef const struct foo T1;
+
+int a0[__builtin_types_compatible_p(T0,
+ const T1) ? 1 : -1];
diff --git a/clang/test/Sema/PR2923.c b/clang/test/Sema/PR2923.c
new file mode 100644
index 0000000..f22e70d
--- /dev/null
+++ b/clang/test/Sema/PR2923.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Test for absence of crash reported in PR 2923:
+//
+// http://llvm.org/bugs/show_bug.cgi?id=2923
+//
+// Previously we had a crash when deallocating the FunctionDecl for 'bar'
+// because FunctionDecl::getNumParams() just used the type of foo to determine
+// the number of parameters it has. In the case of 'bar' there are no
+// ParmVarDecls.
+int foo(int x, int y) { return x + y; }
+extern typeof(foo) bar;
diff --git a/clang/test/Sema/PR2963-enum-constant.c b/clang/test/Sema/PR2963-enum-constant.c
new file mode 100644
index 0000000..43daabf
--- /dev/null
+++ b/clang/test/Sema/PR2963-enum-constant.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+typedef short short_fixed;
+
+enum
+{
+ // 8.8 short_fixed
+ SHORT_FIXED_FRACTIONAL_BITS= 8,
+ SHORT_FIXED_ONE= 1<<SHORT_FIXED_FRACTIONAL_BITS
+};
+
+#define FLOAT_TO_SHORT_FIXED(f) ((short_fixed)((f)*SHORT_FIXED_ONE))
+
+enum
+{
+ SOME_VALUE= FLOAT_TO_SHORT_FIXED(0.1) // expected-warning{{expression is not an integer constant expression}}
+};
diff --git a/clang/test/Sema/__try.c b/clang/test/Sema/__try.c
new file mode 100644
index 0000000..1641402
--- /dev/null
+++ b/clang/test/Sema/__try.c
@@ -0,0 +1,172 @@
+// RUN: %clang_cc1 -fborland-extensions -fsyntax-only -verify %s
+
+#define JOIN2(x,y) x ## y
+#define JOIN(x,y) JOIN2(x,y)
+#define TEST2(name) JOIN(name,__LINE__)
+#define TEST TEST2(test)
+typedef int DWORD;
+
+#pragma sysheader begin
+
+struct EXCEPTION_INFO{};
+
+int __exception_code();
+struct EXCEPTION_INFO* __exception_info();
+void __abnormal_termination();
+
+#define GetExceptionCode __exception_code
+#define GetExceptionInformation __exception_info
+#define AbnormalTermination __abnormal_termination
+
+#pragma sysheader end
+
+DWORD FilterExpression(int); // expected-note{{declared here}}
+DWORD FilterExceptionInformation(struct EXCEPTION_INFO*);
+
+const char * NotFilterExpression();
+
+void TEST() {
+ __try {
+ __try {
+ __try {
+ }
+ __finally{
+ }
+ }
+ __finally{
+ }
+ }
+ __finally{
+ }
+}
+
+void TEST() {
+ __try {
+
+ }
+} // expected-error{{expected '__except' or '__finally' block}}
+
+void TEST() {
+ __except ( FilterExpression() ) { // expected-warning{{implicit declaration of function '__except' is invalid in C99}} \
+ // expected-error{{too few arguments to function call, expected 1, have 0}}
+
+ }
+}
+
+void TEST() {
+ __finally { } // expected-error{{}}
+}
+
+void TEST() {
+ __try{
+ int try_scope = 0;
+ } // TODO: expected expression is an extra error
+ __except( try_scope ? 1 : -1 ) // expected-error{{undeclared identifier 'try_scope'}} expected-error{{expected expression}}
+ {}
+}
+
+void TEST() {
+ __try {
+
+ }
+ // TODO: Why are there two errors?
+ __except( ) { // expected-error{{expected expression}} expected-error{{expected expression}}
+ }
+}
+
+void TEST() {
+ __try {
+
+ }
+ __except ( FilterExpression(GetExceptionCode()) ) {
+
+ }
+
+ __try {
+
+ }
+ __except( FilterExpression(__exception_code()) ) {
+
+ }
+
+ __try {
+
+ }
+ __except( FilterExceptionInformation(__exception_info()) ) {
+
+ }
+
+ __try {
+
+ }
+ __except(FilterExceptionInformation( GetExceptionInformation() ) ) {
+
+ }
+}
+
+void TEST() {
+ __try {
+
+ }
+ __except ( NotFilterExpression() ) { // expected-error{{filter expression type should be an integral value not 'const char *'}}
+
+ }
+}
+
+void TEST() {
+ int function_scope = 0;
+ __try {
+ int try_scope = 0;
+ }
+ __except ( FilterExpression(GetExceptionCode()) ) {
+ (void)function_scope;
+ (void)try_scope; // expected-error{{undeclared identifier}}
+ }
+}
+
+void TEST() {
+ int function_scope = 0;
+ __try {
+ int try_scope = 0;
+ }
+ __finally {
+ (void)function_scope;
+ (void)try_scope; // expected-error{{undeclared identifier}}
+ }
+}
+
+void TEST() {
+ int function_scope = 0;
+ __try {
+
+ }
+ __except( function_scope ? 1 : -1 ) {}
+}
+
+void TEST() {
+ __try {
+ (void)AbnormalTermination; // expected-error{{only allowed in __finally block}}
+ (void)__abnormal_termination; // expected-error{{only allowed in __finally block}}
+ }
+ __except( 1 ) {
+ (void)AbnormalTermination; // expected-error{{only allowed in __finally block}}
+ (void)__abnormal_termination; // expected-error{{only allowed in __finally block}}
+ }
+
+ __try {
+ }
+ __finally {
+ AbnormalTermination();
+ __abnormal_termination();
+ }
+}
+
+void TEST() {
+ (void)__exception_code; // expected-error{{only allowed in __except block}}
+ (void)__exception_info; // expected-error{{only allowed in __except filter expression}}
+ (void)__abnormal_termination; // expected-error{{only allowed in __finally block}}
+
+ (void)GetExceptionCode(); // expected-error{{only allowed in __except block}}
+ (void)GetExceptionInformation(); // expected-error{{only allowed in __except filter expression}}
+ (void)AbnormalTermination(); // expected-error{{only allowed in __finally block}}
+}
diff --git a/clang/test/Sema/address-constant.c b/clang/test/Sema/address-constant.c
new file mode 100644
index 0000000..e842a73
--- /dev/null
+++ b/clang/test/Sema/address-constant.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int i;
+int a[] = {0};
+struct { int i; } s;
+
+int *array[] = {&i, a, &s.i};
+
+extern void f(void);
+void (*f_addr)(void) = &f;
diff --git a/clang/test/Sema/address_spaces.c b/clang/test/Sema/address_spaces.c
new file mode 100644
index 0000000..24799da
--- /dev/null
+++ b/clang/test/Sema/address_spaces.c
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+#define _AS1 __attribute__((address_space(1)))
+#define _AS2 __attribute__((address_space(2)))
+#define _AS3 __attribute__((address_space(3)))
+
+void bar(_AS2 int a); // expected-error {{parameter may not be qualified with an address space}}
+
+void foo(_AS3 float *a,
+ _AS1 float b) // expected-error {{parameter may not be qualified with an address space}}
+{
+ _AS2 *x;// expected-warning {{type specifier missing, defaults to 'int'}}
+ _AS1 float * _AS2 *B;
+
+ int _AS1 _AS2 *Y; // expected-error {{multiple address spaces specified for type}}
+ int *_AS1 _AS2 *Z; // expected-error {{multiple address spaces specified for type}}
+
+ _AS1 int local; // expected-error {{automatic variable qualified with an address space}}
+ _AS1 int array[5]; // expected-error {{automatic variable qualified with an address space}}
+ _AS1 int arrarr[5][5]; // expected-error {{automatic variable qualified with an address space}}
+
+ __attribute__((address_space(-1))) int *_boundsA; // expected-error {{address space is negative}}
+ __attribute__((address_space(0xFFFFFF))) int *_boundsB;
+ __attribute__((address_space(0x1000000))) int *_boundsC; // expected-error {{address space is larger than the maximum supported}}
+ // chosen specifically to overflow 32 bits and come out reasonable
+ __attribute__((address_space(4294967500))) int *_boundsD; // expected-error {{address space is larger than the maximum supported}}
+
+ *a = 5.0f + b;
+}
+
+struct _st {
+ int x, y;
+} s __attribute ((address_space(1))) = {1, 1};
+
+
+// rdar://6774906
+__attribute__((address_space(256))) void * * const base = 0;
+void * get_0(void) {
+ return base[0]; // expected-error {{returning '__attribute__((address_space(256))) void *' from a function with result type 'void *' changes address space of pointer}}
+}
+
+__attribute__((address_space(1))) char test3_array[10];
+void test3(void) {
+ extern void test3_helper(char *p); // expected-note {{passing argument to parameter 'p' here}}
+ test3_helper(test3_array); // expected-error {{changes address space of pointer}}
+}
+
+typedef void ft(void);
+_AS1 ft qf; // expected-error {{function type may not be qualified with an address space}}
+typedef _AS1 ft qft; // expected-error {{function type may not be qualified with an address space}}
diff --git a/clang/test/Sema/align-arm-apcs.c b/clang/test/Sema/align-arm-apcs.c
new file mode 100644
index 0000000..0a5d3fe
--- /dev/null
+++ b/clang/test/Sema/align-arm-apcs.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple arm-unknown-unknown -target-abi apcs-gnu -fsyntax-only -verify %s
+
+struct s0 { double f0; int f1; };
+char chk0[__alignof__(struct s0) == 4 ? 1 : -1];
diff --git a/clang/test/Sema/align-x86-64.c b/clang/test/Sema/align-x86-64.c
new file mode 100644
index 0000000..edea5d8
--- /dev/null
+++ b/clang/test/Sema/align-x86-64.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s
+
+// PR5599
+
+void frob(void *);
+
+void foo(void) {
+ float x[4];
+ char y[__alignof__(x) == 16 ? 1 : -1];
+ frob(y);
+}
+
+// PR5637
+
+typedef __attribute__((aligned(16))) struct {
+ unsigned long long w[3];
+} UINT192;
+
+UINT192 ten2mk192M[] = {
+ {{0xcddd6e04c0592104ULL, 0x0fcf80dc33721d53ULL, 0xa7c5ac471b478423ULL}},
+ {{0xcddd6e04c0592104ULL, 0x0fcf80dc33721d53ULL, 0xa7c5ac471b478423ULL}},
+ {{0xcddd6e04c0592104ULL, 0x0fcf80dc33721d53ULL, 0xa7c5ac471b478423ULL}}
+};
+
+short chk1[sizeof(ten2mk192M) == 80 ? 1 : -1];
diff --git a/clang/test/Sema/align-x86.c b/clang/test/Sema/align-x86.c
new file mode 100644
index 0000000..c6cd754
--- /dev/null
+++ b/clang/test/Sema/align-x86.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+
+// PR3433
+double g1;
+short chk1[__alignof__(g1) == 8 ? 1 : -1];
+short chk2[__alignof__(double) == 8 ? 1 : -1];
+
+long long g2;
+short chk1[__alignof__(g2) == 8 ? 1 : -1];
+short chk2[__alignof__(long long) == 8 ? 1 : -1];
+
+unsigned long long g5;
+short chk1[__alignof__(g5) == 8 ? 1 : -1];
+short chk2[__alignof__(unsigned long long) == 8 ? 1 : -1];
+
+_Complex double g3;
+short chk1[__alignof__(g3) == 8 ? 1 : -1];
+short chk2[__alignof__(_Complex double) == 8 ? 1 : -1];
+
+// PR6362
+struct __attribute__((packed)) {unsigned int a;} g4;
+short chk1[__alignof__(g4) == 1 ? 1 : -1];
+short chk2[__alignof__(g4.a) == 1 ? 1 : -1];
+
+
+// PR5637
+
+#define ALIGNED(x) __attribute__((aligned(x)))
+
+typedef ALIGNED(2) struct {
+ char a[3];
+} T;
+
+short chk1[sizeof(T) == 3 ? 1 : -1];
+short chk2[sizeof(T[1]) == 4 ? 1 : -1];
+short chk3[sizeof(T[2]) == 6 ? 1 : -1];
+short chk4[sizeof(T[2][1]) == 8 ? 1 : -1];
+short chk5[sizeof(T[1][2]) == 6 ? 1 : -1];
+
+typedef struct ALIGNED(2) {
+ char a[3];
+} T2;
+
+short chk1[sizeof(T2) == 4 ? 1 : -1];
+short chk2[sizeof(T2[1]) == 4 ? 1 : -1];
+short chk3[sizeof(T2[2]) == 8 ? 1 : -1];
+short chk4[sizeof(T2[2][1]) == 8 ? 1 : -1];
+short chk5[sizeof(T2[1][2]) == 8 ? 1 : -1];
diff --git a/clang/test/Sema/alignas.c b/clang/test/Sema/alignas.c
new file mode 100644
index 0000000..5832393
--- /dev/null
+++ b/clang/test/Sema/alignas.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c1x %s
+
+_Alignas(3) int align_illegal; //expected-error {{requested alignment is not a power of 2}}
+_Alignas(int) char align_big;
+_Alignas(1) int align_small; // FIXME: this should be rejected
+_Alignas(1) unsigned _Alignas(8) int _Alignas(1) align_multiple;
+
+struct align_member {
+ _Alignas(8) int member;
+};
+
+typedef _Alignas(8) char align_typedef; // FIXME: this should be rejected
+
+_Static_assert(__alignof(align_big) == __alignof(int), "k's alignment is wrong");
+_Static_assert(__alignof(align_small) == 1, "j's alignment is wrong");
+_Static_assert(__alignof(align_multiple) == 8, "l's alignment is wrong");
+_Static_assert(__alignof(struct align_member) == 8, "quuux's alignment is wrong");
+_Static_assert(sizeof(struct align_member) == 8, "quuux's size is wrong");
+_Static_assert(__alignof(align_typedef) == 8, "typedef's alignment is wrong");
diff --git a/clang/test/Sema/altivec-init.c b/clang/test/Sema/altivec-init.c
new file mode 100644
index 0000000..973aab1
--- /dev/null
+++ b/clang/test/Sema/altivec-init.c
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 %s -triple=powerpc-apple-darwin8 -faltivec -verify -pedantic -fsyntax-only
+
+typedef int v4 __attribute((vector_size(16)));
+typedef short v8 __attribute((vector_size(16)));
+
+v8 foo(void) {
+ v8 a;
+ v4 b;
+ a = (v8){4, 2};
+ b = (v4)(5, 6, 7, 8, 9); // expected-warning {{excess elements in vector initializer}}
+ b = (v4)(5, 6, 8, 8.0f);
+
+ vector int vi;
+ vi = (vector int)(1);
+ vi = (vector int)(1, 2); // expected-error {{number of elements must be either one or match the size of the vector}}
+ vi = (vector int)(1, 2, 3, 4);
+ vi = (vector int)(1, 2, 3, 4, 5); // expected-warning {{excess elements in vector initializer}}
+ vi = (vector int){1};
+ vi = (vector int){1, 2};
+ vi = (vector int){1, 2, 3, 4, 5}; // expected-warning {{excess elements in vector initializer}}
+ vector float vf;
+ vf = (vector float)(1.0);
+
+ return (v8){0, 1, 2, 3, 1, 2, 3, 4};
+
+ // FIXME: test that (type)(fn)(args) still works with -faltivec
+ // FIXME: test that c++ overloaded commas still work -faltivec
+}
+
+void __attribute__((__overloadable__)) f(v4 a)
+{
+}
+
+void __attribute__((__overloadable__)) f(int a)
+{
+}
+
+void test()
+{
+ v4 vGCC;
+ vector int vAltiVec;
+
+ f(vAltiVec);
+ vGCC = vAltiVec;
+ int res = vGCC > vAltiVec;
+ vAltiVec = 0 ? vGCC : vGCC;
+}
diff --git a/clang/test/Sema/annotate.c b/clang/test/Sema/annotate.c
new file mode 100644
index 0000000..5b27277
--- /dev/null
+++ b/clang/test/Sema/annotate.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+void __attribute__((annotate("foo"))) foo(float *a) {
+ __attribute__((annotate("bar"))) int x;
+ __attribute__((annotate(1))) int y; // expected-error {{argument to annotate attribute was not a string literal}}
+ __attribute__((annotate("bar", 1))) int z; // expected-error {{attribute takes one argument}}
+ int u = __builtin_annotation(z, (char*) 0); // expected-error {{__builtin_annotation requires a non wide string constant}}
+ int v = __builtin_annotation(z, (char*) L"bar"); // expected-error {{__builtin_annotation requires a non wide string constant}}
+ int w = __builtin_annotation(z, "foo");
+}
diff --git a/clang/test/Sema/anonymous-struct-union-c11.c b/clang/test/Sema/anonymous-struct-union-c11.c
new file mode 100644
index 0000000..229ee52
--- /dev/null
+++ b/clang/test/Sema/anonymous-struct-union-c11.c
@@ -0,0 +1,19 @@
+// Check for warnings in non-C11 mode:
+// RUN: %clang_cc1 -fsyntax-only -verify -Wc11-extensions %s
+
+// Expect no warnings in C11 mode:
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -std=c11 %s
+
+struct s {
+ int a;
+ struct { // expected-warning{{anonymous structs are a C11 extension}}
+ int b;
+ };
+};
+
+struct t {
+ int a;
+ union { // expected-warning{{anonymous unions are a C11 extension}}
+ int b;
+ };
+};
diff --git a/clang/test/Sema/anonymous-struct-union.c b/clang/test/Sema/anonymous-struct-union.c
new file mode 100644
index 0000000..e082290
--- /dev/null
+++ b/clang/test/Sema/anonymous-struct-union.c
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct X {
+ union {
+ float f3;
+ double d2;
+ } named;
+
+ union {
+ int i;
+ float f;
+
+ union {
+ float f2;
+ double d;
+ };
+ };
+
+ struct {
+ int a;
+ float b;
+ };
+};
+
+void test_unqual_references(struct X x, const struct X xc) {
+ x.i = 0;
+ x.f = 0.0;
+ x.f2 = x.f;
+ x.d = x.f;
+ x.f3 = 0; // expected-error{{no member named 'f3'}}
+ x.a = 0;
+
+ xc.d = 0.0; // expected-error{{read-only variable is not assignable}}
+ xc.f = 0; // expected-error{{read-only variable is not assignable}}
+ xc.a = 0; // expected-error{{read-only variable is not assignable}}
+}
+
+
+struct Redecl {
+ int x; // expected-note{{previous declaration is here}}
+ struct y { };
+
+ union {
+ int x; // expected-error{{member of anonymous union redeclares 'x'}}
+ float y;
+ double z; // expected-note{{previous declaration is here}}
+ double zz; // expected-note{{previous declaration is here}}
+ };
+
+ int z; // expected-error{{duplicate member 'z'}}
+ void zz(); // expected-error{{duplicate member 'zz'}}
+};
+
+union { // expected-warning{{declaration does not declare anything}}
+ int int_val;
+ float float_val;
+};
+
+static union { // expected-warning{{declaration does not declare anything}}
+ int int_val2;
+ float float_val2;
+};
+
+void f() {
+ int_val2 = 0; // expected-error{{use of undeclared identifier}}
+ float_val2 = 0.0; // expected-error{{use of undeclared identifier}}
+}
+
+void g() {
+ union { // expected-warning{{declaration does not declare anything}}
+ int i;
+ float f2;
+ };
+ i = 0; // expected-error{{use of undeclared identifier}}
+ f2 = 0.0; // expected-error{{use of undeclared identifier}}
+}
+
+// <rdar://problem/6483159>
+struct s0 { union { int f0; }; };
+
+// <rdar://problem/6481130>
+typedef struct { }; // expected-warning{{declaration does not declare anything}}
+
+// PR3675
+struct s1 {
+ int f0; // expected-note{{previous declaration is here}}
+ union {
+ int f0; // expected-error{{member of anonymous union redeclares 'f0'}}
+ };
+};
+
+// PR3680
+struct {}; // expected-warning{{declaration does not declare anything}}
+
+struct s2 {
+ union {
+ int a;
+ } // expected-warning{{expected ';' at end of declaration list}}
+}; // expected-error{{expected member name or ';' after declaration specifiers}}
+
+// Make sure we don't a.k.a. anonymous structs.
+typedef struct {
+ int x;
+} a_struct;
+int tmp = (a_struct) { .x = 0 }; // expected-error {{initializing 'int' with an expression of incompatible type 'a_struct'}}
+
+// This example comes out of the C11 standard; make sure we don't accidentally reject it.
+struct s {
+ struct { int i; };
+ int a[];
+};
diff --git a/clang/test/Sema/arg-duplicate.c b/clang/test/Sema/arg-duplicate.c
new file mode 100644
index 0000000..feeb458
--- /dev/null
+++ b/clang/test/Sema/arg-duplicate.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int f3(y, x,
+ x) // expected-error {{redefinition of parameter}}
+ int y,
+ x, // expected-note {{previous declaration is here}}
+ x; // expected-error {{redefinition of parameter}}
+{
+ return x + y;
+}
+
+void f4(void) {
+ f3 (1, 1, 2, 3, 4); // expected-warning{{too many arguments}}
+}
+
diff --git a/clang/test/Sema/arg-scope-c99.c b/clang/test/Sema/arg-scope-c99.c
new file mode 100644
index 0000000..912776a
--- /dev/null
+++ b/clang/test/Sema/arg-scope-c99.c
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c99 -verify %s
+void bb(int sz, int ar[sz][sz]) { }
diff --git a/clang/test/Sema/arg-scope.c b/clang/test/Sema/arg-scope.c
new file mode 100644
index 0000000..ed92619
--- /dev/null
+++ b/clang/test/Sema/arg-scope.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+void aa(int b, int x[sizeof b]) {}
+
+void foo(int i, int A[i]) {}
+
diff --git a/clang/test/Sema/arm-layout.c b/clang/test/Sema/arm-layout.c
new file mode 100644
index 0000000..d017fdb
--- /dev/null
+++ b/clang/test/Sema/arm-layout.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple armv7-unknown-unknown -target-abi apcs-gnu %s -verify
+// RUN: %clang_cc1 -triple armv7-unknown-unknown -target-abi aapcs %s -verify
+
+#define check(name, cond) int _##name##_check[(cond) ? 1 : -1]
+
+struct s0 { char field0; double field1; };
+#ifdef __ARM_EABI__
+check(s0_size, sizeof(struct s0) == 16);
+#else
+check(s0_size, sizeof(struct s0) == 12);
+#endif
+
+struct s1 { char field0; long double field1; };
+#ifdef __ARM_EABI__
+check(s1_size, sizeof(struct s1) == 16);
+#else
+check(s1_size, sizeof(struct s1) == 12);
+#endif
+
+struct s2 {
+ short field0;
+ int field1 : 24;
+ char field2;
+};
+#ifdef __ARM_EABI__
+check(s2_size, sizeof(struct s2) == 8);
+check(s2_offset_0, __builtin_offsetof(struct s2, field0) == 0);
+check(s2_offset_1, __builtin_offsetof(struct s2, field2) == 7);
+#else
+check(s2_size, sizeof(struct s2) == 6);
+check(s2_offset_0, __builtin_offsetof(struct s2, field0) == 0);
+check(s2_offset_1, __builtin_offsetof(struct s2, field2) == 5);
+#endif
+
+struct s3 {
+ short field0;
+ int field1 : 24 __attribute__((aligned(4)));
+ char field2;
+};
+check(s3_size, sizeof(struct s3) == 8);
+check(s3_offset_0, __builtin_offsetof(struct s3, field0) == 0);
+check(s3_offset_1, __builtin_offsetof(struct s3, field2) == 7);
+
+struct s4 {
+ int field0 : 4;
+};
+#ifdef __ARM_EABI__
+check(s4_size, sizeof(struct s4) == 4);
+check(s4_align, __alignof(struct s4) == 4);
+#else
+check(s4_size, sizeof(struct s4) == 1);
+check(s4_align, __alignof(struct s4) == 1);
+#endif
diff --git a/clang/test/Sema/arm-neon-types.c b/clang/test/Sema/arm-neon-types.c
new file mode 100644
index 0000000..1a170db
--- /dev/null
+++ b/clang/test/Sema/arm-neon-types.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -Wvector-conversion -ffreestanding -verify %s
+
+#include <arm_neon.h>
+
+// Radar 8228022: Should not report incompatible vector types.
+int32x2_t test(int32x2_t x) {
+ return vshr_n_s32(x, 31);
+}
+
+// ...but should warn when the types really do not match.
+float32x2_t test2(uint32x2_t x) {
+ return vcvt_n_f32_s32(x, 9); // expected-warning {{incompatible vector types}}
+}
+
+// Check immediate range for vcvt_n intrinsics is 1 to 32. Radar 9558930.
+float32x2_t test3(uint32x2_t x) {
+ // FIXME: The "incompatible result type" error is due to pr10112 and should be
+ // removed when that is fixed.
+ return vcvt_n_f32_u32(x, 0); // expected-error {{argument should be a value from 1 to 32}} expected-error {{incompatible result type}}
+}
+
+typedef signed int vSInt32 __attribute__((__vector_size__(16)));
+int32x4_t test4(int32x4_t a, vSInt32 b) {
+ a += b;
+ b += a;
+ return b += a;
+}
+
+// Warn for incompatible pointer types used with vld/vst intrinsics.
+int16x8_t test5(int *p) {
+ return vld1q_s16(p); // expected-warning {{incompatible pointer types}}
+}
+void test6(float *p, int32x2_t v) {
+ return vst1_s32(p, v); // expected-warning {{incompatible pointer types}}
+}
diff --git a/clang/test/Sema/array-bounds-ptr-arith.c b/clang/test/Sema/array-bounds-ptr-arith.c
new file mode 100644
index 0000000..022335b
--- /dev/null
+++ b/clang/test/Sema/array-bounds-ptr-arith.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -Warray-bounds-pointer-arithmetic %s
+
+// Test case from PR10615
+struct ext2_super_block{
+ unsigned char s_uuid[8]; // expected-note {{declared here}}
+};
+void* ext2_statfs (struct ext2_super_block *es,int a)
+{
+ return (void *)es->s_uuid + sizeof(int); // no-warning
+}
+void* broken (struct ext2_super_block *es,int a)
+{
+ return (void *)es->s_uuid + 80; // expected-warning {{refers past the end of the array}}
+}
+
+// Test case reduced from PR11594
+struct S { int n; };
+void pr11594(struct S *s) {
+ int a[10];
+ int *p = a - s->n;
+}
diff --git a/clang/test/Sema/array-constraint.c b/clang/test/Sema/array-constraint.c
new file mode 100644
index 0000000..bee33c0
--- /dev/null
+++ b/clang/test/Sema/array-constraint.c
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+struct s; // expected-note 2 {{forward declaration of 'struct s'}}
+struct s* t (struct s z[]) { // expected-error {{array has incomplete element type}}
+ return z;
+}
+
+void ff() {
+ struct s v, *p; // expected-error {{variable has incomplete type 'struct s'}}
+
+ p = &v;
+}
+
+void *k (void l[2]) { // expected-error {{array has incomplete element type}}
+ return l;
+}
+
+struct vari {
+ int a;
+ int b[];
+};
+
+struct vari *func(struct vari a[]) { // expected-warning {{'struct vari' may not be used as an array element due to flexible array member}}
+ return a;
+}
+
+int foo[](void); // expected-error {{'foo' declared as array of functions}}
+int foo2[1](void); // expected-error {{'foo2' declared as array of functions}}
+
+typedef int (*pfunc)(void);
+
+pfunc xx(int f[](void)) { // expected-error {{'f' declared as array of functions}}
+ return f;
+}
+
+void check_size() {
+ float f;
+ int size_not_int[f]; // expected-error {{size of array has non-integer type 'float'}}
+ int negative_size[1-2]; // expected-error{{array with a negative size}}
+ int zero_size[0]; // expected-warning{{zero size arrays are an extension}}
+}
+
+static int I;
+typedef int TA[I]; // expected-error {{variable length array declaration not allowed at file scope}}
+
+void strFunc(char *); // expected-note{{passing argument to parameter here}}
+const char staticAry[] = "test";
+void checkStaticAry() {
+ strFunc(staticAry); // expected-warning{{passing 'const char [5]' to parameter of type 'char *' discards qualifiers}}
+}
+
+
diff --git a/clang/test/Sema/array-declared-as-incorrect-type.c b/clang/test/Sema/array-declared-as-incorrect-type.c
new file mode 100644
index 0000000..b93fa9a
--- /dev/null
+++ b/clang/test/Sema/array-declared-as-incorrect-type.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+extern int a1[];
+int a1[1];
+
+extern int a2[]; // expected-note {{previous definition is here}}
+float a2[1]; // expected-error {{redefinition of 'a2'}}
+
+extern int a3[][2];
+int a3[1][2];
+
+extern int a4[][2]; // expected-note {{previous definition is here}}
+int a4[2]; // expected-error {{redefinition of 'a4'}}
+
+extern int a5[1][2][3]; // expected-note {{previous definition is here}}
+int a5[3][2][1]; // expected-error {{redefinition of 'a5'}}
diff --git a/clang/test/Sema/array-init.c b/clang/test/Sema/array-init.c
new file mode 100644
index 0000000..26c0b24
--- /dev/null
+++ b/clang/test/Sema/array-init.c
@@ -0,0 +1,289 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+
+extern int foof() = 1; // expected-error{{illegal initializer (only variables can be initialized)}}
+
+static int x, y, z;
+
+static int ary[] = { x, y, z }; // expected-error{{initializer element is not a compile-time constant}}
+int ary2[] = { x, y, z }; // expected-error{{initializer element is not a compile-time constant}}
+
+extern int fileScopeExtern[3] = { 1, 3, 5 }; // expected-warning{{'extern' variable has an initializer}}
+
+static long ary3[] = { 1, "abc", 3, 4 }; // expected-warning{{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char [4]'}}
+
+void func() {
+ int x = 1;
+
+ typedef int TInt = 1; // expected-error{{illegal initializer (only variables can be initialized)}}
+
+ int xComputeSize[] = { 1, 3, 5 };
+
+ int x3[x] = { 1, 2 }; // expected-error{{variable-sized object may not be initialized}}
+
+ int x4 = { 1, 2 }; // expected-warning{{excess elements in scalar initializer}}
+
+ int y[4][3] = {
+ { 1, 3, 5 },
+ { 2, 4, 6 },
+ { 3, 5, 7 },
+ };
+
+ int y2[4][3] = {
+ 1, 3, 5, 2, 4, 6, 3, 5, 7
+ };
+
+ int y3[4][3] = {
+ { 1, 3, 5 },
+ { 2, 4, 6 },
+ { 3, 5, 7 },
+ { 4, 6, 8 },
+ { 5 }, // expected-warning{{excess elements in array initializer}}
+ };
+
+ struct threeElements {
+ int a,b,c;
+ } z = { 1 };
+
+ struct threeElements *p = 7; // expected-warning{{incompatible integer to pointer conversion initializing 'struct threeElements *' with an expression of type 'int'}}
+
+ extern int blockScopeExtern[3] = { 1, 3, 5 }; // expected-error{{'extern' variable cannot have an initializer}}
+
+ static long x2[3] = { 1.0,
+ "abc", // expected-warning{{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char [4]'}}
+ 5.8 }; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+}
+
+void test() {
+ int y1[3] = {
+ { 1, 2, 3 } // expected-warning{{excess elements in scalar initializer}}
+ };
+ int y3[4][3] = {
+ { 1, 3, 5 },
+ { 2, 4, 6 },
+ { 3, 5, 7 },
+ { 4, 6, 8 },
+ { }, // expected-warning{{use of GNU empty initializer extension}} expected-warning{{excess elements in array initializer}}
+ };
+ int y4[4][3] = {
+ { 1, 3, 5, 2 }, // expected-warning{{excess elements in array initializer}}
+ { 4, 6 },
+ { 3, 5, 7 },
+ { 4, 6, 8 },
+ };
+}
+
+void allLegalAndSynonymous() {
+ short q[4][3][2] = {
+ { 1 },
+ { 2, 3 },
+ { 4, 5, 6 }
+ };
+ short q2[4][3][2] = {
+ { 1, 0, 0, 0, 0, 0 },
+ { 2, 3, 0, 0, 0, 0 },
+ { 4, 5, 6 }
+ };
+ short q3[4][3][2] = {
+ {
+ { 1 },
+ },
+ {
+ { 2, 3 },
+ },
+ {
+ { 4, 5 },
+ { 6 },
+ },
+ };
+}
+
+void legal() {
+ short q[][3][2] = {
+ { 1 },
+ { 2, 3 },
+ { 4, 5, 6 }
+ };
+ int q_sizecheck[(sizeof(q) / sizeof(short [3][2])) == 3? 1 : -1];
+}
+
+unsigned char asso_values[] = { 34 };
+int legal2() {
+ return asso_values[0];
+}
+
+void illegal() {
+ short q2[4][][2] = { // expected-error{{array has incomplete element type 'short [][2]'}}
+ { 1, 0, 0, 0, 0, 0 },
+ { 2, 3, 0, 0, 0, 0 },
+ { 4, 5, 6 }
+ };
+ short q3[4][3][] = { // expected-error{{array has incomplete element type 'short []'}}
+ {
+ { 1 },
+ },
+ {
+ { 2, 3 },
+ },
+ {
+ { 4, 5 },
+ { 6 },
+ },
+ };
+ int a[][] = { 1, 2 }; // expected-error{{array has incomplete element type 'int []'}}
+}
+
+typedef int AryT[];
+
+void testTypedef()
+{
+ AryT a = { 1, 2 }, b = { 3, 4, 5 };
+ int a_sizecheck[(sizeof(a) / sizeof(int)) == 2? 1 : -1];
+ int b_sizecheck[(sizeof(b) / sizeof(int)) == 3? 1 : -1];
+}
+
+static char const xx[] = "test";
+int xx_sizecheck[(sizeof(xx) / sizeof(char)) == 5? 1 : -1];
+static char const yy[5] = "test";
+static char const zz[3] = "test"; // expected-warning{{initializer-string for char array is too long}}
+
+void charArrays() {
+ static char const test[] = "test";
+ int test_sizecheck[(sizeof(test) / sizeof(char)) == 5? 1 : -1];
+ static char const test2[] = { "weird stuff" };
+ static char const test3[] = { "test", "excess stuff" }; // expected-warning{{excess elements in char array initializer}}
+
+ char* cp[] = { "Hello" };
+
+ char c[] = { "Hello" };
+ int l[sizeof(c) == 6 ? 1 : -1];
+
+ int i[] = { "Hello "}; // expected-warning{{incompatible pointer to integer conversion initializing 'int' with an expression of type 'char [7]'}}
+ char c2[] = { "Hello", "Good bye" }; //expected-warning{{excess elements in char array initializer}}
+
+ int i2[1] = { "Hello" }; //expected-warning{{incompatible pointer to integer conversion initializing 'int' with an expression of type 'char [6]'}}
+ char c3[5] = { "Hello" };
+ char c4[4] = { "Hello" }; //expected-warning{{initializer-string for char array is too long}}
+
+ int i3[] = {}; //expected-warning{{zero size arrays are an extension}} expected-warning{{use of GNU empty initializer extension}}
+}
+
+void variableArrayInit() {
+ int a = 4;
+ char strlit[a] = "foo"; //expected-error{{variable-sized object may not be initialized}}
+ int b[a] = { 1, 2, 4 }; //expected-error{{variable-sized object may not be initialized}}
+}
+
+// Pure array tests
+float r1[10] = {{7}}; //expected-warning{{braces around scalar initializer}}
+float r2[] = {{8}}; //expected-warning{{braces around scalar initializer}}
+char r3[][5] = {1,2,3,4,5,6};
+int r3_sizecheck[(sizeof(r3) / sizeof(char[5])) == 2? 1 : -1];
+char r3_2[sizeof r3 == 10 ? 1 : -1];
+float r4[1][2] = {1,{2},3,4}; //expected-warning{{braces around scalar initializer}} expected-warning{{excess elements in array initializer}}
+char r5[][5] = {"aa", "bbb", "ccccc"};
+char r6[sizeof r5 == 15 ? 1 : -1];
+const char r7[] = "zxcv";
+char r8[5] = "5char";
+char r9[5] = "6chars"; //expected-warning{{initializer-string for char array is too long}}
+
+int r11[0] = {}; //expected-warning{{zero size arrays are an extension}} expected-warning{{use of GNU empty initializer extension}}
+
+// Some struct tests
+void autoStructTest() {
+struct s1 {char a; char b;} t1;
+struct s2 {struct s1 c;} t2 = { t1 };
+// The following is a less than great diagnostic (though it's on par with EDG).
+struct s1 t3[] = {t1, t1, "abc", 0}; //expected-warning{{incompatible pointer to integer conversion initializing 'char' with an expression of type 'char [4]'}}
+int t4[sizeof t3 == 6 ? 1 : -1];
+}
+struct foo { int z; } w;
+int bar (void) {
+ struct foo z = { w }; //expected-error{{initializing 'int' with an expression of incompatible type 'struct foo'}}
+ return z.z;
+}
+struct s3 {void (*a)(void);} t5 = {autoStructTest};
+struct {int a; int b[];} t6 = {1, {1, 2, 3}}; // expected-warning{{flexible array initialization is a GNU extension}} \
+// expected-note{{initialized flexible array member 'b' is here}}
+union {char a; int b;} t7[] = {1, 2, 3};
+int t8[sizeof t7 == (3*sizeof(int)) ? 1 : -1];
+
+struct bittest{int : 31, a, :21, :12, b;};
+struct bittest bittestvar = {1, 2, 3, 4}; //expected-warning{{excess elements in struct initializer}}
+
+// Not completely sure what should happen here...
+int u1 = {}; //expected-warning{{use of GNU empty initializer extension}} expected-error{{scalar initializer cannot be empty}}
+int u2 = {{3}}; //expected-warning{{too many braces around scalar initializer}}
+
+// PR2362
+void varArray() {
+ int c[][x] = { 0 }; //expected-error{{variable-sized object may not be initialized}}
+}
+
+// PR2151
+void emptyInit() {struct {} x[] = {6};} //expected-warning{{empty struct is a GNU extension}} \
+// expected-error{{initializer for aggregate with no elements}}
+
+void noNamedInit() {
+ struct {int:5;} x[] = {6}; //expected-error{{initializer for aggregate with no elements}}
+}
+struct {int a; int:5;} noNamedImplicit[] = {1,2,3};
+int noNamedImplicitCheck[sizeof(noNamedImplicit) == 3 * sizeof(*noNamedImplicit) ? 1 : -1];
+
+
+// ptrs are constant
+struct soft_segment_descriptor {
+ long ssd_base;
+};
+static int dblfault_tss;
+
+union uniao { int ola; } xpto[1];
+
+struct soft_segment_descriptor gdt_segs[] = {
+ {(long) &dblfault_tss},
+ { (long)xpto},
+};
+
+static void sppp_ipv6cp_up();
+const struct {} ipcp = { sppp_ipv6cp_up }; //expected-warning{{empty struct is a GNU extension}} \
+// expected-warning{{excess elements in struct initializer}}
+
+struct _Matrix { union { float m[4][4]; }; }; //expected-warning{{anonymous unions are a C11 extension}}
+typedef struct _Matrix Matrix;
+void test_matrix() {
+ const Matrix mat1 = {
+ { { 1.0f, 2.0f, 3.0f, 4.0f,
+ 5.0f, 6.0f, 7.0f, 8.0f,
+ 9.0f, 10.0f, 11.0f, 12.0f,
+ 13.0f, 14.0f, 15.0f, 16.0f } }
+ };
+
+ const Matrix mat2 = {
+ 1.0f, 2.0f, 3.0f, 4.0f,
+ 5.0f, 6.0f, 7.0f, 8.0f,
+ 9.0f, 10.0f, 11.0f, 12.0f,
+ 13.0f, 14.0f, 15.0f, 16.0f
+ };
+}
+
+char badchararray[1] = { badchararray[0], "asdf" }; // expected-warning {{excess elements in array initializer}} expected-error {{initializer element is not a compile-time constant}}
+
+// Test the GNU extension for initializing an array from an array
+// compound literal. PR9261.
+typedef int int5[5];
+int a1[5] = (int[]){1, 2, 3, 4, 5}; // expected-warning{{initialization of an array of type 'int [5]' from a compound literal of type 'int [5]' is a GNU extension}}
+int a2[5] = (int[5]){1, 2, 3, 4, 5}; // expected-warning{{initialization of an array of type 'int [5]' from a compound literal of type 'int [5]' is a GNU extension}}
+int a3[] = ((int[]){1, 2, 3, 4, 5}); // expected-warning{{initialization of an array of type 'int []' from a compound literal of type 'int [5]' is a GNU extension}}
+int a4[] = (int[5]){1, 2, 3, 4, 5}; // expected-warning{{initialization of an array of type 'int []' from a compound literal of type 'int [5]' is a GNU extension}}
+int a5[] = (int5){1, 2, 3, 4, 5}; // expected-warning{{initialization of an array of type 'int []' from a compound literal of type 'int5' (aka 'int [5]') is a GNU extension}}
+
+int a6[5] = (int[]){1, 2, 3}; // expected-error{{cannot initialize array of type 'int [5]' with array of type 'int [3]'}}
+
+int nonconst_value();
+int a7[5] = (int[5]){ 1, 2, 3, 4, nonconst_value() }; // expected-error{{initializer element is not a compile-time constant}}
+
+// <rdar://problem/10636946>
+__attribute__((weak)) const unsigned int test10_bound = 10;
+char test10_global[test10_bound]; // expected-error {{variable length array declaration not allowed at file scope}}
+void test10() {
+ char test10_local[test10_bound] = "help"; // expected-error {{variable-sized object may not be initialized}}
+}
diff --git a/clang/test/Sema/array-size-64.c b/clang/test/Sema/array-size-64.c
new file mode 100644
index 0000000..f22e8e7
--- /dev/null
+++ b/clang/test/Sema/array-size-64.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -verify %s
+
+void f() {
+ int a[2147483647U][2147483647U]; // expected-error{{array is too large}}
+ int b[1073741825U - 1U][2147483647U];
+ int c[18446744073709551615U/sizeof(int)/2];
+}
diff --git a/clang/test/Sema/array-size.c b/clang/test/Sema/array-size.c
new file mode 100644
index 0000000..7580e3e
--- /dev/null
+++ b/clang/test/Sema/array-size.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin -verify %s
+
+void f() {
+ int x0[1073741824]; // expected-error{{array is too large}}
+ int x1[1073741824 + 1]; // expected-error{{array is too large}}
+ int x2[(unsigned)1073741824]; // expected-error{{array is too large}}
+ int x3[(unsigned)1073741824 + 1]; // expected-error{{array is too large}}
+ int x4[1073741824 - 1];
+}
+
diff --git a/clang/test/Sema/asm.c b/clang/test/Sema/asm.c
new file mode 100644
index 0000000..44d83e9
--- /dev/null
+++ b/clang/test/Sema/asm.c
@@ -0,0 +1,125 @@
+// RUN: %clang_cc1 %s -triple i386-pc-linux-gnu -verify -fsyntax-only
+
+void f() {
+ int i;
+
+ asm ("foo\n" : : "a" (i + 2));
+ asm ("foo\n" : : "a" (f())); // expected-error {{invalid type 'void' in asm input}}
+
+ asm ("foo\n" : "=a" (f())); // expected-error {{invalid lvalue in asm output}}
+ asm ("foo\n" : "=a" (i + 2)); // expected-error {{invalid lvalue in asm output}}
+
+ asm ("foo\n" : [symbolic_name] "=a" (i) : "[symbolic_name]" (i));
+ asm ("foo\n" : "=a" (i) : "[" (i)); // expected-error {{invalid input constraint '[' in asm}}
+ asm ("foo\n" : "=a" (i) : "[foo" (i)); // expected-error {{invalid input constraint '[foo' in asm}}
+ asm ("foo\n" : "=a" (i) : "[symbolic_name]" (i)); // expected-error {{invalid input constraint '[symbolic_name]' in asm}}
+}
+
+void clobbers() {
+ asm ("nop" : : : "ax", "#ax", "%ax");
+ asm ("nop" : : : "eax", "rax", "ah", "al");
+ asm ("nop" : : : "0", "%0", "#0");
+ asm ("nop" : : : "foo"); // expected-error {{unknown register name 'foo' in asm}}
+ asm ("nop" : : : "52");
+ asm ("nop" : : : "104"); // expected-error {{unknown register name '104' in asm}}
+ asm ("nop" : : : "-1"); // expected-error {{unknown register name '-1' in asm}}
+ asm ("nop" : : : "+1"); // expected-error {{unknown register name '+1' in asm}}
+}
+
+// rdar://6094010
+void test3() {
+ int x;
+ asm(L"foo" : "=r"(x)); // expected-error {{wide string}}
+ asm("foo" : L"=r"(x)); // expected-error {{wide string}}
+}
+
+// <rdar://problem/6156893>
+void test4(const volatile void *addr)
+{
+ asm ("nop" : : "r"(*addr)); // expected-error {{invalid type 'const volatile void' in asm input for constraint 'r'}}
+ asm ("nop" : : "m"(*addr));
+
+ asm ("nop" : : "r"(test4(addr))); // expected-error {{invalid type 'void' in asm input for constraint 'r'}}
+ asm ("nop" : : "m"(test4(addr))); // expected-error {{invalid lvalue in asm input for constraint 'm'}}
+
+ asm ("nop" : : "m"(f())); // expected-error {{invalid lvalue in asm input for constraint 'm'}}
+}
+
+// <rdar://problem/6512595>
+void test5() {
+ asm("nop" : : "X" (8));
+}
+
+// PR3385
+void test6(long i) {
+ asm("nop" : : "er"(i));
+}
+
+void asm_string_tests(int i) {
+ asm("%!"); // simple asm string, %! is not an error.
+ asm("%!" : ); // expected-error {{invalid % escape in inline assembly string}}
+ asm("xyz %" : ); // expected-error {{invalid % escape in inline assembly string}}
+
+ asm ("%[somename]" :: [somename] "i"(4)); // ok
+ asm ("%[somename]" :: "i"(4)); // expected-error {{unknown symbolic operand name in inline assembly string}}
+ asm ("%[somename" :: "i"(4)); // expected-error {{unterminated symbolic operand name in inline assembly string}}
+ asm ("%[]" :: "i"(4)); // expected-error {{empty symbolic operand name in inline assembly string}}
+
+ // PR3258
+ asm("%9" :: "i"(4)); // expected-error {{invalid operand number in inline asm string}}
+ asm("%1" : "+r"(i)); // ok, referring to input.
+}
+
+// PR4077
+int test7(unsigned long long b) {
+ int a;
+ asm volatile("foo %0 %1" : "=a" (a) :"0" (b)); // expected-error {{input with type 'unsigned long long' matching output with type 'int'}}
+ return a;
+}
+
+// <rdar://problem/7574870>
+asm volatile (""); // expected-warning {{meaningless 'volatile' on asm outside function}}
+
+// PR3904
+void test8(int i) {
+ // A number in an input constraint can't point to a read-write constraint.
+ asm("" : "+r" (i), "=r"(i) : "0" (i)); // expected-error{{invalid input constraint '0' in asm}}
+}
+
+// PR3905
+void test9(int i) {
+ asm("" : [foo] "=r" (i), "=r"(i) : "1[foo]"(i)); // expected-error{{invalid input constraint '1[foo]' in asm}}
+ asm("" : [foo] "=r" (i), "=r"(i) : "[foo]1"(i)); // expected-error{{invalid input constraint '[foo]1' in asm}}
+}
+
+register int g asm("dx"); // expected-error{{global register variables are not supported}}
+
+void test10(void){
+ static int g asm ("g_asm") = 0;
+ extern int gg asm ("gg_asm");
+ __private_extern__ int ggg asm ("ggg_asm");
+
+ int a asm ("a_asm"); // expected-warning{{ignored asm label 'a_asm' on automatic variable}}
+ auto int aa asm ("aa_asm"); // expected-warning{{ignored asm label 'aa_asm' on automatic variable}}
+
+ register int r asm ("cx");
+ register int rr asm ("rr_asm"); // expected-error{{unknown register name 'rr_asm' in asm}}
+}
+
+// This is just an assert because of the boolean conversion.
+// Feel free to change the assembly to something sensible if it causes a problem.
+// rdar://problem/9414925
+void test11(void) {
+ _Bool b;
+ asm volatile ("movb %%gs:%P2,%b0" : "=q"(b) : "0"(0), "i"(5L));
+}
+
+void test12(void) {
+ register int cc __asm ("cc"); // expected-error{{unknown register name 'cc' in asm}}
+}
+
+// PR10223
+void test13(void) {
+ void *esp;
+ __asm__ volatile ("mov %%esp, %o" : "=r"(esp) : : ); // expected-error {{invalid % escape in inline assembly string}}
+}
diff --git a/clang/test/Sema/assign-null.c b/clang/test/Sema/assign-null.c
new file mode 100644
index 0000000..7f172b1
--- /dev/null
+++ b/clang/test/Sema/assign-null.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include <stddef.h>
+
+typedef void (*hookfunc)(void *arg);
+hookfunc hook;
+
+void clear_hook() {
+ hook = NULL;
+}
diff --git a/clang/test/Sema/assign.c b/clang/test/Sema/assign.c
new file mode 100644
index 0000000..2d57029
--- /dev/null
+++ b/clang/test/Sema/assign.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void *test1(void) { return 0; }
+
+void test2 (const struct {int a;} *x) {
+ x->a = 10; // expected-error {{read-only variable is not assignable}}
+}
+
+typedef int arr[10];
+void test3() {
+ const arr b;
+ const int b2[10];
+ b[4] = 1; // expected-error {{read-only variable is not assignable}}
+ b2[4] = 1; // expected-error {{read-only variable is not assignable}}
+}
diff --git a/clang/test/Sema/ast-print.c b/clang/test/Sema/ast-print.c
new file mode 100644
index 0000000..ff66d35
--- /dev/null
+++ b/clang/test/Sema/ast-print.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -ast-print
+
+typedef void func_typedef();
+func_typedef xxx;
+
+typedef void func_t(int x);
+func_t a;
+
diff --git a/clang/test/Sema/atomic-ops.c b/clang/test/Sema/atomic-ops.c
new file mode 100644
index 0000000..f769271
--- /dev/null
+++ b/clang/test/Sema/atomic-ops.c
@@ -0,0 +1,165 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=i686-linux-gnu
+
+// Basic parsing/Sema tests for __c11_atomic_*
+
+typedef enum memory_order {
+ memory_order_relaxed, memory_order_consume, memory_order_acquire,
+ memory_order_release, memory_order_acq_rel, memory_order_seq_cst
+} memory_order;
+
+struct S { char c[3]; };
+
+_Static_assert(__GCC_ATOMIC_BOOL_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_CHAR_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_CHAR16_T_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_CHAR32_T_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_WCHAR_T_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
+_Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
+
+_Static_assert(__c11_atomic_is_lock_free(1), "");
+_Static_assert(__c11_atomic_is_lock_free(2), "");
+_Static_assert(__c11_atomic_is_lock_free(3), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__c11_atomic_is_lock_free(4), "");
+_Static_assert(__c11_atomic_is_lock_free(8), "");
+_Static_assert(__c11_atomic_is_lock_free(16), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__c11_atomic_is_lock_free(17), ""); // expected-error {{not an integral constant expression}}
+
+_Static_assert(__atomic_is_lock_free(1, 0), "");
+_Static_assert(__atomic_is_lock_free(2, 0), "");
+_Static_assert(__atomic_is_lock_free(3, 0), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__atomic_is_lock_free(4, 0), "");
+_Static_assert(__atomic_is_lock_free(8, 0), "");
+_Static_assert(__atomic_is_lock_free(16, 0), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__atomic_is_lock_free(17, 0), ""); // expected-error {{not an integral constant expression}}
+
+char i8;
+short i16;
+int i32;
+int __attribute__((vector_size(8))) i64;
+struct Incomplete *incomplete;
+
+_Static_assert(__atomic_is_lock_free(1, &i8), "");
+_Static_assert(__atomic_is_lock_free(1, &i64), "");
+_Static_assert(__atomic_is_lock_free(2, &i8), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__atomic_is_lock_free(2, &i16), "");
+_Static_assert(__atomic_is_lock_free(2, &i64), "");
+_Static_assert(__atomic_is_lock_free(4, &i16), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__atomic_is_lock_free(4, &i32), "");
+_Static_assert(__atomic_is_lock_free(4, &i64), "");
+_Static_assert(__atomic_is_lock_free(8, &i32), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__atomic_is_lock_free(8, &i64), "");
+
+_Static_assert(__atomic_always_lock_free(1, 0), "");
+_Static_assert(__atomic_always_lock_free(2, 0), "");
+_Static_assert(!__atomic_always_lock_free(3, 0), "");
+_Static_assert(__atomic_always_lock_free(4, 0), "");
+_Static_assert(__atomic_always_lock_free(8, 0), "");
+_Static_assert(!__atomic_always_lock_free(16, 0), "");
+_Static_assert(!__atomic_always_lock_free(17, 0), "");
+
+_Static_assert(__atomic_always_lock_free(1, incomplete), "");
+_Static_assert(!__atomic_always_lock_free(2, incomplete), "");
+_Static_assert(!__atomic_always_lock_free(4, incomplete), "");
+
+_Static_assert(__atomic_always_lock_free(1, &i8), "");
+_Static_assert(__atomic_always_lock_free(1, &i64), "");
+_Static_assert(!__atomic_always_lock_free(2, &i8), "");
+_Static_assert(__atomic_always_lock_free(2, &i16), "");
+_Static_assert(__atomic_always_lock_free(2, &i64), "");
+_Static_assert(!__atomic_always_lock_free(4, &i16), "");
+_Static_assert(__atomic_always_lock_free(4, &i32), "");
+_Static_assert(__atomic_always_lock_free(4, &i64), "");
+_Static_assert(!__atomic_always_lock_free(8, &i32), "");
+_Static_assert(__atomic_always_lock_free(8, &i64), "");
+
+void f(_Atomic(int) *i, _Atomic(int*) *p, _Atomic(float) *d,
+ int *I, int **P, float *D, struct S *s1, struct S *s2) {
+ __c11_atomic_init(I, 5); // expected-error {{pointer to _Atomic}}
+ __c11_atomic_load(0); // expected-error {{too few arguments to function}}
+ __c11_atomic_load(0,0,0); // expected-error {{too many arguments to function}}
+ __c11_atomic_store(0,0,0); // expected-error {{first argument to atomic builtin must be a pointer}}
+ __c11_atomic_store((int*)0,0,0); // expected-error {{first argument to atomic operation must be a pointer to _Atomic}}
+
+ __c11_atomic_load(i, memory_order_seq_cst);
+ __c11_atomic_load(p, memory_order_seq_cst);
+ __c11_atomic_load(d, memory_order_seq_cst);
+
+ int load_n_1 = __atomic_load_n(I, memory_order_relaxed);
+ int *load_n_2 = __atomic_load_n(P, memory_order_relaxed);
+ float load_n_3 = __atomic_load_n(D, memory_order_relaxed); // expected-error {{must be a pointer to integer or pointer}}
+ __atomic_load_n(s1, memory_order_relaxed); // expected-error {{must be a pointer to integer or pointer}}
+
+ __atomic_load(i, I, memory_order_relaxed); // expected-error {{must be a pointer to a trivially-copyable type}}
+ __atomic_load(I, i, memory_order_relaxed); // expected-warning {{passing '_Atomic(int) *' to parameter of type 'int *'}}
+ __atomic_load(I, *P, memory_order_relaxed);
+ __atomic_load(I, *P, memory_order_relaxed, 42); // expected-error {{too many arguments}}
+ (int)__atomic_load(I, I, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
+ __atomic_load(s1, s2, memory_order_acquire);
+
+ __c11_atomic_store(i, 1, memory_order_seq_cst);
+ __c11_atomic_store(p, 1, memory_order_seq_cst); // expected-warning {{incompatible integer to pointer conversion}}
+ (int)__c11_atomic_store(d, 1, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
+
+ __atomic_store_n(I, 4, memory_order_release);
+ __atomic_store_n(I, 4.0, memory_order_release);
+ __atomic_store_n(I, P, memory_order_release); // expected-warning {{parameter of type 'int'}}
+ __atomic_store_n(i, 1, memory_order_release); // expected-error {{must be a pointer to integer or pointer}}
+ __atomic_store_n(s1, *s2, memory_order_release); // expected-error {{must be a pointer to integer or pointer}}
+
+ __atomic_store(I, *P, memory_order_release);
+ __atomic_store(s1, s2, memory_order_release);
+ __atomic_store(i, I, memory_order_release); // expected-error {{trivially-copyable}}
+
+ int exchange_1 = __c11_atomic_exchange(i, 1, memory_order_seq_cst);
+ int exchange_2 = __c11_atomic_exchange(I, 1, memory_order_seq_cst); // expected-error {{must be a pointer to _Atomic}}
+ int exchange_3 = __atomic_exchange_n(i, 1, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
+ int exchange_4 = __atomic_exchange_n(I, 1, memory_order_seq_cst);
+
+ __atomic_exchange(s1, s2, s2, memory_order_seq_cst);
+ __atomic_exchange(s1, I, P, memory_order_seq_cst); // expected-warning 2{{parameter of type 'struct S *'}}
+ (int)__atomic_exchange(s1, s2, s2, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
+
+ __c11_atomic_fetch_add(i, 1, memory_order_seq_cst);
+ __c11_atomic_fetch_add(p, 1, memory_order_seq_cst);
+ __c11_atomic_fetch_add(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer or pointer}}
+
+ __atomic_fetch_add(i, 3, memory_order_seq_cst); // expected-error {{pointer to integer or pointer}}
+ __atomic_fetch_sub(I, 3, memory_order_seq_cst);
+ __atomic_fetch_sub(P, 3, memory_order_seq_cst);
+ __atomic_fetch_sub(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
+ __atomic_fetch_sub(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
+
+ __c11_atomic_fetch_and(i, 1, memory_order_seq_cst);
+ __c11_atomic_fetch_and(p, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
+ __c11_atomic_fetch_and(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
+
+ __atomic_fetch_and(i, 3, memory_order_seq_cst); // expected-error {{pointer to integer}}
+ __atomic_fetch_or(I, 3, memory_order_seq_cst);
+ __atomic_fetch_xor(P, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
+ __atomic_fetch_or(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
+ __atomic_fetch_and(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
+
+ _Bool cmpexch_1 = __c11_atomic_compare_exchange_strong(i, 0, 1, memory_order_seq_cst, memory_order_seq_cst);
+ _Bool cmpexch_2 = __c11_atomic_compare_exchange_strong(p, 0, (int*)1, memory_order_seq_cst, memory_order_seq_cst);
+ _Bool cmpexch_3 = __c11_atomic_compare_exchange_strong(d, (int*)0, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{incompatible pointer types}}
+
+ _Bool cmpexch_4 = __atomic_compare_exchange_n(I, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst);
+ _Bool cmpexch_5 = __atomic_compare_exchange_n(I, P, 5, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{; dereference with *}}
+ _Bool cmpexch_6 = __atomic_compare_exchange_n(I, I, P, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'int **' to parameter of type 'int'}}
+
+ _Bool cmpexch_7 = __atomic_compare_exchange(I, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'int' to parameter of type 'int *'}}
+ _Bool cmpexch_8 = __atomic_compare_exchange(I, P, I, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{; dereference with *}}
+ _Bool cmpexch_9 = __atomic_compare_exchange(I, I, I, 0, memory_order_seq_cst, memory_order_seq_cst);
+
+ const volatile int flag_k = 0;
+ volatile int flag = 0;
+ (void)(int)__atomic_test_and_set(&flag_k, memory_order_seq_cst); // expected-warning {{passing 'const volatile int *' to parameter of type 'volatile void *'}}
+ (void)(int)__atomic_test_and_set(&flag, memory_order_seq_cst);
+ __atomic_clear(&flag_k, memory_order_seq_cst); // expected-warning {{passing 'const volatile int *' to parameter of type 'volatile void *'}}
+ __atomic_clear(&flag, memory_order_seq_cst);
+ (int)__atomic_clear(&flag, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
+}
diff --git a/clang/test/Sema/atomic-type.c b/clang/test/Sema/atomic-type.c
new file mode 100644
index 0000000..a4ac552
--- /dev/null
+++ b/clang/test/Sema/atomic-type.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+// Basic parsing/Sema tests for _Atomic
+// No operations are actually supported on objects of this type yet.
+// The qualifier syntax is not supported yet.
+_Atomic(int) t1;
+_Atomic(int) *t2 = &t1;
+void testf(void*);
+void f(void) {
+ _Atomic(_Atomic(int)*) t3;
+ _Atomic(_Atomic(int)*) *t4[2] = { &t3, 0 };
+ testf(t4);
+}
+extern _Atomic(int (*)(int(*)[], int(*)[10])) mergetest;
+extern _Atomic(int (*)(int(*)[10], int(*)[])) mergetest;
+extern _Atomic(int (*)(int(*)[10], int(*)[10])) mergetest;
+
+_Atomic(int()) error1; // expected-error {{_Atomic cannot be applied to function type}}
+_Atomic(struct ErrorS) error2; // expected-error {{_Atomic cannot be applied to incomplete type}} expected-note {{forward declaration}}
+_Atomic(int[10]) error3; // expected-error {{_Atomic cannot be applied to array type}}
+_Atomic(const int) error4; // expected-error {{_Atomic cannot be applied to qualified type}}
+_Atomic(_Atomic(int)) error5; // expected-error {{_Atomic cannot be applied to atomic type}}
diff --git a/clang/test/Sema/attr-alias.c b/clang/test/Sema/attr-alias.c
new file mode 100644
index 0000000..151052f
--- /dev/null
+++ b/clang/test/Sema/attr-alias.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify %s
+
+void g() {}
+
+// It is important that the following string be in the error message. The gcc
+// testsuite looks for it to decide if a target supports aliases.
+
+void f() __attribute__((alias("g"))); //expected-error {{only weak aliases are supported}}
diff --git a/clang/test/Sema/attr-aligned.c b/clang/test/Sema/attr-aligned.c
new file mode 100644
index 0000000..c094ff1
--- /dev/null
+++ b/clang/test/Sema/attr-aligned.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+
+int x __attribute__((aligned(3))); // expected-error {{requested alignment is not a power of 2}}
+
+// PR3254
+short g0[3] __attribute__((aligned));
+short g0_chk[__alignof__(g0) == 16 ? 1 : -1];
+
+// <rdar://problem/6840045>
+typedef char ueber_aligned_char __attribute__((aligned(8)));
+
+struct struct_with_ueber_char {
+ ueber_aligned_char c;
+};
+
+char a = 0;
+
+char a0[__alignof__(ueber_aligned_char) == 8? 1 : -1] = { 0 };
+char a1[__alignof__(struct struct_with_ueber_char) == 8? 1 : -1] = { 0 };
+char a2[__alignof__(a) == 1? : -1] = { 0 };
+char a3[sizeof(a) == 1? : -1] = { 0 };
+
+// rdar://problem/8335865
+int b __attribute__((aligned(2)));
+char b1[__alignof__(b) == 2 ?: -1] = {0};
+
+struct C { int member __attribute__((aligned(2))); } c;
+char c1[__alignof__(c) == 4 ?: -1] = {0};
+char c2[__alignof__(c.member) == 4 ?: -1] = {0};
+
+struct D { int member __attribute__((aligned(2))) __attribute__((packed)); } d;
+char d1[__alignof__(d) == 2 ?: -1] = {0};
+char d2[__alignof__(d.member) == 2 ?: -1] = {0};
+
+struct E { int member __attribute__((aligned(2))); } __attribute__((packed));
+struct E e;
+char e1[__alignof__(e) == 2 ?: -1] = {0};
+char e2[__alignof__(e.member) == 2 ?: -1] = {0};
diff --git a/clang/test/Sema/attr-args.c b/clang/test/Sema/attr-args.c
new file mode 100644
index 0000000..6135801
--- /dev/null
+++ b/clang/test/Sema/attr-args.c
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -DATTR=noreturn -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=always_inline -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=cdecl -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=const -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=fastcall -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=malloc -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=nothrow -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=stdcall -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=used -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=unused -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=weak -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+
+#define ATTR_DECL(a) __attribute__((ATTR(a)))
+
+int a;
+
+inline ATTR_DECL(a) void* foo(); // expected-error{{attribute takes no arguments}}
+
+
+
+// RUN: %clang_cc1 -DATTR=noreturn -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=always_inline -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=cdecl -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=const -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=fastcall -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=malloc -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=nothrow -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=stdcall -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=used -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=unused -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+// RUN: %clang_cc1 -DATTR=weak -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+
+#define ATTR_DECL(a) __attribute__((ATTR(a)))
+
+int a;
+
+inline ATTR_DECL(a) void* foo(); // expected-error{{attribute takes no arguments}}
+
+
+
diff --git a/clang/test/Sema/attr-availability-ios.c b/clang/test/Sema/attr-availability-ios.c
new file mode 100644
index 0000000..ea05e17
--- /dev/null
+++ b/clang/test/Sema/attr-availability-ios.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 "-triple" "x86_64-apple-ios3.0" -fsyntax-only -verify %s
+
+void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1)));
+void f1(int) __attribute__((availability(ios,introduced=2.1)));
+void f2(int) __attribute__((availability(ios,introduced=2.0,deprecated=3.0)));
+void f3(int) __attribute__((availability(ios,introduced=3.0)));
+void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(ios,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // expected-note{{explicitly marked unavailable}}
+
+void f5(int) __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0)));
+void f6(int) __attribute__((availability(ios,deprecated=3.0)));
+void f6(int) __attribute__((availability(ios,introduced=2.0)));
+
+void test() {
+ f0(0); // expected-warning{{'f0' is deprecated: first deprecated in iOS 2.1}}
+ f1(0);
+ f2(0); // expected-warning{{'f2' is deprecated: first deprecated in iOS 3.0}}
+ f3(0);
+ f4(0); // expected-error{{f4' is unavailable: obsoleted in iOS 3.0}}
+ f5(0); // expected-warning{{'f5' is deprecated: first deprecated in iOS 3.0}}
+ f6(0); // expected-warning{{'f6' is deprecated: first deprecated in iOS 3.0}}
+}
diff --git a/clang/test/Sema/attr-availability-macosx.c b/clang/test/Sema/attr-availability-macosx.c
new file mode 100644
index 0000000..1de26e9
--- /dev/null
+++ b/clang/test/Sema/attr-availability-macosx.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 "-triple" "x86_64-apple-darwin9.0.0" -fsyntax-only -verify %s
+
+void f0(int) __attribute__((availability(macosx,introduced=10.4,deprecated=10.6)));
+void f1(int) __attribute__((availability(macosx,introduced=10.5)));
+void f2(int) __attribute__((availability(macosx,introduced=10.4,deprecated=10.5)));
+void f3(int) __attribute__((availability(macosx,introduced=10.6)));
+void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(ios,introduced=2.0,deprecated=3.0))); // expected-note{{explicitly marked unavailable}}
+void f5(int) __attribute__((availability(ios,introduced=3.2), availability(macosx,unavailable))); // expected-note{{function has been explicitly marked unavailable here}}
+
+void test() {
+ f0(0);
+ f1(0);
+ f2(0); // expected-warning{{'f2' is deprecated: first deprecated in Mac OS X 10.5}}
+ f3(0);
+ f4(0); // expected-error{{f4' is unavailable: obsoleted in Mac OS X 10.5}}
+ f5(0); // expected-error{{'f5' is unavailable: not available on Mac OS X}}
+}
+
+// rdar://10535640
+
+enum {
+ foo __attribute__((availability(macosx,introduced=8.0,deprecated=9.0)))
+};
+
+enum {
+ bar __attribute__((availability(macosx,introduced=8.0,deprecated=9.0))) = foo
+};
+
+enum __attribute__((availability(macosx,introduced=8.0,deprecated=9.0))) {
+ bar1 = foo
+};
diff --git a/clang/test/Sema/attr-availability.c b/clang/test/Sema/attr-availability.c
new file mode 100644
index 0000000..0e6ea96
--- /dev/null
+++ b/clang/test/Sema/attr-availability.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -verify %s
+
+void f0() __attribute__((availability(macosx,introduced=10.4,deprecated=10.2))); // expected-warning{{feature cannot be deprecated in Mac OS X version 10.2 before it was introduced in version 10.4; attribute ignored}}
+void f1() __attribute__((availability(ios,obsoleted=2.1,deprecated=3.0))); // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}}
+void f2() __attribute__((availability(ios,introduced=2.1,deprecated=2.1)));
+
+void f3() __attribute__((availability(otheros,introduced=2.2))); // expected-warning{{unknown platform 'otheros' in availability macro}}
+
+// rdar://10095131
+extern void
+ATSFontGetName(const char *oName) __attribute__((availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName")));
+
+extern void
+ATSFontGetPostScriptName(int flags) __attribute__((availability(macosx,introduced=8.0,obsoleted=9.0, message="use ATSFontGetFullPostScriptName"))); // expected-note {{function has been explicitly marked unavailable here}}
+
+void test_10095131() {
+ ATSFontGetName("Hello"); // expected-warning {{'ATSFontGetName' is deprecated: first deprecated in Mac OS X 9.0 - use CTFontCopyFullName}}
+ ATSFontGetPostScriptName(100); // expected-error {{'ATSFontGetPostScriptName' is unavailable: obsoleted in Mac OS X 9.0 - use ATSFontGetFullPostScriptName}}
+}
+
+// rdar://10711037
+__attribute__((availability(macos, unavailable))) // expected-warning {{attribute 'availability' is ignored}}
+enum {
+ NSDataWritingFileProtectionWriteOnly = 0x30000000,
+ NSDataWritingFileProtectionCompleteUntilUserAuthentication = 0x40000000,
+};
diff --git a/clang/test/Sema/attr-cleanup.c b/clang/test/Sema/attr-cleanup.c
new file mode 100644
index 0000000..59ebbfc
--- /dev/null
+++ b/clang/test/Sema/attr-cleanup.c
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+void c1(int *a);
+
+extern int g1 __attribute((cleanup(c1))); // expected-warning {{cleanup attribute ignored}}
+int g2 __attribute((cleanup(c1))); // expected-warning {{cleanup attribute ignored}}
+static int g3 __attribute((cleanup(c1))); // expected-warning {{cleanup attribute ignored}}
+
+void t1()
+{
+ int v1 __attribute((cleanup)); // expected-error {{attribute takes one argument}}
+ int v2 __attribute((cleanup(1, 2))); // expected-error {{attribute takes one argument}}
+
+ static int v3 __attribute((cleanup(c1))); // expected-warning {{cleanup attribute ignored}}
+
+ int v4 __attribute((cleanup(h))); // expected-error {{'cleanup' argument 'h' not found}}
+
+ int v5 __attribute((cleanup(c1)));
+ int v6 __attribute((cleanup(v3))); // expected-error {{'cleanup' argument 'v3' is not a function}}
+}
+
+struct s {
+ int a, b;
+};
+
+void c2();
+void c3(struct s a);
+
+void t2()
+{
+ int v1 __attribute__((cleanup(c2))); // expected-error {{'cleanup' function 'c2' must take 1 parameter}}
+ int v2 __attribute__((cleanup(c3))); // expected-error {{'cleanup' function 'c3' parameter has type 'struct s' which is incompatible with type 'int *'}}
+}
+
+// This is a manufactured testcase, but gcc accepts it...
+void c4(_Bool a);
+void t4() {
+ __attribute((cleanup(c4))) void* g;
+}
+
diff --git a/clang/test/Sema/attr-decl-after-definition.c b/clang/test/Sema/attr-decl-after-definition.c
new file mode 100644
index 0000000..4d32e00
--- /dev/null
+++ b/clang/test/Sema/attr-decl-after-definition.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void foo();
+void foo() __attribute__((unused));
+void foo() __attribute__((unused));
+void foo(){} // expected-note {{previous definition is here}}
+void foo() __attribute__((constructor)); // expected-warning {{must precede definition}}
+void foo();
+
+int bar;
+extern int bar;
+int bar;
+int bar __attribute__((weak));
+int bar __attribute__((used));
+extern int bar __attribute__((weak));
+int bar = 0; // expected-note {{previous definition is here}}
+int bar __attribute__((weak)); // expected-warning {{must precede definition}}
+int bar;
+
diff --git a/clang/test/Sema/attr-declspec-ignored.c b/clang/test/Sema/attr-declspec-ignored.c
new file mode 100644
index 0000000..6fd35c0
--- /dev/null
+++ b/clang/test/Sema/attr-declspec-ignored.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+__attribute__((visibility("hidden"))) __attribute__((aligned)) struct A; // expected-warning{{attribute 'visibility' is ignored, place it after "struct" to apply attribute to type declaration}} \
+// expected-warning{{attribute 'aligned' is ignored, place it after "struct" to apply attribute to type declaration}}
+__attribute__((visibility("hidden"))) __attribute__((aligned)) union B; // expected-warning{{attribute 'visibility' is ignored, place it after "union" to apply attribute to type declaration}} \
+// expected-warning{{attribute 'aligned' is ignored, place it after "union" to apply attribute to type declaration}}
+__attribute__((visibility("hidden"))) __attribute__((aligned)) enum C {C}; // expected-warning{{attribute 'visibility' is ignored, place it after "enum" to apply attribute to type declaration}} \
+// expected-warning{{attribute 'aligned' is ignored, place it after "enum" to apply attribute to type declaration}}
+
+__attribute__((visibility("hidden"))) __attribute__((aligned)) struct D {} d;
+__attribute__((visibility("hidden"))) __attribute__((aligned)) union E {} e;
+__attribute__((visibility("hidden"))) __attribute__((aligned)) enum F {F} f;
diff --git a/clang/test/Sema/attr-deprecated-message.c b/clang/test/Sema/attr-deprecated-message.c
new file mode 100644
index 0000000..5de31d0
--- /dev/null
+++ b/clang/test/Sema/attr-deprecated-message.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// rdar: // 6734520
+
+typedef int INT1 __attribute__((deprecated("Please avoid INT1")));
+
+typedef INT1 INT2 __attribute__ ((__deprecated__("Please avoid INT2")));
+
+typedef INT1 INT1a; // expected-warning {{'INT1' is deprecated: Please avoid INT1}}
+
+typedef INT1 INT1b __attribute__ ((deprecated("Please avoid INT1b")));
+
+INT1 should_be_unavailable; // expected-warning {{'INT1' is deprecated: Please avoid INT1}}
+INT1a should_not_be_deprecated;
+
+INT1 f1(void) __attribute__ ((deprecated("Please avoid f1")));
+INT1 f2(void); // expected-warning {{'INT1' is deprecated: Please avoid INT1}}
+
+typedef enum {red, green, blue} Color __attribute__((deprecated("Please avoid Color")));
+
+
+Color c1; // expected-warning {{'Color' is deprecated: Please avoid Color}}
+
+int g1;
+int g2 __attribute__ ((deprecated("Please avoid g2")));
+
+int func1()
+{
+ int (*pf)() = f1; // expected-warning {{'f1' is deprecated: Please avoid f1}}
+ int i = f2();
+ return g1 + g2; // expected-warning {{'g2' is deprecated: Please avoid g2}}
+}
diff --git a/clang/test/Sema/attr-deprecated.c b/clang/test/Sema/attr-deprecated.c
new file mode 100644
index 0000000..4760dab
--- /dev/null
+++ b/clang/test/Sema/attr-deprecated.c
@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+int f() __attribute__((deprecated));
+void g() __attribute__((deprecated));
+void g();
+
+extern int var __attribute__((deprecated));
+
+int a() {
+ int (*ptr)() = f; // expected-warning {{'f' is deprecated}}
+ f(); // expected-warning {{'f' is deprecated}}
+
+ // test if attributes propagate to functions
+ g(); // expected-warning {{'g' is deprecated}}
+
+ return var; // expected-warning {{'var' is deprecated}}
+}
+
+// test if attributes propagate to variables
+extern int var;
+int w() {
+ return var; // expected-warning {{'var' is deprecated}}
+}
+
+int old_fn() __attribute__ ((deprecated));
+int old_fn();
+int (*fn_ptr)() = old_fn; // expected-warning {{'old_fn' is deprecated}}
+
+int old_fn() {
+ return old_fn()+1; // no warning, deprecated functions can use deprecated symbols.
+}
+
+
+struct foo {
+ int x __attribute__((deprecated));
+};
+
+void test1(struct foo *F) {
+ ++F->x; // expected-warning {{'x' is deprecated}}
+ struct foo f1 = { .x = 17 }; // expected-warning {{'x' is deprecated}}
+ struct foo f2 = { 17 }; // expected-warning {{'x' is deprecated}}
+}
+
+typedef struct foo foo_dep __attribute__((deprecated));
+foo_dep *test2; // expected-warning {{'foo_dep' is deprecated}}
+
+struct __attribute__((deprecated,
+ invalid_attribute)) bar_dep ; // expected-warning {{unknown attribute 'invalid_attribute' ignored}}
+
+struct bar_dep *test3; // expected-warning {{'bar_dep' is deprecated}}
+
+
+// These should not warn because the actually declaration itself is deprecated.
+// rdar://6756623
+foo_dep *test4 __attribute__((deprecated));
+struct bar_dep *test5 __attribute__((deprecated));
+
+typedef foo_dep test6(struct bar_dep*); // expected-warning {{'foo_dep' is deprecated}} \
+ // expected-warning {{'bar_dep' is deprecated}}
+typedef foo_dep test7(struct bar_dep*) __attribute__((deprecated));
+
+int test8(char *p) {
+ p += sizeof(foo_dep); // expected-warning {{'foo_dep' is deprecated}}
+
+ foo_dep *ptr; // expected-warning {{'foo_dep' is deprecated}}
+ ptr = (foo_dep*) p; // expected-warning {{'foo_dep' is deprecated}}
+
+ int func(foo_dep *foo); // expected-warning {{'foo_dep' is deprecated}}
+ return func(ptr);
+}
+
+foo_dep *test9(void) __attribute__((deprecated));
+foo_dep *test9(void) {
+ void* myalloc(unsigned long);
+
+ foo_dep *ptr
+ = (foo_dep*)
+ myalloc(sizeof(foo_dep));
+ return ptr;
+}
+
+void test10(void) __attribute__((deprecated));
+void test10(void) {
+ if (sizeof(foo_dep) == sizeof(void*)) {
+ }
+ foo_dep *localfunc(void);
+ foo_dep localvar;
+}
+
+char test11[sizeof(foo_dep)] __attribute__((deprecated));
+char test12[sizeof(foo_dep)]; // expected-warning {{'foo_dep' is deprecated}}
+
+int test13(foo_dep *foo) __attribute__((deprecated));
+int test14(foo_dep *foo); // expected-warning {{'foo_dep' is deprecated}}
+
+unsigned long test15 = sizeof(foo_dep); // expected-warning {{'foo_dep' is deprecated}}
+unsigned long test16 __attribute__((deprecated))
+ = sizeof(foo_dep);
+
+foo_dep test17, // expected-warning {{'foo_dep' is deprecated}}
+ test18 __attribute__((deprecated)),
+ test19;
+
+// rdar://problem/8518751
+enum __attribute__((deprecated)) Test20 {
+ test20_a __attribute__((deprecated)),
+ test20_b
+};
+void test20() {
+ enum Test20 f; // expected-warning {{'Test20' is deprecated}}
+ f = test20_a; // expected-warning {{'test20_a' is deprecated}}
+ f = test20_b; // expected-warning {{'test20_b' is deprecated}}
+}
+
+char test21[__has_feature(attribute_deprecated_with_message) ? 1 : -1];
diff --git a/clang/test/Sema/attr-format.c b/clang/test/Sema/attr-format.c
new file mode 100644
index 0000000..a223e08
--- /dev/null
+++ b/clang/test/Sema/attr-format.c
@@ -0,0 +1,80 @@
+//RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include <stdarg.h>
+
+void a(const char *a, ...) __attribute__((format(printf, 1,2))); // no-error
+void b(const char *a, ...) __attribute__((format(printf, 1,1))); // expected-error {{'format' attribute parameter 3 is out of bounds}}
+void c(const char *a, ...) __attribute__((format(printf, 0,2))); // expected-error {{'format' attribute parameter 2 is out of bounds}}
+void d(const char *a, int c) __attribute__((format(printf, 1,2))); // expected-error {{format attribute requires variadic function}}
+void e(char *str, int c, ...) __attribute__((format(printf, 2,3))); // expected-error {{format argument not a string type}}
+
+typedef const char* xpto;
+void f(xpto c, va_list list) __attribute__((format(printf, 1, 0))); // no-error
+void g(xpto c) __attribute__((format(printf, 1, 0))); // no-error
+
+void y(char *str) __attribute__((format(strftime, 1,0))); // no-error
+void z(char *str, int c, ...) __attribute__((format(strftime, 1,2))); // expected-error {{strftime format attribute requires 3rd parameter to be 0}}
+
+int (*f_ptr)(char*,...) __attribute__((format(printf, 1,2))); // no-error
+int (*f2_ptr)(double,...) __attribute__((format(printf, 1, 2))); // expected-error {{format argument not a string type}}
+
+struct _mystruct {
+ int (*printf)(const char *format, ...) __attribute__((__format__(printf, 1, 2))); // no-error
+ int (*printf2)(double format, ...) __attribute__((__format__(printf, 1, 2))); // expected-error {{format argument not a string type}}
+};
+
+typedef int (*f3_ptr)(char*,...) __attribute__((format(printf,1,0))); // no-error
+
+// <rdar://problem/6623513>
+int rdar6623513(void *, const char*, const char*, ...)
+ __attribute__ ((format (printf, 3, 0)));
+
+int rdar6623513_aux(int len, const char* s) {
+ rdar6623513(0, "hello", "%.*s", len, s);
+}
+
+
+
+// same as format(printf(...))...
+void a2(const char *a, ...) __attribute__((format(printf0, 1,2))); // no-error
+void b2(const char *a, ...) __attribute__((format(printf0, 1,1))); // expected-error {{'format' attribute parameter 3 is out of bounds}}
+void c2(const char *a, ...) __attribute__((format(printf0, 0,2))); // expected-error {{'format' attribute parameter 2 is out of bounds}}
+void d2(const char *a, int c) __attribute__((format(printf0, 1,2))); // expected-error {{format attribute requires variadic function}}
+void e2(char *str, int c, ...) __attribute__((format(printf0, 2,3))); // expected-error {{format argument not a string type}}
+
+// FreeBSD usage
+#define __printf0like(fmt,va) __attribute__((__format__(__printf0__,fmt,va)))
+void null(int i, const char *a, ...) __printf0like(2,0); // no-error
+void null(int i, const char *a, ...) { // expected-note{{passing argument to parameter 'a' here}}
+ if (a)
+ (void)0/* vprintf(...) would go here */;
+}
+
+void callnull(void){
+ null(0, 0); // no error
+ null(0, (char*)0); // no error
+ null(0, (void*)0); // no error
+ null(0, (int*)0); // expected-warning {{incompatible pointer types}}
+}
+
+
+
+// PR4470
+int xx_vprintf(const char *, va_list);
+
+const char *foo(const char *format) __attribute__((format_arg(1)));
+
+void __attribute__((format(printf, 1, 0)))
+foo2(const char *fmt, va_list va) {
+ xx_vprintf(foo(fmt), va);
+}
+
+// PR6542
+extern void gcc_format (const char *, ...)
+ __attribute__ ((__format__(__gcc_diag__, 1, 2)));
+extern void gcc_cformat (const char *, ...)
+ __attribute__ ((__format__(__gcc_cdiag__, 1, 2)));
+extern void gcc_cxxformat (const char *, ...)
+ __attribute__ ((__format__(__gcc_cxxdiag__, 1, 2)));
+extern void gcc_tformat (const char *, ...)
+ __attribute__ ((__format__(__gcc_tdiag__, 1, 2)));
diff --git a/clang/test/Sema/attr-format_arg.c b/clang/test/Sema/attr-format_arg.c
new file mode 100644
index 0000000..64a2387
--- /dev/null
+++ b/clang/test/Sema/attr-format_arg.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int printf(const char *, ...);
+
+const char* f(const char *s) __attribute__((format_arg(1)));
+
+void g(const char *s) {
+ printf("%d", 123);
+ printf("%d %d", 123); // expected-warning{{more '%' conversions than data arguments}}
+
+ printf(f("%d"), 123);
+ printf(f("%d %d"), 123); // expected-warning{{more '%' conversions than data arguments}}
+}
diff --git a/clang/test/Sema/attr-malloc.c b/clang/test/Sema/attr-malloc.c
new file mode 100644
index 0000000..2cec84d
--- /dev/null
+++ b/clang/test/Sema/attr-malloc.c
@@ -0,0 +1,28 @@
+// RUN: %clang -Xclang -verify -fsyntax-only %s
+// RUN: %clang -emit-llvm -S -o %t %s
+
+#include <stddef.h>
+
+// Declare malloc here explicitly so we don't depend on system headers.
+void * malloc(size_t) __attribute((malloc));
+
+int no_vars __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
+
+void returns_void (void) __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
+int returns_int (void) __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
+int * returns_intptr(void) __attribute((malloc)); // no-warning
+typedef int * iptr;
+iptr returns_iptr (void) __attribute((malloc)); // no-warning
+
+__attribute((malloc)) void *(*f)(); // expected-warning{{'malloc' attribute only applies to functions returning a pointer type}}
+__attribute((malloc)) int (*g)(); // expected-warning{{'malloc' attribute only applies to functions returning a pointer type}}
+
+__attribute((malloc))
+void * xalloc(unsigned n) { return malloc(n); } // no-warning
+// RUN: grep 'define noalias .* @xalloc(' %t
+
+#define malloc_like __attribute((__malloc__))
+void * xalloc2(unsigned) malloc_like;
+void * xalloc2(unsigned n) { return malloc(n); }
+// RUN: grep 'define noalias .* @xalloc2(' %t
+
diff --git a/clang/test/Sema/attr-mode.c b/clang/test/Sema/attr-mode.c
new file mode 100644
index 0000000..0c53362
--- /dev/null
+++ b/clang/test/Sema/attr-mode.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -DTEST_32BIT_X86 -fsyntax-only \
+// RUN: -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -DTEST_64BIT_X86 -fsyntax-only \
+// RUN: -verify %s
+
+typedef int i16_1 __attribute((mode(HI)));
+int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
+typedef int i16_2 __attribute((__mode__(__HI__)));
+int i16_2_test[sizeof(i16_1) == 2 ? 1 : -1];
+
+typedef float f64 __attribute((mode(DF)));
+int f64_test[sizeof(f64) == 8 ? 1 : -1];
+
+typedef int invalid_1 __attribute((mode)); // expected-error{{attribute requires unquoted parameter}}
+typedef int invalid_2 __attribute((mode())); // expected-error{{attribute requires unquoted parameter}}
+typedef int invalid_3 __attribute((mode(II))); // expected-error{{unknown machine mode}}
+typedef struct {int i,j,k;} invalid_4 __attribute((mode(SI))); // expected-error{{mode attribute only supported for integer and floating-point types}}
+typedef float invalid_5 __attribute((mode(SI))); // expected-error{{type of machine mode does not match type of base type}}
+
+int **__attribute((mode(QI)))* i32; // expected-error{{mode attribute}}
+
+typedef _Complex double c32 __attribute((mode(SC)));
+int c32_test[sizeof(c32) == 8 ? 1 : -1];
+typedef _Complex float c64 __attribute((mode(DC)));
+typedef _Complex float c80 __attribute((mode(XC)));
+
+// PR6108: Correctly select 'long' built in type on 64-bit platforms for 64 bit
+// modes. Also test other mode-based conversions.
+typedef int i8_mode_t __attribute__ ((__mode__ (__QI__)));
+typedef unsigned int ui8_mode_t __attribute__ ((__mode__ (__QI__)));
+typedef int i16_mode_t __attribute__ ((__mode__ (__HI__)));
+typedef unsigned int ui16_mode_t __attribute__ ((__mode__ (__HI__)));
+typedef int i32_mode_t __attribute__ ((__mode__ (__SI__)));
+typedef unsigned int ui32_mode_t __attribute__ ((__mode__ (__SI__)));
+typedef int i64_mode_t __attribute__ ((__mode__ (__DI__)));
+typedef unsigned int ui64_mode_t __attribute__ ((__mode__ (__DI__)));
+void f_i8_arg(i8_mode_t* x) { (void)x; }
+void f_ui8_arg(ui8_mode_t* x) { (void)x; }
+void f_i16_arg(i16_mode_t* x) { (void)x; }
+void f_ui16_arg(ui16_mode_t* x) { (void)x; }
+void f_i32_arg(i32_mode_t* x) { (void)x; }
+void f_ui32_arg(ui32_mode_t* x) { (void)x; }
+void f_i64_arg(i64_mode_t* x) { (void)x; }
+void f_ui64_arg(ui64_mode_t* x) { (void)x; }
+void test_char_to_i8(signed char* y) { f_i8_arg(y); }
+void test_char_to_ui8(unsigned char* y) { f_ui8_arg(y); }
+void test_short_to_i16(short* y) { f_i16_arg(y); }
+void test_short_to_ui16(unsigned short* y) { f_ui16_arg(y); }
+void test_int_to_i32(int* y) { f_i32_arg(y); }
+void test_int_to_ui32(unsigned int* y) { f_ui32_arg(y); }
+#if TEST_32BIT_X86
+void test_long_to_i64(long long* y) { f_i64_arg(y); }
+void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
+#elif TEST_64BIT_X86
+void test_long_to_i64(long* y) { f_i64_arg(y); }
+void test_long_to_ui64(unsigned long* y) { f_ui64_arg(y); }
+#else
+#error Unknown test architecture.
+#endif
diff --git a/clang/test/Sema/attr-naked.c b/clang/test/Sema/attr-naked.c
new file mode 100644
index 0000000..d9fa542
--- /dev/null
+++ b/clang/test/Sema/attr-naked.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+int a __attribute__((naked)); // expected-warning {{'naked' attribute only applies to functions}}
+
+__attribute__((naked)) int t0(void) {
+ __asm__ volatile("mov r0, #0");
+}
+
+void t1() __attribute__((naked));
+
+void t2() __attribute__((naked(2))); // expected-error {{attribute takes no arguments}}
+
diff --git a/clang/test/Sema/attr-nodebug.c b/clang/test/Sema/attr-nodebug.c
new file mode 100644
index 0000000..a66e961
--- /dev/null
+++ b/clang/test/Sema/attr-nodebug.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+int a __attribute__((nodebug)); // expected-warning {{'nodebug' attribute only applies to functions}}
+
+void t1() __attribute__((nodebug));
+
+void t2() __attribute__((nodebug(2))); // expected-error {{attribute takes no arguments}}
+
diff --git a/clang/test/Sema/attr-noinline.c b/clang/test/Sema/attr-noinline.c
new file mode 100644
index 0000000..dfc88a8
--- /dev/null
+++ b/clang/test/Sema/attr-noinline.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+int a __attribute__((noinline)); // expected-warning {{'noinline' attribute only applies to functions}}
+
+void t1() __attribute__((noinline));
+
+void t2() __attribute__((noinline(2))); // expected-error {{attribute takes no arguments}}
+
diff --git a/clang/test/Sema/attr-noreturn.c b/clang/test/Sema/attr-noreturn.c
new file mode 100644
index 0000000..5c643ff
--- /dev/null
+++ b/clang/test/Sema/attr-noreturn.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+static void (*fp0)(void) __attribute__((noreturn));
+
+void fatal();
+
+static void __attribute__((noreturn)) f0(void) {
+ fatal();
+} // expected-warning {{function declared 'noreturn' should not return}}
+
+// On K&R
+int f1() __attribute__((noreturn));
+
+int g0 __attribute__((noreturn)); // expected-warning {{'noreturn' only applies to function types; type here is 'int'}}
+
+int f2() __attribute__((noreturn(1, 2))); // expected-error {{attribute takes no arguments}}
+
+void f3() __attribute__((noreturn));
+void f3() {
+ return; // expected-warning {{function 'f3' declared 'noreturn' should not return}}
+}
+
+#pragma clang diagnostic error "-Winvalid-noreturn"
+
+void f4() __attribute__((noreturn));
+void f4() {
+ return; // expected-error {{function 'f4' declared 'noreturn' should not return}}
+}
+
+// PR4685
+extern void f5 (unsigned long) __attribute__ ((__noreturn__));
+
+void
+f5 (unsigned long size)
+{
+
+}
+
+// PR2461
+__attribute__((noreturn)) void f(__attribute__((noreturn)) void (*x)(void)) {
+ x();
+}
+
+typedef void (*Fun)(void) __attribute__ ((noreturn(2))); // expected-error {{attribute takes no arguments}}
diff --git a/clang/test/Sema/attr-regparm.c b/clang/test/Sema/attr-regparm.c
new file mode 100644
index 0000000..642c07e
--- /dev/null
+++ b/clang/test/Sema/attr-regparm.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+
+__attribute((regparm(2))) int x0(void);
+__attribute((regparm(1.0))) int x1(void); // expected-error{{'regparm' attribute requires integer constant}}
+__attribute((regparm(-1))) int x2(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}}
+__attribute((regparm(5))) int x3(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}}
+__attribute((regparm(5,3))) int x4(void); // expected-error{{attribute takes one argument}}
+
+void __attribute__((regparm(3))) x5(int);
+void x5(int); // expected-note{{previous declaration is here}}
+void __attribute__((regparm(2))) x5(int); // expected-error{{function declared with with regparm(2) attribute was previously declared with the regparm(3) attribute}}
diff --git a/clang/test/Sema/attr-returns-twice.c b/clang/test/Sema/attr-returns-twice.c
new file mode 100644
index 0000000..13f53e3
--- /dev/null
+++ b/clang/test/Sema/attr-returns-twice.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+int a __attribute__((returns_twice)); // expected-warning {{'returns_twice' attribute only applies to functions}}
+
+__attribute__((returns_twice)) void t0(void) {
+}
+
+void t1() __attribute__((returns_twice));
+
+void t2() __attribute__((returns_twice(2))); // expected-error {{attribute takes no arguments}}
+
+typedef void (*t3)(void) __attribute__((returns_twice)); // expected-warning {{'returns_twice' attribute only applies to functions}}
diff --git a/clang/test/Sema/attr-section.c b/clang/test/Sema/attr-section.c
new file mode 100644
index 0000000..a932525
--- /dev/null
+++ b/clang/test/Sema/attr-section.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -triple x86_64-apple-darwin9 %s
+
+int x __attribute__((section(
+ 42))); // expected-error {{argument to section attribute was not a string literal}}
+
+
+// rdar://4341926
+int y __attribute__((section(
+ "sadf"))); // expected-error {{mach-o section specifier requires a segment and section separated by a comma}}
+
+// PR6007
+void test() {
+ __attribute__((section("NEAR,x"))) int n1; // expected-error {{'section' attribute is not valid on local variables}}
+ __attribute__((section("NEAR,x"))) static int n2; // ok.
+}
diff --git a/clang/test/Sema/attr-sentinel.c b/clang/test/Sema/attr-sentinel.c
new file mode 100644
index 0000000..abc108f
--- /dev/null
+++ b/clang/test/Sema/attr-sentinel.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define NULL (void*)0
+
+#define ATTR __attribute__ ((__sentinel__))
+
+void foo1 (int x, ...) ATTR; // expected-note 3 {{function has been explicitly marked sentinel here}}
+void foo5 (int x, ...) __attribute__ ((__sentinel__(1))); // expected-note {{function has been explicitly marked sentinel here}}
+void foo6 (int x, ...) __attribute__ ((__sentinel__(5))); // expected-note {{function has been explicitly marked sentinel here}}
+void foo7 (int x, ...) __attribute__ ((__sentinel__(0))); // expected-note {{function has been explicitly marked sentinel here}}
+void foo10 (int x, ...) __attribute__ ((__sentinel__(1,1)));
+void foo12 (int x, ... ) ATTR; // expected-note {{function has been explicitly marked sentinel here}}
+
+#define FOOMACRO(...) foo1(__VA_ARGS__)
+
+void test1() {
+ foo1(1, NULL); // OK
+ foo1(1, 0) ; // expected-warning {{missing sentinel in function call}}
+ foo5(1, NULL, 2); // OK
+ foo5(1,2,NULL, 1); // OK
+ foo5(1, NULL, 2, 1); // expected-warning {{missing sentinel in function call}}
+
+ foo6(1,2,3,4,5,6,7); // expected-warning {{missing sentinel in function call}}
+ foo6(1,NULL,3,4,5,6,7); // OK
+ foo7(1); // expected-warning {{not enough variable arguments in 'foo7' declaration to fit a sentinel}}
+ foo7(1, NULL); // OK
+
+ foo12(1); // expected-warning {{not enough variable arguments in 'foo12' declaration to fit a sentinel}}
+
+ // PR 5685
+ struct A {};
+ struct A a, b, c;
+ foo1(3, &a, &b, &c); // expected-warning {{missing sentinel in function call}}
+ foo1(3, &a, &b, &c, (struct A*) 0);
+
+ // PR11002
+ FOOMACRO(1, 2); // expected-warning {{missing sentinel in function call}}
+}
+
+
+
+void (*e) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (1,1)));
+
+void test2() {
+ void (*b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)); // expected-note {{function has been explicitly marked sentinel here}}
+ void (*z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))); // expected-note {{function has been explicitly marked sentinel here}}
+
+
+ void (*y) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (5))); // expected-note {{function has been explicitly marked sentinel here}}
+
+ b(1, "%s", (void*)0); // OK
+ b(1, "%s", 0); // expected-warning {{missing sentinel in function call}}
+ z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in function call}}
+ z(1, "%s", (void*)0, 1, 0); // OK
+
+ y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in function call}}
+
+ y(1, "%s", (void*)0,3,4,5,6,7); // OK
+}
diff --git a/clang/test/Sema/attr-unavailable-message.c b/clang/test/Sema/attr-unavailable-message.c
new file mode 100644
index 0000000..b2956d8
--- /dev/null
+++ b/clang/test/Sema/attr-unavailable-message.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar: //6734520
+
+int foo(int) __attribute__((__unavailable__("USE IFOO INSTEAD"))); // expected-note {{function has been explicitly marked unavailable here}}
+double dfoo(double) __attribute__((__unavailable__("NO LONGER"))); // expected-note 2 {{function has been explicitly marked unavailable here}}
+
+void bar() __attribute__((__unavailable__)); // expected-note {{explicitly marked unavailable}}
+
+void test_foo() {
+ int ir = foo(1); // expected-error {{'foo' is unavailable: USE IFOO INSTEAD}}
+ double dr = dfoo(1.0); // expected-error {{'dfoo' is unavailable: NO LONGER}}
+
+ void (*fp)() = &bar; // expected-error {{'bar' is unavailable}}
+
+ double (*fp4)(double) = dfoo; // expected-error {{'dfoo' is unavailable: NO LONGER}}
+}
+
+char test2[__has_feature(attribute_unavailable_with_message) ? 1 : -1];
+
+// rdar://9623855
+void unavail(void) __attribute__((__unavailable__));
+void unavail(void) {
+ // No complains inside an unavailable function.
+ int ir = foo(1);
+ double dr = dfoo(1.0);
+ void (*fp)() = &bar;
+ double (*fp4)(double) = dfoo;
+}
+
+// rdar://10201690
+enum foo {
+ a = 1,
+ b __attribute__((deprecated())) = 2,
+ c = 3
+}__attribute__((deprecated()));
+
+enum fee { // expected-note {{declaration has been explicitly marked unavailable here}}
+ r = 1, // expected-note {{declaration has been explicitly marked unavailable here}}
+ s = 2,
+ t = 3
+}__attribute__((unavailable()));
+
+enum fee f() { // expected-error {{'fee' is unavailable}}
+ int i = a; // expected-warning {{'a' is deprecated}}
+
+ i = b; // expected-warning {{'b' is deprecated}}
+
+ return r; // expected-error {{'r' is unavailable}}
+}
diff --git a/clang/test/Sema/attr-unknown.c b/clang/test/Sema/attr-unknown.c
new file mode 100644
index 0000000..d1a831d
--- /dev/null
+++ b/clang/test/Sema/attr-unknown.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wattributes %s
+
+int x __attribute__((foobar)); // expected-warning {{unknown attribute 'foobar' ignored}}
+void z() __attribute__((bogusattr)); // expected-warning {{unknown attribute 'bogusattr' ignored}}
diff --git a/clang/test/Sema/attr-unused.c b/clang/test/Sema/attr-unused.c
new file mode 100644
index 0000000..07c65cb
--- /dev/null
+++ b/clang/test/Sema/attr-unused.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
+
+static void (*fp0)(void) __attribute__((unused));
+
+static void __attribute__((unused)) f0(void);
+
+// On K&R
+int f1() __attribute__((unused));
+
+int g0 __attribute__((unused));
+
+int f2() __attribute__((unused(1, 2))); // expected-error {{attribute takes no arguments}}
+
+struct Test0_unused {} __attribute__((unused));
+struct Test0_not_unused {};
+typedef int Int_unused __attribute__((unused));
+typedef int Int_not_unused;
+
+void test0() {
+ int x; // expected-warning {{unused variable}}
+
+ Int_not_unused i0; // expected-warning {{unused variable}}
+ Int_unused i1; // expected-warning {{'Int_unused' was marked unused but was used}}
+
+ struct Test0_not_unused s0; // expected-warning {{unused variable}}
+ struct Test0_unused s1; // expected-warning {{'Test0_unused' was marked unused but was used}}
+}
+
+int f3(int x) { // expected-warning{{unused parameter 'x'}}
+ return 0;
+}
+
+int f4(int x) {
+ return x;
+}
+
+int f5(int x __attribute__((__unused__))) {
+ return 0;
+}
+
+int f6(int x __attribute__((__unused__))) {
+ return x; // expected-warning{{'x' was marked unused but was used}}
+}
diff --git a/clang/test/Sema/attr-used.c b/clang/test/Sema/attr-used.c
new file mode 100644
index 0000000..0838816
--- /dev/null
+++ b/clang/test/Sema/attr-used.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+extern int l0 __attribute__((used)); // expected-warning {{used attribute ignored}}
+__private_extern__ int l1 __attribute__((used)); // expected-warning {{used attribute ignored}}
+
+struct __attribute__((used)) s { // expected-warning {{'used' attribute only applies to variables and functions}}
+ int x;
+};
+
+int a __attribute__((used));
+
+static void __attribute__((used)) f0(void) {
+}
+
+void f1() {
+ static int a __attribute__((used));
+ int b __attribute__((used)); // expected-warning {{used attribute ignored}}
+}
+
+
diff --git a/clang/test/Sema/attr-visibility.c b/clang/test/Sema/attr-visibility.c
new file mode 100644
index 0000000..5cf2695
--- /dev/null
+++ b/clang/test/Sema/attr-visibility.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+
+void test0() __attribute__((visibility("default")));
+void test1() __attribute__((visibility("hidden")));
+void test2() __attribute__((visibility("internal")));
+
+// rdar://problem/10753392
+void test3() __attribute__((visibility("protected"))); // expected-warning {{target does not support 'protected' visibility; using 'default'}}
+
diff --git a/clang/test/Sema/attr-weak.c b/clang/test/Sema/attr-weak.c
new file mode 100644
index 0000000..adedf12
--- /dev/null
+++ b/clang/test/Sema/attr-weak.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+extern int g0 __attribute__((weak));
+extern int g1 __attribute__((weak_import));
+int g2 __attribute__((weak));
+int g3 __attribute__((weak_import)); // expected-warning {{'weak_import' attribute cannot be specified on a definition}}
+int __attribute__((weak_import)) g4(void);
+void __attribute__((weak_import)) g5(void) {
+}
+
+struct __attribute__((weak)) s0 {}; // expected-warning {{'weak' attribute only applies to variables and functions}}
+struct __attribute__((weak_import)) s1 {}; // expected-warning {{'weak_import' attribute only applies to variables and functions}}
+
+static int x __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
+
+// rdar://9538608
+int C; // expected-note {{previous definition is here}}
+extern int C __attribute__((weak_import)); // expected-warning {{an already-declared variable is made a weak_import declaration}}
diff --git a/clang/test/Sema/bitfield-layout.c b/clang/test/Sema/bitfield-layout.c
new file mode 100644
index 0000000..2655fc7
--- /dev/null
+++ b/clang/test/Sema/bitfield-layout.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=i686-apple-darwin9
+
+#define CHECK_SIZE(kind, name, size) extern int name##1[sizeof(kind name) == size ? 1 : -1];
+#define CHECK_ALIGN(kind, name, size) extern int name##2[__alignof(kind name) == size ? 1 : -1];
+
+// Zero-width bit-fields
+struct a {char x; int : 0; char y;};
+CHECK_SIZE(struct, a, 5)
+CHECK_ALIGN(struct, a, 1)
+
+union b {char x; int : 0; char y;};
+CHECK_SIZE(union, b, 1)
+CHECK_ALIGN(union, b, 1)
+
+// Unnamed bit-field align
+struct c {char x; int : 20;};
+CHECK_SIZE(struct, c, 4)
+CHECK_ALIGN(struct, c, 1)
+
+union d {char x; int : 20;};
+CHECK_SIZE(union, d, 3)
+CHECK_ALIGN(union, d, 1)
+
+// Bit-field packing
+struct __attribute__((packed)) e {int x : 4, y : 30, z : 30;};
+CHECK_SIZE(struct, e, 8)
+CHECK_ALIGN(struct, e, 1)
+
+// Alignment on bit-fields
+struct f {__attribute((aligned(8))) int x : 30, y : 30, z : 30;};
+CHECK_SIZE(struct, f, 24)
+CHECK_ALIGN(struct, f, 8)
+
+// Large structure (overflows i32, in bits).
+struct s0 {
+ char a[0x32100000];
+ int x:30, y:30;
+};
+
+CHECK_SIZE(struct, s0, 0x32100008)
+CHECK_ALIGN(struct, s0, 4)
+
diff --git a/clang/test/Sema/bitfield-promote.c b/clang/test/Sema/bitfield-promote.c
new file mode 100644
index 0000000..4d14ad1
--- /dev/null
+++ b/clang/test/Sema/bitfield-promote.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct {unsigned x : 2;} x;
+__typeof__((x.x+=1)+1) y;
+__typeof__(x.x<<1) y;
+int y;
+
+
+struct { int x : 8; } x1;
+long long y1;
+__typeof__(((long long)x1.x + 1)) y1;
+
+
+// Check for extensions: variously sized unsigned bit-fields fitting
+// into a signed int promote to signed int.
+enum E { ec1, ec2, ec3 };
+struct S {
+ enum E e : 2;
+ unsigned short us : 4;
+ unsigned long long ul1 : 8;
+ unsigned long long ul2 : 50;
+} s;
+
+__typeof(s.e + s.e) x_e;
+int x_e;
+
+__typeof(s.us + s.us) x_us;
+int x_us;
+
+__typeof(s.ul1 + s.ul1) x_ul1;
+int x_ul1;
+
+__typeof(s.ul2 + s.ul2) x_ul2;
+unsigned long long x_ul2;
+
diff --git a/clang/test/Sema/bitfield.c b/clang/test/Sema/bitfield.c
new file mode 100644
index 0000000..a1ce894
--- /dev/null
+++ b/clang/test/Sema/bitfield.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+enum e0; // expected-note{{forward declaration of 'enum e0'}}
+
+struct a {
+ int a : -1; // expected-error{{bit-field 'a' has negative width}}
+
+ // rdar://6081627
+ int b : 33; // expected-error{{size of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}}
+
+ int c : (1 + 0.25); // expected-error{{expression is not an integer constant expression}}
+ int d : (int)(1 + 0.25);
+
+ // rdar://6138816
+ int e : 0; // expected-error {{bit-field 'e' has zero width}}
+
+ float xx : 4; // expected-error {{bit-field 'xx' has non-integral type}}
+
+ // PR3607
+ enum e0 f : 1; // expected-error {{field has incomplete type 'enum e0'}}
+
+ int g : (_Bool)1;
+
+ // PR4017
+ char : 10; // expected-error {{size of anonymous bit-field (10 bits) exceeds size of its type (8 bits)}}
+ unsigned : -2; // expected-error {{anonymous bit-field has negative width (-2)}}
+ float : 12; // expected-error {{anonymous bit-field has non-integral type 'float'}}
+};
+
+struct b {unsigned x : 2;} x;
+__typeof__(x.x+1) y;
+int y;
+
+struct {unsigned x : 2;} x2;
+__typeof__((x.x+=1)+1) y;
+__typeof__((0,x.x)+1) y;
+__typeof__(x.x<<1) y;
+int y;
+
+struct PR8025 {
+ double : 2; // expected-error{{anonymous bit-field has non-integral type 'double'}}
+};
diff --git a/clang/test/Sema/block-args.c b/clang/test/Sema/block-args.c
new file mode 100644
index 0000000..5ee383e
--- /dev/null
+++ b/clang/test/Sema/block-args.c
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks
+
+void take(void*);
+
+void test() {
+ take(^(int x){});
+ take(^(int x, int y){});
+ take(^(int x, int y){});
+ take(^(int x, // expected-note {{previous declaration is here}}
+ int x){}); // expected-error {{redefinition of parameter 'x'}}
+
+
+ take(^(int x) { return x+1; });
+
+ int (^CP)(int) = ^(int x) { return x*x; };
+ take(CP);
+
+ int arg;
+ ^{return 1;}();
+ ^{return 2;}(arg); // expected-error {{too many arguments to block call}}
+ ^(void){return 3;}(1); // expected-error {{too many arguments to block call}}
+ ^(){return 4;}(arg); // expected-error {{too many arguments to block call}}
+ ^(int x, ...){return 5;}(arg, arg); // Explicit varargs, ok.
+}
+
+int main(int argc, char** argv) {
+ ^(int argCount) {
+ argCount = 3;
+ }(argc);
+}
+
+// radar 7528255
+void f0() {
+ ^(int, double d, char) {}(1, 1.34, 'a'); // expected-error {{parameter name omitted}} \
+ // expected-error {{parameter name omitted}}
+}
+
+// rdar://problem/8962770
+void test4() {
+ int (^f)() = ^((x)) { }; // expected-error {{expected ')'}} expected-warning {{type specifier missing}} expected-note {{to match this}}
+}
+
+// rdar://problem/9170609
+void test5_helper(void (^)(int, int[*]));
+void test5(void) {
+ test5_helper(^(int n, int array[n]) {});
+}
diff --git a/clang/test/Sema/block-call.c b/clang/test/Sema/block-call.c
new file mode 100644
index 0000000..2aa1422
--- /dev/null
+++ b/clang/test/Sema/block-call.c
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks
+
+int (*FP)();
+int (^IFP) ();
+int (^II) (int);
+int main() {
+ int (*FPL) (int) = FP; // C doesn't consider this an error.
+
+ // For Blocks, the ASTContext::typesAreBlockCompatible() makes sure this is an error.
+ int (^PFR) (int) = IFP; // OK
+ PFR = II; // OK
+
+ int (^IFP) () = PFR; // OK
+
+
+ const int (^CIC) () = IFP; // OK - initializing 'const int (^)()' with an expression of type 'int (^)()'}}
+
+ const int (^CICC) () = CIC;
+
+
+ int * const (^IPCC) () = 0;
+
+ int * const (^IPCC1) () = IPCC;
+
+ int * (^IPCC2) () = IPCC; // expected-error {{incompatible block pointer types initializing 'int *(^)()' with an expression of type 'int *const (^)()'}}
+
+ int (^IPCC3) (const int) = PFR;
+
+ int (^IPCC4) (int, char (^CArg) (double));
+
+ int (^IPCC5) (int, char (^CArg) (double)) = IPCC4;
+
+ int (^IPCC6) (int, char (^CArg) (float)) = IPCC4; // expected-error {{incompatible block pointer types initializing 'int (^)(int, char (^)(float))' with an expression of type 'int (^)(int, char (^)(double))'}}
+
+ IPCC2 = 0;
+ IPCC2 = 1; // expected-error {{invalid block pointer conversion assigning to 'int *(^)()' from 'int'}}
+ int (^x)() = 0;
+ int (^y)() = 3; // expected-error {{invalid block pointer conversion initializing 'int (^)()' with an expression of type 'int'}}
+ int a = 1;
+ int (^z)() = a+4; // expected-error {{invalid block pointer conversion initializing 'int (^)()' with an expression of type 'int'}}
+}
+
+int blah() {
+ int (^IFP) (float);
+ char (^PCP)(double, double, char);
+
+ IFP(1.0);
+ IFP (1.0, 2.0); // expected-error {{too many arguments to block call}}
+
+ char ch = PCP(1.0, 2.0, 'a');
+ return PCP(1.0, 2.0); // expected-error {{too few arguments to block}}
+}
diff --git a/clang/test/Sema/block-explicit-noreturn-type.c b/clang/test/Sema/block-explicit-noreturn-type.c
new file mode 100644
index 0000000..12f4f4f
--- /dev/null
+++ b/clang/test/Sema/block-explicit-noreturn-type.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks
+// rdar://10466373
+
+typedef short SHORT;
+
+void f0() {
+ (void) ^{
+ if (1)
+ return (float)1.0;
+ else if (2)
+ return (double)2.0; // expected-error {{return type 'double' must match previous return type 'float' when block literal has}}
+ else
+ return (SHORT)3; // expected-error {{return type 'SHORT' (aka 'short') must match previous return type 'float' when}}
+ };
+}
diff --git a/clang/test/Sema/block-labels.c b/clang/test/Sema/block-labels.c
new file mode 100644
index 0000000..d1b60cc
--- /dev/null
+++ b/clang/test/Sema/block-labels.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -verify -fblocks -fsyntax-only
+
+void xx();
+
+int a() {
+ A:
+
+ if (1) xx();
+ return ^{
+ A: return 1;
+ }();
+}
+int b() {
+ A: return ^{int a; A:return 1;}();
+}
+
+int d() {
+ A: return ^{int a; A: a = ^{int a; A:return 1;}() + ^{int b; A:return 2;}(); return a; }();
+}
+
+int c() {
+ goto A; // expected-error {{use of undeclared label 'A'}}
+ return ^{
+ A:
+ return 1;
+ }();
+}
diff --git a/clang/test/Sema/block-literal.c b/clang/test/Sema/block-literal.c
new file mode 100644
index 0000000..c303b84
--- /dev/null
+++ b/clang/test/Sema/block-literal.c
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
+
+void I( void (^)(void));
+void (^noop)(void);
+
+void nothing();
+int printf(const char*, ...);
+
+typedef void (^T) (void);
+
+void takeblock(T);
+int takeintint(int (^C)(int)) { return C(4); }
+
+T somefunction() {
+ if (^{ })
+ nothing();
+
+ noop = ^{};
+
+ noop = ^{printf("\nClosure\n"); };
+
+ I(^{ });
+
+ return ^{printf("\nClosure\n"); };
+}
+void test2() {
+ int x = 4;
+
+ takeblock(^{ printf("%d\n", x); });
+
+ while (1) {
+ takeblock(^{
+ break; // expected-error {{'break' statement not in loop or switch statement}}
+ continue; // expected-error {{'continue' statement not in loop statement}}
+ while(1) break; // ok
+ goto foo; // expected-error {{use of undeclared label 'foo'}}
+ a: goto a; // ok
+ });
+ break;
+ }
+
+ foo:
+ takeblock(^{ x = 4; }); // expected-error {{variable is not assignable (missing __block type specifier)}}
+ __block y = 7; // expected-warning {{type specifier missing, defaults to 'int'}}
+ takeblock(^{ y = 8; });
+}
+
+
+void (^test3())(void) {
+ return ^{};
+}
+
+void test4() {
+ void (^noop)(void) = ^{};
+ void (*noop2)() = 0;
+}
+
+void myfunc(int (^block)(int)) {}
+
+void myfunc3(const int *x);
+
+void test5() {
+ int a;
+
+ myfunc(^(int abcd) {
+ myfunc3(&a);
+ return 1;
+ });
+}
+
+void *X;
+
+void test_arguments() {
+ int y;
+ int (^c)(char);
+ (1 ? c : 0)('x');
+ (1 ? 0 : c)('x');
+
+ (1 ? c : c)('x');
+}
+
+static int global_x = 10;
+void (^global_block)(void) = ^{ printf("global x is %d\n", global_x); };
+
+typedef void (^void_block_t)(void);
+
+static const void_block_t myBlock = ^{ };
+
+static const void_block_t myBlock2 = ^ void(void) { };
diff --git a/clang/test/Sema/block-misc.c b/clang/test/Sema/block-misc.c
new file mode 100644
index 0000000..2260458
--- /dev/null
+++ b/clang/test/Sema/block-misc.c
@@ -0,0 +1,228 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks
+void donotwarn();
+
+int (^IFP) ();
+int (^II) (int);
+int test1() {
+ int (^PFR) (int) = 0; // OK
+ PFR = II; // OK
+
+ if (PFR == II) // OK
+ donotwarn();
+
+ if (PFR == IFP) // OK
+ donotwarn();
+
+ if (PFR == (int (^) (int))IFP) // OK
+ donotwarn();
+
+ if (PFR == 0) // OK
+ donotwarn();
+
+ if (PFR) // OK
+ donotwarn();
+
+ if (!PFR) // OK
+ donotwarn();
+
+ return PFR != IFP; // OK
+}
+
+int test2(double (^S)()) {
+ double (^I)(int) = (void*) S;
+ (void*)I = (void *)S; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}}
+
+ void *pv = I;
+
+ pv = S;
+
+ I(1);
+
+ return (void*)I == (void *)S;
+}
+
+int^ x; // expected-error {{block pointer to non-function type is invalid}}
+int^^ x1; // expected-error {{block pointer to non-function type is invalid}} expected-error {{block pointer to non-function type is invalid}}
+
+void test3() {
+ char *^ y; // expected-error {{block pointer to non-function type is invalid}}
+}
+
+
+
+enum {NSBIRLazilyAllocated = 0};
+
+int test4(int argc) { // rdar://6251437
+ ^{
+ switch (argc) {
+ case NSBIRLazilyAllocated: // is an integer constant expression.
+ default:
+ break;
+ }
+ }();
+ return 0;
+}
+
+
+void bar(void*);
+// rdar://6257721 - reference to static/global is byref by default.
+static int test5g;
+void test5() {
+ bar(^{ test5g = 1; });
+}
+
+// rdar://6405429 - __func__ in a block refers to the containing function name.
+const char*test6() {
+ return ^{
+ return __func__;
+ } ();
+}
+
+// radr://6732116 - block comparisons
+void (^test7a)();
+int test7(void (^p)()) {
+ return test7a == p;
+}
+
+
+void test8() {
+somelabel:
+ ^{ goto somelabel; }(); // expected-error {{use of undeclared label 'somelabel'}}
+}
+
+void test9() {
+ goto somelabel; // expected-error {{use of undeclared label 'somelabel'}}
+ ^{ somelabel: ; }();
+}
+
+void test10(int i) {
+ switch (i) {
+ case 41: ;
+ ^{ case 42: ; }(); // expected-error {{'case' statement not in switch statement}}
+ }
+}
+
+void test11(int i) {
+ switch (i) {
+ case 41: ;
+ ^{ break; }(); // expected-error {{'break' statement not in loop or switch statement}}
+ }
+
+ for (; i < 100; ++i)
+ ^{ break; }(); // expected-error {{'break' statement not in loop or switch statement}}
+}
+
+void (^test12f)(void);
+void test12() {
+ test12f = ^test12f; // expected-error {{type name requires a specifier or qualifier}} expected-error {{expected expression}}
+}
+
+// rdar://6808730
+void *test13 = ^{
+ int X = 32;
+
+ void *P = ^{
+ return X+4; // References outer block's "X", so outer block is constant.
+ };
+};
+
+void test14() {
+ int X = 32;
+ static void *P = ^{ // expected-error {{initializer element is not a compile-time constant}}
+
+ void *Q = ^{
+ // References test14's "X": outer block is non constant.
+ return X+4;
+ };
+ };
+}
+
+enum { LESS };
+
+void foo(long (^comp)()) { // expected-note{{passing argument to parameter 'comp' here}}
+}
+
+void (^test15f)(void);
+void test15() {
+ foo(^{ return LESS; }); // expected-error {{incompatible block pointer types passing 'int (^)(void)' to parameter of type 'long (^)()'}}
+}
+
+__block int test16i; // expected-error {{__block attribute not allowed, only allowed on local variables}}
+
+void test16(__block int i) { // expected-error {{__block attribute not allowed, only allowed on local variables}}
+ int size = 5;
+ extern __block double extern_var; // expected-error {{__block attribute not allowed, only allowed on local variables}}
+ static __block char * pch; // expected-error {{__block attribute not allowed, only allowed on local variables}}
+ __block int a[size]; // expected-error {{__block attribute not allowed on declaration with a variably modified type}}
+ __block int (*ap)[size]; // expected-error {{__block attribute not allowed on declaration with a variably modified type}}
+}
+
+void f();
+
+void test17() {
+ void (^bp)(int);
+ void (*rp)(int);
+ void (^bp1)();
+ void *vp = bp;
+
+ f(1 ? bp : vp);
+ f(1 ? vp : bp);
+ f(1 ? bp : bp1);
+ (void)(bp > rp); // expected-error {{invalid operands}}
+ (void)(bp > 0); // expected-error {{invalid operands}}
+ (void)(bp > bp); // expected-error {{invalid operands}}
+ (void)(bp > vp); // expected-error {{invalid operands}}
+ f(1 ? bp : rp); // expected-error {{incompatible operand types ('void (^)(int)' and 'void (*)(int)')}}
+ (void)(bp == 1); // expected-error {{invalid operands to binary expression}}
+ (void)(bp == 0);
+ (void)(1 == bp); // expected-error {{invalid operands to binary expression}}
+ (void)(0 == bp);
+ (void)(bp < 1); // expected-error {{invalid operands to binary expression}}
+ (void)(bp < 0); // expected-error {{invalid operands to binary expression}}
+ (void)(1 < bp); // expected-error {{invalid operands to binary expression}}
+ (void)(0 < bp); // expected-error {{invalid operands to binary expression}}
+}
+
+void test18() {
+ void (^const blockA)(void) = ^{ };
+ blockA = ^{ }; // expected-error {{read-only variable is not assignable}}
+}
+
+// rdar://7072507
+int test19() {
+ goto L0; // expected-error {{goto into protected scope}}
+
+ __block int x; // expected-note {{jump bypasses setup of __block variable}}
+L0:
+ x = 0;
+ ^(){ ++x; }();
+ return x;
+}
+
+// radr://7438948
+void test20() {
+ int n = 7;
+ int vla[n]; // expected-note {{declared here}}
+ int (*vm)[n] = 0; // expected-note {{declared here}}
+ vla[1] = 4341;
+ ^{
+ (void)vla[1]; // expected-error {{cannot refer to declaration with a variably modified type inside block}}
+ (void)(vm+1); // expected-error {{cannot refer to declaration with a variably modified type inside block}}
+ }();
+}
+
+// radr://7438948
+void test21() {
+ int a[7]; // expected-note {{declared here}}
+ __block int b[10]; // expected-note {{declared here}}
+ a[1] = 1;
+ ^{
+ (void)a[1]; // expected-error {{cannot refer to declaration with an array type inside block}}
+ (void)b[1]; // expected-error {{cannot refer to declaration with an array type inside block}}
+ }();
+}
+
+// rdar ://8218839
+const char * (^func)(void) = ^{ return __func__; };
+const char * (^function)(void) = ^{ return __FUNCTION__; };
+const char * (^pretty)(void) = ^{ return __PRETTY_FUNCTION__; };
diff --git a/clang/test/Sema/block-printf-attribute-1.c b/clang/test/Sema/block-printf-attribute-1.c
new file mode 100644
index 0000000..dd678a5
--- /dev/null
+++ b/clang/test/Sema/block-printf-attribute-1.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks
+
+#include <stdarg.h>
+
+int main() {
+ void (^b) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 1, 3))) = // expected-error {{format argument not a string type}}
+ ^ __attribute__ ((__format__ (__printf__, 1, 3))) (int arg, const char * format, ...) {}; // expected-error {{format argument not a string type}}
+
+ void (^z) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 2, 3))) = ^ __attribute__ ((__format__ (__printf__, 2, 3))) (int arg, const char * format, ...) {};
+
+ z(1, "%s", 1); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+ z(1, "%s", "HELLO"); // no-warning
+}
+
+void multi_attr(va_list ap, int *x, long *y) {
+ // Handle block with multiple format attributes.
+ void (^vprintf_scanf) (const char *, va_list, const char *, ...) __attribute__((__format__(__printf__, 1, 0))) __attribute__((__format__(__scanf__, 3, 4))) =
+ ^ __attribute__((__format__(__printf__, 1, 0))) __attribute__((__format__(__scanf__, 3, 4))) (const char *str, va_list args, const char *fmt, ...) {};
+
+ vprintf_scanf("%", ap, "%d"); // expected-warning {{incomplete format specifier}}, expected-warning {{more '%' conversions than data arguments}}
+}
diff --git a/clang/test/Sema/block-return-1.c b/clang/test/Sema/block-return-1.c
new file mode 100644
index 0000000..631a2d4
--- /dev/null
+++ b/clang/test/Sema/block-return-1.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
+
+int j;
+void foo() {
+ ^ (void) { if (j) return 1; }(); // expected-error {{control may reach end of non-void block}}
+}
diff --git a/clang/test/Sema/block-return-2.c b/clang/test/Sema/block-return-2.c
new file mode 100644
index 0000000..d5fbc6f
--- /dev/null
+++ b/clang/test/Sema/block-return-2.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
+
+void foo() {
+ ^ (void) __attribute__((noreturn)) { }(); // expected-error {{block declared 'noreturn' should not return}}
+}
diff --git a/clang/test/Sema/block-return-3.c b/clang/test/Sema/block-return-3.c
new file mode 100644
index 0000000..cd942a7
--- /dev/null
+++ b/clang/test/Sema/block-return-3.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
+
+void foo() {
+ ^ int (void) { }(); // expected-error {{control reaches end of non-void block}}
+}
diff --git a/clang/test/Sema/block-return.c b/clang/test/Sema/block-return.c
new file mode 100644
index 0000000..6967955
--- /dev/null
+++ b/clang/test/Sema/block-return.c
@@ -0,0 +1,136 @@
+// RUN: %clang_cc1 -pedantic -fsyntax-only %s -verify -fblocks
+
+typedef void (^CL)(void);
+
+CL foo() {
+ short y;
+ short (^add1)(void) = ^{ return y+1; }; // expected-error {{incompatible block pointer types initializing 'short (^)(void)' with an expression of type 'int (^)(void)'}}
+
+ CL X = ^{
+ if (2)
+ return;
+ return 1; // expected-error {{return type 'int' must match previous return type 'void' when block literal has unspecified explicit return type}}
+ };
+
+ int (^Y) (void) = ^{
+ if (3)
+ return 1;
+ else
+ return; // expected-error {{return type 'void' must match previous return type 'int' when block literal has unspecified explicit return type}}
+ };
+
+ char *(^Z)(void) = ^{
+ if (3)
+ return "";
+ else
+ return (char*)0;
+ };
+
+ double (^A)(void) = ^ { // expected-error {{incompatible block pointer types initializing 'double (^)(void)' with an expression of type 'float (^)(void)'}}
+ if (1)
+ return (float)1.0;
+ else
+ if (2)
+ return (double)2.0; // expected-error {{return type 'double' must match previous return type 'float' when block literal has unspecified explicit return type}}
+ return 1; // expected-error {{return type 'int' must match previous return type 'float' when block literal has unspecified explicit return type}}
+ };
+ char *(^B)(void) = ^{
+ if (3)
+ return "";
+ else
+ return 2; // expected-error {{return type 'int' must match previous return type 'char *' when block literal has unspecified explicit return type}}
+ };
+
+ return ^{ return 1; }; // expected-error {{incompatible block pointer types returning 'int (^)(void)' from a function with result type 'CL' (aka 'void (^)(void)')}}
+}
+
+typedef int (^CL2)(void);
+
+CL2 foo2() {
+ return ^{ return 1; };
+}
+
+typedef unsigned int * uintptr_t;
+typedef char Boolean;
+typedef int CFBasicHash;
+
+#define INVOKE_CALLBACK2(P, A, B) (P)(A, B)
+
+typedef struct {
+ Boolean (^isEqual)(const CFBasicHash *, uintptr_t stack_value_or_key1, uintptr_t stack_value_or_key2, Boolean is_key);
+} CFBasicHashCallbacks;
+
+int foo3() {
+ CFBasicHashCallbacks cb;
+
+ Boolean (*value_equal)(uintptr_t, uintptr_t) = 0;
+
+ cb.isEqual = ^(const CFBasicHash *table, uintptr_t stack_value_or_key1, uintptr_t stack_value_or_key2, Boolean is_key) {
+ return (Boolean)(uintptr_t)INVOKE_CALLBACK2(value_equal, (uintptr_t)stack_value_or_key1, (uintptr_t)stack_value_or_key2);
+ };
+}
+
+static int funk(char *s) {
+ if (^{} == ((void*)0))
+ return 1;
+ else
+ return 0;
+}
+void next();
+void foo4() {
+ int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(const char *)' with an expression of type 'int (^)(char *)'}}
+ int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (*)(const char *)' with an expression of type 'int (char *)'}}
+
+ int (^nested)(char *s) = ^(char *str) { void (^nest)(void) = ^(void) { printf("%s\n", str); }; next(); return 1; }; // expected-warning{{implicitly declaring library function 'printf' with type 'int (const char *, ...)'}} \
+ // expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
+}
+
+typedef void (^bptr)(void);
+
+bptr foo5(int j) {
+ __block int i;
+ if (j)
+ return ^{ ^{ i=0; }(); }; // expected-error {{returning block that lives on the local stack}}
+ return ^{ i=0; }; // expected-error {{returning block that lives on the local stack}}
+ return (^{ i=0; }); // expected-error {{returning block that lives on the local stack}}
+ return (void*)(^{ i=0; }); // expected-error {{returning block that lives on the local stack}}
+}
+
+int (*funcptr3[5])(long);
+int sz8 = sizeof(^int (*[5])(long) {return funcptr3;}); // expected-error {{block cannot return array type}} expected-warning {{incompatible pointer to integer conversion}}
+int sz9 = sizeof(^int(*())()[3]{ }); // expected-error {{function cannot return array type}}
+
+void foo6() {
+ int (^b)(int) __attribute__((noreturn));
+ b = ^ (int i) __attribute__((noreturn)) { return 1; }; // expected-error {{block declared 'noreturn' should not return}}
+ b(1);
+ int (^c)(void) __attribute__((noreturn)) = ^ __attribute__((noreturn)) { return 100; }; // expected-error {{block declared 'noreturn' should not return}}
+}
+
+
+void foo7()
+{
+ const int (^BB) (void) = ^{ const int i = 1; return i; }; // OK - initializing 'const int (^)(void)' with an expression of type 'int (^)(void)'
+
+ const int (^CC) (void) = ^const int{ const int i = 1; return i; };
+
+
+ int i;
+ int (^FF) (void) = ^{ return i; }; // OK
+ int (^EE) (void) = ^{ return i+1; }; // OK
+
+ __block int j;
+ int (^JJ) (void) = ^{ return j; }; // OK
+ int (^KK) (void) = ^{ return j+1; }; // OK
+
+ __block const int k;
+ const int cint = 100;
+
+ int (^MM) (void) = ^{ return k; };
+ int (^NN) (void) = ^{ return cint; };
+}
+
+// rdar://11069896
+void (^blk)(void) = ^{
+ return (void)0; // expected-warning {{void block literal should not return void expression}}
+};
diff --git a/clang/test/Sema/block-sentinel-attribute.c b/clang/test/Sema/block-sentinel-attribute.c
new file mode 100644
index 0000000..daf0a95
--- /dev/null
+++ b/clang/test/Sema/block-sentinel-attribute.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s
+
+void (^e) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (1,1)));
+
+int main() {
+ void (^bbad) (int arg, const char * format) __attribute__ ((__sentinel__)) ; // expected-warning {{'sentinel' attribute only supported for variadic blocks}}
+ bbad = ^void (int arg, const char * format) __attribute__ ((__sentinel__)) {} ; // expected-warning {{'sentinel' attribute only supported for variadic blocks}}
+ void (^b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)) = // expected-note {{block has been explicitly marked sentinel here}}
+ ^ __attribute__ ((__sentinel__)) (int arg, const char * format, ...) {};
+ void (^z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))) = ^ __attribute__ ((__sentinel__ (2))) (int arg, const char * format, ...) {}; // expected-note {{block has been explicitly marked sentinel here}}
+
+
+ void (^y) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (5))) = ^ __attribute__ ((__sentinel__ (5))) (int arg, const char * format, ...) {}; // expected-note {{block has been explicitly marked sentinel here}}
+
+ b(1, "%s", (void*)0); // OK
+ b(1, "%s", 0); // expected-warning {{missing sentinel in block call}}
+ z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in block call}}
+ z(1, "%s", (void*)0, 1, 0); // OK
+
+ y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in block call}}
+
+ y(1, "%s", (void*)0,3,4,5,6,7); // OK
+
+}
+
diff --git a/clang/test/Sema/block-storageclass.c b/clang/test/Sema/block-storageclass.c
new file mode 100644
index 0000000..9bfbfbd
--- /dev/null
+++ b/clang/test/Sema/block-storageclass.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks
+
+int printf(const char *, ...);
+void _Block_byref_release(void*src){}
+
+int main() {
+ __block int X = 1234;
+ __block const char * message = "HELLO";
+
+ X = X - 1234;
+
+ X += 1;
+
+ printf ("%s(%d)\n", message, X);
+ X -= 1;
+
+ return X;
+}
diff --git a/clang/test/Sema/builtin-object-size.c b/clang/test/Sema/builtin-object-size.c
new file mode 100644
index 0000000..0abc27b
--- /dev/null
+++ b/clang/test/Sema/builtin-object-size.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin9 -verify %s
+
+int a[10];
+
+int f0() {
+ return __builtin_object_size(&a); // expected-error {{too few arguments to function}}
+}
+int f1() {
+ return (__builtin_object_size(&a, 0) +
+ __builtin_object_size(&a, 1) +
+ __builtin_object_size(&a, 2) +
+ __builtin_object_size(&a, 3));
+}
+int f2() {
+ return __builtin_object_size(&a, -1); // expected-error {{argument should be a value from 0 to 3}}
+}
+int f3() {
+ return __builtin_object_size(&a, 4); // expected-error {{argument should be a value from 0 to 3}}
+}
+
+
+// rdar://6252231 - cannot call vsnprintf with va_list on x86_64
+void f4(const char *fmt, ...) {
+ __builtin_va_list args;
+ __builtin___vsnprintf_chk (0, 42, 0, 11, fmt, args);
+}
+
diff --git a/clang/test/Sema/builtin-prefetch.c b/clang/test/Sema/builtin-prefetch.c
new file mode 100644
index 0000000..c5fa792
--- /dev/null
+++ b/clang/test/Sema/builtin-prefetch.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void foo() {
+ int a;
+ __builtin_prefetch(&a);
+ __builtin_prefetch(&a, 1);
+ __builtin_prefetch(&a, 1, 2);
+ __builtin_prefetch(&a, 1, 9, 3); // expected-error{{too many arguments to function}}
+ __builtin_prefetch(&a, "hello", 2); // expected-error{{argument to '__builtin_prefetch' must be a constant integer}}
+ __builtin_prefetch(&a, a, 2); // expected-error{{argument to '__builtin_prefetch' must be a constant integer}}
+ __builtin_prefetch(&a, 2); // expected-error{{argument should be a value from 0 to 1}}
+ __builtin_prefetch(&a, 0, 4); // expected-error{{argument should be a value from 0 to 3}}
+ __builtin_prefetch(&a, -1, 4); // expected-error{{argument should be a value from 0 to 1}}
+}
diff --git a/clang/test/Sema/builtin-stackaddress.c b/clang/test/Sema/builtin-stackaddress.c
new file mode 100644
index 0000000..5f63bb1
--- /dev/null
+++ b/clang/test/Sema/builtin-stackaddress.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+void* a(unsigned x) {
+return __builtin_return_address(0);
+}
+
+void b(unsigned x) {
+return __builtin_return_address(x); // expected-error{{argument to '__builtin_return_address' must be a constant integer}}
+}
+
+void* c(unsigned x) {
+return __builtin_frame_address(0);
+}
+
+void d(unsigned x) {
+return __builtin_frame_address(x); // expected-error{{argument to '__builtin_frame_address' must be a constant integer}}
+}
diff --git a/clang/test/Sema/builtin-unary-fp.c b/clang/test/Sema/builtin-unary-fp.c
new file mode 100644
index 0000000..57568db
--- /dev/null
+++ b/clang/test/Sema/builtin-unary-fp.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
+void check(int);
+void a() {
+ check(__builtin_isfinite(1.0f));
+ check(__builtin_isinf(1.0));
+ check(__builtin_isinf_sign(1.0L));
+ check(__builtin_isnan(1.0f));
+ check(__builtin_isnormal(1.0f));
+ check(__builtin_isfinite(1)); // expected-error{{requires argument of floating point type}}
+ check(__builtin_isinf()); // expected-error{{too few arguments}}
+ check(__builtin_isnan(1,2)); // expected-error{{too many arguments}}
+ check(__builtin_fpclassify(0, 0, 0, 0, 0, 1.0));
+ check(__builtin_fpclassify(0, 0, 0, 0, 0, 1)); // expected-error{{requires argument of floating point type}}
+ check(__builtin_fpclassify(0, 0, 0, 0, 1)); // expected-error{{too few arguments}}
+ check(__builtin_fpclassify(0, 0, 0, 0, 0, 1, 0)); // expected-error{{too many arguments}}
+}
diff --git a/clang/test/Sema/builtin_objc_msgSend.c b/clang/test/Sema/builtin_objc_msgSend.c
new file mode 100644
index 0000000..357a5bc
--- /dev/null
+++ b/clang/test/Sema/builtin_objc_msgSend.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// rdar://8632525
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+
+typedef struct objc_selector *SEL;
+extern id objc_msgSend(id self, SEL op, ...);
+
diff --git a/clang/test/Sema/builtins-arm.c b/clang/test/Sema/builtins-arm.c
new file mode 100644
index 0000000..4077240
--- /dev/null
+++ b/clang/test/Sema/builtins-arm.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify -DTEST0 %s
+// RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify -DTEST1 %s
+
+#ifdef TEST0
+void __clear_cache(char*, char*);
+#endif
+
+#ifdef TEST1
+void __clear_cache(void*, void*);
+#endif
+
+// va_list on ARM is void*.
+void test2() {
+ __builtin_va_list ptr = "x";
+ *ptr = '0'; // expected-error {{incomplete type 'void' is not assignable}}
+}
diff --git a/clang/test/Sema/builtins-decl.c b/clang/test/Sema/builtins-decl.c
new file mode 100644
index 0000000..19bdb84
--- /dev/null
+++ b/clang/test/Sema/builtins-decl.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=i686-mingw32
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-mingw32
+
+// mingw-w64's intrin.h has decls below.
+// we should accept them.
+extern unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char);
+extern unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short);
+extern unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int);
diff --git a/clang/test/Sema/builtins.c b/clang/test/Sema/builtins.c
new file mode 100644
index 0000000..b8b0367
--- /dev/null
+++ b/clang/test/Sema/builtins.c
@@ -0,0 +1,164 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wno-string-plus-int -triple=i686-apple-darwin9
+// This test needs to set the target because it uses __builtin_ia32_vec_ext_v4si
+
+int test1(float a, int b) {
+ return __builtin_isless(a, b);
+}
+int test2(int a, int b) {
+ return __builtin_islessequal(a, b); // expected-error {{floating point type}}
+}
+
+int test3(double a, float b) {
+ return __builtin_isless(a, b);
+}
+int test4(int* a, double b) {
+ return __builtin_islessequal(a, b); // expected-error {{floating point type}}
+}
+
+int test5(float a, long double b) {
+ return __builtin_isless(a, b, b); // expected-error {{too many arguments}}
+}
+int test6(float a, long double b) {
+ return __builtin_islessequal(a); // expected-error {{too few arguments}}
+}
+
+
+#define CFSTR __builtin___CFStringMakeConstantString
+void test7() {
+ const void *X;
+ X = CFSTR("\242"); // expected-warning {{input conversion stopped}}
+ X = CFSTR("\0"); // no-warning
+ X = CFSTR(242); // expected-error {{CFString literal is not a string constant}} expected-warning {{incompatible integer to pointer conversion}}
+ X = CFSTR("foo", "bar"); // expected-error {{too many arguments to function call}}
+}
+
+
+// atomics.
+
+void test9(short v) {
+ unsigned i, old;
+
+ old = __sync_fetch_and_add(); // expected-error {{too few arguments to function call}}
+ old = __sync_fetch_and_add(&old); // expected-error {{too few arguments to function call}}
+ old = __sync_fetch_and_add((unsigned*)0, 42i); // expected-warning {{imaginary constants are an extension}}
+
+ // PR7600: Pointers are implicitly casted to integers and back.
+ void *old_ptr = __sync_val_compare_and_swap((void**)0, 0, 0);
+
+ // Ensure the return type is correct even when implicit casts are stripped
+ // away. This triggers an assertion while checking the comparison otherwise.
+ if (__sync_fetch_and_add(&old, 1) == 1) {
+ }
+}
+
+
+// rdar://7236819
+void test10(void) __attribute__((noreturn));
+
+void test10(void) {
+ __asm__("int3");
+ __builtin_unreachable();
+
+ // No warning about falling off the end of a noreturn function.
+}
+
+void test11(int X) {
+ switch (X) {
+ case __builtin_eh_return_data_regno(0): // constant foldable.
+ break;
+ }
+
+ __builtin_eh_return_data_regno(X); // expected-error {{argument to '__builtin_eh_return_data_regno' must be a constant integer}}
+}
+
+// PR5062
+void test12(void) __attribute__((__noreturn__));
+void test12(void) {
+ __builtin_trap(); // no warning because trap is noreturn.
+}
+
+void test_unknown_builtin(int a, int b) {
+ __builtin_isles(a, b); // expected-error{{use of unknown builtin}} \
+ // expected-note{{did you mean '__builtin_isless'?}}
+}
+
+int test13() {
+ __builtin_eh_return(0, 0); // no warning, eh_return never returns.
+}
+
+// <rdar://problem/8228293>
+void test14() {
+ int old;
+ old = __sync_fetch_and_min((volatile int *)&old, 1);
+}
+
+// <rdar://problem/8336581>
+void test15(const char *s) {
+ __builtin_printf("string is %s\n", s);
+}
+
+// PR7885
+int test16() {
+ return __builtin_constant_p() + // expected-error{{too few arguments}}
+ __builtin_constant_p(1, 2); // expected-error {{too many arguments}}
+}
+
+const int test17_n = 0;
+const char test17_c[] = {1, 2, 3, 0};
+const char test17_d[] = {1, 2, 3, 4};
+typedef int __attribute__((vector_size(16))) IntVector;
+struct Aggregate { int n; char c; };
+enum Enum { EnumValue1, EnumValue2 };
+
+typedef __typeof(sizeof(int)) size_t;
+size_t strlen(const char *);
+
+void test17() {
+#define ASSERT(...) { int arr[(__VA_ARGS__) ? 1 : -1]; }
+#define T(...) ASSERT(__builtin_constant_p(__VA_ARGS__))
+#define F(...) ASSERT(!__builtin_constant_p(__VA_ARGS__))
+
+ // __builtin_constant_p returns 1 if the argument folds to:
+ // - an arithmetic constant with value which is known at compile time
+ T(test17_n);
+ T(&test17_c[3] - test17_c);
+ T(3i + 5); // expected-warning {{imaginary constant}}
+ T(4.2 * 7.6);
+ T(EnumValue1);
+ T((enum Enum)(int)EnumValue2);
+
+ // - the address of the first character of a string literal, losslessly cast
+ // to any type
+ T("string literal");
+ T((double*)"string literal");
+ T("string literal" + 0);
+ T((long)"string literal");
+
+ // ... and otherwise returns 0.
+ F("string literal" + 1);
+ F(&test17_n);
+ F(test17_c);
+ F(&test17_c);
+ F(&test17_d);
+ F((struct Aggregate){0, 1});
+ F((IntVector){0, 1, 2, 3});
+
+ // Ensure that a technique used in glibc is handled correctly.
+#define OPT(...) (__builtin_constant_p(__VA_ARGS__) && strlen(__VA_ARGS__) < 4)
+ // FIXME: These are incorrectly treated as ICEs because strlen is treated as
+ // a builtin.
+ ASSERT(OPT("abc"));
+ ASSERT(!OPT("abcd"));
+ // In these cases, the strlen is non-constant, but the __builtin_constant_p
+ // is 0: the array size is not an ICE but is foldable.
+ ASSERT(!OPT(test17_c)); // expected-warning {{folded}}
+ ASSERT(!OPT(&test17_c[0])); // expected-warning {{folded}}
+ ASSERT(!OPT((char*)test17_c)); // expected-warning {{folded}}
+ ASSERT(!OPT(test17_d)); // expected-warning {{folded}}
+ ASSERT(!OPT(&test17_d[0])); // expected-warning {{folded}}
+ ASSERT(!OPT((char*)test17_d)); // expected-warning {{folded}}
+
+#undef OPT
+#undef T
+#undef F
+}
diff --git a/clang/test/Sema/c11-typedef-redef.c b/clang/test/Sema/c11-typedef-redef.c
new file mode 100644
index 0000000..b899f15
--- /dev/null
+++ b/clang/test/Sema/c11-typedef-redef.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c11 %s -verify
+
+typedef int type;
+typedef type type;
+typedef int type;
+
+void f(int N) {
+ typedef int type2;
+ typedef type type2;
+ typedef int type2;
+
+ typedef int vla[N]; // expected-note{{previous definition is here}}
+ typedef int vla[N]; // expected-error{{redefinition of typedef for variably-modified type 'int [N]'}}
+
+ typedef int vla2[N];
+ typedef vla2 vla3; // expected-note{{previous definition is here}}
+ typedef vla2 vla3; // expected-error{{redefinition of typedef for variably-modified type 'vla2' (aka 'int [N]')}}
+}
diff --git a/clang/test/Sema/c89-2.c b/clang/test/Sema/c89-2.c
new file mode 100644
index 0000000..f6f6bd9
--- /dev/null
+++ b/clang/test/Sema/c89-2.c
@@ -0,0 +1,5 @@
+/* RUN: %clang_cc1 %s -std=c89 -pedantic-errors -verify
+ */
+
+#if 1LL /* expected-error {{long long}} */
+#endif
diff --git a/clang/test/Sema/c89.c b/clang/test/Sema/c89.c
new file mode 100644
index 0000000..110d7e1
--- /dev/null
+++ b/clang/test/Sema/c89.c
@@ -0,0 +1,112 @@
+/* RUN: %clang_cc1 %s -std=c89 -pedantic -fsyntax-only -verify -Wimplicit-function-declaration
+ */
+void test1() {
+ {
+ int i;
+ i = i + 1;
+ int j; /* expected-warning {{mixing declarations and code}} */
+ }
+ {
+ __extension__ int i;
+ i = i + 1;
+ int j; /* expected-warning {{mixing declarations and code}} */
+ }
+ {
+ int i;
+ i = i + 1;
+ __extension__ int j; /* expected-warning {{mixing declarations and code}} */
+ }
+}
+
+long long test2; /* expected-warning {{extension}} */
+
+
+void test3(int i) {
+ int A[i]; /* expected-warning {{variable length array}} */
+}
+
+int test4 = 0LL; /* expected-warning {{long long}} */
+
+/* PR1999 */
+void test5(register);
+
+/* PR2041 */
+int *restrict;
+int *__restrict; /* expected-error {{expected identifier}} */
+
+
+/* Implicit int, always ok */
+test6() { return 0; }
+
+/* PR2012 */
+test7; /* expected-warning {{declaration specifier missing, defaulting to 'int'}} */
+
+void test8(int, x); /* expected-warning {{declaration specifier missing, defaulting to 'int'}} */
+
+typedef int sometype;
+int a(sometype, y) {return 0;} /* expected-warning {{declaration specifier missing, defaulting to 'int'}} \
+ expected-error {{parameter name omitted}}*/
+
+
+
+
+void bar (void *);
+void f11 (z) /* expected-error {{may not have 'void' type}} */
+void z;
+{ bar (&z); }
+
+typedef void T;
+void foo(T); /* typedef for void is allowed */
+
+void foo(void) {}
+
+/* PR2759 */
+void test10 (int x[*]); /* expected-warning {{variable length arrays are a C99 feature}} */
+void test11 (int x[static 4]); /* expected-warning {{static array size is a C99 feature}} */
+
+void test12 (int x[const 4]) { /* expected-warning {{qualifier in array size is a C99 feature}} */
+ int Y[x[1]]; /* expected-warning {{variable length arrays are a C99 feature}} */
+}
+
+/* PR4074 */
+struct test13 {
+ int X[23];
+} test13a();
+
+void test13b() {
+ int a = test13a().X[1]; /* expected-warning {{ISO C90 does not allow subscripting non-lvalue array}} */
+ int b = 1[test13a().X]; /* expected-warning {{ISO C90 does not allow subscripting non-lvalue array}} */
+}
+
+/* Make sure we allow *test14 as a "function designator" */
+int test14() { return (&*test14)(); }
+
+int test15[5] = { [2] = 1 }; /* expected-warning {{designated initializers are a C99 feature}} */
+
+extern int printf(__const char *__restrict __format, ...);
+
+/* Warn, but don't suggest typo correction. */
+void test16() {
+ printg("Hello, world!\n"); /* expected-warning {{implicit declaration of function 'printg'}} */
+}
+
+struct x { int x,y[]; }; /* expected-warning {{Flexible array members are a C99-specific feature}} */
+
+/* Duplicated type-qualifiers aren't allowed by C90 */
+const const int c_i; /* expected-warning {{duplicate 'const' declaration specifier}} */
+typedef volatile int vol_int;
+volatile vol_int volvol_i; /* expected-warning {{duplicate 'volatile' declaration specifier}} */
+typedef volatile vol_int volvol_int; /* expected-warning {{duplicate 'volatile' declaration specifier}} */
+const int * const c;
+
+typedef const int CI;
+
+const CI mine1[5][5]; /* expected-warning {{duplicate 'const' declaration specifier}} */
+
+typedef CI array_of_CI[5];
+const array_of_CI mine2; /* expected-warning {{duplicate 'const' declaration specifier}} */
+
+typedef CI *array_of_pointer_to_CI[5];
+const array_of_pointer_to_CI mine3;
+
+void main() {} /* expected-error {{'main' must return 'int'}} */
diff --git a/clang/test/Sema/callingconv.c b/clang/test/Sema/callingconv.c
new file mode 100644
index 0000000..25669f0
--- /dev/null
+++ b/clang/test/Sema/callingconv.c
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+void __attribute__((fastcall)) foo(float *a) {
+}
+
+void __attribute__((stdcall)) bar(float *a) {
+}
+
+void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{attribute takes no arguments}}
+}
+
+void __attribute__((fastcall)) test0() { // expected-error {{function with no prototype cannot use fastcall calling convention}}
+}
+
+void __attribute__((fastcall)) test1(void) {
+}
+
+void __attribute__((fastcall)) test2(int a, ...) { // expected-error {{variadic function cannot use fastcall calling convention}}
+}
+
+void __attribute__((cdecl)) ctest0() {}
+
+void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{attribute takes no arguments}}
+
+void (__attribute__((fastcall)) *pfoo)(float*) = foo;
+
+void (__attribute__((stdcall)) *pbar)(float*) = bar;
+
+void (__attribute__((cdecl)) *ptest1)(void) = test1; // expected-warning {{incompatible pointer types}}
+
+void (*pctest0)() = ctest0;
+
+void ctest2() {}
+void (__attribute__((cdecl)) *pctest2)() = ctest2;
+
+typedef void (__attribute__((fastcall)) *Handler) (float *);
+Handler H = foo;
+
+// PR6361
+void ctest3();
+void __attribute__((cdecl)) ctest3() {}
+
+// PR6408
+typedef __attribute__((stdcall)) void (*PROC)();
+PROC __attribute__((cdecl)) ctest4(const char *x) {}
+
diff --git a/clang/test/Sema/carbon.c b/clang/test/Sema/carbon.c
new file mode 100644
index 0000000..045d72c
--- /dev/null
+++ b/clang/test/Sema/carbon.c
@@ -0,0 +1,5 @@
+// RUN: %clang -fsyntax-only %s -print-stats
+#ifdef __APPLE__
+#include <Carbon/Carbon.h>
+#endif
+
diff --git a/clang/test/Sema/cast-incomplete.c b/clang/test/Sema/cast-incomplete.c
new file mode 100644
index 0000000..dd10e00
--- /dev/null
+++ b/clang/test/Sema/cast-incomplete.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+// PR5692
+
+enum x; // expected-note {{forward declaration}}
+extern struct y a; // expected-note {{forward declaration}}
+extern union z b; // expected-note 2 {{forward declaration}}
+
+void foo() {
+ (enum x)1; // expected-error {{cast to incomplete type}}
+ (struct y)a; // expected-error {{cast to incomplete type}}
+ (union z)b; // expected-error {{cast to incomplete type}}
+ (union z)1; // expected-error {{cast to incomplete type}}
+}
+
diff --git a/clang/test/Sema/cast-to-union.c b/clang/test/Sema/cast-to-union.c
new file mode 100644
index 0000000..c32964d
--- /dev/null
+++ b/clang/test/Sema/cast-to-union.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+union u { int i; unsigned : 3; };
+void f(union u);
+
+void test(int x) {
+ f((union u)x); // expected-warning {{C99 forbids casts to union type}}
+ f((union u)&x); // expected-error {{cast to union type from type 'int *' not present in union}}
+ f((union u)2U); // expected-error {{cast to union type from type 'unsigned int' not present in union}}
+}
+
+union u w = (union u)2; // expected-warning {{C99 forbids casts to union type}}
+union u ww = (union u)1.0; // expected-error{{cast to union type from type 'double' not present in union}}
+union u x = 7; // expected-error{{initializing 'union u' with an expression of incompatible type 'int'}}
+int i;
+union u zz = (union u)i; // expected-error{{initializer element is not a compile-time constant}} expected-warning {{C99 forbids casts to union type}}
+
+struct s {int a, b;};
+struct s y = { 1, 5 };
+struct s z = (struct s){ 1, 5 };
diff --git a/clang/test/Sema/cast.c b/clang/test/Sema/cast.c
new file mode 100644
index 0000000..71c44b4
--- /dev/null
+++ b/clang/test/Sema/cast.c
@@ -0,0 +1,159 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+typedef struct { unsigned long bits[(((1) + (64) - 1) / (64))]; } cpumask_t;
+cpumask_t x;
+void foo() {
+ (void)x;
+}
+void bar() {
+ char* a;
+ double b;
+ b = (double)a; // expected-error {{pointer cannot be cast to type}}
+ a = (char*)b; // expected-error {{cannot be cast to a pointer type}}
+}
+
+long bar1(long *next) {
+ return (long)(*next)++;
+}
+
+typedef _Bool Bool;
+typedef int Int;
+typedef long Long;
+typedef float Float;
+typedef double Double;
+typedef _Complex int CInt;
+typedef _Complex long CLong;
+typedef _Complex float CFloat;
+typedef _Complex double CDouble;
+typedef void *VoidPtr;
+typedef char *CharPtr;
+
+void testBool(Bool v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+ (void) (VoidPtr) v;
+ (void) (CharPtr) v;
+}
+
+void testInt(Int v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+ (void) (VoidPtr) v;
+ (void) (CharPtr) v;
+}
+
+void testLong(Long v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+ (void) (VoidPtr) v;
+ (void) (CharPtr) v;
+}
+
+void testFloat(Float v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+}
+
+void testDouble(Double v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+}
+
+void testCI(CInt v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+}
+
+void testCLong(CLong v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+}
+
+void testCFloat(CFloat v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+}
+
+void testCDouble(CDouble v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (Float) v;
+ (void) (Double) v;
+ (void) (CInt) v;
+ (void) (CLong) v;
+ (void) (CFloat) v;
+ (void) (CDouble) v;
+}
+
+void testVoidPtr(VoidPtr v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (VoidPtr) v;
+ (void) (CharPtr) v;
+}
+
+void testCharPtr(CharPtr v) {
+ (void) (Bool) v;
+ (void) (Int) v;
+ (void) (Long) v;
+ (void) (VoidPtr) v;
+ (void) (CharPtr) v;
+}
diff --git a/clang/test/Sema/check-increment.c b/clang/test/Sema/check-increment.c
new file mode 100644
index 0000000..070ea74
--- /dev/null
+++ b/clang/test/Sema/check-increment.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int printf(const char *, ...);
+typedef int *pint;
+int main() {
+ int a[5] = {0};
+ pint p = a;
+ p++;
+ printf("%d\n", *p);
+}
diff --git a/clang/test/Sema/compare.c b/clang/test/Sema/compare.c
new file mode 100644
index 0000000..03aebb3
--- /dev/null
+++ b/clang/test/Sema/compare.c
@@ -0,0 +1,335 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify -Wsign-compare %s -Wno-unreachable-code
+
+int test(char *C) { // nothing here should warn.
+ return C != ((void*)0);
+ return C != (void*)0;
+ return C != 0;
+ return C != 1; // expected-warning {{comparison between pointer and integer ('char *' and 'int')}}
+}
+
+int ints(long a, unsigned long b) {
+ enum EnumA {A};
+ enum EnumB {B};
+ enum EnumC {C = 0x10000};
+ return
+ // (a,b)
+ (a == (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
+ (a == (unsigned int) b) +
+ (a == (unsigned short) b) +
+ (a == (unsigned char) b) +
+ ((long) a == b) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a == b) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a == b) + // expected-warning {{comparison of integers of different signs}}
+ ((signed char) a == b) + // expected-warning {{comparison of integers of different signs}}
+ ((long) a == (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a == (unsigned int) b) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a == (unsigned short) b) +
+ ((signed char) a == (unsigned char) b) +
+ (a < (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
+ (a < (unsigned int) b) +
+ (a < (unsigned short) b) +
+ (a < (unsigned char) b) +
+ ((long) a < b) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a < b) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < b) + // expected-warning {{comparison of integers of different signs}}
+ ((signed char) a < b) + // expected-warning {{comparison of integers of different signs}}
+ ((long) a < (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a < (unsigned int) b) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < (unsigned short) b) +
+ ((signed char) a < (unsigned char) b) +
+
+ // (A,b)
+ (A == (unsigned long) b) +
+ (A == (unsigned int) b) +
+ (A == (unsigned short) b) +
+ (A == (unsigned char) b) +
+ ((long) A == b) +
+ ((int) A == b) +
+ ((short) A == b) +
+ ((signed char) A == b) +
+ ((long) A == (unsigned long) b) +
+ ((int) A == (unsigned int) b) +
+ ((short) A == (unsigned short) b) +
+ ((signed char) A == (unsigned char) b) +
+ (A < (unsigned long) b) +
+ (A < (unsigned int) b) +
+ (A < (unsigned short) b) +
+ (A < (unsigned char) b) +
+ ((long) A < b) +
+ ((int) A < b) +
+ ((short) A < b) +
+ ((signed char) A < b) +
+ ((long) A < (unsigned long) b) +
+ ((int) A < (unsigned int) b) +
+ ((short) A < (unsigned short) b) +
+ ((signed char) A < (unsigned char) b) +
+
+ // (a,B)
+ (a == (unsigned long) B) +
+ (a == (unsigned int) B) +
+ (a == (unsigned short) B) +
+ (a == (unsigned char) B) +
+ ((long) a == B) +
+ ((int) a == B) +
+ ((short) a == B) +
+ ((signed char) a == B) +
+ ((long) a == (unsigned long) B) +
+ ((int) a == (unsigned int) B) +
+ ((short) a == (unsigned short) B) +
+ ((signed char) a == (unsigned char) B) +
+ (a < (unsigned long) B) + // expected-warning {{comparison of integers of different signs}}
+ (a < (unsigned int) B) +
+ (a < (unsigned short) B) +
+ (a < (unsigned char) B) +
+ ((long) a < B) +
+ ((int) a < B) +
+ ((short) a < B) +
+ ((signed char) a < B) +
+ ((long) a < (unsigned long) B) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a < (unsigned int) B) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < (unsigned short) B) +
+ ((signed char) a < (unsigned char) B) +
+
+ // (C,b)
+ (C == (unsigned long) b) +
+ (C == (unsigned int) b) +
+ (C == (unsigned short) b) +
+ (C == (unsigned char) b) +
+ ((long) C == b) +
+ ((int) C == b) +
+ ((short) C == b) +
+ ((signed char) C == b) +
+ ((long) C == (unsigned long) b) +
+ ((int) C == (unsigned int) b) +
+ ((short) C == (unsigned short) b) +
+ ((signed char) C == (unsigned char) b) +
+ (C < (unsigned long) b) +
+ (C < (unsigned int) b) +
+ (C < (unsigned short) b) +
+ (C < (unsigned char) b) +
+ ((long) C < b) +
+ ((int) C < b) +
+ ((short) C < b) +
+ ((signed char) C < b) +
+ ((long) C < (unsigned long) b) +
+ ((int) C < (unsigned int) b) +
+ ((short) C < (unsigned short) b) +
+ ((signed char) C < (unsigned char) b) +
+
+ // (a,C)
+ (a == (unsigned long) C) +
+ (a == (unsigned int) C) +
+ (a == (unsigned short) C) +
+ (a == (unsigned char) C) +
+ ((long) a == C) +
+ ((int) a == C) +
+ ((short) a == C) +
+ ((signed char) a == C) +
+ ((long) a == (unsigned long) C) +
+ ((int) a == (unsigned int) C) +
+ ((short) a == (unsigned short) C) +
+ ((signed char) a == (unsigned char) C) +
+ (a < (unsigned long) C) + // expected-warning {{comparison of integers of different signs}}
+ (a < (unsigned int) C) +
+ (a < (unsigned short) C) +
+ (a < (unsigned char) C) +
+ ((long) a < C) +
+ ((int) a < C) +
+ ((short) a < C) +
+ ((signed char) a < C) +
+ ((long) a < (unsigned long) C) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a < (unsigned int) C) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < (unsigned short) C) +
+ ((signed char) a < (unsigned char) C) +
+
+ // (0x80000,b)
+ (0x80000 == (unsigned long) b) +
+ (0x80000 == (unsigned int) b) +
+ (0x80000 == (unsigned short) b) +
+ (0x80000 == (unsigned char) b) +
+ ((long) 0x80000 == b) +
+ ((int) 0x80000 == b) +
+ ((short) 0x80000 == b) +
+ ((signed char) 0x80000 == b) +
+ ((long) 0x80000 == (unsigned long) b) +
+ ((int) 0x80000 == (unsigned int) b) +
+ ((short) 0x80000 == (unsigned short) b) +
+ ((signed char) 0x80000 == (unsigned char) b) +
+ (0x80000 < (unsigned long) b) +
+ (0x80000 < (unsigned int) b) +
+ (0x80000 < (unsigned short) b) +
+ (0x80000 < (unsigned char) b) +
+ ((long) 0x80000 < b) +
+ ((int) 0x80000 < b) +
+ ((short) 0x80000 < b) +
+ ((signed char) 0x80000 < b) +
+ ((long) 0x80000 < (unsigned long) b) +
+ ((int) 0x80000 < (unsigned int) b) +
+ ((short) 0x80000 < (unsigned short) b) +
+ ((signed char) 0x80000 < (unsigned char) b) +
+
+ // (a,0x80000)
+ (a == (unsigned long) 0x80000) +
+ (a == (unsigned int) 0x80000) +
+ (a == (unsigned short) 0x80000) +
+ (a == (unsigned char) 0x80000) +
+ ((long) a == 0x80000) +
+ ((int) a == 0x80000) +
+ ((short) a == 0x80000) +
+ ((signed char) a == 0x80000) +
+ ((long) a == (unsigned long) 0x80000) +
+ ((int) a == (unsigned int) 0x80000) +
+ ((short) a == (unsigned short) 0x80000) +
+ ((signed char) a == (unsigned char) 0x80000) +
+ (a < (unsigned long) 0x80000) + // expected-warning {{comparison of integers of different signs}}
+ (a < (unsigned int) 0x80000) +
+ (a < (unsigned short) 0x80000) +
+ (a < (unsigned char) 0x80000) +
+ ((long) a < 0x80000) +
+ ((int) a < 0x80000) +
+ ((short) a < 0x80000) +
+ ((signed char) a < 0x80000) +
+ ((long) a < (unsigned long) 0x80000) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a < (unsigned int) 0x80000) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < (unsigned short) 0x80000) +
+ ((signed char) a < (unsigned char) 0x80000) +
+
+ // We should be able to avoid warning about this.
+ (b != (a < 4 ? 1 : 2)) +
+
+ 10
+ ;
+}
+
+int equal(char *a, const char *b) {
+ return a == b;
+}
+
+int arrays(char (*a)[5], char(*b)[10], char(*c)[5]) {
+ int d = (a == c);
+ return a == b; // expected-warning {{comparison of distinct pointer types}}
+}
+
+int pointers(int *a) {
+ return a > 0; // expected-warning {{ordered comparison between pointer and zero ('int *' and 'int') is an extension}}
+ return a > 42; // expected-warning {{ordered comparison between pointer and integer ('int *' and 'int')}}
+ return a > (void *)0; // expected-warning {{comparison of distinct pointer types}}
+}
+
+int function_pointers(int (*a)(int), int (*b)(int), void (*c)(int)) {
+ return a > b; // expected-warning {{ordered comparison of function pointers}}
+ return function_pointers > function_pointers; // expected-warning {{self-comparison always evaluates to false}} expected-warning{{ordered comparison of function pointers}}
+ return a > c; // expected-warning {{comparison of distinct pointer types}}
+ return a == (void *) 0;
+ return a == (void *) 1; // expected-warning {{equality comparison between function pointer and void pointer}}
+}
+
+int void_pointers(void* foo) {
+ return foo == (void*) 0;
+ return foo == (void*) 1;
+}
+
+
+int test1(int i) {
+ enum en { zero };
+ return i > zero;
+}
+
+// PR5937
+int test2(int i32) {
+ struct foo {
+ unsigned int u8 : 8;
+ unsigned long long u31 : 31;
+ unsigned long long u32 : 32;
+ unsigned long long u63 : 63;
+ unsigned long long u64 : 64;
+ } *x;
+
+ if (x->u8 == i32) { // comparison in int32, exact
+ return 0;
+ } else if (x->u31 == i32) { // comparison in int32, exact
+ return 1;
+ } else if (x->u32 == i32) { // expected-warning {{comparison of integers of different signs}}
+ return 2;
+ } else if (x->u63 == i32) { // comparison in uint64, exact because ==
+ return 3;
+ } else if (x->u64 == i32) { // expected-warning {{comparison of integers of different signs}}
+ return 4;
+ } else {
+ return 5;
+ }
+}
+
+// PR5887
+void test3() {
+ unsigned short x, y;
+ unsigned int z;
+ if ((x > y ? x : y) > z)
+ (void) 0;
+}
+
+// PR5961
+extern char *ptr4;
+void test4() {
+ long value;
+ if (value < (unsigned long) &ptr4) // expected-warning {{comparison of integers of different signs}}
+ return;
+}
+
+// PR4807
+int test5(unsigned int x) {
+ return (x < 0) // expected-warning {{comparison of unsigned expression < 0 is always false}}
+ && (0 > x) // expected-warning {{comparison of 0 > unsigned expression is always false}}
+ && (x >= 0) // expected-warning {{comparison of unsigned expression >= 0 is always true}}
+ && (0 <= x); // expected-warning {{comparison of 0 <= unsigned expression is always true}}
+}
+
+int test6(unsigned i, unsigned power) {
+ unsigned x = (i < (1 << power) ? i : 0);
+ return x != 3 ? 1 << power : i;
+}
+
+// <rdar://problem/8414119> enum >= (enum)0 comparison should not generate any warnings
+enum rdar8414119_Vals { X, Y, Z };
+#define ZERO 0
+#define CHECK(x) (x >= X)
+void rdar8414119_foo(enum rdar8414119_Vals v) {
+ if (CHECK(v)) // no-warning
+ return;
+ if (v >= X) // no-warning
+ return;
+}
+int rdar8414119_bar(unsigned x) {
+ return x >= ZERO; // no-warning
+}
+#undef ZERO
+#undef CHECK
+
+int rdar8511238() {
+ enum A { A_foo, A_bar };
+ enum A a;
+ if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
+ return 0;
+ return 20;
+}
+
+// PR10336
+int test9(int sv, unsigned uv, long slv) {
+ return sv == (uv ^= slv); // expected-warning {{comparison of integers of different signs: 'int' and 'unsigned int'}}
+}
+
+void test10(void) {
+ int si;
+ unsigned int ui;
+ long sl;
+
+ _Bool b;
+ b = (si == (ui = sl)); // expected-warning {{comparison of integers of different signs: 'int' and 'unsigned int'}}
+ b = (si == (ui = sl&15));
+}
+
+// PR11572
+struct test11S { unsigned x : 30; };
+int test11(unsigned y, struct test11S *p) {
+ return y > (p->x >> 24); // no-warning
+}
diff --git a/clang/test/Sema/complex-imag.c b/clang/test/Sema/complex-imag.c
new file mode 100644
index 0000000..1c6fb15
--- /dev/null
+++ b/clang/test/Sema/complex-imag.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -verify %s
+
+void f1() {
+ int a = 1;
+ int b = __imag a;
+ int *c = &__real a;
+ int *d = &__imag a; // expected-error {{must be an lvalue}}
+}
+
+void f2() {
+ _Complex int a = 1;
+ int b = __imag a;
+ int *c = &__real a;
+ int *d = &__imag a;
+}
+
+void f3() {
+ double a = 1;
+ double b = __imag a;
+ double *c = &__real a;
+ double *d = &__imag a; // expected-error {{must be an lvalue}}
+}
+
+void f4() {
+ _Complex double a = 1;
+ double b = __imag a;
+ double *c = &__real a;
+ double *d = &__imag a;
+}
diff --git a/clang/test/Sema/complex-init-list.c b/clang/test/Sema/complex-init-list.c
new file mode 100644
index 0000000..bfc6899
--- /dev/null
+++ b/clang/test/Sema/complex-init-list.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
+
+// This file tests the clang extension which allows initializing the components
+// of a complex number individually using an initialization list. Basically,
+// if you have an explicit init list for a complex number that contains two
+// initializers, this extension kicks in to turn it into component-wise
+// initialization.
+//
+// This extension is useful because there isn't any way to accurately build
+// a complex number at the moment besides setting the components with
+// __real__ and __imag__, which is inconvenient and not usable for constants.
+// (Of course, there are other extensions we could implement that would
+// allow this, like some sort of __builtin_build_complex.)
+//
+// FIXME: It would be a good idea to have a warnings for implicit
+// real->complex and complex->real conversions; as-is, it's way too easy
+// to get implicit conversions when they are not intended.
+
+// Basic testcase
+_Complex float valid1 = { 1.0f, 2.0f }; // expected-warning {{specifying real and imaginary components is an extension}}
+
+
+// Struct for nesting tests
+struct teststruct { _Complex float x; };
+
+
+// Random other valid stuff
+_Complex int valid2 = { 1, 2 }; // expected-warning {{complex integer}} expected-warning {{specifying real and imaginary components is an extension}}
+struct teststruct valid3 = { { 1.0f, 2.0f} }; // expected-warning {{specifying real and imaginary components is an extension}}
+_Complex float valid4[2] = { {1.0f, 1.0f}, {1.0f, 1.0f} }; // expected-warning 2 {{specifying real and imaginary components is an extension}}
+// FIXME: We need some sort of warning for valid5
+_Complex float valid5 = {1.0f, 1.0fi}; // expected-warning {{imaginary constants}} expected-warning {{specifying real and imaginary components is an extension}}
+
+
+// Random invalid stuff
+struct teststruct invalid1 = { 1, 2 }; // expected-warning {{excess elements}}
+_Complex float invalid2 = { 1, 2, 3 }; // expected-warning {{excess elements}}
+_Complex float invalid3 = {}; // expected-error {{scalar initializer cannot be empty}} expected-warning {{GNU empty initializer}}
+
+
+// Check incomplete array sizing
+_Complex float sizetest1[] = { {1.0f, 1.0f}, {1.0f, 1.0f} }; // expected-warning 2 {{specifying real and imaginary components is an extension}}
+_Complex float sizecheck1[(sizeof(sizetest1) == sizeof(*sizetest1)*2) ? 1 : -1];
+_Complex float sizetest2[] = { 1.0f, 1.0f, {1.0f, 1.0f} }; // expected-warning {{specifying real and imaginary components is an extension}}
+_Complex float sizecheck2[(sizeof(sizetest2) == sizeof(*sizetest2)*3) ? 1 : -1];
+
+// Constant-folding with init list.
+_Complex float x = 2 + (_Complex float) { 1, 2 }; // expected-warning {{specifying real and imaginary components is an extension}}
diff --git a/clang/test/Sema/complex-int.c b/clang/test/Sema/complex-int.c
new file mode 100644
index 0000000..32249b3
--- /dev/null
+++ b/clang/test/Sema/complex-int.c
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+void a() {
+__complex__ int arr;
+__complex__ short brr;
+__complex__ unsigned xx;
+__complex__ signed yy;
+__complex__ int result;
+int ii;
+int aa = 1 + 1.0iF;
+
+result = arr*ii;
+result = ii*brr;
+
+result = arr*brr;
+result = xx*yy;
+
+switch (arr) { // expected-error{{statement requires expression of integer type ('_Complex int' invalid)}}
+ case brr: ; // expected-error{{expression is not an integer constant expression}}
+ case xx: ; // expected-error{{expression is not an integer constant expression}}
+}
+}
+
+void Tester() {
+__complex short a1;
+__complex int a2;
+__complex float a3;
+__complex double a4;
+short a5;
+int a6;
+float a7;
+double a8;
+#define TestPair(m,n) int x##m##n = a##m+a##n;
+#define TestPairs(m) TestPair(m,1) TestPair(m,2) \
+ TestPair(m,3) TestPair(m,4) \
+ TestPair(m,5) TestPair(m,6) \
+ TestPair(m,7) TestPair(m,8)
+TestPairs(1); TestPairs(2);
+TestPairs(3); TestPairs(4);
+TestPairs(5); TestPairs(6);
+TestPairs(7); TestPairs(8);
+}
+
+// rdar://6097730
+void test3(_Complex int *x) {
+ *x = ~*x;
+}
+
+void test4(_Complex float *x) {
+ *x = ~*x;
+}
+
+void test5(_Complex int *x) {
+ (*x)++;
+}
+
+int i1[(2+3i)*(5+7i) == 29i-11 ? 1 : -1];
+int i2[(29i-11)/(5+7i) == 2+3i ? 1 : -1];
+int i3[-(2+3i) == +(-3i-2) ? 1 : -1];
+int i4[~(2+3i) == 2-3i ? 1 : -1];
+int i5[(3i == -(-3i) ? ((void)3, 1i - 1) : 0) == 1i - 1 ? 1 : -1];
+
+int f1[(2.0+3.0i)*(5.0+7.0i) == 29.0i-11.0 ? 1 : -1];
+int f2[(29.0i-11.0)/(5.0+7.0i) == 2.0+3.0i ? 1 : -1];
+int f3[-(2.0+3.0i) == +(-3.0i-2.0) ? 1 : -1];
+int f4[~(2.0+3.0i) == 2.0-3.0i ? 1 : -1];
+int f5[(3.0i == -(-3.0i) ? ((void)3.0, __extension__ (1.0i - 1.0)) : 0) == 1.0i - 1.0 ? 1 : -1];
diff --git a/clang/test/Sema/complex-promotion.c b/clang/test/Sema/complex-promotion.c
new file mode 100644
index 0000000..23c3b68
--- /dev/null
+++ b/clang/test/Sema/complex-promotion.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+float a;
+
+int b[__builtin_classify_type(a + 1i) == 9 ? 1 : -1];
+int c[__builtin_classify_type(1i + a) == 9 ? 1 : -1];
+
+double d;
+__typeof__ (d + 1i) e;
+
+int f[sizeof(e) == 2 * sizeof(double) ? 1 : -1];
+
+int g;
+int h[__builtin_classify_type(g + 1.0i) == 9 ? 1 : -1];
+int i[__builtin_classify_type(1.0i + a) == 9 ? 1 : -1];
diff --git a/clang/test/Sema/compound-literal.c b/clang/test/Sema/compound-literal.c
new file mode 100644
index 0000000..beec6ca
--- /dev/null
+++ b/clang/test/Sema/compound-literal.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+struct foo { int a, b; };
+
+static struct foo t = (struct foo){0,0};
+static struct foo t1 = __builtin_choose_expr(0, (struct foo){0,0}, (struct foo){0,0});
+static struct foo t2 = {0,0};
+static struct foo t3 = t2; // -expected-error {{initializer element is not a compile-time constant}}
+static int *p = (int []){2,4};
+static int x = (int){1};
+
+static int *p2 = (int []){2,x}; // -expected-error {{initializer element is not a compile-time constant}}
+static long *p3 = (long []){2,"x"}; // -expected-warning {{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char [2]'}}
+
+typedef struct { } cache_t; // -expected-warning{{empty struct is a GNU extension}}
+static cache_t clo_I1_cache = ((cache_t) { } ); // -expected-warning{{use of GNU empty initializer extension}}
+
+typedef struct Test {int a;int b;} Test;
+static Test* ll = &(Test) {0,0};
+
+extern void fooFunc(struct foo *pfoo);
+
+int main(int argc, char **argv) {
+ int *l = (int []){x, *p, *p2};
+ fooFunc(&(struct foo){ 1, 2 });
+}
+
+struct Incomplete; // expected-note{{forward declaration of 'struct Incomplete'}}
+struct Incomplete* I1 = &(struct Incomplete){1, 2, 3}; // -expected-error {{variable has incomplete type}}
+void IncompleteFunc(unsigned x) {
+ struct Incomplete* I2 = (struct foo[x]){1, 2, 3}; // -expected-error {{variable-sized object may not be initialized}}
+ (void){1,2,3}; // -expected-error {{variable has incomplete type}}
+ (void(void)) { 0 }; // -expected-error{{illegal initializer type 'void (void)'}}
+}
+
+// PR6080
+int array[(sizeof(int[3]) == sizeof( (int[]) {0,1,2} )) ? 1 : -1];
diff --git a/clang/test/Sema/conditional-expr.c b/clang/test/Sema/conditional-expr.c
new file mode 100644
index 0000000..184ac4a
--- /dev/null
+++ b/clang/test/Sema/conditional-expr.c
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wsign-conversion %s
+void foo() {
+ *(0 ? (double *)0 : (void *)0) = 0;
+ // FIXME: GCC doesn't consider the the following two statements to be errors.
+ *(0 ? (double *)0 : (void *)(int *)0) = 0; // expected-error {{incomplete type 'void' is not assignable}}
+ *(0 ? (double *)0 : (void *)(double *)0) = 0; // expected-error {{incomplete type 'void' is not assignable}}
+ *(0 ? (double *)0 : (int *)(void *)0) = 0; // expected-error {{incomplete type 'void' is not assignable}} expected-warning {{pointer type mismatch ('double *' and 'int *')}}
+ *(0 ? (double *)0 : (double *)(void *)0) = 0;
+ *((void *) 0) = 0; // expected-error {{incomplete type 'void' is not assignable}}
+ double *dp;
+ int *ip;
+ void *vp;
+
+ dp = vp;
+ vp = dp;
+ ip = dp; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double *'}}
+ dp = ip; // expected-warning {{incompatible pointer types assigning to 'double *' from 'int *'}}
+ dp = 0 ? (double *)0 : (void *)0;
+ vp = 0 ? (double *)0 : (void *)0;
+ ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double *'}}
+
+ const int *cip;
+ vp = (0 ? vp : cip); // expected-warning {{discards qualifiers}}
+ vp = (0 ? cip : vp); // expected-warning {{discards qualifiers}}
+
+ int i = 2;
+ int (*pf)[2];
+ int (*pv)[i];
+ pf = (i ? pf : pv);
+
+ enum {xxx,yyy,zzz} e, *ee;
+ short x;
+ ee = ee ? &x : ee ? &i : &e; // expected-warning {{pointer type mismatch}}
+
+ typedef void *asdf;
+ *(0 ? (asdf) 0 : &x) = 10;
+
+ unsigned long test0 = 5;
+ test0 = test0 ? (long) test0 : test0; // expected-warning {{operand of ? changes signedness: 'long' to 'unsigned long'}}
+ test0 = test0 ? (int) test0 : test0; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
+ test0 = test0 ? (short) test0 : test0; // expected-warning {{operand of ? changes signedness: 'short' to 'unsigned long'}}
+ test0 = test0 ? test0 : (long) test0; // expected-warning {{operand of ? changes signedness: 'long' to 'unsigned long'}}
+ test0 = test0 ? test0 : (int) test0; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
+ test0 = test0 ? test0 : (short) test0; // expected-warning {{operand of ? changes signedness: 'short' to 'unsigned long'}}
+ test0 = test0 ? test0 : (long) 10;
+ test0 = test0 ? test0 : (int) 10;
+ test0 = test0 ? test0 : (short) 10;
+ test0 = test0 ? (long) 10 : test0;
+ test0 = test0 ? (int) 10 : test0;
+ test0 = test0 ? (short) 10 : test0;
+
+ int test1;
+ enum Enum { EVal };
+ test0 = test0 ? EVal : test0;
+ test1 = test0 ? EVal : (int) test0;
+ test0 = test0 ?
+ (unsigned) EVal
+ : (int) test0; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
+
+ test0 = test0 ? EVal : test1; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
+ test0 = test0 ? test1 : EVal; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
+
+ const int *const_int;
+ int *nonconst_int;
+ *(test0 ? const_int : nonconst_int) = 42; // expected-error {{read-only variable is not assignable}}
+ *(test0 ? nonconst_int : const_int) = 42; // expected-error {{read-only variable is not assignable}}
+
+ // The composite type here should be "int (*)[12]", fine for the sizeof
+ int (*incomplete)[];
+ int (*complete)[12];
+ sizeof(*(test0 ? incomplete : complete)); // expected-warning {{expression result unused}}
+ sizeof(*(test0 ? complete : incomplete)); // expected-warning {{expression result unused}}
+
+ int __attribute__((address_space(2))) *adr2;
+ int __attribute__((address_space(3))) *adr3;
+ test0 ? adr2 : adr3; // expected-warning {{pointer type mismatch}} expected-warning {{expression result unused}}
+
+ // Make sure address-space mask ends up in the result type
+ (test0 ? (test0 ? adr2 : adr2) : nonconst_int); // expected-warning {{pointer type mismatch}} expected-warning {{expression result unused}}
+}
+
+int Postgresql() {
+ char x;
+ return ((((&x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional expressions with only one void side}}
+}
+
+#define nil ((void*) 0)
+
+extern int f1(void);
+
+int f0(int a) {
+ // GCC considers this a warning.
+ return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-warning {{incompatible pointer to integer conversion returning 'void *' from a function with result type 'int'}}
+}
+
+int f2(int x) {
+ // We can suppress this because the immediate context wants an int.
+ return (x != 0) ? 0U : x;
+}
+
+#define NULL (void*)0
+
+void PR9236() {
+ struct A {int i;} A1;
+ (void)(1 ? A1 : NULL); // expected-error{{non-pointer operand type 'struct A' incompatible with NULL}}
+ (void)(1 ? NULL : A1); // expected-error{{non-pointer operand type 'struct A' incompatible with NULL}}
+ (void)(1 ? 0 : A1); // expected-error{{incompatible operand types}}
+ (void)(1 ? (void*)0 : A1); // expected-error{{incompatible operand types}}
+ (void)(1 ? A1: (void*)0); // expected-error{{incompatible operand types}}
+ (void)(1 ? A1 : (NULL)); // expected-error{{non-pointer operand type 'struct A' incompatible with NULL}}
+}
+
diff --git a/clang/test/Sema/conditional.c b/clang/test/Sema/conditional.c
new file mode 100644
index 0000000..3d7bcca
--- /dev/null
+++ b/clang/test/Sema/conditional.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+const char* test1 = 1 ? "i" : 1 == 1 ? "v" : "r";
+
+void _efree(void *ptr);
+void free(void *ptr);
+
+int _php_stream_free1() {
+ return (1 ? free(0) : _efree(0)); // expected-error {{returning 'void' from a function with incompatible result type 'int'}}
+}
+
+int _php_stream_free2() {
+ return (1 ? _efree(0) : free(0)); // expected-error {{returning 'void' from a function with incompatible result type 'int'}}
+}
diff --git a/clang/test/Sema/const-eval-64.c b/clang/test/Sema/const-eval-64.c
new file mode 100644
index 0000000..5727a93
--- /dev/null
+++ b/clang/test/Sema/const-eval-64.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux %s
+
+#define EVAL_EXPR(testno, expr) int test##testno = sizeof(struct{char qq[expr];});
+
+// <rdar://problem/10962435>
+EVAL_EXPR(1, ((char*)-1LL) + 1 == 0 ? 1 : -1)
+EVAL_EXPR(2, ((char*)-1LL) + 1 < (char*) -1 ? 1 : -1)
diff --git a/clang/test/Sema/const-eval.c b/clang/test/Sema/const-eval.c
new file mode 100644
index 0000000..bc8b227
--- /dev/null
+++ b/clang/test/Sema/const-eval.c
@@ -0,0 +1,133 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux %s
+
+#define EVAL_EXPR(testno, expr) int test##testno = sizeof(struct{char qq[expr];});
+int x;
+EVAL_EXPR(1, (_Bool)&x)
+EVAL_EXPR(2, (int)(1.0+(double)4))
+EVAL_EXPR(3, (int)(1.0+(float)4.0))
+EVAL_EXPR(4, (_Bool)(1 ? (void*)&x : 0))
+EVAL_EXPR(5, (_Bool)(int[]){0})
+struct y {int x,y;};
+EVAL_EXPR(6, (int)(1+(struct y*)0))
+EVAL_EXPR(7, (int)&((struct y*)0)->y)
+EVAL_EXPR(8, (_Bool)"asdf")
+EVAL_EXPR(9, !!&x)
+EVAL_EXPR(10, ((void)1, 12))
+void g0(void);
+EVAL_EXPR(11, (g0(), 12)) // expected-error {{must have a constant size}}
+EVAL_EXPR(12, 1.0&&2.0)
+EVAL_EXPR(13, x || 3.0) // expected-error {{must have a constant size}}
+
+unsigned int l_19 = 1;
+EVAL_EXPR(14, (1 ^ l_19) && 1); // expected-error {{fields must have a constant size}}
+
+void f()
+{
+ int a;
+ EVAL_EXPR(15, (_Bool)&a);
+}
+
+// FIXME: Turn into EVAL_EXPR test once we have more folding.
+_Complex float g16 = (1.0f + 1.0fi);
+
+// ?: in constant expressions.
+int g17[(3?:1) - 2];
+
+EVAL_EXPR(18, ((int)((void*)10 + 10)) == 20 ? 1 : -1);
+
+struct s {
+ int a[(int)-1.0f]; // expected-error {{'a' declared as an array with a negative size}}
+};
+
+EVAL_EXPR(19, ((int)&*(char*)10 == 10 ? 1 : -1));
+
+EVAL_EXPR(20, __builtin_constant_p(*((int*) 10)));
+
+EVAL_EXPR(21, (__imag__ 2i) == 2 ? 1 : -1);
+
+EVAL_EXPR(22, (__real__ (2i+3)) == 3 ? 1 : -1);
+
+int g23[(int)(1.0 / 1.0)] = { 1 };
+int g24[(int)(1.0 / 1.0)] = { 1 , 2 }; // expected-warning {{excess elements in array initializer}}
+int g25[(int)(1.0 + 1.0)], g26 = sizeof(g25);
+
+EVAL_EXPR(26, (_Complex double)0 ? -1 : 1)
+EVAL_EXPR(27, (_Complex int)0 ? -1 : 1)
+EVAL_EXPR(28, (_Complex double)1 ? 1 : -1)
+EVAL_EXPR(29, (_Complex int)1 ? 1 : -1)
+
+
+// PR4027 + rdar://6808859
+struct a { int x, y; };
+static struct a V2 = (struct a)(struct a){ 1, 2};
+static const struct a V1 = (struct a){ 1, 2};
+
+EVAL_EXPR(30, (int)(_Complex float)((1<<30)-1) == (1<<30) ? 1 : -1)
+EVAL_EXPR(31, (int*)0 == (int*)0 ? 1 : -1)
+EVAL_EXPR(32, (int*)0 != (int*)0 ? -1 : 1)
+EVAL_EXPR(33, (void*)0 - (void*)0 == 0 ? 1 : -1)
+void foo(void) {}
+EVAL_EXPR(34, (foo == (void *)0) ? -1 : 1)
+
+// No PR. Mismatched bitwidths lead to a crash on second evaluation.
+const _Bool constbool = 0;
+EVAL_EXPR(35, constbool)
+EVAL_EXPR(36, constbool)
+
+EVAL_EXPR(37, (1,2.0) == 2.0 ? 1 : -1)
+EVAL_EXPR(38, __builtin_expect(1,1) == 1 ? 1 : -1)
+
+// PR7884
+EVAL_EXPR(39, __real__(1.f) == 1 ? 1 : -1)
+EVAL_EXPR(40, __imag__(1.f) == 0 ? 1 : -1)
+
+// From gcc testsuite
+EVAL_EXPR(41, (int)(1+(_Complex unsigned)2))
+
+// rdar://8875946
+void rdar8875946() {
+ double _Complex P;
+ float _Complex P2 = 3.3f + P;
+}
+
+double d = (d = 0.0); // expected-error {{not a compile-time constant}}
+double d2 = ++d; // expected-error {{not a compile-time constant}}
+
+int n = 2;
+int intLvalue[*(int*)((long)&n ?: 1)] = { 1, 2 }; // expected-error {{variable length array}}
+
+union u { int a; char b[4]; };
+char c = ((union u)(123456)).b[0]; // expected-error {{not a compile-time constant}}
+
+extern const int weak_int __attribute__((weak));
+const int weak_int = 42;
+int weak_int_test = weak_int; // expected-error {{not a compile-time constant}}
+
+int literalVsNull1 = "foo" == 0;
+int literalVsNull2 = 0 == "foo";
+
+// PR11385.
+int castViaInt[*(int*)(unsigned long)"test"]; // expected-error {{variable length array}}
+
+// PR11391.
+struct PR11391 { _Complex float f; } pr11391;
+EVAL_EXPR(42, __builtin_constant_p(pr11391.f = 1))
+
+// PR12043
+float varfloat;
+const float constfloat = 0;
+EVAL_EXPR(43, varfloat && constfloat) // expected-error {{must have a constant size}}
+
+// <rdar://problem/11205586>
+// (Make sure we continue to reject this.)
+EVAL_EXPR(44, "x"[0]); // expected-error {{variable length array}}
+
+// <rdar://problem/10962435>
+EVAL_EXPR(45, ((char*)-1) + 1 == 0 ? 1 : -1)
+EVAL_EXPR(46, ((char*)-1) + 1 < (char*) -1 ? 1 : -1)
+EVAL_EXPR(47, &x < &x + 1 ? 1 : -1)
+EVAL_EXPR(48, &x != &x - 1 ? 1 : -1)
+EVAL_EXPR(49, &x < &x - 100 ? 1 : -1) // expected-error {{must have a constant size}}
+
+extern struct Test50S Test50;
+EVAL_EXPR(50, &Test50 < (struct Test50S*)((unsigned)&Test50 + 10)) // expected-error {{must have a constant size}}
diff --git a/clang/test/Sema/const-ptr-int-ptr-cast.c b/clang/test/Sema/const-ptr-int-ptr-cast.c
new file mode 100644
index 0000000..8beaf9d
--- /dev/null
+++ b/clang/test/Sema/const-ptr-int-ptr-cast.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -ffreestanding %s
+
+#include <stdint.h>
+
+char *a = (void*)(uintptr_t)(void*)&a;
diff --git a/clang/test/Sema/constant-builtins-2.c b/clang/test/Sema/constant-builtins-2.c
new file mode 100644
index 0000000..68b46bf
--- /dev/null
+++ b/clang/test/Sema/constant-builtins-2.c
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+// Math stuff
+
+double g0 = __builtin_huge_val();
+float g1 = __builtin_huge_valf();
+long double g2 = __builtin_huge_vall();
+
+double g3 = __builtin_inf();
+float g4 = __builtin_inff();
+long double g5 = __builtin_infl();
+
+double g6 = __builtin_nan("");
+float g7 = __builtin_nanf("");
+long double g8 = __builtin_nanl("");
+
+// GCC constant folds these too (via native strtol):
+//double g6_1 = __builtin_nan("1");
+//float g7_1 = __builtin_nanf("1");
+//long double g8_1 = __builtin_nanl("1");
+
+// APFloat doesn't have signalling NaN functions.
+//double g9 = __builtin_nans("");
+//float g10 = __builtin_nansf("");
+//long double g11 = __builtin_nansl("");
+
+//int g12 = __builtin_abs(-12);
+
+double g13 = __builtin_fabs(-12.);
+double g13_0 = __builtin_fabs(-0.);
+double g13_1 = __builtin_fabs(-__builtin_inf());
+float g14 = __builtin_fabsf(-12.f);
+// GCC doesn't eat this one.
+//long double g15 = __builtin_fabsfl(-12.0L);
+
+float g16 = __builtin_copysign(1.0, -1.0);
+double g17 = __builtin_copysignf(1.0f, -1.0f);
+long double g18 = __builtin_copysignl(1.0L, -1.0L);
+
+//double g19 = __builtin_powi(2.0, 4);
+//float g20 = __builtin_powif(2.0f, 4);
+//long double g21 = __builtin_powil(2.0L, 4);
+
+// GCC misc stuff
+
+extern int f();
+
+int h0 = __builtin_types_compatible_p(int, float);
+//int h1 = __builtin_choose_expr(1, 10, f());
+//int h2 = __builtin_expect(0, 0);
+extern long int bi0;
+extern __typeof__(__builtin_expect(0, 0)) bi0;
+
+// Strings
+int array1[__builtin_strlen("ab\0cd")];
+int array2[(sizeof(array1)/sizeof(int)) == 2? 1 : -1];
diff --git a/clang/test/Sema/constant-builtins.c b/clang/test/Sema/constant-builtins.c
new file mode 100644
index 0000000..5d67fc7
--- /dev/null
+++ b/clang/test/Sema/constant-builtins.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify -pedantic
+
+// Math stuff
+
+float g0 = __builtin_huge_val();
+double g1 = __builtin_huge_valf();
+long double g2 = __builtin_huge_vall();
+float g3 = __builtin_inf();
+double g4 = __builtin_inff();
+long double g5 = __builtin_infl();
+
+// GCC misc stuff
+
+extern int f();
+
+int h0 = __builtin_types_compatible_p(int,float);
+//int h1 = __builtin_choose_expr(1, 10, f());
+//int h2 = __builtin_expect(0, 0);
+
+short somefunc();
+
+short t = __builtin_constant_p(5353) ? 42 : somefunc();
+
+
diff --git a/clang/test/Sema/constant-conversion.c b/clang/test/Sema/constant-conversion.c
new file mode 100644
index 0000000..1376333
--- /dev/null
+++ b/clang/test/Sema/constant-conversion.c
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin %s
+
+// This file tests -Wconstant-conversion, a subcategory of -Wconversion
+// which is on by default.
+
+// rdar://problem/6792488
+void test_6792488(void) {
+ int x = 0x3ff0000000000000U; // expected-warning {{implicit conversion from 'unsigned long' to 'int' changes value from 4607182418800017408 to 0}}
+}
+
+void test_7809123(void) {
+ struct { int i5 : 5; } a;
+
+ a.i5 = 36; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 36 to 4}}
+}
+
+void test() {
+ struct { int bit : 1; } a;
+ a.bit = 1; // shouldn't warn
+}
+
+enum Test2 { K_zero, K_one };
+enum Test2 test2(enum Test2 *t) {
+ *t = 20;
+ return 10; // shouldn't warn
+}
+
+void test3() {
+ struct A {
+ unsigned int foo : 2;
+ int bar : 2;
+ };
+
+ struct A a = { 0, 10 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to -2}}
+ struct A b[] = { 0, 10, 0, 0 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to -2}}
+ struct A c[] = {{10, 0}}; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}}
+ struct A d = (struct A) { 10, 0 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}}
+ struct A e = { .foo = 10 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}}
+}
+
+void test4() {
+ struct A {
+ char c : 2;
+ } a;
+
+ a.c = 0x101; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 257 to 1}}
+}
+
+void test5() {
+ struct A {
+ _Bool b : 1;
+ } a;
+
+ // Don't warn about this implicit conversion to bool, or at least
+ // don't warn about it just because it's a bitfield.
+ a.b = 100;
+}
+
+void test6() {
+ // Test that unreachable code doesn't trigger the truncation warning.
+ unsigned char x = 0 ? 65535 : 1; // no-warning
+ unsigned char y = 1 ? 65535 : 1; // expected-warning {{changes value}}
+}
+
+void test7() {
+ struct {
+ unsigned int twoBits1:2;
+ unsigned int twoBits2:2;
+ unsigned int reserved:28;
+ } f;
+
+ f.twoBits1 = ~1; // expected-warning {{implicit truncation from 'int' to bitfield changes value from -2 to 2}}
+ f.twoBits2 = ~2; // expected-warning {{implicit truncation from 'int' to bitfield changes value from -3 to 1}}
+ f.twoBits1 &= ~1; // no-warning
+ f.twoBits2 &= ~2; // no-warning
+}
+
+void test8() {
+ enum E { A, B, C };
+ struct { enum E x : 1; } f;
+ f.x = C; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 2 to 0}}
+}
diff --git a/clang/test/Sema/constructor-attribute.c b/clang/test/Sema/constructor-attribute.c
new file mode 100644
index 0000000..3825916
--- /dev/null
+++ b/clang/test/Sema/constructor-attribute.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int x __attribute__((constructor)); // expected-warning {{'constructor' attribute only applies to functions}}
+int f() __attribute__((constructor));
+int f() __attribute__((constructor(1)));
+int f() __attribute__((constructor(1,2))); // expected-error {{attribute takes no more than 1 argument}}
+int f() __attribute__((constructor(1.0))); // expected-error {{'constructor' attribute requires parameter 1 to be an integer constant}}
+
+int x __attribute__((destructor)); // expected-warning {{'destructor' attribute only applies to functions}}
+int f() __attribute__((destructor));
+int f() __attribute__((destructor(1)));
+int f() __attribute__((destructor(1,2))); // expected-error {{attribute takes no more than 1 argument}}
+int f() __attribute__((destructor(1.0))); // expected-error {{'destructor' attribute requires parameter 1 to be an integer constant}}
+
+
diff --git a/clang/test/Sema/conversion-64-32.c b/clang/test/Sema/conversion-64-32.c
new file mode 100644
index 0000000..3de20cb
--- /dev/null
+++ b/clang/test/Sema/conversion-64-32.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wshorten-64-to-32 -triple x86_64-apple-darwin %s
+
+int test0(long v) {
+ return v; // expected-warning {{implicit conversion loses integer precision}}
+}
+
+
+// rdar://9546171
+typedef int int4 __attribute__ ((vector_size(16)));
+typedef long long long2 __attribute__((__vector_size__(16)));
+
+int4 test1(long2 a) {
+ int4 v127 = a; // no warning.
+ return v127;
+}
+
+int test2(long v) {
+ return v / 2; // expected-warning {{implicit conversion loses integer precision: 'long' to 'int'}}
+}
diff --git a/clang/test/Sema/conversion.c b/clang/test/Sema/conversion.c
new file mode 100644
index 0000000..a591ac0
--- /dev/null
+++ b/clang/test/Sema/conversion.c
@@ -0,0 +1,419 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wconversion \
+// RUN: -nostdsysteminc -nobuiltininc -isystem %S/Inputs \
+// RUN: -triple x86_64-apple-darwin %s -Wno-unreachable-code
+
+#include <conversion.h>
+
+#define BIG 0x7f7f7f7f7f7f7f7fL
+
+void test0(char c, short s, int i, long l, long long ll) {
+ c = c;
+ c = s; // expected-warning {{implicit conversion loses integer precision}}
+ c = i; // expected-warning {{implicit conversion loses integer precision}}
+ c = l; // expected-warning {{implicit conversion loses integer precision}}
+ s = c;
+ s = s;
+ s = i; // expected-warning {{implicit conversion loses integer precision}}
+ s = l; // expected-warning {{implicit conversion loses integer precision}}
+ i = c;
+ i = s;
+ i = i;
+ i = l; // expected-warning {{implicit conversion loses integer precision}}
+ l = c;
+ l = s;
+ l = i;
+ l = l;
+
+ c = (char) 0;
+ c = (short) 0;
+ c = (int) 0;
+ c = (long) 0;
+ s = (char) 0;
+ s = (short) 0;
+ s = (int) 0;
+ s = (long) 0;
+ i = (char) 0;
+ i = (short) 0;
+ i = (int) 0;
+ i = (long) 0;
+ l = (char) 0;
+ l = (short) 0;
+ l = (int) 0;
+ l = (long) 0;
+
+ c = (char) BIG;
+ c = (short) BIG; // expected-warning {{implicit conversion from 'short' to 'char' changes value}}
+ c = (int) BIG; // expected-warning {{implicit conversion from 'int' to 'char' changes value}}
+ c = (long) BIG; // expected-warning {{implicit conversion from 'long' to 'char' changes value}}
+ s = (char) BIG;
+ s = (short) BIG;
+ s = (int) BIG; // expected-warning {{implicit conversion from 'int' to 'short' changes value}}
+ s = (long) BIG; // expected-warning {{implicit conversion from 'long' to 'short' changes value}}
+ i = (char) BIG;
+ i = (short) BIG;
+ i = (int) BIG;
+ i = (long) BIG; // expected-warning {{implicit conversion from 'long' to 'int' changes value}}
+ l = (char) BIG;
+ l = (short) BIG;
+ l = (int) BIG;
+ l = (long) BIG;
+}
+
+char test1(long long ll) {
+ return (long long) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+char test1_a(long long ll) {
+ return (long) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+char test1_b(long long ll) {
+ return (int) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+char test1_c(long long ll) {
+ return (short) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+char test1_d(long long ll) {
+ return (char) ll;
+}
+char test1_e(long long ll) {
+ return (long long) BIG; // expected-warning {{implicit conversion from 'long long' to 'char' changes value}}
+}
+char test1_f(long long ll) {
+ return (long) BIG; // expected-warning {{implicit conversion from 'long' to 'char' changes value}}
+}
+char test1_g(long long ll) {
+ return (int) BIG; // expected-warning {{implicit conversion from 'int' to 'char' changes value}}
+}
+char test1_h(long long ll) {
+ return (short) BIG; // expected-warning {{implicit conversion from 'short' to 'char' changes value}}
+}
+char test1_i(long long ll) {
+ return (char) BIG;
+}
+
+short test2(long long ll) {
+ return (long long) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+short test2_a(long long ll) {
+ return (long) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+short test2_b(long long ll) {
+ return (int) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+short test2_c(long long ll) {
+ return (short) ll;
+}
+short test2_d(long long ll) {
+ return (char) ll;
+}
+short test2_e(long long ll) {
+ return (long long) BIG; // expected-warning {{implicit conversion from 'long long' to 'short' changes value}}
+}
+short test2_f(long long ll) {
+ return (long) BIG; // expected-warning {{implicit conversion from 'long' to 'short' changes value}}
+}
+short test2_g(long long ll) {
+ return (int) BIG; // expected-warning {{implicit conversion from 'int' to 'short' changes value}}
+}
+short test2_h(long long ll) {
+ return (short) BIG;
+}
+short test2_i(long long ll) {
+ return (char) BIG;
+}
+
+int test3(long long ll) {
+ return (long long) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+int test3_b(long long ll) {
+ return (long) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+int test3_c(long long ll) {
+ return (int) ll;
+}
+int test3_d(long long ll) {
+ return (short) ll;
+}
+int test3_e(long long ll) {
+ return (char) ll;
+}
+int test3_f(long long ll) {
+ return (long long) BIG; // expected-warning {{implicit conversion from 'long long' to 'int' changes value}}
+}
+int test3_g(long long ll) {
+ return (long) BIG; // expected-warning {{implicit conversion from 'long' to 'int' changes value}}
+}
+int test3_h(long long ll) {
+ return (int) BIG;
+}
+int test3_i(long long ll) {
+ return (short) BIG;
+}
+int test3_j(long long ll) {
+ return (char) BIG;
+}
+
+long test4(long long ll) {
+ return (long long) ll;
+}
+long test4_a(long long ll) {
+ return (long) ll;
+}
+long test4_b(long long ll) {
+ return (int) ll;
+}
+long test4_c(long long ll) {
+ return (short) ll;
+}
+long test4_d(long long ll) {
+ return (char) ll;
+}
+long test4_e(long long ll) {
+ return (long long) BIG;
+}
+long test4_f(long long ll) {
+ return (long) BIG;
+}
+long test4_g(long long ll) {
+ return (int) BIG;
+}
+long test4_h(long long ll) {
+ return (short) BIG;
+}
+long test4_i(long long ll) {
+ return (char) BIG;
+}
+
+long long test5(long long ll) {
+ return (long long) ll;
+ return (long) ll;
+ return (int) ll;
+ return (short) ll;
+ return (char) ll;
+ return (long long) BIG;
+ return (long) BIG;
+ return (int) BIG;
+ return (short) BIG;
+ return (char) BIG;
+}
+
+void takes_char(char);
+void takes_short(short);
+void takes_int(int);
+void takes_long(long);
+void takes_longlong(long long);
+void takes_float(float);
+void takes_double(double);
+void takes_longdouble(long double);
+
+void test6(char v) {
+ takes_char(v);
+ takes_short(v);
+ takes_int(v);
+ takes_long(v);
+ takes_longlong(v);
+ takes_float(v);
+ takes_double(v);
+ takes_longdouble(v);
+}
+
+void test7(short v) {
+ takes_char(v); // expected-warning {{implicit conversion loses integer precision}}
+ takes_short(v);
+ takes_int(v);
+ takes_long(v);
+ takes_longlong(v);
+ takes_float(v);
+ takes_double(v);
+ takes_longdouble(v);
+}
+
+void test8(int v) {
+ takes_char(v); // expected-warning {{implicit conversion loses integer precision}}
+ takes_short(v); // expected-warning {{implicit conversion loses integer precision}}
+ takes_int(v);
+ takes_long(v);
+ takes_longlong(v);
+ takes_float(v);
+ takes_double(v);
+ takes_longdouble(v);
+}
+
+void test9(long v) {
+ takes_char(v); // expected-warning {{implicit conversion loses integer precision}}
+ takes_short(v); // expected-warning {{implicit conversion loses integer precision}}
+ takes_int(v); // expected-warning {{implicit conversion loses integer precision}}
+ takes_long(v);
+ takes_longlong(v);
+ takes_float(v);
+ takes_double(v);
+ takes_longdouble(v);
+}
+
+void test10(long long v) {
+ takes_char(v); // expected-warning {{implicit conversion loses integer precision}}
+ takes_short(v); // expected-warning {{implicit conversion loses integer precision}}
+ takes_int(v); // expected-warning {{implicit conversion loses integer precision}}
+ takes_long(v);
+ takes_longlong(v);
+ takes_float(v);
+ takes_double(v);
+ takes_longdouble(v);
+}
+
+void test11(float v) {
+ takes_char(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
+ takes_short(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
+ takes_int(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
+ takes_long(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
+ takes_longlong(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
+ takes_float(v);
+ takes_double(v);
+ takes_longdouble(v);
+}
+
+void test12(double v) {
+ takes_char(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
+ takes_short(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
+ takes_int(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
+ takes_long(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
+ takes_longlong(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
+ takes_float(v); // expected-warning {{implicit conversion loses floating-point precision}}
+ takes_double(v);
+ takes_longdouble(v);
+}
+
+void test13(long double v) {
+ takes_char(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
+ takes_short(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
+ takes_int(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
+ takes_long(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
+ takes_longlong(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
+ takes_float(v); // expected-warning {{implicit conversion loses floating-point precision}}
+ takes_double(v); // expected-warning {{implicit conversion loses floating-point precision}}
+ takes_longdouble(v);
+}
+
+void test14(long l) {
+ // Fine because of the boolean whitelist.
+ char c;
+ c = (l == 4);
+ c = ((l <= 4) && (l >= 0));
+ c = ((l <= 4) && (l >= 0)) || (l > 20);
+}
+
+void test15(char c) {
+ c = c + 1 + c * 2;
+ c = (short) c + 1 + c * 2; // expected-warning {{implicit conversion loses integer precision}}
+}
+
+// PR 5422
+extern void *test16_external;
+void test16(void) {
+ int a = (unsigned long) &test16_external; // expected-warning {{implicit conversion loses integer precision}}
+}
+
+// PR 5938
+void test17() {
+ union {
+ unsigned long long a : 8;
+ unsigned long long b : 32;
+ unsigned long long c;
+ } U;
+
+ unsigned int x;
+ x = U.a;
+ x = U.b;
+ x = U.c; // expected-warning {{implicit conversion loses integer precision}}
+}
+
+// PR 5939
+void test18() {
+ union {
+ unsigned long long a : 1;
+ unsigned long long b;
+ } U;
+
+ int x;
+ x = (U.a ? 0 : 1);
+ x = (U.b ? 0 : 1);
+}
+
+// None of these should warn.
+unsigned char test19(unsigned long u64) {
+ unsigned char x1 = u64 & 0xff;
+ unsigned char x2 = u64 >> 56;
+
+ unsigned char mask = 0xee;
+ unsigned char x3 = u64 & mask;
+ return x1 + x2 + x3;
+}
+
+// <rdar://problem/7631400>
+void test_7631400(void) {
+ // This should show up despite the caret being inside a macro substitution
+ char s = LONG_MAX; // expected-warning {{implicit conversion from 'long' to 'char' changes value}}
+}
+
+// <rdar://problem/7676608>: assertion for compound operators with non-integral RHS
+void f7676608(int);
+void test_7676608(void) {
+ float q = 0.7f;
+ char c = 5;
+ f7676608(c *= q);
+}
+
+// <rdar://problem/7904686>
+void test_7904686(void) {
+ const int i = -1;
+ unsigned u1 = i; // expected-warning {{implicit conversion changes signedness}}
+ u1 = i; // expected-warning {{implicit conversion changes signedness}}
+
+ unsigned u2 = -1; // expected-warning {{implicit conversion changes signedness}}
+ u2 = -1; // expected-warning {{implicit conversion changes signedness}}
+}
+
+// <rdar://problem/8232669>: don't warn about conversions required by
+// contexts in system headers
+void test_8232669(void) {
+ unsigned bitset[20];
+ SETBIT(bitset, 0);
+
+ unsigned y = 50;
+ SETBIT(bitset, y);
+
+#define USER_SETBIT(set,bit) do { int i = bit; set[i/(8*sizeof(set[0]))] |= (1 << (i%(8*sizeof(set)))); } while(0)
+ USER_SETBIT(bitset, 0); // expected-warning 2 {{implicit conversion changes signedness}}
+}
+
+// <rdar://problem/8559831>
+enum E8559831a { E8559831a_val };
+enum E8559831b { E8559831b_val };
+typedef enum { E8559831c_val } E8559831c;
+enum { E8559831d_val } value_d;
+
+void test_8559831_a(enum E8559831a value);
+void test_8559831(enum E8559831b value_a, E8559831c value_c) {
+ test_8559831_a(value_a); // expected-warning{{implicit conversion from enumeration type 'enum E8559831b' to different enumeration type 'enum E8559831a'}}
+ enum E8559831a a1 = value_a; // expected-warning{{implicit conversion from enumeration type 'enum E8559831b' to different enumeration type 'enum E8559831a'}}
+ a1 = value_a; // expected-warning{{implicit conversion from enumeration type 'enum E8559831b' to different enumeration type 'enum E8559831a'}}
+
+ test_8559831_a(E8559831b_val); // expected-warning{{implicit conversion from enumeration type 'enum E8559831b' to different enumeration type 'enum E8559831a'}}
+ enum E8559831a a1a = E8559831b_val; // expected-warning{{implicit conversion from enumeration type 'enum E8559831b' to different enumeration type 'enum E8559831a'}}
+ a1 = E8559831b_val; // expected-warning{{implicit conversion from enumeration type 'enum E8559831b' to different enumeration type 'enum E8559831a'}}
+
+ test_8559831_a(value_c); // expected-warning{{implicit conversion from enumeration type 'E8559831c' to different enumeration type 'enum E8559831a'}}
+ enum E8559831a a2 = value_c; // expected-warning{{implicit conversion from enumeration type 'E8559831c' to different enumeration type 'enum E8559831a'}}
+ a2 = value_c; // expected-warning{{implicit conversion from enumeration type 'E8559831c' to different enumeration type 'enum E8559831a'}}
+
+ test_8559831_a(value_d);
+ enum E8559831a a3 = value_d;
+ a3 = value_d;
+}
+
+void test26(int si, long sl) {
+ si = sl % sl; // expected-warning {{implicit conversion loses integer precision: 'long' to 'int'}}
+ si = sl % si;
+ si = si % sl;
+ si = si / sl;
+ si = sl / si; // expected-warning {{implicit conversion loses integer precision: 'long' to 'int'}}
+}
diff --git a/clang/test/Sema/crash-invalid-array.c b/clang/test/Sema/crash-invalid-array.c
new file mode 100644
index 0000000..a3bc03b
--- /dev/null
+++ b/clang/test/Sema/crash-invalid-array.c
@@ -0,0 +1,17 @@
+// RUN: not %clang_cc1 -O1 %s -emit-llvm
+// PR6913
+
+#include <stdio.h>
+
+int main()
+{
+ int x[10][10];
+ int (*p)[] = x; // expected-error {{invalid use of array with unspecified bounds}
+
+ int i;
+
+ for(i = 0; i < 10; ++i)
+ {
+ p[i][i] = i;
+ }
+}
diff --git a/clang/test/Sema/darwin-align-cast.c b/clang/test/Sema/darwin-align-cast.c
new file mode 100644
index 0000000..2080974
--- /dev/null
+++ b/clang/test/Sema/darwin-align-cast.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+typedef long unsigned int __darwin_size_t;
+typedef long __darwin_ssize_t;
+typedef __darwin_size_t size_t;
+typedef __darwin_ssize_t ssize_t;
+
+struct cmsghdr {};
+
+#if 0
+This code below comes from the following system headers:
+sys/socket.h:#define CMSG_SPACE(l) (__DARWIN_ALIGN(sizeof(struct
+cmsghdr)) + __DARWIN_ALIGN(l))
+
+i386/_param.h:#define __DARWIN_ALIGN(p) ((__darwin_size_t)((char *)(p)
++ __DARWIN_ALIGNBYTES) &~ __DARWIN_ALIGNBYTES)
+#endif
+
+ssize_t sendFileDescriptor(int fd, void *data, size_t nbytes, int sendfd) {
+ union {
+ char control[(((__darwin_size_t)((char *)(sizeof(struct cmsghdr)) + (sizeof(__darwin_size_t) - 1)) &~ (sizeof(__darwin_size_t) - 1)) + ((__darwin_size_t)((char *)(sizeof(int)) + (sizeof(__darwin_size_t) - 1)) &~ (sizeof(__darwin_size_t) - 1)))];
+ } control_un;
+ return 0;
+}
+
diff --git a/clang/test/Sema/decl-in-prototype.c b/clang/test/Sema/decl-in-prototype.c
new file mode 100644
index 0000000..05b8e0a
--- /dev/null
+++ b/clang/test/Sema/decl-in-prototype.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1_only -verify %s
+
+const int AA = 5;
+
+int f1(enum {AA,BB} E) {
+ return BB;
+}
+
+int f2(enum {AA=7,BB} E) {
+ return AA;
+}
+
+struct a {
+};
+
+int f3(struct a { } *); // expected-warning {{will not be visible outside of this function}}
+
+struct A { struct b { int j; } t; }; // expected-note {{previous definition is here}}
+
+int f4(struct A { struct b { int j; } t; } *); // expected-warning {{declaration of 'struct A' will not be visible outside of this function}} expected-warning {{redefinition of 'b' will not be visible outside of this function}}
+
+struct aA {
+ struct ab { // expected-note {{previous definition is here}} expected-note {{previous definition is here}}
+ int j;
+ } b;
+};
+
+int f5(struct aA { struct ab { int j; } b; struct ab { char glorx; } glorx; } *); // expected-warning {{declaration of 'struct aA' will not be visible}} expected-warning {{redefinition of 'ab' will not be visible}} expected-warning {{redefinition of 'ab' will not be visible}}
+
+void f6(struct z {int b;} c) { // expected-warning {{declaration of 'struct z' will not be visible outside of this function}}
+ struct z d;
+ d.b = 4;
+}
diff --git a/clang/test/Sema/decl-invalid.c b/clang/test/Sema/decl-invalid.c
new file mode 100644
index 0000000..f6fed3c
--- /dev/null
+++ b/clang/test/Sema/decl-invalid.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+// See Sema::ParsedFreeStandingDeclSpec about the double diagnostic
+typedef union <anonymous> __mbstate_t; // expected-error {{declaration of anonymous union must be a definition}} expected-warning {{declaration does not declare anything}}
+
+
+// PR2017
+void x();
+int a() {
+ int r[x()]; // expected-error {{size of array has non-integer type 'void'}}
+
+ static y ?; // expected-error{{unknown type name 'y'}} \
+ expected-error{{expected identifier or '('}}
+}
+
+int; // expected-warning {{declaration does not declare anything}}
+typedef int; // expected-warning {{declaration does not declare anything}}
+const int; // expected-warning {{declaration does not declare anything}}
+struct; // expected-error {{declaration of anonymous struct must be a definition}} // expected-warning {{declaration does not declare anything}}
+typedef int I;
+I; // expected-warning {{declaration does not declare anything}}
+
+
+
+// rdar://6880449
+register int test1; // expected-error {{illegal storage class on file-scoped variable}}
+register int test2 __asm__("edi"); // expected-error {{global register variables are not supported}}
+
diff --git a/clang/test/Sema/decl-type-merging.c b/clang/test/Sema/decl-type-merging.c
new file mode 100644
index 0000000..259b0dd
--- /dev/null
+++ b/clang/test/Sema/decl-type-merging.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -pedantic %s
+
+int x[10];
+int x[] = {1,2,3};
+int testx[(sizeof(x) == sizeof(int) * 10) ? 1 : -1];
+
+int (*a)(int (*x)[10], int (*y)[]);
+int (*a)(int (*x)[], int (*y)[5]);
+void b() {
+ int x[10], y[5];
+ a(&x, &y);
+ a(&y, &y); // expected-warning {{incompatible pointer}}
+ a(&x, &x); // expected-warning {{incompatible pointer}}
+}
+
+
diff --git a/clang/test/Sema/declspec.c b/clang/test/Sema/declspec.c
new file mode 100644
index 0000000..7354028
--- /dev/null
+++ b/clang/test/Sema/declspec.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+typedef char T[4];
+
+T foo(int n, int m) { } // expected-error {{cannot return array type}}
+
+void foof(const char *, ...) __attribute__((__format__(__printf__, 1, 2))), barf (void);
+
+int typedef validTypeDecl() { } // expected-error {{function definition declared 'typedef'}}
+
+struct _zend_module_entry { } // expected-error {{expected ';' after struct}}
+int gv1;
+typedef struct _zend_function_entry { } // expected-error {{expected ';' after struct}} \
+ // expected-warning {{declaration does not declare anything}}
+int gv2;
+
+static void buggy(int *x) { }
+
+// Type qualifiers.
+typedef int f(void);
+typedef f* fptr;
+const f* v1; // expected-warning {{qualifier on function type 'f' (aka 'int (void)') has unspecified behavior}}
+__restrict__ f* v2; // expected-error {{restrict requires a pointer or reference ('f' (aka 'int (void)') is invalid)}}
+__restrict__ fptr v3; // expected-error {{pointer to function type 'f' (aka 'int (void)') may not be 'restrict' qualified}}
+f *__restrict__ v4; // expected-error {{pointer to function type 'f' (aka 'int (void)') may not be 'restrict' qualified}}
+
+restrict struct hallo; // expected-error {{restrict requires a pointer or reference}}
+
+// PR6180
+struct test1 {
+} // expected-error {{expected ';' after struct}}
+
+void test2() {}
+
+
+// PR6423
+struct test3s {
+} // expected-error {{expected ';' after struct}}
+typedef int test3g;
diff --git a/clang/test/Sema/default.c b/clang/test/Sema/default.c
new file mode 100644
index 0000000..429e63a
--- /dev/null
+++ b/clang/test/Sema/default.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f5 (int z) {
+ if (z)
+ default: // expected-error {{not in switch statement}}
+ ;
+}
+
diff --git a/clang/test/Sema/default1.c b/clang/test/Sema/default1.c
new file mode 100644
index 0000000..631e848
--- /dev/null
+++ b/clang/test/Sema/default1.c
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+void f(int i = 0); // expected-error {{C does not support default arguments}}
diff --git a/clang/test/Sema/deref.c b/clang/test/Sema/deref.c
new file mode 100644
index 0000000..845b286
--- /dev/null
+++ b/clang/test/Sema/deref.c
@@ -0,0 +1,44 @@
+/* RUN: %clang_cc1 -fsyntax-only -verify -std=c90 -pedantic %s
+ */
+void
+foo (void)
+{
+ struct b;
+ struct b* x = 0;
+ struct b* y = &*x;
+}
+
+void foo2 (void)
+{
+ typedef int (*arrayptr)[];
+ arrayptr x = 0;
+ arrayptr y = &*x;
+}
+
+void foo3 (void)
+{
+ void* x = 0;
+ void* y = &*x; /* expected-warning{{address of an expression of type 'void'}} */
+}
+
+extern const void cv1;
+
+const void *foo4 (void)
+{
+ return &cv1;
+}
+
+extern void cv2;
+void *foo5 (void)
+{
+ return &cv2; /* expected-warning{{address of an expression of type 'void'}} */
+}
+
+typedef const void CVT;
+extern CVT cv3;
+
+const void *foo6 (void)
+{
+ return &cv3;
+}
+
diff --git a/clang/test/Sema/designated-initializers.c b/clang/test/Sema/designated-initializers.c
new file mode 100644
index 0000000..c9a8482
--- /dev/null
+++ b/clang/test/Sema/designated-initializers.c
@@ -0,0 +1,279 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-unknown %s
+
+int complete_array_from_init[] = { 1, 2, [10] = 5, 1, 2, [5] = 2, 6 };
+
+int complete_array_from_init_check[((sizeof(complete_array_from_init) / sizeof(int)) == 13)? 1 : -1];
+
+int iarray[10] = {
+ [0] = 1,
+ [1 ... 5] = 2,
+ [ 6 ... 6 ] = 3,
+ [ 8 ... 7 ] = 4, // expected-error{{array designator range [8, 7] is empty}}
+ [10] = 5,
+ [-1] = 6 // expected-error{{array designator value '-1' is negative}}
+};
+
+int iarray2[10] = {
+ [10] = 1, // expected-error{{array designator index (10) exceeds array bounds (10)}}
+};
+
+int iarray3[10] = {
+ [3] 2, // expected-warning{{use of GNU 'missing =' extension in designator}}
+ [5 ... 12] = 2 // expected-error{{array designator index (12) exceeds array bounds (10)}}
+};
+
+struct point {
+ double x;
+ double y;
+};
+
+struct point p1 = {
+ .y = 1.0,
+ x: 2.0, // expected-warning{{}}
+ .a = 4.0, // expected-error{{field designator 'a' does not refer to any field in type 'struct point'}}
+};
+
+struct point p2 = {
+ [1] = 1.0 // expected-error{{array designator cannot initialize non-array type}}
+};
+
+struct point array[10] = {
+ [0].x = 1.0,
+ [1].y = 2.0,
+ [2].z = 3.0, // expected-error{{field designator 'z' does not refer to any field in type 'struct point'}}
+};
+
+struct point array2[10] = {
+ [10].x = 2.0, // expected-error{{array designator index (10) exceeds array bounds (10)}}
+ [4 ... 5].y = 2.0,
+ [4 ... 6] = { .x = 3, .y = 4.0 }
+};
+
+struct point array3[10] = {
+ .x = 5 // expected-error{{field designator cannot initialize a non-struct, non-union type}}
+};
+
+struct rect {
+ struct point top_left;
+ struct point bottom_right;
+};
+
+struct rect window = { .top_left.x = 1.0 };
+
+struct rect windows[] = {
+ [2].top_left = { 1.0, 2.0 },
+ [4].bottom_right = { .y = 1.0 },
+ { { .y = 7.0, .x = 8.0 }, { .x = 5.0 } },
+ [3] = { .top_left = { 1.1, 2.2 }, .bottom_right = { .y = 1.1 } }
+};
+
+int windows_size[((sizeof(windows) / sizeof(struct rect)) == 6)? 1 : -1];
+
+struct rect windows_bad[3] = {
+ [2].top_left = { { .x = 1.1 } }, // expected-error{{designator in initializer for scalar type}}
+ [1].top_left = { .x = 1.1 }
+};
+
+struct gui {
+ struct rect windows[10];
+};
+
+struct gui gui[] = {
+ [5].windows[3].top_left.x = { 7.0 } // expected-warning{{braces around scalar initializer}}
+};
+
+struct translator {
+ struct wonky { int * ptr; } wonky ;
+ struct rect window;
+ struct point offset;
+} tran = {
+ .window = { .top_left = { 1.0, 2.0 } },
+ { .x = 5.0, .y = 6.0 },
+ .wonky = { 0 }
+};
+
+int anint;
+struct {int x,*y;} z[] = {[0].x = 2, &z[0].x};
+
+struct outer { struct inner { int x, *y; } in, *inp; } zz[] = {
+ [0].in.x = 2, &zz[0].in.x, &zz[0].in,
+ 0, &anint, &zz[1].in,
+ [3].in = { .y = &anint, .x = 17 },
+ [7].in.y = &anint, &zz[0].in,
+ [4].in.y = &anint, [5].in.x = 12
+};
+
+int zz_sizecheck[sizeof(zz) / sizeof(struct outer) == 8? 1 : -1 ];
+
+struct disklabel_ops {
+ struct {} type;
+ int labelsize;
+};
+
+struct disklabel_ops disklabel64_ops = {
+ .labelsize = sizeof(struct disklabel_ops)
+};
+
+// PR clang/3378
+int bitwidth[] = { [(long long int)1] = 5, [(short int)2] = 2 };
+int a[]= { [sizeof(int)] = 0 };
+int a2[]= { [0 ... sizeof(int)] = 0 };
+
+// Test warnings about initializers overriding previous initializers
+struct X {
+ int a, b, c;
+};
+
+int counter = 0;
+int get8() { ++counter; return 8; }
+
+void test() {
+ struct X xs[] = {
+ [0] = (struct X){1, 2}, // expected-note{{previous initialization is here}}
+ [0].c = 3, // expected-warning{{subobject initialization overrides initialization of other fields within its enclosing subobject}}
+ (struct X) {4, 5, 6}, // expected-note{{previous initialization is here}}
+ [1].b = get8(), // expected-warning{{subobject initialization overrides initialization of other fields within its enclosing subobject}}
+ [0].b = 8
+ };
+}
+
+// FIXME: How do we test that this initializes the long properly?
+union { char c; long l; } u1 = { .l = 0xFFFF };
+
+extern float global_float;
+
+struct XX { int a, *b; };
+struct XY { int before; struct XX xx, *xp; float* after; } xy[] = {
+ 0, 0, &xy[0].xx.a, &xy[0].xx, &global_float,
+ [1].xx = 0, &xy[1].xx.a, &xy[1].xx, &global_float,
+ 0, // expected-note{{previous initialization is here}}
+ 0, // expected-note{{previous initialization is here}}
+ [2].before = 0, // expected-warning{{initializer overrides prior initialization of this subobject}}
+ 0, // expected-warning{{initializer overrides prior initialization of this subobject}}
+ &xy[2].xx.a, &xy[2].xx, &global_float
+};
+
+// PR3519
+struct foo {
+ int arr[10];
+};
+
+struct foo Y[10] = {
+ [1] .arr [1] = 2,
+ [4] .arr [2] = 4
+};
+
+struct bar {
+ struct foo f;
+ float *arr[10];
+};
+
+extern float f;
+struct bar saloon = {
+ .f.arr[3] = 1,
+ .arr = { &f }
+};
+
+typedef unsigned char u_char;
+typedef unsigned short u_short;
+
+union wibble {
+ u_char arr1[6];
+ u_short arr2[3];
+};
+
+const union wibble wobble = { .arr2[0] = 0xffff,
+ .arr2[1] = 0xffff,
+ .arr2[2] = 0xffff };
+
+const union wibble wobble2 = { .arr2 = {4, 5, 6}, 7 }; // expected-warning{{excess elements in union initializer}}
+
+// PR3778
+struct s {
+ union { int i; };
+};
+struct s si = {
+ { .i = 1 }
+};
+
+double d0;
+char c0;
+float f0;
+int i0;
+
+struct Enigma {
+ union {
+ struct {
+ struct {
+ double *double_ptr;
+ char *string;
+ };
+ float *float_ptr;
+ };
+ int *int_ptr;
+ };
+ char *string2;
+};
+
+struct Enigma enigma = {
+ .double_ptr = &d0, &c0,
+ &f0, // expected-note{{previous}}
+ &c0,
+ .float_ptr = &f0 // expected-warning{{overrides}}
+};
+
+
+/// PR4073
+/// Should use evaluate to fold aggressively and emit a warning if not an ice.
+extern int crazy_x;
+
+int crazy_Y[] = {
+ [ 0 ? crazy_x : 4] = 1
+};
+
+// PR5843
+struct expr {
+ int nargs;
+ union {
+ unsigned long int num;
+ struct expr *args[3];
+ } val;
+};
+
+struct expr expr0 = {
+ .nargs = 2,
+ .val = {
+ .args = {
+ [0] = (struct expr *)0,
+ [1] = (struct expr *)0
+ }
+ }
+};
+
+// PR6955
+
+struct ds {
+ struct {
+ struct {
+ unsigned int a;
+ };
+ unsigned int b;
+ struct {
+ unsigned int c;
+ };
+ };
+};
+
+// C1X lookup-based anonymous member init cases
+struct ds ds0 = {
+ { {
+ .a = 1 // expected-note{{previous initialization is here}}
+ } },
+ .a = 2, // expected-warning{{initializer overrides prior initialization of this subobject}}
+ .b = 3
+};
+struct ds ds1 = { .c = 0 };
+struct ds ds2 = { { {
+ .a = 0,
+ .b = 1 // expected-error{{field designator 'b' does not refer to any field}}
+} } };
diff --git a/clang/test/Sema/dllimport-dllexport.c b/clang/test/Sema/dllimport-dllexport.c
new file mode 100644
index 0000000..610059e
--- /dev/null
+++ b/clang/test/Sema/dllimport-dllexport.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -verify %s
+
+inline void __attribute__((dllexport)) foo1(){} // expected-warning{{dllexport attribute ignored}}
+inline void __attribute__((dllimport)) foo2(){} // expected-warning{{dllimport attribute ignored}}
+
+void __attribute__((dllimport)) foo3(){} // expected-error{{dllimport attribute can be applied only to symbol declaration}}
+
+void __attribute__((dllimport, dllexport)) foo4(); // expected-warning{{dllimport attribute ignored}}
+
+void __attribute__((dllexport)) foo5();
+void __attribute__((dllimport)) foo5(); // expected-warning{{dllimport attribute ignored}}
+
+typedef int __attribute__((dllexport)) type6; // expected-warning{{'dllexport' attribute only applies to variables and functions}}
+
+typedef int __attribute__((dllimport)) type7; // expected-warning{{'dllimport' attribute only applies to variables and functions}}
+
+void __attribute__((dllimport)) foo6();
+void foo6(){} // expected-warning {{'foo6' redeclared without dllimport attribute: previous dllimport ignored}}
+
+// PR6269
+inline void __declspec(dllexport) foo7(){} // expected-warning{{dllexport attribute ignored}}
+inline void __declspec(dllimport) foo8(){} // expected-warning{{dllimport attribute ignored}}
+
+void __declspec(dllimport) foo9(){} // expected-error{{dllimport attribute can be applied only to symbol declaration}}
+
+void __declspec(dllimport) __declspec(dllexport) foo10(); // expected-warning{{dllimport attribute ignored}}
+
+void __declspec(dllexport) foo11();
+void __declspec(dllimport) foo11(); // expected-warning{{dllimport attribute ignored}}
+
+typedef int __declspec(dllexport) type1; // expected-warning{{'dllexport' attribute only applies to variables and functions}}
+
+typedef int __declspec(dllimport) type2; // expected-warning{{'dllimport' attribute only applies to variables and functions}}
+
+void __declspec(dllimport) foo12();
+void foo12(){} // expected-warning {{'foo12' redeclared without dllimport attribute: previous dllimport ignored}}
diff --git a/clang/test/Sema/enum-packed.c b/clang/test/Sema/enum-packed.c
new file mode 100644
index 0000000..0eb6c14
--- /dev/null
+++ b/clang/test/Sema/enum-packed.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR7477
+enum __attribute__((packed)) E {
+ Ea, Eb, Ec, Ed
+};
+
+void test_E(enum E e) {
+ switch (e) {
+ case Ea:
+ case Eb:
+ case Ec:
+ case Ed:
+ break;
+ }
+}
diff --git a/clang/test/Sema/enum.c b/clang/test/Sema/enum.c
new file mode 100644
index 0000000..fc2b491
--- /dev/null
+++ b/clang/test/Sema/enum.c
@@ -0,0 +1,121 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
+enum e {A,
+ B = 42LL << 32, // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
+ C = -4, D = 12456 };
+
+enum f { a = -2147483648, b = 2147483647 }; // ok.
+
+enum g { // too negative
+ c = -2147483649, // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
+ d = 2147483647 };
+enum h { e = -2147483648, // too pos
+ f = 2147483648, // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
+ i = 0xFFFF0000 // expected-warning {{too large}}
+};
+
+// minll maxull
+enum x // expected-warning {{enumeration values exceed range of largest integer}}
+{ y = -9223372036854775807LL-1, // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
+z = 9223372036854775808ULL }; // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
+
+int test() {
+ return sizeof(enum e) ;
+}
+
+enum gccForwardEnumExtension ve; // expected-warning{{ISO C forbids forward references to 'enum' types}} \
+// expected-error{{tentative definition has type 'enum gccForwardEnumExtension' that is never completed}} \
+// expected-note{{forward declaration of 'enum gccForwardEnumExtension'}}
+
+int test2(int i)
+{
+ ve + i; // expected-error{{invalid operands to binary expression}}
+}
+
+// PR2020
+union u0; // expected-note {{previous use is here}}
+enum u0 { U0A }; // expected-error {{use of 'u0' with tag type that does not match previous declaration}}
+
+
+// rdar://6095136
+extern enum some_undefined_enum ve2; // expected-warning {{ISO C forbids forward references to 'enum' types}}
+
+void test4() {
+ for (; ve2;) // expected-error {{statement requires expression of scalar type}}
+ ;
+ (_Bool)ve2; // expected-error {{arithmetic or pointer type is required}}
+
+ for (; ;ve2) // expected-warning {{expression result unused}}
+ ;
+ (void)ve2;
+ ve2; // expected-warning {{expression result unused}}
+}
+
+// PR2416
+enum someenum {}; // expected-error {{use of empty enum}}
+
+// <rdar://problem/6093889>
+enum e0 { // expected-note {{previous definition is here}}
+ E0 = sizeof(enum e0 { E1 }), // expected-error {{nested redefinition}}
+};
+
+// PR3173
+enum { PR3173A, PR3173B = PR3173A+50 };
+
+// PR2753
+void foo() {
+ enum xpto; // expected-warning{{ISO C forbids forward references to 'enum' types}}
+ enum xpto; // expected-warning{{ISO C forbids forward references to 'enum' types}}
+}
+
+// <rdar://problem/6503878>
+typedef enum { X = 0 }; // expected-warning{{typedef requires a name}}
+
+
+enum NotYetComplete { // expected-note{{definition of 'enum NotYetComplete' is not complete until the closing '}'}}
+ NYC1 = sizeof(enum NotYetComplete) // expected-error{{invalid application of 'sizeof' to an incomplete type 'enum NotYetComplete'}}
+};
+
+/// PR3688
+struct s1 {
+ enum e1 (*bar)(void); // expected-warning{{ISO C forbids forward references to 'enum' types}}
+};
+
+enum e1 { YES, NO };
+
+static enum e1 badfunc(struct s1 *q) {
+ return q->bar();
+}
+
+
+// Make sure we don't a.k.a. anonymous enums.
+typedef enum {
+ an_enumerator = 20
+} an_enum;
+char * s = (an_enum) an_enumerator; // expected-warning {{incompatible integer to pointer conversion initializing 'char *' with an expression of type 'an_enum'}}
+
+// PR4515
+enum PR4515 {PR4515a=1u,PR4515b=(PR4515a-2)/2};
+int CheckPR4515[PR4515b==0?1:-1];
+
+// PR7911
+extern enum PR7911T PR7911V; // expected-warning{{ISO C forbids forward references to 'enum' types}}
+void PR7911F() {
+ switch (PR7911V); // expected-error {{statement requires expression of integer type}}
+}
+
+char test5[__has_feature(enumerator_attributes) ? 1 : -1];
+
+// PR8694
+// rdar://8707031
+void PR8694(int* e) // expected-note {{passing argument to parameter 'e' here}}
+{
+}
+
+void crash(enum E* e) // expected-warning {{declaration of 'enum E' will not be visible outside of this function}} \
+ // expected-warning {{ISO C forbids forward references to 'enum' types}}
+{
+ PR8694(e); // expected-warning {{incompatible pointer types passing 'enum E *' to parameter of type 'int *'}}
+}
+
+typedef enum { NegativeShort = (short)-1 } NegativeShortEnum;
+int NegativeShortTest[NegativeShort == -1 ? 1 : -1];
diff --git a/clang/test/Sema/expr-address-of.c b/clang/test/Sema/expr-address-of.c
new file mode 100644
index 0000000..2b8cfbf
--- /dev/null
+++ b/clang/test/Sema/expr-address-of.c
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+struct xx { int bitf:1; };
+
+struct entry { struct xx *whatever;
+ int value;
+ int bitf:1; };
+void add_one(int *p) { (*p)++; }
+
+void test() {
+ register struct entry *p;
+ add_one(&p->value);
+ struct entry pvalue;
+ add_one(&p->bitf); // expected-error {{address of bit-field requested}}
+ add_one(&pvalue.bitf); // expected-error {{address of bit-field requested}}
+ add_one(&p->whatever->bitf); // expected-error {{address of bit-field requested}}
+}
+
+void foo() {
+ register int x[10];
+ &x[10]; // expected-error {{address of register variable requested}}
+
+ register int *y;
+
+ int *x2 = &y; // expected-error {{address of register variable requested}}
+ int *x3 = &y[10];
+}
+
+void testVectorComponentAccess() {
+ typedef float v4sf __attribute__ ((vector_size (16)));
+ static v4sf q;
+ float* r = &q[0]; // expected-error {{address of vector element requested}}
+}
+
+typedef __attribute__(( ext_vector_type(4) )) float float4;
+
+float *testExtVectorComponentAccess(float4 x) {
+ return &x.w; // expected-error {{address of vector element requested}}
+}
+
+void f0() {
+ register int *x0;
+ int *_dummy0 = &(*x0);
+
+ register int *x1;
+ int *_dummy1 = &(*(x1 + 1));
+}
+
+// FIXME: The checks for this function are broken; we should error
+// on promoting a register array to a pointer! (C99 6.3.2.1p3)
+void f1() {
+ register int x0[10];
+ int *_dummy00 = x0; // fixme-error {{address of register variable requested}}
+ int *_dummy01 = &(*x0); // fixme-error {{address of register variable requested}}
+
+ register int x1[10];
+ int *_dummy1 = &(*(x1 + 1)); // fixme-error {{address of register variable requested}}
+
+ register int *x2;
+ int *_dummy2 = &(*(x2 + 1));
+
+ register int x3[10][10][10];
+ int (*_dummy3)[10] = &x3[0][0]; // expected-error {{address of register variable requested}}
+
+ register struct { int f0[10]; } x4;
+ int *_dummy4 = &x4.f0[2]; // expected-error {{address of register variable requested}}
+}
+
+void f2() {
+ register int *y;
+
+ int *_dummy0 = &y; // expected-error {{address of register variable requested}}
+ int *_dummy1 = &y[10];
+}
+
+void f3() {
+ extern void f4();
+ void (*_dummy0)() = &****f4;
+}
+
+void f4() {
+ register _Complex int x;
+
+ int *_dummy0 = &__real__ x; // expected-error {{address of register variable requested}}
+}
+
+void f5() {
+ register int arr[2];
+
+ /* This is just here because if we happened to support this as an
+ lvalue we would need to give a warning. Note that gcc warns about
+ this as a register before it warns about it as an invalid
+ lvalue. */
+ int *_dummy0 = &(int*) arr; // expected-error {{address expression must be an lvalue or a function designator}}
+ int *_dummy1 = &(arr + 1); // expected-error {{address expression must be an lvalue or a function designator}}
+}
+
+void f6(register int x) {
+ int * dummy0 = &x; // expected-error {{address of register variable requested}}
+}
+
+char* f7() {
+ register struct {char* x;} t1 = {"Hello"};
+ char* dummy1 = &(t1.x[0]);
+
+ struct {int a : 10;} t2;
+ int* dummy2 = &(t2.a); // expected-error {{address of bit-field requested}}
+
+ void* t3 = &(*(void*)0);
+}
+
+void f8() {
+ void *dummy0 = &f8(); // expected-error {{address expression must be an lvalue or a function designator}}
+
+ extern void v;
+ void *dummy1 = &(1 ? v : f8()); // expected-error {{address expression must be an lvalue or a function designator}}
+
+ void *dummy2 = &(f8(), v); // expected-error {{address expression must be an lvalue or a function designator}}
+
+ void *dummy3 = &({ ; }); // expected-error {{address expression must be an lvalue or a function designator}}
+}
diff --git a/clang/test/Sema/expr-comma-c99.c b/clang/test/Sema/expr-comma-c99.c
new file mode 100644
index 0000000..d0883ba
--- /dev/null
+++ b/clang/test/Sema/expr-comma-c99.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c99
+// rdar://6095180
+
+struct s { char c[17]; };
+extern struct s foo(void);
+
+struct s a, b, c;
+
+int A[sizeof((foo().c)) == 17 ? 1 : -1];
+int B[sizeof((a.c)) == 17 ? 1 : -1];
+
+
+// comma does array/function promotion in c99.
+int X[sizeof(0, (foo().c)) == sizeof(char*) ? 1 : -1];
+int Y[sizeof(0, (a,b).c) == sizeof(char*) ? 1 : -1];
+int Z[sizeof(0, (a=b).c) == sizeof(char*) ? 1 : -1];
+
diff --git a/clang/test/Sema/expr-comma.c b/clang/test/Sema/expr-comma.c
new file mode 100644
index 0000000..d3e4020
--- /dev/null
+++ b/clang/test/Sema/expr-comma.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c89
+// rdar://6095180
+
+struct s { char c[17]; };
+extern struct s foo(void);
+
+struct s a, b, c;
+
+int A[sizeof((foo().c)) == 17 ? 1 : -1];
+int B[sizeof((a.c)) == 17 ? 1 : -1];
+
+
+// comma does not promote array/function in c90 unless they are lvalues.
+int W[sizeof(0, a.c) == sizeof(char*) ? 1 : -1];
+int X[sizeof(0, (foo().c)) == 17 ? 1 : -1];
+int Y[sizeof(0, (a,b).c) == 17 ? 1 : -1];
+int Z[sizeof(0, (a=b).c) == 17 ? 1 : -1];
diff --git a/clang/test/Sema/exprs.c b/clang/test/Sema/exprs.c
new file mode 100644
index 0000000..72cff65
--- /dev/null
+++ b/clang/test/Sema/exprs.c
@@ -0,0 +1,240 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+// PR 8876 - don't warn about trivially unreachable null derefs. Note that
+// we put this here because the reachability analysis only kicks in for
+// suppressing false positives when code has no errors.
+#define PR8876(err_ptr) do {\
+ if (err_ptr) *(int*)(err_ptr) = 1;\
+ } while (0)
+
+#define PR8876_pos(err_ptr) do {\
+ if (!err_ptr) *(int*)(err_ptr) = 1;\
+ } while (0)
+
+
+// Test that we don't report divide-by-zero errors in unreachable code.
+// This test should be left as is, as it also tests CFG functionality.
+void radar9171946() {
+ if (0) {
+ 0 / (0 ? 1 : 0); // expected-warning {{expression result unused}}
+ }
+}
+
+int test_pr8876() {
+ PR8876(0); // no-warning
+ PR8876_pos(0); // expected-warning{{indirection of non-volatile null pointer will be deleted, not trap}} expected-note{{consider using __builtin_trap() or qualifying pointer with 'volatile'}}
+ return 0;
+}
+
+// PR 8183 - Handle null pointer constants on the left-side of the '&&', and reason about
+// this when determining the reachability of the null pointer dereference on the right side.
+void pr8183(unsigned long long test)
+{
+ (void)((((void*)0)) && (*((unsigned long long*)(((void*)0))) = ((unsigned long long)((test)) % (unsigned long long)((1000000000))))); // no-warning
+ (*((unsigned long long*)(((void*)0))) = ((unsigned long long)((test)) % (unsigned long long)((1000000000)))); // expected-warning {{indirection of non-volatile null pointer will be deleted, not trap}} expected-note {{consider using __builtin_trap() or qualifying pointer with 'volatile'}}
+}
+
+// PR1966
+_Complex double test1() {
+ return __extension__ 1.0if;
+}
+
+_Complex double test2() {
+ return 1.0if; // expected-warning {{imaginary constants are an extension}}
+}
+
+// rdar://6097308
+void test3() {
+ int x;
+ (__extension__ x) = 10;
+}
+
+// rdar://6162726
+void test4() {
+ static int var;
+ var =+ 5; // expected-warning {{use of unary operator that may be intended as compound assignment (+=)}}
+ var =- 5; // expected-warning {{use of unary operator that may be intended as compound assignment (-=)}}
+ var = +5; // no warning when space between the = and +.
+ var = -5;
+
+ var =+5; // no warning when the subexpr of the unary op has no space before it.
+ var =-5;
+
+#define FIVE 5
+ var=-FIVE; // no warning with macros.
+ var=-FIVE;
+}
+
+// rdar://6319320
+void test5(int *X, float *P) {
+ (float*)X = P; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}}
+#define FOO ((float*) X)
+ FOO = P; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}}
+}
+
+void test6() {
+ int X;
+ X(); // expected-error {{called object type 'int' is not a function or function pointer}}
+}
+
+void test7(int *P, _Complex float Gamma) {
+ P = (P-42) + Gamma*4; // expected-error {{invalid operands to binary expression ('int *' and '_Complex float')}}
+}
+
+
+// rdar://6095061
+int test8(void) {
+ int i;
+ __builtin_choose_expr (0, 42, i) = 10;
+ return i;
+}
+
+
+// PR3386
+struct f { int x : 4; float y[]; };
+int test9(struct f *P) {
+ int R;
+ R = __alignof(P->x); // expected-error {{invalid application of '__alignof' to bit-field}}
+ R = __alignof(P->y); // ok.
+ R = sizeof(P->x); // expected-error {{invalid application of 'sizeof' to bit-field}}
+ return R;
+}
+
+// PR3562
+void test10(int n,...) {
+ struct S {
+ double a[n]; // expected-error {{fields must have a constant size}}
+ } s;
+ double x = s.a[0]; // should not get another error here.
+}
+
+
+#define MYMAX(A,B) __extension__ ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
+
+struct mystruct {int A; };
+void test11(struct mystruct P, float F) {
+ MYMAX(P, F); // expected-error {{invalid operands to binary expression ('typeof (P)' (aka 'struct mystruct') and 'typeof (F)' (aka 'float'))}}
+}
+
+// PR3753
+int test12(const char *X) {
+ return X == "foo"; // expected-warning {{comparison against a string literal is unspecified (use strncmp instead)}}
+}
+
+int test12b(const char *X) {
+ return sizeof(X == "foo"); // no-warning
+}
+
+// rdar://6719156
+void test13(
+ void (^P)()) { // expected-error {{blocks support disabled - compile with -fblocks}}
+ P();
+ P = ^(){}; // expected-error {{blocks support disabled - compile with -fblocks}}
+}
+
+void test14() {
+ typedef long long __m64 __attribute__((__vector_size__(8)));
+ typedef short __v4hi __attribute__((__vector_size__(8)));
+
+ // Ok.
+ __v4hi a;
+ __m64 mask = (__m64)((__v4hi)a > (__v4hi)a);
+}
+
+
+// PR5242
+typedef unsigned long *test15_t;
+
+test15_t test15(void) {
+ return (test15_t)0 + (test15_t)0; // expected-error {{invalid operands to binary expression ('test15_t' (aka 'unsigned long *') and 'test15_t')}}
+}
+
+// rdar://7446395
+void test16(float x) { x == ((void*) 0); } // expected-error {{invalid operands to binary expression}}
+
+// PR6004
+void test17(int x) {
+ x = x / 0; // expected-warning {{division by zero is undefined}}
+ x = x % 0; // expected-warning {{remainder by zero is undefined}}
+ x /= 0; // expected-warning {{division by zero is undefined}}
+ x %= 0; // expected-warning {{remainder by zero is undefined}}
+
+ x = sizeof(x/0); // no warning.
+}
+
+// PR6501
+void test18_a(int a); // expected-note 2 {{'test18_a' declared here}}
+void test18(int b) {
+ test18_a(b, b); // expected-error {{too many arguments to function call, expected 1, have 2}}
+ test18_a(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+}
+
+// PR7569
+void test19() {
+ *(int*)0 = 0; // expected-warning {{indirection of non-volatile null pointer}} \
+ // expected-note {{consider using __builtin_trap}}
+ *(volatile int*)0 = 0; // Ok.
+
+ // rdar://9269271
+ int x = *(int*)0; // expected-warning {{indirection of non-volatile null pointer}} \
+ // expected-note {{consider using __builtin_trap}}
+ int x2 = *(volatile int*)0; // Ok.
+ int *p = &(*(int*)0); // Ok;
+}
+
+int test20(int x) {
+ return x && 4; // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+
+ return x && sizeof(int) == 4; // no warning, RHS is logical op.
+
+ // no warning, this is an idiom for "true" in old C style.
+ return x && (signed char)1;
+
+ return x || 0;
+ return x || 1;
+ return x || -1; // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+ return x || 5; // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+ return x && 0;
+ return x && 1;
+ return x && -1; // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+ return x && 5; // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+ return x || (0);
+ return x || (1);
+ return x || (-1); // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+ return x || (5); // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+ return x && (0);
+ return x && (1);
+ return x && (-1); // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+ return x && (5); // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+
+}
+
+struct Test21; // expected-note 2 {{forward declaration}}
+void test21(volatile struct Test21 *ptr) {
+ void test21_help(void);
+ (test21_help(), *ptr); // expected-error {{incomplete type 'struct Test21' where a complete type is required}}
+ (*ptr, test21_help()); // expected-error {{incomplete type 'struct Test21' where a complete type is required}}
+}
+
+// Make sure we do function/array decay.
+void test22() {
+ if ("help")
+ (void) 0;
+
+ if (test22)
+ (void) 0;
+}
diff --git a/clang/test/Sema/ext_vector_casts.c b/clang/test/Sema/ext_vector_casts.c
new file mode 100644
index 0000000..848ec1f
--- /dev/null
+++ b/clang/test/Sema/ext_vector_casts.c
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fno-lax-vector-conversions %s
+
+typedef __attribute__(( ext_vector_type(2) )) float float2;
+typedef __attribute__(( ext_vector_type(4) )) int int4;
+typedef __attribute__(( ext_vector_type(8) )) short short8;
+typedef __attribute__(( ext_vector_type(4) )) float float4;
+typedef float t3 __attribute__ ((vector_size (16)));
+
+static void test() {
+ float2 vec2;
+ float4 vec4, vec4_2;
+ int4 ivec4;
+ short8 ish8;
+ t3 vec4_3;
+ int *ptr;
+ int i;
+
+ vec4 = 5.0f;
+ vec4 = (float4)5.0f;
+ vec4 = (float4)5;
+ vec4 = (float4)vec4_3;
+
+ ivec4 = (int4)5.0f;
+ ivec4 = (int4)5;
+ ivec4 = (int4)vec4_3;
+
+ i = (int)ivec4; // expected-error {{invalid conversion between vector type 'int4' and integer type 'int' of different size}}
+ i = ivec4; // expected-error {{assigning to 'int' from incompatible type 'int4'}}
+
+ ivec4 = (int4)ptr; // expected-error {{invalid conversion between vector type 'int4' and scalar type 'int *'}}
+
+ vec4 = (float4)vec2; // expected-error {{invalid conversion between ext-vector type 'float4' and 'float2'}}
+
+ ish8 += 5; // expected-error {{can't convert between vector values of different size ('short8' and 'int')}}
+ ish8 += (short)5;
+ ivec4 *= 5;
+ vec4 /= 5.2f;
+ vec4 %= 4; // expected-error {{invalid operands to binary expression ('float4' and 'int')}}
+ ivec4 %= 4;
+ ivec4 += vec4; // expected-error {{can't convert between vector values of different size ('int4' and 'float4')}}
+ ivec4 += (int4)vec4;
+ ivec4 -= ivec4;
+ ivec4 |= ivec4;
+ ivec4 += ptr; // expected-error {{can't convert between vector values of different size ('int4' and 'int *')}}
+}
+
+typedef __attribute__(( ext_vector_type(2) )) float2 vecfloat2; // expected-error{{invalid vector element type 'float2'}}
+
+void inc(float2 f2) {
+ f2++; // expected-error{{cannot increment value of type 'float2'}}
+ __real f2; // expected-error{{invalid type 'float2' to __real operator}}
+}
diff --git a/clang/test/Sema/ext_vector_comparisons.c b/clang/test/Sema/ext_vector_comparisons.c
new file mode 100644
index 0000000..605ba6c
--- /dev/null
+++ b/clang/test/Sema/ext_vector_comparisons.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unreachable-code %s
+
+typedef __attribute__(( ext_vector_type(4) )) int int4;
+
+static int4 test1() {
+ int4 vec, rv;
+
+ // comparisons to self...
+ return vec == vec; // expected-warning{{self-comparison always evaluates to a constant}}
+ return vec != vec; // expected-warning{{self-comparison always evaluates to a constant}}
+ return vec < vec; // expected-warning{{self-comparison always evaluates to a constant}}
+ return vec <= vec; // expected-warning{{self-comparison always evaluates to a constant}}
+ return vec > vec; // expected-warning{{self-comparison always evaluates to a constant}}
+ return vec >= vec; // expected-warning{{self-comparison always evaluates to a constant}}
+}
+
+
+typedef __attribute__(( ext_vector_type(4) )) float float4;
+
+static int4 test2() {
+ float4 vec, rv;
+
+ // comparisons to self. no warning, they're floats
+ return vec == vec; // no-warning
+ return vec != vec; // no-warning
+ return vec < vec; // no-warning
+ return vec <= vec; // no-warning
+ return vec > vec; // no-warning
+ return vec >= vec; // no-warning
+}
diff --git a/clang/test/Sema/ext_vector_components.c b/clang/test/Sema/ext_vector_components.c
new file mode 100644
index 0000000..7d3d52a
--- /dev/null
+++ b/clang/test/Sema/ext_vector_components.c
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef __attribute__(( ext_vector_type(2) )) float float2;
+typedef __attribute__(( ext_vector_type(3) )) float float3;
+typedef __attribute__(( ext_vector_type(4) )) float float4;
+typedef __attribute__(( ext_vector_type(16) )) float float16;
+
+static float4 vec4_0 = (float4)0.5f;
+
+static void test() {
+ float2 vec2, vec2_2;
+ float3 vec3;
+ float4 vec4, vec4_2, *vec4p;
+ float16 vec16;
+ float f;
+
+ vec2.z; // expected-error {{vector component access exceeds type 'float2'}}
+ vec2.xyzw; // expected-error {{vector component access exceeds type 'float2'}}
+ vec4.xyzw; // expected-warning {{expression result unused}}
+ vec4.xyzc; // expected-error {{illegal vector component name 'c'}}
+ vec4.s01z; // expected-error {{illegal vector component name 'z'}}
+ vec2 = vec4.s01; // legal, shorten
+ vec2 = vec4.S01; // legal, shorten
+
+ vec3 = vec4.xyz; // legal, shorten
+ f = vec2.x; // legal, shorten
+ f = vec4.xy.x; // legal, shorten
+
+ vec4_2.xyzx = vec4.xyzw; // expected-error {{vector is not assignable (contains duplicate components)}}
+ vec4_2.xyzz = vec4.xyzw; // expected-error {{vector is not assignable (contains duplicate components)}}
+ vec4_2.xyyw = vec4.xyzw; // expected-error {{vector is not assignable (contains duplicate components)}}
+ vec2.x = f;
+ vec2.xx = vec2_2.xy; // expected-error {{vector is not assignable (contains duplicate components)}}
+ vec2.yx = vec2_2.xy;
+ vec4 = (float4){ 1,2,3,4 };
+ vec4.xy.w; // expected-error {{vector component access exceeds type 'float2'}}
+ vec4.s06; // expected-error {{vector component access exceeds type 'float4'}}
+ vec4.x = vec16.sf;
+ vec4.x = vec16.sF;
+
+ vec4p->yz = vec4p->xy;
+}
+
+float2 lo(float3 x) { return x.lo; }
+float2 hi(float3 x) { return x.hi; }
+float2 ev(float3 x) { return x.even; }
+float2 od(float3 x) { return x.odd; }
diff --git a/clang/test/Sema/extern-redecl.c b/clang/test/Sema/extern-redecl.c
new file mode 100644
index 0000000..c176725
--- /dev/null
+++ b/clang/test/Sema/extern-redecl.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// rdar: // 8125274
+static int a16[]; // expected-warning {{tentative array definition assumed to have one element}}
+
+void f16(void) {
+ extern int a16[];
+}
+
+
+// PR10013: Scope of extern declarations extend past enclosing block
+extern int PR10013_x;
+int PR10013(void) {
+ int *PR10013_x = 0;
+ {
+ extern int PR10013_x;
+ extern int PR10013_x;
+ }
+
+ return PR10013_x; // expected-warning{{incompatible pointer to integer conversion}}
+}
+
diff --git a/clang/test/Sema/flexible-array-init.c b/clang/test/Sema/flexible-array-init.c
new file mode 100644
index 0000000..78fc7c5
--- /dev/null
+++ b/clang/test/Sema/flexible-array-init.c
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+struct one {
+ int a;
+ int values[]; // expected-note 4{{initialized flexible array member 'values' is here}}
+} x = {5, {1, 2, 3}}; // expected-warning{{flexible array initialization is a GNU extension}}
+
+struct one x2 = { 5, 1, 2, 3 }; // expected-warning{{flexible array initialization is a GNU extension}}
+
+void test() {
+ struct one x3 = {5, {1, 2, 3}}; // expected-error{{initialization of flexible array member is not allowed}}
+ struct one x3a = { 5 };
+ struct one x3b = { .a = 5 };
+ struct one x3c = { 5, {} }; // expected-warning{{use of GNU empty initializer extension}} \
+ // expected-warning{{flexible array initialization is a GNU extension}} \
+ // expected-warning{{zero size arrays are an extension}}
+}
+
+struct foo {
+ int x;
+ int y[]; // expected-note 8 {{initialized flexible array member 'y' is here}}
+};
+struct bar { struct foo z; }; // expected-warning {{'z' may not be nested in a struct due to flexible array member}}
+
+struct foo a = { 1, { 2, 3, 4 } }; // expected-warning{{flexible array initialization is a GNU extension}}
+struct bar b = { { 1, { 2, 3, 4 } } }; // expected-error{{initialization of flexible array member is not allowed}}
+struct bar c = { { 1, { } } }; // // expected-warning{{flexible array initialization is a GNU extension}} \
+ // expected-warning{{use of GNU empty initializer extension}} \
+ // expected-warning{{zero size arrays are an extension}}
+struct foo d[1] = { { 1, { 2, 3, 4 } } }; // expected-warning{{'struct foo' may not be used as an array element due to flexible array member}} \
+ // expected-error{{initialization of flexible array member is not allowed}}
+
+struct foo desig_foo = { .y = {2, 3, 4} }; // expected-warning{{flexible array initialization is a GNU extension}}
+struct bar desig_bar = { .z.y = { } }; // expected-warning{{use of GNU empty initializer extension}} \
+ // expected-warning{{zero size arrays are an extension}} \
+ // expected-warning{{flexible array initialization is a GNU extension}}
+struct bar desig_bar2 = { .z.y = { 2, 3, 4} }; // expected-error{{initialization of flexible array member is not allowed}}
+struct foo design_foo2 = { .y = 2 }; // expected-error{{flexible array requires brace-enclosed initializer}}
+
+struct point {
+ int x, y;
+};
+
+struct polygon {
+ int numpoints;
+ struct point points[]; // expected-note{{initialized flexible array member 'points' is here}}
+};
+struct polygon poly = {
+ .points[2] = { 1, 2} }; // expected-error{{designator into flexible array member subobject}}
+
+// PR3540
+struct X {
+ int a;
+ int b;
+ char data[];
+};
+
+struct Y {
+ int a:4;
+ int b:4;
+ int c;
+ int d;
+ int e;
+ struct X xs[]; // expected-warning{{'struct X' may not be used as an array element due to flexible array member}}
+};
+
+
+// PR8217
+struct PR8217a {
+ int i;
+ char v[]; // expected-note 2 {{initialized flexible array member 'v' is here}}
+};
+
+void PR8217() {
+ struct PR8217a foo1 = { .i = 0, .v = "foo" }; // expected-error {{initialization of flexible array member is not allowed}}
+ struct PR8217a foo2 = { .i = 0 };
+ struct PR8217a foo3 = { .i = 0, .v = { 'b', 'a', 'r', '\0' } }; // expected-error {{initialization of flexible array member is not allowed}}
+ struct PR8217a bar;
+}
+
+typedef struct PR10648 {
+ unsigned long n;
+ int v[]; // expected-note {{initialized flexible array member 'v' is here}}
+} PR10648;
+int f10648() {
+ return (PR10648){2, {3, 4}}.v[1]; // expected-error {{initialization of flexible array member is not allowed}}
+}
+
+struct FlexWithUnnamedBitfield { int : 10; int x; int y[]; }; // expected-note {{initialized flexible array member 'y' is here}}
+void TestFlexWithUnnamedBitfield() {
+ struct FlexWithUnnamedBitfield x = {10, {3}}; // expected-error {{initialization of flexible array member is not allowed}}
+}
diff --git a/clang/test/Sema/floating-point-compare.c b/clang/test/Sema/floating-point-compare.c
new file mode 100644
index 0000000..60f971c
--- /dev/null
+++ b/clang/test/Sema/floating-point-compare.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -Wfloat-equal -verify %s
+
+int f1(float x, float y) {
+ return x == y; // expected-warning {{comparing floating point with ==}}
+}
+
+int f2(float x, float y) {
+ return x != y; // expected-warning {{comparing floating point with ==}}
+}
+
+int f3(float x) {
+ return x == x; // no-warning
+}
+
+int f4(float x) {
+ return x == 0.0; // no-warning {{comparing}}
+}
+
+int f5(float x) {
+ return x == __builtin_inf(); // no-warning
+}
+
+int f7(float x) {
+ return x == 3.14159; // expected-warning {{comparing}}
+}
diff --git a/clang/test/Sema/fn-ptr-as-fn-prototype.c b/clang/test/Sema/fn-ptr-as-fn-prototype.c
new file mode 100644
index 0000000..cf95c97
--- /dev/null
+++ b/clang/test/Sema/fn-ptr-as-fn-prototype.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1_only -ast-print %s | FileCheck %s
+
+// This testcase checks the functionality of
+// Sema::ActOn{Start,End}FunctionDeclarator, specifically checking that
+// ActOnEndFunctionDeclarator is called after the typedef so the enum
+// is in the global scope, not the scope of f().
+
+// CHECK: typedef void (*g)();
+typedef void (*g) ();
+// CHECK: enum {
+enum {
+ k = -1
+};
+// CHECK: void f() {
+void f() {}
diff --git a/clang/test/Sema/for.c b/clang/test/Sema/for.c
new file mode 100644
index 0000000..b998f4b
--- /dev/null
+++ b/clang/test/Sema/for.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check C99 6.8.5p3
+void b1 (void) { for (void (*f) (void);;); }
+void b2 (void) { for (void f (void);;); } // expected-error {{declaration of non-local variable}}
+void b3 (void) { for (static int f;;); } // expected-error {{declaration of non-local variable}}
+void b4 (void) { for (typedef int f;;); } // expected-error {{declaration of non-local variable}}
diff --git a/clang/test/Sema/format-string-percentm.c b/clang/test/Sema/format-string-percentm.c
new file mode 100644
index 0000000..1ffc439
--- /dev/null
+++ b/clang/test/Sema/format-string-percentm.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple i686-pc-linux-gnu
+
+// PR 4142 - support glibc extension to printf: '%m' (which prints strerror(errno)).
+int printf(char const*,...);
+void percentm(void) {
+ printf("%m");
+}
diff --git a/clang/test/Sema/format-strings-c90.c b/clang/test/Sema/format-strings-c90.c
new file mode 100644
index 0000000..66ca507
--- /dev/null
+++ b/clang/test/Sema/format-strings-c90.c
@@ -0,0 +1,30 @@
+/* RUN: %clang_cc1 -fsyntax-only -verify -triple i386-apple-darwin9 -pedantic -std=c89 %s
+ */
+
+int scanf(const char * restrict, ...);
+int printf(const char *restrict, ...);
+
+void foo(char **sp, float *fp, int *ip) {
+ scanf("%as", sp); /* expected-warning{{'a' length modifier is not supported by ISO C}} */
+ scanf("%a[abc]", sp); /* expected-warning{{'a' length modifier is not supported by ISO C}} */
+
+ /* TODO: Warn that the 'a' conversion specifier is a C99 feature. */
+ scanf("%a", fp);
+ scanf("%afoobar", fp);
+ printf("%a", 1.0);
+ printf("%as", 1.0);
+ printf("%aS", 1.0);
+ printf("%a[", 1.0);
+ printf("%afoo", 1.0);
+
+ scanf("%da", ip);
+
+ /* Test argument type check for the 'a' length modifier. */
+ scanf("%as", fp); /* expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
+ expected-warning{{'a' length modifier is not supported by ISO C}} */
+ scanf("%aS", fp); /* expected-warning{{format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}}
+ expected-warning{{'a' length modifier is not supported by ISO C}}
+ expected-warning{{'S' conversion specifier is not supported by ISO C}} */
+ scanf("%a[abc]", fp); /* expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
+ expected-warning{{'a' length modifier is not supported by ISO C}} */
+}
diff --git a/clang/test/Sema/format-strings-fixit-ssize_t.c b/clang/test/Sema/format-strings-fixit-ssize_t.c
new file mode 100644
index 0000000..5208a29
--- /dev/null
+++ b/clang/test/Sema/format-strings-fixit-ssize_t.c
@@ -0,0 +1,18 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -pedantic -Wall -fixit %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -pedantic -Wall -Werror %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -E -o - %t | FileCheck %s
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+int printf(char const *, ...);
+
+void test() {
+ typedef signed long int ssize_t;
+ printf("%f", (ssize_t) 42);
+}
+
+// CHECK: printf("%zd", (ssize_t) 42);
diff --git a/clang/test/Sema/format-strings-fixit.c b/clang/test/Sema/format-strings-fixit.c
new file mode 100644
index 0000000..800691e
--- /dev/null
+++ b/clang/test/Sema/format-strings-fixit.c
@@ -0,0 +1,208 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -pedantic -Wall -fixit %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror %t
+// RUN: %clang_cc1 -E -o - %t | FileCheck %s
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+int printf(char const *, ...);
+
+typedef __SIZE_TYPE__ size_t;
+typedef __INTMAX_TYPE__ intmax_t;
+typedef __UINTMAX_TYPE__ uintmax_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+
+void test() {
+ // Basic types
+ printf("%s", (int) 123);
+ printf("abc%0f", "testing testing 123");
+ printf("%u", (long) -12);
+ printf("%p", 123);
+ printf("%c\n", "x");
+ printf("%c\n", 1.23);
+
+ // Larger types
+ printf("%+.2d", (unsigned long long) 123456);
+ printf("%1d", (long double) 1.23);
+
+ // Flag handling
+ printf("%0+s", (unsigned) 31337); // 0 flag should stay
+ printf("%#p", (void *) 0);
+ printf("% +f", 1.23); // + flag should stay
+ printf("%0-f", 1.23); // - flag should stay
+
+ // Positional arguments
+#pragma clang diagnostic push // Don't warn about using positional arguments.
+#pragma clang diagnostic ignored "-Wformat-non-iso"
+ printf("%1$f:%2$.*3$f:%4$.*3$f\n", 1, 2, 3, 4);
+#pragma clang diagnostic pop
+
+ // Precision
+ printf("%10.5d", 1l); // (bug 7394)
+ printf("%.2c", 'a');
+
+ // Ignored flags
+ printf("%0-f", 1.23);
+
+ // Bad length modifiers
+ printf("%hhs", "foo");
+#pragma clang diagnostic push // Don't warn about using positional arguments.
+#pragma clang diagnostic ignored "-Wformat-non-iso"
+ printf("%1$zp", (void *)0);
+#pragma clang diagnostic pop
+
+ // Preserve the original formatting for unsigned integers.
+ unsigned long val = 42;
+ printf("%X", val);
+
+ // size_t, etc.
+ printf("%f", (size_t) 42);
+ printf("%f", (intmax_t) 42);
+ printf("%f", (uintmax_t) 42);
+ printf("%f", (ptrdiff_t) 42);
+
+ // string
+ printf("%ld", "foo");
+
+ // Preserve the original choice of conversion specifier.
+ printf("%o", (long) 42);
+ printf("%u", (long) 42);
+ printf("%x", (long) 42);
+ printf("%X", (long) 42);
+ printf("%i", (unsigned long) 42);
+ printf("%d", (unsigned long) 42);
+ printf("%F", (long double) 42);
+ printf("%e", (long double) 42);
+ printf("%E", (long double) 42);
+ printf("%g", (long double) 42);
+ printf("%G", (long double) 42);
+ printf("%a", (long double) 42);
+ printf("%A", (long double) 42);
+}
+
+int scanf(char const *, ...);
+
+void test2() {
+ char str[100];
+ short shortVar;
+ unsigned short uShortVar;
+ int intVar;
+ unsigned uIntVar;
+ float floatVar;
+ double doubleVar;
+ long double longDoubleVar;
+ long longVar;
+ unsigned long uLongVar;
+ long long longLongVar;
+ unsigned long long uLongLongVar;
+ size_t sizeVar;
+ intmax_t intmaxVar;
+ uintmax_t uIntmaxVar;
+ ptrdiff_t ptrdiffVar;
+
+ scanf("%lf", str);
+ scanf("%f", &shortVar);
+ scanf("%f", &uShortVar);
+ scanf("%p", &intVar);
+ scanf("%Lf", &uIntVar);
+ scanf("%ld", &floatVar);
+ scanf("%f", &doubleVar);
+ scanf("%d", &longDoubleVar);
+ scanf("%f", &longVar);
+ scanf("%f", &uLongVar);
+ scanf("%f", &longLongVar);
+ scanf("%f", &uLongLongVar);
+
+ // Some named ints.
+ scanf("%f", &sizeVar);
+ scanf("%f", &intmaxVar);
+ scanf("%f", &uIntmaxVar);
+ scanf("%f", &ptrdiffVar);
+
+ // Preserve the original formatting.
+ scanf("%o", &longVar);
+ scanf("%u", &longVar);
+ scanf("%x", &longVar);
+ scanf("%X", &longVar);
+ scanf("%i", &uLongVar);
+ scanf("%d", &uLongVar);
+ scanf("%F", &longDoubleVar);
+ scanf("%e", &longDoubleVar);
+ scanf("%E", &longDoubleVar);
+ scanf("%g", &longDoubleVar);
+ scanf("%G", &longDoubleVar);
+ scanf("%a", &longDoubleVar);
+ scanf("%A", &longDoubleVar);
+}
+
+// Validate the fixes.
+// CHECK: printf("%d", (int) 123);
+// CHECK: printf("abc%s", "testing testing 123");
+// CHECK: printf("%lu", (long) -12);
+// CHECK: printf("%d", 123);
+// CHECK: printf("%s\n", "x");
+// CHECK: printf("%f\n", 1.23);
+// CHECK: printf("%+.2lld", (unsigned long long) 123456);
+// CHECK: printf("%1Lf", (long double) 1.23);
+// CHECK: printf("%0u", (unsigned) 31337);
+// CHECK: printf("%p", (void *) 0);
+// CHECK: printf("%+f", 1.23);
+// CHECK: printf("%-f", 1.23);
+// CHECK: printf("%1$d:%2$.*3$d:%4$.*3$d\n", 1, 2, 3, 4);
+// CHECK: printf("%10.5ld", 1l);
+// CHECK: printf("%c", 'a');
+// CHECK: printf("%-f", 1.23);
+// CHECK: printf("%s", "foo");
+// CHECK: printf("%1$p", (void *)0);
+// CHECK: printf("%lX", val);
+// CHECK: printf("%zu", (size_t) 42);
+// CHECK: printf("%jd", (intmax_t) 42);
+// CHECK: printf("%ju", (uintmax_t) 42);
+// CHECK: printf("%td", (ptrdiff_t) 42);
+// CHECK: printf("%s", "foo");
+// CHECK: printf("%lo", (long) 42);
+// CHECK: printf("%lu", (long) 42);
+// CHECK: printf("%lx", (long) 42);
+// CHECK: printf("%lX", (long) 42);
+// CHECK: printf("%li", (unsigned long) 42);
+// CHECK: printf("%ld", (unsigned long) 42);
+// CHECK: printf("%LF", (long double) 42);
+// CHECK: printf("%Le", (long double) 42);
+// CHECK: printf("%LE", (long double) 42);
+// CHECK: printf("%Lg", (long double) 42);
+// CHECK: printf("%LG", (long double) 42);
+// CHECK: printf("%La", (long double) 42);
+// CHECK: printf("%LA", (long double) 42);
+
+// CHECK: scanf("%s", str);
+// CHECK: scanf("%hd", &shortVar);
+// CHECK: scanf("%hu", &uShortVar);
+// CHECK: scanf("%d", &intVar);
+// CHECK: scanf("%u", &uIntVar);
+// CHECK: scanf("%f", &floatVar);
+// CHECK: scanf("%lf", &doubleVar);
+// CHECK: scanf("%Lf", &longDoubleVar);
+// CHECK: scanf("%ld", &longVar);
+// CHECK: scanf("%lu", &uLongVar);
+// CHECK: scanf("%lld", &longLongVar);
+// CHECK: scanf("%llu", &uLongLongVar);
+// CHECK: scanf("%zu", &sizeVar);
+// CHECK: scanf("%jd", &intmaxVar);
+// CHECK: scanf("%ju", &uIntmaxVar);
+// CHECK: scanf("%td", &ptrdiffVar);
+// CHECK: scanf("%lo", &longVar);
+// CHECK: scanf("%lu", &longVar);
+// CHECK: scanf("%lx", &longVar);
+// CHECK: scanf("%lX", &longVar);
+// CHECK: scanf("%li", &uLongVar);
+// CHECK: scanf("%ld", &uLongVar);
+// CHECK: scanf("%LF", &longDoubleVar);
+// CHECK: scanf("%Le", &longDoubleVar);
+// CHECK: scanf("%LE", &longDoubleVar);
+// CHECK: scanf("%Lg", &longDoubleVar);
+// CHECK: scanf("%LG", &longDoubleVar);
+// CHECK: scanf("%La", &longDoubleVar);
+// CHECK: scanf("%LA", &longDoubleVar);
diff --git a/clang/test/Sema/format-strings-int-typedefs.c b/clang/test/Sema/format-strings-int-typedefs.c
new file mode 100644
index 0000000..341d49c
--- /dev/null
+++ b/clang/test/Sema/format-strings-int-typedefs.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+
+int printf(char const *, ...);
+int scanf(char const *, ...);
+
+void test(void) {
+ printf("%jd", 42.0); // expected-warning {{format specifies type 'intmax_t' (aka 'long long')}}
+ printf("%ju", 42.0); // expected-warning {{format specifies type 'uintmax_t' (aka 'unsigned long long')}}
+ printf("%zu", 42.0); // expected-warning {{format specifies type 'size_t' (aka 'unsigned long')}}
+ printf("%td", 42.0); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'int')}}
+ printf("%lc", 42.0); // expected-warning {{format specifies type 'wint_t' (aka 'int')}}
+ printf("%ls", 42.0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+ printf("%S", 42.0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+ printf("%C", 42.0); // expected-warning {{format specifies type 'wchar_t' (aka 'int')}}
+
+ scanf("%jd", 0); // expected-warning {{format specifies type 'intmax_t *' (aka 'long long *')}}
+ scanf("%ju", 0); // expected-warning {{format specifies type 'uintmax_t *' (aka 'unsigned long long *')}}
+ scanf("%zu", 0); // expected-warning {{format specifies type 'size_t *' (aka 'unsigned long *')}}
+ scanf("%td", 0); // expected-warning {{format specifies type 'ptrdiff_t *' (aka 'int *')}}
+ scanf("%lc", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+ scanf("%ls", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+ scanf("%S", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+ scanf("%C", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+
+
+ // typedef size_t et al. to something crazy.
+ typedef void *size_t;
+ typedef void *intmax_t;
+ typedef void *uintmax_t;
+ typedef void *ptrdiff_t;
+
+ // The warning still fires, because it checks the underlying type.
+ printf("%jd", (intmax_t)42); // expected-warning {{format specifies type 'intmax_t' (aka 'long long') but the argument has type 'intmax_t' (aka 'void *')}}
+ printf("%ju", (uintmax_t)42); // expected-warning {{format specifies type 'uintmax_t' (aka 'unsigned long long') but the argument has type 'uintmax_t' (aka 'void *')}}
+ printf("%zu", (size_t)42); // expected-warning {{format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'size_t' (aka 'void *')}}
+ printf("%td", (ptrdiff_t)42); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'int') but the argument has type 'ptrdiff_t' (aka 'void *')}}
+}
diff --git a/clang/test/Sema/format-strings-no-fixit.c b/clang/test/Sema/format-strings-no-fixit.c
new file mode 100644
index 0000000..701e945
--- /dev/null
+++ b/clang/test/Sema/format-strings-no-fixit.c
@@ -0,0 +1,65 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -fsyntax-only -fixit %t
+// RUN: %clang_cc1 -E -o - %t | FileCheck %s
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. Only
+ warnings for format strings within the function call will be
+ fixed by -fixit. Other format strings will be left alone. */
+
+int printf(char const *, ...);
+int scanf(char const *, ...);
+
+void pr9751() {
+ const char kFormat1[] = "%s";
+ printf(kFormat1, 5);
+ printf("%s", 5);
+
+ const char kFormat2[] = "%.3p";
+ void *p;
+ printf(kFormat2, p);
+ printf("%.3p", p);
+
+ const char kFormat3[] = "%0s";
+ printf(kFormat3, "a");
+ printf("%0s", "a");
+
+ const char kFormat4[] = "%hhs";
+ printf(kFormat4, "a");
+ printf("%hhs", "a");
+
+ const char kFormat5[] = "%-0d";
+ printf(kFormat5, 5);
+ printf("%-0d", 5);
+
+ const char kFormat6[] = "%00d";
+ int *i;
+ scanf(kFormat6, i);
+ scanf("%00d", i);
+}
+
+// CHECK: const char kFormat1[] = "%s";
+// CHECK: printf(kFormat1, 5);
+// CHECK: printf("%d", 5);
+
+// CHECK: const char kFormat2[] = "%.3p";
+// CHECK: void *p;
+// CHECK: printf(kFormat2, p);
+// CHECK: printf("%p", p);
+
+// CHECK: const char kFormat3[] = "%0s";
+// CHECK: printf(kFormat3, "a");
+// CHECK: printf("%s", "a");
+
+// CHECK: const char kFormat4[] = "%hhs";
+// CHECK: printf(kFormat4, "a");
+// CHECK: printf("%s", "a");
+
+// CHECK: const char kFormat5[] = "%-0d";
+// CHECK: printf(kFormat5, 5);
+// CHECK: printf("%-d", 5);
+
+// CHECK: const char kFormat6[] = "%00d";
+// CHECK: int *i;
+// CHECK: scanf(kFormat6, i);
+// CHECK: scanf("%d", i);
diff --git a/clang/test/Sema/format-strings-non-iso.c b/clang/test/Sema/format-strings-non-iso.c
new file mode 100644
index 0000000..ed8095f
--- /dev/null
+++ b/clang/test/Sema/format-strings-non-iso.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -pedantic %s
+
+int printf(const char *restrict, ...);
+int scanf(const char * restrict, ...);
+
+void f(void) {
+ char *cp;
+
+ // The 'q' length modifier.
+ printf("%qd", (long long)42); // expected-warning{{'q' length modifier is not supported by ISO C}}
+ scanf("%qd", (long long *)0); // expected-warning{{'q' length modifier is not supported by ISO C}}
+
+ // The 'm' length modifier.
+ scanf("%ms", &cp); // expected-warning{{'m' length modifier is not supported by ISO C}}
+
+ // The 'S' and 'C' conversion specifiers.
+ printf("%S", L"foo"); // expected-warning{{'S' conversion specifier is not supported by ISO C}}
+ printf("%C", L'x'); // expected-warning{{'C' conversion specifier is not supported by ISO C}}
+
+ // Combining 'L' with an integer conversion specifier.
+ printf("%Li", (long long)42); // expected-warning{{using length modifier 'L' with conversion specifier 'i' is not supported by ISO C}}
+ printf("%Lo", (long long)42); // expected-warning{{using length modifier 'L' with conversion specifier 'o' is not supported by ISO C}}
+ printf("%Lu", (long long)42); // expected-warning{{using length modifier 'L' with conversion specifier 'u' is not supported by ISO C}}
+ printf("%Lx", (long long)42); // expected-warning{{using length modifier 'L' with conversion specifier 'x' is not supported by ISO C}}
+ printf("%LX", (long long)42); // expected-warning{{using length modifier 'L' with conversion specifier 'X' is not supported by ISO C}}
+
+ // Positional arguments.
+ printf("%1$d", 42); // expected-warning{{positional arguments are not supported by ISO C}}
+}
diff --git a/clang/test/Sema/format-strings-scanf.c b/clang/test/Sema/format-strings-scanf.c
new file mode 100644
index 0000000..e94af5a
--- /dev/null
+++ b/clang/test/Sema/format-strings-scanf.c
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i386-apple-darwin9 -Wformat-nonliteral %s
+
+// Test that -Wformat=0 works:
+// RUN: %clang_cc1 -fsyntax-only -Werror -Wformat=0 %s
+
+#include <stdarg.h>
+typedef __typeof(sizeof(int)) size_t;
+typedef struct _FILE FILE;
+typedef __WCHAR_TYPE__ wchar_t;
+
+int fscanf(FILE * restrict, const char * restrict, ...) ;
+int scanf(const char * restrict, ...) ;
+int sscanf(const char * restrict, const char * restrict, ...) ;
+int my_scanf(const char * restrict, ...) __attribute__((__format__(__scanf__, 1, 2)));
+
+int vscanf(const char * restrict, va_list);
+int vfscanf(FILE * restrict, const char * restrict, va_list);
+int vsscanf(const char * restrict, const char * restrict, va_list);
+
+void test(const char *s, int *i) {
+ scanf(s, i); // expected-warning{{ormat string is not a string literal}}
+ scanf("%0d", i); // expected-warning{{zero field width in scanf format string is unused}}
+ scanf("%00d", i); // expected-warning{{zero field width in scanf format string is unused}}
+ scanf("%d%[asdfasdfd", i, s); // expected-warning{{no closing ']' for '%[' in scanf format string}}
+
+ unsigned short s_x;
+ scanf ("%" "hu" "\n", &s_x); // no-warning
+ scanf("%y", i); // expected-warning{{invalid conversion specifier 'y'}}
+ scanf("%%"); // no-warning
+ scanf("%%%1$d", i); // no-warning
+ scanf("%1$d%%", i); // no-warning
+ scanf("%d", i, i); // expected-warning{{data argument not used by format string}}
+ scanf("%*d", i); // // expected-warning{{data argument not used by format string}}
+ scanf("%*d", i); // // expected-warning{{data argument not used by format string}}
+ scanf("%*d%1$d", i); // no-warning
+}
+
+void bad_length_modifiers(char *s, void *p, wchar_t *ws, long double *ld) {
+ scanf("%hhs", "foo"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}}
+ scanf("%1$zp", &p); // expected-warning{{length modifier 'z' results in undefined behavior or no effect with 'p' conversion specifier}}
+ scanf("%ls", ws); // no-warning
+ scanf("%#.2Lf", ld); // expected-warning{{invalid conversion specifier '#'}}
+}
+
+// Test that the scanf call site is where the warning is attached. If the
+// format string is somewhere else, point to it in a note.
+void pr9751() {
+ int *i;
+ char str[100];
+ const char kFormat1[] = "%00d"; // expected-note{{format string is defined here}}}
+ scanf(kFormat1, i); // expected-warning{{zero field width in scanf format string is unused}}
+ scanf("%00d", i); // expected-warning{{zero field width in scanf format string is unused}}
+ const char kFormat2[] = "%["; // expected-note{{format string is defined here}}}
+ scanf(kFormat2, str); // expected-warning{{no closing ']' for '%[' in scanf format string}}
+ scanf("%[", str); // expected-warning{{no closing ']' for '%[' in scanf format string}}
+ const char kFormat3[] = "%hu"; // expected-note{{format string is defined here}}}
+ scanf(kFormat3, &i); // expected-warning {{format specifies type 'unsigned short *' but the argument}}
+ const char kFormat4[] = "%lp"; // expected-note{{format string is defined here}}}
+ scanf(kFormat4, &i); // expected-warning {{length modifier 'l' results in undefined behavior or no effect with 'p' conversion specifier}}
+}
+
+void test_variants(int *i, const char *s, ...) {
+ FILE *f = 0;
+ char buf[100];
+
+ fscanf(f, "%ld", i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}}
+ sscanf(buf, "%ld", i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}}
+ my_scanf("%ld", i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}}
+
+ va_list ap;
+ va_start(ap, s);
+
+ vscanf("%[abc", ap); // expected-warning{{no closing ']' for '%[' in scanf format string}}
+ vfscanf(f, "%[abc", ap); // expected-warning{{no closing ']' for '%[' in scanf format string}}
+ vsscanf(buf, "%[abc", ap); // expected-warning{{no closing ']' for '%[' in scanf format string}}
+}
+
+void test_scanlist(int *ip, char *sp, wchar_t *ls) {
+ scanf("%[abc]", ip); // expected-warning{{format specifies type 'char *' but the argument has type 'int *'}}
+ scanf("%h[abc]", sp); // expected-warning{{length modifier 'h' results in undefined behavior or no effect with '[' conversion specifier}}
+ scanf("%l[xyx]", ls); // no-warning
+ scanf("%ll[xyx]", ls); // expected-warning {{length modifier 'll' results in undefined behavior or no effect with '[' conversion specifier}}
+}
+
+void test_alloc_extension(char **sp, wchar_t **lsp, float *fp) {
+ /* Make sure "%a" gets parsed as a conversion specifier for float,
+ * even when followed by an 's', 'S' or '[', which would cause it to be
+ * parsed as a length modifier in C90. */
+ scanf("%as", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'char **'}}
+ scanf("%aS", lsp); // expected-warning{{format specifies type 'float *' but the argument has type 'wchar_t **'}}
+ scanf("%a[bcd]", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'char **'}}
+
+ // Test that the 'm' length modifier is only allowed with s, S, c, C or [.
+ // TODO: Warn that 'm' is an extension.
+ scanf("%ms", sp); // No warning.
+ scanf("%mS", lsp); // No warning.
+ scanf("%mc", sp); // No warning.
+ scanf("%mC", lsp); // No warning.
+ scanf("%m[abc]", sp); // No warning.
+ scanf("%md", sp); // expected-warning{{length modifier 'm' results in undefined behavior or no effect with 'd' conversion specifier}}
+
+ // Test argument type check for the 'm' length modifier.
+ scanf("%ms", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
+ scanf("%mS", fp); // expected-warning{{format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}}
+ scanf("%mc", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
+ scanf("%mC", fp); // expected-warning{{format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}}
+ scanf("%m[abc]", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
+}
+
+void test_longlong(long long *x, unsigned long long *y) {
+ scanf("%Ld", y); // no-warning
+ scanf("%Lu", y); // no-warning
+ scanf("%Lx", y); // no-warning
+ scanf("%Ld", x); // no-warning
+ scanf("%Lu", x); // no-warning
+ scanf("%Lx", x); // no-warning
+ scanf("%Ls", "hello"); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 's' conversion specifier}}
+}
+
+void test_quad(int *x, long long *llx) {
+ scanf("%qd", x); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}}
+ scanf("%qd", llx); // no-warning
+}
diff --git a/clang/test/Sema/format-strings-size_t.c b/clang/test/Sema/format-strings-size_t.c
new file mode 100644
index 0000000..7f88ff3
--- /dev/null
+++ b/clang/test/Sema/format-strings-size_t.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+
+int printf(char const *, ...);
+
+void test(void) {
+ // size_t
+ printf("%zu", (double)42); // expected-warning {{format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'double'}}
+
+ // intmax_t / uintmax_t
+ printf("%jd", (double)42); // expected-warning {{format specifies type 'intmax_t' (aka 'long') but the argument has type 'double'}}
+ printf("%ju", (double)42); // expected-warning {{format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'double'}}
+
+ // ptrdiff_t
+ printf("%td", (double)42); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'long') but the argument has type 'double'}}
+}
diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c
new file mode 100644
index 0000000..086c5c6
--- /dev/null
+++ b/clang/test/Sema/format-strings.c
@@ -0,0 +1,523 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral %s
+
+#include <stdarg.h>
+typedef __typeof(sizeof(int)) size_t;
+typedef struct _FILE FILE;
+int fprintf(FILE *, const char *restrict, ...);
+int printf(const char *restrict, ...); // expected-note{{passing argument to parameter here}}
+int snprintf(char *restrict, size_t, const char *restrict, ...);
+int sprintf(char *restrict, const char *restrict, ...);
+int vasprintf(char **, const char *, va_list);
+int asprintf(char **, const char *, ...);
+int vfprintf(FILE *, const char *restrict, va_list);
+int vprintf(const char *restrict, va_list);
+int vsnprintf(char *, size_t, const char *, va_list);
+int vsprintf(char *restrict, const char *restrict, va_list); // expected-note{{passing argument to parameter here}}
+
+int vscanf(const char *restrict format, va_list arg);
+
+char * global_fmt;
+
+void check_string_literal( FILE* fp, const char* s, char *buf, ... ) {
+
+ char * b;
+ va_list ap;
+ va_start(ap,buf);
+
+ printf(s); // expected-warning {{format string is not a string literal}}
+ vprintf(s,ap); // expected-warning {{format string is not a string literal}}
+ fprintf(fp,s); // expected-warning {{format string is not a string literal}}
+ vfprintf(fp,s,ap); // expected-warning {{format string is not a string literal}}
+ asprintf(&b,s); // expected-warning {{format string is not a string lit}}
+ vasprintf(&b,s,ap); // expected-warning {{format string is not a string literal}}
+ sprintf(buf,s); // expected-warning {{format string is not a string literal}}
+ snprintf(buf,2,s); // expected-warning {{format string is not a string lit}}
+ __builtin___sprintf_chk(buf,0,-1,s); // expected-warning {{format string is not a string literal}}
+ __builtin___snprintf_chk(buf,2,0,-1,s); // expected-warning {{format string is not a string lit}}
+ vsprintf(buf,s,ap); // expected-warning {{format string is not a string lit}}
+ vsnprintf(buf,2,s,ap); // expected-warning {{format string is not a string lit}}
+ vsnprintf(buf,2,global_fmt,ap); // expected-warning {{format string is not a string literal}}
+ __builtin___vsnprintf_chk(buf,2,0,-1,s,ap); // expected-warning {{format string is not a string lit}}
+ __builtin___vsnprintf_chk(buf,2,0,-1,global_fmt,ap); // expected-warning {{format string is not a string literal}}
+
+ vscanf(s, ap); // expected-warning {{format string is not a string literal}}
+
+ // rdar://6079877
+ printf("abc"
+ "%*d", 1, 1); // no-warning
+ printf("abc\
+def"
+ "%*d", 1, 1); // no-warning
+
+ // <rdar://problem/6079850>, allow 'unsigned' (instead of 'int') to be used for both
+ // the field width and precision. This deviates from C99, but is reasonably safe
+ // and is also accepted by GCC.
+ printf("%*d", (unsigned) 1, 1); // no-warning
+}
+
+__attribute__((__format__ (__printf__, 2, 4)))
+void check_string_literal2( FILE* fp, const char* s, char *buf, ... ) {
+ char * b;
+ va_list ap;
+ va_start(ap,buf);
+
+ printf(s); // expected-warning {{format string is not a string literal}}
+ vprintf(s,ap); // no-warning
+ fprintf(fp,s); // expected-warning {{format string is not a string literal}}
+ vfprintf(fp,s,ap); // no-warning
+ asprintf(&b,s); // expected-warning {{format string is not a string lit}}
+ vasprintf(&b,s,ap); // no-warning
+ sprintf(buf,s); // expected-warning {{format string is not a string literal}}
+ snprintf(buf,2,s); // expected-warning {{format string is not a string lit}}
+ __builtin___vsnprintf_chk(buf,2,0,-1,s,ap); // no-warning
+
+ vscanf(s, ap); // expected-warning {{format string is not a string literal}}
+}
+
+void check_conditional_literal(const char* s, int i) {
+ printf(i == 1 ? "yes" : "no"); // no-warning
+ printf(i == 0 ? (i == 1 ? "yes" : "no") : "dont know"); // no-warning
+ printf(i == 0 ? (i == 1 ? s : "no") : "dont know"); // expected-warning{{format string is not a string literal}}
+ printf("yes" ?: "no %d", 1); // expected-warning{{data argument not used by format string}}
+}
+
+void check_writeback_specifier()
+{
+ int x;
+ char *b;
+
+ printf("%n",&x); // expected-warning {{'%n' in format string discouraged}}
+ sprintf(b,"%d%%%n",1, &x); // expected-warning {{'%n' in format string dis}}
+}
+
+void check_invalid_specifier(FILE* fp, char *buf)
+{
+ printf("%s%lb%d","unix",10,20); // expected-warning {{invalid conversion specifier 'b'}}
+ fprintf(fp,"%%%l"); // expected-warning {{incomplete format specifier}}
+ sprintf(buf,"%%%%%ld%d%d", 1, 2, 3); // expected-warning{{format specifies type 'long' but the argument has type 'int'}}
+ snprintf(buf, 2, "%%%%%ld%;%d", 1, 2, 3); // expected-warning{{format specifies type 'long' but the argument has type 'int'}} expected-warning {{invalid conversion specifier ';'}}
+}
+
+void check_null_char_string(char* b)
+{
+ printf("\0this is bogus%d",1); // expected-warning {{string contains '\0'}}
+ snprintf(b,10,"%%%%%d\0%d",1,2); // expected-warning {{string contains '\0'}}
+ printf("%\0d",1); // expected-warning {{string contains '\0'}}
+}
+
+void check_empty_format_string(char* buf, ...)
+{
+ va_list ap;
+ va_start(ap,buf);
+ vprintf("",ap); // expected-warning {{format string is empty}}
+ sprintf(buf, "", 1); // expected-warning {{format string is empty}}
+
+ // Don't warn about empty format strings when there are no data arguments.
+ // This can arise from macro expansions and non-standard format string
+ // functions.
+ sprintf(buf, ""); // no-warning
+}
+
+void check_wide_string(char* b, ...)
+{
+ va_list ap;
+ va_start(ap,b);
+
+ printf(L"foo %d",2); // expected-warning {{incompatible pointer types}}, expected-warning {{should not be a wide string}}
+ vsprintf(b,L"bar %d",ap); // expected-warning {{incompatible pointer types}}, expected-warning {{should not be a wide string}}
+}
+
+void check_asterisk_precision_width(int x) {
+ printf("%*d"); // expected-warning {{'*' specified field width is missing a matching 'int' argument}}
+ printf("%.*d"); // expected-warning {{'.*' specified field precision is missing a matching 'int' argument}}
+ printf("%*d",12,x); // no-warning
+ printf("%*d","foo",x); // expected-warning {{field width should have type 'int', but argument has type 'char *'}}
+ printf("%.*d","foo",x); // expected-warning {{field precision should have type 'int', but argument has type 'char *'}}
+}
+
+void __attribute__((format(printf,1,3))) myprintf(const char*, int blah, ...);
+
+void test_myprintf() {
+ myprintf("%d", 17, 18); // okay
+}
+
+void test_constant_bindings(void) {
+ const char * const s1 = "hello";
+ const char s2[] = "hello";
+ const char *s3 = "hello";
+ char * const s4 = "hello";
+ extern const char s5[];
+
+ printf(s1); // no-warning
+ printf(s2); // no-warning
+ printf(s3); // expected-warning{{not a string literal}}
+ printf(s4); // expected-warning{{not a string literal}}
+ printf(s5); // expected-warning{{not a string literal}}
+}
+
+
+// Test what happens when -Wformat-security only.
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+#pragma GCC diagnostic warning "-Wformat-security"
+
+void test9(char *P) {
+ int x;
+ printf(P); // expected-warning {{format string is not a string literal (potentially insecure)}}
+ printf(P, 42);
+ printf("%n", &x); // expected-warning {{use of '%n' in format string discouraged }}
+}
+
+void torture(va_list v8) {
+ vprintf ("%*.*d", v8); // no-warning
+
+}
+
+void test10(int x, float f, int i, long long lli) {
+ printf("%s"); // expected-warning{{more '%' conversions than data arguments}}
+ printf("%@", 12); // expected-warning{{invalid conversion specifier '@'}}
+ printf("\0"); // expected-warning{{format string contains '\0' within the string body}}
+ printf("xs\0"); // expected-warning{{format string contains '\0' within the string body}}
+ printf("%*d\n"); // expected-warning{{'*' specified field width is missing a matching 'int' argument}}
+ printf("%*.*d\n", x); // expected-warning{{'.*' specified field precision is missing a matching 'int' argument}}
+ printf("%*d\n", f, x); // expected-warning{{field width should have type 'int', but argument has type 'double'}}
+ printf("%*.*d\n", x, f, x); // expected-warning{{field precision should have type 'int', but argument has type 'double'}}
+ printf("%**\n"); // expected-warning{{invalid conversion specifier '*'}}
+ printf("%n", &i); // expected-warning{{use of '%n' in format string discouraged (potentially insecure)}}
+ printf("%d%d\n", x); // expected-warning{{more '%' conversions than data arguments}}
+ printf("%d\n", x, x); // expected-warning{{data argument not used by format string}}
+ printf("%W%d%Z\n", x, x, x); // expected-warning{{invalid conversion specifier 'W'}} expected-warning{{invalid conversion specifier 'Z'}}
+ printf("%"); // expected-warning{{incomplete format specifier}}
+ printf("%.d", x); // no-warning
+ printf("%.", x); // expected-warning{{incomplete format specifier}}
+ printf("%f", 4); // expected-warning{{format specifies type 'double' but the argument has type 'int'}}
+ printf("%qd", lli); // no-warning
+ printf("%qd", x); // expected-warning{{format specifies type 'long long' but the argument has type 'int'}}
+ printf("%qp", (void *)0); // expected-warning{{length modifier 'q' results in undefined behavior or no effect with 'p' conversion specifier}}
+ printf("hhX %hhX", (unsigned char)10); // no-warning
+ printf("llX %llX", (long long) 10); // no-warning
+ // This is fine, because there is an implicit conversion to an int.
+ printf("%d", (unsigned char) 10); // no-warning
+ printf("%d", (long long) 10); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}}
+ printf("%Lf\n", (long double) 1.0); // no-warning
+ printf("%f\n", (long double) 1.0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}}
+ // The man page says that a zero precision is okay.
+ printf("%.0Lf", (long double) 1.0); // no-warning
+ printf("%c\n", "x"); // expected-warning{{format specifies type 'int' but the argument has type 'char *'}}
+ printf("%c\n", 1.23); // expected-warning{{format specifies type 'int' but the argument has type 'double'}}
+ printf("Format %d, is %! %f", 1, 2, 4.4); // expected-warning{{invalid conversion specifier '!'}}
+}
+
+typedef unsigned char uint8_t;
+
+void should_understand_small_integers() {
+ printf("%hhu", (short) 10); // expected-warning{{format specifies type 'unsigned char' but the argument has type 'short'}}
+ printf("%hu\n", (unsigned char) 1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'unsigned char'}}
+ printf("%hu\n", (uint8_t)1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'uint8_t'}}
+}
+
+void test11(void *p, char *s) {
+ printf("%p", p); // no-warning
+ printf("%p", 123); // expected-warning{{format specifies type 'void *' but the argument has type 'int'}}
+ printf("%.4p", p); // expected-warning{{precision used with 'p' conversion specifier, resulting in undefined behavior}}
+ printf("%+p", p); // expected-warning{{flag '+' results in undefined behavior with 'p' conversion specifier}}
+ printf("% p", p); // expected-warning{{flag ' ' results in undefined behavior with 'p' conversion specifier}}
+ printf("%0p", p); // expected-warning{{flag '0' results in undefined behavior with 'p' conversion specifier}}
+ printf("%s", s); // no-warning
+ printf("%+s", p); // expected-warning{{flag '+' results in undefined behavior with 's' conversion specifier}}
+ printf("% s", p); // expected-warning{{flag ' ' results in undefined behavior with 's' conversion specifier}}
+ printf("%0s", p); // expected-warning{{flag '0' results in undefined behavior with 's' conversion specifier}}
+}
+
+void test12(char *b) {
+ unsigned char buf[4];
+ printf ("%.4s\n", buf); // no-warning
+ printf ("%.4s\n", &buf); // expected-warning{{format specifies type 'char *' but the argument has type 'unsigned char (*)[4]'}}
+
+ // Verify that we are checking asprintf
+ asprintf(&b, "%d", "asprintf"); // expected-warning{{format specifies type 'int' but the argument has type 'char *'}}
+}
+
+void test13(short x) {
+ char bel = 007;
+ printf("bel: '0%hhd'\n", bel); // no-warning
+ printf("x: '0%hhd'\n", x); // expected-warning {{format specifies type 'char' but the argument has type 'short'}}
+}
+
+typedef struct __aslclient *aslclient;
+typedef struct __aslmsg *aslmsg;
+int asl_log(aslclient asl, aslmsg msg, int level, const char *format, ...) __attribute__((__format__ (__printf__, 4, 5)));
+void test_asl(aslclient asl) {
+ // Test case from <rdar://problem/7341605>.
+ asl_log(asl, 0, 3, "Error: %m"); // no-warning
+ asl_log(asl, 0, 3, "Error: %W"); // expected-warning{{invalid conversion specifier 'W'}}
+}
+
+// <rdar://problem/7595366>
+typedef enum { A } int_t;
+void f0(int_t x) { printf("%d\n", x); }
+
+// Unicode test cases. These are possibly specific to Mac OS X. If so, they should
+// eventually be moved into a separate test.
+typedef __WCHAR_TYPE__ wchar_t;
+
+void test_unicode_conversions(wchar_t *s) {
+ printf("%S", s); // no-warning
+ printf("%s", s); // expected-warning{{format specifies type 'char *' but the argument has type 'wchar_t *'}}
+ printf("%C", s[0]); // no-warning
+ printf("%c", s[0]);
+ // FIXME: This test reports inconsistent results. On Windows, '%C' expects
+ // 'unsigned short'.
+ // printf("%C", 10);
+ printf("%S", "hello"); // expected-warning{{but the argument has type 'char *'}}
+}
+
+// Mac OS X supports positional arguments in format strings.
+// This is an IEEE extension (IEEE Std 1003.1).
+// FIXME: This is probably not portable everywhere.
+void test_positional_arguments() {
+ printf("%0$", (int)2); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
+ printf("%1$*0$d", (int) 2); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
+ printf("%1$d", (int) 2); // no-warning
+ printf("%1$d", (int) 2, 2); // expected-warning{{data argument not used by format string}}
+ printf("%1$d%1$f", (int) 2); // expected-warning{{format specifies type 'double' but the argument has type 'int'}}
+ printf("%1$2.2d", (int) 2); // no-warning
+ printf("%2$*1$.2d", (int) 2, (int) 3); // no-warning
+ printf("%2$*8$d", (int) 2, (int) 3); // expected-warning{{specified field width is missing a matching 'int' argument}}
+ printf("%%%1$d", (int) 2); // no-warning
+ printf("%1$d%%", (int) 2); // no-warning
+}
+
+// PR 6697 - Handle format strings where the data argument is not adjacent to the format string
+void myprintf_PR_6697(const char *format, int x, ...) __attribute__((__format__(printf,1, 3)));
+void test_pr_6697() {
+ myprintf_PR_6697("%s\n", 1, "foo"); // no-warning
+ myprintf_PR_6697("%s\n", 1, (int)0); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+ // FIXME: Not everything should clearly support positional arguments,
+ // but we need a way to identify those cases.
+ myprintf_PR_6697("%1$s\n", 1, "foo"); // no-warning
+ myprintf_PR_6697("%2$s\n", 1, "foo"); // expected-warning{{data argument position '2' exceeds the number of data arguments (1)}}
+ myprintf_PR_6697("%18$s\n", 1, "foo"); // expected-warning{{data argument position '18' exceeds the number of data arguments (1)}}
+ myprintf_PR_6697("%1$s\n", 1, (int) 0); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+}
+
+void rdar8026030(FILE *fp) {
+ fprintf(fp, "\%"); // expected-warning{{incomplete format specifier}}
+}
+
+void bug7377_bad_length_mod_usage() {
+ // Bad length modifiers
+ printf("%hhs", "foo"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}}
+ printf("%1$zp", (void *)0); // expected-warning{{length modifier 'z' results in undefined behavior or no effect with 'p' conversion specifier}}
+ printf("%ls", L"foo"); // no-warning
+ printf("%#.2Lf", (long double)1.234); // no-warning
+
+ // Bad flag usage
+ printf("%#p", (void *) 0); // expected-warning{{flag '#' results in undefined behavior with 'p' conversion specifier}}
+ printf("%0d", -1); // no-warning
+ printf("%#n", (void *) 0); // expected-warning{{flag '#' results in undefined behavior with 'n' conversion specifier}} expected-warning{{use of '%n' in format string discouraged (potentially insecure)}}
+ printf("%-n", (void *) 0); // expected-warning{{flag '-' results in undefined behavior with 'n' conversion specifier}} expected-warning{{use of '%n' in format string discouraged (potentially insecure)}}
+ printf("%-p", (void *) 0); // no-warning
+
+ // Bad optional amount use
+ printf("%.2c", 'a'); // expected-warning{{precision used with 'c' conversion specifier, resulting in undefined behavior}}
+ printf("%1n", (void *) 0); // expected-warning{{field width used with 'n' conversion specifier, resulting in undefined behavior}} expected-warning{{use of '%n' in format string discouraged (potentially insecure)}}
+ printf("%.9n", (void *) 0); // expected-warning{{precision used with 'n' conversion specifier, resulting in undefined behavior}} expected-warning{{use of '%n' in format string discouraged (potentially insecure)}}
+
+ // Ignored flags
+ printf("% +f", 1.23); // expected-warning{{flag ' ' is ignored when flag '+' is present}}
+ printf("%+ f", 1.23); // expected-warning{{flag ' ' is ignored when flag '+' is present}}
+ printf("%0-f", 1.23); // expected-warning{{flag '0' is ignored when flag '-' is present}}
+ printf("%-0f", 1.23); // expected-warning{{flag '0' is ignored when flag '-' is present}}
+ printf("%-+f", 1.23); // no-warning
+}
+
+// PR 7981 - handle '%lc' (wint_t)
+#ifndef wint_t
+typedef int __darwin_wint_t;
+typedef __darwin_wint_t wint_t;
+#endif
+
+void pr7981(wint_t c, wchar_t c2) {
+ printf("%lc", c); // no-warning
+ printf("%lc", 1.0); // expected-warning{{the argument has type 'double'}}
+ printf("%lc", (char) 1); // no-warning
+ printf("%lc", &c); // expected-warning{{the argument has type 'wint_t *' (aka 'int *')}}
+ printf("%lc", c2); // no-warning
+}
+
+// <rdar://problem/8269537> -Wformat-security says NULL is not a string literal
+void rdar8269537() {
+ // This is likely to crash in most cases, but -Wformat-nonliteral technically
+ // doesn't warn in this case.
+ printf(0); // no-warning
+}
+
+// Handle functions with multiple format attributes.
+extern void rdar8332221_vprintf_scanf(const char *, va_list, const char *, ...)
+ __attribute__((__format__(__printf__, 1, 0)))
+ __attribute__((__format__(__scanf__, 3, 4)));
+
+void rdar8332221(va_list ap, int *x, long *y) {
+ rdar8332221_vprintf_scanf("%", ap, "%d", x); // expected-warning{{incomplete format specifier}}
+}
+
+// PR8641
+void pr8641() {
+ printf("%#x\n", 10);
+ printf("%#X\n", 10);
+}
+
+void posix_extensions() {
+ // Test %'d, "thousands grouping".
+ // <rdar://problem/8816343>
+ printf("%'d\n", 123456789); // no-warning
+ printf("%'i\n", 123456789); // no-warning
+ printf("%'f\n", (float) 1.0); // no-warning
+ printf("%'p\n", (void*) 0); // expected-warning{{results in undefined behavior with 'p' conversion specifier}}
+}
+
+// PR8486
+//
+// Test what happens when -Wformat is on, but -Wformat-security is off.
+#pragma GCC diagnostic warning "-Wformat"
+#pragma GCC diagnostic ignored "-Wformat-security"
+
+void pr8486() {
+ printf("%s", 1); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+}
+
+// PR9314
+// Don't warn about string literals that are PreDefinedExprs, e.g. __func__.
+void pr9314() {
+ printf(__PRETTY_FUNCTION__); // no-warning
+ printf(__func__); // no-warning
+}
+
+int printf(const char * restrict, ...) __attribute__((__format__ (__printf__, 1, 2)));
+
+void rdar9612060(void) {
+ printf("%s", 2); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+}
+
+void check_char(unsigned char x, signed char y) {
+ printf("%c", y); // no-warning
+ printf("%hhu", x); // no-warning
+ printf("%hhi", y); // no-warning
+ printf("%hhi", x); // no-warning
+ printf("%c", x); // no-warning
+ printf("%hhu", y); // no-warning
+}
+
+// Test suppression of individual warnings.
+
+void test_suppress_invalid_specifier() {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-invalid-specifier"
+ printf("%@", 12); // no-warning
+#pragma clang diagnostic pop
+}
+
+// Make sure warnings are on for next test.
+#pragma GCC diagnostic warning "-Wformat"
+#pragma GCC diagnostic warning "-Wformat-security"
+
+// Test that the printf call site is where the warning is attached. If the
+// format string is somewhere else, point to it in a note.
+void pr9751() {
+ const char kFormat1[] = "%d %d \n"; // expected-note{{format string is defined here}}}
+ printf(kFormat1, 0); // expected-warning{{more '%' conversions than data arguments}}
+ printf("%d %s\n", 0); // expected-warning{{more '%' conversions than data arguments}}
+
+ const char kFormat2[] = "%18$s\n"; // expected-note{{format string is defined here}}
+ printf(kFormat2, 1, "foo"); // expected-warning{{data argument position '18' exceeds the number of data arguments (2)}}
+ printf("%18$s\n", 1, "foo"); // expected-warning{{data argument position '18' exceeds the number of data arguments (2)}}
+
+ const char kFormat3[] = "%n"; // expected-note{{format string is defined here}}
+ printf(kFormat3, "as"); // expected-warning{{use of '%n' in format string discouraged}}
+ printf("%n", "as"); // expected-warning{{use of '%n' in format string discouraged}}
+
+ const char kFormat4[] = "%y"; // expected-note{{format string is defined here}}
+ printf(kFormat4, 5); // expected-warning{{invalid conversion specifier 'y'}}
+ printf("%y", 5); // expected-warning{{invalid conversion specifier 'y'}}
+
+ const char kFormat5[] = "%."; // expected-note{{format string is defined here}}
+ printf(kFormat5, 5); // expected-warning{{incomplete format specifier}}
+ printf("%.", 5); // expected-warning{{incomplete format specifier}}
+
+ const char kFormat6[] = "%s"; // expected-note{{format string is defined here}}
+ printf(kFormat6, 5); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+ printf("%s", 5); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+
+ const char kFormat7[] = "%0$"; // expected-note{{format string is defined here}}
+ printf(kFormat7, 5); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
+ printf("%0$", 5); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
+
+ const char kFormat8[] = "%1$d %d"; // expected-note{{format string is defined here}}
+ printf(kFormat8, 4, 4); // expected-warning{{cannot mix positional and non-positional arguments in format string}}
+ printf("%1$d %d", 4, 4); // expected-warning{{cannot mix positional and non-positional arguments in format string}}
+
+ const char kFormat9[] = ""; // expected-note{{format string is defined here}}
+ printf(kFormat9, 4, 4); // expected-warning{{format string is empty}}
+ printf("", 4, 4); // expected-warning{{format string is empty}}
+
+ const char kFormat10[] = "\0%d"; // expected-note{{format string is defined here}}
+ printf(kFormat10, 4); // expected-warning{{format string contains '\0' within the string body}}
+ printf("\0%d", 4); // expected-warning{{format string contains '\0' within the string body}}
+
+ const char kFormat11[] = "%*d"; // expected-note{{format string is defined here}}
+ printf(kFormat11); // expected-warning{{'*' specified field width is missing a matching 'int' argument}}
+ printf("%*d"); // expected-warning{{'*' specified field width is missing a matching 'int' argument}}
+
+ const char kFormat12[] = "%*d"; // expected-note{{format string is defined here}}
+ printf(kFormat12, 4.4); // expected-warning{{field width should have type 'int', but argument has type 'double'}}
+ printf("%*d", 4.4); // expected-warning{{field width should have type 'int', but argument has type 'double'}}
+
+ const char kFormat13[] = "%.3p"; // expected-note{{format string is defined here}}
+ void *p;
+ printf(kFormat13, p); // expected-warning{{precision used with 'p' conversion specifier, resulting in undefined behavior}}
+ printf("%.3p", p); // expected-warning{{precision used with 'p' conversion specifier, resulting in undefined behavior}}
+
+ const char kFormat14[] = "%0s"; // expected-note{{format string is defined here}}
+ printf(kFormat14, "a"); // expected-warning{{flag '0' results in undefined behavior with 's' conversion specifier}}
+ printf("%0s", "a"); // expected-warning{{flag '0' results in undefined behavior with 's' conversion specifier}}
+
+ const char kFormat15[] = "%hhs"; // expected-note{{format string is defined here}}
+ printf(kFormat15, "a"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}}
+ printf("%hhs", "a"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}}
+
+ const char kFormat16[] = "%-0d"; // expected-note{{format string is defined here}}
+ printf(kFormat16, 5); // expected-warning{{flag '0' is ignored when flag '-' is present}}
+ printf("%-0d", 5); // expected-warning{{flag '0' is ignored when flag '-' is present}}
+
+ // Make sure that the "format string is defined here" note is not emitted
+ // when the original string is within the argument expression.
+ printf(1 ? "yes %d" : "no %d"); // expected-warning 2{{more '%' conversions than data arguments}}
+
+ const char kFormat17[] = "%hu"; // expected-note{{format string is defined here}}}
+ printf(kFormat17, (int[]){0}); // expected-warning{{format specifies type 'unsigned short' but the argument}}
+
+ printf("%a", (long double)0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}}
+}
+
+// PR 9466: clang: doesn't know about %Lu, %Ld, and %Lx
+void printf_longlong(long long x, unsigned long long y) {
+ printf("%Ld", y); // no-warning
+ printf("%Lu", y); // no-warning
+ printf("%Lx", y); // no-warning
+ printf("%Ld", x); // no-warning
+ printf("%Lu", x); // no-warning
+ printf("%Lx", x); // no-warning
+ printf("%Ls", "hello"); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 's' conversion specifier}}
+}
+
+void __attribute__((format(strfmon,1,2))) monformat(const char *fmt, ...);
+void __attribute__((format(strftime,1,0))) dateformat(const char *fmt);
+
+// Other formats
+void test_other_formats() {
+ char *str = "";
+ monformat("", 1); // expected-warning{{format string is empty}}
+ monformat(str); // expected-warning{{format string is not a string literal (potentially insecure)}}
+ dateformat(""); // expected-warning{{format string is empty}}
+ dateformat(str); // no-warning (using strftime non literal is not unsafe)
+}
diff --git a/clang/test/Sema/fp16-sema.c b/clang/test/Sema/fp16-sema.c
new file mode 100644
index 0000000..e678f9a
--- /dev/null
+++ b/clang/test/Sema/fp16-sema.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Functions cannot have parameters of type __fp16.
+extern void f (__fp16); // expected-error {{parameters cannot have __fp16 type; did you forget * ?}}
+extern void g (__fp16 *);
+
+extern void (*pf) (__fp16); // expected-error {{parameters cannot have __fp16 type; did you forget * ?}}
+extern void (*pg) (__fp16*);
+
+typedef void(*tf) (__fp16); // expected-error {{parameters cannot have __fp16 type; did you forget * ?}}
+typedef void(*tg) (__fp16*);
+
+void kf(a)
+ __fp16 a; { // expected-error {{parameters cannot have __fp16 type; did you forget * ?}}
+}
+
+void kg(a)
+ __fp16 *a; {
+}
+
+// Functions cannot return type __fp16.
+extern __fp16 f1 (void); // expected-error {{function return value cannot have __fp16 type; did you forget * ?}}
+extern __fp16 *g1 (void);
+
+extern __fp16 (*pf1) (void); // expected-error {{function return value cannot have __fp16 type; did you forget * ?}}
+extern __fp16 *(*gf1) (void);
+
+typedef __fp16 (*tf1) (void); // expected-error {{function return value cannot have __fp16 type; did you forget * ?}}
+typedef __fp16 *(*tg1) (void);
+
diff --git a/clang/test/Sema/fpack-struct.c b/clang/test/Sema/fpack-struct.c
new file mode 100644
index 0000000..37c8444
--- /dev/null
+++ b/clang/test/Sema/fpack-struct.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -DEXPECTED_STRUCT_SIZE=5 -fpack-struct 1 %s
+// RUN: %clang_cc1 -DEXPECTED_STRUCT_SIZE=6 -fpack-struct 2 %s
+
+struct s0 {
+ int x;
+ char c;
+};
+
+int t0[sizeof(struct s0) == EXPECTED_STRUCT_SIZE ?: -1];
diff --git a/clang/test/Sema/freemain.c b/clang/test/Sema/freemain.c
new file mode 100644
index 0000000..eed644d
--- /dev/null
+++ b/clang/test/Sema/freemain.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -ffreestanding %s
+
+// Tests that -ffreestanding disables all special treatment of main().
+
+void* allocate(long size);
+
+void* main(void* context, long size) {
+ if (context) return allocate(size);
+} // expected-warning {{control may reach end of non-void function}}
diff --git a/clang/test/Sema/function-ptr.c b/clang/test/Sema/function-ptr.c
new file mode 100644
index 0000000..ff85272
--- /dev/null
+++ b/clang/test/Sema/function-ptr.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -verify -pedantic
+typedef int unary_int_func(int arg);
+unary_int_func *func;
+
+unary_int_func *set_func(void *p) {
+ func = p; // expected-warning {{converts between void pointer and function pointer}}
+ p = func; // expected-warning {{converts between void pointer and function pointer}}
+
+ return p; // expected-warning {{converts between void pointer and function pointer}}
+}
+
diff --git a/clang/test/Sema/function-redecl.c b/clang/test/Sema/function-redecl.c
new file mode 100644
index 0000000..7076bdf
--- /dev/null
+++ b/clang/test/Sema/function-redecl.c
@@ -0,0 +1,131 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR3588
+void g0(int, int);
+void g0(); // expected-note{{previous declaration is here}} expected-note{{'g0' declared here}}
+
+void f0() {
+ g0(1, 2, 3); // expected-error{{too many arguments to function call}}
+}
+
+void g0(int); // expected-error{{conflicting types for 'g0'}}
+
+int g1(int, int);
+
+typedef int INT;
+
+INT g1(x, y)
+ int x;
+ int y;
+{
+ return x + y;
+}
+
+int g2(int, int); // expected-note{{previous declaration is here}}
+
+INT g2(x) // expected-error{{conflicting types for 'g2'}}
+ int x;
+{
+ return x;
+}
+
+void test() {
+ int f1;
+ {
+ void f1(double);
+ {
+ void f1(double); // expected-note{{previous declaration is here}}
+ {
+ int f1(int); // expected-error{{conflicting types for 'f1'}}
+ }
+ }
+ }
+}
+
+extern void g3(int); // expected-note{{previous declaration is here}}
+static void g3(int x) { } // expected-error{{static declaration of 'g3' follows non-static declaration}}
+
+void test2() {
+ extern int f2; // expected-note 2 {{previous definition is here}}
+ {
+ void f2(int); // expected-error{{redefinition of 'f2' as different kind of symbol}}
+ }
+
+ {
+ int f2;
+ {
+ void f2(int); // expected-error{{redefinition of 'f2' as different kind of symbol}}
+ }
+ }
+}
+
+// <rdar://problem/6127293>
+int outer1(int); // expected-note{{previous declaration is here}}
+struct outer3 { };
+int outer4(int);
+int outer5; // expected-note{{previous definition is here}}
+int *outer7(int);
+
+void outer_test() {
+ int outer1(float); // expected-error{{conflicting types for 'outer1'}}
+ int outer2(int); // expected-note{{previous declaration is here}}
+ int outer3(int); // expected-note{{previous declaration is here}}
+ int outer4(int); // expected-note{{previous declaration is here}}
+ int outer5(int); // expected-error{{redefinition of 'outer5' as different kind of symbol}}
+ int* outer6(int); // expected-note{{previous declaration is here}}
+ int *outer7(int);
+ int outer8(int);
+
+ int *ip7 = outer7(6);
+}
+
+int outer2(float); // expected-error{{conflicting types for 'outer2'}}
+int outer3(float); // expected-error{{conflicting types for 'outer3'}}
+int outer4(float); // expected-error{{conflicting types for 'outer4'}}
+
+void outer_test2(int x) {
+ int* ip = outer6(x); // expected-warning{{use of out-of-scope declaration of 'outer6'}}
+ int *ip2 = outer7(x);
+}
+
+void outer_test3() {
+ int *(*fp)(int) = outer8; // expected-error{{use of undeclared identifier 'outer8'}}
+}
+
+static float outer8(float); // okay
+
+enum e { e1, e2 };
+
+// GNU extension: prototypes and K&R function definitions
+int isroot(short x, // expected-note{{previous declaration is here}}
+ enum e);
+
+int isroot(x, y)
+ short x; // expected-warning{{promoted type 'int' of K&R function parameter is not compatible with the parameter type 'short' declared in a previous prototype}}
+ unsigned int y;
+{
+ return x == 1;
+}
+
+// PR3817
+void *h0(unsigned a0, ...);
+extern __typeof (h0) h1 __attribute__((__sentinel__));
+extern __typeof (h1) h1 __attribute__((__sentinel__));
+
+// PR3840
+void i0 (unsigned short a0);
+extern __typeof (i0) i1;
+extern __typeof (i1) i1;
+
+typedef int a();
+typedef int a2(int*);
+a x;
+a2 x2; // expected-note{{passing argument to parameter here}}
+void test_x() {
+ x(5);
+ x2(5); // expected-warning{{incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'}}
+}
+
+enum e0 {one};
+void f3();
+void f3(enum e0 x) {}
diff --git a/clang/test/Sema/function.c b/clang/test/Sema/function.c
new file mode 100644
index 0000000..1b0dc2a
--- /dev/null
+++ b/clang/test/Sema/function.c
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
+
+// PR1892, PR11354
+void f(double a[restrict][5]) { __typeof(a) x = 10; } // expected-warning {{(aka 'double (*restrict)[5]')}}
+
+int foo (__const char *__path);
+int foo(__const char *__restrict __file);
+
+void func(const char*); // expected-note {{previous declaration is here}}
+void func(char*); // expected-error{{conflicting types for 'func'}}
+
+void g(int (*)(const void **, const void **));
+void g(int (*compar)()) {
+}
+
+void h(); // expected-note {{previous declaration is here}}
+void h (const char *fmt, ...) {} // expected-error{{conflicting types for 'h'}}
+
+// PR1965
+int t5(b); // expected-error {{parameter list without types}}
+int t6(int x, g); // expected-warning {{type specifier missing, defaults to 'int'}}
+
+int t7(, ); // expected-error {{expected parameter declarator}} expected-error {{expected parameter declarator}}
+int t8(, int a); // expected-error {{expected parameter declarator}}
+int t9(int a, ); // expected-error {{expected parameter declarator}}
+
+
+// PR2042
+void t10(){}
+void t11(){t10(1);} // expected-warning{{too many arguments}}
+
+// PR3208
+void t12(int) {} // expected-error{{parameter name omitted}}
+
+// PR2790
+void t13() {
+ return 0; // expected-error {{void function 't13' should not return a value}}
+}
+int t14() {
+ return; // expected-error {{non-void function 't14' should return a value}}
+}
+
+// <rdar://problem/6097326>
+y(y) { return y; } // expected-warning{{parameter 'y' was not declared, defaulting to type 'int'}} \
+ // expected-warning{{type specifier missing, defaults to 'int'}}
+
+
+// PR3137, <rdar://problem/6127293>
+extern int g0_3137(void);
+void f0_3137() {
+ int g0_3137(void);
+}
+void f1_3137() {
+ int (*fp)(void) = g0_3137;
+}
+
+void f1static() {
+ static void f2static(int); // expected-error{{function declared in block scope cannot have 'static' storage class}}
+ register void f2register(int); // expected-error{{illegal storage class on function}}
+}
+
+struct incomplete_test a(void) {} // expected-error{{incomplete result type 'struct incomplete_test' in function definition}} \
+ // expected-note{{forward declaration of 'struct incomplete_test'}}
+
+
+extern __inline
+__attribute__((__gnu_inline__))
+void gnu_inline1() {}
+
+void
+__attribute__((__gnu_inline__)) // expected-warning {{'gnu_inline' attribute requires function to be marked 'inline', attribute ignored}}
+gnu_inline2() {}
+
+
+// rdar://6802350
+inline foo_t invalid_type() { // expected-error {{unknown type name 'foo_t'}}
+}
+
+typedef void fn_t(void);
+fn_t t17;
+
+// PR4049
+unknown_type t18(void*) { // expected-error {{unknown type name 'unknown_type'}} expected-error{{parameter name omitted}}
+}
+
+unknown_type t19(int* P) { // expected-error {{unknown type name 'unknown_type'}}
+ P = P+1; // no warning.
+}
+
+// missing ',' before '...'
+void t20(int i...) { } // expected-error {{requires a comma}}
+
+int n;
+void t21(int n, int (*array)[n]);
diff --git a/clang/test/Sema/generic-selection.c b/clang/test/Sema/generic-selection.c
new file mode 100644
index 0000000..8cef975
--- /dev/null
+++ b/clang/test/Sema/generic-selection.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c1x -fsyntax-only -verify %s
+
+void foo(int n) {
+ (void) _Generic(0,
+ struct A: 0, // expected-error {{type 'struct A' in generic association incomplete}}
+ void(): 0, // expected-error {{type 'void ()' in generic association not an object type}}
+ int[n]: 0); // expected-error {{type 'int [n]' in generic association is a variably modified type}}
+
+ (void) _Generic(0,
+ void (*)(): 0, // expected-note {{compatible type 'void (*)()' specified here}}
+ void (*)(void): 0); // expected-error {{type 'void (*)(void)' in generic association compatible with previously specified type 'void (*)()'}}
+
+ (void) _Generic((void (*)()) 0, // expected-error {{controlling expression type 'void (*)()' compatible with 2 generic association types}}
+ void (*)(int): 0, // expected-note {{compatible type 'void (*)(int)' specified here}}
+ void (*)(void): 0); // expected-note {{compatible type 'void (*)(void)' specified here}}
+
+ (void) _Generic(0, // expected-error {{controlling expression type 'int' not compatible with any generic association type}}
+ char: 0, short: 0, long: 0);
+
+ int a1[_Generic(0, int: 1, short: 2, float: 3, default: 4) == 1 ? 1 : -1];
+ int a2[_Generic(0, default: 1, short: 2, float: 3, int: 4) == 4 ? 1 : -1];
+ int a3[_Generic(0L, int: 1, short: 2, float: 3, default: 4) == 4 ? 1 : -1];
+ int a4[_Generic(0L, default: 1, short: 2, float: 3, int: 4) == 1 ? 1 : -1];
+ int a5[_Generic(0, int: 1, short: 2, float: 3) == 1 ? 1 : -1];
+ int a6[_Generic(0, short: 1, float: 2, int: 3) == 3 ? 1 : -1];
+}
diff --git a/clang/test/Sema/gnu89.c b/clang/test/Sema/gnu89.c
new file mode 100644
index 0000000..189e6b0
--- /dev/null
+++ b/clang/test/Sema/gnu89.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only -verify
+
+int f(int restrict);
+
+void main() {} // expected-warning {{return type of 'main' is not 'int'}}
diff --git a/clang/test/Sema/heinous-extensions-off.c b/clang/test/Sema/heinous-extensions-off.c
new file mode 100644
index 0000000..9b80d34
--- /dev/null
+++ b/clang/test/Sema/heinous-extensions-off.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify
+
+int foo() {
+ int a;
+ // PR3788
+ asm("nop" : : "m"((int)(a))); // expected-error {{cast in a inline asm context requiring an l-value}}
+ // PR3794
+ asm("nop" : "=r"((unsigned)a)); // expected-error {{cast in a inline asm context requiring an l-value}}
+}
+
diff --git a/clang/test/Sema/heinous-extensions-on.c b/clang/test/Sema/heinous-extensions-on.c
new file mode 100644
index 0000000..176f472
--- /dev/null
+++ b/clang/test/Sema/heinous-extensions-on.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -verify -fheinous-gnu-extensions
+
+void foo() {
+ int a;
+ // PR3788
+ asm("nop" : : "m"((int)(a))); // expected-warning {{cast in a inline asm context requiring an l-value}}
+ // PR3794
+ asm("nop" : "=r"((unsigned)a)); // expected-warning {{cast in a inline asm context requiring an l-value}}
+}
diff --git a/clang/test/Sema/i-c-e.c b/clang/test/Sema/i-c-e.c
new file mode 100644
index 0000000..ee61ac3
--- /dev/null
+++ b/clang/test/Sema/i-c-e.c
@@ -0,0 +1,75 @@
+// RUN: %clang %s -ffreestanding -fsyntax-only -Xclang -verify -pedantic -fpascal-strings -std=c99
+
+#include <stdint.h>
+#include <limits.h>
+
+int a() {int p; *(1 ? &p : (void*)(0 && (a(),1))) = 10;} // expected-error {{incomplete type 'void' is not assignable}}
+
+// rdar://6091492 - ?: with __builtin_constant_p as the operand is an i-c-e.
+int expr;
+char w[__builtin_constant_p(expr) ? expr : 1];
+
+char v[sizeof(__builtin_constant_p(0)) == sizeof(int) ? 1 : -1];
+
+int implicitConversion = 1.0;
+char floatArith[(int)(1.0+2.0)]; // expected-warning {{must be an integer constant expression}}
+
+// __builtin_constant_p as the condition of ?: allows arbitrary foldable
+// constants to be transmogrified into i-c-e's.
+char b[__builtin_constant_p((int)(1.0+2.0)) ? (int)(1.0+2.0) : -1];
+
+struct c {
+ int a : (
+ __builtin_constant_p((int)(1.0+2.0)) ? (int)(1.0+
+ expr // expected-error {{expression is not an integer constant expression}}
+ ) : -1);
+};
+
+
+
+
+void test1(int n, int* p) { *(n ? p : (void *)(7-7)) = 1; }
+void test2(int n, int* p) { *(n ? p : (void *)0) = 1; }
+
+
+
+char array[1024/(sizeof (long))];
+
+int x['\xBb' == (char) 187 ? 1: -1];
+
+// PR1992
+void func(int x)
+{
+ switch (x) {
+ case sizeof("abc"): break;
+ case sizeof("loooong"): func(4);
+ case sizeof("\ploooong"): func(4);
+ }
+}
+
+
+// rdar://4213768
+int expr;
+char y[__builtin_constant_p(expr) ? -1 : 1];
+char z[__builtin_constant_p(4) ? 1 : -1];
+
+// Comma tests
+int comma1[0?1,2:3];
+int comma2[1||(1,2)]; // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+int comma3[(1,2)]; // expected-warning {{size of static array must be an integer constant expression}}
+
+// Pointer + __builtin_constant_p
+char pbcp[__builtin_constant_p(4) ? (intptr_t)&expr : 0]; // expected-error {{variable length array declaration not allowed at file scope}}
+
+int illegaldiv1a[1 || 1/0];
+int illegaldiv1b[1 && 1/0]; //expected-error{{variable length array declaration not allowed at file scope}}
+
+int illegaldiv2[1/0]; // expected-error {{variable length array declaration not allowed at file scope}}
+int illegaldiv3[INT_MIN / -1]; // expected-error {{variable length array declaration not allowed at file scope}}
+// PR9262
+int illegaldiv4[0 / (1 / 0)]; // expected-error {{variable length array declaration not allowed at file scope}}
+
+int chooseexpr[__builtin_choose_expr(1, 1, expr)];
+int realop[(__real__ 4) == 4 ? 1 : -1];
+int imagop[(__imag__ 4) == 0 ? 1 : -1];
diff --git a/clang/test/Sema/illegal-types.c b/clang/test/Sema/illegal-types.c
new file mode 100644
index 0000000..819b38a
--- /dev/null
+++ b/clang/test/Sema/illegal-types.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -x c++ -std=c++98 %s
+
+void a (void []()); // expected-error{{'type name' declared as array of functions}}
+void b (void p[]()); // expected-error{{'p' declared as array of functions}}
+void c (int &[]); // expected-error{{'type name' declared as array of references}}
+void d (int &p[]); // expected-error{{'p' declared as array of references}}
+
diff --git a/clang/test/Sema/implicit-builtin-decl.c b/clang/test/Sema/implicit-builtin-decl.c
new file mode 100644
index 0000000..8cdd365
--- /dev/null
+++ b/clang/test/Sema/implicit-builtin-decl.c
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+void f() {
+ int *ptr = malloc(sizeof(int) * 10); // expected-warning{{implicitly declaring library function 'malloc' with type}} \
+ // expected-note{{please include the header <stdlib.h> or explicitly provide a declaration for 'malloc'}} \
+ // expected-note{{'malloc' is a builtin with type 'void *}}
+}
+
+void *alloca(__SIZE_TYPE__); // redeclaration okay
+
+int *calloc(__SIZE_TYPE__, __SIZE_TYPE__); // expected-warning{{incompatible redeclaration of library function 'calloc'}} \
+ // expected-note{{'calloc' is a builtin with type 'void *}}
+
+
+void g(int malloc) { // okay: these aren't functions
+ int calloc = 1;
+}
+
+void h() {
+ int malloc(int); // expected-warning{{incompatible redeclaration of library function 'malloc'}}
+ int strcpy(int); // expected-warning{{incompatible redeclaration of library function 'strcpy'}} \
+ // expected-note{{'strcpy' is a builtin with type 'char *(char *, const char *)'}}
+}
+
+void f2() {
+ fprintf(0, "foo"); // expected-warning{{declaration of built-in function 'fprintf' requires inclusion of the header <stdio.h>}} \
+ expected-warning {{implicit declaration of function 'fprintf' is invalid in C99}}
+}
+
+// PR2892
+void __builtin_object_size(); // expected-error{{conflicting types}} \
+// expected-note{{'__builtin_object_size' is a builtin with type}}
+
+int a[10];
+
+int f0() {
+ return __builtin_object_size(&a); // expected-error {{too few arguments to function}}
+}
+
+void * realloc(void *p, int size) { // expected-warning{{incompatible redeclaration of library function 'realloc'}} \
+// expected-note{{'realloc' is a builtin with type 'void *(void *,}}
+ return p;
+}
+
+// PR3855
+void snprintf(); // expected-warning{{incompatible redeclaration of library function 'snprintf'}} \
+ // expected-note{{'snprintf' is a builtin}}
+
+int
+main(int argc, char *argv[])
+{
+ snprintf();
+}
+
+void snprintf() { }
+
+// PR8316
+void longjmp(); // expected-warning{{declaration of built-in function 'longjmp' requires inclusion of the header <setjmp.h>}}
diff --git a/clang/test/Sema/implicit-builtin-freestanding.c b/clang/test/Sema/implicit-builtin-freestanding.c
new file mode 100644
index 0000000..505e522
--- /dev/null
+++ b/clang/test/Sema/implicit-builtin-freestanding.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -ffreestanding %s
+
+int malloc(int a) { return a; }
+
diff --git a/clang/test/Sema/implicit-builtin-redecl.c b/clang/test/Sema/implicit-builtin-redecl.c
new file mode 100644
index 0000000..9fb7e62
--- /dev/null
+++ b/clang/test/Sema/implicit-builtin-redecl.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR3592
+static void* malloc(int);
+static void* malloc(int size) {
+ return ((void*)0); /*do not use heap in this file*/
+}
+
+void *calloc(int, int, int); // expected-warning{{incompatible redeclaration of library function 'calloc'}} \
+// expected-note{{'calloc' is a builtin with type 'void *}}
+
+void f1(void) {
+ calloc(0, 0, 0);
+}
+
+void f2() {
+ int index = 1;
+}
+
+static int index;
+
+int f3() {
+ return index << 2;
+}
+
+typedef int rindex;
diff --git a/clang/test/Sema/implicit-cast.c b/clang/test/Sema/implicit-cast.c
new file mode 100644
index 0000000..088b195
--- /dev/null
+++ b/clang/test/Sema/implicit-cast.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+static char *test1(int cf) {
+ return cf ? "abc" : 0;
+}
+static char *test2(int cf) {
+ return cf ? 0 : "abc";
+}
diff --git a/clang/test/Sema/implicit-decl.c b/clang/test/Sema/implicit-decl.c
new file mode 100644
index 0000000..ffab9a6
--- /dev/null
+++ b/clang/test/Sema/implicit-decl.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Werror
+
+typedef int int32_t;
+typedef unsigned char Boolean;
+
+extern int printf(__const char *__restrict __format, ...); // expected-note{{'printf' declared here}}
+
+void func() {
+ int32_t *vector[16];
+ const char compDesc[16 + 1];
+ int32_t compCount = 0;
+ if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-note {{previous implicit declaration is here}} \
+ expected-error {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}}
+ }
+
+ printg("Hello, World!\n"); // expected-error{{implicit declaration of function 'printg' is invalid in C99}} \
+ // expected-note{{did you mean 'printf'?}}
+
+ __builtin_is_les(1, 3); // expected-error{{use of unknown builtin '__builtin_is_les'}}
+}
+Boolean _CFCalendarDecomposeAbsoluteTimeV(const char *componentDesc, int32_t **vector, int32_t count) { // expected-error{{conflicting types for '_CFCalendarDecomposeAbsoluteTimeV'}}
+ return 0;
+}
+
+
+// Test the typo-correction callback in Sema::ImplicitlyDefineFunction
+extern int sformatf(char *str, __const char *__restrict __format, ...); // expected-note{{'sformatf' declared here}}
+void test_implicit() {
+ int formats = 0;
+ formatd("Hello, World!\n"); // expected-error{{implicit declaration of function 'formatd' is invalid in C99}} \
+ // expected-note{{did you mean 'sformatf'?}}
+}
diff --git a/clang/test/Sema/implicit-def.c b/clang/test/Sema/implicit-def.c
new file mode 100644
index 0000000..6caa090
--- /dev/null
+++ b/clang/test/Sema/implicit-def.c
@@ -0,0 +1,8 @@
+/* RUN: %clang_cc1 -fsyntax-only %s -std=c89
+ * RUN: not %clang_cc1 -fsyntax-only %s -std=c99 -pedantic-errors
+ */
+
+int A() {
+ return X();
+}
+
diff --git a/clang/test/Sema/implicit-int.c b/clang/test/Sema/implicit-int.c
new file mode 100644
index 0000000..3063db6
--- /dev/null
+++ b/clang/test/Sema/implicit-int.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify -pedantic
+
+foo() { // expected-warning {{type specifier missing, defaults to 'int'}}
+ return 0;
+}
+
+y; // expected-warning {{type specifier missing, defaults to 'int'}}
+
+// rdar://6131634
+void f((x)); // expected-warning {{type specifier missing, defaults to 'int'}}
+
+
+// PR3702
+#define PAD(ms10) { \
+ register i; \
+}
+
+#define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */
+
+void
+h19_insline(n) // expected-warning {{parameter 'n' was not declared, defaulting to type 'int'}}
+{
+ ILPAD(); // expected-warning {{type specifier missing, defaults to 'int'}}
+}
+
+struct foo {
+ __extension__ __attribute__((packed)) x : 4; // expected-warning {{type specifier missing, defaults to 'int'}}
+};
diff --git a/clang/test/Sema/incompatible-sign.c b/clang/test/Sema/incompatible-sign.c
new file mode 100644
index 0000000..6249feb
--- /dev/null
+++ b/clang/test/Sema/incompatible-sign.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+int a(int* x); // expected-note{{passing argument to parameter 'x' here}}
+int b(unsigned* y) { return a(y); } // expected-warning {{passing 'unsigned int *' to parameter of type 'int *' converts between pointers to integer types with different sign}}
+
diff --git a/clang/test/Sema/incomplete-call.c b/clang/test/Sema/incomplete-call.c
new file mode 100644
index 0000000..d34bda5
--- /dev/null
+++ b/clang/test/Sema/incomplete-call.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct foo; // expected-note 3 {{forward declaration of 'struct foo'}}
+
+struct foo a(); // expected-note {{'a' declared here}}
+void b(struct foo);
+void c();
+
+void func(void *p) {
+ a(); // expected-error{{calling 'a' with incomplete return type 'struct foo'}}
+ b(*(struct foo*)p); // expected-error{{argument type 'struct foo' is incomplete}}
+ c(*(struct foo*)p); // expected-error{{argument type 'struct foo' is incomplete}}
+}
diff --git a/clang/test/Sema/incomplete-decl.c b/clang/test/Sema/incomplete-decl.c
new file mode 100644
index 0000000..0214a0c
--- /dev/null
+++ b/clang/test/Sema/incomplete-decl.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct foo; // expected-note 5 {{forward declaration of 'struct foo'}}
+
+void b; // expected-error {{variable has incomplete type 'void'}}
+struct foo f; // expected-error{{tentative definition has type 'struct foo' that is never completed}}
+
+static void c; // expected-error {{variable has incomplete type 'void'}}
+static struct foo g; // expected-warning {{tentative definition of variable with internal linkage has incomplete non-array type 'struct foo'}} \
+ expected-error{{tentative definition has type 'struct foo' that is never completed}}
+
+extern void d;
+extern struct foo e;
+
+int ary[]; // expected-warning {{tentative array definition assumed to have one element}}
+struct foo bary[]; // expected-error {{array has incomplete element type 'struct foo'}}
+
+void func() {
+ int ary[]; // expected-error{{definition of variable with array type needs an explicit size or an initializer}}
+ void b; // expected-error {{variable has incomplete type 'void'}}
+ struct foo f; // expected-error {{variable has incomplete type 'struct foo'}}
+}
+
+int h[]; // expected-warning {{tentative array definition assumed to have one element}}
+int (*i)[] = &h+1; // expected-error {{arithmetic on a pointer to an incomplete type 'int []'}}
+
+struct bar j = {1}; // expected-error {{variable has incomplete type 'struct bar'}} \
+ expected-note {{forward declaration of 'struct bar'}}
+struct bar k;
+struct bar { int a; };
+
diff --git a/clang/test/Sema/indirect-goto.c b/clang/test/Sema/indirect-goto.c
new file mode 100644
index 0000000..4c1c6c3
--- /dev/null
+++ b/clang/test/Sema/indirect-goto.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct c {int x;};
+int a(struct c x, long long y) {
+ void const* l1_ptr = &&l1;
+ goto *l1_ptr;
+l1:
+ goto *x; // expected-error{{incompatible type}}
+ goto *y; // expected-warning{{incompatible integer to pointer conversion}}
+}
+
diff --git a/clang/test/Sema/init-struct-qualified.c b/clang/test/Sema/init-struct-qualified.c
new file mode 100644
index 0000000..49ec7cc
--- /dev/null
+++ b/clang/test/Sema/init-struct-qualified.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify < %s
+typedef float CGFloat;
+typedef struct _NSPoint { CGFloat x; CGFloat y; } NSPoint;
+typedef struct _NSSize { CGFloat width; CGFloat height; } NSSize;
+typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect;
+
+extern const NSPoint NSZeroPoint;
+
+extern NSSize canvasSize();
+void func() {
+ const NSRect canvasRect = { NSZeroPoint, canvasSize() };
+}
diff --git a/clang/test/Sema/init-vector.c b/clang/test/Sema/init-vector.c
new file mode 100644
index 0000000..f0cf32b
--- /dev/null
+++ b/clang/test/Sema/init-vector.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef float __attribute__((vector_size (16))) v4f_t;
+
+typedef union {
+ struct {
+ float x, y, z, w;
+ }s;
+ v4f_t v;
+} vector_t;
+
+
+vector_t foo(v4f_t p)
+{
+ vector_t v = {.v = p};
+ return v;
+}
diff --git a/clang/test/Sema/init.c b/clang/test/Sema/init.c
new file mode 100644
index 0000000..81a665d
--- /dev/null
+++ b/clang/test/Sema/init.c
@@ -0,0 +1,159 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -ffreestanding
+
+#include <stddef.h>
+#include <stdint.h>
+
+typedef void (* fp)(void);
+void foo(void);
+
+// PR clang/3377
+fp a[(short int)1] = { foo };
+
+int myArray[5] = {1, 2, 3, 4, 5};
+int *myPointer2 = myArray;
+int *myPointer = &(myArray[2]);
+
+
+extern int x;
+void *g = &x;
+int *h = &x;
+
+struct union_crash
+{
+ union
+ {
+ };
+};
+
+int test() {
+ int a[10];
+ int b[10] = a; // expected-error {{array initializer must be an initializer list}}
+ int +; // expected-error {{expected identifier or '('}}
+
+ struct union_crash u = { .d = 1 }; // expected-error {{field designator 'd' does not refer to any field in type 'struct union_crash'}}
+}
+
+
+// PR2050
+struct cdiff_cmd {
+ const char *name;
+ unsigned short argc;
+ int (*handler)();
+};
+int cdiff_cmd_open();
+struct cdiff_cmd commands[] = {
+ {"OPEN", 1, &cdiff_cmd_open }
+};
+
+// PR2348
+static struct { int z; } s[2];
+int *t = &(*s).z;
+
+// PR2349
+short *a2(void)
+{
+ short int b;
+ static short *bp = &b; // expected-error {{initializer element is not a compile-time constant}}
+
+ return bp;
+}
+
+int pbool(void) {
+ typedef const _Bool cbool;
+ _Bool pbool1 = (void *) 0;
+ cbool pbool2 = &pbool;
+ return pbool2;
+}
+
+
+// rdar://5870981
+union { float f; unsigned u; } u = { 1.0f };
+
+// rdar://6156694
+int f3(int x) { return x; }
+typedef void (*vfunc)(void);
+void *bar = (vfunc) f3;
+
+// PR2747
+struct sym_reg {
+ char nc_gpreg;
+};
+int sym_fw1a_scr[] = {
+ ((int)(&((struct sym_reg *)0)->nc_gpreg)) & 0,
+ 8 * ((int)(&((struct sym_reg *)0)->nc_gpreg))
+};
+
+// PR3001
+struct s1 s2 = { // expected-error {{variable has incomplete type 'struct s1'}} \
+ // expected-note {{forward declaration of 'struct s1'}}
+ .a = sizeof(struct s3), // expected-error {{invalid application of 'sizeof'}} \
+ // expected-note{{forward declaration of 'struct s3'}}
+ .b = bogus // expected-error {{use of undeclared identifier 'bogus'}}
+}
+
+// PR3382
+char t[] = ("Hello");
+
+// <rdar://problem/6094855>
+typedef struct { } empty;
+
+typedef struct {
+ empty e;
+ int i2;
+} st;
+
+st st1 = { .i2 = 1 };
+
+// <rdar://problem/6096826>
+struct {
+ int a;
+ int z[2];
+} y = { .z = {} };
+
+int bbb[10];
+
+struct foo2 {
+ uintptr_t a;
+};
+
+struct foo2 bar2[] = {
+ { (intptr_t)bbb }
+};
+
+struct foo2 bar3 = { 1, 2 }; // expected-warning{{excess elements in struct initializer}}
+
+int* ptest1 = __builtin_choose_expr(1, (int*)0, (int*)0);
+
+typedef int32_t ivector4 __attribute((vector_size(16)));
+ivector4 vtest1 = 1 ? (ivector4){1} : (ivector4){1};
+ivector4 vtest2 = __builtin_choose_expr(1, (ivector4){1}, (ivector4){1});
+
+uintptr_t ptrasintadd1 = (uintptr_t)&a - 4;
+uintptr_t ptrasintadd2 = (uintptr_t)&a + 4;
+uintptr_t ptrasintadd3 = 4 + (uintptr_t)&a;
+
+// PR4285
+const wchar_t widestr[] = L"asdf";
+
+// PR5447
+const double pr5447 = (0.05 < -1.0) ? -1.0 : 0.0499878;
+
+// PR4386
+
+// None of these are constant initializers, but we implement GCC's old
+// behaviour of accepting bar and zed but not foo. GCC's behaviour was
+// changed in 2007 (rev 122551), so we should be able to change too one
+// day.
+int PR4386_bar();
+int PR4386_foo() __attribute((weak));
+int PR4386_zed();
+
+int PR4386_a = ((void *) PR4386_bar) != 0;
+int PR4386_b = ((void *) PR4386_foo) != 0; // expected-error{{initializer element is not a compile-time constant}}
+int PR4386_c = ((void *) PR4386_zed) != 0;
+int PR4386_zed() __attribute((weak));
+
+// <rdar://problem/10185490> (derived from SPEC vortex benchmark)
+typedef char strty[10];
+struct vortexstruct { strty s; };
+struct vortexstruct vortexvar = { "asdf" };
diff --git a/clang/test/Sema/initialize-noreturn.c b/clang/test/Sema/initialize-noreturn.c
new file mode 100644
index 0000000..5557862
--- /dev/null
+++ b/clang/test/Sema/initialize-noreturn.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// rdar://10095762
+
+typedef void (*Fn_noret)(void) __attribute__((noreturn));
+typedef void (*Fn_ret)(void);
+
+void foo(void);
+void foo_noret(void) __attribute__((noreturn));
+
+void test() {
+ Fn_noret fn2 = &foo; // expected-warning {{incompatible pointer types initializing 'Fn_noret'}}
+ Fn_noret fn3 = &foo_noret;
+ Fn_ret fn4 = &foo_noret;
+ Fn_ret fn5 = &foo;
+}
+
diff --git a/clang/test/Sema/inline-redef.c b/clang/test/Sema/inline-redef.c
new file mode 100644
index 0000000..4a46e11
--- /dev/null
+++ b/clang/test/Sema/inline-redef.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=gnu89 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#if __STDC_VERSION__ >= 199901
+#define GNU_INLINE __attribute((__gnu_inline__))
+#else
+#define GNU_INLINE
+#endif
+
+// PR5253
+// rdar://9559708 (same extension in C99 mode)
+// GNU Extension: check that we can redefine an extern inline function
+GNU_INLINE extern inline int f(int a) {return a;}
+int f(int b) {return b;} // expected-note{{previous definition is here}}
+// And now check that we can't redefine a normal function
+int f(int c) {return c;} // expected-error{{redefinition of 'f'}}
+
+// Check that we can redefine an extern inline function as a static function
+GNU_INLINE extern inline int g(int a) {return a;}
+static int g(int b) {return b;}
+
+// Check that we ensure the types of the two definitions are the same
+GNU_INLINE extern inline int h(int a) {return a;} // expected-note{{previous definition is here}}
+int h(short b) {return b;} // expected-error{{conflicting types for 'h'}}
diff --git a/clang/test/Sema/inline.c b/clang/test/Sema/inline.c
new file mode 100644
index 0000000..3c99f24
--- /dev/null
+++ b/clang/test/Sema/inline.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check that we don't allow illegal uses of inline
+inline int a; // expected-error{{'inline' can only appear on functions}}
+typedef inline int b; // expected-error{{'inline' can only appear on functions}}
+int d(inline int a); // expected-error{{'inline' can only appear on functions}}
diff --git a/clang/test/Sema/int-arith-convert.c b/clang/test/Sema/int-arith-convert.c
new file mode 100644
index 0000000..c56ab3b
--- /dev/null
+++ b/clang/test/Sema/int-arith-convert.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple=i686-linux-gnu -fsyntax-only -verify %s
+
+// Check types are the same through redeclaration
+unsigned long x;
+__typeof(1u+1l) x;
+
+unsigned y;
+__typeof(1+1u) y;
+__typeof(1u+1) y;
+
+long long z;
+__typeof(1ll+1u) z;
diff --git a/clang/test/Sema/invalid-decl.c b/clang/test/Sema/invalid-decl.c
new file mode 100644
index 0000000..a5e7ad3
--- /dev/null
+++ b/clang/test/Sema/invalid-decl.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+void test() {
+ char = 4; // expected-error {{expected identifier}}
+}
+
+
+// PR2400
+typedef xtype (*x)(void* handle); // expected-error {{function cannot return function type}} expected-warning {{type specifier missing, defaults to 'int'}} expected-warning {{type specifier missing, defaults to 'int'}}
+
+typedef void ytype();
+
+
+typedef struct _zend_module_entry zend_module_entry;
+struct _zend_module_entry {
+ ytype globals_size; // expected-error {{field 'globals_size' declared as a function}}
+};
+
+zend_module_entry openssl_module_entry = {
+ sizeof(zend_module_entry)
+};
+
diff --git a/clang/test/Sema/invalid-init-diag.c b/clang/test/Sema/invalid-init-diag.c
new file mode 100644
index 0000000..3e4870e
--- /dev/null
+++ b/clang/test/Sema/invalid-init-diag.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+int a;
+struct {int x;} x = a; // expected-error {{with an expression of incompatible type 'int'}}
diff --git a/clang/test/Sema/invalid-struct-init.c b/clang/test/Sema/invalid-struct-init.c
new file mode 100644
index 0000000..000d3ab
--- /dev/null
+++ b/clang/test/Sema/invalid-struct-init.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+typedef struct _zend_module_entry zend_module_entry;
+struct _zend_module_entry {
+ _efree((p)); // expected-error{{type name requires a specifier or qualifier}} \
+ expected-warning {{type specifier missing, defaults to 'int'}}
+
+};
+typedef struct _zend_function_entry { } zend_function_entry;
+typedef struct _zend_pcre_globals { } zend_pcre_globals;
+zend_pcre_globals pcre_globals;
+
+static void zm_globals_ctor_pcre(zend_pcre_globals *pcre_globals ) { }
+static void zm_globals_dtor_pcre(zend_pcre_globals *pcre_globals ) { }
+static void zm_info_pcre(zend_module_entry *zend_module ) { }
+static int zm_startup_pcre(int type, int module_number ) { }
+
+static int zm_shutdown_pcre(int type, int module_number ) {
+ zend_function_entry pcre_functions[] = {{ }; // expected-error{{expected '}'}} expected-note {{to match this '{'}}
+ zend_module_entry pcre_module_entry = {
+ sizeof(zend_module_entry), 20071006, 0, 0, ((void *)0), ((void *)0),
+ "pcre", pcre_functions, zm_startup_pcre, zm_shutdown_pcre, ((void *)0),
+ ((void *)0), zm_info_pcre, ((void *)0), sizeof(zend_pcre_globals), &pcre_globals,
+ ((void (*)(void* ))(zm_globals_ctor_pcre)), ((void (*)(void* ))(zm_globals_dtor_pcre)),
+ ((void *)0), 0, 0, ((void *)0), 0
+ };
+}
diff --git a/clang/test/Sema/knr-def-call.c b/clang/test/Sema/knr-def-call.c
new file mode 100644
index 0000000..f41275d
--- /dev/null
+++ b/clang/test/Sema/knr-def-call.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -Wconversion -Wliteral-conversion -fsyntax-only -verify %s
+
+// C DR #316, PR 3626.
+void f0(a, b, c, d) int a,b,c,d; {}
+void t0(void) {
+ f0(1); // expected-warning{{too few arguments}}
+}
+
+void f1(a, b) int a, b; {}
+void t1(void) {
+ f1(1, 2, 3); // expected-warning{{too many arguments}}
+}
+
+void f2(float); // expected-note{{previous declaration is here}}
+void f2(x) float x; { } // expected-warning{{promoted type 'double' of K&R function parameter is not compatible with the parameter type 'float' declared in a previous prototype}}
+
+typedef void (*f3)(void);
+f3 t3(int b) { return b? f0 : f1; } // okay
+
+// <rdar://problem/8193107>
+void f4() {
+ char *rindex();
+}
+
+char *rindex(s, c)
+ register char *s, c; // expected-warning{{promoted type 'char *' of K&R function parameter is not compatible with the parameter type 'const char *' declared in a previous prototype}}
+{
+ return 0;
+}
+
+// PR8314
+void proto(int);
+void proto(x)
+ int x;
+{
+}
+
+void use_proto() {
+ proto(42.1); // expected-warning{{implicit conversion turns literal floating-point number into integer}}
+ (&proto)(42.1); // expected-warning{{implicit conversion turns literal floating-point number into integer}}
+}
diff --git a/clang/test/Sema/knr-variadic-def.c b/clang/test/Sema/knr-variadic-def.c
new file mode 100644
index 0000000..6d5d632
--- /dev/null
+++ b/clang/test/Sema/knr-variadic-def.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+// PR4287
+
+#include <stdarg.h>
+char *foo = "test";
+int test(char*,...);
+
+int test(fmt)
+ char*fmt;
+{
+ va_list ap;
+ char*a;
+ int x;
+
+ va_start(ap,fmt);
+ a=va_arg(ap,char*);
+ x=(a!=foo);
+ va_end(ap);
+ return x;
+}
+
+void exit();
+
+int main(argc,argv)
+ int argc;char**argv;
+{
+ exit(test("",foo));
+}
+
diff --git a/clang/test/Sema/many-logical-ops.c b/clang/test/Sema/many-logical-ops.c
new file mode 100644
index 0000000..09a7684
--- /dev/null
+++ b/clang/test/Sema/many-logical-ops.c
@@ -0,0 +1,2010 @@
+// RUN: %clang_cc1 -fsyntax-only -Wconstant-conversion -verify %s
+
+// rdar://10913206&10941790
+// Check that we don't get stack overflow trying to evaluate a huge number of
+// logical operators.
+
+int foo(int x) {
+ return
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x;
+}
diff --git a/clang/test/Sema/many-parameters.c b/clang/test/Sema/many-parameters.c
new file mode 100644
index 0000000..1473c94
--- /dev/null
+++ b/clang/test/Sema/many-parameters.c
@@ -0,0 +1,310 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c99 %s
+
+// This test simply tests that the compiler does not crash. An optimization
+// in ParmVarDecls means that functions with fewer than 256 parameters use a fast path,
+// while those with >= 256 parameters use a slow path.
+//
+// Crash was reported in PR 10538.
+
+void foo(
+int x0,
+int x1,
+int x2,
+int x3,
+int x4,
+int x5,
+int x6,
+int x7,
+int x8,
+int x9,
+int x10,
+int x11,
+int x12,
+int x13,
+int x14,
+int x15,
+int x16,
+int x17,
+int x18,
+int x19,
+int x20,
+int x21,
+int x22,
+int x23,
+int x24,
+int x25,
+int x26,
+int x27,
+int x28,
+int x29,
+int x30,
+int x31,
+int x32,
+int x33,
+int x34,
+int x35,
+int x36,
+int x37,
+int x38,
+int x39,
+int x40,
+int x41,
+int x42,
+int x43,
+int x44,
+int x45,
+int x46,
+int x47,
+int x48,
+int x49,
+int x50,
+int x51,
+int x52,
+int x53,
+int x54,
+int x55,
+int x56,
+int x57,
+int x58,
+int x59,
+int x60,
+int x61,
+int x62,
+int x63,
+int x64,
+int x65,
+int x66,
+int x67,
+int x68,
+int x69,
+int x70,
+int x71,
+int x72,
+int x73,
+int x74,
+int x75,
+int x76,
+int x77,
+int x78,
+int x79,
+int x80,
+int x81,
+int x82,
+int x83,
+int x84,
+int x85,
+int x86,
+int x87,
+int x88,
+int x89,
+int x90,
+int x91,
+int x92,
+int x93,
+int x94,
+int x95,
+int x96,
+int x97,
+int x98,
+int x99,
+int x100,
+int x101,
+int x102,
+int x103,
+int x104,
+int x105,
+int x106,
+int x107,
+int x108,
+int x109,
+int x110,
+int x111,
+int x112,
+int x113,
+int x114,
+int x115,
+int x116,
+int x117,
+int x118,
+int x119,
+int x120,
+int x121,
+int x122,
+int x123,
+int x124,
+int x125,
+int x126,
+int x127,
+int x128,
+int x129,
+int x130,
+int x131,
+int x132,
+int x133,
+int x134,
+int x135,
+int x136,
+int x137,
+int x138,
+int x139,
+int x140,
+int x141,
+int x142,
+int x143,
+int x144,
+int x145,
+int x146,
+int x147,
+int x148,
+int x149,
+int x150,
+int x151,
+int x152,
+int x153,
+int x154,
+int x155,
+int x156,
+int x157,
+int x158,
+int x159,
+int x160,
+int x161,
+int x162,
+int x163,
+int x164,
+int x165,
+int x166,
+int x167,
+int x168,
+int x169,
+int x170,
+int x171,
+int x172,
+int x173,
+int x174,
+int x175,
+int x176,
+int x177,
+int x178,
+int x179,
+int x180,
+int x181,
+int x182,
+int x183,
+int x184,
+int x185,
+int x186,
+int x187,
+int x188,
+int x189,
+int x190,
+int x191,
+int x192,
+int x193,
+int x194,
+int x195,
+int x196,
+int x197,
+int x198,
+int x199,
+int x200,
+int x201,
+int x202,
+int x203,
+int x204,
+int x205,
+int x206,
+int x207,
+int x208,
+int x209,
+int x210,
+int x211,
+int x212,
+int x213,
+int x214,
+int x215,
+int x216,
+int x217,
+int x218,
+int x219,
+int x220,
+int x221,
+int x222,
+int x223,
+int x224,
+int x225,
+int x226,
+int x227,
+int x228,
+int x229,
+int x230,
+int x231,
+int x232,
+int x233,
+int x234,
+int x235,
+int x236,
+int x237,
+int x238,
+int x239,
+int x240,
+int x241,
+int x242,
+int x243,
+int x244,
+int x245,
+int x246,
+int x247,
+int x248,
+int x249,
+int x250,
+int x251,
+int x252,
+int x253,
+int x254,
+int x255,
+int x256,
+int x257,
+int x258,
+int x259,
+int x260,
+int x261,
+int x262,
+int x263,
+int x264,
+int x265,
+int x266,
+int x267,
+int x268,
+int x269,
+int x270,
+int x271,
+int x272,
+int x273,
+int x274,
+int x275,
+int x276,
+int x277,
+int x278,
+int x279,
+int x280,
+int x281,
+int x282,
+int x283,
+int x284,
+int x285,
+int x286,
+int x287,
+int x288,
+int x289,
+int x290,
+int x291,
+int x292,
+int x293,
+int x294,
+int x295,
+int x296,
+int x297,
+int x298,
+int x299
+);
diff --git a/clang/test/Sema/member-reference.c b/clang/test/Sema/member-reference.c
new file mode 100644
index 0000000..7bda143
--- /dev/null
+++ b/clang/test/Sema/member-reference.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+struct simple { int i; };
+
+void f(void) {
+ struct simple s[1];
+ s->i = 1;
+}
+
+typedef int x;
+struct S {
+ int x;
+ x z;
+};
+
+void g(void) {
+ struct S s[1];
+ s->x = 1;
+ s->z = 2;
+}
diff --git a/clang/test/Sema/memset-invalid.c b/clang/test/Sema/memset-invalid.c
new file mode 100644
index 0000000..c763858
--- /dev/null
+++ b/clang/test/Sema/memset-invalid.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+char memset(); // expected-warning {{incompatible redeclaration of library function 'memset'}} expected-note{{'memset' is a builtin with type}}
+char test() {
+ return memset();
+}
diff --git a/clang/test/Sema/merge-decls.c b/clang/test/Sema/merge-decls.c
new file mode 100644
index 0000000..1a84d33
--- /dev/null
+++ b/clang/test/Sema/merge-decls.c
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+void foo(void);
+void foo(void) {}
+void foo(void);
+void foo(void); // expected-note {{previous declaration is here}}
+
+void foo(int); // expected-error {{conflicting types for 'foo'}}
+
+int funcdef()
+{
+ return 0;
+}
+
+int funcdef();
+
+int funcdef2() { return 0; } // expected-note {{previous definition is here}}
+int funcdef2() { return 0; } // expected-error {{redefinition of 'funcdef2'}}
+
+// PR2502
+void (*f)(void);
+void (*f)() = 0;
+
+typedef __attribute__(( ext_vector_type(2) )) int Vi2;
+typedef __attribute__(( ext_vector_type(2) )) float Vf2;
+
+Vf2 g0; // expected-note {{previous definition is here}}
+Vi2 g0; // expected-error {{redefinition of 'g0'}}
+
+_Complex int g1; // expected-note {{previous definition is here}}
+_Complex float g1; // expected-error {{redefinition of 'g1'}}
+
+// rdar://6096412
+extern char i6096412[10];
+extern char i6096412[];
+void foo6096412(void) {
+ int x = sizeof(i6096412);
+}
+
diff --git a/clang/test/Sema/missing-field-initializers.c b/clang/test/Sema/missing-field-initializers.c
new file mode 100644
index 0000000..90e0e2a
--- /dev/null
+++ b/clang/test/Sema/missing-field-initializers.c
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-field-initializers %s
+
+// This was PR4808.
+
+struct Foo { int a, b; };
+
+struct Foo foo0 = { 1 }; // expected-warning {{missing field 'b' initializer}}
+struct Foo foo1 = { .a = 1 }; // designator avoids MFI warning
+struct Foo foo2 = { .b = 1 }; // designator avoids MFI warning
+
+struct Foo bar0[] = {
+ { 1,2 },
+ { 1 }, // expected-warning {{missing field 'b' initializer}}
+ { 1,2 }
+};
+
+struct Foo bar1[] = {
+ 1, 2,
+ 1, 2,
+ 1
+}; // expected-warning {{missing field 'b' initializer}}
+
+struct Foo bar2[] = { {}, {}, {} };
+
+struct One { int a; int b; };
+struct Two { float c; float d; float e; };
+
+struct Three {
+ union {
+ struct One one;
+ struct Two two;
+ } both;
+};
+
+struct Three t0 = {
+ { .one = { 1, 2 } }
+};
+struct Three t1 = {
+ { .two = { 1.0f, 2.0f, 3.0f } }
+};
+
+struct Three data[] = {
+ { { .one = { 1, 2 } } },
+ { { .one = { 1 } } }, // expected-warning {{missing field 'b' initializer}}
+ { { .two = { 1.0f, 2.0f, 3.0f } } },
+ { { .two = { 1.0f, 2.0f } } } // expected-warning {{missing field 'e' initializer}}
+};
+
+struct { int:5; int a; int:5; int b; int:5; } noNamedImplicit[] = {
+ { 1, 2 },
+ { 1 } // expected-warning {{missing field 'b' initializer}}
+};
diff --git a/clang/test/Sema/ms_class_layout.cpp b/clang/test/Sema/ms_class_layout.cpp
new file mode 100644
index 0000000..ea3f899
--- /dev/null
+++ b/clang/test/Sema/ms_class_layout.cpp
@@ -0,0 +1,335 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -cxx-abi microsoft %s 2>&1 \
+// RUN: | FileCheck %s
+
+#pragma pack(push, 8)
+
+class B {
+public:
+ virtual void b(){}
+ int b_field;
+protected:
+private:
+};
+
+class A : public B {
+public:
+ int a_field;
+ virtual void a(){}
+ char one;
+protected:
+private:
+};
+
+class D {
+public:
+ virtual void b(){}
+ double a;
+};
+
+class C : public virtual A,
+ public D, public B {
+public:
+ double c1_field;
+ int c2_field;
+ double c3_field;
+ int c4_field;
+ virtual void foo(){}
+ virtual void bar(){}
+protected:
+private:
+};
+
+struct BaseStruct
+{
+ BaseStruct(){}
+ double v0;
+ float v1;
+ C fg;
+};
+
+struct DerivedStruct : public BaseStruct {
+ int x;
+};
+
+struct G
+{
+ int g_field;
+};
+
+struct H : public G,
+ public virtual D
+{
+};
+
+struct I : public virtual D
+{
+ virtual ~I(){}
+ double q;
+};
+
+struct K
+{
+ int k;
+};
+
+struct L
+{
+ int l;
+};
+
+struct M : public virtual K
+{
+ int m;
+};
+
+struct N : public L, public M
+{
+ virtual void f(){}
+};
+
+struct O : public H, public G {
+ virtual void fo(){}
+};
+
+struct P : public M, public virtual L {
+ int p;
+};
+
+struct R {};
+
+#pragma pack(pop)
+
+// This needs only for building layouts.
+// Without this clang doesn`t dump record layouts.
+int main() {
+ // This avoid "Can't yet mangle constructors!" for MS ABI.
+ C* c;
+ c->foo();
+ DerivedStruct* v;
+ H* g;
+ BaseStruct* u;
+ I* i;
+ N* n;
+ O* o;
+ P* p;
+ R* r;
+ return 0;
+}
+
+// CHECK: 0 | class D
+// CHECK-NEXT: 0 | (D vftable pointer)
+// CHECK-NEXT: 8 | double a
+
+// CHECK-NEXT: sizeof=16, dsize=16, align=8
+// CHECK-NEXT: nvsize=16, nvalign=8
+
+// CHECK: %class.D = type { i32 (...)**, double }
+
+// CHECK: 0 | class B
+// CHECK-NEXT: 0 | (B vftable pointer)
+// CHECK-NEXT: 4 | int b_field
+
+// CHECK-NEXT: sizeof=8, dsize=8, align=4
+// CHECK-NEXT: nvsize=8, nvalign=4
+
+// CHECK: %class.B = type { i32 (...)**, i32 }
+
+// CHECK: 0 | class A
+// CHECK-NEXT: 0 | class B (primary base)
+// CHECK-NEXT: 0 | (B vftable pointer)
+// CHECK-NEXT: 4 | int b_field
+// CHECK-NEXT: 8 | int a_field
+// CHECK-NEXT: 12 | char one
+
+// CHECK-NEXT: sizeof=16, dsize=16, align=4
+// CHECK-NEXT: nvsize=16, nvalign=4
+
+// CHECK: 0 | class C
+// CHECK-NEXT: 0 | class D (primary base)
+// CHECK-NEXT: 0 | (D vftable pointer)
+// CHECK-NEXT: 8 | double a
+// CHECK-NEXT: 16 | class B (base)
+// CHECK-NEXT: 16 | (B vftable pointer)
+// CHECK-NEXT: 20 | int b_field
+// CHECK-NEXT: 24 | (C vbtable pointer)
+// CHECK-NEXT: 32 | double c1_field
+// CHECK-NEXT: 40 | int c2_field
+// CHECK-NEXT: 48 | double c3_field
+// CHECK-NEXT: 56 | int c4_field
+// CHECK-NEXT: 64 | class A (virtual base)
+// CHECK-NEXT: 64 | class B (primary base)
+// CHECK-NEXT: 64 | (B vftable pointer)
+// CHECK-NEXT: 68 | int b_field
+// CHECK-NEXT: 72 | int a_field
+// CHECK-NEXT: 76 | char one
+
+// CHECK-NEXT: sizeof=80, dsize=80, align=8
+// CHECK-NEXT: nvsize=64, nvalign=8
+
+// CHECK: %class.A = type { %class.B, i32, i8 }
+
+// CHECK: %class.C = type { %class.D, %class.B, i32*, double, i32, double, i32, [4 x i8], %class.A }
+// CHECK: %class.C.base = type { %class.D, %class.B, i32*, double, i32, double, i32 }
+
+// CHECK: 0 | struct BaseStruct
+// CHECK-NEXT: 0 | double v0
+// CHECK-NEXT: 8 | float v1
+// CHECK-NEXT: 16 | class C fg
+// CHECK-NEXT: 16 | class D (primary base)
+// CHECK-NEXT: 16 | (D vftable pointer)
+// CHECK-NEXT: 24 | double a
+// CHECK-NEXT: 32 | class B (base)
+// CHECK-NEXT: 32 | (B vftable pointer)
+// CHECK-NEXT: 36 | int b_field
+// CHECK-NEXT: 40 | (C vbtable pointer)
+// CHECK-NEXT: 48 | double c1_field
+// CHECK-NEXT: 56 | int c2_field
+// CHECK-NEXT: 64 | double c3_field
+// CHECK-NEXT: 72 | int c4_field
+// CHECK-NEXT: 80 | class A (virtual base)
+// CHECK-NEXT: 80 | class B (primary base)
+// CHECK-NEXT: 80 | (B vftable pointer)
+// CHECK-NEXT: 84 | int b_field
+// CHECK-NEXT: 88 | int a_field
+// CHECK-NEXT: 92 | char one
+
+// CHECK-NEXT: sizeof=80, dsize=80, align=8
+// CHECK-NEXT: nvsize=64, nvalign=8
+
+// CHECK: sizeof=96, dsize=96, align=8
+// CHECK-NEXT: nvsize=96, nvalign=8
+
+// CHECK: %struct.BaseStruct = type { double, float, %class.C }
+
+// CHECK: 0 | struct DerivedStruct
+// CHECK-NEXT: 0 | struct BaseStruct (base)
+// CHECK-NEXT: 0 | double v0
+// CHECK-NEXT: 8 | float v1
+// CHECK-NEXT: 16 | class C fg
+// CHECK-NEXT: 16 | class D (primary base)
+// CHECK-NEXT: 16 | (D vftable pointer)
+// CHECK-NEXT: 24 | double a
+// CHECK-NEXT: 32 | class B (base)
+// CHECK-NEXT: 32 | (B vftable pointer)
+// CHECK-NEXT: 36 | int b_field
+// CHECK-NEXT: 40 | (C vbtable pointer)
+// CHECK-NEXT: 48 | double c1_field
+// CHECK-NEXT: 56 | int c2_field
+// CHECK-NEXT: 64 | double c3_field
+// CHECK-NEXT: 72 | int c4_field
+// CHECK-NEXT: 80 | class A (virtual base)
+// CHECK-NEXT: 80 | class B (primary base)
+// CHECK-NEXT: 80 | (B vftable pointer)
+// CHECK-NEXT: 84 | int b_field
+// CHECK-NEXT: 88 | int a_field
+// CHECK-NEXT: 92 | char one
+// CHECK-NEXT: sizeof=80, dsize=80, align=8
+// CHECK-NEXT: nvsize=64, nvalign=8
+
+// CHECK: 96 | int x
+// CHECK-NEXT: sizeof=104, dsize=104, align=8
+// CHECK-NEXT: nvsize=104, nvalign=8
+
+// CHECK: %struct.DerivedStruct = type { %struct.BaseStruct, i32 }
+
+// CHECK: 0 | struct G
+// CHECK-NEXT: 0 | int g_field
+// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: nvsize=4, nvalign=4
+
+// CHECK: 0 | struct H
+// CHECK-NEXT: 0 | struct G (base)
+// CHECK-NEXT: 0 | int g_field
+// CHECK-NEXT: 4 | (H vbtable pointer)
+// CHECK-NEXT: 8 | class D (virtual base)
+// CHECK-NEXT: 8 | (D vftable pointer)
+// CHECK-NEXT: 16 | double a
+// CHECK-NEXT: sizeof=24, dsize=24, align=8
+// CHECK-NEXT: nvsize=8, nvalign=4
+
+// CHECK: %struct.H = type { %struct.G, i32*, %class.D }
+
+// CHECK: 0 | struct I
+// CHECK-NEXT: 0 | (I vftable pointer)
+// CHECK-NEXT: 8 | (I vbtable pointer)
+// CHECK-NEXT: 16 | double q
+// CHECK-NEXT: 24 | class D (virtual base)
+// CHECK-NEXT: 24 | (D vftable pointer)
+// CHECK-NEXT: 32 | double a
+// CHECK-NEXT: sizeof=40, dsize=40, align=8
+// CHECK-NEXT: nvsize=24, nvalign=8
+
+// CHECK: %struct.I = type { i32 (...)**, [4 x i8], i32*, double, %class.D }
+// CHECK: %struct.I.base = type { i32 (...)**, [4 x i8], i32*, double }
+
+// CHECK: 0 | struct L
+// CHECK-NEXT: 0 | int l
+// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: nvsize=4, nvalign=4
+
+// CHECK: 0 | struct K
+// CHECK-NEXT: 0 | int k
+// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: nvsize=4, nvalign=4
+
+// CHECK: 0 | struct M
+// CHECK-NEXT: 0 | (M vbtable pointer)
+// CHECK-NEXT: 4 | int m
+// CHECK-NEXT: 8 | struct K (virtual base)
+// CHECK-NEXT: 8 | int k
+// CHECK-NEXT: sizeof=12, dsize=12, align=4
+
+//CHECK: %struct.M = type { i32*, i32, %struct.K }
+//CHECK: %struct.M.base = type { i32*, i32 }
+
+// CHECK: 0 | struct N
+// CHECK-NEXT: 4 | struct L (base)
+// CHECK-NEXT: 4 | int l
+// CHECK-NEXT: 8 | struct M (base)
+// CHECK-NEXT: 8 | (M vbtable pointer)
+// CHECK-NEXT: 12 | int m
+// CHECK-NEXT: 0 | (N vftable pointer)
+// CHECK-NEXT: 16 | struct K (virtual base)
+// CHECK-NEXT: 16 | int k
+// CHECK-NEXT: sizeof=20, dsize=20, align=4
+// CHECK-NEXT: nvsize=16, nvalign=4
+
+//CHECK: %struct.N = type { i32 (...)**, %struct.L, %struct.M.base, %struct.K }
+
+// FIXME: MSVC place struct H at offset 8.
+// CHECK: 0 | struct O
+// CHECK-NEXT: 4 | struct H (base)
+// CHECK-NEXT: 4 | struct G (base)
+// CHECK-NEXT: 4 | int g_field
+// CHECK-NEXT: 8 | (H vbtable pointer)
+// CHECK-NEXT: 12 | struct G (base)
+// CHECK-NEXT: 12 | int g_field
+// CHECK-NEXT: 0 | (O vftable pointer)
+// CHECK-NEXT: 16 | class D (virtual base)
+// CHECK-NEXT: 16 | (D vftable pointer)
+// CHECK-NEXT: 24 | double a
+// CHECK-NEXT: sizeof=32, dsize=32, align=8
+// CHECK-NEXT: nvsize=16, nvalign=4
+
+//CHECK: %struct.O = type { i32 (...)**, %struct.H.base, %struct.G, %class.D }
+//CHECK: %struct.O.base = type { i32 (...)**, %struct.H.base, %struct.G }
+
+// CHECK: 0 | struct P
+// CHECK-NEXT: 0 | struct M (base)
+// CHECK-NEXT: 0 | (M vbtable pointer)
+// CHECK-NEXT: 4 | int m
+// CHECK-NEXT: 8 | int p
+// CHECK-NEXT: 12 | struct K (virtual base)
+// CHECK-NEXT: 12 | int k
+// CHECK-NEXT: 16 | struct L (virtual base)
+// CHECK-NEXT: 16 | int l
+// CHECK-NEXT: sizeof=20, dsize=20, align=4
+// CHECK-NEXT: nvsize=12, nvalign=4
+
+//CHECK: %struct.P = type { %struct.M.base, i32, %struct.K, %struct.L }
+
+// CHECK: 0 | struct R (empty)
+// CHECK-NEXT: sizeof=1, dsize=0, align=1
+// CHECK-NEXT: nvsize=0, nvalign=1
+
+//CHECK: %struct.R = type { i8 }
diff --git a/clang/test/Sema/neon-vector-types.c b/clang/test/Sema/neon-vector-types.c
new file mode 100644
index 0000000..cbf0133
--- /dev/null
+++ b/clang/test/Sema/neon-vector-types.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+typedef float float32_t;
+typedef signed char poly8_t;
+typedef short poly16_t;
+typedef unsigned long long uint64_t;
+
+// Define some valid Neon types.
+typedef __attribute__((neon_vector_type(2))) int int32x2_t;
+typedef __attribute__((neon_vector_type(4))) int int32x4_t;
+typedef __attribute__((neon_vector_type(1))) uint64_t uint64x1_t;
+typedef __attribute__((neon_vector_type(2))) uint64_t uint64x2_t;
+typedef __attribute__((neon_vector_type(2))) float32_t float32x2_t;
+typedef __attribute__((neon_vector_type(4))) float32_t float32x4_t;
+typedef __attribute__((neon_polyvector_type(16))) poly8_t poly8x16_t;
+typedef __attribute__((neon_polyvector_type(8))) poly16_t poly16x8_t;
+
+// The attributes must have a single argument.
+typedef __attribute__((neon_vector_type(2, 4))) int only_one_arg; // expected-error{{attribute takes one argument}}
+
+// The number of elements must be an ICE.
+typedef __attribute__((neon_vector_type(2.0))) int non_int_width; // expected-error{{attribute requires integer constant}}
+
+// Only certain element types are allowed.
+typedef __attribute__((neon_vector_type(2))) double double_elt; // expected-error{{invalid vector element type}}
+typedef __attribute__((neon_vector_type(4))) void* ptr_elt; // expected-error{{invalid vector element type}}
+typedef __attribute__((neon_polyvector_type(4))) float32_t bad_poly_elt; // expected-error{{invalid vector element type}}
+struct aggr { signed char c; };
+typedef __attribute__((neon_vector_type(8))) struct aggr aggregate_elt; // expected-error{{invalid vector element type}}
+
+// The total vector size must be 64 or 128 bits.
+typedef __attribute__((neon_vector_type(1))) int int32x1_t; // expected-error{{Neon vector size must be 64 or 128 bits}}
+typedef __attribute__((neon_vector_type(3))) int int32x3_t; // expected-error{{Neon vector size must be 64 or 128 bits}}
diff --git a/clang/test/Sema/nested-redef.c b/clang/test/Sema/nested-redef.c
new file mode 100644
index 0000000..bbc4859
--- /dev/null
+++ b/clang/test/Sema/nested-redef.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct X { // expected-note{{previous definition is here}}
+ struct X { } x; // expected-error{{nested redefinition of 'X'}}
+};
+
+struct Y { };
+void f(void) {
+ struct Y { }; // okay: this is a different Y
+}
+
+struct T;
+struct Z {
+ struct T { int x; } t;
+ struct U { int x; } u;
+};
+
+void f2(void) {
+ struct T t;
+ struct U u;
+}
+
+
diff --git a/clang/test/Sema/no-format-y2k-turnsoff-format.c b/clang/test/Sema/no-format-y2k-turnsoff-format.c
new file mode 100644
index 0000000..b206ecd
--- /dev/null
+++ b/clang/test/Sema/no-format-y2k-turnsoff-format.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wformat -Wno-format-y2k
+// rdar://9504680
+
+void foo(const char *, ...) __attribute__((__format__ (__printf__, 1, 2)));
+
+void bar(unsigned int a) {
+ foo("%s", a); // expected-warning {{format specifies type 'char *' but the argument has type 'unsigned int'}}
+}
+
diff --git a/clang/test/Sema/nonnull.c b/clang/test/Sema/nonnull.c
new file mode 100644
index 0000000..cea8e3d
--- /dev/null
+++ b/clang/test/Sema/nonnull.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+// rdar://9584012
+
+typedef struct {
+ char *str;
+} Class;
+
+typedef union {
+ Class *object;
+} Instance __attribute__((transparent_union));
+
+__attribute__((nonnull(1))) void Class_init(Instance this, char *str) {
+ this.object->str = str;
+}
+
+int main(void) {
+ Class *obj;
+ Class_init(0, "Hello World"); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ Class_init(obj, "Hello World");
+}
+
diff --git a/clang/test/Sema/offsetof.c b/clang/test/Sema/offsetof.c
new file mode 100644
index 0000000..46fb515
--- /dev/null
+++ b/clang/test/Sema/offsetof.c
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
+
+typedef struct P { int i; float f; } PT;
+struct external_sun3_core
+{
+ unsigned c_regs;
+
+ PT X[100];
+
+};
+
+void swap()
+{
+ int x;
+ x = offsetof(struct external_sun3_core, c_regs);
+ x = __builtin_offsetof(struct external_sun3_core, X[42].f);
+
+ x = __builtin_offsetof(struct external_sun3_core, X[42].f2); // expected-error {{no member named 'f2'}}
+ x = __builtin_offsetof(int, X[42].f2); // expected-error {{offsetof requires struct}}
+
+ int a[__builtin_offsetof(struct external_sun3_core, X) == 4 ? 1 : -1];
+ int b[__builtin_offsetof(struct external_sun3_core, X[42]) == 340 ? 1 : -1];
+ int c[__builtin_offsetof(struct external_sun3_core, X[42].f2) == 344 ? 1 : -1]; // expected-error {{no member named 'f2'}}
+}
+
+extern int f();
+
+struct s1 { int a; };
+int v1 = offsetof (struct s1, a) == 0 ? 0 : f();
+
+struct s2 { int a; };
+int v2 = (int)(&((struct s2 *) 0)->a) == 0 ? 0 : f();
+
+struct s3 { int a; };
+int v3 = __builtin_offsetof(struct s3, a) == 0 ? 0 : f();
+
+// PR3396
+struct sockaddr_un {
+ unsigned char sun_len;
+ char sun_path[104];
+};
+int a(int len) {
+int a[__builtin_offsetof(struct sockaddr_un, sun_path[len+1])];
+}
+
+// PR4079
+union x {struct {int x;};};
+int x[__builtin_offsetof(union x, x)];
+
+// rdar://problem/7222956
+struct incomplete; // expected-note 2 {{forward declaration of 'struct incomplete'}}
+int test1[__builtin_offsetof(struct incomplete, foo)]; // expected-error {{offsetof of incomplete type 'struct incomplete'}}
+
+int test2[__builtin_offsetof(struct incomplete[10], [4].foo)]; // expected-error {{array has incomplete element type 'struct incomplete'}}
+
+// Bitfields
+struct has_bitfields {
+ int i : 7;
+ int j : 12; // expected-note{{bit-field is declared here}}
+};
+
+int test3 = __builtin_offsetof(struct has_bitfields, j); // expected-error{{cannot compute offset of bit-field 'j'}}
+
+typedef struct Array { int array[1]; } Array;
+int test4 = __builtin_offsetof(Array, array);
+
+int test5() {
+ return __builtin_offsetof(Array, array[*(int*)0]); // expected-warning{{indirection of non-volatile null pointer}} expected-note{{__builtin_trap}}
+}
diff --git a/clang/test/Sema/overloadable-complex.c b/clang/test/Sema/overloadable-complex.c
new file mode 100644
index 0000000..efdeb8f
--- /dev/null
+++ b/clang/test/Sema/overloadable-complex.c
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+char *foo(float) __attribute__((__overloadable__));
+
+void test_foo_1(float fv, double dv, float _Complex fc, double _Complex dc) {
+ char *cp1 = foo(fv);
+ char *cp2 = foo(dv);
+ // Note: GCC and EDG reject these two, but they are valid C99 conversions
+ char *cp3 = foo(fc);
+ char *cp4 = foo(dc);
+}
+
+int *foo(float _Complex) __attribute__((__overloadable__));
+
+void test_foo_2(float fv, double dv, float _Complex fc, double _Complex dc) {
+ char *cp1 = foo(fv);
+ char *cp2 = foo(dv);
+ int *ip = foo(fc);
+ int *lp = foo(dc);
+}
+
+long *foo(double _Complex) __attribute__((__overloadable__));
+
+void test_foo_3(float fv, double dv, float _Complex fc, double _Complex dc) {
+ char *cp1 = foo(fv);
+ char *cp2 = foo(dv);
+ int *ip = foo(fc);
+ long *lp = foo(dc);
+}
+
+char *promote_or_convert(double _Complex) __attribute__((__overloadable__)); // expected-note 2 {{candidate function}}
+int *promote_or_convert(long double _Complex) __attribute__((__overloadable__)); // expected-note 2 {{candidate function}}
+
+void test_promote_or_convert(float f, float _Complex fc) {
+ char *cp = promote_or_convert(fc); // expected-error{{call to 'promote_or_convert' is ambiguous}}
+ int *ip2 = promote_or_convert(f); // expected-error{{call to 'promote_or_convert' is ambiguous}}
+}
+
+char *promote_or_convert2(float) __attribute__((__overloadable__));
+int *promote_or_convert2(double _Complex) __attribute__((__overloadable__));
+
+void test_promote_or_convert2(float _Complex fc) {
+ int *cp = promote_or_convert2(fc);
+}
+
+char *promote_or_convert3(int _Complex) __attribute__((__overloadable__));
+int *promote_or_convert3(long _Complex) __attribute__((__overloadable__));
+
+void test_promote_or_convert3(short _Complex sc) {
+ char *cp = promote_or_convert3(sc);
+}
diff --git a/clang/test/Sema/overloadable.c b/clang/test/Sema/overloadable.c
new file mode 100644
index 0000000..5d39f15
--- /dev/null
+++ b/clang/test/Sema/overloadable.c
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute can only be applied to a function}}
+
+int *f(int) __attribute__((overloadable)); // expected-note 2{{previous overload of function is here}}
+float *f(float); // expected-error{{overloaded function 'f' must have the 'overloadable' attribute}}
+int *f(int); // expected-error{{redeclaration of 'f' must have the 'overloadable' attribute}} \
+ // expected-note{{previous declaration is here}}
+double *f(double) __attribute__((overloadable)); // okay, new
+
+void test_f(int iv, float fv, double dv) {
+ int *ip = f(iv);
+ float *fp = f(fv);
+ double *dp = f(dv);
+}
+
+int *accept_funcptr(int (*)()) __attribute__((overloadable)); // \
+ // expected-note{{candidate function}}
+float *accept_funcptr(int (*)(int, double)) __attribute__((overloadable)); // \
+ // expected-note{{candidate function}}
+
+void test_funcptr(int (*f1)(int, double),
+ int (*f2)(int, float)) {
+ float *fp = accept_funcptr(f1);
+ accept_funcptr(f2); // expected-error{{no matching function for call to 'accept_funcptr'}}
+}
+
+struct X { int x; float y; };
+struct Y { int x; float y; };
+int* accept_struct(struct X x) __attribute__((__overloadable__));
+float* accept_struct(struct Y y) __attribute__((overloadable));
+
+void test_struct(struct X x, struct Y y) {
+ int *ip = accept_struct(x);
+ float *fp = accept_struct(y);
+}
+
+double *f(int) __attribute__((overloadable)); // expected-error{{conflicting types for 'f'}}
+
+double promote(float) __attribute__((__overloadable__)); // expected-note {{candidate}}
+double promote(double) __attribute__((__overloadable__)); // expected-note {{candidate}}
+long double promote(long double) __attribute__((__overloadable__)); // expected-note {{candidate}}
+
+void promote(...) __attribute__((__overloadable__, __unavailable__)); // \
+ // expected-note{{candidate function}}
+
+void test_promote(short* sp) {
+ promote(1.0);
+ promote(sp); // expected-error{{call to unavailable function 'promote'}}
+}
+
+// PR6600
+typedef double Double;
+typedef Double DoubleVec __attribute__((vector_size(16)));
+typedef int Int;
+typedef Int IntVec __attribute__((vector_size(16)));
+double magnitude(DoubleVec) __attribute__((__overloadable__));
+double magnitude(IntVec) __attribute__((__overloadable__));
+double test_p6600(DoubleVec d) {
+ return magnitude(d) * magnitude(d);
+}
+
+// PR7738
+extern int __attribute__((overloadable)) f0(); // expected-error{{'overloadable' function 'f0' must have a prototype}}
+typedef int f1_type();
+f1_type __attribute__((overloadable)) f1; // expected-error{{'overloadable' function 'f1' must have a prototype}}
+
+void test() {
+ f0();
+ f1();
+}
diff --git a/clang/test/Sema/overloaded-func-transparent-union.c b/clang/test/Sema/overloaded-func-transparent-union.c
new file mode 100644
index 0000000..fa0314e
--- /dev/null
+++ b/clang/test/Sema/overloaded-func-transparent-union.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// rdar:// 9129552
+// PR9406
+
+typedef struct {
+ char *str;
+ char *str2;
+} Class;
+
+typedef union {
+ Class *object;
+} Instance __attribute__((transparent_union));
+
+__attribute__((overloadable)) void Class_Init(Instance this, char *str, void *str2) {
+ this.object->str = str;
+ this.object->str2 = str2;
+}
+
+__attribute__((overloadable)) void Class_Init(Instance this, char *str) {
+ this.object->str = str;
+ this.object->str2 = str;
+}
+
+int main(void) {
+ Class obj;
+ Class_Init(&obj, "Hello ", " World");
+}
+
diff --git a/clang/test/Sema/parentheses.c b/clang/test/Sema/parentheses.c
new file mode 100644
index 0000000..9751336
--- /dev/null
+++ b/clang/test/Sema/parentheses.c
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wparentheses -fixit %s -o - | %clang_cc1 -Wparentheses -Werror -
+
+// Test the various warnings under -Wparentheses
+void if_assign(void) {
+ int i;
+ if (i = 4) {} // expected-warning {{assignment as a condition}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ if ((i = 4)) {}
+}
+
+void bitwise_rel(unsigned i) {
+ (void)(i & 0x2 == 0); // expected-warning {{& has lower precedence than ==}} \
+ // expected-note{{place parentheses around the & expression to evaluate it first}} \
+ // expected-note{{place parentheses around the == expression to silence this warning}}
+ (void)(0 == i & 0x2); // expected-warning {{& has lower precedence than ==}} \
+ // expected-note{{place parentheses around the & expression to evaluate it first}} \
+ // expected-note{{place parentheses around the == expression to silence this warning}}
+ (void)(i & 0xff < 30); // expected-warning {{& has lower precedence than <}} \
+ // expected-note{{place parentheses around the & expression to evaluate it first}} \
+ // expected-note{{place parentheses around the < expression to silence this warning}}
+ (void)((i & 0x2) == 0);
+ (void)(i & (0x2 == 0));
+ // Eager logical op
+ (void)(i == 1 | i == 2 | i == 3);
+ (void)(i != 1 & i != 2 & i != 3);
+
+ (void)(i & i | i); // expected-warning {{'&' within '|'}} \
+ // expected-note {{place parentheses around the '&' expression to silence this warning}}
+
+ (void)(i | i & i); // expected-warning {{'&' within '|'}} \
+ // expected-note {{place parentheses around the '&' expression to silence this warning}}
+
+ (void)(i ||
+ i && i); // expected-warning {{'&&' within '||'}} \
+ // expected-note {{place parentheses around the '&&' expression to silence this warning}}
+ (void)(i || i && "w00t"); // no warning.
+ (void)("w00t" && i || i); // no warning.
+ (void)(i || i && "w00t" || i); // expected-warning {{'&&' within '||'}} \
+ // expected-note {{place parentheses around the '&&' expression to silence this warning}}
+ (void)(i || "w00t" && i || i); // expected-warning {{'&&' within '||'}} \
+ // expected-note {{place parentheses around the '&&' expression to silence this warning}}
+ (void)(i && i || 0); // no warning.
+ (void)(0 || i && i); // no warning.
+}
+
+_Bool someConditionFunc();
+
+void conditional_op(int x, int y, _Bool b) {
+ (void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+ // expected-note {{place parentheses around the '+' expression to silence this warning}}
+
+ (void)((x + someConditionFunc()) ? 1 : 2); // no warning
+
+ (void)(x - b ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '-'}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+ // expected-note {{place parentheses around the '-' expression to silence this warning}}
+
+ (void)(x * (x == y) ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '*'}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+ // expected-note {{place parentheses around the '*' expression to silence this warning}}
+
+ (void)(x / !x ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '/'}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+ // expected-note {{place parentheses around the '/' expression to silence this warning}}
+
+ (void)(x % 2 ? 1 : 2); // no warning
+}
+
+// RUN: %clang_cc1 -fsyntax-only -Wparentheses -Werror -fdiagnostics-show-option %s 2>&1 | FileCheck %s
+// CHECK: error: using the result of an assignment as a condition without parentheses [-Werror,-Wparentheses]
diff --git a/clang/test/Sema/parentheses.cpp b/clang/test/Sema/parentheses.cpp
new file mode 100644
index 0000000..7674166
--- /dev/null
+++ b/clang/test/Sema/parentheses.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wparentheses -fixit %s -o - | %clang_cc1 -Wparentheses -Werror -
+
+bool someConditionFunc();
+
+void conditional_op(int x, int y, bool b) {
+ (void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+ // expected-note {{place parentheses around the '+' expression to silence this warning}}
+
+ (void)(x - b ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '-'}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+ // expected-note {{place parentheses around the '-' expression to silence this warning}}
+
+ (void)(x * (x == y) ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '*'}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+ // expected-note {{place parentheses around the '*' expression to silence this warning}}
+}
+
+class Stream {
+public:
+ operator int();
+ Stream &operator<<(int);
+ Stream &operator<<(const char*);
+};
+
+void f(Stream& s, bool b) {
+ (void)(s << b ? "foo" : "bar"); // expected-warning {{operator '?:' has lower precedence than '<<'}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+ // expected-note {{place parentheses around the '<<' expression to silence this warning}}
+}
+
+struct S {
+ operator int() { return 42; }
+ friend S operator+(const S &lhs, bool) { return S(); }
+};
+
+void test(S *s, bool (S::*m_ptr)()) {
+ (void)(*s + true ? "foo" : "bar"); // expected-warning {{operator '?:' has lower precedence than '+'}} \
+ // expected-note {{place parentheses around the '?:' expression to evaluate it first}} \
+ // expected-note {{place parentheses around the '+' expression to silence this warning}}
+
+ (void)((*s + true) ? "foo" : "bar"); // No warning.
+
+ // Don't crash on unusual member call expressions.
+ (void)((s->*m_ptr)() ? "foo" : "bar");
+}
diff --git a/clang/test/Sema/pointer-addition.c b/clang/test/Sema/pointer-addition.c
new file mode 100644
index 0000000..21ce63b
--- /dev/null
+++ b/clang/test/Sema/pointer-addition.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
+
+typedef struct S S; // expected-note 3 {{forward declaration of 'struct S'}}
+void a(S* b, void* c) {
+ void (*fp)(int) = 0;
+ b++; // expected-error {{arithmetic on a pointer to an incomplete type}}
+ b += 1; // expected-error {{arithmetic on a pointer to an incomplete type}}
+ c++; // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
+ c += 1; // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
+ c--; // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
+ c -= 1; // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
+ (void) c[1]; // expected-warning {{subscript of a pointer to void is a GNU extension}}
+ b = 1+b; // expected-error {{arithmetic on a pointer to an incomplete type}}
+ /* The next couple tests are only pedantic warnings in gcc */
+ void (*d)(S*,void*) = a;
+ d += 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
+ d++; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
+ d--; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
+ d -= 1; // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
+ (void)(1 + d); // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' is a GNU extension}}
+}
diff --git a/clang/test/Sema/pointer-conversion.c b/clang/test/Sema/pointer-conversion.c
new file mode 100644
index 0000000..2d755ae
--- /dev/null
+++ b/clang/test/Sema/pointer-conversion.c
@@ -0,0 +1,10 @@
+//RUN: %clang_cc1 -fsyntax-only -verify %s
+
+char * c;
+char const ** c2 = &c; // expected-warning {{discards qualifiers in nested pointer types}}
+
+typedef char dchar;
+dchar *** c3 = &c2; // expected-warning {{discards qualifiers in nested pointer types}}
+
+volatile char * c4;
+char ** c5 = &c4; // expected-warning {{discards qualifiers in nested pointer types}}
diff --git a/clang/test/Sema/pointer-subtract-compat.c b/clang/test/Sema/pointer-subtract-compat.c
new file mode 100644
index 0000000..b801f81
--- /dev/null
+++ b/clang/test/Sema/pointer-subtract-compat.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
+
+typedef const char rchar;
+int a(char* a, rchar* b) {
+ return a-b;
+}
+
+// <rdar://problem/6520707>
+void f0(void (*fp)(void)) {
+ int x = fp - fp; // expected-warning{{arithmetic on pointers to the function type 'void (void)' is a GNU extension}}
+}
diff --git a/clang/test/Sema/pragma-align-mac68k-unsupported.c b/clang/test/Sema/pragma-align-mac68k-unsupported.c
new file mode 100644
index 0000000..c23c01b
--- /dev/null
+++ b/clang/test/Sema/pragma-align-mac68k-unsupported.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fsyntax-only -verify %s
+
+/* expected-error {{mac68k alignment pragma is not supported}} */ #pragma options align=mac68k
diff --git a/clang/test/Sema/pragma-align-mac68k.c b/clang/test/Sema/pragma-align-mac68k.c
new file mode 100644
index 0000000..fb8da51
--- /dev/null
+++ b/clang/test/Sema/pragma-align-mac68k.c
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+
+#include <stddef.h>
+
+#pragma options align=mac68k
+
+typedef float __attribute__((vector_size (8))) v2f_t;
+typedef float __attribute__((vector_size (16))) v4f_t;
+
+extern int a0_0[__alignof(v2f_t) == 8 ? 1 : -1];
+extern int a0_1[__alignof(v4f_t) == 16 ? 1 : -1];
+
+struct s1 {
+ char f0;
+ int f1;
+};
+extern int a1_0[offsetof(struct s1, f0) == 0 ? 1 : -1];
+extern int a1_1[offsetof(struct s1, f1) == 2 ? 1 : -1];
+extern int a1_2[sizeof(struct s1) == 6 ? 1 : -1];
+extern int a1_3[__alignof(struct s1) == 2 ? 1 : -1];
+
+struct s2 {
+ char f0;
+ double f1;
+};
+extern int a2_0[offsetof(struct s2, f0) == 0 ? 1 : -1];
+extern int a2_1[offsetof(struct s2, f1) == 2 ? 1 : -1];
+extern int a2_2[sizeof(struct s2) == 10 ? 1 : -1];
+extern int a2_3[__alignof(struct s2) == 2 ? 1 : -1];
+
+struct s3 {
+ char f0;
+ v4f_t f1;
+};
+extern int a3_0[offsetof(struct s3, f0) == 0 ? 1 : -1];
+extern int a3_1[offsetof(struct s3, f1) == 2 ? 1 : -1];
+extern int a3_2[sizeof(struct s3) == 18 ? 1 : -1];
+extern int a3_3[__alignof(struct s3) == 2 ? 1 : -1];
+
+struct s4 {
+ char f0;
+ char f1;
+};
+extern int a4_0[offsetof(struct s4, f0) == 0 ? 1 : -1];
+extern int a4_1[offsetof(struct s4, f1) == 1 ? 1 : -1];
+extern int a4_2[sizeof(struct s4) == 2 ? 1 : -1];
+extern int a4_3[__alignof(struct s4) == 2 ? 1 : -1];
+
+struct s5 {
+ unsigned f0 : 9;
+ unsigned f1 : 9;
+};
+extern int a5_0[sizeof(struct s5) == 4 ? 1 : -1];
+extern int a5_1[__alignof(struct s5) == 2 ? 1 : -1];
+
+struct s6 {
+ unsigned : 0;
+ unsigned : 0;
+};
+extern int a6_0[sizeof(struct s6) == 0 ? 1 : -1];
+extern int a6_1[__alignof(struct s6) == 2 ? 1 : -1];
+
+struct s7 {
+ char : 1;
+ unsigned : 1;
+};
+extern int a7_0[sizeof(struct s7) == 2 ? 1 : -1];
+extern int a7_1[__alignof(struct s7) == 2 ? 1 : -1];
+
+struct s8 {
+ char f0;
+ unsigned : 1;
+};
+extern int a8_0[sizeof(struct s8) == 2 ? 1 : -1];
+extern int a8_1[__alignof(struct s8) == 2 ? 1 : -1];
+
+struct s9 {
+ char f0[3];
+ unsigned : 0;
+ char f1;
+};
+extern int a9_0[sizeof(struct s9) == 6 ? 1 : -1];
+extern int a9_1[__alignof(struct s9) == 2 ? 1 : -1];
+
+struct s10 {
+ char f0;
+};
+extern int a10_0[sizeof(struct s10) == 2 ? 1 : -1];
+extern int a10_1[__alignof(struct s10) == 2 ? 1 : -1];
+
+struct s11 {
+ char f0;
+ v2f_t f1;
+};
+extern int a11_0[offsetof(struct s11, f0) == 0 ? 1 : -1];
+extern int a11_1[offsetof(struct s11, f1) == 2 ? 1 : -1];
+extern int a11_2[sizeof(struct s11) == 10 ? 1 : -1];
+extern int a11_3[__alignof(struct s11) == 2 ? 1 : -1];
diff --git a/clang/test/Sema/pragma-align-packed.c b/clang/test/Sema/pragma-align-packed.c
new file mode 100644
index 0000000..74fbd13
--- /dev/null
+++ b/clang/test/Sema/pragma-align-packed.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+
+#pragma pack(push, 1)
+struct s0 {
+ char f0;
+ int f1 __attribute__((aligned(4)));
+};
+extern int a[sizeof(struct s0) == 5 ? 1 : -1];
+#pragma pack(pop)
+
+struct __attribute__((packed)) s1 {
+ char f0;
+ int f1 __attribute__((aligned(4)));
+};
+extern int a[sizeof(struct s1) == 8 ? 1 : -1];
+
+#pragma options align=packed
+struct s2 {
+ char f0;
+ int f1 __attribute__((aligned(4)));
+};
+extern int a[sizeof(struct s2) == 5 ? 1 : -1];
+#pragma options align=reset
+
+#pragma pack(1)
+struct s3_0 { unsigned char f0; unsigned int f1; };
+int t3_0[sizeof(struct s3_0) == 5 ? 1 : -1];
+#pragma options align=reset
+struct s3_1 { unsigned char f0; unsigned int f1; };
+int t3_1[sizeof(struct s3_1) == 8 ? 1 : -1];
diff --git a/clang/test/Sema/pragma-arc-cf-code-audited.c b/clang/test/Sema/pragma-arc-cf-code-audited.c
new file mode 100644
index 0000000..b646e89
--- /dev/null
+++ b/clang/test/Sema/pragma-arc-cf-code-audited.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#pragma clang arc_cf_code_audited foo // expected-error {{expected 'begin' or 'end'}}
+
+#pragma clang arc_cf_code_audited begin foo // expected-warning {{extra tokens at end of #pragma directive}}
+
+#pragma clang arc_cf_code_audited end
+#pragma clang arc_cf_code_audited end // expected-error {{not currently inside '#pragma clang arc_cf_code_audited'}}
+
+#pragma clang arc_cf_code_audited begin // expected-note {{#pragma entered here}}
+#pragma clang arc_cf_code_audited begin // expected-error {{already inside '#pragma clang arc_cf_code_audited'}} expected-note {{#pragma entered here}}
+
+#include "Inputs/pragma-arc-cf-code-audited.h" // expected-error {{cannot #include files inside '#pragma clang arc_cf_code_audited'}}
+
+// This is actually on the #pragma line in the header.
+// expected-error {{'#pragma clang arc_cf_code_audited' was not ended within this file}}
+
+#pragma clang arc_cf_code_audited begin // expected-error {{'#pragma clang arc_cf_code_audited' was not ended within this file}}
diff --git a/clang/test/Sema/pragma-ms_struct.c b/clang/test/Sema/pragma-ms_struct.c
new file mode 100644
index 0000000..d76ee8b
--- /dev/null
+++ b/clang/test/Sema/pragma-ms_struct.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 %s
+
+#pragma ms_struct on
+
+#pragma ms_struct off
+
+#pragma ms_struct reset
+
+#pragma ms_struct // expected-warning {{incorrect use of '#pragma ms_struct on|off' - ignored}}
+
+#pragma ms_struct on top of spaghetti // expected-warning {{extra tokens at end of '#pragma ms_struct' - ignored}}
+
+struct foo
+{
+ int a;
+ int b;
+ char c;
+};
+
+
+struct {
+ unsigned long bf_1 : 12;
+ unsigned long : 0;
+ unsigned long bf_2 : 12;
+} __attribute__((__ms_struct__)) t1;
+
+struct S {
+ double __attribute__((ms_struct)) d; // expected-warning {{'ms_struct' attribute ignored}}
+ unsigned long bf_1 : 12;
+ unsigned long : 0;
+ unsigned long bf_2 : 12;
+} __attribute__((ms_struct)) t2;
+
+
+// rdar://10513599
+#pragma ms_struct on
+
+typedef struct
+{
+void *pv;
+int l;
+} Foo;
+
+typedef struct
+{
+void *pv1;
+Foo foo;
+unsigned short fInited : 1;
+void *pv2;
+} PackOddity;
+
+#pragma ms_struct off
+
+static int arr[sizeof(PackOddity) == 40 ? 1 : -1];
+
diff --git a/clang/test/Sema/pragma-pack-2.c b/clang/test/Sema/pragma-pack-2.c
new file mode 100644
index 0000000..4a4c202
--- /dev/null
+++ b/clang/test/Sema/pragma-pack-2.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin9 %s -fsyntax-only -verify
+
+#include <stddef.h>
+
+#pragma pack(4)
+
+// Baseline
+struct s0 {
+ char f0;
+ int f1;
+};
+extern int a0[offsetof(struct s0, f1) == 4 ? 1 : -1];
+
+#pragma pack(push, 2)
+struct s1 {
+ char f0;
+ int f1;
+};
+extern int a1[offsetof(struct s1, f1) == 2 ? 1 : -1];
+#pragma pack(pop)
+
+#pragma pack(1)
+struct s3_0 {
+ char f0;
+ int f1;
+};
+#pragma pack()
+struct s3_1 {
+ char f0;
+ int f1;
+};
+extern int a3_0[offsetof(struct s3_0, f1) == 1 ? 1 : -1];
+extern int a3_1[offsetof(struct s3_1, f1) == 4 ? 1 : -1];
+
+// pack(0) is like pack()
+#pragma pack(1)
+struct s4_0 {
+ char f0;
+ int f1;
+};
+#pragma pack(0)
+struct s4_1 {
+ char f0;
+ int f1;
+};
+extern int a4_0[offsetof(struct s4_0, f1) == 1 ? 1 : -1];
+extern int a4_1[offsetof(struct s4_1, f1) == 4 ? 1 : -1];
+
+void f() {
+ #pragma pack(push, 2)
+ struct s5_0 {
+ char f0;
+ struct s2_4_0 {
+ int f0;
+ } f1;
+ };
+ #pragma pack(pop)
+ extern int s5_0[offsetof(struct s5_0, f1) == 2 ? 1 : -1];
+}
diff --git a/clang/test/Sema/pragma-pack-3.c b/clang/test/Sema/pragma-pack-3.c
new file mode 100644
index 0000000..d97359e
--- /dev/null
+++ b/clang/test/Sema/pragma-pack-3.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin9 %s -fsyntax-only -verify
+
+// Stack: [], Alignment: 8
+
+#pragma pack(push, 1)
+// Stack: [8], Alignment: 1
+
+#pragma pack(push, 4)
+// Stack: [8, 1], Alignment: 4
+
+// Note that this differs from gcc; pack() in gcc appears to pop the
+// top stack entry and resets the current alignment. This is both
+// inconsistent with MSVC, and the gcc documentation. In other cases,
+// for example changing this to pack(8), I don't even understand what gcc
+// is doing.
+
+#pragma pack()
+// Stack: [8, 1], Alignment: 8
+
+#pragma pack(pop)
+// Stack: [8], Alignment: 1
+struct s0 {
+ char f0;
+ short f1;
+};
+int a[sizeof(struct s0) == 3 ? 1 : -1];
+
+#pragma pack(pop)
+// Stack: [], Alignment: 8
+struct s1 {
+ char f0;
+ short f1;
+};
+int b[sizeof(struct s1) == 4 ? 1 : -1];
diff --git a/clang/test/Sema/pragma-pack-4.c b/clang/test/Sema/pragma-pack-4.c
new file mode 100644
index 0000000..b06fc0e
--- /dev/null
+++ b/clang/test/Sema/pragma-pack-4.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin9 %s -fsyntax-only -verify
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -fsyntax-only -verify
+
+// rdar://problem/7095436
+#pragma pack(4)
+
+struct s0 {
+ long long a __attribute__((aligned(8)));
+ long long b __attribute__((aligned(8)));
+ unsigned int c __attribute__((aligned(8)));
+ int d[12];
+};
+
+struct s1 {
+ int a[15];
+ struct s0 b;
+};
+
+int arr0[((sizeof(struct s1) % 64) == 0) ? 1 : -1];
diff --git a/clang/test/Sema/pragma-pack-5.c b/clang/test/Sema/pragma-pack-5.c
new file mode 100644
index 0000000..95bbe1f
--- /dev/null
+++ b/clang/test/Sema/pragma-pack-5.c
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -fsyntax-only -verify -ffreestanding
+// <rdar://problem/10494810> and PR9560
+// Check #pragma pack handling with bitfields.
+
+#include <stddef.h>
+#pragma pack(2)
+
+struct s0 {
+ char f1;
+ unsigned f2 : 32;
+ char f3;
+};
+extern int check[sizeof(struct s0) == 6 ? 1 : -1];
+
+struct s1 {
+ char f1;
+ unsigned : 0;
+ char f3;
+};
+extern int check[sizeof(struct s1) == 5 ? 1 : -1];
+
+struct s2 {
+ char f1;
+ unsigned : 0;
+ unsigned f3 : 8;
+ char f4;
+};
+extern int check[sizeof(struct s2) == 6 ? 1 : -1];
+
+struct s3 {
+ char f1;
+ unsigned : 0;
+ unsigned f3 : 16;
+ char f4;
+};
+extern int check[sizeof(struct s3) == 8 ? 1 : -1];
+extern int check[offsetof(struct s3, f4) == 6 ? 1 : -1];
+
+struct s4 {
+ char f1;
+ unsigned f2 : 8;
+ char f3;
+};
+extern int check[sizeof(struct s4) == 4 ? 1 : -1];
+extern int check[offsetof(struct s4, f3) == 2 ? 1 : -1];
diff --git a/clang/test/Sema/pragma-pack-and-options-align.c b/clang/test/Sema/pragma-pack-and-options-align.c
new file mode 100644
index 0000000..ebf1ade
--- /dev/null
+++ b/clang/test/Sema/pragma-pack-and-options-align.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin9 %s -fsyntax-only -verify
+
+// Check that #pragma pack and #pragma options share the same stack.
+
+#pragma pack(push, 1)
+struct s0 {
+ char c;
+ int x;
+};
+extern int a[sizeof(struct s0) == 5 ? 1 : -1];
+
+#pragma options align=natural
+struct s1 {
+ char c;
+ int x;
+};
+extern int a[sizeof(struct s1) == 8 ? 1 : -1];
+
+#pragma options align=reset
+#pragma options align=native
+struct s1_1 {
+ char c;
+ int x;
+};
+extern int a[sizeof(struct s1_1) == 8 ? 1 : -1];
+
+#pragma pack(pop)
+struct s2 {
+ char c;
+ int x;
+};
+extern int a[sizeof(struct s2) == 5 ? 1 : -1];
+#pragma pack(pop)
+
+struct s3 {
+ char c;
+ int x;
+};
+extern int a[sizeof(struct s3) == 8 ? 1 : -1];
+
+/* expected-warning {{#pragma options align=reset failed: stack empty}} */ #pragma options align=reset
+/* expected-warning {{#pragma pack(pop, ...) failed: stack empty}} */ #pragma pack(pop)
diff --git a/clang/test/Sema/pragma-pack-apple.c b/clang/test/Sema/pragma-pack-apple.c
new file mode 100644
index 0000000..5b33c03
--- /dev/null
+++ b/clang/test/Sema/pragma-pack-apple.c
@@ -0,0 +1,10 @@
+// RUN: %clang -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -fsyntax-only -fapple-pragma-pack %s 2>&1 | FileCheck -check-prefix=CHECK-APPLE %s
+
+#pragma pack(push,1)
+#pragma pack(2)
+#pragma pack()
+#pragma pack(show)
+
+// CHECK: pack(show) == 8
+// CHECK-APPLE: pack(show) == 1
diff --git a/clang/test/Sema/pragma-pack.c b/clang/test/Sema/pragma-pack.c
new file mode 100644
index 0000000..e93ce42
--- /dev/null
+++ b/clang/test/Sema/pragma-pack.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -verify %s
+
+/* expected-warning {{value of #pragma pack(show) == 8}} */ #pragma pack(show)
+/* expected-warning {{expected #pragma pack parameter to be}} */ #pragma pack(3)
+/* expected-warning {{value of #pragma pack(show) == 8}} */ #pragma pack(show)
+#pragma pack(4)
+/* expected-warning {{value of #pragma pack(show) == 4}} */ #pragma pack(show)
+#pragma pack() // resets to default
+/* expected-warning {{value of #pragma pack(show) == 8}} */ #pragma pack(show)
+#pragma pack(2)
+#pragma pack(push, eek, 16) // -> (eek, 2), 16
+/* expected-warning {{value of #pragma pack(show) == 16}} */ #pragma pack(show)
+#pragma pack(push) // -> (eek, 2), (, 2), 16
+/* expected-warning {{value of #pragma pack(show) == 16}} */ #pragma pack(show)
+#pragma pack(1)
+#pragma pack(push, 8) // -> (eek, 2), (, 2), (, 1), 8
+/* expected-warning {{value of #pragma pack(show) == 8}} */ #pragma pack(show)
+#pragma pack(pop) // -> (eek, 2), (,2), 1
+/* expected-warning {{value of #pragma pack(show) == 1}} */ #pragma pack(show)
+#pragma pack(pop, eek)
+/* expected-warning {{value of #pragma pack(show) == 2}} */ #pragma pack(show)
+/* expected-warning {{pack(pop, ...) failed: stack empty}} */ #pragma pack(pop)
+
+#pragma pack(push)
+#pragma pack(pop, 16)
+/* expected-warning {{value of #pragma pack(show) == 16}} */ #pragma pack(show)
+
diff --git a/clang/test/Sema/pragma-unused.c b/clang/test/Sema/pragma-unused.c
new file mode 100644
index 0000000..aafac0d
--- /dev/null
+++ b/clang/test/Sema/pragma-unused.c
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -Wused-but-marked-unused -Wunused -verify %s
+
+void f1(void) {
+ int x, y, z;
+ #pragma unused(x)
+ #pragma unused(y, z)
+
+ int w; // expected-warning {{unused}}
+ #pragma unused w // expected-warning{{missing '(' after '#pragma unused' - ignoring}}
+}
+
+void f2(void) {
+ int x, y; // expected-warning {{unused}} expected-warning {{unused}}
+ #pragma unused(x,) // expected-warning{{expected '#pragma unused' argument to be a variable name}}
+ #pragma unused() // expected-warning{{expected '#pragma unused' argument to be a variable name}}
+}
+
+void f3(void) {
+ #pragma unused(x) // expected-warning{{undeclared variable 'x' used as an argument for '#pragma unused'}}
+}
+
+void f4(void) {
+ int w; // expected-warning {{unused}}
+ #pragma unused((w)) // expected-warning{{expected '#pragma unused' argument to be a variable name}}
+}
+
+void f6(void) {
+ int z; // no-warning
+ {
+ #pragma unused(z) // no-warning
+ }
+}
+
+void f7() {
+ int y;
+ #pragma unused(undeclared, undefined, y) // expected-warning{{undeclared variable 'undeclared' used as an argument for '#pragma unused'}} expected-warning{{undeclared variable 'undefined' used as an argument for '#pragma unused'}}
+}
+
+int f8(int x) { // expected-warning{{unused parameter 'x'}}
+ return 0;
+}
+
+int f9(int x) {
+ return x;
+}
+
+int f10(int x) {
+ #pragma unused(x)
+ return 0;
+}
+
+int f11(int x) {
+ #pragma unused(x)
+ return x; // expected-warning{{'x' was marked unused but was used}}
+}
+
+int f12(int x) {
+ int y = x;
+ #pragma unused(x) // expected-warning{{'x' was marked unused but was used}}
+ return y;
+}
+
+// rdar://8793832
+static int glob_var = 0;
+#pragma unused(glob_var)
diff --git a/clang/test/Sema/predef.c b/clang/test/Sema/predef.c
new file mode 100644
index 0000000..95bcfb9
--- /dev/null
+++ b/clang/test/Sema/predef.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void abcdefghi12(void) {
+ const char (*ss)[12] = &__func__;
+ static int arr[sizeof(__func__)==12 ? 1 : -1];
+}
+
+char *X = __func__; // expected-warning {{predefined identifier is only valid}} \
+ expected-warning {{initializing 'char *' with an expression of type 'const char [1]' discards qualifiers}}
+
+void a() {
+ __func__[0] = 'a'; // expected-error {{variable is not assignable}}
+}
+
+// rdar://6097892 - GCC permits this insanity.
+const char *b = __func__; // expected-warning {{predefined identifier is only valid}}
+const char *c = __FUNCTION__; // expected-warning {{predefined identifier is only valid}}
+const char *d = __PRETTY_FUNCTION__; // expected-warning {{predefined identifier is only valid}}
+
diff --git a/clang/test/Sema/predefined-function.c b/clang/test/Sema/predefined-function.c
new file mode 100644
index 0000000..1c40b6e
--- /dev/null
+++ b/clang/test/Sema/predefined-function.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+char *funk(int format);
+enum Test {A=-1};
+char *funk(enum Test x);
+
+int eli(float b); // expected-note {{previous declaration is here}} \
+// expected-note{{passing argument to parameter 'b' here}}
+int b(int c) {return 1;}
+
+int foo();
+int foo() {
+ int eli(int (int)); // expected-error {{conflicting types for 'eli'}}
+ eli(b); // expected-error{{passing 'int (int)' to parameter of incompatible type 'float'}}
+ return 0;
+}
+
+int bar();
+int bar(int i) // expected-note {{previous definition is here}}
+{
+ return 0;
+}
+int bar() // expected-error {{redefinition of 'bar'}}
+{
+ return 0;
+}
+
+int foobar(int); // note {{previous declaration is here}}
+int foobar() // error {{conflicting types for 'foobar'}}
+{
+ return 0;
+}
+
+int wibble(); // expected-note {{previous declaration is here}}
+float wibble() // expected-error {{conflicting types for 'wibble'}}
+{
+ return 0.0f;
+}
diff --git a/clang/test/Sema/private-extern.c b/clang/test/Sema/private-extern.c
new file mode 100644
index 0000000..25591dc
--- /dev/null
+++ b/clang/test/Sema/private-extern.c
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+static int g0; // expected-note{{previous definition}}
+int g0; // expected-error{{non-static declaration of 'g0' follows static declaration}}
+
+static int g1;
+extern int g1;
+
+static int g2;
+__private_extern__ int g2;
+
+int g3; // expected-note{{previous definition}}
+static int g3; // expected-error{{static declaration of 'g3' follows non-static declaration}}
+
+extern int g4; // expected-note{{previous definition}}
+static int g4; // expected-error{{static declaration of 'g4' follows non-static declaration}}
+
+__private_extern__ int g5; // expected-note{{previous definition}}
+static int g5; // expected-error{{static declaration of 'g5' follows non-static declaration}}
+
+void f0() {
+ int g6; // expected-note {{previous}}
+ extern int g6; // expected-error {{extern declaration of 'g6' follows non-extern declaration}}
+}
+
+void f1() {
+ int g7; // expected-note {{previous}}
+ __private_extern__ int g7; // expected-error {{extern declaration of 'g7' follows non-extern declaration}}
+}
+
+void f2() {
+ extern int g8; // expected-note{{previous definition}}
+ int g8; // expected-error {{non-extern declaration of 'g8' follows extern declaration}}
+}
+
+void f3() {
+ __private_extern__ int g9; // expected-note{{previous definition}}
+ int g9; // expected-error {{non-extern declaration of 'g9' follows extern declaration}}
+}
+
+void f4() {
+ extern int g10;
+ extern int g10;
+}
+
+void f5() {
+ __private_extern__ int g11;
+ __private_extern__ int g11;
+}
+
+void f6() {
+ // FIXME: Diagnose
+ extern int g12;
+ __private_extern__ int g12;
+}
+
+void f7() {
+ // FIXME: Diagnose
+ __private_extern__ int g13;
+ extern int g13;
+}
+
+struct s0;
+void f8() {
+ extern struct s0 g14;
+ __private_extern__ struct s0 g14;
+}
+struct s0 { int x; };
+
+void f9() {
+ extern int g15 = 0; // expected-error{{'extern' variable cannot have an initializer}}
+ // FIXME: linkage specifier in warning.
+ __private_extern__ int g16 = 0; // expected-error{{'extern' variable cannot have an initializer}}
+}
+
+extern int g17;
+int g17 = 0;
+
+extern int g18 = 0; // expected-warning{{'extern' variable has an initializer}}
+
+__private_extern__ int g19;
+int g19 = 0;
+
+__private_extern__ int g20 = 0;
diff --git a/clang/test/Sema/rdr6094103-unordered-compare-promote.c b/clang/test/Sema/rdr6094103-unordered-compare-promote.c
new file mode 100644
index 0000000..7bb363e
--- /dev/null
+++ b/clang/test/Sema/rdr6094103-unordered-compare-promote.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -ast-dump %s 2>&1 | grep ImplicitCastExpr | count 4
+
+int foo (double x, long double y) {
+ // There needs to be an implicit cast on x here.
+ return __builtin_isgreater(x, y);
+}
diff --git a/clang/test/Sema/recover-goto.c b/clang/test/Sema/recover-goto.c
new file mode 100644
index 0000000..0e8f6d3
--- /dev/null
+++ b/clang/test/Sema/recover-goto.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+void a() { // expected-note {{to match this '{'}}
+ goto A; // expected-error {{use of undeclared label}}
+// expected-error {{expected '}'}}
diff --git a/clang/test/Sema/redefinition.c b/clang/test/Sema/redefinition.c
new file mode 100644
index 0000000..1ee35f7
--- /dev/null
+++ b/clang/test/Sema/redefinition.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+int f(int a) { return 0; } // expected-note {{previous definition is here}}
+int f(int);
+int f(int a) { return 0; } // expected-error {{redefinition of 'f'}}
+
+// <rdar://problem/6097326>
+int foo(x) {
+ return 0;
+}
+int x = 1;
+
+// <rdar://problem/6880464>
+extern inline int g(void) { return 0; } // expected-note{{previous definition}}
+int g(void) { return 0; } // expected-error{{redefinition of a 'extern inline' function 'g' is not supported in C99 mode}}
diff --git a/clang/test/Sema/return-noreturn.c b/clang/test/Sema/return-noreturn.c
new file mode 100644
index 0000000..448fce7
--- /dev/null
+++ b/clang/test/Sema/return-noreturn.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks -Wmissing-noreturn -Wno-unreachable-code
+
+int j;
+void test1() { // expected-warning {{function 'test1' could be declared with attribute 'noreturn'}}
+ ^ (void) { while (1) { } }(); // expected-warning {{block could be declared with attribute 'noreturn'}}
+ ^ (void) { if (j) while (1) { } }();
+ while (1) { }
+}
+
+void test2() {
+ if (j) while (1) { }
+}
+
+__attribute__((__noreturn__))
+void test2_positive() {
+ if (j) while (1) { }
+} // expected-warning{{function declared 'noreturn' should not return}}
+
+
+// This test case illustrates that we don't warn about the missing return
+// because the function is marked noreturn and there is an infinite loop.
+extern int foo_test_3();
+__attribute__((__noreturn__)) void* test3(int arg) {
+ while (1) foo_test_3();
+}
+
+__attribute__((__noreturn__)) void* test3_positive(int arg) {
+ while (0) foo_test_3();
+} // expected-warning{{function declared 'noreturn' should not return}}
+
+
+// PR5298 - -Wmissing-noreturn shouldn't warn if the function is already
+// declared noreturn.
+void __attribute__((noreturn))
+test4() {
+ test2_positive();
+}
diff --git a/clang/test/Sema/return-silent.c b/clang/test/Sema/return-silent.c
new file mode 100644
index 0000000..eb9641b
--- /dev/null
+++ b/clang/test/Sema/return-silent.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -Wno-return-type -fsyntax-only -verify
+
+int t14() {
+ return;
+}
+
+void t15() {
+ return 1;
+}
diff --git a/clang/test/Sema/return.c b/clang/test/Sema/return.c
new file mode 100644
index 0000000..77bd3f6
--- /dev/null
+++ b/clang/test/Sema/return.c
@@ -0,0 +1,266 @@
+// RUN: %clang %s -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -Xclang -verify -fblocks -Wno-unreachable-code -Wno-unused-value
+
+// clang emits the following warning by default.
+// With GCC, -pedantic, -Wreturn-type or -Wall are required to produce the
+// following warning.
+int t14() {
+ return; // expected-warning {{non-void function 't14' should return a value}}
+}
+
+void t15() {
+ return 1; // expected-warning {{void function 't15' should not return a value}}
+}
+
+int unknown();
+
+void test0() {
+}
+
+int test1() {
+} // expected-warning {{control reaches end of non-void function}}
+
+int test2() {
+ a: goto a;
+}
+
+int test3() {
+ goto a;
+ a: ;
+} // expected-warning {{control reaches end of non-void function}}
+
+
+void halt() {
+ a: goto a;
+}
+
+void halt2() __attribute__((noreturn));
+
+int test4() {
+ halt2();
+}
+
+int test5() {
+ halt2(), (void)1;
+}
+
+int test6() {
+ 1, halt2();
+}
+
+int j;
+int unknown_nohalt() {
+ return j;
+}
+
+int test7() {
+ unknown();
+} // expected-warning {{control reaches end of non-void function}}
+
+int test8() {
+ (void)(1 + unknown());
+} // expected-warning {{control reaches end of non-void function}}
+
+int halt3() __attribute__((noreturn));
+
+int test9() {
+ (void)(halt3() + unknown());
+}
+
+int test10() {
+ (void)(unknown() || halt3());
+} // expected-warning {{control may reach end of non-void function}}
+
+int test11() {
+ (void)(unknown() && halt3());
+} // expected-warning {{control may reach end of non-void function}}
+
+int test12() {
+ (void)(halt3() || unknown());
+}
+
+int test13() {
+ (void)(halt3() && unknown());
+}
+
+int test14() {
+ (void)(1 || unknown());
+} // expected-warning {{control reaches end of non-void function}}
+
+int test15() {
+ (void)(0 || unknown());
+} // expected-warning {{control reaches end of non-void function}}
+
+int test16() {
+ (void)(0 && unknown());
+} // expected-warning {{control reaches end of non-void function}}
+
+int test17() {
+ (void)(1 && unknown());
+} // expected-warning {{control reaches end of non-void function}}
+
+int test18() {
+ (void)(unknown_nohalt() && halt3());
+} // expected-warning {{control may reach end of non-void function}}
+
+int test19() {
+ (void)(unknown_nohalt() && unknown());
+} // expected-warning {{control reaches end of non-void function}}
+
+int test20() {
+ int i;
+ if (i)
+ return 0;
+ else if (0)
+ return 2;
+} // expected-warning {{control may reach end of non-void function}}
+
+int test21() {
+ int i;
+ if (i)
+ return 0;
+ else if (1)
+ return 2;
+}
+
+int test22() {
+ int i;
+ switch (i) default: ;
+} // expected-warning {{control reaches end of non-void function}}
+
+int test23() {
+ int i;
+ switch (i) {
+ case 0:
+ return 0;
+ case 2:
+ return 2;
+ }
+} // expected-warning {{control may reach end of non-void function}}
+
+int test24() {
+ int i;
+ switch (i) {
+ case 0:
+ return 0;
+ case 2:
+ return 2;
+ default:
+ return -1;
+ }
+}
+
+int test25() {
+ 1 ? halt3() : unknown();
+}
+
+int test26() {
+ 0 ? halt3() : unknown();
+} // expected-warning {{control reaches end of non-void function}}
+
+int j;
+void (*fptr)() __attribute__((noreturn));
+int test27() {
+ switch (j) {
+ case 1:
+ do { } while (1);
+ break;
+ case 2:
+ for (;;) ;
+ break;
+ case 3:
+ for (;1;) ;
+ for (;0;) {
+ goto done;
+ }
+ return 1;
+ case 4:
+ while (0) { goto done; }
+ return 1;
+ case 5:
+ while (1) { return 1; }
+ break;
+ case 6:
+ fptr();
+ break;
+ default:
+ return 1;
+ }
+ done: ;
+}
+
+// PR4624
+void test28() __attribute__((noreturn));
+void test28(x) { while (1) { } }
+
+void exit(int);
+int test29() {
+ exit(1);
+}
+
+#include <setjmp.h>
+jmp_buf test30_j;
+int test30() {
+ if (j)
+ longjmp(test30_j, 1);
+ else
+#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
+ longjmp(test30_j, 2);
+#else
+ _longjmp(test30_j, 1);
+#endif
+}
+
+typedef void test31_t(int status);
+void test31(test31_t *callback __attribute__((noreturn)));
+
+void test32() {
+ ^ (void) { while (1) { } }();
+ ^ (void) { if (j) while (1) { } }();
+ while (1) { }
+}
+
+void test33() {
+ if (j) while (1) { }
+}
+
+// Test that 'static inline' functions are only analyzed for CFG-based warnings
+// when they are used.
+static inline int si_has_missing_return() {} // expected-warning{{control reaches end of non-void function}}
+static inline int si_has_missing_return_2() {}; // expected-warning{{control reaches end of non-void function}}
+static inline int si_forward();
+static inline int si_has_missing_return_3(int x) {
+ if (x)
+ return si_has_missing_return_3(x+1);
+} // expected-warning{{control may reach end of non-void function}}
+
+int test_static_inline(int x) {
+ si_forward();
+ return x ? si_has_missing_return_2() : si_has_missing_return_3(x);
+}
+static inline int si_forward() {} // expected-warning{{control reaches end of non-void function}}
+
+// Test warnings on ignored qualifiers on return types.
+const int ignored_c_quals(); // expected-warning{{'const' type qualifier on return type has no effect}}
+const volatile int ignored_cv_quals(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
+char* const volatile restrict ignored_cvr_quals(); // expected-warning{{'const volatile restrict' type qualifiers on return type have no effect}}
+
+// Test that for switch(enum) that if the switch statement covers all the cases
+// that we don't consider that for -Wreturn-type.
+enum Cases { C1, C2, C3, C4 };
+int test_enum_cases(enum Cases C) {
+ switch (C) {
+ case C1: return 1;
+ case C2: return 2;
+ case C4: return 3;
+ case C3: return 4;
+ }
+} // no-warning
+
+// PR12318 - Don't give a may reach end of non-void function warning.
+int test34(int x) {
+ if (x == 1) {
+ return 3;
+ } else if ( x == 2 || 1) {
+ return 5;
+ }
+}
diff --git a/clang/test/Sema/scope-check.c b/clang/test/Sema/scope-check.c
new file mode 100644
index 0000000..a9494d3
--- /dev/null
+++ b/clang/test/Sema/scope-check.c
@@ -0,0 +1,234 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=gnu99 %s -Wno-unreachable-code
+
+int test1(int x) {
+ goto L; // expected-error{{goto into protected scope}}
+ int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
+ int b[x]; // expected-note {{jump bypasses initialization of variable length array}}
+ L:
+ return sizeof a;
+}
+
+int test2(int x) {
+ goto L; // expected-error{{goto into protected scope}}
+ typedef int a[x]; // expected-note {{jump bypasses initialization of VLA typedef}}
+ L:
+ return sizeof(a);
+}
+
+void test3clean(int*);
+
+int test3() {
+ goto L; // expected-error{{goto into protected scope}}
+int a __attribute((cleanup(test3clean))); // expected-note {{jump bypasses initialization of variable with __attribute__((cleanup))}}
+L:
+ return a;
+}
+
+int test4(int x) {
+ goto L; // expected-error{{goto into protected scope}}
+int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
+ test4(x);
+L:
+ return sizeof a;
+}
+
+int test5(int x) {
+ int a[x];
+ test5(x);
+ goto L; // Ok.
+L:
+ goto L; // Ok.
+ return sizeof a;
+}
+
+int test6() {
+ // just plain invalid.
+ goto x; // expected-error {{use of undeclared label 'x'}}
+}
+
+void test7(int x) {
+ switch (x) {
+ case 1: ;
+ int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
+ case 2: // expected-error {{switch case is in protected scope}}
+ a[1] = 2;
+ break;
+ }
+}
+
+int test8(int x) {
+ // For statement.
+ goto L2; // expected-error {{goto into protected scope}}
+ for (int arr[x]; // expected-note {{jump bypasses initialization of variable length array}}
+ ; ++x)
+ L2:;
+
+ // Statement expressions.
+ goto L3; // expected-error {{goto into protected scope}}
+ int Y = ({ int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
+ L3: 4; });
+
+ goto L4; // expected-error {{goto into protected scope}}
+ {
+ int A[x], // expected-note {{jump bypasses initialization of variable length array}}
+ B[x]; // expected-note {{jump bypasses initialization of variable length array}}
+ L4: ;
+ }
+
+ {
+ L5: ;// ok
+ int A[x], B = ({ if (x)
+ goto L5;
+ else
+ goto L6;
+ 4; });
+ L6:; // ok.
+ if (x) goto L6; // ok
+ }
+
+ {
+ L7: ;// ok
+ int A[x], B = ({ if (x)
+ goto L7;
+ else
+ goto L8; // expected-error {{goto into protected scope}}
+ 4; }),
+ C[x]; // expected-note {{jump bypasses initialization of variable length array}}
+ L8:; // bad
+ }
+
+ {
+ L9: ;// ok
+ int A[({ if (x)
+ goto L9;
+ else
+ // FIXME:
+ goto L10; // fixme-error {{goto into protected scope}}
+ 4; })];
+ L10:; // bad
+ }
+
+ {
+ // FIXME: Crashes goto checker.
+ //goto L11;// ok
+ //int A[({ L11: 4; })];
+ }
+
+ {
+ goto L12;
+
+ int y = 4; // fixme-warn: skips initializer.
+ L12:
+ ;
+ }
+
+ // Statement expressions 2.
+ goto L1; // expected-error {{goto into protected scope}}
+ return x == ({
+ int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
+ L1:
+ 42; });
+}
+
+void test9(int n, void *P) {
+ int Y;
+ int Z = 4;
+ goto *P; // expected-error {{indirect goto might cross protected scopes}}
+
+L2: ;
+ int a[n]; // expected-note {{jump bypasses initialization of variable length array}}
+
+L3: // expected-note {{possible target of indirect goto}}
+L4:
+ goto *P;
+ goto L3; // ok
+ goto L4; // ok
+
+ void *Ptrs[] = {
+ &&L2,
+ &&L3
+ };
+}
+
+void test10(int n, void *P) {
+ goto L0; // expected-error {{goto into protected scope}}
+ typedef int A[n]; // expected-note {{jump bypasses initialization of VLA typedef}}
+L0:
+
+ goto L1; // expected-error {{goto into protected scope}}
+ A b, c[10]; // expected-note 2 {{jump bypasses initialization of variable length array}}
+L1:
+ goto L2; // expected-error {{goto into protected scope}}
+ A d[n]; // expected-note {{jump bypasses initialization of variable length array}}
+L2:
+ return;
+}
+
+void test11(int n) {
+ void *P = ^{
+ switch (n) {
+ case 1:;
+ case 2:
+ case 3:;
+ int Arr[n]; // expected-note {{jump bypasses initialization of variable length array}}
+ case 4: // expected-error {{switch case is in protected scope}}
+ return;
+ }
+ };
+}
+
+
+// TODO: When and if gotos are allowed in blocks, this should work.
+void test12(int n) {
+ void *P = ^{
+ goto L1;
+ L1:
+ goto L2;
+ L2:
+ goto L3; // expected-error {{goto into protected scope}}
+ int Arr[n]; // expected-note {{jump bypasses initialization of variable length array}}
+ L3:
+ goto L4;
+ L4: return;
+ };
+}
+
+void test13(int n, void *p) {
+ int vla[n];
+ goto *p;
+ a0: ;
+ static void *ps[] = { &&a0 };
+}
+
+int test14(int n) {
+ static void *ps[] = { &&a0, &&a1 };
+ if (n < 0)
+ goto *&&a0;
+
+ if (n > 0) {
+ int vla[n];
+ a1:
+ vla[n-1] = 0;
+ }
+ a0:
+ return 0;
+}
+
+
+// PR8473: IR gen can't deal with indirect gotos past VLA
+// initialization, so that really needs to be a hard error.
+void test15(int n, void *pc) {
+ static const void *addrs[] = { &&L1, &&L2 };
+
+ goto *pc; // expected-error {{indirect goto might cross protected scope}}
+
+ L1:
+ {
+ char vla[n]; // expected-note {{jump bypasses initialization}}
+ L2: // expected-note {{possible target}}
+ vla[0] = 'a';
+ }
+}
+
+// rdar://9024687
+int test16(int [sizeof &&z]); // expected-error {{use of address-of-label extension outside of a function body}}
diff --git a/clang/test/Sema/self-comparison.c b/clang/test/Sema/self-comparison.c
new file mode 100644
index 0000000..edb3a6a
--- /dev/null
+++ b/clang/test/Sema/self-comparison.c
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int foo(int x) {
+ return x == x; // expected-warning {{self-comparison always evaluates to true}}
+}
+
+int foo2(int x) {
+ return (x) != (((x))); // expected-warning {{self-comparison always evaluates to false}}
+}
+
+void foo3(short s, short t) {
+ if (s == s) {} // expected-warning {{self-comparison always evaluates to true}}
+ if (s == t) {} // no-warning
+}
+
+void foo4(void* v, void* w) {
+ if (v == v) {} // expected-warning {{self-comparison always evaluates to true}}
+ if (v == w) {} // no-warning
+}
+
+int qux(int x) {
+ return x < x; // expected-warning {{self-comparison}}
+}
+
+int qux2(int x) {
+ return x > x; // expected-warning {{self-comparison}}
+}
+
+int bar(float x) {
+ return x == x; // no-warning
+}
+
+int bar2(float x) {
+ return x != x; // no-warning
+}
+
+#define IS_THE_ANSWER(x) (x == 42)
+
+int macro_comparison() {
+ return IS_THE_ANSWER(42);
+}
+
+// Don't complain in unevaluated contexts.
+int compare_sizeof(int x) {
+ return sizeof(x == x); // no-warning
+}
+
+int array_comparisons() {
+ int array1[2];
+ int array2[2];
+
+ //
+ // compare same array
+ //
+ return array1 == array1; // expected-warning{{self-comparison always evaluates to true}}
+ return array1 != array1; // expected-warning{{self-comparison always evaluates to false}}
+ return array1 < array1; // expected-warning{{self-comparison always evaluates to false}}
+ return array1 <= array1; // expected-warning{{self-comparison always evaluates to true}}
+ return array1 > array1; // expected-warning{{self-comparison always evaluates to false}}
+ return array1 >= array1; // expected-warning{{self-comparison always evaluates to true}}
+
+ //
+ // compare differrent arrays
+ //
+ return array1 == array2; // expected-warning{{array comparison always evaluates to false}}
+ return array1 != array2; // expected-warning{{array comparison always evaluates to true}}
+
+ //
+ // we don't know what these are going to be
+ //
+ return array1 < array2; // expected-warning{{array comparison always evaluates to a constant}}
+ return array1 <= array2; // expected-warning{{array comparison always evaluates to a constant}}
+ return array1 > array2; // expected-warning{{array comparison always evaluates to a constant}}
+ return array1 >= array2; // expected-warning{{array comparison always evaluates to a constant}}
+
+}
+
+// Don't issue a warning when either the left or right side of the comparison
+// results from a macro expansion. <rdar://problem/8435950>
+#define R8435950_A i
+#define R8435950_B i
+
+int R8435950(int i) {
+ if (R8435950_A == R8435950_B) // no-warning
+ return 0;
+ return 1;
+}
+
diff --git a/clang/test/Sema/sentinel-attribute.c b/clang/test/Sema/sentinel-attribute.c
new file mode 100644
index 0000000..e5cbf6e
--- /dev/null
+++ b/clang/test/Sema/sentinel-attribute.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+int x __attribute__((sentinel)); //expected-warning{{'sentinel' attribute only applies to functions, methods and blocks}}
+
+void f1(int a, ...) __attribute__ ((sentinel));
+void f2(int a, ...) __attribute__ ((sentinel(1)));
+
+void f3(int a, ...) __attribute__ ((sentinel("hello"))); //expected-error{{'sentinel' attribute requires parameter 1 to be an integer constant}}
+void f4(int a, ...) __attribute__ ((sentinel(1, 2, 3))); //expected-error{{attribute takes no more than 2 arguments}}
+void f4(int a, ...) __attribute__ ((sentinel(-1))); //expected-error{{parameter 1 less than zero}}
+void f4(int a, ...) __attribute__ ((sentinel(0, 2))); // expected-error{{parameter 2 not 0 or 1}}
+
+void f5(int a) __attribute__ ((sentinel)); //expected-warning{{'sentinel' attribute only supported for variadic functions}}
+
+
+void f6() __attribute__((__sentinel__)); // expected-warning {{'sentinel' attribute requires named arguments}}
diff --git a/clang/test/Sema/shift.c b/clang/test/Sema/shift.c
new file mode 100644
index 0000000..142d83c
--- /dev/null
+++ b/clang/test/Sema/shift.c
@@ -0,0 +1,68 @@
+// RUN: %clang -Wall -Wshift-sign-overflow -ffreestanding -fsyntax-only -Xclang -verify %s
+
+#include <limits.h>
+
+#define WORD_BIT (sizeof(int) * CHAR_BIT)
+
+enum {
+ X = 1 << 0,
+ Y = 1 << 1,
+ Z = 1 << 2
+};
+
+void test() {
+ char c;
+
+ c = 0 << 0;
+ c = 0 << 1;
+ c = 1 << 0;
+ c = 1 << -0;
+ c = 1 >> -0;
+ c = 1 << -1; // expected-warning {{shift count is negative}}
+ c = 1 >> -1; // expected-warning {{shift count is negative}}
+ c = 1 << c;
+ c <<= 0;
+ c >>= 0;
+ c <<= 1;
+ c >>= 1;
+ c <<= -1; // expected-warning {{shift count is negative}}
+ c >>= -1; // expected-warning {{shift count is negative}}
+ c <<= 999999; // expected-warning {{shift count >= width of type}}
+ c >>= 999999; // expected-warning {{shift count >= width of type}}
+ c <<= CHAR_BIT; // expected-warning {{shift count >= width of type}}
+ c >>= CHAR_BIT; // expected-warning {{shift count >= width of type}}
+ c <<= CHAR_BIT+1; // expected-warning {{shift count >= width of type}}
+ c >>= CHAR_BIT+1; // expected-warning {{shift count >= width of type}}
+ (void)((long)c << CHAR_BIT);
+
+ int i;
+ i = 1 << (WORD_BIT - 2);
+ i = 2 << (WORD_BIT - 1); // expected-warning {{bits to represent, but 'int' only has}}
+ i = 1 << (WORD_BIT - 1); // expected-warning {{sets the sign bit of the shift expression}}
+ i = -1 << (WORD_BIT - 1);
+ i = 0 << (WORD_BIT - 1);
+ i = (char)1 << (WORD_BIT - 2);
+
+ unsigned u;
+ u = 1U << (WORD_BIT - 1);
+ u = 5U << (WORD_BIT - 1);
+
+ long long int lli;
+ lli = INT_MIN << 2; // expected-warning {{bits to represent, but 'int' only has}}
+ lli = 1LL << (sizeof(long long) * CHAR_BIT - 2);
+}
+
+#define a 0
+#define ashift 8
+enum { b = (a << ashift) };
+
+// Don't warn for negative shifts in code that is unreachable.
+void test_pr5544() {
+ (void) (((1) > 63 && (1) < 128 ? (((unsigned long long) 1)<<((1)-64)) : (unsigned long long) 0)); // no-warning
+}
+
+void test_shift_too_much(char x) {
+ if (0)
+ (void) (x >> 80); // no-warning
+ (void) (x >> 80); // expected-warning {{shift count >= width of type}}
+}
diff --git a/clang/test/Sema/short-enums.c b/clang/test/Sema/short-enums.c
new file mode 100644
index 0000000..6605c4e
--- /dev/null
+++ b/clang/test/Sema/short-enums.c
@@ -0,0 +1,5 @@
+// RUN: not %clang_cc1 -fsyntax-only %s -verify
+// RUN: %clang_cc1 -fshort-enums -fsyntax-only %s -verify
+
+enum x { A };
+int t0[sizeof(enum x) == 1 ? 1 : -1];
diff --git a/clang/test/Sema/sign-conversion.c b/clang/test/Sema/sign-conversion.c
new file mode 100644
index 0000000..4b1ee75
--- /dev/null
+++ b/clang/test/Sema/sign-conversion.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion %s
+
+// PR9345: make a subgroup of -Wconversion for signedness changes
+
+void test(int x) {
+ unsigned t0 = x; // expected-warning {{implicit conversion changes signedness}}
+ unsigned t1 = (t0 == 5 ? x : 0); // expected-warning {{operand of ? changes signedness}}
+}
diff --git a/clang/test/Sema/statements.c b/clang/test/Sema/statements.c
new file mode 100644
index 0000000..f01ee40
--- /dev/null
+++ b/clang/test/Sema/statements.c
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+typedef unsigned __uint32_t;
+
+#define __byte_swap_int_var(x) \
+__extension__ ({ register __uint32_t __X = (x); \
+ __asm ("bswap %0" : "+r" (__X)); \
+ __X; })
+
+int test(int _x) {
+ return (__byte_swap_int_var(_x));
+}
+
+// PR2374
+int test2() { return ({L:5;}); }
+int test3() { return ({ {5;} }); } // expected-error {{returning 'void' from a function with incompatible result type 'int'}}\
+ // expected-warning {{expression result unused}}
+int test4() { return ({ ({5;}); }); }
+int test5() { return ({L1: L2: L3: 5;}); }
+int test6() { return ({5;}); }
+void test7() { ({5;}); } // expected-warning {{expression result unused}}
+
+// PR3062
+int test8[({10;})]; // expected-error {{statement expression not allowed at file scope}}
+
+// PR3912
+void test9(const void *P) {
+ __builtin_prefetch(P);
+}
+
+
+void *test10() {
+bar:
+ return &&bar; // expected-warning {{returning address of label, which is local}}
+}
+
+// PR6034
+void test11(int bit) {
+ switch (bit) // expected-warning {{switch statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
+ switch (env->fpscr) // expected-error {{use of undeclared identifier 'env'}}
+ {
+ }
+}
+
+// rdar://3271964
+enum Numbers { kOne, kTwo, kThree, kFour};
+int test12(enum Numbers num) {
+ switch (num == kOne) {// expected-warning {{switch condition has boolean value}}
+ default:
+ case kThree:
+ break;
+ }
+}
+
+
+enum x { a, b, c, d, e, f, g };
+
+void foo(enum x X) {
+ switch (X) { // expected-warning {{enumeration value 'g' not handled in switch}}
+ case a:
+ case b:
+ case c:
+ case d:
+ case e:
+ case f:
+ break;
+ }
+
+ switch (X) { // expected-warning {{enumeration values 'f' and 'g' not handled in switch}}
+ case a:
+ case b:
+ case c:
+ case d:
+ case e:
+ break;
+ }
+
+ switch (X) { // expected-warning {{enumeration values 'e', 'f', and 'g' not handled in switch}}
+ case a:
+ case b:
+ case c:
+ case d:
+ break;
+ }
+
+ switch (X) { // expected-warning {{5 enumeration values not handled in switch: 'c', 'd', 'e'...}}
+ case a:
+ case b:
+ break;
+ }
+}
+
+// PR 8880
+// FIXME: Clang should reject this, since GCC does. Previously this
+// was causing a crash in the CFG builder.
+int test_pr8880() {
+ int first = 1;
+ for ( ; ({ if (first) { first = 0; continue; } 0; }); )
+ return 0;
+ return 1;
+}
+
diff --git a/clang/test/Sema/static-array.c b/clang/test/Sema/static-array.c
new file mode 100644
index 0000000..2d4b968
--- /dev/null
+++ b/clang/test/Sema/static-array.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void cat0(int a[static 0]) {} // expected-warning {{'static' has no effect on zero-length arrays}}
+
+void cat(int a[static 3]) {} // expected-note 2 {{callee declares array parameter as static here}}
+
+typedef int i3[static 3];
+void tcat(i3 a) {}
+
+void vat(int i, int a[static i]) {} // expected-note {{callee declares array parameter as static here}}
+
+void f(int *p) {
+ int a[2], b[3], c[4];
+
+ cat0(0);
+
+ cat(0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ cat(a); // expected-warning {{array argument is too small; contains 2 elements, callee requires at least 3}}
+ cat(b);
+ cat(c);
+ cat(p);
+
+ tcat(0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ tcat(a); // expected-warning {{array argument is too small; contains 2 elements, callee requires at least 3}}
+ tcat(b);
+ tcat(c);
+ tcat(p);
+
+ vat(1, 0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ vat(3, b);
+}
diff --git a/clang/test/Sema/static-assert.c b/clang/test/Sema/static-assert.c
new file mode 100644
index 0000000..13d7070
--- /dev/null
+++ b/clang/test/Sema/static-assert.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -std=c1x -fsyntax-only -verify %s
+
+_Static_assert("foo", "string is nonzero"); // expected-error {{static_assert expression is not an integral constant expression}}
+
+_Static_assert(1, "1 is nonzero");
+_Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}}
+
+void foo(void) {
+ _Static_assert(1, "1 is nonzero");
+ _Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}}
+}
diff --git a/clang/test/Sema/static-init.c b/clang/test/Sema/static-init.c
new file mode 100644
index 0000000..bbf9038
--- /dev/null
+++ b/clang/test/Sema/static-init.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef __typeof((int*) 0 - (int*) 0) intptr_t;
+
+static int f = 10;
+static int b = f; // expected-error {{initializer element is not a compile-time constant}}
+
+float r = (float) (intptr_t) &r; // expected-error {{initializer element is not a compile-time constant}}
+intptr_t s = (intptr_t) &s;
+_Bool t = &t;
+
+
+union bar {
+ int i;
+};
+
+struct foo {
+ short ptr;
+};
+
+union bar u[1];
+struct foo x = {(intptr_t) u}; // expected-error {{initializer element is not a compile-time constant}}
+struct foo y = {(char) u}; // expected-error {{initializer element is not a compile-time constant}}
+intptr_t z = (intptr_t) u; // no-error
diff --git a/clang/test/Sema/stdcall-fastcall.c b/clang/test/Sema/stdcall-fastcall.c
new file mode 100644
index 0000000..eeacf94
--- /dev/null
+++ b/clang/test/Sema/stdcall-fastcall.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-pc-linux-gnu %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-apple-darwin10 %s
+
+// CC qualifier can be applied only to functions
+int __attribute__((stdcall)) var1; // expected-warning{{'stdcall' only applies to function types; type here is 'int'}}
+int __attribute__((fastcall)) var2; // expected-warning{{'fastcall' only applies to function types; type here is 'int'}}
+
+// Different CC qualifiers are not compatible
+void __attribute__((stdcall, fastcall)) foo3(void); // expected-error{{fastcall and stdcall attributes are not compatible}}
+void __attribute__((stdcall)) foo4(); // expected-note{{previous declaration is here}}
+void __attribute__((fastcall)) foo4(void); // expected-error{{function declared 'fastcall' here was previously declared 'stdcall'}}
+
+// rdar://8876096
+void rdar8876096foo1(int i, int j) __attribute__((fastcall, cdecl)); // expected-error {{not compatible}}
+void rdar8876096foo2(int i, int j) __attribute__((fastcall, stdcall)); // expected-error {{not compatible}}
+void rdar8876096foo3(int i, int j) __attribute__((fastcall, regparm(2))); // expected-error {{not compatible}}
+void rdar8876096foo4(int i, int j) __attribute__((stdcall, cdecl)); // expected-error {{not compatible}}
+void rdar8876096foo5(int i, int j) __attribute__((stdcall, fastcall)); // expected-error {{not compatible}}
+void rdar8876096foo6(int i, int j) __attribute__((cdecl, fastcall)); // expected-error {{not compatible}}
+void rdar8876096foo7(int i, int j) __attribute__((cdecl, stdcall)); // expected-error {{not compatible}}
+void rdar8876096foo8(int i, int j) __attribute__((regparm(2), fastcall)); // expected-error {{not compatible}}
diff --git a/clang/test/Sema/struct-cast.c b/clang/test/Sema/struct-cast.c
new file mode 100644
index 0000000..30ef892
--- /dev/null
+++ b/clang/test/Sema/struct-cast.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+struct S {
+ int one;
+ int two;
+};
+
+struct S const foo(void);
+
+
+struct S tmp;
+
+void priv_sock_init() {
+ tmp = (struct S)foo();
+}
diff --git a/clang/test/Sema/struct-compat.c b/clang/test/Sema/struct-compat.c
new file mode 100644
index 0000000..65bef9f
--- /dev/null
+++ b/clang/test/Sema/struct-compat.c
@@ -0,0 +1,17 @@
+/* RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify
+ */
+
+extern struct {int a;} x; // expected-note {{previous definition is here}}
+extern struct {int a;} x; // expected-error {{redefinition of 'x'}}
+
+struct x;
+int a(struct x* b) {
+// Per C99 6.7.2.3, since the outer and inner "struct x"es have different
+// scopes, they don't refer to the same type, and are therefore incompatible
+struct x {int a;} *c = b; // expected-warning {{incompatible pointer types}}
+}
+
+struct x {int a;} r;
+int b() {
+struct x {char x;} s = r; // expected-error {{initializing 'struct x' with an expression of incompatible type 'struct x'}}
+}
diff --git a/clang/test/Sema/struct-decl.c b/clang/test/Sema/struct-decl.c
new file mode 100644
index 0000000..6070e87
--- /dev/null
+++ b/clang/test/Sema/struct-decl.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR3459
+struct bar {
+ char n[1];
+};
+
+struct foo {
+ char name[(int)&((struct bar *)0)->n];
+ char name2[(int)&((struct bar *)0)->n - 1]; //expected-error{{'name2' declared as an array with a negative size}}
+};
+
+// PR3430
+struct s {
+ struct st {
+ int v;
+ } *ts;
+};
+
+struct st;
+
+int foo() {
+ struct st *f;
+ return f->v + f[0].v;
+}
+
+// PR3642, PR3671
+struct pppoe_tag {
+ short tag_type;
+ char tag_data[];
+};
+struct datatag {
+ struct pppoe_tag hdr; //expected-warning{{field 'hdr' with variable sized type 'struct pppoe_tag' not at the end of a struct or class is a GNU extension}}
+ char data;
+};
+
+
+// PR4092
+struct s0 {
+ char a; // expected-note {{previous declaration is here}}
+ char a; // expected-error {{duplicate member 'a'}}
+};
+
+struct s0 f0(void) {}
+
+// <rdar://problem/8177927> - This previously triggered an assertion failure.
+struct x0 {
+ unsigned int x1;
+};
+
+// rdar://problem/9150338
+static struct test1 { // expected-warning {{'static' ignored on this declaration}}
+ int x;
+};
+const struct test2 { // expected-warning {{'const' ignored on this declaration}}
+ int x;
+};
+inline struct test3 { // expected-warning {{'inline' ignored on this declaration}}
+ int x;
+};
diff --git a/clang/test/Sema/struct-packed-align.c b/clang/test/Sema/struct-packed-align.c
new file mode 100644
index 0000000..6ca6a60
--- /dev/null
+++ b/clang/test/Sema/struct-packed-align.c
@@ -0,0 +1,134 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+// Packed structs.
+struct s {
+ char a;
+ int b __attribute__((packed));
+ char c;
+ int d;
+};
+
+extern int a1[sizeof(struct s) == 12 ? 1 : -1];
+extern int a2[__alignof(struct s) == 4 ? 1 : -1];
+
+struct __attribute__((packed)) packed_s {
+ char a;
+ int b __attribute__((packed));
+ char c;
+ int d;
+};
+
+extern int b1[sizeof(struct packed_s) == 10 ? 1 : -1];
+extern int b2[__alignof(struct packed_s) == 1 ? 1 : -1];
+
+struct fas {
+ char a;
+ int b[];
+};
+
+extern int c1[sizeof(struct fas) == 4 ? 1 : -1];
+extern int c2[__alignof(struct fas) == 4 ? 1 : -1];
+
+struct __attribute__((packed)) packed_fas {
+ char a;
+ int b[];
+};
+
+extern int d1[sizeof(struct packed_fas) == 1 ? 1 : -1];
+extern int d2[__alignof(struct packed_fas) == 1 ? 1 : -1];
+
+struct packed_after_fas {
+ char a;
+ int b[];
+} __attribute__((packed));
+
+extern int d1_2[sizeof(struct packed_after_fas) == 1 ? 1 : -1];
+extern int d2_2[__alignof(struct packed_after_fas) == 1 ? 1 : -1];
+
+// Alignment
+
+struct __attribute__((aligned(8))) as1 {
+ char c;
+};
+
+extern int e1[sizeof(struct as1) == 8 ? 1 : -1];
+extern int e2[__alignof(struct as1) == 8 ? 1 : -1];
+
+// FIXME: Will need to force arch once max usable alignment isn't hard
+// coded.
+struct __attribute__((aligned)) as1_2 {
+ char c;
+};
+extern int e1_2[sizeof(struct as1_2) == 16 ? 1 : -1];
+extern int e2_2[__alignof(struct as1_2) == 16 ? 1 : -1];
+
+struct as2 {
+ char c;
+ int __attribute__((aligned(8))) a;
+};
+
+extern int f1[sizeof(struct as2) == 16 ? 1 : -1];
+extern int f2[__alignof(struct as2) == 8 ? 1 : -1];
+
+struct __attribute__((packed)) as3 {
+ char c;
+ int a;
+ int __attribute__((aligned(8))) b;
+};
+
+extern int g1[sizeof(struct as3) == 16 ? 1 : -1];
+extern int g2[__alignof(struct as3) == 8 ? 1 : -1];
+
+
+// rdar://5921025
+struct packedtest {
+ int ted_likes_cheese;
+ void *args[] __attribute__((packed));
+};
+
+// Packed union
+union __attribute__((packed)) au4 {char c; int x;};
+extern int h1[sizeof(union au4) == 4 ? 1 : -1];
+extern int h2[__alignof(union au4) == 1 ? 1 : -1];
+
+// Aligned union
+union au5 {__attribute__((aligned(4))) char c;};
+extern int h1[sizeof(union au5) == 4 ? 1 : -1];
+extern int h2[__alignof(union au5) == 4 ? 1 : -1];
+
+// Alignment+packed
+struct as6 {char c; __attribute__((packed, aligned(2))) int x;};
+extern int i1[sizeof(struct as6) == 6 ? 1 : -1];
+extern int i2[__alignof(struct as6) == 2 ? 1 : -1];
+
+union au6 {char c; __attribute__((packed, aligned(2))) int x;};
+extern int k1[sizeof(union au6) == 4 ? 1 : -1];
+extern int k2[__alignof(union au6) == 2 ? 1 : -1];
+
+// Check postfix attributes
+union au7 {char c; int x;} __attribute__((packed));
+extern int l1[sizeof(union au7) == 4 ? 1 : -1];
+extern int l2[__alignof(union au7) == 1 ? 1 : -1];
+
+struct packed_fas2 {
+ char a;
+ int b[];
+} __attribute__((packed));
+
+extern int m1[sizeof(struct packed_fas2) == 1 ? 1 : -1];
+extern int m2[__alignof(struct packed_fas2) == 1 ? 1 : -1];
+
+// Attribute aligned can round down typedefs. PR9253
+typedef long long __attribute__((aligned(1))) nt;
+
+struct nS {
+ char buf_nr;
+ nt start_lba;
+};
+
+extern int n1[sizeof(struct nS) == 9 ? 1 : -1];
+extern int n2[__alignof(struct nS) == 1 ? 1 : -1];
+
+
+
+
diff --git a/clang/test/Sema/surpress-deprecated.c b/clang/test/Sema/surpress-deprecated.c
new file mode 100644
index 0000000..dd673b9
--- /dev/null
+++ b/clang/test/Sema/surpress-deprecated.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -Wno-deprecated-declarations -verify %s
+extern void OldFunction() __attribute__((deprecated));
+
+int main (int argc, const char * argv[]) {
+ OldFunction();
+}
+
diff --git a/clang/test/Sema/switch.c b/clang/test/Sema/switch.c
new file mode 100644
index 0000000..a7a7f60
--- /dev/null
+++ b/clang/test/Sema/switch.c
@@ -0,0 +1,322 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-enum -Wcovered-switch-default %s
+void f (int z) {
+ while (z) {
+ default: z--; // expected-error {{statement not in switch}}
+ }
+}
+
+void foo(int X) {
+ switch (X) {
+ case 42: ; // expected-note {{previous case}}
+ case 5000000000LL: // expected-warning {{overflow}}
+ case 42: // expected-error {{duplicate case value}}
+ ;
+
+ case 100 ... 99: ; // expected-warning {{empty case range}}
+
+ case 43: ; // expected-note {{previous case}}
+ case 43 ... 45: ; // expected-error {{duplicate case value}}
+
+ case 100 ... 20000:; // expected-note {{previous case}}
+ case 15000 ... 40000000:; // expected-error {{duplicate case value}}
+ }
+}
+
+void test3(void) {
+ // empty switch;
+ switch (0); // expected-warning {{no case matching constant switch condition '0'}} \
+ // expected-warning {{switch statement has empty body}} \
+ // expected-note{{put the semicolon on a separate line to silence this warning}}
+}
+
+extern int g();
+
+void test4()
+{
+ int cond;
+ switch (cond) {
+ case 0 && g():
+ case 1 || g():
+ break;
+ }
+
+ switch(cond) {
+ case g(): // expected-error {{expression is not an integer constant expression}}
+ case 0 ... g(): // expected-error {{expression is not an integer constant expression}}
+ break;
+ }
+
+ switch (cond) {
+ case 0 && g() ... 1 || g():
+ break;
+ }
+
+ switch (cond) {
+ case g() // expected-error {{expression is not an integer constant expression}}
+ && 0:
+ break;
+ }
+
+ switch (cond) {
+ case 0 ...
+ g() // expected-error {{expression is not an integer constant expression}}
+ || 1:
+ break;
+ }
+}
+
+void test5(int z) {
+ switch(z) {
+ default: // expected-note {{previous case defined here}}
+ default: // expected-error {{multiple default labels in one switch}}
+ break;
+ }
+}
+
+void test6() {
+ char ch = 'a';
+ switch(ch) {
+ case 1234: // expected-warning {{overflow converting case value}}
+ break;
+ }
+}
+
+// PR5606
+int f0(int var) {
+ switch (va) { // expected-error{{use of undeclared identifier 'va'}}
+ case 1:
+ break;
+ case 2:
+ return 1;
+ }
+ return 2;
+}
+
+void test7() {
+ enum {
+ A = 1,
+ B
+ } a;
+ switch(a) { //expected-warning{{enumeration value 'B' not handled in switch}}
+ case A:
+ break;
+ }
+ switch(a) {
+ case B:
+ case A:
+ break;
+ }
+ switch(a) {
+ case A:
+ case B:
+ case 3: // expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ break;
+ }
+ switch(a) {
+ case A:
+ case B:
+ case 3 ... //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ 4: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ break;
+ }
+ switch(a) {
+ case 1 ... 2:
+ break;
+ }
+ switch(a) {
+ case 0 ... 2: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ break;
+ }
+ switch(a) {
+ case 1 ... 3: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ break;
+ }
+ switch(a) {
+ case 0 ... //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ 3: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ break;
+ }
+
+}
+
+void test8() {
+ enum {
+ A,
+ B,
+ C = 1
+ } a;
+ switch(a) {
+ case A:
+ case B:
+ break;
+ }
+ switch(a) {
+ case A:
+ case C:
+ break;
+ }
+ switch(a) { //expected-warning{{enumeration value 'B' not handled in switch}}
+ case A:
+ break;
+ }
+}
+
+void test9() {
+ enum {
+ A = 3,
+ C = 1
+ } a;
+ switch(a) {
+ case 0: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ case 1:
+ case 2: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ case 3:
+ case 4: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ break;
+ }
+}
+
+void test10() {
+ enum {
+ A = 10,
+ C = 2,
+ B = 4,
+ D = 12
+ } a;
+ switch(a) {
+ case 0 ... //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ 1: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ case 2 ... 4:
+ case 5 ... //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ 9: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ case 10 ... 12:
+ case 13 ... //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ 16: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ break;
+ }
+}
+
+void test11() {
+ enum {
+ A = -1,
+ B,
+ C
+ } a;
+ switch(a) { //expected-warning{{enumeration value 'A' not handled in switch}}
+ case B:
+ case C:
+ break;
+ }
+
+ switch(a) { //expected-warning{{enumeration value 'A' not explicitly handled in switch}}
+ case B:
+ case C:
+ break;
+
+ default:
+ break;
+ }
+}
+
+void test12() {
+ enum {
+ A = -1,
+ B = 4294967286
+ } a;
+ switch(a) {
+ case A:
+ case B:
+ break;
+ }
+}
+
+// <rdar://problem/7643909>
+typedef enum {
+ val1,
+ val2,
+ val3
+} my_type_t;
+
+int test13(my_type_t t) {
+ switch(t) { // expected-warning{{enumeration value 'val3' not handled in switch}}
+ case val1:
+ return 1;
+ case val2:
+ return 2;
+ }
+ return -1;
+}
+
+// <rdar://problem/7658121>
+enum {
+ EC0 = 0xFFFF0000,
+ EC1 = 0xFFFF0001,
+};
+
+int test14(int a) {
+ switch(a) {
+ case EC0: return 0;
+ case EC1: return 1;
+ }
+ return 0;
+}
+
+void f1(unsigned x) {
+ switch (x) {
+ case -1: break;
+ default: break;
+ }
+}
+
+void test15() {
+ int i = 0;
+ switch (1) { // expected-warning {{no case matching constant switch condition '1'}}
+ case 0: i = 0; break;
+ case 2: i++; break;
+ }
+}
+
+void test16() {
+ const char c = '5';
+ switch (c) { // expected-warning {{no case matching constant switch condition '53'}}
+ case '6': return;
+ }
+}
+
+// PR7359
+void test17(int x) {
+ switch (x >= 17) { // expected-warning {{switch condition has boolean value}}
+ case 0: return;
+ }
+
+ switch ((int) (x <= 17)) {
+ case 0: return;
+ }
+}
+
+int test18() {
+ enum { A, B } a;
+ switch (a) {
+ case A: return 0;
+ case B: return 1;
+ case 7: return 1; // expected-warning {{case value not in enumerated type}}
+ default: return 2; // expected-warning {{default label in switch which covers all enumeration values}}
+ }
+}
+
+// rdar://110822110
+typedef enum {
+ kOne = 1,
+} Ints;
+
+void rdar110822110(Ints i)
+{
+ switch (i) {
+ case kOne:
+ break;
+ case 2: // expected-warning {{case value not in enumerated type 'Ints'}}
+ break;
+ default: // expected-warning {{default label in switch which covers all enumeration values}}
+ break;
+ }
+}
diff --git a/clang/test/Sema/tentative-decls.c b/clang/test/Sema/tentative-decls.c
new file mode 100644
index 0000000..b15537b
--- /dev/null
+++ b/clang/test/Sema/tentative-decls.c
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+// PR3310
+struct a x1; // expected-note 2{{forward declaration of 'struct a'}}
+static struct a x2; // expected-warning{{tentative definition of variable with internal linkage has incomplete non-array type 'struct a'}}
+struct a x3[10]; // expected-error{{array has incomplete element type 'struct a'}}
+struct a {int x;};
+static struct a x2_okay;
+struct a x3_okay[10];
+struct b x4; // expected-error{{tentative definition has type 'struct b' that is never completed}} \
+ // expected-note{{forward declaration of 'struct b'}}
+
+const int a [1] = {1};
+extern const int a[];
+
+extern const int b[];
+const int b [1] = {1};
+
+extern const int c[] = {1}; // expected-warning{{'extern' variable has an initializer}}
+const int c[];
+
+int i1 = 1; // expected-note {{previous definition is here}}
+int i1 = 2; // expected-error {{redefinition of 'i1'}}
+int i1;
+int i1;
+extern int i5; // expected-note {{previous definition is here}}
+static int i5; // expected-error{{static declaration of 'i5' follows non-static declaration}}
+
+static int i2 = 5; // expected-note 1 {{previous definition is here}}
+int i2 = 3; // expected-error{{non-static declaration of 'i2' follows static declaration}}
+
+static int i3 = 5;
+extern int i3;
+
+__private_extern__ int pExtern;
+int pExtern = 0;
+
+int i4;
+int i4;
+extern int i4;
+
+int (*pToArray)[];
+int (*pToArray)[8];
+
+int redef[10];
+int redef[]; // expected-note {{previous definition is here}}
+int redef[11]; // expected-error{{redefinition of 'redef'}}
+
+void func() {
+ extern int i6; // expected-note {{previous definition is here}}
+ static int i6; // expected-error{{static declaration of 'i6' follows non-static declaration}}
+}
+
+void func2(void)
+{
+ extern double *p;
+ extern double *p;
+}
+
+// <rdar://problem/6808352>
+static int a0[];
+static int b0;
+
+static int a0[] = { 4 };
+static int b0 = 5;
diff --git a/clang/test/Sema/text-diag.c b/clang/test/Sema/text-diag.c
new file mode 100644
index 0000000..6dcaaa8
--- /dev/null
+++ b/clang/test/Sema/text-diag.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+unsigned char *foo = "texto\
+que continua\
+e continua";
diff --git a/clang/test/Sema/thread-specifier.c b/clang/test/Sema/thread-specifier.c
new file mode 100644
index 0000000..9ec88c5
--- /dev/null
+++ b/clang/test/Sema/thread-specifier.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s
+
+__thread int t1;
+__thread extern int t2;
+__thread static int t3;
+__thread __private_extern__ int t4;
+struct t5 { __thread int x; }; // expected-error {{type name does not allow storage class to be specified}}
+__thread int t6(); // expected-error {{'__thread' is only allowed on variable declarations}}
+int f(__thread int t7) { // expected-error {{'__thread' is only allowed on variable declarations}}
+ __thread int t8; // expected-error {{'__thread' variables must have global storage}}
+ __thread extern int t9;
+ __thread static int t10;
+ __thread __private_extern__ int t11;
+ __thread auto int t12; // expected-error {{'__thread' variables must have global storage}}
+ __thread register int t13; // expected-error {{'__thread' variables must have global storage}}
+}
+__thread typedef int t14; // expected-error {{'__thread' is only allowed on variable declarations}}
+__thread int t15; // expected-note {{previous definition is here}}
+int t15; // expected-error {{non-thread-local declaration of 't15' follows thread-local declaration}}
+int t16; // expected-note {{previous definition is here}}
+__thread int t16; // expected-error {{thread-local declaration of 't16' follows non-thread-local declaration}}
diff --git a/clang/test/Sema/transparent-union-pointer.c b/clang/test/Sema/transparent-union-pointer.c
new file mode 100644
index 0000000..31c9391
--- /dev/null
+++ b/clang/test/Sema/transparent-union-pointer.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+typedef union {
+ union wait *__uptr;
+ int *__iptr;
+} __WAIT_STATUS __attribute__ ((__transparent_union__));
+
+extern int wait (__WAIT_STATUS __stat_loc);
+
+void fastcgi_cleanup() {
+ int status = 0;
+ wait(&status);
+}
+
diff --git a/clang/test/Sema/transparent-union.c b/clang/test/Sema/transparent-union.c
new file mode 100644
index 0000000..ab1ba18
--- /dev/null
+++ b/clang/test/Sema/transparent-union.c
@@ -0,0 +1,73 @@
+// RUN: %clang -fsyntax-only -Xclang -verify %s
+typedef union {
+ int *ip;
+ float *fp;
+ long *__restrict rlp;
+ void *vpa[1];
+} TU __attribute__((transparent_union));
+
+void f(TU); // expected-note{{passing argument to parameter here}}
+
+void g(int *ip, float *fp, char *cp) {
+ f(ip);
+ f(fp);
+ f(cp); // expected-error{{incompatible type}}
+ f(0);
+
+ TU tu_ip = ip; // expected-error{{incompatible type}}
+ TU tu;
+ tu.ip = ip;
+}
+
+/* Test ability to redeclare a function taking a transparent_union arg
+ with various compatible and incompatible argument types. */
+
+void fip(TU);
+void fip(int *i) {}
+
+void ffp(TU);
+void ffp(float *f) {}
+
+void flp(TU);
+void flp(long *l) {}
+
+void fvp(TU); // expected-note{{previous declaration is here}}
+void fvp(void *p) {} // expected-error{{conflicting types}}
+
+void fsp(TU); // expected-note{{previous declaration is here}}
+void fsp(short *s) {} // expected-error{{conflicting types}}
+
+void fi(TU); // expected-note{{previous declaration is here}}
+void fi(int i) {} // expected-error{{conflicting types}}
+
+void fvpp(TU); // expected-note{{previous declaration is here}}
+void fvpp(void **v) {} // expected-error{{conflicting types}}
+
+/* FIXME: we'd like to just use an "int" here and align it differently
+ from the normal "int", but if we do so we lose the alignment
+ information from the typedef within the compiler. */
+typedef struct { int x, y; } __attribute__((aligned(8))) aligned_struct8;
+
+typedef struct { int x, y; } __attribute__((aligned(4))) aligned_struct4;
+typedef union {
+ aligned_struct4 s4; // expected-note{{alignment of first field}}
+ aligned_struct8 s8; // expected-warning{{alignment of field}}
+} TU1 __attribute__((transparent_union));
+
+typedef union {
+ char c; // expected-note{{size of first field is 8 bits}}
+ int i; // expected-warning{{size of field}}
+} TU2 __attribute__((transparent_union));
+
+typedef union {
+ float f; // expected-warning{{floating}}
+} TU3 __attribute__((transparent_union));
+
+typedef union { } TU4 __attribute__((transparent_union)); // expected-warning{{field}}
+
+typedef int int4 __attribute__((ext_vector_type(4)));
+typedef union {
+ int4 vec; // expected-warning{{first field of a transparent union cannot have vector type 'int4'; transparent_union attribute ignored}}
+} TU5 __attribute__((transparent_union));
+
+
diff --git a/clang/test/Sema/type-spec-struct-union.c b/clang/test/Sema/type-spec-struct-union.c
new file mode 100644
index 0000000..ce65095
--- /dev/null
+++ b/clang/test/Sema/type-spec-struct-union.c
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+
+/* This test checks the introduction of struct and union types based
+ on a type specifier of the form "struct-or-union identifier" when they
+ type has not yet been declared. See C99 6.7.2.3p8. */
+
+typedef struct S1 {
+ union {
+ struct S2 *x;
+ struct S3 *y;
+ } u1;
+} S1;
+
+int test_struct_scope(S1 *s1, struct S2 *s2, struct S3 *s3) {
+ if (s1->u1.x == s2) return 1;
+ if (s1->u1.y == s3) return 1;
+ return 0;
+}
+
+int test_struct_scope_2(S1 *s1) {
+ struct S2 { int x; } *s2 = 0;
+ if (s1->u1.x == s2) return 1; /* expected-warning {{comparison of distinct pointer types ('struct S2 *' and 'struct S2 *')}} */
+ return 0;
+}
+
+// FIXME: We do not properly implement C99 6.2.1p4, which says that
+// the type "struct S4" declared in the function parameter list has
+// block scope within the function definition. The problem, in this
+// case, is that the code is ill-formed but we warn about the two S4's
+// being incompatible (we think they are two different types).
+int test_struct_scope_3(struct S4 * s4) { // expected-warning{{declaration of 'struct S4' will not be visible outside of this function}}
+ struct S4 { int y; } *s4_2 = 0;
+ /* if (s4 == s4_2) return 1; */
+ return 0;
+}
+
+void f(struct S5 { int y; } s5); // expected-warning{{declaration of 'struct S5' will not be visible outside of this function}}
+
+// PR clang/3312
+struct S6 {
+ enum { BAR } e;
+};
+
+void test_S6() {
+ struct S6 a;
+ a.e = BAR;
+}
+
+// <rdar://problem/6487669>
+typedef struct z_foo_s {
+ struct bar_baz *baz;
+} z_foo;
+typedef z_foo *z_foop;
+struct bar_baz {
+ enum {
+ SQUAT, FLAG, DICT4, DICT3, DICT2, DICT1, DICT0, HOP, CHECK4, CHECK3, CHECK2, CHECK1, DONE, BAD
+ } mode;
+ int nowrap;
+};
+void
+wizbiz_quxPoof(z)
+ z_foop z;
+{
+ z->baz->mode = z->baz->nowrap ? HOP : SQUAT;
+}
diff --git a/clang/test/Sema/typecheck-binop.c b/clang/test/Sema/typecheck-binop.c
new file mode 100644
index 0000000..be52d0b
--- /dev/null
+++ b/clang/test/Sema/typecheck-binop.c
@@ -0,0 +1,27 @@
+/* RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify
+ */
+struct incomplete; // expected-note{{forward declaration of 'struct incomplete'}}
+
+int sub1(int *a, double *b) {
+ return a - b; /* expected-error{{not pointers to compatible types}} */
+}
+
+void *sub2(struct incomplete *P) {
+ return P-4; /* expected-error{{arithmetic on a pointer to an incomplete type 'struct incomplete'}} */
+}
+
+void *sub3(void *P) {
+ return P-4; /* expected-warning{{arithmetic on a pointer to void is a GNU extension}} */
+}
+
+int sub4(void *P, void *Q) {
+ return P-Q; /* expected-warning{{arithmetic on pointers to void is a GNU extension}} */
+}
+
+int sub5(void *P, int *Q) {
+ return P-Q; /* expected-error{{not pointers to compatible types}} */
+}
+
+int logicaland1(int a) {
+ return a && (void)a; /* expected-error{{invalid operands}} */
+}
diff --git a/clang/test/Sema/typedef-prototype.c b/clang/test/Sema/typedef-prototype.c
new file mode 100644
index 0000000..8372154
--- /dev/null
+++ b/clang/test/Sema/typedef-prototype.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int unary_int_func(int arg);
+unary_int_func add_one;
+
+int add_one(int arg) {
+ return arg + 1;
+}
diff --git a/clang/test/Sema/typedef-redef.c b/clang/test/Sema/typedef-redef.c
new file mode 100644
index 0000000..025f65c
--- /dev/null
+++ b/clang/test/Sema/typedef-redef.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef const int x; // expected-note {{previous definition is here}}
+extern x a;
+typedef int x; // expected-error {{typedef redefinition with different types}}
+extern x a;
+
+// <rdar://problem/6097585>
+int y; // expected-note 2 {{previous definition is here}}
+float y; // expected-error{{redefinition of 'y' with a different type}}
+double y; // expected-error{{redefinition of 'y' with a different type}}
diff --git a/clang/test/Sema/typedef-retain.c b/clang/test/Sema/typedef-retain.c
new file mode 100644
index 0000000..a7173b7
--- /dev/null
+++ b/clang/test/Sema/typedef-retain.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -fno-lax-vector-conversions
+
+typedef float float4 __attribute__((vector_size(16)));
+typedef int int4 __attribute__((vector_size(16)));
+typedef int4* int4p;
+
+void test1(float4 a, int4 *result, int i) {
+ result[i] = a; // expected-error {{assigning to 'int4' from incompatible type 'float4'}}
+}
+
+void test2(float4 a, int4p result, int i) {
+ result[i] = a; // expected-error {{assigning to 'int4' from incompatible type 'float4'}}
+}
+
+// PR2039
+typedef int a[5];
+void test3() {
+ typedef const a b;
+ b r;
+ r[0]=10; // expected-error {{read-only variable is not assignable}}
+}
+
+int test4(const a y) {
+ y[0] = 10; // expected-error {{read-only variable is not assignable}}
+}
+
diff --git a/clang/test/Sema/typedef-variable-type.c b/clang/test/Sema/typedef-variable-type.c
new file mode 100644
index 0000000..8a7ee8b
--- /dev/null
+++ b/clang/test/Sema/typedef-variable-type.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic -Wno-typedef-redefinition -std=c99
+
+// Make sure we accept a single typedef
+typedef int (*a)[!.0]; // expected-warning{{size of static array must be an integer constant expression}}
+
+// And make sure we accept identical redefinitions in system headers
+// (The test uses -Wno-typedef-redefinition to simulate this.)
+typedef int (*a)[!.0]; // expected-warning{{size of static array must be an integer constant expression}}
diff --git a/clang/test/Sema/typeof-use-deprecated.c b/clang/test/Sema/typeof-use-deprecated.c
new file mode 100644
index 0000000..238e501
--- /dev/null
+++ b/clang/test/Sema/typeof-use-deprecated.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+struct s { int a; } __attribute__((deprecated)) x; // expected-warning {{'s' is deprecated}}
+
+typeof(x) y; // expected-warning {{'s' is deprecated}}
+
+union un{ int a; } __attribute__((deprecated)) u; // expected-warning {{'un' is deprecated}}
+
+typeof( u) z; // expected-warning {{'un' is deprecated}}
+
+enum E{ one} __attribute__((deprecated)) e; // expected-warning {{'E' is deprecated}}
+
+typeof( e) w; // expected-warning {{'E' is deprecated}}
+
+struct foo { int x; } __attribute__((deprecated));
+typedef struct foo bar __attribute__((deprecated));
+bar x1; // expected-warning {{'bar' is deprecated}}
+
+int main() { typeof(x1) y; } // expected-warning {{'foo' is deprecated}}
+
+struct gorf { int x; };
+typedef struct gorf T __attribute__((deprecated));
+T t; // expected-warning {{'T' is deprecated}}
+void wee() { typeof(t) y; }
+
+
diff --git a/clang/test/Sema/types.c b/clang/test/Sema/types.c
new file mode 100644
index 0000000..3bec83e
--- /dev/null
+++ b/clang/test/Sema/types.c
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 %s -pedantic -verify -triple=x86_64-apple-darwin9
+
+// rdar://6097662
+typedef int (*T)[2];
+restrict T x;
+
+typedef int *S[2];
+restrict S y; // expected-error {{restrict requires a pointer or reference ('S' (aka 'int *[2]') is invalid)}}
+
+
+
+// int128_t is available.
+int a() {
+ __int128_t s;
+ __uint128_t t;
+}
+// but not a keyword
+int b() {
+ int __int128_t;
+ int __uint128_t;
+}
+// __int128 is a keyword
+int c() {
+ __int128 i;
+ unsigned __int128 j;
+ long unsigned __int128 k; // expected-error {{'long __int128' is invalid}}
+ int __int128; // expected-error {{cannot combine with previous}} expected-warning {{does not declare anything}}
+}
+// __int128_t is __int128; __uint128_t is unsigned __int128.
+typedef __int128 check_int_128; // expected-note {{here}}
+typedef __int128_t check_int_128; // expected-note {{here}} expected-warning {{redefinition}}
+typedef int check_int_128; // expected-error {{different types ('int' vs '__int128_t' (aka '__int128'))}}
+
+typedef unsigned __int128 check_uint_128; // expected-note {{here}}
+typedef __uint128_t check_uint_128; // expected-note {{here}} expected-warning {{redefinition}}
+typedef int check_uint_128; // expected-error {{different types ('int' vs '__uint128_t' (aka 'unsigned __int128'))}}
+
+// Array type merging should convert array size to whatever matches the target
+// pointer size.
+// rdar://6880874
+extern int i[1LL];
+int i[(short)1];
+
+enum e { e_1 };
+extern int j[sizeof(enum e)]; // expected-note {{previous definition}}
+int j[42]; // expected-error {{redefinition of 'j' with a different type}}
+
+// rdar://6880104
+_Decimal32 x; // expected-error {{GNU decimal type extension not supported}}
+
+
+// rdar://6880951
+int __attribute__ ((vector_size (8), vector_size (8))) v; // expected-error {{invalid vector element type}}
+
+void test(int i) {
+ char c = (char __attribute__((align(8)))) i; // expected-error {{'align' attribute ignored when parsing type}}
+}
+
+// http://llvm.org/PR11082
+//
+// FIXME: This may or may not be the correct approach (no warning or error),
+// but large amounts of Linux and FreeBSD code need this attribute to not be
+// a hard error in order to work correctly.
+void test2(int i) {
+ char c = (char __attribute__((may_alias))) i;
+}
diff --git a/clang/test/Sema/ucn-cstring.c b/clang/test/Sema/ucn-cstring.c
new file mode 100644
index 0000000..5d3e85d
--- /dev/null
+++ b/clang/test/Sema/ucn-cstring.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
+
+int printf(const char *, ...);
+
+int main(void) {
+ int a[sizeof("hello \u2192 \u2603 \u2190 world") == 24 ? 1 : -1];
+
+ printf("%s (%zd)\n", "hello \u2192 \u2603 \u2190 world", sizeof("hello \u2192 \u2603 \u2190 world"));
+ printf("%s (%zd)\n", "\U00010400\U0001D12B", sizeof("\U00010400\U0001D12B"));
+ // Some error conditions...
+ printf("%s\n", "\U"); // expected-error{{\u used with no following hex digits}}
+ printf("%s\n", "\U00"); // expected-error{{incomplete universal character name}}
+ printf("%s\n", "\U0001"); // expected-error{{incomplete universal character name}}
+ printf("%s\n", "\u0001"); // expected-error{{universal character name refers to a control character}}
+ return 0;
+}
diff --git a/clang/test/Sema/uninit-variables-vectors.c b/clang/test/Sema/uninit-variables-vectors.c
new file mode 100644
index 0000000..10a8ecc
--- /dev/null
+++ b/clang/test/Sema/uninit-variables-vectors.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -Wuninitialized -fsyntax-only %s -verify
+
+typedef int __v4si __attribute__((__vector_size__(16)));
+typedef float __m128 __attribute__((__vector_size__(16)));
+__m128 _mm_xor_ps(__m128 a, __m128 b);
+__m128 _mm_loadu_ps(const float *p);
+
+void test1(float *input) {
+ __m128 x, y, z, w, X; // expected-note {{variable 'x' is declared here}} expected-note {{variable 'y' is declared here}} expected-note {{variable 'w' is declared here}} expected-note {{variable 'z' is declared here}}
+ x = _mm_xor_ps(x,x); // expected-warning {{variable 'x' is uninitialized when used here}}
+ y = _mm_xor_ps(y,y); // expected-warning {{variable 'y' is uninitialized when used here}}
+ z = _mm_xor_ps(z,z); // expected-warning {{variable 'z' is uninitialized when used here}}
+ w = _mm_xor_ps(w,w); // expected-warning {{variable 'w' is uninitialized when used here}}
+ X = _mm_loadu_ps(&input[0]);
+ X = _mm_xor_ps(X,X); // no-warning
+}
+
diff --git a/clang/test/Sema/uninit-variables.c b/clang/test/Sema/uninit-variables.c
new file mode 100644
index 0000000..d62186d
--- /dev/null
+++ b/clang/test/Sema/uninit-variables.c
@@ -0,0 +1,426 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -Wconditional-uninitialized -fsyntax-only -fblocks %s -verify
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+
+int test1() {
+ int x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ return x; // expected-warning{{variable 'x' is uninitialized when used here}}
+}
+
+int test2() {
+ int x = 0;
+ return x; // no-warning
+}
+
+int test3() {
+ int x;
+ x = 0;
+ return x; // no-warning
+}
+
+int test4() {
+ int x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ ++x; // expected-warning{{variable 'x' is uninitialized when used here}}
+ return x;
+}
+
+int test5() {
+ int x, y; // expected-note{{initialize the variable 'y' to silence this warning}}
+ x = y; // expected-warning{{variable 'y' is uninitialized when used here}}
+ return x;
+}
+
+int test6() {
+ int x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ x += 2; // expected-warning{{variable 'x' is uninitialized when used here}}
+ return x;
+}
+
+int test7(int y) {
+ int x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ if (y)
+ x = 1;
+ return x; // expected-warning{{variable 'x' may be uninitialized when used here}}
+}
+
+int test7b(int y) {
+ int x = x; // expected-note{{variable 'x' is declared here}}
+ if (y)
+ x = 1;
+ // Warn with "may be uninitialized" here (not "is uninitialized"), since the
+ // self-initialization is intended to suppress a -Wuninitialized warning.
+ return x; // expected-warning{{variable 'x' may be uninitialized when used here}}
+}
+
+int test8(int y) {
+ int x;
+ if (y)
+ x = 1;
+ else
+ x = 0;
+ return x;
+}
+
+int test9(int n) {
+ int x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ for (unsigned i = 0 ; i < n; ++i) {
+ if (i == n - 1)
+ break;
+ x = 1;
+ }
+ return x; // expected-warning{{variable 'x' may be uninitialized when used here}}
+}
+
+int test10(unsigned n) {
+ int x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ for (unsigned i = 0 ; i < n; ++i) {
+ x = 1;
+ }
+ return x; // expected-warning{{variable 'x' may be uninitialized when used here}}
+}
+
+int test11(unsigned n) {
+ int x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ for (unsigned i = 0 ; i <= n; ++i) {
+ x = 1;
+ }
+ return x; // expected-warning{{variable 'x' may be uninitialized when used here}}
+}
+
+void test12(unsigned n) {
+ for (unsigned i ; n ; ++i) ; // expected-warning{{variable 'i' is uninitialized when used here}} expected-note{{initialize the variable 'i' to silence this warning}}
+}
+
+int test13() {
+ static int i;
+ return i; // no-warning
+}
+
+// Simply don't crash on this test case.
+void test14() {
+ const char *p = 0;
+ for (;;) {}
+}
+
+void test15() {
+ int x = x; // no-warning: signals intended lack of initialization.
+}
+
+int test15b() {
+ // Warn here with the self-init, since it does result in a use of
+ // an unintialized variable and this is the root cause.
+ int x = x; // expected-warning {{variable 'x' is uninitialized when used within its own initialization}}
+ return x;
+}
+
+// Don't warn in the following example; shows dataflow confluence.
+char *test16_aux();
+void test16() {
+ char *p = test16_aux();
+ for (unsigned i = 0 ; i < 100 ; i++)
+ p[i] = 'a'; // no-warning
+}
+
+void test17() {
+ // Don't warn multiple times about the same uninitialized variable
+ // along the same path.
+ int *x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ *x = 1; // expected-warning{{variable 'x' is uninitialized when used here}}
+ *x = 1; // no-warning
+}
+
+int test18(int x, int y) {
+ int z;
+ if (x && y && (z = 1)) {
+ return z; // no-warning
+ }
+ return 0;
+}
+
+int test19_aux1();
+int test19_aux2();
+int test19_aux3(int *x);
+int test19() {
+ int z;
+ if (test19_aux1() + test19_aux2() && test19_aux1() && test19_aux3(&z))
+ return z; // no-warning
+ return 0;
+}
+
+int test20() {
+ int z; // expected-note{{initialize the variable 'z' to silence this warning}}
+ if ((test19_aux1() + test19_aux2() && test19_aux1()) || test19_aux3(&z))
+ return z; // expected-warning{{variable 'z' may be uninitialized when used here}}
+ return 0;
+}
+
+int test21(int x, int y) {
+ int z; // expected-note{{initialize the variable 'z' to silence this warning}}
+ if ((x && y) || test19_aux3(&z) || test19_aux2())
+ return z; // expected-warning{{variable 'z' may be uninitialized when used here}}
+ return 0;
+}
+
+int test22() {
+ int z;
+ while (test19_aux1() + test19_aux2() && test19_aux1() && test19_aux3(&z))
+ return z; // no-warning
+ return 0;
+}
+
+int test23() {
+ int z;
+ for ( ; test19_aux1() + test19_aux2() && test19_aux1() && test19_aux3(&z) ; )
+ return z; // no-warning
+ return 0;
+}
+
+// The basic uninitialized value analysis doesn't have enough path-sensitivity
+// to catch initializations relying on control-dependencies spanning multiple
+// conditionals. This possibly can be handled by making the CFG itself
+// represent such control-dependencies, but it is a niche case.
+int test24(int flag) {
+ unsigned val; // expected-note{{initialize the variable 'val' to silence this warning}}
+ if (flag)
+ val = 1;
+ if (!flag)
+ val = 1;
+ return val; // expected-warning{{variable 'val' may be uninitialized when used here}}
+}
+
+float test25() {
+ float x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ return x; // expected-warning{{variable 'x' is uninitialized when used here}}
+}
+
+typedef int MyInt;
+MyInt test26() {
+ MyInt x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ return x; // expected-warning{{variable 'x' is uninitialized when used here}}
+}
+
+// Test handling of sizeof().
+int test27() {
+ struct test_27 { int x; } *y;
+ return sizeof(y->x); // no-warning
+}
+
+int test28() {
+ int len; // expected-note{{initialize the variable 'len' to silence this warning}}
+ return sizeof(int[len]); // expected-warning{{variable 'len' is uninitialized when used here}}
+}
+
+void test29() {
+ int x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ (void) ^{ (void) x; }; // expected-warning{{variable 'x' is uninitialized when captured by block}}
+}
+
+void test30() {
+ static int x; // no-warning
+ (void) ^{ (void) x; };
+}
+
+void test31() {
+ __block int x; // no-warning
+ (void) ^{ (void) x; };
+}
+
+int test32_x;
+void test32() {
+ (void) ^{ (void) test32_x; }; // no-warning
+}
+
+void test_33() {
+ int x; // no-warning
+ (void) x;
+}
+
+int test_34() {
+ int x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ (void) x;
+ return x; // expected-warning{{variable 'x' is uninitialized when used here}}
+}
+
+// Test that this case doesn't crash.
+void test35(int x) {
+ __block int y = 0;
+ ^{ y = (x == 0); }();
+}
+
+// Test handling of indirect goto.
+void test36()
+{
+ void **pc; // expected-note{{initialize the variable 'pc' to silence this warning}}
+ void *dummy[] = { &&L1, &&L2 };
+ L1:
+ goto *pc; // expected-warning{{variable 'pc' is uninitialized when used here}}
+ L2:
+ goto *pc;
+}
+
+// Test && nested in ||.
+int test37_a();
+int test37_b();
+int test37()
+{
+ int identifier;
+ if ((test37_a() && (identifier = 1)) ||
+ (test37_b() && (identifier = 2))) {
+ return identifier; // no-warning
+ }
+ return 0;
+}
+
+// Test merging of path-specific dataflow values (without asserting).
+int test38(int r, int x, int y)
+{
+ int z;
+ return ((r < 0) || ((r == 0) && (x < y)));
+}
+
+int test39(int x) {
+ int y; // expected-note{{initialize the variable 'y' to silence this warning}}
+ int z = x + y; // expected-warning {{variable 'y' is uninitialized when used here}}
+ return z;
+}
+
+
+int test40(int x) {
+ int y; // expected-note{{initialize the variable 'y' to silence this warning}}
+ return x ? 1 : y; // expected-warning {{variable 'y' is uninitialized when used here}}
+}
+
+int test41(int x) {
+ int y; // expected-note{{initialize the variable 'y' to silence this warning}}
+ if (x) y = 1; // no-warning
+ return y; // expected-warning {{variable 'y' may be uninitialized when used here}}
+}
+
+void test42() {
+ int a;
+ a = 30; // no-warning
+}
+
+void test43_aux(int x);
+void test43(int i) {
+ int x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ for (i = 0 ; i < 10; i++)
+ test43_aux(x++); // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
+void test44(int i) {
+ int x = i;
+ int y; // expected-note{{initialize the variable 'y' to silence this warning}}
+ for (i = 0; i < 10; i++ ) {
+ test43_aux(x++); // no-warning
+ x += y; // expected-warning {{variable 'y' is uninitialized when used here}}
+ }
+}
+
+int test45(int j) {
+ int x = 1, y = x + 1;
+ if (y) // no-warning
+ return x;
+ return y;
+}
+
+void test46()
+{
+ int i; // expected-note{{initialize the variable 'i' to silence this warning}}
+ int j = i ? : 1; // expected-warning {{variable 'i' is uninitialized when used here}}
+}
+
+void *test47(int *i)
+{
+ return i ? : 0; // no-warning
+}
+
+void *test49(int *i)
+{
+ int a;
+ return &a ? : i; // no-warning
+}
+
+void test50()
+{
+ char c[1 ? : 2]; // no-warning
+}
+
+int test51(void)
+{
+ __block int a;
+ ^(void) {
+ a = 42;
+ }();
+ return a; // no-warning
+}
+
+// FIXME: This is a false positive, but it tests logical operations in switch statements.
+int test52(int a, int b) {
+ int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+ switch (a || b) { // expected-warning {{switch condition has boolean value}}
+ case 0:
+ x = 1;
+ break;
+ case 1:
+ x = 2;
+ break;
+ }
+ return x; // expected-warning {{variable 'x' may be uninitialized when used here}}
+}
+
+void test53() {
+ int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+ int y = (x); // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
+// This CFG caused the uninitialized values warning to inf-loop.
+extern int PR10379_g();
+void PR10379_f(int *len) {
+ int new_len; // expected-note{{initialize the variable 'new_len' to silence this warning}}
+ for (int i = 0; i < 42 && PR10379_g() == 0; i++) {
+ if (PR10379_g() == 1)
+ continue;
+ if (PR10379_g() == 2)
+ PR10379_f(&new_len);
+ else if (PR10379_g() == 3)
+ PR10379_f(&new_len);
+ *len += new_len; // expected-warning {{variable 'new_len' may be uninitialized when used here}}
+ }
+}
+
+// Test that sizeof(VLA) doesn't trigger a warning.
+void test_vla_sizeof(int x) {
+ double (*memory)[2][x] = malloc(sizeof(*memory)); // no-warning
+}
+
+// Test absurd case of deadcode + use of blocks. This previously was a false positive
+// due to an analysis bug.
+int test_block_and_dead_code() {
+ __block int x;
+ ^{ x = 1; }();
+ if (0)
+ return x;
+ return x; // no-warning
+}
+
+// This previously triggered an infinite loop in the analysis.
+void PR11069(int a, int b) {
+ unsigned long flags;
+ for (;;) {
+ if (a && !b)
+ break;
+ }
+ for (;;) {
+ // This does not trigger a warning because it isn't a real use.
+ (void)(flags); // no-warning
+ }
+}
+
+// Test uninitialized value used in loop condition.
+void rdar9432305(float *P) {
+ int i; // expected-note {{initialize the variable 'i' to silence this warning}}
+ for (; i < 10000; ++i) // expected-warning {{variable 'i' is uninitialized when used here}}
+ P[i] = 0.0f;
+}
diff --git a/clang/test/Sema/unnamed-bitfield-init.c b/clang/test/Sema/unnamed-bitfield-init.c
new file mode 100644
index 0000000..f3cc49c
--- /dev/null
+++ b/clang/test/Sema/unnamed-bitfield-init.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+typedef struct {
+ int a; int : 24; char b;
+} S;
+
+S a = { 1, 2 };
diff --git a/clang/test/Sema/unused-expr-system-header.c b/clang/test/Sema/unused-expr-system-header.c
new file mode 100644
index 0000000..dcc8918
--- /dev/null
+++ b/clang/test/Sema/unused-expr-system-header.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -verify %s
+#include <unused-expr-system-header.h>
+void f(int i1, int i2) {
+ POSSIBLY_BAD_MACRO(5);
+ STATEMENT_EXPR_MACRO(5);
+ COMMA_MACRO_1(i1 == i2, f(i1, i2)); // expected-warning {{expression result unused}}
+ COMMA_MACRO_2(i1 == i2, f(i1, i2));
+ COMMA_MACRO_3(i1 == i2, f(i1, i2)); // expected-warning {{expression result unused}}
+ COMMA_MACRO_4(i1 == i2, f(i1, i2));
+}
diff --git a/clang/test/Sema/unused-expr.c b/clang/test/Sema/unused-expr.c
new file mode 100644
index 0000000..9761116
--- /dev/null
+++ b/clang/test/Sema/unused-expr.c
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unreachable-code
+
+int foo(int X, int Y);
+
+double sqrt(double X); // implicitly const because of no -fmath-errno!
+
+void bar(volatile int *VP, int *P, int A,
+ _Complex double C, volatile _Complex double VC) {
+
+ VP < P; // expected-warning {{expression result unused}}
+ (void)A;
+ (void)foo(1,2); // no warning.
+
+ A < foo(1, 2); // expected-warning {{expression result unused}}
+
+ foo(1,2)+foo(4,3); // expected-warning {{expression result unused}}
+
+
+ *P; // expected-warning {{expression result unused}}
+ *VP; // no warning.
+ P[4]; // expected-warning {{expression result unused}}
+ VP[4]; // no warning.
+
+ __real__ C; // expected-warning {{expression result unused}}
+ __real__ VC;
+
+ // We know this can't change errno because of no -fmath-errno.
+ sqrt(A); // expected-warning {{ignoring return value of function declared with const attribute}}
+}
+
+extern void t1();
+extern void t2();
+void t3(int c) {
+ c ? t1() : t2();
+}
+
+// This shouldn't warn: the expr at the end of the stmtexpr really is used.
+int stmt_expr(int x, int y) {
+ return ({int _a = x, _b = y; _a > _b ? _a : _b; });
+}
+
+void nowarn(unsigned char* a, unsigned char* b)
+{
+ unsigned char c = 1;
+ *a |= c, *b += c;
+
+
+ // PR4633
+ int y, x;
+ ((void)0), y = x;
+}
+
+void t4(int a) {
+ int b = 0;
+
+ if (a)
+ b < 1; // expected-warning{{expression result unused}}
+ else
+ b < 2; // expected-warning{{expression result unused}}
+
+ while (1)
+ b < 3; // expected-warning{{expression result unused}}
+
+ do
+ b < 4; // expected-warning{{expression result unused}}
+ while (1);
+
+ for (;;)
+ b < 5; // expected-warning{{expression result unused}}
+
+ for (b < 1;;) {} // expected-warning{{expression result unused}}
+ for (;b < 1;) {}
+ for (;;b < 1) {} // expected-warning{{expression result unused}}
+}
+
+// rdar://7186119
+int t5f(void) __attribute__((warn_unused_result));
+void t5() {
+ t5f(); // expected-warning {{ignoring return value of function declared with warn_unused_result}}
+}
+
+
+int fn1() __attribute__ ((warn_unused_result));
+int fn2() __attribute__ ((pure));
+int fn3() __attribute__ ((const));
+// rdar://6587766
+int t6() {
+ if (fn1() < 0 || fn2(2,1) < 0 || fn3(2) < 0) // no warnings
+ return -1;
+
+ fn1(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
+ fn2(92, 21); // expected-warning {{ignoring return value of function declared with pure attribute}}
+ fn3(42); // expected-warning {{ignoring return value of function declared with const attribute}}
+ __builtin_fabsf(0); // expected-warning {{ignoring return value of function declared with const attribute}}
+ return 0;
+}
+
+int t7 __attribute__ ((warn_unused_result)); // expected-warning {{'warn_unused_result' attribute only applies to functions}}
+
+// PR4010
+int (*fn4)(void) __attribute__ ((warn_unused_result));
+void t8() {
+ fn4(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
+}
+
+void t9() __attribute__((warn_unused_result)); // expected-warning {{attribute 'warn_unused_result' cannot be applied to functions without return value}}
+
+// rdar://7410924
+void *some_function(void);
+void t10() {
+ (void*) some_function(); //expected-warning {{expression result unused; should this cast be to 'void'?}}
+}
+
+void f(int i, ...) {
+ __builtin_va_list ap;
+
+ __builtin_va_start(ap, i);
+ __builtin_va_arg(ap, int);
+ __builtin_va_end(ap);
+}
+
+// PR8371
+int fn5() __attribute__ ((__const));
diff --git a/clang/test/Sema/usual-float.c b/clang/test/Sema/usual-float.c
new file mode 100644
index 0000000..5a9ab34
--- /dev/null
+++ b/clang/test/Sema/usual-float.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -fsyntax-only
+
+typedef float CGFloat;
+
+extern void func(CGFloat);
+void foo(int dir, int n, int tindex) {
+ const float PI = 3.142;
+ CGFloat cgf = 3.4;
+
+ float ang = (float) tindex * (-dir*2.0f*PI/n);
+ func((CGFloat)cgf/65535.0f);
+}
diff --git a/clang/test/Sema/va_arg_x86_32.c b/clang/test/Sema/va_arg_x86_32.c
new file mode 100644
index 0000000..e49f0a4
--- /dev/null
+++ b/clang/test/Sema/va_arg_x86_32.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple=i686-pc-linux-gnu %s
+
+int a() {
+ __builtin_va_arg((char*)0, int); // expected-error {{expression is not assignable}}
+ __builtin_va_arg((void*){0}, int); // expected-error {{first argument to 'va_arg' is of type 'void *'}}
+}
diff --git a/clang/test/Sema/va_arg_x86_64.c b/clang/test/Sema/va_arg_x86_64.c
new file mode 100644
index 0000000..9f514c1
--- /dev/null
+++ b/clang/test/Sema/va_arg_x86_64.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-unknown-freebsd7.0 %s
+
+// PR2631
+char* foo(char *fmt, __builtin_va_list ap)
+{
+ return __builtin_va_arg((ap), char *);
+}
+
+// PR2692
+typedef __builtin_va_list va_list;
+static void f (char * (*g) (char **, int), char **p, ...) {
+ char *s;
+ va_list v;
+ s = g (p, __builtin_va_arg(v, int));
+}
diff --git a/clang/test/Sema/var-redecl.c b/clang/test/Sema/var-redecl.c
new file mode 100644
index 0000000..f7576b6
--- /dev/null
+++ b/clang/test/Sema/var-redecl.c
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int outer1; // expected-note{{previous definition is here}}
+extern int outer2; // expected-note{{previous definition is here}}
+int outer4;
+int outer4; // expected-note{{previous definition is here}}
+int outer5;
+int outer6(float); // expected-note{{previous definition is here}}
+int outer7(float);
+
+void outer_test() {
+ extern float outer1; // expected-error{{redefinition of 'outer1' with a different type}}
+ extern float outer2; // expected-error{{redefinition of 'outer2' with a different type}}
+ extern float outer3; // expected-note{{previous definition is here}}
+ double outer4;
+ extern int outer5; // expected-note{{previous definition is here}}
+ extern int outer6; // expected-error{{redefinition of 'outer6' as different kind of symbol}}
+ int outer7;
+ extern int outer8; // expected-note{{previous definition is here}}
+ extern int outer9;
+ {
+ extern int outer9; // expected-note{{previous definition is here}}
+ }
+}
+
+int outer3; // expected-error{{redefinition of 'outer3' with a different type}}
+float outer4; // expected-error{{redefinition of 'outer4' with a different type}}
+float outer5; // expected-error{{redefinition of 'outer5' with a different type}}
+int outer8(int); // expected-error{{redefinition of 'outer8' as different kind of symbol}}
+float outer9; // expected-error{{redefinition of 'outer9' with a different type}}
+
+extern int outer13; // expected-note{{previous definition is here}}
+void outer_shadowing_test() {
+ extern int outer10;
+ extern int outer11; // expected-note{{previous definition is here}}
+ extern int outer12; // expected-note{{previous definition is here}}
+ {
+ float outer10;
+ float outer11;
+ float outer12;
+ {
+ extern int outer10; // okay
+ extern float outer11; // expected-error{{redefinition of 'outer11' with a different type}}
+ static double outer12;
+ {
+ extern float outer12; // expected-error{{redefinition of 'outer12' with a different type}}
+ extern float outer13; // expected-error{{redefinition of 'outer13' with a different type}}
+ }
+ }
+ }
+}
+
+void g18(void) { // expected-note{{'g18' declared here}}
+ extern int g19;
+}
+int *p=&g19; // expected-error{{use of undeclared identifier 'g19'}} \
+ // expected-warning{{incompatible pointer types}}
+
+// PR3645
+static int a;
+extern int a; // expected-note {{previous definition is here}}
+int a; // expected-error {{non-static declaration of 'a' follows static declaration}}
diff --git a/clang/test/Sema/varargs-x86-64.c b/clang/test/Sema/varargs-x86-64.c
new file mode 100644
index 0000000..2fe9b10
--- /dev/null
+++ b/clang/test/Sema/varargs-x86-64.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-apple-darwin9
+
+// rdar://6726818
+void f1() {
+ const __builtin_va_list args2;
+ (void)__builtin_va_arg(args2, int); // expected-error {{first argument to 'va_arg' is of type 'const __builtin_va_list' and not 'va_list'}}
+}
+
diff --git a/clang/test/Sema/varargs.c b/clang/test/Sema/varargs.c
new file mode 100644
index 0000000..07081ed
--- /dev/null
+++ b/clang/test/Sema/varargs.c
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-apple-darwin9
+
+void f1(int a)
+{
+ __builtin_va_list ap;
+
+ __builtin_va_start(ap, a, a); // expected-error {{too many arguments to function}}
+ __builtin_va_start(ap, a); // expected-error {{'va_start' used in function with fixed args}}
+}
+
+void f2(int a, int b, ...)
+{
+ __builtin_va_list ap;
+
+ __builtin_va_start(ap, 10); // expected-warning {{second parameter of 'va_start' not last named argument}}
+ __builtin_va_start(ap, a); // expected-warning {{second parameter of 'va_start' not last named argument}}
+ __builtin_va_start(ap, b);
+}
+
+void f3(float a, ...)
+{
+ __builtin_va_list ap;
+
+ __builtin_va_start(ap, a);
+ __builtin_va_start(ap, (a));
+}
+
+
+// stdarg: PR3075
+void f4(const char *msg, ...) {
+ __builtin_va_list ap;
+ __builtin_stdarg_start((ap), (msg));
+ __builtin_va_end (ap);
+}
+
+void f5() {
+ __builtin_va_list ap;
+ __builtin_va_start(ap,ap); // expected-error {{'va_start' used in function with fixed args}}
+}
+
+void f6(int a, ...) {
+ __builtin_va_list ap;
+ __builtin_va_start(ap); // expected-error {{too few arguments to function}}
+}
+
+// PR3350
+void
+foo(__builtin_va_list authors, ...) {
+ __builtin_va_start (authors, authors);
+ (void)__builtin_va_arg(authors, int);
+ __builtin_va_end (authors);
+}
+
+void f7(int a, ...) {
+ __builtin_va_list ap;
+ __builtin_va_start(ap, a);
+ // FIXME: This error message is sub-par.
+ __builtin_va_arg(ap, int) = 1; // expected-error {{expression is not assignable}}
+ int *x = &__builtin_va_arg(ap, int); // expected-error {{address expression must be an lvalue or a function designator}}
+ __builtin_va_end(ap);
+}
+
+void f8(int a, ...) {
+ __builtin_va_list ap;
+ __builtin_va_start(ap, a);
+ (void)__builtin_va_arg(ap, void); // expected-error {{second argument to 'va_arg' is of incomplete type 'void'}}
+ __builtin_va_end(ap);
+}
+
+enum E { x = -1, y = 2, z = 10000 };
+void f9(__builtin_va_list args)
+{
+ (void)__builtin_va_arg(args, float); // expected-warning {{second argument to 'va_arg' is of promotable type 'float'}}
+ (void)__builtin_va_arg(args, enum E); // Don't warn here in C
+ (void)__builtin_va_arg(args, short); // expected-warning {{second argument to 'va_arg' is of promotable type 'short'}}
+ (void)__builtin_va_arg(args, char); // expected-warning {{second argument to 'va_arg' is of promotable type 'char'}}
+}
diff --git a/clang/test/Sema/variadic-block.c b/clang/test/Sema/variadic-block.c
new file mode 100644
index 0000000..ba4bb71
--- /dev/null
+++ b/clang/test/Sema/variadic-block.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks
+
+#include <stdarg.h>
+
+int main(int argc, char *argv[]) {
+
+ long (^addthem)(const char *, ...) = ^long (const char *format, ...){
+ va_list argp;
+ const char *p;
+ int i;
+ char c;
+ double d;
+ long result = 0;
+ va_start(argp, format);
+ for (p = format; *p; p++) switch (*p) {
+ case 'i':
+ i = va_arg(argp, int);
+ result += i;
+ break;
+ case 'd':
+ d = va_arg(argp, double);
+ result += (int)d;
+ break;
+ case 'c':
+ c = va_arg(argp, int);
+ result += c;
+ break;
+ }
+ return result;
+ };
+ long testresult = addthem("ii", 10, 20);
+ if (testresult != 30) {
+ return 1;
+ }
+ testresult = addthem("idc", 30, 40.0, 'a');
+ if (testresult != (70+'a')) {
+ return 1;
+ }
+ return 0;
+}
+
diff --git a/clang/test/Sema/variadic-incomplete-arg-type.c b/clang/test/Sema/variadic-incomplete-arg-type.c
new file mode 100644
index 0000000..2b5dd1a
--- /dev/null
+++ b/clang/test/Sema/variadic-incomplete-arg-type.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// rdar://10961370
+
+typedef struct __CFError * CFErrorRef; // expected-note {{forward declaration of 'struct __CFError'}}
+
+void junk(int, ...);
+
+int main()
+{
+ CFErrorRef error;
+ junk(1, *error, (void)0); // expected-error {{argument type 'struct __CFError' is incomplete}} \
+ // expected-error {{argument type 'void' is incomplete}}
+}
diff --git a/clang/test/Sema/vector-assign.c b/clang/test/Sema/vector-assign.c
new file mode 100644
index 0000000..f01eb45
--- /dev/null
+++ b/clang/test/Sema/vector-assign.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion
+typedef unsigned int v2u __attribute__ ((vector_size (8)));
+typedef signed int v2s __attribute__ ((vector_size (8)));
+typedef signed int v1s __attribute__ ((vector_size (4)));
+typedef float v2f __attribute__ ((vector_size(8)));
+typedef signed short v4ss __attribute__ ((vector_size (8)));
+
+void test1() {
+ v2s v1;
+ v2u v2;
+ v1s v3;
+ v2f v4;
+ v4ss v5;
+
+ v1 = v2; // expected-warning {{incompatible vector types assigning to 'v2s' from 'v2u'}}
+ v1 = v3; // expected-error {{assigning to 'v2s' from incompatible type 'v1s'}}
+ v1 = v4; // expected-warning {{incompatible vector types assigning to 'v2s' from 'v2f'}}
+ v1 = v5; // expected-warning {{incompatible vector types assigning to 'v2s' from 'v4ss'}}
+
+ v2 = v1; // expected-warning {{incompatible vector types assigning to 'v2u' from 'v2s'}}
+ v2 = v3; // expected-error {{assigning to 'v2u' from incompatible type 'v1s'}}
+ v2 = v4; // expected-warning {{incompatible vector types assigning to 'v2u' from 'v2f'}}
+ v2 = v5; // expected-warning {{incompatible vector types assigning to 'v2u' from 'v4ss'}}
+
+ v3 = v1; // expected-error {{assigning to 'v1s' from incompatible type 'v2s'}}
+ v3 = v2; // expected-error {{assigning to 'v1s' from incompatible type 'v2u'}}
+ v3 = v4; // expected-error {{assigning to 'v1s' from incompatible type 'v2f'}}
+ v3 = v5; // expected-error {{assigning to 'v1s' from incompatible type 'v4ss'}}
+
+ v4 = v1; // expected-warning {{incompatible vector types assigning to 'v2f' from 'v2s'}}
+ v4 = v2; // expected-warning {{incompatible vector types assigning to 'v2f' from 'v2u'}}
+ v4 = v3; // expected-error {{assigning to 'v2f' from incompatible type 'v1s'}}
+ v4 = v5; // expected-warning {{incompatible vector types assigning to 'v2f' from 'v4ss'}}
+
+ v5 = v1; // expected-warning {{incompatible vector types assigning to 'v4ss' from 'v2s'}}
+ v5 = v2; // expected-warning {{incompatible vector types assigning to 'v4ss' from 'v2u'}}
+ v5 = v3; // expected-error {{assigning to 'v4ss' from incompatible type 'v1s'}}
+ v5 = v4; // expected-warning {{incompatible vector types assigning to 'v4ss' from 'v2f'}}
+}
+
+// PR2263
+float test2(__attribute__((vector_size(16))) float a, int b) {
+ return a[b];
+}
+
+// PR4838
+typedef long long __attribute__((__vector_size__(2 * sizeof(long long))))
+longlongvec;
+
+void test3a(longlongvec *); // expected-note{{passing argument to parameter here}}
+void test3(const unsigned *src) {
+ test3a(src); // expected-warning {{incompatible pointer types passing 'const unsigned int *' to parameter of type 'longlongvec *'}}
+}
diff --git a/clang/test/Sema/vector-cast.c b/clang/test/Sema/vector-cast.c
new file mode 100644
index 0000000..f1cf013
--- /dev/null
+++ b/clang/test/Sema/vector-cast.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify -Wvector-conversion
+
+typedef long long t1 __attribute__ ((vector_size (8)));
+typedef char t2 __attribute__ ((vector_size (16)));
+typedef float t3 __attribute__ ((vector_size (16)));
+
+void f()
+{
+ t1 v1;
+ t2 v2;
+ t3 v3;
+
+ v2 = (t2)v1; // -expected-error {{invalid conversion between vector type \
+'t2' and 't1' of different size}}
+ v1 = (t1)v2; // -expected-error {{invalid conversion between vector type \
+'t1' and 't2' of different size}}
+ v3 = (t3)v2;
+
+ v1 = (t1)(char *)10; // -expected-error {{invalid conversion between vector \
+type 't1' and scalar type 'char *'}}
+ v1 = (t1)(long long)10;
+ v1 = (t1)(short)10; // -expected-error {{invalid conversion between vector \
+type 't1' and integer type 'short' of different size}}
+
+ long long r1 = (long long)v1;
+ short r2 = (short)v1; // -expected-error {{invalid conversion between vector \
+type 't1' and integer type 'short' of different size}}
+ char *r3 = (char *)v1; // -expected-error {{invalid conversion between vector\
+ type 't1' and scalar type 'char *'}}
+}
+
+
+void f2(t2 X); // expected-note{{passing argument to parameter 'X' here}}
+
+void f3(t3 Y) {
+ f2(Y); // expected-warning {{incompatible vector types passing 't3' to parameter of type 't2'}}
+}
+
diff --git a/clang/test/Sema/vector-init.c b/clang/test/Sema/vector-init.c
new file mode 100644
index 0000000..5be040a
--- /dev/null
+++ b/clang/test/Sema/vector-init.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+//typedef __attribute__(( ext_vector_type(4) )) float float4;
+typedef float float4 __attribute__((vector_size(16)));
+
+float4 foo = (float4){ 1.0, 2.0, 3.0, 4.0 };
+
+float4 foo2 = (float4){ 1.0, 2.0, 3.0, 4.0 , 5.0 }; // expected-warning{{excess elements in vector initializer}}
+
+float4 array[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0};
+int array_sizecheck[(sizeof(array) / sizeof(float4)) == 3 ? 1 : -1];
+
+float4 array2[2] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
+ 9.0 }; // expected-warning {{excess elements in array initializer}}
+
+float4 array3[2] = { {1.0, 2.0, 3.0}, 5.0, 6.0, 7.0, 8.0,
+ 9.0 }; // expected-warning {{excess elements in array initializer}}
+
+// PR5650
+__attribute__((vector_size(16))) float f1(void) {
+ __attribute__((vector_size(16))) float vec = {0.0f, 0.0f, 0.0f};
+ return(vec);
+}
+
+__attribute__((vector_size(16))) float f2(
+ __attribute__((vector_size(16))) float a1) {
+ return(a1);
+}
+
+
+
+// PR5265
+typedef float __attribute__((ext_vector_type (3))) float3;
+int test2[sizeof(float3) == sizeof(float4) ? 1 : -1];
+
+// rdar://problem/8345836
+typedef long long __attribute__((vector_size(16))) longlong2;
+typedef short __attribute__((vector_size(16))) short8;
+typedef short __attribute__((vector_size(8))) short4;
+void test3() {
+ extern short8 test3_helper(void);
+ longlong2 arr1[2] = { test3_helper(), test3_helper() };
+ short4 arr2[2] = { test3_helper(), test3_helper() }; // expected-error 2 {{initializing 'short4' with an expression of incompatible type 'short8'}}
+}
diff --git a/clang/test/Sema/vector-ops.c b/clang/test/Sema/vector-ops.c
new file mode 100644
index 0000000..3ab75d0
--- /dev/null
+++ b/clang/test/Sema/vector-ops.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion
+typedef unsigned int v2u __attribute__ ((vector_size (8)));
+typedef int v2s __attribute__ ((vector_size (8)));
+typedef float v2f __attribute__ ((vector_size(8)));
+
+void test1(v2u v2ua, v2s v2sa, v2f v2fa) {
+ // Bitwise binary operators
+ (void)(v2ua & v2ua);
+ (void)(v2fa & v2fa); // expected-error{{invalid operands to binary expression}}
+
+ // Unary operators
+ (void)(~v2ua);
+ (void)(~v2fa); // expected-error{{invalid argument type 'v2f' to unary}}
+
+ // Comparison operators
+ v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' from 'int __attribute__((ext_vector_type(2)))'}}
+ v2sa = (v2ua==v2sa);
+
+ // Arrays
+ int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u'}}
+ int array2[17];
+ // FIXME: error message below needs type!
+ (void)(array2[v2ua]); // expected-error{{array subscript is not an integer}}
+
+ v2u *v2u_ptr = 0;
+ v2s *v2s_ptr;
+ v2s_ptr = v2u_ptr; // expected-warning{{converts between pointers to integer types with different sign}}
+}
+
diff --git a/clang/test/Sema/vfprintf-invalid-redecl.c b/clang/test/Sema/vfprintf-invalid-redecl.c
new file mode 100644
index 0000000..cbf47a6
--- /dev/null
+++ b/clang/test/Sema/vfprintf-invalid-redecl.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// PR4290
+
+// The following declaration is not compatible with vfprintf(), but make
+// sure this isn't an error: autoconf expects this to build.
+char vfprintf(); // expected-warning {{incompatible redeclaration of library function 'vfprintf'}} expected-note {{'vfprintf' is a builtin}}
diff --git a/clang/test/Sema/vfprintf-valid-redecl.c b/clang/test/Sema/vfprintf-valid-redecl.c
new file mode 100644
index 0000000..14fbbc4
--- /dev/null
+++ b/clang/test/Sema/vfprintf-valid-redecl.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify
+// PR4290
+
+// The following declaration is compatible with vfprintf, so we shouldn't
+// warn.
+int vfprintf();
diff --git a/clang/test/Sema/vla-2.c b/clang/test/Sema/vla-2.c
new file mode 100644
index 0000000..819cab9
--- /dev/null
+++ b/clang/test/Sema/vla-2.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
+// Check that we don't crash trying to emit warnings in a potentially-evaluated
+// sizeof or typeof. (This test needs to be in a separate file because we use
+// a different codepath when we have already emitted an error.)
+
+int PotentiallyEvaluatedSizeofWarn(int n) {
+ return (int)sizeof *(0 << 32,(int(*)[n])0); // expected-warning {{expression result unused}} expected-warning {{shift count >= width of type}}
+}
+
+void PotentiallyEvaluatedTypeofWarn(int n) {
+ __typeof(*(0 << 32,(int(*)[n])0)) x; // expected-warning {{expression result unused}} expected-warning {{shift count >= width of type}}
+ (void)x;
+}
+
+void PotentiallyEvaluatedArrayBoundWarn(int n) {
+ (void)*(int(*)[(0 << 32,n)])0; // FIXME: We should warn here.
+}
diff --git a/clang/test/Sema/vla.c b/clang/test/Sema/vla.c
new file mode 100644
index 0000000..4fd6361
--- /dev/null
+++ b/clang/test/Sema/vla.c
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
+
+int test1() {
+ typedef int x[test1()]; // vla
+ static int y = sizeof(x); // expected-error {{not a compile-time constant}}
+}
+
+// PR2347
+void f (unsigned int m)
+{
+ int e[2][m];
+
+ e[0][0] = 0;
+}
+
+// PR3048
+int x = sizeof(struct{char qq[x];}); // expected-error {{fields must have a constant size}}
+
+// PR2352
+void f2(unsigned int m)
+{
+ extern int e1[2][m]; // expected-error {{variable length array declaration can not have 'extern' linkage}}
+
+ e1[0][0] = 0;
+
+}
+
+// PR2361
+int i;
+int c[][i]; // expected-error {{variably modified type declaration not allowed at file scope}}
+int d[i]; // expected-error {{variable length array declaration not allowed at file scope}}
+
+int (*e)[i]; // expected-error {{variably modified type declaration not allowed at file scope}}
+
+void f3()
+{
+ static int a[i]; // expected-error {{variable length array declaration can not have 'static' storage duration}}
+ extern int b[i]; // expected-error {{variable length array declaration can not have 'extern' linkage}}
+
+ extern int (*c1)[i]; // expected-error {{variably modified type declaration can not have 'extern' linkage}}
+ static int (*d)[i];
+}
+
+// PR3663
+static const unsigned array[((2 * (int)((((4) / 2) + 1.0/3.0) * (4) - 1e-8)) + 1)]; // expected-warning {{variable length array folded to constant array as an extension}}
+
+int a[*]; // expected-error {{star modifier used outside of function prototype}}
+int f4(int a[*][*]);
+
+// PR2044
+int pr2044(int b) {int (*c(void))[b];**c() = 2;} // expected-error {{variably modified type}}
+int pr2044b;
+int (*pr2044c(void))[pr2044b]; // expected-error {{variably modified type}}
+
+const int f5_ci = 1;
+void f5() { char a[][f5_ci] = {""}; } // expected-warning {{variable length array folded to constant array as an extension}}
+
+// PR5185
+void pr5185(int a[*]);
+void pr5185(int a[*]) // expected-error {{variable length array must be bound in function definition}}
+{
+}
+
+// Make sure this isn't treated as an error
+int TransformBug(int a) {
+ return sizeof(*(int(*)[({ goto v; v: a;})]) 0); // expected-warning {{use of GNU statement expression extension}}
+}
diff --git a/clang/test/Sema/void_arg.c b/clang/test/Sema/void_arg.c
new file mode 100644
index 0000000..337972f
--- /dev/null
+++ b/clang/test/Sema/void_arg.c
@@ -0,0 +1,26 @@
+/* RUN: %clang_cc1 -fsyntax-only %s -verify
+ */
+
+typedef void Void;
+
+void foo() {
+ int X;
+
+ X = sizeof(int (void a)); // expected-error {{argument may not have 'void' type}}
+ X = sizeof(int (int, void)); // expected-error {{must be the first and only parameter}}
+ X = sizeof(int (void, ...)); // expected-error {{must be the first and only parameter}}
+
+ X = sizeof(int (Void a)); // expected-error {{argument may not have 'void' type}}
+ X = sizeof(int (int, Void)); // expected-error {{must be the first and only parameter}}
+ X = sizeof(int (Void, ...)); // expected-error {{must be the first and only parameter}}
+
+ // Accept these.
+ X = sizeof(int (void));
+ X = sizeof(int (Void));
+}
+
+// this is ok.
+void bar(Void) {
+}
+
+void f(const void); // expected-error {{parameter must not have type qualifiers}}
diff --git a/clang/test/Sema/warn-cast-align.c b/clang/test/Sema/warn-cast-align.c
new file mode 100644
index 0000000..9d64699
--- /dev/null
+++ b/clang/test/Sema/warn-cast-align.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -Wcast-align -verify %s
+
+// Simple casts.
+void test0(char *P) {
+ char *a = (char*) P;
+ short *b = (short*) P; // expected-warning {{cast from 'char *' to 'short *' increases required alignment from 1 to 2}}
+ int *c = (int*) P; // expected-warning {{cast from 'char *' to 'int *' increases required alignment from 1 to 4}}
+}
+
+// Casts from void* are a special case.
+void test1(void *P) {
+ char *a = (char*) P;
+ short *b = (short*) P;
+ int *c = (int*) P;
+
+ const volatile void *P2 = P;
+ char *d = (char*) P2;
+ short *e = (short*) P2;
+ int *f = (int*) P2;
+
+ const char *g = (const char*) P2;
+ const short *h = (const short*) P2;
+ const int *i = (const int*) P2;
+
+ const volatile char *j = (const volatile char*) P2;
+ const volatile short *k = (const volatile short*) P2;
+ const volatile int *l = (const volatile int*) P2;
+}
+
+// Aligned struct.
+struct __attribute__((aligned(16))) A {
+ char buffer[16];
+};
+void test2(char *P) {
+ struct A *a = (struct A*) P; // expected-warning {{cast from 'char *' to 'struct A *' increases required alignment from 1 to 16}}
+}
+
+// Incomplete type.
+void test3(char *P) {
+ struct B *b = (struct B*) P;
+}
diff --git a/clang/test/Sema/warn-char-subscripts.c b/clang/test/Sema/warn-char-subscripts.c
new file mode 100644
index 0000000..374a609
--- /dev/null
+++ b/clang/test/Sema/warn-char-subscripts.c
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -Wchar-subscripts -fsyntax-only -verify %s
+
+void t1() {
+ int array[1] = { 0 };
+ char subscript = 0;
+ int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}}
+}
+
+void t2() {
+ int array[1] = { 0 };
+ char subscript = 0;
+ int val = subscript[array]; // expected-warning{{array subscript is of type 'char'}}
+}
+
+void t3() {
+ int *array = 0;
+ char subscript = 0;
+ int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}}
+}
+
+void t4() {
+ int *array = 0;
+ char subscript = 0;
+ int val = subscript[array]; // expected-warning{{array subscript is of type 'char'}}
+}
+
+char returnsChar();
+void t5() {
+ int *array = 0;
+ int val = array[returnsChar()]; // expected-warning{{array subscript is of type 'char'}}
+}
+
+void t6() {
+ int array[1] = { 0 };
+ signed char subscript = 0;
+ int val = array[subscript]; // no warning for explicit signed char
+}
+
+void t7() {
+ int array[1] = { 0 };
+ unsigned char subscript = 0;
+ int val = array[subscript]; // no warning for unsigned char
+}
+
+typedef char CharTy;
+void t8() {
+ int array[1] = { 0 };
+ CharTy subscript = 0;
+ int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}}
+}
+
+typedef signed char SignedCharTy;
+void t9() {
+ int array[1] = { 0 };
+ SignedCharTy subscript = 0;
+ int val = array[subscript]; // no warning for explicit signed char
+}
+
+typedef unsigned char UnsignedCharTy;
+void t10() {
+ int array[1] = { 0 };
+ UnsignedCharTy subscript = 0;
+ int val = array[subscript]; // no warning for unsigned char
+}
diff --git a/clang/test/Sema/warn-freestanding-complex.c b/clang/test/Sema/warn-freestanding-complex.c
new file mode 100644
index 0000000..14e063f
--- /dev/null
+++ b/clang/test/Sema/warn-freestanding-complex.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -ffreestanding -pedantic -verify %s
+
+void foo(float _Complex c) { // expected-warning{{complex numbers are an extension in a freestanding C99 implementation}}
+}
diff --git a/clang/test/Sema/warn-gnu-designators.c b/clang/test/Sema/warn-gnu-designators.c
new file mode 100644
index 0000000..bdb3374
--- /dev/null
+++ b/clang/test/Sema/warn-gnu-designators.c
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -Wno-gnu-designator -verify %s
+struct { int x, y, z[12]; } value = { x:17, .z [3 ... 5] = 7 };
diff --git a/clang/test/Sema/warn-missing-braces.c b/clang/test/Sema/warn-missing-braces.c
new file mode 100644
index 0000000..ebfe984
--- /dev/null
+++ b/clang/test/Sema/warn-missing-braces.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -Wmissing-braces -verify %s
+
+int a[2][2] = { 0, 1, 2, 3 }; // expected-warning{{suggest braces}} expected-warning{{suggest braces}}
diff --git a/clang/test/Sema/warn-missing-prototypes.c b/clang/test/Sema/warn-missing-prototypes.c
new file mode 100644
index 0000000..bfd1459
--- /dev/null
+++ b/clang/test/Sema/warn-missing-prototypes.c
@@ -0,0 +1,37 @@
+// RUN: %clang -Wmissing-prototypes -fsyntax-only -Xclang -verify %s
+
+int f();
+
+int f(int x) { return x; } // expected-warning{{no previous prototype for function 'f'}}
+
+static int g(int x) { return x; }
+
+int h(int x) { return x; } // expected-warning{{no previous prototype for function 'h'}}
+
+static int g2();
+
+int g2(int x) { return x; }
+
+void test(void);
+
+int h3();
+int h4(int);
+int h4();
+
+void test(void) {
+ int h2(int x);
+ int h3(int x);
+ int h4();
+}
+
+int h2(int x) { return x; } // expected-warning{{no previous prototype for function 'h2'}}
+int h3(int x) { return x; } // expected-warning{{no previous prototype for function 'h3'}}
+int h4(int x) { return x; }
+
+int f2(int);
+int f2();
+
+int f2(int x) { return x; }
+
+// rdar://6759522
+int main(void) { return 0; }
diff --git a/clang/test/Sema/warn-shadow.c b/clang/test/Sema/warn-shadow.c
new file mode 100644
index 0000000..32aca8d
--- /dev/null
+++ b/clang/test/Sema/warn-shadow.c
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fblocks -Wshadow %s
+
+int i; // expected-note 3 {{previous declaration is here}}
+
+void foo() {
+ int pass1;
+ int i; // expected-warning {{declaration shadows a variable in the global scope}} \
+ // expected-note {{previous declaration is here}}
+ {
+ int pass2;
+ int i; // expected-warning {{declaration shadows a local variable}} \
+ // expected-note {{previous declaration is here}}
+ {
+ int pass3;
+ int i; // expected-warning {{declaration shadows a local variable}}
+ }
+ }
+
+ int sin; // okay; 'sin' has not been declared, even though it's a builtin.
+}
+
+// <rdar://problem/7677531>
+void (^test1)(int) = ^(int i) { // expected-warning {{declaration shadows a variable in the global scope}} \
+ // expected-note{{previous declaration is here}}
+ {
+ int i; // expected-warning {{declaration shadows a local variable}} \
+ // expected-note{{previous declaration is here}}
+
+ (^(int i) { return i; })(i); //expected-warning {{declaration shadows a local variable}}
+ }
+};
+
+
+struct test2 {
+ int i;
+};
+
+void test3(void) {
+ struct test4 {
+ int i;
+ };
+}
+
+void test4(int i) { // expected-warning {{declaration shadows a variable in the global scope}}
+}
+
+// Don't warn about shadowing for function declarations.
+void test5(int i);
+void test6(void (*f)(int i)) {}
+void test7(void *context, void (*callback)(void *context)) {}
+
+extern int bob; // expected-note {{previous declaration is here}}
+
+// rdar://8883302
+void rdar8883302() {
+ extern int bob; // don't warn for shadowing.
+}
+
+void test8() {
+ int bob; // expected-warning {{declaration shadows a variable in the global scope}}
+}
diff --git a/clang/test/Sema/warn-sizeof-arrayarg.c b/clang/test/Sema/warn-sizeof-arrayarg.c
new file mode 100644
index 0000000..ba8a5fa
--- /dev/null
+++ b/clang/test/Sema/warn-sizeof-arrayarg.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int Arr[10];
+
+typedef int trungl_int;
+
+void f(int a[10], Arr arr) { // \
+// expected-note {{declared here}} \
+// expected-note {{declared here}} \
+// expected-note {{declared here}} \
+// expected-note {{declared here}}
+
+ /* Should warn. */
+ (void)sizeof(a); // \
+ // expected-warning{{sizeof on array function parameter will return size of 'int *' instead of 'int [10]'}}
+ (void)sizeof((((a)))); // \
+ // expected-warning{{sizeof on array function parameter will return size of 'int *' instead of 'int [10]'}}
+ (void)sizeof a; // \
+ // expected-warning{{sizeof on array function parameter will return size of 'int *' instead of 'int [10]'}}
+ (void)sizeof arr; // \
+ // expected-warning{{sizeof on array function parameter will return size of 'int *' instead of 'Arr' (aka 'int [10]')}}
+
+ /* Shouldn't warn. */
+ int b[10];
+ (void)sizeof b;
+ Arr brr;
+ (void)sizeof brr;
+ (void)sizeof(Arr);
+ (void)sizeof(int);
+}
diff --git a/clang/test/Sema/warn-strlcpycat-size.c b/clang/test/Sema/warn-strlcpycat-size.c
new file mode 100644
index 0000000..8babdde
--- /dev/null
+++ b/clang/test/Sema/warn-strlcpycat-size.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -Wstrlcpy-strlcat-size -verify -fsyntax-only %s
+
+typedef __SIZE_TYPE__ size_t;
+size_t strlcpy (char * restrict dst, const char * restrict src, size_t size);
+size_t strlcat (char * restrict dst, const char * restrict src, size_t size);
+size_t strlen (const char *s);
+
+char s1[100];
+char s2[200];
+char * s3;
+
+struct {
+ char f1[100];
+ char f2[100][3];
+} s4, **s5;
+
+int x;
+
+void f(void)
+{
+ strlcpy(s1, s2, sizeof(s1)); // no warning
+ strlcpy(s1, s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
+ strlcpy(s1, s3, strlen(s3)+1); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
+ strlcat(s2, s3, sizeof(s3)); // expected-warning {{size argument in 'strlcat' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
+ strlcpy(s4.f1, s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
+ strlcpy((*s5)->f2[x], s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
+ strlcpy(s1+3, s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}}
+}
+
+// Don't issue FIXIT for flexible arrays.
+struct S {
+ int y;
+ char x[];
+};
+
+void flexible_arrays(struct S *s) {
+ char str[] = "hi";
+ strlcpy(s->x, str, sizeof(str)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}}
+}
+
+// Don't issue FIXIT for destinations of size 1.
+void size_1() {
+ char z[1];
+ char str[] = "hi";
+
+ strlcpy(z, str, sizeof(str)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}}
+}
+
+// Support VLAs.
+void vlas(int size) {
+ char z[size];
+ char str[] = "hi";
+
+ strlcpy(z, str, sizeof(str)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
+}
diff --git a/clang/test/Sema/warn-strncat-size.c b/clang/test/Sema/warn-strncat-size.c
new file mode 100644
index 0000000..7157edf
--- /dev/null
+++ b/clang/test/Sema/warn-strncat-size.c
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -Wstrncat-size -verify -fsyntax-only %s
+// RUN: %clang_cc1 -DUSE_BUILTINS -Wstrncat-size -verify -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -Wstrncat-size -fixit -x c %s
+// RUN: %clang_cc1 -DUSE_BUILTINS -fsyntax-only -Wstrncat-size -fixit -x c %s
+
+typedef __SIZE_TYPE__ size_t;
+size_t strlen (const char *s);
+
+#ifdef USE_BUILTINS
+# define BUILTIN(f) __builtin_ ## f
+#else
+# define BUILTIN(f) f
+#endif
+
+#define strncat BUILTIN(strncat)
+char *strncat(char *restrict s1, const char *restrict s2, size_t n);
+
+struct {
+ char f1[100];
+ char f2[100][3];
+} s4, **s5;
+
+char s1[100];
+char s2[200];
+int x;
+
+void test(char *src) {
+ char dest[10];
+
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - strlen(dest) - 1); // no-warning
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - 1); // no-warning - the code might assume that dest is empty
+
+ strncat(dest, src, sizeof(src)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
+
+ strncat(dest, src, sizeof(src) - 1); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
+
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest)); // expected-warning{{the value of the size argument in 'strncat' is too large, might lead to a buffer overflow}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
+
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - strlen(dest)); // expected-warning{{the value of the size argument in 'strncat' is too large, might lead to a buffer overflow}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
+
+ strncat((*s5)->f2[x], s2, sizeof(s2)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
+ strncat(s1+3, s2, sizeof(s2)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}}
+ strncat(s4.f1, s2, sizeof(s2)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
+}
+
+// Don't issue FIXIT for flexible arrays.
+struct S {
+ int y;
+ char x[];
+};
+
+void flexible_arrays(struct S *s) {
+ char str[] = "hi";
+ strncat(s->x, str, sizeof(str)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}}
+}
+
+// Don't issue FIXIT for destinations of size 1.
+void size_1() {
+ char z[1];
+ char str[] = "hi";
+
+ strncat(z, str, sizeof(z)); // expected-warning{{the value of the size argument in 'strncat' is too large, might lead to a buffer overflow}}
+}
+
+// Support VLAs.
+void vlas(int size) {
+ char z[size];
+ char str[] = "hi";
+
+ strncat(z, str, sizeof(str)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
+}
diff --git a/clang/test/Sema/warn-unreachable.c b/clang/test/Sema/warn-unreachable.c
new file mode 100644
index 0000000..636513f
--- /dev/null
+++ b/clang/test/Sema/warn-unreachable.c
@@ -0,0 +1,134 @@
+// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code -Wno-unused-value -Wno-covered-switch-default
+
+int halt() __attribute__((noreturn));
+int live();
+int dead();
+
+void test1() {
+ goto c;
+ d:
+ goto e; // expected-warning {{will never be executed}}
+ c: ;
+ int i;
+ return;
+ goto b; // expected-warning {{will never be executed}}
+ goto a; // expected-warning {{will never be executed}}
+ b:
+ i = 1;
+ a:
+ i = 2;
+ goto f;
+ e:
+ goto d;
+ f: ;
+}
+
+void test2() {
+ int i;
+ switch (live()) {
+ case 1:
+ halt(),
+ dead(); // expected-warning {{will never be executed}}
+
+ case 2:
+ live(), halt(),
+ dead(); // expected-warning {{will never be executed}}
+
+ case 3:
+ live()
+ + // expected-warning {{will never be executed}}
+ halt();
+ dead();
+
+ case 4:
+ a4:
+ live(),
+ halt();
+ goto a4; // expected-warning {{will never be executed}}
+
+ case 5:
+ goto a5;
+ c5:
+ dead(); // expected-warning {{will never be executed}}
+ goto b5;
+ a5:
+ live(),
+ halt();
+ b5:
+ goto c5;
+
+ case 6:
+ if (live())
+ goto e6;
+ live(),
+ halt();
+ d6:
+ dead(); // expected-warning {{will never be executed}}
+ goto b6;
+ c6:
+ dead();
+ goto b6;
+ e6:
+ live(),
+ halt();
+ b6:
+ goto c6;
+ case 7:
+ halt()
+ +
+ dead(); // expected-warning {{will never be executed}}
+ - // expected-warning {{will never be executed}}
+ halt();
+ case 8:
+ i // expected-warning {{will never be executed}}
+ +=
+ halt();
+ case 9:
+ halt()
+ ? // expected-warning {{will never be executed}}
+ dead() : dead();
+ case 10:
+ ( // expected-warning {{will never be executed}}
+ float)halt();
+ case 11: {
+ int a[5];
+ live(),
+ a[halt() // expected-warning {{will never be executed}}
+ ];
+ }
+ }
+}
+
+enum Cases { C1, C2, C3 };
+int test_enum_cases(enum Cases C) {
+ switch (C) {
+ case C1:
+ case C2:
+ case C3:
+ return 1;
+ default: {
+ int i = 0; // expected-warning{{will never be executed}}
+ ++i;
+ return i;
+ }
+ }
+}
+
+// Handle unreachable code triggered by macro expansions.
+void __myassert_rtn(const char *, const char *, int, const char *) __attribute__((__noreturn__));
+
+#define myassert(e) \
+ (__builtin_expect(!(e), 0) ? __myassert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
+
+void test_assert() {
+ myassert(0 && "unreachable");
+ return; // no-warning
+}
+
+// Test case for PR 9774. Tests that dead code in macros aren't warned about.
+#define MY_MAX(a,b) ((a) >= (b) ? (a) : (b))
+void PR9774(int *s) {
+ for (int i = 0; i < MY_MAX(2, 3); i++) // no-warning
+ s[i] = 0;
+}
+
diff --git a/clang/test/Sema/warn-unused-function.c b/clang/test/Sema/warn-unused-function.c
new file mode 100644
index 0000000..8f4cdcb
--- /dev/null
+++ b/clang/test/Sema/warn-unused-function.c
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-function -Wunneeded-internal-declaration -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s
+
+void foo() {}
+static void f2() {}
+static void f1() {f2();} // expected-warning{{unused}}
+
+static int f0() { return 17; } // expected-warning{{not needed and will not be emitted}}
+int x = sizeof(f0());
+
+static void f3();
+extern void f3() { } // expected-warning{{unused}}
+
+// FIXME: This will trigger a warning when it should not.
+// Update once PR6281 is fixed.
+//inline static void f4();
+//void f4() { }
+
+static void __attribute__((used)) f5() {}
+static void f6();
+static void __attribute__((used)) f6();
+static void f6() {};
+
+static void f7(void);
+void f8(void(*a0)(void));
+void f9(void) { f8(f7); }
+static void f7(void) {}
+
+__attribute__((unused)) static void bar(void);
+void bar(void) { }
+
+__attribute__((constructor)) static void bar2(void);
+void bar2(void) { }
+
+__attribute__((destructor)) static void bar3(void);
+void bar3(void) { }
+
+static void f10(void); // expected-warning{{unused}}
+static void f10(void);
+
+static void f11(void);
+static void f11(void) { } // expected-warning{{unused}}
+
+static void f12(void) { } // expected-warning{{unused}}
+static void f12(void);
+
+// PR7923
+static void unused(void) { unused(); } // expected-warning{{not needed and will not be emitted}}
+
+// rdar://8728293
+static void cleanupMalloc(char * const * const allocation) { }
+void f13(void) {
+ char * const __attribute__((cleanup(cleanupMalloc))) a;
+ (void)a;
+}
diff --git a/clang/test/Sema/warn-unused-label.c b/clang/test/Sema/warn-unused-label.c
new file mode 100644
index 0000000..48370a5
--- /dev/null
+++ b/clang/test/Sema/warn-unused-label.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-label -verify %s
+
+void f() {
+ a:
+ goto a;
+ b: // expected-warning{{unused}}
+ c: __attribute__((unused));
+ d: __attribute__((noreturn)); // expected-warning {{'noreturn' attribute only applies to functions}}
+ goto d;
+ return;
+}
diff --git a/clang/test/Sema/warn-unused-parameters.c b/clang/test/Sema/warn-unused-parameters.c
new file mode 100644
index 0000000..af048e7
--- /dev/null
+++ b/clang/test/Sema/warn-unused-parameters.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fblocks -fsyntax-only -Wunused-parameter %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fblocks -fsyntax-only -Wunused %s 2>&1 | FileCheck -check-prefix=CHECK-unused %s
+
+int f0(int x,
+ int y,
+ int z __attribute__((unused))) {
+ return x;
+}
+
+void f1() {
+ (void)^(int x,
+ int y,
+ int z __attribute__((unused))) { return x; };
+}
+
+// Used when testing '-Wunused' to see that we only emit one diagnostic, and no
+// warnings for the above cases.
+static void achor() {};
+
+// CHECK: 5:12: warning: unused parameter 'y'
+// CHECK: 12:15: warning: unused parameter 'y'
+// CHECK-unused: 1 warning generated
+
+// RUN: %clang_cc1 -fblocks -fsyntax-only -Weverything %s 2>&1 | FileCheck -check-prefix=CHECK-everything %s
+// RUN: %clang_cc1 -fblocks -fsyntax-only -Weverything -Werror %s 2>&1 | FileCheck -check-prefix=CHECK-everything-error %s
+// RUN: %clang_cc1 -fblocks -fsyntax-only -Weverything -Wno-unused %s 2>&1 | FileCheck -check-prefix=CHECK-everything-no-unused %s
+// CHECK-everything: 6 warnings generated
+// CHECK-everything-error: 5 errors generated
+// CHECK-everything-no-unused: 5 warnings generated
+
diff --git a/clang/test/Sema/warn-unused-value.c b/clang/test/Sema/warn-unused-value.c
new file mode 100644
index 0000000..95cd8fb
--- /dev/null
+++ b/clang/test/Sema/warn-unused-value.c
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -Wunused-label %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s
+
+int i = 0;
+int j = 0;
+
+void foo();
+
+// PR4806
+void pr4806() {
+ 1,foo(); // expected-warning {{expression result unused}}
+
+ // other
+ foo();
+ i; // expected-warning {{expression result unused}}
+
+ i,foo(); // expected-warning {{expression result unused}}
+ foo(),i; // expected-warning {{expression result unused}}
+
+ i,j,foo(); // expected-warning {{expression result unused}} expected-warning {{expression result unused}}
+ i,foo(),j; // expected-warning {{expression result unused}} expected-warning {{expression result unused}}
+ foo(),i,j; // expected-warning {{expression result unused}} expected-warning {{expression result unused}}
+
+ i++;
+
+ i++,foo();
+ foo(),i++;
+
+ i++,j,foo(); // expected-warning {{expression result unused}}
+ i++,foo(),j; // expected-warning {{expression result unused}}
+ foo(),i++,j; // expected-warning {{expression result unused}}
+
+ i,j++,foo(); // expected-warning {{expression result unused}}
+ i,foo(),j++; // expected-warning {{expression result unused}}
+ foo(),i,j++; // expected-warning {{expression result unused}}
+
+ i++,j++,foo();
+ i++,foo(),j++;
+ foo(),i++,j++;
+
+ {};
+ ({});
+ ({}),foo();
+ foo(),({});
+
+ (int)1U; // expected-warning {{expression result unused}}
+ (void)1U;
+
+ // pointer to volatile has side effect (thus no warning)
+ int* pi = &i;
+ volatile int* pj = &j;
+ *pi; // expected-warning {{expression result unused}}
+ *pj;
+
+ foo_label: // expected-warning {{unused label}}
+ i; // expected-warning {{expression result unused}}
+}
+
+// Don't warn about unused '||', '&&' expressions that contain assignments.
+int test_logical_foo1();
+int test_logical_foo2();
+int test_logical_foo3();
+int test_logical_bar() {
+ int x = 0;
+ (x = test_logical_foo1()) || // no-warning
+ (x = test_logical_foo2()) || // no-warning
+ (x = test_logical_foo3()); // no-warning
+
+ x || test_logical_foo1(); // no-warning
+
+ return x;
+}
+
+// PR8282
+void conditional_for_control_flow(int cond, int x, int y)
+{
+ cond? y++ : x; // no-warning
+ cond? y : ++x; // no-warning
+ cond? (x |= y) : ++x; // no-warning
+ cond? y : x; // expected-warning {{expression result unused}}
+}
+
+struct s0 { int f0; };
+
+void f0(int a);
+void f1(struct s0 *a) {
+ // rdar://8139785
+ f0((int)(a->f0 + 1, 10)); // expected-warning {{expression result unused}}
+}
diff --git a/clang/test/Sema/warn-unused-variables.c b/clang/test/Sema/warn-unused-variables.c
new file mode 100644
index 0000000..58e52b1
--- /dev/null
+++ b/clang/test/Sema/warn-unused-variables.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -fblocks -verify %s
+
+struct s0 {
+ unsigned int i;
+};
+
+int proto(int a, int b);
+
+void f0(void) {
+ int a __attribute__((unused)),
+ b; // expected-warning{{unused}}
+ return;
+}
+
+void f1(void) {
+ int i;
+ (void)sizeof(i);
+ return;
+}
+
+// PR5933
+int f2() {
+ int X = 4; // Shouldn't have a bogus 'unused variable X' warning.
+ return Y + X; // expected-error {{use of undeclared identifier 'Y'}}
+}
+
+int f3() {
+ int X1 = 4;
+ (void)(Y1 + X1); // expected-error {{use of undeclared identifier 'Y1'}}
+ (void)(^() { int X = 4; }); // expected-warning{{unused}}
+ (void)(^() { int X = 4; return Y + X; }); // expected-error {{use of undeclared identifier 'Y'}}
+}
diff --git a/clang/test/Sema/warn-write-strings.c b/clang/test/Sema/warn-write-strings.c
new file mode 100644
index 0000000..dee554c
--- /dev/null
+++ b/clang/test/Sema/warn-write-strings.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fconst-strings %s
+
+// PR4804
+char* x = "foo"; // expected-warning {{initializing 'char *' with an expression of type 'const char [4]' discards qualifiers}}
+
+// PR7192
+#include <stddef.h>
+void test(wchar_t *dst) {
+ dst[0] = 0; // Ok.
+}
diff --git a/clang/test/Sema/wchar.c b/clang/test/Sema/wchar.c
new file mode 100644
index 0000000..28ec2f1
--- /dev/null
+++ b/clang/test/Sema/wchar.c
@@ -0,0 +1,22 @@
+// RUN: %clang %s -fsyntax-only -Xclang -verify
+// RUN: %clang %s -fsyntax-only -fshort-wchar -Xclang -verify -DSHORT_WCHAR
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+#if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
+ || defined(_M_X64) || defined(SHORT_WCHAR)
+ #define WCHAR_T_TYPE unsigned short
+#elif defined(__sun) || defined(__AuroraUX__)
+ #define WCHAR_T_TYPE long
+#else /* Solaris or AuroraUX. */
+ #define WCHAR_T_TYPE int
+#endif
+
+int check_wchar_size[sizeof(*L"") == sizeof(wchar_t) ? 1 : -1];
+
+void foo() {
+ WCHAR_T_TYPE t1[] = L"x";
+ wchar_t tab[] = L"x";
+ WCHAR_T_TYPE t2[] = "x"; // expected-error {{initializer}}
+ char t3[] = L"x"; // expected-error {{initializer}}
+}
diff --git a/clang/test/Sema/weak-import-on-enum.c b/clang/test/Sema/weak-import-on-enum.c
new file mode 100644
index 0000000..3a2c0e5
--- /dev/null
+++ b/clang/test/Sema/weak-import-on-enum.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+// rdar://10277579
+
+enum __attribute__((deprecated)) __attribute__((weak_import)) A {
+ a0
+};
+
diff --git a/clang/test/Sema/x86-attr-force-align-arg-pointer.c b/clang/test/Sema/x86-attr-force-align-arg-pointer.c
new file mode 100644
index 0000000..5d36e9a
--- /dev/null
+++ b/clang/test/Sema/x86-attr-force-align-arg-pointer.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -fsyntax-only -verify %s
+
+int a __attribute__((force_align_arg_pointer)); // expected-warning{{attribute only applies to functions}}
+
+// It doesn't matter where the attribute is located.
+void b(void) __attribute__((force_align_arg_pointer));
+void __attribute__((force_align_arg_pointer)) c(void);
+
+// Functions only have to be declared force_align_arg_pointer once.
+void b(void) {}
+
+// It doesn't matter which declaration has the attribute.
+void d(void);
+void __attribute__((force_align_arg_pointer)) d(void) {}
+
+// Attribute is ignored on function pointer types.
+void (__attribute__((force_align_arg_pointer)) *p)();
+typedef void (__attribute__((__force_align_arg_pointer__)) *p2)();
+// Attribute is also ignored on function typedefs.
+typedef void __attribute__((force_align_arg_pointer)) e(void);
+
diff --git a/clang/test/Sema/x86-builtin-palignr.c b/clang/test/Sema/x86-builtin-palignr.c
new file mode 100644
index 0000000..6f4b90d
--- /dev/null
+++ b/clang/test/Sema/x86-builtin-palignr.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -ffreestanding -fsyntax-only -target-feature +ssse3 -target-feature +mmx -verify -triple x86_64-pc-linux-gnu %s
+// RUN: %clang_cc1 -ffreestanding -fsyntax-only -target-feature +ssse3 -target-feature +mmx -verify -triple i686-apple-darwin10 %s
+
+#include <tmmintrin.h>
+
+__m64 test1(__m64 a, __m64 b, int c) {
+ // FIXME: The "incompatible result type" error is due to pr10112 and should
+ // be removed when that is fixed.
+ return _mm_alignr_pi8(a, b, c); // expected-error {{argument to '__builtin_ia32_palignr' must be a constant integer}} expected-error {{incompatible result type}}
+}
+
+int test2(int N) {
+ __m128i white2;
+ white2 = __builtin_ia32_pslldqi128(white2, N); // expected-error {{argument to '__builtin_ia32_pslldqi128' must be a constant integer}}
+ return 0;
+}
+
diff --git a/clang/test/SemaCUDA/config-type.cu b/clang/test/SemaCUDA/config-type.cu
new file mode 100644
index 0000000..a469d38
--- /dev/null
+++ b/clang/test/SemaCUDA/config-type.cu
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void cudaConfigureCall(unsigned gridSize, unsigned blockSize); // expected-error {{must have scalar return type}}
diff --git a/clang/test/SemaCUDA/cuda.h b/clang/test/SemaCUDA/cuda.h
new file mode 100644
index 0000000..26a8df0
--- /dev/null
+++ b/clang/test/SemaCUDA/cuda.h
@@ -0,0 +1,19 @@
+/* Minimal declarations for CUDA support. Testing purposes only. */
+
+#include <stddef.h>
+
+#define __constant__ __attribute__((constant))
+#define __device__ __attribute__((device))
+#define __global__ __attribute__((global))
+#define __host__ __attribute__((host))
+#define __shared__ __attribute__((shared))
+
+struct dim3 {
+ unsigned x, y, z;
+ __host__ __device__ dim3(unsigned x, unsigned y = 1, unsigned z = 1) : x(x), y(y), z(z) {}
+};
+
+typedef struct cudaStream *cudaStream_t;
+
+int cudaConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0,
+ cudaStream_t stream = 0);
diff --git a/clang/test/SemaCUDA/function-target.cu b/clang/test/SemaCUDA/function-target.cu
new file mode 100644
index 0000000..c7a55e2
--- /dev/null
+++ b/clang/test/SemaCUDA/function-target.cu
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include "cuda.h"
+
+__host__ void h1h(void);
+__device__ void h1d(void); // expected-note {{candidate function not viable: call to __device__ function from __host__ function}}
+__host__ __device__ void h1hd(void);
+__global__ void h1g(void);
+
+struct h1ds { // expected-note {{requires 1 argument}}
+ __device__ h1ds(); // expected-note {{candidate constructor not viable: call to __device__ function from __host__ function}}
+};
+
+__host__ void h1(void) {
+ h1h();
+ h1d(); // expected-error {{no matching function}}
+ h1hd();
+ h1g<<<1, 1>>>();
+ h1ds x; // expected-error {{no matching constructor}}
+}
+
+__host__ void d1h(void); // expected-note {{candidate function not viable: call to __host__ function from __device__ function}}
+__device__ void d1d(void);
+__host__ __device__ void d1hd(void);
+__global__ void d1g(void); // expected-note {{'d1g' declared here}}
+
+__device__ void d1(void) {
+ d1h(); // expected-error {{no matching function}}
+ d1d();
+ d1hd();
+ d1g<<<1, 1>>>(); // expected-error {{reference to __global__ function 'd1g' in __device__ function}}
+}
+
+__host__ void hd1h(void); // expected-note {{candidate function not viable: call to __host__ function from __host__ __device__ function}}
+__device__ void hd1d(void); // expected-note {{candidate function not viable: call to __device__ function from __host__ __device__ function}}
+__host__ __device__ void hd1hd(void);
+__global__ void hd1g(void); // expected-note {{'hd1g' declared here}}
+
+__host__ __device__ void hd1(void) {
+ hd1h(); // expected-error {{no matching function}}
+ hd1d(); // expected-error {{no matching function}}
+ hd1hd();
+ hd1g<<<1, 1>>>(); // expected-error {{reference to __global__ function 'hd1g' in __host__ __device__ function}}
+}
diff --git a/clang/test/SemaCUDA/kernel-call.cu b/clang/test/SemaCUDA/kernel-call.cu
new file mode 100644
index 0000000..91b1d49
--- /dev/null
+++ b/clang/test/SemaCUDA/kernel-call.cu
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include "cuda.h"
+
+__global__ void g1(int x) {}
+
+template <typename T> void t1(T arg) {
+ g1<<<arg, arg>>>(1);
+}
+
+void h1(int x) {}
+int h2(int x) { return 1; }
+
+int main(void) {
+ g1<<<1, 1>>>(42);
+ g1(42); // expected-error {{call to global function g1 not configured}}
+ g1<<<1>>>(42); // expected-error {{too few execution configuration arguments to kernel function call}}
+ g1<<<1, 1, 0, 0, 0>>>(42); // expected-error {{too many execution configuration arguments to kernel function call}}
+
+ t1(1);
+
+ h1<<<1, 1>>>(42); // expected-error {{kernel call to non-global function h1}}
+
+ int (*fp)(int) = h2;
+ fp<<<1, 1>>>(42); // expected-error {{must have void return type}}
+}
diff --git a/clang/test/SemaCUDA/qualifiers.cu b/clang/test/SemaCUDA/qualifiers.cu
new file mode 100644
index 0000000..1346d65
--- /dev/null
+++ b/clang/test/SemaCUDA/qualifiers.cu
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include "cuda.h"
+
+__global__ void g1(int x) {}
+__global__ int g2(int x) { // expected-error {{must have void return type}}
+ return 1;
+}
diff --git a/clang/test/SemaCXX/2008-01-11-BadWarning.cpp b/clang/test/SemaCXX/2008-01-11-BadWarning.cpp
new file mode 100644
index 0000000..b84e7c1
--- /dev/null
+++ b/clang/test/SemaCXX/2008-01-11-BadWarning.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s
+// rdar://5683899
+void** f(void **Buckets, unsigned NumBuckets) {
+ return Buckets + NumBuckets;
+}
diff --git a/clang/test/SemaCXX/Inputs/array-bounds-system-header.h b/clang/test/SemaCXX/Inputs/array-bounds-system-header.h
new file mode 100644
index 0000000..07cde80
--- /dev/null
+++ b/clang/test/SemaCXX/Inputs/array-bounds-system-header.h
@@ -0,0 +1,11 @@
+// "System header" for testing that -Warray-bounds is properly suppressed in
+// certain cases.
+
+#define BAD_MACRO_1 \
+ int i[3]; \
+ i[3] = 5
+#define BAD_MACRO_2(_b, _i) \
+ (_b)[(_i)] = 5
+#define QUESTIONABLE_MACRO(_a) \
+ sizeof(_a) > 3 ? (_a)[3] = 5 : 5
+#define NOP(x) (x)
diff --git a/clang/test/SemaCXX/Inputs/lit.local.cfg b/clang/test/SemaCXX/Inputs/lit.local.cfg
new file mode 100644
index 0000000..e6f55ee
--- /dev/null
+++ b/clang/test/SemaCXX/Inputs/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = []
diff --git a/clang/test/SemaCXX/Inputs/malloc.h b/clang/test/SemaCXX/Inputs/malloc.h
new file mode 100644
index 0000000..c54d621
--- /dev/null
+++ b/clang/test/SemaCXX/Inputs/malloc.h
@@ -0,0 +1,3 @@
+extern "C" {
+extern void *malloc (__SIZE_TYPE__ __size) throw () __attribute__ ((__malloc__)) ;
+}
diff --git a/clang/test/SemaCXX/Inputs/warn-new-overaligned-3.h b/clang/test/SemaCXX/Inputs/warn-new-overaligned-3.h
new file mode 100644
index 0000000..d2bd4d5
--- /dev/null
+++ b/clang/test/SemaCXX/Inputs/warn-new-overaligned-3.h
@@ -0,0 +1,19 @@
+#pragma GCC system_header
+
+// This header file pretends to be <new> from the system library, for the
+// purpose of the over-aligned warnings test.
+
+void* operator new(unsigned long) {
+ return 0;
+}
+void* operator new[](unsigned long) {
+ return 0;
+}
+
+void* operator new(unsigned long, void *) {
+ return 0;
+}
+
+void* operator new[](unsigned long, void *) {
+ return 0;
+}
diff --git a/clang/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp b/clang/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
new file mode 100644
index 0000000..0c7d354
--- /dev/null
+++ b/clang/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++98 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions
+
+
+//MSVC allows forward enum declaration
+enum ENUM; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
+ENUM *var = 0;
+ENUM var2 = (ENUM)3;
+enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types are a Microsoft extension}}
diff --git a/clang/test/SemaCXX/MicrosoftCompatibility.cpp b/clang/test/SemaCXX/MicrosoftCompatibility.cpp
new file mode 100644
index 0000000..3634fa3
--- /dev/null
+++ b/clang/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -0,0 +1,176 @@
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions
+
+
+
+namespace ms_conversion_rules {
+
+void f(float a);
+void f(int a);
+
+void test()
+{
+ long a = 0;
+ f((long)0);
+ f(a);
+}
+
+}
+
+
+
+namespace ms_protected_scope {
+ struct C { C(); };
+
+ int jump_over_variable_init(bool b) {
+ if (b)
+ goto foo; // expected-warning {{goto into protected scope}}
+ C c; // expected-note {{jump bypasses variable initialization}}
+ foo:
+ return 1;
+ }
+
+struct Y {
+ ~Y();
+};
+
+void jump_over_var_with_dtor() {
+ goto end; // expected-warning{{goto into protected scope}}
+ Y y; // expected-note {{jump bypasses variable with a non-trivial destructor}}
+ end:
+ ;
+}
+
+ void jump_over_variable_case(int c) {
+ switch (c) {
+ case 0:
+ int x = 56; // expected-note {{jump bypasses variable initialization}}
+ case 1: // expected-error {{switch case is in protected scope}}
+ x = 10;
+ }
+ }
+
+
+void exception_jump() {
+ goto l2; // expected-error {{goto into protected scope}}
+ try { // expected-note {{jump bypasses initialization of try block}}
+ l2: ;
+ } catch(int) {
+ }
+}
+
+int jump_over_indirect_goto() {
+ static void *ps[] = { &&a0 };
+ goto *&&a0; // expected-warning {{goto into protected scope}}
+ int a = 3; // expected-note {{jump bypasses variable initialization}}
+ a0:
+ return 0;
+}
+
+}
+
+namespace PR11826 {
+ struct pair {
+ pair(int v) { }
+ void operator=(pair&& rhs) { }
+ };
+ void f() {
+ pair p0(3);
+ pair p = p0;
+ }
+}
+
+namespace PR11826_for_symmetry {
+ struct pair {
+ pair(int v) { }
+ pair(pair&& rhs) { }
+ };
+ void f() {
+ pair p0(3);
+ pair p(4);
+ p = p0;
+ }
+}
+
+namespace ms_using_declaration_bug {
+
+class A {
+public:
+ int f();
+};
+
+class B : public A {
+private:
+ using A::f;
+};
+
+class C : public B {
+private:
+ using B::f; // expected-warning {{using declaration referring to inaccessible member 'ms_using_declaration_bug::B::f' (which refers to accessible member 'ms_using_declaration_bug::A::f') is a Microsoft compatibility extension}}
+};
+
+}
+
+
+namespace MissingTypename {
+
+template<class T> class A {
+public:
+ typedef int TYPE;
+};
+
+template<class T> class B {
+public:
+ typedef int TYPE;
+};
+
+
+template<class T, class U>
+class C : private A<T>, public B<U> {
+public:
+ typedef A<T> Base1;
+ typedef B<U> Base2;
+ typedef A<U> Base3;
+
+ A<T>::TYPE a1; // expected-warning {{missing 'typename' prior to dependent type name}}
+ Base1::TYPE a2; // expected-warning {{missing 'typename' prior to dependent type name}}
+
+ B<U>::TYPE a3; // expected-warning {{missing 'typename' prior to dependent type name}}
+ Base2::TYPE a4; // expected-warning {{missing 'typename' prior to dependent type name}}
+
+ A<U>::TYPE a5; // expected-error {{missing 'typename' prior to dependent type name}}
+ Base3::TYPE a6; // expected-error {{missing 'typename' prior to dependent type name}}
+ };
+
+class D {
+public:
+ typedef int Type;
+};
+
+template <class T>
+void function_missing_typename(const T::Type param)// expected-warning {{missing 'typename' prior to dependent type name}}
+{
+ const T::Type var = 2; // expected-warning {{missing 'typename' prior to dependent type name}}
+}
+
+template void function_missing_typename<D>(const D::Type param);
+
+}
+
+enum ENUM2 {
+ ENUM2_a = (enum ENUM2) 4,
+ ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
+ ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
+};
+
+
+namespace PR11791 {
+ template<class _Ty>
+ void del(_Ty *_Ptr) {
+ _Ptr->~_Ty(); // expected-warning {{pseudo-destructors on type void are a Microsoft extension}}
+ }
+
+ void f() {
+ int* a = 0;
+ del((void*)a); // expected-note {{in instantiation of function template specialization}}
+ }
+}
diff --git a/clang/test/SemaCXX/MicrosoftExtensions.cpp b/clang/test/SemaCXX/MicrosoftExtensions.cpp
new file mode 100644
index 0000000..0b72cd3
--- /dev/null
+++ b/clang/test/SemaCXX/MicrosoftExtensions.cpp
@@ -0,0 +1,205 @@
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -verify -fms-extensions -fexceptions -fcxx-exceptions
+
+
+// ::type_info is predeclared with forward class declartion
+void f(const type_info &a);
+
+
+// Microsoft doesn't validate exception specification.
+namespace microsoft_exception_spec {
+
+void foo(); // expected-note {{previous declaration}}
+void foo() throw(); // expected-warning {{exception specification in declaration does not match previous declaration}}
+
+void r6() throw(...); // expected-note {{previous declaration}}
+void r6() throw(int); // expected-warning {{exception specification in declaration does not match previous declaration}}
+
+struct Base {
+ virtual void f2();
+ virtual void f3() throw(...);
+};
+
+struct Derived : Base {
+ virtual void f2() throw(...);
+ virtual void f3();
+};
+
+class A {
+ virtual ~A() throw(); // expected-note {{overridden virtual function is here}}
+};
+
+class B : public A {
+ virtual ~B(); // expected-warning {{exception specification of overriding function is more lax than base version}}
+};
+
+}
+
+// MSVC allows type definition in anonymous union and struct
+struct A
+{
+ union
+ {
+ int a;
+ struct B // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
+ {
+ int c;
+ } d;
+
+ union C // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
+ {
+ int e;
+ int ee;
+ } f;
+
+ typedef int D; // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
+ struct F; // expected-warning {{types declared in an anonymous union are a Microsoft extension}}
+ };
+
+ struct
+ {
+ int a2;
+
+ struct B2 // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
+ {
+ int c2;
+ } d2;
+
+ union C2 // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
+ {
+ int e2;
+ int ee2;
+ } f2;
+
+ typedef int D2; // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
+ struct F2; // expected-warning {{types declared in an anonymous struct are a Microsoft extension}}
+ };
+};
+
+// __stdcall handling
+struct M {
+ int __stdcall addP();
+ float __stdcall subtractP();
+};
+
+// __unaligned handling
+typedef char __unaligned *aligned_type;
+
+
+template<typename T> void h1(T (__stdcall M::* const )()) { }
+
+void m1() {
+ h1<int>(&M::addP);
+ h1(&M::subtractP);
+}
+
+
+
+
+
+void f(long long);
+void f(int);
+
+int main()
+{
+ // This is an ambiguous call in standard C++.
+ // This calls f(long long) in Microsoft mode because LL is always signed.
+ f(0xffffffffffffffffLL);
+ f(0xffffffffffffffffi64);
+}
+
+// Enumeration types with a fixed underlying type.
+const int seventeen = 17;
+typedef int Int;
+
+struct X0 {
+ enum E1 : Int { SomeOtherValue } field; // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
+ enum E1 : seventeen;
+};
+
+enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
+ SomeValue = 0x100000000
+};
+
+
+class AAA {
+__declspec(dllimport) void f(void) { }
+void f2(void);
+};
+
+__declspec(dllimport) void AAA::f2(void) { // expected-error {{dllimport attribute can be applied only to symbol}}
+
+}
+
+
+
+template <class T>
+class BB {
+public:
+ void f(int g = 10 ); // expected-note {{previous definition is here}}
+};
+
+template <class T>
+void BB<T>::f(int g = 0) { } // expected-warning {{redefinition of default argument}}
+
+
+
+extern void static_func();
+void static_func(); // expected-note {{previous declaration is here}}
+
+
+static void static_func() // expected-warning {{static declaration of 'static_func' follows non-static declaration}}
+{
+
+}
+
+long function_prototype(int a);
+long (*function_ptr)(int a);
+
+void function_to_voidptr_conv() {
+ void *a1 = function_prototype;
+ void *a2 = &function_prototype;
+ void *a3 = function_ptr;
+}
+
+
+void pointer_to_integral_type_conv(char* ptr) {
+ char ch = (char)ptr;
+ short sh = (short)ptr;
+ ch = (char)ptr;
+ sh = (short)ptr;
+}
+
+
+namespace friend_as_a_forward_decl {
+
+class A {
+ class Nested {
+ friend class B;
+ B* b;
+ };
+ B* b;
+};
+B* global_b;
+
+
+void f()
+{
+ class Local {
+ friend class Z;
+ Z* b;
+ };
+ Z* b;
+}
+
+}
+
+struct PR11150 {
+ class X {
+ virtual void f() = 0;
+ };
+
+ int array[__is_abstract(X)? 1 : -1];
+};
+
+void f() { int __except = 0; }
+
diff --git a/clang/test/SemaCXX/PR10177.cpp b/clang/test/SemaCXX/PR10177.cpp
new file mode 100644
index 0000000..8d745de
--- /dev/null
+++ b/clang/test/SemaCXX/PR10177.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+template<typename T, typename U, U> using alias_ref = T;
+template<typename T, typename U, U> void func_ref() {}
+template<typename T, typename U, U> struct class_ref {};
+
+template<int N>
+struct U {
+ static int a;
+};
+
+template<int N> struct S; // expected-note 2{{here}}
+
+template<int N>
+int U<N>::a = S<N>::kError; // expected-error 2{{undefined}}
+
+template<typename T>
+void f() {
+ // FIXME: The standard suggests that U<0>::a is odr-used by this expression,
+ // but it's not entirely clear that's the right behaviour.
+ (void)alias_ref<int, int&, U<0>::a>();
+ (void)func_ref<int, int&, U<1>::a>(); // expected-note {{here}}
+ (void)class_ref<int, int&, U<2>::a>(); // expected-note {{here}}
+};
+
+int main() {
+ f<int>(); // expected-note 2{{here}}
+}
+
+namespace N {
+ template<typename T> struct S { static int n; };
+ template<typename T> int S<T>::n = 5;
+ void g(int*);
+ template<typename T> int f() {
+ int k[S<T>::n];
+ g(k);
+ return k[3];
+ }
+ int j = f<int>();
+}
diff --git a/clang/test/SemaCXX/PR10243.cpp b/clang/test/SemaCXX/PR10243.cpp
new file mode 100644
index 0000000..129ff80
--- /dev/null
+++ b/clang/test/SemaCXX/PR10243.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct S; // expected-note 4{{forward declaration of 'S'}}
+
+struct T0 {
+ S s; // expected-error{{field has incomplete type 'S'}}
+ T0() = default;
+};
+
+struct T1 {
+ S s; // expected-error{{field has incomplete type 'S'}}
+ T1(T1&) = default;
+};
+
+struct T2 {
+ S s; // expected-error{{field has incomplete type 'S'}}
+ T2& operator=(T2&) = default;
+};
+
+struct T3 {
+ S s; // expected-error{{field has incomplete type 'S'}}
+ ~T3() = default;
+};
diff --git a/clang/test/SemaCXX/PR10447.cpp b/clang/test/SemaCXX/PR10447.cpp
new file mode 100644
index 0000000..08644ad
--- /dev/null
+++ b/clang/test/SemaCXX/PR10447.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -verify %s
+
+// PR12223
+namespace test1 {
+ namespace N {
+ extern "C" void f(struct S*);
+ void g(S*);
+ }
+ namespace N {
+ void f(struct S *s) {
+ g(s);
+ }
+ }
+}
+
+// PR10447
+namespace test2 {
+ extern "C" {
+ void f(struct Bar*) { }
+ test2::Bar *ptr;
+ }
+}
diff --git a/clang/test/SemaCXX/PR10458.cpp b/clang/test/SemaCXX/PR10458.cpp
new file mode 100644
index 0000000..57588eb
--- /dev/null
+++ b/clang/test/SemaCXX/PR10458.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98
+
+void f() {
+ int arr[] = { 1, 2, 3 };
+ for (auto &i : arr) { // expected-warning {{'auto' type specifier is a C++11 extension}} expected-warning {{range-based for loop is a C++11 extension}}
+ }
+}
diff --git a/clang/test/SemaCXX/PR11358.cpp b/clang/test/SemaCXX/PR11358.cpp
new file mode 100644
index 0000000..9c49227
--- /dev/null
+++ b/clang/test/SemaCXX/PR11358.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 %s -verify
+// PR11358
+
+namespace test1 {
+ template<typename T>
+ struct container {
+ class iterator {};
+ iterator begin() { return iterator(); }
+ };
+
+ template<typename T>
+ struct Test {
+ typedef container<T> Container;
+ void test() {
+ Container::iterator i = c.begin(); // expected-error{{missing 'typename'}}
+ }
+ Container c;
+ };
+}
+
+namespace test2 {
+ template <typename Key, typename Value>
+ class hash_map {
+ class const_iterator { void operator++(); };
+ const_iterator begin() const;
+ const_iterator end() const;
+ };
+
+ template <typename KeyType, typename ValueType>
+ void MapTest(hash_map<KeyType, ValueType> map) {
+ for (hash_map<KeyType, ValueType>::const_iterator it = map.begin(); // expected-error{{missing 'typename'}}
+ it != map.end(); it++) {
+ }
+ }
+}
+
+namespace test3 {
+ template<typename T>
+ struct container {
+ class iterator {};
+ };
+
+ template<typename T>
+ struct Test {
+ typedef container<T> Container;
+ void test() {
+ Container::iterator const i; // expected-error{{missing 'typename'}}
+ }
+ Container c;
+ };
+}
diff --git a/clang/test/SemaCXX/PR12481.cpp b/clang/test/SemaCXX/PR12481.cpp
new file mode 100644
index 0000000..9487e4d
--- /dev/null
+++ b/clang/test/SemaCXX/PR12481.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -x c++ -fsyntax-only %s
+
+class C1 { };
+class C2 { };
+template<class TrieData> struct BinaryTrie {
+ ~BinaryTrie() {
+ (void)(({
+ static int x = 5;
+ }
+ ));
+ }
+};
+class FooTable {
+ BinaryTrie<C1> c1_trie_;
+ BinaryTrie<C2> c2_trie_;
+};
+FooTable* foo = new FooTable;
diff --git a/clang/test/SemaCXX/PR5086-ambig-resolution-enum.cpp b/clang/test/SemaCXX/PR5086-ambig-resolution-enum.cpp
new file mode 100644
index 0000000..b5aac5f
--- /dev/null
+++ b/clang/test/SemaCXX/PR5086-ambig-resolution-enum.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+class C {
+public:
+ enum E { e1=0 };
+ const char * fun1(int , enum E) const;
+ int fun1(unsigned, const char *) const;
+};
+
+void foo(const C& rc) {
+ enum {BUFLEN = 128 };
+ const char *p = rc.fun1(BUFLEN - 2, C::e1);
+}
diff --git a/clang/test/SemaCXX/PR6562.cpp b/clang/test/SemaCXX/PR6562.cpp
new file mode 100644
index 0000000..854d9b0
--- /dev/null
+++ b/clang/test/SemaCXX/PR6562.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct X { ~X(); };
+template <typename T>
+struct A {
+ struct B { X x; };
+ struct C : public B {
+ C() : B() { }
+ };
+};
diff --git a/clang/test/SemaCXX/PR6618.cpp b/clang/test/SemaCXX/PR6618.cpp
new file mode 100644
index 0000000..10d4dc8
--- /dev/null
+++ b/clang/test/SemaCXX/PR6618.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class bar; // expected-note {{forward declaration of 'bar'}}
+struct zed {
+ bar g; // expected-error {{field has incomplete type}}
+};
+class baz {
+ zed h;
+};
+void f() {
+ enum {
+ e = sizeof(baz)
+ };
+}
diff --git a/clang/test/SemaCXX/PR7410.cpp b/clang/test/SemaCXX/PR7410.cpp
new file mode 100644
index 0000000..6d2cda9
--- /dev/null
+++ b/clang/test/SemaCXX/PR7410.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct BaseReturn {};
+
+struct Base {
+ virtual BaseReturn Foo() = 0; // expected-note{{overridden virtual function is here}}
+};
+struct X {};
+struct Derived : Base {
+ X Foo(); // expected-error{{virtual function 'Foo' has a different return type ('X') than the function it overrides (which has return type 'BaseReturn')}}
+};
+
+Derived d;
diff --git a/clang/test/SemaCXX/PR7944.cpp b/clang/test/SemaCXX/PR7944.cpp
new file mode 100644
index 0000000..51b3f6b
--- /dev/null
+++ b/clang/test/SemaCXX/PR7944.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR7944
+
+#define MACRO(x) x
+
+struct B { int f() { return 0; } };
+struct A { B* b() { return new B; } };
+
+void g() {
+ A a;
+ MACRO(a.b->f()); // expected-error{{reference to non-static member function must be called; did you mean to call it with no arguments?}}
+}
diff --git a/clang/test/SemaCXX/PR8012.cpp b/clang/test/SemaCXX/PR8012.cpp
new file mode 100644
index 0000000..9cfc2b0
--- /dev/null
+++ b/clang/test/SemaCXX/PR8012.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+void foo (int operator+); // expected-error{{cannot be the name of a parameter}}
diff --git a/clang/test/SemaCXX/PR8385.cpp b/clang/test/SemaCXX/PR8385.cpp
new file mode 100644
index 0000000..77a117a
--- /dev/null
+++ b/clang/test/SemaCXX/PR8385.cpp
@@ -0,0 +1,7 @@
+// RUN: not %clang_cc1 -fsyntax-only %s
+
+// don't crash on this, but don't constrain our diagnostics here as they're
+// currently rather poor (we even accept things like "template struct {}").
+// Other, explicit tests, should verify the relevant behavior of template
+// instantiation.
+struct{template struct{
diff --git a/clang/test/SemaCXX/PR8755.cpp b/clang/test/SemaCXX/PR8755.cpp
new file mode 100644
index 0000000..07778dd
--- /dev/null
+++ b/clang/test/SemaCXX/PR8755.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template <typename T>
+struct A {
+ typedef int iterator; // expected-note{{declared here}}
+};
+
+template <typename T>
+void f() {
+ class A <T> ::iterator foo; // expected-error{{elaborated type refers to a typedef}}
+}
+
+void g() {
+ f<int>(); // expected-note{{in instantiation of function template}}
+}
+
diff --git a/clang/test/SemaCXX/PR8884.cpp b/clang/test/SemaCXX/PR8884.cpp
new file mode 100644
index 0000000..4026465
--- /dev/null
+++ b/clang/test/SemaCXX/PR8884.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+extern "C" {
+ class bar {
+ friend struct foo;
+ static struct foo& baz ();
+ };
+ struct foo {
+ void zed () {
+ bar::baz();
+ }
+ };
+}
diff --git a/clang/test/SemaCXX/PR9459.cpp b/clang/test/SemaCXX/PR9459.cpp
new file mode 100644
index 0000000..2b96f34
--- /dev/null
+++ b/clang/test/SemaCXX/PR9459.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Don't crash.
+
+template<typename>struct ae_same;
+template<typename>struct ts{}ap() // expected-error {{expected ';' after struct}} expected-error {{requires a type specifier}}
+{ts<a>::ap<ae_same<int>::&ae_same<>>::p(a); }; // expected-error {{use of undeclared identifier 'a'}}
diff --git a/clang/test/SemaCXX/PR9460.cpp b/clang/test/SemaCXX/PR9460.cpp
new file mode 100644
index 0000000..0dd8446
--- /dev/null
+++ b/clang/test/SemaCXX/PR9460.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Don't crash.
+
+template<typename aT>
+struct basic_string{
+ a; // expected-error {{requires a type specifier}}
+ basic_string(aT*);
+};
+
+struct runtime_error{
+ runtime_error(
+basic_string<char> struct{ // expected-error {{cannot combine with previous 'type-name' declaration specifier}}
+a(){ // expected-error {{requires a type specifier}}
+ runtime_error(0);
+}
+}
+);
+};
diff --git a/clang/test/SemaCXX/PR9461.cpp b/clang/test/SemaCXX/PR9461.cpp
new file mode 100644
index 0000000..beed348
--- /dev/null
+++ b/clang/test/SemaCXX/PR9461.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Don't crash.
+
+template<typename,typename=int,typename=int>struct basic_string;
+
+typedef basic_string<char> string;
+
+
+
+template<typename aT,typename,typename oc>
+struct basic_string
+{
+int us;
+basic_string(const aT*,const oc&a=int());
+
+int _S_construct();
+
+int _S_construct(int);
+
+_S_construct(); // expected-error {{requires}}
+};
+
+template<typename _CharT,typename _Traits,typename _Alloc>
+basic_string<_CharT,_Traits,_Alloc>::basic_string(const _CharT*,const _Alloc&)
+:us(_S_construct)
+{string a;}
+
+struct runtime_error{runtime_error(string);};
+
+struct system_error:runtime_error{ // expected-note {{to match}}
+system_error():time_error("" // expected-error 3 {{expected}} expected-note {{to match}}
diff --git a/clang/test/SemaCXX/PR9572.cpp b/clang/test/SemaCXX/PR9572.cpp
new file mode 100644
index 0000000..b475b57
--- /dev/null
+++ b/clang/test/SemaCXX/PR9572.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class Base {
+ virtual ~Base(); // expected-note {{implicitly declared private here}}
+};
+struct Foo : public Base { // expected-error {{base class 'Base' has private destructor}}
+ const int kBlah = 3; // expected-warning {{is a C++11 extension}}
+ Foo();
+};
+struct Bar : public Foo {
+ Bar() { } // expected-note {{implicit default destructor for 'Foo' first required here}}
+};
+struct Baz {
+ Foo f;
+ Baz() { }
+};
diff --git a/clang/test/SemaCXX/PR9884.cpp b/clang/test/SemaCXX/PR9884.cpp
new file mode 100644
index 0000000..ab883c4
--- /dev/null
+++ b/clang/test/SemaCXX/PR9884.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class Base {
+protected:
+ Base(int val);
+};
+
+
+class Derived : public Base {
+public:
+ Derived(int val);
+};
+
+
+Derived::Derived(int val)
+ : Base( val )
+{
+}
diff --git a/clang/test/SemaCXX/PR9902.cpp b/clang/test/SemaCXX/PR9902.cpp
new file mode 100644
index 0000000..80086e4
--- /dev/null
+++ b/clang/test/SemaCXX/PR9902.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template <class _Tp, class _Up, bool = false>
+struct __allocator_traits_rebind
+{
+};
+
+template <template <class, class...> class _Alloc, class _Tp, class ..._Args,
+class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false>
+{
+ typedef _Alloc<_Up, _Args...> type;
+};
+
+template <class Alloc>
+struct allocator_traits
+{
+ template <class T> using rebind_alloc = typename __allocator_traits_rebind<Alloc, T>::type;
+ template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
+};
+
+template <class T>
+struct allocator {};
+
+int main()
+{
+ allocator_traits<allocator<char>>::rebind_alloc<int> a;
+}
diff --git a/clang/test/SemaCXX/PR9908.cpp b/clang/test/SemaCXX/PR9908.cpp
new file mode 100644
index 0000000..fc090cc
--- /dev/null
+++ b/clang/test/SemaCXX/PR9908.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template <class _Tp, class _Up>
+struct __allocator_traits_rebind
+{
+ typedef typename _Tp::template rebind<_Up>::other type;
+};
+
+template <class Alloc>
+struct allocator_traits
+{
+ typedef Alloc allocator_type;
+ template <class T> using rebind_alloc = typename
+__allocator_traits_rebind<allocator_type, T>::type;
+ template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
+};
+
+template <class T>
+struct ReboundA {};
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+ template <class U> struct rebind {typedef ReboundA<U> other;};
+};
+
+int main()
+{
+ allocator_traits<A<char> >::rebind_traits<double> a;
+}
diff --git a/clang/test/SemaCXX/__null.cpp b/clang/test/SemaCXX/__null.cpp
new file mode 100644
index 0000000..56e59c0
--- /dev/null
+++ b/clang/test/SemaCXX/__null.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -Wno-null-conversion -fsyntax-only -verify
+// RUN: %clang_cc1 -triple i686-unknown-unknown %s -Wno-null-conversion -fsyntax-only -verify
+
+void f() {
+ int* i = __null;
+ i = __null;
+ int i2 = __null;
+
+ // Verify statically that __null is the right size
+ int a[sizeof(typeof(__null)) == sizeof(void*)? 1 : -1];
+
+ // Verify that null is evaluated as 0.
+ int b[__null ? -1 : 1];
+}
+
+struct A {};
+
+void g() {
+ (void)(0 ? __null : A()); // expected-error {{non-pointer operand type 'A' incompatible with NULL}}
+ (void)(0 ? A(): __null); // expected-error {{non-pointer operand type 'A' incompatible with NULL}}
+}
diff --git a/clang/test/SemaCXX/__try.cpp b/clang/test/SemaCXX/__try.cpp
new file mode 100644
index 0000000..cb5d38a
--- /dev/null
+++ b/clang/test/SemaCXX/__try.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fborland-extensions -fcxx-exceptions %s
+
+// This test is from http://docwiki.embarcadero.com/RADStudio/en/Try
+
+int puts(const char *);
+
+template<typename T>
+int printf(const char *, T);
+
+const char * strdup(const char *);
+
+void free(const void *);
+
+#define EXCEPTION_EXECUTE_HANDLER 1
+
+class Exception
+{
+public:
+ Exception(const char* s = "Unknown"){what = strdup(s); }
+ Exception(const Exception& e ){what = strdup(e.what); }
+ ~Exception() {free(what); }
+ const char* msg() const {return what; }
+private:
+ const char* what;
+};
+
+int main()
+{
+ float e, f, g;
+ try
+ {
+ try
+ {
+ f = 1.0;
+ g = 0.0;
+ try
+ {
+ puts("Another exception:");
+
+ e = f / g;
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER)
+ {
+ puts("Caught a C-based exception.");
+ throw(Exception("Hardware error: Divide by 0"));
+ }
+ }
+ catch(const Exception& e)
+ {
+ printf("Caught C++ Exception: %s :\n", e.msg());
+ }
+ }
+ __finally
+ {
+ puts("C++ allows __finally too!");
+ }
+ return e;
+}
diff --git a/clang/test/SemaCXX/abstract.cpp b/clang/test/SemaCXX/abstract.cpp
new file mode 100644
index 0000000..b164d9e
--- /dev/null
+++ b/clang/test/SemaCXX/abstract.cpp
@@ -0,0 +1,261 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
+#define __CONCAT(__X, __Y) __CONCAT1(__X, __Y)
+#define __CONCAT1(__X, __Y) __X ## __Y
+
+#define static_assert(__b, __m) \
+ typedef int __CONCAT(__sa, __LINE__)[__b ? 1 : -1]
+#endif
+
+class C {
+ virtual void f() = 0; // expected-note {{unimplemented pure virtual method 'f'}}
+};
+
+static_assert(__is_abstract(C), "C has a pure virtual function");
+
+class D : C {
+};
+
+static_assert(__is_abstract(D), "D inherits from an abstract class");
+
+class E : D {
+ virtual void f();
+};
+
+static_assert(!__is_abstract(E), "E inherits from an abstract class but implements f");
+
+C *d = new C; // expected-error {{allocating an object of abstract class type 'C'}}
+
+C c; // expected-error {{variable type 'C' is an abstract class}}
+void t1(C c); // expected-error {{parameter type 'C' is an abstract class}}
+void t2(C); // expected-error {{parameter type 'C' is an abstract class}}
+
+struct S {
+ C c; // expected-error {{field type 'C' is an abstract class}}
+};
+
+void t3(const C&);
+
+void f() {
+ C(); // expected-error {{allocating an object of abstract class type 'C'}}
+ t3(C()); // expected-error {{allocating an object of abstract class type 'C'}}
+}
+
+C e1[2]; // expected-error {{array of abstract class type 'C'}}
+C (*e2)[2]; // expected-error {{array of abstract class type 'C'}}
+C (**e3)[2]; // expected-error {{array of abstract class type 'C'}}
+
+void t4(C c[2]); // expected-error {{array of abstract class type 'C'}}
+
+void t5(void (*)(C)); // expected-error {{parameter type 'C' is an abstract class}}
+
+typedef void (*Func)(C); // expected-error {{parameter type 'C' is an abstract class}}
+void t6(Func);
+
+class F {
+ F a() { while (1) {} } // expected-error {{return type 'F' is an abstract class}}
+
+ class D {
+ void f(F c); // expected-error {{parameter type 'F' is an abstract class}}
+ };
+
+ union U {
+ void u(F c); // expected-error {{parameter type 'F' is an abstract class}}
+ };
+
+ virtual void f() = 0; // expected-note {{unimplemented pure virtual method 'f'}}
+};
+
+// Diagnosing in these cases is prohibitively expensive. We still
+// diagnose at the function definition, of course.
+
+class Abstract;
+
+void t7(Abstract a);
+
+void t8() {
+ void h(Abstract a);
+}
+
+namespace N {
+void h(Abstract a);
+}
+
+class Abstract {
+ virtual void f() = 0;
+};
+
+// <rdar://problem/6854087>
+class foo {
+public:
+ virtual foo *getFoo() = 0;
+};
+
+class bar : public foo {
+public:
+ virtual bar *getFoo();
+};
+
+bar x;
+
+// <rdar://problem/6902298>
+class A {
+public:
+ virtual void release() = 0;
+ virtual void release(int count) = 0;
+ virtual void retain() = 0;
+};
+
+class B : public A {
+public:
+ virtual void release();
+ virtual void release(int count);
+ virtual void retain();
+};
+
+void foo(void) {
+ B b;
+}
+
+struct K {
+ int f;
+ virtual ~K();
+};
+
+struct L : public K {
+ void f();
+};
+
+// PR5222
+namespace PR5222 {
+ struct A {
+ virtual A *clone() = 0;
+ };
+ struct B : public A {
+ virtual B *clone() = 0;
+ };
+ struct C : public B {
+ virtual C *clone();
+ };
+
+ C c;
+}
+
+// PR5550 - instantiating template didn't track overridden methods
+namespace PR5550 {
+ struct A {
+ virtual void a() = 0;
+ virtual void b() = 0;
+ };
+ template<typename T> struct B : public A {
+ virtual void b();
+ virtual void c() = 0;
+ };
+ struct C : public B<int> {
+ virtual void a();
+ virtual void c();
+ };
+ C x;
+}
+
+namespace PureImplicit {
+ // A pure virtual destructor should be implicitly overridden.
+ struct A { virtual ~A() = 0; };
+ struct B : A {};
+ B x;
+
+ // A pure virtual assignment operator should be implicitly overridden.
+ struct D;
+ struct C { virtual D& operator=(const D&) = 0; };
+ struct D : C {};
+ D y;
+}
+
+namespace test1 {
+ struct A {
+ virtual void foo() = 0;
+ };
+
+ struct B : A {
+ using A::foo;
+ };
+
+ struct C : B {
+ void foo();
+ };
+
+ void test() {
+ C c;
+ }
+}
+
+// rdar://problem/8302168
+namespace test2 {
+ struct X1 {
+ virtual void xfunc(void) = 0; // expected-note {{unimplemented pure virtual method}}
+ void g(X1 parm7); // expected-error {{parameter type 'test2::X1' is an abstract class}}
+ void g(X1 parm8[2]); // expected-error {{array of abstract class type 'test2::X1'}}
+ };
+
+ template <int N>
+ struct X2 {
+ virtual void xfunc(void) = 0; // expected-note {{unimplemented pure virtual method}}
+ void g(X2 parm10); // expected-error {{parameter type 'X2<N>' is an abstract class}}
+ void g(X2 parm11[2]); // expected-error {{array of abstract class type 'X2<N>'}}
+ };
+}
+
+namespace test3 {
+ struct A { // expected-note {{not complete until}}
+ A x; // expected-error {{field has incomplete type}}
+ virtual void abstract() = 0;
+ };
+
+ struct B { // expected-note {{not complete until}}
+ virtual void abstract() = 0;
+ B x; // expected-error {{field has incomplete type}}
+ };
+
+ struct C {
+ static C x; // expected-error {{abstract class}}
+ virtual void abstract() = 0; // expected-note {{unimplemented pure virtual method}}
+ };
+
+ struct D {
+ virtual void abstract() = 0; // expected-note {{unimplemented pure virtual method}}
+ static D x; // expected-error {{abstract class}}
+ };
+}
+
+namespace test4 {
+ template <class T> struct A {
+ A x; // expected-error {{abstract class}}
+ virtual void abstract() = 0; // expected-note {{unimplemented pure virtual method}}
+ };
+
+ template <class T> struct B {
+ virtual void abstract() = 0; // expected-note {{unimplemented pure virtual method}}
+ B x; // expected-error {{abstract class}}
+ };
+
+ template <class T> struct C {
+ static C x; // expected-error {{abstract class}}
+ virtual void abstract() = 0; // expected-note {{unimplemented pure virtual method}}
+ };
+
+ template <class T> struct D {
+ virtual void abstract() = 0; // expected-note {{unimplemented pure virtual method}}
+ static D x; // expected-error {{abstract class}}
+ };
+}
+
+// PR9247: Crash on invalid in clang::Sema::ActOnFinishCXXMemberSpecification
+namespace pr9247 {
+ struct A {
+ virtual void g(const A& input) = 0;
+ struct B {
+ C* f(int foo);
+ };
+ };
+}
diff --git a/clang/test/SemaCXX/access-base-class.cpp b/clang/test/SemaCXX/access-base-class.cpp
new file mode 100644
index 0000000..f676e19
--- /dev/null
+++ b/clang/test/SemaCXX/access-base-class.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+namespace T1 {
+
+class A { };
+class B : private A { }; // expected-note {{declared private here}}
+
+void f(B* b) {
+ A *a = b; // expected-error{{cannot cast 'T1::B' to its private base class 'T1::A'}}
+}
+
+}
+
+namespace T2 {
+
+class A { };
+class B : A { }; // expected-note {{implicitly declared private here}}
+
+void f(B* b) {
+ A *a = b; // expected-error {{cannot cast 'T2::B' to its private base class 'T2::A'}}
+}
+
+}
+
+namespace T3 {
+
+class A { };
+class B : public A { };
+
+void f(B* b) {
+ A *a = b;
+}
+
+}
+
+namespace T4 {
+
+class A {};
+
+class B : private virtual A {};
+class C : public virtual A {};
+
+class D : public B, public C {};
+
+void f(D *d) {
+ // This takes the D->C->B->A path.
+ A *a = d;
+}
+
+}
+
+namespace T5 {
+ class A {};
+
+ class B : private A {
+ void f(B *b) {
+ A *a = b;
+ }
+ };
+}
+
+namespace T6 {
+ class C;
+
+ class A {}; // expected-note{{member is declared here}}
+
+ class B : private A { // expected-note {{declared private here}} expected-note {{constrained by private inheritance here}}
+ void f(C* c);
+ };
+
+ class C : public B {
+ void f(C *c) {
+ A* a = c; // expected-error {{cannot cast 'T6::C' to its private base class 'T6::A'}} \
+ // expected-error {{'A' is a private member of 'T6::A'}}
+ }
+ };
+
+ void B::f(C *c) {
+ A *a = c;
+ }
+}
+
+namespace T7 {
+ class A {};
+ class B : public A {};
+ class C : private B {
+ void f(C *c) {
+ A* a = c; // okay
+ }
+ };
+}
+
diff --git a/clang/test/SemaCXX/access-control-check.cpp b/clang/test/SemaCXX/access-control-check.cpp
new file mode 100644
index 0000000..4540e99
--- /dev/null
+++ b/clang/test/SemaCXX/access-control-check.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class M {
+ int iM;
+};
+
+class P {
+ int iP; // expected-note {{declared private here}}
+ int PPR(); // expected-note {{declared private here}}
+};
+
+class N : M,P {
+ N() {}
+ int PR() { return iP + PPR(); } // expected-error 2 {{private member of 'P'}}
+};
diff --git a/clang/test/SemaCXX/access-member-pointer.cpp b/clang/test/SemaCXX/access-member-pointer.cpp
new file mode 100644
index 0000000..676eb10
--- /dev/null
+++ b/clang/test/SemaCXX/access-member-pointer.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR7694
+
+class A { };
+class B : private A { public: void foo(); }; // expected-note {{declared private here}}
+void B::foo() {
+ (void)static_cast<void(A::*)()>(&B::foo);
+}
+void bar() {
+ (void)static_cast<void(A::*)()>(&B::foo); // expected-error {{cannot cast 'B' to its private base class 'A'}}
+}
diff --git a/clang/test/SemaCXX/access.cpp b/clang/test/SemaCXX/access.cpp
new file mode 100644
index 0000000..18ad301
--- /dev/null
+++ b/clang/test/SemaCXX/access.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class C {
+ struct S; // expected-note {{previously declared 'private' here}}
+public:
+
+ struct S {}; // expected-error {{'S' redeclared with 'public' access}}
+};
+
+struct S {
+ class C; // expected-note {{previously declared 'public' here}}
+
+private:
+ class C { }; // expected-error {{'C' redeclared with 'private' access}}
+};
+
+class T {
+protected:
+ template<typename T> struct A; // expected-note {{previously declared 'protected' here}}
+
+private:
+ template<typename T> struct A {}; // expected-error {{'A' redeclared with 'private' access}}
+};
+
+// PR5573
+namespace test1 {
+ class A {
+ private:
+ class X; // expected-note {{previously declared 'private' here}}
+ public:
+ class X; // expected-error {{'X' redeclared with 'public' access}}
+ class X {};
+ };
+}
diff --git a/clang/test/SemaCXX/addr-of-overloaded-function-casting.cpp b/clang/test/SemaCXX/addr-of-overloaded-function-casting.cpp
new file mode 100644
index 0000000..cfd55ee
--- /dev/null
+++ b/clang/test/SemaCXX/addr-of-overloaded-function-casting.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+void g();
+
+void f(); // expected-note 9{{candidate function}}
+void f(int); // expected-note 9{{candidate function}}
+
+template<class T> void t(T); // expected-note 6{{candidate function}}
+template<class T> void t(T*); // expected-note 6{{candidate function}}
+
+template<class T> void u(T);
+
+int main()
+{
+ { bool b = (void (&)(char))f; } // expected-error{{does not match required type}}
+ { bool b = (void (*)(char))f; } // expected-error{{does not match required type}}
+
+ { bool b = (void (&)(int))f; } //ok
+ { bool b = (void (*)(int))f; } //ok
+
+ { bool b = static_cast<void (&)(char)>(f); } // expected-error{{does not match}}
+ { bool b = static_cast<void (*)(char)>(f); } // expected-error{{address of overloaded function}}
+
+ { bool b = static_cast<void (&)(int)>(f); } //ok
+ { bool b = static_cast<void (*)(int)>(f); } //ok
+
+
+ { bool b = reinterpret_cast<void (&)(char)>(f); } // expected-error{{cannot resolve}}
+ { bool b = reinterpret_cast<void (*)(char)>(f); } // expected-error{{cannot resolve}}
+
+ { bool b = reinterpret_cast<void (*)(char)>(g); } //ok
+ { bool b = static_cast<void (*)(char)>(g); } // expected-error{{not allowed}}
+
+ { bool b = reinterpret_cast<void (&)(int)>(f); } // expected-error{{cannot resolve}}
+ { bool b = reinterpret_cast<void (*)(int)>(f); } // expected-error{{cannot resolve}}
+
+ { bool b = (int (&)(char))t; } // expected-error{{does not match}}
+ { bool b = (int (*)(char))t; } // expected-error{{does not match}}
+
+ { bool b = (void (&)(int))t; } //ok
+ { bool b = (void (*)(int))t; } //ok
+
+ { bool b = static_cast<void (&)(char)>(t); } //ok
+ { bool b = static_cast<void (*)(char)>(t); } //ok
+
+ { bool b = static_cast<void (&)(int)>(t); } //ok
+ { bool b = static_cast<void (*)(int)>(t); } //ok
+
+
+ { bool b = reinterpret_cast<void (&)(char)>(t); } // expected-error{{cannot resolve}}
+ { bool b = reinterpret_cast<void (*)(char)>(t); } // expected-error{{cannot resolve}}
+
+ { bool b = reinterpret_cast<int (*)(char)>(g); } //ok
+ { bool b = static_cast<int (*)(char)>(t); } // expected-error{{cannot be static_cast}}
+ { bool b = static_cast<int (&)(char)>(t); } // expected-error{{does not match required}}
+
+ { bool b = static_cast<void (&)(char)>(f); } // expected-error{{does not match}}
+}
diff --git a/clang/test/SemaCXX/addr-of-overloaded-function.cpp b/clang/test/SemaCXX/addr-of-overloaded-function.cpp
new file mode 100644
index 0000000..096f748
--- /dev/null
+++ b/clang/test/SemaCXX/addr-of-overloaded-function.cpp
@@ -0,0 +1,210 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+int f(double); // expected-note{{candidate function}}
+int f(int); // expected-note{{candidate function}}
+
+int (*pfd)(double) = f; // selects f(double)
+int (*pfd2)(double) = &f; // selects f(double)
+int (*pfd3)(double) = ((&((f)))); // selects f(double)
+int (*pfi)(int) = &f; // selects f(int)
+// FIXME: This error message is not very good. We need to keep better
+// track of what went wrong when the implicit conversion failed to
+// give a better error message here.
+int (*pfe)(...) = &f; // expected-error{{address of overloaded function 'f' does not match required type 'int (...)'}}
+int (&rfi)(int) = f; // selects f(int)
+int (&rfd)(double) = f; // selects f(double)
+
+void g(int (*fp)(int)); // expected-note{{candidate function}}
+void g(int (*fp)(float));
+void g(int (*fp)(double)); // expected-note{{candidate function}}
+
+int g1(int);
+int g1(char);
+
+int g2(int);
+int g2(double);
+
+template<typename T> T g3(T);
+int g3(int);
+int g3(char);
+
+void g_test() {
+ g(g1);
+ g(g2); // expected-error{{call to 'g' is ambiguous}}
+ g(g3);
+}
+
+template<typename T> T h1(T);
+template<typename R, typename A1> R h1(A1);
+int h1(char);
+
+void ha(int (*fp)(int));
+void hb(int (*fp)(double));
+
+void h_test() {
+ ha(h1);
+ hb(h1);
+}
+
+struct A { };
+void f(void (*)(A *));
+
+struct B
+{
+ void g() { f(d); }
+ void d(void *);
+ static void d(A *);
+};
+
+struct C {
+ C &getC() {
+ return makeAC; // expected-error{{reference to non-static member function must be called}}
+ }
+
+ C &makeAC();
+ const C &makeAC() const;
+
+ static void f(); // expected-note{{candidate function}}
+ static void f(int); // expected-note{{candidate function}}
+
+ void g() {
+ int (&fp)() = f; // expected-error{{address of overloaded function 'f' does not match required type 'int ()'}}
+ }
+};
+
+// PR6886
+namespace test0 {
+ void myFunction(void (*)(void *));
+
+ class Foo {
+ void foo();
+
+ static void bar(void*);
+ static void bar();
+ };
+
+ void Foo::foo() {
+ myFunction(bar);
+ }
+}
+
+namespace PR7971 {
+ struct S {
+ void g() {
+ f(&g);
+ }
+ void f(bool (*)(int, char));
+ static bool g(int, char);
+ };
+}
+
+namespace PR8033 {
+ template <typename T1, typename T2> int f(T1 *, const T2 *); // expected-note {{candidate function [with T1 = const int, T2 = int]}} \
+ // expected-note{{candidate function}}
+ template <typename T1, typename T2> int f(const T1 *, T2 *); // expected-note {{candidate function [with T1 = int, T2 = const int]}} \
+ // expected-note{{candidate function}}
+ int (*p)(const int *, const int *) = f; // expected-error{{address of overloaded function 'f' is ambiguous}} \
+ // expected-error{{address of overloaded function 'f' is ambiguous}}
+
+}
+
+namespace PR8196 {
+ template <typename T> struct mcdata {
+ typedef int result_type;
+ };
+ template <class T>
+ typename mcdata<T>::result_type wrap_mean(mcdata<T> const&);
+ void add_property(double(*)(mcdata<double> const &)); // expected-note{{candidate function not viable: no overload of 'wrap_mean' matching}}
+ void f() {
+ add_property(&wrap_mean); // expected-error{{no matching function for call to 'add_property'}}
+ }
+}
+
+namespace PR7425 {
+ template<typename T>
+ void foo()
+ {
+ }
+
+ struct B
+ {
+ template<typename T>
+ B(const T&)
+ {
+ }
+ };
+
+ void bar(const B& b)
+ {
+ }
+
+ void bar2(const B& b = foo<int>)
+ {
+ }
+
+ void test(int argc, char** argv)
+ {
+ bar(foo<int>);
+ bar2();
+ }
+}
+
+namespace test1 {
+ void fun(int x) {}
+
+ void parameter_number() {
+ void (*ptr1)(int, int) = &fun; // expected-error {{cannot initialize a variable of type 'void (*)(int, int)' with an rvalue of type 'void (*)(int)': different number of parameters (2 vs 1)}}
+ void (*ptr2)(int, int);
+ ptr2 = &fun; // expected-error {{assigning to 'void (*)(int, int)' from incompatible type 'void (*)(int)': different number of parameters (2 vs 1)}}
+ }
+
+ void parameter_mismatch() {
+ void (*ptr1)(double) = &fun; // expected-error {{cannot initialize a variable of type 'void (*)(double)' with an rvalue of type 'void (*)(int)': type mismatch at 1st parameter ('double' vs 'int')}}
+ void (*ptr2)(double);
+ ptr2 = &fun; // expected-error {{assigning to 'void (*)(double)' from incompatible type 'void (*)(int)': type mismatch at 1st parameter ('double' vs 'int')}}
+ }
+
+ void return_type_test() {
+ int (*ptr1)(int) = &fun; // expected-error {{cannot initialize a variable of type 'int (*)(int)' with an rvalue of type 'void (*)(int)': different return type ('int' vs 'void')}}
+ int (*ptr2)(int);
+ ptr2 = &fun; // expected-error {{assigning to 'int (*)(int)' from incompatible type 'void (*)(int)': different return type ('int' vs 'void')}}
+ }
+
+ int foo(double x, double y) {return 0;} // expected-note {{candidate function has different number of parameters (expected 1 but has 2)}}
+ int foo(int x, int y) {return 0;} // expected-note {{candidate function has different number of parameters (expected 1 but has 2)}}
+ int foo(double x) {return 0;} // expected-note {{candidate function has type mismatch at 1st parameter (expected 'int' but has 'double')}}
+ double foo(float x, float y) {return 0;} // expected-note {{candidate function has different number of parameters (expected 1 but has 2)}}
+ double foo(int x, float y) {return 0;} // expected-note {{candidate function has different number of parameters (expected 1 but has 2)}}
+ double foo(float x) {return 0;} // expected-note {{candidate function has type mismatch at 1st parameter (expected 'int' but has 'float')}}
+ double foo(int x) {return 0;} // expected-note {{candidate function has different return type ('int' expected but has 'double')}}
+
+ int (*ptr)(int) = &foo; // expected-error {{address of overloaded function 'foo' does not match required type 'int (int)'}}
+
+ struct Qualifiers {
+ void N() {};
+ void C() const {};
+ void V() volatile {};
+ void R() __restrict {};
+ void CV() const volatile {};
+ void CR() const __restrict {};
+ void VR() volatile __restrict {};
+ void CVR() const volatile __restrict {};
+ };
+
+
+ void QualifierTest() {
+ void (Qualifiers::*X)();
+ X = &Qualifiers::C; // expected-error {{assigning to 'void (test1::Qualifiers::*)()' from incompatible type 'void (test1::Qualifiers::*)() const': different qualifiers (none vs const)}}
+ X = &Qualifiers::V; // expected-error{{assigning to 'void (test1::Qualifiers::*)()' from incompatible type 'void (test1::Qualifiers::*)() volatile': different qualifiers (none vs volatile)}}
+ X = &Qualifiers::R; // expected-error{{assigning to 'void (test1::Qualifiers::*)()' from incompatible type 'void (test1::Qualifiers::*)() restrict': different qualifiers (none vs restrict)}}
+ X = &Qualifiers::CV; // expected-error{{assigning to 'void (test1::Qualifiers::*)()' from incompatible type 'void (test1::Qualifiers::*)() const volatile': different qualifiers (none vs const and volatile)}}
+ X = &Qualifiers::CR; // expected-error{{assigning to 'void (test1::Qualifiers::*)()' from incompatible type 'void (test1::Qualifiers::*)() const restrict': different qualifiers (none vs const and restrict)}}
+ X = &Qualifiers::VR; // expected-error{{assigning to 'void (test1::Qualifiers::*)()' from incompatible type 'void (test1::Qualifiers::*)() volatile restrict': different qualifiers (none vs volatile and restrict)}}
+ X = &Qualifiers::CVR; // expected-error{{assigning to 'void (test1::Qualifiers::*)()' from incompatible type 'void (test1::Qualifiers::*)() const volatile restrict': different qualifiers (none vs const, volatile, and restrict)}}
+ }
+
+ struct Dummy {
+ void N() {};
+ };
+
+ void (Qualifiers::*X)() = &Dummy::N; // expected-error{{cannot initialize a variable of type 'void (test1::Qualifiers::*)()' with an rvalue of type 'void (test1::Dummy::*)()': different classes ('test1::Qualifiers' vs 'test1::Dummy')}}
+}
diff --git a/clang/test/SemaCXX/address-of-temporary.cpp b/clang/test/SemaCXX/address-of-temporary.cpp
new file mode 100644
index 0000000..eb5dee5
--- /dev/null
+++ b/clang/test/SemaCXX/address-of-temporary.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -Wno-error=address-of-temporary -verify %s
+struct X {
+ X();
+ X(int);
+ X(int, int);
+};
+
+void f0() { (void)&X(); } // expected-warning{{taking the address of a temporary object}}
+void f1() { (void)&X(1); } // expected-warning{{taking the address of a temporary object}}
+void f2() { (void)&X(1, 2); } // expected-warning{{taking the address of a temporary object}}
+void f3() { (void)&(X)1; } // expected-warning{{taking the address of a temporary object}}
+
diff --git a/clang/test/SemaCXX/address-of.cpp b/clang/test/SemaCXX/address-of.cpp
new file mode 100644
index 0000000..69fcaff
--- /dev/null
+++ b/clang/test/SemaCXX/address-of.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR clang/3175
+
+void bar(int*);
+
+class c {
+ int var;
+ static int svar;
+ void foo() {
+ bar(&var);
+ bar(&svar);
+ }
+
+ static void wibble() {
+ bar(&var); // expected-error{{invalid use of member 'var' in static member function}}
+ bar(&svar);
+ }
+};
+
+enum E {
+ Enumerator
+};
+
+void test() {
+ (void)&Enumerator; // expected-error{{address expression must be an lvalue or a function designator}}
+}
+
+template<int N>
+void test2() {
+ (void)&N; // expected-error{{address expression must be an lvalue or a function designator}}
+}
+
+// PR clang/3222
+void xpto();
+void (*xyz)(void) = &xpto;
+
+struct PR11066 {
+ static int foo(short);
+ static int foo(float);
+ void test();
+};
+
+void PR11066::test() {
+ int (PR11066::*ptr)(int) = & &PR11066::foo; // expected-error{{address expression must be an lvalue or a function designator}}
+}
+
diff --git a/clang/test/SemaCXX/address-space-conversion.cpp b/clang/test/SemaCXX/address-space-conversion.cpp
new file mode 100644
index 0000000..d21d419
--- /dev/null
+++ b/clang/test/SemaCXX/address-space-conversion.cpp
@@ -0,0 +1,197 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// This test checks for the various conversions and casting operations
+// with address-space-qualified pointers.
+
+struct A { virtual ~A() {} };
+struct B : A { };
+
+typedef void *void_ptr;
+typedef void __attribute__((address_space(1))) *void_ptr_1;
+typedef void __attribute__((address_space(2))) *void_ptr_2;
+
+typedef int *int_ptr;
+typedef int __attribute__((address_space(1))) *int_ptr_1;
+typedef int __attribute__((address_space(2))) *int_ptr_2;
+
+typedef A *A_ptr;
+typedef A __attribute__((address_space(1))) *A_ptr_1;
+typedef A __attribute__((address_space(2))) *A_ptr_2;
+
+typedef B *B_ptr;
+typedef B __attribute__((address_space(1))) *B_ptr_1;
+typedef B __attribute__((address_space(2))) *B_ptr_2;
+
+void test_const_cast(int_ptr ip, int_ptr_1 ip1, int_ptr_2 ip2,
+ A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
+ const int *cip,
+ const int __attribute__((address_space(1))) *cip1) {
+ // Cannot use const_cast to cast between address spaces, add an
+ // address space, or remove an address space.
+ (void)const_cast<int_ptr>(ip1); // expected-error{{is not allowed}}
+ (void)const_cast<int_ptr>(ip2); // expected-error{{is not allowed}}
+ (void)const_cast<int_ptr_1>(ip); // expected-error{{is not allowed}}
+ (void)const_cast<int_ptr_1>(ip2); // expected-error{{is not allowed}}
+ (void)const_cast<int_ptr_2>(ip); // expected-error{{is not allowed}}
+ (void)const_cast<int_ptr_2>(ip1); // expected-error{{is not allowed}}
+
+ (void)const_cast<A_ptr>(ap1); // expected-error{{is not allowed}}
+ (void)const_cast<A_ptr>(ap2); // expected-error{{is not allowed}}
+ (void)const_cast<A_ptr_1>(ap); // expected-error{{is not allowed}}
+ (void)const_cast<A_ptr_1>(ap2); // expected-error{{is not allowed}}
+ (void)const_cast<A_ptr_2>(ap); // expected-error{{is not allowed}}
+ (void)const_cast<A_ptr_2>(ap1); // expected-error{{is not allowed}}
+
+ // It's acceptable to cast away constness.
+ (void)const_cast<int_ptr>(cip);
+ (void)const_cast<int_ptr_1>(cip1);
+}
+
+void test_static_cast(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2,
+ A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
+ B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2) {
+ // Well-formed upcast
+ (void)static_cast<A_ptr>(bp);
+ (void)static_cast<A_ptr_1>(bp1);
+ (void)static_cast<A_ptr_2>(bp2);
+
+ // Well-formed downcast
+ (void)static_cast<B_ptr>(ap);
+ (void)static_cast<B_ptr_1>(ap1);
+ (void)static_cast<B_ptr_2>(ap2);
+
+ // Well-formed cast to/from void
+ (void)static_cast<void_ptr>(ap);
+ (void)static_cast<void_ptr_1>(ap1);
+ (void)static_cast<void_ptr_2>(ap2);
+ (void)static_cast<A_ptr>(vp);
+ (void)static_cast<A_ptr_1>(vp1);
+ (void)static_cast<A_ptr_2>(vp2);
+
+ // Ill-formed upcasts
+ (void)static_cast<A_ptr>(bp1); // expected-error{{is not allowed}}
+ (void)static_cast<A_ptr>(bp2); // expected-error{{is not allowed}}
+ (void)static_cast<A_ptr_1>(bp); // expected-error{{is not allowed}}
+ (void)static_cast<A_ptr_1>(bp2); // expected-error{{is not allowed}}
+ (void)static_cast<A_ptr_2>(bp); // expected-error{{is not allowed}}
+ (void)static_cast<A_ptr_2>(bp1); // expected-error{{is not allowed}}
+
+ // Ill-formed downcasts
+ (void)static_cast<B_ptr>(ap1); // expected-error{{casts away qualifiers}}
+ (void)static_cast<B_ptr>(ap2); // expected-error{{casts away qualifiers}}
+ (void)static_cast<B_ptr_1>(ap); // expected-error{{casts away qualifiers}}
+ (void)static_cast<B_ptr_1>(ap2); // expected-error{{casts away qualifiers}}
+ (void)static_cast<B_ptr_2>(ap); // expected-error{{casts away qualifiers}}
+ (void)static_cast<B_ptr_2>(ap1); // expected-error{{casts away qualifiers}}
+
+ // Ill-formed cast to/from void
+ (void)static_cast<void_ptr>(ap1); // expected-error{{is not allowed}}
+ (void)static_cast<void_ptr>(ap2); // expected-error{{is not allowed}}
+ (void)static_cast<void_ptr_1>(ap); // expected-error{{is not allowed}}
+ (void)static_cast<void_ptr_1>(ap2); // expected-error{{is not allowed}}
+ (void)static_cast<void_ptr_2>(ap); // expected-error{{is not allowed}}
+ (void)static_cast<void_ptr_2>(ap1); // expected-error{{is not allowed}}
+ (void)static_cast<A_ptr>(vp1); // expected-error{{casts away qualifiers}}
+ (void)static_cast<A_ptr>(vp2); // expected-error{{casts away qualifiers}}
+ (void)static_cast<A_ptr_1>(vp); // expected-error{{casts away qualifiers}}
+ (void)static_cast<A_ptr_1>(vp2); // expected-error{{casts away qualifiers}}
+ (void)static_cast<A_ptr_2>(vp); // expected-error{{casts away qualifiers}}
+ (void)static_cast<A_ptr_2>(vp1); // expected-error{{casts away qualifiers}}
+}
+
+void test_dynamic_cast(A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
+ B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2) {
+ // Well-formed upcast
+ (void)dynamic_cast<A_ptr>(bp);
+ (void)dynamic_cast<A_ptr_1>(bp1);
+ (void)dynamic_cast<A_ptr_2>(bp2);
+
+ // Well-formed downcast
+ (void)dynamic_cast<B_ptr>(ap);
+ (void)dynamic_cast<B_ptr_1>(ap1);
+ (void)dynamic_cast<B_ptr_2>(ap2);
+
+ // Ill-formed upcasts
+ (void)dynamic_cast<A_ptr>(bp1); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<A_ptr>(bp2); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<A_ptr_1>(bp); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<A_ptr_1>(bp2); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<A_ptr_2>(bp); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<A_ptr_2>(bp1); // expected-error{{casts away qualifiers}}
+
+ // Ill-formed downcasts
+ (void)dynamic_cast<B_ptr>(ap1); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<B_ptr>(ap2); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<B_ptr_1>(ap); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<B_ptr_1>(ap2); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<B_ptr_2>(ap); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<B_ptr_2>(ap1); // expected-error{{casts away qualifiers}}
+}
+
+void test_reinterpret_cast(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2,
+ A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
+ B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2,
+ const void __attribute__((address_space(1))) *cvp1) {
+ // reinterpret_cast can be used to cast to a different address space.
+ (void)reinterpret_cast<A_ptr>(ap1);
+ (void)reinterpret_cast<A_ptr>(ap2);
+ (void)reinterpret_cast<A_ptr>(bp);
+ (void)reinterpret_cast<A_ptr>(bp1);
+ (void)reinterpret_cast<A_ptr>(bp2);
+ (void)reinterpret_cast<A_ptr>(vp);
+ (void)reinterpret_cast<A_ptr>(vp1);
+ (void)reinterpret_cast<A_ptr>(vp2);
+ (void)reinterpret_cast<A_ptr_1>(ap);
+ (void)reinterpret_cast<A_ptr_1>(ap2);
+ (void)reinterpret_cast<A_ptr_1>(bp);
+ (void)reinterpret_cast<A_ptr_1>(bp1);
+ (void)reinterpret_cast<A_ptr_1>(bp2);
+ (void)reinterpret_cast<A_ptr_1>(vp);
+ (void)reinterpret_cast<A_ptr_1>(vp1);
+ (void)reinterpret_cast<A_ptr_1>(vp2);
+
+ // ... but don't try to cast away constness!
+ (void)reinterpret_cast<A_ptr_2>(cvp1); // expected-error{{casts away qualifiers}}
+}
+
+void test_cstyle_cast(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2,
+ A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
+ B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2,
+ const void __attribute__((address_space(1))) *cvp1) {
+ // C-style casts are the wild west of casts.
+ (void)(A_ptr)(ap1);
+ (void)(A_ptr)(ap2);
+ (void)(A_ptr)(bp);
+ (void)(A_ptr)(bp1);
+ (void)(A_ptr)(bp2);
+ (void)(A_ptr)(vp);
+ (void)(A_ptr)(vp1);
+ (void)(A_ptr)(vp2);
+ (void)(A_ptr_1)(ap);
+ (void)(A_ptr_1)(ap2);
+ (void)(A_ptr_1)(bp);
+ (void)(A_ptr_1)(bp1);
+ (void)(A_ptr_1)(bp2);
+ (void)(A_ptr_1)(vp);
+ (void)(A_ptr_1)(vp1);
+ (void)(A_ptr_1)(vp2);
+ (void)(A_ptr_2)(cvp1);
+}
+
+void test_implicit_conversion(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2,
+ A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
+ B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2) {
+ // Well-formed conversions
+ void_ptr vpA = ap;
+ void_ptr_1 vp_1A = ap1;
+ void_ptr_2 vp_2A = ap2;
+ A_ptr ap_A = bp;
+ A_ptr_1 ap_A1 = bp1;
+ A_ptr_2 ap_A2 = bp2;
+
+ // Ill-formed conversions
+ void_ptr vpB = ap1; // expected-error{{cannot initialize a variable of type}}
+ void_ptr_1 vp_1B = ap2; // expected-error{{cannot initialize a variable of type}}
+ A_ptr ap_B = bp1; // expected-error{{cannot initialize a variable of type}}
+ A_ptr_1 ap_B1 = bp2; // expected-error{{cannot initialize a variable of type}}
+}
diff --git a/clang/test/SemaCXX/address-space-newdelete.cpp b/clang/test/SemaCXX/address-space-newdelete.cpp
new file mode 100644
index 0000000..b809cd3
--- /dev/null
+++ b/clang/test/SemaCXX/address-space-newdelete.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void* operator new (__SIZE_TYPE__ size, void* ptr);
+void* operator new[](__SIZE_TYPE__ size, void* ptr);
+
+typedef int __attribute__((address_space(1))) int_1;
+
+void test_new(void *p) {
+ (void)new int_1; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+ (void)new __attribute__((address_space(1))) int; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+ (void)new int_1 [5]; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+ (void)new __attribute__((address_space(1))) int [5]; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+
+ // Placement new
+ (void)new (p) int_1; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+ (void)new (p) __attribute__((address_space(1))) int; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+ (void)new (p) int_1 [5]; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+ (void)new (p) __attribute__((address_space(1))) int [5]; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+}
+
+void test_delete(int_1 *ip1) {
+ delete ip1; // expected-error{{'delete' cannot delete objects of type 'int' in address space '1'}}
+ delete [] ip1; // expected-error{{'delete' cannot delete objects of type 'int' in address space '1'}}
+}
diff --git a/clang/test/SemaCXX/address-space-references.cpp b/clang/test/SemaCXX/address-space-references.cpp
new file mode 100644
index 0000000..f5a63d2
--- /dev/null
+++ b/clang/test/SemaCXX/address-space-references.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int __attribute__((address_space(1))) int_1;
+typedef int __attribute__((address_space(2))) int_2;
+
+void f0(int_1 &); // expected-note{{candidate function not viable: 1st argument ('int') is in address space 0, but parameter must be in address space 1}} \
+// expected-note{{candidate function not viable: 1st argument ('int_2' (aka '__attribute__((address_space(2))) int')) is in address space 2, but parameter must be in address space 1}}
+void f0(const int_1 &); // expected-note{{candidate function not viable: 1st argument ('int') is in address space 0, but parameter must be in address space 1}} \
+// expected-note{{candidate function not viable: 1st argument ('int_2' (aka '__attribute__((address_space(2))) int')) is in address space 2, but parameter must be in address space 1}}
+
+void test_f0() {
+ int i;
+ static int_1 i1;
+ static int_2 i2;
+
+ f0(i); // expected-error{{no matching function for call to 'f0'}}
+ f0(i1);
+ f0(i2); // expected-error{{no matching function for call to 'f0'}}
+}
diff --git a/clang/test/SemaCXX/aggregate-initialization.cpp b/clang/test/SemaCXX/aggregate-initialization.cpp
new file mode 100644
index 0000000..885bf70
--- /dev/null
+++ b/clang/test/SemaCXX/aggregate-initialization.cpp
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// Verify that using an initializer list for a non-aggregate looks for
+// constructors..
+// Note that due to a (likely) standard bug, this is technically an aggregate,
+// but we do not treat it as one.
+struct NonAggr1 { // expected-note 2 {{candidate constructor}}
+ NonAggr1(int, int) { } // expected-note {{candidate constructor}}
+
+ int m;
+};
+
+struct Base { };
+struct NonAggr2 : public Base { // expected-note 3 {{candidate constructor}}
+ int m;
+};
+
+class NonAggr3 { // expected-note 3 {{candidate constructor}}
+ int m;
+};
+
+struct NonAggr4 { // expected-note 3 {{candidate constructor}}
+ int m;
+ virtual void f();
+};
+
+NonAggr1 na1 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr1'}}
+NonAggr2 na2 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr2'}}
+NonAggr3 na3 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr3'}}
+NonAggr4 na4 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr4'}}
+
+// PR5817
+typedef int type[][2];
+const type foo = {0};
+
+// Vector initialization.
+typedef short __v4hi __attribute__ ((__vector_size__ (8)));
+__v4hi v1 = { (void *)1, 2, 3 }; // expected-error {{cannot initialize a vector element of type 'short' with an rvalue of type 'void *'}}
+
+// Array initialization.
+int a[] = { (void *)1 }; // expected-error {{cannot initialize an array element of type 'int' with an rvalue of type 'void *'}}
+
+// Struct initialization.
+struct S { int a; } s = { (void *)1 }; // expected-error {{cannot initialize a member subobject of type 'int' with an rvalue of type 'void *'}}
+
+// Check that we're copy-initializing the structs.
+struct A {
+ A();
+ A(int);
+ ~A();
+
+ A(const A&) = delete; // expected-note 2 {{function has been explicitly marked deleted here}}
+};
+
+struct B {
+ A a;
+};
+
+struct C {
+ const A& a;
+};
+
+void f() {
+ A as1[1] = { };
+ A as2[1] = { 1 }; // expected-error {{copying array element of type 'A' invokes deleted constructor}}
+
+ B b1 = { };
+ B b2 = { 1 }; // expected-error {{copying member subobject of type 'A' invokes deleted constructor}}
+
+ C c1 = { 1 };
+}
+
+class Agg {
+public:
+ int i, j;
+};
+
+class AggAgg {
+public:
+ Agg agg1;
+ Agg agg2;
+};
+
+AggAgg aggagg = { 1, 2, 3, 4 };
diff --git a/clang/test/SemaCXX/alias-template.cpp b/clang/test/SemaCXX/alias-template.cpp
new file mode 100644
index 0000000..484dd33
--- /dev/null
+++ b/clang/test/SemaCXX/alias-template.cpp
@@ -0,0 +1,147 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+namespace RedeclAliasTypedef {
+ template<typename U> using T = int;
+ template<typename U> using T = int;
+ template<typename U> using T = T<U>;
+}
+
+namespace IllegalTypeIds {
+ template<typename U> using A = void(int n = 0); // expected-error {{default arguments can only be specified for parameters in a function declaration}}
+ template<typename U> using B = inline void(int n); // expected-error {{type name does not allow function specifier}}
+ template<typename U> using C = virtual void(int n); // expected-error {{type name does not allow function specifier}}
+ template<typename U> using D = explicit void(int n); // expected-error {{type name does not allow function specifier}}
+ template<typename U> using E = void(int n) throw(); // expected-error {{exception specifications are not allowed in type aliases}}
+ template<typename U> using F = void(*)(int n) &&; // expected-error {{pointer to function type cannot have '&&' qualifier}}
+ template<typename U> using G = __thread void(int n); // expected-error {{type name does not allow storage class to be specified}}
+ template<typename U> using H = constexpr int; // expected-error {{type name does not allow constexpr specifier}}
+
+ template<typename U> using Y = void(int n); // ok
+ template<typename U> using Z = void(int n) &&; // ok
+}
+
+namespace IllegalSyntax {
+ template<typename Z> using ::T = void(int n); // expected-error {{name defined in alias declaration must be an identifier}}
+ template<typename Z> using operator int = void(int n); // expected-error {{name defined in alias declaration must be an identifier}}
+ template<typename Z> using typename U = void; // expected-error {{name defined in alias declaration must be an identifier}}
+ template<typename Z> using typename ::V = void(int n); // expected-error {{name defined in alias declaration must be an identifier}}
+ template<typename Z> using typename ::operator bool = void(int n); // expected-error {{name defined in alias declaration must be an identifier}}
+}
+
+namespace VariableLengthArrays {
+ template<typename Z> using T = int[42]; // ok
+
+ int n = 32;
+ template<typename Z> using T = int[n]; // expected-error {{variable length array declaration not allowed at file scope}}
+
+ const int m = 42;
+ template<typename Z> using U = int[m]; // expected-note {{previous definition}}
+ template<typename Z> using U = int[42]; // ok
+ template<typename Z> using U = int; // expected-error {{type alias template redefinition with different types ('int' vs 'int [42]')}}
+}
+
+namespace RedeclFunc {
+ int f(int, char**);
+ template<typename Z> using T = int;
+ T<char> f(int, char **); // ok
+}
+
+namespace LookupFilter {
+ namespace N { template<typename U> using S = int; }
+ using namespace N;
+ template<typename U> using S = S<U>*; // ok
+}
+
+namespace InFunctions {
+ template<typename...T> struct S0 {
+ template<typename Z> using U = T*; // expected-error {{declaration type contains unexpanded parameter pack 'T'}}
+ U<char> u;
+ };
+
+ template<typename Z> using T1 = int;
+ template<typename Z> using T2 = int[-1]; // expected-error {{array size is negative}}
+ template<typename...T> struct S3 { // expected-note {{template parameter is declared here}}
+ template<typename Z> using T = int; // expected-error {{declaration of 'T' shadows template parameter}}
+ };
+ template<typename Z> using Z = Z;
+}
+
+namespace ClassNameRedecl {
+ class C0 {
+ // FIXME: this diagnostic is pretty poor
+ template<typename U> using C0 = int; // expected-error {{name defined in alias declaration must be an identifier}}
+ };
+ class C1 {
+ // FIXME: this diagnostic is pretty poor
+ template<typename U> using C1 = C1; // expected-error {{name defined in alias declaration must be an identifier}}
+ };
+ class C2 {
+ template<typename U> using C0 = C1; // ok
+ };
+ template<typename...T> class C3 {
+ template<typename U> using f = T; // expected-error {{declaration type contains unexpanded parameter pack 'T'}}
+ };
+ template<typename T> class C4 { // expected-note {{template parameter is declared here}}
+ template<typename U> using T = int; // expected-error {{declaration of 'T' shadows template parameter}}
+ };
+ class C5 {
+ class c; // expected-note {{previous definition}}
+ template<typename U> using c = int; // expected-error {{redefinition of 'c' as different kind of symbol}}
+ class d; // expected-note {{previous definition}}
+ template<typename U> using d = d; // expected-error {{redefinition of 'd' as different kind of symbol}}
+ };
+ class C6 {
+ class c { template<typename U> using C6 = int; }; // ok
+ };
+}
+
+class CtorDtorName {
+ template<typename T> using X = CtorDtorName;
+ X<int>(); // expected-error {{expected member name}}
+ ~X<int>(); // expected-error {{destructor cannot be declared using a type alias}}
+};
+
+namespace TagName {
+ template<typename Z> using S = struct { int n; }; // expected-error {{can not be defined}}
+ template<typename Z> using T = class { int n; }; // expected-error {{can not be defined}}
+ template<typename Z> using U = enum { a, b, c }; // expected-error {{can not be defined}}
+ template<typename Z> using V = struct V { int n; }; // expected-error {{redefinition of 'V' as different kind of symbol}} \
+ expected-error {{'TagName::V' can not be defined in a type alias template}} \
+ expected-note {{previous definition is here}}
+}
+
+namespace StdExample {
+ template<typename T, typename U> struct pair;
+
+ template<typename T> using handler_t = void (*)(T);
+ extern handler_t<int> ignore;
+ extern void (*ignore)(int);
+ // FIXME: we recover as if cell is an undeclared variable. the diagnostics are terrible!
+ template<typename T> using cell = pair<T*, cell<T>*>; // expected-error {{use of undeclared identifier 'cell'}} \
+ expected-error {{'T' does not refer to a value}} \
+ expected-note {{declared here}} \
+ expected-error {{expected ';' after alias declaration}}
+}
+
+namespace Access {
+ class C0 {
+ template<typename Z> using U = int; // expected-note {{declared private here}}
+ };
+ C0::U<int> v; // expected-error {{'U' is a private member}}
+ class C1 {
+ public:
+ template<typename Z> using U = int;
+ };
+ C1::U<int> w; // ok
+}
+
+namespace VoidArg {
+ template<typename Z> using V = void;
+ V<int> f(int); // ok
+ V<char> g(V<double>); // expected-error {{empty parameter list defined with a type alias of 'void' not allowed}}
+}
+
+namespace Curried {
+ template<typename T, typename U> struct S;
+ template<typename T> template<typename U> using SS = S<T, U>; // expected-error {{extraneous template parameter list in alias template declaration}}
+}
diff --git a/clang/test/SemaCXX/alignof-sizeof-reference.cpp b/clang/test/SemaCXX/alignof-sizeof-reference.cpp
new file mode 100644
index 0000000..ccdf45e
--- /dev/null
+++ b/clang/test/SemaCXX/alignof-sizeof-reference.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct s0; // expected-note {{forward declaration}}
+char ar[sizeof(s0&)]; // expected-error {{invalid application of 'sizeof' to an incomplete type}}
+void test() {
+ char &r = ar[0];
+ static_assert(alignof(r) == 1, "bad alignment");
+ static_assert(sizeof(r) == 1, "bad size");
+}
+
+void f(); // expected-note{{possible target for call}}
+void f(int); // expected-note{{possible target for call}}
+void g() {
+ sizeof(&f); // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} \
+ // expected-warning{{expression result unused}}
+}
+
+template<typename T> void f_template(); // expected-note{{possible target for call}}
+template<typename T> void f_template(T*); // expected-note{{possible target for call}}
+void rdar9659191() {
+ (void)alignof(f_template<int>); // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
+}
diff --git a/clang/test/SemaCXX/altivec.cpp b/clang/test/SemaCXX/altivec.cpp
new file mode 100644
index 0000000..39421b7
--- /dev/null
+++ b/clang/test/SemaCXX/altivec.cpp
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -faltivec -fno-lax-vector-conversions -triple powerpc-unknown-unknown -verify %s
+
+typedef int V4i __attribute__((vector_size(16)));
+
+void test_vec_step(vector short arg1) {
+ vector bool char vbc;
+ vector signed char vsc;
+ vector unsigned char vuc;
+ vector bool short vbs;
+ vector short vs;
+ vector unsigned short vus;
+ vector pixel vp;
+ vector bool int vbi;
+ vector int vi;
+ vector unsigned int vui;
+ vector float vf;
+
+ vector int *pvi;
+
+ int res1[vec_step(arg1) == 8 ? 1 : -1];
+ int res2[vec_step(vbc) == 16 ? 1 : -1];
+ int res3[vec_step(vsc) == 16 ? 1 : -1];
+ int res4[vec_step(vuc) == 16 ? 1 : -1];
+ int res5[vec_step(vbs) == 8 ? 1 : -1];
+ int res6[vec_step(vs) == 8 ? 1 : -1];
+ int res7[vec_step(vus) == 8 ? 1 : -1];
+ int res8[vec_step(vp) == 8 ? 1 : -1];
+ int res9[vec_step(vbi) == 4 ? 1 : -1];
+ int res10[vec_step(vi) == 4 ? 1 : -1];
+ int res11[vec_step(vui) == 4 ? 1 : -1];
+ int res12[vec_step(vf) == 4 ? 1 : -1];
+ int res13[vec_step(*pvi) == 4 ? 1 : -1];
+}
+
+void f(V4i a)
+{
+}
+
+void test1()
+{
+ V4i vGCC;
+ vector int vAltiVec;
+
+ f(vAltiVec);
+ vGCC = vAltiVec;
+ bool res = vGCC > vAltiVec;
+ vAltiVec = 0 ? vGCC : vGCC;
+}
+
+template<typename T>
+void template_f(T param) {
+ param++;
+}
+
+void test2()
+{
+ vector int vi;
+ ++vi;
+ vi++;
+ --vi;
+ vi--;
+ vector float vf;
+ vf++;
+
+ ++vi=vi;
+ (++vi)[1]=1;
+ template_f(vi);
+}
+
+namespace LValueToRValueConversions {
+ struct Struct {
+ float f();
+ int n();
+ };
+
+ vector float initFloat = (vector float)(Struct().f); // expected-error {{did you mean to call it}}
+ vector int initInt = (vector int)(Struct().n); // expected-error {{did you mean to call it}}
+}
diff --git a/clang/test/SemaCXX/ambig-user-defined-conversions.cpp b/clang/test/SemaCXX/ambig-user-defined-conversions.cpp
new file mode 100644
index 0000000..1a3c102
--- /dev/null
+++ b/clang/test/SemaCXX/ambig-user-defined-conversions.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace test0 {
+ struct BASE {
+ operator int &(); // expected-note {{candidate function}}
+ };
+ struct BASE1 {
+ operator int &(); // expected-note {{candidate function}}
+ };
+
+ struct B : public BASE, BASE1 {};
+
+ extern B f();
+ B b1;
+
+ void func(const int ci, const char cc); // expected-note {{candidate function}}
+ void func(const char ci, const B b); // expected-note {{candidate function}}
+ void func(const B b, const int ci); // expected-note {{candidate function}}
+
+ const int Test1() {
+
+ func(b1, f()); // expected-error {{call to 'func' is ambiguous}}
+ return f(); // expected-error {{conversion from 'test0::B' to 'const int' is ambiguous}}
+ }
+
+ // This used to crash when comparing the two operands.
+ void func2(const char cc); // expected-note {{candidate function}}
+ void func2(const int ci); // expected-note {{candidate function}}
+ void Test2() {
+ func2(b1); // expected-error {{call to 'func2' is ambiguous}}
+ }
+}
+
+namespace test1 {
+ struct E;
+ struct A {
+ A (E&);
+ };
+
+ struct E {
+ operator A ();
+ };
+
+ struct C {
+ C (E&);
+ };
+
+ void f1(A); // expected-note {{candidate function}}
+ void f1(C); // expected-note {{candidate function}}
+
+ void Test2()
+ {
+ E b;
+ f1(b); // expected-error {{call to 'f1' is ambiguous}}
+ // ambiguous because b -> C via constructor and
+ // b -> A via constructor or conversion function.
+ }
+}
+
+namespace rdar8876150 {
+ struct A { operator bool(); };
+ struct B : A { };
+ struct C : A { };
+ struct D : B, C { };
+
+ bool f(D d) { return !d; } // expected-error{{ambiguous conversion from derived class 'rdar8876150::D' to base class 'rdar8876150::A':}}
+}
diff --git a/clang/test/SemaCXX/ambiguous-builtin-unary-operator.cpp b/clang/test/SemaCXX/ambiguous-builtin-unary-operator.cpp
new file mode 100644
index 0000000..6e96e03
--- /dev/null
+++ b/clang/test/SemaCXX/ambiguous-builtin-unary-operator.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+struct A {
+ operator int&();
+ operator long*& ();
+};
+
+struct B {
+ operator long&();
+ operator int*& ();
+};
+
+struct C : B, A { };
+
+void test(C c) {
+ ++c; // expected-error {{use of overloaded operator '++' is ambiguous}}\
+ // expected-note {{built-in candidate operator++(int &)}} \
+ // expected-note {{built-in candidate operator++(long &)}} \
+ // expected-note {{built-in candidate operator++(long *&)}} \
+ // expected-note {{built-in candidate operator++(int *&)}}
+}
+
+struct A1 { operator volatile int&(); };
+
+struct B1 { operator volatile long&(); };
+
+struct C1 : B1, A1 { };
+
+void test(C1 c) {
+ ++c; // expected-error {{use of overloaded operator '++' is ambiguous}} \
+ // expected-note {{built-in candidate operator++(volatile int &)}} \
+ // expected-note {{built-in candidate operator++(volatile long &)}}
+}
+
diff --git a/clang/test/SemaCXX/anonymous-struct.cpp b/clang/test/SemaCXX/anonymous-struct.cpp
new file mode 100644
index 0000000..19a88d7
--- /dev/null
+++ b/clang/test/SemaCXX/anonymous-struct.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct S {
+ S(); // expected-note {{because type 'S' has a user-declared constructor}}
+};
+
+struct { // expected-error {{anonymous structs and classes must be class members}}
+};
+
+struct E {
+ struct {
+ S x; // expected-error {{anonymous struct member 'x' has a non-trivial constructor}}
+ };
+ static struct {
+ };
+};
diff --git a/clang/test/SemaCXX/anonymous-union.cpp b/clang/test/SemaCXX/anonymous-union.cpp
new file mode 100644
index 0000000..2dd7ab8
--- /dev/null
+++ b/clang/test/SemaCXX/anonymous-union.cpp
@@ -0,0 +1,199 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+struct X {
+ union {
+ float f3;
+ double d2;
+ } named;
+
+ union {
+ int i;
+ float f;
+
+ union {
+ float f2;
+ mutable double d;
+ };
+ };
+
+ void test_unqual_references();
+
+ struct { // expected-warning{{anonymous structs are a GNU extension}}
+ int a;
+ float b;
+ };
+
+ void test_unqual_references_const() const;
+
+ mutable union { // expected-error{{anonymous union at class scope must not have a storage specifier}}
+ float c1;
+ double c2;
+ };
+};
+
+void X::test_unqual_references() {
+ i = 0;
+ f = 0.0;
+ f2 = f;
+ d = f;
+ f3 = 0; // expected-error{{use of undeclared identifier 'f3'}}
+ a = 0;
+}
+
+void X::test_unqual_references_const() const {
+ d = 0.0;
+ f2 = 0; // expected-error{{read-only variable is not assignable}}
+ a = 0; // expected-error{{read-only variable is not assignable}}
+}
+
+void test_unqual_references(X x, const X xc) {
+ x.i = 0;
+ x.f = 0.0;
+ x.f2 = x.f;
+ x.d = x.f;
+ x.f3 = 0; // expected-error{{no member named 'f3'}}
+ x.a = 0;
+
+ xc.d = 0.0;
+ xc.f = 0; // expected-error{{read-only variable is not assignable}}
+ xc.a = 0; // expected-error{{read-only variable is not assignable}}
+}
+
+
+struct Redecl {
+ int x; // expected-note{{previous declaration is here}}
+ class y { };
+
+ union {
+ int x; // expected-error{{member of anonymous union redeclares 'x'}}
+ float y;
+ double z; // expected-note{{previous declaration is here}}
+ double zz; // expected-note{{previous definition is here}}
+ };
+
+ int z; // expected-error{{duplicate member 'z'}}
+ void zz(); // expected-error{{redefinition of 'zz' as different kind of symbol}}
+};
+
+union { // expected-error{{anonymous unions at namespace or global scope must be declared 'static'}}
+ int int_val;
+ float float_val;
+};
+
+static union {
+ int int_val2;
+ float float_val2;
+};
+
+void f() {
+ int_val2 = 0;
+ float_val2 = 0.0;
+}
+
+void g() {
+ union {
+ int i;
+ float f2;
+ };
+ i = 0;
+ f2 = 0.0;
+}
+
+struct BadMembers {
+ union {
+ struct X { }; // expected-error {{types cannot be declared in an anonymous union}}
+ struct { int x; int y; } y;
+
+ void f(); // expected-error{{functions cannot be declared in an anonymous union}}
+ private: int x1; // expected-error{{anonymous union cannot contain a private data member}}
+ protected: float x2; // expected-error{{anonymous union cannot contain a protected data member}}
+ };
+};
+
+// <rdar://problem/6481130>
+typedef union { }; // expected-warning{{declaration does not declare anything}}
+
+// <rdar://problem/7562438>
+typedef struct objc_module *Foo ;
+
+typedef struct _s {
+ union {
+ int a;
+ int Foo;
+ };
+} s, *ps;
+
+// <rdar://problem/7987650>
+namespace test4 {
+ class A {
+ struct { // expected-warning{{anonymous structs are a GNU extension}}
+ int s0; // expected-note {{declared private here}}
+ double s1; // expected-note {{declared private here}}
+ union {
+ int su0; // expected-note {{declared private here}}
+ double su1; // expected-note {{declared private here}}
+ };
+ };
+ union {
+ int u0; // expected-note {{declared private here}}
+ double u1; // expected-note {{declared private here}}
+ struct { // expected-warning{{anonymous structs are a GNU extension}}
+ int us0; // expected-note {{declared private here}}
+ double us1; // expected-note {{declared private here}}
+ };
+ };
+ };
+
+ void test() {
+ A a;
+ (void) a.s0; // expected-error {{private member}}
+ (void) a.s1; // expected-error {{private member}}
+ (void) a.su0; // expected-error {{private member}}
+ (void) a.su1; // expected-error {{private member}}
+ (void) a.u0; // expected-error {{private member}}
+ (void) a.u1; // expected-error {{private member}}
+ (void) a.us0; // expected-error {{private member}}
+ (void) a.us1; // expected-error {{private member}}
+ }
+}
+
+typedef void *voidPtr;
+
+void f2() {
+ union { int **ctxPtr; void **voidPtr; };
+}
+
+void foo_PR6741() {
+ union {
+ char *m_a;
+ int *m_b;
+ };
+
+ if(1) {
+ union {
+ char *m_a;
+ int *m_b;
+ };
+ }
+}
+
+namespace PR8326 {
+ template <class T>
+ class Foo {
+ public:
+ Foo()
+ : x(0)
+ , y(1){
+ }
+
+ private:
+ const union { // expected-warning{{anonymous union cannot be 'const'}}
+ struct { // expected-warning{{anonymous structs are a GNU extension}}
+ T x;
+ T y;
+ };
+ T v[2];
+ };
+ };
+
+ Foo<int> baz;
+}
diff --git a/clang/test/SemaCXX/array-bound-merge.cpp b/clang/test/SemaCXX/array-bound-merge.cpp
new file mode 100644
index 0000000..74f58fa
--- /dev/null
+++ b/clang/test/SemaCXX/array-bound-merge.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR5515
+
+extern int a[];
+int a[10];
+extern int b[10];
+int b[];
+extern int c[1];
+int c[] = {1,2}; // expected-error {{excess elements in array initializer}}
diff --git a/clang/test/SemaCXX/array-bounds-ptr-arith.cpp b/clang/test/SemaCXX/array-bounds-ptr-arith.cpp
new file mode 100644
index 0000000..16e2567
--- /dev/null
+++ b/clang/test/SemaCXX/array-bounds-ptr-arith.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -verify -Wno-string-plus-int -Warray-bounds-pointer-arithmetic %s
+
+void swallow (const char *x) { (void)x; }
+void test_pointer_arithmetic(int n) {
+ const char hello[] = "Hello world!"; // expected-note 2 {{declared here}}
+ const char *helloptr = hello;
+
+ swallow("Hello world!" + 6); // no-warning
+ swallow("Hello world!" - 6); // expected-warning {{refers before the beginning of the array}}
+ swallow("Hello world!" + 14); // expected-warning {{refers past the end of the array}}
+ swallow("Hello world!" + 13); // no-warning
+
+ swallow(hello + 6); // no-warning
+ swallow(hello - 6); // expected-warning {{refers before the beginning of the array}}
+ swallow(hello + 14); // expected-warning {{refers past the end of the array}}
+ swallow(hello + 13); // no-warning
+
+ swallow(helloptr + 6); // no-warning
+ swallow(helloptr - 6); // no-warning
+ swallow(helloptr + 14); // no-warning
+ swallow(helloptr + 13); // no-warning
+
+ double numbers[2]; // expected-note {{declared here}}
+ swallow((char*)numbers + sizeof(double)); // no-warning
+ swallow((char*)numbers + 60); // expected-warning {{refers past the end of the array}}
+
+ char buffer[5]; // expected-note 2 {{declared here}}
+ // TODO: Add FixIt notes for adding parens around non-ptr part of arith expr
+ swallow(buffer + sizeof("Hello")-1); // expected-warning {{refers past the end of the array}}
+ swallow(buffer + (sizeof("Hello")-1)); // no-warning
+ if (n > 0 && n <= 6) swallow(buffer + 6 - n); // expected-warning {{refers past the end of the array}}
+ if (n > 0 && n <= 6) swallow(buffer + (6 - n)); // no-warning
+}
diff --git a/clang/test/SemaCXX/array-bounds-system-header.cpp b/clang/test/SemaCXX/array-bounds-system-header.cpp
new file mode 100644
index 0000000..34de5b5
--- /dev/null
+++ b/clang/test/SemaCXX/array-bounds-system-header.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -isystem %S/Inputs -verify %s
+#include <array-bounds-system-header.h>
+void test_system_header_macro() {
+ BAD_MACRO_1; // no-warning
+ char a[3]; // expected-note 2 {{declared here}}
+ BAD_MACRO_2(a, 3); // expected-warning {{array index 3}}
+ QUESTIONABLE_MACRO(a);
+ NOP(a[3] = 5); // expected-warning {{array index 3}}
+}
diff --git a/clang/test/SemaCXX/array-bounds.cpp b/clang/test/SemaCXX/array-bounds.cpp
new file mode 100644
index 0000000..57a9e3d
--- /dev/null
+++ b/clang/test/SemaCXX/array-bounds.cpp
@@ -0,0 +1,255 @@
+// RUN: %clang_cc1 -verify %s
+
+int foo() {
+ int x[2]; // expected-note 4 {{array 'x' declared here}}
+ int y[2]; // expected-note 2 {{array 'y' declared here}}
+ int z[1]; // expected-note {{array 'z' declared here}}
+ int w[1][1]; // expected-note {{array 'w' declared here}}
+ int v[1][1][1]; // expected-note {{array 'v' declared here}}
+ int *p = &y[2]; // no-warning
+ (void) sizeof(x[2]); // no-warning
+ y[2] = 2; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+ z[1] = 'x'; // expected-warning {{array index 1 is past the end of the array (which contains 1 element)}}
+ w[0][2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}}
+ v[0][0][2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}}
+ return x[2] + // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+ y[-1] + // expected-warning {{array index -1 is before the beginning of the array}}
+ x[sizeof(x)] + // expected-warning {{array index 8 is past the end of the array (which contains 2 elements)}}
+ x[sizeof(x) / sizeof(x[0])] + // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+ x[sizeof(x) / sizeof(x[0]) - 1] + // no-warning
+ x[sizeof(x[2])]; // expected-warning {{array index 4 is past the end of the array (which contains 2 elements)}}
+}
+
+// This code example tests that -Warray-bounds works with arrays that
+// are template parameters.
+template <char *sz> class Qux {
+ bool test() { return sz[0] == 'a'; }
+};
+
+void f1(int a[1]) {
+ int val = a[3]; // no warning for function argumnet
+}
+
+void f2(const int (&a)[2]) { // expected-note {{declared here}}
+ int val = a[3]; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
+}
+
+void test() {
+ struct {
+ int a[0];
+ } s2;
+ s2.a[3] = 0; // no warning for 0-sized array
+
+ union {
+ short a[2]; // expected-note 4 {{declared here}}
+ char c[4];
+ } u;
+ u.a[3] = 1; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
+ u.c[3] = 1; // no warning
+ short *p = &u.a[2]; // no warning
+ p = &u.a[3]; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
+ *(&u.a[2]) = 1; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+ *(&u.a[3]) = 1; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
+ *(&u.c[3]) = 1; // no warning
+
+ const int const_subscript = 3;
+ int array[2]; // expected-note {{declared here}}
+ array[const_subscript] = 0; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
+
+ int *ptr;
+ ptr[3] = 0; // no warning for pointer references
+ int array2[] = { 0, 1, 2 }; // expected-note 2 {{declared here}}
+
+ array2[3] = 0; // expected-warning {{array index 3 is past the end of the array (which contains 3 elements)}}
+ array2[2+2] = 0; // expected-warning {{array index 4 is past the end of the array (which contains 3 elements)}}
+
+ const char *str1 = "foo";
+ char c1 = str1[5]; // no warning for pointers
+
+ const char str2[] = "foo"; // expected-note {{declared here}}
+ char c2 = str2[5]; // expected-warning {{array index 5 is past the end of the array (which contains 4 elements)}}
+
+ int (*array_ptr)[2];
+ (*array_ptr)[3] = 1; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
+}
+
+template <int I> struct S {
+ char arr[I]; // expected-note 2 {{declared here}}
+};
+template <int I> void f() {
+ S<3> s;
+ s.arr[4] = 0; // expected-warning {{array index 4 is past the end of the array (which contains 3 elements)}}
+ s.arr[I] = 0; // expected-warning {{array index 5 is past the end of the array (which contains 3 elements)}}
+}
+
+void test_templates() {
+ f<5>(); // expected-note {{in instantiation}}
+}
+
+#define SIZE 10
+#define ARR_IN_MACRO(flag, arr, idx) flag ? arr[idx] : 1
+
+int test_no_warn_macro_unreachable() {
+ int arr[SIZE]; // expected-note {{array 'arr' declared here}}
+ return ARR_IN_MACRO(0, arr, SIZE) + // no-warning
+ ARR_IN_MACRO(1, arr, SIZE); // expected-warning{{array index 10 is past the end of the array (which contains 10 elements)}}
+}
+
+// This exhibited an assertion failure for a 32-bit build of Clang.
+int test_pr9240() {
+ short array[100]; // expected-note {{array 'array' declared here}}
+ return array[(unsigned long long) 100]; // expected-warning {{array index 100 is past the end of the array (which contains 100 elements)}}
+}
+
+// PR 9284 - a template parameter can cause an array bounds access to be
+// infeasible.
+template <bool extendArray>
+void pr9284() {
+ int arr[3 + (extendArray ? 1 : 0)];
+
+ if (extendArray)
+ arr[3] = 42; // no-warning
+}
+
+template <bool extendArray>
+void pr9284b() {
+ int arr[3 + (extendArray ? 1 : 0)]; // expected-note {{array 'arr' declared here}}
+
+ if (!extendArray)
+ arr[3] = 42; // expected-warning{{array index 3 is past the end of the array (which contains 3 elements)}}
+}
+
+void test_pr9284() {
+ pr9284<true>();
+ pr9284<false>();
+ pr9284b<true>();
+ pr9284b<false>(); // expected-note{{in instantiation of function template specialization 'pr9284b<false>' requested here}}
+}
+
+int test_pr9296() {
+ int array[2];
+ return array[true]; // no-warning
+}
+
+int test_sizeof_as_condition(int flag) {
+ int arr[2] = { 0, 0 }; // expected-note {{array 'arr' declared here}}
+ if (flag)
+ return sizeof(char) != sizeof(char) ? arr[2] : arr[1];
+ return sizeof(char) == sizeof(char) ? arr[2] : arr[1]; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+}
+
+void test_switch() {
+ switch (4) {
+ case 1: {
+ int arr[2];
+ arr[2] = 1; // no-warning
+ break;
+ }
+ case 4: {
+ int arr[2]; // expected-note {{array 'arr' declared here}}
+ arr[2] = 1; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+ break;
+ }
+ default: {
+ int arr[2];
+ arr[2] = 1; // no-warning
+ break;
+ }
+ }
+}
+
+// Test nested switch statements.
+enum enumA { enumA_A, enumA_B, enumA_C, enumA_D, enumA_E };
+enum enumB { enumB_X, enumB_Y, enumB_Z };
+static enum enumB myVal = enumB_X;
+void test_nested_switch() {
+ switch (enumA_E) { // expected-warning {{no case matching constant}}
+ switch (myVal) { // expected-warning {{enumeration values 'enumB_X' and 'enumB_Z' not handled in switch}}
+ case enumB_Y: ;
+ }
+ }
+}
+
+// Test that if all the values of an enum covered, that the 'default' branch
+// is unreachable.
+enum Values { A, B, C, D };
+void test_all_enums_covered(enum Values v) {
+ int x[2];
+ switch (v) {
+ case A: return;
+ case B: return;
+ case C: return;
+ case D: return;
+ }
+ x[2] = 0; // no-warning
+}
+
+namespace tailpad {
+ struct foo {
+ char c1[1]; // expected-note {{declared here}}
+ int x;
+ char c2[1];
+ };
+
+ class baz {
+ public:
+ char c1[1]; // expected-note {{declared here}}
+ int x;
+ char c2[1];
+ };
+
+ char bar(struct foo *F, baz *B) {
+ return F->c1[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
+ F->c2[3] + // no warning, foo could have tail padding allocated.
+ B->c1[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
+ B->c2[3]; // no warning, baz could have tail padding allocated.
+ }
+}
+
+namespace metaprogramming {
+#define ONE 1
+ struct foo { char c[ONE]; }; // expected-note {{declared here}}
+ template <int N> struct bar { char c[N]; }; // expected-note {{declared here}}
+
+ char test(foo *F, bar<1> *B) {
+ return F->c[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
+ B->c[3]; // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
+ }
+}
+
+void bar(int x) {}
+int test_more() {
+ int foo[5]; // expected-note 5 {{array 'foo' declared here}}
+ bar(foo[5]); // expected-warning {{array index 5 is past the end of the array (which contains 5 elements)}}
+ ++foo[5]; // expected-warning {{array index 5 is past the end of the array (which contains 5 elements)}}
+ if (foo[6]) // expected-warning {{array index 6 is past the end of the array (which contains 5 elements)}}
+ return --foo[6]; // expected-warning {{array index 6 is past the end of the array (which contains 5 elements)}}
+ else
+ return foo[5]; // expected-warning {{array index 5 is past the end of the array (which contains 5 elements)}}
+}
+
+void test_pr10771() {
+ double foo[4096]; // expected-note {{array 'foo' declared here}}
+
+ ((char*)foo)[sizeof(foo) - 1] = '\0'; // no-warning
+ *(((char*)foo) + sizeof(foo) - 1) = '\0'; // no-warning
+
+ ((char*)foo)[sizeof(foo)] = '\0'; // expected-warning {{array index 32768 is past the end of the array (which contains 32768 elements)}}
+
+ // TODO: This should probably warn, too.
+ *(((char*)foo) + sizeof(foo)) = '\0'; // no-warning
+}
+
+int test_pr11007_aux(const char * restrict, ...);
+
+// Test checking with varargs.
+void test_pr11007() {
+ double a[5]; // expected-note {{array 'a' declared here}}
+ test_pr11007_aux("foo", a[1000]); // expected-warning {{array index 1000 is past the end of the array}}
+}
+
+void test_rdar10916006(void)
+{
+ int a[128]; // expected-note {{array 'a' declared here}}
+ a[(unsigned char)'\xA1'] = 1; // expected-warning {{array index 161 is past the end of the array}}
+}
diff --git a/clang/test/SemaCXX/arrow-operator.cpp b/clang/test/SemaCXX/arrow-operator.cpp
new file mode 100644
index 0000000..6535a0a
--- /dev/null
+++ b/clang/test/SemaCXX/arrow-operator.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct T {
+ void f();
+};
+
+struct A {
+ T* operator->(); // expected-note{{candidate function}}
+};
+
+struct B {
+ T* operator->(); // expected-note{{candidate function}}
+};
+
+struct C : A, B {
+};
+
+struct D : A { };
+
+struct E; // expected-note {{forward declaration of 'E'}}
+
+void f(C &c, D& d, E& e) {
+ c->f(); // expected-error{{use of overloaded operator '->' is ambiguous}}
+ d->f();
+ e->f(); // expected-error{{incomplete definition of type}}
+}
+
+// rdar://8875304
+namespace rdar8875304 {
+class Point {};
+class Line_Segment{ public: Line_Segment(const Point&){} };
+class Node { public: Point Location(){ Point p; return p; } };
+
+void f()
+{
+ Node** node1;
+ Line_Segment(node1->Location()); // expected-error {{not a structure or union}}
+}
+}
diff --git a/clang/test/SemaCXX/atomic-type.cxx b/clang/test/SemaCXX/atomic-type.cxx
new file mode 100644
index 0000000..18707eb
--- /dev/null
+++ b/clang/test/SemaCXX/atomic-type.cxx
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -verify %s
+
+template<typename T> struct atomic {
+ _Atomic(T) value;
+};
+
+template<typename T> struct user {
+ struct inner { char n[sizeof(T)]; };
+ atomic<inner> i;
+};
+
+user<int> u;
+
+// Test overloading behavior of atomics.
+struct A { };
+
+int &ovl1(_Atomic(int));
+long &ovl1(_Atomic(long));
+float &ovl1(_Atomic(float));
+double &ovl1(_Atomic(A const *const *));
+short &ovl1(_Atomic(A **));
+
+void test_overloading(int i, float f, _Atomic(int) ai, _Atomic(float) af,
+ long l, _Atomic(long) al, A const *const *acc,
+ A const ** ac, A **a) {
+ int& ir1 = ovl1(i);
+ int& ir2 = ovl1(ai);
+ long& lr1 = ovl1(l);
+ long& lr2 = ovl1(al);
+ float &fr1 = ovl1(f);
+ float &fr2 = ovl1(af);
+ double &dr1 = ovl1(acc);
+ double &dr2 = ovl1(ac);
+ short &sr1 = ovl1(a);
+}
diff --git a/clang/test/SemaCXX/attr-after-definition.cpp b/clang/test/SemaCXX/attr-after-definition.cpp
new file mode 100644
index 0000000..148a63e
--- /dev/null
+++ b/clang/test/SemaCXX/attr-after-definition.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct X { };
+struct Y { };
+
+bool f0(X) { return true; } // expected-note{{definition}}
+bool f1(X) { return true; }
+
+__attribute__ ((__visibility__("hidden"))) bool f0(X); // expected-warning{{attribute}}
+__attribute__ ((__visibility__("hidden"))) bool f1(Y);
diff --git a/clang/test/SemaCXX/attr-cxx0x.cpp b/clang/test/SemaCXX/attr-cxx0x.cpp
new file mode 100644
index 0000000..4281895
--- /dev/null
+++ b/clang/test/SemaCXX/attr-cxx0x.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+int align_illegal alignas(3); //expected-error {{requested alignment is not a power of 2}}
+char align_big alignas(int);
+int align_small alignas(1); // FIXME: this should be rejected
+int align_multiple alignas(1) alignas(8) alignas(1);
+
+struct align_member {
+ int member alignas(8);
+};
+
+template <unsigned A> struct alignas(A) align_class_template {};
+
+// FIXME: these should not error
+template <typename... T> alignas(T...) struct align_class_temp_pack_type {}; // expected-error{{pack expansions in alignment specifiers are not supported yet}}
+template <unsigned... A> alignas(A...) struct align_class_temp_pack_expr {}; // expected-error{{pack expansions in alignment specifiers are not supported yet}}
+
+typedef char align_typedef alignas(8);
+template<typename T> using align_alias_template = align_typedef;
+
+static_assert(alignof(align_big) == alignof(int), "k's alignment is wrong");
+static_assert(alignof(align_small) == 1, "j's alignment is wrong");
+static_assert(alignof(align_multiple) == 8, "l's alignment is wrong");
+static_assert(alignof(align_member) == 8, "quuux's alignment is wrong");
+static_assert(sizeof(align_member) == 8, "quuux's size is wrong");
+static_assert(alignof(align_typedef) == 8, "typedef's alignment is wrong");
+static_assert(alignof(align_class_template<8>) == 8, "template's alignment is wrong");
+static_assert(alignof(align_class_template<16>) == 16, "template's alignment is wrong");
+// FIXME: enable these tests
+// static_assert(alignof(align_class_temp_pack_type<short, int, long>) == alignof(long), "template's alignment is wrong");
+// static_assert(alignof(align_class_temp_pack_expr<8, 16, 32>) == 32, "template's alignment is wrong");
+static_assert(alignof(align_alias_template<int>) == 8, "alias template's alignment is wrong");
diff --git a/clang/test/SemaCXX/attr-declspec-ignored.cpp b/clang/test/SemaCXX/attr-declspec-ignored.cpp
new file mode 100644
index 0000000..0503750
--- /dev/null
+++ b/clang/test/SemaCXX/attr-declspec-ignored.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+namespace test1 {
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) class A; // expected-warning{{attribute 'visibility' is ignored, place it after "class" to apply attribute to type declaration}} \
+ // expected-warning{{attribute 'aligned' is ignored, place it after "class" to apply attribute to type declaration}}
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) struct B; // expected-warning{{attribute 'visibility' is ignored, place it after "struct" to apply attribute to type declaration}} \
+ // expected-warning{{attribute 'aligned' is ignored, place it after "struct" to apply attribute to type declaration}}
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) union C; // expected-warning{{attribute 'visibility' is ignored, place it after "union" to apply attribute to type declaration}} \
+ // expected-warning{{attribute 'aligned' is ignored, place it after "union" to apply attribute to type declaration}}
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) enum D {D}; // expected-warning{{attribute 'visibility' is ignored, place it after "enum" to apply attribute to type declaration}} \
+ // expected-warning{{attribute 'aligned' is ignored, place it after "enum" to apply attribute to type declaration}}
+}
+
+namespace test2 {
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) class A {} a;
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) struct B {} b;
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) union C {} c;
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) enum D {D} d;
+}
diff --git a/clang/test/SemaCXX/attr-deprecated.cpp b/clang/test/SemaCXX/attr-deprecated.cpp
new file mode 100644
index 0000000..46568aa
--- /dev/null
+++ b/clang/test/SemaCXX/attr-deprecated.cpp
@@ -0,0 +1,235 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+class A {
+ void f() __attribute__((deprecated));
+ void g(A* a);
+ void h(A* a) __attribute__((deprecated));
+
+ int b __attribute__((deprecated));
+};
+
+void A::g(A* a)
+{
+ f(); // expected-warning{{'f' is deprecated}}
+ a->f(); // expected-warning{{'f' is deprecated}}
+
+ (void)b; // expected-warning{{'b' is deprecated}}
+ (void)a->b; // expected-warning{{'b' is deprecated}}
+}
+
+void A::h(A* a)
+{
+ f();
+ a->f();
+
+ (void)b;
+ (void)a->b;
+}
+
+struct B {
+ virtual void f() __attribute__((deprecated));
+ void g();
+};
+
+void B::g() {
+ f();
+ B::f(); // expected-warning{{'f' is deprecated}}
+}
+
+struct C : B {
+ virtual void f();
+ void g();
+};
+
+void C::g() {
+ f();
+ C::f();
+ B::f(); // expected-warning{{'f' is deprecated}}
+}
+
+void f(B* b, C *c) {
+ b->f();
+ b->B::f(); // expected-warning{{'f' is deprecated}}
+
+ c->f();
+ c->C::f();
+ c->B::f(); // expected-warning{{'f' is deprecated}}
+}
+
+struct D {
+ virtual void f() __attribute__((deprecated));
+};
+
+void D::f() { }
+
+void f(D* d) {
+ d->f();
+}
+
+
+// Overloaded namespace members.
+namespace test1 {
+ void foo(int) __attribute__((deprecated));
+ void test1() { foo(10); } // expected-warning {{deprecated}}
+ void foo(short) __attribute__((deprecated));
+ void test2(short s) { foo(s); } // expected-warning {{deprecated}}
+ void foo(long);
+ void test3(long l) { foo(l); }
+ struct A {
+ friend void foo(A*) __attribute__((deprecated));
+ };
+ void test4(A *a) { foo(a); } // expected-warning {{deprecated}}
+
+ namespace ns {
+ struct Foo {};
+ void foo(const Foo &f) __attribute__((deprecated));
+ }
+ void test5() {
+ foo(ns::Foo()); // expected-warning {{deprecated}}
+ }
+}
+
+// Overloaded class members.
+namespace test2 {
+ struct A {
+ void foo(int) __attribute__((deprecated));
+ void foo(long);
+ static void bar(int) __attribute__((deprecated));
+ static void bar(long);
+
+ void test2(int i, long l);
+ };
+ void test1(int i, long l) {
+ A a;
+ a.foo(i); // expected-warning {{deprecated}}
+ a.foo(l);
+ a.bar(i); // expected-warning {{deprecated}}
+ a.bar(l);
+ A::bar(i); // expected-warning {{deprecated}}
+ A::bar(l);
+ }
+
+ void A::test2(int i, long l) {
+ foo(i); // expected-warning {{deprecated}}
+ foo(l);
+ bar(i); // expected-warning {{deprecated}}
+ bar(l);
+ }
+}
+
+// Overloaded operators.
+namespace test3 {
+ struct A {
+ void operator*(const A &);
+ void operator*(int) __attribute__((deprecated));
+ void operator-(const A &) const;
+ };
+ void operator+(const A &, const A &);
+ void operator+(const A &, int) __attribute__((deprecated));
+ void operator-(const A &, int) __attribute__((deprecated));
+
+ void test() {
+ A a, b;
+ a + b;
+ a + 1; // expected-warning {{deprecated}}
+ a - b;
+ a - 1; // expected-warning {{deprecated}}
+ a * b;
+ a * 1; // expected-warning {{deprecated}}
+ }
+}
+
+// Overloaded operator call.
+namespace test4 {
+ struct A {
+ typedef void (*intfn)(int);
+ typedef void (*unintfn)(unsigned);
+ operator intfn() __attribute__((deprecated));
+ operator unintfn();
+ void operator ()(A &) __attribute__((deprecated));
+ void operator ()(const A &);
+ };
+
+ void test() {
+ A a;
+ a(1); // expected-warning {{deprecated}}
+ a(1U);
+
+ A &b = a;
+ const A &c = a;
+ a(b); // expected-warning {{deprecated}}
+ a(c);
+ }
+}
+
+namespace test5 {
+ struct A {
+ operator int() __attribute__((deprecated));
+ operator long();
+ };
+ void test1(A a) {
+ int i = a; // expected-warning {{deprecated}}
+ long l = a;
+ }
+
+ void foo(int);
+ void foo(void*);
+ void bar(long);
+ void bar(void*);
+ void test2(A a) {
+ foo(a); // expected-warning {{deprecated}}
+ bar(a);
+ }
+
+ struct B {
+ int myInt;
+ long myLong;
+
+ B(A &a) :
+ myInt(a), // expected-warning {{deprecated}}
+ myLong(a)
+ {}
+ };
+}
+
+// rdar://problem/8518751
+namespace test6 {
+ enum __attribute__((deprecated)) A {
+ a0
+ };
+ void testA() {
+ A x; // expected-warning {{'A' is deprecated}}
+ x = a0; // expected-warning {{'a0' is deprecated}}
+ }
+
+ enum B {
+ b0 __attribute__((deprecated)),
+ b1
+ };
+ void testB() {
+ B x;
+ x = b0; // expected-warning {{'b0' is deprecated}}
+ x = b1;
+ }
+
+ template <class T> struct C {
+ enum __attribute__((deprecated)) Enum {
+ c0
+ };
+ };
+ void testC() {
+ C<int>::Enum x; // expected-warning {{'Enum' is deprecated}}
+ x = C<int>::c0; // expected-warning {{'c0' is deprecated}}
+ }
+
+ template <class T> struct D {
+ enum Enum {
+ d0,
+ d1 __attribute__((deprecated)),
+ };
+ };
+ void testD() {
+ D<int>::Enum x;
+ x = D<int>::d0;
+ x = D<int>::d1; // expected-warning {{'d1' is deprecated}}
+ }
+}
diff --git a/clang/test/SemaCXX/attr-format.cpp b/clang/test/SemaCXX/attr-format.cpp
new file mode 100644
index 0000000..da134a1
--- /dev/null
+++ b/clang/test/SemaCXX/attr-format.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -Wformat-nonliteral -verify %s
+struct S {
+ static void f(const char*, ...) __attribute__((format(printf, 1, 2)));
+ static const char* f2(const char*) __attribute__((format_arg(1)));
+
+ // GCC has a hidden 'this' argument in member functions which is why
+ // the format argument is argument 2 here.
+ void g(const char*, ...) __attribute__((format(printf, 2, 3)));
+ const char* g2(const char*) __attribute__((format_arg(2)));
+
+ void h(const char*, ...) __attribute__((format(printf, 1, 4))); // \
+ expected-error{{implicit this argument as the format string}}
+ void h2(const char*, ...) __attribute__((format(printf, 2, 1))); // \
+ expected-error{{out of bounds}}
+ const char* h3(const char*) __attribute__((format_arg(1))); // \
+ expected-error{{invalid for the implicit this argument}}
+};
+
+// PR5521
+struct A { void a(const char*,...) __attribute((format(printf,2,3))); };
+void b(A x) {
+ x.a("%d", 3);
+}
+
+// PR8625: correctly interpret static member calls as not having an implicit
+// 'this' argument.
+namespace PR8625 {
+ struct S {
+ static void f(const char*, const char*, ...)
+ __attribute__((format(printf, 2, 3)));
+ };
+ void test(S s, const char* str) {
+ s.f(str, "%s", str);
+ }
+}
diff --git a/clang/test/SemaCXX/attr-nonnull.cpp b/clang/test/SemaCXX/attr-nonnull.cpp
new file mode 100644
index 0000000..09c054c
--- /dev/null
+++ b/clang/test/SemaCXX/attr-nonnull.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct S {
+ S(const char *) __attribute__((nonnull(2)));
+
+ static void f(const char*, const char*) __attribute__((nonnull(1)));
+
+ // GCC has a hidden 'this' argument in member functions, so the middle
+ // argument is the one that must not be null.
+ void g(const char*, const char*, const char*) __attribute__((nonnull(3)));
+
+ void h(const char*) __attribute__((nonnull(1))); // \
+ expected-error{{invalid for the implicit this argument}}
+};
+
+void test() {
+ S s(0); // expected-warning{{null passed}}
+
+ s.f(0, ""); // expected-warning{{null passed}}
+ s.f("", 0);
+ s.g("", 0, ""); // expected-warning{{null passed}}
+ s.g(0, "", 0);
+}
+
+namespace rdar8769025 {
+ __attribute__((nonnull)) void f0(int *&p);
+ __attribute__((nonnull)) void f1(int * const &p);
+ __attribute__((nonnull(2))) void f2(int i, int * const &p);
+
+ void test_f1() {
+ f1(0); // expected-warning{{null passed to a callee which requires a non-null argument}}
+ f2(0, 0); // expected-warning{{null passed to a callee which requires a non-null argument}}
+ }
+}
diff --git a/clang/test/SemaCXX/attr-noreturn.cpp b/clang/test/SemaCXX/attr-noreturn.cpp
new file mode 100644
index 0000000..eaf0d0c
--- /dev/null
+++ b/clang/test/SemaCXX/attr-noreturn.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Reachability tests have to come first because they get suppressed
+// if any errors have occurred.
+namespace test5 {
+ struct A {
+ __attribute__((noreturn)) void fail();
+ void nofail();
+ } a;
+
+ int &test1() {
+ a.nofail();
+ } // expected-warning {{control reaches end of non-void function}}
+
+ int &test2() {
+ a.fail();
+ }
+}
+
+// PR5620
+void f0() __attribute__((__noreturn__));
+void f1(void (*)());
+void f2() { f1(f0); }
+
+// Taking the address of a noreturn function
+void test_f0a() {
+ void (*fp)() = f0;
+ void (*fp1)() __attribute__((noreturn)) = f0;
+}
+
+// Taking the address of an overloaded noreturn function
+void f0(int) __attribute__((__noreturn__));
+
+void test_f0b() {
+ void (*fp)() = f0;
+ void (*fp1)() __attribute__((noreturn)) = f0;
+}
+
+// No-returned function pointers
+typedef void (* noreturn_fp)() __attribute__((noreturn));
+
+void f3(noreturn_fp); // expected-note{{candidate function}}
+
+void test_f3() {
+ f3(f0); // okay
+ f3(f2); // expected-error{{no matching function for call}}
+}
+
+
+class xpto {
+ int blah() __attribute__((noreturn));
+};
+
+int xpto::blah() {
+ return 3; // expected-warning {{function 'blah' declared 'noreturn' should not return}}
+}
diff --git a/clang/test/SemaCXX/attr-regparm.cpp b/clang/test/SemaCXX/attr-regparm.cpp
new file mode 100644
index 0000000..91ee613
--- /dev/null
+++ b/clang/test/SemaCXX/attr-regparm.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-pc-linux-gnu %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-apple-darwin10 %s
+
+// PR7025
+struct X0 {
+ void __attribute__((regparm(3))) f0();
+ void __attribute__((regparm(3))) f1();
+ void __attribute__((regparm(3))) f2(); // expected-note{{previous declaration is here}}
+ void f3(); // expected-note{{previous declaration is here}}
+};
+
+void X0::f0() { }
+void __attribute__((regparm(3))) X0::f1() { }
+void __attribute__((regparm(2))) X0::f2() { } // expected-error{{function declared with with regparm(2) attribute was previously declared with the regparm(3) attribute}}
+void __attribute__((regparm(2))) X0::f3() { } // expected-error{{function declared with with regparm(2) attribute was previously declared without the regparm attribute}}
diff --git a/clang/test/SemaCXX/attr-sentinel.cpp b/clang/test/SemaCXX/attr-sentinel.cpp
new file mode 100644
index 0000000..92c6e21
--- /dev/null
+++ b/clang/test/SemaCXX/attr-sentinel.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f(int, ...) __attribute__((sentinel));
+
+void g() {
+ f(1, 2, __null);
+}
+
+typedef __typeof__(sizeof(int)) size_t;
+
+struct S {
+ S(int,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+ void a(int,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+ void* operator new(size_t,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+ void operator()(int,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+};
+
+void class_test() {
+ S s(1,2,3); // expected-warning {{missing sentinel in function call}}
+ S* s2 = new (1,2,3) S(1, __null); // expected-warning {{missing sentinel in function call}}
+ s2->a(1,2,3); // expected-warning {{missing sentinel in function call}}
+ s(1,2,3); // expected-warning {{missing sentinel in function call}}
+}
diff --git a/clang/test/SemaCXX/attr-unavailable.cpp b/clang/test/SemaCXX/attr-unavailable.cpp
new file mode 100644
index 0000000..2d82668
--- /dev/null
+++ b/clang/test/SemaCXX/attr-unavailable.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int &foo(int); // expected-note {{candidate}}
+double &foo(double); // expected-note {{candidate}}
+void foo(...) __attribute__((__unavailable__)); // expected-note {{candidate function}} \
+// expected-note{{function has been explicitly marked unavailable here}}
+
+void bar(...) __attribute__((__unavailable__)); // expected-note 2{{explicitly marked unavailable}}
+
+void test_foo(short* sp) {
+ int &ir = foo(1);
+ double &dr = foo(1.0);
+ foo(sp); // expected-error{{call to unavailable function 'foo'}}
+
+ void (*fp)(...) = &bar; // expected-error{{'bar' is unavailable}}
+ void (*fp2)(...) = bar; // expected-error{{'bar' is unavailable}}
+
+ int &(*fp3)(int) = foo;
+ void (*fp4)(...) = foo; // expected-error{{'foo' is unavailable}}
+}
+
+namespace radar9046492 {
+// rdar://9046492
+#define FOO __attribute__((unavailable("not available - replaced")))
+
+void foo() FOO; // expected-note {{candidate function has been explicitly made unavailable}}
+void bar() {
+ foo(); // expected-error {{call to unavailable function 'foo': not available - replaced}}
+}
+}
+
+void unavail(short* sp) __attribute__((__unavailable__));
+void unavail(short* sp) {
+ // No complains inside an unavailable function.
+ int &ir = foo(1);
+ double &dr = foo(1.0);
+ foo(sp);
+ foo();
+}
diff --git a/clang/test/SemaCXX/attr-weak.cpp b/clang/test/SemaCXX/attr-weak.cpp
new file mode 100644
index 0000000..b6a9e0a
--- /dev/null
+++ b/clang/test/SemaCXX/attr-weak.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s
+
+static int test0 __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
+static void test1() __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
+
+namespace test2 __attribute__((weak)) { // expected-warning {{'weak' attribute only applies to variables and functions}}
+}
+
+namespace {
+ int test3 __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
+ void test4() __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
+}
+
+struct Test5 {
+ static void test5() __attribute__((weak)); // no error
+};
+
+namespace {
+ struct Test6 {
+ static void test6() __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
+ };
+}
+
+template <class T> struct Test7 {
+ void test7() __attribute__((weak)) {}
+};
+namespace { class Internal; }
+template struct Test7<Internal>;
+template struct Test7<int>;
diff --git a/clang/test/SemaCXX/attr-weakref.cpp b/clang/test/SemaCXX/attr-weakref.cpp
new file mode 100644
index 0000000..a345791
--- /dev/null
+++ b/clang/test/SemaCXX/attr-weakref.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s
+
+// GCC will accept anything as the argument of weakref. Should we
+// check for an existing decl?
+static int a1() __attribute__((weakref ("foo")));
+static int a2() __attribute__((weakref, alias ("foo")));
+
+static int a3 __attribute__((weakref ("foo")));
+static int a4 __attribute__((weakref, alias ("foo")));
+
+// gcc rejects, clang accepts
+static int a5 __attribute__((alias ("foo"), weakref));
+
+// this is pointless, but accepted by gcc. We reject it.
+static int a6 __attribute__((weakref)); //expected-error {{weakref declaration of 'a6' must also have an alias attribute}}
+
+// gcc warns, clang rejects
+void f(void) {
+ static int a __attribute__((weakref ("v2"))); // expected-error {{declaration of 'a' must be in a global context}}
+}
+
+// both gcc and clang reject
+class c {
+ static int a __attribute__((weakref ("v2"))); // expected-error {{declaration of 'a' must be in a global context}}
+ static int b() __attribute__((weakref ("f3"))); // expected-error {{declaration of 'b' must be in a global context}}
+};
+int a7() __attribute__((weakref ("f1"))); // expected-error {{weakref declaration must have internal linkage}}
+int a8 __attribute__((weakref ("v1"))); // expected-error {{weakref declaration must have internal linkage}}
+
+// gcc accepts this
+int a9 __attribute__((weakref)); // expected-error {{weakref declaration must have internal linkage}}
diff --git a/clang/test/SemaCXX/auto-cxx0x.cpp b/clang/test/SemaCXX/auto-cxx0x.cpp
new file mode 100644
index 0000000..a8f9e84
--- /dev/null
+++ b/clang/test/SemaCXX/auto-cxx0x.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+void f() {
+ auto int a; // expected-warning {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
+ int auto b; // expected-error{{cannot combine with previous 'int' declaration specifier}}
+}
diff --git a/clang/test/SemaCXX/auto-cxx98.cpp b/clang/test/SemaCXX/auto-cxx98.cpp
new file mode 100644
index 0000000..1e28d06
--- /dev/null
+++ b/clang/test/SemaCXX/auto-cxx98.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wc++11-compat
+void f() {
+ auto int a; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}}
+ int auto b; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}}
+ auto c; // expected-warning {{C++11 extension}} expected-error {{requires an initializer}}
+ static auto d = 0; // expected-warning {{C++11 extension}}
+ auto static e = 0; // expected-warning {{C++11 extension}}
+}
diff --git a/clang/test/SemaCXX/auto-subst-failure.cpp b/clang/test/SemaCXX/auto-subst-failure.cpp
new file mode 100644
index 0000000..b323dfc
--- /dev/null
+++ b/clang/test/SemaCXX/auto-subst-failure.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+void f() {
+ auto a = f(); // expected-error {{variable has incomplete type 'void'}}
+ auto &b = f(); // expected-error {{cannot form a reference to 'void'}}
+ auto *c = f(); // expected-error {{incompatible initializer of type 'void'}}
+
+ auto d(f()); // expected-error {{variable has incomplete type 'void'}}
+ auto &&e(f()); // expected-error {{cannot form a reference to 'void'}}
+ auto *g(f()); // expected-error {{incompatible initializer of type 'void'}}
+
+ (void)new auto(f()); // expected-error {{allocation of incomplete type 'void'}}
+ (void)new auto&(f()); // expected-error {{cannot form a reference to 'void'}}
+ (void)new auto*(f()); // expected-error {{incompatible constructor argument of type 'void'}}
+}
diff --git a/clang/test/SemaCXX/bitfield-layout.cpp b/clang/test/SemaCXX/bitfield-layout.cpp
new file mode 100644
index 0000000..adecf55
--- /dev/null
+++ b/clang/test/SemaCXX/bitfield-layout.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-apple-darwin10
+
+#define CHECK_SIZE(name, size) extern int name##1[sizeof(name) == size ? 1 : -1];
+#define CHECK_ALIGN(name, size) extern int name##2[__alignof(name) == size ? 1 : -1];
+
+// Simple tests.
+struct Test1 {
+ char c : 9; // expected-warning {{size of bit-field 'c' (9 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+};
+CHECK_SIZE(Test1, 2);
+CHECK_ALIGN(Test1, 1);
+
+struct Test2 {
+ char c : 16; // expected-warning {{size of bit-field 'c' (16 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+};
+CHECK_SIZE(Test2, 2);
+CHECK_ALIGN(Test2, 2);
+
+struct Test3 {
+ char c : 32; // expected-warning {{size of bit-field 'c' (32 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+};
+CHECK_SIZE(Test3, 4);
+CHECK_ALIGN(Test3, 4);
+
+struct Test4 {
+ char c : 64; // expected-warning {{size of bit-field 'c' (64 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+};
+CHECK_SIZE(Test4, 8);
+CHECK_ALIGN(Test4, 8);
+
diff --git a/clang/test/SemaCXX/block-call.cpp b/clang/test/SemaCXX/block-call.cpp
new file mode 100644
index 0000000..d519911
--- /dev/null
+++ b/clang/test/SemaCXX/block-call.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s -fblocks
+
+int (*FP)();
+int (^IFP) ();
+int (^II) (int);
+int main() {
+ int (*FPL) (int) = FP; // expected-error {{cannot initialize a variable of type 'int (*)(int)' with an lvalue of type 'int (*)()'}}
+
+ // For Blocks, the ASTContext::typesAreBlockCompatible() makes sure this is an error.
+ int (^PFR) (int) = IFP; // expected-error {{cannot initialize a variable of type 'int (^)(int)' with an lvalue of type 'int (^)()'}}
+ PFR = II; // OK
+
+ int (^IFP) () = PFR; // OK
+
+
+ const int (^CIC) () = IFP; // OK - initializing 'const int (^)()' with an expression of type 'int (^)()'}}
+
+ const int (^CICC) () = CIC;
+
+
+ int * const (^IPCC) () = 0;
+
+ int * const (^IPCC1) () = IPCC;
+
+ int * (^IPCC2) () = IPCC; // expected-error {{cannot initialize a variable of type 'int *(^)()' with an lvalue of type 'int *const (^)()'}}
+
+ int (^IPCC3) (const int) = PFR;
+
+ int (^IPCC4) (int, char (^CArg) (double));
+
+ int (^IPCC5) (int, char (^CArg) (double)) = IPCC4;
+
+ int (^IPCC6) (int, char (^CArg) (float)) = IPCC4; // expected-error {{cannot initialize a variable of type 'int (^)(int, char (^)(float))' with an lvalue of type}}
+
+ IPCC2 = 0;
+ IPCC2 = 1;
+ int (^x)() = 0;
+ int (^y)() = 3; // expected-error {{cannot initialize a variable of type 'int (^)()' with an rvalue of type 'int'}}
+ int a = 1;
+ int (^z)() = a+4; // expected-error {{cannot initialize a variable of type 'int (^)()' with an rvalue of type 'int'}}
+}
+
+int blah() {
+ int (^IFP) (float);
+ char (^PCP)(double, double, char);
+
+ IFP(1.0);
+ IFP (1.0, 2.0); // expected-error {{too many arguments to block call}}
+
+ char ch = PCP(1.0, 2.0, 'a');
+ return PCP(1.0, 2.0); // expected-error {{too few arguments to block}}
+}
diff --git a/clang/test/SemaCXX/blocks-1.cpp b/clang/test/SemaCXX/blocks-1.cpp
new file mode 100644
index 0000000..1b15094
--- /dev/null
+++ b/clang/test/SemaCXX/blocks-1.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks -std=c++11
+
+extern "C" int exit(int);
+
+typedef struct {
+ unsigned long ps[30];
+ int qs[30];
+} BobTheStruct;
+
+int main (int argc, const char * argv[]) {
+ BobTheStruct inny;
+ BobTheStruct outty;
+ BobTheStruct (^copyStruct)(BobTheStruct);
+ int i;
+
+ for(i=0; i<30; i++) {
+ inny.ps[i] = i * i * i;
+ inny.qs[i] = -i * i * i;
+ }
+
+ copyStruct = ^(BobTheStruct aBigStruct){ return aBigStruct; }; // pass-by-value intrinsically copies the argument
+
+ outty = copyStruct(inny);
+
+ if ( &inny == &outty ) {
+ exit(1);
+ }
+ for(i=0; i<30; i++) {
+ if ( (inny.ps[i] != outty.ps[i]) || (inny.qs[i] != outty.qs[i]) ) {
+ exit(1);
+ }
+ }
+
+ return 0;
+}
+
+namespace rdar8134521 {
+ void foo() {
+ int (^P)(int) = reinterpret_cast<int(^)(int)>(1);
+ P = (int(^)(int))(1);
+
+ P = reinterpret_cast<int(^)(int)>((void*)1);
+ P = (int(^)(int))((void*)1);
+ }
+}
+
+namespace rdar11055105 {
+ struct A {
+ void foo();
+ };
+
+ template <class T> void foo(T &x) noexcept(noexcept(x.foo()));
+
+ void (^block)() = ^{
+ A a;
+ foo(a);
+ };
+}
diff --git a/clang/test/SemaCXX/blocks.cpp b/clang/test/SemaCXX/blocks.cpp
new file mode 100644
index 0000000..adbff55
--- /dev/null
+++ b/clang/test/SemaCXX/blocks.cpp
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks
+
+void tovoid(void*);
+
+void tovoid_test(int (^f)(int, int)) {
+ tovoid(f);
+}
+
+void reference_lvalue_test(int& (^f)()) {
+ f() = 10;
+}
+
+// PR 7165
+namespace test1 {
+ void g(void (^)());
+ struct Foo {
+ void foo();
+ void test() {
+ (void) ^{ foo(); };
+ }
+ };
+}
+
+namespace test2 {
+ int repeat(int value, int (^block)(int), unsigned n) {
+ while (n--) value = block(value);
+ return value;
+ }
+
+ class Power {
+ int base;
+
+ public:
+ Power(int base) : base(base) {}
+ int calculate(unsigned n) {
+ return repeat(1, ^(int v) { return v * base; }, n);
+ }
+ };
+
+ int test() {
+ return Power(2).calculate(10);
+ }
+}
+
+// rdar: // 8382559
+namespace radar8382559 {
+ void func(bool& outHasProperty);
+
+ int test3() {
+ __attribute__((__blocks__(byref))) bool hasProperty = false;
+ bool has = true;
+
+ bool (^b)() = ^ {
+ func(hasProperty);
+ if (hasProperty)
+ hasProperty = 0;
+ if (has)
+ hasProperty = 1;
+ return hasProperty;
+ };
+ func(hasProperty);
+ func(has);
+ b();
+ if (hasProperty)
+ hasProperty = 1;
+ if (has)
+ has = 2;
+ return hasProperty = 1;
+ }
+}
diff --git a/clang/test/SemaCXX/bool.cpp b/clang/test/SemaCXX/bool.cpp
new file mode 100644
index 0000000..2b3ab68
--- /dev/null
+++ b/clang/test/SemaCXX/bool.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Bool literals can be enum values.
+enum {
+ ReadWrite = false,
+ ReadOnly = true
+};
+
+// bool cannot be decremented, and gives a warning on increment
+void test(bool b)
+{
+ ++b; // expected-warning {{incrementing expression of type bool is deprecated}}
+ b++; // expected-warning {{incrementing expression of type bool is deprecated}}
+ --b; // expected-error {{cannot decrement expression of type bool}}
+ b--; // expected-error {{cannot decrement expression of type bool}}
+
+ bool *b1 = (int *)0; // expected-error{{cannot initialize}}
+}
+
+// static_assert_arg_is_bool(x) compiles only if x is a bool.
+template <typename T>
+void static_assert_arg_is_bool(T x) {
+ bool* p = &x;
+}
+
+void test2() {
+ int n = 2;
+ static_assert_arg_is_bool(n && 4); // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+ static_assert_arg_is_bool(n || 5); // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+}
diff --git a/clang/test/SemaCXX/borland-extensions.cpp b/clang/test/SemaCXX/borland-extensions.cpp
new file mode 100644
index 0000000..4831530
--- /dev/null
+++ b/clang/test/SemaCXX/borland-extensions.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fborland-extensions
+
+// Borland extensions
+
+// 1. test -fborland-extensions
+int dummy_function() { return 0; }
+
+// 2. test __pascal
+int _pascal f2();
+
+float __pascal gi2(int, int);
+template<typename T> T g2(T (__pascal * const )(int, int)) { return 0; }
+
+struct M {
+ int __pascal addP();
+ float __pascal subtractP();
+};
+template<typename T> int h2(T (__pascal M::* const )()) { return 0; }
+void m2() {
+ int i; float f;
+ i = f2();
+ f = gi2(2, i);
+ f = g2(gi2);
+ i = h2<int>(&M::addP);
+ f = h2(&M::subtractP);
+}
+
+// 3. test other calling conventions
+int _cdecl fa3();
+int _fastcall fc3();
+int _stdcall fd3();
+
+// 4. test __uuidof()
+typedef struct _GUID {
+ unsigned long Data1;
+ unsigned short Data2;
+ unsigned short Data3;
+ unsigned char Data4[ 8 ];
+} GUID;
+
+struct __declspec(uuid("{12345678-1234-1234-1234-123456789abc}")) Foo;
+struct Data {
+ GUID const* Guid;
+};
+
+void t4() {
+ unsigned long data;
+
+ const GUID guid_inl = __uuidof(Foo);
+ Data ata1 = { &guid_inl};
+ data = ata1.Guid->Data1;
+}
+
diff --git a/clang/test/SemaCXX/builtin-exception-spec.cpp b/clang/test/SemaCXX/builtin-exception-spec.cpp
new file mode 100644
index 0000000..324d20e
--- /dev/null
+++ b/clang/test/SemaCXX/builtin-exception-spec.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -verify %s
+#include <malloc.h>
+
+extern "C" {
+void *malloc(__SIZE_TYPE__);
+}
diff --git a/clang/test/SemaCXX/builtin-ptrtomember-ambig.cpp b/clang/test/SemaCXX/builtin-ptrtomember-ambig.cpp
new file mode 100644
index 0000000..61e3478
--- /dev/null
+++ b/clang/test/SemaCXX/builtin-ptrtomember-ambig.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+struct A {};
+
+struct R {
+ operator const A*();
+};
+
+
+struct B : R {
+ operator A*();
+};
+
+struct C : B {
+
+};
+
+
+void foo(C c, int A::* pmf) {
+ // FIXME. Why so many built-in candidates?
+ int i = c->*pmf; // expected-error {{use of overloaded operator '->*' is ambiguous}} \
+ // expected-note {{built-in candidate operator->*(const struct A *, const int struct A::*)}} \
+ // expected-note {{built-in candidate operator->*(const struct A *, int struct A::*)}} \
+ // expected-note {{built-in candidate operator->*(struct A *, const int struct A::*)}} \
+ // expected-note {{built-in candidate operator->*(struct A *, int struct A::*)}}
+}
+
diff --git a/clang/test/SemaCXX/builtin-ptrtomember-overload-1.cpp b/clang/test/SemaCXX/builtin-ptrtomember-overload-1.cpp
new file mode 100644
index 0000000..2d93c6b
--- /dev/null
+++ b/clang/test/SemaCXX/builtin-ptrtomember-overload-1.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+struct A {};
+struct E {};
+
+struct R {
+ operator A*();
+ operator E*(); // expected-note{{candidate function}}
+};
+
+
+struct S {
+ operator A*();
+ operator E*(); // expected-note{{candidate function}}
+};
+
+struct B : R {
+ operator A*();
+};
+
+struct C : B {
+
+};
+
+void foo(C c, int A::* pmf) {
+ int i = c->*pmf;
+}
+
+struct B1 : R, S {
+ operator A*();
+};
+
+struct C1 : B1 {
+
+};
+
+void foo1(C1 c1, int A::* pmf) {
+ int i = c1->*pmf;
+ c1->*pmf = 10;
+}
+
+void foo1(C1 c1, int E::* pmf) {
+ int i = c1->*pmf; // expected-error {{use of overloaded operator '->*' is ambiguous}} \
+ // expected-note {{because of ambiguity in conversion of 'C1' to 'E *'}} \
+ // expected-note 4 {{built-in candidate operator}}
+}
diff --git a/clang/test/SemaCXX/builtin-ptrtomember-overload.cpp b/clang/test/SemaCXX/builtin-ptrtomember-overload.cpp
new file mode 100644
index 0000000..c7b5173
--- /dev/null
+++ b/clang/test/SemaCXX/builtin-ptrtomember-overload.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+struct A {};
+
+struct B {
+ operator A*();
+};
+
+struct C : B {
+
+};
+
+
+void foo(C c, B b, int A::* pmf) {
+ int j = c->*pmf;
+ int i = b->*pmf;
+}
+
+struct D {
+ operator const D *();
+};
+
+struct DPtr {
+ operator volatile int D::*();
+};
+
+int test(D d, DPtr dptr) {
+ return d->*dptr;
+}
+
diff --git a/clang/test/SemaCXX/builtin_objc_msgSend.cpp b/clang/test/SemaCXX/builtin_objc_msgSend.cpp
new file mode 100644
index 0000000..0e90d54
--- /dev/null
+++ b/clang/test/SemaCXX/builtin_objc_msgSend.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// rdar://8686888
+
+typedef struct objc_selector *SEL;
+typedef struct objc_object *id;
+
+extern "C" __attribute__((visibility("default"))) id objc_msgSend(id self, SEL op, ...)
+ __attribute__((visibility("default")));
+
+inline void TCFReleaseGC(void * object)
+{
+ static SEL SEL_release;
+ objc_msgSend((id)object, SEL_release);
+}
diff --git a/clang/test/SemaCXX/builtins.cpp b/clang/test/SemaCXX/builtins.cpp
new file mode 100644
index 0000000..568ba5d
--- /dev/null
+++ b/clang/test/SemaCXX/builtins.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+typedef const struct __CFString * CFStringRef;
+#define CFSTR __builtin___CFStringMakeConstantString
+
+void f() {
+ (void)CFStringRef(CFSTR("Hello"));
+}
+
+void a() { __builtin_va_list x, y; ::__builtin_va_copy(x, y); }
diff --git a/clang/test/SemaCXX/c99-variable-length-array.cpp b/clang/test/SemaCXX/c99-variable-length-array.cpp
new file mode 100644
index 0000000..7773c08
--- /dev/null
+++ b/clang/test/SemaCXX/c99-variable-length-array.cpp
@@ -0,0 +1,141 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wvla %s
+struct NonPOD {
+ NonPOD();
+};
+
+struct NonPOD2 {
+ NonPOD np;
+};
+
+struct POD {
+ int x;
+ int y;
+};
+
+// We allow VLAs of POD types, only.
+void vla(int N) {
+ int array1[N]; // expected-warning{{variable length arrays are a C99 feature}}
+ POD array2[N]; // expected-warning{{variable length arrays are a C99 feature}}
+ NonPOD array3[N]; // expected-error{{variable length array of non-POD element type 'NonPOD'}}
+ NonPOD2 array4[N][3]; // expected-error{{variable length array of non-POD element type 'NonPOD2'}}
+}
+
+/// Warn about VLAs in templates.
+template<typename T>
+void vla_in_template(int N, T t) {
+ int array1[N]; // expected-warning{{variable length arrays are a C99 feature}}
+}
+
+struct HasConstantValue {
+ static const unsigned int value = 2;
+};
+
+struct HasNonConstantValue {
+ static unsigned int value;
+};
+
+template<typename T>
+void vla_in_template(T t) {
+ int array2[T::value]; // expected-warning{{variable length arrays are a C99 feature}}
+}
+
+template void vla_in_template<HasConstantValue>(HasConstantValue);
+template void vla_in_template<HasNonConstantValue>(HasNonConstantValue); // expected-note{{instantiation of}}
+
+template<typename T> struct X0 { };
+
+// Cannot use any variably-modified type with a template parameter or
+// argument.
+void inst_with_vla(int N) {
+ int array[N]; // expected-warning{{variable length arrays are a C99 feature}}
+ X0<__typeof__(array)> x0a; // expected-error{{variably modified type 'typeof (array)' (aka 'int [N]') cannot be used as a template argument}}
+}
+
+template<typename T>
+struct X1 {
+ template<int (&Array)[T::value]> // expected-error{{non-type template parameter of variably modified type 'int (&)[HasNonConstantValue::value]'}} \
+ // expected-warning{{variable length arrays are a C99 feature}}
+ struct Inner {
+
+ };
+};
+
+X1<HasConstantValue> x1a;
+X1<HasNonConstantValue> x1b; // expected-note{{in instantiation of}}
+
+// Template argument deduction does not allow deducing a size from a VLA.
+template<typename T, unsigned N>
+void accept_array(T (&array)[N]); // expected-note{{candidate template ignored: failed template argument deduction}}
+
+void test_accept_array(int N) {
+ int array[N]; // expected-warning{{variable length arrays are a C99 feature}}
+ accept_array(array); // expected-error{{no matching function for call to 'accept_array'}}
+}
+
+// Variably-modified types cannot be used in local classes.
+void local_classes(int N) { // expected-note {{declared here}}
+ struct X {
+ int size;
+ int array[N]; // expected-error{{fields must have a constant size: 'variable length array in structure' extension will never be supported}} \
+ // expected-error{{reference to local variable 'N' declared in enclosing function 'local_classes'}} \
+ // expected-warning{{variable length arrays are a C99 feature}}
+ };
+}
+
+namespace PR7206 {
+ void f(int x) {
+ struct edge_info {
+ float left;
+ float right;
+ };
+ struct edge_info edgeInfo[x]; // expected-warning{{variable length arrays are a C99 feature}}
+ }
+}
+
+namespace rdar8020206 {
+ template<typename T>
+ void f(int i) {
+ const unsigned value = i;
+ int array[value * i]; // expected-warning 2{{variable length arrays are a C99 feature}}
+ }
+
+ template void f<int>(int); // expected-note{{instantiation of}}
+}
+
+namespace rdar8021385 {
+ typedef int my_int;
+ struct A { typedef int my_int; };
+ template<typename T>
+ struct B {
+ typedef typename T::my_int my_int;
+ void f0() {
+ int M = 4;
+ my_int a[M]; // expected-warning{{variable length arrays are a C99 feature}}
+ }
+ };
+ B<A> a;
+}
+
+namespace PR8209 {
+ void f(int n) {
+ typedef int vla_type[n]; // expected-warning{{variable length arrays are a C99 feature}}
+ (void)new vla_type; // expected-error{{variably}}
+ }
+}
+
+namespace rdar8733881 { // rdar://8733881
+
+static const int k_cVal3 = (int)(1000*0.2f);
+ int f() {
+ // Ok, fold to a constant size array as an extension.
+ char rgch[k_cVal3] = {0};
+ }
+}
+
+namespace PR11744 {
+ template<typename T> int f(int n) {
+ T arr[3][n]; // expected-warning 3 {{variable length arrays are a C99 feature}}
+ return 3;
+ }
+ int test = f<int>(0); // expected-note {{instantiation of}}
+}
diff --git a/clang/test/SemaCXX/c99.cpp b/clang/test/SemaCXX/c99.cpp
new file mode 100644
index 0000000..13918dc
--- /dev/null
+++ b/clang/test/SemaCXX/c99.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+void f1(int i[static 5]) { // expected-error{{C99}}
+}
+
+struct Point { int x; int y; };
+
+Point p1 = { .x = 17, // expected-warning{{designated initializers are a C99 feature}}
+ y: 25 }; // expected-warning{{designated initializers are a C99 feature}} \
+ // expected-warning{{use of GNU old-style field designator extension}}
diff --git a/clang/test/SemaCXX/cast-conversion.cpp b/clang/test/SemaCXX/cast-conversion.cpp
new file mode 100644
index 0000000..dd2bc98
--- /dev/null
+++ b/clang/test/SemaCXX/cast-conversion.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+struct R {
+ R(int);
+};
+
+struct A {
+ A(R);
+};
+
+struct B { // expected-note 3 {{candidate constructor (the implicit copy constructor) not viable}} \
+ expected-note 3 {{candidate constructor (the implicit move constructor) not viable}}
+ B(A); // expected-note 3 {{candidate constructor not viable}}
+};
+
+int main () {
+ B(10); // expected-error {{no matching conversion for functional-style cast from 'int' to 'B'}}
+ (B)10; // expected-error {{no matching conversion for C-style cast from 'int' to 'B'}}
+ static_cast<B>(10); // expected-error {{no matching conversion for static_cast from 'int' to 'B'}} \\
+ // expected-warning {{expression result unused}}
+}
+
+template<class T>
+struct X0 {
+ X0(const T &);
+};
+
+template<class T>
+X0<T> make_X0(const T &Val) {
+ return X0<T>(Val);
+}
+
+void test_X0() {
+ const char array[2] = { 'a', 'b' };
+ make_X0(array);
+}
+
+// PR5210 recovery
+class C {
+protected:
+ template <int> float* &f0(); // expected-note{{candidate}}
+ template <unsigned> float* &f0(); // expected-note{{candidate}}
+
+ void f1() {
+ static_cast<float*>(f0<0>()); // expected-error{{ambiguous}}
+ }
+};
diff --git a/clang/test/SemaCXX/cast-explicit-ctor.cpp b/clang/test/SemaCXX/cast-explicit-ctor.cpp
new file mode 100644
index 0000000..0052856
--- /dev/null
+++ b/clang/test/SemaCXX/cast-explicit-ctor.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct B { explicit B(bool); };
+void f() {
+ (void)(B)true;
+ (void)B(true);
+}
diff --git a/clang/test/SemaCXX/class-base-member-init.cpp b/clang/test/SemaCXX/class-base-member-init.cpp
new file mode 100644
index 0000000..e84e57b
--- /dev/null
+++ b/clang/test/SemaCXX/class-base-member-init.cpp
@@ -0,0 +1,92 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+class S {
+public:
+ S ();
+};
+
+struct D : S {
+ D() :
+ b1(0), // expected-note {{previous initialization is here}}
+ b2(1),
+ b1(0), // expected-error {{multiple initializations given for non-static member 'b1'}}
+ S(), // expected-note {{previous initialization is here}}
+ S() // expected-error {{multiple initializations given for base 'S'}}
+ {}
+ int b1;
+ int b2;
+};
+
+struct A {
+ struct {
+ int a;
+ int b;
+ };
+ A();
+};
+
+A::A() : a(10), b(20) { }
+
+namespace Test1 {
+ template<typename T> struct A {};
+ template<typename T> struct B : A<T> {
+
+ B() : A<T>(), // expected-note {{previous initialization is here}}
+ A<T>() { } // expected-error {{multiple initializations given for base 'A<T>'}}
+ };
+}
+
+namespace Test2 {
+ template<typename T> struct A : T {
+ A() : T(), // expected-note {{previous initialization is here}}
+ T() { } // expected-error {{multiple initializations given for base 'T'}}
+ };
+}
+
+namespace Test3 {
+ template<typename T> struct A {
+ T t;
+
+ A() : t(1), // expected-note {{previous initialization is here}}
+ t(2) { } // expected-error {{multiple initializations given for non-static member 't'}}
+ };
+}
+
+namespace test4 {
+ class A {
+ union {
+ struct {
+ int a;
+ int b;
+ };
+
+ int c;
+
+ union {
+ int d;
+ int e;
+ };
+ };
+
+ A(char _) : a(0), b(0) {}
+ A(short _) : a(0), c(0) {} // expected-error {{initializing multiple members of union}} expected-note {{previous initialization is here}}
+ A(int _) : d(0), e(0) {} // expected-error {{initializing multiple members of union}} expected-note {{previous initialization is here}}
+ A(long _) : a(0), d(0) {} // expected-error {{initializing multiple members of union}} expected-note {{previous initialization is here}}
+ };
+}
+
+namespace test5 {
+ struct Base {
+ Base(int);
+ };
+ struct A : Base {
+ A() : decltype(Base(1))(3) {
+ }
+ A(int) : Base(3), // expected-note {{previous initialization is here}}
+ decltype(Base(1))(2), // expected-error {{multiple initializations given for base 'decltype(test5::Base(1))' (aka 'test5::Base')}}
+ decltype(int())() { // expected-error {{constructor initializer 'decltype(int())' (aka 'int') does not name a class}}
+ }
+ A(float) : decltype(A())(3) {
+ }
+ };
+}
diff --git a/clang/test/SemaCXX/class-layout.cpp b/clang/test/SemaCXX/class-layout.cpp
new file mode 100644
index 0000000..d81944a
--- /dev/null
+++ b/clang/test/SemaCXX/class-layout.cpp
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify
+
+#define SA(n, p) int a##n[(p) ? 1 : -1]
+
+struct A {
+ int a;
+ char b;
+};
+
+SA(0, sizeof(A) == 8);
+
+struct B : A {
+ char c;
+};
+
+SA(1, sizeof(B) == 12);
+
+struct C {
+// Make fields private so C won't be a POD type.
+private:
+ int a;
+ char b;
+};
+
+SA(2, sizeof(C) == 8);
+
+struct D : C {
+ char c;
+};
+
+SA(3, sizeof(D) == 8);
+
+struct __attribute__((packed)) E {
+ char b;
+ int a;
+};
+
+SA(4, sizeof(E) == 5);
+
+struct __attribute__((packed)) F : E {
+ char d;
+};
+
+SA(5, sizeof(F) == 6);
+
+struct G { G(); };
+struct H : G { };
+
+SA(6, sizeof(H) == 1);
+
+struct I {
+ char b;
+ int a;
+} __attribute__((packed));
+
+SA(6_1, sizeof(I) == 5);
+
+// PR5580
+namespace PR5580 {
+
+class A { bool iv0 : 1; };
+SA(7, sizeof(A) == 1);
+
+class B : A { bool iv0 : 1; };
+SA(8, sizeof(B) == 2);
+
+struct C { bool iv0 : 1; };
+SA(9, sizeof(C) == 1);
+
+struct D : C { bool iv0 : 1; };
+SA(10, sizeof(D) == 2);
+
+}
+
+namespace Test1 {
+
+// Test that we don't assert on this hierarchy.
+struct A { };
+struct B : A { virtual void b(); };
+class C : virtual A { int c; };
+struct D : virtual B { };
+struct E : C, virtual D { };
+class F : virtual E { };
+struct G : virtual E, F { };
+
+SA(0, sizeof(G) == 24);
+
+}
+
+namespace Test2 {
+
+// Test that this somewhat complex class structure is laid out correctly.
+struct A { };
+struct B : A { virtual void b(); };
+struct C : virtual B { };
+struct D : virtual A { };
+struct E : virtual B, D { };
+struct F : E, virtual C { };
+struct G : virtual F, A { };
+struct H { G g; };
+
+SA(0, sizeof(H) == 24);
+
+}
diff --git a/clang/test/SemaCXX/class-names.cpp b/clang/test/SemaCXX/class-names.cpp
new file mode 100644
index 0000000..2962988
--- /dev/null
+++ b/clang/test/SemaCXX/class-names.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class C { };
+
+C c;
+
+void D(int);
+
+class D {};
+
+void foo()
+{
+ D(5);
+ class D d;
+}
+
+class D; // expected-note {{previous use is here}}
+
+enum D; // expected-error {{use of 'D' with tag type that does not match previous declaration}}
+
+class A * A;
+
+class A * a2;
+
+void bar()
+{
+ A = 0;
+}
+
+void C(int);
+
+void bar2()
+{
+ C(17);
+}
+
+extern int B;
+class B;
+class B {};
+int B;
+
+enum E { e1_val };
+E e1;
+
+void E(int);
+
+void bar3() {
+ E(17);
+}
+
+enum E e2;
+
+enum E2 { E2 };
diff --git a/clang/test/SemaCXX/class.cpp b/clang/test/SemaCXX/class.cpp
new file mode 100644
index 0000000..4dffc8d
--- /dev/null
+++ b/clang/test/SemaCXX/class.cpp
@@ -0,0 +1,197 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s
+class C {
+public:
+ auto int errx; // expected-error {{storage class specified for a member declaration}} expected-warning {{'auto' storage class specifier is redundant}}
+ register int erry; // expected-error {{storage class specified for a member declaration}}
+ extern int errz; // expected-error {{storage class specified for a member declaration}}
+
+ static void sm() {
+ sx = 0;
+ this->x = 0; // expected-error {{invalid use of 'this' outside of a non-static member function}}
+ x = 0; // expected-error {{invalid use of member 'x' in static member function}}
+ }
+
+ class NestedC {
+ public:
+ NestedC(int);
+ void f() {
+ sx = 0;
+ x = 0; // expected-error {{use of non-static data member 'x' of 'C' from nested type 'NestedC'}}
+ sm();
+ m(); // expected-error {{call to non-static member function 'm' of 'C' from nested type 'NestedC'}}
+ }
+ };
+
+ int b : 1, w : 2;
+ int : 1, : 2;
+ typedef int E : 1; // expected-error {{typedef member 'E' cannot be a bit-field}}
+ static int sb : 1; // expected-error {{static member 'sb' cannot be a bit-field}}
+ static int vs;
+
+ typedef int func();
+ func tm;
+ func *ptm;
+ func btm : 1; // expected-error {{bit-field 'btm' has non-integral type}}
+ NestedC bc : 1; // expected-error {{bit-field 'bc' has non-integral type}}
+
+ enum E1 { en1, en2 };
+
+ int i = 0; // expected-warning {{in-class initialization of non-static data member is a C++11 extension}}
+ static int si = 0; // expected-error {{non-const static data member must be initialized out of line}}
+ static const NestedC ci = 0; // expected-error {{static data member of type 'const C::NestedC' must be initialized out of line}}
+ static const int nci = vs; // expected-error {{in-class initializer for static data member is not a constant expression}}
+ static const int vi = 0;
+ static const volatile int cvi = 0; // ok, illegal in C++11
+ static const E evi = 0;
+
+ void m() {
+ sx = 0;
+ this->x = 0;
+ y = 0;
+ this = 0; // expected-error {{expression is not assignable}}
+ }
+
+ int f1(int p) {
+ A z = 6;
+ return p + x + this->y + z;
+ }
+
+ typedef int A;
+
+ virtual int viv; // expected-error {{'virtual' can only appear on non-static member functions}}
+ virtual static int vsif(); // expected-error {{'virtual' can only appear on non-static member functions}}
+ virtual int vif();
+
+private:
+ int x,y;
+ static int sx;
+
+ mutable int mi;
+ mutable int &mir; // expected-error {{'mutable' cannot be applied to references}}
+ mutable void mfn(); // expected-error {{'mutable' cannot be applied to functions}}
+ mutable const int mci; // expected-error {{'mutable' and 'const' cannot be mixed}}
+
+ static const int number = 50;
+ static int arr[number];
+};
+
+class C2 {
+ void f() {
+ static int lx;
+ class LC1 {
+ int m() { return lx; }
+ };
+ class LC2 {
+ int m() { return lx; }
+ };
+ }
+};
+
+struct C3 {
+ int i;
+ mutable int j;
+};
+void f()
+{
+ const C3 c3 = { 1, 2 };
+ (void)static_cast<int*>(&c3.i); // expected-error {{static_cast from 'const int *' to 'int *' is not allowed}}
+ // but no error here
+ (void)static_cast<int*>(&c3.j);
+}
+
+// Play with mutable a bit more, to make sure it doesn't crash anything.
+mutable int gi; // expected-error {{'mutable' can only be applied to member variables}}
+mutable void gfn(); // expected-error {{illegal storage class on function}}
+void ogfn()
+{
+ mutable int ml; // expected-error {{'mutable' can only be applied to member variables}}
+
+ // PR3020: This used to crash due to double ownership of C4.
+ struct C4;
+ C4; // expected-warning {{declaration does not declare anything}}
+}
+
+struct C4 {
+ void f(); // expected-note{{previous declaration is here}}
+ int f; // expected-error{{duplicate member 'f'}}
+};
+
+// PR5415 - don't hang!
+struct S
+{
+ void f(); // expected-note 1 {{previous declaration}}
+ void S::f() {} // expected-warning {{extra qualification on member}} expected-error {{class member cannot be redeclared}} expected-note {{previous declaration}} expected-note {{previous definition}}
+ void f() {} // expected-error {{class member cannot be redeclared}} expected-error {{redefinition}}
+};
+
+// Don't crash on this bogus code.
+namespace pr6629 {
+ // TODO: most of these errors are spurious
+ template<class T1, class T2> struct foo :
+ bogus<foo<T1,T2> > // expected-error {{unknown template name 'bogus'}} \
+ // BOGUS expected-error {{expected '{' after base class list}} \
+ // BOGUS expected-error {{expected ';' after struct}} \
+ // BOGUS expected-error {{expected unqualified-id}}
+ { };
+
+ template<> struct foo<unknown,unknown> { // expected-error {{undeclared identifier 'unknown'}}
+ template <typename U1, typename U2> struct bar {
+ typedef bar type;
+ static const int value = 0;
+ };
+ };
+}
+
+namespace PR7153 {
+ class EnclosingClass {
+ public:
+ struct A { } mutable *member;
+ };
+
+ void f(const EnclosingClass &ec) {
+ ec.member = 0;
+ }
+}
+
+namespace PR7196 {
+ struct A {
+ int a;
+
+ void f() {
+ char i[sizeof(a)];
+ enum { x = sizeof(i) };
+ enum { y = sizeof(a) };
+ }
+ };
+}
+
+namespace rdar8066414 {
+ class C {
+ C() {}
+ } // expected-error{{expected ';' after class}}
+}
+
+namespace rdar8367341 {
+ float foo();
+
+ struct A {
+ static const float x = 5.0f; // expected-warning {{in-class initializer for static data member of type 'const float' is a GNU extension}}
+ static const float y = foo(); // expected-warning {{in-class initializer for static data member of type 'const float' is a GNU extension}} expected-error {{in-class initializer for static data member is not a constant expression}}
+ };
+}
+
+namespace with_anon {
+struct S {
+ union {
+ char c;
+ };
+};
+
+void f() {
+ S::c; // expected-error {{invalid use of non-static data member}}
+}
+}
+
+struct PR9989 {
+ static int const PR9989_Member = sizeof PR9989_Member;
+};
diff --git a/clang/test/SemaCXX/comma.cpp b/clang/test/SemaCXX/comma.cpp
new file mode 100644
index 0000000..79ff7d1
--- /dev/null
+++ b/clang/test/SemaCXX/comma.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR6076
+void f();
+void (&g)() = (void(), f);
+
+int a[1];
+int (&b)[1] = (void(), a);
diff --git a/clang/test/SemaCXX/compare.cpp b/clang/test/SemaCXX/compare.cpp
new file mode 100644
index 0000000..28e2dd0
--- /dev/null
+++ b/clang/test/SemaCXX/compare.cpp
@@ -0,0 +1,225 @@
+// Force x86-64 because some of our heuristics are actually based
+// on integer sizes.
+
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify -Wsign-compare %s
+
+int test0(long a, unsigned long b) {
+ enum EnumA {A};
+ enum EnumB {B};
+ enum EnumC {C = 0x10000};
+ return
+ // (a,b)
+ (a == (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
+ (a == (unsigned int) b) +
+ (a == (unsigned short) b) +
+ (a == (unsigned char) b) +
+ ((long) a == b) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a == b) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a == b) + // expected-warning {{comparison of integers of different signs}}
+ ((signed char) a == b) + // expected-warning {{comparison of integers of different signs}}
+ ((long) a == (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a == (unsigned int) b) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a == (unsigned short) b) +
+ ((signed char) a == (unsigned char) b) +
+ (a < (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
+ (a < (unsigned int) b) +
+ (a < (unsigned short) b) +
+ (a < (unsigned char) b) +
+ ((long) a < b) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a < b) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < b) + // expected-warning {{comparison of integers of different signs}}
+ ((signed char) a < b) + // expected-warning {{comparison of integers of different signs}}
+ ((long) a < (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a < (unsigned int) b) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < (unsigned short) b) +
+ ((signed char) a < (unsigned char) b) +
+
+ // (A,b)
+ (A == (unsigned long) b) +
+ (A == (unsigned int) b) +
+ (A == (unsigned short) b) +
+ (A == (unsigned char) b) +
+ ((long) A == b) +
+ ((int) A == b) +
+ ((short) A == b) +
+ ((signed char) A == b) +
+ ((long) A == (unsigned long) b) +
+ ((int) A == (unsigned int) b) +
+ ((short) A == (unsigned short) b) +
+ ((signed char) A == (unsigned char) b) +
+ (A < (unsigned long) b) +
+ (A < (unsigned int) b) +
+ (A < (unsigned short) b) +
+ (A < (unsigned char) b) +
+ ((long) A < b) +
+ ((int) A < b) +
+ ((short) A < b) +
+ ((signed char) A < b) +
+ ((long) A < (unsigned long) b) +
+ ((int) A < (unsigned int) b) +
+ ((short) A < (unsigned short) b) +
+ ((signed char) A < (unsigned char) b) +
+
+ // (a,B)
+ (a == (unsigned long) B) +
+ (a == (unsigned int) B) +
+ (a == (unsigned short) B) +
+ (a == (unsigned char) B) +
+ ((long) a == B) +
+ ((int) a == B) +
+ ((short) a == B) +
+ ((signed char) a == B) +
+ ((long) a == (unsigned long) B) +
+ ((int) a == (unsigned int) B) +
+ ((short) a == (unsigned short) B) +
+ ((signed char) a == (unsigned char) B) +
+ (a < (unsigned long) B) + // expected-warning {{comparison of integers of different signs}}
+ (a < (unsigned int) B) +
+ (a < (unsigned short) B) +
+ (a < (unsigned char) B) +
+ ((long) a < B) +
+ ((int) a < B) +
+ ((short) a < B) +
+ ((signed char) a < B) +
+ ((long) a < (unsigned long) B) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a < (unsigned int) B) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < (unsigned short) B) +
+ ((signed char) a < (unsigned char) B) +
+
+ // (C,b)
+ (C == (unsigned long) b) +
+ (C == (unsigned int) b) +
+ (C == (unsigned short) b) +
+ (C == (unsigned char) b) +
+ ((long) C == b) +
+ ((int) C == b) +
+ ((short) C == b) +
+ ((signed char) C == b) +
+ ((long) C == (unsigned long) b) +
+ ((int) C == (unsigned int) b) +
+ ((short) C == (unsigned short) b) +
+ ((signed char) C == (unsigned char) b) +
+ (C < (unsigned long) b) +
+ (C < (unsigned int) b) +
+ (C < (unsigned short) b) +
+ (C < (unsigned char) b) +
+ ((long) C < b) +
+ ((int) C < b) +
+ ((short) C < b) +
+ ((signed char) C < b) +
+ ((long) C < (unsigned long) b) +
+ ((int) C < (unsigned int) b) +
+ ((short) C < (unsigned short) b) +
+ ((signed char) C < (unsigned char) b) +
+
+ // (a,C)
+ (a == (unsigned long) C) +
+ (a == (unsigned int) C) +
+ (a == (unsigned short) C) +
+ (a == (unsigned char) C) +
+ ((long) a == C) +
+ ((int) a == C) +
+ ((short) a == C) +
+ ((signed char) a == C) +
+ ((long) a == (unsigned long) C) +
+ ((int) a == (unsigned int) C) +
+ ((short) a == (unsigned short) C) +
+ ((signed char) a == (unsigned char) C) +
+ (a < (unsigned long) C) + // expected-warning {{comparison of integers of different signs}}
+ (a < (unsigned int) C) +
+ (a < (unsigned short) C) +
+ (a < (unsigned char) C) +
+ ((long) a < C) +
+ ((int) a < C) +
+ ((short) a < C) +
+ ((signed char) a < C) +
+ ((long) a < (unsigned long) C) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a < (unsigned int) C) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < (unsigned short) C) +
+ ((signed char) a < (unsigned char) C) +
+
+ // (0x80000,b)
+ (0x80000 == (unsigned long) b) +
+ (0x80000 == (unsigned int) b) +
+ (0x80000 == (unsigned short) b) +
+ (0x80000 == (unsigned char) b) +
+ ((long) 0x80000 == b) +
+ ((int) 0x80000 == b) +
+ ((short) 0x80000 == b) +
+ ((signed char) 0x80000 == b) +
+ ((long) 0x80000 == (unsigned long) b) +
+ ((int) 0x80000 == (unsigned int) b) +
+ ((short) 0x80000 == (unsigned short) b) +
+ ((signed char) 0x80000 == (unsigned char) b) +
+ (0x80000 < (unsigned long) b) +
+ (0x80000 < (unsigned int) b) +
+ (0x80000 < (unsigned short) b) +
+ (0x80000 < (unsigned char) b) +
+ ((long) 0x80000 < b) +
+ ((int) 0x80000 < b) +
+ ((short) 0x80000 < b) +
+ ((signed char) 0x80000 < b) +
+ ((long) 0x80000 < (unsigned long) b) +
+ ((int) 0x80000 < (unsigned int) b) +
+ ((short) 0x80000 < (unsigned short) b) +
+ ((signed char) 0x80000 < (unsigned char) b) +
+
+ // (a,0x80000)
+ (a == (unsigned long) 0x80000) +
+ (a == (unsigned int) 0x80000) +
+ (a == (unsigned short) 0x80000) +
+ (a == (unsigned char) 0x80000) +
+ ((long) a == 0x80000) +
+ ((int) a == 0x80000) +
+ ((short) a == 0x80000) +
+ ((signed char) a == 0x80000) +
+ ((long) a == (unsigned long) 0x80000) +
+ ((int) a == (unsigned int) 0x80000) +
+ ((short) a == (unsigned short) 0x80000) +
+ ((signed char) a == (unsigned char) 0x80000) +
+ (a < (unsigned long) 0x80000) + // expected-warning {{comparison of integers of different signs}}
+ (a < (unsigned int) 0x80000) +
+ (a < (unsigned short) 0x80000) +
+ (a < (unsigned char) 0x80000) +
+ ((long) a < 0x80000) +
+ ((int) a < 0x80000) +
+ ((short) a < 0x80000) +
+ ((signed char) a < 0x80000) +
+ ((long) a < (unsigned long) 0x80000) + // expected-warning {{comparison of integers of different signs}}
+ ((int) a < (unsigned int) 0x80000) + // expected-warning {{comparison of integers of different signs}}
+ ((short) a < (unsigned short) 0x80000) +
+ ((signed char) a < (unsigned char) 0x80000) +
+
+ 10
+ ;
+}
+
+int test1(int i) {
+ enum en { zero };
+ return i > zero;
+}
+
+enum E { e };
+void test2(int i, void *vp) {
+ if (test1 == vp) { } // expected-warning{{equality comparison between function pointer and void pointer}}
+ if (test1 == e) { } // expected-error{{comparison between pointer and integer}}
+ if (vp < 0) { }
+ if (test1 < e) { } // expected-error{{comparison between pointer and integer}}
+}
+
+// PR7536
+static const unsigned int kMax = 0;
+int pr7536() {
+ return (kMax > 0);
+}
+
+// -Wsign-compare should not warn when ?: operands have different signedness.
+// This will be caught by -Wsign-conversion
+void test3() {
+ unsigned long a;
+ signed long b;
+ (void) (true ? a : b);
+ (void) (true ? (unsigned int)a : (signed int)b);
+ (void) (true ? b : a);
+ (void) (true ? (unsigned char)b : (signed char)a);
+}
diff --git a/clang/test/SemaCXX/complex-init-list.cpp b/clang/test/SemaCXX/complex-init-list.cpp
new file mode 100644
index 0000000..e75833a
--- /dev/null
+++ b/clang/test/SemaCXX/complex-init-list.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
+
+// This file tests the clang extension which allows initializing the components
+// of a complex number individually using an initialization list. Basically,
+// if you have an explicit init list for a complex number that contains two
+// initializers, this extension kicks in to turn it into component-wise
+// initialization.
+//
+// See also the testcase for the C version of this extension in
+// test/Sema/complex-init-list.c.
+
+// Basic testcase
+// (No pedantic warning is necessary because _Complex is not part of C++.)
+_Complex float valid1 = { 1.0f, 2.0f };
diff --git a/clang/test/SemaCXX/complex-overload.cpp b/clang/test/SemaCXX/complex-overload.cpp
new file mode 100644
index 0000000..719a850
--- /dev/null
+++ b/clang/test/SemaCXX/complex-overload.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+char *foo(float);
+
+void test_foo_1(float fv, double dv, float _Complex fc, double _Complex dc) {
+ char *cp1 = foo(fv);
+ char *cp2 = foo(dv);
+ // Note: GCC and EDG reject these two, but they are valid C99 conversions
+ char *cp3 = foo(fc);
+ char *cp4 = foo(dc);
+}
+
+int *foo(float _Complex);
+
+void test_foo_2(float fv, double dv, float _Complex fc, double _Complex dc) {
+ char *cp1 = foo(fv);
+ char *cp2 = foo(dv);
+ int *ip = foo(fc);
+ int *lp = foo(dc);
+}
+
+long *foo(double _Complex);
+
+void test_foo_3(float fv, double dv, float _Complex fc, double _Complex dc) {
+ char *cp1 = foo(fv);
+ char *cp2 = foo(dv);
+ int *ip = foo(fc);
+ long *lp = foo(dc);
+}
+
+char *promote_or_convert(double _Complex); // expected-note{{candidate function}}
+int *promote_or_convert(long double _Complex); // expected-note{{candidate function}}
+
+void test_promote_or_convert(float f, float _Complex fc) {
+ char *cp = promote_or_convert(fc);
+ int *ip2 = promote_or_convert(f); // expected-error{{call to 'promote_or_convert' is ambiguous}}
+}
+
+char *promote_or_convert2(float);
+int *promote_or_convert2(double _Complex);
+
+void test_promote_or_convert2(float _Complex fc) {
+ int *cp = promote_or_convert2(fc);
+}
+
+char *promote_or_convert3(int _Complex);
+int *promote_or_convert3(long _Complex);
+
+void test_promote_or_convert3(short _Complex sc) {
+ char *cp = promote_or_convert3(sc);
+}
diff --git a/clang/test/SemaCXX/composite-pointer-type.cpp b/clang/test/SemaCXX/composite-pointer-type.cpp
new file mode 100644
index 0000000..06fc8f4
--- /dev/null
+++ b/clang/test/SemaCXX/composite-pointer-type.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class Base { };
+class Derived1 : public Base { };
+class Derived2 : public Base { };
+
+void f0(volatile Base *b, Derived1 *d1, const Derived2 *d2) {
+ if (b > d1)
+ return;
+ if (d1 <= b)
+ return;
+ if (b > d2)
+ return;
+ if (d1 >= d2) // expected-error{{comparison of distinct}}
+ return;
+}
+
+void f1(volatile Base *b, Derived1 *d1, const Derived2 *d2) {
+ if (b == d1)
+ return;
+ if (d1 == b)
+ return;
+ if (b != d2)
+ return;
+ if (d1 == d2) // expected-error{{comparison of distinct}}
+ return;
+}
+
+// PR4691
+int ptrcmp1(void *a, int *b) {
+ return a < b;
+}
+int ptrcmp2(long *a, int *b) {
+ return a < b; // expected-error{{distinct}}
+}
+
+// PR5509 - Multi-level pointers
+int f2() {
+ typedef int *IntPtr;
+ typedef IntPtr *IntPtrPtr;
+ typedef IntPtr const *IntPtrConstPtr;
+ IntPtrConstPtr i = 0;
+ IntPtrPtr j = 0;
+ return i != j;
+}
+
+// PR5763
+typedef double Matrix4[4][4];
+
+bool f(Matrix4 m1, const Matrix4 m2) {
+ return m1 != m2;
+}
+
+// PR6346
+bool f1(bool b, void **p, const void **q) {
+ if (p == q) // expected-warning{{comparison of distinct pointer types ('void **' and 'const void **') uses non-standard composite pointer type 'const void *const *'}}
+ return false;
+
+ return b? p : q; // expected-warning{{incompatible operand types ('void **' and 'const void **') use non-standard composite pointer type 'const void *const *'}}
+}
diff --git a/clang/test/SemaCXX/compound-literal.cpp b/clang/test/SemaCXX/compound-literal.cpp
new file mode 100644
index 0000000..fe0e45d
--- /dev/null
+++ b/clang/test/SemaCXX/compound-literal.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// http://llvm.org/PR7905
+namespace PR7905 {
+struct S; // expected-note {{forward declaration}}
+void foo1() {
+ (void)(S[]) {{3}}; // expected-error {{array has incomplete element type}}
+}
+
+template <typename T> struct M { T m; };
+void foo2() {
+ (void)(M<short> []) {{3}};
+}
+}
diff --git a/clang/test/SemaCXX/condition.cpp b/clang/test/SemaCXX/condition.cpp
new file mode 100644
index 0000000..993f8e1
--- /dev/null
+++ b/clang/test/SemaCXX/condition.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void test() {
+ int x;
+ if (x) ++x;
+ if (int x=0) ++x;
+
+ typedef int arr[10];
+ while (arr x=0) ; // expected-error {{an array type is not allowed here}} expected-error {{array initializer must be an initializer list}}
+ while (int f()=0) ; // expected-warning {{interpreted as a function declaration}} expected-note {{initializer}} expected-error {{a function type is not allowed here}}
+
+ struct S {} s;
+ if (s) ++x; // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}}
+ while (struct S x=s) ; // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}}
+ do ; while (s); // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}}
+ for (;s;) ; // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}}
+ switch (s) {} // expected-error {{statement requires expression of integer type ('struct S' invalid)}}
+
+ while (struct NewS *x=0) ;
+ while (struct S {} *x=0) ; // expected-error {{types may not be defined in conditions}}
+ while (struct {} *x=0) ; // expected-error {{types may not be defined in conditions}}
+ switch (enum {E} x=0) ; // expected-error {{types may not be defined in conditions}} expected-error {{cannot initialize}} \
+ // expected-warning{{enumeration value 'E' not handled in switch}} expected-warning {{switch statement has empty body}} \
+ // expected-note{{put the semicolon on a separate line}}
+
+ if (int x=0) { // expected-note 2 {{previous definition is here}}
+ int x; // expected-error {{redefinition of 'x'}}
+ }
+ else
+ int x; // expected-error {{redefinition of 'x'}}
+ while (int x=0) int x; // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
+ while (int x=0) { int x; } // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
+ for (int x; int x=0; ) ; // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
+ for (int x; ; ) int x; // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
+ for (; int x=0; ) int x; // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
+ for (; int x=0; ) { int x; } // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
+ switch (int x=0) { default: int x; } // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}}
+}
+
+int* get_int_ptr();
+
+void test2() {
+ float *ip;
+ if (int *ip = ip) {
+ }
+}
+
+// Make sure we do function/array decay.
+void test3() {
+ if ("help")
+ (void) 0;
+
+ if (test3) // expected-warning {{address of function 'test3' will always evaluate to 'true'}} \
+ expected-note {{prefix with the address-of operator to silence this warning}}
+ (void) 0;
+}
+
+void test4(bool (&x)(void)) {
+ while (x);
+}
diff --git a/clang/test/SemaCXX/conditional-expr.cpp b/clang/test/SemaCXX/conditional-expr.cpp
new file mode 100644
index 0000000..4aee913
--- /dev/null
+++ b/clang/test/SemaCXX/conditional-expr.cpp
@@ -0,0 +1,330 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -Wsign-conversion %s
+
+// C++ rules for ?: are a lot stricter than C rules, and have to take into
+// account more conversion options.
+// This test runs in C++0x mode for the contextual conversion of the condition.
+
+struct ToBool { explicit operator bool(); };
+
+struct B;
+struct A {
+ A();
+ A(const B&); // expected-note 2 {{candidate constructor}}
+};
+struct B { operator A() const; }; // expected-note 2 {{candidate function}}
+struct I { operator int(); };
+struct J { operator I(); };
+struct K { operator double(); };
+typedef void (*vfn)();
+struct F { operator vfn(); };
+struct G { operator vfn(); };
+
+struct Base {
+ int trick();
+ A trick() const;
+ void fn1();
+};
+struct Derived : Base {
+ void fn2();
+};
+struct Convertible { operator Base&(); };
+struct Priv : private Base {}; // expected-note 4 {{declared private here}}
+struct Mid : Base {};
+struct Fin : Mid, Derived {};
+typedef void (Derived::*DFnPtr)();
+struct ToMemPtr { operator DFnPtr(); };
+
+struct BadDerived;
+struct BadBase { operator BadDerived&(); };
+struct BadDerived : BadBase {};
+
+struct Fields {
+ int i1, i2, b1 : 3, b2 : 3;
+};
+struct MixedFields {
+ int i;
+ volatile int vi;
+ const int ci;
+ const volatile int cvi;
+};
+struct MixedFieldsDerived : MixedFields {
+};
+
+enum Enum { EVal };
+
+struct Ambig {
+ operator short(); // expected-note 2 {{candidate function}}
+ operator signed char(); // expected-note 2 {{candidate function}}
+};
+
+void test()
+{
+ // This function tests C++0x 5.16
+
+ // p1 (contextually convert to bool)
+ int i1 = ToBool() ? 0 : 1;
+
+ // p2 (one or both void, and throwing)
+ i1 ? throw 0 : throw 1;
+ i1 ? test() : throw 1;
+ i1 ? throw 0 : test();
+ i1 ? test() : test();
+ i1 = i1 ? throw 0 : 0;
+ i1 = i1 ? 0 : throw 0;
+ i1 ? 0 : test(); // expected-error {{right operand to ? is void, but left operand is of type 'int'}}
+ i1 ? test() : 0; // expected-error {{left operand to ? is void, but right operand is of type 'int'}}
+ (i1 ? throw 0 : i1) = 0; // expected-error {{expression is not assignable}}
+ (i1 ? i1 : throw 0) = 0; // expected-error {{expression is not assignable}}
+
+ // p3 (one or both class type, convert to each other)
+ // b1 (lvalues)
+ Base base;
+ Derived derived;
+ Convertible conv;
+ Base &bar1 = i1 ? base : derived;
+ Base &bar2 = i1 ? derived : base;
+ Base &bar3 = i1 ? base : conv;
+ Base &bar4 = i1 ? conv : base;
+ // these are ambiguous
+ BadBase bb;
+ BadDerived bd;
+ (void)(i1 ? bb : bd); // expected-error {{conditional expression is ambiguous; 'BadBase' can be converted to 'BadDerived' and vice versa}}
+ (void)(i1 ? bd : bb); // expected-error {{conditional expression is ambiguous}}
+ // curiously enough (and a defect?), these are not
+ // for rvalues, hierarchy takes precedence over other conversions
+ (void)(i1 ? BadBase() : BadDerived());
+ (void)(i1 ? BadDerived() : BadBase());
+
+ // b2.1 (hierarchy stuff)
+ extern const Base constret();
+ extern const Derived constder();
+ // should use const overload
+ A a1((i1 ? constret() : Base()).trick());
+ A a2((i1 ? Base() : constret()).trick());
+ A a3((i1 ? constret() : Derived()).trick());
+ A a4((i1 ? Derived() : constret()).trick());
+ // should use non-const overload
+ i1 = (i1 ? Base() : Base()).trick();
+ i1 = (i1 ? Base() : Base()).trick();
+ i1 = (i1 ? Base() : Derived()).trick();
+ i1 = (i1 ? Derived() : Base()).trick();
+ // should fail: const lost
+ (void)(i1 ? Base() : constder()); // expected-error {{incompatible operand types ('Base' and 'const Derived')}}
+ (void)(i1 ? constder() : Base()); // expected-error {{incompatible operand types ('const Derived' and 'Base')}}
+
+ Priv priv;
+ Fin fin;
+ (void)(i1 ? Base() : Priv()); // expected-error{{private base class}}
+ (void)(i1 ? Priv() : Base()); // expected-error{{private base class}}
+ (void)(i1 ? Base() : Fin()); // expected-error{{ambiguous conversion from derived class 'Fin' to base class 'Base':}}
+ (void)(i1 ? Fin() : Base()); // expected-error{{ambiguous conversion from derived class 'Fin' to base class 'Base':}}
+ (void)(i1 ? base : priv); // expected-error {{private base class}}
+ (void)(i1 ? priv : base); // expected-error {{private base class}}
+ (void)(i1 ? base : fin); // expected-error {{ambiguous conversion from derived class 'Fin' to base class 'Base':}}
+ (void)(i1 ? fin : base); // expected-error {{ambiguous conversion from derived class 'Fin' to base class 'Base':}}
+
+ // b2.2 (non-hierarchy)
+ i1 = i1 ? I() : i1;
+ i1 = i1 ? i1 : I();
+ I i2(i1 ? I() : J());
+ I i3(i1 ? J() : I());
+ // "the type [it] woud have if E2 were converted to an rvalue"
+ vfn pfn = i1 ? F() : test;
+ pfn = i1 ? test : F();
+ (void)(i1 ? A() : B()); // expected-error {{conversion from 'B' to 'A' is ambiguous}}
+ (void)(i1 ? B() : A()); // expected-error {{conversion from 'B' to 'A' is ambiguous}}
+ (void)(i1 ? 1 : Ambig()); // expected-error {{conversion from 'Ambig' to 'int' is ambiguous}}
+ (void)(i1 ? Ambig() : 1); // expected-error {{conversion from 'Ambig' to 'int' is ambiguous}}
+ // By the way, this isn't an lvalue:
+ &(i1 ? i1 : i2); // expected-error {{address expression must be an lvalue or a function designator}}
+
+ // p4 (lvalue, same type)
+ Fields flds;
+ int &ir1 = i1 ? flds.i1 : flds.i2;
+ (i1 ? flds.b1 : flds.i2) = 0;
+ (i1 ? flds.i1 : flds.b2) = 0;
+ (i1 ? flds.b1 : flds.b2) = 0;
+
+ // p5 (conversion to built-in types)
+ // GCC 4.3 fails these
+ double d1 = i1 ? I() : K();
+ pfn = i1 ? F() : G();
+ DFnPtr pfm;
+ pfm = i1 ? DFnPtr() : &Base::fn1;
+ pfm = i1 ? &Base::fn1 : DFnPtr();
+
+ // p6 (final conversions)
+ i1 = i1 ? i1 : ir1;
+ int *pi1 = i1 ? &i1 : 0;
+ pi1 = i1 ? 0 : &i1;
+ i1 = i1 ? i1 : EVal;
+ i1 = i1 ? EVal : i1;
+ d1 = i1 ? 'c' : 4.0;
+ d1 = i1 ? 4.0 : 'c';
+ Base *pb = i1 ? (Base*)0 : (Derived*)0;
+ pb = i1 ? (Derived*)0 : (Base*)0;
+ pfm = i1 ? &Base::fn1 : &Derived::fn2;
+ pfm = i1 ? &Derived::fn2 : &Base::fn1;
+ pfm = i1 ? &Derived::fn2 : 0;
+ pfm = i1 ? 0 : &Derived::fn2;
+ const int (MixedFieldsDerived::*mp1) =
+ i1 ? &MixedFields::ci : &MixedFieldsDerived::i;
+ const volatile int (MixedFields::*mp2) =
+ i1 ? &MixedFields::ci : &MixedFields::cvi;
+ (void)(i1 ? &MixedFields::ci : &MixedFields::vi);
+ // Conversion of primitives does not result in an lvalue.
+ &(i1 ? i1 : d1); // expected-error {{address expression must be an lvalue or a function designator}}
+
+ (void)&(i1 ? flds.b1 : flds.i1); // expected-error {{address of bit-field requested}}
+ (void)&(i1 ? flds.i1 : flds.b1); // expected-error {{address of bit-field requested}}
+
+
+ unsigned long test0 = 5;
+ test0 = test0 ? (long) test0 : test0; // expected-warning {{operand of ? changes signedness: 'long' to 'unsigned long'}}
+ test0 = test0 ? (int) test0 : test0; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
+ test0 = test0 ? (short) test0 : test0; // expected-warning {{operand of ? changes signedness: 'short' to 'unsigned long'}}
+ test0 = test0 ? test0 : (long) test0; // expected-warning {{operand of ? changes signedness: 'long' to 'unsigned long'}}
+ test0 = test0 ? test0 : (int) test0; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
+ test0 = test0 ? test0 : (short) test0; // expected-warning {{operand of ? changes signedness: 'short' to 'unsigned long'}}
+ test0 = test0 ? test0 : (long) 10;
+ test0 = test0 ? test0 : (int) 10;
+ test0 = test0 ? test0 : (short) 10;
+ test0 = test0 ? (long) 10 : test0;
+ test0 = test0 ? (int) 10 : test0;
+ test0 = test0 ? (short) 10 : test0;
+
+ int test1;
+ test0 = test0 ? EVal : test0;
+ test1 = test0 ? EVal : (int) test0;
+
+ test0 = test0 ? EVal : test1; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
+ test0 = test0 ? test1 : EVal; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
+
+ test1 = test0 ? EVal : (int) test0;
+ test1 = test0 ? (int) test0 : EVal;
+
+ // Note the thing that this does not test: since DR446, various situations
+ // *must* create a separate temporary copy of class objects. This can only
+ // be properly tested at runtime, though.
+}
+
+namespace PR6595 {
+ struct OtherString {
+ OtherString();
+ OtherString(const char*);
+ };
+
+ struct String {
+ String(const char *);
+ String(const OtherString&);
+ operator const char*() const;
+ };
+
+ void f(bool Cond, String S, OtherString OS) {
+ (void)(Cond? S : "");
+ (void)(Cond? "" : S);
+ const char a[1] = {'a'};
+ (void)(Cond? S : a);
+ (void)(Cond? a : S);
+ (void)(Cond? OS : S);
+ }
+}
+
+namespace PR6757 {
+ struct Foo1 {
+ Foo1();
+ Foo1(const Foo1&);
+ };
+
+ struct Foo2 { };
+
+ struct Foo3 {
+ Foo3();
+ Foo3(Foo3&); // expected-note{{would lose const qualifier}}
+ };
+
+ struct Bar {
+ operator const Foo1&() const;
+ operator const Foo2&() const;
+ operator const Foo3&() const;
+ };
+
+ void f() {
+ (void)(true ? Bar() : Foo1()); // okay
+ (void)(true ? Bar() : Foo2()); // okay
+ (void)(true ? Bar() : Foo3()); // expected-error{{no viable constructor copying temporary}}
+ }
+}
+
+// Reduced from selfhost.
+namespace test1 {
+ struct A {
+ enum Foo {
+ fa, fb, fc, fd, fe, ff
+ };
+
+ Foo x();
+ };
+
+ void foo(int);
+
+ void test(A *a) {
+ foo(a ? a->x() : 0);
+ }
+}
+
+namespace rdar7998817 {
+ class X {
+ X(X&); // expected-note{{declared private here}}
+
+ struct ref { };
+
+ public:
+ X();
+ X(ref);
+
+ operator ref();
+ };
+
+ void f(bool B) {
+ X x;
+ (void)(B? x // expected-error{{calling a private constructor of class 'rdar7998817::X'}}
+ : X());
+ }
+}
+
+namespace PR7598 {
+ enum Enum {
+ v = 1,
+ };
+
+ const Enum g() {
+ return v;
+ }
+
+ const volatile Enum g2() {
+ return v;
+ }
+
+ void f() {
+ const Enum v2 = v;
+ Enum e = false ? g() : v;
+ Enum e2 = false ? v2 : v;
+ Enum e3 = false ? g2() : v;
+ }
+
+}
+
+namespace PR9236 {
+#define NULL 0L
+ void f() {
+ int i;
+ (void)(true ? A() : NULL); // expected-error{{non-pointer operand type 'A' incompatible with NULL}}
+ (void)(true ? NULL : A()); // expected-error{{non-pointer operand type 'A' incompatible with NULL}}
+ (void)(true ? 0 : A()); // expected-error{{incompatible operand types}}
+ (void)(true ? nullptr : A()); // expected-error{{non-pointer operand type 'A' incompatible with nullptr}}
+ (void)(true ? nullptr : i); // expected-error{{non-pointer operand type 'int' incompatible with nullptr}}
+ (void)(true ? __null : A()); // expected-error{{non-pointer operand type 'A' incompatible with NULL}}
+ (void)(true ? (void*)0 : A()); // expected-error{{incompatible operand types}}
+ }
+}
diff --git a/clang/test/SemaCXX/const-cast.cpp b/clang/test/SemaCXX/const-cast.cpp
new file mode 100644
index 0000000..62851f8
--- /dev/null
+++ b/clang/test/SemaCXX/const-cast.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {};
+
+// See if aliasing can confuse this baby.
+typedef char c;
+typedef c *cp;
+typedef cp *cpp;
+typedef cpp *cppp;
+typedef cppp &cpppr;
+typedef const cppp &cpppcr;
+typedef const char cc;
+typedef cc *ccp;
+typedef volatile ccp ccvp;
+typedef ccvp *ccvpp;
+typedef const volatile ccvpp ccvpcvp;
+typedef ccvpcvp *ccvpcvpp;
+typedef int iar[100];
+typedef iar &iarr;
+typedef int (*f)(int);
+
+char ***good_const_cast_test(ccvpcvpp var)
+{
+ // Cast away deep consts and volatiles.
+ char ***var2 = const_cast<cppp>(var);
+ char ***const &var3 = var2;
+ // Const reference to reference.
+ char ***&var4 = const_cast<cpppr>(var3);
+ // Drop reference. Intentionally without qualifier change.
+ char *** var5 = const_cast<cppp>(var4);
+ // Const array to array reference.
+ const int ar[100] = {0};
+ int (&rar)[100] = const_cast<iarr>(ar);
+ // Array decay. Intentionally without qualifier change.
+ int *pi = const_cast<int*>(ar);
+ f fp = 0;
+ // Don't misidentify fn** as a function pointer.
+ f *fpp = const_cast<f*>(&fp);
+ int const A::* const A::*icapcap = 0;
+ int A::* A::* iapap = const_cast<int A::* A::*>(icapcap);
+
+ return var4;
+}
+
+short *bad_const_cast_test(char const *volatile *const volatile *var)
+{
+ // Different pointer levels.
+ char **var2 = const_cast<char**>(var); // expected-error {{const_cast from 'const char *volatile *const volatile *' to 'char **' is not allowed}}
+ // Different final type.
+ short ***var3 = const_cast<short***>(var); // expected-error {{const_cast from 'const char *volatile *const volatile *' to 'short ***' is not allowed}}
+ // Rvalue to reference.
+ char ***&var4 = const_cast<cpppr>(&var2); // expected-error {{const_cast from rvalue to reference type 'cpppr'}}
+ // Non-pointer.
+ char v = const_cast<char>(**var2); // expected-error {{const_cast to 'char', which is not a reference, pointer-to-object, or pointer-to-data-member}}
+ const int *ar[100] = {0};
+ // Not even lenient g++ accepts this.
+ int *(*rar)[100] = const_cast<int *(*)[100]>(&ar); // expected-error {{const_cast from 'const int *(*)[100]' to 'int *(*)[100]' is not allowed}}
+ f fp1 = 0;
+ // Function pointers.
+ f fp2 = const_cast<f>(fp1); // expected-error {{const_cast to 'f' (aka 'int (*)(int)'), which is not a reference, pointer-to-object, or pointer-to-data-member}}
+ void (A::*mfn)() = 0;
+ (void)const_cast<void (A::*)()>(mfn); // expected-error {{const_cast to 'void (A::*)()', which is not a reference, pointer-to-object, or pointer-to-data-member}}
+ return **var3;
+}
diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp
new file mode 100644
index 0000000..9f80e71
--- /dev/null
+++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -0,0 +1,1250 @@
+// RUN: %clang_cc1 -triple i686-linux -Wno-string-plus-int -fsyntax-only -verify -std=c++11 -pedantic %s -Wno-comment
+
+namespace StaticAssertFoldTest {
+
+int x;
+static_assert(++x, "test"); // expected-error {{not an integral constant expression}}
+static_assert(false, "test"); // expected-error {{test}}
+
+}
+
+typedef decltype(sizeof(char)) size_t;
+
+template<typename T> constexpr T id(const T &t) { return t; }
+template<typename T> constexpr T min(const T &a, const T &b) {
+ return a < b ? a : b;
+}
+template<typename T> constexpr T max(const T &a, const T &b) {
+ return a < b ? b : a;
+}
+template<typename T, size_t N> constexpr T *begin(T (&xs)[N]) { return xs; }
+template<typename T, size_t N> constexpr T *end(T (&xs)[N]) { return xs + N; }
+
+struct MemberZero {
+ constexpr int zero() { return 0; }
+};
+
+namespace DerivedToVBaseCast {
+
+ struct U { int n; };
+ struct V : U { int n; };
+ struct A : virtual V { int n; };
+ struct Aa { int n; };
+ struct B : virtual A, Aa {};
+ struct C : virtual A, Aa {};
+ struct D : B, C {};
+
+ D d;
+ constexpr B *p = &d;
+ constexpr C *q = &d;
+
+ static_assert((void*)p != (void*)q, "");
+ static_assert((A*)p == (A*)q, "");
+ static_assert((Aa*)p != (Aa*)q, "");
+
+ constexpr B &pp = d;
+ constexpr C &qq = d;
+ static_assert((void*)&pp != (void*)&qq, "");
+ static_assert(&(A&)pp == &(A&)qq, "");
+ static_assert(&(Aa&)pp != &(Aa&)qq, "");
+
+ constexpr V *v = p;
+ constexpr V *w = q;
+ constexpr V *x = (A*)p;
+ static_assert(v == w, "");
+ static_assert(v == x, "");
+
+ static_assert((U*)&d == p, "");
+ static_assert((U*)&d == q, "");
+ static_assert((U*)&d == v, "");
+ static_assert((U*)&d == w, "");
+ static_assert((U*)&d == x, "");
+
+ struct X {};
+ struct Y1 : virtual X {};
+ struct Y2 : X {};
+ struct Z : Y1, Y2 {};
+ Z z;
+ static_assert((X*)(Y1*)&z != (X*)(Y2*)&z, "");
+}
+
+namespace ConstCast {
+
+constexpr int n1 = 0;
+constexpr int n2 = const_cast<int&>(n1);
+constexpr int *n3 = const_cast<int*>(&n1);
+constexpr int n4 = *const_cast<int*>(&n1);
+constexpr const int * const *n5 = const_cast<const int* const*>(&n3);
+constexpr int **n6 = const_cast<int**>(&n3);
+constexpr int n7 = **n5;
+constexpr int n8 = **n6;
+
+}
+
+namespace TemplateArgumentConversion {
+ template<int n> struct IntParam {};
+
+ using IntParam0 = IntParam<0>;
+ using IntParam0 = IntParam<id(0)>;
+ using IntParam0 = IntParam<MemberZero().zero>; // expected-error {{did you mean to call it with no arguments?}}
+}
+
+namespace CaseStatements {
+ void f(int n) {
+ switch (n) {
+ case MemberZero().zero: // expected-error {{did you mean to call it with no arguments?}} expected-note {{previous}}
+ case id(0): // expected-error {{duplicate case value '0'}}
+ return;
+ }
+ }
+}
+
+extern int &Recurse1;
+int &Recurse2 = Recurse1; // expected-note {{declared here}}
+int &Recurse1 = Recurse2;
+constexpr int &Recurse3 = Recurse2; // expected-error {{must be initialized by a constant expression}} expected-note {{initializer of 'Recurse2' is not a constant expression}}
+
+extern const int RecurseA;
+const int RecurseB = RecurseA; // expected-note {{declared here}}
+const int RecurseA = 10;
+constexpr int RecurseC = RecurseB; // expected-error {{must be initialized by a constant expression}} expected-note {{initializer of 'RecurseB' is not a constant expression}}
+
+namespace MemberEnum {
+ struct WithMemberEnum {
+ enum E { A = 42 };
+ } wme;
+
+ static_assert(wme.A == 42, "");
+}
+
+namespace DefaultArguments {
+
+const int z = int();
+constexpr int Sum(int a = 0, const int &b = 0, const int *c = &z, char d = 0) {
+ return a + b + *c + d;
+}
+const int four = 4;
+constexpr int eight = 8;
+constexpr const int twentyseven = 27;
+static_assert(Sum() == 0, "");
+static_assert(Sum(1) == 1, "");
+static_assert(Sum(1, four) == 5, "");
+static_assert(Sum(1, eight, &twentyseven) == 36, "");
+static_assert(Sum(1, 2, &four, eight) == 15, "");
+
+}
+
+namespace Ellipsis {
+
+// Note, values passed through an ellipsis can't actually be used.
+constexpr int F(int a, ...) { return a; }
+static_assert(F(0) == 0, "");
+static_assert(F(1, 0) == 1, "");
+static_assert(F(2, "test") == 2, "");
+static_assert(F(3, &F) == 3, "");
+int k = 0; // expected-note {{here}}
+static_assert(F(4, k) == 3, ""); // expected-error {{constant expression}} expected-note {{read of non-const variable 'k'}}
+
+}
+
+namespace Recursion {
+ constexpr int fib(int n) { return n > 1 ? fib(n-1) + fib(n-2) : n; }
+ static_assert(fib(11) == 89, "");
+
+ constexpr int gcd_inner(int a, int b) {
+ return b == 0 ? a : gcd_inner(b, a % b);
+ }
+ constexpr int gcd(int a, int b) {
+ return gcd_inner(max(a, b), min(a, b));
+ }
+
+ static_assert(gcd(1749237, 5628959) == 7, "");
+}
+
+namespace FunctionCast {
+ // When folding, we allow functions to be cast to different types. Such
+ // cast functions cannot be called, even if they're constexpr.
+ constexpr int f() { return 1; }
+ typedef double (*DoubleFn)();
+ typedef int (*IntFn)();
+ int a[(int)DoubleFn(f)()]; // expected-error {{variable length array}} expected-warning{{C99 feature}}
+ int b[(int)IntFn(f)()]; // ok
+}
+
+namespace StaticMemberFunction {
+ struct S {
+ static constexpr int k = 42;
+ static constexpr int f(int n) { return n * k + 2; }
+ } s;
+
+ constexpr int n = s.f(19);
+ static_assert(S::f(19) == 800, "");
+ static_assert(s.f(19) == 800, "");
+ static_assert(n == 800, "");
+
+ constexpr int (*sf1)(int) = &S::f;
+ constexpr int (*sf2)(int) = &s.f;
+ constexpr const int *sk = &s.k;
+}
+
+namespace ParameterScopes {
+
+ const int k = 42;
+ constexpr const int &ObscureTheTruth(const int &a) { return a; }
+ constexpr const int &MaybeReturnJunk(bool b, const int a) { // expected-note 2{{declared here}}
+ return ObscureTheTruth(b ? a : k);
+ }
+ static_assert(MaybeReturnJunk(false, 0) == 42, ""); // ok
+ constexpr int a = MaybeReturnJunk(true, 0); // expected-error {{constant expression}} expected-note {{read of variable whose lifetime has ended}}
+
+ constexpr const int MaybeReturnNonstaticRef(bool b, const int a) {
+ return ObscureTheTruth(b ? a : k);
+ }
+ static_assert(MaybeReturnNonstaticRef(false, 0) == 42, ""); // ok
+ constexpr int b = MaybeReturnNonstaticRef(true, 0); // ok
+
+ constexpr int InternalReturnJunk(int n) {
+ return MaybeReturnJunk(true, n); // expected-note {{read of variable whose lifetime has ended}}
+ }
+ constexpr int n3 = InternalReturnJunk(0); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'InternalReturnJunk(0)'}}
+
+ constexpr int LToR(int &n) { return n; }
+ constexpr int GrabCallersArgument(bool which, int a, int b) {
+ return LToR(which ? b : a);
+ }
+ static_assert(GrabCallersArgument(false, 1, 2) == 1, "");
+ static_assert(GrabCallersArgument(true, 4, 8) == 8, "");
+
+}
+
+namespace Pointers {
+
+ constexpr int f(int n, const int *a, const int *b, const int *c) {
+ return n == 0 ? 0 : *a + f(n-1, b, c, a);
+ }
+
+ const int x = 1, y = 10, z = 100;
+ static_assert(f(23, &x, &y, &z) == 788, "");
+
+ constexpr int g(int n, int a, int b, int c) {
+ return f(n, &a, &b, &c);
+ }
+ static_assert(g(23, x, y, z) == 788, "");
+
+}
+
+namespace FunctionPointers {
+
+ constexpr int Double(int n) { return 2 * n; }
+ constexpr int Triple(int n) { return 3 * n; }
+ constexpr int Twice(int (*F)(int), int n) { return F(F(n)); }
+ constexpr int Quadruple(int n) { return Twice(Double, n); }
+ constexpr auto Select(int n) -> int (*)(int) {
+ return n == 2 ? &Double : n == 3 ? &Triple : n == 4 ? &Quadruple : 0;
+ }
+ constexpr int Apply(int (*F)(int), int n) { return F(n); } // expected-note {{subexpression}}
+
+ static_assert(1 + Apply(Select(4), 5) + Apply(Select(3), 7) == 42, "");
+
+ constexpr int Invalid = Apply(Select(0), 0); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'Apply(0, 0)'}}
+
+}
+
+namespace PointerComparison {
+
+int x, y;
+static_assert(&x == &y, "false"); // expected-error {{false}}
+static_assert(&x != &y, "");
+constexpr bool g1 = &x == &y;
+constexpr bool g2 = &x != &y;
+constexpr bool g3 = &x <= &y; // expected-error {{must be initialized by a constant expression}}
+constexpr bool g4 = &x >= &y; // expected-error {{must be initialized by a constant expression}}
+constexpr bool g5 = &x < &y; // expected-error {{must be initialized by a constant expression}}
+constexpr bool g6 = &x > &y; // expected-error {{must be initialized by a constant expression}}
+
+struct S { int x, y; } s;
+static_assert(&s.x == &s.y, "false"); // expected-error {{false}}
+static_assert(&s.x != &s.y, "");
+static_assert(&s.x <= &s.y, "");
+static_assert(&s.x >= &s.y, "false"); // expected-error {{false}}
+static_assert(&s.x < &s.y, "");
+static_assert(&s.x > &s.y, "false"); // expected-error {{false}}
+
+static_assert(0 == &y, "false"); // expected-error {{false}}
+static_assert(0 != &y, "");
+constexpr bool n3 = 0 <= &y; // expected-error {{must be initialized by a constant expression}}
+constexpr bool n4 = 0 >= &y; // expected-error {{must be initialized by a constant expression}}
+constexpr bool n5 = 0 < &y; // expected-error {{must be initialized by a constant expression}}
+constexpr bool n6 = 0 > &y; // expected-error {{must be initialized by a constant expression}}
+
+static_assert(&x == 0, "false"); // expected-error {{false}}
+static_assert(&x != 0, "");
+constexpr bool n9 = &x <= 0; // expected-error {{must be initialized by a constant expression}}
+constexpr bool n10 = &x >= 0; // expected-error {{must be initialized by a constant expression}}
+constexpr bool n11 = &x < 0; // expected-error {{must be initialized by a constant expression}}
+constexpr bool n12 = &x > 0; // expected-error {{must be initialized by a constant expression}}
+
+static_assert(&x == &x, "");
+static_assert(&x != &x, "false"); // expected-error {{false}}
+static_assert(&x <= &x, "");
+static_assert(&x >= &x, "");
+static_assert(&x < &x, "false"); // expected-error {{false}}
+static_assert(&x > &x, "false"); // expected-error {{false}}
+
+constexpr S* sptr = &s;
+constexpr bool dyncast = sptr == dynamic_cast<S*>(sptr); // expected-error {{constant expression}} expected-note {{dynamic_cast}}
+
+struct U {};
+struct Str {
+ int a : dynamic_cast<S*>(sptr) == dynamic_cast<S*>(sptr); // \
+ expected-warning {{not an integral constant expression}} \
+ expected-note {{dynamic_cast is not allowed in a constant expression}}
+ int b : reinterpret_cast<S*>(sptr) == reinterpret_cast<S*>(sptr); // \
+ expected-warning {{not an integral constant expression}} \
+ expected-note {{reinterpret_cast is not allowed in a constant expression}}
+ int c : (S*)(long)(sptr) == (S*)(long)(sptr); // \
+ expected-warning {{not an integral constant expression}} \
+ expected-note {{cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
+ int d : (S*)(42) == (S*)(42); // \
+ expected-warning {{not an integral constant expression}} \
+ expected-note {{cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
+ int e : (Str*)(sptr) == (Str*)(sptr); // \
+ expected-warning {{not an integral constant expression}} \
+ expected-note {{cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
+ int f : &(U&)(*sptr) == &(U&)(*sptr); // \
+ expected-warning {{not an integral constant expression}} \
+ expected-note {{cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
+ int g : (S*)(void*)(sptr) == sptr; // \
+ expected-warning {{not an integral constant expression}} \
+ expected-note {{cast from 'void *' is not allowed in a constant expression}}
+};
+
+extern char externalvar[];
+constexpr bool constaddress = (void *)externalvar == (void *)0x4000UL; // expected-error {{must be initialized by a constant expression}}
+constexpr bool litaddress = "foo" == "foo"; // expected-error {{must be initialized by a constant expression}} expected-warning {{unspecified}}
+static_assert(0 != "foo", "");
+
+}
+
+namespace MaterializeTemporary {
+
+constexpr int f(const int &r) { return r; }
+constexpr int n = f(1);
+
+constexpr bool same(const int &a, const int &b) { return &a == &b; }
+constexpr bool sameTemporary(const int &n) { return same(n, n); }
+
+static_assert(n, "");
+static_assert(!same(4, 4), "");
+static_assert(same(n, n), "");
+static_assert(sameTemporary(9), "");
+
+}
+
+constexpr int strcmp_ce(const char *p, const char *q) {
+ return (!*p || *p != *q) ? *p - *q : strcmp_ce(p+1, q+1);
+}
+
+namespace StringLiteral {
+
+template<typename Char>
+constexpr int MangleChars(const Char *p) {
+ return *p + 3 * (*p ? MangleChars(p+1) : 0);
+}
+
+static_assert(MangleChars("constexpr!") == 1768383, "");
+static_assert(MangleChars(u8"constexpr!") == 1768383, "");
+static_assert(MangleChars(L"constexpr!") == 1768383, "");
+static_assert(MangleChars(u"constexpr!") == 1768383, "");
+static_assert(MangleChars(U"constexpr!") == 1768383, "");
+
+constexpr char c0 = "nought index"[0];
+constexpr char c1 = "nice index"[10];
+constexpr char c2 = "nasty index"[12]; // expected-error {{must be initialized by a constant expression}} expected-warning {{is past the end}} expected-note {{read of dereferenced one-past-the-end pointer}}
+constexpr char c3 = "negative index"[-1]; // expected-error {{must be initialized by a constant expression}} expected-warning {{is before the beginning}} expected-note {{cannot refer to element -1 of array of 15 elements}}
+constexpr char c4 = ((char*)(int*)"no reinterpret_casts allowed")[14]; // expected-error {{must be initialized by a constant expression}} expected-note {{cast which performs the conversions of a reinterpret_cast}}
+
+constexpr const char *p = "test" + 2;
+static_assert(*p == 's', "");
+
+constexpr const char *max_iter(const char *a, const char *b) {
+ return *a < *b ? b : a;
+}
+constexpr const char *max_element(const char *a, const char *b) {
+ return (a+1 >= b) ? a : max_iter(a, max_element(a+1, b));
+}
+
+constexpr char str[] = "the quick brown fox jumped over the lazy dog";
+constexpr const char *max = max_element(begin(str), end(str));
+static_assert(*max == 'z', "");
+static_assert(max == str + 38, "");
+
+static_assert(strcmp_ce("hello world", "hello world") == 0, "");
+static_assert(strcmp_ce("hello world", "hello clang") > 0, "");
+static_assert(strcmp_ce("constexpr", "test") < 0, "");
+static_assert(strcmp_ce("", " ") < 0, "");
+
+struct S {
+ int n : "foo"[4]; // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer is not allowed in a constant expression}}
+};
+
+struct T {
+ char c[6];
+ constexpr T() : c{"foo"} {}
+};
+constexpr T t;
+
+static_assert(t.c[0] == 'f', "");
+static_assert(t.c[1] == 'o', "");
+static_assert(t.c[2] == 'o', "");
+static_assert(t.c[3] == 0, "");
+static_assert(t.c[4] == 0, "");
+static_assert(t.c[5] == 0, "");
+static_assert(t.c[6] == 0, ""); // expected-error {{constant expression}} expected-note {{one-past-the-end}}
+
+struct U {
+ wchar_t chars[6];
+ int n;
+} constexpr u = { { L"test" }, 0 };
+static_assert(u.chars[2] == L's', "");
+
+struct V {
+ char c[4];
+ constexpr V() : c("hi!") {}
+};
+static_assert(V().c[1] == "i"[0], "");
+
+}
+
+namespace Array {
+
+template<typename Iter>
+constexpr auto Sum(Iter begin, Iter end) -> decltype(+*begin) {
+ return begin == end ? 0 : *begin + Sum(begin+1, end);
+}
+
+constexpr int xs[] = { 1, 2, 3, 4, 5 };
+constexpr int ys[] = { 5, 4, 3, 2, 1 };
+constexpr int sum_xs = Sum(begin(xs), end(xs));
+static_assert(sum_xs == 15, "");
+
+constexpr int ZipFoldR(int (*F)(int x, int y, int c), int n,
+ const int *xs, const int *ys, int c) {
+ return n ? F(
+ *xs, // expected-note {{read of dereferenced one-past-the-end pointer}}
+ *ys,
+ ZipFoldR(F, n-1, xs+1, ys+1, c)) // \
+ expected-note {{in call to 'ZipFoldR(&SubMul, 2, &xs[4], &ys[4], 1)'}} \
+ expected-note {{in call to 'ZipFoldR(&SubMul, 1, &xs[5], &ys[5], 1)'}}
+ : c;
+}
+constexpr int MulAdd(int x, int y, int c) { return x * y + c; }
+constexpr int InnerProduct = ZipFoldR(MulAdd, 5, xs, ys, 0);
+static_assert(InnerProduct == 35, "");
+
+constexpr int SubMul(int x, int y, int c) { return (x - y) * c; }
+constexpr int DiffProd = ZipFoldR(SubMul, 2, xs+3, ys+3, 1);
+static_assert(DiffProd == 8, "");
+static_assert(ZipFoldR(SubMul, 3, xs+3, ys+3, 1), ""); // \
+ expected-error {{constant expression}} \
+ expected-note {{in call to 'ZipFoldR(&SubMul, 3, &xs[3], &ys[3], 1)'}}
+
+constexpr const int *p = xs + 3;
+constexpr int xs4 = p[1]; // ok
+constexpr int xs5 = p[2]; // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
+constexpr int xs6 = p[3]; // expected-error {{constant expression}} expected-note {{cannot refer to element 6}}
+constexpr int xs0 = p[-3]; // ok
+constexpr int xs_1 = p[-4]; // expected-error {{constant expression}} expected-note {{cannot refer to element -1}}
+
+constexpr int zs[2][2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+static_assert(zs[0][0][0][0] == 1, "");
+static_assert(zs[1][1][1][1] == 16, "");
+static_assert(zs[0][0][0][2] == 3, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
+static_assert((&zs[0][0][0][2])[-1] == 2, "");
+static_assert(**(**(zs + 1) + 1) == 11, "");
+static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][-1] + 1) == 11, ""); // expected-error {{constant expression}} expected-note {{cannot refer to element -1 of array of 2 elements in a constant expression}}
+static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2) == 11, "");
+constexpr int err_zs_1_2_0_0 = zs[1][2][0][0]; // expected-error {{constant expression}} expected-note {{cannot access array element of pointer past the end}}
+
+constexpr int fail(const int &p) {
+ return (&p)[64]; // expected-note {{cannot refer to element 64 of array of 2 elements}}
+}
+static_assert(fail(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2)) == 11, ""); // \
+expected-error {{static_assert expression is not an integral constant expression}} \
+expected-note {{in call to 'fail(zs[1][0][1][0])'}}
+
+constexpr int arr[40] = { 1, 2, 3, [8] = 4 }; // expected-warning {{C99 feature}}
+constexpr int SumNonzero(const int *p) {
+ return *p + (*p ? SumNonzero(p+1) : 0);
+}
+constexpr int CountZero(const int *p, const int *q) {
+ return p == q ? 0 : (*p == 0) + CountZero(p+1, q);
+}
+static_assert(SumNonzero(arr) == 6, "");
+static_assert(CountZero(arr, arr + 40) == 36, "");
+
+struct ArrayElem {
+ constexpr ArrayElem() : n(0) {}
+ int n;
+ constexpr int f() { return n; }
+};
+struct ArrayRVal {
+ constexpr ArrayRVal() {}
+ ArrayElem elems[10];
+};
+static_assert(ArrayRVal().elems[3].f() == 0, "");
+
+}
+
+namespace DependentValues {
+
+struct I { int n; typedef I V[10]; };
+I::V x, y;
+template<bool B> struct S {
+ int k;
+ void f() {
+ I::V &cells = B ? x : y;
+ I &i = cells[k];
+ switch (i.n) {}
+ }
+};
+
+}
+
+namespace Class {
+
+struct A { constexpr A(int a, int b) : k(a + b) {} int k; };
+constexpr int fn(const A &a) { return a.k; }
+static_assert(fn(A(4,5)) == 9, "");
+
+struct B { int n; int m; } constexpr b = { 0, b.n }; // expected-warning {{uninitialized}}
+struct C {
+ constexpr C(C *this_) : m(42), n(this_->m) {} // ok
+ int m, n;
+};
+struct D {
+ C c;
+ constexpr D() : c(&c) {}
+};
+static_assert(D().c.n == 42, "");
+
+struct E {
+ constexpr E() : p(&p) {}
+ void *p;
+};
+constexpr const E &e1 = E(); // expected-error {{constant expression}} expected-note {{reference to temporary is not a constant expression}} expected-note {{temporary created here}}
+// This is a constant expression if we elide the copy constructor call, and
+// is not a constant expression if we don't! But we do, so it is.
+constexpr E e2 = E();
+static_assert(e2.p == &e2.p, "");
+constexpr E e3;
+static_assert(e3.p == &e3.p, "");
+
+extern const class F f;
+struct F {
+ constexpr F() : p(&f.p) {}
+ const void *p;
+};
+constexpr F f;
+
+struct G {
+ struct T {
+ constexpr T(T *p) : u1(), u2(p) {}
+ union U1 {
+ constexpr U1() {}
+ int a, b = 42;
+ } u1;
+ union U2 {
+ constexpr U2(T *p) : c(p->u1.b) {}
+ int c, d;
+ } u2;
+ } t;
+ constexpr G() : t(&t) {}
+} constexpr g;
+
+static_assert(g.t.u1.a == 42, ""); // expected-error {{constant expression}} expected-note {{read of member 'a' of union with active member 'b'}}
+static_assert(g.t.u1.b == 42, "");
+static_assert(g.t.u2.c == 42, "");
+static_assert(g.t.u2.d == 42, ""); // expected-error {{constant expression}} expected-note {{read of member 'd' of union with active member 'c'}}
+
+struct S {
+ int a, b;
+ const S *p;
+ double d;
+ const char *q;
+
+ constexpr S(int n, const S *p) : a(5), b(n), p(p), d(n), q("hello") {}
+};
+
+S global(43, &global);
+
+static_assert(S(15, &global).b == 15, "");
+
+constexpr bool CheckS(const S &s) {
+ return s.a == 5 && s.b == 27 && s.p == &global && s.d == 27. && s.q[3] == 'l';
+}
+static_assert(CheckS(S(27, &global)), "");
+
+struct Arr {
+ char arr[3];
+ constexpr Arr() : arr{'x', 'y', 'z'} {}
+};
+constexpr int hash(Arr &&a) {
+ return a.arr[0] + a.arr[1] * 0x100 + a.arr[2] * 0x10000;
+}
+constexpr int k = hash(Arr());
+static_assert(k == 0x007a7978, "");
+
+
+struct AggregateInit {
+ const char &c;
+ int n;
+ double d;
+ int arr[5];
+ void *p;
+};
+
+constexpr AggregateInit agg1 = { "hello"[0] };
+
+static_assert(strcmp_ce(&agg1.c, "hello") == 0, "");
+static_assert(agg1.n == 0, "");
+static_assert(agg1.d == 0.0, "");
+static_assert(agg1.arr[-1] == 0, ""); // expected-error {{constant expression}} expected-note {{cannot refer to element -1}}
+static_assert(agg1.arr[0] == 0, "");
+static_assert(agg1.arr[4] == 0, "");
+static_assert(agg1.arr[5] == 0, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end}}
+static_assert(agg1.p == nullptr, "");
+
+static constexpr const unsigned char uc[] = { "foo" };
+static_assert(uc[0] == 'f', "");
+static_assert(uc[3] == 0, "");
+
+namespace SimpleDerivedClass {
+
+struct B {
+ constexpr B(int n) : a(n) {}
+ int a;
+};
+struct D : B {
+ constexpr D(int n) : B(n) {}
+};
+constexpr D d(3);
+static_assert(d.a == 3, "");
+
+}
+
+struct Bottom { constexpr Bottom() {} };
+struct Base : Bottom {
+ constexpr Base(int a = 42, const char *b = "test") : a(a), b(b) {}
+ int a;
+ const char *b;
+};
+struct Base2 : Bottom {
+ constexpr Base2(const int &r) : r(r) {}
+ int q = 123;
+ const int &r;
+};
+struct Derived : Base, Base2 {
+ constexpr Derived() : Base(76), Base2(a) {}
+ int c = r + b[1];
+};
+
+constexpr bool operator==(const Base &a, const Base &b) {
+ return a.a == b.a && strcmp_ce(a.b, b.b) == 0;
+}
+
+constexpr Base base;
+constexpr Base base2(76);
+constexpr Derived derived;
+static_assert(derived.a == 76, "");
+static_assert(derived.b[2] == 's', "");
+static_assert(derived.c == 76 + 'e', "");
+static_assert(derived.q == 123, "");
+static_assert(derived.r == 76, "");
+static_assert(&derived.r == &derived.a, "");
+
+static_assert(!(derived == base), "");
+static_assert(derived == base2, "");
+
+constexpr Bottom &bot1 = (Base&)derived;
+constexpr Bottom &bot2 = (Base2&)derived;
+static_assert(&bot1 != &bot2, "");
+
+constexpr Bottom *pb1 = (Base*)&derived;
+constexpr Bottom *pb2 = (Base2*)&derived;
+static_assert(&pb1 != &pb2, "");
+static_assert(pb1 == &bot1, "");
+static_assert(pb2 == &bot2, "");
+
+constexpr Base2 &fail = (Base2&)bot1; // expected-error {{constant expression}} expected-note {{cannot cast object of dynamic type 'const Class::Derived' to type 'Class::Base2'}}
+constexpr Base &fail2 = (Base&)*pb2; // expected-error {{constant expression}} expected-note {{cannot cast object of dynamic type 'const Class::Derived' to type 'Class::Base'}}
+constexpr Base2 &ok2 = (Base2&)bot2;
+static_assert(&ok2 == &derived, "");
+
+constexpr Base2 *pfail = (Base2*)pb1; // expected-error {{constant expression}} expected-note {{cannot cast object of dynamic type 'const Class::Derived' to type 'Class::Base2'}}
+constexpr Base *pfail2 = (Base*)&bot2; // expected-error {{constant expression}} expected-note {{cannot cast object of dynamic type 'const Class::Derived' to type 'Class::Base'}}
+constexpr Base2 *pok2 = (Base2*)pb2;
+static_assert(pok2 == &derived, "");
+static_assert(&ok2 == pok2, "");
+static_assert((Base2*)(Derived*)(Base*)pb1 == pok2, "");
+static_assert((Derived*)(Base*)pb1 == (Derived*)pok2, "");
+
+constexpr Base *nullB = 42 - 6 * 7;
+static_assert((Bottom*)nullB == 0, "");
+static_assert((Derived*)nullB == 0, "");
+static_assert((void*)(Bottom*)nullB == (void*)(Derived*)nullB, "");
+
+namespace ConversionOperators {
+
+struct T {
+ constexpr T(int n) : k(5*n - 3) {}
+ constexpr operator int() { return k; }
+ int k;
+};
+
+struct S {
+ constexpr S(int n) : k(2*n + 1) {}
+ constexpr operator int() { return k; }
+ constexpr operator T() { return T(k); }
+ int k;
+};
+
+constexpr bool check(T a, T b) { return a == b.k; }
+
+static_assert(S(5) == 11, "");
+static_assert(check(S(5), 11), "");
+
+}
+
+}
+
+namespace Temporaries {
+
+struct S {
+ constexpr S() {}
+ constexpr int f();
+};
+struct T : S {
+ constexpr T(int n) : S(), n(n) {}
+ int n;
+};
+constexpr int S::f() {
+ // 'this' must be the postfix-expression in a class member access expression,
+ // so we can't just use
+ // return static_cast<T*>(this)->n;
+ return this->*(int(S::*))&T::n;
+}
+// The T temporary is implicitly cast to an S subobject, but we can recover the
+// T full-object via a base-to-derived cast, or a derived-to-base-casted member
+// pointer.
+static_assert(T(3).f() == 3, "");
+
+constexpr int f(const S &s) {
+ return static_cast<const T&>(s).n;
+}
+constexpr int n = f(T(5));
+static_assert(f(T(5)) == 5, "");
+
+constexpr bool b(int n) { return &n; }
+static_assert(b(0), "");
+
+}
+
+namespace Union {
+
+union U {
+ int a;
+ int b;
+};
+
+constexpr U u[4] = { { .a = 0 }, { .b = 1 }, { .a = 2 }, { .b = 3 } }; // expected-warning 4{{C99 feature}}
+static_assert(u[0].a == 0, "");
+static_assert(u[0].b, ""); // expected-error {{constant expression}} expected-note {{read of member 'b' of union with active member 'a'}}
+static_assert(u[1].b == 1, "");
+static_assert((&u[1].b)[1] == 2, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
+static_assert(*(&(u[1].b) + 1 + 1) == 3, ""); // expected-error {{constant expression}} expected-note {{cannot refer to element 2 of non-array object}}
+static_assert((&(u[1]) + 1 + 1)->b == 3, "");
+
+constexpr U v = {};
+static_assert(v.a == 0, "");
+
+union Empty {};
+constexpr Empty e = {};
+
+// Make sure we handle trivial copy constructors for unions.
+constexpr U x = {42};
+constexpr U y = x;
+static_assert(y.a == 42, "");
+static_assert(y.b == 42, ""); // expected-error {{constant expression}} expected-note {{'b' of union with active member 'a'}}
+
+}
+
+namespace MemberPointer {
+ struct A {
+ constexpr A(int n) : n(n) {}
+ int n;
+ constexpr int f() { return n + 3; }
+ };
+ constexpr A a(7);
+ static_assert(A(5).*&A::n == 5, "");
+ static_assert((&a)->*&A::n == 7, "");
+ static_assert((A(8).*&A::f)() == 11, "");
+ static_assert(((&a)->*&A::f)() == 10, "");
+
+ struct B : A {
+ constexpr B(int n, int m) : A(n), m(m) {}
+ int m;
+ constexpr int g() { return n + m + 1; }
+ };
+ constexpr B b(9, 13);
+ static_assert(B(4, 11).*&A::n == 4, "");
+ static_assert(B(4, 11).*&B::m == 11, "");
+ static_assert(B(4, 11).*(int(A::*))&B::m == 11, "");
+ static_assert((&b)->*&A::n == 9, "");
+ static_assert((&b)->*&B::m == 13, "");
+ static_assert((&b)->*(int(A::*))&B::m == 13, "");
+ static_assert((B(4, 11).*&A::f)() == 7, "");
+ static_assert((B(4, 11).*&B::g)() == 16, "");
+ static_assert((B(4, 11).*(int(A::*)()const)&B::g)() == 16, "");
+ static_assert(((&b)->*&A::f)() == 12, "");
+ static_assert(((&b)->*&B::g)() == 23, "");
+ static_assert(((&b)->*(int(A::*)()const)&B::g)() == 23, "");
+
+ struct S {
+ constexpr S(int m, int n, int (S::*pf)() const, int S::*pn) :
+ m(m), n(n), pf(pf), pn(pn) {}
+ constexpr S() : m(), n(), pf(&S::f), pn(&S::n) {}
+
+ constexpr int f() { return this->*pn; }
+ virtual int g() const;
+
+ int m, n;
+ int (S::*pf)() const;
+ int S::*pn;
+ };
+
+ constexpr int S::*pm = &S::m;
+ constexpr int S::*pn = &S::n;
+ constexpr int (S::*pf)() const = &S::f;
+ constexpr int (S::*pg)() const = &S::g;
+
+ constexpr S s(2, 5, &S::f, &S::m);
+
+ static_assert((s.*&S::f)() == 2, "");
+ static_assert((s.*s.pf)() == 2, "");
+
+ static_assert(pf == &S::f, "");
+ static_assert(pf == s.*&S::pf, "");
+ static_assert(pm == &S::m, "");
+ static_assert(pm != pn, "");
+ static_assert(s.pn != pn, "");
+ static_assert(s.pn == pm, "");
+ static_assert(pg != nullptr, "");
+ static_assert(pf != nullptr, "");
+ static_assert((int S::*)nullptr == nullptr, "");
+ static_assert(pg == pg, ""); // expected-error {{constant expression}} expected-note {{comparison of pointer to virtual member function 'g' has unspecified value}}
+ static_assert(pf != pg, ""); // expected-error {{constant expression}} expected-note {{comparison of pointer to virtual member function 'g' has unspecified value}}
+
+ template<int n> struct T : T<n-1> {};
+ template<> struct T<0> { int n; };
+ template<> struct T<30> : T<29> { int m; };
+
+ T<17> t17;
+ T<30> t30;
+
+ constexpr int (T<10>::*deepn) = &T<0>::n;
+ static_assert(&(t17.*deepn) == &t17.n, "");
+ static_assert(deepn == &T<2>::n, "");
+
+ constexpr int (T<15>::*deepm) = (int(T<10>::*))&T<30>::m;
+ constexpr int *pbad = &(t17.*deepm); // expected-error {{constant expression}}
+ static_assert(&(t30.*deepm) == &t30.m, "");
+ static_assert(deepm == &T<50>::m, "");
+ static_assert(deepm != deepn, "");
+
+ constexpr T<5> *p17_5 = &t17;
+ constexpr T<13> *p17_13 = (T<13>*)p17_5;
+ constexpr T<23> *p17_23 = (T<23>*)p17_13; // expected-error {{constant expression}} expected-note {{cannot cast object of dynamic type 'T<17>' to type 'T<23>'}}
+ static_assert(&(p17_5->*(int(T<3>::*))deepn) == &t17.n, "");
+ static_assert(&(p17_13->*deepn) == &t17.n, "");
+ constexpr int *pbad2 = &(p17_13->*(int(T<9>::*))deepm); // expected-error {{constant expression}}
+
+ constexpr T<5> *p30_5 = &t30;
+ constexpr T<23> *p30_23 = (T<23>*)p30_5;
+ constexpr T<13> *p30_13 = p30_23;
+ static_assert(&(p30_5->*(int(T<3>::*))deepn) == &t30.n, "");
+ static_assert(&(p30_13->*deepn) == &t30.n, "");
+ static_assert(&(p30_23->*deepn) == &t30.n, "");
+ static_assert(&(p30_5->*(int(T<2>::*))deepm) == &t30.m, "");
+ static_assert(&(((T<17>*)p30_13)->*deepm) == &t30.m, "");
+ static_assert(&(p30_23->*deepm) == &t30.m, "");
+
+ struct Base { int n; };
+ template<int N> struct Mid : Base {};
+ struct Derived : Mid<0>, Mid<1> {};
+ static_assert(&Mid<0>::n == &Mid<1>::n, "");
+ static_assert((int Derived::*)(int Mid<0>::*)&Mid<0>::n !=
+ (int Derived::*)(int Mid<1>::*)&Mid<1>::n, "");
+ static_assert(&Mid<0>::n == (int Mid<0>::*)&Base::n, "");
+}
+
+namespace ArrayBaseDerived {
+
+ struct Base {
+ constexpr Base() {}
+ int n = 0;
+ };
+ struct Derived : Base {
+ constexpr Derived() {}
+ constexpr const int *f() { return &n; }
+ };
+
+ constexpr Derived a[10];
+ constexpr Derived *pd3 = const_cast<Derived*>(&a[3]);
+ constexpr Base *pb3 = const_cast<Derived*>(&a[3]);
+ static_assert(pb3 == pd3, "");
+
+ // pb3 does not point to an array element.
+ constexpr Base *pb4 = pb3 + 1; // ok, one-past-the-end pointer.
+ constexpr int pb4n = pb4->n; // expected-error {{constant expression}} expected-note {{cannot access field of pointer past the end}}
+ constexpr Base *err_pb5 = pb3 + 2; // expected-error {{constant expression}} expected-note {{cannot refer to element 2}} expected-note {{here}}
+ constexpr int err_pb5n = err_pb5->n; // expected-error {{constant expression}} expected-note {{initializer of 'err_pb5' is not a constant expression}}
+ constexpr Base *err_pb2 = pb3 - 1; // expected-error {{constant expression}} expected-note {{cannot refer to element -1}} expected-note {{here}}
+ constexpr int err_pb2n = err_pb2->n; // expected-error {{constant expression}} expected-note {{initializer of 'err_pb2'}}
+ constexpr Base *pb3a = pb4 - 1;
+
+ // pb4 does not point to a Derived.
+ constexpr Derived *err_pd4 = (Derived*)pb4; // expected-error {{constant expression}} expected-note {{cannot access derived class of pointer past the end}}
+ constexpr Derived *pd3a = (Derived*)pb3a;
+ constexpr int pd3n = pd3a->n;
+
+ // pd3a still points to the Derived array.
+ constexpr Derived *pd6 = pd3a + 3;
+ static_assert(pd6 == &a[6], "");
+ constexpr Derived *pd9 = pd6 + 3;
+ constexpr Derived *pd10 = pd6 + 4;
+ constexpr int pd9n = pd9->n; // ok
+ constexpr int err_pd10n = pd10->n; // expected-error {{constant expression}} expected-note {{cannot access base class of pointer past the end}}
+ constexpr int pd0n = pd10[-10].n;
+ constexpr int err_pdminus1n = pd10[-11].n; // expected-error {{constant expression}} expected-note {{cannot refer to element -1 of}}
+
+ constexpr Base *pb9 = pd9;
+ constexpr const int *(Base::*pfb)() const =
+ static_cast<const int *(Base::*)() const>(&Derived::f);
+ static_assert((pb9->*pfb)() == &a[9].n, "");
+}
+
+namespace Complex {
+
+class complex {
+ int re, im;
+public:
+ constexpr complex(int re = 0, int im = 0) : re(re), im(im) {}
+ constexpr complex(const complex &o) : re(o.re), im(o.im) {}
+ constexpr complex operator-() const { return complex(-re, -im); }
+ friend constexpr complex operator+(const complex &l, const complex &r) {
+ return complex(l.re + r.re, l.im + r.im);
+ }
+ friend constexpr complex operator-(const complex &l, const complex &r) {
+ return l + -r;
+ }
+ friend constexpr complex operator*(const complex &l, const complex &r) {
+ return complex(l.re * r.re - l.im * r.im, l.re * r.im + l.im * r.re);
+ }
+ friend constexpr bool operator==(const complex &l, const complex &r) {
+ return l.re == r.re && l.im == r.im;
+ }
+ constexpr bool operator!=(const complex &r) const {
+ return re != r.re || im != r.im;
+ }
+ constexpr int real() const { return re; }
+ constexpr int imag() const { return im; }
+};
+
+constexpr complex i = complex(0, 1);
+constexpr complex k = (3 + 4*i) * (6 - 4*i);
+static_assert(complex(1,0).real() == 1, "");
+static_assert(complex(1,0).imag() == 0, "");
+static_assert(((complex)1).imag() == 0, "");
+static_assert(k.real() == 34, "");
+static_assert(k.imag() == 12, "");
+static_assert(k - 34 == 12*i, "");
+static_assert((complex)1 == complex(1), "");
+static_assert((complex)1 != complex(0, 1), "");
+static_assert(complex(1) == complex(1), "");
+static_assert(complex(1) != complex(0, 1), "");
+constexpr complex makeComplex(int re, int im) { return complex(re, im); }
+static_assert(makeComplex(1,0) == complex(1), "");
+static_assert(makeComplex(1,0) != complex(0, 1), "");
+
+class complex_wrap : public complex {
+public:
+ constexpr complex_wrap(int re, int im = 0) : complex(re, im) {}
+ constexpr complex_wrap(const complex_wrap &o) : complex(o) {}
+};
+
+static_assert((complex_wrap)1 == complex(1), "");
+static_assert((complex)1 != complex_wrap(0, 1), "");
+static_assert(complex(1) == complex_wrap(1), "");
+static_assert(complex_wrap(1) != complex(0, 1), "");
+constexpr complex_wrap makeComplexWrap(int re, int im) {
+ return complex_wrap(re, im);
+}
+static_assert(makeComplexWrap(1,0) == complex(1), "");
+static_assert(makeComplexWrap(1,0) != complex(0, 1), "");
+
+}
+
+namespace PR11595 {
+ struct A { constexpr bool operator==(int x) { return true; } };
+ struct B { B(); A& x; };
+ static_assert(B().x == 3, ""); // expected-error {{constant expression}} expected-note {{non-literal type 'PR11595::B' cannot be used in a constant expression}}
+
+ constexpr bool f(int k) { // expected-error {{constexpr function never produces a constant expression}}
+ return B().x == k; // expected-note {{non-literal type 'PR11595::B' cannot be used in a constant expression}}
+ }
+}
+
+namespace ExprWithCleanups {
+ struct A { A(); ~A(); int get(); };
+ constexpr int get(bool FromA) { return FromA ? A().get() : 1; }
+ constexpr int n = get(false);
+}
+
+namespace Volatile {
+
+volatile constexpr int n1 = 0; // expected-note {{here}}
+volatile const int n2 = 0; // expected-note {{here}}
+int n3 = 37; // expected-note {{declared here}}
+
+constexpr int m1 = n1; // expected-error {{constant expression}} expected-note {{read of volatile-qualified type 'const volatile int'}}
+constexpr int m2 = n2; // expected-error {{constant expression}} expected-note {{read of volatile-qualified type 'const volatile int'}}
+constexpr int m1b = const_cast<const int&>(n1); // expected-error {{constant expression}} expected-note {{read of volatile object 'n1'}}
+constexpr int m2b = const_cast<const int&>(n2); // expected-error {{constant expression}} expected-note {{read of volatile object 'n2'}}
+
+struct T { int n; };
+const T t = { 42 }; // expected-note {{declared here}}
+
+constexpr int f(volatile int &&r) {
+ return r; // expected-note {{read of volatile-qualified type 'volatile int'}}
+}
+constexpr int g(volatile int &&r) {
+ return const_cast<int&>(r); // expected-note {{read of volatile temporary is not allowed in a constant expression}}
+}
+struct S {
+ int j : f(0); // expected-error {{constant expression}} expected-note {{in call to 'f(0)'}}
+ int k : g(0); // expected-error {{constant expression}} expected-note {{temporary created here}} expected-note {{in call to 'g(0)'}}
+ int l : n3; // expected-error {{constant expression}} expected-note {{read of non-const variable}}
+ int m : t.n; // expected-error {{constant expression}} expected-note {{read of non-constexpr variable}}
+};
+
+}
+
+namespace ExternConstexpr {
+ extern constexpr int n = 0;
+ extern constexpr int m; // expected-error {{constexpr variable declaration must be a definition}}
+ void f() {
+ extern constexpr int i; // expected-error {{constexpr variable declaration must be a definition}}
+ constexpr int j = 0;
+ constexpr int k; // expected-error {{default initialization of an object of const type}}
+ }
+}
+
+namespace ComplexConstexpr {
+ constexpr _Complex float test1 = {};
+ constexpr _Complex float test2 = {1};
+ constexpr _Complex double test3 = {1,2};
+ constexpr _Complex int test4 = {4};
+ constexpr _Complex int test5 = 4;
+ constexpr _Complex int test6 = {5,6};
+ typedef _Complex float fcomplex;
+ constexpr fcomplex test7 = fcomplex();
+
+ constexpr const double &t2r = __real test3;
+ constexpr const double &t2i = __imag test3;
+ static_assert(&t2r + 1 == &t2i, "");
+ static_assert(t2r == 1.0, "");
+ static_assert(t2i == 2.0, "");
+ constexpr const double *t2p = &t2r;
+ static_assert(t2p[-1] == 0.0, ""); // expected-error {{constant expr}} expected-note {{cannot refer to element -1 of array of 2 elements}}
+ static_assert(t2p[0] == 1.0, "");
+ static_assert(t2p[1] == 2.0, "");
+ static_assert(t2p[2] == 0.0, ""); // expected-error {{constant expr}} expected-note {{one-past-the-end pointer}}
+ static_assert(t2p[3] == 0.0, ""); // expected-error {{constant expr}} expected-note {{cannot refer to element 3 of array of 2 elements}}
+ constexpr _Complex float *p = 0;
+ constexpr float pr = __real *p; // expected-error {{constant expr}} expected-note {{cannot access real component of null}}
+ constexpr float pi = __imag *p; // expected-error {{constant expr}} expected-note {{cannot access imaginary component of null}}
+ constexpr const _Complex double *q = &test3 + 1;
+ constexpr double qr = __real *q; // expected-error {{constant expr}} expected-note {{cannot access real component of pointer past the end}}
+ constexpr double qi = __imag *q; // expected-error {{constant expr}} expected-note {{cannot access imaginary component of pointer past the end}}
+
+ static_assert(__real test6 == 5, "");
+ static_assert(__imag test6 == 6, "");
+ static_assert(&__imag test6 == &__real test6 + 1, "");
+}
+
+namespace InstantiateCaseStmt {
+ template<int x> constexpr int f() { return x; }
+ template<int x> int g(int c) { switch(c) { case f<x>(): return 1; } return 0; }
+ int gg(int c) { return g<4>(c); }
+}
+
+namespace ConvertedConstantExpr {
+ extern int &m;
+ extern int &n;
+
+ constexpr int k = 4;
+ int &m = const_cast<int&>(k);
+
+ // If we have nothing more interesting to say, ensure we don't produce a
+ // useless note and instead just point to the non-constant subexpression.
+ enum class E {
+ em = m,
+ en = n, // expected-error {{not a constant expression}}
+ eo = (m +
+ n // expected-error {{not a constant expression}}
+ ),
+ eq = reinterpret_cast<int>((int*)0) // expected-error {{not a constant expression}} expected-note {{reinterpret_cast}}
+ };
+}
+
+namespace IndirectField {
+ struct S {
+ struct { // expected-warning {{GNU extension}}
+ union {
+ struct { // expected-warning {{GNU extension}}
+ int a;
+ int b;
+ };
+ int c;
+ };
+ int d;
+ };
+ union {
+ int e;
+ int f;
+ };
+ constexpr S(int a, int b, int d, int e) : a(a), b(b), d(d), e(e) {}
+ constexpr S(int c, int d, int f) : c(c), d(d), f(f) {}
+ };
+
+ constexpr S s1(1, 2, 3, 4);
+ constexpr S s2(5, 6, 7);
+
+ // FIXME: The diagnostics here do a very poor job of explaining which unnamed
+ // member is active and which is requested.
+ static_assert(s1.a == 1, "");
+ static_assert(s1.b == 2, "");
+ static_assert(s1.c == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
+ static_assert(s1.d == 3, "");
+ static_assert(s1.e == 4, "");
+ static_assert(s1.f == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
+
+ static_assert(s2.a == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
+ static_assert(s2.b == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
+ static_assert(s2.c == 5, "");
+ static_assert(s2.d == 6, "");
+ static_assert(s2.e == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
+ static_assert(s2.f == 7, "");
+}
+
+// DR1405: don't allow reading mutable members in constant expressions.
+namespace MutableMembers {
+ struct MM {
+ mutable int n; // expected-note 3{{declared here}}
+ } constexpr mm = { 4 };
+ constexpr int mmn = mm.n; // expected-error {{constant expression}} expected-note {{read of mutable member 'n' is not allowed in a constant expression}}
+ int x = (mm.n = 1, 3);
+ constexpr int mmn2 = mm.n; // expected-error {{constant expression}} expected-note {{read of mutable member 'n' is not allowed in a constant expression}}
+
+ // Here's one reason why allowing this would be a disaster...
+ template<int n> struct Id { int k = n; };
+ int f() {
+ constexpr MM m = { 0 };
+ ++m.n;
+ return Id<m.n>().k; // expected-error {{not a constant expression}} expected-note {{read of mutable member 'n' is not allowed in a constant expression}}
+ }
+
+ struct A { int n; };
+ struct B { mutable A a; }; // expected-note {{here}}
+ struct C { B b; };
+ constexpr C c[3] = {};
+ constexpr int k = c[1].b.a.n; // expected-error {{constant expression}} expected-note {{mutable}}
+}
+
+namespace Fold {
+
+ // This macro forces its argument to be constant-folded, even if it's not
+ // otherwise a constant expression.
+ #define fold(x) (__builtin_constant_p(x) ? (x) : (x))
+
+ constexpr int n = (int)(char*)123; // expected-error {{constant expression}} expected-note {{reinterpret_cast}}
+ constexpr int m = fold((int)(char*)123); // ok
+ static_assert(m == 123, "");
+
+ #undef fold
+
+}
+
+namespace DR1454 {
+
+constexpr const int &f(const int &n) { return n; }
+constexpr int k1 = f(0); // ok
+
+struct Wrap {
+ const int &value;
+};
+constexpr const Wrap &g(const Wrap &w) { return w; }
+constexpr int k2 = g({0}).value; // ok
+
+constexpr const int &i = 0; // expected-error {{constant expression}} expected-note {{temporary}} expected-note 2{{here}}
+constexpr const int j = i; // expected-error {{constant expression}} expected-note {{initializer of 'i' is not a constant expression}}
+
+}
+
+namespace RecursiveOpaqueExpr {
+ template<typename Iter>
+ constexpr auto LastNonzero(Iter p, Iter q) -> decltype(+*p) {
+ return p != q ? (LastNonzero(p+1, q) ?: *p) : 0; // expected-warning {{GNU}}
+ }
+
+ constexpr int arr1[] = { 1, 0, 0, 3, 0, 2, 0, 4, 0, 0 };
+ static_assert(LastNonzero(begin(arr1), end(arr1)) == 4, "");
+
+ constexpr int arr2[] = { 1, 0, 0, 3, 0, 2, 0, 4, 0, 5 };
+ static_assert(LastNonzero(begin(arr2), end(arr2)) == 5, "");
+}
+
+namespace VLASizeof {
+
+ void f(int k) {
+ int arr[k]; // expected-warning {{C99}}
+ constexpr int n = 1 +
+ sizeof(arr) // expected-error {{constant expression}}
+ * 3;
+ }
+}
+
+namespace CompoundLiteral {
+ // FIXME:
+ // We don't model the semantics of this correctly: the compound literal is
+ // represented as a prvalue in the AST, but actually behaves like an lvalue.
+ // We treat the compound literal as a temporary and refuse to produce a
+ // pointer to it. This is OK: we're not required to treat this as a constant
+ // in C++, and in C we model compound literals as lvalues.
+ constexpr int *p = (int*)(int[1]){0}; // expected-warning {{C99}} expected-error {{constant expression}} expected-note 2{{temporary}}
+}
+
+namespace Vector {
+ typedef int __attribute__((vector_size(16))) VI4;
+ constexpr VI4 f(int n) {
+ return VI4 { n * 3, n + 4, n - 5, n / 6 };
+ }
+ constexpr auto v1 = f(10);
+
+ typedef double __attribute__((vector_size(32))) VD4;
+ constexpr VD4 g(int n) {
+ return (VD4) { n / 2.0, n + 1.5, n - 5.4, n * 0.9 }; // expected-warning {{C99}}
+ }
+ constexpr auto v2 = g(4);
+}
diff --git a/clang/test/SemaCXX/constant-expression.cpp b/clang/test/SemaCXX/constant-expression.cpp
new file mode 100644
index 0000000..23a4dda
--- /dev/null
+++ b/clang/test/SemaCXX/constant-expression.cpp
@@ -0,0 +1,119 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -pedantic %s
+// C++ [expr.const]p1:
+// In several places, C++ requires expressions that evaluate to an integral
+// or enumeration constant: as array bounds, as case expressions, as
+// bit-field lengths, as enumerator initializers, as static member
+// initializers, and as integral or enumeration non-type template arguments.
+// An integral constant-expression can involve only literals, enumerators,
+// const variables or static data members of integral or enumeration types
+// initialized with constant expressions, and sizeof expressions. Floating
+// literals can appear only if they are cast to integral or enumeration types.
+
+enum Enum { eval = 1 };
+const int cval = 2;
+const Enum ceval = eval;
+struct Struct {
+ static const int sval = 3;
+ static const Enum seval = eval;
+};
+
+template <int itval, Enum etval> struct C {
+ enum E {
+ v1 = 1,
+ v2 = eval,
+ v3 = cval,
+ v4 = ceval,
+ v5 = Struct::sval,
+ v6 = Struct::seval,
+ v7 = itval,
+ v8 = etval,
+ v9 = (int)1.5,
+ v10 = sizeof(Struct),
+ v11 = true? 1 + cval * Struct::sval ^ itval / (int)1.5 - sizeof(Struct) : 0
+ };
+ unsigned
+ b1 : 1,
+ b2 : eval,
+ b3 : cval,
+ b4 : ceval,
+ b5 : Struct::sval,
+ b6 : Struct::seval,
+ b7 : itval,
+ b8 : etval,
+ b9 : (int)1.5,
+ b10 : sizeof(Struct),
+ b11 : true? 1 + cval * Struct::sval ^ itval / (int)1.5 - sizeof(Struct) : 0
+ ;
+ static const int
+ i1 = 1,
+ i2 = eval,
+ i3 = cval,
+ i4 = ceval,
+ i5 = Struct::sval,
+ i6 = Struct::seval,
+ i7 = itval,
+ i8 = etval,
+ i9 = (int)1.5,
+ i10 = sizeof(Struct),
+ i11 = true? 1 + cval * Struct::sval ^ itval / (int)1.5 - sizeof(Struct) : 0
+ ;
+ void f(int cond) {
+ switch(cond) {
+ case 0 + 1:
+ case 100 + eval:
+ case 200 + cval:
+ case 300 + ceval:
+ case 400 + Struct::sval:
+ case 500 + Struct::seval:
+ case 600 + itval:
+ case 700 + etval:
+ case 800 + (int)1.5:
+ case 900 + sizeof(Struct):
+ case 1000 + (true? 1 + cval * Struct::sval ^
+ itval / (int)1.5 - sizeof(Struct) : 0):
+ ;
+ }
+ }
+ typedef C<itval, etval> T0;
+};
+
+template struct C<1, eval>;
+template struct C<cval, ceval>;
+template struct C<Struct::sval, Struct::seval>;
+
+enum {
+ a = sizeof(int) == 8,
+ b = a? 8 : 4
+};
+
+void diags(int n) {
+ switch (n) {
+ case (1/0, 1): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
+ case (int)(1/0, 2.0): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
+ case __imag(1/0): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
+ case (int)__imag((double)(1/0)): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
+ ;
+ }
+}
+
+namespace IntOrEnum {
+ const int k = 0;
+ const int &p = k;
+ template<int n> struct S {};
+ S<p> s; // expected-error {{not an integral constant expression}}
+}
+
+extern const int recurse1;
+// recurse2 cannot be used in a constant expression because it is not
+// initialized by a constant expression. The same expression appearing later in
+// the TU would be a constant expression, but here it is not.
+const int recurse2 = recurse1;
+const int recurse1 = 1;
+int array1[recurse1]; // ok
+int array2[recurse2]; // expected-warning {{variable length array}} expected-warning {{integer constant expression}}
+
+namespace FloatConvert {
+ typedef int a[(int)42.3];
+ typedef int a[(int)42.997];
+ typedef int b[(int)4e10]; // expected-warning {{variable length}} expected-error {{variable length}}
+}
diff --git a/clang/test/SemaCXX/constexpr-ackermann.cpp b/clang/test/SemaCXX/constexpr-ackermann.cpp
new file mode 100644
index 0000000..c4ea313
--- /dev/null
+++ b/clang/test/SemaCXX/constexpr-ackermann.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s
+
+constexpr unsigned long long A(unsigned long long m, unsigned long long n) {
+ return m == 0 ? n + 1 : n == 0 ? A(m-1, 1) : A(m - 1, A(m, n - 1));
+}
+
+using X = int[A(3,4)];
+using X = int[125];
diff --git a/clang/test/SemaCXX/constexpr-backtrace-limit.cpp b/clang/test/SemaCXX/constexpr-backtrace-limit.cpp
new file mode 100644
index 0000000..9c40eed
--- /dev/null
+++ b/clang/test/SemaCXX/constexpr-backtrace-limit.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit 0 -fconstexpr-depth 4 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST1
+// TEST1: constant expression
+// TEST1-NEXT: exceeded maximum depth of 4
+// TEST1-NEXT: in call to 'recurse(2)'
+// TEST1-NEXT: in call to 'recurse(3)'
+// TEST1-NEXT: in call to 'recurse(4)'
+// TEST1-NEXT: in call to 'recurse(5)'
+
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit 2 -fconstexpr-depth 4 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST2
+// TEST2: constant expression
+// TEST2-NEXT: exceeded maximum depth of 4
+// TEST2-NEXT: in call to 'recurse(2)'
+// TEST2-NEXT: skipping 2 calls
+// TEST2-NEXT: in call to 'recurse(5)'
+
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit 2 -fconstexpr-depth 8 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST3
+// TEST3: constant expression
+// TEST3-NEXT: reinterpret_cast
+// TEST3-NEXT: in call to 'recurse(0)'
+// TEST3-NEXT: skipping 4 calls
+// TEST3-NEXT: in call to 'recurse(5)'
+
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit 8 -fconstexpr-depth 8 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST4
+// TEST4: constant expression
+// TEST4-NEXT: reinterpret_cast
+// TEST4-NEXT: in call to 'recurse(0)'
+// TEST4-NEXT: in call to 'recurse(1)'
+// TEST4-NEXT: in call to 'recurse(2)'
+// TEST4-NEXT: in call to 'recurse(3)'
+// TEST4-NEXT: in call to 'recurse(4)'
+// TEST4-NEXT: in call to 'recurse(5)'
+
+constexpr int recurse(int n) { return n ? recurse(n-1) : *(int*)n; }
+static_assert(recurse(5), "");
diff --git a/clang/test/SemaCXX/constexpr-depth.cpp b/clang/test/SemaCXX/constexpr-depth.cpp
new file mode 100644
index 0000000..feba6fd
--- /dev/null
+++ b/clang/test/SemaCXX/constexpr-depth.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -DMAX=128 -fconstexpr-depth 128
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -DMAX=2 -fconstexpr-depth 2
+// RUN: %clang -std=c++11 -fsyntax-only -Xclang -verify %s -DMAX=10 -fconstexpr-depth=10
+
+constexpr int depth(int n) { return n > 1 ? depth(n-1) : 0; } // expected-note {{exceeded maximum depth}} expected-note +{{}}
+
+constexpr int kBad = depth(MAX + 1); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'depth(}}
+constexpr int kGood = depth(MAX);
diff --git a/clang/test/SemaCXX/constexpr-factorial.cpp b/clang/test/SemaCXX/constexpr-factorial.cpp
new file mode 100644
index 0000000..b6cdde5
--- /dev/null
+++ b/clang/test/SemaCXX/constexpr-factorial.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s
+
+constexpr unsigned oddfac(unsigned n) {
+ return n == 1 ? 1 : n * oddfac(n-2);
+}
+constexpr unsigned k = oddfac(123);
+
+using A = int[k % 256];
+using A = int[43];
diff --git a/clang/test/SemaCXX/constexpr-nqueens.cpp b/clang/test/SemaCXX/constexpr-nqueens.cpp
new file mode 100644
index 0000000..b158d6e
--- /dev/null
+++ b/clang/test/SemaCXX/constexpr-nqueens.cpp
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s
+
+typedef unsigned long uint64_t;
+
+struct Board {
+ uint64_t State;
+ bool Failed;
+
+ constexpr Board() : State(0), Failed(false) {}
+ constexpr Board(const Board &O) : State(O.State), Failed(O.Failed) {}
+ constexpr Board(uint64_t State, bool Failed = false) :
+ State(State), Failed(Failed) {}
+ constexpr Board addQueen(int Row, int Col) {
+ return Board(State | ((uint64_t)Row << (Col * 4)));
+ }
+ constexpr int getQueenRow(int Col) {
+ return (State >> (Col * 4)) & 0xf;
+ }
+ constexpr bool ok(int Row, int Col) {
+ return okRecurse(Row, Col, 0);
+ }
+ constexpr bool okRecurse(int Row, int Col, int CheckCol) {
+ return Col == CheckCol ? true :
+ getQueenRow(CheckCol) == Row ? false :
+ getQueenRow(CheckCol) == Row + (Col - CheckCol) ? false :
+ getQueenRow(CheckCol) == Row + (CheckCol - Col) ? false :
+ okRecurse(Row, Col, CheckCol + 1);
+ }
+ constexpr bool at(int Row, int Col) {
+ return getQueenRow(Col) == Row;
+ }
+ constexpr bool check(const char *, int=0, int=0);
+};
+
+constexpr Board buildBoardRecurse(int N, int Col, const Board &B);
+constexpr Board buildBoardScan(int N, int Col, int Row, const Board &B);
+constexpr Board tryBoard(const Board &Try,
+ int N, int Col, int Row, const Board &B) {
+ return Try.Failed ? buildBoardScan(N, Col, Row, B) : Try;
+}
+constexpr Board buildBoardScan(int N, int Col, int Row, const Board &B) {
+ return Row == N ? Board(0, true) :
+ B.ok(Row, Col) ?
+ tryBoard(buildBoardRecurse(N, Col + 1, B.addQueen(Row, Col)),
+ N, Col, Row+1, B) :
+ buildBoardScan(N, Col, Row + 1, B);
+}
+constexpr Board buildBoardRecurse(int N, int Col, const Board &B) {
+ return Col == N ? B : buildBoardScan(N, Col, 0, B);
+}
+constexpr Board buildBoard(int N) {
+ return buildBoardRecurse(N, 0, Board());
+}
+
+constexpr Board q8 = buildBoard(8);
+
+constexpr bool Board::check(const char *p, int Row, int Col) {
+ return
+ *p == '\n' ? check(p+1, Row+1, 0) :
+ *p == 'o' ? at(Row, Col) && check(p+1, Row, Col+1) :
+ *p == '-' ? !at(Row, Col) && check(p+1, Row, Col+1) :
+ *p == 0 ? true :
+ false;
+}
+static_assert(q8.check(
+ "o-------\n"
+ "------o-\n"
+ "----o---\n"
+ "-------o\n"
+ "-o------\n"
+ "---o----\n"
+ "-----o--\n"
+ "--o-----\n"), "");
diff --git a/clang/test/SemaCXX/constexpr-printing.cpp b/clang/test/SemaCXX/constexpr-printing.cpp
new file mode 100644
index 0000000..9170fa1
--- /dev/null
+++ b/clang/test/SemaCXX/constexpr-printing.cpp
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -triple x86_64-linux-gnu
+
+struct S;
+constexpr int extract(const S &s);
+
+struct S {
+ constexpr S() : n(extract(*this)), m(0) {} // expected-note {{in call to 'extract(s1)'}}
+ constexpr S(int k) : n(k), m(extract(*this)) {}
+ int n, m;
+};
+
+constexpr int extract(const S &s) { return s.n; } // expected-note {{read of uninitialized object is not allowed in a constant expression}}
+
+constexpr S s1; // ok
+void f() {
+ constexpr S s1; // expected-error {{constant expression}} expected-note {{in call to 'S()'}}
+ constexpr S s2(10);
+}
+
+typedef __attribute__((vector_size(16))) int vector_int;
+
+struct T {
+ constexpr T() : arr() {}
+ int arr[4];
+};
+struct U : T {
+ constexpr U(const int *p) : T(), another(), p(p) {}
+ constexpr U(const U &u) : T(), another(), p(u.p) {}
+ T another;
+ const int *p;
+};
+constexpr U u1(&u1.arr[2]);
+
+constexpr int test_printing(int a, float b, _Complex int c, _Complex float d,
+ int *e, int &f, vector_int g, U h) {
+ return *e; // expected-note {{read of non-constexpr variable 'u2'}}
+}
+U u2(0); // expected-note {{here}}
+static_assert(test_printing(12, 39.762, 3 + 4i, 12.9 + 3.6i, &u2.arr[4], u2.another.arr[2], (vector_int){5, 1, 2, 3}, u1) == 0, ""); // \
+expected-error {{constant expression}} \
+expected-note {{in call to 'test_printing(12, 3.976200e+01, 3+4i, 1.290000e+01+3.600000e+00i, &u2.T::arr[4], u2.another.arr[2], {5, 1, 2, 3}, {{{}}, {{}}, &u1.T::arr[2]})'}}
+
+struct V {
+ // FIXME: when we can generate these as constexpr constructors, remove the
+ // explicit definitions.
+ constexpr V() : arr{[255] = 42} {}
+ constexpr V(const V &v) : arr{[255] = 42} {}
+ int arr[256];
+};
+constexpr V v;
+constexpr int get(const int *p) { return *p; } // expected-note {{read of dereferenced one-past-the-end pointer}}
+constexpr int passLargeArray(V v) { return get(v.arr+256); } // expected-note {{in call to 'get(&v.arr[256])'}}
+static_assert(passLargeArray(v) == 0, ""); // expected-error {{constant expression}} expected-note {{in call to 'passLargeArray({{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...}})'}}
+
+union Union {
+ constexpr Union(int n) : b(n) {}
+ constexpr Union(const Union &u) : b(u.b) {}
+ int a, b;
+};
+constexpr Union myUnion = 76;
+
+constexpr int badness(Union u) { return u.a + u.b; } // expected-note {{read of member 'a' of union with active member 'b'}}
+static_assert(badness(myUnion), ""); // expected-error {{constant expression}} \
+ expected-note {{in call to 'badness({.b = 76})'}}
+
+struct MemPtrTest {
+ int n;
+ void f();
+};
+MemPtrTest mpt; // expected-note {{here}}
+constexpr int MemPtr(int (MemPtrTest::*a), void (MemPtrTest::*b)(), int &c) {
+ return c; // expected-note {{read of non-constexpr variable 'mpt'}}
+}
+static_assert(MemPtr(&MemPtrTest::n, &MemPtrTest::f, mpt.*&MemPtrTest::n), ""); // expected-error {{constant expression}} \
+expected-note {{in call to 'MemPtr(&MemPtrTest::n, &MemPtrTest::f, mpt.n)'}}
+
+template<typename CharT>
+constexpr CharT get(const CharT *p) { return p[-1]; } // expected-note 5{{}}
+
+constexpr char c = get("test\0\\\"\t\a\b\234"); // \
+ expected-error {{}} expected-note {{"test\000\\\"\t\a\b\234"}}
+constexpr char c8 = get(u8"test\0\\\"\t\a\b\234"); // \
+ expected-error {{}} expected-note {{u8"test\000\\\"\t\a\b\234"}}
+constexpr char16_t c16 = get(u"test\0\\\"\t\a\b\234\u1234"); // \
+ expected-error {{}} expected-note {{u"test\000\\\"\t\a\b\234\u1234"}}
+constexpr char32_t c32 = get(U"test\0\\\"\t\a\b\234\u1234\U0010ffff"); // \
+ expected-error {{}} expected-note {{U"test\000\\\"\t\a\b\234\u1234\U0010FFFF"}}
+constexpr wchar_t wc = get(L"test\0\\\"\t\a\b\234\u1234\xffffffff"); // \
+ expected-error {{}} expected-note {{L"test\000\\\"\t\a\b\234\x1234\xFFFFFFFF"}}
+
+constexpr char32_t c32_err = get(U"\U00110000"); // expected-error {{invalid universal character}}
+
+typedef decltype(sizeof(int)) LabelDiffTy;
+constexpr LabelDiffTy mulBy3(LabelDiffTy x) { return x * 3; } // expected-note {{subexpression}}
+void LabelDiffTest() {
+ static_assert(mulBy3((LabelDiffTy)&&a-(LabelDiffTy)&&b) == 3, ""); // expected-error {{constant expression}} expected-note {{call to 'mulBy3(&&a - &&b)'}}
+ a:b:return;
+}
+
+constexpr bool test_bool_printing(bool b) { return 1 / !(2*b | !(2*b)); } // expected-note 2{{division by zero}}
+constexpr bool test_bool_0 = test_bool_printing(false); // expected-error {{constant expr}} expected-note {{in call to 'test_bool_printing(false)'}}
+constexpr bool test_bool_1 = test_bool_printing(true); // expected-error {{constant expr}} expected-note {{in call to 'test_bool_printing(true)'}}
diff --git a/clang/test/SemaCXX/constexpr-strlen.cpp b/clang/test/SemaCXX/constexpr-strlen.cpp
new file mode 100644
index 0000000..5e28e7f
--- /dev/null
+++ b/clang/test/SemaCXX/constexpr-strlen.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -pedantic
+
+# 1 "/usr/include/string.h" 1 3 4
+extern "C" {
+ typedef decltype(sizeof(int)) size_t;
+ extern size_t strlen(const char *p);
+}
+
+# 10 "SemaCXX/constexpr-strlen.cpp" 2
+constexpr int n = __builtin_strlen("hello"); // ok
+constexpr int m = strlen("hello"); // expected-error {{constant expression}} expected-note {{non-constexpr function 'strlen' cannot be used in a constant expression}}
+
+// Make sure we can evaluate a call to strlen.
+int arr[3]; // expected-note {{here}}
+int k = arr[strlen("hello")]; // expected-warning {{array index 5}}
diff --git a/clang/test/SemaCXX/constexpr-turing.cpp b/clang/test/SemaCXX/constexpr-turing.cpp
new file mode 100644
index 0000000..c515378
--- /dev/null
+++ b/clang/test/SemaCXX/constexpr-turing.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+// A direct proof that constexpr is Turing-complete, once DR1454 is implemented.
+
+const unsigned halt = (unsigned)-1;
+
+enum Dir { L, R };
+struct Action {
+ bool tape;
+ Dir dir;
+ unsigned next;
+};
+using State = Action[2];
+
+// An infinite tape!
+struct Tape {
+ constexpr Tape() : l(0), val(false), r(0) {}
+ constexpr Tape(const Tape &old, bool write) :
+ l(old.l), val(write), r(old.r) {}
+ constexpr Tape(const Tape &old, Dir dir) :
+ l(dir == L ? old.l ? old.l->l : 0 : &old),
+ val(dir == L ? old.l ? old.l->val : false
+ : old.r ? old.r->val : false),
+ r(dir == R ? old.r ? old.r->r : 0 : &old) {}
+ const Tape *l;
+ bool val;
+ const Tape *r;
+};
+constexpr Tape update(const Tape &old, bool write) { return Tape(old, write); }
+constexpr Tape move(const Tape &old, Dir dir) { return Tape(old, dir); }
+
+// Run turing machine 'tm' on tape 'tape' from state 'state'. Return number of
+// steps taken until halt.
+constexpr unsigned run(const State *tm, const Tape &tape, unsigned state) {
+ return state == halt ? 1 :
+ run(tm, move(update(tape, tm[state][tape.val].tape),
+ tm[state][tape.val].dir),
+ tm[state][tape.val].next) + 1;
+}
+
+// 3-state busy beaver. 14 steps.
+constexpr State bb3[] = {
+ { { true, R, 1 }, { true, L, 2 } },
+ { { true, L, 0 }, { true, R, 1 } },
+ { { true, L, 1 }, { true, R, halt } }
+};
+static_assert(run(bb3, Tape(), 0) == 14, "");
+
+// 4-state busy beaver. 108 steps.
+constexpr State bb4[] = {
+ { { true, R, 1 }, { true, L, 1 } },
+ { { true, L, 0 }, { false, L, 2 } },
+ { { true, R, halt }, { true, L, 3 } },
+ { { true, R, 3 }, { false, R, 0 } } };
+static_assert(run(bb4, Tape(), 0) == 108, "");
diff --git a/clang/test/SemaCXX/constexpr-value-init.cpp b/clang/test/SemaCXX/constexpr-value-init.cpp
new file mode 100644
index 0000000..e459f09
--- /dev/null
+++ b/clang/test/SemaCXX/constexpr-value-init.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify
+
+struct A {
+ constexpr A() : a(b + 1), b(a + 1) {} // expected-note {{uninitialized}}
+ int a;
+ int b;
+};
+struct B {
+ A a;
+};
+
+constexpr A a; // ok, zero initialization preceeds static initialization
+void f() {
+ constexpr A a; // expected-error {{constant expression}} expected-note {{in call to 'A()'}}
+}
+
+constexpr B b1; // expected-error {{requires a user-provided default constructor}}
+constexpr B b2 = B(); // ok
+static_assert(b2.a.a == 1, "");
+static_assert(b2.a.b == 2, "");
+
+struct C {
+ int c;
+};
+struct D : C { int d; };
+constexpr C c1; // expected-error {{requires a user-provided default constructor}}
+constexpr C c2 = C(); // ok
+constexpr D d1; // expected-error {{requires a user-provided default constructor}}
+constexpr D d2 = D(); // ok with DR1452
+static_assert(D().c == 0, "");
+static_assert(D().d == 0, "");
+
+struct V : virtual C {};
+template<typename T> struct Z : T {
+ constexpr Z() : V() {}
+};
+constexpr int n = Z<V>().c; // expected-error {{constant expression}} expected-note {{virtual base class}}
diff --git a/clang/test/SemaCXX/constructor-initializer.cpp b/clang/test/SemaCXX/constructor-initializer.cpp
new file mode 100644
index 0000000..e8b7f0b
--- /dev/null
+++ b/clang/test/SemaCXX/constructor-initializer.cpp
@@ -0,0 +1,282 @@
+// RUN: %clang_cc1 -Wreorder -fsyntax-only -verify %s
+class A {
+ int m;
+public:
+ A() : A::m(17) { } // expected-error {{member initializer 'm' does not name a non-static data member or base class}}
+ A(int);
+};
+
+class B : public A {
+public:
+ B() : A(), m(1), n(3.14) { }
+
+private:
+ int m;
+ float n;
+};
+
+
+class C : public virtual B {
+public:
+ C() : B() { }
+};
+
+class D : public C {
+public:
+ D() : B(), C() { }
+};
+
+class E : public D, public B {
+public:
+ E() : B(), D() { } // expected-error{{base class initializer 'B' names both a direct base class and an inherited virtual base class}}
+};
+
+
+typedef int INT;
+
+class F : public B {
+public:
+ int B;
+
+ F() : B(17),
+ m(17), // expected-error{{member initializer 'm' does not name a non-static data member or base class}}
+ INT(17) // expected-error{{constructor initializer 'INT' (aka 'int') does not name a class}}
+ {
+ }
+};
+
+class G : A {
+ G() : A(10); // expected-error{{expected '{'}}
+};
+
+void f() : a(242) { } // expected-error{{only constructors take base initializers}}
+
+class H : A {
+ H();
+};
+
+H::H() : A(10) { }
+
+
+class X {};
+class Y {};
+
+struct S : Y, virtual X {
+ S ();
+};
+
+struct Z : S {
+ Z() : X(), S(), E() {} // expected-error {{type 'E' is not a direct or virtual base of 'Z'}}
+};
+
+class U {
+ union { int a; char* p; };
+ union { int b; double d; };
+
+ U() : a(1), // expected-note {{previous initialization is here}}
+ p(0), // expected-error {{initializing multiple members of union}}
+ d(1.0) {}
+};
+
+struct V {};
+struct Base {};
+struct Base1 {};
+
+struct Derived : Base, Base1, virtual V {
+ Derived ();
+};
+
+struct Current : Derived {
+ int Derived;
+ Current() : Derived(1), ::Derived(), // expected-warning {{field 'Derived' will be initialized after base '::Derived'}} \
+ // expected-warning {{base class '::Derived' will be initialized after base 'Derived::V'}}
+ ::Derived::Base(), // expected-error {{type '::Derived::Base' is not a direct or virtual base of 'Current'}}
+ Derived::Base1(), // expected-error {{type 'Derived::Base1' is not a direct or virtual base of 'Current'}}
+ Derived::V(),
+ ::NonExisting(), // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
+ INT::NonExisting() {} // expected-error {{expected a class or namespace}} \
+ // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
+};
+
+struct M { // expected-note 2 {{candidate constructor (the implicit copy constructor)}} \
+ // expected-note {{declared here}} \
+ // expected-note {{declared here}}
+ M(int i, int j); // expected-note 2 {{candidate constructor}}
+};
+
+struct N : M {
+ N() : M(1), // expected-error {{no matching constructor for initialization of 'M'}}
+ m1(100) { } // expected-error {{no matching constructor for initialization of 'M'}}
+ M m1;
+};
+
+struct P : M {
+ P() { } // expected-error {{constructor for 'P' must explicitly initialize the base class 'M' which does not have a default constructor}} \
+ // expected-error {{member 'm'}}
+ M m; // expected-note {{member is declared here}}
+};
+
+struct Q {
+ Q() : f1(1,2), // expected-error {{excess elements in scalar initializer}}
+ pf(0.0) { } // expected-error {{cannot initialize a member subobject of type 'float *' with an rvalue of type 'double'}}
+ float f1;
+
+ float *pf;
+};
+
+// A silly class used to demonstrate field-is-uninitialized in constructors with
+// multiple params.
+class TwoInOne { public: TwoInOne(TwoInOne a, TwoInOne b) {} };
+class InitializeUsingSelfTest {
+ bool A;
+ char* B;
+ int C;
+ TwoInOne D;
+ InitializeUsingSelfTest(int E)
+ : A(A), // expected-warning {{field is uninitialized when used here}}
+ B((((B)))), // expected-warning {{field is uninitialized when used here}}
+ C(A && InitializeUsingSelfTest::C), // expected-warning {{field is uninitialized when used here}}
+ D(D, // expected-warning {{field is uninitialized when used here}}
+ D) {} // expected-warning {{field is uninitialized when used here}}
+};
+
+int IntWrapper(int i) { return 0; };
+class InitializeUsingSelfExceptions {
+ int A;
+ int B;
+ int C;
+ void *P;
+ InitializeUsingSelfExceptions(int B)
+ : A(IntWrapper(A)), // Due to a conservative implementation, we do not report warnings inside function/ctor calls even though it is possible to do so.
+ B(B), // Not a warning; B is a local variable.
+ C(sizeof(C)), // sizeof doesn't reference contents, do not warn
+ P(&P) {} // address-of doesn't reference contents (the pointer may be dereferenced in the same expression but it would be rare; and weird)
+};
+
+class CopyConstructorTest {
+ bool A, B, C;
+ CopyConstructorTest(const CopyConstructorTest& rhs)
+ : A(rhs.A),
+ B(B), // expected-warning {{field is uninitialized when used here}}
+ C(rhs.C || C) { } // expected-warning {{field is uninitialized when used here}}
+};
+
+// Make sure we aren't marking default constructors when we shouldn't be.
+template<typename T>
+struct NDC {
+ T &ref;
+
+ NDC() { }
+ NDC(T &ref) : ref(ref) { }
+};
+
+struct X0 : NDC<int> {
+ X0(int &ref) : NDC<int>(ref), ndc(ref) { }
+
+ NDC<int> ndc;
+};
+
+namespace Test0 {
+
+struct A { A(); };
+
+struct B {
+ B() { }
+ const A a;
+};
+
+}
+
+namespace Test1 {
+ struct A {
+ enum Kind { Foo } Kind;
+ A() : Kind(Foo) {}
+ };
+}
+
+namespace Test2 {
+
+struct A {
+ A(const A&);
+};
+
+struct B : virtual A { };
+struct C : A, B { };
+
+C f(C c) {
+ return c;
+}
+
+}
+
+// Don't build implicit initializers for anonymous union fields when we already
+// have an explicit initializer for another field in the union.
+namespace PR7402 {
+ struct S {
+ union {
+ void* ptr_;
+ struct { int i_; };
+ };
+
+ template <typename T> S(T) : ptr_(0) { }
+ };
+
+ void f() {
+ S s(3);
+ }
+}
+
+// <rdar://problem/8308215>: don't crash.
+// Lots of questionable recovery here; errors can change.
+namespace test3 {
+ class A : public std::exception {}; // expected-error {{undeclared identifier}} expected-error {{expected class name}} expected-note 3 {{candidate}} expected-note {{passing argument}}
+ class B : public A {
+ public:
+ B(const String& s, int e=0) // expected-error {{unknown type name}}
+ : A(e), m_String(s) , m_ErrorStr(__null) {} // expected-error {{no matching constructor}} expected-error {{does not name}}
+ B(const B& e)
+ : A(e), m_String(e.m_String), m_ErrorStr(__null) { // expected-error {{no viable conversion}} expected-error {{does not name}}
+ }
+ };
+}
+
+// PR8075
+namespace PR8075 {
+
+struct S1 {
+ enum { FOO = 42 };
+ static const int bar = 42;
+ static int baz();
+ S1(int);
+};
+
+const int S1::bar;
+
+struct S2 {
+ S1 s1;
+ S2() : s1(s1.FOO) {}
+};
+
+struct S3 {
+ S1 s1;
+ S3() : s1(s1.bar) {}
+};
+
+struct S4 {
+ S1 s1;
+ S4() : s1(s1.baz()) {}
+};
+
+}
+
+namespace PR12049 {
+ int function();
+
+ class Class
+ {
+ public:
+ Class() : member(function() {} // expected-note {{to match this '('}}
+
+ int member; // expected-error {{expected ')'}}
+ };
+}
diff --git a/clang/test/SemaCXX/constructor-recovery.cpp b/clang/test/SemaCXX/constructor-recovery.cpp
new file mode 100644
index 0000000..c1bb436
--- /dev/null
+++ b/clang/test/SemaCXX/constructor-recovery.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct C {
+ virtual C() = 0; // expected-error{{constructor cannot be declared 'virtual'}}
+};
+
+void f() {
+ C c;
+}
diff --git a/clang/test/SemaCXX/constructor.cpp b/clang/test/SemaCXX/constructor.cpp
new file mode 100644
index 0000000..f3b910d
--- /dev/null
+++ b/clang/test/SemaCXX/constructor.cpp
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+typedef int INT;
+
+class Foo {
+ Foo();
+ (Foo)(float) { }
+ explicit Foo(int); // expected-note {{previous declaration is here}}
+ Foo(const Foo&);
+
+ ((Foo))(INT); // expected-error{{cannot be redeclared}}
+
+ Foo(Foo foo, int i = 17, int j = 42); // expected-error{{copy constructor must pass its first argument by reference}}
+
+ static Foo(short, short); // expected-error{{constructor cannot be declared 'static'}}
+ virtual Foo(double); // expected-error{{constructor cannot be declared 'virtual'}}
+ Foo(long) const; // expected-error{{'const' qualifier is not allowed on a constructor}}
+
+ int Foo(int, int); // expected-error{{constructor cannot have a return type}} \
+ // expected-error{{member 'Foo' has the same name as its class}}
+};
+
+Foo::Foo(const Foo&) { }
+
+typedef struct {
+ int version;
+} Anon;
+extern const Anon anon;
+extern "C" const Anon anon2;
+
+// PR3188: The extern declaration complained about not having an appropriate
+// constructor.
+struct x;
+extern x a;
+
+// A similar case.
+struct y {
+ y(int);
+};
+extern y b;
+
+struct Length {
+ Length l() const { return *this; }
+};
+
+// <rdar://problem/6815988>
+struct mmst_reg{
+ char mmst_reg[10];
+};
+
+// PR3948
+namespace PR3948 {
+// PR3948
+class a {
+ public:
+ int b(int a());
+};
+int x();
+void y() {
+ a z; z.b(x);
+}
+}
+
+namespace A {
+ struct S {
+ S();
+ S(int);
+ void f1();
+ void f2();
+ operator int ();
+ ~S();
+ };
+}
+
+A::S::S() {}
+
+void A::S::f1() {}
+
+struct S {};
+
+A::S::S(int) {}
+
+void A::S::f2() {}
+
+A::S::operator int() { return 1; }
+
+A::S::~S() {}
+
diff --git a/clang/test/SemaCXX/conversion-delete-expr.cpp b/clang/test/SemaCXX/conversion-delete-expr.cpp
new file mode 100644
index 0000000..0f298a8
--- /dev/null
+++ b/clang/test/SemaCXX/conversion-delete-expr.cpp
@@ -0,0 +1,109 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// Test1
+struct B {
+ operator char *(); // expected-note {{candidate function}}
+};
+
+struct D : B {
+ operator int *(); // expected-note {{candidate function}}
+};
+
+void f (D d)
+{
+ delete d; // expected-error {{ambiguous conversion of delete expression of type 'D' to a pointer}}
+}
+
+// Test2
+struct B1 {
+ operator int *();
+};
+
+struct D1 : B1 {
+ operator int *();
+};
+
+void f1 (D1 d)
+{
+ delete d;
+}
+
+// Test3
+struct B2 {
+ operator const int *(); // expected-note {{candidate function}}
+};
+
+struct D2 : B2 {
+ operator int *(); // expected-note {{candidate function}}
+};
+
+void f2 (D2 d)
+{
+ delete d; // expected-error {{ambiguous conversion of delete expression of type 'D2' to a pointer}}
+}
+
+// Test4
+struct B3 {
+ operator const int *(); // expected-note {{candidate function}}
+};
+
+struct A3 {
+ operator const int *(); // expected-note {{candidate function}}
+};
+
+struct D3 : A3, B3 {
+};
+
+void f3 (D3 d)
+{
+ delete d; // expected-error {{ambiguous conversion of delete expression of type 'D3' to a pointer}}
+}
+
+// Test5
+struct X {
+ operator int();
+ operator int*();
+};
+
+void f4(X x) { delete x; delete x; }
+
+// Test6
+struct X1 {
+ operator int();
+ operator int*();
+ template<typename T> operator T*() const; // converts to any pointer!
+};
+
+void f5(X1 x) { delete x; } // OK. In selecting a conversion to pointer function, template convesions are skipped.
+
+// Test7
+struct Base {
+ operator int*();
+};
+
+struct Derived : Base {
+ // not the same function as Base's non-const operator int()
+ operator int*() const;
+};
+
+void foo6(const Derived cd, Derived d) {
+ // overload resolution selects Derived::operator int*() const;
+ delete cd;
+ delete d;
+}
+
+// Test8
+struct BB {
+ template<typename T> operator T*() const;
+};
+
+struct DD : BB {
+ template<typename T> operator T*() const; // hides base conversion
+ operator int *() const;
+};
+
+void foo7 (DD d)
+{
+ // OK. In selecting a conversion to pointer function, template convesions are skipped.
+ delete d;
+}
diff --git a/clang/test/SemaCXX/conversion-function.cpp b/clang/test/SemaCXX/conversion-function.cpp
new file mode 100644
index 0000000..a7a1782
--- /dev/null
+++ b/clang/test/SemaCXX/conversion-function.cpp
@@ -0,0 +1,394 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class X {
+public:
+ operator bool();
+ operator int() const;
+
+ bool f() {
+ return operator bool();
+ }
+
+ float g() {
+ return operator float(); // expected-error{{use of undeclared 'operator float'}}
+ }
+};
+
+operator int(); // expected-error{{conversion function must be a non-static member function}}
+
+operator int; // expected-error{{'operator int' cannot be the name of a variable or data member}}
+
+typedef int func_type(int);
+typedef int array_type[10];
+
+class Y {
+public:
+ void operator bool(int, ...) const; // expected-error{{conversion function cannot have a return type}} \
+ // expected-error{{conversion function cannot have any parameters}}
+
+ operator float(...) const; // expected-error{{conversion function cannot be variadic}}
+
+
+ operator func_type(); // expected-error{{conversion function cannot convert to a function type}}
+ operator array_type(); // expected-error{{conversion function cannot convert to an array type}}
+};
+
+
+typedef int INT;
+typedef INT* INT_PTR;
+
+class Z {
+ operator int(); // expected-note {{previous declaration is here}}
+ operator int**(); // expected-note {{previous declaration is here}}
+
+ operator INT(); // expected-error{{conversion function cannot be redeclared}}
+ operator INT_PTR*(); // expected-error{{conversion function cannot be redeclared}}
+};
+
+
+class A { };
+
+class B : public A {
+public:
+ operator A&() const; // expected-warning{{conversion function converting 'B' to its base class 'A' will never be used}}
+ operator const void() const; // expected-warning{{conversion function converting 'B' to 'const void' will never be used}}
+ operator const B(); // expected-warning{{conversion function converting 'B' to itself will never be used}}
+};
+
+// This used to crash Clang.
+struct Flip;
+struct Flop {
+ Flop();
+ Flop(const Flip&); // expected-note{{candidate constructor}}
+};
+struct Flip {
+ operator Flop() const; // expected-note{{candidate function}}
+};
+Flop flop = Flip(); // expected-error {{conversion from 'Flip' to 'Flop' is ambiguous}}
+
+// This tests that we don't add the second conversion declaration to the list of user conversions
+struct C {
+ operator const char *() const;
+};
+
+C::operator const char*() const { return 0; }
+
+void f(const C& c) {
+ const char* v = c;
+}
+
+// Test. Conversion in base class is visible in derived class.
+class XB {
+public:
+ operator int(); // expected-note {{candidate function}}
+};
+
+class Yb : public XB {
+public:
+ operator char(); // expected-note {{candidate function}}
+};
+
+void f(Yb& a) {
+ if (a) { } // expected-error {{conversion from 'Yb' to 'bool' is ambiguous}}
+ int i = a; // OK. calls XB::operator int();
+ char ch = a; // OK. calls Yb::operator char();
+}
+
+// Test conversion + copy construction.
+class AutoPtrRef { };
+
+class AutoPtr {
+ AutoPtr(AutoPtr &); // expected-note{{declared private here}}
+
+public:
+ AutoPtr();
+ AutoPtr(AutoPtrRef);
+
+ operator AutoPtrRef();
+};
+
+AutoPtr make_auto_ptr();
+
+AutoPtr test_auto_ptr(bool Cond) {
+ AutoPtr p1( make_auto_ptr() );
+
+ AutoPtr p;
+ if (Cond)
+ return p; // expected-error{{calling a private constructor}}
+
+ return AutoPtr();
+}
+
+struct A1 {
+ A1(const char *);
+ ~A1();
+
+private:
+ A1(const A1&); // expected-note 2 {{declared private here}}
+};
+
+A1 f() {
+ // FIXME: redundant diagnostics!
+ return "Hello"; // expected-error {{calling a private constructor}} expected-warning {{an accessible copy constructor}}
+}
+
+namespace source_locations {
+ template<typename T>
+ struct sneaky_int {
+ typedef int type;
+ };
+
+ template<typename T, typename U>
+ struct A { };
+
+ template<typename T>
+ struct A<T, T> : A<T, int> { };
+
+ struct E {
+ template<typename T>
+ operator A<T, typename sneaky_int<T>::type>&() const; // expected-note{{candidate function}}
+ };
+
+ void f() {
+ A<float, float> &af = E(); // expected-error{{no viable conversion}}
+ A<float, int> &af2 = E();
+ const A<float, int> &caf2 = E();
+ }
+
+ // Check
+ template<typename T>
+ struct E2 {
+ operator T
+ * // expected-error{{pointer to a reference}}
+ () const;
+ };
+
+ E2<int&> e2i; // expected-note{{in instantiation}}
+}
+
+namespace crazy_declarators {
+ struct A {
+ (&operator bool())(); // expected-error {{must use a typedef to declare a conversion to 'bool (&)()'}}
+
+ // FIXME: This diagnostic is misleading (the correct spelling
+ // would be 'operator int*'), but it's a corner case of a
+ // rarely-used syntax extension.
+ *operator int(); // expected-error {{must use a typedef to declare a conversion to 'int *'}}
+ };
+}
+
+namespace smart_ptr {
+ class Y {
+ class YRef { };
+
+ Y(Y&);
+
+ public:
+ Y();
+ Y(YRef);
+
+ operator YRef(); // expected-note{{candidate function}}
+ };
+
+ struct X { // expected-note{{candidate constructor (the implicit copy constructor) not}}
+ explicit X(Y);
+ };
+
+ Y make_Y();
+
+ X f() {
+ X x = make_Y(); // expected-error{{no viable conversion from 'smart_ptr::Y' to 'smart_ptr::X'}}
+ X x2(make_Y());
+ return X(Y());
+ }
+}
+
+struct Any {
+ Any(...);
+};
+
+struct Other {
+ Other(const Other &);
+ Other();
+};
+
+void test_any() {
+ Any any = Other(); // expected-error{{cannot pass object of non-POD type 'Other' through variadic constructor; call will abort at runtime}}
+}
+
+namespace PR7055 {
+ // Make sure that we don't allow too many conversions in an
+ // auto_ptr-like template. In particular, we can't create multiple
+ // temporary objects when binding to a reference.
+ struct auto_ptr {
+ struct auto_ptr_ref { };
+
+ auto_ptr(auto_ptr&);
+ auto_ptr(auto_ptr_ref);
+ explicit auto_ptr(int *);
+
+ operator auto_ptr_ref();
+ };
+
+ struct X {
+ X(auto_ptr);
+ };
+
+ X f() {
+ X x(auto_ptr(new int));
+ return X(auto_ptr(new int));
+ }
+
+ auto_ptr foo();
+
+ X e(foo());
+
+ struct Y {
+ Y(X);
+ };
+
+ Y f2(foo());
+}
+
+namespace PR7934 {
+ typedef unsigned char uint8;
+
+ struct MutablePtr {
+ MutablePtr() : ptr(0) {}
+ void *ptr;
+
+ operator void*() { return ptr; }
+
+ private:
+ operator uint8*() { return reinterpret_cast<uint8*>(ptr); }
+ operator const char*() const { return reinterpret_cast<const char*>(ptr); }
+ };
+
+ void fake_memcpy(const void *);
+
+ void use() {
+ MutablePtr ptr;
+ fake_memcpy(ptr);
+ }
+}
+
+namespace rdar8018274 {
+ struct X { };
+ struct Y {
+ operator const struct X *() const;
+ };
+
+ struct Z : Y {
+ operator struct X * ();
+ };
+
+ void test() {
+ Z x;
+ (void) (x != __null);
+ }
+
+
+ struct Base {
+ operator int();
+ };
+
+ struct Derived1 : Base { };
+
+ struct Derived2 : Base { };
+
+ struct SuperDerived : Derived1, Derived2 {
+ using Derived1::operator int;
+ };
+
+ struct UeberDerived : SuperDerived {
+ operator long();
+ };
+
+ void test2(UeberDerived ud) {
+ int i = ud; // expected-error{{ambiguous conversion from derived class 'rdar8018274::SuperDerived' to base class 'rdar8018274::Base'}}
+ }
+
+ struct Base2 {
+ operator int();
+ };
+
+ struct Base3 {
+ operator int();
+ };
+
+ struct Derived23 : Base2, Base3 {
+ using Base2::operator int;
+ };
+
+ struct ExtraDerived23 : Derived23 { };
+
+ void test3(ExtraDerived23 ed) {
+ int i = ed;
+ }
+}
+
+namespace PR8065 {
+ template <typename T> struct Iterator;
+ template <typename T> struct Container;
+
+ template<>
+ struct Iterator<int> {
+ typedef Container<int> container_type;
+ };
+
+ template <typename T>
+ struct Container {
+ typedef typename Iterator<T>::container_type X;
+ operator X(void) { return X(); }
+ };
+
+ Container<int> test;
+}
+
+namespace PR8034 {
+ struct C {
+ operator int();
+
+ private:
+ template <typename T> operator T();
+ };
+ int x = C().operator int();
+}
+
+namespace PR9336 {
+ template<class T>
+ struct generic_list
+ {
+ template<class Container>
+ operator Container()
+ {
+ Container ar;
+ T* i;
+ ar[0]=*i;
+ return ar;
+ }
+ };
+
+ template<class T>
+ struct array
+ {
+ T& operator[](int);
+ const T& operator[](int)const;
+ };
+
+ generic_list<generic_list<int> > l;
+ array<array<int> > a = l;
+}
+
+namespace PR8800 {
+ struct A;
+ struct C {
+ operator A&();
+ };
+ void f() {
+ C c;
+ A& a1(c);
+ A& a2 = c;
+ A& a3 = static_cast<A&>(c);
+ A& a4 = (A&)c;
+ }
+}
diff --git a/clang/test/SemaCXX/conversion.cpp b/clang/test/SemaCXX/conversion.cpp
new file mode 100644
index 0000000..a64b187
--- /dev/null
+++ b/clang/test/SemaCXX/conversion.cpp
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -Wconversion -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -Wconversion %s 2>&1 | FileCheck %s
+
+#include <stddef.h>
+
+typedef signed char int8_t;
+typedef signed short int16_t;
+typedef signed int int32_t;
+typedef signed long int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long uint64_t;
+
+// <rdar://problem/7909130>
+namespace test0 {
+ int32_t test1_positive(char *I, char *E) {
+ return (E - I); // expected-warning {{implicit conversion loses integer precision}}
+ }
+
+ int32_t test1_negative(char *I, char *E) {
+ return static_cast<int32_t>(E - I);
+ }
+
+ uint32_t test2_positive(uint64_t x) {
+ return x; // expected-warning {{implicit conversion loses integer precision}}
+ }
+
+ uint32_t test2_negative(uint64_t x) {
+ return (uint32_t) x;
+ }
+}
+
+namespace test1 {
+ uint64_t test1(int x, unsigned y) {
+ return sizeof(x == y);
+ }
+
+ uint64_t test2(int x, unsigned y) {
+ return __alignof(x == y);
+ }
+
+ void * const foo();
+ bool test2(void *p) {
+ return p == foo();
+ }
+}
+
+namespace test2 {
+ struct A {
+ unsigned int x : 2;
+ A() : x(10) {} // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}}
+ };
+}
+
+// This file tests -Wnull-conversion, a subcategory of -Wconversion
+// which is on by default.
+
+void test3() {
+ int a = NULL; // expected-warning {{implicit conversion of NULL constant to 'int'}}
+ int b;
+ b = NULL; // expected-warning {{implicit conversion of NULL constant to 'int'}}
+ long l = NULL; // FIXME: this should also warn, but currently does not if sizeof(NULL)==sizeof(inttype)
+ int c = ((((NULL)))); // expected-warning {{implicit conversion of NULL constant to 'int'}}
+ int d;
+ d = ((((NULL)))); // expected-warning {{implicit conversion of NULL constant to 'int'}}
+ bool bl = NULL; // FIXME: this should warn but we currently suppress a bunch of conversion-to-bool warnings including this one
+ char ch = NULL; // expected-warning {{implicit conversion of NULL constant to 'char'}}
+ unsigned char uch = NULL; // expected-warning {{implicit conversion of NULL constant to 'unsigned char'}}
+ short sh = NULL; // expected-warning {{implicit conversion of NULL constant to 'short'}}
+
+ // Use FileCheck to ensure we don't get any unnecessary macro-expansion notes
+ // (that don't appear as 'real' notes & can't be seen/tested by -verify)
+ // CHECK-NOT: note:
+ // CHECK: note: expanded from macro 'FNULL'
+#define FNULL NULL
+ int a2 = FNULL; // expected-warning {{implicit conversion of NULL constant to 'int'}}
+ // CHECK-NOT: note:
+ // CHECK: note: expanded from macro 'FINIT'
+#define FINIT int a3 = NULL;
+ FINIT // expected-warning {{implicit conversion of NULL constant to 'int'}}
+}
diff --git a/clang/test/SemaCXX/convert-to-bool.cpp b/clang/test/SemaCXX/convert-to-bool.cpp
new file mode 100644
index 0000000..c9a3555
--- /dev/null
+++ b/clang/test/SemaCXX/convert-to-bool.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct ConvToBool {
+ operator bool() const;
+};
+
+struct ConvToInt {
+ operator int();
+};
+
+struct ExplicitConvToBool {
+ explicit operator bool(); // expected-warning{{explicit conversion functions are a C++11 extension}}
+};
+
+void test_conv_to_bool(ConvToBool ctb, ConvToInt cti, ExplicitConvToBool ecb) {
+ if (ctb) { }
+ if (cti) { }
+ if (ecb) { }
+ for (; ctb; ) { }
+ for (; cti; ) { }
+ for (; ecb; ) { }
+ while (ctb) { };
+ while (cti) { }
+ while (ecb) { }
+ do { } while (ctb);
+ do { } while (cti);
+ do { } while (ecb);
+
+ if (!ctb) { }
+ if (!cti) { }
+ if (!ecb) { }
+
+ bool b1 = !ecb;
+ if (ctb && ecb) { }
+ bool b2 = ctb && ecb;
+ if (ctb || ecb) { }
+ bool b3 = ctb || ecb;
+}
+
+void accepts_bool(bool) { } // expected-note{{candidate function}}
+
+struct ExplicitConvToRef {
+ explicit operator int&(); // expected-warning{{explicit conversion functions are a C++11 extension}}
+};
+
+void test_explicit_bool(ExplicitConvToBool ecb) {
+ bool b1(ecb); // okay
+ bool b2 = ecb; // expected-error{{no viable conversion from 'ExplicitConvToBool' to 'bool'}}
+ accepts_bool(ecb); // expected-error{{no matching function for call to}}
+}
+
+void test_explicit_conv_to_ref(ExplicitConvToRef ecr) {
+ int& i1 = ecr; // expected-error{{non-const lvalue reference to type 'int' cannot bind to a value of unrelated type 'ExplicitConvToRef'}}
+ int& i2(ecr); // okay
+}
+
+struct A { };
+struct B { };
+struct C {
+ explicit operator A&(); // expected-warning{{explicit conversion functions are a C++11 extension}}
+ operator B&(); // expected-note{{candidate}}
+};
+
+void test_copy_init_conversions(C c) {
+ A &a = c; // expected-error{{no viable conversion from 'C' to 'A'}}
+ B &b = b; // okay
+}
+
diff --git a/clang/test/SemaCXX/converting-constructor.cpp b/clang/test/SemaCXX/converting-constructor.cpp
new file mode 100644
index 0000000..1688e51
--- /dev/null
+++ b/clang/test/SemaCXX/converting-constructor.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class Z { };
+
+class Y {
+public:
+ Y(const Z&);
+};
+
+class X {
+public:
+ X(int);
+ X(const Y&);
+};
+
+void f(X); // expected-note{{candidate function}}
+
+void g(short s, Y y, Z z) {
+ f(s);
+ f(1.0f);
+ f(y);
+ f(z); // expected-error{{no matching function}}
+}
+
+
+class FromShort {
+public:
+ FromShort(short s);
+};
+
+class FromShortExplicitly { // expected-note{{candidate constructor (the implicit copy constructor)}}
+public:
+ explicit FromShortExplicitly(short s);
+};
+
+void explicit_constructor(short s) {
+ FromShort fs1(s);
+ FromShort fs2 = s;
+ FromShortExplicitly fse1(s);
+ FromShortExplicitly fse2 = s; // expected-error{{no viable conversion}}
+}
+
+// PR5519
+struct X1 { X1(const char&); };
+void x1(X1);
+void y1() {
+ x1(1);
+}
diff --git a/clang/test/SemaCXX/copy-assignment.cpp b/clang/test/SemaCXX/copy-assignment.cpp
new file mode 100644
index 0000000..798582c
--- /dev/null
+++ b/clang/test/SemaCXX/copy-assignment.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct A {
+};
+
+struct ConvertibleToA {
+ operator A();
+};
+
+struct ConvertibleToConstA {
+ operator const A();
+};
+
+struct B {
+ B& operator=(B&); // expected-note 4 {{candidate function}}
+};
+
+struct ConvertibleToB {
+ operator B();
+};
+
+struct ConvertibleToBref {
+ operator B&();
+};
+
+struct ConvertibleToConstB {
+ operator const B();
+};
+
+struct ConvertibleToConstBref {
+ operator const B&();
+};
+
+struct C {
+ int operator=(int); // expected-note{{candidate function}}
+ long operator=(long); // expected-note{{candidate function}}
+ int operator+=(int); // expected-note{{candidate function}}
+ int operator+=(long); // expected-note{{candidate function}}
+};
+
+struct D {
+ D& operator+=(const D &);
+};
+
+struct ConvertibleToInt {
+ operator int();
+};
+
+void test() {
+ A a, na;
+ const A constA = A();
+ ConvertibleToA convertibleToA;
+ ConvertibleToConstA convertibleToConstA;
+
+ B b, nb;
+ const B constB = B();
+ ConvertibleToB convertibleToB;
+ ConvertibleToBref convertibleToBref;
+ ConvertibleToConstB convertibleToConstB;
+ ConvertibleToConstBref convertibleToConstBref;
+
+ C c, nc;
+ const C constC = C();
+
+ D d, nd;
+ const D constD = D();
+
+ ConvertibleToInt convertibleToInt;
+
+ na = a;
+ na = constA;
+ na = convertibleToA;
+ na = convertibleToConstA;
+ na += a; // expected-error{{no viable overloaded '+='}}
+
+ nb = b;
+ nb = constB; // expected-error{{no viable overloaded '='}}
+ nb = convertibleToB; // expected-error{{no viable overloaded '='}}
+ nb = convertibleToBref;
+ nb = convertibleToConstB; // expected-error{{no viable overloaded '='}}
+ nb = convertibleToConstBref; // expected-error{{no viable overloaded '='}}
+
+ nc = c;
+ nc = constC;
+ nc = 1;
+ nc = 1L;
+ nc = 1.0; // expected-error{{use of overloaded operator '=' is ambiguous}}
+ nc += 1;
+ nc += 1L;
+ nc += 1.0; // expected-error{{use of overloaded operator '+=' is ambiguous}}
+
+ nd = d;
+ nd += d;
+ nd += constD;
+
+ int i;
+ i = convertibleToInt;
+ i = a; // expected-error{{assigning to 'int' from incompatible type 'A'}}
+}
+
+// <rdar://problem/8315440>: Don't crash
+namespace test1 {
+ template<typename T> class A : public unknown::X { // expected-error {{undeclared identifier 'unknown'}} expected-error {{expected class name}}
+ A(UndeclaredType n) : X(n) {} // expected-error {{unknown type name 'UndeclaredType'}}
+ };
+ template<typename T> class B : public A<T> {
+ virtual void foo() {}
+ };
+ extern template class A<char>;
+ extern template class B<char>;
+}
diff --git a/clang/test/SemaCXX/copy-constructor-error.cpp b/clang/test/SemaCXX/copy-constructor-error.cpp
new file mode 100644
index 0000000..64a7d58
--- /dev/null
+++ b/clang/test/SemaCXX/copy-constructor-error.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct S {
+ S (S); // expected-error {{copy constructor must pass its first argument by reference}}
+};
+
+S f();
+
+void g() {
+ S a( f() );
+}
+
+namespace PR6064 {
+ struct A {
+ A() { }
+ inline A(A&, int); // expected-note {{was not a special member function}}
+ };
+
+ A::A(A&, int = 0) { } // expected-warning {{makes this constructor a copy constructor}}
+
+ void f() {
+ A const a;
+ A b(a);
+ }
+}
diff --git a/clang/test/SemaCXX/copy-initialization.cpp b/clang/test/SemaCXX/copy-initialization.cpp
new file mode 100644
index 0000000..ea2db0c
--- /dev/null
+++ b/clang/test/SemaCXX/copy-initialization.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class X {
+public:
+ explicit X(const X&); // expected-note {{candidate constructor}}
+ X(int*); // expected-note 3{{candidate constructor}}
+ explicit X(float*); // expected-note {{candidate constructor}}
+};
+
+class Y : public X { };
+
+void f(Y y, int *ip, float *fp) {
+ X x1 = y; // expected-error{{no matching constructor for initialization of 'X'}}
+ X x2 = 0;
+ X x3 = ip;
+ X x4 = fp; // expected-error{{no viable conversion}}
+ X x2a(0); // expected-error{{call to constructor of 'X' is ambiguous}}
+ X x3a(ip);
+ X x4a(fp);
+}
+
+struct foo {
+ void bar(); // expected-note{{declared here}}
+};
+
+// PR3600
+void test(const foo *P) { P->bar(); } // expected-error{{'bar' not viable: 'this' argument has type 'const foo', but function is not marked const}}
+
+namespace PR6757 {
+ struct Foo {
+ Foo();
+ Foo(Foo&); // expected-note{{candidate constructor not viable}}
+ };
+
+ struct Bar {
+ operator const Foo&() const;
+ };
+
+ void f(Foo);
+
+ void g(Foo foo) {
+ f(Bar()); // expected-error{{no viable constructor copying parameter of type 'const PR6757::Foo'}}
+ f(foo);
+ }
+}
+
+namespace DR5 {
+ // Core issue 5: if a temporary is created in copy-initialization, it is of
+ // the cv-unqualified version of the destination type.
+ namespace Ex1 {
+ struct C { };
+ C c;
+ struct A {
+ A(const A&);
+ A(const C&);
+ };
+ const volatile A a = c; // ok
+ }
+
+ namespace Ex2 {
+ struct S {
+ S(S&&); // expected-warning {{C++11}}
+ S(int);
+ };
+ const S a(0);
+ const S b = 0;
+ }
+}
diff --git a/clang/test/SemaCXX/crashes.cpp b/clang/test/SemaCXX/crashes.cpp
new file mode 100644
index 0000000..b77248e
--- /dev/null
+++ b/clang/test/SemaCXX/crashes.cpp
@@ -0,0 +1,106 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/8124080>
+template<typename _Alloc> class allocator;
+template<class _CharT> struct char_traits;
+template<typename _CharT, typename _Traits = char_traits<_CharT>,
+ typename _Alloc = allocator<_CharT> >
+class basic_string;
+template<typename _CharT, typename _Traits, typename _Alloc>
+const typename basic_string<_CharT, _Traits, _Alloc>::size_type
+basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_max_size // expected-error{{no member named '_Rep' in 'basic_string<_CharT, _Traits, _Alloc>'}}
+ = (((npos - sizeof(_Rep_base))/sizeof(_CharT)) - 1) / 4;
+
+// PR7118
+template<typename T>
+class Foo {
+ class Bar;
+ void f() {
+ Bar i;
+ }
+};
+
+// PR7625
+template<typename T> struct a : T {
+ struct x : T {
+ int aa() { return p; } // expected-error{{use of undeclared identifier 'p'}}
+ };
+};
+
+// rdar://8605381
+namespace rdar8605381 {
+struct X {};
+
+struct Y { // expected-note{{candidate}}
+ Y();
+};
+
+struct {
+ Y obj;
+} objs[] = {
+ new Y // expected-error{{no viable conversion}}
+};
+}
+
+// http://llvm.org/PR8234
+namespace PR8234 {
+template<typename Signature>
+class callback
+{
+};
+
+template<typename R , typename ARG_TYPE0>
+class callback<R( ARG_TYPE0)>
+{
+ public:
+ callback() {}
+};
+
+template< typename ARG_TYPE0>
+class callback<void( ARG_TYPE0)>
+{
+ public:
+ callback() {}
+};
+
+void f()
+{
+ callback<void(const int&)> op;
+}
+}
+
+namespace PR9007 {
+ struct bar {
+ enum xxx {
+ yyy = sizeof(struct foo*)
+ };
+ foo *xxx();
+ };
+}
+
+namespace PR9026 {
+ class InfallibleTArray {
+ };
+ class Variant;
+ class CompVariant {
+ operator const InfallibleTArray&() const;
+ };
+ class Variant {
+ operator const CompVariant&() const;
+ };
+ void Write(const Variant& __v);
+ void Write(const InfallibleTArray& __v);
+ Variant x;
+ void Write2() {
+ Write(x);
+ }
+}
+
+namespace PR10270 {
+ template<typename T> class C;
+ template<typename T> void f() {
+ if (C<T> == 1) // expected-error{{expected unqualified-id}} \
+ // expected-error{{invalid '==' at end of declaration}}
+ return;
+ }
+}
diff --git a/clang/test/SemaCXX/cstyle-cast.cpp b/clang/test/SemaCXX/cstyle-cast.cpp
new file mode 100644
index 0000000..12495ec
--- /dev/null
+++ b/clang/test/SemaCXX/cstyle-cast.cpp
@@ -0,0 +1,231 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {};
+
+// ----------- const_cast --------------
+
+typedef char c;
+typedef c *cp;
+typedef cp *cpp;
+typedef cpp *cppp;
+typedef cppp &cpppr;
+typedef const cppp &cpppcr;
+typedef const char cc;
+typedef cc *ccp;
+typedef volatile ccp ccvp;
+typedef ccvp *ccvpp;
+typedef const volatile ccvpp ccvpcvp;
+typedef ccvpcvp *ccvpcvpp;
+typedef int iar[100];
+typedef iar &iarr;
+typedef int (*f)(int);
+
+void t_cc()
+{
+ ccvpcvpp var = 0;
+ // Cast away deep consts and volatiles.
+ char ***var2 = (cppp)(var);
+ char ***const &var3 = var2;
+ // Const reference to reference.
+ char ***&var4 = (cpppr)(var3);
+ // Drop reference. Intentionally without qualifier change.
+ char *** var5 = (cppp)(var4);
+ const int ar[100] = {0};
+ // Array decay. Intentionally without qualifier change.
+ int *pi = (int*)(ar);
+ f fp = 0;
+ // Don't misidentify fn** as a function pointer.
+ f *fpp = (f*)(&fp);
+ int const A::* const A::*icapcap = 0;
+ int A::* A::* iapap = (int A::* A::*)(icapcap);
+}
+
+// ----------- static_cast -------------
+
+struct B : public A {}; // Single public base.
+struct C1 : public virtual B {}; // Single virtual base.
+struct C2 : public virtual B {};
+struct D : public C1, public C2 {}; // Diamond
+struct E : private A {}; // Single private base.
+struct F : public C1 {}; // Single path to B with virtual.
+struct G1 : public B {};
+struct G2 : public B {};
+struct H : public G1, public G2 {}; // Ambiguous path to B.
+
+enum Enum { En1, En2 };
+enum Onom { On1, On2 };
+
+struct Co1 { operator int(); };
+struct Co2 { Co2(int); };
+struct Co3 { };
+struct Co4 { Co4(Co3); operator Co3(); };
+
+// Explicit implicits
+void t_529_2()
+{
+ int i = 1;
+ (void)(float)(i);
+ double d = 1.0;
+ (void)(float)(d);
+ (void)(int)(d);
+ (void)(char)(i);
+ (void)(unsigned long)(i);
+ (void)(int)(En1);
+ (void)(double)(En1);
+ (void)(int&)(i);
+ (void)(const int&)(i);
+
+ int ar[1];
+ (void)(const int*)(ar);
+ (void)(void (*)())(t_529_2);
+
+ (void)(void*)(0);
+ (void)(void*)((int*)0);
+ (void)(volatile const void*)((const int*)0);
+ (void)(A*)((B*)0);
+ (void)(A&)(*((B*)0));
+ (void)(const B*)((C1*)0);
+ (void)(B&)(*((C1*)0));
+ (void)(A*)((D*)0);
+ (void)(const A&)(*((D*)0));
+ (void)(int B::*)((int A::*)0);
+ (void)(void (B::*)())((void (A::*)())0);
+ (void)(A*)((E*)0); // C-style cast ignores access control
+ (void)(void*)((const int*)0); // const_cast appended
+
+ (void)(int)(Co1());
+ (void)(Co2)(1);
+ (void)(Co3)((Co4)(Co3()));
+
+ // Bad code below
+ //(void)(A*)((H*)0); // {{static_cast from 'struct H *' to 'struct A *' is not allowed}}
+}
+
+// Anything to void
+void t_529_4()
+{
+ (void)(1);
+ (void)(t_529_4);
+}
+
+// Static downcasts
+void t_529_5_8()
+{
+ (void)(B*)((A*)0);
+ (void)(B&)(*((A*)0));
+ (void)(const G1*)((A*)0);
+ (void)(const G1&)(*((A*)0));
+ (void)(B*)((const A*)0); // const_cast appended
+ (void)(B&)(*((const A*)0)); // const_cast appended
+ (void)(E*)((A*)0); // access control ignored
+ (void)(E&)(*((A*)0)); // access control ignored
+
+ // Bad code below
+
+ (void)(C1*)((A*)0); // expected-error {{cannot cast 'A *' to 'C1 *' via virtual base 'B'}}
+ (void)(C1&)(*((A*)0)); // expected-error {{cannot cast 'A' to 'C1 &' via virtual base 'B'}}
+ (void)(D*)((A*)0); // expected-error {{cannot cast 'A *' to 'D *' via virtual base 'B'}}
+ (void)(D&)(*((A*)0)); // expected-error {{cannot cast 'A' to 'D &' via virtual base 'B'}}
+ (void)(H*)((A*)0); // expected-error {{ambiguous cast from base 'A' to derived 'H':\n struct A -> struct B -> struct G1 -> struct H\n struct A -> struct B -> struct G2 -> struct H}}
+ (void)(H&)(*((A*)0)); // expected-error {{ambiguous cast from base 'A' to derived 'H':\n struct A -> struct B -> struct G1 -> struct H\n struct A -> struct B -> struct G2 -> struct H}}
+
+ // TODO: Test DR427. This requires user-defined conversions, though.
+}
+
+// Enum conversions
+void t_529_7()
+{
+ (void)(Enum)(1);
+ (void)(Enum)(1.0);
+ (void)(Onom)(En1);
+
+ // Bad code below
+
+ (void)(Enum)((int*)0); // expected-error {{C-style cast from 'int *' to 'Enum' is not allowed}}
+}
+
+// Void pointer to object pointer
+void t_529_10()
+{
+ (void)(int*)((void*)0);
+ (void)(const A*)((void*)0);
+ (void)(int*)((const void*)0); // const_cast appended
+}
+
+// Member pointer upcast.
+void t_529_9()
+{
+ (void)(int A::*)((int B::*)0);
+
+ // Bad code below
+ (void)(int A::*)((int H::*)0); // expected-error {{ambiguous conversion from pointer to member of derived class 'H' to pointer to member of base class 'A':}}
+ (void)(int A::*)((int F::*)0); // expected-error {{conversion from pointer to member of class 'F' to pointer to member of class 'A' via virtual base 'B' is not allowed}}
+}
+
+// -------- reinterpret_cast -----------
+
+enum test { testval = 1 };
+struct structure { int m; };
+typedef void (*fnptr)();
+
+// Test conversion between pointer and integral types, as in p3 and p4.
+void integral_conversion()
+{
+ void *vp = (void*)(testval);
+ long l = (long)(vp);
+ (void)(float*)(l);
+ fnptr fnp = (fnptr)(l);
+ (void)(char)(fnp); // expected-error {{cast from pointer to smaller type 'char' loses information}}
+ (void)(long)(fnp);
+}
+
+void pointer_conversion()
+{
+ int *p1 = 0;
+ float *p2 = (float*)(p1);
+ structure *p3 = (structure*)(p2);
+ typedef int **ppint;
+ ppint *deep = (ppint*)(p3);
+ (void)(fnptr*)(deep);
+}
+
+void constness()
+{
+ int ***const ipppc = 0;
+ int const *icp = (int const*)(ipppc);
+ (void)(int*)(icp); // const_cast appended
+ int const *const **icpcpp = (int const* const**)(ipppc); // const_cast appended
+ int *ip = (int*)(icpcpp);
+ (void)(int const*)(ip);
+ (void)(int const* const* const*)(ipppc);
+}
+
+void fnptrs()
+{
+ typedef int (*fnptr2)(int);
+ fnptr fp = 0;
+ (void)(fnptr2)(fp);
+ void *vp = (void*)(fp);
+ (void)(fnptr)(vp);
+}
+
+void refs()
+{
+ long l = 0;
+ char &c = (char&)(l);
+ // Bad: from rvalue
+ (void)(int&)(&c); // expected-error {{C-style cast from rvalue to reference type 'int &'}}
+}
+
+void memptrs()
+{
+ const int structure::*psi = 0;
+ (void)(const float structure::*)(psi);
+ (void)(int structure::*)(psi); // const_cast appended
+
+ void (structure::*psf)() = 0;
+ (void)(int (structure::*)())(psf);
+
+ (void)(void (structure::*)())(psi); // expected-error {{C-style cast from 'const int structure::*' to 'void (structure::*)()' is not allowed}}
+ (void)(int structure::*)(psf); // expected-error {{C-style cast from 'void (structure::*)()' to 'int structure::*' is not allowed}}
+}
diff --git a/clang/test/SemaCXX/cv-unqual-rvalues.cpp b/clang/test/SemaCXX/cv-unqual-rvalues.cpp
new file mode 100644
index 0000000..ed76ced
--- /dev/null
+++ b/clang/test/SemaCXX/cv-unqual-rvalues.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR7463: Make sure that when we have an rvalue, it does not have
+// cv-qualified non-class type.
+template <typename T_> void g (T_&); // expected-note 7{{not viable}}
+
+template<const int X> void h() {
+ g(X); // expected-error{{no matching function for call to 'g'}}
+}
+
+template<typename T, T X> void h2() {
+ g(X); // expected-error{{no matching function for call to 'g'}}
+}
+
+void a(__builtin_va_list x) {
+ g(__builtin_va_arg(x, const int)); // expected-error{{no matching function for call to 'g'}}
+ g((const int)0); // expected-error{{no matching function for call to 'g'}}
+ typedef const int cint;
+ g(cint(0)); // expected-error{{no matching function for call to 'g'}}
+ g(static_cast<const int>(1)); // expected-error{{no matching function for call to 'g'}}
+ g(reinterpret_cast<int *const>(0)); // expected-error{{no matching function for call to 'g'}}
+ h<0>();
+ h2<const int, 0>(); // expected-note{{instantiation of}}
+}
diff --git a/clang/test/SemaCXX/cxx-member-pointer-op.cpp b/clang/test/SemaCXX/cxx-member-pointer-op.cpp
new file mode 100644
index 0000000..f43d438
--- /dev/null
+++ b/clang/test/SemaCXX/cxx-member-pointer-op.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+
+struct C {
+ static int (C::* a);
+};
+
+typedef void (C::*pmfc)();
+
+void g(pmfc) {
+ C *c;
+ c->*pmfc(); // expected-error {{invalid use of pointer to member type after ->*}}
+ C c1;
+ c1.*pmfc(); // expected-error {{invalid use of pointer to member type after .*}}
+ c->*(pmfc()); // expected-error {{invalid use of pointer to member type after ->*}}
+ c1.*((pmfc())); // expected-error {{invalid use of pointer to member type after .*}}
+}
+
+int a(C* x) {
+ return x->*C::a;
+}
+
diff --git a/clang/test/SemaCXX/cxx0x-class.cpp b/clang/test/SemaCXX/cxx0x-class.cpp
new file mode 100644
index 0000000..41b0a5c
--- /dev/null
+++ b/clang/test/SemaCXX/cxx0x-class.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+int vs = 0;
+
+class C {
+public:
+ struct NestedC {
+ NestedC(int);
+ };
+
+ int i = 0;
+ static int si = 0; // expected-error {{non-const static data member must be initialized out of line}}
+ static const NestedC ci = 0; // expected-error {{static data member of type 'const C::NestedC' must be initialized out of line}}
+ static const int nci = vs; // expected-error {{in-class initializer for static data member is not a constant expression}}
+ static const int vi = 0;
+ static const volatile int cvi = 0; // expected-error {{static const volatile data member must be initialized out of line}}
+};
+
+namespace rdar8367341 {
+ float foo(); // expected-note {{here}}
+
+ struct A {
+ static const float x = 5.0f; // expected-warning {{GNU extension}} expected-note {{use 'constexpr' specifier to silence this warning}}
+ static const float y = foo(); // expected-warning {{GNU extension}} expected-note {{use 'constexpr' specifier to silence this warning}} expected-error {{in-class initializer for static data member is not a constant expression}}
+ static constexpr float x2 = 5.0f;
+ static constexpr float y2 = foo(); // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr function 'foo'}}
+ };
+}
+
+
+namespace Foo {
+ // Regression test -- forward declaration of Foo should not cause error about
+ // nonstatic data member.
+ class Foo;
+ class Foo {
+ int x;
+ int y = x;
+ };
+}
diff --git a/clang/test/SemaCXX/cxx0x-compat.cpp b/clang/test/SemaCXX/cxx0x-compat.cpp
new file mode 100644
index 0000000..123008a
--- /dev/null
+++ b/clang/test/SemaCXX/cxx0x-compat.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat -verify %s
+
+namespace N {
+ template<typename T> void f(T) {} // expected-note 2{{here}}
+ namespace M {
+ template void ::N::f<int>(int); // expected-warning {{explicit instantiation of 'f' not in a namespace enclosing 'N'}}
+ }
+}
+using namespace N;
+template void f<char>(char); // expected-warning {{explicit instantiation of 'N::f' must occur in namespace 'N'}}
+
+template<typename T> void g(T) {} // expected-note 2{{here}}
+namespace M {
+ template void g<int>(int); // expected-warning {{explicit instantiation of 'g' must occur at global scope}}
+ template void ::g<char>(char); // expected-warning {{explicit instantiation of 'g' must occur at global scope}}
+}
+
+template inline void g<double>(double); // expected-warning {{explicit instantiation cannot be 'inline'}}
+
+void g() {
+ auto int n = 0; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}}
+}
+
+int n;
+struct S {
+ char c;
+}
+s = { n }, // expected-warning {{non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list in C++11}} expected-note {{explicit cast}}
+t = { 1234 }; // expected-warning {{constant expression evaluates to 1234 which cannot be narrowed to type 'char' in C++11}} expected-warning {{changes value}} expected-note {{explicit cast}}
+
+#define PRIuS "uS"
+int printf(const char *, ...);
+typedef __typeof(sizeof(int)) size_t;
+void h(size_t foo, size_t bar) {
+ printf("foo is %"PRIuS", bar is %"PRIuS, foo, bar); // expected-warning 2{{identifier after literal will be treated as a reserved user-defined literal suffix in C++11}}
+}
+
+#define _x + 1
+char c = 'x'_x; // expected-warning {{will be treated as a user-defined literal suffix}}
diff --git a/clang/test/SemaCXX/cxx0x-constexpr-const.cpp b/clang/test/SemaCXX/cxx0x-constexpr-const.cpp
new file mode 100644
index 0000000..197edeb
--- /dev/null
+++ b/clang/test/SemaCXX/cxx0x-constexpr-const.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+constexpr int x = 1;
+constexpr int id(int x) { return x; }
+
+void foo(void) {
+ x = 2; // expected-error {{read-only variable is not assignable}}
+ int (*idp)(int) = id;
+}
+
diff --git a/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp b/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp
new file mode 100644
index 0000000..3290595
--- /dev/null
+++ b/clang/test/SemaCXX/cxx0x-cursory-default-delete.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct non_copiable {
+ non_copiable(const non_copiable&) = delete; // expected-note {{marked deleted here}}
+ non_copiable& operator = (const non_copiable&) = delete; // expected-note {{explicitly deleted}}
+ non_copiable() = default;
+};
+
+struct non_const_copy {
+ non_const_copy(non_const_copy&) = default; // expected-note {{not viable}}
+ non_const_copy& operator = (non_const_copy&) & = default; // expected-note {{not viable}}
+ non_const_copy& operator = (non_const_copy&) && = default; // expected-note {{not viable}}
+ non_const_copy() = default; // expected-note {{not viable}}
+};
+
+void fn1 () {
+ non_copiable nc;
+ non_copiable nc2 = nc; // expected-error {{deleted constructor}}
+ nc = nc; // expected-error {{deleted operator}}
+
+ non_const_copy ncc;
+ non_const_copy ncc2 = ncc;
+ ncc = ncc2;
+ const non_const_copy cncc;
+ non_const_copy ncc3 = cncc; // expected-error {{no matching}}
+ ncc = cncc; // expected-error {{no viable overloaded}}
+};
+
+struct non_const_derived : non_const_copy {
+ non_const_derived(const non_const_derived&) = default; // expected-error {{requires it to be non-const}}
+ non_const_derived& operator =(non_const_derived&) = default;
+};
+
+struct bad_decls {
+ bad_decls(volatile bad_decls&) = default; // expected-error {{may not be volatile}}
+ bad_decls&& operator = (bad_decls) = default; // expected-error 2{{lvalue reference}}
+ bad_decls& operator = (volatile bad_decls&) = default; // expected-error {{may not be volatile}}
+ bad_decls& operator = (const bad_decls&) const = default; // expected-error {{may not have 'const', 'constexpr' or 'volatile' qualifiers}}
+};
+
+struct A {}; struct B {};
+
+struct except_spec_a {
+ virtual ~except_spec_a() throw(A);
+ except_spec_a() throw(A);
+};
+struct except_spec_b {
+ virtual ~except_spec_b() throw(B);
+ except_spec_b() throw(B);
+};
+
+struct except_spec_d_good : except_spec_a, except_spec_b {
+ ~except_spec_d_good();
+};
+except_spec_d_good::~except_spec_d_good() = default;
+// FIXME: This should error in the virtual override check.
+// It doesn't because we generate the implicit specification later than
+// appropriate.
+struct except_spec_d_bad : except_spec_a, except_spec_b {
+ ~except_spec_d_bad() = default;
+};
+
+// FIXME: This should error because the exceptions spec doesn't match.
+struct except_spec_d_mismatch : except_spec_a, except_spec_b {
+ except_spec_d_mismatch() throw(A) = default;
+};
+struct except_spec_d_match : except_spec_a, except_spec_b {
+ except_spec_d_match() throw(A, B) = default;
+};
+
+// gcc-compatibility: allow attributes on default definitions
+// (but not normal definitions)
+struct S { S(); };
+S::S() __attribute((pure)) = default;
+
diff --git a/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp b/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
new file mode 100644
index 0000000..2e4107c
--- /dev/null
+++ b/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+void fn() = default; // expected-error {{only special member}}
+struct foo {
+ void fn() = default; // expected-error {{only special member}}
+
+ foo() = default;
+ foo(const foo&) = default;
+ foo(foo&) = default;
+ foo& operator = (const foo&) = default;
+ foo& operator = (foo&) = default;
+ ~foo() = default;
+};
+
+struct bar {
+ bar();
+ bar(const bar&);
+ bar(bar&);
+ bar& operator = (const bar&);
+ bar& operator = (bar&);
+ ~bar();
+};
+
+bar::bar() = default;
+bar::bar(const bar&) = default;
+bar::bar(bar&) = default;
+bar& bar::operator = (const bar&) = default;
+bar& bar::operator = (bar&) = default;
+bar::~bar() = default;
+
+static_assert(__is_trivial(foo), "foo should be trivial");
+
+static_assert(!__has_trivial_destructor(bar), "bar's destructor isn't trivial");
+static_assert(!__has_trivial_constructor(bar),
+ "bar's default constructor isn't trivial");
+static_assert(!__has_trivial_copy(bar), "bar has no trivial copy");
+static_assert(!__has_trivial_assign(bar), "bar has no trivial assign");
+
+void tester() {
+ foo f, g(f);
+ bar b, c(b);
+ f = g;
+ b = c;
+}
+
+template<typename T> struct S : T {
+ constexpr S() = default;
+ constexpr S(const S&) = default;
+ constexpr S(S&&) = default;
+};
+struct lit { constexpr lit() {} };
+S<lit> s_lit; // ok
+S<bar> s_bar; // ok
diff --git a/clang/test/SemaCXX/cxx0x-delegating-ctors.cpp b/clang/test/SemaCXX/cxx0x-delegating-ctors.cpp
new file mode 100644
index 0000000..2d49f0f
--- /dev/null
+++ b/clang/test/SemaCXX/cxx0x-delegating-ctors.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+struct foo {
+ int i;
+ foo();
+ foo(int);
+ foo(int, int);
+ foo(bool);
+ foo(char);
+ foo(const float*);
+ foo(const float&);
+ foo(void*);
+};
+
+// Good
+foo::foo (int i) : i(i) {
+}
+// Good
+foo::foo () : foo(-1) {
+}
+// Good
+foo::foo (int, int) : foo() {
+}
+
+foo::foo (bool) : foo(true) { // expected-error{{creates a delegation cycle}}
+}
+
+// Good
+foo::foo (const float* f) : foo(*f) { // expected-note{{it delegates to}}
+}
+
+foo::foo (const float &f) : foo(&f) { //expected-error{{creates a delegation cycle}} \
+ //expected-note{{which delegates to}}
+}
+
+foo::foo (char) : i(3), foo(3) { // expected-error{{must appear alone}}
+}
+
+// This should not cause an infinite loop
+foo::foo (void*) : foo(4.0f) {
+}
+
+struct deleted_dtor {
+ ~deleted_dtor() = delete; // expected-note{{function has been explicitly marked deleted here}}
+ deleted_dtor();
+ deleted_dtor(int) : deleted_dtor() // expected-error{{attempt to use a deleted function}}
+ {}
+};
diff --git a/clang/test/SemaCXX/cxx0x-deleted-default-ctor.cpp b/clang/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
new file mode 100644
index 0000000..0cebc10
--- /dev/null
+++ b/clang/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
@@ -0,0 +1,131 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct non_trivial {
+ non_trivial();
+ non_trivial(const non_trivial&);
+ non_trivial& operator = (const non_trivial&);
+ ~non_trivial();
+};
+
+union bad_union {
+ non_trivial nt; // expected-note {{non-trivial default constructor}}
+};
+bad_union u; // expected-error {{call to implicitly-deleted default constructor}}
+union bad_union2 { // expected-note {{all data members are const-qualified}}
+ const int i;
+};
+bad_union2 u2; // expected-error {{call to implicitly-deleted default constructor}}
+
+struct bad_anon {
+ union {
+ non_trivial nt; // expected-note {{non-trivial default constructor}}
+ };
+};
+bad_anon a; // expected-error {{call to implicitly-deleted default constructor}}
+struct bad_anon2 {
+ union { // expected-note {{all data members of an anonymous union member are const-qualified}}
+ const int i;
+ };
+};
+bad_anon2 a2; // expected-error {{call to implicitly-deleted default constructor}}
+
+// This would be great except that we implement
+union good_union {
+ const int i;
+ float f;
+};
+good_union gu;
+struct good_anon {
+ union {
+ const int i;
+ float f;
+ };
+};
+good_anon ga;
+
+struct good : non_trivial {
+ non_trivial nt;
+};
+good g;
+
+struct bad_const {
+ const good g; // expected-note {{field 'g' of const-qualified type 'const good' would not be initialized}}
+};
+bad_const bc; // expected-error {{call to implicitly-deleted default constructor}}
+
+struct good_const {
+ const non_trivial nt;
+};
+good_const gc;
+
+struct no_default {
+ no_default() = delete; // expected-note 3{{deleted here}}
+};
+struct no_dtor {
+ ~no_dtor() = delete; // expected-note 2{{deleted here}}
+};
+
+struct bad_field_default {
+ no_default nd; // expected-note {{field 'nd' has a deleted default constructor}}
+};
+bad_field_default bfd; // expected-error {{call to implicitly-deleted default constructor}}
+struct bad_base_default : no_default { // expected-note {{base class 'no_default' has a deleted default constructor}}
+};
+bad_base_default bbd; // expected-error {{call to implicitly-deleted default constructor}}
+
+struct bad_field_dtor {
+ no_dtor nd; // expected-note {{field 'nd' has a deleted destructor}}
+};
+bad_field_dtor bfx; // expected-error {{call to implicitly-deleted default constructor}}
+struct bad_base_dtor : no_dtor { // expected-note {{base class 'no_dtor' has a deleted destructor}}
+};
+bad_base_dtor bbx; // expected-error {{call to implicitly-deleted default constructor}}
+
+struct ambiguous_default {
+ ambiguous_default();
+ ambiguous_default(int = 2);
+};
+struct has_amb_field {
+ ambiguous_default ad; // expected-note {{field 'ad' has multiple default constructors}}
+};
+has_amb_field haf; // expected-error {{call to implicitly-deleted default constructor}}
+
+class inaccessible_default {
+ inaccessible_default();
+};
+struct has_inacc_field {
+ inaccessible_default id; // expected-note {{field 'id' has an inaccessible default constructor}}
+};
+has_inacc_field hif; // expected-error {{call to implicitly-deleted default constructor}}
+
+class friend_default {
+ friend struct has_friend;
+ friend_default();
+};
+struct has_friend {
+ friend_default fd;
+};
+has_friend hf;
+
+struct defaulted_delete {
+ no_default nd; // expected-note {{because field 'nd' has a deleted default constructor}}
+ defaulted_delete() = default; // expected-note{{implicitly deleted here}}
+};
+defaulted_delete dd; // expected-error {{call to implicitly-deleted default constructor}}
+
+struct late_delete {
+ no_default nd;
+ late_delete();
+};
+late_delete::late_delete() = default; // expected-error {{would delete it}}
+
+// See also rdar://problem/8125400.
+namespace empty {
+ static union {};
+ static union { union {}; };
+ static union { struct {}; };
+ static union { union { union {}; }; };
+ static union { union { struct {}; }; };
+ static union { struct { union {}; }; };
+ static union { struct { struct {}; }; };
+}
diff --git a/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp b/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
new file mode 100644
index 0000000..801a82f
--- /dev/null
+++ b/clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+struct one { char c[1]; };
+struct two { char c[2]; };
+
+namespace aggregate {
+ // Direct list initialization does NOT allow braces to be elided!
+ struct S {
+ int ar[2];
+ struct T {
+ int i1;
+ int i2;
+ } t;
+ struct U {
+ int i1;
+ } u[2];
+ struct V {
+ int var[2];
+ } v;
+ };
+
+ void bracing() {
+ S s1 = { 1, 2, 3 ,4, 5, 6, 7, 8 }; // no-error
+ S s2{ {1, 2}, {3, 4}, { {5}, {6} }, { {7, 8} } }; // completely braced
+ S s3{ 1, 2, 3, 4, 5, 6 }; // expected-error 5 {{cannot omit braces}}
+ S s4{ {1, 2}, {3, 4}, {5, 6}, { {7, 8} } }; // expected-error 2 {{cannot omit braces}}
+ S s5{ {1, 2}, {3, 4}, { {5}, {6} }, {7, 8} }; // expected-error {{cannot omit braces}}
+ }
+
+ void bracing_new() {
+ new S{ {1, 2}, {3, 4}, { {5}, {6} }, { {7, 8} } }; // completely braced
+ new S{ 1, 2, 3, 4, 5, 6 }; // expected-error 5 {{cannot omit braces}}
+ new S{ {1, 2}, {3, 4}, {5, 6}, { {7, 8} } }; // expected-error 2 {{cannot omit braces}}
+ new S{ {1, 2}, {3, 4}, { {5}, {6} }, {7, 8} }; // expected-error {{cannot omit braces}}
+ }
+
+ void bracing_construct() {
+ (void) S{ {1, 2}, {3, 4}, { {5}, {6} }, { {7, 8} } }; // completely braced
+ (void) S{ 1, 2, 3, 4, 5, 6 }; // expected-error 5 {{cannot omit braces}}
+ (void) S{ {1, 2}, {3, 4}, {5, 6}, { {7, 8} } }; // expected-error 2 {{cannot omit braces}}
+ (void) S{ {1, 2}, {3, 4}, { {5}, {6} }, {7, 8} }; // expected-error {{cannot omit braces}}
+ }
+
+ struct String {
+ String(const char*);
+ };
+
+ struct A {
+ int m1;
+ int m2;
+ };
+
+ void function_call() {
+ void takes_A(A);
+ takes_A({1, 2});
+ }
+
+ struct B {
+ int m1;
+ String m2;
+ };
+
+ void overloaded_call() {
+ one overloaded(A);
+ two overloaded(B);
+
+ static_assert(sizeof(overloaded({1, 2})) == sizeof(one), "bad overload");
+ static_assert(sizeof(overloaded({1, "two"})) == sizeof(two),
+ "bad overload");
+ // String is not default-constructible
+ static_assert(sizeof(overloaded({1})) == sizeof(one), "bad overload");
+ }
+
+ struct C { int a[2]; C():a({1, 2}) { } }; // expected-error {{parenthesized initialization of a member array is a GNU extension}}
+}
+
+namespace array_explicit_conversion {
+ typedef int test1[2];
+ typedef int test2[];
+ template<int x> struct A { int a[x]; }; // expected-error {{'a' declared as an array with a negative size}}
+ typedef A<1> test3[];
+ typedef A<-1> test4[];
+ void f() {
+ (void)test1{1};
+ (void)test2{1};
+ (void)test3{{{1}}};
+ (void)test4{{{1}}}; // expected-note {{in instantiation of template class 'array_explicit_conversion::A<-1>' requested here}}
+ }
+}
diff --git a/clang/test/SemaCXX/cxx0x-initializer-constructor.cpp b/clang/test/SemaCXX/cxx0x-initializer-constructor.cpp
new file mode 100644
index 0000000..09aca24
--- /dev/null
+++ b/clang/test/SemaCXX/cxx0x-initializer-constructor.cpp
@@ -0,0 +1,283 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+struct one { char c[1]; };
+struct two { char c[2]; };
+
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b),
+ __size_(__s)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+}
+
+namespace objects {
+
+ struct X1 { X1(int); };
+ struct X2 { explicit X2(int); }; // expected-note {{constructor declared here}}
+
+ template <int N>
+ struct A {
+ A() { static_assert(N == 0, ""); }
+ A(int, double) { static_assert(N == 1, ""); }
+ };
+
+ template <int N>
+ struct F {
+ F() { static_assert(N == 0, ""); }
+ F(int, double) { static_assert(N == 1, ""); }
+ F(std::initializer_list<int>) { static_assert(N == 3, ""); }
+ };
+
+ template <int N>
+ struct D {
+ D(std::initializer_list<int>) { static_assert(N == 0, ""); } // expected-note 1 {{candidate}}
+ D(std::initializer_list<double>) { static_assert(N == 1, ""); } // expected-note 1 {{candidate}}
+ };
+
+ template <int N>
+ struct E {
+ E(int, int) { static_assert(N == 0, ""); }
+ E(X1, int) { static_assert(N == 1, ""); }
+ };
+
+ void overload_resolution() {
+ { A<0> a{}; }
+ { A<0> a = {}; }
+ { A<1> a{1, 1.0}; }
+ { A<1> a = {1, 1.0}; }
+
+ { F<0> f{}; }
+ { F<0> f = {}; }
+ // Narrowing conversions don't affect viability. The next two choose
+ // the initializer_list constructor.
+ // FIXME: Emit narrowing conversion errors.
+ { F<3> f{1, 1.0}; } // xpected-error {{narrowing conversion}}
+ { F<3> f = {1, 1.0}; } // xpected-error {{narrowing conversion}}
+ { F<3> f{1, 2, 3, 4, 5, 6, 7, 8}; }
+ { F<3> f = {1, 2, 3, 4, 5, 6, 7, 8}; }
+ { F<3> f{1, 2, 3, 4, 5, 6, 7, 8}; }
+ { F<3> f{1, 2}; }
+
+ { D<0> d{1, 2, 3}; }
+ { D<1> d{1.0, 2.0, 3.0}; }
+ { D<-1> d{1, 2.0}; } // expected-error {{ambiguous}}
+
+ { E<0> e{1, 2}; }
+ }
+
+ void explicit_implicit() {
+ { X1 x{0}; }
+ { X1 x = {0}; }
+ { X2 x{0}; }
+ { X2 x = {0}; } // expected-error {{constructor is explicit}}
+ }
+
+ struct C {
+ C();
+ C(int, double);
+ C(int, int);
+
+ int operator[](C);
+ };
+
+ C function_call() {
+ void takes_C(C);
+ takes_C({1, 1.0});
+
+ C c;
+ c[{1, 1.0}];
+
+ return {1, 1.0};
+ }
+
+ void inline_init() {
+ (void) C{1, 1.0};
+ (void) new C{1, 1.0};
+ (void) A<1>{1, 1.0};
+ (void) new A<1>{1, 1.0};
+ }
+
+ struct B { // expected-note 2 {{candidate constructor}}
+ B(C, int, C); // expected-note {{candidate constructor not viable: cannot convert initializer list argument to 'objects::C'}}
+ };
+
+ void nested_init() {
+ B b1{{1, 1.0}, 2, {3, 4}};
+ B b2{{1, 1.0, 4}, 2, {3, 4}}; // expected-error {{no matching constructor for initialization of 'objects::B'}}
+ }
+
+ void overloaded_call() {
+ one ov1(B); // expected-note {{not viable: cannot convert initializer list}}
+ two ov1(C); // expected-note {{not viable: cannot convert initializer list}}
+
+ static_assert(sizeof(ov1({})) == sizeof(two), "bad overload");
+ static_assert(sizeof(ov1({1, 2})) == sizeof(two), "bad overload");
+ static_assert(sizeof(ov1({{1, 1.0}, 2, {3, 4}})) == sizeof(one), "bad overload");
+
+ ov1({1}); // expected-error {{no matching function}}
+
+ one ov2(int);
+ two ov2(F<3>);
+ static_assert(sizeof(ov2({1})) == sizeof(one), "bad overload"); // list -> int ranks as identity
+ static_assert(sizeof(ov2({1, 2, 3})) == sizeof(two), "bad overload"); // list -> F only viable
+ }
+
+ struct G { // expected-note 6 {{not viable}}
+ // This is not an initializer-list constructor.
+ template<typename ...T>
+ G(std::initializer_list<int>, T ...); // expected-note 3 {{not viable}}
+ };
+
+ struct H { // expected-note 6 {{not viable}}
+ explicit H(int, int); // expected-note 3 {{not viable}} expected-note {{declared here}}
+ H(int, void*); // expected-note 3 {{not viable}}
+ };
+
+ void edge_cases() {
+ // invalid (the first phase only considers init-list ctors)
+ // (for the second phase, no constructor is viable)
+ G g1{1, 2, 3}; // expected-error {{no matching constructor}}
+ (void) new G{1, 2, 3}; // expected-error {{no matching constructor}}
+ (void) G{1, 2, 3} // expected-error {{no matching constructor}}
+
+ // valid (T deduced to <>).
+ G g2({1, 2, 3});
+ (void) new G({1, 2, 3});
+ (void) G({1, 2, 3});
+
+ // invalid
+ H h1({1, 2}); // expected-error {{no matching constructor}}
+ (void) new H({1, 2}); // expected-error {{no matching constructor}}
+ // FIXME: Bad diagnostic, mentions void type instead of init list.
+ (void) H({1, 2}); // expected-error {{no matching conversion}}
+
+ // valid (by copy constructor).
+ H h2({1, nullptr});
+ (void) new H({1, nullptr});
+ (void) H({1, nullptr});
+
+ // valid
+ H h3{1, 2};
+ (void) new H{1, 2};
+ (void) H{1, 2};
+ }
+
+ struct memberinit {
+ H h1{1, nullptr};
+ H h2 = {1, nullptr};
+ H h3{1, 1};
+ H h4 = {1, 1}; // expected-error {{constructor is explicit}}
+ };
+}
+
+namespace PR12092 {
+
+ struct S {
+ S(const char*);
+ };
+ struct V {
+ template<typename T> V(T, T);
+ void f(std::initializer_list<S>);
+ void f(const V &);
+ };
+
+ void g() {
+ extern V s;
+ s.f({"foo", "bar"});
+ }
+
+}
+
+namespace PR12117 {
+ struct A { A(int); };
+ struct B { B(A); } b{{0}};
+ struct C { C(int); } c{0};
+}
+
+namespace PR12167 {
+ template<int N> struct string {};
+
+ struct X {
+ X(const char v);
+ template<typename T> bool operator()(T) const;
+ };
+
+ template<int N, class Comparator> bool g(const string<N>& s, Comparator cmp) {
+ return cmp(s);
+ }
+ template<int N> bool f(const string<N> &s) {
+ return g(s, X{'x'});
+ }
+
+ bool s = f(string<1>());
+}
+
+namespace PR12257_PR12241 {
+ struct command_pair
+ {
+ command_pair(int, int);
+ };
+
+ struct command_map
+ {
+ command_map(std::initializer_list<command_pair>);
+ };
+
+ struct generator_pair
+ {
+ generator_pair(const command_map);
+ };
+
+ // 5 levels: init list, gen_pair, command_map, init list, command_pair
+ const std::initializer_list<generator_pair> x = {{{{{3, 4}}}}};
+
+ // 4 levels: init list, gen_pair, command_map via init list, command_pair
+ const std::initializer_list<generator_pair> y = {{{{1, 2}}}};
+}
+
+namespace PR12120 {
+ struct A { explicit A(int); A(float); }; // expected-note {{declared here}}
+ A a = { 0 }; // expected-error {{constructor is explicit}}
+
+ struct B { explicit B(short); B(long); }; // expected-note 2 {{candidate}}
+ B b = { 0 }; // expected-error {{ambiguous}}
+}
+
+namespace PR12498 {
+ class ArrayRef; // expected-note{{forward declaration}}
+
+ struct C {
+ void foo(const ArrayRef&); // expected-note{{passing argument to parameter here}}
+ };
+
+ static void bar(C* c)
+ {
+ c->foo({ nullptr, 1 }); // expected-error{{initialization of incomplete type 'const PR12498::ArrayRef'}}
+ }
+
+}
diff --git a/clang/test/SemaCXX/cxx0x-initializer-references.cpp b/clang/test/SemaCXX/cxx0x-initializer-references.cpp
new file mode 100644
index 0000000..c4e9c90
--- /dev/null
+++ b/clang/test/SemaCXX/cxx0x-initializer-references.cpp
@@ -0,0 +1,92 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct one { char c; };
+struct two { char c[2]; };
+
+namespace reference {
+ struct A {
+ int i1, i2;
+ };
+
+ void single_init() {
+ const int &cri1a = {1};
+ const int &cri1b{1};
+
+ int i = 1;
+ int &ri1a = {i};
+ int &ri1b{i};
+
+ int &ri2 = {1}; // expected-error {{cannot bind to an initializer list temporary}}
+
+ A a{1, 2};
+ A &ra1a = {a};
+ A &ra1b{a};
+ }
+
+ void reference_to_aggregate() {
+ const A &ra1{1, 2};
+ A &ra2{1, 2}; // expected-error {{cannot bind to an initializer list temporary}}
+
+ const int (&arrayRef)[] = {1, 2, 3};
+ static_assert(sizeof(arrayRef) == 3 * sizeof(int), "bad array size");
+ }
+
+ struct B {
+ int i1;
+ };
+
+ void call() {
+ void f(const int&);
+ f({1});
+
+ void g(int&); // expected-note {{passing argument}}
+ g({1}); // expected-error {{cannot bind to an initializer list temporary}}
+ int i = 0;
+ g({i});
+
+ void h(const B&);
+ h({1});
+
+ void a(B&); // expected-note {{passing argument}}
+ a({1}); // expected-error {{cannot bind to an initializer list temporary}}
+ B b{1};
+ a({b});
+ }
+
+ void overloading() {
+ one f(const int&);
+ two f(const B&);
+
+ // First is identity conversion, second is user-defined conversion.
+ static_assert(sizeof(f({1})) == sizeof(one), "bad overload resolution");
+
+ one g(int&);
+ two g(const B&);
+
+ static_assert(sizeof(g({1})) == sizeof(two), "bad overload resolution");
+
+ one h(const int&);
+ two h(const A&);
+
+ static_assert(sizeof(h({1, 2})) == sizeof(two), "bad overload resolution");
+ }
+
+ void edge_cases() {
+ // FIXME: very poor error message
+ int const &b({0}); // expected-error {{could not bind}}
+ }
+
+}
+
+namespace PR12182 {
+ void f(int const(&)[3]);
+
+ void g() {
+ f({1, 2});
+ }
+}
+
+namespace PR12660 {
+ const int &i { 1 };
+ struct S { S(int); } const &s { 2 };
+}
diff --git a/clang/test/SemaCXX/cxx0x-initializer-scalars.cpp b/clang/test/SemaCXX/cxx0x-initializer-scalars.cpp
new file mode 100644
index 0000000..627855e
--- /dev/null
+++ b/clang/test/SemaCXX/cxx0x-initializer-scalars.cpp
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct one { char c[1]; };
+struct two { char c[2]; };
+
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b),
+ __size_(__s)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+}
+
+namespace integral {
+
+ void initialization() {
+ { const int a{}; static_assert(a == 0, ""); }
+ { const int a = {}; static_assert(a == 0, ""); }
+ { const int a{1}; static_assert(a == 1, ""); }
+ { const int a = {1}; static_assert(a == 1, ""); }
+ { const int a{1, 2}; } // expected-error {{excess elements}}
+ { const int a = {1, 2}; } // expected-error {{excess elements}}
+ // FIXME: Redundant warnings.
+ { const short a{100000}; } // expected-error {{cannot be narrowed}} expected-note {{inserting an explicit cast}} expected-warning {{changes value}}
+ { const short a = {100000}; } // expected-error {{cannot be narrowed}} expected-note {{inserting an explicit cast}} expected-warning {{changes value}}
+ { if (const int a{1}) static_assert(a == 1, ""); }
+ { if (const int a = {1}) static_assert(a == 1, ""); }
+ }
+
+ int direct_usage() {
+ int ar[10];
+ (void) ar[{1}]; // expected-error {{array subscript is not an integer}}
+
+ return {1};
+ }
+
+ void inline_init() {
+ auto v = int{1};
+ (void) new int{1};
+ }
+
+ struct A {
+ int i;
+ A() : i{1} {}
+ };
+
+ void function_call() {
+ void takes_int(int);
+ takes_int({1});
+ }
+
+ void overloaded_call() {
+ one overloaded(int);
+ two overloaded(double);
+
+ static_assert(sizeof(overloaded({0})) == sizeof(one), "bad overload");
+ static_assert(sizeof(overloaded({0.0})) == sizeof(two), "bad overload");
+
+ void ambiguous(int, double); // expected-note {{candidate}}
+ void ambiguous(double, int); // expected-note {{candidate}}
+ ambiguous({0}, {0}); // expected-error {{ambiguous}}
+
+ void emptylist(int);
+ void emptylist(int, int, int);
+ emptylist({});
+ emptylist({}, {}, {});
+ }
+
+ void edge_cases() {
+ // FIXME: very poor error message
+ int a({0}); // expected-error {{cannot initialize}}
+ (void) int({0}); // expected-error {{functional-style cast}}
+ new int({0}); // expected-error {{cannot initialize}}
+ }
+
+ void default_argument(int i = {}) {
+ }
+ struct DefaultArgument {
+ void default_argument(int i = {}) {
+ }
+ };
+}
+
+namespace PR12118 {
+ void test() {
+ one f(std::initializer_list<int>);
+ two f(int);
+
+ // to initializer_list is preferred
+ static_assert(sizeof(f({0})) == sizeof(one), "bad overload");
+ }
+}
diff --git a/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp b/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
new file mode 100644
index 0000000..7384309
--- /dev/null
+++ b/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -0,0 +1,177 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// This must obviously come before the definition of std::initializer_list.
+void missing_initializerlist() {
+ auto l = {1, 2, 3, 4}; // expected-error {{std::initializer_list was not found}}
+}
+
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b),
+ __size_(__s)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+}
+
+template <typename T, typename U>
+struct same_type { static const bool value = false; };
+template <typename T>
+struct same_type<T, T> { static const bool value = true; };
+
+struct one { char c[1]; };
+struct two { char c[2]; };
+
+struct A {
+ int a, b;
+};
+
+struct B {
+ B();
+ B(int, int);
+};
+
+void simple_list() {
+ std::initializer_list<int> il = { 1, 2, 3 };
+ std::initializer_list<double> dl = { 1.0, 2.0, 3 };
+ std::initializer_list<A> al = { {1, 2}, {2, 3}, {3, 4} };
+ std::initializer_list<B> bl = { {1, 2}, {2, 3}, {} };
+}
+
+void function_call() {
+ void f(std::initializer_list<int>);
+ f({1, 2, 3});
+
+ void g(std::initializer_list<B>);
+ g({ {1, 2}, {2, 3}, {} });
+}
+
+struct C {
+ C(int);
+};
+
+struct D {
+ D();
+ operator int();
+ operator C();
+};
+
+void overloaded_call() {
+ one overloaded(std::initializer_list<int>);
+ two overloaded(std::initializer_list<B>);
+
+ static_assert(sizeof(overloaded({1, 2, 3})) == sizeof(one), "bad overload");
+ static_assert(sizeof(overloaded({ {1, 2}, {2, 3}, {} })) == sizeof(two), "bad overload");
+
+ void ambiguous(std::initializer_list<A>); // expected-note {{candidate}}
+ void ambiguous(std::initializer_list<B>); // expected-note {{candidate}}
+ ambiguous({ {1, 2}, {2, 3}, {3, 4} }); // expected-error {{ambiguous}}
+
+ one ov2(std::initializer_list<int>); // expected-note {{candidate}}
+ two ov2(std::initializer_list<C>); // expected-note {{candidate}}
+ // Worst sequence to int is identity, whereas to C it's user-defined.
+ static_assert(sizeof(ov2({1, 2, 3})) == sizeof(one), "bad overload");
+ // But here, user-defined is worst in both cases.
+ ov2({1, 2, D()}); // expected-error {{ambiguous}}
+}
+
+template <typename T>
+T deduce(std::initializer_list<T>); // expected-note {{conflicting types for parameter 'T' ('int' vs. 'double')}}
+template <typename T>
+T deduce_ref(const std::initializer_list<T>&); // expected-note {{conflicting types for parameter 'T' ('int' vs. 'double')}}
+
+void argument_deduction() {
+ static_assert(same_type<decltype(deduce({1, 2, 3})), int>::value, "bad deduction");
+ static_assert(same_type<decltype(deduce({1.0, 2.0, 3.0})), double>::value, "bad deduction");
+
+ deduce({1, 2.0}); // expected-error {{no matching function}}
+
+ static_assert(same_type<decltype(deduce_ref({1, 2, 3})), int>::value, "bad deduction");
+ static_assert(same_type<decltype(deduce_ref({1.0, 2.0, 3.0})), double>::value, "bad deduction");
+
+ deduce_ref({1, 2.0}); // expected-error {{no matching function}}
+}
+
+void auto_deduction() {
+ auto l = {1, 2, 3, 4};
+ static_assert(same_type<decltype(l), std::initializer_list<int>>::value, "");
+ auto bl = {1, 2.0}; // expected-error {{cannot deduce}}
+
+ for (int i : {1, 2, 3, 4}) {}
+}
+
+void dangle() {
+ new auto{1, 2, 3}; // expected-error {{cannot use list-initialization}}
+ new std::initializer_list<int>{1, 2, 3}; // expected-warning {{at the end of the full-expression}}
+}
+
+struct haslist1 {
+ std::initializer_list<int> il = {1, 2, 3}; // expected-warning{{at the end of the constructor}}
+ std::initializer_list<int> jl{1, 2, 3}; // expected-warning{{at the end of the constructor}}
+ haslist1();
+};
+
+haslist1::haslist1()
+: il{1, 2, 3} // expected-warning{{at the end of the constructor}}
+{}
+
+namespace PR12119 {
+ // Deduction with nested initializer lists.
+ template<typename T> void f(std::initializer_list<T>);
+ template<typename T> void g(std::initializer_list<std::initializer_list<T>>);
+
+ void foo() {
+ f({0, {1}});
+ g({{0, 1}, {2, 3}});
+ std::initializer_list<int> il = {1, 2};
+ g({il, {2, 3}});
+ }
+}
+
+namespace Decay {
+ template<typename T>
+ void f(std::initializer_list<T>) {
+ T x = 1; // expected-error{{cannot initialize a variable of type 'const char *' with an rvalue of type 'int'}}
+ }
+
+ void g() {
+ f({"A", "BB", "CCC"}); // expected-note{{in instantiation of function template specialization 'Decay::f<const char *>' requested here}}
+
+ auto x = { "A", "BB", "CCC" };
+ std::initializer_list<const char *> *il = &x;
+
+ for( auto s : {"A", "BB", "CCC", "DDD"}) { }
+ }
+}
+
+namespace PR12436 {
+ struct X {
+ template<typename T>
+ X(std::initializer_list<int>, T);
+ };
+
+ X x({}, 17);
+}
diff --git a/clang/test/SemaCXX/cxx0x-nontrivial-union.cpp b/clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
new file mode 100644
index 0000000..0e4add8
--- /dev/null
+++ b/clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
@@ -0,0 +1,124 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct non_trivial {
+ non_trivial();
+ non_trivial(const non_trivial&);
+ non_trivial& operator = (const non_trivial&);
+ ~non_trivial();
+};
+
+union u {
+ non_trivial nt;
+};
+union u2 {
+ non_trivial nt;
+ int k;
+ u2(int k) : k(k) {}
+ u2() : nt() {}
+};
+
+union static_data_member {
+ static int i;
+};
+int static_data_member::i;
+
+union bad {
+ int &i; // expected-error {{union member 'i' has reference type 'int &'}}
+};
+
+struct s {
+ union {
+ non_trivial nt;
+ };
+};
+
+// Don't crash on this.
+struct TemplateCtor { template<typename T> TemplateCtor(T); };
+union TemplateCtorMember { TemplateCtor s; };
+
+template<typename T> struct remove_ref { typedef T type; };
+template<typename T> struct remove_ref<T&> { typedef T type; };
+template<typename T> struct remove_ref<T&&> { typedef T type; };
+template<typename T> T &&forward(typename remove_ref<T>::type &&t);
+template<typename T> T &&forward(typename remove_ref<T>::type &t);
+template<typename T> typename remove_ref<T>::type &&move(T &&t);
+
+using size_t = decltype(sizeof(int));
+void *operator new(size_t, void *p) noexcept { return p; }
+
+namespace disabled_dtor {
+ template<typename T>
+ union disable_dtor {
+ T val;
+ template<typename...U>
+ disable_dtor(U &&...u) : val(forward<U>(u)...) {}
+ ~disable_dtor() {}
+ };
+
+ struct deleted_dtor {
+ deleted_dtor(int n, char c) : n(n), c(c) {}
+ int n;
+ char c;
+ ~deleted_dtor() = delete;
+ };
+
+ disable_dtor<deleted_dtor> dd(4, 'x');
+}
+
+namespace optional {
+ template<typename T> struct optional {
+ bool has;
+ union { T value; };
+
+ optional() : has(false) {}
+ template<typename...U>
+ optional(U &&...u) : has(true), value(forward<U>(u)...) {}
+
+ optional(const optional &o) : has(o.has) {
+ if (has) new (&value) T(o.value);
+ }
+ optional(optional &&o) : has(o.has) {
+ if (has) new (&value) T(move(o.value));
+ }
+
+ optional &operator=(const optional &o) {
+ if (has) {
+ if (o.has)
+ value = o.value;
+ else
+ value.~T();
+ } else if (o.has) {
+ new (&value) T(o.value);
+ }
+ has = o.has;
+ }
+ optional &operator=(optional &&o) {
+ if (has) {
+ if (o.has)
+ value = move(o.value);
+ else
+ value.~T();
+ } else if (o.has) {
+ new (&value) T(move(o.value));
+ }
+ has = o.has;
+ }
+
+ ~optional() {
+ if (has)
+ value.~T();
+ }
+
+ explicit operator bool() const { return has; }
+ T &operator*() const { return value; }
+ };
+
+ optional<non_trivial> o1;
+ optional<non_trivial> o2{non_trivial()};
+ optional<non_trivial> o3{*o2};
+ void f() {
+ if (o2)
+ o1 = o2;
+ o2 = optional<non_trivial>();
+ }
+}
diff --git a/clang/test/SemaCXX/cxx0x-return-init-list.cpp b/clang/test/SemaCXX/cxx0x-return-init-list.cpp
new file mode 100644
index 0000000..da83271
--- /dev/null
+++ b/clang/test/SemaCXX/cxx0x-return-init-list.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Test that a very basic variation of generalized initializer returns (that
+// required for libstdc++ 4.5) is supported in C++98.
+
+int test0(int i) {
+ return { i }; // expected-warning{{generalized initializer lists are a C++11 extension}}
+}
+
+template<typename T, typename U>
+T test1(U u) {
+ return { u }; // expected-warning{{generalized initializer lists are a C++11 extension}}
+}
+
+template int test1(char);
+template long test1(int);
diff --git a/clang/test/SemaCXX/cxx0x-type-convert-construct.cpp b/clang/test/SemaCXX/cxx0x-type-convert-construct.cpp
new file mode 100644
index 0000000..6a7fe45
--- /dev/null
+++ b/clang/test/SemaCXX/cxx0x-type-convert-construct.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=gnu++11 -fsyntax-only -verify %s
+
+void f() {
+ char *u8str;
+ u8str = u8"a UTF-8 string"; // expected-error {{assigning to 'char *' from incompatible type 'const char [15]'}}
+ char16_t *ustr;
+ ustr = u"a UTF-16 string"; // expected-error {{assigning to 'char16_t *' from incompatible type 'const char16_t [16]'}}
+ char32_t *Ustr;
+ Ustr = U"a UTF-32 string"; // expected-error {{assigning to 'char32_t *' from incompatible type 'const char32_t [16]'}}
+
+ char *Rstr;
+ Rstr = R"foo(a raw string)foo"; // expected-warning{{conversion from string literal to 'char *' is deprecated}}
+ wchar_t *LRstr;
+ LRstr = LR"foo(a wide raw string)foo"; // expected-warning{{conversion from string literal to 'wchar_t *' is deprecated}}
+ char *u8Rstr;
+ u8Rstr = u8R"foo(a UTF-8 raw string)foo"; // expected-error {{assigning to 'char *' from incompatible type 'const char [19]'}}
+ char16_t *uRstr;
+ uRstr = uR"foo(a UTF-16 raw string)foo"; // expected-error {{assigning to 'char16_t *' from incompatible type 'const char16_t [20]'}}
+ char32_t *URstr;
+ URstr = UR"foo(a UTF-32 raw string)foo"; // expected-error {{assigning to 'char32_t *' from incompatible type 'const char32_t [20]'}}
+}
diff --git a/clang/test/SemaCXX/cxx11-ast-print.cpp b/clang/test/SemaCXX/cxx11-ast-print.cpp
new file mode 100644
index 0000000..afabf88
--- /dev/null
+++ b/clang/test/SemaCXX/cxx11-ast-print.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++11 -ast-print %s | FileCheck %s
+
+// FIXME: Print the trailing-return-type properly.
+// CHECK: decltype(nullptr) operator "" _foo(const char *p, decltype(sizeof(int)));
+auto operator"" _foo(const char *p, decltype(sizeof(int))) -> decltype(nullptr);
+
+// CHECK: decltype(""_foo) operator "" _bar(unsigned long long);
+decltype(""_foo) operator"" _bar(unsigned long long);
+
+// CHECK: decltype(42_bar) operator "" _baz(long double);
+decltype(42_bar) operator"" _baz(long double);
+
+// CHECK: decltype(4.5_baz) operator "" _baz(char);
+decltype(4.5_baz) operator"" _baz(char);
+
+// CHECK: const char *operator "" _quux(const char *);
+const char *operator"" _quux(const char *);
+
+// CHECK: template <char...> const char *operator "" _fritz();
+template<char...> const char *operator"" _fritz();
+
+// CHECK: const char *p1 = "bar1"_foo;
+const char *p1 = "bar1"_foo;
+// CHECK: const char *p2 = "bar2"_foo;
+const char *p2 = R"x(bar2)x"_foo;
+// CHECK: const char *p3 = u8"bar3"_foo;
+const char *p3 = u8"bar3"_foo;
+// CHECK: const char *p4 = 297_bar;
+const char *p4 = 0x129_bar;
+// CHECK: const char *p5 = 1.0E+12_baz;
+const char *p5 = 1e12_baz;
+// CHECK: const char *p6 = 'x'_baz;
+const char *p6 = 'x'_baz;
+// CHECK: const char *p7 = 123_quux;
+const char *p7 = 123_quux;
+// CHECK: const char *p8 = 4.9_quux;
+const char *p8 = 4.9_quux;
+// CHECK: const char *p9 = 0x42e3F_fritz;
+const char *p9 = 0x42e3F_fritz;
+// CHECK: const char *p10 = 3.300e+15_fritz;
+const char *p10 = 3.300e+15_fritz;
diff --git a/clang/test/SemaCXX/cxx11-user-defined-literals.cpp b/clang/test/SemaCXX/cxx11-user-defined-literals.cpp
new file mode 100644
index 0000000..4bbecdb
--- /dev/null
+++ b/clang/test/SemaCXX/cxx11-user-defined-literals.cpp
@@ -0,0 +1,137 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -fms-extensions -triple x86_64-apple-darwin9.0.0
+
+using size_t = decltype(sizeof(int));
+enum class LitKind {
+ Char, WideChar, Char16, Char32,
+ CharStr, WideStr, Char16Str, Char32Str,
+ Integer, Floating, Raw, Template
+};
+constexpr LitKind operator"" _kind(char p) { return LitKind::Char; }
+constexpr LitKind operator"" _kind(wchar_t p) { return LitKind::WideChar; }
+constexpr LitKind operator"" _kind(char16_t p) { return LitKind::Char16; }
+constexpr LitKind operator"" _kind(char32_t p) { return LitKind::Char32; }
+constexpr LitKind operator"" _kind(const char *p, size_t n) { return LitKind::CharStr; }
+constexpr LitKind operator"" _kind(const wchar_t *p, size_t n) { return LitKind::WideStr; }
+constexpr LitKind operator"" _kind(const char16_t *p, size_t n) { return LitKind::Char16Str; }
+constexpr LitKind operator"" _kind(const char32_t *p, size_t n) { return LitKind::Char32Str; }
+constexpr LitKind operator"" _kind(unsigned long long n) { return LitKind::Integer; }
+constexpr LitKind operator"" _kind(long double n) { return LitKind::Floating; }
+constexpr LitKind operator"" _kind2(const char *p) { return LitKind::Raw; }
+template<char ...Cs> constexpr LitKind operator"" _kind3() { return LitKind::Template; }
+
+static_assert('x'_kind == LitKind::Char, "");
+static_assert(L'x'_kind == LitKind::WideChar, "");
+static_assert(u'x'_kind == LitKind::Char16, "");
+static_assert(U'x'_kind == LitKind::Char32, "");
+static_assert("foo"_kind == LitKind::CharStr, "");
+static_assert(u8"foo"_kind == LitKind::CharStr, "");
+static_assert(L"foo"_kind == LitKind::WideStr, "");
+static_assert(u"foo"_kind == LitKind::Char16Str, "");
+static_assert(U"foo"_kind == LitKind::Char32Str, "");
+static_assert(194_kind == LitKind::Integer, "");
+static_assert(0377_kind == LitKind::Integer, "");
+static_assert(0x5ffc_kind == LitKind::Integer, "");
+static_assert(.5954_kind == LitKind::Floating, "");
+static_assert(1._kind == LitKind::Floating, "");
+static_assert(1.e-2_kind == LitKind::Floating, "");
+static_assert(4e6_kind == LitKind::Floating, "");
+static_assert(4e6_kind2 == LitKind::Raw, "");
+static_assert(4e6_kind3 == LitKind::Template, "");
+
+constexpr const char *fractional_digits_impl(const char *p) {
+ return *p == '.' ? p + 1 : *p ? fractional_digits_impl(p + 1) : 0;
+}
+constexpr const char *operator"" _fractional_digits(const char *p) {
+ return fractional_digits_impl(p) ?: p;
+}
+constexpr bool streq(const char *p, const char *q) {
+ return *p == *q && (!*p || streq(p+1, q+1));
+}
+
+static_assert(streq(143.97_fractional_digits, "97"), "");
+static_assert(streq(0x786_fractional_digits, "0x786"), "");
+static_assert(streq(.4_fractional_digits, "4"), "");
+static_assert(streq(4._fractional_digits, ""), "");
+static_assert(streq(1e+97_fractional_digits, "1e+97"), "");
+static_assert(streq(0377_fractional_digits, "0377"), "");
+static_assert(streq(0377.5_fractional_digits, "5"), "");
+
+int operator"" _ambiguous(char); // expected-note {{candidate}}
+namespace N {
+ void *operator"" _ambiguous(char); // expected-note {{candidate}}
+}
+using namespace N;
+int k = 'x'_ambiguous; // expected-error {{ambiguous}}
+
+int operator"" _deleted(unsigned long long) = delete; // expected-note {{here}}
+int m = 42_deleted; // expected-error {{attempt to use a deleted}}
+
+namespace Using {
+ namespace M {
+ int operator"" _using(char);
+ }
+ int k1 = 'x'_using; // expected-error {{no matching literal operator for call to 'operator "" _using'}}
+
+ using M::operator "" _using;
+ int k2 = 'x'_using;
+}
+
+namespace AmbiguousRawTemplate {
+ int operator"" _ambig1(const char *); // expected-note {{candidate}}
+ template<char...> int operator"" _ambig1(); // expected-note {{candidate}}
+
+ int k1 = 123_ambig1; // expected-error {{call to 'operator "" _ambig1' is ambiguous}}
+
+ namespace Inner {
+ template<char...> int operator"" _ambig2(); // expected-note 3{{candidate}}
+ }
+ int operator"" _ambig2(const char *); // expected-note 3{{candidate}}
+ using Inner::operator"" _ambig2;
+
+ int k2 = 123_ambig2; // expected-error {{call to 'operator "" _ambig2' is ambiguous}}
+
+ namespace N {
+ using Inner::operator"" _ambig2;
+
+ int k3 = 123_ambig2; // ok
+
+ using AmbiguousRawTemplate::operator"" _ambig2;
+
+ int k4 = 123_ambig2; // expected-error {{ambiguous}}
+
+ namespace M {
+
+ template<char...> int operator"" _ambig2();
+
+ int k5 = 123_ambig2; // ok
+ }
+
+ int operator"" _ambig2(unsigned long long);
+
+ int k6 = 123_ambig2; // ok
+ int k7 = 123._ambig2; // expected-error {{ambiguous}}
+ }
+}
+
+constexpr unsigned mash(unsigned a) {
+ return 0x93ae27b5 * ((a >> 13) | a << 19);
+}
+template<typename=void> constexpr unsigned hash(unsigned a) { return a; }
+template<char C, char...Cs> constexpr unsigned hash(unsigned a) {
+ return hash<Cs...>(mash(a ^ mash(C)));
+}
+template<typename T, T v> struct constant { constexpr static T value = v; };
+template<char...Cs> constexpr unsigned operator"" _hash() {
+ return constant<unsigned, hash<Cs...>(0)>::value;
+}
+static_assert(0x1234_hash == 0x103eff5e, "");
+static_assert(hash<'0', 'x', '1', '2', '3', '4'>(0) == 0x103eff5e, "");
+
+// Functions and literal suffixes go in separate namespaces.
+namespace Namespace {
+ template<char...> int operator"" _x();
+ int k = _x(); // expected-error {{undeclared identifier '_x'}}
+
+ int _y(unsigned long long);
+ int k2 = 123_y; // expected-error {{no matching literal operator for call to 'operator "" _y'}}
+}
diff --git a/clang/test/SemaCXX/cxx98-compat-flags.cpp b/clang/test/SemaCXX/cxx98-compat-flags.cpp
new file mode 100644
index 0000000..6dc24be
--- /dev/null
+++ b/clang/test/SemaCXX/cxx98-compat-flags.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Wno-bind-to-temporary-copy -Wno-unnamed-type-template-args -Wno-local-type-template-args -Werror %s
+
+template<typename T> int TemplateFn(T) { return 0; }
+void LocalTemplateArg() {
+ struct S {};
+ TemplateFn(S()); // expected-warning {{local type 'S' as template argument is incompatible with C++98}}
+}
+struct {} obj_of_unnamed_type; // expected-note {{here}}
+int UnnamedTemplateArg = TemplateFn(obj_of_unnamed_type); // expected-warning {{unnamed type as template argument is incompatible with C++98}}
+
+namespace CopyCtorIssues {
+ struct Private {
+ Private();
+ private:
+ Private(const Private&); // expected-note {{declared private here}}
+ };
+ struct NoViable {
+ NoViable();
+ NoViable(NoViable&); // expected-note {{not viable}}
+ };
+ struct Ambiguous {
+ Ambiguous();
+ Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}}
+ Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}}
+ };
+ struct Deleted {
+ Private p; // expected-note {{copy constructor of 'Deleted' is implicitly deleted because field 'p' has an inaccessible copy constructor}}
+ };
+
+ const Private &a = Private(); // expected-warning {{copying variable of type 'CopyCtorIssues::Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
+ const NoViable &b = NoViable(); // expected-warning {{copying variable of type 'CopyCtorIssues::NoViable' when binding a reference to a temporary would find no viable constructor in C++98}}
+ const Ambiguous &c = Ambiguous(); // expected-warning {{copying variable of type 'CopyCtorIssues::Ambiguous' when binding a reference to a temporary would find ambiguous constructors in C++98}}
+ const Deleted &d = Deleted(); // expected-warning {{copying variable of type 'CopyCtorIssues::Deleted' when binding a reference to a temporary would invoke a deleted constructor in C++98}}
+}
diff --git a/clang/test/SemaCXX/cxx98-compat-pedantic.cpp b/clang/test/SemaCXX/cxx98-compat-pedantic.cpp
new file mode 100644
index 0000000..00532d5
--- /dev/null
+++ b/clang/test/SemaCXX/cxx98-compat-pedantic.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Werror %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror %s
+
+// -Wc++98-compat-pedantic warns on C++11 features which we accept without a
+// warning in C++98 mode.
+
+#line 32767 // ok
+#line 32768 // expected-warning {{#line number greater than 32767 is incompatible with C++98}}
+
+#define VA_MACRO(x, ...) x // expected-warning {{variadic macros are incompatible with C++98}}
+VA_MACRO(,x) // expected-warning {{empty macro argument list is incompatible with C++98}}
+
+; // expected-warning {{extra ';' outside of a function is incompatible with C++98}}
+
+enum Enum {
+ Enum_value, // expected-warning {{commas at the end of enumerator lists are incompatible with C++98}}
+};
+
+template<typename T> struct InstantiationAfterSpecialization {};
+template<> struct InstantiationAfterSpecialization<int> {}; // expected-note {{here}}
+template struct InstantiationAfterSpecialization<int>; // expected-warning {{explicit instantiation of 'InstantiationAfterSpecialization<int>' that occurs after an explicit specialization is incompatible with C++98}}
+
+void *dlsym();
+void (*FnPtr)() = (void(*)())dlsym(); // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
+void *FnVoidPtr = (void*)&dlsym; // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
+
+struct ConvertToInt {
+ operator int();
+};
+int *ArraySizeConversion = new int[ConvertToInt()]; // expected-warning {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'int' is incompatible with C++98}}
+
+template<typename T> class ExternTemplate {};
+extern template class ExternTemplate<int>; // expected-warning {{extern templates are incompatible with C++98}}
diff --git a/clang/test/SemaCXX/cxx98-compat.cpp b/clang/test/SemaCXX/cxx98-compat.cpp
new file mode 100644
index 0000000..82a9dc8
--- /dev/null
+++ b/clang/test/SemaCXX/cxx98-compat.cpp
@@ -0,0 +1,305 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s
+
+namespace std { struct type_info; }
+
+template<typename ...T> // expected-warning {{variadic templates are incompatible with C++98}}
+class Variadic1 {};
+
+template<template<typename> class ...T> // expected-warning {{variadic templates are incompatible with C++98}}
+class Variadic2 {};
+
+template<int ...I> // expected-warning {{variadic templates are incompatible with C++98}}
+class Variadic3 {};
+
+int alignas(8) with_alignas; // expected-warning {{'alignas' is incompatible with C++98}}
+int with_attribute [[ ]]; // expected-warning {{attributes are incompatible with C++98}}
+
+void Literals() {
+ (void)u8"str"; // expected-warning {{unicode literals are incompatible with C++98}}
+ (void)u"str"; // expected-warning {{unicode literals are incompatible with C++98}}
+ (void)U"str"; // expected-warning {{unicode literals are incompatible with C++98}}
+ (void)u'x'; // expected-warning {{unicode literals are incompatible with C++98}}
+ (void)U'x'; // expected-warning {{unicode literals are incompatible with C++98}}
+
+ (void)u8R"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
+ (void)uR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
+ (void)UR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
+ (void)R"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
+ (void)LR"X(str)X"; // expected-warning {{raw string literals are incompatible with C++98}}
+}
+
+template<typename T> struct S {};
+namespace TemplateParsing {
+ S<::S<void> > s; // expected-warning {{'<::' is treated as digraph '<:' (aka '[') followed by ':' in C++98}}
+ S< ::S<void>> t; // expected-warning {{consecutive right angle brackets are incompatible with C++98 (use '> >')}}
+}
+
+void Lambda() {
+ []{}(); // expected-warning {{lambda expressions are incompatible with C++98}}
+}
+
+int InitList(int i = {}) { // expected-warning {{generalized initializer lists are incompatible with C++98}} \
+ // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
+ (void)new int {}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \
+ // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
+ (void)int{}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \
+ // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
+ int x { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}}
+ S<int> s = {}; // ok, aggregate
+ s = {}; // expected-warning {{generalized initializer lists are incompatible with C++98}}
+ return { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}}
+}
+struct DelayedDefaultArgumentParseInitList {
+ void f(int i = {1}) { // expected-warning {{generalized initializer lists are incompatible with C++98}}
+ }
+};
+
+int operator"" _hello(const char *); // expected-warning {{literal operators are incompatible with C++98}}
+
+enum EnumFixed : int { // expected-warning {{enumeration types with a fixed underlying type are incompatible with C++98}}
+};
+
+enum class EnumScoped { // expected-warning {{scoped enumerations are incompatible with C++98}}
+};
+
+void Deleted() = delete; // expected-warning {{deleted function definitions are incompatible with C++98}}
+struct Defaulted {
+ Defaulted() = default; // expected-warning {{defaulted function definitions are incompatible with C++98}}
+};
+
+int &&RvalueReference = 0; // expected-warning {{rvalue references are incompatible with C++98}}
+struct RefQualifier {
+ void f() &; // expected-warning {{reference qualifiers on functions are incompatible with C++98}}
+};
+
+auto f() -> int; // expected-warning {{trailing return types are incompatible with C++98}}
+
+void RangeFor() {
+ int xs[] = {1, 2, 3};
+ for (int &a : xs) { // expected-warning {{range-based for loop is incompatible with C++98}}
+ }
+}
+
+struct InClassInit {
+ int n = 0; // expected-warning {{in-class initialization of non-static data members is incompatible with C++98}}
+};
+
+struct OverrideControlBase {
+ virtual void f();
+ virtual void g();
+};
+struct OverrideControl final : OverrideControlBase { // expected-warning {{'final' keyword is incompatible with C++98}}
+ virtual void f() override; // expected-warning {{'override' keyword is incompatible with C++98}}
+ virtual void g() final; // expected-warning {{'final' keyword is incompatible with C++98}}
+};
+
+using AliasDecl = int; // expected-warning {{alias declarations are incompatible with C++98}}
+template<typename T> using AliasTemplate = T; // expected-warning {{alias declarations are incompatible with C++98}}
+
+inline namespace InlineNS { // expected-warning {{inline namespaces are incompatible with C++98}}
+}
+
+auto auto_deduction = 0; // expected-warning {{'auto' type specifier is incompatible with C++98}}
+int *p = new auto(0); // expected-warning {{'auto' type specifier is incompatible with C++98}}
+
+const int align_of = alignof(int); // expected-warning {{alignof expressions are incompatible with C++98}}
+char16_t c16 = 0; // expected-warning {{'char16_t' type specifier is incompatible with C++98}}
+char32_t c32 = 0; // expected-warning {{'char32_t' type specifier is incompatible with C++98}}
+constexpr int const_expr = 0; // expected-warning {{'constexpr' specifier is incompatible with C++98}}
+decltype(const_expr) decl_type = 0; // expected-warning {{'decltype' type specifier is incompatible with C++98}}
+__decltype(const_expr) decl_type2 = 0; // ok
+void no_except() noexcept; // expected-warning {{noexcept specifications are incompatible with C++98}}
+bool no_except_expr = noexcept(1 + 1); // expected-warning {{noexcept expressions are incompatible with C++98}}
+void *null = nullptr; // expected-warning {{'nullptr' is incompatible with C++98}}
+static_assert(true, "!"); // expected-warning {{static_assert declarations are incompatible with C++98}}
+
+// FIXME: Reintroduce this test if support for inheriting constructors is
+// implemented.
+#if 0
+struct InhCtorBase {
+ InhCtorBase(int);
+};
+struct InhCtorDerived : InhCtorBase {
+ using InhCtorBase::InhCtorBase; // xpected-warning {{inheriting constructors are incompatible with C++98}}
+};
+#endif
+
+struct FriendMember {
+ static void MemberFn();
+ friend void FriendMember::MemberFn(); // expected-warning {{friend declaration naming a member of the declaring class is incompatible with C++98}}
+};
+
+struct DelegCtor {
+ DelegCtor(int) : DelegCtor() {} // expected-warning {{delegating constructors are incompatible with C++98}}
+ DelegCtor();
+};
+
+template<int n = 0> void DefaultFuncTemplateArg(); // expected-warning {{default template arguments for a function template are incompatible with C++98}}
+
+template<typename T> int TemplateFn(T) { return 0; }
+void LocalTemplateArg() {
+ struct S {};
+ TemplateFn(S()); // expected-warning {{local type 'S' as template argument is incompatible with C++98}}
+}
+struct {} obj_of_unnamed_type; // expected-note {{here}}
+int UnnamedTemplateArg = TemplateFn(obj_of_unnamed_type); // expected-warning {{unnamed type as template argument is incompatible with C++98}}
+
+namespace RedundantParensInAddressTemplateParam {
+ int n;
+ template<int*p> struct S {};
+ S<(&n)> s; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}}
+ S<(((&n)))> t; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}}
+}
+
+namespace TemplateSpecOutOfScopeNs {
+ template<typename T> struct S {}; // expected-note {{here}}
+}
+template<> struct TemplateSpecOutOfScopeNs::S<char> {}; // expected-warning {{class template specialization of 'S' outside namespace 'TemplateSpecOutOfScopeNs' is incompatible with C++98}}
+
+struct Typename {
+ template<typename T> struct Inner {};
+};
+typename ::Typename TypenameOutsideTemplate(); // expected-warning {{use of 'typename' outside of a template is incompatible with C++98}}
+Typename::template Inner<int> TemplateOutsideTemplate(); // expected-warning {{use of 'template' keyword outside of a template is incompatible with C++98}}
+
+struct TrivialButNonPOD {
+ int f(int);
+private:
+ int k;
+};
+void Ellipsis(int n, ...);
+void TrivialButNonPODThroughEllipsis() {
+ Ellipsis(1, TrivialButNonPOD()); // expected-warning {{passing object of trivial but non-POD type 'TrivialButNonPOD' through variadic function is incompatible with C++98}}
+}
+
+struct HasExplicitConversion {
+ explicit operator bool(); // expected-warning {{explicit conversion functions are incompatible with C++98}}
+};
+
+struct Struct {};
+enum Enum { enum_val = 0 };
+struct BadFriends {
+ friend enum ::Enum; // expected-warning {{befriending enumeration type 'enum ::Enum' is incompatible with C++98}}
+ friend int; // expected-warning {{non-class friend type 'int' is incompatible with C++98}}
+ friend Struct; // expected-warning {{befriending 'Struct' without 'struct' keyword is incompatible with C++98}}
+};
+
+int n = {}; // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
+
+class PrivateMember {
+ struct ImPrivate {};
+};
+template<typename T> typename T::ImPrivate SFINAEAccessControl(T t) { // expected-warning {{substitution failure due to access control is incompatible with C++98}} expected-note {{while substituting deduced template arguments into function template 'SFINAEAccessControl' [with T = PrivateMember]}}
+ return typename T::ImPrivate();
+}
+int SFINAEAccessControl(...) { return 0; }
+int CheckSFINAEAccessControl = SFINAEAccessControl(PrivateMember());
+
+template<typename T>
+struct FriendRedefinition {
+ friend void Friend() {} // expected-warning {{friend function 'Friend' would be implicitly redefined in C++98}} expected-note {{previous}}
+};
+FriendRedefinition<int> FriendRedef1;
+FriendRedefinition<char> FriendRedef2; // expected-note {{requested here}}
+
+namespace CopyCtorIssues {
+ struct Private {
+ Private();
+ private:
+ Private(const Private&); // expected-note {{declared private here}}
+ };
+ struct NoViable {
+ NoViable();
+ NoViable(NoViable&); // expected-note {{not viable}}
+ };
+ struct Ambiguous {
+ Ambiguous();
+ Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}}
+ Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}}
+ };
+ struct Deleted {
+ Private p; // expected-note {{implicitly deleted}}
+ };
+
+ const Private &a = Private(); // expected-warning {{copying variable of type 'CopyCtorIssues::Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
+ const NoViable &b = NoViable(); // expected-warning {{copying variable of type 'CopyCtorIssues::NoViable' when binding a reference to a temporary would find no viable constructor in C++98}}
+ const Ambiguous &c = Ambiguous(); // expected-warning {{copying variable of type 'CopyCtorIssues::Ambiguous' when binding a reference to a temporary would find ambiguous constructors in C++98}}
+ const Deleted &d = Deleted(); // expected-warning {{copying variable of type 'CopyCtorIssues::Deleted' when binding a reference to a temporary would invoke a deleted constructor in C++98}}
+}
+
+namespace UnionOrAnonStructMembers {
+ struct NonTrivCtor {
+ NonTrivCtor(); // expected-note 2{{user-declared constructor}}
+ };
+ struct NonTrivCopy {
+ NonTrivCopy(const NonTrivCopy&); // expected-note 2{{user-declared copy constructor}}
+ };
+ struct NonTrivDtor {
+ ~NonTrivDtor(); // expected-note 2{{user-declared destructor}}
+ };
+ union BadUnion {
+ NonTrivCtor ntc; // expected-warning {{union member 'ntc' with a non-trivial constructor is incompatible with C++98}}
+ NonTrivCopy ntcp; // expected-warning {{union member 'ntcp' with a non-trivial copy constructor is incompatible with C++98}}
+ NonTrivDtor ntd; // expected-warning {{union member 'ntd' with a non-trivial destructor is incompatible with C++98}}
+ };
+ struct Wrap {
+ struct {
+ NonTrivCtor ntc; // expected-warning {{anonymous struct member 'ntc' with a non-trivial constructor is incompatible with C++98}}
+ NonTrivCopy ntcp; // expected-warning {{anonymous struct member 'ntcp' with a non-trivial copy constructor is incompatible with C++98}}
+ NonTrivDtor ntd; // expected-warning {{anonymous struct member 'ntd' with a non-trivial destructor is incompatible with C++98}}
+ };
+ };
+ union WithStaticDataMember {
+ static constexpr double d = 0.0; // expected-warning {{static data member 'd' in union is incompatible with C++98}} expected-warning {{'constexpr' specifier is incompatible with C++98}}
+ static const int n = 0; // expected-warning {{static data member 'n' in union is incompatible with C++98}}
+ static int k; // expected-warning {{static data member 'k' in union is incompatible with C++98}}
+ };
+}
+
+int EnumNNS = Enum::enum_val; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}}
+template<typename T> void EnumNNSFn() {
+ int k = T::enum_val; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}}
+};
+template void EnumNNSFn<Enum>(); // expected-note {{in instantiation}}
+
+void JumpDiagnostics(int n) {
+ goto DirectJump; // expected-warning {{goto would jump into protected scope in C++98}}
+ TrivialButNonPOD tnp1; // expected-note {{jump bypasses initialization of non-POD variable}}
+
+DirectJump:
+ void *Table[] = {&&DirectJump, &&Later};
+ goto *Table[n]; // expected-warning {{indirect goto might cross protected scopes in C++98}}
+
+ TrivialButNonPOD tnp2; // expected-note {{jump bypasses initialization of non-POD variable}}
+Later: // expected-note {{possible target of indirect goto}}
+ switch (n) {
+ TrivialButNonPOD tnp3; // expected-note {{jump bypasses initialization of non-POD variable}}
+ default: // expected-warning {{switch case would be in a protected scope in C++98}}
+ return;
+ }
+}
+
+namespace UnevaluatedMemberAccess {
+ struct S {
+ int n;
+ int f() { return sizeof(S::n); } // ok
+ };
+ int k = sizeof(S::n); // expected-warning {{use of non-static data member 'n' in an unevaluated context is incompatible with C++98}}
+ const std::type_info &ti = typeid(S::n); // expected-warning {{use of non-static data member 'n' in an unevaluated context is incompatible with C++98}}
+}
+
+namespace LiteralUCNs {
+ char c1 = '\u001e'; // expected-warning {{universal character name referring to a control character is incompatible with C++98}}
+ wchar_t c2 = L'\u0041'; // expected-warning {{specifying character 'A' with a universal character name is incompatible with C++98}}
+ const char *s1 = "foo\u0031"; // expected-warning {{specifying character '1' with a universal character name is incompatible with C++98}}
+ const wchar_t *s2 = L"bar\u0085"; // expected-warning {{universal character name referring to a control character is incompatible with C++98}}
+}
+
+namespace NonTypeTemplateArgs {
+ template<typename T, T v> struct S {};
+ const int k = 5; // expected-note {{here}}
+ static void f() {} // expected-note {{here}}
+ S<const int&, k> s1; // expected-warning {{non-type template argument referring to object 'k' with internal linkage is incompatible with C++98}}
+ S<void(&)(), f> s2; // expected-warning {{non-type template argument referring to function 'f' with internal linkage is incompatible with C++98}}
+}
diff --git a/clang/test/SemaCXX/dcl_ambig_res.cpp b/clang/test/SemaCXX/dcl_ambig_res.cpp
new file mode 100644
index 0000000..fa71b11
--- /dev/null
+++ b/clang/test/SemaCXX/dcl_ambig_res.cpp
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+
+// [dcl.ambig.res]p1:
+struct S {
+ S(int);
+ void bar();
+};
+
+int returns_an_int();
+
+void foo(double a)
+{
+ S w(int(a)); // expected-warning{{disambiguated}}
+ w(17);
+ S x1(int()); // expected-warning{{disambiguated}}
+ x1(&returns_an_int);
+ S y((int)a);
+ y.bar();
+ S z = int(a);
+ z.bar();
+}
+
+// [dcl.ambig.res]p3:
+char *p;
+void *operator new(__SIZE_TYPE__, int);
+void foo3() {
+ const int x = 63;
+ new (int(*p)) int; //new-placement expression
+ new (int(*[x])); //new type-id
+}
+
+// [dcl.ambig.res]p4:
+template <class T> // expected-note{{here}}
+struct S4 {
+ T *p;
+};
+S4<int()> x; //type-id
+S4<int(1)> y; // expected-error{{must be a type}}
+
+// [dcl.ambig.res]p5:
+void foo5()
+{
+ (void)sizeof(int(1)); //expression
+ // FIXME: should we make this an error rather than a warning?
+ // (It affects SFINAE)
+ (void)sizeof(int()); // expected-warning{{function type}}
+}
+
+// [dcl.ambig.res]p6:
+void foo6()
+{
+ (void)(int(1)); //expression
+ (void)(int())1; // expected-error{{to 'int ()'}}
+}
+
+// [dcl.ambig.res]p7:
+class C7 { };
+void f7(int(C7)) { } // expected-note{{candidate}}
+int g7(C7);
+void foo7() {
+ f7(1); // expected-error{{no matching function}}
+ f7(g7); //OK
+}
+
+void h7(int *(C7[10])) { } // expected-note{{previous}}
+void h7(int *(*_fp)(C7 _parm[10])) { } // expected-error{{redefinition}}
+
+struct S5 {
+ static bool const value = false;
+};
+int foo8() {
+ int v(int(S5::value)); // expected-warning{{disambiguated}} expected-error{{parameter declarator cannot be qualified}}
+}
+
+template<typename T>
+void rdar8739801( void (T::*)( void ) __attribute__((unused)) );
diff --git a/clang/test/SemaCXX/dcl_init_aggr.cpp b/clang/test/SemaCXX/dcl_init_aggr.cpp
new file mode 100644
index 0000000..bd3de9e
--- /dev/null
+++ b/clang/test/SemaCXX/dcl_init_aggr.cpp
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+// C++ [dcl.init.aggr]p2
+struct A {
+ int x;
+ struct B {
+ int i;
+ int j;
+ } b;
+} a1 = { 1, { 2, 3 } };
+
+struct NonAggregate {
+ NonAggregate();
+
+ int a, b;
+};
+NonAggregate non_aggregate_test = { 1, 2 }; // expected-error{{non-aggregate type 'NonAggregate' cannot be initialized with an initializer list}}
+
+NonAggregate non_aggregate_test2[2] = { { 1, 2 }, { 3, 4 } }; // expected-error 2 {{initialization of non-aggregate type 'NonAggregate' with an initializer list}}
+
+
+// C++ [dcl.init.aggr]p3
+A a_init = A();
+
+// C++ [dcl.init.aggr]p4
+int x[] = { 1, 3, 5 };
+int x_sizecheck[(sizeof(x) / sizeof(int)) == 3? 1 : -1];
+int x2[] = { }; // expected-warning{{zero size arrays are an extension}}
+
+// C++ [dcl.init.aggr]p5
+struct StaticMemberTest {
+ int i;
+ static int s;
+ int *j;
+} smt = { 1, &smt.i };
+
+// C++ [dcl.init.aggr]p6
+char cv[4] = { 'a', 's', 'd', 'f', 0 }; // expected-error{{excess elements in array initializer}}
+
+// C++ [dcl.init.aggr]p7
+struct TooFew { int a; char* b; int c; };
+TooFew too_few = { 1, "asdf" }; // expected-warning{{conversion from string literal to 'char *' is deprecated}}
+
+struct NoDefaultConstructor { // expected-note 3 {{candidate constructor (the implicit copy constructor)}} \
+ // expected-note{{declared here}}
+ NoDefaultConstructor(int); // expected-note 3 {{candidate constructor}}
+};
+struct TooFewError { // expected-error{{implicit default constructor for}}
+ int a;
+ NoDefaultConstructor nodef; // expected-note{{member is declared here}}
+};
+TooFewError too_few_okay = { 1, 1 };
+TooFewError too_few_error = { 1 }; // expected-error{{no matching constructor}}
+
+TooFewError too_few_okay2[2] = { 1, 1 }; // expected-note{{implicit default constructor for 'TooFewError' first required here}}
+TooFewError too_few_error2[2] = { 1 }; // expected-error{{no matching constructor}}
+
+NoDefaultConstructor too_few_error3[3] = { }; // expected-error {{no matching constructor}}
+
+// C++ [dcl.init.aggr]p8
+struct Empty { };
+struct EmptyTest {
+ Empty s;
+ int i;
+} empty_test = { { }, 3 };
+
+EmptyTest empty_test2 = { 3 }; // expected-error{{initializer for aggregate with no elements requires explicit braces}}
+
+struct NonEmpty {
+ int a;
+ Empty empty;
+};
+struct NonEmptyTest {
+ NonEmpty a, b;
+} non_empty_test = { { }, { } };
+
+// C++ [dcl.init.aggr]p9
+struct HasReference {
+ int i;
+ int &j; // expected-note{{uninitialized reference member is here}}
+};
+int global_int;
+HasReference r1 = { 1, global_int };
+HasReference r2 = { 1 } ; // expected-error{{reference member of type 'int &' uninitialized}}
+
+// C++ [dcl.init.aggr]p10
+// Note: the behavior here is identical to C
+int xs[2][2] = { 3, 1, 4, 2 };
+float y[4][3] = { { 1 }, { 2 }, { 3 }, { 4 } };
+
+// C++ [dcl.init.aggr]p11
+// Note: the behavior here is identical to C
+float y2[4][3] = { { 1, 3, 5 }, { 2, 4, 6 }, { 3, 5, 7 } };
+float same_as_y2[4][3] = { 1, 3, 5, 2, 4, 6, 3, 5, 7 };
+
+// C++ [dcl.init.aggr]p12
+struct A2 {
+ int i;
+ operator int *();
+};
+struct B2 {
+ A2 a1, a2;
+ int *z;
+};
+struct C2 {
+ operator A2();
+};
+struct D2 {
+ operator int();
+};
+A2 a2;
+C2 c2;
+D2 d2;
+B2 b2 = { 4, a2, a2 };
+B2 b2_2 = { 4, d2, 0 };
+B2 b2_3 = { c2, a2, a2 };
+
+// C++ [dcl.init.aggr]p15:
+union u { int a; char* b; }; // expected-note{{candidate constructor (the implicit copy constructor)}}
+u u1 = { 1 };
+u u2 = u1;
+u u3 = 1; // expected-error{{no viable conversion}}
+u u4 = { 0, "asdf" }; // expected-error{{excess elements in union initializer}}
+u u5 = { "asdf" }; // expected-error{{cannot initialize a member subobject of type 'int' with an lvalue of type 'const char [5]'}}
diff --git a/clang/test/SemaCXX/decl-expr-ambiguity.cpp b/clang/test/SemaCXX/decl-expr-ambiguity.cpp
new file mode 100644
index 0000000..6f4d08c
--- /dev/null
+++ b/clang/test/SemaCXX/decl-expr-ambiguity.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic-errors %s
+
+void f() {
+ int a;
+ struct S { int m; };
+ typedef S *T;
+
+ // Expressions.
+ T(a)->m = 7;
+ int(a)++; // expected-error {{assignment to cast is illegal}}
+ __extension__ int(a)++; // expected-error {{assignment to cast is illegal}}
+ __typeof(int)(a,5)<<a; // expected-error {{excess elements in scalar initializer}}
+ void(a), ++a;
+ if (int(a)+1) {}
+ for (int(a)+1;;) {} // expected-warning {{expression result unused}}
+ a = sizeof(int()+1);
+ a = sizeof(int(1));
+ typeof(int()+1) a2; // expected-error {{extension used}}
+ (int(1)); // expected-warning {{expression result unused}}
+
+ // type-id
+ (int())1; // expected-error {{C-style cast from 'int' to 'int ()' is not allowed}}
+
+ // Declarations.
+ int fd(T(a)); // expected-warning {{parentheses were disambiguated as a function declarator}}
+ T(*d)(int(p)); // expected-warning {{parentheses were disambiguated as a function declarator}} expected-note {{previous definition is here}}
+ typedef T(*td)(int(p));
+ extern T(*tp)(int(p));
+ T d3(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
+ T d3v(void);
+ typedef T d3t();
+ extern T f3();
+ __typeof(*T()) f4(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
+ typedef void *V;
+ __typeof(*V()) f5();
+ T multi1,
+ multi2(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
+ T(d)[5]; // expected-error {{redefinition of 'd'}}
+ typeof(int[])(f) = { 1, 2 }; // expected-error {{extension used}}
+ void(b)(int);
+ int(d2) __attribute__(());
+ if (int(a)=1) {}
+ int(d3(int()));
+}
+
+struct RAII {
+ RAII();
+ ~RAII();
+};
+
+void func();
+namespace N {
+ struct S;
+
+ void emptyParens() {
+ RAII raii(); // expected-warning {{function declaration}} expected-note {{remove parentheses to declare a variable}}
+ int a, b, c, d, e, // expected-note {{change this ',' to a ';' to call 'func'}}
+ func(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ S s(); // expected-warning {{function declaration}}
+ }
+}
+
+class C { };
+void fn(int(C)) { } // void fn(int(*fp)(C c)) { } expected-note{{candidate function}}
+ // not: void fn(int C);
+int g(C);
+
+void foo() {
+ fn(1); // expected-error {{no matching function}}
+ fn(g); // OK
+}
diff --git a/clang/test/SemaCXX/decl-init-ref.cpp b/clang/test/SemaCXX/decl-init-ref.cpp
new file mode 100644
index 0000000..4c635c1
--- /dev/null
+++ b/clang/test/SemaCXX/decl-init-ref.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct A {};
+
+struct BASE {
+ operator A(); // expected-note {{candidate function}}
+};
+
+struct BASE1 {
+ operator A(); // expected-note {{candidate function}}
+};
+
+class B : public BASE , public BASE1
+{
+ public:
+ B();
+} b;
+
+extern B f();
+
+const int& ri = (void)0; // expected-error {{reference to type 'const int' could not bind to an rvalue of type 'void'}}
+
+int main() {
+ const A& rca = f(); // expected-error {{reference initialization of type 'const A &' with initializer of type 'B' is ambiguous}}
+ A& ra = f(); // expected-error {{non-const lvalue reference to type 'A' cannot bind to a temporary of type 'B'}}
+}
+
+struct PR6139 { A (&x)[1]; };
+PR6139 x = {{A()}}; // expected-error{{non-const lvalue reference to type 'A [1]' cannot bind to a temporary of type 'A'}}
diff --git a/clang/test/SemaCXX/decltype-98.cpp b/clang/test/SemaCXX/decltype-98.cpp
new file mode 100644
index 0000000..db52565
--- /dev/null
+++ b/clang/test/SemaCXX/decltype-98.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s
+extern int x;
+__decltype(1) x = 3;
diff --git a/clang/test/SemaCXX/decltype-crash.cpp b/clang/test/SemaCXX/decltype-crash.cpp
new file mode 100644
index 0000000..002bd4c
--- /dev/null
+++ b/clang/test/SemaCXX/decltype-crash.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s
+
+int& a();
+
+void f() {
+ decltype(a()) c; // expected-warning {{'decltype' is a keyword in C++11}} expected-error {{use of undeclared identifier 'decltype'}}
+}
diff --git a/clang/test/SemaCXX/decltype-overloaded-functions.cpp b/clang/test/SemaCXX/decltype-overloaded-functions.cpp
new file mode 100644
index 0000000..b0a43a9
--- /dev/null
+++ b/clang/test/SemaCXX/decltype-overloaded-functions.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+void f(); // expected-note{{possible target for call}}
+void f(int); // expected-note{{possible target for call}}
+decltype(f) a; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error {{variable has incomplete type 'decltype(f())' (aka 'void')}}
+
+template<typename T> struct S {
+ decltype(T::f) * f; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error {{call to non-static member function without an object argument}}
+};
+
+struct K {
+ void f(); // expected-note{{possible target for call}}
+ void f(int); // expected-note{{possible target for call}}
+};
+S<K> b; // expected-note{{in instantiation of template class 'S<K>' requested here}}
diff --git a/clang/test/SemaCXX/decltype-pr4444.cpp b/clang/test/SemaCXX/decltype-pr4444.cpp
new file mode 100644
index 0000000..2f95075
--- /dev/null
+++ b/clang/test/SemaCXX/decltype-pr4444.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+template<typename T, T t>
+struct TestStruct {
+ typedef decltype(t+2) sum_type;
+};
diff --git a/clang/test/SemaCXX/decltype-pr4448.cpp b/clang/test/SemaCXX/decltype-pr4448.cpp
new file mode 100644
index 0000000..9d33ce7
--- /dev/null
+++ b/clang/test/SemaCXX/decltype-pr4448.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+template< typename T, T t, decltype(t+2) v >
+struct Convoluted {};
+
+int test_array[5];
+
+Convoluted< int *, test_array, nullptr > tarray;
diff --git a/clang/test/SemaCXX/decltype-this.cpp b/clang/test/SemaCXX/decltype-this.cpp
new file mode 100644
index 0000000..a13416f
--- /dev/null
+++ b/clang/test/SemaCXX/decltype-this.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template<typename T, typename U> struct is_same {
+ static const bool value = false;
+};
+
+template<typename T> struct is_same<T, T> {
+ static const bool value = true;
+};
+
+struct S {
+ void f() { static_assert(is_same<decltype(this), S*>::value, ""); }
+ void g() const { static_assert(is_same<decltype(this), const S*>::value, ""); }
+ void h() volatile { static_assert(is_same<decltype(this), volatile S*>::value, ""); }
+ void i() const volatile { static_assert(is_same<decltype(this), const volatile S*>::value, ""); }
+};
diff --git a/clang/test/SemaCXX/decltype.cpp b/clang/test/SemaCXX/decltype.cpp
new file mode 100644
index 0000000..a1200e0
--- /dev/null
+++ b/clang/test/SemaCXX/decltype.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// PR5290
+int const f0();
+void f0_test() {
+ decltype(0, f0()) i = 0;
+ i = 0;
+}
+
+struct A { int a[1]; A() { } };
+typedef A const AC;
+int &f1(int*);
+float &f2(int const*);
+
+void test_f2() {
+ float &fr = f2(AC().a);
+}
+
+namespace pr10154 {
+ class A{
+ A(decltype(nullptr) param);
+ };
+}
+
+template<typename T> struct S {};
+template<typename T> auto f(T t) -> decltype(S<int>(t)) {
+ using U = decltype(S<int>(t));
+ using U = S<int>;
+ return S<int>(t);
+}
diff --git a/clang/test/SemaCXX/default-arg-special-member.cpp b/clang/test/SemaCXX/default-arg-special-member.cpp
new file mode 100644
index 0000000..8402d38
--- /dev/null
+++ b/clang/test/SemaCXX/default-arg-special-member.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wno-default-arg-special-member -Werror -fsyntax-only %s
+
+class foo {
+ foo(foo&, int); // expected-note {{was not a special member function}}
+ foo(int); // expected-note {{was not a special member function}}
+ foo(const foo&); // expected-note {{was a copy constructor}}
+};
+
+foo::foo(foo&, int = 0) { } // expected-warning {{makes this constructor a copy constructor}}
+foo::foo(int = 0) { } // expected-warning {{makes this constructor a default constructor}}
+foo::foo(const foo& = 0) { } //expected-warning {{makes this constructor a default constructor}}
diff --git a/clang/test/SemaCXX/default-argument-temporaries.cpp b/clang/test/SemaCXX/default-argument-temporaries.cpp
new file mode 100644
index 0000000..3ab7bf4
--- /dev/null
+++ b/clang/test/SemaCXX/default-argument-temporaries.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct B { B(void* = 0); };
+
+struct A {
+ A(B b = B()) { }
+};
+
+void f() {
+ (void)B();
+ (void)A();
+}
diff --git a/clang/test/SemaCXX/default-assignment-operator.cpp b/clang/test/SemaCXX/default-assignment-operator.cpp
new file mode 100644
index 0000000..668c600
--- /dev/null
+++ b/clang/test/SemaCXX/default-assignment-operator.cpp
@@ -0,0 +1,118 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class Base { // expected-error {{cannot define the implicit default assignment operator for 'Base', because non-static reference member 'ref' can't use default assignment operator}} \
+ // expected-warning{{class 'Base' does not declare any constructor to initialize its non-modifiable members}}
+ int &ref; // expected-note {{declared here}} \
+ // expected-note{{reference member 'ref' will never be initialized}}
+};
+
+class X : Base { // // expected-error {{cannot define the implicit default assignment operator for 'X', because non-static const member 'cint' can't use default assignment operator}} \
+// expected-note{{assignment operator for 'Base' first required here}}
+public:
+ X();
+ const int cint; // expected-note {{declared here}}
+};
+
+struct Y : X {
+ Y();
+ Y& operator=(const Y&);
+ Y& operator=(volatile Y&);
+ Y& operator=(const volatile Y&);
+ Y& operator=(Y&);
+};
+
+class Z : Y {};
+
+Z z1;
+Z z2;
+
+// Test1
+void f(X x, const X cx) {
+ x = cx; // expected-note{{assignment operator for 'X' first required here}}
+ x = cx;
+ z1 = z2;
+}
+
+// Test2
+class T {};
+T t1;
+T t2;
+
+void g() {
+ t1 = t2;
+}
+
+// Test3
+class V {
+public:
+ V();
+ V &operator = (V &b);
+};
+
+class W : V {};
+W w1, w2;
+
+void h() {
+ w1 = w2;
+}
+
+// Test4
+
+class B1 {
+public:
+ B1();
+ B1 &operator = (B1 b);
+};
+
+class D1 : B1 {};
+D1 d1, d2;
+
+void i() {
+ d1 = d2;
+}
+
+// Test5
+
+class E1 { // expected-error{{cannot define the implicit default assignment operator for 'E1', because non-static const member 'a' can't use default assignment operator}}
+
+public:
+ const int a; // expected-note{{declared here}}
+ E1() : a(0) {}
+
+};
+
+E1 e1, e2;
+
+void j() {
+ e1 = e2; // expected-note{{assignment operator for 'E1' first required here}}
+}
+
+namespace ProtectedCheck {
+ struct X {
+ protected:
+ X &operator=(const X&); // expected-note{{declared protected here}}
+ };
+
+ struct Y : public X { };
+
+ void f(Y y) { y = y; }
+
+ struct Z { // expected-error{{'operator=' is a protected member of 'ProtectedCheck::X'}}
+ X x;
+ };
+
+ void f(Z z) { z = z; } // expected-note{{implicit default copy assignment operator}}
+
+}
+
+namespace MultiplePaths {
+ struct X0 {
+ X0 &operator=(const X0&);
+ };
+
+ struct X1 : public virtual X0 { };
+
+ struct X2 : X0, X1 { };
+
+ void f(X2 x2) { x2 = x2; }
+}
diff --git a/clang/test/SemaCXX/default-constructor-initializers.cpp b/clang/test/SemaCXX/default-constructor-initializers.cpp
new file mode 100644
index 0000000..e783f49
--- /dev/null
+++ b/clang/test/SemaCXX/default-constructor-initializers.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct X1 { // has no implicit default constructor
+ X1(int);
+};
+
+struct X2 : X1 { // expected-note 2 {{'X2' declared here}}
+ X2(int);
+};
+
+struct X3 : public X2 { // expected-error {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}}
+};
+X3 x3; // expected-note {{first required here}}
+
+
+struct X4 { // expected-error {{must explicitly initialize the member 'x2'}} \
+ // expected-error {{must explicitly initialize the reference member 'rx2'}}
+ X2 x2; // expected-note {{member is declared here}}
+ X2 & rx2; // expected-note {{declared here}}
+};
+
+X4 x4; // expected-note {{first required here}}
+
+
+struct Y1 { // has no implicit default constructor
+ Y1(int);
+};
+
+struct Y2 : Y1 {
+ Y2(int);
+ Y2();
+};
+
+struct Y3 : public Y2 {
+};
+Y3 y3;
+
+struct Y4 {
+ Y2 y2;
+};
+
+Y4 y4;
+
+// More tests
+
+struct Z1 { // expected-error {{must explicitly initialize the reference member 'z'}} \
+ // expected-error {{must explicitly initialize the const member 'c1'}}
+ int& z; // expected-note {{declared here}}
+ const int c1; // expected-note {{declared here}}
+ volatile int v1;
+};
+
+// Test default initialization which *requires* a constructor call for non-POD.
+Z1 z1; // expected-note {{first required here}}
+
+// Ensure that value initialization doesn't use trivial implicit constructors.
+namespace PR7948 {
+ // Note that this is also non-POD to ensure we don't just special case PODs.
+ struct S { const int x; ~S(); };
+ const S arr[2] = { { 42 } };
+}
+
+// This is valid
+union U {
+ const int i;
+ float f;
+};
+U u;
diff --git a/clang/test/SemaCXX/default1.cpp b/clang/test/SemaCXX/default1.cpp
new file mode 100644
index 0000000..ae6ef97
--- /dev/null
+++ b/clang/test/SemaCXX/default1.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+void f(int i);
+void f(int i = 0); // expected-note {{previous definition is here}}
+void f(int i = 17); // expected-error {{redefinition of default argument}}
+
+
+void g(int i, int j, int k = 3);
+void g(int i, int j = 2, int k);
+void g(int i = 1, int j, int k);
+
+void h(int i, int j = 2, int k = 3,
+ int l, // expected-error {{missing default argument on parameter 'l'}}
+ int, // expected-error {{missing default argument on parameter}}
+ int n);// expected-error {{missing default argument on parameter 'n'}}
+
+struct S { } s;
+void i(int = s) { } // expected-error {{no viable conversion}} \
+// expected-note{{passing argument to parameter here}}
+
+struct X {
+ X(int);
+};
+
+void j(X x = 17);
+
+struct Y { // expected-note 2{{candidate}}
+ explicit Y(int);
+};
+
+void k(Y y = 17); // expected-error{{no viable conversion}} \
+// expected-note{{passing argument to parameter 'y' here}}
+
+void kk(Y = 17); // expected-error{{no viable conversion}} \
+// expected-note{{passing argument to parameter here}}
+
+int l () {
+ int m(int i, int j, int k = 3);
+ if (1)
+ {
+ int m(int i, int j = 2, int k = 4);
+ m(8);
+ }
+ return 0;
+}
+
+int i () {
+ void j (int f = 4);
+ {
+ void j (int f); // expected-note{{'j' declared here}}
+ j(); // expected-error{{too few arguments to function call, expected 1, have 0}}
+ }
+}
diff --git a/clang/test/SemaCXX/default2.cpp b/clang/test/SemaCXX/default2.cpp
new file mode 100644
index 0000000..1626044
--- /dev/null
+++ b/clang/test/SemaCXX/default2.cpp
@@ -0,0 +1,124 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f(int i, int j, int k = 3);
+void f(int i, int j, int k);
+void f(int i, int j = 2, int k);
+void f(int i, int j, int k);
+void f(int i = 1, int j, int k);
+void f(int i, int j, int k);
+
+void i()
+{
+ f();
+ f(0);
+ f(0, 1);
+ f(0, 1, 2);
+}
+
+
+int f1(int i, // expected-note {{previous declaration is here}}
+ int i, int j) { // expected-error {{redefinition of parameter 'i'}}
+ i = 17;
+ return j;
+}
+
+int x;
+void g(int x, int y = x); // expected-error {{default argument references parameter 'x'}}
+
+void g2(int x, int y, int z = x + y); // expected-error {{default argument references parameter 'x'}} expected-error {{default argument references parameter 'y'}}
+
+class X {
+ void f(X* x = this); // expected-error{{invalid use of 'this' outside of a non-static member function}}
+
+ void g() {
+ int f(X* x = this); // expected-error{{default argument references 'this'}}
+ }
+};
+
+// C++ [dcl.fct.default]p6
+class C {
+ static int x;
+ void f(int i = 3); // expected-note{{previous definition is here}}
+ void g(int i, int j = x);
+
+ void h();
+};
+void C::f(int i = 3) // expected-error{{redefinition of default argument}}
+{ }
+
+void C::g(int i = 88, int j) {}
+
+void C::h() {
+ g(); // okay
+}
+
+// C++ [dcl.fct.default]p9
+struct Y {
+ int a;
+ int mem1(int i = a); // expected-error{{invalid use of non-static data member 'a'}}
+ int mem2(int i = b); // OK; use Y::b
+ int mem3(int i);
+ int mem4(int i);
+
+ struct Nested {
+ int mem5(int i = b, // OK; use Y::b
+ int j = c, // OK; use Y::Nested::c
+ int k = j, // expected-error{{default argument references parameter 'j'}}
+ int l = a, // expected-error{{invalid use of non-static data member 'a'}}
+ Nested* self = this, // expected-error{{invalid use of 'this' outside of a non-static member function}}
+ int m); // expected-error{{missing default argument on parameter 'm'}}
+ static int c;
+ Nested(int i = 42);
+ };
+
+ int mem7(Nested n = Nested());
+
+ static int b;
+};
+
+int Y::mem3(int i = b) { return i; } // OK; use X::b
+
+int Y::mem4(int i = a) // expected-error{{invalid use of non-static data member 'a'}}
+{ return i; }
+
+
+// Try to verify that default arguments interact properly with copy
+// constructors.
+class Z {
+public:
+ Z(Z&, int i = 17); // expected-note 3 {{candidate constructor}}
+
+ void f(Z& z) {
+ Z z2; // expected-error{{no matching constructor for initialization}}
+ Z z3(z);
+ }
+
+ void test_Z(const Z& z) {
+ Z z2(z); // expected-error{{no matching constructor for initialization of 'Z'}}
+ }
+};
+
+void test_Z(const Z& z) {
+ Z z2(z); // expected-error{{no matching constructor for initialization of 'Z'}}
+}
+
+struct ZZ {
+ static ZZ g(int = 17);
+
+ void f(ZZ z = g()); // expected-error{{no matching constructor for initialization}} \
+ // expected-note{{passing argument to parameter 'z' here}}
+
+ ZZ(ZZ&, int = 17); // expected-note{{candidate constructor}}
+};
+
+// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#325
+class C2 {
+ static void g(int = f()); // expected-error{{use of default argument to function 'f' that is declared later in class 'C2'}}
+ static int f(int = 10); // expected-note{{default argument declared here}}
+};
+
+// Make sure we actually parse the default argument for an inline definition
+class XX {
+ void A(int length = -1 ) { }
+ void B() { A(); }
+};
diff --git a/clang/test/SemaCXX/defaulted-ctor-loop.cpp b/clang/test/SemaCXX/defaulted-ctor-loop.cpp
new file mode 100644
index 0000000..6416336
--- /dev/null
+++ b/clang/test/SemaCXX/defaulted-ctor-loop.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// WARNING: This test may recurse infinitely if failing.
+
+struct foo;
+struct bar {
+ bar(foo&);
+};
+struct foo {
+ bar b;
+ foo()
+ : b(b) // expected-warning{{field is uninitialized}}
+ {}
+};
diff --git a/clang/test/SemaCXX/defaulted-private-dtor.cpp b/clang/test/SemaCXX/defaulted-private-dtor.cpp
new file mode 100644
index 0000000..e6f9555
--- /dev/null
+++ b/clang/test/SemaCXX/defaulted-private-dtor.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s -fcxx-exceptions
+
+class BadDtor {
+ // A private, but nonetheless trivial, destructor.
+ ~BadDtor() = default; // expected-note 9{{here}}
+ friend class K;
+};
+void f() {
+ BadDtor *p = new BadDtor[3]; // expected-error {{private destructor}}
+ delete [] p; // expected-error {{private destructor}}
+ const BadDtor &dd2 = BadDtor(); // expected-error {{private destructor}}
+ BadDtor dd; // expected-error {{private destructor}}
+ throw dd; // expected-error {{private destructor}}
+}
+struct V {
+ V();
+ BadDtor bd; // expected-note {{inaccessible destructor}}
+};
+V v; // expected-error {{deleted function}}
+struct W : BadDtor { // expected-note {{inaccessible destructor}}
+ W();
+};
+W w; // expected-error {{deleted function}}
+struct X : BadDtor { // expected-error {{private destructor}}
+ ~X() {}
+};
+struct Y {
+ BadDtor dd; // expected-error {{private destructor}}
+ ~Y() {}
+};
+struct Z : virtual BadDtor { // expected-error {{private destructor}}
+ ~Z() {}
+};
+BadDtor dd; // expected-error {{private destructor}}
+
+class K : BadDtor {
+ void f() {
+ BadDtor *p = new BadDtor[3];
+ delete [] p;
+ const BadDtor &dd2 = BadDtor();
+ BadDtor dd;
+ throw dd;
+
+ {
+ BadDtor x;
+ goto dont_call_dtor;
+ }
+dont_call_dtor:
+ ;
+ }
+ struct Z : virtual BadDtor {
+ ~Z() {}
+ };
+ BadDtor dd;
+ ~K();
+};
diff --git a/clang/test/SemaCXX/delete.cpp b/clang/test/SemaCXX/delete.cpp
new file mode 100644
index 0000000..5824fac
--- /dev/null
+++ b/clang/test/SemaCXX/delete.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: cp %s %t
+// RUN: %clang_cc1 -fixit -x c++ %t
+// RUN: %clang_cc1 -E -o - %t | FileCheck %s
+
+void f(int a[10][20]) {
+ // CHECK: delete[] a;
+ delete a; // expected-warning {{'delete' applied to a pointer-to-array type}}
+}
diff --git a/clang/test/SemaCXX/deleted-function.cpp b/clang/test/SemaCXX/deleted-function.cpp
new file mode 100644
index 0000000..d13fd0e
--- /dev/null
+++ b/clang/test/SemaCXX/deleted-function.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fcxx-exceptions %s
+
+int i = delete; // expected-error {{only functions can have deleted definitions}}
+
+void fn() = delete; // expected-note {{candidate function has been explicitly deleted}}
+
+void fn2(); // expected-note {{previous declaration is here}}
+void fn2() = delete; // expected-error {{deleted definition must be first declaration}}
+
+void fn3() = delete; // expected-note {{previous definition is here}}
+void fn3() { // expected-error {{redefinition}}
+}
+
+void ov(int) {} // expected-note {{candidate function}}
+void ov(double) = delete; // expected-note {{candidate function has been explicitly deleted}}
+
+struct WithDel {
+ WithDel() = delete; // expected-note {{function has been explicitly marked deleted here}}
+ void fn() = delete; // expected-note {{function has been explicitly marked deleted here}}
+ operator int() = delete; // expected-note {{function has been explicitly marked deleted here}}
+ void operator +(int) = delete;
+
+ int i = delete; // expected-error {{only functions can have deleted definitions}}
+};
+
+void test() {
+ fn(); // expected-error {{call to deleted function 'fn'}}
+ ov(1);
+ ov(1.0); // expected-error {{call to deleted function 'ov'}}
+
+ WithDel dd; // expected-error {{call to deleted constructor of 'WithDel'}}
+ WithDel *d = 0;
+ d->fn(); // expected-error {{attempt to use a deleted function}}
+ int i = *d; // expected-error {{invokes a deleted function}}
+}
+
+struct DelDtor {
+ ~DelDtor() = delete; // expected-note 9{{here}}
+};
+void f() {
+ DelDtor *p = new DelDtor[3]; // expected-error {{attempt to use a deleted function}}
+ delete [] p; // expected-error {{attempt to use a deleted function}}
+ const DelDtor &dd2 = DelDtor(); // expected-error {{attempt to use a deleted function}}
+ DelDtor dd; // expected-error {{attempt to use a deleted function}}
+ throw dd; // expected-error {{attempt to use a deleted function}}
+}
+struct X : DelDtor {
+ ~X() {} // expected-error {{attempt to use a deleted function}}
+};
+struct Y {
+ DelDtor dd;
+ ~Y() {} // expected-error {{attempt to use a deleted function}}
+};
+struct Z : virtual DelDtor {
+ ~Z() {} // expected-error {{attempt to use a deleted function}}
+};
+DelDtor dd; // expected-error {{attempt to use a deleted function}}
diff --git a/clang/test/SemaCXX/deleted-operator.cpp b/clang/test/SemaCXX/deleted-operator.cpp
new file mode 100644
index 0000000..0e0282a
--- /dev/null
+++ b/clang/test/SemaCXX/deleted-operator.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct PR10757 {
+ bool operator~() = delete; // expected-note {{explicitly deleted}}
+ bool operator==(const PR10757&) = delete; // expected-note {{explicitly deleted}}
+ operator float();
+};
+int PR10757f() {
+ PR10757 a1;
+ // FIXME: We get a ridiculous number of "built-in candidate" notes here...
+ if(~a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 6 {{built-in candidate}}
+ if(a1==a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 81 {{built-in candidate}}
+}
+
+struct DelOpDel {
+ virtual ~DelOpDel() {} // expected-error {{deleted function}}
+ void operator delete(void*) = delete; // expected-note {{deleted here}}
+};
diff --git a/clang/test/SemaCXX/dependent-auto.cpp b/clang/test/SemaCXX/dependent-auto.cpp
new file mode 100644
index 0000000..6d37f7a
--- /dev/null
+++ b/clang/test/SemaCXX/dependent-auto.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+template<typename T>
+struct only {
+ only(T);
+ template<typename U> only(U) = delete; // expected-note {{here}}
+};
+
+template<typename ...T>
+void f(T ...t) {
+ auto x(t...); // expected-error {{is empty}} expected-error {{contains multiple expressions}}
+ only<int> check = x;
+}
+
+void g() {
+ f(); // expected-note {{here}}
+ f(0);
+ f(0, 1); // expected-note {{here}}
+}
+
+
+template<typename T>
+bool h(T t) {
+ auto a = t;
+ decltype(a) b;
+ a = a + b;
+
+ auto p = new auto(t);
+
+ only<double*> test = p; // expected-error {{conversion function from 'char *' to 'only<double *>'}}
+ return p;
+}
+
+bool b = h('x'); // expected-note {{here}}
+
+// PR 9276 - Make sure we check auto types deduce the same
+// in the case of a dependent initializer
+namespace PR9276 {
+ template<typename T>
+ void f() {
+ auto i = T(), j = 0; // expected-error {{deduced as 'long' in declaration of 'i' and deduced as 'int' in declaration of 'j'}}
+ }
+
+ void g() {
+ f<long>(); // expected-note {{here}}
+ f<int>();
+ }
+}
+
+namespace NoRepeatedDiagnostic {
+ template<typename T>
+ void f() {
+ auto a = 0, b = 0.0, c = T(); // expected-error {{deduced as 'int' in declaration of 'a' and deduced as 'double' in declaration of 'b'}}
+ }
+ // We've already diagnosed an issue. No extra diagnostics is needed for these.
+ template void f<int>();
+ template void f<double>();
+ template void f<char>();
+}
diff --git a/clang/test/SemaCXX/dependent-noexcept-unevaluated.cpp b/clang/test/SemaCXX/dependent-noexcept-unevaluated.cpp
new file mode 100644
index 0000000..0a3a8bb
--- /dev/null
+++ b/clang/test/SemaCXX/dependent-noexcept-unevaluated.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s
+
+template <class T>
+T&&
+declval() noexcept;
+
+template <class T>
+struct some_trait
+{
+ static const bool value = false;
+};
+
+template <class T>
+void swap(T& x, T& y) noexcept(some_trait<T>::value)
+{
+ T tmp(static_cast<T&&>(x));
+ x = static_cast<T&&>(y);
+ y = static_cast<T&&>(tmp);
+}
+
+template <class T, unsigned N>
+struct array
+{
+ T data[N];
+
+ void swap(array& a) noexcept(noexcept(swap(declval<T&>(), declval<T&>())));
+};
+
+struct DefaultOnly
+{
+ DefaultOnly() = default;
+ DefaultOnly(const DefaultOnly&) = delete;
+ DefaultOnly& operator=(const DefaultOnly&) = delete;
+ ~DefaultOnly() = default;
+};
+
+int main()
+{
+ array<DefaultOnly, 1> a, b;
+}
diff --git a/clang/test/SemaCXX/dependent-types.cpp b/clang/test/SemaCXX/dependent-types.cpp
new file mode 100644
index 0000000..13ed72f
--- /dev/null
+++ b/clang/test/SemaCXX/dependent-types.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++11 %s
+
+template<typename T> using U = int &;
+
+template<typename T, int Size> void f() {
+ T x1;
+ T* x2;
+ T& x3; // expected-error{{declaration of reference variable 'x3' requires an initializer}}
+ T x4[]; // expected-error{{needs an explicit size or an initializer}}
+ T x5[Size];
+ int x6[Size];
+ U<T> x7; // expected-error{{declaration of reference variable 'x7' requires an initializer}}
+}
diff --git a/clang/test/SemaCXX/derived-to-base-ambig.cpp b/clang/test/SemaCXX/derived-to-base-ambig.cpp
new file mode 100644
index 0000000..129ec79
--- /dev/null
+++ b/clang/test/SemaCXX/derived-to-base-ambig.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class A { };
+class B : public A { };
+class C : public A { };
+class D : public B, public C { };
+
+void f(D* d) {
+ A* a;
+ a = d; // expected-error{{ambiguous conversion from derived class 'D' to base class 'A':}} expected-error{{assigning to 'A *' from incompatible type 'D *'}}
+}
+
+class Object2 { };
+class A2 : public Object2 { };
+class B2 : public virtual A2 { };
+class C2 : virtual public A2 { };
+class D2 : public B2, public C2 { };
+class E2 : public D2, public C2, public virtual A2 { };
+class F2 : public E2, public A2 { };
+
+void g(E2* e2, F2* f2) {
+ Object2* o2;
+ o2 = e2;
+ o2 = f2; // expected-error{{ambiguous conversion from derived class 'F2' to base class 'Object2':}} expected-error{{assigning to 'Object2 *' from incompatible type 'F2 *'}}
+}
+
+// Test that ambiguous/inaccessibility checking does not trigger too
+// early, because it should not apply during overload resolution.
+void overload_okay(Object2*);
+void overload_okay(E2*);
+
+void overload_call(F2* f2) {
+ overload_okay(f2);
+}
diff --git a/clang/test/SemaCXX/destructor.cpp b/clang/test/SemaCXX/destructor.cpp
new file mode 100644
index 0000000..f3c6ab0
--- /dev/null
+++ b/clang/test/SemaCXX/destructor.cpp
@@ -0,0 +1,365 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -verify %s
+class A {
+public:
+ ~A();
+};
+
+class B {
+public:
+ ~B() { }
+};
+
+class C {
+public:
+ (~C)() { }
+};
+
+struct D {
+ static void ~D(int, ...) const { } // \
+ // expected-error{{static member function cannot have 'const' qualifier}} \
+ // expected-error{{destructor cannot be declared 'static'}} \
+ // expected-error{{destructor cannot have any parameters}} \
+ // expected-error{{destructor cannot be variadic}} \
+ // expected-error{{destructor cannot have a return type}} \
+ // expected-error{{'const' qualifier is not allowed on a destructor}}
+};
+
+struct D2 {
+ void ~D2() { } // \
+ // expected-error{{destructor cannot have a return type}}
+};
+
+
+struct E;
+
+typedef E E_typedef;
+struct E {
+ ~E_typedef(); // expected-error{{destructor cannot be declared using a typedef 'E_typedef' (aka 'E') of the class name}}
+};
+
+struct F {
+ (~F)(); // expected-note {{previous declaration is here}}
+ ~F(); // expected-error {{destructor cannot be redeclared}}
+};
+
+~; // expected-error {{expected a class name after '~' to name a destructor}}
+~undef(); // expected-error {{expected the class name after '~' to name a destructor}}
+~operator+(int, int); // expected-error {{expected a class name after '~' to name a destructor}}
+~F(){} // expected-error {{destructor must be a non-static member function}}
+
+struct G {
+ ~G();
+};
+
+G::~G() { }
+
+// <rdar://problem/6841210>
+struct H {
+ ~H(void) { }
+};
+
+struct X {};
+
+struct Y {
+ ~X(); // expected-error {{expected the class name after '~' to name the enclosing class}}
+};
+
+namespace PR6421 {
+ class T; // expected-note{{forward declaration}}
+
+ class QGenericArgument // expected-note{{declared here}}
+ {
+ template<typename U>
+ void foo(T t) // expected-error{{variable has incomplete type}}
+ { }
+
+ void disconnect()
+ {
+ T* t;
+ bob<QGenericArgument>(t); // expected-error{{undeclared identifier 'bob'}} \
+ // expected-error{{does not refer to a value}}
+ }
+ };
+}
+
+namespace PR6709 {
+ template<class T> class X { T v; ~X() { ++*v; } };
+ void a(X<int> x) {}
+}
+
+struct X0 { virtual ~X0() throw(); };
+struct X1 : public X0 { };
+
+// Make sure we instantiate operator deletes when building a virtual
+// destructor.
+namespace test6 {
+ template <class T> class A {
+ public:
+ void *operator new(__SIZE_TYPE__);
+ void operator delete(void *p) {
+ T::deleteIt(p); // expected-error {{type 'int' cannot be used prior to '::'}}
+ }
+
+ virtual ~A() {}
+ };
+
+ class B : A<int> { B(); }; // expected-note {{in instantiation of member function 'test6::A<int>::operator delete' requested here}}
+ B::B() {}
+}
+
+// Make sure classes are marked invalid when they have invalid
+// members. This avoids a crash-on-invalid.
+namespace test7 {
+ struct A {
+ ~A() const; // expected-error {{'const' qualifier is not allowed on a destructor}}
+ };
+ struct B : A {};
+
+ void test() {
+ B *b;
+ b->~B();
+ }
+}
+
+namespace nonvirtualdtor {
+struct S1 { // expected-warning {{has virtual functions but non-virtual destructor}}
+ virtual void m();
+};
+
+struct S2 {
+ ~S2(); // expected-warning {{has virtual functions but non-virtual destructor}}
+ virtual void m();
+};
+
+struct S3 : public S1 { // expected-warning {{has virtual functions but non-virtual destructor}}
+ virtual void m();
+};
+
+struct S4 : public S2 { // expected-warning {{has virtual functions but non-virtual destructor}}
+ virtual void m();
+};
+
+struct B {
+ virtual ~B();
+ virtual void m();
+};
+
+struct S5 : public B {
+ virtual void m();
+};
+
+struct S6 {
+ virtual void m();
+private:
+ ~S6();
+};
+
+struct S7 {
+ virtual void m();
+protected:
+ ~S7();
+};
+
+template<class T> class TS : public B {
+ virtual void m();
+};
+
+TS<int> baz;
+
+template<class T> class TS2 { // expected-warning {{'nonvirtualdtor::TS2<int>' has virtual functions but non-virtual destructor}}
+ virtual void m();
+};
+
+TS2<int> foo; // expected-note {{instantiation}}
+}
+
+namespace dnvd { // delete-non-virtual-dtor warning
+struct NP {};
+
+struct B { // expected-warning {{has virtual functions but non-virtual destructor}}
+ virtual void foo();
+};
+
+struct D: B {}; // expected-warning {{has virtual functions but non-virtual destructor}}
+
+struct F final: B {}; // expected-warning {{has virtual functions but non-virtual destructor}}
+
+struct VB {
+ virtual void foo();
+ virtual ~VB();
+};
+
+struct VD: VB {};
+
+struct VF final: VB {};
+
+template <typename T>
+class simple_ptr {
+public:
+ simple_ptr(T* t): _ptr(t) {}
+ ~simple_ptr() { delete _ptr; } // \
+ // expected-warning {{delete called on 'dnvd::B' that has virtual functions but non-virtual destructor}} \
+ // expected-warning {{delete called on 'dnvd::D' that has virtual functions but non-virtual destructor}}
+ T& operator*() const { return *_ptr; }
+private:
+ T* _ptr;
+};
+
+template <typename T>
+class simple_ptr2 {
+public:
+ simple_ptr2(T* t): _ptr(t) {}
+ ~simple_ptr2() { delete _ptr; } // expected-warning {{delete called on 'dnvd::B' that has virtual functions but non-virtual destructor}}
+ T& operator*() const { return *_ptr; }
+private:
+ T* _ptr;
+};
+
+void use(B&);
+void use(VB&);
+
+void nowarnstack() {
+ B b; use(b);
+ D d; use(d);
+ F f; use(f);
+ VB vb; use(vb);
+ VD vd; use(vd);
+ VF vf; use(vf);
+}
+
+void nowarnnonpoly() {
+ {
+ NP* np = new NP();
+ delete np;
+ }
+ {
+ NP* np = new NP[4];
+ delete[] np;
+ }
+}
+
+void nowarnarray() {
+ {
+ B* b = new B[4];
+ delete[] b;
+ }
+ {
+ D* d = new D[4];
+ delete[] d;
+ }
+ {
+ VB* vb = new VB[4];
+ delete[] vb;
+ }
+ {
+ VD* vd = new VD[4];
+ delete[] vd;
+ }
+}
+
+template <typename T>
+void nowarntemplate() {
+ {
+ T* t = new T();
+ delete t;
+ }
+ {
+ T* t = new T[4];
+ delete[] t;
+ }
+}
+
+void nowarn0() {
+ {
+ F* f = new F();
+ delete f;
+ }
+ {
+ VB* vb = new VB();
+ delete vb;
+ }
+ {
+ VB* vb = new VD();
+ delete vb;
+ }
+ {
+ VD* vd = new VD();
+ delete vd;
+ }
+ {
+ VF* vf = new VF();
+ delete vf;
+ }
+}
+
+void warn0() {
+ {
+ B* b = new B();
+ delete b; // expected-warning {{delete called on 'dnvd::B' that has virtual functions but non-virtual destructor}}
+ }
+ {
+ B* b = new D();
+ delete b; // expected-warning {{delete called on 'dnvd::B' that has virtual functions but non-virtual destructor}}
+ }
+ {
+ D* d = new D();
+ delete d; // expected-warning {{delete called on 'dnvd::D' that has virtual functions but non-virtual destructor}}
+ }
+}
+
+void nowarn1() {
+ {
+ simple_ptr<F> f(new F());
+ use(*f);
+ }
+ {
+ simple_ptr<VB> vb(new VB());
+ use(*vb);
+ }
+ {
+ simple_ptr<VB> vb(new VD());
+ use(*vb);
+ }
+ {
+ simple_ptr<VD> vd(new VD());
+ use(*vd);
+ }
+ {
+ simple_ptr<VF> vf(new VF());
+ use(*vf);
+ }
+}
+
+void warn1() {
+ {
+ simple_ptr<B> b(new B()); // expected-note {{in instantiation of member function 'dnvd::simple_ptr<dnvd::B>::~simple_ptr' requested here}}
+ use(*b);
+ }
+ {
+ simple_ptr2<B> b(new D()); // expected-note {{in instantiation of member function 'dnvd::simple_ptr2<dnvd::B>::~simple_ptr2' requested here}}
+ use(*b);
+ }
+ {
+ simple_ptr<D> d(new D()); // expected-note {{in instantiation of member function 'dnvd::simple_ptr<dnvd::D>::~simple_ptr' requested here}}
+ use(*d);
+ }
+}
+}
+
+namespace PR9238 {
+ class B { public: ~B(); };
+ class C : virtual B { public: ~C() { } };
+}
+
+namespace PR7900 {
+ struct A { // expected-note 2{{type 'PR7900::A' is declared here}}
+ };
+ struct B : public A {
+ };
+ void foo() {
+ B b;
+ b.~B();
+ b.~A(); // expected-error{{destructor type 'PR7900::A' in object destruction expression does not match the type 'PR7900::B' of the object being destroyed}}
+ (&b)->~A(); // expected-error{{destructor type 'PR7900::A' in object destruction expression does not match the type 'PR7900::B' of the object being destroyed}}
+ }
+}
diff --git a/clang/test/SemaCXX/direct-initializer.cpp b/clang/test/SemaCXX/direct-initializer.cpp
new file mode 100644
index 0000000..a7899c7
--- /dev/null
+++ b/clang/test/SemaCXX/direct-initializer.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int x(1);
+int (x2)(1);
+
+void f() {
+ int x(1);
+ int (x2)(1);
+ for (int x(1);;) {}
+}
+
+class Y {
+public: explicit Y(float);
+};
+
+class X { // expected-note{{candidate constructor (the implicit copy constructor)}}
+public:
+ explicit X(int); // expected-note{{candidate constructor}}
+ X(float, float, float); // expected-note{{candidate constructor}}
+ X(float, Y); // expected-note{{candidate constructor}}
+};
+
+class Z { // expected-note{{candidate constructor (the implicit copy constructor)}}
+public:
+ Z(int); // expected-note{{candidate constructor}}
+};
+
+void g() {
+ X x1(5);
+ X x2(1.0, 3, 4.2);
+ X x3(1.0, 1.0); // expected-error{{no matching constructor for initialization of 'X'}}
+ Y y(1.0);
+ X x4(3.14, y);
+
+ Z z; // expected-error{{no matching constructor for initialization of 'Z'}}
+}
+
+struct Base {
+ operator int*() const;
+};
+
+struct Derived : Base {
+ operator int*(); // expected-note {{candidate function}}
+};
+
+void foo(const Derived cd, Derived d) {
+ int *pi = cd; // expected-error {{no viable conversion from 'const Derived' to 'int *'}}
+ int *ppi = d;
+
+}
diff --git a/clang/test/SemaCXX/discrim-union.cpp b/clang/test/SemaCXX/discrim-union.cpp
new file mode 100644
index 0000000..15c9a22
--- /dev/null
+++ b/clang/test/SemaCXX/discrim-union.cpp
@@ -0,0 +1,118 @@
+// RUN: %clang_cc1 -std=c++11 %s -fsyntax-only -fcxx-exceptions
+
+template<typename T> struct remove_reference { typedef T type; };
+template<typename T> struct remove_reference<T&> { typedef T type; };
+template<typename T> struct remove_reference<T&&> { typedef T type; };
+
+template<typename T> constexpr T &&forward(typename remove_reference<T>::type &t) noexcept { return static_cast<T&&>(t); }
+template<typename T> constexpr T &&forward(typename remove_reference<T>::type &&t) noexcept { return static_cast<T&&>(t); }
+template<typename T> constexpr typename remove_reference<T>::type &&move(T &&t) noexcept { return static_cast<typename remove_reference<T>::type&&>(t); }
+
+template<typename T> T declval() noexcept;
+
+namespace detail {
+ template<unsigned N> struct select {}; // : integral_constant<unsigned, N> {};
+ template<typename T> struct type {};
+
+ template<typename...T> union either_impl;
+
+ template<> union either_impl<> {
+ void get(...);
+ void destroy(...) { throw "logic_error"; }
+ };
+
+ template<typename T, typename...Ts> union either_impl<T, Ts...> {
+ private:
+ T val;
+ either_impl<Ts...> rest;
+ typedef either_impl<Ts...> rest_t;
+
+ public:
+ constexpr either_impl(select<0>, T &&t) : val(move(t)) {}
+
+ template<unsigned N, typename U>
+ constexpr either_impl(select<N>, U &&u) : rest(select<N-1>(), move(u)) {}
+
+ constexpr static unsigned index(type<T>) { return 0; }
+ template<typename U>
+ constexpr static unsigned index(type<U> t) {
+ return decltype(rest)::index(t) + 1;
+ }
+
+ void destroy(unsigned elem) {
+ if (elem)
+ rest.destroy(elem - 1);
+ else
+ val.~T();
+ }
+
+ constexpr const T &get(select<0>) { return val; }
+ template<unsigned N> constexpr const decltype(static_cast<const rest_t&>(rest).get(select<N-1>{})) get(select<N>) {
+ return rest.get(select<N-1>{});
+ }
+ };
+}
+
+template<typename T>
+struct a {
+ T value;
+ template<typename...U>
+ constexpr a(U &&...u) : value{forward<U>(u)...} {}
+};
+template<typename T> using an = a<T>;
+
+template<typename T, typename U> T throw_(const U &u) { throw u; }
+
+template<typename...T>
+class either {
+ unsigned elem;
+ detail::either_impl<T...> impl;
+ typedef decltype(impl) impl_t;
+
+public:
+ template<typename U>
+ constexpr either(a<U> &&t) :
+ elem(impl_t::index(detail::type<U>())),
+ impl(detail::select<impl_t::index(detail::type<U>())>(), move(t.value)) {}
+
+ // Destruction disabled to allow use in a constant expression.
+ // FIXME: declare a destructor iff any element has a nontrivial destructor
+ //~either() { impl.destroy(elem); }
+
+ constexpr unsigned index() noexcept { return elem; }
+
+ template<unsigned N> using const_get_result =
+ decltype(static_cast<const impl_t&>(impl).get(detail::select<N>{}));
+
+ template<unsigned N>
+ constexpr const_get_result<N> get() {
+ // Can't just use throw here, since that makes the conditional a prvalue,
+ // which means we return a reference to a temporary.
+ return (elem != N ? throw_<const_get_result<N>>("bad_either_get")
+ : impl.get(detail::select<N>{}));
+ }
+
+ template<typename U>
+ constexpr const U &get() {
+ return get<impl_t::index(detail::type<U>())>();
+ }
+};
+
+typedef either<int, char, double> icd;
+constexpr icd icd1 = an<int>(4);
+constexpr icd icd2 = a<char>('x');
+constexpr icd icd3 = a<double>(6.5);
+
+static_assert(icd1.get<int>() == 4, "");
+static_assert(icd2.get<char>() == 'x', "");
+static_assert(icd3.get<double>() == 6.5, "");
+
+struct non_triv {
+ constexpr non_triv() : n(5) {}
+ int n;
+};
+constexpr either<const icd*, non_triv> icd4 = a<const icd*>(&icd2);
+constexpr either<const icd*, non_triv> icd5 = a<non_triv>();
+
+static_assert(icd4.get<const icd*>()->get<char>() == 'x', "");
+static_assert(icd5.get<non_triv>().n == 5, "");
diff --git a/clang/test/SemaCXX/do-while-scope.cpp b/clang/test/SemaCXX/do-while-scope.cpp
new file mode 100644
index 0000000..2602ae1
--- /dev/null
+++ b/clang/test/SemaCXX/do-while-scope.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void test() {
+ int x;
+ do
+ int x;
+ while (1);
+}
diff --git a/clang/test/SemaCXX/dr1301.cpp b/clang/test/SemaCXX/dr1301.cpp
new file mode 100644
index 0000000..ec0db74
--- /dev/null
+++ b/clang/test/SemaCXX/dr1301.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+struct A { // expected-note 2{{candidate}}
+ A(int); // expected-note {{candidate}}
+ int n;
+};
+int a = A().n; // expected-error {{no matching constructor}}
+
+struct B {
+ B() = delete; // expected-note 3{{here}}
+ int n;
+};
+int b = B().n; // expected-error {{call to deleted}}
+
+struct C {
+ B b; // expected-note {{deleted default constructor}}
+};
+int c = C().b.n; // expected-error {{call to implicitly-deleted default}}
+
+struct D {
+ D() = default; // expected-note {{here}}
+ B b; // expected-note {{'b' has a deleted default constructor}}
+};
+int d = D().b.n; // expected-error {{call to implicitly-deleted default}}
+
+struct E {
+ E() = default;
+ int n;
+};
+int e = E().n; // ok
+
+struct F {
+ F();
+ int n;
+};
+int f = F().n; // ok
+
+union G {
+ F f; // expected-note {{non-trivial default constructor}}
+};
+int g = G().f.n; // expected-error {{call to implicitly-deleted default}}
+
+struct H {
+ int n;
+private:
+ H(); // expected-note {{here}}
+};
+int h = H().n; // expected-error {{private constructor}}
+
+struct I {
+ H h; // expected-note {{inaccessible default constructor}}
+};
+int i = I().h.n; // expected-error {{call to implicitly-deleted default}}
+
+struct J {
+ J();
+ virtual int f();
+ int n;
+};
+int j1 = J().n; // ok
+int j2 = J().f(); // ok
+
+union K {
+ J j; // expected-note 2{{non-trivial default constructor}}
+ int m;
+};
+int k1 = K().j.n; // expected-error {{call to implicitly-deleted default}}
+int k2 = K().j.f(); // expected-error {{call to implicitly-deleted default}}
diff --git a/clang/test/SemaCXX/dynamic-cast.cpp b/clang/test/SemaCXX/dynamic-cast.cpp
new file mode 100644
index 0000000..b73e8c5
--- /dev/null
+++ b/clang/test/SemaCXX/dynamic-cast.cpp
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {};
+struct B : A {};
+struct C : B {};
+
+struct D : private A {};
+struct E : A {};
+struct F : B, E {};
+
+struct Incomplete; // expected-note 2 {{forward declaration of 'Incomplete'}}
+
+struct Poly
+{
+ virtual void f();
+};
+
+struct PolyDerived : Poly
+{
+};
+
+void basic_bad()
+{
+ // ptr -> nonptr
+ (void)dynamic_cast<A>((A*)0); // expected-error {{'A' is not a reference or pointer}}
+ // nonptr -> ptr
+ (void)dynamic_cast<A*>(0); // expected-error {{'int' is not a pointer}}
+ // ptr -> noncls
+ (void)dynamic_cast<int*>((A*)0); // expected-error {{'int' is not a class}}
+ // noncls -> ptr
+ (void)dynamic_cast<A*>((int*)0); // expected-error {{'int' is not a class}}
+ // ref -> noncls
+ (void)dynamic_cast<int&>(*((A*)0)); // expected-error {{'int' is not a class}}
+ // noncls -> ref
+ (void)dynamic_cast<A&>(*((int*)0)); // expected-error {{'int' is not a class}}
+ // ptr -> incomplete
+ (void)dynamic_cast<Incomplete*>((A*)0); // expected-error {{'Incomplete' is an incomplete type}}
+ // incomplete -> ptr
+ (void)dynamic_cast<A*>((Incomplete*)0); // expected-error {{'Incomplete' is an incomplete type}}
+}
+
+void same()
+{
+ (void)dynamic_cast<A*>((A*)0);
+ (void)dynamic_cast<A&>(*((A*)0));
+}
+
+void up()
+{
+ (void)dynamic_cast<A*>((B*)0);
+ (void)dynamic_cast<A&>(*((B*)0));
+ (void)dynamic_cast<A*>((C*)0);
+ (void)dynamic_cast<A&>(*((C*)0));
+
+ // Inaccessible
+ //(void)dynamic_cast<A*>((D*)0);
+ //(void)dynamic_cast<A&>(*((D*)0));
+
+ // Ambiguous
+ (void)dynamic_cast<A*>((F*)0); // expected-error {{ambiguous conversion from derived class 'F' to base class 'A':\n struct F -> struct B -> struct A\n struct F -> struct E -> struct A}}
+ (void)dynamic_cast<A&>(*((F*)0)); // expected-error {{ambiguous conversion from derived class 'F' to base class 'A':\n struct F -> struct B -> struct A\n struct F -> struct E -> struct A}}
+}
+
+void poly()
+{
+ (void)dynamic_cast<A*>((Poly*)0);
+ (void)dynamic_cast<A&>(*((Poly*)0));
+ (void)dynamic_cast<A*>((PolyDerived*)0);
+ (void)dynamic_cast<A&>(*((PolyDerived*)0));
+
+ // Not polymorphic source
+ (void)dynamic_cast<Poly*>((A*)0); // expected-error {{'A' is not polymorphic}}
+ (void)dynamic_cast<PolyDerived&>(*((A*)0)); // expected-error {{'A' is not polymorphic}}
+}
diff --git a/clang/test/SemaCXX/elaborated-type-specifier.cpp b/clang/test/SemaCXX/elaborated-type-specifier.cpp
new file mode 100644
index 0000000..760079f
--- /dev/null
+++ b/clang/test/SemaCXX/elaborated-type-specifier.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Test the use of elaborated-type-specifiers to inject the names of
+// structs (or classes or unions) into an outer scope as described in
+// C++ [basic.scope.pdecl]p5.
+typedef struct S1 {
+ union {
+ struct S2 *x;
+ struct S3 *y;
+ };
+} S1;
+
+bool test_elab(S1 *s1, struct S2 *s2, struct S3 *s3) {
+ if (s1->x == s2) return true;
+ if (s1->y == s3) return true;
+ return false;
+}
+
+namespace NS {
+ class X {
+ public:
+ void test_elab2(struct S4 *s4);
+ };
+
+ void X::test_elab2(S4 *s4) { } // expected-note{{passing argument to parameter 's4' here}}
+}
+
+void test_X_elab(NS::X x) {
+ struct S4 *s4 = 0;
+ x.test_elab2(s4); // expected-error{{cannot initialize a parameter of type 'NS::S4 *' with an lvalue of type 'struct S4 *'}}
+}
+
+namespace NS {
+ S4 *get_S4();
+}
+
+void test_S5_scope() {
+ S4 *s4; // expected-error{{use of undeclared identifier 'S4'}} \
+ // expected-error{{use of undeclared identifier 's4'}}
+}
+
+int test_funcparam_scope(struct S5 * s5) {
+ struct S5 { int y; } *s5_2 = 0;
+ if (s5 == s5_2) return 1; // expected-error {{comparison of distinct pointer types ('struct S5 *' and 'struct S5 *')}}
+ return 0;
+}
+
+
diff --git a/clang/test/SemaCXX/empty-class-layout.cpp b/clang/test/SemaCXX/empty-class-layout.cpp
new file mode 100644
index 0000000..c68f2bb
--- /dev/null
+++ b/clang/test/SemaCXX/empty-class-layout.cpp
@@ -0,0 +1,157 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify
+
+#define SA(n, p) int a##n[(p) ? 1 : -1]
+
+namespace Test0 {
+
+struct A { int a; };
+SA(0, sizeof(A) == 4);
+
+struct B { };
+SA(1, sizeof(B) == 1);
+
+struct C : A, B { };
+SA(2, sizeof(C) == 4);
+
+struct D { };
+struct E : D { };
+struct F : E { };
+
+struct G : E, F { };
+SA(3, sizeof(G) == 2);
+
+struct Empty { Empty(); };
+
+struct I : Empty {
+ Empty e;
+};
+SA(4, sizeof(I) == 2);
+
+struct J : Empty {
+ Empty e[2];
+};
+SA(5, sizeof(J) == 3);
+
+template<int N> struct Derived : Empty, Derived<N - 1> {
+};
+template<> struct Derived<0> : Empty { };
+
+struct S1 : virtual Derived<10> {
+ Empty e;
+};
+SA(6, sizeof(S1) == 24);
+
+struct S2 : virtual Derived<10> {
+ Empty e[2];
+};
+SA(7, sizeof(S2) == 24);
+
+struct S3 {
+ Empty e;
+};
+
+struct S4 : Empty, S3 {
+};
+SA(8, sizeof(S4) == 2);
+
+struct S5 : S3, Empty {};
+SA(9, sizeof(S5) == 2);
+
+struct S6 : S5 { };
+SA(10, sizeof(S6) == 2);
+
+struct S7 : Empty {
+ void *v;
+};
+SA(11, sizeof(S7) == 8);
+
+struct S8 : Empty, A {
+};
+SA(12, sizeof(S8) == 4);
+
+}
+
+namespace Test1 {
+
+// Test that we don't try to place both A subobjects at offset 0.
+struct A { };
+class B { virtual void f(); };
+class C : A, virtual B { };
+struct D : virtual C { };
+struct E : virtual A { };
+class F : D, E { };
+
+SA(0, sizeof(F) == 24);
+
+}
+
+namespace Test2 {
+
+// Test that B::a isn't laid out at offset 0.
+struct Empty { };
+struct A : Empty { };
+struct B : Empty {
+ A a;
+};
+
+SA(0, sizeof(B) == 2);
+
+}
+
+namespace Test3 {
+
+// Test that B::a isn't laid out at offset 0.
+struct Empty { };
+struct A { Empty e; };
+struct B : Empty { A a; };
+SA(0, sizeof(B) == 2);
+
+}
+
+namespace Test4 {
+
+// Test that C::Empty isn't laid out at offset 0.
+struct Empty { };
+struct A : Empty { };
+struct B { A a; };
+struct C : B, Empty { };
+SA(0, sizeof(C) == 2);
+
+}
+
+namespace Test5 {
+
+// Test that B::Empty isn't laid out at offset 0.
+struct Empty { };
+struct Field : virtual Empty { };
+struct A {
+ Field f;
+};
+struct B : A, Empty { };
+SA(0, sizeof(B) == 16);
+
+}
+
+namespace Test6 {
+
+// Test that B::A isn't laid out at offset 0.
+struct Empty { };
+struct Field : virtual Empty { };
+struct A {
+ Field f;
+};
+struct B : Empty, A { };
+SA(0, sizeof(B) == 16);
+
+}
+
+namespace Test7 {
+ // Make sure we reserve enough space for both bases; PR11745.
+ struct Empty { };
+ struct Base1 : Empty { };
+ struct Base2 : Empty { };
+ struct Test : Base1, Base2 {
+ char c;
+ };
+ SA(0, sizeof(Test) == 2);
+}
diff --git a/clang/test/SemaCXX/enum-bitfield.cpp b/clang/test/SemaCXX/enum-bitfield.cpp
new file mode 100644
index 0000000..63445ca
--- /dev/null
+++ b/clang/test/SemaCXX/enum-bitfield.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify -triple x86_64-apple-darwin %s
+
+enum E {};
+
+struct Z {};
+typedef int Integer;
+
+struct X {
+ enum E : 1;
+ enum E : Z; // expected-error{{invalid underlying type}}
+ enum E2 : int;
+ enum E3 : Integer;
+};
+
+struct Y {
+ enum E : int(2);
+ enum E : Z(); // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'Z'}}
+};
diff --git a/clang/test/SemaCXX/enum-scoped.cpp b/clang/test/SemaCXX/enum-scoped.cpp
new file mode 100644
index 0000000..ebe9245
--- /dev/null
+++ b/clang/test/SemaCXX/enum-scoped.cpp
@@ -0,0 +1,247 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify -triple x86_64-apple-darwin %s
+
+enum class E1 {
+ Val1 = 1L
+};
+
+enum struct E2 {
+ Val1 = '\0'
+};
+
+E1 v1 = Val1; // expected-error{{undeclared identifier}}
+E1 v2 = E1::Val1;
+
+static_assert(sizeof(E1) == sizeof(int), "bad size");
+static_assert(sizeof(E1::Val1) == sizeof(int), "bad size");
+static_assert(sizeof(E2) == sizeof(int), "bad size");
+static_assert(sizeof(E2::Val1) == sizeof(int), "bad size");
+
+E1 v3 = E2::Val1; // expected-error{{cannot initialize a variable}}
+int x1 = E1::Val1; // expected-error{{cannot initialize a variable}}
+
+enum E3 : char {
+ Val2 = 1
+};
+
+E3 v4 = Val2;
+E1 v5 = Val2; // expected-error{{cannot initialize a variable}}
+
+static_assert(sizeof(E3) == 1, "bad size");
+
+int x2 = Val2;
+
+int a1[Val2];
+int a2[E1::Val1]; // expected-error{{size of array has non-integer type}}
+
+int* p1 = new int[Val2];
+int* p2 = new int[E1::Val1]; // expected-error{{array size expression must have integral or unscoped enumeration type, not 'E1'}}
+
+enum class E4 {
+ e1 = -2147483648, // ok
+ e2 = 2147483647, // ok
+ e3 = 2147483648 // expected-error{{enumerator value evaluates to 2147483648, which cannot be narrowed to type 'int'}}
+};
+
+enum class E5 {
+ e1 = 2147483647, // ok
+ e2 // expected-error{{2147483648 is not representable in the underlying}}
+};
+
+enum class E6 : bool {
+ e1 = false, e2 = true,
+ e3 // expected-error{{2 is not representable in the underlying}}
+};
+
+enum E7 : bool {
+ e1 = false, e2 = true,
+ e3 // expected-error{{2 is not representable in the underlying}}
+};
+
+template <class T>
+struct X {
+ enum E : T {
+ e1, e2,
+ e3 // expected-error{{2 is not representable in the underlying}}
+ };
+};
+
+X<bool> X2; // expected-note{{in instantiation of template}}
+
+enum Incomplete1; // expected-error{{C++ forbids forward references}}
+
+enum Complete1 : int;
+Complete1 complete1;
+
+enum class Complete2;
+Complete2 complete2;
+
+// All the redeclarations below are done twice on purpose. Tests that the type
+// of the declaration isn't changed.
+
+enum class Redeclare2; // expected-note{{previous use is here}} expected-note{{previous use is here}}
+enum Redeclare2; // expected-error{{previously declared as scoped}}
+enum Redeclare2; // expected-error{{previously declared as scoped}}
+
+enum Redeclare3 : int; // expected-note{{previous use is here}} expected-note{{previous use is here}}
+enum Redeclare3; // expected-error{{previously declared with fixed underlying type}}
+enum Redeclare3; // expected-error{{previously declared with fixed underlying type}}
+
+enum class Redeclare5;
+enum class Redeclare5 : int; // ok
+
+enum Redeclare6 : int; // expected-note{{previous use is here}} expected-note{{previous use is here}}
+enum Redeclare6 : short; // expected-error{{redeclared with different underlying type}}
+enum Redeclare6 : short; // expected-error{{redeclared with different underlying type}}
+
+enum class Redeclare7; // expected-note{{previous use is here}} expected-note{{previous use is here}}
+enum class Redeclare7 : short; // expected-error{{redeclared with different underlying type}}
+enum class Redeclare7 : short; // expected-error{{redeclared with different underlying type}}
+
+enum : long {
+ long_enum_val = 10000
+};
+
+enum : long x; // expected-error{{unnamed enumeration must be a definition}} \
+// expected-warning{{declaration does not declare anything}}
+
+void PR9333() {
+ enum class scoped_enum { yes, no, maybe };
+ scoped_enum e = scoped_enum::yes;
+ if (e == scoped_enum::no) { }
+}
+
+// <rdar://problem/9366066>
+namespace rdar9366066 {
+ enum class X : unsigned { value };
+
+ void f(X x) {
+ x % X::value; // expected-error{{invalid operands to binary expression ('rdar9366066::X' and 'rdar9366066::X')}}
+ x % 8; // expected-error{{invalid operands to binary expression ('rdar9366066::X' and 'int')}}
+ }
+}
+
+// Part 1 of PR10264
+namespace test5 {
+ namespace ns {
+ typedef unsigned Atype;
+ enum A : Atype;
+ }
+ enum ns::A : ns::Atype {
+ x, y, z
+ };
+}
+
+// Part 2 of PR10264
+namespace test6 {
+ enum A : unsigned;
+ struct A::a; // expected-error {{incomplete type 'test6::A' named in nested name specifier}}
+ enum A::b; // expected-error {{incomplete type 'test6::A' named in nested name specifier}}
+ int A::c; // expected-error {{incomplete type 'test6::A' named in nested name specifier}}
+ void A::d(); // expected-error {{incomplete type 'test6::A' named in nested name specifier}}
+ void test() {
+ (void) A::e; // expected-error {{incomplete type 'test6::A' named in nested name specifier}}
+ }
+}
+
+namespace PR11484 {
+ const int val = 104;
+ enum class test1 { owner_dead = val, };
+}
+
+namespace N2764 {
+ enum class E { a, b };
+ enum E x1 = E::a; // ok
+ enum class E x2 = E::a; // expected-error {{reference to scoped enumeration must use 'enum' not 'enum class'}}
+
+ enum F { a, b };
+ enum F y1 = a; // ok
+ enum class F y2 = a; // expected-error {{reference to enumeration must use 'enum' not 'enum class'}}
+
+ struct S {
+ friend enum class E; // expected-error {{reference to scoped enumeration must use 'enum' not 'enum class'}}
+ friend enum class F; // expected-error {{reference to enumeration must use 'enum' not 'enum class'}}
+
+ friend enum G {}; // expected-error {{forward reference}} expected-error {{cannot define a type in a friend declaration}}
+ friend enum class H {}; // expected-error {{cannot define a type in a friend declaration}}
+
+ enum A : int;
+ A a;
+ } s;
+
+ enum S::A : int {};
+
+ enum class B;
+}
+
+enum class N2764::B {};
+
+namespace PR12106 {
+ template<typename E> struct Enum {
+ Enum() : m_e(E::Last) {}
+ E m_e;
+ };
+
+ enum eCOLORS { Last };
+ Enum<eCOLORS> e;
+}
+
+namespace test7 {
+ enum class E { e = (struct S*)0 == (struct S*)0 };
+ S *p;
+}
+
+namespace test8 {
+ template<typename T> struct S {
+ enum A : int; // expected-note {{here}}
+ enum class B; // expected-note {{here}}
+ enum class C : int; // expected-note {{here}}
+ enum class D : int; // expected-note {{here}}
+ };
+ template<typename T> enum S<T>::A { a }; // expected-error {{previously declared with fixed underlying type}}
+ template<typename T> enum class S<T>::B : char { b }; // expected-error {{redeclared with different underlying}}
+ template<typename T> enum S<T>::C : int { c }; // expected-error {{previously declared as scoped}}
+ template<typename T> enum class S<T>::D : char { d }; // expected-error {{redeclared with different underlying}}
+}
+
+namespace test9 {
+ template<typename T> struct S {
+ enum class ET : T; // expected-note 2{{here}}
+ enum class Eint : int; // expected-note 2{{here}}
+ };
+ template<> enum class S<int>::ET : int {};
+ template<> enum class S<char>::ET : short {}; // expected-error {{different underlying type}}
+ template<> enum class S<int>::Eint : short {}; // expected-error {{different underlying type}}
+ template<> enum class S<char>::Eint : int {};
+
+ template<typename T> enum class S<T>::ET : int {}; // expected-error {{different underlying type 'int' (was 'short')}}
+ template<typename T> enum class S<T>::Eint : T {}; // expected-error {{different underlying type 'short' (was 'int')}}
+
+ // The implicit instantiation of S<short> causes the implicit instantiation of
+ // all declarations of member enumerations, so is ill-formed, even though we
+ // never instantiate the definitions of S<short>::ET nor S<short>::Eint.
+ S<short> s; // expected-note {{in instantiation of}}
+}
+
+namespace test10 {
+ template<typename T> int f() {
+ enum E : int;
+ enum E : T; // expected-note {{here}}
+ E x;
+ enum E : int { e }; // expected-error {{different underlying}}
+ x = e;
+ return x;
+ }
+ int k = f<int>();
+ int l = f<short>(); // expected-note {{here}}
+
+ template<typename T> int g() {
+ enum class E : int;
+ enum class E : T; // expected-note {{here}}
+ E x;
+ enum class E : int { e }; // expected-error {{different underlying}}
+ x = E::e;
+ return (int)x;
+ }
+ int m = g<int>();
+ int n = g<short>(); // expected-note {{here}}
+}
diff --git a/clang/test/SemaCXX/enum-unscoped-nonexistent.cpp b/clang/test/SemaCXX/enum-unscoped-nonexistent.cpp
new file mode 100644
index 0000000..d49800c
--- /dev/null
+++ b/clang/test/SemaCXX/enum-unscoped-nonexistent.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+struct Base {
+ static const int a = 1;
+};
+template<typename T> struct S : Base {
+ enum E : int;
+ constexpr int f();
+ constexpr int g(); // expected-note {{declared here}}
+ void h();
+};
+template<> enum S<char>::E : int {}; // expected-note {{enum 'S<char>::E' was explicitly specialized here}}
+template<> enum S<short>::E : int { b = 2 };
+template<> enum S<int>::E : int { a = 4 };
+template<typename T> enum S<T>::E : int { b = 8 };
+
+// The unqualified-id here names a member of the non-dependent base class Base
+// and not the injected enumerator name 'a' from the specialization.
+template<typename T> constexpr int S<T>::f() { return a; }
+static_assert(S<char>().f() == 1, "");
+static_assert(S<int>().f() == 1, "");
+
+// The unqualified-id here names a member of the current instantiation, which
+// bizarrely might not exist in some instantiations.
+template<typename T> constexpr int S<T>::g() { return b; } // expected-error {{enumerator 'b' does not exist in instantiation of 'S<char>'}}
+static_assert(S<char>().g() == 1, ""); // expected-note {{here}} expected-error {{not an integral constant expression}} expected-note {{undefined}}
+static_assert(S<short>().g() == 2, "");
+static_assert(S<long>().g() == 8, "");
+
+// 'b' is type-dependent, so these assertions should not fire before 'h' is
+// instantiated.
+template<typename T> void S<T>::h() {
+ char c[S<T>::b];
+ static_assert(b != 8, "");
+ static_assert(sizeof(c) != 8, "");
+}
+void f() {
+ S<short>().h(); // ok, b == 2
+}
diff --git a/clang/test/SemaCXX/enum.cpp b/clang/test/SemaCXX/enum.cpp
new file mode 100644
index 0000000..370e1c3
--- /dev/null
+++ b/clang/test/SemaCXX/enum.cpp
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++98 -verify -triple x86_64-apple-darwin %s
+enum E { // expected-note{{previous definition is here}}
+ Val1,
+ Val2
+};
+
+enum E; // expected-warning{{redeclaration of already-defined enum 'E' is a GNU extension}}
+
+int& enumerator_type(int);
+float& enumerator_type(E);
+
+void f() {
+ E e = Val1;
+ float& fr = enumerator_type(Val2);
+}
+
+// <rdar://problem/6502934>
+typedef enum Foo {
+ A = 0,
+ B = 1
+} Foo;
+
+void bar() {
+ Foo myvar = A;
+ myvar = B;
+}
+
+/// PR3688
+struct s1 {
+ enum e1 (*bar)(void); // expected-error{{ISO C++ forbids forward references to 'enum' types}}
+};
+
+enum e1 { YES, NO };
+
+static enum e1 badfunc(struct s1 *q) {
+ return q->bar();
+}
+
+enum e2; // expected-error{{ISO C++ forbids forward references to 'enum' types}}
+
+namespace test1 {
+ template <class A, class B> struct is_same { static const int value = -1; };
+ template <class A> struct is_same<A,A> { static const int value = 1; };
+
+ enum enum0 { v0 };
+ int test0[is_same<__typeof(+v0), int>::value];
+
+ enum enum1 { v1 = __INT_MAX__ };
+ int test1[is_same<__typeof(+v1), int>::value];
+
+ enum enum2 { v2 = __INT_MAX__ * 2U };
+ int test2[is_same<__typeof(+v2), unsigned int>::value];
+
+ enum enum3 { v3 = __LONG_MAX__ };
+ int test3[is_same<__typeof(+v3), long>::value];
+
+ enum enum4 { v4 = __LONG_MAX__ * 2UL };
+ int test4[is_same<__typeof(+v4), unsigned long>::value];
+}
+
+// PR6061
+namespace PR6061 {
+ struct A { enum { id }; };
+ struct B { enum { id }; };
+
+ struct C : public A, public B
+ {
+ enum { id };
+ };
+}
+
+namespace Conditional {
+ enum a { A }; a x(const enum a x) { return 1?x:A; }
+}
+
+namespace PR7051 {
+ enum E { e0 };
+ void f() {
+ E e;
+ e = 1; // expected-error{{assigning to 'PR7051::E' from incompatible type 'int'}}
+ e |= 1; // expected-error{{assigning to 'PR7051::E' from incompatible type 'int'}}
+ }
+}
+
+// PR7466
+enum { }; // expected-warning{{declaration does not declare anything}}
+typedef enum { }; // expected-warning{{typedef requires a name}}
+
+// PR7921
+enum PR7921E {
+ PR7921V = (PR7921E)(123) // expected-error {{expression is not an integral constant expression}}
+};
+
+void PR8089() {
+ enum E; // expected-error{{ISO C++ forbids forward references to 'enum' types}}
+ int a = (E)3; // expected-error{{cannot initialize a variable of type 'int' with an rvalue of type 'E'}}
+}
diff --git a/clang/test/SemaCXX/exception-spec-no-exceptions.cpp b/clang/test/SemaCXX/exception-spec-no-exceptions.cpp
new file mode 100644
index 0000000..2e18070
--- /dev/null
+++ b/clang/test/SemaCXX/exception-spec-no-exceptions.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fobjc-exceptions %s
+
+// Note that we're specifically excluding -fcxx-exceptions in the command line above.
+
+// That this should work even with -fobjc-exceptions is PR9358
+
+// PR7243: redeclarations
+namespace test0 {
+ void foo() throw(int);
+ void foo() throw();
+}
+
+// Overrides.
+namespace test1 {
+ struct A {
+ virtual void foo() throw();
+ };
+
+ struct B : A {
+ virtual void foo() throw(int);
+ };
+}
+
+// Calls from less permissive contexts. We don't actually do this
+// check, but if we did it should also be disabled under
+// -fno-exceptions.
+namespace test2 {
+ void foo() throw(int);
+ void bar() throw() {
+ foo();
+ }
+}
+
diff --git a/clang/test/SemaCXX/exceptions.cpp b/clang/test/SemaCXX/exceptions.cpp
new file mode 100644
index 0000000..486d88e
--- /dev/null
+++ b/clang/test/SemaCXX/exceptions.cpp
@@ -0,0 +1,122 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
+
+struct A; // expected-note 4 {{forward declaration of 'A'}}
+
+struct Abstract { virtual void f() = 0; }; // expected-note {{unimplemented pure virtual method 'f'}}
+
+void trys() {
+ try {
+ } catch(int i) { // expected-note {{previous definition}}
+ int j = i;
+ int i; // expected-error {{redefinition of 'i'}}
+ } catch(float i) {
+ } catch(void v) { // expected-error {{cannot catch incomplete type 'void'}}
+ } catch(A a) { // expected-error {{cannot catch incomplete type 'A'}}
+ } catch(A *a) { // expected-error {{cannot catch pointer to incomplete type 'A'}}
+ } catch(A &a) { // expected-error {{cannot catch reference to incomplete type 'A'}}
+ } catch(Abstract) { // expected-error {{variable type 'Abstract' is an abstract class}}
+ } catch(...) {
+ int j = i; // expected-error {{use of undeclared identifier 'i'}}
+ }
+
+ try {
+ } catch(...) { // expected-error {{catch-all handler must come last}}
+ } catch(int) {
+ }
+}
+
+void throws() {
+ throw;
+ throw 0;
+ throw throw; // expected-error {{cannot throw object of incomplete type 'void'}}
+ throw (A*)0; // expected-error {{cannot throw pointer to object of incomplete type 'A'}}
+}
+
+void jumps() {
+l1:
+ goto l5;
+ goto l4; // expected-error {{goto into protected scope}}
+ goto l3; // expected-error {{goto into protected scope}}
+ goto l2; // expected-error {{goto into protected scope}}
+ goto l1;
+ try { // expected-note 4 {{jump bypasses initialization of try block}}
+ l2:
+ goto l5;
+ goto l4; // expected-error {{goto into protected scope}}
+ goto l3; // expected-error {{goto into protected scope}}
+ goto l2;
+ goto l1;
+ } catch(int) { // expected-note 4 {{jump bypasses initialization of catch block}}
+ l3:
+ goto l5;
+ goto l4; // expected-error {{goto into protected scope}}
+ goto l3;
+ goto l2; // expected-error {{goto into protected scope}}
+ goto l1;
+ } catch(...) { // expected-note 4 {{jump bypasses initialization of catch block}}
+ l4:
+ goto l5;
+ goto l4;
+ goto l3; // expected-error {{goto into protected scope}}
+ goto l2; // expected-error {{goto into protected scope}}
+ goto l1;
+ }
+l5:
+ goto l5;
+ goto l4; // expected-error {{goto into protected scope}}
+ goto l3; // expected-error {{goto into protected scope}}
+ goto l2; // expected-error {{goto into protected scope}}
+ goto l1;
+}
+
+struct BadReturn {
+ BadReturn() try {
+ } catch(...) {
+ // Try to hide
+ try {
+ } catch(...) {
+ {
+ if (0)
+ return; // expected-error {{return in the catch of a function try block of a constructor is illegal}}
+ }
+ }
+ }
+ BadReturn(int);
+};
+
+BadReturn::BadReturn(int) try {
+} catch(...) {
+ // Try to hide
+ try {
+ } catch(int) {
+ return; // expected-error {{return in the catch of a function try block of a constructor is illegal}}
+ } catch(...) {
+ {
+ if (0)
+ return; // expected-error {{return in the catch of a function try block of a constructor is illegal}}
+ }
+ }
+}
+
+// Cannot throw an abstract type.
+class foo {
+public:
+ foo() {}
+ void bar () {
+ throw *this; // expected-error{{cannot throw an object of abstract type 'foo'}}
+ }
+ virtual void test () = 0; // expected-note{{unimplemented pure virtual method 'test'}}
+};
+
+namespace PR6831 {
+ namespace NA { struct S; }
+ namespace NB { struct S; }
+
+ void f() {
+ using namespace NA;
+ using namespace NB;
+ try {
+ } catch (int S) {
+ }
+ }
+}
diff --git a/clang/test/SemaCXX/explicit.cpp b/clang/test/SemaCXX/explicit.cpp
new file mode 100644
index 0000000..4774637
--- /dev/null
+++ b/clang/test/SemaCXX/explicit.cpp
@@ -0,0 +1,175 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+namespace Constructor {
+struct A {
+ A(int);
+};
+
+struct B {
+ explicit B(int);
+};
+
+B::B(int) { }
+
+struct C {
+ void f(const A&);
+ void f(const B&);
+};
+
+void f(C c) {
+ c.f(10);
+}
+}
+
+namespace Conversion {
+ struct A {
+ operator int();
+ explicit operator bool();
+ };
+
+ A::operator bool() { return false; }
+
+ struct B {
+ void f(int);
+ void f(bool);
+ };
+
+ void f(A a, B b) {
+ b.f(a);
+ }
+
+ void testExplicit()
+ {
+ // Taken from 12.3.2p2
+ class Y { }; // expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'Conversion::Z' to 'const Conversion::Y &' for 1st argument}} \
+ expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'Conversion::Z' to 'Conversion::Y &&' for 1st argument}} \
+ expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'Conversion::Z' to 'const Conversion::Y &' for 1st argument}} \
+ expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'Conversion::Z' to 'Conversion::Y &&' for 1st argument}}
+
+ struct Z {
+ explicit operator Y() const;
+ explicit operator int() const;
+ };
+
+ Z z;
+ // 13.3.1.4p1 & 8.5p16:
+ Y y2 = z; // expected-error {{no viable conversion from 'Conversion::Z' to 'Conversion::Y'}}
+ Y y3 = (Y)z;
+ Y y4 = Y(z);
+ Y y5 = static_cast<Y>(z);
+ // 13.3.1.5p1 & 8.5p16:
+ int i1 = (int)z;
+ int i2 = int(z);
+ int i3 = static_cast<int>(z);
+ int i4(z);
+ // 13.3.1.6p1 & 8.5.3p5:
+ const Y& y6 = z; // expected-error {{no viable conversion from 'Conversion::Z' to 'const Conversion::Y'}}
+ const int& y7(z);
+ }
+
+ void testBool() {
+ struct Bool {
+ operator bool();
+ };
+
+ struct NotBool {
+ explicit operator bool(); // expected-note {{conversion to integral type 'bool'}}
+ };
+ Bool b;
+ NotBool n;
+
+ (void) (1 + b);
+ (void) (1 + n); // expected-error {{invalid operands to binary expression ('int' and 'Conversion::NotBool')}}
+
+ // 5.3.1p9:
+ (void) (!b);
+ (void) (!n);
+
+ // 5.14p1:
+ (void) (b && true);
+ (void) (n && true);
+
+ // 5.15p1:
+ (void) (b || true);
+ (void) (n || true);
+
+ // 5.16p1:
+ (void) (b ? 0 : 1);
+ (void) (n ? 0: 1);
+
+ // 5.19p5:
+ // TODO: After constexpr has been implemented
+
+ // 6.4p4:
+ if (b) {}
+ if (n) {}
+
+ // 6.4.2p2:
+ switch (b) {} // expected-warning {{switch condition has boolean value}}
+ switch (n) {} // expected-error {{switch condition type 'Conversion::NotBool' requires explicit conversion to 'bool'}} \
+ expected-warning {{switch condition has boolean value}}
+
+ // 6.5.1:
+ while (b) {}
+ while (n) {}
+
+ // 6.5.2p1:
+ do {} while (b);
+ do {} while (n);
+
+ // 6.5.3:
+ for (;b;) {}
+ for (;n;) {}
+ }
+
+ void testNew()
+ {
+ // 5.3.4p6:
+ struct Int {
+ operator int();
+ };
+ struct NotInt {
+ explicit operator int(); // expected-note {{conversion to integral type 'int' declared here}}
+ };
+
+ Int i;
+ NotInt ni;
+
+ new int[i];
+ new int[ni]; // expected-error {{array size expression of type 'Conversion::NotInt' requires explicit conversion to type 'int'}}
+ }
+
+ void testDelete()
+ {
+ // 5.3.5pp2:
+ struct Ptr {
+ operator int*();
+ };
+ struct NotPtr {
+ explicit operator int*();
+ };
+
+ Ptr p;
+ NotPtr np;
+
+ delete p;
+ delete np; // expected-error {{cannot delete expression of type 'Conversion::NotPtr'}}
+ }
+
+ void testFunctionPointer()
+ {
+ // 13.3.1.1.2p2:
+ using Func = void(*)(int);
+
+ struct FP {
+ operator Func();
+ };
+ struct NotFP {
+ explicit operator Func();
+ };
+
+ FP fp;
+ NotFP nfp;
+ fp(1);
+ nfp(1); // expected-error {{type 'Conversion::NotFP' does not provide a call operator}}
+ }
+}
diff --git a/clang/test/SemaCXX/expression-traits.cpp b/clang/test/SemaCXX/expression-traits.cpp
new file mode 100644
index 0000000..2767d4a
--- /dev/null
+++ b/clang/test/SemaCXX/expression-traits.cpp
@@ -0,0 +1,620 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions %s
+
+//
+// Tests for "expression traits" intrinsics such as __is_lvalue_expr.
+//
+// For the time being, these tests are written against the 2003 C++
+// standard (ISO/IEC 14882:2003 -- see draft at
+// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2001/n1316/).
+//
+// C++0x has its own, more-refined, idea of lvalues and rvalues.
+// If/when we need to support those, we'll need to track both
+// standard documents.
+
+#if !__has_feature(cxx_static_assert)
+# define CONCAT_(X_, Y_) CONCAT1_(X_, Y_)
+# define CONCAT1_(X_, Y_) X_ ## Y_
+
+// This emulation can be used multiple times on one line (and thus in
+// a macro), except at class scope
+# define static_assert(b_, m_) \
+ typedef int CONCAT_(sa_, __LINE__)[b_ ? 1 : -1]
+#endif
+
+// Tests are broken down according to section of the C++03 standard
+// (ISO/IEC 14882:2003(E))
+
+// Assertion macros encoding the following two paragraphs
+//
+// basic.lval/1 Every expression is either an lvalue or an rvalue.
+//
+// expr.prim/5 A parenthesized expression is a primary expression whose type
+// and value are identical to those of the enclosed expression. The
+// presence of parentheses does not affect whether the expression is
+// an lvalue.
+//
+// Note: these asserts cannot be made at class scope in C++03. Put
+// them in a member function instead.
+#define ASSERT_LVALUE(expr) \
+ static_assert(__is_lvalue_expr(expr), "should be an lvalue"); \
+ static_assert(__is_lvalue_expr((expr)), \
+ "the presence of parentheses should have" \
+ " no effect on lvalueness (expr.prim/5)"); \
+ static_assert(!__is_rvalue_expr(expr), "should be an lvalue"); \
+ static_assert(!__is_rvalue_expr((expr)), \
+ "the presence of parentheses should have" \
+ " no effect on lvalueness (expr.prim/5)")
+
+#define ASSERT_RVALUE(expr); \
+ static_assert(__is_rvalue_expr(expr), "should be an rvalue"); \
+ static_assert(__is_rvalue_expr((expr)), \
+ "the presence of parentheses should have" \
+ " no effect on lvalueness (expr.prim/5)"); \
+ static_assert(!__is_lvalue_expr(expr), "should be an rvalue"); \
+ static_assert(!__is_lvalue_expr((expr)), \
+ "the presence of parentheses should have" \
+ " no effect on lvalueness (expr.prim/5)")
+
+enum Enum { Enumerator };
+
+int ReturnInt();
+void ReturnVoid();
+Enum ReturnEnum();
+
+void basic_lval_5()
+{
+ // basic.lval/5: The result of calling a function that does not return
+ // a reference is an rvalue.
+ ASSERT_RVALUE(ReturnInt());
+ ASSERT_RVALUE(ReturnVoid());
+ ASSERT_RVALUE(ReturnEnum());
+}
+
+int& ReturnIntReference();
+extern Enum& ReturnEnumReference();
+
+void basic_lval_6()
+{
+ // basic.lval/6: An expression which holds a temporary object resulting
+ // from a cast to a nonreference type is an rvalue (this includes
+ // the explicit creation of an object using functional notation
+ struct IntClass
+ {
+ explicit IntClass(int = 0);
+ IntClass(char const*);
+ operator int() const;
+ };
+
+ struct ConvertibleToIntClass
+ {
+ operator IntClass() const;
+ };
+
+ ConvertibleToIntClass b;
+
+ // Make sure even trivial conversions are not detected as lvalues
+ int intLvalue = 0;
+ ASSERT_RVALUE((int)intLvalue);
+ ASSERT_RVALUE((short)intLvalue);
+ ASSERT_RVALUE((long)intLvalue);
+
+ // Same tests with function-call notation
+ ASSERT_RVALUE(int(intLvalue));
+ ASSERT_RVALUE(short(intLvalue));
+ ASSERT_RVALUE(long(intLvalue));
+
+ char charLValue = 'x';
+ ASSERT_RVALUE((signed char)charLValue);
+ ASSERT_RVALUE((unsigned char)charLValue);
+
+ ASSERT_RVALUE(static_cast<int>(IntClass()));
+ IntClass intClassLValue;
+ ASSERT_RVALUE(static_cast<int>(intClassLValue));
+ ASSERT_RVALUE(static_cast<IntClass>(ConvertibleToIntClass()));
+ ConvertibleToIntClass convertibleToIntClassLValue;
+ ASSERT_RVALUE(static_cast<IntClass>(convertibleToIntClassLValue));
+
+
+ typedef signed char signed_char;
+ typedef unsigned char unsigned_char;
+ ASSERT_RVALUE(signed_char(charLValue));
+ ASSERT_RVALUE(unsigned_char(charLValue));
+
+ ASSERT_RVALUE(int(IntClass()));
+ ASSERT_RVALUE(int(intClassLValue));
+ ASSERT_RVALUE(IntClass(ConvertibleToIntClass()));
+ ASSERT_RVALUE(IntClass(convertibleToIntClassLValue));
+}
+
+void conv_ptr_1()
+{
+ // conv.ptr/1: A null pointer constant is an integral constant
+ // expression (5.19) rvalue of integer type that evaluates to
+ // zero.
+ ASSERT_RVALUE(0);
+}
+
+void expr_6()
+{
+ // expr/6: If an expression initially has the type "reference to T"
+ // (8.3.2, 8.5.3), ... the expression is an lvalue.
+ int x = 0;
+ int& referenceToInt = x;
+ ASSERT_LVALUE(referenceToInt);
+ ASSERT_LVALUE(ReturnIntReference());
+}
+
+void expr_prim_2()
+{
+ // 5.1/2 A string literal is an lvalue; all other
+ // literals are rvalues.
+ ASSERT_LVALUE("foo");
+ ASSERT_RVALUE(1);
+ ASSERT_RVALUE(1.2);
+ ASSERT_RVALUE(10UL);
+}
+
+void expr_prim_3()
+{
+ // 5.1/3: The keyword "this" names a pointer to the object for
+ // which a nonstatic member function (9.3.2) is invoked. ...The
+ // expression is an rvalue.
+ struct ThisTest
+ {
+ void f() { ASSERT_RVALUE(this); }
+ };
+}
+
+extern int variable;
+void Function();
+
+struct BaseClass
+{
+ virtual ~BaseClass();
+
+ int BaseNonstaticMemberFunction();
+ static int BaseStaticMemberFunction();
+ int baseDataMember;
+};
+
+struct Class : BaseClass
+{
+ static void function();
+ static int variable;
+
+ template <class T>
+ struct NestedClassTemplate {};
+
+ template <class T>
+ static int& NestedFuncTemplate() { return variable; } // expected-note{{possible target for call}}
+
+ template <class T>
+ int& NestedMemfunTemplate() { return variable; }
+
+ int operator*() const;
+
+ template <class T>
+ int operator+(T) const;
+
+ int NonstaticMemberFunction();
+ static int StaticMemberFunction();
+ int dataMember;
+
+ int& referenceDataMember;
+ static int& staticReferenceDataMember;
+ static int staticNonreferenceDataMember;
+
+ enum Enum { Enumerator };
+
+ operator long() const;
+
+ Class();
+ Class(int,int);
+
+ void expr_prim_4()
+ {
+ // 5.1/4: The operator :: followed by an identifier, a
+ // qualified-id, or an operator-function-id is a primary-
+ // expression. ...The result is an lvalue if the entity is
+ // a function or variable.
+ ASSERT_LVALUE(::Function); // identifier: function
+ ASSERT_LVALUE(::variable); // identifier: variable
+
+ // the only qualified-id form that can start without "::" (and thus
+ // be legal after "::" ) is
+ //
+ // ::<sub>opt</sub> nested-name-specifier template<sub>opt</sub> unqualified-id
+ ASSERT_LVALUE(::Class::function); // qualified-id: function
+ ASSERT_LVALUE(::Class::variable); // qualified-id: variable
+
+ // The standard doesn't give a clear answer about whether these
+ // should really be lvalues or rvalues without some surrounding
+ // context that forces them to be interpreted as naming a
+ // particular function template specialization (that situation
+ // doesn't come up in legal pure C++ programs). This language
+ // extension simply rejects them as requiring additional context
+ __is_lvalue_expr(::Class::NestedFuncTemplate); // qualified-id: template \
+ // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
+
+ __is_lvalue_expr(::Class::NestedMemfunTemplate); // qualified-id: template \
+ // expected-error{{reference to non-static member function must be called}}
+
+ __is_lvalue_expr(::Class::operator+); // operator-function-id: template \
+ // expected-error{{reference to non-static member function must be called}}
+
+ //ASSERT_RVALUE(::Class::operator*); // operator-function-id: member function
+ }
+
+ void expr_prim_7()
+ {
+ // expr.prim/7 An identifier is an id-expression provided it has been
+ // suitably declared (clause 7). [Note: ... ] The type of the
+ // expression is the type of the identifier. The result is the
+ // entity denoted by the identifier. The result is an lvalue if
+ // the entity is a function, variable, or data member... (cont'd)
+ ASSERT_LVALUE(Function); // identifier: function
+ ASSERT_LVALUE(StaticMemberFunction); // identifier: function
+ ASSERT_LVALUE(variable); // identifier: variable
+ ASSERT_LVALUE(dataMember); // identifier: data member
+ //ASSERT_RVALUE(NonstaticMemberFunction); // identifier: member function
+
+ // (cont'd)...A nested-name-specifier that names a class,
+ // optionally followed by the keyword template (14.2), and then
+ // followed by the name of a member of either that class (9.2) or
+ // one of its base classes... is a qualified-id... The result is
+ // the member. The type of the result is the type of the
+ // member. The result is an lvalue if the member is a static
+ // member function or a data member.
+ ASSERT_LVALUE(Class::dataMember);
+ ASSERT_LVALUE(Class::StaticMemberFunction);
+ //ASSERT_RVALUE(Class::NonstaticMemberFunction); // identifier: member function
+
+ ASSERT_LVALUE(Class::baseDataMember);
+ ASSERT_LVALUE(Class::BaseStaticMemberFunction);
+ //ASSERT_RVALUE(Class::BaseNonstaticMemberFunction); // identifier: member function
+ }
+};
+
+void expr_call_10()
+{
+ // expr.call/10: A function call is an lvalue if and only if the
+ // result type is a reference. This statement is partially
+ // redundant with basic.lval/5
+ basic_lval_5();
+
+ ASSERT_LVALUE(ReturnIntReference());
+ ASSERT_LVALUE(ReturnEnumReference());
+}
+
+namespace Namespace
+{
+ int x;
+ void function();
+}
+
+void expr_prim_8()
+{
+ // expr.prim/8 A nested-name-specifier that names a namespace
+ // (7.3), followed by the name of a member of that namespace (or
+ // the name of a member of a namespace made visible by a
+ // using-directive ) is a qualified-id; 3.4.3.2 describes name
+ // lookup for namespace members that appear in qualified-ids. The
+ // result is the member. The type of the result is the type of the
+ // member. The result is an lvalue if the member is a function or
+ // a variable.
+ ASSERT_LVALUE(Namespace::x);
+ ASSERT_LVALUE(Namespace::function);
+}
+
+void expr_sub_1(int* pointer)
+{
+ // expr.sub/1 A postfix expression followed by an expression in
+ // square brackets is a postfix expression. One of the expressions
+ // shall have the type "pointer to T" and the other shall have
+ // enumeration or integral type. The result is an lvalue of type
+ // "T."
+ ASSERT_LVALUE(pointer[1]);
+
+ // The expression E1[E2] is identical (by definition) to *((E1)+(E2)).
+ ASSERT_LVALUE(*(pointer+1));
+}
+
+void expr_type_conv_1()
+{
+ // expr.type.conv/1 A simple-type-specifier (7.1.5) followed by a
+ // parenthesized expression-list constructs a value of the specified
+ // type given the expression list. ... If the expression list
+ // specifies more than a single value, the type shall be a class with
+ // a suitably declared constructor (8.5, 12.1), and the expression
+ // T(x1, x2, ...) is equivalent in effect to the declaration T t(x1,
+ // x2, ...); for some invented temporary variable t, with the result
+ // being the value of t as an rvalue.
+ ASSERT_RVALUE(Class(2,2));
+}
+
+void expr_type_conv_2()
+{
+ // expr.type.conv/2 The expression T(), where T is a
+ // simple-type-specifier (7.1.5.2) for a non-array complete object
+ // type or the (possibly cv-qualified) void type, creates an
+ // rvalue of the specified type,
+ ASSERT_RVALUE(int());
+ ASSERT_RVALUE(Class());
+ ASSERT_RVALUE(void());
+}
+
+
+void expr_ref_4()
+{
+ // Applies to expressions of the form E1.E2
+
+ // If E2 is declared to have type "reference to T", then E1.E2 is
+ // an lvalue;.... Otherwise, one of the following rules applies.
+ ASSERT_LVALUE(Class().staticReferenceDataMember);
+ ASSERT_LVALUE(Class().referenceDataMember);
+
+ // - If E2 is a static data member, and the type of E2 is T, then
+ // E1.E2 is an lvalue; ...
+ ASSERT_LVALUE(Class().staticNonreferenceDataMember);
+ ASSERT_LVALUE(Class().staticReferenceDataMember);
+
+
+ // - If E2 is a non-static data member, ... If E1 is an lvalue,
+ // then E1.E2 is an lvalue...
+ Class lvalue;
+ ASSERT_LVALUE(lvalue.dataMember);
+ ASSERT_RVALUE(Class().dataMember);
+
+ // - If E1.E2 refers to a static member function, ... then E1.E2
+ // is an lvalue
+ ASSERT_LVALUE(Class().StaticMemberFunction);
+
+ // - Otherwise, if E1.E2 refers to a non-static member function,
+ // then E1.E2 is not an lvalue.
+ //ASSERT_RVALUE(Class().NonstaticMemberFunction);
+
+ // - If E2 is a member enumerator, and the type of E2 is T, the
+ // expression E1.E2 is not an lvalue. The type of E1.E2 is T.
+ ASSERT_RVALUE(Class().Enumerator);
+ ASSERT_RVALUE(lvalue.Enumerator);
+}
+
+
+void expr_post_incr_1(int x)
+{
+ // expr.post.incr/1 The value obtained by applying a postfix ++ is
+ // the value that the operand had before applying the
+ // operator... The result is an rvalue.
+ ASSERT_RVALUE(x++);
+}
+
+void expr_dynamic_cast_2()
+{
+ // expr.dynamic.cast/2: If T is a pointer type, v shall be an
+ // rvalue of a pointer to complete class type, and the result is
+ // an rvalue of type T.
+ Class instance;
+ ASSERT_RVALUE(dynamic_cast<Class*>(&instance));
+
+ // If T is a reference type, v shall be an
+ // lvalue of a complete class type, and the result is an lvalue of
+ // the type referred to by T.
+ ASSERT_LVALUE(dynamic_cast<Class&>(instance));
+}
+
+void expr_dynamic_cast_5()
+{
+ // expr.dynamic.cast/5: If T is "reference to cv1 B" and v has type
+ // "cv2 D" such that B is a base class of D, the result is an
+ // lvalue for the unique B sub-object of the D object referred
+ // to by v.
+ typedef BaseClass B;
+ typedef Class D;
+ D object;
+ ASSERT_LVALUE(dynamic_cast<B&>(object));
+}
+
+// expr.dynamic.cast/8: The run-time check logically executes as follows:
+//
+// - If, in the most derived object pointed (referred) to by v, v
+// points (refers) to a public base class subobject of a T object, and
+// if only one object of type T is derived from the sub-object pointed
+// (referred) to by v, the result is a pointer (an lvalue referring)
+// to that T object.
+//
+// - Otherwise, if v points (refers) to a public base class sub-object
+// of the most derived object, and the type of the most derived object
+// has a base class, of type T, that is unambiguous and public, the
+// result is a pointer (an lvalue referring) to the T sub-object of
+// the most derived object.
+//
+// The mention of "lvalue" in the text above appears to be a
+// defect that is being corrected by the response to UK65 (see
+// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2841.html).
+
+#if 0
+void expr_typeid_1()
+{
+ // expr.typeid/1: The result of a typeid expression is an lvalue...
+ ASSERT_LVALUE(typeid(1));
+}
+#endif
+
+void expr_static_cast_1(int x)
+{
+ // expr.static.cast/1: The result of the expression
+ // static_cast<T>(v) is the result of converting the expression v
+ // to type T. If T is a reference type, the result is an lvalue;
+ // otherwise, the result is an rvalue.
+ ASSERT_LVALUE(static_cast<int&>(x));
+ ASSERT_RVALUE(static_cast<int>(x));
+}
+
+void expr_reinterpret_cast_1()
+{
+ // expr.reinterpret.cast/1: The result of the expression
+ // reinterpret_cast<T>(v) is the result of converting the
+ // expression v to type T. If T is a reference type, the result is
+ // an lvalue; otherwise, the result is an rvalue
+ ASSERT_RVALUE(reinterpret_cast<int*>(0));
+ char const v = 0;
+ ASSERT_LVALUE(reinterpret_cast<char const&>(v));
+}
+
+void expr_unary_op_1(int* pointer, struct incomplete* pointerToIncompleteType)
+{
+ // expr.unary.op/1: The unary * operator performs indirection: the
+ // expression to which it is applied shall be a pointer to an
+ // object type, or a pointer to a function type and the result is
+ // an lvalue referring to the object or function to which the
+ // expression points.
+ ASSERT_LVALUE(*pointer);
+ ASSERT_LVALUE(*Function);
+
+ // [Note: a pointer to an incomplete type
+ // (other than cv void ) can be dereferenced. ]
+ ASSERT_LVALUE(*pointerToIncompleteType);
+}
+
+void expr_pre_incr_1(int operand)
+{
+ // expr.pre.incr/1: The operand of prefix ++ ... shall be a
+ // modifiable lvalue.... The value is the new value of the
+ // operand; it is an lvalue.
+ ASSERT_LVALUE(++operand);
+}
+
+void expr_cast_1(int x)
+{
+ // expr.cast/1: The result of the expression (T) cast-expression
+ // is of type T. The result is an lvalue if T is a reference type,
+ // otherwise the result is an rvalue.
+ ASSERT_LVALUE((void(&)())expr_cast_1);
+ ASSERT_LVALUE((int&)x);
+ ASSERT_RVALUE((void(*)())expr_cast_1);
+ ASSERT_RVALUE((int)x);
+}
+
+void expr_mptr_oper()
+{
+ // expr.mptr.oper/6: The result of a .* expression is an lvalue
+ // only if its first operand is an lvalue and its second operand
+ // is a pointer to data member... (cont'd)
+ typedef Class MakeRValue;
+ ASSERT_RVALUE(MakeRValue().*(&Class::dataMember));
+ //ASSERT_RVALUE(MakeRValue().*(&Class::NonstaticMemberFunction));
+ Class lvalue;
+ ASSERT_LVALUE(lvalue.*(&Class::dataMember));
+ //ASSERT_RVALUE(lvalue.*(&Class::NonstaticMemberFunction));
+
+ // (cont'd)...The result of an ->* expression is an lvalue only
+ // if its second operand is a pointer to data member. If the
+ // second operand is the null pointer to member value (4.11), the
+ // behavior is undefined.
+ ASSERT_LVALUE((&lvalue)->*(&Class::dataMember));
+ //ASSERT_RVALUE((&lvalue)->*(&Class::NonstaticMemberFunction));
+}
+
+void expr_cond(bool cond)
+{
+ // 5.16 Conditional operator [expr.cond]
+ //
+ // 2 If either the second or the third operand has type (possibly
+ // cv-qualified) void, then the lvalue-to-rvalue (4.1),
+ // array-to-pointer (4.2), and function-to-pointer (4.3) standard
+ // conversions are performed on the second and third operands, and one
+ // of the following shall hold:
+ //
+ // - The second or the third operand (but not both) is a
+ // throw-expression (15.1); the result is of the type of the other and
+ // is an rvalue.
+
+ Class classLvalue;
+ ASSERT_RVALUE(cond ? throw 1 : (void)0);
+ ASSERT_RVALUE(cond ? (void)0 : throw 1);
+ ASSERT_RVALUE(cond ? throw 1 : classLvalue);
+ ASSERT_RVALUE(cond ? classLvalue : throw 1);
+
+ // - Both the second and the third operands have type void; the result
+ // is of type void and is an rvalue. [Note: this includes the case
+ // where both operands are throw-expressions. ]
+ ASSERT_RVALUE(cond ? (void)1 : (void)0);
+ ASSERT_RVALUE(cond ? throw 1 : throw 0);
+
+ // expr.cond/4: If the second and third operands are lvalues and
+ // have the same type, the result is of that type and is an
+ // lvalue.
+ ASSERT_LVALUE(cond ? classLvalue : classLvalue);
+ int intLvalue = 0;
+ ASSERT_LVALUE(cond ? intLvalue : intLvalue);
+
+ // expr.cond/5:Otherwise, the result is an rvalue.
+ typedef Class MakeRValue;
+ ASSERT_RVALUE(cond ? MakeRValue() : classLvalue);
+ ASSERT_RVALUE(cond ? classLvalue : MakeRValue());
+ ASSERT_RVALUE(cond ? MakeRValue() : MakeRValue());
+ ASSERT_RVALUE(cond ? classLvalue : intLvalue);
+ ASSERT_RVALUE(cond ? intLvalue : int());
+}
+
+void expr_ass_1(int x)
+{
+ // expr.ass/1: There are several assignment operators, all of
+ // which group right-to-left. All require a modifiable lvalue as
+ // their left operand, and the type of an assignment expression is
+ // that of its left operand. The result of the assignment
+ // operation is the value stored in the left operand after the
+ // assignment has taken place; the result is an lvalue.
+ ASSERT_LVALUE(x = 1);
+ ASSERT_LVALUE(x += 1);
+ ASSERT_LVALUE(x -= 1);
+ ASSERT_LVALUE(x *= 1);
+ ASSERT_LVALUE(x /= 1);
+ ASSERT_LVALUE(x %= 1);
+ ASSERT_LVALUE(x ^= 1);
+ ASSERT_LVALUE(x &= 1);
+ ASSERT_LVALUE(x |= 1);
+}
+
+void expr_comma(int x)
+{
+ // expr.comma: A pair of expressions separated by a comma is
+ // evaluated left-to-right and the value of the left expression is
+ // discarded... result is an lvalue if its right operand is.
+
+ // Can't use the ASSERT_XXXX macros without adding parens around
+ // the comma expression.
+ static_assert(__is_lvalue_expr(x,x), "expected an lvalue");
+ static_assert(__is_rvalue_expr(x,1), "expected an rvalue");
+ static_assert(__is_lvalue_expr(1,x), "expected an lvalue");
+ static_assert(__is_rvalue_expr(1,1), "expected an rvalue");
+}
+
+#if 0
+template<typename T> void f();
+
+// FIXME These currently fail
+void expr_fun_lvalue()
+{
+ ASSERT_LVALUE(&f<int>);
+}
+
+void expr_fun_rvalue()
+{
+ ASSERT_RVALUE(f<int>);
+}
+#endif
+
+template <int NonTypeNonReferenceParameter, int& NonTypeReferenceParameter>
+void check_temp_param_6()
+{
+ ASSERT_RVALUE(NonTypeNonReferenceParameter);
+ ASSERT_LVALUE(NonTypeReferenceParameter);
+}
+
+int AnInt = 0;
+
+void temp_param_6()
+{
+ check_temp_param_6<3,AnInt>();
+}
diff --git a/clang/test/SemaCXX/expressions.cpp b/clang/test/SemaCXX/expressions.cpp
new file mode 100644
index 0000000..355833e
--- /dev/null
+++ b/clang/test/SemaCXX/expressions.cpp
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void choice(int);
+int choice(bool);
+
+void test() {
+ // Result of ! must be type bool.
+ int i = choice(!1);
+}
+
+// rdar://8018252
+void f0() {
+ extern void f0_1(int*);
+ register int x;
+ f0_1(&x);
+}
+
+namespace test1 {
+ template <class T> void bar(T &x) { T::fail(); }
+ template <class T> void bar(volatile T &x) {}
+
+ void test_ints() {
+ volatile int x;
+ bar(x = 5);
+ bar(x += 5);
+ }
+
+ enum E { E_zero };
+ void test_enums() {
+ volatile E x;
+ bar(x = E_zero);
+ bar(x += E_zero); // expected-error {{incompatible type}}
+ }
+}
+
+int test2(int x) {
+ return x && 4; // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+
+ return x && sizeof(int) == 4; // no warning, RHS is logical op.
+ return x && true;
+ return x && false;
+ return x || true;
+ return x || false;
+
+ return x && (unsigned)0; // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+
+ return x || (unsigned)1; // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+
+ return x || 0; // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+ return x || 1; // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+ return x || -1; // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+ return x || 5; // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+ return x && 0; // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+ return x && 1; // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+ return x && -1; // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+ return x && 5; // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+ return x || (0); // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+ return x || (1); // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+ return x || (-1); // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+ return x || (5); // expected-warning {{use of logical '||' with constant operand}} \
+ // expected-note {{use '|' for a bitwise operation}}
+ return x && (0); // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+ return x && (1); // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+ return x && (-1); // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+ return x && (5); // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+}
+
+template<unsigned int A, unsigned int B> struct S
+{
+ enum {
+ e1 = A && B,
+ e2 = A && 7 // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+ };
+
+ int foo() {
+ int x = A && B;
+ int y = B && 3; // expected-warning {{use of logical '&&' with constant operand}} \
+ // expected-note {{use '&' for a bitwise operation}} \
+ // expected-note {{remove constant to silence this warning}}
+
+ return x + y;
+ }
+};
+
+void test3() {
+ S<5, 8> s1;
+ S<2, 7> s2;
+ (void)s1.foo();
+ (void)s2.foo();
+}
diff --git a/clang/test/SemaCXX/flexible-array-test.cpp b/clang/test/SemaCXX/flexible-array-test.cpp
new file mode 100644
index 0000000..e6c3132
--- /dev/null
+++ b/clang/test/SemaCXX/flexible-array-test.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// pr7029
+
+template <class Key, class T> struct QMap
+{
+ void insert(const Key &, const T &);
+ T v;
+};
+
+
+template <class Key, class T>
+void QMap<Key, T>::insert(const Key &, const T &avalue)
+{
+ v = avalue;
+}
+
+
+struct inotify_event
+{
+ int wd;
+
+ // clang doesn't like '[]':
+ // cannot initialize a parameter of type 'void *' with an rvalue of type 'char (*)[]'
+ char name [];
+};
+
+
+void foo()
+{
+ inotify_event event;
+ inotify_event* ptr = &event;
+ inotify_event event1 = *ptr;
+ *ptr = event;
+ QMap<int, inotify_event> eventForId;
+ eventForId.insert(ptr->wd, *ptr);
+}
+
+struct S {
+ virtual void foo();
+};
+
+struct X {
+ int blah;
+ S strings[]; // expected-error {{flexible array member 'strings' of non-POD element type 'S []'}}
+};
+
+class A {
+ int s;
+ char c[];
+};
+
+union B {
+ int s;
+ char c[];
+};
+
+namespace rdar9065507 {
+
+struct StorageBase {
+ long ref_count;
+ unsigned size;
+ unsigned capacity;
+};
+
+struct Storage : StorageBase {
+ int data[];
+};
+
+}
diff --git a/clang/test/SemaCXX/fntype-decl.cpp b/clang/test/SemaCXX/fntype-decl.cpp
new file mode 100644
index 0000000..b8ae625
--- /dev/null
+++ b/clang/test/SemaCXX/fntype-decl.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR2942
+typedef void fn(int);
+fn f; // expected-note {{previous declaration is here}}
+
+int g(int x, int y);
+int g(int x, int y = 2);
+
+typedef int g_type(int, int);
+g_type g;
+
+int h(int x) { // expected-note {{previous definition is here}}
+ return g(x);
+}
+
+float f(int) { } // expected-error{{functions that differ only in their return type cannot be overloaded}}
+
+int h(int) { } // expected-error{{redefinition of 'h'}}
+
diff --git a/clang/test/SemaCXX/for-range-examples.cpp b/clang/test/SemaCXX/for-range-examples.cpp
new file mode 100644
index 0000000..8bda510
--- /dev/null
+++ b/clang/test/SemaCXX/for-range-examples.cpp
@@ -0,0 +1,182 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+namespace value_range_detail {
+ template<typename T>
+ class value_range_iter {
+ T t;
+ public:
+ value_range_iter(const T &t) : t(t) {}
+ T operator*() const { return t; }
+ bool operator!=(const value_range_iter &o) const { return t != o.t; }
+ value_range_iter &operator++() { ++t; return *this; }
+ };
+
+ template<typename T>
+ struct value_range {
+ value_range(const T &a, const T &b) : begin_(a), end_(b) {}
+ value_range_iter<T> begin_, end_;
+ };
+
+ template<typename T>
+ value_range_iter<T> begin(const value_range<T> &r) { return r.begin_; }
+ template<typename T>
+ value_range_iter<T> end(const value_range<T> &r) { return r.end_; }
+
+
+ struct end_t {};
+
+ template<typename T>
+ class value_range_step_iter {
+ T it, step;
+ public:
+ value_range_step_iter(const T &it, const T &step) : it(it), step(step) {}
+ T operator*() const { return it; }
+ bool operator!=(value_range_step_iter end) const { return it != end.it; }
+ value_range_step_iter &operator++() { it += step; return *this; }
+ };
+
+ template<typename T>
+ class value_range_step {
+ T it, step, end_;
+ public:
+ value_range_step(const T &it, const T &end, const T &step) :
+ it(it), end_(end), step(step) {}
+ typedef value_range_step_iter<T> iterator;
+ iterator begin() const { return iterator(it, step); }
+ iterator end() const { return iterator(end_, step); }
+ };
+}
+
+template<typename T>
+value_range_detail::value_range<T> range(const T &a, const T &b) { return value_range_detail::value_range<T>(a, b); }
+
+template<typename T>
+value_range_detail::value_range_step<T> range(const T &a, const T &b, const T &step) { return value_range_detail::value_range_step<T>(a, b, step); }
+
+
+namespace map_range {
+ template<typename T>
+ class vector {
+ T storage[100];
+ decltype(sizeof(char)) size;
+ public:
+ vector() : size() {}
+ void push_back(T t) { storage[size++] = t; }
+ T *begin() { return storage; }
+ T *end() { return storage + size; }
+ };
+
+ template<typename T> struct tuple_elem {
+ T t;
+ tuple_elem() {}
+ tuple_elem(T t) : t(t) {}
+ };
+ template<typename... A>
+ struct tuple : tuple_elem<A>... {
+ tuple() : tuple_elem<A>()... {}
+ tuple(A... a) : tuple_elem<A>(a)... {}
+ template<typename B> B &get() { return tuple_elem<B>::t; }
+ };
+
+ template<typename F, typename I>
+ class map_iter {
+ F f;
+ I i;
+ public:
+ map_iter(F f, I i) : f(f), i(i) {}
+ auto operator*() const -> decltype(f(*i)) { return f(*i); }
+ bool operator!=(const map_iter &o) const { return i != o.i; }
+ map_iter &operator++() { ++i; return *this; }
+ };
+
+ template<typename T>
+ struct iter_pair {
+ T begin_, end_;
+ iter_pair(T begin, T end) : begin_(begin), end_(end) {}
+ };
+ template<typename T> T begin(iter_pair<T> p) { return p.begin_; }
+ template<typename T> T end(iter_pair<T> p) { return p.end_; }
+
+ template<typename...> class mem_fun_impl;
+ template<typename R, typename T, typename... A>
+ class mem_fun_impl<R (T::*)(A...)> {
+ typedef R (T::*F)(A...);
+ F f;
+ public:
+ mem_fun_impl(F f) : f(f) {}
+ R operator()(T &t, A &&...a) const { return (t.*f)(static_cast<A&&>(a)...); }
+ };
+ template<typename F> mem_fun_impl<F> mem_fun(F f) { return mem_fun_impl<F>(f); }
+
+ template<typename F, typename T>
+ auto map(const F &f, T &t) -> iter_pair<map_iter<F, decltype(t.begin())>> {
+ typedef map_iter<F, decltype(t.begin())> iter;
+ return iter_pair<iter>(iter(f, t.begin()), iter(f, t.end()));
+ }
+}
+
+#define assert(b) if (!b) { return 1; }
+int main() {
+ int total = 0;
+
+ for (auto n : range(1, 5)) {
+ total += n;
+ }
+ assert(total == 10);
+
+ for (auto n : range(10, 100, 10)) {
+ total += n;
+ }
+ assert(total == 460);
+
+ map_range::vector<char> chars;
+ chars.push_back('a');
+ chars.push_back('b');
+ chars.push_back('c');
+ for (char c : chars) {
+ ++total;
+ }
+ assert(total == 463);
+
+ typedef map_range::tuple<int, double> T;
+ map_range::vector<T> pairs;
+ pairs.push_back(T(42, 12.9));
+ pairs.push_back(T(6, 4.2));
+ pairs.push_back(T(9, 1.1));
+ for (auto a : map(map_range::mem_fun(&T::get<int>), pairs)) {
+ total += a;
+ }
+ assert(total == 500);
+}
+
+// PR11793
+namespace test2 {
+ class A {
+ int xs[10]; // expected-note {{implicitly declared private here}}
+ };
+ void test(A &a) {
+ for (int x : a.xs) { } // expected-error {{'xs' is a private member of 'test2::A'}}
+ }
+}
+
+namespace test3 {
+ // Make sure this doesn't crash
+ struct A {};
+ struct B { ~B(); operator bool(); };
+ struct C { B operator!=(const C&); C& operator++(); int operator*(); };
+ C begin(const A&);
+ C end(const A&);
+ template<typename T> void f() { for (auto a : A()) {} }
+ void g() { f<int>(); }
+}
+
+namespace test4 {
+ void f() {
+ int y;
+
+ // Make sure these don't crash. Better diagnostics would be nice.
+ for (: {1, 2, 3}) {} // expected-error {{expected expression}} expected-error {{expected ';'}}
+ for (x : {1, 2, 3}) {} // expected-error {{undeclared identifier}} expected-error {{expected ';'}}
+ for (y : {1, 2, 3}) {} // expected-error {{must declare a variable}} expected-warning {{result unused}}
+ }
+}
diff --git a/clang/test/SemaCXX/for-range-no-std.cpp b/clang/test/SemaCXX/for-range-no-std.cpp
new file mode 100644
index 0000000..fa42ca4
--- /dev/null
+++ b/clang/test/SemaCXX/for-range-no-std.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions
+
+struct S {
+ int *begin();
+ int *end();
+};
+
+struct T {
+};
+
+struct Range {};
+int begin(Range); // expected-note {{not viable}}
+int end(Range);
+
+namespace NS {
+ struct ADL {};
+ struct iter {
+ int operator*();
+ bool operator!=(iter);
+ void operator++();
+ };
+ iter begin(ADL); // expected-note {{not viable}}
+ iter end(ADL);
+
+ struct NoADL {};
+}
+NS::iter begin(NS::NoADL); // expected-note {{not viable}}
+NS::iter end(NS::NoADL);
+
+void f() {
+ int a[] = {1, 2, 3};
+ for (auto b : S()) {} // ok
+ for (auto b : T()) {} // expected-error {{no matching function for call to 'begin'}} expected-note {{range has type}}
+ for (auto b : a) {} // ok
+ for (int b : NS::ADL()) {} // ok
+ for (int b : NS::NoADL()) {} // expected-error {{no matching function for call to 'begin'}} expected-note {{range has type}}
+}
+
+void PR11601() {
+ void (*vv[])() = {PR11601, PR11601, PR11601};
+ for (void (*i)() : vv) i();
+}
diff --git a/clang/test/SemaCXX/for-range-unused.cpp b/clang/test/SemaCXX/for-range-unused.cpp
new file mode 100644
index 0000000..ce6b379
--- /dev/null
+++ b/clang/test/SemaCXX/for-range-unused.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -Wunused
+
+// PR9968: We used to warn that __range is unused in a dependent for-range.
+
+template <typename T>
+ struct Vector {
+ void doIt() {
+ int a; // expected-warning {{unused variable 'a'}}
+
+ for (auto& e : elements)
+ ;
+ }
+
+ T elements[10];
+ };
+
+
+int main(int, char**) {
+ Vector<int> vector;
+ vector.doIt();
+}
diff --git a/clang/test/SemaCXX/format-strings-0x.cpp b/clang/test/SemaCXX/format-strings-0x.cpp
new file mode 100644
index 0000000..e7c5904
--- /dev/null
+++ b/clang/test/SemaCXX/format-strings-0x.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++11 %s
+
+extern "C" {
+extern int scanf(const char *restrict, ...);
+extern int printf(const char *restrict, ...);
+}
+
+void f(char **sp, float *fp) {
+ scanf("%as", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'char **'}}
+
+ printf("%a", 1.0);
+ scanf("%afoobar", fp);
+ printf(nullptr);
+ printf(*sp); // expected-warning {{not a string literal}}
+}
diff --git a/clang/test/SemaCXX/format-strings.cpp b/clang/test/SemaCXX/format-strings.cpp
new file mode 100644
index 0000000..6b0df29
--- /dev/null
+++ b/clang/test/SemaCXX/format-strings.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -pedantic %s
+
+#include <stdarg.h>
+
+extern "C" {
+extern int scanf(const char *restrict, ...);
+extern int printf(const char *restrict, ...);
+extern int vprintf(const char *restrict, va_list);
+}
+
+void f(char **sp, float *fp) {
+ scanf("%as", sp); // expected-warning{{'a' length modifier is not supported by ISO C}}
+
+ // TODO: Warn that the 'a' conversion specifier is a C++11 feature.
+ printf("%a", 1.0);
+ scanf("%afoobar", fp);
+}
+
+void g() {
+ printf("%ls", "foo"); // expected-warning{{format specifies type 'wchar_t *' but the argument has type 'const char *'}}
+}
+
+// Test that we properly handle format_idx on C++ members.
+class Foo {
+public:
+ const char *gettext(const char *fmt) __attribute__((format_arg(2)));
+
+ int scanf(const char *, ...) __attribute__((format(scanf, 2, 3)));
+ int printf(const char *, ...) __attribute__((format(printf, 2, 3)));
+ int printf2(const char *, ...);
+
+ static const char *gettext_static(const char *fmt) __attribute__((format_arg(1)));
+ static int printf_static(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
+};
+
+void h(int *i) {
+ Foo foo;
+ foo.scanf("%d"); // expected-warning{{more '%' conversions than data arguments}}
+ foo.printf("%d", i); // expected-warning{{format specifies type 'int' but the argument has type 'int *'}}
+ Foo::printf_static("%d", i); // expected-warning{{format specifies type 'int' but the argument has type 'int *'}}
+
+ printf(foo.gettext("%d"), i); // expected-warning{{format specifies type 'int' but the argument has type 'int *'}}
+ printf(Foo::gettext_static("%d"), i); // expected-warning{{format specifies type 'int' but the argument has type 'int *'}}
+}
+
+// Test handling __null for format string literal checking.
+extern "C" {
+ int test_null_format(const char *format, ...) __attribute__((__format__ (__printf__, 1, 2)));
+}
+
+void rdar8269537(const char *f)
+{
+ test_null_format(false); // expected-warning {{null from a constant boolean}}
+ test_null_format(0); // no-warning
+ test_null_format(__null); // no-warning
+ test_null_format(f); // expected-warning {{not a string literal}}
+}
+
+int Foo::printf(const char *fmt, ...) {
+ va_list ap;
+ va_start(ap,fmt);
+ const char * const format = fmt;
+ vprintf(format, ap); // no-warning
+
+ const char *format2 = fmt;
+ vprintf(format2, ap); // expected-warning{{format string is not a string literal}}
+
+ return 0;
+}
+
+int Foo::printf2(const char *fmt, ...) {
+ va_list ap;
+ va_start(ap,fmt);
+ vprintf(fmt, ap); // expected-warning{{format string is not a string literal}}
+
+ return 0;
+}
diff --git a/clang/test/SemaCXX/friend-class-nodecl.cpp b/clang/test/SemaCXX/friend-class-nodecl.cpp
new file mode 100644
index 0000000..41e2da6
--- /dev/null
+++ b/clang/test/SemaCXX/friend-class-nodecl.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -ast-print %s -o %t
+// RUN: not grep '^ *class B' %t
+
+// Tests that the tag decls in friend declarations aren't added to the
+// declaring class's decl chain.
+
+class A {
+ friend class B;
+};
+
diff --git a/clang/test/SemaCXX/friend-out-of-line.cpp b/clang/test/SemaCXX/friend-out-of-line.cpp
new file mode 100644
index 0000000..56b2daa
--- /dev/null
+++ b/clang/test/SemaCXX/friend-out-of-line.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/10204947>
+namespace N {
+ class X;
+};
+
+class N::X {
+ template<typename T> friend const T& f(const X&);
+ friend const int& g(const X&);
+ friend class Y;
+};
diff --git a/clang/test/SemaCXX/friend.cpp b/clang/test/SemaCXX/friend.cpp
new file mode 100644
index 0000000..c5b11eb
--- /dev/null
+++ b/clang/test/SemaCXX/friend.cpp
@@ -0,0 +1,140 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+friend class A; // expected-error {{'friend' used outside of class}}
+void f() { friend class A; } // expected-error {{'friend' used outside of class}}
+class C { friend class A; };
+class D { void f() { friend class A; } }; // expected-error {{'friend' used outside of class}}
+
+// PR5760
+namespace test0 {
+ namespace ns {
+ void f(int);
+ }
+
+ struct A {
+ friend void ns::f(int a);
+ };
+}
+
+// Test derived from LLVM's Registry.h
+namespace test1 {
+ template <class T> struct Outer {
+ void foo(T);
+ struct Inner {
+ friend void Outer::foo(T);
+ };
+ };
+
+ void test() {
+ (void) Outer<int>::Inner();
+ }
+}
+
+// PR5476
+namespace test2 {
+ namespace foo {
+ void Func(int x);
+ }
+
+ class Bar {
+ friend void ::test2::foo::Func(int x);
+ };
+}
+
+// PR5134
+namespace test3 {
+ class Foo {
+ friend const int getInt(int inInt = 0);
+
+ };
+}
+
+namespace test4 {
+ class T4A {
+ friend class T4B;
+
+ public:
+ T4A(class T4B *);
+
+ protected:
+ T4B *mB; // error here
+ };
+
+ class T4B {};
+}
+
+namespace rdar8529993 {
+struct A { ~A(); };
+
+struct B : A
+{
+ template<int> friend A::~A(); // expected-error {{destructor cannot be declared as a template}}
+};
+}
+
+// PR7915
+namespace test5 {
+ struct A;
+ struct A1 { friend void A(); };
+
+ struct B { friend void B(); };
+}
+
+// PR8479
+namespace test6_1 {
+ class A {
+ public:
+ private:
+ friend class vectorA;
+ A() {}
+ };
+ class vectorA {
+ public:
+ vectorA(int i, const A& t = A()) {}
+ };
+ void f() {
+ vectorA v(1);
+ }
+}
+namespace test6_2 {
+ template<class T>
+ class vector {
+ public:
+ vector(int i, const T& t = T()) {}
+ };
+ class A {
+ public:
+ private:
+ friend class vector<A>;
+ A() {}
+ };
+ void f() {
+ vector<A> v(1);
+ }
+}
+namespace test6_3 {
+ template<class T>
+ class vector {
+ public:
+ vector(int i) {}
+ void f(const T& t = T()) {}
+ };
+ class A {
+ public:
+ private:
+ friend void vector<A>::f(const A&);
+ A() {}
+ };
+ void f() {
+ vector<A> v(1);
+ v.f();
+ }
+}
+
+namespace test7 {
+ extern "C" {
+ class X {
+ friend int f() { return 42; }
+ };
+ }
+}
diff --git a/clang/test/SemaCXX/function-extern-c.cpp b/clang/test/SemaCXX/function-extern-c.cpp
new file mode 100644
index 0000000..f20cd38
--- /dev/null
+++ b/clang/test/SemaCXX/function-extern-c.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -Wreturn-type -fsyntax-only -std=c++11 -verify %s
+
+class A {
+public:
+ A(const A&);
+};
+
+struct S {
+ int i;
+ double d;
+
+ virtual void B() {}
+};
+
+union U {
+ struct {
+ int i;
+ virtual void B() {} // Can only do this in C++11
+ } t;
+};
+
+struct S2 {
+ int i;
+ double d;
+};
+
+extern "C" U f3( void ); // expected-warning {{'f3' has C-linkage specified, but returns user-defined type 'U' which is incompatible with C}}
+extern "C" S f0(void); // expected-warning {{'f0' has C-linkage specified, but returns user-defined type 'S' which is incompatible with C}}
+extern "C" A f4( void ); // expected-warning {{'f4' has C-linkage specified, but returns user-defined type 'A' which is incompatible with C}}
+
+// These should all be fine
+extern "C" S2 f5( void );
+extern "C" void f2( A x );
+extern "C" void f6( S s );
+extern "C" void f7( U u );
+extern "C" double f8(void);
+extern "C" long long f11( void );
+extern "C" A *f10( void );
diff --git a/clang/test/SemaCXX/function-overload-typo-crash.cpp b/clang/test/SemaCXX/function-overload-typo-crash.cpp
new file mode 100644
index 0000000..8c5cec8
--- /dev/null
+++ b/clang/test/SemaCXX/function-overload-typo-crash.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR10283
+void min(); //expected-note {{'min' declared here}}
+void min(int);
+
+template <typename T> void max(T); //expected-note {{'max' declared here}}
+
+void f() {
+ fin(); //expected-error {{use of undeclared identifier 'fin'; did you mean 'min'}}
+ fax(0); //expected-error {{use of undeclared identifier 'fax'; did you mean 'max'}}
+}
+
+template <typename T> void somefunc(T*, T*); //expected-note {{'somefunc' declared here}}
+template <typename T> void somefunc(const T[]); //expected-note {{'somefunc' declared here}}
+template <typename T1, typename T2> void somefunc(T1*, T2*); //expected-note {{'somefunc' declared here}}
+template <typename T1, typename T2> void somefunc(T1*, const T2[]); //expected-note 2 {{'somefunc' declared here}}
+
+void c() {
+ int *i = 0, *j = 0;
+ const int x[] = {1, 2, 3};
+ long *l = 0;
+ somefun(i, j); //expected-error {{use of undeclared identifier 'somefun'; did you mean 'somefunc'?}}
+ somefun(x); //expected-error {{use of undeclared identifier 'somefun'; did you mean 'somefunc'?}}
+ somefun(i, l); //expected-error {{use of undeclared identifier 'somefun'; did you mean 'somefunc'?}}
+ somefun(l, x); //expected-error {{use of undeclared identifier 'somefun'; did you mean 'somefunc'?}}
+ somefun(i, x); //expected-error {{use of undeclared identifier 'somefun'; did you mean 'somefunc'?}}
+}
diff --git a/clang/test/SemaCXX/function-overloaded-redecl.cpp b/clang/test/SemaCXX/function-overloaded-redecl.cpp
new file mode 100644
index 0000000..0077881
--- /dev/null
+++ b/clang/test/SemaCXX/function-overloaded-redecl.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef const int cInt;
+
+void f (int);
+void f (const int); // redecl
+
+void f (int) { } // expected-note {{previous definition is here}}
+void f (cInt) { } // expected-error {{redefinition of 'f'}}
+
diff --git a/clang/test/SemaCXX/function-redecl.cpp b/clang/test/SemaCXX/function-redecl.cpp
new file mode 100644
index 0000000..0eb109d
--- /dev/null
+++ b/clang/test/SemaCXX/function-redecl.cpp
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+int foo(int);
+
+namespace N {
+ void f1() {
+ void foo(int); // okay
+ }
+
+ // FIXME: we shouldn't even need this declaration to detect errors
+ // below.
+ void foo(int); // expected-note{{previous declaration is here}}
+
+ void f2() {
+ int foo(int); // expected-error{{functions that differ only in their return type cannot be overloaded}}
+
+ {
+ int foo;
+ {
+ // FIXME: should diagnose this because it's incompatible with
+ // N::foo. However, name lookup isn't properly "skipping" the
+ // "int foo" above.
+ float foo(int);
+ }
+ }
+ }
+}
+
+class A {
+ void typocorrection(); // expected-note {{'typocorrection' declared here}}
+};
+
+void A::Notypocorrection() { // expected-error {{out-of-line definition of 'Notypocorrection' does not match any declaration in 'A'; did you mean 'typocorrection'}}
+}
+
+
+namespace test0 {
+ void dummy() {
+ void Bar(); // expected-note {{'Bar' declared here}}
+ class A {
+ friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean 'Bar'}}
+ };
+ }
+}
+
+
+class B {
+ void typocorrection(const int); // expected-note {{'typocorrection' declared here}}
+ void typocorrection(double);
+};
+
+void B::Notypocorrection(int) { // expected-error {{out-of-line definition of 'Notypocorrection' does not match any declaration in 'B'; did you mean 'typocorrection'}}
+}
+
+struct X { int f(); };
+struct Y : public X {};
+int Y::f() { return 3; } // expected-error {{out-of-line definition of 'f' does not match any declaration in 'Y'}}
+
+namespace test1 {
+struct Foo {
+ class Inner { };
+};
+}
+
+class Bar {
+ void f(test1::Foo::Inner foo) const; // expected-note {{member declaration does not match because it is const qualified}}
+};
+
+using test1::Foo;
+
+void Bar::f(Foo::Inner foo) { // expected-error {{out-of-line definition of 'f' does not match any declaration in 'Bar'}}
+ (void)foo;
+}
+
+class Crash {
+ public:
+ void GetCart(int count) const;
+};
+// This out-of-line definition was fine...
+void Crash::cart(int count) const {} // expected-error {{out-of-line definition of 'cart' does not match any declaration in 'Crash'}} \
+ // expected-note {{'cart' declared here}} \
+ // expected-note {{previous definition is here}}
+// ...while this one crashed clang
+void Crash::chart(int count) const {} // expected-error {{out-of-line definition of 'chart' does not match any declaration in 'Crash'; did you mean 'cart'?}} \
+ // expected-error {{redefinition of 'cart'}}
+
+class TestConst {
+ public:
+ int getit() const; // expected-note {{member declaration does not match because it is const qualified}}
+ void setit(int); // expected-note {{member declaration does not match because it is not const qualified}}
+};
+
+int TestConst::getit() { // expected-error {{out-of-line definition of 'getit' does not match any declaration in 'TestConst'}}
+ return 1;
+}
+
+void TestConst::setit(int) const { // expected-error {{out-of-line definition of 'setit' does not match any declaration in 'TestConst'}}
+}
+
+struct J { int typo() const; };
+int J::typo_() { return 3; } // expected-error {{out-of-line definition of 'typo_' does not match any declaration in 'J'}}
diff --git a/clang/test/SemaCXX/function-type-qual.cpp b/clang/test/SemaCXX/function-type-qual.cpp
new file mode 100644
index 0000000..73613ae
--- /dev/null
+++ b/clang/test/SemaCXX/function-type-qual.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f() const; // expected-error {{non-member function cannot have 'const' qualifier}}
+void (*pf)() const; // expected-error {{pointer to function type cannot have 'const' qualifier}}
+extern void (&rf)() const; // expected-error {{reference to function type cannot have 'const' qualifier}}
+
+typedef void cfn() const;
+cfn f2; // expected-error {{non-member function of type 'cfn' (aka 'void () const') cannot have 'const' qualifier}}
+
+class C {
+ void f() const;
+ cfn f2;
+ static void f3() const; // expected-error {{static member function cannot have 'const' qualifier}}
+ static cfn f4; // expected-error {{static member function of type 'cfn' (aka 'void () const') cannot have 'const' qualifier}}
+
+ void m1() {
+ x = 0;
+ }
+
+ void m2() const {
+ x = 0; // expected-error {{read-only variable is not assignable}}
+ }
+
+ int x;
+};
+
+void (C::*mpf)() const;
+cfn C::*mpg;
diff --git a/clang/test/SemaCXX/functional-cast.cpp b/clang/test/SemaCXX/functional-cast.cpp
new file mode 100644
index 0000000..61e4da3
--- /dev/null
+++ b/clang/test/SemaCXX/functional-cast.cpp
@@ -0,0 +1,320 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// ------------ not interpreted as C-style cast ------------
+
+struct SimpleValueInit {
+ int i;
+};
+
+struct InitViaConstructor {
+ InitViaConstructor(int i = 7);
+};
+
+struct NoValueInit { // expected-note 2 {{candidate constructor (the implicit copy constructor)}}
+ NoValueInit(int i, int j); // expected-note 2 {{candidate constructor}}
+};
+
+void test_cxx_functional_value_init() {
+ (void)SimpleValueInit();
+ (void)InitViaConstructor();
+ (void)NoValueInit(); // expected-error{{no matching constructor for initialization}}
+}
+
+void test_cxx_function_cast_multi() {
+ (void)NoValueInit(0, 0);
+ (void)NoValueInit(0, 0, 0); // expected-error{{no matching constructor for initialization}}
+ (void)int(1, 2); // expected-error{{excess elements in scalar initializer}}
+}
+
+
+// ------------------ everything else --------------------
+
+struct A {};
+
+// ----------- const_cast --------------
+
+typedef char c;
+typedef c *cp;
+typedef cp *cpp;
+typedef cpp *cppp;
+typedef cppp &cpppr;
+typedef const cppp &cpppcr;
+typedef const char cc;
+typedef cc *ccp;
+typedef volatile ccp ccvp;
+typedef ccvp *ccvpp;
+typedef const volatile ccvpp ccvpcvp;
+typedef ccvpcvp *ccvpcvpp;
+typedef int iar[100];
+typedef iar &iarr;
+typedef int (*f)(int);
+
+void t_cc()
+{
+ ccvpcvpp var = 0;
+ // Cast away deep consts and volatiles.
+ char ***var2 = cppp(var);
+ char ***const &var3 = var2;
+ // Const reference to reference.
+ char ***&var4 = cpppr(var3);
+ // Drop reference. Intentionally without qualifier change.
+ char *** var5 = cppp(var4);
+ const int ar[100] = {0};
+ // Array decay. Intentionally without qualifier change.
+ typedef int *intp;
+ int *pi = intp(ar);
+ f fp = 0;
+ // Don't misidentify fn** as a function pointer.
+ typedef f *fp_t;
+ f *fpp = fp_t(&fp);
+ int const A::* const A::*icapcap = 0;
+ typedef int A::* A::*iapap_t;
+ iapap_t iapap = iapap_t(icapcap);
+}
+
+// ----------- static_cast -------------
+
+struct B : public A {}; // Single public base.
+struct C1 : public virtual B {}; // Single virtual base.
+struct C2 : public virtual B {};
+struct D : public C1, public C2 {}; // Diamond
+struct E : private A {}; // Single private base.
+struct F : public C1 {}; // Single path to B with virtual.
+struct G1 : public B {};
+struct G2 : public B {};
+struct H : public G1, public G2 {}; // Ambiguous path to B.
+
+enum Enum { En1, En2 };
+enum Onom { On1, On2 };
+
+struct Co1 { operator int(); };
+struct Co2 { Co2(int); };
+struct Co3 { };
+struct Co4 { Co4(Co3); operator Co3(); };
+
+// Explicit implicits
+void t_529_2()
+{
+ int i = 1;
+ (void)float(i);
+ double d = 1.0;
+ (void)float(d);
+ (void)int(d);
+ (void)char(i);
+ typedef unsigned long ulong;
+ (void)ulong(i);
+ (void)int(En1);
+ (void)double(En1);
+ typedef int &intr;
+ (void)intr(i);
+ typedef const int &cintr;
+ (void)cintr(i);
+
+ int ar[1];
+ typedef const int *cintp;
+ (void)cintp(ar);
+ typedef void (*pfvv)();
+ (void)pfvv(t_529_2);
+
+ typedef void *voidp;
+ (void)voidp(0);
+ (void)voidp((int*)0);
+ typedef volatile const void *vcvoidp;
+ (void)vcvoidp((const int*)0);
+ typedef A *Ap;
+ (void)Ap((B*)0);
+ typedef A &Ar;
+ (void)Ar(*((B*)0));
+ typedef const B *cBp;
+ (void)cBp((C1*)0);
+ typedef B &Br;
+ (void)Br(*((C1*)0));
+ (void)Ap((D*)0);
+ typedef const A &cAr;
+ (void)cAr(*((D*)0));
+ typedef int B::*Bmp;
+ (void)Bmp((int A::*)0);
+ typedef void (B::*Bmfp)();
+ (void)Bmfp((void (A::*)())0);
+ (void)Ap((E*)0); // functional-style cast ignores access control
+ (void)voidp((const int*)0); // const_cast appended
+
+ (void)int(Co1());
+ (void)Co2(1);
+ (void)Co3((Co4)(Co3()));
+
+ // Bad code below
+ //(void)(A*)((H*)0); // {{static_cast from 'struct H *' to 'struct A *' is not allowed}}
+}
+
+// Anything to void
+void t_529_4()
+{
+ void(1);
+ (void(t_529_4));
+}
+
+// Static downcasts
+void t_529_5_8()
+{
+ typedef B *Bp;
+ (void)Bp((A*)0);
+ typedef B &Br;
+ (void)Br(*((A*)0));
+ typedef const G1 *cG1p;
+ (void)cG1p((A*)0);
+ typedef const G1 &cG1r;
+ (void)cG1r(*((A*)0));
+ (void)Bp((const A*)0); // const_cast appended
+ (void)Br(*((const A*)0)); // const_cast appended
+ typedef E *Ep;
+ (void)Ep((A*)0); // access control ignored
+ typedef E &Er;
+ (void)Er(*((A*)0)); // access control ignored
+
+ // Bad code below
+
+ typedef C1 *C1p;
+ (void)C1p((A*)0); // expected-error {{cannot cast 'A *' to 'C1p' (aka 'C1 *') via virtual base 'B'}}
+ typedef C1 &C1r;
+ (void)C1r(*((A*)0)); // expected-error {{cannot cast 'A' to 'C1r' (aka 'C1 &') via virtual base 'B'}}
+ typedef D *Dp;
+ (void)Dp((A*)0); // expected-error {{cannot cast 'A *' to 'Dp' (aka 'D *') via virtual base 'B'}}
+ typedef D &Dr;
+ (void)Dr(*((A*)0)); // expected-error {{cannot cast 'A' to 'Dr' (aka 'D &') via virtual base 'B'}}
+ typedef H *Hp;
+ (void)Hp((A*)0); // expected-error {{ambiguous cast from base 'A' to derived 'H':\n struct A -> struct B -> struct G1 -> struct H\n struct A -> struct B -> struct G2 -> struct H}}
+ typedef H &Hr;
+ (void)Hr(*((A*)0)); // expected-error {{ambiguous cast from base 'A' to derived 'H':\n struct A -> struct B -> struct G1 -> struct H\n struct A -> struct B -> struct G2 -> struct H}}
+
+ // TODO: Test DR427. This requires user-defined conversions, though.
+}
+
+// Enum conversions
+void t_529_7()
+{
+ (void)Enum(1);
+ (void)Enum(1.0);
+ (void)Onom(En1);
+
+ // Bad code below
+
+ (void)Enum((int*)0); // expected-error {{functional-style cast from 'int *' to 'Enum' is not allowed}}
+}
+
+// Void pointer to object pointer
+void t_529_10()
+{
+ typedef int *intp;
+ (void)intp((void*)0);
+ typedef const A *cAp;
+ (void)cAp((void*)0);
+ (void)intp((const void*)0); // const_cast appended
+}
+
+// Member pointer upcast.
+void t_529_9()
+{
+ typedef int A::*Amp;
+ (void)Amp((int B::*)0);
+
+ // Bad code below
+ (void)Amp((int H::*)0); // expected-error {{ambiguous conversion from pointer to member of derived class 'H' to pointer to member of base class 'A':}}
+ (void)Amp((int F::*)0); // expected-error {{conversion from pointer to member of class 'F' to pointer to member of class 'A' via virtual base 'B' is not allowed}}
+}
+
+// -------- reinterpret_cast -----------
+
+enum test { testval = 1 };
+struct structure { int m; };
+typedef void (*fnptr)();
+
+// Test conversion between pointer and integral types, as in p3 and p4.
+void integral_conversion()
+{
+ typedef void *voidp;
+ void *vp = voidp(testval);
+ long l = long(vp);
+ typedef float *floatp;
+ (void)floatp(l);
+ fnptr fnp = fnptr(l);
+ (void)char(fnp); // expected-error {{cast from pointer to smaller type 'char' loses information}}
+ (void)long(fnp);
+}
+
+void pointer_conversion()
+{
+ int *p1 = 0;
+ typedef float *floatp;
+ float *p2 = floatp(p1);
+ typedef structure *structurep;
+ structure *p3 = structurep(p2);
+ typedef int **ppint;
+ typedef ppint *pppint;
+ ppint *deep = pppint(p3);
+ typedef fnptr fnptrp;
+ (void)fnptrp(deep);
+}
+
+void constness()
+{
+ int ***const ipppc = 0;
+ typedef int const *icp_t;
+ int const *icp = icp_t(ipppc);
+ typedef int *intp;
+ (void)intp(icp); // const_cast appended
+ typedef int const *const ** intcpcpp;
+ intcpcpp icpcpp = intcpcpp(ipppc); // const_cast appended
+ int *ip = intp(icpcpp);
+ (void)icp_t(ip);
+ typedef int const *const *const *intcpcpcp;
+ (void)intcpcpcp(ipppc);
+}
+
+void fnptrs()
+{
+ typedef int (*fnptr2)(int);
+ fnptr fp = 0;
+ (void)fnptr2(fp);
+ typedef void *voidp;
+ void *vp = voidp(fp);
+ (void)fnptr(vp);
+}
+
+void refs()
+{
+ long l = 0;
+ typedef char &charr;
+ char &c = charr(l);
+ // Bad: from rvalue
+ typedef int &intr;
+ (void)intr(&c); // expected-error {{functional-style cast from rvalue to reference type 'intr' (aka 'int &')}}
+}
+
+void memptrs()
+{
+ const int structure::*psi = 0;
+ typedef const float structure::*structurecfmp;
+ (void)structurecfmp(psi);
+ typedef int structure::*structureimp;
+ (void)structureimp(psi); // const_cast appended
+
+ void (structure::*psf)() = 0;
+ typedef int (structure::*structureimfp)();
+ (void)structureimfp(psf);
+
+ typedef void (structure::*structurevmfp)();
+ (void)structurevmfp(psi); // expected-error {{functional-style cast from 'const int structure::*' to 'structurevmfp' (aka 'void (structure::*)()') is not allowed}}
+ (void)structureimp(psf); // expected-error {{functional-style cast from 'void (structure::*)()' to 'structureimp' (aka 'int structure::*') is not allowed}}
+}
+
+// ---------------- misc ------------------
+
+void crash_on_invalid_1()
+{
+ typedef itn Typo; // expected-error {{unknown type name 'itn'}}
+ (void)Typo(1); // used to crash
+
+ typedef int &int_ref;
+ (void)int_ref(); // expected-error {{reference to type 'int' requires an initializer}}
+}
diff --git a/clang/test/SemaCXX/generic-selection.cpp b/clang/test/SemaCXX/generic-selection.cpp
new file mode 100644
index 0000000..c0a5d89
--- /dev/null
+++ b/clang/test/SemaCXX/generic-selection.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template <typename T, typename U = void*>
+struct A {
+ enum {
+ id = _Generic(T(), // expected-error {{controlling expression type 'char' not compatible with any generic association type}}
+ int: 1, // expected-note {{compatible type 'int' specified here}}
+ float: 2,
+ U: 3) // expected-error {{type 'int' in generic association compatible with previously specified type 'int'}}
+ };
+};
+
+static_assert(A<int>::id == 1, "fail");
+static_assert(A<float>::id == 2, "fail");
+static_assert(A<double, double>::id == 3, "fail");
+
+A<char> a1; // expected-note {{in instantiation of template class 'A<char, void *>' requested here}}
+A<short, int> a2; // expected-note {{in instantiation of template class 'A<short, int>' requested here}}
+
+template <typename T, typename U>
+struct B {
+ enum {
+ id = _Generic(T(),
+ int: 1, // expected-note {{compatible type 'int' specified here}}
+ int: 2, // expected-error {{type 'int' in generic association compatible with previously specified type 'int'}}
+ U: 3)
+ };
+};
+
+template <unsigned Arg, unsigned... Args> struct Or {
+ enum { result = Arg | Or<Args...>::result };
+};
+
+template <unsigned Arg> struct Or<Arg> {
+ enum { result = Arg };
+};
+
+template <class... Args> struct TypeMask {
+ enum {
+ result = Or<_Generic(Args(), int: 1, long: 2, short: 4, float: 8)...>::result
+ };
+};
+
+static_assert(TypeMask<int, long, short>::result == 7, "fail");
+static_assert(TypeMask<float, short>::result == 12, "fail");
+static_assert(TypeMask<int, float, float>::result == 9, "fail");
diff --git a/clang/test/SemaCXX/gnu-case-ranges.cpp b/clang/test/SemaCXX/gnu-case-ranges.cpp
new file mode 100644
index 0000000..b082e3a
--- /dev/null
+++ b/clang/test/SemaCXX/gnu-case-ranges.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -verify -Wno-covered-switch-default %s
+
+enum E {
+ one,
+ two,
+ three,
+ four
+};
+
+
+int test(enum E e)
+{
+ switch (e)
+ {
+ case one:
+ return 7;
+ case two ... two + 1:
+ return 42;
+ case four:
+ return 25;
+ default:
+ return 0;
+ }
+}
diff --git a/clang/test/SemaCXX/goto.cpp b/clang/test/SemaCXX/goto.cpp
new file mode 100644
index 0000000..24bcb7c
--- /dev/null
+++ b/clang/test/SemaCXX/goto.cpp
@@ -0,0 +1,127 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall -fblocks %s
+
+// PR9463
+double *end;
+void f(bool b1, bool b2) {
+ {
+ do {
+ int end = 0;
+ if (b2) {
+ do {
+ goto end;
+ } while (b2);
+ }
+ end = 1;
+ } while (b1);
+ }
+
+ end:
+ return;
+}
+
+namespace N {
+ float* end;
+ void f(bool b1, bool b2) {
+ {
+ do {
+ int end = 0;
+ if (b2) {
+ do {
+ goto end;
+ } while (b2);
+ }
+ end = 1;
+ } while (b1);
+ }
+
+ end:
+ return;
+ }
+}
+
+void g() {
+ end = 1; // expected-error{{assigning to 'double *' from incompatible type 'int'}}
+}
+
+void h(int end) {
+ {
+ goto end; // expected-error{{use of undeclared label 'end'}}
+ }
+}
+
+void h2(int end) {
+ {
+ __label__ end;
+ goto end;
+
+ end:
+ ::end = 0;
+ }
+ end: // expected-warning{{unused label 'end'}}
+ end = 1;
+}
+
+class X {
+public:
+ X();
+};
+
+void rdar9135994()
+{
+X:
+ goto X;
+}
+
+namespace PR9495 {
+ struct NonPOD { NonPOD(); ~NonPOD(); };
+
+ void f(bool b) {
+ NonPOD np;
+ if (b) {
+ goto undeclared; // expected-error{{use of undeclared label 'undeclared'}}
+ }
+ }
+
+ void g() {
+ (void)^(bool b){
+ NonPOD np;
+ if (b) {
+ goto undeclared; // expected-error{{use of undeclared label 'undeclared'}}
+ }
+ };
+ }
+}
+
+extern "C" {
+ void exit(int);
+}
+
+void f() {
+ {
+ goto exit;
+ }
+ exit:
+ return;
+}
+
+namespace PR10620 {
+ struct S {
+ ~S() {}
+ };
+ void g(const S& s) {
+ goto done; // expected-error {{goto into protected scope}}
+ const S s2(s); // expected-note {{jump bypasses variable initialization}}
+ done:
+ ;
+ }
+}
+
+namespace test12 {
+ struct A { A(); A(const A&); ~A(); };
+ void test(A a) { // expected-note {{jump enters lifetime of block}} FIXME: wierd location
+ goto lbl; // expected-error {{goto into protected scope}}
+ (void) ^{ (void) a; };
+ lbl:
+ return;
+ }
+}
diff --git a/clang/test/SemaCXX/goto2.cpp b/clang/test/SemaCXX/goto2.cpp
new file mode 100644
index 0000000..01ea031
--- /dev/null
+++ b/clang/test/SemaCXX/goto2.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+//PR9463
+int subfun(const char *text) {
+ const char *tmp = text;
+ return 0;
+}
+
+void fun(const char* text) {
+ int count = 0;
+ bool check = true;
+
+ if (check)
+ {
+ const char *end = text;
+
+ if (check)
+ {
+ do
+ {
+ if (check)
+ {
+ count = subfun(end);
+ goto end;
+ }
+
+ check = !check;
+ }
+ while (check);
+ }
+ // also works, after commenting following line of source code
+ int e = subfun(end);
+ }
+ end:
+ if (check)
+ ++count;
+}
+
+const char *text = "some text";
+
+int main() {
+ const char *ptr = text;
+
+ fun(ptr);
+
+ return 0;
+}
diff --git a/clang/test/SemaCXX/i-c-e-cxx.cpp b/clang/test/SemaCXX/i-c-e-cxx.cpp
new file mode 100644
index 0000000..5631577
--- /dev/null
+++ b/clang/test/SemaCXX/i-c-e-cxx.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+// C++-specific tests for integral constant expressions.
+
+const int c = 10;
+int ar[c];
+
+struct X0 {
+ static const int value = static_cast<int>(4.0);
+};
+
+void f() {
+ if (const int value = 17) {
+ int array[value];
+ }
+}
+
+int a() {
+ const int t=t; // expected-note {{declared here}}
+ switch(1) { // expected-warning {{no case matching constant switch condition '1'}}
+ case t:; // expected-error {{not an integral constant expression}} expected-note {{initializer of 't' is not a constant expression}}
+ }
+}
+
+// PR6206: out-of-line definitions are legit
+namespace pr6206 {
+ class Foo {
+ public:
+ static const int kBar;
+ };
+
+ const int Foo::kBar = 20;
+
+ char Test() {
+ char str[Foo::kBar];
+ str[0] = '0';
+ return str[0];
+ }
+}
+
+// PR6373: default arguments don't count.
+void pr6373(const unsigned x = 0) {
+ unsigned max = 80 / x;
+}
+
+
+// rdar://9204520
+namespace rdar9204520 {
+
+struct A {
+ static const int B = int(0.75 * 1000 * 1000); // expected-warning {{not a constant expression; folding it to a constant is a GNU extension}}
+};
+
+int foo() { return A::B; }
+}
+
+// PR11040
+const int x = 10;
+int* y = reinterpret_cast<const char&>(x); // expected-error {{cannot initialize}}
+
+// This isn't an integral constant expression, but make sure it folds anyway.
+struct PR8836 { char _; long long a; }; // expected-warning {{long long}}
+int PR8836test[(__typeof(sizeof(int)))&reinterpret_cast<const volatile char&>((((PR8836*)0)->a))]; // expected-warning {{folded to constant array as an extension}} expected-note {{cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
+
+const int nonconst = 1.0; // expected-note {{declared here}}
+int arr[nonconst]; // expected-warning {{folded to constant array as an extension}} expected-note {{initializer of 'nonconst' is not a constant expression}}
+const int castfloat = static_cast<int>(1.0);
+int arr2[castfloat]; // ok
diff --git a/clang/test/SemaCXX/illegal-member-initialization.cpp b/clang/test/SemaCXX/illegal-member-initialization.cpp
new file mode 100644
index 0000000..87069ef
--- /dev/null
+++ b/clang/test/SemaCXX/illegal-member-initialization.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {
+ A() : value(), cvalue() { } // expected-error {{reference to type 'int' requires an initializer}}
+ int &value;
+ const int cvalue;
+};
+
+struct B {
+};
+
+struct X {
+ X() { } // expected-error {{constructor for 'X' must explicitly initialize the reference member 'value'}} \
+ // expected-error {{constructor for 'X' must explicitly initialize the const member 'cvalue'}} \
+ // expected-error {{constructor for 'X' must explicitly initialize the reference member 'b'}} \
+ // expected-error {{constructor for 'X' must explicitly initialize the const member 'cb'}}
+ int &value; // expected-note{{declared here}}
+ const int cvalue; // expected-note{{declared here}}
+ B& b; // expected-note{{declared here}}
+ const B cb; // expected-note{{declared here}}
+};
+
+
+// PR5924
+struct bar {};
+bar xxx();
+
+struct foo {
+ foo_t a; // expected-error {{unknown type name 'foo_t'}}
+ foo() : a(xxx()) {} // no error here.
+};
diff --git a/clang/test/SemaCXX/implicit-exception-spec.cpp b/clang/test/SemaCXX/implicit-exception-spec.cpp
new file mode 100644
index 0000000..25316f8
--- /dev/null
+++ b/clang/test/SemaCXX/implicit-exception-spec.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -std=c++11 -Wall %s
+
+template<bool b> struct ExceptionIf { static int f(); };
+template<> struct ExceptionIf<false> { typedef int f; };
+
+// The exception specification of a defaulted default constructor depends on
+// the contents of in-class member initializers. However, the in-class member
+// initializers can depend on the exception specification of the constructor,
+// since the class is considered complete within them. We reject any such cases.
+namespace InClassInitializers {
+ // Noexcept::Noexcept() is implicitly declared as noexcept(false), because it
+ // directly invokes ThrowSomething(). However...
+ //
+ // If noexcept(Noexcept()) is false, then Noexcept() is a constant expression,
+ // so noexcept(Noexcept()) is true. But if noexcept(Noexcept()) is true, then
+ // Noexcept::Noexcept is not declared constexpr, therefore noexcept(Noexcept())
+ // is false.
+ bool ThrowSomething() noexcept(false);
+ struct ConstExpr {
+ bool b = noexcept(ConstExpr()) && ThrowSomething(); // expected-error {{exception specification is not available until end of class definition}}
+ };
+ // We can use it now.
+ bool w = noexcept(ConstExpr());
+
+ // Much more obviously broken: we can't parse the initializer without already
+ // knowing whether it produces a noexcept expression.
+ struct TemplateArg {
+ int n = ExceptionIf<noexcept(TemplateArg())>::f(); // expected-error {{exception specification is not available until end of class definition}}
+ };
+ bool x = noexcept(TemplateArg());
+
+ // And within a nested class.
+ struct Nested {
+ struct Inner {
+ int n = ExceptionIf<noexcept(Nested())>::f(); // expected-error {{exception specification is not available until end of class definition}}
+ } inner;
+ };
+ bool y = noexcept(Nested());
+ bool z = noexcept(Nested::Inner());
+}
+
+namespace ExceptionSpecification {
+ // A type is permitted to be used in a dynamic exception specification when it
+ // is still being defined, but isn't complete within such an exception
+ // specification.
+ struct Nested { // expected-note {{not complete}}
+ struct T {
+ T() noexcept(!noexcept(Nested())); // expected-error{{incomplete type}}
+ } t;
+ };
+}
+
+namespace DefaultArgument {
+ struct Default {
+ struct T {
+ T(int = ExceptionIf<noexcept(Default())::f()); // expected-error {{call to implicitly-deleted default constructor}}
+ } t; // expected-note {{has no default constructor}}
+ };
+}
+
+namespace ImplicitDtorExceptionSpec {
+ struct A {
+ virtual ~A();
+
+ struct Inner {
+ ~Inner() throw();
+ };
+ Inner inner;
+ };
+
+ struct B {
+ virtual ~B() {} // expected-note {{here}}
+ };
+
+ struct C : B {
+ virtual ~C() {}
+ A a;
+ };
+
+ struct D : B {
+ ~D(); // expected-error {{more lax than base}}
+ struct E {
+ ~E();
+ struct F {
+ ~F() throw(A);
+ } f;
+ } e;
+ };
+}
diff --git a/clang/test/SemaCXX/implicit-int.cpp b/clang/test/SemaCXX/implicit-int.cpp
new file mode 100644
index 0000000..9711adf
--- /dev/null
+++ b/clang/test/SemaCXX/implicit-int.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+x; // expected-error{{C++ requires a type specifier for all declarations}}
+
+f(int y) { return y; } // expected-error{{C++ requires a type specifier for all declarations}}
diff --git a/clang/test/SemaCXX/implicit-member-functions.cpp b/clang/test/SemaCXX/implicit-member-functions.cpp
new file mode 100644
index 0000000..8451739
--- /dev/null
+++ b/clang/test/SemaCXX/implicit-member-functions.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A { };
+A::A() { } // expected-error {{definition of implicitly declared default constructor}}
+
+struct B { };
+B::B(const B&) { } // expected-error {{definition of implicitly declared copy constructor}}
+
+struct C { };
+C& C::operator=(const C&) { return *this; } // expected-error {{definition of implicitly declared copy assignment operator}}
+
+struct D { };
+D::~D() { } // expected-error {{definition of implicitly declared destructor}}
+
+// Make sure that the special member functions are introduced for
+// name-lookup purposes and overload with user-declared
+// constructors and assignment operators.
+namespace PR6570 {
+ class A { };
+
+ class B {
+ public:
+ B() {}
+
+ B(const A& a) {
+ operator = (CONST);
+ operator = (a);
+ }
+
+ B& operator = (const A& a) {
+ return *this;
+ }
+
+ void f(const A &a) {
+ B b(a);
+ };
+
+ static const B CONST;
+ };
+
+}
+
+namespace PR7594 {
+ // If the lazy declaration of special member functions is triggered
+ // in an out-of-line initializer, make sure the functions aren't in
+ // the initializer scope. This used to crash Clang:
+ struct C {
+ C();
+ static C *c;
+ };
+ C *C::c = new C();
+}
diff --git a/clang/test/SemaCXX/implicit-virtual-member-functions.cpp b/clang/test/SemaCXX/implicit-virtual-member-functions.cpp
new file mode 100644
index 0000000..f6082e5
--- /dev/null
+++ b/clang/test/SemaCXX/implicit-virtual-member-functions.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct A {
+ virtual ~A();
+};
+
+struct B : A { // expected-error {{no suitable member 'operator delete' in 'B'}}
+ virtual void f();
+
+ void operator delete (void *, int); // expected-note {{'operator delete' declared here}}
+};
+
+void B::f() { // expected-note {{implicit default destructor for 'B' first required here}}
+}
+
+struct C : A { // expected-error {{no suitable member 'operator delete' in 'C'}}
+ C();
+ void operator delete(void *, int); // expected-note {{'operator delete' declared here}}
+};
+
+C::C() { } // expected-note {{implicit default destructor for 'C' first required here}}
+
+struct D : A { // expected-error {{no suitable member 'operator delete' in 'D'}}
+ void operator delete(void *, int); // expected-note {{'operator delete' declared here}}
+};
+
+void f() {
+ new D; // expected-note {{implicit default destructor for 'D' first required here}}
+}
+
diff --git a/clang/test/SemaCXX/incomplete-call.cpp b/clang/test/SemaCXX/incomplete-call.cpp
new file mode 100644
index 0000000..69eb03a
--- /dev/null
+++ b/clang/test/SemaCXX/incomplete-call.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct A; // expected-note 14 {{forward declaration of 'A'}}
+
+A f(); // expected-note {{'f' declared here}}
+
+struct B {
+ A f(); // expected-note {{'f' declared here}}
+ A operator()(); // expected-note 2 {{'operator()' declared here}}
+ operator A(); // expected-note {{'operator A' declared here}}
+ A operator!(); // expected-note 2 {{'operator!' declared here}}
+ A operator++(int); // expected-note {{'operator++' declared here}}
+ A operator[](int); // expected-note {{'operator[]' declared here}}
+ A operator+(int); // expected-note {{'operator+' declared here}}
+ A operator->(); // expected-note {{'operator->' declared here}}
+};
+
+void g() {
+ f(); // expected-error {{calling 'f' with incomplete return type 'A'}}
+
+ typedef A (*Func)();
+ Func fp;
+ fp(); // expected-error {{calling function with incomplete return type 'A'}}
+ ((Func)0)(); // expected-error {{calling function with incomplete return type 'A'}}
+
+ B b;
+ b.f(); // expected-error {{calling 'f' with incomplete return type 'A'}}
+
+ b.operator()(); // expected-error {{calling 'operator()' with incomplete return type 'A'}}
+ b.operator A(); // expected-error {{calling 'operator A' with incomplete return type 'A'}}
+ b.operator!(); // expected-error {{calling 'operator!' with incomplete return type 'A'}}
+
+ !b; // expected-error {{calling 'operator!' with incomplete return type 'A'}}
+ b(); // expected-error {{calling 'operator()' with incomplete return type 'A'}}
+ b++; // expected-error {{calling 'operator++' with incomplete return type 'A'}}
+ b[0]; // expected-error {{calling 'operator[]' with incomplete return type 'A'}}
+ b + 1; // expected-error {{calling 'operator+' with incomplete return type 'A'}}
+ b->f(); // expected-error {{calling 'operator->' with incomplete return type 'A'}}
+
+ A (B::*mfp)() = 0;
+ (b.*mfp)(); // expected-error {{calling function with incomplete return type 'A'}}
+
+}
+
+
+struct C; // expected-note{{forward declaration}}
+
+void test_incomplete_object_call(C& c) {
+ c(); // expected-error{{incomplete type in call to object of type}}
+}
diff --git a/clang/test/SemaCXX/increment-decrement.cpp b/clang/test/SemaCXX/increment-decrement.cpp
new file mode 100644
index 0000000..11b7d1e
--- /dev/null
+++ b/clang/test/SemaCXX/increment-decrement.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+volatile int i;
+
+const int &inc = i++;
+const int &dec = i--;
+
+const int &incfail = ++i; // expected-error {{drops qualifiers}}
+const int &decfail = --i; // expected-error {{drops qualifiers}}
+
+// PR7794
+void f0(int e) {
+ ++(int&)e;
+}
diff --git a/clang/test/SemaCXX/indirect-goto.cpp b/clang/test/SemaCXX/indirect-goto.cpp
new file mode 100644
index 0000000..5b3fac4
--- /dev/null
+++ b/clang/test/SemaCXX/indirect-goto.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace test1 {
+ // Make sure this doesn't crash.
+ struct A { ~A(); };
+ void a() { goto *(A(), &&L); L: return; }
+}
diff --git a/clang/test/SemaCXX/inherit.cpp b/clang/test/SemaCXX/inherit.cpp
new file mode 100644
index 0000000..a926c81
--- /dev/null
+++ b/clang/test/SemaCXX/inherit.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class A { };
+
+class B1 : A { };
+
+class B2 : virtual A { };
+
+class B3 : virtual virtual A { }; // expected-error{{duplicate 'virtual' in base specifier}}
+
+class C : public B1, private B2 { };
+
+
+class D; // expected-note {{forward declaration of 'D'}}
+
+class E : public D { }; // expected-error{{base class has incomplete type}}
+
+typedef int I;
+
+class F : public I { }; // expected-error{{base specifier must name a class}}
+
+union U1 : public A { }; // expected-error{{unions cannot have base classes}}
+
+union U2 {};
+
+class G : public U2 { }; // expected-error{{unions cannot be base classes}}
+
+typedef G G_copy;
+typedef G G_copy_2;
+typedef G_copy G_copy_3;
+
+class H : G_copy, A, G_copy_2, // expected-error{{base class 'G_copy' (aka 'G') specified more than once as a direct base class}}
+ public G_copy_3 { }; // expected-error{{base class 'G_copy' (aka 'G') specified more than once as a direct base class}}
diff --git a/clang/test/SemaCXX/init-priority-attr.cpp b/clang/test/SemaCXX/init-priority-attr.cpp
new file mode 100644
index 0000000..6facebf
--- /dev/null
+++ b/clang/test/SemaCXX/init-priority-attr.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class Two {
+private:
+ int i, j, k;
+public:
+ static int count;
+ Two( int ii, int jj ) { i = ii; j = jj; k = count++; };
+ Two( void ) { i = 0; j = 0; k = count++; };
+ int eye( void ) { return i; };
+ int jay( void ) { return j; };
+ int kay( void ) { return k; };
+};
+
+extern Two foo;
+extern Two goo;
+extern Two coo[];
+extern Two koo[];
+
+Two foo __attribute__((init_priority(101))) ( 5, 6 );
+
+Two goo __attribute__((init_priority(2,3))) ( 5, 6 ); // expected-error {{attribute takes one argument}}
+
+Two coo[2] __attribute__((init_priority(3))); // expected-error {{init_priority attribute requires integer constant between 101 and 65535 inclusive}}
+
+Two koo[4] __attribute__((init_priority(1.13))); // expected-error {{'init_priority' attribute requires integer constant}}
+
+
+Two func() __attribute__((init_priority(1001))); // expected-error {{can only use 'init_priority' attribute on file-scope definitions of objects of class type}}
+
+int i __attribute__((init_priority(1001))); // expected-error {{can only use 'init_priority' attribute on file-scope definitions of objects of class type}}
+
+int main() {
+ Two foo __attribute__((init_priority(1001))); // expected-error {{can only use 'init_priority' attribute on file-scope definitions of objects of class type}}
+}
+
diff --git a/clang/test/SemaCXX/inline.cpp b/clang/test/SemaCXX/inline.cpp
new file mode 100644
index 0000000..e569300
--- /dev/null
+++ b/clang/test/SemaCXX/inline.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check that we don't allow illegal uses of inline
+// (checking C++-only constructs here)
+struct c {inline int a;}; // expected-error{{'inline' can only appear on functions}}
diff --git a/clang/test/SemaCXX/instantiate-blocks.cpp b/clang/test/SemaCXX/instantiate-blocks.cpp
new file mode 100644
index 0000000..bb0f8d8
--- /dev/null
+++ b/clang/test/SemaCXX/instantiate-blocks.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s
+// rdar: // 6182276
+
+template <typename T, typename T1> void foo(T t, T1 r)
+{
+ T block_arg;
+ __block T1 byref_block_arg;
+
+ T1 (^block)(T) = ^ T1 (T arg) {
+ byref_block_arg = arg;
+ block_arg = arg; // expected-error {{variable is not assignable (missing __block type specifier)}}
+ return block_arg+arg; };
+}
+
+// rdar://10466373
+template <typename T, typename T1> void noret(T t, T1 r)
+{
+ (void) ^{
+ if (1)
+ return t;
+ else if (2)
+ return r; // expected-error {{return type 'double' must match previous return type 'float' when block literal has unspecified explicit return type}}
+ };
+}
+
+int main(void)
+{
+ foo(100, 'a'); // expected-note {{in instantiation of function template specialization 'foo<int, char>' requested here}}
+
+ noret((float)0.0, double(0.0)); // expected-note {{in instantiation of function template specialization 'noret<float, double>' requested here}}
+}
+
diff --git a/clang/test/SemaCXX/invalid-instantiated-field-decl.cpp b/clang/test/SemaCXX/invalid-instantiated-field-decl.cpp
new file mode 100644
index 0000000..8b26489
--- /dev/null
+++ b/clang/test/SemaCXX/invalid-instantiated-field-decl.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template <typename T>
+class SmallVectorImpl {
+public:
+ explicit SmallVectorImpl(unsigned N) {
+ }
+
+ ~SmallVectorImpl() { }
+
+};
+
+template <typename T, unsigned N>
+class SmallVector : public SmallVectorImpl<T> {
+ typedef typename SmallVectorImpl<T>::U U; // expected-error {{no type named 'U' in 'SmallVectorImpl<CallSite>'}}
+ enum {
+
+ MinUs = (static_cast<unsigned int>(sizeof(T))*N + // expected-error {{invalid application of 'sizeof' to an incomplete type 'CallSite'}}
+ static_cast<unsigned int>(sizeof(U)) - 1) /
+ static_cast<unsigned int>(sizeof(U)),
+ NumInlineEltsElts = MinUs
+ };
+ U InlineElts[NumInlineEltsElts];
+public:
+ SmallVector() : SmallVectorImpl<T>(NumInlineEltsElts) {
+ }
+
+};
+
+class CallSite; // expected-note {{forward declaration of 'CallSite'}}
+class InlineFunctionInfo {
+public:
+ explicit InlineFunctionInfo() {}
+ SmallVector<CallSite, 2> DevirtualizedCalls; // expected-note {{in instantiation of template class 'SmallVector<CallSite, 2>' requested}}
+};
diff --git a/clang/test/SemaCXX/invalid-member-expr.cpp b/clang/test/SemaCXX/invalid-member-expr.cpp
new file mode 100644
index 0000000..287d9af
--- /dev/null
+++ b/clang/test/SemaCXX/invalid-member-expr.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class X {};
+
+void test() {
+ X x;
+
+ x.int; // expected-error{{expected unqualified-id}}
+ x.~int(); // expected-error{{expected a class name}}
+ x.operator; // expected-error{{expected a type}}
+ x.operator typedef; // expected-error{{expected a type}} expected-error{{type name does not allow storage class}}
+}
+
+void test2() {
+ X *x;
+
+ x->int; // expected-error{{expected unqualified-id}}
+ x->~int(); // expected-error{{expected a class name}}
+ x->operator; // expected-error{{expected a type}}
+ x->operator typedef; // expected-error{{expected a type}} expected-error{{type name does not allow storage class}}
+}
+
+// PR6327
+namespace test3 {
+ template <class A, class B> struct pair {};
+
+ void test0() {
+ pair<int, int> z = minmax({}); // expected-error {{expected expression}}
+ }
+
+ struct string {
+ class iterator {};
+ };
+
+ void test1() {
+ string s;
+ string::iterator i = s.foo(); // expected-error {{no member named 'foo'}}
+ }
+}
diff --git a/clang/test/SemaCXX/invalid-template-specifier.cpp b/clang/test/SemaCXX/invalid-template-specifier.cpp
new file mode 100644
index 0000000..bcd6da7
--- /dev/null
+++ b/clang/test/SemaCXX/invalid-template-specifier.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// PR4809
+// This test is primarily checking that this doesn't crash, not the particular
+// diagnostics.
+
+const template basic_istream<char>; // expected-error {{expected unqualified-id}}
+
+namespace S {}
+template <class X> class Y {
+ void x() { S::template y<char>(1); } // expected-error {{does not refer to a template}} \
+ // expected-error {{unqualified-id}}
+};
diff --git a/clang/test/SemaCXX/issue547.cpp b/clang/test/SemaCXX/issue547.cpp
new file mode 100644
index 0000000..ab03a15
--- /dev/null
+++ b/clang/test/SemaCXX/issue547.cpp
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<typename T>
+struct classify_function {
+ static const unsigned value = 0;
+};
+
+template<typename R, typename ...Args>
+struct classify_function<R(Args...)> {
+ static const unsigned value = 1;
+};
+
+template<typename R, typename ...Args>
+struct classify_function<R(Args...) const> {
+ static const unsigned value = 2;
+};
+
+template<typename R, typename ...Args>
+struct classify_function<R(Args...) volatile> {
+ static const unsigned value = 3;
+};
+
+template<typename R, typename ...Args>
+struct classify_function<R(Args...) const volatile> {
+ static const unsigned value = 4;
+};
+
+template<typename R, typename ...Args>
+struct classify_function<R(Args......)> {
+ static const unsigned value = 5;
+};
+
+template<typename R, typename ...Args>
+struct classify_function<R(Args......) const> {
+ static const unsigned value = 6;
+};
+
+template<typename R, typename ...Args>
+struct classify_function<R(Args......) volatile> {
+ static const unsigned value = 7;
+};
+
+template<typename R, typename ...Args>
+struct classify_function<R(Args......) const volatile> {
+ static const unsigned value = 8;
+};
+
+template<typename R, typename ...Args>
+struct classify_function<R(Args......) &&> {
+ static const unsigned value = 9;
+};
+
+template<typename R, typename ...Args>
+struct classify_function<R(Args......) const &> {
+ static const unsigned value = 10;
+};
+
+typedef void f0(int) const;
+typedef void f1(int, float...) const volatile;
+typedef void f2(int, double, ...) &&;
+typedef void f3(int, double, ...) const &;
+
+int check0[classify_function<f0>::value == 2? 1 : -1];
+int check1[classify_function<f1>::value == 8? 1 : -1];
+int check2[classify_function<f2>::value == 9? 1 : -1];
+int check3[classify_function<f3>::value == 10? 1 : -1];
diff --git a/clang/test/SemaCXX/lambda-expressions.cpp b/clang/test/SemaCXX/lambda-expressions.cpp
new file mode 100644
index 0000000..e91dee9
--- /dev/null
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -0,0 +1,150 @@
+// RUN: %clang_cc1 -std=c++0x -Wno-unused-value -fsyntax-only -verify -fblocks %s
+
+namespace std { class type_info; };
+
+namespace ExplicitCapture {
+ class C {
+ int Member;
+
+ static void Overload(int);
+ void Overload();
+ virtual C& Overload(float);
+
+ void ImplicitThisCapture() {
+ [](){(void)Member;}; // expected-error {{'this' cannot be implicitly captured in this context}}
+ [&](){(void)Member;};
+
+ [this](){(void)Member;};
+ [this]{[this]{};};
+ []{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}}
+ []{Overload(3);};
+ []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}}
+ []{(void)typeid(Overload());};
+ []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}}
+ }
+ };
+
+ void f() {
+ [this] () {}; // expected-error {{'this' cannot be captured in this context}}
+ }
+}
+
+namespace ReturnDeduction {
+ void test() {
+ [](){ return 1; };
+ [](){ return 1; };
+ [](){ return ({return 1; 1;}); };
+ [](){ return ({return 'c'; 1;}); }; // expected-error {{must match previous return type}} \
+ // expected-warning{{omitted result type}}
+ []()->int{ return 'c'; return 1; };
+ [](){ return 'c'; return 1; }; // expected-error {{must match previous return type}}
+ []() { return; return (void)0; };
+ [](){ return 1; return 1; }; // expected-warning{{omitted result type}}
+ }
+}
+
+namespace ImplicitCapture {
+ void test() {
+ int a = 0; // expected-note 5 {{declared}}
+ []() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}}
+ [&]() { return a; };
+ [=]() { return a; };
+ [=]() { int* b = &a; }; // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const int *'}}
+ [=]() { return [&]() { return a; }; };
+ []() { return [&]() { return a; }; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
+ []() { return ^{ return a; }; };// expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
+ []() { return [&a] { return a; }; }; // expected-error 2 {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note 2 {{lambda expression begins here}}
+ [=]() { return [&a] { return a; }; }; //
+
+ const int b = 2;
+ []() { return b; };
+
+ union { // expected-note {{declared}}
+ int c;
+ float d;
+ };
+ d = 3;
+ [=]() { return c; }; // expected-error {{unnamed variable cannot be implicitly captured in a lambda expression}}
+
+ __block int e; // expected-note 3 {{declared}}
+ [&]() { return e; }; // expected-error {{__block variable 'e' cannot be captured in a lambda expression}}
+ [&e]() { return e; }; // expected-error 2 {{__block variable 'e' cannot be captured in a lambda expression}}
+
+ int f[10]; // expected-note {{declared}}
+ [&]() { return f[2]; };
+ (void) ^{ return []() { return f[2]; }; }; // expected-error {{variable 'f' cannot be implicitly captured in a lambda with no capture-default specified}} \
+ // expected-note{{lambda expression begins here}}
+
+ struct G { G(); G(G&); int a; }; // expected-note 6 {{not viable}}
+ G g;
+ [=]() { const G* gg = &g; return gg->a; }; // expected-warning{{omitted result type}}
+ [=]() { return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error {{no matching constructor for initialization of 'ImplicitCapture::G'}} \
+ // expected-warning{{omitted result type}}
+ (void)^{ return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error 2 {{no matching constructor for initialization of 'const ImplicitCapture::G'}} \
+ // expected-warning{{omitted result type}}
+
+ const int h = a; // expected-note {{declared}}
+ []() { return h; }; // expected-error {{variable 'h' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
+
+ // The exemption for variables which can appear in constant expressions
+ // applies only to objects (and not to references).
+ // FIXME: This might be a bug in the standard.
+ static int i;
+ constexpr int &ref_i = i; // expected-note {{declared}}
+ [] { return ref_i; }; // expected-error {{variable 'ref_i' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
+ }
+}
+
+namespace PR12031 {
+ struct X {
+ template<typename T>
+ X(const T&);
+ ~X();
+ };
+
+ void f(int i, X x);
+ void g() {
+ const int v = 10;
+ f(v, [](){});
+ }
+}
+
+namespace NullPtr {
+ int &f(int *p);
+ char &f(...);
+ void g() {
+ int n = 0;
+ [=] {
+ char &k = f(n); // not a null pointer constant
+ } ();
+
+ const int m = 0;
+ [=] {
+ int &k = f(m); // a null pointer constant
+ } ();
+
+ [=] () -> bool {
+ int &k = f(m); // a null pointer constant
+ return &m == 0;
+ } ();
+
+ [m] {
+ int &k = f(m); // a null pointer constant
+ } ();
+ }
+}
+
+void PR12248()
+{
+ unsigned int result = 0;
+ auto l = [&]() { ++result; };
+}
+
+namespace ModifyingCapture {
+ void test() {
+ int n = 0;
+ [=] {
+ n = 1; // expected-error {{cannot assign to a variable captured by copy in a non-mutable lambda}}
+ };
+ }
+}
diff --git a/clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp b/clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp
new file mode 100644
index 0000000..3ac2336
--- /dev/null
+++ b/clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+// This is a test for an egregious hack in Clang that works around
+// issues with GCC's evolution. libstdc++ 4.2.x uses __is_pod as an
+// identifier (to declare a struct template like the one below), while
+// GCC 4.3 and newer make __is_pod a keyword. Clang treats __is_pod as
+// a keyword *unless* it is introduced following the struct keyword.
+
+template<typename T>
+struct __is_pod {
+};
+
+__is_pod<int> ipi;
+
+// Ditto for __is_same.
+template<typename T>
+struct __is_same {
+};
+
+__is_same<int> isi;
+
+// Another, similar egregious hack for __is_signed, which is a type
+// trait in Embarcadero's compiler but is used as an identifier in
+// libstdc++.
+struct test_is_signed {
+ static const bool __is_signed = true;
+};
+
+bool check_signed = test_is_signed::__is_signed;
+
+#if __has_feature(is_pod)
+# error __is_pod won't work now anyway
+#endif
diff --git a/clang/test/SemaCXX/libstdcxx_map_base_hack.cpp b/clang/test/SemaCXX/libstdcxx_map_base_hack.cpp
new file mode 100644
index 0000000..a556281
--- /dev/null
+++ b/clang/test/SemaCXX/libstdcxx_map_base_hack.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+// libstdc++ 4.2.x contains a bug where a friend struct template
+// declaration for std::tr1::__detail::_Map base has different
+// template arguments than the real declaration. Clang has an
+// egregious hack to work around this problem, since we can't modify
+// all of the world's libstdc++'s.
+
+namespace std { namespace tr1 { namespace __detail {
+ template<typename _Key, typename _Value, typename _Ex, bool __unique,
+ typename _Hashtable>
+ struct _Map_base { };
+
+} } }
+
+namespace std { namespace tr1 {
+ template<typename T>
+ struct X1 {
+ template<typename _Key2, typename _Pair, typename _Hashtable>
+ friend struct __detail::_Map_base;
+ };
+
+} }
+
+std::tr1::X1<int> x1i;
diff --git a/clang/test/SemaCXX/linkage-spec.cpp b/clang/test/SemaCXX/linkage-spec.cpp
new file mode 100644
index 0000000..cb7e32c
--- /dev/null
+++ b/clang/test/SemaCXX/linkage-spec.cpp
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+extern "C" {
+ extern "C" void f(int);
+}
+
+extern "C++" {
+ extern "C++" int& g(int);
+ float& g();
+}
+double& g(double);
+
+void test(int x, double d) {
+ f(x);
+ float &f1 = g();
+ int& i1 = g(x);
+ double& d1 = g(d);
+}
+
+extern "C" int foo;
+extern "C" int foo;
+
+extern "C" const int bar;
+extern "C" int const bar;
+
+// <rdar://problem/6895431>
+extern "C" struct bar d;
+extern struct bar e;
+
+extern "C++" {
+ namespace N0 {
+ struct X0 {
+ int foo(int x) { return x; }
+ };
+ }
+}
+
+// PR5430
+namespace pr5430 {
+ extern "C" void func(void);
+}
+using namespace pr5430;
+extern "C" void pr5430::func(void) { }
+
+// PR5404
+int f2(char *)
+{
+ return 0;
+}
+
+extern "C"
+{
+ int f2(int)
+ {
+ return f2((char *)0);
+ }
+}
+
+// PR6991
+extern "C" typedef int (*PutcFunc_t)(int);
+
+
+// PR7859
+extern "C" void pr7859_a(int) {} // expected-note {{previous definition}}
+extern "C" void pr7859_a(int) {} // expected-error {{redefinition}}
+
+extern "C" void pr7859_b() {} // expected-note {{previous definition}}
+extern "C" void pr7859_b(int) {} // expected-error {{conflicting}}
+
+extern "C" void pr7859_c(short) {} // expected-note {{previous definition}}
+extern "C" void pr7859_c(int) {} // expected-error {{conflicting}}
+
+// <rdar://problem/8318976>
+extern "C" {
+ struct s0 {
+ private:
+ s0();
+ s0(const s0 &);
+ };
+}
+
+//PR7754
+extern "C++" template <class T> int pr7754(T param);
+
+namespace N {
+ int value;
+}
+
+extern "C++" using N::value;
+
+// PR7076
+extern "C" const char *Version_string = "2.9";
+
+namespace PR9162 {
+ extern "C" {
+ typedef struct _ArtsSink ArtsSink;
+ struct _ArtsSink {
+ int sink;
+ };
+ }
+ int arts_sink_get_type()
+ {
+ return sizeof(ArtsSink);
+ }
+}
diff --git a/clang/test/SemaCXX/linkage.cpp b/clang/test/SemaCXX/linkage.cpp
new file mode 100644
index 0000000..6b73d59
--- /dev/null
+++ b/clang/test/SemaCXX/linkage.cpp
@@ -0,0 +1,96 @@
+// This is an IR generation test because the calculation of visibility
+// during IR gen will cause linkage to be implicitly recomputed and
+// compared against the earlier cached value. If we had a way of
+// testing linkage directly in Sema, that would be better.
+
+// RUN: %clang_cc1 -Werror -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s
+
+// PR8926
+namespace test0 {
+ typedef struct {
+ void *foo() { return 0; }
+ } A;
+
+ // CHECK: define linkonce_odr i8* @_ZN5test01A3fooEv(
+
+ void test(A *a) {
+ a->foo();
+ }
+}
+
+namespace test1 {
+ typedef struct {
+ template <unsigned n> void *foo() { return 0; }
+
+ void foo() {
+ foo<0>();
+ }
+ } A;
+
+ // CHECK: define linkonce_odr void @_ZN5test11A3fooEv(
+ // another at the end
+
+ void test(A *a) {
+ a->foo();
+ }
+}
+
+namespace test2 {
+ typedef struct {
+ template <unsigned n> struct B {
+ void *foo() { return 0; }
+ };
+
+ void foo(B<0> *b) {
+ b->foo();
+ }
+ } A;
+
+ // CHECK: define linkonce_odr void @_ZN5test21A3fooEPNS0_1BILj0EEE(
+
+ void test(A *a) {
+ a->foo(0);
+ }
+}
+
+namespace test3 {
+ namespace { struct A {}; }
+
+ // CHECK: define internal void @_ZN5test34testENS_12_GLOBAL__N_11AE(
+ void test(A a) {}
+ void force() { test(A()); }
+
+ // CHECK: define void @test3(
+ extern "C" void test3(A a) {}
+}
+
+namespace {
+ // CHECK: define void @test4(
+ extern "C" void test4(void) {}
+}
+
+// PR9316: Ensure that even non-namespace-scope function declarations in
+// a C declaration context respect that over the anonymous namespace.
+extern "C" {
+ namespace {
+ struct X {
+ int f() {
+ extern int g();
+ extern int a;
+
+ // Test both for mangling in the code generation and warnings from use
+ // of internal, undefined names via -Werror.
+ // CHECK: call i32 @g(
+ // CHECK: load i32* @a,
+ return g() + a;
+ }
+ };
+ }
+ // Force the above function to be emitted by codegen.
+ int test(X& x) {
+ return x.f();
+ }
+}
+
+// CHECK: define linkonce_odr i8* @_ZN5test21A1BILj0EE3fooEv(
+// CHECK: define linkonce_odr i8* @_ZN5test11A3fooILj0EEEPvv(
diff --git a/clang/test/SemaCXX/literal-operators.cpp b/clang/test/SemaCXX/literal-operators.cpp
new file mode 100644
index 0000000..7f68cd3
--- /dev/null
+++ b/clang/test/SemaCXX/literal-operators.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+#include <stddef.h>
+
+struct tag {
+ void operator "" _tag_bad (const char *); // expected-error {{literal operator 'operator "" _tag_bad' must be in a namespace or global scope}}
+ friend void operator "" _tag_good (const char *);
+};
+
+namespace ns { void operator "" _ns_good (const char *); }
+
+// Check extern "C++" declarations
+extern "C++" void operator "" _extern_good (const char *);
+extern "C++" { void operator "" _extern_good (const char *); }
+
+void fn () { void operator "" _fn_good (const char *); }
+
+// One-param declarations (const char * was already checked)
+void operator "" _good (char);
+void operator "" _good (wchar_t);
+void operator "" _good (char16_t);
+void operator "" _good (char32_t);
+void operator "" _good (unsigned long long);
+void operator "" _good (long double);
+
+// Two-param declarations
+void operator "" _good (const char *, size_t);
+void operator "" _good (const wchar_t *, size_t);
+void operator "" _good (const char16_t *, size_t);
+void operator "" _good (const char32_t *, size_t);
+
+// Check typedef and array equivalences
+void operator "" _good (const char[]);
+typedef const char c;
+void operator "" _good (c*);
+
+// Check extra cv-qualifiers
+void operator "" _cv_good (volatile const char *, const size_t); // expected-error {{parameter declaration for literal operator 'operator "" _cv_good' is not valid}}
+
+// Template declaration
+template <char...> void operator "" _good ();
+
+// FIXME: Test some invalid decls that might crop up.
diff --git a/clang/test/SemaCXX/literal-type.cpp b/clang/test/SemaCXX/literal-type.cpp
new file mode 100644
index 0000000..14a4094
--- /dev/null
+++ b/clang/test/SemaCXX/literal-type.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+static_assert(__is_literal(int), "fail");
+static_assert(__is_literal_type(int), "fail"); // alternate spelling for GCC
+static_assert(__is_literal(void*), "fail");
+enum E { E1 };
+static_assert(__is_literal(E), "fail");
+static_assert(__is_literal(decltype(E1)), "fail");
+typedef int IAR[10];
+static_assert(__is_literal(IAR), "fail");
+typedef int Vector __attribute__((vector_size(16)));
+typedef int VectorExt __attribute__((ext_vector_type(4)));
+static_assert(__is_literal(Vector), "fail");
+static_assert(__is_literal(VectorExt), "fail");
+
+// C++0x [basic.types]p10:
+// A type is a literal type if it is:
+// [...]
+// -- a class type that has all of the following properties:
+// -- it has a trivial destructor
+// -- every constructor call and full-expression in the
+// brace-or-equal-initializers for non-static data members (if an) is
+// a constant expression,
+// -- it is an aggregate type or has at least one constexpr constructor
+// or constructor template that is not a copy or move constructor, and
+// [DR1452 adds class types with trivial default constructors to
+// this list]
+// -- it has all non-static data members and base classes of literal
+// types
+struct Empty {};
+struct LiteralType {
+ int x;
+ E e;
+ IAR arr;
+ Empty empty;
+ int method();
+};
+struct HasDtor { ~HasDtor(); };
+
+class NonAggregate { int x; };
+struct NonLiteral { NonLiteral(); };
+struct HasNonLiteralBase : NonLiteral {};
+struct HasNonLiteralMember { HasDtor x; };
+
+static_assert(__is_literal(Empty), "fail");
+static_assert(__is_literal(LiteralType), "fail");
+static_assert(__is_literal(NonAggregate), "fail");
+static_assert(!__is_literal(NonLiteral), "fail");
+static_assert(!__is_literal(HasDtor), "fail");
+static_assert(!__is_literal(HasNonLiteralBase), "fail");
+static_assert(!__is_literal(HasNonLiteralMember), "fail");
+
+// DR1361 removes the brace-or-equal-initializer bullet so that we can allow:
+extern int f(); // expected-note {{here}}
+struct HasNonConstExprMemInit {
+ int x = f(); // expected-note {{non-constexpr function}}
+ constexpr HasNonConstExprMemInit() {} // expected-error {{never produces a constant expression}}
+ constexpr HasNonConstExprMemInit(int y) : x(y) {} // ok
+};
+static_assert(__is_literal(HasNonConstExprMemInit), "fail");
+
+class HasConstExprCtor {
+ int x;
+public:
+ constexpr HasConstExprCtor(int x) : x(x) {}
+};
+template <typename T> class HasConstExprCtorTemplate {
+ T x;
+public:
+ template <typename U> constexpr HasConstExprCtorTemplate(U y) : x(y) {}
+};
+template <typename T> class HasConstExprCtorT {
+ constexpr HasConstExprCtorT(T) {}
+};
+static_assert(__is_literal(HasConstExprCtor), "fail");
+static_assert(__is_literal(HasConstExprCtorTemplate<int>), "fail");
+static_assert(__is_literal(HasConstExprCtorT<NonLiteral>), "fail");
diff --git a/clang/test/SemaCXX/local-classes.cpp b/clang/test/SemaCXX/local-classes.cpp
new file mode 100644
index 0000000..500b219
--- /dev/null
+++ b/clang/test/SemaCXX/local-classes.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR6382 {
+ int foo()
+ {
+ goto error;
+ {
+ struct BitPacker {
+ BitPacker() {}
+ };
+ BitPacker packer;
+ }
+
+ error:
+ return -1;
+ }
+}
+
+namespace PR6383 {
+ void test (bool gross)
+ {
+ struct compare_and_set
+ {
+ void operator() (const bool inner, const bool gross = false)
+ {
+ // the code
+ }
+ } compare_and_set2;
+
+ compare_and_set2 (false, gross);
+ }
+}
+
+namespace Templates {
+ template<int Value>
+ void f() {
+ struct Inner {
+ static int getValue() { return Value; }
+ };
+ }
+}
diff --git a/clang/test/SemaCXX/lookup-member.cpp b/clang/test/SemaCXX/lookup-member.cpp
new file mode 100644
index 0000000..c75b185
--- /dev/null
+++ b/clang/test/SemaCXX/lookup-member.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace A {
+ class String;
+};
+
+using A::String;
+class String;
+
+// rdar://8603569
+union value {
+char *String;
+};
diff --git a/clang/test/SemaCXX/member-class-11.cpp b/clang/test/SemaCXX/member-class-11.cpp
new file mode 100644
index 0000000..c230c53
--- /dev/null
+++ b/clang/test/SemaCXX/member-class-11.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct rdar9677163 {
+ struct Y { ~Y(); };
+ struct Z { ~Z(); };
+ Y::~Y() { } // expected-error{{non-friend class member '~Y' cannot have a qualified name}}
+ ~Z(); // expected-error{{expected the class name after '~' to name the enclosing class}}
+};
diff --git a/clang/test/SemaCXX/member-expr-anonymous-union.cpp b/clang/test/SemaCXX/member-expr-anonymous-union.cpp
new file mode 100644
index 0000000..6e35eb2
--- /dev/null
+++ b/clang/test/SemaCXX/member-expr-anonymous-union.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// PR5543
+
+struct A { int x; union { int* y; float* z; }; }; struct B : A {int a;};
+int* a(B* x) { return x->y; }
+
+struct x { union { int y; }; }; x y; template <int X> int f() { return X+y.y; }
+int g() { return f<2>(); }
+
diff --git a/clang/test/SemaCXX/member-expr-static.cpp b/clang/test/SemaCXX/member-expr-static.cpp
new file mode 100644
index 0000000..7ed60f7
--- /dev/null
+++ b/clang/test/SemaCXX/member-expr-static.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+typedef void (*thread_continue_t)();
+
+extern "C" {
+ extern void kernel_thread_start(thread_continue_t continuation);
+ extern void pure_c(void);
+}
+
+class _IOConfigThread {
+public:
+ static void main( void );
+};
+
+
+void foo( void ) {
+ kernel_thread_start(&_IOConfigThread::main);
+ kernel_thread_start((thread_continue_t)&_IOConfigThread::main);
+ kernel_thread_start(&pure_c);
+}
diff --git a/clang/test/SemaCXX/member-expr.cpp b/clang/test/SemaCXX/member-expr.cpp
new file mode 100644
index 0000000..dbddd1c
--- /dev/null
+++ b/clang/test/SemaCXX/member-expr.cpp
@@ -0,0 +1,159 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class X{
+public:
+ enum E {Enumerator}; // expected-note 2{{declared here}}
+ int f();
+ static int mem;
+ static float g();
+};
+
+void test(X* xp, X x) {
+ int i1 = x.f();
+ int i2 = xp->f();
+ x.E; // expected-error{{cannot refer to type member 'E' in 'X' with '.'}}
+ xp->E; // expected-error{{cannot refer to type member 'E' in 'X' with '->'}}
+ int i3 = x.Enumerator;
+ int i4 = xp->Enumerator;
+ x.mem = 1;
+ xp->mem = 2;
+ float f1 = x.g();
+ float f2 = xp->g();
+}
+
+struct A {
+ int f0;
+};
+struct B {
+ A *f0();
+};
+int f0(B *b) {
+ return b->f0->f0; // expected-error{{did you mean to call it with no arguments}}
+}
+
+int i;
+
+namespace C {
+ int i;
+}
+
+void test2(X *xp) {
+ xp->::i = 7; // expected-error{{qualified member access refers to a member in the global namespace}}
+ xp->C::i = 7; // expected-error{{qualified member access refers to a member in namespace 'C'}}
+}
+
+
+namespace test3 {
+ struct NamespaceDecl;
+
+ struct NamedDecl {
+ void *getIdentifier() const;
+ };
+
+ struct NamespaceDecl : NamedDecl {
+ bool isAnonymousNamespace() const {
+ return !getIdentifier();
+ }
+ };
+}
+
+namespace test4 {
+ class X {
+ protected:
+ template<typename T> void f(T);
+ };
+
+ class Y : public X {
+ public:
+ using X::f;
+ };
+
+ void test_f(Y y) {
+ y.f(17);
+ }
+}
+
+namespace test5 {
+ struct A {
+ template <class T> void foo();
+ };
+
+ void test0(int x) {
+ x.A::foo<int>(); // expected-error {{'int' is not a structure or union}}
+ }
+
+ void test1(A *x) {
+ x.A::foo<int>(); // expected-error {{'test5::A *' is a pointer}}
+ }
+
+ void test2(A &x) {
+ x->A::foo<int>(); // expected-error {{'test5::A' is not a pointer}}
+ }
+}
+
+namespace PR7508 {
+ struct A {
+ struct CleanupScope {};
+ void PopCleanupBlock(); // expected-note{{'PopCleanupBlock' declared here}}
+ };
+
+ void foo(A &a) {
+ a.PopCleanupScope(); // expected-error{{no member named 'PopCleanupScope' in 'PR7508::A'; did you mean 'PopCleanupBlock'?}}
+ }
+}
+
+namespace rdar8231724 {
+ namespace N {
+ template<typename T> struct X1;
+ int i;
+ }
+
+ struct X { };
+ struct Y : X { };
+
+ void f(Y *y) {
+ y->N::X1<int>; // expected-error{{'rdar8231724::N::X1' is not a member of class 'rdar8231724::Y'}}
+ }
+}
+
+namespace PR9025 {
+ struct S { int x; };
+ S fun(); // expected-note{{possible target for call}}
+ int fun(int i); // expected-note{{possible target for call}}
+ int g() {
+ return fun.x; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
+ }
+
+ S fun2(); // expected-note{{possible target for call}}
+ S fun2(int i); // expected-note{{possible target for call}}
+ int g2() {
+ return fun2.x; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
+ }
+
+ S fun3(int i=0); // expected-note{{possible target for call}}
+ int fun3(int i, int j); // expected-note{{possible target for call}}
+ int g3() {
+ return fun3.x; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
+ }
+
+ template <typename T> S fun4(); // expected-note{{possible target for call}}
+ int g4() {
+ return fun4.x; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
+ }
+
+ S fun5(int i); // expected-note{{possible target for call}}
+ S fun5(float f); // expected-note{{possible target for call}}
+ int g5() {
+ return fun5.x; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
+ }
+}
+
+namespace FuncInMemberExpr {
+ struct Vec { int size(); };
+ Vec fun1();
+ int test1() { return fun1.size(); } // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments}}
+ Vec *fun2();
+ int test2() { return fun2->size(); } // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments}}
+ Vec fun3(int x = 0);
+ int test3() { return fun3.size(); } // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments}}
+}
diff --git a/clang/test/SemaCXX/member-init.cpp b/clang/test/SemaCXX/member-init.cpp
new file mode 100644
index 0000000..c93c85b
--- /dev/null
+++ b/clang/test/SemaCXX/member-init.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -std=c++11 -Wall %s
+
+struct Bitfield {
+ int n : 3 = 7; // expected-error {{bitfield member cannot have an in-class initializer}}
+};
+
+int a;
+class NoWarning {
+ int &n = a;
+public:
+ int &GetN() { return n; }
+};
+
+bool b();
+int k;
+struct Recurse {
+ int &n = b() ? Recurse().n : k; // ok
+};
+
+struct UnknownBound {
+ int as[] = { 1, 2, 3 }; // expected-error {{array bound cannot be deduced from an in-class initializer}}
+ int bs[4] = { 4, 5, 6, 7 };
+ int cs[] = { 8, 9, 10 }; // expected-error {{array bound cannot be deduced from an in-class initializer}}
+};
+
+template<int n> struct T { static const int B; };
+template<> struct T<2> { template<int C, int D> using B = int; };
+const int C = 0, D = 0;
+struct S {
+ int as[] = { decltype(x)::B<C, D>(0) }; // expected-error {{array bound cannot be deduced from an in-class initializer}}
+ T<sizeof(as) / sizeof(int)> x; // expected-error {{requires a type specifier}}
+ // test that we handle invalid array bound deductions without crashing when the declarator name is itself invalid
+ operator int[](){}; // expected-error {{'operator int' cannot be the name of a variable or data member}} \
+ // expected-error {{array bound cannot be deduced from an in-class initializer}}
+};
+
+struct ThrowCtor { ThrowCtor(int) noexcept(false); };
+struct NoThrowCtor { NoThrowCtor(int) noexcept(true); };
+
+struct Throw { ThrowCtor tc = 42; };
+struct NoThrow { NoThrowCtor tc = 42; };
+
+static_assert(!noexcept(Throw()), "incorrect exception specification");
+static_assert(noexcept(NoThrow()), "incorrect exception specification");
+
+struct CheckExcSpec {
+ CheckExcSpec() noexcept(true) = default;
+ int n = 0;
+};
+struct CheckExcSpecFail {
+ CheckExcSpecFail() noexcept(true) = default; // expected-error {{exception specification of explicitly defaulted default constructor does not match the calculated one}}
+ ThrowCtor tc = 123;
+};
+
+struct TypedefInit {
+ typedef int A = 0; // expected-error {{illegal initializer}}
+};
+
+// PR10578 / <rdar://problem/9877267>
+namespace PR10578 {
+ template<typename T>
+ struct X {
+ X() {
+ T* x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
+ }
+ };
+
+ struct Y : X<int> {
+ Y();
+ };
+
+ Y::Y() try { // expected-note{{in instantiation of member function 'PR10578::X<int>::X' requested here}}
+ } catch(...) {
+ }
+}
diff --git a/clang/test/SemaCXX/member-location.cpp b/clang/test/SemaCXX/member-location.cpp
new file mode 100644
index 0000000..6f7e1f5
--- /dev/null
+++ b/clang/test/SemaCXX/member-location.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR4103: Make sure we have a location for the error
+class A {
+ float a(int *); // expected-note{{passing argument to parameter here}}
+ int b();
+};
+int A::b() { return a(a((int*)0)); } // expected-error {{cannot initialize a parameter of type 'int *' with an rvalue of type 'float'}}
+
diff --git a/clang/test/SemaCXX/member-name-lookup.cpp b/clang/test/SemaCXX/member-name-lookup.cpp
new file mode 100644
index 0000000..0149169
--- /dev/null
+++ b/clang/test/SemaCXX/member-name-lookup.cpp
@@ -0,0 +1,158 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct A {
+ int a; // expected-note 4{{member found by ambiguous name lookup}}
+ static int b;
+ static int c; // expected-note 2{{member found by ambiguous name lookup}}
+
+ enum E { enumerator };
+
+ typedef int type;
+
+ static void f(int);
+ void f(float); // expected-note 2{{member found by ambiguous name lookup}}
+
+ static void static_f(int);
+ static void static_f(double);
+};
+
+struct B : A {
+ int d; // expected-note 2{{member found by ambiguous name lookup}}
+
+ enum E2 { enumerator2 };
+
+ enum E3 { enumerator3 }; // expected-note 2{{member found by ambiguous name lookup}}
+};
+
+struct C : A {
+ int c; // expected-note 2{{member found by ambiguous name lookup}}
+ int d; // expected-note 2{{member found by ambiguous name lookup}}
+
+ enum E3 { enumerator3_2 }; // expected-note 2{{member found by ambiguous name lookup}}
+};
+
+struct D : B, C {
+ void test_lookup();
+};
+
+void test_lookup(D d) {
+ d.a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}}
+ (void)d.b; // okay
+ d.c; // expected-error{{member 'c' found in multiple base classes of different types}}
+ d.d; // expected-error{{member 'd' found in multiple base classes of different types}}
+ d.f(0); // expected-error{{non-static member 'f' found in multiple base-class subobjects of type 'A':}}
+ d.static_f(0); // okay
+
+ D::E e = D::enumerator; // okay
+ D::type t = 0; // okay
+
+ D::E2 e2 = D::enumerator2; // okay
+
+ D::E3 e3; // expected-error{{multiple base classes}}
+}
+
+void D::test_lookup() {
+ a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}}
+ (void)b; // okay
+ c; // expected-error{{member 'c' found in multiple base classes of different types}}
+ d; // expected-error{{member 'd' found in multiple base classes of different types}}
+ f(0); // expected-error{{non-static member 'f' found in multiple base-class subobjects of type 'A':}}
+ static_f(0); // okay
+
+ E e = enumerator; // okay
+ type t = 0; // okay
+
+ E2 e2 = enumerator2; // okay
+
+ E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}}
+}
+
+struct B2 : virtual A {
+ int d; // expected-note 2{{member found by ambiguous name lookup}}
+
+ enum E2 { enumerator2 };
+
+ enum E3 { enumerator3 }; // expected-note 2 {{member found by ambiguous name lookup}}
+};
+
+struct C2 : virtual A {
+ int c;
+ int d; // expected-note 2{{member found by ambiguous name lookup}}
+
+ enum E3 { enumerator3_2 }; // expected-note 2{{member found by ambiguous name lookup}}
+};
+
+struct D2 : B2, C2 {
+ void test_virtual_lookup();
+};
+
+struct F : A { };
+struct G : F, D2 {
+ void test_virtual_lookup();
+};
+
+void test_virtual_lookup(D2 d2, G g) {
+ (void)d2.a;
+ (void)d2.b;
+ (void)d2.c; // okay
+ d2.d; // expected-error{{member 'd' found in multiple base classes of different types}}
+ d2.f(0); // okay
+ d2.static_f(0); // okay
+
+ D2::E e = D2::enumerator; // okay
+ D2::type t = 0; // okay
+
+ D2::E2 e2 = D2::enumerator2; // okay
+
+ D2::E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}}
+
+ g.a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}}
+ g.static_f(0); // okay
+}
+
+void D2::test_virtual_lookup() {
+ (void)a;
+ (void)b;
+ (void)c; // okay
+ d; // expected-error{{member 'd' found in multiple base classes of different types}}
+ f(0); // okay
+ static_f(0); // okay
+
+ E e = enumerator; // okay
+ type t = 0; // okay
+
+ E2 e2 = enumerator2; // okay
+
+ E3 e3; // expected-error{{member 'E3' found in multiple base classes of different types}}
+}
+
+void G::test_virtual_lookup() {
+ a; // expected-error{{non-static member 'a' found in multiple base-class subobjects of type 'A':}}
+ static_f(0); // okay
+}
+
+
+struct HasMemberType1 {
+ struct type { }; // expected-note{{member found by ambiguous name lookup}}
+};
+
+struct HasMemberType2 {
+ struct type { }; // expected-note{{member found by ambiguous name lookup}}
+};
+
+struct HasAnotherMemberType : HasMemberType1, HasMemberType2 {
+ struct type { };
+};
+
+struct UsesAmbigMemberType : HasMemberType1, HasMemberType2 {
+ type t; // expected-error{{member 'type' found in multiple base classes of different types}}
+};
+
+struct X0 {
+ struct Inner {
+ static const int m;
+ };
+
+ static const int n = 17;
+};
+
+const int X0::Inner::m = n;
diff --git a/clang/test/SemaCXX/member-operator-expr.cpp b/clang/test/SemaCXX/member-operator-expr.cpp
new file mode 100644
index 0000000..ae5f8bb
--- /dev/null
+++ b/clang/test/SemaCXX/member-operator-expr.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class X {
+public:
+ int operator++();
+ operator int();
+};
+
+void test() {
+ X x;
+ int i;
+
+ i = x.operator++();
+ i = x.operator int();
+ x.operator--(); // expected-error{{no member named 'operator--'}}
+ x.operator float(); // expected-error{{no member named 'operator float'}}
+ x.operator; // expected-error{{expected a type}}
+}
+
+void test2() {
+ X *x;
+ int i;
+
+ i = x->operator++();
+ i = x->operator int();
+ x->operator--(); // expected-error{{no member named 'operator--'}}
+ x->operator float(); // expected-error{{no member named 'operator float'}}
+ x->operator; // expected-error{{expected a type}}
+}
diff --git a/clang/test/SemaCXX/member-pointer-ms.cpp b/clang/test/SemaCXX/member-pointer-ms.cpp
new file mode 100644
index 0000000..3b2d0fc
--- /dev/null
+++ b/clang/test/SemaCXX/member-pointer-ms.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -cxx-abi microsoft -fsyntax-only -verify %s
+
+// Test that we reject pointers to members of incomplete classes (for now)
+struct A; //expected-note{{forward declaration of 'A'}}
+int A::*pai1; //expected-error{{incomplete type 'A'}}
+
+// Test that we don't allow reinterpret_casts from pointers of one size to
+// pointers of a different size.
+struct A {};
+struct B {};
+struct C: A, B {};
+
+void (A::*paf)();
+void (C::*pcf)() = reinterpret_cast<void (C::*)()>(paf); //expected-error{{cannot reinterpret_cast from member pointer type}}
diff --git a/clang/test/SemaCXX/member-pointer-size.cpp b/clang/test/SemaCXX/member-pointer-size.cpp
new file mode 100644
index 0000000..3aa1eaf
--- /dev/null
+++ b/clang/test/SemaCXX/member-pointer-size.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify
+// RUN: %clang_cc1 -triple i686-unknown-unknown %s -fsyntax-only -verify
+#include <stddef.h>
+
+struct A;
+
+void f() {
+ int A::*dataMember;
+
+ int (A::*memberFunction)();
+
+ typedef int assert1[sizeof(dataMember) == sizeof(ptrdiff_t) ? 1 : -1];
+ typedef int assert2[sizeof(memberFunction) == sizeof(ptrdiff_t) * 2 ? 1 : -1];
+}
+
diff --git a/clang/test/SemaCXX/member-pointer.cpp b/clang/test/SemaCXX/member-pointer.cpp
new file mode 100644
index 0000000..4e8b4a8
--- /dev/null
+++ b/clang/test/SemaCXX/member-pointer.cpp
@@ -0,0 +1,314 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {};
+enum B { Dummy };
+namespace C {}
+struct D : A {};
+struct E : A {};
+struct F : D, E {};
+struct G : virtual D {};
+
+int A::*pdi1;
+int (::A::*pdi2);
+int (A::*pfi)(int);
+
+int B::*pbi; // expected-error {{expected a class or namespace}}
+int C::*pci; // expected-error {{'pci' does not point into a class}}
+void A::*pdv; // expected-error {{'pdv' declared as a member pointer to void}}
+int& A::*pdr; // expected-error {{'pdr' declared as a member pointer to a reference}}
+
+void f() {
+ // This requires tentative parsing.
+ int (A::*pf)(int, int);
+
+ // Implicit conversion to bool.
+ bool b = pdi1;
+ b = pfi;
+
+ // Conversion from null pointer constant.
+ pf = 0;
+ pf = __null;
+
+ // Conversion to member of derived.
+ int D::*pdid = pdi1;
+ pdid = pdi2;
+
+ // Fail conversion due to ambiguity and virtuality.
+ int F::*pdif = pdi1; // expected-error {{ambiguous conversion from pointer to member of base class 'A' to pointer to member of derived class 'F':}}
+ int G::*pdig = pdi1; // expected-error {{conversion from pointer to member of class 'A' to pointer to member of class 'G' via virtual base 'D' is not allowed}}
+
+ // Conversion to member of base.
+ pdi1 = pdid; // expected-error {{assigning to 'int A::*' from incompatible type 'int D::*'}}
+
+ // Comparisons
+ int (A::*pf2)(int, int);
+ int (D::*pf3)(int, int) = 0;
+ bool b1 = (pf == pf2); (void)b1;
+ bool b2 = (pf != pf2); (void)b2;
+ bool b3 = (pf == pf3); (void)b3;
+ bool b4 = (pf != 0); (void)b4;
+}
+
+struct TheBase
+{
+ void d();
+};
+
+struct HasMembers : TheBase
+{
+ int i;
+ void f();
+
+ void g();
+ void g(int);
+ static void g(double);
+};
+
+namespace Fake
+{
+ int i;
+ void f();
+}
+
+void g() {
+ HasMembers hm;
+
+ int HasMembers::*pmi = &HasMembers::i;
+ int *pni = &Fake::i;
+ int *pmii = &hm.i;
+
+ void (HasMembers::*pmf)() = &HasMembers::f;
+ void (*pnf)() = &Fake::f;
+ &hm.f; // expected-error {{cannot create a non-constant pointer to member function}}
+
+ void (HasMembers::*pmgv)() = &HasMembers::g;
+ void (HasMembers::*pmgi)(int) = &HasMembers::g;
+ void (*pmgd)(double) = &HasMembers::g;
+
+ void (HasMembers::*pmd)() = &HasMembers::d;
+}
+
+struct Incomplete;
+
+void h() {
+ HasMembers hm, *phm = &hm;
+
+ int HasMembers::*pi = &HasMembers::i;
+ hm.*pi = 0;
+ int i = phm->*pi;
+ (void)&(hm.*pi);
+ (void)&(phm->*pi);
+ (void)&((&hm)->*pi);
+
+ void (HasMembers::*pf)() = &HasMembers::f;
+ (hm.*pf)();
+ (phm->*pf)();
+
+ (void)(hm->*pi); // expected-error {{left hand operand to ->* must be a pointer to class compatible with the right hand operand, but is 'HasMembers'}}
+ (void)(phm.*pi); // expected-error {{left hand operand to .* must be a class compatible with the right hand operand, but is 'HasMembers *'}}
+ (void)(i.*pi); // expected-error {{left hand operand to .* must be a class compatible with the right hand operand, but is 'int'}}
+ int *ptr;
+ (void)(ptr->*pi); // expected-error {{left hand operand to ->* must be a pointer to class compatible with the right hand operand, but is 'int *'}}
+
+ int A::*pai = 0;
+ D d, *pd = &d;
+ (void)(d.*pai);
+ (void)(pd->*pai);
+ F f, *ptrf = &f;
+ (void)(f.*pai); // expected-error {{left hand operand to .* must be a class compatible with the right hand operand, but is 'F'}}
+ (void)(ptrf->*pai); // expected-error {{left hand operand to ->* must be a pointer to class compatible with the right hand operand, but is 'F *'}}
+
+ (void)(hm.*i); // expected-error {{pointer-to-member}}
+ (void)(phm->*i); // expected-error {{pointer-to-member}}
+
+ // Okay
+ Incomplete *inc;
+ int Incomplete::*pii = 0;
+ (void)(inc->*pii);
+}
+
+struct OverloadsPtrMem
+{
+ int operator ->*(const char *);
+};
+
+void i() {
+ OverloadsPtrMem m;
+ int foo = m->*"Awesome!";
+}
+
+namespace pr5985 {
+ struct c {
+ void h();
+ void f() {
+ void (c::*p)();
+ p = &h; // expected-error {{must explicitly qualify}}
+ p = &this->h; // expected-error {{cannot create a non-constant pointer to member function}}
+ p = &(*this).h; // expected-error {{cannot create a non-constant pointer to member function}}
+ }
+ };
+}
+
+namespace pr6783 {
+ struct Base {};
+ struct X; // expected-note {{forward declaration}}
+
+ int test1(int Base::* p2m, X* object)
+ {
+ return object->*p2m; // expected-error {{left hand operand to ->*}}
+ }
+}
+
+namespace PR7176 {
+ namespace base
+ {
+ struct Process
+ { };
+ struct Continuous : Process
+ {
+ bool cond();
+ };
+ }
+
+ typedef bool( base::Process::*Condition )();
+
+ void m()
+ { (void)(Condition) &base::Continuous::cond; }
+}
+
+namespace rdar8358512 {
+ // We can't call this with an overload set because we're not allowed
+ // to look into overload sets unless the parameter has some kind of
+ // function type.
+ template <class F> void bind(F f); // expected-note 12 {{candidate template ignored}}
+ template <class F, class T> void bindmem(F (T::*f)()); // expected-note 4 {{candidate template ignored}}
+ template <class F> void bindfn(F (*f)()); // expected-note 4 {{candidate template ignored}}
+
+ struct A {
+ void nonstat();
+ void nonstat(int);
+
+ void mixed();
+ static void mixed(int);
+
+ static void stat();
+ static void stat(int);
+
+ template <typename T> struct Test0 {
+ void test() {
+ bind(&nonstat); // expected-error {{no matching function for call}}
+ bind(&A::nonstat); // expected-error {{no matching function for call}}
+
+ bind(&mixed); // expected-error {{no matching function for call}}
+ bind(&A::mixed); // expected-error {{no matching function for call}}
+
+ bind(&stat); // expected-error {{no matching function for call}}
+ bind(&A::stat); // expected-error {{no matching function for call}}
+ }
+ };
+
+ template <typename T> struct Test1 {
+ void test() {
+ bindmem(&nonstat); // expected-error {{no matching function for call}}
+ bindmem(&A::nonstat);
+
+ bindmem(&mixed); // expected-error {{no matching function for call}}
+ bindmem(&A::mixed);
+
+ bindmem(&stat); // expected-error {{no matching function for call}}
+ bindmem(&A::stat); // expected-error {{no matching function for call}}
+ }
+ };
+
+ template <typename T> struct Test2 {
+ void test() {
+ bindfn(&nonstat); // expected-error {{no matching function for call}}
+ bindfn(&A::nonstat); // expected-error {{no matching function for call}}
+
+ bindfn(&mixed); // expected-error {{no matching function for call}}
+ bindfn(&A::mixed); // expected-error {{no matching function for call}}
+
+ bindfn(&stat);
+ bindfn(&A::stat);
+ }
+ };
+ };
+
+ template <class T> class B {
+ void nonstat();
+ void nonstat(int);
+
+ void mixed();
+ static void mixed(int);
+
+ static void stat();
+ static void stat(int);
+
+ // None of these can be diagnosed yet, because the arguments are
+ // still dependent.
+ void test0a() {
+ bind(&nonstat);
+ bind(&B::nonstat);
+
+ bind(&mixed);
+ bind(&B::mixed);
+
+ bind(&stat);
+ bind(&B::stat);
+ }
+
+ void test0b() {
+ bind(&nonstat); // expected-error {{no matching function for call}}
+ bind(&B::nonstat); // expected-error {{no matching function for call}}
+
+ bind(&mixed); // expected-error {{no matching function for call}}
+ bind(&B::mixed); // expected-error {{no matching function for call}}
+
+ bind(&stat); // expected-error {{no matching function for call}}
+ bind(&B::stat); // expected-error {{no matching function for call}}
+ }
+ };
+
+ template void B<int>::test0b(); // expected-note {{in instantiation}}
+}
+
+namespace PR9973 {
+ template<class R, class T> struct dm
+ {
+ typedef R T::*F;
+ F f_;
+ template<class U> int & call(U u)
+ { return u->*f_; } // expected-error{{reference to non-static member function must be called; did you mean to call it with no arguments?}} expected-error {{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'int'}}
+
+ template<class U> int operator()(U u)
+ { call(u); } // expected-note{{in instantiation of}}
+ };
+
+ template<class R, class T>
+ dm<R, T> mem_fn(R T::*) ;
+
+ struct test
+ { int nullary_v(); };
+
+ void f()
+ {
+ test* t;
+ mem_fn(&test::nullary_v)(t); // expected-note{{in instantiation of}}
+ }
+}
+
+namespace test8 {
+ struct A { int foo; };
+ int test1() {
+ // Verify that we perform (and check) an lvalue conversion on the operands here.
+ return (*((A**) 0)) // expected-warning {{indirection of non-volatile null pointer will be deleted}} expected-note {{consider}}
+ ->**(int A::**) 0; // expected-warning {{indirection of non-volatile null pointer will be deleted}} expected-note {{consider}}
+ }
+
+ int test2() {
+ // Verify that we perform (and check) an lvalue conversion on the operands here.
+ // TODO: the .* should itself warn about being a dereference of null.
+ return (*((A*) 0))
+ .**(int A::**) 0; // expected-warning {{indirection of non-volatile null pointer will be deleted}} expected-note {{consider}}
+ }
+}
diff --git a/clang/test/SemaCXX/member-pointers-2.cpp b/clang/test/SemaCXX/member-pointers-2.cpp
new file mode 100644
index 0000000..6c39282
--- /dev/null
+++ b/clang/test/SemaCXX/member-pointers-2.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+
+// Tests that Sema properly creates member-access expressions for
+// these instead of bare FieldDecls.
+
+struct Foo {
+ int myvalue;
+
+ // We have to override these to get something with an lvalue result.
+ int &operator++(int);
+ int &operator--(int);
+};
+
+struct Test0 {
+ Foo memfoo;
+ int memint;
+ int memarr[10];
+ Test0 *memptr;
+ struct MemClass { int a; } memstruct;
+ int &memfun();
+
+ void test() {
+ int *p;
+ p = &Test0::memfoo++;
+ p = &Test0::memfoo--;
+ p = &Test0::memarr[1];
+ p = &Test0::memptr->memint;
+ p = &Test0::memstruct.a;
+ p = &Test0::memfun();
+ }
+};
+
+void test0() {
+ Test0 mytest;
+ mytest.test();
+}
+
+namespace rdar9065289 {
+ typedef void (*FuncPtr)();
+ struct X0 { };
+
+ struct X1
+ {
+ X0* x0;
+ FuncPtr X0::*fptr;
+ };
+
+ void f(X1 p) {
+ (p.x0->*(p.fptr))();
+ }
+}
diff --git a/clang/test/SemaCXX/microsoft-cxx0x.cpp b/clang/test/SemaCXX/microsoft-cxx0x.cpp
new file mode 100644
index 0000000..3b9bbef
--- /dev/null
+++ b/clang/test/SemaCXX/microsoft-cxx0x.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wc++11-narrowing -Wmicrosoft -verify -fms-extensions -std=c++11
+
+
+struct A {
+ unsigned int a;
+};
+int b = 3;
+A var = { b }; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
diff --git a/clang/test/SemaCXX/missing-header.cpp b/clang/test/SemaCXX/missing-header.cpp
new file mode 100644
index 0000000..5b3915b
--- /dev/null
+++ b/clang/test/SemaCXX/missing-header.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include "not exist" // expected-error{{'not exist' file not found}}
+
+class AnalysisDeclContext {};
+static ControlFlowKind CheckFallThrough(AnalysisDeclContext &AC) {
+ if (const AsmStmt *AS = dyn_cast<AsmStmt>(S)) {}
+ bool NoReturnEdge = false;
+}
diff --git a/clang/test/SemaCXX/missing-members.cpp b/clang/test/SemaCXX/missing-members.cpp
new file mode 100644
index 0000000..529ba10
--- /dev/null
+++ b/clang/test/SemaCXX/missing-members.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+namespace A {
+ namespace B {
+ class C { };
+ struct S { };
+ union U { };
+ }
+}
+
+void f() {
+ A::B::i; // expected-error {{no member named 'i' in namespace 'A::B'}}
+ A::B::C::i; // expected-error {{no member named 'i' in 'A::B::C'}}
+ ::i; // expected-error {{no member named 'i' in the global namespace}}
+}
+
+namespace B {
+ class B { };
+}
+
+void g() {
+ A::B::D::E; // expected-error {{no member named 'D' in namespace 'A::B'}}
+ B::B::C::D; // expected-error {{no member named 'C' in 'B::B'}}
+ ::C::D; // expected-error {{no member named 'C' in the global namespace}}
+}
+
+int A::B::i = 10; // expected-error {{no member named 'i' in namespace 'A::B'}}
+int A::B::C::i = 10; // expected-error {{no member named 'i' in 'A::B::C'}}
+int A::B::S::i = 10; // expected-error {{no member named 'i' in 'A::B::S'}}
+int A::B::U::i = 10; // expected-error {{no member named 'i' in 'A::B::U'}}
+
+using A::B::D; // expected-error {{no member named 'D' in namespace 'A::B'}}
+
+struct S : A::B::C {
+ using A::B::C::f; // expected-error {{no member named 'f' in 'A::B::C'}}
+
+};
diff --git a/clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp b/clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp
new file mode 100644
index 0000000..83f8395
--- /dev/null
+++ b/clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp
@@ -0,0 +1,121 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions %s
+
+namespace fizbin { class Foobar {}; } // expected-note 2 {{'fizbin::Foobar' declared here}} \
+ // expected-note {{'Foobar' declared here}}
+Foobar *my_bar // expected-error{{unknown type name 'Foobar'; did you mean 'fizbin::Foobar'?}}
+ = new Foobar; // expected-error{{unknown type name 'Foobar'; did you mean 'fizbin::Foobar'?}}
+fizbin::Foobar *my_foo = new fizbin::FooBar; // expected-error{{no type named 'FooBar' in namespace 'fizbin'; did you mean 'Foobar'?}}
+
+namespace barstool { int toFoobar() { return 1; } } // expected-note 3 {{'barstool::toFoobar' declared here}}
+int Double(int x) { return x + x; }
+void empty() {
+ Double(toFoobar()); // expected-error{{use of undeclared identifier 'toFoobar'; did you mean 'barstool::toFoobar'?}}
+}
+
+namespace fizbin {
+ namespace baztool { bool toFoobar() { return true; } } // expected-note{{'fizbin::baztool' declared here}}
+ namespace nested { bool moreFoobar() { return true; } } // expected-note{{'fizbin::nested::moreFoobar' declared here}}
+ namespace nested { bool lessFoobar() { return true; } } // expected-note{{'fizbin::nested' declared here}} \
+ // expected-note{{'fizbin::nested::lessFoobar' declared here}}
+ class dummy { // expected-note 2 {{'fizbin::dummy' declared here}}
+ public:
+ static bool moreFoobar() { return false; } // expected-note{{'moreFoobar' declared here}}
+ };
+}
+void Check() { // expected-note{{'Check' declared here}}
+ if (toFoobar()) Double(7); // expected-error{{use of undeclared identifier 'toFoobar'; did you mean 'barstool::toFoobar'?}}
+ if (noFoobar()) Double(7); // expected-error{{use of undeclared identifier 'noFoobar'; did you mean 'barstool::toFoobar'?}}
+ if (moreFoobar()) Double(7); // expected-error{{use of undeclared identifier 'moreFoobar'; did you mean 'fizbin::nested::moreFoobar'}}
+ if (lessFoobar()) Double(7); // expected-error{{use of undeclared identifier 'lessFoobar'; did you mean 'fizbin::nested::lessFoobar'?}}
+ if (baztool::toFoobar()) Double(7); // expected-error{{use of undeclared identifier 'baztool'; did you mean 'fizbin::baztool'?}}
+ if (nested::moreFoobar()) Double(7); // expected-error{{use of undeclared identifier 'nested'; did you mean 'fizbin::nested'?}}
+ if (dummy::moreFoobar()) Double(7); // expected-error{{use of undeclared identifier 'dummy'; did you mean 'fizbin::dummy'?}}
+ if (dummy::mreFoobar()) Double(7); // expected-error{{use of undeclared identifier 'dummy'; did you mean 'fizbin::dummy'?}} \
+ // expected-error{{no member named 'mreFoobar' in 'fizbin::dummy'; did you mean 'moreFoobar'?}}
+ if (moFoobin()) Double(7); // expected-error{{use of undeclared identifier 'moFoobin'}}
+}
+
+void Alt() {
+ Cleck(); // expected-error{{use of undeclared identifier 'Cleck'; did you mean 'Check'?}}
+}
+
+namespace N {
+ namespace inner {
+ class myvector { /* ... */ }; // expected-note{{'inner::myvector' declared here}}
+ }
+
+ void f() {
+ myvector v; // expected-error{{unknown type name 'myvector'; did you mean 'inner::myvector'?}}
+ }
+}
+
+namespace realstd {
+ inline namespace __1 {
+ class mylinkedlist { /* ... */ }; // expected-note 2 {{'realstd::mylinkedlist' declared here}}
+ }
+
+ class linkedlist { /* ... */ };
+}
+
+void f() {
+ mylinkedlist v; // expected-error{{unknown type name 'mylinkedlist'; did you mean 'realstd::mylinkedlist'?}}
+ nylinkedlist w; // expected-error{{unknown type name 'nylinkedlist'; did you mean 'realstd::mylinkedlist'?}}
+}
+
+// Test case from http://llvm.org/bugs/show_bug.cgi?id=10318
+namespace llvm {
+ template <typename T> class GraphWriter {}; // expected-note 3{{declared here}}
+}
+
+struct S {};
+void bar() {
+ GraphWriter<S> x; //expected-error{{no template named 'GraphWriter'; did you mean 'llvm::GraphWriter'?}}
+ (void)new llvm::GraphWriter; // expected-error {{use of class template llvm::GraphWriter requires template arguments}}
+ (void)new llvm::Graphwriter<S>; // expected-error {{no template named 'Graphwriter' in namespace 'llvm'; did you mean 'GraphWriter'?}}
+}
+
+// If namespace prefixes and character edits have the same weight, correcting
+// "fimish" to "N::famish" would have the same edit distance as correcting
+// "fimish" to "Finish". The result would be no correction being suggested
+// unless one of the corrections is given precedence (e.g. by filtering out
+// suggestions with added namespace qualifiers).
+namespace N { void famish(int); }
+void Finish(int); // expected-note {{'Finish' declared here}}
+void Start() {
+ fimish(7); // expected-error {{use of undeclared identifier 'fimish'; did you mean 'Finish'?}}
+}
+
+// But just eliminating the corrections containing added namespace qualifiers
+// won't work if both of the tied corrections have namespace qualifiers added.
+namespace N {
+void someCheck(int); // expected-note {{'N::someCheck' declared here}}
+namespace O { void somechock(int); }
+}
+void confusing() {
+ somechick(7); // expected-error {{use of undeclared identifier 'somechick'; did you mean 'N::someCheck'?}}
+}
+
+
+class Message {};
+namespace extra {
+ namespace util {
+ namespace MessageUtils {
+ bool Equivalent(const Message&, const Message&); // expected-note {{'extra::util::MessageUtils::Equivalent' declared here}} \
+ // expected-note {{'::extra::util::MessageUtils::Equivalent' declared here}}
+ }
+ }
+}
+namespace util { namespace MessageUtils {} }
+bool nstest () {
+ Message a, b;
+ return util::MessageUtils::Equivalent(a, b); // expected-error {{no member named 'Equivalent' in namespace 'util::MessageUtils'; did you mean 'extra::util::MessageUtils::Equivalent'?}}
+}
+
+namespace util {
+ namespace extra {
+ bool nstest () {
+ Message a, b;
+ return MessageUtils::Equivalent(a, b); // expected-error {{no member named 'Equivalent' in namespace 'util::MessageUtils'; did you mean '::extra::util::MessageUtils::Equivalent'?}}
+ }
+ }
+}
diff --git a/clang/test/SemaCXX/ms-exception-spec.cpp b/clang/test/SemaCXX/ms-exception-spec.cpp
new file mode 100644
index 0000000..bda56f5
--- /dev/null
+++ b/clang/test/SemaCXX/ms-exception-spec.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions
+
+void f() throw(...) { }
diff --git a/clang/test/SemaCXX/namespace-alias.cpp b/clang/test/SemaCXX/namespace-alias.cpp
new file mode 100644
index 0000000..e18b58b
--- /dev/null
+++ b/clang/test/SemaCXX/namespace-alias.cpp
@@ -0,0 +1,127 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace N { struct X { }; };
+
+namespace A = N;
+
+int B; // expected-note {{previous definition is here}}
+namespace B = N; // expected-error {{redefinition of 'B' as different kind of symbol}}
+
+namespace C { } // expected-note {{previous definition is here}}
+namespace C = N; // expected-error {{redefinition of 'C'}}
+
+int i;
+namespace D =
+i; // expected-error {{expected namespace name}}
+
+namespace E1 = N::
+Foo; // expected-error {{expected namespace name}}
+namespace E2 = N::
+X; // expected-error {{expected namespace name}}
+
+namespace F {
+ namespace A { namespace B { } } // expected-note {{candidate found by name lookup is 'F::A::B'}}
+ namespace B { } // expected-note {{candidate found by name lookup is 'F::B'}}
+ using namespace A;
+ namespace D = B; // expected-error {{reference to 'B' is ambiguous}}
+}
+
+namespace G {
+ namespace B = N;
+}
+
+namespace H {
+ namespace A1 { }
+ namespace A2 { }
+
+ // These all point to A1.
+ namespace B = A1; // expected-note {{previous definition is here}}
+ namespace B = A1;
+ namespace C = B;
+ namespace B = C;
+
+ namespace B = A2; // expected-error {{redefinition of 'B' as different kind of symbol}}
+}
+
+namespace I {
+ namespace A1 { int i; }
+
+ namespace A2 = A1;
+}
+
+int f() {
+ return I::A2::i;
+}
+
+namespace J {
+ namespace A {
+ namespace B { void func (); }
+ }
+
+ namespace C = A;
+
+ using namespace C::B;
+
+ void g() {
+ func();
+ }
+}
+
+namespace K {
+ namespace KA { void func(); }
+
+ void f() {
+ namespace KB = KA;
+ KB::func();
+ }
+
+ template <class T> void g() {
+ namespace KC = KA;
+ KC::func();
+ }
+ template void g<int>();
+ template void g<long>();
+
+ void h() {
+ KB::func(); // expected-error {{undeclared identifier 'KB'}}
+ KC::func(); // expected-error {{undeclared identifier 'KC'}}
+ }
+}
+
+namespace {
+ class C1;
+}
+namespace {
+ class C1;
+}
+C1 *pc1 = 0;
+
+namespace N {
+ namespace {
+ class C2;
+ }
+}
+namespace N {
+ namespace {
+ class C2;
+ }
+}
+N::C2 *pc2 = 0;
+
+// PR6341
+namespace A = N;
+namespace N { }
+namespace A = N;
+
+A::X nx;
+
+namespace PR7014 {
+ namespace X
+ {
+ namespace Y {}
+ }
+
+ using namespace X;
+
+ namespace Y = X::Y;
+}
diff --git a/clang/test/SemaCXX/namespace.cpp b/clang/test/SemaCXX/namespace.cpp
new file mode 100644
index 0000000..d47b707
--- /dev/null
+++ b/clang/test/SemaCXX/namespace.cpp
@@ -0,0 +1,92 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+namespace A { // expected-note 2 {{previous definition is here}}
+ int A;
+ void f() { A = 0; }
+}
+
+void f() { A = 0; } // expected-error {{unexpected namespace name 'A': expected expression}}
+int A; // expected-error {{redefinition of 'A' as different kind of symbol}}
+class A; // expected-error {{redefinition of 'A' as different kind of symbol}}
+
+class B {}; // expected-note {{previous definition is here}} \
+ // expected-note{{candidate function (the implicit copy assignment operator)}}
+
+void C(); // expected-note {{previous definition is here}}
+namespace C {} // expected-error {{redefinition of 'C' as different kind of symbol}}
+
+namespace D {
+ class D {};
+}
+
+namespace S1 {
+ int x;
+
+ namespace S2 {
+
+ namespace S3 {
+ B x;
+ }
+ }
+}
+
+namespace S1 {
+ void f() {
+ x = 0;
+ }
+
+ namespace S2 {
+
+ namespace S3 {
+ void f() {
+ x = 0; // expected-error {{no viable overloaded '='}}
+ }
+ }
+
+ int y;
+ }
+}
+
+namespace S1 {
+ namespace S2 {
+ namespace S3 {
+ void f3() {
+ y = 0;
+ }
+ }
+ }
+}
+
+namespace B {} // expected-error {{redefinition of 'B' as different kind of symbol}}
+
+
+namespace foo {
+ enum x {
+ Y
+ };
+}
+
+static foo::x test1; // ok
+
+static foo::X test2; // typo: expected-error {{no type named 'X' in}}
+
+namespace PR6620 {
+ namespace numeric {
+ namespace op {
+ struct greater {};
+ }
+ namespace {
+ extern op::greater const greater;
+ }
+ }
+
+ namespace numeric {
+ namespace {
+ op::greater const greater = op::greater();
+ }
+
+ template<typename T, typename U>
+ int f(T& l, U& r)
+ { numeric::greater(l, r); }
+
+ }
+}
diff --git a/clang/test/SemaCXX/neon-vector-types.cpp b/clang/test/SemaCXX/neon-vector-types.cpp
new file mode 100644
index 0000000..aa82b11
--- /dev/null
+++ b/clang/test/SemaCXX/neon-vector-types.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://9208404
+
+typedef int MP4Err;
+typedef float Float32;
+typedef float float32_t;
+typedef __attribute__((neon_vector_type(4))) float32_t float32x4_t;
+typedef float vFloat __attribute__((__vector_size__(16)));
+typedef vFloat VFLOAT;
+typedef unsigned long UInt32;
+
+extern int bar (float32x4_t const *p);
+
+int foo (const Float32 *realBufPtr) {
+ float32x4_t const *vRealPtr = (VFLOAT *)&realBufPtr[0];
+ return bar(vRealPtr);
+}
+
+MP4Err autoCorrelation2nd_Neon(Float32 *alphar, Float32 *alphai,
+ const Float32 *realBufPtr,
+ const Float32 *imagBufPtr,
+ const UInt32 len)
+{
+ float32x4_t const *vRealPtr = (VFLOAT *)&realBufPtr[0];
+ return 0;
+}
+
diff --git a/clang/test/SemaCXX/nested-name-spec-locations.cpp b/clang/test/SemaCXX/nested-name-spec-locations.cpp
new file mode 100644
index 0000000..048d4ba
--- /dev/null
+++ b/clang/test/SemaCXX/nested-name-spec-locations.cpp
@@ -0,0 +1,162 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Note: the formatting in this test case is intentionally funny, with
+// nested-name-specifiers stretched out vertically so that we can
+// match up diagnostics per-line and still verify that we're getting
+// good source-location information.
+
+namespace outer {
+ namespace inner {
+ template<typename T>
+ struct X0 {
+ };
+ }
+}
+
+template<typename T>
+struct add_reference {
+ typedef T& type;
+};
+
+namespace outer_alias = outer;
+
+template<typename T>
+struct UnresolvedUsingValueDeclTester {
+ using outer::inner::X0<
+ typename add_reference<T>::type
+ * // expected-error{{declared as a pointer to a reference of type}}
+ >::value;
+};
+
+UnresolvedUsingValueDeclTester<int> UnresolvedUsingValueDeclCheck; // expected-note{{in instantiation of template class}}
+
+template<typename T>
+struct UnresolvedUsingTypenameDeclTester {
+ using outer::inner::X0<
+ typename add_reference<T>::type
+ * // expected-error{{declared as a pointer to a reference of type}}
+ >::value;
+};
+
+UnresolvedUsingTypenameDeclTester<int> UnresolvedUsingTypenameDeclCheck; // expected-note{{in instantiation of template class}}
+
+
+template<typename T, typename U>
+struct PseudoDestructorExprTester {
+ void f(T *t) {
+ t->T::template Inner<typename add_reference<U>::type
+ * // expected-error{{as a pointer to a reference of type}}
+ >::Blarg::~Blarg();
+ }
+};
+
+struct HasInnerTemplate {
+ template<typename T>
+ struct Inner;
+
+ typedef HasInnerTemplate T;
+};
+
+void PseudoDestructorExprCheck(
+ PseudoDestructorExprTester<HasInnerTemplate, float> tester) {
+ tester.f(0); // expected-note{{in instantiation of member function}}
+}
+
+template<typename T>
+struct DependentScopedDeclRefExpr {
+ void f() {
+ outer_alias::inner::X0<typename add_reference<T>::type
+ * // expected-error{{as a pointer to a reference of type}}
+ >::value = 17;
+ }
+};
+
+void DependentScopedDeclRefExprCheck(DependentScopedDeclRefExpr<int> t) {
+ t.f(); // expected-note{{in instantiation of member function}}
+}
+
+
+template<typename T>
+struct TypenameTypeTester {
+ typedef typename outer::inner::X0<
+ typename add_reference<T>::type
+ * // expected-error{{declared as a pointer to a reference of type}}
+ >::type type;
+};
+
+TypenameTypeTester<int> TypenameTypeCheck; // expected-note{{in instantiation of template class}}
+
+template<typename T, typename U>
+struct DependentTemplateSpecializationTypeTester {
+ typedef typename T::template apply<typename add_reference<U>::type
+ * // expected-error{{declared as a pointer to a reference of type}}
+ >::type type;
+};
+
+struct HasApply {
+ template<typename T>
+ struct apply {
+ typedef T type;
+ };
+};
+
+DependentTemplateSpecializationTypeTester<HasApply, int> DTSTCheck; // expected-note{{in instantiation of template class}}
+
+template<typename T, typename U>
+struct DependentTemplateSpecializationTypeTester2 {
+ typedef typename T::template apply<typename add_reference<U>::type
+ * // expected-error{{declared as a pointer to a reference of type}}
+ > type;
+};
+
+DependentTemplateSpecializationTypeTester2<HasApply, int> DTSTCheck2; // expected-note{{in instantiation of template class}}
+
+template<typename T, typename U>
+struct DependentTemplateSpecializationTypeTester3 :
+ T::template apply<typename add_reference<U>::type
+ * // expected-error{{declared as a pointer to a reference of type}}
+ >
+{};
+
+DependentTemplateSpecializationTypeTester3<HasApply, int> DTSTCheck3; // expected-note{{in instantiation of template class}}
+
+template<typename T, typename U>
+struct DependentTemplateSpecializationTypeTester4 {
+ typedef class T::template apply<typename add_reference<U>::type
+ * // expected-error{{declared as a pointer to a reference of type}}
+ > type;
+};
+
+DependentTemplateSpecializationTypeTester4<HasApply, int> DTSTCheck4; // expected-note{{in instantiation of template class}}
+
+template<template<class T> class TTP>
+struct AcceptedTemplateTemplateParameter {
+};
+
+template<typename T, typename U>
+struct DependentTemplateTemplateArgumentTester {
+ typedef AcceptedTemplateTemplateParameter<
+ T::
+ template apply<
+ typename add_reference<U>::type
+ * // expected-error{{declared as a pointer to a reference of type}}
+ >::
+ template X>
+ type;
+};
+
+DependentTemplateTemplateArgumentTester<HasApply, int> DTTACheck; // expected-note{{in instantiation of template class}}
+
+namespace PR9388 {
+ namespace std {
+ template<typename T> class vector {
+ };
+ }
+ template<typename T> static void foo(std::vector<T*> &V) {
+ __PRETTY_FUNCTION__; // expected-warning{{expression result unused}}
+ }
+ void bar(std::vector<int*> &Blocks) {
+ foo(Blocks); // expected-note{{in instantiation of}}
+ }
+
+}
diff --git a/clang/test/SemaCXX/nested-name-spec.cpp b/clang/test/SemaCXX/nested-name-spec.cpp
new file mode 100644
index 0000000..b317634
--- /dev/null
+++ b/clang/test/SemaCXX/nested-name-spec.cpp
@@ -0,0 +1,288 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s
+namespace A {
+ struct C {
+ static int cx;
+
+ static int cx2;
+
+ static int Ag1();
+ static int Ag2();
+ };
+ int ax;
+ void Af();
+}
+
+A:: ; // expected-error {{expected unqualified-id}}
+// FIXME: there is a member 'ax'; it's just not a class.
+::A::ax::undef ex3; // expected-error {{no member named 'ax'}}
+A::undef1::undef2 ex4; // expected-error {{no member named 'undef1'}}
+
+int A::C::Ag1() { return 0; }
+
+static int A::C::Ag2() { return 0; } // expected-error{{'static' can}}
+
+int A::C::cx = 17;
+
+
+static int A::C::cx2 = 17; // expected-error{{'static' can}}
+
+class C2 {
+ void m(); // expected-note{{member declaration does not match because it is not const qualified}}
+
+ void f(const int& parm); // expected-note{{type of 1st parameter of member declaration does not match definition ('const int &' vs 'int')}}
+ void f(int) const; // expected-note{{member declaration does not match because it is const qualified}}
+ void f(float);
+
+ int x;
+};
+
+void C2::m() const { } // expected-error{{out-of-line definition of 'm' does not match any declaration in 'C2'}}
+
+void C2::f(int) { } // expected-error{{out-of-line definition of 'f' does not match any declaration in 'C2'}}
+
+void C2::m() {
+ x = 0;
+}
+
+namespace B {
+ void ::A::Af() {} // expected-error {{cannot define or redeclare 'Af' here because namespace 'B' does not enclose namespace 'A'}}
+}
+
+void f1() {
+ void A::Af(); // expected-error {{definition or redeclaration of 'Af' not allowed inside a function}}
+}
+
+void f2() {
+ A:: ; // expected-error {{expected unqualified-id}}
+ A::C::undef = 0; // expected-error {{no member named 'undef'}}
+ ::A::C::cx = 0;
+ int x = ::A::ax = A::C::cx;
+ x = sizeof(A::C);
+ x = sizeof(::A::C::cx);
+}
+
+A::C c1;
+struct A::C c2;
+struct S : public A::C {};
+struct A::undef; // expected-error {{no struct named 'undef' in namespace 'A'}}
+
+namespace A2 {
+ typedef int INT;
+ struct RC;
+ struct CC {
+ struct NC;
+ };
+}
+
+struct A2::RC {
+ INT x;
+};
+
+struct A2::CC::NC {
+ void m() {}
+};
+
+void f3() {
+ N::x = 0; // expected-error {{use of undeclared identifier 'N'}}
+ int N;
+ N::x = 0; // expected-error {{expected a class or namespace}}
+ { int A; A::ax = 0; }
+ { typedef int A; A::ax = 0; } // expected-error{{expected a class or namespace}}
+ { typedef A::C A; A::ax = 0; } // expected-error {{no member named 'ax'}}
+ { typedef A::C A; A::cx = 0; }
+}
+
+// make sure the following doesn't hit any asserts
+void f4(undef::C); // expected-error {{use of undeclared identifier 'undef'}} \
+ expected-error {{variable has incomplete type 'void'}}
+
+typedef void C2::f5(int); // expected-error{{typedef declarator cannot be qualified}}
+
+void f6(int A2::RC::x); // expected-error{{parameter declarator cannot be qualified}}
+
+int A2::RC::x; // expected-error{{non-static data member defined out-of-line}}
+
+void A2::CC::NC::m(); // expected-error{{out-of-line declaration of a member must be a definition}}
+
+
+namespace E {
+ int X = 5;
+
+ namespace Nested {
+ enum E {
+ X = 0
+ };
+
+ void f() {
+ return E::X; // expected-error{{expected a class or namespace}}
+ }
+ }
+}
+
+
+class Operators {
+ Operators operator+(const Operators&) const; // expected-note{{member declaration does not match because it is const qualified}}
+ operator bool();
+};
+
+Operators Operators::operator+(const Operators&) { // expected-error{{out-of-line definition of 'operator+' does not match any declaration in 'Operators'}}
+ Operators ops;
+ return ops;
+}
+
+Operators Operators::operator+(const Operators&) const {
+ Operators ops;
+ return ops;
+}
+
+Operators::operator bool() {
+ return true;
+}
+
+namespace A {
+ void g(int&); // expected-note{{type of 1st parameter of member declaration does not match definition ('int &' vs 'const int &')}}
+}
+
+void A::f() {} // expected-error{{out-of-line definition of 'f' does not match any declaration in namespace 'A'}}
+
+void A::g(const int&) { } // expected-error{{out-of-line definition of 'g' does not match any declaration in namespace 'A'}}
+
+struct Struct { };
+
+void Struct::f() { } // expected-error{{out-of-line definition of 'f' does not match any declaration in 'Struct'}}
+
+void global_func(int);
+void global_func2(int);
+
+namespace N {
+ void ::global_func(int) { } // expected-error{{definition or redeclaration of 'global_func' cannot name the global scope}}
+
+ void f();
+ // FIXME: if we move this to a separate definition of N, things break!
+}
+void ::global_func2(int) { } // expected-warning{{extra qualification on member 'global_func2'}}
+
+void N::f() { } // okay
+
+struct Y; // expected-note{{forward declaration of 'Y'}}
+Y::foo y; // expected-error{{incomplete type 'Y' named in nested name specifier}}
+
+X::X() : a(5) { } // expected-error{{use of undeclared identifier 'X'}} \
+ // expected-error{{C++ requires a type specifier for all declarations}} \
+ // expected-error{{only constructors take base initializers}}
+
+struct foo_S {
+ static bool value;
+};
+bool (foo_S::value);
+
+
+namespace somens {
+ struct a { }; // expected-note{{candidate constructor (the implicit copy constructor)}}
+}
+
+template <typename T>
+class foo {
+};
+
+
+// PR4452 / PR4451
+foo<somens:a> a2; // expected-error {{unexpected ':' in nested name specifier}}
+
+somens::a a3 = a2; // expected-error {{no viable conversion}}
+
+// typedefs and using declarations.
+namespace test1 {
+ namespace ns {
+ class Counter { public: static int count; };
+ typedef Counter counter;
+ }
+ using ns::counter;
+
+ class Test {
+ void test1() {
+ counter c;
+ c.count++;
+ counter::count++;
+ }
+ };
+}
+
+// We still need to do lookup in the lexical scope, even if we push a
+// non-lexical scope.
+namespace test2 {
+ namespace ns {
+ extern int *count_ptr;
+ }
+ namespace {
+ int count = 0;
+ }
+
+ int *ns::count_ptr = &count;
+}
+
+// PR6259, invalid case
+namespace test3 {
+ class A; // expected-note {{forward declaration}}
+ void foo(const char *path) {
+ A::execute(path); // expected-error {{incomplete type 'test3::A' named in nested name specifier}}
+ }
+}
+
+namespace PR7133 {
+ namespace A {
+ class Foo;
+ }
+
+ namespace A {
+ namespace B {
+ bool foo(Foo &);
+ }
+ }
+
+ bool A::B::foo(Foo &) {
+ return false;
+ }
+}
+
+class CLASS {
+ void CLASS::foo2(); // expected-warning {{extra qualification on member 'foo2'}}
+};
+
+namespace PR8159 {
+ class B { };
+
+ class A {
+ int A::a; // expected-warning{{extra qualification on member 'a'}}
+ static int A::b; // expected-warning{{extra qualification on member 'b'}}
+ int ::c; // expected-error{{non-friend class member 'c' cannot have a qualified name}}
+ };
+}
+
+namespace rdar7980179 {
+ class A { void f0(); }; // expected-note {{previous}}
+ int A::f0() {} // expected-error {{out-of-line definition of 'rdar7980179::A::f0' differs from the declaration in the return type}}
+}
+
+namespace alias = A;
+double *dp = (alias::C*)0; // expected-error{{cannot initialize a variable of type 'double *' with an rvalue of type 'alias::C *'}}
+
+// http://llvm.org/PR10109
+namespace PR10109 {
+template<typename T>
+struct A {
+protected:
+ struct B;
+ struct B::C; // expected-error {{requires a template parameter list}} \
+ // expected-error {{no struct named 'C'}} \
+ // expected-error{{non-friend class member 'C' cannot have a qualified name}}
+};
+
+template<typename T>
+struct A2 {
+protected:
+ struct B;
+};
+template <typename T>
+struct A2<T>::B::C; // expected-error {{no struct named 'C'}}
+}
diff --git a/clang/test/SemaCXX/new-array-size-conv.cpp b/clang/test/SemaCXX/new-array-size-conv.cpp
new file mode 100644
index 0000000..e8bb679
--- /dev/null
+++ b/clang/test/SemaCXX/new-array-size-conv.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+
+struct ValueInt
+{
+ ValueInt(int v = 0) : ValueLength(v) {}
+ operator int () const { return ValueLength; } // expected-note 3{{conversion to integral type 'int' declared here}}
+private:
+ int ValueLength;
+};
+
+enum E { e };
+struct ValueEnum {
+ operator E() const; // expected-note{{conversion to enumeration type 'E' declared here}}
+};
+
+struct ValueBoth : ValueInt, ValueEnum { };
+
+struct IndirectValueInt : ValueInt { };
+struct TwoValueInts : ValueInt, IndirectValueInt { };
+
+void test() {
+ (void)new int[ValueInt(10)]; // expected-warning{{implicit conversion from array size expression of type 'ValueInt' to integral type 'int' is a C++11 extension}}
+ (void)new int[ValueEnum()]; // expected-warning{{implicit conversion from array size expression of type 'ValueEnum' to enumeration type 'E' is a C++11 extension}}
+ (void)new int[ValueBoth()]; // expected-error{{ambiguous conversion of array size expression of type 'ValueBoth' to an integral or enumeration type}}
+
+ (void)new int[TwoValueInts()]; // expected-error{{ambiguous conversion of array size expression of type 'TwoValueInts' to an integral or enumeration type}}
+}
diff --git a/clang/test/SemaCXX/new-delete-0x.cpp b/clang/test/SemaCXX/new-delete-0x.cpp
new file mode 100644
index 0000000..dcc2e9b
--- /dev/null
+++ b/clang/test/SemaCXX/new-delete-0x.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple=i686-pc-linux-gnu -std=c++11
+
+using size_t = decltype(sizeof(0));
+struct noreturn_t {} constexpr noreturn = {};
+
+void *operator new [[noreturn]] (size_t, noreturn_t);
+void operator delete [[noreturn]] (void*, noreturn_t);
+
+void good_news()
+{
+ auto p = new int[2][[]];
+ auto q = new int[[]][2];
+ auto r = new int*[[]][2][[]];
+ auto s = new (int(*[[]])[2][[]]);
+}
+
+void bad_news(int *ip)
+{
+ // attribute-specifiers can go almost anywhere in a new-type-id...
+ auto r = new int[[]{return 1;}()][2]; // expected-error {{expected ']'}}
+ auto s = new int*[[]{return 1;}()][2]; // expected-error {{expected ']'}}
+ // ... but not here:
+ auto t = new (int(*)[[]]); // expected-error {{an attribute list cannot appear here}}
+ auto u = new (int(*)[[]{return 1;}()][2]); // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}} expected-error {{variably modified type}}
+}
+
+void good_deletes()
+{
+ delete [&]{ return (int*)0; }();
+ // FIXME: This appears to be legal.
+ delete []{ return (int*)0; }(); // unexpected-error {{expected expression}}
+}
diff --git a/clang/test/SemaCXX/new-delete-cxx0x.cpp b/clang/test/SemaCXX/new-delete-cxx0x.cpp
new file mode 100644
index 0000000..c404fab
--- /dev/null
+++ b/clang/test/SemaCXX/new-delete-cxx0x.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -triple=i686-pc-linux-gnu
+
+void ugly_news(int *ip) {
+ // These are ill-formed according to one reading of C++98, and at the least
+ // have undefined behavior. But they're well-formed, and defined to throw
+ // std::bad_array_new_length, in C++11.
+ (void)new int[-1]; // expected-warning {{array size is negative}}
+ (void)new int[2000000000]; // expected-warning {{array is too large}}
+}
+
+
+struct S {
+ S(int);
+ S();
+ ~S();
+};
+
+struct T { // expected-note 2 {{not viable}}
+ T(int); // expected-note {{not viable}}
+};
+
+void fn() {
+ (void) new int[2] {1, 2};
+ (void) new S[2] {1, 2};
+ (void) new T[2] {1, 2}; // expected-error {{no matching constructor}}
+}
diff --git a/clang/test/SemaCXX/new-delete-predefined-decl-2.cpp b/clang/test/SemaCXX/new-delete-predefined-decl-2.cpp
new file mode 100644
index 0000000..981476d
--- /dev/null
+++ b/clang/test/SemaCXX/new-delete-predefined-decl-2.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DQUALIFIED -fsyntax-only -verify %s
+
+// PR5904
+void f0(int *ptr) {
+#ifndef QUALIFIED
+ operator delete(ptr);
+#endif
+}
+
+void f1(int *ptr) {
+ ::operator delete[](ptr);
+}
diff --git a/clang/test/SemaCXX/new-delete-predefined-decl.cpp b/clang/test/SemaCXX/new-delete-predefined-decl.cpp
new file mode 100644
index 0000000..20b15b7
--- /dev/null
+++ b/clang/test/SemaCXX/new-delete-predefined-decl.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -DTEMPLATE_OVERLOAD -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include <stddef.h>
+
+// Note that each test must be run separately so it can be the first operator
+// new declaration in the file.
+
+#if defined(TEMPLATE_OVERLOAD)
+// Don't crash on global template operator new overloads.
+template<typename T> void* operator new(size_t, T);
+void test_template_overload() {
+ (void)new(0) double;
+}
+#endif
+
+void test_predefined() {
+ (void)new double;
+}
diff --git a/clang/test/SemaCXX/new-delete.cpp b/clang/test/SemaCXX/new-delete.cpp
new file mode 100644
index 0000000..e77e3d6
--- /dev/null
+++ b/clang/test/SemaCXX/new-delete.cpp
@@ -0,0 +1,501 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple=i686-pc-linux-gnu
+
+#include <stddef.h>
+
+struct S // expected-note {{candidate}}
+{
+ S(int, int, double); // expected-note {{candidate}}
+ S(double, int); // expected-note 2 {{candidate}}
+ S(float, int); // expected-note 2 {{candidate}}
+};
+struct T; // expected-note{{forward declaration of 'T'}}
+struct U
+{
+ // A special new, to verify that the global version isn't used.
+ void* operator new(size_t, S*); // expected-note {{candidate}}
+};
+struct V : U
+{
+};
+
+// PR5823
+void* operator new(const size_t); // expected-note 2 {{candidate}}
+void* operator new(size_t, int*); // expected-note 3 {{candidate}}
+void* operator new(size_t, float*); // expected-note 3 {{candidate}}
+void* operator new(size_t, S); // expected-note 2 {{candidate}}
+
+struct foo { };
+
+void good_news()
+{
+ int *pi = new int;
+ float *pf = new (pi) float();
+ pi = new int(1);
+ pi = new int('c');
+ const int *pci = new const int();
+ S *ps = new S(1, 2, 3.4);
+ ps = new (pf) (S)(1, 2, 3.4);
+ S *(*paps)[2] = new S*[*pi][2];
+ typedef int ia4[4];
+ ia4 *pai = new (int[3][4]);
+ pi = ::new int;
+ U *pu = new (ps) U;
+ V *pv = new (ps) V;
+
+ pi = new (S(1.0f, 2)) int;
+
+ (void)new int[true];
+
+ // PR7147
+ typedef int a[2];
+ foo* f1 = new foo;
+ foo* f2 = new foo[2];
+ typedef foo x[2];
+ typedef foo y[2][2];
+ x* f3 = new y;
+}
+
+struct abstract {
+ virtual ~abstract() = 0;
+};
+
+void bad_news(int *ip)
+{
+ int i = 1; // expected-note 2{{here}}
+ (void)new; // expected-error {{expected a type}}
+ (void)new 4; // expected-error {{expected a type}}
+ (void)new () int; // expected-error {{expected expression}}
+ (void)new int[1.1]; // expected-error {{array size expression must have integral or enumeration type, not 'double'}}
+ (void)new int[1][i]; // expected-error {{only the first dimension}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}}
+ (void)new (int[1][i]); // expected-error {{only the first dimension}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}}
+ (void)new (int[i]); // expected-warning {{when type is in parentheses}}
+ (void)new int(*(S*)0); // expected-error {{no viable conversion from 'S' to 'int'}}
+ (void)new int(1, 2); // expected-error {{excess elements in scalar initializer}}
+ (void)new S(1); // expected-error {{no matching constructor}}
+ (void)new S(1, 1); // expected-error {{call to constructor of 'S' is ambiguous}}
+ (void)new const int; // expected-error {{default initialization of an object of const type 'const int'}}
+ (void)new float*(ip); // expected-error {{cannot initialize a new value of type 'float *' with an lvalue of type 'int *'}}
+ // Undefined, but clang should reject it directly.
+ (void)new int[-1]; // expected-error {{array size is negative}}
+ (void)new int[2000000000]; // expected-error {{array is too large}}
+ (void)new int[*(S*)0]; // expected-error {{array size expression must have integral or enumeration type, not 'S'}}
+ (void)::S::new int; // expected-error {{expected unqualified-id}}
+ (void)new (0, 0) int; // expected-error {{no matching function for call to 'operator new'}}
+ (void)new (0L) int; // expected-error {{call to 'operator new' is ambiguous}}
+ // This must fail, because the member version shouldn't be found.
+ (void)::new ((S*)0) U; // expected-error {{no matching function for call to 'operator new'}}
+ // This must fail, because any member version hides all global versions.
+ (void)new U; // expected-error {{no matching function for call to 'operator new'}}
+ (void)new (int[]); // expected-error {{array size must be specified in new expressions}}
+ (void)new int&; // expected-error {{cannot allocate reference type 'int &' with new}}
+ // Some lacking cases due to lack of sema support.
+}
+
+void good_deletes()
+{
+ delete (int*)0;
+ delete [](int*)0;
+ delete (S*)0;
+ ::delete (int*)0;
+}
+
+void bad_deletes()
+{
+ delete 0; // expected-error {{cannot delete expression of type 'int'}}
+ delete [0] (int*)0; // expected-error {{expected expression}}
+ delete (void*)0; // expected-warning {{cannot delete expression with pointer-to-'void' type 'void *'}}
+ delete (T*)0; // expected-warning {{deleting pointer to incomplete type}}
+ ::S::delete (int*)0; // expected-error {{expected unqualified-id}}
+}
+
+struct X0 { };
+
+struct X1 {
+ operator int*();
+ operator float();
+};
+
+struct X2 {
+ operator int*(); // expected-note {{candidate function}}
+ operator float*(); // expected-note {{candidate function}}
+};
+
+void test_delete_conv(X0 x0, X1 x1, X2 x2) {
+ delete x0; // expected-error{{cannot delete}}
+ delete x1;
+ delete x2; // expected-error{{ambiguous conversion of delete expression of type 'X2' to a pointer}}
+}
+
+// PR4782
+class X3 {
+public:
+ static void operator delete(void * mem, size_t size);
+};
+
+class X4 {
+public:
+ static void release(X3 *x);
+ static void operator delete(void * mem, size_t size);
+};
+
+
+void X4::release(X3 *x) {
+ delete x;
+}
+
+class X5 {
+public:
+ void Destroy() const { delete this; }
+};
+
+class Base {
+public:
+ static void *operator new(signed char) throw(); // expected-error {{'operator new' takes type size_t}}
+ static int operator new[] (size_t) throw(); // expected-error {{operator new[]' must return type 'void *'}}
+};
+
+class Tier {};
+class Comp : public Tier {};
+
+class Thai : public Base {
+public:
+ Thai(const Tier *adoptDictionary);
+};
+
+void loadEngineFor() {
+ const Comp *dict;
+ new Thai(dict);
+}
+
+template <class T> struct TBase {
+ void* operator new(T size, int); // expected-error {{'operator new' cannot take a dependent type as first parameter; use size_t}}
+};
+
+TBase<int> t1;
+
+class X6 {
+public:
+ static void operator delete(void*, int); // expected-note {{member found by ambiguous name lookup}}
+};
+
+class X7 {
+public:
+ static void operator delete(void*, int); // expected-note {{member found by ambiguous name lookup}}
+};
+
+class X8 : public X6, public X7 {
+};
+
+void f(X8 *x8) {
+ delete x8; // expected-error {{member 'operator delete' found in multiple base classes of different types}}
+}
+
+class X9 {
+public:
+ static void operator delete(void*, int); // expected-note {{'operator delete' declared here}}
+ static void operator delete(void*, float); // expected-note {{'operator delete' declared here}}
+};
+
+void f(X9 *x9) {
+ delete x9; // expected-error {{no suitable member 'operator delete' in 'X9'}}
+}
+
+struct X10 {
+ virtual ~X10();
+};
+
+struct X11 : X10 { // expected-error {{no suitable member 'operator delete' in 'X11'}}
+ void operator delete(void*, int); // expected-note {{'operator delete' declared here}}
+};
+
+void f() {
+ X11 x11; // expected-note {{implicit default destructor for 'X11' first required here}}
+}
+
+struct X12 {
+ void* operator new(size_t, void*);
+};
+
+struct X13 : X12 {
+ using X12::operator new;
+};
+
+static void* f(void* g)
+{
+ return new (g) X13();
+}
+
+class X14 {
+public:
+ static void operator delete(void*, const size_t);
+};
+
+void f(X14 *x14a, X14 *x14b) {
+ delete x14a;
+}
+
+class X15 {
+private:
+ X15(); // expected-note {{declared private here}}
+ ~X15(); // expected-note {{declared private here}}
+};
+
+void f(X15* x) {
+ new X15(); // expected-error {{calling a private constructor}}
+ delete x; // expected-error {{calling a private destructor}}
+}
+
+namespace PR5918 { // Look for template operator new overloads.
+ struct S { template<typename T> static void* operator new(size_t, T); };
+ void test() {
+ (void)new(0) S;
+ }
+}
+
+namespace Test1 {
+
+void f() {
+ (void)new int[10](1, 2); // expected-error {{array 'new' cannot have initialization arguments}}
+
+ typedef int T[10];
+ (void)new T(1, 2); // expected-error {{array 'new' cannot have initialization arguments}}
+}
+
+template<typename T>
+void g(unsigned i) {
+ (void)new T[1](i); // expected-error {{array 'new' cannot have initialization arguments}}
+}
+
+template<typename T>
+void h(unsigned i) {
+ (void)new T(i); // expected-error {{array 'new' cannot have initialization arguments}}
+}
+template void h<unsigned>(unsigned);
+template void h<unsigned[10]>(unsigned); // expected-note {{in instantiation of function template specialization 'Test1::h<unsigned int [10]>' requested here}}
+
+}
+
+// Don't diagnose access for overload candidates that aren't selected.
+namespace PR7436 {
+struct S1 {
+ void* operator new(size_t);
+ void operator delete(void* p);
+
+private:
+ void* operator new(size_t, void*); // expected-note {{declared private here}}
+ void operator delete(void*, void*);
+};
+class S2 {
+ void* operator new(size_t); // expected-note {{declared private here}}
+ void operator delete(void* p); // expected-note {{declared private here}}
+};
+
+void test(S1* s1, S2* s2) {
+ delete s1;
+ delete s2; // expected-error {{is a private member}}
+ (void)new S1();
+ (void)new (0L) S1(); // expected-error {{is a private member}}
+ (void)new S2(); // expected-error {{is a private member}}
+}
+}
+
+namespace rdar8018245 {
+ struct X0 {
+ static const int value = 17;
+ };
+
+ const int X0::value;
+
+ struct X1 {
+ static int value;
+ };
+
+ int X1::value;
+
+ template<typename T>
+ int *f() {
+ return new (int[T::value]); // expected-warning{{when type is in parentheses, array cannot have dynamic size}}
+ }
+
+ template int *f<X0>();
+ template int *f<X1>(); // expected-note{{in instantiation of}}
+
+}
+
+// <rdar://problem/8248780>
+namespace Instantiate {
+ template<typename T> struct X {
+ operator T*();
+ };
+
+ void f(X<int> &xi) {
+ delete xi;
+ }
+}
+
+namespace PR7810 {
+ struct X {
+ // cv is ignored in arguments
+ static void operator delete(void *const);
+ };
+ struct Y {
+ // cv is ignored in arguments
+ static void operator delete(void *volatile);
+ };
+}
+
+// Don't crash on template delete operators
+namespace TemplateDestructors {
+ struct S {
+ virtual ~S() {}
+
+ void* operator new(const size_t size);
+ template<class T> void* operator new(const size_t, const int, T*);
+ void operator delete(void*, const size_t);
+ template<class T> void operator delete(void*, const size_t, const int, T*);
+ };
+}
+
+namespace DeleteParam {
+ struct X {
+ void operator delete(X*); // expected-error{{first parameter of 'operator delete' must have type 'void *'}}
+ };
+
+ struct Y {
+ void operator delete(void* const);
+ };
+}
+
+// <rdar://problem/8427878>
+// Test that the correct 'operator delete' is selected to pair with
+// the unexpected placement 'operator new'.
+namespace PairedDelete {
+ template <class T> struct A {
+ A();
+ void *operator new(size_t s, double d = 0);
+ void operator delete(void *p, double d);
+ void operator delete(void *p) {
+ T::dealloc(p);
+ }
+ };
+
+ A<int> *test() {
+ return new A<int>();
+ }
+}
+
+namespace PR7702 {
+ void test1() {
+ new DoesNotExist; // expected-error {{unknown type name 'DoesNotExist'}}
+ }
+}
+
+namespace ArrayNewNeedsDtor {
+ struct A { A(); private: ~A(); }; // expected-note {{declared private here}}
+ struct B { B(); A a; }; // expected-error {{field of type 'ArrayNewNeedsDtor::A' has private destructor}}
+ B *test9() {
+ return new B[5]; // expected-note {{implicit default destructor for 'ArrayNewNeedsDtor::B' first required here}}
+ }
+}
+
+namespace DeleteIncompleteClass {
+ struct A; // expected-note {{forward declaration}}
+ extern A x;
+ void f() { delete x; } // expected-error {{deleting incomplete class type}}
+}
+
+namespace DeleteIncompleteClassPointerError {
+ struct A; // expected-note {{forward declaration}}
+ void f(A *x) { 1+delete x; } // expected-warning {{deleting pointer to incomplete type}} \
+ // expected-error {{invalid operands to binary expression}}
+}
+
+namespace PR10504 {
+ struct A {
+ virtual void foo() = 0;
+ };
+ void f(A *x) { delete x; } // expected-warning {{delete called on 'PR10504::A' that is abstract but has non-virtual destructor}}
+}
+
+struct PlacementArg {};
+inline void *operator new[](size_t, const PlacementArg &) throw () {
+ return 0;
+}
+inline void operator delete[](void *, const PlacementArg &) throw () {
+}
+
+namespace r150682 {
+
+ template <typename X>
+ struct S {
+ struct Inner {};
+ S() { new Inner[1]; }
+ };
+
+ struct T {
+ };
+
+ template<typename X>
+ void tfn() {
+ new (*(PlacementArg*)0) T[1];
+ }
+
+ void fn() {
+ tfn<int>();
+ }
+
+}
+
+namespace P12023 {
+ struct CopyCounter
+ {
+ CopyCounter();
+ CopyCounter(const CopyCounter&);
+ };
+
+ int main()
+ {
+ CopyCounter* f = new CopyCounter[10](CopyCounter()); // expected-error {{cannot have initialization arguments}}
+ return 0;
+ }
+}
+
+namespace PR12061 {
+ template <class C> struct scoped_array {
+ scoped_array(C* p = __null);
+ };
+ template <class Payload> struct Foo {
+ Foo() : a_(new scoped_array<int>[5]) { }
+ scoped_array< scoped_array<int> > a_;
+ };
+ class Bar {};
+ Foo<Bar> x;
+
+ template <class C> struct scoped_array2 {
+ scoped_array2(C* p = __null, C* q = __null);
+ };
+ template <class Payload> struct Foo2 {
+ Foo2() : a_(new scoped_array2<int>[5]) { }
+ scoped_array2< scoped_array2<int> > a_;
+ };
+ class Bar2 {};
+ Foo2<Bar2> x2;
+
+ class MessageLoop {
+ public:
+ explicit MessageLoop(int type = 0);
+ };
+ template <class CookieStoreTestTraits>
+ class CookieStoreTest {
+ protected:
+ CookieStoreTest() {
+ new MessageLoop;
+ }
+ };
+ struct CookieMonsterTestTraits {
+ };
+ class DeferredCookieTaskTest : public CookieStoreTest<CookieMonsterTestTraits>
+ {
+ DeferredCookieTaskTest() {}
+ };
+}
diff --git a/clang/test/SemaCXX/no-exceptions.cpp b/clang/test/SemaCXX/no-exceptions.cpp
new file mode 100644
index 0000000..f739568
--- /dev/null
+++ b/clang/test/SemaCXX/no-exceptions.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Various tests for -fno-exceptions
+
+typedef __SIZE_TYPE__ size_t;
+
+namespace test0 {
+ // rdar://problem/7878149
+ class Foo {
+ public:
+ void* operator new(size_t x);
+ private:
+ void operator delete(void *x);
+ };
+
+ void test() {
+ // Under -fexceptions, this does access control for the associated
+ // 'operator delete'.
+ (void) new Foo();
+ }
+}
+
+namespace test1 {
+void f() {
+ throw; // expected-error {{cannot use 'throw' with exceptions disabled}}
+}
+
+void g() {
+ try { // expected-error {{cannot use 'try' with exceptions disabled}}
+ f();
+ } catch (...) {
+ }
+}
+
+}
diff --git a/clang/test/SemaCXX/no-implicit-builtin-decls.cpp b/clang/test/SemaCXX/no-implicit-builtin-decls.cpp
new file mode 100644
index 0000000..d82f7f1
--- /dev/null
+++ b/clang/test/SemaCXX/no-implicit-builtin-decls.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f() {
+ void *p = malloc(sizeof(int) * 10); // expected-error{{use of undeclared identifier 'malloc'}}
+}
+
+int malloc(double);
diff --git a/clang/test/SemaCXX/non-empty-class-size-zero.cpp b/clang/test/SemaCXX/non-empty-class-size-zero.cpp
new file mode 100644
index 0000000..6b714db
--- /dev/null
+++ b/clang/test/SemaCXX/non-empty-class-size-zero.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only %s
+// rdar://8945175
+
+struct X {
+ int array[0];
+ int array1[0];
+ int array2[0];
+ X();
+ ~X();
+};
+
+struct Y {
+ int first;
+ X padding;
+ int second;
+};
+
+int zero_size_array[(sizeof(Y) == 8) -1]; // no error here!
diff --git a/clang/test/SemaCXX/null_in_arithmetic_ops.cpp b/clang/test/SemaCXX/null_in_arithmetic_ops.cpp
new file mode 100644
index 0000000..a6c0dbf
--- /dev/null
+++ b/clang/test/SemaCXX/null_in_arithmetic_ops.cpp
@@ -0,0 +1,93 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -fblocks -Wnull-arithmetic -verify -Wno-string-plus-int %s
+#include <stddef.h>
+
+void f() {
+ int a;
+ bool b;
+ void (^c)();
+ class X;
+ void (X::*d) ();
+ extern void e();
+ int f[2];
+ const void *v;
+
+ a = 0 ? NULL + a : a + NULL; // expected-warning 2{{use of NULL in arithmetic operation}}
+ a = 0 ? NULL - a : a - NULL; // expected-warning 2{{use of NULL in arithmetic operation}}
+ a = 0 ? NULL / a : a / NULL; // expected-warning 2{{use of NULL in arithmetic operation}} \
+ // expected-warning {{division by zero is undefined}}
+ a = 0 ? NULL * a : a * NULL; // expected-warning 2{{use of NULL in arithmetic operation}}
+ a = 0 ? NULL >> a : a >> NULL; // expected-warning 2{{use of NULL in arithmetic operation}}
+ a = 0 ? NULL << a : a << NULL; // expected-warning 2{{use of NULL in arithmetic operation}}
+ a = 0 ? NULL % a : a % NULL; // expected-warning 2{{use of NULL in arithmetic operation}} \
+ expected-warning {{remainder by zero is undefined}}
+ a = 0 ? NULL & a : a & NULL; // expected-warning 2{{use of NULL in arithmetic operation}}
+ a = 0 ? NULL | a : a | NULL; // expected-warning 2{{use of NULL in arithmetic operation}}
+ a = 0 ? NULL ^ a : a ^ NULL; // expected-warning 2{{use of NULL in arithmetic operation}}
+
+ // Check for warnings or errors when doing arithmetic on pointers and other
+ // types.
+ v = 0 ? NULL + &a : &a + NULL; // expected-warning 2{{use of NULL in arithmetic operation}}
+ v = 0 ? NULL + c : c + NULL; // \
+ expected-error {{invalid operands to binary expression ('long' and 'void (^)()')}} \
+ expected-error {{invalid operands to binary expression ('void (^)()' and 'long')}}
+ v = 0 ? NULL + d : d + NULL; // \
+ expected-error {{invalid operands to binary expression ('long' and 'void (X::*)()')}} \
+ expected-error {{invalid operands to binary expression ('void (X::*)()' and 'long')}}
+ v = 0 ? NULL + e : e + NULL; // expected-error 2{{arithmetic on a pointer to the function type 'void ()'}}
+ v = 0 ? NULL + f : f + NULL; // expected-warning 2{{use of NULL in arithmetic operation}}
+ v = 0 ? NULL + "f" : "f" + NULL; // expected-warning 2{{use of NULL in arithmetic operation}}
+
+ // Using two NULLs should only give one error instead of two.
+ a = NULL + NULL; // expected-warning{{use of NULL in arithmetic operation}}
+ a = NULL - NULL; // expected-warning{{use of NULL in arithmetic operation}}
+ a = NULL / NULL; // expected-warning{{use of NULL in arithmetic operation}} \
+ // expected-warning{{division by zero is undefined}}
+ a = NULL * NULL; // expected-warning{{use of NULL in arithmetic operation}}
+ a = NULL >> NULL; // expected-warning{{use of NULL in arithmetic operation}}
+ a = NULL << NULL; // expected-warning{{use of NULL in arithmetic operation}}
+ a = NULL % NULL; // expected-warning{{use of NULL in arithmetic operation}} \
+ // expected-warning{{remainder by zero is undefined}}
+ a = NULL & NULL; // expected-warning{{use of NULL in arithmetic operation}}
+ a = NULL | NULL; // expected-warning{{use of NULL in arithmetic operation}}
+ a = NULL ^ NULL; // expected-warning{{use of NULL in arithmetic operation}}
+
+ a += NULL; // expected-warning{{use of NULL in arithmetic operation}}
+ a -= NULL; // expected-warning{{use of NULL in arithmetic operation}}
+ a /= NULL; // expected-warning{{use of NULL in arithmetic operation}} \
+ // expected-warning{{division by zero is undefined}}
+ a *= NULL; // expected-warning{{use of NULL in arithmetic operation}}
+ a >>= NULL; // expected-warning{{use of NULL in arithmetic operation}}
+ a <<= NULL; // expected-warning{{use of NULL in arithmetic operation}}
+ a %= NULL; // expected-warning{{use of NULL in arithmetic operation}} \
+ // expected-warning{{remainder by zero is undefined}}
+ a &= NULL; // expected-warning{{use of NULL in arithmetic operation}}
+ a |= NULL; // expected-warning{{use of NULL in arithmetic operation}}
+ a ^= NULL; // expected-warning{{use of NULL in arithmetic operation}}
+
+ b = a < NULL || a > NULL; // expected-warning 2{{comparison between NULL and non-pointer ('int' and NULL)}}
+ b = NULL < a || NULL > a; // expected-warning 2{{comparison between NULL and non-pointer (NULL and 'int')}}
+ b = a <= NULL || a >= NULL; // expected-warning 2{{comparison between NULL and non-pointer ('int' and NULL)}}
+ b = NULL <= a || NULL >= a; // expected-warning 2{{comparison between NULL and non-pointer (NULL and 'int')}}
+ b = a == NULL || a != NULL; // expected-warning 2{{comparison between NULL and non-pointer ('int' and NULL)}}
+ b = NULL == a || NULL != a; // expected-warning 2{{comparison between NULL and non-pointer (NULL and 'int')}}
+
+ b = &a < NULL || NULL < &a || &a > NULL || NULL > &a;
+ b = &a <= NULL || NULL <= &a || &a >= NULL || NULL >= &a;
+ b = &a == NULL || NULL == &a || &a != NULL || NULL != &a;
+
+ b = 0 == a;
+ b = 0 == &a;
+
+ b = NULL < NULL || NULL > NULL;
+ b = NULL <= NULL || NULL >= NULL;
+ b = NULL == NULL || NULL != NULL;
+
+ b = ((NULL)) != a; // expected-warning{{comparison between NULL and non-pointer (NULL and 'int')}}
+
+ // Check that even non-standard pointers don't warn.
+ b = c == NULL || NULL == c || c != NULL || NULL != c;
+ b = d == NULL || NULL == d || d != NULL || NULL != d;
+ b = e == NULL || NULL == e || e != NULL || NULL != e;
+ b = f == NULL || NULL == f || f != NULL || NULL != f;
+ b = "f" == NULL || NULL == "f" || "f" != NULL || NULL != "f";
+}
diff --git a/clang/test/SemaCXX/nullptr-98.cpp b/clang/test/SemaCXX/nullptr-98.cpp
new file mode 100644
index 0000000..0d624c2
--- /dev/null
+++ b/clang/test/SemaCXX/nullptr-98.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s
+void f(void *);
+void g() { f(__nullptr); }
diff --git a/clang/test/SemaCXX/nullptr.cpp b/clang/test/SemaCXX/nullptr.cpp
new file mode 100644
index 0000000..e313603
--- /dev/null
+++ b/clang/test/SemaCXX/nullptr.cpp
@@ -0,0 +1,185 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -ffreestanding %s
+#include <stdint.h>
+
+typedef decltype(nullptr) nullptr_t;
+
+struct A {};
+
+int o1(char*);
+void o1(uintptr_t);
+void o2(char*); // expected-note {{candidate}}
+void o2(int A::*); // expected-note {{candidate}}
+
+nullptr_t f(nullptr_t null)
+{
+ // Implicit conversions.
+ null = nullptr;
+ void *p = nullptr;
+ p = null;
+ int *pi = nullptr;
+ pi = null;
+ null = 0;
+ int A::*pm = nullptr;
+ pm = null;
+ void (*pf)() = nullptr;
+ pf = null;
+ void (A::*pmf)() = nullptr;
+ pmf = null;
+ bool b = nullptr;
+
+ // Can't convert nullptr to integral implicitly.
+ uintptr_t i = nullptr; // expected-error {{cannot initialize}}
+
+ // Operators
+ (void)(null == nullptr);
+ (void)(null <= nullptr);
+ (void)(null == (void*)0);
+ (void)((void*)0 == nullptr);
+ (void)(null <= (void*)0);
+ (void)((void*)0 <= nullptr);
+ (void)(0 == nullptr);
+ (void)(nullptr == 0);
+ (void)(nullptr <= 0);
+ (void)(0 <= nullptr);
+ (void)(1 > nullptr); // expected-error {{invalid operands to binary expression}}
+ (void)(1 != nullptr); // expected-error {{invalid operands to binary expression}}
+ (void)(1 + nullptr); // expected-error {{invalid operands to binary expression}}
+ (void)(0 ? nullptr : 0); // expected-error {{non-pointer operand type 'int' incompatible with nullptr}}
+ (void)(0 ? nullptr : (void*)0);
+ (void)(0 ? nullptr : A()); // expected-error {{non-pointer operand type 'A' incompatible with nullptr}}
+ (void)(0 ? A() : nullptr); // expected-error {{non-pointer operand type 'A' incompatible with nullptr}}
+
+ // Overloading
+ int t = o1(nullptr);
+ t = o1(null);
+ o2(nullptr); // expected-error {{ambiguous}}
+
+ // nullptr is an rvalue, null is an lvalue
+ (void)&nullptr; // expected-error {{address expression must be an lvalue}}
+ nullptr_t *pn = &null;
+
+ // You can reinterpret_cast nullptr to an integer.
+ (void)reinterpret_cast<uintptr_t>(nullptr);
+ (void)reinterpret_cast<uintptr_t>(*pn);
+
+ int *ip = *pn;
+ if (*pn) { }
+
+ // You can throw nullptr.
+ throw nullptr;
+}
+
+// Template arguments can be nullptr.
+template <int *PI, void (*PF)(), int A::*PM, void (A::*PMF)()>
+struct T {};
+
+typedef T<nullptr, nullptr, nullptr, nullptr> NT;
+
+namespace test1 {
+template<typename T, typename U> struct is_same {
+ static const bool value = false;
+};
+
+template<typename T> struct is_same<T, T> {
+ static const bool value = true;
+};
+
+void *g(void*);
+bool g(bool);
+
+// Test that we prefer g(void*) over g(bool).
+static_assert(is_same<decltype(g(nullptr)), void*>::value, "");
+}
+
+namespace test2 {
+ void f(int, ...) __attribute__((sentinel));
+
+ void g() {
+ // nullptr can be used as the sentinel value.
+ f(10, nullptr);
+ }
+}
+
+namespace test3 {
+ void f(const char*, ...) __attribute__((format(printf, 1, 2)));
+
+ void g() {
+ // Don't warn when using nullptr with %p.
+ f("%p", nullptr);
+ }
+}
+
+static_assert(__is_scalar(nullptr_t), "");
+static_assert(__is_pod(nullptr_t), "");
+static_assert(sizeof(nullptr_t) == sizeof(void*), "");
+
+static_assert(!(nullptr < nullptr), "");
+static_assert(!(nullptr > nullptr), "");
+static_assert( nullptr <= nullptr, "");
+static_assert( nullptr >= nullptr, "");
+static_assert( nullptr == nullptr, "");
+static_assert(!(nullptr != nullptr), "");
+
+static_assert(!(0 < nullptr), "");
+static_assert(!(0 > nullptr), "");
+static_assert( 0 <= nullptr, "");
+static_assert( 0 >= nullptr, "");
+static_assert( 0 == nullptr, "");
+static_assert(!(0 != nullptr), "");
+
+static_assert(!(nullptr < 0), "");
+static_assert(!(nullptr > 0), "");
+static_assert( nullptr <= 0, "");
+static_assert( nullptr >= 0, "");
+static_assert( nullptr == 0, "");
+static_assert(!(nullptr != 0), "");
+
+namespace overloading {
+ int &f1(int*);
+ float &f1(bool);
+
+ void test_f1() {
+ int &ir = (f1)(nullptr);
+ }
+
+ struct ConvertsToNullPtr {
+ operator nullptr_t() const;
+ };
+
+ void test_conversion(ConvertsToNullPtr ctn) {
+ (void)(ctn == ctn);
+ (void)(ctn != ctn);
+ (void)(ctn <= ctn);
+ (void)(ctn >= ctn);
+ (void)(ctn < ctn);
+ (void)(ctn > ctn);
+ }
+}
+
+namespace templates {
+ template<typename T, nullptr_t Value>
+ struct X {
+ X() { ptr = Value; }
+
+ T *ptr;
+ };
+
+ X<int, nullptr> x;
+
+
+ template<int (*fp)(int), int* p, int A::* pmd, int (A::*pmf)(int)>
+ struct X2 {};
+
+ X2<nullptr, nullptr, nullptr, nullptr> x2;
+}
+
+namespace null_pointer_constant {
+
+// Pending implementation of core issue 903, ensure we don't allow any of the
+// C++11 constant evaluation semantics in null pointer constants.
+struct S { int n; };
+constexpr int null() { return 0; }
+void *p = S().n; // expected-error {{cannot initialize}}
+void *q = null(); // expected-error {{cannot initialize}}
+
+}
diff --git a/clang/test/SemaCXX/nullptr_in_arithmetic_ops.cpp b/clang/test/SemaCXX/nullptr_in_arithmetic_ops.cpp
new file mode 100644
index 0000000..9671353
--- /dev/null
+++ b/clang/test/SemaCXX/nullptr_in_arithmetic_ops.cpp
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -std=c++11 -verify %s
+
+void foo() {
+ int a;
+ bool b;
+
+ a = 0 ? nullptr + a : a + nullptr; // expected-error 2{{invalid operands to binary expression}}
+ a = 0 ? nullptr - a : a - nullptr; // expected-error 2{{invalid operands to binary expression}}
+ a = 0 ? nullptr / a : a / nullptr; // expected-error 2{{invalid operands to binary expression}}
+ a = 0 ? nullptr * a : a * nullptr; // expected-error 2{{invalid operands to binary expression}}
+ a = 0 ? nullptr >> a : a >> nullptr; // expected-error 2{{invalid operands to binary expression}}
+ a = 0 ? nullptr << a : a << nullptr; // expected-error 2{{invalid operands to binary expression}}
+ a = 0 ? nullptr % a : a % nullptr; // expected-error 2{{invalid operands to binary expression}}
+ a = 0 ? nullptr & a : a & nullptr; // expected-error 2{{invalid operands to binary expression}}
+ a = 0 ? nullptr | a : a | nullptr; // expected-error 2{{invalid operands to binary expression}}
+ a = 0 ? nullptr ^ a : a ^ nullptr; // expected-error 2{{invalid operands to binary expression}}
+
+ // Using two nullptrs should only give one error instead of two.
+ a = nullptr + nullptr; // expected-error{{invalid operands to binary expression}}
+ a = nullptr - nullptr; // expected-error{{invalid operands to binary expression}}
+ a = nullptr / nullptr; // expected-error{{invalid operands to binary expression}}
+ a = nullptr * nullptr; // expected-error{{invalid operands to binary expression}}
+ a = nullptr >> nullptr; // expected-error{{invalid operands to binary expression}}
+ a = nullptr << nullptr; // expected-error{{invalid operands to binary expression}}
+ a = nullptr % nullptr; // expected-error{{invalid operands to binary expression}}
+ a = nullptr & nullptr; // expected-error{{invalid operands to binary expression}}
+ a = nullptr | nullptr; // expected-error{{invalid operands to binary expression}}
+ a = nullptr ^ nullptr; // expected-error{{invalid operands to binary expression}}
+
+ a += nullptr; // expected-error{{invalid operands to binary expression}}
+ a -= nullptr; // expected-error{{invalid operands to binary expression}}
+ a /= nullptr; // expected-error{{invalid operands to binary expression}}
+ a *= nullptr; // expected-error{{invalid operands to binary expression}}
+ a >>= nullptr; // expected-error{{invalid operands to binary expression}}
+ a <<= nullptr; // expected-error{{invalid operands to binary expression}}
+ a %= nullptr; // expected-error{{invalid operands to binary expression}}
+ a &= nullptr; // expected-error{{invalid operands to binary expression}}
+ a |= nullptr; // expected-error{{invalid operands to binary expression}}
+ a ^= nullptr; // expected-error{{invalid operands to binary expression}}
+
+ b = a < nullptr || nullptr < a; // expected-error 2{{invalid operands to binary expression}}
+ b = a > nullptr || nullptr > a; // expected-error 2{{invalid operands to binary expression}}
+ b = a <= nullptr || nullptr <= a; // expected-error 2{{invalid operands to binary expression}}
+ b = a >= nullptr || nullptr >= a; // expected-error 2{{invalid operands to binary expression}}
+ b = a == nullptr || nullptr == a; // expected-error 2{{invalid operands to binary expression}}
+ b = a != nullptr || nullptr != a; // expected-error 2{{invalid operands to binary expression}}
+
+ b = &a < nullptr || nullptr < &a || &a > nullptr || nullptr > &a;
+ b = &a <= nullptr || nullptr <= &a || &a >= nullptr || nullptr >= &a;
+ b = &a == nullptr || nullptr == &a || &a != nullptr || nullptr != &a;
+
+ b = nullptr < nullptr || nullptr > nullptr;
+ b = nullptr <= nullptr || nullptr >= nullptr;
+ b = nullptr == nullptr || nullptr != nullptr;
+
+ b = ((nullptr)) != a; // expected-error{{invalid operands to binary expression}}
+
+ void (^c)();
+ c = nullptr;
+ b = c == nullptr || nullptr == c || c != nullptr || nullptr != c;
+
+ class X;
+ void (X::*d) ();
+ d = nullptr;
+ b = d == nullptr || nullptr == d || d != nullptr || nullptr != d;
+
+ extern void e();
+ b = e == nullptr || nullptr == e || e != nullptr || nullptr != e;
+
+ int f[2];
+ b = f == nullptr || nullptr == f || f != nullptr || nullptr != f;
+ b = "f" == nullptr || nullptr == "f" || "f" != nullptr || nullptr != "f";
+}
diff --git a/clang/test/SemaCXX/offsetof.cpp b/clang/test/SemaCXX/offsetof.cpp
new file mode 100644
index 0000000..a5f5d34
--- /dev/null
+++ b/clang/test/SemaCXX/offsetof.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof
+
+struct NonPOD {
+ virtual void f();
+ int m;
+};
+
+struct P {
+ NonPOD fieldThatPointsToANonPODType;
+};
+
+void f() {
+ int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // expected-warning{{offset of on non-POD type 'P'}}
+}
+
+struct Base { int x; };
+struct Derived : Base { int y; };
+int o = __builtin_offsetof(Derived, x); // expected-warning{{offset of on non-POD type}}
+
+const int o2 = sizeof(__builtin_offsetof(Derived, x));
+
+struct HasArray {
+ int array[17];
+};
+
+// Constant and non-constant offsetof expressions
+void test_ice(int i) {
+ int array0[__builtin_offsetof(HasArray, array[5])];
+ int array1[__builtin_offsetof(HasArray, array[i])];
+}
+
+// Bitfields
+struct has_bitfields {
+ int i : 7;
+ int j : 12; // expected-note{{bit-field is declared here}}
+};
+
+int test3 = __builtin_offsetof(struct has_bitfields, j); // expected-error{{cannot compute offset of bit-field 'j'}}
+
+// offsetof referring to members of a base class.
+struct Base1 {
+ int x;
+};
+
+struct Base2 {
+ int y;
+};
+
+struct Derived2 : public Base1, public Base2 {
+ int z;
+};
+
+int derived1[__builtin_offsetof(Derived2, x) == 0? 1 : -1];
+int derived2[__builtin_offsetof(Derived2, y) == 4? 1 : -1];
+int derived3[__builtin_offsetof(Derived2, z) == 8? 1 : -1];
+
+// offsetof referring to anonymous struct in base.
+// PR7769
+struct foo {
+ struct {
+ int x;
+ };
+};
+
+struct bar : public foo {
+};
+
+int anonstruct[__builtin_offsetof(bar, x) == 0 ? 1 : -1];
+
+struct LtoRCheck {
+ int a[10];
+ int f();
+};
+int ltor = __builtin_offsetof(struct LtoRCheck, a[LtoRCheck().f]); // \
+ expected-error {{reference to non-static member function must be called}}
diff --git a/clang/test/SemaCXX/operator-arrow-temporary.cpp b/clang/test/SemaCXX/operator-arrow-temporary.cpp
new file mode 100644
index 0000000..8e79609
--- /dev/null
+++ b/clang/test/SemaCXX/operator-arrow-temporary.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR9615
+
+struct Resource {
+ void doit();
+};
+
+template<int x> struct Lock {
+ ~Lock() { int a[x]; } // expected-error {{declared as an array with a negative size}}
+ Resource* operator->() { return 0; }
+};
+
+struct Accessor {
+ Lock<-1> operator->();
+};
+
+// Make sure we try to instantiate the destructor for Lock here
+void f() { Accessor acc; acc->doit(); } // expected-note {{requested here}}
+
diff --git a/clang/test/SemaCXX/out-of-line-def-mismatch.cpp b/clang/test/SemaCXX/out-of-line-def-mismatch.cpp
new file mode 100644
index 0000000..6ade5b8
--- /dev/null
+++ b/clang/test/SemaCXX/out-of-line-def-mismatch.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s
+
+namespace N2 {
+ struct S1;
+
+ namespace N1 {
+ class C1 {};
+
+ struct S2 {
+ void func(S1*); // expected-note {{type of 1st parameter of member declaration does not match definition ('N2::S1 *' vs 'N2::N1::S1 *')}}
+ void func(C1&, unsigned, const S1*); // expected-note {{type of 3rd parameter of member declaration does not match definition ('const N2::S1 *' vs 'const N2::N1::S1 *')}}
+ void func(const S1*, unsigned); //expected-note {{type of 1st parameter of member declaration does not match definition ('const N2::S1 *' vs 'N2::N1::S1')}}
+ void func(unsigned, const S1*); // expected-note {{type of 1st parameter of member declaration does not match definition ('unsigned int' vs 'unsigned int *')}}
+ };
+
+ struct S1 {};
+ }
+}
+
+void N2::N1::S2::func(S1*) {} // expected-error {{out-of-line definition of 'func' does not match any declaration in 'N2::N1::S2'}}
+void N2::N1::S2::func(C1&, unsigned, const S1*) {} // expected-error {{out-of-line definition of 'func' does not match any declaration in 'N2::N1::S2'}}
+void N2::N1::S2::func(S1*, double) {} // expected-error {{out-of-line definition of 'func' does not match any declaration in 'N2::N1::S2'}}
+void N2::N1::S2::func(S1, unsigned) {} // expected-error {{out-of-line definition of 'func' does not match any declaration in 'N2::N1::S2'}}
+void N2::N1::S2::func(unsigned*, S1*) {} // expected-error {{out-of-line definition of 'func' does not match any declaration in 'N2::N1::S2'}}
diff --git a/clang/test/SemaCXX/overload-0x.cpp b/clang/test/SemaCXX/overload-0x.cpp
new file mode 100644
index 0000000..677d16a
--- /dev/null
+++ b/clang/test/SemaCXX/overload-0x.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+namespace test0 {
+ struct A { // expected-note {{candidate function (the implicit copy assignment operator) not viable: 'this' argument has type 'const test0::A', but method is not marked const}} expected-note {{candidate function (the implicit move assignment operator) not viable: 'this' argument has type 'const test0::A', but method is not marked const}}
+ A &operator=(void*); // expected-note {{candidate function not viable: 'this' argument has type 'const test0::A', but method is not marked const}}
+ };
+
+ void test(const A &a) {
+ a = "help"; // expected-error {{no viable overloaded '='}}
+ }
+}
diff --git a/clang/test/SemaCXX/overload-call-copycon.cpp b/clang/test/SemaCXX/overload-call-copycon.cpp
new file mode 100644
index 0000000..6720cb6
--- /dev/null
+++ b/clang/test/SemaCXX/overload-call-copycon.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wnon-pod-varargs
+class X { }; // expected-note {{the implicit copy constructor}} \
+ // expected-note{{the implicit default constructor}}
+
+int& copycon(X x); // expected-note{{passing argument to parameter}}
+float& copycon(...);
+
+void test_copycon(X x, X const xc, X volatile xv) {
+ int& i1 = copycon(x);
+ int& i2 = copycon(xc);
+ copycon(xv); // expected-error{{no matching constructor}}
+}
+
+class A {
+public:
+ A(A&); // expected-note{{would lose const qualifier}} \
+ // expected-note{{no known conversion}}
+};
+
+class B : public A { }; // expected-note{{would lose const qualifier}} \
+// expected-note{{would lose volatile qualifier}} \
+// expected-note 2{{requires 0 arguments}}
+
+short& copycon2(A a); // expected-note{{passing argument to parameter}}
+int& copycon2(B b); // expected-note 2{{passing argument to parameter}}
+float& copycon2(...);
+
+void test_copycon2(A a, const A ac, B b, B const bc, B volatile bv) {
+ int& i1 = copycon2(b);
+ copycon2(bc); // expected-error{{no matching constructor}}
+ copycon2(bv); // expected-error{{no matching constructor}}
+ short& s1 = copycon2(a);
+ copycon2(ac); // expected-error{{no matching constructor}}
+}
+
+int& copycon3(A a); // expected-note{{passing argument to parameter 'a' here}}
+float& copycon3(...);
+
+void test_copycon3(B b, const B bc) {
+ int& i1 = copycon3(b);
+ copycon3(bc); // expected-error{{no matching constructor}}
+}
+
+class C : public B { };
+
+float& copycon4(A a);
+int& copycon4(B b);
+
+void test_copycon4(C c) {
+ int& i = copycon4(c);
+};
diff --git a/clang/test/SemaCXX/overload-call.cpp b/clang/test/SemaCXX/overload-call.cpp
new file mode 100644
index 0000000..b5e1214
--- /dev/null
+++ b/clang/test/SemaCXX/overload-call.cpp
@@ -0,0 +1,570 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+int* f(int) { return 0; }
+float* f(float) { return 0; }
+void f();
+
+void test_f(int iv, float fv) {
+ float* fp = f(fv);
+ int* ip = f(iv);
+}
+
+int* g(int, float, int); // expected-note {{candidate function}}
+float* g(int, int, int); // expected-note {{candidate function}}
+double* g(int, float, float); // expected-note {{candidate function}}
+char* g(int, float, ...); // expected-note {{candidate function}}
+void g();
+
+void test_g(int iv, float fv) {
+ int* ip1 = g(iv, fv, 0);
+ float* fp1 = g(iv, iv, 0);
+ double* dp1 = g(iv, fv, fv);
+ char* cp1 = g(0, 0);
+ char* cp2 = g(0, 0, 0, iv, fv);
+
+ double* dp2 = g(0, fv, 1.5); // expected-error {{call to 'g' is ambiguous}}
+}
+
+double* h(double f);
+int* h(int);
+
+void test_h(float fv, unsigned char cv) {
+ double* dp = h(fv);
+ int* ip = h(cv);
+}
+
+int* i(int);
+double* i(long);
+
+void test_i(short sv, int iv, long lv, unsigned char ucv) {
+ int* ip1 = i(sv);
+ int* ip2 = i(iv);
+ int* ip3 = i(ucv);
+ double* dp1 = i(lv);
+}
+
+int* j(void*);
+double* j(bool);
+
+void test_j(int* ip) {
+ int* ip1 = j(ip);
+}
+
+int* k(char*);
+double* k(bool);
+
+void test_k() {
+ int* ip1 = k("foo"); // expected-warning{{conversion from string literal to 'char *' is deprecated}}
+ int* ip2 = k(("foo")); // expected-warning{{conversion from string literal to 'char *' is deprecated}}
+ double* dp1 = k(L"foo");
+}
+
+int* l(wchar_t*);
+double* l(bool);
+
+void test_l() {
+ int* ip1 = l(L"foo"); // expected-warning{{conversion from string literal to 'wchar_t *' is deprecated}}
+ double* dp1 = l("foo");
+}
+
+int* m(const char*);
+double* m(char*);
+
+void test_m() {
+ int* ip = m("foo");
+}
+
+int* n(char*);
+double* n(void*);
+class E;
+
+void test_n(E* e) {
+ char ca[7];
+ int* ip1 = n(ca);
+ int* ip2 = n("foo"); // expected-warning{{conversion from string literal to 'char *' is deprecated}}
+
+ float fa[7];
+ double* dp1 = n(fa);
+
+ double* dp2 = n(e);
+}
+
+enum PromotesToInt {
+ PromotesToIntValue = -1
+};
+
+enum PromotesToUnsignedInt {
+ PromotesToUnsignedIntValue = __INT_MAX__ * 2U
+};
+
+int* o(int);
+double* o(unsigned int);
+float* o(long);
+
+void test_o() {
+ int* ip1 = o(PromotesToIntValue);
+ double* dp1 = o(PromotesToUnsignedIntValue);
+}
+
+int* p(int);
+double* p(double);
+
+void test_p() {
+ int* ip = p((short)1);
+ double* dp = p(1.0f);
+}
+
+struct Bits {
+ signed short int_bitfield : 5;
+ unsigned int uint_bitfield : 8;
+};
+
+int* bitfields(int, int);
+float* bitfields(unsigned int, int);
+
+void test_bitfield(Bits bits, int x) {
+ int* ip = bitfields(bits.int_bitfield, 0);
+ float* fp = bitfields(bits.uint_bitfield, 0u);
+}
+
+int* multiparm(long, int, long); // expected-note {{candidate function}}
+float* multiparm(int, int, int); // expected-note {{candidate function}}
+double* multiparm(int, int, short); // expected-note {{candidate function}}
+
+void test_multiparm(long lv, short sv, int iv) {
+ int* ip1 = multiparm(lv, iv, lv);
+ int* ip2 = multiparm(lv, sv, lv);
+ float* fp1 = multiparm(iv, iv, iv);
+ float* fp2 = multiparm(sv, iv, iv);
+ double* dp1 = multiparm(sv, sv, sv);
+ double* dp2 = multiparm(iv, sv, sv);
+ multiparm(sv, sv, lv); // expected-error {{call to 'multiparm' is ambiguous}}
+}
+
+// Test overloading based on qualification vs. no qualification
+// conversion.
+int* quals1(int const * p);
+char* quals1(int * p);
+
+int* quals2(int const * const * pp);
+char* quals2(int * * pp);
+
+int* quals3(int const * * const * ppp);
+char* quals3(int *** ppp);
+
+void test_quals(int * p, int * * pp, int * * * ppp) {
+ char* q1 = quals1(p);
+ char* q2 = quals2(pp);
+ char* q3 = quals3(ppp);
+}
+
+// Test overloading based on qualification ranking (C++ 13.3.2)p3.
+int* quals_rank1(int const * p);
+float* quals_rank1(int const volatile *p);
+char* quals_rank1(char*);
+double* quals_rank1(const char*);
+
+int* quals_rank2(int const * const * pp);
+float* quals_rank2(int * const * pp);
+
+void quals_rank3(int const * const * const volatile * p); // expected-note{{candidate function}}
+void quals_rank3(int const * const volatile * const * p); // expected-note{{candidate function}}
+
+void quals_rank3(int const *); // expected-note{{candidate function}}
+void quals_rank3(int volatile *); // expected-note{{candidate function}}
+
+void test_quals_ranking(int * p, int volatile *pq, int * * pp, int * * * ppp) {
+ int* q1 = quals_rank1(p);
+ float* q2 = quals_rank1(pq);
+ double* q3 = quals_rank1("string literal");
+ char a[17];
+ const char* ap = a;
+ char* q4 = quals_rank1(a);
+ double* q5 = quals_rank1(ap);
+
+ float* q6 = quals_rank2(pp);
+
+ quals_rank3(ppp); // expected-error {{call to 'quals_rank3' is ambiguous}}
+
+ quals_rank3(p); // expected-error {{call to 'quals_rank3' is ambiguous}}
+ quals_rank3(pq);
+}
+
+// Test overloading based on derived-to-base conversions
+class A { };
+class B : public A { };
+class C : public B { };
+class D : public C { };
+
+int* derived1(A*);
+char* derived1(const A*);
+float* derived1(void*);
+
+int* derived2(A*);
+float* derived2(B*);
+
+int* derived3(A*);
+float* derived3(const B*);
+char* derived3(C*);
+
+void test_derived(B* b, B const* bc, C* c, const C* cc, void* v, D* d) {
+ int* d1 = derived1(b);
+ char* d2 = derived1(bc);
+ int* d3 = derived1(c);
+ char* d4 = derived1(cc);
+ float* d5 = derived1(v);
+
+ float* d6 = derived2(b);
+ float* d7 = derived2(c);
+
+ char* d8 = derived3(d);
+}
+
+void derived4(C*); // expected-note{{candidate function not viable: cannot convert from base class pointer 'A *' to derived class pointer 'C *' for 1st argument}}
+
+void test_base(A* a) {
+ derived4(a); // expected-error{{no matching function for call to 'derived4}}
+}
+
+// Test overloading of references.
+// (FIXME: tests binding to determine candidate sets, not overload
+// resolution per se).
+int* intref(int&);
+float* intref(const int&);
+
+void intref_test() {
+ float* ir1 = intref(5);
+ float* ir2 = intref(5.5); // expected-warning{{implicit conversion turns literal floating-point number into integer}}
+}
+
+void derived5(C&); // expected-note{{candidate function not viable: cannot bind base class object of type 'A' to derived class reference 'C &' for 1st argument}}
+
+void test_base(A& a) {
+ derived5(a); // expected-error{{no matching function for call to 'derived5}}
+}
+
+// Test reference binding vs. standard conversions.
+int& bind_vs_conv(const double&);
+float& bind_vs_conv(int);
+
+void bind_vs_conv_test()
+{
+ int& i1 = bind_vs_conv(1.0f);
+ float& f1 = bind_vs_conv((short)1);
+}
+
+// Test that cv-qualifiers get subsumed in the reference binding.
+struct X { };
+struct Y { };
+struct Z : X, Y { };
+
+int& cvqual_subsume(X&); // expected-note{{candidate function}}
+float& cvqual_subsume(const Y&); // expected-note{{candidate function}}
+
+int& cvqual_subsume2(const X&); // expected-note{{candidate function}}
+float& cvqual_subsume2(const volatile Y&); // expected-note{{candidate function}}
+
+Z get_Z();
+
+void cvqual_subsume_test(Z z) {
+ cvqual_subsume(z); // expected-error{{call to 'cvqual_subsume' is ambiguous}}
+ int& x = cvqual_subsume2(get_Z()); // expected-error{{call to 'cvqual_subsume2' is ambiguous}}
+}
+
+// Test overloading with cv-qualification differences in reference
+// binding.
+int& cvqual_diff(X&);
+float& cvqual_diff(const X&);
+
+void cvqual_diff_test(X x, Z z) {
+ int& i1 = cvqual_diff(x);
+ int& i2 = cvqual_diff(z);
+}
+
+// Test overloading with derived-to-base differences in reference
+// binding.
+struct Z2 : Z { };
+
+int& db_rebind(X&);
+long& db_rebind(Y&);
+float& db_rebind(Z&);
+
+void db_rebind_test(Z2 z2) {
+ float& f1 = db_rebind(z2);
+}
+
+class string { };
+class opt : public string { };
+
+struct SR {
+ SR(const string&);
+};
+
+void f(SR) { }
+
+void g(opt o) {
+ f(o);
+}
+
+
+namespace PR5756 {
+ int &a(void*, int);
+ float &a(void*, float);
+ void b() {
+ int &ir = a(0,0);
+ (void)ir;
+ }
+}
+
+// Tests the exact text used to note the candidates
+namespace test1 {
+ template <class T> void foo(T t, unsigned N); // expected-note {{candidate function [with T = int] not viable: no known conversion from 'const char [6]' to 'unsigned int' for 2nd argument}}
+ void foo(int n, char N); // expected-note {{candidate function not viable: no known conversion from 'const char [6]' to 'char' for 2nd argument}}
+ void foo(int n); // expected-note {{candidate function not viable: requires 1 argument, but 2 were provided}}
+ void foo(unsigned n = 10); // expected-note {{candidate function not viable: requires at most 1 argument, but 2 were provided}}
+ void foo(int n, const char *s, int t); // expected-note {{candidate function not viable: requires 3 arguments, but 2 were provided}}
+ void foo(int n, const char *s, int t, ...); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}}
+ void foo(int n, const char *s, int t, int u = 0); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}}
+
+ void test() {
+ foo(4, "hello"); //expected-error {{no matching function for call to 'foo'}}
+ }
+}
+
+// PR 6014
+namespace test2 {
+ struct QFixed {
+ QFixed(int i);
+ QFixed(long i);
+ };
+
+ bool operator==(const QFixed &f, int i);
+
+ class qrgb666 {
+ inline operator unsigned int () const;
+
+ inline bool operator==(const qrgb666 &v) const;
+ inline bool operator!=(const qrgb666 &v) const { return !(*this == v); }
+ };
+}
+
+// PR 6117
+namespace test3 {
+ struct Base {};
+ struct Incomplete;
+
+ void foo(Base *); // expected-note 2 {{cannot convert argument of incomplete type}}
+ void foo(Base &); // expected-note 2 {{cannot convert argument of incomplete type}}
+
+ void test(Incomplete *P) {
+ foo(P); // expected-error {{no matching function for call to 'foo'}}
+ foo(*P); // expected-error {{no matching function for call to 'foo'}}
+ }
+}
+
+namespace DerivedToBaseVsVoid {
+ struct A { };
+ struct B : A { };
+
+ float &f(void *);
+ int &f(const A*);
+
+ void g(B *b) {
+ int &ir = f(b);
+ }
+}
+
+// PR 6398 + PR 6421
+namespace test4 {
+ class A;
+ class B {
+ static void foo(); // expected-note {{not viable}}
+ static void foo(int*); // expected-note {{not viable}}
+ static void foo(long*); // expected-note {{not viable}}
+
+ void bar(A *a) {
+ foo(a); // expected-error {{no matching function for call}}
+ }
+ };
+}
+
+namespace DerivedToBase {
+ struct A { };
+ struct B : A { };
+ struct C : B { };
+
+ int &f0(const A&);
+ float &f0(B);
+
+ void g() {
+ float &fr = f0(C());
+ }
+}
+
+namespace PR6483 {
+ struct X0 {
+ operator const unsigned int & () const;
+ };
+
+ struct X1 {
+ operator unsigned int & () const;
+ };
+
+ void f0(const bool &);
+ void f1(bool &); // expected-note 2{{not viable}}
+
+ void g(X0 x0, X1 x1) {
+ f0(x0);
+ f1(x0); // expected-error{{no matching function for call}}
+ f0(x1);
+ f1(x1); // expected-error{{no matching function for call}}
+ }
+}
+
+namespace PR6078 {
+ struct A {
+ A(short); // expected-note{{candidate constructor}}
+ A(long); // expected-note{{candidate constructor}}
+ };
+ struct S {
+ typedef void ft(A);
+ operator ft*();
+ };
+
+ void f() {
+ S()(0); // expected-error{{conversion from 'int' to 'PR6078::A' is ambiguous}}
+ }
+}
+
+namespace PR6177 {
+ struct String { String(char const*); };
+
+ void f(bool const volatile&); // expected-note{{passing argument to parameter here}}
+ void f(String);
+
+ void g() { f(""); } // expected-error{{volatile lvalue reference to type 'const volatile bool' cannot bind to a value of unrelated type 'const char [1]'}}
+}
+
+namespace PR7095 {
+ struct X { };
+
+ struct Y {
+ operator const X*();
+
+ private:
+ operator X*();
+ };
+
+ void f(const X *);
+ void g(Y y) { f(y); }
+}
+
+namespace PR7224 {
+ class A {};
+ class B : public A {};
+
+ int &foo(A *const d);
+ float &foo(const A *const d);
+
+ void bar()
+ {
+ B *const d = 0;
+ B const *const d2 = 0;
+ int &ir = foo(d);
+ float &fr = foo(d2);
+ }
+}
+
+namespace NontrivialSubsequence {
+ struct X0;
+
+ class A {
+ operator X0 *();
+ public:
+ operator const X0 *();
+ };
+
+ A a;
+ void foo( void const * );
+
+ void g() {
+ foo(a);
+ }
+}
+
+// rdar://rdar8499524
+namespace rdar8499524 {
+ struct W {};
+ struct S {
+ S(...);
+ };
+
+ void g(const S&);
+ void f() {
+ g(W());
+ }
+}
+
+namespace rdar9173984 {
+ template <typename T, unsigned long N> int &f(const T (&)[N]);
+ template <typename T> float &f(const T *);
+
+ void test() {
+ int arr[2] = {0, 0};
+ int *arrp = arr;
+ int &ir = f(arr);
+ float &fr = f(arrp);
+ }
+}
+
+namespace PR9507 {
+ void f(int * const&); // expected-note{{candidate function}}
+ void f(int const(&)[1]); // expected-note{{candidate function}}
+
+ int main() {
+ int n[1];
+ f(n); // expected-error{{call to 'f' is ambiguous}}
+ }
+}
+
+namespace rdar9803316 {
+ void foo(float);
+ int &foo(int);
+
+ void bar() {
+ int &ir = (&foo)(0);
+ }
+}
+
+namespace IncompleteArg {
+ // Ensure that overload resolution attempts to complete argument types when
+ // performing ADL.
+ template<typename T> struct S {
+ friend int f(const S&);
+ };
+ extern S<int> s;
+ int k = f(s);
+
+ template<typename T> struct Op {
+ friend bool operator==(const Op &, const Op &);
+ };
+ extern Op<char> op;
+ bool b = op == op;
+
+ // ... and not in other cases! Nothing here requires U<int()> to be complete.
+ // (Note that instantiating U<int()> will fail.)
+ template<typename T> struct U {
+ T t;
+ };
+ struct Consumer {
+ template<typename T>
+ int operator()(const U<T> &);
+ };
+ template<typename T> U<T> &make();
+ Consumer c;
+ int n = sizeof(c(make<int()>()));
+}
+
+namespace PR12142 {
+ void fun(int (*x)[10]); // expected-note{{candidate function not viable: 1st argument ('const int (*)[10]') would lose const qualifier}}
+ void g() { fun((const int(*)[10])0); } // expected-error{{no matching function for call to 'fun'}}
+}
diff --git a/clang/test/SemaCXX/overload-decl.cpp b/clang/test/SemaCXX/overload-decl.cpp
new file mode 100644
index 0000000..c610ff7
--- /dev/null
+++ b/clang/test/SemaCXX/overload-decl.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+void f();
+void f(int);
+void f(int, float);
+void f(int, int);
+void f(int, ...);
+
+typedef float Float;
+void f(int, Float); // expected-note {{previous declaration is here}}
+
+int f(int, Float); // expected-error {{functions that differ only in their return type cannot be overloaded}}
+
+void g(void); // expected-note {{previous declaration is here}}
+int g(); // expected-error {{functions that differ only in their return type cannot be overloaded}}
+
+typedef int INT;
+
+class X {
+ void f();
+ void f(int); // expected-note {{previous declaration is here}}
+ void f() const;
+
+ void f(INT); // expected-error{{cannot be redeclared}}
+
+ void g(int); // expected-note {{previous declaration is here}}
+ void g(int, float); // expected-note {{previous declaration is here}}
+ int g(int, Float); // expected-error {{functions that differ only in their return type cannot be overloaded}}
+
+ static void g(float);
+ static void g(int); // expected-error {{static and non-static member functions with the same parameter types cannot be overloaded}}
+};
diff --git a/clang/test/SemaCXX/overload-member-call.cpp b/clang/test/SemaCXX/overload-member-call.cpp
new file mode 100644
index 0000000..37c9552
--- /dev/null
+++ b/clang/test/SemaCXX/overload-member-call.cpp
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct X {
+ int& f(int) const; // expected-note 2 {{candidate function}}
+ float& f(int); // expected-note 2 {{candidate function}}
+
+ void test_f(int x) const {
+ int& i = f(x);
+ }
+
+ void test_f2(int x) {
+ float& f2 = f(x);
+ }
+
+ int& g(int) const; // expected-note 2 {{candidate function}}
+ float& g(int); // expected-note 2 {{candidate function}}
+ static double& g(double); // expected-note 2 {{candidate function}}
+
+ void h(int);
+
+ void test_member() {
+ float& f1 = f(0);
+ float& f2 = g(0);
+ double& d1 = g(0.0);
+ }
+
+ void test_member_const() const {
+ int &i1 = f(0);
+ int &i2 = g(0);
+ double& d1 = g(0.0);
+ }
+
+ static void test_member_static() {
+ double& d1 = g(0.0);
+ g(0); // expected-error{{call to 'g' is ambiguous}}
+ }
+};
+
+void test(X x, const X xc, X* xp, const X* xcp, volatile X xv, volatile X* xvp) {
+ int& i1 = xc.f(0);
+ int& i2 = xcp->f(0);
+ float& f1 = x.f(0);
+ float& f2 = xp->f(0);
+ xv.f(0); // expected-error{{no matching member function for call to 'f'}}
+ xvp->f(0); // expected-error{{no matching member function for call to 'f'}}
+
+ int& i3 = xc.g(0);
+ int& i4 = xcp->g(0);
+ float& f3 = x.g(0);
+ float& f4 = xp->g(0);
+ double& d1 = xp->g(0.0);
+ double& d2 = X::g(0.0);
+ X::g(0); // expected-error{{call to 'g' is ambiguous}}
+
+ X::h(0); // expected-error{{call to non-static member function without an object argument}}
+}
+
+struct X1 {
+ int& member();
+ float& member() const;
+};
+
+struct X2 : X1 { };
+
+void test_X2(X2 *x2p, const X2 *cx2p) {
+ int &ir = x2p->member();
+ float &fr = cx2p->member();
+}
+
+// Tests the exact text used to note the candidates
+namespace test1 {
+ class A {
+ template <class T> void foo(T t, unsigned N); // expected-note {{candidate function [with T = int] not viable: no known conversion from 'const char [6]' to 'unsigned int' for 2nd argument}}
+ void foo(int n, char N); // expected-note {{candidate function not viable: no known conversion from 'const char [6]' to 'char' for 2nd argument}}
+ void foo(int n); // expected-note {{candidate function not viable: requires 1 argument, but 2 were provided}}
+ void foo(unsigned n = 10); // expected-note {{candidate function not viable: requires at most 1 argument, but 2 were provided}}
+ void foo(int n, const char *s, int t); // expected-note {{candidate function not viable: requires 3 arguments, but 2 were provided}}
+ void foo(int n, const char *s, int t, ...); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}}
+ void foo(int n, const char *s, int t, int u = 0); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}}
+
+ void bar(double d); //expected-note {{candidate function not viable: 'this' argument has type 'const test1::A', but method is not marked const}}
+ void bar(int i); //expected-note {{candidate function not viable: 'this' argument has type 'const test1::A', but method is not marked const}}
+
+ void baz(A &d); // expected-note {{candidate function not viable: 1st argument ('const test1::A') would lose const qualifier}}
+ void baz(int i); // expected-note {{candidate function not viable: no known conversion from 'const test1::A' to 'int' for 1st argument}}
+ };
+
+ void test() {
+ A a;
+ a.foo(4, "hello"); //expected-error {{no matching member function for call to 'foo'}}
+
+ const A b = A();
+ b.bar(0); //expected-error {{no matching member function for call to 'bar'}}
+
+ a.baz(b); //expected-error {{no matching member function for call to 'baz'}}
+ }
+}
+
diff --git a/clang/test/SemaCXX/overload-value-dep-arg.cpp b/clang/test/SemaCXX/overload-value-dep-arg.cpp
new file mode 100644
index 0000000..c1834a7
--- /dev/null
+++ b/clang/test/SemaCXX/overload-value-dep-arg.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class C {
+ C(void*);
+};
+
+int f(const C&);
+int f(unsigned long);
+
+template<typename T> int f(const T* t) {
+ return f(reinterpret_cast<unsigned long>(t));
+}
+
diff --git a/clang/test/SemaCXX/overloaded-builtin-operators-0x.cpp b/clang/test/SemaCXX/overloaded-builtin-operators-0x.cpp
new file mode 100644
index 0000000..6a5a162
--- /dev/null
+++ b/clang/test/SemaCXX/overloaded-builtin-operators-0x.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -fshow-overloads=best -std=c++11 -verify %s
+
+template <class T>
+struct X
+{
+ operator T() const {return T();}
+};
+
+void test_char16t(X<char16_t> x) {
+ bool b = x == char16_t();
+}
diff --git a/clang/test/SemaCXX/overloaded-builtin-operators.cpp b/clang/test/SemaCXX/overloaded-builtin-operators.cpp
new file mode 100644
index 0000000..b3c0808
--- /dev/null
+++ b/clang/test/SemaCXX/overloaded-builtin-operators.cpp
@@ -0,0 +1,239 @@
+// RUN: %clang_cc1 -fsyntax-only -fshow-overloads=best -verify %s
+struct yes;
+struct no;
+
+struct Short {
+ operator short();
+};
+
+struct Long {
+ operator long();
+};
+
+enum E1 { };
+struct Enum1 {
+ operator E1();
+};
+
+enum E2 { };
+struct Enum2 {
+ operator E2();
+};
+
+
+struct X {
+ void f();
+};
+
+typedef void (X::*pmf)();
+struct Xpmf {
+ operator pmf();
+};
+
+yes& islong(long);
+yes& islong(unsigned long); // FIXME: shouldn't be needed
+no& islong(int);
+
+void f(Short s, Long l, Enum1 e1, Enum2 e2, Xpmf pmf) {
+ // C++ [over.built]p8
+ int i1 = +e1;
+ int i2 = -e2;
+
+ // C++ [over.built]p10:
+ int i3 = ~s;
+ bool b1 = !s;
+
+ // C++ [over.built]p12
+ (void)static_cast<yes&>(islong(s + l));
+ (void)static_cast<no&>(islong(s + s));
+
+ // C++ [over.built]p16
+ (void)(pmf == &X::f);
+ (void)(pmf == 0);
+
+ // C++ [over.built]p17
+ (void)static_cast<yes&>(islong(s % l));
+ (void)static_cast<yes&>(islong(l << s));
+ (void)static_cast<no&>(islong(s << l));
+ (void)static_cast<yes&>(islong(e1 % l));
+ // FIXME: should pass (void)static_cast<no&>(islong(e1 % e2));
+}
+
+struct ShortRef { // expected-note{{candidate function (the implicit copy assignment operator)}}
+ operator short&();
+};
+
+struct LongRef {
+ operator volatile long&();
+};
+
+struct XpmfRef { // expected-note{{candidate function (the implicit copy assignment operator)}}
+ operator pmf&();
+};
+
+struct E2Ref {
+ operator E2&();
+};
+
+void g(ShortRef sr, LongRef lr, E2Ref e2_ref, XpmfRef pmf_ref) {
+ // C++ [over.built]p3
+ short s1 = sr++;
+
+ // C++ [over.built]p3
+ long l1 = lr--;
+
+ // C++ [over.built]p18
+ short& sr1 = (sr *= lr);
+ volatile long& lr1 = (lr *= sr);
+
+ // C++ [over.built]p20:
+ E2 e2r2;
+ e2r2 = e2_ref;
+
+ pmf &pmr = (pmf_ref = &X::f); // expected-error{{no viable overloaded '='}}
+ pmf pmr2;
+ pmr2 = pmf_ref;
+
+ // C++ [over.built]p22
+ short& sr2 = (sr %= lr);
+ volatile long& lr2 = (lr <<= sr);
+
+ bool b1 = (sr && lr) || (sr || lr);
+}
+
+struct VolatileIntPtr {
+ operator int volatile *();
+};
+
+struct ConstIntPtr {
+ operator int const *();
+};
+
+struct VolatileIntPtrRef {
+ operator int volatile *&();
+};
+
+struct ConstIntPtrRef {
+ operator int const *&();
+};
+
+void test_with_ptrs(VolatileIntPtr vip, ConstIntPtr cip, ShortRef sr,
+ VolatileIntPtrRef vipr, ConstIntPtrRef cipr) {
+ const int& cir1 = cip[sr];
+ const int& cir2 = sr[cip];
+ volatile int& vir1 = vip[sr];
+ volatile int& vir2 = sr[vip];
+ bool b1 = (vip == cip);
+ long p1 = vip - cip;
+
+ // C++ [over.built]p5:
+ int volatile *vip1 = vipr++;
+ int const *cip1 = cipr++;
+ int volatile *&vipr1 = ++vipr;
+ int const *&cipr1 = --cipr;
+
+ // C++ [over.built]p6:
+ int volatile &ivr = *vip;
+
+ // C++ [over.built]p8:
+ int volatile *vip2 = +vip;
+ int i1 = +sr;
+ int i2 = -sr;
+
+ // C++ [over.built]p13:
+ int volatile &ivr2 = vip[17];
+ int const &icr2 = 17[cip];
+}
+
+// C++ [over.match.open]p4
+
+void test_assign_restrictions(ShortRef& sr) {
+ sr = (short)0; // expected-error{{no viable overloaded '='}}
+}
+
+struct Base { };
+struct Derived1 : Base { };
+struct Derived2 : Base { };
+
+template<typename T>
+struct ConvertibleToPtrOf {
+ operator T*();
+};
+
+bool test_with_base_ptrs(ConvertibleToPtrOf<Derived1> d1,
+ ConvertibleToPtrOf<Derived2> d2) {
+ return d1 == d2; // expected-error{{invalid operands}}
+}
+
+// DR425
+struct A {
+ template< typename T > operator T() const;
+};
+
+void test_dr425(A a) {
+ // FIXME: lots of candidates here!
+ (void)(1.0f * a); // expected-error{{ambiguous}} \
+ // expected-note 4{{candidate}} \
+ // expected-note {{remaining 77 candidates omitted; pass -fshow-overloads=all to show them}}
+}
+
+// pr5432
+enum e {X};
+
+const int a[][2] = {{1}};
+
+int test_pr5432() {
+ return a[X][X];
+}
+
+void f() {
+ (void)__extension__(A());
+}
+
+namespace PR7319 {
+ typedef enum { Enum1, Enum2, Enum3 } MyEnum;
+
+ template<typename X> bool operator>(const X &inX1, const X &inX2);
+
+ void f() {
+ MyEnum e1, e2;
+ if (e1 > e2) {}
+ }
+}
+
+namespace PR8477 {
+ struct Foo {
+ operator bool();
+ operator const char *();
+ };
+
+ bool doit() {
+ Foo foo;
+ long long zero = 0;
+ (void)(foo + zero);
+ (void)(foo - zero);
+ (void)(zero + foo);
+ (void)(zero[foo]);
+ (void)(foo - foo); // expected-error{{use of overloaded operator '-' is ambiguous}} \
+ // expected-note 4{{built-in candidate operator-}} \
+ // expected-note{{candidates omitted}}
+ return foo[zero] == zero;
+ }
+}
+
+namespace PR7851 {
+ struct X {
+ operator const void *() const;
+ operator void *();
+
+ operator const unsigned *() const;
+ operator unsigned *();
+ };
+
+ void f() {
+ X x;
+ x[0] = 1;
+ *x = 0;
+ (void)(x - x);
+ }
+}
diff --git a/clang/test/SemaCXX/overloaded-name.cpp b/clang/test/SemaCXX/overloaded-name.cpp
new file mode 100644
index 0000000..6da0354
--- /dev/null
+++ b/clang/test/SemaCXX/overloaded-name.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int ovl(int); // expected-note 3{{possible target for call}}
+float ovl(float); // expected-note 3{{possible target for call}}
+
+template<typename T> T ovl(T); // expected-note 3{{possible target for call}}
+
+void test(bool b) {
+ (void)((void)0, ovl); // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
+ // PR7863
+ (void)(b? ovl : &ovl); // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
+ (void)(b? ovl<float> : &ovl); // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
+ (void)(b? ovl<float> : ovl<float>);
+}
+
+namespace rdar9623945 {
+ void f(...) {
+ }
+
+ class X {
+ public:
+ const char* text(void);
+ void g(void) {
+ f(text());
+ f(text); // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
+ f(text());
+ f(text); // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
+ }
+ };
+}
diff --git a/clang/test/SemaCXX/overloaded-operator-decl.cpp b/clang/test/SemaCXX/overloaded-operator-decl.cpp
new file mode 100644
index 0000000..4519a2d
--- /dev/null
+++ b/clang/test/SemaCXX/overloaded-operator-decl.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct X {
+ X();
+ X(int);
+};
+
+X operator+(X, X);
+X operator-(X, X) { X x; return x; }
+
+struct Y {
+ Y operator-() const;
+ void operator()(int x = 17) const;
+ int operator[](int);
+
+ static int operator+(Y, Y); // expected-error{{overloaded 'operator+' cannot be a static member function}}
+};
+
+
+void f(X x) {
+ x = operator+(x, x);
+}
+
+X operator+(int, float); // expected-error{{overloaded 'operator+' must have at least one parameter of class or enumeration type}}
+
+X operator*(X, X = 5); // expected-error{{parameter of overloaded 'operator*' cannot have a default argument}}
+
+X operator/(X, X, ...); // expected-error{{overloaded 'operator/' cannot be variadic}}
+
+X operator%(Y); // expected-error{{overloaded 'operator%' must be a binary operator (has 1 parameter)}}
+
+void operator()(Y&, int, int); // expected-error{{overloaded 'operator()' must be a non-static member function}}
+
+typedef int INT;
+typedef float FLOAT;
+Y& operator++(Y&);
+Y operator++(Y&, INT);
+X operator++(X&, FLOAT); // expected-error{{parameter of overloaded post-increment operator must have type 'int' (not 'FLOAT' (aka 'float'))}}
+
+int operator+; // expected-error{{'operator+' cannot be the name of a variable or data member}}
+
+namespace PR6238 {
+ static struct {
+ void operator()();
+ } plus;
+}
+
+struct PR10839 {
+ operator int; // expected-error{{'operator int' cannot be the name of a variable or data member}}
+ int operator+; // expected-error{{'operator+' cannot be the name of a variable or data member}}
+};
diff --git a/clang/test/SemaCXX/overloaded-operator.cpp b/clang/test/SemaCXX/overloaded-operator.cpp
new file mode 100644
index 0000000..8ecb54d
--- /dev/null
+++ b/clang/test/SemaCXX/overloaded-operator.cpp
@@ -0,0 +1,417 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class X { };
+
+X operator+(X, X);
+
+void f(X x) {
+ x = x + x;
+}
+
+struct Y;
+struct Z;
+
+struct Y {
+ Y(const Z&);
+};
+
+struct Z {
+ Z(const Y&);
+};
+
+Y operator+(Y, Y);
+bool operator-(Y, Y); // expected-note{{candidate function}}
+bool operator-(Z, Z); // expected-note{{candidate function}}
+
+void g(Y y, Z z) {
+ y = y + z;
+ bool b = y - z; // expected-error{{use of overloaded operator '-' is ambiguous}}
+}
+
+struct A {
+ bool operator==(Z&); // expected-note 2{{candidate function}}
+};
+
+A make_A();
+
+bool operator==(A&, Z&); // expected-note 3{{candidate function}}
+
+void h(A a, const A ac, Z z) {
+ make_A() == z; // expected-warning{{equality comparison result unused}}
+ a == z; // expected-error{{use of overloaded operator '==' is ambiguous}}
+ ac == z; // expected-error{{invalid operands to binary expression ('const A' and 'Z')}}
+}
+
+struct B {
+ bool operator==(const B&) const;
+
+ void test(Z z) {
+ make_A() == z; // expected-warning{{equality comparison result unused}}
+ }
+};
+
+// we shouldn't see warnings about self-comparison,
+// this is a member function, we dunno what it'll do
+bool i(B b)
+{
+ return b == b;
+}
+
+enum Enum1 { };
+enum Enum2 { };
+
+struct E1 {
+ E1(Enum1) { }
+};
+
+struct E2 {
+ E2(Enum2);
+};
+
+// C++ [over.match.oper]p3 - enum restriction.
+float& operator==(E1, E2); // expected-note{{candidate function}}
+
+void enum_test(Enum1 enum1, Enum2 enum2, E1 e1, E2 e2, Enum1 next_enum1) {
+ float &f1 = (e1 == e2);
+ float &f2 = (enum1 == e2);
+ float &f3 = (e1 == enum2);
+ float &f4 = (enum1 == next_enum1); // expected-error{{non-const lvalue reference to type 'float' cannot bind to a temporary of type 'bool'}}
+}
+
+// PR5244 - Argument-dependent lookup would include the two operators below,
+// which would break later assumptions and lead to a crash.
+class pr5244_foo
+{
+ pr5244_foo(int);
+ pr5244_foo(char);
+};
+
+bool operator==(const pr5244_foo& s1, const pr5244_foo& s2); // expected-note{{candidate function}}
+bool operator==(char c, const pr5244_foo& s); // expected-note{{candidate function}}
+
+enum pr5244_bar
+{
+ pr5244_BAR
+};
+
+class pr5244_baz
+{
+public:
+ pr5244_bar quux;
+};
+
+void pr5244_barbaz()
+{
+ pr5244_baz quuux;
+ (void)(pr5244_BAR == quuux.quux);
+}
+
+
+
+struct PostInc {
+ PostInc operator++(int);
+ PostInc& operator++();
+};
+
+struct PostDec {
+ PostDec operator--(int);
+ PostDec& operator--();
+};
+
+void incdec_test(PostInc pi, PostDec pd) {
+ const PostInc& pi1 = pi++;
+ const PostDec& pd1 = pd--;
+ PostInc &pi2 = ++pi;
+ PostDec &pd2 = --pd;
+}
+
+struct SmartPtr {
+ int& operator*();
+ long& operator*() const volatile;
+};
+
+void test_smartptr(SmartPtr ptr, const SmartPtr cptr,
+ const volatile SmartPtr cvptr) {
+ int &ir = *ptr;
+ long &lr = *cptr;
+ long &lr2 = *cvptr;
+}
+
+
+struct ArrayLike {
+ int& operator[](int);
+};
+
+void test_arraylike(ArrayLike a) {
+ int& ir = a[17];
+}
+
+struct SmartRef {
+ int* operator&();
+};
+
+void test_smartref(SmartRef r) {
+ int* ip = &r;
+}
+
+bool& operator,(X, Y);
+
+void test_comma(X x, Y y) {
+ bool& b1 = (x, y);
+ X& xr = (x, x); // expected-warning {{expression result unused}}
+}
+
+struct Callable {
+ int& operator()(int, double = 2.71828); // expected-note{{candidate function}}
+ float& operator()(int, double, long, ...); // expected-note{{candidate function}}
+
+ double& operator()(float); // expected-note{{candidate function}}
+};
+
+struct Callable2 {
+ int& operator()(int i = 0);
+ double& operator()(...) const;
+};
+
+struct DerivesCallable : public Callable {
+};
+
+void test_callable(Callable c, Callable2 c2, const Callable2& c2c,
+ DerivesCallable dc) {
+ int &ir = c(1);
+ float &fr = c(1, 3.14159, 17, 42);
+
+ c(); // expected-error{{no matching function for call to object of type 'Callable'}}
+
+ double &dr = c(1.0f);
+
+ int &ir2 = c2();
+ int &ir3 = c2(1);
+ double &fr2 = c2c();
+
+ int &ir4 = dc(17);
+ double &fr3 = dc(3.14159f);
+}
+
+typedef float FLOAT;
+typedef int& INTREF;
+typedef INTREF Func1(FLOAT, double);
+typedef float& Func2(int, double);
+
+struct ConvertToFunc {
+ operator Func1*(); // expected-note 2{{conversion candidate of type 'INTREF (*)(FLOAT, double)'}}
+ operator Func2&(); // expected-note 2{{conversion candidate of type 'float &(&)(int, double)'}}
+ void operator()();
+};
+
+struct ConvertToFuncDerived : ConvertToFunc { };
+
+void test_funcptr_call(ConvertToFunc ctf, ConvertToFuncDerived ctfd) {
+ int &i1 = ctf(1.0f, 2.0);
+ float &f1 = ctf((short int)1, 1.0f);
+ ctf((long int)17, 2.0); // expected-error{{call to object of type 'ConvertToFunc' is ambiguous}}
+ ctf();
+
+ int &i2 = ctfd(1.0f, 2.0);
+ float &f2 = ctfd((short int)1, 1.0f);
+ ctfd((long int)17, 2.0); // expected-error{{call to object of type 'ConvertToFuncDerived' is ambiguous}}
+ ctfd();
+}
+
+struct HasMember {
+ int m;
+};
+
+struct Arrow1 {
+ HasMember* operator->();
+};
+
+struct Arrow2 {
+ Arrow1 operator->(); // expected-note{{candidate function}}
+};
+
+void test_arrow(Arrow1 a1, Arrow2 a2, const Arrow2 a3) {
+ int &i1 = a1->m;
+ int &i2 = a2->m;
+ a3->m; // expected-error{{no viable overloaded 'operator->'}}
+}
+
+struct CopyConBase {
+};
+
+struct CopyCon : public CopyConBase {
+ CopyCon(const CopyConBase &Base);
+
+ CopyCon(const CopyConBase *Base) {
+ *this = *Base;
+ }
+};
+
+namespace N {
+ struct X { };
+}
+
+namespace M {
+ N::X operator+(N::X, N::X);
+}
+
+namespace M {
+ void test_X(N::X x) {
+ (void)(x + x);
+ }
+}
+
+struct AA { bool operator!=(AA&); };
+struct BB : AA {};
+bool x(BB y, BB z) { return y != z; }
+
+
+struct AX {
+ AX& operator ->(); // expected-note {{declared here}}
+ int b;
+};
+
+void m() {
+ AX a;
+ a->b = 0; // expected-error {{circular pointer delegation detected}}
+}
+
+struct CircA {
+ struct CircB& operator->(); // expected-note {{declared here}}
+ int val;
+};
+struct CircB {
+ struct CircC& operator->(); // expected-note {{declared here}}
+};
+struct CircC {
+ struct CircA& operator->(); // expected-note {{declared here}}
+};
+
+void circ() {
+ CircA a;
+ a->val = 0; // expected-error {{circular pointer delegation detected}}
+}
+
+// PR5360: Arrays should lead to built-in candidates for subscript.
+typedef enum {
+ LastReg = 23,
+} Register;
+class RegAlloc {
+ int getPriority(Register r) {
+ return usepri[r];
+ }
+ int usepri[LastReg + 1];
+};
+
+// PR5546: Don't generate incorrect and ambiguous overloads for multi-level
+// arrays.
+namespace pr5546
+{
+ enum { X };
+ extern const char *const sMoveCommands[][2][2];
+ const char* a() { return sMoveCommands[X][0][0]; }
+ const char* b() { return (*(sMoveCommands+X))[0][0]; }
+}
+
+// PR5512 and its discussion
+namespace pr5512 {
+ struct Y {
+ operator short();
+ operator float();
+ };
+ void g_test(Y y) {
+ short s = 0;
+ // DR507, this should be ambiguous, but we special-case assignment
+ s = y;
+ // Note: DR507, this is ambiguous as specified
+ //s += y;
+ }
+
+ struct S {};
+ void operator +=(int&, S);
+ void f(S s) {
+ int i = 0;
+ i += s;
+ }
+
+ struct A {operator int();};
+ int a;
+ void b(A x) {
+ a += x;
+ }
+}
+
+// PR5900
+namespace pr5900 {
+ struct NotAnArray {};
+ void test0() {
+ NotAnArray x;
+ x[0] = 0; // expected-error {{does not provide a subscript operator}}
+ }
+
+ struct NonConstArray {
+ int operator[](unsigned); // expected-note {{candidate}}
+ };
+ int test1() {
+ const NonConstArray x = NonConstArray();
+ return x[0]; // expected-error {{no viable overloaded operator[] for type}}
+ }
+
+ // Not really part of this PR, but implemented at the same time.
+ struct NotAFunction {};
+ void test2() {
+ NotAFunction x;
+ x(); // expected-error {{does not provide a call operator}}
+ }
+}
+
+// Operator lookup through using declarations.
+namespace N {
+ struct X2 { };
+}
+
+namespace N2 {
+ namespace M {
+ namespace Inner {
+ template<typename T>
+ N::X2 &operator<<(N::X2&, const T&);
+ }
+ using Inner::operator<<;
+ }
+}
+
+void test_lookup_through_using() {
+ using namespace N2::M;
+ N::X2 x;
+ x << 17;
+}
+
+namespace rdar9136502 {
+ struct X {
+ int i();
+ int i(int);
+ };
+
+ struct Y {
+ Y &operator<<(int);
+ };
+
+ void f(X x, Y y) {
+ y << x.i; // expected-error{{reference to non-static member function must be called}}
+ }
+}
+
+namespace rdar9222009 {
+class StringRef {
+ inline bool operator==(StringRef LHS, StringRef RHS) { // expected-error{{overloaded 'operator==' must be a binary operator (has 3 parameters)}}
+ return !(LHS == RHS); // expected-error{{invalid operands to binary expression ('rdar9222009::StringRef' and 'rdar9222009::StringRef')}}
+ }
+};
+
+}
+
+namespace PR11784 {
+ struct A { A& operator=(void (*x)()); };
+ void f();
+ void f(int);
+ void g() { A x; x = f; }
+}
diff --git a/clang/test/SemaCXX/pascal-strings.cpp b/clang/test/SemaCXX/pascal-strings.cpp
new file mode 100644
index 0000000..89194b5
--- /dev/null
+++ b/clang/test/SemaCXX/pascal-strings.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -fpascal-strings
+const wchar_t *pascalString = L"\pThis is a Pascal string";
+
+unsigned char a[3] = "\pa";
+unsigned char b[3] = "\pab";
+unsigned char c[3] = "\pabc"; // expected-error {{initializer-string for char array is too long}}
diff --git a/clang/test/SemaCXX/pragma-pack.cpp b/clang/test/SemaCXX/pragma-pack.cpp
new file mode 100644
index 0000000..1bc738b
--- /dev/null
+++ b/clang/test/SemaCXX/pragma-pack.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -verify %s
+
+namespace rdar8745206 {
+
+struct Base {
+ int i;
+};
+
+#pragma pack(push, 1)
+struct Sub : public Base {
+ char c;
+};
+#pragma pack(pop)
+
+int check[sizeof(Sub) == 5 ? 1 : -1];
+
+}
+
+namespace check2 {
+
+struct Base {
+ virtual ~Base();
+ int x;
+};
+
+#pragma pack(push, 1)
+struct Sub : virtual Base {
+ char c;
+};
+#pragma pack(pop)
+
+int check[sizeof(Sub) == 13 ? 1 : -1];
+
+}
diff --git a/clang/test/SemaCXX/pragma-unused.cpp b/clang/test/SemaCXX/pragma-unused.cpp
new file mode 100644
index 0000000..c9ddffa
--- /dev/null
+++ b/clang/test/SemaCXX/pragma-unused.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -Wunused -verify %s
+
+struct S {
+ void m(int x, int y) {
+ int z;
+ #pragma unused(x,y,z)
+ }
+};
diff --git a/clang/test/SemaCXX/pragma-visibility.cpp b/clang/test/SemaCXX/pragma-visibility.cpp
new file mode 100644
index 0000000..e3ef97a
--- /dev/null
+++ b/clang/test/SemaCXX/pragma-visibility.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace test1 __attribute__((visibility("hidden"))) { // expected-note{{surrounding namespace with visibility attribute starts here}}
+#pragma GCC visibility pop // expected-error{{#pragma visibility pop with no matching #pragma visibility push}}
+}
+
+// GCC 4.6 accepts this, but the "hidden" leaks past the namespace end.
+namespace test2 __attribute__((visibility("hidden"))) {
+#pragma GCC visibility push(protected) // expected-error{{#pragma visibility push with no matching #pragma visibility pop}}
+} // expected-note{{surrounding namespace with visibility attribute ends here}}
+
+#pragma GCC visibility pop // expected-error{{#pragma visibility pop with no matching #pragma visibility push}}
+
+// <rdar://problem/10871094>
+struct A {
+ #pragma GCC visibility push(protected)
+ #pragma GCC visibility pop
+};
+
+void f() {
+ #pragma GCC visibility push(protected)
+ #pragma GCC visibility pop
+}
diff --git a/clang/test/SemaCXX/prefetch-enum.cpp b/clang/test/SemaCXX/prefetch-enum.cpp
new file mode 100644
index 0000000..3c77dae
--- /dev/null
+++ b/clang/test/SemaCXX/prefetch-enum.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+// PR5679
+
+enum X { A = 3 };
+
+void Test() {
+ char ch;
+ __builtin_prefetch(&ch, 0, A);
+}
diff --git a/clang/test/SemaCXX/primary-base.cpp b/clang/test/SemaCXX/primary-base.cpp
new file mode 100644
index 0000000..a6cbbad
--- /dev/null
+++ b/clang/test/SemaCXX/primary-base.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class A { virtual void f(); };
+class B : virtual A { };
+
+class C : B { };
+
+// Since A is already a primary base class, C should be the primary base class
+// of F.
+class F : virtual A, virtual C { };
+
+int sa[sizeof(F) == sizeof(A) ? 1 : -1];
diff --git a/clang/test/SemaCXX/pseudo-destructors.cpp b/clang/test/SemaCXX/pseudo-destructors.cpp
new file mode 100644
index 0000000..a8f6683
--- /dev/null
+++ b/clang/test/SemaCXX/pseudo-destructors.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct A {};
+
+enum Foo { F };
+typedef Foo Bar; // expected-note{{type 'Bar' (aka 'Foo') is declared here}}
+
+typedef int Integer;
+typedef double Double;
+
+void g();
+
+namespace N {
+ typedef Foo Wibble;
+ typedef int OtherInteger;
+}
+
+template <typename T>
+void cv_test(const volatile T* cvt) {
+ cvt->T::~T(); // no-warning
+}
+
+void f(A* a, Foo *f, int *i, double *d, int ii) {
+ a->~A();
+ a->A::~A();
+
+ a->~foo(); // expected-error{{identifier 'foo' in object destruction expression does not name a type}}
+
+ a->~Bar(); // expected-error{{destructor type 'Bar' (aka 'Foo') in object destruction expression does not match the type 'A' of the object being destroyed}}
+
+ f->~Bar();
+ f->~Foo();
+ i->~Bar(); // expected-error{{does not match}}
+
+ g().~Bar(); // expected-error{{non-scalar}}
+
+ f->::~Bar();
+ f->N::~Wibble(); // FIXME: technically, Wibble isn't a class-name
+
+ f->::~Bar(17, 42); // expected-error{{cannot have any arguments}}
+
+ i->~Integer();
+ i->Integer::~Integer();
+ i->N::~OtherInteger();
+ i->N::OtherInteger::~OtherInteger();
+ i->N::OtherInteger::~Integer(); // expected-error{{'Integer' does not refer to a type name in pseudo-destructor expression; expected the name of type 'int'}}
+ i->N::~Integer(); // expected-error{{'Integer' does not refer to a type name in pseudo-destructor expression; expected the name of type 'int'}}
+ i->Integer::~Double(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('Double' (aka 'double')) in pseudo-destructor expression}}
+
+ ii->~Integer(); // expected-error{{member reference type 'int' is not a pointer; maybe you meant to use '.'?}}
+ ii.~Integer();
+
+ cv_test(a);
+ cv_test(f);
+ cv_test(i);
+ cv_test(d);
+}
+
+
+typedef int Integer;
+
+void destroy_without_call(int *ip) {
+ ip->~Integer; // expected-error{{called immediately}}
+}
+
+// PR5530
+namespace N1 {
+ class X0 { };
+}
+
+void test_X0(N1::X0 &x0) {
+ x0.~X0();
+}
+
+namespace PR11339 {
+ template<class T>
+ void destroy(T* p) {
+ p->~T(); // ok
+ p->~oops(); // expected-error{{expected the class name after '~' to name a destructor}}
+ }
+
+ template void destroy(int*); // expected-note{{in instantiation of function template specialization}}
+}
diff --git a/clang/test/SemaCXX/ptrtomember-overload-resolution.cpp b/clang/test/SemaCXX/ptrtomember-overload-resolution.cpp
new file mode 100644
index 0000000..787e330
--- /dev/null
+++ b/clang/test/SemaCXX/ptrtomember-overload-resolution.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+// 13.3.3.2 Ranking implicit conversion sequences
+// conversion of A::* to B::* is better than conversion of A::* to C::*,
+struct A {
+int Ai;
+};
+
+struct B : public A {};
+struct C : public B {};
+
+const char * f(int C::*){ return ""; }
+int f(int B::*) { return 1; }
+
+struct D : public C {};
+
+const char * g(int B::*){ return ""; }
+int g(int D::*) { return 1; }
+
+void test()
+{
+ int i = f(&A::Ai);
+
+ const char * str = g(&A::Ai);
+}
+
+// conversion of B::* to C::* is better than conversion of A::* to C::*
+typedef void (A::*pmfa)();
+typedef void (B::*pmfb)();
+typedef void (C::*pmfc)();
+
+struct X {
+ operator pmfa();
+ operator pmfb();
+};
+
+
+void g(pmfc);
+
+void test2(X x)
+{
+ g(x);
+}
+
diff --git a/clang/test/SemaCXX/ptrtomember.cpp b/clang/test/SemaCXX/ptrtomember.cpp
new file mode 100644
index 0000000..aee535e
--- /dev/null
+++ b/clang/test/SemaCXX/ptrtomember.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+struct S {
+ int i;
+
+ int mem(int);
+};
+
+int foo(int S::* ps, S *s)
+{
+ return (s->*ps)(1); // expected-error {{called object type 'int' is not a function or function pointer}}
+}
+
+struct S2 {
+ int bitfield : 1;
+};
+
+int S2::*pf = &S2::bitfield; // expected-error {{address of bit-field requested}}
+
+struct S3 {
+ void m();
+};
+
+void f3(S3* p, void (S3::*m)()) {
+ p->*m; // expected-error {{reference to non-static member function must be called}}
+ (void)(p->*m); // expected-error {{reference to non-static member function must be called}}
+ (void)(void*)(p->*m); // expected-error {{reference to non-static member function must be called}} expected-error {{cannot cast from type 'void' to pointer type 'void *'}}
+ (void)reinterpret_cast<void*>(p->*m); // expected-error {{reference to non-static member function must be called}} expected-error {{reinterpret_cast from 'void' to 'void *' is not allowed}}
+ if (p->*m) {} // expected-error {{reference to non-static member function must be called}} expected-error {{value of type 'void' is not contextually convertible to 'bool'}}
+ if (!(p->*m)) {} // expected-error {{reference to non-static member function must be called}} expected-error {{invalid argument type 'void' to unary expression}}
+ if (p->m) {}; // expected-error {{reference to non-static member function must be called}} expected-error {{value of type 'void' is not contextually convertible to 'bool'}}
+ if (!p->m) {}; // expected-error {{reference to non-static member function must be called}} expected-error {{invalid argument type 'void' to unary expression}}
+}
diff --git a/clang/test/SemaCXX/qual-id-test.cpp b/clang/test/SemaCXX/qual-id-test.cpp
new file mode 100644
index 0000000..9994d75
--- /dev/null
+++ b/clang/test/SemaCXX/qual-id-test.cpp
@@ -0,0 +1,149 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+namespace A
+{
+ namespace B
+ {
+ struct base // expected-note{{object type}}
+ {
+ void x() {}
+ void y() {}
+ };
+ }
+
+ struct member
+ {
+ void foo();
+ };
+
+ struct middleman
+ {
+ member * operator->() { return 0; }
+ };
+
+ struct sub : B::base
+ {
+ void x() {}
+ middleman operator->() { return middleman(); }
+ };
+}
+
+struct bad
+{
+ int x();
+};
+
+namespace C
+{
+ void fun()
+ {
+ A::sub a;
+
+ a.x();
+
+ a.sub::x();
+ a.base::x();
+
+ a.B::base::x(); // expected-error{{use of undeclared identifier 'B'}}
+
+ a.A::sub::x();
+ a.A::B::base::x();
+
+ a.bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}}
+
+ a->foo();
+ a->member::foo();
+ a->A::member::foo();
+ }
+
+ void fun2()
+ {
+ A::sub *a;
+
+ a->x();
+
+ a->sub::x();
+ a->base::x();
+
+ a->B::base::x(); // expected-error{{use of undeclared identifier 'B'}}
+
+ a->A::sub::x();
+ a->A::B::base::x();
+
+ a->bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}}
+
+ (*a)->foo();
+ (*a)->member::foo();
+ (*a)->A::member::foo();
+ }
+
+ void fun3()
+ {
+ int i;
+ i.foo(); // expected-error{{member reference base type 'int' is not a structure or union}}
+ }
+
+ void fun4a() {
+ A::sub *a;
+
+ typedef A::member base; // expected-note{{current scope}}
+ a->base::x(); // expected-error{{ambiguous}}
+ }
+
+ void fun4b() {
+ A::sub *a;
+
+ typedef A::B::base base;
+ a->base::x();
+ }
+
+ template<typename T>
+ void fun5()
+ {
+ T a;
+ a.x();
+ a->foo();
+
+ a.A::sub::x();
+ a.A::B::base::x();
+ a->A::member::foo();
+
+ a.bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}}
+ }
+
+ void test_fun5() {
+ fun5<A::sub>(); // expected-note{{instantiation}}
+ }
+
+ template<typename T>
+ void fun6() {
+ T a;
+ a.sub::x();
+ a.base::x();
+ a->member::foo();
+ a.B::base::x(); // expected-error{{use of undeclared identifier 'B'}}
+ }
+
+ void test_fun6() {
+ fun6<A::sub>(); // expected-note{{instantiation}}
+ }
+
+}
+
+// PR4703
+struct a {
+ int a;
+ static int sa;
+};
+
+a a;
+
+int a::sa = a.a; // expected-error {{invalid use of non-static data member 'a'}}
+
+
+namespace PR6645 {
+ typedef int foo;
+ namespace Inner {
+ typedef int PR6645::foo; // expected-error{{typedef declarator cannot be qualified}} \
+ // expected-error{{cannot define or redeclare 'foo' here because namespace 'Inner' does not enclose namespace 'PR6645'}}
+ }
+}
diff --git a/clang/test/SemaCXX/qualification-conversion.cpp b/clang/test/SemaCXX/qualification-conversion.cpp
new file mode 100644
index 0000000..f1af5bf
--- /dev/null
+++ b/clang/test/SemaCXX/qualification-conversion.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+int* quals1(int const * p);
+int* quals2(int const * const * pp);
+int* quals3(int const * * const * ppp); // expected-note{{candidate function}}
+
+void test_quals(int * p, int * * pp, int * * * ppp) {
+ int const * const * pp2 = pp;
+ quals1(p);
+ quals2(pp);
+ quals3(ppp); // expected-error {{no matching}}
+}
+
+struct A {};
+void mquals1(int const A::*p);
+void mquals2(int const A::* const A::*pp);
+void mquals3(int const A::* A::* const A::*ppp); // expected-note{{candidate function}}
+
+void test_mquals(int A::*p, int A::* A::*pp, int A::* A::* A::*ppp) {
+ int const A::* const A::* pp2 = pp;
+ mquals1(p);
+ mquals2(pp);
+ mquals3(ppp); // expected-error {{no matching}}
+}
+
+void aquals1(int const (*p)[1]);
+void aquals2(int * const (*pp)[1]);
+void aquals2a(int const * (*pp2)[1]); // expected-note{{candidate function}}
+
+void test_aquals(int (*p)[1], int * (*pp)[1], int * (*pp2)[1]) {
+ int const (*p2)[1] = p;
+ aquals1(p);
+ aquals2(pp);
+ aquals2a(pp2); // expected-error {{no matching}}
+}
diff --git a/clang/test/SemaCXX/qualified-id-lookup.cpp b/clang/test/SemaCXX/qualified-id-lookup.cpp
new file mode 100644
index 0000000..d65a468
--- /dev/null
+++ b/clang/test/SemaCXX/qualified-id-lookup.cpp
@@ -0,0 +1,153 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+namespace Ns {
+ int f(); // expected-note{{previous declaration is here}}
+
+ enum E {
+ Enumerator
+ };
+}
+namespace Ns {
+ double f(); // expected-error{{functions that differ only in their return type cannot be overloaded}}
+
+ int x = Enumerator;
+}
+
+namespace Ns2 {
+ float f();
+}
+
+int y = Ns::Enumerator;
+
+namespace Ns2 {
+ float f(int); // expected-note{{previous declaration is here}}
+}
+
+namespace Ns2 {
+ double f(int); // expected-error{{functions that differ only in their return type cannot be overloaded}}
+}
+
+namespace N {
+ int& f1();
+}
+
+namespace N {
+ struct f1 {
+ static int member;
+
+ typedef int type;
+
+ void foo(type);
+ };
+
+ void test_f1() {
+ int &i1 = f1();
+ }
+}
+
+void N::f1::foo(int i) {
+ f1::member = i;
+ f1::type &ir = i;
+}
+
+namespace N {
+ float& f1(int x) {
+ N::f1::type& i1 = x;
+ f1::type& i2 = x;
+ }
+
+ struct f2 {
+ static int member;
+ };
+ void f2();
+}
+
+int i1 = N::f1::member;
+typedef struct N::f1 type1;
+int i2 = N::f2::member;
+typedef struct N::f2 type2;
+
+void test_f1(int i) {
+ int &v1 = N::f1();
+ float &v2 = N::f1(i);
+ int v3 = ::i1;
+ int v4 = N::f1::member;
+}
+
+typedef int f2_type;
+namespace a {
+ typedef int f2_type(int, int);
+
+ void test_f2() {
+ ::f2_type(1, 2); // expected-error {{excess elements in scalar initializer}}
+ }
+}
+
+// PR clang/3291
+namespace a {
+ namespace a { // A1
+ namespace a { // A2
+ int i;
+ }
+ }
+}
+
+void test_a() {
+ a::a::i = 3; // expected-error{{no member named 'i'}}
+ a::a::a::i = 4;
+}
+
+struct Undef { // expected-note{{definition of 'Undef' is not complete until the closing '}'}}
+ typedef int type;
+
+ Undef::type member;
+
+ static int size = sizeof(Undef); // expected-error{{invalid application of 'sizeof' to an incomplete type 'Undef'}}
+
+ int f();
+};
+
+int Undef::f() {
+ return sizeof(Undef);
+}
+
+// PR clang/5667
+namespace test1 {
+ template <typename T> struct is_class {
+ enum { value = 0 };
+ };
+
+ template <typename T> class ClassChecker {
+ bool isClass() {
+ return is_class<T>::value;
+ }
+ };
+
+ template class ClassChecker<int>;
+}
+
+namespace PR6830 {
+ namespace foo {
+
+ class X {
+ public:
+ X() {}
+ };
+
+ } // namespace foo
+
+ class Z {
+ public:
+ explicit Z(const foo::X& x) {}
+
+ void Work() {}
+ };
+
+ void Test() {
+ Z(foo::X()).Work();
+ }
+}
+
+namespace pr12339 {
+ extern "C" void i;
+ pr12339::FOO // expected-error{{no type named 'FOO' in namespace 'pr12339'}}
+} // expected-error{{expected unqualified-id}}
diff --git a/clang/test/SemaCXX/qualified-member-enum.cpp b/clang/test/SemaCXX/qualified-member-enum.cpp
new file mode 100644
index 0000000..83b0a59
--- /dev/null
+++ b/clang/test/SemaCXX/qualified-member-enum.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check that this doesn't crash.
+struct A {
+ enum {LABEL};
+};
+int f() {
+ return A().A::LABEL;
+}
+
diff --git a/clang/test/SemaCXX/qualified-names-diag.cpp b/clang/test/SemaCXX/qualified-names-diag.cpp
new file mode 100644
index 0000000..c8b5746
--- /dev/null
+++ b/clang/test/SemaCXX/qualified-names-diag.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+namespace foo {
+ namespace wibble {
+ struct x { int y; };
+
+ namespace bar {
+ namespace wonka {
+ struct x {
+ struct y { };
+ };
+ }
+ }
+ }
+}
+
+namespace bar {
+ typedef int y;
+
+ struct incomplete; // expected-note{{forward declaration of 'bar::incomplete'}}
+}
+void test() {
+ foo::wibble::x a;
+ ::bar::y b;
+ a + b; // expected-error{{invalid operands to binary expression ('foo::wibble::x' and '::bar::y' (aka 'int'))}}
+
+ ::foo::wibble::bar::wonka::x::y c;
+ c + b; // expected-error{{invalid operands to binary expression ('::foo::wibble::bar::wonka::x::y' and '::bar::y' (aka 'int'))}}
+
+ (void)sizeof(bar::incomplete); // expected-error{{invalid application of 'sizeof' to an incomplete type 'bar::incomplete'}}
+}
+
+int ::foo::wibble::bar::wonka::x::y::* ptrmem;
+
diff --git a/clang/test/SemaCXX/qualified-names-print.cpp b/clang/test/SemaCXX/qualified-names-print.cpp
new file mode 100644
index 0000000..2099268
--- /dev/null
+++ b/clang/test/SemaCXX/qualified-names-print.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -ast-print %s 2>&1 | grep "N::M::X<INT>::value"
+namespace N {
+ namespace M {
+ template<typename T>
+ struct X {
+ enum { value };
+ };
+ }
+}
+
+typedef int INT;
+
+int test() {
+ return N::M::X<INT>::value;
+}
diff --git a/clang/test/SemaCXX/redeclared-alias-template.cpp b/clang/test/SemaCXX/redeclared-alias-template.cpp
new file mode 100644
index 0000000..09e9d0d
--- /dev/null
+++ b/clang/test/SemaCXX/redeclared-alias-template.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template<typename T> using A = int; // expected-note 2{{previous}}
+template<typename T> using A = char; // expected-error {{type alias template redefinition with different types ('char' vs 'int')}}
+template<typename T1, typename T2> using A = T1; // expected-error {{too many template parameters in template redeclaration}}
+
+template<typename T1, typename T2> using B = T1; // expected-note {{previous}}
+template<typename T2, typename T1> using B = T1; // expected-error {{type alias template redefinition with different types}}
+
+
+template<typename> struct S;
+template<template<typename> class F> using FInt = F<int>;
+template<typename X> using SXRInt = FInt<S<X>::template R>;
+template<typename X> using SXRInt = typename S<X>::template R<int>; // ok, redeclaration.
+
+template<template<typename> class> struct TT;
+
+namespace FilterLookup {
+ TT<A> f(); // expected-note {{previous declaration is here}}
+
+ template<typename> using A = int;
+ TT<A> f(); // expected-error {{functions that differ only in their return type cannot be overloaded}}
+}
diff --git a/clang/test/SemaCXX/redeclared-auto.cpp b/clang/test/SemaCXX/redeclared-auto.cpp
new file mode 100644
index 0000000..87ad6bd
--- /dev/null
+++ b/clang/test/SemaCXX/redeclared-auto.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+extern int a;
+auto a = 0; // expected-note 2{{here}}
+auto a = 0; // expected-error {{redefinition}}
+int a = 0; // expected-error {{redefinition}}
+extern auto a; // expected-error {{requires an initializer}}
+
+extern int b; // expected-note {{here}}
+auto b = 0.0; // expected-error {{different type}}
+
+struct S {
+ static int a;
+ static int b; // expected-note {{here}}
+};
+
+auto S::a = 0; // expected-note 2{{here}}
+auto S::a; // expected-error {{redefinition}} expected-error {{requires an initializer}}
+int S::a = 0; // expected-error {{redefinition}}
+
+auto S::b = 0.0; // expected-error {{different type}}
+
+void f() {
+ extern int a;
+ extern auto a; // expected-error {{requires an initializer}}
+}
diff --git a/clang/test/SemaCXX/ref-init-ambiguous.cpp b/clang/test/SemaCXX/ref-init-ambiguous.cpp
new file mode 100644
index 0000000..ce47e10
--- /dev/null
+++ b/clang/test/SemaCXX/ref-init-ambiguous.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+enum E2 { };
+
+struct A {
+ operator E2&(); // expected-note 3 {{candidate function}}
+};
+
+struct B {
+ operator E2&(); // expected-note 3 {{candidate function}}
+};
+
+struct C : B, A {
+};
+
+void test(C c) {
+ const E2 &e2 = c; // expected-error {{reference initialization of type 'const E2 &' with initializer of type 'C' is ambiguous}}
+}
+
+void foo(const E2 &);// expected-note{{passing argument to parameter here}}
+
+const E2 & re(C c) {
+ foo(c); // expected-error {{reference initialization of type 'const E2 &' with initializer of type 'C' is ambiguous}}
+
+ return c; // expected-error {{reference initialization of type 'const E2 &' with initializer of type 'C' is ambiguous}}
+}
+
+
diff --git a/clang/test/SemaCXX/references.cpp b/clang/test/SemaCXX/references.cpp
new file mode 100644
index 0000000..70d3799
--- /dev/null
+++ b/clang/test/SemaCXX/references.cpp
@@ -0,0 +1,139 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+int g(int);
+
+void f() {
+ int i;
+ int &r = i;
+ r = 1;
+ int *p = &r;
+ int &rr = r;
+ int (&rg)(int) = g;
+ rg(i);
+ int a[3];
+ int (&ra)[3] = a;
+ ra[1] = i;
+ int *Q;
+ int *& P = Q;
+ P[1] = 1;
+}
+
+typedef int t[1];
+void test2() {
+ t a;
+ t& b = a;
+
+
+ int c[3];
+ int (&rc)[3] = c;
+}
+
+// C++ [dcl.init.ref]p5b1
+struct A { };
+struct B : A { } b;
+
+void test3() {
+ double d = 2.0;
+ double& rd = d; // rd refers to d
+ const double& rcd = d; // rcd refers to d
+
+ A& ra = b; // ra refers to A subobject in b
+ const A& rca = b; // rca refers to A subobject in b
+}
+
+B fB();
+
+// C++ [dcl.init.ref]p5b2
+void test4() {
+ double& rd2 = 2.0; // expected-error{{non-const lvalue reference to type 'double' cannot bind to a temporary of type 'double'}}
+ int i = 2;
+ double& rd3 = i; // expected-error{{non-const lvalue reference to type 'double' cannot bind to a value of unrelated type 'int'}}
+
+ const A& rca = fB();
+}
+
+void test5() {
+ // const double& rcd2 = 2; // rcd2 refers to temporary with value 2.0
+ const volatile int cvi = 1;
+ const int& r = cvi; // expected-error{{binding of reference to type 'const int' to a value of type 'const volatile int' drops qualifiers}}
+}
+
+// C++ [dcl.init.ref]p3
+int& test6(int& x) {
+ int& yo; // expected-error{{declaration of reference variable 'yo' requires an initializer}}
+
+ return x;
+}
+int& not_initialized_error; // expected-error{{declaration of reference variable 'not_initialized_error' requires an initializer}}
+extern int& not_initialized_okay;
+
+class Test6 { // expected-warning{{class 'Test6' does not declare any constructor to initialize its non-modifiable members}}
+ int& okay; // expected-note{{reference member 'okay' will never be initialized}}
+};
+
+struct C : B, A { };
+
+void test7(C& c) {
+ A& a1 = c; // expected-error {{ambiguous conversion from derived class 'C' to base class 'A':}}
+}
+
+// C++ [dcl.ref]p1, C++ [dcl.ref]p4
+void test8(int& const,// expected-error{{'const' qualifier may not be applied to a reference}}
+
+ void&, // expected-error{{cannot form a reference to 'void'}}
+ int& &) // expected-error{{type name declared as a reference to a reference}}
+{
+ typedef int& intref;
+ typedef intref& intrefref; // C++ DR 106: reference collapsing
+
+ typedef intref const intref_c; // okay. FIXME: how do we verify that this is the same type as intref?
+}
+
+
+class string {
+ char *Data;
+ unsigned Length;
+public:
+ string();
+ ~string();
+};
+
+string getInput();
+
+void test9() {
+ string &s = getInput(); // expected-error{{lvalue reference}}
+}
+
+void test10() {
+ __attribute((vector_size(16))) typedef int vec4;
+ typedef __attribute__(( ext_vector_type(4) )) int ext_vec4;
+
+ vec4 v;
+ int &a = v[0]; // expected-error{{non-const reference cannot bind to vector element}}
+ const int &b = v[0];
+
+ ext_vec4 ev;
+ int &c = ev.x; // expected-error{{non-const reference cannot bind to vector element}}
+ const int &d = ev.x;
+}
+
+namespace PR7149 {
+ template<typename T> struct X0
+ {
+ T& first;
+ X0(T& p1) : first(p1) { }
+ };
+
+
+ void f()
+ {
+ int p1[1];
+ X0< const int[1]> c(p1);
+ }
+}
+
+namespace PR8608 {
+ bool& f(unsigned char& c) { return (bool&)c; }
+}
+
+// The following crashed trying to recursively evaluate the LValue.
+const int &do_not_crash = do_not_crash;
diff --git a/clang/test/SemaCXX/reinterpret-cast.cpp b/clang/test/SemaCXX/reinterpret-cast.cpp
new file mode 100644
index 0000000..7f41b93
--- /dev/null
+++ b/clang/test/SemaCXX/reinterpret-cast.cpp
@@ -0,0 +1,292 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -ffreestanding -Wundefined-reinterpret-cast %s
+
+#include <stdint.h>
+
+enum test { testval = 1 };
+struct structure { int m; };
+typedef void (*fnptr)();
+
+// Test the conversion to self.
+void self_conversion()
+{
+ // T->T is allowed per [expr.reinterpret.cast]p2 so long as it doesn't
+ // cast away constness, and is integral, enumeration, pointer or
+ // pointer-to-member.
+ int i = 0;
+ (void)reinterpret_cast<int>(i);
+
+ test e = testval;
+ (void)reinterpret_cast<test>(e);
+
+ // T*->T* is allowed
+ int *pi = 0;
+ (void)reinterpret_cast<int*>(pi);
+
+ const int structure::*psi = 0;
+ (void)reinterpret_cast<const int structure::*>(psi);
+
+ structure s;
+ (void)reinterpret_cast<structure>(s); // expected-error {{reinterpret_cast from 'structure' to 'structure' is not allowed}}
+
+ float f = 0.0f;
+ (void)reinterpret_cast<float>(f); // expected-error {{reinterpret_cast from 'float' to 'float' is not allowed}}
+}
+
+// Test conversion between pointer and integral types, as in /3 and /4.
+void integral_conversion()
+{
+ void *vp = reinterpret_cast<void*>(testval);
+ intptr_t i = reinterpret_cast<intptr_t>(vp);
+ (void)reinterpret_cast<float*>(i);
+ fnptr fnp = reinterpret_cast<fnptr>(i);
+ (void)reinterpret_cast<char>(fnp); // expected-error {{cast from pointer to smaller type 'char' loses information}}
+ (void)reinterpret_cast<intptr_t>(fnp);
+}
+
+void pointer_conversion()
+{
+ int *p1 = 0;
+ float *p2 = reinterpret_cast<float*>(p1);
+ structure *p3 = reinterpret_cast<structure*>(p2);
+ typedef int **ppint;
+ ppint *deep = reinterpret_cast<ppint*>(p3);
+ (void)reinterpret_cast<fnptr*>(deep);
+}
+
+void constness()
+{
+ int ***const ipppc = 0;
+ // Valid: T1* -> T2 const*
+ int const *icp = reinterpret_cast<int const*>(ipppc);
+ // Invalid: T1 const* -> T2*
+ (void)reinterpret_cast<int*>(icp); // expected-error {{reinterpret_cast from 'const int *' to 'int *' casts away qualifiers}}
+ // Invalid: T1*** -> T2 const* const**
+ int const *const **icpcpp = reinterpret_cast<int const* const**>(ipppc); // expected-error {{reinterpret_cast from 'int ***' to 'const int *const **' casts away qualifiers}}
+ // Valid: T1* -> T2*
+ int *ip = reinterpret_cast<int*>(icpcpp);
+ // Valid: T* -> T const*
+ (void)reinterpret_cast<int const*>(ip);
+ // Valid: T*** -> T2 const* const* const*
+ (void)reinterpret_cast<int const* const* const*>(ipppc);
+}
+
+void fnptrs()
+{
+ typedef int (*fnptr2)(int);
+ fnptr fp = 0;
+ (void)reinterpret_cast<fnptr2>(fp);
+ void *vp = reinterpret_cast<void*>(fp);
+ (void)reinterpret_cast<fnptr>(vp);
+}
+
+void refs()
+{
+ long l = 0;
+ char &c = reinterpret_cast<char&>(l);
+ // Bad: from rvalue
+ (void)reinterpret_cast<int&>(&c); // expected-error {{reinterpret_cast from rvalue to reference type 'int &'}}
+}
+
+void memptrs()
+{
+ const int structure::*psi = 0;
+ (void)reinterpret_cast<const float structure::*>(psi);
+ (void)reinterpret_cast<int structure::*>(psi); // expected-error {{reinterpret_cast from 'const int structure::*' to 'int structure::*' casts away qualifiers}}
+
+ void (structure::*psf)() = 0;
+ (void)reinterpret_cast<int (structure::*)()>(psf);
+
+ (void)reinterpret_cast<void (structure::*)()>(psi); // expected-error {{reinterpret_cast from 'const int structure::*' to 'void (structure::*)()' is not allowed}}
+ (void)reinterpret_cast<int structure::*>(psf); // expected-error {{reinterpret_cast from 'void (structure::*)()' to 'int structure::*' is not allowed}}
+
+ // Cannot cast from integers to member pointers, not even the null pointer
+ // literal.
+ (void)reinterpret_cast<void (structure::*)()>(0); // expected-error {{reinterpret_cast from 'int' to 'void (structure::*)()' is not allowed}}
+ (void)reinterpret_cast<int structure::*>(0); // expected-error {{reinterpret_cast from 'int' to 'int structure::*' is not allowed}}
+}
+
+namespace PR5545 {
+// PR5545
+class A;
+class B;
+void (A::*a)();
+void (B::*b)() = reinterpret_cast<void (B::*)()>(a);
+}
+
+// <rdar://problem/8018292>
+void const_arrays() {
+ typedef char STRING[10];
+ const STRING *s;
+ const char *c;
+
+ (void)reinterpret_cast<char *>(s); // expected-error {{reinterpret_cast from 'const STRING *' (aka 'char const (*)[10]') to 'char *' casts away qualifiers}}
+ (void)reinterpret_cast<const STRING *>(c);
+}
+
+namespace PR9564 {
+ struct a { int a : 10; }; a x;
+ int *y = &reinterpret_cast<int&>(x.a); // expected-error {{not allowed}}
+
+ __attribute((ext_vector_type(4))) typedef float v4;
+ float& w(v4 &a) { return reinterpret_cast<float&>(a[1]); } // expected-error {{not allowed}}
+}
+
+void dereference_reinterpret_cast() {
+ struct A {};
+ typedef A A2;
+ class B {};
+ typedef B B2;
+ A a;
+ B b;
+ A2 a2;
+ B2 b2;
+ long l;
+ double d;
+ float f;
+ char c;
+ unsigned char uc;
+ void* v_ptr;
+ (void)reinterpret_cast<double&>(l); // expected-warning {{reinterpret_cast from 'long' to 'double &' has undefined behavior}}
+ (void)*reinterpret_cast<double*>(&l); // expected-warning {{dereference of type 'double *' that was reinterpret_cast from type 'long *' has undefined behavior}}
+ (void)reinterpret_cast<double&>(f); // expected-warning {{reinterpret_cast from 'float' to 'double &' has undefined behavior}}
+ (void)*reinterpret_cast<double*>(&f); // expected-warning {{dereference of type 'double *' that was reinterpret_cast from type 'float *' has undefined behavior}}
+ (void)reinterpret_cast<float&>(l); // expected-warning {{reinterpret_cast from 'long' to 'float &' has undefined behavior}}
+ (void)*reinterpret_cast<float*>(&l); // expected-warning {{dereference of type 'float *' that was reinterpret_cast from type 'long *' has undefined behavior}}
+ (void)reinterpret_cast<float&>(d); // expected-warning {{reinterpret_cast from 'double' to 'float &' has undefined behavior}}
+ (void)*reinterpret_cast<float*>(&d); // expected-warning {{dereference of type 'float *' that was reinterpret_cast from type 'double *' has undefined behavior}}
+
+ // TODO: add warning for tag types
+ (void)reinterpret_cast<A&>(b);
+ (void)*reinterpret_cast<A*>(&b);
+ (void)reinterpret_cast<B&>(a);
+ (void)*reinterpret_cast<B*>(&a);
+ (void)reinterpret_cast<A2&>(b2);
+ (void)*reinterpret_cast<A2*>(&b2);
+ (void)reinterpret_cast<B2&>(a2);
+ (void)*reinterpret_cast<B2*>(&a2);
+
+ // Casting to itself is allowed
+ (void)reinterpret_cast<A&>(a);
+ (void)*reinterpret_cast<A*>(&a);
+ (void)reinterpret_cast<B&>(b);
+ (void)*reinterpret_cast<B*>(&b);
+ (void)reinterpret_cast<long&>(l);
+ (void)*reinterpret_cast<long*>(&l);
+ (void)reinterpret_cast<double&>(d);
+ (void)*reinterpret_cast<double*>(&d);
+ (void)reinterpret_cast<char&>(c);
+ (void)*reinterpret_cast<char*>(&c);
+
+ // Casting to and from chars are allowable
+ (void)reinterpret_cast<A&>(c);
+ (void)*reinterpret_cast<A*>(&c);
+ (void)reinterpret_cast<B&>(c);
+ (void)*reinterpret_cast<B*>(&c);
+ (void)reinterpret_cast<long&>(c);
+ (void)*reinterpret_cast<long*>(&c);
+ (void)reinterpret_cast<double&>(c);
+ (void)*reinterpret_cast<double*>(&c);
+ (void)reinterpret_cast<char&>(l);
+ (void)*reinterpret_cast<char*>(&l);
+ (void)reinterpret_cast<char&>(d);
+ (void)*reinterpret_cast<char*>(&d);
+ (void)reinterpret_cast<char&>(f);
+ (void)*reinterpret_cast<char*>(&f);
+
+ // Casting from void pointer.
+ (void)*reinterpret_cast<A*>(v_ptr);
+ (void)*reinterpret_cast<B*>(v_ptr);
+ (void)*reinterpret_cast<long*>(v_ptr);
+ (void)*reinterpret_cast<double*>(v_ptr);
+ (void)*reinterpret_cast<float*>(v_ptr);
+
+ // Casting to void pointer
+ (void)*reinterpret_cast<void*>(&a);
+ (void)*reinterpret_cast<void*>(&b);
+ (void)*reinterpret_cast<void*>(&l);
+ (void)*reinterpret_cast<void*>(&d);
+ (void)*reinterpret_cast<void*>(&f);
+}
+
+void reinterpret_cast_whitelist () {
+ // the dynamic type of the object
+ int a;
+ float b;
+ (void)reinterpret_cast<int&>(a);
+ (void)*reinterpret_cast<int*>(&a);
+ (void)reinterpret_cast<float&>(b);
+ (void)*reinterpret_cast<float*>(&b);
+
+ // a cv-qualified version of the dynamic object
+ (void)reinterpret_cast<const int&>(a);
+ (void)*reinterpret_cast<const int*>(&a);
+ (void)reinterpret_cast<volatile int&>(a);
+ (void)*reinterpret_cast<volatile int*>(&a);
+ (void)reinterpret_cast<const volatile int&>(a);
+ (void)*reinterpret_cast<const volatile int*>(&a);
+ (void)reinterpret_cast<const float&>(b);
+ (void)*reinterpret_cast<const float*>(&b);
+ (void)reinterpret_cast<volatile float&>(b);
+ (void)*reinterpret_cast<volatile float*>(&b);
+ (void)reinterpret_cast<const volatile float&>(b);
+ (void)*reinterpret_cast<const volatile float*>(&b);
+
+ // a type that is the signed or unsigned type corresponding to the dynamic
+ // type of the object
+ signed d;
+ unsigned e;
+ (void)reinterpret_cast<signed&>(d);
+ (void)*reinterpret_cast<signed*>(&d);
+ (void)reinterpret_cast<signed&>(e);
+ (void)*reinterpret_cast<signed*>(&e);
+ (void)reinterpret_cast<unsigned&>(d);
+ (void)*reinterpret_cast<unsigned*>(&d);
+ (void)reinterpret_cast<unsigned&>(e);
+ (void)*reinterpret_cast<unsigned*>(&e);
+
+ // a type that is the signed or unsigned type corresponding a cv-qualified
+ // version of the dynamic type the object
+ (void)reinterpret_cast<const signed&>(d);
+ (void)*reinterpret_cast<const signed*>(&d);
+ (void)reinterpret_cast<const signed&>(e);
+ (void)*reinterpret_cast<const signed*>(&e);
+ (void)reinterpret_cast<const unsigned&>(d);
+ (void)*reinterpret_cast<const unsigned*>(&d);
+ (void)reinterpret_cast<const unsigned&>(e);
+ (void)*reinterpret_cast<const unsigned*>(&e);
+ (void)reinterpret_cast<volatile signed&>(d);
+ (void)*reinterpret_cast<volatile signed*>(&d);
+ (void)reinterpret_cast<volatile signed&>(e);
+ (void)*reinterpret_cast<volatile signed*>(&e);
+ (void)reinterpret_cast<volatile unsigned&>(d);
+ (void)*reinterpret_cast<volatile unsigned*>(&d);
+ (void)reinterpret_cast<volatile unsigned&>(e);
+ (void)*reinterpret_cast<volatile unsigned*>(&e);
+ (void)reinterpret_cast<const volatile signed&>(d);
+ (void)*reinterpret_cast<const volatile signed*>(&d);
+ (void)reinterpret_cast<const volatile signed&>(e);
+ (void)*reinterpret_cast<const volatile signed*>(&e);
+ (void)reinterpret_cast<const volatile unsigned&>(d);
+ (void)*reinterpret_cast<const volatile unsigned*>(&d);
+ (void)reinterpret_cast<const volatile unsigned&>(e);
+ (void)*reinterpret_cast<const volatile unsigned*>(&e);
+
+ // an aggregate or union type that includes one of the aforementioned types
+ // among its members (including, recursively, a member of a subaggregate or
+ // contained union)
+ // TODO: checking is not implemented for tag types
+
+ // a type that is a (possible cv-qualified) base class type of the dynamic
+ // type of the object
+ // TODO: checking is not implemented for tag types
+
+ // a char or unsigned char type
+ (void)reinterpret_cast<char&>(a);
+ (void)*reinterpret_cast<char*>(&a);
+ (void)reinterpret_cast<unsigned char&>(a);
+ (void)*reinterpret_cast<unsigned char*>(&a);
+ (void)reinterpret_cast<char&>(b);
+ (void)*reinterpret_cast<char*>(&b);
+ (void)reinterpret_cast<unsigned char&>(b);
+ (void)*reinterpret_cast<unsigned char*>(&b);
+}
diff --git a/clang/test/SemaCXX/reinterpret-fn-obj-pedantic.cpp b/clang/test/SemaCXX/reinterpret-fn-obj-pedantic.cpp
new file mode 100644
index 0000000..9cdf5a1
--- /dev/null
+++ b/clang/test/SemaCXX/reinterpret-fn-obj-pedantic.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -pedantic %s
+
+void fnptrs()
+{
+ typedef void (*fnptr)();
+ fnptr fp = 0;
+ void *vp = reinterpret_cast<void*>(fp); // expected-warning {{cast between pointer-to-function and pointer-to-object is an extension}}
+ (void)reinterpret_cast<fnptr>(vp); // expected-warning {{cast between pointer-to-function and pointer-to-object is an extension}}
+}
diff --git a/clang/test/SemaCXX/return-noreturn.cpp b/clang/test/SemaCXX/return-noreturn.cpp
new file mode 100644
index 0000000..617de00
--- /dev/null
+++ b/clang/test/SemaCXX/return-noreturn.cpp
@@ -0,0 +1,140 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -Wreturn-type -Wmissing-noreturn -Wno-unreachable-code -Wno-covered-switch-default
+// RUN: %clang_cc1 %s -fsyntax-only -std=c++11 -verify -Wreturn-type -Wmissing-noreturn -Wno-unreachable-code -Wno-covered-switch-default
+
+// A destructor may be marked noreturn and should still influence the CFG.
+void pr6884_abort() __attribute__((noreturn));
+
+struct pr6884_abort_struct {
+ pr6884_abort_struct() {}
+ ~pr6884_abort_struct() __attribute__((noreturn)) { pr6884_abort(); }
+};
+
+struct other { ~other() {} };
+
+// Ensure that destructors from objects are properly modeled in the CFG despite
+// the presence of switches, case statements, labels, and blocks. These tests
+// try to cover bugs reported in both PR6884 and PR10063.
+namespace abort_struct_complex_cfgs {
+ int basic(int x) {
+ switch (x) { default: pr6884_abort(); }
+ }
+ int f1(int x) {
+ switch (x) default: pr6884_abort_struct();
+ }
+ int f2(int x) {
+ switch (x) { default: pr6884_abort_struct(); }
+ }
+ int f2_positive(int x) {
+ switch (x) { default: ; }
+ } // expected-warning {{control reaches end of non-void function}}
+ int f3(int x) {
+ switch (x) { default: { pr6884_abort_struct(); } }
+ }
+ int f4(int x) {
+ switch (x) default: L1: L2: case 4: pr6884_abort_struct();
+ }
+ int f5(int x) {
+ switch (x) default: L1: { L2: case 4: pr6884_abort_struct(); }
+ }
+ int f6(int x) {
+ switch (x) default: L1: L2: case 4: { pr6884_abort_struct(); }
+ }
+
+ // Test that these constructs work even when extraneous blocks are created
+ // before and after the switch due to implicit destructors.
+ int g1(int x) {
+ other o;
+ switch (x) default: pr6884_abort_struct();
+ }
+ int g2(int x) {
+ other o;
+ switch (x) { default: pr6884_abort_struct(); }
+ }
+ int g2_positive(int x) {
+ other o;
+ switch (x) { default: ; }
+ } // expected-warning {{control reaches end of non-void function}}
+ int g3(int x) {
+ other o;
+ switch (x) { default: { pr6884_abort_struct(); } }
+ }
+ int g4(int x) {
+ other o;
+ switch (x) default: L1: L2: case 4: pr6884_abort_struct();
+ }
+ int g5(int x) {
+ other o;
+ switch (x) default: L1: { L2: case 4: pr6884_abort_struct(); }
+ }
+ int g6(int x) {
+ other o;
+ switch (x) default: L1: L2: case 4: { pr6884_abort_struct(); }
+ }
+
+ // Test that these constructs work even with variables carrying the no-return
+ // destructor instead of temporaries.
+ int h1(int x) {
+ other o;
+ switch (x) default: pr6884_abort_struct a;
+ }
+ int h2(int x) {
+ other o;
+ switch (x) { default: pr6884_abort_struct a; }
+ }
+ int h3(int x) {
+ other o;
+ switch (x) { default: { pr6884_abort_struct a; } }
+ }
+ int h4(int x) {
+ other o;
+ switch (x) default: L1: L2: case 4: pr6884_abort_struct a;
+ }
+ int h5(int x) {
+ other o;
+ switch (x) default: L1: { L2: case 4: pr6884_abort_struct a; }
+ }
+ int h6(int x) {
+ other o;
+ switch (x) default: L1: L2: case 4: { pr6884_abort_struct a; }
+ }
+}
+
+// PR9380
+struct PR9380 {
+ ~PR9380();
+};
+struct PR9380_B : public PR9380 {
+ PR9380_B( const PR9380& str );
+};
+void test_PR9380(const PR9380& aKey) {
+ const PR9380& flatKey = PR9380_B(aKey);
+}
+
+// Array of objects with destructors. This is purely a coverage test case.
+void test_array() {
+ PR9380 a[2];
+}
+
+// Test classes wrapped in typedefs. This is purely a coverage test case
+// for CFGImplictDtor::getDestructorDecl().
+void test_typedefs() {
+ typedef PR9380 PR9380_Ty;
+ PR9380_Ty test;
+ PR9380_Ty test2[20];
+}
+
+// PR9412 - Handle CFG traversal with null successors.
+enum PR9412_MatchType { PR9412_Exact };
+
+template <PR9412_MatchType type> int PR9412_t() {
+ switch (type) {
+ case PR9412_Exact:
+ default:
+ break;
+ }
+} // expected-warning {{control reaches end of non-void function}}
+
+void PR9412_f() {
+ PR9412_t<PR9412_Exact>(); // expected-note {{in instantiation of function template specialization 'PR9412_t<0>' requested here}}
+}
+
diff --git a/clang/test/SemaCXX/return-stack-addr.cpp b/clang/test/SemaCXX/return-stack-addr.cpp
new file mode 100644
index 0000000..fbbaf83
--- /dev/null
+++ b/clang/test/SemaCXX/return-stack-addr.cpp
@@ -0,0 +1,141 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int* ret_local() {
+ int x = 1;
+ return &x; // expected-warning {{address of stack memory}}
+}
+
+int* ret_local_array() {
+ int x[10];
+ return x; // expected-warning {{address of stack memory}}
+}
+
+int* ret_local_array_element(int i) {
+ int x[10];
+ return &x[i]; // expected-warning {{address of stack memory}}
+}
+
+int *ret_local_array_element_reversed(int i) {
+ int x[10];
+ return &i[x]; // expected-warning {{address of stack memory}}
+}
+
+int* ret_local_array_element_const_index() {
+ int x[10];
+ return &x[2]; // expected-warning {{address of stack memory}}
+}
+
+int& ret_local_ref() {
+ int x = 1;
+ return x; // expected-warning {{reference to stack memory}}
+}
+
+int* ret_local_addrOf() {
+ int x = 1;
+ return &*&x; // expected-warning {{address of stack memory}}
+}
+
+int* ret_local_addrOf_paren() {
+ int x = 1;
+ return (&(*(&x))); // expected-warning {{address of stack memory}}
+}
+
+int* ret_local_addrOf_ptr_arith() {
+ int x = 1;
+ return &*(&x+1); // expected-warning {{address of stack memory}}
+}
+
+int* ret_local_addrOf_ptr_arith2() {
+ int x = 1;
+ return &*(&x+1); // expected-warning {{address of stack memory}}
+}
+
+int* ret_local_field() {
+ struct { int x; } a;
+ return &a.x; // expected-warning {{address of stack memory}}
+}
+
+int& ret_local_field_ref() {
+ struct { int x; } a;
+ return a.x; // expected-warning {{reference to stack memory}}
+}
+
+int* ret_conditional(bool cond) {
+ int x = 1;
+ int y = 2;
+ return cond ? &x : &y; // expected-warning {{address of stack memory}}
+}
+
+int* ret_conditional_rhs(int *x, bool cond) {
+ int y = 1;
+ return cond ? x : &y; // expected-warning {{address of stack memory}}
+}
+
+void* ret_c_cast() {
+ int x = 1;
+ return (void*) &x; // expected-warning {{address of stack memory}}
+}
+
+int* ret_static_var() {
+ static int x = 1;
+ return &x; // no warning.
+}
+
+int z = 1;
+
+int* ret_global() {
+ return &z; // no warning.
+}
+
+int* ret_parameter(int x) {
+ return &x; // expected-warning {{address of stack memory}}
+}
+
+
+void* ret_cpp_static_cast(short x) {
+ return static_cast<void*>(&x); // expected-warning {{address of stack memory}}
+}
+
+int* ret_cpp_reinterpret_cast(double x) {
+ return reinterpret_cast<int*>(&x); // expected-warning {{address of stack me}}
+}
+
+int* ret_cpp_reinterpret_cast_no_warning(long x) {
+ return reinterpret_cast<int*>(x); // no-warning
+}
+
+int* ret_cpp_const_cast(const int x) {
+ return const_cast<int*>(&x); // expected-warning {{address of stack memory}}
+}
+
+// PR 7999 - handle the case where a field is itself a reference.
+template <typename T> struct PR7999 {
+ PR7999(T& t) : value(t) {}
+ T& value;
+};
+
+struct PR7999_X {};
+
+PR7999_X& PR7999_f(PR7999<PR7999_X> s) { return s.value; } // no-warning
+void test_PR7999(PR7999_X& x) { (void)PR7999_f(x); } // no-warning
+
+// PR 8774: Don't try to evaluate parameters with default arguments like
+// variables with an initializer, especially in templates where the default
+// argument may not be an expression (yet).
+namespace PR8774 {
+ template <typename U> struct B { };
+ template <typename V> V f(typename B<V>::type const &v = B<V>::value()) {
+ return v;
+ }
+ template <> struct B<const char *> {
+ typedef const char *type;
+ static const char *value();
+ };
+ void g() {
+ const char *t;
+ f<const char*>(t);
+ }
+}
+
+// TODO: test case for dynamic_cast. clang does not yet have
+// support for C++ classes to write such a test case.
diff --git a/clang/test/SemaCXX/return.cpp b/clang/test/SemaCXX/return.cpp
new file mode 100644
index 0000000..2f98a27
--- /dev/null
+++ b/clang/test/SemaCXX/return.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 %s -fcxx-exceptions -fexceptions -fsyntax-only -Wignored-qualifiers -verify
+
+int test1() {
+ throw;
+}
+
+// PR5071
+template<typename T> T f() { }
+
+template<typename T>
+void g(T t) {
+ return t * 2; // okay
+}
+
+template<typename T>
+T h() {
+ return 17;
+}
+
+// Don't warn on cv-qualified class return types, only scalar return types.
+namespace ignored_quals {
+struct S {};
+const S class_c();
+const volatile S class_cv();
+
+const int scalar_c(); // expected-warning{{'const' type qualifier on return type has no effect}}
+int const scalar_c2(); // expected-warning{{'const' type qualifier on return type has no effect}}
+
+const
+char*
+const // expected-warning{{'const' type qualifier on return type has no effect}}
+f();
+
+char
+const*
+const // expected-warning{{'const' type qualifier on return type has no effect}}
+g();
+
+char* const h(); // expected-warning{{'const' type qualifier on return type has no effect}}
+char* volatile i(); // expected-warning{{'volatile' type qualifier on return type has no effect}}
+
+char*
+volatile // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
+const
+j();
+
+const volatile int scalar_cv(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
+}
+
+namespace PR9328 {
+ typedef char *PCHAR;
+ class Test
+ {
+ const PCHAR GetName() { return 0; } // expected-warning{{'const' type qualifier on return type has no effect}}
+ };
+}
+
+class foo {
+ operator int * const ();
+};
+
+namespace PR10057 {
+ struct S {
+ ~S();
+ };
+
+ template <class VarType>
+ void Test(const VarType& value) {
+ return S() = value;
+ }
+}
+
+namespace return_has_expr {
+ struct S {
+ S() {
+ return 42; // expected-error {{constructor 'S' should not return a value}}
+ }
+ ~S() {
+ return 42; // expected-error {{destructor '~S' should not return a value}}
+ }
+ };
+}
diff --git a/clang/test/SemaCXX/runtimediag-ppe.cpp b/clang/test/SemaCXX/runtimediag-ppe.cpp
new file mode 100644
index 0000000..0e8451b
--- /dev/null
+++ b/clang/test/SemaCXX/runtimediag-ppe.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Make sure diagnostics that we don't print based on runtime control
+// flow are delayed correctly in cases where we can't immediately tell whether
+// the context is unevaluated.
+
+namespace std {
+ class type_info;
+}
+
+int& NP(int);
+void test1() { (void)typeid(NP(1 << 32)); }
+
+class Poly { virtual ~Poly(); };
+Poly& P(int);
+void test2() { (void)typeid(P(1 << 32)); } // expected-warning {{shift count >= width of type}}
+
+void test3() { 1 ? (void)0 : (void)typeid(P(1 << 32)); }
diff --git a/clang/test/SemaCXX/rval-references-examples.cpp b/clang/test/SemaCXX/rval-references-examples.cpp
new file mode 100644
index 0000000..110ae26
--- /dev/null
+++ b/clang/test/SemaCXX/rval-references-examples.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<typename T>
+class unique_ptr {
+ T *ptr;
+
+ unique_ptr(const unique_ptr&) = delete; // expected-note 3{{function has been explicitly marked deleted here}}
+ unique_ptr &operator=(const unique_ptr&) = delete; // expected-note{{candidate function has been explicitly deleted}}
+public:
+ unique_ptr() : ptr(0) { }
+ unique_ptr(unique_ptr &&other) : ptr(other.ptr) { other.ptr = 0; }
+ explicit unique_ptr(T *ptr) : ptr(ptr) { }
+
+ ~unique_ptr() { delete ptr; }
+
+ unique_ptr &operator=(unique_ptr &&other) { // expected-note{{candidate function not viable: no known conversion from 'unique_ptr<int>' to 'unique_ptr<int> &&' for 1st argument}}
+ if (this == &other)
+ return *this;
+
+ delete ptr;
+ ptr = other.ptr;
+ other.ptr = 0;
+ return *this;
+ }
+};
+
+template<typename T>
+struct remove_reference {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_reference<T&> {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_reference<T&&> {
+ typedef T type;
+};
+
+
+template <class T> typename remove_reference<T>::type&& move(T&& t) {
+ return static_cast<typename remove_reference<T>::type&&>(t);
+}
+
+template <class T> T&& forward(typename remove_reference<T>::type& t) {
+ return static_cast<T&&>(t);
+}
+
+template <class T> T&& forward(typename remove_reference<T>::type&& t) {
+ return static_cast<T&&>(t);
+}
+
+template<typename T, typename ...Args>
+unique_ptr<T> make_unique_ptr(Args &&...args) {
+ return unique_ptr<T>(new T(forward<Args>(args)...));
+}
+
+template<typename T> void accept_unique_ptr(unique_ptr<T>); // expected-note{{passing argument to parameter here}}
+
+unique_ptr<int> test_unique_ptr() {
+ // Simple construction
+ unique_ptr<int> p;
+ unique_ptr<int> p1(new int);
+
+ // Move construction
+ unique_ptr<int> p2(make_unique_ptr<int>(17));
+ unique_ptr<int> p3 = make_unique_ptr<int>(17);
+
+ // Copy construction (failures)
+ unique_ptr<int> p4(p); // expected-error{{call to deleted constructor of 'unique_ptr<int>'}}
+ unique_ptr<int> p5 = p; // expected-error{{call to deleted constructor of 'unique_ptr<int>'}}
+
+ // Move assignment
+ p2 = move(p);
+ p2 = make_unique_ptr<int>(0);
+
+ // Copy assignment (failures);
+ p2 = p3; // expected-error{{overload resolution selected deleted operator '='}}
+
+ // Implicit copies
+ accept_unique_ptr(make_unique_ptr<double>(0.0));
+ accept_unique_ptr(move(p2));
+
+ // Implicit copies (failures);
+ accept_unique_ptr(p); // expected-error{{call to deleted constructor of 'unique_ptr<int>'}}
+
+ return p;
+}
+
+namespace perfect_forwarding {
+ struct A { };
+
+ struct F0 {
+ void operator()(A&, const A&, A&&, const A&&, A&&, const A&&); // expected-note{{candidate function not viable: 5th argument ('const perfect_forwarding::A') would lose const qualifier}}
+ };
+
+ template<typename F, typename ...Args>
+ void forward(F f, Args &&...args) {
+ f(static_cast<Args&&>(args)...); // expected-error{{no matching function for call to object of type 'perfect_forwarding::F0'}}
+ }
+
+ template<typename T> T get();
+
+ void test_forward() {
+ forward(F0(), get<A&>(), get<A const&>(), get<A>(), get<const A>(),
+ get<A&&>(), get<const A&&>());
+ forward(F0(), get<A&>(), get<A const&>(), get<A>(), get<const A>(), // expected-note{{in instantiation of function template specialization 'perfect_forwarding::forward<perfect_forwarding::F0, perfect_forwarding::A &, const perfect_forwarding::A &, perfect_forwarding::A, const perfect_forwarding::A, const perfect_forwarding::A, const perfect_forwarding::A>' requested here}}
+ get<const A&&>(), get<const A&&>());
+ }
+};
diff --git a/clang/test/SemaCXX/rval-references.cpp b/clang/test/SemaCXX/rval-references.cpp
new file mode 100644
index 0000000..fc341e8
--- /dev/null
+++ b/clang/test/SemaCXX/rval-references.cpp
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s
+
+typedef int&& irr;
+typedef irr& ilr_c1; // Collapses to int&
+typedef int& ilr;
+typedef ilr&& ilr_c2; // Collapses to int&
+
+irr ret_irr() {
+ return 0; // expected-warning {{returning reference to local temporary}}
+}
+
+struct not_int {};
+
+int over(int&);
+not_int over(int&&);
+
+int over2(const int&);
+not_int over2(int&&);
+
+struct conv_to_not_int_rvalue {
+ operator not_int &&();
+};
+
+typedef void (fun_type)();
+void fun();
+fun_type &&make_fun();
+
+void f() {
+ int &&virr1; // expected-error {{declaration of reference variable 'virr1' requires an initializer}}
+ int &&virr2 = 0;
+ int &&virr3 = virr2; // expected-error {{rvalue reference to type 'int' cannot bind to lvalue of type 'int'}}
+ int i1 = 0;
+ int &&virr4 = i1; // expected-error {{rvalue reference to type 'int' cannot bind to lvalue of type 'int'}}
+ int &&virr5 = ret_irr();
+ int &&virr6 = static_cast<int&&>(i1);
+ (void)static_cast<not_int&&>(i1); // expected-error {{types are not compatible}}
+
+ int i2 = over(i1);
+ not_int ni1 = over(0);
+ int i3 = over(virr2);
+ not_int ni2 = over(ret_irr());
+
+ int i4 = over2(i1);
+ not_int ni3 = over2(0);
+
+ ilr_c1 vilr1 = i1;
+ ilr_c2 vilr2 = i1;
+
+ conv_to_not_int_rvalue cnir;
+ not_int &&ni4 = cnir;
+ not_int &ni5 = cnir; // expected-error{{non-const lvalue reference to type 'not_int' cannot bind to a value of unrelated type 'conv_to_not_int_rvalue'}}
+ not_int &&ni6 = conv_to_not_int_rvalue();
+
+ fun_type &&fun_ref = fun; // works because functions are special
+ fun_type &&fun_ref2 = make_fun(); // same
+ fun_type &fun_lref = make_fun(); // also special
+
+ try {
+ } catch(int&&) { // expected-error {{cannot catch exceptions by rvalue reference}}
+ }
+}
+
+int&& should_warn(int i) {
+ // FIXME: The stack address return test doesn't reason about casts.
+ return static_cast<int&&>(i); // xpected-warning {{returning reference to temporary}}
+}
+int&& should_not_warn(int&& i) { // But GCC 4.4 does
+ return static_cast<int&&>(i);
+}
+
+
+// Test the return dance. This also tests IsReturnCopyElidable.
+struct MoveOnly {
+ MoveOnly();
+ MoveOnly(const MoveOnly&) = delete; // expected-note {{candidate constructor}} \
+ // expected-note 3{{explicitly marked deleted here}}
+ MoveOnly(MoveOnly&&); // expected-note {{candidate constructor}}
+ MoveOnly(int&&); // expected-note {{candidate constructor}}
+};
+
+MoveOnly gmo;
+MoveOnly returningNonEligible() {
+ int i;
+ static MoveOnly mo;
+ MoveOnly &r = mo;
+ if (0) // Copy from global can't be elided
+ return gmo; // expected-error {{call to deleted constructor}}
+ else if (0) // Copy from local static can't be elided
+ return mo; // expected-error {{call to deleted constructor}}
+ else if (0) // Copy from reference can't be elided
+ return r; // expected-error {{call to deleted constructor}}
+ else // Construction from different type can't be elided
+ return i; // expected-error {{no viable conversion from 'int' to 'MoveOnly'}}
+}
diff --git a/clang/test/SemaCXX/scope-check.cpp b/clang/test/SemaCXX/scope-check.cpp
new file mode 100644
index 0000000..b659de0
--- /dev/null
+++ b/clang/test/SemaCXX/scope-check.cpp
@@ -0,0 +1,209 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s -Wno-unreachable-code
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=gnu++11 %s -Wno-unreachable-code
+
+namespace test0 {
+ struct D { ~D(); };
+
+ int f(bool b) {
+ if (b) {
+ D d;
+ goto end;
+ }
+
+ end:
+ return 1;
+ }
+}
+
+namespace test1 {
+ struct C { C(); };
+
+ int f(bool b) {
+ if (b)
+ goto foo; // expected-error {{goto into protected scope}}
+ C c; // expected-note {{jump bypasses variable initialization}}
+ foo:
+ return 1;
+ }
+}
+
+namespace test2 {
+ struct C { C(); };
+
+ int f(void **ip) {
+ static void *ips[] = { &&lbl1, &&lbl2 };
+
+ C c;
+ goto *ip;
+ lbl1:
+ return 0;
+ lbl2:
+ return 1;
+ }
+}
+
+namespace test3 {
+ struct C { C(); };
+
+ int f(void **ip) {
+ static void *ips[] = { &&lbl1, &&lbl2 };
+
+ goto *ip;
+ lbl1: {
+ C c;
+ return 0;
+ }
+ lbl2:
+ return 1;
+ }
+}
+
+namespace test4 {
+ struct C { C(); };
+ struct D { ~D(); };
+
+ int f(void **ip) {
+ static void *ips[] = { &&lbl1, &&lbl2 };
+
+ C c0;
+
+ goto *ip; // expected-error {{indirect goto might cross protected scopes}}
+ C c1; // expected-note {{jump bypasses variable initialization}}
+ lbl1: // expected-note {{possible target of indirect goto}}
+ return 0;
+ lbl2:
+ return 1;
+ }
+}
+
+namespace test5 {
+ struct C { C(); };
+ struct D { ~D(); };
+
+ int f(void **ip) {
+ static void *ips[] = { &&lbl1, &&lbl2 };
+ C c0;
+
+ goto *ip;
+ lbl1: // expected-note {{possible target of indirect goto}}
+ return 0;
+ lbl2:
+ if (ip[1]) {
+ D d; // expected-note {{jump exits scope of variable with non-trivial destructor}}
+ ip += 2;
+ goto *ip; // expected-error {{indirect goto might cross protected scopes}}
+ }
+ return 1;
+ }
+}
+
+namespace test6 {
+ struct C { C(); };
+
+ unsigned f(unsigned s0, unsigned s1, void **ip) {
+ static void *ips[] = { &&lbl1, &&lbl2, &&lbl3, &&lbl4 };
+ C c0;
+
+ goto *ip;
+ lbl1:
+ s0++;
+ goto *++ip;
+ lbl2:
+ s0 -= s1;
+ goto *++ip;
+ lbl3: {
+ unsigned tmp = s0;
+ s0 = s1;
+ s1 = tmp;
+ goto *++ip;
+ }
+ lbl4:
+ return s0;
+ }
+}
+
+// C++0x says it's okay to skip non-trivial initializers on static
+// locals, and we implement that in '03 as well.
+namespace test7 {
+ struct C { C(); };
+
+ void test() {
+ goto foo;
+ static C c;
+ foo:
+ return;
+ }
+}
+
+// PR7789
+namespace test8 {
+ void test1(int c) {
+ switch (c) {
+ case 0:
+ int x = 56; // expected-note {{jump bypasses variable initialization}}
+ case 1: // expected-error {{switch case is in protected scope}}
+ x = 10;
+ }
+ }
+
+ void test2() {
+ goto l2; // expected-error {{goto into protected scope}}
+ l1: int x = 5; // expected-note {{jump bypasses variable initialization}}
+ l2: x++;
+ }
+}
+
+namespace test9 {
+ struct S { int i; };
+ void test1() {
+ goto foo;
+ S s;
+ foo:
+ return;
+ }
+ unsigned test2(unsigned x, unsigned y) {
+ switch (x) {
+ case 2:
+ S s;
+ if (y > 42) return x + y;
+ default:
+ return x - 2;
+ }
+ }
+}
+
+// http://llvm.org/PR10462
+namespace PR10462 {
+enum MyEnum {
+ something_valid,
+ something_invalid
+};
+
+bool recurse() {
+ MyEnum K;
+ switch (K) { // expected-warning {{enumeration value 'something_invalid' not handled in switch}}
+ case something_valid:
+ case what_am_i_thinking: // expected-error {{use of undeclared identifier}}
+ int *X = 0;
+ if (recurse()) {
+ }
+
+ break;
+ }
+}
+
+
+namespace test10 {
+
+int test() {
+ static void *ps[] = { &&a0 };
+ goto *&&a0; // expected-error {{goto into protected scope}}
+ int a = 3; // expected-note {{jump bypasses variable initialization}}
+ a0:
+ return 0;
+}
+
+}
+
+}
+
diff --git a/clang/test/SemaCXX/shift.cpp b/clang/test/SemaCXX/shift.cpp
new file mode 100644
index 0000000..d5a5bed
--- /dev/null
+++ b/clang/test/SemaCXX/shift.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -Wall -Wshift-sign-overflow -ffreestanding -fsyntax-only -verify %s
+
+#include <limits.h>
+
+#define WORD_BIT (sizeof(int) * CHAR_BIT)
+
+template <int N> void f() {
+ (void)(N << 30); // expected-warning {{bits to represent, but 'int' only has}}
+ (void)(30 << N); // expected-warning {{bits to represent, but 'int' only has}}
+}
+
+void test() {
+ f<30>(); // expected-note {{instantiation}}
+}
diff --git a/clang/test/SemaCXX/short-enums.cpp b/clang/test/SemaCXX/short-enums.cpp
new file mode 100644
index 0000000..ca713b7
--- /dev/null
+++ b/clang/test/SemaCXX/short-enums.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fshort-enums -fsyntax-only %s
+
+// This shouldn't crash: PR9474
+
+enum E { VALUE_1 };
+
+template <typename T>
+struct A {};
+
+template <E Enum>
+struct B : A<B<Enum> > {};
+
+void bar(int x) {
+ switch (x) {
+ case sizeof(B<VALUE_1>): ;
+ }
+} \ No newline at end of file
diff --git a/clang/test/SemaCXX/short-wchar-sign.cpp b/clang/test/SemaCXX/short-wchar-sign.cpp
new file mode 100644
index 0000000..9a177c0
--- /dev/null
+++ b/clang/test/SemaCXX/short-wchar-sign.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -fshort-wchar -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -pedantic -verify %s
+
+// Check that short wchar_t is unsigned, and that regular wchar_t is not.
+int test[(wchar_t(-1)<wchar_t(0)) == (sizeof(wchar_t) == 4) ?1:-1];
diff --git a/clang/test/SemaCXX/sourceranges.cpp b/clang/test/SemaCXX/sourceranges.cpp
new file mode 100644
index 0000000..0537aa2
--- /dev/null
+++ b/clang/test/SemaCXX/sourceranges.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -ast-dump %s | FileCheck %s
+
+template<class T>
+class P {
+ public:
+ P(T* t) {}
+};
+
+namespace foo {
+class A {};
+enum B {};
+typedef int C;
+}
+
+int main() {
+ // CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::A *'
+ P<foo::A> p14 = new foo::A;
+ // CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::B *'
+ P<foo::B> p24 = new foo::B;
+ // CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::C *'
+ P<foo::C> pr4 = new foo::C;
+}
+
+foo::A getName() {
+ // CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:10, col:17> 'foo::A'
+ return foo::A();
+}
diff --git a/clang/test/SemaCXX/statements.cpp b/clang/test/SemaCXX/statements.cpp
new file mode 100644
index 0000000..6d04c84
--- /dev/null
+++ b/clang/test/SemaCXX/statements.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify
+
+void foo() {
+ return foo();
+}
+
+// PR6451 - C++ Jump checking
+struct X {
+ X();
+};
+
+void test2() {
+ goto later; // expected-error {{goto into protected scope}}
+ X x; // expected-note {{jump bypasses variable initialization}}
+later:
+ ;
+}
+
+namespace PR6536 {
+ struct A {};
+ void a() { goto out; A x; out: return; }
+}
diff --git a/clang/test/SemaCXX/static-array-member.cpp b/clang/test/SemaCXX/static-array-member.cpp
new file mode 100644
index 0000000..8f57549
--- /dev/null
+++ b/clang/test/SemaCXX/static-array-member.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+struct X0 {
+ static int array[];
+
+ int x;
+ int y;
+};
+
+int X0::array[sizeof(X0) * 2];
+
+template<typename T, int N>
+struct X1 {
+ static T array[];
+};
+
+template<typename T, int N>
+T X1<T, N>::array[N];
diff --git a/clang/test/SemaCXX/static-assert.cpp b/clang/test/SemaCXX/static-assert.cpp
new file mode 100644
index 0000000..364e4e4
--- /dev/null
+++ b/clang/test/SemaCXX/static-assert.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -triple=x86_64-linux-gnu
+
+int f(); // expected-note {{declared here}}
+
+static_assert(f(), "f"); // expected-error {{static_assert expression is not an integral constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}}
+static_assert(true, "true is not false");
+static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
+
+void g() {
+ static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
+}
+
+class C {
+ static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
+};
+
+template<int N> struct T {
+ static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed "N is not 2!"}}
+};
+
+T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}}
+T<2> t2;
+
+template<typename T> struct S {
+ static_assert(sizeof(T) > sizeof(char), "Type not big enough!"); // expected-error {{static_assert failed "Type not big enough!"}}
+};
+
+S<char> s1; // expected-note {{in instantiation of template class 'S<char>' requested here}}
+S<int> s2;
+
+static_assert(false, L"\xFFFFFFFF"); // expected-error {{static_assert failed L"\xFFFFFFFF"}}
+static_assert(false, u"\U000317FF"); // expected-error {{static_assert failed u"\U000317FF"}}
+// FIXME: render this as u8"\u03A9"
+static_assert(false, u8"Ω"); // expected-error {{static_assert failed u8"\316\251"}}
+static_assert(false, L"\u1234"); // expected-error {{static_assert failed L"\x1234"}}
+static_assert(false, L"\x1ff" "0\x123" "fx\xfffff" "goop"); // expected-error {{static_assert failed L"\x1FF""0\x123""fx\xFFFFFgoop"}}
diff --git a/clang/test/SemaCXX/static-cast-complete-type.cpp b/clang/test/SemaCXX/static-cast-complete-type.cpp
new file mode 100644
index 0000000..6d76f81
--- /dev/null
+++ b/clang/test/SemaCXX/static-cast-complete-type.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T> struct S {
+ S(int);
+};
+
+struct T; // expected-note{{forward declaration of 'T'}}
+
+void f() {
+ S<int> s0 = static_cast<S<int> >(0);
+ S<void*> s1 = static_cast<S<void*> >(00);
+
+ (void)static_cast<T>(10); // expected-error{{'T' is an incomplete type}}
+}
diff --git a/clang/test/SemaCXX/static-cast.cpp b/clang/test/SemaCXX/static-cast.cpp
new file mode 100644
index 0000000..7fb016e
--- /dev/null
+++ b/clang/test/SemaCXX/static-cast.cpp
@@ -0,0 +1,197 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct A {};
+struct B : public A {}; // Single public base.
+struct C1 : public virtual B {}; // Single virtual base.
+struct C2 : public virtual B {};
+struct D : public C1, public C2 {}; // Diamond
+struct E : private A {}; // Single private base. expected-note 3 {{declared private here}}
+struct F : public C1 {}; // Single path to B with virtual.
+struct G1 : public B {};
+struct G2 : public B {};
+struct H : public G1, public G2 {}; // Ambiguous path to B.
+
+enum Enum { En1, En2 };
+enum Onom { On1, On2 };
+
+struct Co1 { operator int(); };
+struct Co2 { Co2(int); };
+struct Co3 { };
+struct Co4 { Co4(Co3); operator Co3(); };
+
+// Explicit implicits
+void t_529_2()
+{
+ int i = 1;
+ (void)static_cast<float>(i);
+ double d = 1.0;
+ (void)static_cast<float>(d);
+ (void)static_cast<int>(d);
+ (void)static_cast<char>(i);
+ (void)static_cast<unsigned long>(i);
+ (void)static_cast<int>(En1);
+ (void)static_cast<double>(En1);
+ (void)static_cast<int&>(i);
+ (void)static_cast<const int&>(i);
+
+ int ar[1];
+ (void)static_cast<const int*>(ar);
+ (void)static_cast<void (*)()>(t_529_2);
+
+ (void)static_cast<void*>(0);
+ (void)static_cast<void*>((int*)0);
+ (void)static_cast<volatile const void*>((const int*)0);
+ (void)static_cast<A*>((B*)0);
+ (void)static_cast<A&>(*((B*)0));
+ (void)static_cast<const B*>((C1*)0);
+ (void)static_cast<B&>(*((C1*)0));
+ (void)static_cast<A*>((D*)0);
+ (void)static_cast<const A&>(*((D*)0));
+ (void)static_cast<int B::*>((int A::*)0);
+ (void)static_cast<void (B::*)()>((void (A::*)())0);
+
+ (void)static_cast<int>(Co1());
+ (void)static_cast<Co2>(1);
+ (void)static_cast<Co3>(static_cast<Co4>(Co3()));
+
+ // Bad code below
+
+ (void)static_cast<void*>((const int*)0); // expected-error {{static_cast from 'const int *' to 'void *' is not allowed}}
+ (void)static_cast<A*>((E*)0); // expected-error {{cannot cast 'E' to its private base class 'A'}}
+ (void)static_cast<A*>((H*)0); // expected-error {{ambiguous conversion}}
+ (void)static_cast<int>((int*)0); // expected-error {{static_cast from 'int *' to 'int' is not allowed}}
+ (void)static_cast<A**>((B**)0); // expected-error {{static_cast from 'B **' to 'A **' is not allowed}}
+ (void)static_cast<char&>(i); // expected-error {{non-const lvalue reference to type 'char' cannot bind to a value of unrelated type 'int'}}
+}
+
+// Anything to void
+void t_529_4()
+{
+ static_cast<void>(1);
+ static_cast<void>(t_529_4);
+}
+
+// Static downcasts
+void t_529_5_8()
+{
+ (void)static_cast<B*>((A*)0);
+ (void)static_cast<B&>(*((A*)0));
+ (void)static_cast<const G1*>((A*)0);
+ (void)static_cast<const G1&>(*((A*)0));
+
+ // Bad code below
+
+ (void)static_cast<C1*>((A*)0); // expected-error {{cannot cast 'A *' to 'C1 *' via virtual base 'B'}}
+ (void)static_cast<C1&>(*((A*)0)); // expected-error {{cannot cast 'A' to 'C1 &' via virtual base 'B'}}
+ (void)static_cast<D*>((A*)0); // expected-error {{cannot cast 'A *' to 'D *' via virtual base 'B'}}
+ (void)static_cast<D&>(*((A*)0)); // expected-error {{cannot cast 'A' to 'D &' via virtual base 'B'}}
+ (void)static_cast<B*>((const A*)0); // expected-error {{static_cast from 'const A *' to 'B *' casts away qualifiers}}
+ (void)static_cast<B&>(*((const A*)0)); // expected-error {{static_cast from 'const A' to 'B &' casts away qualifiers}}
+ (void)static_cast<E*>((A*)0); // expected-error {{cannot cast private base class 'A' to 'E'}}
+ (void)static_cast<E&>(*((A*)0)); // expected-error {{cannot cast private base class 'A' to 'E'}}
+ (void)static_cast<H*>((A*)0); // expected-error {{ambiguous cast from base 'A' to derived 'H':\n struct A -> struct B -> struct G1 -> struct H\n struct A -> struct B -> struct G2 -> struct H}}
+ (void)static_cast<H&>(*((A*)0)); // expected-error {{ambiguous cast from base 'A' to derived 'H':\n struct A -> struct B -> struct G1 -> struct H\n struct A -> struct B -> struct G2 -> struct H}}
+ (void)static_cast<E*>((B*)0); // expected-error {{static_cast from 'B *' to 'E *' is not allowed}}
+ (void)static_cast<E&>(*((B*)0)); // expected-error {{non-const lvalue reference to type 'E' cannot bind to a value of unrelated type 'B'}}
+
+ // TODO: Test inaccessible base in context where it's accessible, i.e.
+ // member function and friend.
+
+ // TODO: Test DR427. This requires user-defined conversions, though.
+}
+
+// Enum conversions
+void t_529_7()
+{
+ (void)static_cast<Enum>(1);
+ (void)static_cast<Enum>(1.0);
+ (void)static_cast<Onom>(En1);
+
+ // Bad code below
+
+ (void)static_cast<Enum>((int*)0); // expected-error {{static_cast from 'int *' to 'Enum' is not allowed}}
+}
+
+// Void pointer to object pointer
+void t_529_10()
+{
+ (void)static_cast<int*>((void*)0);
+ (void)static_cast<const A*>((void*)0);
+
+ // Bad code below
+
+ (void)static_cast<int*>((const void*)0); // expected-error {{static_cast from 'const void *' to 'int *' casts away qualifiers}}
+ (void)static_cast<void (*)()>((void*)0); // expected-error {{static_cast from 'void *' to 'void (*)()' is not allowed}}
+}
+
+// Member pointer upcast.
+void t_529_9()
+{
+ (void)static_cast<int A::*>((int B::*)0);
+
+ // Bad code below
+ (void)static_cast<int A::*>((int H::*)0); // expected-error {{ambiguous conversion from pointer to member of derived class 'H' to pointer to member of base class 'A':}}
+ (void)static_cast<int A::*>((int F::*)0); // expected-error {{conversion from pointer to member of class 'F' to pointer to member of class 'A' via virtual base 'B' is not allowed}}
+}
+
+// PR 5261 - static_cast should instantiate template if possible
+namespace pr5261 {
+ struct base {};
+ template<typename E> struct derived : public base {};
+ template<typename E> struct outer {
+ base *pb;
+ ~outer() { (void)static_cast<derived<E>*>(pb); }
+ };
+ outer<int> EntryList;
+}
+
+
+// Initialization by constructor
+struct X0;
+
+struct X1 {
+ X1();
+ X1(X1&);
+ X1(const X0&);
+
+ operator X0() const;
+};
+
+struct X0 { };
+
+void test_ctor_init() {
+ (void)static_cast<X1>(X1());
+}
+
+// Casting away constness
+struct X2 {
+};
+
+struct X3 : X2 {
+};
+
+struct X4 {
+ typedef const X3 X3_typedef;
+
+ void f() const {
+ (void)static_cast<X3_typedef*>(x2);
+ }
+
+ const X2 *x2;
+};
+
+// PR5897 - accept static_cast from const void* to const int (*)[1].
+void PR5897() { (void)static_cast<const int(*)[1]>((const void*)0); }
+
+namespace PR6072 {
+ struct A { };
+ struct B : A { void f(int); void f(); }; // expected-note 2{{candidate function}}
+ struct C : B { };
+ struct D { };
+
+ void f() {
+ (void)static_cast<void (A::*)()>(&B::f);
+ (void)static_cast<void (B::*)()>(&B::f);
+ (void)static_cast<void (C::*)()>(&B::f);
+ (void)static_cast<void (D::*)()>(&B::f); // expected-error{{address of overloaded function 'f' cannot be static_cast to type 'void (PR6072::D::*)()'}}
+ }
+}
diff --git a/clang/test/SemaCXX/static-initializers.cpp b/clang/test/SemaCXX/static-initializers.cpp
new file mode 100644
index 0000000..ca49fce
--- /dev/null
+++ b/clang/test/SemaCXX/static-initializers.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+int f() {
+ return 10;
+}
+
+void g() {
+ static int a = f();
+}
+
+static int b = f();
diff --git a/clang/test/SemaCXX/storage-class.cpp b/clang/test/SemaCXX/storage-class.cpp
new file mode 100644
index 0000000..01cfbfc
--- /dev/null
+++ b/clang/test/SemaCXX/storage-class.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+extern const int PR6495a = 42;
+extern int PR6495b = 42; // expected-warning{{'extern' variable has an initializer}}
+extern const int PR6495c[] = {42,43,44};
+
+extern struct Test1 {}; // expected-warning {{'extern' ignored on this declaration}}
+extern "C" struct Test0 {}; // no warning
diff --git a/clang/test/SemaCXX/string-plus-int.cpp b/clang/test/SemaCXX/string-plus-int.cpp
new file mode 100644
index 0000000..5752f8f
--- /dev/null
+++ b/clang/test/SemaCXX/string-plus-int.cpp
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-array-bounds %s -fpascal-strings
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2>&1 -Wno-array-bounds -fpascal-strings | FileCheck %s
+
+void consume(const char* c) {}
+void consume(const unsigned char* c) {}
+void consume(const wchar_t* c) {}
+void consumeChar(char c) {}
+
+enum MyEnum {
+ kMySmallEnum = 1,
+ kMyEnum = 5
+};
+
+enum OperatorOverloadEnum {
+ kMyOperatorOverloadedEnum = 5
+};
+
+const char* operator+(const char* c, OperatorOverloadEnum e) {
+ return "yo";
+}
+
+const char* operator+(OperatorOverloadEnum e, const char* c) {
+ return "yo";
+}
+
+void f(int index) {
+ // Should warn.
+ // CHECK: fix-it:"{{.*}}":{31:11-31:11}:"&"
+ // CHECK: fix-it:"{{.*}}":{31:17-31:18}:"["
+ // CHECK: fix-it:"{{.*}}":{31:20-31:20}:"]"
+ consume("foo" + 5); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+ consume("foo" + index); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+ consume("foo" + kMyEnum); // expected-warning {{adding 'MyEnum' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+
+ consume(5 + "foo"); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+ consume(index + "foo"); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+ consume(kMyEnum + "foo"); // expected-warning {{adding 'MyEnum' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+
+ // FIXME: suggest replacing with "foo"[5]
+ consumeChar(*("foo" + 5)); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+ consumeChar(*(5 + "foo")); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+
+ consume(L"foo" + 5); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+
+ // Should not warn.
+ consume(&("foo"[3]));
+ consume(&("foo"[index]));
+ consume(&("foo"[kMyEnum]));
+ consume("foo" + kMySmallEnum);
+ consume(kMySmallEnum + "foo");
+
+ consume(L"foo" + 2);
+
+ consume("foo" + 3); // Points at the \0
+ consume("foo" + 4); // Points 1 past the \0, which is legal too.
+ consume("\pfoo" + 4); // Pascal strings don't have a trailing \0, but they
+ // have a leading length byte, so this is fine too.
+
+ consume("foo" + kMyOperatorOverloadedEnum);
+ consume(kMyOperatorOverloadedEnum + "foo");
+
+ #define A "foo"
+ #define B "bar"
+ consume(A B + sizeof(A) - 1);
+}
+
diff --git a/clang/test/SemaCXX/struct-class-redecl.cpp b/clang/test/SemaCXX/struct-class-redecl.cpp
new file mode 100644
index 0000000..5c59578
--- /dev/null
+++ b/clang/test/SemaCXX/struct-class-redecl.cpp
@@ -0,0 +1,164 @@
+// RUN: %clang_cc1 -fsyntax-only -Wmismatched-tags -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wmismatched-tags %s 2>&1 | FileCheck %s
+class X; // expected-note 2{{here}}
+typedef struct X * X_t; // expected-warning{{previously declared}}
+union X { int x; float y; }; // expected-error{{use of 'X' with tag type that does not match previous declaration}}
+
+template<typename T> struct Y; // expected-note{{did you mean class here?}}
+template<class U> class Y { }; // expected-warning{{previously declared}}
+
+class A;
+class A; // expected-note{{previous use is here}}
+struct A; // expected-warning{{struct 'A' was previously declared as a class}}
+
+class B; // expected-note{{did you mean struct here?}}
+class B; // expected-note{{previous use is here}}\
+ // expected-note{{did you mean struct here?}}
+struct B; // expected-warning{{struct 'B' was previously declared as a class}}
+struct B {}; // expected-warning{{'B' defined as a struct here but previously declared as a class}}
+
+class C; // expected-note{{previous use is here}}
+struct C; // expected-warning{{struct 'C' was previously declared as a class}}\
+ // expected-note{{previous use is here}}\
+ // expected-note{{did you mean class here?}}
+class C; // expected-warning{{class 'C' was previously declared as a struct}}\
+ // expected-note{{previous use is here}}
+struct C; // expected-warning{{struct 'C' was previously declared as a class}}\
+ // expected-note{{did you mean class here?}}
+class C {}; // expected-warning{{'C' defined as a class here but previously declared as a struct}}
+
+struct D {}; // expected-note{{previous definition is here}}\
+ // expected-note{{previous use is here}}
+class D {}; // expected-error{{redefinition of 'D'}}
+struct D;
+class D; // expected-warning{{class 'D' was previously declared as a struct}}\
+ // expected-note{{did you mean struct here?}}
+
+class E;
+class E;
+class E {};
+class E;
+
+struct F;
+struct F;
+struct F {};
+struct F;
+
+template<class U> class G; // expected-note{{previous use is here}}\
+ // expected-note{{did you mean struct here?}}
+template<class U> struct G; // expected-warning{{struct template 'G' was previously declared as a class template}}
+template<class U> struct G {}; // expected-warning{{'G' defined as a struct template here but previously declared as a class template}}
+
+/*
+*** 'X' messages ***
+CHECK: warning: struct 'X' was previously declared as a class
+CHECK: {{^}}typedef struct X * X_t;
+CHECK: {{^}} ^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}class X;
+CHECK: {{^}} ^{{$}}
+CHECK: error: use of 'X' with tag type that does not match previous declaration
+CHECK: {{^}}union X { int x; float y; };
+CHECK: {{^}}^~~~~{{$}}
+CHECK: {{^}}class{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}class X;
+CHECK: {{^}} ^{{$}}
+*** 'Y' messages ***
+CHECK: warning: 'Y' defined as a class template here but
+ previously declared as a struct template
+CHECK: {{^}}template<class U> class Y { };
+CHECK: {{^}} ^{{$}}
+CHECK: note: did you mean class here?
+CHECK: {{^}}template<typename T> struct Y;
+CHECK: {{^}} ^~~~~~{{$}}
+CHECK: {{^}} class{{$}}
+*** 'A' messages ***
+CHECK: warning: struct 'A' was previously declared as a class
+CHECK: {{^}}struct A;
+CHECK: {{^}}^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}class A;
+CHECK: {{^}} ^{{$}}
+*** 'B' messages ***
+CHECK: warning: struct 'B' was previously declared as a class
+CHECK: {{^}}struct B;
+CHECK: {{^}}^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}class B;
+CHECK: {{^}} ^{{$}}
+CHECK: 'B' defined as a struct here but previously declared as a class
+CHECK: {{^}}struct B {};
+CHECK: {{^}}^{{$}}
+CHECK: note: did you mean struct here?
+CHECK: {{^}}class B;
+CHECK: {{^}}^~~~~{{$}}
+CHECK: {{^}}struct{{$}}
+CHECK: note: did you mean struct here?
+CHECK: {{^}}class B;
+CHECK: {{^}}^~~~~{{$}}
+CHECK: {{^}}struct{{$}}
+*** 'C' messages ***
+CHECK: warning: struct 'C' was previously declared as a class
+CHECK: {{^}}struct C;
+CHECK: {{^}}^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}class C;
+CHECK: {{^}} ^{{$}}
+CHECK: warning: class 'C' was previously declared as a struct
+CHECK: {{^}}class C;
+CHECK: {{^}}^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}struct C;
+CHECK: {{^}} ^{{$}}
+CHECK: warning: struct 'C' was previously declared as a class
+CHECK: {{^}}struct C;
+CHECK: {{^}}^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}class C;
+CHECK: {{^}} ^{{$}}
+CHECK: warning: 'C' defined as a class here but previously declared as a struct
+CHECK: {{^}}class C {};
+CHECK: {{^}}^{{$}}
+CHECK: note: did you mean class here?
+CHECK: {{^}}struct C;
+CHECK: {{^}}^~~~~~{{$}}
+CHECK: {{^}}class{{$}}
+CHECK: note: did you mean class here?
+CHECK: {{^}}struct C;
+CHECK: {{^}}^~~~~~{{$}}
+CHECK: {{^}}class{{$}}
+*** 'D' messages ***
+CHECK: error: redefinition of 'D'
+CHECK: {{^}}class D {};
+CHECK: {{^}} ^{{$}}
+CHECK: note: previous definition is here
+CHECK: {{^}}struct D {};
+CHECK: {{^}} ^{{$}}
+CHECK: warning: class 'D' was previously declared as a struct
+CHECK: {{^}}class D;
+CHECK: {{^}}^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}struct D {};
+CHECK: {{^}} ^{{$}}
+CHECK: note: did you mean struct here?
+CHECK: {{^}}class D;
+CHECK: {{^}}^~~~~{{$}}
+CHECK: {{^}}struct{{$}}
+*** 'E' messages ***
+*** 'F' messages ***
+*** 'G' messages ***
+CHECK: warning: struct template 'G' was previously declared as a class template
+CHECK: {{^}}template<class U> struct G;
+CHECK: {{^}} ^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}template<class U> class G;
+CHECK: {{^}} ^{{$}}
+CHECK: warning: 'G' defined as a struct template here but previously declared as a class template
+CHECK: {{^}}template<class U> struct G {};
+CHECK: {{^}} ^{{$}}
+CHECK: note: did you mean struct here?
+CHECK: {{^}}template<class U> class G;
+CHECK: {{^}} ^~~~~
+CHECK: {{^}} struct
+*/
diff --git a/clang/test/SemaCXX/switch-0x.cpp b/clang/test/SemaCXX/switch-0x.cpp
new file mode 100644
index 0000000..2e74da0
--- /dev/null
+++ b/clang/test/SemaCXX/switch-0x.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// PR5518
+struct A {
+ explicit operator int(); // expected-note{{conversion to integral type}}
+};
+
+void x() {
+ switch(A()) { // expected-error{{explicit conversion to}}
+ }
+}
diff --git a/clang/test/SemaCXX/switch.cpp b/clang/test/SemaCXX/switch.cpp
new file mode 100644
index 0000000..517faa9
--- /dev/null
+++ b/clang/test/SemaCXX/switch.cpp
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+void test() {
+ bool x = true;
+ switch (x) { // expected-warning {{bool}}
+ case 0:
+ break;
+ }
+
+ int n = 3;
+ switch (n && true) { // expected-warning {{bool}}
+ case 1:
+ break;
+ }
+}
+
+// PR5518
+struct A {
+ operator int(); // expected-note{{conversion to integral type}}
+};
+
+void x() {
+ switch(A()) {
+ }
+}
+
+enum E { e1, e2 };
+struct B : A {
+ operator E() const; // expected-note{{conversion to enumeration type}}
+};
+
+void x2() {
+ switch (B()) { // expected-error{{multiple conversions}}
+ }
+}
+
+struct C; // expected-note{{forward declaration}}
+
+void x3(C &c) {
+ switch (c) { // expected-error{{incomplete class type}}
+ }
+}
+
+namespace test3 {
+ enum En { A, B, C };
+ template <En how> void foo() {
+ int x = 0, y = 5;
+
+ switch (how) { //expected-warning {{no case matching constant switch condition '2'}}
+ case A: x *= y; break;
+ case B: x += y; break;
+ // No case for C, but it's okay because we have a constant condition.
+ }
+ }
+
+ template void foo<A>();
+ template void foo<B>();
+ template void foo<C>(); //expected-note {{in instantiation}}
+}
+
+// PR9304 and rdar://9045501
+void click_check_header_sizes() {
+ switch (0 == 8) { // expected-warning {{switch condition has boolean value}}
+ case 0: ;
+ }
+}
+
+void local_class(int n) {
+ for (;;) switch (n) {
+ case 0:
+ struct S {
+ void f() {
+ case 1: // expected-error {{'case' statement not in switch statement}}
+ break; // expected-error {{'break' statement not in loop or switch statement}}
+ default: // expected-error {{'default' statement not in switch statement}}
+ continue; // expected-error {{'continue' statement not in loop statement}}
+ }
+ };
+ S().f();
+ []{
+ case 2: // expected-error {{'case' statement not in switch statement}}
+ break; // expected-error {{'break' statement not in loop or switch statement}}
+ default: // expected-error {{'default' statement not in switch statement}}
+ continue; // expected-error {{'continue' statement not in loop statement}}
+ }();
+ }
+}
diff --git a/clang/test/SemaCXX/tag-ambig.cpp b/clang/test/SemaCXX/tag-ambig.cpp
new file mode 100644
index 0000000..6403cf3
--- /dev/null
+++ b/clang/test/SemaCXX/tag-ambig.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/9168556>
+typedef struct Point Point;
+
+namespace NameSpace {
+ class Point;
+}
+
+using namespace NameSpace;
+
+class Test
+{
+public:
+ struct Point { };
+ virtual bool testMethod (Test::Point& p) = 0;
+};
+
+// PR8151
+namespace A { struct Face {}; }
+namespace B { struct Face {}; }
+using namespace A;
+using namespace B;
+
+class C {
+ struct Face;
+ Face *mFaces;
+};
diff --git a/clang/test/SemaCXX/templated-friend-decl.cpp b/clang/test/SemaCXX/templated-friend-decl.cpp
new file mode 100644
index 0000000..c0034cd
--- /dev/null
+++ b/clang/test/SemaCXX/templated-friend-decl.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s
+
+template <typename T>
+struct Foo {
+ template <typename U>
+ struct Bar {};
+
+ // The templated declaration for class Bar should not be instantiated when
+ // Foo<int> is. This is to protect against PR5848; for now, this "parses" but
+ // requires a rewrite of the templated friend code to be properly fixed.
+ template <typename U>
+ friend struct Bar;
+};
+
+Foo<int> x;
diff --git a/clang/test/SemaCXX/this.cpp b/clang/test/SemaCXX/this.cpp
new file mode 100644
index 0000000..27ee1e8
--- /dev/null
+++ b/clang/test/SemaCXX/this.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+int x = this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
+
+void f() {
+ int x = this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
+}
diff --git a/clang/test/SemaCXX/trailing-return-0x.cpp b/clang/test/SemaCXX/trailing-return-0x.cpp
new file mode 100644
index 0000000..c219b77
--- /dev/null
+++ b/clang/test/SemaCXX/trailing-return-0x.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template <class T>
+struct only
+{
+ only(T) {}
+
+ template <class U>
+ only(U)
+ {
+ static_assert(sizeof(U) == 0, "expected type failure");
+ }
+};
+
+auto f() -> int
+{
+ return 0;
+}
+
+auto g(); // expected-error{{return without trailing return type}}
+
+int h() -> int; // expected-error{{trailing return type must specify return type 'auto', not 'int'}}
+
+int i();
+auto i() -> int;
+int i() {}
+
+using T = auto (int) -> auto (*)(char) -> void; // expected-note {{previous}}
+using T = void; // expected-error {{type alias redefinition with different types ('void' vs 'auto (int) -> auto (*)(char) -> void')}}
+
+using U = auto (int) -> auto (*)(char) -> void;
+using U = void (*(int))(char); // ok
+
+int x;
+
+template <class T>
+auto i(T x) -> decltype(x)
+{
+ return x;
+}
+
+only<double> p1 = i(1.0);
+
+template <class T>
+struct X
+{
+ auto f(T x) -> T { return x; }
+
+ template <class U>
+ auto g(T x, U y) -> decltype(x + y)
+ {
+ return x + y;
+ }
+
+ template<typename U>
+ struct nested {
+ template <class V>
+ auto h(T x, U y, V z) -> decltype(x + y + z)
+ {
+ return x + y + z;
+ }
+ };
+
+ template<typename U>
+ nested<U> get_nested();
+};
+
+X<int> xx;
+only<int> p2 = xx.f(0L);
+only<double> p3 = xx.g(0L, 1.0);
+only<double> p4 = xx.get_nested<double>().h(0L, 1.0, 3.14f);
diff --git a/clang/test/SemaCXX/trivial-constructor.cpp b/clang/test/SemaCXX/trivial-constructor.cpp
new file mode 100644
index 0000000..bda206b
--- /dev/null
+++ b/clang/test/SemaCXX/trivial-constructor.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+struct T1 {
+};
+static_assert(__has_trivial_constructor(T1), "T1 has trivial constructor!");
+
+struct T2 {
+ T2();
+};
+static_assert(!__has_trivial_constructor(T2), "T2 has a user-declared constructor!");
+
+struct T3 {
+ virtual void f();
+};
+static_assert(!__has_trivial_constructor(T3), "T3 has a virtual function!");
+
+struct T4 : virtual T3 {
+};
+static_assert(!__has_trivial_constructor(T4), "T4 has a virtual base class!");
+
+struct T5 : T1 {
+};
+static_assert(__has_trivial_constructor(T5), "All the direct base classes of T5 have trivial constructors!");
+
+struct T6 {
+ T5 t5;
+ T1 t1[2][2];
+ static T2 t2;
+};
+static_assert(__has_trivial_constructor(T6), "All nonstatic data members of T6 have trivial constructors!");
+
+struct T7 {
+ T4 t4;
+};
+static_assert(!__has_trivial_constructor(T7), "t4 does not have a trivial constructor!");
+
+struct T8 : T2 {
+};
+static_assert(!__has_trivial_constructor(T8), "The base class T2 does not have a trivial constructor!");
diff --git a/clang/test/SemaCXX/trivial-destructor.cpp b/clang/test/SemaCXX/trivial-destructor.cpp
new file mode 100644
index 0000000..db415cf
--- /dev/null
+++ b/clang/test/SemaCXX/trivial-destructor.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+struct T1 {
+};
+static_assert(__has_trivial_destructor(T1), "T1 has trivial destructor!");
+
+struct T2 {
+ ~T2();
+};
+static_assert(!__has_trivial_destructor(T2), "T2 has a user-declared destructor!");
+
+struct T3 {
+ virtual void f();
+};
+static_assert(__has_trivial_destructor(T3), "T3 has a virtual function (but still a trivial destructor)!");
+
+struct T4 : virtual T3 {
+};
+static_assert(__has_trivial_destructor(T4), "T4 has a virtual base class! (but still a trivial destructor)!");
+
+struct T5 : T1 {
+};
+static_assert(__has_trivial_destructor(T5), "All the direct base classes of T5 have trivial destructors!");
+
+struct T6 {
+ T5 t5;
+ T1 t1[2][2];
+ static T2 t2;
+};
+static_assert(__has_trivial_destructor(T6), "All nonstatic data members of T6 have trivial destructors!");
+
+struct T7 {
+ T2 t2;
+};
+static_assert(!__has_trivial_destructor(T7), "t2 does not have a trivial destructor!");
+
+struct T8 : T2 {
+};
+static_assert(!__has_trivial_destructor(T8), "The base class T2 does not have a trivial destructor!");
diff --git a/clang/test/SemaCXX/type-convert-construct.cpp b/clang/test/SemaCXX/type-convert-construct.cpp
new file mode 100644
index 0000000..479af21
--- /dev/null
+++ b/clang/test/SemaCXX/type-convert-construct.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f() {
+ float v1 = float(1);
+ int v2 = typeof(int)(1,2); // expected-error {{excess elements in scalar initializer}}
+ typedef int arr[];
+ int v3 = arr(); // expected-error {{array types cannot be value-initialized}}
+ int v4 = int();
+ int v5 = int; // expected-error {{expected '(' for function-style cast or type construction}}
+ typedef int T;
+ int *p;
+ bool v6 = T(0) == p;
+ char *str;
+ str = "a string"; // expected-warning{{conversion from string literal to 'char *' is deprecated}}
+ wchar_t *wstr;
+ wstr = L"a wide string"; // expected-warning{{conversion from string literal to 'wchar_t *' is deprecated}}
+}
diff --git a/clang/test/SemaCXX/type-definition-in-specifier.cpp b/clang/test/SemaCXX/type-definition-in-specifier.cpp
new file mode 100644
index 0000000..a614e6c
--- /dev/null
+++ b/clang/test/SemaCXX/type-definition-in-specifier.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct S0;
+struct S1;
+struct S2;
+struct S3;
+struct S4;
+struct S5;
+struct S6;
+
+struct S0 { int x; };
+
+void f0() {
+ typedef struct S1 { int x; } S1_typedef;
+
+ (void)((struct S2 { int x; }*)0); // expected-error{{can not be defined}}
+
+ struct S3 { int x; } s3;
+
+ (void)static_cast<struct S4 { int x; } *>(0); // expected-error{{can not be defined}}
+}
+
+struct S5 { int x; } f1() { return S5(); } // expected-error{{result type}}
+
+void f2(struct S6 { int x; } p); // expected-error{{parameter type}}
diff --git a/clang/test/SemaCXX/type-dependent-exprs.cpp b/clang/test/SemaCXX/type-dependent-exprs.cpp
new file mode 100644
index 0000000..398c3cb
--- /dev/null
+++ b/clang/test/SemaCXX/type-dependent-exprs.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class X {
+public:
+ virtual int f();
+};
+
+void g(int); // expected-note{{candidate function}}
+
+template<typename T>
+T f(T x) {
+ (void)(x + 0);
+ (void)T(0);
+ (void)(x += 0);
+ (void)(x? x : x);
+ (void)static_cast<int>(x);
+ (void)reinterpret_cast<int>(x);
+ (void)dynamic_cast<X*>(&x);
+ (void)const_cast<int>(x);
+ return g(x);
+ h(x); // h is a dependent name
+ g(1, 1); // expected-error{{no matching function for call}}
+ h(1); // expected-error{{use of undeclared identifier 'h'}}
+ return 0;
+}
+
+// This one entered into an infinite loop.
+template <unsigned long N>
+void rdar8520617() {
+ if (N > 1) { }
+}
+
+int f2() {
+ rdar8520617<0>();
+}
+
diff --git a/clang/test/SemaCXX/type-formatting.cpp b/clang/test/SemaCXX/type-formatting.cpp
new file mode 100644
index 0000000..3fe9278
--- /dev/null
+++ b/clang/test/SemaCXX/type-formatting.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct X0 { };
+struct X1 { };
+
+template<typename T>
+void f0() {
+ const T *t = (const X0*)0; // expected-error{{cannot initialize a variable of type 'const X1 *' with an rvalue of type 'const X0 *'}}
+}
+template void f0<X1>(); // expected-note{{instantiation of}}
diff --git a/clang/test/SemaCXX/type-traits-incomplete.cpp b/clang/test/SemaCXX/type-traits-incomplete.cpp
new file mode 100644
index 0000000..c0a520e
--- /dev/null
+++ b/clang/test/SemaCXX/type-traits-incomplete.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct S; // expected-note 2 {{forward declaration of 'S'}}
+
+void f() {
+ __is_pod(S); // expected-error{{incomplete type 'S' used in type trait expression}}
+ __is_pod(S[]); // expected-error{{incomplete type 'S' used in type trait expression}}
+}
diff --git a/clang/test/SemaCXX/type-traits.cpp b/clang/test/SemaCXX/type-traits.cpp
new file mode 100644
index 0000000..f53939a
--- /dev/null
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -0,0 +1,1818 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 %s
+#define T(b) (b) ? 1 : -1
+#define F(b) (b) ? -1 : 1
+
+struct NonPOD { NonPOD(int); };
+
+// PODs
+enum Enum { EV };
+struct POD { Enum e; int i; float f; NonPOD* p; };
+struct Empty {};
+typedef Empty EmptyAr[10];
+typedef int Int;
+typedef Int IntAr[10];
+typedef Int IntArNB[];
+class Statics { static int priv; static NonPOD np; };
+union EmptyUnion {};
+union Union { int i; float f; };
+struct HasFunc { void f (); };
+struct HasOp { void operator *(); };
+struct HasConv { operator int(); };
+struct HasAssign { void operator =(int); };
+
+struct HasAnonymousUnion {
+ union {
+ int i;
+ float f;
+ };
+};
+
+typedef int Vector __attribute__((vector_size(16)));
+typedef int VectorExt __attribute__((ext_vector_type(4)));
+
+// Not PODs
+typedef const void cvoid;
+struct Derives : POD {};
+typedef Derives DerivesAr[10];
+typedef Derives DerivesArNB[];
+struct DerivesEmpty : Empty {};
+struct HasCons { HasCons(int); };
+struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
+struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
+struct HasDefaultTrivialCopyAssign {
+ HasDefaultTrivialCopyAssign &operator =(const HasDefaultTrivialCopyAssign&)
+ = default;
+};
+struct TrivialMoveButNotCopy {
+ TrivialMoveButNotCopy &operator=(TrivialMoveButNotCopy&&) = default;
+ TrivialMoveButNotCopy &operator=(const TrivialMoveButNotCopy&);
+};
+struct NonTrivialDefault {
+ NonTrivialDefault();
+};
+
+struct HasDest { ~HasDest(); };
+class HasPriv { int priv; };
+class HasProt { protected: int prot; };
+struct HasRef { int i; int& ref; HasRef() : i(0), ref(i) {} };
+struct HasNonPOD { NonPOD np; };
+struct HasVirt { virtual void Virt() {}; };
+typedef NonPOD NonPODAr[10];
+typedef HasVirt VirtAr[10];
+typedef NonPOD NonPODArNB[];
+union NonPODUnion { int i; Derives n; };
+struct DerivesHasCons : HasCons {};
+struct DerivesHasCopyAssign : HasCopyAssign {};
+struct DerivesHasMoveAssign : HasMoveAssign {};
+struct DerivesHasDest : HasDest {};
+struct DerivesHasPriv : HasPriv {};
+struct DerivesHasProt : HasProt {};
+struct DerivesHasRef : HasRef {};
+struct DerivesHasVirt : HasVirt {};
+
+struct HasNoThrowCopyAssign {
+ void operator =(const HasNoThrowCopyAssign&) throw();
+};
+struct HasMultipleCopyAssign {
+ void operator =(const HasMultipleCopyAssign&) throw();
+ void operator =(volatile HasMultipleCopyAssign&);
+};
+struct HasMultipleNoThrowCopyAssign {
+ void operator =(const HasMultipleNoThrowCopyAssign&) throw();
+ void operator =(volatile HasMultipleNoThrowCopyAssign&) throw();
+};
+
+struct HasNoThrowConstructor { HasNoThrowConstructor() throw(); };
+struct HasNoThrowConstructorWithArgs {
+ HasNoThrowConstructorWithArgs(HasCons i = HasCons(0)) throw();
+};
+
+struct HasNoThrowCopy { HasNoThrowCopy(const HasNoThrowCopy&) throw(); };
+struct HasMultipleCopy {
+ HasMultipleCopy(const HasMultipleCopy&) throw();
+ HasMultipleCopy(volatile HasMultipleCopy&);
+};
+struct HasMultipleNoThrowCopy {
+ HasMultipleNoThrowCopy(const HasMultipleNoThrowCopy&) throw();
+ HasMultipleNoThrowCopy(volatile HasMultipleNoThrowCopy&) throw();
+};
+
+struct HasVirtDest { virtual ~HasVirtDest(); };
+struct DerivedVirtDest : HasVirtDest {};
+typedef HasVirtDest VirtDestAr[1];
+
+class AllPrivate {
+ AllPrivate() throw();
+ AllPrivate(const AllPrivate&) throw();
+ AllPrivate &operator=(const AllPrivate &) throw();
+ ~AllPrivate() throw();
+};
+
+struct ThreeArgCtor {
+ ThreeArgCtor(int*, char*, int);
+};
+
+void is_pod()
+{
+ { int arr[T(__is_pod(int))]; }
+ { int arr[T(__is_pod(Enum))]; }
+ { int arr[T(__is_pod(POD))]; }
+ { int arr[T(__is_pod(Int))]; }
+ { int arr[T(__is_pod(IntAr))]; }
+ { int arr[T(__is_pod(Statics))]; }
+ { int arr[T(__is_pod(Empty))]; }
+ { int arr[T(__is_pod(EmptyUnion))]; }
+ { int arr[T(__is_pod(Union))]; }
+ { int arr[T(__is_pod(HasFunc))]; }
+ { int arr[T(__is_pod(HasOp))]; }
+ { int arr[T(__is_pod(HasConv))]; }
+ { int arr[T(__is_pod(HasAssign))]; }
+ { int arr[T(__is_pod(IntArNB))]; }
+ { int arr[T(__is_pod(HasAnonymousUnion))]; }
+ { int arr[T(__is_pod(Vector))]; }
+ { int arr[T(__is_pod(VectorExt))]; }
+
+ { int arr[F(__is_pod(Derives))]; }
+ { int arr[F(__is_pod(DerivesAr))]; }
+ { int arr[F(__is_pod(DerivesArNB))]; }
+ { int arr[F(__is_pod(DerivesEmpty))]; }
+ { int arr[F(__is_pod(HasCons))]; }
+ { int arr[F(__is_pod(HasCopyAssign))]; }
+ { int arr[F(__is_pod(HasMoveAssign))]; }
+ { int arr[F(__is_pod(HasDest))]; }
+ { int arr[F(__is_pod(HasPriv))]; }
+ { int arr[F(__is_pod(HasProt))]; }
+ { int arr[F(__is_pod(HasRef))]; }
+ { int arr[F(__is_pod(HasVirt))]; }
+ { int arr[F(__is_pod(DerivesHasCons))]; }
+ { int arr[F(__is_pod(DerivesHasCopyAssign))]; }
+ { int arr[F(__is_pod(DerivesHasMoveAssign))]; }
+ { int arr[F(__is_pod(DerivesHasDest))]; }
+ { int arr[F(__is_pod(DerivesHasPriv))]; }
+ { int arr[F(__is_pod(DerivesHasProt))]; }
+ { int arr[F(__is_pod(DerivesHasRef))]; }
+ { int arr[F(__is_pod(DerivesHasVirt))]; }
+ { int arr[F(__is_pod(NonPOD))]; }
+ { int arr[F(__is_pod(HasNonPOD))]; }
+ { int arr[F(__is_pod(NonPODAr))]; }
+ { int arr[F(__is_pod(NonPODArNB))]; }
+ { int arr[F(__is_pod(void))]; }
+ { int arr[F(__is_pod(cvoid))]; }
+// { int arr[F(__is_pod(NonPODUnion))]; }
+}
+
+typedef Empty EmptyAr[10];
+struct Bit0 { int : 0; };
+struct Bit0Cons { int : 0; Bit0Cons(); };
+struct BitOnly { int x : 3; };
+//struct DerivesVirt : virtual POD {};
+
+void is_empty()
+{
+ { int arr[T(__is_empty(Empty))]; }
+ { int arr[T(__is_empty(DerivesEmpty))]; }
+ { int arr[T(__is_empty(HasCons))]; }
+ { int arr[T(__is_empty(HasCopyAssign))]; }
+ { int arr[T(__is_empty(HasMoveAssign))]; }
+ { int arr[T(__is_empty(HasDest))]; }
+ { int arr[T(__is_empty(HasFunc))]; }
+ { int arr[T(__is_empty(HasOp))]; }
+ { int arr[T(__is_empty(HasConv))]; }
+ { int arr[T(__is_empty(HasAssign))]; }
+ { int arr[T(__is_empty(Bit0))]; }
+ { int arr[T(__is_empty(Bit0Cons))]; }
+
+ { int arr[F(__is_empty(Int))]; }
+ { int arr[F(__is_empty(POD))]; }
+ { int arr[F(__is_empty(EmptyUnion))]; }
+ { int arr[F(__is_empty(EmptyAr))]; }
+ { int arr[F(__is_empty(HasRef))]; }
+ { int arr[F(__is_empty(HasVirt))]; }
+ { int arr[F(__is_empty(BitOnly))]; }
+ { int arr[F(__is_empty(void))]; }
+ { int arr[F(__is_empty(IntArNB))]; }
+ { int arr[F(__is_empty(HasAnonymousUnion))]; }
+// { int arr[F(__is_empty(DerivesVirt))]; }
+}
+
+typedef Derives ClassType;
+
+void is_class()
+{
+ { int arr[T(__is_class(Derives))]; }
+ { int arr[T(__is_class(HasPriv))]; }
+ { int arr[T(__is_class(ClassType))]; }
+ { int arr[T(__is_class(HasAnonymousUnion))]; }
+
+ { int arr[F(__is_class(int))]; }
+ { int arr[F(__is_class(Enum))]; }
+ { int arr[F(__is_class(Int))]; }
+ { int arr[F(__is_class(IntAr))]; }
+ { int arr[F(__is_class(DerivesAr))]; }
+ { int arr[F(__is_class(Union))]; }
+ { int arr[F(__is_class(cvoid))]; }
+ { int arr[F(__is_class(IntArNB))]; }
+}
+
+typedef Union UnionAr[10];
+typedef Union UnionType;
+
+void is_union()
+{
+ { int arr[T(__is_union(Union))]; }
+ { int arr[T(__is_union(UnionType))]; }
+
+ { int arr[F(__is_union(int))]; }
+ { int arr[F(__is_union(Enum))]; }
+ { int arr[F(__is_union(Int))]; }
+ { int arr[F(__is_union(IntAr))]; }
+ { int arr[F(__is_union(UnionAr))]; }
+ { int arr[F(__is_union(cvoid))]; }
+ { int arr[F(__is_union(IntArNB))]; }
+ { int arr[F(__is_union(HasAnonymousUnion))]; }
+}
+
+typedef Enum EnumType;
+
+void is_enum()
+{
+ { int arr[T(__is_enum(Enum))]; }
+ { int arr[T(__is_enum(EnumType))]; }
+
+ { int arr[F(__is_enum(int))]; }
+ { int arr[F(__is_enum(Union))]; }
+ { int arr[F(__is_enum(Int))]; }
+ { int arr[F(__is_enum(IntAr))]; }
+ { int arr[F(__is_enum(UnionAr))]; }
+ { int arr[F(__is_enum(Derives))]; }
+ { int arr[F(__is_enum(ClassType))]; }
+ { int arr[F(__is_enum(cvoid))]; }
+ { int arr[F(__is_enum(IntArNB))]; }
+ { int arr[F(__is_enum(HasAnonymousUnion))]; }
+}
+
+struct FinalClass final {
+};
+
+template<typename T>
+struct PotentiallyFinal { };
+
+template<typename T>
+struct PotentiallyFinal<T*> final { };
+
+template<>
+struct PotentiallyFinal<int> final { };
+
+void is_final()
+{
+ { int arr[T(__is_final(FinalClass))]; }
+ { int arr[T(__is_final(PotentiallyFinal<float*>))]; }
+ { int arr[T(__is_final(PotentiallyFinal<int>))]; }
+
+ { int arr[F(__is_final(int))]; }
+ { int arr[F(__is_final(Union))]; }
+ { int arr[F(__is_final(Int))]; }
+ { int arr[F(__is_final(IntAr))]; }
+ { int arr[F(__is_final(UnionAr))]; }
+ { int arr[F(__is_final(Derives))]; }
+ { int arr[F(__is_final(ClassType))]; }
+ { int arr[F(__is_final(cvoid))]; }
+ { int arr[F(__is_final(IntArNB))]; }
+ { int arr[F(__is_final(HasAnonymousUnion))]; }
+ { int arr[F(__is_final(PotentiallyFinal<float>))]; }
+}
+
+typedef HasVirt Polymorph;
+struct InheritPolymorph : Polymorph {};
+
+void is_polymorphic()
+{
+ { int arr[T(__is_polymorphic(Polymorph))]; }
+ { int arr[T(__is_polymorphic(InheritPolymorph))]; }
+
+ { int arr[F(__is_polymorphic(int))]; }
+ { int arr[F(__is_polymorphic(Union))]; }
+ { int arr[F(__is_polymorphic(Int))]; }
+ { int arr[F(__is_polymorphic(IntAr))]; }
+ { int arr[F(__is_polymorphic(UnionAr))]; }
+ { int arr[F(__is_polymorphic(Derives))]; }
+ { int arr[F(__is_polymorphic(ClassType))]; }
+ { int arr[F(__is_polymorphic(Enum))]; }
+ { int arr[F(__is_polymorphic(cvoid))]; }
+ { int arr[F(__is_polymorphic(IntArNB))]; }
+}
+
+void is_integral()
+{
+ int t01[T(__is_integral(bool))];
+ int t02[T(__is_integral(char))];
+ int t03[T(__is_integral(signed char))];
+ int t04[T(__is_integral(unsigned char))];
+ //int t05[T(__is_integral(char16_t))];
+ //int t06[T(__is_integral(char32_t))];
+ int t07[T(__is_integral(wchar_t))];
+ int t08[T(__is_integral(short))];
+ int t09[T(__is_integral(unsigned short))];
+ int t10[T(__is_integral(int))];
+ int t11[T(__is_integral(unsigned int))];
+ int t12[T(__is_integral(long))];
+ int t13[T(__is_integral(unsigned long))];
+
+ int t21[F(__is_integral(float))];
+ int t22[F(__is_integral(double))];
+ int t23[F(__is_integral(long double))];
+ int t24[F(__is_integral(Union))];
+ int t25[F(__is_integral(UnionAr))];
+ int t26[F(__is_integral(Derives))];
+ int t27[F(__is_integral(ClassType))];
+ int t28[F(__is_integral(Enum))];
+ int t29[F(__is_integral(void))];
+ int t30[F(__is_integral(cvoid))];
+ int t31[F(__is_integral(IntArNB))];
+}
+
+void is_floating_point()
+{
+ int t01[T(__is_floating_point(float))];
+ int t02[T(__is_floating_point(double))];
+ int t03[T(__is_floating_point(long double))];
+
+ int t11[F(__is_floating_point(bool))];
+ int t12[F(__is_floating_point(char))];
+ int t13[F(__is_floating_point(signed char))];
+ int t14[F(__is_floating_point(unsigned char))];
+ //int t15[F(__is_floating_point(char16_t))];
+ //int t16[F(__is_floating_point(char32_t))];
+ int t17[F(__is_floating_point(wchar_t))];
+ int t18[F(__is_floating_point(short))];
+ int t19[F(__is_floating_point(unsigned short))];
+ int t20[F(__is_floating_point(int))];
+ int t21[F(__is_floating_point(unsigned int))];
+ int t22[F(__is_floating_point(long))];
+ int t23[F(__is_floating_point(unsigned long))];
+ int t24[F(__is_floating_point(Union))];
+ int t25[F(__is_floating_point(UnionAr))];
+ int t26[F(__is_floating_point(Derives))];
+ int t27[F(__is_floating_point(ClassType))];
+ int t28[F(__is_floating_point(Enum))];
+ int t29[F(__is_floating_point(void))];
+ int t30[F(__is_floating_point(cvoid))];
+ int t31[F(__is_floating_point(IntArNB))];
+}
+
+void is_arithmetic()
+{
+ int t01[T(__is_arithmetic(float))];
+ int t02[T(__is_arithmetic(double))];
+ int t03[T(__is_arithmetic(long double))];
+ int t11[T(__is_arithmetic(bool))];
+ int t12[T(__is_arithmetic(char))];
+ int t13[T(__is_arithmetic(signed char))];
+ int t14[T(__is_arithmetic(unsigned char))];
+ //int t15[T(__is_arithmetic(char16_t))];
+ //int t16[T(__is_arithmetic(char32_t))];
+ int t17[T(__is_arithmetic(wchar_t))];
+ int t18[T(__is_arithmetic(short))];
+ int t19[T(__is_arithmetic(unsigned short))];
+ int t20[T(__is_arithmetic(int))];
+ int t21[T(__is_arithmetic(unsigned int))];
+ int t22[T(__is_arithmetic(long))];
+ int t23[T(__is_arithmetic(unsigned long))];
+
+ int t24[F(__is_arithmetic(Union))];
+ int t25[F(__is_arithmetic(UnionAr))];
+ int t26[F(__is_arithmetic(Derives))];
+ int t27[F(__is_arithmetic(ClassType))];
+ int t28[F(__is_arithmetic(Enum))];
+ int t29[F(__is_arithmetic(void))];
+ int t30[F(__is_arithmetic(cvoid))];
+ int t31[F(__is_arithmetic(IntArNB))];
+}
+
+struct ACompleteType {};
+struct AnIncompleteType;
+
+void is_complete_type()
+{
+ int t01[T(__is_complete_type(float))];
+ int t02[T(__is_complete_type(double))];
+ int t03[T(__is_complete_type(long double))];
+ int t11[T(__is_complete_type(bool))];
+ int t12[T(__is_complete_type(char))];
+ int t13[T(__is_complete_type(signed char))];
+ int t14[T(__is_complete_type(unsigned char))];
+ //int t15[T(__is_complete_type(char16_t))];
+ //int t16[T(__is_complete_type(char32_t))];
+ int t17[T(__is_complete_type(wchar_t))];
+ int t18[T(__is_complete_type(short))];
+ int t19[T(__is_complete_type(unsigned short))];
+ int t20[T(__is_complete_type(int))];
+ int t21[T(__is_complete_type(unsigned int))];
+ int t22[T(__is_complete_type(long))];
+ int t23[T(__is_complete_type(unsigned long))];
+ int t24[T(__is_complete_type(ACompleteType))];
+
+ int t30[F(__is_complete_type(AnIncompleteType))];
+}
+
+void is_void()
+{
+ int t01[T(__is_void(void))];
+ int t02[T(__is_void(cvoid))];
+
+ int t10[F(__is_void(float))];
+ int t11[F(__is_void(double))];
+ int t12[F(__is_void(long double))];
+ int t13[F(__is_void(bool))];
+ int t14[F(__is_void(char))];
+ int t15[F(__is_void(signed char))];
+ int t16[F(__is_void(unsigned char))];
+ int t17[F(__is_void(wchar_t))];
+ int t18[F(__is_void(short))];
+ int t19[F(__is_void(unsigned short))];
+ int t20[F(__is_void(int))];
+ int t21[F(__is_void(unsigned int))];
+ int t22[F(__is_void(long))];
+ int t23[F(__is_void(unsigned long))];
+ int t24[F(__is_void(Union))];
+ int t25[F(__is_void(UnionAr))];
+ int t26[F(__is_void(Derives))];
+ int t27[F(__is_void(ClassType))];
+ int t28[F(__is_void(Enum))];
+ int t29[F(__is_void(IntArNB))];
+ int t30[F(__is_void(void*))];
+ int t31[F(__is_void(cvoid*))];
+}
+
+void is_array()
+{
+ int t01[T(__is_array(IntAr))];
+ int t02[T(__is_array(IntArNB))];
+ int t03[T(__is_array(UnionAr))];
+
+ int t10[F(__is_array(void))];
+ int t11[F(__is_array(cvoid))];
+ int t12[F(__is_array(float))];
+ int t13[F(__is_array(double))];
+ int t14[F(__is_array(long double))];
+ int t15[F(__is_array(bool))];
+ int t16[F(__is_array(char))];
+ int t17[F(__is_array(signed char))];
+ int t18[F(__is_array(unsigned char))];
+ int t19[F(__is_array(wchar_t))];
+ int t20[F(__is_array(short))];
+ int t21[F(__is_array(unsigned short))];
+ int t22[F(__is_array(int))];
+ int t23[F(__is_array(unsigned int))];
+ int t24[F(__is_array(long))];
+ int t25[F(__is_array(unsigned long))];
+ int t26[F(__is_array(Union))];
+ int t27[F(__is_array(Derives))];
+ int t28[F(__is_array(ClassType))];
+ int t29[F(__is_array(Enum))];
+ int t30[F(__is_array(void*))];
+ int t31[F(__is_array(cvoid*))];
+}
+
+template <typename T> void tmpl_func(T&) {}
+
+template <typename T> struct type_wrapper {
+ typedef T type;
+ typedef T* ptrtype;
+ typedef T& reftype;
+};
+
+void is_function()
+{
+ int t01[T(__is_function(type_wrapper<void(void)>::type))];
+ int t02[T(__is_function(typeof(tmpl_func<int>)))];
+
+ typedef void (*ptr_to_func_type)(void);
+
+ int t10[F(__is_function(void))];
+ int t11[F(__is_function(cvoid))];
+ int t12[F(__is_function(float))];
+ int t13[F(__is_function(double))];
+ int t14[F(__is_function(long double))];
+ int t15[F(__is_function(bool))];
+ int t16[F(__is_function(char))];
+ int t17[F(__is_function(signed char))];
+ int t18[F(__is_function(unsigned char))];
+ int t19[F(__is_function(wchar_t))];
+ int t20[F(__is_function(short))];
+ int t21[F(__is_function(unsigned short))];
+ int t22[F(__is_function(int))];
+ int t23[F(__is_function(unsigned int))];
+ int t24[F(__is_function(long))];
+ int t25[F(__is_function(unsigned long))];
+ int t26[F(__is_function(Union))];
+ int t27[F(__is_function(Derives))];
+ int t28[F(__is_function(ClassType))];
+ int t29[F(__is_function(Enum))];
+ int t30[F(__is_function(void*))];
+ int t31[F(__is_function(cvoid*))];
+ int t32[F(__is_function(void(*)()))];
+ int t33[F(__is_function(ptr_to_func_type))];
+ int t34[F(__is_function(type_wrapper<void(void)>::ptrtype))];
+ int t35[F(__is_function(type_wrapper<void(void)>::reftype))];
+}
+
+void is_reference()
+{
+ int t01[T(__is_reference(int&))];
+ int t02[T(__is_reference(const int&))];
+ int t03[T(__is_reference(void *&))];
+
+ int t10[F(__is_reference(int))];
+ int t11[F(__is_reference(const int))];
+ int t12[F(__is_reference(void *))];
+}
+
+void is_lvalue_reference()
+{
+ int t01[T(__is_lvalue_reference(int&))];
+ int t02[T(__is_lvalue_reference(void *&))];
+ int t03[T(__is_lvalue_reference(const int&))];
+ int t04[T(__is_lvalue_reference(void * const &))];
+
+ int t10[F(__is_lvalue_reference(int))];
+ int t11[F(__is_lvalue_reference(const int))];
+ int t12[F(__is_lvalue_reference(void *))];
+}
+
+#if __has_feature(cxx_rvalue_references)
+
+void is_rvalue_reference()
+{
+ int t01[T(__is_rvalue_reference(const int&&))];
+ int t02[T(__is_rvalue_reference(void * const &&))];
+
+ int t10[F(__is_rvalue_reference(int&))];
+ int t11[F(__is_rvalue_reference(void *&))];
+ int t12[F(__is_rvalue_reference(const int&))];
+ int t13[F(__is_rvalue_reference(void * const &))];
+ int t14[F(__is_rvalue_reference(int))];
+ int t15[F(__is_rvalue_reference(const int))];
+ int t16[F(__is_rvalue_reference(void *))];
+}
+
+#endif
+
+void is_fundamental()
+{
+ int t01[T(__is_fundamental(float))];
+ int t02[T(__is_fundamental(double))];
+ int t03[T(__is_fundamental(long double))];
+ int t11[T(__is_fundamental(bool))];
+ int t12[T(__is_fundamental(char))];
+ int t13[T(__is_fundamental(signed char))];
+ int t14[T(__is_fundamental(unsigned char))];
+ //int t15[T(__is_fundamental(char16_t))];
+ //int t16[T(__is_fundamental(char32_t))];
+ int t17[T(__is_fundamental(wchar_t))];
+ int t18[T(__is_fundamental(short))];
+ int t19[T(__is_fundamental(unsigned short))];
+ int t20[T(__is_fundamental(int))];
+ int t21[T(__is_fundamental(unsigned int))];
+ int t22[T(__is_fundamental(long))];
+ int t23[T(__is_fundamental(unsigned long))];
+ int t24[T(__is_fundamental(void))];
+ int t25[T(__is_fundamental(cvoid))];
+
+ int t30[F(__is_fundamental(Union))];
+ int t31[F(__is_fundamental(UnionAr))];
+ int t32[F(__is_fundamental(Derives))];
+ int t33[F(__is_fundamental(ClassType))];
+ int t34[F(__is_fundamental(Enum))];
+ int t35[F(__is_fundamental(IntArNB))];
+}
+
+void is_object()
+{
+ int t01[T(__is_object(int))];
+ int t02[T(__is_object(int *))];
+ int t03[T(__is_object(void *))];
+ int t04[T(__is_object(Union))];
+ int t05[T(__is_object(UnionAr))];
+ int t06[T(__is_object(ClassType))];
+ int t07[T(__is_object(Enum))];
+
+ int t10[F(__is_object(type_wrapper<void(void)>::type))];
+ int t11[F(__is_object(int&))];
+ int t12[F(__is_object(void))];
+}
+
+void is_scalar()
+{
+ int t01[T(__is_scalar(float))];
+ int t02[T(__is_scalar(double))];
+ int t03[T(__is_scalar(long double))];
+ int t04[T(__is_scalar(bool))];
+ int t05[T(__is_scalar(char))];
+ int t06[T(__is_scalar(signed char))];
+ int t07[T(__is_scalar(unsigned char))];
+ int t08[T(__is_scalar(wchar_t))];
+ int t09[T(__is_scalar(short))];
+ int t10[T(__is_scalar(unsigned short))];
+ int t11[T(__is_scalar(int))];
+ int t12[T(__is_scalar(unsigned int))];
+ int t13[T(__is_scalar(long))];
+ int t14[T(__is_scalar(unsigned long))];
+ int t15[T(__is_scalar(Enum))];
+ int t16[T(__is_scalar(void*))];
+ int t17[T(__is_scalar(cvoid*))];
+
+ int t20[F(__is_scalar(void))];
+ int t21[F(__is_scalar(cvoid))];
+ int t22[F(__is_scalar(Union))];
+ int t23[F(__is_scalar(UnionAr))];
+ int t24[F(__is_scalar(Derives))];
+ int t25[F(__is_scalar(ClassType))];
+ int t26[F(__is_scalar(IntArNB))];
+}
+
+struct StructWithMembers {
+ int member;
+ void method() {}
+};
+
+void is_compound()
+{
+ int t01[T(__is_compound(void*))];
+ int t02[T(__is_compound(cvoid*))];
+ int t03[T(__is_compound(void (*)()))];
+ int t04[T(__is_compound(int StructWithMembers::*))];
+ int t05[T(__is_compound(void (StructWithMembers::*)()))];
+ int t06[T(__is_compound(int&))];
+ int t07[T(__is_compound(Union))];
+ int t08[T(__is_compound(UnionAr))];
+ int t09[T(__is_compound(Derives))];
+ int t10[T(__is_compound(ClassType))];
+ int t11[T(__is_compound(IntArNB))];
+ int t12[T(__is_compound(Enum))];
+
+ int t20[F(__is_compound(float))];
+ int t21[F(__is_compound(double))];
+ int t22[F(__is_compound(long double))];
+ int t23[F(__is_compound(bool))];
+ int t24[F(__is_compound(char))];
+ int t25[F(__is_compound(signed char))];
+ int t26[F(__is_compound(unsigned char))];
+ int t27[F(__is_compound(wchar_t))];
+ int t28[F(__is_compound(short))];
+ int t29[F(__is_compound(unsigned short))];
+ int t30[F(__is_compound(int))];
+ int t31[F(__is_compound(unsigned int))];
+ int t32[F(__is_compound(long))];
+ int t33[F(__is_compound(unsigned long))];
+ int t34[F(__is_compound(void))];
+ int t35[F(__is_compound(cvoid))];
+}
+
+void is_pointer()
+{
+ StructWithMembers x;
+
+ int t01[T(__is_pointer(void*))];
+ int t02[T(__is_pointer(cvoid*))];
+ int t03[T(__is_pointer(cvoid*))];
+ int t04[T(__is_pointer(char*))];
+ int t05[T(__is_pointer(int*))];
+ int t06[T(__is_pointer(int**))];
+ int t07[T(__is_pointer(ClassType*))];
+ int t08[T(__is_pointer(Derives*))];
+ int t09[T(__is_pointer(Enum*))];
+ int t10[T(__is_pointer(IntArNB*))];
+ int t11[T(__is_pointer(Union*))];
+ int t12[T(__is_pointer(UnionAr*))];
+ int t13[T(__is_pointer(StructWithMembers*))];
+ int t14[T(__is_pointer(void (*)()))];
+
+ int t20[F(__is_pointer(void))];
+ int t21[F(__is_pointer(cvoid))];
+ int t22[F(__is_pointer(cvoid))];
+ int t23[F(__is_pointer(char))];
+ int t24[F(__is_pointer(int))];
+ int t25[F(__is_pointer(int))];
+ int t26[F(__is_pointer(ClassType))];
+ int t27[F(__is_pointer(Derives))];
+ int t28[F(__is_pointer(Enum))];
+ int t29[F(__is_pointer(IntArNB))];
+ int t30[F(__is_pointer(Union))];
+ int t31[F(__is_pointer(UnionAr))];
+ int t32[F(__is_pointer(StructWithMembers))];
+ int t33[F(__is_pointer(int StructWithMembers::*))];
+ int t34[F(__is_pointer(void (StructWithMembers::*) ()))];
+}
+
+void is_member_object_pointer()
+{
+ StructWithMembers x;
+
+ int t01[T(__is_member_object_pointer(int StructWithMembers::*))];
+
+ int t10[F(__is_member_object_pointer(void (StructWithMembers::*) ()))];
+ int t11[F(__is_member_object_pointer(void*))];
+ int t12[F(__is_member_object_pointer(cvoid*))];
+ int t13[F(__is_member_object_pointer(cvoid*))];
+ int t14[F(__is_member_object_pointer(char*))];
+ int t15[F(__is_member_object_pointer(int*))];
+ int t16[F(__is_member_object_pointer(int**))];
+ int t17[F(__is_member_object_pointer(ClassType*))];
+ int t18[F(__is_member_object_pointer(Derives*))];
+ int t19[F(__is_member_object_pointer(Enum*))];
+ int t20[F(__is_member_object_pointer(IntArNB*))];
+ int t21[F(__is_member_object_pointer(Union*))];
+ int t22[F(__is_member_object_pointer(UnionAr*))];
+ int t23[F(__is_member_object_pointer(StructWithMembers*))];
+ int t24[F(__is_member_object_pointer(void))];
+ int t25[F(__is_member_object_pointer(cvoid))];
+ int t26[F(__is_member_object_pointer(cvoid))];
+ int t27[F(__is_member_object_pointer(char))];
+ int t28[F(__is_member_object_pointer(int))];
+ int t29[F(__is_member_object_pointer(int))];
+ int t30[F(__is_member_object_pointer(ClassType))];
+ int t31[F(__is_member_object_pointer(Derives))];
+ int t32[F(__is_member_object_pointer(Enum))];
+ int t33[F(__is_member_object_pointer(IntArNB))];
+ int t34[F(__is_member_object_pointer(Union))];
+ int t35[F(__is_member_object_pointer(UnionAr))];
+ int t36[F(__is_member_object_pointer(StructWithMembers))];
+ int t37[F(__is_member_object_pointer(void (*)()))];
+}
+
+void is_member_function_pointer()
+{
+ StructWithMembers x;
+
+ int t01[T(__is_member_function_pointer(void (StructWithMembers::*) ()))];
+
+ int t10[F(__is_member_function_pointer(int StructWithMembers::*))];
+ int t11[F(__is_member_function_pointer(void*))];
+ int t12[F(__is_member_function_pointer(cvoid*))];
+ int t13[F(__is_member_function_pointer(cvoid*))];
+ int t14[F(__is_member_function_pointer(char*))];
+ int t15[F(__is_member_function_pointer(int*))];
+ int t16[F(__is_member_function_pointer(int**))];
+ int t17[F(__is_member_function_pointer(ClassType*))];
+ int t18[F(__is_member_function_pointer(Derives*))];
+ int t19[F(__is_member_function_pointer(Enum*))];
+ int t20[F(__is_member_function_pointer(IntArNB*))];
+ int t21[F(__is_member_function_pointer(Union*))];
+ int t22[F(__is_member_function_pointer(UnionAr*))];
+ int t23[F(__is_member_function_pointer(StructWithMembers*))];
+ int t24[F(__is_member_function_pointer(void))];
+ int t25[F(__is_member_function_pointer(cvoid))];
+ int t26[F(__is_member_function_pointer(cvoid))];
+ int t27[F(__is_member_function_pointer(char))];
+ int t28[F(__is_member_function_pointer(int))];
+ int t29[F(__is_member_function_pointer(int))];
+ int t30[F(__is_member_function_pointer(ClassType))];
+ int t31[F(__is_member_function_pointer(Derives))];
+ int t32[F(__is_member_function_pointer(Enum))];
+ int t33[F(__is_member_function_pointer(IntArNB))];
+ int t34[F(__is_member_function_pointer(Union))];
+ int t35[F(__is_member_function_pointer(UnionAr))];
+ int t36[F(__is_member_function_pointer(StructWithMembers))];
+ int t37[F(__is_member_function_pointer(void (*)()))];
+}
+
+void is_member_pointer()
+{
+ StructWithMembers x;
+
+ int t01[T(__is_member_pointer(int StructWithMembers::*))];
+ int t02[T(__is_member_pointer(void (StructWithMembers::*) ()))];
+
+ int t10[F(__is_member_pointer(void*))];
+ int t11[F(__is_member_pointer(cvoid*))];
+ int t12[F(__is_member_pointer(cvoid*))];
+ int t13[F(__is_member_pointer(char*))];
+ int t14[F(__is_member_pointer(int*))];
+ int t15[F(__is_member_pointer(int**))];
+ int t16[F(__is_member_pointer(ClassType*))];
+ int t17[F(__is_member_pointer(Derives*))];
+ int t18[F(__is_member_pointer(Enum*))];
+ int t19[F(__is_member_pointer(IntArNB*))];
+ int t20[F(__is_member_pointer(Union*))];
+ int t21[F(__is_member_pointer(UnionAr*))];
+ int t22[F(__is_member_pointer(StructWithMembers*))];
+ int t23[F(__is_member_pointer(void))];
+ int t24[F(__is_member_pointer(cvoid))];
+ int t25[F(__is_member_pointer(cvoid))];
+ int t26[F(__is_member_pointer(char))];
+ int t27[F(__is_member_pointer(int))];
+ int t28[F(__is_member_pointer(int))];
+ int t29[F(__is_member_pointer(ClassType))];
+ int t30[F(__is_member_pointer(Derives))];
+ int t31[F(__is_member_pointer(Enum))];
+ int t32[F(__is_member_pointer(IntArNB))];
+ int t33[F(__is_member_pointer(Union))];
+ int t34[F(__is_member_pointer(UnionAr))];
+ int t35[F(__is_member_pointer(StructWithMembers))];
+ int t36[F(__is_member_pointer(void (*)()))];
+}
+
+void is_const()
+{
+ int t01[T(__is_const(cvoid))];
+ int t02[T(__is_const(const char))];
+ int t03[T(__is_const(const int))];
+ int t04[T(__is_const(const long))];
+ int t05[T(__is_const(const short))];
+ int t06[T(__is_const(const signed char))];
+ int t07[T(__is_const(const wchar_t))];
+ int t08[T(__is_const(const bool))];
+ int t09[T(__is_const(const float))];
+ int t10[T(__is_const(const double))];
+ int t11[T(__is_const(const long double))];
+ int t12[T(__is_const(const unsigned char))];
+ int t13[T(__is_const(const unsigned int))];
+ int t14[T(__is_const(const unsigned long long))];
+ int t15[T(__is_const(const unsigned long))];
+ int t16[T(__is_const(const unsigned short))];
+ int t17[T(__is_const(const void))];
+ int t18[T(__is_const(const ClassType))];
+ int t19[T(__is_const(const Derives))];
+ int t20[T(__is_const(const Enum))];
+ int t21[T(__is_const(const IntArNB))];
+ int t22[T(__is_const(const Union))];
+ int t23[T(__is_const(const UnionAr))];
+
+ int t30[F(__is_const(char))];
+ int t31[F(__is_const(int))];
+ int t32[F(__is_const(long))];
+ int t33[F(__is_const(short))];
+ int t34[F(__is_const(signed char))];
+ int t35[F(__is_const(wchar_t))];
+ int t36[F(__is_const(bool))];
+ int t37[F(__is_const(float))];
+ int t38[F(__is_const(double))];
+ int t39[F(__is_const(long double))];
+ int t40[F(__is_const(unsigned char))];
+ int t41[F(__is_const(unsigned int))];
+ int t42[F(__is_const(unsigned long long))];
+ int t43[F(__is_const(unsigned long))];
+ int t44[F(__is_const(unsigned short))];
+ int t45[F(__is_const(void))];
+ int t46[F(__is_const(ClassType))];
+ int t47[F(__is_const(Derives))];
+ int t48[F(__is_const(Enum))];
+ int t49[F(__is_const(IntArNB))];
+ int t50[F(__is_const(Union))];
+ int t51[F(__is_const(UnionAr))];
+}
+
+void is_volatile()
+{
+ int t02[T(__is_volatile(volatile char))];
+ int t03[T(__is_volatile(volatile int))];
+ int t04[T(__is_volatile(volatile long))];
+ int t05[T(__is_volatile(volatile short))];
+ int t06[T(__is_volatile(volatile signed char))];
+ int t07[T(__is_volatile(volatile wchar_t))];
+ int t08[T(__is_volatile(volatile bool))];
+ int t09[T(__is_volatile(volatile float))];
+ int t10[T(__is_volatile(volatile double))];
+ int t11[T(__is_volatile(volatile long double))];
+ int t12[T(__is_volatile(volatile unsigned char))];
+ int t13[T(__is_volatile(volatile unsigned int))];
+ int t14[T(__is_volatile(volatile unsigned long long))];
+ int t15[T(__is_volatile(volatile unsigned long))];
+ int t16[T(__is_volatile(volatile unsigned short))];
+ int t17[T(__is_volatile(volatile void))];
+ int t18[T(__is_volatile(volatile ClassType))];
+ int t19[T(__is_volatile(volatile Derives))];
+ int t20[T(__is_volatile(volatile Enum))];
+ int t21[T(__is_volatile(volatile IntArNB))];
+ int t22[T(__is_volatile(volatile Union))];
+ int t23[T(__is_volatile(volatile UnionAr))];
+
+ int t30[F(__is_volatile(char))];
+ int t31[F(__is_volatile(int))];
+ int t32[F(__is_volatile(long))];
+ int t33[F(__is_volatile(short))];
+ int t34[F(__is_volatile(signed char))];
+ int t35[F(__is_volatile(wchar_t))];
+ int t36[F(__is_volatile(bool))];
+ int t37[F(__is_volatile(float))];
+ int t38[F(__is_volatile(double))];
+ int t39[F(__is_volatile(long double))];
+ int t40[F(__is_volatile(unsigned char))];
+ int t41[F(__is_volatile(unsigned int))];
+ int t42[F(__is_volatile(unsigned long long))];
+ int t43[F(__is_volatile(unsigned long))];
+ int t44[F(__is_volatile(unsigned short))];
+ int t45[F(__is_volatile(void))];
+ int t46[F(__is_volatile(ClassType))];
+ int t47[F(__is_volatile(Derives))];
+ int t48[F(__is_volatile(Enum))];
+ int t49[F(__is_volatile(IntArNB))];
+ int t50[F(__is_volatile(Union))];
+ int t51[F(__is_volatile(UnionAr))];
+}
+
+struct TrivialStruct {
+ int member;
+};
+
+struct NonTrivialStruct {
+ int member;
+ NonTrivialStruct() {
+ member = 0;
+ }
+};
+
+struct SuperNonTrivialStruct {
+ SuperNonTrivialStruct() { }
+ ~SuperNonTrivialStruct() { }
+};
+
+struct NonTCStruct {
+ NonTCStruct(const NonTCStruct&) {}
+};
+
+struct AllDefaulted {
+ AllDefaulted() = default;
+ AllDefaulted(const AllDefaulted &) = default;
+ AllDefaulted(AllDefaulted &&) = default;
+ AllDefaulted &operator=(const AllDefaulted &) = default;
+ AllDefaulted &operator=(AllDefaulted &&) = default;
+ ~AllDefaulted() = default;
+};
+
+struct AllDeleted {
+ AllDeleted() = delete;
+ AllDeleted(const AllDeleted &) = delete;
+ AllDeleted(AllDeleted &&) = delete;
+ AllDeleted &operator=(const AllDeleted &) = delete;
+ AllDeleted &operator=(AllDeleted &&) = delete;
+ ~AllDeleted() = delete;
+};
+
+struct ExtDefaulted {
+ ExtDefaulted();
+ ExtDefaulted(const ExtDefaulted &);
+ ExtDefaulted(ExtDefaulted &&);
+ ExtDefaulted &operator=(const ExtDefaulted &);
+ ExtDefaulted &operator=(ExtDefaulted &&);
+ ~ExtDefaulted();
+};
+
+// Despite being defaulted, these functions are not trivial.
+ExtDefaulted::ExtDefaulted() = default;
+ExtDefaulted::ExtDefaulted(const ExtDefaulted &) = default;
+ExtDefaulted::ExtDefaulted(ExtDefaulted &&) = default;
+ExtDefaulted &ExtDefaulted::operator=(const ExtDefaulted &) = default;
+ExtDefaulted &ExtDefaulted::operator=(ExtDefaulted &&) = default;
+ExtDefaulted::~ExtDefaulted() = default;
+
+void is_trivial2()
+{
+ int t01[T(__is_trivial(char))];
+ int t02[T(__is_trivial(int))];
+ int t03[T(__is_trivial(long))];
+ int t04[T(__is_trivial(short))];
+ int t05[T(__is_trivial(signed char))];
+ int t06[T(__is_trivial(wchar_t))];
+ int t07[T(__is_trivial(bool))];
+ int t08[T(__is_trivial(float))];
+ int t09[T(__is_trivial(double))];
+ int t10[T(__is_trivial(long double))];
+ int t11[T(__is_trivial(unsigned char))];
+ int t12[T(__is_trivial(unsigned int))];
+ int t13[T(__is_trivial(unsigned long long))];
+ int t14[T(__is_trivial(unsigned long))];
+ int t15[T(__is_trivial(unsigned short))];
+ int t16[T(__is_trivial(ClassType))];
+ int t17[T(__is_trivial(Derives))];
+ int t18[T(__is_trivial(Enum))];
+ int t19[T(__is_trivial(IntAr))];
+ int t20[T(__is_trivial(Union))];
+ int t21[T(__is_trivial(UnionAr))];
+ int t22[T(__is_trivial(TrivialStruct))];
+ int t23[T(__is_trivial(AllDefaulted))];
+ int t24[T(__is_trivial(AllDeleted))];
+
+ int t30[F(__is_trivial(void))];
+ int t31[F(__is_trivial(NonTrivialStruct))];
+ int t32[F(__is_trivial(SuperNonTrivialStruct))];
+ int t33[F(__is_trivial(NonTCStruct))];
+ int t34[F(__is_trivial(ExtDefaulted))];
+}
+
+void is_trivially_copyable2()
+{
+ int t01[T(__is_trivially_copyable(char))];
+ int t02[T(__is_trivially_copyable(int))];
+ int t03[T(__is_trivially_copyable(long))];
+ int t04[T(__is_trivially_copyable(short))];
+ int t05[T(__is_trivially_copyable(signed char))];
+ int t06[T(__is_trivially_copyable(wchar_t))];
+ int t07[T(__is_trivially_copyable(bool))];
+ int t08[T(__is_trivially_copyable(float))];
+ int t09[T(__is_trivially_copyable(double))];
+ int t10[T(__is_trivially_copyable(long double))];
+ int t11[T(__is_trivially_copyable(unsigned char))];
+ int t12[T(__is_trivially_copyable(unsigned int))];
+ int t13[T(__is_trivially_copyable(unsigned long long))];
+ int t14[T(__is_trivially_copyable(unsigned long))];
+ int t15[T(__is_trivially_copyable(unsigned short))];
+ int t16[T(__is_trivially_copyable(ClassType))];
+ int t17[T(__is_trivially_copyable(Derives))];
+ int t18[T(__is_trivially_copyable(Enum))];
+ int t19[T(__is_trivially_copyable(IntAr))];
+ int t20[T(__is_trivially_copyable(Union))];
+ int t21[T(__is_trivially_copyable(UnionAr))];
+ int t22[T(__is_trivially_copyable(TrivialStruct))];
+ int t23[T(__is_trivially_copyable(NonTrivialStruct))];
+ int t24[T(__is_trivially_copyable(AllDefaulted))];
+ int t25[T(__is_trivially_copyable(AllDeleted))];
+
+ int t30[F(__is_trivially_copyable(void))];
+ int t31[F(__is_trivially_copyable(SuperNonTrivialStruct))];
+ int t32[F(__is_trivially_copyable(NonTCStruct))];
+ int t33[F(__is_trivially_copyable(ExtDefaulted))];
+}
+
+struct CStruct {
+ int one;
+ int two;
+};
+
+struct CEmptyStruct {};
+
+struct CppEmptyStruct : CStruct {};
+struct CppStructStandard : CEmptyStruct {
+ int three;
+ int four;
+};
+struct CppStructNonStandardByBase : CStruct {
+ int three;
+ int four;
+};
+struct CppStructNonStandardByVirt : CStruct {
+ virtual void method() {}
+};
+struct CppStructNonStandardByMemb : CStruct {
+ CppStructNonStandardByVirt member;
+};
+struct CppStructNonStandardByProt : CStruct {
+ int five;
+protected:
+ int six;
+};
+struct CppStructNonStandardByVirtBase : virtual CStruct {
+};
+struct CppStructNonStandardBySameBase : CEmptyStruct {
+ CEmptyStruct member;
+};
+struct CppStructNonStandardBy2ndVirtBase : CEmptyStruct {
+ CEmptyStruct member;
+};
+
+void is_standard_layout()
+{
+ typedef const int ConstInt;
+ typedef ConstInt ConstIntAr[4];
+ typedef CppStructStandard CppStructStandardAr[4];
+
+ int t01[T(__is_standard_layout(int))];
+ int t02[T(__is_standard_layout(ConstInt))];
+ int t03[T(__is_standard_layout(ConstIntAr))];
+ int t04[T(__is_standard_layout(CStruct))];
+ int t05[T(__is_standard_layout(CppStructStandard))];
+ int t06[T(__is_standard_layout(CppStructStandardAr))];
+ int t07[T(__is_standard_layout(Vector))];
+ int t08[T(__is_standard_layout(VectorExt))];
+
+ typedef CppStructNonStandardByBase CppStructNonStandardByBaseAr[4];
+
+ int t10[F(__is_standard_layout(CppStructNonStandardByVirt))];
+ int t11[F(__is_standard_layout(CppStructNonStandardByMemb))];
+ int t12[F(__is_standard_layout(CppStructNonStandardByProt))];
+ int t13[F(__is_standard_layout(CppStructNonStandardByVirtBase))];
+ int t14[F(__is_standard_layout(CppStructNonStandardByBase))];
+ int t15[F(__is_standard_layout(CppStructNonStandardByBaseAr))];
+ int t16[F(__is_standard_layout(CppStructNonStandardBySameBase))];
+ int t17[F(__is_standard_layout(CppStructNonStandardBy2ndVirtBase))];
+}
+
+void is_signed()
+{
+ //int t01[T(__is_signed(char))];
+ int t02[T(__is_signed(int))];
+ int t03[T(__is_signed(long))];
+ int t04[T(__is_signed(short))];
+ int t05[T(__is_signed(signed char))];
+ int t06[T(__is_signed(wchar_t))];
+
+ int t10[F(__is_signed(bool))];
+ int t11[F(__is_signed(cvoid))];
+ int t12[F(__is_signed(float))];
+ int t13[F(__is_signed(double))];
+ int t14[F(__is_signed(long double))];
+ int t15[F(__is_signed(unsigned char))];
+ int t16[F(__is_signed(unsigned int))];
+ int t17[F(__is_signed(unsigned long long))];
+ int t18[F(__is_signed(unsigned long))];
+ int t19[F(__is_signed(unsigned short))];
+ int t20[F(__is_signed(void))];
+ int t21[F(__is_signed(ClassType))];
+ int t22[F(__is_signed(Derives))];
+ int t23[F(__is_signed(Enum))];
+ int t24[F(__is_signed(IntArNB))];
+ int t25[F(__is_signed(Union))];
+ int t26[F(__is_signed(UnionAr))];
+}
+
+void is_unsigned()
+{
+ int t01[T(__is_unsigned(bool))];
+ int t02[T(__is_unsigned(unsigned char))];
+ int t03[T(__is_unsigned(unsigned short))];
+ int t04[T(__is_unsigned(unsigned int))];
+ int t05[T(__is_unsigned(unsigned long))];
+ int t06[T(__is_unsigned(unsigned long long))];
+ int t07[T(__is_unsigned(Enum))];
+
+ int t10[F(__is_unsigned(void))];
+ int t11[F(__is_unsigned(cvoid))];
+ int t12[F(__is_unsigned(float))];
+ int t13[F(__is_unsigned(double))];
+ int t14[F(__is_unsigned(long double))];
+ int t16[F(__is_unsigned(char))];
+ int t17[F(__is_unsigned(signed char))];
+ int t18[F(__is_unsigned(wchar_t))];
+ int t19[F(__is_unsigned(short))];
+ int t20[F(__is_unsigned(int))];
+ int t21[F(__is_unsigned(long))];
+ int t22[F(__is_unsigned(Union))];
+ int t23[F(__is_unsigned(UnionAr))];
+ int t24[F(__is_unsigned(Derives))];
+ int t25[F(__is_unsigned(ClassType))];
+ int t26[F(__is_unsigned(IntArNB))];
+}
+
+typedef Int& IntRef;
+typedef const IntAr ConstIntAr;
+typedef ConstIntAr ConstIntArAr[4];
+
+struct HasCopy {
+ HasCopy(HasCopy& cp);
+};
+
+struct HasMove {
+ HasMove(HasMove&& cp);
+};
+
+struct HasTemplateCons {
+ HasVirt Annoying;
+
+ template <typename T>
+ HasTemplateCons(const T&);
+};
+
+void has_trivial_default_constructor() {
+ { int arr[T(__has_trivial_constructor(Int))]; }
+ { int arr[T(__has_trivial_constructor(IntAr))]; }
+ { int arr[T(__has_trivial_constructor(Union))]; }
+ { int arr[T(__has_trivial_constructor(UnionAr))]; }
+ { int arr[T(__has_trivial_constructor(POD))]; }
+ { int arr[T(__has_trivial_constructor(Derives))]; }
+ { int arr[T(__has_trivial_constructor(DerivesAr))]; }
+ { int arr[T(__has_trivial_constructor(ConstIntAr))]; }
+ { int arr[T(__has_trivial_constructor(ConstIntArAr))]; }
+ { int arr[T(__has_trivial_constructor(HasDest))]; }
+ { int arr[T(__has_trivial_constructor(HasPriv))]; }
+ { int arr[T(__has_trivial_constructor(HasCopyAssign))]; }
+ { int arr[T(__has_trivial_constructor(HasMoveAssign))]; }
+ { int arr[T(__has_trivial_constructor(const Int))]; }
+ { int arr[T(__has_trivial_constructor(AllDefaulted))]; }
+ { int arr[T(__has_trivial_constructor(AllDeleted))]; }
+
+ { int arr[F(__has_trivial_constructor(HasCons))]; }
+ { int arr[F(__has_trivial_constructor(HasRef))]; }
+ { int arr[F(__has_trivial_constructor(HasCopy))]; }
+ { int arr[F(__has_trivial_constructor(IntRef))]; }
+ { int arr[F(__has_trivial_constructor(VirtAr))]; }
+ { int arr[F(__has_trivial_constructor(void))]; }
+ { int arr[F(__has_trivial_constructor(cvoid))]; }
+ { int arr[F(__has_trivial_constructor(HasTemplateCons))]; }
+ { int arr[F(__has_trivial_constructor(AllPrivate))]; }
+ { int arr[F(__has_trivial_constructor(ExtDefaulted))]; }
+}
+
+void has_trivial_copy_constructor() {
+ { int arr[T(__has_trivial_copy(Int))]; }
+ { int arr[T(__has_trivial_copy(IntAr))]; }
+ { int arr[T(__has_trivial_copy(Union))]; }
+ { int arr[T(__has_trivial_copy(UnionAr))]; }
+ { int arr[T(__has_trivial_copy(POD))]; }
+ { int arr[T(__has_trivial_copy(Derives))]; }
+ { int arr[T(__has_trivial_copy(ConstIntAr))]; }
+ { int arr[T(__has_trivial_copy(ConstIntArAr))]; }
+ { int arr[T(__has_trivial_copy(HasDest))]; }
+ { int arr[T(__has_trivial_copy(HasPriv))]; }
+ { int arr[T(__has_trivial_copy(HasCons))]; }
+ { int arr[T(__has_trivial_copy(HasRef))]; }
+ { int arr[T(__has_trivial_copy(HasMove))]; }
+ { int arr[T(__has_trivial_copy(IntRef))]; }
+ { int arr[T(__has_trivial_copy(HasCopyAssign))]; }
+ { int arr[T(__has_trivial_copy(HasMoveAssign))]; }
+ { int arr[T(__has_trivial_copy(const Int))]; }
+ { int arr[T(__has_trivial_copy(AllDefaulted))]; }
+ { int arr[T(__has_trivial_copy(AllDeleted))]; }
+
+ { int arr[F(__has_trivial_copy(HasCopy))]; }
+ { int arr[F(__has_trivial_copy(HasTemplateCons))]; }
+ { int arr[F(__has_trivial_copy(DerivesAr))]; }
+ { int arr[F(__has_trivial_copy(VirtAr))]; }
+ { int arr[F(__has_trivial_copy(void))]; }
+ { int arr[F(__has_trivial_copy(cvoid))]; }
+ { int arr[F(__has_trivial_copy(AllPrivate))]; }
+ { int arr[F(__has_trivial_copy(ExtDefaulted))]; }
+}
+
+void has_trivial_copy_assignment() {
+ { int arr[T(__has_trivial_assign(Int))]; }
+ { int arr[T(__has_trivial_assign(IntAr))]; }
+ { int arr[T(__has_trivial_assign(Union))]; }
+ { int arr[T(__has_trivial_assign(UnionAr))]; }
+ { int arr[T(__has_trivial_assign(POD))]; }
+ { int arr[T(__has_trivial_assign(Derives))]; }
+ { int arr[T(__has_trivial_assign(HasDest))]; }
+ { int arr[T(__has_trivial_assign(HasPriv))]; }
+ { int arr[T(__has_trivial_assign(HasCons))]; }
+ { int arr[T(__has_trivial_assign(HasRef))]; }
+ { int arr[T(__has_trivial_assign(HasCopy))]; }
+ { int arr[T(__has_trivial_assign(HasMove))]; }
+ { int arr[T(__has_trivial_assign(HasMoveAssign))]; }
+ { int arr[T(__has_trivial_assign(AllDefaulted))]; }
+ { int arr[T(__has_trivial_assign(AllDeleted))]; }
+
+ { int arr[F(__has_trivial_assign(IntRef))]; }
+ { int arr[F(__has_trivial_assign(HasCopyAssign))]; }
+ { int arr[F(__has_trivial_assign(const Int))]; }
+ { int arr[F(__has_trivial_assign(ConstIntAr))]; }
+ { int arr[F(__has_trivial_assign(ConstIntArAr))]; }
+ { int arr[F(__has_trivial_assign(DerivesAr))]; }
+ { int arr[F(__has_trivial_assign(VirtAr))]; }
+ { int arr[F(__has_trivial_assign(void))]; }
+ { int arr[F(__has_trivial_assign(cvoid))]; }
+ { int arr[F(__has_trivial_assign(AllPrivate))]; }
+ { int arr[F(__has_trivial_assign(ExtDefaulted))]; }
+}
+
+void has_trivial_destructor() {
+ { int arr[T(__has_trivial_destructor(Int))]; }
+ { int arr[T(__has_trivial_destructor(IntAr))]; }
+ { int arr[T(__has_trivial_destructor(Union))]; }
+ { int arr[T(__has_trivial_destructor(UnionAr))]; }
+ { int arr[T(__has_trivial_destructor(POD))]; }
+ { int arr[T(__has_trivial_destructor(Derives))]; }
+ { int arr[T(__has_trivial_destructor(ConstIntAr))]; }
+ { int arr[T(__has_trivial_destructor(ConstIntArAr))]; }
+ { int arr[T(__has_trivial_destructor(HasPriv))]; }
+ { int arr[T(__has_trivial_destructor(HasCons))]; }
+ { int arr[T(__has_trivial_destructor(HasRef))]; }
+ { int arr[T(__has_trivial_destructor(HasCopy))]; }
+ { int arr[T(__has_trivial_destructor(HasMove))]; }
+ { int arr[T(__has_trivial_destructor(IntRef))]; }
+ { int arr[T(__has_trivial_destructor(HasCopyAssign))]; }
+ { int arr[T(__has_trivial_destructor(HasMoveAssign))]; }
+ { int arr[T(__has_trivial_destructor(const Int))]; }
+ { int arr[T(__has_trivial_destructor(DerivesAr))]; }
+ { int arr[T(__has_trivial_destructor(VirtAr))]; }
+ { int arr[T(__has_trivial_destructor(AllDefaulted))]; }
+ { int arr[T(__has_trivial_destructor(AllDeleted))]; }
+
+ { int arr[F(__has_trivial_destructor(HasDest))]; }
+ { int arr[F(__has_trivial_destructor(void))]; }
+ { int arr[F(__has_trivial_destructor(cvoid))]; }
+ { int arr[F(__has_trivial_destructor(AllPrivate))]; }
+ { int arr[F(__has_trivial_destructor(ExtDefaulted))]; }
+}
+
+struct A { ~A() {} };
+template<typename> struct B : A { };
+
+void f() {
+ { int arr[F(__has_trivial_destructor(A))]; }
+ { int arr[F(__has_trivial_destructor(B<int>))]; }
+}
+
+class PR11110 {
+ template <int> int operator=( int );
+ int operator=(PR11110);
+};
+
+class UsingAssign;
+
+class UsingAssignBase {
+protected:
+ UsingAssign &operator=(const UsingAssign&) throw();
+};
+
+class UsingAssign : public UsingAssignBase {
+public:
+ using UsingAssignBase::operator=;
+};
+
+void has_nothrow_assign() {
+ { int arr[T(__has_nothrow_assign(Int))]; }
+ { int arr[T(__has_nothrow_assign(IntAr))]; }
+ { int arr[T(__has_nothrow_assign(Union))]; }
+ { int arr[T(__has_nothrow_assign(UnionAr))]; }
+ { int arr[T(__has_nothrow_assign(POD))]; }
+ { int arr[T(__has_nothrow_assign(Derives))]; }
+ { int arr[T(__has_nothrow_assign(HasDest))]; }
+ { int arr[T(__has_nothrow_assign(HasPriv))]; }
+ { int arr[T(__has_nothrow_assign(HasCons))]; }
+ { int arr[T(__has_nothrow_assign(HasRef))]; }
+ { int arr[T(__has_nothrow_assign(HasCopy))]; }
+ { int arr[T(__has_nothrow_assign(HasMove))]; }
+ { int arr[T(__has_nothrow_assign(HasMoveAssign))]; }
+ { int arr[T(__has_nothrow_assign(HasNoThrowCopyAssign))]; }
+ { int arr[T(__has_nothrow_assign(HasMultipleNoThrowCopyAssign))]; }
+ { int arr[T(__has_nothrow_assign(HasVirtDest))]; }
+ { int arr[T(__has_nothrow_assign(AllPrivate))]; }
+ { int arr[T(__has_nothrow_assign(UsingAssign))]; }
+
+ { int arr[F(__has_nothrow_assign(IntRef))]; }
+ { int arr[F(__has_nothrow_assign(HasCopyAssign))]; }
+ { int arr[F(__has_nothrow_assign(HasMultipleCopyAssign))]; }
+ { int arr[F(__has_nothrow_assign(const Int))]; }
+ { int arr[F(__has_nothrow_assign(ConstIntAr))]; }
+ { int arr[F(__has_nothrow_assign(ConstIntArAr))]; }
+ { int arr[F(__has_nothrow_assign(DerivesAr))]; }
+ { int arr[F(__has_nothrow_assign(VirtAr))]; }
+ { int arr[F(__has_nothrow_assign(void))]; }
+ { int arr[F(__has_nothrow_assign(cvoid))]; }
+ { int arr[F(__has_nothrow_assign(PR11110))]; }
+}
+
+void has_nothrow_copy() {
+ { int arr[T(__has_nothrow_copy(Int))]; }
+ { int arr[T(__has_nothrow_copy(IntAr))]; }
+ { int arr[T(__has_nothrow_copy(Union))]; }
+ { int arr[T(__has_nothrow_copy(UnionAr))]; }
+ { int arr[T(__has_nothrow_copy(POD))]; }
+ { int arr[T(__has_nothrow_copy(const Int))]; }
+ { int arr[T(__has_nothrow_copy(ConstIntAr))]; }
+ { int arr[T(__has_nothrow_copy(ConstIntArAr))]; }
+ { int arr[T(__has_nothrow_copy(Derives))]; }
+ { int arr[T(__has_nothrow_copy(IntRef))]; }
+ { int arr[T(__has_nothrow_copy(HasDest))]; }
+ { int arr[T(__has_nothrow_copy(HasPriv))]; }
+ { int arr[T(__has_nothrow_copy(HasCons))]; }
+ { int arr[T(__has_nothrow_copy(HasRef))]; }
+ { int arr[T(__has_nothrow_copy(HasMove))]; }
+ { int arr[T(__has_nothrow_copy(HasCopyAssign))]; }
+ { int arr[T(__has_nothrow_copy(HasMoveAssign))]; }
+ { int arr[T(__has_nothrow_copy(HasNoThrowCopy))]; }
+ { int arr[T(__has_nothrow_copy(HasMultipleNoThrowCopy))]; }
+ { int arr[T(__has_nothrow_copy(HasVirtDest))]; }
+ { int arr[T(__has_nothrow_copy(HasTemplateCons))]; }
+ { int arr[T(__has_nothrow_copy(AllPrivate))]; }
+
+ { int arr[F(__has_nothrow_copy(HasCopy))]; }
+ { int arr[F(__has_nothrow_copy(HasMultipleCopy))]; }
+ { int arr[F(__has_nothrow_copy(DerivesAr))]; }
+ { int arr[F(__has_nothrow_copy(VirtAr))]; }
+ { int arr[F(__has_nothrow_copy(void))]; }
+ { int arr[F(__has_nothrow_copy(cvoid))]; }
+}
+
+template<bool b> struct assert_expr;
+template<> struct assert_expr<true> {};
+
+void has_nothrow_constructor() {
+ { int arr[T(__has_nothrow_constructor(Int))]; }
+ { int arr[T(__has_nothrow_constructor(IntAr))]; }
+ { int arr[T(__has_nothrow_constructor(Union))]; }
+ { int arr[T(__has_nothrow_constructor(UnionAr))]; }
+ { int arr[T(__has_nothrow_constructor(POD))]; }
+ { int arr[T(__has_nothrow_constructor(Derives))]; }
+ { int arr[T(__has_nothrow_constructor(DerivesAr))]; }
+ { int arr[T(__has_nothrow_constructor(ConstIntAr))]; }
+ { int arr[T(__has_nothrow_constructor(ConstIntArAr))]; }
+ { int arr[T(__has_nothrow_constructor(HasDest))]; }
+ { int arr[T(__has_nothrow_constructor(HasPriv))]; }
+ { int arr[T(__has_nothrow_constructor(HasCopyAssign))]; }
+ { int arr[T(__has_nothrow_constructor(const Int))]; }
+ { int arr[T(__has_nothrow_constructor(HasNoThrowConstructor))]; }
+ { int arr[T(__has_nothrow_constructor(HasVirtDest))]; }
+ // { int arr[T(__has_nothrow_constructor(VirtAr))]; } // not implemented
+ { int arr[T(__has_nothrow_constructor(AllPrivate))]; }
+
+ { int arr[F(__has_nothrow_constructor(HasCons))]; }
+ { int arr[F(__has_nothrow_constructor(HasRef))]; }
+ { int arr[F(__has_nothrow_constructor(HasCopy))]; }
+ { int arr[F(__has_nothrow_constructor(HasMove))]; }
+ { int arr[F(__has_nothrow_constructor(HasNoThrowConstructorWithArgs))]; }
+ { int arr[F(__has_nothrow_constructor(IntRef))]; }
+ { int arr[F(__has_nothrow_constructor(void))]; }
+ { int arr[F(__has_nothrow_constructor(cvoid))]; }
+ { int arr[F(__has_nothrow_constructor(HasTemplateCons))]; }
+
+ // While parsing an in-class initializer, the constructor is not known to be
+ // non-throwing yet.
+ struct HasInClassInit { int n = (assert_expr<!__has_nothrow_constructor(HasInClassInit)>(), 0); };
+ { int arr[T(__has_nothrow_constructor(HasInClassInit))]; }
+}
+
+void has_virtual_destructor() {
+ { int arr[F(__has_virtual_destructor(Int))]; }
+ { int arr[F(__has_virtual_destructor(IntAr))]; }
+ { int arr[F(__has_virtual_destructor(Union))]; }
+ { int arr[F(__has_virtual_destructor(UnionAr))]; }
+ { int arr[F(__has_virtual_destructor(POD))]; }
+ { int arr[F(__has_virtual_destructor(Derives))]; }
+ { int arr[F(__has_virtual_destructor(DerivesAr))]; }
+ { int arr[F(__has_virtual_destructor(const Int))]; }
+ { int arr[F(__has_virtual_destructor(ConstIntAr))]; }
+ { int arr[F(__has_virtual_destructor(ConstIntArAr))]; }
+ { int arr[F(__has_virtual_destructor(HasDest))]; }
+ { int arr[F(__has_virtual_destructor(HasPriv))]; }
+ { int arr[F(__has_virtual_destructor(HasCons))]; }
+ { int arr[F(__has_virtual_destructor(HasRef))]; }
+ { int arr[F(__has_virtual_destructor(HasCopy))]; }
+ { int arr[F(__has_virtual_destructor(HasMove))]; }
+ { int arr[F(__has_virtual_destructor(HasCopyAssign))]; }
+ { int arr[F(__has_virtual_destructor(HasMoveAssign))]; }
+ { int arr[F(__has_virtual_destructor(IntRef))]; }
+ { int arr[F(__has_virtual_destructor(VirtAr))]; }
+
+ { int arr[T(__has_virtual_destructor(HasVirtDest))]; }
+ { int arr[T(__has_virtual_destructor(DerivedVirtDest))]; }
+ { int arr[F(__has_virtual_destructor(VirtDestAr))]; }
+ { int arr[F(__has_virtual_destructor(void))]; }
+ { int arr[F(__has_virtual_destructor(cvoid))]; }
+ { int arr[F(__has_virtual_destructor(AllPrivate))]; }
+}
+
+
+class Base {};
+class Derived : Base {};
+class Derived2a : Derived {};
+class Derived2b : Derived {};
+class Derived3 : virtual Derived2a, virtual Derived2b {};
+template<typename T> struct BaseA { T a; };
+template<typename T> struct DerivedB : BaseA<T> { };
+template<typename T> struct CrazyDerived : T { };
+
+
+class class_forward; // expected-note {{forward declaration of 'class_forward'}}
+
+template <typename Base, typename Derived>
+void isBaseOfT() {
+ int t[T(__is_base_of(Base, Derived))];
+};
+template <typename Base, typename Derived>
+void isBaseOfF() {
+ int t[F(__is_base_of(Base, Derived))];
+};
+
+template <class T> class DerivedTemp : Base {};
+template <class T> class NonderivedTemp {};
+template <class T> class UndefinedTemp; // expected-note {{declared here}}
+
+void is_base_of() {
+ { int arr[T(__is_base_of(Base, Derived))]; }
+ { int arr[T(__is_base_of(const Base, Derived))]; }
+ { int arr[F(__is_base_of(Derived, Base))]; }
+ { int arr[F(__is_base_of(Derived, int))]; }
+ { int arr[T(__is_base_of(Base, Base))]; }
+ { int arr[T(__is_base_of(Base, Derived3))]; }
+ { int arr[T(__is_base_of(Derived, Derived3))]; }
+ { int arr[T(__is_base_of(Derived2b, Derived3))]; }
+ { int arr[T(__is_base_of(Derived2a, Derived3))]; }
+ { int arr[T(__is_base_of(BaseA<int>, DerivedB<int>))]; }
+ { int arr[F(__is_base_of(DerivedB<int>, BaseA<int>))]; }
+ { int arr[T(__is_base_of(Base, CrazyDerived<Base>))]; }
+ { int arr[F(__is_base_of(Union, Union))]; }
+ { int arr[T(__is_base_of(Empty, Empty))]; }
+ { int arr[T(__is_base_of(class_forward, class_forward))]; }
+ { int arr[F(__is_base_of(Empty, class_forward))]; } // expected-error {{incomplete type 'class_forward' used in type trait expression}}
+ { int arr[F(__is_base_of(Base&, Derived&))]; }
+ int t18[F(__is_base_of(Base[10], Derived[10]))];
+ { int arr[F(__is_base_of(int, int))]; }
+ { int arr[F(__is_base_of(long, int))]; }
+ { int arr[T(__is_base_of(Base, DerivedTemp<int>))]; }
+ { int arr[F(__is_base_of(Base, NonderivedTemp<int>))]; }
+ { int arr[F(__is_base_of(Base, UndefinedTemp<int>))]; } // expected-error {{implicit instantiation of undefined template 'UndefinedTemp<int>'}}
+
+ isBaseOfT<Base, Derived>();
+ isBaseOfF<Derived, Base>();
+
+ isBaseOfT<Base, CrazyDerived<Base> >();
+ isBaseOfF<CrazyDerived<Base>, Base>();
+
+ isBaseOfT<BaseA<int>, DerivedB<int> >();
+ isBaseOfF<DerivedB<int>, BaseA<int> >();
+}
+
+template<class T, class U>
+class TemplateClass {};
+
+template<class T>
+using TemplateAlias = TemplateClass<T, int>;
+
+typedef class Base BaseTypedef;
+
+void is_same()
+{
+ int t01[T(__is_same(Base, Base))];
+ int t02[T(__is_same(Base, BaseTypedef))];
+ int t03[T(__is_same(TemplateClass<int, int>, TemplateAlias<int>))];
+
+ int t10[F(__is_same(Base, const Base))];
+ int t11[F(__is_same(Base, Base&))];
+ int t12[F(__is_same(Base, Derived))];
+}
+
+struct IntWrapper
+{
+ int value;
+ IntWrapper(int _value) : value(_value) {}
+ operator int() const {
+ return value;
+ }
+};
+
+struct FloatWrapper
+{
+ float value;
+ FloatWrapper(float _value) : value(_value) {}
+ FloatWrapper(const IntWrapper& obj)
+ : value(static_cast<float>(obj.value)) {}
+ operator float() const {
+ return value;
+ }
+ operator IntWrapper() const {
+ return IntWrapper(static_cast<int>(value));
+ }
+};
+
+void is_convertible()
+{
+ int t01[T(__is_convertible(IntWrapper, IntWrapper))];
+ int t02[T(__is_convertible(IntWrapper, const IntWrapper))];
+ int t03[T(__is_convertible(IntWrapper, int))];
+ int t04[T(__is_convertible(int, IntWrapper))];
+ int t05[T(__is_convertible(IntWrapper, FloatWrapper))];
+ int t06[T(__is_convertible(FloatWrapper, IntWrapper))];
+ int t07[T(__is_convertible(FloatWrapper, float))];
+ int t08[T(__is_convertible(float, FloatWrapper))];
+}
+
+struct FromInt { FromInt(int); };
+struct ToInt { operator int(); };
+typedef void Function();
+
+void is_convertible_to();
+class PrivateCopy {
+ PrivateCopy(const PrivateCopy&);
+ friend void is_convertible_to();
+};
+
+template<typename T>
+struct X0 {
+ template<typename U> X0(const X0<U>&);
+};
+
+void is_convertible_to() {
+ { int arr[T(__is_convertible_to(Int, Int))]; }
+ { int arr[F(__is_convertible_to(Int, IntAr))]; }
+ { int arr[F(__is_convertible_to(IntAr, IntAr))]; }
+ { int arr[T(__is_convertible_to(void, void))]; }
+ { int arr[T(__is_convertible_to(cvoid, void))]; }
+ { int arr[T(__is_convertible_to(void, cvoid))]; }
+ { int arr[T(__is_convertible_to(cvoid, cvoid))]; }
+ { int arr[T(__is_convertible_to(int, FromInt))]; }
+ { int arr[T(__is_convertible_to(long, FromInt))]; }
+ { int arr[T(__is_convertible_to(double, FromInt))]; }
+ { int arr[T(__is_convertible_to(const int, FromInt))]; }
+ { int arr[T(__is_convertible_to(const int&, FromInt))]; }
+ { int arr[T(__is_convertible_to(ToInt, int))]; }
+ { int arr[T(__is_convertible_to(ToInt, const int&))]; }
+ { int arr[T(__is_convertible_to(ToInt, long))]; }
+ { int arr[F(__is_convertible_to(ToInt, int&))]; }
+ { int arr[F(__is_convertible_to(ToInt, FromInt))]; }
+ { int arr[T(__is_convertible_to(IntAr&, IntAr&))]; }
+ { int arr[T(__is_convertible_to(IntAr&, const IntAr&))]; }
+ { int arr[F(__is_convertible_to(const IntAr&, IntAr&))]; }
+ { int arr[F(__is_convertible_to(Function, Function))]; }
+ { int arr[F(__is_convertible_to(PrivateCopy, PrivateCopy))]; }
+ { int arr[T(__is_convertible_to(X0<int>, X0<float>))]; }
+}
+
+namespace is_convertible_to_instantiate {
+ // Make sure we don't try to instantiate the constructor.
+ template<int x> class A { A(int) { int a[x]; } };
+ int x = __is_convertible_to(int, A<-1>);
+}
+
+void is_trivial()
+{
+ { int arr[T(__is_trivial(int))]; }
+ { int arr[T(__is_trivial(Enum))]; }
+ { int arr[T(__is_trivial(POD))]; }
+ { int arr[T(__is_trivial(Int))]; }
+ { int arr[T(__is_trivial(IntAr))]; }
+ { int arr[T(__is_trivial(IntArNB))]; }
+ { int arr[T(__is_trivial(Statics))]; }
+ { int arr[T(__is_trivial(Empty))]; }
+ { int arr[T(__is_trivial(EmptyUnion))]; }
+ { int arr[T(__is_trivial(Union))]; }
+ { int arr[T(__is_trivial(Derives))]; }
+ { int arr[T(__is_trivial(DerivesAr))]; }
+ { int arr[T(__is_trivial(DerivesArNB))]; }
+ { int arr[T(__is_trivial(DerivesEmpty))]; }
+ { int arr[T(__is_trivial(HasFunc))]; }
+ { int arr[T(__is_trivial(HasOp))]; }
+ { int arr[T(__is_trivial(HasConv))]; }
+ { int arr[T(__is_trivial(HasAssign))]; }
+ { int arr[T(__is_trivial(HasAnonymousUnion))]; }
+ { int arr[T(__is_trivial(HasPriv))]; }
+ { int arr[T(__is_trivial(HasProt))]; }
+ { int arr[T(__is_trivial(DerivesHasPriv))]; }
+ { int arr[T(__is_trivial(DerivesHasProt))]; }
+ { int arr[T(__is_trivial(Vector))]; }
+ { int arr[T(__is_trivial(VectorExt))]; }
+
+ { int arr[F(__is_trivial(HasCons))]; }
+ { int arr[F(__is_trivial(HasCopyAssign))]; }
+ { int arr[F(__is_trivial(HasMoveAssign))]; }
+ { int arr[F(__is_trivial(HasDest))]; }
+ { int arr[F(__is_trivial(HasRef))]; }
+ { int arr[F(__is_trivial(HasNonPOD))]; }
+ { int arr[F(__is_trivial(HasVirt))]; }
+ { int arr[F(__is_trivial(DerivesHasCons))]; }
+ { int arr[F(__is_trivial(DerivesHasCopyAssign))]; }
+ { int arr[F(__is_trivial(DerivesHasMoveAssign))]; }
+ { int arr[F(__is_trivial(DerivesHasDest))]; }
+ { int arr[F(__is_trivial(DerivesHasRef))]; }
+ { int arr[F(__is_trivial(DerivesHasVirt))]; }
+ { int arr[F(__is_trivial(void))]; }
+ { int arr[F(__is_trivial(cvoid))]; }
+}
+
+void trivial_checks()
+{
+ { int arr[T(__is_trivially_copyable(int))]; }
+ { int arr[T(__is_trivially_copyable(Enum))]; }
+ { int arr[T(__is_trivially_copyable(POD))]; }
+ { int arr[T(__is_trivially_copyable(Int))]; }
+ { int arr[T(__is_trivially_copyable(IntAr))]; }
+ { int arr[T(__is_trivially_copyable(IntArNB))]; }
+ { int arr[T(__is_trivially_copyable(Statics))]; }
+ { int arr[T(__is_trivially_copyable(Empty))]; }
+ { int arr[T(__is_trivially_copyable(EmptyUnion))]; }
+ { int arr[T(__is_trivially_copyable(Union))]; }
+ { int arr[T(__is_trivially_copyable(Derives))]; }
+ { int arr[T(__is_trivially_copyable(DerivesAr))]; }
+ { int arr[T(__is_trivially_copyable(DerivesArNB))]; }
+ { int arr[T(__is_trivially_copyable(DerivesEmpty))]; }
+ { int arr[T(__is_trivially_copyable(HasFunc))]; }
+ { int arr[T(__is_trivially_copyable(HasOp))]; }
+ { int arr[T(__is_trivially_copyable(HasConv))]; }
+ { int arr[T(__is_trivially_copyable(HasAssign))]; }
+ { int arr[T(__is_trivially_copyable(HasAnonymousUnion))]; }
+ { int arr[T(__is_trivially_copyable(HasPriv))]; }
+ { int arr[T(__is_trivially_copyable(HasProt))]; }
+ { int arr[T(__is_trivially_copyable(DerivesHasPriv))]; }
+ { int arr[T(__is_trivially_copyable(DerivesHasProt))]; }
+ { int arr[T(__is_trivially_copyable(Vector))]; }
+ { int arr[T(__is_trivially_copyable(VectorExt))]; }
+ { int arr[T(__is_trivially_copyable(HasCons))]; }
+ { int arr[T(__is_trivially_copyable(HasRef))]; }
+ { int arr[T(__is_trivially_copyable(HasNonPOD))]; }
+ { int arr[T(__is_trivially_copyable(DerivesHasCons))]; }
+ { int arr[T(__is_trivially_copyable(DerivesHasRef))]; }
+
+ { int arr[F(__is_trivially_copyable(HasCopyAssign))]; }
+ { int arr[F(__is_trivially_copyable(HasMoveAssign))]; }
+ { int arr[F(__is_trivially_copyable(HasDest))]; }
+ { int arr[F(__is_trivially_copyable(HasVirt))]; }
+ { int arr[F(__is_trivially_copyable(DerivesHasCopyAssign))]; }
+ { int arr[F(__is_trivially_copyable(DerivesHasMoveAssign))]; }
+ { int arr[F(__is_trivially_copyable(DerivesHasDest))]; }
+ { int arr[F(__is_trivially_copyable(DerivesHasVirt))]; }
+ { int arr[F(__is_trivially_copyable(void))]; }
+ { int arr[F(__is_trivially_copyable(cvoid))]; }
+
+ { int arr[T((__is_trivially_constructible(int)))]; }
+ { int arr[T((__is_trivially_constructible(int, int)))]; }
+ { int arr[T((__is_trivially_constructible(int, float)))]; }
+ { int arr[T((__is_trivially_constructible(int, int&)))]; }
+ { int arr[T((__is_trivially_constructible(int, const int&)))]; }
+ { int arr[T((__is_trivially_constructible(int, int)))]; }
+ { int arr[T((__is_trivially_constructible(HasCopyAssign, HasCopyAssign)))]; }
+ { int arr[T((__is_trivially_constructible(HasCopyAssign, const HasCopyAssign&)))]; }
+ { int arr[T((__is_trivially_constructible(HasCopyAssign, HasCopyAssign&&)))]; }
+ { int arr[T((__is_trivially_constructible(HasCopyAssign)))]; }
+ { int arr[T((__is_trivially_constructible(NonTrivialDefault,
+ const NonTrivialDefault&)))]; }
+ { int arr[T((__is_trivially_constructible(NonTrivialDefault,
+ NonTrivialDefault&&)))]; }
+ { int arr[T((__is_trivially_constructible(AllDefaulted)))]; }
+ { int arr[T((__is_trivially_constructible(AllDefaulted,
+ const AllDefaulted &)))]; }
+ { int arr[T((__is_trivially_constructible(AllDefaulted,
+ AllDefaulted &&)))]; }
+
+ { int arr[F((__is_trivially_constructible(int, int*)))]; }
+ { int arr[F((__is_trivially_constructible(NonTrivialDefault)))]; }
+ { int arr[F((__is_trivially_constructible(ThreeArgCtor, int*, char*, int&)))]; }
+ { int arr[F((__is_trivially_constructible(AllDeleted)))]; }
+ { int arr[F((__is_trivially_constructible(AllDeleted,
+ const AllDeleted &)))]; }
+ { int arr[F((__is_trivially_constructible(AllDeleted,
+ AllDeleted &&)))]; }
+ { int arr[F((__is_trivially_constructible(ExtDefaulted)))]; }
+ { int arr[F((__is_trivially_constructible(ExtDefaulted,
+ const ExtDefaulted &)))]; }
+ { int arr[F((__is_trivially_constructible(ExtDefaulted,
+ ExtDefaulted &&)))]; }
+
+ { int arr[T((__is_trivially_assignable(int&, int)))]; }
+ { int arr[T((__is_trivially_assignable(int&, int&)))]; }
+ { int arr[T((__is_trivially_assignable(int&, int&&)))]; }
+ { int arr[T((__is_trivially_assignable(int&, const int&)))]; }
+ { int arr[T((__is_trivially_assignable(POD&, POD)))]; }
+ { int arr[T((__is_trivially_assignable(POD&, POD&)))]; }
+ { int arr[T((__is_trivially_assignable(POD&, POD&&)))]; }
+ { int arr[T((__is_trivially_assignable(POD&, const POD&)))]; }
+ { int arr[T((__is_trivially_assignable(int*&, int*)))]; }
+ { int arr[T((__is_trivially_assignable(AllDefaulted,
+ const AllDefaulted &)))]; }
+ { int arr[T((__is_trivially_assignable(AllDefaulted,
+ AllDefaulted &&)))]; }
+
+ { int arr[F((__is_trivially_assignable(int*&, float*)))]; }
+ { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign)))]; }
+ { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign&)))]; }
+ { int arr[F((__is_trivially_assignable(HasCopyAssign&, const HasCopyAssign&)))]; }
+ { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign&&)))]; }
+ { int arr[F((__is_trivially_assignable(TrivialMoveButNotCopy&,
+ TrivialMoveButNotCopy&)))]; }
+ { int arr[F((__is_trivially_assignable(TrivialMoveButNotCopy&,
+ const TrivialMoveButNotCopy&)))]; }
+ { int arr[F((__is_trivially_assignable(AllDeleted,
+ const AllDeleted &)))]; }
+ { int arr[F((__is_trivially_assignable(AllDeleted,
+ AllDeleted &&)))]; }
+ { int arr[F((__is_trivially_assignable(ExtDefaulted,
+ const ExtDefaulted &)))]; }
+ { int arr[F((__is_trivially_assignable(ExtDefaulted,
+ ExtDefaulted &&)))]; }
+
+ { int arr[T((__is_trivially_assignable(HasDefaultTrivialCopyAssign&,
+ HasDefaultTrivialCopyAssign&)))]; }
+ { int arr[T((__is_trivially_assignable(HasDefaultTrivialCopyAssign&,
+ const HasDefaultTrivialCopyAssign&)))]; }
+ { int arr[T((__is_trivially_assignable(TrivialMoveButNotCopy&,
+ TrivialMoveButNotCopy)))]; }
+ { int arr[T((__is_trivially_assignable(TrivialMoveButNotCopy&,
+ TrivialMoveButNotCopy&&)))]; }
+}
+
+// Instantiation of __is_trivially_constructible
+template<typename T, typename ...Args>
+struct is_trivially_constructible {
+ static const bool value = __is_trivially_constructible(T, Args...);
+};
+
+void is_trivially_constructible_test() {
+ { int arr[T((is_trivially_constructible<int>::value))]; }
+ { int arr[T((is_trivially_constructible<int, int>::value))]; }
+ { int arr[T((is_trivially_constructible<int, float>::value))]; }
+ { int arr[T((is_trivially_constructible<int, int&>::value))]; }
+ { int arr[T((is_trivially_constructible<int, const int&>::value))]; }
+ { int arr[T((is_trivially_constructible<int, int>::value))]; }
+ { int arr[T((is_trivially_constructible<HasCopyAssign, HasCopyAssign>::value))]; }
+ { int arr[T((is_trivially_constructible<HasCopyAssign, const HasCopyAssign&>::value))]; }
+ { int arr[T((is_trivially_constructible<HasCopyAssign, HasCopyAssign&&>::value))]; }
+ { int arr[T((is_trivially_constructible<HasCopyAssign>::value))]; }
+ { int arr[T((is_trivially_constructible<NonTrivialDefault,
+ const NonTrivialDefault&>::value))]; }
+ { int arr[T((is_trivially_constructible<NonTrivialDefault,
+ NonTrivialDefault&&>::value))]; }
+
+ { int arr[F((is_trivially_constructible<int, int*>::value))]; }
+ { int arr[F((is_trivially_constructible<NonTrivialDefault>::value))]; }
+ { int arr[F((is_trivially_constructible<ThreeArgCtor, int*, char*, int&>::value))]; }
+}
+
+void array_rank() {
+ int t01[T(__array_rank(IntAr) == 1)];
+ int t02[T(__array_rank(ConstIntArAr) == 2)];
+}
+
+void array_extent() {
+ int t01[T(__array_extent(IntAr, 0) == 10)];
+ int t02[T(__array_extent(ConstIntArAr, 0) == 4)];
+ int t03[T(__array_extent(ConstIntArAr, 1) == 10)];
+}
diff --git a/clang/test/SemaCXX/typedef-redecl.cpp b/clang/test/SemaCXX/typedef-redecl.cpp
new file mode 100644
index 0000000..b53bcd2
--- /dev/null
+++ b/clang/test/SemaCXX/typedef-redecl.cpp
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+typedef int INT;
+typedef INT REALLY_INT; // expected-note {{previous definition is here}}
+typedef REALLY_INT REALLY_REALLY_INT;
+typedef REALLY_INT BOB;
+typedef float REALLY_INT; // expected-error{{typedef redefinition with different types ('float' vs 'INT' (aka 'int'))}}
+
+struct X {
+ typedef int result_type; // expected-note {{previous definition is here}}
+ typedef INT result_type; // expected-error {{redefinition of 'result_type'}}
+};
+
+struct Y; // expected-note{{previous definition is here}}
+typedef int Y; // expected-error{{typedef redefinition with different types ('int' vs 'Y')}}
+
+typedef int Y2; // expected-note{{declared here}}
+struct Y2; // expected-error{{definition of type 'Y2' conflicts with typedef of the same name}}
+
+void f(); // expected-note{{previous definition is here}}
+typedef int f; // expected-error{{redefinition of 'f' as different kind of symbol}}
+
+typedef int f2; // expected-note{{previous definition is here}}
+void f2(); // expected-error{{redefinition of 'f2' as different kind of symbol}}
+
+typedef struct s s;
+typedef int I;
+typedef int I;
+typedef I I;
+
+struct s { };
+
+// PR5874
+namespace test1 {
+ typedef int foo;
+ namespace a { using test1::foo; };
+ typedef int foo;
+ using namespace a;
+ foo x;
+}
+
+namespace PR6923 {
+ struct A;
+
+ extern "C" {
+ struct A;
+ typedef struct A A;
+ }
+
+ struct A;
+}
+
+namespace PR7462 {
+ struct A {};
+ typedef int operator! (A); // expected-error{{typedef name must be an identifier}}
+ int i = !A(); // expected-error{{invalid argument type}}
+}
+
+template<typename T>
+typedef T f(T t) { return t; } // expected-error {{function definition declared 'typedef'}}
+int k = f(0);
+int k2 = k;
+
+namespace PR11630 {
+ template <class T>
+ struct S
+ {
+ static const unsigned C = 1;
+ static void f()
+ {
+ typedef int q[C == 1 ? 1 : -1]; // expected-note{{previous definition is here}}
+ typedef int q[C >= 1 ? 2 : -2]; // expected-error{{typedef redefinition with different types ('int [2]' vs 'int [1]')}}
+ typedef int n[C == 1 ? 1 : -1];
+ typedef int n[C >= 1 ? 1 : -1];
+ }
+ };
+
+ template <int T>
+ struct S2
+ {
+ static void f()
+ {
+ typedef int q[1]; // expected-note{{previous definition is here}}
+ typedef int q[T]; // expected-error{{typedef redefinition with different types ('int [2]' vs 'int [1]')}}
+ }
+ };
+
+ void f() {
+ S<int> a;
+ a.f(); // expected-note{{in instantiation of member function 'PR11630::S<int>::f' requested here}}
+ S2<1> b;
+ b.f();
+ S2<2> b2;
+ b2.f(); // expected-note{{in instantiation of member function 'PR11630::S2<2>::f' requested here}}
+ }
+}
diff --git a/clang/test/SemaCXX/typeid-ref.cpp b/clang/test/SemaCXX/typeid-ref.cpp
new file mode 100644
index 0000000..d01fd31
--- /dev/null
+++ b/clang/test/SemaCXX/typeid-ref.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+namespace std {
+ class type_info;
+}
+
+struct X { };
+
+void f() {
+ // CHECK: @_ZTS1X = linkonce_odr constant
+ // CHECK: @_ZTI1X = linkonce_odr unnamed_addr constant
+ (void)typeid(X&);
+}
diff --git a/clang/test/SemaCXX/typeid.cpp b/clang/test/SemaCXX/typeid.cpp
new file mode 100644
index 0000000..d3a2a28
--- /dev/null
+++ b/clang/test/SemaCXX/typeid.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f()
+{
+ (void)typeid(int); // expected-error {{you need to include <typeinfo> before using the 'typeid' operator}}
+}
+
+namespace std {
+ class type_info;
+}
+
+void g()
+{
+ (void)typeid(int);
+}
+
+struct X; // expected-note 3{{forward declaration}}
+
+void g1(X &x) {
+ (void)typeid(X); // expected-error{{'typeid' of incomplete type 'X'}}
+ (void)typeid(X&); // expected-error{{'typeid' of incomplete type 'X'}}
+ (void)typeid(x); // expected-error{{'typeid' of incomplete type 'X'}}
+}
diff --git a/clang/test/SemaCXX/types_compatible_p.cpp b/clang/test/SemaCXX/types_compatible_p.cpp
new file mode 100644
index 0000000..4aa9a1c
--- /dev/null
+++ b/clang/test/SemaCXX/types_compatible_p.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+bool f() {
+ return __builtin_types_compatible_p(int, const int); // expected-error{{C++}}
+}
diff --git a/clang/test/SemaCXX/typo-correction.cpp b/clang/test/SemaCXX/typo-correction.cpp
new file mode 100644
index 0000000..b1e8d91
--- /dev/null
+++ b/clang/test/SemaCXX/typo-correction.cpp
@@ -0,0 +1,192 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions %s
+
+struct errc {
+ int v_;
+ operator int() const {return v_;}
+};
+
+class error_condition
+{
+ int _val_;
+public:
+ error_condition() : _val_(0) {}
+
+ error_condition(int _val)
+ : _val_(_val) {}
+
+ template <class E>
+ error_condition(E _e) {
+ // make_error_condition must not be typo corrected to error_condition
+ // even though the first declaration of make_error_condition has not
+ // yet been encountered. This was a bug in the first version of the type
+ // name typo correction patch that wasn't noticed until building LLVM with
+ // Clang failed.
+ *this = make_error_condition(_e);
+ }
+
+};
+
+inline error_condition make_error_condition(errc _e) {
+ return error_condition(static_cast<int>(_e));
+}
+
+
+// Prior to the introduction of a callback object to further filter possible
+// typo corrections, this example would not trigger a suggestion as "base_type"
+// is a closer match to "basetype" than is "BaseType" but "base_type" does not
+// refer to a base class or non-static data member.
+struct BaseType { };
+struct Derived : public BaseType { // expected-note {{base class 'BaseType' specified here}}
+ static int base_type; // expected-note {{'base_type' declared here}}
+ Derived() : basetype() {} // expected-error{{initializer 'basetype' does not name a non-static data member or base class; did you mean the base class 'BaseType'?}}
+};
+
+// Test the improvement from passing a callback object to CorrectTypo in
+// the helper function LookupMemberExprInRecord.
+int get_type(struct Derived *st) {
+ return st->Base_Type; // expected-error{{no member named 'Base_Type' in 'Derived'; did you mean 'base_type'?}}
+}
+
+// In this example, somename should not be corrected to the cached correction
+// "some_name" since "some_name" is a class and a namespace name is needed.
+class some_name {}; // expected-note {{'some_name' declared here}}
+somename Foo; // expected-error {{unknown type name 'somename'; did you mean 'some_name'?}}
+namespace SomeName {} // expected-note {{namespace 'SomeName' defined here}}
+using namespace somename; // expected-error {{no namespace named 'somename'; did you mean 'SomeName'?}}
+
+
+// Without the callback object, CorrectTypo would choose "field1" as the
+// correction for "fielda" as it is closer than "FieldA", but that correction
+// would be later discarded by the caller and no suggestion would be given.
+struct st {
+ struct {
+ int field1;
+ };
+ double FieldA; // expected-note{{'FieldA' declared here}}
+};
+st var = { .fielda = 0.0 }; // expected-error{{field designator 'fielda' does not refer to any field in type 'st'; did you mean 'FieldA'?}}
+
+// Test the improvement from passing a callback object to CorrectTypo in
+// Sema::BuildCXXNestedNameSpecifier. And also for the improvement by doing
+// so in Sema::getTypeName.
+typedef char* another_str; // expected-note{{'another_str' declared here}}
+namespace AnotherStd { // expected-note{{'AnotherStd' declared here}}
+ class string {};
+}
+another_std::string str; // expected-error{{use of undeclared identifier 'another_std'; did you mean 'AnotherStd'?}}
+another_str *cstr = new AnotherStr; // expected-error{{unknown type name 'AnotherStr'; did you mean 'another_str'?}}
+
+// Test the improvement from passing a callback object to CorrectTypo in
+// Sema::ActOnSizeofParameterPackExpr.
+char* TireNames;
+template<typename ...TypeNames> struct count { // expected-note{{parameter pack 'TypeNames' declared here}}
+ static const unsigned value = sizeof...(TyreNames); // expected-error{{'TyreNames' does not refer to the name of a parameter pack; did you mean 'TypeNames'?}}
+};
+
+// Test the typo-correction callback in Sema::DiagnoseUnknownTypeName.
+namespace unknown_type_test {
+ class StreamOut {}; // expected-note 2 {{'StreamOut' declared here}}
+ long stream_count; // expected-note 2 {{'stream_count' declared here}}
+};
+unknown_type_test::stream_out out; // expected-error{{no type named 'stream_out' in namespace 'unknown_type_test'; did you mean 'StreamOut'?}}
+
+// Demonstrate a case where using only the cached value returns the wrong thing
+// when the cached value was the result of a previous callback object that only
+// accepts a subset of the current callback object.
+namespace {
+using namespace unknown_type_test;
+void bar(long i);
+void before_caching_classname() {
+ bar((stream_out)); // expected-error{{use of undeclared identifier 'stream_out'; did you mean 'stream_count'?}}
+}
+stream_out out; // expected-error{{unknown type name 'stream_out'; did you mean 'StreamOut'?}}
+void after_caching_classname() {
+ bar((stream_out)); // expected-error{{use of undeclared identifier 'stream_out'; did you mean 'stream_count'?}}
+}
+}
+
+// Test the typo-correction callback in Sema::DiagnoseInvalidRedeclaration.
+struct BaseDecl {
+ void add_in(int i);
+};
+struct TestRedecl : public BaseDecl {
+ void add_it(int i); // expected-note{{'add_it' declared here}}
+};
+void TestRedecl::add_in(int i) {} // expected-error{{out-of-line definition of 'add_in' does not match any declaration in 'TestRedecl'; did you mean 'add_it'?}}
+
+// Test the improved typo correction for the Parser::ParseCastExpr =>
+// Sema::ActOnIdExpression => Sema::DiagnoseEmptyLookup call path.
+class SomeNetMessage;
+class Message {};
+void foo(Message&);
+void foo(SomeNetMessage&);
+void doit(void *data) {
+ Message somenetmsg; // expected-note{{'somenetmsg' declared here}}
+ foo(somenetmessage); // expected-error{{use of undeclared identifier 'somenetmessage'; did you mean 'somenetmsg'?}}
+ foo((somenetmessage)data); // expected-error{{use of undeclared identifier 'somenetmessage'; did you mean 'SomeNetMessage'?}}
+}
+
+// Test the typo-correction callback in BuildRecoveryCallExpr.
+// Solves the main issue in PR 9320 of suggesting corrections that take the
+// wrong number of arguments.
+void revoke(const char*); // expected-note 2{{'revoke' declared here}}
+void Test() {
+ Invoke(); // expected-error{{use of undeclared identifier 'Invoke'}}
+ Invoke("foo"); // expected-error{{use of undeclared identifier 'Invoke'; did you mean 'revoke'?}}
+ Invoke("foo", "bar"); // expected-error{{use of undeclared identifier 'Invoke'}}
+}
+void Test2(void (*invoke)(const char *, int)) { // expected-note{{'invoke' declared here}}
+ Invoke(); // expected-error{{use of undeclared identifier 'Invoke'}}
+ Invoke("foo"); // expected-error{{use of undeclared identifier 'Invoke'; did you mean 'revoke'?}}
+ Invoke("foo", 7); // expected-error{{use of undeclared identifier 'Invoke'; did you mean 'invoke'?}}
+ Invoke("foo", 7, 22); // expected-error{{use of undeclared identifier 'Invoke'}}
+}
+
+void provoke(const char *x, bool y=false) {} // expected-note 2{{'provoke' declared here}}
+void Test3() {
+ Provoke(); // expected-error{{use of undeclared identifier 'Provoke'}}
+ Provoke("foo"); // expected-error{{use of undeclared identifier 'Provoke'; did you mean 'provoke'?}}
+ Provoke("foo", true); // expected-error{{use of undeclared identifier 'Provoke'; did you mean 'provoke'?}}
+ Provoke("foo", 7, 22); // expected-error{{use of undeclared identifier 'Provoke'}}
+}
+
+// PR 11737 - Don't try to typo-correct the implicit 'begin' and 'end' in a
+// C++11 for-range statement.
+struct R {};
+bool begun(R);
+void RangeTest() {
+ for (auto b : R()) {} // expected-error {{use of undeclared identifier 'begin'}} expected-note {{range has type}}
+}
+
+// PR 12019 - Avoid infinite mutual recursion in DiagnoseInvalidRedeclaration
+// by not trying to typo-correct a method redeclaration to declarations not
+// in the current record.
+class Parent {
+ void set_types(int index, int value);
+ void add_types(int value);
+};
+class Child: public Parent {};
+void Child::add_types(int value) {} // expected-error{{out-of-line definition of 'add_types' does not match any declaration in 'Child'}}
+
+// Fix the callback based filtering of typo corrections within
+// Sema::ActOnIdExpression by Parser::ParseCastExpression to allow type names as
+// potential corrections for template arguments.
+namespace clash {
+class ConstructExpr {}; // expected-note{{'clash::ConstructExpr' declared here}}
+}
+class ClashTool {
+ bool HaveConstructExpr();
+ template <class T> T* getExprAs();
+
+ void test() {
+ ConstructExpr *expr = // expected-error{{unknown type name 'ConstructExpr'; did you mean 'clash::ConstructExpr'?}}
+ getExprAs<ConstructExpr>(); // expected-error{{use of undeclared identifier 'ConstructExpr'; did you mean 'clash::ConstructExpr'?}}
+ }
+};
+
+namespace test1 {
+ struct S {
+ struct Foobar *f; // expected-note{{'Foobar' declared here}}
+ };
+ test1::FooBar *b; // expected-error{{no type named 'FooBar' in namespace 'test1'; did you mean 'Foobar'?}}
+}
diff --git a/clang/test/SemaCXX/unary-real-imag.cpp b/clang/test/SemaCXX/unary-real-imag.cpp
new file mode 100644
index 0000000..91b63e3
--- /dev/null
+++ b/clang/test/SemaCXX/unary-real-imag.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {};
+int i = __real__ A(); // expected-error {{invalid type 'A' to __real operator}}
+int j = __imag__ A(); // expected-error {{invalid type 'A' to __imag operator}}
+
diff --git a/clang/test/SemaCXX/undefined-internal.cpp b/clang/test/SemaCXX/undefined-internal.cpp
new file mode 100644
index 0000000..1541720
--- /dev/null
+++ b/clang/test/SemaCXX/undefined-internal.cpp
@@ -0,0 +1,183 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Make sure we don't produce invalid IR.
+// RUN: %clang_cc1 -emit-llvm-only %s
+
+namespace test1 {
+ static void foo(); // expected-warning {{function 'test1::foo' has internal linkage but is not defined}}
+ template <class T> static void bar(); // expected-warning {{function 'test1::bar<int>' has internal linkage but is not defined}}
+
+ void test() {
+ foo(); // expected-note {{used here}}
+ bar<int>(); // expected-note {{used here}}
+ }
+}
+
+namespace test2 {
+ namespace {
+ void foo(); // expected-warning {{function 'test2::<anonymous namespace>::foo' has internal linkage but is not defined}}
+ extern int var; // expected-warning {{variable 'test2::<anonymous namespace>::var' has internal linkage but is not defined}}
+ template <class T> void bar(); // expected-warning {{function 'test2::<anonymous namespace>::bar<int>' has internal linkage but is not defined}}
+ }
+ void test() {
+ foo(); // expected-note {{used here}}
+ var = 0; // expected-note {{used here}}
+ bar<int>(); // expected-note {{used here}}
+ }
+}
+
+namespace test3 {
+ namespace {
+ void foo();
+ extern int var;
+ template <class T> void bar();
+ }
+
+ void test() {
+ foo();
+ var = 0;
+ bar<int>();
+ }
+
+ namespace {
+ void foo() {}
+ int var = 0;
+ template <class T> void bar() {}
+ }
+}
+
+namespace test4 {
+ namespace {
+ struct A {
+ A(); // expected-warning {{function 'test4::<anonymous namespace>::A::A' has internal linkage but is not defined}}
+ ~A();// expected-warning {{function 'test4::<anonymous namespace>::A::~A' has internal linkage but is not defined}}
+ virtual void foo(); // expected-warning {{function 'test4::<anonymous namespace>::A::foo' has internal linkage but is not defined}}
+ virtual void bar() = 0;
+ virtual void baz(); // expected-warning {{function 'test4::<anonymous namespace>::A::baz' has internal linkage but is not defined}}
+ };
+ }
+
+ void test(A &a) {
+ a.foo(); // expected-note {{used here}}
+ a.bar();
+ a.baz(); // expected-note {{used here}}
+ }
+
+ struct Test : A {
+ Test() {} // expected-note 2 {{used here}}
+ };
+}
+
+// rdar://problem/9014651
+namespace test5 {
+ namespace {
+ struct A {};
+ }
+
+ template <class N> struct B {
+ static int var; // expected-warning {{variable 'test5::B<test5::<anonymous>::A>::var' has internal linkage but is not defined}}
+ static void foo(); // expected-warning {{function 'test5::B<test5::<anonymous>::A>::foo' has internal linkage but is not defined}}
+ };
+
+ void test() {
+ B<A>::var = 0; // expected-note {{used here}}
+ B<A>::foo(); // expected-note {{used here}}
+ }
+}
+
+namespace test6 {
+ template <class T> struct A {
+ static const int zero = 0;
+ static const int one = 1;
+ static const int two = 2;
+
+ int value;
+
+ A() : value(zero) {
+ value = one;
+ }
+ };
+
+ namespace { struct Internal; }
+
+ void test() {
+ A<Internal> a;
+ a.value = A<Internal>::two;
+ }
+}
+
+// We support (as an extension) private, undefined copy constructors when
+// a temporary is bound to a reference even in C++98. Similarly, we shouldn't
+// warn about this copy constructor being used without a definition.
+namespace PR9323 {
+ namespace {
+ struct Uncopyable {
+ Uncopyable() {}
+ private:
+ Uncopyable(const Uncopyable&); // expected-note {{declared private here}}
+ };
+ }
+ void f(const Uncopyable&) {}
+ void test() {
+ f(Uncopyable()); // expected-warning {{C++98 requires an accessible copy constructor}}
+ };
+}
+
+
+namespace std { class type_info; };
+namespace cxx11_odr_rules {
+ // Note: the way this test is written isn't really ideal, but there really
+ // isn't any other way to check that the odr-used logic for constants
+ // is working without working implicit capture in lambda-expressions.
+ // (The more accurate used-but-not-defined warning is the only other visible
+ // effect of accurate odr-used computation.)
+ //
+ // Note that the warning in question can trigger in cases some people would
+ // consider false positives; hopefully that happens rarely in practice.
+ //
+ // FIXME: Suppressing this test while I figure out how to fix a bug in the
+ // odr-use marking code.
+
+ namespace {
+ struct A {
+ static const int unused = 10;
+ static const int used1 = 20; // xpected-warning {{internal linkage}}
+ static const int used2 = 20; // xpected-warning {{internal linkage}}
+ virtual ~A() {}
+ };
+ }
+
+ void a(int,int);
+ A& p(const int&) { static A a; return a; }
+
+ // Check handling of default arguments
+ void b(int = A::unused);
+
+ void tests() {
+ // Basic test
+ a(A::unused, A::unused);
+
+ // Check that nesting an unevaluated or constant-evaluated context does
+ // the right thing.
+ a(A::unused, sizeof(int[10]));
+
+ // Check that the checks work with unevaluated contexts
+ (void)sizeof(p(A::used1));
+ (void)typeid(p(A::used1)); // xpected-note {{used here}}
+
+ // Misc other testing
+ a(A::unused, 1 ? A::used2 : A::used2); // xpected-note {{used here}}
+ b();
+ }
+}
+
+
+namespace OverloadUse {
+ namespace {
+ void f();
+ void f(int); // expected-warning {{function 'OverloadUse::<anonymous namespace>::f' has internal linkage but is not defined}}
+ }
+ template<void x()> void t(int*) { x(); }
+ template<void x(int)> void t(long*) { x(10); } // expected-note {{used here}}
+ void g() { long a; t<f>(&a); }
+}
diff --git a/clang/test/SemaCXX/underlying_type.cpp b/clang/test/SemaCXX/underlying_type.cpp
new file mode 100644
index 0000000..7bca06b
--- /dev/null
+++ b/clang/test/SemaCXX/underlying_type.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify -std=c++11 %s
+
+#include "limits.h"
+
+template<typename T, typename U>
+struct is_same_type {
+ static const bool value = false;
+};
+template <typename T>
+struct is_same_type<T, T> {
+ static const bool value = true;
+};
+
+__underlying_type(int) a; // expected-error {{only enumeration types}}
+__underlying_type(struct b) c; // expected-error {{only enumeration types}}
+
+enum class f : char;
+static_assert(is_same_type<char, __underlying_type(f)>::value,
+ "f has the wrong underlying type");
+
+enum g {d = INT_MIN };
+static_assert(is_same_type<int, __underlying_type(g)>::value,
+ "g has the wrong underlying type");
+
+__underlying_type(f) h;
+static_assert(is_same_type<char, decltype(h)>::value,
+ "h has the wrong type");
+
+template <typename T>
+struct underlying_type {
+ typedef __underlying_type(T) type; // expected-error {{only enumeration types}}
+};
+
+static_assert(is_same_type<underlying_type<f>::type, char>::value,
+ "f has the wrong underlying type in the template");
+
+underlying_type<int>::type e; // expected-note {{requested here}}
+
+using uint = unsigned;
+enum class foo : uint { bar };
+
+static_assert(is_same_type<underlying_type<foo>::type, unsigned>::value,
+ "foo has the wrong underlying type");
diff --git a/clang/test/SemaCXX/uninit-variables-conditional.cpp b/clang/test/SemaCXX/uninit-variables-conditional.cpp
new file mode 100644
index 0000000..3c44c72
--- /dev/null
+++ b/clang/test/SemaCXX/uninit-variables-conditional.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -Wconditional-uninitialized -fsyntax-only %s -verify
+
+class Foo {
+public:
+ Foo();
+ ~Foo();
+ operator bool();
+};
+
+int bar();
+int baz();
+int init(double *);
+
+// This case flags a false positive under -Wconditional-uninitialized because
+// the destructor in Foo fouls about the minor bit of path-sensitivity in
+// -Wuninitialized.
+double test() {
+ double x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ if (bar() || baz() || Foo() || init(&x))
+ return 1.0;
+
+ return x; // expected-warning {{variable 'x' may be uninitialized when used here}}
+}
diff --git a/clang/test/SemaCXX/uninit-variables.cpp b/clang/test/SemaCXX/uninit-variables.cpp
new file mode 100644
index 0000000..eb6428d
--- /dev/null
+++ b/clang/test/SemaCXX/uninit-variables.cpp
@@ -0,0 +1,143 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -fsyntax-only -fcxx-exceptions %s -verify
+
+// Stub out types for 'typeid' to work.
+namespace std { class type_info {}; }
+
+int test1_aux(int &x);
+int test1() {
+ int x;
+ test1_aux(x);
+ return x; // no-warning
+}
+
+int test2_aux() {
+ int x;
+ int &y = x;
+ return x; // no-warning
+}
+
+// Don't warn on unevaluated contexts.
+void unevaluated_tests() {
+ int x;
+ (void)sizeof(x);
+ (void)typeid(x);
+}
+
+// Warn for glvalue arguments to typeid whose type is polymorphic.
+struct A { virtual ~A() {} };
+void polymorphic_test() {
+ A *a; // expected-note{{initialize the variable 'a' to silence this warning}}
+ (void)typeid(*a); // expected-warning{{variable 'a' is uninitialized when used here}}
+}
+
+// Handle cases where the CFG may constant fold some branches, thus
+// mitigating the need for some path-sensitivity in the analysis.
+unsigned test3_aux();
+unsigned test3() {
+ unsigned x = 0;
+ const bool flag = true;
+ if (flag && (x = test3_aux()) == 0) {
+ return x;
+ }
+ return x;
+}
+unsigned test3_b() {
+ unsigned x ;
+ const bool flag = true;
+ if (flag && (x = test3_aux()) == 0) {
+ x = 1;
+ }
+ return x; // no-warning
+}
+unsigned test3_c() {
+ unsigned x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ const bool flag = false;
+ if (flag && (x = test3_aux()) == 0) {
+ x = 1;
+ }
+ return x; // expected-warning{{variable 'x' is uninitialized when used here}}
+}
+
+enum test4_A {
+ test4_A_a, test_4_A_b
+};
+test4_A test4() {
+ test4_A a; // expected-note{{variable 'a' is declared here}}
+ return a; // expected-warning{{variable 'a' is uninitialized when used here}}
+}
+
+// Test variables getting invalidated by function calls with reference arguments
+// *AND* there are multiple invalidated arguments.
+void test5_aux(int &, int &);
+
+int test5() {
+ int x, y;
+ test5_aux(x, y);
+ return x + y; // no-warning
+}
+
+// This test previously crashed Sema.
+class Rdar9188004A {
+public:
+ virtual ~Rdar9188004A();
+};
+
+template< typename T > class Rdar9188004B : public Rdar9188004A {
+virtual double *foo(Rdar9188004B *next) const {
+ double *values = next->foo(0);
+ try {
+ }
+ catch(double e) {
+ values[0] = e;
+ }
+ return 0;
+ }
+};
+class Rdar9188004C : public Rdar9188004B<Rdar9188004A> {
+ virtual void bar(void) const;
+};
+void Rdar9188004C::bar(void) const {}
+
+// Don't warn about uninitialized variables in unreachable code.
+void PR9625() {
+ if (false) {
+ int x;
+ (void)static_cast<float>(x); // no-warning
+ }
+}
+
+// Don't warn about variables declared in "catch"
+void RDar9251392_bar(const char *msg);
+
+void RDar9251392() {
+ try {
+ throw "hi";
+ }
+ catch (const char* msg) {
+ RDar9251392_bar(msg); // no-warning
+ }
+}
+
+// Test handling of "no-op" casts.
+void test_noop_cast()
+{
+ int x = 1;
+ int y = (int&)x; // no-warning
+}
+
+void test_noop_cast2() {
+ int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+ int y = (int&)x; // expected-warning {{uninitialized when used here}}
+}
+
+// Test handling of bit casts.
+void test_bitcasts() {
+ int x = 1;
+ int y = (float &)x; // no-warning
+}
+
+void test_bitcasts_2() {
+ int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+ int y = (float &)x; // expected-warning {{uninitialized when used here}}
+}
+
diff --git a/clang/test/SemaCXX/uninitialized.cpp b/clang/test/SemaCXX/uninitialized.cpp
new file mode 100644
index 0000000..7879e7c
--- /dev/null
+++ b/clang/test/SemaCXX/uninitialized.cpp
@@ -0,0 +1,169 @@
+// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -std=c++11 -verify %s
+
+int foo(int x);
+int bar(int* x);
+int boo(int& x);
+int far(const int& x);
+
+// Test self-references within initializers which are guaranteed to be
+// uninitialized.
+int a = a; // no-warning: used to signal intended lack of initialization.
+int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}}
+int c = (c + c); // expected-warning 2 {{variable 'c' is uninitialized when used within its own initialization}}
+void test() {
+ int d = ({ d + d ;}); // expected-warning {{variable 'd' is uninitialized when used within its own initialization}}
+}
+int e = static_cast<long>(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}}
+int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}}
+
+// Thes don't warn as they don't require the value.
+int g = sizeof(g);
+void* ptr = &ptr;
+int h = bar(&h);
+int i = boo(i);
+int j = far(j);
+int k = __alignof__(k);
+
+
+// Test self-references with record types.
+class A {
+ // Non-POD class.
+ public:
+ enum count { ONE, TWO, THREE };
+ int num;
+ static int count;
+ int get() const { return num; }
+ int get2() { return num; }
+ void set(int x) { num = x; }
+ static int zero() { return 0; }
+
+ A() {}
+ A(A const &a) {}
+ A(int x) {}
+ A(int *x) {}
+ A(A *a) {}
+ ~A();
+};
+
+A getA() { return A(); }
+A getA(int x) { return A(); }
+A getA(A* a) { return A(); }
+
+void setupA() {
+ A a1;
+ a1.set(a1.get());
+ A a2(a1.get());
+ A a3(a1);
+ A a4(&a4);
+ A a5(a5.zero());
+ A a6(a6.ONE);
+ A a7 = getA();
+ A a8 = getA(a8.TWO);
+ A a9 = getA(&a9);
+ A a10(a10.count);
+
+ A a11(a11); // expected-warning {{variable 'a11' is uninitialized when used within its own initialization}}
+ A a12(a12.get()); // expected-warning {{variable 'a12' is uninitialized when used within its own initialization}}
+ A a13(a13.num); // expected-warning {{variable 'a13' is uninitialized when used within its own initialization}}
+ A a14 = A(a14); // expected-warning {{variable 'a14' is uninitialized when used within its own initialization}}
+ A a15 = getA(a15.num); // expected-warning {{variable 'a15' is uninitialized when used within its own initialization}}
+ A a16(&a16.num); // expected-warning {{variable 'a16' is uninitialized when used within its own initialization}}
+ A a17(a17.get2()); // expected-warning {{variable 'a17' is uninitialized when used within its own initialization}}
+}
+
+struct B {
+ // POD struct.
+ int x;
+ int *y;
+};
+
+B getB() { return B(); };
+B getB(int x) { return B(); };
+B getB(int *x) { return B(); };
+B getB(B *b) { return B(); };
+
+void setupB() {
+ B b1;
+ B b2(b1);
+ B b3 = { 5, &b3.x };
+ B b4 = getB();
+ B b5 = getB(&b5);
+ B b6 = getB(&b6.x);
+
+ // Silence unused warning
+ (void) b2;
+ (void) b4;
+
+ B b7(b7); // expected-warning {{variable 'b7' is uninitialized when used within its own initialization}}
+ B b8 = getB(b8.x); // expected-warning {{variable 'b8' is uninitialized when used within its own initialization}}
+ B b9 = getB(b9.y); // expected-warning {{variable 'b9' is uninitialized when used within its own initialization}}
+}
+
+// Also test similar constructs in a field's initializer.
+struct S {
+ int x;
+ void *ptr;
+
+ S(bool (*)[1]) : x(x) {} // expected-warning {{field is uninitialized when used here}}
+ S(bool (*)[2]) : x(x + 1) {} // expected-warning {{field is uninitialized when used here}}
+ S(bool (*)[3]) : x(x + x) {} // expected-warning {{field is uninitialized when used here}}
+ S(bool (*)[4]) : x(static_cast<long>(x) + 1) {} // expected-warning {{field is uninitialized when used here}}
+ S(bool (*)[5]) : x(foo(x)) {} // FIXME: This should warn!
+
+ // These don't actually require the value of x and so shouldn't warn.
+ S(char (*)[1]) : x(sizeof(x)) {} // rdar://8610363
+ S(char (*)[2]) : ptr(&ptr) {}
+ S(char (*)[3]) : x(__alignof__(x)) {}
+ S(char (*)[4]) : x(bar(&x)) {}
+ S(char (*)[5]) : x(boo(x)) {}
+ S(char (*)[6]) : x(far(x)) {}
+};
+
+struct C { char a[100], *e; } car = { .e = car.a };
+
+// <rdar://problem/10398199>
+namespace rdar10398199 {
+ class FooBase { protected: ~FooBase() {} };
+ class Foo : public FooBase {
+ public:
+ operator int&() const;
+ };
+ void stuff();
+ template <typename T> class FooImpl : public Foo {
+ T val;
+ public:
+ FooImpl(const T &x) : val(x) {}
+ ~FooImpl() { stuff(); }
+ };
+
+ template <typename T> FooImpl<T> makeFoo(const T& x) {
+ return FooImpl<T>(x);
+ }
+
+ void test() {
+ const Foo &x = makeFoo(42);
+ const int&y = makeFoo(42u);
+ (void)x;
+ (void)y;
+ };
+}
+
+// PR 12325 - this was a false uninitialized value warning due to
+// a broken CFG.
+int pr12325(int params) {
+ int x = ({
+ while (false)
+ ;
+ int _v = params;
+ if (false)
+ ;
+ _v; // no-warning
+ });
+ return x;
+}
+
+// Test lambda expressions with -Wuninitialized
+int test_lambda() {
+ auto f1 = [] (int x, int y) { int z; return x + y + z; }; // expected-warning {{C++11 requires lambda with omitted result type to consist of a single return statement}} expected-warning{{variable 'z' is uninitialized when used here}} expected-note {{initialize the variable 'z' to silence this warning}}
+ return f1(1, 2);
+}
diff --git a/clang/test/SemaCXX/unknown-anytype-blocks.cpp b/clang/test/SemaCXX/unknown-anytype-blocks.cpp
new file mode 100644
index 0000000..86ce7e1
--- /dev/null
+++ b/clang/test/SemaCXX/unknown-anytype-blocks.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -funknown-anytype -fblocks -fsyntax-only -verify -std=c++11 %s
+
+namespace test1 {
+ __unknown_anytype (^foo)();
+ __unknown_anytype (^bar)();
+ int test() {
+ auto ret1 = (int)foo();
+ auto ret2 = bar(); // expected-error {{'bar' has unknown return type; cast the call to its declared return type}}
+ return ret1;
+ }
+}
diff --git a/clang/test/SemaCXX/unknown-anytype.cpp b/clang/test/SemaCXX/unknown-anytype.cpp
new file mode 100644
index 0000000..a07ec83
--- /dev/null
+++ b/clang/test/SemaCXX/unknown-anytype.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -funknown-anytype -fsyntax-only -verify %s
+
+namespace test0 {
+ extern __unknown_anytype test0;
+ extern __unknown_anytype test1();
+ extern __unknown_anytype test2(int);
+}
+
+namespace test1 {
+ extern __unknown_anytype foo;
+ int test() {
+ // TODO: it would be great if the 'cannot initialize' errors
+ // turned into something more interesting. It's just a matter of
+ // making sure that these locations check for placeholder types
+ // properly.
+
+ int x = foo; // expected-error {{'foo' has unknown type}}
+ int y = 0 + foo; // expected-error {{'foo' has unknown type}}
+ return foo; // expected-error {{'foo' has unknown type}}
+ }
+}
+
+namespace test2 {
+ extern __unknown_anytype foo();
+ void test() {
+ foo(); // expected-error {{'foo' has unknown return type}}
+ }
+}
+
+namespace test3 {
+ extern __unknown_anytype foo;
+ void test() {
+ foo(); // expected-error {{call to unsupported expression with unknown type}}
+ ((void(void)) foo)(); // expected-error {{variable 'foo' with unknown type cannot be given a function type}}
+ }
+}
+
+// rdar://problem/9899447
+namespace test4 {
+ extern __unknown_anytype test0(...);
+ extern __unknown_anytype test1(...);
+
+ void test() {
+ void (*fn)(int) = (void(*)(int)) test0;
+ int x = (int) test1; // expected-error {{function 'test1' with unknown type must be given a function type}}
+ }
+}
diff --git a/clang/test/SemaCXX/unknown-type-name.cpp b/clang/test/SemaCXX/unknown-type-name.cpp
new file mode 100644
index 0000000..5f8d8ca
--- /dev/null
+++ b/clang/test/SemaCXX/unknown-type-name.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR3990
+namespace N {
+ struct Wibble {
+ };
+
+ typedef Wibble foo;
+}
+using namespace N;
+
+foo::bar x; // expected-error{{no type named 'bar' in 'N::Wibble'}}
+
+void f() {
+ foo::bar = 4; // expected-error{{no member named 'bar' in 'N::Wibble'}}
+}
+
+template<typename T>
+struct A {
+ typedef T type;
+
+ type f();
+};
+
+template<typename T>
+A<T>::type g(T t) { return t; } // expected-error{{missing 'typename'}}
+
+template<typename T>
+A<T>::type A<T>::f() { return type(); } // expected-error{{missing 'typename'}}
diff --git a/clang/test/SemaCXX/unreachable-catch-clauses.cpp b/clang/test/SemaCXX/unreachable-catch-clauses.cpp
new file mode 100644
index 0000000..c75067f
--- /dev/null
+++ b/clang/test/SemaCXX/unreachable-catch-clauses.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
+
+class BaseEx {};
+class Ex1: public BaseEx {};
+typedef Ex1 Ex2;
+
+void f();
+
+void test()
+try {}
+catch (BaseEx &e) { f(); }
+catch (Ex1 &e) { f(); } // expected-note {{for type class Ex1 &}}
+catch (Ex2 &e) { f(); } // expected-warning {{exception of type Ex2 & will be caught by earlier handler}}
+
diff --git a/clang/test/SemaCXX/unreachable-code.cpp b/clang/test/SemaCXX/unreachable-code.cpp
new file mode 100644
index 0000000..743290e
--- /dev/null
+++ b/clang/test/SemaCXX/unreachable-code.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -Wunreachable-code -fblocks -verify %s
+
+int j;
+void bar() { }
+int test1() {
+ for (int i = 0;
+ i != 10;
+ ++i) { // expected-warning {{will never be executed}}
+ if (j == 23) // missing {}'s
+ bar();
+ return 1;
+ }
+ return 0;
+ return 1; // expected-warning {{will never be executed}}
+}
+
+void test2(int i) {
+ switch (i) {
+ case 0:
+ break;
+ bar(); // expected-warning {{will never be executed}}
+ case 2:
+ switch (i) {
+ default:
+ a: goto a;
+ }
+ bar(); // expected-warning {{will never be executed}}
+ }
+ b: goto b;
+ bar(); // expected-warning {{will never be executed}}
+}
+
+void test3() {
+ ^{ return;
+ bar(); // expected-warning {{will never be executed}}
+ }();
+ while (++j) {
+ continue;
+ bar(); // expected-warning {{will never be executed}}
+ }
+}
+
+// PR 6130 - Don't warn about bogus unreachable code with throw's and
+// temporary objects.
+class PR6130 {
+public:
+ PR6130();
+ ~PR6130();
+};
+
+int pr6130(unsigned i) {
+ switch(i) {
+ case 0: return 1;
+ case 1: return 2;
+ default:
+ throw PR6130(); // no-warning
+ }
+}
diff --git a/clang/test/SemaCXX/unused-functions.cpp b/clang/test/SemaCXX/unused-functions.cpp
new file mode 100644
index 0000000..3598082
--- /dev/null
+++ b/clang/test/SemaCXX/unused-functions.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wunused -verify %s
+
+static int foo(int x) { return x; }
+
+template<typename T>
+T get_from_foo(T y) { return foo(y); }
+
+int g(int z) { return get_from_foo(z); }
+
+namespace { void f() = delete; }
diff --git a/clang/test/SemaCXX/unused-with-error.cpp b/clang/test/SemaCXX/unused-with-error.cpp
new file mode 100644
index 0000000..5660007
--- /dev/null
+++ b/clang/test/SemaCXX/unused-with-error.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused -verify %s
+
+// Make sure 'unused' warnings are disabled when errors occurred.
+static void foo(int *X) { // expected-note {{candidate}}
+}
+void bar(const int *Y) {
+ foo(Y); // expected-error {{no matching function for call}}
+}
diff --git a/clang/test/SemaCXX/unused.cpp b/clang/test/SemaCXX/unused.cpp
new file mode 100644
index 0000000..88783ce
--- /dev/null
+++ b/clang/test/SemaCXX/unused.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR4103 : Make sure we don't get a bogus unused expression warning
+class APInt {
+ char foo;
+};
+class APSInt : public APInt {
+ char bar;
+public:
+ APSInt &operator=(const APSInt &RHS);
+};
+
+APSInt& APSInt::operator=(const APSInt &RHS) {
+ APInt::operator=(RHS);
+ return *this;
+}
+
+template<typename T>
+struct X {
+ X();
+};
+
+void test() {
+ X<int>();
+}
diff --git a/clang/test/SemaCXX/user-defined-conversions.cpp b/clang/test/SemaCXX/user-defined-conversions.cpp
new file mode 100644
index 0000000..43ec5a3
--- /dev/null
+++ b/clang/test/SemaCXX/user-defined-conversions.cpp
@@ -0,0 +1,99 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct X {
+ operator bool();
+};
+
+int& f(bool);
+float& f(int);
+
+void f_test(X x) {
+ int& i1 = f(x);
+}
+
+struct Y {
+ operator short();
+ operator float();
+};
+
+void g(int);
+
+void g_test(Y y) {
+ g(y);
+ short s;
+ s = y;
+}
+
+struct A { };
+struct B : A { };
+
+struct C {
+ operator B&();
+};
+
+// Test reference binding via an lvalue conversion function.
+void h(volatile A&);
+void h_test(C c) {
+ h(c);
+}
+
+// Test conversion followed by copy-construction
+struct FunkyDerived;
+
+struct Base {
+ Base(const FunkyDerived&);
+};
+
+struct Derived : Base { };
+
+struct FunkyDerived : Base { };
+
+struct ConvertibleToBase {
+ operator Base();
+};
+
+struct ConvertibleToDerived {
+ operator Derived();
+};
+
+struct ConvertibleToFunkyDerived {
+ operator FunkyDerived();
+};
+
+void test_conversion(ConvertibleToBase ctb, ConvertibleToDerived ctd,
+ ConvertibleToFunkyDerived ctfd) {
+ Base b1 = ctb;
+ Base b2(ctb);
+ Base b3 = ctd;
+ Base b4(ctd);
+ Base b5 = ctfd;
+}
+
+struct X1 {
+ X1(X1&); // expected-note{{candidate constructor not viable: no known conversion from 'X1' to 'X1 &' for 1st argument}}
+};
+
+struct X2 {
+ operator X1();
+};
+
+int &f(X1);
+float &f(...);
+
+void g(X2 b) {
+ int &ir = f(b); // expected-error{{no viable constructor copying parameter of type 'X1'}}
+}
+
+namespace rdar10202900 {
+ class A {
+ public:
+ A();
+
+ private:
+ A(int i); // expected-note{{declared private here}}
+ };
+
+ void testA(A a) {
+ int b = 10;
+ a = b; // expected-error{{calling a private constructor of class 'rdar10202900::A'}}
+ }
+}
diff --git a/clang/test/SemaCXX/using-decl-1.cpp b/clang/test/SemaCXX/using-decl-1.cpp
new file mode 100644
index 0000000..ebe97f6
--- /dev/null
+++ b/clang/test/SemaCXX/using-decl-1.cpp
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+extern "C" { void f(bool); }
+
+namespace std {
+ using ::f;
+ inline void f() { return f(true); }
+}
+
+namespace M {
+ void f(float);
+}
+
+namespace N {
+ using M::f;
+ void f(int) { } // expected-note{{previous}}
+
+ void f(int) { } // expected-error{{redefinition}}
+}
+
+namespace N {
+ void f(double);
+ void f(long);
+}
+
+struct X0 {
+ void operator()(int);
+ void operator()(long);
+};
+
+struct X1 : X0 {
+ // FIXME: give this operator() a 'float' parameter to test overloading
+ // behavior. It currently fails.
+ void operator()();
+ using X0::operator();
+
+ void test() {
+ (*this)(1);
+ }
+};
+
+struct A { void f(); };
+struct B : A { };
+class C : B { using B::f; };
+
+// PR5751: Resolve overloaded functions through using decls.
+namespace O {
+ void f(int i);
+ void f(double d);
+}
+namespace P {
+ void f();
+ void g(void (*ptr)(int));
+ using O::f;
+ void test() {
+ f();
+ f(1);
+ void (*f_ptr1)(double) = f;
+ void (*f_ptr2)() = f;
+ g(f);
+ }
+}
+
+// Make sure that ADL can find names brought in by using decls.
+namespace test0 {
+ namespace ns {
+ class Foo {};
+
+ namespace inner {
+ void foo(char *); // expected-note {{no known conversion}}
+ }
+
+ using inner::foo;
+ }
+
+ void test(ns::Foo *p) {
+ foo(*p); // expected-error {{no matching function for call to 'foo'}}
+ }
+}
+
+// Redeclarations!
+namespace test1 {
+ namespace ns0 { struct Foo {}; }
+ namespace A { void foo(ns0::Foo *p, int y, int z); }
+ namespace ns2 { using A::foo; }
+ namespace ns1 { struct Bar : ns0::Foo {}; }
+ namespace A { void foo(ns0::Foo *p, int y, int z = 0); } // expected-note {{candidate}}
+ namespace ns1 { using A::foo; }
+ namespace ns2 { struct Baz : ns1::Bar {}; }
+ namespace A { void foo(ns0::Foo *p, int y = 0, int z); }
+
+ void test(ns2::Baz *p) {
+ foo(p, 0, 0); // okay!
+ foo(p, 0); // should be fine!
+ foo(p); // expected-error {{no matching function}}
+ }
+}
+
+namespace test2 {
+ namespace ns { int foo; }
+ template <class T> using ns::foo; // expected-error {{cannot template a using declaration}}
+
+ // PR8022
+ struct A {
+ template <typename T> void f(T);
+ };
+ class B : A {
+ template <typename T> using A::f<T>; // expected-error {{cannot template a using declaration}}
+ };
+}
+
+// PR8756
+namespace foo
+{
+ class Class1; // expected-note{{forward declaration}}
+ class Class2
+ {
+ using ::foo::Class1::Function; // expected-error{{incomplete type 'foo::Class1' named in nested name specifier}}
+ };
+}
diff --git a/clang/test/SemaCXX/using-decl-pr4441.cpp b/clang/test/SemaCXX/using-decl-pr4441.cpp
new file mode 100644
index 0000000..39a446f
--- /dev/null
+++ b/clang/test/SemaCXX/using-decl-pr4441.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace A {
+ struct B { };
+ void operator+(B,B);
+}
+
+using A::operator+;
diff --git a/clang/test/SemaCXX/using-decl-pr4450.cpp b/clang/test/SemaCXX/using-decl-pr4450.cpp
new file mode 100644
index 0000000..4f929ad
--- /dev/null
+++ b/clang/test/SemaCXX/using-decl-pr4450.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace A {
+ void g();
+}
+
+namespace X {
+ using A::g;
+}
+
+void h()
+{
+ A::g();
+ X::g();
+}
diff --git a/clang/test/SemaCXX/using-decl-templates.cpp b/clang/test/SemaCXX/using-decl-templates.cpp
new file mode 100644
index 0000000..2f8abca
--- /dev/null
+++ b/clang/test/SemaCXX/using-decl-templates.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> struct A {
+ void f() { }
+ struct N { }; // expected-note{{target of using declaration}}
+};
+
+template<typename T> struct B : A<T> {
+ using A<T>::f;
+ using A<T>::N; // expected-error{{dependent using declaration resolved to type without 'typename'}}
+
+ using A<T>::foo; // expected-error{{no member named 'foo'}}
+ using A<double>::f; // expected-error{{using declaration refers into 'A<double>::', which is not a base class of 'B<int>'}}
+};
+
+B<int> a; // expected-note{{in instantiation of template class 'B<int>' requested here}}
+
+template<typename T> struct C : A<T> {
+ using A<T>::f;
+
+ void f() { };
+};
+
+template <typename T> struct D : A<T> {
+ using A<T>::f;
+
+ void f();
+};
+
+template<typename T> void D<T>::f() { }
+
+template<typename T> struct E : A<T> {
+ using A<T>::f;
+
+ void g() { f(); }
+};
+
+namespace test0 {
+ struct Base {
+ int foo;
+ };
+ template<typename T> struct E : Base {
+ using Base::foo;
+ };
+
+ template struct E<int>;
+}
+
+// PR7896
+namespace PR7896 {
+template <class T> struct Foo {
+ int k (float);
+};
+struct Baz {
+ int k (int);
+};
+template <class T> struct Bar : public Foo<T>, Baz {
+ using Foo<T>::k;
+ using Baz::k;
+ int foo() {
+ return k (1.0f);
+ }
+};
+template int Bar<int>::foo();
+}
+
+// PR10883
+namespace PR10883 {
+ template <typename T>
+ class Base {
+ public:
+ typedef long Container;
+ };
+
+ template <typename T>
+ class Derived : public Base<T> {
+ public:
+ using Base<T>::Container;
+
+ void foo(const Container& current); // expected-error {{unknown type name 'Container'}}
+ };
+}
diff --git a/clang/test/SemaCXX/using-directive.cpp b/clang/test/SemaCXX/using-directive.cpp
new file mode 100644
index 0000000..22c6e14
--- /dev/null
+++ b/clang/test/SemaCXX/using-directive.cpp
@@ -0,0 +1,135 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace A {
+ short i; // expected-note 2{{candidate found by name lookup is 'A::i'}}
+ namespace B {
+ long i; // expected-note{{candidate found by name lookup is 'A::B::i'}}
+ void f() {} // expected-note{{candidate function}}
+ int k;
+ namespace E {} // \
+ expected-note{{candidate found by name lookup is 'A::B::E'}}
+ }
+
+ namespace E {} // expected-note{{candidate found by name lookup is 'A::E'}}
+
+ namespace C {
+ using namespace B;
+ namespace E {} // \
+ expected-note{{candidate found by name lookup is 'A::C::E'}}
+ }
+
+ void f() {} // expected-note{{candidate function}}
+
+ class K1 {
+ void foo();
+ };
+
+ void local_i() {
+ char i;
+ using namespace A;
+ using namespace B;
+ int a[sizeof(i) == sizeof(char)? 1 : -1]; // okay
+ }
+ namespace B {
+ int j;
+ }
+
+ void ambig_i() {
+ using namespace A;
+ using namespace A::B;
+ (void) i; // expected-error{{reference to 'i' is ambiguous}}
+ f(); // expected-error{{call to 'f' is ambiguous}}
+ (void) j; // okay
+ using namespace C;
+ (void) k; // okay
+ using namespace E; // expected-error{{reference to 'E' is ambiguous}}
+ }
+
+ struct K2 {}; // expected-note 2{{candidate found by name lookup is 'A::K2'}}
+}
+
+struct K2 {}; // expected-note 2{{candidate found by name lookup is 'K2'}}
+
+using namespace A;
+
+void K1::foo() {} // okay
+
+struct K2 *k2; // expected-error{{reference to 'K2' is ambiguous}}
+
+K2 *k3; // expected-error{{reference to 'K2' is ambiguous}}
+
+class X { // expected-note{{candidate found by name lookup is 'X'}}
+ // FIXME: produce a suitable error message for this
+ using namespace A; // expected-error{{not allowed}}
+};
+
+namespace N {
+ struct K2;
+ struct K2 { };
+}
+
+namespace Ni {
+ int i(); // expected-note{{candidate found by name lookup is 'Ni::i'}}
+}
+
+namespace NiTest {
+ using namespace A;
+ using namespace Ni;
+
+ int test() {
+ return i; // expected-error{{reference to 'i' is ambiguous}}
+ }
+}
+
+namespace OneTag {
+ struct X; // expected-note{{candidate found by name lookup is 'OneTag::X'}}
+}
+
+namespace OneFunction {
+ void X(); // expected-note{{candidate found by name lookup is 'OneFunction::X'}}
+}
+
+namespace TwoTag {
+ struct X; // expected-note{{candidate found by name lookup is 'TwoTag::X'}}
+}
+
+namespace FuncHidesTagAmbiguity {
+ using namespace OneTag;
+ using namespace OneFunction;
+ using namespace TwoTag;
+
+ void test() {
+ (void)X(); // expected-error{{reference to 'X' is ambiguous}}
+ }
+}
+
+// PR5479
+namespace Aliased {
+ void inAliased();
+}
+namespace Alias = Aliased;
+using namespace Alias;
+void testAlias() {
+ inAliased();
+}
+
+namespace N { void f2(int); }
+
+extern "C++" {
+ using namespace N;
+ void f3() { f2(1); }
+}
+
+void f4() { f2(1); }
+
+// PR7517
+using namespace std; // expected-warning{{using directive refers to implicitly-defined namespace 'std'}}
+using namespace ::std; // expected-warning{{using directive refers to implicitly-defined namespace 'std'}}
+
+namespace test1 {
+ namespace ns { typedef int test1; }
+ template <class T> using namespace ns; // expected-error {{cannot template a using directive}}
+
+ // Test that we recovered okay.
+ test1 x;
+}
diff --git a/clang/test/SemaCXX/value-dependent-exprs.cpp b/clang/test/SemaCXX/value-dependent-exprs.cpp
new file mode 100644
index 0000000..2017ffa
--- /dev/null
+++ b/clang/test/SemaCXX/value-dependent-exprs.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -verify %s
+
+template <unsigned I>
+class C0 {
+ static const int iv0 = 1 << I;
+
+ enum {
+ A = I,
+ B = I + 1
+ };
+
+ struct s0 {
+ int a : I;
+ int b[I];
+ };
+
+ // FIXME: I'm unclear where the right place to handle this is.
+#if 0
+ void f0(int *p) {
+ if (p == I) {
+ }
+ }
+#endif
+
+#if 0
+ // FIXME: Not sure whether we care about these.
+ void f1(int *a)
+ __attribute__((nonnull(1 + I)))
+ __attribute__((constructor(1 + I)))
+ __attribute__((destructor(1 + I)))
+ __attribute__((sentinel(1 + I, 2 + I))),
+ __attribute__((reqd_work_group_size(1 + I, 2 + I, 3 + I))),
+ __attribute__((format_arg(1 + I))),
+ __attribute__((aligned(1 + I))),
+ __attribute__((regparm(1 + I)));
+
+ typedef int int_a0 __attribute__((address_space(1 + B)));
+#endif
+
+#if 0
+ // FIXME: This doesn't work. PR4996.
+ int f2() {
+ return __builtin_choose_expr(I, 1, 2);
+ }
+#endif
+
+};
diff --git a/clang/test/SemaCXX/value-initialization.cpp b/clang/test/SemaCXX/value-initialization.cpp
new file mode 100644
index 0000000..4e3acbb
--- /dev/null
+++ b/clang/test/SemaCXX/value-initialization.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+struct A { // expected-warning {{does not declare any constructor to initialize}}
+ const int i; // expected-note{{const member 'i' will never be initialized}} expected-note {{implicitly deleted}}
+ virtual void f() { }
+};
+
+int main () {
+ (void)A(); // expected-error {{call to implicitly-deleted default constructor}}
+}
diff --git a/clang/test/SemaCXX/vararg-default-arg.cpp b/clang/test/SemaCXX/vararg-default-arg.cpp
new file mode 100644
index 0000000..3c8e41c
--- /dev/null
+++ b/clang/test/SemaCXX/vararg-default-arg.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// PR5462
+
+void f1(void);
+void f2(const char * = __null, ...);
+
+void f1(void)
+{
+ f2();
+}
diff --git a/clang/test/SemaCXX/vararg-non-pod.cpp b/clang/test/SemaCXX/vararg-non-pod.cpp
new file mode 100644
index 0000000..86b560e
--- /dev/null
+++ b/clang/test/SemaCXX/vararg-non-pod.cpp
@@ -0,0 +1,125 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s -Wno-error=non-pod-varargs
+
+extern char version[];
+
+class C {
+public:
+ C(int);
+ void g(int a, ...);
+ static void h(int a, ...);
+};
+
+void g(int a, ...);
+
+void t1()
+{
+ C c(10);
+
+ g(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic function; call will abort at runtime}}
+ g(10, version);
+}
+
+void t2()
+{
+ C c(10);
+
+ c.g(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic method; call will abort at runtime}}
+ c.g(10, version);
+
+ C::h(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic function; call will abort at runtime}}
+ C::h(10, version);
+}
+
+int (^block)(int, ...);
+
+void t3()
+{
+ C c(10);
+
+ block(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic block; call will abort at runtime}}
+ block(10, version);
+}
+
+class D {
+public:
+ void operator() (int a, ...);
+};
+
+void t4()
+{
+ C c(10);
+
+ D d;
+
+ d(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic method; call will abort at runtime}}
+ d(10, version);
+}
+
+class E {
+ E(int, ...); // expected-note 2{{implicitly declared private here}}
+};
+
+void t5()
+{
+ C c(10);
+
+ E e(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic constructor; call will abort at runtime}} \
+ // expected-error{{calling a private constructor of class 'E'}}
+ (void)E(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic constructor; call will abort at runtime}} \
+ // expected-error{{calling a private constructor of class 'E'}}
+
+}
+
+// PR5761: unevaluated operands and the non-POD warning
+class Foo {
+ public:
+ Foo() {}
+};
+
+int Helper(...);
+const int size = sizeof(Helper(Foo()));
+
+namespace std {
+ class type_info { };
+}
+
+struct Base { virtual ~Base(); };
+Base &get_base(...);
+int eat_base(...);
+
+void test_typeid(Base &base) {
+ (void)typeid(get_base(base)); // expected-warning{{cannot pass object of non-POD type 'Base' through variadic function; call will abort at runtime}}
+ (void)typeid(eat_base(base)); // okay
+}
+
+
+// rdar://7985267 - Shouldn't warn, doesn't actually use __builtin_va_start is
+// magic.
+
+void t6(Foo somearg, ... ) {
+ __builtin_va_list list;
+ __builtin_va_start(list, somearg);
+}
+
+void t7(int n, ...) {
+ __builtin_va_list list;
+ __builtin_va_start(list, n);
+ (void)__builtin_va_arg(list, C); // expected-warning{{second argument to 'va_arg' is of non-POD type 'C'}}
+ __builtin_va_end(list);
+}
+
+struct Abstract {
+ virtual void doit() = 0; // expected-note{{unimplemented pure virtual method}}
+};
+
+void t8(int n, ...) {
+ __builtin_va_list list;
+ __builtin_va_start(list, n);
+ (void)__builtin_va_arg(list, Abstract); // expected-error{{second argument to 'va_arg' is of abstract type 'Abstract'}}
+ __builtin_va_end(list);
+}
+
+int t9(int n) {
+ // Make sure the error works in potentially-evaluated sizeof
+ return (int)sizeof(*(Helper(Foo()), (int (*)[n])0)); // expected-warning{{cannot pass object of non-POD type}}
+}
diff --git a/clang/test/SemaCXX/vector-casts.cpp b/clang/test/SemaCXX/vector-casts.cpp
new file mode 100644
index 0000000..681a07e
--- /dev/null
+++ b/clang/test/SemaCXX/vector-casts.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+typedef int __v2si __attribute__((__vector_size__(8)));
+typedef short __v4hi __attribute__((__vector_size__(8)));
+typedef short __v8hi __attribute__((__vector_size__(16)));
+
+struct S { }; // expected-note 2 {{candidate constructor}}
+
+void f() {
+ __v2si v2si;
+ __v4hi v4hi;
+ __v8hi v8hi;
+ unsigned long long ll;
+ unsigned char c;
+ S s;
+
+ (void)reinterpret_cast<__v2si>(v4hi);
+ (void)(__v2si)v4hi;
+ (void)reinterpret_cast<__v4hi>(v2si);
+ (void)(__v4hi)v2si;
+ (void)reinterpret_cast<unsigned long long>(v2si);
+ (void)(unsigned long long)v2si;
+ (void)reinterpret_cast<__v2si>(ll);
+ (void)(__v2si)(ll);
+
+ (void)reinterpret_cast<S>(v2si); // expected-error {{reinterpret_cast from '__v2si' to 'S' is not allowed}}
+ (void)(S)v2si; // expected-error {{no matching conversion for C-style cast from '__v2si' to 'S'}}
+ (void)reinterpret_cast<__v2si>(s); // expected-error {{reinterpret_cast from 'S' to '__v2si' is not allowed}}
+ (void)(__v2si)s; // expected-error {{cannot convert 'S' to '__v2si' without a conversion operator}}
+
+ (void)reinterpret_cast<unsigned char>(v2si); // expected-error {{reinterpret_cast from vector '__v2si' to scalar 'unsigned char' of different size}}
+ (void)(unsigned char)v2si; // expected-error {{C-style cast from vector '__v2si' to scalar 'unsigned char' of different size}}
+ (void)reinterpret_cast<__v2si>(c); // expected-error {{reinterpret_cast from scalar 'unsigned char' to vector '__v2si' of different size}}
+
+ (void)reinterpret_cast<__v8hi>(v4hi); // expected-error {{reinterpret_cast from vector '__v4hi' to vector '__v8hi' of different size}}
+ (void)(__v8hi)v4hi; // expected-error {{C-style cast from vector '__v4hi' to vector '__v8hi' of different size}}
+ (void)reinterpret_cast<__v4hi>(v8hi); // expected-error {{reinterpret_cast from vector '__v8hi' to vector '__v4hi' of different size}}
+ (void)(__v4hi)v8hi; // expected-error {{C-style cast from vector '__v8hi' to vector '__v4hi' of different size}}
+}
+
+
diff --git a/clang/test/SemaCXX/vector-no-lax.cpp b/clang/test/SemaCXX/vector-no-lax.cpp
new file mode 100644
index 0000000..32dcacf
--- /dev/null
+++ b/clang/test/SemaCXX/vector-no-lax.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fno-lax-vector-conversions -verify %s
+typedef unsigned int __attribute__((vector_size (16))) vUInt32;
+typedef int __attribute__((vector_size (16))) vSInt32;
+
+vSInt32 foo (vUInt32 a) {
+ vSInt32 b = { 0, 0, 0, 0 };
+ b += a; // expected-error{{can't convert between vector values}}
+ return b;
+}
diff --git a/clang/test/SemaCXX/vector.cpp b/clang/test/SemaCXX/vector.cpp
new file mode 100644
index 0000000..82245ac
--- /dev/null
+++ b/clang/test/SemaCXX/vector.cpp
@@ -0,0 +1,269 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+typedef char char16 __attribute__ ((__vector_size__ (16)));
+typedef long long longlong16 __attribute__ ((__vector_size__ (16)));
+typedef char char16_e __attribute__ ((__ext_vector_type__ (16)));
+typedef long long longlong16_e __attribute__ ((__ext_vector_type__ (2)));
+
+// Test overloading and function calls with vector types.
+void f0(char16);
+
+void f0_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) {
+ f0(c16);
+ f0(ll16);
+ f0(c16e);
+ f0(ll16e);
+}
+
+int &f1(char16); // expected-note 2{{candidate function}}
+float &f1(longlong16); // expected-note 2{{candidate function}}
+
+void f1_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) {
+ int &ir1 = f1(c16);
+ float &fr1 = f1(ll16);
+ f1(c16e); // expected-error{{call to 'f1' is ambiguous}}
+ f1(ll16e); // expected-error{{call to 'f1' is ambiguous}}
+}
+
+void f2(char16_e); // expected-note{{no known conversion from 'longlong16_e' to 'char16_e' for 1st argument}} \
+ // expected-note{{candidate function not viable: no known conversion from 'convertible_to<longlong16_e>' to 'char16_e' for 1st argument}}
+
+void f2_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e ll16e) {
+ f2(c16);
+ f2(ll16);
+ f2(c16e);
+ f2(ll16e); // expected-error{{no matching function}}
+ f2('a');
+ f2(17);
+}
+
+// Test the conditional operator with vector types.
+void conditional(bool Cond, char16 c16, longlong16 ll16, char16_e c16e,
+ longlong16_e ll16e) {
+ // Conditional operators with the same type.
+ __typeof__(Cond? c16 : c16) *c16p1 = &c16;
+ __typeof__(Cond? ll16 : ll16) *ll16p1 = &ll16;
+ __typeof__(Cond? c16e : c16e) *c16ep1 = &c16e;
+ __typeof__(Cond? ll16e : ll16e) *ll16ep1 = &ll16e;
+
+ // Conditional operators with similar types.
+ __typeof__(Cond? c16 : c16e) *c16ep2 = &c16e;
+ __typeof__(Cond? c16e : c16) *c16ep3 = &c16e;
+ __typeof__(Cond? ll16 : ll16e) *ll16ep2 = &ll16e;
+ __typeof__(Cond? ll16e : ll16) *ll16ep3 = &ll16e;
+
+ // Conditional operators with compatible types under -flax-vector-conversions (default)
+ (void)(Cond? c16 : ll16);
+ (void)(Cond? ll16e : c16e);
+ (void)(Cond? ll16e : c16);
+}
+
+// Test C++ cast'ing of vector types.
+void casts(longlong16 ll16, longlong16_e ll16e) {
+ // C-style casts.
+ (void)(char16)ll16;
+ (void)(char16_e)ll16;
+ (void)(longlong16)ll16;
+ (void)(longlong16_e)ll16;
+ (void)(char16)ll16e;
+ (void)(char16_e)ll16e;
+ (void)(longlong16)ll16e;
+ (void)(longlong16_e)ll16e;
+
+ // Function-style casts.
+ (void)char16(ll16);
+ (void)char16_e(ll16);
+ (void)longlong16(ll16);
+ (void)longlong16_e(ll16);
+ (void)char16(ll16e);
+ (void)char16_e(ll16e);
+ (void)longlong16(ll16e);
+ (void)longlong16_e(ll16e);
+
+ // static_cast
+ (void)static_cast<char16>(ll16);
+ (void)static_cast<char16_e>(ll16);
+ (void)static_cast<longlong16>(ll16);
+ (void)static_cast<longlong16_e>(ll16);
+ (void)static_cast<char16>(ll16e);
+ (void)static_cast<char16_e>(ll16e); // expected-error{{static_cast from 'longlong16_e' to 'char16_e' is not allowed}}
+ (void)static_cast<longlong16>(ll16e);
+ (void)static_cast<longlong16_e>(ll16e);
+
+ // reinterpret_cast
+ (void)reinterpret_cast<char16>(ll16);
+ (void)reinterpret_cast<char16_e>(ll16);
+ (void)reinterpret_cast<longlong16>(ll16);
+ (void)reinterpret_cast<longlong16_e>(ll16);
+ (void)reinterpret_cast<char16>(ll16e);
+ (void)reinterpret_cast<char16_e>(ll16e);
+ (void)reinterpret_cast<longlong16>(ll16e);
+ (void)reinterpret_cast<longlong16_e>(ll16e);
+}
+
+template<typename T>
+struct convertible_to { // expected-note 3 {{candidate function (the implicit copy assignment operator)}}
+ operator T() const;
+};
+
+void test_implicit_conversions(bool Cond, char16 c16, longlong16 ll16,
+ char16_e c16e, longlong16_e ll16e,
+ convertible_to<char16> to_c16,
+ convertible_to<longlong16> to_ll16,
+ convertible_to<char16_e> to_c16e,
+ convertible_to<longlong16_e> to_ll16e,
+ convertible_to<char16&> rto_c16,
+ convertible_to<char16_e&> rto_c16e) {
+ f0(to_c16);
+ f0(to_ll16);
+ f0(to_c16e);
+ f0(to_ll16e);
+ f2(to_c16);
+ f2(to_ll16);
+ f2(to_c16e);
+ f2(to_ll16e); // expected-error{{no matching function}}
+
+ (void)(c16 == c16e);
+ (void)(c16 == to_c16);
+ (void)+to_c16;
+ (void)-to_c16;
+ (void)~to_c16;
+ (void)(to_c16 == to_c16e);
+ (void)(to_c16 != to_c16e);
+ (void)(to_c16 < to_c16e);
+ (void)(to_c16 <= to_c16e);
+ (void)(to_c16 > to_c16e);
+ (void)(to_c16 >= to_c16e);
+ (void)(to_c16 + to_c16);
+ (void)(to_c16 - to_c16);
+ (void)(to_c16 * to_c16);
+ (void)(to_c16 / to_c16);
+ (void)(rto_c16 = to_c16); // expected-error{{no viable overloaded '='}}
+ (void)(rto_c16 += to_c16);
+ (void)(rto_c16 -= to_c16);
+ (void)(rto_c16 *= to_c16);
+ (void)(rto_c16 /= to_c16);
+
+ (void)+to_c16e;
+ (void)-to_c16e;
+ (void)~to_c16e;
+ (void)(to_c16e == to_c16e);
+ (void)(to_c16e != to_c16e);
+ (void)(to_c16e < to_c16e);
+ (void)(to_c16e <= to_c16e);
+ (void)(to_c16e > to_c16e);
+ (void)(to_c16e >= to_c16e);
+ (void)(to_c16e + to_c16);
+ (void)(to_c16e - to_c16);
+ (void)(to_c16e * to_c16);
+ (void)(to_c16e / to_c16);
+ (void)(rto_c16e = to_c16); // expected-error{{no viable overloaded '='}}
+ (void)(rto_c16e += to_c16);
+ (void)(rto_c16e -= to_c16);
+ (void)(rto_c16e *= to_c16);
+ (void)(rto_c16e /= to_c16);
+
+ (void)+to_c16;
+ (void)-to_c16;
+ (void)~to_c16;
+ (void)(to_c16 == to_c16e);
+ (void)(to_c16 != to_c16e);
+ (void)(to_c16 < to_c16e);
+ (void)(to_c16 <= to_c16e);
+ (void)(to_c16 > to_c16e);
+ (void)(to_c16 >= to_c16e);
+ (void)(to_c16 + to_c16e);
+ (void)(to_c16 - to_c16e);
+ (void)(to_c16 * to_c16e);
+ (void)(to_c16 / to_c16e);
+ (void)(rto_c16 = c16e); // expected-error{{no viable overloaded '='}}
+ (void)(rto_c16 += to_c16e);
+ (void)(rto_c16 -= to_c16e);
+ (void)(rto_c16 *= to_c16e);
+ (void)(rto_c16 /= to_c16e);
+
+ (void)(Cond? to_c16 : to_c16e);
+ (void)(Cond? to_ll16e : to_ll16);
+
+ // These 2 are convertable with -flax-vector-conversions (default)
+ (void)(Cond? to_c16 : to_ll16);
+ (void)(Cond? to_c16e : to_ll16e);
+}
+
+typedef float fltx2 __attribute__((__vector_size__(8)));
+typedef float fltx4 __attribute__((__vector_size__(16)));
+typedef double dblx2 __attribute__((__vector_size__(16)));
+typedef double dblx4 __attribute__((__vector_size__(32)));
+
+void accept_fltx2(fltx2); // expected-note{{candidate function not viable: no known conversion from 'double' to 'fltx2' for 1st argument}}
+void accept_fltx4(fltx4);
+void accept_dblx2(dblx2);
+void accept_dblx4(dblx4);
+void accept_bool(bool); // expected-note{{candidate function not viable: no known conversion from 'fltx2' to 'bool' for 1st argument}}
+
+void test(fltx2 fltx2_val, fltx4 fltx4_val, dblx2 dblx2_val, dblx4 dblx4_val) {
+ // Exact matches
+ accept_fltx2(fltx2_val);
+ accept_fltx4(fltx4_val);
+ accept_dblx2(dblx2_val);
+ accept_dblx4(dblx4_val);
+
+ // Same-size conversions
+ // FIXME: G++ rejects these conversions, we accept them. Revisit this!
+ accept_fltx4(dblx2_val);
+ accept_dblx2(fltx4_val);
+
+ // Conversion to bool.
+ accept_bool(fltx2_val); // expected-error{{no matching function for call to 'accept_bool'}}
+
+ // Scalar-to-vector conversions.
+ accept_fltx2(1.0); // expected-error{{no matching function for call to 'accept_fltx2'}}
+}
+
+typedef int intx4 __attribute__((__vector_size__(16)));
+typedef int inte4 __attribute__((__ext_vector_type__(4)));
+typedef int flte4 __attribute__((__ext_vector_type__(4)));
+
+void test_mixed_vector_types(fltx4 f, intx4 n, flte4 g, flte4 m) {
+ (void)(f == g);
+ (void)(g != f);
+ (void)(f <= g);
+ (void)(g >= f);
+ (void)(f < g);
+ (void)(g > f);
+
+ (void)(+g);
+ (void)(-g);
+
+ (void)(f + g);
+ (void)(f - g);
+ (void)(f * g);
+ (void)(f / g);
+ (void)(f = g);
+ (void)(f += g);
+ (void)(f -= g);
+ (void)(f *= g);
+ (void)(f /= g);
+
+
+ (void)(n == m);
+ (void)(m != n);
+ (void)(n <= m);
+ (void)(m >= n);
+ (void)(n < m);
+ (void)(m > n);
+
+ (void)(+m);
+ (void)(-m);
+ (void)(~m);
+
+ (void)(n + m);
+ (void)(n - m);
+ (void)(n * m);
+ (void)(n / m);
+ (void)(n % m);
+ (void)(n = m);
+ (void)(n += m);
+ (void)(n -= m);
+ (void)(n *= m);
+ (void)(n /= m);
+}
diff --git a/clang/test/SemaCXX/virtual-base-used.cpp b/clang/test/SemaCXX/virtual-base-used.cpp
new file mode 100644
index 0000000..d147b13
--- /dev/null
+++ b/clang/test/SemaCXX/virtual-base-used.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR7800
+
+class NoDestroy { ~NoDestroy(); }; // expected-note 3 {{declared private here}}
+struct A {
+ virtual ~A();
+};
+
+struct B : public virtual A {
+ NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
+};
+struct D : public virtual B {
+ virtual void foo();
+ ~D();
+};
+void D::foo() { // expected-note {{implicit default destructor for 'B' first required here}}
+}
+
+struct E : public virtual A {
+ NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
+};
+struct F : public E { // expected-note {{implicit default destructor for 'E' first required here}}
+};
+struct G : public virtual F {
+ virtual void foo();
+ ~G();
+};
+void G::foo() { // expected-note {{implicit default destructor for 'F' first required here}}
+}
+
+struct H : public virtual A {
+ NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
+};
+struct I : public virtual H {
+ ~I();
+};
+struct J : public I {
+ virtual void foo();
+ ~J();
+};
+void J::foo() { // expected-note {{implicit default destructor for 'H' first required here}}
+}
diff --git a/clang/test/SemaCXX/virtual-member-functions-key-function.cpp b/clang/test/SemaCXX/virtual-member-functions-key-function.cpp
new file mode 100644
index 0000000..09a30b9
--- /dev/null
+++ b/clang/test/SemaCXX/virtual-member-functions-key-function.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct A {
+ virtual ~A();
+};
+
+struct B : A { // expected-error {{no suitable member 'operator delete' in 'B'}}
+ B() { } // expected-note {{implicit default destructor for 'B' first required here}}
+ void operator delete(void *, int); // expected-note {{'operator delete' declared here}}
+};
+
+struct C : A { // expected-error {{no suitable member 'operator delete' in 'C'}}
+ void operator delete(void *, int); // expected-note {{'operator delete' declared here}}
+};
+
+void f() {
+ (void)new B;
+ (void)new C; // expected-note {{implicit default destructor for 'C' first required here}}
+}
+
+// Make sure that the key-function computation is consistent when the
+// first virtual member function of a nested class has an inline body.
+struct Outer {
+ struct Inner {
+ virtual void f() { }
+ void g();
+ };
+};
+
+void Outer::Inner::g() { }
diff --git a/clang/test/SemaCXX/virtual-override.cpp b/clang/test/SemaCXX/virtual-override.cpp
new file mode 100644
index 0000000..b477438
--- /dev/null
+++ b/clang/test/SemaCXX/virtual-override.cpp
@@ -0,0 +1,290 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+namespace T1 {
+
+class A {
+ virtual int f(); // expected-note{{overridden virtual function is here}}
+};
+
+class B : A {
+ virtual void f(); // expected-error{{virtual function 'f' has a different return type ('void') than the function it overrides (which has return type 'int')}}
+};
+
+}
+
+namespace T2 {
+
+struct a { };
+struct b { };
+
+class A {
+ virtual a* f(); // expected-note{{overridden virtual function is here}}
+};
+
+class B : A {
+ virtual b* f(); // expected-error{{return type of virtual function 'f' is not covariant with the return type of the function it overrides ('T2::b *' is not derived from 'T2::a *')}}
+};
+
+}
+
+namespace T3 {
+
+struct a { };
+struct b : private a { }; // expected-note{{declared private here}}
+
+class A {
+ virtual a* f(); // FIXME: desired-note{{overridden virtual function is here}}
+};
+
+class B : A {
+ virtual b* f(); // expected-error{{invalid covariant return for virtual function: 'T3::a' is a private base class of 'T3::b'}}
+};
+
+}
+
+namespace T4 {
+
+struct a { };
+struct a1 : a { };
+struct b : a, a1 { };
+
+class A {
+ virtual a* f(); // expected-note{{overridden virtual function is here}}
+};
+
+class B : A {
+ virtual b* f(); // expected-error{{return type of virtual function 'f' is not covariant with the return type of the function it overrides (ambiguous conversion from derived class 'T4::b' to base class 'T4::a':\n\
+ struct T4::b -> struct T4::a\n\
+ struct T4::b -> struct T4::a1 -> struct T4::a)}}
+};
+
+}
+
+namespace T5 {
+
+struct a { };
+
+class A {
+ virtual a* const f();
+ virtual a* const g(); // expected-note{{overridden virtual function is here}}
+};
+
+class B : A {
+ virtual a* const f();
+ virtual a* g(); // expected-error{{return type of virtual function 'g' is not covariant with the return type of the function it overrides ('T5::a *' has different qualifiers than 'T5::a *const')}}
+};
+
+}
+
+namespace T6 {
+
+struct a { };
+
+class A {
+ virtual const a* f();
+ virtual a* g(); // expected-note{{overridden virtual function is here}}
+};
+
+class B : A {
+ virtual a* f();
+ virtual const a* g(); // expected-error{{return type of virtual function 'g' is not covariant with the return type of the function it overrides (class type 'const T6::a *' is more qualified than class type 'T6::a *'}}
+};
+
+}
+
+namespace T7 {
+ struct a { };
+ struct b { };
+
+ class A {
+ a* f();
+ };
+
+ class B : A {
+ virtual b* f();
+ };
+}
+
+namespace T8 {
+ struct a { };
+ struct b; // expected-note {{forward declaration of 'T8::b'}}
+
+ class A {
+ virtual a *f();
+ };
+
+ class B : A {
+ b* f(); // expected-error {{return type of virtual function 'f' is not covariant with the return type of the function it overrides ('T8::b' is incomplete)}}
+ };
+}
+
+namespace T9 {
+ struct a { };
+
+ template<typename T> struct b : a {
+ int a[sizeof(T) ? -1 : -1]; // expected-error {{array with a negative size}}
+ };
+
+ class A {
+ virtual a *f();
+ };
+
+ class B : A {
+ virtual b<int> *f(); // expected-note {{in instantiation of template class 'T9::b<int>' requested here}}
+ };
+}
+
+// PR5656
+class X0 {
+ virtual void f0();
+};
+class X1 : public X0 {
+ void f0() = 0;
+};
+
+template <typename Base>
+struct Foo : Base {
+ void f(int) = 0; // expected-error{{not virtual and cannot be declared pure}}
+};
+
+struct Base1 { virtual void f(int); };
+struct Base2 { };
+
+void test() {
+ (void)sizeof(Foo<Base1>);
+ (void)sizeof(Foo<Base2>); // expected-note{{instantiation}}
+}
+
+template<typename Base>
+struct Foo2 : Base {
+ template<typename T> int f(T);
+};
+
+void test2() {
+ Foo2<Base1> f1;
+ Foo2<Base2> f2;
+ f1.f(17);
+ f2.f(17);
+};
+
+struct Foo3 {
+ virtual void f(int) = 0; // expected-note{{unimplemented pure virtual method}}
+};
+
+template<typename T>
+struct Bar3 : Foo3 {
+ void f(T);
+};
+
+void test3() {
+ Bar3<int> b3i; // okay
+ Bar3<float> b3f; // expected-error{{is an abstract class}}
+}
+
+// 5920
+namespace PR5920 {
+ class Base {};
+
+ template <typename T>
+ class Derived : public Base {};
+
+ class Foo {
+ public:
+ virtual Base* Method();
+ };
+
+ class Bar : public Foo {
+ public:
+ virtual Derived<int>* Method();
+ };
+}
+
+// Look through template types and typedefs to see whether return types are
+// pointers or references.
+namespace PR6110 {
+ class Base {};
+ class Derived : public Base {};
+
+ typedef Base* BaseP;
+ typedef Derived* DerivedP;
+
+ class X { virtual BaseP f(); };
+ class X1 : public X { virtual DerivedP f(); };
+
+ template <typename T> class Y { virtual T f(); };
+ template <typename T1, typename T> class Y1 : public Y<T> { virtual T1 f(); };
+ Y1<Derived*, Base*> y;
+}
+
+// Defer checking for covariance if either return type is dependent.
+namespace type_dependent_covariance {
+ struct B {};
+ template <int N> struct TD : public B {};
+ template <> struct TD<1> {};
+
+ template <int N> struct TB {};
+ struct D : public TB<0> {};
+
+ template <int N> struct X {
+ virtual B* f1(); // expected-note{{overridden virtual function is here}}
+ virtual TB<N>* f2(); // expected-note{{overridden virtual function is here}}
+ };
+ template <int N, int M> struct X1 : X<N> {
+ virtual TD<M>* f1(); // expected-error{{return type of virtual function 'f1' is not covariant with the return type of the function it overrides ('TD<1> *'}}
+ virtual D* f2(); // expected-error{{return type of virtual function 'f2' is not covariant with the return type of the function it overrides ('type_dependent_covariance::D *' is not derived from 'TB<1> *')}}
+ };
+
+ X1<0, 0> good;
+ X1<0, 1> bad_derived; // expected-note{{instantiation}}
+ X1<1, 0> bad_base; // expected-note{{instantiation}}
+}
+
+namespace T10 {
+ struct A { };
+ struct B : A { };
+
+ struct C {
+ virtual A&& f();
+ };
+
+ struct D : C {
+ virtual B&& f();
+ };
+};
+
+namespace T11 {
+ struct A { };
+ struct B : A { };
+
+ struct C {
+ virtual A& f(); // expected-note {{overridden virtual function is here}}
+ };
+
+ struct D : C {
+ virtual B&& f(); // expected-error {{virtual function 'f' has a different return type ('T11::B &&') than the function it overrides (which has return type 'T11::A &')}}
+ };
+};
+
+namespace T12 {
+ struct A { };
+ struct B : A { };
+
+ struct C {
+ virtual A&& f(); // expected-note {{overridden virtual function is here}}
+ };
+
+ struct D : C {
+ virtual B& f(); // expected-error {{virtual function 'f' has a different return type ('T12::B &') than the function it overrides (which has return type 'T12::A &&')}}
+ };
+};
+
+namespace PR8168 {
+ class A {
+ public:
+ virtual void foo() {} // expected-note{{overridden virtual function is here}}
+ };
+
+ class B : public A {
+ public:
+ static void foo() {} // expected-error{{'static' member function 'foo' overrides a virtual function}}
+ };
+}
diff --git a/clang/test/SemaCXX/virtuals.cpp b/clang/test/SemaCXX/virtuals.cpp
new file mode 100644
index 0000000..ea7d203
--- /dev/null
+++ b/clang/test/SemaCXX/virtuals.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -std=c++11 %s
+
+class A {
+ virtual void f();
+ virtual void g() = 0; // expected-note{{unimplemented pure virtual method 'g' in 'A'}}
+
+ void h() = 0; // expected-error {{'h' is not virtual and cannot be declared pure}}
+ void i() = 1; // expected-error {{initializer on function does not look like a pure-specifier}}
+ void j() = 0u; // expected-error {{initializer on function does not look like a pure-specifier}}
+
+
+ void k();
+
+public:
+ A(int);
+};
+
+virtual void A::k() { } // expected-error{{'virtual' can only be specified inside the class definition}}
+
+class B : public A {
+ // Needs to recognize that overridden function is virtual.
+ void g() = 0;
+
+ // Needs to recognize that function does not override.
+ void g(int) = 0; // expected-error{{'g' is not virtual and cannot be declared pure}}
+};
+
+// Needs to recognize invalid uses of abstract classes.
+A fn(A) // expected-error{{parameter type 'A' is an abstract class}} \
+ // expected-error{{return type 'A' is an abstract class}}
+{
+ A a; // expected-error{{variable type 'A' is an abstract class}}
+ (void)static_cast<A>(0);
+ try {
+ } catch(A) { // expected-error{{variable type 'A' is an abstract class}}
+ }
+}
+
+namespace rdar9670557 {
+ typedef int func(int);
+ func *a();
+ struct X {
+ virtual func f = 0;
+ virtual func (g) = 0;
+ func *h = 0;
+ };
+}
diff --git a/clang/test/SemaCXX/vla.cpp b/clang/test/SemaCXX/vla.cpp
new file mode 100644
index 0000000..d63b633
--- /dev/null
+++ b/clang/test/SemaCXX/vla.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -verify %s
+
+// PR11925
+int n;
+int (&f())[n]; // expected-error {{function declaration cannot have variably modified type}}
diff --git a/clang/test/SemaCXX/vtable-instantiation.cc b/clang/test/SemaCXX/vtable-instantiation.cc
new file mode 100644
index 0000000..2a1b989
--- /dev/null
+++ b/clang/test/SemaCXX/vtable-instantiation.cc
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR8640 {
+ template<class T1> struct C1 {
+ virtual void c1() {
+ T1 t1 = 3; // expected-error {{cannot initialize a variable}}
+ }
+ };
+
+ template<class T2> struct C2 {
+ void c2() {
+ new C1<T2>(); // expected-note {{in instantiation of member function}}
+ }
+ };
+
+ void f() {
+ C2<int*> c2;
+ c2.c2(); // expected-note {{in instantiation of member function}}
+ }
+}
+
+namespace PR9325 {
+ template<typename T>
+ class Target
+ {
+ public:
+ virtual T Value() const
+ {
+ return 1; // expected-error{{cannot initialize return object of type 'int *' with an rvalue of type 'int'}}
+ }
+ };
+
+ template<typename T>
+ struct Provider
+ {
+ static Target<T> Instance;
+ };
+
+ template<typename T>
+ Target<T> Provider<T>::Instance; // expected-note{{in instantiation of}}
+
+ void f()
+ {
+ Target<int*>* traits = &Provider<int*>::Instance;
+ }
+}
+
+namespace PR10020 {
+ struct MG {
+ virtual void Accept(int) = 0;
+ };
+
+ template <typename Type>
+ struct GMG : MG {
+ void Accept(int i) {
+ static_cast<Type *>(0)->Accept(i); // expected-error{{member reference base}}
+ }
+ static GMG* Method() { return &singleton; } // expected-note{{in instantiation of}}
+ static GMG singleton;
+ };
+
+ template <typename Type>
+ GMG<Type> GMG<Type>::singleton;
+
+ void test(void) {
+ GMG<int>::Method(); // expected-note{{in instantiation of}}
+ }
+}
diff --git a/clang/test/SemaCXX/warn-assignment-condition.cpp b/clang/test/SemaCXX/warn-assignment-condition.cpp
new file mode 100644
index 0000000..04f2e79
--- /dev/null
+++ b/clang/test/SemaCXX/warn-assignment-condition.cpp
@@ -0,0 +1,146 @@
+// RUN: %clang_cc1 -fsyntax-only -Wparentheses -verify %s
+
+struct A {
+ int foo();
+ friend A operator+(const A&, const A&);
+ A operator|=(const A&);
+ operator bool();
+};
+
+void test() {
+ int x, *p;
+ A a, b;
+
+ // With scalars.
+ if (x = 7) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ if ((x = 7)) {}
+ do {
+ } while (x = 7); // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ do {
+ } while ((x = 7));
+ while (x = 7) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+
+ while ((x = 7)) {}
+ for (; x = 7; ) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ for (; (x = 7); ) {}
+
+ if (p = p) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ if ((p = p)) {}
+ do {
+ } while (p = p); // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ do {
+ } while ((p = p));
+ while (p = p) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ while ((p = p)) {}
+ for (; p = p; ) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ for (; (p = p); ) {}
+
+ // Initializing variables (shouldn't warn).
+ if (int y = x) {}
+ while (int y = x) {}
+ if (A y = a) {}
+ while (A y = a) {}
+
+ // With temporaries.
+ if (x = (b+b).foo()) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ if ((x = (b+b).foo())) {}
+ do {
+ } while (x = (b+b).foo()); // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ do {
+ } while ((x = (b+b).foo()));
+ while (x = (b+b).foo()) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ while ((x = (b+b).foo())) {}
+ for (; x = (b+b).foo(); ) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ for (; (x = (b+b).foo()); ) {}
+
+ // With a user-defined operator.
+ if (a = b + b) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ if ((a = b + b)) {}
+ do {
+ } while (a = b + b); // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ do {
+ } while ((a = b + b));
+ while (a = b + b) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ while ((a = b + b)) {}
+ for (; a = b + b; ) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ for (; (a = b + b); ) {}
+
+ // Compound assignments.
+ if (x |= 2) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '!=' to turn this compound assignment into an inequality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+
+ if (a |= b) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '!=' to turn this compound assignment into an inequality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+
+ if ((x == 5)) {} // expected-warning {{equality comparison with extraneous parentheses}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}} \
+ // expected-note {{remove extraneous parentheses around the comparison to silence this warning}}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wparentheses-equality"
+ if ((x == 5)) {} // no-warning
+#pragma clang diagnostic pop
+
+ if ((5 == x)) {}
+
+#define EQ(x,y) ((x) == (y))
+ if (EQ(x, 5)) {}
+#undef EQ
+}
+
+void (*fn)();
+
+void test2() {
+ if ((fn == test2)) {} // expected-warning {{equality comparison with extraneous parentheses}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}} \
+ // expected-note {{remove extraneous parentheses around the comparison to silence this warning}}
+ if ((test2 == fn)) {}
+}
+
+namespace rdar9027658 {
+template <typename T>
+void f() {
+ if ((T::g == 3)) { } // expected-warning {{equality comparison with extraneous parentheses}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}} \
+ // expected-note {{remove extraneous parentheses around the comparison to silence this warning}}
+}
+
+struct S { int g; };
+void test() {
+ f<S>(); // expected-note {{in instantiation}}
+}
+}
diff --git a/clang/test/SemaCXX/warn-bad-memaccess.cpp b/clang/test/SemaCXX/warn-bad-memaccess.cpp
new file mode 100644
index 0000000..3a02c84
--- /dev/null
+++ b/clang/test/SemaCXX/warn-bad-memaccess.cpp
@@ -0,0 +1,117 @@
+// RUN: %clang_cc1 -fsyntax-only -Wdynamic-class-memaccess -verify %s
+
+extern "C" void *memset(void *, int, unsigned);
+extern "C" void *memmove(void *s1, const void *s2, unsigned n);
+extern "C" void *memcpy(void *s1, const void *s2, unsigned n);
+extern "C" void *memcmp(void *s1, const void *s2, unsigned n);
+
+// Several types that should not warn.
+struct S1 {} s1;
+struct S2 { int x; } s2;
+struct S3 { float x, y; S1 s[4]; void (*f)(S1**); } s3;
+
+class C1 {
+ int x, y, z;
+public:
+ void foo() {}
+} c1;
+
+struct X1 { virtual void f(); } x1;
+struct X2 : virtual S1 {} x2;
+
+void test_warn() {
+ memset(&x1, 0, sizeof x1); // \
+ // expected-warning {{destination for this 'memset' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ memset(&x2, 0, sizeof x2); // \
+ // expected-warning {{destination for this 'memset' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+
+ memmove(&x1, 0, sizeof x1); // \
+ // expected-warning{{destination for this 'memmove' call is a pointer to dynamic class 'struct X1'; vtable pointer will be overwritten}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ memmove(0, &x1, sizeof x1); // \
+ // expected-warning{{source of this 'memmove' call is a pointer to dynamic class 'struct X1'; vtable pointer will be moved}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ memcpy(&x1, 0, sizeof x1); // \
+ // expected-warning{{destination for this 'memcpy' call is a pointer to dynamic class 'struct X1'; vtable pointer will be overwritten}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ memcpy(0, &x1, sizeof x1); // \
+ // expected-warning{{source of this 'memcpy' call is a pointer to dynamic class 'struct X1'; vtable pointer will be copied}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ memcmp(&x1, 0, sizeof x1); // \
+ // expected-warning{{first operand of this 'memcmp' call is a pointer to dynamic class 'struct X1'; vtable pointer will be compared}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ memcmp(0, &x1, sizeof x1); // \
+ // expected-warning{{second operand of this 'memcmp' call is a pointer to dynamic class 'struct X1'; vtable pointer will be compared}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+
+ __builtin_memset(&x1, 0, sizeof x1); // \
+ // expected-warning {{destination for this '__builtin_memset' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ __builtin_memset(&x2, 0, sizeof x2); // \
+ // expected-warning {{destination for this '__builtin_memset' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+
+ __builtin_memmove(&x1, 0, sizeof x1); // \
+ // expected-warning{{destination for this '__builtin_memmove' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ __builtin_memmove(0, &x1, sizeof x1); // \
+ // expected-warning{{source of this '__builtin_memmove' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ __builtin_memcpy(&x1, 0, sizeof x1); // \
+ // expected-warning{{destination for this '__builtin_memcpy' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ __builtin_memcpy(0, &x1, sizeof x1); // \
+ // expected-warning{{source of this '__builtin_memcpy' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+
+ __builtin___memset_chk(&x1, 0, sizeof x1, sizeof x1); // \
+ // expected-warning {{destination for this '__builtin___memset_chk' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ __builtin___memset_chk(&x2, 0, sizeof x2, sizeof x2); // \
+ // expected-warning {{destination for this '__builtin___memset_chk' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+
+ __builtin___memmove_chk(&x1, 0, sizeof x1, sizeof x1); // \
+ // expected-warning{{destination for this '__builtin___memmove_chk' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ __builtin___memmove_chk(0, &x1, sizeof x1, sizeof x1); // \
+ // expected-warning{{source of this '__builtin___memmove_chk' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ __builtin___memcpy_chk(&x1, 0, sizeof x1, sizeof x1); // \
+ // expected-warning{{destination for this '__builtin___memcpy_chk' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ __builtin___memcpy_chk(0, &x1, sizeof x1, sizeof x1); // \
+ // expected-warning{{source of this '__builtin___memcpy_chk' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+}
+
+void test_nowarn(void *void_ptr) {
+ int i, *iptr;
+ float y;
+ char c;
+
+ memset(&i, 0, sizeof i);
+ memset(&iptr, 0, sizeof iptr);
+ memset(&y, 0, sizeof y);
+ memset(&c, 0, sizeof c);
+ memset(void_ptr, 0, 42);
+ memset(&s1, 0, sizeof s1);
+ memset(&s2, 0, sizeof s2);
+ memset(&s3, 0, sizeof s3);
+ memset(&c1, 0, sizeof c1);
+
+ // Unevaluated code shouldn't warn.
+ (void)sizeof memset(&x1, 0, sizeof x1);
+
+ // Dead code shouldn't warn.
+ if (false) memset(&x1, 0, sizeof x1);
+}
+
+namespace N {
+ void *memset(void *, int, unsigned);
+ void test_nowarn() {
+ N::memset(&x1, 0, sizeof x1);
+ }
+}
diff --git a/clang/test/SemaCXX/warn-bool-conversion.cpp b/clang/test/SemaCXX/warn-bool-conversion.cpp
new file mode 100644
index 0000000..b3d136e
--- /dev/null
+++ b/clang/test/SemaCXX/warn-bool-conversion.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int* j = false; // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}}
+
+void foo(int* i, int *j=(false)) // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}}
+{
+ foo(false); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}}
+ foo((int*)false); // no-warning: explicit cast
+ foo(0); // no-warning: not a bool, even though its convertible to bool
+
+ foo(false == true); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}}
+ foo((42 + 24) < 32); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}}
+
+ const bool kFlag = false;
+ foo(kFlag); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}}
+}
+
+char f(struct Undefined*);
+double f(...);
+
+// Ensure that when using false in metaprogramming machinery its conversion
+// isn't flagged.
+template <int N> struct S {};
+S<sizeof(f(false))> s;
diff --git a/clang/test/SemaCXX/warn-cast-align.cpp b/clang/test/SemaCXX/warn-cast-align.cpp
new file mode 100644
index 0000000..68acbdd
--- /dev/null
+++ b/clang/test/SemaCXX/warn-cast-align.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -Wcast-align -verify %s
+
+// Simple casts.
+void test0(char *P) {
+ char *a; short *b; int *c;
+
+ a = (char*) P;
+ a = static_cast<char*>(P);
+ a = reinterpret_cast<char*>(P);
+ typedef char *CharPtr;
+ a = CharPtr(P);
+
+ b = (short*) P; // expected-warning {{cast from 'char *' to 'short *' increases required alignment from 1 to 2}}
+ b = reinterpret_cast<short*>(P);
+ typedef short *ShortPtr;
+ b = ShortPtr(P); // expected-warning {{cast from 'char *' to 'ShortPtr' (aka 'short *') increases required alignment from 1 to 2}}
+
+ c = (int*) P; // expected-warning {{cast from 'char *' to 'int *' increases required alignment from 1 to 4}}
+ c = reinterpret_cast<int*>(P);
+ typedef int *IntPtr;
+ c = IntPtr(P); // expected-warning {{cast from 'char *' to 'IntPtr' (aka 'int *') increases required alignment from 1 to 4}}
+}
+
+// Casts from void* are a special case.
+void test1(void *P) {
+ char *a; short *b; int *c;
+
+ a = (char*) P;
+ a = static_cast<char*>(P);
+ a = reinterpret_cast<char*>(P);
+ typedef char *CharPtr;
+ a = CharPtr(P);
+
+ b = (short*) P;
+ b = static_cast<short*>(P);
+ b = reinterpret_cast<short*>(P);
+ typedef short *ShortPtr;
+ b = ShortPtr(P);
+
+ c = (int*) P;
+ c = static_cast<int*>(P);
+ c = reinterpret_cast<int*>(P);
+ typedef int *IntPtr;
+ c = IntPtr(P);
+}
diff --git a/clang/test/SemaCXX/warn-char-subscripts.cpp b/clang/test/SemaCXX/warn-char-subscripts.cpp
new file mode 100644
index 0000000..84ea536
--- /dev/null
+++ b/clang/test/SemaCXX/warn-char-subscripts.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -Wchar-subscripts -fsyntax-only -verify %s
+
+template<typename T>
+void t1() {
+ int array[1] = { 0 };
+ T subscript = 0;
+ int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}}
+}
+
+template<typename T>
+void t2() {
+ int array[1] = { 0 };
+ T subscript = 0;
+ int val = subscript[array]; // expected-warning{{array subscript is of type 'char'}}
+}
+
+void test() {
+ t1<char>(); // expected-note {{in instantiation of function template specialization 't1<char>' requested here}}
+ t2<char>(); // expected-note {{in instantiation of function template specialization 't2<char>' requested here}}
+}
+
diff --git a/clang/test/SemaCXX/warn-dangling-field.cpp b/clang/test/SemaCXX/warn-dangling-field.cpp
new file mode 100644
index 0000000..95f8c61
--- /dev/null
+++ b/clang/test/SemaCXX/warn-dangling-field.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -Wdangling-field -verify %s
+
+struct X {
+ X(int);
+};
+struct Y {
+ operator X*();
+ operator X&();
+};
+
+struct S {
+ int &x, *y; // expected-note {{reference member declared here}} \
+ // expected-note {{pointer member declared here}}
+ S(int i)
+ : x(i), // expected-warning {{binding reference member 'x' to stack allocated parameter 'i'}}
+ y(&i) {} // expected-warning {{initializing pointer member 'y' with the stack address of parameter 'i'}}
+ S(int &i) : x(i), y(&i) {} // no-warning: reference parameter
+ S(int *i) : x(*i), y(i) {} // no-warning: pointer parameter
+};
+
+struct S2 {
+ const X &x; // expected-note {{reference member declared here}}
+ S2(int i) : x(i) {} // expected-warning {{binding reference member 'x' to a temporary}}
+};
+
+struct S3 {
+ X &x1, *x2;
+ S3(Y y) : x1(y), x2(y) {} // no-warning: conversion operator
+};
+
+template <typename T> struct S4 {
+ T x; // expected-note {{reference member declared here}}
+ S4(int i) : x(i) {} // expected-warning {{binding reference member 'x' to stack allocated parameter 'i'}}
+};
+
+template struct S4<int>; // no warning from this instantiation
+template struct S4<int&>; // expected-note {{in instantiation}}
diff --git a/clang/test/SemaCXX/warn-deprecated-header.cpp b/clang/test/SemaCXX/warn-deprecated-header.cpp
new file mode 100644
index 0000000..f6ac2cb
--- /dev/null
+++ b/clang/test/SemaCXX/warn-deprecated-header.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -fdeprecated-macro -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Werror %s
+
+#ifdef __DEPRECATED
+#warning This file is deprecated. // expected-warning {{This file is deprecated.}}
+#endif
diff --git a/clang/test/SemaCXX/warn-empty-body.cpp b/clang/test/SemaCXX/warn-empty-body.cpp
new file mode 100644
index 0000000..d643ced
--- /dev/null
+++ b/clang/test/SemaCXX/warn-empty-body.cpp
@@ -0,0 +1,271 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+void a(int i);
+int b();
+int c();
+
+void test1(int x, int y) {
+ while(true) {
+ if (x); // expected-warning {{if statement has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+
+ int i;
+ // PR11329
+ for (i = 0; i < x; i++); { // expected-warning{{for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+ b();
+ }
+
+ for (i = 0; i < x; i++); // expected-warning{{for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ {
+ a(i);
+ }
+
+ for (i = 0;
+ i < x;
+ i++); // expected-warning{{for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ {
+ a(i);
+ }
+
+ int arr[3] = { 1, 2, 3 };
+ for (int j : arr); // expected-warning{{range-based for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+
+ for (int j :
+ arr); // expected-warning{{range-based for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+
+ while (b() == 0); // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+
+ while (b() == 0); { // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+ }
+
+ while (b() == 0); // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ {
+ a(i);
+ }
+
+ while (b() == 0 ||
+ c() == 0); // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ {
+ a(i);
+ }
+
+ do; // expected-note{{to match this 'do'}}
+ b(); // expected-error{{expected 'while' in do/while loop}}
+ while (b()); // no-warning
+ c();
+
+ do; // expected-note{{to match this 'do'}}
+ b(); // expected-error{{expected 'while' in do/while loop}}
+ while (b()); // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ c();
+
+ switch(x) // no-warning
+ {
+ switch(y); // expected-warning{{switch statement has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ {
+ case 0:
+ a(10);
+ break;
+ default:
+ a(20);
+ break;
+ }
+ }
+ }
+}
+
+/// There should be no warning when null statement is placed on its own line.
+void test2(int x, int y) {
+ if (x) // no-warning
+ ; // no-warning
+
+ int i;
+ for (i = 0; i < x; i++) // no-warning
+ ; // no-warning
+
+ for (i = 0;
+ i < x;
+ i++) // no-warning
+ ; // no-warning
+
+ int arr[3] = { 1, 2, 3 };
+ for (int j : arr) // no-warning
+ ; // no-warning
+
+ while (b() == 0) // no-warning
+ ; // no-warning
+
+ while (b() == 0 ||
+ c() == 0) // no-warning
+ ; // no-warning
+
+ switch(x)
+ {
+ switch(y) // no-warning
+ ; // no-warning
+ }
+
+ // Last `for' or `while' statement in compound statement shouldn't warn.
+ while(b() == 0); // no-warning
+}
+
+/// There should be no warning for a null statement resulting from an empty macro.
+#define EMPTY(a)
+void test3(int x, int y) {
+ if (x) EMPTY(x); // no-warning
+
+ int i;
+ for (i = 0; i < x; i++) EMPTY(i); // no-warning
+
+ for (i = 0;
+ i < x;
+ i++) EMPTY(i); // no-warning
+
+ int arr[3] = { 1, 2, 3 };
+ for (int j : arr) EMPTY(j); // no-warning
+
+ for (int j :
+ arr) EMPTY(j); // no-warning
+
+ while (b() == 0) EMPTY(i); // no-warning
+
+ while (b() == 0 ||
+ c() == 0) EMPTY(i); // no-warning
+
+ switch (x) {
+ switch (y)
+ EMPTY(i); // no-warning
+ }
+}
+
+void test4(int x)
+{
+ // Idiom used in some metaprogramming constructs.
+ switch (x) default:; // no-warning
+
+ // Frequent idiom used in macros.
+ do {} while (false); // no-warning
+}
+
+/// There should be no warning for a common for/while idiom when it is obvious
+/// from indentation that next statement wasn't meant to be a body.
+void test5(int x, int y) {
+ int i;
+ for (i = 0; i < x; i++); // expected-warning{{for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+
+ for (i = 0; i < x; i++); // no-warning
+ a(i);
+
+ for (i = 0;
+ i < x;
+ i++); // expected-warning{{for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+
+ for (i = 0;
+ i < x;
+ i++); // no-warning
+ a(i);
+
+ while (b() == 0); // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+
+ while (b() == 0); // no-warning
+ a(i);
+
+ while (b() == 0 ||
+ c() == 0); // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+
+ while (b() == 0 ||
+ c() == 0); // no-warning
+ a(i);
+}
+
+/// There should be no warning for a statement with a non-null body.
+void test6(int x, int y) {
+ if (x) {} // no-warning
+
+ if (x)
+ a(x); // no-warning
+
+ int i;
+ for (i = 0; i < x; i++) // no-warning
+ a(i); // no-warning
+
+ for (i = 0; i < x; i++) { // no-warning
+ a(i); // no-warning
+ }
+
+ for (i = 0;
+ i < x;
+ i++) // no-warning
+ a(i); // no-warning
+
+ int arr[3] = { 1, 2, 3 };
+ for (int j : arr) // no-warning
+ a(j);
+
+ for (int j : arr) {} // no-warning
+
+ while (b() == 0) // no-warning
+ a(i); // no-warning
+
+ while (b() == 0) {} // no-warning
+
+ switch(x) // no-warning
+ {
+ switch(y) // no-warning
+ {
+ case 0:
+ a(10);
+ break;
+ default:
+ a(20);
+ break;
+ }
+ }
+}
+
+void test_errors(int x) {
+ if (1)
+ aa; // expected-error{{use of undeclared identifier}}
+ // no empty body warning.
+
+ int i;
+ for (i = 0; i < x; i++)
+ bb; // expected-error{{use of undeclared identifier}}
+
+ int arr[3] = { 1, 2, 3 };
+ for (int j : arr)
+ cc; // expected-error{{use of undeclared identifier}}
+
+ while (b() == 0)
+ dd; // expected-error{{use of undeclared identifier}}
+}
+
+// Warnings for statements in templates shouldn't be duplicated for all
+// instantiations.
+template <typename T>
+void test_template(int x) {
+ if (x); // expected-warning{{if statement has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+
+ if (x)
+ EMPTY(x); // no-warning
+
+ int arr[3] = { 1, 2, 3 };
+ for (int j : arr); // expected-warning{{range-based for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+
+ while (b() == 0); // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(x);
+}
+
+void test_template_inst(int x) {
+ test_template<int>(x);
+ test_template<double>(x);
+}
+
diff --git a/clang/test/SemaCXX/warn-enum-compare.cpp b/clang/test/SemaCXX/warn-enum-compare.cpp
new file mode 100644
index 0000000..52639e7
--- /dev/null
+++ b/clang/test/SemaCXX/warn-enum-compare.cpp
@@ -0,0 +1,212 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+enum Foo { FooA, FooB, FooC };
+enum Bar { BarD, BarE, BarF };
+enum { AnonAA = 42, AnonAB = 43 };
+enum { AnonBA = 44, AnonBB = 45 };
+
+namespace name1 {
+ enum Foo {F1, F2, F3};
+ enum Baz {B1, B2, B3};
+}
+
+namespace name2 {
+ enum Baz {B1, B2, B3};
+}
+
+using name1::Baz;
+using name1::B1;
+using name2::B2;
+typedef name1::Foo oneFoo;
+typedef name1::Foo twoFoo;
+Foo getFoo();
+Bar getBar();
+
+void test () {
+ Foo x = FooA;
+ Bar y = BarD;
+ Baz z = name1::B3;
+ name1::Foo a;
+ oneFoo b;
+ twoFoo c;
+
+ while (x == FooA);
+ while (y == BarD);
+ while (a == name1::F1);
+ while (z == name1::B2);
+ while (a == b);
+ while (a == c);
+ while (b == c);
+ while (B1 == name1::B2);
+ while (B2 == name2::B1);
+ while (x == AnonAA);
+ while (AnonBB == y);
+ while (AnonAA == AnonAB);
+ while (AnonAB == AnonBA);
+ while (AnonBB == AnonAA);
+
+ while ((x) == FooA);
+ while ((y) == BarD);
+ while ((a) == name1::F1);
+ while (z == (name1::B2));
+ while (a == (b));
+ while (a == (c));
+ while ((b) == (c));
+ while ((B1) == (name1::B2));
+ while ((B2) == (name2::B1));
+
+ while (((x)) == FooA);
+ while ((y) == (BarD));
+ while ((a) == (name1::F1));
+ while (z == (name1::B2));
+ while ((a) == ((((b)))));
+ while (((a)) == (c));
+ while ((b) == (((c))));
+ while ((((((B1))))) == (((name1::B2))));
+ while (B2 == ((((((name2::B1)))))));
+
+ while (B1 == B2); // expected-warning {{comparison of two values with different enumeration types ('name1::Baz' and 'name2::Baz')}}
+ while (name1::B2 == name2::B3); // expected-warning {{comparison of two values with different enumeration types ('name1::Baz' and 'name2::Baz')}}
+ while (z == name2::B2); // expected-warning {{comparison of two values with different enumeration types ('name1::Baz' and 'name2::Baz')}}
+
+ while (((((B1)))) == B2); // expected-warning {{comparison of two values with different enumeration types ('name1::Baz' and 'name2::Baz')}}
+ while (name1::B2 == (name2::B3)); // expected-warning {{comparison of two values with different enumeration types ('name1::Baz' and 'name2::Baz')}}
+ while (z == ((((name2::B2))))); // expected-warning {{comparison of two values with different enumeration types ('name1::Baz' and 'name2::Baz')}}
+
+ while ((((B1))) == (((B2)))); // expected-warning {{comparison of two values with different enumeration types ('name1::Baz' and 'name2::Baz')}}
+ while ((name1::B2) == (((name2::B3)))); // expected-warning {{comparison of two values with different enumeration types ('name1::Baz' and 'name2::Baz')}}
+ while ((((z))) == (name2::B2)); // expected-warning {{comparison of two values with different enumeration types ('name1::Baz' and 'name2::Baz')}}
+
+ while (x == a); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'name1::Foo')}}
+ while (x == b); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'oneFoo' (aka 'name1::Foo'))}}
+ while (x == c); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'twoFoo' (aka 'name1::Foo'))}}
+
+ while (x == y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (x != y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (x >= y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (x <= y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (x > y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (x < y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+
+ while (FooB == y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (FooB != y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (FooB >= y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (FooB <= y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (FooB > y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (FooB < y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+
+ while (FooB == BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (FooB != BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (FooB >= BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (FooB <= BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (FooB > BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (FooB < BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+
+ while (x == BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (x != BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (x >= BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (x <= BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (x > BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (x < BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+
+ while (getFoo() == y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (getFoo() != y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (getFoo() >= y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (getFoo() <= y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (getFoo() > y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (getFoo() < y); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+
+ while (getFoo() == BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (getFoo() != BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (getFoo() >= BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (getFoo() <= BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (getFoo() > BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (getFoo() < BarD); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+
+ while (getFoo() == getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (getFoo() != getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (getFoo() >= getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (getFoo() <= getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (getFoo() > getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (getFoo() < getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+
+ while (FooB == getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (FooB != getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (FooB >= getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (FooB <= getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (FooB > getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (FooB < getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+
+ while (x == getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (x != getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (x >= getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (x <= getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (x > getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+ while (x < getBar()); // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+
+
+
+ while (y == x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (y != x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (y >= x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (y <= x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (y > x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (y < x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+
+ while (y == FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (y != FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (y >= FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (y <= FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (y > FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (y < FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+
+ while (BarD == FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (BarD != FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (BarD >= FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (BarD <= FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (BarD > FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (BarD <FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+
+ while (BarD == x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (BarD != x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (BarD >= x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (BarD <= x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (BarD < x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (BarD > x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+
+ while (y == getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (y != getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (y >= getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (y <= getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (y > getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (y < getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+
+ while (BarD == getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (BarD != getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (BarD >= getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (BarD <= getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (BarD > getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (BarD < getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+
+ while (getBar() == getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (getBar() != getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (getBar() >= getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (getBar() <= getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (getBar() > getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (getBar() < getFoo()); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+
+ while (getBar() == FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (getBar() != FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (getBar() >= FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (getBar() <= FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (getBar() > FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (getBar() < FooB); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+
+ while (getBar() == x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (getBar() != x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (getBar() >= x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (getBar() <= x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (getBar() > x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+ while (getBar() < x); // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+
+}
diff --git a/clang/test/SemaCXX/warn-everthing.cpp b/clang/test/SemaCXX/warn-everthing.cpp
new file mode 100644
index 0000000..ad3dd8a
--- /dev/null
+++ b/clang/test/SemaCXX/warn-everthing.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -Weverything -fsyntax-only %s -verify
+
+// This previously crashed due to a bug in the CFG. Exercising all
+// warnings helps check CFG construction.
+class PR12271 {
+public:
+ PR12271();
+ ~PR12271();
+};
+
+void testPR12271() { // expected-warning {{no previous prototype for function 'testPR12271'}}
+ PR12271 a[1][1]; // expected-warning {{unused variable 'a'}}
+}
diff --git a/clang/test/SemaCXX/warn-exit-time-destructors.cpp b/clang/test/SemaCXX/warn-exit-time-destructors.cpp
new file mode 100644
index 0000000..f49134b
--- /dev/null
+++ b/clang/test/SemaCXX/warn-exit-time-destructors.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -Wexit-time-destructors %s -verify
+
+namespace test1 {
+ struct A { ~A(); };
+ A a; // expected-warning {{declaration requires an exit-time destructor}}
+ A b[10]; // expected-warning {{declaration requires an exit-time destructor}}
+ A c[10][10]; // expected-warning {{declaration requires an exit-time destructor}}
+
+ A &d = a;
+ A &e = b[5];
+ A &f = c[5][7];
+}
+
+namespace test2 {
+void f() {
+ struct A { ~A() { } };
+
+ static A a; // expected-warning {{declaration requires an exit-time destructor}}
+ static A b[10]; // expected-warning {{declaration requires an exit-time destructor}}
+ static A c[10][10]; // expected-warning {{declaration requires an exit-time destructor}}
+
+ static A &d = a;
+ static A &e = b[5];
+ static A &f = c[5][7];
+}
+
+}
diff --git a/clang/test/SemaCXX/warn-func-as-bool.cpp b/clang/test/SemaCXX/warn-func-as-bool.cpp
new file mode 100644
index 0000000..b5df744
--- /dev/null
+++ b/clang/test/SemaCXX/warn-func-as-bool.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -x c++ -verify -fsyntax-only %s
+
+void f1();
+
+struct S {
+ static void f2();
+};
+
+extern void f3() __attribute__((weak_import));
+
+struct S2 {
+ static void f4() __attribute__((weak_import));
+};
+
+bool f5();
+bool f6(int);
+
+void bar() {
+ bool b;
+
+ b = f1; // expected-warning {{address of function 'f1' will always evaluate to 'true'}} \
+ expected-note {{prefix with the address-of operator to silence this warning}}
+ if (f1) {} // expected-warning {{address of function 'f1' will always evaluate to 'true'}} \
+ expected-note {{prefix with the address-of operator to silence this warning}}
+ b = S::f2; // expected-warning {{address of function 'S::f2' will always evaluate to 'true'}} \
+ expected-note {{prefix with the address-of operator to silence this warning}}
+ if (S::f2) {} // expected-warning {{address of function 'S::f2' will always evaluate to 'true'}} \
+ expected-note {{prefix with the address-of operator to silence this warning}}
+ b = f5; // expected-warning {{address of function 'f5' will always evaluate to 'true'}} \
+ expected-note {{prefix with the address-of operator to silence this warning}} \
+ expected-note {{suffix with parentheses to turn this into a function call}}
+ b = f6; // expected-warning {{address of function 'f6' will always evaluate to 'true'}} \
+ expected-note {{prefix with the address-of operator to silence this warning}}
+
+ // implicit casts of weakly imported symbols are ok:
+ b = f3;
+ if (f3) {}
+ b = S2::f4;
+ if (S2::f4) {}
+}
diff --git a/clang/test/SemaCXX/warn-global-constructors.cpp b/clang/test/SemaCXX/warn-global-constructors.cpp
new file mode 100644
index 0000000..6330958
--- /dev/null
+++ b/clang/test/SemaCXX/warn-global-constructors.cpp
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -fsyntax-only -Wglobal-constructors %s -verify
+
+int opaque_int();
+
+namespace test0 {
+ // These should never require global constructors.
+ int a;
+ int b = 20;
+ float c = 5.0f;
+
+ // This global constructor is avoidable based on initialization order.
+ int d = b; // expected-warning {{global constructor}}
+
+ // These global constructors are unavoidable.
+ int e = opaque_int(); // expected-warning {{global constructor}}
+ int f = b; // expected-warning {{global constructor}}
+}
+
+namespace test1 {
+ struct A { int x; };
+ A a;
+ A b = A();
+ A c = { 10 };
+ A d = { opaque_int() }; // expected-warning {{global constructor}}
+ A e = A(A());
+ A f = A(a); // expected-warning {{global constructor}}
+ A g(a); // expected-warning {{global constructor}}
+ A h((A())); // elided
+ A i((A(A()))); // elided
+}
+
+namespace test2 {
+ struct A { A(); };
+ A a; // expected-warning {{global constructor}}
+ A b[10]; // expected-warning {{global constructor}}
+ A c[10][10]; // expected-warning {{global constructor}}
+
+ A &d = a;
+ A &e = b[5];
+ A &f = c[5][7];
+}
+
+namespace test3 {
+ struct A { ~A(); };
+ A a; // expected-warning {{global destructor}}
+ A b[10]; // expected-warning {{global destructor}}
+ A c[10][10]; // expected-warning {{global destructor}}
+
+ A &d = a;
+ A &e = b[5];
+ A &f = c[5][7];
+}
+
+namespace test4 {
+ char a[] = "hello";
+ char b[6] = "hello";
+ char c[][6] = { "hello" };
+}
+
+namespace test5 {
+ struct A { A(); };
+
+ void f1() {
+ static A a;
+ }
+ void f2() {
+ static A& a = *new A;
+ }
+}
+
+namespace test6 {
+ struct A { ~A(); };
+
+ void f1() {
+ static A a;
+ }
+ void f2() {
+ static A& a = *new A;
+ }
+}
+
+namespace pr8095 {
+ struct Foo {
+ int x;
+ Foo(int x1) : x(x1) {}
+ };
+ void foo() {
+ static Foo a(0);
+ }
+
+ struct Bar {
+ ~Bar();
+ };
+ void bar() {
+ static Bar b;
+ }
+}
diff --git a/clang/test/SemaCXX/warn-large-by-value-copy.cpp b/clang/test/SemaCXX/warn-large-by-value-copy.cpp
new file mode 100644
index 0000000..3e419ec
--- /dev/null
+++ b/clang/test/SemaCXX/warn-large-by-value-copy.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wlarge-by-value-copy=100 %s
+
+// rdar://8548050
+namespace rdar8548050 {
+
+struct S100 {
+ char x[100];
+};
+
+struct S101 {
+ char x[101];
+};
+
+S100 f100(S100 s) { return s; }
+
+S101 f101(S101 s) { return s; } // expected-warning {{return value of 'f101' is a large (101 bytes) pass-by-value object}} \
+ // expected-warning {{'s' is a large (101 bytes) pass-by-value argument}}
+
+typedef int Arr[200];
+void farr(Arr a) { }
+
+struct NonPOD {
+ char x[200];
+ virtual void m();
+};
+
+NonPOD fNonPOD(NonPOD s) { return s; }
+
+template <unsigned size>
+struct TS {
+ char x[size];
+};
+
+template <unsigned size>
+void tf(TS<size> ts) {} // expected-warning {{ts' is a large (300 bytes) pass-by-value argument}}
+
+void g() {
+ TS<300> ts;
+ tf<300>(ts); // expected-note {{instantiation}}
+}
+
+}
+
+template<typename T> class DependentPOD {
+ enum b { x };
+ b foo() { return x; }
+};
diff --git a/clang/test/SemaCXX/warn-literal-conversion.cpp b/clang/test/SemaCXX/warn-literal-conversion.cpp
new file mode 100644
index 0000000..5fcae5d
--- /dev/null
+++ b/clang/test/SemaCXX/warn-literal-conversion.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -Wliteral-conversion -verify %s
+
+void foo(int y);
+
+// Warn when a literal float or double is assigned or bound to an integer.
+void test0() {
+ // Float
+ int y0 = 1.2222F; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+ int y1 = (1.2222F); // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+ int y2 = (((1.2222F))); // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+ int y3 = 12E-1F; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+ int y4 = 1.23E1F; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+ // Double
+ int y5 = 1.2222; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+ int y6 = 12E-1; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+ int y7 = 1.23E1; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+ int y8 = (1.23E1); // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+
+ // Test assignment to an existing variable.
+ y8 = 2.22F; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+
+ // Test direct initialization.
+ int y9(1.23F); // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+
+ // Test passing a literal floating-point value to a function that takes an integer.
+ foo(1.2F); // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+
+ int y10 = -1.2F; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+
+ // -Wconversion-literal does NOT catch const values.
+ // (-Wconversion DOES catch them.)
+ static const float sales_tax_rate = .095F;
+ int z = sales_tax_rate;
+ foo(sales_tax_rate);
+
+ // Expressions, such as those that indicate rounding-down, should NOT produce warnings.
+ int x = 24 * 0.5;
+ int y = (24*60*60) * 0.25;
+ int pennies = 123.45 * 100;
+}
diff --git a/clang/test/SemaCXX/warn-memset-bad-sizeof.cpp b/clang/test/SemaCXX/warn-memset-bad-sizeof.cpp
new file mode 100644
index 0000000..e0d28da
--- /dev/null
+++ b/clang/test/SemaCXX/warn-memset-bad-sizeof.cpp
@@ -0,0 +1,145 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-sizeof-array-argument %s
+//
+extern "C" void *memset(void *, int, unsigned);
+extern "C" void *memmove(void *s1, const void *s2, unsigned n);
+extern "C" void *memcpy(void *s1, const void *s2, unsigned n);
+extern "C" void *memcmp(void *s1, const void *s2, unsigned n);
+
+struct S {int a, b, c, d;};
+typedef S* PS;
+
+struct Foo {};
+typedef const Foo& CFooRef;
+typedef const Foo CFoo;
+typedef volatile Foo VFoo;
+typedef const volatile Foo CVFoo;
+
+typedef double Mat[4][4];
+
+template <class Dest, class Source>
+inline Dest bit_cast(const Source& source) {
+ Dest dest;
+ memcpy(&dest, &source, sizeof(dest));
+ return dest;
+}
+
+// http://www.lysator.liu.se/c/c-faq/c-2.html#2-6
+void f(Mat m, const Foo& const_foo, char *buffer) {
+ S s;
+ S* ps = &s;
+ PS ps2 = &s;
+ char arr[5];
+ char* parr[5];
+ Foo foo;
+ char* heap_buffer = new char[42];
+
+ /* Should warn */
+ memset(&s, 0, sizeof(&s)); // \
+ // expected-warning {{argument to 'sizeof' in 'memset' call is the same expression as the destination}}
+ memset(ps, 0, sizeof(ps)); // \
+ // expected-warning {{argument to 'sizeof' in 'memset' call is the same expression as the destination}}
+ memset(ps2, 0, sizeof(ps2)); // \
+ // expected-warning {{argument to 'sizeof' in 'memset' call is the same expression as the destination}}
+ memset(ps2, 0, sizeof(typeof(ps2))); // \
+ // expected-warning {{argument to 'sizeof' in 'memset' call is the same pointer type}}
+ memset(ps2, 0, sizeof(PS)); // \
+ // expected-warning {{argument to 'sizeof' in 'memset' call is the same pointer type}}
+ memset(heap_buffer, 0, sizeof(heap_buffer)); // \
+ // expected-warning {{argument to 'sizeof' in 'memset' call is the same expression as the destination}}
+
+ memcpy(&s, 0, sizeof(&s)); // \
+ // expected-warning {{argument to 'sizeof' in 'memcpy' call is the same expression as the destination}}
+ memcpy(0, &s, sizeof(&s)); // \
+ // expected-warning {{argument to 'sizeof' in 'memcpy' call is the same expression as the source}}
+
+ memmove(ps, 0, sizeof(ps)); // \
+ // expected-warning {{argument to 'sizeof' in 'memmove' call is the same expression as the destination}}
+ memcmp(ps, 0, sizeof(ps)); // \
+ // expected-warning {{argument to 'sizeof' in 'memcmp' call is the same expression as the destination}}
+
+ /* Shouldn't warn */
+ memset((void*)&s, 0, sizeof(&s));
+ memset(&s, 0, sizeof(s));
+ memset(&s, 0, sizeof(S));
+ memset(&s, 0, sizeof(const S));
+ memset(&s, 0, sizeof(volatile S));
+ memset(&s, 0, sizeof(volatile const S));
+ memset(&foo, 0, sizeof(CFoo));
+ memset(&foo, 0, sizeof(VFoo));
+ memset(&foo, 0, sizeof(CVFoo));
+ memset(ps, 0, sizeof(*ps));
+ memset(ps2, 0, sizeof(*ps2));
+ memset(ps2, 0, sizeof(typeof(*ps2)));
+ memset(arr, 0, sizeof(arr));
+ memset(parr, 0, sizeof(parr));
+
+ memcpy(&foo, &const_foo, sizeof(Foo));
+ memcpy((void*)&s, 0, sizeof(&s));
+ memcpy(0, (void*)&s, sizeof(&s));
+ char *cptr;
+ memcpy(&cptr, buffer, sizeof(cptr));
+ memcpy((char*)&cptr, buffer, sizeof(cptr));
+
+ CFooRef cfoo = foo;
+ memcpy(&foo, &cfoo, sizeof(Foo));
+
+ memcpy(0, &arr, sizeof(arr));
+ typedef char Buff[8];
+ memcpy(0, &arr, sizeof(Buff));
+
+ unsigned char* puc;
+ bit_cast<char*>(puc);
+
+ float* pf;
+ bit_cast<int*>(pf);
+
+ int iarr[14];
+ memset(&iarr[0], 0, sizeof iarr);
+
+ int* iparr[14];
+ memset(&iparr[0], 0, sizeof iparr);
+
+ memset(m, 0, sizeof(Mat));
+
+ // Copy to raw buffer shouldn't warn either
+ memcpy(&foo, &arr, sizeof(Foo));
+ memcpy(&arr, &foo, sizeof(Foo));
+
+ // Shouldn't warn, and shouldn't crash either.
+ memset(({
+ if (0) {}
+ while (0) {}
+ for (;;) {}
+ &s;
+ }), 0, sizeof(s));
+}
+
+namespace ns {
+void memset(void* s, char c, int n);
+void f(int* i) {
+ memset(i, 0, sizeof(i));
+}
+}
+
+extern "C" int strncmp(const char *s1, const char *s2, unsigned n);
+extern "C" int strncasecmp(const char *s1, const char *s2, unsigned n);
+extern "C" char *strncpy(char *det, const char *src, unsigned n);
+extern "C" char *strncat(char *dst, const char *src, unsigned n);
+extern "C" char *strndup(const char *src, unsigned n);
+
+void strcpy_and_friends() {
+ const char* FOO = "<- should be an array instead";
+ const char* BAR = "<- this, too";
+
+ strncmp(FOO, BAR, sizeof(FOO)); // \
+ // expected-warning {{argument to 'sizeof' in 'strncmp' call is the same expression as the destination}}
+ strncasecmp(FOO, BAR, sizeof(FOO)); // \
+ // expected-warning {{argument to 'sizeof' in 'strncasecmp' call is the same expression as the destination}}
+
+ char buff[80];
+
+ strncpy(buff, BAR, sizeof(BAR)); // \
+ // expected-warning {{argument to 'sizeof' in 'strncpy' call is the same expression as the source}}
+ strndup(FOO, sizeof(FOO)); // \
+ // expected-warning {{argument to 'sizeof' in 'strndup' call is the same expression as the source}}
+}
diff --git a/clang/test/SemaCXX/warn-missing-noreturn.cpp b/clang/test/SemaCXX/warn-missing-noreturn.cpp
new file mode 100644
index 0000000..8072ac6
--- /dev/null
+++ b/clang/test/SemaCXX/warn-missing-noreturn.cpp
@@ -0,0 +1,125 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wmissing-noreturn -Wreturn-type
+void f() __attribute__((noreturn));
+
+template<typename T> void g(T) {
+ f();
+}
+
+template void g<int>(int);
+
+template<typename T> struct A {
+ void g() {
+ f();
+ }
+};
+
+template struct A<int>;
+
+struct B {
+ template<typename T> void g(T) {
+ f();
+ }
+};
+
+template void B::g<int>(int);
+
+// We don't want a warning here.
+struct X {
+ virtual void g() { f(); }
+};
+
+namespace test1 {
+ bool condition();
+
+ // We don't want a warning here.
+ void foo() {
+ while (condition()) {}
+ }
+}
+
+
+// <rdar://problem/7880658> - This test case previously had a false "missing return"
+// warning.
+struct R7880658 {
+ R7880658 &operator++();
+ bool operator==(const R7880658 &) const;
+ bool operator!=(const R7880658 &) const;
+};
+
+void f_R7880658(R7880658 f, R7880658 l) { // no-warning
+ for (; f != l; ++f) {
+ }
+}
+
+namespace test2 {
+
+ bool g();
+ void *h() __attribute__((noreturn));
+ void *j();
+
+ struct A {
+ void *f;
+
+ A() : f(0) { }
+ A(int) : f(h()) { } // expected-warning {{function 'A' could be declared with attribute 'noreturn'}}
+ A(char) : f(j()) { }
+ A(bool b) : f(b ? h() : j()) { }
+ };
+}
+
+namespace test3 {
+ struct A {
+ ~A();
+ };
+
+ struct B {
+ ~B() { }
+
+ A a;
+ };
+
+ struct C : A {
+ ~C() { }
+ };
+}
+
+// <rdar://problem/8875247> - Properly handle CFGs with destructors.
+struct rdar8875247 {
+ ~rdar8875247 ();
+};
+void rdar8875247_aux();
+
+int rdar8875247_test() {
+ rdar8875247 f;
+} // expected-warning{{control reaches end of non-void function}}
+
+struct rdar8875247_B {
+ rdar8875247_B();
+ ~rdar8875247_B();
+};
+
+rdar8875247_B test_rdar8875247_B() {
+ rdar8875247_B f;
+ return f;
+} // no-warning
+
+namespace PR10801 {
+ struct Foo {
+ void wibble() __attribute((__noreturn__));
+ };
+
+ struct Bar {
+ void wibble();
+ };
+
+ template <typename T> void thingy(T thing) {
+ thing.wibble();
+ }
+
+ void test() {
+ Foo f;
+ Bar b;
+ thingy(f);
+ thingy(b);
+ }
+}
diff --git a/clang/test/SemaCXX/warn-missing-prototypes.cpp b/clang/test/SemaCXX/warn-missing-prototypes.cpp
new file mode 100644
index 0000000..f7e8db3
--- /dev/null
+++ b/clang/test/SemaCXX/warn-missing-prototypes.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-prototypes %s
+
+void f() { } // expected-warning {{no previous prototype for function 'f'}}
+
+namespace NS {
+ void f() { } // expected-warning {{no previous prototype for function 'f'}}
+}
+
+namespace {
+ // Don't warn about functions in anonymous namespaces.
+ void f() { }
+}
+
+struct A {
+ // Don't warn about member functions.
+ void f() { }
+};
+
+// Don't warn about inline functions.
+inline void g() { }
+
+// Don't warn about function templates.
+template<typename> void h() { }
+
+// Don't warn when instantiating function templates.
+template void h<int>();
+
+// PR9519: don't warn about friend functions.
+class I {
+ friend void I_friend() {}
+};
+
diff --git a/clang/test/SemaCXX/warn-new-overaligned-2.cpp b/clang/test/SemaCXX/warn-new-overaligned-2.cpp
new file mode 100644
index 0000000..5505009
--- /dev/null
+++ b/clang/test/SemaCXX/warn-new-overaligned-2.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned -verify %s
+
+// This test verifies that we don't warn when the global operator new is
+// overridden. That's why we can't merge this with the other test file.
+
+void* operator new(unsigned long);
+void* operator new[](unsigned long);
+
+struct Test {
+ template <typename T>
+ struct SeparateCacheLines {
+ T data;
+ } __attribute__((aligned(256)));
+
+ SeparateCacheLines<int> high_contention_data[10];
+};
+
+void helper() {
+ Test t;
+ new Test;
+ new Test[10];
+}
diff --git a/clang/test/SemaCXX/warn-new-overaligned-3.cpp b/clang/test/SemaCXX/warn-new-overaligned-3.cpp
new file mode 100644
index 0000000..c9a57fb
--- /dev/null
+++ b/clang/test/SemaCXX/warn-new-overaligned-3.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned %s -isystem %S/Inputs -verify
+
+// This test ensures that we still get the warning even if we #include <new>
+// where the header here simulates <new>.
+#include <warn-new-overaligned-3.h>
+
+namespace test1 {
+struct Test {
+ template <typename T>
+ struct SeparateCacheLines {
+ T data;
+ } __attribute__((aligned(256)));
+
+ SeparateCacheLines<int> high_contention_data[10];
+};
+
+void helper() {
+ Test t;
+ new Test; // expected-warning {{type 'test1::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+ new Test[10]; // expected-warning {{type 'test1::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+}
+}
+
+namespace test2 {
+struct helper { int i __attribute__((aligned(256))); };
+
+struct Placement {
+ Placement() {
+ new (d) helper();
+ }
+ helper *d;
+};
+}
diff --git a/clang/test/SemaCXX/warn-new-overaligned.cpp b/clang/test/SemaCXX/warn-new-overaligned.cpp
new file mode 100644
index 0000000..42a4e35
--- /dev/null
+++ b/clang/test/SemaCXX/warn-new-overaligned.cpp
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned -verify %s
+
+namespace test1 {
+struct Test {
+ template <typename T>
+ struct SeparateCacheLines {
+ T data;
+ } __attribute__((aligned(256)));
+
+ SeparateCacheLines<int> high_contention_data[10];
+};
+
+void helper() {
+ Test t;
+ new Test; // expected-warning {{type 'test1::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+ new Test[10]; // expected-warning {{type 'test1::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+}
+}
+
+namespace test2 {
+class Test {
+ typedef int __attribute__((aligned(256))) aligned_int;
+ aligned_int high_contention_data[10];
+};
+
+void helper() {
+ Test t;
+ new Test; // expected-warning {{type 'test2::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+ new Test[10]; // expected-warning {{type 'test2::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+}
+}
+
+namespace test3 {
+struct Test {
+ template <typename T>
+ struct SeparateCacheLines {
+ T data;
+ } __attribute__((aligned(256)));
+
+ void* operator new(unsigned long) {
+ return 0;
+ }
+
+ SeparateCacheLines<int> high_contention_data[10];
+};
+
+void helper() {
+ Test t;
+ new Test;
+ new Test[10]; // expected-warning {{type 'test3::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+}
+}
+
+namespace test4 {
+struct Test {
+ template <typename T>
+ struct SeparateCacheLines {
+ T data;
+ } __attribute__((aligned(256)));
+
+ void* operator new[](unsigned long) {
+ return 0;
+ }
+
+ SeparateCacheLines<int> high_contention_data[10];
+};
+
+void helper() {
+ Test t;
+ new Test; // expected-warning {{type 'test4::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+ new Test[10];
+}
+}
diff --git a/clang/test/SemaCXX/warn-overloaded-virtual.cpp b/clang/test/SemaCXX/warn-overloaded-virtual.cpp
new file mode 100644
index 0000000..8e2b671
--- /dev/null
+++ b/clang/test/SemaCXX/warn-overloaded-virtual.cpp
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -fsyntax-only -Woverloaded-virtual -verify %s
+
+struct B1 {
+ virtual void foo(int); // expected-note {{declared here}}
+ virtual void foo(); // expected-note {{declared here}}
+};
+
+struct S1 : public B1 {
+ void foo(float); // expected-warning {{hides overloaded virtual functions}}
+};
+
+struct S2 : public B1 {
+ void foo(); // expected-note {{declared here}}
+};
+
+struct B2 {
+ virtual void foo(void*); // expected-note {{declared here}}
+};
+
+struct MS1 : public S2, public B2 {
+ virtual void foo(int); // expected-warning {{hides overloaded virtual functions}}
+};
+
+struct B3 {
+ virtual void foo(int);
+ virtual void foo();
+};
+
+struct S3 : public B3 {
+ using B3::foo;
+ void foo(float);
+};
+
+struct B4 {
+ virtual void foo();
+};
+
+struct S4 : public B4 {
+ void foo(float);
+ void foo();
+};
+
+namespace PR9182 {
+struct Base {
+ virtual void foo(int);
+};
+
+void Base::foo(int) { }
+
+struct Derived : public Base {
+ virtual void foo(int);
+ void foo(int, int);
+};
+}
+
+namespace PR9396 {
+class A {
+public:
+ virtual void f(int) {}
+};
+
+class B : public A {
+public:
+ static void f() {}
+};
+}
diff --git a/clang/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp b/clang/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp
new file mode 100644
index 0000000..ade6198
--- /dev/null
+++ b/clang/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+struct A {
+ A() { f(); } // expected-warning {{call to pure virtual member function 'f'; overrides of 'f' in subclasses are not available in the constructor of 'A'}}
+ ~A() { f(); } // expected-warning {{call to pure virtual member function 'f'; overrides of 'f' in subclasses are not available in the destructor of 'A'}}
+
+ virtual void f() = 0; // expected-note 2 {{'f' declared here}}
+};
+
+// Don't warn (or note) when calling the function on a pointer. (PR10195)
+struct B {
+ A *a;
+ B() { a->f(); };
+ ~B() { a->f(); };
+};
diff --git a/clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp b/clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
new file mode 100644
index 0000000..8c254e5
--- /dev/null
+++ b/clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
@@ -0,0 +1,132 @@
+// RUN: %clang_cc1 -fsyntax-only -Wreorder -verify %s
+
+struct BB {};
+
+struct BB1 {};
+
+class complex : public BB, BB1 {
+public:
+ complex()
+ : s2(1), // expected-warning {{field 's2' will be initialized after field 's1'}}
+ s1(1),
+ s3(3), // expected-warning {{field 's3' will be initialized after base 'BB1'}}
+ BB1(), // expected-warning {{base class 'BB1' will be initialized after base 'BB'}}
+ BB()
+ {}
+ int s1;
+ int s2;
+ int s3;
+};
+
+
+// testing virtual bases.
+
+
+struct V {
+ V();
+};
+
+struct A : public virtual V {
+ A();
+};
+
+struct B : public virtual V {
+ B();
+};
+
+struct Diamond : public A, public B {
+ Diamond() : A(), B() {}
+};
+
+
+struct C : public A, public B, private virtual V {
+ C() { }
+};
+
+
+struct D : public A, public B {
+ D() : A(), V() { } // expected-warning {{base class 'A' will be initialized after base 'V'}}
+};
+
+
+struct E : public A, public B, private virtual V {
+ E() : A(), V() { } // expected-warning {{base class 'A' will be initialized after base 'V'}}
+};
+
+
+struct A1 {
+ A1();
+};
+
+struct B1 {
+ B1();
+};
+
+struct F : public A1, public B1, private virtual V {
+ F() : A1(), V() { } // expected-warning {{base class 'A1' will be initialized after base 'V'}}
+};
+
+struct X : public virtual A, virtual V, public virtual B {
+ X(): A(), V(), B() {} // expected-warning {{base class 'A' will be initialized after base 'V'}}
+};
+
+class Anon {
+ int c; union {int a,b;}; int d;
+ Anon() : c(10), b(1), d(2) {}
+};
+class Anon2 {
+ int c; union {int a,b;}; int d;
+ Anon2() : c(2),
+ d(10), // expected-warning {{field 'd' will be initialized after field 'b'}}
+ b(1) {}
+};
+class Anon3 {
+ union {int a,b;};
+ Anon3() : b(1) {}
+};
+
+namespace T1 {
+
+struct S1 { };
+struct S2: virtual S1 { };
+struct S3 { };
+
+struct S4: virtual S3, S2 {
+ S4() : S2(), // expected-warning {{base class 'T1::S2' will be initialized after base 'T1::S3'}}
+ S3() { };
+};
+}
+
+namespace test2 {
+ struct Foo { Foo(); };
+ class A {
+ template <class T> A(T *t) :
+ y(), // expected-warning {{field 'y' will be initialized after field 'x'}}
+ x()
+ {}
+ Foo x;
+ Foo y;
+ };
+}
+
+// PR6575: this should not crash
+namespace test3 {
+ struct MyClass {
+ MyClass() : m_int(0) {}
+ union {
+ struct {
+ int m_int;
+ };
+ };
+ };
+}
+
+namespace PR7179 {
+ struct X
+ {
+ struct Y
+ {
+ template <class T> Y(T x) : X(x) { }
+ };
+ };
+}
diff --git a/clang/test/SemaCXX/warn-self-assign.cpp b/clang/test/SemaCXX/warn-self-assign.cpp
new file mode 100644
index 0000000..fcdb2ab
--- /dev/null
+++ b/clang/test/SemaCXX/warn-self-assign.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -Wself-assign -verify %s
+
+void f() {
+ int a = 42, b = 42;
+ a = a; // expected-warning{{explicitly assigning}}
+ b = b; // expected-warning{{explicitly assigning}}
+ a = b;
+ b = a = b;
+ a = a = a; // expected-warning{{explicitly assigning}}
+ a = b = b = a;
+}
+
+// Dummy type.
+struct S {};
+
+void false_positives() {
+#define OP =
+#define LHS a
+#define RHS a
+ int a = 42;
+ // These shouldn't warn due to the use of the preprocessor.
+ a OP a;
+ LHS = a;
+ a = RHS;
+ LHS OP RHS;
+#undef OP
+#undef LHS
+#undef RHS
+
+ S s;
+ s = s; // Not a builtin assignment operator, no warning.
+
+ // Volatile stores aren't side-effect free.
+ volatile int vol_a;
+ vol_a = vol_a;
+ volatile int &vol_a_ref = vol_a;
+ vol_a_ref = vol_a_ref;
+}
+
+template <typename T> void g() {
+ T a;
+ a = a; // May or may not be a builtin assignment operator, no warning.
+}
+void instantiate() {
+ g<int>();
+ g<S>();
+}
diff --git a/clang/test/SemaCXX/warn-self-comparisons.cpp b/clang/test/SemaCXX/warn-self-comparisons.cpp
new file mode 100644
index 0000000..620be19
--- /dev/null
+++ b/clang/test/SemaCXX/warn-self-comparisons.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f(int (&array1)[2], int (&array2)[2]) {
+ if (array1 == array2) { } // no warning
+}
diff --git a/clang/test/SemaCXX/warn-shadow.cpp b/clang/test/SemaCXX/warn-shadow.cpp
new file mode 100644
index 0000000..68e9467
--- /dev/null
+++ b/clang/test/SemaCXX/warn-shadow.cpp
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow %s
+
+namespace {
+ int i; // expected-note {{previous declaration is here}}
+}
+
+namespace one {
+namespace two {
+ int j; // expected-note {{previous declaration is here}}
+}
+}
+
+namespace xx {
+ int m;
+}
+namespace yy {
+ int m;
+}
+
+using namespace one::two;
+using namespace xx;
+using namespace yy;
+
+void foo() {
+ int i; // expected-warning {{declaration shadows a variable in namespace '<anonymous>'}}
+ int j; // expected-warning {{declaration shadows a variable in namespace 'one::two'}}
+ int m;
+}
+
+class A {
+ static int data; // expected-note {{previous declaration}}
+ int field; // expected-note {{previous declaration}}
+
+ void test() {
+ char *field; // expected-warning {{declaration shadows a field of 'A'}}
+ char *data; // expected-warning {{declaration shadows a static data member of 'A'}}
+ }
+};
+
+// TODO: this should warn, <rdar://problem/5018057>
+class B : A {
+ int data;
+ static int field;
+};
+
+// rdar://8900456
+namespace rdar8900456 {
+struct Foo {
+ static void Baz();
+private:
+ int Bar;
+};
+
+void Foo::Baz() {
+ double Bar = 12; // Don't warn.
+}
+}
+
+// http://llvm.org/PR9160
+namespace PR9160 {
+struct V {
+ V(int);
+};
+struct S {
+ V v;
+ static void m() {
+ if (1) {
+ V v(0);
+ }
+ }
+};
+}
+
+extern int bob; // expected-note {{previous declaration is here}}
+
+// rdar://8883302
+void rdar8883302() {
+ extern int bob; // don't warn for shadowing.
+}
+
+void test8() {
+ int bob; // expected-warning {{declaration shadows a variable in the global namespace}}
+}
diff --git a/clang/test/SemaCXX/warn-sign-conversion.cpp b/clang/test/SemaCXX/warn-sign-conversion.cpp
new file mode 100644
index 0000000..ba2bc9b
--- /dev/null
+++ b/clang/test/SemaCXX/warn-sign-conversion.cpp
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wsign-conversion %s
+
+// NOTE: When a 'enumeral mismatch' warning is implemented then expect several
+// of the following cases to be impacted.
+
+// namespace for anonymous enums tests
+namespace test1 {
+ enum { A };
+ enum { B = -1 };
+
+ template <typename T> struct Foo {
+ enum { C };
+ enum { D = ~0U };
+ };
+
+ enum { E = ~0U };
+
+ void doit_anonymous( int i ) {
+ int a1 = 1 ? i : A;
+ int a2 = 1 ? A : i;
+
+ int b1 = 1 ? i : B;
+ int b2 = 1 ? B : i;
+
+ int c1 = 1 ? i : Foo<bool>::C;
+ int c2 = 1 ? Foo<bool>::C : i;
+
+ int d1a = 1 ? i : Foo<bool>::D; // expected-warning {{test1::Foo<bool>::<anonymous enum at }}
+ int d1b = 1 ? i : Foo<bool>::D; // expected-warning {{warn-sign-conversion.cpp:13:5>' to 'int'}}
+ int d2a = 1 ? Foo<bool>::D : i; // expected-warning {{operand of ? changes signedness: 'test1::Foo<bool>::<anonymous enum at }}
+ int d2b = 1 ? Foo<bool>::D : i; // expected-warning {{warn-sign-conversion.cpp:13:5>' to 'int'}}
+ int d3a = 1 ? B : Foo<bool>::D; // expected-warning {{operand of ? changes signedness: 'test1::Foo<bool>::<anonymous enum at }}
+ int d3b = 1 ? B : Foo<bool>::D; // expected-warning {{warn-sign-conversion.cpp:13:5>' to 'int'}}
+ int d4a = 1 ? Foo<bool>::D : B; // expected-warning {{operand of ? changes signedness: 'test1::Foo<bool>::<anonymous enum at }}
+ int d4b = 1 ? Foo<bool>::D : B; // expected-warning {{warn-sign-conversion.cpp:13:5>' to 'int'}}
+
+ int e1a = 1 ? i : E; // expected-warning {{operand of ? changes signedness: 'test1::<anonymous enum at }}
+ int e1b = 1 ? i : E; // expected-warning {{warn-sign-conversion.cpp:16:3>' to 'int'}}
+ int e2a = 1 ? E : i; // expected-warning {{operand of ? changes signedness: 'test1::<anonymous enum at }}
+ int e2b = 1 ? E : i; // expected-warning {{warn-sign-conversion.cpp:16:3>' to 'int'}}
+ int e3a = 1 ? E : B; // expected-warning {{operand of ? changes signedness: 'test1::<anonymous enum at }}
+ int e3b = 1 ? E : B; // expected-warning {{warn-sign-conversion.cpp:16:3>' to 'int'}}
+ int e4a = 1 ? B : E; // expected-warning {{operand of ? changes signedness: 'test1::<anonymous enum at }}
+ int e4b = 1 ? B : E; // expected-warning {{warn-sign-conversion.cpp:16:3>' to 'int'}}
+ }
+}
+
+// namespace for named enums tests
+namespace test2 {
+ enum Named1 { A };
+ enum Named2 { B = -1 };
+
+ template <typename T> struct Foo {
+ enum Named3 { C };
+ enum Named4 { D = ~0U };
+ };
+
+ enum Named5 { E = ~0U };
+
+ void doit_anonymous( int i ) {
+ int a1 = 1 ? i : A;
+ int a2 = 1 ? A : i;
+
+ int b1 = 1 ? i : B;
+ int b2 = 1 ? B : i;
+
+ int c1 = 1 ? i : Foo<bool>::C;
+ int c2 = 1 ? Foo<bool>::C : i;
+
+ int d1 = 1 ? i : Foo<bool>::D; // expected-warning {{operand of ? changes signedness: 'test2::Foo<bool>::Named4' to 'int'}}
+ int d2 = 1 ? Foo<bool>::D : i; // expected-warning {{operand of ? changes signedness: 'test2::Foo<bool>::Named4' to 'int'}}
+ int d3 = 1 ? B : Foo<bool>::D; // expected-warning {{operand of ? changes signedness: 'test2::Foo<bool>::Named4' to 'int'}}
+ int d4 = 1 ? Foo<bool>::D : B; // expected-warning {{operand of ? changes signedness: 'test2::Foo<bool>::Named4' to 'int'}}
+
+ int e1 = 1 ? i : E; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}}
+ int e2 = 1 ? E : i; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}}
+ int e3 = 1 ? E : B; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}}
+ int e4 = 1 ? B : E; // expected-warning {{operand of ? changes signedness: 'test2::Named5' to 'int'}}
+ }
+}
diff --git a/clang/test/SemaCXX/warn-string-conversion.cpp b/clang/test/SemaCXX/warn-string-conversion.cpp
new file mode 100644
index 0000000..23960e4
--- /dev/null
+++ b/clang/test/SemaCXX/warn-string-conversion.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -Wstring-conversion -verify %s
+
+// Warn on cases where a string literal is converted into a bool.
+// An exception is made for this in logical operators.
+void assert(bool condition);
+void test0() {
+ bool b0 = "hi"; // expected-warning{{implicit conversion turns string literal into bool: 'const char [3]' to 'bool'}}
+ b0 = ""; // expected-warning{{implicit conversion turns string literal into bool: 'const char [1]' to 'bool'}}
+ b0 = 0 && "";
+ assert("error"); // expected-warning{{implicit conversion turns string literal into bool: 'const char [6]' to 'bool'}}
+ assert(0 && "error");
+
+ while("hi") {} // expected-warning{{implicit conversion turns string literal into bool: 'const char [3]' to 'bool'}}
+ do {} while("hi"); // expected-warning{{implicit conversion turns string literal into bool: 'const char [3]' to 'bool'}}
+ for (;"hi";); // expected-warning{{implicit conversion turns string literal into bool: 'const char [3]' to 'bool'}}
+ if("hi") {} // expected-warning{{implicit conversion turns string literal into bool: 'const char [3]' to 'bool'}}
+}
+
diff --git a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
new file mode 100644
index 0000000..566e5c1
--- /dev/null
+++ b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -0,0 +1,2243 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
+
+#define LOCKABLE __attribute__ ((lockable))
+#define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
+#define GUARDED_BY(x) __attribute__ ((guarded_by(x)))
+#define GUARDED_VAR __attribute__ ((guarded_var))
+#define PT_GUARDED_BY(x) __attribute__ ((pt_guarded_by(x)))
+#define PT_GUARDED_VAR __attribute__ ((pt_guarded_var))
+#define ACQUIRED_AFTER(...) __attribute__ ((acquired_after(__VA_ARGS__)))
+#define ACQUIRED_BEFORE(...) __attribute__ ((acquired_before(__VA_ARGS__)))
+#define EXCLUSIVE_LOCK_FUNCTION(...) __attribute__ ((exclusive_lock_function(__VA_ARGS__)))
+#define SHARED_LOCK_FUNCTION(...) __attribute__ ((shared_lock_function(__VA_ARGS__)))
+#define EXCLUSIVE_TRYLOCK_FUNCTION(...) __attribute__ ((exclusive_trylock_function(__VA_ARGS__)))
+#define SHARED_TRYLOCK_FUNCTION(...) __attribute__ ((shared_trylock_function(__VA_ARGS__)))
+#define UNLOCK_FUNCTION(...) __attribute__ ((unlock_function(__VA_ARGS__)))
+#define LOCK_RETURNED(x) __attribute__ ((lock_returned(x)))
+#define LOCKS_EXCLUDED(...) __attribute__ ((locks_excluded(__VA_ARGS__)))
+#define EXCLUSIVE_LOCKS_REQUIRED(...) \
+ __attribute__ ((exclusive_locks_required(__VA_ARGS__)))
+#define SHARED_LOCKS_REQUIRED(...) \
+ __attribute__ ((shared_locks_required(__VA_ARGS__)))
+#define NO_THREAD_SAFETY_ANALYSIS __attribute__ ((no_thread_safety_analysis))
+
+//-----------------------------------------//
+// Helper fields
+//-----------------------------------------//
+
+
+class __attribute__((lockable)) Mutex {
+ public:
+ void Lock() __attribute__((exclusive_lock_function));
+ void ReaderLock() __attribute__((shared_lock_function));
+ void Unlock() __attribute__((unlock_function));
+ bool TryLock() __attribute__((exclusive_trylock_function(true)));
+ bool ReaderTryLock() __attribute__((shared_trylock_function(true)));
+ void LockWhen(const int &cond) __attribute__((exclusive_lock_function));
+};
+
+class __attribute__((scoped_lockable)) MutexLock {
+ public:
+ MutexLock(Mutex *mu) __attribute__((exclusive_lock_function(mu)));
+ ~MutexLock() __attribute__((unlock_function));
+};
+
+class __attribute__((scoped_lockable)) ReaderMutexLock {
+ public:
+ ReaderMutexLock(Mutex *mu) __attribute__((exclusive_lock_function(mu)));
+ ~ReaderMutexLock() __attribute__((unlock_function));
+};
+
+
+Mutex sls_mu;
+
+Mutex sls_mu2 __attribute__((acquired_after(sls_mu)));
+int sls_guard_var __attribute__((guarded_var)) = 0;
+int sls_guardby_var __attribute__((guarded_by(sls_mu))) = 0;
+
+bool getBool();
+
+class MutexWrapper {
+public:
+ Mutex mu;
+ int x __attribute__((guarded_by(mu)));
+ void MyLock() __attribute__((exclusive_lock_function(mu)));
+};
+
+MutexWrapper sls_mw;
+
+void sls_fun_0() {
+ sls_mw.mu.Lock();
+ sls_mw.x = 5;
+ sls_mw.mu.Unlock();
+}
+
+void sls_fun_2() {
+ sls_mu.Lock();
+ int x = sls_guard_var;
+ sls_mu.Unlock();
+}
+
+void sls_fun_3() {
+ sls_mu.Lock();
+ sls_guard_var = 2;
+ sls_mu.Unlock();
+}
+
+void sls_fun_4() {
+ sls_mu2.Lock();
+ sls_guard_var = 2;
+ sls_mu2.Unlock();
+}
+
+void sls_fun_5() {
+ sls_mu.Lock();
+ int x = sls_guardby_var;
+ sls_mu.Unlock();
+}
+
+void sls_fun_6() {
+ sls_mu.Lock();
+ sls_guardby_var = 2;
+ sls_mu.Unlock();
+}
+
+void sls_fun_7() {
+ sls_mu.Lock();
+ sls_mu2.Lock();
+ sls_mu2.Unlock();
+ sls_mu.Unlock();
+}
+
+void sls_fun_8() {
+ sls_mu.Lock();
+ if (getBool())
+ sls_mu.Unlock();
+ else
+ sls_mu.Unlock();
+}
+
+void sls_fun_9() {
+ if (getBool())
+ sls_mu.Lock();
+ else
+ sls_mu.Lock();
+ sls_mu.Unlock();
+}
+
+void sls_fun_good_6() {
+ if (getBool()) {
+ sls_mu.Lock();
+ } else {
+ if (getBool()) {
+ getBool(); // EMPTY
+ } else {
+ getBool(); // EMPTY
+ }
+ sls_mu.Lock();
+ }
+ sls_mu.Unlock();
+}
+
+void sls_fun_good_7() {
+ sls_mu.Lock();
+ while (getBool()) {
+ sls_mu.Unlock();
+ if (getBool()) {
+ if (getBool()) {
+ sls_mu.Lock();
+ continue;
+ }
+ }
+ sls_mu.Lock();
+ }
+ sls_mu.Unlock();
+}
+
+void sls_fun_good_8() {
+ sls_mw.MyLock();
+ sls_mw.mu.Unlock();
+}
+
+void sls_fun_bad_1() {
+ sls_mu.Unlock(); // \
+ // expected-warning{{unlocking 'sls_mu' that was not locked}}
+}
+
+void sls_fun_bad_2() {
+ sls_mu.Lock();
+ sls_mu.Lock(); // \
+ // expected-warning{{locking 'sls_mu' that is already locked}}
+ sls_mu.Unlock();
+}
+
+void sls_fun_bad_3() {
+ sls_mu.Lock(); // expected-note {{mutex acquired here}}
+} // expected-warning{{mutex 'sls_mu' is still locked at the end of function}}
+
+void sls_fun_bad_4() {
+ if (getBool())
+ sls_mu.Lock(); // \
+ expected-warning{{mutex 'sls_mu2' is not locked on every path through here}} \
+ expected-note{{mutex acquired here}}
+
+ else
+ sls_mu2.Lock(); // \
+ expected-note{{mutex acquired here}}
+} // expected-warning{{mutex 'sls_mu' is not locked on every path through here}}
+
+void sls_fun_bad_5() {
+ sls_mu.Lock(); // expected-note {{mutex acquired here}}
+ if (getBool())
+ sls_mu.Unlock();
+} // expected-warning{{mutex 'sls_mu' is not locked on every path through here}}
+
+void sls_fun_bad_6() {
+ if (getBool()) {
+ sls_mu.Lock(); // expected-note {{mutex acquired here}}
+ } else {
+ if (getBool()) {
+ getBool(); // EMPTY
+ } else {
+ getBool(); // EMPTY
+ }
+ }
+ sls_mu.Unlock(); // \
+ expected-warning{{mutex 'sls_mu' is not locked on every path through here}}\
+ expected-warning{{unlocking 'sls_mu' that was not locked}}
+}
+
+void sls_fun_bad_7() {
+ sls_mu.Lock();
+ while (getBool()) {
+ sls_mu.Unlock();
+ if (getBool()) {
+ if (getBool()) {
+ continue; // \
+ expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}}
+ }
+ }
+ sls_mu.Lock(); // expected-note {{mutex acquired here}}
+ }
+ sls_mu.Unlock();
+}
+
+void sls_fun_bad_8() {
+ sls_mu.Lock(); // expected-note{{mutex acquired here}}
+
+ // FIXME: TERRIBLE SOURCE LOCATION!
+ do { // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}}
+ sls_mu.Unlock();
+ } while (getBool());
+}
+
+void sls_fun_bad_9() {
+ do {
+ sls_mu.Lock(); // \
+ // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}} \
+ // expected-note{{mutex acquired here}}
+ } while (getBool());
+ sls_mu.Unlock();
+}
+
+void sls_fun_bad_10() {
+ sls_mu.Lock(); // expected-note 2{{mutex acquired here}}
+ while(getBool()) {
+ sls_mu.Unlock(); // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}}
+ }
+} // expected-warning{{mutex 'sls_mu' is still locked at the end of function}}
+
+void sls_fun_bad_11() {
+ while (getBool()) { // \
+ expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}}
+ sls_mu.Lock(); // expected-note {{mutex acquired here}}
+ }
+ sls_mu.Unlock(); // \
+ // expected-warning{{unlocking 'sls_mu' that was not locked}}
+}
+
+void sls_fun_bad_12() {
+ sls_mu.Lock(); // expected-note {{mutex acquired here}}
+ while (getBool()) {
+ sls_mu.Unlock();
+ if (getBool()) {
+ if (getBool()) {
+ break; // expected-warning{{mutex 'sls_mu' is not locked on every path through here}}
+ }
+ }
+ sls_mu.Lock();
+ }
+ sls_mu.Unlock();
+}
+
+//-----------------------------------------//
+// Handling lock expressions in attribute args
+// -------------------------------------------//
+
+Mutex aa_mu;
+
+class GlobalLocker {
+public:
+ void globalLock() __attribute__((exclusive_lock_function(aa_mu)));
+ void globalUnlock() __attribute__((unlock_function(aa_mu)));
+};
+
+GlobalLocker glock;
+
+void aa_fun_1() {
+ glock.globalLock();
+ glock.globalUnlock();
+}
+
+void aa_fun_bad_1() {
+ glock.globalUnlock(); // \
+ // expected-warning{{unlocking 'aa_mu' that was not locked}}
+}
+
+void aa_fun_bad_2() {
+ glock.globalLock();
+ glock.globalLock(); // \
+ // expected-warning{{locking 'aa_mu' that is already locked}}
+ glock.globalUnlock();
+}
+
+void aa_fun_bad_3() {
+ glock.globalLock(); // expected-note{{mutex acquired here}}
+} // expected-warning{{mutex 'aa_mu' is still locked at the end of function}}
+
+//--------------------------------------------------//
+// Regression tests for unusual method names
+//--------------------------------------------------//
+
+Mutex wmu;
+
+// Test diagnostics for other method names.
+class WeirdMethods {
+ // FIXME: can't currently check inside constructors and destructors.
+ WeirdMethods() {
+ wmu.Lock(); // EXPECTED-NOTE {{mutex acquired here}}
+ } // EXPECTED-WARNING {{mutex 'wmu' is still locked at the end of function}}
+ ~WeirdMethods() {
+ wmu.Lock(); // EXPECTED-NOTE {{mutex acquired here}}
+ } // EXPECTED-WARNING {{mutex 'wmu' is still locked at the end of function}}
+ void operator++() {
+ wmu.Lock(); // expected-note {{mutex acquired here}}
+ } // expected-warning {{mutex 'wmu' is still locked at the end of function}}
+ operator int*() {
+ wmu.Lock(); // expected-note {{mutex acquired here}}
+ return 0;
+ } // expected-warning {{mutex 'wmu' is still locked at the end of function}}
+};
+
+//-----------------------------------------------//
+// Errors for guarded by or guarded var variables
+// ----------------------------------------------//
+
+int *pgb_gvar __attribute__((pt_guarded_var));
+int *pgb_var __attribute__((pt_guarded_by(sls_mu)));
+
+class PGBFoo {
+ public:
+ int x;
+ int *pgb_field __attribute__((guarded_by(sls_mu2)))
+ __attribute__((pt_guarded_by(sls_mu)));
+ void testFoo() {
+ pgb_field = &x; // \
+ // expected-warning {{writing variable 'pgb_field' requires locking 'sls_mu2' exclusively}}
+ *pgb_field = x; // expected-warning {{reading variable 'pgb_field' requires locking 'sls_mu2'}} \
+ // expected-warning {{writing the value pointed to by 'pgb_field' requires locking 'sls_mu' exclusively}}
+ x = *pgb_field; // expected-warning {{reading variable 'pgb_field' requires locking 'sls_mu2'}} \
+ // expected-warning {{reading the value pointed to by 'pgb_field' requires locking 'sls_mu'}}
+ (*pgb_field)++; // expected-warning {{reading variable 'pgb_field' requires locking 'sls_mu2'}} \
+ // expected-warning {{writing the value pointed to by 'pgb_field' requires locking 'sls_mu' exclusively}}
+ }
+};
+
+class GBFoo {
+ public:
+ int gb_field __attribute__((guarded_by(sls_mu)));
+
+ void testFoo() {
+ gb_field = 0; // \
+ // expected-warning {{writing variable 'gb_field' requires locking 'sls_mu' exclusively}}
+ }
+
+ void testNoAnal() __attribute__((no_thread_safety_analysis)) {
+ gb_field = 0;
+ }
+};
+
+GBFoo GlobalGBFoo __attribute__((guarded_by(sls_mu)));
+
+void gb_fun_0() {
+ sls_mu.Lock();
+ int x = *pgb_var;
+ sls_mu.Unlock();
+}
+
+void gb_fun_1() {
+ sls_mu.Lock();
+ *pgb_var = 2;
+ sls_mu.Unlock();
+}
+
+void gb_fun_2() {
+ int x;
+ pgb_var = &x;
+}
+
+void gb_fun_3() {
+ int *x = pgb_var;
+}
+
+void gb_bad_0() {
+ sls_guard_var = 1; // \
+ // expected-warning{{writing variable 'sls_guard_var' requires locking any mutex exclusively}}
+}
+
+void gb_bad_1() {
+ int x = sls_guard_var; // \
+ // expected-warning{{reading variable 'sls_guard_var' requires locking any mutex}}
+}
+
+void gb_bad_2() {
+ sls_guardby_var = 1; // \
+ // expected-warning {{writing variable 'sls_guardby_var' requires locking 'sls_mu' exclusively}}
+}
+
+void gb_bad_3() {
+ int x = sls_guardby_var; // \
+ // expected-warning {{reading variable 'sls_guardby_var' requires locking 'sls_mu'}}
+}
+
+void gb_bad_4() {
+ *pgb_gvar = 1; // \
+ // expected-warning {{writing the value pointed to by 'pgb_gvar' requires locking any mutex exclusively}}
+}
+
+void gb_bad_5() {
+ int x = *pgb_gvar; // \
+ // expected-warning {{reading the value pointed to by 'pgb_gvar' requires locking any mutex}}
+}
+
+void gb_bad_6() {
+ *pgb_var = 1; // \
+ // expected-warning {{writing the value pointed to by 'pgb_var' requires locking 'sls_mu' exclusively}}
+}
+
+void gb_bad_7() {
+ int x = *pgb_var; // \
+ // expected-warning {{reading the value pointed to by 'pgb_var' requires locking 'sls_mu'}}
+}
+
+void gb_bad_8() {
+ GBFoo G;
+ G.gb_field = 0; // \
+ // expected-warning {{writing variable 'gb_field' requires locking 'sls_mu'}}
+}
+
+void gb_bad_9() {
+ sls_guard_var++; // \
+ // expected-warning{{writing variable 'sls_guard_var' requires locking any mutex exclusively}}
+ sls_guard_var--; // \
+ // expected-warning{{writing variable 'sls_guard_var' requires locking any mutex exclusively}}
+ ++sls_guard_var; // \
+ // expected-warning{{writing variable 'sls_guard_var' requires locking any mutex exclusively}}
+ --sls_guard_var;// \
+ // expected-warning{{writing variable 'sls_guard_var' requires locking any mutex exclusively}}
+}
+
+//-----------------------------------------------//
+// Warnings on variables with late parsed attributes
+// ----------------------------------------------//
+
+class LateFoo {
+public:
+ int a __attribute__((guarded_by(mu)));
+ int b;
+
+ void foo() __attribute__((exclusive_locks_required(mu))) { }
+
+ void test() {
+ a = 0; // \
+ // expected-warning{{writing variable 'a' requires locking 'mu' exclusively}}
+ b = a; // \
+ // expected-warning {{reading variable 'a' requires locking 'mu'}}
+ c = 0; // \
+ // expected-warning {{writing variable 'c' requires locking 'mu' exclusively}}
+ }
+
+ int c __attribute__((guarded_by(mu)));
+
+ Mutex mu;
+};
+
+class LateBar {
+ public:
+ int a_ __attribute__((guarded_by(mu1_)));
+ int b_;
+ int *q __attribute__((pt_guarded_by(mu)));
+ Mutex mu1_;
+ Mutex mu;
+ LateFoo Foo;
+ LateFoo Foo2;
+ LateFoo *FooPointer;
+};
+
+LateBar b1, *b3;
+
+void late_0() {
+ LateFoo FooA;
+ LateFoo FooB;
+ FooA.mu.Lock();
+ FooA.a = 5;
+ FooA.mu.Unlock();
+}
+
+void late_1() {
+ LateBar BarA;
+ BarA.FooPointer->mu.Lock();
+ BarA.FooPointer->a = 2;
+ BarA.FooPointer->mu.Unlock();
+}
+
+void late_bad_0() {
+ LateFoo fooA;
+ LateFoo fooB;
+ fooA.mu.Lock();
+ fooB.a = 5; // \
+ // expected-warning{{writing variable 'a' requires locking 'mu' exclusively}}
+ fooA.mu.Unlock();
+}
+
+void late_bad_1() {
+ Mutex mu;
+ mu.Lock();
+ b1.mu1_.Lock();
+ int res = b1.a_ + b3->b_;
+ b3->b_ = *b1.q; // \
+ // expected-warning{{reading the value pointed to by 'q' requires locking 'mu'}}
+ b1.mu1_.Unlock();
+ b1.b_ = res;
+ mu.Unlock();
+}
+
+void late_bad_2() {
+ LateBar BarA;
+ BarA.FooPointer->mu.Lock();
+ BarA.Foo.a = 2; // \
+ // expected-warning{{writing variable 'a' requires locking 'mu' exclusively}}
+ BarA.FooPointer->mu.Unlock();
+}
+
+void late_bad_3() {
+ LateBar BarA;
+ BarA.Foo.mu.Lock();
+ BarA.FooPointer->a = 2; // \
+ // expected-warning{{writing variable 'a' requires locking 'mu' exclusively}}
+ BarA.Foo.mu.Unlock();
+}
+
+void late_bad_4() {
+ LateBar BarA;
+ BarA.Foo.mu.Lock();
+ BarA.Foo2.a = 2; // \
+ // expected-warning{{writing variable 'a' requires locking 'mu' exclusively}}
+ BarA.Foo.mu.Unlock();
+}
+
+//-----------------------------------------------//
+// Extra warnings for shared vs. exclusive locks
+// ----------------------------------------------//
+
+void shared_fun_0() {
+ sls_mu.Lock();
+ do {
+ sls_mu.Unlock();
+ sls_mu.Lock();
+ } while (getBool());
+ sls_mu.Unlock();
+}
+
+void shared_fun_1() {
+ sls_mu.ReaderLock(); // \
+ // expected-warning {{mutex 'sls_mu' is locked exclusively and shared in the same scope}}
+ do {
+ sls_mu.Unlock();
+ sls_mu.Lock(); // \
+ // expected-note {{the other lock of mutex 'sls_mu' is here}}
+ } while (getBool());
+ sls_mu.Unlock();
+}
+
+void shared_fun_3() {
+ if (getBool())
+ sls_mu.Lock();
+ else
+ sls_mu.Lock();
+ *pgb_var = 1;
+ sls_mu.Unlock();
+}
+
+void shared_fun_4() {
+ if (getBool())
+ sls_mu.ReaderLock();
+ else
+ sls_mu.ReaderLock();
+ int x = sls_guardby_var;
+ sls_mu.Unlock();
+}
+
+void shared_fun_8() {
+ if (getBool())
+ sls_mu.Lock(); // \
+ // expected-warning {{mutex 'sls_mu' is locked exclusively and shared in the same scope}}
+ else
+ sls_mu.ReaderLock(); // \
+ // expected-note {{the other lock of mutex 'sls_mu' is here}}
+ sls_mu.Unlock();
+}
+
+void shared_bad_0() {
+ sls_mu.Lock(); // \
+ // expected-warning {{mutex 'sls_mu' is locked exclusively and shared in the same scope}}
+ do {
+ sls_mu.Unlock();
+ sls_mu.ReaderLock(); // \
+ // expected-note {{the other lock of mutex 'sls_mu' is here}}
+ } while (getBool());
+ sls_mu.Unlock();
+}
+
+void shared_bad_1() {
+ if (getBool())
+ sls_mu.Lock(); // \
+ // expected-warning {{mutex 'sls_mu' is locked exclusively and shared in the same scope}}
+ else
+ sls_mu.ReaderLock(); // \
+ // expected-note {{the other lock of mutex 'sls_mu' is here}}
+ *pgb_var = 1;
+ sls_mu.Unlock();
+}
+
+void shared_bad_2() {
+ if (getBool())
+ sls_mu.ReaderLock(); // \
+ // expected-warning {{mutex 'sls_mu' is locked exclusively and shared in the same scope}}
+ else
+ sls_mu.Lock(); // \
+ // expected-note {{the other lock of mutex 'sls_mu' is here}}
+ *pgb_var = 1;
+ sls_mu.Unlock();
+}
+
+// FIXME: Add support for functions (not only methods)
+class LRBar {
+ public:
+ void aa_elr_fun() __attribute__((exclusive_locks_required(aa_mu)));
+ void aa_elr_fun_s() __attribute__((shared_locks_required(aa_mu)));
+ void le_fun() __attribute__((locks_excluded(sls_mu)));
+};
+
+class LRFoo {
+ public:
+ void test() __attribute__((exclusive_locks_required(sls_mu)));
+ void testShared() __attribute__((shared_locks_required(sls_mu2)));
+};
+
+void elr_fun() __attribute__((exclusive_locks_required(sls_mu)));
+void elr_fun() {}
+
+LRFoo MyLRFoo;
+LRBar Bar;
+
+void es_fun_0() {
+ aa_mu.Lock();
+ Bar.aa_elr_fun();
+ aa_mu.Unlock();
+}
+
+void es_fun_1() {
+ aa_mu.Lock();
+ Bar.aa_elr_fun_s();
+ aa_mu.Unlock();
+}
+
+void es_fun_2() {
+ aa_mu.ReaderLock();
+ Bar.aa_elr_fun_s();
+ aa_mu.Unlock();
+}
+
+void es_fun_3() {
+ sls_mu.Lock();
+ MyLRFoo.test();
+ sls_mu.Unlock();
+}
+
+void es_fun_4() {
+ sls_mu2.Lock();
+ MyLRFoo.testShared();
+ sls_mu2.Unlock();
+}
+
+void es_fun_5() {
+ sls_mu2.ReaderLock();
+ MyLRFoo.testShared();
+ sls_mu2.Unlock();
+}
+
+void es_fun_6() {
+ Bar.le_fun();
+}
+
+void es_fun_7() {
+ sls_mu.Lock();
+ elr_fun();
+ sls_mu.Unlock();
+}
+
+void es_fun_8() __attribute__((no_thread_safety_analysis));
+
+void es_fun_8() {
+ Bar.aa_elr_fun_s();
+}
+
+void es_fun_9() __attribute__((shared_locks_required(aa_mu)));
+void es_fun_9() {
+ Bar.aa_elr_fun_s();
+}
+
+void es_fun_10() __attribute__((exclusive_locks_required(aa_mu)));
+void es_fun_10() {
+ Bar.aa_elr_fun_s();
+}
+
+void es_bad_0() {
+ Bar.aa_elr_fun(); // \
+ // expected-warning {{calling function 'aa_elr_fun' requires exclusive lock on 'aa_mu'}}
+}
+
+void es_bad_1() {
+ aa_mu.ReaderLock();
+ Bar.aa_elr_fun(); // \
+ // expected-warning {{calling function 'aa_elr_fun' requires exclusive lock on 'aa_mu'}}
+ aa_mu.Unlock();
+}
+
+void es_bad_2() {
+ Bar.aa_elr_fun_s(); // \
+ // expected-warning {{calling function 'aa_elr_fun_s' requires shared lock on 'aa_mu'}}
+}
+
+void es_bad_3() {
+ MyLRFoo.test(); // \
+ // expected-warning {{calling function 'test' requires exclusive lock on 'sls_mu'}}
+}
+
+void es_bad_4() {
+ MyLRFoo.testShared(); // \
+ // expected-warning {{calling function 'testShared' requires shared lock on 'sls_mu2'}}
+}
+
+void es_bad_5() {
+ sls_mu.ReaderLock();
+ MyLRFoo.test(); // \
+ // expected-warning {{calling function 'test' requires exclusive lock on 'sls_mu'}}
+ sls_mu.Unlock();
+}
+
+void es_bad_6() {
+ sls_mu.Lock();
+ Bar.le_fun(); // \
+ // expected-warning {{cannot call function 'le_fun' while mutex 'sls_mu' is locked}}
+ sls_mu.Unlock();
+}
+
+void es_bad_7() {
+ sls_mu.ReaderLock();
+ Bar.le_fun(); // \
+ // expected-warning {{cannot call function 'le_fun' while mutex 'sls_mu' is locked}}
+ sls_mu.Unlock();
+}
+
+
+//-----------------------------------------------//
+// Unparseable lock expressions
+// ----------------------------------------------//
+
+// FIXME -- derive new tests for unhandled expressions
+
+
+//----------------------------------------------------------------------------//
+// The following test cases are ported from the gcc thread safety implementation
+// They are each wrapped inside a namespace with the test number of the gcc test
+//
+// FIXME: add all the gcc tests, once this analysis passes them.
+//----------------------------------------------------------------------------//
+
+//-----------------------------------------//
+// Good testcases (no errors)
+//-----------------------------------------//
+
+namespace thread_annot_lock_20 {
+class Bar {
+ public:
+ static int func1() EXCLUSIVE_LOCKS_REQUIRED(mu1_);
+ static int b_ GUARDED_BY(mu1_);
+ static Mutex mu1_;
+ static int a_ GUARDED_BY(mu1_);
+};
+
+Bar b1;
+
+int Bar::func1()
+{
+ int res = 5;
+
+ if (a_ == 4)
+ res = b_;
+ return res;
+}
+} // end namespace thread_annot_lock_20
+
+namespace thread_annot_lock_22 {
+// Test various usage of GUARDED_BY and PT_GUARDED_BY annotations, especially
+// uses in class definitions.
+Mutex mu;
+
+class Bar {
+ public:
+ int a_ GUARDED_BY(mu1_);
+ int b_;
+ int *q PT_GUARDED_BY(mu);
+ Mutex mu1_ ACQUIRED_AFTER(mu);
+};
+
+Bar b1, *b3;
+int *p GUARDED_BY(mu) PT_GUARDED_BY(mu);
+int res GUARDED_BY(mu) = 5;
+
+int func(int i)
+{
+ int x;
+ mu.Lock();
+ b1.mu1_.Lock();
+ res = b1.a_ + b3->b_;
+ *p = i;
+ b1.a_ = res + b3->b_;
+ b3->b_ = *b1.q;
+ b1.mu1_.Unlock();
+ b1.b_ = res;
+ x = res;
+ mu.Unlock();
+ return x;
+}
+} // end namespace thread_annot_lock_22
+
+namespace thread_annot_lock_27_modified {
+// test lock annotations applied to function definitions
+// Modified: applied annotations only to function declarations
+Mutex mu1;
+Mutex mu2 ACQUIRED_AFTER(mu1);
+
+class Foo {
+ public:
+ int method1(int i) SHARED_LOCKS_REQUIRED(mu2) EXCLUSIVE_LOCKS_REQUIRED(mu1);
+};
+
+int Foo::method1(int i) {
+ return i;
+}
+
+
+int foo(int i) EXCLUSIVE_LOCKS_REQUIRED(mu2) SHARED_LOCKS_REQUIRED(mu1);
+int foo(int i) {
+ return i;
+}
+
+static int bar(int i) EXCLUSIVE_LOCKS_REQUIRED(mu1);
+static int bar(int i) {
+ return i;
+}
+
+void main() {
+ Foo a;
+
+ mu1.Lock();
+ mu2.Lock();
+ a.method1(1);
+ foo(2);
+ mu2.Unlock();
+ bar(3);
+ mu1.Unlock();
+}
+} // end namespace thread_annot_lock_27_modified
+
+
+namespace thread_annot_lock_38 {
+// Test the case where a template member function is annotated with lock
+// attributes in a non-template class.
+class Foo {
+ public:
+ void func1(int y) LOCKS_EXCLUDED(mu_);
+ template <typename T> void func2(T x) LOCKS_EXCLUDED(mu_);
+ private:
+ Mutex mu_;
+};
+
+Foo *foo;
+
+void main()
+{
+ foo->func1(5);
+ foo->func2(5);
+}
+} // end namespace thread_annot_lock_38
+
+namespace thread_annot_lock_43 {
+// Tests lock canonicalization
+class Foo {
+ public:
+ Mutex *mu_;
+};
+
+class FooBar {
+ public:
+ Foo *foo_;
+ int GetA() EXCLUSIVE_LOCKS_REQUIRED(foo_->mu_) { return a_; }
+ int a_ GUARDED_BY(foo_->mu_);
+};
+
+FooBar *fb;
+
+void main()
+{
+ int x;
+ fb->foo_->mu_->Lock();
+ x = fb->GetA();
+ fb->foo_->mu_->Unlock();
+}
+} // end namespace thread_annot_lock_43
+
+namespace thread_annot_lock_49 {
+// Test the support for use of lock expression in the annotations
+class Foo {
+ public:
+ Mutex foo_mu_;
+};
+
+class Bar {
+ private:
+ Foo *foo;
+ Mutex bar_mu_ ACQUIRED_AFTER(foo->foo_mu_);
+
+ public:
+ void Test1() {
+ foo->foo_mu_.Lock();
+ bar_mu_.Lock();
+ bar_mu_.Unlock();
+ foo->foo_mu_.Unlock();
+ }
+};
+
+void main() {
+ Bar bar;
+ bar.Test1();
+}
+} // end namespace thread_annot_lock_49
+
+namespace thread_annot_lock_61_modified {
+ // Modified to fix the compiler errors
+ // Test the fix for a bug introduced by the support of pass-by-reference
+ // paramters.
+ struct Foo { Foo &operator<< (bool) {return *this;} };
+ Foo &getFoo();
+ struct Bar { Foo &func () {return getFoo();} };
+ struct Bas { void operator& (Foo &) {} };
+ void mumble()
+ {
+ Bas() & Bar().func() << "" << "";
+ Bas() & Bar().func() << "";
+ }
+} // end namespace thread_annot_lock_61_modified
+
+
+namespace thread_annot_lock_65 {
+// Test the fix for a bug in the support of allowing reader locks for
+// non-const, non-modifying overload functions. (We didn't handle the builtin
+// properly.)
+enum MyFlags {
+ Zero,
+ One,
+ Two,
+ Three,
+ Four,
+ Five,
+ Six,
+ Seven,
+ Eight,
+ Nine
+};
+
+inline MyFlags
+operator|(MyFlags a, MyFlags b)
+{
+ return MyFlags(static_cast<int>(a) | static_cast<int>(b));
+}
+
+inline MyFlags&
+operator|=(MyFlags& a, MyFlags b)
+{
+ return a = a | b;
+}
+} // end namespace thread_annot_lock_65
+
+namespace thread_annot_lock_66_modified {
+// Modified: Moved annotation to function defn
+// Test annotations on out-of-line definitions of member functions where the
+// annotations refer to locks that are also data members in the class.
+Mutex mu;
+
+class Foo {
+ public:
+ int method1(int i) SHARED_LOCKS_REQUIRED(mu1, mu, mu2);
+ int data GUARDED_BY(mu1);
+ Mutex *mu1;
+ Mutex *mu2;
+};
+
+int Foo::method1(int i)
+{
+ return data + i;
+}
+
+void main()
+{
+ Foo a;
+
+ a.mu2->Lock();
+ a.mu1->Lock();
+ mu.Lock();
+ a.method1(1);
+ mu.Unlock();
+ a.mu1->Unlock();
+ a.mu2->Unlock();
+}
+} // end namespace thread_annot_lock_66_modified
+
+namespace thread_annot_lock_68_modified {
+// Test a fix to a bug in the delayed name binding with nested template
+// instantiation. We use a stack to make sure a name is not resolved to an
+// inner context.
+template <typename T>
+class Bar {
+ Mutex mu_;
+};
+
+template <typename T>
+class Foo {
+ public:
+ void func(T x) {
+ mu_.Lock();
+ count_ = x;
+ mu_.Unlock();
+ }
+
+ private:
+ T count_ GUARDED_BY(mu_);
+ Bar<T> bar_;
+ Mutex mu_;
+};
+
+void main()
+{
+ Foo<int> *foo;
+ foo->func(5);
+}
+} // end namespace thread_annot_lock_68_modified
+
+namespace thread_annot_lock_30_modified {
+// Test delay parsing of lock attribute arguments with nested classes.
+// Modified: trylocks replaced with exclusive_lock_fun
+int a = 0;
+
+class Bar {
+ struct Foo;
+
+ public:
+ void MyLock() EXCLUSIVE_LOCK_FUNCTION(mu);
+
+ int func() {
+ MyLock();
+// if (foo == 0) {
+// return 0;
+// }
+ a = 5;
+ mu.Unlock();
+ return 1;
+ }
+
+ class FooBar {
+ int x;
+ int y;
+ };
+
+ private:
+ Mutex mu;
+};
+
+Bar *bar;
+
+void main()
+{
+ bar->func();
+}
+} // end namespace thread_annot_lock_30_modified
+
+namespace thread_annot_lock_47 {
+// Test the support for annotations on virtual functions.
+// This is a good test case. (i.e. There should be no warning emitted by the
+// compiler.)
+class Base {
+ public:
+ virtual void func1() EXCLUSIVE_LOCKS_REQUIRED(mu_);
+ virtual void func2() LOCKS_EXCLUDED(mu_);
+ Mutex mu_;
+};
+
+class Child : public Base {
+ public:
+ virtual void func1() EXCLUSIVE_LOCKS_REQUIRED(mu_);
+ virtual void func2() LOCKS_EXCLUDED(mu_);
+};
+
+void main() {
+ Child *c;
+ Base *b = c;
+
+ b->mu_.Lock();
+ b->func1();
+ b->mu_.Unlock();
+ b->func2();
+
+ c->mu_.Lock();
+ c->func1();
+ c->mu_.Unlock();
+ c->func2();
+}
+} // end namespace thread_annot_lock_47
+
+//-----------------------------------------//
+// Tests which produce errors
+//-----------------------------------------//
+
+namespace thread_annot_lock_13 {
+Mutex mu1;
+Mutex mu2;
+
+int g GUARDED_BY(mu1);
+int w GUARDED_BY(mu2);
+
+class Foo {
+ public:
+ void bar() LOCKS_EXCLUDED(mu_, mu1);
+ int foo() SHARED_LOCKS_REQUIRED(mu_) EXCLUSIVE_LOCKS_REQUIRED(mu2);
+
+ private:
+ int a_ GUARDED_BY(mu_);
+ public:
+ Mutex mu_ ACQUIRED_AFTER(mu1);
+};
+
+int Foo::foo()
+{
+ int res;
+ w = 5;
+ res = a_ + 5;
+ return res;
+}
+
+void Foo::bar()
+{
+ int x;
+ mu_.Lock();
+ x = foo(); // expected-warning {{calling function 'foo' requires exclusive lock on 'mu2'}}
+ a_ = x + 1;
+ mu_.Unlock();
+ if (x > 5) {
+ mu1.Lock();
+ g = 2;
+ mu1.Unlock();
+ }
+}
+
+void main()
+{
+ Foo f1, *f2;
+ f1.mu_.Lock();
+ f1.bar(); // expected-warning {{cannot call function 'bar' while mutex 'mu_' is locked}}
+ mu2.Lock();
+ f1.foo();
+ mu2.Unlock();
+ f1.mu_.Unlock();
+ f2->mu_.Lock();
+ f2->bar(); // expected-warning {{cannot call function 'bar' while mutex 'mu_' is locked}}
+ f2->mu_.Unlock();
+ mu2.Lock();
+ w = 2;
+ mu2.Unlock();
+}
+} // end namespace thread_annot_lock_13
+
+namespace thread_annot_lock_18_modified {
+// Modified: Trylocks removed
+// Test the ability to distnguish between the same lock field of
+// different objects of a class.
+ class Bar {
+ public:
+ bool MyLock() EXCLUSIVE_LOCK_FUNCTION(mu1_);
+ void MyUnlock() UNLOCK_FUNCTION(mu1_);
+ int a_ GUARDED_BY(mu1_);
+
+ private:
+ Mutex mu1_;
+};
+
+Bar *b1, *b2;
+
+void func()
+{
+ b1->MyLock();
+ b1->a_ = 5;
+ b2->a_ = 3; // expected-warning {{writing variable 'a_' requires locking 'mu1_' exclusively}}
+ b2->MyLock();
+ b2->MyUnlock();
+ b1->MyUnlock();
+}
+} // end namespace thread_annot_lock_18_modified
+
+namespace thread_annot_lock_21 {
+// Test various usage of GUARDED_BY and PT_GUARDED_BY annotations, especially
+// uses in class definitions.
+Mutex mu;
+
+class Bar {
+ public:
+ int a_ GUARDED_BY(mu1_);
+ int b_;
+ int *q PT_GUARDED_BY(mu);
+ Mutex mu1_ ACQUIRED_AFTER(mu);
+};
+
+Bar b1, *b3;
+int *p GUARDED_BY(mu) PT_GUARDED_BY(mu);
+
+int res GUARDED_BY(mu) = 5;
+
+int func(int i)
+{
+ int x;
+ b3->mu1_.Lock();
+ res = b1.a_ + b3->b_; // expected-warning {{reading variable 'a_' requires locking 'mu1_'}} \
+ // expected-warning {{writing variable 'res' requires locking 'mu' exclusively}}
+ *p = i; // expected-warning {{reading variable 'p' requires locking 'mu'}} \
+ // expected-warning {{writing the value pointed to by 'p' requires locking 'mu' exclusively}}
+ b1.a_ = res + b3->b_; // expected-warning {{reading variable 'res' requires locking 'mu'}} \
+ // expected-warning {{writing variable 'a_' requires locking 'mu1_' exclusively}}
+ b3->b_ = *b1.q; // expected-warning {{reading the value pointed to by 'q' requires locking 'mu'}}
+ b3->mu1_.Unlock();
+ b1.b_ = res; // expected-warning {{reading variable 'res' requires locking 'mu'}}
+ x = res; // expected-warning {{reading variable 'res' requires locking 'mu'}}
+ return x;
+}
+} // end namespace thread_annot_lock_21
+
+namespace thread_annot_lock_35_modified {
+// Test the analyzer's ability to distinguish the lock field of different
+// objects.
+class Foo {
+ private:
+ Mutex lock_;
+ int a_ GUARDED_BY(lock_);
+
+ public:
+ void Func(Foo* child) LOCKS_EXCLUDED(lock_) {
+ Foo *new_foo = new Foo;
+
+ lock_.Lock();
+
+ child->Func(new_foo); // There shouldn't be any warning here as the
+ // acquired lock is not in child.
+ child->bar(7); // expected-warning {{calling function 'bar' requires exclusive lock on 'lock_'}}
+ child->a_ = 5; // expected-warning {{writing variable 'a_' requires locking 'lock_' exclusively}}
+ lock_.Unlock();
+ }
+
+ void bar(int y) EXCLUSIVE_LOCKS_REQUIRED(lock_) {
+ a_ = y;
+ }
+};
+
+Foo *x;
+
+void main() {
+ Foo *child = new Foo;
+ x->Func(child);
+}
+} // end namespace thread_annot_lock_35_modified
+
+namespace thread_annot_lock_36_modified {
+// Modified to move the annotations to function defns.
+// Test the analyzer's ability to distinguish the lock field of different
+// objects
+class Foo {
+ private:
+ Mutex lock_;
+ int a_ GUARDED_BY(lock_);
+
+ public:
+ void Func(Foo* child) LOCKS_EXCLUDED(lock_);
+ void bar(int y) EXCLUSIVE_LOCKS_REQUIRED(lock_);
+};
+
+void Foo::Func(Foo* child) {
+ Foo *new_foo = new Foo;
+
+ lock_.Lock();
+
+ child->lock_.Lock();
+ child->Func(new_foo); // expected-warning {{cannot call function 'Func' while mutex 'lock_' is locked}}
+ child->bar(7);
+ child->a_ = 5;
+ child->lock_.Unlock();
+
+ lock_.Unlock();
+}
+
+void Foo::bar(int y) {
+ a_ = y;
+}
+
+
+Foo *x;
+
+void main() {
+ Foo *child = new Foo;
+ x->Func(child);
+}
+} // end namespace thread_annot_lock_36_modified
+
+
+namespace thread_annot_lock_42 {
+// Test support of multiple lock attributes of the same kind on a decl.
+class Foo {
+ private:
+ Mutex mu1, mu2, mu3;
+ int x GUARDED_BY(mu1) GUARDED_BY(mu2);
+ int y GUARDED_BY(mu2);
+
+ void f2() LOCKS_EXCLUDED(mu1) LOCKS_EXCLUDED(mu2) LOCKS_EXCLUDED(mu3) {
+ mu2.Lock();
+ y = 2;
+ mu2.Unlock();
+ }
+
+ public:
+ void f1() EXCLUSIVE_LOCKS_REQUIRED(mu2) EXCLUSIVE_LOCKS_REQUIRED(mu1) {
+ x = 5;
+ f2(); // expected-warning {{cannot call function 'f2' while mutex 'mu1' is locked}} \
+ // expected-warning {{cannot call function 'f2' while mutex 'mu2' is locked}}
+ }
+};
+
+Foo *foo;
+
+void func()
+{
+ foo->f1(); // expected-warning {{calling function 'f1' requires exclusive lock on 'mu2'}} \
+ // expected-warning {{calling function 'f1' requires exclusive lock on 'mu1'}}
+}
+} // end namespace thread_annot_lock_42
+
+namespace thread_annot_lock_46 {
+// Test the support for annotations on virtual functions.
+class Base {
+ public:
+ virtual void func1() EXCLUSIVE_LOCKS_REQUIRED(mu_);
+ virtual void func2() LOCKS_EXCLUDED(mu_);
+ Mutex mu_;
+};
+
+class Child : public Base {
+ public:
+ virtual void func1() EXCLUSIVE_LOCKS_REQUIRED(mu_);
+ virtual void func2() LOCKS_EXCLUDED(mu_);
+};
+
+void main() {
+ Child *c;
+ Base *b = c;
+
+ b->func1(); // expected-warning {{calling function 'func1' requires exclusive lock on 'mu_'}}
+ b->mu_.Lock();
+ b->func2(); // expected-warning {{cannot call function 'func2' while mutex 'mu_' is locked}}
+ b->mu_.Unlock();
+
+ c->func1(); // expected-warning {{calling function 'func1' requires exclusive lock on 'mu_'}}
+ c->mu_.Lock();
+ c->func2(); // expected-warning {{cannot call function 'func2' while mutex 'mu_' is locked}}
+ c->mu_.Unlock();
+}
+} // end namespace thread_annot_lock_46
+
+namespace thread_annot_lock_67_modified {
+// Modified: attributes on definitions moved to declarations
+// Test annotations on out-of-line definitions of member functions where the
+// annotations refer to locks that are also data members in the class.
+Mutex mu;
+Mutex mu3;
+
+class Foo {
+ public:
+ int method1(int i) SHARED_LOCKS_REQUIRED(mu1, mu, mu2, mu3);
+ int data GUARDED_BY(mu1);
+ Mutex *mu1;
+ Mutex *mu2;
+};
+
+int Foo::method1(int i) {
+ return data + i;
+}
+
+void main()
+{
+ Foo a;
+ a.method1(1); // expected-warning {{calling function 'method1' requires shared lock on 'mu1'}} \
+ // expected-warning {{calling function 'method1' requires shared lock on 'mu'}} \
+ // expected-warning {{calling function 'method1' requires shared lock on 'mu2'}} \
+ // expected-warning {{calling function 'method1' requires shared lock on 'mu3'}}
+}
+} // end namespace thread_annot_lock_67_modified
+
+
+namespace substitution_test {
+ class MyData {
+ public:
+ Mutex mu;
+
+ void lockData() __attribute__((exclusive_lock_function(mu))) { }
+ void unlockData() __attribute__((unlock_function(mu))) { }
+
+ void doSomething() __attribute__((exclusive_locks_required(mu))) { }
+ };
+
+
+ class DataLocker {
+ public:
+ void lockData (MyData *d) __attribute__((exclusive_lock_function(d->mu))) { }
+ void unlockData(MyData *d) __attribute__((unlock_function(d->mu))) { }
+ };
+
+
+ class Foo {
+ public:
+ void foo(MyData* d) __attribute__((exclusive_locks_required(d->mu))) { }
+
+ void bar1(MyData* d) {
+ d->lockData();
+ foo(d);
+ d->unlockData();
+ }
+
+ void bar2(MyData* d) {
+ DataLocker dlr;
+ dlr.lockData(d);
+ foo(d);
+ dlr.unlockData(d);
+ }
+
+ void bar3(MyData* d1, MyData* d2) {
+ DataLocker dlr;
+ dlr.lockData(d1); // expected-note {{mutex acquired here}}
+ dlr.unlockData(d2); // \
+ // expected-warning {{unlocking 'mu' that was not locked}}
+ } // expected-warning {{mutex 'mu' is still locked at the end of function}}
+
+ void bar4(MyData* d1, MyData* d2) {
+ DataLocker dlr;
+ dlr.lockData(d1);
+ foo(d2); // \
+ // expected-warning {{calling function 'foo' requires exclusive lock on 'mu'}}
+ dlr.unlockData(d1);
+ }
+ };
+} // end namespace substituation_test
+
+
+
+namespace constructor_destructor_tests {
+ Mutex fooMu;
+ int myVar GUARDED_BY(fooMu);
+
+ class Foo {
+ public:
+ Foo() __attribute__((exclusive_lock_function(fooMu))) { }
+ ~Foo() __attribute__((unlock_function(fooMu))) { }
+ };
+
+ void fooTest() {
+ Foo foo;
+ myVar = 0;
+ }
+}
+
+
+namespace invalid_lock_expression_test {
+
+class LOCKABLE MyLockable {
+public:
+ MyLockable() __attribute__((exclusive_lock_function)) { }
+ ~MyLockable() { }
+};
+
+// create an empty lock expression
+void foo() {
+ MyLockable lock; // \
+ // expected-warning {{cannot resolve lock expression}}
+}
+
+} // end namespace invalid_lock_expression_test
+
+namespace template_member_test {
+
+ struct S { int n; };
+ struct T {
+ Mutex m;
+ S *s GUARDED_BY(this->m);
+ };
+ Mutex m;
+ struct U {
+ union {
+ int n;
+ };
+ } *u GUARDED_BY(m);
+
+ template<typename U>
+ struct IndirectLock {
+ int DoNaughtyThings(T *t) {
+ u->n = 0; // expected-warning {{reading variable 'u' requires locking 'm'}}
+ return t->s->n; // expected-warning {{reading variable 's' requires locking 'm'}}
+ }
+ };
+
+ template struct IndirectLock<int>; // expected-note {{here}}
+
+ struct V {
+ void f(int);
+ void f(double);
+
+ Mutex m;
+ V *p GUARDED_BY(this->m);
+ };
+ template<typename U> struct W {
+ V v;
+ void f(U u) {
+ v.p->f(u); // expected-warning {{reading variable 'p' requires locking 'm'}}
+ }
+ };
+ template struct W<int>; // expected-note {{here}}
+
+}
+
+namespace test_scoped_lockable {
+
+struct TestScopedLockable {
+ Mutex mu1;
+ Mutex mu2;
+ int a __attribute__((guarded_by(mu1)));
+ int b __attribute__((guarded_by(mu2)));
+
+ bool getBool();
+
+ void foo1() {
+ MutexLock mulock(&mu1);
+ a = 5;
+ }
+
+ void foo2() {
+ ReaderMutexLock mulock1(&mu1);
+ if (getBool()) {
+ MutexLock mulock2a(&mu2);
+ b = a + 1;
+ }
+ else {
+ MutexLock mulock2b(&mu2);
+ b = a + 2;
+ }
+ }
+
+ void foo3() {
+ MutexLock mulock_a(&mu1);
+ MutexLock mulock_b(&mu1); // \
+ // expected-warning {{locking 'mu1' that is already locked}}
+ } // expected-warning {{unlocking 'mu1' that was not locked}}
+
+ void foo4() {
+ MutexLock mulock1(&mu1), mulock2(&mu2);
+ a = b+1;
+ b = a+1;
+ }
+};
+
+} // end namespace test_scoped_lockable
+
+
+namespace FunctionAttrTest {
+
+class Foo {
+public:
+ Mutex mu_;
+ int a GUARDED_BY(mu_);
+};
+
+Foo fooObj;
+
+void foo() EXCLUSIVE_LOCKS_REQUIRED(fooObj.mu_);
+
+void bar() {
+ foo(); // expected-warning {{calling function 'foo' requires exclusive lock on 'mu_'}}
+ fooObj.mu_.Lock();
+ foo();
+ fooObj.mu_.Unlock();
+}
+
+}; // end namespace FunctionAttrTest
+
+
+struct TestTryLock {
+ Mutex mu;
+ int a GUARDED_BY(mu);
+ bool cond;
+
+ void foo1() {
+ if (mu.TryLock()) {
+ a = 1;
+ mu.Unlock();
+ }
+ }
+
+ void foo2() {
+ if (!mu.TryLock()) return;
+ a = 2;
+ mu.Unlock();
+ }
+
+ void foo3() {
+ bool b = mu.TryLock();
+ if (b) {
+ a = 3;
+ mu.Unlock();
+ }
+ }
+
+ void foo4() {
+ bool b = mu.TryLock();
+ if (!b) return;
+ a = 4;
+ mu.Unlock();
+ }
+
+ void foo5() {
+ while (mu.TryLock()) {
+ a = a + 1;
+ mu.Unlock();
+ }
+ }
+
+ void foo6() {
+ bool b = mu.TryLock();
+ b = !b;
+ if (b) return;
+ a = 6;
+ mu.Unlock();
+ }
+
+ void foo7() {
+ bool b1 = mu.TryLock();
+ bool b2 = !b1;
+ bool b3 = !b2;
+ if (b3) {
+ a = 7;
+ mu.Unlock();
+ }
+ }
+
+ // Test use-def chains: join points
+ void foo8() {
+ bool b = mu.TryLock();
+ bool b2 = b;
+ if (cond)
+ b = true;
+ if (b) { // b should be unknown at this point, becuase of the join point
+ a = 8; // expected-warning {{writing variable 'a' requires locking 'mu' exclusively}}
+ }
+ if (b2) { // b2 should be known at this point.
+ a = 8;
+ mu.Unlock();
+ }
+ }
+
+ // Test use-def-chains: back edges
+ void foo9() {
+ bool b = mu.TryLock();
+
+ for (int i = 0; i < 10; ++i);
+
+ if (b) { // b is still known, because the loop doesn't alter it
+ a = 9;
+ mu.Unlock();
+ }
+ }
+
+ // Test use-def chains: back edges
+ void foo10() {
+ bool b = mu.TryLock();
+
+ while (cond) {
+ if (b) { // b should be uknown at this point b/c of the loop
+ a = 10; // expected-warning {{writing variable 'a' requires locking 'mu' exclusively}}
+ }
+ b = !b;
+ }
+ }
+}; // end TestTrylock
+
+
+namespace TestTemplateAttributeInstantiation {
+
+class Foo1 {
+public:
+ Mutex mu_;
+ int a GUARDED_BY(mu_);
+};
+
+class Foo2 {
+public:
+ int a GUARDED_BY(mu_);
+ Mutex mu_;
+};
+
+
+class Bar {
+public:
+ // Test non-dependent expressions in attributes on template functions
+ template <class T>
+ void barND(Foo1 *foo, T *fooT) EXCLUSIVE_LOCKS_REQUIRED(foo->mu_) {
+ foo->a = 0;
+ }
+
+ // Test dependent expressions in attributes on template functions
+ template <class T>
+ void barD(Foo1 *foo, T *fooT) EXCLUSIVE_LOCKS_REQUIRED(fooT->mu_) {
+ fooT->a = 0;
+ }
+};
+
+
+template <class T>
+class BarT {
+public:
+ Foo1 fooBase;
+ T fooBaseT;
+
+ // Test non-dependent expression in ordinary method on template class
+ void barND() EXCLUSIVE_LOCKS_REQUIRED(fooBase.mu_) {
+ fooBase.a = 0;
+ }
+
+ // Test dependent expressions in ordinary methods on template class
+ void barD() EXCLUSIVE_LOCKS_REQUIRED(fooBaseT.mu_) {
+ fooBaseT.a = 0;
+ }
+
+ // Test dependent expressions in template method in template class
+ template <class T2>
+ void barTD(T2 *fooT) EXCLUSIVE_LOCKS_REQUIRED(fooBaseT.mu_, fooT->mu_) {
+ fooBaseT.a = 0;
+ fooT->a = 0;
+ }
+};
+
+template <class T>
+class Cell {
+public:
+ Mutex mu_;
+ // Test dependent guarded_by
+ T data GUARDED_BY(mu_);
+
+ void fooEx() EXCLUSIVE_LOCKS_REQUIRED(mu_) {
+ data = 0;
+ }
+
+ void foo() {
+ mu_.Lock();
+ data = 0;
+ mu_.Unlock();
+ }
+};
+
+void test() {
+ Bar b;
+ BarT<Foo2> bt;
+ Foo1 f1;
+ Foo2 f2;
+
+ f1.mu_.Lock();
+ f2.mu_.Lock();
+ bt.fooBase.mu_.Lock();
+ bt.fooBaseT.mu_.Lock();
+
+ b.barND(&f1, &f2);
+ b.barD(&f1, &f2);
+ bt.barND();
+ bt.barD();
+ bt.barTD(&f2);
+
+ f1.mu_.Unlock();
+ bt.barTD(&f1); // \
+ // expected-warning {{calling function 'barTD' requires exclusive lock on 'mu_'}}
+
+ bt.fooBase.mu_.Unlock();
+ bt.fooBaseT.mu_.Unlock();
+ f2.mu_.Unlock();
+
+ Cell<int> cell;
+ cell.data = 0; // \
+ // expected-warning {{writing variable 'data' requires locking 'mu_' exclusively}}
+ cell.foo();
+ cell.mu_.Lock();
+ cell.fooEx();
+ cell.mu_.Unlock();
+}
+
+
+template <class T>
+class CellDelayed {
+public:
+ // Test dependent guarded_by
+ T data GUARDED_BY(mu_);
+ static T static_data GUARDED_BY(static_mu_);
+
+ void fooEx(CellDelayed<T> *other) EXCLUSIVE_LOCKS_REQUIRED(mu_, other->mu_) {
+ this->data = other->data;
+ }
+
+ template <class T2>
+ void fooExT(CellDelayed<T2> *otherT) EXCLUSIVE_LOCKS_REQUIRED(mu_, otherT->mu_) {
+ this->data = otherT->data;
+ }
+
+ void foo() {
+ mu_.Lock();
+ data = 0;
+ mu_.Unlock();
+ }
+
+ Mutex mu_;
+ static Mutex static_mu_;
+};
+
+void testDelayed() {
+ CellDelayed<int> celld;
+ CellDelayed<int> celld2;
+ celld.foo();
+ celld.mu_.Lock();
+ celld2.mu_.Lock();
+
+ celld.fooEx(&celld2);
+ celld.fooExT(&celld2);
+
+ celld2.mu_.Unlock();
+ celld.mu_.Unlock();
+}
+
+}; // end namespace TestTemplateAttributeInstantiation
+
+
+namespace FunctionDeclDefTest {
+
+class Foo {
+public:
+ Mutex mu_;
+ int a GUARDED_BY(mu_);
+
+ virtual void foo1(Foo *f_declared) EXCLUSIVE_LOCKS_REQUIRED(f_declared->mu_);
+};
+
+// EXCLUSIVE_LOCKS_REQUIRED should be applied, and rewritten to f_defined->mu_
+void Foo::foo1(Foo *f_defined) {
+ f_defined->a = 0;
+};
+
+void test() {
+ Foo myfoo;
+ myfoo.foo1(&myfoo); // \
+ // expected-warning {{calling function 'foo1' requires exclusive lock on 'mu_'}}
+ myfoo.mu_.Lock();
+ myfoo.foo1(&myfoo);
+ myfoo.mu_.Unlock();
+}
+
+};
+
+namespace GoingNative {
+
+ struct __attribute__((lockable)) mutex {
+ void lock() __attribute__((exclusive_lock_function));
+ void unlock() __attribute__((unlock_function));
+ // ...
+ };
+ bool foo();
+ bool bar();
+ mutex m;
+ void test() {
+ m.lock();
+ while (foo()) {
+ m.unlock();
+ // ...
+ if (bar()) {
+ // ...
+ if (foo())
+ continue; // expected-warning {{expecting mutex 'm' to be locked at start of each loop}}
+ //...
+ }
+ // ...
+ m.lock(); // expected-note {{mutex acquired here}}
+ }
+ m.unlock();
+ }
+
+}
+
+
+
+namespace FunctionDefinitionTest {
+
+class Foo {
+public:
+ void foo1();
+ void foo2();
+ void foo3(Foo *other);
+
+ template<class T>
+ void fooT1(const T& dummy1);
+
+ template<class T>
+ void fooT2(const T& dummy2) EXCLUSIVE_LOCKS_REQUIRED(mu_);
+
+ Mutex mu_;
+ int a GUARDED_BY(mu_);
+};
+
+template<class T>
+class FooT {
+public:
+ void foo();
+
+ Mutex mu_;
+ T a GUARDED_BY(mu_);
+};
+
+
+void Foo::foo1() NO_THREAD_SAFETY_ANALYSIS {
+ a = 1;
+}
+
+void Foo::foo2() EXCLUSIVE_LOCKS_REQUIRED(mu_) {
+ a = 2;
+}
+
+void Foo::foo3(Foo *other) EXCLUSIVE_LOCKS_REQUIRED(other->mu_) {
+ other->a = 3;
+}
+
+template<class T>
+void Foo::fooT1(const T& dummy1) EXCLUSIVE_LOCKS_REQUIRED(mu_) {
+ a = dummy1;
+}
+
+/* TODO -- uncomment with template instantiation of attributes.
+template<class T>
+void Foo::fooT2(const T& dummy2) {
+ a = dummy2;
+}
+*/
+
+void fooF1(Foo *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu_) {
+ f->a = 1;
+}
+
+void fooF2(Foo *f);
+void fooF2(Foo *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu_) {
+ f->a = 2;
+}
+
+void fooF3(Foo *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu_);
+void fooF3(Foo *f) {
+ f->a = 3;
+}
+
+template<class T>
+void FooT<T>::foo() EXCLUSIVE_LOCKS_REQUIRED(mu_) {
+ a = 0;
+}
+
+void test() {
+ int dummy = 0;
+ Foo myFoo;
+
+ myFoo.foo2(); // \
+ // expected-warning {{calling function 'foo2' requires exclusive lock on 'mu_'}}
+ myFoo.foo3(&myFoo); // \
+ // expected-warning {{calling function 'foo3' requires exclusive lock on 'mu_'}}
+ myFoo.fooT1(dummy); // \
+ // expected-warning {{calling function 'fooT1' requires exclusive lock on 'mu_'}}
+
+ // FIXME: uncomment with template instantiation of attributes patch
+ // myFoo.fooT2(dummy); // expected warning
+
+ fooF1(&myFoo); // \
+ // expected-warning {{calling function 'fooF1' requires exclusive lock on 'mu_'}}
+ fooF2(&myFoo); // \
+ // expected-warning {{calling function 'fooF2' requires exclusive lock on 'mu_'}}
+ fooF3(&myFoo); // \
+ // expected-warning {{calling function 'fooF3' requires exclusive lock on 'mu_'}}
+
+ myFoo.mu_.Lock();
+ myFoo.foo2();
+ myFoo.foo3(&myFoo);
+ myFoo.fooT1(dummy);
+
+ // FIXME: uncomment with template instantiation of attributes patch
+ // myFoo.fooT2(dummy);
+
+ fooF1(&myFoo);
+ fooF2(&myFoo);
+ fooF3(&myFoo);
+ myFoo.mu_.Unlock();
+
+ FooT<int> myFooT;
+ myFooT.foo(); // \
+ // expected-warning {{calling function 'foo' requires exclusive lock on 'mu_'}}
+}
+
+} // end namespace FunctionDefinitionTest
+
+
+namespace SelfLockingTest {
+
+class LOCKABLE MyLock {
+public:
+ int foo GUARDED_BY(this);
+
+ void lock() EXCLUSIVE_LOCK_FUNCTION();
+ void unlock() UNLOCK_FUNCTION();
+
+ void doSomething() {
+ this->lock(); // allow 'this' as a lock expression
+ foo = 0;
+ doSomethingElse();
+ this->unlock();
+ }
+
+ void doSomethingElse() EXCLUSIVE_LOCKS_REQUIRED(this) {
+ foo = 1;
+ };
+
+ void test() {
+ foo = 2; // \
+ // expected-warning {{writing variable 'foo' requires locking 'this' exclusively}}
+ }
+};
+
+
+class LOCKABLE MyLock2 {
+public:
+ Mutex mu_;
+ int foo GUARDED_BY(this);
+
+ // don't check inside lock and unlock functions
+ void lock() EXCLUSIVE_LOCK_FUNCTION() { mu_.Lock(); }
+ void unlock() UNLOCK_FUNCTION() { mu_.Unlock(); }
+
+ // don't check inside constructors and destructors
+ MyLock2() { foo = 1; }
+ ~MyLock2() { foo = 0; }
+};
+
+
+} // end namespace SelfLockingTest
+
+
+namespace InvalidNonstatic {
+
+// Forward decl here causes bogus "invalid use of non-static data member"
+// on reference to mutex_ in guarded_by attribute.
+class Foo;
+
+class Foo {
+ Mutex* mutex_;
+
+ int foo __attribute__((guarded_by(mutex_)));
+};
+
+} // end namespace InvalidNonStatic
+
+
+namespace NoReturnTest {
+
+bool condition();
+void fatal() __attribute__((noreturn));
+
+Mutex mu_;
+
+void test1() {
+ MutexLock lock(&mu_);
+ if (condition()) {
+ fatal();
+ return;
+ }
+}
+
+} // end namespace NoReturnTest
+
+
+namespace TestMultiDecl {
+
+class Foo {
+public:
+ int GUARDED_BY(mu_) a;
+ int GUARDED_BY(mu_) b, c;
+
+ void foo() {
+ a = 0; // \
+ // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}}
+ b = 0; // \
+ // expected-warning {{writing variable 'b' requires locking 'mu_' exclusively}}
+ c = 0; // \
+ // expected-warning {{writing variable 'c' requires locking 'mu_' exclusively}}
+ }
+
+private:
+ Mutex mu_;
+};
+
+} // end namespace TestMultiDecl
+
+
+namespace WarnNoDecl {
+
+class Foo {
+ void foo(int a); __attribute__(( // \
+ // expected-warning {{declaration does not declare anything}}
+ exclusive_locks_required(a))); // \
+ // expected-warning {{attribute exclusive_locks_required ignored}}
+};
+
+} // end namespace WarnNoDecl
+
+
+
+namespace MoreLockExpressions {
+
+class Foo {
+public:
+ Mutex mu_;
+ int a GUARDED_BY(mu_);
+};
+
+class Bar {
+public:
+ int b;
+ Foo* f;
+
+ Foo& getFoo() { return *f; }
+ Foo& getFoo2(int c) { return *f; }
+ Foo& getFoo3(int c, int d) { return *f; }
+
+ Foo& getFooey() { return *f; }
+};
+
+Foo& getBarFoo(Bar &bar, int c) { return bar.getFoo2(c); }
+
+void test() {
+ Foo foo;
+ Foo *fooArray;
+ Bar bar;
+ int a;
+ int b;
+ int c;
+
+ bar.getFoo().mu_.Lock();
+ bar.getFoo().a = 0;
+ bar.getFoo().mu_.Unlock();
+
+ (bar.getFoo().mu_).Lock(); // test parenthesis
+ bar.getFoo().a = 0;
+ (bar.getFoo().mu_).Unlock();
+
+ bar.getFoo2(a).mu_.Lock();
+ bar.getFoo2(a).a = 0;
+ bar.getFoo2(a).mu_.Unlock();
+
+ bar.getFoo3(a, b).mu_.Lock();
+ bar.getFoo3(a, b).a = 0;
+ bar.getFoo3(a, b).mu_.Unlock();
+
+ getBarFoo(bar, a).mu_.Lock();
+ getBarFoo(bar, a).a = 0;
+ getBarFoo(bar, a).mu_.Unlock();
+
+ bar.getFoo2(10).mu_.Lock();
+ bar.getFoo2(10).a = 0;
+ bar.getFoo2(10).mu_.Unlock();
+
+ bar.getFoo2(a + 1).mu_.Lock();
+ bar.getFoo2(a + 1).a = 0;
+ bar.getFoo2(a + 1).mu_.Unlock();
+
+ (a > 0 ? fooArray[1] : fooArray[b]).mu_.Lock();
+ (a > 0 ? fooArray[1] : fooArray[b]).a = 0;
+ (a > 0 ? fooArray[1] : fooArray[b]).mu_.Unlock();
+
+ bar.getFoo().mu_.Lock();
+ bar.getFooey().a = 0; // \
+ // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}}
+ bar.getFoo().mu_.Unlock();
+
+ bar.getFoo2(a).mu_.Lock();
+ bar.getFoo2(b).a = 0; // \
+ // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}}
+ bar.getFoo2(a).mu_.Unlock();
+
+ bar.getFoo3(a, b).mu_.Lock();
+ bar.getFoo3(a, c).a = 0; // \
+ // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}}
+ bar.getFoo3(a, b).mu_.Unlock();
+
+ getBarFoo(bar, a).mu_.Lock();
+ getBarFoo(bar, b).a = 0; // \
+ // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}}
+ getBarFoo(bar, a).mu_.Unlock();
+
+ (a > 0 ? fooArray[1] : fooArray[b]).mu_.Lock();
+ (a > 0 ? fooArray[b] : fooArray[c]).a = 0; // \
+ // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}}
+ (a > 0 ? fooArray[1] : fooArray[b]).mu_.Unlock();
+}
+
+
+} // end namespace
+
+
diff --git a/clang/test/SemaCXX/warn-thread-safety-parsing.cpp b/clang/test/SemaCXX/warn-thread-safety-parsing.cpp
new file mode 100644
index 0000000..c2fa1d7
--- /dev/null
+++ b/clang/test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -0,0 +1,1345 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
+
+#define LOCKABLE __attribute__ ((lockable))
+#define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
+#define GUARDED_BY(x) __attribute__ ((guarded_by(x)))
+#define GUARDED_VAR __attribute__ ((guarded_var))
+#define PT_GUARDED_BY(x) __attribute__ ((pt_guarded_by(x)))
+#define PT_GUARDED_VAR __attribute__ ((pt_guarded_var))
+#define ACQUIRED_AFTER(...) __attribute__ ((acquired_after(__VA_ARGS__)))
+#define ACQUIRED_BEFORE(...) __attribute__ ((acquired_before(__VA_ARGS__)))
+#define EXCLUSIVE_LOCK_FUNCTION(...) __attribute__ ((exclusive_lock_function(__VA_ARGS__)))
+#define SHARED_LOCK_FUNCTION(...) __attribute__ ((shared_lock_function(__VA_ARGS__)))
+#define EXCLUSIVE_TRYLOCK_FUNCTION(...) __attribute__ ((exclusive_trylock_function(__VA_ARGS__)))
+#define SHARED_TRYLOCK_FUNCTION(...) __attribute__ ((shared_trylock_function(__VA_ARGS__)))
+#define UNLOCK_FUNCTION(...) __attribute__ ((unlock_function(__VA_ARGS__)))
+#define LOCK_RETURNED(x) __attribute__ ((lock_returned(x)))
+#define LOCKS_EXCLUDED(...) __attribute__ ((locks_excluded(__VA_ARGS__)))
+#define EXCLUSIVE_LOCKS_REQUIRED(...) \
+ __attribute__ ((exclusive_locks_required(__VA_ARGS__)))
+#define SHARED_LOCKS_REQUIRED(...) \
+ __attribute__ ((shared_locks_required(__VA_ARGS__)))
+#define NO_THREAD_SAFETY_ANALYSIS __attribute__ ((no_thread_safety_analysis))
+
+
+class __attribute__((lockable)) Mu {
+ public:
+ void Lock();
+};
+
+class UnlockableMu{
+};
+
+class MuWrapper {
+ public:
+ Mu mu;
+ Mu getMu() {
+ return mu;
+ }
+ Mu * getMuPointer() {
+ return &mu;
+ }
+};
+
+
+class MuDoubleWrapper {
+ public:
+ MuWrapper* muWrapper;
+ MuWrapper* getWrapper() {
+ return muWrapper;
+ }
+};
+
+Mu mu1;
+UnlockableMu umu;
+Mu mu2;
+MuWrapper muWrapper;
+MuDoubleWrapper muDoubleWrapper;
+Mu* muPointer;
+Mu ** muDoublePointer = & muPointer;
+Mu& muRef = mu1;
+
+//---------------------------------------//
+// Scoping tests
+//--------------------------------------//
+
+class Foo {
+ Mu foomu;
+ void needLock() __attribute__((exclusive_lock_function(foomu)));
+};
+
+class Foo2 {
+ void needLock() __attribute__((exclusive_lock_function(foomu)));
+ Mu foomu;
+};
+
+class Bar {
+ Mu barmu;
+ Mu barmu2 __attribute__((acquired_after(barmu)));
+};
+
+
+//-----------------------------------------//
+// No Thread Safety Analysis (noanal) //
+//-----------------------------------------//
+
+// FIXME: Right now we cannot parse attributes put on function definitions
+// We would like to patch this at some point.
+
+#if !__has_attribute(no_thread_safety_analysis)
+#error "Should support no_thread_safety_analysis attribute"
+#endif
+
+void noanal_fun() __attribute__((no_thread_safety_analysis));
+
+void noanal_fun_args() __attribute__((no_thread_safety_analysis(1))); // \
+ // expected-error {{attribute takes no arguments}}
+
+int noanal_testfn(int y) __attribute__((no_thread_safety_analysis));
+
+int noanal_testfn(int y) {
+ int x __attribute__((no_thread_safety_analysis)) = y; // \
+ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}}
+ return x;
+};
+
+int noanal_test_var __attribute__((no_thread_safety_analysis)); // \
+ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}}
+
+class NoanalFoo {
+ private:
+ int test_field __attribute__((no_thread_safety_analysis)); // \
+ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}}
+ void test_method() __attribute__((no_thread_safety_analysis));
+};
+
+class __attribute__((no_thread_safety_analysis)) NoanalTestClass { // \
+ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}}
+};
+
+void noanal_fun_params(int lvar __attribute__((no_thread_safety_analysis))); // \
+ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}}
+
+
+//-----------------------------------------//
+// Guarded Var Attribute (gv)
+//-----------------------------------------//
+
+#if !__has_attribute(guarded_var)
+#error "Should support guarded_var attribute"
+#endif
+
+int gv_var_noargs __attribute__((guarded_var));
+
+int gv_var_args __attribute__((guarded_var(1))); // \
+ // expected-error {{attribute takes no arguments}}
+
+class GVFoo {
+ private:
+ int gv_field_noargs __attribute__((guarded_var));
+ int gv_field_args __attribute__((guarded_var(1))); // \
+ // expected-error {{attribute takes no arguments}}
+};
+
+class __attribute__((guarded_var)) GV { // \
+ // expected-warning {{'guarded_var' attribute only applies to fields and global variables}}
+};
+
+void gv_function() __attribute__((guarded_var)); // \
+ // expected-warning {{'guarded_var' attribute only applies to fields and global variables}}
+
+void gv_function_params(int gv_lvar __attribute__((guarded_var))); // \
+ // expected-warning {{'guarded_var' attribute only applies to fields and global variables}}
+
+int gv_testfn(int y){
+ int x __attribute__((guarded_var)) = y; // \
+ // expected-warning {{'guarded_var' attribute only applies to fields and global variables}}
+ return x;
+}
+
+//-----------------------------------------//
+// Pt Guarded Var Attribute (pgv)
+//-----------------------------------------//
+
+//FIXME: add support for boost::scoped_ptr<int> fancyptr and references
+
+#if !__has_attribute(pt_guarded_var)
+#error "Should support pt_guarded_var attribute"
+#endif
+
+int *pgv_pt_var_noargs __attribute__((pt_guarded_var));
+
+int pgv_var_noargs __attribute__((pt_guarded_var)); // \
+ // expected-warning {{'pt_guarded_var' only applies to pointer types; type here is 'int'}}
+
+class PGVFoo {
+ private:
+ int *pt_field_noargs __attribute__((pt_guarded_var));
+ int field_noargs __attribute__((pt_guarded_var)); // \
+ // expected-warning {{'pt_guarded_var' only applies to pointer types; type here is 'int'}}
+ int *gv_field_args __attribute__((pt_guarded_var(1))); // \
+ // expected-error {{attribute takes no arguments}}
+};
+
+class __attribute__((pt_guarded_var)) PGV { // \
+ // expected-warning {{'pt_guarded_var' attribute only applies to fields and global variables}}
+};
+
+int *pgv_var_args __attribute__((pt_guarded_var(1))); // \
+ // expected-error {{attribute takes no arguments}}
+
+
+void pgv_function() __attribute__((pt_guarded_var)); // \
+ // expected-warning {{'pt_guarded_var' attribute only applies to fields and global variables}}
+
+void pgv_function_params(int *gv_lvar __attribute__((pt_guarded_var))); // \
+ // expected-warning {{'pt_guarded_var' attribute only applies to fields and global variables}}
+
+void pgv_testfn(int y){
+ int *x __attribute__((pt_guarded_var)) = new int(0); // \
+ // expected-warning {{'pt_guarded_var' attribute only applies to fields and global variables}}
+ delete x;
+}
+
+//-----------------------------------------//
+// Lockable Attribute (l)
+//-----------------------------------------//
+
+//FIXME: In future we may want to add support for structs, ObjC classes, etc.
+
+#if !__has_attribute(lockable)
+#error "Should support lockable attribute"
+#endif
+
+class __attribute__((lockable)) LTestClass {
+};
+
+class __attribute__((lockable (1))) LTestClass_args { // \
+ // expected-error {{attribute takes no arguments}}
+};
+
+void l_test_function() __attribute__((lockable)); // \
+ // expected-warning {{'lockable' attribute only applies to classes}}
+
+int l_testfn(int y) {
+ int x __attribute__((lockable)) = y; // \
+ // expected-warning {{'lockable' attribute only applies to classes}}
+ return x;
+}
+
+int l_test_var __attribute__((lockable)); // \
+ // expected-warning {{'lockable' attribute only applies to classes}}
+
+class LFoo {
+ private:
+ int test_field __attribute__((lockable)); // \
+ // expected-warning {{'lockable' attribute only applies to classes}}
+ void test_method() __attribute__((lockable)); // \
+ // expected-warning {{'lockable' attribute only applies to classes}}
+};
+
+
+void l_function_params(int lvar __attribute__((lockable))); // \
+ // expected-warning {{'lockable' attribute only applies to classes}}
+
+
+//-----------------------------------------//
+// Scoped Lockable Attribute (sl)
+//-----------------------------------------//
+
+#if !__has_attribute(scoped_lockable)
+#error "Should support scoped_lockable attribute"
+#endif
+
+class __attribute__((scoped_lockable)) SLTestClass {
+};
+
+class __attribute__((scoped_lockable (1))) SLTestClass_args { // \
+ // expected-error {{attribute takes no arguments}}
+};
+
+void sl_test_function() __attribute__((scoped_lockable)); // \
+ // expected-warning {{'scoped_lockable' attribute only applies to classes}}
+
+int sl_testfn(int y) {
+ int x __attribute__((scoped_lockable)) = y; // \
+ // expected-warning {{'scoped_lockable' attribute only applies to classes}}
+ return x;
+}
+
+int sl_test_var __attribute__((scoped_lockable)); // \
+ // expected-warning {{'scoped_lockable' attribute only applies to classes}}
+
+class SLFoo {
+ private:
+ int test_field __attribute__((scoped_lockable)); // \
+ // expected-warning {{'scoped_lockable' attribute only applies to classes}}
+ void test_method() __attribute__((scoped_lockable)); // \
+ // expected-warning {{'scoped_lockable' attribute only applies to classes}}
+};
+
+
+void sl_function_params(int lvar __attribute__((scoped_lockable))); // \
+ // expected-warning {{'scoped_lockable' attribute only applies to classes}}
+
+
+//-----------------------------------------//
+// Guarded By Attribute (gb)
+//-----------------------------------------//
+
+// FIXME: Eventually, would we like this attribute to take more than 1 arg?
+
+#if !__has_attribute(guarded_by)
+#error "Should support guarded_by attribute"
+#endif
+
+//1. Check applied to the right types & argument number
+
+int gb_var_arg __attribute__((guarded_by(mu1)));
+
+int gb_var_args __attribute__((guarded_by(mu1, mu2))); // \
+ // expected-error {{attribute takes one argument}}
+
+int gb_var_noargs __attribute__((guarded_by)); // \
+ // expected-error {{attribute takes one argument}}
+
+class GBFoo {
+ private:
+ int gb_field_noargs __attribute__((guarded_by)); // \
+ // expected-error {{attribute takes one argument}}
+ int gb_field_args __attribute__((guarded_by(mu1)));
+};
+
+class __attribute__((guarded_by(mu1))) GB { // \
+ // expected-warning {{'guarded_by' attribute only applies to fields and global variables}}
+};
+
+void gb_function() __attribute__((guarded_by(mu1))); // \
+ // expected-warning {{'guarded_by' attribute only applies to fields and global variables}}
+
+void gb_function_params(int gv_lvar __attribute__((guarded_by(mu1)))); // \
+ // expected-warning {{'guarded_by' attribute only applies to fields and global variables}}
+
+int gb_testfn(int y){
+ int x __attribute__((guarded_by(mu1))) = y; // \
+ // expected-warning {{'guarded_by' attribute only applies to fields and global variables}}
+ return x;
+}
+
+//2. Check argument parsing.
+
+// legal attribute arguments
+int gb_var_arg_1 __attribute__((guarded_by(muWrapper.mu)));
+int gb_var_arg_2 __attribute__((guarded_by(muDoubleWrapper.muWrapper->mu)));
+int gb_var_arg_3 __attribute__((guarded_by(muWrapper.getMu())));
+int gb_var_arg_4 __attribute__((guarded_by(*muWrapper.getMuPointer())));
+int gb_var_arg_5 __attribute__((guarded_by(&mu1)));
+int gb_var_arg_6 __attribute__((guarded_by(muRef)));
+int gb_var_arg_7 __attribute__((guarded_by(muDoubleWrapper.getWrapper()->getMu())));
+int gb_var_arg_8 __attribute__((guarded_by(muPointer)));
+
+
+// illegal attribute arguments
+int gb_var_arg_bad_1 __attribute__((guarded_by(1))); // \
+ // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'int'}}
+int gb_var_arg_bad_2 __attribute__((guarded_by("mu"))); // \
+ // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'const char [3]'}}
+int gb_var_arg_bad_3 __attribute__((guarded_by(muDoublePointer))); // \
+ // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'class Mu **'}}
+int gb_var_arg_bad_4 __attribute__((guarded_by(umu))); // \
+ // expected-warning {{'guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute; type here is 'class UnlockableMu'}}
+
+//3.
+// Thread Safety analysis tests
+
+
+//-----------------------------------------//
+// Pt Guarded By Attribute (pgb)
+//-----------------------------------------//
+
+#if !__has_attribute(pt_guarded_by)
+#error "Should support pt_guarded_by attribute"
+#endif
+
+//1. Check applied to the right types & argument number
+
+int *pgb_var_noargs __attribute__((pt_guarded_by)); // \
+ // expected-error {{attribute takes one argument}}
+
+int *pgb_ptr_var_arg __attribute__((pt_guarded_by(mu1)));
+
+int *pgb_ptr_var_args __attribute__((guarded_by(mu1, mu2))); // \
+ // expected-error {{attribute takes one argument}}
+
+int pgb_var_args __attribute__((pt_guarded_by(mu1))); // \
+ // expected-warning {{'pt_guarded_by' only applies to pointer types; type here is 'int'}}
+
+class PGBFoo {
+ private:
+ int *pgb_field_noargs __attribute__((pt_guarded_by)); // \
+ // expected-error {{attribute takes one argument}}
+ int *pgb_field_args __attribute__((pt_guarded_by(mu1)));
+};
+
+class __attribute__((pt_guarded_by(mu1))) PGB { // \
+ // expected-warning {{'pt_guarded_by' attribute only applies to fields and global variables}}
+};
+
+void pgb_function() __attribute__((pt_guarded_by(mu1))); // \
+ // expected-warning {{'pt_guarded_by' attribute only applies to fields and global variables}}
+
+void pgb_function_params(int gv_lvar __attribute__((pt_guarded_by(mu1)))); // \
+ // expected-warning {{'pt_guarded_by' attribute only applies to fields and global variables}}
+
+void pgb_testfn(int y){
+ int *x __attribute__((pt_guarded_by(mu1))) = new int(0); // \
+ // expected-warning {{'pt_guarded_by' attribute only applies to fields and global variables}}
+ delete x;
+}
+
+//2. Check argument parsing.
+
+// legal attribute arguments
+int * pgb_var_arg_1 __attribute__((pt_guarded_by(muWrapper.mu)));
+int * pgb_var_arg_2 __attribute__((pt_guarded_by(muDoubleWrapper.muWrapper->mu)));
+int * pgb_var_arg_3 __attribute__((pt_guarded_by(muWrapper.getMu())));
+int * pgb_var_arg_4 __attribute__((pt_guarded_by(*muWrapper.getMuPointer())));
+int * pgb_var_arg_5 __attribute__((pt_guarded_by(&mu1)));
+int * pgb_var_arg_6 __attribute__((pt_guarded_by(muRef)));
+int * pgb_var_arg_7 __attribute__((pt_guarded_by(muDoubleWrapper.getWrapper()->getMu())));
+int * pgb_var_arg_8 __attribute__((pt_guarded_by(muPointer)));
+
+
+// illegal attribute arguments
+int * pgb_var_arg_bad_1 __attribute__((pt_guarded_by(1))); // \
+ // expected-warning {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}}
+int * pgb_var_arg_bad_2 __attribute__((pt_guarded_by("mu"))); // \
+ // expected-warning {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}}
+int * pgb_var_arg_bad_3 __attribute__((pt_guarded_by(muDoublePointer))); // \
+ // expected-warning {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}}
+int * pgb_var_arg_bad_4 __attribute__((pt_guarded_by(umu))); // \
+ // expected-warning {{'pt_guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+
+
+//-----------------------------------------//
+// Acquired After (aa)
+//-----------------------------------------//
+
+// FIXME: Would we like this attribute to take more than 1 arg?
+
+#if !__has_attribute(acquired_after)
+#error "Should support acquired_after attribute"
+#endif
+
+Mu mu_aa __attribute__((acquired_after(mu1)));
+
+Mu aa_var_noargs __attribute__((acquired_after)); // \
+ // expected-error {{attribute takes at least 1 argument}}
+
+class AAFoo {
+ private:
+ Mu aa_field_noargs __attribute__((acquired_after)); // \
+ // expected-error {{attribute takes at least 1 argument}}
+ Mu aa_field_args __attribute__((acquired_after(mu1)));
+};
+
+class __attribute__((acquired_after(mu1))) AA { // \
+ // expected-warning {{'acquired_after' attribute only applies to fields and global variables}}
+};
+
+void aa_function() __attribute__((acquired_after(mu1))); // \
+ // expected-warning {{'acquired_after' attribute only applies to fields and global variables}}
+
+void aa_function_params(int gv_lvar __attribute__((acquired_after(mu1)))); // \
+ // expected-warning {{'acquired_after' attribute only applies to fields and global variables}}
+
+void aa_testfn(int y){
+ Mu x __attribute__((acquired_after(mu1))) = Mu(); // \
+ // expected-warning {{'acquired_after' attribute only applies to fields and global variables}}
+}
+
+//Check argument parsing.
+
+// legal attribute arguments
+Mu aa_var_arg_1 __attribute__((acquired_after(muWrapper.mu)));
+Mu aa_var_arg_2 __attribute__((acquired_after(muDoubleWrapper.muWrapper->mu)));
+Mu aa_var_arg_3 __attribute__((acquired_after(muWrapper.getMu())));
+Mu aa_var_arg_4 __attribute__((acquired_after(*muWrapper.getMuPointer())));
+Mu aa_var_arg_5 __attribute__((acquired_after(&mu1)));
+Mu aa_var_arg_6 __attribute__((acquired_after(muRef)));
+Mu aa_var_arg_7 __attribute__((acquired_after(muDoubleWrapper.getWrapper()->getMu())));
+Mu aa_var_arg_8 __attribute__((acquired_after(muPointer)));
+
+
+// illegal attribute arguments
+Mu aa_var_arg_bad_1 __attribute__((acquired_after(1))); // \
+ // expected-warning {{'acquired_after' attribute requires arguments that are class type or point to class type}}
+Mu aa_var_arg_bad_2 __attribute__((acquired_after("mu"))); // \
+ // expected-warning {{'acquired_after' attribute requires arguments that are class type or point to class type}}
+Mu aa_var_arg_bad_3 __attribute__((acquired_after(muDoublePointer))); // \
+ // expected-warning {{'acquired_after' attribute requires arguments that are class type or point to class type}}
+Mu aa_var_arg_bad_4 __attribute__((acquired_after(umu))); // \
+ // expected-warning {{'acquired_after' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+UnlockableMu aa_var_arg_bad_5 __attribute__((acquired_after(mu_aa))); // \
+ // expected-warning {{'acquired_after' attribute can only be applied in a context annotated with 'lockable' attribute}}
+
+//-----------------------------------------//
+// Acquired Before (ab)
+//-----------------------------------------//
+
+#if !__has_attribute(acquired_before)
+#error "Should support acquired_before attribute"
+#endif
+
+Mu mu_ab __attribute__((acquired_before(mu1)));
+
+Mu ab_var_noargs __attribute__((acquired_before)); // \
+ // expected-error {{attribute takes at least 1 argument}}
+
+class ABFoo {
+ private:
+ Mu ab_field_noargs __attribute__((acquired_before)); // \
+ // expected-error {{attribute takes at least 1 argument}}
+ Mu ab_field_args __attribute__((acquired_before(mu1)));
+};
+
+class __attribute__((acquired_before(mu1))) AB { // \
+ // expected-warning {{'acquired_before' attribute only applies to fields and global variables}}
+};
+
+void ab_function() __attribute__((acquired_before(mu1))); // \
+ // expected-warning {{'acquired_before' attribute only applies to fields and global variables}}
+
+void ab_function_params(int gv_lvar __attribute__((acquired_before(mu1)))); // \
+ // expected-warning {{'acquired_before' attribute only applies to fields and global variables}}
+
+void ab_testfn(int y){
+ Mu x __attribute__((acquired_before(mu1))) = Mu(); // \
+ // expected-warning {{'acquired_before' attribute only applies to fields and global variables}}
+}
+
+// Note: illegal int ab_int __attribute__((acquired_before(mu1))) will
+// be taken care of by warnings that ab__int is not lockable.
+
+//Check argument parsing.
+
+// legal attribute arguments
+Mu ab_var_arg_1 __attribute__((acquired_before(muWrapper.mu)));
+Mu ab_var_arg_2 __attribute__((acquired_before(muDoubleWrapper.muWrapper->mu)));
+Mu ab_var_arg_3 __attribute__((acquired_before(muWrapper.getMu())));
+Mu ab_var_arg_4 __attribute__((acquired_before(*muWrapper.getMuPointer())));
+Mu ab_var_arg_5 __attribute__((acquired_before(&mu1)));
+Mu ab_var_arg_6 __attribute__((acquired_before(muRef)));
+Mu ab_var_arg_7 __attribute__((acquired_before(muDoubleWrapper.getWrapper()->getMu())));
+Mu ab_var_arg_8 __attribute__((acquired_before(muPointer)));
+
+
+// illegal attribute arguments
+Mu ab_var_arg_bad_1 __attribute__((acquired_before(1))); // \
+ // expected-warning {{'acquired_before' attribute requires arguments that are class type or point to class type}}
+Mu ab_var_arg_bad_2 __attribute__((acquired_before("mu"))); // \
+ // expected-warning {{'acquired_before' attribute requires arguments that are class type or point to class type}}
+Mu ab_var_arg_bad_3 __attribute__((acquired_before(muDoublePointer))); // \
+ // expected-warning {{'acquired_before' attribute requires arguments that are class type or point to class type}}
+Mu ab_var_arg_bad_4 __attribute__((acquired_before(umu))); // \
+ // expected-warning {{'acquired_before' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+UnlockableMu ab_var_arg_bad_5 __attribute__((acquired_before(mu_ab))); // \
+ // expected-warning {{'acquired_before' attribute can only be applied in a context annotated with 'lockable' attribute}}
+
+
+//-----------------------------------------//
+// Exclusive Lock Function (elf)
+//-----------------------------------------//
+
+#if !__has_attribute(exclusive_lock_function)
+#error "Should support exclusive_lock_function attribute"
+#endif
+
+// takes zero or more arguments, all locks (vars/fields)
+
+void elf_function() __attribute__((exclusive_lock_function));
+
+void elf_function_args() __attribute__((exclusive_lock_function(mu1, mu2)));
+
+int elf_testfn(int y) __attribute__((exclusive_lock_function));
+
+int elf_testfn(int y) {
+ int x __attribute__((exclusive_lock_function)) = y; // \
+ // expected-warning {{'exclusive_lock_function' attribute only applies to functions and methods}}
+ return x;
+};
+
+int elf_test_var __attribute__((exclusive_lock_function)); // \
+ // expected-warning {{'exclusive_lock_function' attribute only applies to functions and methods}}
+
+class ElfFoo {
+ private:
+ int test_field __attribute__((exclusive_lock_function)); // \
+ // expected-warning {{'exclusive_lock_function' attribute only applies to functions and methods}}
+ void test_method() __attribute__((exclusive_lock_function));
+};
+
+class __attribute__((exclusive_lock_function)) ElfTestClass { // \
+ // expected-warning {{'exclusive_lock_function' attribute only applies to functions and methods}}
+};
+
+void elf_fun_params(int lvar __attribute__((exclusive_lock_function))); // \
+ // expected-warning {{'exclusive_lock_function' attribute only applies to functions and methods}}
+
+// Check argument parsing.
+
+// legal attribute arguments
+int elf_function_1() __attribute__((exclusive_lock_function(muWrapper.mu)));
+int elf_function_2() __attribute__((exclusive_lock_function(muDoubleWrapper.muWrapper->mu)));
+int elf_function_3() __attribute__((exclusive_lock_function(muWrapper.getMu())));
+int elf_function_4() __attribute__((exclusive_lock_function(*muWrapper.getMuPointer())));
+int elf_function_5() __attribute__((exclusive_lock_function(&mu1)));
+int elf_function_6() __attribute__((exclusive_lock_function(muRef)));
+int elf_function_7() __attribute__((exclusive_lock_function(muDoubleWrapper.getWrapper()->getMu())));
+int elf_function_8() __attribute__((exclusive_lock_function(muPointer)));
+int elf_function_9(Mu x) __attribute__((exclusive_lock_function(1)));
+int elf_function_9(Mu x, Mu y) __attribute__((exclusive_lock_function(1,2)));
+
+
+// illegal attribute arguments
+int elf_function_bad_2() __attribute__((exclusive_lock_function("mu"))); // \
+ // expected-warning {{'exclusive_lock_function' attribute requires arguments that are class type or point to class type}}
+int elf_function_bad_3() __attribute__((exclusive_lock_function(muDoublePointer))); // \
+ // expected-warning {{'exclusive_lock_function' attribute requires arguments that are class type or point to class type}}
+int elf_function_bad_4() __attribute__((exclusive_lock_function(umu))); // \
+ // expected-warning {{'exclusive_lock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+
+int elf_function_bad_1() __attribute__((exclusive_lock_function(1))); // \
+ // expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
+int elf_function_bad_5(Mu x) __attribute__((exclusive_lock_function(0))); // \
+ // expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: can only be 1, since there is one parameter}}
+int elf_function_bad_6(Mu x, Mu y) __attribute__((exclusive_lock_function(0))); // \
+ // expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: must be between 1 and 2}}
+int elf_function_bad_7() __attribute__((exclusive_lock_function(0))); // \
+ // expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
+
+
+//-----------------------------------------//
+// Shared Lock Function (slf)
+//-----------------------------------------//
+
+#if !__has_attribute(shared_lock_function)
+#error "Should support shared_lock_function attribute"
+#endif
+
+// takes zero or more arguments, all locks (vars/fields)
+
+void slf_function() __attribute__((shared_lock_function));
+
+void slf_function_args() __attribute__((shared_lock_function(mu1, mu2)));
+
+int slf_testfn(int y) __attribute__((shared_lock_function));
+
+int slf_testfn(int y) {
+ int x __attribute__((shared_lock_function)) = y; // \
+ // expected-warning {{'shared_lock_function' attribute only applies to functions and methods}}
+ return x;
+};
+
+int slf_test_var __attribute__((shared_lock_function)); // \
+ // expected-warning {{'shared_lock_function' attribute only applies to functions and methods}}
+
+void slf_fun_params(int lvar __attribute__((shared_lock_function))); // \
+ // expected-warning {{'shared_lock_function' attribute only applies to functions and methods}}
+
+class SlfFoo {
+ private:
+ int test_field __attribute__((shared_lock_function)); // \
+ // expected-warning {{'shared_lock_function' attribute only applies to functions and methods}}
+ void test_method() __attribute__((shared_lock_function));
+};
+
+class __attribute__((shared_lock_function)) SlfTestClass { // \
+ // expected-warning {{'shared_lock_function' attribute only applies to functions and methods}}
+};
+
+// Check argument parsing.
+
+// legal attribute arguments
+int slf_function_1() __attribute__((shared_lock_function(muWrapper.mu)));
+int slf_function_2() __attribute__((shared_lock_function(muDoubleWrapper.muWrapper->mu)));
+int slf_function_3() __attribute__((shared_lock_function(muWrapper.getMu())));
+int slf_function_4() __attribute__((shared_lock_function(*muWrapper.getMuPointer())));
+int slf_function_5() __attribute__((shared_lock_function(&mu1)));
+int slf_function_6() __attribute__((shared_lock_function(muRef)));
+int slf_function_7() __attribute__((shared_lock_function(muDoubleWrapper.getWrapper()->getMu())));
+int slf_function_8() __attribute__((shared_lock_function(muPointer)));
+int slf_function_9(Mu x) __attribute__((shared_lock_function(1)));
+int slf_function_9(Mu x, Mu y) __attribute__((shared_lock_function(1,2)));
+
+
+// illegal attribute arguments
+int slf_function_bad_2() __attribute__((shared_lock_function("mu"))); // \
+ // expected-warning {{'shared_lock_function' attribute requires arguments that are class type or point to class type}}
+int slf_function_bad_3() __attribute__((shared_lock_function(muDoublePointer))); // \
+ // expected-warning {{'shared_lock_function' attribute requires arguments that are class type or point to class type}}
+int slf_function_bad_4() __attribute__((shared_lock_function(umu))); // \
+ // expected-warning {{'shared_lock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+
+int slf_function_bad_1() __attribute__((shared_lock_function(1))); // \
+ // expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
+int slf_function_bad_5(Mu x) __attribute__((shared_lock_function(0))); // \
+ // expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: can only be 1, since there is one parameter}}
+int slf_function_bad_6(Mu x, Mu y) __attribute__((shared_lock_function(0))); // \
+ // expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: must be between 1 and 2}}
+int slf_function_bad_7() __attribute__((shared_lock_function(0))); // \
+ // expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
+
+
+//-----------------------------------------//
+// Exclusive TryLock Function (etf)
+//-----------------------------------------//
+
+#if !__has_attribute(exclusive_trylock_function)
+#error "Should support exclusive_trylock_function attribute"
+#endif
+
+// takes a mandatory boolean or integer argument specifying the retval
+// plus an optional list of locks (vars/fields)
+
+void etf_function() __attribute__((exclusive_trylock_function)); // \
+ // expected-error {{attribute takes at least 1 argument}}
+
+void etf_function_args() __attribute__((exclusive_trylock_function(1, mu2)));
+
+void etf_function_arg() __attribute__((exclusive_trylock_function(1)));
+
+int etf_testfn(int y) __attribute__((exclusive_trylock_function(1)));
+
+int etf_testfn(int y) {
+ int x __attribute__((exclusive_trylock_function(1))) = y; // \
+ // expected-warning {{'exclusive_trylock_function' attribute only applies to functions and methods}}
+ return x;
+};
+
+int etf_test_var __attribute__((exclusive_trylock_function(1))); // \
+ // expected-warning {{'exclusive_trylock_function' attribute only applies to functions and methods}}
+
+class EtfFoo {
+ private:
+ int test_field __attribute__((exclusive_trylock_function(1))); // \
+ // expected-warning {{'exclusive_trylock_function' attribute only applies to functions and methods}}
+ void test_method() __attribute__((exclusive_trylock_function(1)));
+};
+
+class __attribute__((exclusive_trylock_function(1))) EtfTestClass { // \
+ // expected-warning {{'exclusive_trylock_function' attribute only applies to functions and methods}}
+};
+
+void etf_fun_params(int lvar __attribute__((exclusive_trylock_function(1)))); // \
+ // expected-warning {{'exclusive_trylock_function' attribute only applies to functions and methods}}
+
+// Check argument parsing.
+
+// legal attribute arguments
+int etf_function_1() __attribute__((exclusive_trylock_function(1, muWrapper.mu)));
+int etf_function_2() __attribute__((exclusive_trylock_function(1, muDoubleWrapper.muWrapper->mu)));
+int etf_function_3() __attribute__((exclusive_trylock_function(1, muWrapper.getMu())));
+int etf_function_4() __attribute__((exclusive_trylock_function(1, *muWrapper.getMuPointer())));
+int etf_function_5() __attribute__((exclusive_trylock_function(1, &mu1)));
+int etf_function_6() __attribute__((exclusive_trylock_function(1, muRef)));
+int etf_function_7() __attribute__((exclusive_trylock_function(1, muDoubleWrapper.getWrapper()->getMu())));
+int etf_functetfn_8() __attribute__((exclusive_trylock_function(1, muPointer)));
+int etf_function_9() __attribute__((exclusive_trylock_function(true)));
+
+
+// illegal attribute arguments
+int etf_function_bad_1() __attribute__((exclusive_trylock_function(mu1))); // \
+ // expected-error {{'exclusive_trylock_function' attribute first argument must be of int or bool type}}
+int etf_function_bad_2() __attribute__((exclusive_trylock_function("mu"))); // \
+ // expected-error {{'exclusive_trylock_function' attribute first argument must be of int or bool type}}
+int etf_function_bad_3() __attribute__((exclusive_trylock_function(muDoublePointer))); // \
+ // expected-error {{'exclusive_trylock_function' attribute first argument must be of int or bool type}}
+
+int etf_function_bad_4() __attribute__((exclusive_trylock_function(1, "mu"))); // \
+ // expected-warning {{'exclusive_trylock_function' attribute requires arguments that are class type or point to class type}}
+int etf_function_bad_5() __attribute__((exclusive_trylock_function(1, muDoublePointer))); // \
+ // expected-warning {{'exclusive_trylock_function' attribute requires arguments that are class type or point to class type}}
+int etf_function_bad_6() __attribute__((exclusive_trylock_function(1, umu))); // \
+ // expected-warning {{'exclusive_trylock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+
+
+//-----------------------------------------//
+// Shared TryLock Function (stf)
+//-----------------------------------------//
+
+#if !__has_attribute(shared_trylock_function)
+#error "Should support shared_trylock_function attribute"
+#endif
+
+// takes a mandatory boolean or integer argument specifying the retval
+// plus an optional list of locks (vars/fields)
+
+void stf_function() __attribute__((shared_trylock_function)); // \
+ // expected-error {{attribute takes at least 1 argument}}
+
+void stf_function_args() __attribute__((shared_trylock_function(1, mu2)));
+
+void stf_function_arg() __attribute__((shared_trylock_function(1)));
+
+int stf_testfn(int y) __attribute__((shared_trylock_function(1)));
+
+int stf_testfn(int y) {
+ int x __attribute__((shared_trylock_function(1))) = y; // \
+ // expected-warning {{'shared_trylock_function' attribute only applies to functions and methods}}
+ return x;
+};
+
+int stf_test_var __attribute__((shared_trylock_function(1))); // \
+ // expected-warning {{'shared_trylock_function' attribute only applies to functions and methods}}
+
+void stf_fun_params(int lvar __attribute__((shared_trylock_function(1)))); // \
+ // expected-warning {{'shared_trylock_function' attribute only applies to functions and methods}}
+
+
+class StfFoo {
+ private:
+ int test_field __attribute__((shared_trylock_function(1))); // \
+ // expected-warning {{'shared_trylock_function' attribute only applies to functions and methods}}
+ void test_method() __attribute__((shared_trylock_function(1)));
+};
+
+class __attribute__((shared_trylock_function(1))) StfTestClass { // \
+ // expected-warning {{'shared_trylock_function' attribute only applies to functions and methods}}
+};
+
+// Check argument parsing.
+
+// legal attribute arguments
+int stf_function_1() __attribute__((shared_trylock_function(1, muWrapper.mu)));
+int stf_function_2() __attribute__((shared_trylock_function(1, muDoubleWrapper.muWrapper->mu)));
+int stf_function_3() __attribute__((shared_trylock_function(1, muWrapper.getMu())));
+int stf_function_4() __attribute__((shared_trylock_function(1, *muWrapper.getMuPointer())));
+int stf_function_5() __attribute__((shared_trylock_function(1, &mu1)));
+int stf_function_6() __attribute__((shared_trylock_function(1, muRef)));
+int stf_function_7() __attribute__((shared_trylock_function(1, muDoubleWrapper.getWrapper()->getMu())));
+int stf_function_8() __attribute__((shared_trylock_function(1, muPointer)));
+int stf_function_9() __attribute__((shared_trylock_function(true)));
+
+
+// illegal attribute arguments
+int stf_function_bad_1() __attribute__((shared_trylock_function(mu1))); // \
+ // expected-error {{'shared_trylock_function' attribute first argument must be of int or bool type}}
+int stf_function_bad_2() __attribute__((shared_trylock_function("mu"))); // \
+ // expected-error {{'shared_trylock_function' attribute first argument must be of int or bool type}}
+int stf_function_bad_3() __attribute__((shared_trylock_function(muDoublePointer))); // \
+ // expected-error {{'shared_trylock_function' attribute first argument must be of int or bool type}}
+
+int stf_function_bad_4() __attribute__((shared_trylock_function(1, "mu"))); // \
+ // expected-warning {{'shared_trylock_function' attribute requires arguments that are class type or point to class type}}
+int stf_function_bad_5() __attribute__((shared_trylock_function(1, muDoublePointer))); // \
+ // expected-warning {{'shared_trylock_function' attribute requires arguments that are class type or point to class type}}
+int stf_function_bad_6() __attribute__((shared_trylock_function(1, umu))); // \
+ // expected-warning {{'shared_trylock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+
+
+//-----------------------------------------//
+// Unlock Function (uf)
+//-----------------------------------------//
+
+#if !__has_attribute(unlock_function)
+#error "Should support unlock_function attribute"
+#endif
+
+// takes zero or more arguments, all locks (vars/fields)
+
+void uf_function() __attribute__((unlock_function));
+
+void uf_function_args() __attribute__((unlock_function(mu1, mu2)));
+
+int uf_testfn(int y) __attribute__((unlock_function));
+
+int uf_testfn(int y) {
+ int x __attribute__((unlock_function)) = y; // \
+ // expected-warning {{'unlock_function' attribute only applies to functions and methods}}
+ return x;
+};
+
+int uf_test_var __attribute__((unlock_function)); // \
+ // expected-warning {{'unlock_function' attribute only applies to functions and methods}}
+
+class UfFoo {
+ private:
+ int test_field __attribute__((unlock_function)); // \
+ // expected-warning {{'unlock_function' attribute only applies to functions and methods}}
+ void test_method() __attribute__((unlock_function));
+};
+
+class __attribute__((no_thread_safety_analysis)) UfTestClass { // \
+ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}}
+};
+
+void uf_fun_params(int lvar __attribute__((unlock_function))); // \
+ // expected-warning {{'unlock_function' attribute only applies to functions and methods}}
+
+// Check argument parsing.
+
+// legal attribute arguments
+int uf_function_1() __attribute__((unlock_function(muWrapper.mu)));
+int uf_function_2() __attribute__((unlock_function(muDoubleWrapper.muWrapper->mu)));
+int uf_function_3() __attribute__((unlock_function(muWrapper.getMu())));
+int uf_function_4() __attribute__((unlock_function(*muWrapper.getMuPointer())));
+int uf_function_5() __attribute__((unlock_function(&mu1)));
+int uf_function_6() __attribute__((unlock_function(muRef)));
+int uf_function_7() __attribute__((unlock_function(muDoubleWrapper.getWrapper()->getMu())));
+int uf_function_8() __attribute__((unlock_function(muPointer)));
+int uf_function_9(Mu x) __attribute__((unlock_function(1)));
+int uf_function_9(Mu x, Mu y) __attribute__((unlock_function(1,2)));
+
+
+// illegal attribute arguments
+int uf_function_bad_2() __attribute__((unlock_function("mu"))); // \
+ // expected-warning {{'unlock_function' attribute requires arguments that are class type or point to class type}}
+int uf_function_bad_3() __attribute__((unlock_function(muDoublePointer))); // \
+ // expected-warning {{'unlock_function' attribute requires arguments that are class type or point to class type}}
+int uf_function_bad_4() __attribute__((unlock_function(umu))); // \
+ // expected-warning {{'unlock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+
+int uf_function_bad_1() __attribute__((unlock_function(1))); // \
+ // expected-error {{'unlock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
+int uf_function_bad_5(Mu x) __attribute__((unlock_function(0))); // \
+ // expected-error {{'unlock_function' attribute parameter 1 is out of bounds: can only be 1, since there is one parameter}}
+int uf_function_bad_6(Mu x, Mu y) __attribute__((unlock_function(0))); // \
+ // expected-error {{'unlock_function' attribute parameter 1 is out of bounds: must be between 1 and 2}}
+int uf_function_bad_7() __attribute__((unlock_function(0))); // \
+ // expected-error {{'unlock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
+
+
+//-----------------------------------------//
+// Lock Returned (lr)
+//-----------------------------------------//
+
+#if !__has_attribute(lock_returned)
+#error "Should support lock_returned attribute"
+#endif
+
+// Takes exactly one argument, a var/field
+
+void lr_function() __attribute__((lock_returned)); // \
+ // expected-error {{attribute takes one argument}}
+
+void lr_function_arg() __attribute__((lock_returned(mu1)));
+
+void lr_function_args() __attribute__((lock_returned(mu1, mu2))); // \
+ // expected-error {{attribute takes one argument}}
+
+int lr_testfn(int y) __attribute__((lock_returned(mu1)));
+
+int lr_testfn(int y) {
+ int x __attribute__((lock_returned(mu1))) = y; // \
+ // expected-warning {{'lock_returned' attribute only applies to functions and methods}}
+ return x;
+};
+
+int lr_test_var __attribute__((lock_returned(mu1))); // \
+ // expected-warning {{'lock_returned' attribute only applies to functions and methods}}
+
+void lr_fun_params(int lvar __attribute__((lock_returned(mu1)))); // \
+ // expected-warning {{'lock_returned' attribute only applies to functions and methods}}
+
+class LrFoo {
+ private:
+ int test_field __attribute__((lock_returned(mu1))); // \
+ // expected-warning {{'lock_returned' attribute only applies to functions and methods}}
+ void test_method() __attribute__((lock_returned(mu1)));
+};
+
+class __attribute__((lock_returned(mu1))) LrTestClass { // \
+ // expected-warning {{'lock_returned' attribute only applies to functions and methods}}
+};
+
+// Check argument parsing.
+
+// legal attribute arguments
+int lr_function_1() __attribute__((lock_returned(muWrapper.mu)));
+int lr_function_2() __attribute__((lock_returned(muDoubleWrapper.muWrapper->mu)));
+int lr_function_3() __attribute__((lock_returned(muWrapper.getMu())));
+int lr_function_4() __attribute__((lock_returned(*muWrapper.getMuPointer())));
+int lr_function_5() __attribute__((lock_returned(&mu1)));
+int lr_function_6() __attribute__((lock_returned(muRef)));
+int lr_function_7() __attribute__((lock_returned(muDoubleWrapper.getWrapper()->getMu())));
+int lr_function_8() __attribute__((lock_returned(muPointer)));
+
+
+// illegal attribute arguments
+int lr_function_bad_1() __attribute__((lock_returned(1))); // \
+ // expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}}
+int lr_function_bad_2() __attribute__((lock_returned("mu"))); // \
+ // expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}}
+int lr_function_bad_3() __attribute__((lock_returned(muDoublePointer))); // \
+ // expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}}
+int lr_function_bad_4() __attribute__((lock_returned(umu))); // \
+ // expected-warning {{'lock_returned' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+
+
+
+//-----------------------------------------//
+// Locks Excluded (le)
+//-----------------------------------------//
+
+#if !__has_attribute(locks_excluded)
+#error "Should support locks_excluded attribute"
+#endif
+
+// takes one or more arguments, all locks (vars/fields)
+
+void le_function() __attribute__((locks_excluded)); // \
+ // expected-error {{attribute takes at least 1 argument}}
+
+void le_function_arg() __attribute__((locks_excluded(mu1)));
+
+void le_function_args() __attribute__((locks_excluded(mu1, mu2)));
+
+int le_testfn(int y) __attribute__((locks_excluded(mu1)));
+
+int le_testfn(int y) {
+ int x __attribute__((locks_excluded(mu1))) = y; // \
+ // expected-warning {{'locks_excluded' attribute only applies to functions and methods}}
+ return x;
+};
+
+int le_test_var __attribute__((locks_excluded(mu1))); // \
+ // expected-warning {{'locks_excluded' attribute only applies to functions and methods}}
+
+void le_fun_params(int lvar __attribute__((locks_excluded(mu1)))); // \
+ // expected-warning {{'locks_excluded' attribute only applies to functions and methods}}
+
+class LeFoo {
+ private:
+ int test_field __attribute__((locks_excluded(mu1))); // \
+ // expected-warning {{'locks_excluded' attribute only applies to functions and methods}}
+ void test_method() __attribute__((locks_excluded(mu1)));
+};
+
+class __attribute__((locks_excluded(mu1))) LeTestClass { // \
+ // expected-warning {{'locks_excluded' attribute only applies to functions and methods}}
+};
+
+// Check argument parsing.
+
+// legal attribute arguments
+int le_function_1() __attribute__((locks_excluded(muWrapper.mu)));
+int le_function_2() __attribute__((locks_excluded(muDoubleWrapper.muWrapper->mu)));
+int le_function_3() __attribute__((locks_excluded(muWrapper.getMu())));
+int le_function_4() __attribute__((locks_excluded(*muWrapper.getMuPointer())));
+int le_function_5() __attribute__((locks_excluded(&mu1)));
+int le_function_6() __attribute__((locks_excluded(muRef)));
+int le_function_7() __attribute__((locks_excluded(muDoubleWrapper.getWrapper()->getMu())));
+int le_function_8() __attribute__((locks_excluded(muPointer)));
+
+
+// illegal attribute arguments
+int le_function_bad_1() __attribute__((locks_excluded(1))); // \
+ // expected-warning {{'locks_excluded' attribute requires arguments that are class type or point to class type}}
+int le_function_bad_2() __attribute__((locks_excluded("mu"))); // \
+ // expected-warning {{'locks_excluded' attribute requires arguments that are class type or point to class type}}
+int le_function_bad_3() __attribute__((locks_excluded(muDoublePointer))); // \
+ // expected-warning {{'locks_excluded' attribute requires arguments that are class type or point to class type}}
+int le_function_bad_4() __attribute__((locks_excluded(umu))); // \
+ // expected-warning {{'locks_excluded' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+
+
+
+//-----------------------------------------//
+// Exclusive Locks Required (elr)
+//-----------------------------------------//
+
+#if !__has_attribute(exclusive_locks_required)
+#error "Should support exclusive_locks_required attribute"
+#endif
+
+// takes one or more arguments, all locks (vars/fields)
+
+void elr_function() __attribute__((exclusive_locks_required)); // \
+ // expected-error {{attribute takes at least 1 argument}}
+
+void elr_function_arg() __attribute__((exclusive_locks_required(mu1)));
+
+void elr_function_args() __attribute__((exclusive_locks_required(mu1, mu2)));
+
+int elr_testfn(int y) __attribute__((exclusive_locks_required(mu1)));
+
+int elr_testfn(int y) {
+ int x __attribute__((exclusive_locks_required(mu1))) = y; // \
+ // expected-warning {{'exclusive_locks_required' attribute only applies to functions and methods}}
+ return x;
+};
+
+int elr_test_var __attribute__((exclusive_locks_required(mu1))); // \
+ // expected-warning {{'exclusive_locks_required' attribute only applies to functions and methods}}
+
+void elr_fun_params(int lvar __attribute__((exclusive_locks_required(mu1)))); // \
+ // expected-warning {{'exclusive_locks_required' attribute only applies to functions and methods}}
+
+class ElrFoo {
+ private:
+ int test_field __attribute__((exclusive_locks_required(mu1))); // \
+ // expected-warning {{'exclusive_locks_required' attribute only applies to functions and methods}}
+ void test_method() __attribute__((exclusive_locks_required(mu1)));
+};
+
+class __attribute__((exclusive_locks_required(mu1))) ElrTestClass { // \
+ // expected-warning {{'exclusive_locks_required' attribute only applies to functions and methods}}
+};
+
+// Check argument parsing.
+
+// legal attribute arguments
+int elr_function_1() __attribute__((exclusive_locks_required(muWrapper.mu)));
+int elr_function_2() __attribute__((exclusive_locks_required(muDoubleWrapper.muWrapper->mu)));
+int elr_function_3() __attribute__((exclusive_locks_required(muWrapper.getMu())));
+int elr_function_4() __attribute__((exclusive_locks_required(*muWrapper.getMuPointer())));
+int elr_function_5() __attribute__((exclusive_locks_required(&mu1)));
+int elr_function_6() __attribute__((exclusive_locks_required(muRef)));
+int elr_function_7() __attribute__((exclusive_locks_required(muDoubleWrapper.getWrapper()->getMu())));
+int elr_function_8() __attribute__((exclusive_locks_required(muPointer)));
+
+
+// illegal attribute arguments
+int elr_function_bad_1() __attribute__((exclusive_locks_required(1))); // \
+ // expected-warning {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}}
+int elr_function_bad_2() __attribute__((exclusive_locks_required("mu"))); // \
+ // expected-warning {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}}
+int elr_function_bad_3() __attribute__((exclusive_locks_required(muDoublePointer))); // \
+ // expected-warning {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}}
+int elr_function_bad_4() __attribute__((exclusive_locks_required(umu))); // \
+ // expected-warning {{'exclusive_locks_required' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+
+
+
+
+//-----------------------------------------//
+// Shared Locks Required (slr)
+//-----------------------------------------//
+
+#if !__has_attribute(shared_locks_required)
+#error "Should support shared_locks_required attribute"
+#endif
+
+// takes one or more arguments, all locks (vars/fields)
+
+void slr_function() __attribute__((shared_locks_required)); // \
+ // expected-error {{attribute takes at least 1 argument}}
+
+void slr_function_arg() __attribute__((shared_locks_required(mu1)));
+
+void slr_function_args() __attribute__((shared_locks_required(mu1, mu2)));
+
+int slr_testfn(int y) __attribute__((shared_locks_required(mu1)));
+
+int slr_testfn(int y) {
+ int x __attribute__((shared_locks_required(mu1))) = y; // \
+ // expected-warning {{'shared_locks_required' attribute only applies to functions and methods}}
+ return x;
+};
+
+int slr_test_var __attribute__((shared_locks_required(mu1))); // \
+ // expected-warning {{'shared_locks_required' attribute only applies to functions and methods}}
+
+void slr_fun_params(int lvar __attribute__((shared_locks_required(mu1)))); // \
+ // expected-warning {{'shared_locks_required' attribute only applies to functions and methods}}
+
+class SlrFoo {
+ private:
+ int test_field __attribute__((shared_locks_required(mu1))); // \
+ // expected-warning {{'shared_locks_required' attribute only applies to functions and methods}}
+ void test_method() __attribute__((shared_locks_required(mu1)));
+};
+
+class __attribute__((shared_locks_required(mu1))) SlrTestClass { // \
+ // expected-warning {{'shared_locks_required' attribute only applies to functions and methods}}
+};
+
+// Check argument parsing.
+
+// legal attribute arguments
+int slr_function_1() __attribute__((shared_locks_required(muWrapper.mu)));
+int slr_function_2() __attribute__((shared_locks_required(muDoubleWrapper.muWrapper->mu)));
+int slr_function_3() __attribute__((shared_locks_required(muWrapper.getMu())));
+int slr_function_4() __attribute__((shared_locks_required(*muWrapper.getMuPointer())));
+int slr_function_5() __attribute__((shared_locks_required(&mu1)));
+int slr_function_6() __attribute__((shared_locks_required(muRef)));
+int slr_function_7() __attribute__((shared_locks_required(muDoubleWrapper.getWrapper()->getMu())));
+int slr_function_8() __attribute__((shared_locks_required(muPointer)));
+
+
+// illegal attribute arguments
+int slr_function_bad_1() __attribute__((shared_locks_required(1))); // \
+ // expected-warning {{'shared_locks_required' attribute requires arguments that are class type or point to class type}}
+int slr_function_bad_2() __attribute__((shared_locks_required("mu"))); // \
+ // expected-warning {{'shared_locks_required' attribute requires arguments that are class type or point to class type}}
+int slr_function_bad_3() __attribute__((shared_locks_required(muDoublePointer))); // \
+ // expected-warning {{'shared_locks_required' attribute requires arguments that are class type or point to class type}}
+int slr_function_bad_4() __attribute__((shared_locks_required(umu))); // \
+ // expected-warning {{'shared_locks_required' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+
+
+//-----------------------------------------//
+// Regression tests for unusual cases.
+//-----------------------------------------//
+
+int trivially_false_edges(bool b) {
+ // Create NULL (never taken) edges in CFG
+ if (false) return 1;
+ else return 2;
+}
+
+// Possible Clang bug -- method pointer in template parameter
+class UnFoo {
+public:
+ void foo();
+};
+
+template<void (UnFoo::*methptr)()>
+class MCaller {
+public:
+ static void call_method_ptr(UnFoo *f) {
+ // FIXME: Possible Clang bug:
+ // getCalleeDecl() returns NULL in the following case:
+ (f->*methptr)();
+ }
+};
+
+void call_method_ptr_inst(UnFoo* f) {
+ MCaller<&UnFoo::foo>::call_method_ptr(f);
+}
+
+int temp;
+void empty_back_edge() {
+ // Create a back edge to a block with with no statements
+ for (;;) {
+ ++temp;
+ if (temp > 10) break;
+ }
+}
+
+struct Foomger {
+ void operator++();
+};
+
+struct Foomgoper {
+ Foomger f;
+
+ bool done();
+ void invalid_back_edge() {
+ do {
+ // FIXME: Possible Clang bug:
+ // The first statement in this basic block has no source location
+ ++f;
+ } while (!done());
+ }
+};
+
+
+//-----------------------------------------------------
+// Parsing of member variables and function parameters
+//------------------------------------------------------
+
+Mu gmu;
+
+class StaticMu {
+ static Mu statmu;
+};
+
+class FooLate {
+public:
+ void foo1() __attribute__((exclusive_locks_required(gmu))) { }
+ void foo2() __attribute__((exclusive_locks_required(mu))) { }
+ void foo3(Mu *m) __attribute__((exclusive_locks_required(m))) { }
+ void foo3(FooLate *f) __attribute__((exclusive_locks_required(f->mu))) { }
+ void foo4(FooLate *f) __attribute__((exclusive_locks_required(f->mu)));
+
+ static void foo5() __attribute__((exclusive_locks_required(mu))); // \
+ // expected-error {{'this' cannot be implicitly used in a static member function declaration}}
+
+ template <class T>
+ void foo6() __attribute__((exclusive_locks_required(T::statmu))) { }
+
+ template <class T>
+ void foo7(T* f) __attribute__((exclusive_locks_required(f->mu))) { }
+
+ int a __attribute__((guarded_by(gmu)));
+ int b __attribute__((guarded_by(mu)));
+ int c __attribute__((guarded_by(this->mu)));
+
+ Mu mu;
+};
+
+//-------------------------
+// Empty argument lists
+//-------------------------
+
+class __attribute__((lockable)) EmptyArgListsTest {
+ void lock() __attribute__((exclusive_lock_function())) { }
+ void unlock() __attribute__((unlock_function())) { }
+};
+
+
+namespace FunctionDefinitionParseTest {
+// Test parsing of attributes on function definitions.
+
+class Foo {
+public:
+ Mu mu_;
+ void foo1();
+ void foo2(Foo *f);
+};
+
+template <class T>
+class Bar {
+public:
+ Mu mu_;
+ void bar();
+};
+
+void Foo::foo1() __attribute__((exclusive_locks_required(mu_))) { }
+void Foo::foo2(Foo *f) __attribute__((exclusive_locks_required(f->mu_))) { }
+
+template <class T>
+void Bar<T>::bar() __attribute__((exclusive_locks_required(mu_))) { }
+
+void baz(Foo *f) __attribute__((exclusive_locks_required(f->mu_))) { }
+
+} // end namespace
+
+
+namespace TestMultiDecl {
+
+class Foo {
+public:
+ int __attribute__((guarded_by(mu_))) a;
+ int __attribute__((guarded_by(mu_))) b, c;
+
+private:
+ Mu mu_;
+};
+
+
+namespace NestedClassLateDecl {
+
+class Foo {
+ class Bar {
+ int a GUARDED_BY(mu);
+ int b GUARDED_BY(fooMuStatic);
+
+ void bar() EXCLUSIVE_LOCKS_REQUIRED(mu) { a = 0; }
+ void bar2(Bar* b) EXCLUSIVE_LOCKS_REQUIRED(b->mu) { b->a = 0; }
+ void bar3(Foo* f) EXCLUSIVE_LOCKS_REQUIRED(f->fooMu) { f->a = 0; }
+
+ Mu mu;
+ };
+
+ int a GUARDED_BY(fooMu);
+ Mu fooMu;
+ static Mu fooMuStatic;
+};
+
+}
+
+} // end namespace TestMultiDecl
+
diff --git a/clang/test/SemaCXX/warn-unreachable.cpp b/clang/test/SemaCXX/warn-unreachable.cpp
new file mode 100644
index 0000000..f36300a
--- /dev/null
+++ b/clang/test/SemaCXX/warn-unreachable.cpp
@@ -0,0 +1,109 @@
+// RUN: %clang_cc1 %s -fcxx-exceptions -fexceptions -fsyntax-only -verify -fblocks -Wunreachable-code -Wno-unused-value
+
+int &halt() __attribute__((noreturn));
+int &live();
+int dead();
+int liveti() throw(int);
+int (*livetip)() throw(int);
+
+int test1() {
+ try {
+ live();
+ } catch (int i) {
+ live();
+ }
+ return 1;
+}
+
+void test2() {
+ try {
+ live();
+ } catch (int i) {
+ live();
+ }
+ try {
+ liveti();
+ } catch (int i) {
+ live();
+ }
+ try {
+ livetip();
+ } catch (int i) {
+ live();
+ }
+ throw 1;
+ dead(); // expected-warning {{will never be executed}}
+}
+
+
+void test3() {
+ halt()
+ --; // expected-warning {{will never be executed}}
+ // FIXME: The unreachable part is just the '?', but really all of this
+ // code is unreachable and shouldn't be separately reported.
+ halt() // expected-warning {{will never be executed}}
+ ?
+ dead() : dead();
+ live(),
+ float
+ (halt()); // expected-warning {{will never be executed}}
+}
+
+void test4() {
+ struct S {
+ int mem;
+ } s;
+ S &foor();
+ halt(), foor()// expected-warning {{will never be executed}}
+ .mem;
+}
+
+void test5() {
+ struct S {
+ int mem;
+ } s;
+ S &foor() __attribute__((noreturn));
+ foor()
+ .mem; // expected-warning {{will never be executed}}
+}
+
+void test6() {
+ struct S {
+ ~S() { }
+ S(int i) { }
+ };
+ live(),
+ S
+ (halt()); // expected-warning {{will never be executed}}
+}
+
+// Don't warn about unreachable code in template instantiations, as
+// they may only be unreachable in that specific instantiation.
+void isUnreachable();
+
+template <typename T> void test_unreachable_templates() {
+ T::foo();
+ isUnreachable(); // no-warning
+}
+
+struct TestUnreachableA {
+ static void foo() __attribute__((noreturn));
+};
+struct TestUnreachableB {
+ static void foo();
+};
+
+void test_unreachable_templates_harness() {
+ test_unreachable_templates<TestUnreachableA>();
+ test_unreachable_templates<TestUnreachableB>();
+}
+
+// Do warn about explict template specializations, as they represent
+// actual concrete functions that somebody wrote.
+
+template <typename T> void funcToSpecialize() {}
+template <> void funcToSpecialize<int>() {
+ halt();
+ dead(); // expected-warning {{will never be executed}}
+}
+
diff --git a/clang/test/SemaCXX/warn-unused-comparison.cpp b/clang/test/SemaCXX/warn-unused-comparison.cpp
new file mode 100644
index 0000000..0153f21
--- /dev/null
+++ b/clang/test/SemaCXX/warn-unused-comparison.cpp
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -Wno-unused -Wunused-comparison %s
+
+struct A {
+ bool operator==(const A&);
+ bool operator!=(const A&);
+ A operator|=(const A&);
+ operator bool();
+};
+
+void test() {
+ int x, *p;
+ A a, b;
+
+ x == 7; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ x != 7; // expected-warning {{inequality comparison result unused}} \
+ // expected-note {{use '|=' to turn this inequality comparison into an or-assignment}}
+ 7 == x; // expected-warning {{equality comparison result unused}}
+ p == p; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}} \
+ // expected-warning {{self-comparison always evaluates to true}}
+ a == a; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ a == b; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ a != b; // expected-warning {{inequality comparison result unused}} \
+ // expected-note {{use '|=' to turn this inequality comparison into an or-assignment}}
+ A() == b; // expected-warning {{equality comparison result unused}}
+ if (42) x == 7; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ else if (42) x == 7; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ else x == 7; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ do x == 7; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ while (false);
+ while (false) x == 7; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ for (x == 7; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ x == 7; // No warning -- result is used
+ x == 7) // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ x == 7; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ switch (42) default: x == 7; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ switch (42) case 42: x == 7; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ switch (42) {
+ case 1:
+ case 2:
+ default:
+ case 3:
+ case 4:
+ x == 7; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ }
+
+ (void)(x == 7);
+ (void)(p == p); // expected-warning {{self-comparison always evaluates to true}}
+ { bool b = x == 7; }
+
+ { bool b = ({ x == 7; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ x == 7; }); } // no warning on the second, its result is used!
+
+#define EQ(x,y) (x) == (y)
+ EQ(x, 5);
+#undef EQ
+}
+
+namespace PR10291 {
+ template<typename T>
+ class X
+ {
+ public:
+
+ X() : i(0) { }
+
+ void foo()
+ {
+ throw
+ i == 0u ?
+ 5 : 6;
+ }
+
+ private:
+ int i;
+ };
+
+ X<int> x;
+}
diff --git a/clang/test/SemaCXX/warn-unused-filescoped.cpp b/clang/test/SemaCXX/warn-unused-filescoped.cpp
new file mode 100644
index 0000000..dbff4b0
--- /dev/null
+++ b/clang/test/SemaCXX/warn-unused-filescoped.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function %s
+
+static void f1(); // expected-warning{{unused}}
+
+namespace {
+ void f2(); // expected-warning{{unused}}
+
+ void f3() { } // expected-warning{{unused}}
+
+ struct S {
+ void m1() { } // expected-warning{{unused}}
+ void m2(); // expected-warning{{unused}}
+ void m3();
+ S(const S&);
+ void operator=(const S&);
+ };
+
+ template <typename T>
+ struct TS {
+ void m();
+ };
+ template <> void TS<int>::m() { } // expected-warning{{unused}}
+
+ template <typename T>
+ void tf() { }
+ template <> void tf<int>() { } // expected-warning{{unused}}
+
+ struct VS {
+ virtual void vm() { }
+ };
+
+ struct SVS : public VS {
+ void vm() { }
+ };
+}
+
+void S::m3() { } // expected-warning{{unused}}
+
+static inline void f4() { }
+const unsigned int cx = 0;
+
+static int x1; // expected-warning{{unused}}
+
+namespace {
+ int x2; // expected-warning{{unused}}
+
+ struct S2 {
+ static int x; // expected-warning{{unused}}
+ };
+
+ template <typename T>
+ struct TS2 {
+ static int x;
+ };
+ template <> int TS2<int>::x; // expected-warning{{unused}}
+}
+
+namespace PR8841 {
+ // Ensure that friends of class templates are considered to have a dependent
+ // context and not marked unused.
+ namespace {
+ template <typename T> struct X {
+ friend bool operator==(const X&, const X&) { return false; }
+ };
+ }
+ template <typename T> void template_test(X<T> x) {
+ (void)(x == x);
+ }
+ void test() {
+ X<int> x;
+ template_test(x);
+ }
+}
+
+namespace test4 {
+ namespace { struct A {}; }
+
+ void test(A a); // expected-warning {{unused function}}
+ extern "C" void test4(A a);
+}
+
+namespace rdar8733476 {
+ static void foo() { } // expected-warning {{not needed and will not be emitted}}
+
+ template <int>
+ void bar() {
+ foo();
+ }
+}
diff --git a/clang/test/SemaCXX/warn-unused-parameters.cpp b/clang/test/SemaCXX/warn-unused-parameters.cpp
new file mode 100644
index 0000000..00ce1a9
--- /dev/null
+++ b/clang/test/SemaCXX/warn-unused-parameters.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify -std=c++11 %s
+template<typename T>
+struct X {
+ T f0(T x);
+ T f1(T x);
+ T f2(T);
+ template<typename U> U f3(U x);
+ template<typename U> U f4(U x);
+ template<typename U> U f5(U);
+};
+
+template<typename T> T X<T>::f0(T x) { return x; }
+template<typename T> T X<T>::f1(T) { return T(); }
+template<typename T> T X<T>::f2(T x) { return T(); } // expected-warning{{unused parameter 'x'}}
+template<typename T> template<typename U> U X<T>::f3(U x) { return x; }
+template<typename T> template<typename U> U X<T>::f4(U) { return U(); }
+template<typename T> template<typename U> U X<T>::f5(U x) { return U(); } // expected-warning{{unused parameter 'x'}}
+
+void test_X(X<int> &x, int i) {
+ x.f0(i);
+ x.f1(i);
+ x.f2(i);
+ x.f3(i);
+ x.f4(i);
+ x.f5(i);
+}
+
+// Make sure both parameters aren't considered unused.
+template <typename... T>
+static int test_pack(T... t, T... s)
+{
+ auto l = [&t...]() { return sizeof...(s); };
+ return l();
+}
diff --git a/clang/test/SemaCXX/warn-unused-result.cpp b/clang/test/SemaCXX/warn-unused-result.cpp
new file mode 100644
index 0000000..d14fdf9
--- /dev/null
+++ b/clang/test/SemaCXX/warn-unused-result.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int f() __attribute__((warn_unused_result));
+
+struct S {
+ void t() const;
+};
+S g1() __attribute__((warn_unused_result));
+S *g2() __attribute__((warn_unused_result));
+S &g3() __attribute__((warn_unused_result));
+
+void test() {
+ f(); // expected-warning {{ignoring return value}}
+ g1(); // expected-warning {{ignoring return value}}
+ g2(); // expected-warning {{ignoring return value}}
+ g3(); // expected-warning {{ignoring return value}}
+
+ (void)f();
+ (void)g1();
+ (void)g2();
+ (void)g3();
+
+ if (f() == 0) return;
+
+ g1().t();
+ g2()->t();
+ g3().t();
+
+ int i = f();
+ S s1 = g1();
+ S *s2 = g2();
+ S &s3 = g3();
+ const S &s4 = g1();
+}
+
+struct X {
+ int foo() __attribute__((warn_unused_result));
+};
+
+void bah() {
+ X x, *x2;
+ x.foo(); // expected-warning {{ignoring return value}}
+ x2->foo(); // expected-warning {{ignoring return value}}
+}
diff --git a/clang/test/SemaCXX/warn-unused-value.cpp b/clang/test/SemaCXX/warn-unused-value.cpp
new file mode 100644
index 0000000..1c0263c
--- /dev/null
+++ b/clang/test/SemaCXX/warn-unused-value.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value %s
+
+// PR4806
+namespace test0 {
+ class Box {
+ public:
+ int i;
+ volatile int j;
+ };
+
+ void doit() {
+ // pointer to volatile has side effect (thus no warning)
+ Box* box = new Box;
+ box->i; // expected-warning {{expression result unused}}
+ box->j;
+ }
+}
+
+namespace test1 {
+struct Foo {
+ int i;
+ bool operator==(const Foo& rhs) {
+ return i == rhs.i;
+ }
+};
+
+#define NOP(x) (x)
+void b(Foo f1, Foo f2) {
+ NOP(f1 == f2); // expected-warning {{expression result unused}}
+}
+#undef NOP
+}
+
+namespace test2 {
+ extern "C" {
+ namespace std {
+ template<typename T> struct basic_string {
+ struct X {};
+ void method() const {
+ X* x;
+ &x[0]; // expected-warning {{expression result unused}}
+ }
+ };
+ typedef basic_string<char> string;
+ void func(const std::string& str) {
+ str.method(); // expected-note {{in instantiation of member function}}
+ }
+ }
+ }
+}
+
diff --git a/clang/test/SemaCXX/warn-unused-variables.cpp b/clang/test/SemaCXX/warn-unused-variables.cpp
new file mode 100644
index 0000000..5827019
--- /dev/null
+++ b/clang/test/SemaCXX/warn-unused-variables.cpp
@@ -0,0 +1,124 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -verify %s
+template<typename T> void f() {
+ T t;
+ t = 17;
+}
+
+// PR5407
+struct A { A(); };
+struct B { ~B(); };
+void f() {
+ A a;
+ B b;
+}
+
+// PR5531
+namespace PR5531 {
+ struct A {
+ };
+
+ struct B {
+ B(int);
+ };
+
+ struct C {
+ ~C();
+ };
+
+ void test() {
+ A();
+ B(17);
+ C();
+ }
+}
+
+template<typename T>
+struct X0 { };
+
+template<typename T>
+void test_dependent_init(T *p) {
+ X0<int> i(p);
+ (void)i;
+}
+
+namespace PR6948 {
+ template<typename T> class X;
+
+ void f() {
+ X<char> str (read_from_file()); // expected-error{{use of undeclared identifier 'read_from_file'}}
+ }
+}
+
+void unused_local_static() {
+ static int x = 0;
+ static int y = 0; // expected-warning{{unused variable 'y'}}
+#pragma unused(x)
+}
+
+// PR10168
+namespace PR10168 {
+ // We expect a warning in the definition only for non-dependent variables, and
+ // a warning in the instantiation only for dependent variables.
+ template<typename T>
+ struct S {
+ void f() {
+ int a; // expected-warning {{unused variable 'a'}}
+ T b; // expected-warning 2{{unused variable 'b'}}
+ }
+ };
+
+ template<typename T>
+ void f() {
+ int a; // expected-warning {{unused variable 'a'}}
+ T b; // expected-warning 2{{unused variable 'b'}}
+ }
+
+ void g() {
+ S<int>().f(); // expected-note {{here}}
+ S<char>().f(); // expected-note {{here}}
+ f<int>(); // expected-note {{here}}
+ f<char>(); // expected-note {{here}}
+ }
+}
+
+namespace PR11550 {
+ struct S1 {
+ S1();
+ };
+ S1 makeS1();
+ void testS1(S1 a) {
+ // This constructor call can be elided.
+ S1 x = makeS1(); // expected-warning {{unused variable 'x'}}
+
+ // This one cannot, so no warning.
+ S1 y;
+
+ // This call cannot, but the constructor is trivial.
+ S1 z = a; // expected-warning {{unused variable 'z'}}
+ }
+
+ // The same is true even when we know thet constructor has side effects.
+ void foo();
+ struct S2 {
+ S2() {
+ foo();
+ }
+ };
+ S2 makeS2();
+ void testS2(S2 a) {
+ S2 x = makeS2(); // expected-warning {{unused variable 'x'}}
+ S2 y;
+ S2 z = a; // expected-warning {{unused variable 'z'}}
+ }
+
+ // Or when the constructor is not declared by the user.
+ struct S3 {
+ S1 m;
+ };
+ S3 makeS3();
+ void testS3(S3 a) {
+ S3 x = makeS3(); // expected-warning {{unused variable 'x'}}
+ S3 y;
+ S3 z = a; // expected-warning {{unused variable 'z'}}
+ }
+}
diff --git a/clang/test/SemaCXX/warn-using-namespace-in-header.cpp b/clang/test/SemaCXX/warn-using-namespace-in-header.cpp
new file mode 100644
index 0000000..72c2552
--- /dev/null
+++ b/clang/test/SemaCXX/warn-using-namespace-in-header.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -fsyntax-only -Wheader-hygiene -verify %s
+
+#include "warn-using-namespace-in-header.h"
+
+namespace dont_warn {}
+using namespace dont_warn;
+
+// Warning is actually in the header but only the cpp file gets scanned.
+// expected-warning {{using namespace directive in global context in header}}
+
+
+
+
+
+
+
+
+
+// Warn inside linkage specs too.
+// expected-warning {{using namespace directive in global context in header}}
+
+
+
+
+
+
+// expected-warning {{using namespace directive in global context in header}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+// expected-warning {{using namespace directive in global context in header}}
+
+// |using namespace| through a macro shouldn't warn if the instantiation is in a
+// cc file.
+USING_MACRO
diff --git a/clang/test/SemaCXX/warn-using-namespace-in-header.h b/clang/test/SemaCXX/warn-using-namespace-in-header.h
new file mode 100644
index 0000000..b544c54
--- /dev/null
+++ b/clang/test/SemaCXX/warn-using-namespace-in-header.h
@@ -0,0 +1,50 @@
+
+
+
+
+
+// Lots of vertical space to make the error line match up with the line of the
+// expected line in the source file.
+namespace warn_in_header_in_global_context {}
+using namespace warn_in_header_in_global_context;
+
+// While we want to error on the previous using directive, we don't when we are
+// inside a namespace
+namespace dont_warn_here {
+using namespace warn_in_header_in_global_context;
+}
+
+// We should warn in toplevel extern contexts.
+namespace warn_inside_linkage {}
+extern "C++" {
+using namespace warn_inside_linkage;
+}
+
+// This is really silly, but we should warn on it:
+extern "C++" {
+extern "C" {
+extern "C++" {
+using namespace warn_inside_linkage;
+}
+}
+}
+
+// But we shouldn't warn in extern contexts inside namespaces.
+namespace dont_warn_here {
+extern "C++" {
+using namespace warn_in_header_in_global_context;
+}
+}
+
+// We also shouldn't warn in case of functions.
+inline void foo() {
+ using namespace warn_in_header_in_global_context;
+}
+
+
+namespace macronamespace {}
+#define USING_MACRO using namespace macronamespace;
+
+// |using namespace| through a macro should warn if the instantiation is in a
+// header.
+USING_MACRO
diff --git a/clang/test/SemaCXX/warn-weak-vtables.cpp b/clang/test/SemaCXX/warn-weak-vtables.cpp
new file mode 100644
index 0000000..135e034
--- /dev/null
+++ b/clang/test/SemaCXX/warn-weak-vtables.cpp
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -Wweak-vtables -Wweak-template-vtables
+
+struct A { // expected-warning {{'A' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}}
+ virtual void f() { }
+};
+
+template<typename T> struct B {
+ virtual void f() { }
+};
+
+namespace {
+ struct C {
+ virtual void f() { }
+ };
+}
+
+void f() {
+ struct A {
+ virtual void f() { }
+ };
+
+ A *a;
+ a->f();
+}
+
+// Use the vtables
+void uses(A &a, B<int> &b, C &c) {
+ a.f();
+ b.f();
+ c.f();
+}
+
+// <rdar://problem/9979458>
+class Parent {
+public:
+ Parent() {}
+ virtual ~Parent();
+ virtual void * getFoo() const = 0;
+};
+
+class Derived : public Parent {
+public:
+ Derived();
+ void * getFoo() const;
+};
+
+class VeryDerived : public Derived { // expected-warning{{'VeryDerived' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}}
+public:
+ void * getFoo() const { return 0; }
+};
+
+Parent::~Parent() {}
+
+void uses(Parent &p, Derived &d, VeryDerived &vd) {
+ p.getFoo();
+ d.getFoo();
+ vd.getFoo();
+}
+
+template<typename T> struct TemplVirt {
+ virtual void f();
+};
+
+template class TemplVirt<float>; // expected-warning{{explicit template instantiation 'TemplVirt<float>' will emit a vtable in every translation unit}}
+
+template<> struct TemplVirt<bool> {
+ virtual void f();
+};
+
+template<> struct TemplVirt<long> { // expected-warning{{'TemplVirt<long>' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}}
+ virtual void f() {}
+};
+
+void uses(TemplVirt<float>& f, TemplVirt<bool>& b, TemplVirt<long>& l) {
+ f.f();
+ b.f();
+ l.f();
+}
diff --git a/clang/test/SemaCXX/wchar_t.cpp b/clang/test/SemaCXX/wchar_t.cpp
new file mode 100644
index 0000000..f9d7b61
--- /dev/null
+++ b/clang/test/SemaCXX/wchar_t.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+wchar_t x;
+
+void f(wchar_t p) {
+ wchar_t x;
+ unsigned wchar_t y; // expected-warning {{'wchar_t' cannot be signed or unsigned}}
+ signed wchar_t z; // expected-warning {{'wchar_t' cannot be signed or unsigned}}
+ ++x;
+}
+
+// PR4502
+wchar_t const c = L'c';
+int a[c == L'c' ? 1 : -1];
+
+
+// PR5917
+template<typename _CharT>
+struct basic_string {
+};
+
+template<typename _CharT>
+basic_string<_CharT> operator+ (const basic_string<_CharT>&, _CharT);
+
+int t(void) {
+ basic_string<wchar_t>() + L'-';
+ return (0);
+}
+
+
+// rdar://8040728
+wchar_t in[] = L"\x434" "\x434"; // No warning
+
diff --git a/clang/test/SemaCXX/writable-strings-deprecated.cpp b/clang/test/SemaCXX/writable-strings-deprecated.cpp
new file mode 100644
index 0000000..8295401
--- /dev/null
+++ b/clang/test/SemaCXX/writable-strings-deprecated.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -Wno-deprecated-writable-strings -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fwritable-strings -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-write-strings -verify %s
+// rdar://8827606
+
+char *fun(void)
+{
+ return "foo";
+}
+
+void test(bool b)
+{
+ ++b; // expected-warning {{incrementing expression of type bool is deprecated}}
+}
diff --git a/clang/test/SemaCXX/zero-length-arrays.cpp b/clang/test/SemaCXX/zero-length-arrays.cpp
new file mode 100644
index 0000000..05ded4a
--- /dev/null
+++ b/clang/test/SemaCXX/zero-length-arrays.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/10228639>
+class Foo {
+ ~Foo();
+ Foo(const Foo&);
+public:
+ Foo(int);
+};
+
+class Bar {
+ int foo_count;
+ Foo foos[0];
+ Foo foos2[0][2];
+ Foo foos3[2][0];
+
+public:
+ Bar(): foo_count(0) { }
+ ~Bar() { }
+};
+
+void testBar() {
+ Bar b;
+ Bar b2(b);
+ b = b2;
+}
diff --git a/clang/test/SemaObjC/ClassPropertyNotObject.m b/clang/test/SemaObjC/ClassPropertyNotObject.m
new file mode 100644
index 0000000..02ed40a
--- /dev/null
+++ b/clang/test/SemaObjC/ClassPropertyNotObject.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://10565506
+
+@protocol P @end
+
+@interface I
+@property Class<P> MyClass;
+@property Class MyClass1;
+@property void * VOIDSTAR;
+@end
+
+@implementation I
+@synthesize MyClass, MyClass1, VOIDSTAR;
+@end
diff --git a/clang/test/SemaObjC/ContClassPropertyLookup.m b/clang/test/SemaObjC/ContClassPropertyLookup.m
new file mode 100644
index 0000000..06a0ffa
--- /dev/null
+++ b/clang/test/SemaObjC/ContClassPropertyLookup.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface MyObject {
+ int _foo;
+}
+@end
+
+@interface MyObject(whatever)
+@property (assign) int foo;
+@end
+
+@interface MyObject()
+@property (assign) int foo;
+@end
+
+@implementation MyObject
+@synthesize foo = _foo;
+@end
+
+// rdar://10666594
+@interface MPMediaItem
+@end
+
+@class MPMediaItem;
+
+@interface MPMediaItem ()
+@property (nonatomic, readonly) id title;
+@end
+
+@interface PodcastEpisodesViewController
+@end
+
+@implementation PodcastEpisodesViewController
+- (id) Meth {
+ MPMediaItem *episode;
+ return episode.title;
+}
+@end
diff --git a/clang/test/SemaObjC/DoubleMethod.m b/clang/test/SemaObjC/DoubleMethod.m
new file mode 100644
index 0000000..4eca4c7
--- /dev/null
+++ b/clang/test/SemaObjC/DoubleMethod.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -Wduplicate-method-match -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface Subclass
+{
+ int ivar;
+}
+
+- (void) method; // expected-note {{previous declaration is here}}
+- (void) method; // expected-warning {{multiple declarations of method 'method' found and ignored}}
+@end
+
+@implementation Subclass
+- (void) method {;} // expected-note {{previous declaration is here}}
+- (void) method {;} // expected-error {{duplicate declaration of method 'method'}}
+@end
+
+int main (void) {
+ return 0;
+}
diff --git a/clang/test/SemaObjC/Inputs/arc-system-header.h b/clang/test/SemaObjC/Inputs/arc-system-header.h
new file mode 100644
index 0000000..5012a2a
--- /dev/null
+++ b/clang/test/SemaObjC/Inputs/arc-system-header.h
@@ -0,0 +1,52 @@
+static inline void *test0(id x) {
+ return x;
+}
+
+static inline void **test1(__strong id* x) {
+ return (void**) x;
+}
+
+
+
+
+
+struct Test3 {
+ id *field;
+};
+
+@interface Test4 {
+@public
+ id *field1;
+ __strong id *field2;
+}
+@end
+
+struct Test5 {
+ id field;
+};
+
+
+
+
+
+
+
+extern struct Test6 *const kMagicConstant;
+
+
+
+
+
+@interface Test7
+@property id *prop;
+@end
+
+
+
+
+
+
+
+static inline void *test8(id ptr) {
+ return (__bridge_retain void*) ptr;
+}
diff --git a/clang/test/SemaObjC/NSString-type.m b/clang/test/SemaObjC/NSString-type.m
new file mode 100644
index 0000000..3b4857a
--- /dev/null
+++ b/clang/test/SemaObjC/NSString-type.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -verify %s
+// rdar://10907410
+
+void test(id pid, Class pclass) {
+ void (^block)(void) = @"help"; // expected-error {{initializing 'void (^)(void)' with an expression of incompatible type 'NSString *'}}
+ void (^block1)(void) = pid;
+ void (^block2)(void) = @"help"; // expected-error {{initializing 'void (^)(void)' with an expression of incompatible type 'NSString *'}}
+ void (^block3)(void) = @"help"; // expected-error {{initializing 'void (^)(void)' with an expression of incompatible type 'NSString *'}}
+}
+
diff --git a/clang/test/SemaObjC/access-property-getter.m b/clang/test/SemaObjC/access-property-getter.m
new file mode 100644
index 0000000..afaf82e
--- /dev/null
+++ b/clang/test/SemaObjC/access-property-getter.m
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -verify %s
+
+@protocol NSObject
+- (oneway void)release;
+@end
+
+@protocol XCOutputStreams <NSObject>
+@end
+
+
+@interface XCWorkQueueCommandInvocation
+{
+ id <XCOutputStreams> _outputStream;
+}
+@end
+
+@interface XCWorkQueueCommandSubprocessInvocation : XCWorkQueueCommandInvocation
+@end
+
+@interface XCWorkQueueCommandLocalSubprocessInvocation : XCWorkQueueCommandSubprocessInvocation
+@end
+
+@interface XCWorkQueueCommandDistributedSubprocessInvocation : XCWorkQueueCommandSubprocessInvocation
+@end
+
+@interface XCWorkQueueCommandCacheFetchInvocation : XCWorkQueueCommandSubprocessInvocation
+
+@end
+
+@implementation XCWorkQueueCommandCacheFetchInvocation
+- (id)harvestPredictivelyProcessedOutputFiles
+{
+ _outputStream.release; // expected-warning {{property access result unused - getters should not be used for side effects}}
+ return 0;
+}
+@end
diff --git a/clang/test/SemaObjC/alias-test-1.m b/clang/test/SemaObjC/alias-test-1.m
new file mode 100644
index 0000000..2cea115
--- /dev/null
+++ b/clang/test/SemaObjC/alias-test-1.m
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@compatibility_alias alias4 foo; // expected-warning {{cannot find interface declaration for 'foo'}}
+
+@class class2; // expected-note {{previous declaration is here}}
+@class class3;
+
+typedef int I; // expected-note {{previous declaration is here}}
+
+@compatibility_alias alias1 I; // expected-warning {{cannot find interface declaration for 'I'}}
+
+@compatibility_alias alias class2;
+@compatibility_alias alias class3; // expected-error {{conflicting types for alias 'alias'}}
+
+
+typedef int alias2; // expected-note {{previous declaration is here}}
+@compatibility_alias alias2 class3; // expected-error {{conflicting types for alias 'alias2'}}
+
+alias *p;
+class2 *p2;
+
+int foo ()
+{
+
+ if (p == p2) {
+ int alias = 1;
+ }
+
+ alias *p3;
+ return p3 == p2;
+}
diff --git a/clang/test/SemaObjC/alias-test-2.m b/clang/test/SemaObjC/alias-test-2.m
new file mode 100644
index 0000000..6688db6
--- /dev/null
+++ b/clang/test/SemaObjC/alias-test-2.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+// Note: GCC doesn't produce any of the following errors.
+@interface Super @end // expected-note {{previous definition is here}}
+
+@interface MyWpModule @end // expected-note {{previous definition is here}}
+
+@compatibility_alias MyAlias MyWpModule;
+
+@compatibility_alias AliasForSuper Super;
+
+@implementation MyAlias : AliasForSuper // expected-error {{conflicting super class name 'Super'}}
+@end
+
+@interface MyAlias : AliasForSuper // expected-error {{duplicate interface definition for class 'MyWpModule'}}
+@end
+
diff --git a/clang/test/SemaObjC/arc-bridged-cast.m b/clang/test/SemaObjC/arc-bridged-cast.m
new file mode 100644
index 0000000..56efe81
--- /dev/null
+++ b/clang/test/SemaObjC/arc-bridged-cast.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify %s
+
+typedef const void *CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
+typedef const struct __CFString *CFStringRef;
+
+@interface NSString
+@end
+
+CFTypeRef CFCreateSomething();
+CFStringRef CFCreateString();
+CFTypeRef CFGetSomething();
+CFStringRef CFGetString();
+
+id CreateSomething();
+NSString *CreateNSString();
+
+void from_cf() {
+ id obj1 = (__bridge_transfer id)CFCreateSomething();
+ id obj2 = (__bridge_transfer NSString*)CFCreateString();
+ (__bridge int*)CFCreateSomething(); // expected-error{{incompatible types casting 'CFTypeRef' (aka 'const void *') to 'int *' with a __bridge cast}}
+ id obj3 = (__bridge id)CFGetSomething();
+ id obj4 = (__bridge NSString*)CFGetString();
+}
+
+void to_cf(id obj) {
+ CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething();
+ CFStringRef cf2 = (__bridge_retained CFStringRef)CreateNSString();
+ CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething();
+ CFStringRef cf4 = (__bridge CFStringRef)CreateNSString();
+
+ // rdar://problem/9629566 - temporary workaround
+ CFTypeRef cf5 = (__bridge_retain CFTypeRef)CreateSomething(); // expected-error {{unknown cast annotation __bridge_retain; did you mean __bridge_retained?}}
+}
+
+void fixits() {
+ id obj1 = (id)CFCreateSomething(); // 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}}
+ CFTypeRef cf1 = (CFTypeRef)CreateSomething(); // expected-error{{cast of Objective-C pointer type 'id' to C pointer type 'CFTypeRef' (aka 'const void *') 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 'CFTypeRef' (aka 'const void *')}}
+}
diff --git a/clang/test/SemaObjC/arc-cf.m b/clang/test/SemaObjC/arc-cf.m
new file mode 100644
index 0000000..69662ea
--- /dev/null
+++ b/clang/test/SemaObjC/arc-cf.m
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify %s
+
+#if __has_feature(arc_cf_code_audited)
+char _global[-1]; // expected-error {{declared as an array with a negative size}}
+#endif
+
+typedef const void *CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
+typedef const struct __CFString *CFStringRef;
+
+extern CFStringRef CFMakeString0(void);
+extern CFStringRef CFCreateString0(void);
+void test0() {
+ id x;
+ x = (id) CFMakeString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
+ x = (id) CFCreateString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
+}
+
+extern CFStringRef CFMakeString1(void) __attribute__((cf_returns_not_retained));
+extern CFStringRef CFCreateString1(void) __attribute__((cf_returns_retained));
+void test1() {
+ id x;
+ x = (id) CFMakeString1();
+ x = (id) CFCreateString1(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
+}
+
+#define CF_AUDIT_BEGIN _Pragma("clang arc_cf_code_audited begin")
+#define CF_AUDIT_END _Pragma("clang arc_cf_code_audited end")
+#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
+#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
+
+CF_AUDIT_BEGIN
+extern CFStringRef CFMakeString2(void);
+extern CFStringRef CFCreateString2(void) CF_RETURNS_NOT_RETAINED;
+extern CFStringRef CFMakeString3(void) CF_RETURNS_RETAINED;
+extern CFStringRef CFCreateString3(void);
+CF_AUDIT_END
+void test2() {
+ id x;
+ x = (id) CFMakeString2();
+ x = (id) CFCreateString2();
+ x = (id) CFMakeString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
+ x = (id) CFCreateString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
+}
diff --git a/clang/test/SemaObjC/arc-decls.m b/clang/test/SemaObjC/arc-decls.m
new file mode 100644
index 0000000..8d5cca2
--- /dev/null
+++ b/clang/test/SemaObjC/arc-decls.m
@@ -0,0 +1,99 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -verify -Wno-objc-root-class %s
+
+// rdar://8843524
+
+struct A {
+ id x; // expected-error {{ARC forbids Objective-C objects in structs or unions}}
+};
+
+union u {
+ id u; // expected-error {{ARC forbids Objective-C objects in structs or unions}}
+};
+
+@interface I {
+ struct A a;
+ struct B {
+ id y[10][20]; // expected-error {{ARC forbids Objective-C objects in structs or unions}}
+ id z;
+ } b;
+
+ union u c;
+};
+@end
+
+// rdar://10260525
+struct r10260525 {
+ id (^block) (); // expected-error {{ARC forbids blocks in structs or unions}}
+};
+
+struct S {
+ id __attribute__((objc_ownership(none))) i;
+ void * vp;
+ int i1;
+};
+
+// rdar://9046528
+
+@class NSError;
+
+__autoreleasing id X; // expected-error {{global variables cannot have __autoreleasing ownership}}
+__autoreleasing NSError *E; // expected-error {{global variables cannot have __autoreleasing ownership}}
+
+
+extern id __autoreleasing X1; // expected-error {{global variables cannot have __autoreleasing ownership}}
+
+void func()
+{
+ id X;
+ static id __autoreleasing X1; // expected-error {{global variables cannot have __autoreleasing ownership}}
+ extern id __autoreleasing E; // expected-error {{global variables cannot have __autoreleasing ownership}}
+
+}
+
+// rdar://9157348
+
+@interface J
+@property (retain) id newFoo; // expected-note {{property declared here}}
+@property (strong) id copyBar; // expected-note {{property declared here}}
+@property (copy) id allocBaz; // expected-note {{property declared here}}
+@property (copy, nonatomic) id new;
+@end
+
+@implementation J
+@synthesize newFoo; // expected-error {{property's synthesized getter follows Cocoa naming convention for returning}}
+@synthesize copyBar; // expected-error {{property's synthesized getter follows Cocoa naming convention for returning}}
+@synthesize allocBaz; // expected-error {{property's synthesized getter follows Cocoa naming convention for returning}}
+@synthesize new;
+- new {return 0; };
+@end
+
+
+// rdar://10187884
+@interface Super
+- (void)bar:(id)b; // expected-note {{parameter declared here}}
+- (void)bar1:(id) __attribute((ns_consumed)) b;
+- (void)ok:(id) __attribute((ns_consumed)) b;
+- (id)ns_non; // expected-note {{method declared here}}
+- (id)not_ret:(id) b __attribute((ns_returns_not_retained)); // expected-note {{method declared here}}
+- (id)both__returns_not_retained:(id) b __attribute((ns_returns_not_retained));
+@end
+
+@interface Sub : Super
+- (void)bar:(id) __attribute((ns_consumed)) b; // expected-error {{overriding method has mismatched ns_consumed attribute on its parameter}}
+- (void)bar1:(id)b;
+- (void)ok:(id) __attribute((ns_consumed)) b;
+- (id)ns_non __attribute((ns_returns_not_retained)); // expected-error {{overriding method has mismatched ns_returns_not_retained attributes}}
+- (id)not_ret:(id) b __attribute((ns_returns_retained)); // expected-error {{overriding method has mismatched ns_returns_retained attributes}}
+- (id)both__returns_not_retained:(id) b __attribute((ns_returns_not_retained));
+@end
+
+// Test that we give a good diagnostic here that mentions the missing
+// ownership qualifier. We don't want this to get suppressed because
+// of an invalid conversion.
+void test7(void) {
+ id x;
+ id *px = &x; // expected-error {{pointer to non-const type 'id' with no explicit ownership}}
+
+ I *y;
+ J **py = &y; // expected-error {{pointer to non-const type 'J *' with no explicit ownership}} expected-warning {{incompatible pointer types initializing}}
+}
diff --git a/clang/test/SemaObjC/arc-invalid.m b/clang/test/SemaObjC/arc-invalid.m
new file mode 100644
index 0000000..c736ed4
--- /dev/null
+++ b/clang/test/SemaObjC/arc-invalid.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fblocks -verify %s
+
+// rdar://problem/10982793
+// [p foo] in ARC creates a cleanup.
+// The plus is invalid and causes the cleanup to go unbound.
+// Don't crash.
+@interface A
+- (id) foo;
+@end
+void takeBlock(void (^)(void));
+void test0(id p) {
+ takeBlock(^{ [p foo] + p; }); // expected-error {{invalid operands to binary expression}}
+}
+
+void test1(void) {
+ __autoreleasing id p; // expected-note {{'p' declared here}}
+ takeBlock(^{ (void) p; }); // expected-error {{cannot capture __autoreleasing variable in a block}}
+}
diff --git a/clang/test/SemaObjC/arc-jump-block.m b/clang/test/SemaObjC/arc-jump-block.m
new file mode 100644
index 0000000..26a1fc8
--- /dev/null
+++ b/clang/test/SemaObjC/arc-jump-block.m
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
+// rdar://9535237
+
+typedef struct dispatch_queue_s *dispatch_queue_t;
+
+typedef void (^dispatch_block_t)(void);
+
+void dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
+
+extern __attribute__((visibility("default"))) struct dispatch_queue_s _dispatch_main_q;
+
+@interface SwitchBlockCrashAppDelegate
+- (void)pageLeft;
+- (void)pageRight;;
+@end
+
+@implementation SwitchBlockCrashAppDelegate
+
+- (void)choose:(int)button {
+ switch (button) {
+ case 0:
+ dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; }); // expected-note 3 {{jump enters lifetime of block which strongly captures a variable}}
+ break;
+ case 2: // expected-error {{switch case is in protected scope}}
+ dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; }); // expected-note 2 {{jump enters lifetime of block which strongly captures a variable}}
+ break;
+ case 3: // expected-error {{switch case is in protected scope}}
+ {
+ dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
+ break;
+ }
+ case 4: // expected-error {{switch case is in protected scope}}
+ break;
+ }
+
+ __block SwitchBlockCrashAppDelegate *captured_block_obj;
+ switch (button) {
+ case 10:
+ {
+ dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; });
+ break;
+ }
+ case 12:
+ if (button)
+ dispatch_async((&_dispatch_main_q), ^{ [captured_block_obj pageRight]; });
+ break;
+ case 13:
+ while (button)
+ dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
+ break;
+ case 14:
+ break;
+ }
+
+ switch (button) {
+ case 10:
+ {
+ dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; });
+ break;
+ }
+ case 12:
+ if (button)
+ dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
+ switch (button) {
+ case 0:
+ {
+ dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; });
+ break;
+ }
+ case 4:
+ break;
+ }
+ break;
+ case 13:
+ while (button)
+ dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
+ break;
+ case 14:
+ break;
+ }
+}
+- (void)pageLeft {}
+- (void)pageRight {}
+@end
+
+// Test 2. rdar://problem/11150919
+int test2(id obj, int state) { // expected-note {{jump enters lifetime of block}} FIXME: wierd location
+ switch (state) {
+ case 0:
+ (void) ^{ (void) obj; };
+ return 0;
+
+ default: // expected-error {{switch case is in protected scope}}
+ return 1;
+ }
+}
+
diff --git a/clang/test/SemaObjC/arc-no-runtime.m b/clang/test/SemaObjC/arc-no-runtime.m
new file mode 100644
index 0000000..b75064f
--- /dev/null
+++ b/clang/test/SemaObjC/arc-no-runtime.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fobjc-arc -verify -Wno-objc-root-class %s
+
+// rdar://problem/9150784
+void test(void) {
+ __weak id x; // expected-error {{the current deployment target does not support automated __weak references}}
+ __weak void *v; // expected-warning {{'__weak' only applies to objective-c object or block pointer types}}
+}
+
+@interface A
+@property (weak) id testObjectWeakProperty; // expected-note {{declared here}}
+@end
+
+@implementation A
+// rdar://9605088
+@synthesize testObjectWeakProperty; // expected-error {{the current deployment target does not support automated __weak references}}
+@end
diff --git a/clang/test/SemaObjC/arc-non-pod-memaccess.m b/clang/test/SemaObjC/arc-non-pod-memaccess.m
new file mode 100644
index 0000000..2b1223a
--- /dev/null
+++ b/clang/test/SemaObjC/arc-non-pod-memaccess.m
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks -triple x86_64-apple-darwin10.0.0 %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks -triple x86_64-apple-darwin10.0.0 %s
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void *memset(void *, int, __SIZE_TYPE__);
+void *memmove(void *s1, const void *s2, __SIZE_TYPE__ n);
+void *memcpy(void *s1, const void *s2, __SIZE_TYPE__ n);
+
+#ifdef __cplusplus
+}
+#endif
+
+void test(id __strong *sip, id __weak *wip, id __autoreleasing *aip,
+ id __unsafe_unretained *uip, void *ptr) {
+ // All okay.
+ memset(sip, 0, 17);
+ memset(wip, 0, 17);
+ memset(aip, 0, 17);
+ memset(uip, 0, 17);
+
+ memcpy(sip, ptr, 17); // expected-warning{{destination for this 'memcpy' call is a pointer to ownership-qualified type}} \
+ // expected-note{{explicitly cast the pointer to silence this warning}}
+ memcpy(wip, ptr, 17); // expected-warning{{destination for this 'memcpy' call is a pointer to ownership-qualified type}} \
+ // expected-note{{explicitly cast the pointer to silence this warning}}
+ memcpy(aip, ptr, 17); // expected-warning{{destination for this 'memcpy' call is a pointer to ownership-qualified type}} \
+ // expected-note{{explicitly cast the pointer to silence this warning}}
+ memcpy(uip, ptr, 17);
+
+ memcpy(ptr, sip, 17); // expected-warning{{source of this 'memcpy' call is a pointer to ownership-qualified type}} \
+ // expected-note{{explicitly cast the pointer to silence this warning}}
+ memcpy(ptr, wip, 17); // expected-warning{{source of this 'memcpy' call is a pointer to ownership-qualified type}} \
+ // expected-note{{explicitly cast the pointer to silence this warning}}
+ memcpy(ptr, aip, 17); // expected-warning{{source of this 'memcpy' call is a pointer to ownership-qualified type}} \
+ // expected-note{{explicitly cast the pointer to silence this warning}}
+ memcpy(ptr, uip, 17);
+
+ memmove(sip, ptr, 17); // expected-warning{{destination for this 'memmove' call is a pointer to ownership-qualified type}} \
+ // expected-note{{explicitly cast the pointer to silence this warning}}
+ memmove(wip, ptr, 17); // expected-warning{{destination for this 'memmove' call is a pointer to ownership-qualified type}} \
+ // expected-note{{explicitly cast the pointer to silence this warning}}
+ memmove(aip, ptr, 17); // expected-warning{{destination for this 'memmove' call is a pointer to ownership-qualified type}} \
+ // expected-note{{explicitly cast the pointer to silence this warning}}
+ memmove(uip, ptr, 17);
+
+ memmove(ptr, sip, 17); // expected-warning{{source of this 'memmove' call is a pointer to ownership-qualified type}} \
+ // expected-note{{explicitly cast the pointer to silence this warning}}
+ memmove(ptr, wip, 17); // expected-warning{{source of this 'memmove' call is a pointer to ownership-qualified type}} \
+ // expected-note{{explicitly cast the pointer to silence this warning}}
+ memmove(ptr, aip, 17); // expected-warning{{source of this 'memmove' call is a pointer to ownership-qualified type}} \
+ // expected-note{{explicitly cast the pointer to silence this warning}}
+ memmove(ptr, uip, 17);
+}
+
+void rdar9772982(int i, ...) {
+ __builtin_va_list ap;
+
+ __builtin_va_start(ap, i);
+ __builtin_va_arg(ap, __strong id); // expected-error{{second argument to 'va_arg' is of ARC ownership-qualified type '__strong id'}}
+ __builtin_va_end(ap);
+}
diff --git a/clang/test/SemaObjC/arc-nsconsumed-errors.m b/clang/test/SemaObjC/arc-nsconsumed-errors.m
new file mode 100644
index 0000000..62e74aa
--- /dev/null
+++ b/clang/test/SemaObjC/arc-nsconsumed-errors.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify -fblocks -triple x86_64-apple-darwin10.0.0 %s
+// rdar://10187884
+
+typedef void (^blk)(id arg1, __attribute((ns_consumed)) id arg2);
+typedef void (^blk1)(__attribute((ns_consumed))id arg1, __attribute((ns_consumed)) id arg2);
+blk a = ^void (__attribute((ns_consumed)) id arg1, __attribute((ns_consumed)) id arg2){}; // expected-error {{incompatible block pointer types initializing}}
+
+blk b = ^void (id arg1, __attribute((ns_consumed)) id arg2){};
+
+blk c = ^void (__attribute((ns_consumed)) id arg1, __attribute((ns_consumed)) id arg2){}; // expected-error {{incompatible block pointer types initializing}}
+
+blk d = ^void (id arg1, id arg2) {}; // expected-error {{incompatible block pointer types initializing}}
+
+blk1 a1 = ^void (__attribute((ns_consumed)) id arg1, id arg2){}; // expected-error {{incompatible block pointer types initializing}}
+
+blk1 b2 = ^void (id arg1, __attribute((ns_consumed)) id arg2){}; // expected-error {{incompatible block pointer types initializing}}
+
+blk1 c3 = ^void (__attribute((ns_consumed)) id arg1, __attribute((ns_consumed)) id arg2){};
+
+blk1 d4 = ^void (id arg1, id arg2) {}; // expected-error {{incompatible block pointer types initializing}}
diff --git a/clang/test/SemaObjC/arc-objc-lifetime.m b/clang/test/SemaObjC/arc-objc-lifetime.m
new file mode 100644
index 0000000..03260e8
--- /dev/null
+++ b/clang/test/SemaObjC/arc-objc-lifetime.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
+// rdar://10244607
+
+typedef const struct __CFString * CFStringRef;
+@class NSString;
+
+NSString *CFBridgingRelease();
+
+typedef NSString * PNSString;
+
+typedef __autoreleasing NSString * AUTORELEASEPNSString;
+
+@interface I @end
+
+@implementation I
+- (CFStringRef)myString
+{
+ CFStringRef myString =
+ (__bridge CFStringRef) (__strong NSString *)CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}}
+
+ myString =
+ (__bridge CFStringRef) (__autoreleasing PNSString) CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}}
+ myString =
+ (__bridge CFStringRef) (AUTORELEASEPNSString) CFBridgingRelease(); // OK
+ myString =
+ (__bridge CFStringRef) (typeof(__strong NSString *)) CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}}
+ return myString;
+}
+
+- (void)decodeValueOfObjCType:(const char *)type at:(void *)addr {
+ __autoreleasing id *stuff = (__autoreleasing id *)addr;
+}
+@end
+
+// rdar://problem/10711456
+__strong I *__strong test1; // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}}
+__strong I *(__strong test2); // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}}
+__strong I *(__strong (test3)); // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}}
+__unsafe_unretained __typeof__(test3) test4;
+typedef __strong I *strong_I;
+__unsafe_unretained strong_I test5;
diff --git a/clang/test/SemaObjC/arc-peformselector.m b/clang/test/SemaObjC/arc-peformselector.m
new file mode 100644
index 0000000..dec09e3
--- /dev/null
+++ b/clang/test/SemaObjC/arc-peformselector.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
+// rdar://9659270
+
+@interface NSObject
+- (id)copy; // expected-note {{method 'copy' declared here}}
+- (id) test __attribute__((ns_returns_retained)); // expected-note {{method 'test' declared here}}
++ (id) new ; // expected-note {{method 'new' declared here}}
+- (id) init __attribute__((ns_returns_not_retained));
+- (id)PlusZero;
+- (id)PlusOne __attribute__((ns_returns_retained)); // expected-note {{method 'PlusOne' declared here}}
+@end
+
+@interface I : NSObject
+{
+ SEL sel1;
+}
+- (id)performSelector:(SEL)aSelector;
+- (id)performSelector:(SEL)aSelector withObject:(id)object;
+- (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2;
+@end
+
+@implementation I
+- (id) Meth {
+ return [self performSelector : @selector(copy)]; // expected-error {{performSelector names a selector which retains the object}}
+ return [self performSelector : @selector(test)]; // expected-error {{performSelector names a selector which retains the object}}
+ return [self performSelector : @selector(new)]; // expected-error {{performSelector names a selector which retains the object}}
+ return [self performSelector : @selector(init)];
+ return [self performSelector : sel1]; // expected-warning {{performSelector may cause a leak because its selector is unknown}} \
+ // expected-note {{used here}}
+
+ return [self performSelector : @selector(PlusZero)];
+ return [self performSelector : @selector(PlusOne)]; // expected-error {{performSelector names a selector which retains the object}}
+}
+
+- (id)performSelector:(SEL)aSelector { return 0; }
+- (id)performSelector:(SEL)aSelector withObject:(id)object { return 0; }
+- (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2 { return 0; }
+@end
diff --git a/clang/test/SemaObjC/arc-property-decl-attrs.m b/clang/test/SemaObjC/arc-property-decl-attrs.m
new file mode 100644
index 0000000..1386241
--- /dev/null
+++ b/clang/test/SemaObjC/arc-property-decl-attrs.m
@@ -0,0 +1,81 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify %s
+// rdar://9340606
+
+@interface Foo {
+@public
+ id __unsafe_unretained x;
+ id __weak y;
+ id __autoreleasing z; // expected-error {{ivars cannot have __autoreleasing ownership}}
+}
+@property(strong) id x;
+@property(strong) id y;
+@property(strong) id z;
+@end
+
+@interface Bar {
+@public
+ id __unsafe_unretained x;
+ id __weak y;
+ id __autoreleasing z; // expected-error {{ivars cannot have __autoreleasing ownership}}
+}
+@property(retain) id x;
+@property(retain) id y;
+@property(retain) id z;
+@end
+
+@interface Bas {
+@public
+ id __unsafe_unretained x;
+ id __weak y;
+ id __autoreleasing z; // expected-error {{ivars cannot have __autoreleasing ownership}}
+}
+@property(copy) id x;
+@property(copy) id y;
+@property(copy) id z;
+@end
+
+// Errors should start about here :-)
+
+@interface Bat
+@property(strong) __unsafe_unretained id x; // expected-error {{strong property 'x' may not also be declared __unsafe_unretained}}
+@property(strong) __weak id y; // expected-error {{strong property 'y' may not also be declared __weak}} expected-error {{property attributes 'strong' and 'weak' are mutually exclusive}}
+@property(strong) __autoreleasing id z; // expected-error {{strong property 'z' may not also be declared __autoreleasing}}
+@end
+
+@interface Bau
+@property(retain) __unsafe_unretained id x; // expected-error {{strong property 'x' may not also be declared __unsafe_unretained}}
+@property(retain) __weak id y; // expected-error {{strong property 'y' may not also be declared __weak}} expected-error {{property attributes 'retain' and 'weak' are mutually exclusive}}
+@property(retain) __autoreleasing id z; // expected-error {{strong property 'z' may not also be declared __autoreleasing}}
+@end
+
+@interface Bav
+@property(copy) __unsafe_unretained id x; // expected-error {{strong property 'x' may not also be declared __unsafe_unretained}}
+@property(copy) __weak id y; // expected-error {{strong property 'y' may not also be declared __weak}} expected-error {{property attributes 'copy' and 'weak' are mutually exclusive}}
+@property(copy) __autoreleasing id z; // expected-error {{strong property 'z' may not also be declared __autoreleasing}}
+@end
+
+@interface Bingo
+@property(assign) __unsafe_unretained id x;
+@property(assign) __weak id y; // expected-error {{property attributes 'assign' and 'weak' are mutually exclusive}}
+@property(assign) __autoreleasing id z; // expected-error {{unsafe_unretained property 'z' may not also be declared __autoreleasing}}
+@end
+
+@interface Batman
+@property(unsafe_unretained) __unsafe_unretained id x;
+@property(unsafe_unretained) __weak id y; // expected-error {{property attributes 'unsafe_unretained' and 'weak' are mutually exclusive}}
+@property(unsafe_unretained) __autoreleasing id z; // expected-error {{unsafe_unretained property 'z' may not also be declared __autoreleasing}}
+@end
+
+// rdar://9396329
+@interface Super
+@property (readonly, retain) id foo;
+@property (readonly, weak) id fee;
+@property (readonly, strong) id frr;
+@end
+
+@interface Bugg : Super
+@property (readwrite) id foo;
+@property (readwrite) id fee;
+@property (readwrite) id frr;
+@end
+
diff --git a/clang/test/SemaObjC/arc-property-lifetime.m b/clang/test/SemaObjC/arc-property-lifetime.m
new file mode 100644
index 0000000..fad37cc
--- /dev/null
+++ b/clang/test/SemaObjC/arc-property-lifetime.m
@@ -0,0 +1,170 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
+// rdar://9340606
+
+@interface Foo {
+@public
+ id __unsafe_unretained x;
+ id __weak y;
+ id __autoreleasing z; // expected-error {{ivars cannot have __autoreleasing ownership}}
+}
+@property(strong) id x; // expected-note {{property declared here}}
+@property(strong) id y; // expected-note {{property declared here}}
+@property(strong) id z;
+@end
+
+@implementation Foo
+@synthesize x; // expected-error {{existing ivar 'x' for strong property 'x' may not be __unsafe_unretained}}
+@synthesize y; // expected-error {{existing ivar 'y' for strong property 'y' may not be __weak}}
+@synthesize z; // suppressed
+@end
+
+@interface Bar {
+@public
+ id __unsafe_unretained x;
+ id __weak y;
+ id __autoreleasing z; // expected-error {{ivars cannot have __autoreleasing ownership}}
+}
+@property(retain) id x; // expected-note {{property declared here}}
+@property(retain) id y; // expected-note {{property declared here}}
+@property(retain) id z;
+@end
+
+@implementation Bar
+@synthesize x; // expected-error {{existing ivar 'x' for strong property 'x' may not be __unsafe_unretained}}
+@synthesize y; // expected-error {{existing ivar 'y' for strong property 'y' may not be __weak}}
+@synthesize z; // suppressed
+@end
+
+@interface Bas {
+@public
+ id __unsafe_unretained x;
+ id __weak y;
+ id __autoreleasing z; // expected-error {{ivars cannot have __autoreleasing ownership}}
+}
+@property(copy) id x; // expected-note {{property declared here}}
+@property(copy) id y; // expected-note {{property declared here}}
+@property(copy) id z;
+@end
+
+@implementation Bas
+@synthesize x; // expected-error {{existing ivar 'x' for strong property 'x' may not be __unsafe_unretained}}
+@synthesize y; // expected-error {{existing ivar 'y' for strong property 'y' may not be __weak}}
+@synthesize z; // suppressed
+@end
+
+@interface Bat
+@property(strong) __unsafe_unretained id x; // expected-error {{strong property 'x' may not also be declared __unsafe_unretained}}
+@property(strong) __autoreleasing id z; // expected-error {{strong property 'z' may not also be declared __autoreleasing}}
+@end
+
+@interface Bau
+@property(retain) __unsafe_unretained id x; // expected-error {{strong property 'x' may not also be declared __unsafe_unretained}}
+@property(retain) __autoreleasing id z; // expected-error {{strong property 'z' may not also be declared __autoreleasing}}
+@end
+
+@interface Bav
+@property(copy) __unsafe_unretained id x; // expected-error {{strong property 'x' may not also be declared __unsafe_unretained}}
+@property(copy) __autoreleasing id z; // expected-error {{strong property 'z' may not also be declared __autoreleasing}}
+@end
+
+// rdar://9341593
+@interface Gorf {
+ id __unsafe_unretained x;
+ id y;
+}
+@property(assign) id __unsafe_unretained x;
+@property(assign) id y; // expected-note {{property declared here}}
+@property(assign) id z;
+@end
+
+@implementation Gorf
+@synthesize x;
+@synthesize y; // expected-error {{existing ivar 'y' for property 'y' with assign attribute must be __unsafe_unretained}}
+@synthesize z;
+@end
+
+@interface Gorf2 {
+ id __unsafe_unretained x;
+ id y;
+}
+@property(unsafe_unretained) id __unsafe_unretained x;
+@property(unsafe_unretained) id y; // expected-note {{property declared here}}
+@property(unsafe_unretained) id z;
+@end
+
+@implementation Gorf2
+@synthesize x;
+@synthesize y; // expected-error {{existing ivar 'y' for property 'y' with unsafe_unretained attribute must be __unsafe_unretained}}
+@synthesize z;
+@end
+
+// rdar://9355230
+@interface I {
+ char _isAutosaving;
+}
+@property char isAutosaving;
+
+@end
+
+@implementation I
+@synthesize isAutosaving = _isAutosaving;
+@end
+
+// rdar://10239594
+// Test for 'Class' properties being unretained.
+@interface MyClass {
+@private
+ Class _controllerClass;
+ id _controllerId;
+}
+@property (copy) Class controllerClass;
+@property (copy) id controllerId;
+@end
+
+@implementation MyClass
+@synthesize controllerClass = _controllerClass;
+@synthesize controllerId = _controllerId;
+@end
+
+// rdar://10630891
+@interface UIView @end
+@class UIColor;
+
+@interface UIView(UIViewRendering)
+@property(nonatomic,copy) UIColor *backgroundColor;
+@end
+
+@interface UILabel : UIView
+@end
+
+@interface MyView
+@property (strong) UILabel *label;
+@end
+
+@interface MyView2 : MyView @end
+
+@implementation MyView2
+- (void)foo {
+ super.label.backgroundColor = 0;
+}
+@end
+
+// rdar://10694932
+@interface Baz
+@property id prop;
+@property __strong id strong_prop;
+@property (strong) id strong_attr_prop;
+@property (strong) __strong id realy_strong_attr_prop;
++ (id) alloc;
+- (id) init;
+- (id) implicit;
+- (void) setImplicit : (id) arg;
+@end
+
+void foo(Baz *f) {
+ f.prop = [[Baz alloc] init];
+ f.strong_prop = [[Baz alloc] init];
+ f.strong_attr_prop = [[Baz alloc] init];
+ f.realy_strong_attr_prop = [[Baz alloc] init];
+ f.implicit = [[Baz alloc] init];
+}
diff --git a/clang/test/SemaObjC/arc-property.m b/clang/test/SemaObjC/arc-property.m
new file mode 100644
index 0000000..2599fb9
--- /dev/null
+++ b/clang/test/SemaObjC/arc-property.m
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
+// rdar://9309489
+
+@interface MyClass {
+ id __weak myString;
+ id StrongIvar;
+ id __weak myString2;
+ id __weak myString3;
+ id StrongIvar5;
+}
+@property (strong) id myString; // expected-note {{property declared here}}
+@property (strong) id myString1;
+@property (retain) id myString2; // expected-note {{property declared here}}
+//
+@property (weak) id myString3;
+@property (weak) id myString4;
+@property __weak id myString5; // expected-note {{property declared here}}
+@end
+
+@implementation MyClass
+@synthesize myString; // expected-error {{existing ivar 'myString' for strong property 'myString' may not be __weak}}
+@synthesize myString1 = StrongIvar; // OK
+@synthesize myString2 = myString2; // expected-error {{existing ivar 'myString2' for strong property 'myString2' may not be __weak}}
+//
+@synthesize myString3; // OK
+@synthesize myString4; // OK
+@synthesize myString5 = StrongIvar5; // expected-error {{existing ivar 'StrongIvar5' for __weak property 'myString5' must be __weak}}
+
+@end
+
+// rdar://9340692
+@interface Foo {
+@public
+ id __unsafe_unretained x; // should be __weak
+ id __strong y;
+ id __autoreleasing z; // expected-error {{ivars cannot have __autoreleasing ownership}}
+}
+@property(weak) id x; // expected-note {{property declared here}}
+@property(weak) id y; // expected-note {{property declared here}}
+@property(weak) id z;
+@end
+
+@implementation Foo
+@synthesize x; // expected-error {{existing ivar 'x' for __weak property 'x' must be __weak}}
+@synthesize y; // expected-error {{existing ivar 'y' for __weak property 'y' must be __weak}}
+@synthesize z; // suppressed
+@end
+
+// rdar://problem/10904479
+// Don't crash.
+@interface Test2
+// Minor FIXME: kill the redundant error
+@property (strong) UndeclaredClass *test2; // expected-error {{unknown type name 'UndeclaredClass'}} expected-error {{must be of object type}}
+@end
+@implementation Test2
+@synthesize test2;
+@end
diff --git a/clang/test/SemaObjC/arc-readonly-property-ivar-1.m b/clang/test/SemaObjC/arc-readonly-property-ivar-1.m
new file mode 100644
index 0000000..c773f26
--- /dev/null
+++ b/clang/test/SemaObjC/arc-readonly-property-ivar-1.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fobjc-default-synthesize-properties -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fobjc-default-synthesize-properties -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar:// 10558871
+
+@interface PP
+@property (readonly) id ReadOnlyPropertyNoBackingIvar;
+@property (readonly) id ReadOnlyProperty;
+@property (readonly) id ReadOnlyPropertyX;
+@end
+
+@implementation PP {
+__weak id _ReadOnlyProperty;
+}
+@synthesize ReadOnlyPropertyNoBackingIvar;
+@synthesize ReadOnlyProperty = _ReadOnlyProperty;
+@synthesize ReadOnlyPropertyX = _ReadOnlyPropertyX;
+@end
+
+@interface DD
+@property (readonly) id ReadOnlyProperty;
+@property (readonly) id ReadOnlyPropertyStrong;
+@property (readonly) id ReadOnlyPropertyNoBackingIvar;
+@end
+
+@implementation DD {
+__weak id _ReadOnlyProperty;
+__strong id _ReadOnlyPropertyStrong;
+}
+@end
diff --git a/clang/test/SemaObjC/arc-readonly-property-ivar.m b/clang/test/SemaObjC/arc-readonly-property-ivar.m
new file mode 100644
index 0000000..635b9fe
--- /dev/null
+++ b/clang/test/SemaObjC/arc-readonly-property-ivar.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar:// 10558871
+
+@interface PP
+@property (readonly) id ReadOnlyPropertyNoBackingIvar;
+@property (readonly) id ReadOnlyProperty;
+@property (readonly) id ReadOnlyPropertyX;
+@end
+
+@implementation PP {
+__weak id _ReadOnlyProperty;
+}
+@synthesize ReadOnlyPropertyNoBackingIvar;
+@synthesize ReadOnlyProperty = _ReadOnlyProperty;
+@synthesize ReadOnlyPropertyX = _ReadOnlyPropertyX;
+@end
diff --git a/clang/test/SemaObjC/arc-retain-block-property.m b/clang/test/SemaObjC/arc-retain-block-property.m
new file mode 100644
index 0000000..3b66d14
--- /dev/null
+++ b/clang/test/SemaObjC/arc-retain-block-property.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -verify -Wno-objc-root-class %s
+// rdar://9829425
+
+extern void doSomething();
+
+@interface Test
+{
+@public
+ void (^aBlock)(void);
+}
+@property (retain) void (^aBlock)(void); // expected-warning {{retain'ed block property does not copy the block - use copy attribute instead}}
+@property (weak, retain) void (^aBlockW)(void); // expected-error {{property attributes 'retain' and 'weak' are mutually exclusive}}
+@property (strong, retain) void (^aBlockS)(void); // OK
+@property (readonly, retain) void (^aBlockR)(void); // OK
+@property (copy, retain) void (^aBlockC)(void); // expected-error {{property attributes 'copy' and 'retain' are mutually exclusive}}
+@property (assign, retain) void (^aBlockA)(void); // expected-error {{property attributes 'assign' and 'retain' are mutually exclusive}}
+@end
+
+@implementation Test
+@synthesize aBlock;
+@dynamic aBlockW, aBlockS, aBlockR, aBlockC, aBlockA;
+@end
+
+int main() {
+ Test *t;
+ t.aBlock = ^{ doSomething(); };
+ t.aBlockW = ^{ doSomething(); };
+ t.aBlockS = ^{ doSomething(); };
+}
+
diff --git a/clang/test/SemaObjC/arc-setter-property-match.m b/clang/test/SemaObjC/arc-setter-property-match.m
new file mode 100644
index 0000000..9158b09
--- /dev/null
+++ b/clang/test/SemaObjC/arc-setter-property-match.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
+// rdar://10156674
+
+@class NSArray;
+
+@interface MyClass2 {
+@private
+ NSArray *_names1;
+ NSArray *_names2;
+ NSArray *_names3;
+ NSArray *_names4;
+}
+@property (readwrite, strong) NSArray *names1; // <-- warning: Type of property....
+- (void)setNames1:(NSArray *)names;
+@property (readwrite, strong) __strong NSArray *names2; // <-- warning: Type of property....
+- (void)setNames2:(NSArray *)names;
+@property (readwrite, strong) __strong NSArray *names3; // <-- OK
+- (void)setNames3:(__strong NSArray *)names;
+@property (readwrite, strong) NSArray *names4; // <-- warning: Type of property....
+- (void)setNames4:(__strong NSArray *)names;
+
+@end
+
+@implementation MyClass2
+- (NSArray *)names1 { return _names1; }
+- (void)setNames1:(NSArray *)names {}
+- (NSArray *)names2 { return _names2; }
+- (void)setNames2:(NSArray *)names {}
+- (NSArray *)names3 { return _names3; }
+- (void)setNames3:(__strong NSArray *)names {}
+- (NSArray *)names4 { return _names4; }
+- (void)setNames4:(__strong NSArray *)names {}
+
+@end
+
diff --git a/clang/test/SemaObjC/arc-system-header.m b/clang/test/SemaObjC/arc-system-header.m
new file mode 100644
index 0000000..1a7c39d
--- /dev/null
+++ b/clang/test/SemaObjC/arc-system-header.m
@@ -0,0 +1,50 @@
+// silly workaround expected-note {{marked unavailable here}}
+// RUN: %clang_cc1 -fobjc-arc -isystem %S/Inputs %s -DNO_USE
+// RUN: %clang_cc1 -fobjc-arc -isystem %S/Inputs %s -verify
+
+// another silly workaround expected-note {{marked unavailable here}}
+#include <arc-system-header.h>
+
+#ifndef NO_USE
+void test(id op, void *cp) {
+ cp = test0(op); // expected-error {{'test0' is unavailable: converts between Objective-C and C pointers in -fobjc-arc}}
+ cp = *test1(&op); // expected-error {{'test1' is unavailable: converts between Objective-C and C pointers in -fobjc-arc}}
+}
+
+// workaround expected-note {{marked unavailable here}}
+void test3(struct Test3 *p) {
+ p->field = 0; // expected-error {{'field' is unavailable: this system declaration uses an unsupported type}}
+}
+
+// workaround expected-note {{marked unavailable here}}
+void test4(Test4 *p) {
+ p->field1 = 0; // expected-error {{'field1' is unavailable: this system declaration uses an unsupported type}}
+ p->field2 = 0;
+}
+
+// workaround expected-note {{marked unavailable here}}
+void test5(struct Test5 *p) {
+ p->field = 0; // expected-error {{'field' is unavailable: this system field has retaining ownership}}
+}
+
+id test6() {
+ // This is actually okay to use if declared in a system header.
+ id x;
+ x = (id) kMagicConstant;
+ x = (id) (x ? kMagicConstant : kMagicConstant);
+ x = (id) (x ? kMagicConstant : (void*) 0);
+
+ extern void test6_helper();
+ x = (id) (test6_helper(), kMagicConstant);
+}
+
+// workaround expected-note 4 {{marked unavailable here}}
+void test7(Test7 *p) {
+ *p.prop = 0; // expected-error {{'prop' is unavailable: this system declaration uses an unsupported type}}
+ p.prop = 0; // expected-error {{'prop' is unavailable: this system declaration uses an unsupported type}}
+ *[p prop] = 0; // expected-error {{'prop' is unavailable: this system declaration uses an unsupported type}}
+ [p setProp: 0]; // expected-error {{'setProp:' is unavailable: this system declaration uses an unsupported type}}
+}
+#endif
+
+// test8 in header
diff --git a/clang/test/SemaObjC/arc-type-conversion.m b/clang/test/SemaObjC/arc-type-conversion.m
new file mode 100644
index 0000000..5cf2cf4
--- /dev/null
+++ b/clang/test/SemaObjC/arc-type-conversion.m
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks %s
+
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
+
+void * cvt(id arg)
+{
+ void* voidp_val;
+ (void)(int*)arg; // expected-error {{cast of an Objective-C pointer to 'int *' is disallowed with ARC}}
+ (void)(id)arg;
+ (void)(__autoreleasing id*)arg; // expected-error {{cast of an Objective-C pointer to '__autoreleasing id *' is disallowed with ARC}}
+ (void)(id*)arg; // expected-error {{cast of an Objective-C pointer to '__strong id *' is disallowed with ARC}}
+
+ (void)(__autoreleasing id**)voidp_val;
+ (void)(void*)voidp_val;
+ (void)(void**)arg; // expected-error {{cast of an Objective-C pointer to 'void **' is disallowed with ARC}}
+ cvt((void*)arg); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} \
+ // expected-error {{implicit conversion of C pointer type 'void *' to Objective-C pointer type 'id' requires a bridged cast}} \
+ // expected-note 2 {{use __bridge to convert directly (no change in ownership)}} \
+ // expected-note {{use CFBridgingRetain call to make an ARC object available as a +1 'void *'}} \
+ // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'void *' into ARC}}
+ cvt(0);
+ (void)(__strong id**)(0);
+ return arg; // expected-error {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' 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 'void *'}}
+}
+
+void to_void(__strong id *sip, __weak id *wip,
+ __autoreleasing id *aip,
+ __unsafe_unretained id *uip) {
+ void *vp1 = sip;
+ void *vp2 = wip;
+ void *vp3 = aip;
+ void *vp4 = uip;
+ (void)(void*)sip;
+ (void)(void*)wip;
+ (void)(void*)aip;
+ (void)(void*)uip;
+ (void)(void*)&sip;
+ (void)(void*)&wip;
+ (void)(void*)&aip;
+ (void)(void*)&uip;
+}
+
+void from_void(void *vp) {
+ __strong id *sip = (__strong id *)vp;
+ __weak id *wip = (__weak id *)vp;
+ __autoreleasing id *aip = (__autoreleasing id *)vp;
+ __unsafe_unretained id *uip = (__unsafe_unretained id *)vp;
+
+ __strong id **sipp = (__strong id **)vp;
+ __weak id **wipp = (__weak id **)vp;
+ __autoreleasing id **aipp = (__autoreleasing id **)vp;
+ __unsafe_unretained id **uipp = (__unsafe_unretained id **)vp;
+
+ sip = vp; // expected-error{{implicit conversion of a non-Objective-C pointer type 'void *' to '__strong id *' is disallowed with ARC}}
+ wip = vp; // expected-error{{implicit conversion of a non-Objective-C pointer type 'void *' to '__weak id *' is disallowed with ARC}}
+ aip = vp; // expected-error{{implicit conversion of a non-Objective-C pointer type 'void *' to '__autoreleasing id *' is disallowed with ARC}}
+ uip = vp; // expected-error{{implicit conversion of a non-Objective-C pointer type 'void *' to '__unsafe_unretained id *' is disallowed with ARC}}
+}
+
+typedef void (^Block)();
+typedef void (^Block_strong)() __strong;
+typedef void (^Block_autoreleasing)() __autoreleasing;
+
+@class NSString;
+
+void ownership_transfer_in_cast(void *vp, Block *pblk) {
+ __strong NSString **sip = (NSString**)(__strong id *)vp;
+ __weak NSString **wip = (NSString**)(__weak id *)vp;
+ __autoreleasing id *aip = (id*)(__autoreleasing id *)vp;
+ __unsafe_unretained id *uip = (id*)(__unsafe_unretained id *)vp;
+
+ __strong id **sipp = (id**)(__strong id **)vp;
+ __weak id **wipp = (id**)(__weak id **)vp;
+ __autoreleasing id **aipp = (id**)(__autoreleasing id **)vp;
+ __unsafe_unretained id **uipp = (id**)(__unsafe_unretained id **)vp;
+
+ Block_strong blk_strong1;
+ Block_strong blk_strong2 = (Block)blk_strong1;
+ Block_autoreleasing *blk_auto = (Block*)pblk;
+
+ id lv;
+ (void)(id)&lv; // expected-error {{cast of an indirect pointer to an Objective-C pointer to 'id'}}
+ (void)(id*)lv; // expected-error {{cast of an Objective-C pointer to '__strong id *'}}
+ (void)(NSString*)&lv; // expected-error {{cast of an indirect pointer to an Objective-C pointer to 'NSString *'}}
+ (void)(NSString**)lv; // expected-error {{cast of an Objective-C pointer to 'NSString *__strong *'}}
+ (void)(Block)&lv; // expected-error {{cast of an indirect pointer to an Objective-C pointer to 'Block'}}
+ (void)(Block*)lv; // expected-error {{cast of an Objective-C pointer to '__strong Block *'}}
+}
+
+// <rdar://problem/10486347>
+void conversion_in_conditional(id a, void* b) {
+ id c = 1 ? a : b; // expected-error {{operands to conditional of types 'id' and 'void *' are incompatible in ARC mode}}
+ id d = 1 ? b : a; // expected-error {{operands to conditional of types 'void *' and 'id' are incompatible in ARC mode}}
+}
diff --git a/clang/test/SemaObjC/arc-unavailable-for-weakref.m b/clang/test/SemaObjC/arc-unavailable-for-weakref.m
new file mode 100644
index 0000000..8498de6
--- /dev/null
+++ b/clang/test/SemaObjC/arc-unavailable-for-weakref.m
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
+// rdar://9693477
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface NSOptOut1072 // expected-note {{class is declared here}}
+@end
+
+@interface sub : NSOptOut1072 @end // expected-note 2 {{class is declared here}}
+
+int main() {
+ __weak sub *w2; // expected-error {{class is incompatible with __weak references}}
+
+ __weak NSOptOut1072 *ns1; // expected-error {{class is incompatible with __weak references}}
+
+ id obj;
+
+ ns1 = (__weak sub *)obj; // expected-error {{assignment of a weak-unavailable object to a __weak object}} \
+ // expected-error {{class is incompatible with __weak references}} \
+ // expected-error {{explicit ownership qualifier on cast result has no effect}}
+}
+
+// rdar://9732636
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface NOWEAK
++ (id) new;
+@end
+
+NOWEAK * Test1() {
+ NOWEAK * strong1 = [NOWEAK new];
+ __weak id weak1;
+ weak1 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
+
+ __weak id weak2 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
+ return (__weak id)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK *' to a __weak object of type '__weak id'}} \
+ // expected-error {{explicit ownership qualifier on cast result has no effect}}
+}
+
+@protocol P @end
+@protocol P1 @end
+
+NOWEAK<P, P1> * Test2() {
+ NOWEAK<P, P1> * strong1 = 0;
+ __weak id<P> weak1;
+ weak1 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
+
+ __weak id<P> weak2 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
+ return (__weak id<P>)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK<P,P1> *' to a __weak object of type '__weak id<P>'}} \
+ // expected-error {{explicit ownership qualifier on cast result has no effect}}
+}
+
+// rdar://10535245
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface NSFont
+@end
+
+@interface I
+{
+}
+@property (weak) NSFont *font; // expected-note {{property declared here}}
+@end
+
+@implementation I
+@synthesize font = _font; // expected-error {{synthesis of a weak-unavailable property is disallowed because it requires synthesis of an ivar of the __weak object}}
+@end
diff --git a/clang/test/SemaObjC/arc-unavailable-system-function.m b/clang/test/SemaObjC/arc-unavailable-system-function.m
new file mode 100644
index 0000000..b0b70db
--- /dev/null
+++ b/clang/test/SemaObjC/arc-unavailable-system-function.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin11 -fobjc-arc -verify %s
+// rdar://10186625
+
+# 1 "<command line>"
+# 1 "/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h" 1 3
+id * foo(); // expected-note {{function has been explicitly marked unavailable here}}
+
+# 1 "arc-unavailable-system-function.m" 2
+void ret() {
+ foo(); // expected-error {{'foo' is unavailable: this system declaration uses an unsupported type}}
+}
+
+
diff --git a/clang/test/SemaObjC/arc-unbridged-cast.m b/clang/test/SemaObjC/arc-unbridged-cast.m
new file mode 100644
index 0000000..7d5a6b0
--- /dev/null
+++ b/clang/test/SemaObjC/arc-unbridged-cast.m
@@ -0,0 +1,123 @@
+// // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
+
+typedef const struct __CFString * CFStringRef;
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
+
+
+@interface Object
+@property CFStringRef property;
+- (CFStringRef) implicitProperty;
+- (CFStringRef) newString;
+- (CFStringRef) makeString;
+@end
+
+extern Object *object;
+
+// rdar://9744349
+id test0(void) {
+ id p1 = (id)[object property];
+ id p2 = (__bridge_transfer id)[object property];
+ id p3 = (__bridge id)[object property];
+ return (id) object.property;
+}
+
+// rdar://10140692
+CFStringRef unauditedString(void);
+CFStringRef plusOneString(void) __attribute__((cf_returns_retained));
+
+#pragma clang arc_cf_code_audited begin
+CFStringRef auditedString(void);
+CFStringRef auditedCreateString(void);
+#pragma clang arc_cf_code_audited end
+
+void test1(int cond) {
+ id x;
+ x = (id) auditedString();
+ x = (id) (cond ? auditedString() : (void*) 0);
+ x = (id) (cond ? (void*) 0 : auditedString());
+ x = (id) (cond ? (CFStringRef) @"help" : auditedString());
+
+ x = (id) unauditedString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? unauditedString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+
+ x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+
+ x = (id) [object property];
+ x = (id) (cond ? [object property] : (void*) 0);
+ x = (id) (cond ? (void*) 0 : [object property]);
+ x = (id) (cond ? (CFStringRef) @"help" : [object property]);
+
+ x = (id) object.property;
+ x = (id) (cond ? object.property : (void*) 0);
+ x = (id) (cond ? (void*) 0 : object.property);
+ x = (id) (cond ? (CFStringRef) @"help" : object.property);
+
+ x = (id) object.implicitProperty;
+ x = (id) (cond ? object.implicitProperty : (void*) 0);
+ x = (id) (cond ? (void*) 0 : object.implicitProperty);
+ x = (id) (cond ? (CFStringRef) @"help" : object.implicitProperty);
+
+ x = (id) [object makeString];
+ x = (id) (cond ? [object makeString] : (void*) 0);
+ x = (id) (cond ? (void*) 0 : [object makeString]);
+ x = (id) (cond ? (CFStringRef) @"help" : [object makeString]);
+
+ x = (id) [object newString];
+ x = (id) (cond ? [object newString] : (void*) 0);
+ x = (id) (cond ? (void*) 0 : [object newString]);
+ x = (id) (cond ? (CFStringRef) @"help" : [object newString]); // a bit questionable
+}
+
+// rdar://problem/10246264
+@interface CFTaker
+- (void) takeOrdinary: (CFStringRef) arg;
+- (void) takeVariadic: (int) n, ...;
+- (void) takeConsumed: (CFStringRef __attribute__((cf_consumed))) arg;
+@end
+void testCFTaker(CFTaker *taker, id string) {
+ [taker takeOrdinary: (CFStringRef) string];
+ [taker takeVariadic: 1, (CFStringRef) string];
+ [taker takeConsumed: (CFStringRef) string]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+}
+
+void takeCFOrdinaryUnaudited(CFStringRef arg);
+void takeCFVariadicUnaudited(int n, ...);
+void takeCFConsumedUnaudited(CFStringRef __attribute__((cf_consumed)) arg);
+#pragma clang arc_cf_code_audited begin
+void takeCFOrdinaryAudited(CFStringRef arg);
+void takeCFVariadicAudited(int n, ...);
+void takeCFConsumedAudited(CFStringRef __attribute__((cf_consumed)) arg);
+#pragma clang arc_cf_code_audited end
+
+void testTakerFunctions(id string) {
+ takeCFOrdinaryUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFVariadicUnaudited(1, (CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFConsumedUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+
+ void (*taker)(CFStringRef) = 0;
+ taker((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+
+ takeCFOrdinaryAudited((CFStringRef) string);
+ takeCFVariadicAudited(1, (CFStringRef) string);
+ takeCFConsumedAudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+}
+
+void testTakerFunctions_parens(id string) {
+ takeCFOrdinaryUnaudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFVariadicUnaudited(1, ((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFConsumedUnaudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+
+ void (*taker)(CFStringRef) = 0;
+ taker(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+
+ takeCFOrdinaryAudited(((CFStringRef) string));
+ takeCFVariadicAudited(1, ((CFStringRef) string));
+ takeCFConsumedAudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+}
diff --git a/clang/test/SemaObjC/arc-unsafe-assigns.m b/clang/test/SemaObjC/arc-unsafe-assigns.m
new file mode 100644
index 0000000..1805b85
--- /dev/null
+++ b/clang/test/SemaObjC/arc-unsafe-assigns.m
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
+// rdar://9495837
+
+@interface Foo {
+ __unsafe_unretained id unsafe_ivar;
+}
+
+@property (assign,nonatomic) id unsafe_prop;
+
+- (id)init;
++ (id)new;
++ (id)alloc;
+
+-(void)Meth;
+@end
+
+@implementation Foo
+@synthesize unsafe_prop;
+-(id)init { return self; }
++(id)new { return 0; }
++(id)alloc { return 0; }
+
+-(void)Meth {
+ self.unsafe_prop = [Foo new]; // expected-warning {{assigning retained object to unsafe property}}
+ self->unsafe_ivar = [Foo new]; // expected-warning {{assigning retained object to unsafe_unretained}}
+ self.unsafe_prop = [[Foo alloc] init]; // expected-warning {{assigning retained object to unsafe property}}
+ self->unsafe_ivar = [[Foo alloc] init]; // expected-warning {{assigning retained object to unsafe_unretained}}
+
+ __unsafe_unretained id unsafe_var;
+ unsafe_var = [Foo new]; // expected-warning {{assigning retained object to unsafe_unretained}}
+ unsafe_var = [[Foo alloc] init]; // expected-warning {{assigning retained object to unsafe_unretained}}
+}
+@end
+
+void bar(Foo *f) {
+ f.unsafe_prop = [Foo new]; // expected-warning {{assigning retained object to unsafe property}}
+
+ __unsafe_unretained id unsafe_var;
+ unsafe_var = [Foo new]; // expected-warning {{assigning retained object to unsafe_unretained}}
+ unsafe_var = [[Foo alloc] init]; // expected-warning {{assigning retained object to unsafe_unretained}}
+}
diff --git a/clang/test/SemaObjC/arc-unsafe_unretained.m b/clang/test/SemaObjC/arc-unsafe_unretained.m
new file mode 100644
index 0000000..a6c5f98
--- /dev/null
+++ b/clang/test/SemaObjC/arc-unsafe_unretained.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -fobjc-arc %s
+
+struct X {
+ __unsafe_unretained id object;
+ int (^ __unsafe_unretained block)(int, int);
+};
+
+void f(struct X x) {
+ x.object = 0;
+ x.block = ^(int x, int y) { return x + y; };
+}
diff --git a/clang/test/SemaObjC/arc.m b/clang/test/SemaObjC/arc.m
new file mode 100644
index 0000000..9c3b298
--- /dev/null
+++ b/clang/test/SemaObjC/arc.m
@@ -0,0 +1,698 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
+
+typedef unsigned long NSUInteger;
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
+
+void test0(void (*fn)(int), int val) {
+ fn(val);
+}
+
+@interface A
+- (id)retain;
+- (id)autorelease;
+- (oneway void)release;
+- (void)dealloc;
+- (NSUInteger)retainCount;
+@end
+
+void test1(A *a) {
+ 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}}
+ [a dealloc]; // expected-error {{ARC forbids explicit message send of 'dealloc'}}
+ [a retain]; // expected-error {{ARC forbids explicit message send of 'retain'}}
+ [a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}}
+ [a release]; // expected-error {{ARC forbids explicit message send of 'release'}}
+ [a autorelease]; // expected-error {{ARC forbids explicit message send of 'autorelease'}}
+}
+
+@interface Test2 : A
+- (void) dealloc;
+@end
+@implementation Test2
+- (void) dealloc {
+ // This should maybe just be ignored. We're just going to warn about it for now.
+ [super dealloc]; // expected-error {{ARC forbids explicit message send of 'dealloc'}}
+}
+@end
+
+// rdar://8843638
+
+@interface I
+- (id)retain; // expected-note {{method 'retain' declared here}}
+- (id)autorelease; // expected-note {{method 'autorelease' declared here}}
+- (oneway void)release; // expected-note {{method 'release' declared here}}
+- (NSUInteger)retainCount; // expected-note {{method 'retainCount' declared here}}
+@end
+
+@implementation I
+- (id)retain{return 0;} // expected-error {{ARC forbids implementation of 'retain'}}
+- (id)autorelease{return 0;} // expected-error {{ARC forbids implementation of 'autorelease'}}
+- (oneway void)release{} // expected-error {{ARC forbids implementation of 'release'}}
+- (NSUInteger)retainCount{ return 0; } // expected-error {{ARC forbids implementation of 'retainCount'}}
+@end
+
+@implementation I(CAT)
+- (id)retain{return 0;} // expected-error {{ARC forbids implementation of 'retain'}} \
+ // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+- (id)autorelease{return 0;} // expected-error {{ARC forbids implementation of 'autorelease'}} \
+ // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+- (oneway void)release{} // expected-error {{ARC forbids implementation of 'release'}} \
+ // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+- (NSUInteger)retainCount{ return 0; } // expected-error {{ARC forbids implementation of 'retainCount'}} \
+ // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+@end
+
+// rdar://8861761
+
+@interface B
+-(id)alloc;
+- (id)initWithInt: (int) i;
+@end
+
+void rdar8861761() {
+ B *o1 = [[B alloc] initWithInt:0];
+ B *o2 = [B alloc];
+ [o2 initWithInt:0]; // expected-warning {{expression result unused}}
+}
+
+// rdar://8925835
+@interface rdar8925835
+- (void)foo:(void (^)(unsigned captureCount, I * const capturedStrings[captureCount]))block;
+@end
+
+void test5() {
+ extern void test5_helper(__autoreleasing id *);
+ id x;
+
+ // Okay because of magic temporaries.
+ test5_helper(&x);
+
+ __autoreleasing id *a = &x; // expected-error {{initializing '__autoreleasing id *' with an expression of type '__strong id *' changes retain/release properties of pointer}}
+
+ a = &x; // expected-error {{assigning '__strong id *' to '__autoreleasing id *' changes retain/release properties of pointer}}
+
+ extern void test5_helper2(id const *);
+ test5_helper2(&x);
+
+ extern void test5_helper3(__weak id *); // expected-note {{passing argument to parameter here}}
+ test5_helper3(&x); // expected-error {{passing '__strong id *' to parameter of type '__weak id *' changes retain/release properties of pointer}}
+}
+
+// rdar://problem/8937869
+void test6(unsigned cond) {
+ switch (cond) {
+ case 0:
+ ;
+ id x; // expected-note {{jump bypasses initialization of retaining variable}}
+
+ case 1: // expected-error {{switch case is in protected scope}}
+ break;
+ }
+}
+
+@class NSError;
+void test7(void) {
+ extern void test7_helper(NSError **);
+ NSError *err;
+ test7_helper(&err);
+}
+void test7_weak(void) {
+ extern void test7_helper(NSError **);
+ __weak NSError *err;
+ test7_helper(&err);
+}
+void test7_unsafe(void) {
+ extern void test7_helper(NSError **); // expected-note {{passing argument to parameter here}}
+ __unsafe_unretained NSError *err;
+ test7_helper(&err); // expected-error {{passing 'NSError *__unsafe_unretained *' to parameter of type 'NSError *__autoreleasing *' changes retain/release properties of pointer}}
+}
+
+@class Test8_incomplete;
+@interface Test8_complete @end;
+@interface Test8_super @end;
+@interface Test8 : Test8_super
+- (id) init00;
+- (id) init01; // expected-note {{declaration in interface}} \
+ // expected-note{{overridden method}}
+- (id) init02; // expected-note{{overridden method}}
+- (id) init03; // covariance
+- (id) init04; // covariance
+- (id) init05; // expected-note{{overridden method}}
+
+- (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}} \
+ // expected-note{{overridden method}}
+- (Test8_super*) init32; // expected-note{{overridden method}}
+- (Test8_super*) init33;
+- (Test8_super*) init34; // covariance
+- (Test8_super*) init35; // expected-note{{overridden method}}
+
+- (Test8*) init40; // id exception to covariance
+- (Test8*) init41; // expected-note {{declaration in interface}} \
+ // expected-note{{overridden method}}
+- (Test8*) init42; // expected-note{{overridden method}}
+- (Test8*) init43; // this should be a warning, but that's a general language thing, not an ARC thing
+- (Test8*) init44;
+- (Test8*) init45; // expected-note{{overridden method}}
+
+- (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}}
+@end
+@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}} \
+ // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'void'}}
+- (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}} \
+ // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'void'}}
+- (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}} \
+ // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'void'}}
+- (void) init51 {}
+
+- (Test8_incomplete*) init02 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} \
+ // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_incomplete *'}}
+- (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}} \
+ // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_incomplete *'}}
+- (Test8_incomplete*) init42 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} \
+ // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_incomplete *'}}
+- (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}} \
+ // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_complete *'}}
+- (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}} \
+ // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_complete *'}}
+- (Test8_complete*) init45 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} \
+ // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_complete *'}}
+- (Test8_complete*) init55 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
+@end
+
+@class Test9_incomplete;
+@interface Test9
+- (Test9_incomplete*) init1; // expected-error {{init methods must return a type related to the receiver type}}
+- (Test9_incomplete*) init2;
+@end
+id test9(Test9 *v) {
+ return [v init1];
+}
+
+// Test that the inference rules are different for fast enumeration variables.
+void test10(id collection) {
+ for (id x in collection) {
+ __strong id *ptr = &x; // expected-warning {{initializing '__strong id *' with an expression of type 'const __strong id *' discards qualifiers}}
+ }
+
+ for (__strong id x in collection) {
+ __weak id *ptr = &x; // expected-error {{initializing '__weak id *' with an expression of type '__strong id *' changes retain/release properties of pointer}}
+ }
+}
+
+// rdar://problem/9078626
+#define nil ((void*) 0)
+void test11(id op, void *vp) {
+ _Bool b;
+ b = (op == nil);
+ b = (nil == op);
+
+ b = (vp == nil);
+ b = (nil == vp);
+
+ b = (vp == op); // expected-error {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRetain call}}
+ b = (op == vp); // expected-error {{implicit conversion of C pointer type 'void *' to Objective-C pointer type 'id' requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRelease call}}
+}
+
+void test12(id collection) {
+ for (id x in collection) {
+ x = 0; // expected-error {{fast enumeration variables can't be modified in ARC by default; declare the variable __strong to allow this}}
+ }
+
+ for (const id x in collection) {
+ x = 0; // expected-error {{read-only variable is not assignable}}
+ }
+
+ for (__strong id x in collection) {
+ x = 0;
+ }
+}
+
+@interface Test13
+- (id) init0;
+- (void) noninit;
+@end
+@implementation Test13
+- (id) init0 {
+ self = 0;
+}
+- (void) noninit {
+ self = 0; // expected-error {{cannot assign to 'self' outside of a method in the init family}}
+}
+@end
+
+// <rdar://problem/10274056>
+@interface Test13_B
+- (id) consumesSelf __attribute__((ns_consumes_self));
+@end
+@implementation Test13_B
+- (id) consumesSelf {
+ self = 0; // no-warning
+}
+@end
+
+// rdar://problem/9172151
+@class Test14A, Test14B;
+void test14() {
+ extern void test14_consume(id *);
+ extern int test14_cond(void);
+ extern float test14_nowriteback(id __autoreleasing const *); // expected-note{{passing argument to parameter here}}
+
+ Test14A *a;
+ Test14B *b;
+ id i;
+ id cla[10];
+ id vla[test14_cond() + 10];
+
+ test14_consume((__strong id*) &a);
+ test14_consume((test14_cond() ? (__strong id*) &b : &i));
+ test14_consume(test14_cond() ? 0 : &a);
+ test14_consume(test14_cond() ? (void*) 0 : (&a));
+ test14_consume(cla); // expected-error {{passing address of non-scalar object to __autoreleasing parameter for write-back}}
+ test14_consume(vla); // expected-error {{passing address of non-scalar object to __autoreleasing parameter for write-back}}
+ test14_consume(&cla[5]); // expected-error {{passing address of non-scalar object to __autoreleasing parameter for write-back}}
+
+ __strong id *test14_indirect(void);
+ test14_consume(test14_indirect()); // expected-error {{passing address of non-local object to __autoreleasing parameter for write-back}}
+
+ extern id test14_global;
+ test14_consume(&test14_global); // expected-error {{passing address of non-local object to __autoreleasing parameter for write-back}}
+
+ extern __strong id *test14_global_ptr;
+ test14_consume(test14_global_ptr); // expected-error {{passing address of non-local object to __autoreleasing parameter for write-back}}
+
+ static id static_local;
+ test14_consume(&static_local); // expected-error {{passing address of non-local object to __autoreleasing parameter for write-back}}
+
+ __weak id* wip;
+ test14_nowriteback(&static_local); // okay, not a write-back.
+ test14_nowriteback(wip); // expected-error{{passing '__weak id *' to parameter of type '__autoreleasing id const *' changes retain/release properties of pointer}}
+}
+
+void test15() {
+ __block __autoreleasing id x; // expected-error {{__block variables cannot have __autoreleasing ownership}}
+}
+
+struct Test16;
+@interface Test16a
+- (void) test16_0: (int) x;
+- (int) test16_1: (int) x; // expected-note {{one possibility}}
+- (int) test16_2: (int) x; // expected-note {{one possibility}}
+- (id) test16_3: (int) x __attribute__((ns_returns_retained)); // expected-note {{one possibility}}
+- (void) test16_4: (int) x __attribute__((ns_consumes_self)); // expected-note {{one possibility}}
+- (void) test16_5: (id) __attribute__((ns_consumed)) x; // expected-note {{one possibility}}
+- (void) test16_6: (id) x;
+@end
+
+@interface Test16b
+- (void) test16_0: (int) x;
+- (int) test16_1: (char*) x; // expected-note {{also found}}
+- (char*) test16_2: (int) x; // expected-note {{also found}}
+- (id) test16_3: (int) x; // expected-note {{also found}}
+- (void) test16_4: (int) x; // expected-note {{also found}}
+- (void) test16_5: (id) x; // expected-note {{also found}}
+- (void) test16_6: (struct Test16 *) x;
+@end
+
+void test16(void) {
+ id v;
+ [v test16_0: 0];
+ [v test16_1: 0]; // expected-error {{multiple methods named 'test16_1:' found with mismatched result, parameter type or attributes}}
+ [v test16_2: 0]; // expected-error {{multiple methods named}}
+ [v test16_3: 0]; // expected-error {{multiple methods named}}
+ [v test16_4: 0]; // expected-error {{multiple methods named}}
+ [v test16_5: 0]; // expected-error {{multiple methods named}}
+ [v test16_6: 0];
+}
+
+@class Test17; // expected-note 2{{forward declaration of class here}}
+@protocol Test17p
+- (void) test17;
++ (void) test17;
+@end
+void test17(void) {
+ Test17 *v0;
+ [v0 test17]; // expected-error {{receiver type 'Test17' for instance message is a forward declaration}}
+
+ Test17<Test17p> *v1;
+ [v1 test17]; // expected-error {{receiver type 'Test17<Test17p>' for instance message is a forward declaration}}
+
+ [Test17 test17]; // expected-error {{receiver 'Test17' for class message is a forward declaration}}
+}
+
+void test18(void) {
+ id x;
+ [x test18]; // expected-error {{no known instance method for selector 'test18'}}
+}
+
+extern struct Test19 *test19a;
+struct Test19 *const test19b = 0;
+void test19(void) {
+ id x;
+ x = (id) test19a; // expected-error {{bridged cast}} \
+ // expected-note{{use __bridge to convert directly (no change in ownership)}} \
+ // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'struct Test19 *' into ARC}}
+ x = (id) test19b; // expected-error {{bridged cast}} \
+ // expected-note{{use __bridge to convert directly (no change in ownership)}} \
+ // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'struct Test19 *' into ARC}}
+}
+
+// rdar://problem/8951453
+static __thread id test20_implicit; // expected-error {{thread-local variable has non-trivial ownership: type is '__strong id'}}
+static __thread __strong id test20_strong; // expected-error {{thread-local variable has non-trivial ownership: type is '__strong id'}}
+static __thread __weak id test20_weak; // expected-error {{thread-local variable has non-trivial ownership: type is '__weak id'}}
+static __thread __autoreleasing id test20_autoreleasing; // expected-error {{thread-local variable has non-trivial ownership: type is '__autoreleasing id'}} expected-error {{global variables cannot have __autoreleasing ownership}}
+static __thread __unsafe_unretained id test20_unsafe;
+void test20(void) {
+ static __thread id test20_implicit; // expected-error {{thread-local variable has non-trivial ownership: type is '__strong id'}}
+ static __thread __strong id test20_strong; // expected-error {{thread-local variable has non-trivial ownership: type is '__strong id'}}
+ static __thread __weak id test20_weak; // expected-error {{thread-local variable has non-trivial ownership: type is '__weak id'}}
+ static __thread __autoreleasing id test20_autoreleasing; // expected-error {{thread-local variable has non-trivial ownership: type is '__autoreleasing id'}} expected-error {{global variables cannot have __autoreleasing ownership}}
+ static __thread __unsafe_unretained id test20_unsafe;
+}
+
+// rdar://9310049
+_Bool fn(id obj) {
+ return (_Bool)obj;
+}
+
+// Check casting w/ ownership qualifiers.
+void test21() {
+ __strong id *sip;
+ (void)(__weak id *)sip; // expected-error{{casting '__strong id *' to type '__weak id *' changes retain/release properties of pointer}}
+ (void)(__weak const id *)sip; // expected-error{{casting '__strong id *' to type '__weak id const *' changes retain/release properties of pointer}}
+ (void)(__autoreleasing id *)sip; // expected-error{{casting '__strong id *' to type '__autoreleasing id *' changes retain/release properties of pointer}}
+ (void)(__autoreleasing const id *)sip; // okay
+}
+
+// rdar://problem/9340462
+void test22(id x[]) { // expected-error {{must explicitly describe intended ownership of an object array parameter}}
+}
+
+// rdar://problem/9400219
+void test23(void) {
+ void *ptr;
+ ptr = @"foo";
+ ptr = (ptr ? @"foo" : 0);
+ ptr = (ptr ? @"foo" : @"bar");
+}
+
+id test24(void) {
+ extern void test24_helper(void);
+ return test24_helper(), (void*) 0;
+}
+
+// rdar://9400841
+@interface Base
+@property (assign) id content;
+@end
+
+@interface Foo : Base
+-(void)test;
+@end
+
+@implementation Foo
+-(void)test {
+ super.content = 0;
+}
+@end
+
+// <rdar://problem/9398437>
+void test25(Class *classes) {
+ Class *other_classes;
+ test25(other_classes);
+}
+
+void test26(id y) {
+ extern id test26_var1;
+ __sync_swap(&test26_var1, 0, y); // expected-error {{cannot perform atomic operation on a pointer to type '__strong id': type has non-trivial ownership}}
+
+ extern __unsafe_unretained id test26_var2;
+ __sync_swap(&test26_var2, 0, y);
+}
+
+@interface Test26
+- (id) init;
+- (id) initWithInt: (int) x;
+@end
+@implementation Test26
+- (id) init { return self; }
+- (id) initWithInt: (int) x {
+ [self init]; // expected-error {{the result of a delegate init call must be immediately returned or assigned to 'self'}}
+ return self;
+}
+@end
+
+// rdar://9525555
+@interface Test27 {
+ __weak id _myProp1;
+ id myProp2;
+}
+@property id x;
+@property (readonly) id ro;
+@property (readonly) id custom_ro;
+@property int y;
+
+@property (readonly) __weak id myProp1;
+@property (readonly) id myProp2;
+@property (readonly) __strong id myProp3;
+@end
+
+@implementation Test27
+@synthesize x;
+@synthesize ro;
+@synthesize y;
+
+@synthesize myProp1 = _myProp1;
+@synthesize myProp2;
+@synthesize myProp3;
+
+-(id)custom_ro { return 0; }
+@end
+
+// rdar://9569264
+@interface Test28
+@property (nonatomic, assign) __strong id a; // expected-error {{unsafe_unretained property 'a' may not also be declared __strong}}
+@end
+
+@interface Test28 ()
+@property (nonatomic, assign) __strong id b; // expected-error {{unsafe_unretained property 'b' may not also be declared __strong}}
+@end
+
+@implementation Test28
+@synthesize a;
+@synthesize b;
+@end
+
+// rdar://9573962
+typedef struct Bark Bark;
+@interface Test29
+@property Bark* P;
+@end
+
+@implementation Test29
+@synthesize P;
+- (id)Meth {
+ Bark** f = &P;
+ return 0;
+}
+@end
+
+// rdar://9495837
+@interface Test30
++ (id) new;
+- (void)Meth;
+@end
+
+@implementation Test30
++ (id) new { return 0; }
+- (void) Meth {
+ __weak id x = [Test30 new]; // expected-warning {{assigning retained object to weak variable}}
+ id __unsafe_unretained u = [Test30 new]; // expected-warning {{assigning retained object to unsafe_unretained variable}}
+ id y = [Test30 new];
+ x = [Test30 new]; // expected-warning {{assigning retained object to weak variable}}
+ u = [Test30 new]; // expected-warning {{assigning retained object to unsafe_unretained variable}}
+ y = [Test30 new];
+}
+@end
+
+// rdar://9411838
+@protocol PTest31 @end
+
+int Test31() {
+ Class cls;
+ id ids;
+ id<PTest31> pids;
+ Class<PTest31> pcls;
+
+ int i = (ids->isa ? 1 : 0); // expected-error {{member reference base type 'id' is not a structure or union}}
+ int j = (pids->isa ? 1 : 0); // expected-error {{member reference base type 'id<PTest31>' is not a structure or union}}
+ int k = (pcls->isa ? i : j); // expected-error {{member reference base type 'Class<PTest31>' is not a structure or union}}
+ return cls->isa ? i : j; // expected-error {{member reference base type 'Class' is not a structure or union}}
+}
+
+// rdar://9612030
+@interface ITest32 {
+@public
+ id ivar;
+}
+@end
+
+id Test32(__weak ITest32 *x) {
+ __weak ITest32 *y;
+ x->ivar = 0; // expected-error {{dereferencing a __weak pointer is not allowed}}
+ return y ? y->ivar // expected-error {{dereferencing a __weak pointer is not allowed}}
+ : (*x).ivar; // expected-error {{dereferencing a __weak pointer is not allowed}}
+}
+
+// rdar://9619861
+extern int printf(const char*, ...);
+typedef long intptr_t;
+
+int Test33(id someid) {
+ printf( "Hello%ld", (intptr_t)someid);
+ return (int)someid;
+}
+
+// rdar://9636091
+@interface I34
+@property (nonatomic, retain) id newName __attribute__((ns_returns_not_retained)) ;
+
+@property (nonatomic, retain) id newName1 __attribute__((ns_returns_not_retained)) ;
+- (id) newName1 __attribute__((ns_returns_not_retained));
+
+@property (nonatomic, retain) id newName2 __attribute__((ns_returns_not_retained)); // expected-note {{roperty declared here}}
+- (id) newName2; // expected-warning {{property declared as returning non-retained objects; getter returning retained objects}}
+@end
+
+@implementation I34
+@synthesize newName;
+
+@synthesize newName1;
+- (id) newName1 { return 0; }
+
+@synthesize newName2;
+@end
+
+void test35(void) {
+ extern void test36_helper(id*);
+ id x;
+ __strong id *xp = 0;
+
+ test36_helper(&x);
+ test36_helper(xp); // expected-error {{passing address of non-local object to __autoreleasing parameter for write-back}}
+
+ // rdar://problem/9665710
+ __block id y;
+ test36_helper(&y);
+ ^{ test36_helper(&y); }();
+
+ __strong int non_objc_type; // expected-warning {{'__strong' only applies to objective-c object or block pointer types}}
+}
+
+void test36(int first, ...) {
+ // <rdar://problem/9758798>
+ __builtin_va_list arglist;
+ __builtin_va_start(arglist, first);
+ id obj = __builtin_va_arg(arglist, id);
+ __builtin_va_end(arglist);
+}
+
+@class Test37; // expected-note{{forward declaration of class here}}
+void test37(Test37 *c) {
+ for (id y in c) { // expected-error {{collection expression type 'Test37' is a forward declaration}}
+ (void) y;
+ }
+
+ (void)sizeof(id*); // no error.
+}
+
+// rdar://problem/9887979
+@interface Test38
+@property int value;
+@end
+void test38() {
+ extern Test38 *test38_helper(void);
+ switch (test38_helper().value) {
+ case 0:
+ case 1:
+ ;
+ }
+}
+
+// rdar://10186536
+@class NSColor;
+void _NSCalc(NSColor* color, NSColor* bezelColors[]) __attribute__((unavailable("not available in automatic reference counting mode")));
+
+void _NSCalcBeze(NSColor* color, NSColor* bezelColors[]); // expected-error {{must explicitly describe intended ownership of an object array parameter}}
+
+// rdar://9970739
+@interface RestaurantTableViewCell
+- (void) restaurantLocation;
+@end
+
+@interface Radar9970739
+- (void) Meth;
+@end
+
+@implementation Radar9970739
+- (void) Meth {
+ RestaurantTableViewCell *cell;
+ [cell restaurantLocatoin]; // expected-error {{no visible @interface for 'RestaurantTableViewCell' declares the selector 'restaurantLocatoin'}}
+}
+@end
+
diff --git a/clang/test/SemaObjC/argument-checking.m b/clang/test/SemaObjC/argument-checking.m
new file mode 100644
index 0000000..9019a0f
--- /dev/null
+++ b/clang/test/SemaObjC/argument-checking.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+struct S { int a; };
+
+extern int charStarFunc(char *); // expected-note{{passing argument to parameter here}}
+extern int charFunc(char); // expected-note{{passing argument to parameter here}}
+
+@interface Test
++alloc;
+-(int)charStarMeth:(char *)s; // expected-note{{passing argument to parameter 's' here}}
+-structMeth:(struct S)s; // expected-note{{passing argument to parameter 's' here}}
+-structMeth:(struct S)s
+ :(struct S)s2; // expected-note{{passing argument to parameter 's2' here}}
+@end
+
+void test() {
+ id obj = [Test alloc];
+ struct S sInst;
+
+ charStarFunc(1); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'char *'}}
+ charFunc("abc"); // expected-warning {{incompatible pointer to integer conversion passing 'char [4]' to parameter of type 'char'}}
+
+ [obj charStarMeth:1]; // expected-warning {{incompatible integer to pointer conversion sending 'int'}}
+ [obj structMeth:1]; // expected-error {{sending 'int'}}
+ [obj structMeth:sInst :1]; // expected-error {{sending 'int'}}
+}
diff --git a/clang/test/SemaObjC/assign-rvalue-message.m b/clang/test/SemaObjC/assign-rvalue-message.m
new file mode 100644
index 0000000..1105d5e
--- /dev/null
+++ b/clang/test/SemaObjC/assign-rvalue-message.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://9005189
+
+@interface Foo
+@end
+
+struct Bar {
+ int x;
+};
+
+@implementation Foo {
+ struct Bar bar;
+}
+
+- (const struct Bar)bar {
+ return bar;
+}
+
+- (void)baz {
+ bar.x = 0;
+ [self bar].x = 10; // expected-error {{assigning to 'readonly' return result of an objective-c message not allowed}}
+}
+@end
diff --git a/clang/test/SemaObjC/at-defs.m b/clang/test/SemaObjC/at-defs.m
new file mode 100644
index 0000000..4c0c586
--- /dev/null
+++ b/clang/test/SemaObjC/at-defs.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-fragile-abi %s -fsyntax-only
+
+@interface Test {
+ double a;
+}
+@end
+@implementation Test
+@end
+@interface TestObject : Test {
+@public
+ float bar;
+ int foo;
+}
+@end
+@implementation TestObject
+@end
+struct wibble {
+ @defs(TestObject)
+};
+
+
+int main(void)
+{
+ TestObject * a = (id)malloc(100);
+ a->foo = 12;
+ printf("12: %d\n", ((struct wibble*)a)->foo);
+ printf("%d: %d\n", ((char*)&(((struct wibble*)a)->foo)) - (char*)a, ((char*)&(a->foo)) - (char*)a);
+ return 0;
+}
diff --git a/clang/test/SemaObjC/atomoic-property-synnthesis-rules.m b/clang/test/SemaObjC/atomoic-property-synnthesis-rules.m
new file mode 100644
index 0000000..b681558
--- /dev/null
+++ b/clang/test/SemaObjC/atomoic-property-synnthesis-rules.m
@@ -0,0 +1,377 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+/*
+ Conditions for warning:
+ 1. the property is atomic
+ 2. the current @implementation contains an @synthesize for the property
+ 3. the current @implementation contains a hand-written setter XOR getter
+ 4. the property is read-write
+
+ Cases marked WARN should warn one the following:
+ warning: Atomic property 'x' has a synthesized setter and a
+ manually-implemented getter, which may break atomicity.
+ warning: Atomic property 'x' has a synthesized getter and a
+ manually-implemented setter, which may break atomicity.
+
+ Cases not marked WARN only satisfy the indicated subset
+ of the conditions required to warn.
+
+ There should be 8 warnings.
+*/
+
+@interface Foo
+{
+ /* 12 4 */ int GetSet;
+ /* WARN */ int Get;
+ /* WARN */ int Set;
+ /* 12 4 */ int None;
+ /* 2 4 */ int GetSet_Nonatomic;
+ /* 234 */ int Get_Nonatomic;
+ /* 234 */ int Set_Nonatomic;
+ /* 2 4 */ int None_Nonatomic;
+
+ /* 12 */ int GetSet_ReadOnly;
+ /* 123 */ int Get_ReadOnly;
+ /* 123 */ int Set_ReadOnly;
+ /* 12 */ int None_ReadOnly;
+ /* 2 */ int GetSet_Nonatomic_ReadOnly;
+ /* 23 */ int Get_Nonatomic_ReadOnly;
+ /* 23 */ int Set_Nonatomic_ReadOnly;
+ /* 2 */ int None_Nonatomic_ReadOnly;
+
+ /* 12 4 */ int GetSet_ReadWriteInExt;
+ /* WARN */ int Get_ReadWriteInExt;
+ /* WARN */ int Set_ReadWriteInExt;
+ /* 12 4 */ int None_ReadWriteInExt;
+ /* 2 4 */ int GetSet_Nonatomic_ReadWriteInExt;
+ /* 234 */ int Get_Nonatomic_ReadWriteInExt;
+ /* 234 */ int Set_Nonatomic_ReadWriteInExt;
+ /* 2 4 */ int None_Nonatomic_ReadWriteInExt;
+
+
+ /* 12 4 */ int GetSet_LateSynthesize;
+ /* WARN */ int Get_LateSynthesize;
+ /* WARN */ int Set_LateSynthesize;
+ /* 12 4 */ int None_LateSynthesize;
+ /* 2 4 */ int GetSet_Nonatomic_LateSynthesize;
+ /* 234 */ int Get_Nonatomic_LateSynthesize;
+ /* 234 */ int Set_Nonatomic_LateSynthesize;
+ /* 2 4 */ int None_Nonatomic_LateSynthesize;
+
+ /* 12 */ int GetSet_ReadOnly_LateSynthesize;
+ /* 123 */ int Get_ReadOnly_LateSynthesize;
+ /* 123 */ int Set_ReadOnly_LateSynthesize;
+ /* 12 */ int None_ReadOnly_LateSynthesize;
+ /* 2 */ int GetSet_Nonatomic_ReadOnly_LateSynthesize;
+ /* 23 */ int Get_Nonatomic_ReadOnly_LateSynthesize;
+ /* 23 */ int Set_Nonatomic_ReadOnly_LateSynthesize;
+ /* 2 */ int None_Nonatomic_ReadOnly_LateSynthesize;
+
+ /* 12 4 */ int GetSet_ReadWriteInExt_LateSynthesize;
+ /* WARN */ int Get_ReadWriteInExt_LateSynthesize;
+ /* WARN */ int Set_ReadWriteInExt_LateSynthesize;
+ /* 12 4 */ int None_ReadWriteInExt_LateSynthesize;
+ /* 2 4 */ int GetSet_Nonatomic_ReadWriteInExt_LateSynthesize;
+ /* 234 */ int Get_Nonatomic_ReadWriteInExt_LateSynthesize;
+ /* 234 */ int Set_Nonatomic_ReadWriteInExt_LateSynthesize;
+ /* 2 4 */ int None_Nonatomic_ReadWriteInExt_LateSynthesize;
+
+
+ /* 1 4 */ int GetSet_NoSynthesize;
+ /* 1 34 */ int Get_NoSynthesize;
+ /* 1 34 */ int Set_NoSynthesize;
+ /* 1 4 */ int None_NoSynthesize;
+ /* 4 */ int GetSet_Nonatomic_NoSynthesize;
+ /* 34 */ int Get_Nonatomic_NoSynthesize;
+ /* 34 */ int Set_Nonatomic_NoSynthesize;
+ /* 4 */ int None_Nonatomic_NoSynthesize;
+
+ /* 1 */ int GetSet_ReadOnly_NoSynthesize;
+ /* 1 3 */ int Get_ReadOnly_NoSynthesize;
+ /* 1 3 */ int Set_ReadOnly_NoSynthesize;
+ /* 1 */ int None_ReadOnly_NoSynthesize;
+ /* */ int GetSet_Nonatomic_ReadOnly_NoSynthesize;
+ /* 3 */ int Get_Nonatomic_ReadOnly_NoSynthesize;
+ /* 3 */ int Set_Nonatomic_ReadOnly_NoSynthesize;
+ /* */ int None_Nonatomic_ReadOnly_NoSynthesize;
+
+ /* 1 4 */ int GetSet_ReadWriteInExt_NoSynthesize;
+ /* 1 34 */ int Get_ReadWriteInExt_NoSynthesize;
+ /* 1 34 */ int Set_ReadWriteInExt_NoSynthesize;
+ /* 1 4 */ int None_ReadWriteInExt_NoSynthesize;
+ /* 4 */ int GetSet_Nonatomic_ReadWriteInExt_NoSynthesize;
+ /* 34 */ int Get_Nonatomic_ReadWriteInExt_NoSynthesize;
+ /* 34 */ int Set_Nonatomic_ReadWriteInExt_NoSynthesize;
+ /* 4 */ int None_Nonatomic_ReadWriteInExt_NoSynthesize;
+}
+
+// read-write - might warn
+@property int GetSet;
+@property int Get; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
+@property int Set; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
+@property int None;
+@property(nonatomic) int GetSet_Nonatomic;
+@property(nonatomic) int Get_Nonatomic;
+@property(nonatomic) int Set_Nonatomic;
+@property(nonatomic) int None_Nonatomic;
+
+// read-only - must not warn
+@property(readonly) int GetSet_ReadOnly;
+@property(readonly) int Get_ReadOnly;
+@property(readonly) int Set_ReadOnly;
+@property(readonly) int None_ReadOnly;
+@property(nonatomic,readonly) int GetSet_Nonatomic_ReadOnly;
+@property(nonatomic,readonly) int Get_Nonatomic_ReadOnly;
+@property(nonatomic,readonly) int Set_Nonatomic_ReadOnly;
+@property(nonatomic,readonly) int None_Nonatomic_ReadOnly;
+
+// read-only in class, read-write in class extension - might warn
+@property(readonly) int GetSet_ReadWriteInExt;
+@property(readonly) int Get_ReadWriteInExt; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
+@property(readonly) int Set_ReadWriteInExt; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
+@property(readonly) int None_ReadWriteInExt;
+@property(nonatomic,readonly) int GetSet_Nonatomic_ReadWriteInExt;
+@property(nonatomic,readonly) int Get_Nonatomic_ReadWriteInExt;
+@property(nonatomic,readonly) int Set_Nonatomic_ReadWriteInExt;
+@property(nonatomic,readonly) int None_Nonatomic_ReadWriteInExt;
+
+
+// same as above, but @synthesize follows the hand-written methods - might warn
+@property int GetSet_LateSynthesize;
+@property int Get_LateSynthesize; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
+@property int Set_LateSynthesize; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
+@property int None_LateSynthesize;
+@property(nonatomic) int GetSet_Nonatomic_LateSynthesize;
+@property(nonatomic) int Get_Nonatomic_LateSynthesize;
+@property(nonatomic) int Set_Nonatomic_LateSynthesize;
+@property(nonatomic) int None_Nonatomic_LateSynthesize;
+
+@property(readonly) int GetSet_ReadOnly_LateSynthesize;
+@property(readonly) int Get_ReadOnly_LateSynthesize;
+@property(readonly) int Set_ReadOnly_LateSynthesize;
+@property(readonly) int None_ReadOnly_LateSynthesize;
+@property(nonatomic,readonly) int GetSet_Nonatomic_ReadOnly_LateSynthesize;
+@property(nonatomic,readonly) int Get_Nonatomic_ReadOnly_LateSynthesize;
+@property(nonatomic,readonly) int Set_Nonatomic_ReadOnly_LateSynthesize;
+@property(nonatomic,readonly) int None_Nonatomic_ReadOnly_LateSynthesize;
+
+@property(readonly) int GetSet_ReadWriteInExt_LateSynthesize;
+@property(readonly) int Get_ReadWriteInExt_LateSynthesize; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
+@property(readonly) int Set_ReadWriteInExt_LateSynthesize; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
+@property(readonly) int None_ReadWriteInExt_LateSynthesize;
+@property(nonatomic,readonly) int GetSet_Nonatomic_ReadWriteInExt_LateSynthesize;
+@property(nonatomic,readonly) int Get_Nonatomic_ReadWriteInExt_LateSynthesize;
+@property(nonatomic,readonly) int Set_Nonatomic_ReadWriteInExt_LateSynthesize;
+@property(nonatomic,readonly) int None_Nonatomic_ReadWriteInExt_LateSynthesize;
+
+
+// same as above, but with no @synthesize - must not warn
+@property int GetSet_NoSynthesize;
+@property int Get_NoSynthesize;
+@property int Set_NoSynthesize;
+@property int None_NoSynthesize;
+@property(nonatomic) int GetSet_Nonatomic_NoSynthesize;
+@property(nonatomic) int Get_Nonatomic_NoSynthesize;
+@property(nonatomic) int Set_Nonatomic_NoSynthesize;
+@property(nonatomic) int None_Nonatomic_NoSynthesize;
+
+@property(readonly) int GetSet_ReadOnly_NoSynthesize;
+@property(readonly) int Get_ReadOnly_NoSynthesize;
+@property(readonly) int Set_ReadOnly_NoSynthesize;
+@property(readonly) int None_ReadOnly_NoSynthesize;
+@property(nonatomic,readonly) int GetSet_Nonatomic_ReadOnly_NoSynthesize;
+@property(nonatomic,readonly) int Get_Nonatomic_ReadOnly_NoSynthesize;
+@property(nonatomic,readonly) int Set_Nonatomic_ReadOnly_NoSynthesize;
+@property(nonatomic,readonly) int None_Nonatomic_ReadOnly_NoSynthesize;
+
+@property(readonly) int GetSet_ReadWriteInExt_NoSynthesize;
+@property(readonly) int Get_ReadWriteInExt_NoSynthesize;
+@property(readonly) int Set_ReadWriteInExt_NoSynthesize;
+@property(readonly) int None_ReadWriteInExt_NoSynthesize;
+@property(nonatomic,readonly) int GetSet_Nonatomic_ReadWriteInExt_NoSynthesize;
+@property(nonatomic,readonly) int Get_Nonatomic_ReadWriteInExt_NoSynthesize;
+@property(nonatomic,readonly) int Set_Nonatomic_ReadWriteInExt_NoSynthesize;
+@property(nonatomic,readonly) int None_Nonatomic_ReadWriteInExt_NoSynthesize;
+
+@end
+
+
+@interface Foo ()
+
+@property(readwrite) int GetSet_ReadWriteInExt;
+@property(readwrite) int Get_ReadWriteInExt;
+@property(readwrite) int Set_ReadWriteInExt;
+@property(readwrite) int None_ReadWriteInExt;
+@property(nonatomic,readwrite) int GetSet_Nonatomic_ReadWriteInExt;
+@property(nonatomic,readwrite) int Get_Nonatomic_ReadWriteInExt;
+@property(nonatomic,readwrite) int Set_Nonatomic_ReadWriteInExt;
+@property(nonatomic,readwrite) int None_Nonatomic_ReadWriteInExt;
+
+@property(readwrite) int GetSet_ReadWriteInExt_LateSynthesize;
+@property(readwrite) int Get_ReadWriteInExt_LateSynthesize;
+@property(readwrite) int Set_ReadWriteInExt_LateSynthesize;
+@property(readwrite) int None_ReadWriteInExt_LateSynthesize;
+@property(nonatomic,readwrite) int GetSet_Nonatomic_ReadWriteInExt_LateSynthesize;
+@property(nonatomic,readwrite) int Get_Nonatomic_ReadWriteInExt_LateSynthesize;
+@property(nonatomic,readwrite) int Set_Nonatomic_ReadWriteInExt_LateSynthesize;
+@property(nonatomic,readwrite) int None_Nonatomic_ReadWriteInExt_LateSynthesize;
+
+@property(readwrite) int GetSet_ReadWriteInExt_NoSynthesize;
+@property(readwrite) int Get_ReadWriteInExt_NoSynthesize;
+@property(readwrite) int Set_ReadWriteInExt_NoSynthesize;
+@property(readwrite) int None_ReadWriteInExt_NoSynthesize;
+@property(nonatomic,readwrite) int GetSet_Nonatomic_ReadWriteInExt_NoSynthesize;
+@property(nonatomic,readwrite) int Get_Nonatomic_ReadWriteInExt_NoSynthesize;
+@property(nonatomic,readwrite) int Set_Nonatomic_ReadWriteInExt_NoSynthesize;
+@property(nonatomic,readwrite) int None_Nonatomic_ReadWriteInExt_NoSynthesize;
+
+@end
+
+@implementation Foo
+
+@synthesize GetSet, Get, Set, None, GetSet_Nonatomic, Get_Nonatomic, Set_Nonatomic, None_Nonatomic;
+@synthesize GetSet_ReadOnly, Get_ReadOnly, Set_ReadOnly, None_ReadOnly, GetSet_Nonatomic_ReadOnly, Get_Nonatomic_ReadOnly, Set_Nonatomic_ReadOnly, None_Nonatomic_ReadOnly;
+@synthesize GetSet_ReadWriteInExt, Get_ReadWriteInExt, Set_ReadWriteInExt, None_ReadWriteInExt, GetSet_Nonatomic_ReadWriteInExt, Get_Nonatomic_ReadWriteInExt, Set_Nonatomic_ReadWriteInExt, None_Nonatomic_ReadWriteInExt;
+
+#define GET(x) \
+ -(int) x { return self->x; }
+#define SET(x) \
+ -(void) set##x:(int)value { self->x = value; }
+
+GET(GetSet)
+SET(GetSet)
+GET(Get) // expected-warning {{writable atomic property 'Get' cannot pair a synthesized setter with a user defined getter}}
+SET(Set) // expected-warning {{writable atomic property 'Set' cannot pair a synthesized getter with a user defined setter}}
+GET(GetSet_Nonatomic)
+SET(GetSet_Nonatomic)
+GET(Get_Nonatomic)
+SET(Set_Nonatomic)
+
+GET(GetSet_ReadOnly)
+SET(GetSet_ReadOnly)
+GET(Get_ReadOnly)
+SET(Set_ReadOnly)
+GET(GetSet_Nonatomic_ReadOnly)
+SET(GetSet_Nonatomic_ReadOnly)
+GET(Get_Nonatomic_ReadOnly)
+SET(Set_Nonatomic_ReadOnly)
+
+GET(GetSet_ReadWriteInExt)
+SET(GetSet_ReadWriteInExt)
+GET(Get_ReadWriteInExt) // expected-warning {{writable atomic property 'Get_ReadWriteInExt' cannot pair a synthesized setter with a user defined getter}}
+SET(Set_ReadWriteInExt) // expected-warning {{writable atomic property 'Set_ReadWriteInExt' cannot pair a synthesized getter with a user defined setter}}
+GET(GetSet_Nonatomic_ReadWriteInExt)
+SET(GetSet_Nonatomic_ReadWriteInExt)
+GET(Get_Nonatomic_ReadWriteInExt)
+SET(Set_Nonatomic_ReadWriteInExt)
+
+
+GET(GetSet_LateSynthesize)
+SET(GetSet_LateSynthesize)
+GET(Get_LateSynthesize) // expected-warning {{writable atomic property 'Get_LateSynthesize' cannot pair a synthesized setter with a user defined getter}}
+SET(Set_LateSynthesize) // expected-warning {{writable atomic property 'Set_LateSynthesize' cannot pair a synthesized getter with a user defined setter}}
+GET(GetSet_Nonatomic_LateSynthesize)
+SET(GetSet_Nonatomic_LateSynthesize)
+GET(Get_Nonatomic_LateSynthesize)
+SET(Set_Nonatomic_LateSynthesize)
+
+GET(GetSet_ReadOnly_LateSynthesize)
+SET(GetSet_ReadOnly_LateSynthesize)
+GET(Get_ReadOnly_LateSynthesize)
+SET(Set_ReadOnly_LateSynthesize)
+GET(GetSet_Nonatomic_ReadOnly_LateSynthesize)
+SET(GetSet_Nonatomic_ReadOnly_LateSynthesize)
+GET(Get_Nonatomic_ReadOnly_LateSynthesize)
+SET(Set_Nonatomic_ReadOnly_LateSynthesize)
+
+GET(GetSet_ReadWriteInExt_LateSynthesize)
+SET(GetSet_ReadWriteInExt_LateSynthesize)
+GET(Get_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Get_ReadWriteInExt_LateSynthesize' cannot pair a synthesized setter with a user defined getter}}
+SET(Set_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Set_ReadWriteInExt_LateSynthesize' cannot pair a synthesized getter with a user defined setter}}
+GET(GetSet_Nonatomic_ReadWriteInExt_LateSynthesize)
+SET(GetSet_Nonatomic_ReadWriteInExt_LateSynthesize)
+GET(Get_Nonatomic_ReadWriteInExt_LateSynthesize)
+SET(Set_Nonatomic_ReadWriteInExt_LateSynthesize)
+
+
+GET(GetSet_NoSynthesize)
+SET(GetSet_NoSynthesize)
+GET(Get_NoSynthesize)
+SET(Set_NoSynthesize)
+GET(GetSet_Nonatomic_NoSynthesize)
+SET(GetSet_Nonatomic_NoSynthesize)
+GET(Get_Nonatomic_NoSynthesize)
+SET(Set_Nonatomic_NoSynthesize)
+
+GET(GetSet_ReadOnly_NoSynthesize)
+SET(GetSet_ReadOnly_NoSynthesize)
+GET(Get_ReadOnly_NoSynthesize)
+SET(Set_ReadOnly_NoSynthesize)
+GET(GetSet_Nonatomic_ReadOnly_NoSynthesize)
+SET(GetSet_Nonatomic_ReadOnly_NoSynthesize)
+GET(Get_Nonatomic_ReadOnly_NoSynthesize)
+SET(Set_Nonatomic_ReadOnly_NoSynthesize)
+
+GET(GetSet_ReadWriteInExt_NoSynthesize)
+SET(GetSet_ReadWriteInExt_NoSynthesize)
+GET(Get_ReadWriteInExt_NoSynthesize)
+SET(Set_ReadWriteInExt_NoSynthesize)
+GET(GetSet_Nonatomic_ReadWriteInExt_NoSynthesize)
+SET(GetSet_Nonatomic_ReadWriteInExt_NoSynthesize)
+GET(Get_Nonatomic_ReadWriteInExt_NoSynthesize)
+SET(Set_Nonatomic_ReadWriteInExt_NoSynthesize)
+
+
+// late synthesize - follows getter/setter implementations
+
+@synthesize GetSet_LateSynthesize, Get_LateSynthesize, Set_LateSynthesize, None_LateSynthesize, GetSet_Nonatomic_LateSynthesize, Get_Nonatomic_LateSynthesize, Set_Nonatomic_LateSynthesize, None_Nonatomic_LateSynthesize;
+@synthesize GetSet_ReadOnly_LateSynthesize, Get_ReadOnly_LateSynthesize, Set_ReadOnly_LateSynthesize, None_ReadOnly_LateSynthesize, GetSet_Nonatomic_ReadOnly_LateSynthesize, Get_Nonatomic_ReadOnly_LateSynthesize, Set_Nonatomic_ReadOnly_LateSynthesize, None_Nonatomic_ReadOnly_LateSynthesize;
+@synthesize GetSet_ReadWriteInExt_LateSynthesize, Get_ReadWriteInExt_LateSynthesize, Set_ReadWriteInExt_LateSynthesize, None_ReadWriteInExt_LateSynthesize, GetSet_Nonatomic_ReadWriteInExt_LateSynthesize, Get_Nonatomic_ReadWriteInExt_LateSynthesize, Set_Nonatomic_ReadWriteInExt_LateSynthesize, None_Nonatomic_ReadWriteInExt_LateSynthesize;
+
+// no synthesize - use dynamic instead
+
+@dynamic GetSet_NoSynthesize, Get_NoSynthesize, Set_NoSynthesize, None_NoSynthesize, GetSet_Nonatomic_NoSynthesize, Get_Nonatomic_NoSynthesize, Set_Nonatomic_NoSynthesize, None_Nonatomic_NoSynthesize;
+@dynamic GetSet_ReadOnly_NoSynthesize, Get_ReadOnly_NoSynthesize, Set_ReadOnly_NoSynthesize, None_ReadOnly_NoSynthesize, GetSet_Nonatomic_ReadOnly_NoSynthesize, Get_Nonatomic_ReadOnly_NoSynthesize, Set_Nonatomic_ReadOnly_NoSynthesize, None_Nonatomic_ReadOnly_NoSynthesize;
+@dynamic GetSet_ReadWriteInExt_NoSynthesize, Get_ReadWriteInExt_NoSynthesize, Set_ReadWriteInExt_NoSynthesize, None_ReadWriteInExt_NoSynthesize, GetSet_Nonatomic_ReadWriteInExt_NoSynthesize, Get_Nonatomic_ReadWriteInExt_NoSynthesize, Set_Nonatomic_ReadWriteInExt_NoSynthesize, None_Nonatomic_ReadWriteInExt_NoSynthesize;
+
+@end
+
+/*
+// the following method should cause a warning along the lines of
+// :warning: Atomic property 'x' cannot pair a synthesized setter/getter with a manually implemented setter/getter
+- (void) setX: (int) aValue
+{
+ x = aValue;
+}
+
+// no warning 'cause this is nonatomic
+- (void) setY: (int) aValue
+{
+ y = aValue;
+}
+
+// the following method should cause a warning along the lines of
+// :warning: Atomic property 'x' cannot pair a synthesized setter/getter with a manually implemented setter/getter
+- (int) j
+{
+ return j;
+}
+
+// no warning 'cause this is nonatomic
+- (int) k
+{
+ return k;
+}
+@end
+*/
+int main (int argc, const char * argv[]) {
+ return 0;
+}
diff --git a/clang/test/SemaObjC/attr-availability.m b/clang/test/SemaObjC/attr-availability.m
new file mode 100644
index 0000000..d857bda
--- /dev/null
+++ b/clang/test/SemaObjC/attr-availability.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9.0.0 -fsyntax-only -verify %s
+@interface A
+- (void)method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2)));
+@end
+
+@interface B : A
+- (void)method;
+@end
+
+void f(A *a, B *b) {
+ [a method]; // expected-warning{{'method' is deprecated: first deprecated in Mac OS X 10.2}}
+ [b method];
+}
diff --git a/clang/test/SemaObjC/attr-cleanup.m b/clang/test/SemaObjC/attr-cleanup.m
new file mode 100644
index 0000000..8415c69
--- /dev/null
+++ b/clang/test/SemaObjC/attr-cleanup.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+@class NSString;
+
+void c1(id *a);
+
+void t1()
+{
+ NSString *s __attribute((cleanup(c1)));
+}
diff --git a/clang/test/SemaObjC/attr-deprecated.m b/clang/test/SemaObjC/attr-deprecated.m
new file mode 100644
index 0000000..db0b958
--- /dev/null
+++ b/clang/test/SemaObjC/attr-deprecated.m
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface A {
+ int X __attribute__((deprecated));
+}
++ (void)F __attribute__((deprecated));
+- (void)f __attribute__((deprecated));
+@end
+
+@implementation A
++ (void)F __attribute__((deprecated))
+{
+ [self F]; // no warning, since the caller is also deprecated.
+}
+
+- (void)g
+{
+ X++; // expected-warning{{'X' is deprecated}}
+ self->X++; // expected-warning{{'X' is deprecated}}
+ [self f]; // expected-warning{{'f' is deprecated}}
+}
+
+- (void)f
+{
+ [self f]; // no warning, the caller is deprecated in its interface.
+}
+@end
+
+@interface B: A
+@end
+
+@implementation B
++ (void)G
+{
+ [super F]; // expected-warning{{'F' is deprecated}}
+}
+
+- (void)g
+{
+ [super f]; // // expected-warning{{'f' is deprecated}}
+}
+@end
+
+@protocol P
+- (void)p __attribute__((deprecated));
+@end
+
+void t1(A *a)
+{
+ [A F]; // expected-warning{{'F' is deprecated}}
+ [a f]; // expected-warning{{'f' is deprecated}}
+}
+
+void t2(id a)
+{
+ [a f];
+}
+
+void t3(A<P>* a)
+{
+ [a f]; // expected-warning{{'f' is deprecated}}
+ [a p]; // expected-warning{{'p' is deprecated}}
+}
+
+void t4(Class c)
+{
+ [c F];
+}
+
+
+
+@interface Bar
+
+@property (assign, setter = MySetter:) int FooBar __attribute__ ((deprecated));
+- (void) MySetter : (int) value;
+@end
+
+int t5() {
+ Bar *f;
+ f.FooBar = 1; // expected-warning {{'FooBar' is deprecated}}
+ return f.FooBar; // expected-warning {{'FooBar' is deprecated}}
+}
+
+
+__attribute ((deprecated))
+@interface DEPRECATED {
+ @public int ivar;
+ DEPRECATED *ivar2; // no warning.
+}
+- (int) instancemethod;
+- (DEPRECATED *) meth; // no warning.
+@property int prop;
+@end
+
+@interface DEPRECATED (Category) // no warning.
+- (DEPRECATED *) meth2; // no warning.
+@end
+
+@interface DEPRECATED (Category2) // no warning.
+@end
+
+@implementation DEPRECATED (Category2) // expected-warning {{'DEPRECATED' is deprecated}}
+@end
+
+@interface NS : DEPRECATED // expected-warning {{'DEPRECATED' is deprecated}}
+@end
+
+
+@interface Test2
+@property int test2 __attribute__((deprecated));
+@end
+
+void test(Test2 *foo) {
+ int x;
+ x = foo.test2; // expected-warning {{'test2' is deprecated}}
+ x = [foo test2]; // expected-warning {{'test2' is deprecated}}
+ foo.test2 = x; // expected-warning {{'test2' is deprecated}}
+ [foo setTest2: x]; // expected-warning {{'setTest2:' is deprecated}}
+}
+
+__attribute__((deprecated))
+@interface A(Blah) // expected-error{{attributes may not be specified on a category}}
+@end
diff --git a/clang/test/SemaObjC/attr-malloc.m b/clang/test/SemaObjC/attr-malloc.m
new file mode 100644
index 0000000..a504b33
--- /dev/null
+++ b/clang/test/SemaObjC/attr-malloc.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fblocks %s
+
+@interface TestAttrMallocOnMethods {}
+- (id) test1 __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
+- (int) test2 __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
+@end
+
+id bar(void) __attribute((malloc)); // no-warning
+
+typedef void (^bptr)(void);
+bptr baz(void) __attribute((malloc)); // no-warning
+
+__attribute((malloc)) id (*f)(); // expected-warning {{functions returning a pointer type}}
+__attribute((malloc)) bptr (*g)(); // expected-warning {{functions returning a pointer type}}
+__attribute((malloc)) void *(^h)(); // expected-warning {{functions returning a pointer type}}
+
diff --git a/clang/test/SemaObjC/attr-ns-bridged.m b/clang/test/SemaObjC/attr-ns-bridged.m
new file mode 100644
index 0000000..1ab60a2
--- /dev/null
+++ b/clang/test/SemaObjC/attr-ns-bridged.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef struct __attribute__((ns_bridged)) test0s *test0ref;
+
+void test0func(void) __attribute__((ns_bridged)); // expected-error {{'ns_bridged' attribute only applies to structs}}
+
+union __attribute__((ns_bridged)) test0u; // expected-error {{'ns_bridged' attribute only applies to structs}}
+
+struct __attribute__((ns_bridged(Test1))) test1s;
+
+@class Test2;
+struct __attribute__((ns_bridged(Test2))) test2s;
+
+void Test3(void); // expected-note {{declared here}}
+struct __attribute__((ns_bridged(Test3))) test3s; // expected-error {{parameter of 'ns_bridged' attribute does not name an Objective-C class}}
diff --git a/clang/test/SemaObjC/attr-objc-exception.m b/clang/test/SemaObjC/attr-objc-exception.m
new file mode 100644
index 0000000..b497271
--- /dev/null
+++ b/clang/test/SemaObjC/attr-objc-exception.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+__attribute__((__objc_exception__))
+@interface NSException {
+ int x;
+}
+
+@end
+
+
+__attribute__((__objc_exception__)) // expected-error {{attribute may only be applied to an Objective-C interface}}
+int X;
+
+__attribute__((__objc_exception__)) // expected-error {{attribute may only be applied to an Objective-C interface}}
+void foo();
+
diff --git a/clang/test/SemaObjC/attr-objc-gc.m b/clang/test/SemaObjC/attr-objc-gc.m
new file mode 100644
index 0000000..9ca12c9
--- /dev/null
+++ b/clang/test/SemaObjC/attr-objc-gc.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+static id __attribute((objc_gc(weak))) a;
+static id __attribute((objc_gc(strong))) b;
+
+static id __attribute((objc_gc())) c; // expected-error{{'objc_gc' attribute requires parameter 1 to be a string}}
+static id __attribute((objc_gc(123))) d; // expected-error{{'objc_gc' attribute requires parameter 1 to be a string}}
+static id __attribute((objc_gc(foo, 456))) e; // expected-error{{attribute takes one argument}}
+static id __attribute((objc_gc(hello))) f; // expected-warning{{'objc_gc' attribute argument not supported: 'hello'}}
+
+static int __attribute__((objc_gc(weak))) g; // expected-warning {{'objc_gc' only applies to pointer types; type here is 'int'}}
+
+static __weak int h; // expected-warning {{'__weak' only applies to pointer types; type here is 'int'}}
+
+// TODO: it would be great if this reported as __weak
+#define WEAK __weak
+static WEAK int h; // expected-warning {{'objc_gc' only applies to pointer types; type here is 'int'}}
+
+/* expected-warning {{'__weak' only applies to pointer types; type here is 'int'}}*/ static __we\
+ak int i;
+
+// rdar://problem/9126213
+void test2(id __attribute((objc_gc(strong))) *strong,
+ id __attribute((objc_gc(weak))) *weak) {
+ void *opaque;
+ opaque = strong;
+ strong = opaque;
+
+ opaque = weak;
+ weak = opaque;
+}
diff --git a/clang/test/SemaObjC/attr-root-class.m b/clang/test/SemaObjC/attr-root-class.m
new file mode 100644
index 0000000..195cd66
--- /dev/null
+++ b/clang/test/SemaObjC/attr-root-class.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wattributes -Wobjc-root-class %s
+@interface RootClass {} // expected-warning {{class 'RootClass' defined without specifying a base class}} \
+ // expected-note {{add a super class to fix this problem}}
+@end
+@implementation RootClass
+@end
+
+__attribute__((objc_root_class))
+@interface NonRootClass : RootClass // expected-error {{objc_root_class attribute may only be specified on a root class declaration}}
+@end
+@implementation NonRootClass
+@end
+
+__attribute__((objc_root_class)) static void nonClassDeclaration() // expected-error {{attribute may only be applied to an Objective-C interface}}
+{
+}
diff --git a/clang/test/SemaObjC/autoreleasepool.m b/clang/test/SemaObjC/autoreleasepool.m
new file mode 100644
index 0000000..45c749e
--- /dev/null
+++ b/clang/test/SemaObjC/autoreleasepool.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+void *objc_autoreleasepool_push();
+void autoreleasepool_pop(void*);
+
+@interface AUTORP @end
+
+@implementation AUTORP
+- (void) unregisterTask:(id) task {
+ goto L; // expected-error {{goto into protected scope}}
+
+ @autoreleasepool { // expected-note {{jump bypasses auto release push of @autoreleasepool block}}
+ void *tmp = objc_autoreleasepool_push();
+ L:
+ autoreleasepool_pop(tmp);
+ @autoreleasepool {
+ return;
+ }
+ }
+}
+@end
+
diff --git a/clang/test/SemaObjC/bad-property-synthesis-crash.m b/clang/test/SemaObjC/bad-property-synthesis-crash.m
new file mode 100644
index 0000000..ea4e004
--- /dev/null
+++ b/clang/test/SemaObjC/bad-property-synthesis-crash.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://10177744
+
+@interface Foo
+@property (nonatomic, retain) NSString* what; // expected-error {{unknown type name 'NSString'}} \
+ // expected-error {{property with}} \
+ // expected-note {{previous definition is here}}
+@end
+
+@implementation Foo
+- (void) setWhat: (NSString*) value { // expected-error {{expected a type}} \
+ // expected-warning {{conflicting parameter types in implementation of}}
+ __what; // expected-error {{use of undeclared identifier}} \
+ // expected-warning {{expression result unused}}
+}
+@synthesize what; // expected-note 2 {{'what' declared here}}
+@end
+
+@implementation Bar // expected-warning {{cannot find interface declaration for}}
+- (NSString*) what { // expected-error {{expected a type}}
+ return __what; // expected-error {{use of undeclared identifier}}
+}
+@end
diff --git a/clang/test/SemaObjC/bad-receiver-1.m b/clang/test/SemaObjC/bad-receiver-1.m
new file mode 100644
index 0000000..fe3eecf
--- /dev/null
+++ b/clang/test/SemaObjC/bad-receiver-1.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface I
+- (id) retain;
+@end
+
+int objc_lookUpClass(const char*);
+
+void __raiseExc1() {
+ [objc_lookUpClass("NSString") retain]; // expected-warning {{receiver type 'int' is not 'id'}} \
+ expected-warning {{method '-retain' not found}}
+}
+
+typedef const struct __CFString * CFStringRef;
+
+void func() {
+ CFStringRef obj;
+
+ [obj self]; // expected-warning {{receiver type 'CFStringRef' (aka 'const struct __CFString *') is not 'id'}} \\
+ expected-warning {{method '-self' not found}}
+}
diff --git a/clang/test/SemaObjC/block-as-object.m b/clang/test/SemaObjC/block-as-object.m
new file mode 100644
index 0000000..a85b606
--- /dev/null
+++ b/clang/test/SemaObjC/block-as-object.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks
+
+@interface Whatever
+- copy;
+@end
+
+typedef long (^MyBlock)(id obj1, id obj2);
+
+void foo(MyBlock b) {
+ id bar = [b copy];
+}
+
+void foo2(id b) {
+}
+
+void foo3(void (^block)(void)) {
+ foo2(block);
+ id x;
+ foo(x);
+}
diff --git a/clang/test/SemaObjC/block-attr.m b/clang/test/SemaObjC/block-attr.m
new file mode 100644
index 0000000..80092fc
--- /dev/null
+++ b/clang/test/SemaObjC/block-attr.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks -fobjc-gc-only %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks -fobjc-gc-only %s
+
+@interface Thing {}
+
+@property void(^someBlock)(void); // expected-warning {{'copy' attribute must be specified for the block property}}
+@property(copy) void(^OK)(void);
+
+// rdar://8820813
+@property (readonly) void (^block)(void); // readonly property is OK
+
+@end
diff --git a/clang/test/SemaObjC/block-explicit-return-type.m b/clang/test/SemaObjC/block-explicit-return-type.m
new file mode 100644
index 0000000..22e5b6f
--- /dev/null
+++ b/clang/test/SemaObjC/block-explicit-return-type.m
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
+// FIXME: should compile
+// Test for blocks with explicit return type specified.
+
+typedef float * PF;
+float gf;
+
+@interface NSView
+ - (id) some_method_that_returns_id;
+@end
+
+NSView *some_object;
+
+void some_func (NSView * (^) (id));
+
+typedef struct dispatch_item_s *dispatch_item_t;
+typedef void (^completion_block_t)(void);
+
+typedef double (^myblock)(int);
+double test(myblock I);
+
+int main() {
+ __block int x = 1;
+ __block int y = 2;
+
+ (void)^void *{ return 0; };
+
+ (void)^float(float y){ return y; };
+
+ (void)^double (float y, double d) {
+ if (y)
+ return d;
+ else
+ return y;
+ };
+
+ const char * (^chb) (int flag, const char *arg, char *arg1) = ^ const char * (int flag, const char *arg, char *arg1) {
+ if (flag)
+ return 0;
+ if (flag == 1)
+ return arg;
+ else if (flag == 2)
+ return "";
+ return arg1;
+ };
+
+ (void)^PF { return &gf; };
+
+ some_func(^ NSView * (id whatever) { return [some_object some_method_that_returns_id]; });
+
+ double res = test(^(int z){x = y+z; return (double)z; });
+}
+
+void func() {
+ completion_block_t X;
+
+ completion_block_t (^blockx)(dispatch_item_t) = ^completion_block_t (dispatch_item_t item) {
+ return X;
+ };
+
+ completion_block_t (^blocky)(dispatch_item_t) = ^(dispatch_item_t item) {
+ return X;
+ };
+
+ blockx = blocky;
+}
+
+
+// intent: block taking int returning block that takes char,int and returns int
+int (^(^block)(double x))(char, short);
+
+void foo() {
+ int one = 1;
+ block = ^(double x){ return ^(char c, short y) { return one + c + y; };}; // expected-error {{returning block that lives on the local stack}}
+ // or:
+ block = ^(double x){ return ^(char c, short y) { return one + (int)c + y; };}; // expected-error {{returning block that lives on the local stack}}
+}
diff --git a/clang/test/SemaObjC/block-id-as-block-argtype.m b/clang/test/SemaObjC/block-id-as-block-argtype.m
new file mode 100644
index 0000000..20bb6ad
--- /dev/null
+++ b/clang/test/SemaObjC/block-id-as-block-argtype.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks
+// rdar://10734265
+
+@class NSObject;
+typedef void (^block1_t)(int arg);
+typedef void (^block2_t)(block1_t arg);
+typedef void (^block3_t)(NSObject *arg);
+typedef void (^block4_t)(id arg);
+
+void fn(block4_t arg); // expected-note {{passing argument to parameter 'arg' here}}
+
+void another_fn(block2_t arg);
+
+int main() {
+ block1_t b1;
+ block2_t b2;
+ block3_t b3;
+ block3_t b4;
+ block4_t b5;
+
+ fn(b1); // expected-error {{incompatible block pointer types passing 'block1_t' (aka 'void (^)(int)') to parameter of type 'block4_t' (aka 'void (^)(id)')}}
+ fn(b2); // must succeed: block1_t *is* compatible with id
+ fn(b3); // succeeds: NSObject* compatible with id
+ fn(b4); // succeeds: id compatible with id
+
+ another_fn(b5);
+}
diff --git a/clang/test/SemaObjC/block-ivar.m b/clang/test/SemaObjC/block-ivar.m
new file mode 100644
index 0000000..c7ea1d9
--- /dev/null
+++ b/clang/test/SemaObjC/block-ivar.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks
+
+@interface NSObject {
+ struct objc_object *isa;
+}
+@end
+@interface Foo : NSObject {
+ int _prop;
+}
+@end
+
+@implementation Foo
+- (int)doSomething {
+ int (^blk)(void) = ^{ return _prop; };
+ return blk();
+}
+
+@end
+
diff --git a/clang/test/SemaObjC/block-on-method-param.m b/clang/test/SemaObjC/block-on-method-param.m
new file mode 100644
index 0000000..d5cbc8a
--- /dev/null
+++ b/clang/test/SemaObjC/block-on-method-param.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
+
+// rdar://10681443
+@interface I
+- (void) compileSandboxProfileAndReturnError:(__attribute__((__blocks__(byref))) id)errorp; // expected-error {{__block attribute not allowed, only allowed on local variables}}
+@end
+
+@implementation I
+- (void) compileSandboxProfileAndReturnError:(__attribute__((__blocks__(byref))) id)errorp {} // expected-error {{__block attribute not allowed, only allowed on local variables}}
+@end
+
diff --git a/clang/test/SemaObjC/block-return.m b/clang/test/SemaObjC/block-return.m
new file mode 100644
index 0000000..15c3fb6
--- /dev/null
+++ b/clang/test/SemaObjC/block-return.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks -fobjc-gc-only %s
+// rdar://8979379
+
+@interface NSString
+- (__attribute__((objc_gc(strong))) const char *)UTF8String;
+@end
+
+int main() {
+__attribute__((objc_gc(strong))) char const *(^libraryNameForIndex)() = ^() {
+ NSString *moduleName;
+ return [moduleName UTF8String];
+ };
+}
diff --git a/clang/test/SemaObjC/block-type-safety.m b/clang/test/SemaObjC/block-type-safety.m
new file mode 100644
index 0000000..56342ba
--- /dev/null
+++ b/clang/test/SemaObjC/block-type-safety.m
@@ -0,0 +1,157 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
+// test for block type safety.
+
+@interface Super @end
+@interface Sub : Super @end
+
+void f2(void(^f)(Super *)) { // expected-note{{passing argument to parameter 'f' here}}
+ Super *o;
+ f(o);
+}
+
+void f3(void(^f)(Sub *)) {
+ Sub *o;
+ f(o);
+}
+
+void r0(Super* (^f)()) {
+ Super *o = f();
+}
+
+void r1(Sub* (^f)()) { // expected-note{{passing argument to parameter 'f' here}}
+ Sub *o = f();
+}
+
+@protocol NSObject;
+
+void r2 (id<NSObject> (^f) (void)) {
+ id o = f();
+}
+
+void test1() {
+ f2(^(Sub *o) { }); // expected-error {{incompatible block pointer types passing}}
+ f3(^(Super *o) { }); // OK, block taking Super* may be called with a Sub*
+
+ r0(^Super* () { return 0; }); // OK
+ r0(^Sub* () { return 0; }); // OK, variable of type Super* gets return value of type Sub*
+ r0(^id () { return 0; });
+
+ r1(^Super* () { return 0; }); // expected-error {{incompatible block pointer types passing}}
+ r1(^Sub* () { return 0; }); // OK
+ r1(^id () { return 0; });
+
+ r2(^id<NSObject>() { return 0; });
+}
+
+
+@interface A @end
+@interface B @end
+
+void f0(void (^f)(A* x)) {
+ A* a;
+ f(a);
+}
+
+void f1(void (^f)(id x)) {
+ B *b;
+ f(b);
+}
+
+void test2(void)
+{
+ f0(^(id a) { }); // OK
+ f1(^(A* a) { });
+ f1(^(id<NSObject> a) { }); // OK
+}
+
+@interface NSArray
+ // Calls block() with every object in the array
+ -enumerateObjectsWithBlock:(void (^)(id obj))block;
+@end
+
+@interface MyThing
+-(void) printThing;
+@end
+
+@implementation MyThing
+ static NSArray* myThings; // array of MyThing*
+
+ -(void) printThing { }
+
+// programmer wants to write this:
+ -printMyThings1 {
+ [myThings enumerateObjectsWithBlock: ^(MyThing *obj) {
+ [obj printThing];
+ }];
+ }
+
+// strict type safety requires this:
+ -printMyThings {
+ [myThings enumerateObjectsWithBlock: ^(id obj) {
+ MyThing *obj2 = (MyThing *)obj;
+ [obj2 printThing];
+ }];
+ }
+@end
+
+@protocol P, P2;
+void f4(void (^f)(id<P> x)) { // expected-note{{passing argument to parameter 'f' here}}
+ NSArray<P2> *b;
+ f(b); // expected-warning {{passing 'NSArray<P2> *' to parameter of incompatible type 'id<P>'}}
+}
+
+void test3() {
+ f4(^(NSArray<P2>* a) { }); // expected-error {{incompatible block pointer types passing 'void (^)(NSArray<P2> *)' to parameter of type 'void (^)(id<P>)'}}
+}
+
+// rdar : //8302845
+@protocol Foo @end
+
+@interface Baz @end
+
+@interface Baz(FooConformance) <Foo>
+@end
+
+@implementation Baz @end
+
+int test4 () {
+ id <Foo> (^b)() = ^{ // Doesn't work
+ return (Baz *)0;
+ };
+ return 0;
+}
+
+// rdar:// 9118343
+
+@protocol NSCopying @end
+
+@interface NSAllArray <NSCopying>
+@end
+
+@interface NSAllArray (FooConformance) <Foo>
+@end
+
+int test5() {
+ NSAllArray *(^block)(id);
+ id <Foo> (^genericBlock)(id);
+ genericBlock = block;
+ return 0;
+}
+
+// rdar://10798770
+typedef int NSInteger;
+
+typedef enum : NSInteger {NSOrderedAscending = -1L, NSOrderedSame, NSOrderedDescending} NSComparisonResult;
+
+typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
+
+@interface radar10798770
+- (void)sortUsingComparator:(NSComparator)c;
+@end
+
+void f() {
+ radar10798770 *f;
+ [f sortUsingComparator:^(id a, id b) {
+ return NSOrderedSame;
+ }];
+}
diff --git a/clang/test/SemaObjC/blocks.m b/clang/test/SemaObjC/blocks.m
new file mode 100644
index 0000000..7beec19
--- /dev/null
+++ b/clang/test/SemaObjC/blocks.m
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
+
+#define bool _Bool
+@protocol NSObject;
+
+void bar(id(^)(void));
+void foo(id <NSObject>(^objectCreationBlock)(void)) {
+ return bar(objectCreationBlock);
+}
+
+void bar2(id(*)(void));
+void foo2(id <NSObject>(*objectCreationBlock)(void)) {
+ return bar2(objectCreationBlock);
+}
+
+void bar3(id(*)());
+void foo3(id (*objectCreationBlock)(int)) {
+ return bar3(objectCreationBlock);
+}
+
+void bar4(id(^)());
+void foo4(id (^objectCreationBlock)(int)) {
+ return bar4(objectCreationBlock);
+}
+
+void bar5(id(^)(void)); // expected-note 3{{passing argument to parameter here}}
+void foo5(id (^objectCreationBlock)(bool)) {
+ bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(bool)' to parameter of type 'id (^)(void)'}}
+#undef bool
+ bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(_Bool)' to parameter of type 'id (^)(void)'}}
+#define bool int
+ bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(_Bool)' to parameter of type 'id (^)(void)'}}
+}
+
+void bar6(id(^)(int));
+void foo6(id (^objectCreationBlock)()) {
+ return bar6(objectCreationBlock);
+}
+
+void foo7(id (^x)(int)) {
+ if (x) { }
+}
+
+@interface itf
+@end
+
+void foo8() {
+ void *P = ^(itf x) {}; // expected-error {{interface type 'itf' cannot be passed by value; did you forget * in 'itf'}}
+ P = ^itf(int x) {}; // expected-error {{interface type 'itf' cannot be returned by value; did you forget * in 'itf'}}
+ P = ^itf() {}; // expected-error {{interface type 'itf' cannot be returned by value; did you forget * in 'itf'}}
+ P = ^itf{}; // expected-error {{interface type 'itf' cannot be returned by value; did you forget * in 'itf'}}
+}
+
+
+int foo9() {
+ typedef void (^DVTOperationGroupScheduler)();
+ id _suboperationSchedulers;
+
+ for (DVTOperationGroupScheduler scheduler in _suboperationSchedulers) {
+ ;
+ }
+
+}
+
+// rdar 7725203
+@class NSString;
+
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+
+void foo10() {
+ void(^myBlock)(void) = ^{
+ };
+ NSLog(@"%@", myBlock);
+}
+
diff --git a/clang/test/SemaObjC/builtin_objc_assign_ivar.m b/clang/test/SemaObjC/builtin_objc_assign_ivar.m
new file mode 100644
index 0000000..5839bf4
--- /dev/null
+++ b/clang/test/SemaObjC/builtin_objc_assign_ivar.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -x objective-c %s -fsyntax-only -verify
+// rdar://9362887
+
+typedef __typeof__(((int*)0)-((int*)0)) ptrdiff_t;
+extern id objc_assign_ivar(id value, id dest, ptrdiff_t offset);
+
diff --git a/clang/test/SemaObjC/builtin_objc_lib_functions.m b/clang/test/SemaObjC/builtin_objc_lib_functions.m
new file mode 100644
index 0000000..956ee12
--- /dev/null
+++ b/clang/test/SemaObjC/builtin_objc_lib_functions.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -x objective-c %s -fsyntax-only -verify
+// rdar://8592641
+Class f0() { return objc_getClass("a"); } // expected-warning {{implicitly declaring library function 'objc_getClass' with type 'id (const char *)'}} \
+ // expected-note {{please include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_getClass'}}
+
+// rdar://8735023
+Class f1() { return objc_getMetaClass("a"); } // expected-warning {{implicitly declaring library function 'objc_getMetaClass' with type 'id (const char *)'}} \
+ // expected-note {{please include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_getMetaClass'}}
+
+void f2(id val) { objc_enumerationMutation(val); } // expected-warning {{implicitly declaring library function 'objc_enumerationMutation' with type 'void (id)'}} \
+ // expected-note {{please include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_enumerationMutation'}}
+
+long double f3(id self, SEL op) { return objc_msgSend_fpret(self, op); } // expected-warning {{implicitly declaring library function 'objc_msgSend_fpret' with type 'long double (id, SEL, ...)'}} \
+ // expected-note {{please include the header <objc/message.h> or explicitly provide a declaration for 'objc_msgSend_fpret'}}
+
+id f4(struct objc_super *super, SEL op) { // expected-warning {{declaration of 'struct objc_super' will not be visible outside of this function}}
+ return objc_msgSendSuper(super, op); // expected-warning {{implicitly declaring library function 'objc_msgSendSuper' with type 'id (void *, SEL, ...)'}} \
+ // expected-note {{please include the header <objc/message.h> or explicitly provide a declaration for 'objc_msgSendSuper'}}
+}
+
+id f5(id val, id *dest) {
+ return objc_assign_strongCast(val, dest); // expected-warning {{implicitly declaring library function 'objc_assign_strongCast' with type 'id (id, id *)'}} \
+ // expected-note {{please include the header <objc/objc-auto.h> or explicitly provide a declaration for 'objc_assign_strongCast'}}
+}
+
+int f6(Class exceptionClass, id exception) {
+ return objc_exception_match(exceptionClass, exception); // expected-warning {{implicitly declaring library function 'objc_exception_match' with type 'int (id, id)'}} \
+ // expected-note {{please include the header <objc/objc-exception.h> or explicitly provide a declaration for 'objc_exception_match'}}
+}
diff --git a/clang/test/SemaObjC/builtin_objc_msgSend.m b/clang/test/SemaObjC/builtin_objc_msgSend.m
new file mode 100644
index 0000000..bf17225
--- /dev/null
+++ b/clang/test/SemaObjC/builtin_objc_msgSend.m
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// rdar://8632525
+extern id objc_msgSend(id self, SEL op, ...);
diff --git a/clang/test/SemaObjC/builtin_objc_nslog.m b/clang/test/SemaObjC/builtin_objc_nslog.m
new file mode 100644
index 0000000..c940b16
--- /dev/null
+++ b/clang/test/SemaObjC/builtin_objc_nslog.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x objective-c %s -fsyntax-only -verify
+
+#include <stdarg.h>
+
+void f1(id arg) {
+ NSLog(@"%@", arg); // expected-warning {{implicitly declaring library function 'NSLog' with type 'void (id, ...)'}} \
+ // expected-note {{please include the header <Foundation/NSObjCRuntime.h> or explicitly provide a declaration for 'NSLog'}}
+}
+
+void f2(id str, va_list args) {
+ NSLogv(@"%@", args); // expected-warning {{implicitly declaring library function 'NSLogv' with type }} \
+ // expected-note {{please include the header <Foundation/NSObjCRuntime.h> or explicitly provide a declaration for 'NSLogv'}}
+}
diff --git a/clang/test/SemaObjC/call-super-2.m b/clang/test/SemaObjC/call-super-2.m
new file mode 100644
index 0000000..3c45a2c
--- /dev/null
+++ b/clang/test/SemaObjC/call-super-2.m
@@ -0,0 +1,108 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include <stddef.h>
+
+typedef struct objc_object *id;
+id objc_getClass(const char *s);
+
+@interface Object
+- (id) initWithInt: (int) i;
+@end
+
+@protocol Func
++ (int) class_func0;
+- (int) instance_func0;
+@end
+
+@interface Derived: Object
++ (int) class_func1;
++ (int) class_func2;
++ (int) class_func3;
++ (int) class_func4;
++ (int) class_func5;
++ (int) class_func6;
++ (int) class_func7;
+- (int) instance_func1;
+- (int) instance_func2;
+- (int) instance_func3;
+- (int) instance_func4;
+- (int) instance_func5;
+- (int) instance_func6;
+- (int) instance_func7;
+- (id) initWithInt: (int) i;
+@end
+
+@implementation Derived
++ (int) class_func1
+{
+ int i = (size_t)[self class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}
+ return i + (size_t)[super class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}
+}
++ (int) class_func2
+{
+ int i = [(id <Func>)self class_func0];
+ i += [(id <Func>)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
+ i += [(Class <Func>)self class_func0]; //
+ return i + [(Class <Func>)super class_func0]; // // expected-error {{cannot cast 'super' (it isn't an expression)}}
+}
++ (int) class_func3
+{
+ return [(Object <Func> *)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
+}
++ (int) class_func4
+{
+ return [(Derived <Func> *)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
+}
++ (int) class_func5
+{
+ int i = (size_t)[Derived class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}
+ return i + (size_t)[Object class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}
+}
++ (int) class_func6
+{
+ return (size_t)[objc_getClass("Object") class_func1]; // GCC warns about this
+}
++ (int) class_func7
+{
+ return [objc_getClass("Derived") class_func1];
+}
+- (int) instance_func1
+{
+ int i = (size_t)[self instance_func0]; // expected-warning {{instance method '-instance_func0' not found (return type defaults to 'id')}}
+ return i + (size_t)[super instance_func0]; // expected-warning {{'Object' may not respond to 'instance_func0'}}
+}
+- (int) instance_func2
+{
+ return [(id <Func>)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
+}
+- (int) instance_func3
+{
+ return [(Object <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
+}
+- (int) instance_func4
+{
+ return [(Derived <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
+}
+- (int) instance_func5
+{
+ int i = (size_t)[Derived instance_func1]; // expected-warning {{class method '+instance_func1' not found (return type defaults to 'id')}}
+ return i + (size_t)[Object instance_func1]; // expected-warning {{class method '+instance_func1' not found (return type defaults to 'id')}}
+}
+- (int) instance_func6
+{
+ return (size_t)[objc_getClass("Object") class_func1];
+}
+- (int) instance_func7
+{
+ return [objc_getClass("Derived") class_func1];
+}
+- (id) initWithInt: (int) i
+{
+ // Don't warn about parentheses here.
+ if (self = [super initWithInt: i]) {
+ [self instance_func1];
+ }
+ return self;
+}
+@end
+
diff --git a/clang/test/SemaObjC/catch-stmt.m b/clang/test/SemaObjC/catch-stmt.m
new file mode 100644
index 0000000..dcb4764
--- /dev/null
+++ b/clang/test/SemaObjC/catch-stmt.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -verify -fobjc-exceptions %s
+@interface A @end
+@protocol P;
+
+void f() {
+ @try {
+ } @catch (void a) { // expected-error{{@catch parameter is not a pointer to an interface type}}
+ } @catch (int) { // expected-error{{@catch parameter is not a pointer to an interface type}}
+ } @catch (int *b) { // expected-error{{@catch parameter is not a pointer to an interface type}}
+ } @catch (id <P> c) { // expected-error{{illegal qualifiers on @catch parameter}}
+ } @catch(A* a) { }
+}
+
diff --git a/clang/test/SemaObjC/category-1.m b/clang/test/SemaObjC/category-1.m
new file mode 100644
index 0000000..f842278
--- /dev/null
+++ b/clang/test/SemaObjC/category-1.m
@@ -0,0 +1,101 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface MyClass1 @end
+
+@protocol p1,p2,p3;
+
+@interface MyClass1 (Category1) <p1> // expected-warning {{cannot find protocol definition for 'p1'}} expected-note {{previous definition is here}}
+@end
+
+@interface MyClass1 (Category1) // expected-warning {{duplicate definition of category 'Category1' on interface 'MyClass1'}}
+@end
+
+@interface MyClass1 (Category3)
+@end
+
+@interface MyClass1 (Category4) @end // expected-note {{previous definition is here}}
+@interface MyClass1 (Category5) @end
+@interface MyClass1 (Category6) @end
+@interface MyClass1 (Category7) @end // expected-note {{previous definition is here}}
+@interface MyClass1 (Category8) @end // expected-note {{previous definition is here}}
+
+
+@interface MyClass1 (Category4) @end // expected-warning {{duplicate definition of category 'Category4' on interface 'MyClass1'}}
+@interface MyClass1 (Category7) @end // expected-warning {{duplicate definition of category 'Category7' on interface 'MyClass1'}}
+@interface MyClass1 (Category8) @end // expected-warning {{duplicate definition of category 'Category8' on interface 'MyClass1'}}
+
+
+@protocol p3 @end
+
+@interface MyClass1 (Category) <p2, p3> @end // expected-warning {{cannot find protocol definition for 'p2'}}
+
+@interface UnknownClass (Category) @end // expected-error {{cannot find interface declaration for 'UnknownClass'}}
+
+@class MyClass2; // expected-note{{forward declaration of class here}}
+
+@interface MyClass2 (Category) @end // expected-error {{cannot define category for undefined class 'MyClass2'}}
+
+@interface XCRemoteComputerManager
+@end
+
+@interface XCRemoteComputerManager()
+@end
+
+@interface XCRemoteComputerManager()
+@end
+
+@interface XCRemoteComputerManager(x) // expected-note {{previous definition is here}}
+@end
+
+@interface XCRemoteComputerManager(x) // expected-warning {{duplicate definition of category 'x' on interface 'XCRemoteComputerManager'}}
+@end
+
+@implementation XCRemoteComputerManager
+@end
+
+@implementation XCRemoteComputerManager(x) // expected-note {{previous definition is here}}
+@end
+
+@implementation XCRemoteComputerManager(x) // expected-error {{reimplementation of category 'x' for class 'XCRemoteComputerManager'}}
+@end
+
+// <rdar://problem/7249233>
+
+@protocol MultipleCat_P
+-(void) im0; // expected-note {{method 'im0' declared here}}
+@end
+
+@interface MultipleCat_I @end // expected-note {{required for direct or indirect protocol 'MultipleCat_P'}}
+
+@interface MultipleCat_I() @end
+
+@interface MultipleCat_I() <MultipleCat_P> @end
+
+@implementation MultipleCat_I // expected-warning {{incomplete implementation}} \
+ // expected-warning {{method 'im0' in protocol not implemented}}
+@end
+
+// <rdar://problem/7680391> - Handle nameless categories with no name that refer
+// to an undefined class
+@interface RDar7680391 () @end // expected-error{{cannot find interface declaration}}
+
+// <rdar://problem/8891119> - Handle @synthesize being used in conjunction
+// with explicitly declared accessor.
+@interface RDar8891119 {
+ id _name;
+}
+@end
+@interface RDar8891119 ()
+- (id)name;
+@end
+@interface RDar8891119 ()
+@property (copy) id name;
+@end
+@implementation RDar8891119
+@synthesize name = _name;
+@end
+
+// rdar://10968158
+@class I; // expected-note {{forward declaration}}
+@implementation I(cat) // expected-error{{cannot find interface declaration}}
+@end
diff --git a/clang/test/SemaObjC/category-method-lookup-2.m b/clang/test/SemaObjC/category-method-lookup-2.m
new file mode 100644
index 0000000..a31d824
--- /dev/null
+++ b/clang/test/SemaObjC/category-method-lookup-2.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef struct objc_class *Class;
+@interface NSObject
+- (Class)class;
+@end
+@interface Bar : NSObject
+@end
+@interface Bar (Cat)
+@end
+
+// NOTE: No class implementation for Bar precedes this category definition.
+@implementation Bar (Cat)
+
+// private method.
++ classMethod { return self; }
+
+- instanceMethod {
+ [[self class] classMethod];
+ return 0;
+}
+
+@end
diff --git a/clang/test/SemaObjC/category-method-lookup.m b/clang/test/SemaObjC/category-method-lookup.m
new file mode 100644
index 0000000..4223a74
--- /dev/null
+++ b/clang/test/SemaObjC/category-method-lookup.m
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface Foo
+@end
+@implementation Foo
+@end
+
+@implementation Foo(Whatever)
++(float)returnsFloat { return 7.0; }
+@end
+
+@interface Foo (MoreStuff)
++(int)returnsInt;
+@end
+
+@implementation Foo (MoreStuff)
++(int)returnsInt {
+ return 0;
+}
+
++(void)returnsNothing {
+}
+-(int)callsReturnsInt {
+ float f = [Foo returnsFloat]; // GCC doesn't find this method (which is a bug IMHO).
+ [Foo returnsNothing];
+ return [Foo returnsInt];
+}
+@end
+
+int main() {return 0;}
+
diff --git a/clang/test/SemaObjC/check-dup-decl-methods-1.m b/clang/test/SemaObjC/check-dup-decl-methods-1.m
new file mode 100644
index 0000000..3895667
--- /dev/null
+++ b/clang/test/SemaObjC/check-dup-decl-methods-1.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -Wduplicate-method-match -fsyntax-only -verify %s
+
+@interface SUPER
+- (int) meth;
++ (int) foobar;
+@end
+
+@interface T @end
+
+@interface class1 : SUPER
+- (int) meth; // expected-note {{previous declaration is here}}
+- (int*) meth; // expected-error {{duplicate declaration of method 'meth'}}
+- (T*) meth1; // expected-note {{previous declaration is here}}
+- (T*) meth1; // expected-warning {{multiple declarations of method 'meth1' found and ignored}}
++ (T*) meth1;
+@end
+
+@interface class1(cat)
+- (int) catm : (char)ch1; // expected-note {{previous declaration is here}}
+- (int) catm1 : (char)ch : (int)i;
+- (int) catm : (char*)ch1; // expected-error {{duplicate declaration of method 'catm:'}}
++ (int) catm1 : (char)ch : (int)i;
++ (T*) meth1;
+@end
+
+@interface class1(cat1)
++ (int) catm1 : (char)ch : (int)i; // expected-note {{previous declaration is here}}
++ (T*) meth1; // expected-note {{previous declaration is here}}
++ (int) catm1 : (char)ch : (int*)i; // expected-error {{duplicate declaration of method 'catm1::'}}
++ (T**) meth1; // expected-error {{duplicate declaration of method 'meth1'}}
++ (int) foobar;
+@end
+
+@protocol P
+- (int) meth; // expected-note {{previous declaration is here}}
+- (int*) meth; // expected-error {{duplicate declaration of method 'meth'}}
+@end
+
diff --git a/clang/test/SemaObjC/check-dup-objc-decls-1.m b/clang/test/SemaObjC/check-dup-objc-decls-1.m
new file mode 100644
index 0000000..d6fa53a
--- /dev/null
+++ b/clang/test/SemaObjC/check-dup-objc-decls-1.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface Foo // expected-note {{previous definition is here}}
+@end
+
+float Foo; // expected-error {{redefinition of 'Foo' as different kind of symbol}}
+
+@class Bar; // expected-note {{previous definition is here}}
+
+typedef int Bar; // expected-error {{redefinition of 'Bar' as different kind of symbol}}
+
+@implementation FooBar // expected-warning {{cannot find interface declaration for 'FooBar'}}
+@end
+
+
+typedef int OBJECT; // expected-note {{previous definition is here}}
+
+@class OBJECT ; // expected-error {{redefinition of 'OBJECT' as different kind of symbol}}
+
+
+typedef int Gorf; // expected-note {{previous definition is here}}
+
+@interface Gorf @end // expected-error {{redefinition of 'Gorf' as different kind of symbol}} expected-note {{previous definition is here}}
+
+void Gorf() // expected-error {{redefinition of 'Gorf' as different kind of symbol}}
+{
+ int Bar, Foo, FooBar;
+}
+
+@protocol P -im1; @end
+@protocol Q -im2; @end
+@interface A<P> @end // expected-note {{previous definition is here}}
+@interface A<Q> @end // expected-error {{duplicate interface definition for class 'A'}}
+
+@protocol PP<P> @end // expected-note {{previous definition is here}}
+@protocol PP<Q> @end // expected-warning {{duplicate protocol definition of 'PP'}}
+
+@interface A(Cat)<P> @end // expected-note {{previous definition is here}}
+@interface A(Cat)<Q> @end // expected-warning {{duplicate definition of category 'Cat' on interface 'A'}}
+
+// rdar 7626768
+@class NSString;
+NSString * TestBaz; // expected-note {{previous definition is here}}
+NSString * const TestBaz; // expected-error {{redefinition of 'TestBaz' with a different type}}
diff --git a/clang/test/SemaObjC/class-bitfield.m b/clang/test/SemaObjC/class-bitfield.m
new file mode 100644
index 0000000..ae12e04
--- /dev/null
+++ b/clang/test/SemaObjC/class-bitfield.m
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 %s -fobjc-fragile-abi -fsyntax-only -verify
+
+@interface X
+{
+ int a : -1; // expected-error{{bit-field 'a' has negative width}}
+
+ // rdar://6081627
+ int b : 33; // expected-error{{size of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}}
+
+ int c : (1 + 0.25); // expected-error{{expression is not an integer constant expression}}
+ int d : (int)(1 + 0.25);
+
+ // rdar://6138816
+ int e : 0; // expected-error {{bit-field 'e' has zero width}}
+}
+@end
+
+@interface Base {
+ int i;
+}
+@end
+
+@interface WithBitFields: Base {
+ void *isa; // expected-note {{previous definition is here}}
+ unsigned a: 5;
+ signed b: 4;
+ int c: 5; // expected-note {{previous definition is here}}
+}
+@end
+
+@implementation WithBitFields {
+ char *isa; // expected-error {{instance variable 'isa' has conflicting type: 'char *' vs 'void *'}}
+ unsigned a: 5;
+ signed b: 4;
+ int c: 3; // expected-error {{instance variable 'c' has conflicting bit-field width}}
+}
+@end
diff --git a/clang/test/SemaObjC/class-conforming-protocol-1.m b/clang/test/SemaObjC/class-conforming-protocol-1.m
new file mode 100644
index 0000000..115ddd2
--- /dev/null
+++ b/clang/test/SemaObjC/class-conforming-protocol-1.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -Wduplicate-method-match -fsyntax-only -verify %s
+
+@protocol P1 @end
+@protocol P2 @end
+@protocol P3 @end
+
+@interface INTF
+- (INTF*) METH1; // expected-note {{previous declaration is here}}
+- (INTF<P1>*) METH1; // expected-error {{duplicate declaration of method 'METH1'}}
+
+- (INTF<P2,P1>*) METH2; // expected-note {{previous declaration is here}}
+- (INTF<P2,P1,P3>*) METH2; // expected-error {{duplicate declaration of method 'METH2'}}
+
+- (INTF<P2,P1,P3>*) METH3; // expected-note {{previous declaration is here}}
+- (INTF<P3,P1,P2, P3>*) METH3; // expected-warning {{multiple declarations of method 'METH3' found and ignored}}
+
+@end
+
+INTF<P2,P1,P3>* p1;
+
diff --git a/clang/test/SemaObjC/class-conforming-protocol-2.m b/clang/test/SemaObjC/class-conforming-protocol-2.m
new file mode 100644
index 0000000..a3bd0b1
--- /dev/null
+++ b/clang/test/SemaObjC/class-conforming-protocol-2.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify %s
+
+@protocol NSWindowDelegate @end
+
+@protocol IBStringsTableWindowDelegate <NSWindowDelegate>
+@end
+
+@interface NSWindow
+- (void)setDelegate:(id <NSWindowDelegate>)anObject; // expected-note {{previous definition is here}}
+- (id <IBStringsTableWindowDelegate>) delegate; // expected-note {{previous definition is here}}
+@end
+
+
+@interface IBStringsTableWindow : NSWindow {}
+@end
+
+@implementation IBStringsTableWindow
+- (void)setDelegate:(id <IBStringsTableWindowDelegate>)delegate { // expected-warning {{conflicting parameter types in implementation of 'setDelegate:'}}
+}
+- (id <NSWindowDelegate>)delegate { // expected-warning {{conflicting return type in implementation of 'delegate':}}
+ return 0;
+}
+@end
diff --git a/clang/test/SemaObjC/class-def-test-1.m b/clang/test/SemaObjC/class-def-test-1.m
new file mode 100644
index 0000000..0d114b9
--- /dev/null
+++ b/clang/test/SemaObjC/class-def-test-1.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol SUPER;
+
+@interface SUPER <SUPER> @end // expected-warning {{cannot find protocol definition for 'SUPER'}}
+
+typedef int INTF; // expected-note {{previous definition is here}}
+
+@interface INTF @end // expected-error {{redefinition of 'INTF' as different kind of symbol}}
+
+@interface OBJECT @end // expected-note {{previous definition is here}}
+
+@interface INTF1 : OBJECT @end // expected-note {{previous definition is here}}
+
+@interface INTF1 : OBJECT @end // expected-error {{duplicate interface definition for class 'INTF1'}}
+
+typedef int OBJECT; // expected-error {{redefinition of 'OBJECT' as different kind of symbol}}
+
+typedef int OBJECT2; // expected-note {{previous definition is here}}
+@interface INTF2 : OBJECT2 @end // expected-error {{redefinition of 'OBJECT2' as different kind of symbol}}
+
+
+@protocol PROTO;
+
+@interface INTF3 : PROTO @end // expected-error {{cannot find interface declaration for 'PROTO', superclass of 'INTF3'}}
+
+// Make sure we allow the following (for GCC compatibility).
+@interface NSObject @end
+typedef NSObject TD_NSObject;
+@interface XCElementUnit : TD_NSObject {}
+@end
+
+// Make sure we don't typo-correct to ourselves.
+@interface SomeClassSub : SomeClassSup // expected-error{{cannot find interface declaration for 'SomeClassSup', superclass of 'SomeClassSub'}}
+@end
diff --git a/clang/test/SemaObjC/class-extension-after-implementation.m b/clang/test/SemaObjC/class-extension-after-implementation.m
new file mode 100644
index 0000000..ccfd3ef
--- /dev/null
+++ b/clang/test/SemaObjC/class-extension-after-implementation.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://7822210
+
+@interface A @end
+
+@implementation A @end // expected-note {{class implementation is declared here}}
+
+@interface A () // expected-error {{cannot declare class extension for 'A' after class implementation}}
+-(void) im0;
+@end
+
diff --git a/clang/test/SemaObjC/class-extension-dup-methods.m b/clang/test/SemaObjC/class-extension-dup-methods.m
new file mode 100644
index 0000000..692ff8c
--- /dev/null
+++ b/clang/test/SemaObjC/class-extension-dup-methods.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface Foo
+- (int) garf; // expected-note {{previous declaration is here}}
+- (int) OK;
++ (int) cgarf; // expected-note {{previous declaration is here}}
+- (int) InstMeth;
+@end
+
+@interface Foo()
+- (void) garf; // expected-error {{duplicate declaration of method 'garf'}}
++ (void) cgarf; // expected-error {{duplicate declaration of method 'cgarf'}}
++ (int) InstMeth;
+- (int) OK;
+@end
diff --git a/clang/test/SemaObjC/class-getter-using-dotsyntax.m b/clang/test/SemaObjC/class-getter-using-dotsyntax.m
new file mode 100644
index 0000000..4ff9428
--- /dev/null
+++ b/clang/test/SemaObjC/class-getter-using-dotsyntax.m
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+typedef struct objc_class *Class;
+
+struct objc_class {
+ Class isa;
+};
+
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+@interface XCActivityLogSection
++ (unsigned)serializationFormatVersion;
++ (unsigned)sectionByDeserializingData;
++ (Class)retursClass;
+@end
+
+@implementation XCActivityLogSection
+
++ (unsigned)serializationFormatVersion
+{
+
+ return 0;
+}
++ (unsigned)sectionByDeserializingData {
+ unsigned version;
+ return self.serializationFormatVersion;
+}
+
++ (Class)retursClass {
+ Class version;
+ // FIXIT. (*version).isa does not work. Results in compiler error.
+ return version->isa;
+}
+
+@end
+
+
diff --git a/clang/test/SemaObjC/class-impl-1.m b/clang/test/SemaObjC/class-impl-1.m
new file mode 100644
index 0000000..68becaf
--- /dev/null
+++ b/clang/test/SemaObjC/class-impl-1.m
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+typedef int INTF3; // expected-note {{previous definition is here}}
+
+@interface SUPER @end // expected-note {{previous definition is here}}
+
+@interface OBJECT @end
+
+@interface INTF : OBJECT
+@end
+
+@implementation INTF @end // expected-note {{previous definition is here}}
+
+@implementation INTF // expected-error {{reimplementation of class 'INTF'}}
+@end
+
+
+@interface INTF1 : OBJECT
+@end
+
+@implementation INTF1 : SUPER // expected-error {{conflicting super class name 'SUPER'}}
+@end
+
+@interface INTF2
+@end
+
+@implementation INTF2 : SUPR // expected-error {{cannot find interface declaration for 'SUPR', superclass of 'INTF2'}}
+@end
+
+@implementation INTF3 @end // expected-error {{redefinition of 'INTF3' as different kind of symbol}}
+
+@implementation INTF4 @end // expected-warning {{cannot find interface declaration for 'INTF4'}}
+
+@class INTF5; // expected-note{{forward declaration of class here}}
+
+@implementation INTF5 { // expected-warning {{cannot find interface declaration for 'INTF5'}}
+ int x;
+}
+@end
+
diff --git a/clang/test/SemaObjC/class-message-protocol-lookup.m b/clang/test/SemaObjC/class-message-protocol-lookup.m
new file mode 100644
index 0000000..37df7a6
--- /dev/null
+++ b/clang/test/SemaObjC/class-message-protocol-lookup.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://9224670
+
+@interface RandomObject {
+@private
+}
++ (id)alloc;
+@end
+
+@protocol TestProtocol
+- (void)nothingInteresting;
+@end
+
+@protocol Test2Protocol
++ (id)alloc;
+- (id)alloc2; // expected-note 2 {{method 'alloc2' declared here}}
+@end
+
+@implementation RandomObject
+- (void) Meth {
+ Class<TestProtocol> c = [c alloc]; // expected-warning {{class method '+alloc' not found (return type defaults to 'id')}}
+ Class<Test2Protocol> c1 = [c1 alloc2]; // expected-warning {{instance method 'alloc2' found instead of class method 'alloc2'}}
+ Class<Test2Protocol> c2 = [c2 alloc]; // ok
+}
++ (id)alloc { return 0; }
+@end
+
+int main ()
+{
+ Class<TestProtocol> c = [c alloc]; // expected-warning {{class method '+alloc' not found (return type defaults to 'id')}}
+ Class<Test2Protocol> c1 = [c1 alloc2]; // expected-warning {{instance method 'alloc2' found instead of class method 'alloc2'}}
+ Class<Test2Protocol> c2 = [c2 alloc]; // ok
+ return 0;
+}
diff --git a/clang/test/SemaObjC/class-method-lookup.m b/clang/test/SemaObjC/class-method-lookup.m
new file mode 100644
index 0000000..8c8c216
--- /dev/null
+++ b/clang/test/SemaObjC/class-method-lookup.m
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface MyBase
+- (void) rootInstanceMethod;
+@end
+
+@interface MyIntermediate: MyBase
+@end
+
+@interface MyDerived: MyIntermediate
+- (void) instanceMethod;
++ (void) classMethod;
+@end
+
+@implementation MyDerived
+- (void) instanceMethod {
+}
+
++ (void) classMethod { /* If a class method is not found, the root */
+ [self rootInstanceMethod]; /* class is searched for an instance method */
+ [MyIntermediate rootInstanceMethod]; /* with the same name. */
+
+ [self instanceMethod];// expected-warning {{'+instanceMethod' not found (return type defaults to 'id')}}
+ [MyDerived instanceMethod];// expected-warning {{'+instanceMethod' not found (return type defaults to 'id')}}
+}
+@end
+
+@interface Object @end
+
+@interface Class1
+- (void)setWindow:(Object *)wdw;
+@end
+
+@interface Class2
+- (void)setWindow:(Class1 *)window;
+@end
+
+#define nil (void*)0
+
+id foo(void) {
+ Object *obj;
+ id obj2 = obj;
+ [obj setWindow:nil]; // expected-warning {{'Object' may not respond to 'setWindow:'}}
+
+ return obj;
+}
diff --git a/clang/test/SemaObjC/class-method-self.m b/clang/test/SemaObjC/class-method-self.m
new file mode 100644
index 0000000..b1e37bf
--- /dev/null
+++ b/clang/test/SemaObjC/class-method-self.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
+
+typedef struct objc_class *Class;
+@interface XX
+
+- (void)addObserver:(XX*)o; // expected-note 2{{passing argument to parameter 'o' here}}
+
+@end
+
+@interface YY
+
++ (void)classMethod;
+
+@end
+
+@implementation YY
+
+static XX *obj;
+
++ (void)classMethod {
+ [obj addObserver:self]; // expected-warning {{incompatible pointer types sending 'Class' to parameter of type 'XX *'}}
+ Class whatever;
+ [obj addObserver:whatever]; // expected-warning {{incompatible pointer types sending 'Class' to parameter of type 'XX *'}}
+}
+@end
+
diff --git a/clang/test/SemaObjC/class-property-access.m b/clang/test/SemaObjC/class-property-access.m
new file mode 100644
index 0000000..c46d3fb
--- /dev/null
+++ b/clang/test/SemaObjC/class-property-access.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface Test {}
++ (Test*)one;
+- (int)two;
+@end
+
+int main ()
+{
+ return Test.one.two;
+}
+
diff --git a/clang/test/SemaObjC/class-proto-1.m b/clang/test/SemaObjC/class-proto-1.m
new file mode 100644
index 0000000..02c40aa
--- /dev/null
+++ b/clang/test/SemaObjC/class-proto-1.m
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface INTF1 @end
+
+@protocol p1,p2,p3;
+
+@protocol p1;
+
+@protocol PROTO1
+- (INTF1<p1>*) meth;
+@end
+
+@protocol p1 @end
+
+@interface I1 <p1> @end
+
+@interface E1 <p2> @end // expected-warning {{cannot find protocol definition for 'p2'}}
+
+@protocol p2 @end
+
+
+@interface I2 <p1,p2> @end
+
+@interface E2 <p1,p2,p3> @end // expected-warning {{cannot find protocol definition for 'p3'}}
+
+@class U1, U2; // expected-note {{forward declaration of class here}}
+
+@interface E3 : U1 @end // expected-error {{attempting to use the forward class 'U1' as superclass of 'E3'}}
+
+
+@interface I3 : E3 @end
+
+@interface U2 @end
+
+@interface I4 : U2 <p1,p2>
+@end
diff --git a/clang/test/SemaObjC/class-protocol-method-match.m b/clang/test/SemaObjC/class-protocol-method-match.m
new file mode 100644
index 0000000..7c936e6
--- /dev/null
+++ b/clang/test/SemaObjC/class-protocol-method-match.m
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -Woverriding-method-mismatch -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://9352731
+
+@protocol Bar
+@required
+- (bycopy id)bud; // expected-note {{previous declaration is here}}
+- (unsigned char) baz; // expected-note {{previous declaration is here}}
+- (char) ok;
+- (void) also_ok;
+@end
+
+@protocol Bar1
+@required
+- (unsigned char) baz; // expected-note {{previous declaration is here}}
+- (unsigned char) also_ok; // expected-note {{previous declaration is here}}
+- (void) ban : (int) arg, ...; // expected-note {{previous declaration is here}}
+@end
+
+@protocol Baz <Bar, Bar1>
+- (void) bar : (unsigned char)arg; // expected-note {{previous declaration is here}}
+- (void) ok;
+- (char) bak; // expected-note {{previous declaration is here}}
+@end
+
+@interface Foo <Baz>
+- (id)bud; // expected-warning {{conflicting distributed object modifiers on return type in declaration of 'bud'}}
+- (void) baz; // expected-warning 2 {{conflicting return type in declaration of 'baz': 'unsigned char' vs 'void'}}
+- (void) bar : (unsigned char*)arg; // expected-warning {{conflicting parameter types in declaration of 'bar:': 'unsigned char' vs 'unsigned char *'}}
+- (void) ok;
+- (void) also_ok; // expected-warning {{conflicting return type in declaration of 'also_ok': 'unsigned char' vs 'void'}}
+- (void) still_ok;
+- (void) ban : (int) arg; // expected-warning {{conflicting variadic declaration of method and its implementation}}
+@end
+
+@interface Foo()
+- (void) bak;
+@end
+
+@implementation Foo
+- (bycopy id)bud { return 0; }
+- (void) baz {}
+- (void) bar : (unsigned char*)arg {}
+- (void) ok {}
+- (void) also_ok {}
+- (void) still_ok {}
+- (void) ban : (int) arg {}
+- (void) bak {} // expected-warning {{conflicting return type in declaration of 'bak': 'char' vs 'void'}}
+@end
diff --git a/clang/test/SemaObjC/class-protocol.m b/clang/test/SemaObjC/class-protocol.m
new file mode 100644
index 0000000..91cd138
--- /dev/null
+++ b/clang/test/SemaObjC/class-protocol.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// pr5552
+
+@interface Protocol
+@end
+
diff --git a/clang/test/SemaObjC/class-unavail-warning.m b/clang/test/SemaObjC/class-unavail-warning.m
new file mode 100644
index 0000000..b2bd388
--- /dev/null
+++ b/clang/test/SemaObjC/class-unavail-warning.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://9092208
+
+__attribute__((unavailable("not available")))
+@interface MyClass { // expected-note 8 {{declaration has been explicitly marked unavailable here}}
+@public
+ void *_test;
+ MyClass *ivar; // no error.
+}
+
+- (id)self;
+- new;
++ (void)addObject:(id)anObject;
+- (MyClass *)meth; // no error.
+
+@end
+
+@interface Foo {
+ MyClass *ivar; // expected-error {{unavailable}}
+}
+- (MyClass *)meth; // expected-error {{unavailable}}
+@end
+
+@interface MyClass (Cat1)
+- (MyClass *)meth; // no error.
+@end
+
+@interface MyClass (Cat2) // no error.
+@end
+
+@implementation MyClass (Cat2) // expected-error {{unavailable}}
+@end
+
+int main() {
+ [MyClass new]; // expected-error {{'MyClass' is unavailable: not available}}
+ [MyClass self]; // expected-error {{'MyClass' is unavailable: not available}}
+ [MyClass addObject:((void *)0)]; // expected-error {{'MyClass' is unavailable: not available}}
+
+ MyClass *foo = [MyClass new]; // expected-error 2 {{'MyClass' is unavailable: not available}}
+
+ return 0;
+}
diff --git a/clang/test/SemaObjC/cocoa-api-usage.m b/clang/test/SemaObjC/cocoa-api-usage.m
new file mode 100644
index 0000000..85e2115
--- /dev/null
+++ b/clang/test/SemaObjC/cocoa-api-usage.m
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -fsyntax-only -Wobjc-cocoa-api -verify
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %s -fsyntax-only -Wobjc-cocoa-api -verify
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c %s.fixed -fsyntax-only
+// RUN: cp %s %t.m
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %t.m -fixit -Wobjc-cocoa-api
+// RUN: diff %s.fixed %t.m
+// RUN: cp %s %t.m
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %t.m -fixit -Wobjc-cocoa-api
+// RUN: diff %s.fixed %t.m
+
+typedef signed char BOOL;
+#define nil ((void*) 0)
+
+@interface NSObject
++ (id)alloc;
+@end
+
+@interface NSString : NSObject
++ (id)stringWithString:(NSString *)string;
+- (id)initWithString:(NSString *)aString;
+@end
+
+@interface NSArray : NSObject
+- (id)objectAtIndex:(unsigned long)index;
+- (id)objectAtIndexedSubscript:(int)index;
+@end
+
+@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;
+
+- (id)objectAtIndex:(unsigned long)index;
+@end
+
+@interface NSMutableArray : NSArray
+- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary : NSObject
+- (id)objectForKeyedSubscript:(id)key;
+@end
+
+@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;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)anObject forKey:(id)aKey;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@interface NSNumber : NSObject
+@end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+#define M(x) (x)
+#define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
+#define TWO(x) ((x), (x))
+
+void foo() {
+ NSString *str = M([NSString stringWithString:@"foo"]); // expected-warning {{redundant}}
+ str = [[NSString alloc] initWithString:@"foo"];
+ NSArray *arr = [NSArray arrayWithArray:@[str]]; // expected-warning {{redundant}}
+ NSDictionary *dict = [NSDictionary dictionaryWithDictionary:@{str: arr}]; // expected-warning {{redundant}}
+}
diff --git a/clang/test/SemaObjC/cocoa-api-usage.m.fixed b/clang/test/SemaObjC/cocoa-api-usage.m.fixed
new file mode 100644
index 0000000..55e060a
--- /dev/null
+++ b/clang/test/SemaObjC/cocoa-api-usage.m.fixed
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -fsyntax-only -Wobjc-cocoa-api -verify
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %s -fsyntax-only -Wobjc-cocoa-api -verify
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c %s.fixed -fsyntax-only
+// RUN: cp %s %t.m
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %t.m -fixit -Wobjc-cocoa-api
+// RUN: diff %s.fixed %t.m
+// RUN: cp %s %t.m
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %t.m -fixit -Wobjc-cocoa-api
+// RUN: diff %s.fixed %t.m
+
+typedef signed char BOOL;
+#define nil ((void*) 0)
+
+@interface NSObject
++ (id)alloc;
+@end
+
+@interface NSString : NSObject
++ (id)stringWithString:(NSString *)string;
+- (id)initWithString:(NSString *)aString;
+@end
+
+@interface NSArray : NSObject
+- (id)objectAtIndex:(unsigned long)index;
+- (id)objectAtIndexedSubscript:(int)index;
+@end
+
+@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;
+
+- (id)objectAtIndex:(unsigned long)index;
+@end
+
+@interface NSMutableArray : NSArray
+- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary : NSObject
+- (id)objectForKeyedSubscript:(id)key;
+@end
+
+@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;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)anObject forKey:(id)aKey;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@interface NSNumber : NSObject
+@end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+#define M(x) (x)
+#define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
+#define TWO(x) ((x), (x))
+
+void foo() {
+ NSString *str = M(@"foo"); // expected-warning {{redundant}}
+ str = [[NSString alloc] initWithString:@"foo"];
+ NSArray *arr = @[str]; // expected-warning {{redundant}}
+ NSDictionary *dict = @{str: arr}; // expected-warning {{redundant}}
+}
diff --git a/clang/test/SemaObjC/cocoa.m b/clang/test/SemaObjC/cocoa.m
new file mode 100644
index 0000000..a8cfb72
--- /dev/null
+++ b/clang/test/SemaObjC/cocoa.m
@@ -0,0 +1,5 @@
+// RUN: %clang -arch x86_64 %s -fsyntax-only -Xclang -print-stats
+#ifdef __APPLE__
+#include <Cocoa/Cocoa.h>
+#endif
+
diff --git a/clang/test/SemaObjC/compare-qualified-class.m b/clang/test/SemaObjC/compare-qualified-class.m
new file mode 100644
index 0000000..0f415b6
--- /dev/null
+++ b/clang/test/SemaObjC/compare-qualified-class.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://8191774
+
+@protocol SomeProtocol
+@end
+
+@protocol SomeProtocol1
+@end
+
+@interface SomeObject <SomeProtocol>
+@end
+
+int main () {
+ Class <SomeProtocol> classA;
+ Class <SomeProtocol> classB;
+ Class <SomeProtocol, SomeProtocol1> classC;
+ Class <SomeProtocol1> classD;
+ void * pv = 0;
+ Class c = (Class)0;;
+ if (pv)
+ return classA == pv;
+
+ if (c)
+ return classA == c;
+
+ return classA == classB || classA == classC ||
+ classC == classA ||
+ classA == classD; // expected-warning {{comparison of distinct pointer types ('Class<SomeProtocol> *' and 'Class<SomeProtocol1> *')}}
+}
+
diff --git a/clang/test/SemaObjC/compare-qualified-id.m b/clang/test/SemaObjC/compare-qualified-id.m
new file mode 100644
index 0000000..d31dfae
--- /dev/null
+++ b/clang/test/SemaObjC/compare-qualified-id.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end // expected-note {{method 'copyWithZone:' declared here}}
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@interface NSObject <NSObject> {} @end
+typedef struct {} NSFastEnumerationState;
+@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; @end
+@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count; @end
+@interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey; @end
+extern NSString * const NSTaskDidTerminateNotification;
+
+@interface XCPropertyExpansionContext : NSObject <NSCopying> { // expected-note {{required for direct or indirect protocol 'NSCopying'}}
+ NSMutableDictionary * _propNamesToPropValuesCache;
+} @end
+
+@protocol XCPropertyValues <NSObject, NSCopying>
+- (NSString *)evaluateAsStringInContext:(XCPropertyExpansionContext *)context withNestingState:(const void *)state;
+@end
+
+@implementation XCPropertyExpansionContext // expected-warning {{incomplete implementation}} \
+ // expected-warning {{method 'copyWithZone:' in protocol not implemented}}
+- (NSString *)expandedValueForProperty:(NSString *)property {
+ id <XCPropertyValues> cachedValueNode = [_propNamesToPropValuesCache objectForKey:property]; // expected-warning {{method '-objectForKey:' not found (return type defaults to 'id')}}
+ if (cachedValueNode == ((void *)0)) { }
+ NSString * expandedValue = [cachedValueNode evaluateAsStringInContext:self withNestingState:((void *)0)];
+ return expandedValue;
+}
+@end
diff --git a/clang/test/SemaObjC/compatible-protocol-qualified-types.m b/clang/test/SemaObjC/compatible-protocol-qualified-types.m
new file mode 100644
index 0000000..c0b929d
--- /dev/null
+++ b/clang/test/SemaObjC/compatible-protocol-qualified-types.m
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -pedantic -fsyntax-only -verify -Wno-objc-root-class %s
+typedef signed char BOOL;
+
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+@end
+
+@protocol NSCoding
+- (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+
+@interface NSObject <NSObject> {}
+@end
+
+typedef float CGFloat;
+
+@interface NSResponder : NSObject <NSCoding> {}
+@end
+
+@protocol XCSelectionSource;
+
+@interface XCSelection : NSResponder {}
+- (NSObject <XCSelectionSource> *) source;
+@end
+
+extern NSString * const XCActiveSelectionLevel;
+
+@interface XCActionManager : NSResponder {}
++defaultActionManager;
+-selectionAtLevel:(NSString *const)s;
+@end
+
+@implementation XDMenuItemsManager // expected-warning {{cannot find interface declaration for 'XDMenuItemsManager'}}
++ (void)initialize {
+ id<XCSelectionSource, NSObject> source =
+ [[[XCActionManager defaultActionManager] selectionAtLevel:XCActiveSelectionLevel] source];
+}
+@end
+
+@protocol NSTextStorageDelegate;
+@class NSNotification;
+
+@interface NSTextStorage : NSObject
+
+- (void)setDelegate:(id <NSTextStorageDelegate>)delegate; // expected-note{{passing argument to parameter 'delegate' here}}
+- (id <NSTextStorageDelegate>)delegate;
+
+@end
+
+@protocol NSTextStorageDelegate <NSObject>
+@optional
+
+- (void)textStorageWillProcessEditing:(NSNotification *)notification;
+- (void)textStorageDidProcessEditing:(NSNotification *)notification;
+
+@end
+
+@interface SKTText : NSObject {
+ @private
+
+
+ NSTextStorage *_contents;
+}
+@end
+
+@implementation SKTText
+
+
+- (NSTextStorage *)contents {
+ [_contents setDelegate:self]; // expected-warning {{sending 'SKTText *' to parameter of incompatible type 'id<NSTextStorageDelegate>'}}
+ return 0;
+}
+
+@end
diff --git a/clang/test/SemaObjC/compound-init.m b/clang/test/SemaObjC/compound-init.m
new file mode 100644
index 0000000..7b288bb
--- /dev/null
+++ b/clang/test/SemaObjC/compound-init.m
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+@interface A
+@end
+
+void f() {
+ (A){ 0 }; // expected-error{{cannot initialize Objective-C class type 'A'}}
+}
diff --git a/clang/test/SemaObjC/comptypes-1.m b/clang/test/SemaObjC/comptypes-1.m
new file mode 100644
index 0000000..997ef19
--- /dev/null
+++ b/clang/test/SemaObjC/comptypes-1.m
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+#define nil (void *)0;
+#define Nil (void *)0;
+
+extern void foo();
+
+@protocol MyProtocol
+- (void) foo;
+@end
+
+@interface MyClass
+@end
+
+@interface MyOtherClass <MyProtocol>
+- (void) foo;
+@end
+
+int main()
+{
+ id obj = nil;
+ id<MyProtocol> obj_p = nil;
+ MyClass *obj_c = nil;
+ MyOtherClass *obj_cp = nil;
+ Class obj_C = Nil;
+
+ /* Assigning to an 'id' variable should never
+ generate a warning. */
+ obj = obj_p; /* Ok */
+ obj = obj_c; /* Ok */
+ obj = obj_cp; /* Ok */
+ obj = obj_C; /* Ok */
+
+ /* Assigning to a 'MyClass *' variable should always generate a
+ warning, unless done from an 'id'. */
+ obj_c = obj; /* Ok */
+ obj_c = obj_cp; // // expected-warning {{incompatible pointer types assigning to 'MyClass *' from 'MyOtherClass *'}}
+ obj_c = obj_C; // expected-warning {{incompatible pointer types assigning to 'MyClass *' from 'Class'}}
+
+ /* Assigning to an 'id<MyProtocol>' variable should generate a
+ warning if done from a 'MyClass *' (which doesn't implement
+ MyProtocol), but not from an 'id' or from a 'MyOtherClass *'
+ (which implements MyProtocol). */
+ obj_p = obj; /* Ok */
+ obj_p = obj_c; // expected-warning {{assigning to 'id<MyProtocol>' from incompatible type 'MyClass *'}}
+ obj_p = obj_cp; /* Ok */
+ obj_p = obj_C; // expected-warning {{incompatible pointer types assigning to 'id<MyProtocol>' from 'Class'}}
+
+ /* Assigning to a 'MyOtherClass *' variable should always generate
+ a warning, unless done from an 'id' or an 'id<MyProtocol>' (since
+ MyOtherClass implements MyProtocol). */
+ obj_cp = obj; /* Ok */
+ obj_cp = obj_c; // expected-warning {{incompatible pointer types assigning to 'MyOtherClass *' from 'MyClass *'}}
+ obj_cp = obj_p; /* Ok */
+ obj_cp = obj_C; // expected-warning {{incompatible pointer types assigning to 'MyOtherClass *' from 'Class'}}
+
+ /* Any comparison involving an 'id' must be without warnings. */
+ if (obj == obj_p) foo() ; /* Ok */ /*Bogus warning here in 2.95.4*/
+ if (obj_p == obj) foo() ; /* Ok */
+ if (obj == obj_c) foo() ; /* Ok */
+ if (obj_c == obj) foo() ; /* Ok */
+ if (obj == obj_cp) foo() ; /* Ok */
+ if (obj_cp == obj) foo() ; /* Ok */
+ if (obj == obj_C) foo() ; /* Ok */
+ if (obj_C == obj) foo() ; /* Ok */
+
+ /* Any comparison between 'MyClass *' and anything which is not an 'id'
+ must generate a warning. */
+ if (obj_p == obj_c) foo() ; // expected-warning {{comparison of distinct pointer types ('id<MyProtocol>' and 'MyClass *')}}
+
+ if (obj_c == obj_cp) foo() ; // expected-warning {{comparison of distinct pointer types ('MyClass *' and 'MyOtherClass *')}}
+ if (obj_cp == obj_c) foo() ; // expected-warning {{comparison of distinct pointer types ('MyOtherClass *' and 'MyClass *')}}
+
+ if (obj_c == obj_C) foo() ;
+ if (obj_C == obj_c) foo() ;
+
+ /* Any comparison between 'MyOtherClass *' (which implements
+ MyProtocol) and an 'id' implementing MyProtocol are Ok. */
+ if (obj_cp == obj_p) foo() ; /* Ok */
+ if (obj_p == obj_cp) foo() ; /* Ok */
+
+
+ if (obj_p == obj_C) foo() ;
+ if (obj_C == obj_p) foo() ;
+ if (obj_cp == obj_C) foo() ;
+ if (obj_C == obj_cp) foo() ;
+
+ return 0;
+}
diff --git a/clang/test/SemaObjC/comptypes-10.m b/clang/test/SemaObjC/comptypes-10.m
new file mode 100644
index 0000000..5f16a6e
--- /dev/null
+++ b/clang/test/SemaObjC/comptypes-10.m
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+//rdar: //8591619
+// pr8453
+
+@protocol NSCopying @end
+@protocol NSPROTO @end
+@protocol NSPROTO1 @end
+@protocol NSPROTO2 @end
+
+@interface NSObject <NSCopying, NSPROTO, NSPROTO1> {
+ Class isa;
+}
+@end
+
+void gorf(NSObject <NSCopying> *); // expected-note {{passing argument to parameter here}}
+
+NSObject <NSCopying> *foo(id <NSCopying> bar, id id_obj)
+{
+ NSObject <NSCopying> *Init = bar; // expected-warning {{initializing 'NSObject<NSCopying> *' with an expression of incompatible type 'id<NSCopying>'}}
+ NSObject *Init1 = bar; // expected-warning {{initializing 'NSObject *' with an expression of incompatible type 'id<NSCopying>'}}
+
+ NSObject <NSCopying> *I = id_obj;
+ NSObject *I1 = id_obj;
+ gorf(bar); // expected-warning {{passing 'id<NSCopying>' to parameter of incompatible type 'NSObject<NSCopying> *'}}
+
+ gorf(id_obj);
+
+ return bar; // expected-warning {{returning 'id<NSCopying>' from a function with incompatible result type 'NSObject<NSCopying> *'}}
+}
+
+void test(id <NSCopying, NSPROTO, NSPROTO2> bar)
+{
+ NSObject <NSCopying> *Init = bar; // expected-warning {{initializing 'NSObject<NSCopying> *' with an expression of incompatible type 'id<NSCopying,NSPROTO,NSPROTO2>'}}
+}
+
+// rdar://8843851
+@interface NSObject (CAT)
++ (struct S*)Meth : (struct S*)arg;
+@end
+
+struct S {
+ char *types;
+};
+
+@interface I
+@end
+
+@implementation I
+- (struct S *)Meth : (struct S*)a {
+ return [NSObject Meth : a];
+}
+@end
diff --git a/clang/test/SemaObjC/comptypes-2.m b/clang/test/SemaObjC/comptypes-2.m
new file mode 100644
index 0000000..74e42c9
--- /dev/null
+++ b/clang/test/SemaObjC/comptypes-2.m
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define nil (void *)0;
+#define Nil (void *)0;
+
+@protocol MyProtocol
+- (void) foo;
+@end
+
+@interface MyClass
+@end
+
+int main()
+{
+ id obj = nil;
+ id<MyProtocol> obj_p = nil;
+ MyClass *obj_c = nil;
+ Class obj_C = Nil;
+
+ /* All these casts should generate no warnings. */
+
+ obj = (id)obj_p;
+ obj = (id)obj_c;
+ obj = (id)obj_C;
+ obj_c = (MyClass *)obj;
+ obj_c = (MyClass *)obj_p;
+ obj_c = (MyClass *)obj_C;
+ obj_p = (id<MyProtocol>)obj;
+ obj_p = (id<MyProtocol>)obj_c;
+ obj_p = (id<MyProtocol>)obj_C;
+ obj_C = (Class)obj;
+ obj_C = (Class)obj_p;
+ obj_C = (Class)obj_c;
+
+
+ return 0;
+}
diff --git a/clang/test/SemaObjC/comptypes-3.m b/clang/test/SemaObjC/comptypes-3.m
new file mode 100644
index 0000000..6c1ce41
--- /dev/null
+++ b/clang/test/SemaObjC/comptypes-3.m
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define nil (void *)0;
+
+extern void foo();
+
+@protocol MyProtocolA
+- (void) methodA;
+@end
+
+@protocol MyProtocolB
+- (void) methodB;
+@end
+
+@protocol MyProtocolAB <MyProtocolA, MyProtocolB>
+@end
+
+@protocol MyProtocolAC <MyProtocolA>
+- (void) methodC;
+@end
+
+int main()
+{
+ id<MyProtocolA> obj_a = nil;
+ id<MyProtocolB> obj_b = nil;
+ id<MyProtocolAB> obj_ab = nil;
+ id<MyProtocolAC> obj_ac = nil;
+
+ obj_a = obj_b; // expected-warning {{assigning to 'id<MyProtocolA>' from incompatible type 'id<MyProtocolB>'}}
+ obj_a = obj_ab; /* Ok */
+ obj_a = obj_ac; /* Ok */
+
+ obj_b = obj_a; // expected-warning {{assigning to 'id<MyProtocolB>' from incompatible type 'id<MyProtocolA>'}}
+ obj_b = obj_ab; /* Ok */
+ obj_b = obj_ac; // expected-warning {{assigning to 'id<MyProtocolB>' from incompatible type 'id<MyProtocolAC>'}}
+
+ obj_ab = obj_a; // expected-warning {{assigning to 'id<MyProtocolAB>' from incompatible type 'id<MyProtocolA>'}}
+ obj_ab = obj_b; // expected-warning {{assigning to 'id<MyProtocolAB>' from incompatible type 'id<MyProtocolB>'}}
+ obj_ab = obj_ac; // expected-warning {{assigning to 'id<MyProtocolAB>' from incompatible type 'id<MyProtocolAC>'}}
+
+ obj_ac = obj_a; // expected-warning {{assigning to 'id<MyProtocolAC>' from incompatible type 'id<MyProtocolA>'}}
+ obj_ac = obj_b; // expected-warning {{assigning to 'id<MyProtocolAC>' from incompatible type 'id<MyProtocolB>'}}
+ obj_ac = obj_ab; // expected-warning {{assigning to 'id<MyProtocolAC>' from incompatible type 'id<MyProtocolAB>'}}
+
+ if (obj_a == obj_b) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolA>' and 'id<MyProtocolB>')}}
+ if (obj_b == obj_a) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolB>' and 'id<MyProtocolA>')}}
+
+ if (obj_a == obj_ab) foo (); /* Ok */
+ if (obj_ab == obj_a) foo (); /* Ok */
+
+ if (obj_a == obj_ac) foo (); /* Ok */
+ if (obj_ac == obj_a) foo (); /* Ok */
+
+ if (obj_b == obj_ab) foo (); /* Ok */
+ if (obj_ab == obj_b) foo (); /* Ok */
+
+ if (obj_b == obj_ac) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolB>' and 'id<MyProtocolAC>')}}
+ if (obj_ac == obj_b) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolAC>' and 'id<MyProtocolB>')}}
+
+ if (obj_ab == obj_ac) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolAB>' and 'id<MyProtocolAC>')}}
+ if (obj_ac == obj_ab) foo (); // expected-warning {{comparison of distinct pointer types ('id<MyProtocolAC>' and 'id<MyProtocolAB>')}}
+
+ return 0;
+}
diff --git a/clang/test/SemaObjC/comptypes-4.m b/clang/test/SemaObjC/comptypes-4.m
new file mode 100644
index 0000000..adc324c
--- /dev/null
+++ b/clang/test/SemaObjC/comptypes-4.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+extern void foo();
+
+@protocol MyProtocol @end
+
+@interface MyClass @end
+
+int main()
+{
+ MyClass <MyProtocol> *obj_p;
+ MyClass *obj_cp;
+
+ obj_cp = obj_p;
+ obj_p = obj_cp; // expected-warning {{incompatible pointer types assigning to 'MyClass<MyProtocol> *' from 'MyClass *'}}
+
+ if (obj_cp == obj_p)
+ foo();
+
+ if (obj_p == obj_cp)
+ foo();
+
+}
+
+
diff --git a/clang/test/SemaObjC/comptypes-5.m b/clang/test/SemaObjC/comptypes-5.m
new file mode 100644
index 0000000..46300e3
--- /dev/null
+++ b/clang/test/SemaObjC/comptypes-5.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+
+#define nil (void *)0;
+
+extern void foo();
+
+@protocol MyProtocol
+- (void) method;
+@end
+
+@interface MyClass
+@end
+
+@interface MyClass (Addition) <MyProtocol>
+- (void) method;
+@end
+
+@interface MyOtherClass : MyClass
+@end
+
+int main()
+{
+ id <MyProtocol> obj_id_p = nil;
+ MyClass *obj_c_cat_p = nil;
+ MyOtherClass *obj_c_super_p = nil;
+ MyOtherClass<MyProtocol> *obj_c_super_p_q = nil;
+ MyClass<MyProtocol> *obj_c_cat_p_q = nil;
+
+ obj_c_cat_p = obj_id_p;
+ obj_c_super_p = obj_id_p;
+ obj_id_p = obj_c_cat_p; /* Ok */
+ obj_id_p = obj_c_super_p; /* Ok */
+
+ if (obj_c_cat_p == obj_id_p) foo(); /* Ok */
+ if (obj_c_super_p == obj_id_p) foo() ; /* Ok */
+ if (obj_id_p == obj_c_cat_p) foo(); /* Ok */
+ if (obj_id_p == obj_c_super_p) foo(); /* Ok */
+
+ obj_c_cat_p = obj_c_super_p; // ok.
+ obj_c_cat_p = obj_c_super_p_q; // ok.
+ obj_c_super_p = obj_c_cat_p_q; // expected-warning {{incompatible pointer types}}
+ obj_c_cat_p_q = obj_c_super_p;
+ return 0;
+}
diff --git a/clang/test/SemaObjC/comptypes-6.m b/clang/test/SemaObjC/comptypes-6.m
new file mode 100644
index 0000000..98cf488
--- /dev/null
+++ b/clang/test/SemaObjC/comptypes-6.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+@interface Derived
+@end
+
+@interface Object @end
+
+extern Object* foo(void);
+
+static Derived *test(void)
+{
+ Derived *m = foo(); // expected-warning {{incompatible pointer types initializing 'Derived *' with an expression of type 'Object *'}}
+
+ return m;
+}
+
diff --git a/clang/test/SemaObjC/comptypes-7.m b/clang/test/SemaObjC/comptypes-7.m
new file mode 100644
index 0000000..dde504b
--- /dev/null
+++ b/clang/test/SemaObjC/comptypes-7.m
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+#define nil (void *)0;
+#define Nil (void *)0;
+
+extern void foo();
+
+@protocol MyProtocol
+- (void) method;
+@end
+
+@interface MyClass
+@end
+
+int main()
+{
+ id obj = nil;
+ id <MyProtocol> obj_p = nil;
+ MyClass *obj_c = nil;
+ Class obj_C = Nil;
+
+ int i = 0;
+ int *j = nil;
+
+ /* These should all generate warnings. */
+
+ obj = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'id' from 'int'}}
+ obj = j; // expected-warning {{incompatible pointer types assigning to 'id' from 'int *'}}
+
+ obj_p = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'id<MyProtocol>' from 'int'}}
+ obj_p = j; // expected-warning {{incompatible pointer types assigning to 'id<MyProtocol>' from 'int *'}}
+
+ obj_c = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'MyClass *' from 'int'}}
+ obj_c = j; // expected-warning {{incompatible pointer types assigning to 'MyClass *' from 'int *'}}
+
+ obj_C = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'Class' from 'int'}}
+ obj_C = j; // expected-warning {{incompatible pointer types assigning to 'Class' from 'int *'}}
+
+ i = obj; // expected-warning {{incompatible pointer to integer conversion assigning to 'int' from 'id'}}
+ i = obj_p; // expected-warning {{incompatible pointer to integer conversion assigning to 'int' from 'id<MyProtocol>'}}
+ i = obj_c; // expected-warning {{incompatible pointer to integer conversion assigning to 'int' from 'MyClass *'}}
+ i = obj_C; // expected-warning {{incompatible pointer to integer conversion assigning to 'int' from 'Class'}}
+
+ j = obj; // expected-warning {{incompatible pointer types assigning to 'int *' from 'id'}}
+ j = obj_p; // expected-warning {{incompatible pointer types assigning to 'int *' from 'id<MyProtocol>'}}
+ j = obj_c; // expected-warning {{incompatible pointer types assigning to 'int *' from 'MyClass *'}}
+ j = obj_C; // expected-warning {{incompatible pointer types assigning to 'int *' from 'Class'}}
+
+ if (obj == i) foo() ; // expected-warning {{comparison between pointer and integer ('id' and 'int')}}
+ if (i == obj) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'id')}}
+ if (obj == j) foo() ; // expected-warning {{comparison of distinct pointer types ('id' and 'int *')}}
+ if (j == obj) foo() ; // expected-warning {{comparison of distinct pointer types ('int *' and 'id')}}
+
+ if (obj_c == i) foo() ; // expected-warning {{comparison between pointer and integer ('MyClass *' and 'int')}}
+ if (i == obj_c) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'MyClass *')}}
+ if (obj_c == j) foo() ; // expected-warning {{comparison of distinct pointer types ('MyClass *' and 'int *')}}
+ if (j == obj_c) foo() ; // expected-warning {{comparison of distinct pointer types ('int *' and 'MyClass *')}}
+
+ if (obj_p == i) foo() ; // expected-warning {{comparison between pointer and integer ('id<MyProtocol>' and 'int')}}
+ if (i == obj_p) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'id<MyProtocol>')}}
+ if (obj_p == j) foo() ; // expected-warning {{comparison of distinct pointer types ('id<MyProtocol>' and 'int *')}}
+ if (j == obj_p) foo() ; // expected-warning {{comparison of distinct pointer types ('int *' and 'id<MyProtocol>')}}
+
+ if (obj_C == i) foo() ; // expected-warning {{comparison between pointer and integer ('Class' and 'int')}}
+ if (i == obj_C) foo() ; // expected-warning {{comparison between pointer and integer ('int' and 'Class')}}
+ if (obj_C == j) foo() ; // expected-warning {{comparison of distinct pointer types ('Class' and 'int *')}}
+ if (j == obj_C) foo() ; // expected-warning {{comparison of distinct pointer types ('int *' and 'Class')}}
+
+ Class bar1 = Nil;
+ Class <MyProtocol> bar = Nil;
+ bar = bar1;
+ bar1 = bar;
+
+ return 0;
+}
diff --git a/clang/test/SemaObjC/comptypes-8.m b/clang/test/SemaObjC/comptypes-8.m
new file mode 100644
index 0000000..750b0a6
--- /dev/null
+++ b/clang/test/SemaObjC/comptypes-8.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol MyProtocol
+@end
+
+id<MyProtocol> obj_p = 0;
+
+int main()
+{
+ obj_p = 0;
+}
+
diff --git a/clang/test/SemaObjC/comptypes-9.m b/clang/test/SemaObjC/comptypes-9.m
new file mode 100644
index 0000000..cc6932d
--- /dev/null
+++ b/clang/test/SemaObjC/comptypes-9.m
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+// FIXME: This test case tests the patch applied in: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20080602/006017.html
+// Eventually that logic should be treated as an extension.
+
+typedef signed char BOOL;
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+@end
+
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+
+@protocol NSMutableCopying
+- (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+
+@protocol NSCoding
+- (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+
+@interface NSObject <NSObject> {}
+@end
+
+@class NSArray;
+
+typedef struct {} NSFastEnumerationState;
+
+@protocol NSFastEnumeration
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+
+@class NSString;
+
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+- (NSUInteger)count;
+- (id)objectAtIndex:(NSUInteger)index;
+@end
+
+typedef unsigned short unichar;
+
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
+@end
+
+@interface NSSimpleCString : NSString
+{}
+
+@end
+
+@interface NSConstantString : NSSimpleCString @end
+
+extern void *_NSConstantStringClassReference;
+
+@interface NSResponder : NSObject <NSCoding> {}
+@end
+
+@class NSDate, NSDictionary, NSError, NSException, NSNotification;
+
+@interface NSWindowController : NSResponder <NSCoding> {}
+@end
+
+@class PBXBuildLog, PBXBuildLogItem, PBXBuildLogContainerItem, XCWorkQueueCommand, XCBuildLogContainerItemMutationState;
+
+@protocol PBXBuildLogContainerItems <NSObject>
+- (PBXBuildLog *)buildLog;
+@end
+
+@interface PBXBuildLogItem : NSObject {}
+- (id <PBXBuildLogContainerItems>)superitem;
+@end
+@interface PBXBuildResultsModule
+@end
+
+@implementation PBXBuildResultsModule
+- (void) revealItems
+{
+ PBXBuildLogItem *objItem;
+ PBXBuildLogItem *superitem = [objItem superitem];
+}
+@end
diff --git a/clang/test/SemaObjC/comptypes-a.m b/clang/test/SemaObjC/comptypes-a.m
new file mode 100644
index 0000000..18d546b
--- /dev/null
+++ b/clang/test/SemaObjC/comptypes-a.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -Wmethod-signatures -verify -pedantic -Wno-objc-root-class %s
+typedef signed char BOOL;
+typedef int NSInteger;
+
+@class NSString;
+
+@protocol PBXCompletionItem
+- (NSString *) name;
+- (NSInteger)priority;
+@end
+
+extern NSInteger codeAssistantCaseCompareItems(id a, id b, void *context);
+
+NSInteger codeAssistantCaseCompareItems(id<PBXCompletionItem> a, id<PBXCompletionItem> b, void *context)
+{
+ return 0;
+}
+
+@interface TedWantsToVerifyObjCDoesTheRightThing
+
+- compareThis:(int)a withThat:(id)b; // expected-note {{previous definition is here}} \
+ // expected-note {{previous definition is here}}
+
+@end
+
+@implementation TedWantsToVerifyObjCDoesTheRightThing
+
+- compareThis:(id<PBXCompletionItem>)
+ a // expected-warning {{conflicting parameter types in implementation of 'compareThis:withThat:': 'int' vs 'id<PBXCompletionItem>'}}
+ withThat:(id<PBXCompletionItem>)b { // expected-warning {{conflicting parameter types in implementation of 'compareThis:withThat:': 'id' vs 'id<PBXCompletionItem>'}}
+ return self;
+}
+
+@end
diff --git a/clang/test/SemaObjC/comptypes-legal.m b/clang/test/SemaObjC/comptypes-legal.m
new file mode 100644
index 0000000..d83d559
--- /dev/null
+++ b/clang/test/SemaObjC/comptypes-legal.m
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+
+@protocol NSObject
+@end
+@interface NSObject <NSObject> {
+}
+@end
+@interface NSString : NSObject
+@end
+void __setRetained(id *ivar, id value, NSObject **o) {
+ *ivar = value;
+}
+static NSString *_logProcessPrefix = 0;
+void func() {
+ __setRetained(&_logProcessPrefix, _logProcessPrefix, &_logProcessPrefix);
+}
+@implementation NSObject (ScopeAdditions)
++ (void)setObjectLogProcessPrefix:(NSString *)processPrefix {
+ __setRetained(&_logProcessPrefix, processPrefix, &_logProcessPrefix);
+}
+@end
+
+@class Derived;
+
+NSObject *ExternFunc (NSObject *filePath, NSObject *key);
+typedef id FuncSignature (NSObject *arg1, Derived *arg2);
+
+@interface Derived: NSObject
++ (void)registerFunc:(FuncSignature *)function; // expected-note{{passing argument to parameter 'function' here}}
+@end
+
+void foo(void)
+{
+ // GCC currently allows this (it has some fiarly new support for covariant return types and contravariant argument types).
+ // Since registerFunc: expects a Derived object as it's second argument, I don't know why this would be legal.
+ [Derived registerFunc: ExternFunc]; // expected-warning{{incompatible pointer types sending 'NSObject *(NSObject *, NSObject *)' to parameter of type 'FuncSignature *'}}
+}
diff --git a/clang/test/SemaObjC/conditional-expr-2.m b/clang/test/SemaObjC/conditional-expr-2.m
new file mode 100644
index 0000000..fdf3d13
--- /dev/null
+++ b/clang/test/SemaObjC/conditional-expr-2.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface A
+@end
+@interface B
+@end
+
+void f0(int cond, A *a, B *b) {
+ // Ensure that we can still send a message to result of incompatible
+ // conditional expression.
+ [ (cond ? a : b) test ]; // expected-warning{{incompatible operand types ('A *' and 'B *')}} expected-warning {{method '-test' not found}}
+}
+
+@interface NSKey @end
+@interface KeySub : NSKey @end
+
+@interface UpdatesList @end
+
+void foo (int i, NSKey *NSKeyValueCoding_NullValue, UpdatesList *nukedUpdatesList)
+{
+ id obj;
+ NSKey *key;
+ KeySub *keysub;
+
+ obj = i ? NSKeyValueCoding_NullValue : nukedUpdatesList; // expected-warning{{incompatible operand types ('NSKey *' and 'UpdatesList *')}}
+ key = i ? NSKeyValueCoding_NullValue : nukedUpdatesList; // expected-warning{{incompatible operand types ('NSKey *' and 'UpdatesList *')}}
+ key = i ? NSKeyValueCoding_NullValue : keysub;
+ keysub = i ? NSKeyValueCoding_NullValue : keysub; // expected-warning{{incompatible pointer types assigning to 'KeySub *' from 'NSKey *'}}
+}
diff --git a/clang/test/SemaObjC/conditional-expr-3.m b/clang/test/SemaObjC/conditional-expr-3.m
new file mode 100644
index 0000000..166e02b
--- /dev/null
+++ b/clang/test/SemaObjC/conditional-expr-3.m
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol P0
+@end
+@protocol P1
+@end
+@protocol P2
+@end
+
+@interface A <P0>
+@end
+
+@interface B : A
+@end
+
+void bar(id x);
+void barP0(id<P0> x);
+void barP1(id<P1> x);
+void barP2(id<P2> x);
+
+void f0(A *a) {
+ id l = a;
+}
+
+void f1(id x, A *a) {
+ id<P0> l = a;
+}
+
+void f2(id<P1> x) {
+ id<P0> l = x; // expected-warning {{initializing 'id<P0>' with an expression of incompatible type 'id<P1>'}}
+}
+
+void f3(A *a) {
+ id<P1> l = a; // expected-warning {{initializing 'id<P1>' with an expression of incompatible type 'A *'}}
+}
+
+void f4(int cond, id x, A *a) {
+ bar(cond ? x : a);
+}
+
+void f5(int cond, A *a, B *b) {
+ bar(cond ? a : b);
+}
+
+void f6(int cond, id x, A *a) {
+ bar(cond ? (id<P0, P1>) x : a);
+}
+
+void f7(int cond, id x, A *a) {
+ bar(cond ? a : (id<P0, P1>) x);
+}
+
+void f8(int cond, id<P0,P1> x0, id<P0,P2> x1) {
+ barP0(cond ? x0 : x1); // expected-warning {{incompatible operand types ('id<P0,P1>' and 'id<P0,P2>')}}
+}
+
+void f9(int cond, id<P0,P1> x0, id<P0,P2> x1) {
+ barP1(cond ? x0 : x1); // expected-warning {{incompatible operand types ('id<P0,P1>' and 'id<P0,P2>')}}
+}
+
+void f10(int cond, id<P0,P1> x0, id<P0,P2> x1) {
+ barP2(cond ? x0 : x1); // expected-warning {{incompatible operand types ('id<P0,P1>' and 'id<P0,P2>')}}
+}
+
+int f11(int cond, A* a, B* b) {
+ return (cond? b : a)->x; // expected-error{{'A' does not have a member named 'x'}}
+}
diff --git a/clang/test/SemaObjC/conditional-expr-4.m b/clang/test/SemaObjC/conditional-expr-4.m
new file mode 100644
index 0000000..56bcfc2
--- /dev/null
+++ b/clang/test/SemaObjC/conditional-expr-4.m
@@ -0,0 +1,80 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// <rdar://problem/6212771>
+
+#define nil ((void*) 0)
+
+@interface A
+@property int x;
+@end
+
+@interface B : A
+@end
+
+// Basic checks...
+id f0(int cond, id a, void *b) {
+ return cond ? a : b;
+}
+A *f0_a(int cond, A *a, void *b) {
+ return cond ? a : b;
+}
+
+id f1(int cond, id a) {
+ return cond ? a : nil;
+}
+A *f1_a(int cond, A *a) {
+ return cond ? a : nil;
+}
+
+void *f1_const_a(int x, void *p, const A * q) {
+ void *r = x ? p : q; // expected-warning{{initializing 'void *' with an expression of type 'const void *' discards qualifiers}}
+ return r;
+}
+
+// Check interaction with qualified id
+
+@protocol P0 @end
+
+id f2(int cond, id<P0> a, void *b) {
+ return cond ? a : b;
+}
+
+id f3(int cond, id<P0> a) {
+ return cond ? a : nil;
+}
+
+// Check that result actually has correct type.
+
+// Using properties is one way to find the compiler internal type of a
+// conditional expression. Simple assignment doesn't work because if
+// the type is id then it can be implicitly promoted.
+@protocol P1
+@property int x;
+@end
+
+int f5(int cond, id<P1> a, id<P1> b) {
+ return (cond ? a : b).x;
+}
+int f5_a(int cond, A *a, A *b) {
+ return (cond ? a : b).x;
+}
+int f5_b(int cond, A *a, B *b) {
+ return (cond ? a : b).x;
+}
+
+int f6(int cond, id<P1> a, void *b) {
+ // This should result in something with id type, currently.
+ return (cond ? a : b).x; // expected-error {{member reference base type 'void *' is not a structure or union}}
+}
+
+int f7(int cond, id<P1> a) {
+ return (cond ? a : nil).x;
+}
+
+int f8(int cond, id<P1> a, A *b) {
+ return a == b; // expected-warning {{comparison of distinct pointer types ('id<P1>' and 'A *')}}
+}
+
+int f9(int cond, id<P1> a, A *b) {
+ return (cond ? a : b).x; // expected-warning {{incompatible operand types ('id<P1>' and 'A *')}} \
+ expected-error {{property 'x' not found on object of type 'id'}}
+}
diff --git a/clang/test/SemaObjC/conditional-expr-5.m b/clang/test/SemaObjC/conditional-expr-5.m
new file mode 100644
index 0000000..47aed3e
--- /dev/null
+++ b/clang/test/SemaObjC/conditional-expr-5.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface PBXBuildSettingsDictionary
+{
+ int i;
+}
+@end
+
+@interface XCConditionalBuildSettingsDictionary : PBXBuildSettingsDictionary
+{
+}
+@end
+
+@implementation PBXBuildSettingsDictionary
+
+- (XCConditionalBuildSettingsDictionary *)conditionalDictionaryForConditionSet
+{
+ return i ? self : (id)0;
+}
+
+- (XCConditionalBuildSettingsDictionary *)conditionalDictionaryForConditionSet2
+{
+ return i ? (id)0 : self;
+}
+@end
+
+
diff --git a/clang/test/SemaObjC/conditional-expr-6.m b/clang/test/SemaObjC/conditional-expr-6.m
new file mode 100644
index 0000000..098688a
--- /dev/null
+++ b/clang/test/SemaObjC/conditional-expr-6.m
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol MyProtocol @end
+
+@interface NSObject @end
+
+@interface NSInterm : NSObject <MyProtocol>
+@end
+
+@interface NSArray : NSInterm
+@end
+
+@interface NSSet : NSObject <MyProtocol>
+@end
+
+
+@interface N1 : NSObject
+@end
+
+@interface N1() <MyProtocol>
+@end
+
+NSObject* test (int argc) {
+ NSArray *array = ((void*)0);
+ NSSet *set = ((void*)0);
+ return (argc) ? set : array ;
+}
+
+
+NSObject* test1 (int argc) {
+ NSArray *array = ((void*)0);
+ NSSet *set = ((void*)0);
+ id <MyProtocol> instance = (argc) ? array : set;
+ id <MyProtocol> instance1 = (argc) ? set : array;
+
+ N1 *n1 = ((void*)0);
+ id <MyProtocol> instance2 = (argc) ? set : n1;
+ id <MyProtocol> instance3 = (argc) ? n1 : array;
+
+ NSArray<MyProtocol> *qual_array = ((void*)0);
+ id <MyProtocol> instance4 = (argc) ? array : qual_array;
+ id <MyProtocol> instance5 = (argc) ? qual_array : array;
+ NSSet<MyProtocol> *qual_set = ((void*)0);
+ id <MyProtocol> instance6 = (argc) ? qual_set : qual_array;
+ id <MyProtocol> instance7 = (argc) ? qual_set : array;
+ id <MyProtocol> instance8 = (argc) ? qual_array : set;
+ id <MyProtocol> instance9 = (argc) ? qual_array : qual_set;
+
+
+ return (argc) ? array : set;
+}
diff --git a/clang/test/SemaObjC/conditional-expr-7.m b/clang/test/SemaObjC/conditional-expr-7.m
new file mode 100644
index 0000000..3ddf3d7
--- /dev/null
+++ b/clang/test/SemaObjC/conditional-expr-7.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// radar 7682116
+
+@interface Super @end
+
+@interface NSArray : Super @end
+@interface NSSet : Super @end
+
+@protocol MyProtocol
+- (void)myMethod;
+@end
+
+@protocol MyProtocol2 <MyProtocol>
+- (void)myMethod2;
+@end
+
+@interface NSArray() <MyProtocol2>
+@end
+
+@interface NSSet() <MyProtocol>
+@end
+
+int main (int argc, const char * argv[]) {
+ NSArray *array = (void*)0;
+ NSSet *set = (void*)0;
+ id <MyProtocol> instance = (argc) ? array : set;
+ instance = (void*)0;
+ return 0;
+}
+
diff --git a/clang/test/SemaObjC/conditional-expr-8.m b/clang/test/SemaObjC/conditional-expr-8.m
new file mode 100644
index 0000000..6799983
--- /dev/null
+++ b/clang/test/SemaObjC/conditional-expr-8.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://9296866
+
+@interface NSResponder
+@end
+
+
+@interface NSView : NSResponder
+@end
+
+@interface WebView : NSView
+@end
+
+@protocol WebDocumentView
+@end
+
+@implementation NSView
+
+- (void) FUNC : (id)s {
+ WebView *m_webView;
+ NSView <WebDocumentView> *documentView;
+ NSView *coordinateView = s ? documentView : m_webView;
+}
+@end
+
diff --git a/clang/test/SemaObjC/conditional-expr.m b/clang/test/SemaObjC/conditional-expr.m
new file mode 100644
index 0000000..e0a3210
--- /dev/null
+++ b/clang/test/SemaObjC/conditional-expr.m
@@ -0,0 +1,119 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wno-objc-root-class %s
+@protocol NSObject
+@end
+
+@protocol DTOutputStreams <NSObject>
+@end
+
+@interface DTFilterOutputStream <DTOutputStreams>
+- nextOutputStream;
+@end
+
+@implementation DTFilterOutputStream
+- (id)initWithNextOutputStream:(id <DTOutputStreams>) outputStream {
+ id <DTOutputStreams> nextOutputStream = [self nextOutputStream];
+ self = nextOutputStream;
+ return nextOutputStream ? nextOutputStream : self;
+}
+- nextOutputStream {
+ return self;
+}
+@end
+
+@interface DTFilterOutputStream2
+- nextOutputStream; // expected-note {{method definition for 'nextOutputStream' not found}}
+@end
+
+@implementation DTFilterOutputStream2 // expected-warning {{incomplete implementation}}
+- (id)initWithNextOutputStream:(id <DTOutputStreams>) outputStream {
+ id <DTOutputStreams> nextOutputStream = [self nextOutputStream];
+ self = nextOutputStream; // expected-warning {{assigning to 'DTFilterOutputStream2 *' from incompatible type 'id<DTOutputStreams>'}}
+ return nextOutputStream ? nextOutputStream : self; // expected-warning {{incompatible operand types ('id<DTOutputStreams>' and 'DTFilterOutputStream2 *')}}
+}
+@end
+
+// No @interface declaration for DTFilterOutputStream3
+@implementation DTFilterOutputStream3 // expected-warning {{cannot find interface declaration for 'DTFilterOutputStream3'}}
+- (id)initWithNextOutputStream:(id <DTOutputStreams>) outputStream {
+ id <DTOutputStreams> nextOutputStream = [self nextOutputStream]; // expected-warning {{method '-nextOutputStream' not found (return type defaults to 'id')}}
+ self = nextOutputStream; // expected-warning {{assigning to 'DTFilterOutputStream3 *' from incompatible type 'id<DTOutputStreams>'}}
+ return nextOutputStream ? nextOutputStream : self; // expected-warning {{incompatible operand types ('id<DTOutputStreams>' and 'DTFilterOutputStream3 *')}}
+}
+@end
+
+//
+
+@protocol P0
+@property int intProp;
+@end
+@protocol P1
+@end
+@protocol P2
+@end
+
+@interface A <P0>
+@end
+
+@interface B : A
+@end
+
+@interface C
+@end
+
+@interface D
+@end
+
+void f0(id<P0> x) {
+ x.intProp = 1;
+}
+
+void f1(int cond, id<P0> x, id<P0> y) {
+ (cond ? x : y).intProp = 1;
+}
+
+void f2(int cond, id<P0> x, A *y) {
+ (cond ? x : y).intProp = 1;
+}
+
+void f3(int cond, id<P0> x, B *y) {
+ (cond ? x : y).intProp = 1;
+}
+
+void f4(int cond, id x, B *y) {
+ (cond ? x : y).intProp = 1; // expected-error {{property 'intProp' not found on object of type 'id'}}
+}
+
+void f5(int cond, id<P0> x, C *y) {
+ (cond ? x : y).intProp = 1; // expected-warning {{incompatible operand types ('id<P0>' and 'C *')}} expected-error {{property 'intProp' not found on object of type 'id'}}
+}
+
+void f6(int cond, C *x, D *y) {
+ (cond ? x : y).intProp = 1; // expected-warning {{incompatible operand types}}, expected-error {{property 'intProp' not found on object of type 'id'}}
+}
+
+id f7(int a, id<P0> x, A* p) {
+ return a ? x : p;
+}
+
+void f8(int a, A<P0> *x, A *y) {
+ [ (a ? x : y ) intProp ];
+}
+
+void f9(int a, A<P0> *x, A<P1> *y) {
+ id l0 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
+ A<P0> *l1 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
+ A<P1> *l2 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
+ [ (a ? x : y ) intProp ]; // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
+}
+
+void f10(int a, id<P0> x, id y) {
+ [ (a ? x : y ) intProp ];
+}
+
+void f11(int a, id<P0> x, id<P1> y) {
+ [ (a ? x : y ) intProp ]; // expected-warning {{incompatible operand types ('id<P0>' and 'id<P1>')}}
+}
+
+void f12(int a, A<P0> *x, A<P1> *y) {
+ A<P1>* l0 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
+}
diff --git a/clang/test/SemaObjC/conflict-atomic-property.m b/clang/test/SemaObjC/conflict-atomic-property.m
new file mode 100644
index 0000000..033980c
--- /dev/null
+++ b/clang/test/SemaObjC/conflict-atomic-property.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://10260017
+
+@interface Foo
+@property (nonatomic, assign, atomic) float dummy; // expected-error {{property attributes 'atomic' and 'nonatomic' are mutually exclusive}}
+@property (nonatomic, assign) float d1;
+@property (atomic, assign) float d2;
+@property (assign) float d3;
+@property (atomic, nonatomic, assign) float d4; // expected-error {{property attributes 'atomic' and 'nonatomic' are mutually exclusive}}
+@end
diff --git a/clang/test/SemaObjC/conflict-nonfragile-abi2.m b/clang/test/SemaObjC/conflict-nonfragile-abi2.m
new file mode 100644
index 0000000..8197327
--- /dev/null
+++ b/clang/test/SemaObjC/conflict-nonfragile-abi2.m
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
+// rdar://8225011
+
+int glob;
+
+@interface I
+@property int glob;
+@property int p;
+@property int le;
+@property int l;
+@property int ls;
+@property int r;
+@end
+
+// rdar://9027673
+// Warning on future name lookup rule is removed.
+@implementation I
+- (int) Meth { return glob; } // no warning
+@synthesize glob;
+// rdar://8248681
+- (int) Meth1: (int) p {
+ extern int le;
+ int l = 1;
+ static int ls;
+ register int r;
+ p = le + ls + r;
+ return l;
+}
+@dynamic p;
+@dynamic le;
+@dynamic l;
+@dynamic ls;
+@dynamic r;
+@end
+
+
diff --git a/clang/test/SemaObjC/conflicting-ivar-test-1.m b/clang/test/SemaObjC/conflicting-ivar-test-1.m
new file mode 100644
index 0000000..a7c1d35
--- /dev/null
+++ b/clang/test/SemaObjC/conflicting-ivar-test-1.m
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -fobjc-fragile-abi -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface INTF
+{
+@public
+ int IVAR; // expected-note {{previous definition is here}}
+}
+@end
+
+@implementation INTF
+{
+@private
+
+ int XIVAR; // expected-error {{conflicting instance variable names: 'XIVAR' vs 'IVAR'}}
+}
+@end
+
+
+
+@interface INTF1
+{
+@public
+ int IVAR;
+ int IVAR1; // expected-error {{inconsistent number of instance variables specified}}
+}
+@end
+
+@implementation INTF1
+{
+@private
+
+ int IVAR;
+}
+@end
+
+
+@interface INTF2
+{
+@public
+ int IVAR;
+}
+@end
+
+@implementation INTF2
+{
+@private
+
+ int IVAR;
+ int IVAR1; // expected-error {{inconsistent number of instance variables specified}}
+}
+@end
+
+
+@interface INTF3
+{
+@public
+ int IVAR; // expected-note {{previous definition is here}}
+}
+@end
+
+@implementation INTF3
+{
+@private
+
+ short IVAR; // expected-error {{instance variable 'IVAR' has conflicting type: 'short' vs 'int'}}
+}
+@end
+
+@implementation INTF4 // expected-warning {{cannot find interface declaration for 'INTF4'}}
+{
+@private
+
+ short IVAR;
+}
+@end
+
+@interface INTF5
+{
+ char * ch;
+}
+@end
+
+@implementation INTF5
+{
+}
+@end
diff --git a/clang/test/SemaObjC/continuation-class-err.m b/clang/test/SemaObjC/continuation-class-err.m
new file mode 100644
index 0000000..d691f12
--- /dev/null
+++ b/clang/test/SemaObjC/continuation-class-err.m
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface ReadOnly
+{
+ id _object;
+ id _object1;
+}
+@property(readonly) id object; // expected-note {{property declared here}}
+@property(readwrite, assign) id object1; // expected-note {{property declared here}}
+@property (readonly) int indentLevel;
+@end
+
+@interface ReadOnly ()
+@property(readwrite, copy) id object; // expected-warning {{property attribute in continuation class does not match the primary class}}
+@property(readonly) id object1; // expected-error {{illegal redeclaration of property in continuation class 'ReadOnly' (attribute must be 'readwrite', while its primary must be 'readonly')}}
+@property (readwrite, assign) int indentLevel; // OK. assign the the default in any case.
+@end
+
+@protocol Proto
+ @property (copy) id fee; // expected-note {{property declared here}}
+@end
+
+@protocol Foo<Proto>
+ @property (copy) id foo; // expected-note {{property declared here}}
+@end
+
+@interface Bar <Foo> {
+ id _foo;
+ id _fee;
+}
+@end
+
+@interface Bar ()
+@property (copy) id foo; // expected-error {{illegal redeclaration of property in continuation class 'Bar' (attribute must be 'readwrite', while its primary must be 'readonly')}}
+@property (copy) id fee; // expected-error {{illegal redeclaration of property in continuation class 'Bar' (attribute must be 'readwrite', while its primary must be 'readonly')}}
+@end
+
+@implementation Bar
+@synthesize foo = _foo;
+@synthesize fee = _fee;
+@end
+
+// rdar://10752081
+@interface MyOtherClass() // expected-error {{cannot find interface declaration for 'MyOtherClass'}}
+{
+ id array;
+}
+@end
+
+@implementation MyOtherClass // expected-warning {{cannot find interface declaration for 'MyOtherClass'}}
+@end
diff --git a/clang/test/SemaObjC/continuation-class-property.m b/clang/test/SemaObjC/continuation-class-property.m
new file mode 100644
index 0000000..7d95424
--- /dev/null
+++ b/clang/test/SemaObjC/continuation-class-property.m
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// radar 7509234
+
+@protocol Foo
+@property (readonly, copy) id foos;
+@end
+
+@interface Bar <Foo> {
+}
+
+@end
+
+@interface Baz <Foo> {
+}
+@end
+
+@interface Bar ()
+@property (readwrite, copy) id foos;
+@end
+
+@interface Baz ()
+@property (readwrite, copy) id foos;
+@end
+
+
+// rdar://10142679
+@class NSString;
+
+typedef struct {
+ float width;
+ float length;
+} NSRect;
+
+@interface MyClass {
+}
+@property (readonly) NSRect foo; // expected-note {{property declared here}}
+@property (readonly, strong) NSString *bar; // expected-note {{property declared here}}
+@end
+
+@interface MyClass ()
+@property (readwrite) NSString *foo; // expected-error {{type of property 'NSString *' in continuation class does not match property type in primary class}}
+@property (readwrite, strong) NSRect bar; // expected-error {{type of property 'NSRect' in continuation class does not match property type in primary class}}
+@end
+
+// rdar://10655530
+struct S;
+struct S1;
+@interface STAdKitContext
+@property (nonatomic, readonly, assign) struct evhttp_request *httpRequest;
+@property (nonatomic, readonly, assign) struct S *httpRequest2;
+@property (nonatomic, readonly, assign) struct S1 *httpRequest3;
+@property (nonatomic, readonly, assign) struct S2 *httpRequest4;
+@end
+
+struct evhttp_request;
+struct S1;
+
+@interface STAdKitContext()
+@property (nonatomic, readwrite, assign) struct evhttp_request *httpRequest;
+@property (nonatomic, readwrite, assign) struct S *httpRequest2;
+@property (nonatomic, readwrite, assign) struct S1 *httpRequest3;
+@property (nonatomic, readwrite, assign) struct S2 *httpRequest4;
+@end
diff --git a/clang/test/SemaObjC/crash-label.m b/clang/test/SemaObjC/crash-label.m
new file mode 100644
index 0000000..b0ca5b5
--- /dev/null
+++ b/clang/test/SemaObjC/crash-label.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+ - (NSDictionary*) _executeScript:(NSString *)source { // expected-error 2 {{expected a type}} \
+ // expected-error {{missing context for method declaration}}
+Exit: [nilArgs release];
+}
+- (NSDictionary *) _setupKernelStandardMode:(NSString *)source { // expected-error 2 {{expected a type}} \
+ // expected-error {{missing context for method declaration}}
+ Exit: if(_ciKernel && !success ) {
diff --git a/clang/test/SemaObjC/custom-atomic-property.m b/clang/test/SemaObjC/custom-atomic-property.m
new file mode 100644
index 0000000..53eaeb0
--- /dev/null
+++ b/clang/test/SemaObjC/custom-atomic-property.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -Wcustom-atomic-properties -verify -Wno-objc-root-class %s
+
+@interface Foo
+@property (assign) Foo *myProp; // expected-note {{property declared here}} expected-note {{property declared here}}
+@end
+
+@implementation Foo
+ -(Foo*)myProp {return 0;} // expected-warning {{atomic by default property 'myProp' has a user defined getter (property should be marked 'atomic' if this is intended)}}
+ -(void)setMyProp:(Foo*)e {} // expected-warning {{atomic by default property 'myProp' has a user defined setter (property should be marked 'atomic' if this is intended)}}
+@end
+
+@interface Foo2 {
+ Foo *myProp;
+}
+@property (assign) Foo *myProp;
+@end
+
+@implementation Foo2
+@synthesize myProp; // no warnings.
+@end
diff --git a/clang/test/SemaObjC/debugger-cast-result-to-id.m b/clang/test/SemaObjC/debugger-cast-result-to-id.m
new file mode 100644
index 0000000..00a02be
--- /dev/null
+++ b/clang/test/SemaObjC/debugger-cast-result-to-id.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -funknown-anytype -fsyntax-only -fdebugger-support -fdebugger-cast-result-to-id -verify %s
+
+extern __unknown_anytype test0;
+extern __unknown_anytype test1();
+
+void test_unknown_anytype_receiver() {
+ (void)(int)[[test0 unknownMethod] otherUnknownMethod];;
+ (void)(id)[[test1() unknownMethod] otherUnknownMethod];
+}
+
+// rdar://10988847
+@class NSString; // expected-note {{forward declaration of class here}}
+
+void rdar10988847() {
+ id s = [NSString stringWithUTF8String:"foo"]; // expected-warning {{receiver 'NSString' is a forward class and corresponding @interface may not exist}}
+}
diff --git a/clang/test/SemaObjC/debugger-support.m b/clang/test/SemaObjC/debugger-support.m
new file mode 100644
index 0000000..21c096e
--- /dev/null
+++ b/clang/test/SemaObjC/debugger-support.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdebugger-support %s -emit-llvm -o - | FileCheck %s
+
+// rdar://problem/9416370
+void test0(id x) {
+ struct A { int w, x, y, z; };
+ struct A result = (struct A) [x makeStruct];
+ // CHECK: define void @test0(
+ // CHECK: [[X:%.*]] = alloca i8*, align 8
+ // CHECK-NEXT: [[RESULT:%.*]] = alloca [[A:%.*]], align 4
+ // CHECK-NEXT: store i8* {{%.*}}, i8** [[X]],
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[X]],
+ // CHECK-NEXT: [[T1:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_"
+ // CHECK-NEXT: [[T2:%.*]] = call { i64, i64 } bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to { i64, i64 } (i8*, i8*)*)(i8* [[T0]], i8* [[T1]])
+}
diff --git a/clang/test/SemaObjC/default-synthesize-1.m b/clang/test/SemaObjC/default-synthesize-1.m
new file mode 100644
index 0000000..c201e74
--- /dev/null
+++ b/clang/test/SemaObjC/default-synthesize-1.m
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+
+@interface NSObject
+- (void) release;
+- (id) retain;
+@end
+@class NSString;
+
+@interface SynthItAll : NSObject
+@property int howMany;
+@property (retain) NSString* what;
+@end
+
+@implementation SynthItAll
+//@synthesize howMany, what;
+@end
+
+
+@interface SynthSetter : NSObject
+@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair
+@property (nonatomic, retain) NSString* what;
+@end
+
+@implementation SynthSetter
+//@synthesize howMany, what;
+
+- (int) howMany {
+ return _howMany;
+}
+// - (void) setHowMany: (int) value
+
+- (NSString*) what {
+ return _what;
+}
+// - (void) setWhat: (NSString*) value
+@end
+
+
+@interface SynthGetter : NSObject
+@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair
+@property (nonatomic, retain) NSString* what;
+@end
+
+@implementation SynthGetter
+//@synthesize howMany, what;
+
+// - (int) howMany
+- (void) setHowMany: (int) value {
+ _howMany = value;
+}
+
+// - (NSString*) what
+- (void) setWhat: (NSString*) value {
+ if (_what != value) {
+ [_what release];
+ _what = [value retain];
+ }
+}
+@end
+
+
+@interface SynthNone : NSObject
+@property int howMany;
+@property (retain) NSString* what;
+@end
+
+@implementation SynthNone
+//@synthesize howMany, what; // REM: Redundant anyway
+
+- (int) howMany {
+ return howMany; // expected-error {{use of undeclared identifier 'howMany'}}
+}
+- (void) setHowMany: (int) value {
+ howMany = value; // expected-error {{use of undeclared identifier 'howMany'}}
+}
+
+- (NSString*) what {
+ return what; // expected-error {{use of undeclared identifier 'what'}}
+}
+- (void) setWhat: (NSString*) value {
+ if (what != value) { // expected-error {{use of undeclared identifier 'what'}}
+ [what release]; // expected-error {{use of undeclared identifier 'what'}}
+ what = [value retain]; // expected-error {{use of undeclared identifier 'what'}}
+ }
+}
+@end
+
+// rdar://8349319
+// No default synthesis if implementation has getter (readonly) and setter(readwrite) methods.
+@interface DSATextSearchResult
+@property(assign,readonly) float relevance;
+@property(assign,readonly) char isTitleMatch;
+@end
+
+@interface DSANodeSearchResult : DSATextSearchResult {}
+@end
+
+
+@implementation DSATextSearchResult
+-(char)isTitleMatch {
+ return (char)0;
+}
+
+-(float)relevance {
+ return 0.0;
+}
+@end
+
+@implementation DSANodeSearchResult
+-(id)initWithNode:(id )node relevance:(float)relevance isTitleMatch:(char)isTitleMatch {
+ relevance = 0.0;
+ isTitleMatch = 'a';
+ return self;
+}
+@end
+
diff --git a/clang/test/SemaObjC/default-synthesize-2.m b/clang/test/SemaObjC/default-synthesize-2.m
new file mode 100644
index 0000000..b95f263
--- /dev/null
+++ b/clang/test/SemaObjC/default-synthesize-2.m
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+// rdar://8843851
+
+@interface StopAccessingIvarsDirectlyExample
+@property(strong) id name, rank, serialNumber;
+@end
+
+@implementation StopAccessingIvarsDirectlyExample
+
+- (void)identifyYourSelf {
+ if (self.name && self.rank && self.serialNumber)
+ self.name = 0;
+}
+
+// @synthesize name, rank, serialNumber;
+// default synthesis allows direct access to property ivars.
+- (id)init {
+ _name = _rank = _serialNumber = 0;
+ return self;
+}
+
+- (void)dealloc {
+}
+@end
+
+
+// Test2
+@interface Test2
+@property(strong, nonatomic) id object;
+@end
+
+// object has user declared setter/getter so it won't be
+// default synthesized; thus causing user error.
+@implementation Test2
+- (id) bar { return object; } // expected-error {{use of undeclared identifier 'object'}}
+- (void)setObject:(id)newObject {}
+- (id)object { return 0; }
+@end
+
+// Test3
+@interface Test3
+{
+ id uid;
+}
+@property (readwrite, assign) id uid;
+@end
+
+@implementation Test3
+// Oops, forgot to write @synthesize! will be default synthesized
+- (void) myMethod {
+ self.uid = 0; // Use of the “setter”
+ uid = 0; // Use of the wrong instance variable
+ _uid = 0; // Use of the property instance variable
+}
+@end
+
+@interface Test4 {
+ id _var;
+}
+@property (readwrite, assign) id var;
+@end
+
+
+// default synthesize property named 'var'
+@implementation Test4
+- (id) myMethod {
+ return self->_var; // compiles because 'var' is synthesized by default
+}
+@end
+
+@interface Test5
+{
+ id _var;
+}
+@property (readwrite, assign) id var;
+@end
+
+// default synthesis of property 'var'
+@implementation Test5
+- (id) myMethod {
+ Test5 *foo = 0;
+ return foo->_var; // OK
+}
+@end
+
+@interface Test6
+{
+ id _var; // expected-note {{'_var' declared here}}
+}
+@property (readwrite, assign) id var;
+@end
+
+// no default synthesis. So error is expected.
+@implementation Test6
+- (id) myMethod
+{
+ return var; // expected-error {{use of undeclared identifier 'var'}}
+}
+@synthesize var = _var;
+@end
+
+int* _object;
+
+@interface Test7
+@property (readwrite, assign) id object;
+@end
+
+// With default synthesis, '_object' is be the synthesized ivar not the global
+// 'int*' object. So no error.
+@implementation Test7
+- (id) myMethod {
+ return _object;
+}
+@end
+
diff --git a/clang/test/SemaObjC/default-synthesize-3.m b/clang/test/SemaObjC/default-synthesize-3.m
new file mode 100644
index 0000000..606ece3
--- /dev/null
+++ b/clang/test/SemaObjC/default-synthesize-3.m
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+
+#if __has_attribute(objc_requires_property_definitions)
+__attribute ((objc_requires_property_definitions))
+#endif
+@interface NoAuto // expected-note 2 {{class with specified objc_requires_property_definitions attribute is declared here}}
+@property int NoAutoProp; // expected-note 2 {{property declared here}}
+@end
+
+@implementation NoAuto // expected-warning {{property 'NoAutoProp' requires method 'NoAutoProp' to be defined}} \
+ // expected-warning {{property 'NoAutoProp' requires method 'setNoAutoProp:'}}
+@end
+
+__attribute ((objc_requires_property_definitions)) // redundant, just for testing
+@interface Sub : NoAuto // expected-note 3 {{class with specified objc_requires_property_definitions attribute is declared here}}
+@property (copy) id SubProperty; // expected-note 2 {{property declared here}}
+@end
+
+@implementation Sub // expected-warning {{property 'SubProperty' requires method 'SubProperty' to be defined}} \
+ // expected-warning {{property 'SubProperty' requires method 'setSubProperty:' to be defined}}
+@end
+
+@interface Deep : Sub
+@property (copy) id DeepProperty;
+@property (copy) id DeepSynthProperty;
+@property (copy) id DeepMustSynthProperty; // expected-note {{property declared here}}
+@end
+
+@implementation Deep // expected-warning {{property 'DeepMustSynthProperty' requires method 'setDeepMustSynthProperty:' to be defined}}
+@dynamic DeepProperty;
+@synthesize DeepSynthProperty;
+- (id) DeepMustSynthProperty { return 0; }
+@end
+
+__attribute ((objc_requires_property_definitions))
+@interface Deep(CAT) // expected-error {{attributes may not be specified on a category}}
+@end
+
+__attribute ((objc_requires_property_definitions)) // expected-error {{objc_requires_property_definitions attribute may only be specified on a class}}
+@protocol P @end
diff --git a/clang/test/SemaObjC/default-synthesize.m b/clang/test/SemaObjC/default-synthesize.m
new file mode 100644
index 0000000..e6ea0a5
--- /dev/null
+++ b/clang/test/SemaObjC/default-synthesize.m
@@ -0,0 +1,140 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+
+@interface NSString @end
+
+@interface NSObject @end
+
+@interface SynthItAll
+@property int howMany;
+@property (retain) NSString* what;
+@end
+
+@implementation SynthItAll
+#if !__has_feature(objc_default_synthesize_properties)
+@synthesize howMany, what;
+#endif
+@end
+
+
+@interface SynthSetter : NSObject
+@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair
+@property (nonatomic, retain) NSString* what;
+@end
+
+@implementation SynthSetter
+#if !__has_feature(objc_default_synthesize_properties)
+@synthesize howMany, what;
+#endif
+
+- (int) howMany {
+ return self.howMany;
+}
+// - (void) setHowMany: (int) value
+
+- (NSString*) what {
+ return self.what;
+}
+// - (void) setWhat: (NSString*) value
+@end
+
+
+@interface SynthGetter : NSObject
+@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair
+@property (nonatomic, retain) NSString* what;
+@end
+
+@implementation SynthGetter
+#if !__has_feature(objc_default_synthesize_properties)
+@synthesize howMany, what;
+#endif
+
+// - (int) howMany
+- (void) setHowMany: (int) value {
+ self.howMany = value;
+}
+
+// - (NSString*) what
+- (void) setWhat: (NSString*) value {
+ if (self.what != value) {
+ }
+}
+@end
+
+
+@interface SynthNone : NSObject
+@property int howMany;
+@property (retain) NSString* what;
+@end
+
+@implementation SynthNone
+#if !__has_feature(objc_default_synthesize_properties)
+@synthesize howMany, what; // REM: Redundant anyway
+#endif
+
+- (int) howMany {
+ return self.howMany;
+}
+- (void) setHowMany: (int) value {
+ self.howMany = value;
+}
+
+- (NSString*) what {
+ return self.what;
+}
+- (void) setWhat: (NSString*) value {
+ if (self.what != value) {
+ }
+}
+@end
+
+@protocol TopProtocol
+ @property (readonly) id myString;
+@end
+
+@interface TopClass <TopProtocol>
+{
+ id myString;
+}
+@end
+
+@interface SubClass : TopClass <TopProtocol>
+@end
+
+@implementation SubClass @end
+
+// rdar://7920807
+@interface C @end
+@interface C (Category)
+@property int p; // expected-note 2 {{property declared here}}
+@end
+@implementation C (Category) // expected-warning {{property 'p' requires method 'p' to be defined}} \
+ // expected-warning {{property 'p' requires method 'setP:' to be defined}}
+@end
+
+// Don't complain if a property is already @synthesized by usr.
+@interface D
+{
+}
+@property int PROP;
+@end
+
+@implementation D
+- (int) Meth { return self.PROP; }
+#if __has_feature(objc_default_synthesize_properties)
+@synthesize PROP=IVAR;
+#endif
+@end
+
+// rdar://10567333
+@protocol MyProtocol
+@property (nonatomic, strong) NSString *requiredString; // expected-note {{property declared here}}
+
+@optional
+@property (nonatomic, strong) NSString *optionalString;
+@end
+
+@interface MyClass <MyProtocol>
+@end
+
+@implementation MyClass // expected-warning {{auto property synthesis will not synthesize property declared in a protocol}}
+@end
diff --git a/clang/test/SemaObjC/deref-interface.m b/clang/test/SemaObjC/deref-interface.m
new file mode 100644
index 0000000..3201412
--- /dev/null
+++ b/clang/test/SemaObjC/deref-interface.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
+
+@interface NSView
+ - (id)initWithView:(id)realView;
+@end
+
+@implementation NSView
+ - (id)initWithView:(id)realView {
+ *(NSView *)self = *(NSView *)realView; // expected-error {{cannot assign to class object}}
+ }
+@end
+
diff --git a/clang/test/SemaObjC/direct-synthesized-ivar-access.m b/clang/test/SemaObjC/direct-synthesized-ivar-access.m
new file mode 100644
index 0000000..54b7110
--- /dev/null
+++ b/clang/test/SemaObjC/direct-synthesized-ivar-access.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -Wnonfragile-abi2 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+// rdar://8673791
+// rdar://9943851
+
+@interface I {
+}
+
+@property int IVAR;
+- (int) OK;
+@end
+
+@implementation I
+- (int) Meth { return _IVAR; }
+- (int) OK { return self.IVAR; }
+@end
diff --git a/clang/test/SemaObjC/dist-object-modifiers.m b/clang/test/SemaObjC/dist-object-modifiers.m
new file mode 100644
index 0000000..aa7e340
--- /dev/null
+++ b/clang/test/SemaObjC/dist-object-modifiers.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://7076235
+
+@protocol P
+- (bycopy id)serverPID; // expected-note {{previous declaration is here}}
+- (void)doStuff:(bycopy id)clientId; // expected-note {{previous declaration is here}}
+- (bycopy id)Ok;
++ (oneway id) stillMore : (byref id)Arg : (bycopy oneway id)Arg1; // expected-note 3 {{previous declaration is here}}
+@end
+
+@interface I <P>
+- (id)Ok;
+@end
+
+@implementation I
+- (id)serverPID { return 0; } // expected-warning {{conflicting distributed object modifiers on return type in implementation of 'serverPID'}}
+- (void)doStuff:(id)clientId { } // expected-warning {{conflicting distributed object modifiers on parameter type in implementation of 'doStuff:'}}
+- (bycopy id)Ok { return 0; }
++ (id) stillMore : (id)Arg : (bycopy id)Arg1 { return Arg; } // expected-warning {{conflicting distributed object modifiers on return type in implementation of 'stillMore::'}} \
+ // expected-warning 2{{conflicting distributed object modifiers on parameter type in implementation of 'stillMore::'}}
+@end
diff --git a/clang/test/SemaObjC/duplicate-ivar-check.m b/clang/test/SemaObjC/duplicate-ivar-check.m
new file mode 100644
index 0000000..260c215
--- /dev/null
+++ b/clang/test/SemaObjC/duplicate-ivar-check.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface B1 {
+@public
+ double fill_B; // expected-note {{previous declaration is here}}
+ unsigned : 0;
+}
+@end
+
+@interface B : B1 {
+@public
+ int one; // expected-note {{previous declaration is here}}
+ int one; // expected-error {{duplicate member 'one'}}
+ unsigned : 0;
+}
+@end
+
+@interface A : B {
+@public
+ int fill_B; // expected-error {{duplicate member 'fill_B'}}
+}
+@end
diff --git a/clang/test/SemaObjC/duplicate-ivar-in-class-extension.m b/clang/test/SemaObjC/duplicate-ivar-in-class-extension.m
new file mode 100644
index 0000000..9b9d58c
--- /dev/null
+++ b/clang/test/SemaObjC/duplicate-ivar-in-class-extension.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface Root @end
+
+@interface SuperClass : Root
+{
+ int iSuper; // expected-note {{previous declaration is here}}
+}
+@end
+
+@interface SubClass : SuperClass {
+ int ivar; // expected-error {{duplicate member 'ivar'}}
+ int another_ivar; // expected-error {{duplicate member 'another_ivar'}}
+ int iSuper; // expected-error {{duplicate member 'iSuper'}}
+}
+@end
+
+@interface SuperClass () {
+ int ivar; // expected-note {{previous declaration is here}}
+}
+@end
+
+@interface Root () {
+ int another_ivar; // expected-note {{previous declaration is here}}
+}
+@end
+
+@implementation SubClass
+-(int) method {
+ return self->ivar; // would be ambiguous if the duplicate ivar were allowed
+}
+@end
diff --git a/clang/test/SemaObjC/duplicate-property-class-extension.m b/clang/test/SemaObjC/duplicate-property-class-extension.m
new file mode 100644
index 0000000..bf48ed6
--- /dev/null
+++ b/clang/test/SemaObjC/duplicate-property-class-extension.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://7629420
+
+@interface Foo
+@property (readonly) char foo;
+@property (readwrite) char bar; // expected-note {{property declared here}}
+@end
+
+@interface Foo ()
+@property (readwrite) char foo; // expected-note 2 {{property declared here}}
+@property (readwrite) char NewProperty; // expected-note 2 {{property declared here}}
+@property (readwrite) char bar; // expected-error{{illegal redeclaration of 'readwrite' property in continuation class 'Foo' (perhaps you intended this to be a 'readwrite' redeclaration of a 'readonly' public property?)}}
+@end
+
+@interface Foo ()
+@property (readwrite) char foo; // expected-error {{property has a previous declaration}}
+@property (readwrite) char NewProperty; // expected-error {{property has a previous declaration}}
+@end
+
+@interface Foo ()
+@property (readonly) char foo; // expected-error {{property has a previous declaration}}
+@property (readwrite) char NewProperty; // expected-error {{property has a previous declaration}}
+@end
+
diff --git a/clang/test/SemaObjC/duplicate-property.m b/clang/test/SemaObjC/duplicate-property.m
new file mode 100644
index 0000000..bc1fe71
--- /dev/null
+++ b/clang/test/SemaObjC/duplicate-property.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface Foo {
+ id x;
+}
+@property (nonatomic, retain) id x; // expected-note{{property declared here}}
+@property (nonatomic, retain) id x; // expected-error{{property has a previous declaration}}
+@end
diff --git a/clang/test/SemaObjC/enhanced-proto-2.m b/clang/test/SemaObjC/enhanced-proto-2.m
new file mode 100644
index 0000000..28b03d9
--- /dev/null
+++ b/clang/test/SemaObjC/enhanced-proto-2.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
+
+@protocol MyProto1
+@optional
+- (void) FOO;
+@optional
+- (void) FOO1;
+@optional
+- (void) REQ;
+@optional
+@end
+
+@interface MyProto2 <MyProto1>
+- (void) FOO2;
+- (void) FOO3;
+@end
+
+@implementation MyProto2
+- (void) FOO2{}
+- (void) FOO3{}
+@end
diff --git a/clang/test/SemaObjC/enum-fixed-type.m b/clang/test/SemaObjC/enum-fixed-type.m
new file mode 100644
index 0000000..95153be
--- /dev/null
+++ b/clang/test/SemaObjC/enum-fixed-type.m
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#if !__has_feature(objc_fixed_enum)
+# error Enumerations with a fixed underlying type are not supported
+#endif
+
+typedef long Integer;
+
+typedef enum : Integer { Enumerator1, Enumerator2 } Enumeration;
+
+int array[sizeof(Enumeration) == sizeof(long)? 1 : -1];
+
+
+enum Color { Red, Green, Blue };
+
+struct X {
+ enum Color : 4;
+ enum Color field1: 4;
+ enum Other : Integer field2;
+ enum Other : Integer field3 : 4;
+ enum : Integer { Blah, Blarg } field4 : 4;
+};
+
+void test() {
+ long value = 2;
+ Enumeration e = value;
+}
+
+// <rdar://10381507>
+typedef enum : long { Foo } IntegerEnum;
+int arr[(sizeof(typeof(Foo)) == sizeof(typeof(IntegerEnum))) - 1];
+int arr1[(sizeof(typeof(Foo)) == sizeof(typeof(long))) - 1];
+int arr2[(sizeof(typeof(IntegerEnum)) == sizeof(typeof(long))) - 1];
+
+// <rdar://problem/10760113>
+typedef enum : long long { Bar = -1 } LongLongEnum;
+int arr3[(long long)Bar == (long long)-1 ? 1 : -1];
diff --git a/clang/test/SemaObjC/err-ivar-access-in-class-method.m b/clang/test/SemaObjC/err-ivar-access-in-class-method.m
new file mode 100644
index 0000000..2a5e0dc
--- /dev/null
+++ b/clang/test/SemaObjC/err-ivar-access-in-class-method.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://10593227
+
+@class UIWindow;
+
+@interface CNAppDelegate
+
+@property (strong, nonatomic) UIWindow *window;
+
+@end
+
+
+@interface CNAppDelegate ()
+@property (nonatomic,retain) id foo;
+@end
+
+@implementation CNAppDelegate
+@synthesize foo;
+@synthesize window = _window;
+
++(void)myClassMethod;
+{
+ foo = 0; // expected-error {{instance variable 'foo' accessed in class method}}
+}
+@end
diff --git a/clang/test/SemaObjC/error-implicit-property.m b/clang/test/SemaObjC/error-implicit-property.m
new file mode 100644
index 0000000..ea0587a
--- /dev/null
+++ b/clang/test/SemaObjC/error-implicit-property.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -verify %s
+// rdar://11273060
+
+@interface I
+- (void) setP : (int)arg;
+@end
+
+@interface J
+ - (int) P;
+@end
+
+@interface K @end
+
+@interface II @end
+
+@implementation II
+- (void) Meth : (I*) arg {
+ arg.P++; // expected-error {{no getter method 'P' for increment of property}}
+ --arg.P; // expected-error {{no getter method 'P' for decrement of property}}
+}
+- (void) Meth1 : (J*) arg {
+ arg.P++; // expected-error {{no setter method 'setP:' for increment of property}}
+ arg.P--; // expected-error {{no setter method 'setP:' for decrement of property}}
+}
+
+- (void) Meth2 : (K*) arg {
+ arg.P++; // expected-error {{property 'P' not found on object of type 'K *'}}
+ arg.P--; // expected-error {{property 'P' not found on object of type 'K *'}}
+}
+@end
diff --git a/clang/test/SemaObjC/error-missing-getter.m b/clang/test/SemaObjC/error-missing-getter.m
new file mode 100644
index 0000000..3c91ab2
--- /dev/null
+++ b/clang/test/SemaObjC/error-missing-getter.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://8155806
+
+@interface Subclass
+{
+ int setterOnly;
+}
+- (void) setSetterOnly : (int) arg;
+@end
+
+int func (int arg, Subclass *x) {
+ if (x.setterOnly) { // expected-error {{expected getter method not found on object of type 'Subclass *'}}
+ x.setterOnly = 1;
+ }
+ func(x.setterOnly + 1, x); // expected-error {{expected getter method not found on object of type 'Subclass *'}}
+ int i = x.setterOnly + 1; // expected-error {{expected getter method not found on object of type 'Subclass *'}}
+ return x.setterOnly + 1; // expected-error {{expected getter method not found on object of type 'Subclass *'}}
+}
+
diff --git a/clang/test/SemaObjC/error-property-gc-attr.m b/clang/test/SemaObjC/error-property-gc-attr.m
new file mode 100644
index 0000000..5680296
--- /dev/null
+++ b/clang/test/SemaObjC/error-property-gc-attr.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface INTF
+{
+ id IVAR; // expected-note {{ivar is declared here}}
+ __weak id II;
+ __weak id WID;
+ id ID;
+ __weak INTF* AWEAK;
+ __weak INTF* WI;
+}
+@property (assign) __weak id pweak;
+@property (assign) __weak id WID;
+@property (assign) __strong id NOT;
+@property (assign) id ID;
+@property (assign) INTF* AWEAK;
+@property (assign) __weak INTF* WI;
+@end
+
+@implementation INTF
+@synthesize pweak=IVAR; // expected-error {{existing ivar 'IVAR' for __weak property 'pweak' must be __weak}}
+@synthesize NOT=II; // expected-error {{existing ivar 'II' for strong property 'NOT' may not be __weak}}
+@synthesize WID;
+@synthesize ID;
+@synthesize AWEAK; // expected-error {{existing ivar 'AWEAK' for strong property 'AWEAK' may not be __weak}}
+@synthesize WI;
+@end
diff --git a/clang/test/SemaObjC/exprs.m b/clang/test/SemaObjC/exprs.m
new file mode 100644
index 0000000..b198cba
--- /dev/null
+++ b/clang/test/SemaObjC/exprs.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 %s -fsyntax-only -fblocks -verify -Wno-unreachable-code
+
+// rdar://6597252
+Class test1(Class X) {
+ return 1 ? X : X;
+}
+
+
+// rdar://6079877
+void test2() {
+ id str = @"foo"
+ "bar\0" // no-warning
+ @"baz" " blarg";
+ id str2 = @"foo"
+ "bar"
+ @"baz"
+ " b\0larg"; // no-warning
+
+
+ if (@encode(int) == "foo") { } // expected-warning {{result of comparison against @encode is unspecified}}
+}
+
+#define MAX(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
+void (^foo)(int, int) = ^(int x, int y) { int z = MAX(x, y); };
+
+
+
+// rdar://8445858
+@class Object;
+static Object *g;
+void test3(Object *o) {
+ // this is ok.
+ __sync_bool_compare_and_swap(&g, 0, o);
+}
+
+@class Incomplete_ObjC_class; // expected-note{{forward declaration of class here}}
+struct Incomplete_struct; // expected-note {{forward declaration}}
+
+void test_encode() {
+ (void)@encode(Incomplete_ObjC_class); // expected-error {{incomplete type}}
+ (void)@encode(struct Incomplete_struct); // expected-error {{incomplete type}}
+ (void)@encode(Incomplete_ObjC_class*);
+ (void)@encode(id);
+}
diff --git a/clang/test/SemaObjC/foreach.m b/clang/test/SemaObjC/foreach.m
new file mode 100644
index 0000000..d0e0f7b
--- /dev/null
+++ b/clang/test/SemaObjC/foreach.m
@@ -0,0 +1,57 @@
+/* RUN: %clang_cc1 -Wall -fsyntax-only -verify -std=c89 -pedantic %s
+ */
+
+@class NSArray;
+
+void f(NSArray *a) {
+ id keys;
+ for (int i in a); /* expected-error{{selector element type 'int' is not a valid object}} */
+ for ((id)2 in a); /* expected-error{{selector element is not a valid lvalue}} */
+ for (2 in a); /* expected-error{{selector element is not a valid lvalue}} */
+
+ /* This should be ok, 'thisKey' should be scoped to the loop in question,
+ * and no diagnostics even in pedantic mode should happen.
+ * rdar://6814674
+ */
+ for (id thisKey in keys);
+ for (id thisKey in keys);
+}
+
+/* // rdar://9072298 */
+@protocol NSObject @end
+
+@interface NSObject <NSObject> {
+ Class isa;
+}
+@end
+
+typedef struct {
+ unsigned long state;
+ id *itemsPtr;
+ unsigned long *mutationsPtr;
+ unsigned long extra[5];
+} NSFastEnumerationState;
+
+@protocol NSFastEnumeration
+
+- (unsigned long)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(unsigned long)len;
+
+@end
+
+int main ()
+{
+ NSObject<NSFastEnumeration>* collection = ((void*)0);
+ for (id thing in collection) { }
+
+ return 0;
+}
+
+/* rdar://problem/11068137 */
+@interface Test2
+@property (assign) id prop;
+@end
+void test2(NSObject<NSFastEnumeration> *collection) {
+ Test2 *obj;
+ for (obj.prop in collection) { /* expected-error {{selector element is not a valid lvalue}} */
+ }
+}
diff --git a/clang/test/SemaObjC/format-arg-attribute.m b/clang/test/SemaObjC/format-arg-attribute.m
new file mode 100644
index 0000000..6edb8fd
--- /dev/null
+++ b/clang/test/SemaObjC/format-arg-attribute.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s
+
+@class NSString;
+
+extern NSString *fa2 (const NSString *) __attribute__((format_arg(1)));
+extern NSString *fa3 (NSString *) __attribute__((format_arg(1)));
+
+extern void fc1 (const NSString *) __attribute__((format_arg)); // expected-error {{attribute takes one argument}}
+extern void fc2 (const NSString *) __attribute__((format_arg())); // expected-error {{attribute takes one argument}}
+extern void fc3 (const NSString *) __attribute__((format_arg(1, 2))); // expected-error {{attribute takes one argument}}
+
+struct s1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to functions}}
+union u1 { int i; } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to functions}}
+enum e1 { E1V0 } __attribute__((format_arg(1))); // expected-warning {{'format_arg' attribute only applies to functions}}
+
+extern NSString *ff3 (const NSString *) __attribute__((format_arg(3-2)));
+extern NSString *ff4 (const NSString *) __attribute__((format_arg(foo))); // expected-error {{attribute takes one argument}}
+
+/* format_arg formats must take and return a string. */
+extern NSString *fi0 (int) __attribute__((format_arg(1))); // expected-error {{format argument not a string type}}
+extern NSString *fi1 (NSString *) __attribute__((format_arg(1)));
+
+extern NSString *fi2 (NSString *) __attribute__((format_arg(1)));
+
+extern int fi3 (const NSString *) __attribute__((format_arg(1))); // expected-error {{function does not return NSString}}
+extern NSString *fi4 (const NSString *) __attribute__((format_arg(1)));
+extern NSString *fi5 (const NSString *) __attribute__((format_arg(1)));
diff --git a/clang/test/SemaObjC/format-strings-objc.m b/clang/test/SemaObjC/format-strings-objc.m
new file mode 100644
index 0000000..987889b
--- /dev/null
+++ b/clang/test/SemaObjC/format-strings-objc.m
@@ -0,0 +1,188 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -Wformat-nonliteral -fsyntax-only -fblocks -verify -Wno-objc-root-class %s
+
+//===----------------------------------------------------------------------===//
+// The following code is reduced using delta-debugging from
+// Foundation.h (Mac OS X).
+//
+// It includes the basic definitions for the test cases below.
+// Not including Foundation.h directly makes this test case both svelt and
+// portable to non-Mac platforms.
+//===----------------------------------------------------------------------===//
+
+#include <stdarg.h>
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...);
+extern void NSLogv(NSString *format, va_list args);
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@interface NSObject <NSObject> {} @end
+typedef float CGFloat;
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length; @end
+@interface NSSimpleCString : NSString {} @end
+@interface NSConstantString : NSSimpleCString @end
+extern void *_NSConstantStringClassReference;
+
+typedef const struct __CFString * CFStringRef;
+extern void CFStringCreateWithFormat(CFStringRef format, ...) __attribute__((format(CFString, 1, 2)));
+
+int printf(const char * restrict, ...) ;
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+void check_nslog(unsigned k) {
+ NSLog(@"%d%%", k); // no-warning
+ NSLog(@"%s%lb%d", "unix", 10,20); // expected-warning {{invalid conversion specifier 'b'}}
+}
+
+// Check type validation
+extern void NSLog2(int format, ...) __attribute__((format(__NSString__, 1, 2))); // expected-error {{format argument not an NSString}}
+extern void CFStringCreateWithFormat2(int *format, ...) __attribute__((format(CFString, 1, 2))); // expected-error {{format argument not a CFString}}
+
+// <rdar://problem/7068334> - Catch use of long long with int arguments.
+void rdar_7068334() {
+ long long test = 500;
+ printf("%i ",test); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}}
+ NSLog(@"%i ",test); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}}
+}
+
+// <rdar://problem/7697748>
+void rdar_7697748() {
+ NSLog(@"%@!"); // expected-warning{{more '%' conversions than data arguments}}
+}
+
+@protocol Foo;
+
+void test_p_conversion_with_objc_pointer(id x, id<Foo> y) {
+ printf("%p", x); // no-warning
+ printf("%p", y); // no-warning
+}
+
+// <rdar://problem/10696348>, PR 10274 - CFString and NSString formats are ignored
+extern void MyNSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+extern void MyCFStringCreateWithFormat(CFStringRef format, ...) __attribute__((format(__CFString__, 1, 2)));
+
+void check_mylog() {
+ MyNSLog(@"%@"); // expected-warning {{more '%' conversions than data arguments}}
+ // FIXME: find a way to test CFString too, but I don't know how to create constant CFString.
+}
+
+// PR 10275 - format function attribute isn't checked in Objective-C methods
+@interface Foo
++ (id)fooWithFormat:(NSString *)fmt, ... __attribute__((format(__NSString__, 1, 2)));
++ (id)fooWithCStringFormat:(const char *)format, ... __attribute__((format(__printf__, 1, 2)));
+@end
+
+void check_method() {
+ [Foo fooWithFormat:@"%@"]; // expected-warning {{more '%' conversions than data arguments}}
+ [Foo fooWithCStringFormat:"%@"]; // expected-warning {{invalid conversion specifier '@'}}
+}
+
+// Warn about using BOOL with %@
+void rdar10743758(id x) {
+ NSLog(@"%@ %@", x, (BOOL) 1); // expected-warning {{format specifies type 'id' but the argument has type 'BOOL' (aka 'signed char')}}
+}
+
+NSString *test_literal_propagation(void) {
+ const char * const s1 = "constant string %s"; // expected-note {{format string is defined here}}
+ printf(s1); // expected-warning {{more '%' conversions than data arguments}}
+ const char * const s5 = "constant string %s"; // expected-note {{format string is defined here}}
+ const char * const s2 = s5;
+ printf(s2); // expected-warning {{more '%' conversions than data arguments}}
+
+ const char * const s3 = (const char *)0;
+ printf(s3); // no-warning (NULL is a valid format string)
+
+ NSString * const ns1 = @"constant string %s"; // expected-note {{format string is defined here}}
+ NSLog(ns1); // expected-warning {{more '%' conversions than data arguments}}
+ NSString * const ns5 = @"constant string %s"; // expected-note {{format string is defined here}}
+ NSString * const ns2 = ns5;
+ NSLog(ns2); // expected-warning {{more '%' conversions than data arguments}}
+ NSString * ns3 = ns1;
+ NSLog(ns3); // expected-warning {{format string is not a string literal}}}
+}
+
+// Do not emit warnings when using NSLocalizedString
+extern NSString *GetLocalizedString(NSString *str);
+#define NSLocalizedString(key) GetLocalizedString(key)
+
+void check_NSLocalizedString() {
+ [Foo fooWithFormat:NSLocalizedString(@"format"), @"arg"]; // no-warning
+}
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+// Test that %S, %C, %ls check for 16 bit types in ObjC strings, as described at
+// http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265
+
+void test_percent_S() {
+ const unsigned short data[] = { 'a', 'b', 0 };
+ const unsigned short* ptr = data;
+ NSLog(@"%S", ptr); // no-warning
+
+ const wchar_t* wchar_ptr = L"ab";
+ NSLog(@"%S", wchar_ptr); // expected-warning{{format specifies type 'const unsigned short *' but the argument has type 'const wchar_t *'}}
+}
+
+void test_percent_ls() {
+ const unsigned short data[] = { 'a', 'b', 0 };
+ const unsigned short* ptr = data;
+ NSLog(@"%ls", ptr); // no-warning
+
+ const wchar_t* wchar_ptr = L"ab";
+ NSLog(@"%ls", wchar_ptr); // expected-warning{{format specifies type 'const unsigned short *' but the argument has type 'const wchar_t *'}}
+}
+
+void test_percent_C() {
+ const unsigned short data = 'a';
+ NSLog(@"%C", data); // no-warning
+
+ const wchar_t wchar_data = L'a';
+ NSLog(@"%C", wchar_data); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'wchar_t'}}
+}
+
+// Test that %@ works with toll-free bridging (<rdar://problem/10814120>).
+void test_toll_free_bridging(CFStringRef x) {
+ NSLog(@"%@", x); // no-warning
+}
+
+@interface Bar
++ (void)log:(NSString *)fmt, ...;
++ (void)log2:(NSString *)fmt, ... __attribute__((format(NSString, 1, 2)));
+@end
+
+@implementation Bar
+
++ (void)log:(NSString *)fmt, ... {
+ va_list ap;
+ va_start(ap,fmt);
+ NSLogv(fmt, ap); // expected-warning{{format string is not a string literal}}
+ va_end(ap);
+}
+
++ (void)log2:(NSString *)fmt, ... {
+ va_list ap;
+ va_start(ap,fmt);
+ NSLogv(fmt, ap); // no-warning
+ va_end(ap);
+}
+
+@end
+
+
+// Test that it is okay to use %p with the address of a block.
+void rdar11049844_aux();
+int rdar11049844() {
+ typedef void (^MyBlock)(void);
+ MyBlock x = ^void() { rdar11049844_aux(); };
+ printf("%p", x); // no-warning
+}
+
diff --git a/clang/test/SemaObjC/forward-class-1.m b/clang/test/SemaObjC/forward-class-1.m
new file mode 100644
index 0000000..85c6c87
--- /dev/null
+++ b/clang/test/SemaObjC/forward-class-1.m
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@class FOO, BAR; // expected-note {{forward declaration of class here}}
+@class FOO, BAR;
+
+@interface INTF : FOO // expected-error {{attempting to use the forward class 'FOO' as superclass of 'INTF'}}
+@end
+
+@interface FOO
+- (BAR*) Meth1;
+- (FOO*) Meth2;
+@end
+
+@interface INTF1 : FOO
+@end
+
+@interface INTF2 : INTF1 // expected-note {{previous definition is here}}
+@end
+
+
+@class INTF1, INTF2;
+
+@interface INTF2 : INTF1 // expected-error {{duplicate interface definition for class 'INTF2'}}
+@end
+
+// 2nd test of a forward class declaration matching a typedef name
+// referring to class object.
+// FIXME. This may become a negative test should we decide to make this an error.
+//
+@interface NSObject @end
+
+@protocol XCElementP @end
+
+typedef NSObject <XCElementP> XCElement; // expected-note {{previous definition is here}}
+
+@interface XCElementMainImp {
+ XCElement * _editingElement;
+}
+@end
+
+@class XCElement; // expected-warning {{redefinition of forward class 'XCElement' of a typedef name of an object type is ignored}}
+
+@implementation XCElementMainImp
+- (XCElement *)editingElement { return _editingElement; }
+@end
+
+
+// rdar://9653341
+@class B; // expected-note {{forward declaration of class here}}
+@interface A : B {} // expected-error {{attempting to use the forward class 'B' as superclass of 'A'}}
+@end
+
+@interface B : A {}
+@end
+
+@implementation A @end
+@implementation B @end
+
diff --git a/clang/test/SemaObjC/forward-class-receiver.m b/clang/test/SemaObjC/forward-class-receiver.m
new file mode 100644
index 0000000..9bcb039
--- /dev/null
+++ b/clang/test/SemaObjC/forward-class-receiver.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface I
++ new; // expected-note {{method 'new' is used for the forward class}}
+@end
+Class isa;
+
+@class NotKnown; // expected-note{{forward declaration of class here}}
+
+void foo(NotKnown *n) {
+ [isa new];
+ [NotKnown new]; /* expected-warning {{receiver 'NotKnown' is a forward class and corresponding}} */
+}
diff --git a/clang/test/SemaObjC/forward-class-redeclare.m b/clang/test/SemaObjC/forward-class-redeclare.m
new file mode 100644
index 0000000..80dc335
--- /dev/null
+++ b/clang/test/SemaObjC/forward-class-redeclare.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://10733000
+
+@interface NSObject @end
+
+@protocol PLAssetContainer
+@property (readonly, nonatomic, retain) id assets;
+@end
+
+
+typedef NSObject <PLAssetContainer> PLAlbum; // expected-note {{previous definition is here}}
+
+@class PLAlbum; // expected-warning {{redefinition of forward class 'PLAlbum' of a typedef name of an object type is ignore}}
+
+@interface PLPhotoBrowserController
+{
+ PLAlbum *_album;
+}
+@end
+
+@interface WPhotoViewController:PLPhotoBrowserController
+@end
+
+@implementation WPhotoViewController
+- (void)_prepareForContracting
+{
+ (void)_album.assets;
+}
+@end
diff --git a/clang/test/SemaObjC/gc-attributes.m b/clang/test/SemaObjC/gc-attributes.m
new file mode 100644
index 0000000..2f54328
--- /dev/null
+++ b/clang/test/SemaObjC/gc-attributes.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc -fsyntax-only -verify %s
+
+@interface A
+@end
+
+void f0(__strong A**); // expected-note{{passing argument to parameter here}}
+
+void test_f0() {
+ A *a;
+ static __weak A *a2;
+ f0(&a);
+ f0(&a2); // expected-warning{{passing 'A *__weak *' to parameter of type 'A *__strong *' discards qualifiers}}
+}
+
+void f1(__weak A**); // expected-note{{passing argument to parameter here}}
+
+void test_f1() {
+ A *a;
+ __strong A *a2;
+ f1(&a);
+ f1(&a2); // expected-warning{{passing 'A *__strong *' to parameter of type 'A *__weak *' discards qualifiers}}
+}
diff --git a/clang/test/SemaObjC/gcc-cast-ext.m b/clang/test/SemaObjC/gcc-cast-ext.m
new file mode 100644
index 0000000..30e0dce
--- /dev/null
+++ b/clang/test/SemaObjC/gcc-cast-ext.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -verify -fms-extensions -Wno-objc-root-class %s
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+typedef struct _NSRange { } NSRange;
+
+@class PBXFileReference;
+
+@interface PBXDocBookmark
++ alloc; // expected-note {{method definition for 'alloc' not found}}
+- autorelease; // expected-note {{method definition for 'autorelease' not found}}
+@end
+
+// GCC allows pointer expressions in integer constant expressions.
+struct {
+ char control[((int)(char *)2)];
+} xx;
+
+@implementation PBXDocBookmark // expected-warning {{incomplete implementation}}
+
++ (id)bookmarkWithFileReference:(PBXFileReference *)fileRef gylphRange:(NSRange)range anchor:(NSString *)htmlAnchor
+{
+ NSRange r = (NSRange)range;
+ return [[[self alloc] initWithFileReference:fileRef gylphRange:(NSRange)range anchor:(NSString *)htmlAnchor] autorelease]; // expected-warning {{method '-initWithFileReference:gylphRange:anchor:' not found (return type defaults to 'id')}}
+}
+@end
diff --git a/clang/test/SemaObjC/ibaction.m b/clang/test/SemaObjC/ibaction.m
new file mode 100644
index 0000000..9c59d7a
--- /dev/null
+++ b/clang/test/SemaObjC/ibaction.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
+
+@interface Foo
+{
+ __attribute__((iboutlet)) id myoutlet;
+}
++ (void) __attribute__((ibaction)) myClassMethod:(id)msg; // expected-warning{{ibaction attribute can only be applied to Objective-C instance methods}}
+- (void) __attribute__((ibaction)) myMessage:(id)msg;
+@end
+
+@implementation Foo
++ (void) __attribute__((ibaction)) myClassMethod:(id)msg {} // expected-warning{{ibaction attribute can only be applied to Objective-C instance methods}}
+// Normally attributes should not be attached to method definitions, but
+// we allow 'ibaction' to be attached because it can be expanded from
+// the IBAction macro.
+- (void) __attribute__((ibaction)) myMessage:(id)msg {} // no-warning
+@end
diff --git a/clang/test/SemaObjC/iboutletcollection-attr.m b/clang/test/SemaObjC/iboutletcollection-attr.m
new file mode 100644
index 0000000..22c21a7
--- /dev/null
+++ b/clang/test/SemaObjC/iboutletcollection-attr.m
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
+// rdar://8308053
+
+@class NSObject;
+
+@interface I {
+ __attribute__((iboutletcollection(I))) id ivar1;
+ __attribute__((iboutletcollection(id))) id ivar2;
+ __attribute__((iboutletcollection())) id ivar3;
+ __attribute__((iboutletcollection)) id ivar4;
+}
+@property (nonatomic, retain) __attribute__((iboutletcollection(I))) id prop1;
+@property (nonatomic, retain) __attribute__((iboutletcollection(id))) id prop2;
+@property (nonatomic, retain) __attribute__((iboutletcollection())) id prop3;
+@property (nonatomic, retain) __attribute__((iboutletcollection)) id prop4;
+@end
+
+typedef void *PV;
+@interface BAD {
+ __attribute__((iboutletcollection(I, 1))) id ivar1; // expected-error {{attribute takes one argument}}
+ __attribute__((iboutletcollection(B))) id ivar2; // expected-error {{invalid type 'B' as argument of iboutletcollection attribute}}
+ __attribute__((iboutletcollection(PV))) id ivar3; // expected-error {{invalid type 'PV' as argument of iboutletcollection attribute}}
+ __attribute__((iboutletcollection(PV))) void *ivar4; // expected-warning {{ivar with 'iboutletcollection' attribute must be an object type (invalid 'void *')}}
+ __attribute__((iboutletcollection(int))) id ivar5; // expected-error {{type argument of iboutletcollection attribute cannot be a builtin type}}
+ __attribute__((iboutlet)) int ivar6; // expected-warning {{ivar with 'iboutlet' attribute must be an object type}}
+}
+@property (nonatomic, retain) __attribute__((iboutletcollection(I,2,3))) id prop1; // expected-error {{attribute takes one argument}}
+@property (nonatomic, retain) __attribute__((iboutletcollection(B))) id prop2; // expected-error {{invalid type 'B' as argument of iboutletcollection attribute}}
+
+@property __attribute__((iboutletcollection(BAD))) int prop3; // expected-warning {{property with 'iboutletcollection' attribute must be an object type (invalid 'int')}}
+@end
+
+// rdar://10296078
+@interface ParentRDar10296078 @end
+@class NSArray;
+@protocol RDar10296078_Protocol;
+@class RDar10296078_OtherClass;
+
+@interface RDar10296078 : ParentRDar10296078
+@property (nonatomic, strong)
+ __attribute__((iboutletcollection(RDar10296078_OtherClass<RDar10296078_Protocol>))) NSArray *stuff;
+@end
diff --git a/clang/test/SemaObjC/id-isa-ref.m b/clang/test/SemaObjC/id-isa-ref.m
new file mode 100644
index 0000000..c2debb0
--- /dev/null
+++ b/clang/test/SemaObjC/id-isa-ref.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef struct objc_object {
+ struct objc_class *isa;
+} *id;
+
+@interface NSObject {
+ struct objc_class *isa;
+}
+@end
+@interface Whatever : NSObject
++self;
+@end
+
+static void func() {
+
+ id x;
+
+ // rdar://8290002
+ [(*x).isa self]; // expected-warning {{direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()}}
+ [x->isa self]; // expected-warning {{direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()}}
+
+ Whatever *y;
+
+ // GCC allows this, with the following warning:
+ // instance variable 'isa' is @protected; this will be a hard error in the future
+ //
+ // FIXME: see if we can avoid the 2 warnings that follow the error.
+ [(*y).isa self]; // expected-error {{instance variable 'isa' is protected}} \
+ expected-warning{{receiver type 'struct objc_class *' is not 'id' or interface pointer, consider casting it to 'id'}} \
+ expected-warning{{method '-self' not found (return type defaults to 'id')}}
+ [y->isa self]; // expected-error {{instance variable 'isa' is protected}} \
+ expected-warning{{receiver type 'struct objc_class *' is not 'id' or interface pointer, consider casting it to 'id'}} \
+ expected-warning{{method '-self' not found (return type defaults to 'id')}}
+}
diff --git a/clang/test/SemaObjC/id.m b/clang/test/SemaObjC/id.m
new file mode 100644
index 0000000..27b84de
--- /dev/null
+++ b/clang/test/SemaObjC/id.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol Foo;
+
+Class T;
+id<Foo> S;
+id R;
+void foo() {
+ // Test assignment compatibility of Class and id. No warning should be
+ // produced.
+ // rdar://6770142 - Class and id<foo> are compatible.
+ S = T; // expected-warning {{incompatible pointer types assigning to 'id<Foo>' from 'Class'}}
+ T = S; // expected-warning {{incompatible pointer types assigning to 'Class' from 'id<Foo>'}}
+ R = T; T = R;
+ R = S; S = R;
+}
+
+// Test attempt to redefine 'id' in an incompatible fashion.
+typedef int id; // FIXME: Decide how we want to deal with this (now that 'id' is more of a built-in type).
+id b;
+
diff --git a/clang/test/SemaObjC/id_builtin.m b/clang/test/SemaObjC/id_builtin.m
new file mode 100644
index 0000000..a1431d6
--- /dev/null
+++ b/clang/test/SemaObjC/id_builtin.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+// id is now builtin. There should be no errors.
+id obj;
+
+@interface Foo
+
+- defaultToId;
+
+@end
diff --git a/clang/test/SemaObjC/idiomatic-parentheses.m b/clang/test/SemaObjC/idiomatic-parentheses.m
new file mode 100644
index 0000000..417b948
--- /dev/null
+++ b/clang/test/SemaObjC/idiomatic-parentheses.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wparentheses -Wno-objc-root-class %s
+
+// Don't warn about some common ObjC idioms unless we have -Widiomatic-parentheses on.
+// <rdar://problem/7382435>
+
+@interface Object
+- (id) init;
+- (id) initWithInt: (int) i;
+- (void) iterate: (id) coll;
+- (id) nextObject;
+@end
+
+@implementation Object
+- (id) init {
+ if (self = [self init]) {
+ }
+ return self;
+}
+
+- (id) initWithInt: (int) i {
+ if (self = [self initWithInt: i]) {
+ }
+ return self;
+}
+
+- (void) iterate: (id) coll {
+ id cur;
+ while (cur = [coll nextObject]) {
+ }
+}
+
+- (id) nextObject {
+ return self;
+}
+@end
diff --git a/clang/test/SemaObjC/ignore-qualifier-on-qualified-id.m b/clang/test/SemaObjC/ignore-qualifier-on-qualified-id.m
new file mode 100644
index 0000000..36a2c1a
--- /dev/null
+++ b/clang/test/SemaObjC/ignore-qualifier-on-qualified-id.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
+// rdar://10667659
+
+@protocol NSCopying @end
+
+@interface NSString <NSCopying>
+@end
+
+void takeId(id test) {}
+
+void takeCopyableId(id<NSCopying> test) {}
+
+id<NSCopying> Test () {
+ NSString const *constantString = @"Test";
+ takeId(constantString);
+ takeCopyableId(constantString);
+ id ID = constantString;
+ id<NSCopying> IDQNSCopying = constantString;
+ return constantString;
+}
diff --git a/clang/test/SemaObjC/ignore-weakimport-method.m b/clang/test/SemaObjC/ignore-weakimport-method.m
new file mode 100644
index 0000000..d71cebf
--- /dev/null
+++ b/clang/test/SemaObjC/ignore-weakimport-method.m
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+@interface foo
++ (void) cx __attribute__((weak_import));
+- (void) x __attribute__((weak_import));
+@end
+
diff --git a/clang/test/SemaObjC/illegal-nonarc-bridged-cast.m b/clang/test/SemaObjC/illegal-nonarc-bridged-cast.m
new file mode 100644
index 0000000..a5bb01f
--- /dev/null
+++ b/clang/test/SemaObjC/illegal-nonarc-bridged-cast.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fblocks -verify %s
+// rdar://10597832
+
+typedef const void *CFTypeRef;
+typedef const struct __CFString *CFStringRef;
+
+@interface NSString
+@end
+
+CFTypeRef CFCreateSomething();
+CFStringRef CFCreateString();
+CFTypeRef CFGetSomething();
+CFStringRef CFGetString();
+
+id CreateSomething();
+NSString *CreateNSString();
+
+void from_cf() {
+ id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}}
+ id obj2 = (__bridge_transfer NSString*)CFCreateString(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}}
+ (__bridge int*)CFCreateSomething(); // expected-warning {{'__bridge' casts have no effect when not using ARC}} \
+ // expected-warning {{expression result unused}}
+ id obj3 = (__bridge id)CFGetSomething(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
+ id obj4 = (__bridge NSString*)CFGetString(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
+}
+
+void to_cf(id obj) {
+ CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // expected-warning {{'__bridge_retained' casts have no effect when not using ARC}}
+ CFStringRef cf2 = (__bridge_retained CFStringRef)CreateNSString(); // expected-warning {{'__bridge_retained' casts have no effect when not using ARC}}
+ CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
+ CFStringRef cf4 = (__bridge CFStringRef)CreateNSString(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
+}
+
+void fixits() {
+ id obj1 = (id)CFCreateSomething();
+ CFTypeRef cf1 = (CFTypeRef)CreateSomething();
+}
+
+#pragma clang diagnostic ignored "-Warc-bridge-casts-disallowed-in-nonarc"
+
+void to_cf_ignored(id obj) {
+ CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // no-warning
+ CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // no-warning
+}
diff --git a/clang/test/SemaObjC/incompatible-protocol-qualified-types.m b/clang/test/SemaObjC/incompatible-protocol-qualified-types.m
new file mode 100644
index 0000000..494d23e
--- /dev/null
+++ b/clang/test/SemaObjC/incompatible-protocol-qualified-types.m
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -pedantic -fsyntax-only -verify %s
+
+@protocol MyProto1
+@end
+
+@protocol MyProto2
+@end
+
+@interface INTF @end
+
+INTF <MyProto1> * Func(INTF <MyProto1, MyProto2> *p2) // expected-note{{passing argument to parameter 'p2' here}}
+{
+ return p2;
+}
+
+
+INTF <MyProto1> * Func1(INTF <MyProto1, MyProto2> *p2)
+{
+ return p2;
+}
+
+INTF <MyProto1, MyProto2> * Func2(INTF <MyProto1> *p2)
+{
+ Func(p2); // expected-warning {{incompatible pointer types passing 'INTF<MyProto1> *' to parameter of type 'INTF<MyProto1,MyProto2> *'}}
+ return p2; // expected-warning {{incompatible pointer types returning 'INTF<MyProto1> *' from a function with result type 'INTF<MyProto1,MyProto2> *'}}
+}
+
+
+
+INTF <MyProto1> * Func3(INTF <MyProto2> *p2)
+{
+ return p2; // expected-warning {{incompatible pointer types returning 'INTF<MyProto2> *' from a function with result type 'INTF<MyProto1> *'}}
+}
+
+
+INTF <MyProto1, MyProto2> * Func4(INTF <MyProto2, MyProto1> *p2)
+{
+ return p2;
+}
+
diff --git a/clang/test/SemaObjC/incomplete-implementation.m b/clang/test/SemaObjC/incomplete-implementation.m
new file mode 100644
index 0000000..54f66ef
--- /dev/null
+++ b/clang/test/SemaObjC/incomplete-implementation.m
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface I
+- Meth; // expected-note{{method definition for 'Meth' not found}} \
+ // expected-note{{method 'Meth' declared here}}
+@end
+
+@implementation I // expected-warning{{incomplete implementation}}
+@end
+
+@implementation I(CAT)
+- Meth {return 0;} // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+@end
+
+#pragma GCC diagnostic ignored "-Wincomplete-implementation"
+@interface I2
+- Meth; // expected-note{{method 'Meth' declared here}}
+@end
+
+@implementation I2
+@end
+
+@implementation I2(CAT)
+- Meth {return 0;} // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+@end
+
+@interface Q
+@end
+
+// rdar://10336158
+@implementation Q
+
+__attribute__((visibility("default")))
+@interface QN // expected-error {{Objective-C declarations may only appear in global scope}}
+{
+}
+@end
+
+@end
+
diff --git a/clang/test/SemaObjC/inst-method-lookup-in-root.m b/clang/test/SemaObjC/inst-method-lookup-in-root.m
new file mode 100644
index 0000000..babd2a0
--- /dev/null
+++ b/clang/test/SemaObjC/inst-method-lookup-in-root.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol P
+- (id) inst_in_proto;
+@end
+
+@interface Object <P>
+- (id) inst_in_root;
+@end
+
+@interface Base
+@end
+
+@interface Derived: Base
+- (id)starboard;
+@end
+
+void foo(void) {
+ Class receiver;
+
+ [Derived starboard]; // expected-warning {{method '+starboard' not found}}
+
+ [receiver starboard]; // expected-warning {{instance method 'starboard' is being used on 'Class'}}
+ [receiver inst_in_root]; // Ok!
+ [receiver inst_in_proto]; // Ok!
+}
+
diff --git a/clang/test/SemaObjC/instancetype.m b/clang/test/SemaObjC/instancetype.m
new file mode 100644
index 0000000..40f35d9
--- /dev/null
+++ b/clang/test/SemaObjC/instancetype.m
@@ -0,0 +1,190 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#if !__has_feature(objc_instancetype)
+# error Missing 'instancetype' feature macro.
+#endif
+
+@interface Root
++ (instancetype)alloc;
+- (instancetype)init; // expected-note{{overridden method is part of the 'init' method family}}
+- (instancetype)self;
+- (Class)class;
+
+@property (assign) Root *selfProp;
+- (instancetype)selfProp;
+@end
+
+@protocol Proto1
+@optional
+- (instancetype)methodInProto1;
+@end
+
+@protocol Proto2
+@optional
+- (instancetype)methodInProto2; // expected-note{{overridden method returns an instance of its class type}}
+- (instancetype)otherMethodInProto2; // expected-note{{overridden method returns an instance of its class type}}
+@end
+
+@interface Subclass1 : Root
+- (instancetype)initSubclass1;
+- (void)methodOnSubclass1;
++ (instancetype)allocSubclass1;
+@end
+
+@interface Subclass2 : Root
+- (instancetype)initSubclass2;
+- (void)methodOnSubclass2;
+@end
+
+// Sanity check: the basic initialization pattern.
+void test_instancetype_alloc_init_simple() {
+ Root *r1 = [[Root alloc] init];
+ Subclass1 *sc1 = [[Subclass1 alloc] init];
+}
+
+// Test that message sends to instancetype methods have the right type.
+void test_instancetype_narrow_method_search() {
+ // instancetype on class methods
+ Subclass1 *sc1 = [[Subclass1 alloc] initSubclass2]; // expected-warning{{'Subclass1' may not respond to 'initSubclass2'}}
+ Subclass2 *sc2 = [[Subclass2 alloc] initSubclass2]; // okay
+
+ // instancetype on instance methods
+ [[[Subclass1 alloc] init] methodOnSubclass2]; // expected-warning{{'Subclass1' may not respond to 'methodOnSubclass2'}}
+ [[[Subclass2 alloc] init] methodOnSubclass2];
+
+ // instancetype on class methods using protocols
+ typedef Subclass1<Proto1> SC1Proto1;
+ typedef Subclass1<Proto2> SC1Proto2;
+ [[SC1Proto1 alloc] methodInProto2]; // expected-warning{{method '-methodInProto2' not found (return type defaults to 'id')}}
+ [[SC1Proto2 alloc] methodInProto2];
+
+ // instancetype on instance methods
+ Subclass1<Proto1> *sc1proto1 = 0;
+ [[sc1proto1 self] methodInProto2]; // expected-warning{{method '-methodInProto2' not found (return type defaults to 'id')}}
+ Subclass1<Proto2> *sc1proto2 = 0;
+ [[sc1proto2 self] methodInProto2];
+
+ // Exact type checks
+ typeof([[Subclass1 alloc] init]) *ptr1 = (Subclass1 **)0;
+ typeof([[Subclass2 alloc] init]) *ptr2 = (Subclass2 **)0;
+
+ // Message sends to Class.
+ Subclass1<Proto1> *sc1proto1_2 = [[[sc1proto1 class] alloc] init];
+
+ // Property access
+ [sc1proto1.self methodInProto2]; // expected-warning{{method '-methodInProto2' not found (return type defaults to 'id')}}
+ [sc1proto2.self methodInProto2];
+ [Subclass1.alloc initSubclass2]; // expected-warning{{'Subclass1' may not respond to 'initSubclass2'}}
+ [Subclass2.alloc initSubclass2];
+
+ [sc1proto1.selfProp methodInProto2]; // expected-warning{{method '-methodInProto2' not found (return type defaults to 'id')}}
+ [sc1proto2.selfProp methodInProto2];
+}
+
+// Test that message sends to super methods have the right type.
+@interface Subsubclass1 : Subclass1
+- (instancetype)initSubclass1;
++ (instancetype)allocSubclass1;
+
+- (void)onlyInSubsubclass1;
+@end
+
+@implementation Subsubclass1
+- (instancetype)initSubclass1 {
+ // Check based on method search.
+ [[super initSubclass1] methodOnSubclass2]; // expected-warning{{'Subsubclass1' may not respond to 'methodOnSubclass2'}}
+ [super.initSubclass1 methodOnSubclass2]; // expected-warning{{'Subsubclass1' may not respond to 'methodOnSubclass2'}}
+
+ self = [super init]; // common pattern
+
+ // Exact type check.
+ typeof([super initSubclass1]) *ptr1 = (Subsubclass1**)0;
+
+ return self;
+}
+
++ (instancetype)allocSubclass1 {
+ // Check based on method search.
+ [[super allocSubclass1] methodOnSubclass2]; // expected-warning{{'Subsubclass1' may not respond to 'methodOnSubclass2'}}
+
+ // The ASTs don't model super property accesses well enough to get this right
+ [super.allocSubclass1 methodOnSubclass2]; // expected-warning{{'Subsubclass1' may not respond to 'methodOnSubclass2'}}
+
+ // Exact type check.
+ typeof([super allocSubclass1]) *ptr1 = (Subsubclass1**)0;
+
+ return [super allocSubclass1];
+}
+
+- (void)onlyInSubsubclass1 {}
+@end
+
+// Check compatibility rules for inheritance of related return types.
+@class Subclass4;
+
+@interface Subclass3 <Proto1, Proto2>
+- (Subclass3 *)methodInProto1;
+- (Subclass4 *)methodInProto2; // expected-warning{{method is expected to return an instance of its class type 'Subclass3', but is declared to return 'Subclass4 *'}}
+@end
+
+@interface Subclass4 : Root
++ (Subclass4 *)alloc; // okay
+- (Subclass3 *)init; // expected-warning{{method is expected to return an instance of its class type 'Subclass4', but is declared to return 'Subclass3 *'}}
+- (id)self; // expected-note{{overridden method is part of the 'self' method family}}
+- (instancetype)initOther;
+@end
+
+@protocol Proto3 <Proto1, Proto2>
+@optional
+- (id)methodInProto1;
+- (Subclass1 *)methodInProto2;
+- (int)otherMethodInProto2; // expected-warning{{protocol method is expected to return an instance of the implementing class, but is declared to return 'int'}}
+@end
+
+@implementation Subclass4
++ (id)alloc {
+ return self; // expected-warning{{incompatible pointer types casting 'Class' to type 'Subclass4 *'}}
+}
+
+- (Subclass3 *)init { return 0; } // don't complain: we lost the related return type
+
+- (Subclass3 *)self { return 0; } // expected-warning{{method is expected to return an instance of its class type 'Subclass4', but is declared to return 'Subclass3 *'}}
+
+- (Subclass4 *)initOther { return 0; }
+
+@end
+
+// Check that inherited related return types influence the types of
+// message sends.
+void test_instancetype_inherited() {
+ [[Subclass4 alloc] initSubclass1]; // expected-warning{{'Subclass4' may not respond to 'initSubclass1'}}
+ [[Subclass4 alloc] initOther];
+}
+
+// Check that related return types tighten up the semantics of
+// Objective-C method implementations.
+@implementation Subclass2
+- (instancetype)initSubclass2 {
+ Subclass1 *sc1 = [[Subclass1 alloc] init];
+ return sc1; // expected-warning{{incompatible pointer types casting 'Subclass1 *' to type 'Subclass2 *'}}
+}
+- (void)methodOnSubclass2 {}
+- (id)self {
+ Subclass1 *sc1 = [[Subclass1 alloc] init];
+ return sc1; // expected-warning{{incompatible pointer types casting 'Subclass1 *' to type 'Subclass2 *'}}
+}
+@end
+
+@interface MyClass : Root
++ (int)myClassMethod;
+@end
+
+@implementation MyClass
++ (int)myClassMethod { return 0; }
+
+- (void)blah {
+ int i = [[MyClass self] myClassMethod];
+}
+
+@end
+
diff --git a/clang/test/SemaObjC/interface-1.m b/clang/test/SemaObjC/interface-1.m
new file mode 100644
index 0000000..87c2307
--- /dev/null
+++ b/clang/test/SemaObjC/interface-1.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi %s -fsyntax-only -verify
+// rdar://5957506
+
+@interface NSWhatever :
+NSObject // expected-error {{cannot find interface declaration for 'NSObject'}}
+<NSCopying> // expected-error {{cannot find protocol declaration for 'NSCopying'}}
+@end
+
+
+// rdar://6095245
+@interface A
+{
+ int x
+} // expected-error {{expected ';' at end of declaration list}}
+@end
+
+
+// rdar://4304469
+@interface INT1
+@end
+
+void test2() {
+ // rdar://6827200
+ INT1 b[3]; // expected-error {{array of interface 'INT1' is invalid (probably should be an array of pointers)}}
+ INT1 *c = &b[0];
+ ++c;
+}
+
+
+// rdar://6611778
+@interface FOO // expected-note {{previous definition is here}}
+- (void)method;
+@end
+
+@interface FOO // expected-error {{duplicate interface definition for class 'FOO'}}
+- (void)method2;
+@end
+
diff --git a/clang/test/SemaObjC/interface-layout-2.m b/clang/test/SemaObjC/interface-layout-2.m
new file mode 100644
index 0000000..02b1403
--- /dev/null
+++ b/clang/test/SemaObjC/interface-layout-2.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+@interface A
+{
+ int ivar;
+}
+@end
+
+@interface B : A
+- (int)ivar;
+@end
+
+@implementation B
+- (int)ivar {
+ return ivar;
+}
+@end
diff --git a/clang/test/SemaObjC/interface-layout.m b/clang/test/SemaObjC/interface-layout.m
new file mode 100644
index 0000000..a8a93f0
--- /dev/null
+++ b/clang/test/SemaObjC/interface-layout.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple i386-apple-darwin9 -fobjc-fragile-abi
+typedef struct objc_object {} *id;
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+
+@protocol NSObject
+- (BOOL) isEqual:(id) object;
+@end
+
+@protocol NSCopying
+- (id) copyWithZone:(NSZone *) zone;
+@end
+
+@interface NSObject < NSObject > {}
+@end
+
+extern id NSAllocateObject (Class aClass, NSUInteger extraBytes, NSZone * zone);
+
+@interface MyClassBase : NSObject < NSCopying > {}
+@end
+
+@interface MyClassDirectNode : MyClassBase < NSCopying >
+{
+ @public NSUInteger attributeRuns[((1024 - 16 - sizeof (MyClassBase)) / (sizeof (NSUInteger) + sizeof (void *)))];
+}
+@end
diff --git a/clang/test/SemaObjC/interface-scope-2.m b/clang/test/SemaObjC/interface-scope-2.m
new file mode 100644
index 0000000..60fd900
--- /dev/null
+++ b/clang/test/SemaObjC/interface-scope-2.m
@@ -0,0 +1,128 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-apple-darwin9 -Wno-objc-root-class %s
+// FIXME: must also compile as Objective-C++
+
+// <rdar://problem/6487662>
+typedef struct objc_selector *SEL;
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (BOOL)respondsToSelector:(SEL)aSelector;
+@end
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+@protocol NSMutableCopying
+- (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+@protocol NSCoding
+- (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
+@end
+@class NSString, NSData;
+typedef struct _NSPoint {}
+NSRange;
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
+@end
+@interface NSMutableString : NSString
+- (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)aString;
+@end
+@class NSArray, NSDictionary, NSMapTable;
+@interface NSResponder : NSObject <NSCoding> {}
+@end
+@protocol NSAnimatablePropertyContainer
+- (id)animator;
+@end
+extern NSString *NSAnimationTriggerOrderIn ;
+@interface NSView : NSResponder <NSAnimatablePropertyContainer> {
+ struct __VFlags2 {} _vFlags2;
+}
+@end
+@class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView;
+@interface FooiagramView : NSView {
+id _delegate;
+}
+@end
+@class FooiagramView;
+@interface _FooiagramViewReserved : NSObject {
+@public
+ NSMutableString *_typeToSelectString;
+ struct _FooiagramViewFlags {
+ unsigned int delegateRespondsToPrintInfoForBarView : 1;
+ } _dvFlags;
+}
+@end
+extern _FooiagramViewReserved *_FooiagramViewBarViewReserved(FooiagramView *BarView);
+@interface FooiagramView (FooiagramViewPrivate)
++ (Class)_defaultBarToolManagerClass;
+@end
+@implementation FooiagramView
+static NSMapTable *_defaultMenuForClass = 0;
+- (void)setDelegate:(id)delegate {
+ if (_delegate != delegate) {
+ struct _FooiagramViewFlags *dvFlags =
+ &_FooiagramViewBarViewReserved(self)->_dvFlags;
+ if (_delegate != ((void *)0)) {
+ dvFlags->delegateRespondsToPrintInfoForBarView = [_delegate respondsToSelector:@selector(printInfoForBarView:)];
+ }
+ }
+}
+@end
+
+// <rdar://problem/6487684>
+@interface WizKing_MIKeep {
+struct __LoreStuffNode *_historyStuff;
+}
+@end
+typedef struct __LoreStuffNode {} LoreStuffNode;
+@implementation WizKing_MIKeep
+- init {
+ LoreStuffNode *node;
+ node = &(_historyStuff[1]);
+ return 0;
+}
+@end
+
+// <rdar://problem/6487702>
+typedef long unsigned int __darwin_size_t;
+typedef __darwin_size_t size_t;
+void *memset(void *, int, size_t);
+@class NSString, NSURL, NSError;
+@interface OingoWerdnaPeon : NSObject {}
+@end typedef enum {
+OingoPT_SmashOK, OingoPT_NoSuchFile, }
+OingoWerdnaPeonIOMethod;
+@interface OingoWerdnaPeonSmashDrivel : NSObject <NSCopying> {}
+@end
+@interface OingoBoingoContraptionPeon : OingoWerdnaPeon {
+struct _OingoBoingoContraptionPeonFlags {}
+_nfttFlags;
+}
+@end
+@implementation OingoBoingoContraptionPeon
++ (void)initialize {}
+- (id)initWithSmashDrivel:(OingoWerdnaPeonSmashDrivel *)info {
+ if (self != ((void *)0)) {
+ (void)memset(&_nfttFlags, 0, sizeof(struct _OingoBoingoContraptionPeonFlags));
+ }
+ return 0;
+}
+@end
+
+@interface Blah {
+ struct X {
+ int x;
+ } value;
+}
+@end
+
+@implementation Blah
+- (int)getValue {
+ struct X *xp = &value;
+ return xp->x;
+}
+@end
diff --git a/clang/test/SemaObjC/interface-scope.m b/clang/test/SemaObjC/interface-scope.m
new file mode 100644
index 0000000..0671dae
--- /dev/null
+++ b/clang/test/SemaObjC/interface-scope.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface I1 {
+@private
+ int x;
+ struct {
+ unsigned int x : 3;
+ unsigned int y : 3;
+ } flags;
+ int y;
+}
+@end
diff --git a/clang/test/SemaObjC/interface-tu-variable.m b/clang/test/SemaObjC/interface-tu-variable.m
new file mode 100644
index 0000000..b8779cc
--- /dev/null
+++ b/clang/test/SemaObjC/interface-tu-variable.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface XX
+int x; // expected-error {{cannot declare variable inside @interface or @protocol}}
+int one=1; // expected-error {{cannot declare variable inside @interface or @protocol}}
+@end
+
+@protocol PPP
+int ddd; // expected-error {{cannot declare variable inside @interface or @protocol}}
+@end
+
+@interface XX(CAT)
+ char * III; // expected-error {{cannot declare variable inside @interface or @protocol}}
+ extern int OK;
+@end
+
+@interface XX()
+ char * III2; // expected-error {{cannot declare variable inside @interface or @protocol}}
+ extern int OK2;
+@end
+
+
+int main( int argc, const char *argv[] ) {
+ return x+one;
+}
+
diff --git a/clang/test/SemaObjC/invalid-code.m b/clang/test/SemaObjC/invalid-code.m
new file mode 100644
index 0000000..290f9d5
--- /dev/null
+++ b/clang/test/SemaObjC/invalid-code.m
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -Wno-objc-root-class %s
+
+// rdar://6124613
+void test1() {
+ void *xyzzy = 0;
+ void *p = @xyzzy; // expected-error {{unexpected '@' in program}}
+}
+
+// <rdar://problem/7495713>
+// This previously triggered a crash because the class has not been defined.
+@implementation RDar7495713 (rdar_7495713_cat) // expected-error{{cannot find interface declaration for 'RDar7495713'}}
+- (id) rdar_7495713 {
+ __PRETTY_FUNCTION__; // expected-warning{{expression result unused}}
+}
+@end
+
+// <rdar://problem/7881045>
+// This previously triggered a crash because a ';' was expected after the @throw statement.
+void foo() {
+ @throw (id)0 // expected-error{{expected ';' after @throw}}
+}
+
+// <rdar://problem/10415026>
+@class NSView;
+@implementation IBFillView(IBFillViewIntegration) // expected-error {{cannot find interface declaration for 'IBFillView'}}
+- (NSView *)ibDesignableContentView {
+ [Cake lie]; // expected-error {{undeclared}}
+ return self;
+}
+@end
+
+@interface I
+@end
+@interface I2
+@end
+
+@implementation I // expected-note {{started here}}
+-(void) foo {}
+
+@implementation I2 // expected-error {{missing '@end'}}
+-(void) foo2 {}
+@end
+
+@end // expected-error {{'@end' must appear in an Objective-C context}}
+
+@class ForwardBase;
+@implementation SomeI : ForwardBase // expected-error {{cannot find interface declaration for 'ForwardBase', superclass of 'SomeI'}} \
+ // expected-warning {{cannot find interface declaration for 'SomeI'}}
+-(void)meth {}
+@end
+
+@interface I3
+__attribute__((unavailable)) @interface I4 @end // expected-error {{Objective-C declarations may only appear in global scope}}
+@end
diff --git a/clang/test/SemaObjC/invalid-objc-decls-1.m b/clang/test/SemaObjC/invalid-objc-decls-1.m
new file mode 100644
index 0000000..46338bb
--- /dev/null
+++ b/clang/test/SemaObjC/invalid-objc-decls-1.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface Super @end
+Super s1; // expected-error{{interface type cannot be statically allocated}}
+
+extern Super e1; // expected-error{{interface type cannot be statically allocated}}
+
+struct S {
+ Super s1; // expected-error{{interface type cannot be statically allocated}}
+};
+
+@protocol P1 @end
+
+@interface INTF
+{
+ Super ivar1; // expected-error{{interface type cannot be statically allocated}}
+}
+@end
+
+struct whatever {
+ Super objField; // expected-error{{interface type cannot be statically allocated}}
+};
+
+@interface MyIntf
+{
+ Super<P1> ivar1; // expected-error{{interface type cannot be statically allocated}}
+}
+@end
+
+Super foo( // expected-error{{interface type 'Super' cannot be returned by value; did you forget * in 'Super'}}
+ Super parm1) { // expected-error{{interface type 'Super' cannot be passed by value; did you forget * in 'Super'}}
+ Super p1; // expected-error{{interface type cannot be statically allocated}}
+ return p1;
+}
+
+@interface NSMutableSet @end
+
+@interface DVTDummyAnnotationProvider
+ @property(readonly) NSMutableSet annotations; // expected-error{{interface type cannot be statically allocated}}
+
+@end
+
diff --git a/clang/test/SemaObjC/invalid-receiver.m b/clang/test/SemaObjC/invalid-receiver.m
new file mode 100644
index 0000000..1174dd2
--- /dev/null
+++ b/clang/test/SemaObjC/invalid-receiver.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef struct NotAClass {
+ int a, b;
+} NotAClass;
+
+void foo() {
+ [NotAClass nonexistent_method]; // expected-error {{receiver type 'NotAClass' (aka 'struct NotAClass') is not an Objective-C class}}
+}
diff --git a/clang/test/SemaObjC/invalid-typename.m b/clang/test/SemaObjC/invalid-typename.m
new file mode 100644
index 0000000..50dd188
--- /dev/null
+++ b/clang/test/SemaObjC/invalid-typename.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@class NSString, NSArray;
+
+@protocol ISyncSessionCallback
+- (oneway void)clientWithId:(bycopy NSString *)clientId
+ canBeginSyncingPlanWithId:(bycopy NSString *)planId
+ syncModes:(bycopy NSArray /* ISDSyncState */ *)syncModes
+ entities:(bycopy NSArray /* ISDEntity */ *)entities
+ truthPullers:(bycopy NSDictionary /* NSString -> [NSString] */ *)truthPullers; // expected-error{{expected ')'}} expected-note {{to match this '('}}
+@end
+
diff --git a/clang/test/SemaObjC/ivar-access-package.m b/clang/test/SemaObjC/ivar-access-package.m
new file mode 100644
index 0000000..abc3420
--- /dev/null
+++ b/clang/test/SemaObjC/ivar-access-package.m
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef unsigned char BOOL;
+
+@interface NSObject {
+ id isa;
+}
++new;
++alloc;
+-init;
+-autorelease;
+@end
+
+@interface NSAutoreleasePool : NSObject
+- drain;
+@end
+
+@interface A : NSObject {
+@package
+ id object;
+}
+@end
+
+@interface B : NSObject
+- (BOOL)containsSelf:(A*)a;
+@end
+
+@implementation A
+@end
+
+@implementation B
+- (BOOL)containsSelf:(A*)a {
+ return a->object == self;
+}
+@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;
+}
+
diff --git a/clang/test/SemaObjC/ivar-access-tests.m b/clang/test/SemaObjC/ivar-access-tests.m
new file mode 100644
index 0000000..cd7e09d
--- /dev/null
+++ b/clang/test/SemaObjC/ivar-access-tests.m
@@ -0,0 +1,122 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface MySuperClass
+{
+@private
+ int private;
+
+@protected
+ int protected;
+
+@public
+ int public;
+}
+@end
+
+@implementation MySuperClass
+- (void) test {
+ int access;
+ MySuperClass *s = 0;
+ access = s->private;
+ access = s->protected;
+}
+@end
+
+
+@interface MyClass : MySuperClass
+@end
+
+@implementation MyClass
+- (void) test {
+ int access;
+ MySuperClass *s = 0;
+ access = s->private; // expected-error {{instance variable 'private' is private}}
+ access = s->protected;
+ MyClass *m=0;
+ access = m->private; // expected-error {{instance variable 'private' is private}}
+ access = m->protected;
+}
+@end
+
+
+@interface Deeper : MyClass
+@end
+
+@implementation Deeper
+- (void) test {
+ int access;
+ MySuperClass *s = 0;
+ access = s->private; // expected-error {{instance variable 'private' is private}}
+ access = s->protected;
+ MyClass *m=0;
+ access = m->private; // expected-error {{instance variable 'private' is private}}
+ access = m->protected;
+}
+@end
+
+@interface Unrelated
+@end
+
+@implementation Unrelated
+- (void) test {
+ int access;
+ MySuperClass *s = 0;
+ access = s->private; // expected-error {{instance variable 'private' is private}}
+ access = s->protected; // expected-error {{instance variable 'protected' is protected}}
+ MyClass *m=0;
+ access = m->private; // expected-error {{instance variable 'private' is private}}
+ access = m->protected; // expected-error {{instance variable 'protected' is protected}}
+}
+@end
+
+int main (void)
+{
+ MySuperClass *s = 0;
+ int access;
+ access = s->private; // expected-error {{instance variable 'private' is private}}
+ access = s->protected; // expected-error {{instance variable 'protected' is protected}}
+ return 0;
+}
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object;
+@end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+@interface NSResponder : NSObject <NSCoding> {}
+@end
+@protocol NSAnimatablePropertyContainer
+- (id)animator;
+@end
+extern NSString *NSAnimationTriggerOrderIn ;
+@interface NSView : NSResponder <NSAnimatablePropertyContainer> {
+ struct __VFlags2 {
+ }
+ _vFlags2;
+}
+@end
+@class NSFontDescriptor, NSAffineTransform, NSGraphicsContext;
+@interface NSScrollView : NSView {}
+@end
+
+@class CasperMixerView;
+@interface CasperDiffScrollView : NSScrollView {
+@private
+ CasperMixerView *_comparatorView;
+ NSView *someField;
+}
+@end
+
+@implementation CasperDiffScrollView
++ (void)initialize {}
+static void _CasperDiffScrollViewInstallMixerView(CasperDiffScrollView *scrollView) {
+ if (scrollView->someField != ((void *)0)) {
+ }
+}
+@end
diff --git a/clang/test/SemaObjC/ivar-in-class-extension-error.m b/clang/test/SemaObjC/ivar-in-class-extension-error.m
new file mode 100644
index 0000000..cecaa33
--- /dev/null
+++ b/clang/test/SemaObjC/ivar-in-class-extension-error.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fobjc-fragile-abi -fsyntax-only -verify %s
+// rdar://6812436
+
+@interface A @end
+
+@interface A () {
+ int _p0; // expected-error {{ivars may not be placed in class extension}}
+}
+@property int p0;
+@end
+
+@interface A(CAT) {
+ int _p1; // expected-error {{ivars may not be placed in categories}}
+}
+@end
diff --git a/clang/test/SemaObjC/ivar-in-class-extension.m b/clang/test/SemaObjC/ivar-in-class-extension.m
new file mode 100644
index 0000000..cf02d26
--- /dev/null
+++ b/clang/test/SemaObjC/ivar-in-class-extension.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface SomeClass @end
+
+int fn1(SomeClass *obj) {
+ obj->privateIvar = 1; // expected-error {{'SomeClass' does not have a member named 'privateIvar}}
+ return obj->publicIvar; // expected-error {{'SomeClass' does not have a member named 'publicIvar'}}
+}
+
+@interface SomeClass () {
+// @private by default
+ int privateIvar;
+@public
+ int publicIvar;
+}
+@end
+
+int fn2(SomeClass *obj) {
+ obj->publicIvar = 1;
+ return obj->publicIvar // ok
+ + obj->privateIvar; // expected-error {{instance variable 'privateIvar' is private}}
+}
+
+@implementation SomeClass
+
+int fn3(SomeClass *obj) {
+ obj->privateIvar = 2;
+ return obj->publicIvar // ok
+ + obj->privateIvar; // ok
+ }
+@end
+
+@interface SomeClass (Category)
+ {
+ int categoryIvar; // expected-error {{ivars may not be placed in categories}}
+ }
+@end
+
+@interface SomeClass (Category1)
+ {
+ }
+@end
diff --git a/clang/test/SemaObjC/ivar-in-implementations.m b/clang/test/SemaObjC/ivar-in-implementations.m
new file mode 100644
index 0000000..7281f55
--- /dev/null
+++ b/clang/test/SemaObjC/ivar-in-implementations.m
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface Super @end
+
+@interface INTFSTANDALONE : Super
+{
+ id IVAR; // expected-note {{previous definition is here}}
+}
+
+@end
+
+@implementation INTFSTANDALONE : Super // expected-warning {{class implementation may not have super class}}
+{
+ id PRIV_IVAR;
+@protected
+ id PRTCTD;
+@private
+ id IVAR3;
+ int IVAR; // expected-error {{instance variable is already declared}}
+@public
+ id IVAR4;
+}
+@end
+
+@interface Base @end
+
+@implementation Base {
+ int ivar1;
+@public
+ int ivar2;
+}
+@end
+
+id fn1(INTFSTANDALONE *b) { return b->PRIV_IVAR; } // expected-error {{instance variable 'PRIV_IVAR' is private}}
+
+id fn2(INTFSTANDALONE *b) { return b->PRTCTD; } // expected-error {{instance variable 'PRTCTD' is protected}}
+
+id fn4(INTFSTANDALONE *b) { return b->IVAR4; }
+
diff --git a/clang/test/SemaObjC/ivar-lookup-resolution-builtin.m b/clang/test/SemaObjC/ivar-lookup-resolution-builtin.m
new file mode 100644
index 0000000..dd11b51
--- /dev/null
+++ b/clang/test/SemaObjC/ivar-lookup-resolution-builtin.m
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// pr5986
+
+@interface Test {
+ int index;
+}
+- (int) index;
++ (int) ClassMethod;
+@end
+
+@implementation Test
+- (int) index
+{
+ return index;
+}
++ (int) ClassMethod
+{
+ return index; // expected-error {{instance variable 'index' accessed in class method}}
+}
+@end
+
+@interface Test1 {
+}
+- (int) InstMethod;
++ (int) ClassMethod;
+@end
+
+@implementation Test1
+- (int) InstMethod
+{
+ return index; // expected-warning {{implicitly declaring library function 'index'}} \
+ // expected-note {{please include the header <strings.h> or explicitly provide a declaration for 'index'}} \
+ // expected-warning {{incompatible pointer to integer conversion returning}}
+}
++ (int) ClassMethod
+{
+ return index; // expected-warning {{incompatible pointer to integer conversion returning}}
+}
+@end
+
diff --git a/clang/test/SemaObjC/ivar-lookup.m b/clang/test/SemaObjC/ivar-lookup.m
new file mode 100644
index 0000000..df9d8ba
--- /dev/null
+++ b/clang/test/SemaObjC/ivar-lookup.m
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface Test {
+ int x;
+}
+
+-(void) setX: (int) d;
+@end
+
+extern struct foo x;
+
+@implementation Test
+
+-(void) setX: (int) n {
+ x = n;
+}
+
+@end
+
+@interface Ivar
+- (float*)method;
+@end
+
+@interface A {
+ A *Ivar;
+}
+- (int*)method;
+@end
+
+@implementation A
+- (int*)method {
+ int *ip = [Ivar method]; // expected-warning{{incompatible pointer types initializing 'int *' with an expression of type 'float *'}}
+ // Note that there is no warning in Objective-C++
+ return 0;
+}
+@end
+
+@interface TwoIvars {
+ int a;
+ int b;
+}
+@end
+
+@implementation TwoIvars
++ (int)classMethod {
+ return a + b; // expected-error{{instance variable 'a' accessed in class method}} \
+ // expected-error{{instance variable 'b' accessed in class method}}
+}
+@end
+
+// rdar://10309454
+@interface Radar10309454
+{
+ int IVAR; // expected-note 4 {{previous definition is here}}
+}
+@end
+
+@interface Radar10309454()
+{
+ int IVAR; // expected-error {{instance variable is already declared}}
+ int PIVAR; // expected-note {{previous definition is here}}
+}
+@end
+
+@interface Radar10309454()
+{
+ int IVAR; // expected-error {{instance variable is already declared}}
+}
+@end
+
+@interface Radar10309454()
+{
+ int IVAR; // expected-error {{instance variable is already declared}}
+ int PIVAR; // expected-error {{instance variable is already declared}}
+}
+@end
+
+@implementation Radar10309454
+{
+ int IVAR; // expected-error {{instance variable is already declared}}
+}
+@end
diff --git a/clang/test/SemaObjC/ivar-ref-misuse.m b/clang/test/SemaObjC/ivar-ref-misuse.m
new file mode 100644
index 0000000..3115f5b
--- /dev/null
+++ b/clang/test/SemaObjC/ivar-ref-misuse.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface Sprite { // expected-note{{'Sprite' declared here}}
+ int sprite, spree;
+ int UseGlobalBar;
+}
++ (void)setFoo:(int)foo;
++ (void)setSprite:(int)sprite;
+- (void)setFoo:(int)foo;
+- (void)setSprite:(int)sprite;
+@end
+
+int spree = 23;
+int UseGlobalBar;
+
+@implementation Sprite
++ (void)setFoo:(int)foo {
+ sprite = foo; // expected-error {{instance variable 'sprite' accessed in class method}}
+ spree = foo;
+ Xsprite = foo; // expected-error {{unknown type name 'Xsprite'; did you mean 'Sprite'?}} \
+ // expected-error{{expected identifier or '('}}
+ UseGlobalBar = 10;
+}
++ (void)setSprite:(int)sprite {
+ int spree;
+ sprite = 15;
+ spree = 17;
+ ((Sprite *)self)->sprite = 16; /* NB: This is how one _should_ access */
+ ((Sprite *)self)->spree = 18; /* ivars from within class methods! */
+}
+- (void)setFoo:(int)foo {
+ sprite = foo;
+ spree = foo;
+}
+- (void)setSprite:(int)sprite {
+ int spree;
+ sprite = 15; // expected-warning {{local declaration of 'sprite' hides instance variable}}
+ self->sprite = 16;
+ spree = 17; // expected-warning {{local declaration of 'spree' hides instance variable}}
+ self->spree = 18;
+}
+@end
diff --git a/clang/test/SemaObjC/ivar-sem-check-1.m b/clang/test/SemaObjC/ivar-sem-check-1.m
new file mode 100644
index 0000000..de038f5
--- /dev/null
+++ b/clang/test/SemaObjC/ivar-sem-check-1.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct S; // expected-note{{forward declaration of 'struct S'}}
+typedef int FOO();
+
+@interface INTF
+{
+ struct F {} JJ;
+ int arr[]; // expected-error {{field has incomplete type}}
+ struct S IC; // expected-error {{field has incomplete type}}
+ struct T { // expected-note {{previous definition is here}}
+ struct T {} X; // expected-error {{nested redefinition of 'T'}}
+ }YYY;
+ FOO BADFUNC; // expected-error {{field 'BADFUNC' declared as a function}}
+ int kaka; // expected-note {{previous declaration is here}}
+ int kaka; // expected-error {{duplicate member 'kaka'}}
+ char ch[]; // expected-error {{field has incomplete type}}
+}
+@end
diff --git a/clang/test/SemaObjC/ivar-sem-check-2.m b/clang/test/SemaObjC/ivar-sem-check-2.m
new file mode 100644
index 0000000..bf884b3
--- /dev/null
+++ b/clang/test/SemaObjC/ivar-sem-check-2.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface Super {
+ id value2; // expected-note {{previously declared 'value2' here}}
+}
+@property(retain) id value;
+@property(retain) id value1;
+@property(retain) id prop;
+@end
+
+@interface Sub : Super
+{
+ id value;
+}
+@end
+
+@implementation Sub
+@synthesize value; // expected-note {{previous use is here}}
+@synthesize value1=value; // expected-error {{synthesized properties 'value1' and 'value' both claim ivar 'value'}}
+@synthesize prop=value2; // expected-error {{property 'prop' attempting to use ivar 'value2' declared in super class 'Super'}}
+@end
+
+
diff --git a/clang/test/SemaObjC/legacy-implementation-1.m b/clang/test/SemaObjC/legacy-implementation-1.m
new file mode 100644
index 0000000..2e4c5ae
--- /dev/null
+++ b/clang/test/SemaObjC/legacy-implementation-1.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@implementation INTF // expected-warning {{cannot find interface declaration for 'INTF'}}
+@end
+
+INTF* pi;
+
+INTF* FUNC()
+{
+ return pi;
+}
diff --git a/clang/test/SemaObjC/message.m b/clang/test/SemaObjC/message.m
new file mode 100644
index 0000000..621a18f
--- /dev/null
+++ b/clang/test/SemaObjC/message.m
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+
+@interface foo
+- (void)meth;
+@end
+
+@implementation foo
+- (void) contents {} // No declaration in @interface!
+- (void) meth { [self contents]; }
+@end
+
+typedef struct _NSPoint {
+ float x;
+ float y;
+} NSPoint;
+
+typedef struct _NSSize {
+ float width;
+ float height;
+} NSSize;
+
+typedef struct _NSRect {
+ NSPoint origin;
+ NSSize size;
+} NSRect;
+
+@interface AnyClass
+- (NSRect)rect;
+@end
+
+@class Helicopter;
+
+static void func(Helicopter *obj) {
+ // Note that the proto for "rect" is found in the global pool even when
+ // a statically typed object's class interface isn't in scope! This
+ // behavior isn't very desirable, however wee need it for GCC compatibility.
+ NSRect r = [obj rect];
+}
+
+@interface NSObject @end
+
+extern Class NSClassFromObject(id object);
+
+@interface XX : NSObject
+@end
+
+@implementation XX
+
++ _privateMethod {
+ return self;
+}
+
+- (void) xx {
+ [NSClassFromObject(self) _privateMethod];
+}
+@end
+
+@implementation XX (Private)
+- (void) yy {
+ [NSClassFromObject(self) _privateMethod];
+}
+@end
+
+@interface I0
+-(void) nonVararg: (int) x;
+@end
+
+int f0(I0 *ob) {
+ [ ob nonVararg: 0, 1, 2]; // expected-error {{too many arguments to method call}}
+}
+
+int f2() {
+ const id foo;
+ [foo bar]; // expected-warning {{method '-bar' not found (return type defaults to 'id')}}
+ return 0;
+}
+
+
+// PR3766
+struct S { int X; } S;
+
+int test5(int X) {
+ int a = [X somemsg]; // expected-warning {{receiver type 'int' is not 'id'}} \
+ expected-warning {{method '-somemsg' not found}} \
+ expected-warning {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'id'}}
+ int b = [S somemsg]; // expected-error {{bad receiver type 'struct S'}}
+}
+
+// PR4021
+void foo4() {
+ struct objc_object X[10];
+
+ [X rect]; // expected-warning {{receiver type 'struct objc_object *' is not 'id' or interface pointer, consider casting it to 'id'}} expected-warning {{method '-rect' not found (return type defaults to 'id')}}
+}
+
diff --git a/clang/test/SemaObjC/method-arg-qualifier-warning.m b/clang/test/SemaObjC/method-arg-qualifier-warning.m
new file mode 100644
index 0000000..690509e
--- /dev/null
+++ b/clang/test/SemaObjC/method-arg-qualifier-warning.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef signed char BOOL;
+
+@interface NSString
+- (BOOL)isEqualToString:(NSString *)aString; // expected-note 2{{passing argument to parameter 'aString' here}}
+@end
+
+static const NSString * Identifier1 = @"Identifier1";
+static NSString const * Identifier2 = @"Identifier2";
+static NSString * const Identifier3 = @"Identifier3";
+
+int main () {
+
+ [@"Identifier1" isEqualToString:Identifier1]; // expected-warning {{sending 'const NSString *' to parameter of type 'NSString *' discards qualifiers}}
+ [@"Identifier2" isEqualToString:Identifier2]; // expected-warning {{sending 'const NSString *' to parameter of type 'NSString *' discards qualifiers}}
+ [@"Identifier3" isEqualToString:Identifier3];
+ return 0;
+}
+
diff --git a/clang/test/SemaObjC/method-attributes.m b/clang/test/SemaObjC/method-attributes.m
new file mode 100644
index 0000000..f7252af
--- /dev/null
+++ b/clang/test/SemaObjC/method-attributes.m
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
+
+@class NSString;
+
+@interface A
+-t1 __attribute__((noreturn));
+- (NSString *)stringByAppendingFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2)));
+-(void) m0 __attribute__((noreturn));
+-(void) m1 __attribute__((unused));
+@end
+
+
+@interface INTF
+- (int) foo1: (int)arg1 __attribute__((deprecated));
+
+- (int) foo: (int)arg1; // expected-note {{method 'foo:' declared here}}
+
+- (int) foo2: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)); // expected-note {{method 'foo2:' declared here}}
+- (int) foo3: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)) __attribute__((ns_consumes_self));
+@end
+
+@implementation INTF
+- (int) foo: (int)arg1 __attribute__((deprecated)){ // expected-warning {{attributes on method implementation and its declaration must match}}
+ return 10;
+}
+- (int) foo1: (int)arg1 {
+ return 10;
+}
+- (int) foo2: (int)arg1 __attribute__((deprecated)) { // expected-warning {{attributes on method implementation and its declaration must match}}
+ return 10;
+}
+- (int) foo3: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)) __attribute__((ns_consumes_self)) {return 0; }
+- (void) dep __attribute__((deprecated)) { } // OK private methodn
+@end
+
+
+// rdar://10529259
+#define IBAction void)__attribute__((ibaction)
+
+@interface Foo
+- (void)doSomething1:(id)sender;
+- (void)doSomething2:(id)sender; // expected-note {{method 'doSomething2:' declared here}}
+@end
+
+@implementation Foo
+- (void)doSomething1:(id)sender{}
+- (void)doSomething2:(id)sender{}
+@end
+
+@interface Bar : Foo
+- (IBAction)doSomething1:(id)sender;
+@end
+@implementation Bar
+- (IBAction)doSomething1:(id)sender {}
+- (IBAction)doSomething2:(id)sender {} // expected-warning {{attributes on method implementation and its declaration must match}}
+- (IBAction)doSomething3:(id)sender {}
+@end
diff --git a/clang/test/SemaObjC/method-bad-param.m b/clang/test/SemaObjC/method-bad-param.m
new file mode 100644
index 0000000..9505cb4
--- /dev/null
+++ b/clang/test/SemaObjC/method-bad-param.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface foo
+@end
+
+@implementation foo
+@end
+
+@interface bar
+-(void) my_method:(foo) my_param; // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
+- (foo)cccccc:(long)ddddd; // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
+@end
+
+@implementation bar
+-(void) my_method:(foo) my_param // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
+{
+}
+- (foo)cccccc:(long)ddddd // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
+{
+}
+@end
+
+void somefunc(foo x) {} // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
+foo somefunc2() {} // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
+
+// rdar://6780761
+void f0(foo *a0) {
+ extern void g0(int x, ...);
+ g0(1, *(foo*)a0); // expected-error {{cannot pass object with interface type 'foo' by-value through variadic function}}
+}
+
+// rdar://8421082
+enum bogus; // expected-note {{forward declaration of 'enum bogus'}}
+
+@interface fee {
+}
+- (void)crashMe:(enum bogus)p;
+@end
+
+@implementation fee
+- (void)crashMe:(enum bogus)p { // expected-error {{variable has incomplete type 'enum bogus'}}
+}
+@end
+
diff --git a/clang/test/SemaObjC/method-conflict-1.m b/clang/test/SemaObjC/method-conflict-1.m
new file mode 100644
index 0000000..ca91ebd
--- /dev/null
+++ b/clang/test/SemaObjC/method-conflict-1.m
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+// This test case tests the default behavior.
+
+// rdar://7933061
+
+@interface NSObject @end
+
+@interface NSArray : NSObject @end
+
+@interface MyClass : NSObject {
+}
+- (void)myMethod:(NSArray *)object;
+- (void)myMethod1:(NSObject *)object; // broken-note {{previous definition is here}}
+@end
+
+@implementation MyClass
+- (void)myMethod:(NSObject *)object {
+}
+- (void)myMethod1:(NSArray *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'NSObject *' vs 'NSArray *'}}
+}
+@end
+
+
+@protocol MyProtocol @end
+
+@interface MyOtherClass : NSObject <MyProtocol> {
+}
+- (void)myMethod:(id <MyProtocol>)object; // broken-note {{previous definition is here}}
+- (void)myMethod1:(id <MyProtocol>)object; // broken-note {{previous definition is here}}
+@end
+
+@implementation MyOtherClass
+- (void)myMethod:(MyClass *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod:': 'id<MyProtocol>' vs 'MyClass *'}}
+}
+- (void)myMethod1:(MyClass<MyProtocol> *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'id<MyProtocol>' vs 'MyClass<MyProtocol> *'}}
+}
+@end
+
+
+
+@interface A @end
+@interface B : A @end
+
+@interface Test1 {}
+- (void) test1:(A*) object; // broken-note {{previous definition is here}}
+- (void) test2:(B*) object;
+@end
+
+@implementation Test1
+- (void) test1:(B*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}}
+- (void) test2:(A*) object {}
+@end
+
+// rdar://problem/8597621 wants id -> A* to be an exception
+@interface Test2 {}
+- (void) test1:(id) object; // broken-note {{previous definition is here}}
+- (void) test2:(A*) object;
+@end
+@implementation Test2
+- (void) test1:(A*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}}
+- (void) test2:(id) object {}
+@end
+
+@interface Test3 {}
+- (A*) test1;
+- (B*) test2; // broken-note {{previous definition is here}}
+@end
+
+@implementation Test3
+- (B*) test1 { return 0; }
+- (A*) test2 { return 0; } // broken-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}}
+@end
+
+// The particular case of overriding with an id return is white-listed.
+@interface Test4 {}
+- (id) test1;
+- (A*) test2;
+@end
+@implementation Test4
+- (A*) test1 { return 0; } // id -> A* is rdar://problem/8596987
+- (id) test2 { return 0; }
+@end
diff --git a/clang/test/SemaObjC/method-conflict-2.m b/clang/test/SemaObjC/method-conflict-2.m
new file mode 100644
index 0000000..df59f24
--- /dev/null
+++ b/clang/test/SemaObjC/method-conflict-2.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface A @end
+@interface B : A @end
+
+@interface Test1 {}
+- (void) test1:(A*) object; // expected-note {{previous definition is here}}
+- (void) test2:(B*) object;
+@end
+
+@implementation Test1
+- (void) test1:(B*) object {} // expected-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}}
+- (void) test2:(A*) object {}
+@end
+
+@interface Test2 {}
+- (void) test1:(id) object; // expected-note {{previous definition is here}}
+- (void) test2:(A*) object;
+@end
+
+@implementation Test2
+- (void) test1:(A*) object {} // expected-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}}
+- (void) test2:(id) object {}
+@end
+
+@interface Test3 {}
+- (A*) test1;
+- (B*) test2; // expected-note {{previous definition is here}}
+@end
+
+@implementation Test3
+- (B*) test1 { return 0; }
+- (A*) test2 { return 0; } // expected-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}}
+@end
+
+// The particular case of overriding with an id return is white-listed.
+@interface Test4 {}
+- (id) test1;
+- (A*) test2;
+@end
+@implementation Test4
+- (A*) test1 { return 0; } // id -> A* is rdar://problem/8596987
+- (id) test2 { return 0; }
+@end
diff --git a/clang/test/SemaObjC/method-conflict.m b/clang/test/SemaObjC/method-conflict.m
new file mode 100644
index 0000000..2da629e
--- /dev/null
+++ b/clang/test/SemaObjC/method-conflict.m
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end @interface NSObject <NSObject> {
+}
+@end extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
+@end @class NSString;
+typedef struct _NSRange {
+}
+ NSRange;
+@interface NSValue (NSValueRangeExtensions) + (NSValue *)valueWithRange:(NSRange)range;
+@end @interface NSAttributedString : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSString *)string;
+@end @interface NSMutableAttributedString : NSAttributedString - (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)str;
+@end @class NSArray, NSDictionary, NSString, NSError;
+@interface NSScanner : NSObject <NSCopying> - (NSString *)string;
+@end typedef struct {
+}
+ CSSM_FIELDGROUP, *CSSM_FIELDGROUP_PTR;
+@protocol XDUMLClassifier;
+@protocol XDUMLClassInterfaceCommons <XDUMLClassifier>
+@end @protocol XDUMLImplementation;
+@protocol XDUMLElement <NSObject> - (NSArray *) ownedElements;
+@end @protocol XDUMLDataType;
+@protocol XDUMLNamedElement <XDUMLElement> - (NSString *) name;
+@end enum _XDSourceLanguage {
+XDSourceUnknown=0, XDSourceJava, XDSourceC, XDSourceCPP, XDSourceObjectiveC };
+typedef NSUInteger XDSourceLanguage;
+@protocol XDSCClassifier <XDUMLClassInterfaceCommons> - (XDSourceLanguage)language;
+@end @class XDSCDocController;
+@interface XDSCDisplaySpecification : NSObject <NSCoding>{
+}
+@end @class XDSCOperation;
+@interface XDSCClassFormatter : NSObject {
+}
++ (NSUInteger) compartmentsForClassifier: (id <XDUMLClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec; // expected-note {{previous definition is here}}
+@end
+@class NSString;
+@implementation XDSCClassFormatter
+
++ appendVisibility: (id <XDUMLNamedElement>) element withSpecification: (XDSCDisplaySpecification *) displaySpec to: (NSMutableAttributedString *) attributedString
+{
+ return 0;
+}
++ (NSUInteger) compartmentsForClassifier: (id <XDSCClassifier>) classifier withSpecification: (XDSCDisplaySpecification *) displaySpec { // expected-warning {{conflicting parameter types in implementation of 'compartmentsForClassifier:withSpecification:'}}
+ return 0;
+}
+@end
+
+// rdar: // 8006060
+@interface Bar
+- (void)foo:(id)format, ...; // expected-note {{previous declaration is here}}
+- (void)foo1:(id)format; // expected-note {{previous declaration is here}}
+@end
+@implementation Bar
+- (void)foo:(id)format {}; // expected-warning {{conflicting variadic declaration of method and its implementation}}
+- (void)foo1:(id)format, ... {}; // expected-warning {{conflicting variadic declaration of method and its implementation}}
+@end
+
diff --git a/clang/test/SemaObjC/method-def-1.m b/clang/test/SemaObjC/method-def-1.m
new file mode 100644
index 0000000..7b292fb
--- /dev/null
+++ b/clang/test/SemaObjC/method-def-1.m
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface foo
+- (int)meth;
+@end
+
+@implementation foo
+- (int) meth { return [self meth]; }
+@end
+
+// PR2708
+@interface MyClass
++- (void)myMethod; // expected-error {{expected selector for Objective-C method}}
+- (vid)myMethod2; // expected-error {{expected a type}}
+@end
+
+@implementation MyClass
+- (void)myMethod { }
+- (vid)myMethod2 { } // expected-error {{expected a type}}
+
+@end
+
+
+@protocol proto;
+@protocol NSObject;
+
+//@protocol GrowlPluginHandler <NSObject> @end
+
+
+@interface SomeClass2
+- (int)myMethod1: (id<proto>)
+arg; // expected-note {{previous definition is here}}
+@end
+
+@implementation SomeClass2
+- (int)myMethod1: (id<NSObject>)
+ arg { // expected-warning {{conflicting parameter types in implementation of 'myMethod1:': 'id<proto>' vs 'id<NSObject>'}}
+
+}
+@end
diff --git a/clang/test/SemaObjC/method-def-2.m b/clang/test/SemaObjC/method-def-2.m
new file mode 100644
index 0000000..915f231
--- /dev/null
+++ b/clang/test/SemaObjC/method-def-2.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -ast-print %s
+extern void abort(void);
+#define CHECK_IF(expr) if(!(expr)) abort()
+
+static double d = 4.5920234e2;
+
+@interface Foo
+-(void) brokenType: (int)x floatingPoint: (double)y;
+@end
+
+
+@implementation Foo
+-(void) brokenType: (int)x floatingPoint: (double)y
+{
+ CHECK_IF(x == 459);
+ CHECK_IF(y == d);
+}
+@end
+
diff --git a/clang/test/SemaObjC/method-encoding-2.m b/clang/test/SemaObjC/method-encoding-2.m
new file mode 100644
index 0000000..619a886
--- /dev/null
+++ b/clang/test/SemaObjC/method-encoding-2.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s
+// TODO: We don't support rewrite of method definitions
+
+@interface Intf
+- (in out bycopy id) address:(byref inout void *)location with:(out oneway unsigned **)arg2;
+- (id) another:(void *)location with:(unsigned **)arg2;
+@end
+
+@implementation Intf
+- (in out bycopy id) address:(byref inout void *)location with:(out oneway unsigned **)arg2{ return 0; }
+- (id) another:(void *)location with:(unsigned **)arg2 { return 0; }
+@end
diff --git a/clang/test/SemaObjC/method-in-class-extension-impl.m b/clang/test/SemaObjC/method-in-class-extension-impl.m
new file mode 100644
index 0000000..c205322
--- /dev/null
+++ b/clang/test/SemaObjC/method-in-class-extension-impl.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://8530080
+
+@protocol ViewDelegate @end
+
+@interface NSTextView
+- (id <ViewDelegate>)delegate;
+@end
+
+@interface FooTextView : NSTextView
+@end
+
+@interface FooTextView()
+- (id)delegate;
+@end
+
+@implementation FooTextView
+- (id)delegate {return 0; }
+@end
+
diff --git a/clang/test/SemaObjC/method-lookup-2.m b/clang/test/SemaObjC/method-lookup-2.m
new file mode 100644
index 0000000..53cae83
--- /dev/null
+++ b/clang/test/SemaObjC/method-lookup-2.m
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+typedef signed char BOOL;
+
+@protocol NSObject
++ alloc;
+- init;
+- (BOOL) isEqual:(id) object;
+- (Class)class;
+@end
+
+@interface NSObject < NSObject > {} @end
+
+@class NSString, NSPort;
+
+@interface NSPortNameServer:NSObject
++ (NSPortNameServer *) systemDefaultPortNameServer;
+@end
+
+@interface NSMachBootstrapServer:NSPortNameServer + (id) sharedInstance; @end
+
+enum {
+ NSWindowsNTOperatingSystem = 1, NSWindows95OperatingSystem, NSSolarisOperatingSystem, NSHPUXOperatingSystem, NSMACHOperatingSystem, NSSunOSOperatingSystem, NSOSF1OperatingSystem
+};
+
+@interface NSRunLoop:NSObject {} @end
+
+@interface NSRunLoop(NSRunLoopConveniences)
+- (void) run;
+@end
+
+extern NSString *const NSWillBecomeMultiThreadedNotification;
+
+@interface SenTestTool:NSObject {}
+@end
+
+@implementation SenTestTool
++ (void) initialize {}
++(SenTestTool *) sharedInstance { return 0; }
+-(int) run { return 0; }
++(int) run {
+ return[[self sharedInstance] run];
+}
+@end
+
+@interface XX : NSObject
+
++ classMethod;
+
+@end
+
+@interface YY : NSObject
+- whatever;
+@end
+
+@implementation YY
+
+- whatever {
+ id obj = [[XX alloc] init];
+ [[obj class] classMethod];
+ return 0;
+}
+
+@end
diff --git a/clang/test/SemaObjC/method-lookup-3.m b/clang/test/SemaObjC/method-lookup-3.m
new file mode 100644
index 0000000..b3d9c46
--- /dev/null
+++ b/clang/test/SemaObjC/method-lookup-3.m
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef struct { int y; } Abstract;
+
+typedef struct { int x; } Alternate;
+
+#define INTERFERE_TYPE Alternate*
+
+@protocol A
+@property Abstract *x; // expected-note {{using}}
+@end
+
+@interface B
+@property Abstract *y; // expected-note {{using}}
+@end
+
+@interface B (Category)
+@property Abstract *z; // expected-note {{using}}
+@end
+
+@interface InterferencePre
+-(void) x; // expected-note {{also found}}
+-(void) y; // expected-note {{also found}}
+-(void) z; // expected-note {{also found}}
+-(void) setX: (INTERFERE_TYPE) arg;
+-(void) setY: (INTERFERE_TYPE) arg;
+-(void) setZ: (INTERFERE_TYPE) arg;
+@end
+
+void f0(id a0) {
+ Abstract *l = [a0 x]; // expected-warning {{multiple methods named 'x' found}}
+}
+
+void f1(id a0) {
+ Abstract *l = [a0 y]; // expected-warning {{multiple methods named 'y' found}}
+}
+
+void f2(id a0) {
+ Abstract *l = [a0 z]; // expected-warning {{multiple methods named 'z' found}}
+}
+
+void f3(id a0, Abstract *a1) {
+ [ a0 setX: a1];
+}
+
+void f4(id a0, Abstract *a1) {
+ [ a0 setY: a1];
+}
+
+void f5(id a0, Abstract *a1) {
+ [ a0 setZ: a1];
+}
+
+// pr7861
+void f6(id<A> a0) {
+ Abstract *l = [a0 x];
+}
+
+struct test3a { int x, y; };
+struct test3b { unsigned x, y; };
+@interface Test3A - (struct test3a) test3; @end
+@interface Test3B - (struct test3b) test3; @end
+void test3(id x) {
+ (void) [x test3];
+}
+
+struct test4a { int x, y; };
+struct test4b { float x, y; };
+@interface Test4A - (struct test4a) test4; @end //expected-note{{using}}
+@interface Test4B - (struct test4b) test4; @end //expected-note{{also found}}
+void test4(id x) {
+ (void) [x test4]; //expected-warning {{multiple methods named 'test4' found}}
+}
diff --git a/clang/test/SemaObjC/method-lookup-4.m b/clang/test/SemaObjC/method-lookup-4.m
new file mode 100644
index 0000000..700565e
--- /dev/null
+++ b/clang/test/SemaObjC/method-lookup-4.m
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface NSObject {}
+
+@end
+
+@interface MyClass : NSObject {}
+
+@end
+
+@interface MyClass (MyCategorie)
+
+@end
+
+@interface MySubClass : MyClass {}
+
+@end
+
+@interface MySubSubClass : MySubClass {}
+
+@end
+
+@implementation NSObject (NSObjectCategory)
+- (void)rootMethod {}
+@end
+
+@implementation MyClass
+
++ (void)myClassMethod { }
+- (void)myMethod { }
+
+@end
+
+@implementation MyClass (MyCategorie)
++ (void)myClassCategoryMethod { }
+- (void)categoryMethod {}
+@end
+
+@implementation MySubClass
+
+- (void)mySubMethod {}
+
+- (void)myTest {
+ [self mySubMethod];
+ // should lookup method in superclass implementation if available
+ [self myMethod];
+ [super myMethod];
+
+ [self categoryMethod];
+ [super categoryMethod];
+
+ // instance method of root class
+ [MyClass rootMethod];
+
+ [MyClass myClassMethod];
+ [MySubClass myClassMethod];
+
+ [MyClass myClassCategoryMethod];
+ [MySubClass myClassCategoryMethod];
+}
+
+@end
diff --git a/clang/test/SemaObjC/method-lookup-5.m b/clang/test/SemaObjC/method-lookup-5.m
new file mode 100644
index 0000000..13df218
--- /dev/null
+++ b/clang/test/SemaObjC/method-lookup-5.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://8592156
+
+typedef struct objc_class *Class;
+@interface A
+-(Class) foo;
+@end
+
+void f0(A *a) { int x = [[a foo] baz]; } // expected-warning {{method '+baz' not found (return type defaults to 'id')}} \
+ // expected-warning {{ncompatible pointer to integer conversion initializing 'int' with an expression of type 'id'}}
diff --git a/clang/test/SemaObjC/method-lookup.m b/clang/test/SemaObjC/method-lookup.m
new file mode 100644
index 0000000..13e2d7f
--- /dev/null
+++ b/clang/test/SemaObjC/method-lookup.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+typedef signed char BOOL;
+typedef int NSInteger;
+
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (BOOL)respondsToSelector:(SEL)s;
+@end
+
+@interface NSObject <NSObject> {}
+@end
+
+@class NSString, NSData, NSMutableData, NSMutableDictionary, NSMutableArray;
+
+@protocol PBXCompletionItem
+- (NSString *) name;
+- (NSInteger)priority;
+- setPriority:(NSInteger)p;
+@end
+
+@implementation PBXCodeAssistant // expected-warning{{cannot find interface declaration for 'PBXCodeAssistant'}}
+static NSMutableArray * recentCompletions = ((void *)0);
++ (float) factorForRecentCompletion:(NSString *) completion
+{
+ for (NSObject<PBXCompletionItem> * item in [self completionItems]) // expected-warning{{method '+completionItems' not found (return type defaults to 'id')}}
+ {
+ if ([item respondsToSelector:@selector(setPriority:)])
+ {
+ [(id)item setPriority:[item priority] / [PBXCodeAssistant factorForRecentCompletion:[item name]]];
+ }
+ }
+ return 0;
+}
+@end
+
diff --git a/clang/test/SemaObjC/method-no-context.m b/clang/test/SemaObjC/method-no-context.m
new file mode 100644
index 0000000..c087549
--- /dev/null
+++ b/clang/test/SemaObjC/method-no-context.m
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+- im0 { // expected-error{{missing context for method declaration}}
+ int a; return 0;
diff --git a/clang/test/SemaObjC/method-not-defined.m b/clang/test/SemaObjC/method-not-defined.m
new file mode 100644
index 0000000..22466f7
--- /dev/null
+++ b/clang/test/SemaObjC/method-not-defined.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface Foo
+@end
+
+void test() {
+ Foo *fooObj;
+ id obj;
+
+ [[Foo alloc] init]; // expected-warning {{class method '+alloc' not found (return type defaults to 'id')}} expected-warning {{instance method '-init' not found (return type defaults to 'id')}}
+ [fooObj notdefined]; // expected-warning {{instance method '-notdefined' not found (return type defaults to 'id')}}
+ [obj whatever:1 :2 :3]; // expected-warning {{instance method '-whatever:::' not found (return type defaults to 'id')}}
+}
diff --git a/clang/test/SemaObjC/method-prototype-scope.m b/clang/test/SemaObjC/method-prototype-scope.m
new file mode 100644
index 0000000..0bebd9b
--- /dev/null
+++ b/clang/test/SemaObjC/method-prototype-scope.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -Wduplicate-method-arg -verify -Wno-objc-root-class %s
+
+// rdar://8877730
+
+int object;
+
+@class NSString, NSArray;
+
+@interface Test
+- Func:(int)XXXX, id object;
+
+- doSomethingElseWith:(id)object;
+
+- (NSString *)doSomethingWith:(NSString *)object and:(NSArray *)object; // expected-warning {{redeclaration of method parameter 'object'}} \
+ // expected-note {{previous declaration is here}}
+@end
+
+@implementation Test
+
+- (NSString *)doSomethingWith:(NSString *)object and:(NSArray *)object // expected-warning {{redefinition of method parameter 'object'}} \
+ // expected-note {{previous declaration is here}}
+{
+ return object; // expected-warning {{incompatible pointer types returning 'NSArray *' from a function with result type 'NSString *'}}
+}
+
+- Func:(int)XXXX, id object { return object; }
+
+- doSomethingElseWith:(id)object { return object; }
+
+@end
+
+struct P;
+
+@interface Test1
+- doSomethingWith:(struct S *)object and:(struct P *)obj; // expected-warning {{declaration of 'struct S' will not be visible outside of this function}}
+@end
+
+int obj;
diff --git a/clang/test/SemaObjC/method-sentinel-attr.m b/clang/test/SemaObjC/method-sentinel-attr.m
new file mode 100644
index 0000000..274e936
--- /dev/null
+++ b/clang/test/SemaObjC/method-sentinel-attr.m
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define NULL (void*)0
+
+#define ATTR __attribute__ ((__sentinel__))
+
+@interface INTF
+- (void) foo1 : (int)x, ... ATTR; // expected-note {{method has been explicitly marked sentinel here}}
+- (void) foo3 : (int)x __attribute__ ((__sentinel__)) ; // expected-warning {{'sentinel' attribute only supported for variadic functions}}
+- (void) foo5 : (int)x, ... __attribute__ ((__sentinel__(1))); // expected-note {{method has been explicitly marked sentinel here}}
+- (void) foo6 : (int)x, ... __attribute__ ((__sentinel__(5))); // expected-note {{method has been explicitly marked sentinel here}}
+- (void) foo7 : (int)x, ... __attribute__ ((__sentinel__(0))); // expected-note {{method has been explicitly marked sentinel here}}
+- (void) foo8 : (int)x, ... __attribute__ ((__sentinel__("a"))); // expected-error {{'sentinel' attribute requires parameter 1 to be an integer constant}}
+- (void) foo9 : (int)x, ... __attribute__ ((__sentinel__(-1))); // expected-error {{'sentinel' parameter 1 less than zero}}
+- (void) foo10 : (int)x, ... __attribute__ ((__sentinel__(1,1)));
+- (void) foo11 : (int)x, ... __attribute__ ((__sentinel__(1,1,3))); // expected-error {{attribute takes no more than 2 arguments}}
+- (void) foo12 : (int)x, ... ATTR; // expected-note {{method has been explicitly marked sentinel here}}
+
+// rdar://7975788
+- (id) foo13 : (id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id) foo14 : (id)firstObj : (Class)secondObj, ... __attribute__((sentinel(0,1)));
+- (id) foo15 : (id*)firstObj, ... __attribute__((sentinel(0,1)));
+- (id) foo16 : (id**)firstObj, ... __attribute__((sentinel(0,1)));
+@end
+
+int main ()
+{
+ INTF *p;
+
+ [p foo1:1, NULL]; // OK
+ [p foo1:1, 0]; // expected-warning {{missing sentinel in method dispatch}}
+ [p foo5:1, NULL, 2]; // OK
+ [p foo5:1, 2, NULL, 1]; // OK
+ [p foo5:1, NULL, 2, 1]; // expected-warning {{missing sentinel in method dispatch}}
+
+ [p foo6:1,2,3,4,5,6,7]; // expected-warning {{missing sentinel in method dispatch}}
+ [p foo6:1,NULL,3,4,5,6,7]; // OK
+ [p foo7:1]; // expected-warning {{not enough variable arguments in 'foo7:' declaration to fit a sentinel}}
+ [p foo7:1, NULL]; // ok
+
+ [p foo12:1]; // expected-warning {{not enough variable arguments in 'foo12:' declaration to fit a sentinel}}
+
+ // rdar://7975788
+ [ p foo13 : NULL];
+ [ p foo14 : 0 : NULL];
+ [ p foo16 : NULL];
+ [ p foo15 : NULL];
+}
+
diff --git a/clang/test/SemaObjC/method-typecheck-1.m b/clang/test/SemaObjC/method-typecheck-1.m
new file mode 100644
index 0000000..ee068d0
--- /dev/null
+++ b/clang/test/SemaObjC/method-typecheck-1.m
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface A
+- (void) setMoo: (int) x; // expected-note {{previous definition is here}}
+- (int) setMoo1: (int) x; // expected-note {{previous definition is here}}
+- (int) setOk : (int) x : (double) d;
+@end
+
+@implementation A
+-(void) setMoo: (float) x {} // expected-warning {{conflicting parameter types in implementation of 'setMoo:': 'int' vs 'float'}}
+- (char) setMoo1: (int) x { return 0; } // expected-warning {{conflicting return type in implementation of 'setMoo1:': 'int' vs 'char'}}
+- (int) setOk : (int) x : (double) d { return 0; }
+@end
+
+
+
+@interface C
++ (void) cMoo: (int) x; // expected-note 2 {{previous definition is here}}
+@end
+
+@implementation C
++(float) cMoo: // expected-warning {{conflicting return type in implementation of 'cMoo:': 'void' vs 'float'}}
+ (float) x { return 0; } // expected-warning {{conflicting parameter types in implementation of 'cMoo:': 'int' vs 'float'}}
+@end
+
+
+@interface A(CAT)
+- (void) setCat: (int) x; // expected-note 2 {{previous definition is here}}
++ (void) cCat: (int) x; // expected-note {{previous definition is here}}
+@end
+
+@implementation A(CAT)
+-(float) setCat: // expected-warning {{conflicting return type in implementation of 'setCat:': 'void' vs 'float'}}
+(float) x { return 0; } // expected-warning {{conflicting parameter types in implementation of 'setCat:': 'int' vs 'float'}}
++ (int) cCat: (int) x { return 0; } // expected-warning {{conflicting return type in implementation of 'cCat:': 'void' vs 'int'}}
+@end
diff --git a/clang/test/SemaObjC/method-typecheck-2.m b/clang/test/SemaObjC/method-typecheck-2.m
new file mode 100644
index 0000000..84efa0b
--- /dev/null
+++ b/clang/test/SemaObjC/method-typecheck-2.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol P
+- (void) doSomethingInProtocol: (float) x; // expected-note {{previous definition is here}}
++ (void) doSomethingClassyInProtocol: (float) x; // expected-note {{previous definition is here}}
+- (void) doNothingInProtocol : (float) x;
++ (void) doNothingClassyInProtocol : (float) x;
+@end
+
+@interface I <P>
+- (void) doSomething: (float) x; // expected-note {{previous definition is here}}
++ (void) doSomethingClassy: (int) x; // expected-note {{previous definition is here}}
+@end
+
+@interface Bar : I
+@end
+
+@implementation Bar
+- (void) doSomething: (int) x {} // expected-warning {{conflicting parameter types}}
++ (void) doSomethingClassy: (float) x{} // expected-warning {{conflicting parameter types}}
+- (void) doSomethingInProtocol: (id) x {} // expected-warning {{conflicting parameter types}}
++ (void) doSomethingClassyInProtocol: (id) x {} // expected-warning {{conflicting parameter types}}
+@end
+
+
diff --git a/clang/test/SemaObjC/method-typecheck-3.m b/clang/test/SemaObjC/method-typecheck-3.m
new file mode 100644
index 0000000..1999b7d
--- /dev/null
+++ b/clang/test/SemaObjC/method-typecheck-3.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify %s
+
+@class B;
+@interface A
+- (B*)obj;
+- (B*)a; // expected-note {{previous definition is here}}
+- (void)takesA: (A*)a; // expected-note {{previous definition is here}}
+- (void)takesId: (id)a; // expected-note {{previous definition is here}}
+@end
+
+
+@interface B : A
+@end
+
+@implementation B
+- (id)obj {return self;} // 'id' overrides are white-listed?
+- (A*)a { return self;} // expected-warning {{conflicting return type in implementation of 'a'}}
+- (void)takesA: (B*)a // expected-warning {{conflicting parameter types in implementation of 'takesA:'}}
+{}
+- (void)takesId: (B*)a // expected-warning {{conflicting parameter types in implementation of 'takesId:'}}
+{}
+@end
diff --git a/clang/test/SemaObjC/method-undef-category-warn-1.m b/clang/test/SemaObjC/method-undef-category-warn-1.m
new file mode 100644
index 0000000..2548cbd
--- /dev/null
+++ b/clang/test/SemaObjC/method-undef-category-warn-1.m
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface MyClass1
+@end
+
+@protocol P
+- (void) Pmeth; // expected-note {{method 'Pmeth' declared here}}
+- (void) Pmeth1; // expected-note {{method 'Pmeth1' declared here}}
+@end
+
+@interface MyClass1(CAT) <P> // expected-note {{required for direct or indirect protocol 'P'}}
+- (void) meth2; // expected-note {{method definition for 'meth2' not found}}
+@end
+
+@implementation MyClass1(CAT) // expected-warning {{incomplete implementation}} \
+ // expected-warning {{method 'Pmeth' in protocol not implemented}}
+- (void) Pmeth1{}
+@end
+
+@interface MyClass1(DOG) <P> // expected-note {{required for direct or indirect protocol 'P'}}
+- (void)ppp; // expected-note {{method definition for 'ppp' not found}}
+@end
+
+@implementation MyClass1(DOG) // expected-warning {{incomplete implementation}} \
+ // expected-warning {{method 'Pmeth1' in protocol not implemented}}
+- (void) Pmeth {}
+@end
+
+@implementation MyClass1(CAT1)
+@end
+
+// rdar://10823023
+@class NSString;
+
+@protocol NSObject
+- (NSString *)meth_inprotocol;
+@end
+
+@interface NSObject <NSObject>
+- (NSString *)description;
++ (NSString *) cls_description;
+@end
+
+@protocol Foo
+- (NSString *)description;
++ (NSString *) cls_description;
+@end
+
+@interface NSObject (FooConformance) <Foo>
+@end
+
+@implementation NSObject (FooConformance)
+@end
+
+// rdar://11186449
+// Don't warn when a category does not implemented a method imported
+// by its protocol because another category has its declaration and
+// that category will implement it.
+@interface NSOrderedSet @end
+
+@interface NSOrderedSet(CoolectionImplements)
+- (unsigned char)containsObject:(id)object;
+@end
+
+@protocol Collection
+- (unsigned char)containsObject:(id)object;
+@end
+
+@interface NSOrderedSet (CollectionConformance) <Collection>
+@end
+
+@implementation NSOrderedSet (CollectionConformance)
+@end
+
diff --git a/clang/test/SemaObjC/method-undef-extension-warn-1.m b/clang/test/SemaObjC/method-undef-extension-warn-1.m
new file mode 100644
index 0000000..c092f24
--- /dev/null
+++ b/clang/test/SemaObjC/method-undef-extension-warn-1.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface MyClass // expected-note {{required for direct or indirect protocol 'P'}}
+@end
+
+@protocol P
+- (void)Pmeth;
+- (void)Pmeth1; // expected-note {{method 'Pmeth1' declared here}}
+@end
+
+// Class extension
+@interface MyClass () <P>
+- (void)meth2; // expected-note {{method definition for 'meth2' not found}}
+@end
+
+// Add a category to test that clang does not emit warning for this method.
+@interface MyClass (Category)
+- (void)categoryMethod;
+@end
+
+@implementation MyClass // expected-warning {{incomplete implementation}} \
+ // expected-warning {{method 'Pmeth1' in protocol not implemented}}
+- (void)Pmeth {}
+@end
diff --git a/clang/test/SemaObjC/method-undefined-warn-1.m b/clang/test/SemaObjC/method-undefined-warn-1.m
new file mode 100644
index 0000000..27d645e
--- /dev/null
+++ b/clang/test/SemaObjC/method-undefined-warn-1.m
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface INTF
+- (void) meth;
+- (void) meth : (int) arg1;
+- (int) int_meth; // expected-note {{method definition for 'int_meth' not found}}
++ (int) cls_meth; // expected-note {{method definition for 'cls_meth' not found}}
++ (void) cls_meth1 : (int) arg1; // expected-note {{method definition for 'cls_meth1:' not found}}
+@end
+
+@implementation INTF // expected-warning {{incomplete implementation}}
+- (void) meth {}
+- (void) meth : (int) arg2{}
+- (void) cls_meth1 : (int) arg2{}
+@end
+
+@interface INTF1
+- (void) meth;
+- (void) meth : (int) arg1;
+- (int) int_meth; // expected-note {{method definition for 'int_meth' not found}}
++ (int) cls_meth; // expected-note {{method definition for 'cls_meth' not found}}
++ (void) cls_meth1 : (int) arg1; // expected-note {{method definition for 'cls_meth1:' not found}}
+@end
+
+@implementation INTF1 // expected-warning {{incomplete implementation}}
+- (void) meth {}
+- (void) meth : (int) arg2{}
+- (void) cls_meth1 : (int) arg2{}
+@end
+
+@interface INTF2
+- (void) meth;
+- (void) meth : (int) arg1;
+- (void) cls_meth1 : (int) arg1;
+@end
+
+@implementation INTF2
+- (void) meth {}
+- (void) meth : (int) arg2{}
+- (void) cls_meth1 : (int) arg2{}
+@end
+
+
+// rdar://8850818
+@interface Root @end
+
+@interface Foo : Root @end
+
+@implementation Foo
+
+- (void)someFunction { return; }
+
++ (void)anotherFunction {
+ [self someFunction]; // expected-warning {{method '+someFunction' not found (return type defaults to 'id')}}
+}
+@end
diff --git a/clang/test/SemaObjC/method-unused-attribute.m b/clang/test/SemaObjC/method-unused-attribute.m
new file mode 100644
index 0000000..d604c39
--- /dev/null
+++ b/clang/test/SemaObjC/method-unused-attribute.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify -Wno-objc-root-class %s
+
+@interface INTF
+- (void) correct_use_of_unused: (void *) notice : (id)another_arg;
+- (void) will_warn_unused_arg: (void *) notice : (id)warn_unused;
+- (void) unused_attr_on_decl_ignored: (void *) __attribute__((unused)) will_warn;
+@end
+
+@implementation INTF
+- (void) correct_use_of_unused: (void *) __attribute__((unused)) notice : (id) __attribute__((unused)) newarg{
+}
+- (void) will_warn_unused_arg: (void *) __attribute__((unused)) notice : (id)warn_unused {} // expected-warning {{unused parameter 'warn_unused'}}
+- (void) unused_attr_on_decl_ignored: (void *) will_warn{} // expected-warning {{unused parameter 'will_warn'}}
+@end
+
diff --git a/clang/test/SemaObjC/method-warn-unused-attribute.m b/clang/test/SemaObjC/method-warn-unused-attribute.m
new file mode 100644
index 0000000..042f442
--- /dev/null
+++ b/clang/test/SemaObjC/method-warn-unused-attribute.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-value -verify %s
+
+@interface INTF
+- (id) foo __attribute__((warn_unused_result));
+- (void) garf __attribute__((warn_unused_result)); // expected-warning {{attribute 'warn_unused_result' cannot be applied to Objective-C method without return value}}
+- (int) fee __attribute__((warn_unused_result));
++ (int) c __attribute__((warn_unused_result));
+@end
+
+void foo(INTF *a) {
+ [a garf];
+ [a fee]; // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
+ [INTF c]; // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
+}
+
+
diff --git a/clang/test/SemaObjC/missing-atend-metadata.m b/clang/test/SemaObjC/missing-atend-metadata.m
new file mode 100644
index 0000000..f072981
--- /dev/null
+++ b/clang/test/SemaObjC/missing-atend-metadata.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface I0
+@end
+
+@implementation I0 // expected-note {{implementation started here}}
+- meth { return 0; }
+
+@interface I1 : I0 // expected-error {{missing '@end'}}
+@end
+
+@implementation I1 // expected-note {{implementation started here}}
+-(void) im0 { self = [super init]; } // expected-warning {{not found}}
+
+@interface I2 : I0 // expected-error {{missing '@end'}}
+- I2meth;
+@end
+
+@implementation I2 // expected-note {{implementation started here}}
+- I2meth { return 0; }
+
+@implementation I2(CAT) // expected-error 2 {{missing '@end'}} expected-note {{implementation started here}}
diff --git a/clang/test/SemaObjC/missing-method-context.m b/clang/test/SemaObjC/missing-method-context.m
new file mode 100644
index 0000000..1378b36
--- /dev/null
+++ b/clang/test/SemaObjC/missing-method-context.m
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+- (void)compilerTestAgainst; // expected-error {{missing context for method declaration}}
+
+void xx(); // expected-error {{expected method body}}
diff --git a/clang/test/SemaObjC/missing-method-return-type.m b/clang/test/SemaObjC/missing-method-return-type.m
new file mode 100644
index 0000000..fc6ff7b
--- /dev/null
+++ b/clang/test/SemaObjC/missing-method-return-type.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -Wmissing-method-return-type -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://9615045
+
+@interface I
+- initWithFoo:(id)foo; // expected-warning {{method has no return type specified; defaults to 'id'}}
+@end
+
+@implementation I
+- initWithFoo:(id)foo { return 0; } // expected-warning {{method has no return type specified; defaults to 'id'}}
+@end
+
diff --git a/clang/test/SemaObjC/narrow-property-type-in-cont-class.m b/clang/test/SemaObjC/narrow-property-type-in-cont-class.m
new file mode 100644
index 0000000..3ba848f
--- /dev/null
+++ b/clang/test/SemaObjC/narrow-property-type-in-cont-class.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
+// rdar://10790488
+
+@interface NSArray @end
+
+@interface NSMutableArray : NSArray
+@end
+
+@interface GKTurnBasedMatchMakerKVO
+@property(nonatomic,readonly,retain) NSArray* outline;
+@property(nonatomic,readonly,retain) NSMutableArray* err_outline; // expected-note {{property declared here}}
+@end
+
+@interface GKTurnBasedMatchMakerKVO ()
+@property(nonatomic,readwrite,retain) NSMutableArray* outline;
+@property(nonatomic,readwrite,retain) NSArray* err_outline; // expected-error {{type of property 'NSArray *' in continuation class does not match property type in primary class}}
+@end
+
diff --git a/clang/test/SemaObjC/nested-typedef-decl.m b/clang/test/SemaObjC/nested-typedef-decl.m
new file mode 100644
index 0000000..bb01ead
--- /dev/null
+++ b/clang/test/SemaObjC/nested-typedef-decl.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://10041908
+
+@interface Bar {
+ struct _A *_hardlinkList;
+}
+@end
+@implementation Bar
+typedef struct _A {
+ int dev;
+ int inode;
+} A;
+
+- (void) idx:(int)idx ino:(int)ino dev:(int)dev
+{
+ _hardlinkList[idx].inode = ino;
+ _hardlinkList[idx].dev = dev;
+}
+@end
+
diff --git a/clang/test/SemaObjC/newproperty-class-method-1.m b/clang/test/SemaObjC/newproperty-class-method-1.m
new file mode 100644
index 0000000..0f32998
--- /dev/null
+++ b/clang/test/SemaObjC/newproperty-class-method-1.m
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
+
+void abort(void);
+
+@interface Subclass
++ (int)magicNumber;
++ (void)setMagicNumber:(int)value;
++ (void)setFakeSetterNumber:(int)value;
+@end
+
+@implementation Subclass
+int _magicNumber = 0;
++ (int)magicNumber {
+ return _magicNumber;
+}
+
++ (void)setMagicNumber:(int)value {
+ _magicNumber = value;
+}
+
++ (void)setFakeSetterNumber:(int)value {
+ _magicNumber = value;
+}
+
++ (void) classMeth
+{
+ self.magicNumber = 10;
+ if (self.magicNumber != 10)
+ abort ();
+}
+@end
+
+int main (void) {
+
+ int a;
+ Subclass.magicNumber = 2 /*[Subclass setMagicNumber:2]*/;
+ if (Subclass.magicNumber != 0)
+ abort ();
+ if (Subclass.magicNumber != 2)
+ abort ();
+ Subclass.magicNumber += 3;
+ if (Subclass.magicNumber != 5)
+ abort ();
+ Subclass.magicNumber -= 5;
+ if (Subclass.magicNumber != 0)
+ abort ();
+ /* We only have a setter in the following case. */
+ Subclass.fakeSetterNumber = 123;
+
+ /* We read it using the other getter. */
+ if (Subclass.magicNumber != 123)
+ abort ();
+ Subclass.fakeSetterNumber = Subclass.magicNumber;
+ if (Subclass.magicNumber != 123)
+ abort ();
+
+ Subclass.fakeSetterNumberX = 123; // expected-error{{property 'fakeSetterNumberX' not found on object of type 'Subclass'}}
+
+ /* Test class methods using the new syntax. */
+ [Subclass classMeth];
+ return 0;
+}
diff --git a/clang/test/SemaObjC/no-gc-weak-test.m b/clang/test/SemaObjC/no-gc-weak-test.m
new file mode 100644
index 0000000..dd9b73c
--- /dev/null
+++ b/clang/test/SemaObjC/no-gc-weak-test.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface Subtask
+{
+ id _delegate;
+}
+@property(nonatomic,readwrite,assign) id __weak delegate;
+@end
+
+@implementation Subtask
+@synthesize delegate = _delegate;
+@end
+
+
+@interface PVSelectionOverlayView2
+{
+ id __weak _selectionRect;
+}
+
+@property(assign) id selectionRect;
+
+@end
+
+@implementation PVSelectionOverlayView2
+
+@synthesize selectionRect = _selectionRect;
+@end
+
diff --git a/clang/test/SemaObjC/no-ivar-access-control.m b/clang/test/SemaObjC/no-ivar-access-control.m
new file mode 100644
index 0000000..6f00b1a
--- /dev/null
+++ b/clang/test/SemaObjC/no-ivar-access-control.m
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -fsyntax-only -fdebugger-support -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fdebugger-support -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://10997647
+
+@interface I
+{
+@private
+int ivar;
+}
+@end
+
+@implementation I
+- (int) meth {
+ return self->ivar;
+}
+int foo1(I* p) {
+ return p->ivar;
+}
+@end
+
+int foo(I* p) {
+ return p->ivar;
+}
+
+@interface B
+@end
+
+@implementation B
+- (int) meth : (I*) arg {
+ return arg->ivar;
+}
+@end
+
+
+@interface I1 {
+ int protected_ivar;
+}
+@property int PROP_INMAIN;
+@end
+
+@interface I1() {
+ int private_ivar;
+}
+@property int PROP_INCLASSEXT;
+@end
+
+@implementation I1
+@synthesize PROP_INMAIN, PROP_INCLASSEXT;
+
+- (int) Meth {
+ PROP_INMAIN = 1;
+ PROP_INCLASSEXT = 2;
+ protected_ivar = 1; // OK
+ return private_ivar; // OK
+}
+@end
+
+
+@interface DER : I1
+@end
+
+@implementation DER
+- (int) Meth {
+ protected_ivar = 1; // OK
+ PROP_INMAIN = 1;
+ PROP_INCLASSEXT = 2;
+ return private_ivar;
+}
+@end
+
diff --git a/clang/test/SemaObjC/no-objc-exceptions.m b/clang/test/SemaObjC/no-objc-exceptions.m
new file mode 100644
index 0000000..d47f51a
--- /dev/null
+++ b/clang/test/SemaObjC/no-objc-exceptions.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f() {
+ @throw @"Hello"; // expected-error {{cannot use '@throw' with Objective-C exceptions disabled}}
+}
+
+void g() {
+ @try { // expected-error {{cannot use '@try' with Objective-C exceptions disabled}}
+ f();
+ } @finally {
+
+ }
+}
diff --git a/clang/test/SemaObjC/no-protocol-option-tests.m b/clang/test/SemaObjC/no-protocol-option-tests.m
new file mode 100644
index 0000000..dbd2a14
--- /dev/null
+++ b/clang/test/SemaObjC/no-protocol-option-tests.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -Wno-protocol -verify -Wno-objc-root-class %s
+// rdar: // 7056600
+
+@protocol P
+- PMeth;
+@end
+
+// Test1
+@interface I <P> @end
+@implementation I @end // no warning with -Wno-protocol
+
+// Test2
+@interface C -PMeth; @end
+@interface C (Category) <P> @end
+@implementation C (Category) @end // no warning with -Wno-protocol
+
+// Test2
+@interface super - PMeth; @end
+@interface J : super <P>
+- PMeth; // expected-note {{method definition for 'PMeth' not found}}
+@end
+@implementation J @end // expected-warning {{incomplete implementation}}
+
+// Test3
+@interface K : super <P>
+@end
+@implementation K @end // no warning with -Wno-protocol
+
+// Test4
+@interface Root @end
+@interface L : Root<P> @end
+@implementation L @end // no warning with -Wno-protocol
diff --git a/clang/test/SemaObjC/no-warn-qual-mismatch.m b/clang/test/SemaObjC/no-warn-qual-mismatch.m
new file mode 100644
index 0000000..1e3c186
--- /dev/null
+++ b/clang/test/SemaObjC/no-warn-qual-mismatch.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// radar 7211563
+
+@interface X
+
++ (void)prototypeWithScalar:(int)aParameter;
++ (void)prototypeWithPointer:(void *)aParameter;
+
+@end
+
+@implementation X
+
++ (void)prototypeWithScalar:(const int)aParameter {}
++ (void)prototypeWithPointer:(void * const)aParameter {}
+
+@end
diff --git a/clang/test/SemaObjC/no-warn-synth-protocol-meth.m b/clang/test/SemaObjC/no-warn-synth-protocol-meth.m
new file mode 100644
index 0000000..103f6bb
--- /dev/null
+++ b/clang/test/SemaObjC/no-warn-synth-protocol-meth.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@protocol CYCdef
+- (int)name;
+@end
+
+@interface JSCdef <CYCdef> {
+ int name;
+}
+
+@property (assign) int name;
+@end
+
+@implementation JSCdef
+@synthesize name;
+@end
+
diff --git a/clang/test/SemaObjC/no-warn-unimpl-method.m b/clang/test/SemaObjC/no-warn-unimpl-method.m
new file mode 100644
index 0000000..dd6e3ad
--- /dev/null
+++ b/clang/test/SemaObjC/no-warn-unimpl-method.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+// This program tests that if class implements the forwardInvocation method, then
+// every method possible is implemented in the class and should not issue
+// warning of the "Method definition not found" kind. */
+
+@interface NSObject
+@end
+
+@interface NSInvocation
+@end
+
+@interface NSProxy
+@end
+
+@protocol MyProtocol
+ -(void) doSomething;
+@end
+
+@interface DestinationClass : NSObject<MyProtocol>
+ -(void) doSomething;
+@end
+
+@implementation DestinationClass
+ -(void) doSomething
+ {
+ }
+@end
+
+@interface MyProxy : NSProxy<MyProtocol>
+{
+ DestinationClass *mTarget;
+}
+ - (id) init;
+ - (void)forwardInvocation:(NSInvocation *)anInvocation;
+@end
+
+@implementation MyProxy
+ - (void)forwardInvocation:(NSInvocation *)anInvocation
+ {
+ }
+ - (id) init { return 0; }
+@end
diff --git a/clang/test/SemaObjC/no-warning-unavail-unimp.m b/clang/test/SemaObjC/no-warning-unavail-unimp.m
new file mode 100644
index 0000000..88d519d
--- /dev/null
+++ b/clang/test/SemaObjC/no-warning-unavail-unimp.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://9651605
+
+@interface Foo
+@property (getter=getVal) int val __attribute__((unavailable));
+- Method __attribute__((unavailable));
++ CMethod __attribute__((unavailable));
+@end
+
+@implementation Foo
+@end
+
diff --git a/clang/test/SemaObjC/nonnull.h b/clang/test/SemaObjC/nonnull.h
new file mode 100644
index 0000000..f5a038f
--- /dev/null
+++ b/clang/test/SemaObjC/nonnull.h
@@ -0,0 +1,2 @@
+// rdar: //6857843
+#define NONNULL_ATTR __attribute__((nonnull))
diff --git a/clang/test/SemaObjC/nonnull.m b/clang/test/SemaObjC/nonnull.m
new file mode 100644
index 0000000..a38c0ac
--- /dev/null
+++ b/clang/test/SemaObjC/nonnull.m
@@ -0,0 +1,96 @@
+#include "nonnull.h"
+
+// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wno-objc-root-class %s
+
+@class NSObject;
+
+NONNULL_ATTR
+int f1(int x); // no warning
+int f2(int *x) __attribute__ ((nonnull (1)));
+int f3(int *x) __attribute__ ((nonnull (0))); // expected-error {{'nonnull' attribute parameter 1 is out of bounds}}
+int f4(int *x, int *y) __attribute__ ((nonnull (1,2)));
+int f5(int *x, int *y) __attribute__ ((nonnull (2,1)));
+int f6(NSObject *x) __attribute__ ((nonnull (1))); // no-warning
+int f7(NSObject *x) __attribute__ ((nonnull)); // no-warning
+
+
+extern void func1 (void (^block1)(), void (^block2)(), int) __attribute__((nonnull));
+
+extern void func3 (void (^block1)(), int, void (^block2)(), int)
+__attribute__((nonnull(1,3)));
+
+extern void func4 (void (^block1)(), void (^block2)()) __attribute__((nonnull(1)))
+__attribute__((nonnull(2)));
+
+void func6();
+void func7();
+
+void
+foo (int i1, int i2, int i3, void (^cp1)(), void (^cp2)(), void (^cp3)())
+{
+ func1(cp1, cp2, i1);
+
+ func1(0, cp2, i1); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ func1(cp1, 0, i1); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ func1(cp1, cp2, 0);
+
+
+ func3(0, i2, cp3, i3); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ func3(cp3, i2, 0, i3); // expected-warning {{null passed to a callee which requires a non-null argument}}
+
+ func4(0, cp1); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ func4(cp1, 0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+
+ // Shouldn't these emit warnings? Clang doesn't, and neither does GCC. It
+ // seems that the checking should handle Objective-C pointers.
+ func6((NSObject*) 0); // no-warning
+ func7((NSObject*) 0); // no-warning
+}
+
+void func5(int) NONNULL_ATTR; // no warning
+
+// rdar://6857843
+struct dispatch_object_s {
+ int x;
+};
+
+typedef union {
+ long first;
+ struct dispatch_object_s *_do;
+} dispatch_object_t __attribute__((transparent_union));
+
+__attribute__((nonnull))
+void _dispatch_queue_push_list(dispatch_object_t _head); // no warning
+
+void func6(dispatch_object_t _head) {
+ _dispatch_queue_push_list(0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ _dispatch_queue_push_list(_head._do); // no warning
+}
+
+// rdar://9287695
+#define NULL (void*)0
+
+@interface NSObject
+- (void)doSomethingWithNonNullPointer:(void *)ptr :(int)iarg : (void*)ptr1 __attribute__((nonnull(1, 3)));
++ (void)doSomethingClassyWithNonNullPointer:(void *)ptr __attribute__((nonnull(1)));
+@end
+
+extern void DoSomethingNotNull(void *db) __attribute__((nonnull(1)));
+
+@interface IMP
+{
+ void * vp;
+}
+@end
+
+@implementation IMP
+- (void) Meth {
+ NSObject *object;
+ [object doSomethingWithNonNullPointer:NULL:1:NULL]; // expected-warning 2 {{null passed to a callee which requires a non-null argument}}
+ [object doSomethingWithNonNullPointer:vp:1:NULL]; // expected-warning {{null passed to a callee which requires a non-null argument}}
+ [NSObject doSomethingClassyWithNonNullPointer:NULL]; // expected-warning {{null passed to a callee which requires a non-null argument}}
+ DoSomethingNotNull(NULL); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ [object doSomethingWithNonNullPointer:vp:1:vp];
+}
+@end
+
diff --git a/clang/test/SemaObjC/nsobject-attribute-1.m b/clang/test/SemaObjC/nsobject-attribute-1.m
new file mode 100644
index 0000000..72d8fa6
--- /dev/null
+++ b/clang/test/SemaObjC/nsobject-attribute-1.m
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface NSObject
+- (id)self;
+- (id)copy;
+@end
+
+typedef struct _foo *__attribute__((NSObject)) Foo_ref;
+
+@interface TestObject {
+ Foo_ref dict;
+}
+@property(retain) Foo_ref dict;
+@end
+
+@implementation TestObject
+@synthesize dict;
+@end
+
+@interface NSDictionary
+- (int)retainCount;
+@end
+
+int main(int argc, char *argv[]) {
+ NSDictionary *dictRef;
+ Foo_ref foo = (Foo_ref)dictRef;
+
+ // do Properties retain?
+ int before = [dictRef retainCount];
+ int after = [dictRef retainCount];
+
+ if ([foo retainCount] != [dictRef retainCount]) {
+ }
+
+ // do Blocks retain?
+ {
+ void (^block)(void) = ^{
+ [foo self];
+ };
+ before = [foo retainCount];
+ id save = [block copy];
+ after = [foo retainCount];
+ if (after <= before) {
+ ;
+ }
+ }
+ return 0;
+}
diff --git a/clang/test/SemaObjC/nsobject-attribute.m b/clang/test/SemaObjC/nsobject-attribute.m
new file mode 100644
index 0000000..f41df89
--- /dev/null
+++ b/clang/test/SemaObjC/nsobject-attribute.m
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+typedef struct CGColor * __attribute__ ((NSObject)) CGColorRef;
+static int count;
+static CGColorRef tmp = 0;
+
+typedef struct S1 __attribute__ ((NSObject)) CGColorRef1; // expected-error {{__attribute ((NSObject)) is for pointer types only}}
+typedef void * __attribute__ ((NSObject)) CGColorRef2; // expected-error {{__attribute ((NSObject)) is for pointer types only}}
+
+
+@interface HandTested {
+@public
+ CGColorRef x;
+}
+
+@property(copy) CGColorRef x;
+// rdar: // 7809460
+typedef struct CGColor * __attribute__((NSObject)) CGColorRefNoNSObject;
+@property (nonatomic, retain) CGColorRefNoNSObject color;
+@end
+
+void setProperty(id self, id value) {
+ ((HandTested *)self)->x = value;
+}
+
+id getProperty(id self) {
+ return (id)((HandTested *)self)->x;
+}
+
+@implementation HandTested
+@synthesize x=x;
+@dynamic color;
+@end
+
+int main(int argc, char *argv[]) {
+ HandTested *to;
+ to.x = tmp; // setter
+ if (tmp != to.x)
+ to.x = tmp;
+ return 0;
+}
+
+// rdar://10453342
+@interface I
+{
+ __attribute__((NSObject)) void * color; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}}
+}
+ // <rdar://problem/10930507>
+@property (nonatomic, retain) __attribute__((NSObject)) void * color; // // no-warning
+@end
+void test_10453342() {
+ char* __attribute__((NSObject)) string2 = 0; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}}
+}
+
diff --git a/clang/test/SemaObjC/objc-array-literal.m b/clang/test/SemaObjC/objc-array-literal.m
new file mode 100644
index 0000000..9f59316
--- /dev/null
+++ b/clang/test/SemaObjC/objc-array-literal.m
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://10111397
+
+#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
+typedef unsigned long NSUInteger;
+#else
+typedef unsigned int NSUInteger;
+#endif
+
+@class NSString;
+
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+
+@class NSFastEnumerationState;
+
+@protocol NSFastEnumeration
+
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id [])buffer count:(NSUInteger)len;
+
+@end
+
+@interface NSNumber
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+@interface NSArray <NSFastEnumeration>
++ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
+@end
+
+
+int main() {
+ NSArray *array = @[@"Hello", @"There", @"How Are You", [NSNumber numberWithInt:42]];
+
+ for (id string in array)
+ NSLog(@"%@\n", string);
+
+ NSArray *array1 = @["Forgot"]; // expected-error {{string literal must be prefixed by '@' in a collection}}
+
+ const char *blah;
+ NSArray *array2 = @[blah]; // expected-error{{collection element of type 'const char *' is not an Objective-C object}}
+}
diff --git a/clang/test/SemaObjC/objc-buffered-methods.m b/clang/test/SemaObjC/objc-buffered-methods.m
new file mode 100644
index 0000000..a4b83be
--- /dev/null
+++ b/clang/test/SemaObjC/objc-buffered-methods.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://8843851
+
+int* global;
+
+@interface I
+- (void) Meth;
+@property int prop;
+@property int prop1;
+@end
+
+@implementation I
++ (void) _defaultMinSize { };
+static void _initCommon() {
+ Class graphicClass;
+ [graphicClass _defaultMinSize];
+}
+
+- (void) Meth { [self Forw]; } // No warning now
+- (void) Forw {}
+- (int) func { return prop; } // compiles - synthesized ivar will be accessible here.
+- (int)get_g { return global; } // No warning here - synthesized ivar will be accessible here.
+@synthesize prop;
+@synthesize prop1=global;
+@end
diff --git a/clang/test/SemaObjC/objc-container-subscripting-1.m b/clang/test/SemaObjC/objc-container-subscripting-1.m
new file mode 100644
index 0000000..a58a7c3
--- /dev/null
+++ b/clang/test/SemaObjC/objc-container-subscripting-1.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef unsigned int size_t;
+@protocol P @end
+
+@interface NSMutableArray
+@end
+
+@interface XNSMutableArray
+@end
+
+int main() {
+id array;
+id oldObject = array[10]; // expected-warning {{instance method '-objectAtIndexedSubscript:' not found (return type defaults to 'id')}}
+
+array[10] = 0; // expected-warning {{instance method '-setObject:atIndexedSubscript:' not found (return type defaults to 'id')}}
+
+id<P> p_array;
+oldObject = p_array[10]; // expected-warning {{instance method '-objectAtIndexedSubscript:' not found (return type defaults to 'id')}}
+
+p_array[10] = 0; // expected-warning {{instance method '-setObject:atIndexedSubscript:' not found (return type defaults to 'id')}}
+}
+
diff --git a/clang/test/SemaObjC/objc-container-subscripting-2.m b/clang/test/SemaObjC/objc-container-subscripting-2.m
new file mode 100644
index 0000000..3c0081b
--- /dev/null
+++ b/clang/test/SemaObjC/objc-container-subscripting-2.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef unsigned int size_t;
+@protocol P @end
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+@end
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id)key;
+- (void)setObject:(id)object forKeyedSubscript:(size_t)key;
+@end
+
+id func() {
+ NSMutableArray *array;
+ float f;
+ array[f] = array; // expected-error {{indexing expression is invalid because subscript type 'float' is not an integral or objective-C pointer type}}
+ return array[3.14]; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or objective-C pointer type}}
+}
+
+void test_unused() {
+ NSMutableArray *array;
+ array[10]; // expected-warning {{container access result unused - container access should not be used for side effects}}
+
+ NSMutableDictionary *dict;
+ dict[array]; // expected-warning {{container access result unused - container access should not be used for side effects}}
+}
+
diff --git a/clang/test/SemaObjC/objc-container-subscripting-3.m b/clang/test/SemaObjC/objc-container-subscripting-3.m
new file mode 100644
index 0000000..5fd1a10
--- /dev/null
+++ b/clang/test/SemaObjC/objc-container-subscripting-3.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://10904488
+
+@interface Test
+- (int)objectAtIndexedSubscript:(int)index; // expected-note {{method 'objectAtIndexedSubscript:' declared here}}
+- (void)setObject:(int)object atIndexedSubscript:(int)index; // expected-note {{parameter of type 'int' is declared here}}
+@end
+
+@interface NSMutableDictionary
+- (int)objectForKeyedSubscript:(id)key; // expected-note {{method 'objectForKeyedSubscript:' declared here}}
+- (void)setObject:(int)object forKeyedSubscript:(id)key; // expected-note {{parameter of type 'int' is declared here}}
+@end
+
+int main() {
+ Test *array;
+ int i = array[10]; // expected-error {{method for accessing array element must have Objective-C object return type instead of 'int'}}
+ array[2] = i; // expected-error {{cannot assign to this array because assigning method's 2nd parameter of type 'int' is not an objective-C pointer type}}
+
+ NSMutableDictionary *dict;
+ id key, val;
+ val = dict[key]; // expected-error {{method for accessing dictionary element must have Objective-C object return type instead of 'int'}} \
+ // expected-warning {{incompatible integer to pointer conversion assigning to 'id' from 'int'}}
+ dict[key] = val; // expected-error {{method object parameter type 'int' is not object type}}
+}
+
diff --git a/clang/test/SemaObjC/objc-container-subscripting.m b/clang/test/SemaObjC/objc-container-subscripting.m
new file mode 100644
index 0000000..4125bc6
--- /dev/null
+++ b/clang/test/SemaObjC/objc-container-subscripting.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef unsigned int size_t;
+@protocol P @end
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(double)index; // expected-note {{parameter of type 'double' is declared here}}
+- (void)setObject:(id *)object atIndexedSubscript:(void *)index; // expected-note {{parameter of type 'void *' is declared here}} \
+ // expected-note {{parameter of type 'id *' is declared here}}
+@end
+@interface I @end
+
+int main() {
+ NSMutableArray<P> * array;
+ id oldObject = array[10]; // expected-error {{method index parameter type 'double' is not integral type}}
+ array[3] = 0; // expected-error {{method index parameter type 'void *' is not integral type}} \
+ // expected-error {{cannot assign to this array because assigning method's 2nd parameter of type 'id *' is not an objective-C pointer type}}
+
+ I* iarray;
+ iarray[3] = 0; // expected-error {{expected method to write array element not found on object of type 'I *'}}
+ I* p = iarray[4]; // expected-error {{expected method to read array element not found on object of type 'I *'}}
+
+ oldObject = array[10]++; // expected-error {{illegal operation on objective-c container subscripting}}
+ oldObject = array[10]--; // expected-error {{illegal operation on objective-c container subscripting}}
+ oldObject = --array[10]; // expected-error {{illegal operation on objective-c container subscripting}}
+}
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id*)key; // expected-note {{parameter of type 'id *' is declared here}}
+- (void)setObject:(void*)object forKeyedSubscript:(id*)key; // expected-note {{parameter of type 'void *' is declared here}} \
+ // expected-note {{parameter of type 'id *' is declared here}}
+@end
+@class NSString;
+
+void testDict() {
+ NSMutableDictionary *dictionary;
+ NSString *key;
+ id newObject, oldObject;
+ oldObject = dictionary[key]; // expected-error {{method key parameter type 'id *' is not object type}}
+ dictionary[key] = newObject; // expected-error {{method object parameter type 'void *' is not object type}} \
+ // expected-error {{method key parameter type 'id *' is not object type}}
+}
diff --git a/clang/test/SemaObjC/objc-cstyle-args-in-methods.m b/clang/test/SemaObjC/objc-cstyle-args-in-methods.m
new file mode 100644
index 0000000..d37b589
--- /dev/null
+++ b/clang/test/SemaObjC/objc-cstyle-args-in-methods.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface Foo
+- (id)test:(id)one, id two;
+- (id)bad:(id)one, id two, double three;
+@end
+
+@implementation Foo
+- (id)test:(id )one, id two {return two; }
+- (id)bad:(id)one, id two, double three { return two; }
+@end
+
+
+int main() {
+ Foo *foo;
+ [foo test:@"One", @"Two"];
+ [foo bad:@"One", @"Two"]; // expected-error {{too few arguments to method call}}
+ [foo bad:@"One", @"Two", 3.14];
+ [foo bad:@"One", @"Two", 3.14, @"Two"]; // expected-error {{too many arguments to method call}}
+}
diff --git a/clang/test/SemaObjC/objc-dictionary-literal.m b/clang/test/SemaObjC/objc-dictionary-literal.m
new file mode 100644
index 0000000..2acbc39
--- /dev/null
+++ b/clang/test/SemaObjC/objc-dictionary-literal.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://11062080
+
+@interface NSNumber
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+@protocol NSCopying @end
+typedef unsigned long NSUInteger;
+typedef long NSInteger;
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@interface NSString<NSCopying>
+@end
+
+@interface NSArray
+- (id)objectAtIndexedSubscript:(NSInteger)index;
+- (void)setObject:(id)object atIndexedSubscript:(NSInteger)index;
+@end
+
+int main() {
+ NSDictionary *dict = @{ @"name":@666 };
+ dict[@"name"] = @666;
+
+ dict["name"] = @666; // expected-error {{indexing expression is invalid because subscript type 'char *' is not an objective-C pointer}}
+
+ return 0;
+}
+
diff --git a/clang/test/SemaObjC/objc-literal-nsnumber.m b/clang/test/SemaObjC/objc-literal-nsnumber.m
new file mode 100644
index 0000000..6635bea
--- /dev/null
+++ b/clang/test/SemaObjC/objc-literal-nsnumber.m
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+// rdar://10111397
+
+#if __LP64__
+typedef unsigned long NSUInteger;
+#else
+typedef unsigned int NSUInteger;
+#endif
+
+@interface NSObject
++ (NSObject*)nsobject;
+@end
+
+@interface NSNumber : NSObject
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithFloat:(float)value;
+@end
+
+int main() {
+ NSNumber * N = @3.1415926535; // expected-error {{declaration of 'numberWithDouble:' is missing in NSNumber class}}
+ NSNumber *noNumber = @__objc_yes; // expected-error {{declaration of 'numberWithBool:' is missing in NSNumber class}}
+ NSNumber * NInt = @1000;
+ NSNumber * NLongDouble = @1000.0l; // expected-error{{'long double' is not a valid literal type for NSNumber}}
+ id character = @ 'a';
+
+ NSNumber *NNegativeInt = @-1000;
+ NSNumber *NPositiveInt = @+1000;
+ NSNumber *NNegativeFloat = @-1000.1f;
+ NSNumber *NPositiveFloat = @+1000.1f;
+
+ int five = 5;
+ @-five; // expected-error{{@- must be followed by a number to form an NSNumber object}}
+ @+five; // expected-error{{@+ must be followed by a number to form an NSNumber object}}
+}
+
+// Dictionary test
+@class NSDictionary;
+
+NSDictionary *err() {
+ return @{@"name" : @"value"}; // expected-error {{declaration of 'dictionaryWithObjects:forKeys:count:' is missing in NSDictionary class}}
+}
+
+@interface NSDate : NSObject
++ (NSDate *) date;
+@end
+
+@protocol NSCopying
+- copy;
+@end
+
+@interface NSDictionary : NSObject
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id<NSCopying> [])keys count:(NSUInteger)cnt;
+@end
+
+@interface NSString<NSCopying>
+@end
+
+id NSUserName();
+
+int Int();
+
+NSDictionary * blocks() {
+ return @{ @"task" : ^ { return 17; } };
+}
+
+NSDictionary * warn() {
+ NSDictionary *dictionary = @{@"name" : NSUserName(),
+ @"date" : [NSDate date],
+ @"name2" : @"other",
+ NSObject.nsobject : @"nsobject" }; // expected-warning{{passing 'NSObject *' to parameter of incompatible type 'const id<NSCopying>'}}
+ NSDictionary *dictionary2 = @{@"name" : Int()}; // expected-error {{collection element of type 'int' is not an Objective-C object}}
+
+ NSObject *o;
+ NSDictionary *dictionary3 = @{o : o, // expected-warning{{passing 'NSObject *' to parameter of incompatible type 'const id<NSCopying>'}}
+ @"date" : [NSDate date] };
+ return dictionary3;
+}
+
+// rdar:// 11231426
+typedef float BOOL;
+
+BOOL radar11231426() {
+ return __objc_yes;
+}
diff --git a/clang/test/SemaObjC/objc-literal-sig.m b/clang/test/SemaObjC/objc-literal-sig.m
new file mode 100644
index 0000000..fb5c79f
--- /dev/null
+++ b/clang/test/SemaObjC/objc-literal-sig.m
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+typedef _Bool BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
++ (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;
++ (int)numberWithBool:(BOOL)value; // expected-note{{method returns unexpected type 'int' (should be an object type)}}
+@end
+
+@interface NSArray
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const int [])objects // expected-note{{first parameter has unexpected type 'const int *' (should be 'const id *')}}
+ count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects
+ forKeys:(const int [])keys // expected-note{{second parameter has unexpected type 'const int *' (should be 'const id *')}}
+ count:(unsigned long)cnt;
+@end
+
+void test_sig() {
+ (void)@__objc_yes; // expected-error{{literal construction method 'numberWithBool:' has incompatible signature}}
+ id array = @[ @17 ]; // expected-error{{literal construction method 'arrayWithObjects:count:' has incompatible signature}}
+ id dict = @{ @"hello" : @17 }; // expected-error{{literal construction method 'dictionaryWithObjects:forKeys:count:' has incompatible signature}}
+}
diff --git a/clang/test/SemaObjC/objc-qualified-property-lookup.m b/clang/test/SemaObjC/objc-qualified-property-lookup.m
new file mode 100644
index 0000000..48b28cb
--- /dev/null
+++ b/clang/test/SemaObjC/objc-qualified-property-lookup.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://9078584
+
+@interface NSObject @end
+
+@protocol TextInput
+-editRange;
+@end
+
+@interface I {
+ NSObject<TextInput>* editor;
+}
+- (id) Meth;
+@end
+
+@implementation I
+- (id) Meth {
+ return editor.editRange;
+}
+@end
+
diff --git a/clang/test/SemaObjC/objc-string-constant.m b/clang/test/SemaObjC/objc-string-constant.m
new file mode 100644
index 0000000..cc6d60c
--- /dev/null
+++ b/clang/test/SemaObjC/objc-string-constant.m
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -Wsemicolon-before-method-body %s -verify -fsyntax-only
+
+#define nil 0 /* id of Nil instance */
+
+@interface NSObject
+@end
+
+@interface NSString : NSObject
+
+@end
+
+@interface NSMutableString : NSString
+
+@end
+
+@interface NSSimpleCString : NSString {
+@protected
+ char *bytes;
+ int numBytes;
+}
+@end
+
+@interface NSConstantString : NSSimpleCString
+@end
+
+
+@interface Subclass : NSObject
+- (NSString *)token;
+@end
+
+@implementation Subclass
+- (NSString *)token; // expected-warning {{semicolon before method body is ignored}}
+{
+ NSMutableString *result = nil;
+
+ return (result != nil) ? result : @"";
+}
+@end
+
diff --git a/clang/test/SemaObjC/objc2-merge-gc-attribue-decl.m b/clang/test/SemaObjC/objc2-merge-gc-attribue-decl.m
new file mode 100644
index 0000000..673a741
--- /dev/null
+++ b/clang/test/SemaObjC/objc2-merge-gc-attribue-decl.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify %s
+@interface INTF @end
+
+extern INTF* p2;
+extern __strong INTF* p2;
+
+extern __strong id p1;
+extern id p1;
+
+extern id CFRunLoopGetMain();
+extern __strong id CFRunLoopGetMain();
+
+extern __weak id WLoopGetMain(); // expected-note {{previous declaration is here}}
+extern id WLoopGetMain(); // expected-error {{conflicting types for 'WLoopGetMain'}}
+
+extern id p3; // expected-note {{previous definition is here}}
+extern __weak id p3; // expected-error {{redefinition of 'p3' with a different type}}
+
+extern void *p4; // expected-note {{previous definition is here}}
+extern void * __strong p4; // expected-error {{redefinition of 'p4' with a different type}}
+
+extern id p5;
+extern __strong id p5;
+
+extern char* __strong p6; // expected-note {{previous definition is here}}
+extern char* p6; // expected-error {{redefinition of 'p6' with a different type}}
+
+extern __strong char* p7; // expected-note {{previous definition is here}}
+extern char* p7; // expected-error {{redefinition of 'p7' with a different type}}
diff --git a/clang/test/SemaObjC/objc2-warn-weak-decl.m b/clang/test/SemaObjC/objc2-warn-weak-decl.m
new file mode 100644
index 0000000..b85f768
--- /dev/null
+++ b/clang/test/SemaObjC/objc2-warn-weak-decl.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -fobjc-gc -verify %s
+// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fsyntax-only -fobjc-gc -verify %s
+struct S {
+ __weak id p; // expected-warning {{__weak attribute cannot be specified on a field declaration}}
+};
+
+int main ()
+{
+ __weak id local; // expected-warning {{Objective-C GC does not allow weak variables on the stack}}
+}
+
diff --git a/clang/test/SemaObjC/pedantic-dynamic-test.m b/clang/test/SemaObjC/pedantic-dynamic-test.m
new file mode 100644
index 0000000..61f36b3
--- /dev/null
+++ b/clang/test/SemaObjC/pedantic-dynamic-test.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wno-objc-root-class %s
+// rdar: // 7860960
+
+@interface I
+{
+ int window;
+}
+@property int window, noWarningNeeded;
+@end
+
+@implementation I
+
+@synthesize window;
+
+@dynamic noWarningNeeded;
+@end
diff --git a/clang/test/SemaObjC/pragma-pack.m b/clang/test/SemaObjC/pragma-pack.m
new file mode 100644
index 0000000..ba39257
--- /dev/null
+++ b/clang/test/SemaObjC/pragma-pack.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -verify -Wno-objc-root-class %s
+
+// Make sure pragma pack works inside ObjC methods. <rdar://problem/10893316>
+@interface X
+@end
+@implementation X
+- (void)Y {
+#pragma pack(push, 1)
+ struct x {
+ char a;
+ int b;
+ };
+#pragma pack(pop)
+ typedef char check_[sizeof (struct x) == 5 ? 1 : -1];
+}
+@end
diff --git a/clang/test/SemaObjC/property-10.m b/clang/test/SemaObjC/property-10.m
new file mode 100644
index 0000000..51eb39c
--- /dev/null
+++ b/clang/test/SemaObjC/property-10.m
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsyntax-only -Wreadonly-setter-attrs -verify %s -fblocks
+
+// Check property attribute consistency.
+
+@interface I0
+@property(readonly, readwrite) int p0; // expected-error {{property attributes 'readonly' and 'readwrite' are mutually exclusive}}
+
+@property(retain) int p1; // expected-error {{property with 'retain (or strong)' attribute must be of object type}}
+@property(strong) int s1; // expected-error {{property with 'retain (or strong)' attribute must be of object type}}
+
+@property(copy) int p2; // expected-error {{property with 'copy' attribute must be of object type}}
+
+@property(assign, copy) id p3_0; // expected-error {{property attributes 'assign' and 'copy' are mutually exclusive}}
+@property(assign, retain) id p3_1; // expected-error {{property attributes 'assign' and 'retain' are mutually exclusive}}
+@property(assign, strong) id s3_1; // expected-error {{property attributes 'assign' and 'strong' are mutually exclusive}}
+@property(copy, retain) id p3_2; // expected-error {{property attributes 'copy' and 'retain' are mutually exclusive}}
+@property(copy, strong) id s3_2; // expected-error {{property attributes 'copy' and 'strong' are mutually exclusive}}
+@property(assign, copy, retain) id p3_3; // expected-error {{property attributes 'assign' and 'copy' are mutually exclusive}}, expected-error {{property attributes 'assign' and 'retain' are mutually exclusive}}
+@property(assign, copy, strong) id s3_3; // expected-error {{property attributes 'assign' and 'copy' are mutually exclusive}}, expected-error {{property attributes 'assign' and 'strong' are mutually exclusive}}
+
+@property(unsafe_unretained, copy) id p4_0; // expected-error {{property attributes 'unsafe_unretained' and 'copy' are mutually exclusive}}
+@property(unsafe_unretained, retain) id p4_1; // expected-error {{property attributes 'unsafe_unretained' and 'retain' are mutually exclusive}}
+@property(unsafe_unretained, strong) id s4_1; // expected-error {{property attributes 'unsafe_unretained' and 'strong' are mutually exclusive}}
+@property(unsafe_unretained, copy, retain) id p4_3; // expected-error {{property attributes 'unsafe_unretained' and 'copy' are mutually exclusive}}, expected-error {{property attributes 'unsafe_unretained' and 'retain' are mutually exclusive}}
+@property(unsafe_unretained, copy, strong) id s4_3; // expected-error {{property attributes 'unsafe_unretained' and 'copy' are mutually exclusive}}, expected-error {{property attributes 'unsafe_unretained' and 'strong' are mutually exclusive}}
+
+@property id p4; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}, expected-warning {{default property attribute 'assign' not appropriate for non-gc object}}
+
+@property(nonatomic,copy) int (^includeMailboxCondition)();
+@property(nonatomic,copy) int (*includeMailboxCondition2)(); // expected-error {{property with 'copy' attribute must be of object type}}
+
+@end
+
+@interface I0()
+@property (retain) int PROP; // expected-error {{property with 'retain (or strong)' attribute must be of object type}}
+@property (strong) int SPROP; // expected-error {{property with 'retain (or strong)' attribute must be of object type}}
+@property(nonatomic,copy) int (*PROP1)(); // expected-error {{property with 'copy' attribute must be of object type}}
+@property(nonatomic,weak) int (*PROP2)(); // expected-error {{property with 'weak' attribute must be of object type}}
+@end
+
+// rdar://10357768
+@interface rdar10357768
+{
+ int n1;
+}
+@property (readonly, setter=crushN1:) int n1; // expected-warning {{setter cannot be specified for a readonly property}}
+@end
+
diff --git a/clang/test/SemaObjC/property-11.m b/clang/test/SemaObjC/property-11.m
new file mode 100644
index 0000000..2976115
--- /dev/null
+++ b/clang/test/SemaObjC/property-11.m
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface NSSound
+@end
+@interface NSFont
+@end
+
+@interface NSSound (Adds)
+@end
+
+@implementation NSSound (Adds)
+- foo {
+ return self;
+}
+- (void)setFoo:obj {
+}
+@end
+
+@implementation NSFont (Adds)
+
+- xx {
+ NSSound *x;
+ id o;
+
+ // GCC does *not* warn about the following. Since foo/setFoo: are not in the
+ // class or category interface for NSSound, the compiler shouldn't find them.
+ // For now, we will support GCC's behavior (sigh).
+ o = [x foo];
+ o = x.foo;
+ [x setFoo:o];
+ x.foo = o;
+ return 0;
+}
+
+@end
+
diff --git a/clang/test/SemaObjC/property-12.m b/clang/test/SemaObjC/property-12.m
new file mode 100644
index 0000000..cd0fccf
--- /dev/null
+++ b/clang/test/SemaObjC/property-12.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -Wreadonly-setter-attrs -verify %s
+
+@protocol P0
+@property(readonly,assign) id X; // expected-warning {{property attributes 'readonly' and 'assign' are mutually exclusive}}
+@end
+
+@protocol P1
+@property(readonly,retain) id X; // expected-warning {{property attributes 'readonly' and 'retain' are mutually exclusive}}
+@end
+
+@protocol P2
+@property(readonly,copy) id X; // expected-warning {{property attributes 'readonly' and 'copy' are mutually exclusive}}
+@end
+
+@protocol P3
+@property(readonly,readwrite) id X; // expected-error {{property attributes 'readonly' and 'readwrite' are mutually exclusive}}
+@end
+
+@protocol P4
+@property(assign,copy) id X; // expected-error {{property attributes 'assign' and 'copy' are mutually exclusive}}
+@end
+
+@protocol P5
+@property(assign,retain) id X; // expected-error {{property attributes 'assign' and 'retain' are mutually exclusive}}
+@end
+
+@protocol P6
+@property(copy,retain) id X; // expected-error {{property attributes 'copy' and 'retain' are mutually exclusive}}
+@end
+
+
+
diff --git a/clang/test/SemaObjC/property-13.m b/clang/test/SemaObjC/property-13.m
new file mode 100644
index 0000000..2ca3416
--- /dev/null
+++ b/clang/test/SemaObjC/property-13.m
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unreachable-code
+
+@interface NSObject
++ alloc;
+- init;
+@end
+
+@protocol Test
+ @property int required;
+
+@optional
+ @property int optional;
+ @property int optional1;
+ @property int optional_preexisting_setter_getter;
+ @property (setter = setOptional_preexisting_setter_getter: ,
+ getter = optional_preexisting_setter_getter) int optional_with_setter_getter_attr;
+@required
+ @property int required1;
+@optional
+ @property int optional_to_be_defined;
+ @property (readonly, getter = optional_preexisting_setter_getter) int optional_getter_attr;
+@end
+
+@interface Test : NSObject <Test> {
+ int ivar;
+ int ivar1;
+ int ivar2;
+}
+@property int required;
+@property int optional_to_be_defined;
+- (int) optional_preexisting_setter_getter;
+- (void) setOptional_preexisting_setter_getter:(int)value;
+@end
+
+@implementation Test
+@synthesize required = ivar;
+@synthesize required1 = ivar1;
+@synthesize optional_to_be_defined = ivar2;
+- (int) optional_preexisting_setter_getter { return ivar; }
+- (void) setOptional_preexisting_setter_getter:(int)value
+ {
+ ivar = value;
+ }
+- (void) setOptional_getter_attr:(int)value { ivar = value; }
+@end
+
+void abort(void);
+int main ()
+{
+ Test *x = [[Test alloc] init];
+ /* 1. Test of a required property */
+ x.required1 = 100;
+ if (x.required1 != 100)
+ abort ();
+
+ /* 2. Test of a synthesize optional property */
+ x.optional_to_be_defined = 123;
+ if (x.optional_to_be_defined != 123)
+ abort ();
+
+ /* 3. Test of optional property with pre-sxisting defined setter/getter */
+ x.optional_preexisting_setter_getter = 200;
+ if (x.optional_preexisting_setter_getter != 200)
+ abort ();
+
+ /* 4. Test of optional property with setter/getter attribute */
+ if (x.optional_with_setter_getter_attr != 200)
+ abort ();
+ return 0;
+
+ /* 5. Test of optional property with getter attribute and default setter method. */
+ x.optional_getter_attr = 1000;
+ if (x.optional_getter_attr != 1000)
+ abort ();
+
+ return 0;
+}
+
diff --git a/clang/test/SemaObjC/property-2.m b/clang/test/SemaObjC/property-2.m
new file mode 100644
index 0000000..f95af59
--- /dev/null
+++ b/clang/test/SemaObjC/property-2.m
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface Tester
+@property char PropertyAtomic_char;
+@property short PropertyAtomic_short;
+@property int PropertyAtomic_int;
+@property long PropertyAtomic_long;
+@property long long PropertyAtomic_longlong;
+@property float PropertyAtomic_float;
+@property double PropertyAtomic_double;
+@property(assign) id PropertyAtomic_id;
+@property(retain) id PropertyAtomicRetained_id;
+@property(copy) id PropertyAtomicRetainedCopied_id;
+@property(retain) id PropertyAtomicRetainedGCOnly_id;
+@property(copy) id PropertyAtomicRetainedCopiedGCOnly_id;
+@end
+
+@implementation Tester
+@dynamic PropertyAtomic_char;
+@dynamic PropertyAtomic_short;
+@dynamic PropertyAtomic_int;
+@dynamic PropertyAtomic_long;
+@dynamic PropertyAtomic_longlong;
+@dynamic PropertyAtomic_float;
+@dynamic PropertyAtomic_double;
+@dynamic PropertyAtomic_id;
+@dynamic PropertyAtomicRetained_id;
+@dynamic PropertyAtomicRetainedCopied_id;
+@dynamic PropertyAtomicRetainedGCOnly_id;
+@dynamic PropertyAtomicRetainedCopiedGCOnly_id;
+@end
+
+@interface SubClass : Tester
+{
+ char PropertyAtomic_char;
+ short PropertyAtomic_short;
+ int PropertyAtomic_int;
+ long PropertyAtomic_long;
+ long long PropertyAtomic_longlong;
+ float PropertyAtomic_float;
+ double PropertyAtomic_double;
+ id PropertyAtomic_id;
+ id PropertyAtomicRetained_id;
+ id PropertyAtomicRetainedCopied_id;
+ id PropertyAtomicRetainedGCOnly_id;
+ id PropertyAtomicRetainedCopiedGCOnly_id;
+}
+@end
+
+@implementation SubClass
+@synthesize PropertyAtomic_char;
+@synthesize PropertyAtomic_short;
+@synthesize PropertyAtomic_int;
+@synthesize PropertyAtomic_long;
+@synthesize PropertyAtomic_longlong;
+@synthesize PropertyAtomic_float;
+@synthesize PropertyAtomic_double;
+@synthesize PropertyAtomic_id;
+@synthesize PropertyAtomicRetained_id;
+@synthesize PropertyAtomicRetainedCopied_id;
+@synthesize PropertyAtomicRetainedGCOnly_id;
+@synthesize PropertyAtomicRetainedCopiedGCOnly_id;
+@end
diff --git a/clang/test/SemaObjC/property-3.m b/clang/test/SemaObjC/property-3.m
new file mode 100644
index 0000000..439dc28
--- /dev/null
+++ b/clang/test/SemaObjC/property-3.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -verify %s
+
+@interface I
+{
+ id d1;
+}
+@property (readwrite, copy) id d1;
+@property (readwrite, copy) id d2;
+@end
+
+@interface NOW : I
+@property (readonly) id d1; // expected-warning {{attribute 'readonly' of property 'd1' restricts attribute 'readwrite' of property inherited from 'I'}} expected-warning {{property 'd1' 'copy' attribute does not match the property inherited from 'I'}}
+@property (readwrite, copy) I* d2;
+@end
diff --git a/clang/test/SemaObjC/property-4.m b/clang/test/SemaObjC/property-4.m
new file mode 100644
index 0000000..2168048
--- /dev/null
+++ b/clang/test/SemaObjC/property-4.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -verify %s
+
+@interface Object
+@end
+
+@protocol ProtocolObject
+@property int class;
+@property (copy) id MayCauseError;
+@end
+
+@protocol ProtocolDerivedGCObject <ProtocolObject>
+@property int Dclass;
+@end
+
+@interface GCObject : Object <ProtocolDerivedGCObject> {
+ int ifield;
+ int iOwnClass;
+ int iDclass;
+}
+@property int OwnClass;
+@end
+
+@interface ReleaseObject : GCObject <ProtocolObject> {
+ int newO;
+ int oldO;
+}
+@property (retain) id MayCauseError; // expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from 'ProtocolObject'}}
+@end
+
diff --git a/clang/test/SemaObjC/property-5.m b/clang/test/SemaObjC/property-5.m
new file mode 100644
index 0000000..cd7cc24
--- /dev/null
+++ b/clang/test/SemaObjC/property-5.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -verify %s
+
+@protocol P1 @end
+@protocol P2 @end
+@protocol P3 @end
+
+@interface NSData @end
+
+@interface MutableNSData : NSData @end
+
+@interface Base : NSData <P1>
+@property(readonly) id ref;
+@property(readonly) Base *p_base;
+@property(readonly) NSData *nsdata;
+@property(readonly) NSData * m_nsdata;
+@end
+
+@interface Data : Base <P1, P2>
+@property(readonly) NSData *ref;
+@property(readonly) Data *p_base;
+@property(readonly) MutableNSData * m_nsdata;
+@end
+
+@interface MutedData: Data
+@property(readonly) id p_base;
+@end
+
+@interface ConstData : Data <P1, P2, P3>
+@property(readonly) ConstData *p_base;
+@end
+
+void foo(Base *b, id x) {
+ [ b setRef: x ]; // expected-warning {{method '-setRef:' not found}}
+}
diff --git a/clang/test/SemaObjC/property-6.m b/clang/test/SemaObjC/property-6.m
new file mode 100644
index 0000000..933a4f0
--- /dev/null
+++ b/clang/test/SemaObjC/property-6.m
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s
+# 1 "<command line>"
+# 1 "/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h" 1 3
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
++ class;
+@end
+
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+
+@protocol NSMutableCopying
+- (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+
+@protocol NSCoding
+- (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+
+@interface NSObject <NSObject> {}
+@end
+
+typedef struct {} NSFastEnumerationState;
+
+@protocol NSFastEnumeration
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+- (NSUInteger)count;
+@end
+
+@interface NSMutableArray : NSArray
+- (void)addObject:(id)anObject;
++ (id)arrayWithCapacity:(int)numItems;
+@end
+
+@interface NSBundle : NSObject {}
++ (NSBundle *)bundleForClass:(Class)aClass;
+- (NSString *)bundlePath;
+- (void)setBundlePath:(NSString *)x;
+@end
+
+@interface NSException : NSObject <NSCopying, NSCoding> {}
+@end
+
+@class NSArray, NSDictionary, NSError, NSString, NSURL;
+
+@interface DTPlugInManager : NSObject
+@end
+
+@implementation DTPlugInManager
++ (DTPlugInManager *)defaultPlugInManager {
+ @try {
+ NSMutableArray *plugInPaths = [NSMutableArray arrayWithCapacity:100];
+ NSBundle *frameworkBundle = [NSBundle bundleForClass:[DTPlugInManager class]];
+ frameworkBundle.bundlePath = 0;
+ [plugInPaths addObject:frameworkBundle.bundlePath];
+ }
+ @catch (NSException *exception) {}
+}
+@end
diff --git a/clang/test/SemaObjC/property-7.m b/clang/test/SemaObjC/property-7.m
new file mode 100644
index 0000000..e6cba50
--- /dev/null
+++ b/clang/test/SemaObjC/property-7.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+typedef signed char BOOL;
+typedef struct _NSZone NSZone;
+
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+@end
+
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+
+@interface NSObject <NSObject> {}
+@end
+
+@class NSString, NSData, NSMutableData, NSMutableDictionary, NSMutableArray;
+
+@interface SCMObject : NSObject <NSCopying> {}
+ @property(assign) SCMObject *__attribute__((objc_gc(weak))) parent;
+@end
+
+@interface SCMNode : SCMObject
+{
+ NSString *_name;
+}
+@property(copy) NSString *name;
+@end
+
+@implementation SCMNode
+ @synthesize name = _name;
+ - (void) setParent:(SCMObject *__attribute__((objc_gc(weak)))) inParent {
+ super.parent = inParent;
+ }
+@end
diff --git a/clang/test/SemaObjC/property-8.m b/clang/test/SemaObjC/property-8.m
new file mode 100644
index 0000000..8647aba
--- /dev/null
+++ b/clang/test/SemaObjC/property-8.m
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+
+@interface NSObject <NSObject> {} @end
+
+typedef float CGFloat;
+
+typedef enum { NSMinXEdge = 0, NSMinYEdge = 1, NSMaxXEdge = 2, NSMaxYEdge = 3 } NSFastEnumerationState;
+
+@protocol NSFastEnumeration
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+
+@class NSString;
+
+@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+- (NSUInteger)count;
+@end
+
+extern NSString * const NSBundleDidLoadNotification;
+
+@interface NSObject(NSKeyValueObserving)
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context;
+- (void)removeObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath;
+@end
+
+enum { NSCaseInsensitivePredicateOption = 0x01, NSDiacriticInsensitivePredicateOption = 0x02 };
+
+@interface NSResponder : NSObject <NSCoding> {}
+@end
+
+extern NSString * const NSFullScreenModeAllScreens;
+@interface NSWindowController : NSResponder <NSCoding> {}
+@end
+
+extern NSString *NSAlignmentBinding ;
+
+@interface _XCOQQuery : NSObject {}
+@end
+
+extern NSString *PBXWindowDidChangeFirstResponderNotification;
+
+@interface PBXModule : NSWindowController {}
+@end
+
+@class _XCOQHelpTextBackgroundView;
+@interface PBXOpenQuicklyModule : PBXModule
+{
+@private
+ _XCOQQuery *_query;
+}
+@end
+
+@interface PBXOpenQuicklyModule ()
+@property(readwrite, retain) _XCOQQuery *query;
+@end
+
+@implementation PBXOpenQuicklyModule
+@synthesize query = _query;
+- (void) _clearQuery
+{
+ [self.query removeObserver: self forKeyPath: @"matches"];
+}
+@end
+
diff --git a/clang/test/SemaObjC/property-9-impl-method.m b/clang/test/SemaObjC/property-9-impl-method.m
new file mode 100644
index 0000000..84eb363
--- /dev/null
+++ b/clang/test/SemaObjC/property-9-impl-method.m
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// rdar://5967199
+
+typedef signed char BOOL;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+
+@protocol NSObject
+- (BOOL) isEqual:(id) object;
+@end
+
+@protocol NSCoding
+- (void) encodeWithCoder:(NSCoder *) aCoder;
+@end
+
+@interface NSObject < NSObject > {}
+@end
+
+typedef float CGFloat;
+typedef struct _NSPoint {} NSSize;
+typedef struct _NSRect {} NSRect;
+typedef enum { NSMinXEdge = 0, NSMinYEdge = 1, NSMaxXEdge = 2, NSMaxYEdge = 3} NSRectEdge;
+extern void NSDivideRect(NSRect inRect, NSRect * slice, NSRect * rem, CGFloat amount, NSRectEdge edge);
+
+@interface NSResponder:NSObject < NSCoding > {}
+@end
+
+@protocol NSAnimatablePropertyContainer
+- (id) animator;
+@end
+
+extern NSString *NSAnimationTriggerOrderIn;
+
+@interface NSView:NSResponder < NSAnimatablePropertyContainer > {}
+-(NSRect) bounds;
+@end
+
+enum {
+ NSBackgroundStyleLight = 0, NSBackgroundStyleDark, NSBackgroundStyleRaised, NSBackgroundStyleLowered
+};
+
+@interface NSTabView:NSView {}
+@end
+
+@ class OrganizerTabHeader;
+
+@interface OrganizerTabView:NSTabView {}
+@property(assign)
+NSSize minimumSize;
+@end
+
+@interface OrganizerTabView()
+@property(readonly) OrganizerTabHeader *tabHeaderView;
+@property(readonly) NSRect headerRect;
+@end
+
+@implementation OrganizerTabView
+@dynamic tabHeaderView, headerRect, minimumSize;
+-(CGFloat) tabAreaThickness { return 0; }
+-(NSRectEdge) rectEdgeForTabs {
+ NSRect dummy, result = {};
+ NSDivideRect(self.bounds, &result, &dummy, self.tabAreaThickness, self.rectEdgeForTabs);
+ return 0;
+}
+@end
+
+@class NSImage;
+
+@interface XCImageArchiveEntry : NSObject
+{
+ NSImage *_cachedImage;
+}
+
+@end
+
+@implementation XCImageArchiveEntry
+
+- (NSImage *)image
+{
+ return _cachedImage;
+}
+
+@end
+
+@interface XCImageArchive : NSObject
+@end
+
+@implementation XCImageArchive
+
+- (NSImage *)imageNamed:(NSString *)name
+{
+ XCImageArchiveEntry * entry;
+ return entry ? entry.image : ((void *)0);
+}
+
+@end
diff --git a/clang/test/SemaObjC/property-9.m b/clang/test/SemaObjC/property-9.m
new file mode 100644
index 0000000..4bed875
--- /dev/null
+++ b/clang/test/SemaObjC/property-9.m
@@ -0,0 +1,108 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+typedef signed char BOOL;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+
+@interface NSObject <NSObject> {} @end
+
+@interface _NSServicesInContextMenu : NSObject {
+ id _requestor;
+ NSObject *_appleEventDescriptor;
+}
+
+@property (retain, nonatomic) id requestor;
+@property (retain, nonatomic) id appleEventDescriptor;
+
+@end
+
+@implementation _NSServicesInContextMenu
+
+@synthesize requestor = _requestor, appleEventDescriptor = _appleEventDescriptor;
+
+@end
+
+@class NSString;
+
+@protocol MyProtocol
+- (NSString *)stringValue;
+@end
+
+@interface MyClass : NSObject {
+ id _myIvar;
+}
+@property (readwrite, retain) id<MyProtocol> myIvar;
+@end
+
+@implementation MyClass
+@synthesize myIvar = _myIvar;
+@end
+
+
+@interface BadPropClass
+{
+ int _awesome;
+}
+
+@property (readonly) int; // expected-warning {{declaration does not declare anything}}
+@property (readonly) ; // expected-error {{type name requires a specifier or qualifier}}
+@property (readonly) int : 4; // expected-error {{property requires fields to be named}}
+
+
+// test parser recovery: rdar://6254579
+@property ( // expected-note {{to match this '('}}
+ readonly getter=isAwesome) // expected-error {{expected ')'}}
+
+ int _awesome;
+@property (readonlyx) // expected-error {{unknown property attribute 'readonlyx'}}
+ int _awesome2;
+
+@property ( // expected-note {{to match this '('}}
+ +) // expected-error {{expected ')'}}
+
+ int _awesome3;
+
+@end
+
+@protocol PVImageViewProtocol
+@property int inEyeDropperMode;
+@end
+
+@interface Cls
+@property int inEyeDropperMode;
+@end
+
+@interface PVAdjustColor @end
+
+@implementation PVAdjustColor
+
+- xx {
+ id <PVImageViewProtocol> view;
+ Cls *c;
+
+ c.inEyeDropperMode = 1;
+ view.inEyeDropperMode = 1;
+}
+@end
+
+// radar 7427072
+@interface MyStyleIntf
+{
+ int _myStyle;
+}
+
+@property(readonly) int myStyle;
+
+- (float)setMyStyle:(int)style;
+@end
+
+// rdar://8774513
+@class MDAInstance; // expected-note {{forward declaration of class here}}
+
+@interface MDATestDocument
+@property(retain) MDAInstance *instance;
+@end
+
+id f0(MDATestDocument *d) {
+ return d.instance.path; // expected-error {{property 'path' cannot be found in forward class object 'MDAInstance'}}
+}
+
diff --git a/clang/test/SemaObjC/property-and-class-extension.m b/clang/test/SemaObjC/property-and-class-extension.m
new file mode 100644
index 0000000..7040078
--- /dev/null
+++ b/clang/test/SemaObjC/property-and-class-extension.m
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+/**
+When processing @synthesize, treat ivars in a class extension the same as ivars in the class @interface,
+and treat ivars in a superclass extension the same as ivars in the superclass @interface.
+In particular, when searching for an ivar to back an @synthesize, do look at ivars in the class's own class
+extension but ignore any ivars in superclass class extensions.
+*/
+
+@interface Super {
+ int ISA;
+}
+@end
+
+@interface Super() {
+ int Property; // expected-note {{previously declared 'Property' here}}
+}
+@end
+
+@interface SomeClass : Super {
+ int interfaceIvar1;
+ int interfaceIvar2;
+}
+@property int Property;
+@property int Property1;
+@end
+
+@interface SomeClass () {
+ int Property1;
+}
+@end
+
+@implementation SomeClass
+@synthesize Property; // expected-error {{property 'Property' attempting to use ivar 'Property' declared in super class 'Super'}}
+@synthesize Property1; // OK
+@end
diff --git a/clang/test/SemaObjC/property-and-ivar-use.m b/clang/test/SemaObjC/property-and-ivar-use.m
new file mode 100644
index 0000000..5b40d85
--- /dev/null
+++ b/clang/test/SemaObjC/property-and-ivar-use.m
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// Do not issue error if 'ivar' used previously belongs to the inherited class
+// and has same name as @dynalic property in current class.
+
+typedef signed char BOOL;
+
+@protocol IDEBuildable
+@property (readonly) BOOL hasRecursiveDependencyCycle;
+@end
+
+@protocol IDEBuildableProduct <IDEBuildable>
+@end
+
+@interface IDEBuildableSupportMixIn
+@property (readonly) BOOL hasRecursiveDependencyCycle;
+@end
+
+@interface Xcode3TargetBuildable <IDEBuildable>
+{
+ IDEBuildableSupportMixIn *_buildableMixIn;
+}
+@end
+
+@interface Xcode3TargetProduct : Xcode3TargetBuildable <IDEBuildableProduct>
+@end
+
+@implementation Xcode3TargetBuildable
+- (BOOL)hasRecursiveDependencyCycle
+{
+ return [_buildableMixIn hasRecursiveDependencyCycle];
+}
+@end
+
+@implementation Xcode3TargetProduct
+@dynamic hasRecursiveDependencyCycle;
+@end
diff --git a/clang/test/SemaObjC/property-category-1.m b/clang/test/SemaObjC/property-category-1.m
new file mode 100644
index 0000000..3788bc9
--- /dev/null
+++ b/clang/test/SemaObjC/property-category-1.m
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface Object
++ (id)new;
+@end
+
+@interface ReadOnly : Object
+{
+ int _object;
+ int _Anotherobject;
+}
+@property(readonly) int object;
+@property(readonly) int Anotherobject;
+@end
+
+@interface ReadOnly ()
+@property(readwrite) int object;
+@property(readwrite, setter = myAnotherobjectSetter:) int Anotherobject;
+@end
+
+@implementation ReadOnly
+@synthesize object = _object;
+@synthesize Anotherobject = _Anotherobject;
+- (void) myAnotherobjectSetter : (int)val {
+ _Anotherobject = val;
+}
+- (int) Anotherobject { return _Anotherobject; }
+@end
+
+int main(int argc, char **argv) {
+ ReadOnly *test = [ReadOnly new];
+ test.object = 12345;
+ test.Anotherobject = 200;
+ return test.object - 12345 + test.Anotherobject - 200;
+}
+
+///
+
+@interface I0
+@property(readonly) int p0; // expected-note {{property declared here}}
+@end
+
+@interface I0 (Cat0)
+@end
+
+@interface I0 (Cat1)
+@end
+
+@implementation I0 // expected-warning {{property 'p0' requires method 'p0' to be define}}
+- (void) foo {
+ self.p0 = 0; // expected-error {{assignment to readonly property}}
+}
+@end
diff --git a/clang/test/SemaObjC/property-category-2.m b/clang/test/SemaObjC/property-category-2.m
new file mode 100644
index 0000000..ecc3681
--- /dev/null
+++ b/clang/test/SemaObjC/property-category-2.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Test that a property can be synthesize in a category
+// implementation with no error.
+
+@protocol MyProtocol
+@property float myFloat;
+@property float anotherFloat; // expected-note 2 {{property declared}}
+@end
+
+@interface MyObject { float anotherFloat; }
+@end
+
+@interface MyObject (CAT) <MyProtocol>
+@end
+
+@implementation MyObject (CAT) // expected-warning {{property 'anotherFloat' requires method}} \
+ // expected-warning {{property 'anotherFloat' requires method 'setAnotherFloat:'}}
+@dynamic myFloat; // OK
+@synthesize anotherFloat; // expected-error {{@synthesize not allowed in a category's implementation}}
+@end
diff --git a/clang/test/SemaObjC/property-category-3.m b/clang/test/SemaObjC/property-category-3.m
new file mode 100644
index 0000000..47e93a3
--- /dev/null
+++ b/clang/test/SemaObjC/property-category-3.m
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@protocol P
+ @property(readonly) int X; // expected-note {{property declared here}}
+@end
+
+@protocol P1<P>
+ @property (copy) id ID;
+@end
+
+@interface I
+@end
+
+@interface I (Cat) <P>
+@property float X; // expected-warning {{property type 'float' is incompatible with type 'int' inherited from 'P'}}
+@end
+
+@interface I (Cat2) <P1>
+@property (retain) id ID; // expected-warning {{property 'ID' 'copy' attribute does not match the property inherited from 'P1'}}
+@end
+
+
+@interface A
+@property(assign) int categoryProperty;
+@end
+
+// Don't issue warning on unimplemented setter/getter
+// because property is @dynamic.
+@implementation A
+@dynamic categoryProperty;
+@end
diff --git a/clang/test/SemaObjC/property-category-4.m b/clang/test/SemaObjC/property-category-4.m
new file mode 100644
index 0000000..e7939b3
--- /dev/null
+++ b/clang/test/SemaObjC/property-category-4.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface IDELogNavigator
+{
+ id selectedObjects;
+}
+@end
+
+@interface IDELogNavigator (CAT)
+ @property (readwrite, retain) id selectedObjects; // expected-note {{property declared here}}
+ @property (readwrite, retain) id d_selectedObjects; // expected-note {{property declared here}}
+@end
+
+@implementation IDELogNavigator
+@synthesize selectedObjects = _selectedObjects; // expected-error {{property declared in category 'CAT' cannot be implemented in class implementation}}
+@dynamic d_selectedObjects; // expected-error {{property declared in category 'CAT' cannot be implemented in class implementation}}
+@end
+
diff --git a/clang/test/SemaObjC/property-category-impl.m b/clang/test/SemaObjC/property-category-impl.m
new file mode 100644
index 0000000..9524c22
--- /dev/null
+++ b/clang/test/SemaObjC/property-category-impl.m
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+/* This test is for categories which don't implement the accessors but some accessors are
+ implemented in their base class implementation. In this case,no warning must be issued.
+*/
+
+@interface MyClass
+{
+ int _foo;
+}
+@property(readonly) int foo;
+@end
+
+@implementation MyClass
+- (int) foo { return _foo; }
+@end
+
+@interface MyClass (private)
+@property(readwrite) int foo;
+@end
+
+@implementation MyClass (private)
+- (void) setFoo:(int)foo { _foo = foo; }
+@end
+
+@interface MyClass (public)
+@property(readwrite) int foo; // expected-note {{property declared here}}
+@end
+
+@implementation MyClass (public)// expected-warning {{property 'foo' requires method 'setFoo:' to be defined }}
+@end
diff --git a/clang/test/SemaObjC/property-dot-receiver.m b/clang/test/SemaObjC/property-dot-receiver.m
new file mode 100644
index 0000000..c5a928b
--- /dev/null
+++ b/clang/test/SemaObjC/property-dot-receiver.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://8962253
+
+@interface Singleton {
+}
++ (Singleton*) instance;
+@end
+
+@implementation Singleton
+
+- (void) someSelector { }
+
++ (Singleton*) instance { return 0; }
+
++ (void) compileError
+{
+ [Singleton.instance someSelector]; // clang issues error here
+}
+
+@end
+
diff --git a/clang/test/SemaObjC/property-error-readonly-assign.m b/clang/test/SemaObjC/property-error-readonly-assign.m
new file mode 100644
index 0000000..3484172
--- /dev/null
+++ b/clang/test/SemaObjC/property-error-readonly-assign.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface A
+ -(int) x;
+@property (readonly) int x;
+@property int ok;
+@end
+
+@interface B
+ -(void) setOk:(int)arg;
+ -(int) x;
+ -(int) ok;
+@end
+
+void f0(A *a, B* b) {
+ a.x = 10; // expected-error {{assignment to readonly property}}
+ a.ok = 20;
+ b.x = 10; // expected-error {{no setter method 'setX:' for assignment to property}}
+ b.ok = 20;
+}
+
+typedef struct {
+ int i1, i2;
+} NSRect;
+
+NSRect NSMakeRect();
+
+@interface NSWindow
+{
+ NSRect _frame;
+}
+- (NSRect)frame;
+@end
+
+@interface NSWindow (Category)
+-(void)methodToMakeClangCrash;
+@end
+
+@implementation NSWindow (Category)
+-(void)methodToMakeClangCrash
+{
+ self.frame = NSMakeRect(); // expected-error {{no setter method 'setFrame:' for assignment to property}}
+}
+@end
diff --git a/clang/test/SemaObjC/property-expression-error.m b/clang/test/SemaObjC/property-expression-error.m
new file mode 100644
index 0000000..e306722
--- /dev/null
+++ b/clang/test/SemaObjC/property-expression-error.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface AddressMyProperties
+{
+ unsigned index;
+}
+@property unsigned index;
+@end
+
+@implementation AddressMyProperties
+@synthesize index;
+@end
+
+int main() {
+ AddressMyProperties *object;
+ &object.index; // expected-error {{address of property expression requested}}
+ return 0;
+}
+
+typedef int Foo;
+void test() {
+ Foo.x; // expected-error {{expected identifier or '('}}
+}
diff --git a/clang/test/SemaObjC/property-impl-misuse.m b/clang/test/SemaObjC/property-impl-misuse.m
new file mode 100644
index 0000000..c3cedb0
--- /dev/null
+++ b/clang/test/SemaObjC/property-impl-misuse.m
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface I {
+ int Y;
+}
+@property int X;
+@property int Y;
+@property int Z;
+@end
+
+@implementation I
+@dynamic X; // expected-note {{previous declaration is here}}
+@dynamic X; // expected-error {{property 'X' is already implemented}}
+@synthesize Y; // expected-note {{previous use is here}}
+@synthesize Z=Y; // expected-error {{synthesized properties 'Z' and 'Y' both claim ivar 'Y'}}
+@end
+
+// rdar://8703553
+@interface IDEPathCell
+{
+@private
+ id _gradientStyle;
+}
+
+@property (readwrite, assign, nonatomic) id gradientStyle;
+@end
+
+@implementation IDEPathCell
+
+@synthesize gradientStyle = _gradientStyle;
+- (void)setGradientStyle:(id)value { }
+
++ (void)_componentCellWithRepresentedObject {
+ self.gradientStyle; // expected-error {{property 'gradientStyle' not found on object of type 'Class'}}
+}
+@end
diff --git a/clang/test/SemaObjC/property-in-class-extension.m b/clang/test/SemaObjC/property-in-class-extension.m
new file mode 100644
index 0000000..a7b5130
--- /dev/null
+++ b/clang/test/SemaObjC/property-in-class-extension.m
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://7766184
+
+@interface Foo @end
+
+@interface Foo ()
+ @property (readonly) int bar;
+@end
+
+void FUNC () {
+ Foo *foo;
+ foo.bar = 0; // expected-error {{assignment to readonly property}}
+}
+
+// rdar://8747333
+@class NSObject;
+
+@interface rdar8747333 {
+@private
+ NSObject *_bar;
+ NSObject *_baz;
+ NSObject *_bam;
+}
+- (NSObject *)baz;
+@end
+
+@interface rdar8747333 ()
+- (NSObject *)bar;
+@end
+
+@interface rdar8747333 ()
+@property (readwrite, assign) NSObject *bar;
+@property (readwrite, assign) NSObject *baz;
+@property (readwrite, assign) NSObject *bam;
+@property (readwrite, assign) NSObject *warn;
+@end
+
+@interface rdar8747333 ()
+- (NSObject *)bam;
+- (NSObject *)warn; // expected-note {{method definition for 'warn' not found}}
+- (void)setWarn : (NSObject *)val; // expected-note {{method definition for 'setWarn:' not found}}
+@end
+
+@implementation rdar8747333 // expected-warning {{incomplete implementation}}
+@synthesize bar = _bar;
+@synthesize baz = _baz;
+@synthesize bam = _bam;
+@dynamic warn;
+@end
+
diff --git a/clang/test/SemaObjC/property-inherited.m b/clang/test/SemaObjC/property-inherited.m
new file mode 100644
index 0000000..f5f1b42
--- /dev/null
+++ b/clang/test/SemaObjC/property-inherited.m
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 -x objective-c++ %s -fsyntax-only -verify
+
+// rdar://6497242 Inherited overridden protocol declared objects don't work
+// rdar://9740328 Case for c++
+
+@protocol NSObject @end
+@interface NSObject @end
+
+@protocol FooDelegate<NSObject>
+@optional
+- (void)fooTask;
+@end
+
+@protocol BarDelegate<NSObject, FooDelegate>
+@optional
+- (void)barTask;
+@end
+
+@interface Foo : NSObject {
+ id _delegate;
+}
+@property(nonatomic, assign) id<FooDelegate> delegate;
+@property(nonatomic, assign) id<BarDelegate> delegate2; // expected-note {{property declared here}}
+@end
+@interface Bar : Foo {
+}
+@property(nonatomic, assign) id<BarDelegate> delegate;
+@property(nonatomic, assign) id<FooDelegate> delegate2; // expected-warning{{property type 'id<FooDelegate>' is incompatible with type 'id<BarDelegate>' inherited from 'Foo'}}
+@end
+
+@interface NSData @end
+
+@interface NSMutableData : NSData @end
+
+@interface Base : NSData
+@property(assign) id ref;
+@property(assign) Base *p_base;
+@property(assign) NSMutableData *p_data; // expected-note {{property declared here}}
+@end
+
+@interface Data : Base
+@property(assign) NSData *ref;
+@property(assign) Data *p_base;
+@property(assign) NSData *p_data; // expected-warning{{property type 'NSData *' is incompatible with type 'NSMutableData *' inherited from 'Base'}}
+@end
diff --git a/clang/test/SemaObjC/property-ivar-mismatch.m b/clang/test/SemaObjC/property-ivar-mismatch.m
new file mode 100644
index 0000000..6abd6e6
--- /dev/null
+++ b/clang/test/SemaObjC/property-ivar-mismatch.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// Test that arithmatic types on property and its ivar have exact match.
+
+@interface Test4
+{
+ char ivar; // expected-note{{ivar is declared here}}
+}
+@property int prop;
+@end
+
+@implementation Test4
+@synthesize prop = ivar; // expected-error {{type of property 'prop' ('int') does not match type of ivar 'ivar' ('char')}}
+@end
+
diff --git a/clang/test/SemaObjC/property-lookup-in-id.m b/clang/test/SemaObjC/property-lookup-in-id.m
new file mode 100644
index 0000000..38aa32c
--- /dev/null
+++ b/clang/test/SemaObjC/property-lookup-in-id.m
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://9106929
+
+typedef struct objc_class *Class;
+
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+
+typedef struct __FSEventStream* FSEventStreamRef;
+
+extern id NSApp;
+
+@interface FileSystemMonitor {
+
+ FSEventStreamRef fsEventStream;
+}
+@property(assign) FSEventStreamRef fsEventStream;
+
+@end
+
+@implementation FileSystemMonitor
+@synthesize fsEventStream;
+
+- (void)startFSEventGathering:(id)sender
+{
+ fsEventStream = [NSApp delegate].fsEventStream; // expected-warning {{instance method '-delegate' not found (return type defaults to 'id')}} \
+ // expected-error {{property 'fsEventStream' not found on object of type 'id'}}
+
+}
+@end
+
diff --git a/clang/test/SemaObjC/property-method-lookup-impl.m b/clang/test/SemaObjC/property-method-lookup-impl.m
new file mode 100644
index 0000000..19d4e68
--- /dev/null
+++ b/clang/test/SemaObjC/property-method-lookup-impl.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface SSyncCEList
+{
+ id _list;
+}
+@end
+
+@implementation SSyncCEList
+
+- (id) list { return 0; }
+@end
+
+@interface SSyncConflictList : SSyncCEList
+@end
+
+@implementation SSyncConflictList
+
+- (id)Meth : (SSyncConflictList*)other
+ {
+ return other.list;
+ }
+@end
+
diff --git a/clang/test/SemaObjC/property-missing.m b/clang/test/SemaObjC/property-missing.m
new file mode 100644
index 0000000..3ebf0a8
--- /dev/null
+++ b/clang/test/SemaObjC/property-missing.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR3234
+
+@protocol NSCopying @end
+@interface NSObject @end
+
+void f1(NSObject *o)
+{
+ o.foo; // expected-error{{property 'foo' not found on object of type 'NSObject *'}}
+}
+
+void f2(id<NSCopying> o)
+{
+ o.foo; // expected-error{{property 'foo' not found on object of type 'id<NSCopying>'}}
+}
+
+void f3(id o)
+{
+ o.foo; // expected-error{{property 'foo' not found on object of type 'id'}}
+}
+
+// rdar://8851803
+@class SomeOtherClass; // expected-note {{forward declaration of class here}}
+
+@interface MyClass {
+ SomeOtherClass *someOtherObject;
+}
+@end
+
+void foo(MyClass *myObject) {
+ myObject.someOtherObject.someProperty = 0; // expected-error {{property 'someOtherObject' refers to an incomplete Objective-C class 'SomeOtherClass' (with no @interface available)}}
+}
+
diff --git a/clang/test/SemaObjC/property-nonfragile-abi.m b/clang/test/SemaObjC/property-nonfragile-abi.m
new file mode 100644
index 0000000..55bf91f
--- /dev/null
+++ b/clang/test/SemaObjC/property-nonfragile-abi.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef signed char BOOL;
+
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+@end
+
+@interface NSObject <NSObject> {}
+@end
+
+@interface XCDeviceWillExecuteInfoBaton : NSObject {}
+ @property (retain) __attribute__((objc_gc(strong))) NSString *sdkPath;
+@end
+
+@implementation XCDeviceWillExecuteInfoBaton
+ @synthesize sdkPath;
+@end
+
diff --git a/clang/test/SemaObjC/property-noprotocol-warning.m b/clang/test/SemaObjC/property-noprotocol-warning.m
new file mode 100644
index 0000000..71bb86a
--- /dev/null
+++ b/clang/test/SemaObjC/property-noprotocol-warning.m
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+
+@interface Object
++ (id) new;
+@end
+
+@protocol GCObject
+@property int class;
+@end
+
+@protocol DerivedGCObject <GCObject>
+@property int Dclass;
+@end
+
+@interface GCObject : Object <DerivedGCObject> {
+ int ifield;
+ int iOwnClass;
+ int iDclass;
+}
+@property int OwnClass;
+@end
+
+@implementation GCObject : Object
+@synthesize class=ifield;
+@synthesize Dclass=iDclass;
+@synthesize OwnClass=iOwnClass;
+@end
+
+int main(int argc, char **argv) {
+ GCObject *f = [GCObject new];
+ f.class = 5;
+ f.Dclass = 1;
+ f.OwnClass = 3;
+ return f.class + f.Dclass + f.OwnClass - 9;
+}
diff --git a/clang/test/SemaObjC/property-not-lvalue.m b/clang/test/SemaObjC/property-not-lvalue.m
new file mode 100644
index 0000000..12d2cc6
--- /dev/null
+++ b/clang/test/SemaObjC/property-not-lvalue.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+typedef struct NSSize {
+ int width;
+ struct {
+ int dim;
+ } inner;
+} NSSize;
+
+@interface Foo {
+ NSSize _size;
+}
+@property NSSize size;
+@end
+
+void foo() {
+ Foo *f;
+ f.size.width = 2.2; // expected-error {{expression is not assignable}}
+ f.size.inner.dim = 200; // expected-error {{expression is not assignable}}
+}
+
+// radar 7628953
+
+@interface Gorf {
+}
+- (NSSize)size;
+@end
+
+@implementation Gorf
+- (void)MyView_sharedInit {
+ self.size.width = 2.2; // expected-error {{expression is not assignable}}
+}
+- (NSSize)size {}
+@end
diff --git a/clang/test/SemaObjC/property-ns-returns-not-retained-attr.m b/clang/test/SemaObjC/property-ns-returns-not-retained-attr.m
new file mode 100644
index 0000000..96ef3ed
--- /dev/null
+++ b/clang/test/SemaObjC/property-ns-returns-not-retained-attr.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://9636091
+
+@interface I
+@property (nonatomic, retain) id newName __attribute__((ns_returns_not_retained)) ;
+
+@property (nonatomic, retain) id newName1 __attribute__((ns_returns_not_retained)) ;
+- (id) newName1 __attribute__((ns_returns_not_retained));
+
+@property (nonatomic, retain) id newName2 __attribute__((ns_returns_not_retained)); // expected-note {{roperty declared here}}
+- (id) newName2; // expected-warning {{property declared as returning non-retained objects; getter returning retained objects}}
+@end
+
+@implementation I
+@synthesize newName;
+
+@synthesize newName1;
+- (id) newName1 { return 0; }
+
+@synthesize newName2;
+@end
diff --git a/clang/test/SemaObjC/property-redundant-decl-accessor.m b/clang/test/SemaObjC/property-redundant-decl-accessor.m
new file mode 100644
index 0000000..3b0e825
--- /dev/null
+++ b/clang/test/SemaObjC/property-redundant-decl-accessor.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -Werror -verify -Wno-objc-root-class %s
+
+@interface MyClass {
+ const char *_myName;
+}
+
+@property const char *myName;
+
+- (const char *)myName;
+- (void)setMyName:(const char *)name;
+
+@end
+
+@implementation MyClass
+
+@synthesize myName = _myName;
+
+@end
diff --git a/clang/test/SemaObjC/property-typecheck-1.m b/clang/test/SemaObjC/property-typecheck-1.m
new file mode 100644
index 0000000..f71e4a0
--- /dev/null
+++ b/clang/test/SemaObjC/property-typecheck-1.m
@@ -0,0 +1,101 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface A
+-(float) x; // expected-note {{declared here}}
+@property int x; // expected-warning {{type of property 'x' does not match type of accessor 'x'}}
+@end
+
+@interface A (Cat)
+@property int moo; // expected-note {{previous definition is here}}
+@end
+
+@implementation A (Cat)
+-(int) moo {
+ return 0;
+}
+-(void) setMoo: (float) x { // expected-warning {{conflicting parameter types in implementation of 'setMoo:': 'int' vs 'float'}}
+}
+@end
+
+
+typedef int T[2];
+typedef void (F)(void);
+
+@interface C
+@property(assign) T p2; // expected-error {{property cannot have array or function type 'T'}}
+
+@property(assign) F f2; // expected-error {{property cannot have array or function type 'F'}}
+
+@end
+
+
+@class SSyncSet;
+
+@interface SPeer
+ @property(nonatomic,readonly,retain) SSyncSet* syncSet;
+@end
+
+@class SSyncSet_iDisk;
+
+@interface SPeer_iDisk_remote1 : SPeer
+- (SSyncSet_iDisk*) syncSet; // expected-note {{declared here}}
+@end
+
+@interface SPeer_iDisk_local
+- (SSyncSet_iDisk*) syncSet;
+@end
+
+@interface SSyncSet
+@end
+
+@interface SSyncSet_iDisk
+@property(nonatomic,readonly,retain) SPeer_iDisk_local* localPeer;
+@end
+
+@interface SPeer_iDisk_remote1 (protected)
+@end
+
+@implementation SPeer_iDisk_remote1 (protected)
+- (id) preferredSource1
+{
+ return self.syncSet.localPeer; // expected-warning {{type of property 'syncSet' does not match type of accessor 'syncSet'}}
+}
+@end
+
+@interface NSArray @end
+
+@interface NSMutableArray : NSArray
+@end
+
+@interface Class1
+{
+ NSMutableArray* pieces;
+ NSArray* first;
+}
+
+@property (readonly) NSArray* pieces; // expected-warning {{type of property 'pieces' does not match type of accessor 'pieces'}}
+@property (readonly) NSMutableArray* first;
+
+- (NSMutableArray*) pieces; // expected-note {{declared here}} // expected-note {{declared here}}
+- (NSArray*) first;
+@end
+
+@interface Class2 {
+ Class1* container;
+}
+
+@end
+
+@implementation Class2
+
+- (id) lastPiece
+{
+ return container.pieces; // expected-warning {{type of property 'pieces' does not match type of accessor 'pieces'}}
+}
+
+- (id)firstPeice
+{
+ return container.first;
+}
+@end
+
diff --git a/clang/test/SemaObjC/property-user-setter.m b/clang/test/SemaObjC/property-user-setter.m
new file mode 100644
index 0000000..7d4e544
--- /dev/null
+++ b/clang/test/SemaObjC/property-user-setter.m
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface I0
+@property(readonly) int x;
+@property(readonly) int y;
+@property(readonly) int z;
+-(void) setY: (int) y0;
+@end
+
+@interface I0 (Cat0)
+-(void) setX: (int) a0;
+@end
+
+@implementation I0
+@dynamic x;
+@dynamic y;
+@dynamic z;
+-(void) setY: (int) y0{}
+
+-(void) im0 {
+ self.x = 0;
+ self.y = 2;
+ self.z = 2; // expected-error {{assignment to readonly property}}
+}
+@end
+
+// Test when property is 'readonly' but it has a setter in
+// its implementation only.
+@interface I1 {
+}
+@property(readonly) int identifier;
+@end
+
+
+@implementation I1
+@dynamic identifier;
+- (void)setIdentifier:(int)ident {}
+
+- (id)initWithIdentifier:(int)Arg {
+ self.identifier = 0;
+}
+
+@end
+
+
+// Also in a category implementation
+@interface I1(CAT)
+@property(readonly) int rprop;
+@end
+
+
+@implementation I1(CAT)
+@dynamic rprop;
+- (void)setRprop:(int)ident {}
+
+- (id)initWithIdentifier:(int)Arg {
+ self.rprop = 0;
+}
+
+@end
+
+static int g_val;
+
+@interface Root
++ alloc;
+- init;
+@end
+
+@interface Subclass : Root
+{
+ int setterOnly;
+}
+- (void) setSetterOnly:(int)value;
+@end
+
+@implementation Subclass
+- (void) setSetterOnly:(int)value {
+ setterOnly = value;
+ g_val = setterOnly;
+}
+@end
+
+@interface C {}
+// - (int)Foo;
+- (void)setFoo:(int)value;
+@end
+
+void g(int); // expected-note {{passing argument to parameter here}}
+
+void f(C *c) {
+ c.Foo = 17; // OK
+ g(c.Foo); // expected-error {{expected getter method not found on object of type 'C *'}}
+}
+
+
+void abort(void);
+int main (void) {
+ Subclass *x = [[Subclass alloc] init];
+
+ x.setterOnly = 4; // OK
+ if (g_val != 4)
+ abort ();
+ return 0;
+}
diff --git a/clang/test/SemaObjC/property-weak.m b/clang/test/SemaObjC/property-weak.m
new file mode 100644
index 0000000..a4397a6
--- /dev/null
+++ b/clang/test/SemaObjC/property-weak.m
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+
+@interface foo
+@property(nonatomic) int foo __attribute__((weak_import));
+@end
diff --git a/clang/test/SemaObjC/property.m b/clang/test/SemaObjC/property.m
new file mode 100644
index 0000000..a948741
--- /dev/null
+++ b/clang/test/SemaObjC/property.m
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface I
+{
+ int IVAR; // expected-note{{ivar is declared here}}
+ int name;
+}
+@property int d1;
+@property id prop_id; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}, expected-warning {{default property attribute 'assign' not appropriate for non-gc object}}
+@property int name;
+@end
+
+@interface I(CAT)
+@property int d1; // expected-note 2 {{property declared here}}
+@end
+
+@implementation I
+@synthesize d1; // expected-error {{synthesized property 'd1' must either be named the same as}}
+@dynamic bad; // expected-error {{property implementation must have its declaration in interface 'I'}}
+@synthesize prop_id; // expected-error {{synthesized property 'prop_id' must either be named the same}} // expected-note {{previous declaration is here}}
+@synthesize prop_id = IVAR; // expected-error {{type of property 'prop_id' ('id') does not match type of ivar 'IVAR' ('int')}} // expected-error {{property 'prop_id' is already implemented}}
+@synthesize name; // OK! property with same name as an accessible ivar of same name
+@end
+
+@implementation I(CAT) // expected-warning {{property 'd1' requires method 'd1' to be defined }} \
+ // expected-warning {{property 'd1' requires method 'setD1:' to be defined }}
+@synthesize d1; // expected-error {{@synthesize not allowed in a category's implementation}}
+@dynamic bad; // expected-error {{property implementation must have its declaration in the category 'CAT'}}
+@end
+
+@implementation E // expected-warning {{cannot find interface declaration for 'E'}}
+@dynamic d; // expected-error {{property implementation must have its declaration in interface 'E'}}
+@end
+
+@implementation Q(MYCAT) // expected-error {{cannot find interface declaration for 'Q'}}
+@dynamic d; // expected-error {{property implementation in a category with no category declaration}}
+@end
+
+@interface Foo
+@property double bar;
+@end
+
+int func1() {
+ id foo;
+ double bar = [foo bar];
+ return 0;
+}
+
+// PR3932
+typedef id BYObjectIdentifier;
+@interface Foo1 {
+ void *isa;
+}
+@property(copy) BYObjectIdentifier identifier;
+@end
+
+@interface Foo2
+{
+ int ivar;
+}
+@property int treeController; // expected-note {{property declared here}}
+@property int ivar; // OK
+@property int treeController; // expected-error {{property has a previous declaration}}
+@end
+
+// rdar://10127639
+@synthesize window; // expected-error {{missing context for property implementation declaration}}
+
+// rdar://10408414
+Class test6_getClass();
+@interface Test6
+@end
+@implementation Test6
++ (float) globalValue { return 5.0f; }
++ (float) gv { return test6_getClass().globalValue; }
+@end
+
+@interface Test7
+@property unsigned length;
+@end
+void test7(Test7 *t) {
+ char data[t.length] = {}; // expected-error {{variable-sized object may not be initialized}}
+}
diff --git a/clang/test/SemaObjC/props-on-prots.m b/clang/test/SemaObjC/props-on-prots.m
new file mode 100644
index 0000000..c01e833
--- /dev/null
+++ b/clang/test/SemaObjC/props-on-prots.m
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+typedef signed char BOOL;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+
+@protocol NSObject
+- (BOOL) isEqual:(id) object;
+@end
+
+@protocol NSCoding
+- (void) encodeWithCoder:(NSCoder *) aCoder;
+@end
+
+@interface NSObject < NSObject > {} @end
+
+typedef float CGFloat;
+
+@interface NSResponder:NSObject < NSCoding > {} @end
+
+@class XCElementView;
+
+typedef struct _XCElementInset {} XCElementInset;
+
+@protocol XCElementP < NSObject >
+-(id) vertical;
+@end
+
+@protocol XCElementDisplayDelegateP;
+@protocol XCElementTabMarkerP;
+
+typedef NSObject < XCElementTabMarkerP > XCElementTabMarker;
+
+@protocol XCElementTabberP < XCElementP >
+-(void) setMarker:(XCElementTabMarker *) marker;
+@end
+
+typedef NSObject < XCElementTabberP > XCElementTabber;
+
+@protocol XCElementTabMarkerP < NSObject >
+@property(nonatomic)
+BOOL variableSized;
+@end
+
+@protocol XCElementJustifierP < XCElementP >
+-(void) setHJustification:(CGFloat) hJust;
+@end
+
+typedef NSObject < XCElementJustifierP > XCElementJustifier;
+@interface XCElementImp:NSObject < XCElementP > {}
+@end
+
+@class XCElementImp;
+
+@interface XCElementTabberImp:XCElementImp < XCElementTabberP > {
+ XCElementTabMarker *_marker;
+}
+@end
+
+@implementation XCElementTabberImp
+- (void) setMarker:(XCElementTabMarker *) marker {
+ if (_marker && _marker.variableSized) {
+ }
+}
+- (id)vertical { return self; }
+- (BOOL)isEqual:x { return 1; }
+@end
diff --git a/clang/test/SemaObjC/protocol-archane.m b/clang/test/SemaObjC/protocol-archane.m
new file mode 100644
index 0000000..49c9851
--- /dev/null
+++ b/clang/test/SemaObjC/protocol-archane.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://5986251
+
+@protocol SomeProtocol
+- (void) bar;
+@end
+
+void bar();
+void foo(id x) {
+ bar((short<SomeProtocol>)x); // expected-error {{expected ')'}} expected-note {{to match this '('}}
+ bar((<SomeProtocol>)x); // expected-warning {{protocol qualifiers without 'id' is archaic}}
+
+ [(<SomeProtocol>)x bar]; // expected-warning {{protocol qualifiers without 'id' is archaic}}
+}
+
+@protocol MyProtocol
+- (void)doSomething;
+@end
+
+@interface MyClass
+- (void)m1:(id <MyProtocol> const)arg1;
+
+// FIXME: provide a better diagnostic (no typedef).
+- (void)m2:(id <MyProtocol> short)arg1; // expected-error {{'short type-name' is invalid}}
+@end
+
+typedef int NotAnObjCObjectType;
+
+// GCC doesn't diagnose this.
+NotAnObjCObjectType <SomeProtocol> *obj; // expected-error {{invalid protocol qualifiers on non-ObjC type}}
+
+typedef struct objc_class *Class;
+
+Class <SomeProtocol> UnfortunateGCCExtension;
+
+// rdar://10238337
+@protocol Broken @end
+@interface Crash @end
+@implementation Crash
+- (void)crashWith:(<Broken>)a { // expected-warning {{protocol qualifiers without 'id' is archaic}}
+}
+@end
diff --git a/clang/test/SemaObjC/protocol-attribute.m b/clang/test/SemaObjC/protocol-attribute.m
new file mode 100644
index 0000000..178774c
--- /dev/null
+++ b/clang/test/SemaObjC/protocol-attribute.m
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+__attribute ((unavailable))
+@protocol FwProto; // expected-note{{marked unavailable}}
+
+Class <FwProto> cFw = 0; // expected-error {{'FwProto' is unavailable}}
+
+
+__attribute ((deprecated)) @protocol MyProto1
+@end
+
+@protocol Proto2 <MyProto1> // expected-warning {{'MyProto1' is deprecated}}
++method2;
+@end
+
+
+@interface MyClass1 <MyProto1> // expected-warning {{'MyProto1' is deprecated}}
+{
+ Class isa;
+}
+@end
+
+@interface Derived : MyClass1 <MyProto1> // expected-warning {{'MyProto1' is deprecated}}
+{
+ id <MyProto1> ivar; // expected-warning {{'MyProto1' is deprecated}}
+}
+@end
+
+@interface MyClass1 (Category) <MyProto1, Proto2> // expected-warning {{'MyProto1' is deprecated}}
+@end
+
+
+
+Class <MyProto1> clsP1 = 0; // expected-warning {{'MyProto1' is deprecated}}
+
+@protocol FwProto @end // expected-note{{marked unavailable}}
+
+@interface MyClass2 <FwProto> // expected-error {{'FwProto' is unavailable}}
+@end
+
+__attribute ((unavailable)) __attribute ((deprecated)) @protocol XProto; // expected-note{{marked unavailable}}
+
+id <XProto> idX = 0; // expected-error {{'XProto' is unavailable}}
+
+int main ()
+{
+ MyClass1 <MyProto1> *p1; // expected-warning {{'MyProto1' is deprecated}}
+}
+
diff --git a/clang/test/SemaObjC/protocol-expr-1.m b/clang/test/SemaObjC/protocol-expr-1.m
new file mode 100644
index 0000000..fe01d1d
--- /dev/null
+++ b/clang/test/SemaObjC/protocol-expr-1.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol fproto;
+
+@protocol p1
+@end
+
+@class cl;
+
+int main()
+{
+ Protocol *proto = @protocol(p1);
+ Protocol *fproto = @protocol(fproto);
+}
+
diff --git a/clang/test/SemaObjC/protocol-expr-neg-1.m b/clang/test/SemaObjC/protocol-expr-neg-1.m
new file mode 100644
index 0000000..58ac8c0
--- /dev/null
+++ b/clang/test/SemaObjC/protocol-expr-neg-1.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@class Protocol;
+
+@protocol fproto;
+
+@protocol p1
+@end
+
+@class cl;
+
+int main()
+{
+ Protocol *proto = @protocol(p1);
+ Protocol *fproto = @protocol(fproto);
+ Protocol *pp = @protocol(i); // expected-error {{cannot find protocol declaration for 'i'}}
+ Protocol *p1p = @protocol(cl); // expected-error {{cannot find protocol declaration for 'cl'}}
+}
+
diff --git a/clang/test/SemaObjC/protocol-id-test-1.m b/clang/test/SemaObjC/protocol-id-test-1.m
new file mode 100644
index 0000000..19a4432
--- /dev/null
+++ b/clang/test/SemaObjC/protocol-id-test-1.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
+
+@interface FF
+- (void) Meth;
+@end
+
+@protocol P
+@end
+
+@interface INTF<P>
+- (void)IMeth;
+@end
+
+@implementation INTF
+- (void)IMeth {INTF<P> *pi; [pi Meth]; } // expected-warning {{method '-Meth' not found (return type defaults to 'id')}}
+@end
diff --git a/clang/test/SemaObjC/protocol-id-test-2.m b/clang/test/SemaObjC/protocol-id-test-2.m
new file mode 100644
index 0000000..6bd2fee
--- /dev/null
+++ b/clang/test/SemaObjC/protocol-id-test-2.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
+
+@protocol P
+@end
+
+@interface INTF<P>
+- (void)IMeth;
+@end
+
+@implementation INTF
+- (void)IMeth { [(id<P>)self Meth]; } // expected-warning {{method '-Meth' not found (return type defaults to 'id')}}
+@end
diff --git a/clang/test/SemaObjC/protocol-id-test-3.m b/clang/test/SemaObjC/protocol-id-test-3.m
new file mode 100644
index 0000000..624bab0
--- /dev/null
+++ b/clang/test/SemaObjC/protocol-id-test-3.m
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -pedantic -fsyntax-only -verify %s
+
+@protocol MyProto1
+@end
+
+@protocol MyProto2
+@end
+
+@interface INTF @end
+
+id<MyProto1> Func(INTF <MyProto1, MyProto2> *p2) // expected-note 2{{passing argument to parameter 'p2' here}}
+{
+ return p2;
+}
+
+
+
+
+ id<MyProto1> Gunc(id <MyProto1, MyProto2>p2)
+{
+ return p2;
+}
+
+
+ id<MyProto1> Gunc1(id <MyProto1, MyProto2>p2)
+{
+ return p2;
+}
+
+id<MyProto1, MyProto2> Gunc2(id <MyProto1>p2)
+{
+ Func(p2); // expected-warning {{passing 'id<MyProto1>' to parameter of incompatible type 'INTF<MyProto1,MyProto2> *'}}
+ return p2; // expected-warning {{returning 'id<MyProto1>' from a function with incompatible result type 'id<MyProto1,MyProto2>'}}
+}
+
+
+
+id<MyProto1> Gunc3(id <MyProto2>p2)
+{
+ return p2; // expected-warning {{returning 'id<MyProto2>' from a function with incompatible result type 'id<MyProto1>'}}
+}
+
+
+id<MyProto1, MyProto2> Gunc4(id <MyProto2, MyProto1>p2)
+{
+ return p2;
+}
+
+
+
+INTF<MyProto1> * Hunc(id <MyProto1, MyProto2>p2)
+{
+ return p2;
+}
+
+
+INTF<MyProto1> * Hunc1(id <MyProto1, MyProto2>p2)
+{
+ return p2;
+}
+
+INTF<MyProto1, MyProto2> * Hunc2(id <MyProto1>p2)
+{
+ Func(p2); // expected-warning {{passing 'id<MyProto1>' to parameter of incompatible type 'INTF<MyProto1,MyProto2> *'}}
+ return p2; // expected-warning {{returning 'id<MyProto1>' from a function with incompatible result type 'INTF<MyProto1,MyProto2> *'}}
+}
+
+INTF<MyProto1> * Hunc3(id <MyProto2>p2)
+{
+ return p2; // expected-warning {{returning 'id<MyProto2>' from a function with incompatible result type 'INTF<MyProto1> *'}}
+}
+
+
+INTF<MyProto1, MyProto2> * Hunc4(id <MyProto2, MyProto1>p2)
+{
+ return p2;
+}
+
+id Iunc(id <MyProto1, MyProto2>p2)
+{
+ return p2;
+}
+
+
+id<MyProto1> Iunc1(id p2)
+{
+ return p2;
+}
+
+id<MyProto1, MyProto2> Iunc2(id p2)
+{
+ Iunc(p2);
+ return p2;
+}
diff --git a/clang/test/SemaObjC/protocol-implementation-inherited.m b/clang/test/SemaObjC/protocol-implementation-inherited.m
new file mode 100644
index 0000000..c333bb5
--- /dev/null
+++ b/clang/test/SemaObjC/protocol-implementation-inherited.m
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol P0
+-bar;
+@end
+
+@interface A <P0>
+@end
+
+// Interface conforms to inherited protocol
+
+@interface B0 : A <P0>
+@end
+
+@implementation B0
+@end
+
+// Interface conforms to a protocol which extends another. The other
+// protocol is inherited, and extended methods are implemented.
+
+@protocol P1 <P0>
+-foo;
+@end
+
+@interface B1 : A <P1>
+@end
+
+@implementation B1
+-foo { return 0; };
+@end
+
+// Interface conforms to a protocol whose methods are provided by an
+// alternate inherited protocol.
+
+@protocol P2
+-bar;
+@end
+
+@interface B2 : A <P2>
+@end
+
+@implementation B2
+@end
+
+// Interface conforms to a protocol whose methods are provided by a base class.
+
+@interface A1
+-bar;
+@end
+
+@interface B3 : A1 <P2>
+@end
+
+@implementation B3
+@end
+
diff --git a/clang/test/SemaObjC/protocol-implementing-class-methods.m b/clang/test/SemaObjC/protocol-implementing-class-methods.m
new file mode 100644
index 0000000..503eef1
--- /dev/null
+++ b/clang/test/SemaObjC/protocol-implementing-class-methods.m
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://7020493
+
+@protocol P1
+@optional
+- (int) PMeth;
+@required
+- (void) : (double) arg; // expected-note {{method ':' declared here}}
+@end
+
+@interface NSImage <P1>
+- (void) initialize; // expected-note {{method 'initialize' declared here}}
+@end
+
+@interface NSImage (AirPortUI)
+- (void) initialize;
+@end
+
+@interface NSImage()
+- (void) CEMeth; // expected-note {{method 'CEMeth' declared here}}
+@end
+
+@implementation NSImage (AirPortUI)
+- (void) initialize {NSImage *p=0; [p initialize]; } // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+- (int) PMeth{ return 0; }
+- (void) : (double) arg{}; // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+- (void) CEMeth {}; // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+@end
+
+// rdar://10014946
+typedef char BOOL;
+@interface I
+{
+ BOOL allowsDeleting;
+}
+@property (nonatomic, assign, readwrite) BOOL allowsDeleting;
+@end
+
+@implementation I(CAT)
+- (BOOL) allowsDeleting { return 1; }
+@end
diff --git a/clang/test/SemaObjC/protocol-lookup-2.m b/clang/test/SemaObjC/protocol-lookup-2.m
new file mode 100644
index 0000000..bf07523
--- /dev/null
+++ b/clang/test/SemaObjC/protocol-lookup-2.m
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+@interface NSObject @end
+
+@protocol ProtocolA
+
++ (id)classMethod;
+- (id)instanceMethod;
+
+@end
+
+@protocol ProtocolB <ProtocolA>
+
+@end
+
+@interface Foo : NSObject <ProtocolB>
+
+@end
+
+@interface SubFoo : Foo
+
+@end
+
+@implementation SubFoo
+
++ (id)method {
+ return [super classMethod];
+}
+
+- (id)method {
+ return [super instanceMethod];
+}
+
+@end
diff --git a/clang/test/SemaObjC/protocol-lookup.m b/clang/test/SemaObjC/protocol-lookup.m
new file mode 100644
index 0000000..ed3fbe0
--- /dev/null
+++ b/clang/test/SemaObjC/protocol-lookup.m
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+@protocol NSObject
+- retain;
+- release;
+@end
+
+@interface NSObject
+- init;
+- dealloc;
+@end
+
+@protocol Foo <NSObject>
+@end
+
+@protocol Bar <Foo>
+@end
+
+@interface Baz : NSObject {
+ id <Foo> _foo;
+ id <Bar> _bar;
+}
+- (id)initWithFoo:(id <Foo>)foo bar:(id <Bar>)bar;
+@end
+
+@implementation Baz
+
+- (id)init
+{
+ return [self initWithFoo:0 bar:0];
+}
+
+- (id)initWithFoo:(id <Foo>)foo bar:(id <Bar>)bar
+{
+ self = [super init];
+ if (self != 0) {
+ _foo = [foo retain];
+ _bar = [bar retain];
+ }
+ return self;
+}
+
+- dealloc
+{
+ [_foo release];
+ [_bar release];
+ [super dealloc];
+ return 0;
+}
+
+@end
+
diff --git a/clang/test/SemaObjC/protocol-qualified-class-unsupported.m b/clang/test/SemaObjC/protocol-qualified-class-unsupported.m
new file mode 100644
index 0000000..4bf6b28
--- /dev/null
+++ b/clang/test/SemaObjC/protocol-qualified-class-unsupported.m
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include <stddef.h>
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+id objc_getClass(const char *s);
+
+@interface Object
++ self;
+@end
+
+@protocol Func
++ (void) class_func0;
+- (void) instance_func0;
+@end
+
+@interface Derived: Object <Func>
+@end
+
+@interface Derived2: Object <Func>
+@end
+
+static void doSomething(Class <Func> unsupportedObjectType) {
+ [unsupportedObjectType class_func0];
+}
+
+static void doSomethingElse(id <Func> pleaseConvertToThisType) {
+ [pleaseConvertToThisType class_func0];
+}
+
+int main(int argv, char *argc[]) {
+ doSomething([Derived self]);
+ doSomething([Derived2 self]);
+ doSomethingElse([Derived self]);
+ doSomethingElse([Derived2 self]);
+}
+
diff --git a/clang/test/SemaObjC/protocol-typecheck.m b/clang/test/SemaObjC/protocol-typecheck.m
new file mode 100644
index 0000000..4eb1b26
--- /dev/null
+++ b/clang/test/SemaObjC/protocol-typecheck.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface NSObject @end
+@protocol XCElementP @end
+@protocol XCElementSpacerP <XCElementP> @end
+
+@protocol PWhatever @end
+
+@interface XX
+
+- (void)setFlexElement:(NSObject <PWhatever, XCElementP> *)flexer;
+- (void)setFlexElement2:(NSObject <PWhatever, XCElementSpacerP> *)flexer; // expected-note{{passing argument to parameter 'flexer' here}}
+
+@end
+
+void func() {
+ NSObject <PWhatever, XCElementSpacerP> * flexer;
+ NSObject <PWhatever, XCElementP> * flexer2;
+ XX *obj;
+ [obj setFlexElement:flexer];
+ // FIXME: GCC provides the following diagnostic (which is much better):
+ // protocol-typecheck.m:21: warning: class 'NSObject <PWhatever, XCElementP>' does not implement the 'XCElementSpacerP' protocol
+ [obj setFlexElement2:flexer2]; // expected-warning{{incompatible pointer types sending 'NSObject<PWhatever,XCElementP> *' to parameter of type 'NSObject<PWhatever,XCElementSpacerP> *'}}
+}
+
diff --git a/clang/test/SemaObjC/protocol-warn.m b/clang/test/SemaObjC/protocol-warn.m
new file mode 100644
index 0000000..2d04238
--- /dev/null
+++ b/clang/test/SemaObjC/protocol-warn.m
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// radar 7638810
+
+@protocol NSObject @end
+
+@interface NSObject <NSObject> @end
+
+@interface UIResponder : NSObject
+@end
+
+@implementation UIResponder
+@end
+
+@interface UIView : UIResponder
+@end
+
+@implementation UIView
+@end
+
+@interface UIWebTiledView : UIView
+@end
+
+@implementation UIWebTiledView
+@end
+
+@interface UIWebDocumentView : UIWebTiledView
+@end
+
+@implementation UIWebDocumentView
+@end
+
+@interface UIWebBrowserView : UIWebDocumentView
+@end
+
+@implementation UIWebBrowserView
+@end
+
+@interface UIPDFView : UIView
+@end
+
+@implementation UIPDFView
+@end
+
+@interface UIWebPDFView : UIPDFView
+@end
+
+@implementation UIWebPDFView
+@end
+
+UIWebPDFView *getView()
+{
+ UIWebBrowserView *browserView;
+ UIWebPDFView *pdfView;
+ return pdfView ? pdfView : browserView; // expected-warning {{incompatible pointer types returning 'UIView<NSObject> *' from a function with result type 'UIWebPDFView *'}}
+}
diff --git a/clang/test/SemaObjC/protocols.m b/clang/test/SemaObjC/protocols.m
new file mode 100644
index 0000000..ca38f20
--- /dev/null
+++ b/clang/test/SemaObjC/protocols.m
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface INTF1
+@required // expected-error {{directive may only be specified in protocols only}}
+- (int) FooBar;
+- (int) FooBar1;
+- (int) FooBar2;
+@optional // expected-error {{directive may only be specified in protocols only}}
++ (int) C;
+
+- (int)I;
+@end
+
+@protocol p1,p2,p3;
+
+@protocol p1;
+
+@protocol PROTO1
+@required
+- (int) FooBar;
+@optional
+- (void) MyMethod1;
++ (int) S;
+@end
+
+
+@protocol PROTO2<p1>
+@end
+
+@protocol p1 @end
+
+@protocol PROTO<p1> // expected-note {{previous definition is here}}
+@end
+
+@protocol PROTO<p1> // expected-warning {{duplicate protocol definition of 'PROTO'}}
+@end
+
+@protocol PROTO3<p1, p1>
+@end
+
+@protocol p2 <p1>
+@end
+
+@protocol PROTO4 <p1, p2, PROTO, PROTO3, p3>
+@end
+
+
+// rdar://6771034
+@protocol XX;
+@protocol YY <XX> // Use of declaration of XX here should not cause a warning.
+- zz;
+@end
+
+
+// Detect circular dependencies.
+@protocol B;
+@protocol C < B > // expected-note{{previous definition is here}}
+@end
+@protocol A < C >
+@end
+@protocol B < A > // expected-error{{protocol has circular dependency}}
+@end
+
+@protocol P
+- (int)test:(int)param, ..; // expected-warning{{type specifier missing}} \
+ // expected-error{{expected ';' after method prototype}}
+@end
diff --git a/clang/test/SemaObjC/provisional-ivar-lookup.m b/clang/test/SemaObjC/provisional-ivar-lookup.m
new file mode 100644
index 0000000..2ec23a5
--- /dev/null
+++ b/clang/test/SemaObjC/provisional-ivar-lookup.m
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+
+// rdar:// 8565343
+@interface Foo {
+@private
+ int _foo;
+ int _foo2;
+}
+@property (readwrite, nonatomic) int foo, foo1, foo2, foo3;
+@property (readwrite, nonatomic) int PROP;
+@end
+
+@implementation Foo
+
+@synthesize foo = _foo;
+@synthesize foo1;
+
+- (void)setFoo:(int)value {
+ _foo = foo; // expected-error {{use of undeclared identifier 'foo'}}
+}
+
+- (void)setFoo1:(int)value {
+ _foo = foo1; // OK
+}
+
+- (void)setFoo2:(int)value {
+ _foo = foo2; // expected-error {{use of undeclared identifier 'foo2'}}
+}
+
+- (void)setFoo3:(int)value {
+ _foo = foo3; // OK
+}
+
+@synthesize foo2 = _foo2;
+@synthesize foo3;
+
+@synthesize PROP=PROP;
+- (void)setPROP:(int)value {
+ PROP = PROP; // OK
+}
+
+@end
+
diff --git a/clang/test/SemaObjC/qualified-protocol-method-conflicts.m b/clang/test/SemaObjC/qualified-protocol-method-conflicts.m
new file mode 100644
index 0000000..d1d5612
--- /dev/null
+++ b/clang/test/SemaObjC/qualified-protocol-method-conflicts.m
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -Woverriding-method-mismatch -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://6191214
+
+@protocol Xint
+-(void) setX: (int) arg0; // expected-note {{previous declaration is here}}
++(int) C; // expected-note {{previous declaration is here}}
+@end
+
+@protocol Xfloat
+-(void) setX: (float) arg0; // expected-note 2 {{previous declaration is here}}
++(float) C; // expected-note 2 {{previous declaration is here}}
+@end
+
+@interface A <Xint, Xfloat>
+@end
+
+@implementation A
+-(void) setX: (int) arg0 { } // expected-warning {{conflicting parameter types in declaration of 'setX:': 'float' vs 'int'}}
++(int) C {return 0; } // expected-warning {{conflicting return type in declaration of 'C': 'float' vs 'int'}}
+@end
+
+@interface B <Xfloat, Xint>
+@end
+
+@implementation B
+-(void) setX: (float) arg0 { } // expected-warning {{conflicting parameter types in declaration of 'setX:': 'int' vs 'float'}}
++ (float) C {return 0.0; } // expected-warning {{conflicting return type in declaration of 'C': 'int' vs 'float'}}
+@end
+
+@protocol Xint_float<Xint, Xfloat>
+@end
+
+@interface C<Xint_float>
+@end
+
+@implementation C
+-(void) setX: (int) arg0 { } // expected-warning {{conflicting parameter types in declaration of 'setX:': 'float' vs 'int'}}
++ (int) C {return 0;} // expected-warning {{conflicting return type in declaration of 'C': 'float' vs 'int'}}
+@end
diff --git a/clang/test/SemaObjC/rdar6248119.m b/clang/test/SemaObjC/rdar6248119.m
new file mode 100644
index 0000000..046992c
--- /dev/null
+++ b/clang/test/SemaObjC/rdar6248119.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify -fobjc-exceptions
+// Test case for:
+// <rdar://problem/6248119> @finally doesn't introduce a new scope
+
+void f0() {
+ int i;
+ @try {
+ } @finally {
+ int i = 0;
+ }
+}
+
+void f1() {
+ int i;
+ @try {
+ int i =0;
+ } @finally {
+ }
+}
+
+void f2() {
+ int i;
+ @try {
+ } @catch(id e) {
+ int i = 0;
+ }
+}
diff --git a/clang/test/SemaObjC/rdr-6211479-array-property.m b/clang/test/SemaObjC/rdr-6211479-array-property.m
new file mode 100644
index 0000000..39c056c
--- /dev/null
+++ b/clang/test/SemaObjC/rdr-6211479-array-property.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// <rdar://problem/6211479>
+
+typedef int T[2];
+
+@interface A
+@property(assign) T p2; // expected-error {{property cannot have array or function type 'T' (aka 'int [2]')}}
+@end
diff --git a/clang/test/SemaObjC/receiver-forward-class.m b/clang/test/SemaObjC/receiver-forward-class.m
new file mode 100644
index 0000000..cefb5d7
--- /dev/null
+++ b/clang/test/SemaObjC/receiver-forward-class.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -Wreceiver-forward-class -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -Wreceiver-forward-class -verify %s
+// rdar://10686120
+
+@class A; // expected-note {{forward declaration of class here}}
+
+@interface B
+-(int) width; // expected-note {{using}}
+@end
+@interface C
+-(float) width; // expected-note {{also found}}
+@end
+
+int f0(A *x) {
+ return [x width]; // expected-warning {{receiver type 'A' for instance message is a forward declaration}} \
+ // expected-warning {{multiple methods named 'width' found}} \
+ // expected-note {{receiver is treated with 'id' type for purpose of method lookup}}
+}
+
diff --git a/clang/test/SemaObjC/related-result-type-inference.m b/clang/test/SemaObjC/related-result-type-inference.m
new file mode 100644
index 0000000..124767c
--- /dev/null
+++ b/clang/test/SemaObjC/related-result-type-inference.m
@@ -0,0 +1,180 @@
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
+
+@interface Unrelated
+@end
+
+@interface NSObject
++ (id)new;
++ (id)alloc;
+- (NSObject *)init;
+
+- (id)retain; // expected-note{{instance method 'retain' is assumed to return an instance of its receiver type ('NSArray *')}}
+- autorelease;
+
+- (id)self;
+
+- (id)copy;
+- (id)mutableCopy;
+
+// Do not infer when instance/class mismatches
+- (id)newNotInferred;
+- (id)alloc;
++ (id)initWithBlarg;
++ (id)self;
+
+// Do not infer when the return types mismatch.
+- (Unrelated *)initAsUnrelated;
+@end
+
+@interface NSString : NSObject
+- (id)init;
+- (id)initWithCString:(const char*)string;
+@end
+
+@interface NSArray : NSObject
+- (unsigned)count;
+@end
+
+@interface NSBlah
+@end
+
+@interface NSMutableArray : NSArray
+@end
+
+@interface NSBlah ()
++ (Unrelated *)newUnrelated;
+@end
+
+void test_inference() {
+ // Inference based on method family
+ __typeof__(([[NSString alloc] init])) *str = (NSString**)0;
+ __typeof__(([[[[NSString new] self] retain] autorelease])) *str2 = (NSString **)0;
+ __typeof__(([[NSString alloc] initWithCString:"blah"])) *str3 = (NSString**)0;
+
+ // Not inferred
+ __typeof__(([[NSString new] copy])) *id1 = (id*)0;
+
+ // Not inferred due to instance/class mismatches
+ __typeof__(([[NSString new] newNotInferred])) *id2 = (id*)0;
+ __typeof__(([[NSString new] alloc])) *id3 = (id*)0;
+ __typeof__(([NSString self])) *id4 = (id*)0;
+ __typeof__(([NSString initWithBlarg])) *id5 = (id*)0;
+
+ // Not inferred due to return type mismatch
+ __typeof__(([[NSString alloc] initAsUnrelated])) *unrelated = (Unrelated**)0;
+ __typeof__(([NSBlah newUnrelated])) *unrelated2 = (Unrelated**)0;
+
+
+ NSArray *arr = [[NSMutableArray alloc] init];
+ NSMutableArray *marr = [arr retain]; // expected-warning{{incompatible pointer types initializing 'NSMutableArray *' with an expression of type 'NSArray *'}}
+}
+
+@implementation NSBlah
++ (Unrelated *)newUnrelated {
+ return (Unrelated *)0;
+}
+@end
+
+@implementation NSBlah (Cat)
++ (Unrelated *)newUnrelated2 {
+ return (Unrelated *)0;
+}
+@end
+
+@interface A
+- (id)initBlah; // expected-note 2{{overridden method is part of the 'init' method family}}
+@end
+
+@interface B : A
+- (Unrelated *)initBlah; // expected-warning{{method is expected to return an instance of its class type 'B', but is declared to return 'Unrelated *'}}
+@end
+
+@interface C : A
+@end
+
+@implementation C
+- (Unrelated *)initBlah { // expected-warning{{method is expected to return an instance of its class type 'C', but is declared to return 'Unrelated *'}}
+ return (Unrelated *)0;
+}
+@end
+
+@interface D
++ (id)newBlarg; // expected-note{{overridden method is part of the 'new' method family}}
+@end
+
+@interface D ()
++ alloc; // expected-note{{overridden method is part of the 'alloc' method family}}
+@end
+
+@implementation D
++ (Unrelated *)newBlarg { // expected-warning{{method is expected to return an instance of its class type 'D', but is declared to return 'Unrelated *'}}
+ return (Unrelated *)0;
+}
+
++ (Unrelated *)alloc { // expected-warning{{method is expected to return an instance of its class type 'D', but is declared to return 'Unrelated *'}}
+ return (Unrelated *)0;
+}
+@end
+
+@protocol P1
+- (id)initBlah; // expected-note{{overridden method is part of the 'init' method family}}
+- (int)initBlarg;
+@end
+
+@protocol P2 <P1>
+- (int)initBlah; // expected-warning{{protocol method is expected to return an instance of the implementing class, but is declared to return 'int'}}
+- (int)initBlarg;
+- (int)initBlech;
+@end
+
+@interface E
+- init;
+@end
+
+@implementation E
+- init {
+ return self;
+}
+@end
+
+@protocol P3
++ (NSString *)newString;
+@end
+
+@interface F<P3>
+@end
+
+@implementation F
++ (NSString *)newString { return @"blah"; }
+@end
+
+// <rdar://problem/9340699>
+@interface G
+- (id)_ABC_init __attribute__((objc_method_family(init))); // expected-note {{method '_ABC_init' declared here}}
+@end
+
+@interface G (Additions)
+- (id)_ABC_init2 __attribute__((objc_method_family(init)));
+@end
+
+@implementation G (Additions)
+- (id)_ABC_init { // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
+ return 0;
+}
+- (id)_ABC_init2 {
+ return 0;
+}
+- (id)_ABC_init3 {
+ return 0;
+}
+@end
+
+// PR12384
+@interface Fail @end
+@protocol X @end
+@implementation Fail
+- (id<X>) initWithX
+{
+ return (id)self; // expected-warning {{returning 'Fail *' from a function with incompatible result type 'id<X>'}}
+}
+@end
diff --git a/clang/test/SemaObjC/restrict-id-type.m b/clang/test/SemaObjC/restrict-id-type.m
new file mode 100644
index 0000000..b24fcb0
--- /dev/null
+++ b/clang/test/SemaObjC/restrict-id-type.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=gnu99 -fsyntax-only -verify %s
+
+void f0(restrict id a0) {}
+
+void f1(restrict id *a0) {}
+
+void f2(restrict Class a0) {}
+
+void f3(restrict Class *a0) {}
diff --git a/clang/test/SemaObjC/return.m b/clang/test/SemaObjC/return.m
new file mode 100644
index 0000000..f69d41e
--- /dev/null
+++ b/clang/test/SemaObjC/return.m
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-noreturn -fobjc-exceptions -Wno-objc-root-class %s
+
+int test1() {
+ id a;
+ @throw a;
+}
+
+// PR5286
+void test2(int a) {
+ while (1) {
+ if (a)
+ return;
+ }
+}
+
+// PR5286
+void test3(int a) { // expected-warning {{function 'test3' could be declared with attribute 'noreturn'}}
+ while (1) {
+ if (a)
+ @throw (id)0;
+ }
+}
+
+// <rdar://problem/4289832> - This code always returns, we should not
+// issue a noreturn warning.
+@class NSException;
+@class NSString;
+NSString *rdar_4289832() { // no-warning
+ @try
+ {
+ return @"a";
+ }
+ @catch(NSException *exception)
+ {
+ return @"b";
+ }
+ @finally
+ {
+ }
+}
+
+void exit(int) __attribute__((noreturn));
+@interface rdar10098695
+@end
+
+@implementation rdar10098695
+- (void)method { // expected-warning{{method 'method' could be declared with attribute 'noreturn'}}
+ exit(1);
+}
+@end
diff --git a/clang/test/SemaObjC/scope-check.m b/clang/test/SemaObjC/scope-check.m
new file mode 100644
index 0000000..e19ba47
--- /dev/null
+++ b/clang/test/SemaObjC/scope-check.m
@@ -0,0 +1,103 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -Wno-objc-root-class %s
+
+@class A, B, C;
+
+void test1() {
+ goto L; // expected-error{{goto into protected scope}}
+ goto L2; // expected-error{{goto into protected scope}}
+ goto L3; // expected-error{{goto into protected scope}}
+ @try { // expected-note {{jump bypasses initialization of @try block}}
+L: ;
+ } @catch (A *x) { // expected-note {{jump bypasses initialization of @catch block}}
+L2: ;
+ } @catch (B *x) {
+ } @catch (C *c) {
+ } @finally {// expected-note {{jump bypasses initialization of @finally block}}
+L3: ;
+ }
+
+ @try {
+ goto L4; // expected-error{{goto into protected scope}}
+ goto L5; // expected-error{{goto into protected scope}}
+ } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
+ L5: ;
+ goto L6; // expected-error{{goto into protected scope}}
+ } @catch (B *c) { // expected-note {{jump bypasses initialization of @catch block}}
+ L6: ;
+ } @finally { // expected-note {{jump bypasses initialization of @finally block}}
+ L4: ;
+ }
+
+
+ @try { // expected-note 2 {{jump bypasses initialization of @try block}}
+ L7: ;
+ } @catch (C *c) {
+ goto L7; // expected-error{{goto into protected scope}}
+ } @finally {
+ goto L7; // expected-error{{goto into protected scope}}
+ }
+
+ goto L8; // expected-error{{goto into protected scope}}
+ @try {
+ } @catch (A *c) {
+ } @catch (B *c) {
+ } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
+ L8: ;
+ }
+
+ // rdar://6810106
+ id X;
+ goto L9; // expected-error{{goto into protected scope}}
+ goto L10; // ok
+ @synchronized // expected-note {{jump bypasses initialization of @synchronized block}}
+ ( ({ L10: ; X; })) {
+ L9:
+ ;
+ }
+}
+
+void test2(int a) {
+ if (a) goto L0;
+ @try {} @finally {}
+ L0:
+ return;
+}
+
+// rdar://6803963
+void test3() {
+ @try {
+ goto blargh;
+ blargh: ;
+ } @catch (...) {}
+}
+
+@interface Greeter
++ (void) hello;
+@end
+
+@implementation Greeter
++ (void) hello {
+
+ @try {
+ goto blargh; // expected-error {{goto into protected scope}}
+ } @catch (...) { // expected-note {{jump bypasses initialization of @catch block}}
+ blargh: ;
+ }
+}
+
++ (void)meth2 {
+ int n; void *P;
+ goto L0; // expected-error {{goto into protected scope}}
+ typedef int A[n]; // expected-note {{jump bypasses initialization of VLA typedef}}
+ L0:
+
+ goto L1; // expected-error {{goto into protected scope}}
+ A b, c[10]; // expected-note 2 {{jump bypasses initialization of variable length array}}
+ L1:
+ goto L2; // expected-error {{goto into protected scope}}
+ A d[n]; // expected-note {{jump bypasses initialization of variable length array}}
+ L2:
+ return;
+}
+
+@end
diff --git a/clang/test/SemaObjC/selector-1.m b/clang/test/SemaObjC/selector-1.m
new file mode 100644
index 0000000..16d44cb
--- /dev/null
+++ b/clang/test/SemaObjC/selector-1.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -verify %s
+
+@interface I
+- (id) compare: (char) arg1;
+- length;
+@end
+
+@interface J
+- (id) compare: (id) arg1;
+@end
+
+SEL func()
+{
+ return @selector(compare:); // Non warning on multiple selector found.
+}
+
+int main() {
+ SEL s = @selector(retain);
+ SEL s1 = @selector(meth1:);
+ SEL s2 = @selector(retainArgument::);
+ SEL s3 = @selector(retainArgument:::::);
+ SEL s4 = @selector(retainArgument:with:);
+ SEL s5 = @selector(meth1:with:with:);
+ SEL s6 = @selector(getEnum:enum:bool:);
+ SEL s7 = @selector(char:float:double:unsigned:short:long:);
+
+ SEL s9 = @selector(:enum:bool:);
+}
diff --git a/clang/test/SemaObjC/selector-2.m b/clang/test/SemaObjC/selector-2.m
new file mode 100644
index 0000000..fb75369
--- /dev/null
+++ b/clang/test/SemaObjC/selector-2.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -Wselector -verify %s
+// rdar://8851684
+@interface I
+- length;
+@end
+
+static inline SEL IsEmpty() {
+ return @selector(length);
+}
+
+int main (int argc, const char * argv[]) {
+ return 0;
+}
+
diff --git a/clang/test/SemaObjC/selector-3.m b/clang/test/SemaObjC/selector-3.m
new file mode 100644
index 0000000..4c12a93
--- /dev/null
+++ b/clang/test/SemaObjC/selector-3.m
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -fsyntax-only -Wselector -verify -Wno-objc-root-class %s
+// rdar://8851684
+
+@interface Foo
+- (void) foo;
+- (void) bar;
+@end
+
+@implementation Foo
+- (void) bar
+{
+}
+
+- (void) foo
+{
+ SEL a,b,c;
+ a = @selector(b1ar); // expected-warning {{unimplemented selector 'b1ar'}}
+ b = @selector(bar);
+}
+@end
+
+@interface I
+- length;
+@end
+
+SEL func()
+{
+ return @selector(length); // expected-warning {{unimplemented selector 'length'}}
+}
+
+// rdar://9545564
+@class MSPauseManager;
+
+@protocol MSPauseManagerDelegate
+@optional
+- (void)pauseManagerDidPause:(MSPauseManager *)manager;
+- (int)respondsToSelector:(SEL)aSelector;
+@end
+
+@interface MSPauseManager
+{
+ id<MSPauseManagerDelegate> _delegate;
+}
+@end
+
+
+@implementation MSPauseManager
+- (id) Meth {
+ if ([_delegate respondsToSelector:@selector(pauseManagerDidPause:)])
+ return 0;
+ return 0;
+}
+@end
+
diff --git a/clang/test/SemaObjC/selector-error.m b/clang/test/SemaObjC/selector-error.m
new file mode 100644
index 0000000..f59dec8
--- /dev/null
+++ b/clang/test/SemaObjC/selector-error.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface Foo
+- (char*) foo;
+- (void) bar;
+@end
+
+@implementation Foo
+- (void) bar
+{
+}
+
+- (char*) foo
+{
+ char* a,b,c;
+ a = (char*)@selector(bar); // expected-error {{cannot type cast @selector expression}}
+ return (char*)@selector(bar); // expected-error {{cannot type cast @selector expression}}
+}
+@end
+
diff --git a/clang/test/SemaObjC/selector-overload.m b/clang/test/SemaObjC/selector-overload.m
new file mode 100644
index 0000000..53ba6f7
--- /dev/null
+++ b/clang/test/SemaObjC/selector-overload.m
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 %s -fsyntax-only
+
+@interface NSObject
++ alloc;
+- init;
+@end
+
+struct D {
+ double d;
+};
+
+@interface Foo : NSObject
+
+- method:(int)a;
+- method:(int)a;
+
+@end
+
+@interface Bar : NSObject
+
+- method:(void *)a;
+
+@end
+
+@interface Car : NSObject
+
+- method:(struct D)a;
+
+@end
+
+@interface Zar : NSObject
+
+- method:(float)a;
+
+@end
+
+@interface Rar : NSObject
+
+- method:(float)a;
+
+@end
+
+int main() {
+ id xx = [[Car alloc] init]; // expected-warning {{incompatible types assigning 'int' to 'id'}}
+
+ [xx method:4];
+}
diff --git a/clang/test/SemaObjC/self-assign.m b/clang/test/SemaObjC/self-assign.m
new file mode 100644
index 0000000..e0f5f43
--- /dev/null
+++ b/clang/test/SemaObjC/self-assign.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+@interface A
+@end
+
+@implementation A
+- (id):(int)x :(int)y {
+ int z;
+ // <rdar://problem/8939352>
+ if (self = [self :x :y]) {} // expected-warning{{using the result of an assignment as a condition without parentheses}} \
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+ return self;
+}
+@end
diff --git a/clang/test/SemaObjC/self-declared-in-block.m b/clang/test/SemaObjC/self-declared-in-block.m
new file mode 100644
index 0000000..40a0331
--- /dev/null
+++ b/clang/test/SemaObjC/self-declared-in-block.m
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fblocks -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -triple x86_64-apple-darwin10 -fblocks -verify -Wno-objc-root-class %s
+// rdar://9154582
+
+@interface Blocky @end
+
+@implementation Blocky {
+ int _a;
+}
+- (int)doAThing {
+ ^{
+ char self;
+ return _a;
+ }();
+ return _a;
+}
+
+@end
+
+
+// rdar://9284603
+@interface ShadowSelf
+{
+ int _anIvar;
+}
+@end
+
+@interface C {
+ int _cIvar;
+}
+@end
+
+@implementation ShadowSelf
+- (void)doSomething {
+ __typeof(self) newSelf = self;
+ {
+ __typeof(self) self = newSelf;
+ (void)_anIvar;
+ }
+ {
+ C* self;
+ (void) _anIvar;
+ }
+}
+- (void)doAThing {
+ ^{
+ id self;
+ (void)_anIvar;
+ }();
+}
+@end
+
diff --git a/clang/test/SemaObjC/self-in-function.m b/clang/test/SemaObjC/self-in-function.m
new file mode 100644
index 0000000..9027a94
--- /dev/null
+++ b/clang/test/SemaObjC/self-in-function.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+// rdar://9181463
+
+typedef struct objc_class *Class;
+
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+@interface NSObject
++ (id) alloc;
+@end
+
+
+void foo(Class self) {
+ [self alloc];
+ (^() {
+ [self alloc];
+ })();
+}
+
+void bar(Class self) {
+ Class y = self;
+ [y alloc];
+}
+
diff --git a/clang/test/SemaObjC/setter-dotsyntax.m b/clang/test/SemaObjC/setter-dotsyntax.m
new file mode 100644
index 0000000..e0b51e8
--- /dev/null
+++ b/clang/test/SemaObjC/setter-dotsyntax.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://8528170
+
+@interface NSObject @end
+
+@protocol MyProtocol
+- (int) level;
+- (void) setLevel:(int)inLevel;
+@end
+
+@interface MyClass : NSObject <MyProtocol>
+@end
+
+int main ()
+{
+ id<MyProtocol> c;
+ c.level = 10;
+ return 0;
+}
diff --git a/clang/test/SemaObjC/severe-syntax-error.m b/clang/test/SemaObjC/severe-syntax-error.m
new file mode 100644
index 0000000..8c59151
--- /dev/null
+++ b/clang/test/SemaObjC/severe-syntax-error.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://10633434
+
+@interface testClass
+@end
+
+@class NSArray;
+
+@implementation testClass
+
+static NSArray* prefixArray[] = @"BEGIN:", @"END:", @"VERSION:", @"N:", @"FN:", @"TEL;", @"TEL:", nil; // expected-error {{array initializer must be an initializer list}} \
+ // expected-error {{expected identifier or '('}} \
+ // expected-error {{expected ';' after top level declarator}}
+
+static NSString* prefixArray1[] = @"BEGIN:", @"END:", @"VERSION:", @"N:", @"FN:", @"TEL;", @"TEL:", nil; // expected-error {{unknown type name 'NSString'}} \
+ // expected-error {{expected identifier or '('}} \
+ // expected-error {{expected ';' after top level declarator}}
+
+static char* cArray[] = "BEGIN:", "END"; // expected-error {{array initializer must be an initializer list}} \
+ // expected-error {{expected identifier or '('}} \
+ // expected-error {{expected ';' after top level declarator}}
+
+@end
diff --git a/clang/test/SemaObjC/sizeof-interface.m b/clang/test/SemaObjC/sizeof-interface.m
new file mode 100644
index 0000000..7304b6c
--- /dev/null
+++ b/clang/test/SemaObjC/sizeof-interface.m
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
+
+@class I0; // expected-note 2{{forward declaration of class here}}
+
+// rdar://6811884
+int g0 = sizeof(I0); // expected-error{{invalid application of 'sizeof' to an incomplete type 'I0'}}
+
+// rdar://6821047
+void *g3(I0 *P) {
+ P = P+5; // expected-error {{arithmetic on a pointer to an incomplete type 'I0'}}
+
+ return &P[4]; // expected-error{{expected method to read array element not found on object of type 'I0 *'}}
+}
+
+
+
+@interface I0 {
+@public
+ char x[4];
+}
+
+@property int p0;
+@end
+
+// size == 4
+int g1[ sizeof(I0) // expected-error {{invalid application of 'sizeof' to interface 'I0' in non-fragile ABI}}
+ == 4 ? 1 : -1];
+
+@implementation I0
+@synthesize p0 = _p0;
+@end
+
+// size == 4 (we do not include extended properties in the
+// sizeof).
+int g2[ sizeof(I0) // expected-error {{invalid application of 'sizeof' to interface 'I0' in non-fragile ABI}}
+ == 4 ? 1 : -1];
+
+@interface I1
+@property int p0;
+@end
+
+@implementation I1
+@synthesize p0 = _p0;
+@end
+
+typedef struct { @defs(I1); } I1_defs; // expected-error {{invalid application of @defs in non-fragile ABI}}
+
+// FIXME: This is currently broken due to the way the record layout we
+// create is tied to whether we have seen synthesized properties. Ugh.
+// int g3[ sizeof(I1) == 0 ? 1 : -1];
+
+// rdar://6821047
+int bar(I0 *P) {
+ P = P+5; // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size in non-fragile ABI}}
+ P = 5+P; // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size in non-fragile ABI}}
+ P = P-5; // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size in non-fragile ABI}}
+
+ return P[4].x[2]; // expected-error {{expected method to read array element not found on object of type 'I0 *'}}
+}
+
+
+@interface I @end
+
+@interface XCAttributeRunDirectNode
+{
+ @public
+ unsigned long attributeRuns[1024 + sizeof(I)]; // expected-error {{invalid application of 'sizeof' to interface 'I' in non-fragile ABI}}
+ int i;
+}
+@end
+
+@implementation XCAttributeRunDirectNode
+
+- (unsigned long)gatherStats:(id )stats
+{
+ return attributeRuns[i];
+}
+@end
+
+
+@interface Foo @end
+
+int foo()
+{
+ Foo *f;
+
+ // Both of these crash clang nicely
+ ++f; // expected-error {{arithmetic on pointer to interface 'Foo', which is not a constant size in non-fragile ABI}}
+ --f; // expected-error {{arithmetic on pointer to interface 'Foo', which is not a constant size in non-fragile ABI}}
+}
diff --git a/clang/test/SemaObjC/special-dep-unavail-warning.m b/clang/test/SemaObjC/special-dep-unavail-warning.m
new file mode 100644
index 0000000..754bf5f
--- /dev/null
+++ b/clang/test/SemaObjC/special-dep-unavail-warning.m
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://8769853
+
+@interface B
+- (void) depInA;
+- (void) unavailMeth __attribute__((unavailable)); // expected-note {{has been explicitly marked unavailable here}}
+- (void) depInA1 __attribute__((deprecated));
+- (void) unavailMeth1;
+- (void) depInA2 __attribute__((deprecated));
+- (void) unavailMeth2 __attribute__((unavailable)); // expected-note {{has been explicitly marked unavailable here}}
+- (void) depunavailInA;
+- (void) depunavailInA1 __attribute__((deprecated)) __attribute__((unavailable)); // expected-note {{has been explicitly marked unavailable here}}
+- (void)FuzzyMeth __attribute__((deprecated));
+- (void)FuzzyMeth1 __attribute__((unavailable));
+@end
+
+@interface A
+- (void) unavailMeth1 __attribute__((unavailable)); // expected-note {{has been explicitly marked unavailable here}}
+- (void) depInA __attribute__((deprecated));
+- (void) depInA2 __attribute__((deprecated));
+- (void) depInA1;
+- (void) unavailMeth2 __attribute__((unavailable));
+- (void) depunavailInA __attribute__((deprecated)) __attribute__((unavailable)); // expected-note {{has been explicitly marked unavailable here}}
+- (void) depunavailInA1;
+- (void)FuzzyMeth __attribute__((unavailable));
+- (void)FuzzyMeth1 __attribute__((deprecated));
+@end
+
+
+@class C; // expected-note 5 {{forward declaration of class here}}
+
+void test(C *c) {
+ [c depInA]; // expected-warning {{'depInA' maybe deprecated because receiver type is unknown}}
+ [c unavailMeth]; // expected-warning {{'unavailMeth' maybe unavailable because receiver type is unknown}}
+ [c depInA1]; // expected-warning {{'depInA1' maybe deprecated because receiver type is unknown}}
+ [c unavailMeth1]; // expected-warning {{'unavailMeth1' maybe unavailable because receiver type is unknown}}
+ [c depInA2]; // expected-warning {{'depInA2' maybe deprecated because receiver type is unknown}}
+ [c unavailMeth2]; // expected-warning {{'unavailMeth2' maybe unavailable because receiver type is unknown}}
+ [c depunavailInA]; // expected-warning {{'depunavailInA' maybe unavailable because receiver type is unknown}}
+ [c depunavailInA1];// expected-warning {{'depunavailInA1' maybe unavailable because receiver type is unknown}}
+ [c FuzzyMeth]; // expected-warning {{'FuzzyMeth' maybe deprecated because receiver type is unknown}}
+ [c FuzzyMeth1]; // expected-warning {{'FuzzyMeth1' maybe deprecated because receiver type is unknown}}
+
+}
+
+// rdar://10268422
+__attribute ((deprecated))
+@interface DEPRECATED
++(id)new;
+@end
+
+void foo() {
+ [DEPRECATED new]; // expected-warning {{'DEPRECATED' is deprecated}}
+}
+
diff --git a/clang/test/SemaObjC/stand-alone-implementation.m b/clang/test/SemaObjC/stand-alone-implementation.m
new file mode 100644
index 0000000..6fa9b4b
--- /dev/null
+++ b/clang/test/SemaObjC/stand-alone-implementation.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// radar 7547942
+// Allow injection of ivars into implementation's implicit class.
+
+@implementation INTFSTANDALONE // expected-warning {{cannot find interface declaration for 'INTFSTANDALONE'}}
+{
+ id IVAR1;
+ id IVAR2;
+}
+- (id) Meth { return IVAR1; }
+@end
+
diff --git a/clang/test/SemaObjC/static-ivar-ref-1.m b/clang/test/SemaObjC/static-ivar-ref-1.m
new file mode 100644
index 0000000..d9f99f5
--- /dev/null
+++ b/clang/test/SemaObjC/static-ivar-ref-1.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -ast-print %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -ast-print %s 2>&1 | FileCheck %s
+
+@interface current
+{
+@public
+ int ivar;
+ int ivar1;
+ int ivar2;
+}
+@end
+
+current *pc;
+
+int foo()
+{
+ return pc->ivar2 + (*pc).ivar + pc->ivar1;
+}
+
+// CHECK: @interface current{
+// CHECK: int ivar;
+// CHECK: int ivar1;
+// CHECK: int ivar2;
+// CHECK: }
+// CHECK: @end
+// CHECK: current *pc;
+// CHECK: int foo() {
+// CHECK: return pc->ivar2 + (*pc).ivar + pc->ivar1;
+// CHECK: }
+
diff --git a/clang/test/SemaObjC/stmts.m b/clang/test/SemaObjC/stmts.m
new file mode 100644
index 0000000..d452db8
--- /dev/null
+++ b/clang/test/SemaObjC/stmts.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -fobjc-exceptions
+
+struct some_struct;
+
+@interface NSObject
+@end
+
+// Note: NSException is not declared.
+void f0(id x) {
+ @try {
+ } @catch (NSException *x) { // expected-error {{unknown type name 'NSException'}}
+ } @catch (struct some_struct x) { // expected-error {{@catch parameter is not a pointer to an interface type}}
+ } @catch (int x) { // expected-error {{@catch parameter is not a pointer to an interface type}}
+ } @catch (static NSObject *y) { // expected-error {{@catch parameter cannot have storage specifier 'static'}}
+ } @catch (...) {
+ }
+}
+
diff --git a/clang/test/SemaObjC/string.m b/clang/test/SemaObjC/string.m
new file mode 100644
index 0000000..04f20ab
--- /dev/null
+++ b/clang/test/SemaObjC/string.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+// RUN: %clang_cc1 %s -verify -fsyntax-only -DDECLAREIT
+
+// a declaration of NSConstantString is not required.
+#ifdef DECLAREIT
+@interface NSConstantString;
+@end
+#endif
+
+
+
+id s = @"123"; // simple
+id t = @"123" @"456"; // concat
+id u = @"123" @ blah; // expected-error {{unexpected token}}
+
diff --git a/clang/test/SemaObjC/super-cat-prot.m b/clang/test/SemaObjC/super-cat-prot.m
new file mode 100644
index 0000000..3e28986
--- /dev/null
+++ b/clang/test/SemaObjC/super-cat-prot.m
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@interface NSObject <NSObject> {} @end
+typedef float CGFloat;
+typedef struct _NSSize {} NSSize;
+typedef struct _NSRect {} NSRect;
+@interface NSResponder : NSObject <NSCoding> {} @end
+@protocol NSAnimatablePropertyContainer - (id)animator; @end
+extern NSString *NSAnimationTriggerOrderIn ;
+@interface NSView : NSResponder <NSAnimatablePropertyContainer> {} @end
+@class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView;
+enum { NSBoxPrimary = 0, NSBoxSecondary = 1, NSBoxSeparator = 2, NSBoxOldStyle = 3, NSBoxCustom = 4};
+typedef NSUInteger NSBoxType;
+@interface NSBox : NSView {} - (NSBoxType)boxType; @end
+@class NSArray, NSError, NSImage, NSView, NSNotificationCenter, NSURL;
+@interface NSProBox:NSBox {} @end
+enum IBKnobPosition { IBNoKnobPosition = -1, IBBottomLeftKnobPosition = 0,
+ IBMiddleLeftKnobPosition, IBTopLeftKnobPosition,
+ IBTopMiddleKnobPosition, IBTopRightKnobPosition,
+ IBMiddleRightKnobPosition, IBBottomRightKnobPosition,
+ IBBottomMiddleKnobPosition };
+typedef enum IBKnobPosition IBKnobPosition;
+typedef struct _IBInset {} IBInset;
+@protocol IBObjectProtocol -(NSString *)inspectorClassName; @end
+@protocol IBViewProtocol
+ -(NSSize)minimumFrameSizeFromKnobPosition:(IBKnobPosition)position;
+ -(IBInset)ibShadowInset;
+@end
+@class NSPasteboard;
+@interface NSObject (NSObject_IBObjectProtocol) <IBObjectProtocol> @end
+@interface NSView (NSView_IBViewProtocol) <IBViewProtocol> - (NSRect)layoutRect; @end
+typedef enum { NSProTextFieldSquareBezel = 0, NSProTextFieldRoundedBezel = 1, NSProTextFieldDisplayBezel = 2 } MKModuleReusePolicy;
+@implementation NSProBox(IBAdditions)
+-(NSString *)inspectorClassName { return 0; }
+-(IBInset)ibShadowInset {
+ if ([self boxType] == NSBoxSeparator) {
+ return [super ibShadowInset];
+ }
+ while (1) {}
+}
+-(NSSize)minimumFrameSizeFromKnobPosition:(IBKnobPosition)knobPosition {
+ if ([self boxType] != NSBoxSeparator)
+ return [super minimumFrameSizeFromKnobPosition:knobPosition];
+ while (1) {}
+}
+@end
diff --git a/clang/test/SemaObjC/super-class-protocol-conformance.m b/clang/test/SemaObjC/super-class-protocol-conformance.m
new file mode 100644
index 0000000..32d5392
--- /dev/null
+++ b/clang/test/SemaObjC/super-class-protocol-conformance.m
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://7884086
+
+@interface NSObject @end
+
+@protocol TopProtocol
+ @property (readonly) id myString; // expected-note {{property}}
+@end
+
+@protocol SubProtocol <TopProtocol>
+@end
+
+@interface TopClass : NSObject <TopProtocol> {}
+@end
+
+@interface SubClass : TopClass <SubProtocol> {}
+@end
+
+@interface SubClass1 : TopClass {}
+@end
+
+@implementation SubClass1 @end // Test1 - No Warning
+
+@implementation TopClass // expected-warning {{property 'myString' requires method 'myString' to be defined}}
+@end
+
+@implementation SubClass // Test3 - No Warning
+@end
+
+@interface SubClass2 : TopClass<TopProtocol>
+@end
+
+@implementation SubClass2 @end // Test 4 - No Warning
+
+@interface SubClass3 : TopClass<SubProtocol> @end
+@implementation SubClass3 @end // Test 5 - No Warning
+
+@interface SubClass4 : SubClass3 @end
+@implementation SubClass4 @end // Test 5 - No Warning
+
+@protocol NewProtocol
+ @property (readonly) id myNewString; // expected-note {{property}}
+@end
+
+@interface SubClass5 : SubClass4 <NewProtocol> @end
+@implementation SubClass5 @end // expected-warning {{property 'myNewString' requires method 'myNewString' to be defined}}
+
+
+// Radar 8035776
+@protocol SuperProtocol
+@end
+
+@interface Super <SuperProtocol>
+@end
+
+@protocol ProtocolWithProperty <SuperProtocol>
+@property (readonly, assign) id invalidationBacktrace; // expected-note {{property}}
+@end
+
+@interface INTF : Super <ProtocolWithProperty>
+@end
+
+@implementation INTF @end // expected-warning{{property 'invalidationBacktrace' requires method 'invalidationBacktrace' to be defined}}
diff --git a/clang/test/SemaObjC/super-property-message-expr.m b/clang/test/SemaObjC/super-property-message-expr.m
new file mode 100644
index 0000000..c25164e
--- /dev/null
+++ b/clang/test/SemaObjC/super-property-message-expr.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface SStoreNodeInfo
+
+@property(nonatomic,readonly,retain) id descriptionShort;
+
+- (id)stringByAppendingFormat:(int)format, ... ;
+
+@end
+
+@interface SStoreNodeInfo_iDisk : SStoreNodeInfo
+{
+@private
+ id _etag;
+}
+@end
+
+@implementation SStoreNodeInfo_iDisk
+- (id) X { return [super.descriptionShort stringByAppendingFormat:1, _etag]; }
+
+@end
diff --git a/clang/test/SemaObjC/super-property-notation.m b/clang/test/SemaObjC/super-property-notation.m
new file mode 100644
index 0000000..7d3f7c7
--- /dev/null
+++ b/clang/test/SemaObjC/super-property-notation.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface B
++(int) classGetter;
+-(int) getter;
+@end
+
+@interface A : B
+@end
+
+@implementation A
++(int) classGetter {
+ return 0;
+}
+
++(int) classGetter2 {
+ return super.classGetter;
+}
+
+-(void) method {
+ int x = super.getter;
+}
+@end
+
+void f0() {
+ // FIXME: not implemented yet.
+ //int l1 = A.classGetter;
+ int l2 = [A classGetter2];
+}
+
diff --git a/clang/test/SemaObjC/super.m b/clang/test/SemaObjC/super.m
new file mode 100644
index 0000000..cf48c19
--- /dev/null
+++ b/clang/test/SemaObjC/super.m
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
+
+void takevoidptr(void*);
+
+
+@interface Foo
+- iMethod;
++ cMethod;
+@end
+
+@interface A
++ superClassMethod;
+- (void)instanceMethod;
+@end
+
+@interface B : A
+- (void)instanceMethod;
++ classMethod;
+@end
+
+@implementation B
+
+- (void)instanceMethod {
+ [super iMethod]; // expected-warning{{'A' may not respond to 'iMethod'}}
+
+ // Use of super in a block is ok and does codegen to the right thing.
+ // rdar://7852959
+ takevoidptr(^{
+ [super instanceMethod];
+ });
+}
+
++ classMethod {
+ [super cMethod]; // expected-warning{{method '+cMethod' not found (return type defaults to 'id')}}
+
+ id X[] = { [ super superClassMethod] };
+ id Y[] = {
+ [ super.superClassMethod iMethod],
+ super.superClassMethod,
+ (id)super.superClassMethod // not a cast of super: rdar://7853261
+ };
+ return 0;
+}
+@end
+
+@interface XX
+- m;
+@end
+
+void f(id super) {
+ [super m];
+}
+void f0(int super) {
+ [super m]; // expected-warning{{receiver type 'int' is not 'id'}} \
+ expected-warning {{method '-m' not found (return type defaults to 'id')}}
+}
+void f1(id puper) { // expected-note {{'puper' declared here}}
+ [super m]; // expected-error{{use of undeclared identifier 'super'}}
+}
+
+// radar 7400691
+typedef Foo super;
+
+typedef Foo FooTD;
+
+void test() {
+ [FooTD cMethod];
+ [super cMethod];
+}
+
+struct SomeStruct {
+ int X;
+};
+
+int test2() {
+ struct SomeStruct super = { 0 };
+ return super.X;
+}
+
+int test3() {
+ id super = 0;
+ [(B*)super instanceMethod];
+ int *s1 = (int*)super;
+
+ id X[] = { [ super superClassMethod] };
+ return 0;
+}
diff --git a/clang/test/SemaObjC/synchronized.m b/clang/test/SemaObjC/synchronized.m
new file mode 100644
index 0000000..c158815
--- /dev/null
+++ b/clang/test/SemaObjC/synchronized.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface PBXTrackableTaskManager @end
+
+@implementation PBXTrackableTaskManager
+- (id) init { return 0; }
+- (void) unregisterTask:(id) task {
+ @synchronized (self) {
+ id taskID = [task taskIdentifier]; // expected-warning {{method '-taskIdentifier' not found (return type defaults to 'id')}}
+ }
+}
+@end
+
+
+struct x { int a; } b;
+
+void test1() {
+ @synchronized (b) { // expected-error {{@synchronized requires an Objective-C object type ('struct x' invalid)}}
+ }
+
+ @synchronized (42) { // expected-error {{@synchronized requires an Objective-C object type ('int' invalid)}}
+ }
+}
diff --git a/clang/test/SemaObjC/synth-provisional-ivars-1.m b/clang/test/SemaObjC/synth-provisional-ivars-1.m
new file mode 100644
index 0000000..0e155f4
--- /dev/null
+++ b/clang/test/SemaObjC/synth-provisional-ivars-1.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+// rdar://8913053
+
+typedef unsigned char BOOL;
+
+@interface MailApp
+{
+ BOOL _isAppleInternal;
+}
+@property(assign) BOOL isAppleInternal;
+@end
+
+static BOOL isAppleInternal() {return 0; }
+
+@implementation MailApp
+
+- (BOOL)isAppleInternal {
+ return _isAppleInternal;
+}
+
+- (void)setIsAppleInternal:(BOOL)flag {
+ _isAppleInternal= !!flag;
+}
+
+- (void) Meth {
+ self.isAppleInternal = isAppleInternal();
+}
+@end
diff --git a/clang/test/SemaObjC/synth-provisional-ivars.m b/clang/test/SemaObjC/synth-provisional-ivars.m
new file mode 100644
index 0000000..9d7abd5
--- /dev/null
+++ b/clang/test/SemaObjC/synth-provisional-ivars.m
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+
+int bar;
+
+@interface I
+{
+ int _bar;
+}
+@property int PROP;
+@property int PROP1;
+@property int PROP2;
+@property int PROP3;
+@property int PROP4;
+
+@property int bar;
+@property int bar1;
+
+@end
+
+@implementation I
+- (int) Meth { return _PROP; }
+
+@dynamic PROP1;
+- (int) Meth1 { return PROP1; } // expected-error {{use of undeclared identifier 'PROP1'}}
+
+- (int) Meth2 { return PROP2; } // expected-error {{use of undeclared identifier 'PROP2'}}
+@dynamic PROP2;
+
+- (int) Meth3 { return PROP3; } // expected-error {{use of undeclared identifier 'PROP3'}}
+@synthesize PROP3=IVAR;
+
+- (int) Meth4 { return PROP4; }
+@synthesize PROP4=PROP4; // expected-note 4 {{'PROP4' declared here}}
+
+- (int) Meth5 { return bar; }
+@synthesize bar = _bar;
+
+- (int) Meth6 { return _bar1; }
+
+@end
+
+@implementation I(CAT)
+- (int) Meth { return PROP1; } // expected-error {{use of undeclared identifier 'PROP1'}}
+@end
+
+@implementation I(r8251648)
+- (int) Meth1: (int) bar {
+ return bar;
+}
+@end
diff --git a/clang/test/SemaObjC/synthesize-setter-contclass.m b/clang/test/SemaObjC/synthesize-setter-contclass.m
new file mode 100644
index 0000000..d754415
--- /dev/null
+++ b/clang/test/SemaObjC/synthesize-setter-contclass.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface TestClass
+{
+ int _isItIsOrIsItAint;
+}
+@property (readonly) int itIsOrItAint;
+-(void) doSomething;
+@end
+
+@interface TestClass()
+@property (readwrite) int itIsOrItAint;
+@end
+
+@implementation TestClass
+@synthesize itIsOrItAint = _isItIsOrIsItAint;
+
+-(void) doSomething
+{
+ int i = [self itIsOrItAint];
+
+ [self setItIsOrItAint:(int)1];
+}
+@end
diff --git a/clang/test/SemaObjC/synthesized-ivar.m b/clang/test/SemaObjC/synthesized-ivar.m
new file mode 100644
index 0000000..8c9d905
--- /dev/null
+++ b/clang/test/SemaObjC/synthesized-ivar.m
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+@interface I
+{
+}
+@property int IP;
+@end
+
+@implementation I
+@synthesize IP;
+- (int) Meth {
+ return IP;
+}
+@end
+
+// rdar://7823675
+int f0(I *a) { return a->IP; } // expected-error {{instance variable 'IP' is private}}
+
+// rdar://8769582
+
+@interface I1 {
+ int protected_ivar;
+}
+@property int PROP_INMAIN;
+@end
+
+@interface I1() {
+ int private_ivar;
+}
+@property int PROP_INCLASSEXT;
+@end
+
+@implementation I1
+- (int) Meth {
+ _PROP_INMAIN = 1;
+ _PROP_INCLASSEXT = 2;
+ protected_ivar = 1; // OK
+ return private_ivar; // OK
+}
+@end
+
+
+@interface DER : I1
+@end
+
+@implementation DER
+- (int) Meth {
+ protected_ivar = 1; // OK
+ _PROP_INMAIN = 1; // expected-error {{instance variable '_PROP_INMAIN' is private}}
+ _PROP_INCLASSEXT = 2; // expected-error {{instance variable '_PROP_INCLASSEXT' is private}}
+ return private_ivar; // expected-error {{instance variable 'private_ivar' is private}}
+}
+@end
+
+@interface A
+@property (weak) id testObjectWeakProperty; // expected-note {{declared here}}
+@end
+
+@implementation A
+// rdar://9605088
+@synthesize testObjectWeakProperty; // expected-error {{@synthesize of 'weak' property is only allowed in ARC or GC mode}}
+@end
diff --git a/clang/test/SemaObjC/transparent-union.m b/clang/test/SemaObjC/transparent-union.m
new file mode 100644
index 0000000..6f2dbf9
--- /dev/null
+++ b/clang/test/SemaObjC/transparent-union.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+typedef union {
+ struct xx_object_s *_do;
+ struct xx_continuation_s *_dc;
+ struct xx_queue_s *_dq;
+ struct xx_queue_attr_s *_dqa;
+ struct xx_group_s *_dg;
+ struct xx_source_s *_ds;
+ struct xx_source_attr_s *_dsa;
+ struct xx_semaphore_s *_dsema;
+} xx_object_t __attribute__((transparent_union));
+
+@interface INTF
+- (void) doSomething : (xx_object_t) xxObject;
+- (void)testMeth;
+@end
+
+@implementation INTF
+- (void) doSomething : (xx_object_t) xxObject {}
+- (void)testMeth { struct xx_queue_s *sq; [self doSomething:sq ]; }
+@end
diff --git a/clang/test/SemaObjC/try-catch.m b/clang/test/SemaObjC/try-catch.m
new file mode 100644
index 0000000..5afbbb6
--- /dev/null
+++ b/clang/test/SemaObjC/try-catch.m
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s
+typedef signed char BOOL;
+typedef struct _NSZone NSZone;
+
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+@end
+
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+
+@protocol NSCoding
+- (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+
+@interface NSObject <NSObject> {}
+@end
+
+@class NSData, NSArray, NSDictionary, NSCharacterSet, NSData, NSURL, NSError, NSLocale;
+
+@interface NSException : NSObject <NSCopying, NSCoding> {}
+@end
+
+@class ASTNode, XCRefactoringParser, Transform, TransformInstance, XCRefactoringSelectionInfo;
+
+@interface XCRefactoringTransformation : NSObject {}
+@end
+
+@implementation XCRefactoringTransformation
+- (NSDictionary *)setUpInfoForTransformKey:(NSString *)transformKey outError:(NSError **)outError {
+ @try {}
+ // the exception name is optional (weird)
+ @catch (NSException *) {}
+}
+@end
+
+int foo() {
+ struct s { int a, b; } agg, *pagg;
+
+ @throw 42; // expected-error {{@throw requires an Objective-C object type ('int' invalid)}}
+ @throw agg; // expected-error {{@throw requires an Objective-C object type ('struct s' invalid)}}
+ @throw pagg; // expected-error {{@throw requires an Objective-C object type ('struct s *' invalid)}}
+ @throw; // expected-error {{@throw (rethrow) used outside of a @catch block}}
+}
diff --git a/clang/test/SemaObjC/typedef-class.m b/clang/test/SemaObjC/typedef-class.m
new file mode 100644
index 0000000..bd68397
--- /dev/null
+++ b/clang/test/SemaObjC/typedef-class.m
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+
+@protocol NSObject - (BOOL) isEqual:(id) object; - (id)init; @end
+@protocol NSCopying - (id) copyWithZone:(NSZone *) zone; @end
+@protocol NSCoding - (void) encodeWithCoder:(NSCoder *) aCoder; @end
+
+@interface NSObject < NSObject > {}
++(id) alloc;
+@end
+
+typedef float CGFloat;
+
+@interface NSTask:NSObject
+- (id) init;
+@end
+
+typedef NSUInteger NSControlSize;
+typedef struct __CFlags {} _CFlags;
+
+@interface NSCell:NSObject < NSCopying, NSCoding > {}
+@end
+
+@interface NSActionCell:NSCell {} @end
+
+@class NSAttributedString, NSFont, NSImage, NSSound;
+
+typedef struct _XCElementInset {} XCElementInset;
+
+@protocol XCElementP < NSObject >
+-(BOOL) vertical;
+@end
+
+@protocol XCElementDisplayDelegateP;
+@protocol XCElementDisplayDelegateP < NSObject >
+-(void) configureForControlSize:(NSControlSize)size font:(NSFont *)font addDefaultSpace:(XCElementInset) additionalSpace;
+@end
+
+@protocol XCElementSpacerP < XCElementP >
+@end
+
+typedef NSObject < XCElementSpacerP > XCElementSpacer;
+
+@protocol XCElementTogglerP < XCElementP > -(void) setDisplayed:(BOOL) displayed;
+@end
+
+typedef NSObject < XCElementTogglerP > XCElementToggler; // expected-note {{previous definition is here}}
+
+@interface XCElementRootFace:NSObject {} @end
+
+@interface XCElementFace:XCElementRootFace {} @end
+
+@class XCElementToggler; // expected-warning {{redefinition of forward class 'XCElementToggler' of a typedef name of an object type is ignored}}
+
+@interface XCRASlice:XCElementFace {} @end
+
+@class XCElementSpacings;
+
+@interface XCElementDisplay:NSObject < XCElementDisplayDelegateP > {} @end
+@interface XCElementDisplayRect:XCElementDisplay {} @end
+
+typedef XCElementDisplayRect XCElementGraphicsRect;
+
+@interface XCElementDisplayFillerImage:XCElementDisplay {} @end
+
+@implementation XCRASlice
+- (void) addSliceWithLabel:(NSString *)label statusKey:(NSString *)statusKey disclosed:(BOOL)disclosed
+{
+ static XCElementGraphicsRect *_sGraphicsDelegate = ((void *) 0);
+ if (!_sGraphicsDelegate) {
+ _sGraphicsDelegate =[[XCElementGraphicsRect alloc] init];
+ }
+}
+@end
diff --git a/clang/test/SemaObjC/ucn-objc-string.m b/clang/test/SemaObjC/ucn-objc-string.m
new file mode 100644
index 0000000..6070278
--- /dev/null
+++ b/clang/test/SemaObjC/ucn-objc-string.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+@class NSString;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+
+int main() {
+ NSLog(@"Hi…");
+ NSLog(@"Exposé");
+ NSLog(@"\U00010400\U0001D12B");
+ NSLog(@"hello \u2192 \u2603 \u2190 world");
+ NSLog(@"hello → ☃ ← world");
+ return 0;
+}
+
diff --git a/clang/test/SemaObjC/undeclared-selector.m b/clang/test/SemaObjC/undeclared-selector.m
new file mode 100644
index 0000000..0914510
--- /dev/null
+++ b/clang/test/SemaObjC/undeclared-selector.m
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -fsyntax-only -Wundeclared-selector -verify -Wno-objc-root-class %s
+
+typedef struct objc_selector *SEL;
+
+@interface MyClass
+
++ (void) methodA;
+- (void) methodB;
++ (void) methodD;
+- (void) methodF;
+
+@end
+
+@implementation MyClass
+
++ (void) methodA {}
+- (void) methodB {}
++ (void) methodD
+{
+ SEL d = @selector(methodD); /* Ok */
+ SEL e = @selector(methodE);
+}
+
+- (void) methodE
+{
+ SEL e = @selector(methodE); /* Ok */
+}
+
+- (void) methodF
+{
+ SEL e = @selector(methodE); /* Ok */
+}
+
+@end
+
+int main (void)
+{
+ SEL a = @selector(methodA); /* Ok */
+ SEL b = @selector(methodB); /* Ok */
+ SEL c = @selector(methodC); // expected-warning {{undeclared selector 'methodC'}}
+ SEL d = @selector(methodD); /* Ok */
+ SEL e = @selector(methodE); /* Ok */
+ return 0;
+
+}
diff --git a/clang/test/SemaObjC/undef-class-messagin-error.m b/clang/test/SemaObjC/undef-class-messagin-error.m
new file mode 100644
index 0000000..63e0b9d
--- /dev/null
+++ b/clang/test/SemaObjC/undef-class-messagin-error.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface _Child // expected-note{{'_Child' declared here}}
++ (int) flashCache;
+@end
+
+@interface Child (Categ) // expected-error {{cannot find interface declaration for 'Child'; did you mean '_Child'?}}
++ (int) flushCache2;
+@end
+
+@implementation OtherChild (Categ) // expected-error {{cannot find interface declaration for 'OtherChild'}}
++ (int) flushCache2 { [super flashCache]; } // expected-error {{no @interface declaration found in class messaging of 'flushCache2'}}
+@end
diff --git a/clang/test/SemaObjC/undef-protocol-methods-1.m b/clang/test/SemaObjC/undef-protocol-methods-1.m
new file mode 100644
index 0000000..15ba1a1
--- /dev/null
+++ b/clang/test/SemaObjC/undef-protocol-methods-1.m
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@protocol P1
+- (void) P1proto; // expected-note {{method 'P1proto' declared here}}
++ (void) ClsP1Proto; // expected-note {{method 'ClsP1Proto' declared here}}
+- (void) DefP1proto;
+@end
+@protocol P2
+- (void) P2proto; // expected-note {{method 'P2proto' declared here}}
++ (void) ClsP2Proto; // expected-note {{method 'ClsP2Proto' declared here}}
+@end
+
+@protocol P3<P2>
+- (void) P3proto; // expected-note {{method 'P3proto' declared here}}
++ (void) ClsP3Proto; // expected-note {{method 'ClsP3Proto' declared here}}
++ (void) DefClsP3Proto;
+@end
+
+@protocol PROTO<P1, P3>
+- (void) meth; // expected-note {{method 'meth' declared here}}
+- (void) meth : (int) arg1; // expected-note {{method 'meth:' declared here}}
++ (void) cls_meth : (int) arg1; // expected-note {{method 'cls_meth:' declared here}}
+@end
+
+@interface INTF <PROTO> // expected-note 3 {{required for direct or indirect protocol 'PROTO'}} \
+ // expected-note 2 {{required for direct or indirect protocol 'P1'}} \
+ // expected-note 2 {{required for direct or indirect protocol 'P3'}} \
+ // expected-note 2 {{required for direct or indirect protocol 'P2'}}
+@end
+
+@implementation INTF // expected-warning {{incomplete implementation}} \
+ // expected-warning 9 {{in protocol not implemented}}
+- (void) DefP1proto{}
+
++ (void) DefClsP3Proto{}
+
+@end
diff --git a/clang/test/SemaObjC/undef-superclass-1.m b/clang/test/SemaObjC/undef-superclass-1.m
new file mode 100644
index 0000000..e8e03c5
--- /dev/null
+++ b/clang/test/SemaObjC/undef-superclass-1.m
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@class SUPER, Y; // expected-note 2 {{forward declaration of class here}}
+
+@interface INTF :SUPER // expected-error {{attempting to use the forward class 'SUPER' as superclass of 'INTF'}}
+@end
+
+@interface SUPER @end
+
+@interface INTF1 : SUPER // expected-note {{previous definition is here}}
+@end
+
+@interface INTF2 : INTF1
+@end
+
+@interface INTF3 : Y // expected-error {{attempting to use the forward class 'Y' as superclass of 'INTF3'}} \
+ // expected-note{{'INTF3' declared here}}
+@end
+
+@interface INTF1 // expected-error {{duplicate interface definition for class 'INTF1'}}
+@end
+
+@implementation SUPER
+- (void)dealloc {
+ [super dealloc]; // expected-error {{'SUPER' cannot use 'super' because it is a root class}}
+}
+@end
+
+@interface RecursiveClass : RecursiveClass // expected-error {{trying to recursively use 'RecursiveClass' as superclass of 'RecursiveClass'}}
+@end
+
+@implementation RecursiveClass
+@end
+
+@implementation iNTF3 // expected-warning{{cannot find interface declaration for 'iNTF3'; did you mean 'INTF3'?}}
+@end
diff --git a/clang/test/SemaObjC/undefined-protocol-type-1.m b/clang/test/SemaObjC/undefined-protocol-type-1.m
new file mode 100644
index 0000000..f1a0802
--- /dev/null
+++ b/clang/test/SemaObjC/undefined-protocol-type-1.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol p1, p4;
+@protocol p2 @end
+
+@interface T
+- (T<p2, p3, p1, p4>*) meth; // expected-error {{cannot find protocol declaration for 'p3'}}
+- (T<p2, p3, p1, p4>*) meth1; // expected-error {{cannot find protocol declaration for 'p3'}}
+@end
diff --git a/clang/test/SemaObjC/unimplemented-protocol-prop.m b/clang/test/SemaObjC/unimplemented-protocol-prop.m
new file mode 100644
index 0000000..1438cf5
--- /dev/null
+++ b/clang/test/SemaObjC/unimplemented-protocol-prop.m
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@protocol PROTOCOL0
+@required
+@property float MyProperty0; // expected-note 2 {{property declared}}
+@end
+
+@protocol PROTOCOL<PROTOCOL0>
+@required
+@property float MyProperty; // expected-note 2 {{property declared}}
+@optional
+@property float OptMyProperty;
+@end
+
+@interface I <PROTOCOL>
+@end
+
+@implementation I @end // expected-warning {{property 'MyProperty0' requires method 'MyProperty0' to be defined}} \
+ // expected-warning {{property 'MyProperty0' requires method 'setMyProperty0:' to be defined}}\
+ // expected-warning {{property 'MyProperty' requires method 'MyProperty' to be defined}} \
+ // expected-warning {{property 'MyProperty' requires method 'setMyProperty:' to be defined}}
+
+// rdar://10120691
+// property is implemented in super class. No warning
+
+@protocol PROTOCOL1
+@property int MyProp;
+@end
+
+@interface superclass
+@property int MyProp;
+@end
+
+@interface childclass : superclass <PROTOCOL1>
+@end
+
+@implementation childclass
+@end
+
diff --git a/clang/test/SemaObjC/uninit-variables.m b/clang/test/SemaObjC/uninit-variables.m
new file mode 100644
index 0000000..cad0f54
--- /dev/null
+++ b/clang/test/SemaObjC/uninit-variables.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -fsyntax-only -fblocks %s -verify
+
+// Duplicated from uninit-variables.c.
+// Test just to ensure the analysis is working.
+int test1() {
+ int x; // expected-note{{initialize the variable 'x' to silence this warning}}
+ return x; // expected-warning{{variable 'x' is uninitialized when used here}}
+}
+
+// Test ObjC fast enumeration.
+void test2() {
+ id collection = 0;
+ for (id obj in collection) {
+ if (0 == obj) // no-warning
+ break;
+ }
+}
+
+void test3() {
+ id collection = 0;
+ id obj;
+ for (obj in collection) { // no-warning
+ if (0 == obj) // no-warning
+ break;
+ }
+}
+
diff --git a/clang/test/SemaObjC/unknown-anytype.m b/clang/test/SemaObjC/unknown-anytype.m
new file mode 100644
index 0000000..38e058c
--- /dev/null
+++ b/clang/test/SemaObjC/unknown-anytype.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -funknown-anytype -fsyntax-only -fdebugger-support -verify %s
+
+extern __unknown_anytype test0;
+extern __unknown_anytype test1();
+
+@interface A
+- (int*)getIntPtr;
+- (double*)getSomePtr;
+@end
+
+@interface B
+- (float*)getFloatPtr;
+- (short*)getSomePtr;
+@end
+
+void test_unknown_anytype_receiver() {
+ int *ip = [test0 getIntPtr];
+ float *fp = [test1() getFloatPtr];
+ double *dp = [test1() getSomePtr]; // okay: picks first method found
+ [[test0 unknownMethod] otherUnknownMethod]; // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}}
+ (void)(int)[[test0 unknownMethod] otherUnknownMethod];;
+ [[test1() unknownMethod] otherUnknownMethod]; // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}}
+ (void)(id)[[test1() unknownMethod] otherUnknownMethod];
+
+ if ([[test0 unknownMethod] otherUnknownMethod]) { // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}}
+ }
+ if ([[test1() unknownMethod] otherUnknownMethod]) { // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}}
+ }
+}
diff --git a/clang/test/SemaObjC/unqualified-to-qualified-class-warn.m b/clang/test/SemaObjC/unqualified-to-qualified-class-warn.m
new file mode 100644
index 0000000..e6fa138
--- /dev/null
+++ b/clang/test/SemaObjC/unqualified-to-qualified-class-warn.m
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://9091389
+
+@protocol Fooable
+- (void)foo;
+@end
+
+@protocol SubFooable <Fooable>
+@end
+
+@interface AClass
+@end
+
+@interface BClass : AClass <SubFooable>
+@end
+
+@implementation BClass
+- (void)foo {
+}
+@end
+
+void functionTakingAClassConformingToAProtocol(AClass <Fooable> *instance) { // expected-note {{passing argument to parameter 'instance' here}}
+}
+
+int main () {
+ AClass *aobject = 0;
+ BClass *bobject = 0;
+ functionTakingAClassConformingToAProtocol(aobject); // expected-warning {{incompatible pointer types passing 'AClass *' to parameter of type 'AClass<Fooable> *'}}
+ functionTakingAClassConformingToAProtocol(bobject); // Shouldn't warn - does implement Fooable
+ return 0;
+}
+
+// rdar://9267196
+@interface NSObject @end
+
+@protocol MyProtocol
+@end
+
+@interface MyClass : NSObject
+{
+}
+@end
+
+@implementation MyClass
+@end
+
+@interface MySubclass : MyClass <MyProtocol>
+{
+}
+@end
+
+@interface MyTestClass : NSObject
+{
+@private
+ NSObject <MyProtocol> *someObj;
+}
+
+@property (nonatomic, assign) NSObject <MyProtocol> *someObj;
+
+@end
+
+@implementation MyTestClass
+
+@synthesize someObj;
+
+- (void)someMethod
+{
+ MySubclass *foo;
+ [self setSomeObj:foo]; // no warning here!
+}
+
+@end
diff --git a/clang/test/SemaObjC/unused.m b/clang/test/SemaObjC/unused.m
new file mode 100644
index 0000000..975b9a9
--- /dev/null
+++ b/clang/test/SemaObjC/unused.m
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -verify -Wunused -Wunused-parameter -fsyntax-only -Wno-objc-root-class %s
+
+int printf(const char *, ...);
+
+@interface Greeter
++ (void) hello;
+@end
+
+@implementation Greeter
++ (void) hello { printf("Hello, World!\n"); }
+@end
+
+int test1(void) {
+ [Greeter hello];
+ return 0;
+}
+
+@interface NSObject @end
+@interface NSString : NSObject
+- (int)length;
+@end
+
+void test2() {
+ @"pointless example call for test purposes".length; // expected-warning {{property access result unused - getters should not be used for side effects}}
+}
+
+@interface foo
+- (int)meth: (int)x: (int)y: (int)z ;
+@end
+
+@implementation foo
+- (int) meth: (int)x:
+(int)y: // expected-warning{{unused}}
+(int) __attribute__((unused))z { return x; }
+@end
+
+//===------------------------------------------------------------------------===
+// The next test shows how clang accepted attribute((unused)) on ObjC
+// instance variables, which GCC does not.
+//===------------------------------------------------------------------------===
+
+#if __has_feature(attribute_objc_ivar_unused)
+#define UNUSED_IVAR __attribute__((unused))
+#else
+#error __attribute__((unused)) not supported on ivars
+#endif
+
+@interface TestUnusedIvar {
+ id y __attribute__((unused)); // no-warning
+ id x UNUSED_IVAR; // no-warning
+}
+@end
+
diff --git a/clang/test/SemaObjC/va-method-1.m b/clang/test/SemaObjC/va-method-1.m
new file mode 100644
index 0000000..fe7ccd7
--- /dev/null
+++ b/clang/test/SemaObjC/va-method-1.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include <stdarg.h>
+
+@interface NSObject @end
+@interface XX : NSObject @end
+
+@implementation XX
+- (void)encodeValuesOfObjCTypes:(const char *)types, ... {
+ va_list ap;
+ va_start(ap, types);
+ while (*types) ;
+ va_end(ap);
+}
+
+@end
+
diff --git a/clang/test/SemaObjC/warn-assign-property-nscopying.m b/clang/test/SemaObjC/warn-assign-property-nscopying.m
new file mode 100644
index 0000000..1bdb4f0
--- /dev/null
+++ b/clang/test/SemaObjC/warn-assign-property-nscopying.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fobjc-gc -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fobjc-gc -fsyntax-only -verify %s
+
+@protocol NSCopying @end
+
+@interface NSObject <NSCopying>
+@end
+
+@interface NSDictionary : NSObject
+@end
+
+@interface INTF
+ @property NSDictionary* undoAction; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}} // expected-warning {{default assign attribute on property 'undoAction' which implements NSCopying protocol is not appropriate with}}
+ @property id okAction; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}
+@end
+
diff --git a/clang/test/SemaObjC/warn-deprecated-implementations.m b/clang/test/SemaObjC/warn-deprecated-implementations.m
new file mode 100644
index 0000000..919b221
--- /dev/null
+++ b/clang/test/SemaObjC/warn-deprecated-implementations.m
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -fsyntax-only -Wdeprecated-implementations -verify -Wno-objc-root-class %s
+// rdar://8973810
+
+@protocol P
+- (void) D __attribute__((deprecated)); // expected-note {{method 'D' declared here}}
+@end
+
+@interface A <P>
++ (void)F __attribute__((deprecated)); // expected-note {{method 'F' declared here}}
+@end
+
+@interface A()
+- (void) E __attribute__((deprecated)); // expected-note {{method 'E' declared here}}
+@end
+
+@implementation A
++ (void)F { } // expected-warning {{Implementing deprecated method}}
+- (void) D {} // expected-warning {{Implementing deprecated method}}
+- (void) E {} // expected-warning {{Implementing deprecated method}}
+@end
+
+__attribute__((deprecated))
+@interface CL // expected-note 2 {{class declared here}}
+@end
+
+@implementation CL // expected-warning {{Implementing deprecated class}}
+@end
+
+@implementation CL ( SomeCategory ) // expected-warning {{'CL' is deprecated}} \
+ // expected-warning {{Implementing deprecated category}}
+@end
+
+@interface CL_SUB : CL // expected-warning {{'CL' is deprecated}}
+@end
+
+@interface BASE
+- (void) B __attribute__((deprecated)); // expected-note {{method 'B' declared here}}
+@end
+
+@interface SUB : BASE
+@end
+
+@implementation SUB
+- (void) B {} // expected-warning {{Implementing deprecated method}}
+@end
+
diff --git a/clang/test/SemaObjC/warn-forward-class-attr-deprecated.m b/clang/test/SemaObjC/warn-forward-class-attr-deprecated.m
new file mode 100644
index 0000000..854ff69
--- /dev/null
+++ b/clang/test/SemaObjC/warn-forward-class-attr-deprecated.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://10290322
+
+@class ABGroupImportFilesScope; // expected-note {{forward declaration of class here}}
+
+@interface I1
+- (id) filenames __attribute__((deprecated));
+@end
+
+@interface I2
+- (id) Meth : (ABGroupImportFilesScope*) scope;
+- (id) filenames __attribute__((deprecated));
+- (id)initWithAccount: (id)account filenames:(id)filenames;
+@end
+
+@implementation I2
+- (id) Meth : (ABGroupImportFilesScope*) scope
+{
+ id p = [self initWithAccount : 0 filenames :[scope filenames]]; // expected-warning {{'filenames' maybe deprecated because receiver type is unknown}}
+ return 0;
+}
+- (id) filenames { return 0; }
+- (id)initWithAccount: (id)account filenames:(id)filenames { return 0; }
+@end
diff --git a/clang/test/SemaObjC/warn-implicit-atomic-property.m b/clang/test/SemaObjC/warn-implicit-atomic-property.m
new file mode 100644
index 0000000..887a286
--- /dev/null
+++ b/clang/test/SemaObjC/warn-implicit-atomic-property.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -Wimplicit-atomic-properties -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+// rdar://8774580
+
+@interface Super
+@property (nonatomic, readwrite) int P; // OK
+@property (atomic, readwrite) int P1; // OK
+@property (readwrite) int P2; // expected-note {{property declared here}}
+@property int P3; // expected-note {{property declared here}}
+@end
+
+@implementation Super // expected-warning {{property is assumed atomic when auto-synthesizing the property}}
+@synthesize P,P1,P2; // expected-warning {{property is assumed atomic by default}}
+@end
diff --git a/clang/test/SemaObjC/warn-incompatible-builtin-types.m b/clang/test/SemaObjC/warn-incompatible-builtin-types.m
new file mode 100644
index 0000000..fd4fb7d
--- /dev/null
+++ b/clang/test/SemaObjC/warn-incompatible-builtin-types.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://7634850
+
+@interface Foo
+- (void)foo:(Class)class; // expected-note{{passing argument to parameter 'class' here}}
+@end
+
+void FUNC() {
+ Class c, c1;
+ SEL s1, s2;
+ id i, i1;
+ Foo *f;
+ [f foo:f]; // expected-warning {{incompatible pointer types sending 'Foo *' to parameter of type 'Class'}}
+ c = f; // expected-warning {{incompatible pointer types assigning to 'Class' from 'Foo *'}}
+
+ c = i;
+
+ i = c;
+
+ c = c1;
+
+ i = i1;
+
+ s1 = i; // expected-warning {{incompatible pointer types assigning to 'SEL' from 'id'}}
+ i = s1; // expected-warning {{incompatible pointer types assigning to 'id' from 'SEL'}}
+
+ s1 = s2;
+
+ s1 = c; // expected-warning {{incompatible pointer types assigning to 'SEL' from 'Class'}}
+
+ c = s1; // expected-warning {{incompatible pointer types assigning to 'Class' from 'SEL'}}
+
+ f = i;
+
+ f = c; // expected-warning {{incompatible pointer types assigning to 'Foo *' from 'Class'}}
+
+ f = s1; // expected-warning {{incompatible pointer types assigning to 'Foo *' from 'SEL'}}
+
+ i = f;
+
+ s1 = f; // expected-warning {{incompatible pointer types assigning to 'SEL' from 'Foo *'}}
+}
diff --git a/clang/test/SemaObjC/warn-missing-super.m b/clang/test/SemaObjC/warn-missing-super.m
new file mode 100644
index 0000000..02b8165
--- /dev/null
+++ b/clang/test/SemaObjC/warn-missing-super.m
@@ -0,0 +1,58 @@
+@protocol NSCopying @end
+
+__attribute__((objc_root_class))
+@interface NSObject <NSCopying>
+- (void)dealloc;
+@end
+
+@implementation NSObject
+- (void)dealloc {
+ // Root class, shouldn't warn
+}
+- (void)finalize {
+ // Root class, shouldn't warn
+}
+@end
+
+@interface Subclass1 : NSObject
+- (void)dealloc;
+- (void)finalize;
+@end
+
+@implementation Subclass1
+- (void)dealloc {
+}
+- (void)finalize {
+}
+@end
+
+@interface Subclass2 : NSObject
+- (void)dealloc;
+- (void)finalize;
+@end
+
+@implementation Subclass2
+- (void)dealloc {
+ [super dealloc]; // Shouldn't warn
+}
+- (void)finalize {
+ [super finalize]; // Shouldn't warn
+}
+@end
+
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
+// CHECK: warn-missing-super.m:24:1: warning: method possibly missing a [super dealloc] call
+// CHECK: 1 warning generated.
+
+// RUN: %clang_cc1 -fsyntax-only -fobjc-gc %s 2>&1 | FileCheck --check-prefix=CHECK-GC %s
+// CHECK-GC: warn-missing-super.m:24:1: warning: method possibly missing a [super dealloc] call
+// CHECK-GC: warn-missing-super.m:26:1: warning: method possibly missing a [super finalize] call
+// CHECK-GC: 2 warnings generated.
+
+// RUN: %clang_cc1 -fsyntax-only -fobjc-gc-only %s 2>&1 | FileCheck --check-prefix=CHECK-GC-ONLY %s
+// CHECK-GC-ONLY: warn-missing-super.m:26:1: warning: method possibly missing a [super finalize] call
+// CHECK-GC-ONLY: 1 warning generated.
+
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-arc %s 2>&1 | FileCheck --check-prefix=CHECK-ARC %s
+// CHECK-ARC: warn-missing-super.m:36:4: error: ARC forbids explicit message send of 'dealloc'
+// CHECK-ARC: 1 error generated.
diff --git a/clang/test/SemaObjC/warn-retain-cycle.m b/clang/test/SemaObjC/warn-retain-cycle.m
new file mode 100644
index 0000000..00fd234
--- /dev/null
+++ b/clang/test/SemaObjC/warn-retain-cycle.m
@@ -0,0 +1,125 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
+
+@interface Test0
+- (void) setBlock: (void(^)(void)) block;
+- (void) addBlock: (void(^)(void)) block;
+- (void) actNow;
+@end
+void test0(Test0 *x) {
+ [x setBlock: // expected-note {{block will be retained by the captured object}}
+ ^{ [x actNow]; }]; // expected-warning {{capturing 'x' strongly in this block is likely to lead to a retain cycle}}
+ x.block = // expected-note {{block will be retained by the captured object}}
+ ^{ [x actNow]; }; // expected-warning {{capturing 'x' strongly in this block is likely to lead to a retain cycle}}
+
+ [x addBlock: // expected-note {{block will be retained by the captured object}}
+ ^{ [x actNow]; }]; // expected-warning {{capturing 'x' strongly in this block is likely to lead to a retain cycle}}
+
+ // These actually don't cause retain cycles.
+ __weak Test0 *weakx = x;
+ [x addBlock: ^{ [weakx actNow]; }];
+ [x setBlock: ^{ [weakx actNow]; }];
+ x.block = ^{ [weakx actNow]; };
+
+ // These do cause retain cycles, but we're not clever enough to figure that out.
+ [weakx addBlock: ^{ [x actNow]; }];
+ [weakx setBlock: ^{ [x actNow]; }];
+ weakx.block = ^{ [x actNow]; };
+}
+
+@interface BlockOwner
+@property (retain) void (^strong)(void); // expected-warning {{retain'ed block property does not copy the block - use copy attribute instead}}
+@end
+
+@interface Test1 {
+@public
+ BlockOwner *owner;
+};
+@property (retain) BlockOwner *owner;
+@property (assign) __strong BlockOwner *owner2; // expected-error {{unsafe_unretained property 'owner2' may not also be declared __strong}}
+@property (assign) BlockOwner *owner3;
+@end
+void test1(Test1 *x) {
+ x->owner.strong = ^{ (void) x; }; // expected-warning {{retain cycle}} expected-note {{block will be retained by an object strongly retained by the captured object}}
+ x.owner.strong = ^{ (void) x; }; // expected-warning {{retain cycle}} expected-note {{block will be retained by an object strongly retained by the captured object}}
+ x.owner2.strong = ^{ (void) x; };
+ x.owner3.strong = ^{ (void) x; };
+}
+
+@implementation Test1 {
+ BlockOwner * __unsafe_unretained owner3ivar;
+ __weak BlockOwner *weakowner;
+}
+@dynamic owner;
+@dynamic owner2;
+@synthesize owner3 = owner3ivar;
+
+- (id) init {
+ self.owner.strong = ^{ (void) owner; }; // expected-warning {{retain cycle}} expected-note {{block will be retained by an object strongly retained by the captured object}}
+ self.owner2.strong = ^{ (void) owner; };
+
+ // TODO: should we warn here? What's the story with this kind of mismatch?
+ self.owner3.strong = ^{ (void) owner; };
+
+ owner.strong = ^{ (void) owner; }; // expected-warning {{retain cycle}} expected-note {{block will be retained by an object strongly retained by the captured object}}
+
+ owner.strong = ^{ ^{ (void) owner; }(); }; // expected-warning {{retain cycle}} expected-note {{block will be retained by an object strongly retained by the captured object}}
+
+ owner.strong = ^{ (void) sizeof(self); // expected-note {{block will be retained by an object strongly retained by the captured object}}
+ (void) owner; }; // expected-warning {{capturing 'self' strongly in this block is likely to lead to a retain cycle}}
+
+ weakowner.strong = ^{ (void) owner; };
+
+ return self;
+}
+- (void) foo {
+ owner.strong = ^{ (void) owner; }; // expected-warning {{retain cycle}} expected-note {{block will be retained by an object strongly retained by the captured object}}
+}
+@end
+
+void test2_helper(id);
+@interface Test2 {
+ void (^block)(void);
+ id x;
+}
+@end
+@implementation Test2
+- (void) test {
+ block = ^{ // expected-note {{block will be retained by an object strongly retained by the captured object}}
+ test2_helper(x); // expected-warning {{capturing 'self' strongly in this block is likely to lead to a retain cycle}}
+ };
+}
+@end
+
+
+@interface NSOperationQueue {}
+- (void)addOperationWithBlock:(void (^)(void))block;
+- (void)addSomethingElse:(void (^)(void))block;
+
+@end
+
+@interface Test3 {
+ NSOperationQueue *myOperationQueue;
+ unsigned count;
+}
+@end
+void doSomething(unsigned v);
+@implementation Test3
+- (void) test {
+ // 'addOperationWithBlock:' is specifically whitelisted.
+ [myOperationQueue addOperationWithBlock:^() { // no-warning
+ if (count > 20) {
+ doSomething(count);
+ }
+ }];
+}
+- (void) test_positive {
+ // Sanity check that we are really whitelisting 'addOperationWithBlock:' and not doing
+ // something funny.
+ [myOperationQueue addSomethingElse:^() { // expected-note {{block will be retained by an object strongly retained by the captured object}}
+ if (count > 20) { // expected-warning {{capturing 'self' strongly in this block is likely to lead to a retain cycle}}
+ doSomething(count);
+ }
+ }];
+}
+@end
+
diff --git a/clang/test/SemaObjC/warn-selector-selection.m b/clang/test/SemaObjC/warn-selector-selection.m
new file mode 100644
index 0000000..e395f43
--- /dev/null
+++ b/clang/test/SemaObjC/warn-selector-selection.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface Object
+- (void)foo;
+@end
+
+@interface Class1
+- (void)setWindow:(Object *)wdw;
+@end
+
+void foo(void) {
+ Object *obj;
+ [obj setWindow:0]; // expected-warning{{'Object' may not respond to 'setWindow:'}}
+}
diff --git a/clang/test/SemaObjC/warn-strict-selector-match.m b/clang/test/SemaObjC/warn-strict-selector-match.m
new file mode 100644
index 0000000..34f1712
--- /dev/null
+++ b/clang/test/SemaObjC/warn-strict-selector-match.m
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -Wstrict-selector-match -fsyntax-only -verify %s
+
+@interface Foo
+-(int) method; // expected-note {{using}}
+@end
+
+@interface Bar
+-(float) method; // expected-note {{also found}}
+@end
+
+int main() { [(id)0 method]; } // expected-warning {{multiple methods named 'method' found}}
+
+@interface Object @end
+
+@interface Class1
+- (void)setWindow:(Object *)wdw; // expected-note {{using}}
+@end
+
+@interface Class2
+- (void)setWindow:(Class1 *)window; // expected-note {{also found}}
+@end
+
+id foo(void) {
+ Object *obj = 0;
+ id obj2 = obj;
+ [obj setWindow:0]; // expected-warning {{Object' may not respond to 'setWindow:'}}
+ [obj2 setWindow:0]; // expected-warning {{multiple methods named 'setWindow:' found}}
+ return obj;
+}
+
+@protocol MyObject
+- (id)initWithData:(Object *)data; // expected-note {{using}} \
+ // expected-note {{passing argument to parameter 'data' here}}
+@end
+
+@protocol SomeOther
+- (id)initWithData:(int)data; // expected-note {{also found}}
+@end
+
+@protocol MyCoding
+- (id)initWithData:(id<MyObject, MyCoding>)data; // expected-note {{also found}}
+@end
+
+@interface NTGridDataObject: Object <MyCoding>
+{
+ Object<MyCoding> *_data;
+}
++ (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data;
+@end
+
+@implementation NTGridDataObject
+- (id)initWithData:(id<MyObject, MyCoding>)data {
+ return data;
+}
++ (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data
+{
+ NTGridDataObject *result = [(id)0 initWithData:data]; // expected-warning {{multiple methods named 'initWithData:' found}} \
+ expected-warning {{sending 'id<MyObject,MyCoding>' to parameter of incompatible type 'Object *'}}
+ return result;
+}
+@end
+
+@interface Base
+- (unsigned)port;
+@end
+
+@interface Derived: Base
+- (Object *)port;
++ (Protocol *)port;
+@end
+
+void foo1(void) {
+ [(Class)0 port]; // OK - gcc issues warning but there is only one Class method so no ambiguity to warn
+}
+
diff --git a/clang/test/SemaObjC/warn-superclass-method-mismatch.m b/clang/test/SemaObjC/warn-superclass-method-mismatch.m
new file mode 100644
index 0000000..5205473
--- /dev/null
+++ b/clang/test/SemaObjC/warn-superclass-method-mismatch.m
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -Wsuper-class-method-mismatch -verify %s
+
+@interface Root
+-(void) method_r: (char)ch : (float*)f1 : (int*) x; // expected-note {{previous declaration is here}}
+@end
+
+@class Sub;
+
+@interface Base : Root
+-(void) method: (int*) x; // expected-note {{previous declaration is here}}
+-(void) method1: (Base*) x; // expected-note {{previous declaration is here}}
+-(void) method2: (Sub*) x; // expected-note{{passing argument to parameter 'x' here}}
++ method3: (int)x1 : (Base *)x2 : (float)x3; // expected-note {{previous declaration is here}}
++ mathod4: (id)x1;
+- method5: (int) x : (double) d; // expected-note {{previous declaration is here}}
+- method6: (int) x : (float) d; // expected-note {{previous declaration is here}}
+@end
+
+struct A {
+ int x,y,z;
+};
+
+@interface Sub : Base
+-(void) method: (struct A*) a; // expected-warning {{method parameter type 'struct A *' does not match super class method parameter type 'int *'}}
+-(void) method1: (Sub*) x; // expected-warning {{method parameter type 'Sub *' does not match super class method parameter type 'Base *'}}
+-(void) method2: (Base*) x; // no need to warn. At call point we warn if need be.
++ method3: (int)x1 : (Sub *)x2 : (float)x3; // expected-warning {{method parameter type 'Sub *' does not match super class method parameter type 'Base *'}}
++ mathod4: (Base*)x1;
+-(void) method_r: (char)ch : (float*)f1 : (Sub*) x; // expected-warning {{method parameter type 'Sub *' does not match super class method parameter type 'int *'}}
+- method5: (int) x : (float) d; // expected-warning {{method parameter type 'float' does not match super class method parameter type 'double'}}
+- method6: (int) x : (double) d; // expected-warning {{method parameter type 'double' does not match super class method parameter type 'float'}}
+@end
+
+void f(Base *base, Sub *sub) {
+ int x;
+ [base method:&x]; // warn. if base is actually 'Sub' it will use -[Sub method] with wrong arguments
+
+ Base *b;
+ [base method1:b]; // if base is actuall 'Sub' it will use [Sub method1] with wrong argument.
+
+ [base method2:b]; // expected-warning {{}}
+
+ Sub *s;
+ [base method2:s]; // if base is actually 'Sub' OK. Either way OK.
+
+}
+
+
+
+
diff --git a/clang/test/SemaObjC/warn-unreachable.m b/clang/test/SemaObjC/warn-unreachable.m
new file mode 100644
index 0000000..832cbd2
--- /dev/null
+++ b/clang/test/SemaObjC/warn-unreachable.m
@@ -0,0 +1,17 @@
+// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code -Wno-unused-value -Wno-covered-switch-default
+
+// This previously triggered a warning from -Wunreachable-code because of
+// a busted CFG.
+typedef signed char BOOL;
+BOOL radar10989084() {
+ @autoreleasepool { // no-warning
+ return __objc_yes;
+ }
+}
+
+// Test the warning works.
+void test_unreachable() {
+ return;
+ return; // expected-warning {{will never be executed}}
+}
+
diff --git a/clang/test/SemaObjC/warn-unused-exception-param.m b/clang/test/SemaObjC/warn-unused-exception-param.m
new file mode 100644
index 0000000..221e16f
--- /dev/null
+++ b/clang/test/SemaObjC/warn-unused-exception-param.m
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -Wunused-exception-parameter %s
+void f0() {
+ @try {} @catch(id a) {} // expected-warning{{unused exception parameter 'a'}}
+}
diff --git a/clang/test/SemaObjC/warn-weak-field.m b/clang/test/SemaObjC/warn-weak-field.m
new file mode 100644
index 0000000..e7b0fe2
--- /dev/null
+++ b/clang/test/SemaObjC/warn-weak-field.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -fobjc-gc -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fsyntax-only -fobjc-gc -verify -Wno-objc-root-class %s
+
+struct S {
+ __weak id w; // expected-warning {{__weak attribute cannot be specified on a field declaration}}
+ __strong id p1;
+};
+
+@interface I
+{
+ __weak id w; // OK
+ __strong id LHS;
+}
+- (void) foo;
+@end
+@implementation I
+- (void) foo { w = 0; LHS = w; }
+@end
+
+int main ()
+{
+ struct I {
+ __weak id w1; // expected-warning {{__weak attribute cannot be specified on a field declaration}}
+ };
+}
diff --git a/clang/test/SemaObjC/warn-write-strings.m b/clang/test/SemaObjC/warn-write-strings.m
new file mode 100644
index 0000000..163c864
--- /dev/null
+++ b/clang/test/SemaObjC/warn-write-strings.m
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fconst-strings %s
+
+// PR4804
+char* x = "foo"; // expected-warning {{initializing 'char *' with an expression of type 'const char [4]' discards qualifiers}}
diff --git a/clang/test/SemaObjC/weak-attr-ivar.m b/clang/test/SemaObjC/weak-attr-ivar.m
new file mode 100644
index 0000000..e3d96da
--- /dev/null
+++ b/clang/test/SemaObjC/weak-attr-ivar.m
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+@end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+typedef struct {
+ id *itemsPtr;
+ unsigned long *mutationsPtr;
+} NSFastEnumerationState;
+@protocol NSFastEnumeration
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+@class NSString;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end
+@interface NSMutableArray : NSArray - (void)addObject:(id)anObject;
+@end
+extern NSString * const NSUndoManagerCheckpointNotification;
+@interface NSValueTransformer : NSObject {} @end
+@class FooModel;
+@interface FooObject : NSObject <NSCopying> {}
+@end
+@interface FooNode : FooObject {}
+- (NSArray *) children;
+@end
+typedef enum { Foo_HUH_NONE } FooHUHCode;
+@interface FooPlaypenEntry : FooNode {
+ NSMutableArray *_interestingChildren;
+ FooHUHCode _HUH;
+ __attribute__((objc_gc(weak))) FooPlaypenEntry *_mostInterestingChild;
+ id _author;
+}
+@property(copy) NSString *author;
+- (BOOL) isInteresting;
+@end NSString *FooHUHCodeToString(FooHUHCode HUH) { return 0; }
+@interface FooHUHCodeToStringTransformer: NSValueTransformer {
+}
+@end @implementation FooPlaypenEntry @synthesize author = _author;
+- (BOOL) isInteresting { return 1; }
+- (NSArray *) interestingChildren {
+ if (!_interestingChildren) {
+ for (FooPlaypenEntry *child in [self children]) {
+ if ([child isInteresting]) {
+ if (!_mostInterestingChild)
+ _mostInterestingChild = child;
+ else if (child->_HUH > _mostInterestingChild->_HUH)
+ _mostInterestingChild = child;
+ }
+ }
+ }
+ return 0;
+}
+- (FooHUHCode) HUH {
+ if (_HUH == Foo_HUH_NONE) {
+ if (_mostInterestingChild)
+ return [_mostInterestingChild HUH];
+ }
+ return 0;
+}
+@end
+
+// rdar://problem/9123040
+@interface Test1 {
+@public
+ id ivar __attribute__((objc_gc(weak)));
+}
+@property (assign) id prop __attribute((objc_gc(weak)));
+@end
+void test1(Test1 *t) {
+ id *(__attribute__((objc_gc(strong))) x) = &t->ivar; // expected-warning {{initializing '__strong id *' with an expression of type '__weak id *' discards qualifiers}}
+}
diff --git a/clang/test/SemaObjC/weak-property.m b/clang/test/SemaObjC/weak-property.m
new file mode 100644
index 0000000..8a2adf9
--- /dev/null
+++ b/clang/test/SemaObjC/weak-property.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -verify -Wno-objc-root-class %s
+// rdar://8899430
+
+@interface WeakPropertyTest {
+ Class isa;
+ __weak id value;
+ id x;
+}
+@property (weak) id value1;
+@property __weak id value;
+@property () __weak id value2;
+
+@property (weak, assign) id v1; // expected-error {{property attributes 'assign' and 'weak' are mutually exclusive}}
+@property (weak, copy) id v2; // expected-error {{property attributes 'copy' and 'weak' are mutually exclusive}}
+@property (weak, retain) id v3; // expected-error {{property attributes 'retain' and 'weak' are mutually exclusive}}
+@property (weak, assign) id v4; // expected-error {{property attributes 'assign' and 'weak' are mutually exclusive}}
+
+@property () __weak id x; // expected-note {{property declared here}}
+@end
+
+@implementation WeakPropertyTest
+@synthesize x; // expected-error {{existing ivar 'x' for __weak property 'x' must be __weak}}
+@dynamic value1, value, value2, v1,v2,v3,v4;
+@end
diff --git a/clang/test/SemaObjC/weak-receiver-warn.m b/clang/test/SemaObjC/weak-receiver-warn.m
new file mode 100644
index 0000000..f3955da
--- /dev/null
+++ b/clang/test/SemaObjC/weak-receiver-warn.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -Wreceiver-is-weak -verify %s
+// rdar://10225276
+
+@interface Test0
+- (void) setBlock: (void(^)(void)) block;
+- (void) addBlock: (void(^)(void)) block;
+- (void) actNow;
+@end
+
+void test0(Test0 *x) {
+ __weak Test0 *weakx = x;
+ [x addBlock: ^{ [weakx actNow]; }]; // expected-warning {{weak receiver may be unpredictably null in ARC mode}}
+ [x setBlock: ^{ [weakx actNow]; }]; // expected-warning {{weak receiver may be unpredictably null in ARC mode}}
+ x.block = ^{ [weakx actNow]; }; // expected-warning {{weak receiver may be unpredictably null in ARC mode}}
+
+ [weakx addBlock: ^{ [x actNow]; }]; // expected-warning {{weak receiver may be unpredictably null in ARC mode}}
+ [weakx setBlock: ^{ [x actNow]; }]; // expected-warning {{weak receiver may be unpredictably null in ARC mode}}
+ weakx.block = ^{ [x actNow]; };
+}
diff --git a/clang/test/SemaObjC/writable-property-in-superclass.m b/clang/test/SemaObjC/writable-property-in-superclass.m
new file mode 100644
index 0000000..bbd1f16
--- /dev/null
+++ b/clang/test/SemaObjC/writable-property-in-superclass.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface MessageStore
+@property (assign, readonly) int P;
+@end
+
+@interface MessageStore (CAT)
+@property (assign) int P;
+@end
+
+@interface NeXTMbox : MessageStore
+@end
+
+@implementation NeXTMbox
+- (void) Meth { self.P = 1; }
+@end
+
diff --git a/clang/test/SemaObjCXX/Inputs/arc-system-header.h b/clang/test/SemaObjCXX/Inputs/arc-system-header.h
new file mode 100644
index 0000000..d7adeb4
--- /dev/null
+++ b/clang/test/SemaObjCXX/Inputs/arc-system-header.h
@@ -0,0 +1,14 @@
+@interface B
+@end
+
+
+@interface A {
+@public
+ union {
+ struct {
+ B *b;
+ } a_b;
+ void *void_ptr;
+ } data;
+}
+@end
diff --git a/clang/test/SemaObjCXX/NSString-type.mm b/clang/test/SemaObjCXX/NSString-type.mm
new file mode 100644
index 0000000..1033866
--- /dev/null
+++ b/clang/test/SemaObjCXX/NSString-type.mm
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -verify %s
+// rdar://10907410
+
+void test(id pid, Class pclass) {
+ void (^block)(void) = @"help"; // expected-error {{cannot initialize a variable of type 'void (^)()' with an rvalue of type 'NSString *'}}
+ void (^block1)(void) = pid;
+ void (^block2)(void) = @"help"; // expected-error {{cannot initialize a variable of type 'void (^)()' with an rvalue of type 'NSString *'}}
+ void (^block3)(void) = @"help"; // expected-error {{cannot initialize a variable of type 'void (^)()' with an rvalue of type 'NSString *'}}
+}
+
diff --git a/clang/test/SemaObjCXX/arc-0x.mm b/clang/test/SemaObjCXX/arc-0x.mm
new file mode 100644
index 0000000..28eec51
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-0x.mm
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -verify -fblocks -fobjc-exceptions %s
+
+// "Move" semantics, trivial version.
+void move_it(__strong id &&from) {
+ id to = static_cast<__strong id&&>(from);
+}
+
+// Deduction with 'auto'.
+@interface A
++ alloc;
+- init;
+@end
+
+// Ensure that deduction works with lifetime qualifiers.
+void deduction(id obj) {
+ auto a = [[A alloc] init];
+ __strong A** aPtr = &a;
+
+ auto a2([[A alloc] init]);
+ __strong A** aPtr2 = &a2;
+
+ __strong id *idp = new auto(obj);
+
+ __strong id array[17];
+ for (auto x : array) {
+ __strong id *xPtr = &x;
+ }
+
+ @try {
+ } @catch (auto e) { // expected-error {{'auto' not allowed in exception declaration}}
+ }
+}
+
+// rdar://problem/11068137
+void test1a() {
+ __autoreleasing id p; // expected-note 2 {{'p' declared here}}
+ (void) [&p] {};
+ (void) [p] {}; // expected-error {{cannot capture __autoreleasing variable in a lambda by copy}}
+ (void) [=] { (void) p; }; // expected-error {{cannot capture __autoreleasing variable in a lambda by copy}}
+}
+void test1b() {
+ __autoreleasing id v;
+ __autoreleasing id &p = v; // expected-note 2 {{'p' declared here}}
+ (void) [&p] {};
+ (void) [p] {}; // expected-error {{cannot capture __autoreleasing variable in a lambda by copy}}
+ (void) [=] { (void) p; }; // expected-error {{cannot capture __autoreleasing variable in a lambda by copy}}
+}
+void test1c() {
+ __autoreleasing id v; // expected-note {{'v' declared here}}
+ __autoreleasing id &p = v;
+ (void) ^{ (void) p; };
+ (void) ^{ (void) v; }; // expected-error {{cannot capture __autoreleasing variable in a block}}
+}
diff --git a/clang/test/SemaObjCXX/arc-bool-conversion.mm b/clang/test/SemaObjCXX/arc-bool-conversion.mm
new file mode 100644
index 0000000..d8f840e
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-bool-conversion.mm
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify -fblocks -triple x86_64-apple-darwin10.0.0 %s
+// rdar://9310049
+
+bool fn(id obj) {
+ return (bool)obj;
+}
+
diff --git a/clang/test/SemaObjCXX/arc-bridged-cast.mm b/clang/test/SemaObjCXX/arc-bridged-cast.mm
new file mode 100644
index 0000000..1ea67a3
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-bridged-cast.mm
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify %s
+
+typedef const void *CFTypeRef;
+typedef const struct __CFString *CFStringRef;
+
+@interface NSString
+@end
+
+CFTypeRef CFCreateSomething();
+CFStringRef CFCreateString();
+CFTypeRef CFGetSomething();
+CFStringRef CFGetString();
+
+id CreateSomething();
+NSString *CreateNSString();
+
+template<typename IdType, typename StringType, typename IntPtrType>
+void from_cf() {
+ id obj1 = (__bridge_transfer IdType)CFCreateSomething();
+ id obj2 = (__bridge_transfer StringType)CFCreateString();
+ (__bridge IntPtrType)CFCreateSomething(); // expected-error{{incompatible types casting 'CFTypeRef' (aka 'const void *') to 'int *' with a __bridge cast}}
+ id obj3 = (__bridge IdType)CFGetSomething();
+ id obj4 = (__bridge StringType)CFGetString();
+}
+
+template void from_cf<id, NSString*, int*>(); // expected-note{{in instantiation of function template specialization}}
+
+template<typename IdType, typename StringType>
+void to_cf(id obj) {
+ CFTypeRef cf1 = (__bridge_retained IdType)CreateSomething();
+ CFStringRef cf2 = (__bridge_retained StringType)CreateNSString();
+ CFTypeRef cf3 = (__bridge IdType)CreateSomething();
+ CFStringRef cf4 = (__bridge StringType)CreateNSString();
+}
+
+template void to_cf<CFTypeRef, CFStringRef>(id);
diff --git a/clang/test/SemaObjCXX/arc-libstdcxx.mm b/clang/test/SemaObjCXX/arc-libstdcxx.mm
new file mode 100644
index 0000000..71771b4
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-libstdcxx.mm
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-arc-cxxlib=libstdc++ -fobjc-runtime-has-weak -verify %s
+
+@interface A @end
+
+int check0[std::__is_scalar<__strong id>::__value? -1 : 1];
+int check1[std::__is_scalar<__weak id>::__value? -1 : 1];
+int check2[std::__is_scalar<__autoreleasing id>::__value? -1 : 1];
+int check3[std::__is_scalar<__strong A*>::__value? -1 : 1];
+int check4[std::__is_scalar<__weak A*>::__value? -1 : 1];
+int check5[std::__is_scalar<__autoreleasing A*>::__value? -1 : 1];
diff --git a/clang/test/SemaObjCXX/arc-memfunc.mm b/clang/test/SemaObjCXX/arc-memfunc.mm
new file mode 100644
index 0000000..274f873
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-memfunc.mm
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify -fblocks %s
+
+struct X0 {
+ static id makeObject1() __attribute__((ns_returns_retained));
+ id makeObject2() __attribute__((ns_returns_retained));
+};
+
+void test_X0(X0 x0, X0 *x0p) {
+ X0::makeObject1();
+ x0.makeObject2();
+ x0p->makeObject2();
+ id (X0::*pmf)() __attribute__((ns_returns_retained)) = &X0::makeObject2;
+ (x0.*pmf)();
+ (x0p->*pmf)();
+}
diff --git a/clang/test/SemaObjCXX/arc-non-pod.mm b/clang/test/SemaObjCXX/arc-non-pod.mm
new file mode 100644
index 0000000..1c5cf7a
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-non-pod.mm
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -Warc-abi -verify -fblocks -triple x86_64-apple-darwin10.0.0 %s
+
+// Classes that have an Objective-C object pointer.
+struct HasObjectMember0 { // expected-warning{{'HasObjectMember0' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
+ id x;
+};
+
+struct HasObjectMember1 { // expected-warning{{'HasObjectMember1' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
+ id x[3];
+};
+
+struct HasObjectMember2 { // expected-warning{{'HasObjectMember2' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
+ 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 ownership.
+struct HasObjectMember3 {
+ __unsafe_unretained id x[3][2];
+};
+
+struct HasBlockPointerMember0 { // expected-warning{{'HasBlockPointerMember0' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
+ int (^bp)(int);
+};
+
+struct HasBlockPointerMember1 { // expected-warning{{'HasBlockPointerMember1' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
+ int (^bp[2][3])(int);
+};
+
+struct NonPOD {
+ NonPOD(const NonPOD&);
+};
+
+struct HasObjectMemberAndNonPOD0 { // expected-warning{{'HasObjectMemberAndNonPOD0' cannot be shared between ARC and non-ARC code; add a non-trivial copy assignment operator to make it ABI-compatible}} \
+ // expected-warning{{'HasObjectMemberAndNonPOD0' cannot be shared between ARC and non-ARC code; add a non-trivial destructor to make it ABI-compatible}}
+ id x;
+ NonPOD np;
+};
+
+struct HasObjectMemberAndNonPOD1 { // expected-warning{{'HasObjectMemberAndNonPOD1' cannot be shared between ARC and non-ARC code; add a non-trivial copy assignment operator to make it ABI-compatible}} \
+ // expected-warning{{'HasObjectMemberAndNonPOD1' cannot be shared between ARC and non-ARC code; add a non-trivial destructor to make it ABI-compatible}}
+ NonPOD np;
+ id x[3];
+};
+
+struct HasObjectMemberAndNonPOD2 { // expected-warning{{'HasObjectMemberAndNonPOD2' cannot be shared between ARC and non-ARC code; add a non-trivial copy assignment operator to make it ABI-compatible}} \
+ // expected-warning{{'HasObjectMemberAndNonPOD2' cannot be shared between ARC and non-ARC code; add a non-trivial destructor to make it ABI-compatible}}
+ NonPOD np;
+ id x[3][2];
+};
+
+struct HasObjectMemberAndNonPOD3 {
+ HasObjectMemberAndNonPOD3 &operator=(const HasObjectMemberAndNonPOD3&);
+ ~HasObjectMemberAndNonPOD3();
+ NonPOD np;
+ id x[3][2];
+};
+
+struct HasBlockPointerMemberAndNonPOD0 { // expected-warning{{'HasBlockPointerMemberAndNonPOD0' cannot be shared between ARC and non-ARC code; add a non-trivial copy assignment operator to make it ABI-compatible}} \
+// expected-warning{{'HasBlockPointerMemberAndNonPOD0' cannot be shared between ARC and non-ARC code; add a non-trivial destructor to make it ABI-compatible}}
+ NonPOD np;
+ int (^bp)(int);
+};
+
+struct HasBlockPointerMemberAndNonPOD1 { // expected-warning{{'HasBlockPointerMemberAndNonPOD1' cannot be shared between ARC and non-ARC code; add a non-trivial copy assignment operator to make it ABI-compatible}} \
+// expected-warning{{'HasBlockPointerMemberAndNonPOD1' cannot be shared between ARC and non-ARC code; add a non-trivial destructor to make it ABI-compatible}}
+ 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];
+int check_non_pod_block2[__is_pod(int (^ __strong)(int))? -1 : 1];
+
+struct FlexibleArrayMember0 {
+ int length;
+ id array[]; // expected-error{{flexible array member 'array' of non-POD element type 'id __strong[]'}}
+};
+
+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];
+}
+
+@interface Crufty {
+ union {
+ struct {
+ id object; // expected-note{{has __strong ownership}}
+ } an_object; // expected-error{{union member 'an_object' has a non-trivial copy constructor}}
+ void *ptr;
+ } storage;
+}
+@end
diff --git a/clang/test/SemaObjCXX/arc-nsconsumed-errors.mm b/clang/test/SemaObjCXX/arc-nsconsumed-errors.mm
new file mode 100644
index 0000000..93f5d99
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-nsconsumed-errors.mm
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify -fblocks -triple x86_64-apple-darwin10.0.0 %s
+// rdar://10187884
+
+typedef void (^blk)(id, __attribute((ns_consumed)) id);
+typedef void (^blk1)(__attribute((ns_consumed))id, __attribute((ns_consumed)) id);
+blk a = ^void (__attribute((ns_consumed)) id, __attribute((ns_consumed)) id){}; // expected-error {{cannot initialize a variable of type '__strong blk'}}
+
+blk b = ^void (id, __attribute((ns_consumed)) id){};
+
+blk c = ^void (__attribute((ns_consumed)) id, __attribute((ns_consumed)) id){}; // expected-error {{cannot initialize a variable of type '__strong blk'}}
+
+blk d = ^void (id, id) {}; // expected-error {{cannot initialize a variable of type '__strong blk'}}
+
+blk1 a1 = ^void (__attribute((ns_consumed)) id, id){}; // expected-error {{cannot initialize a variable of type '__strong blk1'}}
+
+blk1 b2 = ^void (id, __attribute((ns_consumed)) id){}; // expected-error {{cannot initialize a variable of type '__strong blk1'}}
+
+blk1 c3 = ^void (__attribute((ns_consumed)) id, __attribute((ns_consumed)) id){};
+
+blk1 d4 = ^void (id, id) {}; // expected-error {{cannot initialize a variable of type '__strong blk1'}}
diff --git a/clang/test/SemaObjCXX/arc-object-init-destroy.mm b/clang/test/SemaObjCXX/arc-object-init-destroy.mm
new file mode 100644
index 0000000..e10e3ea
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-object-init-destroy.mm
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify -Warc-abi -fblocks -triple x86_64-apple-darwin10.0.0 %s
+
+typedef __strong id strong_id;
+typedef __weak id weak_id;
+void test_pseudo_destructors(__strong id *sptr, __weak id *wptr) {
+ sptr->~id(); // okay
+ wptr->~id(); // okay
+ sptr->~strong_id(); // okay
+ wptr->~weak_id();
+ sptr->~weak_id(); // expected-error{{pseudo-destructor destroys object of type '__strong id' with inconsistently-qualified type 'weak_id' (aka '__weak id')}}
+ wptr->strong_id::~strong_id(); // expected-error{{pseudo-destructor destroys object of type '__weak id' with inconsistently-qualified type 'strong_id' (aka '__strong id')}}
+
+ sptr->id::~id(); // okay
+ wptr->id::~id(); // okay
+}
+
+void test_delete(__strong id *sptr, __weak id *wptr) {
+ delete sptr;
+ delete wptr;
+ delete [] sptr; // expected-warning{{destroying an array of '__strong id'; this array must not have been allocated from non-ARC code}}
+ delete [] wptr; // expected-warning{{destroying an array of '__weak id'; this array must not have been allocated from non-ARC code}}
+}
+
+void test_new(int n) {
+ (void)new strong_id;
+ (void)new weak_id;
+ (void)new strong_id [n]; // expected-warning{{allocating an array of 'strong_id' (aka '__strong id'); this array must not be deleted in non-ARC code}}
+ (void)new weak_id [n]; // expected-warning{{allocating an array of 'weak_id' (aka '__weak id'); this array must not be deleted in non-ARC code}}
+
+ (void)new __strong id;
+ (void)new __weak id;
+ (void)new __strong id [n]; // expected-warning{{allocating an array of '__strong id'; this array must not be deleted in non-ARC code}}
+
+ // Infer '__strong'.
+ __strong id *idptr = new id;
+ __strong id *idptr2 = new id [n]; // expected-warning{{allocating an array of '__strong id'; this array must not be deleted in non-ARC code}}
+
+ // ... but not for arrays.
+ typedef id id_array[2][3];
+ (void)new id_array; // expected-error{{'new' cannot allocate an array of 'id' with no explicit ownership}}
+
+ typedef __strong id strong_id_array[2][3];
+ typedef __strong id strong_id_3[3];
+ strong_id_3 *idptr3 = new strong_id_array; // expected-warning{{allocating an array of '__strong id'; this array must not be deleted in non-ARC code}}
+}
+
+void test_jump_scope() {
+ goto done; // expected-error{{goto into protected scope}}
+ __strong id x; // expected-note{{jump bypasses initialization of retaining variable}}
+ done:
+ return;
+}
diff --git a/clang/test/SemaObjCXX/arc-overloading.mm b/clang/test/SemaObjCXX/arc-overloading.mm
new file mode 100644
index 0000000..a749417
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-overloading.mm
@@ -0,0 +1,202 @@
+// RUN: %clang_cc1 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify -fblocks -Wno-objc-root-class %s
+
+// Simple ownership conversions + diagnostics.
+int &f0(id __strong const *); // expected-note{{candidate function not viable: 1st argument ('__weak id *') has __weak ownership, but parameter has __strong ownership}}
+
+void test_f0() {
+ id __strong *sip;
+ id __strong const *csip;
+ id __weak *wip;
+ id __autoreleasing *aip;
+ id __unsafe_unretained *uip;
+
+ int &ir1 = f0(sip);
+ int &ir2 = f0(csip);
+ int &ir3 = f0(aip);
+ int &ir4 = f0(uip);
+ f0(wip); // expected-error{{no matching function for call to 'f0'}}
+}
+
+// Simple overloading
+int &f1(id __strong const *);
+float &f1(id __weak const *);
+
+void test_f1() {
+ id __strong *sip;
+ id __strong const *csip;
+ id __weak *wip;
+ id __autoreleasing *aip;
+ id __unsafe_unretained *uip;
+
+ int &ir1 = f1(sip);
+ int &ir2 = f1(csip);
+ float &fr1 = f1(wip);
+ int &ir3 = f1(aip);
+ int &ir4 = f1(uip);
+}
+
+// Simple overloading
+int &f2(id __strong const *); // expected-note{{candidate function}}
+float &f2(id __autoreleasing const *); // expected-note{{candidate function}}
+
+void test_f2() {
+ id __strong *sip;
+ id __strong const *csip;
+ id __weak *wip;
+ id __autoreleasing *aip;
+ id __unsafe_unretained *uip;
+
+ // Prefer non-ownership conversions to ownership conversions.
+ int &ir1 = f2(sip);
+ int &ir2 = f2(csip);
+ float &fr1 = f2(aip);
+
+ f2(uip); // expected-error{{call to 'f2' is ambiguous}}
+}
+
+// Writeback conversion
+int &f3(id __autoreleasing *); // expected-note{{candidate function not viable: 1st argument ('__unsafe_unretained id *') has __unsafe_unretained ownership, but parameter has __autoreleasing ownership}}
+
+void test_f3() {
+ id __strong sip;
+ id __weak wip;
+ id __autoreleasing aip;
+ id __unsafe_unretained uip;
+
+ int &ir1 = f3(&sip);
+ int &ir2 = f3(&wip);
+ int &ir3 = f3(&aip);
+ f3(&uip); // expected-error{{no matching function for call to 'f3'}}
+}
+
+// Writeback conversion vs. no conversion
+int &f4(id __autoreleasing *);
+float &f4(id __strong *);
+
+void test_f4() {
+ id __strong sip;
+ id __weak wip;
+ id __autoreleasing aip;
+ extern __weak id weak_global_ptr;
+
+ float &fr1 = f4(&sip);
+ int &ir1 = f4(&wip);
+ int &ir2 = f4(&aip);
+ int &ir3 = f4(&weak_global_ptr); // expected-error{{passing address of non-local object to __autoreleasing parameter for write-back}}
+}
+
+// Writeback conversion vs. other conversion.
+int &f5(id __autoreleasing *);
+float &f5(id const __unsafe_unretained *);
+
+void test_f5() {
+ id __strong sip;
+ id __weak wip;
+ id __autoreleasing aip;
+
+ int &ir1 = f5(&wip);
+ float &fr1 = f5(&sip);
+ int &ir2 = f5(&aip);
+}
+
+@interface A
+@end
+
+int &f6(id __autoreleasing *);
+float &f6(id const __unsafe_unretained *);
+
+void test_f6() {
+ A* __strong sip;
+ A* __weak wip;
+ A* __autoreleasing aip;
+
+ int &ir1 = f6(&wip);
+ float &fr1 = f6(&sip);
+ int &ir2 = f6(&aip);
+}
+
+// Reference binding
+void f7(__strong id&); // expected-note{{candidate function not viable: 1st argument ('__weak id') has __weak ownership, but parameter has __strong ownership}} \
+ // expected-note{{candidate function not viable: 1st argument ('__autoreleasing id') has __autoreleasing ownership, but parameter has __strong ownership}} \
+ // expected-note{{candidate function not viable: 1st argument ('__unsafe_unretained id') has __unsafe_unretained ownership, but parameter has __strong ownership}}
+
+void test_f7() {
+ __strong id strong_id;
+ __weak id weak_id;
+ __autoreleasing id autoreleasing_id;
+ __unsafe_unretained id unsafe_id;
+ f7(strong_id);
+ f7(weak_id); // expected-error{{no matching function for call to 'f7'}}
+ f7(autoreleasing_id); // expected-error{{no matching function for call to 'f7'}}
+ f7(unsafe_id); // expected-error{{no matching function for call to 'f7'}}
+}
+
+void f8(const __strong id&);
+
+void test_f8() {
+ __strong id strong_id;
+ __weak id weak_id;
+ __autoreleasing id autoreleasing_id;
+ __unsafe_unretained id unsafe_id;
+
+ f8(strong_id);
+ f8(weak_id);
+ f8(autoreleasing_id);
+ f8(unsafe_id);
+}
+
+int &f9(__strong id&);
+float &f9(const __autoreleasing id&);
+
+void test_f9() {
+ __strong id strong_id;
+ __weak id weak_id;
+ __autoreleasing id autoreleasing_id;
+ __unsafe_unretained id unsafe_id;
+
+ int &ir1 = f9(strong_id);
+ float &fr1 = f9(autoreleasing_id);
+ float &fr2 = f9(unsafe_id);
+ float &fr2a = f9(weak_id);
+
+ __strong A *strong_a;
+ __weak A *weak_a;
+ __autoreleasing A *autoreleasing_a;
+ __unsafe_unretained A *unsafe_unretained_a;
+ float &fr3 = f9(strong_a);
+ float &fr4 = f9(autoreleasing_a);
+ float &fr5 = f9(unsafe_unretained_a);
+ float &fr6 = f9(weak_a);
+
+ const __autoreleasing id& ar1 = strong_a;
+ const __autoreleasing id& ar2 = autoreleasing_a;
+ const __autoreleasing id& ar3 = unsafe_unretained_a;
+ const __autoreleasing id& ar4 = weak_a;
+}
+
+// rdar://9790531
+void f9790531(void *inClientData); // expected-note {{candidate function not viable: cannot implicitly convert argument of type 'MixerEQGraphTestDelegate *const __strong' to 'void *' for 1st argument under ARC}}
+void f9790531_1(struct S*inClientData); // expected-note {{candidate function not viable}}
+void f9790531_2(char * inClientData); // expected-note {{candidate function not viable}}
+
+@class UIApplication;
+
+@interface MixerEQGraphTestDelegate
+- (void)applicationDidFinishLaunching;
+@end
+
+@implementation MixerEQGraphTestDelegate
+- (void)applicationDidFinishLaunching {
+ f9790531(self); // expected-error {{no matching function for call to 'f9790531'}}
+ f9790531_1(self); // expected-error {{no matching function for call to 'f9790531_1'}}
+ f9790531_2(self); // expected-error {{no matching function for call to 'f9790531_2'}}
+}
+@end
+
+class rdar10142572 {
+ id f() __attribute__((ns_returns_retained));
+ id g(); // expected-note{{previous declaration}}
+};
+
+id rdar10142572::f() { return 0; } // okay: merged down
+id __attribute__((ns_returns_retained)) rdar10142572::g() { return 0; } // expected-error{{function declared with the ns_returns_retained attribute was previously declared without the ns_returns_retained attribute}}
diff --git a/clang/test/SemaObjCXX/arc-ppe.mm b/clang/test/SemaObjCXX/arc-ppe.mm
new file mode 100644
index 0000000..c9ff811
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-ppe.mm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-arc %s
+
+// Make sure the ARC auto-deduction of id* in unevaluated contexts
+// works correctly in cases where we can't immediately tell whether the
+// context is unevaluated.
+
+namespace std {
+ class type_info;
+}
+
+int& NP(void*);
+void test1() { (void)typeid(NP((void*)(id*)0)); }
+
+class Poly { virtual ~Poly(); };
+Poly& P(void*);
+void test2() { (void)typeid(P((void*)(id*)0)); } // expected-error {{pointer to non-const type 'id'}}
diff --git a/clang/test/SemaObjCXX/arc-system-header.mm b/clang/test/SemaObjCXX/arc-system-header.mm
new file mode 100644
index 0000000..107b5b5
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-system-header.mm
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fobjc-arc -isystem %S/Inputs %s -verify
+
+#include <arc-system-header.h>
+
+void f(A* a) {
+ a->data.void_ptr = 0;
+ a->data.a_b.b = 0; // expected-error{{'a_b' is unavailable: this system field has retaining ownership}}
+}
+// Silly location below
+// expected-note{{declaration has been explicitly marked unavailable here}}
diff --git a/clang/test/SemaObjCXX/arc-templates.mm b/clang/test/SemaObjCXX/arc-templates.mm
new file mode 100644
index 0000000..9eca846
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-templates.mm
@@ -0,0 +1,268 @@
+// RUN: %clang_cc1 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify -fblocks %s
+
+@interface A
+@end
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+// Instantiation for reference/pointer types that will get lifetime
+// adjustments.
+template<typename T>
+struct X0 {
+ typedef T* pointer; // okay: ends up being strong.
+ typedef T& reference; // okay: ends up being strong
+};
+
+void test_X0() {
+ X0<id> x0id;
+ X0<A*> x0a;
+ X0<__strong A*> x0sa;
+
+ id __strong *ptr;
+ id __strong val;
+ X0<__strong id>::pointer &ptr_ref = ptr;
+ X0<__strong id>::reference ref = val;
+}
+
+int check_infer_strong[is_same<id, __strong id>::value? 1 : -1];
+
+// Check template argument deduction (e.g., for specialization) using
+// lifetime qualifiers.
+template<typename T>
+struct is_pointer_strong {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_pointer_strong<__strong T*> {
+ static const bool value = true;
+};
+
+int check_ptr_strong1[is_pointer_strong<__strong id*>::value? 1 : -1];
+int check_ptr_strong2[is_pointer_strong<__weak id*>::value? -1 : 1];
+int check_ptr_strong3[is_pointer_strong<__autoreleasing id*>::value? -1 : 1];
+int check_ptr_strong4[is_pointer_strong<__unsafe_unretained id*>::value? -1 : 1];
+int check_ptr_strong5[is_pointer_strong<id>::value? -1 : 1];
+
+// Check substitution into lifetime-qualified dependent types.
+template<typename T>
+struct make_strong_pointer {
+ typedef __strong T *type;
+};
+
+template<typename T>
+struct make_strong_pointer<__weak T> {
+ typedef __strong T *type;
+};
+
+template<typename T>
+struct make_strong_pointer<__autoreleasing T> {
+ typedef __strong T *type;
+};
+
+template<typename T>
+struct make_strong_pointer<__unsafe_unretained T> {
+ typedef __strong T *type;
+};
+
+// Adding qualifiers
+int check_make_strong1[is_same<make_strong_pointer<id>::type, __strong id *>::value ? 1 : -1];
+int check_make_strong2[is_same<make_strong_pointer<A*>::type, A* __strong *>::value ? 1 : -1];
+
+// Adding redundant qualifiers
+int check_make_strong3[is_same<make_strong_pointer<__strong id>::type, __strong id *>::value ? 1 : -1];
+int check_make_strong4[is_same<make_strong_pointer<__strong A*>::type, A* __strong *>::value ? 1 : -1];
+
+// Adding nonsensical qualifiers.
+int check_make_strong5[is_same<make_strong_pointer<int>::type, int *>::value ? 1 : -1];
+int check_make_strong6[is_same<make_strong_pointer<__weak id>::type, __strong id *>::value ? 1 : -1];
+
+template<typename T>
+struct make_weak {
+ typedef __weak T type;
+};
+
+int check_make_weak0[is_same<make_weak<id>::type, __weak id>::value? 1 : -1];
+int check_make_weak1[is_same<make_weak<__strong id>::type, __weak id>::value? 1 : -1];
+int check_make_weak2[is_same<make_weak<__autoreleasing id>::type, __weak id>::value? 1 : -1];
+
+template<typename T>
+struct make_weak_fail {
+ typedef T T_type;
+ typedef __weak T_type type; // expected-error{{the type 'T_type' (aka '__weak id') is already explicitly ownership-qualified}} \
+ // expected-error{{the type 'T_type' (aka '__strong id') is already explicitly ownership-qualified}}
+};
+
+int check_make_weak_fail0[is_same<make_weak_fail<__weak id>::type, __weak id>::value? 1 : -1]; // expected-note{{in instantiation of template class 'make_weak_fail<__weak id>' requested here}}
+
+int check_make_weak_fail1[is_same<make_weak_fail<id>::type, __weak id>::value? -1 : 1]; // expected-note{{in instantiation of template class 'make_weak_fail<id>' requested here}}
+
+// Check template argument deduction from function templates.
+template<typename T> struct identity { };
+
+template<typename T> identity<T> accept_strong_ptr(__strong T*);
+template<typename T> identity<T> accept_strong_ref(__strong T&);
+
+template<typename T> identity<T> accept_any_ptr(T*);
+template<typename T> identity<T> accept_any_ref(T&);
+
+void test_func_deduction_id() {
+ __strong id *sip;
+ __weak id *wip;
+ __autoreleasing id *aip;
+ __unsafe_unretained id *uip;
+
+ identity<id> res1 = accept_strong_ptr(sip);
+ identity<__strong id> res2 = accept_any_ptr(sip);
+
+ __strong id si;
+ __weak id wi;
+ __autoreleasing id ai;
+ __unsafe_unretained id ui;
+ identity<id> res3 = accept_strong_ref(si);
+ identity<__strong id> res4 = accept_any_ref(si);
+ identity<__weak id> res5 = accept_any_ref(wi);
+ identity<__autoreleasing id> res6 = accept_any_ref(ai);
+ identity<__unsafe_unretained id> res7 = accept_any_ref(ui);
+}
+
+void test_func_deduction_A() {
+ __strong A * *sip;
+ __weak A * *wip;
+ __autoreleasing A * *aip;
+ __unsafe_unretained A * *uip;
+
+ identity<A *> res1 = accept_strong_ptr(sip);
+ identity<__strong A *> res2 = accept_any_ptr(sip);
+
+ __strong A * si;
+ __weak A * wi;
+ __autoreleasing A * ai;
+ __unsafe_unretained A * ui;
+ identity<A *> res3 = accept_strong_ref(si);
+ identity<__strong A *> res4 = accept_any_ref(si);
+ identity<__weak A *> res5 = accept_any_ref(wi);
+ identity<__autoreleasing A *> res6 = accept_any_ref(ai);
+ identity<__unsafe_unretained A *> res7 = accept_any_ref(ui);
+}
+
+// Test partial ordering (qualified vs. non-qualified).
+template<typename T>
+struct classify_pointer_pointer {
+ static const unsigned value = 0;
+};
+
+template<typename T>
+struct classify_pointer_pointer<T*> {
+ static const unsigned value = 1;
+};
+
+template<typename T>
+struct classify_pointer_pointer<__strong T*> {
+ static const unsigned value = 2;
+};
+
+template<typename T>
+struct classify_pointer_pointer<__weak T*> {
+ static const unsigned value = 3;
+};
+
+template<typename T>
+struct classify_pointer_pointer<T&> {
+ static const unsigned value = 4;
+};
+
+template<typename T>
+struct classify_pointer_pointer<__strong T&> {
+ static const unsigned value = 5;
+};
+
+template<typename T>
+struct classify_pointer_pointer<__weak T&> {
+ static const unsigned value = 6;
+};
+
+int classify_ptr1[classify_pointer_pointer<int>::value == 0? 1 : -1];
+int classify_ptr2[classify_pointer_pointer<int *>::value == 1? 1 : -1];
+int classify_ptr3[classify_pointer_pointer<id __strong *>::value == 2? 1 : -1];
+int classify_ptr4[classify_pointer_pointer<id __weak *>::value == 3? 1 : -1];
+int classify_ptr5[classify_pointer_pointer<int&>::value == 4? 1 : -1];
+int classify_ptr6[classify_pointer_pointer<id __strong&>::value == 5? 1 : -1];
+int classify_ptr7[classify_pointer_pointer<id __weak&>::value == 6? 1 : -1];
+int classify_ptr8[classify_pointer_pointer<id __autoreleasing&>::value == 4? 1 : -1];
+int classify_ptr9[classify_pointer_pointer<id __unsafe_unretained&>::value == 4? 1 : -1];
+int classify_ptr10[classify_pointer_pointer<id __autoreleasing *>::value == 1? 1 : -1];
+int classify_ptr11[classify_pointer_pointer<id __unsafe_unretained *>::value == 1? 1 : -1];
+int classify_ptr12[classify_pointer_pointer<int *>::value == 1? 1 : -1];
+int classify_ptr13[classify_pointer_pointer<A * __strong *>::value == 2? 1 : -1];
+int classify_ptr14[classify_pointer_pointer<A * __weak *>::value == 3? 1 : -1];
+int classify_ptr15[classify_pointer_pointer<int&>::value == 4? 1 : -1];
+int classify_ptr16[classify_pointer_pointer<A * __strong&>::value == 5? 1 : -1];
+int classify_ptr17[classify_pointer_pointer<A * __weak&>::value == 6? 1 : -1];
+int classify_ptr18[classify_pointer_pointer<A * __autoreleasing&>::value == 4? 1 : -1];
+int classify_ptr19[classify_pointer_pointer<A * __unsafe_unretained&>::value == 4? 1 : -1];
+int classify_ptr20[classify_pointer_pointer<A * __autoreleasing *>::value == 1? 1 : -1];
+int classify_ptr21[classify_pointer_pointer<A * __unsafe_unretained *>::value == 1? 1 : -1];
+
+template<typename T> int& qual_vs_unqual_ptr(__strong T*);
+template<typename T> double& qual_vs_unqual_ptr(__weak T*);
+template<typename T> float& qual_vs_unqual_ptr(T*);
+template<typename T> int& qual_vs_unqual_ref(__strong T&);
+template<typename T> double& qual_vs_unqual_ref(__weak T&);
+template<typename T> float& qual_vs_unqual_ref(T&);
+
+void test_qual_vs_unqual_id() {
+ __strong id *sip;
+ __weak id *wip;
+ __autoreleasing id *aip;
+ __unsafe_unretained id *uip;
+
+ int &ir1 = qual_vs_unqual_ptr(sip);
+ double &dr1 = qual_vs_unqual_ptr(wip);
+ float &fr1 = qual_vs_unqual_ptr(aip);
+ float &fr2 = qual_vs_unqual_ptr(uip);
+
+ int &ir2 = qual_vs_unqual_ref(*sip);
+ double &dr2 = qual_vs_unqual_ref(*wip);
+ float &fr3 = qual_vs_unqual_ref(*aip);
+ float &fr4 = qual_vs_unqual_ref(*uip);
+}
+
+void test_qual_vs_unqual_a() {
+ __strong A * *sap;
+ __weak A * *wap;
+ __autoreleasing A * *aap;
+ __unsafe_unretained A * *uap;
+
+ int &ir1 = qual_vs_unqual_ptr(sap);
+ double &dr1 = qual_vs_unqual_ptr(wap);
+ float &fr1 = qual_vs_unqual_ptr(aap);
+ float &fr2 = qual_vs_unqual_ptr(uap);
+
+ int &ir2 = qual_vs_unqual_ref(*sap);
+ double &dr2 = qual_vs_unqual_ref(*wap);
+ float &fr3 = qual_vs_unqual_ref(*aap);
+ float &fr4 = qual_vs_unqual_ref(*uap);
+}
+
+namespace rdar9828157 {
+ // Template argument deduction involving lifetime qualifiers and
+ // non-lifetime types.
+ class A { };
+
+ template<typename T> float& f(T&);
+ template<typename T> int& f(__strong T&);
+ template<typename T> double& f(__weak T&);
+
+ void test_f(A* ap) {
+ float &fr = (f)(ap);
+ }
+}
diff --git a/clang/test/SemaObjCXX/arc-type-conversion.mm b/clang/test/SemaObjCXX/arc-type-conversion.mm
new file mode 100644
index 0000000..fd42513
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-type-conversion.mm
@@ -0,0 +1,218 @@
+// RUN: %clang_cc1 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify -fblocks %s
+// rdar://8843600
+
+void * cvt(id arg) // expected-note{{candidate function not viable: cannot convert argument of incomplete type 'void *' to '__strong id'}}
+{
+ void* voidp_val;
+ (void)(int*)arg; // expected-error {{cast of an Objective-C pointer to 'int *' is disallowed with ARC}}
+ (void)(id)arg;
+ (void)(__autoreleasing id*)arg; // expected-error{{C-style cast from 'id' to '__autoreleasing id *' casts away qualifiers}}
+ (void)(id*)arg; // expected-error{{C-style cast from 'id' to '__strong id *' casts away qualifiers}}
+
+ (void)(__autoreleasing id**)voidp_val;
+ (void)(void*)voidp_val;
+ (void)(void**)arg; // expected-error {{cast of an Objective-C pointer to 'void **' is disallowed}}
+ cvt((void*)arg); // expected-error {{no matching function for call to 'cvt'}}
+ cvt(0);
+ (void)(__strong id**)(0);
+
+ // FIXME: Diagnostic could be better here.
+ return arg; // expected-error{{cannot initialize return object of type 'void *' with an lvalue of type '__strong id'}}
+}
+
+// rdar://8898937
+namespace rdar8898937 {
+
+typedef void (^dispatch_block_t)(void);
+
+void dispatch_once(dispatch_block_t block);
+static void _dispatch_once(dispatch_block_t block)
+{
+ dispatch_once(block);
+}
+
+}
+
+void static_casts(id arg) {
+ void* voidp_val;
+ (void)static_cast<int*>(arg); // expected-error {{cannot cast from type 'id' to pointer type 'int *'}}
+ (void)static_cast<id>(arg);
+ (void)static_cast<__autoreleasing id*>(arg); // expected-error{{cannot cast from type 'id' to pointer type '__autoreleasing id *'}}
+ (void)static_cast<id*>(arg); // expected-error {{cannot cast from type 'id' to pointer type '__strong id *'}}
+
+ (void)static_cast<__autoreleasing id**>(voidp_val);
+ (void)static_cast<void*>(voidp_val);
+ (void)static_cast<void**>(arg); // expected-error {{cannot cast from type 'id' to pointer type 'void **'}}
+ (void)static_cast<__strong id**>(0);
+
+ __strong id *idp;
+ (void)static_cast<__autoreleasing id*>(idp); // expected-error{{static_cast from '__strong id *' to '__autoreleasing id *' is not allowed}}
+ (void)static_cast<__weak id*>(idp); // expected-error{{static_cast from '__strong id *' to '__weak id *' is not allowed}}
+}
+
+void test_const_cast(__strong id *sip, __weak id *wip,
+ const __strong id *csip, __weak const id *cwip) {
+ // Cannot use const_cast to cast between ownership qualifications or
+ // add/remove ownership qualifications.
+ (void)const_cast<__strong id *>(wip); // expected-error{{is not allowed}}
+ (void)const_cast<__weak id *>(sip); // expected-error{{is not allowed}}
+
+ // It's acceptable to cast away constness.
+ (void)const_cast<__strong id *>(csip);
+ (void)const_cast<__weak id *>(cwip);
+}
+
+void test_reinterpret_cast(__strong id *sip, __weak id *wip,
+ const __strong id *csip, __weak const id *cwip) {
+ // Okay to reinterpret_cast to add/remove/change ownership
+ // qualifications.
+ (void)reinterpret_cast<__strong id *>(wip);
+ (void)reinterpret_cast<__weak id *>(sip);
+
+ // Not allowed to cast away constness
+ (void)reinterpret_cast<__strong id *>(csip); // expected-error{{reinterpret_cast from '__strong id const *' to '__strong id *' casts away qualifiers}}
+ (void)reinterpret_cast<__weak id *>(cwip); // expected-error{{reinterpret_cast from '__weak id const *' to '__weak id *' casts away qualifiers}}
+ (void)reinterpret_cast<__weak id *>(csip); // expected-error{{reinterpret_cast from '__strong id const *' to '__weak id *' casts away qualifiers}}
+ (void)reinterpret_cast<__strong id *>(cwip); // expected-error{{reinterpret_cast from '__weak id const *' to '__strong id *' casts away qualifiers}}
+}
+
+void test_cstyle_cast(__strong id *sip, __weak id *wip,
+ const __strong id *csip, __weak const id *cwip) {
+ // C-style casts aren't allowed to change Objective-C ownership
+ // qualifiers (beyond what the normal implicit conversion allows).
+
+ (void)(__strong id *)wip; // expected-error{{C-style cast from '__weak id *' to '__strong id *' casts away qualifiers}}
+ (void)(__strong id *)cwip; // expected-error{{C-style cast from '__weak id const *' to '__strong id *' casts away qualifiers}}
+ (void)(__weak id *)sip; // expected-error{{C-style cast from '__strong id *' to '__weak id *' casts away qualifiers}}
+ (void)(__weak id *)csip; // expected-error{{C-style cast from '__strong id const *' to '__weak id *' casts away qualifiers}}
+
+ (void)(__strong const id *)wip; // expected-error{{C-style cast from '__weak id *' to '__strong id const *' casts away qualifiers}}
+ (void)(__strong const id *)cwip; // expected-error{{C-style cast from '__weak id const *' to '__strong id const *' casts away qualifiers}}
+ (void)(__weak const id *)sip; // expected-error{{C-style cast from '__strong id *' to '__weak id const *' casts away qualifiers}}
+ (void)(__weak const id *)csip; // expected-error{{C-style cast from '__strong id const *' to '__weak id const *' casts away qualifiers}}
+ (void)(__autoreleasing const id *)wip; // expected-error{{C-style cast from '__weak id *' to '__autoreleasing id const *' casts away qualifiers}}
+ (void)(__autoreleasing const id *)cwip; // expected-error{{C-style cast from '__weak id const *' to '__autoreleasing id const *' casts away qualifiers}}
+ (void)(__autoreleasing const id *)sip;
+ (void)(__autoreleasing const id *)csip;
+}
+
+void test_functional_cast(__strong id *sip, __weak id *wip,
+ __autoreleasing id *aip) {
+ // Functional casts aren't allowed to change Objective-C ownership
+ // qualifiers (beyond what the normal implicit conversion allows).
+
+ typedef __strong id *strong_id_pointer;
+ typedef __weak id *weak_id_pointer;
+ typedef __autoreleasing id *autoreleasing_id_pointer;
+
+ typedef const __strong id *const_strong_id_pointer;
+ typedef const __weak id *const_weak_id_pointer;
+ typedef const __autoreleasing id *const_autoreleasing_id_pointer;
+
+ (void)strong_id_pointer(wip); // expected-error{{functional-style cast from '__weak id *' to 'strong_id_pointer' (aka '__strong id *') casts away qualifiers}}
+ (void)weak_id_pointer(sip); // expected-error{{functional-style cast from '__strong id *' to 'weak_id_pointer' (aka '__weak id *') casts away qualifiers}}
+ (void)autoreleasing_id_pointer(sip); // expected-error{{functional-style cast from '__strong id *' to 'autoreleasing_id_pointer' (aka '__autoreleasing id *') casts away qualifiers}}
+ (void)autoreleasing_id_pointer(wip); // expected-error{{functional-style cast from '__weak id *' to 'autoreleasing_id_pointer' (aka '__autoreleasing id *') casts away qualifiers}}
+ (void)const_strong_id_pointer(wip); // expected-error{{functional-style cast from '__weak id *' to 'const_strong_id_pointer' (aka 'const __strong id *') casts away qualifiers}}
+ (void)const_weak_id_pointer(sip); // expected-error{{functional-style cast from '__strong id *' to 'const_weak_id_pointer' (aka 'const __weak id *') casts away qualifiers}}
+ (void)const_autoreleasing_id_pointer(sip);
+ (void)const_autoreleasing_id_pointer(aip);
+ (void)const_autoreleasing_id_pointer(wip); // expected-error{{functional-style cast from '__weak id *' to 'const_autoreleasing_id_pointer' (aka 'const __autoreleasing id *') casts away qualifiers}}
+}
+
+void test_unsafe_unretained(__strong id *sip, __weak id *wip,
+ __autoreleasing id *aip,
+ __unsafe_unretained id *uip,
+ const __unsafe_unretained id *cuip) {
+ uip = sip; // expected-error{{assigning to '__unsafe_unretained id *' from incompatible type '__strong id *'}}
+ uip = wip; // expected-error{{assigning to '__unsafe_unretained id *' from incompatible type '__weak id *'}}
+ uip = aip; // expected-error{{assigning to '__unsafe_unretained id *' from incompatible type '__autoreleasing id *'}}
+
+ cuip = sip;
+ cuip = wip; // expected-error{{assigning to '__unsafe_unretained id const *' from incompatible type '__weak id *'}}
+ cuip = aip;
+}
+
+void to_void(__strong id *sip, __weak id *wip,
+ __autoreleasing id *aip,
+ __unsafe_unretained id *uip) {
+ void *vp1 = sip;
+ void *vp2 = wip;
+ void *vp3 = aip;
+ void *vp4 = uip;
+ (void)(void*)sip;
+ (void)(void*)wip;
+ (void)(void*)aip;
+ (void)(void*)uip;
+ (void)static_cast<void*>(sip);
+ (void)static_cast<void*>(wip);
+ (void)static_cast<void*>(aip);
+ (void)static_cast<void*>(uip);
+ (void)reinterpret_cast<void*>(sip);
+ (void)reinterpret_cast<void*>(wip);
+ (void)reinterpret_cast<void*>(aip);
+ (void)reinterpret_cast<void*>(uip);
+
+ (void)(void*)&sip;
+ (void)(void*)&wip;
+ (void)(void*)&aip;
+ (void)(void*)&uip;
+ (void)static_cast<void*>(&sip);
+ (void)static_cast<void*>(&wip);
+ (void)static_cast<void*>(&aip);
+ (void)static_cast<void*>(&uip);
+ (void)reinterpret_cast<void*>(&sip);
+ (void)reinterpret_cast<void*>(&wip);
+ (void)reinterpret_cast<void*>(&aip);
+ (void)reinterpret_cast<void*>(&uip);
+}
+
+void from_void(void *vp) {
+ __strong id *sip = (__strong id *)vp;
+ __weak id *wip = (__weak id *)vp;
+ __autoreleasing id *aip = (__autoreleasing id *)vp;
+ __unsafe_unretained id *uip = (__unsafe_unretained id *)vp;
+ __strong id *sip2 = static_cast<__strong id *>(vp);
+ __weak id *wip2 = static_cast<__weak id *>(vp);
+ __autoreleasing id *aip2 = static_cast<__autoreleasing id *>(vp);
+ __unsafe_unretained id *uip2 = static_cast<__unsafe_unretained id *>(vp);
+ __strong id *sip3 = reinterpret_cast<__strong id *>(vp);
+ __weak id *wip3 = reinterpret_cast<__weak id *>(vp);
+ __autoreleasing id *aip3 = reinterpret_cast<__autoreleasing id *>(vp);
+ __unsafe_unretained id *uip3 = reinterpret_cast<__unsafe_unretained id *>(vp);
+
+ __strong id **sipp = (__strong id **)vp;
+ __weak id **wipp = (__weak id **)vp;
+ __autoreleasing id **aipp = (__autoreleasing id **)vp;
+ __unsafe_unretained id **uipp = (__unsafe_unretained id **)vp;
+
+ sip = vp; // expected-error{{assigning to '__strong id *' from incompatible type 'void *'}}
+ wip = vp; // expected-error{{assigning to '__weak id *' from incompatible type 'void *'}}
+ aip = vp; // expected-error{{assigning to '__autoreleasing id *' from incompatible type 'void *'}}
+ uip = vp; // expected-error{{assigning to '__unsafe_unretained id *' from incompatible type 'void *'}}
+}
+
+typedef void (^Block)();
+typedef void (^Block_strong)() __strong;
+typedef void (^Block_autoreleasing)() __autoreleasing;
+
+@class NSString;
+
+void ownership_transfer_in_cast(void *vp, Block *pblk) {
+ __strong NSString **sip2 = static_cast<NSString **>(static_cast<__strong id *>(vp));
+ __strong NSString **&si2pref = static_cast<NSString **&>(sip2);
+ __weak NSString **wip2 = static_cast<NSString **>(static_cast<__weak id *>(vp));
+ __autoreleasing id *aip2 = static_cast<id *>(static_cast<__autoreleasing id *>(vp));
+ __unsafe_unretained id *uip2 = static_cast<id *>(static_cast<__unsafe_unretained id *>(vp));
+ __strong id *sip3 = reinterpret_cast<id *>(reinterpret_cast<__strong id *>(vp));
+ __weak id *wip3 = reinterpret_cast<id *>(reinterpret_cast<__weak id *>(vp));
+ __autoreleasing id *aip3 = reinterpret_cast<id *>(reinterpret_cast<__autoreleasing id *>(vp));
+ __unsafe_unretained id *uip3 = reinterpret_cast<id *>(reinterpret_cast<__unsafe_unretained id *>(vp));
+
+ Block_strong blk_strong1;
+ Block_strong blk_strong2 = static_cast<Block>(blk_strong1);
+ Block_autoreleasing *blk_auto = static_cast<Block*>(pblk);
+}
+
+// Make sure we don't crash.
+void writeback_test(NSString & &) {} // expected-error {{type name declared as a reference to a reference}}
diff --git a/clang/test/SemaObjCXX/arc-type-traits.mm b/clang/test/SemaObjCXX/arc-type-traits.mm
new file mode 100644
index 0000000..9877870
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-type-traits.mm
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify %s
+
+// Check the results of the various type-trait query functions on
+// lifetime-qualified types in ARC.
+
+#define JOIN3(X,Y) X ## Y
+#define JOIN2(X,Y) JOIN3(X,Y)
+#define JOIN(X,Y) JOIN2(X,Y)
+
+#define TRAIT_IS_TRUE(Trait, Type) char JOIN2(Trait,__LINE__)[Trait(Type)? 1 : -1]
+#define TRAIT_IS_FALSE(Trait, Type) char JOIN2(Trait,__LINE__)[Trait(Type)? -1 : 1]
+
+// __has_nothrow_assign
+TRAIT_IS_TRUE(__has_nothrow_assign, __strong id);
+TRAIT_IS_TRUE(__has_nothrow_assign, __weak id);
+TRAIT_IS_TRUE(__has_nothrow_assign, __autoreleasing id);
+TRAIT_IS_TRUE(__has_nothrow_assign, __unsafe_unretained id);
+
+// __has_nothrow_copy
+TRAIT_IS_TRUE(__has_nothrow_copy, __strong id);
+TRAIT_IS_TRUE(__has_nothrow_copy, __weak id);
+TRAIT_IS_TRUE(__has_nothrow_copy, __autoreleasing id);
+TRAIT_IS_TRUE(__has_nothrow_copy, __unsafe_unretained id);
+
+// __has_nothrow_constructor
+TRAIT_IS_TRUE(__has_nothrow_constructor, __strong id);
+TRAIT_IS_TRUE(__has_nothrow_constructor, __weak id);
+TRAIT_IS_TRUE(__has_nothrow_constructor, __autoreleasing id);
+TRAIT_IS_TRUE(__has_nothrow_constructor, __unsafe_unretained id);
+
+// __has_trivial_assign
+TRAIT_IS_FALSE(__has_trivial_assign, __strong id);
+TRAIT_IS_FALSE(__has_trivial_assign, __weak id);
+TRAIT_IS_FALSE(__has_trivial_assign, __autoreleasing id);
+TRAIT_IS_TRUE(__has_trivial_assign, __unsafe_unretained id);
+
+// __has_trivial_copy
+TRAIT_IS_FALSE(__has_trivial_copy, __strong id);
+TRAIT_IS_FALSE(__has_trivial_copy, __weak id);
+TRAIT_IS_FALSE(__has_trivial_copy, __autoreleasing id);
+TRAIT_IS_TRUE(__has_trivial_copy, __unsafe_unretained id);
+
+// __has_trivial_constructor
+TRAIT_IS_FALSE(__has_trivial_constructor, __strong id);
+TRAIT_IS_FALSE(__has_trivial_constructor, __weak id);
+TRAIT_IS_FALSE(__has_trivial_constructor, __autoreleasing id);
+TRAIT_IS_TRUE(__has_trivial_constructor, __unsafe_unretained id);
+
+// __has_trivial_destructor
+TRAIT_IS_FALSE(__has_trivial_destructor, __strong id);
+TRAIT_IS_FALSE(__has_trivial_destructor, __weak id);
+TRAIT_IS_TRUE(__has_trivial_destructor, __autoreleasing id);
+TRAIT_IS_TRUE(__has_trivial_destructor, __unsafe_unretained id);
+
+// __is_literal
+TRAIT_IS_TRUE(__is_literal, __strong id);
+TRAIT_IS_TRUE(__is_literal, __weak id);
+TRAIT_IS_TRUE(__is_literal, __autoreleasing id);
+TRAIT_IS_TRUE(__is_literal, __unsafe_unretained id);
+
+// __is_literal_type
+TRAIT_IS_TRUE(__is_literal_type, __strong id);
+TRAIT_IS_TRUE(__is_literal_type, __weak id);
+TRAIT_IS_TRUE(__is_literal_type, __autoreleasing id);
+TRAIT_IS_TRUE(__is_literal_type, __unsafe_unretained id);
+
+// __is_pod
+TRAIT_IS_FALSE(__is_pod, __strong id);
+TRAIT_IS_FALSE(__is_pod, __weak id);
+TRAIT_IS_FALSE(__is_pod, __autoreleasing id);
+TRAIT_IS_TRUE(__is_pod, __unsafe_unretained id);
+
+// __is_trivial
+TRAIT_IS_FALSE(__is_trivial, __strong id);
+TRAIT_IS_FALSE(__is_trivial, __weak id);
+TRAIT_IS_FALSE(__is_trivial, __autoreleasing id);
+TRAIT_IS_TRUE(__is_trivial, __unsafe_unretained id);
+
+// __is_scalar
+TRAIT_IS_FALSE(__is_scalar, __strong id);
+TRAIT_IS_FALSE(__is_scalar, __weak id);
+TRAIT_IS_FALSE(__is_scalar, __autoreleasing id);
+TRAIT_IS_TRUE(__is_scalar, __unsafe_unretained id);
+
+// __is_standard_layout
+TRAIT_IS_TRUE(__is_standard_layout, __strong id);
+TRAIT_IS_TRUE(__is_standard_layout, __weak id);
+TRAIT_IS_TRUE(__is_standard_layout, __autoreleasing id);
+TRAIT_IS_TRUE(__is_standard_layout, __unsafe_unretained id);
+
diff --git a/clang/test/SemaObjCXX/arc-unavailable-for-weakref.mm b/clang/test/SemaObjCXX/arc-unavailable-for-weakref.mm
new file mode 100644
index 0000000..2a80aeb
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-unavailable-for-weakref.mm
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify %s
+// rdar://9693477
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface NSOptOut1072 // expected-note {{class is declared here}}
+@end
+
+@interface sub : NSOptOut1072 @end // expected-note 2 {{class is declared here}}
+
+int main() {
+ __weak sub *w2; // expected-error {{class is incompatible with __weak references}}
+
+ __weak NSOptOut1072 *ns1; // expected-error {{class is incompatible with __weak references}}
+
+ id obj;
+
+ ns1 = (__weak sub *)obj; // expected-error {{assignment of a weak-unavailable object to a __weak object}} \
+ // expected-error {{class is incompatible with __weak references}} \
+ // expected-error {{explicit ownership qualifier on cast result has no effect}}
+}
+
+// rdar://9732636
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface NOWEAK
++ (id) new;
+@end
+
+NOWEAK * Test1() {
+ NOWEAK * strong1 = [NOWEAK new];
+ __weak id weak1;
+ weak1 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
+
+ __weak id weak2 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
+ return (__weak id)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK *' to a __weak object of type '__weak id'}} \
+ // expected-error {{explicit ownership qualifier on cast result has no effect}}
+}
+
+@protocol P @end
+@protocol P1 @end
+
+NOWEAK<P, P1> * Test2() {
+ NOWEAK<P, P1> * strong1 = 0;
+ __weak id<P> weak1;
+ weak1 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
+
+ __weak id<P> weak2 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
+ return (__weak id<P, P1>)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK<P,P1> *' to a __weak object of type '__weak id<P,P1>'}} \
+ // expected-error {{explicit ownership qualifier on cast result has no effect}}
+}
+
diff --git a/clang/test/SemaObjCXX/arc-unbridged-cast.mm b/clang/test/SemaObjCXX/arc-unbridged-cast.mm
new file mode 100644
index 0000000..0b3ba07
--- /dev/null
+++ b/clang/test/SemaObjCXX/arc-unbridged-cast.mm
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
+
+typedef const struct __CFString * CFStringRef;
+typedef const void * CFTypeRef;
+extern "C" CFTypeRef CFBridgingRetain(id X);
+extern "C" id CFBridgingRelease(CFTypeRef);
+
+
+@interface Object
+@property CFStringRef property;
+- (CFStringRef) implicitProperty;
+- (CFStringRef) newString;
+- (CFStringRef) makeString;
+@end
+
+extern Object *object;
+
+// rdar://9744349
+id test0(void) {
+ id p1 = (id)[object property];
+ id p2 = (__bridge_transfer id)[object property];
+ id p3 = (__bridge id)[object property];
+ return (id) object.property;
+}
+
+// rdar://10140692
+CFStringRef unauditedString(void);
+CFStringRef plusOneString(void) __attribute__((cf_returns_retained));
+
+#pragma clang arc_cf_code_audited begin
+CFStringRef auditedString(void);
+CFStringRef auditedCreateString(void);
+#pragma clang arc_cf_code_audited end
+
+void test1(int cond) {
+ id x;
+ x = (id) auditedString();
+ x = (id) (cond ? auditedString() : (void*) 0);
+ x = (id) (cond ? (void*) 0 : auditedString());
+ x = (id) (cond ? (CFStringRef) @"help" : auditedString());
+
+ x = (id) unauditedString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? unauditedString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+
+ x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+
+ x = (id) [object property];
+ x = (id) (cond ? [object property] : (void*) 0);
+ x = (id) (cond ? (void*) 0 : [object property]);
+ x = (id) (cond ? (CFStringRef) @"help" : [object property]);
+
+ x = (id) object.property;
+ x = (id) (cond ? object.property : (void*) 0);
+ x = (id) (cond ? (void*) 0 : object.property);
+ x = (id) (cond ? (CFStringRef) @"help" : object.property);
+
+ x = (id) object.implicitProperty;
+ x = (id) (cond ? object.implicitProperty : (void*) 0);
+ x = (id) (cond ? (void*) 0 : object.implicitProperty);
+ x = (id) (cond ? (CFStringRef) @"help" : object.implicitProperty);
+
+ x = (id) [object makeString];
+ x = (id) (cond ? [object makeString] : (void*) 0);
+ x = (id) (cond ? (void*) 0 : [object makeString]);
+ x = (id) (cond ? (CFStringRef) @"help" : [object makeString]);
+
+ x = (id) [object newString];
+ x = (id) (cond ? [object newString] : (void*) 0);
+ x = (id) (cond ? (void*) 0 : [object newString]);
+ x = (id) (cond ? (CFStringRef) @"help" : [object newString]); // a bit questionable
+}
+
+// rdar://problem/10246264
+@interface CFTaker
+- (void) takeOrdinary: (CFStringRef) arg;
+- (void) takeVariadic: (int) n, ...;
+- (void) takeConsumed: (CFStringRef __attribute__((cf_consumed))) arg;
+@end
+void testCFTaker(CFTaker *taker, id string) {
+ [taker takeOrdinary: (CFStringRef) string];
+ [taker takeVariadic: 1, (CFStringRef) string];
+ [taker takeConsumed: (CFStringRef) string]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+}
+
+void takeCFOrdinaryUnaudited(CFStringRef arg);
+void takeCFVariadicUnaudited(int n, ...);
+void takeCFConsumedUnaudited(CFStringRef __attribute__((cf_consumed)) arg);
+#pragma clang arc_cf_code_audited begin
+void takeCFOrdinaryAudited(CFStringRef arg);
+void takeCFVariadicAudited(int n, ...);
+void takeCFConsumedAudited(CFStringRef __attribute__((cf_consumed)) arg);
+#pragma clang arc_cf_code_audited end
+
+void testTakerFunctions(id string) {
+ takeCFOrdinaryUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFVariadicUnaudited(1, (CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFConsumedUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+
+ void (*taker)(CFStringRef) = 0;
+ taker((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+
+ takeCFOrdinaryAudited((CFStringRef) string);
+ takeCFVariadicAudited(1, (CFStringRef) string);
+ takeCFConsumedAudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+}
diff --git a/clang/test/SemaObjCXX/argument-dependent-lookup.mm b/clang/test/SemaObjCXX/argument-dependent-lookup.mm
new file mode 100644
index 0000000..a25cc68
--- /dev/null
+++ b/clang/test/SemaObjCXX/argument-dependent-lookup.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/9142559>: For the purposes of Argument-Dependent
+// Lookup, Objective-C classes are considered to be in the global
+// namespace.
+
+@interface NSFoo
+@end
+
+template<typename T>
+void f(T t) {
+ g(t);
+}
+
+void g(NSFoo*);
+
+void test(NSFoo *foo) {
+ f(foo);
+}
diff --git a/clang/test/SemaObjCXX/blocks.mm b/clang/test/SemaObjCXX/blocks.mm
new file mode 100644
index 0000000..09d614d
--- /dev/null
+++ b/clang/test/SemaObjCXX/blocks.mm
@@ -0,0 +1,146 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
+@protocol NSObject;
+
+void bar(id(^)(void));
+void foo(id <NSObject>(^objectCreationBlock)(void)) {
+ return bar(objectCreationBlock); // OK
+}
+
+void bar2(id(*)(void));
+void foo2(id <NSObject>(*objectCreationBlock)(void)) {
+ return bar2(objectCreationBlock); // expected-warning{{incompatible pointer types passing 'id<NSObject> (*)()' to parameter of type 'id (*)()'}}
+}
+
+void bar3(id(*)()); // expected-note{{candidate function}}
+void foo3(id (*objectCreationBlock)(int)) {
+ return bar3(objectCreationBlock); // expected-error{{no matching}}
+}
+
+void bar4(id(^)()); // expected-note{{candidate function}}
+void foo4(id (^objectCreationBlock)(int)) {
+ return bar4(objectCreationBlock); // expected-error{{no matching}}
+}
+
+void foo5(id (^x)(int)) {
+ if (x) { }
+}
+
+// <rdar://problem/6590445>
+@interface Foo {
+ @private
+ void (^_block)(void);
+}
+- (void)bar;
+@end
+
+namespace N {
+ class X { };
+ void foo(X);
+}
+
+@implementation Foo
+- (void)bar {
+ _block();
+ foo(N::X()); // okay
+}
+@end
+
+typedef signed char BOOL;
+void foo6(void *block) {
+ void (^vb)(id obj, int idx, BOOL *stop) = (void (^)(id, int, BOOL *))block;
+ BOOL (^bb)(id obj, int idx, BOOL *stop) = (BOOL (^)(id, int, BOOL *))block;
+}
+
+// <rdar://problem/8600419>: Require that the types of block
+// parameters are complete.
+namespace N1 {
+ template<class _T> class ptr; // expected-note{{template is declared here}}
+
+ template<class _T>
+ class foo {
+ public:
+ void bar(void (^)(ptr<_T>));
+ };
+
+ class X;
+
+ void test2();
+
+ void test()
+ {
+ foo<X> f;
+ f.bar(^(ptr<X> _f) { // expected-error{{implicit instantiation of undefined template 'N1::ptr<N1::X>'}}
+ test2();
+ });
+ }
+}
+
+// Make sure we successfully instantiate the copy constructor of a
+// __block variable's type.
+namespace N2 {
+ template <int n> struct A {
+ A() {}
+ A(const A &other) {
+ int invalid[-n]; // expected-error 2 {{array with a negative size}}
+ }
+ };
+
+ void test1() {
+ __block A<1> x; // expected-note {{requested here}}
+ }
+
+ template <int n> void test2() {
+ __block A<n> x; // expected-note {{requested here}}
+ }
+ template void test2<2>();
+}
+
+// Handle value-dependent block declaration references.
+namespace N3 {
+ template<int N> struct X { };
+
+ template<int N>
+ void f() {
+ X<N> xN = ^() { return X<N>(); }();
+ }
+}
+
+// rdar://8979379
+
+@interface A
+@end
+
+@interface B : A
+@end
+
+void f(int (^bl)(A* a)); // expected-note {{candidate function not viable: no known conversion from 'int (^)(B *)' to 'int (^)(A *)' for 1st argument}}
+
+void g() {
+ f(^(B* b) { return 0; }); // expected-error {{no matching function for call to 'f'}}
+}
+
+namespace DependentReturn {
+ template<typename T>
+ void f(T t) {
+ (void)^(T u) {
+ if (t != u)
+ return t + u;
+ else
+ return;
+ };
+
+ (void)^(T u) {
+ if (t == u)
+ return;
+ else
+ return t + u;
+ };
+ }
+
+ struct X { };
+ void operator+(X, X);
+ bool operator==(X, X);
+ bool operator!=(X, X);
+
+ template void f<X>(X);
+}
diff --git a/clang/test/SemaObjCXX/category-lookup.mm b/clang/test/SemaObjCXX/category-lookup.mm
new file mode 100644
index 0000000..0e87025
--- /dev/null
+++ b/clang/test/SemaObjCXX/category-lookup.mm
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface NSObject @end
+
+@interface NSObject (NSScriptClassDescription)
+@end
+
+void f() {
+ NSScriptClassDescription *f; // expected-error {{use of undeclared identifier 'NSScriptClassDescription'}}
+}
diff --git a/clang/test/SemaObjCXX/composite-objc-pointertype.mm b/clang/test/SemaObjCXX/composite-objc-pointertype.mm
new file mode 100644
index 0000000..684f633
--- /dev/null
+++ b/clang/test/SemaObjCXX/composite-objc-pointertype.mm
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface Foo
+@end
+
+@implementation Foo
+- (id)test {
+ id bar;
+ Class cl;
+ Foo *f;
+
+ (void)((bar!= 0) ? bar : 0);
+ (void)((cl != 0) ? cl : 0);
+ (void)((f != 0) ? 0 : f);
+ return (0 == 1) ? 0 : bar;
+}
+@end
+
diff --git a/clang/test/SemaObjCXX/conditional-expr.mm b/clang/test/SemaObjCXX/conditional-expr.mm
new file mode 100644
index 0000000..a6b7c08
--- /dev/null
+++ b/clang/test/SemaObjCXX/conditional-expr.mm
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol P0
+@end
+@protocol P1
+@end
+@protocol P2
+@end
+
+@interface A <P0>
+@end
+
+@interface B : A
+@end
+
+void bar(id x);
+void barP0(id<P0> x);
+void barP1(id<P1> x);
+void barP2(id<P2> x);
+
+void f0(A *a) {
+ id l = a;
+}
+
+void f1(id x, A *a) {
+ id<P0> l = a;
+}
+
+void f2(id<P1> x) {
+ id<P0> l = x; // expected-error {{cannot initialize a variable of type 'id<P0>' with an lvalue of type 'id<P1>'}}
+}
+
+void f3(A *a) {
+ id<P1> l = a; // expected-error {{cannot initialize a variable of type 'id<P1>' with an lvalue of type 'A *'}}
+}
+
+void f4(int cond, id x, A *a) {
+ bar(cond ? x : a);
+}
+
+void f5(int cond, A *a, B *b) {
+ bar(cond ? a : b);
+}
+
+void f6(int cond, id x, A *a) {
+ bar(cond ? (id<P0, P1>) x : a);
+}
+
+void f7(int cond, id x, A *a) {
+ bar(cond ? a : (id<P0, P1>) x);
+}
+
+void f8(int cond, id<P0,P1> x0, id<P0,P2> x1) {
+ barP0(cond ? x0 : x1); // expected-warning {{incompatible operand types ('id<P0,P1>' and 'id<P0,P2>')}}
+}
+
+void f9(int cond, id<P0,P1> x0, id<P0,P2> x1) {
+ barP1(cond ? x0 : x1); // expected-warning {{incompatible operand types ('id<P0,P1>' and 'id<P0,P2>')}}
+}
+
+void f10(int cond, id<P0,P1> x0, id<P0,P2> x1) {
+ barP2(cond ? x0 : x1); // expected-warning {{incompatible operand types ('id<P0,P1>' and 'id<P0,P2>')}}
+}
+
+int f11(int cond, A* a, B* b) {
+ return (cond? b : a)->x; // expected-error{{'A' does not have a member named 'x'}}
+}
diff --git a/clang/test/SemaObjCXX/const-cast.mm b/clang/test/SemaObjCXX/const-cast.mm
new file mode 100644
index 0000000..933fd47
--- /dev/null
+++ b/clang/test/SemaObjCXX/const-cast.mm
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@class Foo;
+
+void test() {
+ const Foo *foo1 = 0;
+ Foo *foo2 = foo1; // expected-error {{cannot initialize}}
+}
+
+void test1() {
+ const Foo *foo1 = 0;
+ Foo *foo2 = const_cast<Foo*>(foo1);
+}
diff --git a/clang/test/SemaObjCXX/conversion-ranking.mm b/clang/test/SemaObjCXX/conversion-ranking.mm
new file mode 100644
index 0000000..6c1408b
--- /dev/null
+++ b/clang/test/SemaObjCXX/conversion-ranking.mm
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+@protocol P1
+@end
+
+@interface A <P1>
+@end
+
+@interface B : A
+@end
+
+@interface C : B
+@end
+
+template<typename T>
+struct ConvertsTo {
+ operator T() const;
+};
+
+
+// conversion of C* to B* is better than conversion of C* to A*.
+int &f0(A*);
+float &f0(B*);
+
+void test_f0(C *c) {
+ float &fr1 = f0(c);
+}
+
+// conversion of B* to A* is better than conversion of C* to A*
+void f1(A*);
+
+struct ConvertsToBoth {
+private:
+ operator C*() const;
+
+public:
+ operator B*() const;
+};
+
+void test_f1(ConvertsTo<B*> toB, ConvertsTo<C*> toC, ConvertsToBoth toBoth) {
+ f1(toB);
+ f1(toC);
+ f1(toBoth);
+};
+
+// A conversion to an a non-id object pointer type is better than a
+// conversion to 'id'.
+int &f2(A*);
+float &f2(id);
+
+void test_f2(B *b) {
+ int &ir = f2(b);
+}
+
+// A conversion to an a non-Class object pointer type is better than a
+// conversion to 'Class'.
+int &f3(A*);
+float &f3(Class);
+
+void test_f3(B *b) {
+ int &ir = f3(b);
+}
+
+// When both conversions convert to 'id' or 'Class', pick the most
+// specific type to convert from.
+void f4(id);
+
+void test_f4(ConvertsTo<B*> toB, ConvertsTo<C*> toC, ConvertsToBoth toBoth) {
+ f4(toB);
+ f4(toC);
+ f4(toBoth);
+}
+
+void f5(id<P1>);
+
+void test_f5(ConvertsTo<B*> toB, ConvertsTo<C*> toC, ConvertsToBoth toBoth) {
+ f5(toB);
+ f5(toC);
+ f5(toBoth);
+}
+
+
+// A conversion to an a non-id object pointer type is better than a
+// conversion to qualified 'id'.
+int &f6(A*);
+float &f6(id<P1>);
+
+void test_f6(B *b) {
+ int &ir = f6(b);
+}
diff --git a/clang/test/SemaObjCXX/conversion-to-objc-pointer-2.mm b/clang/test/SemaObjCXX/conversion-to-objc-pointer-2.mm
new file mode 100644
index 0000000..b03d4d8
--- /dev/null
+++ b/clang/test/SemaObjCXX/conversion-to-objc-pointer-2.mm
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar: // 7963410
+
+@protocol NSObject @end
+@interface NSObject
+- (id)init;
+- (id) alloc;
+- (id) autorelease;
+@end
+
+template<class T>
+class TNSAutoRef
+{
+public:
+ TNSAutoRef(T t)
+ : fRef(t)
+ { }
+
+ ~TNSAutoRef()
+ { }
+
+ operator T() const
+ { return fRef; }
+
+private:
+ T fRef;
+};
+
+
+#pragma mark -
+
+
+@protocol TFooProtocol <NSObject>
+
+- (void) foo;
+@end
+
+
+#pragma mark -
+
+
+@interface TFoo : NSObject
+
+- (void) setBlah: (id<TFooProtocol>)blah;
+@end
+
+
+#pragma mark -
+
+
+@implementation TFoo
+
+- (void) setBlah: (id<TFooProtocol>)blah
+ { }
+@end
+
+
+#pragma mark -
+
+
+@interface TBar : NSObject
+
+- (void) setBlah: (id)blah;
+@end
+
+#pragma mark -
+
+
+@implementation TBar
+
+- (void) setBlah: (id)blah
+ { }
+@end
+
+
+#pragma mark -
+
+
+int main (int argc, const char * argv[]) {
+
+ NSObject* object1 = [[[NSObject alloc] init] autorelease];
+ TNSAutoRef<NSObject*> object2([[NSObject alloc] init]);
+ TNSAutoRef<TBar*> bar([[TBar alloc] init]);
+ [bar setBlah: object1]; // <== Does not compile. It should.
+ if (object1 == object2)
+ [bar setBlah: object2]; // <== Does not compile. It should.
+ return 0;
+}
diff --git a/clang/test/SemaObjCXX/conversion-to-objc-pointer.mm b/clang/test/SemaObjCXX/conversion-to-objc-pointer.mm
new file mode 100644
index 0000000..235aaac
--- /dev/null
+++ b/clang/test/SemaObjCXX/conversion-to-objc-pointer.mm
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar: // 7963410
+
+template<class T>
+class TNSAutoRef
+{
+public:
+ TNSAutoRef(T t)
+ : fRef(t)
+ { }
+
+ ~TNSAutoRef()
+ { }
+
+ operator T() const
+ { return fRef; }
+
+ T Get() const
+ { return fRef; }
+
+private:
+ T fRef;
+};
+
+@interface NSObject
+- (id) alloc;
+- (id)init;
+@end
+
+@interface TFoo : NSObject
+- (void) foo;
+@end
+
+@implementation TFoo
+- (void) foo {}
+@end
+
+@interface TBar : NSObject
+- (void) foo;
+@end
+
+@implementation TBar
+- (void) foo {}
+@end
+
+int main () {
+ TNSAutoRef<TBar*> bar([[TBar alloc] init]);
+ [bar foo];
+ return 0;
+}
diff --git a/clang/test/SemaObjCXX/cstyle-block-pointer-cast.mm b/clang/test/SemaObjCXX/cstyle-block-pointer-cast.mm
new file mode 100644
index 0000000..0f982ba
--- /dev/null
+++ b/clang/test/SemaObjCXX/cstyle-block-pointer-cast.mm
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
+// radar 7562285
+
+typedef int (^blocktype)(int a, int b);
+
+@interface A {
+ A* a;
+ id b;
+ Class c;
+}
+- (blocktype)Meth;
+@end
+
+@implementation A
+- (blocktype)Meth {
+ if (b)
+ return (blocktype)b;
+ else if (a)
+ return (blocktype)a; // expected-error {{C-style cast from 'A *' to 'blocktype' (aka 'int (^)(int, int)') is not allowed}}
+ else
+ return (blocktype)c;
+}
+@end
+
+@interface B {
+ blocktype a;
+ blocktype b;
+ blocktype c;
+}
+- (id)Meth;
+@end
+
+@implementation B
+- (id)Meth {
+ if (a)
+ return (A*)a; // expected-error {{C-style cast from 'blocktype' (aka 'int (^)(int, int)') to 'A *' is not allowed}}
+ if (b)
+ return (id)b;
+ if (c)
+ return (Class)b;
+}
+@end
diff --git a/clang/test/SemaObjCXX/cstyle-cast.mm b/clang/test/SemaObjCXX/cstyle-cast.mm
new file mode 100644
index 0000000..29a8404
--- /dev/null
+++ b/clang/test/SemaObjCXX/cstyle-cast.mm
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol P @end
+@interface I @end
+
+struct X { X(); };
+
+void test1(X x) {
+ void *cft;
+ id oct = (id)cft;
+
+ Class ccct;
+ ccct = (Class)cft;
+
+ I* iict = (I*)cft;
+
+ id<P> qid = (id<P>)cft;
+
+ I<P> *ip = (I<P>*)cft;
+
+ (id)x; // expected-error {{cannot convert 'X' to 'id' without a conversion operator}}
+
+ id *pid = (id*)ccct;
+
+ id<P> *qpid = (id<P>*)ccct;
+
+ int **pii;
+
+ ccct = (Class)pii;
+
+ qpid = (id<P>*)pii;
+
+ iict = (I*)pii;
+
+ pii = (int **)ccct;
+
+ pii = (int **)qpid;
+
+}
+
diff --git a/clang/test/SemaObjCXX/cxxoperator-selector.mm b/clang/test/SemaObjCXX/cxxoperator-selector.mm
new file mode 100644
index 0000000..f1aecab
--- /dev/null
+++ b/clang/test/SemaObjCXX/cxxoperator-selector.mm
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar:// 8328250
+
+@class NSDate;
+
+@interface XSGraphDataSet
+- and;
+- xor;
+- or;
+
+- ||; // expected-error {{expected selector for Objective-C method}}
+
+- &&; // expected-error {{expected selector for Objective-C method}}
+
+- (void)dataSetForValuesBetween:(NSDate *)startDate and:(NSDate *)endDate;
+@end
+
+@implementation XSGraphDataSet
+- (id) and{return 0; };
+- (id) xor{return 0; };
+- (id) or{return 0; };
+
+- (void)dataSetForValuesBetween:(NSDate *)startDate and:(NSDate *)endDate { return; }
+@end
diff --git a/clang/test/SemaObjCXX/debugger-cast-result-to-id.mm b/clang/test/SemaObjCXX/debugger-cast-result-to-id.mm
new file mode 100644
index 0000000..cd7aa7b
--- /dev/null
+++ b/clang/test/SemaObjCXX/debugger-cast-result-to-id.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fdebugger-support -fdebugger-cast-result-to-id -funknown-anytype -fsyntax-only -verify %s
+
+// rdar://problem/9416370
+namespace test0 {
+ void test(id x) {
+ if ([x foo]) {} // expected-error {{no known method '-foo'; cast the message send to the method's return type}}
+ [x foo];
+ }
+}
+
+// rdar://10988847
+@class NSString; // expected-note {{forward declaration of class here}}
+namespace test1 {
+ void rdar10988847() {
+ id s = [NSString stringWithUTF8String:"foo"]; // expected-warning {{receiver 'NSString' is a forward class and corresponding @interface may not exist}}
+ }
+}
diff --git a/clang/test/SemaObjCXX/deduction.mm b/clang/test/SemaObjCXX/deduction.mm
new file mode 100644
index 0000000..220f368
--- /dev/null
+++ b/clang/test/SemaObjCXX/deduction.mm
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@class NSString;
+
+// Reduced from WebKit.
+namespace test0 {
+ template <typename T> struct RemovePointer {
+ typedef T Type;
+ };
+
+ template <typename T> struct RemovePointer<T*> {
+ typedef T Type;
+ };
+
+ template <typename T> struct RetainPtr {
+ typedef typename RemovePointer<T>::Type ValueType;
+ typedef ValueType* PtrType;
+ RetainPtr(PtrType ptr);
+ };
+
+ void test(NSString *S) {
+ RetainPtr<NSString*> ptr(S);
+ }
+
+ void test(id S) {
+ RetainPtr<id> ptr(S);
+ }
+}
+
+@class Test1Class;
+@protocol Test1Protocol;
+namespace test1 {
+ template <typename T> struct RemovePointer {
+ typedef T type;
+ };
+ template <typename T> struct RemovePointer<T*> {
+ typedef T type;
+ };
+ template <typename A, typename B> struct is_same {};
+ template <typename A> struct is_same<A,A> {
+ static void foo();
+ };
+ template <typename T> struct tester {
+ void test() {
+ is_same<T, typename RemovePointer<T>::type*>::foo(); // expected-error 2 {{no member named 'foo'}}
+ }
+ };
+
+ template struct tester<id>;
+ template struct tester<id<Test1Protocol> >;
+ template struct tester<Class>;
+ template struct tester<Class<Test1Protocol> >;
+ template struct tester<Test1Class*>;
+ template struct tester<Test1Class<Test1Protocol>*>;
+
+ template struct tester<Test1Class>; // expected-note {{in instantiation}}
+ template struct tester<Test1Class<Test1Protocol> >; // expected-note {{in instantiation}}
+}
+
+namespace test2 {
+ template <typename T> void foo(const T* t) {}
+ void test(id x) {
+ foo(x);
+ }
+}
diff --git a/clang/test/SemaObjCXX/exceptions-fragile.mm b/clang/test/SemaObjCXX/exceptions-fragile.mm
new file mode 100644
index 0000000..91b7077
--- /dev/null
+++ b/clang/test/SemaObjCXX/exceptions-fragile.mm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fobjc-fragile-abi -fsyntax-only -verify %s
+
+@interface NSException @end
+void opaque();
+
+namespace test0 {
+ void test() {
+ try {
+ } catch (NSException *e) { // expected-warning {{can not catch an exception thrown with @throw in C++ in the non-unified exception model}}
+ }
+ }
+}
diff --git a/clang/test/SemaObjCXX/expr-objcxx.mm b/clang/test/SemaObjCXX/expr-objcxx.mm
new file mode 100644
index 0000000..e70a001
--- /dev/null
+++ b/clang/test/SemaObjCXX/expr-objcxx.mm
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+// rdar://8366474
+void *P = @selector(foo::bar::);
diff --git a/clang/test/SemaObjCXX/foreach-block.mm b/clang/test/SemaObjCXX/foreach-block.mm
new file mode 100644
index 0000000..91bd0c8
--- /dev/null
+++ b/clang/test/SemaObjCXX/foreach-block.mm
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
+// rdar://8295106
+
+int main() {
+id array;
+
+ for (int (^b)(void) in array) {
+ if (b() == 10000) {
+ return 1;
+ }
+ }
+
+ int (^b)(void) in array; // expected-error {{expected ';' at end of declaration}}
+}
diff --git a/clang/test/SemaObjCXX/fragile-abi-object-assign.m b/clang/test/SemaObjCXX/fragile-abi-object-assign.m
new file mode 100644
index 0000000..5bb3ac6
--- /dev/null
+++ b/clang/test/SemaObjCXX/fragile-abi-object-assign.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-fragile-abi -verify -Wno-objc-root-class %s
+// rdar://10731065
+
+@interface MyView {}
+@end
+
+@implementation MyViewTemplate // expected-warning {{cannot find interface declaration for 'MyViewTemplate'}}
+- (id) createRealObject {
+ id realObj;
+ *(MyView *) realObj = *(MyView *) self; // expected-error {{cannot assign to class object}}
+}
+@end
+
diff --git a/clang/test/SemaObjCXX/function-pointer-void-star.mm b/clang/test/SemaObjCXX/function-pointer-void-star.mm
new file mode 100644
index 0000000..8d3d625
--- /dev/null
+++ b/clang/test/SemaObjCXX/function-pointer-void-star.mm
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+extern "C" id (*_dealloc)(id) ;
+
+void foo() {
+ extern void *_original_dealloc;
+ if (_dealloc == _original_dealloc) { }
+ if (_dealloc != _original_dealloc) { }
+}
diff --git a/clang/test/SemaObjCXX/gc-attributes.mm b/clang/test/SemaObjCXX/gc-attributes.mm
new file mode 100644
index 0000000..4549683
--- /dev/null
+++ b/clang/test/SemaObjCXX/gc-attributes.mm
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc -fsyntax-only -verify %s
+
+@interface A
+@end
+
+void f0(__strong A**); // expected-note{{candidate function not viable: 1st argument ('A *__weak *') has __weak ownership, but parameter has __strong ownership}}
+
+void test_f0() {
+ A *a;
+ static __weak A *a2;
+ f0(&a);
+ f0(&a2); // expected-error{{no matching function}}
+}
+
+void f1(__weak A**); // expected-note{{candidate function not viable: 1st argument ('A *__strong *') has __strong ownership, but parameter has __weak ownership}}
+
+void test_f1() {
+ A *a;
+ __strong A *a2;
+ f1(&a);
+ f1(&a2); // expected-error{{no matching function}}
+}
diff --git a/clang/test/SemaObjCXX/goto.mm b/clang/test/SemaObjCXX/goto.mm
new file mode 100644
index 0000000..55bde99
--- /dev/null
+++ b/clang/test/SemaObjCXX/goto.mm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+// PR9495
+struct NonPOD { NonPOD(); ~NonPOD(); };
+
+@interface A
+@end
+
+@implementation A
+- (void)method:(bool)b {
+ NonPOD np;
+ if (b) {
+ goto undeclared; // expected-error{{use of undeclared label 'undeclared'}}
+ }
+}
+@end
diff --git a/clang/test/SemaObjCXX/instantiate-expr.mm b/clang/test/SemaObjCXX/instantiate-expr.mm
new file mode 100644
index 0000000..75a5b7e
--- /dev/null
+++ b/clang/test/SemaObjCXX/instantiate-expr.mm
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface A {
+@public
+ int ivar;
+}
+@property int prop;
+@end
+
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+// Test instantiation of value-dependent ObjCIvarRefExpr,
+// ObjCIsaRefExpr, and ObjCPropertyRefExpr nodes.
+A *get_an_A(unsigned);
+id get_an_id(unsigned);
+
+template<unsigned N, typename T, typename U, typename V>
+void f(U value, V value2) {
+ get_an_A(N)->ivar = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}}
+ get_an_A(N).prop = value2; // expected-error{{assigning to 'int' from incompatible type 'double *'}}
+ T c = get_an_id(N)->isa; // expected-error{{cannot initialize a variable of type 'int' with an lvalue of type 'Class'}} \
+ // expected-warning 5 {{direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()}}
+}
+
+template void f<6, Class>(int, int); // expected-note{{in instantiation of}}
+template void f<7, Class>(int*, int); // expected-note{{in instantiation of}}
+template void f<8, Class>(int, double*); // expected-note{{in instantiation of}}
+template void f<9, int>(int, int); // expected-note{{in instantiation of}}
+
+// Test instantiation of unresolved member reference expressions to an
+// ivar reference.
+template<typename T, typename U, typename V>
+void f2(T ptr, U value, V value2) {
+ ptr->ivar = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}}
+ ptr.prop = value2; // expected-error{{assigning to 'int' from incompatible type 'double *'}}
+}
+
+template void f2(A*, int, int);
+template void f2(A*, int*, int); // expected-note{{instantiation of}}
+template void f2(A*, int, double*); // expected-note{{instantiation of}}
+
+// Test instantiation of unresolved member referfence expressions to
+// an isa.
+template<typename T, typename U>
+void f3(U ptr) {
+ T c = ptr->isa; // expected-error{{cannot initialize a variable of type 'int' with an lvalue of type 'Class'}} \
+ // expected-warning 2 {{direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()}}
+}
+
+template void f3<Class>(id); // expected-note{{in instantiation of}}
+template void f3<int>(id); // expected-note{{instantiation of}}
+
+// Implicit setter/getter
+@interface B
+- (int)foo;
+- (void)setFoo:(int)value;
+@end
+
+template<typename T>
+void f4(B *b, T value) {
+ b.foo = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}}
+}
+
+template void f4(B*, int);
+template void f4(B*, int*); // expected-note{{in instantiation of function template specialization 'f4<int *>' requested here}}
+
+template<typename T, typename U>
+void f5(T ptr, U value) {
+ ptr.foo = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}}
+}
+
+template void f5(B*, int);
+template void f5(B*, int*); // expected-note{{in instantiation of function template specialization 'f5<B *, int *>' requested here}}
diff --git a/clang/test/SemaObjCXX/instantiate-message.mm b/clang/test/SemaObjCXX/instantiate-message.mm
new file mode 100644
index 0000000..e09b182
--- /dev/null
+++ b/clang/test/SemaObjCXX/instantiate-message.mm
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Test template instantiation of Objective-C message sends.
+
+@interface ClassMethods
++ (ClassMethods *)method1:(void*)ptr;
+@end
+
+template<typename T>
+struct identity {
+ typedef T type;
+};
+
+template<typename R, typename T, typename Arg1>
+void test_class_method(Arg1 arg1) {
+ R *result1 = [T method1:arg1];
+ R *result2 = [typename identity<T>::type method1:arg1];
+ R *result3 = [ClassMethods method1:arg1]; // expected-error{{cannot initialize a variable of type 'ClassMethods2 *' with an rvalue of type 'ClassMethods *'}}
+}
+
+template void test_class_method<ClassMethods, ClassMethods>(void*);
+template void test_class_method<ClassMethods, ClassMethods>(int*);
+
+@interface ClassMethods2
++ (ClassMethods2 *)method1:(int*)ptr;
+@end
+
+template void test_class_method<ClassMethods2, ClassMethods2>(int*); // expected-note{{in instantiation of}}
+
+
+@interface InstanceMethods
+- (InstanceMethods *)method1:(void*)ptr;
+@end
+
+template<typename R, typename T, typename Arg1>
+void test_instance_method(Arg1 arg1) {
+ T *receiver = 0;
+ InstanceMethods *im = 0;
+ R *result1 = [receiver method1:arg1];
+ R *result2 = [im method1:arg1]; // expected-error{{cannot initialize a variable of type 'InstanceMethods2 *' with an rvalue of type 'InstanceMethods *'}}
+}
+
+template void test_instance_method<InstanceMethods, InstanceMethods>(void*);
+template void test_instance_method<InstanceMethods, InstanceMethods>(int*);
+
+@interface InstanceMethods2
+- (InstanceMethods2 *)method1:(void*)ptr;
+@end
+
+template void test_instance_method<InstanceMethods2, InstanceMethods2>(int*); // expected-note{{in instantiation of}}
diff --git a/clang/test/SemaObjCXX/instantiate-method-return.mm b/clang/test/SemaObjCXX/instantiate-method-return.mm
new file mode 100644
index 0000000..2a3ae32
--- /dev/null
+++ b/clang/test/SemaObjCXX/instantiate-method-return.mm
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// PR7386
+
+@class NSObject;
+
+class A;
+template<class T> class V {};
+
+@protocol Protocol
+- (V<A*>)protocolMethod;
+@end
+
+
+@interface I<Protocol>
+@end
+
+
+@implementation I
+- (void)randomMethod:(id)info {
+ V<A*> vec([self protocolMethod]);
+}
+
+- (V<A*>)protocolMethod {
+ V<A*> va; return va;
+}
+@end
diff --git a/clang/test/SemaObjCXX/instantiate-stmt.mm b/clang/test/SemaObjCXX/instantiate-stmt.mm
new file mode 100644
index 0000000..ff72858
--- /dev/null
+++ b/clang/test/SemaObjCXX/instantiate-stmt.mm
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s
+
+@interface NSException
+@end
+
+// @throw
+template<typename T>
+void throw_test(T value) {
+ @throw value; // expected-error{{@throw requires an Objective-C object type ('int' invalid)}}
+}
+
+template void throw_test(NSException *);
+template void throw_test(int); // expected-note{{in instantiation of}}
+
+// @synchronized
+template<typename T>
+void synchronized_test(T value) {
+ @synchronized (value) { // expected-error{{@synchronized requires an Objective-C object type ('int' invalid)}}
+ value = 0;
+ }
+}
+
+template void synchronized_test(NSException *);
+template void synchronized_test(int); // expected-note{{in instantiation of}}
+
+// fast enumeration
+@interface NSArray
+- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount;
+@end
+
+@interface NSString
+@end
+
+struct vector {};
+
+template<typename T> void eat(T);
+
+template<typename E, typename T>
+void fast_enumeration_test(T collection) {
+ for (E element in collection) { // expected-error{{selector element type 'int' is not a valid object}} \
+ // expected-error{{collection expression type 'vector' is not a valid object}}
+ eat(element);
+ }
+
+ E element;
+ for (element in collection) // expected-error{{selector element type 'int' is not a valid object}} \
+ // expected-error{{collection expression type 'vector' is not a valid object}}
+ eat(element);
+
+ for (NSString *str in collection) // expected-error{{collection expression type 'vector' is not a valid object}}
+ eat(str);
+
+ NSString *str;
+ for (str in collection) // expected-error{{collection expression type 'vector' is not a valid object}}
+ eat(str);
+}
+
+template void fast_enumeration_test<NSString *>(NSArray*);
+template void fast_enumeration_test<int>(NSArray*); // expected-note{{in instantiation of}}
+template void fast_enumeration_test<NSString *>(vector); // expected-note{{in instantiation of}}
+
+// @try/@catch/@finally
+
+template<typename T, typename U>
+void try_catch_finally_test(U value) {
+ @try {
+ value = 1; // expected-error{{assigning to 'int *' from incompatible type 'int'}}
+ }
+ @catch (T obj) { // expected-error{{@catch parameter is not a pointer to an interface type}}
+ id x = obj;
+ } @finally {
+ value = 0;
+ }
+}
+
+template void try_catch_finally_test<NSString *>(int);
+template void try_catch_finally_test<NSString *>(int*); // expected-note{{in instantiation of}}
+template void try_catch_finally_test<NSString>(int); // expected-note{{in instantiation of function template specialization 'try_catch_finally_test<NSString, int>' requested here}}
diff --git a/clang/test/SemaObjCXX/ivar-construct.mm b/clang/test/SemaObjCXX/ivar-construct.mm
new file mode 100644
index 0000000..a066fca
--- /dev/null
+++ b/clang/test/SemaObjCXX/ivar-construct.mm
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+struct Y {
+ Y();
+
+private:
+ ~Y(); // expected-note 3{{declared private here}}
+};
+
+template<typename T>
+struct X : T { }; // expected-error 2{{private destructor}}
+
+struct Z; // expected-note{{forward declaration}}
+
+@interface A {
+ X<Y> x; // expected-note{{implicit default destructor}}
+ Y y; // expected-error{{private destructor}}
+}
+@end
+
+@implementation A // expected-note{{implicit default constructor}}
+@end
+
+@interface B {
+ Z z; // expected-error{{incomplete type}}
+}
+@end
+
+@implementation B
+@end
+
+// <rdar://problem/11284902>
+template<typename T> struct Incomplete; // expected-note{{declared here}}
+
+@interface C {
+ Incomplete<int> a[4][4][4]; // expected-error{{implicit instantiation of undefined template 'Incomplete<int>'}}
+}
+@end
diff --git a/clang/test/SemaObjCXX/ivar-lookup.mm b/clang/test/SemaObjCXX/ivar-lookup.mm
new file mode 100644
index 0000000..fc99c15
--- /dev/null
+++ b/clang/test/SemaObjCXX/ivar-lookup.mm
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+@interface Ivar
+- (float*)method;
+@end
+
+@interface A {
+ A *Ivar;
+}
+- (int*)method;
+@end
+
+@implementation A
+- (int*)method {
+ int *ip = [Ivar method]; // Okay; calls A's method on the instance variable Ivar.
+ // Note that Objective-C calls Ivar's method.
+ return 0;
+}
+@end
diff --git a/clang/test/SemaObjCXX/ivar-reference-type.mm b/clang/test/SemaObjCXX/ivar-reference-type.mm
new file mode 100644
index 0000000..2b5df45
--- /dev/null
+++ b/clang/test/SemaObjCXX/ivar-reference-type.mm
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+@interface A {
+ int &r; // expected-error {{instance variables cannot be of reference type}}
+}
+@end
diff --git a/clang/test/SemaObjCXX/ivar-struct.mm b/clang/test/SemaObjCXX/ivar-struct.mm
new file mode 100644
index 0000000..3f9c7eb
--- /dev/null
+++ b/clang/test/SemaObjCXX/ivar-struct.mm
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+@interface A {
+ struct X {
+ int x, y;
+ } X;
+}
+@end
diff --git a/clang/test/SemaObjCXX/linkage-spec.mm b/clang/test/SemaObjCXX/linkage-spec.mm
new file mode 100644
index 0000000..584571d
--- /dev/null
+++ b/clang/test/SemaObjCXX/linkage-spec.mm
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+extern "C" {
+@class Protocol;
+}
+
+// <rdar://problem/7827709>
+extern "C" {
+@class I;
+}
+
+@interface I
+@end
+
+// rdar://10015110
+@protocol VKAnnotation;
+extern "C" {
+
+@protocol VKAnnotation
+ @property (nonatomic, assign) id coordinate;
+@end
+}
diff --git a/clang/test/SemaObjCXX/literals.mm b/clang/test/SemaObjCXX/literals.mm
new file mode 100644
index 0000000..6cdd207
--- /dev/null
+++ b/clang/test/SemaObjCXX/literals.mm
@@ -0,0 +1,187 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -fblocks %s
+
+// rdar://11231426
+typedef signed char BOOL;
+
+void y(BOOL (^foo)());
+
+void x() {
+ y(^{
+ return __objc_yes;
+ });
+}
+
+@protocol NSCopying
+- copy;
+@end
+
+@interface NSObject
+@end
+
+@interface NSNumber : NSObject <NSCopying>
+-copy;
+@end
+
+@interface NSNumber (NSNumberCreation)
++ (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;
+@end
+
+@interface NSArray : NSObject <NSCopying>
+-copy;
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id<NSCopying> [])keys count:(unsigned long)cnt;
+@end
+
+template<typename T>
+struct ConvertibleTo {
+ operator T();
+};
+
+template<typename T>
+struct ExplicitlyConvertibleTo {
+ explicit operator T();
+};
+
+template<typename T>
+class PrivateConvertibleTo {
+private:
+ operator T(); // expected-note{{declared private here}}
+};
+
+template<typename T> ConvertibleTo<T> makeConvertible();
+
+struct X {
+ ConvertibleTo<id> x;
+ ConvertibleTo<id> get();
+};
+
+template<typename T> T test_numeric_instantiation() {
+ return @-17.42;
+}
+
+template id test_numeric_instantiation();
+
+void test_convertibility(ConvertibleTo<NSArray*> toArray,
+ ConvertibleTo<id> toId,
+ ConvertibleTo<int (^)(int)> toBlock,
+ ConvertibleTo<int> toInt,
+ ExplicitlyConvertibleTo<NSArray *> toArrayExplicit) {
+ id array = @[
+ toArray,
+ toId,
+ toBlock,
+ toInt // expected-error{{collection element of type 'ConvertibleTo<int>' is not an Objective-C object}}
+ ];
+ id array2 = @[ toArrayExplicit ]; // expected-error{{collection element of type 'ExplicitlyConvertibleTo<NSArray *>' is not an Objective-C object}}
+
+ id array3 = @[
+ makeConvertible<id>(),
+ makeConvertible<id>, // expected-error{{collection element of type 'ConvertibleTo<id> ()' is not an Objective-C object}}
+ ];
+
+ X x;
+ id array4 = @[ x.x ];
+ id array5 = @[ x.get ]; // expected-error{{reference to non-static member function must be called}}
+ id array6 = @[ PrivateConvertibleTo<NSArray*>() ]; // expected-error{{operator NSArray *' is a private member of 'PrivateConvertibleTo<NSArray *>'}}
+}
+
+template<typename T>
+void test_array_literals(T t) {
+ id arr = @[ @17, t ]; // expected-error{{collection element of type 'int' is not an Objective-C object}}
+}
+
+template void test_array_literals(id);
+template void test_array_literals(NSArray*);
+template void test_array_literals(int); // expected-note{{in instantiation of function template specialization 'test_array_literals<int>' requested here}}
+
+template<typename T, typename U>
+void test_dictionary_literals(T t, U u) {
+ NSObject *object;
+ id dict = @{
+ @17 : t, // expected-error{{collection element of type 'int' is not an Objective-C object}}
+ u : @42 // expected-error{{collection element of type 'int' is not an Objective-C object}}
+ };
+
+ id dict2 = @{
+ object : @"object" // expected-error{{cannot initialize a parameter of type 'const id<NSCopying>' with an rvalue of type 'NSObject *'}}
+ };
+}
+
+template void test_dictionary_literals(id, NSArray*);
+template void test_dictionary_literals(NSArray*, id);
+template void test_dictionary_literals(int, id); // expected-note{{in instantiation of function template specialization 'test_dictionary_literals<int, id>' requested here}}
+template void test_dictionary_literals(id, int); // expected-note{{in instantiation of function template specialization 'test_dictionary_literals<id, int>' requested here}}
+
+template<typename ...Args>
+void test_bad_variadic_array_literal(Args ...args) {
+ id arr1 = @[ args ]; // expected-error{{initializer contains unexpanded parameter pack 'args'}}
+}
+
+template<typename ...Args>
+void test_variadic_array_literal(Args ...args) {
+ id arr1 = @[ args... ]; // expected-error{{collection element of type 'int' is not an Objective-C object}}
+}
+template void test_variadic_array_literal(id);
+template void test_variadic_array_literal(id, NSArray*);
+template void test_variadic_array_literal(id, int, NSArray*); // expected-note{{in instantiation of function template specialization 'test_variadic_array_literal<id, int, NSArray *>' requested here}}
+
+template<typename ...Args>
+void test_bad_variadic_dictionary_literal(Args ...args) {
+ id dict = @{ args : @17 }; // expected-error{{initializer contains unexpanded parameter pack 'args'}}
+}
+
+// Test array literal pack expansions.
+template<typename T, typename U>
+struct pair {
+ T first;
+ U second;
+};
+
+template<typename T, typename ...Ts, typename ... Us>
+void test_variadic_dictionary_expansion(T t, pair<Ts, Us>... key_values) {
+ id dict = @{
+ t : key_values.second ..., // expected-error{{collection element of type 'int' is not an Objective-C object}}
+ key_values.first : key_values.second ..., // expected-error{{collection element of type 'float' is not an Objective-C object}}
+ key_values.second : t ...
+ };
+}
+
+template void test_variadic_dictionary_expansion(id,
+ pair<NSNumber*, id>,
+ pair<id, ConvertibleTo<id>>);
+template void test_variadic_dictionary_expansion(NSNumber *, // expected-note{{in instantiation of function template specialization}}
+ pair<NSNumber*, int>,
+ pair<id, ConvertibleTo<id>>);
+template void test_variadic_dictionary_expansion(NSNumber *, // expected-note{{in instantiation of function template specialization}}
+ pair<NSNumber*, id>,
+ pair<float, ConvertibleTo<id>>);
+
+// Test parsing
+struct key {
+ static id value;
+};
+
+id key;
+id value;
+
+void test_dictionary_colon() {
+ id dict = @{ key : value };
+}
diff --git a/clang/test/SemaObjCXX/message.mm b/clang/test/SemaObjCXX/message.mm
new file mode 100644
index 0000000..5ac2f40
--- /dev/null
+++ b/clang/test/SemaObjCXX/message.mm
@@ -0,0 +1,127 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify -Wno-objc-root-class %s
+@interface I1
+- (int*)method;
+@end
+
+@implementation I1
+- (int*)method {
+ struct x { };
+ [x method]; // expected-error{{receiver type 'x' is not an Objective-C class}}
+ return 0;
+}
+@end
+
+typedef struct { int x; } ivar;
+
+@interface I2 {
+ id ivar;
+}
+- (int*)method;
++ (void)method;
+@end
+
+struct I2_holder {
+ I2_holder();
+
+ I2 *get();
+};
+
+I2 *operator+(I2_holder, int);
+
+@implementation I2
+- (int*)method {
+ [ivar method];
+
+ // Test instance messages that start with a simple-type-specifier.
+ [I2_holder().get() method];
+ [I2_holder().get() + 17 method];
+ return 0;
+}
++ (void)method {
+ [ivar method]; // expected-error{{receiver type 'ivar' is not an Objective-C class}}
+}
+@end
+
+// Class message sends
+@interface I3
++ (int*)method;
+@end
+
+@interface I4 : I3
++ (int*)otherMethod;
+@end
+
+template<typename T>
+struct identity {
+ typedef T type;
+};
+
+@implementation I4
++ (int *)otherMethod {
+ // Test class messages that use non-trivial simple-type-specifiers
+ // or typename-specifiers.
+ if (false) {
+ if (true)
+ return [typename identity<I3>::type method]; // expected-warning{{occurs outside of a template}}
+
+ return [::I3 method];
+ }
+
+ int* ip1 = {[super method]};
+ int* ip2 = {[::I3 method]};
+ int* ip3 = {[typename identity<I3>::type method]}; // expected-warning{{occurs outside of a template}}
+ int* ip4 = {[typename identity<I2_holder>::type().get() method]}; // expected-warning{{occurs outside of a template}}
+ int array[5] = {[3] = 2};
+ return [super method];
+}
+@end
+
+struct String {
+ String(const char *);
+};
+
+struct MutableString : public String { };
+
+// C++-specific parameter types
+@interface I5
+- method:(const String&)str1
+ other:(String&)str2; // expected-note{{passing argument to parameter 'str2' here}}
+@end
+
+void test_I5(I5 *i5, String s) {
+ [i5 method:"hello" other:s];
+ [i5 method:s other:"world"]; // expected-error{{non-const lvalue reference to type 'String' cannot bind to a value of unrelated type 'const char [6]'}}
+}
+
+// <rdar://problem/8483253>
+@interface A
+
+struct X { };
+
++ (A *)create:(void (*)(void *x, X r, void *data))callback
+ callbackData:(void *)callback_data;
+
+@end
+
+
+void foo(void)
+{
+ void *fun;
+ void *ptr;
+ X r;
+ A *im = [A create:(void (*)(void *cgl_ctx, X r, void *data)) fun
+ callbackData:ptr];
+}
+
+// <rdar://problem/8807070>
+template<typename T> struct X1; // expected-note{{template is declared here}}
+
+@interface B
++ (X1<int>)blah;
++ (X1<float>&)blarg;
+@end
+
+void f() {
+ [B blah]; // expected-error{{implicit instantiation of undefined template 'X1<int>'}}
+ [B blarg];
+}
diff --git a/clang/test/SemaObjCXX/namespace-lookup.mm b/clang/test/SemaObjCXX/namespace-lookup.mm
new file mode 100644
index 0000000..205b443
--- /dev/null
+++ b/clang/test/SemaObjCXX/namespace-lookup.mm
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/9388207>
+@interface A
+@end
+
+@interface A(N)
+@end
+
+@protocol M
+@end
+
+namespace N { }
+namespace M { }
diff --git a/clang/test/SemaObjCXX/null_objc_pointer.mm b/clang/test/SemaObjCXX/null_objc_pointer.mm
new file mode 100644
index 0000000..0da9e50
--- /dev/null
+++ b/clang/test/SemaObjCXX/null_objc_pointer.mm
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wnull-arithmetic %s
+#define NULL __null
+
+@interface X
+@end
+
+void f() {
+ bool b;
+ X *d;
+ b = d < NULL || NULL < d || d > NULL || NULL > d;
+ b = d <= NULL || NULL <= d || d >= NULL || NULL >= d;
+ b = d == NULL || NULL == d || d != NULL || NULL != d;
+}
diff --git a/clang/test/SemaObjCXX/nullptr.mm b/clang/test/SemaObjCXX/nullptr.mm
new file mode 100644
index 0000000..2b29b04
--- /dev/null
+++ b/clang/test/SemaObjCXX/nullptr.mm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++11 -fblocks -fsyntax-only -verify %s
+
+@interface A
+@end
+
+void comparisons(A *a) {
+ (void)(a == nullptr);
+ (void)(nullptr == a);
+}
+
+void assignment(A *a) {
+ a = nullptr;
+}
+
+int PR10145a = (void(^)())0 == nullptr;
+int PR10145b = nullptr == (void(^)())0;
diff --git a/clang/test/SemaObjCXX/objc-container-subscripting.mm b/clang/test/SemaObjCXX/objc-container-subscripting.mm
new file mode 100644
index 0000000..c835cbe
--- /dev/null
+++ b/clang/test/SemaObjCXX/objc-container-subscripting.mm
@@ -0,0 +1,138 @@
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -fsyntax-only -std=c++11 -verify %s
+
+@class NSArray;
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id)key;
+- (void)setObject:(id)object forKeyedSubscript:(id)key; // expected-note {{passing argument to parameter 'object' here}}
+@end
+
+template<typename T, typename U, typename O>
+void test_dictionary_subscripts(T base, U key, O obj) {
+ base[key] = obj; // expected-error {{expected method to write array element not found on object of type 'NSMutableDictionary *'}} \
+ // expected-error {{cannot initialize a parameter of type 'id' with an lvalue of type 'int'}}
+ obj = base[key]; // expected-error {{expected method to read array element not found on object of type 'NSMutableDictionary *'}} \
+ // expected-error {{assigning to 'int' from incompatible type 'id'}}
+
+}
+
+template void test_dictionary_subscripts(NSMutableDictionary*, id, NSArray *ns);
+
+template void test_dictionary_subscripts(NSMutableDictionary*, NSArray *ns, id);
+
+template void test_dictionary_subscripts(NSMutableDictionary*, int, id); // expected-note {{in instantiation of function template specialization 'test_dictionary_subscripts<NSMutableDictionary *, int, id>' requested here}}
+
+template void test_dictionary_subscripts(NSMutableDictionary*, id, int); // expected-note {{in instantiation of function template specialization 'test_dictionary_subscripts<NSMutableDictionary *, id, int>' requested here}}
+
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(int)index;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+template<typename T, typename U, typename O>
+void test_array_subscripts(T base, U index, O obj) {
+ base[index] = obj; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or objective-C pointer type}}
+ obj = base[index]; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or objective-C pointer type}}
+}
+
+template void test_array_subscripts(NSMutableArray *, int, id);
+template void test_array_subscripts(NSMutableArray *, short, id);
+enum E { e };
+
+template void test_array_subscripts(NSMutableArray *, E, id);
+
+template void test_array_subscripts(NSMutableArray *, double, id); // expected-note {{in instantiation of function template specialization 'test_array_subscripts<NSMutableArray *, double, id>' requested here}}
+
+template<typename T>
+struct ConvertibleTo {
+ operator T();
+};
+
+template<typename T>
+struct ExplicitlyConvertibleTo {
+ explicit operator T();
+};
+
+template<typename T> ConvertibleTo<T> makeConvertible();
+
+struct X {
+ ConvertibleTo<id> x;
+ ConvertibleTo<id> get();
+};
+
+NSMutableArray *test_array_convertibility(ConvertibleTo<NSMutableArray*> toArray,
+ ConvertibleTo<id> toId,
+ ConvertibleTo<int (^)(int)> toBlock,
+ ConvertibleTo<int> toInt,
+ ExplicitlyConvertibleTo<NSMutableArray *> toArrayExplicit) {
+ id array;
+
+ array[1] = toArray;
+
+ array[4] = array[1];
+
+ toArrayExplicit[2] = toId; // expected-error {{type 'ExplicitlyConvertibleTo<NSMutableArray *>' does not provide a subscript operator}}
+
+ return array[toInt];
+
+}
+
+id test_dict_convertibility(ConvertibleTo<NSMutableDictionary*> toDict,
+ ConvertibleTo<id> toId,
+ ConvertibleTo<int (^)(int)> toBlock,
+ ConvertibleTo<int> toInt,
+ ExplicitlyConvertibleTo<NSMutableDictionary *> toDictExplicit) {
+
+
+ NSMutableDictionary *Dict;
+ id Id;
+ Dict[toId] = toBlock;
+
+ Dict[toBlock] = toBlock;
+
+ Dict[toBlock] = Dict[toId] = Dict[toBlock];
+
+ Id = toDictExplicit[toId] = Id; // expected-error {{no viable overloaded operator[] for type 'ExplicitlyConvertibleTo<NSMutableDictionary *>'}}
+
+ return Dict[toBlock];
+}
+
+
+template<typename ...Args>
+void test_bad_variadic_array_subscripting(Args ...args) {
+ id arr1;
+ arr1[3] = args; // expected-error {{expression contains unexpanded parameter pack 'args'}}
+}
+
+template<typename ...Args>
+void test_variadic_array_subscripting(Args ...args) {
+ id arr[] = {args[3]...}; // which means: {a[3], b[3], c[3]};
+}
+
+template void test_variadic_array_subscripting(id arg1, NSMutableArray* arg2, id arg3);
+
+@class Key;
+
+template<typename Index, typename ...Args>
+void test_variadic_dictionary_subscripting(Index I, Args ...args) {
+ id arr[] = {args[I]...}; // which means: {a[3], b[3], c[3]};
+}
+
+template void test_variadic_dictionary_subscripting(Key *key, id arg1, NSMutableDictionary* arg2, id arg3);
+
+template<int N>
+id get(NSMutableArray *array) {
+ return array[N]; // array[N] should be a value- and instantiation-dependent ObjCSubscriptRefExpr
+}
+
+struct WeirdIndex {
+ operator int(); // expected-note {{type conversion function declared here}}
+ operator id(); // expected-note {{type conversion function declared here}}
+};
+
+id FUNC(WeirdIndex w) {
+ NSMutableArray *array;
+ return array[w]; // expected-error {{indexing expression is invalid because subscript type 'WeirdIndex' has multiple type conversion functions}}
+}
+
diff --git a/clang/test/SemaObjCXX/objc-decls-inside-namespace.mm b/clang/test/SemaObjCXX/objc-decls-inside-namespace.mm
new file mode 100644
index 0000000..0702071
--- /dev/null
+++ b/clang/test/SemaObjCXX/objc-decls-inside-namespace.mm
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+namespace C {
+
+@protocol P; //expected-error{{Objective-C declarations may only appear in global scope}}
+
+@class Bar; //expected-error{{Objective-C declarations may only appear in global scope}}
+
+@compatibility_alias Foo Bar; //expected-error{{Objective-C declarations may only appear in global scope}}
+
+@interface A //expected-error{{Objective-C declarations may only appear in global scope}}
+@end
+
+@implementation A //expected-error{{Objective-C declarations may only appear in global scope}}
+@end
+
+@protocol P //expected-error{{Objective-C declarations may only appear in global scope}}
+@end
+
+@interface A(C) //expected-error{{Objective-C declarations may only appear in global scope}}
+@end
+
+@implementation A(C) //expected-error{{Objective-C declarations may only appear in global scope}}
+@end
+
+@interface B @end //expected-error{{Objective-C declarations may only appear in global scope}}
+@implementation B //expected-error{{Objective-C declarations may only appear in global scope}}
++ (void) foo {}
+@end
+
+}
+
diff --git a/clang/test/SemaObjCXX/objc-extern-c.mm b/clang/test/SemaObjCXX/objc-extern-c.mm
new file mode 100644
index 0000000..6bd3761
--- /dev/null
+++ b/clang/test/SemaObjCXX/objc-extern-c.mm
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol P // expected-note {{previous}}
+-(void)meth1;
+@end
+
+@interface I // expected-note {{previous}}
+@end
+
+@interface I2
+@end
+@interface I2(C) // expected-note {{previous}}
+@end
+
+extern "C" {
+@protocol P // expected-warning {{duplicate protocol definition of 'P' is ignored}}
+-(void)meth2;
+@end
+
+@interface I // expected-error {{duplicate}}
+@end
+
+@interface I2(C) // expected-warning {{duplicate}}
+@end
+}
+
+void test(id<P> p) {
+ [p meth1];
+ [p meth2]; // expected-warning {{not found}}
+}
diff --git a/clang/test/SemaObjCXX/objc-pointer-conv.mm b/clang/test/SemaObjCXX/objc-pointer-conv.mm
new file mode 100644
index 0000000..611b7bc
--- /dev/null
+++ b/clang/test/SemaObjCXX/objc-pointer-conv.mm
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+typedef const void * VoidStar;
+
+typedef struct __CFDictionary * CFMDRef;
+
+void RandomFunc(CFMDRef theDict, const void *key, const void *value);
+
+@interface Foo
+- (void)_apply:(void (*)(const void *, const void *, void *))func context:(void *)context;
+- (void)a:(id *)objects b:(id *)keys;
+@end
+
+@implementation Foo
+- (void)_apply:(void (*)(const void *, const void *, void *))func context:(void *)context {
+ id item;
+ id obj;
+ func(item, obj, context);
+}
+
+- (void)a:(id *)objects b:(id *)keys {
+ VoidStar dict;
+ id key;
+ RandomFunc((CFMDRef)dict, key, objects[3]);
+}
+@end
+
+@interface I
+- (void) Meth : (I*) Arg; // expected-note{{passing argument to parameter 'Arg' here}}
+@end
+
+void Func (I* arg); // expected-note {{candidate function not viable: no known conversion from 'const I *' to 'I *' for 1st argument}}
+
+void foo(const I *p, I* sel) {
+ [sel Meth : p]; // expected-error {{cannot initialize a parameter of type 'I *' with an lvalue of type 'const I *'}}
+ Func(p); // expected-error {{no matching function for call to 'Func'}}
+}
+
+@interface DerivedFromI : I
+@end
+
+void accept_derived(DerivedFromI*);
+
+void test_base_to_derived(I* i) {
+ accept_derived(i); // expected-warning{{incompatible pointer types passing 'I *' to parameter of type 'DerivedFromI *'}}
+ DerivedFromI *di = i; // expected-warning{{incompatible pointer types initializing 'DerivedFromI *' with an expression of type 'I *'}}
+ DerivedFromI *di2 = (DerivedFromI *)i;
+}
diff --git a/clang/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm b/clang/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm
new file mode 100644
index 0000000..7be5f17
--- /dev/null
+++ b/clang/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify %s
+@interface INTF @end
+
+extern INTF* p2;
+extern __strong INTF* p2;
+
+extern __strong id p1;
+extern id p1;
+
+extern id CFRunLoopGetMain();
+extern __strong id CFRunLoopGetMain();
+
+extern __strong id CFRunLoopGetMain2();
+extern id CFRunLoopGetMain2();
+
+extern INTF* CFRunLoopGetMain3();
+extern __strong INTF* CFRunLoopGetMain3();
+
+extern __strong INTF* CFRunLoopGetMain4();
+extern INTF* CFRunLoopGetMain4();
+
+typedef id ID;
+extern ID CFRunLoopGetMain5();
+extern __strong id CFRunLoopGetMain5();
+
+extern __strong id CFRunLoopGetMain6();
+extern ID CFRunLoopGetMain6();
+
+extern ID CFRunLoopGetMain7();
+extern __strong ID CFRunLoopGetMain7();
+
+extern __strong ID CFRunLoopGetMain8();
+extern ID CFRunLoopGetMain8();
+
+extern __weak id WLoopGetMain(); // expected-note {{previous declaration is here}}
+extern id WLoopGetMain(); // expected-error {{functions that differ only in their return type cannot be overloaded}}
+
+extern id p3; // expected-note {{previous definition is here}}
+extern __weak id p3; // expected-error {{redefinition of 'p3' with a different type}}
+
+extern void *p4; // expected-note {{previous definition is here}}
+extern void * __strong p4; // expected-error {{redefinition of 'p4' with a different type}}
+
+extern id p5;
+extern __strong id p5;
+
+extern char* __strong p6; // expected-note {{previous definition is here}}
+extern char* p6; // expected-error {{redefinition of 'p6' with a different type}}
+
+extern __strong char* p7; // expected-note {{previous definition is here}}
+extern char* p7; // expected-error {{redefinition of 'p7' with a different type}}
diff --git a/clang/test/SemaObjCXX/overload-1.mm b/clang/test/SemaObjCXX/overload-1.mm
new file mode 100644
index 0000000..fc17ca2
--- /dev/null
+++ b/clang/test/SemaObjCXX/overload-1.mm
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol Proto1 @end
+
+@protocol Proto2 @end
+
+void f(id<Proto1> *) { } // expected-note {{previous definition is here}}
+
+void f(id<Proto1, Proto2> *) { } // expected-error {{conflicting types for 'f'}}
+
+void f(Class<Proto1> *) { } // expected-note {{previous definition is here}}
+
+void f(Class<Proto1, Proto2> *) { } // expected-error {{conflicting types for 'f'}}
+
+@interface I @end
+
+void f(I<Proto1> *) { } // expected-note {{previous definition is here}}
+
+void f(I<Proto1, Proto2> *) { } // expected-error {{conflicting types for 'f'}}
+
+@interface I1 @end
+
+void f1(I<Proto1> *) { }
+
+void f1(I1<Proto1, Proto2> *) { }
diff --git a/clang/test/SemaObjCXX/overload-gc.mm b/clang/test/SemaObjCXX/overload-gc.mm
new file mode 100644
index 0000000..5488ea5
--- /dev/null
+++ b/clang/test/SemaObjCXX/overload-gc.mm
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -triple i386-apple-darwin9 -fobjc-gc -verify %s
+
+void f0(__weak id *);
+
+void test_f0(id *x) {
+ f0(x);
+}
+
+@interface A
+@end
+
+void f1(__weak id*);
+void test_f1(__weak A** a) {
+ f1(a);
+}
+
+@interface B : A
+@end
+
+void f2(__weak A**);
+void test_f2(__weak B** b) {
+ f2(b);
+}
+
diff --git a/clang/test/SemaObjCXX/overload.mm b/clang/test/SemaObjCXX/overload.mm
new file mode 100644
index 0000000..6f24c59
--- /dev/null
+++ b/clang/test/SemaObjCXX/overload.mm
@@ -0,0 +1,179 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+@interface Foo
+@end
+
+@implementation Foo
+
+void func(id);
+
++ zone {
+ func(self);
+ return self;
+}
+@end
+
+@protocol P0
+@end
+
+@protocol P1
+@end
+
+@interface A <P0>
+@end
+
+@interface B : A
+@end
+
+@interface C <P1>
+@end
+
+int& f(A*); // expected-note {{candidate}}
+float& f(B*); // expected-note {{candidate}}
+void g(A*);
+
+int& h(A*);
+float& h(id);
+
+void test0(A* a, B* b, id val) {
+ int& i1 = f(a);
+ float& f1 = f(b);
+
+ // GCC succeeds here, which is clearly ridiculous.
+ float& f2 = f(val); // expected-error {{ambiguous}}
+
+ g(a);
+ g(b);
+ g(val);
+ int& i2 = h(a);
+ float& f3 = h(val);
+
+ int& i3 = h(b);
+}
+
+void test1(A* a) {
+ B* b = a; // expected-warning{{incompatible pointer types initializing 'B *' with an expression of type 'A *'}}
+ B *c; c = a; // expected-warning{{incompatible pointer types assigning to 'B *' from 'A *'}}
+}
+
+void test2(A** ap) {
+ B** bp = ap; // expected-warning{{incompatible pointer types initializing 'B **' with an expression of type 'A **'}}
+ bp = ap; // expected-warning{{incompatible pointer types assigning to 'B **' from 'A **'}}
+}
+
+// FIXME: we should either allow overloading here or give a better diagnostic
+int& cv(A*); // expected-note {{previous declaration}} expected-note 2 {{not viable}}
+float& cv(const A*); // expected-error {{cannot be overloaded}}
+
+int& cv2(void*);
+float& cv2(const void*);
+
+void cv_test(A* a, B* b, const A* ac, const B* bc) {
+ int &i1 = cv(a);
+ int &i2 = cv(b);
+ float &f1 = cv(ac); // expected-error {{no matching function}}
+ float &f2 = cv(bc); // expected-error {{no matching function}}
+ int& i3 = cv2(a);
+ float& f3 = cv2(ac);
+}
+
+// We agree with GCC that these can't be overloaded.
+int& qualid(id<P0>); // expected-note {{previous declaration}} expected-note {{not viable}}
+float& qualid(id<P1>); // expected-error {{cannot be overloaded}}
+
+void qualid_test(A *a, B *b, C *c) {
+ int& i1 = qualid(a);
+ int& i2 = qualid(b);
+
+ // This doesn't work only because the overload was rejected above.
+ float& f1 = qualid(c); // expected-error {{no matching function}}
+
+ id<P0> p1 = 0;
+ p1 = 0;
+}
+
+
+@class NSException;
+typedef struct {
+ void (*throw_exc)(id);
+}
+objc_exception_functions_t;
+
+void (*_NSExceptionRaiser(void))(NSException *) {
+ objc_exception_functions_t exc_funcs;
+ return exc_funcs.throw_exc; // expected-warning{{incompatible pointer types returning 'void (*)(id)' from a function with result type 'void (*)(NSException *)'}}
+}
+
+namespace test5 {
+ void foo(bool);
+ void foo(void *);
+
+ void test(id p) {
+ foo(p);
+ }
+}
+
+// rdar://problem/8592139
+namespace test6 {
+ void foo(id); // expected-note{{candidate function}}
+ void foo(A*) __attribute__((unavailable)); // expected-note {{explicitly made unavailable}}
+
+ void test(B *b) {
+ foo(b); // expected-error {{call to unavailable function 'foo'}}
+ }
+}
+
+namespace rdar8714395 {
+ int &f(const void*);
+ float &f(const Foo*);
+
+ int &f2(const void*);
+ float &f2(Foo const* const *);
+
+ int &f3(const void*);
+ float &f3(Foo const**);
+
+ void g(Foo *p) {
+ float &fr = f(p);
+ float &fr2 = f2(&p);
+ int &ir = f3(&p);
+ }
+
+
+}
+
+namespace rdar8734046 {
+ void f1(id);
+ void f2(id<P0>);
+ void g(const A *a) {
+ f1(a);
+ f2(a);
+ }
+}
+
+namespace PR9735 {
+ int &f3(const A*);
+ float &f3(const void*);
+
+ void test_f(B* b, const B* bc) {
+ int &ir1 = f3(b);
+ int &ir2 = f3(bc);
+ }
+}
+
+@interface D : B
+@end
+
+namespace rdar9327203 {
+ int &f(void* const&, int);
+ float &f(void* const&, long);
+
+ void g(id x) {
+ int &fr = (f)(x, 0);
+ }
+}
+
+namespace class_id {
+ // it's okay to overload Class with id.
+ void f(Class) { }
+ void f(id) { }
+}
diff --git a/clang/test/SemaObjCXX/parameters.mm b/clang/test/SemaObjCXX/parameters.mm
new file mode 100644
index 0000000..1a7869d
--- /dev/null
+++ b/clang/test/SemaObjCXX/parameters.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -verify %s
+
+@interface A
+@end
+
+template<typename T>
+struct X0 {
+ void f(T); // expected-error{{interface type 'A' cannot be passed by value}}
+};
+
+X0<A> x0a; // expected-note{{instantiation}}
+
+
+struct test2 { virtual void foo() = 0; }; // expected-note {{unimplemented}}
+@interface Test2
+- (void) foo: (test2) foo; // expected-error {{parameter type 'test2' is an abstract class}}
+@end
diff --git a/clang/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm b/clang/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm
new file mode 100644
index 0000000..d0f8404
--- /dev/null
+++ b/clang/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface G
+@end
+
+@interface F
+- (void)bar:(id *)objects;
+- (void)foo:(G**)objects;
+@end
+
+
+void a() {
+ F *b;
+ G **keys;
+ [b bar:keys];
+
+ id *PID;
+ [b foo:PID];
+
+}
+
+
+// pr7936
+@interface I1 @end
+
+class Wrapper {
+public:
+ operator id() const { return (id)_value; }
+ operator Class() const { return (Class)_value; }
+ operator I1*() const { return (I1*)_value; }
+
+ bool Compare(id obj) { return *this == obj; }
+ bool CompareClass(Class obj) { return *this == obj; }
+ bool CompareI1(I1* obj) { return *this == obj; }
+
+ Wrapper &operator*();
+ Wrapper &operator[](int);
+ Wrapper& operator->*(int);
+
+private:
+ long _value;
+};
+
+void f() {
+ Wrapper w;
+ w[0];
+ *w;
+ w->*(0);
+}
diff --git a/clang/test/SemaObjCXX/propert-dot-error.mm b/clang/test/SemaObjCXX/propert-dot-error.mm
new file mode 100644
index 0000000..2237411
--- /dev/null
+++ b/clang/test/SemaObjCXX/propert-dot-error.mm
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar: // 8379892
+
+struct X {
+ X();
+ X(const X&);
+ ~X();
+
+ static int staticData;
+ int data;
+ void method();
+};
+
+@interface A {
+ X xval;
+}
+
+- (X)x;
+- (void)setx:(X)x;
+@end
+
+void f(A* a) {
+ a.x = X(); // expected-error {{no setter method 'setX:' for assignment to property}}
+}
+
+struct Y : X { };
+
+@interface B {
+@private
+ Y *y;
+}
+- (Y)value;
+- (void)setValue : (Y) arg;
+@property Y value;
+@end
+
+void g(B *b) {
+ b.value.data = 17; // expected-error {{not assignable}}
+ b.value.staticData = 17;
+ b.value.method();
+}
+
+@interface C
+@end
+
+@implementation C
+- (void)method:(B *)b {
+ // <rdar://problem/8985943>
+ b.operator+ = 17; // expected-error{{'operator+' is not a valid property name (accessing an object of type 'B *')}}
+ b->operator+ = 17; // expected-error{{'B' does not have a member named 'operator+'}}
+}
+@end
+
+// PR9759
+class Forward;
+@interface D {
+@public
+ int ivar;
+}
+
+@property int property;
+@end
+
+void testD(D *d) {
+ d.Forward::property = 17; // expected-error{{property access cannot be qualified with 'Forward::'}}
+ d->Forward::ivar = 12; // expected-error{{ivar access cannot be qualified with 'Forward::'}}
+ d.D::property = 17; // expected-error{{expected a class or namespace}}
+ d->D::ivar = 12; // expected-error{{expected a class or namespace}}
+}
diff --git a/clang/test/SemaObjCXX/properties.mm b/clang/test/SemaObjCXX/properties.mm
new file mode 100644
index 0000000..3c6b138
--- /dev/null
+++ b/clang/test/SemaObjCXX/properties.mm
@@ -0,0 +1,108 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Wno-objc-root-class %s
+
+struct X {
+ void f() const;
+ ~X();
+};
+
+@interface A {
+ X x_;
+}
+
+- (const X&)x;
+- (void)setx:(const X&)other;
+@end
+
+@implementation A
+
+- (const X&)x { return x_; }
+- (void)setx:(const X&)other { x_ = other; }
+- (void)method {
+ self.x.f();
+}
+@end
+
+// rdar://problem/10444030
+@interface Test2
+- (void) setY: (int) y;
+- (int) z;
+@end
+void test2(Test2 *a) {
+ auto y = a.y; // expected-error {{expected getter method not found on object of type 'Test2 *'}}
+ auto z = a.z;
+}
+
+// rdar://problem/10672108
+@interface Test3
+- (int) length;
+@end
+void test3(Test3 *t) {
+ char vla[t.length] = {}; // expected-error {{variable-sized object may not be initialized}}
+ char *heaparray = new char[t.length];
+}
+
+// <rdar://problem/10672501>
+namespace std {
+ template<typename T> void count();
+}
+
+@interface Test4
+- (X&) prop;
+@end
+
+void test4(Test4 *t) {
+ (void)const_cast<const X&>(t.prop);
+ (void)dynamic_cast<X&>(t.prop);
+ (void)reinterpret_cast<int&>(t.prop);
+}
+
+@interface Test5 {
+@public
+ int count;
+}
+@property int count;
+@end
+
+void test5(Test5* t5) {
+ if (t5.count < 2) { }
+ if (t5->count < 2) { }
+}
+
+
+@interface Test6
++ (Class)class;
+- (Class)class;
+@end
+
+void test6(Test6 *t6) {
+ Class x = t6.class;
+ Class x2 = Test6.class;
+}
+
+template<typename T>
+void test6_template(T *t6) {
+ Class x = t6.class;
+}
+
+template void test6_template(Test6*);
+
+// rdar://problem/10965735
+struct Test7PointerMaker {
+ operator char *() const;
+};
+@interface Test7
+- (char*) implicit_property;
+- (char) bad_implicit_property;
+- (Test7PointerMaker) implicit_struct_property;
+@property int *explicit_property;
+@property int bad_explicit_property;
+@property Test7PointerMaker explicit_struct_property;
+@end
+void test7(Test7 *ptr) {
+ delete ptr.implicit_property;
+ delete ptr.bad_implicit_property; // expected-error {{cannot delete expression of type 'char'}}
+ delete ptr.explicit_property;
+ delete ptr.bad_explicit_property; // expected-error {{cannot delete expression of type 'int'}}
+ delete ptr.implicit_struct_property;
+ delete ptr.explicit_struct_property;
+}
diff --git a/clang/test/SemaObjCXX/property-reference.mm b/clang/test/SemaObjCXX/property-reference.mm
new file mode 100644
index 0000000..b86ae5e
--- /dev/null
+++ b/clang/test/SemaObjCXX/property-reference.mm
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://9070460
+
+class TCPPObject
+{
+public:
+ TCPPObject(const TCPPObject& inObj);
+ TCPPObject();
+ ~TCPPObject();
+
+ TCPPObject& operator=(const TCPPObject& inObj)const ; // expected-note {{'operator=' declared here}}
+
+ void* Data();
+
+private:
+ void* fData;
+};
+
+
+typedef const TCPPObject& CREF_TCPPObject;
+
+@interface TNSObject
+@property (assign, readwrite, nonatomic) CREF_TCPPObject cppObjectNonAtomic;
+@property (assign, readwrite) CREF_TCPPObject cppObjectAtomic;
+@property (assign, readwrite, nonatomic) const TCPPObject& cppObjectDynamic;
+@end
+
+
+@implementation TNSObject
+
+@synthesize cppObjectNonAtomic;
+@synthesize cppObjectAtomic; // expected-error{{atomic property of reference type 'CREF_TCPPObject' (aka 'const TCPPObject &') cannot have non-trivial assignment operator}}
+@dynamic cppObjectDynamic;
+
+- (const TCPPObject&) cppObjectNonAtomic
+{
+ return cppObjectNonAtomic;
+}
+
+- (void) setCppObjectNonAtomic: (const TCPPObject&)cppObject
+{
+ cppObjectNonAtomic = cppObject;
+}
+@end
+
+
+// <rdar://problem/11052352>
+@interface NSObject
++ alloc;
+- init;
+- class;
+@end
+
+template<typename T> void f() {
+ NSObject *o = [NSObject.alloc init];
+ [o class];
+}
+
+template void f<int>();
diff --git a/clang/test/SemaObjCXX/property-synthesis-error.mm b/clang/test/SemaObjCXX/property-synthesis-error.mm
new file mode 100644
index 0000000..4b726d8
--- /dev/null
+++ b/clang/test/SemaObjCXX/property-synthesis-error.mm
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar: //8550657
+
+@interface NSArray @end
+
+@interface NSMutableArray : NSArray @end
+
+@interface MyClass
+{
+ NSMutableArray * _array;
+}
+
+@property (readonly) NSMutableArray * array;
+
+@end
+
+@interface MyClass ()
+
+@property (readwrite) NSMutableArray * array;
+
+@end
+
+@implementation MyClass
+
+@synthesize array=_array;
+
+@end
+
+int main(void)
+{
+ return 0;
+}
+
+// rdar://6137845
+class TCPPObject
+{
+public:
+ TCPPObject(const TCPPObject& inObj);
+ TCPPObject();
+ ~TCPPObject();
+ TCPPObject& operator=(const TCPPObject& inObj); // expected-note {{'operator=' declared here}}
+private:
+ void* fData;
+};
+
+class Trivial
+{
+public:
+ Trivial(const Trivial& inObj);
+ Trivial();
+ ~Trivial();
+private:
+ void* fData;
+};
+
+@interface MyDocument
+{
+@private
+ TCPPObject _cppObject;
+ TCPPObject _ncppObject;
+ Trivial _tcppObject;
+}
+@property (assign, readwrite) const TCPPObject& cppObject;
+@property (assign, readwrite, nonatomic) const TCPPObject& ncppObject;
+@property (assign, readwrite) const Trivial& tcppObject;
+@end
+
+@implementation MyDocument
+
+@synthesize cppObject = _cppObject; // expected-error {{atomic property of reference type 'const TCPPObject &' cannot have non-trivial assignment operator}}
+@synthesize ncppObject = _ncppObject;
+
+@synthesize tcppObject = _tcppObject;
+@end
diff --git a/clang/test/SemaObjCXX/property-type-mismatch.mm b/clang/test/SemaObjCXX/property-type-mismatch.mm
new file mode 100644
index 0000000..059793c
--- /dev/null
+++ b/clang/test/SemaObjCXX/property-type-mismatch.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://9740328
+
+@protocol P1;
+
+@interface NSObject
+@end
+
+@interface A : NSObject
+@property (assign) NSObject<P1> *prop;
+@end
+
+@protocol P2 <P1>
+@end
+
+@interface B : A
+@property (assign) NSObject<P2> *prop;
+@end
+
diff --git a/clang/test/SemaObjCXX/protocol-lookup.mm b/clang/test/SemaObjCXX/protocol-lookup.mm
new file mode 100644
index 0000000..bd8444c
--- /dev/null
+++ b/clang/test/SemaObjCXX/protocol-lookup.mm
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+@protocol NSObject
+- retain;
+- release;
+@end
+
+@interface NSObject
+- init;
+- dealloc;
+@end
+
+@protocol Foo <NSObject>
+@end
+
+@protocol Bar <Foo>
+@end
+
+@interface Baz : NSObject {
+ id <Foo> _foo;
+ id <Bar> _bar;
+}
+- (id)initWithFoo:(id <Foo>)foo bar:(id <Bar>)bar;
+@end
+
+@implementation Baz
+
+- (id)init
+{
+ return [self initWithFoo:0 bar:0];
+}
+
+- (id)initWithFoo:(id <Foo>)foo bar:(id <Bar>)bar
+{
+ self = [super init];
+ if (self != 0) {
+ _foo = [foo retain];
+ _bar = [bar retain];
+ }
+ return self;
+}
+
+- dealloc
+{
+ [_foo release];
+ [_bar release];
+ [super dealloc];
+ return 0;
+}
+
+@end
+
+void rdar8575095(id a) {
+ [id<NSObject>(a) retain];
+ id<NSObject> x(id<NSObject>(0));
+ id<NSObject> x2(id<NSObject>(y)); // expected-warning{{parentheses were disambiguated as a function declarator}}
+}
diff --git a/clang/test/SemaObjCXX/references.mm b/clang/test/SemaObjCXX/references.mm
new file mode 100644
index 0000000..3a52200
--- /dev/null
+++ b/clang/test/SemaObjCXX/references.mm
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -verify -emit-llvm -o - %s
+
+// Test reference binding.
+
+typedef struct {
+ int f0;
+ int f1;
+} T;
+
+@interface A
+@property (assign) T p0;
+@property (assign) T& p1;
+@end
+
+int f0(const T& t) {
+ return t.f0;
+}
+
+int f1(A *a) {
+ return f0(a.p0);
+}
+
+int f2(A *a) {
+ return f0(a.p1);
+}
+
+// PR7740
+@class NSString;
+
+void f3(id);
+void f4(NSString &tmpstr) {
+ f3(&tmpstr);
+}
+
+// PR7741
+@protocol P1 @end
+@protocol P2 @end
+@protocol P3 @end
+@interface foo<P1> {} @end
+@interface bar : foo <P1, P2, P3> {} @end
+typedef bar baz;
+
+struct ToBar {
+ operator bar&() const;
+};
+
+void f5(foo&);
+void f5b(foo<P1>&);
+void f5c(foo<P2>&);
+void f5d(foo<P3>&);
+void f6(baz* x) {
+ f5(*x);
+ f5b(*x);
+ f5c(*x);
+ f5d(*x);
+ (void)((foo&)*x);
+ f5(ToBar());
+ f5b(ToBar());
+ f5c(ToBar());
+ f5d(ToBar());
+ (void)((foo&)ToBar());
+}
diff --git a/clang/test/SemaObjCXX/reinterpret-cast-objc-pointertype.mm b/clang/test/SemaObjCXX/reinterpret-cast-objc-pointertype.mm
new file mode 100644
index 0000000..fcabade
--- /dev/null
+++ b/clang/test/SemaObjCXX/reinterpret-cast-objc-pointertype.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface NSString @end
+
+typedef const struct __CFString * CFStringRef;
+const NSString* fRef;
+
+CFStringRef func() {
+ return reinterpret_cast<CFStringRef>(fRef);
+}
+
+CFStringRef fRef1;
+
+const NSString* func1() {
+ return reinterpret_cast<const NSString*>(fRef1);
+}
+
+@interface I @end
+const I *fRef2;
+
+const NSString* func2() {
+ return reinterpret_cast<const NSString*>(fRef2);
+}
diff --git a/clang/test/SemaObjCXX/related-result-type-inference.mm b/clang/test/SemaObjCXX/related-result-type-inference.mm
new file mode 100644
index 0000000..675e6ac
--- /dev/null
+++ b/clang/test/SemaObjCXX/related-result-type-inference.mm
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -verify %s
+
+@interface Unrelated
+@end
+
+@interface NSObject
++ (id)new;
++ (id)alloc;
+- (NSObject *)init;
+
+- (id)retain; // expected-note 2{{instance method 'retain' is assumed to return an instance of its receiver type ('NSArray *')}}
+- autorelease;
+
+- (id)self;
+
+- (id)copy;
+- (id)mutableCopy;
+
+// Do not infer when instance/class mismatches
+- (id)newNotInferred;
+- (id)alloc;
++ (id)initWithBlarg;
++ (id)self;
+
+// Do not infer when the return types mismatch.
+- (Unrelated *)initAsUnrelated;
+@end
+
+@interface NSString : NSObject
+- (id)init;
+- (id)initWithCString:(const char*)string;
+@end
+
+@interface NSArray : NSObject
+- (unsigned)count;
+@end
+
+@interface NSBlah
+@end
+
+@interface NSMutableArray : NSArray
+@end
+
+@interface NSBlah ()
++ (Unrelated *)newUnrelated;
+@end
+
+void test_inference() {
+ // Inference based on method family
+ __typeof__(([[NSString alloc] init])) *str = (NSString**)0;
+ __typeof__(([[[[NSString new] self] retain] autorelease])) *str2 = (NSString **)0;
+ __typeof__(([[NSString alloc] initWithCString:"blah"])) *str3 = (NSString**)0;
+
+ // Not inferred
+ __typeof__(([[NSString new] copy])) *id1 = (id*)0;
+
+ // Not inferred due to instance/class mismatches
+ __typeof__(([[NSString new] newNotInferred])) *id2 = (id*)0;
+ __typeof__(([[NSString new] alloc])) *id3 = (id*)0;
+ __typeof__(([NSString self])) *id4 = (id*)0;
+ __typeof__(([NSString initWithBlarg])) *id5 = (id*)0;
+
+ // Not inferred due to return type mismatch
+ __typeof__(([[NSString alloc] initAsUnrelated])) *unrelated = (Unrelated**)0;
+ __typeof__(([NSBlah newUnrelated])) *unrelated2 = (Unrelated**)0;
+
+ NSArray *arr = [[NSMutableArray alloc] init];
+ NSMutableArray *marr = [arr retain]; // expected-warning{{incompatible pointer types initializing 'NSMutableArray *' with an expression of type 'NSArray *'}}
+ marr = [arr retain]; // expected-warning{{incompatible pointer types assigning to 'NSMutableArray *' from 'NSArray *'}}
+ arr = [marr retain];
+}
diff --git a/clang/test/SemaObjCXX/reserved-keyword-methods.mm b/clang/test/SemaObjCXX/reserved-keyword-methods.mm
new file mode 100644
index 0000000..1302128
--- /dev/null
+++ b/clang/test/SemaObjCXX/reserved-keyword-methods.mm
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define FOR_EACH_KEYWORD(macro) \
+macro(asm) \
+macro(bool) \
+macro(catch) \
+macro(class) \
+macro(const_cast) \
+macro(delete) \
+macro(dynamic_cast) \
+macro(explicit) \
+macro(export) \
+macro(false) \
+macro(friend) \
+macro(mutable) \
+macro(namespace) \
+macro(new) \
+macro(operator) \
+macro(private) \
+macro(protected) \
+macro(public) \
+macro(reinterpret_cast) \
+macro(static_cast) \
+macro(template) \
+macro(this) \
+macro(throw) \
+macro(true) \
+macro(try) \
+macro(typename) \
+macro(typeid) \
+macro(using) \
+macro(virtual) \
+macro(wchar_t)
+
+
+#define DECLARE_METHOD(name) - (void)name;
+#define DECLARE_PROPERTY_WITH_GETTER(name) @property (getter=name) int prop_##name;
+@interface A
+//FOR_EACH_KEYWORD(DECLARE_METHOD)
+FOR_EACH_KEYWORD(DECLARE_PROPERTY_WITH_GETTER)
+@end
+
diff --git a/clang/test/SemaObjCXX/standard-conversion-to-bool.mm b/clang/test/SemaObjCXX/standard-conversion-to-bool.mm
new file mode 100644
index 0000000..2e69848
--- /dev/null
+++ b/clang/test/SemaObjCXX/standard-conversion-to-bool.mm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@class NSString;
+id a;
+NSString *b;
+
+void f() {
+ bool b1 = a;
+ bool b2 = b;
+}
+
+
diff --git a/clang/test/SemaObjCXX/static-cast.mm b/clang/test/SemaObjCXX/static-cast.mm
new file mode 100644
index 0000000..e282702
--- /dev/null
+++ b/clang/test/SemaObjCXX/static-cast.mm
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol NSTextViewDelegate;
+
+@interface NSResponder @end
+
+class AutoreleaseObject
+{
+public:
+ AutoreleaseObject();
+ ~AutoreleaseObject();
+
+
+ AutoreleaseObject& operator=(NSResponder* inValue);
+ AutoreleaseObject& operator=(const AutoreleaseObject& inValue);
+
+ AutoreleaseObject(const AutoreleaseObject& inValue);
+
+ operator NSResponder*() const;
+};
+
+
+void InvokeSaveFocus()
+{
+ AutoreleaseObject mResolvedFirstResponder;
+ id<NSTextViewDelegate> Mydelegate;
+ mResolvedFirstResponder = static_cast<NSResponder*>(Mydelegate);
+}
+
diff --git a/clang/test/SemaObjCXX/unknown-anytype.mm b/clang/test/SemaObjCXX/unknown-anytype.mm
new file mode 100644
index 0000000..b28b135
--- /dev/null
+++ b/clang/test/SemaObjCXX/unknown-anytype.mm
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fdebugger-support -funknown-anytype -fsyntax-only -verify %s
+
+// rdar://problem/9416370
+namespace test0 {
+ void test(id x) {
+ if ([x foo]) {} // expected-error {{no known method '-foo'; cast the message send to the method's return type}}
+ [x foo]; // expected-error {{no known method '-foo'; cast the message send to the method's return type}}
+ }
+}
diff --git a/clang/test/SemaObjCXX/vararg-non-pod.mm b/clang/test/SemaObjCXX/vararg-non-pod.mm
new file mode 100644
index 0000000..5a6281d
--- /dev/null
+++ b/clang/test/SemaObjCXX/vararg-non-pod.mm
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-error=non-pod-varargs
+
+extern char version[];
+
+@protocol P;
+
+class C {
+public:
+ C(int);
+};
+
+@interface D
+- (void)g:(int)a, ...;
+@end
+
+void t1(D *d)
+{
+ C c(10);
+
+ [d g:10, c]; // expected-warning{{cannot pass object of non-POD type 'C' through variadic method; call will abort at runtime}}
+ [d g:10, version];
+}
+
+void t2(D *d, id p)
+{
+ [d g:10, p];
+}
+
+void t3(D *d, id<P> p)
+{
+ [d g:10, p];
+}
diff --git a/clang/test/SemaObjCXX/vla.mm b/clang/test/SemaObjCXX/vla.mm
new file mode 100644
index 0000000..d6da1c0
--- /dev/null
+++ b/clang/test/SemaObjCXX/vla.mm
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface Data
+- (unsigned)length;
+- (void)getData:(void*)buffer;
+@end
+
+void test(Data *d) {
+ char buffer[[d length]];
+ [d getData:buffer];
+}
+
diff --git a/clang/test/SemaObjCXX/void_to_obj.mm b/clang/test/SemaObjCXX/void_to_obj.mm
new file mode 100644
index 0000000..97151fd
--- /dev/null
+++ b/clang/test/SemaObjCXX/void_to_obj.mm
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+// <rdar://problem/6463729>
+@class XX;
+
+void func() {
+ XX *obj;
+ void *vv;
+
+ obj = vv; // expected-error{{assigning to 'XX *' from incompatible type 'void *'}}
+}
+
+// <rdar://problem/7952457>
+@interface I
+{
+ void* delegate;
+}
+- (I*) Meth;
+- (I*) Meth1;
+@end
+
+@implementation I
+- (I*) Meth { return static_cast<I*>(delegate); }
+- (I*) Meth1 { return reinterpret_cast<I*>(delegate); }
+@end
+
diff --git a/clang/test/SemaObjCXX/warn-strict-selector-match.mm b/clang/test/SemaObjCXX/warn-strict-selector-match.mm
new file mode 100644
index 0000000..330b10b
--- /dev/null
+++ b/clang/test/SemaObjCXX/warn-strict-selector-match.mm
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -Wstrict-selector-match -fsyntax-only -verify %s
+
+@interface Base
+- (id) meth1: (Base *)arg1; // expected-note {{using}}
+- (id) window; // expected-note {{using}}
+@end
+
+@interface Derived: Base
+- (id) meth1: (Derived *)arg1; // expected-note {{also found}}
+- (Base *) window; // expected-note {{also found}}
+@end
+
+void foo(void) {
+ id r;
+
+ [r meth1:r]; // expected-warning {{multiple methods named 'meth1:' found}}
+ [r window]; // expected-warning {{multiple methods named 'window' found}}
+}
diff --git a/clang/test/SemaOpenCL/address-spaces.cl b/clang/test/SemaOpenCL/address-spaces.cl
new file mode 100644
index 0000000..6ab10b3
--- /dev/null
+++ b/clang/test/SemaOpenCL/address-spaces.cl
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+__constant int ci = 1;
+
+__kernel void foo(__global int *gip) {
+ __local int li;
+ __local int lj = 2; // expected-error {{'__local' variable cannot have an initializer}}
+
+ int *ip;
+ ip = gip; // expected-error {{assigning '__global int *' to 'int *' changes address space of pointer}}
+ ip = &li; // expected-error {{assigning '__local int *' to 'int *' changes address space of pointer}}
+ ip = &ci; // expected-error {{assigning '__constant int *' to 'int *' changes address space of pointer}}
+}
diff --git a/clang/test/SemaOpenCL/cond.cl b/clang/test/SemaOpenCL/cond.cl
new file mode 100644
index 0000000..79dc82d
--- /dev/null
+++ b/clang/test/SemaOpenCL/cond.cl
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+typedef __attribute__((ext_vector_type(4))) float float4;
+
+float4 foo(float4 a, float4 b, float4 c, float4 d) { return a < b ? c : d; }
diff --git a/clang/test/SemaOpenCL/extension-fp64.cl b/clang/test/SemaOpenCL/extension-fp64.cl
new file mode 100644
index 0000000..e0c2b1e
--- /dev/null
+++ b/clang/test/SemaOpenCL/extension-fp64.cl
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
+ double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
+ (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
+}
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+void f2(void) {
+ double d;
+ (void) 1.0;
+}
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : disable
+
+void f3(void) {
+ double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
+}
diff --git a/clang/test/SemaOpenCL/init.cl b/clang/test/SemaOpenCL/init.cl
new file mode 100644
index 0000000..b3ecfec
--- /dev/null
+++ b/clang/test/SemaOpenCL/init.cl
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+typedef float float8 __attribute((ext_vector_type(8)));
+
+typedef float float32_t;
+typedef __attribute__(( __vector_size__(16) )) float32_t __neon_float32x4_t;
+typedef struct __simd128_float32_t {
+ __neon_float32x4_t val;
+} float32x4_t;
+
+float8 foo(float8 x) {
+ float32x4_t lo;
+ float32x4_t hi;
+ return (float8) (lo.val, hi.val);
+}
diff --git a/clang/test/SemaOpenCL/vec_compare.cl b/clang/test/SemaOpenCL/vec_compare.cl
new file mode 100644
index 0000000..dd91aa5
--- /dev/null
+++ b/clang/test/SemaOpenCL/vec_compare.cl
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+typedef __attribute__((ext_vector_type(2))) unsigned int uint2;
+typedef __attribute__((ext_vector_type(2))) int int2;
+
+void unsignedCompareOps()
+{
+ uint2 A, B;
+ int2 result = A != B;
+}
+
diff --git a/clang/test/SemaOpenCL/vec_step.cl b/clang/test/SemaOpenCL/vec_step.cl
new file mode 100644
index 0000000..d83ebf1
--- /dev/null
+++ b/clang/test/SemaOpenCL/vec_step.cl
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+
+typedef int int2 __attribute__((ext_vector_type(2)));
+typedef int int3 __attribute__((ext_vector_type(3)));
+typedef int int4 __attribute__((ext_vector_type(4)));
+typedef int int8 __attribute__((ext_vector_type(8)));
+typedef int int16 __attribute__((ext_vector_type(16)));
+
+void foo(int3 arg1, int8 arg2) {
+ int4 auto1;
+ int16 *auto2;
+ int auto3;
+ int2 auto4;
+ struct S *incomplete1;
+
+ int res1[vec_step(arg1) == 4 ? 1 : -1];
+ int res2[vec_step(arg2) == 8 ? 1 : -1];
+ int res3[vec_step(auto1) == 4 ? 1 : -1];
+ int res4[vec_step(*auto2) == 16 ? 1 : -1];
+ int res5[vec_step(auto3) == 1 ? 1 : -1];
+ int res6[vec_step(auto4) == 2 ? 1 : -1];
+ int res7[vec_step(int2) == 2 ? 1 : -1];
+ int res8[vec_step(int3) == 4 ? 1 : -1];
+ int res9[vec_step(int4) == 4 ? 1 : -1];
+ int res10[vec_step(int8) == 8 ? 1 : -1];
+ int res11[vec_step(int16) == 16 ? 1 : -1];
+ int res12[vec_step(void) == 1 ? 1 : -1];
+
+ int res13 = vec_step(*incomplete1); // expected-error {{'vec_step' requires built-in scalar or vector type, 'struct S' invalid}}
+ int res14 = vec_step(int16*); // expected-error {{'vec_step' requires built-in scalar or vector type, 'int16 *' invalid}}
+ int res15 = vec_step(void(void)); // expected-error {{'vec_step' requires built-in scalar or vector type, 'void (void)' invalid}}
+}
diff --git a/clang/test/SemaOpenCL/vector_conv_invalid.cl b/clang/test/SemaOpenCL/vector_conv_invalid.cl
new file mode 100644
index 0000000..e6ef5a4
--- /dev/null
+++ b/clang/test/SemaOpenCL/vector_conv_invalid.cl
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -verify %s
+
+typedef unsigned int uint4 __attribute((ext_vector_type(4)));
+typedef int int4 __attribute((ext_vector_type(4)));
+typedef int int3 __attribute((ext_vector_type(3)));
+typedef unsigned uint3 __attribute((ext_vector_type(3)));
+
+void vector_conv_invalid() {
+ uint4 u = (uint4)(1);
+ int4 i = u; // expected-error{{initializing 'int4' with an expression of incompatible type 'uint4'}}
+ int4 e = (int4)u; // expected-error{{invalid conversion between ext-vector type 'int4' and 'uint4'}}
+
+ uint3 u4 = (uint3)u; // expected-error{{invalid conversion between ext-vector type 'uint3' and 'uint4'}}
+}
diff --git a/clang/test/SemaOpenCL/vector_literals_const.cl b/clang/test/SemaOpenCL/vector_literals_const.cl
new file mode 100644
index 0000000..e761816
--- /dev/null
+++ b/clang/test/SemaOpenCL/vector_literals_const.cl
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+typedef int int2 __attribute((ext_vector_type(2)));
+typedef int int3 __attribute((ext_vector_type(3)));
+typedef int int4 __attribute((ext_vector_type(4)));
+
+__constant int4 i_1_1_1_1 = (int4)(1,2,3,4);
+__constant int4 i_2_1_1 = (int4)((int2)(1,2),3,4);
+__constant int4 i_1_2_1 = (int4)(1,(int2)(2,3),4);
+__constant int4 i_1_1_2 = (int4)(1,2,(int2)(3,4));
+__constant int4 i_2_2 = (int4)((int2)(1,2),(int2)(3,4));
+__constant int4 i_3_1 = (int4)((int3)(1,2,3),4);
+__constant int4 i_1_3 = (int4)(1,(int3)(2,3,4));
+
+typedef float float2 __attribute((ext_vector_type(2)));
+typedef float float3 __attribute((ext_vector_type(3)));
+typedef float float4 __attribute((ext_vector_type(4)));
+
+__constant float4 f_1_1_1_1 = (float4)(1,2,3,4);
+__constant float4 f_2_1_1 = (float4)((float2)(1,2),3,4);
+__constant float4 f_1_2_1 = (float4)(1,(float2)(2,3),4);
+__constant float4 f_1_1_2 = (float4)(1,2,(float2)(3,4));
+__constant float4 f_2_2 = (float4)((float2)(1,2),(float2)(3,4));
+__constant float4 f_3_1 = (float4)((float3)(1,2,3),4);
+__constant float4 f_1_3 = (float4)(1,(float3)(2,3,4));
+
diff --git a/clang/test/SemaOpenCL/vector_literals_invalid.cl b/clang/test/SemaOpenCL/vector_literals_invalid.cl
new file mode 100644
index 0000000..e4e23cd
--- /dev/null
+++ b/clang/test/SemaOpenCL/vector_literals_invalid.cl
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -verify %s
+
+typedef __attribute__(( ext_vector_type(4) )) float float4;
+typedef __attribute__(( ext_vector_type(4) )) int int4;
+typedef __attribute__(( ext_vector_type(8) )) int int8;
+
+void vector_literals_invalid()
+{
+ int4 a = (int4)(1,2,3); // expected-error{{too few elements}}
+ int4 b = (int4)(1,2,3,4,5); // expected-error{{excess elements in vector}}
+ ((float4)(1.0f))++; // expected-error{{cannot increment value of type 'float4'}}
+ int8 d = (int8)(a,(float4)(1)); // expected-error{{initializing 'int' with an expression of incompatible type 'float4'}}
+}
diff --git a/clang/test/SemaTemplate/ackermann.cpp b/clang/test/SemaTemplate/ackermann.cpp
new file mode 100644
index 0000000..9525bfc
--- /dev/null
+++ b/clang/test/SemaTemplate/ackermann.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// template<unsigned M, unsigned N>
+// struct Ackermann {
+// enum {
+// value = M ? (N ? Ackermann<M-1, Ackermann<M, N-1> >::value
+// : Ackermann<M-1, 1>::value)
+// : N + 1
+// };
+// };
+
+template<unsigned M, unsigned N>
+struct Ackermann {
+ enum {
+ value = Ackermann<M-1, Ackermann<M, N-1>::value >::value
+ };
+};
+
+template<unsigned M> struct Ackermann<M, 0> {
+ enum {
+ value = Ackermann<M-1, 1>::value
+ };
+};
+
+template<unsigned N> struct Ackermann<0, N> {
+ enum {
+ value = N + 1
+ };
+};
+
+template<> struct Ackermann<0, 0> {
+ enum {
+ value = 1
+ };
+};
+
+int g0[Ackermann<3, 4>::value == 125 ? 1 : -1];
+
diff --git a/clang/test/SemaTemplate/address-spaces.cpp b/clang/test/SemaTemplate/address-spaces.cpp
new file mode 100644
index 0000000..eda03db
--- /dev/null
+++ b/clang/test/SemaTemplate/address-spaces.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+typedef int __attribute__((address_space(1))) int_1;;
+typedef int __attribute__((address_space(2))) int_2;;
+typedef int __attribute__((address_space(1))) *int_1_ptr;
+typedef int_2 *int_2_ptr;
+
+// Check that we maintain address spaces through template argument
+// deduction from a type.
+template<typename T>
+struct remove_pointer {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_pointer<T *> {
+ typedef T type;
+};
+
+int check_remove0[is_same<remove_pointer<int_1_ptr>::type, int_1>::value? 1 : -1];
+int check_remove1[is_same<remove_pointer<int_2_ptr>::type, int_2>::value? 1 : -1];
+int check_remove2[is_same<remove_pointer<int_2_ptr>::type, int>::value? -1 : 1];
+int check_remove3[is_same<remove_pointer<int_2_ptr>::type, int_1>::value? -1 : 1];
+
+template<typename T>
+struct is_pointer_in_address_space_1 {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_pointer_in_address_space_1<T __attribute__((address_space(1))) *> {
+ static const bool value = true;
+};
+
+int check_ptr_in_as1[is_pointer_in_address_space_1<int_1_ptr>::value? 1 : -1];
+int check_ptr_in_as2[is_pointer_in_address_space_1<int_2_ptr>::value? -1 : 1];
+int check_ptr_in_as3[is_pointer_in_address_space_1<int*>::value? -1 : 1];
+
+// Check that we maintain address spaces through template argument
+// deduction for a call.
+template<typename T>
+void accept_any_pointer(T*) {
+ T *x = 1; // expected-error{{cannot initialize a variable of type '__attribute__((address_space(1))) int *' with an rvalue of type 'int'}} \
+ // expected-error{{cannot initialize a variable of type '__attribute__((address_space(3))) int *' with an rvalue of type 'int'}}
+}
+
+void test_accept_any_pointer(int_1_ptr ip1, int_2_ptr ip2) {
+ static __attribute__((address_space(3))) int array[17];
+ accept_any_pointer(ip1); // expected-note{{in instantiation of}}
+ accept_any_pointer(array); // expected-note{{in instantiation of}}
+}
+
+template<typename T> struct identity {};
+
+template<typename T>
+identity<T> accept_arg_in_address_space_1(__attribute__((address_space(1))) T &ir1);
+
+template<typename T>
+identity<T> accept_any_arg(T &ir1);
+
+void test_arg_in_address_space_1() {
+ static int __attribute__((address_space(1))) int_1;
+ identity<int> ii = accept_arg_in_address_space_1(int_1);
+ identity<int __attribute__((address_space(1)))> ii2 = accept_any_arg(int_1);
+}
+
+// Partial ordering
+template<typename T> int &order1(__attribute__((address_space(1))) T&);
+template<typename T> float &order1(T&);
+
+void test_order1() {
+ static __attribute__((address_space(1))) int i1;
+ int i;
+ int &ir = order1(i1);
+ float &fr = order1(i);
+}
diff --git a/clang/test/SemaTemplate/alias-church-numerals.cpp b/clang/test/SemaTemplate/alias-church-numerals.cpp
new file mode 100644
index 0000000..69d7716
--- /dev/null
+++ b/clang/test/SemaTemplate/alias-church-numerals.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<template<template<typename> class, typename> class T, template<typename> class V> struct PartialApply {
+ template<typename W> using R = T<V, W>;
+};
+
+template<typename T> using Id = T;
+template<template<typename> class, typename X> using Zero = X;
+template<template<template<typename> class, typename> class N, template<typename> class F, typename X> using Succ = F<N<F,X>>;
+
+template<template<typename> class F, typename X> using One = Succ<Zero, F, X>;
+template<template<typename> class F, typename X> using Two = Succ<One, F, X>;
+
+template<template<template<typename> class, typename> class A,
+ template<template<typename> class, typename> class B,
+ template<typename> class F,
+ typename X> using Add = A<F, B<F, X>>;
+
+template<template<template<typename> class, typename> class A,
+ template<template<typename> class, typename> class B,
+ template<typename> class F,
+ typename X> using Mul = A<PartialApply<B,F>::template R, X>;
+
+template<template<typename> class F, typename X> using Four = Add<Two, Two, F, X>;
+template<template<typename> class F, typename X> using Sixteen = Mul<Four, Four, F, X>;
+template<template<typename> class F, typename X> using TwoHundredAndFiftySix = Mul<Sixteen, Sixteen, F, X>;
+
+template<typename T, T N> struct Const { static const T value = N; };
+template<typename A> struct IncrementHelper;
+template<typename T, T N> struct IncrementHelper<Const<T, N>> { using Result = Const<T, N+1>; };
+template<typename A> using Increment = typename IncrementHelper<A>::Result;
+
+using Arr = int[TwoHundredAndFiftySix<Increment, Const<int, 0>>::value];
+using Arr = int[256];
diff --git a/clang/test/SemaTemplate/alias-nested-nontag.cpp b/clang/test/SemaTemplate/alias-nested-nontag.cpp
new file mode 100644
index 0000000..4b5226b
--- /dev/null
+++ b/clang/test/SemaTemplate/alias-nested-nontag.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template<typename T> using Id = T; // expected-note {{type alias template 'Id' declared here}}
+struct U { static Id<int> V; };
+Id<int> ::U::V; // expected-error {{type 'Id<int>' (aka 'int') cannot be used prior to '::' because it has no members}} \
+ expected-error {{C++ requires a type specifier}}
diff --git a/clang/test/SemaTemplate/alias-template-template-param.cpp b/clang/test/SemaTemplate/alias-template-template-param.cpp
new file mode 100644
index 0000000..c22fccb
--- /dev/null
+++ b/clang/test/SemaTemplate/alias-template-template-param.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template<template<typename> class D> using C = D<int>;
+
+// Substitution of the alias template transforms the TemplateSpecializationType
+// 'D<int>' into the DependentTemplateSpecializationType 'T::template U<int>'.
+template<typename T> void f(C<T::template U>);
diff --git a/clang/test/SemaTemplate/alias-templates.cpp b/clang/test/SemaTemplate/alias-templates.cpp
new file mode 100644
index 0000000..75615ee
--- /dev/null
+++ b/clang/test/SemaTemplate/alias-templates.cpp
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<typename S>
+struct A {
+ typedef S B;
+ template<typename T> using C = typename T::B;
+ template<typename T> struct D {
+ template<typename U> using E = typename A<U>::template C<A<T>>;
+ template<typename U> using F = A<E<U>>;
+ template<typename U> using G = C<F<U>>;
+ G<T> g;
+ };
+ typedef decltype(D<B>().g) H;
+ D<H> h;
+ template<typename T> using I = A<decltype(h.g)>;
+ template<typename T> using J = typename A<decltype(h.g)>::template C<I<T>>;
+};
+
+A<int> a;
+A<char>::D<double> b;
+
+template<typename T> T make();
+
+namespace X {
+ template<typename T> struct traits {
+ typedef T thing;
+ typedef decltype(val(make<thing>())) inner_ptr;
+
+ template<typename U> using rebind_thing = typename thing::template rebind<U>;
+ template<typename U> using rebind = traits<rebind_thing<U>>;
+
+ inner_ptr &&alloc();
+ void free(inner_ptr&&);
+ };
+
+ template<typename T> struct ptr_traits {
+ typedef T *type;
+ };
+ template<typename T> using ptr = typename ptr_traits<T>::type;
+
+ template<typename T> struct thing {
+ typedef T inner;
+ typedef ptr<inner> inner_ptr;
+ typedef traits<thing<inner>> traits_type;
+
+ template<typename U> using rebind = thing<U>;
+
+ thing(traits_type &traits) : traits(traits), val(traits.alloc()) {}
+ ~thing() { traits.free(static_cast<inner_ptr&&>(val)); }
+
+ traits_type &traits;
+ inner_ptr val;
+
+ friend inner_ptr val(const thing &t) { return t.val; }
+ };
+
+ template<> struct ptr_traits<bool> {
+ typedef bool &type;
+ };
+ template<> bool &traits<thing<bool>>::alloc() { static bool b; return b; }
+ template<> void traits<thing<bool>>::free(bool&) {}
+}
+
+typedef X::traits<X::thing<int>> itt;
+
+itt::thing::traits_type itr;
+itt::thing ith(itr);
+
+itt::rebind<bool> btr;
+itt::rebind_thing<bool> btt(btr);
+
+namespace PR11848 {
+ template<typename T> using U = int;
+
+ template<typename T, typename ...Ts>
+ void f(U<T> i, U<Ts> ...is) { // expected-error {{type 'U<Ts>' (aka 'int') of function parameter pack does not contain any unexpanded parameter packs}}
+ return i + f<Ts...>(is...); // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
+ }
+
+ template<typename ...Ts>
+ struct S {
+ S(U<Ts>...ts); // expected-error {{does not contain any unexpanded parameter packs}}
+ };
+
+ template<typename T>
+ struct Hidden1 {
+ template<typename ...Ts>
+ Hidden1(typename T::template U<Ts> ...ts); // expected-error{{type 'typename Hide::U<Ts>' (aka 'int') of function parameter pack does not contain any unexpanded parameter packs}}
+ };
+
+ template<typename T, typename ...Ts>
+ struct Hidden2 {
+ Hidden2(typename T::template U<Ts> ...ts);
+ };
+
+ struct Hide {
+ template<typename T> using U = int;
+ };
+
+ Hidden1<Hide> h1; // expected-note{{in instantiation of template class 'PR11848::Hidden1<PR11848::Hide>' requested here}}
+ Hidden2<Hide, double, char> h2(1, 2);
+}
diff --git a/clang/test/SemaTemplate/ambiguous-ovl-print.cpp b/clang/test/SemaTemplate/ambiguous-ovl-print.cpp
new file mode 100644
index 0000000..7e3fa24
--- /dev/null
+++ b/clang/test/SemaTemplate/ambiguous-ovl-print.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f(void*, int); // expected-note{{candidate function}}
+template<typename T>
+ void f(T*, long); // expected-note{{candidate function}}
+
+void test_f(int *ip, int i) {
+ f(ip, i); // expected-error{{ambiguous}}
+}
diff --git a/clang/test/SemaTemplate/anonymous-union.cpp b/clang/test/SemaTemplate/anonymous-union.cpp
new file mode 100644
index 0000000..97ecd6e
--- /dev/null
+++ b/clang/test/SemaTemplate/anonymous-union.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR5868
+struct T0 {
+ int x;
+ union {
+ void *m0;
+ };
+};
+template <typename T>
+struct T1 : public T0, public T {
+ void f0() {
+ m0 = 0; // expected-error{{ambiguous conversion}}
+ }
+};
+
+struct A : public T0 { };
+
+void f1(T1<A> *S) { S->f0(); } // expected-note{{instantiation of member function}}
+
+namespace rdar8635664 {
+ template<typename T>
+ struct X {
+ struct inner;
+
+ struct inner {
+ union {
+ int x;
+ float y;
+ };
+
+ typedef T type;
+ };
+ };
+
+ void test() {
+ X<int>::inner i;
+ i.x = 0;
+ }
+}
diff --git a/clang/test/SemaTemplate/array-to-pointer-decay.cpp b/clang/test/SemaTemplate/array-to-pointer-decay.cpp
new file mode 100644
index 0000000..072c0e5
--- /dev/null
+++ b/clang/test/SemaTemplate/array-to-pointer-decay.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct mystruct {
+ int member;
+};
+
+template <int i>
+int foo() {
+ mystruct s[1];
+ return s->member;
+}
+
+int main() {
+ foo<1>();
+}
+
+// PR7405
+struct hb_sanitize_context_t {
+ int start;
+};
+template <typename Type> static bool sanitize() {
+ hb_sanitize_context_t c[1];
+ return !c->start;
+}
+bool closure = sanitize<int>();
diff --git a/clang/test/SemaTemplate/atomics.cpp b/clang/test/SemaTemplate/atomics.cpp
new file mode 100644
index 0000000..e9fdc9d
--- /dev/null
+++ b/clang/test/SemaTemplate/atomics.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR8345
+template<typename T> T f(T* value) {
+ return __sync_add_and_fetch(value, 1);
+}
+int g(long long* x) { return f(x); }
+int g(int* x) { return f(x); }
+
+namespace PR11320 {
+ template<typename T>
+ void g(unsigned *x) {
+ __sync_bool_compare_and_swap(x, 1, 4);
+ }
+ void h() { g<int>(0); }
+}
diff --git a/clang/test/SemaTemplate/attributes.cpp b/clang/test/SemaTemplate/attributes.cpp
new file mode 100644
index 0000000..495f4a7
--- /dev/null
+++ b/clang/test/SemaTemplate/attributes.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace attribute_aligned {
+ template<int N>
+ struct X {
+ char c[1] __attribute__((__aligned__((N)))); // expected-error {{alignment is not a power of 2}}
+ };
+
+ template <bool X> struct check {
+ int check_failed[X ? 1 : -1]; // expected-error {{array with a negative size}}
+ };
+
+ template <int N> struct check_alignment {
+ typedef check<N == sizeof(X<N>)> t; // expected-note {{in instantiation}}
+ };
+
+ check_alignment<1>::t c1;
+ check_alignment<2>::t c2;
+ check_alignment<3>::t c3; // expected-note 2 {{in instantiation}}
+ check_alignment<4>::t c4;
+}
+
+namespace PR9049 {
+ extern const void *CFRetain(const void *ref);
+
+ template<typename T> __attribute__((cf_returns_retained))
+ inline T WBCFRetain(T aValue) { return aValue ? (T)CFRetain(aValue) : (T)0; }
+
+
+ extern void CFRelease(const void *ref);
+
+ template<typename T>
+ inline void WBCFRelease(__attribute__((cf_consumed)) T aValue) { if(aValue) CFRelease(aValue); }
+}
diff --git a/clang/test/SemaTemplate/canonical-expr-type-0x.cpp b/clang/test/SemaTemplate/canonical-expr-type-0x.cpp
new file mode 100644
index 0000000..d7379ea
--- /dev/null
+++ b/clang/test/SemaTemplate/canonical-expr-type-0x.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+void f();
+
+// Test typeof(expr) canonicalization
+template<typename T, T N>
+void f0(T x, decltype(f(N, x)) y) { } // expected-note{{previous}}
+
+template<typename T, T N>
+void f0(T x, decltype((f)(N, x)) y) { }
+
+template<typename U, U M>
+void f0(U u, decltype(f(M, u))) { } // expected-error{{redefinition}}
+
+// PR12438: Test sizeof...() canonicalization
+template<int> struct N {};
+
+template<typename...T>
+N<sizeof...(T)> f1() {} // expected-note{{previous}}
+
+template<typename, typename...T>
+N<sizeof...(T)> f1() {}
+
+template<class...U>
+N<sizeof...(U)> f1() {} // expected-error{{redefinition}}
diff --git a/clang/test/SemaTemplate/canonical-expr-type.cpp b/clang/test/SemaTemplate/canonical-expr-type.cpp
new file mode 100644
index 0000000..7582df5
--- /dev/null
+++ b/clang/test/SemaTemplate/canonical-expr-type.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f();
+
+// Test typeof(expr) canonicalization
+template<typename T>
+void f0(T x, __typeof__(f(x)) y) { } // expected-note{{previous}}
+
+template<typename T>
+void f0(T x, __typeof__((f)(x)) y) { }
+
+template<typename U>
+void f0(U u, __typeof__(f(u))) { } // expected-error{{redefinition}}
+
+// Test insane typeof(expr) overload set canonicalization
+void f(int);
+void f(double);
+
+template<typename T, T N>
+void f0a(T x, __typeof__(f(N)) y) { } // expected-note{{previous}}
+
+void f(int);
+
+template<typename T, T N>
+void f0a(T x, __typeof__(f(N)) y) { } // expected-error{{redefinition}} \
+ // expected-note{{previous}}
+
+void f(float);
+
+template<typename T, T N>
+void f0a(T x, __typeof__(f(N)) y) { } // expected-error{{redefinition}}
+
+// Test dependently-sized array canonicalization
+template<typename T, int N, int M>
+void f1(T (&array)[N + M]) { } // expected-note{{previous}}
+
+template<typename T, int N, int M>
+void f1(T (&array)[M + N]) { }
+
+template<typename T, int M, int N>
+void f1(T (&array)[M + N]) { } // expected-error{{redefinition}}
+
+// Test dependently-sized extended vector type canonicalization
+template<typename T, int N, int M>
+struct X2 {
+ typedef T __attribute__((ext_vector_type(N))) type1;
+ typedef T __attribute__((ext_vector_type(M))) type2;
+ typedef T __attribute__((ext_vector_type(N))) type3;
+
+ void f0(type1); // expected-note{{previous}}
+ void f0(type2);
+ void f0(type3); // expected-error{{redeclared}}
+};
diff --git a/clang/test/SemaTemplate/class-template-ctor-initializer.cpp b/clang/test/SemaTemplate/class-template-ctor-initializer.cpp
new file mode 100644
index 0000000..44bb4bd
--- /dev/null
+++ b/clang/test/SemaTemplate/class-template-ctor-initializer.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<class X> struct A {};
+
+template<class X> struct B : A<X> {
+ B() : A<X>() {}
+};
+B<int> x;
+
+template<class X> struct B1 : A<X> {
+ typedef A<X> Base;
+ B1() : Base() {}
+};
+B1<int> x1;
+
+
+template<typename T> struct Tmpl { };
+
+template<typename T> struct TmplB { };
+
+struct TmplC : Tmpl<int> {
+ TmplC() :
+ Tmpl<int>(),
+ TmplB<int>() { } // expected-error {{type 'TmplB<int>' is not a direct or virtual base of 'TmplC'}}
+};
+
+
+struct TmplD : Tmpl<char>, TmplB<char> {
+ TmplD():
+ Tmpl<int>(), // expected-error {{type 'Tmpl<int>' is not a direct or virtual base of 'TmplD'}}
+ TmplB<char>() {}
+};
+
+namespace PR7259 {
+ class Base {
+ public:
+ Base() {}
+ };
+
+ template <class ParentClass>
+ class Derived : public ParentClass {
+ public:
+ Derived() : Base() {}
+ };
+
+ class Final : public Derived<Base> {
+ };
+
+ int
+ main (void)
+ {
+ Final final;
+ return 0;
+ }
+}
diff --git a/clang/test/SemaTemplate/class-template-decl.cpp b/clang/test/SemaTemplate/class-template-decl.cpp
new file mode 100644
index 0000000..ec4e016
--- /dev/null
+++ b/clang/test/SemaTemplate/class-template-decl.cpp
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> class A;
+
+extern "C++" {
+ template<typename T> class B;
+}
+
+namespace N {
+ template<typename T> class C;
+}
+
+extern "C" {
+ template<typename T> class D; // expected-error{{templates must have C++ linkage}}
+}
+
+template<class U> class A; // expected-note{{previous template declaration is here}}
+
+template<int N> class A; // expected-error{{template parameter has a different kind in template redeclaration}}
+
+template<int N> class NonTypeTemplateParm;
+
+typedef int INT;
+
+template<INT M> class NonTypeTemplateParm; // expected-note{{previous non-type template parameter with type 'INT' (aka 'int') is here}}
+
+template<long> class NonTypeTemplateParm; // expected-error{{template non-type parameter has a different type 'long' in template redeclaration}}
+
+template<template<typename T> class X> class TemplateTemplateParm;
+
+template<template<class> class Y> class TemplateTemplateParm; // expected-note{{previous template declaration is here}} \
+ // expected-note{{previous template template parameter is here}}
+
+template<typename> class TemplateTemplateParm; // expected-error{{template parameter has a different kind in template redeclaration}}
+
+template<template<typename T, int> class X> class TemplateTemplateParm; // expected-error{{too many template parameters in template template parameter redeclaration}}
+
+template<typename T>
+struct test {}; // expected-note{{previous definition}}
+
+template<typename T>
+struct test : T {}; // expected-error{{redefinition}}
+
+class X {
+public:
+ template<typename T> class C;
+};
+
+void f() {
+ template<typename T> class X; // expected-error{{expression}}
+}
+
+template<typename T> class X1 var; // expected-error{{declared as a template}}
+
+namespace M {
+}
+
+template<typename T> class M::C3 { }; // expected-error{{out-of-line definition of 'C3' does not match any declaration in namespace 'M'}}
+
+namespace PR8001 {
+ template<typename T1>
+ struct Foo {
+ template<typename T2> class Bar;
+ typedef Bar<T1> Baz;
+
+ template<typename T2>
+ struct Bar {
+ Bar() {}
+ };
+ };
+
+ void pr8001() {
+ Foo<int>::Baz x;
+ Foo<int>::Bar<int> y(x);
+ }
+}
+
+namespace rdar9676205 {
+ template <unsigned, class _Tp> class tuple_element;
+
+ template <class _T1, class _T2> class pair;
+
+ template <class _T1, class _T2>
+ class tuple_element<0, pair<_T1, _T2> >
+ {
+ template <class _Tp>
+ struct X
+ {
+ template <class _Up, bool = X<_Up>::value>
+ struct Y
+ : public X<_Up>,
+ public Y<_Up>
+ { };
+ };
+ };
+}
+
diff --git a/clang/test/SemaTemplate/class-template-id-2.cpp b/clang/test/SemaTemplate/class-template-id-2.cpp
new file mode 100644
index 0000000..d09f524
--- /dev/null
+++ b/clang/test/SemaTemplate/class-template-id-2.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+namespace N {
+ template<typename T> class A { };
+
+ template<> class A<int> { };
+
+ template<> class A<float>; // expected-note{{forward declaration of 'N::A<float>'}}
+
+ class B : public A<int> { };
+}
+
+class C1 : public N::A<int> { };
+
+class C2 : public N::A<float> { }; // expected-error{{base class has incomplete type}}
+
+struct D1 {
+ operator N::A<int>();
+};
+
+namespace N {
+ struct D2 {
+ operator A<int>();
+ };
+}
diff --git a/clang/test/SemaTemplate/class-template-id.cpp b/clang/test/SemaTemplate/class-template-id.cpp
new file mode 100644
index 0000000..3b02778
--- /dev/null
+++ b/clang/test/SemaTemplate/class-template-id.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T, typename U = float> struct A { };
+
+typedef A<int> A_int;
+
+typedef float FLOAT;
+
+A<int, FLOAT> *foo(A<int> *ptr, A<int> const *ptr2, A<int, double> *ptr3) {
+ if (ptr)
+ return ptr; // okay
+ else if (ptr2)
+ return ptr2; // expected-error{{cannot initialize return object of type 'A<int, FLOAT> *' with an lvalue of type 'const A<int> *'}}
+ else {
+ return ptr3; // expected-error{{cannot initialize return object of type 'A<int, FLOAT> *' with an lvalue of type 'A<int, double> *'}}
+ }
+}
+
+template<int I> struct B;
+
+const int value = 12;
+B<17 + 2> *bar(B<(19)> *ptr1, B< (::value + 7) > *ptr2, B<19 - 3> *ptr3) {
+ if (ptr1)
+ return ptr1;
+ else if (ptr2)
+ return ptr2;
+ else
+ return ptr3; // expected-error{{cannot initialize return object of type 'B<17 + 2> *' with an lvalue of type 'B<19 - 3>}}
+}
+
+typedef B<5> B5;
+
+
+namespace N {
+ template<typename T> struct C {};
+}
+
+N::C<int> c1;
+typedef N::C<float> c2;
+
+// PR5655
+template<typename T> struct Foo { }; // expected-note{{template is declared here}}
+
+void f(void) { Foo bar; } // expected-error{{without a template argument list}}
+
+// rdar://problem/8254267
+template <typename T> class Party;
+template <> class Party<T> { friend struct Party<>; }; // expected-error {{use of undeclared identifier 'T'}}
diff --git a/clang/test/SemaTemplate/class-template-spec.cpp b/clang/test/SemaTemplate/class-template-spec.cpp
new file mode 100644
index 0000000..f9015b3
--- /dev/null
+++ b/clang/test/SemaTemplate/class-template-spec.cpp
@@ -0,0 +1,121 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T, typename U = int> struct A; // expected-note {{template is declared here}} \
+ // expected-note{{explicitly specialized}}
+
+template<> struct A<double, double>; // expected-note{{forward declaration}}
+
+template<> struct A<float, float> { // expected-note{{previous definition}}
+ int x;
+};
+
+template<> struct A<float> { // expected-note{{previous definition}}
+ int y;
+};
+
+int test_specs(A<float, float> *a1, A<float, int> *a2) {
+ return a1->x + a2->y;
+}
+
+int test_incomplete_specs(A<double, double> *a1,
+ A<double> *a2)
+{
+ (void)a1->x; // expected-error{{member access into incomplete type}}
+ (void)a2->x; // expected-error{{implicit instantiation of undefined template 'A<double, int>'}}
+}
+
+typedef float FLOAT;
+
+template<> struct A<float, FLOAT>;
+
+template<> struct A<FLOAT, float> { }; // expected-error{{redefinition}}
+
+template<> struct A<float, int> { }; // expected-error{{redefinition}}
+
+template<typename T, typename U = int> struct X;
+
+template <> struct X<int, int> { int foo(); }; // #1
+template <> struct X<float> { int bar(); }; // #2
+
+typedef int int_type;
+void testme(X<int_type> *x1, X<float, int> *x2) {
+ (void)x1->foo(); // okay: refers to #1
+ (void)x2->bar(); // okay: refers to #2
+}
+
+// Make sure specializations are proper classes.
+template<>
+struct A<char> {
+ A();
+};
+
+A<char>::A() { }
+
+// Make sure we can see specializations defined before the primary template.
+namespace N{
+ template<typename T> struct A0;
+}
+
+namespace N {
+ template<>
+ struct A0<void> {
+ typedef void* pointer;
+ };
+}
+
+namespace N {
+ template<typename T>
+ struct A0 {
+ void foo(A0<void>::pointer p = 0);
+ };
+}
+
+// Diagnose specialization errors
+struct A<double> { }; // expected-error{{template specialization requires 'template<>'}}
+
+template<> struct ::A<double>;
+
+namespace N {
+ template<typename T> struct B; // expected-note 2{{explicitly specialized}}
+
+ template<> struct ::N::B<char>; // okay
+ template<> struct ::N::B<short>; // okay
+ template<> struct ::N::B<int>; // okay
+
+ int f(int);
+}
+
+template<> struct N::B<int> { }; // okay
+
+template<> struct N::B<float> { }; // expected-warning{{C++11 extension}}
+
+namespace M {
+ template<> struct ::N::B<short> { }; // expected-error{{class template specialization of 'B' not in a namespace enclosing 'N'}}
+
+ template<> struct ::A<long double>; // expected-error{{originally}}
+}
+
+template<> struct N::B<char> {
+ int testf(int x) { return f(x); }
+};
+
+// PR5264
+template <typename T> class Foo;
+Foo<int>* v;
+Foo<int>& F() { return *v; }
+template <typename T> class Foo {};
+Foo<int> x;
+
+
+// Template template parameters
+template<template<class T> class Wibble>
+class Wibble<int> { }; // expected-error{{cannot specialize a template template parameter}}
+
+namespace rdar9676205 {
+ template<typename T>
+ struct X {
+ template<typename U>
+ struct X<U*> { // expected-error{{explicit specialization of 'X' in class scope}}
+ };
+ };
+
+}
diff --git a/clang/test/SemaTemplate/constexpr-instantiate.cpp b/clang/test/SemaTemplate/constexpr-instantiate.cpp
new file mode 100644
index 0000000..2f9fe0e
--- /dev/null
+++ b/clang/test/SemaTemplate/constexpr-instantiate.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+namespace UseBeforeDefinition {
+ struct A {
+ template<typename T> static constexpr T get() { return T(); }
+ // ok, not a constant expression.
+ int n = get<int>();
+ };
+
+ // ok, constant expression.
+ constexpr int j = A::get<int>();
+
+ template<typename T> constexpr int consume(T);
+ // ok, not a constant expression.
+ const int k = consume(0); // expected-note {{here}}
+
+ template<typename T> constexpr int consume(T) { return 0; }
+ // ok, constant expression.
+ constexpr int l = consume(0);
+
+ constexpr int m = k; // expected-error {{constant expression}} expected-note {{initializer of 'k'}}
+}
+
+namespace IntegralConst {
+ template<typename T> constexpr T f(T n) { return n; }
+ enum E {
+ v = f(0), w = f(1) // ok
+ };
+ static_assert(w == 1, "");
+
+ char arr[f('x')]; // ok
+ static_assert(sizeof(arr) == 'x', "");
+}
+
+namespace ConvertedConst {
+ template<typename T> constexpr T f(T n) { return n; }
+ int f() {
+ switch (f()) {
+ case f(4): return 0;
+ }
+ return 1;
+ }
+}
+
+namespace OverloadResolution {
+ template<typename T> constexpr T f(T t) { return t; }
+
+ template<int n> struct S { };
+
+ template<typename T> auto g(T t) -> S<f(sizeof(T))> &;
+ char &f(...);
+
+ template<typename T> auto h(T t[f(sizeof(T))]) -> decltype(&*t) {
+ return t;
+ }
+
+ S<4> &k = g(0);
+ int *p, *q = h(p);
+}
+
+namespace DataMember {
+ template<typename T> struct S { static const int k; };
+ const int n = S<int>::k; // expected-note {{here}}
+ template<typename T> const int S<T>::k = 0;
+ constexpr int m = S<int>::k; // ok
+ constexpr int o = n; // expected-error {{constant expression}} expected-note {{initializer of 'n'}}
+}
+
+namespace Reference {
+ const int k = 5;
+ template<typename T> struct S {
+ static volatile int &r;
+ };
+ template<typename T> volatile int &S<T>::r = const_cast<volatile int&>(k);
+ constexpr int n = const_cast<int&>(S<int>::r);
+ static_assert(n == 5, "");
+}
diff --git a/clang/test/SemaTemplate/constructor-template.cpp b/clang/test/SemaTemplate/constructor-template.cpp
new file mode 100644
index 0000000..cf3fdfb
--- /dev/null
+++ b/clang/test/SemaTemplate/constructor-template.cpp
@@ -0,0 +1,128 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct X0 { // expected-note{{candidate}}
+ X0(int); // expected-note{{candidate}}
+ template<typename T> X0(T); // expected-note {{candidate}}
+ template<typename T, typename U> X0(T*, U*); // expected-note {{candidate}}
+
+ // PR4761
+ template<typename T> X0() : f0(T::foo) {} // expected-note {{candidate}}
+ int f0;
+};
+
+void accept_X0(X0);
+
+void test_X0(int i, float f) {
+ X0 x0a(i);
+ X0 x0b(f);
+ X0 x0c = i;
+ X0 x0d = f;
+ accept_X0(i);
+ accept_X0(&i);
+ accept_X0(f);
+ accept_X0(&f);
+ X0 x0e(&i, &f);
+ X0 x0f(&f, &i);
+
+ X0 x0g(f, &i); // expected-error{{no matching constructor}}
+}
+
+template<typename T>
+struct X1 {
+ X1(const X1&);
+ template<typename U> X1(const X1<U>&);
+};
+
+template<typename T>
+struct Outer {
+ typedef X1<T> A;
+
+ A alloc;
+
+ explicit Outer(const A& a) : alloc(a) { }
+};
+
+void test_X1(X1<int> xi) {
+ Outer<int> oi(xi);
+ Outer<float> of(xi);
+}
+
+// PR4655
+template<class C> struct A {};
+template <> struct A<int>{A(const A<int>&);};
+struct B { A<int> x; B(B& a) : x(a.x) {} };
+
+struct X2 {
+ X2(); // expected-note{{candidate constructor}}
+ X2(X2&); // expected-note {{candidate constructor}}
+ template<typename T> X2(T);
+};
+
+X2 test(bool Cond, X2 x2) {
+ if (Cond)
+ return x2; // okay, uses copy constructor
+
+ return X2(); // expected-error{{no matching constructor}}
+}
+
+struct X3 {
+ template<typename T> X3(T);
+};
+
+template<> X3::X3(X3); // expected-error{{must pass its first argument by reference}}
+
+struct X4 {
+ X4();
+ ~X4();
+ X4(X4&);
+ template<typename T> X4(const T&, int = 17);
+};
+
+X4 test_X4(bool Cond, X4 x4) {
+ X4 a(x4, 17); // okay, constructor template
+ X4 b(x4); // okay, copy constructor
+ return X4();
+}
+
+// Instantiation of a non-dependent use of a constructor
+struct DefaultCtorHasDefaultArg {
+ explicit DefaultCtorHasDefaultArg(int i = 17);
+};
+
+template<typename T>
+void default_ctor_inst() {
+ DefaultCtorHasDefaultArg def;
+}
+
+template void default_ctor_inst<int>();
+
+template<typename T>
+struct X5 {
+ X5();
+ X5(const T &);
+};
+
+struct X6 {
+ template<typename T> X6(T);
+};
+
+void test_X5_X6() {
+ X5<X6> tf;
+ X5<X6> tf2(tf);
+}
+
+namespace PR8182 {
+ struct foo {
+ foo();
+ template<class T> foo(T&);
+
+ private:
+ foo(const foo&);
+ };
+
+ void test_foo() {
+ foo f1;
+ foo f2(f1);
+ foo f3 = f1;
+ }
+
+}
diff --git a/clang/test/SemaTemplate/copy-ctor-assign.cpp b/clang/test/SemaTemplate/copy-ctor-assign.cpp
new file mode 100644
index 0000000..ae6dc9c
--- /dev/null
+++ b/clang/test/SemaTemplate/copy-ctor-assign.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Make sure that copy constructors and assignment operators are properly
+// generated when there is a matching
+
+// PR5072
+template<typename T>
+struct X {
+ template<typename U>
+ X(const X<U>& other)
+ : value(other.value + 1) { } // expected-error{{binary expression}}
+
+ template<typename U>
+ X& operator=(const X<U>& other) {
+ value = other.value + 1; // expected-error{{binary expression}}
+ return *this;
+ }
+
+ T value;
+};
+
+struct Y {};
+
+X<int Y::*> test0(X<int Y::*> x) { return x; }
+X<int> test1(X<long> x) { return x; }
+
+
+X<int> test2(X<int Y::*> x) {
+ return x; // expected-note{{instantiation}}
+}
+
+void test3(X<int> &x, X<int> xi, X<long> xl, X<int Y::*> xmptr) {
+ x = xi;
+ x = xl;
+ x = xmptr; // expected-note{{instantiation}}
+}
+
+struct X1 {
+ X1 &operator=(const X1&);
+};
+
+template<typename T>
+struct X2 : X1 {
+ template<typename U> X2 &operator=(const U&);
+};
+
+struct X3 : X2<int> {
+};
+
+void test_X2(X3 &to, X3 from) {
+ to = from;
+}
diff --git a/clang/test/SemaTemplate/crash-10438657.cpp b/clang/test/SemaTemplate/crash-10438657.cpp
new file mode 100644
index 0000000..2ee64bd
--- /dev/null
+++ b/clang/test/SemaTemplate/crash-10438657.cpp
@@ -0,0 +1,15 @@
+// RUN: not %clang_cc1 -fsyntax-only %s 2> %t
+// RUN: FileCheck %s < %t
+// CHECK: 10 errors
+template<typename _CharT>
+class collate : public locale::facet {
+
+protected:
+virtual ~collate() {}
+ class wxObject;
+ class __attribute__ ((visibility("default"))) wxGDIRefData
+ : public wxObjectRefData {};
+ class __attribute__ ((visibility("default"))) wxGDIObject : public wxObject { \
+ public:
+ virtual bool IsOk() const {
+ return m_refData && static_cast<wxGDIRefData *>(m_refData)->IsOk();
diff --git a/clang/test/SemaTemplate/crash-8204126.cpp b/clang/test/SemaTemplate/crash-8204126.cpp
new file mode 100644
index 0000000..eb96560
--- /dev/null
+++ b/clang/test/SemaTemplate/crash-8204126.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct A
+{
+ template<int> template<typename T> friend void foo(T) {} // expected-error{{extraneous template parameter list}}
+ void bar() { foo(0); } // expected-error{{use of undeclared identifier 'foo'}}
+};
diff --git a/clang/test/SemaTemplate/current-instantiation.cpp b/clang/test/SemaTemplate/current-instantiation.cpp
new file mode 100644
index 0000000..ccef811
--- /dev/null
+++ b/clang/test/SemaTemplate/current-instantiation.cpp
@@ -0,0 +1,237 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// This test concerns the identity of dependent types within the
+// canonical type system, specifically focusing on the difference
+// between members of the current instantiation and membmers of an
+// unknown specialization. This considers C++ [temp.type], which
+// specifies type equivalence within a template, and C++0x
+// [temp.dep.type], which defines what it means to be a member of the
+// current instantiation.
+
+template<typename T, typename U>
+struct X0 {
+ typedef T T_type;
+ typedef U U_type;
+
+ void f0(T&); // expected-note{{previous}}
+ void f0(typename X0::U_type&);
+ void f0(typename X0::T_type&); // expected-error{{redecl}}
+
+ void f1(T&); // expected-note{{previous}}
+ void f1(typename X0::U_type&);
+ void f1(typename X0<T, U>::T_type&); // expected-error{{redecl}}
+
+ void f2(T&); // expected-note{{previous}}
+ void f2(typename X0::U_type&);
+ void f2(typename X0<T_type, U_type>::T_type&); // expected-error{{redecl}}
+
+ void f3(T&); // expected-note{{previous}}
+ void f3(typename X0::U_type&);
+ void f3(typename ::X0<T_type, U_type>::T_type&); // expected-error{{redecl}}
+
+ struct X1 {
+ typedef T my_T_type;
+
+ void g0(T&); // expected-note{{previous}}
+ void g0(typename X0::U_type&);
+ void g0(typename X0::T_type&); // expected-error{{redecl}}
+
+ void g1(T&); // expected-note{{previous}}
+ void g1(typename X0::U_type&);
+ void g1(typename X0<T, U>::T_type&); // expected-error{{redecl}}
+
+ void g2(T&); // expected-note{{previous}}
+ void g2(typename X0::U_type&);
+ void g2(typename X0<T_type, U_type>::T_type&); // expected-error{{redecl}}
+
+ void g3(T&); // expected-note{{previous}}
+ void g3(typename X0::U_type&);
+ void g3(typename ::X0<T_type, U_type>::T_type&); // expected-error{{redecl}}
+
+ void g4(T&); // expected-note{{previous}}
+ void g4(typename X0::U_type&);
+ void g4(typename X1::my_T_type&); // expected-error{{redecl}}
+
+ void g5(T&); // expected-note{{previous}}
+ void g5(typename X0::U_type&);
+ void g5(typename X0::X1::my_T_type&); // expected-error{{redecl}}
+
+ void g6(T&); // expected-note{{previous}}
+ void g6(typename X0::U_type&);
+ void g6(typename X0<T, U>::X1::my_T_type&); // expected-error{{redecl}}
+
+ void g7(T&); // expected-note{{previous}}
+ void g7(typename X0::U_type&);
+ void g7(typename ::X0<typename X1::my_T_type, U_type>::X1::my_T_type&); // expected-error{{redecl}}
+
+ void g8(T&); // expected-note{{previous}}
+ void g8(typename X0<U, T_type>::T_type&);
+ void g8(typename ::X0<typename X0<T_type, U>::X1::my_T_type, U_type>::X1::my_T_type&); // expected-error{{redecl}}
+ };
+};
+
+
+template<typename T, typename U>
+struct X0<T*, U*> {
+ typedef T T_type;
+ typedef U U_type;
+ typedef T* Tptr;
+ typedef U* Uptr;
+
+ void f0(T&); // expected-note{{previous}}
+ void f0(typename X0::U_type&);
+ void f0(typename X0::T_type&); // expected-error{{redecl}}
+
+ void f1(T&); // expected-note{{previous}}
+ void f1(typename X0::U_type&);
+ void f1(typename X0<T*, U*>::T_type&); // expected-error{{redecl}}
+
+ void f2(T&); // expected-note{{previous}}
+ void f2(typename X0::U_type&);
+ void f2(typename X0<T_type*, U_type*>::T_type&); // expected-error{{redecl}}
+
+ void f3(T&); // expected-note{{previous}}
+ void f3(typename X0::U_type&);
+ void f3(typename ::X0<T_type*, U_type*>::T_type&); // expected-error{{redecl}}
+
+ void f4(T&); // expected-note{{previous}}
+ void f4(typename X0::U_type&);
+ void f4(typename ::X0<Tptr, Uptr>::T_type&); // expected-error{{redecl}}
+
+ void f5(X0*); // expected-note{{previous}}
+ void f5(::X0<T, U>*);
+ void f5(::X0<T*, U*>*); // expected-error{{redecl}}
+
+ struct X2 {
+ typedef T my_T_type;
+
+ void g0(T&); // expected-note{{previous}}
+ void g0(typename X0::U_type&);
+ void g0(typename X0::T_type&); // expected-error{{redecl}}
+
+ void g1(T&); // expected-note{{previous}}
+ void g1(typename X0::U_type&);
+ void g1(typename X0<T*, U*>::T_type&); // expected-error{{redecl}}
+
+ void g2(T&); // expected-note{{previous}}
+ void g2(typename X0::U_type&);
+ void g2(typename X0<T_type*, U_type*>::T_type&); // expected-error{{redecl}}
+
+ void g3(T&); // expected-note{{previous}}
+ void g3(typename X0::U_type&);
+ void g3(typename ::X0<T_type*, U_type*>::T_type&); // expected-error{{redecl}}
+
+ void g4(T&); // expected-note{{previous}}
+ void g4(typename X0::U_type&);
+ void g4(typename X2::my_T_type&); // expected-error{{redecl}}
+
+ void g5(T&); // expected-note{{previous}}
+ void g5(typename X0::U_type&);
+ void g5(typename X0::X2::my_T_type&); // expected-error{{redecl}}
+
+ void g6(T&); // expected-note{{previous}}
+ void g6(typename X0::U_type&);
+ void g6(typename X0<T*, U*>::X2::my_T_type&); // expected-error{{redecl}}
+
+ void g7(T&); // expected-note{{previous}}
+ void g7(typename X0::U_type&);
+ void g7(typename ::X0<typename X2::my_T_type*, U_type*>::X2::my_T_type&); // expected-error{{redecl}}
+
+ void g8(T&); // expected-note{{previous}}
+ void g8(typename X0<U, T_type>::T_type&);
+ void g8(typename ::X0<typename X0<T_type*, U*>::X2::my_T_type*, U_type*>::X2::my_T_type&); // expected-error{{redecl}}
+ };
+};
+
+template<typename T>
+struct X1 {
+ static int *a;
+ void f(float *b) {
+ X1<T>::a = b; // expected-error{{incompatible}}
+ X1<T*>::a = b;
+ }
+};
+
+namespace ConstantInCurrentInstantiation {
+ template<typename T>
+ struct X {
+ static const int value = 2;
+ static int array[value];
+ };
+
+ template<typename T> const int X<T>::value;
+
+ template<typename T>
+ int X<T>::array[X<T>::value] = { 1, 2 };
+}
+
+namespace Expressions {
+ template <bool b>
+ struct Bool {
+ enum anonymous_enum { value = b };
+ };
+ struct True : public Bool<true> {};
+ struct False : public Bool<false> {};
+
+ template <typename T1, typename T2>
+ struct Is_Same : public False {};
+ template <typename T>
+ struct Is_Same<T, T> : public True {};
+
+ template <bool b, typename T = void>
+ struct Enable_If {};
+ template <typename T>
+ struct Enable_If<true, T> {
+ typedef T type;
+ };
+
+ template <typename T>
+ class Class {
+ public:
+ template <typename U>
+ typename Enable_If<Is_Same<U, Class>::value, void>::type
+ foo();
+ };
+
+
+ template <typename T>
+ template <typename U>
+ typename Enable_If<Is_Same<U, Class<T> >::value, void>::type
+ Class<T>::foo() {}
+}
+
+namespace PR9255 {
+ template<typename T>
+ class X0 {
+ public:
+ class Inner1;
+
+ class Inner2 {
+ public:
+ void f()
+ {
+ Inner1::f.g();
+ }
+ };
+ };
+}
+
+namespace rdar10194295 {
+ template<typename XT>
+ class X {
+ public:
+ enum Enum { Yes, No };
+ template<Enum> void foo();
+ template<Enum> class Inner;
+ };
+
+ template<typename XT>
+ template<typename X<XT>::Enum>
+ void X<XT>::foo()
+ {
+ }
+
+ template<typename XT>
+ template<typename X<XT>::Enum>
+ class X<XT>::Inner { };
+}
diff --git a/clang/test/SemaTemplate/deduction-crash.cpp b/clang/test/SemaTemplate/deduction-crash.cpp
new file mode 100644
index 0000000..cf3899f
--- /dev/null
+++ b/clang/test/SemaTemplate/deduction-crash.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1| FileCheck %s
+
+// Note that the error count below doesn't matter. We just want to
+// make sure that the parser doesn't crash.
+// CHECK: 13 errors
+
+// PR7511
+template<a>
+struct int_;
+
+template<a>
+template<int,typename T1,typename>
+struct ac
+{
+ typedef T1 ae
+};
+
+template<class>struct aaa
+{
+ typedef ac<1,int,int>::ae ae
+};
+
+template<class>
+struct state_machine
+{
+ typedef aaa<int>::ae aaa;
+ int start()
+ {
+ ant(0);
+ }
+
+ template<class>
+ struct region_processing_helper
+ {
+ template<class,int=0>
+ struct In;
+
+ template<int my>
+ struct In<a::int_<aaa::a>,my>;
+
+ template<class Event>
+ int process(Event)
+ {
+ In<a::int_<0> > a;
+ }
+ }
+ template<class Event>
+ int ant(Event)
+ {
+ region_processing_helper<int>* helper;
+ helper->process(0)
+ }
+};
+
+int a()
+{
+ state_machine<int> p;
+ p.ant(0);
+}
+
+// PR9974
+template <int> struct enable_if;
+template <class > struct remove_reference ;
+template <class _Tp> struct remove_reference<_Tp&> ;
+
+template <class > struct __tuple_like;
+
+template <class _Tp, class _Up, int = __tuple_like<typename remove_reference<_Tp>::type>::value>
+struct __tuple_convertible;
+
+struct pair
+{
+template<class _Tuple, int = enable_if<__tuple_convertible<_Tuple, pair>::value>::type>
+pair(_Tuple&& );
+};
+
+template <class> struct basic_ostream;
+
+template <int>
+void endl( ) ;
+
+extern basic_ostream<char> cout;
+
+int operator<<( basic_ostream<char> , pair ) ;
+
+void register_object_imp ( )
+{
+cout << endl<1>;
+}
diff --git a/clang/test/SemaTemplate/deduction.cpp b/clang/test/SemaTemplate/deduction.cpp
new file mode 100644
index 0000000..aecb5ee
--- /dev/null
+++ b/clang/test/SemaTemplate/deduction.cpp
@@ -0,0 +1,164 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Template argument deduction with template template parameters.
+template<typename T, template<T> class A>
+struct X0 {
+ static const unsigned value = 0;
+};
+
+template<template<int> class A>
+struct X0<int, A> {
+ static const unsigned value = 1;
+};
+
+template<int> struct X0i;
+template<long> struct X0l;
+int array_x0a[X0<long, X0l>::value == 0? 1 : -1];
+int array_x0b[X0<int, X0i>::value == 1? 1 : -1];
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+template<typename T> struct allocator { };
+template<typename T, typename Alloc = allocator<T> > struct vector {};
+
+// Fun with meta-lambdas!
+struct _1 {};
+struct _2 {};
+
+// Replaces all occurrences of _1 with Arg1 and _2 with Arg2 in T.
+template<typename T, typename Arg1, typename Arg2>
+struct Replace {
+ typedef T type;
+};
+
+// Replacement of the whole type.
+template<typename Arg1, typename Arg2>
+struct Replace<_1, Arg1, Arg2> {
+ typedef Arg1 type;
+};
+
+template<typename Arg1, typename Arg2>
+struct Replace<_2, Arg1, Arg2> {
+ typedef Arg2 type;
+};
+
+// Replacement through cv-qualifiers
+template<typename T, typename Arg1, typename Arg2>
+struct Replace<const T, Arg1, Arg2> {
+ typedef typename Replace<T, Arg1, Arg2>::type const type;
+};
+
+// Replacement of templates
+template<template<typename> class TT, typename T1, typename Arg1, typename Arg2>
+struct Replace<TT<T1>, Arg1, Arg2> {
+ typedef TT<typename Replace<T1, Arg1, Arg2>::type> type;
+};
+
+template<template<typename, typename> class TT, typename T1, typename T2,
+ typename Arg1, typename Arg2>
+struct Replace<TT<T1, T2>, Arg1, Arg2> {
+ typedef TT<typename Replace<T1, Arg1, Arg2>::type,
+ typename Replace<T2, Arg1, Arg2>::type> type;
+};
+
+// Just for kicks...
+template<template<typename, typename> class TT, typename T1,
+ typename Arg1, typename Arg2>
+struct Replace<TT<T1, _2>, Arg1, Arg2> {
+ typedef TT<typename Replace<T1, Arg1, Arg2>::type, Arg2> type;
+};
+
+int array0[is_same<Replace<_1, int, float>::type, int>::value? 1 : -1];
+int array1[is_same<Replace<const _1, int, float>::type, const int>::value? 1 : -1];
+int array2[is_same<Replace<vector<_1>, int, float>::type, vector<int> >::value? 1 : -1];
+int array3[is_same<Replace<vector<const _1>, int, float>::type, vector<const int> >::value? 1 : -1];
+int array4[is_same<Replace<vector<int, _2>, double, float>::type, vector<int, float> >::value? 1 : -1];
+
+// PR5911
+template <typename T, int N> void f(const T (&a)[N]);
+int iarr[] = { 1 };
+void test_PR5911() { f(iarr); }
+
+// Must not examine base classes of incomplete type during template argument
+// deduction.
+namespace PR6257 {
+ template <typename T> struct X {
+ template <typename U> X(const X<U>& u);
+ };
+ struct A;
+ void f(A& a);
+ void f(const X<A>& a);
+ void test(A& a) { (void)f(a); }
+}
+
+// PR7463
+namespace PR7463 {
+ const int f ();
+ template <typename T_> void g (T_&); // expected-note{{T_ = int}}
+ void h (void) { g(f()); } // expected-error{{no matching function for call}}
+}
+
+namespace test0 {
+ template <class T> void make(const T *(*fn)()); // expected-note {{candidate template ignored: can't deduce a type for 'T' which would make 'const T' equal 'char'}}
+ char *char_maker();
+ void test() {
+ make(char_maker); // expected-error {{no matching function for call to 'make'}}
+ }
+}
+
+namespace test1 {
+ template<typename T> void foo(const T a[3][3]);
+ void test() {
+ int a[3][3];
+ foo(a);
+ }
+}
+
+// PR7708
+namespace test2 {
+ template<typename T> struct Const { typedef void const type; };
+
+ template<typename T> void f(T, typename Const<T>::type*);
+ template<typename T> void f(T, void const *);
+
+ void test() {
+ void *p = 0;
+ f(0, p);
+ }
+}
+
+// rdar://problem/8537391
+namespace test3 {
+ struct Foo {
+ template <void F(char)> static inline void foo();
+ };
+
+ class Bar {
+ template<typename T> static inline void wobble(T ch);
+
+ public:
+ static void madness() {
+ Foo::foo<wobble<char> >();
+ }
+ };
+}
+
+// Verify that we can deduce enum-typed arguments correctly.
+namespace test14 {
+ enum E { E0, E1 };
+ template <E> struct A {};
+ template <E e> void foo(const A<e> &a) {}
+
+ void test() {
+ A<E0> a;
+ foo(a);
+ }
+}
diff --git a/clang/test/SemaTemplate/default-arguments-cxx0x.cpp b/clang/test/SemaTemplate/default-arguments-cxx0x.cpp
new file mode 100644
index 0000000..7714313
--- /dev/null
+++ b/clang/test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+// Test default template arguments for function templates.
+template<typename T = int>
+void f0();
+
+template<typename T>
+void f0();
+
+void g0() {
+ f0(); // okay!
+}
+
+template<typename T, int N = T::value>
+int &f1(T);
+
+float &f1(...);
+
+struct HasValue {
+ static const int value = 17;
+};
+
+void g1() {
+ float &fr = f1(15);
+ int &ir = f1(HasValue());
+}
diff --git a/clang/test/SemaTemplate/default-arguments.cpp b/clang/test/SemaTemplate/default-arguments.cpp
new file mode 100644
index 0000000..6391369
--- /dev/null
+++ b/clang/test/SemaTemplate/default-arguments.cpp
@@ -0,0 +1,138 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T, int N = 2> struct X; // expected-note{{template is declared here}}
+
+X<int, 1> *x1;
+X<int> *x2;
+
+X<> *x3; // expected-error{{too few template arguments for class template 'X'}}
+
+template<typename U = float, int M> struct X;
+
+X<> *x4;
+
+template<typename T = int> struct Z { };
+template struct Z<>;
+
+// PR4362
+template<class T> struct a { };
+template<> struct a<int> { static const bool v = true; };
+
+template<class T, bool = a<T>::v> struct p { }; // expected-error {{no member named 'v'}}
+
+template struct p<bool>; // expected-note {{in instantiation of default argument for 'p<bool>' required here}}
+template struct p<int>;
+
+// PR5187
+template<typename T, typename U>
+struct A;
+
+template<typename T, typename U = T>
+struct A;
+
+template<typename T, typename U>
+struct A {
+ void f(A<T>);
+};
+
+template<typename T>
+struct B { };
+
+template<>
+struct B<void> {
+ typedef B<void*> type;
+};
+
+// Nested default arguments for template parameters.
+template<typename T> struct X1 { };
+
+template<typename T>
+struct X2 {
+ template<typename U = typename X1<T>::type> // expected-error{{no type named}}
+ struct Inner1 { };
+
+ template<T Value = X1<T>::value> // expected-error{{no member named 'value'}}
+ struct NonType1 { };
+
+ template<T Value>
+ struct Inner2 { };
+
+ template<typename U>
+ struct Inner3 {
+ template<typename X = T, typename V = U>
+ struct VeryInner { };
+
+ template<T Value1 = sizeof(T), T Value2 = sizeof(U),
+ T Value3 = Value1 + Value2>
+ struct NonType2 { };
+ };
+};
+
+X2<int> x2i;
+X2<int>::Inner1<float> x2iif;
+
+X2<int>::Inner1<> x2bad; // expected-note{{instantiation of default argument}}
+
+X2<int>::NonType1<'a'> x2_nontype1;
+X2<int>::NonType1<> x2_nontype1_bad; // expected-note{{instantiation of default argument}}
+
+// Check multi-level substitution into template type arguments
+X2<int>::Inner3<float>::VeryInner<> vi;
+X2<char>::Inner3<int>::NonType2<> x2_deep_nontype;
+
+template<typename T, typename U>
+struct is_same { static const bool value = false; };
+
+template<typename T>
+struct is_same<T, T> { static const bool value = true; };
+
+int array1[is_same<__typeof__(vi),
+ X2<int>::Inner3<float>::VeryInner<int, float> >::value? 1 : -1];
+
+int array2[is_same<__typeof(x2_deep_nontype),
+ X2<char>::Inner3<int>::NonType2<sizeof(char), sizeof(int),
+ sizeof(char)+sizeof(int)> >::value? 1 : -1];
+
+// Template template parameter defaults
+template<template<typename T> class X = X2> struct X3 { };
+int array3[is_same<X3<>, X3<X2> >::value? 1 : -1];
+
+struct add_pointer {
+ template<typename T>
+ struct apply {
+ typedef T* type;
+ };
+};
+
+template<typename T, template<typename> class X = T::template apply>
+ struct X4;
+int array4[is_same<X4<add_pointer>,
+ X4<add_pointer, add_pointer::apply> >::value? 1 : -1];
+
+template<int> struct X5 {}; // expected-note{{has a different type 'int'}}
+template<long> struct X5b {};
+template<typename T,
+ template<T> class B = X5> // expected-error{{template template argument has different}} \
+ // expected-note{{previous non-type template parameter}}
+ struct X6 {};
+
+X6<int> x6a;
+X6<long> x6b; // expected-note{{while checking a default template argument}}
+X6<long, X5b> x6c;
+
+
+template<template<class> class X = B<int> > struct X7; // expected-error{{must be a class template}}
+
+namespace PR9643 {
+ template<typename T> class allocator {};
+ template<typename T, typename U = allocator<T> > class vector {};
+
+ template<template<typename U, typename = allocator<U> > class container,
+ typename DT>
+ container<DT> initializer(const DT& d) {
+ return container<DT>();
+ }
+
+ void f() {
+ vector<int, allocator<int> > v = initializer<vector>(5);
+ }
+}
diff --git a/clang/test/SemaTemplate/default-expr-arguments-2.cpp b/clang/test/SemaTemplate/default-expr-arguments-2.cpp
new file mode 100644
index 0000000..378999d
--- /dev/null
+++ b/clang/test/SemaTemplate/default-expr-arguments-2.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -ast-dump %s 2>&1 | FileCheck %s
+
+// This is a wacky test to ensure that we're actually instantiating
+// the default arguments of the constructor when the function type is
+// otherwise non-dependent.
+namespace PR6733 {
+ template <class T>
+ class bar {
+ public: enum { kSomeConst = 128 };
+ bar(int x = kSomeConst) {}
+ };
+
+ // CHECK: void f()
+ void f() {
+ // CHECK: bar<int> tmp =
+ // CHECK: CXXDefaultArgExpr{{.*}}'int'
+ bar<int> tmp;
+ }
+}
diff --git a/clang/test/SemaTemplate/default-expr-arguments.cpp b/clang/test/SemaTemplate/default-expr-arguments.cpp
new file mode 100644
index 0000000..1eefa9f
--- /dev/null
+++ b/clang/test/SemaTemplate/default-expr-arguments.cpp
@@ -0,0 +1,305 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T>
+class C { C(int a0 = 0); };
+
+template<>
+C<char>::C(int a0);
+
+struct S { }; // expected-note 3 {{candidate constructor (the implicit copy constructor)}}
+
+template<typename T> void f1(T a, T b = 10) { } // expected-error{{no viable conversion}} \
+// expected-note{{passing argument to parameter 'b' here}}
+
+template<typename T> void f2(T a, T b = T()) { }
+
+template<typename T> void f3(T a, T b = T() + T()); // expected-error{{invalid operands to binary expression ('S' and 'S')}}
+
+void g() {
+ f1(10);
+ f1(S()); // expected-note{{in instantiation of default function argument expression for 'f1<S>' required here}}
+
+ f2(10);
+ f2(S());
+
+ f3(10);
+ f3(S()); // expected-note{{in instantiation of default function argument expression for 'f3<S>' required here}}
+}
+
+template<typename T> struct F {
+ F(T t = 10); // expected-error{{no viable conversion}} \
+ // expected-note{{passing argument to parameter 't' here}}
+ void f(T t = 10); // expected-error{{no viable conversion}} \
+ // expected-note{{passing argument to parameter 't' here}}
+};
+
+struct FD : F<int> { };
+
+void g2() {
+ F<int> f;
+ FD fd;
+}
+
+void g3(F<int> f, F<struct S> s) {
+ f.f();
+ s.f(); // expected-note{{in instantiation of default function argument expression for 'f<S>' required here}}
+
+ F<int> f2;
+ F<S> s2; // expected-note{{in instantiation of default function argument expression for 'F<S>' required here}}
+}
+
+template<typename T> struct G {
+ G(T) {}
+};
+
+void s(G<int> flags = 10) { }
+
+// Test default arguments
+template<typename T>
+struct X0 {
+ void f(T = T()); // expected-error{{no matching}}
+};
+
+template<typename U>
+void X0<U>::f(U) { }
+
+void test_x0(X0<int> xi) {
+ xi.f();
+ xi.f(17);
+}
+
+struct NotDefaultConstructible { // expected-note 2{{candidate}}
+ NotDefaultConstructible(int); // expected-note 2{{candidate}}
+};
+
+void test_x0_not_default_constructible(X0<NotDefaultConstructible> xn) {
+ xn.f(NotDefaultConstructible(17));
+ xn.f(42);
+ xn.f(); // expected-note{{in instantiation of default function argument}}
+}
+
+template<typename T>
+struct X1 {
+ typedef T value_type;
+ X1(const value_type& value = value_type());
+};
+
+void test_X1() {
+ X1<int> x1;
+}
+
+template<typename T>
+struct X2 {
+ void operator()(T = T()); // expected-error{{no matching}}
+};
+
+void test_x2(X2<int> x2i, X2<NotDefaultConstructible> x2n) {
+ x2i();
+ x2i(17);
+ x2n(NotDefaultConstructible(17));
+ x2n(); // expected-note{{in instantiation of default function argument}}
+}
+
+// PR5283
+namespace PR5283 {
+template<typename T> struct A {
+ A(T = 1); // expected-error 3 {{cannot initialize a parameter of type 'int *' with an rvalue of type 'int'}} \
+ // expected-note 3{{passing argument to parameter here}}
+};
+
+struct B : A<int*> {
+ B();
+};
+B::B() { } // expected-note {{in instantiation of default function argument expression for 'A<int *>' required he}}
+
+struct C : virtual A<int*> {
+ C();
+};
+C::C() { } // expected-note {{in instantiation of default function argument expression for 'A<int *>' required he}}
+
+struct D {
+ D();
+
+ A<int*> a;
+};
+D::D() { } // expected-note {{in instantiation of default function argument expression for 'A<int *>' required he}}
+}
+
+// PR5301
+namespace pr5301 {
+ void f(int, int = 0);
+
+ template <typename T>
+ void g(T, T = 0);
+
+ template <int I>
+ void i(int a = I);
+
+ template <typename T>
+ void h(T t) {
+ f(0);
+ g(1);
+ g(t);
+ i<2>();
+ }
+
+ void test() {
+ h(0);
+ }
+}
+
+// PR5810
+namespace PR5810 {
+ template<typename T>
+ struct allocator {
+ allocator() { int a[sizeof(T) ? -1 : -1]; } // expected-error2 {{array with a negative size}}
+ };
+
+ template<typename T>
+ struct vector {
+ vector(const allocator<T>& = allocator<T>()) {} // expected-note2 {{instantiation of}}
+ };
+
+ struct A { };
+ struct B { };
+
+ template<typename>
+ void FilterVTs() {
+ vector<A> Result;
+ }
+
+ void f() {
+ vector<A> Result;
+ }
+
+ template<typename T>
+ struct X {
+ vector<B> bs;
+ X() { }
+ };
+
+ void f2() {
+ X<float> x; // expected-note{{member function}}
+ }
+}
+
+template<typename T> void f4(T, int = 17);
+template<> void f4<int>(int, int);
+
+void f4_test(int i) {
+ f4(i);
+}
+
+// Instantiate for initialization
+namespace InstForInit {
+ template<typename T>
+ struct Ptr {
+ typedef T* type;
+ Ptr(type);
+ };
+
+ template<typename T>
+ struct Holder {
+ Holder(int i, Ptr<T> ptr = 0);
+ };
+
+ void test_holder(int i) {
+ Holder<int> h(i);
+ }
+};
+
+namespace PR5810b {
+ template<typename T>
+ T broken() {
+ T t;
+ double**** not_it = t;
+ }
+
+ void f(int = broken<int>());
+ void g() { f(17); }
+}
+
+namespace PR5810c {
+ template<typename T>
+ struct X {
+ X() {
+ T t;
+ double *****p = t; // expected-error{{cannot initialize a variable of type 'double *****' with an lvalue of type 'int'}}
+ }
+ X(const X&) { }
+ };
+
+ struct Y : X<int> { // expected-note{{instantiation of}}
+ };
+
+ void f(Y y = Y());
+
+ void g() { f(); }
+}
+
+namespace PR8127 {
+ template< typename T > class PointerClass {
+ public:
+ PointerClass( T * object_p ) : p_( object_p ) {
+ p_->acquire();
+ }
+ private:
+ T * p_;
+ };
+
+ class ExternallyImplementedClass;
+
+ class MyClass {
+ void foo( PointerClass<ExternallyImplementedClass> = 0 );
+ };
+}
+
+namespace rdar8427926 {
+ template<typename T>
+ struct Boom {
+ ~Boom() {
+ T t;
+ double *******ptr = t; // expected-error 2{{cannot initialize}}
+ }
+ };
+
+ Boom<float> *bfp;
+
+ struct X {
+ void f(Boom<int> = Boom<int>()) { } // expected-note{{requested here}}
+ void g(int x = (delete bfp, 0)); // expected-note{{requested here}}
+ };
+
+ void test(X *x) {
+ x->f();
+ x->g();
+ }
+}
+
+namespace PR8401 {
+ template<typename T>
+ struct A {
+ A() { T* x = 1; } // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
+ };
+
+ template<typename T>
+ struct B {
+ B(const A<T>& a = A<T>()); // expected-note{{in instantiation of}}
+ };
+
+ void f(B<int> b = B<int>());
+
+ void g() {
+ f();
+ }
+}
+
+namespace PR12581 {
+ const int a = 0;
+ template < typename > struct A;
+ template < typename MatrixType, int =
+ A < MatrixType >::Flags ? : A < MatrixType >::Flags & a > class B;
+ void
+ fn1 ()
+ {
+ }
+}
diff --git a/clang/test/SemaTemplate/delegating-constructors.cpp b/clang/test/SemaTemplate/delegating-constructors.cpp
new file mode 100644
index 0000000..e177b50
--- /dev/null
+++ b/clang/test/SemaTemplate/delegating-constructors.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+namespace PR10457 {
+
+ class string
+ {
+ string(const char* str, unsigned);
+
+ public:
+ template <unsigned N>
+ string(const char (&str)[N])
+ : string(str) {} // expected-error{{constructor for 'string<6>' creates a delegation cycle}}
+ };
+
+ void f() {
+ string s("hello");
+ }
+
+ struct Foo {
+ Foo(int) { }
+
+
+ template <typename T>
+ Foo(T, int i) : Foo(i) { }
+};
+
+ void test_Foo()
+ {
+ Foo f(1, 1);
+ }
+}
diff --git a/clang/test/SemaTemplate/dependent-base-classes.cpp b/clang/test/SemaTemplate/dependent-base-classes.cpp
new file mode 100644
index 0000000..895eacc
--- /dev/null
+++ b/clang/test/SemaTemplate/dependent-base-classes.cpp
@@ -0,0 +1,137 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T, typename U>
+struct X0 : T::template apply<U> {
+ X0(U u) : T::template apply<U>(u) { }
+};
+
+template<typename T, typename U>
+struct X1 : T::apply<U> { }; // expected-error{{use 'template' keyword to treat 'apply' as a dependent template name}}
+
+template<typename T>
+struct X2 : vector<T> { }; // expected-error{{unknown template name 'vector'}}
+
+namespace PR6031 {
+ template<typename T>
+ struct A;
+
+ template <class X>
+ struct C { };
+
+ template <class TT>
+ struct II {
+ typedef typename A<TT>::type type;
+ };
+
+ template <class TT>
+ struct FI : II<TT>
+ {
+ C<typename FI::type> a;
+ };
+
+ template <class TT>
+ struct FI2
+ {
+ C<typename FI2::type> a; // expected-error{{no type named 'type' in 'FI2<TT>'}} \
+ // expected-error{{C++ requires a type specifier for all declarations}}
+ };
+
+ template<typename T>
+ struct Base {
+ class Nested { };
+ template<typename U> struct MemberTemplate { };
+ int a;
+ };
+
+ template<typename T>
+ struct HasDepBase : Base<T> {
+ int foo() {
+ class HasDepBase::Nested nested;
+ typedef typename HasDepBase::template MemberTemplate<T>::type type;
+ return HasDepBase::a;
+ }
+ };
+
+ template<typename T>
+ struct NoDepBase {
+ int foo() {
+ class NoDepBase::Nested nested; // expected-error{{no class named 'Nested' in 'NoDepBase<T>'}}
+ typedef typename NoDepBase::template MemberTemplate<T>::type type; // expected-error{{'MemberTemplate' following the 'template' keyword does not refer to a template}} \
+ // FIXME: expected-error{{unqualified-id}}
+ return NoDepBase::a; // expected-error{{no member named 'a' in 'NoDepBase<T>'}}
+ }
+ };
+}
+
+namespace Ambig {
+ template<typename T>
+ struct Base1 {
+ typedef int type; // expected-note{{member found by ambiguous name lookup}}
+ };
+
+ struct Base2 {
+ typedef float type; // expected-note{{member found by ambiguous name lookup}}
+ };
+
+ template<typename T>
+ struct Derived : Base1<T>, Base2 {
+ typedef typename Derived::type type; // expected-error{{member 'type' found in multiple base classes of different types}}
+ type *foo(float *fp) { return fp; }
+ };
+
+ Derived<int> di; // expected-note{{instantiation of}}
+}
+
+namespace PR6081 {
+ template<typename T>
+ struct A { };
+
+ template<typename T>
+ class B : public A<T>
+ {
+ public:
+ template< class X >
+ void f0(const X & k)
+ {
+ this->template f1<int>()(k);
+ }
+ };
+
+ template<typename T>
+ class C
+ {
+ public:
+ template< class X >
+ void f0(const X & k)
+ {
+ this->template f1<int>()(k); // expected-error{{'f1' following the 'template' keyword does not refer to a template}} \
+ // FIXME: expected-error{{unqualified-id}} \
+ // expected-error{{function-style cast or type construction}} \
+ // expected-error{{expected expression}}
+ }
+ };
+}
+
+namespace PR6413 {
+ template <typename T> class Base_A { };
+
+ class Base_B { };
+
+ template <typename T>
+ class Derived
+ : public virtual Base_A<T>
+ , public virtual Base_B
+ { };
+}
+
+namespace PR5812 {
+ template <class T> struct Base {
+ Base* p;
+ };
+
+ template <class T> struct Derived: public Base<T> {
+ typename Derived::Base* p; // meaning Derived::Base<T>
+ };
+
+ Derived<int> di;
+}
diff --git a/clang/test/SemaTemplate/dependent-base-member-init.cpp b/clang/test/SemaTemplate/dependent-base-member-init.cpp
new file mode 100644
index 0000000..1d4fed3
--- /dev/null
+++ b/clang/test/SemaTemplate/dependent-base-member-init.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR4381
+template<class T> struct X {};
+template<typename T> struct Y : public X<T>::X { };
+
+// PR4621
+class A1 {
+ A1(int x) {}
+};
+template<class C> class B1 : public A1 {
+ B1(C x) : A1(x.x) {}
+};
+class A2 { A2(int x, int y); };
+template <class C> class B2 {
+ A2 x;
+ B2(C x) : x(x.x, x.y) {}
+};
+template <class C> class B3 {
+ C x;
+ B3() : x(1,2) {}
+};
+
+// PR4627
+template<typename _Container> class insert_iterator {
+ _Container* container;
+ insert_iterator(_Container& __x) : container(&__x) {}
+};
+
+// PR4763
+template<typename T> struct s0 {};
+template<typename T> struct s0_traits {};
+template<typename T> struct s1 : s0<typename s0_traits<T>::t0> {
+ s1() {}
+};
+
+// PR6062
+namespace PR6062 {
+ template <typename T>
+ class A : public T::type
+ {
+ A() : T::type()
+ {
+ }
+
+ template <typename U>
+ A(U const& init)
+ : T::type(init)
+ { }
+
+ template<typename U>
+ A(U& init) : U::other_type(init) { }
+ };
+}
+
+template<typename T, typename U>
+struct X0 : T::template apply<U> {
+ X0(int i) : T::template apply<U>(i) { }
+};
+
+// PR7698
+namespace PR7698 {
+ template<typename Type>
+ class A {
+ char mA[sizeof(Type *)];
+ A(): mA() {}
+ };
+}
diff --git a/clang/test/SemaTemplate/dependent-class-member-operator.cpp b/clang/test/SemaTemplate/dependent-class-member-operator.cpp
new file mode 100644
index 0000000..d70a60c
--- /dev/null
+++ b/clang/test/SemaTemplate/dependent-class-member-operator.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR7837
+
+template<class T> struct C1 { void operator()(T); };
+template<class T> struct C2; // expected-note {{template is declared here}}
+template<class T> void foo(T);
+void wrap() {
+ foo(&C1<int>::operator());
+ foo(&C1<int>::operator+); // expected-error {{no member named 'operator+' in 'C1<int>'}}
+ foo(&C2<int>::operator+); // expected-error {{implicit instantiation of undefined template 'C2<int>'}}
+}
diff --git a/clang/test/SemaTemplate/dependent-expr.cpp b/clang/test/SemaTemplate/dependent-expr.cpp
new file mode 100644
index 0000000..a1ddd24
--- /dev/null
+++ b/clang/test/SemaTemplate/dependent-expr.cpp
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR5908
+template <typename Iterator>
+void Test(Iterator it) {
+ *(it += 1);
+}
+
+namespace PR6045 {
+ template<unsigned int r>
+ class A
+ {
+ static const unsigned int member = r;
+ void f();
+ };
+
+ template<unsigned int r>
+ const unsigned int A<r>::member;
+
+ template<unsigned int r>
+ void A<r>::f()
+ {
+ unsigned k;
+ (void)(k % member);
+ }
+}
+
+namespace PR7198 {
+ struct A
+ {
+ ~A() { }
+ };
+
+ template<typename T>
+ struct B {
+ struct C : A {};
+ void f()
+ {
+ C c = C();
+ }
+ };
+}
+
+namespace PR7724 {
+ template<typename OT> int myMethod()
+ { return 2 && sizeof(OT); }
+}
+
+namespace test4 {
+ template <typename T> T *addressof(T &v) {
+ return reinterpret_cast<T*>(
+ &const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
+ }
+}
+
+namespace test5 {
+ template <typename T> class chained_map {
+ int k;
+ void lookup() const {
+ int &v = (int &)k;
+ }
+ };
+}
+
+namespace PR8795 {
+ template <class _CharT> int test(_CharT t)
+ {
+ int data [] = {
+ sizeof(_CharT) > sizeof(char)
+ };
+ return data[0];
+ }
+}
diff --git a/clang/test/SemaTemplate/dependent-names-no-std.cpp b/clang/test/SemaTemplate/dependent-names-no-std.cpp
new file mode 100644
index 0000000..2fb9d99
--- /dev/null
+++ b/clang/test/SemaTemplate/dependent-names-no-std.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+//
+// The whole point of this test is to verify certain diagnostics work in the
+// absence of namespace 'std'.
+
+namespace PR10053 {
+ namespace ns {
+ struct Data {};
+ }
+
+ template<typename T> struct A {
+ T t;
+ A() {
+ f(t); // expected-error {{call to function 'f' that is neither visible in the template definition nor found by argument-dependent lookup}}
+ }
+ };
+
+ void f(ns::Data); // expected-note {{in namespace 'PR10053::ns'}}
+
+ A<ns::Data> a; // expected-note {{in instantiation of member function}}
+}
diff --git a/clang/test/SemaTemplate/dependent-names.cpp b/clang/test/SemaTemplate/dependent-names.cpp
new file mode 100644
index 0000000..924bad9
--- /dev/null
+++ b/clang/test/SemaTemplate/dependent-names.cpp
@@ -0,0 +1,326 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+typedef double A;
+template<typename T> class B {
+ typedef int A;
+};
+
+template<typename T> struct X : B<T> {
+ static A a;
+};
+
+int a0[sizeof(X<int>::a) == sizeof(double) ? 1 : -1];
+
+// PR4365.
+template<class T> class Q;
+template<class T> class R : Q<T> {T current;};
+
+
+namespace test0 {
+ template <class T> class Base {
+ public:
+ void instance_foo();
+ static void static_foo();
+ class Inner {
+ public:
+ void instance_foo();
+ static void static_foo();
+ };
+ };
+
+ template <class T> class Derived1 : Base<T> {
+ public:
+ void test0() {
+ Base<T>::static_foo();
+ Base<T>::instance_foo();
+ }
+
+ void test1() {
+ Base<T>::Inner::static_foo();
+ Base<T>::Inner::instance_foo(); // expected-error {{call to non-static member function without an object argument}}
+ }
+
+ static void test2() {
+ Base<T>::static_foo();
+ Base<T>::instance_foo(); // expected-error {{call to non-static member function without an object argument}}
+ }
+
+ static void test3() {
+ Base<T>::Inner::static_foo();
+ Base<T>::Inner::instance_foo(); // expected-error {{call to non-static member function without an object argument}}
+ }
+ };
+
+ template <class T> class Derived2 : Base<T>::Inner {
+ public:
+ void test0() {
+ Base<T>::static_foo();
+ Base<T>::instance_foo(); // expected-error {{call to non-static member function without an object argument}}
+ }
+
+ void test1() {
+ Base<T>::Inner::static_foo();
+ Base<T>::Inner::instance_foo();
+ }
+
+ static void test2() {
+ Base<T>::static_foo();
+ Base<T>::instance_foo(); // expected-error {{call to non-static member function without an object argument}}
+ }
+
+ static void test3() {
+ Base<T>::Inner::static_foo();
+ Base<T>::Inner::instance_foo(); // expected-error {{call to non-static member function without an object argument}}
+ }
+ };
+
+ void test0() {
+ Derived1<int> d1;
+ d1.test0();
+ d1.test1(); // expected-note {{in instantiation of member function}}
+ d1.test2(); // expected-note {{in instantiation of member function}}
+ d1.test3(); // expected-note {{in instantiation of member function}}
+
+ Derived2<int> d2;
+ d2.test0(); // expected-note {{in instantiation of member function}}
+ d2.test1();
+ d2.test2(); // expected-note {{in instantiation of member function}}
+ d2.test3(); // expected-note {{in instantiation of member function}}
+ }
+}
+
+namespace test1 {
+ template <class T> struct Base {
+ void foo(T); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
+ };
+
+ template <class T> struct Derived : Base<T> {
+ void doFoo(T v) {
+ foo(v); // expected-error {{use of undeclared identifier}}
+ }
+ };
+
+ template struct Derived<int>; // expected-note {{requested here}}
+}
+
+namespace PR8966 {
+ template <class T>
+ class MyClassCore
+ {
+ };
+
+ template <class T>
+ class MyClass : public MyClassCore<T>
+ {
+ public:
+ enum {
+ N
+ };
+
+ // static member declaration
+ static const char* array [N];
+
+ void f() {
+ MyClass<T>::InBase = 17;
+ }
+ };
+
+ // static member definition
+ template <class T>
+ const char* MyClass<T>::array [MyClass<T>::N] = { "A", "B", "C" };
+}
+
+namespace std {
+ inline namespace v1 {
+ template<typename T> struct basic_ostream;
+ }
+ namespace inner {
+ template<typename T> struct vector {};
+ }
+ using inner::vector;
+ template<typename T, typename U> struct pair {};
+ typedef basic_ostream<char> ostream;
+ extern ostream cout;
+ std::ostream &operator<<(std::ostream &out, const char *);
+}
+
+namespace PR10053 {
+ template<typename T> struct A {
+ T t;
+ A() {
+ f(t); // expected-error {{call to function 'f' that is neither visible in the template definition nor found by argument-dependent lookup}}
+ }
+ };
+
+ void f(int&); // expected-note {{'f' should be declared prior to the call site}}
+
+ A<int> a; // expected-note {{in instantiation of member function}}
+
+
+ namespace N {
+ namespace M {
+ template<typename T> int g(T t) {
+ f(t); // expected-error {{call to function 'f' that is neither visible in the template definition nor found by argument-dependent lookup}}
+ };
+ }
+
+ void f(char&); // expected-note {{'f' should be declared prior to the call site}}
+ }
+
+ void f(char&);
+
+ int k = N::M::g<char>(0);; // expected-note {{in instantiation of function}}
+
+
+ namespace O {
+ void f(char&); // expected-note {{candidate function not viable}}
+
+ template<typename T> struct C {
+ static const int n = f(T()); // expected-error {{no matching function}}
+ };
+ }
+
+ int f(double); // no note, shadowed by O::f
+ O::C<double> c; // expected-note {{requested here}}
+
+
+ // Example from www/compatibility.html
+ namespace my_file {
+ template <typename T> T Squared(T x) {
+ return Multiply(x, x); // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}}
+ }
+
+ int Multiply(int x, int y) { // expected-note {{should be declared prior to the call site}}
+ return x * y;
+ }
+
+ int main() {
+ Squared(5); // expected-note {{here}}
+ }
+ }
+
+ // Example from www/compatibility.html
+ namespace my_file2 {
+ template<typename T>
+ void Dump(const T& value) {
+ std::cout << value << "\n"; // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}}
+ }
+
+ namespace ns {
+ struct Data {};
+ }
+
+ std::ostream& operator<<(std::ostream& out, ns::Data data) { // expected-note {{should be declared prior to the call site or in namespace 'PR10053::my_file2::ns'}}
+ return out << "Some data";
+ }
+
+ void Use() {
+ Dump(ns::Data()); // expected-note {{here}}
+ }
+ }
+
+ namespace my_file2_a {
+ template<typename T>
+ void Dump(const T &value) {
+ print(std::cout, value); // expected-error 4{{neither visible in the template definition nor found by argument-dependent lookup}}
+ }
+
+ namespace ns {
+ struct Data {};
+ }
+ namespace ns2 {
+ struct Data {};
+ }
+
+ std::ostream &print(std::ostream &out, int); // expected-note-re {{should be declared prior to the call site$}}
+ std::ostream &print(std::ostream &out, ns::Data); // expected-note {{should be declared prior to the call site or in namespace 'PR10053::my_file2_a::ns'}}
+ std::ostream &print(std::ostream &out, std::vector<ns2::Data>); // expected-note {{should be declared prior to the call site or in namespace 'PR10053::my_file2_a::ns2'}}
+ std::ostream &print(std::ostream &out, std::pair<ns::Data, ns2::Data>); // expected-note {{should be declared prior to the call site or in an associated namespace of one of its arguments}}
+
+ void Use() {
+ Dump(0); // expected-note {{requested here}}
+ Dump(ns::Data()); // expected-note {{requested here}}
+ Dump(std::vector<ns2::Data>()); // expected-note {{requested here}}
+ Dump(std::pair<ns::Data, ns2::Data>()); // expected-note {{requested here}}
+ }
+ }
+
+ namespace unary {
+ template<typename T>
+ T Negate(const T& value) {
+ return !value; // expected-error {{call to function 'operator!' that is neither visible in the template definition nor found by argument-dependent lookup}}
+ }
+
+ namespace ns {
+ struct Data {};
+ }
+
+ ns::Data operator!(ns::Data); // expected-note {{should be declared prior to the call site or in namespace 'PR10053::unary::ns'}}
+
+ void Use() {
+ Negate(ns::Data()); // expected-note {{requested here}}
+ }
+ }
+}
+
+namespace PR10187 {
+ namespace A {
+ template<typename T>
+ struct S {
+ void f() {
+ for (auto &a : e)
+ __range(a); // expected-error {{undeclared identifier '__range'}}
+ }
+ int e[10];
+ };
+ void g() {
+ S<int>().f(); // expected-note {{here}}
+ }
+ }
+
+ namespace B {
+ template<typename T> void g(); // expected-note {{not viable}}
+ template<typename T> void f() {
+ g<int>(T()); // expected-error {{no matching function}}
+ }
+
+ namespace {
+ struct S {};
+ }
+ void g(S);
+
+ template void f<S>(); // expected-note {{here}}
+ }
+}
+
+namespace rdar11242625 {
+
+template <typename T>
+struct Main {
+ struct default_names {
+ typedef int id;
+ };
+
+ template <typename T2 = typename default_names::id>
+ struct TS {
+ T2 q;
+ };
+};
+
+struct Sub : public Main<int> {
+ TS<> ff;
+};
+
+int arr[sizeof(Sub)];
+
+}
+
+namespace PR11421 {
+template < unsigned > struct X {
+ static const unsigned dimension = 3;
+ template<unsigned dim=dimension>
+ struct Y: Y<dim> { }; // expected-error {{incomplete type}} expected-note {{is not complete until the closing}}
+};
+typedef X<3> X3;
+X3::Y<>::iterator it; // expected-note {{requested here}}
+}
diff --git a/clang/test/SemaTemplate/dependent-sized_array.cpp b/clang/test/SemaTemplate/dependent-sized_array.cpp
new file mode 100644
index 0000000..cf0e0f3
--- /dev/null
+++ b/clang/test/SemaTemplate/dependent-sized_array.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+
+template<int N>
+void f() {
+ int a[] = { 1, 2, 3, N };
+ unsigned numAs = sizeof(a) / sizeof(int);
+}
+
+template void f<17>();
+
+
+template<int N>
+void f1() {
+ int a0[] = {}; // expected-warning{{zero}}
+ int a1[] = { 1, 2, 3, N };
+ int a3[sizeof(a1)/sizeof(int) != 4? 1 : -1]; // expected-error{{negative}}
+}
diff --git a/clang/test/SemaTemplate/dependent-template-recover.cpp b/clang/test/SemaTemplate/dependent-template-recover.cpp
new file mode 100644
index 0000000..3c01f65
--- /dev/null
+++ b/clang/test/SemaTemplate/dependent-template-recover.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T, typename U, int N>
+struct X {
+ void f(T* t) {
+ t->f0<U>(); // expected-error{{use 'template' keyword to treat 'f0' as a dependent template name}}
+ t->f0<int>(); // expected-error{{use 'template' keyword to treat 'f0' as a dependent template name}}
+
+ t->operator+<U const, 1>(); // expected-error{{use 'template' keyword to treat 'operator +' as a dependent template name}}
+ t->f1<int const, 2>(); // expected-error{{use 'template' keyword to treat 'f1' as a dependent template name}}
+
+ T::getAs<U>(); // expected-error{{use 'template' keyword to treat 'getAs' as a dependent template name}}
+ t->T::getAs<U>(); // expected-error{{use 'template' keyword to treat 'getAs' as a dependent template name}}
+
+ // FIXME: We can't recover from these yet
+ (*t).f2<N>(); // expected-error{{expected expression}}
+ (*t).f2<0>(); // expected-error{{expected expression}}
+ }
+};
+
+namespace PR9401 {
+ // From GCC PR c++/45558
+ template <typename S, typename T>
+ struct C
+ {
+ template <typename U>
+ struct B
+ {
+ template <typename W>
+ struct E
+ {
+ explicit E(const W &x) : w(x) {}
+ const W &w;
+ };
+ };
+ };
+
+ struct F;
+ template <typename X>
+ struct D
+ {
+ D() {}
+ };
+
+ const D<F> g;
+ template <typename S, typename T>
+ struct A
+ {
+ template <typename U>
+ struct B : C<S, T>::template B<U>
+ {
+ typedef typename C<S, T>::template B<U> V;
+ static const D<typename V::template E<D<F> > > a;
+ };
+ };
+
+ template <typename S, typename T>
+ template <typename U>
+ const D<typename C<S, T>::template B<U>::template E<D<F> > >
+ A<S, T>::B<U>::a = typename C<S, T>::template B<U>::template E<D<F> >(g);
+}
diff --git a/clang/test/SemaTemplate/dependent-type-identity.cpp b/clang/test/SemaTemplate/dependent-type-identity.cpp
new file mode 100644
index 0000000..731013c
--- /dev/null
+++ b/clang/test/SemaTemplate/dependent-type-identity.cpp
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// This test concerns the identity of dependent types within the
+// canonical type system. This corresponds to C++ [temp.type], which
+// specifies type equivalence within a template.
+//
+// FIXME: template template parameters
+
+namespace N {
+ template<typename T>
+ struct X2 {
+ template<typename U>
+ struct apply {
+ typedef U* type;
+ };
+ };
+}
+
+namespace Nalias = N;
+
+template<typename T>
+struct X0 { };
+
+using namespace N;
+
+template<typename T, typename U>
+struct X1 {
+ typedef T type;
+ typedef U U_type;
+
+ void f0(T); // expected-note{{previous}}
+ void f0(U);
+ void f0(type); // expected-error{{redeclar}}
+
+ void f1(T*); // expected-note{{previous}}
+ void f1(U*);
+ void f1(type*); // expected-error{{redeclar}}
+
+ void f2(X0<T>*); // expected-note{{previous}}
+ void f2(X0<U>*);
+ void f2(X0<type>*); // expected-error{{redeclar}}
+
+ void f3(X0<T>*); // expected-note{{previous}}
+ void f3(X0<U>*);
+ void f3(::X0<type>*); // expected-error{{redeclar}}
+
+ void f4(typename T::template apply<U>*); // expected-note{{previous}}
+ void f4(typename U::template apply<U>*);
+ void f4(typename type::template apply<T>*);
+ void f4(typename type::template apply<U_type>*); // expected-error{{redeclar}}
+
+ void f5(typename T::template apply<U>::type*); // expected-note{{previous}}
+ void f5(typename U::template apply<U>::type*);
+ void f5(typename U::template apply<T>::type*);
+ void f5(typename type::template apply<T>::type*);
+ void f5(typename type::template apply<U_type>::type*); // expected-error{{redeclar}}
+
+ void f6(typename N::X2<T>::template apply<U> *); // expected-note{{previous}}
+ void f6(typename N::X2<U>::template apply<U> *);
+ void f6(typename N::X2<U>::template apply<T> *);
+ void f6(typename ::N::X2<type>::template apply<U_type> *); // expected-error{{redeclar}}
+
+ void f7(typename N::X2<T>::template apply<U> *); // expected-note{{previous}}
+ void f7(typename N::X2<U>::template apply<U> *);
+ void f7(typename N::X2<U>::template apply<T> *);
+ void f7(typename X2<type>::template apply<U_type> *); // expected-error{{redeclar}}
+
+ void f8(typename N::X2<T>::template apply<U> *); // expected-note{{previous}}
+ void f8(typename N::X2<U>::template apply<U> *);
+ void f8(typename N::X2<U>::template apply<T> *);
+ void f8(typename ::Nalias::X2<type>::template apply<U_type> *); // expected-error{{redeclar}}
+};
+
+namespace PR6851 {
+ template <bool v>
+ struct S;
+
+ struct N {
+ template <bool w>
+ S< S<w>::cond && 1 > foo();
+ };
+
+ struct Alien;
+ bool operator&&(const Alien&, const Alien&);
+
+ template <bool w>
+ S< S<w>::cond && 1 > N::foo() { }
+}
+
+namespace PR7460 {
+ template <typename T>
+ struct TemplateClass2
+ {
+ enum { SIZE = 100 };
+ static T member[SIZE];
+ };
+
+ template <typename T>
+ T TemplateClass2<T>::member[TemplateClass2<T>::SIZE];
+}
diff --git a/clang/test/SemaTemplate/destructor-template.cpp b/clang/test/SemaTemplate/destructor-template.cpp
new file mode 100644
index 0000000..07beda4
--- /dev/null
+++ b/clang/test/SemaTemplate/destructor-template.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename A> class s0 {
+
+ template<typename B> class s1 : public s0<A> {
+ ~s1() {}
+ s0<A> ms0;
+ };
+
+};
+
+struct Incomplete;
+
+template<typename T>
+void destroy_me(T me) {
+ me.~T();
+}
+
+template void destroy_me(Incomplete*);
+
+namespace PR6152 {
+ template<typename T> struct X { void f(); };
+ template<typename T> struct Y { };
+ template<typename T>
+ void X<T>::f() {
+ Y<T> *y;
+ y->template Y<T>::~Y();
+ y->template Y<T>::~Y<T>();
+ y->~Y();
+ }
+
+ template struct X<int>;
+}
+
+namespace cvquals {
+ template<typename T>
+ void f(int *ptr) {
+ ptr->~T();
+ }
+
+ template void f<const volatile int>(int *);
+}
+
+namespace PR7239 {
+ template<class E> class A { };
+ class B {
+ void f() {
+ A<int>* x;
+ x->A<int>::~A<int>();
+ }
+ };
+}
+
+namespace PR7904 {
+ struct Foo {
+ template <int i> ~Foo() {} // expected-error{{destructor cannot be declared as a template}}
+ };
+ Foo f;
+}
diff --git a/clang/test/SemaTemplate/elaborated-type-specifier.cpp b/clang/test/SemaTemplate/elaborated-type-specifier.cpp
new file mode 100644
index 0000000..514c5f2
--- /dev/null
+++ b/clang/test/SemaTemplate/elaborated-type-specifier.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR6915 {
+ template <typename T>
+ class D {
+ enum T::X v; // expected-error{{use of 'X' with tag type that does not match previous declaration}} \
+ // expected-error{{no enum named 'X' in 'PR6915::D3'}}
+ };
+
+ struct D1 {
+ enum X { value };
+ };
+ struct D2 {
+ class X { }; // expected-note{{previous use is here}}
+ };
+ struct D3 { };
+
+ template class D<D1>;
+ template class D<D2>; // expected-note{{in instantiation of}}
+ template class D<D3>; // expected-note{{in instantiation of}}
+}
+
+template<typename T>
+struct DeclOrDef {
+ enum T::foo; // expected-error{{nested name specifier for a declaration cannot depend on a template parameter}}
+ enum T::bar { // expected-error{{nested name specifier for a declaration cannot depend on a template parameter}}
+ value
+ };
+};
+
+namespace PR6649 {
+ template <typename T> struct foo {
+ class T::bar; // expected-error{{nested name specifier for a declaration cannot depend on a template parameter}}
+ class T::bar { int x; }; // expected-error{{nested name specifier for a declaration cannot depend on a template parameter}}
+ };
+}
+
+namespace rdar8568507 {
+ template <class T> struct A *makeA(T t);
+}
diff --git a/clang/test/SemaTemplate/enum-argument.cpp b/clang/test/SemaTemplate/enum-argument.cpp
new file mode 100644
index 0000000..7d23757
--- /dev/null
+++ b/clang/test/SemaTemplate/enum-argument.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+enum Enum { val = 1 };
+template <Enum v> struct C {
+ typedef C<v> Self;
+};
+template struct C<val>;
+
+template<typename T>
+struct get_size {
+ static const unsigned value = sizeof(T);
+};
+
+template<typename T>
+struct X0 {
+ enum {
+ Val1 = get_size<T>::value,
+ Val2,
+ SumOfValues = Val1 + Val2
+ };
+};
+
+X0<int> x0i;
+
+namespace rdar8020920 {
+ template<typename T>
+ struct X {
+ enum { e0 = 32 };
+
+ unsigned long long bitfield : e0;
+
+ void f(int j) {
+ bitfield + j;
+ }
+ };
+}
diff --git a/clang/test/SemaTemplate/enum-forward.cpp b/clang/test/SemaTemplate/enum-forward.cpp
new file mode 100644
index 0000000..b25c21f
--- /dev/null
+++ b/clang/test/SemaTemplate/enum-forward.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -fms-compatibility %s
+
+template<typename T>
+struct X {
+ enum E *e;
+};
+
+X<int> xi;
diff --git a/clang/test/SemaTemplate/example-dynarray.cpp b/clang/test/SemaTemplate/example-dynarray.cpp
new file mode 100644
index 0000000..999521e
--- /dev/null
+++ b/clang/test/SemaTemplate/example-dynarray.cpp
@@ -0,0 +1,177 @@
+// RUN: %clangxx -emit-llvm -c -o - %s
+#include <stddef.h>
+#include <stdlib.h>
+#include <assert.h>
+
+// Placement new requires <new> to be included, but we don't support that yet.
+void* operator new(size_t, void* ptr) throw() {
+ return ptr;
+}
+void operator delete(void*, void*) throw() {
+}
+
+template<typename T>
+class dynarray {
+public:
+ dynarray() { Start = Last = End = 0; }
+
+ dynarray(const dynarray &other) {
+ Start = (T*)malloc(sizeof(T) * other.size());
+ Last = End = Start + other.size();
+
+ for (unsigned I = 0, N = other.size(); I != N; ++I)
+ new (Start + I) T(other[I]);
+ }
+
+ ~dynarray() {
+ for (unsigned I = 0, N = size(); I != N; ++I)
+ Start[I].~T();
+
+ free(Start);
+ }
+
+ dynarray &operator=(const dynarray &other) {
+ T* NewStart = (T*)malloc(sizeof(T) * other.size());
+
+ for (unsigned I = 0, N = other.size(); I != N; ++I)
+ new (NewStart + I) T(other[I]);
+
+ for (unsigned I = 0, N = size(); I != N; ++I)
+ Start[I].~T();
+
+ free(Start);
+ Start = NewStart;
+ Last = End = NewStart + other.size();
+ return *this;
+ }
+
+ unsigned size() const { return Last - Start; }
+ unsigned capacity() const { return End - Start; }
+
+ void push_back(const T& value);
+
+ void pop_back() {
+ --Last;
+ Last->~T();
+ }
+
+ T& operator[](unsigned Idx) {
+ return Start[Idx];
+ }
+
+ const T& operator[](unsigned Idx) const {
+ return Start[Idx];
+ }
+
+ typedef T* iterator;
+ typedef const T* const_iterator;
+
+ iterator begin() { return Start; }
+ const_iterator begin() const { return Start; }
+
+ iterator end() { return Last; }
+ const_iterator end() const { return Last; }
+
+ bool operator==(const dynarray &other) const {
+ if (size() != other.size())
+ return false;
+
+ for (unsigned I = 0, N = size(); I != N; ++I)
+ if ((*this)[I] != other[I])
+ return false;
+
+ return true;
+ }
+
+ bool operator!=(const dynarray &other) const {
+ return !(*this == other);
+ }
+
+public:
+ T* Start, *Last, *End;
+};
+
+template<typename T>
+void dynarray<T>::push_back(const T& value) {
+ if (Last == End) {
+ unsigned NewCapacity = capacity() * 2;
+ if (NewCapacity == 0)
+ NewCapacity = 4;
+
+ T* NewStart = (T*)malloc(sizeof(T) * NewCapacity);
+
+ unsigned Size = size();
+ for (unsigned I = 0; I != Size; ++I)
+ new (NewStart + I) T(Start[I]);
+
+ for (unsigned I = 0, N = size(); I != N; ++I)
+ Start[I].~T();
+ free(Start);
+
+ Start = NewStart;
+ Last = Start + Size;
+ End = Start + NewCapacity;
+ }
+
+ new (Last) T(value);
+ ++Last;
+}
+
+struct Point {
+ Point() { x = y = z = 0.0; }
+ Point(const Point& other) : x(other.x), y(other.y), z(other.z) { }
+
+ float x, y, z;
+};
+
+int main() {
+ dynarray<int> di;
+ di.push_back(0);
+ di.push_back(1);
+ di.push_back(2);
+ di.push_back(3);
+ di.push_back(4);
+ assert(di.size() == 5);
+ for (dynarray<int>::iterator I = di.begin(), IEnd = di.end(); I != IEnd; ++I)
+ assert(*I == I - di.begin());
+
+ for (int I = 0, N = di.size(); I != N; ++I)
+ assert(di[I] == I);
+
+ di.pop_back();
+ assert(di.size() == 4);
+ di.push_back(4);
+
+ dynarray<int> di2 = di;
+ assert(di2.size() == 5);
+ assert(di.begin() != di2.begin());
+ for (dynarray<int>::iterator I = di2.begin(), IEnd = di2.end();
+ I != IEnd; ++I)
+ assert(*I == I - di2.begin());
+
+ dynarray<int> di3(di);
+ assert(di3.size() == 5);
+ assert(di.begin() != di3.begin());
+ for (dynarray<int>::iterator I = di3.begin(), IEnd = di3.end();
+ I != IEnd; ++I)
+ assert(*I == I - di3.begin());
+
+ dynarray<int> di4;
+ assert(di4.size() == 0);
+ di4 = di;
+ assert(di4.size() == 5);
+ assert(di.begin() != di4.begin());
+ for (dynarray<int>::iterator I = di4.begin(), IEnd = di4.end();
+ I != IEnd; ++I)
+ assert(*I == I - di4.begin());
+
+ assert(di4 == di);
+ di4[3] = 17;
+ assert(di4 != di);
+
+ dynarray<Point> dp;
+ dp.push_back(Point());
+ assert(dp.size() == 1);
+
+ return 0;
+}
diff --git a/clang/test/SemaTemplate/example-typelist.cpp b/clang/test/SemaTemplate/example-typelist.cpp
new file mode 100644
index 0000000..082aeb8
--- /dev/null
+++ b/clang/test/SemaTemplate/example-typelist.cpp
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// A simple cons-style typelist
+struct nil { };
+
+template<typename Head, typename Tail = nil>
+struct cons {
+ typedef Head head;
+ typedef Tail tail;
+};
+
+// is_same trait, for testing
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+// metaprogram that computes the length of a list
+template<typename T> struct length;
+
+template<typename Head, typename Tail>
+struct length<cons<Head, Tail> > {
+ static const unsigned value = length<Tail>::value + 1;
+};
+
+template<>
+struct length<nil> {
+ static const unsigned value = 0;
+};
+
+typedef cons<unsigned char,
+ cons<unsigned short,
+ cons<unsigned int,
+ cons<unsigned long> > > > unsigned_inttypes;
+int length0[length<unsigned_inttypes>::value == 4? 1 : -1];
+
+// metaprogram that reverses a list
+
+// FIXME: I would prefer that this be a partial specialization, but
+// that requires partial ordering of class template partial
+// specializations.
+template<typename T>
+class reverse {
+ typedef typename reverse<typename T::tail>::type reversed_tail;
+
+ typedef typename reverse<typename reversed_tail::tail>::type most_of_tail;
+
+public:
+ typedef cons<typename reversed_tail::head,
+ typename reverse<cons<typename T::head, most_of_tail> >::type> type;
+};
+
+template<typename Head>
+class reverse<cons<Head> > {
+public:
+ typedef cons<Head> type;
+};
+
+template<>
+class reverse<nil> {
+public:
+ typedef nil type;
+};
+
+int reverse0[is_same<reverse<unsigned_inttypes>::type,
+ cons<unsigned long,
+ cons<unsigned int,
+ cons<unsigned short,
+ cons<unsigned char> > > > >::value? 1 : -1];
+
+// metaprogram that finds a type within a list
+
+// FIXME: I would prefer that this be a partial specialization, but
+// that requires partial ordering of class template partial
+// specializations.
+template<typename List, typename T>
+struct find : find<typename List::tail, T> { };
+
+template<typename Tail, typename T>
+struct find<cons<T, Tail>, T> {
+ typedef cons<T, Tail> type;
+};
+
+template<typename T>
+struct find<nil, T> {
+ typedef nil type;
+};
+
+int find0[is_same<find<unsigned_inttypes, unsigned int>::type,
+ cons<unsigned int, cons<unsigned long> > >::value?
+ 1 : -1];
+int find1[is_same<find<unsigned_inttypes, int>::type, nil>::value? 1 : -1];
+
diff --git a/clang/test/SemaTemplate/explicit-instantiation.cpp b/clang/test/SemaTemplate/explicit-instantiation.cpp
new file mode 100644
index 0000000..13d76be
--- /dev/null
+++ b/clang/test/SemaTemplate/explicit-instantiation.cpp
@@ -0,0 +1,107 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template void *; // expected-error{{expected unqualified-id}}
+
+template typedef void f0; // expected-error{{explicit instantiation of typedef}}
+
+int v0; // expected-note{{refers here}}
+template int v0; // expected-error{{does not refer}}
+
+template<typename T>
+struct X0 {
+ static T value;
+
+ T f0(T x) {
+ return x + 1; // expected-error{{invalid operands}}
+ }
+ T* f0(T*, T*) { return T(); }
+
+ template<typename U>
+ T f0(T, U) { return T(); }
+};
+
+template<typename T>
+T X0<T>::value; // expected-error{{no matching constructor}}
+
+template int X0<int>::value;
+
+struct NotDefaultConstructible { // expected-note{{candidate constructor (the implicit copy constructor)}}
+ NotDefaultConstructible(int); // expected-note{{candidate constructor}}
+};
+
+template NotDefaultConstructible X0<NotDefaultConstructible>::value; // expected-note{{instantiation}}
+
+template int X0<int>::f0(int);
+template int* X0<int>::f0(int*, int*);
+template int X0<int>::f0(int, float);
+
+template int X0<int>::f0(int) const; // expected-error{{does not refer}}
+template int* X0<int>::f0(int*, float*); // expected-error{{does not refer}}
+
+struct X1 { };
+typedef int X1::*MemPtr;
+
+template MemPtr X0<MemPtr>::f0(MemPtr); // expected-note{{requested here}}
+
+struct X2 {
+ int f0(int); // expected-note{{refers here}}
+
+ template<typename T> T f1(T) { return T(); }
+ template<typename T> T* f1(T*) { return 0; }
+
+ template<typename T, typename U> void f2(T, U*) { } // expected-note{{candidate}}
+ template<typename T, typename U> void f2(T*, U) { } // expected-note{{candidate}}
+};
+
+template int X2::f0(int); // expected-error{{not an instantiation}}
+
+template int *X2::f1(int *); // okay
+
+template void X2::f2(int *, int *); // expected-error{{ambiguous}}
+
+
+template<typename T> void print_type() { }
+
+template void print_type<int>();
+template void print_type<float>();
+
+template<typename T> void print_type(T*) { }
+
+template void print_type(int*);
+template void print_type<int>(float*); // expected-error{{does not refer}}
+
+void print_type(double*);
+template void print_type<double>(double*);
+
+// PR5069
+template<int I> void foo0 (int (&)[I + 1]) { }
+template void foo0<2> (int (&)[3]);
+
+namespace explicit_instantiation_after_implicit_instantiation {
+ template <int I> struct X0 { static int x; };
+ template <int I> int X0<I>::x;
+ void test1() { (void)&X0<1>::x; }
+ template struct X0<1>;
+}
+
+template<typename> struct X3 { };
+inline template struct X3<int>; // expected-warning{{ignoring 'inline' keyword on explicit template instantiation}}
+static template struct X3<float>; // expected-warning{{ignoring 'static' keyword on explicit template instantiation}}
+
+namespace PR7622 {
+ template<typename,typename=int>
+ struct basic_streambuf;
+
+ template<typename,typename>
+ struct basic_streambuf{friend bob<>()}; // expected-error{{unknown type name 'bob'}} \
+ // expected-error{{expected member name or ';' after declaration specifiers}}
+ template struct basic_streambuf<int>;
+}
+
+// Test that we do not crash.
+class TC1 {
+ class TC2 {
+ template // FIXME: error here.
+ void foo() { }
+ };
+};
diff --git a/clang/test/SemaTemplate/explicit-specialization-member.cpp b/clang/test/SemaTemplate/explicit-specialization-member.cpp
new file mode 100644
index 0000000..7fe6bf3
--- /dev/null
+++ b/clang/test/SemaTemplate/explicit-specialization-member.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T>
+struct X0 {
+ typedef T* type;
+
+ void f0(T);
+ void f1(type);
+};
+
+template<> void X0<char>::f0(char);
+template<> void X0<char>::f1(type);
+
+namespace PR6161 {
+ template<typename _CharT>
+ class numpunct : public locale::facet // expected-error{{use of undeclared identifier 'locale'}} \
+ // expected-error{{expected class name}}
+ {
+ static locale::id id; // expected-error{{use of undeclared identifier}}
+ };
+ numpunct<char>::~numpunct(); // expected-error{{expected the class name after '~' to name a destructor}}
+}
diff --git a/clang/test/SemaTemplate/ext-vector-type.cpp b/clang/test/SemaTemplate/ext-vector-type.cpp
new file mode 100644
index 0000000..f968c13
--- /dev/null
+++ b/clang/test/SemaTemplate/ext-vector-type.cpp
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T, unsigned Length>
+struct make1 {
+ typedef T __attribute__((ext_vector_type(Length))) type;
+};
+
+void test_make1() {
+ make1<int, 5>::type x;
+ x.x = 4;
+}
+
+template<typename T, unsigned Length>
+struct make2 {
+ typedef T __attribute__((ext_vector_type(Length))) type; // expected-error{{zero vector size}}
+};
+
+int test_make2() {
+ make2<int, 0> x; // expected-note{{in instantiation of}}
+}
+
+template<typename T, unsigned Length>
+struct make3 {
+ typedef T __attribute__((ext_vector_type(Length))) type; // expected-error{{invalid vector element type 's'}}
+};
+
+struct s {};
+
+int test_make3() {
+ make3<s, 3>x; // expected-note{{in instantiation of}}
+}
+
+template<typename T, T Length>
+struct make4 {
+ typedef T __attribute__((ext_vector_type(Length))) type;
+};
+
+int test_make4() {
+ make4<int, 4>::type x;
+ x.w = 7;
+}
+
+typedef int* int_ptr;
+template<unsigned Length>
+struct make5 {
+ typedef int_ptr __attribute__((ext_vector_type(Length))) type; // expected-error{{invalid vector element type}}
+};
+
+template<int Length>
+struct make6 {
+ typedef int __attribute__((ext_vector_type(Length))) type;
+};
+
+int test_make6() {
+ make6<4>::type x;
+ x.w = 7;
+
+ make6<2>::type y;
+ y.x = -1;
+ y.w = -1; // expected-error{{vector component access exceeds type}}
+}
+
+namespace Deduction {
+ template<typename T> struct X0;
+
+ template<typename T, unsigned N>
+ struct X0<T __attribute__((ext_vector_type(N)))> {
+ static const unsigned value = 0;
+ };
+
+ template<typename T>
+ struct X0<T __attribute__((ext_vector_type(4)))> {
+ static const unsigned value = 1;
+ };
+
+ template<unsigned N>
+ struct X0<float __attribute__((ext_vector_type(N)))> {
+ static const unsigned value = 2;
+ };
+
+ template<>
+ struct X0<float __attribute__((ext_vector_type(4)))> {
+ static const unsigned value = 3;
+ };
+
+ typedef int __attribute__((ext_vector_type(2))) int2;
+ typedef int __attribute__((ext_vector_type(4))) int4;
+ typedef float __attribute__((ext_vector_type(2))) float2;
+ typedef float __attribute__((ext_vector_type(4))) float4;
+
+ int array0[X0<int2>::value == 0? 1 : -1];
+ int array1[X0<int4>::value == 1? 1 : -1];
+ int array2[X0<float2>::value == 2? 1 : -1];
+ int array3[X0<float4>::value == 3? 1 : -1];
+}
diff --git a/clang/test/SemaTemplate/extern-templates.cpp b/clang/test/SemaTemplate/extern-templates.cpp
new file mode 100644
index 0000000..eca64ed
--- /dev/null
+++ b/clang/test/SemaTemplate/extern-templates.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+class X0 {
+public:
+ void f(T t);
+
+ struct Inner {
+ void g(T t);
+ };
+};
+
+template<typename T>
+void X0<T>::f(T t) {
+ t = 17; // expected-error{{incompatible}}
+}
+
+extern template class X0<int>;
+
+extern template class X0<int*>;
+
+template<typename T>
+void X0<T>::Inner::g(T t) {
+ t = 17; // expected-error{{incompatible}}
+}
+
+void test_intptr(X0<int*> xi, X0<int*>::Inner xii) {
+ xi.f(0);
+ xii.g(0);
+}
+
+extern template class X0<long*>;
+
+void test_longptr(X0<long*> xl, X0<long*>::Inner xli) {
+ xl.f(0);
+ xli.g(0);
+}
+
+template class X0<long*>; // expected-note 2{{instantiation}}
+
+template<typename T>
+class X1 {
+public:
+ void f(T t) { t += 2; }
+
+ void g(T t);
+};
+
+template<typename T>
+void X1<T>::g(T t) {
+ t += 2;
+}
+
+extern template class X1<void*>;
+
+void g_X1(X1<void*> x1, void *ptr) {
+ x1.g(ptr);
+}
+
+extern template void X1<const void*>::g(const void*);
+
+void g_X1_2(X1<const void *> x1, const void *ptr) {
+ x1.g(ptr);
+}
diff --git a/clang/test/SemaTemplate/fibonacci.cpp b/clang/test/SemaTemplate/fibonacci.cpp
new file mode 100644
index 0000000..ff1711f
--- /dev/null
+++ b/clang/test/SemaTemplate/fibonacci.cpp
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+template<unsigned I>
+struct FibonacciEval;
+
+template<unsigned I>
+struct Fibonacci {
+ enum { value = FibonacciEval<I-1>::value + FibonacciEval<I-2>::value };
+};
+
+template<unsigned I>
+struct FibonacciEval {
+ enum { value = Fibonacci<I>::value };
+};
+
+template<> struct Fibonacci<0> {
+ enum { value = 0 };
+};
+
+template<> struct Fibonacci<1> {
+ enum { value = 1 };
+};
+
+int array5[Fibonacci<5>::value == 5? 1 : -1];
+int array10[Fibonacci<10>::value == 55? 1 : -1];
+
+template<unsigned I>
+struct FibonacciEval2;
+
+template<unsigned I>
+struct Fibonacci2 {
+ static const unsigned value
+ = FibonacciEval2<I-1>::value + FibonacciEval2<I-2>::value;
+};
+
+template<unsigned I>
+struct FibonacciEval2 {
+ static const unsigned value = Fibonacci2<I>::value;
+};
+
+template<> struct Fibonacci2<0> {
+ static const unsigned value = 0;
+};
+
+template<> struct Fibonacci2<1> {
+ static const unsigned value = 1;
+};
+
+int array5_2[Fibonacci2<5>::value == 5? 1 : -1];
+int array10_2[Fibonacci2<10>::value == 55? 1 : -1];
+
+template<unsigned I>
+struct Fibonacci3 {
+ static const unsigned value = Fibonacci3<I-1>::value + Fibonacci3<I-2>::value;
+};
+
+template<> struct Fibonacci3<0> {
+ static const unsigned value = 0;
+};
+
+template<> struct Fibonacci3<1> {
+ static const unsigned value = 1;
+};
+
+int array5_3[Fibonacci3<5>::value == 5? 1 : -1];
+int array10_3[Fibonacci3<10>::value == 55? 1 : -1];
diff --git a/clang/test/SemaTemplate/friend-template.cpp b/clang/test/SemaTemplate/friend-template.cpp
new file mode 100644
index 0000000..9c95fa0
--- /dev/null
+++ b/clang/test/SemaTemplate/friend-template.cpp
@@ -0,0 +1,245 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR5057
+namespace test0 {
+ namespace std {
+ class X {
+ public:
+ template<typename T> friend struct Y;
+ };
+ }
+
+ namespace std {
+ template<typename T> struct Y {};
+ }
+}
+
+namespace test1 {
+ template<typename T> void f1(T) { } // expected-note{{here}}
+
+ class X {
+ template<typename T> friend void f0(T);
+ template<typename T> friend void f1(T);
+ };
+
+ template<typename T> void f0(T) { }
+ template<typename T> void f1(T) { } // expected-error{{redefinition}}
+}
+
+// PR4768
+namespace test2 {
+ template<typename T> struct X0 {
+ template<typename U> friend struct X0;
+ };
+
+ template<typename T> struct X0<T*> {
+ template<typename U> friend struct X0;
+ };
+
+ template<> struct X0<int> {
+ template<typename U> friend struct X0;
+ };
+
+ template<typename T> struct X1 {
+ template<typename U> friend void f2(U);
+ template<typename U> friend void f3(U);
+ };
+
+ template<typename U> void f2(U);
+
+ X1<int> x1i;
+ X0<int*> x0ip;
+
+ template<> void f2(int);
+
+ // FIXME: Should this declaration of f3 be required for the specialization of
+ // f3<int> (further below) to work? GCC and EDG don't require it, we do...
+ template<typename U> void f3(U);
+
+ template<> void f3(int);
+}
+
+// PR5332
+namespace test3 {
+ template <typename T> class Foo {
+ template <typename U>
+ friend class Foo;
+ };
+
+ Foo<int> foo;
+
+ template<typename T, T Value> struct X2a;
+
+ template<typename T, int Size> struct X2b;
+
+ template<typename T>
+ class X3 {
+ template<typename U, U Value> friend struct X2a;
+
+ // FIXME: the redeclaration note ends up here because redeclaration
+ // lookup ends up finding the friend target from X3<int>.
+ template<typename U, T Value> friend struct X2b; // expected-error {{template non-type parameter has a different type 'long' in template redeclaration}} \
+ // expected-note {{previous non-type template parameter with type 'int' is here}}
+ };
+
+ X3<int> x3i; // okay
+
+ X3<long> x3l; // expected-note {{in instantiation}}
+}
+
+// PR5716
+namespace test4 {
+ template<typename> struct A {
+ template<typename T> friend void f(const A<T>&);
+ };
+
+ template<typename T> void f(const A<T>&) {
+ int a[sizeof(T) ? -1 : -1]; // expected-error {{array with a negative size}}
+ }
+
+ void f() {
+ f(A<int>()); // expected-note {{in instantiation of function template specialization}}
+ }
+}
+
+namespace test5 {
+ class outer {
+ class foo;
+ template <typename T> friend struct cache;
+ };
+ class outer::foo {
+ template <typename T> friend struct cache;
+ };
+}
+
+// PR6022
+namespace PR6022 {
+ template <class T1, class T2 , class T3 > class A;
+
+ namespace inner {
+ template<class T1, class T2, class T3, class T>
+ A<T1, T2, T3>& f0(A<T1, T2, T3>&, T);
+ }
+
+ template<class T1, class T2, class T3>
+ class A {
+ template<class U1, class U2, class U3, class T>
+ friend A<U1, U2, U3>& inner::f0(A<U1, U2, U3>&, T);
+ };
+}
+
+namespace FriendTemplateDefinition {
+ template<unsigned > struct int_c { };
+
+ template<typename T>
+ struct X {
+ template<unsigned N>
+ friend void f(X, int_c<N>) {
+ int value = N;
+ };
+ };
+
+ void test_X(X<int> x, int_c<5> i5) {
+ f(x, i5);
+ }
+}
+
+namespace PR7013a {
+ template<class > struct X0
+ {
+ typedef int type;
+ };
+ template<typename > struct X1
+ {
+ };
+ template<typename , typename T> struct X2
+ {
+ typename T::type e;
+ };
+ namespace N
+ {
+ template <typename = int, typename = X1<int> > struct X3
+ {
+ template <typename T1, typename T2, typename B> friend void op(X2<T1, T2>& , B);
+ };
+ template <typename Ch, typename Tr, typename B> void op(X2<Ch, Tr>& , B)
+ {
+ X2<int, Tr> s;
+ }
+ }
+ int n()
+ {
+ X2<int, X0<int> > ngs;
+ N::X3<> b;
+ op(ngs, b);
+ return 0;
+ }
+}
+
+namespace PR7013b {
+ template<class > struct X0
+ {
+ typedef int type;
+ };
+ template<typename > struct X1
+ {
+ };
+ template<typename , typename T> struct X2
+ {
+ typename T::type e;
+ };
+ namespace N
+ {
+ template <typename = X1<int> > struct X3
+ {
+ template <typename T1, typename T2, typename B> friend void op(X2<T1, T2>& , B);
+ };
+ template <typename Ch, typename Tr, typename B> void op(X2<Ch, Tr>& , B)
+ {
+ X2<int, Tr> s;
+ }
+ }
+ int n()
+ {
+ X2<int, X0<int> > ngs;
+ N::X3<> b;
+ op(ngs, b);
+ return 0;
+ }
+
+}
+
+namespace PR8649 {
+ template<typename T, typename U, unsigned N>
+ struct X {
+ template<unsigned M> friend class X<T, U, M>; // expected-error{{partial specialization cannot be declared as a friend}}
+ };
+
+ X<int, float, 7> x;
+}
+
+// Don't crash, and error on invalid friend type template.
+namespace friend_type_template_no_tag {
+ template <typename T> struct S {
+ template <typename U> friend S<U>; // expected-error{{friend type templates must use an elaborated type}}
+ };
+ template struct S<int>;
+}
+
+namespace PR10660 {
+ struct A {
+ template <> friend class B; // expected-error{{extraneous 'template<>' in declaration of class 'B'}}
+ };
+}
+
+namespace rdar11147355 {
+ template <class T>
+ struct A {
+ template <class U> class B;
+ template <class S> template <class U> friend class A<S>::B;
+ };
+
+ template <class S> template <class U> class A<S>::B {
+ };
+
+ A<double>::B<double> ab;
+}
diff --git a/clang/test/SemaTemplate/friend.cpp b/clang/test/SemaTemplate/friend.cpp
new file mode 100644
index 0000000..e78a067
--- /dev/null
+++ b/clang/test/SemaTemplate/friend.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T> struct A {
+ struct B { };
+
+ friend struct B;
+};
+
+void f() {
+ A<int>::B b;
+}
+
+struct C0 {
+ friend struct A<int>;
+};
+
+namespace PR6770 {
+ namespace N {
+ int f1(int);
+ }
+ using namespace N;
+
+ namespace M {
+ float f1(float);
+ }
+ using M::f1;
+
+ template<typename T> void f1(T, T);
+ template <class T>
+ void f() {
+ friend class f; // expected-error{{'friend' used outside of class}}
+ friend class f1; // expected-error{{'friend' used outside of class}}
+ }
+}
diff --git a/clang/test/SemaTemplate/fun-template-def.cpp b/clang/test/SemaTemplate/fun-template-def.cpp
new file mode 100644
index 0000000..0427781
--- /dev/null
+++ b/clang/test/SemaTemplate/fun-template-def.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Tests that dependent expressions are always allowed, whereas non-dependent
+// are checked as usual.
+
+#include <stddef.h>
+
+// Fake typeid, lacking a typeinfo header.
+namespace std { class type_info {}; }
+
+struct dummy {}; // expected-note 3 {{candidate constructor (the implicit copy constructor)}}
+
+template<typename T>
+int f0(T x) {
+ return (sizeof(x) == sizeof(int))? 0 : (sizeof(x) == sizeof(double))? 1 : 2;
+}
+
+template <typename T, typename U>
+T f1(T t1, U u1, int i1)
+{
+ T t2 = i1;
+ t2 = i1 + u1;
+ ++u1;
+ u1++;
+ int i2 = u1;
+
+ i1 = t1[u1];
+ i1 *= t1;
+
+ i1(u1, t1); // error
+ u1(i1, t1);
+
+ U u2 = (T)i1;
+ static_cast<void>(static_cast<U>(reinterpret_cast<T>(
+ dynamic_cast<U>(const_cast<T>(i1)))));
+
+ new U(i1, t1);
+ new int(t1, u1);
+ new (t1, u1) int;
+ delete t1;
+
+ dummy d1 = sizeof(t1); // expected-error {{no viable conversion}}
+ dummy d2 = offsetof(T, foo); // expected-error {{no viable conversion}}
+ dummy d3 = __alignof(u1); // expected-error {{no viable conversion}}
+ i1 = typeid(t1); // expected-error {{assigning to 'int' from incompatible type 'const std::type_info'}}
+
+ return u1;
+}
diff --git a/clang/test/SemaTemplate/function-template-specialization.cpp b/clang/test/SemaTemplate/function-template-specialization.cpp
new file mode 100644
index 0000000..a0d41b2
--- /dev/null
+++ b/clang/test/SemaTemplate/function-template-specialization.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<int N> void f0(int (&array)[N]);
+
+// Simple function template specialization (using overloading)
+template<> void f0(int (&array)[1]);
+
+void test_f0() {
+ int iarr1[1];
+ f0(iarr1);
+}
+
+// Function template specialization where there are no matches
+template<> void f0(char (&array)[1]); // expected-error{{no function template matches}}
+template<> void f0<2>(int (&array)[2]) { }
+
+// Function template specialization that requires partial ordering
+template<typename T, int N> void f1(T (&array)[N]); // expected-note{{matches}}
+template<int N> void f1(int (&array)[N]); // expected-note{{matches}}
+
+template<> void f1(float (&array)[1]);
+template<> void f1(int (&array)[1]);
+
+// Function template specialization that results in an ambiguity
+template<typename T> void f1(T (&array)[17]); // expected-note{{matches}}
+template<> void f1(int (&array)[17]); // expected-error{{ambiguous}}
+
+// Resolving that ambiguity with explicitly-specified template arguments.
+template<int N> void f2(double (&array)[N]);
+template<typename T> void f2(T (&array)[42]);
+
+template<> void f2<double>(double (&array)[42]);
+template<> void f2<42>(double (&array)[42]);
+
+void f2<25>(double (&array)[25]); // expected-error{{specialization}}
+
+// PR5833
+namespace PR5833 {
+ template <typename T> bool f0(T &t1);
+ template <> bool f0<float>(float &t1);
+}
+template <> bool PR5833::f0<float>(float &t1) {}
+
+// PR8295
+namespace PR8295 {
+ template <typename T> void f(T t) {}
+ template <typename T> void f<T*>(T* t) {} // expected-error{{function template partial specialization is not allowed}}
+}
diff --git a/clang/test/SemaTemplate/implicit-instantiation-1.cpp b/clang/test/SemaTemplate/implicit-instantiation-1.cpp
new file mode 100644
index 0000000..d1bc5a8
--- /dev/null
+++ b/clang/test/SemaTemplate/implicit-instantiation-1.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T, typename U>
+struct X {
+ T f(T x, U y) { return x + y; }
+
+ unsigned g(T x, U y) { return sizeof(f(x, y)); }
+};
+
+void test(X<int, int> *xii, X<int*, int> *xpi, X<int, int*> *xip) {
+ (void)xii->f(1, 2);
+ (void)xpi->f(0, 2);
+ (void)sizeof(xip->f(2, 0)); // okay: does not instantiate
+ (void)xip->g(2, 0); // okay: does not instantiate
+}
+
+template<typename T, typename U>
+T add(T t, U u) {
+ return t + u; // expected-error{{invalid operands}}
+}
+
+void test_add(char *cp, int i, int *ip) {
+ char* cp2 = add(cp, i);
+ add(cp, cp); // expected-note{{instantiation of}}
+ (void)sizeof(add(ip, ip));
+}
diff --git a/clang/test/SemaTemplate/inject-templated-friend-post.cpp b/clang/test/SemaTemplate/inject-templated-friend-post.cpp
new file mode 100644
index 0000000..39c445c
--- /dev/null
+++ b/clang/test/SemaTemplate/inject-templated-friend-post.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang %s -S -emit-llvm -o - | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
+// RUN: %clang %s -S -emit-llvm -o - -DPROTOTYPE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
+// RUN: %clang %s -S -emit-llvm -o - -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
+// RUN: %clang %s -S -emit-llvm -o - -DPROTOTYPE -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
+// RUN: %clang_cc1 %s -DREDEFINE -verify
+// RUN: %clang_cc1 %s -DPROTOTYPE -DREDEFINE -verify
+// PR8007: friend function not instantiated, reordered version.
+// Corresponds to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38392
+
+struct std_ostream
+{
+ int dummy;
+};
+
+std_ostream cout;
+
+template <typename STRUCT_TYPE>
+struct Streamer;
+
+typedef struct Foo {} Foo;
+
+std_ostream& operator << (std_ostream&, const Streamer<Foo>&);
+
+void test(const Streamer<Foo>& foo)
+{
+ cout << foo;
+}
+
+template <typename STRUCT_TYPE>
+struct Streamer
+{
+ friend std_ostream& operator << (std_ostream& o, const Streamer& f) // expected-error{{redefinition of 'operator<<'}}
+ {
+ Streamer s(f);
+ s(o);
+ return o;
+ }
+
+ Streamer(const STRUCT_TYPE& s) : s(s) {}
+
+ const STRUCT_TYPE& s;
+ void operator () (std_ostream&) const;
+};
+
+#ifdef PROTOTYPE
+std_ostream& operator << (std_ostream&, const Streamer<Foo>&);
+#endif
+
+#ifdef INSTANTIATE
+template struct Streamer<Foo>;
+#endif
+
+#ifdef REDEFINE
+std_ostream& operator << (std_ostream& o, const Streamer<Foo>&) // expected-note{{is here}}
+{
+ return o;
+}
+#endif
+
+#ifndef INSTANTIATE
+template <>
+void Streamer<Foo>::operator () (std_ostream& o) const // expected-note{{requested here}}
+{
+}
+#endif
+
+int main(void)
+{
+ Foo foo;
+ test(foo);
+}
+
diff --git a/clang/test/SemaTemplate/inject-templated-friend.cpp b/clang/test/SemaTemplate/inject-templated-friend.cpp
new file mode 100644
index 0000000..7be613b
--- /dev/null
+++ b/clang/test/SemaTemplate/inject-templated-friend.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang %s -S -emit-llvm -o - | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
+// RUN: %clang_cc1 %s -DREDEFINE -verify
+// PR8007: friend function not instantiated.
+
+struct std_ostream
+{
+ int dummy;
+};
+
+std_ostream cout;
+
+template <typename STRUCT_TYPE>
+struct Streamer
+{
+ friend std_ostream& operator << (std_ostream& o, const Streamer& f) // expected-error{{redefinition of 'operator<<'}}
+ {
+ Streamer s(f);
+ s(o);
+ return o;
+ }
+
+ Streamer(const STRUCT_TYPE& s) : s(s) {}
+
+ const STRUCT_TYPE& s;
+ void operator () (std_ostream&) const;
+};
+
+typedef struct Foo {} Foo;
+
+std_ostream& operator << (std_ostream&, const Streamer<Foo>&);
+#ifdef REDEFINE
+std_ostream& operator << (std_ostream& o, const Streamer<Foo>&) // expected-note{{is here}}
+{
+ // Sema should flag this as a redefinition
+ return o;
+}
+#endif
+
+template <>
+void Streamer<Foo>::operator () (std_ostream& o) const // expected-note{{requested here}}
+{
+}
+
+int main(void)
+{
+ Foo foo;
+ cout << foo;
+}
diff --git a/clang/test/SemaTemplate/injected-class-name.cpp b/clang/test/SemaTemplate/injected-class-name.cpp
new file mode 100644
index 0000000..4c21d25
--- /dev/null
+++ b/clang/test/SemaTemplate/injected-class-name.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T>
+struct X {
+ X<T*> *ptr;
+};
+
+X<int> x;
+
+template<>
+struct X<int***> {
+ typedef X<int***> *ptr;
+};
+
+X<float>::X<int> xi = x; // expected-error{{qualified reference to 'X' is a constructor name rather than a template name wherever a constructor can be declared}}
+
+// [temp.local]p1:
+
+// FIXME: test template template parameters
+template<typename T, typename U>
+struct X0 {
+ typedef T type;
+ typedef U U_type;
+ typedef U_type U_type2;
+
+ void f0(const X0&); // expected-note{{here}}
+ void f0(X0&);
+ void f0(const X0<T, U>&); // expected-error{{redecl}}
+
+ void f1(const X0&); // expected-note{{here}}
+ void f1(X0&);
+ void f1(const X0<type, U_type2>&); // expected-error{{redecl}}
+
+ void f2(const X0&); // expected-note{{here}}
+ void f2(X0&);
+ void f2(const ::X0<type, U_type2>&); // expected-error{{redecl}}
+};
+
+template<typename T, T N>
+struct X1 {
+ void f0(const X1&); // expected-note{{here}}
+ void f0(X1&);
+ void f0(const X1<T, N>&); // expected-error{{redecl}}
+};
+
+namespace pr6326 {
+ template <class T> class A {
+ friend class A;
+ };
+ template class A<int>;
+}
+
+namespace ForwardDecls {
+ template<typename T>
+ struct X;
+
+ template<typename T>
+ struct X {
+ typedef T foo;
+ typedef X<T> xt;
+ typename xt::foo *t;
+ };
+}
diff --git a/clang/test/SemaTemplate/instantiate-anonymous-union.cpp b/clang/test/SemaTemplate/instantiate-anonymous-union.cpp
new file mode 100644
index 0000000..68b233a
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-anonymous-union.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -fsyntax-only %s -Wall
+
+template <typename T> class A { struct { }; };
+
+A<int> a0;
+
+template <typename T> struct B {
+ union {
+ int a;
+ void* b;
+ };
+
+ void f() {
+ a = 10;
+ b = 0;
+ }
+};
+
+B<int> b0;
+
+template <typename T> struct C {
+ union {
+ int a;
+ void* b;
+ };
+
+ C(int a) : a(a) { }
+ C(void* b) : b(b) { }
+};
+
+C<int> c0(0);
+
+namespace PR7088 {
+ template<typename T>
+ void f() {
+ union {
+ int a;
+ union {
+ float real;
+ T d;
+ };
+ };
+
+ a = 17;
+ d = 3.14;
+ }
+
+ template void f<double>();
+}
+
+// Check for problems related to PR7402 that occur when template instantiation
+// instantiates implicit initializers.
+namespace PR7402 {
+ struct X {
+ union {
+ struct {
+ int x;
+ int y;
+ };
+ int v[2];
+ };
+
+ // Check that this requirement survives instantiation.
+ template <typename T> X(const T& t) : x(t), y(t) {}
+ };
+
+ X x(42.0);
+}
+
+namespace PR9188 {
+ struct X0 {
+ union {
+ int member;
+ };
+ };
+
+ static union {
+ int global;
+ };
+
+ struct X1 : X0 {
+ template<typename T>
+ int f() {
+ return this->X0::member + PR9188::global;
+ }
+ };
+
+ template int X1::f<int>();
+}
diff --git a/clang/test/SemaTemplate/instantiate-array.cpp b/clang/test/SemaTemplate/instantiate-array.cpp
new file mode 100644
index 0000000..b8229d3
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-array.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
+#define __CONCAT(__X, __Y) __CONCAT1(__X, __Y)
+#define __CONCAT1(__X, __Y) __X ## __Y
+
+#define static_assert(__b, __m) \
+ typedef int __CONCAT(__sa, __LINE__)[__b ? 1 : -1]
+#endif
+
+template <int N> class IntArray {
+ int elems[N];
+};
+
+static_assert(sizeof(IntArray<10>) == sizeof(int) * 10, "Array size mismatch");
+static_assert(sizeof(IntArray<1>) == sizeof(int) * 1, "Array size mismatch");
+
+template <typename T> class TenElementArray {
+ int elems[10];
+};
+
+static_assert(sizeof(TenElementArray<int>) == sizeof(int) * 10, "Array size mismatch");
+
+template<typename T, int N> class Array {
+ T elems[N];
+};
+
+static_assert(sizeof(Array<int, 10>) == sizeof(int) * 10, "Array size mismatch");
diff --git a/clang/test/SemaTemplate/instantiate-attr.cpp b/clang/test/SemaTemplate/instantiate-attr.cpp
new file mode 100644
index 0000000..bbadb63
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-attr.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template <typename T>
+struct A {
+ char a __attribute__((aligned(16)));
+
+ struct B {
+ typedef T __attribute__((aligned(16))) i16;
+ i16 x;
+ };
+};
+int a[sizeof(A<int>) == 16 ? 1 : -1];
+int a2[sizeof(A<int>::B) == 16 ? 1 : -1];
+
+// rdar://problem/8243419
+namespace test1 {
+ template <typename T> struct A {
+ int a;
+ T b[0];
+ } __attribute__((packed));
+
+ typedef A<unsigned long> type;
+
+ int test0[sizeof(type) == 4 ? 1 : -1];
+ int test1[__builtin_offsetof(type, a) == 0 ? 1 : -1];
+ int test2[__builtin_offsetof(type, b) == 4 ? 1 : -1];
+}
diff --git a/clang/test/SemaTemplate/instantiate-c99.cpp b/clang/test/SemaTemplate/instantiate-c99.cpp
new file mode 100644
index 0000000..ae15528
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-c99.cpp
@@ -0,0 +1,81 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Test template instantiation for C99-specific features.
+
+// ---------------------------------------------------------------------
+// Designated initializers
+// ---------------------------------------------------------------------
+template<typename T, typename XType, typename YType>
+struct DesigInit0 {
+ void f(XType x, YType y) {
+ T agg = {
+ .y = y, // expected-error{{does not refer}}
+ .x = x // expected-error{{does not refer}}
+ };
+ }
+};
+
+struct Point2D {
+ float x, y;
+};
+
+template struct DesigInit0<Point2D, int, double>;
+
+struct Point3D {
+ float x, y, z;
+};
+
+template struct DesigInit0<Point3D, int, double>;
+
+struct Color {
+ unsigned char red, green, blue;
+};
+
+struct ColorPoint3D {
+ Color color;
+ float x, y, z;
+};
+
+template struct DesigInit0<ColorPoint3D, int, double>;
+template struct DesigInit0<Color, int, double>; // expected-note{{instantiation}}
+
+template<typename T, int Subscript1, int Subscript2,
+ typename Val1, typename Val2>
+struct DesigArrayInit0 {
+ void f(Val1 val1, Val2 val2) {
+ T array = {
+ [Subscript1] = val1,
+ [Subscript2] = val2 // expected-error{{exceeds array bounds}}
+ };
+
+ int array2[10] = { [5] = 3 };
+ }
+};
+
+template struct DesigArrayInit0<int[8], 5, 3, float, int>;
+template struct DesigArrayInit0<int[8], 5, 13, float, int>; // expected-note{{instantiation}}
+
+template<typename T, int Subscript1, int Subscript2,
+ typename Val1>
+struct DesigArrayRangeInit0 {
+ void f(Val1 val1) {
+ T array = {
+ [Subscript1...Subscript2] = val1 // expected-error{{exceeds}}
+ };
+ }
+};
+
+template struct DesigArrayRangeInit0<int[8], 3, 5, float>;
+template struct DesigArrayRangeInit0<int[8], 5, 13, float>; // expected-note{{instantiation}}
+
+// ---------------------------------------------------------------------
+// Compound literals
+// ---------------------------------------------------------------------
+template<typename T, typename Arg1, typename Arg2>
+struct CompoundLiteral0 {
+ T f(Arg1 a1, Arg2 a2) {
+ return (T){a1, a2};
+ }
+};
+
+template struct CompoundLiteral0<Point2D, int, float>;
diff --git a/clang/test/SemaTemplate/instantiate-call.cpp b/clang/test/SemaTemplate/instantiate-call.cpp
new file mode 100644
index 0000000..da1eb49
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-call.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace N1 {
+ struct X0 { };
+
+ int& f0(X0);
+}
+
+namespace N2 {
+ char& f0(char);
+
+ template<typename T, typename Result>
+ struct call_f0 {
+ void test_f0(T t) {
+ Result result = f0(t);
+ }
+ };
+}
+
+template struct N2::call_f0<int, char&>;
+template struct N2::call_f0<N1::X0, int&>;
+
+namespace N3 {
+ template<typename T, typename Result>
+ struct call_f0 {
+ void test_f0(T t) {
+ Result &result = f0(t); // expected-error {{undeclared identifier}} \
+ expected-error {{neither visible in the template definition nor found by argument-dependent lookup}}
+ }
+ };
+}
+
+template struct N3::call_f0<int, char&>; // expected-note{{instantiation}}
+template struct N3::call_f0<N1::X0, int&>;
+
+short& f0(char); // expected-note {{should be declared prior to the call site}}
+namespace N4 {
+ template<typename T, typename Result>
+ struct call_f0 {
+ void test_f0(T t) {
+ Result &result = f0(t);
+ }
+ };
+}
+
+template struct N4::call_f0<int, short&>;
+template struct N4::call_f0<N1::X0, int&>;
+template struct N3::call_f0<int, short&>; // expected-note{{instantiation}}
+
+// FIXME: test overloaded function call operators, calls to member
+// functions, etc.
diff --git a/clang/test/SemaTemplate/instantiate-case.cpp b/clang/test/SemaTemplate/instantiate-case.cpp
new file mode 100644
index 0000000..1cc2d5d
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-case.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<class T>
+static int alpha(T c)
+{
+ return *c; // expected-error{{indirection requires pointer operand}}
+}
+
+template<class T>
+static void
+_shexp_match()
+{
+ switch(1) {
+ case 1:
+ alpha(1); // expected-note{{instantiation of function template}}
+ }
+}
+int main() {
+ _shexp_match<char>(); // expected-note{{instantiation of function template}}
+ return 0;
+}
diff --git a/clang/test/SemaTemplate/instantiate-cast.cpp b/clang/test/SemaTemplate/instantiate-cast.cpp
new file mode 100644
index 0000000..b3babf1
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-cast.cpp
@@ -0,0 +1,117 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A { int x; }; // expected-note 2 {{candidate constructor}}
+
+class Base {
+public:
+ virtual void f();
+};
+
+class Derived : public Base { };
+
+struct ConvertibleToInt {
+ operator int() const;
+};
+
+struct Constructible {
+ Constructible(int, float);
+};
+
+// ---------------------------------------------------------------------
+// C-style casts
+// ---------------------------------------------------------------------
+template<typename T, typename U>
+struct CStyleCast0 {
+ void f(T t) {
+ (void)((U)t); // expected-error{{cannot convert 'A' to 'int' without a conversion operator}}
+ }
+};
+
+template struct CStyleCast0<int, float>;
+template struct CStyleCast0<A, int>; // expected-note{{instantiation}}
+
+// ---------------------------------------------------------------------
+// static_cast
+// ---------------------------------------------------------------------
+template<typename T, typename U>
+struct StaticCast0 {
+ void f(T t) {
+ (void)static_cast<U>(t); // expected-error{{no matching conversion for static_cast from 'int' to 'A'}}
+ }
+};
+
+template struct StaticCast0<ConvertibleToInt, bool>;
+template struct StaticCast0<int, float>;
+template struct StaticCast0<int, A>; // expected-note{{instantiation}}
+
+// ---------------------------------------------------------------------
+// dynamic_cast
+// ---------------------------------------------------------------------
+template<typename T, typename U>
+struct DynamicCast0 {
+ void f(T t) {
+ (void)dynamic_cast<U>(t); // expected-error{{not a reference or pointer}}
+ }
+};
+
+template struct DynamicCast0<Base*, Derived*>;
+template struct DynamicCast0<Base*, A>; // expected-note{{instantiation}}
+
+// ---------------------------------------------------------------------
+// reinterpret_cast
+// ---------------------------------------------------------------------
+template<typename T, typename U>
+struct ReinterpretCast0 {
+ void f(T t) {
+ (void)reinterpret_cast<U>(t); // expected-error{{qualifiers}}
+ }
+};
+
+template struct ReinterpretCast0<void (*)(int), void (*)(float)>;
+template struct ReinterpretCast0<int const *, float *>; // expected-note{{instantiation}}
+
+// ---------------------------------------------------------------------
+// const_cast
+// ---------------------------------------------------------------------
+template<typename T, typename U>
+struct ConstCast0 {
+ void f(T t) {
+ (void)const_cast<U>(t); // expected-error{{not allowed}}
+ }
+};
+
+template struct ConstCast0<int const * *, int * *>;
+template struct ConstCast0<int const *, float *>; // expected-note{{instantiation}}
+
+// ---------------------------------------------------------------------
+// C++ functional cast
+// ---------------------------------------------------------------------
+template<typename T, typename U>
+struct FunctionalCast1 {
+ void f(T t) {
+ (void)U(t); // expected-error{{cannot convert 'A' to 'int' without a conversion operator}}
+ }
+};
+
+template struct FunctionalCast1<int, float>;
+template struct FunctionalCast1<A, int>; // expected-note{{instantiation}}
+
+// Generates temporaries, which we cannot handle yet.
+template<int N, long M>
+struct FunctionalCast2 {
+ void f() {
+ (void)Constructible(N, M);
+ }
+};
+
+template struct FunctionalCast2<1, 3>;
+
+// ---------------------------------------------------------------------
+// implicit casting
+// ---------------------------------------------------------------------
+template<typename T>
+struct Derived2 : public Base { };
+
+void test_derived_to_base(Base *&bp, Derived2<int> *dp) {
+ bp = dp;
+}
diff --git a/clang/test/SemaTemplate/instantiate-clang.cpp b/clang/test/SemaTemplate/instantiate-clang.cpp
new file mode 100644
index 0000000..34d68c4
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-clang.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Test template instantiation for Clang-specific features.
+
+// ---------------------------------------------------------------------
+// Vector types
+// ---------------------------------------------------------------------
+typedef __attribute__(( ext_vector_type(2) )) double double2;
+typedef __attribute__(( ext_vector_type(4) )) double double4;
+
+template<typename T>
+struct ExtVectorAccess0 {
+ void f(T v1, double4 v2) {
+ v1.xy = v2.yx;
+ }
+};
+
+template struct ExtVectorAccess0<double2>;
+template struct ExtVectorAccess0<double4>;
+
+typedef __attribute__(( ext_vector_type(2) )) double double2;
+
+template<typename T, typename U, int N, int M>
+struct ShuffleVector0 {
+ void f(T t, U u, double2 a, double2 b) {
+ (void)__builtin_shufflevector(t, u, N, M); // expected-error{{index}}
+ (void)__builtin_shufflevector(a, b, N, M); // expected-error{{index}}
+ (void)__builtin_shufflevector(a, b, 2, 1);
+ }
+};
+
+template struct ShuffleVector0<double2, double2, 2, 1>;
+template struct ShuffleVector0<double2, double2, 4, 3>; // expected-note{{instantiation}}
+
+
diff --git a/clang/test/SemaTemplate/instantiate-complete.cpp b/clang/test/SemaTemplate/instantiate-complete.cpp
new file mode 100644
index 0000000..68d5ae3
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-complete.cpp
@@ -0,0 +1,146 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Tests various places where requiring a complete type involves
+// instantiation of that type.
+
+template<typename T>
+struct X {
+ X(T);
+
+ T f; // expected-error{{data member instantiated with function type 'float (int)'}} \
+ // expected-error{{data member instantiated with function type 'int (int)'}} \
+ // expected-error{{data member instantiated with function type 'char (char)'}} \
+ // expected-error{{data member instantiated with function type 'short (short)'}} \
+ // expected-error{{data member instantiated with function type 'float (float)'}}
+};
+
+X<int> f() { return 0; }
+
+struct XField {
+ X<float(int)> xf; // expected-note{{in instantiation of template class 'X<float (int)>' requested here}}
+};
+
+void test_subscript(X<double> *ptr1, X<int(int)> *ptr2, int i) {
+ (void)ptr1[i];
+ (void)ptr2[i]; // expected-note{{in instantiation of template class 'X<int (int)>' requested here}}
+}
+
+void test_arith(X<signed char> *ptr1, X<unsigned char> *ptr2,
+ X<char(char)> *ptr3, X<short(short)> *ptr4) {
+ (void)(ptr1 + 5);
+ (void)(5 + ptr2);
+ (void)(ptr3 + 5); // expected-note{{in instantiation of template class 'X<char (char)>' requested here}}
+ (void)(5 + ptr4); // expected-note{{in instantiation of template class 'X<short (short)>' requested here}}
+}
+
+void test_new() {
+ (void)new X<float>(0);
+ (void)new X<float(float)>; // expected-note{{in instantiation of template class 'X<float (float)>' requested here}}
+}
+
+void test_memptr(X<long> *p1, long X<long>::*pm1,
+ X<long(long)> *p2,
+ long (X<long(long)>::*pm2)(long)) {
+ (void)(p1->*pm1);
+}
+
+// Reference binding to a base
+template<typename T>
+struct X1 { };
+
+template<typename T>
+struct X2 : public T { };
+
+void refbind_base(X2<X1<int> > &x2) {
+ X1<int> &x1 = x2;
+}
+
+// Enumerate constructors for user-defined conversion.
+template<typename T>
+struct X3 {
+ X3(T);
+};
+
+void enum_constructors(X1<float> &x1) {
+ X3<X1<float> > x3 = x1;
+}
+
+namespace PR6376 {
+ template<typename T, typename U> struct W { };
+
+ template<typename T>
+ struct X {
+ template<typename U>
+ struct apply {
+ typedef W<T, U> type;
+ };
+ };
+
+ template<typename T, typename U>
+ struct Y : public X<T>::template apply<U>::type { };
+
+ template struct Y<int, float>;
+}
+
+namespace TemporaryObjectCopy {
+ // Make sure we instantiate classes when we create a temporary copy.
+ template<typename T>
+ struct X {
+ X(T);
+ };
+
+ template<typename T>
+ void f(T t) {
+ const X<int> &x = X<int>(t);
+ }
+
+ template void f(int);
+}
+
+namespace PR7080 {
+ template <class T, class U>
+ class X
+ {
+ typedef char true_t;
+ class false_t { char dummy[2]; };
+ static true_t dispatch(U);
+ static false_t dispatch(...);
+ static T trigger();
+ public:
+ enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) };
+ };
+
+ template <class T>
+ class rv : public T
+ { };
+
+ bool x = X<int, rv<int>&>::value;
+}
+
+namespace pr7199 {
+ template <class T> class A; // expected-note {{template is declared here}}
+ template <class T> class B {
+ class A<T>::C field; // expected-error {{implicit instantiation of undefined template 'pr7199::A<int>'}}
+ };
+
+ template class B<int>; // expected-note {{in instantiation}}
+}
+
+namespace PR8425 {
+ template <typename T>
+ class BaseT {};
+
+ template <typename T>
+ class DerivedT : public BaseT<T> {};
+
+ template <typename T>
+ class FromT {
+ public:
+ operator DerivedT<T>() const { return DerivedT<T>(); }
+ };
+
+ void test() {
+ FromT<int> ft;
+ BaseT<int> bt(ft);
+ }
+}
diff --git a/clang/test/SemaTemplate/instantiate-decl-dtor.cpp b/clang/test/SemaTemplate/instantiate-decl-dtor.cpp
new file mode 100644
index 0000000..193d976
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-decl-dtor.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+template <typename T> struct A {
+ T x;
+ A(int y) { x = y; }
+ ~A() { *x = 10; } // expected-error {{indirection requires pointer operand}}
+};
+
+void a() {
+ A<int> b = 10; // expected-note {{requested here}}
+}
diff --git a/clang/test/SemaTemplate/instantiate-decl-init.cpp b/clang/test/SemaTemplate/instantiate-decl-init.cpp
new file mode 100644
index 0000000..6b76d72
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-decl-init.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR5426 - the non-dependent obj would be fully processed and wrapped in a
+// CXXConstructExpr at definition time, which would lead to a failure at
+// instantiation time.
+struct arg {
+ arg();
+};
+
+struct oldstylemove {
+ oldstylemove(oldstylemove&);
+ oldstylemove(const arg&);
+};
+
+template <typename T>
+void fn(T t, const arg& arg) {
+ oldstylemove obj(arg);
+}
+
+void test() {
+ fn(1, arg());
+}
+
+struct X0 { };
+
+struct X1 {
+ explicit X1(const X0 &x0 = X0());
+};
+
+template<typename T>
+void f0() {
+ X1 x1;
+}
+
+template void f0<int>();
+template void f0<float>();
+
+struct NonTrivial {
+ NonTrivial();
+ ~NonTrivial();
+};
+
+template<int N> void f1() {
+ NonTrivial array[N];
+}
+template<> void f1<2>();
diff --git a/clang/test/SemaTemplate/instantiate-declref-ice.cpp b/clang/test/SemaTemplate/instantiate-declref-ice.cpp
new file mode 100644
index 0000000..49b1b63
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-declref-ice.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<int i> struct x {
+ static const int j = i;
+ x<j>* y;
+};
+
+template<int i>
+const int x<i>::j;
+
+int array0[x<2>::j];
+
+template<typename T>
+struct X0 {
+ static const unsigned value = sizeof(T);
+};
+
+template<typename T>
+const unsigned X0<T>::value;
+
+int array1[X0<int>::value == sizeof(int)? 1 : -1];
+
+const unsigned& testX0() { return X0<int>::value; }
+
+int array2[X0<int>::value == sizeof(int)? 1 : -1];
+
+template<typename T>
+struct X1 {
+ static const unsigned value;
+};
+
+template<typename T>
+const unsigned X1<T>::value = sizeof(T);
+
+int array3[X1<int>::value == sizeof(int)? 1 : -1];
diff --git a/clang/test/SemaTemplate/instantiate-declref.cpp b/clang/test/SemaTemplate/instantiate-declref.cpp
new file mode 100644
index 0000000..7d4a2ff
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-declref.cpp
@@ -0,0 +1,117 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+namespace N {
+ struct Outer {
+ struct Inner {
+ template<typename T>
+ struct InnerTemplate {
+ struct VeryInner {
+ typedef T type;
+
+ static enum K1 { K1Val = sizeof(T) } Kind1;
+ static enum { K2Val = sizeof(T)*2 } Kind2;
+ enum { K3Val = sizeof(T)*2 } Kind3;
+
+ void foo() {
+ K1 k1 = K1Val;
+ Kind1 = K1Val;
+ Outer::Inner::InnerTemplate<type>::VeryInner::Kind2 = K2Val;
+ Kind3 = K3Val;
+ }
+
+ struct UeberInner {
+ void bar() {
+ K1 k1 = K1Val;
+ Kind1 = K1Val;
+ Outer::Inner::InnerTemplate<type>::VeryInner::Kind2 = K2Val;
+
+ InnerTemplate t;
+ InnerTemplate<type> t2;
+ }
+ };
+ };
+ };
+ };
+ };
+}
+
+typedef int INT;
+template struct N::Outer::Inner::InnerTemplate<INT>::VeryInner;
+template struct N::Outer::Inner::InnerTemplate<INT>::UeberInner; // expected-error{{no struct named 'UeberInner' in 'N::Outer::Inner::InnerTemplate<int>'}}
+
+namespace N2 {
+ struct Outer2 {
+ template<typename T, typename U = T>
+ struct Inner {
+ void foo() {
+ enum { K1Val = sizeof(T) } k1;
+ enum K2 { K2Val = sizeof(T)*2 } k2a;
+
+ K2 k2b = K2Val;
+
+ struct S { T x, y; } s1;
+ struct { U x, y; } s2;
+ s1.x = s2.x; // expected-error{{incompatible}}
+
+ typedef T type;
+ type t2 = s1.x;
+
+ typedef struct { T z; } type2;
+ type2 t3 = { s1.x };
+
+ Inner i1;
+ i1.foo();
+ Inner<T> i2;
+ i2.foo();
+ }
+ };
+ };
+}
+
+template struct N2::Outer2::Inner<float>;
+template struct N2::Outer2::Inner<int*, float*>; // expected-note{{instantiation}}
+
+// Test dependent pointer-to-member expressions.
+template<typename T>
+struct smart_ptr {
+ struct safe_bool {
+ int member;
+ };
+
+ operator int safe_bool::*() const {
+ return ptr? &safe_bool::member : 0;
+ }
+
+ T* ptr;
+};
+
+void test_smart_ptr(smart_ptr<int> p) {
+ if (p) { }
+}
+
+// PR5517
+namespace test0 {
+ template <int K> struct X {
+ X() { extern void x(); }
+ };
+ void g() { X<2>(); }
+}
+
+// <rdar://problem/8302161>
+namespace test1 {
+ template <typename T> void f(T const &t) {
+ union { char c; T t_; };
+ c = 'a'; // <- this shouldn't silently fail to instantiate
+ T::foo(); // expected-error {{has no members}}
+ }
+ template void f(int const &); // expected-note {{requested here}}
+}
+
+namespace test2 {
+ template<typename T> void f() {
+ T::error; // expected-error {{no member}}
+ }
+ void g() {
+ // This counts as an odr-use, so should trigger the instantiation of f<int>.
+ (void)&f<int>; // expected-note {{here}}
+ }
+}
diff --git a/clang/test/SemaTemplate/instantiate-deeply.cpp b/clang/test/SemaTemplate/instantiate-deeply.cpp
new file mode 100644
index 0000000..c5f6594
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-deeply.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -Wall -verify %s
+template<typename a> struct A {
+ template <typename b> struct B {
+ template <typename c> struct C {
+ template <typename d> struct D {
+ template <typename e> struct E {
+ e field;
+ E() : field(0) {
+ d v1 = 4;
+ c v2 = v1 * v1;
+ b v3 = 8;
+ a v4 = v3 * v3;
+ field += v2 + v4;
+ }
+ };
+ };
+ };
+ };
+};
+
+A<int>::B<int>::C<int>::D<int>::E<int> global;
+
+// PR5352
+template <typename T>
+class Foo {
+public:
+ Foo() {}
+
+ struct Bar {
+ T value;
+ };
+
+ Bar u;
+};
+
+template class Foo<int>;
diff --git a/clang/test/SemaTemplate/instantiate-default-assignment-operator.cpp b/clang/test/SemaTemplate/instantiate-default-assignment-operator.cpp
new file mode 100644
index 0000000..31cdef5
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-default-assignment-operator.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename> struct PassRefPtr { };
+template<typename T> struct RefPtr {
+ RefPtr& operator=(const RefPtr&) { int a[sizeof(T) ? -1 : -1];} // expected-error 2 {{array with a negative size}}
+ RefPtr& operator=(const PassRefPtr<T>&);
+};
+
+struct A { RefPtr<int> a; }; // expected-note {{instantiation of member function 'RefPtr<int>::operator=' requested here}}
+struct B : RefPtr<float> { }; // expected-note {{in instantiation of member function 'RefPtr<float>::operator=' requested here}}
+
+void f() {
+ A a1, a2;
+ a1 = a2;
+
+ B b1, b2;
+ b1 = b2;
+}
diff --git a/clang/test/SemaTemplate/instantiate-dependent-nested-name.cpp b/clang/test/SemaTemplate/instantiate-dependent-nested-name.cpp
new file mode 100644
index 0000000..eb1d3fb
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-dependent-nested-name.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR4382
+template<typename T> struct X { static const T A = 1; };
+template<typename T, bool = X<T>::A> struct Y { typedef T A; };
+template<typename T> struct Z { typedef typename Y<T>::A A; };
+extern int x;
+extern Z<int>::A x;
diff --git a/clang/test/SemaTemplate/instantiate-elab-type-specifier.cpp b/clang/test/SemaTemplate/instantiate-elab-type-specifier.cpp
new file mode 100644
index 0000000..e5e10a8
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-elab-type-specifier.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR5681
+template <class T> struct Base {
+ struct foo {};
+ int foo;
+};
+
+template <class T> struct Derived : Base<T> {
+ typedef struct Base<T>::foo type;
+};
+
+template struct Derived<int>;
diff --git a/clang/test/SemaTemplate/instantiate-enum-2.cpp b/clang/test/SemaTemplate/instantiate-enum-2.cpp
new file mode 100644
index 0000000..aa3b590
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-enum-2.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+template<int IntBits> struct X {
+ enum {
+ IntShift = (unsigned long long)IntBits,
+ ShiftedIntMask = (1 << IntShift)
+ };
+};
+X<1> x;
diff --git a/clang/test/SemaTemplate/instantiate-enum.cpp b/clang/test/SemaTemplate/instantiate-enum.cpp
new file mode 100644
index 0000000..5353a92
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-enum.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+template<typename T, T I, int J>
+struct adder {
+ enum {
+ value = I + J,
+ value2
+ };
+};
+
+int array1[adder<long, 3, 4>::value == 7? 1 : -1];
+
+namespace PR6375 {
+ template<typename T>
+ void f() {
+ enum Enum
+ {
+ enumerator1 = 0xFFFFFFF,
+ enumerator2 = enumerator1 - 1
+ };
+
+ int xb1 = enumerator1;
+ int xe1 = enumerator2;
+ }
+
+ template void f<int>();
+}
diff --git a/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp b/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
new file mode 100644
index 0000000..8a6f9ef
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
@@ -0,0 +1,133 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -ftemplate-depth 16 -fcxx-exceptions -fexceptions %s
+
+// DR1330: an exception specification for a function template is only
+// instantiated when it is needed.
+
+template<typename T> void f1(T*) throw(T); // expected-error{{incomplete type 'Incomplete' is not allowed in exception specification}}
+struct Incomplete; // expected-note{{forward}}
+
+void test_f1(Incomplete *incomplete_p, int *int_p) {
+ f1(int_p);
+ f1(incomplete_p); // expected-note{{instantiation of exception spec}}
+}
+
+template<typename T> struct A {
+ template<typename U> struct B {
+ static void f() noexcept(A<U>().n);
+ };
+
+ constexpr A() : n(true) {}
+ bool n;
+};
+
+static_assert(noexcept(A<int>::B<char>::f()), "");
+
+template<unsigned N> struct S {
+ static void recurse() noexcept(noexcept(S<N+1>::recurse())); // \
+ // expected-error {{no member named 'recurse'}} \
+ // expected-note 9{{instantiation of exception spec}}
+};
+decltype(S<0>::recurse()) *pVoid1 = 0; // ok, exception spec not needed
+decltype(&S<0>::recurse) pFn = 0; // ok, exception spec not needed
+
+template<> struct S<10> {};
+void (*pFn2)() noexcept = &S<0>::recurse; // expected-note {{instantiation of exception spec}} expected-error {{not superset}}
+
+
+template<typename T> T go(T a) noexcept(noexcept(go(a))); // \
+// expected-error 16{{call to function 'go' that is neither visible}} \
+// expected-note 16{{'go' should be declared prior to the call site}} \
+// expected-error {{recursive template instantiation exceeded maximum depth of 16}} \
+// expected-error {{use of undeclared identifier 'go'}} \
+
+void f() {
+ int k = go(0); // \
+ // expected-note {{in instantiation of exception specification for 'go<int>' requested here}}
+}
+
+
+namespace dr1330_example {
+ template <class T> struct A {
+ void f(...) throw (typename T::X); // expected-error {{'int'}}
+ void f(int);
+ };
+
+ int main() {
+ A<int>().f(42);
+ }
+
+ int test2() {
+ struct S {
+ template<typename T>
+ static int f() noexcept(noexcept(A<T>().f("boo!"))) { return 0; } // \
+ // expected-note {{instantiation of exception spec}}
+ typedef decltype(f<S>()) X;
+ };
+ S().f<S>(); // ok
+ S().f<int>(); // expected-note {{instantiation of exception spec}}
+ }
+}
+
+namespace core_19754_example {
+ template<typename T> T declval() noexcept;
+
+ template<typename T, typename = decltype(T(declval<T&&>()))>
+ struct is_movable { static const bool value = true; };
+
+ template<typename T>
+ struct wrap {
+ T val;
+ void irrelevant(wrap &p) noexcept(is_movable<T>::value);
+ };
+
+ template<typename T>
+ struct base {
+ base() {}
+ base(const typename T::type1 &);
+ base(const typename T::type2 &);
+ };
+
+ template<typename T>
+ struct type1 {
+ wrap<typename T::base> base;
+ };
+
+ template<typename T>
+ struct type2 {
+ wrap<typename T::base> base;
+ };
+
+ struct types {
+ typedef base<types> base;
+ typedef type1<types> type1;
+ typedef type2<types> type2;
+ };
+
+ base<types> val = base<types>();
+}
+
+namespace pr9485 {
+ template <typename T> void f1(T) throw(typename T::exception); // expected-note {{candidate}}
+ template <typename T> void f1(T, int = 0) throw(typename T::noitpecxe); // expected-note {{candidate}}
+
+ template <typename T> void f2(T) noexcept(T::throws); // expected-note {{candidate}}
+ template <typename T> void f2(T, int = 0) noexcept(T::sworht); // expected-note {{candidate}}
+
+ void test() {
+ f1(0); // expected-error {{ambiguous}}
+ f2(0); // expected-error {{ambiguous}}
+ }
+}
+
+struct Exc1 { char c[4]; };
+struct Exc2 { double x, y, z; };
+struct Base {
+ virtual void f() noexcept; // expected-note {{overridden}}
+};
+template<typename T> struct Derived : Base {
+ void f() noexcept (sizeof(T) == 4); // expected-error {{is more lax}}
+ void g() noexcept (T::error);
+};
+
+Derived<Exc1> d1; // ok
+Derived<Exc2> d2; // expected-note {{in instantiation of}}
diff --git a/clang/test/SemaTemplate/instantiate-exception-spec.cpp b/clang/test/SemaTemplate/instantiate-exception-spec.cpp
new file mode 100644
index 0000000..d4f12df
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-exception-spec.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// FIXME: the "note" should be down at the call site!
+template<typename T> void f1(T*) throw(T); // expected-error{{incomplete type 'Incomplete' is not allowed in exception specification}} \
+ // expected-note{{instantiation of}}
+struct Incomplete; // expected-note{{forward}}
+
+void test_f1(Incomplete *incomplete_p, int *int_p) {
+ f1(int_p);
+ f1(incomplete_p);
+}
diff --git a/clang/test/SemaTemplate/instantiate-expr-1.cpp b/clang/test/SemaTemplate/instantiate-expr-1.cpp
new file mode 100644
index 0000000..9395117
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-expr-1.cpp
@@ -0,0 +1,192 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<int I, int J>
+struct Bitfields {
+ int simple : I; // expected-error{{bit-field 'simple' has zero width}}
+ int parens : (J);
+};
+
+void test_Bitfields(Bitfields<0, 5> *b) {
+ (void)sizeof(Bitfields<10, 5>);
+ (void)sizeof(Bitfields<0, 1>); // expected-note{{in instantiation of template class 'Bitfields<0, 1>' requested here}}
+}
+
+template<int I, int J>
+struct BitfieldPlus {
+ int bitfield : I + J; // expected-error{{bit-field 'bitfield' has zero width}}
+};
+
+void test_BitfieldPlus() {
+ (void)sizeof(BitfieldPlus<0, 1>);
+ (void)sizeof(BitfieldPlus<-5, 5>); // expected-note{{in instantiation of template class 'BitfieldPlus<-5, 5>' requested here}}
+}
+
+template<int I, int J>
+struct BitfieldMinus {
+ int bitfield : I - J; // expected-error{{bit-field 'bitfield' has negative width (-1)}} \
+ // expected-error{{bit-field 'bitfield' has zero width}}
+};
+
+void test_BitfieldMinus() {
+ (void)sizeof(BitfieldMinus<5, 1>);
+ (void)sizeof(BitfieldMinus<0, 1>); // expected-note{{in instantiation of template class 'BitfieldMinus<0, 1>' requested here}}
+ (void)sizeof(BitfieldMinus<5, 5>); // expected-note{{in instantiation of template class 'BitfieldMinus<5, 5>' requested here}}
+}
+
+template<int I, int J>
+struct BitfieldDivide {
+ int bitfield : I / J; // expected-error{{expression is not an integral constant expression}} \
+ // expected-note{{division by zero}}
+};
+
+void test_BitfieldDivide() {
+ (void)sizeof(BitfieldDivide<5, 1>);
+ (void)sizeof(BitfieldDivide<5, 0>); // expected-note{{in instantiation of template class 'BitfieldDivide<5, 0>' requested here}}
+}
+
+template<typename T, T I, int J>
+struct BitfieldDep {
+ int bitfield : I + J;
+};
+
+void test_BitfieldDep() {
+ (void)sizeof(BitfieldDep<int, 1, 5>);
+}
+
+template<int I>
+struct BitfieldNeg {
+ int bitfield : (-I); // expected-error{{bit-field 'bitfield' has negative width (-5)}}
+};
+
+template<typename T, T I>
+struct BitfieldNeg2 {
+ int bitfield : (-I); // expected-error{{bit-field 'bitfield' has negative width (-5)}}
+};
+
+void test_BitfieldNeg() {
+ (void)sizeof(BitfieldNeg<-5>); // okay
+ (void)sizeof(BitfieldNeg<5>); // expected-note{{in instantiation of template class 'BitfieldNeg<5>' requested here}}
+ (void)sizeof(BitfieldNeg2<int, -5>); // okay
+ (void)sizeof(BitfieldNeg2<int, 5>); // expected-note{{in instantiation of template class 'BitfieldNeg2<int, 5>' requested here}}
+}
+
+template<typename T>
+void increment(T &x) {
+ (void)++x;
+}
+
+struct Incrementable {
+ Incrementable &operator++();
+};
+
+void test_increment(Incrementable inc) {
+ increment(inc);
+}
+
+template<typename T>
+void add(const T &x) {
+ (void)(x + x);
+}
+
+namespace PR6237 {
+ template <typename T>
+ void f(T t) {
+ t++;
+ }
+
+ struct B { };
+ B operator++(B &, int);
+
+ template void f(B);
+}
+
+struct Addable {
+ Addable operator+(const Addable&) const;
+};
+
+void test_add(Addable &a) {
+ add(a);
+}
+
+struct CallOperator {
+ int &operator()(int);
+ double &operator()(double);
+};
+
+template<typename Result, typename F, typename Arg1>
+Result test_call_operator(F f, Arg1 arg1) {
+ // PR5266: non-dependent invocations of a function call operator.
+ CallOperator call_op;
+ int &ir = call_op(17);
+ return f(arg1);
+}
+
+void test_call_operator(CallOperator call_op, int i, double d) {
+ int &ir = test_call_operator<int&>(call_op, i);
+ double &dr = test_call_operator<double&>(call_op, d);
+}
+
+template<typename T>
+void test_asm(T t) {
+ asm ("nop" : "=a"(*t) : "r"(*t)); // expected-error {{indirection requires pointer operand ('int' invalid)}}
+}
+
+void test_asm() {
+ int* a;
+ test_asm(a);
+
+ int b;
+ test_asm(b); // expected-note {{in instantiation of function template specialization 'test_asm<int>' requested here}}
+}
+
+namespace PR6424 {
+ template<int I> struct X {
+ X() {
+ int *ip = I; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
+ }
+ };
+
+ template<int> struct Y {
+ typedef X<7> X7;
+
+ void f() { X7(); } // expected-note{{instantiation}}
+ };
+
+ template void Y<3>::f();
+
+ template<int I>
+ struct X2 {
+ void *operator new(__SIZE_TYPE__) {
+ int *ip = I; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
+ return ip;
+ }
+ };
+
+ template<int> struct Y2 {
+ typedef X2<7> X;
+ void f() {
+ new X(); // expected-note{{instantiation of}}
+ }
+ };
+
+ template void Y2<3>::f();
+
+ template<typename T>
+ void rdar10283928(int count) {
+ (void)new char[count]();
+ }
+
+ template void rdar10283928<int>(int);
+}
+
+namespace PR10864 {
+ template<typename T> class Vals {};
+ template<> class Vals<int> { public: static const int i = 1; };
+ template<> class Vals<float> { public: static const double i; };
+ template<typename T> void test_asm_tied(T o) {
+ __asm("addl $1, %0" : "=r" (o) : "0"(Vals<T>::i)); // expected-error {{input with type 'double' matching output with type 'float'}}
+ }
+ void test_asm_tied() {
+ test_asm_tied(1);
+ test_asm_tied(1.f); // expected-note {{instantiation of}}
+ }
+}
diff --git a/clang/test/SemaTemplate/instantiate-expr-2.cpp b/clang/test/SemaTemplate/instantiate-expr-2.cpp
new file mode 100644
index 0000000..eaa68dd
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-expr-2.cpp
@@ -0,0 +1,245 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+typedef char one_byte;
+typedef char (&two_bytes)[2];
+typedef char (&four_bytes)[4];
+typedef char (&eight_bytes)[8];
+
+template<int N> struct A { };
+
+namespace N1 {
+ struct X { };
+}
+
+namespace N2 {
+ struct Y { };
+
+ two_bytes operator+(Y, Y);
+}
+
+namespace N3 {
+ struct Z { };
+
+ eight_bytes operator+(Z, Z);
+}
+
+namespace N4 {
+ one_byte operator+(N1::X, N2::Y);
+
+ template<typename T, typename U>
+ struct BinOpOverload {
+ typedef A<sizeof(T() + U())> type;
+ };
+}
+
+namespace N1 {
+ four_bytes operator+(X, X);
+}
+
+namespace N3 {
+ eight_bytes operator+(Z, Z); // redeclaration
+}
+
+void test_bin_op_overload(A<1> *a1, A<2> *a2, A<4> *a4, A<8> *a8) {
+ typedef N4::BinOpOverload<N1::X, N2::Y>::type XY;
+ XY *xy = a1;
+ typedef N4::BinOpOverload<N1::X, N1::X>::type XX;
+ XX *xx = a4;
+ typedef N4::BinOpOverload<N2::Y, N2::Y>::type YY;
+ YY *yy = a2;
+ typedef N4::BinOpOverload<N3::Z, N3::Z>::type ZZ;
+ ZZ *zz = a8;
+}
+
+namespace N3 {
+ eight_bytes operator-(::N3::Z);
+}
+
+namespace N4 {
+ template<typename T>
+ struct UnaryOpOverload {
+ typedef A<sizeof(-T())> type;
+ };
+}
+
+void test_unary_op_overload(A<8> *a8) {
+ typedef N4::UnaryOpOverload<N3::Z>::type UZ;
+ UZ *uz = a8;
+}
+
+/*
+namespace N5 {
+ template<int I>
+ struct Lookup {
+ enum { val = I, more = val + 1 };
+ };
+
+ template<bool B>
+ struct Cond {
+ enum Junk { is = B ? Lookup<B>::more : Lookup<Lookup<B+1>::more>::val };
+ };
+
+ enum { resultT = Cond<true>::is,
+ resultF = Cond<false>::is };
+}
+*/
+
+namespace N6 {
+ // non-typedependent
+ template<int I>
+ struct Lookup {};
+
+ template<bool B, typename T, typename E>
+ struct Cond {
+ typedef Lookup<B ? sizeof(T) : sizeof(E)> True;
+ typedef Lookup<!B ? sizeof(T) : sizeof(E)> False;
+ };
+
+ typedef Cond<true, int, char>::True True;
+ typedef Cond<true, int, char>::False False;
+
+ // check that we have the right types
+ Lookup<1> const &L1(False());
+ Lookup<sizeof(int)> const &L2(True());
+}
+
+
+namespace N7 {
+ // type dependent
+ template<int I>
+ struct Lookup {};
+
+ template<bool B, typename T, typename E>
+ struct Cond {
+ T foo() { return B ? T() : E(); }
+ typedef Lookup<sizeof(B ? T() : E())> Type;
+ };
+
+ //Cond<true, int*, double> C; // Errors
+ //int V(C.foo()); // Errors
+ //typedef Cond<true, int*, double>::Type Type; // Errors
+ typedef Cond<true, int, double>::Type Type;
+}
+
+template<typename T, unsigned long N> struct IntegralConstant { };
+
+template<typename T>
+struct X0 {
+ void f(T x, IntegralConstant<T, sizeof(x)>);
+};
+
+void test_X0(X0<int> x, IntegralConstant<int, sizeof(int)> ic) {
+ x.f(5,ic);
+}
+
+namespace N8 {
+ struct X {
+ X operator+(const X&) const;
+ };
+
+ template<typename T>
+ T test_plus(const T* xp, const T& x, const T& y) {
+ x.operator+(y);
+ return xp->operator+(y);
+ }
+
+ void test_test_plus(X x) {
+ test_plus(&x, x, x);
+ }
+}
+
+namespace N9 {
+ struct A {
+ bool operator==(int value);
+ };
+
+ template<typename T> struct B {
+ bool f(A a) {
+ return a == 1;
+ }
+ };
+
+ template struct B<int>;
+}
+
+namespace N10 {
+ template <typename T>
+ class A {
+ struct X { };
+
+ public:
+ ~A() {
+ f(reinterpret_cast<X *>(0), reinterpret_cast<X *>(0));
+ }
+
+ private:
+ void f(X *);
+ void f(X *, X *);
+ };
+
+ template class A<int>;
+}
+
+namespace N12 {
+ // PR5224
+ template<typename T>
+ struct A { typedef int t0; };
+
+ struct C {
+ C(int);
+
+ template<typename T>
+ static C *f0(T a0) {return new C((typename A<T>::t0) 1); }
+ };
+
+ void f0(int **a) { C::f0(a); }
+}
+
+namespace PR7202 {
+ template<typename U, typename T>
+ struct meta {
+ typedef T type;
+ };
+
+ struct X {
+ struct dummy;
+
+ template<typename T>
+ X(T, typename meta<T, dummy*>::type = 0);
+
+ template<typename T, typename A>
+ X(T, A);
+ };
+
+ template<typename T>
+ struct Z { };
+
+ template<typename T> Z<T> g(T);
+
+ struct Y {
+ template<typename T>
+ void f(T t) {
+ new X(g(*this));
+ }
+ };
+
+ template void Y::f(int);
+}
+
+namespace N13 {
+ class A{
+ A(const A&);
+
+ public:
+ ~A();
+ A(int);
+ template<typename T> A &operator<<(const T&);
+ };
+
+ template<typename T>
+ void f(T t) {
+ A(17) << t;
+ }
+
+ template void f(int);
+
+}
diff --git a/clang/test/SemaTemplate/instantiate-expr-3.cpp b/clang/test/SemaTemplate/instantiate-expr-3.cpp
new file mode 100644
index 0000000..ca88b00
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-expr-3.cpp
@@ -0,0 +1,119 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// ---------------------------------------------------------------------
+// Imaginary literals
+// ---------------------------------------------------------------------
+template<typename T>
+struct ImaginaryLiteral0 {
+ void f(T &x) {
+ x = 3.0I; // expected-error{{incompatible type}}
+ }
+};
+
+template struct ImaginaryLiteral0<_Complex float>;
+template struct ImaginaryLiteral0<int*>; // expected-note{{instantiation}}
+
+// ---------------------------------------------------------------------
+// Compound assignment operator
+// ---------------------------------------------------------------------
+namespace N1 {
+ struct X { };
+
+ int& operator+=(X&, int); // expected-note{{candidate}}
+}
+
+namespace N2 {
+ long& operator+=(N1::X&, long); // expected-note{{candidate}}
+
+ template<typename T, typename U, typename Result>
+ struct PlusEquals0 {
+ void f(T t, U u) {
+ Result r = t += u; // expected-error{{ambiguous}}
+ }
+ };
+}
+
+namespace N3 {
+ struct Y : public N1::X {
+ short& operator+=(long); // expected-note{{candidate}}
+ };
+}
+
+template struct N2::PlusEquals0<N1::X, int, int&>;
+template struct N2::PlusEquals0<N1::X, long, long&>;
+template struct N2::PlusEquals0<N3::Y, long, short&>;
+template struct N2::PlusEquals0<int, int, int&>;
+template struct N2::PlusEquals0<N3::Y, int, short&>; // expected-note{{instantiation}}
+
+// ---------------------------------------------------------------------
+// Conditional operator
+// ---------------------------------------------------------------------
+template<typename T, typename U, typename Result>
+struct Conditional0 {
+ void f(T t, U u) {
+ Result result = t? : u;
+ }
+};
+
+template struct Conditional0<int, int, int>;
+
+// ---------------------------------------------------------------------
+// Statement expressions
+// ---------------------------------------------------------------------
+template<typename T>
+struct StatementExpr0 {
+ void f(T t) {
+ (void)({
+ if (t) // expected-error{{contextually convertible}}
+ t = t + 17;
+ t + 12; // expected-error{{invalid operands}}
+ });
+ }
+};
+
+template struct StatementExpr0<int>;
+template struct StatementExpr0<N1::X>; // expected-note{{instantiation}}
+
+// ---------------------------------------------------------------------
+// __builtin_choose_expr
+// ---------------------------------------------------------------------
+template<bool Cond, typename T, typename U, typename Result>
+struct Choose0 {
+ void f(T t, U u) {
+ Result r = __builtin_choose_expr(Cond, t, u); // expected-error{{lvalue}}
+ }
+};
+
+template struct Choose0<true, int, float, int&>;
+template struct Choose0<false, int, float, float&>;
+template struct Choose0<true, int, float, float&>; // expected-note{{instantiation}}
+
+// ---------------------------------------------------------------------
+// __builtin_va_arg
+// ---------------------------------------------------------------------
+template<typename ArgType>
+struct VaArg0 {
+ void f(int n, ...) {
+ __builtin_va_list va;
+ __builtin_va_start(va, n);
+ for (int i = 0; i != n; ++i)
+ (void)__builtin_va_arg(va, ArgType);
+ __builtin_va_end(va);
+ }
+};
+
+template struct VaArg0<int>;
+
+template<typename VaList, typename ArgType>
+struct VaArg1 {
+ void f(int n, ...) {
+ VaList va;
+ __builtin_va_start(va, n); // expected-error{{int}}
+ for (int i = 0; i != n; ++i)
+ (void)__builtin_va_arg(va, ArgType); // expected-error{{int}}
+ __builtin_va_end(va); // expected-error{{int}}
+ }
+};
+
+template struct VaArg1<__builtin_va_list, int>;
+template struct VaArg1<int, int>; // expected-note{{instantiation}}
diff --git a/clang/test/SemaTemplate/instantiate-expr-4.cpp b/clang/test/SemaTemplate/instantiate-expr-4.cpp
new file mode 100644
index 0000000..d95ccfe
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-expr-4.cpp
@@ -0,0 +1,354 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
+
+// ---------------------------------------------------------------------
+// C++ Functional Casts
+// ---------------------------------------------------------------------
+template<int N>
+struct ValueInit0 {
+ int f() {
+ return int();
+ }
+};
+
+template struct ValueInit0<5>;
+
+template<int N>
+struct FunctionalCast0 {
+ int f() {
+ return int(N);
+ }
+};
+
+template struct FunctionalCast0<5>;
+
+struct X { // expected-note 3 {{candidate constructor (the implicit copy constructor)}}
+ X(int, int); // expected-note 3 {{candidate constructor}}
+};
+
+template<int N, int M>
+struct BuildTemporary0 {
+ X f() {
+ return X(N, M);
+ }
+};
+
+template struct BuildTemporary0<5, 7>;
+
+template<int N, int M>
+struct Temporaries0 {
+ void f() {
+ (void)X(N, M);
+ }
+};
+
+template struct Temporaries0<5, 7>;
+
+// Ensure that both the constructor and the destructor are instantiated by
+// checking for parse errors from each.
+template<int N> struct BadX {
+ BadX() { int a[-N]; } // expected-error {{array with a negative size}}
+ ~BadX() { int a[-N]; } // expected-error {{array with a negative size}}
+};
+
+template<int N>
+struct PR6671 {
+ void f() { (void)BadX<1>(); } // expected-note 2 {{instantiation}}
+};
+template struct PR6671<1>;
+
+// ---------------------------------------------------------------------
+// new/delete expressions
+// ---------------------------------------------------------------------
+struct Y { };
+
+template<typename T>
+struct New0 {
+ T* f(bool x) {
+ if (x)
+ return new T; // expected-error{{no matching}}
+ else
+ return new T();
+ }
+};
+
+template struct New0<int>;
+template struct New0<Y>;
+template struct New0<X>; // expected-note{{instantiation}}
+
+template<typename T, typename Arg1>
+struct New1 {
+ T* f(bool x, Arg1 a1) {
+ return new T(a1); // expected-error{{no matching}}
+ }
+};
+
+template struct New1<int, float>;
+template struct New1<Y, Y>;
+template struct New1<X, Y>; // expected-note{{instantiation}}
+
+template<typename T, typename Arg1, typename Arg2>
+struct New2 {
+ T* f(bool x, Arg1 a1, Arg2 a2) {
+ return new T(a1, a2); // expected-error{{no matching}}
+ }
+};
+
+template struct New2<X, int, float>;
+template struct New2<X, int, int*>; // expected-note{{instantiation}}
+// FIXME: template struct New2<int, int, float>;
+
+// PR5833
+struct New3 {
+ New3();
+
+ void *operator new[](__SIZE_TYPE__) __attribute__((unavailable)); // expected-note{{explicitly made unavailable}}
+};
+
+template<class C>
+void* object_creator() {
+ return new C(); // expected-error{{call to unavailable function 'operator new[]'}}
+}
+
+template void *object_creator<New3[4]>(); // expected-note{{instantiation}}
+
+template<typename T>
+struct Delete0 {
+ void f(T t) {
+ delete t; // expected-error{{cannot delete}}
+ ::delete [] t; // expected-error{{cannot delete}}
+ }
+};
+
+template struct Delete0<int*>;
+template struct Delete0<X*>;
+template struct Delete0<int>; // expected-note{{instantiation}}
+
+namespace PR5755 {
+ template <class T>
+ void Foo() {
+ char* p = 0;
+ delete[] p;
+ }
+
+ void Test() {
+ Foo<int>();
+ }
+}
+
+namespace PR10480 {
+ template<typename T>
+ struct X {
+ X();
+ ~X() {
+ T *ptr = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
+ }
+ };
+
+ template<typename T>
+ void f() {
+ new X<int>[1]; // expected-note{{in instantiation of member function 'PR10480::X<int>::~X' requested here}}
+ }
+
+ template void f<int>();
+}
+
+// ---------------------------------------------------------------------
+// throw expressions
+// ---------------------------------------------------------------------
+template<typename T>
+struct Throw1 {
+ void f(T t) {
+ throw;
+ throw t; // expected-error{{incomplete type}}
+ }
+};
+
+struct Incomplete; // expected-note 2{{forward}}
+
+template struct Throw1<int>;
+template struct Throw1<int*>;
+template struct Throw1<Incomplete*>; // expected-note{{instantiation}}
+
+// ---------------------------------------------------------------------
+// typeid expressions
+// ---------------------------------------------------------------------
+
+namespace std {
+ class type_info;
+}
+
+template<typename T>
+struct TypeId0 {
+ const std::type_info &f(T* ptr) {
+ if (ptr)
+ return typeid(ptr);
+ else
+ return typeid(T); // expected-error{{'typeid' of incomplete type 'Incomplete'}}
+ }
+};
+
+struct Abstract {
+ virtual void f() = 0;
+};
+
+template struct TypeId0<int>;
+template struct TypeId0<Incomplete>; // expected-note{{instantiation of member function}}
+template struct TypeId0<Abstract>;
+
+// ---------------------------------------------------------------------
+// type traits
+// ---------------------------------------------------------------------
+template<typename T>
+struct is_pod {
+ static const bool value = __is_pod(T);
+};
+
+static int is_pod0[is_pod<X>::value? -1 : 1];
+static int is_pod1[is_pod<Y>::value? 1 : -1];
+
+// ---------------------------------------------------------------------
+// initializer lists
+// ---------------------------------------------------------------------
+template<typename T, typename Val1>
+struct InitList1 {
+ void f(Val1 val1) {
+ T x = { val1 };
+ }
+};
+
+struct APair {
+ int *x;
+ const float *y;
+};
+
+template struct InitList1<int[1], float>;
+template struct InitList1<APair, int*>;
+
+template<typename T, typename Val1, typename Val2>
+struct InitList2 {
+ void f(Val1 val1, Val2 val2) {
+ T x = { val1, val2 }; // expected-error{{cannot initialize}}
+ }
+};
+
+template struct InitList2<APair, int*, float*>;
+template struct InitList2<APair, int*, double*>; // expected-note{{instantiation}}
+
+// ---------------------------------------------------------------------
+// member references
+// ---------------------------------------------------------------------
+template<typename T, typename Result>
+struct DotMemRef0 {
+ void f(T t) {
+ Result result = t.m; // expected-error{{non-const lvalue reference to type}}
+ }
+};
+
+struct MemInt {
+ int m;
+};
+
+struct InheritsMemInt : MemInt { };
+
+struct MemIntFunc {
+ static int m(int);
+};
+
+template struct DotMemRef0<MemInt, int&>;
+template struct DotMemRef0<InheritsMemInt, int&>;
+template struct DotMemRef0<MemIntFunc, int (*)(int)>;
+template struct DotMemRef0<MemInt, float&>; // expected-note{{instantiation}}
+
+template<typename T, typename Result>
+struct ArrowMemRef0 {
+ void f(T t) {
+ Result result = t->m; // expected-error 2{{non-const lvalue reference}}
+ }
+};
+
+template<typename T>
+struct ArrowWrapper {
+ T operator->();
+};
+
+template struct ArrowMemRef0<MemInt*, int&>;
+template struct ArrowMemRef0<InheritsMemInt*, int&>;
+template struct ArrowMemRef0<MemIntFunc*, int (*)(int)>;
+template struct ArrowMemRef0<MemInt*, float&>; // expected-note{{instantiation}}
+
+template struct ArrowMemRef0<ArrowWrapper<MemInt*>, int&>;
+template struct ArrowMemRef0<ArrowWrapper<InheritsMemInt*>, int&>;
+template struct ArrowMemRef0<ArrowWrapper<MemIntFunc*>, int (*)(int)>;
+template struct ArrowMemRef0<ArrowWrapper<MemInt*>, float&>; // expected-note{{instantiation}}
+template struct ArrowMemRef0<ArrowWrapper<ArrowWrapper<MemInt*> >, int&>;
+
+struct UnresolvedMemRefArray {
+ int f(int);
+ int f(char);
+};
+UnresolvedMemRefArray Arr[10];
+template<typename U> int UnresolvedMemRefArrayT(U u) {
+ return Arr->f(u);
+}
+template int UnresolvedMemRefArrayT<int>(int);
+
+// FIXME: we should be able to return a MemInt without the reference!
+MemInt &createMemInt(int);
+
+template<int N>
+struct NonDepMemberExpr0 {
+ void f() {
+ createMemInt(N).m = N;
+ }
+};
+
+template struct NonDepMemberExpr0<0>;
+
+template<typename T, typename Result>
+struct MemberFuncCall0 {
+ void f(T t) {
+ Result result = t.f();
+ }
+};
+
+template<typename T>
+struct HasMemFunc0 {
+ T f();
+};
+
+
+template struct MemberFuncCall0<HasMemFunc0<int&>, const int&>;
+
+template<typename Result>
+struct ThisMemberFuncCall0 {
+ Result g();
+
+ void f() {
+ Result r1 = g();
+ Result r2 = this->g();
+ }
+};
+
+template struct ThisMemberFuncCall0<int&>;
+
+template<typename T>
+struct NonDepMemberCall0 {
+ void foo(HasMemFunc0<int&> x) {
+ T result = x.f(); // expected-error{{non-const lvalue reference}}
+ }
+};
+
+template struct NonDepMemberCall0<int&>;
+template struct NonDepMemberCall0<const int&>;
+template struct NonDepMemberCall0<float&>; // expected-note{{instantiation}}
+
+
+template<typename T>
+struct QualifiedDeclRef0 {
+ T f() {
+ return is_pod<X>::value; // expected-error{{non-const lvalue reference to type 'int' cannot bind to a value of unrelated type 'const bool'}}
+ }
+};
+
+template struct QualifiedDeclRef0<bool>;
+template struct QualifiedDeclRef0<int&>; // expected-note{{instantiation}}
diff --git a/clang/test/SemaTemplate/instantiate-expr-5.cpp b/clang/test/SemaTemplate/instantiate-expr-5.cpp
new file mode 100644
index 0000000..13b7eae
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-expr-5.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template <class A> int x(A x) { return x++; }
+int y() { return x<int>(1); }
+
+namespace PR5880 {
+ template<typename T>
+ struct A {
+ static const int a = __builtin_offsetof(T, a.array[5].m); // expected-error{{no member named 'a' in 'HasM'}}
+ };
+ struct HasM {
+ float m;
+ };
+
+ struct ArrayOfHasM {
+ HasM array[10];
+ };
+
+ struct B { ArrayOfHasM a; };
+ A<B> x;
+ A<HasM> x2; // expected-note{{in instantiation of}}
+
+ template<typename T>
+ struct AnonymousUnion {
+ union {
+ int i;
+ float f;
+ };
+ };
+
+ template<typename T>
+ void test_anon_union() {
+ int array1[__builtin_offsetof(AnonymousUnion<T>, f) == 0? 1 : -1];
+ int array2[__builtin_offsetof(AnonymousUnion<int>, f) == 0? 1 : -1];
+ }
+
+ template void test_anon_union<int>();
+}
diff --git a/clang/test/SemaTemplate/instantiate-expr-basic.cpp b/clang/test/SemaTemplate/instantiate-expr-basic.cpp
new file mode 100644
index 0000000..a266a65
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-expr-basic.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -std=c++11 %s
+
+template <typename T>
+struct S {
+ void f() {
+ __func__; // PredefinedExpr
+ 10; // IntegerLiteral
+ 10.5; // FloatingLiteral
+ 'c'; // CharacterLiteral
+ "hello"; // StringLiteral
+ true; // CXXBooleanLiteralExpr
+ nullptr; // CXXNullPtrLiteralExpr
+ __null; // GNUNullExpr
+ }
+};
+
+template struct S<int>;
diff --git a/clang/test/SemaTemplate/instantiate-field.cpp b/clang/test/SemaTemplate/instantiate-field.cpp
new file mode 100644
index 0000000..a148ee4
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-field.cpp
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+struct X {
+ int x;
+ T y; // expected-error{{data member instantiated with function type}}
+ T* z;
+ T bitfield : 12; // expected-error{{bit-field 'bitfield' has non-integral type 'float'}} \
+ // expected-error{{data member instantiated with function type}}
+
+ mutable T x2; // expected-error{{data member instantiated with function type}}
+};
+
+void test1(const X<int> *xi) {
+ int i1 = xi->x;
+ const int &i2 = xi->y;
+ int* ip1 = xi->z;
+ int i3 = xi->bitfield;
+ xi->x2 = 17;
+}
+
+void test2(const X<float> *xf) {
+ (void)xf->x; // expected-note{{in instantiation of template class 'X<float>' requested here}}
+}
+
+void test3(const X<int(int)> *xf) {
+ (void)xf->x; // expected-note{{in instantiation of template class 'X<int (int)>' requested here}}
+}
+
+namespace PR7123 {
+ template <class > struct requirement_;
+
+ template <void(*)()> struct instantiate
+ { };
+
+ template <class > struct requirement ;
+ struct failed ;
+
+ template <class Model> struct requirement<failed *Model::*>
+ {
+ static void failed()
+ {
+ ((Model*)0)->~Model(); // expected-note{{in instantiation of}}
+ }
+ };
+
+ template <class Model> struct requirement_<void(*)(Model)> : requirement<failed *Model::*>
+ { };
+
+ template <int> struct Requires_
+ { typedef void type; };
+
+ template <class Model> struct usage_requirements
+ {
+ ~usage_requirements()
+ {((Model*)0)->~Model(); } // expected-note{{in instantiation of}}
+ };
+
+ template < typename TT > struct BidirectionalIterator
+ {
+ enum
+ { value = 0 };
+
+ instantiate< requirement_<void(*)(usage_requirements<BidirectionalIterator>)>::failed> int534; // expected-note{{in instantiation of}}
+
+ ~BidirectionalIterator()
+ { i--; } // expected-error{{cannot decrement value of type 'PR7123::X'}}
+
+ TT i;
+ };
+
+ struct X
+ { };
+
+ template<typename RanIter>
+ typename Requires_< BidirectionalIterator<RanIter>::value >::type sort(RanIter,RanIter){}
+
+ void f()
+ {
+ X x;
+ sort(x,x);
+ }
+}
+
+namespace PR7355 {
+ template<typename T1> class A {
+ class D; // expected-note{{declared here}}
+ D d; //expected-error{{implicit instantiation of undefined member 'PR7355::A<int>::D'}}
+ };
+
+ A<int> ai; // expected-note{{in instantiation of}}
+}
+
+namespace PR8712 {
+ template <int dim>
+ class B {
+ public:
+ B(const unsigned char i);
+ unsigned char value : (dim > 0 ? dim : 1);
+ };
+
+ template <int dim>
+ inline B<dim>::B(const unsigned char i) : value(i) {}
+}
diff --git a/clang/test/SemaTemplate/instantiate-friend-class.cpp b/clang/test/SemaTemplate/instantiate-friend-class.cpp
new file mode 100644
index 0000000..c87b8d0
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-friend-class.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR4794
+
+template <class T> class X
+{
+ friend class Y;
+};
+X<int> y;
+
diff --git a/clang/test/SemaTemplate/instantiate-function-1.cpp b/clang/test/SemaTemplate/instantiate-function-1.cpp
new file mode 100644
index 0000000..ceef274
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-function-1.cpp
@@ -0,0 +1,249 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
+template<typename T, typename U>
+struct X0 {
+ void f(T x, U y) {
+ (void)(x + y); // expected-error{{invalid operands}}
+ }
+};
+
+struct X1 { };
+
+template struct X0<int, float>;
+template struct X0<int*, int>;
+template struct X0<int X1::*, int>; // expected-note{{instantiation of}}
+
+template<typename T>
+struct X2 {
+ void f(T);
+
+ T g(T x, T y) {
+ /* DeclStmt */;
+ T *xp = &x, &yr = y; // expected-error{{pointer to a reference}}
+ /* NullStmt */;
+ }
+};
+
+template struct X2<int>;
+template struct X2<int&>; // expected-note{{instantiation of}}
+
+template<typename T>
+struct X3 {
+ void f(T) {
+ Label:
+ T x;
+ goto Label;
+ }
+};
+
+template struct X3<int>;
+
+template <typename T> struct X4 {
+ T f() const {
+ return; // expected-error{{non-void function 'f' should return a value}}
+ }
+
+ T g() const {
+ return 1; // expected-error{{void function 'g' should not return a value}}
+ }
+};
+
+template struct X4<void>; // expected-note{{in instantiation of}}
+template struct X4<int>; // expected-note{{in instantiation of}}
+
+struct Incomplete; // expected-note 2{{forward declaration}}
+
+template<typename T> struct X5 {
+ T f() { } // expected-error{{incomplete result type}}
+};
+void test_X5(X5<Incomplete> x5); // okay!
+
+template struct X5<Incomplete>; // expected-note{{instantiation}}
+
+template<typename T, typename U, typename V> struct X6 {
+ U f(T t, U u, V v) {
+ // IfStmt
+ if (t > 0)
+ return u;
+ else {
+ if (t < 0)
+ return v; // expected-error{{cannot initialize return object of type}}
+ }
+
+ if (T x = t) {
+ t = x;
+ }
+ return v; // expected-error{{cannot initialize return object of type}}
+ }
+};
+
+struct ConvertibleToInt {
+ operator int() const;
+};
+
+template struct X6<ConvertibleToInt, float, char>;
+template struct X6<bool, int, int*>; // expected-note{{instantiation}}
+
+template <typename T> struct X7 {
+ void f() {
+ void *v = this;
+ }
+};
+
+template struct X7<int>;
+
+template<typename T> struct While0 {
+ void f(T t) {
+ while (t) {
+ }
+
+ while (T t2 = T()) ;
+ }
+};
+
+template struct While0<float>;
+
+template<typename T> struct Do0 {
+ void f(T t) {
+ do {
+ } while (t); // expected-error{{not contextually}}
+ }
+};
+
+struct NotConvertibleToBool { };
+template struct Do0<ConvertibleToInt>;
+template struct Do0<NotConvertibleToBool>; // expected-note{{instantiation}}
+
+template<typename T> struct For0 {
+ void f(T f, T l) {
+ for (; f != l; ++f) {
+ if (*f)
+ continue;
+ else if (*f == 17)
+ break;
+ }
+ }
+};
+
+template struct For0<int*>;
+
+template<typename T> struct Member0 {
+ void f(T t) {
+ t;
+ t.f;
+ t->f;
+
+ T* tp;
+ tp.f; // expected-error{{member reference base type 'T *' is not a structure or union}}
+ tp->f;
+
+ this->f;
+ this.f; // expected-error{{member reference base type 'Member0<T> *' is not a structure or union}}
+ }
+};
+
+template<typename T, typename U> struct Switch0 {
+ U f(T value, U v0, U v1, U v2) {
+ switch (value) {
+ case 0: return v0;
+
+ case 1: return v1;
+
+ case 2: // fall through
+
+ default:
+ return v2;
+ }
+ }
+};
+
+template struct Switch0<int, float>;
+
+template<typename T, int I1, int I2> struct Switch1 {
+ T f(T x, T y, T z) {
+ switch (x) {
+ case I1: return y; // expected-note{{previous}}
+ case I2: return z; // expected-error{{duplicate}}
+ default: return x;
+ }
+ }
+};
+
+template struct Switch1<int, 1, 2>;
+template struct Switch1<int, 2, 2>; // expected-note{{instantiation}}
+
+template<typename T> struct IndirectGoto0 {
+ void f(T x) {
+ // FIXME: crummy error message below
+ goto *x; // expected-error{{incompatible}}
+
+ prior:
+ T prior_label;
+ prior_label = &&prior; // expected-error{{assigning to 'int'}}
+
+ T later_label;
+ later_label = &&later; // expected-error{{assigning to 'int'}}
+
+ later:
+ (void)(1+1);
+ }
+};
+
+template struct IndirectGoto0<void*>;
+template struct IndirectGoto0<int>; // expected-note{{instantiation}}
+
+template<typename T> struct TryCatch0 {
+ void f() {
+ try {
+ } catch (T t) { // expected-error{{incomplete type}} \
+ // expected-error{{abstract class}}
+ } catch (...) {
+ }
+ }
+};
+
+struct Abstract {
+ virtual void foo() = 0; // expected-note{{pure virtual}}
+};
+
+template struct TryCatch0<int>; // okay
+template struct TryCatch0<Incomplete*>; // expected-note{{instantiation}}
+template struct TryCatch0<Abstract>; // expected-note{{instantiation}}
+
+// PR4383
+template<typename T> struct X;
+template<typename T> struct Y : public X<T> {
+ Y& x() { return *this; }
+};
+
+// Make sure our assertions don't get too uppity.
+namespace test0 {
+ template <class T> class A { void foo(T array[10]); };
+ template class A<int>;
+}
+
+namespace PR7016 {
+ template<typename T> void f() { T x = x; }
+ template void f<int>();
+}
+
+namespace PR9880 {
+ struct lua_State;
+ struct no_tag { char a; }; // (A)
+ struct yes_tag { long a; long b; }; // (A)
+
+ template <typename T>
+ struct HasIndexMetamethod {
+ template <typename U>
+ static no_tag check(...);
+ template <typename U>
+ static yes_tag check(char[sizeof(&U::luaIndex)]);
+ enum { value = sizeof(check<T>(0)) == sizeof(yes_tag) };
+ };
+
+ class SomeClass {
+ public:
+ int luaIndex(lua_State* L);
+ };
+
+ int i = HasIndexMetamethod<SomeClass>::value;
+}
diff --git a/clang/test/SemaTemplate/instantiate-function-1.mm b/clang/test/SemaTemplate/instantiate-function-1.mm
new file mode 100644
index 0000000..c67b598
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-function-1.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// XFAIL: *
+
+template<typename T> struct Member0 {
+ void f(T t) {
+ t;
+ t.f;
+ t->f;
+
+ T* tp;
+ tp.f;
+ tp->f;
+
+ this->f;
+ this.f; // expected-error{{member reference base type 'struct Member0 *const' is not a structure or union}}
+ }
+};
diff --git a/clang/test/SemaTemplate/instantiate-function-2.cpp b/clang/test/SemaTemplate/instantiate-function-2.cpp
new file mode 100644
index 0000000..19a8b61
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-function-2.cpp
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template <typename T> struct S {
+ S() { }
+ S(T t);
+};
+
+template struct S<int>;
+
+void f() {
+ S<int> s1;
+ S<int> s2(10);
+}
+
+namespace PR7184 {
+ template<typename T>
+ void f() {
+ typedef T type;
+ void g(int array[sizeof(type)]);
+ }
+
+ template void f<int>();
+}
+
+namespace UsedAttr {
+ template<typename T>
+ void __attribute__((used)) foo() {
+ T *x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
+ }
+
+ void bar() {
+ foo<int>(); // expected-note{{instantiation of}}
+ }
+}
+
+namespace PR9654 {
+ typedef void ftype(int);
+
+ template<typename T>
+ ftype f;
+
+ void g() {
+ f<int>(0);
+ }
+}
+
+namespace AliasTagDef {
+ template<typename T>
+ T f() {
+ using S = struct { // expected-warning {{C++11}}
+ T g() {
+ return T();
+ }
+ };
+ return S().g();
+ }
+
+ int n = f<int>();
+}
+
+namespace PR10273 {
+ template<typename T> void (f)(T t) {}
+
+ void g() {
+ (f)(17);
+ }
+}
diff --git a/clang/test/SemaTemplate/instantiate-function-params.cpp b/clang/test/SemaTemplate/instantiate-function-params.cpp
new file mode 100644
index 0000000..54847e4
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-function-params.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR6619
+template<bool C> struct if_c { };
+template<typename T1> struct if_ {
+ typedef if_c< static_cast<bool>(T1::value)> almost_type_; // expected-note 5{{in instantiation}}
+};
+template <class Model, void (Model::*)()> struct wrap_constraints { };
+template <class Model>
+inline char has_constraints_(Model* , // expected-note 2{{while substituting deduced template arguments into function template 'has_constraints_' [with }} \
+ // expected-note 3{{candidate template ignored}}
+ wrap_constraints<Model,&Model::constraints>* = 0); // expected-note 2{{in instantiation}}
+
+template <class Model> struct not_satisfied {
+ static const bool value = sizeof( has_constraints_((Model*)0) == 1); // expected-error 3{{no matching function}}
+};
+template <class ModelFn> struct requirement_;
+template <void(*)()> struct instantiate {
+};
+template <class Model> struct requirement_<void(*)(Model)> : if_< not_satisfied<Model> >::type { // expected-note 5{{in instantiation}}
+};
+template <class Model> struct usage_requirements {
+};
+template < typename TT > struct InputIterator {
+ typedef instantiate< & requirement_<void(*)(usage_requirements<InputIterator> x)>::failed> boost_concept_check1; // expected-note {{in instantiation}}
+};
+template < typename TT > struct ForwardIterator : InputIterator<TT> { // expected-note {{in instantiation}}
+ typedef instantiate< & requirement_<void(*)(usage_requirements<ForwardIterator> x)>::failed> boost_concept_check2; // expected-note {{in instantiation}}
+
+};
+typedef instantiate< &requirement_<void(*)(ForwardIterator<char*> x)>::failed> boost_concept_checkX;// expected-note 3{{in instantiation}}
+
+template<typename T> struct X0 { };
+template<typename R, typename A1> struct X0<R(A1 param)> { };
+
+template<typename T, typename A1, typename A2>
+void instF0(X0<T(A1)> x0a, X0<T(A2)> x0b) {
+ X0<T(A1)> x0c;
+ X0<T(A2)> x0d;
+}
+
+template void instF0<int, int, float>(X0<int(int)>, X0<int(float)>);
+
+template<typename R, typename A1, R (*ptr)(A1)> struct FuncPtr { };
+template<typename A1, int (*ptr)(A1)> struct FuncPtr<int, A1, ptr> { };
+
+template<typename R, typename A1> R unary_func(A1);
+
+template<typename R, typename A1, typename A2>
+void use_func_ptr() {
+ FuncPtr<R, A1, &unary_func<R, A1> > fp1;
+ FuncPtr<R, A2, &unary_func<R, A2> > fp2;
+};
+
+template void use_func_ptr<int, float, double>();
+
+namespace PR6990 {
+ template < typename , typename = int, typename = int > struct X1;
+ template <typename >
+ struct X2;
+
+ template <typename = int *, typename TokenT = int,
+ typename = int( X2<TokenT> &)>
+ struct X3
+ {
+ };
+
+ template <typename , typename P>
+ struct X3_base : X3< X1<int, P> >
+ {
+ protected: typedef X1< P> type;
+ X3<type> e;
+ };
+
+ struct r : X3_base<int, int>
+ {
+ };
+}
+
+namespace InstantiateFunctionTypedef {
+ template<typename T>
+ struct X {
+ typedef int functype(int, int);
+ functype func;
+ };
+
+ void f(X<int> x) {
+ (void)x.func(1, 2);
+ }
+}
diff --git a/clang/test/SemaTemplate/instantiate-init.cpp b/clang/test/SemaTemplate/instantiate-init.cpp
new file mode 100644
index 0000000..f0ca9a5
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-init.cpp
@@ -0,0 +1,109 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct X0 { // expected-note 4{{candidate}}
+ X0(int*, float*); // expected-note 4{{candidate}}
+};
+
+template<typename T, typename U>
+X0 f0(T t, U u) {
+ X0 x0(t, u); // expected-error{{no matching}}
+ return X0(t, u); // expected-error{{no matching}}
+}
+
+void test_f0(int *ip, float *fp, double *dp) {
+ f0(ip, fp);
+ f0(ip, dp); // expected-note{{instantiation}}
+}
+
+template<typename Ret, typename T, typename U>
+Ret f1(Ret *retty, T t, U u) {
+ Ret r0(t, u); // expected-error{{no matching}}
+ return Ret(t, u); // expected-error{{no matching}}
+}
+
+void test_f1(X0 *x0, int *ip, float *fp, double *dp) {
+ f1(x0, ip, fp);
+ f1(x0, ip, dp); // expected-note{{instantiation}}
+}
+
+namespace PR6457 {
+ template <typename T> struct X { explicit X(T* p = 0) { }; };
+ template <typename T> struct Y { Y(int, const T& x); };
+ struct A { };
+ template <typename T>
+ struct B {
+ B() : y(0, X<A>()) { }
+ Y<X<A> > y;
+ };
+ B<int> b;
+}
+
+namespace PR6657 {
+ struct X
+ {
+ X (int, int) { }
+ };
+
+ template <typename>
+ void f0()
+ {
+ X x = X(0, 0);
+ }
+
+ void f1()
+ {
+ f0<int>();
+ }
+}
+
+// Instantiate out-of-line definitions of static data members which complete
+// types through an initializer even when the only use of the member that would
+// cause instantiation is in an unevaluated context, but one requiring its
+// complete type.
+namespace PR10001 {
+ template <typename T> struct S {
+ static const int arr[];
+ static const int x;
+ static int f();
+ };
+
+ template <typename T> const int S<T>::arr[] = { 1, 2, 3 };
+ template <typename T> const int S<T>::x = sizeof(arr) / sizeof(arr[0]);
+ template <typename T> int S<T>::f() { return x; }
+
+ int x = S<int>::f();
+}
+
+namespace PR7985 {
+ template<int N> struct integral_c { };
+
+ template <typename T, int N>
+ integral_c<N> array_lengthof(T (&x)[N]) { return integral_c<N>(); } // expected-note 2{{candidate template ignored: failed template argument deduction}}
+
+ template<typename T>
+ struct Data {
+ T x;
+ };
+
+ template<typename T>
+ struct Description {
+ static const Data<T> data[];
+ };
+
+ template<typename T>
+ const Data<T> Description<T>::data[] = {{ 1 }}; // expected-error{{cannot initialize a member subobject of type 'int *' with an rvalue of type 'int'}}
+
+ template<>
+ Data<float*> Description<float*>::data[];
+
+ void test() {
+ integral_c<1> ic1 = array_lengthof(Description<int>::data);
+ (void)sizeof(array_lengthof(Description<float>::data));
+
+ sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
+ Description<int*>::data // expected-note{{in instantiation of static data member 'PR7985::Description<int *>::data' requested here}}
+ ));
+
+ array_lengthof(Description<float*>::data); // expected-error{{no matching function for call to 'array_lengthof'}}
+ }
+}
diff --git a/clang/test/SemaTemplate/instantiate-invalid.cpp b/clang/test/SemaTemplate/instantiate-invalid.cpp
new file mode 100644
index 0000000..b8a5901
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-invalid.cpp
@@ -0,0 +1,52 @@
+// RUN: not %clang_cc1 -fsyntax-only %s
+namespace PR6375 {
+ template<class Conv> class rasterizer_sl_clip Conv::xi(x2), Conv::yi(y2));
+namespace agg
+{
+ template<class Clip=rasterizer_sl_clip_int> class rasterizer_scanline_aa
+ {
+ template<class Scanline> bool sweep_scanline(Scanline& sl)
+ {
+ unsigned num_cells = m_outline.scanline_num_cells(m_scan_y);
+ while(num_cells) { }
+ }
+ }
+ class scanline_u8 {}
+ template<class PixelFormat> class renderer_base { }
+}
+ template<class Rasterizer, class Scanline, class BaseRenderer, class ColorT>
+ void render_scanlines_aa_solid(Rasterizer& ras, Scanline& sl, BaseRenderer& ren, const ColorT& color)
+ {
+ while(ras.sweep_scanline(sl))
+ {
+ }
+ };
+namespace agg
+{
+ struct rgba8
+ {
+ };
+ template<class Rasterizer, class Scanline, class Renderer, class Ctrl>
+ void render_ctrl(Rasterizer& ras, Scanline& sl, Renderer& r, Ctrl& c)
+ {
+ unsigned i;
+ render_scanlines_aa_solid(ras, sl, r, c.color(i));
+ }
+ template<class ColorT> class rbox_ctrl : public rbox_ctrl_impl
+ {
+ const ColorT& color(unsigned i) const { return *m_colors[i]; }
+ }
+class the_application : public agg::platform_support
+{
+ agg::rbox_ctrl<agg::rgba8> m_polygons;
+ virtual void on_init()
+ {
+ typedef agg::renderer_base<pixfmt_type> base_ren_type;
+ base_ren_type ren_base(pf);
+ agg::scanline_u8 sl;
+ agg::rasterizer_scanline_aa<> ras;
+ agg::render_ctrl(ras, sl, ren_base, m_polygons);
+ }
+};
+}
+}
diff --git a/clang/test/SemaTemplate/instantiate-local-class.cpp b/clang/test/SemaTemplate/instantiate-local-class.cpp
new file mode 100644
index 0000000..20b62c1
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-local-class.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -verify %s
+template<typename T>
+void f0() {
+ struct X;
+ typedef struct Y {
+ T (X::* f1())(int) { return 0; }
+ } Y2;
+
+ Y2 y = Y();
+}
+
+template void f0<int>();
+
+// PR5764
+namespace PR5764 {
+ struct X {
+ template <typename T>
+ void Bar() {
+ typedef T ValueType;
+ struct Y {
+ Y() { V = ValueType(); }
+
+ ValueType V;
+ };
+
+ Y y;
+ }
+ };
+
+ void test(X x) {
+ x.Bar<int>();
+ }
+}
+
+// Instantiation of local classes with virtual functions.
+namespace local_class_with_virtual_functions {
+ template <typename T> struct X { };
+ template <typename T> struct Y { };
+
+ template <typename T>
+ void f() {
+ struct Z : public X<Y<T>*> {
+ virtual void g(Y<T>* y) { }
+ void g2(int x) {(void)x;}
+ };
+ Z z;
+ (void)z;
+ }
+
+ struct S { };
+ void test() { f<S>(); }
+}
+
+namespace PR8801 {
+ template<typename T>
+ void foo() {
+ class X;
+ typedef int (X::*pmf_type)();
+ class X : public T { };
+
+ pmf_type pmf = &T::foo;
+ }
+
+ struct Y { int foo(); };
+
+ template void foo<Y>();
+}
diff --git a/clang/test/SemaTemplate/instantiate-member-class.cpp b/clang/test/SemaTemplate/instantiate-member-class.cpp
new file mode 100644
index 0000000..bb64276
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-member-class.cpp
@@ -0,0 +1,142 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR8965 {
+ template<typename T>
+ struct X {
+ typedef int type;
+
+ T field; // expected-note{{in instantiation of member class}}
+ };
+
+ template<typename T>
+ struct Y {
+ struct Inner;
+
+ typedef typename X<Inner>::type // expected-note{{in instantiation of template class}}
+ type; // expected-note{{not-yet-instantiated member is declared here}}
+
+ struct Inner {
+ typedef type field; // expected-error{{no member 'type' in 'PR8965::Y<int>'; it has not yet been instantiated}}
+ };
+ };
+
+ Y<int> y; // expected-note{{in instantiation of template class}}
+}
+
+template<typename T>
+class X {
+public:
+ struct C { T &foo(); };
+
+ struct D {
+ struct E { T &bar(); }; // expected-error{{cannot form a reference to 'void'}}
+ struct F; // expected-note{{member is declared here}}
+ };
+};
+
+X<int>::C *c1;
+X<float>::C *c2;
+
+X<int>::X *xi; // expected-error{{qualified reference to 'X' is a constructor name rather than a type wherever a constructor can be declared}}
+X<float>::X *xf; // expected-error{{qualified reference to 'X' is a constructor name rather than a type wherever a constructor can be declared}}
+
+void test_naming() {
+ c1 = c2; // expected-error{{assigning to 'X<int>::C *' from incompatible type 'X<float>::C *'}}
+ xi = xf; // expected-error{{assigning to 'X<int>::X<int> *' from incompatible type 'X<float>::X<float> *'}}
+ // FIXME: error above doesn't print the type X<int>::X cleanly!
+}
+
+void test_instantiation(X<double>::C *x,
+ X<float>::D::E *e,
+ X<float>::D::F *f) {
+ double &dr = x->foo();
+ float &fr = e->bar();
+ f->foo(); // expected-error{{implicit instantiation of undefined member 'X<float>::D::F'}}
+
+}
+
+
+X<void>::C *c3; // okay
+X<void>::D::E *e1; // okay
+X<void>::D::E e2; // expected-note{{in instantiation of member class 'X<void>::D::E' requested here}}
+
+// Redeclarations.
+namespace test1 {
+ template <typename T> struct Registry {
+ struct node;
+ static node *Head;
+ struct node {
+ node(int v) { Head = this; }
+ };
+ };
+ void test() {
+ Registry<int>::node node(0);
+ }
+}
+
+// Redeclarations during explicit instantiations.
+namespace test2 {
+ template <typename T> class A {
+ class Foo;
+ class Foo {
+ int foo();
+ };
+ };
+ template class A<int>;
+
+ template <typename T> class B {
+ class Foo;
+ class Foo {
+ public:
+ typedef int X;
+ };
+ typename Foo::X x;
+ class Foo;
+ };
+ template class B<int>;
+
+ template <typename T> class C {
+ class Foo;
+ class Foo;
+ };
+ template <typename T> class C<T>::Foo {
+ int x;
+ };
+ template class C<int>;
+}
+
+namespace AliasTagDef {
+ template<typename T>
+ struct F {
+ using S = struct U { // expected-warning {{C++11}}
+ T g() {
+ return T();
+ }
+ };
+ };
+
+ int m = F<int>::S().g();
+ int n = F<int>::U().g();
+}
+
+namespace rdar10397846 {
+ template<int I> struct A
+ {
+ struct B
+ {
+ struct C { C() { int *ptr = I; } }; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
+ };
+ };
+
+ template<int N> void foo()
+ {
+ class A<N>::B::C X; // expected-note{{in instantiation of member function}}
+ int A<N+1>::B::C::*member = 0;
+ }
+
+ void bar()
+ {
+ foo<0>();
+ foo<1>(); // expected-note{{in instantiation of function template}}
+ }
+}
diff --git a/clang/test/SemaTemplate/instantiate-member-expr.cpp b/clang/test/SemaTemplate/instantiate-member-expr.cpp
new file mode 100644
index 0000000..a31569a
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-member-expr.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T>
+struct S {
+ S() { }
+};
+
+template<typename T>
+struct vector {
+ void push_back(const T&) { int a[sizeof(T) ? -1: -1]; } // expected-error {{array with a negative size}}
+};
+
+class ExprEngine {
+public:
+ typedef vector<S<void *> >CheckersOrdered;
+ CheckersOrdered Checkers;
+
+ template <typename CHECKER>
+ void registerCheck(CHECKER *check) {
+ Checkers.push_back(S<void *>()); // expected-note {{in instantiation of member function 'vector<S<void *> >::push_back' requested here}}
+ }
+};
+
+class RetainReleaseChecker { };
+
+void f(ExprEngine& Eng) {
+ Eng.registerCheck(new RetainReleaseChecker); // expected-note {{in instantiation of function template specialization 'ExprEngine::registerCheck<RetainReleaseChecker>' requested here}}
+}
+
+// PR 5838
+namespace test1 {
+ template<typename T> struct A {
+ int a;
+ };
+
+ template<typename T> struct B : A<float>, A<T> {
+ void f() {
+ a = 0; // should not be ambiguous
+ }
+ };
+ template struct B<int>;
+
+ struct O {
+ int a;
+ template<typename T> struct B : A<T> {
+ void f() {
+ a = 0; // expected-error {{'test1::O::a' is not a member of class 'test1::O::B<int>'}}
+ }
+ };
+ };
+ template struct O::B<int>; // expected-note {{in instantiation}}
+}
+
+// PR7248
+namespace test2 {
+ template <class T> struct A {
+ void foo() {
+ T::bar(); // expected-error {{type 'int' cannot}}
+ }
+ };
+
+ template <class T> class B {
+ void foo(A<T> a) {
+ a.test2::template A<T>::foo(); // expected-note {{in instantiation}}
+ }
+ };
+
+ template class B<int>;
+}
diff --git a/clang/test/SemaTemplate/instantiate-member-initializers.cpp b/clang/test/SemaTemplate/instantiate-member-initializers.cpp
new file mode 100644
index 0000000..45503b3
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-member-initializers.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -Wall -verify %s
+
+template<typename T> struct A {
+ A() : a(1) { } // expected-error{{cannot initialize a member subobject of type 'void *' with an rvalue of type 'int'}}
+
+ T a;
+};
+
+A<int> a0;
+A<void*> a1; // expected-note{{in instantiation of member function 'A<void *>::A' requested here}}
+
+template<typename T> struct B {
+ B() : b(1), // expected-warning {{field 'b' will be initialized after field 'a'}}
+ a(2) { }
+
+ int a;
+ int b;
+};
+
+B<int> b0; // expected-note {{in instantiation of member function 'B<int>::B' requested here}}
+
+template <class T> struct AA { AA(int); };
+template <class T> class BB : public AA<T> {
+public:
+ BB() : AA<T>(1) {}
+};
+BB<int> x;
diff --git a/clang/test/SemaTemplate/instantiate-member-pointers.cpp b/clang/test/SemaTemplate/instantiate-member-pointers.cpp
new file mode 100644
index 0000000..0db90e3
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-member-pointers.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct Y {
+ int x;
+};
+
+template<typename T>
+struct X1 {
+ int f(T* ptr, int T::*pm) { // expected-error{{member pointer}}
+ return ptr->*pm;
+ }
+};
+
+template struct X1<Y>;
+template struct X1<int>; // expected-note{{instantiation}}
+
+template<typename T, typename Class>
+struct X2 {
+ T f(Class &obj, T Class::*pm) { // expected-error{{to a reference}} \
+ // expected-error{{member pointer to void}}
+ return obj.*pm;
+ }
+};
+
+template struct X2<int, Y>;
+template struct X2<int&, Y>; // expected-note{{instantiation}}
+template struct X2<const void, Y>; // expected-note{{instantiation}}
+
+template<typename T, typename Class, T Class::*Ptr>
+struct X3 {
+ X3<T, Class, Ptr> &operator=(const T& value) {
+ return *this;
+ }
+};
+
+X3<int, Y, &Y::x> x3;
+
+typedef int Y::*IntMember;
+
+template<IntMember Member>
+struct X4 {
+ X3<int, Y, Member> member;
+
+ int &getMember(Y& y) { return y.*Member; }
+};
+
+int &get_X4(X4<&Y::x> x4, Y& y) {
+ return x4.getMember(y);
+}
+
+template<IntMember Member>
+void accept_X4(X4<Member>);
+
+void test_accept_X4(X4<&Y::x> x4) {
+ accept_X4(x4);
+}
+
+namespace ValueDepMemberPointer {
+ template <void (*)()> struct instantiate_function {};
+ template <typename T> struct S {
+ static void instantiate();
+ typedef instantiate_function<&S::instantiate> x; // expected-note{{instantiation}}
+ };
+ template <typename T> void S<T>::instantiate() {
+ int a[(int)sizeof(T)-42]; // expected-error{{array with a negative size}}
+ }
+ S<int> s;
+}
diff --git a/clang/test/SemaTemplate/instantiate-member-template.cpp b/clang/test/SemaTemplate/instantiate-member-template.cpp
new file mode 100644
index 0000000..4c74f5f
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-member-template.cpp
@@ -0,0 +1,261 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+struct X0 {
+ template<typename U> T f0(U);
+ template<typename U> U& f1(T*, U); // expected-error{{pointer to a reference}} \
+ // expected-note{{candidate}}
+};
+
+X0<int> x0i;
+X0<void> x0v;
+X0<int&> x0ir; // expected-note{{instantiation}}
+
+void test_X0(int *ip, double *dp) {
+ X0<int> xi;
+ int i1 = xi.f0(ip);
+ double *&dpr = xi.f1(ip, dp);
+ xi.f1(dp, dp); // expected-error{{no matching}}
+
+ X0<void> xv;
+ double *&dpr2 = xv.f1(ip, dp);
+}
+
+template<typename T>
+struct X1 {
+ template<typename U>
+ struct Inner0 {
+ U x;
+ T y; // expected-error{{void}}
+ };
+
+ template<typename U>
+ struct Inner1 {
+ U x; // expected-error{{void}}
+ T y;
+ };
+
+ template<typename U>
+ struct Inner2 {
+ struct SuperInner {
+ U z; // expected-error{{void}}
+ };
+ };
+
+ template<typename U>
+ struct Inner3 {
+ void f0(T t, U u) { // expected-note{{passing argument to parameter 't' here}}
+ (void)(t + u); // expected-error{{invalid operands}}
+ }
+
+ template<typename V>
+ V f1(T t, U u, V) {
+ return t + u; // expected-error{{cannot initialize return object}}
+ }
+ };
+
+ template<typename U>
+ struct Inner4;
+};
+
+template<typename T>
+template<typename U>
+struct X1<T>::Inner4 {
+ template<typename V>
+ V f2(T t, U u, V);
+
+ static U value;
+};
+
+template<typename T>
+template<typename U>
+U X1<T>::Inner4<U>::value; // expected-error{{reference variable}}
+
+template<typename T>
+template<typename U>
+template<typename V>
+V X1<T>::Inner4<U>::f2(T t, U u, V) {
+ return t + u; // expected-error{{cannot initialize return object}}
+}
+
+void test_X1(int *ip, int i, double *dp) {
+ X1<void>::Inner0<int> *xvip; // okay
+ X1<void>::Inner0<int> xvi; // expected-note{{instantiation}}
+
+ X1<int>::Inner1<void> *xivp; // okay
+ X1<int>::Inner1<void> xiv; // expected-note{{instantiation}}
+
+ X1<int>::Inner2<void>::SuperInner *xisivp; // okay
+ X1<int>::Inner2<void>::SuperInner xisiv; // expected-note{{instantiation}}
+
+ X1<int*>::Inner3<int> id3;
+ id3.f0(ip, i);
+ id3.f0(dp, i); // expected-error{{cannot initialize a parameter of type 'int *' with an lvalue of type 'double *'}}
+ id3.f1(ip, i, ip);
+ id3.f1(ip, i, dp); // expected-note{{instantiation}}
+
+ X1<int*>::Inner3<double*> id3b;
+ id3b.f0(ip, dp); // expected-note{{instantiation}}
+
+ X1<int*>::Inner4<int> id4;
+ id4.f2(ip, i, dp); // expected-note{{instantiation}}
+
+ X1<int*>::Inner4<int>::value = 17;
+ i = X1<int*>::Inner4<int&>::value; // expected-note{{instantiation}}
+}
+
+
+template<typename T>
+struct X2 {
+ template<T *Ptr> // expected-error{{pointer to a reference}}
+ struct Inner;
+
+ template<T Value> // expected-error{{cannot have type 'float'}}
+ struct Inner2;
+};
+
+X2<int&> x2a; // expected-note{{instantiation}}
+X2<float> x2b; // expected-note{{instantiation}}
+
+namespace N0 {
+ template<typename T>
+ struct X0 { };
+
+ struct X1 {
+ template<typename T> void f(X0<T>& vals) { g(vals); }
+ template<typename T> void g(X0<T>& vals) { }
+ };
+
+ void test(X1 x1, X0<int> x0i, X0<long> x0l) {
+ x1.f(x0i);
+ x1.f(x0l);
+ }
+}
+
+namespace PR6239 {
+ template <typename T>
+ struct X0 {
+ class type {
+ typedef T E;
+ template <E e> // subsitute T for E and bug goes away
+ struct sfinae { };
+
+ template <class U>
+ typename sfinae<&U::operator=>::type test(int);
+ };
+ };
+
+ template <typename T>
+ struct X1 {
+ typedef T E;
+ template <E e> // subsitute T for E and bug goes away
+ struct sfinae { };
+
+ template <class U>
+ typename sfinae<&U::operator=>::type test(int);
+ };
+
+}
+
+namespace PR7587 {
+ template<typename> class X0;
+ template<typename> struct X1;
+ template<typename> class X2;
+
+ template<typename T> class X3
+ {
+ template<
+ template<typename> class TT,
+ typename U = typename X1<T>::type
+ >
+ struct Inner {
+ typedef X2<TT<typename X1<T>::type> > Type;
+ };
+
+ const typename Inner<X0>::Type minCoeff() const;
+ };
+
+ template<typename T> class X3<T*>
+ {
+ template<
+ template<typename> class TT,
+ typename U = typename X1<T>::type
+ >
+ struct Inner {
+ typedef X2<TT<typename X1<T>::type> > Type;
+ };
+
+ const typename Inner<X0>::Type minCoeff() const;
+ };
+
+}
+
+namespace PR7669 {
+ template<class> struct X {
+ template<class> struct Y {
+ template<int,class> struct Z;
+ template<int Dummy> struct Z<Dummy,int> {};
+ };
+ };
+
+ void a()
+ {
+ X<int>::Y<int>::Z<0,int>();
+ }
+}
+
+namespace PR8489 {
+ template <typename CT>
+ class C {
+ template<typename FT>
+ void F() {} // expected-note{{FT}}
+ };
+ void f() {
+ C<int> c;
+ c.F(); // expected-error{{no matching member function}}
+ }
+}
+
+namespace rdar8986308 {
+ template <bool> struct __static_assert_test;
+ template <> struct __static_assert_test<true> {};
+ template <unsigned> struct __static_assert_check {};
+
+ namespace std {
+
+ template <class _Tp, class _Up>
+ struct __has_rebind
+ {
+ private:
+ struct __two {char _; char __;};
+ template <class _Xp> static __two __test(...);
+ template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0);
+ public:
+ static const bool value = sizeof(__test<_Tp>(0)) == 1;
+ };
+
+ }
+
+ template <class T> struct B1 {};
+
+ template <class T>
+ struct B
+ {
+ template <class U> struct rebind {typedef B1<U> other;};
+ };
+
+ template <class T, class U> struct D1 {};
+
+ template <class T, class U>
+ struct D
+ {
+ template <class V> struct rebind {typedef D1<V, U> other;};
+ };
+
+ int main()
+ {
+ typedef __static_assert_check<sizeof(__static_assert_test<((std::__has_rebind<B<int>, double>::value))>)> __t64;
+ typedef __static_assert_check<sizeof(__static_assert_test<((std::__has_rebind<D<char, int>, double>::value))>)> __t64;
+ }
+
+}
diff --git a/clang/test/SemaTemplate/instantiate-method.cpp b/clang/test/SemaTemplate/instantiate-method.cpp
new file mode 100644
index 0000000..363115d
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-method.cpp
@@ -0,0 +1,177 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T>
+class X {
+public:
+ void f(T x); // expected-error{{argument may not have 'void' type}}
+ void g(T*);
+
+ static int h(T, T); // expected-error {{argument may not have 'void' type}}
+};
+
+int identity(int x) { return x; }
+
+void test(X<int> *xi, int *ip, X<int(int)> *xf) {
+ xi->f(17);
+ xi->g(ip);
+ xf->f(&identity);
+ xf->g(identity);
+ X<int>::h(17, 25);
+ X<int(int)>::h(identity, &identity);
+}
+
+void test_bad() {
+ X<void> xv; // expected-note{{in instantiation of template class 'X<void>' requested here}}
+}
+
+template<typename T, typename U>
+class Overloading {
+public:
+ int& f(T, T); // expected-note{{previous declaration is here}}
+ float& f(T, U); // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+void test_ovl(Overloading<int, long> *oil, int i, long l) {
+ int &ir = oil->f(i, i);
+ float &fr = oil->f(i, l);
+}
+
+void test_ovl_bad() {
+ Overloading<float, float> off; // expected-note{{in instantiation of template class 'Overloading<float, float>' requested here}}
+}
+
+template<typename T>
+class HasDestructor {
+public:
+ virtual ~HasDestructor() = 0;
+};
+
+int i = sizeof(HasDestructor<int>); // FIXME: forces instantiation, but
+ // the code below should probably instantiate by itself.
+int abstract_destructor[__is_abstract(HasDestructor<int>)? 1 : -1];
+
+
+template<typename T>
+class Constructors {
+public:
+ Constructors(const T&);
+ Constructors(const Constructors &other);
+};
+
+void test_constructors() {
+ Constructors<int> ci1(17);
+ Constructors<int> ci2 = ci1;
+}
+
+
+template<typename T>
+struct ConvertsTo {
+ operator T();
+};
+
+void test_converts_to(ConvertsTo<int> ci, ConvertsTo<int *> cip) {
+ int i = ci;
+ int *ip = cip;
+}
+
+// PR4660
+template<class T> struct A0 { operator T*(); };
+template<class T> struct A1;
+
+int *a(A0<int> &x0, A1<int> &x1) {
+ int *y0 = x0;
+ int *y1 = x1; // expected-error{{no viable conversion}}
+}
+
+struct X0Base {
+ int &f();
+ int& g(int);
+ static double &g(double);
+};
+
+template<typename T>
+struct X0 : X0Base {
+};
+
+template<typename U>
+struct X1 : X0<U> {
+ int &f2() {
+ return X0Base::f();
+ }
+};
+
+void test_X1(X1<int> x1i) {
+ int &ir = x1i.f2();
+}
+
+template<typename U>
+struct X2 : X0Base, U {
+ int &f2() { return X0Base::f(); }
+};
+
+template<typename T>
+struct X3 {
+ void test(T x) {
+ double& d1 = X0Base::g(x);
+ }
+};
+
+
+template struct X3<double>;
+
+// Don't try to instantiate this, it's invalid.
+namespace test1 {
+ template <class T> class A {};
+ template <class T> class B {
+ void foo(A<test1::Undeclared> &a) // expected-error {{no member named 'Undeclared' in namespace 'test1'}}
+ {}
+ };
+ template class B<int>;
+}
+
+namespace PR6947 {
+ template< class T >
+ struct X {
+ int f0( )
+ {
+ typedef void ( X::*impl_fun_ptr )( );
+ impl_fun_ptr pImpl = &X::template
+ f0_impl1<int>;
+ }
+ private:
+ int f1() {
+ }
+ template< class Processor>
+ void f0_impl1( )
+ {
+ }
+ };
+
+ char g0() {
+ X<int> pc;
+ pc.f0();
+ }
+
+}
+
+namespace PR7022 {
+ template <typename >
+ struct X1
+ {
+ typedef int state_t( );
+ state_t g ;
+ };
+
+ template < typename U = X1<int> > struct X2
+ {
+ X2( U = U())
+ {
+ }
+ };
+
+ void m(void)
+ {
+ typedef X2<> X2_type;
+ X2_type c;
+ }
+
+}
diff --git a/clang/test/SemaTemplate/instantiate-non-dependent-types.cpp b/clang/test/SemaTemplate/instantiate-non-dependent-types.cpp
new file mode 100644
index 0000000..a0005c5
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-non-dependent-types.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T>
+struct X1 {
+ static void member() { T* x = 1; } // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
+};
+
+template<void(*)()> struct instantiate { };
+
+template<typename T>
+struct X2 {
+ typedef instantiate<&X1<int>::member> i; // expected-note{{in instantiation of}}
+};
+
+X2<int> x;
diff --git a/clang/test/SemaTemplate/instantiate-non-type-template-parameter.cpp b/clang/test/SemaTemplate/instantiate-non-type-template-parameter.cpp
new file mode 100644
index 0000000..027c1e8
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-non-type-template-parameter.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR5311
+template<typename T>
+class StringSwitch {
+public:
+ template<unsigned N>
+ void Case(const char (&S)[N], const int & Value) {
+ }
+};
+
+void test_stringswitch(int argc, char *argv[]) {
+ (void)StringSwitch<int>();
+}
+
+namespace PR6986 {
+ template<class Class,typename Type,Type Class::*>
+ struct non_const_member_base
+ {
+ };
+
+ template<class Class,typename Type,Type Class::*PtrToMember>
+ struct member: non_const_member_base<Class,Type,PtrToMember>
+ {
+ };
+
+ struct test_class
+ {
+ int int_member;
+ };
+ typedef member< test_class,const int,&test_class::int_member > ckey_m;
+ void test()
+ {
+ ckey_m m;
+ }
+}
+
+namespace rdar8980215 {
+ enum E { E1, E2, E3 };
+
+ template<typename T, E e = E2>
+ struct X0 {
+ X0() {}
+ template<typename U> X0(const X0<U, e> &);
+ };
+
+ template<typename T>
+ struct X1 : X0<T> {
+ X1() {}
+ template<typename U> X1(const X1<U> &x) : X0<T>(x) { }
+ };
+
+ X1<int> x1i;
+ X1<float> x1f(x1i);
+}
diff --git a/clang/test/SemaTemplate/instantiate-objc-1.mm b/clang/test/SemaTemplate/instantiate-objc-1.mm
new file mode 100644
index 0000000..2780f8e
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-objc-1.mm
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Obj-C string literal expressions
+template <typename T> struct StringTest {
+ void f() {
+ (void)@"Hello";
+ }
+};
+
+template struct StringTest<int>;
+template struct StringTest<double>;
+
+// @selector expressions
+template <typename T> struct SelectorTest {
+ SEL f() {
+ return @selector(multiple:arguments:);
+ }
+ SEL f2() {
+ return @selector(multiple:arguments:);
+ }
+};
+
+template struct SelectorTest<int>;
+template struct SelectorTest<double>;
+
+// @protocol expressions
+@protocol P
+@end
+
+template <typename T> struct ProtocolTest {
+ void f() {
+ (void)@protocol(P);
+ }
+};
+
+template struct ProtocolTest<int>;
+template struct ProtocolTest<double>;
+
+// @encode expressions
+template <typename T> struct EncodeTest {
+ static const char *encode(T t) {
+ return @encode(T);
+ }
+};
+
+template struct EncodeTest<int>;
+template struct EncodeTest<double>;
+template struct EncodeTest<wchar_t>;
diff --git a/clang/test/SemaTemplate/instantiate-overload-candidates.cpp b/clang/test/SemaTemplate/instantiate-overload-candidates.cpp
new file mode 100644
index 0000000..5b7e60d
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-overload-candidates.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// This is the function actually selected during overload resolution, and the
+// only one defined.
+template <typename T> void f(T*, int) {}
+
+template <typename T> struct S;
+template <typename T> struct S_ : S<T> { typedef int type; }; // expected-note{{in instantiation}}
+template <typename T> struct S {
+ // Force T to have a complete type here so we can observe instantiations with
+ // incomplete types.
+ T t; // expected-error{{field has incomplete type}}
+};
+
+// Provide a bad class and an overload that instantiates templates with it.
+class NoDefinition; // expected-note{{forward declaration}}
+template <typename T> S_<NoDefinition>::type f(T*, NoDefinition*); // expected-note{{in instantiation}}
+
+void test(int x) {
+ f(&x, 0);
+}
diff --git a/clang/test/SemaTemplate/instantiate-overloaded-arrow.cpp b/clang/test/SemaTemplate/instantiate-overloaded-arrow.cpp
new file mode 100644
index 0000000..ee36427
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-overloaded-arrow.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR5488
+
+struct X {
+ int x;
+};
+
+struct Iter {
+ X* operator->();
+};
+
+template <typename T>
+void Foo() {
+ (void)Iter()->x;
+}
+
+void Func() {
+ Foo<int>();
+}
+
diff --git a/clang/test/SemaTemplate/instantiate-self.cpp b/clang/test/SemaTemplate/instantiate-self.cpp
new file mode 100644
index 0000000..cfe9025
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-self.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+// Check that we deal with cases where the instantiation of a class template
+// recursively requires the instantiation of the same template.
+namespace test1 {
+ template<typename T> struct A {
+ struct B { // expected-note {{not complete until the closing '}'}}
+ B b; // expected-error {{has incomplete type 'test1::A<int>::B'}}
+ };
+ B b; // expected-note {{in instantiation of}}
+ };
+ A<int> a; // expected-note {{in instantiation of}}
+}
+
+namespace test2 {
+ template<typename T> struct A {
+ struct B {
+ struct C {};
+ char c[1 + C()]; // expected-error {{invalid operands to binary expression}}
+ friend constexpr int operator+(int, C) { return 4; }
+ };
+ B b; // expected-note {{in instantiation of}}
+ };
+ A<int> a; // expected-note {{in instantiation of}}
+}
+
+namespace test3 {
+ // PR12317
+ template<typename T> struct A {
+ struct B {
+ enum { Val = 1 };
+ char c[1 + Val]; // ok
+ };
+ B b;
+ };
+ A<int> a;
+}
+
+namespace test4 {
+ template<typename T> struct M { typedef int type; };
+ template<typename T> struct A {
+ struct B { // expected-note {{not complete until the closing '}'}}
+ int k[typename A<typename M<T>::type>::B().k[0] + 1]; // expected-error {{incomplete type}}
+ };
+ B b; // expected-note {{in instantiation of}}
+ };
+ A<int> a; // expected-note {{in instantiation of}}
+}
+
+// FIXME: PR12298: Recursive constexpr function template instantiation leads to
+// stack overflow.
+#if 0
+namespace test5 {
+ template<typename T> struct A {
+ constexpr T f(T k) { return g(k); }
+ constexpr T g(T k) {
+ return k ? f(k-1)+1 : 0;
+ }
+ };
+ // This should be accepted.
+ constexpr int x = A<int>().f(5);
+}
+
+namespace test6 {
+ template<typename T> constexpr T f(T);
+ template<typename T> constexpr T g(T t) {
+ typedef int arr[f(T())];
+ return t;
+ }
+ template<typename T> constexpr T f(T t) {
+ typedef int arr[g(T())];
+ return t;
+ }
+ // This should be ill-formed.
+ int n = f(0);
+}
+
+namespace test7 {
+ template<typename T> constexpr T g(T t) {
+ return t;
+ }
+ template<typename T> constexpr T f(T t) {
+ typedef int arr[g(T())];
+ return t;
+ }
+ // This should be accepted.
+ int n = f(0);
+}
+#endif
diff --git a/clang/test/SemaTemplate/instantiate-sizeof.cpp b/clang/test/SemaTemplate/instantiate-sizeof.cpp
new file mode 100644
index 0000000..00d63d0
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-sizeof.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// Make sure we handle contexts correctly with sizeof
+template<typename T> void f(T n) {
+ int buffer[n];
+ [] { int x = sizeof(sizeof(buffer)); }();
+}
+int main() {
+ f<int>(1);
+}
diff --git a/clang/test/SemaTemplate/instantiate-static-var.cpp b/clang/test/SemaTemplate/instantiate-static-var.cpp
new file mode 100644
index 0000000..f309f29
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-static-var.cpp
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T, T Divisor>
+class X {
+public:
+ static const T value = 10 / Divisor; // expected-error{{in-class initializer for static data member is not a constant expression}}
+};
+
+int array1[X<int, 2>::value == 5? 1 : -1];
+X<int, 0> xi0; // expected-note{{in instantiation of template class 'X<int, 0>' requested here}}
+
+
+template<typename T>
+class Y {
+ static const T value = 0; // expected-warning{{in-class initializer for static data member of type 'const float' is a GNU extension}}
+};
+
+Y<float> fy; // expected-note{{in instantiation of template class 'Y<float>' requested here}}
+
+
+// out-of-line static member variables
+
+template<typename T>
+struct Z {
+ static T value;
+};
+
+template<typename T>
+T Z<T>::value; // expected-error{{no matching constructor}}
+
+struct DefCon {};
+
+struct NoDefCon {
+ NoDefCon(const NoDefCon&); // expected-note{{candidate constructor}}
+};
+
+void test() {
+ DefCon &DC = Z<DefCon>::value;
+ NoDefCon &NDC = Z<NoDefCon>::value; // expected-note{{instantiation}}
+}
+
+// PR5609
+struct X1 {
+ ~X1(); // The errors won't be triggered without this dtor.
+};
+
+template <typename T>
+struct Y1 {
+ static char Helper(T);
+ static const int value = sizeof(Helper(T()));
+};
+
+struct X2 {
+ virtual ~X2();
+};
+
+namespace std {
+ class type_info { };
+}
+
+template <typename T>
+struct Y2 {
+ static T &Helper();
+ static const int value = sizeof(typeid(Helper()));
+};
+
+template <int>
+struct Z1 {};
+
+void Test() {
+ Z1<Y1<X1>::value> x;
+ int y[Y1<X1>::value];
+ Z1<Y2<X2>::value> x2;
+ int y2[Y2<X2>::value];
+}
+
+// PR5672
+template <int n>
+struct X3 {};
+
+class Y3 {
+ public:
+ ~Y3(); // The error isn't triggered without this dtor.
+
+ void Foo(X3<1>);
+};
+
+template <typename T>
+struct SizeOf {
+ static const int value = sizeof(T);
+};
+
+void MyTest3() {
+ Y3().Foo(X3<SizeOf<char>::value>());
+}
+
+namespace PR6449 {
+ template<typename T>
+ struct X0 {
+ static const bool var = false;
+ };
+
+ template<typename T>
+ const bool X0<T>::var;
+
+ template<typename T>
+ struct X1 : public X0<T> {
+ static const bool var = false;
+ };
+
+ template<typename T>
+ const bool X1<T>::var;
+
+ template class X0<char>;
+ template class X1<char>;
+
+}
diff --git a/clang/test/SemaTemplate/instantiate-subscript.cpp b/clang/test/SemaTemplate/instantiate-subscript.cpp
new file mode 100644
index 0000000..8c119ec
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-subscript.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+
+struct Sub0 {
+ int &operator[](int);
+};
+
+struct Sub1 {
+ long &operator[](long); // expected-note{{candidate function}}
+};
+
+struct ConvertibleToInt {
+ operator int();
+};
+
+template<typename T, typename U, typename Result>
+struct Subscript0 {
+ void test(T t, U u) {
+ Result &result = t[u]; // expected-error{{no viable overloaded operator[] for type}}
+ }
+};
+
+template struct Subscript0<int*, int, int&>;
+template struct Subscript0<Sub0, int, int&>;
+template struct Subscript0<Sub1, ConvertibleToInt, long&>;
+template struct Subscript0<Sub1, Sub0, long&>; // expected-note{{instantiation}}
+
+// PR5345
+template <typename T>
+struct S {
+ bool operator[](int n) const { return true; }
+};
+
+template <typename T>
+void Foo(const S<int>& s, T x) {
+ if (s[0]) {}
+}
+
+void Bar() {
+ Foo(S<int>(), 0);
+}
diff --git a/clang/test/SemaTemplate/instantiate-template-template-parm.cpp b/clang/test/SemaTemplate/instantiate-template-template-parm.cpp
new file mode 100644
index 0000000..a70c7e8
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-template-template-parm.cpp
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<template<typename T> class MetaFun, typename Value>
+struct apply {
+ typedef typename MetaFun<Value>::type type;
+};
+
+template<class T>
+struct add_pointer {
+ typedef T* type;
+};
+
+template<class T>
+struct add_reference {
+ typedef T& type;
+};
+
+int i;
+apply<add_pointer, int>::type ip = &i;
+apply<add_reference, int>::type ir = i;
+apply<add_reference, float>::type fr = i; // expected-error{{non-const lvalue reference to type 'float' cannot bind to a value of unrelated type 'int'}}
+
+// Template template parameters
+template<int> struct B; // expected-note{{has a different type 'int'}}
+
+template<typename T,
+ template<T Value> class X> // expected-error{{cannot have type 'float'}} \
+ // expected-note{{with type 'long'}}
+struct X0 { };
+
+X0<int, B> x0b1;
+X0<float, B> x0b2; // expected-note{{while substituting}}
+X0<long, B> x0b3; // expected-error{{template template argument has different template parameters}}
+
+template<template<int V> class TT> // expected-note{{parameter with type 'int'}}
+struct X1 { };
+
+template<typename T, template<T V> class TT>
+struct X2 {
+ X1<TT> x1; // expected-error{{has different template parameters}}
+};
+
+template<int V> struct X3i { };
+template<long V> struct X3l { }; // expected-note{{different type 'long'}}
+
+X2<int, X3i> x2okay;
+X2<long, X3l> x2bad; // expected-note{{instantiation}}
+
+template <typename T, template <T, T> class TT, class R = TT<1, 2> >
+struct Comp {
+ typedef R r1;
+ template <T x, T y> struct gt {
+ static const bool result = x > y;
+ };
+ typedef gt<2, 1> r2;
+};
+
+template <int x, int y> struct lt {
+ static const bool result = x < y;
+};
+
+Comp<int, lt> c0;
+
+namespace PR8629 {
+ template<template<int> class TT> struct X0
+ {
+ static void apply();
+ };
+ template<int> struct Type { };
+
+ template<class T> struct X1
+ {
+ template<class U> struct Inner;
+
+ template<class U> void g()
+ {
+ typedef Inner<U> Init;
+ X0<Init::template VeryInner>::apply();
+ }
+ template<int N> void f ()
+ {
+ g<Type<N> >();
+ }
+ };
+ template<class T> template<class U> struct X1<T>::Inner
+ {
+ template<int> struct VeryInner {
+ };
+ };
+ struct X1Container
+ {
+ X1Container()
+ {
+ simplex_.f<0>();
+ }
+ X1<double> simplex_;
+ };
+}
diff --git a/clang/test/SemaTemplate/instantiate-try-catch.cpp b/clang/test/SemaTemplate/instantiate-try-catch.cpp
new file mode 100644
index 0000000..89cae03
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-try-catch.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -std=c++11 -verify %s
+
+template<typename T> struct TryCatch0 {
+ void f() {
+ try {
+ } catch (T&&) { // expected-error 2{{cannot catch exceptions by rvalue reference}}
+ }
+ }
+};
+
+template struct TryCatch0<int&>; // okay
+template struct TryCatch0<int&&>; // expected-note{{instantiation}}
+template struct TryCatch0<int>; // expected-note{{instantiation}}
+
+
+namespace PR10232 {
+ template <typename T>
+ class Templated {
+ struct Exception {
+ private:
+ Exception(const Exception&); // expected-note{{declared private here}}
+ };
+ void exception() {
+ try {
+ } catch(Exception e) { // expected-error{{calling a private constructor of class 'PR10232::Templated<int>::Exception'}}
+ }
+ }
+ };
+
+ template class Templated<int>; // expected-note{{in instantiation of member function 'PR10232::Templated<int>::exception' requested here}}
+}
diff --git a/clang/test/SemaTemplate/instantiate-type.cpp b/clang/test/SemaTemplate/instantiate-type.cpp
new file mode 100644
index 0000000..f5d0270
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-type.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+int* f(int);
+float *f(...);
+
+template<typename T>
+struct X {
+ typedef typeof(T*) typeof_type;
+ typedef typeof(f(T())) typeof_expr;
+};
+
+int *iptr0;
+float *fptr0;
+X<int>::typeof_type &iptr1 = iptr0;
+
+X<int>::typeof_expr &iptr2 = iptr0;
+X<float*>::typeof_expr &fptr1 = fptr0;
diff --git a/clang/test/SemaTemplate/instantiate-typedef.cpp b/clang/test/SemaTemplate/instantiate-typedef.cpp
new file mode 100644
index 0000000..4e6cd24
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-typedef.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+struct add_pointer {
+ typedef T* type; // expected-error{{'type' declared as a pointer to a reference}}
+};
+
+add_pointer<int>::type test1(int * ptr) { return ptr; }
+
+add_pointer<float>::type test2(int * ptr) {
+ return ptr; // expected-error{{cannot initialize return object of type 'add_pointer<float>::type' (aka 'float *') with an lvalue of type 'int *'}}
+}
+
+add_pointer<int&>::type // expected-note{{in instantiation of template class 'add_pointer<int &>' requested here}}
+test3();
diff --git a/clang/test/SemaTemplate/instantiate-typeof.cpp b/clang/test/SemaTemplate/instantiate-typeof.cpp
new file mode 100644
index 0000000..92873cb
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-typeof.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// Make sure we correctly treat __typeof as potentially-evaluated when appropriate
+template<typename T> void f(T n) {
+ int buffer[n]; // expected-note {{declared here}}
+ [] { __typeof(buffer) x; }(); // expected-error {{variable 'buffer' with variably modified type cannot be captured in a lambda expression}}
+}
+int main() {
+ f<int>(1); // expected-note {{in instantiation}}
+}
diff --git a/clang/test/SemaTemplate/instantiate-using-decl.cpp b/clang/test/SemaTemplate/instantiate-using-decl.cpp
new file mode 100644
index 0000000..1bfcb7a
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-using-decl.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace test0 {
+ namespace N { }
+
+ template<typename T>
+ struct A {
+ void f();
+ };
+
+ template<typename T>
+ struct B : A<T> {
+ using A<T>::f;
+
+ void g() {
+ using namespace N;
+ f();
+ }
+ };
+
+ template struct B<int>;
+}
+
+namespace test1 {
+ template <class Derived> struct Visitor1 {
+ void Visit(struct Object1*);
+ };
+ template <class Derived> struct Visitor2 {
+ void Visit(struct Object2*); // expected-note {{candidate function}}
+ };
+
+ template <class Derived> struct JoinVisitor
+ : Visitor1<Derived>, Visitor2<Derived> {
+ typedef Visitor1<Derived> Base1;
+ typedef Visitor2<Derived> Base2;
+
+ void Visit(struct Object1*); // expected-note {{candidate function}}
+ using Base2::Visit;
+ };
+
+ class Knot : public JoinVisitor<Knot> {
+ };
+
+ void test() {
+ Knot().Visit((struct Object1*) 0);
+ Knot().Visit((struct Object2*) 0);
+ Knot().Visit((struct Object3*) 0); // expected-error {{no matching member function for call}}
+ }
+}
+
+// PR5847
+namespace test2 {
+ namespace ns {
+ void foo();
+ }
+
+ template <class T> void bar(T* ptr) {
+ using ns::foo;
+ foo();
+ }
+
+ template void bar(char *);
+}
+
+namespace test3 {
+ template <typename T> struct t {
+ struct s1 {
+ T f1() const;
+ };
+ struct s2 : s1 {
+ using s1::f1;
+ T f1() const;
+ };
+ };
+
+ void f2()
+ {
+ t<int>::s2 a;
+ t<int>::s2 const & b = a;
+ b.f1();
+ }
+}
diff --git a/clang/test/SemaTemplate/instantiation-backtrace.cpp b/clang/test/SemaTemplate/instantiation-backtrace.cpp
new file mode 100644
index 0000000..21456e9
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiation-backtrace.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T> struct A; // expected-note 4{{template is declared here}}
+
+template<typename T> struct B : A<T*> { }; // expected-error{{implicit instantiation of undefined template}} \
+// expected-error{{implicit instantiation of undefined template 'A<X *>'}}
+
+template<typename T> struct C : B<T> { } ; // expected-note{{instantiation of template class}}
+
+template<typename T> struct D : C<T> { }; // expected-note{{instantiation of template class}}
+
+template<typename T> struct E : D<T> { }; // expected-note{{instantiation of template class}}
+
+template<typename T> struct F : E<T(T)> { }; // expected-note{{instantiation of template class}}
+
+void f() {
+ (void)sizeof(F<int>); // expected-note{{instantiation of template class}}
+}
+
+typedef struct { } X;
+
+void g() {
+ (void)sizeof(B<X>); // expected-note{{in instantiation of template class 'B<X>' requested here}}
+}
+
+template<typename T>
+struct G : A<T>, // expected-error{{implicit instantiation of undefined template 'A<int>'}}
+ A<T*> // expected-error{{implicit instantiation of undefined template 'A<int *>'}}
+ { };
+
+void h() {
+ (void)sizeof(G<int>); // expected-note{{in instantiation of template class 'G<int>' requested here}}
+}
diff --git a/clang/test/SemaTemplate/instantiation-default-1.cpp b/clang/test/SemaTemplate/instantiation-default-1.cpp
new file mode 100644
index 0000000..99154a5
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiation-default-1.cpp
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T, typename U = const T> struct Def1;
+
+template<> struct Def1<int> {
+ void foo();
+};
+
+template<> struct Def1<const int> { // expected-note{{previous definition is here}}
+ void bar();
+};
+
+template<> struct Def1<int&> {
+ void wibble();
+};
+
+void test_Def1(Def1<int, const int> *d1, Def1<const int, const int> *d2,
+ Def1<int&, int&> *d3) {
+ d1->foo();
+ d2->bar();
+ d3->wibble();
+}
+
+template<typename T, // FIXME: bad error message below, needs better location info
+ typename T2 = const T*> // expected-error{{'T2' declared as a pointer to a reference}}
+ struct Def2;
+
+template<> struct Def2<int> {
+ void foo();
+};
+
+void test_Def2(Def2<int, int const*> *d2) {
+ d2->foo();
+}
+
+typedef int& int_ref_t;
+Def2<int_ref_t> *d2; // expected-note{{in instantiation of default argument for 'Def2<int &>' required here}}
+
+
+template<> struct Def1<const int, const int> { }; // expected-error{{redefinition of 'Def1<const int>'}}
+
+template<typename T, typename T2 = T&> struct Def3;
+
+template<> struct Def3<int> {
+ void foo();
+};
+
+template<> struct Def3<int&> {
+ void bar();
+};
+
+void test_Def3(Def3<int, int&> *d3a, Def3<int&, int&> *d3b) {
+ d3a->foo();
+ d3b->bar();
+}
+
+
+template<typename T, typename T2 = T[]> struct Def4;
+
+template<> struct Def4<int> {
+ void foo();
+};
+
+void test_Def4(Def4<int, int[]> *d4a) {
+ d4a->foo();
+}
+
+template<typename T, typename T2 = T const[12]> struct Def5;
+
+template<> struct Def5<int> {
+ void foo();
+};
+
+template<> struct Def5<int, int const[13]> {
+ void bar();
+};
+
+void test_Def5(Def5<int, const int[12]> *d5a, Def5<int, const int[13]> *d5b) {
+ d5a->foo();
+ d5b->bar();
+}
+
+template<typename R, typename Arg1, typename Arg2 = Arg1,
+ typename FuncType = R (*)(Arg1, Arg2)>
+ struct Def6;
+
+template<> struct Def6<int, float> {
+ void foo();
+};
+
+template<> struct Def6<bool, int[5], float(double, double)> {
+ void bar();
+};
+
+bool test_Def6(Def6<int, float, float> *d6a,
+ Def6<int, float, float, int (*)(float, float)> *d6b,
+ Def6<bool, int[5], float(double, double),
+ bool(*)(int*, float(*)(double, double))> *d6c) {
+ d6a->foo();
+ d6b->foo();
+ d6c->bar();
+ return d6a == d6b;
+}
diff --git a/clang/test/SemaTemplate/instantiation-default-2.cpp b/clang/test/SemaTemplate/instantiation-default-2.cpp
new file mode 100644
index 0000000..5a744a0
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiation-default-2.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T, T Value> struct Constant; // expected-note{{template parameter is declared here}} \
+// FIXME: bad location expected-error{{a non-type template parameter cannot have type 'float'}}
+
+Constant<int, 5> *c1;
+
+int x;
+float f(int, double);
+
+Constant<int&, x> *c2;
+Constant<int*, &x> *c3;
+Constant<float (*)(int, double), f> *c4;
+Constant<float (*)(int, double), &f> *c5;
+
+Constant<float (*)(int, int), f> *c6; // expected-error{{non-type template argument of type 'float (int, double)' cannot be converted to a value of type 'float (*)(int, int)'}}
+
+Constant<float, 0> *c7; // expected-note{{while substituting}}
diff --git a/clang/test/SemaTemplate/instantiation-default-3.cpp b/clang/test/SemaTemplate/instantiation-default-3.cpp
new file mode 100644
index 0000000..dae6b18
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiation-default-3.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> struct A { };
+
+template<typename T, typename U = A<T*> >
+ struct B : U { };
+
+template<>
+struct A<int*> {
+ void foo();
+};
+
+template<>
+struct A<float*> {
+ void bar();
+};
+
+void test(B<int> *b1, B<float> *b2) {
+ b1->foo();
+ b2->bar();
+}
diff --git a/clang/test/SemaTemplate/instantiation-depth.cpp b/clang/test/SemaTemplate/instantiation-depth.cpp
new file mode 100644
index 0000000..8e1b803
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiation-depth.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-depth 5 -ftemplate-backtrace-limit 4 %s
+// RUN: %clang -fsyntax-only -Xclang -verify -ftemplate-depth-5 -ftemplate-backtrace-limit=4 %s
+// RUN: %clang -fsyntax-only -Xclang -verify -ftemplate-depth=5 -ftemplate-backtrace-limit=4 %s
+
+template<typename T> struct X : X<T*> { }; \
+// expected-error{{recursive template instantiation exceeded maximum depth of 5}} \
+// expected-note 3 {{instantiation of template class}} \
+// expected-note {{skipping 2 contexts in backtrace}} \
+// expected-note {{use -ftemplate-depth=N to increase recursive template instantiation depth}}
+
+void test() {
+ (void)sizeof(X<int>); // expected-note {{instantiation of template class}}
+}
diff --git a/clang/test/SemaTemplate/instantiation-order.cpp b/clang/test/SemaTemplate/instantiation-order.cpp
new file mode 100644
index 0000000..e058a5b
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiation-order.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+// From core issue 1227.
+
+template <class T> struct A { using X = typename T::X; }; // expected-error {{no members}}
+template <class T> typename T::X f(typename A<T>::X);
+template <class T> void f(...) {}
+template <class T> auto g(typename A<T>::X) -> typename T::X; // expected-note {{here}} expected-note {{substituting}}
+template <class T> void g(...) {}
+
+void h()
+{
+ f<int>(0); // ok, SFINAE in return type
+ g<int>(0); // not ok, substitution inside A<int> is a hard error
+}
diff --git a/clang/test/SemaTemplate/issue150.cpp b/clang/test/SemaTemplate/issue150.cpp
new file mode 100644
index 0000000..af3b93c
--- /dev/null
+++ b/clang/test/SemaTemplate/issue150.cpp
@@ -0,0 +1,107 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Core issue 150: Template template parameters and default arguments
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+namespace PR9353 {
+ template<class _T, class Traits> class IM;
+
+ template <class T, class Trt,
+ template<class _T, class Traits = int> class IntervalMap>
+ void foo(IntervalMap<T,Trt>* m) { typedef IntervalMap<int> type; }
+
+ void f(IM<int, int>* m) { foo(m); }
+}
+
+namespace PR9400 {
+ template<template <typename T, typename = T > class U> struct A
+ {
+ template<int> U<int> foo();
+ };
+
+ template <typename T, typename = T>
+ struct s {
+ };
+
+ void f() {
+ A<s> x;
+ x.foo<2>();
+ }
+}
+
+namespace MultiReplace {
+ template<typename Z,
+ template<typename T, typename U = T *, typename V = U const> class TT>
+ struct X {
+ typedef TT<Z> type;
+ };
+
+ template<typename T, typename = int, typename = float>
+ struct Y { };
+
+ int check0[is_same<X<int, Y>::type, Y<int, int*, int* const> >::value? 1 : -1];
+}
+
+namespace MultiReplacePartial {
+ template<typename First, typename Z,
+ template<typename T, typename U = T *, typename V = U const> class TT>
+ struct X {
+ typedef TT<Z> type;
+ };
+
+ template<typename Z,
+ template<typename T, typename U = T *, typename V = U const> class TT>
+ struct X<int, Z, TT> {
+ typedef TT<Z> type;
+ };
+
+ template<typename T, typename = int, typename = float>
+ struct Y { };
+
+ int check0[is_same<X<int, int, Y>::type, Y<int, int*, int* const> >::value? 1 : -1];
+}
+
+namespace PR9016 {
+ template<typename > struct allocator ;
+ template<typename > struct less ;
+
+ template<class T, template<class> class Compare, class Default,
+ template<class> class Alloc>
+ struct interval_set { };
+
+ template <class X, template<class> class = less> struct interval_type_default {
+ typedef X type;
+ };
+
+ template <class T,
+ template<class _T, template<class> class Compare = PR9016::less,
+ class = typename interval_type_default<_T,Compare>::type,
+ template<class> class = allocator> class IntervalSet>
+ struct ZZZ
+ {
+ IntervalSet<T> IntervalSetT;
+ };
+
+ template <class T,
+ template<class _T, template<class> class Compare = PR9016::less,
+ class = typename interval_type_default<_T,Compare>::type,
+ template<class> class = allocator> class IntervalSet>
+ void int40()
+ {
+ IntervalSet<T> IntervalSetT;
+ }
+
+ void test() {
+ ZZZ<int, interval_set> zzz;
+ int40<int, interval_set>();
+ }
+}
diff --git a/clang/test/SemaTemplate/lookup-dependent-bases.cpp b/clang/test/SemaTemplate/lookup-dependent-bases.cpp
new file mode 100644
index 0000000..2710caf
--- /dev/null
+++ b/clang/test/SemaTemplate/lookup-dependent-bases.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s
+
+class C {
+public:
+ static void foo2() { }
+};
+template <class T>
+class A {
+public:
+ typedef C D;
+};
+
+template <class T>
+class B : public A<T> {
+public:
+ void foo() {
+ D::foo2();
+ }
+};
diff --git a/clang/test/SemaTemplate/member-access-ambig.cpp b/clang/test/SemaTemplate/member-access-ambig.cpp
new file mode 100644
index 0000000..f8a01d5
--- /dev/null
+++ b/clang/test/SemaTemplate/member-access-ambig.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR8439
+class A
+{
+};
+
+class B
+{
+public:
+ A & m;
+};
+
+class Base
+{
+public:
+ B &f();
+};
+
+class Derived1 : public Base { };
+
+class Derived2 : public Base { };
+
+class X : public B, public Derived2, public Derived1
+{
+public:
+ virtual void g();
+};
+
+void X::g()
+{
+ m.f<int>(); // expected-error{{no member named 'f' in 'A'}} \
+ // expected-error{{expected '(' for function-style cast}} \
+ // expected-error{{expected expression}}
+}
+
+namespace PR11134 {
+ template<typename Derived> class A;
+ template<typename Derived> class B : A<Derived> {
+ typedef A<Derived> Base;
+ using Base::member;
+ int member;
+ };
+}
+
diff --git a/clang/test/SemaTemplate/member-access-expr.cpp b/clang/test/SemaTemplate/member-access-expr.cpp
new file mode 100644
index 0000000..f1aa30e
--- /dev/null
+++ b/clang/test/SemaTemplate/member-access-expr.cpp
@@ -0,0 +1,149 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T>
+void call_f0(T x) {
+ x.Base::f0();
+}
+
+struct Base {
+ void f0();
+};
+
+struct X0 : Base {
+ typedef Base CrazyBase;
+};
+
+void test_f0(X0 x0) {
+ call_f0(x0);
+}
+
+template<typename TheBase, typename T>
+void call_f0_through_typedef(T x) {
+ typedef TheBase Base2;
+ x.Base2::f0();
+}
+
+void test_f0_through_typedef(X0 x0) {
+ call_f0_through_typedef<Base>(x0);
+}
+
+template<typename TheBase, typename T>
+void call_f0_through_typedef2(T x) {
+ typedef TheBase CrazyBase; // expected-note{{current scope}}
+ x.CrazyBase::f0(); // expected-error{{ambiguous}} \
+ // expected-error 2{{no member named}}
+}
+
+struct OtherBase { };
+
+struct X1 : Base, OtherBase {
+ typedef OtherBase CrazyBase; // expected-note{{object type}}
+};
+
+void test_f0_through_typedef2(X0 x0, X1 x1) {
+ call_f0_through_typedef2<Base>(x0);
+ call_f0_through_typedef2<OtherBase>(x1); // expected-note{{instantiation}}
+ call_f0_through_typedef2<Base>(x1); // expected-note{{instantiation}}
+}
+
+
+struct X2 {
+ operator int() const;
+};
+
+template<typename T, typename U>
+T convert(const U& value) {
+ return value.operator T(); // expected-error{{operator long}}
+}
+
+void test_convert(X2 x2) {
+ convert<int>(x2);
+ convert<long>(x2); // expected-note{{instantiation}}
+}
+
+template<typename T>
+void destruct(T* ptr) {
+ ptr->~T();
+ ptr->T::~T();
+}
+
+template<typename T>
+void destruct_intptr(int *ip) {
+ ip->~T();
+ ip->T::~T();
+}
+
+void test_destruct(X2 *x2p, int *ip) {
+ destruct(x2p);
+ destruct(ip);
+ destruct_intptr<int>(ip);
+}
+
+// PR5220
+class X3 {
+protected:
+ template <int> float* &f0();
+ template <int> const float* &f0() const;
+ void f1() {
+ (void)static_cast<float*>(f0<0>());
+ }
+ void f1() const{
+ (void)f0<0>();
+ }
+};
+
+// Fun with template instantiation and conversions
+struct X4 {
+ int& member();
+ float& member() const;
+};
+
+template<typename T>
+struct X5 {
+ void f(T* ptr) { int& ir = ptr->member(); }
+ void g(T* ptr) { float& fr = ptr->member(); }
+};
+
+void test_X5(X5<X4> x5, X5<const X4> x5c, X4 *xp, const X4 *cxp) {
+ x5.f(xp);
+ x5c.g(cxp);
+}
+
+// In theory we can do overload resolution at template-definition time on this.
+// We should at least not assert.
+namespace test4 {
+ struct Base {
+ template <class T> void foo() {}
+ };
+
+ template <class T> struct Foo : Base {
+ void test() {
+ foo<int>();
+ }
+ };
+}
+
+namespace test5 {
+ template<typename T>
+ struct X {
+ using T::value;
+
+ T &getValue() {
+ return &value;
+ }
+ };
+}
+
+// PR8739
+namespace test6 {
+ struct A {};
+ struct B {};
+ template <class T> class Base;
+ template <class T> class Derived : public Base<T> {
+ A *field;
+ void get(B **ptr) {
+ // It's okay if at some point we figure out how to diagnose this
+ // at instantiation time.
+ *ptr = field;
+ }
+ };
+}
diff --git a/clang/test/SemaTemplate/member-function-template.cpp b/clang/test/SemaTemplate/member-function-template.cpp
new file mode 100644
index 0000000..44954ed
--- /dev/null
+++ b/clang/test/SemaTemplate/member-function-template.cpp
@@ -0,0 +1,103 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct X {
+ template<typename T> T& f0(T);
+
+ void g0(int i, double d) {
+ int &ir = f0(i);
+ double &dr = f0(d);
+ }
+
+ template<typename T> T& f1(T);
+ template<typename T, typename U> U& f1(T, U);
+
+ void g1(int i, double d) {
+ int &ir1 = f1(i);
+ int &ir2 = f1(d, i);
+ int &ir3 = f1(i, i);
+ }
+};
+
+void test_X_f0(X x, int i, float f) {
+ int &ir = x.f0(i);
+ float &fr = x.f0(f);
+}
+
+void test_X_f1(X x, int i, float f) {
+ int &ir1 = x.f1(i);
+ int &ir2 = x.f1(f, i);
+ int &ir3 = x.f1(i, i);
+}
+
+void test_X_f0_address() {
+ int& (X::*pm1)(int) = &X::f0;
+ float& (X::*pm2)(float) = &X::f0;
+}
+
+void test_X_f1_address() {
+ int& (X::*pm1)(int) = &X::f1;
+ float& (X::*pm2)(float) = &X::f1;
+ int& (X::*pm3)(float, int) = &X::f1;
+}
+
+void test_X_f0_explicit(X x, int i, long l) {
+ int &ir1 = x.f0<int>(i);
+ int &ir2 = x.f0<>(i);
+ long &il1 = x.f0<long>(i);
+}
+
+// PR4608
+class A { template <class x> x a(x z) { return z+y; } int y; };
+
+// PR5419
+struct Functor {
+ template <typename T>
+ bool operator()(const T& v) const {
+ return true;
+ }
+};
+
+void test_Functor(Functor f) {
+ f(1);
+}
+
+// Instantiation on ->
+template<typename T>
+struct X1 {
+ template<typename U> U& get();
+};
+
+template<typename T> struct X2; // expected-note{{here}}
+
+void test_incomplete_access(X1<int> *x1, X2<int> *x2) {
+ float &fr = x1->get<float>();
+ (void)x2->get<float>(); // expected-error{{implicit instantiation of undefined template}}
+}
+
+// Instantiation of template template parameters in a member function
+// template.
+namespace TTP {
+ template<int Dim> struct X {
+ template<template<class> class M, class T> void f(const M<T>&);
+ };
+
+ template<typename T> struct Y { };
+
+ void test_f(X<3> x, Y<int> y) { x.f(y); }
+}
+
+namespace PR7387 {
+ template <typename T> struct X {};
+
+ template <typename T1> struct S {
+ template <template <typename> class TC> void foo(const TC<T1>& arg);
+ };
+
+ template <typename T1> template <template <typename> class TC>
+ void S<T1>::foo(const TC<T1>& arg) {}
+
+ void test(const X<int>& x) {
+ S<int> s;
+ s.foo(x);
+ }
+}
diff --git a/clang/test/SemaTemplate/member-inclass-init-value-dependent.cpp b/clang/test/SemaTemplate/member-inclass-init-value-dependent.cpp
new file mode 100644
index 0000000..5bff7f2
--- /dev/null
+++ b/clang/test/SemaTemplate/member-inclass-init-value-dependent.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+// PR10290
+
+template<int Flags> struct foo {
+ int value = Flags && 0;
+};
+
+void test() {
+ foo<4> bar;
+}
+
+struct S {
+ S(int n);
+};
+template<typename> struct T {
+ S s = 0;
+};
+T<int> t;
diff --git a/clang/test/SemaTemplate/member-initializers.cpp b/clang/test/SemaTemplate/member-initializers.cpp
new file mode 100644
index 0000000..40f56b3
--- /dev/null
+++ b/clang/test/SemaTemplate/member-initializers.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> struct A {
+ A() : j(10), i(10) { }
+
+ int i;
+ int j;
+};
+
+template<typename T> struct B : A<T> {
+ B() : A<T>() { }
+};
+
diff --git a/clang/test/SemaTemplate/member-template-access-expr.cpp b/clang/test/SemaTemplate/member-template-access-expr.cpp
new file mode 100644
index 0000000..c95b57d
--- /dev/null
+++ b/clang/test/SemaTemplate/member-template-access-expr.cpp
@@ -0,0 +1,144 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename U, typename T>
+U f0(T t) {
+ return t.template get<U>();
+}
+
+template<typename U, typename T>
+int &f1(T t) {
+ // FIXME: When we pretty-print this, we lose the "template" keyword.
+ return t.U::template get<int&>();
+}
+
+struct X {
+ template<typename T> T get();
+};
+
+void test_f0(X x) {
+ int i = f0<int>(x);
+ int &ir = f0<int&>(x);
+}
+
+struct XDerived : public X {
+};
+
+void test_f1(XDerived xd) {
+ int &ir = f1<X>(xd);
+}
+
+// PR5213
+template <class T>
+struct A {};
+
+template<class T>
+class B
+{
+ A<T> a_;
+
+public:
+ void destroy();
+};
+
+template<class T>
+void
+B<T>::destroy()
+{
+ a_.~A<T>();
+}
+
+void do_destroy_B(B<int> b) {
+ b.destroy();
+}
+
+struct X1 {
+ int* f1(int);
+ template<typename T> float* f1(T);
+
+ static int* f2(int);
+ template<typename T> static float* f2(T);
+};
+
+void test_X1(X1 x1) {
+ float *fp1 = x1.f1<>(17);
+ float *fp2 = x1.f1<int>(3.14); // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+ int *ip1 = x1.f1(17);
+ float *ip2 = x1.f1(3.14);
+
+ float* (X1::*mf1)(int) = &X1::f1;
+ float* (X1::*mf2)(int) = &X1::f1<>;
+ float* (X1::*mf3)(float) = &X1::f1<float>;
+
+ float* (*fp3)(int) = &X1::f2;
+ float* (*fp4)(int) = &X1::f2<>;
+ float* (*fp5)(float) = &X1::f2<float>;
+ float* (*fp6)(int) = X1::f2;
+ float* (*fp7)(int) = X1::f2<>;
+ float* (*fp8)(float) = X1::f2<float>;
+}
+
+template<int A> struct X2 {
+ int m;
+};
+
+template<typename T>
+struct X3 : T { };
+
+template<typename T>
+struct X4 {
+ template<typename U>
+ void f(X2<sizeof(X3<U>().U::m)>);
+};
+
+void f(X4<X3<int> > x4i) {
+ X2<sizeof(int)> x2;
+ x4i.f<X2<sizeof(int)> >(x2);
+}
+
+template<typename T>
+struct X5 {
+ template<typename U>
+ void f();
+
+ void g() {
+ this->f<T*>();
+ }
+};
+
+namespace PR6021 {
+ template< class T1, class T2 >
+ class Outer
+ {
+ public: // Range operations
+ template< class X > X tmpl( const X* = 0 ) const;
+
+ struct Inner
+ {
+ const Outer& o;
+
+ template< class X >
+ operator X() const
+ {
+ return o.tmpl<X>();
+ }
+ };
+ };
+}
+
+namespace rdar8198511 {
+ template<int, typename U>
+ struct Base {
+ void f();
+ };
+
+ template<typename T>
+ struct X0 : Base<1, T> { };
+
+ template<typename T>
+ struct X1 {
+ X0<int> x0;
+
+ void f() {
+ this->x0.Base<1, int>::f();
+ }
+ };
+}
diff --git a/clang/test/SemaTemplate/metafun-apply.cpp b/clang/test/SemaTemplate/metafun-apply.cpp
new file mode 100644
index 0000000..3a7408e
--- /dev/null
+++ b/clang/test/SemaTemplate/metafun-apply.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct add_pointer {
+ template<typename T>
+ struct apply {
+ typedef T* type;
+ };
+};
+
+struct add_reference {
+ template<typename T>
+ struct apply {
+ typedef T& type; // expected-error{{cannot form a reference to 'void'}}
+ };
+};
+
+struct bogus {
+ struct apply {
+ typedef int type;
+ };
+};
+
+template<typename MetaFun, typename T>
+struct apply1 {
+ typedef typename MetaFun::template apply<T>::type type; // expected-note{{in instantiation of template class 'add_reference::apply<void>' requested here}} \
+ // expected-error{{'apply' following the 'template' keyword does not refer to a template}}
+};
+
+int i;
+apply1<add_pointer, int>::type ip = &i;
+apply1<add_reference, int>::type ir = i;
+apply1<add_reference, float>::type fr = i; // expected-error{{non-const lvalue reference to type 'float' cannot bind to a value of unrelated type 'int'}}
+
+void test() {
+ apply1<add_reference, void>::type t; // expected-note{{in instantiation of template class 'apply1<add_reference, void>' requested here}}
+
+ apply1<bogus, int>::type t2; // expected-note{{in instantiation of template class 'apply1<bogus, int>' requested here}}
+}
+
+
diff --git a/clang/test/SemaTemplate/missing-class-keyword-crash.cpp b/clang/test/SemaTemplate/missing-class-keyword-crash.cpp
new file mode 100644
index 0000000..f0eee2b
--- /dev/null
+++ b/clang/test/SemaTemplate/missing-class-keyword-crash.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class G {};
+template <Foo> // expected-error{{unknown type name 'Foo'}} \
+ // expected-note{{template parameter is declared here}}
+class Bar {};
+
+class Bar<G> blah_test; // expected-error{{template argument for non-type template parameter must be an expression}}
diff --git a/clang/test/SemaTemplate/ms-function-specialization-class-scope.cpp b/clang/test/SemaTemplate/ms-function-specialization-class-scope.cpp
new file mode 100644
index 0000000..bda87f9
--- /dev/null
+++ b/clang/test/SemaTemplate/ms-function-specialization-class-scope.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s
+
+
+class A {
+public:
+ template <class U>
+ A(U p) {
+ }
+ template <>
+ A(int p) { // expected-warning{{explicit specialization of 'A' within class scope is a Microsoft extension}}
+ }
+
+ template <class U>
+ void f(U p) {
+ }
+
+ template <>
+ void f(int p) { // expected-warning{{explicit specialization of 'f' within class scope is a Microsoft extension}}
+ }
+
+ void f(int p) {
+ }
+};
+
+void test1()
+{
+ A a(3);
+ char* b ;
+ a.f(b);
+ a.f<int>(99);
+ a.f(100);
+}
+
+
+
+
+template <class T>
+class B {
+public:
+ template <class U>
+ B(U p) {
+ }
+ template <>
+ B(int p) { // expected-warning{{explicit specialization of 'B<T>' within class scope is a Microsoft extension}}
+ }
+
+ template <class U>
+ void f(U p) {
+ T y = 9;
+ }
+
+
+ template <>
+ void f(int p) { // expected-warning{{explicit specialization of 'f' within class scope is a Microsoft extension}}
+ T a = 3;
+ }
+
+ void f(int p) {
+ T a = 3;
+ }
+};
+
+void test2()
+{
+ B<char> b(3);
+ char* ptr;
+ b.f(ptr);
+ b.f<int>(99);
+ b.f(100);
+}
+
diff --git a/clang/test/SemaTemplate/ms-if-exists.cpp b/clang/test/SemaTemplate/ms-if-exists.cpp
new file mode 100644
index 0000000..04f4a63
--- /dev/null
+++ b/clang/test/SemaTemplate/ms-if-exists.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fms-extensions -std=c++11 %s -verify
+
+struct Nontemplate {
+ typedef int type;
+};
+
+template<typename T>
+struct X {
+ __if_exists(Nontemplate::type) {
+ typedef Nontemplate::type type;
+ }
+
+ __if_exists(Nontemplate::value) {
+ typedef Nontemplate::value type2;
+ }
+
+ __if_not_exists(Nontemplate::value) {
+ typedef int type3;
+ }
+
+ __if_exists(T::X) { // expected-warning{{dependent __if_exists declarations are ignored}}
+ typedef T::X type4;
+ }
+};
+
+X<int>::type i1;
+X<int>::type2 i2; // expected-error{{no type named 'type2' in 'X<int>'}}
+X<int>::type3 i3;
+X<int>::type4 i4; // expected-error{{no type named 'type4' in 'X<int>'}}
+
+struct HasFoo {
+ void foo();
+};
+struct HasBar {
+ void bar(int);
+ void bar(float);
+};
+
+template<typename T>
+void f(T t) {
+ __if_exists(T::foo) {
+ { }
+ t.foo();
+ }
+
+ __if_not_exists(T::bar) {
+ int *i = t; // expected-error{{no viable conversion from 'HasFoo' to 'int *'}}
+ { }
+ }
+
+ int array2[] = {
+ 0,
+ __if_exists(T::bar) {2, }// expected-warning{{dependent __if_exists declarations are ignored}}
+ 3
+ };
+}
+
+template void f(HasFoo); // expected-note{{in instantiation of function template specialization 'f<HasFoo>' requested here}}
+template void f(HasBar);
+
+template<typename T, typename ...Ts>
+void g(T, Ts...) {
+ __if_exists(T::operator Ts) { // expected-error{{__if_exists name contains unexpanded parameter pack 'Ts'}}
+ }
+
+ __if_not_exists(Ts::operator T) { // expected-error{{__if_not_exists name contains unexpanded parameter pack 'Ts'}}
+ }
+}
diff --git a/clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp b/clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
new file mode 100644
index 0000000..2c422dc
--- /dev/null
+++ b/clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
@@ -0,0 +1,145 @@
+// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
+
+
+template <class T>
+class A {
+public:
+ void f(T a) { }// expected-note {{must qualify identifier to find this declaration in dependent base class}}
+ void g();// expected-note {{must qualify identifier to find this declaration in dependent base class}}
+};
+
+
+template <class T>
+class B : public A<T> {
+public:
+ void z(T a)
+ {
+ f(a); // expected-warning {{use of identifier 'f' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
+ g(); // expected-warning {{use of identifier 'g' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
+ }
+};
+
+template class B<int>; // expected-note {{requested here}}
+template class B<char>;
+
+void test()
+{
+ B<int> b;
+ b.z(3);
+}
+
+namespace lookup_dependent_bases_id_expr {
+
+template<class T> class A {
+public:
+ int var;
+};
+
+
+template<class T>
+class B : public A<T> {
+public:
+ void f() {
+ var = 3;
+ }
+};
+
+template class B<int>;
+
+}
+
+
+
+namespace lookup_dependent_base_class_static_function {
+
+template <class T>
+class A {
+public:
+ static void static_func();// expected-note {{must qualify identifier to find this declaration in dependent base class}}
+ void func();// expected-note {{must qualify identifier to find this declaration in dependent base class}}
+};
+
+
+template <class T>
+class B : public A<T> {
+public:
+ static void z2(){
+ static_func(); // expected-warning {{use of identifier 'static_func' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
+ func(); // expected-warning {{use of identifier 'func' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} expected-error {{call to non-static member function without an object argument}}
+ }
+};
+template class B<int>; // expected-note {{requested here}}
+
+}
+
+
+
+namespace lookup_dependent_base_class_default_argument {
+
+template<class T>
+class A {
+public:
+ static int f1(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
+ int f2(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
+};
+
+template<class T>
+class B : public A<T> {
+public:
+ void g1(int p = f1());// expected-warning {{use of identifier 'f1' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
+ void g2(int p = f2());// expected-warning {{use of identifier 'f2' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} expected-error {{call to non-static member function without an object argument}}
+};
+
+void foo()
+{
+ B<int> b;
+ b.g1(); // expected-note {{required here}}
+ b.g2(); // expected-note {{required here}}
+}
+
+}
+
+
+namespace lookup_dependent_base_class_friend {
+
+template <class T>
+class B {
+public:
+ static void g(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
+};
+
+template <class T>
+class A : public B<T> {
+public:
+ friend void foo(A<T> p){
+ g(); // expected-warning {{use of identifier 'g' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
+ }
+};
+
+int main2()
+{
+ A<int> a;
+ foo(a); // expected-note {{requested here}}
+}
+
+}
+
+
+namespace lookup_dependent_base_no_typo_correction {
+
+class C {
+public:
+ int m_hWnd;
+};
+
+template <class T>
+class A : public T {
+public:
+ void f(int hWnd) {
+ m_hWnd = 1;
+ }
+};
+
+template class A<C>;
+
+}
diff --git a/clang/test/SemaTemplate/nested-incomplete-class.cpp b/clang/test/SemaTemplate/nested-incomplete-class.cpp
new file mode 100644
index 0000000..a4bfccb
--- /dev/null
+++ b/clang/test/SemaTemplate/nested-incomplete-class.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+template <typename T>
+struct foo {
+ struct bar;
+
+ bar fn() {
+ // Should not get errors about bar being incomplete here.
+ bar b = bar(1, 2);
+ return b;
+ }
+};
+
+template <typename T>
+struct foo<T>::bar {
+ bar(int, int);
+};
+
+void fn() {
+ foo<int>().fn();
+}
diff --git a/clang/test/SemaTemplate/nested-linkage.cpp b/clang/test/SemaTemplate/nested-linkage.cpp
new file mode 100644
index 0000000..6c0791c
--- /dev/null
+++ b/clang/test/SemaTemplate/nested-linkage.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+extern "C" { extern "C++" { template<class C> C x(); } }
diff --git a/clang/test/SemaTemplate/nested-name-spec-template.cpp b/clang/test/SemaTemplate/nested-name-spec-template.cpp
new file mode 100644
index 0000000..635687d
--- /dev/null
+++ b/clang/test/SemaTemplate/nested-name-spec-template.cpp
@@ -0,0 +1,142 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace N {
+ namespace M {
+ template<typename T> struct Promote;
+
+ template<> struct Promote<short> {
+ typedef int type;
+ };
+
+ template<> struct Promote<int> {
+ typedef int type;
+ };
+
+ template<> struct Promote<float> {
+ typedef double type;
+ };
+
+ Promote<short>::type *ret_intptr(int* ip) { return ip; }
+ Promote<int>::type *ret_intptr2(int* ip) { return ip; }
+ }
+
+ M::Promote<int>::type *ret_intptr3(int* ip) { return ip; }
+ M::template Promote<int>::type *ret_intptr4(int* ip) { return ip; } // expected-warning{{'template' keyword outside of a template}}
+ M::template Promote<int> pi; // expected-warning{{'template' keyword outside of a template}}
+}
+
+N::M::Promote<int>::type *ret_intptr5(int* ip) { return ip; }
+::N::M::Promote<int>::type *ret_intptr6(int* ip) { return ip; }
+
+
+N::M::template; // expected-error{{expected unqualified-id}}
+N::M::template Promote; // expected-error{{expected unqualified-id}}
+
+namespace N {
+ template<typename T> struct A;
+
+ template<>
+ struct A<int> {
+ struct X;
+ };
+
+ struct B;
+}
+
+struct ::N::A<int>::X {
+ int foo;
+};
+
+template<typename T>
+struct TestA {
+ typedef typename N::template B<T>::type type; // expected-error{{'B' following the 'template' keyword does not refer to a template}} \
+ // expected-error{{expected member name}}
+};
+
+// Reduced from a Boost failure.
+namespace test1 {
+ template <class T> struct pair {
+ T x;
+ T y;
+
+ static T pair<T>::* const mem_array[2];
+ };
+
+ template <class T>
+ T pair<T>::* const pair<T>::mem_array[2] = { &pair<T>::x, &pair<T>::y };
+}
+
+typedef int T;
+namespace N1 {
+ template<typename T> T f0();
+}
+
+template<typename T> T N1::f0() { }
+
+namespace PR7385 {
+ template< typename > struct has_xxx0
+ {
+ template< typename > struct has_xxx0_introspect
+ {
+ template< typename > struct has_xxx0_substitute ;
+ template< typename V >
+ int int00( has_xxx0_substitute < typename V::template xxx< > > = 0 );
+ };
+ static const int value = has_xxx0_introspect<int>::value; // expected-error{{no member named 'value'}}
+ typedef int type;
+ };
+
+ has_xxx0<int>::type t; // expected-note{{instantiation of}}
+}
+
+namespace PR7725 {
+ template<class ignored> struct TypedefProvider;
+ template<typename T>
+ struct TemplateClass : public TypedefProvider<T>
+ {
+ void PrintSelf() {
+ TemplateClass::Test::PrintSelf();
+ }
+ };
+}
+
+namespace PR9226 {
+ template<typename a>
+ void nt() // expected-note{{function template 'nt' declared here}}
+ { nt<>:: } // expected-error{{qualified name refers into a specialization of function template 'nt'}} \
+ // expected-error{{expected unqualified-id}}
+
+ template<typename T>
+ void f(T*); // expected-note{{function template 'f' declared here}}
+
+ template<typename T>
+ void f(T*, T*); // expected-note{{function template 'f' declared here}}
+
+ void g() {
+ f<int>:: // expected-error{{qualified name refers into a specialization of function template 'f'}}
+ } // expected-error{{expected unqualified-id}}
+
+ struct X {
+ template<typename T> void f(); // expected-note{{function template 'f' declared here}}
+ };
+
+ template<typename T, typename U>
+ struct Y {
+ typedef typename T::template f<U> type; // expected-error{{template name refers to non-type template 'X::f'}}
+ };
+
+ Y<X, int> yxi; // expected-note{{in instantiation of template class 'PR9226::Y<PR9226::X, int>' requested here}}
+}
+
+namespace PR9449 {
+ template <typename T>
+ struct s; // expected-note{{template is declared here}}
+
+ template <typename T>
+ void f() {
+ int s<T>::template n<T>::* f; // expected-error{{implicit instantiation of undefined template 'PR9449::s<int>'}} \
+ // expected-error{{following the 'template' keyword}}
+ }
+
+ template void f<int>(); // expected-note{{in instantiation of}}
+}
diff --git a/clang/test/SemaTemplate/nested-template.cpp b/clang/test/SemaTemplate/nested-template.cpp
new file mode 100644
index 0000000..7849bae
--- /dev/null
+++ b/clang/test/SemaTemplate/nested-template.cpp
@@ -0,0 +1,157 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class A;
+
+class S {
+public:
+ template<typename T> struct A {
+ struct Nested {
+ typedef T type;
+ };
+ };
+};
+
+int i;
+S::A<int>::Nested::type *ip = &i;
+
+template<typename T>
+struct Outer {
+ template<typename U>
+ class Inner0;
+
+ template<typename U>
+ class Inner1 {
+ struct ReallyInner;
+
+ T foo(U);
+ template<typename V> T bar(V);
+ template<typename V> T* bar(V);
+
+ static T value1;
+ static U value2;
+ };
+};
+
+template<typename X>
+template<typename Y>
+class Outer<X>::Inner0 {
+public:
+ void f(X, Y);
+};
+
+template<typename X>
+template<typename Y>
+void Outer<X>::Inner0<Y>::f(X, Y) {
+}
+
+template<typename X>
+template<typename Y>
+struct Outer<X>::Inner1<Y>::ReallyInner {
+ static Y value3;
+
+ void g(X, Y);
+};
+
+template<typename X>
+template<typename Y>
+void Outer<X>::Inner1<Y>::ReallyInner::g(X, Y) {
+}
+
+template<typename X>
+template<typename Y>
+X Outer<X>::Inner1<Y>::foo(Y) {
+ return X();
+}
+
+template<typename X>
+template<typename Y>
+template<typename Z>
+X Outer<X>::Inner1<Y>::bar(Z) {
+ return X();
+}
+
+template<typename X>
+template<typename Y>
+template<typename Z>
+X* Outer<X>::Inner1<Y>::bar(Z) {
+ return 0;
+}
+
+template<typename X>
+template<typename Y>
+X Outer<X>::Inner1<Y>::value1 = 0;
+
+template<typename X>
+template<typename Y>
+Y Outer<X>::Inner1<Y>::value2 = Y();
+
+template<typename X>
+template<typename Y>
+Y Outer<X>::Inner1<Y>::ReallyInner::value3 = Y();
+
+template<typename X>
+template<typename Y>
+Y Outer<X>::Inner1<Y*>::ReallyInner::value4; // expected-error{{Outer<X>::Inner1<Y *>::ReallyInner::}}
+
+
+template<typename T>
+struct X0 { };
+
+template<typename T>
+struct X0<T*> {
+ template<typename U>
+ void f(U u = T()) { }
+};
+
+// PR5103
+template<typename>
+struct X1 {
+ template<typename, bool = false> struct B { };
+};
+template struct X1<int>::B<bool>;
+
+// Template template parameters
+template<typename T>
+struct X2 {
+ template<template<class U, T Value> class> // expected-error{{cannot have type 'float'}} \
+ // expected-note{{previous non-type template}}
+ struct Inner { };
+};
+
+template<typename T,
+ int Value> // expected-note{{template non-type parameter}}
+ struct X2_arg;
+
+X2<int>::Inner<X2_arg> x2i1;
+X2<float> x2a; // expected-note{{instantiation}}
+X2<long>::Inner<X2_arg> x2i3; // expected-error{{template template argument has different}}
+
+namespace PR10896 {
+ template<typename TN>
+ class Foo {
+
+ public:
+ void foo() {}
+ private:
+
+ template<typename T>
+ T SomeField; // expected-error {{member 'SomeField' declared as a template}}
+ };
+
+ void g() {
+ Foo<int> f;
+ f.foo();
+ }
+}
+
+namespace PR10924 {
+ template< class Topology, class ctype >
+ struct ReferenceElement
+ {
+ };
+
+ template< class Topology, class ctype >
+ template< int codim >
+ class ReferenceElement< Topology, ctype > :: BaryCenterArray // expected-error{{out-of-line definition of 'BaryCenterArray' does not match any declaration in 'ReferenceElement<Topology, ctype>'}}
+ {
+ };
+}
diff --git a/clang/test/SemaTemplate/operator-function-id-template.cpp b/clang/test/SemaTemplate/operator-function-id-template.cpp
new file mode 100644
index 0000000..9a0884e
--- /dev/null
+++ b/clang/test/SemaTemplate/operator-function-id-template.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+struct A {
+ template<typename U> A<T> operator+(U);
+};
+
+template<int Value, typename T> bool operator==(A<T>, A<T>);
+
+template<> bool operator==<0>(A<int>, A<int>);
+
+bool test_qualified_id(A<int> ai) {
+ return ::operator==<0, int>(ai, ai);
+}
+
+void test_op(A<int> a, int i) {
+ const A<int> &air = a.operator+<int>(i);
+}
+
+template<typename T>
+void test_op_template(A<T> at, T x) {
+ const A<T> &atr = at.template operator+<T>(x);
+ const A<T> &atr2 = at.A::template operator+<T>(x);
+ // FIXME: unrelated template-name instantiation issue
+ // const A<T> &atr3 = at.template A<T>::template operator+<T>(x);
+}
+
+template void test_op_template<float>(A<float>, float);
diff --git a/clang/test/SemaTemplate/operator-template.cpp b/clang/test/SemaTemplate/operator-template.cpp
new file mode 100644
index 0000000..777b0f5
--- /dev/null
+++ b/clang/test/SemaTemplate/operator-template.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Make sure we accept this
+template<class X>struct A{typedef X Y;};
+template<class X>bool operator==(A<X>,typename A<X>::Y); // expected-note{{candidate template ignored: failed template argument deduction}}
+
+int a(A<int> x) { return operator==(x,1); }
+
+int a0(A<int> x) { return x == 1; }
+
+// FIXME: the location information for the note isn't very good
+template<class X>struct B{typedef X Y;};
+template<class X>bool operator==(B<X>*,typename B<X>::Y); // \
+// expected-error{{overloaded 'operator==' must have at least one parameter of class or enumeration type}} \
+// expected-note{{in instantiation of function template specialization}} \
+// expected-note{{candidate template ignored: substitution failure [with X = int]}}
+int a(B<int> x) { return operator==(&x,1); } // expected-error{{no matching function for call to 'operator=='}}
+
diff --git a/clang/test/SemaTemplate/overload-candidates.cpp b/clang/test/SemaTemplate/overload-candidates.cpp
new file mode 100644
index 0000000..8762cc8
--- /dev/null
+++ b/clang/test/SemaTemplate/overload-candidates.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+const T& min(const T&, const T&); // expected-note{{candidate template ignored: deduced conflicting types for parameter 'T' ('int' vs. 'long')}}
+
+void test_min() {
+ (void)min(1, 2l); // expected-error{{no matching function for call to 'min'}}
+}
+
+template<typename R, typename T>
+R *dyn_cast(const T&); // expected-note{{candidate template ignored: couldn't infer template argument 'R'}}
+
+void test_dyn_cast(int* ptr) {
+ (void)dyn_cast(ptr); // expected-error{{no matching function for call to 'dyn_cast'}}
+}
+
+template<int I, typename T>
+ void get(const T&); // expected-note{{candidate template ignored: invalid explicitly-specified argument for template parameter 'I'}}
+template<template<class T> class, typename T>
+ void get(const T&); // expected-note{{candidate template ignored: invalid explicitly-specified argument for 1st template parameter}}
+
+void test_get(void *ptr) {
+ get<int>(ptr); // expected-error{{no matching function for call to 'get'}}
+}
+
+template<typename T>
+ typename T::type get_type(const T&); // expected-note{{candidate template ignored: substitution failure [with T = int *]}}
+
+void test_get_type(int *ptr) {
+ (void)get_type(ptr); // expected-error{{no matching function for call to 'get_type'}}
+}
+
+struct X {
+ template<typename T>
+ const T& min(const T&, const T&); // expected-note{{candidate template ignored: deduced conflicting types for parameter 'T' ('int' vs. 'long')}}
+};
+
+void test_X_min(X x) {
+ (void)x.min(1, 2l); // expected-error{{no matching member function for call to 'min'}}
+}
diff --git a/clang/test/SemaTemplate/overload-uneval.cpp b/clang/test/SemaTemplate/overload-uneval.cpp
new file mode 100644
index 0000000..8d8a2f4
--- /dev/null
+++ b/clang/test/SemaTemplate/overload-uneval.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused %s
+
+// Tests that overload resolution is treated as an unevaluated context.
+// PR5541
+struct Foo
+{
+ Foo *next;
+};
+
+template <typename>
+struct Bar
+{
+};
+
+
+template <typename T>
+class Wibble
+{
+ typedef Bar<T> B;
+
+ static inline B *concrete(Foo *node) {
+ int a[sizeof(T) ? -1 : -1];
+ return reinterpret_cast<B *>(node);
+ }
+
+public:
+ class It
+ {
+ Foo *i;
+
+ public:
+ inline operator B *() const { return concrete(i); }
+ inline bool operator!=(const It &o) const { return i !=
+o.i; }
+ };
+};
+
+void f() {
+ Wibble<void*>::It a, b;
+
+ a != b;
+}
diff --git a/clang/test/SemaTemplate/partial-spec-instantiate.cpp b/clang/test/SemaTemplate/partial-spec-instantiate.cpp
new file mode 100644
index 0000000..a93af50
--- /dev/null
+++ b/clang/test/SemaTemplate/partial-spec-instantiate.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+// PR4607
+template <class T> struct X {};
+
+template <> struct X<char>
+{
+ static char* g();
+};
+
+template <class T> struct X2 {};
+
+template <class U>
+struct X2<U*> {
+ static void f() {
+ X<U>::g();
+ }
+};
+
+void a(char *a, char *b) {X2<char*>::f();}
+
+namespace WonkyAccess {
+ template<typename T>
+ struct X {
+ int m;
+ };
+
+ template<typename U>
+ class Y;
+
+ template<typename U>
+ struct Y<U*> : X<U> { };
+
+ template<>
+ struct Y<float*> : X<float> { };
+
+ int f(Y<int*> y, Y<float*> y2) {
+ return y.m + y2.m;
+ }
+}
+
+// <rdar://problem/9169404>
+namespace rdar9169404 {
+ template<typename T, T N> struct X { };
+ template<bool C> struct X<bool, C> {
+ typedef int type;
+ };
+
+ X<bool, -1>::type value;
+}
diff --git a/clang/test/SemaTemplate/pragma-ms_struct.cpp b/clang/test/SemaTemplate/pragma-ms_struct.cpp
new file mode 100644
index 0000000..f04dc5c
--- /dev/null
+++ b/clang/test/SemaTemplate/pragma-ms_struct.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-apple-osx10.7.0 %s
+
+#pragma ms_struct on
+
+// <rdar://problem/10791194>
+template<int x> struct foo {
+ long long a;
+ int b;
+};
+extern int arr[sizeof(foo<0>) == 16 ? 1 : -1];
diff --git a/clang/test/SemaTemplate/qualified-id.cpp b/clang/test/SemaTemplate/qualified-id.cpp
new file mode 100644
index 0000000..64dff1c
--- /dev/null
+++ b/clang/test/SemaTemplate/qualified-id.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR5061
+namespace a {
+ template <typename T> class C {};
+}
+namespace b {
+ template<typename T> void f0(a::C<T> &a0) { }
+}
+
+
+namespace test1 {
+ int a = 0;
+ template <class T> class Base { };
+ template <class T> class Derived : public Base<T> {
+ int foo() {
+ return test1::a;
+ }
+ };
+}
+
+namespace test2 {
+ class Impl {
+ public:
+ int foo();
+ };
+ template <class T> class Magic : public Impl {
+ int foo() {
+ return Impl::foo();
+ }
+ };
+}
+
+namespace PR6063 {
+ template <typename T> void f(T, T);
+
+ namespace detail
+ {
+ using PR6063::f;
+ }
+
+ template <typename T>
+ void g(T a, T b)
+ {
+ detail::f(a, b);
+ }
+}
+
+namespace PR12291 {
+ template <typename T>
+ class Outer2 {
+ template <typename V>
+ template <typename W>
+ class Outer2<V>::Inner; // expected-error{{nested name specifier 'Outer2<V>::' for declaration does not refer into a class, class template or class template partial specialization}}
+ };
+}
diff --git a/clang/test/SemaTemplate/qualified-names-diag.cpp b/clang/test/SemaTemplate/qualified-names-diag.cpp
new file mode 100644
index 0000000..b2df47b
--- /dev/null
+++ b/clang/test/SemaTemplate/qualified-names-diag.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace std {
+ template<typename T> class vector { }; // expected-note{{candidate}}
+}
+
+typedef int INT;
+typedef float Real;
+
+void test() {
+ using namespace std;
+
+ std::vector<INT> v1;
+ vector<Real> v2;
+ v1 = v2; // expected-error{{no viable overloaded '='}}
+}
diff --git a/clang/test/SemaTemplate/rdar9173693.cpp b/clang/test/SemaTemplate/rdar9173693.cpp
new file mode 100644
index 0000000..86b4954
--- /dev/null
+++ b/clang/test/SemaTemplate/rdar9173693.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/9173693>
+template< bool C > struct assert { };
+template< bool > struct assert_arg_pred_impl { }; // expected-note 3 {{declared here}}
+template< typename Pred > assert<false> assert_not_arg( void (*)(Pred), typename assert_arg_pred<Pred>::type ); // expected-error 5 {{}}
diff --git a/clang/test/SemaTemplate/recovery-crash.cpp b/clang/test/SemaTemplate/recovery-crash.cpp
new file mode 100644
index 0000000..0ed3258
--- /dev/null
+++ b/clang/test/SemaTemplate/recovery-crash.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// We don't expect a fix-it to be applied in this case. Clang used to crash
+// trying to recover while adding 'this->' before Work(x);
+
+template <typename> struct A {
+ static void Work(int); // expected-note{{must qualify identifier}}
+};
+
+template <typename T> struct B : public A<T> {
+ template <typename T2> B(T2 x) {
+ Work(x); // expected-error{{use of undeclared identifier}}
+ }
+};
+
+void Test() {
+ B<int> b(0); // expected-note{{in instantiation of function template}}
+}
+
diff --git a/clang/test/SemaTemplate/recursive-template-instantiation.cpp b/clang/test/SemaTemplate/recursive-template-instantiation.cpp
new file mode 100644
index 0000000..d6a0b24
--- /dev/null
+++ b/clang/test/SemaTemplate/recursive-template-instantiation.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> void f(T* t) { // expected-note{{failed template argument deduction}}
+ f(*t); // expected-error{{no matching function}}\
+ // expected-note 3{{requested here}}
+}
+
+void test_f(int ****p) {
+ f(p); // expected-note{{requested here}}
+}
diff --git a/clang/test/SemaTemplate/resolve-single-template-id.cpp b/clang/test/SemaTemplate/resolve-single-template-id.cpp
new file mode 100644
index 0000000..0c9bacc
--- /dev/null
+++ b/clang/test/SemaTemplate/resolve-single-template-id.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+namespace std {
+ class type_info {};
+}
+
+void one() { }
+void two() { } // expected-note 4{{possible target for call}}
+void two(int) { } // expected-note 4{{possible target for call}}
+
+template<class T> void twoT() { } // expected-note 5{{possible target for call}}
+template<class T> void twoT(int) { } // expected-note 5{{possible target for call}}
+
+template<class T> void oneT() { }
+template<class T, class U> void oneT(U) { }
+/*
+The target can be
+ an object or reference being initialized (8.5, 8.5.3),
+ the left side of an assignment (5.17),
+ a parameter of a function (5.2.2),
+ a parameter of a user-defined operator (13.5),
+ the return value of a function, operator function, or conversion (6.6.3),
+ an explicit type conversion (5.2.3, 5.2.9, 5.4), or
+ a non-type template-parameter (14.3.2)
+*/
+//#include <typeinfo>
+template<void (*p)(int)> struct test { };
+
+int main()
+{
+ one; // expected-warning {{expression result unused}}
+ two; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
+ oneT<int>; // expected-warning {{expression result unused}}
+ twoT<int>; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
+ typeid(oneT<int>); // expected-warning{{expression result unused}}
+ sizeof(oneT<int>); // expected-warning {{expression result unused}}
+ sizeof(twoT<int>); //expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
+ decltype(oneT<int>)* fun = 0;
+
+ *one; // expected-warning {{expression result unused}}
+ *oneT<int>; // expected-warning {{expression result unused}}
+ *two; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error {{indirection requires pointer operand}}
+ *twoT<int>; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
+ !oneT<int>; // expected-warning {{expression result unused}} expected-warning {{address of function 'oneT<int>' will always evaluate to 'true'}} expected-note {{prefix with the address-of operator to silence this warning}}
+ +oneT<int>; // expected-warning {{expression result unused}}
+ -oneT<int>; //expected-error {{invalid argument type}}
+ oneT<int> == 0; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+ 0 == oneT<int>; // expected-warning {{equality comparison result unused}}
+ 0 != oneT<int>; // expected-warning {{inequality comparison result unused}}
+ (false ? one : oneT<int>); // expected-warning {{expression result unused}}
+ void (*p1)(int); p1 = oneT<int>;
+
+ int i = (int) (false ? (void (*)(int))twoT<int> : oneT<int>); //expected-error {{incompatible operand}}
+ (twoT<int>) == oneT<int>; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} {{cannot resolve overloaded function 'twoT' from context}}
+ bool b = oneT<int>; // expected-warning {{address of function 'oneT<int>' will always evaluate to 'true'}} expected-note {{prefix with the address-of operator to silence this warning}}
+ void (*p)() = oneT<int>;
+ test<oneT<int> > ti;
+ void (*u)(int) = oneT<int>;
+
+ b = (void (*)()) twoT<int>;
+
+ one < one; //expected-warning {{self-comparison always evaluates to false}} \
+ //expected-warning {{expression result unused}}
+
+ oneT<int> < oneT<int>; //expected-warning {{self-comparison always evaluates to false}} \
+ //expected-warning {{expression result unused}}
+
+ two < two; //expected-error 2 {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error {{invalid operands to binary expression ('void' and 'void')}}
+ twoT<int> < twoT<int>; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} {{cannot resolve overloaded function 'twoT' from context}}
+ oneT<int> == 0; // expected-warning {{equality comparison result unused}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}}
+
+}
+
+struct rdar9108698 {
+ template<typename> void f();
+};
+
+void test_rdar9108698(rdar9108698 x) {
+ x.f<int>; // expected-error{{reference to non-static member function must be called}}
+}
diff --git a/clang/test/SemaTemplate/self-comparison.cpp b/clang/test/SemaTemplate/self-comparison.cpp
new file mode 100644
index 0000000..50ab660
--- /dev/null
+++ b/clang/test/SemaTemplate/self-comparison.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template <int A, int B> void foo() {
+ (void)(A == A); // expected-warning {{self-comparison always evaluates to true}}
+ (void)(A == B);
+}
+template <int A, int B> struct S1 {
+ void foo() {
+ (void)(A == A); // expected-warning {{self-comparison always evaluates to true}}
+ (void)(A == B);
+ }
+};
+
+template <int A, int B> struct S2 {
+ template <typename T> T foo() {
+ (void)(A == A); // expected-warning {{self-comparison always evaluates to true}}
+ (void)(A == B);
+ }
+};
+
+struct S3 {
+ template <int A, int B> void foo() {
+ (void)(A == A); // expected-warning {{self-comparison always evaluates to true}}
+ (void)(A == B);
+ }
+};
+
+template <int A> struct S4 {
+ template <int B> void foo() {
+ (void)(A == A); // expected-warning {{self-comparison always evaluates to true}}
+ (void)(A == B);
+ }
+};
+
+const int N = 42;
+template <int X> void foo2() {
+ (void)(X == N);
+ (void)(N == X);
+}
+
+void test() {
+ foo<1, 1>();
+ S1<1, 1> s1; s1.foo();
+ S2<1, 1> s2; s2.foo<void>();
+ S3 s3; s3.foo<1, 1>();
+ S4<1> s4; s4.foo<1>();
+ foo2<N>();
+}
diff --git a/clang/test/SemaTemplate/temp.cpp b/clang/test/SemaTemplate/temp.cpp
new file mode 100644
index 0000000..e037f0f
--- /dev/null
+++ b/clang/test/SemaTemplate/temp.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+
+namespace test0 {
+ // p3
+ template<typename T> int foo(T), bar(T, T); // expected-error{{single entity}}
+}
+
+// PR7252
+namespace test1 {
+ namespace A { template<typename T> struct Base { typedef T t; }; } // expected-note {{member found}}
+ namespace B { template<typename T> struct Base { typedef T t; }; } // expected-note {{member found}}
+
+ template<typename T> struct Derived : A::Base<char>, B::Base<int> {
+ // FIXME: the syntax error here is unfortunate
+ typename Derived::Base<float>::t x; // expected-error {{found in multiple base classes of different types}} \
+ // expected-error {{expected member name or ';'}}
+ };
+}
diff --git a/clang/test/SemaTemplate/temp_arg.cpp b/clang/test/SemaTemplate/temp_arg.cpp
new file mode 100644
index 0000000..5a4c8fc
--- /dev/null
+++ b/clang/test/SemaTemplate/temp_arg.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T,
+ int I,
+ template<typename> class TT>
+ class A; // expected-note 3 {{template is declared here}}
+
+template<typename> class X;
+
+A<int, 0, X> * a1;
+
+A<float, 1, X, double> *a2; // expected-error{{too many template arguments for class template 'A'}}
+A<float, 1> *a3; // expected-error{{too few template arguments for class template 'A'}}
+A a3; // expected-error{{use of class template A requires template arguments}}
+
+namespace test0 {
+ template <class t> class foo {};
+ template <class t> class bar {
+ bar(::test0::foo<tee> *ptr) {} // FIXME(redundant): expected-error 2 {{use of undeclared identifier 'tee'}}
+ };
+}
diff --git a/clang/test/SemaTemplate/temp_arg_nontype.cpp b/clang/test/SemaTemplate/temp_arg_nontype.cpp
new file mode 100644
index 0000000..747ddcc
--- /dev/null
+++ b/clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -0,0 +1,325 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wconversion -verify %s
+template<int N> struct A; // expected-note 5{{template parameter is declared here}}
+
+A<0> *a0;
+
+A<int()> *a1; // expected-error{{template argument for non-type template parameter is treated as type 'int ()'}}
+
+A<int> *a2; // expected-error{{template argument for non-type template parameter must be an expression}}
+
+A<1 >> 2> *a3; // expected-warning{{use of right-shift operator ('>>') in template argument will require parentheses in C++11}}
+
+// C++ [temp.arg.nontype]p5:
+A<A> *a4; // expected-error{{must be an expression}}
+
+enum E { Enumerator = 17 };
+A<E> *a5; // expected-error{{template argument for non-type template parameter must be an expression}}
+template<E Value> struct A1; // expected-note{{template parameter is declared here}}
+A1<Enumerator> *a6; // okay
+A1<17> *a7; // expected-error{{non-type template argument of type 'int' cannot be converted to a value of type 'E'}}
+
+const long LongValue = 12345678;
+A<LongValue> *a8;
+const short ShortValue = 17;
+A<ShortValue> *a9;
+
+int f(int);
+A<f(17)> *a10; // expected-error{{non-type template argument of type 'int' is not an integral constant expression}}
+
+class X {
+public:
+ X();
+ X(int, int);
+ operator int() const;
+};
+A<X(17, 42)> *a11; // expected-error{{non-type template argument of type 'X' must have an integral or enumeration type}}
+
+float f(float);
+
+float g(float); // expected-note 2{{candidate function}}
+double g(double); // expected-note 2{{candidate function}}
+
+int h(int);
+float h2(float);
+
+template<int fp(int)> struct A3; // expected-note 1{{template parameter is declared here}}
+A3<h> *a14_1;
+A3<&h> *a14_2;
+A3<f> *a14_3;
+A3<&f> *a14_4;
+A3<h2> *a14_6; // expected-error{{non-type template argument of type 'float (float)' cannot be converted to a value of type 'int (*)(int)'}}
+A3<g> *a14_7; // expected-error{{address of overloaded function 'g' does not match required type 'int (int)'}}
+
+
+struct Y { } y;
+
+volatile X * X_volatile_ptr;
+template<X const &AnX> struct A4; // expected-note 2{{template parameter is declared here}}
+X an_X;
+A4<an_X> *a15_1; // okay
+A4<*X_volatile_ptr> *a15_2; // expected-error{{non-type template argument does not refer to any declaration}}
+A4<y> *15_3; // expected-error{{non-type template parameter of reference type 'const X &' cannot bind to template argument of type 'struct Y'}} \
+ // FIXME: expected-error{{expected unqualified-id}}
+
+template<int (&fr)(int)> struct A5; // expected-note{{template parameter is declared here}}
+A5<h> *a16_1;
+A5<f> *a16_3;
+A5<h2> *a16_6; // expected-error{{non-type template parameter of reference type 'int (&)(int)' cannot bind to template argument of type 'float (float)'}}
+A5<g> *a14_7; // expected-error{{address of overloaded function 'g' does not match required type 'int (int)'}}
+
+struct Z {
+ int foo(int);
+ float bar(float);
+ int bar(int);
+ double baz(double);
+
+ int int_member;
+ float float_member;
+};
+template<int (Z::*pmf)(int)> struct A6; // expected-note{{template parameter is declared here}}
+A6<&Z::foo> *a17_1;
+A6<&Z::bar> *a17_2;
+A6<&Z::baz> *a17_3; // expected-error{{non-type template argument of type 'double (Z::*)(double)' cannot be converted to a value of type 'int (Z::*)(int)'}}
+
+
+template<int Z::*pm> struct A7; // expected-note{{template parameter is declared here}}
+template<int Z::*pm> struct A7c;
+A7<&Z::int_member> *a18_1;
+A7c<&Z::int_member> *a18_2;
+A7<&Z::float_member> *a18_3; // expected-error{{non-type template argument of type 'float Z::*' cannot be converted to a value of type 'int Z::*'}}
+A7c<(&Z::int_member)> *a18_4; // expected-warning{{address non-type template argument cannot be surrounded by parentheses}}
+
+template<unsigned char C> struct Overflow; // expected-note{{template parameter is declared here}}
+
+Overflow<5> *overflow1; // okay
+Overflow<255> *overflow2; // okay
+Overflow<256> *overflow3; // expected-warning{{non-type template argument value '256' truncated to '0' for template parameter of type 'unsigned char'}}
+
+
+template<unsigned> struct Signedness; // expected-note{{template parameter is declared here}}
+Signedness<10> *signedness1; // okay
+Signedness<-10> *signedness2; // expected-warning{{non-type template argument with value '-10' converted to '4294967286' for unsigned template parameter of type 'unsigned int'}}
+
+template<signed char C> struct SignedOverflow; // expected-note 3 {{template parameter is declared here}}
+SignedOverflow<1> *signedoverflow1;
+SignedOverflow<-1> *signedoverflow2;
+SignedOverflow<-128> *signedoverflow3;
+SignedOverflow<-129> *signedoverflow4; // expected-warning{{non-type template argument value '-129' truncated to '127' for template parameter of type 'signed char'}}
+SignedOverflow<127> *signedoverflow5;
+SignedOverflow<128> *signedoverflow6; // expected-warning{{non-type template argument value '128' truncated to '-128' for template parameter of type 'signed char'}}
+SignedOverflow<(unsigned char)128> *signedoverflow7; // expected-warning{{non-type template argument value '128' truncated to '-128' for template parameter of type 'signed char'}}
+
+// Check canonicalization of template arguments.
+template<int (*)(int, int)> struct FuncPtr0;
+int func0(int, int);
+extern FuncPtr0<&func0> *fp0;
+template<int (*)(int, int)> struct FuncPtr0;
+extern FuncPtr0<&func0> *fp0;
+int func0(int, int);
+extern FuncPtr0<&func0> *fp0;
+
+// PR5350
+namespace ns {
+ template <typename T>
+ struct Foo {
+ static const bool value = true;
+ };
+
+ template <bool b>
+ struct Bar {};
+
+ const bool value = false;
+
+ Bar<bool(ns::Foo<int>::value)> x;
+}
+
+// PR5349
+namespace ns {
+ enum E { k };
+
+ template <E e>
+ struct Baz {};
+
+ Baz<k> f1; // This works.
+ Baz<E(0)> f2; // This too.
+ Baz<static_cast<E>(0)> f3; // And this.
+
+ Baz<ns::E(0)> b1; // This doesn't work.
+ Baz<static_cast<ns::E>(0)> b2; // This neither.
+}
+
+// PR5597
+template<int (*)(float)> struct X0 { };
+
+struct X1 {
+ static int pfunc(float);
+};
+void test_X0_X1() {
+ X0<X1::pfunc> x01;
+}
+
+// PR6249
+namespace pr6249 {
+ template<typename T, T (*func)()> T f() {
+ return func();
+ }
+
+ int h();
+ template int f<int, h>();
+}
+
+namespace PR6723 {
+ template<unsigned char C> void f(int (&a)[C]); // expected-note {{candidate template ignored}} \
+ // expected-note{{substitution failure [with C = '\x00']}}
+ void g() {
+ int arr512[512];
+ f(arr512); // expected-error{{no matching function for call}}
+ f<512>(arr512); // expected-error{{no matching function for call}}
+ }
+}
+
+// Check that we instantiate declarations whose addresses are taken
+// for non-type template arguments.
+namespace EntityReferenced {
+ template<typename T, void (*)(T)> struct X { };
+
+ template<typename T>
+ struct Y {
+ static void f(T x) {
+ x = 1; // expected-error{{assigning to 'int *' from incompatible type 'int'}}
+ }
+ };
+
+ void g() {
+ typedef X<int*, Y<int*>::f> x; // expected-note{{in instantiation of}}
+ }
+}
+
+namespace PR6964 {
+ template <typename ,int, int = 9223372036854775807L > // expected-warning 2{{non-type template argument value '9223372036854775807' truncated to '-1' for template parameter of type 'int'}} \
+ // expected-note 2{{template parameter is declared here}}
+ struct as_nview { };
+
+ template <typename Sequence, int I0>
+ struct as_nview<Sequence, I0> // expected-note{{while checking a default template argument used here}}
+ { };
+}
+
+// rdar://problem/8302138
+namespace test8 {
+ template <int* ip> struct A {
+ int* p;
+ A() : p(ip) {}
+ };
+
+ void test0() {
+ extern int i00;
+ A<&i00> a00;
+ }
+
+ extern int i01;
+ void test1() {
+ A<&i01> a01;
+ }
+
+
+ struct C {
+ int x;
+ char y;
+ double z;
+ };
+
+ template <C* cp> struct B {
+ C* p;
+ B() : p(cp) {}
+ };
+
+ void test2() {
+ extern C c02;
+ B<&c02> b02;
+ }
+
+ extern C c03;
+ void test3() {
+ B<&c03> b03;
+ }
+}
+
+namespace PR8372 {
+ template <int I> void foo() { } // expected-note{{template parameter is declared here}}
+ void bar() { foo <0x80000000> (); } // expected-warning{{non-type template argument value '2147483648' truncated to '-2147483648' for template parameter of type 'int'}}
+}
+
+namespace PR9227 {
+ template <bool B> struct enable_if_bool { };
+ template <> struct enable_if_bool<true> { typedef int type; };
+ void test_bool() { enable_if_bool<false>::type i; } // expected-error{{enable_if_bool<false>}}
+
+ template <char C> struct enable_if_char { };
+ template <> struct enable_if_char<'a'> { typedef int type; };
+ void test_char_0() { enable_if_char<0>::type i; } // expected-error{{enable_if_char<'\x00'>}}
+ void test_char_b() { enable_if_char<'b'>::type i; } // expected-error{{enable_if_char<'b'>}}
+ void test_char_possibly_negative() { enable_if_char<'\x02'>::type i; } // expected-error{{enable_if_char<'\x02'>}}
+ void test_char_single_quote() { enable_if_char<'\''>::type i; } // expected-error{{enable_if_char<'\''>}}
+ void test_char_backslash() { enable_if_char<'\\'>::type i; } // expected-error{{enable_if_char<'\\'>}}
+}
+
+namespace PR10579 {
+ namespace fcppt
+ {
+ namespace container
+ {
+ namespace bitfield
+ {
+
+ template<
+ typename Enum,
+ Enum Size
+ >
+ class basic;
+
+ template<
+ typename Enum,
+ Enum Size
+ >
+ class basic
+ {
+ public:
+ basic()
+ {
+ }
+ };
+
+ }
+ }
+ }
+
+ namespace
+ {
+
+ namespace testenum
+ {
+ enum type
+ {
+ foo,
+ bar,
+ size
+ };
+ }
+
+ }
+
+ int main()
+ {
+ typedef fcppt::container::bitfield::basic<
+ testenum::type,
+ testenum::size
+ > bitfield_foo;
+
+ bitfield_foo obj;
+ }
+
+}
+
+template <int& I> struct PR10766 { static int *ip; };
+template <int& I> int* PR10766<I>::ip = &I;
diff --git a/clang/test/SemaTemplate/temp_arg_template.cpp b/clang/test/SemaTemplate/temp_arg_template.cpp
new file mode 100644
index 0000000..c9ce1b6
--- /dev/null
+++ b/clang/test/SemaTemplate/temp_arg_template.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<template<typename T> class X> struct A; // expected-note 2{{previous template template parameter is here}}
+
+template<template<typename T, int I> class X> struct B; // expected-note{{previous template template parameter is here}}
+
+template<template<int I> class X> struct C; // expected-note{{previous non-type template parameter with type 'int' is here}}
+
+template<class> struct X; // expected-note{{too few template parameters in template template argument}}
+template<int N> struct Y; // expected-note{{template parameter has a different kind in template argument}}
+template<long N> struct Ylong; // expected-note{{template non-type parameter has a different type 'long' in template argument}}
+
+namespace N {
+ template<class> struct Z;
+}
+template<class, class> struct TooMany; // expected-note{{too many template parameters in template template argument}}
+
+
+A<X> *a1;
+A<N::Z> *a2;
+A< ::N::Z> *a3;
+
+A<Y> *a4; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
+A<TooMany> *a5; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
+B<X> *a6; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
+C<Y> *a7;
+C<Ylong> *a8; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
+
+template<typename T> void f(int);
+
+A<f> *a9; // expected-error{{must be a class template}}
+
+// Evil digraph '<:' is parsed as '[', expect error.
+A<::N::Z> *a10; // expected-error{{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}}
+
+// Do not do a digraph correction here.
+A<: :N::Z> *a11; // expected-error{{expected expression}} \
+ expected-error{{C++ requires a type specifier for all declarations}}
+
+// PR7807
+namespace N {
+ template <typename, typename = int>
+ struct X
+ { };
+
+ template <typename ,int>
+ struct Y
+ { X<int> const_ref(); };
+
+ template <template<typename,int> class TT, typename T, int N>
+ int operator<<(int, TT<T, N> a) { // expected-note{{candidate template ignored}}
+ 0 << a.const_ref(); // expected-error{{invalid operands to binary expression ('int' and 'X<int>')}}
+ }
+
+ void f0( Y<int,1> y){ 1 << y; } // expected-note{{in instantiation of function template specialization 'N::operator<<<Y, int, 1>' requested here}}
+}
+
+// PR12179
+template <typename Primitive, template <Primitive...> class F> // expected-warning {{variadic templates are a C++11 extension}}
+struct unbox_args {
+ typedef typename Primitive::template call<F> x;
+};
diff --git a/clang/test/SemaTemplate/temp_arg_type.cpp b/clang/test/SemaTemplate/temp_arg_type.cpp
new file mode 100644
index 0000000..3970942
--- /dev/null
+++ b/clang/test/SemaTemplate/temp_arg_type.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T> class A; // expected-note 2 {{template parameter is declared here}} expected-note{{template is declared here}}
+
+// [temp.arg.type]p1
+A<0> *a1; // expected-error{{template argument for template type parameter must be a type}}
+
+A<A> *a2; // expected-error{{use of class template A requires template arguments}}
+
+A<int> *a3;
+A<int()> *a4;
+A<int(float)> *a5;
+A<A<int> > *a6;
+
+// Pass an overloaded function template:
+template<typename T> void function_tpl(T);
+A<function_tpl> a7; // expected-error{{template argument for template type parameter must be a type}}
+
+// Pass a qualified name:
+namespace ns {
+template<typename T> class B {}; // expected-note{{template is declared here}}
+}
+A<ns::B> a8; // expected-error{{use of class template ns::B requires template arguments}}
+
+// [temp.arg.type]p2
+void f() {
+ class X { };
+ A<X> * a = 0; // expected-warning{{template argument uses local type 'X'}}
+}
+
+struct { int x; } Unnamed; // expected-note{{unnamed type used in template argument was declared here}}
+A<__typeof__(Unnamed)> *a9; // expected-warning{{template argument uses unnamed type}}
+
+template<typename T, unsigned N>
+struct Array {
+ typedef struct { T x[N]; } type;
+};
+
+template<typename T> struct A1 { };
+A1<Array<int, 17>::type> ax;
+
+// FIXME: [temp.arg.type]p3. The check doesn't really belong here (it
+// belongs somewhere in the template instantiation section).
diff --git a/clang/test/SemaTemplate/temp_class_order.cpp b/clang/test/SemaTemplate/temp_class_order.cpp
new file mode 100644
index 0000000..fcf0325
--- /dev/null
+++ b/clang/test/SemaTemplate/temp_class_order.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T, typename U>
+struct X1 {
+ static const int value = 0;
+};
+
+template<typename T, typename U>
+struct X1<T*, U*> {
+ static const int value = 1;
+};
+
+template<typename T>
+struct X1<T*, T*> {
+ static const int value = 2;
+};
+
+template<typename T>
+struct X1<const T*, const T*> {
+ static const int value = 3;
+};
+
+int array0[X1<int, int>::value == 0? 1 : -1];
+int array1[X1<int*, float*>::value == 1? 1 : -1];
+int array2[X1<int*, int*>::value == 2? 1 : -1];
+typedef const int* CIP;
+int array3[X1<const int*, CIP>::value == 3? 1 : -1];
+
+template<typename T, typename U>
+struct X2 { };
+
+template<typename T, typename U>
+struct X2<T*, U> { }; // expected-note{{matches}}
+
+template<typename T, typename U>
+struct X2<T, U*> { }; // expected-note{{matches}}
+
+template<typename T, typename U>
+struct X2<const T*, const U*> { };
+
+X2<int*, int*> x2a; // expected-error{{ambiguous}}
+X2<const int*, const int*> x2b;
diff --git a/clang/test/SemaTemplate/temp_class_spec.cpp b/clang/test/SemaTemplate/temp_class_spec.cpp
new file mode 100644
index 0000000..8a07fd7
--- /dev/null
+++ b/clang/test/SemaTemplate/temp_class_spec.cpp
@@ -0,0 +1,363 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T>
+struct is_pointer {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_pointer<T*> {
+ static const bool value = true;
+};
+
+template<typename T>
+struct is_pointer<const T*> {
+ static const bool value = true;
+};
+
+int array0[is_pointer<int>::value? -1 : 1];
+int array1[is_pointer<int*>::value? 1 : -1];
+int array2[is_pointer<const int*>::value? 1 : -1];
+
+template<typename T>
+struct is_lvalue_reference {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_lvalue_reference<T&> {
+ static const bool value = true;
+};
+
+int lvalue_ref0[is_lvalue_reference<int>::value? -1 : 1];
+int lvalue_ref1[is_lvalue_reference<const int&>::value? 1 : -1];
+
+template<typename T>
+struct is_const {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_const<const T> {
+ static const bool value = true;
+};
+
+int is_const0[is_const<int>::value? -1 : 1];
+int is_const1[is_const<const int>::value? 1 : -1];
+int is_const2[is_const<const volatile int>::value? 1 : -1];
+int is_const3[is_const<const int [3]>::value? 1 : -1];
+int is_const4[is_const<const volatile int[3]>::value? 1 : -1];
+int is_const5[is_const<volatile int[3]>::value? -1 : 1];
+
+template<typename T>
+struct is_volatile {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_volatile<volatile T> {
+ static const bool value = true;
+};
+
+int is_volatile0[is_volatile<int>::value? -1 : 1];
+int is_volatile1[is_volatile<volatile int>::value? 1 : -1];
+int is_volatile2[is_volatile<const volatile int>::value? 1 : -1];
+int is_volatile3[is_volatile<volatile char[3]>::value? 1 : -1];
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+typedef int INT;
+typedef INT* int_ptr;
+
+int is_same0[is_same<int, int>::value? 1 : -1];
+int is_same1[is_same<int, INT>::value? 1 : -1];
+int is_same2[is_same<const int, int>::value? -1 : 1];
+int is_same3[is_same<int_ptr, int>::value? -1 : 1];
+
+template<typename T>
+struct remove_reference {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_reference<T&> {
+ typedef T type;
+};
+
+int remove_ref0[is_same<remove_reference<int>::type, int>::value? 1 : -1];
+int remove_ref1[is_same<remove_reference<int&>::type, int>::value? 1 : -1];
+
+template<typename T>
+struct remove_const {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_const<const T> {
+ typedef T type;
+};
+
+int remove_const0[is_same<remove_const<const int>::type, int>::value? 1 : -1];
+int remove_const1[is_same<remove_const<const int[3]>::type, int[3]>::value? 1 : -1];
+
+template<typename T>
+struct is_incomplete_array {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_incomplete_array<T[]> {
+ static const bool value = true;
+};
+
+int incomplete_array0[is_incomplete_array<int>::value ? -1 : 1];
+int incomplete_array1[is_incomplete_array<int[1]>::value ? -1 : 1];
+int incomplete_array2[is_incomplete_array<bool[]>::value ? 1 : -1];
+int incomplete_array3[is_incomplete_array<int[]>::value ? 1 : -1];
+
+template<typename T>
+struct is_array_with_4_elements {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_array_with_4_elements<T[4]> {
+ static const bool value = true;
+};
+
+int array_with_4_elements0[is_array_with_4_elements<int[]>::value ? -1 : 1];
+int array_with_4_elements1[is_array_with_4_elements<int[1]>::value ? -1 : 1];
+int array_with_4_elements2[is_array_with_4_elements<int[4]>::value ? 1 : -1];
+int array_with_4_elements3[is_array_with_4_elements<int[4][2]>::value ? 1 : -1];
+
+template<typename T>
+struct get_array_size;
+
+template<typename T, unsigned N>
+struct get_array_size<T[N]> {
+ static const unsigned value = N;
+};
+
+int array_size0[get_array_size<int[12]>::value == 12? 1 : -1];
+
+template<typename T>
+struct remove_extent {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_extent<T[]> {
+ typedef T type;
+};
+
+template<typename T, unsigned N>
+struct remove_extent<T[N]> {
+ typedef T type;
+};
+
+int remove_extent0[is_same<remove_extent<int[][5]>::type, int[5]>::value? 1 : -1];
+int remove_extent1[is_same<remove_extent<const int[][5]>::type, const int[5]>::value? 1 : -1];
+
+template<typename T>
+struct is_unary_function {
+ static const bool value = false;
+};
+
+template<typename T, typename U>
+struct is_unary_function<T (*)(U)> {
+ static const bool value = true;
+};
+
+int is_unary_function0[is_unary_function<int>::value ? -1 : 1];
+int is_unary_function1[is_unary_function<int (*)()>::value ? -1 : 1];
+int is_unary_function2[is_unary_function<int (*)(int, bool)>::value ? -1 : 1];
+int is_unary_function3[is_unary_function<int (*)(bool)>::value ? 1 : -1];
+int is_unary_function4[is_unary_function<int (*)(int)>::value ? 1 : -1];
+
+template<typename T>
+struct is_unary_function_with_same_return_type_as_argument_type {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_unary_function_with_same_return_type_as_argument_type<T (*)(T)> {
+ static const bool value = true;
+};
+
+int is_unary_function5[is_unary_function_with_same_return_type_as_argument_type<int>::value ? -1 : 1];
+int is_unary_function6[is_unary_function_with_same_return_type_as_argument_type<int (*)()>::value ? -1 : 1];
+int is_unary_function7[is_unary_function_with_same_return_type_as_argument_type<int (*)(int, bool)>::value ? -1 : 1];
+int is_unary_function8[is_unary_function_with_same_return_type_as_argument_type<int (*)(bool)>::value ? -1 : 1];
+int is_unary_function9[is_unary_function_with_same_return_type_as_argument_type<int (*)(int)>::value ? 1 : -1];
+int is_unary_function10[is_unary_function_with_same_return_type_as_argument_type<int (*)(int, ...)>::value ? -1 : 1];
+int is_unary_function11[is_unary_function_with_same_return_type_as_argument_type<int (* const)(int)>::value ? -1 : 1];
+
+template<typename T>
+struct is_binary_function {
+ static const bool value = false;
+};
+
+template<typename R, typename T1, typename T2>
+struct is_binary_function<R(T1, T2)> {
+ static const bool value = true;
+};
+
+int is_binary_function0[is_binary_function<int(float, double)>::value? 1 : -1];
+
+template<typename T>
+struct is_member_pointer {
+ static const bool value = false;
+};
+
+template<typename T, typename Class>
+struct is_member_pointer<T Class::*> {
+ static const bool value = true;
+};
+
+struct X { };
+
+int is_member_pointer0[is_member_pointer<int X::*>::value? 1 : -1];
+int is_member_pointer1[is_member_pointer<const int X::*>::value? 1 : -1];
+int is_member_pointer2[is_member_pointer<int (X::*)()>::value? 1 : -1];
+int is_member_pointer3[is_member_pointer<int (X::*)(int) const>::value? 1 : -1];
+int is_member_pointer4[is_member_pointer<int (X::**)(int) const>::value? -1 : 1];
+int is_member_pointer5[is_member_pointer<int>::value? -1 : 1];
+
+template<typename T>
+struct is_member_function_pointer {
+ static const bool value = false;
+};
+
+template<typename T, typename Class>
+struct is_member_function_pointer<T (Class::*)()> {
+ static const bool value = true;
+};
+
+template<typename T, typename Class>
+struct is_member_function_pointer<T (Class::*)() const> {
+ static const bool value = true;
+};
+
+template<typename T, typename Class>
+struct is_member_function_pointer<T (Class::*)() volatile> {
+ static const bool value = true;
+};
+
+template<typename T, typename Class>
+struct is_member_function_pointer<T (Class::*)() const volatile> {
+ static const bool value = true;
+};
+
+template<typename T, typename Class, typename A1>
+struct is_member_function_pointer<T (Class::*)(A1)> {
+ static const bool value = true;
+};
+
+template<typename T, typename Class, typename A1>
+struct is_member_function_pointer<T (Class::*)(A1) const> {
+ static const bool value = true;
+};
+
+template<typename T, typename Class, typename A1>
+struct is_member_function_pointer<T (Class::*)(A1) volatile> {
+ static const bool value = true;
+};
+
+template<typename T, typename Class, typename A1>
+struct is_member_function_pointer<T (Class::*)(A1) const volatile> {
+ static const bool value = true;
+};
+
+int is_member_function_pointer0[
+ is_member_function_pointer<int X::*>::value? -1 : 1];
+int is_member_function_pointer1[
+ is_member_function_pointer<int (X::*)()>::value? 1 : -1];
+int is_member_function_pointer2[
+ is_member_function_pointer<X (X::*)(X&)>::value? 1 : -1];
+int is_member_function_pointer3[
+ is_member_function_pointer<int (X::*)() const>::value? 1 : -1];
+int is_member_function_pointer4[
+ is_member_function_pointer<int (X::*)(float) const>::value? 1 : -1];
+
+// Test substitution of non-dependent arguments back into the template
+// argument list of the class template partial specialization.
+template<typename T, typename ValueType = T>
+struct is_nested_value_type_identity {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_nested_value_type_identity<T, typename T::value_type> {
+ static const bool value = true;
+};
+
+template<typename T>
+struct HasValueType {
+ typedef T value_type;
+};
+
+struct HasIdentityValueType {
+ typedef HasIdentityValueType value_type;
+};
+
+struct NoValueType { };
+
+int is_nested_value_type_identity0[
+ is_nested_value_type_identity<HasValueType<int> >::value? -1 : 1];
+int is_nested_value_type_identity1[
+ is_nested_value_type_identity<HasIdentityValueType>::value? 1 : -1];
+int is_nested_value_type_identity2[
+ is_nested_value_type_identity<NoValueType>::value? -1 : 1];
+
+
+// C++ [temp.class.spec]p4:
+template<class T1, class T2, int I> class A { }; //#1
+template<class T, int I> class A<T, T*, I> { }; //#2
+template<class T1, class T2, int I> class A<T1*, T2, I> { }; //#3
+template<class T> class A<int, T*, 5> { }; //#4
+template<class T1, class T2, int I> class A<T1, T2*, I> { }; //#5
+
+// Redefinition of class template partial specializations
+template<typename T, T N, typename U> class A0;
+
+template<typename T, T N> class A0<T, N, int> { }; // expected-note{{here}}
+template<typename T, T N> class A0<T, N, int>;
+template<typename T, T N> class A0<T, N, int> { }; // expected-error{{redef}}
+
+namespace PR6025 {
+ template< int N > struct A;
+
+ namespace N
+ {
+ template< typename F >
+ struct B;
+ }
+
+ template< typename Protect, typename Second >
+ struct C;
+
+ template <class T>
+ struct C< T, A< N::B<T>::value > >
+ {
+ };
+}
+
+namespace PR6181 {
+ template <class T>
+ class a;
+
+ class s;
+
+ template <class U>
+ class a<s> // expected-error{{partial specialization of 'a' does not use any of its template parameters}}
+ {
+ };
+
+}
diff --git a/clang/test/SemaTemplate/temp_class_spec_blocks.cpp b/clang/test/SemaTemplate/temp_class_spec_blocks.cpp
new file mode 100644
index 0000000..b7b96df
--- /dev/null
+++ b/clang/test/SemaTemplate/temp_class_spec_blocks.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks
+template<typename T>
+struct is_unary_block {
+ static const bool value = false;
+};
+
+template<typename T, typename U>
+struct is_unary_block<T (^)(U)> {
+ static const bool value = true;
+};
+
+int is_unary_block0[is_unary_block<int>::value ? -1 : 1];
+int is_unary_block1[is_unary_block<int (^)()>::value ? -1 : 1];
+int is_unary_block2[is_unary_block<int (^)(int, bool)>::value ? -1 : 1];
+int is_unary_block3[is_unary_block<int (^)(bool)>::value ? 1 : -1];
+int is_unary_block4[is_unary_block<int (^)(int)>::value ? 1 : -1];
+
+template<typename T>
+struct is_unary_block_with_same_return_type_as_argument_type {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_unary_block_with_same_return_type_as_argument_type<T (^)(T)> {
+ static const bool value = true;
+};
+
+int is_unary_block5[is_unary_block_with_same_return_type_as_argument_type<int>::value ? -1 : 1];
+int is_unary_block6[is_unary_block_with_same_return_type_as_argument_type<int (^)()>::value ? -1 : 1];
+int is_unary_block7[is_unary_block_with_same_return_type_as_argument_type<int (^)(int, bool)>::value ? -1 : 1];
+int is_unary_block8[is_unary_block_with_same_return_type_as_argument_type<int (^)(bool)>::value ? -1 : 1];
+int is_unary_block9[is_unary_block_with_same_return_type_as_argument_type<int (^)(int)>::value ? 1 : -1];
+int is_unary_block10[is_unary_block_with_same_return_type_as_argument_type<int (^)(int, ...)>::value ? -1 : 1];
+int is_unary_block11[is_unary_block_with_same_return_type_as_argument_type<int (^ const)(int)>::value ? -1 : 1];
diff --git a/clang/test/SemaTemplate/temp_class_spec_neg.cpp b/clang/test/SemaTemplate/temp_class_spec_neg.cpp
new file mode 100644
index 0000000..be5fbb1
--- /dev/null
+++ b/clang/test/SemaTemplate/temp_class_spec_neg.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T> struct vector;
+
+// C++ [temp.class.spec]p6:
+namespace N {
+ namespace M {
+ template<typename T> struct A; // expected-note{{here}}
+ }
+}
+
+template<typename T>
+struct N::M::A<T*> { }; // expected-warning{{C++11 extension}}
+
+// C++ [temp.class.spec]p9
+// bullet 1
+template <int I, int J> struct A {};
+template <int I> struct A<I+5, I*2> {}; // expected-error{{depends on}}
+template <int I, int J> struct B {};
+template <int I> struct B<I, I> {}; //OK
+
+// bullet 2
+template <class T, T t> struct C {}; // expected-note{{declared here}}
+template <class T> struct C<T, 1>; // expected-error{{specializes}}
+template <class T, T* t> struct C<T*, t>; // okay
+
+template< int X, int (*array_ptr)[X] > class A2 {}; // expected-note{{here}}
+int array[5];
+template< int X > class A2<X, &array> { }; // expected-error{{specializes}}
+
+template<typename T, int N, template<typename X> class TT>
+struct Test0;
+
+// bullet 3
+template<typename T, int N, template<typename X> class TT>
+struct Test0<T, N, TT>; // expected-error{{does not specialize}}
+
+// C++ [temp.class.spec]p10
+template<typename T = int, // expected-error{{default template argument}}
+ int N = 17, // expected-error{{default template argument}}
+ template<typename X> class TT = ::vector> // expected-error{{default template argument}}
+ struct Test0<T*, N, TT> { };
+
+template<typename T> struct Test1;
+template<typename T, typename U> // expected-note{{non-deducible}}
+ struct Test1<T*> { }; // expected-warning{{never be used}}
diff --git a/clang/test/SemaTemplate/temp_explicit.cpp b/clang/test/SemaTemplate/temp_explicit.cpp
new file mode 100644
index 0000000..80c90d0
--- /dev/null
+++ b/clang/test/SemaTemplate/temp_explicit.cpp
@@ -0,0 +1,151 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat %s
+//
+// Tests explicit instantiation of templates.
+template<typename T, typename U = T> class X0 { };
+
+namespace N {
+ template<typename T, typename U = T> class X1 { };
+}
+
+// Check the syntax of explicit instantiations.
+template class X0<int, float>;
+template class X0<int>; // expected-note{{previous}}
+
+template class N::X1<int>;
+template class ::N::X1<int, float>;
+
+using namespace N;
+
+// Check for some bogus syntax that probably means that the user
+// wanted to write an explicit specialization, but forgot the '<>'
+// after 'template'.
+template class X0<double> { }; // expected-error{{explicit specialization}}
+
+// Check for explicit instantiations that come after other kinds of
+// instantiations or declarations.
+template class X0<int, int>; // expected-error{{duplicate}}
+
+template<> class X0<char> { }; // expected-note{{previous}}
+template class X0<char>; // expected-warning{{ignored}}
+
+void foo(X0<short>) { }
+template class X0<short>;
+
+// Check that explicit instantiations actually produce definitions. We
+// determine whether this happens by placing semantic errors in the
+// definition of the template we're instantiating.
+template<typename T> struct X2; // expected-note{{declared here}}
+
+template struct X2<float>; // expected-error{{undefined template}}
+
+template<typename T>
+struct X2 {
+ void f0(T*); // expected-error{{pointer to a reference}}
+};
+
+template struct X2<int>; // okay
+template struct X2<int&>; // expected-note{{in instantiation of}}
+
+// Check that explicit instantiations instantiate member classes.
+template<typename T> struct X3 {
+ struct Inner {
+ void f(T*); // expected-error{{pointer to a reference}}
+ };
+};
+
+void f1(X3<int&>); // okay, Inner, not instantiated
+
+template struct X3<int&>; // expected-note{{instantiation}}
+
+template<typename T> struct X4 {
+ struct Inner {
+ struct VeryInner {
+ void f(T*); // expected-error 2{{pointer to a reference}}
+ };
+ };
+};
+
+void f2(X4<int&>); // okay, Inner, not instantiated
+void f3(X4<int&>::Inner); // okay, Inner::VeryInner, not instantiated
+
+template struct X4<int&>; // expected-note{{instantiation}}
+template struct X4<float&>; // expected-note{{instantiation}}
+
+// Check explicit instantiation of member classes
+namespace N2 {
+
+template<typename T>
+struct X5 {
+ struct Inner1 {
+ void f(T&);
+ };
+
+ struct Inner2 { // expected-note {{here}}
+ struct VeryInner {
+ void g(T*); // expected-error 2{{pointer to a reference}}
+ };
+ };
+};
+
+}
+
+template struct N2::X5<void>::Inner2;
+
+using namespace N2;
+template struct X5<int&>::Inner2; // expected-note{{instantiation}}
+
+void f4(X5<float&>::Inner2);
+template struct X5<float&>::Inner2; // expected-note{{instantiation}}
+
+namespace N3 {
+ template struct N2::X5<int>::Inner2; // expected-warning {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}}
+}
+
+struct X6 {
+ struct Inner { // expected-note{{here}}
+ void f();
+ };
+};
+
+template struct X6::Inner; // expected-error{{non-templated}}
+
+// PR5559
+template <typename T>
+struct Foo;
+
+template <>
+struct Foo<int> // expected-note{{header not required for explicitly-specialized}}
+{
+ template <typename U>
+ struct Bar
+ {};
+};
+
+template <> // expected-warning{{extraneous template parameter list}}
+template <>
+struct Foo<int>::Bar<void>
+{};
+
+namespace N1 {
+
+ template<typename T> struct X7 { }; // expected-note{{here}}
+
+ namespace Inner {
+ template<typename T> struct X8 { };
+ }
+
+ template struct X7<int>;
+ template struct Inner::X8<int>;
+}
+
+template<typename T> struct X9 { }; // expected-note{{here}}
+
+template struct ::N1::Inner::X8<float>;
+
+namespace N2 {
+ using namespace N1;
+
+ template struct X7<double>; // expected-warning{{must occur in namespace}}
+
+ template struct X9<float>; // expected-warning{{must occur at global scope}}
+}
diff --git a/clang/test/SemaTemplate/temp_explicit_cxx0x.cpp b/clang/test/SemaTemplate/temp_explicit_cxx0x.cpp
new file mode 100644
index 0000000..e37fcd7
--- /dev/null
+++ b/clang/test/SemaTemplate/temp_explicit_cxx0x.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+namespace N1 {
+
+ template<typename T> struct X0 { }; // expected-note{{here}}
+
+ namespace Inner {
+ template<typename T> struct X1 { };
+ }
+
+ template struct X0<int>;
+ template struct Inner::X1<int>;
+}
+
+template<typename T> struct X2 { }; // expected-note{{here}}
+
+template struct ::N1::Inner::X1<float>;
+
+namespace N2 {
+ using namespace N1;
+
+ template struct X0<double>; // expected-error{{must occur in namespace 'N1'}}
+
+ template struct X2<float>; // expected-error{{at global scope}}
+}
diff --git a/clang/test/SemaTemplate/temp_func_order.cpp b/clang/test/SemaTemplate/temp_func_order.cpp
new file mode 100644
index 0000000..908354b
--- /dev/null
+++ b/clang/test/SemaTemplate/temp_func_order.cpp
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T>
+int &f0(T);
+
+template<typename T>
+float &f0(T*);
+
+void test_f0(int i, int *ip) {
+ int &ir = f0(i);
+ float &fr = f0(ip);
+}
+
+template<typename T, typename U>
+int &f1(T, U);
+
+template<typename T>
+float &f1(T, T);
+
+void test_f1(int i, float f) {
+ int &ir = f1(i, f);
+ float &fr1 = f1(i, i);
+ float &fr2 = f1(f, f);
+}
+
+template<typename T, typename U>
+struct A { };
+
+template<typename T>
+int &f2(T);
+
+template<typename T, typename U>
+float &f2(A<T, U>);
+
+template<typename T>
+double &f2(A<T, T>);
+
+void test_f2(int i, A<int, float> aif, A<int, int> aii) {
+ int &ir = f2(i);
+ float &fr = f2(aif);
+ double &dr = f2(aii);
+}
+
+template<typename T, typename U>
+int &f3(T*, U); // expected-note{{candidate}}
+
+template<typename T, typename U>
+float &f3(T, U*); // expected-note{{candidate}}
+
+void test_f3(int i, int *ip, float *fp) {
+ int &ir = f3(ip, i);
+ float &fr = f3(i, fp);
+ f3(ip, ip); // expected-error{{ambiguous}}
+}
+
+template<typename T>
+int &f4(T&);
+
+template<typename T>
+float &f4(const T&);
+
+void test_f4(int i, const int ic) {
+ int &ir1 = f4(i);
+ float &fr1 = f4(ic);
+}
+
+template<typename T, typename U>
+int &f5(T&, const U&); // expected-note{{candidate}}
+
+template<typename T, typename U>
+float &f5(const T&, U&); // expected-note{{candidate}}
+
+void test_f5(int i, const int ic) {
+ f5(i, i); // expected-error{{ambiguous}}
+}
+
+template<typename T, typename U>
+int &f6(T&, U&);
+
+template<typename T, typename U>
+float &f6(const T&, U&);
+
+void test_f6(int i, const int ic) {
+ int &ir = f6(i, i);
+ float &fr = f6(ic, ic);
+}
+
+struct CrazyFun {
+ template<typename T, typename U> operator A<T, U>();
+ template<typename T> operator A<T, T>();
+};
+
+void fun(CrazyFun cf) {
+ A<int, float> aif = cf;
+ A<int, int> aii = cf;
+}
diff --git a/clang/test/SemaTemplate/template-class-traits.cpp b/clang/test/SemaTemplate/template-class-traits.cpp
new file mode 100644
index 0000000..4710294
--- /dev/null
+++ b/clang/test/SemaTemplate/template-class-traits.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+#define T(b) (b) ? 1 : -1
+#define F(b) (b) ? -1 : 1
+
+struct HasVirt { virtual void a(); };
+template<class T> struct InheritPolymorph : HasVirt {};
+int t01[T(__is_polymorphic(InheritPolymorph<int>))];
+
diff --git a/clang/test/SemaTemplate/template-decl-fail.cpp b/clang/test/SemaTemplate/template-decl-fail.cpp
new file mode 100644
index 0000000..ad134cd
--- /dev/null
+++ b/clang/test/SemaTemplate/template-decl-fail.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> typedef T X; // expected-error{{typedef cannot be a template}}
+
+template<typename T>
+enum t0 { A = T::x }; // expected-error{{enumeration cannot be a template}} \
+ // expected-warning{{declaration does not declare anything}}
+
+enum e0 {};
+template<int x> enum e0 f0(int a=x) {}
diff --git a/clang/test/SemaTemplate/template-id-expr.cpp b/clang/test/SemaTemplate/template-id-expr.cpp
new file mode 100644
index 0000000..4416f92
--- /dev/null
+++ b/clang/test/SemaTemplate/template-id-expr.cpp
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR5336
+template<typename FromCl>
+struct isa_impl_cl {
+ template<class ToCl>
+ static void isa(const FromCl &Val) { }
+};
+
+template<class X, class Y>
+void isa(const Y &Val) { return isa_impl_cl<Y>::template isa<X>(Val); }
+
+class Value;
+void f0(const Value &Val) { isa<Value>(Val); }
+
+// Implicit template-ids.
+template<typename T>
+struct X0 {
+ template<typename U>
+ void f1();
+
+ template<typename U>
+ void f2(U) {
+ f1<U>();
+ }
+};
+
+void test_X0_int(X0<int> xi, float f) {
+ xi.f2(f);
+}
+
+// Not template-id expressions, but they almost look like it.
+template<typename F>
+struct Y {
+ Y(const F&);
+};
+
+template<int I>
+struct X {
+ X(int, int);
+ void f() {
+ Y<X<I> >(X<I>(0, 0));
+ Y<X<I> >(::X<I>(0, 0));
+ }
+};
+
+template struct X<3>;
+
+// 'template' as a disambiguator.
+// PR7030
+struct Y0 {
+ template<typename U>
+ void f1(U);
+
+ template<typename U>
+ static void f2(U);
+
+ void f3(int);
+
+ static int f4(int);
+ template<typename U>
+ static void f4(U);
+
+ template<typename U>
+ void f() {
+ Y0::template f1<U>(0);
+ Y0::template f1(0);
+ this->template f1(0);
+
+ Y0::template f2<U>(0);
+ Y0::template f2(0);
+
+ Y0::template f3(0); // expected-error {{'f3' following the 'template' keyword does not refer to a template}}
+ Y0::template f3(); // expected-error {{'f3' following the 'template' keyword does not refer to a template}}
+
+ int x;
+ x = Y0::f4(0);
+ x = Y0::f4<int>(0); // expected-error {{assigning to 'int' from incompatible type 'void'}}
+ x = Y0::template f4(0); // expected-error {{assigning to 'int' from incompatible type 'void'}}
+
+ x = this->f4(0);
+ x = this->f4<int>(0); // expected-error {{assigning to 'int' from incompatible type 'void'}}
+ x = this->template f4(0); // expected-error {{assigning to 'int' from incompatible type 'void'}}
+ }
+};
+
+struct A {
+ template<int I>
+ struct B {
+ static void b1();
+ };
+};
+
+template<int I>
+void f5() {
+ A::template B<I>::template b1(); // expected-error {{'b1' following the 'template' keyword does not refer to a template}}
+}
+
+template void f5<0>(); // expected-note {{in instantiation of function template specialization 'f5<0>' requested here}}
diff --git a/clang/test/SemaTemplate/template-id-printing.cpp b/clang/test/SemaTemplate/template-id-printing.cpp
new file mode 100644
index 0000000..047589b
--- /dev/null
+++ b/clang/test/SemaTemplate/template-id-printing.cpp
@@ -0,0 +1,141 @@
+// RUN: %clang_cc1 -fsyntax-only -ast-print %s | FileCheck %s
+namespace N {
+ template<typename T, typename U> void f(U);
+ template<int> void f();
+}
+
+void g() {
+ // CHECK: N::f<int>(3.14
+ N::f<int>(3.14);
+
+ // CHECK: N::f<double>
+ void (*fp)(int) = N::f<double>;
+}
+
+
+// (NNS qualified) DeclRefExpr.
+namespace DRE {
+
+template <typename T>
+void foo();
+
+void test() {
+ // CHECK: DRE::foo<int>;
+ DRE::foo<int>;
+ // CHECK: DRE::template foo<int>;
+ DRE::template foo<int>;
+ // CHECK: DRE::foo<int>();
+ DRE::foo<int>();
+ // CHECK: DRE::template foo<int>();
+ DRE::template foo<int>();
+}
+
+} // namespace DRE
+
+
+// MemberExpr.
+namespace ME {
+
+struct S {
+ template <typename T>
+ void mem();
+};
+
+void test() {
+ S s;
+ // CHECK: s.mem<int>();
+ s.mem<int>();
+ // CHECK: s.template mem<int>();
+ s.template mem<int>();
+}
+
+} // namespace ME
+
+
+// UnresolvedLookupExpr.
+namespace ULE {
+
+template <typename T>
+int foo();
+
+template <typename T>
+void test() {
+ // CHECK: ULE::foo<T>;
+ ULE::foo<T>;
+ // CHECK: ULE::template foo<T>;
+ ULE::template foo<T>;
+}
+
+} // namespace ULE
+
+
+// UnresolvedMemberExpr.
+namespace UME {
+
+struct S {
+ template <typename T>
+ void mem();
+};
+
+template <typename U>
+void test() {
+ S s;
+ // CHECK: s.mem<U>();
+ s.mem<U>();
+ // CHECK: s.template mem<U>();
+ s.template mem<U>();
+}
+
+} // namespace UME
+
+
+// DependentScopeDeclRefExpr.
+namespace DSDRE {
+
+template <typename T>
+struct S;
+
+template <typename T>
+void test() {
+ // CHECK: S<T>::foo;
+ S<T>::foo;
+ // CHECK: S<T>::template foo;
+ S<T>::template foo;
+ // CHECK: S<T>::template foo<>;
+ S<T>::template foo<>;
+ // CHECK: S<T>::template foo<T>;
+ S<T>::template foo<T>;
+}
+
+} // namespace DSDRE
+
+
+// DependentScopeMemberExpr.
+namespace DSME {
+
+template <typename T>
+struct S;
+
+template <typename T>
+void test() {
+ S<T> s;
+ // CHECK: s.foo;
+ s.foo;
+ // CHECK: s.template foo;
+ s.template foo;
+ // CHECK: s.template foo<>;
+ s.template foo<>;
+ // CHECK: s.template foo<T>;
+ s.template foo<T>;
+}
+
+} // namespace DSME
+
+namespace DSDRE_withImplicitTemplateArgs {
+
+template <typename T> void foo() {
+ // CHECK: T::template bar();
+ T::template bar();
+}
+
+} // namespace DSDRE_withImplicitTemplateArgs
diff --git a/clang/test/SemaTemplate/typename-specifier-2.cpp b/clang/test/SemaTemplate/typename-specifier-2.cpp
new file mode 100644
index 0000000..551cac3
--- /dev/null
+++ b/clang/test/SemaTemplate/typename-specifier-2.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename MetaFun, typename T>
+struct bind_metafun {
+ typedef typename MetaFun::template apply<T> type;
+};
+
+struct add_pointer {
+ template<typename T>
+ struct apply {
+ typedef T* type;
+ };
+};
+
+int i;
+// FIXME: if we make the declarator below a pointer (e.g., with *ip),
+// the error message isn't so good because we don't get the handy
+// 'aka' telling us that we're dealing with an int**. Should we fix
+// getDesugaredType to dig through pointers and such?
+bind_metafun<add_pointer, int>::type::type ip = &i;
+bind_metafun<add_pointer, float>::type::type fp = &i; // expected-error{{cannot initialize a variable of type 'bind_metafun<add_pointer, float>::type::type' (aka 'float *') with an rvalue of type 'int *'}}
+
+
+template<typename T>
+struct extract_type_type {
+ typedef typename T::type::type t;
+};
+
+double d;
+extract_type_type<bind_metafun<add_pointer, double> >::t dp = &d;
diff --git a/clang/test/SemaTemplate/typename-specifier-3.cpp b/clang/test/SemaTemplate/typename-specifier-3.cpp
new file mode 100644
index 0000000..a463d88
--- /dev/null
+++ b/clang/test/SemaTemplate/typename-specifier-3.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR4364
+template<class T> struct a {
+ T b() {
+ return typename T::x();
+ }
+};
+struct B {
+ typedef B x;
+};
+B c() {
+ a<B> x;
+ return x.b();
+}
+
+// Some extra tests for invalid cases
+template<class T> struct test2 { T b() { return typename T::a; } }; // expected-error{{expected '(' for function-style cast or type construction}}
+template<class T> struct test3 { T b() { return typename a; } }; // expected-error{{expected a qualified name after 'typename'}}
diff --git a/clang/test/SemaTemplate/typename-specifier-4.cpp b/clang/test/SemaTemplate/typename-specifier-4.cpp
new file mode 100644
index 0000000..44cf966
--- /dev/null
+++ b/clang/test/SemaTemplate/typename-specifier-4.cpp
@@ -0,0 +1,164 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+template<typename MetaFun, typename T1, typename T2>
+struct metafun_apply2 {
+ typedef typename MetaFun::template apply<T1, T2> inner;
+ typedef typename inner::type type;
+};
+
+template<typename T, typename U> struct pair;
+
+struct make_pair {
+ template<typename T1, typename T2>
+ struct apply {
+ typedef pair<T1, T2> type;
+ };
+};
+
+int a0[is_same<metafun_apply2<make_pair, int, float>::type,
+ pair<int, float> >::value? 1 : -1];
+int a1[is_same<
+ typename make_pair::template apply<int, float>, // expected-warning{{'template' keyword outside of a template}} \
+ // expected-warning{{'typename' occurs outside of a template}}
+ make_pair::apply<int, float>
+ >::value? 1 : -1];
+
+template<typename MetaFun>
+struct swap_and_apply2 {
+ template<typename T1, typename T2>
+ struct apply {
+ typedef typename MetaFun::template apply<T2, T1> new_metafun;
+ typedef typename new_metafun::type type;
+ };
+};
+
+int a2[is_same<swap_and_apply2<make_pair>::apply<int, float>::type,
+ pair<float, int> >::value? 1 : -1];
+
+template<typename MetaFun>
+struct swap_and_apply2b {
+ template<typename T1, typename T2>
+ struct apply {
+ typedef typename MetaFun::template apply<T2, T1>::type type;
+ };
+};
+
+int a3[is_same<swap_and_apply2b<make_pair>::apply<int, float>::type,
+ pair<float, int> >::value? 1 : -1];
+
+template<typename T>
+struct X0 {
+ template<typename U, typename V>
+ struct Inner;
+
+ void f0(X0<T>::Inner<T*, T&>); // expected-note{{here}}
+ void f0(typename X0<T>::Inner<T*, T&>); // expected-error{{redecl}}
+
+ void f1(X0<T>::Inner<T*, T&>); // expected-note{{here}}
+ void f1(typename X0<T>::template Inner<T*, T&>); // expected-error{{redecl}}
+
+ void f2(typename X0<T>::Inner<T*, T&>::type); // expected-note{{here}}
+ void f2(typename X0<T>::template Inner<T*, T&>::type); // expected-error{{redecl}}
+};
+
+namespace PR6236 {
+ template<typename T, typename U> struct S { };
+
+ template<typename T> struct S<T, T> {
+ template<typename U> struct K { };
+
+ void f() {
+ typedef typename S<T, T>::template K<T> Foo;
+ }
+ };
+}
+
+namespace PR6268 {
+ template <typename T>
+ struct Outer {
+ template <typename U>
+ struct Inner {};
+
+ template <typename U>
+ typename Outer<T>::template Inner<U>
+ foo(typename Outer<T>::template Inner<U>);
+ };
+
+ template <typename T>
+ template <typename U>
+ typename Outer<T>::template Inner<U>
+ Outer<T>::foo(typename Outer<T>::template Inner<U>) {
+ return Inner<U>();
+ }
+}
+
+namespace PR6463 {
+ struct B { typedef int type; }; // expected-note 2{{member found by ambiguous name lookup}}
+ struct C { typedef int type; }; // expected-note 2{{member found by ambiguous name lookup}}
+
+ template<typename T>
+ struct A : B, C {
+ type& a(); // expected-error{{found in multiple base classes}}
+ int x;
+ };
+
+ // FIXME: Improve source location info here.
+ template<typename T>
+ typename A<T>::type& A<T>::a() { // expected-error{{found in multiple base classes}}
+ return x;
+ }
+}
+
+namespace PR7419 {
+ template <typename T> struct S {
+ typedef typename T::Y T2;
+ typedef typename T2::Z T3;
+ typedef typename T3::W T4;
+ T4 *f();
+
+ typedef typename T::template Y<int> TT2;
+ typedef typename TT2::template Z<float> TT3;
+ typedef typename TT3::template W<double> TT4;
+ TT4 g();
+ };
+
+ template <typename T> typename T::Y::Z::W *S<T>::f() { }
+ template <typename T> typename T::template Y<int>::template Z<float>::template W<double> S<T>::g() { }
+}
+
+namespace rdar8740998 {
+ template<typename T>
+ struct X : public T {
+ using T::iterator; // expected-note{{add 'typename' to treat this using declaration as a type}} \
+ // expected-error{{dependent using declaration resolved to type without 'typename'}}
+
+ void f() {
+ typename X<T>::iterator i; // expected-error{{typename specifier refers to a dependent using declaration for a value 'iterator' in 'X<T>'}}
+ }
+ };
+
+ struct HasIterator {
+ typedef int *iterator; // expected-note{{target of using declaration}}
+ };
+
+ void test_X(X<HasIterator> xi) { // expected-note{{in instantiation of template class}}
+ xi.f();
+ }
+}
+
+namespace rdar9068589 {
+ // From GCC PR c++/13950
+ template <class T> struct Base {};
+ template <class T> struct Derived: public Base<T> {
+ typename Derived::template Base<double>* p1;
+ };
+}
diff --git a/clang/test/SemaTemplate/typename-specifier.cpp b/clang/test/SemaTemplate/typename-specifier.cpp
new file mode 100644
index 0000000..9eb4f33
--- /dev/null
+++ b/clang/test/SemaTemplate/typename-specifier.cpp
@@ -0,0 +1,117 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+namespace N {
+ struct A {
+ typedef int type;
+ };
+
+ struct B {
+ };
+
+ struct C {
+ struct type { };
+ int type; // expected-note 2{{referenced member 'type' is declared here}}
+ };
+}
+
+int i;
+
+typename N::A::type *ip1 = &i; // expected-warning{{'typename' occurs outside of a template}}
+typename N::B::type *ip2 = &i; // expected-error{{no type named 'type' in 'N::B'}} \
+// expected-warning{{'typename' occurs outside of a template}}
+typename N::C::type *ip3 = &i; // expected-error{{typename specifier refers to non-type member 'type'}} \
+// expected-warning{{'typename' occurs outside of a template}}
+
+void test(double d) {
+ typename N::A::type f(typename N::A::type(a)); // expected-warning{{parentheses were disambiguated as a function declarator}} \
+ // expected-warning 2{{'typename' occurs outside of a template}}
+ int five = f(5);
+
+ using namespace N;
+ for (typename A::type i = 0; i < 10; ++i) // expected-warning{{'typename' occurs outside of a template}}
+ five += 1;
+
+ const typename N::A::type f2(d); // expected-warning{{'typename' occurs outside of a template}}
+}
+
+namespace N {
+ template<typename T>
+ struct X {
+ typedef typename T::type type; // expected-error {{no type named 'type' in 'N::B'}} \
+ // expected-error {{no type named 'type' in 'B'}} \
+ // FIXME: location info for error above isn't very good \
+ // expected-error 2{{typename specifier refers to non-type member 'type'}} \
+ // expected-error{{type 'int' cannot be used prior to '::' because it has no members}}
+ };
+}
+
+N::X<N::A>::type *ip4 = &i;
+N::X<N::B>::type *ip5 = &i; // expected-note{{in instantiation of template class 'N::X<N::B>' requested here}}
+N::X<N::C>::type *ip6 = &i; // expected-note{{in instantiation of template class 'N::X<N::C>' requested here}}
+
+N::X<int>::type fail1; // expected-note{{in instantiation of template class 'N::X<int>' requested here}}
+
+template<typename T>
+struct Y {
+ typedef typename N::X<T>::type *type; // expected-note{{in instantiation of template class 'N::X<B>' requested here}} \
+ // expected-note{{in instantiation of template class 'N::X<C>' requested here}}
+};
+
+struct A {
+ typedef int type;
+};
+
+struct B {
+};
+
+struct C {
+ struct type { };
+ int type; // expected-note{{referenced member 'type' is declared here}}
+};
+
+::Y<A>::type ip7 = &i;
+::Y<B>::type ip8 = &i; // expected-note{{in instantiation of template class 'Y<B>' requested here}}
+::Y<C>::type ip9 = &i; // expected-note{{in instantiation of template class 'Y<C>' requested here}}
+
+template<typename T> struct D {
+ typedef typename T::foo foo; // expected-error {{type 'long' cannot be used prior to '::' because it has no members}}
+ typedef typename foo::bar bar;
+};
+
+D<long> struct_D; // expected-note {{in instantiation of template class 'D<long>' requested here}}
+
+template<typename T> struct E {
+ typedef typename T::foo foo;
+ typedef typename foo::bar bar; // expected-error {{type 'foo' (aka 'double') cannot be used prior to '::' because it has no members}}
+};
+
+struct F {
+ typedef double foo;
+};
+
+E<F> struct_E; // expected-note {{in instantiation of template class 'E<F>' requested here}}
+
+template<typename T> struct G {
+ typedef typename T::foo foo;
+ typedef typename foo::bar bar;
+};
+
+struct H {
+ struct foo {
+ typedef double bar;
+ };
+};
+
+G<H> struct_G;
+
+namespace PR10925 {
+ template< int mydim, typename Traits >
+ class BasicGeometry
+ {
+ typedef int some_type_t;
+ };
+
+ template<class ctype, int mydim, int coorddim>
+ class MockGeometry : BasicGeometry<mydim, int>{
+ using typename BasicGeometry<mydim, int>::operator[]; // expected-error {{typename is allowed for identifiers only}}
+ };
+}
diff --git a/clang/test/SemaTemplate/typo-dependent-name.cpp b/clang/test/SemaTemplate/typo-dependent-name.cpp
new file mode 100644
index 0000000..96554e9
--- /dev/null
+++ b/clang/test/SemaTemplate/typo-dependent-name.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+struct Base {
+ T inner;
+};
+
+template<typename T>
+struct X {
+ template<typename U>
+ struct Inner {
+ };
+
+ bool f(T other) {
+ return this->inner < other;
+ }
+};
diff --git a/clang/test/SemaTemplate/unresolved-construct.cpp b/clang/test/SemaTemplate/unresolved-construct.cpp
new file mode 100644
index 0000000..bb9ed8e
--- /dev/null
+++ b/clang/test/SemaTemplate/unresolved-construct.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+class A
+{
+public:
+ A() {}
+
+ template <class _F>
+ explicit A(_F&& __f);
+
+ A(A&&) {}
+ A& operator=(A&&) {return *this;}
+};
+
+template <class T>
+void f(T t)
+{
+ A a;
+ a = f(t);
+}
diff --git a/clang/test/SemaTemplate/unused-variables.cpp b/clang/test/SemaTemplate/unused-variables.cpp
new file mode 100644
index 0000000..1b9350b
--- /dev/null
+++ b/clang/test/SemaTemplate/unused-variables.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused -verify %s
+
+struct X0 {
+ ~X0();
+};
+
+struct X1 { };
+
+template<typename T>
+void f() {
+ X0 x0;
+ X1 x1; // expected-warning{{unused variable 'x1'}}
+}
+
+template<typename T, typename U>
+void g() {
+ T t;
+ U u; // expected-warning{{unused variable 'u'}}
+}
+
+template void g<X0, X1>(); // expected-note{{in instantiation of}}
diff --git a/clang/test/SemaTemplate/value-dependent-null-pointer-constant.cpp b/clang/test/SemaTemplate/value-dependent-null-pointer-constant.cpp
new file mode 100644
index 0000000..223500e
--- /dev/null
+++ b/clang/test/SemaTemplate/value-dependent-null-pointer-constant.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+template<typename T, int N>
+struct X0 {
+ const char *f0(bool Cond) {
+ return Cond? "honk" : N;
+ }
+
+ const char *f1(bool Cond) {
+ return Cond? N : "honk";
+ }
+
+ bool f2(const char *str) {
+ return str == N;
+ }
+};
+
+// PR4996
+template<unsigned I> int f0() {
+ return __builtin_choose_expr(I, 0, 1);
+}
+
+// PR5041
+struct A { };
+
+template <typename T> void f(T *t)
+{
+ (void)static_cast<void*>(static_cast<A*>(t));
+}
diff --git a/clang/test/SemaTemplate/virtual-member-functions.cpp b/clang/test/SemaTemplate/virtual-member-functions.cpp
new file mode 100644
index 0000000..974f664
--- /dev/null
+++ b/clang/test/SemaTemplate/virtual-member-functions.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR5557 {
+template <class T> struct A {
+ A();
+ virtual void anchor();
+ virtual int a(T x);
+};
+template<class T> A<T>::A() {}
+template<class T> void A<T>::anchor() { }
+
+template<class T> int A<T>::a(T x) {
+ return *x; // expected-error{{requires pointer operand}}
+}
+
+void f(A<int> x) {
+ x.anchor(); // expected-note{{instantiation}}
+}
+
+template<typename T>
+struct X {
+ virtual void f();
+};
+
+template<>
+void X<int>::f() { }
+}
+
+template<typename T>
+struct Base {
+ virtual ~Base() {
+ int *ptr = 0;
+ T t = ptr; // expected-error{{cannot initialize}}
+ }
+};
+
+template<typename T>
+struct Derived : Base<T> {
+ virtual void foo() { }
+};
+
+template struct Derived<int>; // expected-note {{in instantiation of member function 'Base<int>::~Base' requested here}}
+
+template<typename T>
+struct HasOutOfLineKey {
+ HasOutOfLineKey() { }
+ virtual T *f(float *fp);
+};
+
+template<typename T>
+T *HasOutOfLineKey<T>::f(float *fp) {
+ return fp; // expected-error{{cannot initialize return object of type 'int *' with an lvalue of type 'float *'}}
+}
+
+HasOutOfLineKey<int> out_of_line; // expected-note{{in instantiation of member function 'HasOutOfLineKey<int>::f' requested here}}
+
+namespace std {
+ class type_info;
+}
+
+namespace PR7114 {
+ class A { virtual ~A(); }; // expected-note{{declared private here}}
+
+ template<typename T>
+ class B {
+ public:
+ class Inner : public A { }; // expected-error{{base class 'PR7114::A' has private destructor}}
+ static Inner i;
+ static const unsigned value = sizeof(i) == 4;
+ };
+
+ int f() { return B<int>::value; }
+
+ void test_typeid(B<float>::Inner bfi) {
+ (void)typeid(bfi); // expected-note{{implicit default destructor}}
+ }
+
+ template<typename T>
+ struct X : A {
+ void f() { }
+ };
+
+ void test_X(X<int> xi, X<float> xf) {
+ xi.f();
+ }
+}
diff --git a/clang/test/TestRunner.sh b/clang/test/TestRunner.sh
new file mode 100755
index 0000000..f96d3d5
--- /dev/null
+++ b/clang/test/TestRunner.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+#
+# TestRunner.sh - Backward compatible utility for testing an individual file.
+
+# Find where this script is.
+Dir=$(dirname $(which $0))
+AbsDir=$(cd $Dir; pwd)
+
+# Find 'lit', assuming standard layout.
+lit=$AbsDir/../../../utils/lit/lit.py
+
+# Dispatch to lit.
+$lit "$@"
diff --git a/clang/test/Tooling/clang-check-args.cpp b/clang/test/Tooling/clang-check-args.cpp
new file mode 100644
index 0000000..a14fc7b
--- /dev/null
+++ b/clang/test/Tooling/clang-check-args.cpp
@@ -0,0 +1,8 @@
+// RUN: clang-check . "%s" -- -c 2>&1 | FileCheck %s
+
+// CHECK: C++ requires
+invalid;
+
+// FIXME: JSON doesn't like path separator '\', on Win32 hosts.
+// FIXME: clang-check doesn't like gcc driver on cygming.
+// XFAIL: cygwin,mingw32,win32
diff --git a/clang/test/Tooling/clang-check-pwd.cpp b/clang/test/Tooling/clang-check-pwd.cpp
new file mode 100644
index 0000000..cb94344
--- /dev/null
+++ b/clang/test/Tooling/clang-check-pwd.cpp
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %t/test.cpp\",\"file\":\"%t/test.cpp\"}]" > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: PWD="%t" clang-check "%t" "test.cpp" 2>&1|FileCheck %s
+// FIXME: Make the above easier.
+
+// CHECK: C++ requires
+invalid;
+
+// FIXME: JSON doesn't like path separator '\', on Win32 hosts.
+// FIXME: clang-check doesn't like gcc driver on cygming.
+// XFAIL: cygwin,mingw32,win32
diff --git a/clang/test/Tooling/clang-check.cpp b/clang/test/Tooling/clang-check.cpp
new file mode 100644
index 0000000..de10e4a
--- /dev/null
+++ b/clang/test/Tooling/clang-check.cpp
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo '[{"directory":".","command":"clang++ -c %t/test.cpp","file":"%t/test.cpp"}]' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-check "%t" "%t/test.cpp" 2>&1|FileCheck %s
+// FIXME: Make the above easier.
+
+// CHECK: C++ requires
+invalid;
+
+// FIXME: JSON doesn't like path separator '\', on Win32 hosts.
+// FIXME: clang-check doesn't like gcc driver on cygming.
+// XFAIL: cygwin,mingw32,win32
diff --git a/clang/test/Unit/lit.cfg b/clang/test/Unit/lit.cfg
new file mode 100644
index 0000000..8f27781
--- /dev/null
+++ b/clang/test/Unit/lit.cfg
@@ -0,0 +1,86 @@
+# -*- Python -*-
+
+# Configuration file for the 'lit' test runner.
+
+import os
+
+# name: The name of this test suite.
+config.name = 'Clang-Unit'
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = []
+
+# test_source_root: The root path where tests are located.
+# test_exec_root: The root path where tests should be run.
+clang_obj_root = getattr(config, 'clang_obj_root', None)
+if clang_obj_root is not None:
+ config.test_exec_root = os.path.join(clang_obj_root, 'unittests')
+ config.test_source_root = config.test_exec_root
+
+# testFormat: The test format to use to interpret tests.
+llvm_build_mode = getattr(config, 'llvm_build_mode', "Debug")
+config.test_format = lit.formats.GoogleTest(llvm_build_mode, 'Tests')
+
+# Propagate the temp directory. Windows requires this because it uses \Windows\
+# if none of these are present.
+if 'TMP' in os.environ:
+ config.environment['TMP'] = os.environ['TMP']
+if 'TEMP' in os.environ:
+ config.environment['TEMP'] = os.environ['TEMP']
+
+###
+
+# Check that the object root is known.
+if config.test_exec_root is None:
+ # Otherwise, we haven't loaded the site specific configuration (the user is
+ # probably trying to run on a test file directly, and either the site
+ # configuration hasn't been created by the build system, or we are in an
+ # out-of-tree build situation).
+
+ # Check for 'clang_unit_site_config' user parameter, and use that if available.
+ site_cfg = lit.params.get('clang_unit_site_config', None)
+ if site_cfg and os.path.exists(site_cfg):
+ lit.load_config(config, site_cfg)
+ raise SystemExit
+
+ # Try to detect the situation where we are using an out-of-tree build by
+ # looking for 'llvm-config'.
+ #
+ # FIXME: I debated (i.e., wrote and threw away) adding logic to
+ # automagically generate the lit.site.cfg if we are in some kind of fresh
+ # build situation. This means knowing how to invoke the build system
+ # though, and I decided it was too much magic.
+
+ llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
+ if not llvm_config:
+ lit.fatal('No site specific configuration available!')
+
+ # Get the source and object roots.
+ llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
+ llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
+ clang_src_root = os.path.join(llvm_src_root, "tools", "clang")
+ clang_obj_root = os.path.join(llvm_obj_root, "tools", "clang")
+
+ # Validate that we got a tree which points to here, using the standard
+ # tools/clang layout.
+ this_src_root = os.path.join(os.path.dirname(__file__),'..','..')
+ if os.path.realpath(clang_src_root) != os.path.realpath(this_src_root):
+ lit.fatal('No site specific configuration available!')
+
+ # Check that the site specific configuration exists.
+ site_cfg = os.path.join(clang_obj_root, 'test', 'Unit', 'lit.site.cfg')
+ if not os.path.exists(site_cfg):
+ lit.fatal('No site specific configuration available!')
+
+ # Okay, that worked. Notify the user of the automagic, and reconfigure.
+ lit.note('using out-of-tree build at %r' % clang_obj_root)
+ lit.load_config(config, site_cfg)
+ raise SystemExit
+
+# If necessary, point the dynamic loader at libLLVM.so.
+if config.enable_shared:
+ shlibpath = config.environment.get(config.shlibpath_var,'')
+ if shlibpath:
+ shlibpath = os.pathsep + shlibpath
+ shlibpath = config.shlibdir + shlibpath
+ config.environment[config.shlibpath_var] = shlibpath
diff --git a/clang/test/Unit/lit.site.cfg.in b/clang/test/Unit/lit.site.cfg.in
new file mode 100644
index 0000000..9f4d224
--- /dev/null
+++ b/clang/test/Unit/lit.site.cfg.in
@@ -0,0 +1,26 @@
+## Autogenerated by LLVM/Clang configuration.
+# Do not edit!
+config.llvm_src_root = "@LLVM_SOURCE_DIR@"
+config.llvm_obj_root = "@LLVM_BINARY_DIR@"
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_build_mode = "@LLVM_BUILD_MODE@"
+config.clang_obj_root = "@CLANG_BINARY_DIR@"
+config.enable_shared = @ENABLE_SHARED@
+config.shlibdir = "@SHLIBDIR@"
+config.shlibpath_var = "@SHLIBPATH_VAR@"
+config.target_triple = "@TARGET_TRIPLE@"
+
+# Support substitution of the tools_dir, libs_dirs, and build_mode with user
+# parameters. This is used when we can't determine the tool dir at
+# configuration time.
+try:
+ config.llvm_tools_dir = config.llvm_tools_dir % lit.params
+ config.llvm_libs_dir = config.llvm_libs_dir % lit.params
+ config.llvm_build_mode = config.llvm_build_mode % lit.params
+except KeyError,e:
+ key, = e.args
+ lit.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
+
+# Let the main config do the real work.
+lit.load_config(config, "@CLANG_SOURCE_DIR@/test/Unit/lit.cfg")
diff --git a/clang/test/cxx-sections.data b/clang/test/cxx-sections.data
new file mode 100644
index 0000000..0edc5f1
--- /dev/null
+++ b/clang/test/cxx-sections.data
@@ -0,0 +1,1943 @@
+1 [intro]
+ 1.1 [intro.scope]
+ 1.2 [intro.refs]
+ 1.3 [intro.defs]
+ 1.3.1 [defns.argument]
+ 1.3.2 [defns.cond.supp]
+ 1.3.3 [defns.diagnostic]
+ 1.3.4 [defns.dynamic.type]
+ 1.3.5 [defns.ill.formed]
+ 1.3.6 [defns.impl.defined]
+ 1.3.7 [defns.impl.limits]
+ 1.3.8 [defns.locale.specific]
+ 1.3.9 [defns.multibyte]
+ 1.3.10 [defns.parameter]
+ 1.3.11 [defns.signature]
+ 1.3.12 [defns.static.type]
+ 1.3.13 [defns.undefined]
+ 1.3.14 [defns.unspecified]
+ 1.3.15 [defns.well.formed]
+ 1.4 [intro.compliance]
+ 1.5 [intro.structure]
+ 1.6 [syntax]
+ 1.7 [intro.memory]
+ 1.8 [intro.object]
+ 1.9 [intro.execution]
+ 1.10 [intro.multithread]
+ 1.11 [intro.ack]
+2 [lex]
+ 2.1 [lex.separate]
+ 2.2 [lex.phases]
+ 2.3 [lex.charset]
+ 2.4 [lex.trigraph]
+ 2.5 [lex.pptoken]
+ 2.6 [lex.digraph]
+ 2.7 [lex.token]
+ 2.8 [lex.comment]
+ 2.9 [lex.header]
+ 2.10 [lex.ppnumber]
+ 2.11 [lex.name]
+ 2.12 [lex.key]
+ 2.13 [lex.operators]
+ 2.14 [lex.literal]
+ 2.14.1 [lex.literal.kinds]
+ 2.14.2 [lex.icon]
+ 2.14.3 [lex.ccon]
+ 2.14.4 [lex.fcon]
+ 2.14.5 [lex.string]
+ 2.14.6 [lex.bool]
+ 2.14.7 [lex.nullptr]
+ 2.14.8 [lex.ext]
+3 [basic]
+ 3.1 [basic.def]
+ 3.2 [basic.def.odr]
+ 3.3 [basic.scope]
+ 3.3.1 [basic.scope.declarative]
+ 3.3.2 [basic.scope.pdecl]
+ 3.3.3 [basic.scope.local]
+ 3.3.4 [basic.scope.proto]
+ 3.3.5 [basic.funscope]
+ 3.3.6 [basic.scope.namespace]
+ 3.3.7 [basic.scope.class]
+ 3.3.8 [basic.scope.concept]
+ 3.3.9 [basic.scope.req]
+ 3.3.10 [basic.scope.enum]
+ 3.3.11 [basic.scope.hiding]
+ 3.4 [basic.lookup]
+ 3.4.1 [basic.lookup.unqual]
+ 3.4.2 [basic.lookup.argdep]
+ 3.4.3 [basic.lookup.qual]
+ 3.4.3.1 [class.qual]
+ 3.4.3.2 [namespace.qual]
+ 3.4.3.3 [concept.qual]
+ 3.4.4 [basic.lookup.elab]
+ 3.4.5 [basic.lookup.classref]
+ 3.4.6 [basic.lookup.udir]
+ 3.5 [basic.link]
+ 3.6 [basic.start]
+ 3.6.1 [basic.start.main]
+ 3.6.2 [basic.start.init]
+ 3.6.3 [basic.start.term]
+ 3.7 [basic.stc]
+ 3.7.1 [basic.stc.static]
+ 3.7.2 [basic.stc.thread]
+ 3.7.3 [basic.stc.auto]
+ 3.7.4 [basic.stc.dynamic]
+ 3.7.4.1 [basic.stc.dynamic.allocation]
+ 3.7.4.2 [basic.stc.dynamic.deallocation]
+ 3.7.4.3 [basic.stc.dynamic.safety]
+ 3.7.5 [basic.stc.inherit]
+ 3.8 [basic.life]
+ 3.9 [basic.types]
+ 3.9.1 [basic.fundamental]
+ 3.9.2 [basic.compound]
+ 3.9.3 [basic.type.qualifier]
+ 3.10 [basic.lval]
+ 3.11 [basic.align]
+4 [conv]
+ 4.1 [conv.lval]
+ 4.2 [conv.array]
+ 4.3 [conv.func]
+ 4.4 [conv.qual]
+ 4.5 [conv.prom]
+ 4.6 [conv.fpprom]
+ 4.7 [conv.integral]
+ 4.8 [conv.double]
+ 4.9 [conv.fpint]
+ 4.10 [conv.ptr]
+ 4.11 [conv.mem]
+ 4.12 [conv.bool]
+ 4.13 [conv.rank]
+5 [expr]
+ 5.1 [expr.prim]
+ 5.1.1 [expr.prim.general]
+ 5.1.2 [expr.prim.lambda]
+ 5.2 [expr.post]
+ 5.2.1 [expr.sub]
+ 5.2.2 [expr.call]
+ 5.2.3 [expr.type.conv]
+ 5.2.4 [expr.pseudo]
+ 5.2.5 [expr.ref]
+ 5.2.6 [expr.post.incr]
+ 5.2.7 [expr.dynamic.cast]
+ 5.2.8 [expr.typeid]
+ 5.2.9 [expr.static.cast]
+ 5.2.10 [expr.reinterpret.cast]
+ 5.2.11 [expr.const.cast]
+ 5.3 [expr.unary]
+ 5.3.1 [expr.unary.op]
+ 5.3.2 [expr.pre.incr]
+ 5.3.3 [expr.sizeof]
+ 5.3.4 [expr.new]
+ 5.3.5 [expr.delete]
+ 5.3.6 [expr.alignof]
+ 5.4 [expr.cast]
+ 5.5 [expr.mptr.oper]
+ 5.6 [expr.mul]
+ 5.7 [expr.add]
+ 5.8 [expr.shift]
+ 5.9 [expr.rel]
+ 5.10 [expr.eq]
+ 5.11 [expr.bit.and]
+ 5.12 [expr.xor]
+ 5.13 [expr.or]
+ 5.14 [expr.log.and]
+ 5.15 [expr.log.or]
+ 5.16 [expr.cond]
+ 5.17 [expr.ass]
+ 5.18 [expr.comma]
+ 5.19 [expr.const]
+6 [stmt.stmt]
+ 6.1 [stmt.label]
+ 6.2 [stmt.expr]
+ 6.3 [stmt.block]
+ 6.4 [stmt.select]
+ 6.4.1 [stmt.if]
+ 6.4.2 [stmt.switch]
+ 6.5 [stmt.iter]
+ 6.5.1 [stmt.while]
+ 6.5.2 [stmt.do]
+ 6.5.3 [stmt.for]
+ 6.5.4 [stmt.ranged]
+ 6.6 [stmt.jump]
+ 6.6.1 [stmt.break]
+ 6.6.2 [stmt.cont]
+ 6.6.3 [stmt.return]
+ 6.6.4 [stmt.goto]
+ 6.7 [stmt.dcl]
+ 6.8 [stmt.ambig]
+ 6.9 [stmt.late]
+7 [dcl.dcl]
+ 7.1 [dcl.spec]
+ 7.1.1 [dcl.stc]
+ 7.1.2 [dcl.fct.spec]
+ 7.1.3 [dcl.typedef]
+ 7.1.4 [dcl.friend]
+ 7.1.5 [dcl.constexpr]
+ 7.1.6 [dcl.type]
+ 7.1.6.1 [dcl.type.cv]
+ 7.1.6.2 [dcl.type.simple]
+ 7.1.6.3 [dcl.type.elab]
+ 7.1.6.4 [dcl.spec.auto]
+ 7.2 [dcl.enum]
+ 7.3 [basic.namespace]
+ 7.3.1 [namespace.def]
+ 7.3.1.1 [namespace.unnamed]
+ 7.3.1.2 [namespace.memdef]
+ 7.3.2 [namespace.alias]
+ 7.3.3 [namespace.udecl]
+ 7.3.4 [namespace.udir]
+ 7.4 [dcl.asm]
+ 7.5 [dcl.link]
+ 7.6 [dcl.attr]
+ 7.6.1 [dcl.attr.grammar]
+ 7.6.2 [dcl.align]
+ 7.6.3 [dcl.attr.noreturn]
+ 7.6.4 [dcl.attr.final]
+ 7.6.5 [dcl.attr.depend]
+8 [dcl.decl]
+ 8.1 [dcl.name]
+ 8.2 [dcl.ambig.res]
+ 8.3 [dcl.meaning]
+ 8.3.1 [dcl.ptr]
+ 8.3.2 [dcl.ref]
+ 8.3.3 [dcl.mptr]
+ 8.3.4 [dcl.array]
+ 8.3.5 [dcl.fct]
+ 8.3.6 [dcl.fct.default]
+ 8.4 [dcl.fct.def]
+ 8.5 [dcl.init]
+ 8.5.1 [dcl.init.aggr]
+ 8.5.2 [dcl.init.string]
+ 8.5.3 [dcl.init.ref]
+ 8.5.4 [dcl.init.list]
+9 [class]
+ 9.1 [class.name]
+ 9.2 [class.mem]
+ 9.3 [class.mfct]
+ 9.3.1 [class.mfct.non-static]
+ 9.3.2 [class.this]
+ 9.4 [class.static]
+ 9.4.1 [class.static.mfct]
+ 9.4.2 [class.static.data]
+ 9.5 [class.union]
+ 9.6 [class.bit]
+ 9.7 [class.nest]
+ 9.8 [class.local]
+ 9.9 [class.nested.type]
+10 [class.derived]
+ 10.1 [class.mi]
+ 10.2 [class.member.lookup]
+ 10.3 [class.virtual]
+ 10.4 [class.abstract]
+11 [class.access]
+ 11.1 [class.access.spec]
+ 11.2 [class.access.base]
+ 11.3 [class.access.dcl]
+ 11.4 [class.friend]
+ 11.5 [class.protected]
+ 11.6 [class.access.virt]
+ 11.7 [class.paths]
+ 11.8 [class.access.nest]
+12 [special]
+ 12.1 [class.ctor]
+ 12.2 [class.temporary]
+ 12.3 [class.conv]
+ 12.3.1 [class.conv.ctor]
+ 12.3.2 [class.conv.fct]
+ 12.4 [class.dtor]
+ 12.5 [class.free]
+ 12.6 [class.init]
+ 12.6.1 [class.expl.init]
+ 12.6.2 [class.base.init]
+ 12.7 [class.cdtor]
+ 12.8 [class.copy]
+ 12.9 [class.inhctor]
+13 [over]
+ 13.1 [over.load]
+ 13.2 [over.dcl]
+ 13.3 [over.match]
+ 13.3.1 [over.match.funcs]
+ 13.3.1.1 [over.match.call]
+ 13.3.1.1.1 [over.call.func]
+ 13.3.1.1.2 [over.call.object]
+ 13.3.1.2 [over.match.oper]
+ 13.3.1.3 [over.match.ctor]
+ 13.3.1.4 [over.match.copy]
+ 13.3.1.5 [over.match.conv]
+ 13.3.1.6 [over.match.ref]
+ 13.3.1.7 [over.match.list]
+ 13.3.2 [over.match.viable]
+ 13.3.3 [over.match.best]
+ 13.3.3.1 [over.best.ics]
+ 13.3.3.1.1 [over.ics.scs]
+ 13.3.3.1.2 [over.ics.user]
+ 13.3.3.1.3 [over.ics.ellipsis]
+ 13.3.3.1.4 [over.ics.ref]
+ 13.3.3.1.5 [over.ics.list]
+ 13.3.3.2 [over.ics.rank]
+ 13.4 [over.over]
+ 13.5 [over.oper]
+ 13.5.1 [over.unary]
+ 13.5.2 [over.binary]
+ 13.5.3 [over.ass]
+ 13.5.4 [over.call]
+ 13.5.5 [over.sub]
+ 13.5.6 [over.ref]
+ 13.5.7 [over.inc]
+ 13.5.8 [over.literal]
+ 13.6 [over.built]
+14 [temp]
+ 14.1 [temp.export]
+ 14.2 [temp.param]
+ 14.3 [temp.names]
+ 14.4 [temp.arg]
+ 14.4.1 [temp.arg.type]
+ 14.4.2 [temp.arg.nontype]
+ 14.4.3 [temp.arg.template]
+ 14.5 [temp.type]
+ 14.6 [temp.decls]
+ 14.6.1 [temp.class]
+ 14.6.1.1 [temp.mem.func]
+ 14.6.1.2 [temp.mem.class]
+ 14.6.1.3 [temp.static]
+ 14.6.2 [temp.mem]
+ 14.6.3 [temp.variadic]
+ 14.6.4 [temp.friend]
+ 14.6.5 [temp.class.spec]
+ 14.6.5.1 [temp.class.spec.match]
+ 14.6.5.2 [temp.class.order]
+ 14.6.5.3 [temp.class.spec.mfunc]
+ 14.6.6 [temp.fct]
+ 14.6.6.1 [temp.over.link]
+ 14.6.6.2 [temp.func.order]
+ 14.6.7 [temp.alias]
+ 14.6.8 [temp.concept.map]
+ 14.7 [temp.res]
+ 14.7.1 [temp.local]
+ 14.7.2 [temp.dep]
+ 14.7.2.1 [temp.dep.type]
+ 14.7.2.2 [temp.dep.expr]
+ 14.7.2.3 [temp.dep.constexpr]
+ 14.7.2.4 [temp.dep.temp]
+ 14.7.3 [temp.nondep]
+ 14.7.4 [temp.dep.res]
+ 14.7.4.1 [temp.point]
+ 14.7.4.2 [temp.dep.candidate]
+ 14.7.5 [temp.inject]
+ 14.8 [temp.spec]
+ 14.8.1 [temp.inst]
+ 14.8.2 [temp.explicit]
+ 14.8.3 [temp.expl.spec]
+ 14.9 [temp.fct.spec]
+ 14.9.1 [temp.arg.explicit]
+ 14.9.2 [temp.deduct]
+ 14.9.2.1 [temp.deduct.call]
+ 14.9.2.2 [temp.deduct.funcaddr]
+ 14.9.2.3 [temp.deduct.conv]
+ 14.9.2.4 [temp.deduct.partial]
+ 14.9.2.5 [temp.deduct.type]
+ 14.9.3 [temp.over]
+ 14.10 [concept]
+ 14.10.1 [concept.def]
+ 14.10.1.1 [concept.fct]
+ 14.10.1.2 [concept.assoc]
+ 14.10.1.3 [concept.req]
+ 14.10.1.4 [concept.axiom]
+ 14.10.2 [concept.map]
+ 14.10.2.1 [concept.map.fct]
+ 14.10.2.2 [concept.map.assoc]
+ 14.10.3 [concept.refine]
+ 14.10.3.1 [concept.member.lookup]
+ 14.10.3.2 [concept.refine.maps]
+ 14.10.4 [concept.support]
+ 14.11 [temp.constrained]
+ 14.11.1 [temp.req]
+ 14.11.1.1 [temp.req.sat]
+ 14.11.1.2 [temp.req.impl]
+ 14.11.2 [temp.archetype]
+ 14.11.2.1 [temp.archetype.assemble]
+ 14.11.3 [temp.constrained.set]
+ 14.11.4 [temp.constrained.inst]
+15 [except]
+ 15.1 [except.throw]
+ 15.2 [except.ctor]
+ 15.3 [except.handle]
+ 15.4 [except.spec]
+ 15.5 [except.special]
+ 15.5.1 [except.terminate]
+ 15.5.2 [except.unexpected]
+ 15.5.3 [except.uncaught]
+16 [cpp]
+ 16.1 [cpp.cond]
+ 16.2 [cpp.include]
+ 16.3 [cpp.replace]
+ 16.3.1 [cpp.subst]
+ 16.3.2 [cpp.stringize]
+ 16.3.3 [cpp.concat]
+ 16.3.4 [cpp.rescan]
+ 16.3.5 [cpp.scope]
+ 16.4 [cpp.line]
+ 16.5 [cpp.error]
+ 16.6 [cpp.pragma]
+ 16.7 [cpp.null]
+ 16.8 [cpp.predefined]
+ 16.9 [cpp.pragma.op]
+17 [library]
+ 17.1 [library.general]
+ 17.2 [library.c]
+ 17.3 [definitions]
+ 17.3.1 [defns.arbitrary.stream]
+ 17.3.2 [defns.blocked]
+ 17.3.3 [defns.character]
+ 17.3.4 [defns.character.container]
+ 17.3.5 [defns.comparison]
+ 17.3.6 [defns.component]
+ 17.3.7 [defns.deadlock]
+ 17.3.8 [defns.default.behavior]
+ 17.3.9 [defns.handler]
+ 17.3.10 [defns.iostream.templates]
+ 17.3.11 [defns.modifier]
+ 17.3.12 [defns.move.assign]
+ 17.3.13 [defns.move.assign.op]
+ 17.3.14 [defns.move.ctor]
+ 17.3.15 [defns.obj.state]
+ 17.3.16 [defns.ntcts]
+ 17.3.17 [defns.observer]
+ 17.3.18 [defns.replacement]
+ 17.3.19 [defns.repositional.stream]
+ 17.3.20 [defns.required.behavior]
+ 17.3.21 [defns.reserved.function]
+ 17.3.22 [defns.stable]
+ 17.3.23 [defns.traits]
+ 17.4 [defns.additional]
+ 17.5 [description]
+ 17.5.1 [structure]
+ 17.5.1.1 [structure.elements]
+ 17.5.1.2 [structure.summary]
+ 17.5.1.3 [structure.requirements]
+ 17.5.1.4 [structure.specifications]
+ 17.5.1.5 [structure.see.also]
+ 17.5.2 [conventions]
+ 17.5.2.1 [type.descriptions]
+ 17.5.2.1.1 [type.descriptions.general]
+ 17.5.2.1.2 [enumerated.types]
+ 17.5.2.1.3 [bitmask.types]
+ 17.5.2.1.4 [character.seq]
+ 17.5.2.1.4.1 [byte.strings]
+ 17.5.2.1.4.2 [multibyte.strings]
+ 17.5.2.1.4.3 [char16_t.seq]
+ 17.5.2.1.4.4 [char32_t.seq]
+ 17.5.2.1.4.5 [wide.characters]
+ 17.5.2.2 [functions.within.classes]
+ 17.5.2.3 [objects.within.classes]
+ 17.6 [requirements]
+ 17.6.1 [organization]
+ 17.6.1.1 [contents]
+ 17.6.1.2 [headers]
+ 17.6.1.3 [compliance]
+ 17.6.2 [using]
+ 17.6.2.1 [using.overview]
+ 17.6.2.2 [using.headers]
+ 17.6.2.3 [using.linkage]
+ 17.6.3 [constraints]
+ 17.6.3.1 [constraints.overview]
+ 17.6.3.2 [namespace.constraints]
+ 17.6.3.2.1 [namespace.std]
+ 17.6.3.2.2 [namespace.posix]
+ 17.6.3.3 [reserved.names]
+ 17.6.3.3.1 [macro.names]
+ 17.6.3.3.2 [global.names]
+ 17.6.3.3.3 [extern.names]
+ 17.6.3.3.4 [extern.types]
+ 17.6.3.3.5 [usrlit.suffix]
+ 17.6.3.4 [alt.headers]
+ 17.6.3.5 [derived.classes]
+ 17.6.3.6 [replacement.functions]
+ 17.6.3.7 [handler.functions]
+ 17.6.3.8 [res.on.functions]
+ 17.6.3.9 [res.on.arguments]
+ 17.6.3.10 [res.on.objects]
+ 17.6.3.11 [res.on.required]
+ 17.6.4 [conforming]
+ 17.6.4.1 [conforming.overview]
+ 17.6.4.2 [res.on.headers]
+ 17.6.4.3 [res.on.macro.definitions]
+ 17.6.4.4 [global.functions]
+ 17.6.4.5 [member.functions]
+ 17.6.4.6 [reentrancy]
+ 17.6.4.7 [res.on.data.races]
+ 17.6.4.8 [protection.within.classes]
+ 17.6.4.9 [derivation]
+ 17.6.4.10 [res.on.exception.handling]
+ 17.6.4.11 [res.on.pointer.storage]
+ 17.6.4.12 [value.error.codes]
+18 [language.support]
+ 18.1 [support.general]
+ 18.2 [support.types]
+ 18.3 [support.limits]
+ 18.3.1 [limits]
+ 18.3.1.1 [numeric.limits]
+ 18.3.1.2 [numeric.limits.members]
+ 18.3.1.3 [round.style]
+ 18.3.1.4 [denorm.style]
+ 18.3.1.5 [numeric.special]
+ 18.3.2 [c.limits]
+ 18.4 [cstdint]
+ 18.4.1 [cstdint.syn]
+ 18.4.2 [stdinth]
+ 18.5 [support.start.term]
+ 18.6 [support.dynamic]
+ 18.6.1 [new.delete]
+ 18.6.1.1 [new.delete.single]
+ 18.6.1.2 [new.delete.array]
+ 18.6.1.3 [new.delete.placement]
+ 18.6.1.4 [new.delete.dataraces]
+ 18.6.2 [alloc.errors]
+ 18.6.2.1 [bad.alloc]
+ 18.6.2.2 [new.handler]
+ 18.6.2.3 [set.new.handler]
+ 18.7 [support.rtti]
+ 18.7.1 [type.info]
+ 18.7.2 [type.index]
+ 18.7.2.1 [type.index.overview]
+ 18.7.2.2 [type.index.members]
+ 18.7.2.3 [type.index.templ]
+ 18.7.3 [bad.cast]
+ 18.7.4 [bad.typeid]
+ 18.8 [support.exception]
+ 18.8.1 [exception]
+ 18.8.2 [exception.unexpected]
+ 18.8.2.1 [bad.exception]
+ 18.8.2.2 [unexpected.handler]
+ 18.8.2.3 [set.unexpected]
+ 18.8.2.4 [unexpected]
+ 18.8.3 [exception.terminate]
+ 18.8.3.1 [terminate.handler]
+ 18.8.3.2 [set.terminate]
+ 18.8.3.3 [terminate]
+ 18.8.4 [uncaught]
+ 18.8.5 [propagation]
+ 18.8.6 [except.nested]
+ 18.9 [support.initlist]
+ 18.9.1 [support.initlist.cons]
+ 18.9.2 [support.initlist.access]
+ 18.9.3 [support.initlist.concept]
+ 18.10 [support.runtime]
+19 [diagnostics]
+ 19.1 [diagnostics.general]
+ 19.2 [std.exceptions]
+ 19.2.1 [logic.error]
+ 19.2.2 [domain.error]
+ 19.2.3 [invalid.argument]
+ 19.2.4 [length.error]
+ 19.2.5 [out.of.range]
+ 19.2.6 [runtime.error]
+ 19.2.7 [range.error]
+ 19.2.8 [overflow.error]
+ 19.2.9 [underflow.error]
+ 19.3 [assertions]
+ 19.4 [errno]
+ 19.5 [syserr]
+ 19.5.1 [syserr.errcat]
+ 19.5.1.1 [syserr.errcat.overview]
+ 19.5.1.2 [syserr.errcat.virtuals]
+ 19.5.1.3 [syserr.errcat.nonvirtuals]
+ 19.5.1.4 [syserr.errcat.derived]
+ 19.5.1.5 [syserr.errcat.objects]
+ 19.5.2 [syserr.errcode]
+ 19.5.2.1 [syserr.errcodeenum]
+ 19.5.2.2 [syserr.errcode.overview]
+ 19.5.2.3 [syserr.errcode.constructors]
+ 19.5.2.4 [syserr.errcode.modifiers]
+ 19.5.2.5 [syserr.errcode.observers]
+ 19.5.2.6 [syserr.errcode.nonmembers]
+ 19.5.3 [syserr.errcondition]
+ 19.5.3.1 [syserr.errcondenum]
+ 19.5.3.2 [syserr.errcondition.overview]
+ 19.5.3.3 [syserr.errcondition.constructors]
+ 19.5.3.4 [syserr.errcondition.modifiers]
+ 19.5.3.5 [syserr.errcondition.observers]
+ 19.5.3.6 [syserr.errcondition.nonmembers]
+ 19.5.4 [syserr.compare]
+ 19.5.5 [syserr.syserr]
+ 19.5.5.1 [syserr.syserr.overview]
+ 19.5.5.2 [syserr.syserr.members]
+20 [utilities]
+ 20.1 [utilities.general]
+ 20.2 [utility.concepts]
+ 20.2.1 [concept.transform]
+ 20.2.2 [concept.true]
+ 20.2.3 [concept.classify]
+ 20.2.4 [concept.operator]
+ 20.2.5 [concept.predicate]
+ 20.2.6 [concept.comparison]
+ 20.2.7 [concept.construct]
+ 20.2.8 [concept.destruct]
+ 20.2.9 [concept.copymove]
+ 20.2.10 [concept.memory]
+ 20.2.11 [concept.regular]
+ 20.2.12 [concept.convertible]
+ 20.2.13 [concept.arithmetic]
+ 20.3 [utility]
+ 20.3.1 [operators]
+ 20.3.2 [forward]
+ 20.3.3 [pairs]
+ 20.3.4 [pair.astuple]
+ 20.3.5 [pair.concepts]
+ 20.3.6 [template.bitset]
+ 20.3.6.1 [bitset.cons]
+ 20.3.6.2 [bitset.members]
+ 20.3.6.3 [bitset.operators]
+ 20.4 [ratio]
+ 20.4.1 [ratio.ratio]
+ 20.4.2 [ratio.arithmetic]
+ 20.4.3 [ratio.comparison]
+ 20.4.4 [ratio.si]
+ 20.5 [tuple]
+ 20.5.1 [tuple.general]
+ 20.5.2 [tuple.tuple]
+ 20.5.2.1 [tuple.cnstr]
+ 20.5.2.2 [tuple.creation]
+ 20.5.2.3 [tuple.helper]
+ 20.5.2.4 [tuple.elem]
+ 20.5.2.5 [tuple.rel]
+ 20.5.2.6 [tuple.swap]
+ 20.5.2.7 [tuple.special]
+ 20.5.2.8 [tuple.concepts]
+ 20.6 [meta]
+ 20.6.1 [meta.rqmts]
+ 20.6.2 [meta.type.synop]
+ 20.6.3 [meta.help]
+ 20.6.4 [meta.unary]
+ 20.6.4.1 [meta.unary.cat]
+ 20.6.4.2 [meta.unary.comp]
+ 20.6.4.3 [meta.unary.prop]
+ 20.6.5 [meta.rel]
+ 20.6.6 [meta.trans]
+ 20.6.6.1 [meta.trans.cv]
+ 20.6.6.2 [meta.trans.ref]
+ 20.6.6.3 [meta.trans.sign]
+ 20.6.6.4 [meta.trans.arr]
+ 20.6.6.5 [meta.trans.ptr]
+ 20.6.7 [meta.trans.other]
+ 20.7 [function.objects]
+ 20.7.1 [func.def]
+ 20.7.2 [func.require]
+ 20.7.3 [base]
+ 20.7.4 [func.ret]
+ 20.7.5 [refwrap]
+ 20.7.5.1 [refwrap.const]
+ 20.7.5.2 [refwrap.assign]
+ 20.7.5.3 [refwrap.access]
+ 20.7.5.4 [refwrap.invoke]
+ 20.7.5.5 [refwrap.helpers]
+ 20.7.6 [identity.operation]
+ 20.7.7 [arithmetic.operations]
+ 20.7.8 [comparisons]
+ 20.7.9 [logical.operations]
+ 20.7.10 [bitwise.operations]
+ 20.7.11 [negators]
+ 20.7.12 [bind]
+ 20.7.12.1 [func.bind]
+ 20.7.12.1.1 [func.bind.isbind]
+ 20.7.12.1.2 [func.bind.isplace]
+ 20.7.12.1.3 [func.bind.bind]
+ 20.7.12.1.4 [func.bind.place]
+ 20.7.13 [function.pointer.adaptors]
+ 20.7.14 [member.pointer.adaptors]
+ 20.7.15 [func.memfn]
+ 20.7.16 [func.wrap]
+ 20.7.16.1 [func.wrap.badcall]
+ 20.7.16.1.1 [func.wrap.badcall.const]
+ 20.7.16.2 [func.wrap.func]
+ 20.7.16.2.1 [func.wrap.func.con]
+ 20.7.16.2.2 [func.wrap.func.mod]
+ 20.7.16.2.3 [func.wrap.func.cap]
+ 20.7.16.2.4 [func.wrap.func.inv]
+ 20.7.16.2.5 [func.wrap.func.targ]
+ 20.7.16.2.6 [func.wrap.func.nullptr]
+ 20.7.16.2.7 [func.wrap.func.alg]
+ 20.7.17 [unord.hash]
+ 20.8 [memory]
+ 20.8.1 [allocator.tag]
+ 20.8.2 [allocator]
+ 20.8.2.1 [allocator.general]
+ 20.8.2.2 [allocator.concepts]
+ 20.8.2.3 [allocator.concepts.legacy]
+ 20.8.2.4 [allocator.concepts.members]
+ 20.8.3 [allocator.element.concepts]
+ 20.8.4 [default.allocator]
+ 20.8.4.1 [allocator.members]
+ 20.8.4.2 [allocator.globals]
+ 20.8.5 [allocator.adaptor]
+ 20.8.5.1 [allocator.adaptor.base]
+ 20.8.5.2 [allocator.adaptor.cntr]
+ 20.8.5.3 [allocator.adaptor2.cntr]
+ 20.8.5.4 [allocator.adaptor.members]
+ 20.8.5.5 [allocator.adaptor.globals]
+ 20.8.6 [storage.iterator]
+ 20.8.7 [temporary.buffer]
+ 20.8.8 [specialized.algorithms]
+ 20.8.8.1 [object.addressof]
+ 20.8.8.2 [uninitialized.copy]
+ 20.8.8.3 [uninitialized.fill]
+ 20.8.8.4 [uninitialized.fill.n]
+ 20.8.9 [unique.ptr]
+ 20.8.9.1 [unique.ptr.dltr]
+ 20.8.9.1.1 [unique.ptr.dltr.dflt]
+ 20.8.9.1.2 [unique.ptr.dltr.dflt1]
+ 20.8.9.2 [unique.ptr.single]
+ 20.8.9.2.1 [unique.ptr.single.ctor]
+ 20.8.9.2.2 [unique.ptr.single.dtor]
+ 20.8.9.2.3 [unique.ptr.single.asgn]
+ 20.8.9.2.4 [unique.ptr.single.observers]
+ 20.8.9.2.5 [unique.ptr.single.modifiers]
+ 20.8.9.3 [unique.ptr.runtime]
+ 20.8.9.3.1 [unique.ptr.runtime.ctor]
+ 20.8.9.3.2 [unique.ptr.runtime.observers]
+ 20.8.9.3.3 [unique.ptr.runtime.modifiers]
+ 20.8.9.4 [unique.ptr.special]
+ 20.8.10 [util.smartptr]
+ 20.8.10.1 [util.smartptr.weakptr]
+ 20.8.10.2 [util.smartptr.shared]
+ 20.8.10.2.1 [util.smartptr.shared.const]
+ 20.8.10.2.2 [util.smartptr.shared.dest]
+ 20.8.10.2.3 [util.smartptr.shared.assign]
+ 20.8.10.2.4 [util.smartptr.shared.mod]
+ 20.8.10.2.5 [util.smartptr.shared.obs]
+ 20.8.10.2.6 [util.smartptr.shared.create]
+ 20.8.10.2.7 [util.smartptr.shared.cmp]
+ 20.8.10.2.8 [util.smartptr.shared.io]
+ 20.8.10.2.9 [util.smartptr.shared.spec]
+ 20.8.10.2.10 [util.smartptr.shared.cast]
+ 20.8.10.2.11 [util.smartptr.getdeleter]
+ 20.8.10.3 [util.smartptr.weak]
+ 20.8.10.3.1 [util.smartptr.weak.const]
+ 20.8.10.3.2 [util.smartptr.weak.dest]
+ 20.8.10.3.3 [util.smartptr.weak.assign]
+ 20.8.10.3.4 [util.smartptr.weak.mod]
+ 20.8.10.3.5 [util.smartptr.weak.obs]
+ 20.8.10.3.6 [util.smartptr.weak.spec]
+ 20.8.10.4 [util.smartptr.ownerless]
+ 20.8.10.5 [util.smartptr.enab]
+ 20.8.10.6 [util.smartptr.shared.atomic]
+ 20.8.10.7 [util.dynamic.safety]
+ 20.8.11 [ptr.align]
+ 20.8.12 [c.malloc]
+ 20.9 [time]
+ 20.9.1 [time.clock.req]
+ 20.9.2 [time.traits]
+ 20.9.2.1 [time.traits.is_fp]
+ 20.9.2.2 [time.traits.duration_values]
+ 20.9.2.3 [time.traits.specializations]
+ 20.9.3 [time.duration]
+ 20.9.3.1 [time.duration.cons]
+ 20.9.3.2 [time.duration.observer]
+ 20.9.3.3 [time.duration.arithmetic]
+ 20.9.3.4 [time.duration.special]
+ 20.9.3.5 [time.duration.nonmember]
+ 20.9.3.6 [time.duration.comparisons]
+ 20.9.3.7 [time.duration.cast]
+ 20.9.4 [time.point]
+ 20.9.4.1 [time.point.cons]
+ 20.9.4.2 [time.point.observer]
+ 20.9.4.3 [time.point.arithmetic]
+ 20.9.4.4 [time.point.special]
+ 20.9.4.5 [time.point.nonmember]
+ 20.9.4.6 [time.point.comparisons]
+ 20.9.4.7 [time.point.cast]
+ 20.9.5 [time.clock]
+ 20.9.5.1 [time.clock.system]
+ 20.9.5.2 [time.clock.monotonic]
+ 20.9.5.3 [time.clock.hires]
+ 20.10 [date.time]
+21 [strings]
+ 21.1 [strings.general]
+ 21.2 [char.traits]
+ 21.2.1 [char.traits.require]
+ 21.2.2 [char.traits.typedefs]
+ 21.2.3 [char.traits.specializations]
+ 21.2.3.1 [char.traits.specializations.char]
+ 21.2.3.2 [char.traits.specializations.char16_t]
+ 21.2.3.3 [char.traits.specializations.char32_t]
+ 21.2.3.4 [char.traits.specializations.wchar.t]
+ 21.3 [string.classes]
+ 21.4 [basic.string]
+ 21.4.1 [string.require]
+ 21.4.2 [string.cons]
+ 21.4.3 [string.iterators]
+ 21.4.4 [string.capacity]
+ 21.4.5 [string.access]
+ 21.4.6 [string.modifiers]
+ 21.4.6.1 [string::op+=]
+ 21.4.6.2 [string::append]
+ 21.4.6.3 [string::assign]
+ 21.4.6.4 [string::insert]
+ 21.4.6.5 [string::erase]
+ 21.4.6.6 [string::replace]
+ 21.4.6.7 [string::copy]
+ 21.4.6.8 [string::swap]
+ 21.4.7 [string.ops]
+ 21.4.7.1 [string.accessors]
+ 21.4.7.2 [string::find]
+ 21.4.7.3 [string::rfind]
+ 21.4.7.4 [string::find.first.of]
+ 21.4.7.5 [string::find.last.of]
+ 21.4.7.6 [string::find.first.not.of]
+ 21.4.7.7 [string::find.last.not.of]
+ 21.4.7.8 [string::substr]
+ 21.4.7.9 [string::compare]
+ 21.4.8 [string.nonmembers]
+ 21.4.8.1 [string::op+]
+ 21.4.8.2 [string::operator==]
+ 21.4.8.3 [string::op!=]
+ 21.4.8.4 [string::op&lt;]
+ 21.4.8.5 [string::op&gt;]
+ 21.4.8.6 [string::op&lt;=]
+ 21.4.8.7 [string::op&gt;=]
+ 21.4.8.8 [string.special]
+ 21.4.8.9 [string.io]
+ 21.5 [string.conversions]
+ 21.6 [c.strings]
+22 [localization]
+ 22.1 [localization.general]
+ 22.2 [locale.syn]
+ 22.3 [locales]
+ 22.3.1 [locale]
+ 22.3.1.1 [locale.types]
+ 22.3.1.1.1 [locale.category]
+ 22.3.1.1.2 [locale.facet]
+ 22.3.1.1.3 [locale.id]
+ 22.3.1.2 [locale.cons]
+ 22.3.1.3 [locale.members]
+ 22.3.1.4 [locale.operators]
+ 22.3.1.5 [locale.statics]
+ 22.3.2 [locale.global.templates]
+ 22.3.3 [locale.convenience]
+ 22.3.3.1 [classification]
+ 22.3.3.2 [conversions]
+ 22.3.3.2.1 [conversions.character]
+ 22.3.3.2.2 [conversions.string]
+ 22.3.3.2.3 [conversions.buffer]
+ 22.4 [locale.categories]
+ 22.4.1 [category.ctype]
+ 22.4.1.1 [locale.ctype]
+ 22.4.1.1.1 [locale.ctype.members]
+ 22.4.1.1.2 [locale.ctype.virtuals]
+ 22.4.1.2 [locale.ctype.byname]
+ 22.4.1.3 [facet.ctype.special]
+ 22.4.1.3.1 [facet.ctype.char.dtor]
+ 22.4.1.3.2 [facet.ctype.char.members]
+ 22.4.1.3.3 [facet.ctype.char.statics]
+ 22.4.1.3.4 [facet.ctype.char.virtuals]
+ 22.4.1.4 [locale.codecvt]
+ 22.4.1.4.1 [locale.codecvt.members]
+ 22.4.1.4.2 [locale.codecvt.virtuals]
+ 22.4.1.5 [locale.codecvt.byname]
+ 22.4.2 [category.numeric]
+ 22.4.2.1 [locale.num.get]
+ 22.4.2.1.1 [facet.num.get.members]
+ 22.4.2.1.2 [facet.num.get.virtuals]
+ 22.4.2.2 [locale.nm.put]
+ 22.4.2.2.1 [facet.num.put.members]
+ 22.4.2.2.2 [facet.num.put.virtuals]
+ 22.4.3 [facet.numpunct]
+ 22.4.3.1 [locale.numpunct]
+ 22.4.3.1.1 [facet.numpunct.members]
+ 22.4.3.1.2 [facet.numpunct.virtuals]
+ 22.4.3.2 [locale.numpunct.byname]
+ 22.4.4 [category.collate]
+ 22.4.4.1 [locale.collate]
+ 22.4.4.1.1 [locale.collate.members]
+ 22.4.4.1.2 [locale.collate.virtuals]
+ 22.4.4.2 [locale.collate.byname]
+ 22.4.5 [category.time]
+ 22.4.5.1 [locale.time.get]
+ 22.4.5.1.1 [locale.time.get.members]
+ 22.4.5.1.2 [locale.time.get.virtuals]
+ 22.4.5.2 [locale.time.get.byname]
+ 22.4.5.3 [locale.time.put]
+ 22.4.5.3.1 [locale.time.put.members]
+ 22.4.5.3.2 [locale.time.put.virtuals]
+ 22.4.5.4 [locale.time.put.byname]
+ 22.4.6 [category.monetary]
+ 22.4.6.1 [locale.money.get]
+ 22.4.6.1.1 [locale.money.get.members]
+ 22.4.6.1.2 [locale.money.get.virtuals]
+ 22.4.6.2 [locale.money.put]
+ 22.4.6.2.1 [locale.money.put.members]
+ 22.4.6.2.2 [locale.money.put.virtuals]
+ 22.4.6.3 [locale.moneypunct]
+ 22.4.6.3.1 [locale.moneypunct.members]
+ 22.4.6.3.2 [locale.moneypunct.virtuals]
+ 22.4.6.4 [locale.moneypunct.byname]
+ 22.4.7 [category.messages]
+ 22.4.7.1 [locale.messages]
+ 22.4.7.1.1 [locale.messages.members]
+ 22.4.7.1.2 [locale.messages.virtuals]
+ 22.4.7.2 [locale.messages.byname]
+ 22.4.8 [facets.examples]
+ 22.5 [locale.stdcvt]
+ 22.6 [c.locales]
+23 [containers]
+ 23.1 [containers.general]
+ 23.2 [container.requirements]
+ 23.2.1 [container.requirements.general]
+ 23.2.2 [container.requirements.dataraces]
+ 23.2.3 [sequence.reqmts]
+ 23.2.4 [associative.reqmts]
+ 23.2.4.1 [associative.reqmts.except]
+ 23.2.5 [unord.req]
+ 23.2.5.1 [unord.req.except]
+ 23.2.6 [container.concepts]
+ 23.2.6.1 [container.concepts.free]
+ 23.2.6.2 [container.concepts.member]
+ 23.2.6.3 [container.concepts.maps]
+ 23.3 [sequences]
+ 23.3.1 [array]
+ 23.3.1.1 [array.cons]
+ 23.3.1.2 [array.special]
+ 23.3.1.3 [array.size]
+ 23.3.1.4 [array.data]
+ 23.3.1.5 [array.fill]
+ 23.3.1.6 [array.zero]
+ 23.3.1.7 [array.tuple]
+ 23.3.2 [deque]
+ 23.3.2.1 [deque.cons]
+ 23.3.2.2 [deque.capacity]
+ 23.3.2.3 [deque.modifiers]
+ 23.3.2.4 [deque.special]
+ 23.3.3 [forwardlist]
+ 23.3.3.1 [forwardlist.cons]
+ 23.3.3.2 [forwardlist.iter]
+ 23.3.3.3 [forwardlist.access]
+ 23.3.3.4 [forwardlist.modifiers]
+ 23.3.3.5 [forwardlist.ops]
+ 23.3.3.6 [forwardlist.spec]
+ 23.3.4 [list]
+ 23.3.4.1 [list.cons]
+ 23.3.4.2 [list.capacity]
+ 23.3.4.3 [list.modifiers]
+ 23.3.4.4 [list.ops]
+ 23.3.4.5 [list.special]
+ 23.3.5 [container.adaptors]
+ 23.3.5.1 [queue]
+ 23.3.5.1.1 [queue.defn]
+ 23.3.5.1.2 [queue.ops]
+ 23.3.5.1.3 [queue.special]
+ 23.3.5.2 [priority.queue]
+ 23.3.5.2.1 [priqueue.cons]
+ 23.3.5.2.2 [priqueue.members]
+ 23.3.5.2.3 [priqueue.special]
+ 23.3.5.3 [stack]
+ 23.3.5.3.1 [stack.defn]
+ 23.3.5.3.2 [stack.ops]
+ 23.3.5.3.3 [stack.special]
+ 23.3.6 [vector]
+ 23.3.6.1 [vector.cons]
+ 23.3.6.2 [vector.capacity]
+ 23.3.6.3 [vector.data]
+ 23.3.6.4 [vector.modifiers]
+ 23.3.6.5 [vector.special]
+ 23.3.7 [vector.bool]
+ 23.4 [associative]
+ 23.4.1 [map]
+ 23.4.1.1 [map.cons]
+ 23.4.1.2 [map.access]
+ 23.4.1.3 [map.modifiers]
+ 23.4.1.4 [map.ops]
+ 23.4.1.5 [map.special]
+ 23.4.2 [multimap]
+ 23.4.2.1 [multimap.cons]
+ 23.4.2.2 [multimap.modifiers]
+ 23.4.2.3 [multimap.ops]
+ 23.4.2.4 [multimap.special]
+ 23.4.3 [set]
+ 23.4.3.1 [set.cons]
+ 23.4.3.2 [set.special]
+ 23.4.4 [multiset]
+ 23.4.4.1 [multiset.cons]
+ 23.4.4.2 [multiset.special]
+ 23.5 [unord]
+ 23.5.1 [unord.map]
+ 23.5.1.1 [unord.map.cnstr]
+ 23.5.1.2 [unord.map.elem]
+ 23.5.1.3 [unord.map.swap]
+ 23.5.2 [unord.multimap]
+ 23.5.2.1 [unord.multimap.cnstr]
+ 23.5.2.2 [unord.multimap.swap]
+ 23.5.3 [unord.set]
+ 23.5.3.1 [unord.set.cnstr]
+ 23.5.3.2 [unord.set.swap]
+ 23.5.4 [unord.multiset]
+ 23.5.4.1 [unord.multiset.cnstr]
+ 23.5.4.2 [unord.multiset.swap]
+24 [iterators]
+ 24.1 [iterators.general]
+ 24.2 [iterator.concepts]
+ 24.2.1 [iterator.iterators]
+ 24.2.2 [input.iterators]
+ 24.2.3 [output.iterators]
+ 24.2.4 [forward.iterators]
+ 24.2.5 [bidirectional.iterators]
+ 24.2.6 [random.access.iterators]
+ 24.2.7 [shuffle.iterators]
+ 24.2.8 [iterator.concepts.range]
+ 24.3 [iterator.syn]
+ 24.4 [iterator.operations]
+ 24.5 [predef.iterators]
+ 24.5.1 [reverse.iterators]
+ 24.5.1.1 [reverse.iterator]
+ 24.5.1.2 [reverse.iter.ops]
+ 24.5.1.2.1 [reverse.iter.cons]
+ 24.5.1.2.2 [reverse.iter.op=]
+ 24.5.1.2.3 [reverse.iter.conv]
+ 24.5.1.2.4 [reverse.iter.op.star]
+ 24.5.1.2.5 [reverse.iter.opref]
+ 24.5.1.2.6 [reverse.iter.op++]
+ 24.5.1.2.7 [reverse.iter.op--]
+ 24.5.1.2.8 [reverse.iter.op+]
+ 24.5.1.2.9 [reverse.iter.op+=]
+ 24.5.1.2.10 [reverse.iter.op-]
+ 24.5.1.2.11 [reverse.iter.op-=]
+ 24.5.1.2.12 [reverse.iter.opindex]
+ 24.5.1.2.13 [reverse.iter.op==]
+ 24.5.1.2.14 [reverse.iter.op&lt;]
+ 24.5.1.2.15 [reverse.iter.op!=]
+ 24.5.1.2.16 [reverse.iter.op&gt;]
+ 24.5.1.2.17 [reverse.iter.op&gt;=]
+ 24.5.1.2.18 [reverse.iter.op&lt;=]
+ 24.5.1.2.19 [reverse.iter.opdiff]
+ 24.5.1.2.20 [reverse.iter.opsum]
+ 24.5.1.3 [reverse.iter.maps]
+ 24.5.2 [move.iterators]
+ 24.5.2.1 [move.iterator]
+ 24.5.2.2 [move.iter.ops]
+ 24.5.2.2.1 [move.iter.op.const]
+ 24.5.2.2.2 [move.iter.op=]
+ 24.5.2.2.3 [move.iter.op.conv]
+ 24.5.2.2.4 [move.iter.op.star]
+ 24.5.2.2.5 [move.iter.op.ref]
+ 24.5.2.2.6 [move.iter.op.incr]
+ 24.5.2.2.7 [move.iter.op.decr]
+ 24.5.2.2.8 [move.iter.op.+]
+ 24.5.2.2.9 [move.iter.op.+=]
+ 24.5.2.2.10 [move.iter.op.-]
+ 24.5.2.2.11 [move.iter.op.-=]
+ 24.5.2.2.12 [move.iter.op.index]
+ 24.5.2.2.13 [move.iter.op.comp]
+ 24.5.2.2.14 [move.iter.nonmember]
+ 24.5.2.2.15 [move.iter.maps]
+ 24.6 [stream.iterators]
+ 24.6.1 [istream.iterator]
+ 24.6.1.1 [istream.iterator.cons]
+ 24.6.1.2 [istream.iterator.ops]
+ 24.6.2 [ostream.iterator]
+ 24.6.2.1 [ostream.iterator.cons.des]
+ 24.6.2.2 [ostream.iterator.ops]
+ 24.6.3 [istreambuf.iterator]
+ 24.6.3.1 [istreambuf.iterator::proxy]
+ 24.6.3.2 [istreambuf.iterator.cons]
+ 24.6.3.3 [istreambuf.iterator::op*]
+ 24.6.3.4 [istreambuf.iterator::op++]
+ 24.6.3.5 [istreambuf.iterator::equal]
+ 24.6.3.6 [istreambuf.iterator::op==]
+ 24.6.3.7 [istreambuf.iterator::op!=]
+ 24.6.4 [ostreambuf.iterator]
+ 24.6.4.1 [ostreambuf.iter.cons]
+ 24.6.4.2 [ostreambuf.iter.ops]
+ 24.7 [insert.iterators]
+ 24.7.1 [back.insert.iterator]
+ 24.7.2 [back.insert.iter.ops]
+ 24.7.2.1 [back.insert.iter.cons]
+ 24.7.2.2 [back.insert.iter.op=]
+ 24.7.2.3 [back.insert.iter.op*]
+ 24.7.2.4 [back.insert.iter.op++]
+ 24.7.2.5 [back.inserter]
+ 24.7.2.6 [back.insert.iter.maps]
+ 24.7.3 [front.insert.iterator]
+ 24.7.4 [front.insert.iter.ops]
+ 24.7.4.1 [front.insert.iter.cons]
+ 24.7.4.2 [front.insert.iter.op=]
+ 24.7.4.3 [front.insert.iter.op*]
+ 24.7.4.4 [front.insert.iter.op++]
+ 24.7.4.5 [front.inserter]
+ 24.7.4.6 [front.insert.iter.maps]
+ 24.7.5 [insert.iterator]
+ 24.7.6 [insert.iter.ops]
+ 24.7.6.1 [insert.iter.cons]
+ 24.7.6.2 [insert.iter.op=]
+ 24.7.6.3 [insert.iter.op*]
+ 24.7.6.4 [insert.iter.op++]
+ 24.7.6.5 [inserter]
+ 24.7.6.6 [insert.iter.maps]
+25 [algorithms]
+ 25.1 [algorithms.general]
+ 25.2 [algorithms.syn]
+ 25.3 [alg.nonmodifying]
+ 25.3.1 [alg.all_of]
+ 25.3.2 [alg.any_of]
+ 25.3.3 [alg.none_of]
+ 25.3.4 [alg.foreach]
+ 25.3.5 [alg.find]
+ 25.3.6 [alg.find.end]
+ 25.3.7 [alg.find.first.of]
+ 25.3.8 [alg.adjacent.find]
+ 25.3.9 [alg.count]
+ 25.3.10 [mismatch]
+ 25.3.11 [alg.equal]
+ 25.3.12 [alg.search]
+ 25.4 [alg.modifying.operations]
+ 25.4.1 [alg.copy]
+ 25.4.2 [alg.move]
+ 25.4.3 [alg.swap]
+ 25.4.4 [alg.transform]
+ 25.4.5 [alg.replace]
+ 25.4.6 [alg.fill]
+ 25.4.7 [alg.generate]
+ 25.4.8 [alg.remove]
+ 25.4.9 [alg.unique]
+ 25.4.10 [alg.reverse]
+ 25.4.11 [alg.rotate]
+ 25.4.12 [alg.random.shuffle]
+ 25.4.13 [alg.partitions]
+ 25.5 [alg.sorting]
+ 25.5.1 [alg.sort]
+ 25.5.1.1 [sort]
+ 25.5.1.2 [stable.sort]
+ 25.5.1.3 [partial.sort]
+ 25.5.1.4 [partial.sort.copy]
+ 25.5.1.5 [is.sorted]
+ 25.5.2 [alg.nth.element]
+ 25.5.3 [alg.binary.search]
+ 25.5.3.1 [lower.bound]
+ 25.5.3.2 [upper.bound]
+ 25.5.3.3 [equal.range]
+ 25.5.3.4 [binary.search]
+ 25.5.4 [alg.merge]
+ 25.5.5 [alg.set.operations]
+ 25.5.5.1 [includes]
+ 25.5.5.2 [set.union]
+ 25.5.5.3 [set.intersection]
+ 25.5.5.4 [set.difference]
+ 25.5.5.5 [set.symmetric.difference]
+ 25.5.6 [alg.heap.operations]
+ 25.5.6.1 [push.heap]
+ 25.5.6.2 [pop.heap]
+ 25.5.6.3 [make.heap]
+ 25.5.6.4 [sort.heap]
+ 25.5.6.5 [is.heap]
+ 25.5.7 [alg.min.max]
+ 25.5.8 [alg.lex.comparison]
+ 25.5.9 [alg.permutation.generators]
+ 25.6 [alg.c.library]
+26 [numerics]
+ 26.1 [numerics.general]
+ 26.2 [numeric.requirements]
+ 26.3 [cfenv]
+ 26.3.1 [cfenv.syn]
+ 26.3.2 [fenv]
+ 26.4 [complex.numbers]
+ 26.4.1 [complex.syn]
+ 26.4.2 [complex]
+ 26.4.3 [complex.special]
+ 26.4.4 [complex.members]
+ 26.4.5 [complex.member.ops]
+ 26.4.6 [complex.ops]
+ 26.4.7 [complex.value.ops]
+ 26.4.8 [complex.transcendentals]
+ 26.4.9 [cmplx.over]
+ 26.4.10 [ccmplx]
+ 26.4.11 [cmplxh]
+ 26.5 [rand]
+ 26.5.1 [rand.synopsis]
+ 26.5.2 [rand.concept]
+ 26.5.2.1 [rand.concept.seedseq]
+ 26.5.2.2 [rand.concept.urng]
+ 26.5.2.3 [rand.concept.eng]
+ 26.5.2.4 [rand.concept.adapt]
+ 26.5.2.5 [rand.concept.dist]
+ 26.5.3 [rand.eng]
+ 26.5.3.1 [rand.eng.lcong]
+ 26.5.3.2 [rand.eng.mers]
+ 26.5.3.3 [rand.eng.sub]
+ 26.5.4 [rand.adapt]
+ 26.5.4.1 [rand.adapt.disc]
+ 26.5.4.2 [rand.adapt.ibits]
+ 26.5.4.3 [rand.adapt.shuf]
+ 26.5.5 [rand.predef]
+ 26.5.6 [rand.device]
+ 26.5.7 [rand.util]
+ 26.5.7.1 [rand.util.seedseq]
+ 26.5.7.2 [rand.util.canonical]
+ 26.5.8 [rand.dist]
+ 26.5.8.1 [rand.dist.uni]
+ 26.5.8.1.1 [rand.dist.uni.int]
+ 26.5.8.1.2 [rand.dist.uni.real]
+ 26.5.8.2 [rand.dist.bern]
+ 26.5.8.2.1 [rand.dist.bern.bernoulli]
+ 26.5.8.2.2 [rand.dist.bern.bin]
+ 26.5.8.2.3 [rand.dist.bern.geo]
+ 26.5.8.2.4 [rand.dist.bern.negbin]
+ 26.5.8.3 [rand.dist.pois]
+ 26.5.8.3.1 [rand.dist.pois.poisson]
+ 26.5.8.3.2 [rand.dist.pois.exp]
+ 26.5.8.3.3 [rand.dist.pois.gamma]
+ 26.5.8.3.4 [rand.dist.pois.weibull]
+ 26.5.8.3.5 [rand.dist.pois.extreme]
+ 26.5.8.4 [rand.dist.norm]
+ 26.5.8.4.1 [rand.dist.norm.normal]
+ 26.5.8.4.2 [rand.dist.norm.lognormal]
+ 26.5.8.4.3 [rand.dist.norm.chisq]
+ 26.5.8.4.4 [rand.dist.norm.cauchy]
+ 26.5.8.4.5 [rand.dist.norm.f]
+ 26.5.8.4.6 [rand.dist.norm.t]
+ 26.5.8.5 [rand.dist.samp]
+ 26.5.8.5.1 [rand.dist.samp.discrete]
+ 26.5.8.5.2 [rand.dist.samp.pconst]
+ 26.5.8.5.3 [rand.dist.samp.plinear]
+ 26.6 [numarray]
+ 26.6.1 [valarray.syn]
+ 26.6.2 [template.valarray]
+ 26.6.2.1 [valarray.cons]
+ 26.6.2.2 [valarray.assign]
+ 26.6.2.3 [valarray.access]
+ 26.6.2.4 [valarray.sub]
+ 26.6.2.5 [valarray.unary]
+ 26.6.2.6 [valarray.cassign]
+ 26.6.2.7 [valarray.members]
+ 26.6.3 [valarray.nonmembers]
+ 26.6.3.1 [valarray.binary]
+ 26.6.3.2 [valarray.comparison]
+ 26.6.3.3 [valarray.transcend]
+ 26.6.3.4 [valarray.special]
+ 26.6.4 [class.slice]
+ 26.6.4.1 [cons.slice]
+ 26.6.4.2 [slice.access]
+ 26.6.5 [template.slice.array]
+ 26.6.5.1 [slice.arr.assign]
+ 26.6.5.2 [slice.arr.comp.assign]
+ 26.6.5.3 [slice.arr.fill]
+ 26.6.6 [class.gslice]
+ 26.6.6.1 [gslice.cons]
+ 26.6.6.2 [gslice.access]
+ 26.6.7 [template.gslice.array]
+ 26.6.7.1 [gslice.array.assign]
+ 26.6.7.2 [gslice.array.comp.assign]
+ 26.6.7.3 [gslice.array.fill]
+ 26.6.8 [template.mask.array]
+ 26.6.8.1 [mask.array.assign]
+ 26.6.8.2 [mask.array.comp.assign]
+ 26.6.8.3 [mask.array.fill]
+ 26.6.9 [template.indirect.array]
+ 26.6.9.1 [indirect.array.assign]
+ 26.6.9.2 [indirect.array.comp.assign]
+ 26.6.9.3 [indirect.array.fill]
+ 26.6.9.4 [valarray.concepts]
+ 26.7 [numeric.ops]
+ 26.7.1 [accumulate]
+ 26.7.2 [inner.product]
+ 26.7.3 [partial.sum]
+ 26.7.4 [adjacent.difference]
+ 26.7.5 [numeric.iota]
+ 26.8 [c.math]
+27 [input.output]
+ 27.1 [input.output.general]
+ 27.2 [iostreams.requirements]
+ 27.2.1 [iostream.limits.imbue]
+ 27.2.2 [iostreams.limits.pos]
+ 27.2.3 [iostreams.threadsafety]
+ 27.3 [iostream.forward]
+ 27.4 [iostream.objects]
+ 27.4.1 [narrow.stream.objects]
+ 27.4.2 [wide.stream.objects]
+ 27.5 [iostreams.base]
+ 27.5.1 [stream.types]
+ 27.5.2 [ios.base]
+ 27.5.2.1 [ios.types]
+ 27.5.2.1.1 [ios::failure]
+ 27.5.2.1.2 [ios::fmtflags]
+ 27.5.2.1.3 [ios::iostate]
+ 27.5.2.1.4 [ios::openmode]
+ 27.5.2.1.5 [ios::seekdir]
+ 27.5.2.1.6 [ios::Init]
+ 27.5.2.2 [fmtflags.state]
+ 27.5.2.3 [ios.base.locales]
+ 27.5.2.4 [ios.members.static]
+ 27.5.2.5 [ios.base.storage]
+ 27.5.2.6 [ios.base.callback]
+ 27.5.2.7 [ios.base.cons]
+ 27.5.3 [fpos]
+ 27.5.3.1 [fpos.members]
+ 27.5.3.2 [fpos.operations]
+ 27.5.4 [ios]
+ 27.5.4.1 [basic.ios.cons]
+ 27.5.4.2 [basic.ios.members]
+ 27.5.4.3 [iostate.flags]
+ 27.5.5 [std.ios.manip]
+ 27.5.5.1 [fmtflags.manip]
+ 27.5.5.2 [adjustfield.manip]
+ 27.5.5.3 [basefield.manip]
+ 27.5.5.4 [floatfield.manip]
+ 27.5.5.5 [error.reporting]
+ 27.6 [stream.buffers]
+ 27.6.1 [streambuf.reqts]
+ 27.6.2 [streambuf]
+ 27.6.2.1 [streambuf.cons]
+ 27.6.2.2 [streambuf.members]
+ 27.6.2.2.1 [streambuf.locales]
+ 27.6.2.2.2 [streambuf.buffer]
+ 27.6.2.2.3 [streambuf.pub.get]
+ 27.6.2.2.4 [streambuf.pub.pback]
+ 27.6.2.2.5 [streambuf.pub.put]
+ 27.6.2.3 [streambuf.protected]
+ 27.6.2.3.1 [streambuf.assign]
+ 27.6.2.3.2 [streambuf.get.area]
+ 27.6.2.3.3 [streambuf.put.area]
+ 27.6.2.4 [streambuf.virtuals]
+ 27.6.2.4.1 [streambuf.virt.locales]
+ 27.6.2.4.2 [streambuf.virt.buffer]
+ 27.6.2.4.3 [streambuf.virt.get]
+ 27.6.2.4.4 [streambuf.virt.pback]
+ 27.6.2.4.5 [streambuf.virt.put]
+ 27.7 [iostream.format]
+ 27.7.1 [input.streams]
+ 27.7.1.1 [istream]
+ 27.7.1.1.1 [istream.cons]
+ 27.7.1.1.2 [istream.assign]
+ 27.7.1.1.3 [istream::sentry]
+ 27.7.1.2 [istream.formatted]
+ 27.7.1.2.1 [istream.formatted.reqmts]
+ 27.7.1.2.2 [istream.formatted.arithmetic]
+ 27.7.1.2.3 [istream::extractors]
+ 27.7.1.3 [istream.unformatted]
+ 27.7.1.4 [istream.manip]
+ 27.7.1.5 [iostreamclass]
+ 27.7.1.5.1 [iostream.cons]
+ 27.7.1.5.2 [iostream.dest]
+ 27.7.1.5.3 [iostream.assign]
+ 27.7.1.6 [istream.rvalue]
+ 27.7.2 [output.streams]
+ 27.7.2.1 [ostream]
+ 27.7.2.2 [ostream.cons]
+ 27.7.2.3 [ostream.assign]
+ 27.7.2.4 [ostream::sentry]
+ 27.7.2.5 [ostream.seeks]
+ 27.7.2.6 [ostream.formatted]
+ 27.7.2.6.1 [ostream.formatted.reqmts]
+ 27.7.2.6.2 [ostream.inserters.arithmetic]
+ 27.7.2.6.3 [ostream.inserters]
+ 27.7.2.6.4 [ostream.inserters.character]
+ 27.7.2.7 [ostream.unformatted]
+ 27.7.2.8 [ostream.manip]
+ 27.7.2.9 [ostream.rvalue]
+ 27.7.3 [std.manip]
+ 27.7.4 [ext.manip]
+ 27.8 [string.streams]
+ 27.8.1 [stringbuf]
+ 27.8.1.1 [stringbuf.cons]
+ 27.8.1.2 [stringbuf.assign]
+ 27.8.1.3 [stringbuf.members]
+ 27.8.1.4 [stringbuf.virtuals]
+ 27.8.2 [istringstream]
+ 27.8.2.1 [istringstream.cons]
+ 27.8.2.2 [istringstream.assign]
+ 27.8.2.3 [istringstream.members]
+ 27.8.3 [ostringstream]
+ 27.8.3.1 [ostringstream.cons]
+ 27.8.3.2 [ostringstream.assign]
+ 27.8.3.3 [ostringstream.members]
+ 27.8.4 [stringstream]
+ 27.8.5 [stringstream.cons]
+ 27.8.5.1 [stringstream.assign]
+ 27.8.6 [stringstream.members]
+ 27.9 [file.streams]
+ 27.9.1 [fstreams]
+ 27.9.1.1 [filebuf]
+ 27.9.1.2 [filebuf.cons]
+ 27.9.1.3 [filebuf.assign]
+ 27.9.1.4 [filebuf.members]
+ 27.9.1.5 [filebuf.virtuals]
+ 27.9.1.6 [ifstream]
+ 27.9.1.7 [ifstream.cons]
+ 27.9.1.8 [ifstream.assign]
+ 27.9.1.9 [ifstream.members]
+ 27.9.1.10 [ofstream]
+ 27.9.1.11 [ofstream.cons]
+ 27.9.1.12 [ofstream.assign]
+ 27.9.1.13 [ofstream.members]
+ 27.9.1.14 [fstream]
+ 27.9.1.15 [fstream.cons]
+ 27.9.1.16 [fstream.assign]
+ 27.9.1.17 [fstream.members]
+ 27.9.2 [c.files]
+28 [re]
+ 28.1 [re.general]
+ 28.2 [re.def]
+ 28.2.1 [defns.regex.collating.element]
+ 28.2.2 [defns.regex.finite.state.machine]
+ 28.2.3 [defns.regex.format.specifier]
+ 28.2.4 [defns.regex.matched]
+ 28.2.5 [defns.regex.primary.equivalence.class]
+ 28.2.6 [defns.regex.regular.expression]
+ 28.2.7 [defns.regex.subexpression]
+ 28.3 [re.req]
+ 28.4 [re.syn]
+ 28.5 [re.const]
+ 28.5.1 [re.synopt]
+ 28.5.2 [re.matchflag]
+ 28.5.3 [re.err]
+ 28.6 [re.badexp]
+ 28.7 [re.traits]
+ 28.8 [re.regex]
+ 28.8.1 [re.regex.const]
+ 28.8.2 [re.regex.construct]
+ 28.8.3 [re.regex.assign]
+ 28.8.4 [re.regex.operations]
+ 28.8.5 [re.regex.locale]
+ 28.8.6 [re.regex.swap]
+ 28.8.7 [re.regex.nonmemb]
+ 28.8.7.1 [re.regex.nmswap]
+ 28.9 [re.submatch]
+ 28.9.1 [re.submatch.members]
+ 28.9.2 [re.submatch.op]
+ 28.9.3 [re.submatch.concepts]
+ 28.10 [re.results]
+ 28.10.1 [re.results.const]
+ 28.10.2 [re.results.size]
+ 28.10.3 [re.results.acc]
+ 28.10.4 [re.results.form]
+ 28.10.5 [re.results.all]
+ 28.10.6 [re.results.swap]
+ 28.10.7 [re.results.nonmember]
+ 28.11 [re.alg]
+ 28.11.1 [re.except]
+ 28.11.2 [re.alg.match]
+ 28.11.3 [re.alg.search]
+ 28.11.4 [re.alg.replace]
+ 28.12 [re.iter]
+ 28.12.1 [re.regiter]
+ 28.12.1.1 [re.regiter.cnstr]
+ 28.12.1.2 [re.regiter.comp]
+ 28.12.1.3 [re.regiter.deref]
+ 28.12.1.4 [re.regiter.incr]
+ 28.12.2 [re.tokiter]
+ 28.12.2.1 [re.tokiter.cnstr]
+ 28.12.2.2 [re.tokiter.comp]
+ 28.12.2.3 [re.tokiter.deref]
+ 28.12.2.4 [re.tokiter.incr]
+ 28.13 [re.grammar]
+29 [atomics]
+ 29.1 [atomics.general]
+ 29.2 [atomics.syn]
+ 29.3 [atomics.order]
+ 29.4 [atomics.lockfree]
+ 29.5 [atomics.types]
+ 29.5.1 [atomics.types.integral]
+ 29.5.2 [atomics.types.address]
+ 29.5.3 [atomics.types.generic]
+ 29.6 [atomics.types.operations]
+ 29.7 [atomics.flag]
+ 29.8 [atomics.fences]
+30 [thread]
+ 30.1 [thread.general]
+ 30.2 [thread.req]
+ 30.2.1 [thread.req.paramname]
+ 30.2.2 [thread.req.exception]
+ 30.2.3 [thread.req.native]
+ 30.2.4 [thread.req.timing]
+ 30.3 [thread.threads]
+ 30.3.1 [thread.thread.class]
+ 30.3.1.1 [thread.thread.id]
+ 30.3.1.2 [thread.thread.constr]
+ 30.3.1.3 [thread.thread.destr]
+ 30.3.1.4 [thread.thread.assign]
+ 30.3.1.5 [thread.thread.member]
+ 30.3.1.6 [thread.thread.static]
+ 30.3.1.7 [thread.thread.algorithm]
+ 30.3.2 [thread.thread.this]
+ 30.4 [thread.mutex]
+ 30.4.1 [thread.mutex.requirements]
+ 30.4.1.1 [thread.mutex.class]
+ 30.4.1.2 [thread.mutex.recursive]
+ 30.4.2 [thread.timedmutex.requirements]
+ 30.4.2.1 [thread.timedmutex.class]
+ 30.4.2.2 [thread.timedmutex.recursive]
+ 30.4.3 [thread.lock]
+ 30.4.3.1 [thread.lock.guard]
+ 30.4.3.2 [thread.lock.unique]
+ 30.4.3.2.1 [thread.lock.unique.cons]
+ 30.4.3.2.2 [thread.lock.unique.locking]
+ 30.4.3.2.3 [thread.lock.unique.mod]
+ 30.4.3.2.4 [thread.lock.unique.obs]
+ 30.4.4 [thread.lock.algorithm]
+ 30.4.5 [thread.once]
+ 30.4.5.1 [thread.once.onceflag]
+ 30.4.5.2 [thread.once.callonce]
+ 30.5 [thread.condition]
+ 30.5.1 [thread.condition.condvar]
+ 30.5.2 [thread.condition.condvarany]
+ 30.6 [futures]
+ 30.6.1 [futures.overview]
+ 30.6.2 [futures.errors]
+ 30.6.3 [futures.future_error]
+ 30.6.4 [futures.promise]
+ 30.6.5 [futures.unique_future]
+ 30.6.6 [future.shared_future]
+ 30.6.7 [futures.task]
+A [gram]
+ A.1 [gram.key]
+ A.2 [gram.lex]
+ A.3 [gram.basic]
+ A.4 [gram.expr]
+ A.5 [gram.stmt]
+ A.6 [gram.dcl]
+ A.7 [gram.decl]
+ A.8 [gram.class]
+ A.9 [gram.derived]
+ A.10 [gram.special]
+ A.11 [gram.over]
+ A.12 [gram.temp]
+ A.13 [gram.except]
+ A.14 [gram.cpp]
+B [implimits]
+C [diff]
+ C.1 [diff.iso]
+ C.1.1 [diff.lex]
+ C.1.2 [diff.basic]
+ C.1.3 [diff.expr]
+ C.1.4 [diff.stat]
+ C.1.5 [diff.dcl]
+ C.1.6 [diff.decl]
+ C.1.7 [diff.class]
+ C.1.8 [diff.special]
+ C.1.9 [diff.cpp]
+ C.2 [diff.library]
+ C.2.1 [diff.mods.to.headers]
+ C.2.2 [diff.mods.to.definitions]
+ C.2.2.1 [diff.char16]
+ C.2.2.2 [diff.wchar.t]
+ C.2.2.3 [diff.header.iso646.h]
+ C.2.2.4 [diff.null]
+ C.2.3 [diff.mods.to.declarations]
+ C.2.4 [diff.mods.to.behavior]
+ C.2.4.1 [diff.offsetof]
+ C.2.4.2 [diff.malloc]
+D [depr]
+ D.1 [depr.incr.bool]
+ D.2 [depr.static]
+ D.3 [depr.access.dcl]
+ D.4 [depr.string]
+ D.5 [depr.c.headers]
+ D.6 [depr.ios.members]
+ D.7 [depr.str.strstreams]
+ D.7.1 [depr.strstreambuf]
+ D.7.1.1 [depr.strstreambuf.cons]
+ D.7.1.2 [depr.strstreambuf.members]
+ D.7.1.3 [depr.strstreambuf.virtuals]
+ D.7.2 [depr.istrstream]
+ D.7.2.1 [depr.istrstream.cons]
+ D.7.2.2 [depr.istrstream.members]
+ D.7.3 [depr.ostrstream]
+ D.7.3.1 [depr.ostrstream.cons]
+ D.7.3.2 [depr.ostrstream.members]
+ D.7.4 [depr.strstream]
+ D.7.4.1 [depr.strstream.cons]
+ D.7.4.2 [depr.strstream.dest]
+ D.7.4.3 [depr.strstream.oper]
+ D.8 [depr.lib.binders]
+ D.8.1 [depr.lib.binder.1st]
+ D.8.2 [depr.lib.bind.1st]
+ D.8.3 [depr.lib.binder.2nd]
+ D.8.4 [depr.lib.bind.2nd]
+ D.9 [depr.auto.ptr]
+ D.9.1 [auto.ptr]
+ D.9.1.1 [auto.ptr.cons]
+ D.9.1.2 [auto.ptr.members]
+ D.9.1.3 [auto.ptr.conv]
+ D.10 [depr.lib.iterator.primitives]
+ D.10.1 [iterator.traits]
+ D.10.2 [iterator.basic]
+ D.10.3 [std.iterator.tags]
+ D.10.4 [iterator.backward]
+E [xref]
+
+TR1 1 [tr.intro]
+ TR1 1.1 [tr.description]
+ TR1 1.2 [tr.intro.ext]
+ TR1 1.3 [tr.intro.namespaces]
+TR1 2 [tr.util]
+ TR1 2.1 [tr.util.refwrap]
+ TR1 2.1.1 [tr.util.refwrp.synopsis]
+ TR1 2.1.2 [tr.util.refwrp.refwrp]
+ TR1 2.1.2.1 [tr.util.refwrp.const]
+ TR1 2.1.2.2 [tr.util.refwrp.assign]
+ TR1 2.1.2.3 [tr.util.refwrp.access]
+ TR1 2.1.2.4 [tr.util.refwrp.invoke]
+ TR1 2.1.2.5 [tr.util.refwrp.helpers]
+ TR1 2.2 [tr.util.smartptr]
+ TR1 2.2.1 [tr.util.smartptr.synopsis]
+ TR1 2.2.2 [tr.util.smartptr.weakptr]
+ TR1 2.2.3 [tr.util.smartptr.shared]
+ TR1 2.2.3.1 [tr.util.smartptr.shared.const]
+ TR1 2.2.3.2 [tr.util.smartptr.shared.dest]
+ TR1 2.2.3.3 [tr.util.smartptr.shared.assign]
+ TR1 2.2.3.4 [tr.util.smartptr.shared.mod]
+ TR1 2.2.3.5 [tr.util.smartptr.shared.obs]
+ TR1 2.2.3.6 [tr.util.smartptr.shared.cmp]
+ TR1 2.2.3.7 [tr.util.smartptr.shared.io]
+ TR1 2.2.3.8 [tr.util.smartptr.shared.spec]
+ TR1 2.2.3.9 [tr.util.smartptr.shared.cast]
+ TR1 2.2.3.10 [tr.util.smartptr.getdeleter]
+ TR1 2.2.4 [tr.util.smartptr.weak]
+ TR1 2.2.4.1 [tr.util.smartptr.weak.const]
+ TR1 2.2.4.2 [tr.util.smartptr.weak.dest]
+ TR1 2.2.4.3 [tr.util.smartptr.weak.assign]
+ TR1 2.2.4.4 [tr.util.smartptr.weak.mod]
+ TR1 2.2.4.5 [tr.util.smartptr.weak.obs]
+ TR1 2.2.4.6 [tr.util.smartptr.weak.cmp]
+ TR1 2.2.4.7 [tr.util.smartptr.weak.spec]
+ TR1 2.2.5 [tr.util.smartptr.enab]
+TR1 3 [tr.func]
+ TR1 3.1 [tr.func.def]
+ TR1 3.2 [tr.func.syn]
+ TR1 3.3 [tr.func.require]
+ TR1 3.4 [tr.func.ret]
+ TR1 3.5 [tr.func.memfn]
+ TR1 3.6 [tr.func.bind]
+ TR1 3.6.1 [tr.func.bind.isbind]
+ TR1 3.6.2 [tr.func.bind.isplace]
+ TR1 3.6.3 [tr.func.bind.bind]
+ TR1 3.6.4 [tr.func.bind.place]
+ TR1 3.7 [tr.func.wrap]
+ TR1 3.7.1 [tr.func.wrap.badcall]
+ TR1 3.7.1.1 [tr.func.wrap.badcall.const]
+ TR1 3.7.2 [tr.func.wrap.func]
+ TR1 3.7.2.1 [tr.func.wrap.func.con]
+ TR1 3.7.2.2 [tr.func.wrap.func.mod]
+ TR1 3.7.2.3 [tr.func.wrap.func.cap]
+ TR1 3.7.2.4 [tr.func.wrap.func.inv]
+ TR1 3.7.2.5 [tr.func.wrap.func.targ]
+ TR1 3.7.2.6 [tr.func.wrap.func.undef]
+ TR1 3.7.2.7 [tr.func.wrap.func.nullptr]
+ TR1 3.7.2.8 [tr.func.wrap.func.alg]
+TR1 4 [tr.meta]
+ TR1 4.1 [tr.meta.rqmts]
+ TR1 4.2 [tr.meta.type.synop]
+ TR1 4.3 [tr.meta.help]
+ TR1 4.4 [tr.meta.requirements]
+ TR1 4.5 [tr.meta.unary]
+ TR1 4.5.1 [tr.meta.unary.cat]
+ TR1 4.5.2 [tr.meta.unary.comp]
+ TR1 4.5.3 [tr.meta.unary.prop]
+ TR1 4.6 [tr.meta.rel]
+ TR1 4.7 [tr.meta.trans]
+ TR1 4.7.1 [tr.meta.trans.cv]
+ TR1 4.7.2 [tr.meta.trans.ref]
+ TR1 4.7.3 [tr.meta.trans.arr]
+ TR1 4.7.4 [tr.meta.trans.ptr]
+ TR1 4.8 [tr.meta.trans.other]
+ TR1 4.9 [tr.meta.req]
+TR1 5 [tr.num]
+ TR1 5.1 [tr.rand]
+ TR1 5.1.1 [tr.rand.req]
+ TR1 5.1.2 [tr.rand.synopsis]
+ TR1 5.1.3 [tr.rand.var]
+ TR1 5.1.4 [tr.rand.eng]
+ TR1 5.1.4.1 [tr.rand.eng.lcong]
+ TR1 5.1.4.2 [tr.rand.eng.mers]
+ TR1 5.1.4.3 [tr.rand.eng.sub]
+ TR1 5.1.4.4 [tr.rand.eng.sub1]
+ TR1 5.1.4.5 [tr.rand.eng.disc]
+ TR1 5.1.4.6 [tr.rand.eng.xor]
+ TR1 5.1.5 [tr.rand.predef]
+ TR1 5.1.6 [tr.rand.device]
+ TR1 5.1.7 [tr.rand.dist]
+ TR1 5.1.7.1 [tr.rand.dist.iunif]
+ TR1 5.1.7.2 [tr.rand.dist.bern]
+ TR1 5.1.7.3 [tr.rand.dist.geom]
+ TR1 5.1.7.4 [tr.rand.dist.pois]
+ TR1 5.1.7.5 [tr.rand.dist.bin]
+ TR1 5.1.7.6 [tr.rand.dist.runif]
+ TR1 5.1.7.7 [tr.rand.dist.exp]
+ TR1 5.1.7.8 [tr.rand.dist.norm]
+ TR1 5.1.7.9 [tr.rand.dist.gamma]
+ TR1 5.2 [tr.num.sf]
+ TR1 5.2.1 [tr.num.sf.cmath]
+ TR1 5.2.1.1 [tr.num.sf.Lnm]
+ TR1 5.2.1.2 [tr.num.sf.Plm]
+ TR1 5.2.1.3 [tr.num.sf.beta]
+ TR1 5.2.1.4 [tr.num.sf.ellK]
+ TR1 5.2.1.5 [tr.num.sf.ellEx]
+ TR1 5.2.1.6 [tr.num.sf.ellPx]
+ TR1 5.2.1.7 [tr.num.sf.conhyp]
+ TR1 5.2.1.8 [tr.num.sf.I]
+ TR1 5.2.1.9 [tr.num.sf.J]
+ TR1 5.2.1.10 [tr.num.sf.K]
+ TR1 5.2.1.11 [tr.num.sf.N]
+ TR1 5.2.1.12 [tr.num.sf.ellF]
+ TR1 5.2.1.13 [tr.num.sf.ellE]
+ TR1 5.2.1.14 [tr.num.sf.ellP]
+ TR1 5.2.1.15 [tr.num.sf.ei]
+ TR1 5.2.1.16 [tr.num.sf.Hn]
+ TR1 5.2.1.17 [tr.num.sf.hyper]
+ TR1 5.2.1.18 [tr.num.sf.Ln]
+ TR1 5.2.1.19 [tr.num.sf.Pl]
+ TR1 5.2.1.20 [tr.num.sf.riemannzeta]
+ TR1 5.2.1.21 [tr.num.sf.j]
+ TR1 5.2.1.22 [tr.num.sf.Ylm]
+ TR1 5.2.1.23 [tr.num.sf.n]
+ TR1 5.2.2 [tr.num.sf.mathh]
+TR1 6 [tr.cont]
+ TR1 6.1 [tr.tuple]
+ TR1 6.1.1 [tr.tuple.synopsis]
+ TR1 6.1.2 [tr.tuple.synopsis.pair]
+ TR1 6.1.3 [tr.tuple.tuple]
+ TR1 6.1.3.1 [tr.tuple.cnstr]
+ TR1 6.1.3.2 [tr.tuple.creation]
+ TR1 6.1.3.3 [tr.tuple.helper]
+ TR1 6.1.3.4 [tr.tuple.elem]
+ TR1 6.1.3.5 [tr.tuple.rel]
+ TR1 6.1.4 [tr.tuple.pairs]
+ TR1 6.2 [tr.array]
+ TR1 6.2.1 [tr.array.syn]
+ TR1 6.2.2 [tr.array.array]
+ TR1 6.2.2.1 [tr.array.cons]
+ TR1 6.2.2.2 [tr.array.special]
+ TR1 6.2.2.3 [tr.array.size]
+ TR1 6.2.2.4 [tr.array.zero]
+ TR1 6.2.2.5 [tr.array.tuple]
+ TR1 6.3 [tr.hash]
+ TR1 6.3.1 [tr.unord.req]
+ TR1 6.3.1.1 [tr.unord.req.except]
+ TR1 6.3.2 [tr.unord.fun.syn]
+ TR1 6.3.3 [tr.unord.hash]
+ TR1 6.3.4 [tr.unord.unord]
+ TR1 6.3.4.1 [tr.unord.syn.set]
+ TR1 6.3.4.2 [tr.unord.syn.map]
+ TR1 6.3.4.3 [tr.unord.set]
+ TR1 6.3.4.3.1 [tr.unord.set.cnstr]
+ TR1 6.3.4.3.2 [tr.unord.set.swap]
+ TR1 6.3.4.4 [tr.unord.map]
+ TR1 6.3.4.4.1 [tr.unord.map.cnstr]
+ TR1 6.3.4.4.2 [tr.unord.map.elem]
+ TR1 6.3.4.4.3 [tr.unord.map.swap]
+ TR1 6.3.4.5 [tr.unord.multiset]
+ TR1 6.3.4.5.1 [tr.unord.multiset.cnstr]
+ TR1 6.3.4.5.2 [tr.unord.multiset.swap]
+ TR1 6.3.4.6 [tr.unord.multimap]
+ TR1 6.3.4.6.1 [tr.unord.multimap.cnstr]
+ TR1 6.3.4.6.2 [tr.unord.multimap.swap]
+TR1 7 [tr.re]
+ TR1 7.1 [tr.re.def]
+ TR1 7.2 [tr.re.req]
+ TR1 7.3 [tr.re.sum]
+ TR1 7.4 [tr.re.syn]
+ TR1 7.5 [tr.re.const]
+ TR1 7.5.1 [tr.re.synopt]
+ TR1 7.5.2 [tr.re.matchflag]
+ TR1 7.5.3 [tr.re.err]
+ TR1 7.6 [tr.re.badexp]
+ TR1 7.7 [tr.re.traits]
+ TR1 7.8 [tr.re.regex]
+ TR1 7.8.1 [tr.re.regex.const]
+ TR1 7.8.2 [tr.re.regex.construct]
+ TR1 7.8.3 [tr.re.regex.assign]
+ TR1 7.8.4 [tr.re.regex.operations]
+ TR1 7.8.5 [tr.re.regex.locale]
+ TR1 7.8.6 [tr.re.regex.swap]
+ TR1 7.8.7 [tr.re.regex.nonmemb]
+ TR1 7.8.7.1 [tr.re.regex.nmswap.]
+ TR1 7.9 [tr.re.submatch]
+ TR1 7.9.1 [tr.re.submatch.members]
+ TR1 7.9.2 [tr.re.submatch.op]
+ TR1 7.10 [tr.re.results]
+ TR1 7.10.1 [tr.re.results.const]
+ TR1 7.10.2 [tr.re.results.size]
+ TR1 7.10.3 [tr.re.results.acc]
+ TR1 7.10.4 [tr.re.results.form]
+ TR1 7.10.5 [tr.re.results.all]
+ TR1 7.10.1 [tr.re.results.swap]
+ TR1 7.11 [tr.re.alg]
+ TR1 7.11.1 [tr.re.except]
+ TR1 7.11.2 [tr.re.alg.match]
+ TR1 7.11.3 [tr.re.alg.search]
+ TR1 7.11.4 [tr.re.alg.replace]
+ TR1 7.12 [tr.re.iter]
+ TR1 7.12.1 [tr.re.regiter]
+ TR1 7.12.1.1 [tr.re.regiter.cnstr]
+ TR1 7.12.1.2 [tr.re.regiter.comp]
+ TR1 7.12.1.3 [tr.re.regiter.deref]
+ TR1 7.12.1.4 [tr.re.regiter.incr]
+ TR1 7.12.2 [tr.re.tokiter]
+ TR1 7.12.2.1 [tr.re.tokiter.cnstr]
+ TR1 7.12.2.2 [tr.re.tokiter.comp]
+ TR1 7.12.2.3 [tr.re.tokiter.deref]
+ TR1 7.12.2.4 [tr.re.tokiter.incr]
+ TR1 7.13 [tr.re.grammar]
+TR1 8 [tr.c99]
+ TR1 8.1 [tr.c99.cmplx]
+ TR1 8.1.1 [tr.c99.cmplx.syn]
+ TR1 8.1.2 [tr.c99.cmplx.acos]
+ TR1 8.1.3 [tr.c99.cmplx.asin]
+ TR1 8.1.4 [tr.c99.cmplx.atan]
+ TR1 8.1.5 [tr.c99.cmplx.acosh]
+ TR1 8.1.6 [tr.c99.cmplx.asinh]
+ TR1 8.1.7 [tr.c99.cmplx.atanh]
+ TR1 8.1.8 [tr.c99.cmplx.fabs]
+ TR1 8.1.9 [tr.c99.cmplx.over]
+ TR1 8.2 [tr.c99.ccmplx]
+ TR1 8.3 [tr.c99.cmplxh]
+ TR1 8.4 [tr.c99.cctype]
+ TR1 8.4.1 [tr.c99.cctype.syn]
+ TR1 8.4.2 [tr.c99.cctype.blank]
+ TR1 8.5 [tr.c99.ctypeh]
+ TR1 8.6 [tr.c99.cfenv]
+ TR1 8.6.1 [tr.c99.cfenv.syn]
+ TR1 8.6.2 [tr.c99.cfenv.def]
+ TR1 8.7 [tr.c99.fenv]
+ TR1 8.8 [tr.c99.cfloat]
+ TR1 8.9 [tr.c99.floath]
+ TR1 8.10 [tr.c99.ios]
+ TR1 8.10.1 [tr.c99.ios.syn]
+ TR1 8.10.2 [tr.c99.ios.hex]
+ TR1 8.11 [tr.c99.cinttypes]
+ TR1 8.11.1 [tr.c99.cinttypes.syn]
+ TR1 8.11.2 [tr.c99.cinttypes.def]
+ TR1 8.12 [tr.c99.inttypesh]
+ TR1 8.13 [tr.c99.climits]
+ TR1 8.14 [tr.c99.limitsh]
+ TR1 8.15 [tr.c99.locale]
+ TR1 8.16 [tr.c99.cmath]
+ TR1 8.16.1 [tr.c99.cmath.syn]
+ TR1 8.16.2 [tr.c99.cmath.def]
+ TR1 8.16.3 [tr.c99.cmath.tmpl]
+ TR1 8.16.4 [tr.c99.cmath.over]
+ TR1 8.17 [tr.c99.mathh]
+ TR1 8.18 [tr.c99.cstdarg]
+ TR1 8.19 [tr.c99.stdargh]
+ TR1 8.20 [tr.c99.cbool]
+ TR1 8.21 [tr.c99.boolh]
+ TR1 8.22 [tr.c99.cstdint]
+ TR1 8.22.1 [tr.c99.cstdint.syn]
+ TR1 8.22.2 [tr.c99.cstdint.def]
+ TR1 8.23 [tr.c99.stdinth]
+ TR1 8.24 [tr.c99.cstdio]
+ TR1 8.24.1 [tr.c99.cstdio.syn]
+ TR1 8.24.2 [tr.c99.cstdio.def]
+ TR1 8.24.3 [tr.c99.cstdio.spec]
+ TR1 8.24.4 [tr.c99.stdioh]
+ TR1 8.25 [tr.c99.cstdlib]
+ TR1 8.25.1 [tr.c99.cstdlib.syn]
+ TR1 8.25.2 [tr.c99.cstdlib.def]
+ TR1 8.25.3 [tr.c99.cstdlib.abs]
+ TR1 8.25.4 [tr.c99.cstdlib.div]
+ TR1 8.26 [tr.c99.stdlibh]
+ TR1 8.27 [tr.c99.ctgmath]
+ TR1 8.28 [tr.c99.tgmathh]
+ TR1 8.29 [tr.c99.ctime]
+ TR1 8.30 [tr.c99.cwchar]
+ TR1 8.30.1 [tr.c99.cwchar.syn]
+ TR1 8.30.2 [tr.c99.cwchar.def]
+ TR1 8.30.3 [tr.c99.cwchar.spec]
+ TR1 8.31 [tr.c99.wcharh]
+ TR1 8.32 [tr.c99.cwctype]
+ TR1 8.32.1 [tr.c99.cwctype.syn]
+ TR1 8.32.2 [tr.c99.cwctype.iswblank]
+ TR1 8.33 [tr.c99.wctypeh]
+TR1 A [tr.limits]
+
+TRDecimal 1 [trdec.intro]
+ TRDecimal 1.1 [trdec.model]
+ TRDecimal 1.2 [trdec.encodings]
+ TRDecimal 1.3 [trdec.refs]
+TRDecimal 2 [trdec.conventions]
+ TRDecimal 2.1 [trdec.relation.intro]
+ TRDecimal 2.2 [trdec.relation.tr1]
+ TRDecimal 2.3 [trdec.categories]
+ TRDecimal 2.4 [trdec.namespace]
+TRDecimal 3 [trdec.types]
+ TRDecimal 3.1 [trdec.types.encodings]
+ TRDecimal 3.2 [trdec.types.types]
+ TRDecimal 3.2.1 [trdec.types.types.synopsis]
+ TRDecimal 3.2.2 [trdec.types.types.decimal32]
+ TRDecimal 3.2.2.1 [trdec.types.types.decimal32.cons]
+ TRDecimal 3.2.2.2 [trdec.types.types.decimal32.conv.float]
+ TRDecimal 3.2.2.3 [trdec.types.types.decimal32.conv.from.int]
+ TRDecimal 3.2.2.4 [trdec.types.types.decimal32.conv.to.int]
+ TRDecimal 3.2.2.5 [trdec.types.types.decimal32.incr]
+ TRDecimal 3.2.2.6 [trdec.types.types.decimal32.comp.ass]
+ TRDecimal 3.2.3 [trdec.types.types.decimal64]
+ TRDecimal 3.2.3.1 [trdec.types.types.decimal64.cons]
+ TRDecimal 3.2.3.2 [trdec.types.types.decimal64.float]
+ TRDecimal 3.2.3.3 [trdec.types.types.decimal64.from.int]
+ TRDecimal 3.2.3.4 [trdec.types.types.decimal64.to.int]
+ TRDecimal 3.2.3.5 [trdec.types.types.decimal64.incr]
+ TRDecimal 3.2.3.6 [trdec.types.types.decimal64.comp.ass]
+ TRDecimal 3.2.4 [trdec.types.types.decimal128]
+ TRDecimal 3.2.4.1 [trdec.types.types.decimal128.cons]
+ TRDecimal 3.2.4.2 [trdec.types.types.decimal128.float]
+ TRDecimal 3.2.4.3 [trdec.types.types.decimal128.from.int]
+ TRDecimal 3.2.4.4 [trdec.types.types.decimal128.to.int]
+ TRDecimal 3.2.4.5 [trdec.types.types.decimal128.incr]
+ TRDecimal 3.2.4.6 [trdec.types.types.decimal128.comp.ass]
+ TRDecimal 3.2.5 [trdec.types.types.init]
+ TRDecimal 3.2.6 [trdec.types.types.conv.float]
+ TRDecimal 3.2.7 [trdec.types.types.unary]
+ TRDecimal 3.2.8 [trdec.types.types.binary]
+ TRDecimal 3.2.9 [trdec.types.types.comp]
+ TRDecimal 3.2.10 [trdec.types.types.input]
+ TRDecimal 3.2.11 [trdec.types.types.output]
+ TRDecimal 3.3 [trdec.types.limits]
+ TRDecimal 3.4 [trdec.types.cdecfloat]
+ TRDecimal 3.4.1 [trdec.types.cdecfloat.synopsis]
+ TRDecimal 3.4.2 [trdec.types.decfloat.h.synopsis]
+ TRDecimal 3.4.3 [trdec.types.cdecfloat.max.value]
+ TRDecimal 3.4.4 [trdec.types.cdecfloat.epsilon]
+ TRDecimal 3.4.5 [trdec.types.cdecfloat.min.normal.value]
+ TRDecimal 3.4.6 [trdec.types.cdecfloat.min.subnormal.value]
+ TRDecimal 3.4.7 [trdec.types.cdecfloat.eval.format]
+ TRDecimal 3.5 [trdec.types.cfenv]
+ TRDecimal 3.5.1 [trdec.types.cfenv.synopsis]
+ TRDecimal 3.5.2 [trdec.types.cfenv.round]
+ TRDecimal 3.5.3 [trdec.types.cfenv.fe_dec_getround]
+ TRDecimal 3.5.4 [trdec.types.cfenv.fe_dec_setround]
+ TRDecimal 3.5.5 [trdec.types.cfenv.fenv.h]
+ TRDecimal 3.6 [trdec.types.cmath]
+ TRDecimal 3.6.1 [trdec.types.cmath.synopsis]
+ TRDecimal 3.6.2 [trdec.types.cmath.macros]
+ TRDecimal 3.6.3 [trdec.types.cmath.eval.format]
+ TRDecimal 3.6.4 [trdec.types.cmath.samequantum]
+ TRDecimal 3.6.5 [trdec.types.cmath.quantize]
+ TRDecimal 3.6.6 [trdec.types.cmath.elementary]
+ TRDecimal 3.6.6.1 [trdec.types.cmath.elementary.abs]
+ TRDecimal 3.6.7 [trdec.types.cmath.math.h]
+ TRDecimal 3.6.7.1 [trdec.types.cmath.math.h.synopsis]
+ TRDecimal 3.7 [trdec.types.cstdio]
+ TRDecimal 3.8 [trdec.types.cstdlib]
+ TRDecimal 3.8.1 [trdec.types.cstdlib.synopsis]
+ TRDecimal 3.8.2 [trdec.types.cstdlib.strtod]
+ TRDecimal 3.8.3 [trdec.types.cstdlib.stdlib.h]
+ TRDecimal 3.9 [trdec.types.cwchar]
+ TRDecimal 3.9.1 [trdec.types.cwchar.synopsis]
+ TRDecimal 3.9.2 [trdec.types.cwchar.wcstod]
+ TRDecimal 3.9.3 [trdec.types.cwchar.wchar.h]
+ TRDecimal 3.10 [trdec.types.facets]
+ TRDecimal 3.10.1 [trdec.types.facets.locale]
+ TRDecimal 3.10.2 [trdec.types.facets.extended_num_get]
+ TRDecimal 3.10.2.1 [trdec.types.facets.extended_num_get.mem]
+ TRDecimal 3.10.2.2 [trdec.types.facets.extended_num_get.virt]
+ TRDecimal 3.10.3 [trdec.types.facets.extended_num_put]
+ TRDecimal 3.10.3.1 [trdec.types.facets.extended_num_put.mem]
+ TRDecimal 3.10.3.2 [trdec.types.facets.extended_num_put.virt]
+ TRDecimal 3.11 [trdec.types.traits]
+ TRDecimal 3.11.1 [trdec.types.traits.synopsis]
+ TRDecimal 3.11.2 [trdec.types.traits.is_decimal_floating_point]
+ TRDecimal 3.12 [trdec.types.hash]
+ TRDecimal 3.12.1 [trdec.types.hash.synopsis]
+ TRDecimal 3.12.2 [trdec.types.hash.spec]
+TRDecimal 4 [trdec.compat]
+ TRDecimal 4.1 [trdec.compat.decfloat.h]
+ TRDecimal 4.2 [trdec.compat.literals]
+ TRDecimal 4.3 [trdec.compat.conv]
diff --git a/clang/test/lit.cfg b/clang/test/lit.cfg
new file mode 100644
index 0000000..738dc38
--- /dev/null
+++ b/clang/test/lit.cfg
@@ -0,0 +1,257 @@
+# -*- Python -*-
+
+import os
+import platform
+import re
+import subprocess
+
+
+# Configuration file for the 'lit' test runner.
+
+# name: The name of this test suite.
+config.name = 'Clang'
+
+# Tweak PATH for Win32
+if platform.system() == 'Windows':
+ # Seek sane tools in directories and set to $PATH.
+ path = getattr(config, 'lit_tools_dir', None)
+ path = lit.getToolsPath(path,
+ config.environment['PATH'],
+ ['cmp.exe', 'grep.exe', 'sed.exe'])
+ if path is not None:
+ path = os.path.pathsep.join((path,
+ config.environment['PATH']))
+ config.environment['PATH'] = path
+
+# testFormat: The test format to use to interpret tests.
+#
+# For now we require '&&' between commands, until they get globally killed and
+# the test runner updated.
+execute_external = (platform.system() != 'Windows'
+ or lit.getBashPath() not in [None, ""])
+config.test_format = lit.formats.ShTest(execute_external)
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s']
+
+# test_source_root: The root path where tests are located.
+config.test_source_root = os.path.dirname(__file__)
+
+# test_exec_root: The root path where tests should be run.
+clang_obj_root = getattr(config, 'clang_obj_root', None)
+if clang_obj_root is not None:
+ config.test_exec_root = os.path.join(clang_obj_root, 'test')
+
+# Set llvm_{src,obj}_root for use by others.
+config.llvm_src_root = getattr(config, 'llvm_src_root', None)
+config.llvm_obj_root = getattr(config, 'llvm_obj_root', None)
+
+# Clear some environment variables that might affect Clang.
+#
+# This first set of vars are read by Clang, but shouldn't affect tests
+# that aren't specifically looking for these features, or are required
+# simply to run the tests at all.
+#
+# FIXME: Should we have a tool that enforces this?
+
+# safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
+# 'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
+# 'IOS_SIMULATOR_DEPLOYMENT_TARGET',
+# 'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
+# 'VC80COMNTOOLS')
+possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
+ 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
+ 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
+ 'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
+ 'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
+ 'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
+ 'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
+ 'LIBCLANG_RESOURCE_USAGE',
+ 'LIBCLANG_CODE_COMPLETION_LOGGING']
+# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
+if platform.system() != 'Windows':
+ possibly_dangerous_env_vars.append('INCLUDE')
+for name in possibly_dangerous_env_vars:
+ if name in config.environment:
+ del config.environment[name]
+
+# Tweak the PATH to include the tools dir and the scripts dir.
+if clang_obj_root is not None:
+ llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
+ if not llvm_tools_dir:
+ lit.fatal('No LLVM tools dir set!')
+ path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
+ config.environment['PATH'] = path
+
+ llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
+ if not llvm_libs_dir:
+ lit.fatal('No LLVM libs dir set!')
+ path = os.path.pathsep.join((llvm_libs_dir,
+ config.environment.get('LD_LIBRARY_PATH','')))
+ config.environment['LD_LIBRARY_PATH'] = path
+
+###
+
+# Check that the object root is known.
+if config.test_exec_root is None:
+ # Otherwise, we haven't loaded the site specific configuration (the user is
+ # probably trying to run on a test file directly, and either the site
+ # configuration hasn't been created by the build system, or we are in an
+ # out-of-tree build situation).
+
+ # Check for 'clang_site_config' user parameter, and use that if available.
+ site_cfg = lit.params.get('clang_site_config', None)
+ if site_cfg and os.path.exists(site_cfg):
+ lit.load_config(config, site_cfg)
+ raise SystemExit
+
+ # Try to detect the situation where we are using an out-of-tree build by
+ # looking for 'llvm-config'.
+ #
+ # FIXME: I debated (i.e., wrote and threw away) adding logic to
+ # automagically generate the lit.site.cfg if we are in some kind of fresh
+ # build situation. This means knowing how to invoke the build system though,
+ # and I decided it was too much magic. We should solve this by just having
+ # the .cfg files generated during the configuration step.
+
+ llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
+ if not llvm_config:
+ lit.fatal('No site specific configuration available!')
+
+ # Get the source and object roots.
+ llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
+ llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
+ clang_src_root = os.path.join(llvm_src_root, "tools", "clang")
+ clang_obj_root = os.path.join(llvm_obj_root, "tools", "clang")
+
+ # Validate that we got a tree which points to here, using the standard
+ # tools/clang layout.
+ this_src_root = os.path.dirname(config.test_source_root)
+ if os.path.realpath(clang_src_root) != os.path.realpath(this_src_root):
+ lit.fatal('No site specific configuration available!')
+
+ # Check that the site specific configuration exists.
+ site_cfg = os.path.join(clang_obj_root, 'test', 'lit.site.cfg')
+ if not os.path.exists(site_cfg):
+ lit.fatal('No site specific configuration available! You may need to '
+ 'run "make test" in your Clang build directory.')
+
+ # Okay, that worked. Notify the user of the automagic, and reconfigure.
+ lit.note('using out-of-tree build at %r' % clang_obj_root)
+ lit.load_config(config, site_cfg)
+ raise SystemExit
+
+###
+
+# Discover the 'clang' and 'clangcc' to use.
+
+import os
+
+def inferClang(PATH):
+ # Determine which clang to use.
+ clang = os.getenv('CLANG')
+
+ # If the user set clang in the environment, definitely use that and don't
+ # try to validate.
+ if clang:
+ return clang
+
+ # Otherwise look in the path.
+ clang = lit.util.which('clang', PATH)
+
+ if not clang:
+ lit.fatal("couldn't find 'clang' program, try setting "
+ "CLANG in your environment")
+
+ return clang
+
+# When running under valgrind, we mangle '-vg' onto the end of the triple so we
+# can check it with XFAIL and XTARGET.
+if lit.useValgrind:
+ config.target_triple += '-vg'
+
+config.clang = inferClang(config.environment['PATH']).replace('\\', '/')
+if not lit.quiet:
+ lit.note('using clang: %r' % config.clang)
+
+# Note that when substituting %clang_cc1 also fill in the include directory of
+# the builtin headers. Those are part of even a freestanding environment, but
+# Clang relies on the driver to locate them.
+def getClangBuiltinIncludeDir(clang):
+ # FIXME: Rather than just getting the version, we should have clang print
+ # out its resource dir here in an easy to scrape form.
+ cmd = subprocess.Popen([clang, '-print-file-name=include'],
+ stdout=subprocess.PIPE)
+ if not cmd.stdout:
+ lit.fatal("Couldn't find the include dir for Clang ('%s')" % clang)
+ return cmd.stdout.read().strip()
+
+config.substitutions.append( ('%clang_cc1', '%s -cc1 -internal-isystem %s'
+ % (config.clang,
+ getClangBuiltinIncludeDir(config.clang))) )
+
+config.substitutions.append( ('%clangxx', ' ' + config.clang +
+ ' -ccc-clang-cxx -ccc-cxx '))
+config.substitutions.append( ('%clang', ' ' + config.clang + ' ') )
+config.substitutions.append( ('%test_debuginfo', ' ' + config.llvm_src_root + '/utils/test_debuginfo.pl ') )
+
+# FIXME: Find nicer way to prohibit this.
+config.substitutions.append(
+ (' clang ', """*** Do not use 'clang' in tests, use '%clang'. ***""") )
+config.substitutions.append(
+ (' clang\+\+ ', """*** Do not use 'clang++' in tests, use '%clangxx'. ***"""))
+config.substitutions.append(
+ (' clang-cc ',
+ """*** Do not use 'clang-cc' in tests, use '%clang_cc1'. ***""") )
+config.substitutions.append(
+ (' clang -cc1 ',
+ """*** Do not use 'clang -cc1' in tests, use '%clang_cc1'. ***""") )
+config.substitutions.append(
+ (' %clang-cc1 ',
+ """*** invalid substitution, use '%clang_cc1'. ***""") )
+
+###
+
+# Set available features we allow tests to conditionalize on.
+#
+# As of 2011.08, crash-recovery tests still do not pass on FreeBSD.
+if platform.system() not in ['FreeBSD']:
+ config.available_features.add('crash-recovery')
+
+# Shell execution
+if platform.system() not in ['Windows'] or lit.getBashPath() != '':
+ config.available_features.add('shell')
+
+# Registered Targets
+def get_llc_props(tool):
+ set_of_targets = set()
+ enable_assertions = False
+
+ cmd = subprocess.Popen([tool, '-version'], stdout=subprocess.PIPE)
+
+ # Parse the stdout to get the list of registered targets.
+ parse_targets = False
+ for line in cmd.stdout:
+ if parse_targets:
+ m = re.match( r'(.*) - ', line)
+ if m is not None:
+ set_of_targets.add(m.group(1).strip() + '-registered-target')
+ else:
+ break
+ elif "Registered Targets:" in line:
+ parse_targets = True
+
+ if re.search(r'with assertions', line):
+ enable_assertions = True
+
+ return {"set_of_targets": set_of_targets,
+ "enable_assertions": enable_assertions}
+
+llc_props = get_llc_props(os.path.join(llvm_tools_dir, 'llc'))
+if len(llc_props['set_of_targets']) > 0:
+ config.available_features.update(llc_props['set_of_targets'])
+else:
+ lit.fatal('No Targets Registered with the LLVM Tools!')
+
+if llc_props['enable_assertions']:
+ config.available_features.add('asserts')
diff --git a/clang/test/lit.site.cfg.in b/clang/test/lit.site.cfg.in
new file mode 100644
index 0000000..df90b81
--- /dev/null
+++ b/clang/test/lit.site.cfg.in
@@ -0,0 +1,21 @@
+## Autogenerated by LLVM/Clang configuration.
+# Do not edit!
+config.llvm_src_root = "@LLVM_SOURCE_DIR@"
+config.llvm_obj_root = "@LLVM_BINARY_DIR@"
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
+config.clang_obj_root = "@CLANG_BINARY_DIR@"
+config.target_triple = "@TARGET_TRIPLE@"
+
+# Support substitution of the tools and libs dirs with user parameters. This is
+# used when we can't determine the tool dir at configuration time.
+try:
+ config.llvm_tools_dir = config.llvm_tools_dir % lit.params
+ config.llvm_libs_dir = config.llvm_libs_dir % lit.params
+except KeyError,e:
+ key, = e.args
+ lit.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
+
+# Let the main config do the real work.
+lit.load_config(config, "@CLANG_SOURCE_DIR@/test/lit.cfg")
diff --git a/clang/test/make_test_dirs.pl b/clang/test/make_test_dirs.pl
new file mode 100755
index 0000000..3a524d2
--- /dev/null
+++ b/clang/test/make_test_dirs.pl
@@ -0,0 +1,27 @@
+#!/usr/bin/perl -w
+#
+# Simple little Perl script that takes the cxx-sections.data file as
+# input and generates a directory structure that mimics the standard's
+# structure.
+use English;
+
+$current_indent_level = -4;
+while ($line = <STDIN>) {
+ $line =~ /^\s*/;
+ $next_indent_level = length($MATCH);
+ if ($line =~ /\[([^\]]*)\]/) {
+ my $section = $1;
+ while ($next_indent_level < $current_indent_level) {
+ chdir("..");
+ $current_indent_level -= 4;
+ }
+
+ if ($next_indent_level == $current_indent_level) {
+ chdir("..");
+ } else {
+ $current_indent_level = $next_indent_level;
+ }
+ mkdir($section);
+ chdir($section);
+ }
+}